{"source_code": "from collections import*\nfrom itertools import*\ns = raw_input()\nds = Counter(s)\nfac = [1 for i in range(100)]\nfor i in range(1, 100):\n fac[i] = fac[i-1] * i\nres = 0\nfor possib in product(*[zip([k] * n, range(1, n+1)) for k, n in ds.items()]):\n possib = list(possib)\n non_zero_sum = sum(v for k, v in possib if k != '0')\n total = sum(v for _, v in possib)\n value = non_zero_sum * fac[total-1]\n for _, v in possib:\n value //= fac[v]\n res += value\nprint(res)", "positive_code": [{"source_code": "s = input()\nocc = [0] * 10\nfor c in s: occ[int(c)]+= 1\n# each digit n which occurred, occurs 1 ~ occ[n] times\n\n# first, ignore leading zeroes\nfrom math import factorial as fact\nfrom itertools import combinations\nfrom collections import Counter\ndef multinomial(L):\n res = fact(sum(L))\n for x in L: res//= fact(x)\n \n if L[0] == 0: return res\n L[0]-= 1\n lead0 = fact(sum(L))\n for x in L: lead0//= fact(x)\n L[0]+= 1\n return res - lead0\n\ndef dfs(i):\n if i == 10: return multinomial(rocc)\n ans = 0\n for j in range(rocc_ini[i], occ[i]+1):\n rocc[i] = j\n ans+= dfs(i+1)\n return ans\n\nrocc = [0]*10\nfor i in range(10):\n if occ[i]: rocc[i]+= 1\nrocc_ini = rocc[:]\nprint(dfs(0))\n\n \n"}, {"source_code": "n=input()\n#print(len(n))\nhsh=[0]*10\nfor i in n:\n hsh[ord(i)-ord('0')]+=1\n#print(hsh)\ndef f(n):\n if(n<2):\n return 1\n else:\n return n*f(n-1)\nans=0\nsea=[]\ndef rec(table):\n val=int(\"\".join(list(map(str,table))))\n if(val not in sea):\n global ans\n #print(table,ans)\n s=1\n t=sum(table)\n for i in range(10):\n s*=f(table[i])\n minus=1\n if(table[0]>0):\n table[0]-=1\n for i in range(10):\n minus*=f(table[i])\n ans+=(f(t)//s-f(t-1)//minus)\n table[0]+=1\n else:\n ans+=(f(t)//s)\n sea.append(val)\n #print(table,ans,s,f(t))\n for i in range(10):\n if(table[i]>1):\n table[i]-=1\n rec(table)\n table[i]+=1\nrec(hsh)\nprint(ans)\n\n"}, {"source_code": "n = input()\nall = [0] * 10\nfor x in n:\n\tall[int(x)]+=1\n\ndp = [0] * 20\ndp[0] = 1\nfor i in range(1, 10):\n\tcur = [0] * 20\n\tif(all[i] > 0):\n\t\tfor le in range(0, 20): \n\t\t\tfac = 1\n\t\t\tzn = 1\n\t\t\tfor kol in range(1, all[i] + 1):\n\t\t\t\tif(le + kol < 20):\n\t\t\t\t\tzn *= le + kol\n\t\t\t\t\tfac *= kol\n\t\t\t\t\tcur[le + kol] += (zn // fac) * dp[le]\n\t\tdp = cur\n\n\ncur = [0] * 20\nif(all[0] > 0):\n\tfor le in range(1, 20):\n\t\tfac = 1\n\t\tzn = 1\n\t\tfor kol in range(1, all[0] + 1):\n\t\t\tif(le + kol < 20):\n\t\t\t\tzn *= (le + kol-1)\n\t\t\t\tfac *= kol\n\t\t\t\tcur[le + kol] += (zn // fac) * dp[le]\n\tdp = cur\n\nprint(sum(dp))\n"}, {"source_code": "N = input()\n\nC = [0]*10\nfor n in N:\n C[int(n)] += 1\n\nmemo = {}\ndef dfs(i, state):\n key = tuple(state)\n if key in memo:\n return memo[key]\n r = 0\n if all(s == 0 or 1 <= t for s, t in zip(C, state)):\n r += 1\n for j in range(10):\n if C[j] - state[j] > 0:\n state[j] += 1\n r += dfs(i+1, state)\n state[j] -= 1\n memo[key] = r\n return r\nstate = [0]*10\nans = 0\nfor i in range(1, 10):\n if C[i] > 0:\n state[i] += 1\n ans += dfs(1, state)\n state[i] -= 1\nprint(ans)"}, {"source_code": "n = input()\ncnt = [0] * 10\nfor d in n:\n cnt[int(d)] += 1\nm = [0] * 10\nans = 0\ndef DFS(i : int):\n global ans\n if i == 10:\n pans = 1\n for j in range(sum(m)):\n pans *= j + 1\n for j in range(10):\n for k in range(m[j]):\n pans //= k + 1\n ans += pans\n if m[0]:\n pans = 1\n for j in range(1, sum(m)):\n pans *= j\n for j in range(10):\n for k in range(m[j] - (j == 0)):\n pans //= k + 1\n ans -= pans\n elif cnt[i] == 0:\n DFS(i + 1)\n else:\n for j in range(0, cnt[i]):\n m[i] = j + 1\n DFS(i + 1)\nDFS(0)\nprint(ans)"}, {"source_code": "from collections import defaultdict as dd\nfrom math import factorial as f\n\ns = input()\n\ncnt = dd(int)\n\nfor i in s:\n cnt[i] += 1\n\nans = 0\n\ndef calc(cur_chr, dem, do_not_take_sum, total, diff):\n global ans\n global cnt\n\n if cur_chr == '9':\n for do_not_take in range(0, cnt[cur_chr] + 1):\n if do_not_take > 0 and do_not_take == cnt[cur_chr]:\n continue\n\n cur_do_not_take_sum = do_not_take_sum + do_not_take\n if cur_do_not_take_sum == total:\n continue\n\n cur_dem = dem * f(cnt[cur_chr] - do_not_take)\n num = f(total - cur_do_not_take_sum)\n\n ans += num // cur_dem * diff\n return\n\n for do_not_take in range(0, cnt[cur_chr] + 1):\n if do_not_take > 0 and do_not_take == cnt[cur_chr]:\n if not(diff == -1 and cur_chr == '0'):\n continue\n calc(chr(ord(cur_chr) + 1), dem * f(cnt[cur_chr] - do_not_take), do_not_take_sum + do_not_take, total, diff)\n\ncalc('0', 1, 0, len(s), 1)\n\nif cnt['0'] != 0:\n cnt['0'] -= 1\n calc('0', 1, 0, len(s) - 1, -1)\n\nprint(ans)\n"}, {"source_code": "# ---------------------------iye ha aam zindegi---------------------------------------------\nimport math\nimport heapq, bisect\nimport sys\nfrom collections import deque, defaultdict\nfrom fractions import Fraction\n\nmod = 10 ** 9 + 7\nmod1 = 998244353\n\n# ------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass TreeNode:\n def __init__(self, k, v):\n self.key = k\n self.value = v\n self.left = None\n self.right = None\n self.parent = None\n self.height = 1\n self.num_left = 1\n self.num_total = 1\n\n\nclass AvlTree:\n\n def __init__(self):\n self._tree = None\n\n def add(self, k, v):\n if not self._tree:\n self._tree = TreeNode(k, v)\n return\n node = self._add(k, v)\n if node:\n self._rebalance(node)\n\n def _add(self, k, v):\n node = self._tree\n while node:\n if k < node.key:\n if node.left:\n node = node.left\n else:\n node.left = TreeNode(k, v)\n node.left.parent = node\n return node.left\n elif node.key < k:\n if node.right:\n node = node.right\n else:\n node.right = TreeNode(k, v)\n node.right.parent = node\n return node.right\n else:\n node.value = v\n return\n\n @staticmethod\n def get_height(x):\n return x.height if x else 0\n\n @staticmethod\n def get_num_total(x):\n return x.num_total if x else 0\n\n def _rebalance(self, node):\n\n n = node\n while n:\n lh = self.get_height(n.left)\n rh = self.get_height(n.right)\n n.height = max(lh, rh) + 1\n balance_factor = lh - rh\n n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)\n n.num_left = 1 + self.get_num_total(n.left)\n\n if balance_factor > 1:\n if self.get_height(n.left.left) < self.get_height(n.left.right):\n self._rotate_left(n.left)\n self._rotate_right(n)\n elif balance_factor < -1:\n if self.get_height(n.right.right) < self.get_height(n.right.left):\n self._rotate_right(n.right)\n self._rotate_left(n)\n else:\n n = n.parent\n\n def _remove_one(self, node):\n \"\"\"\n Side effect!!! Changes node. Node should have exactly one child\n \"\"\"\n replacement = node.left or node.right\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = replacement\n else:\n node.parent.right = replacement\n replacement.parent = node.parent\n node.parent = None\n else:\n self._tree = replacement\n replacement.parent = None\n node.left = None\n node.right = None\n node.parent = None\n self._rebalance(replacement)\n\n def _remove_leaf(self, node):\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = None\n else:\n node.parent.right = None\n self._rebalance(node.parent)\n else:\n self._tree = None\n node.parent = None\n node.left = None\n node.right = None\n\n def remove(self, k):\n node = self._get_node(k)\n if not node:\n return\n if AvlTree._is_leaf(node):\n self._remove_leaf(node)\n return\n if node.left and node.right:\n nxt = AvlTree._get_next(node)\n node.key = nxt.key\n node.value = nxt.value\n if self._is_leaf(nxt):\n self._remove_leaf(nxt)\n else:\n self._remove_one(nxt)\n self._rebalance(node)\n else:\n self._remove_one(node)\n\n def get(self, k):\n node = self._get_node(k)\n return node.value if node else -1\n\n def _get_node(self, k):\n if not self._tree:\n return None\n node = self._tree\n while node:\n if k < node.key:\n node = node.left\n elif node.key < k:\n node = node.right\n else:\n return node\n return None\n\n def get_at(self, pos):\n x = pos + 1\n node = self._tree\n while node:\n if x < node.num_left:\n node = node.left\n elif node.num_left < x:\n x -= node.num_left\n node = node.right\n else:\n return (node.key, node.value)\n raise IndexError(\"Out of ranges\")\n\n @staticmethod\n def _is_left(node):\n return node.parent.left and node.parent.left == node\n\n @staticmethod\n def _is_leaf(node):\n return node.left is None and node.right is None\n\n def _rotate_right(self, node):\n if not node.parent:\n self._tree = node.left\n node.left.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.left\n node.left.parent = node.parent\n else:\n node.parent.right = node.left\n node.left.parent = node.parent\n bk = node.left.right\n node.left.right = node\n node.parent = node.left\n node.left = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n def _rotate_left(self, node):\n if not node.parent:\n self._tree = node.right\n node.right.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.right\n node.right.parent = node.parent\n else:\n node.parent.right = node.right\n node.right.parent = node.parent\n bk = node.right.left\n node.right.left = node\n node.parent = node.right\n node.right = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n @staticmethod\n def _get_next(node):\n if not node.right:\n return node.parent\n n = node.right\n while n.left:\n n = n.left\n return n\navl=AvlTree()\n#-----------------------------------------------binary seacrh tree---------------------------------------\nclass SegmentTree1:\n def __init__(self, data, default='z', func=lambda a, b: min(a ,b)):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass SegmentTree:\n def __init__(self, data, default=0, func=lambda a, b: a + b):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------------------iye ha chutiya zindegi-------------------------------------\nclass Factorial:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorials = [1, 1]\n self.invModulos = [0, 1]\n self.invFactorial_ = [1, 1]\n\n def calc(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.factorials):\n return self.factorials[n]\n nextArr = [0] * (n + 1 - len(self.factorials))\n initialI = len(self.factorials)\n prev = self.factorials[-1]\n m = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = prev * i % m\n self.factorials += nextArr\n return self.factorials[n]\n\n def inv(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n^(-1)\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n p = self.MOD\n pi = n % p\n if pi < len(self.invModulos):\n return self.invModulos[pi]\n nextArr = [0] * (n + 1 - len(self.invModulos))\n initialI = len(self.invModulos)\n for i in range(initialI, min(p, n + 1)):\n next = -self.invModulos[p % i] * (p // i) % p\n self.invModulos.append(next)\n return self.invModulos[pi]\n\n def invFactorial(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate (n^(-1))!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.invFactorial_):\n return self.invFactorial_[n]\n self.inv(n) # To make sure already calculated n^-1\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\n initialI = len(self.invFactorial_)\n prev = self.invFactorial_[-1]\n p = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\n self.invFactorial_ += nextArr\n return self.invFactorial_[n]\n\n\nclass Combination:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorial = Factorial(MOD)\n\n def ncr(self, n, k):\n if k < 0 or n < k:\n return 0\n k = min(k, n - k)\n f = self.factorial\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\n\n\n# --------------------------------------iye ha combinations ka zindegi---------------------------------\ndef powm(a, n, m):\n if a == 1 or n == 0:\n return 1\n if n % 2 == 0:\n s = powm(a, n // 2, m)\n return s * s % m\n else:\n return a * powm(a, n - 1, m) % m\n\n\n# --------------------------------------iye ha power ka zindegi---------------------------------\ndef sort_list(list1, list2):\n zipped_pairs = zip(list2, list1)\n\n z = [x for _, x in sorted(zipped_pairs)]\n\n return z\n\n\n# --------------------------------------------------product----------------------------------------\ndef product(l):\n por = 1\n for i in range(len(l)):\n por *= l[i]\n return por\n\n\n# --------------------------------------------------binary----------------------------------------\ndef binarySearchCount(arr, n, key):\n left = 0\n right = n - 1\n\n count = 0\n\n while (left <= right):\n mid = int((right + left)/ 2)\n\n # Check if middle element is\n # less than or equal to key\n if (arr[mid]<=key):\n count = mid+1\n left = mid + 1\n\n # If key is smaller, ignore right half\n else:\n right = mid - 1\n\n return count\n\n\n# --------------------------------------------------binary----------------------------------------\ndef countdig(n):\n c = 0\n while (n > 0):\n n //= 10\n c += 1\n return c\n\n\ndef countGreater( arr,n, k):\n l = 0\n r = n - 1\n\n # Stores the index of the left most element\n # from the array which is greater than k\n leftGreater = n\n\n # Finds number of elements greater than k\n while (l <= r):\n m = int(l + (r - l) / 2)\n if (arr[m] >= k):\n leftGreater = m\n r = m - 1\n\n # If mid element is less than\n # or equal to k update l\n else:\n l = m + 1\n\n # Return the count of elements\n # greater than k\n return (n - leftGreater)\n\n\n# --------------------------------------------------binary------------------------------------\nl=[]\ndef fact(t):\n r=1\n for i in range(1,t+1):\n r*=i\n return r\ndef calc(d,t,s,r,ans,k):\n if t==len(l):\n if k>0:\n ans+=(fact(s-1)*(s-k))//r\n else:\n ans+=fact(s)//r\n #print(s,r,ans)\n return ans\n for i in range(d[l[t]]):\n if l[t]==0:\n k=i+1\n ans=calc(d,t+1,s+i+1,r*fact(i+1),ans,k)\n return ans\nn=input()\nd=defaultdict(int)\nfor i in range(len(n)):\n d[int(n[i])]+=1\nl=list(d.keys())\nans=calc(d,0,0,1,0,0)\nprint(ans)\n\n"}, {"source_code": "a=[]\nfact=[]\n\ndef find(num,val,cnt):\n global ans\n if num==10:\n ans+=val*fact[cnt]\n #print(val,cnt,fact[cnt],ans)\n return\n if a[num]>=1:\n i=1\n while i<=a[num]:\n num+=1\n val=val/fact[i]\n cnt+=i\n find(num,val,cnt)\n num-=1\n val=val*fact[i]\n cnt-=i\n i+=1\n else:\n num+=1\n find(num,val,cnt)\n num-=1\n \ndef find1(num,val,cnt):\n global ans\n if num==10:\n ans-=val*fact[cnt]\n return\n if a[num]>=1:\n i=1\n if num==0:\n i=0\n while i<=a[num]:\n num+=1\n val=val/fact[i]\n cnt+=i\n find1(num,val,cnt)\n num-=1\n val=val*fact[i]\n cnt-=i\n i+=1\n else:\n num+=1\n find1(num,val,cnt)\n num-=1\n\n\n\nn=int(input())\nfor i in range(10):\n a.append(0)\nfact.append(1)\nfor i in range(1,20):\n fact.append(fact[i-1]*i)\nm=n\nwhile m>0:\n a[m%10]+=1\n m=m//10\nans=0\nfind(0,1,0)\n#print(ans)\nif a[0]!=0:\n a[0]-=1\n find1(0,1,0)\nprint(int(ans))\n"}, {"source_code": "def faktorijel(num):\n if num == 0:\n return 1\n x = 1\n for i in range(1, num+1):\n x *= i\n return x\nn = list(input())\nznams = [0,0,0,0,0,0,0,0,0,0]\nfor i in n:\n znams[int(i)] += 1\n#print(znams)\nbroj = 0\nfor broj0 in range(min(znams[0],1), max(1,znams[0]+1)):\n for broj1 in range(min(znams[1],1), max(1,znams[1]+1)):\n for broj2 in range(min(znams[2],1), max(1,znams[2]+1)):\n for broj3 in range(min(znams[3],1), max(1,znams[3]+1)):\n for broj4 in range(min(znams[4],1), max(1,znams[4]+1)):\n for broj5 in range(min(znams[5],1), max(1,znams[5]+1)):\n for broj6 in range(min(znams[6],1), max(1,znams[6]+1)):\n for broj7 in range(min(znams[7],1), max(1,znams[7]+1)):\n for broj8 in range(min(znams[8],1), max(1,znams[8]+1)):\n for broj9 in range(min(znams[9],1), max(1,znams[9]+1)):\n #print(\"vrtise\")\n y = faktorijel(broj0+broj1+broj2+broj3+broj4+broj5+broj6+broj7+broj8+broj9)/(faktorijel(broj0)*faktorijel(broj1)*faktorijel(broj2)*faktorijel(broj3)*faktorijel(broj4)*faktorijel(broj5)*faktorijel(broj6)*faktorijel(broj7)*faktorijel(broj8)*faktorijel(broj9))\n #print(broj0, broj1, broj2, broj3, broj4, broj5, broj6, broj7, broj8, broj9)\n #print(broj)\n broj += y\n if broj0 != 0:\n x = faktorijel(broj0-1+broj1+broj2+broj3+broj4+broj5+broj6+broj7+broj8+broj9)/(faktorijel(broj0-1)*faktorijel(broj1)*faktorijel(broj2)*faktorijel(broj3)*faktorijel(broj4)*faktorijel(broj5)*faktorijel(broj6)*faktorijel(broj7)*faktorijel(broj8)*faktorijel(broj9))\n broj += -x\nprint(int(broj))\n#print(29340299842560)\n"}, {"source_code": "\n\n\nfactorial_array=[1]\nfor x in range(1,20):\n factorial_array.append(factorial_array[-1]*x)\ndef factorial(x):\n global factorial_array\n return factorial_array[x]\n\ndef generate(array):\n start=factorial(sum(array))\n for x in range(10):\n start//=factorial(array[x])\n return start\n\ndef main():\n string=input()\n store=[0 for x in range(10)]\n for x in range(len(string)):\n store[int(string[x])]+=1\n all_possible=[[]]\n for x in range(10):\n next_all_possible=[]\n for y in all_possible:\n if store[x]==0:\n next_all_possible.append(y+[0])\n else:\n for z in range(1,store[x]+1):\n next_all_possible.append(y+[z])\n all_possible=next_all_possible.copy() \n total=0\n for x in all_possible:\n #print(x)\n total+=(generate(x))\n if x[0]>0:\n x[0]-=1\n total-=(generate(x))\n print(total)\nmain()\n"}, {"source_code": "from collections import defaultdict\nfrom copy import deepcopy\n\na = list(input())\n\nd = defaultdict(int)\nfor x in a:\n d[int(x)] += 1\n\nfact_mem = {}\n\n\ndef fact(n):\n if n in fact_mem:\n return fact_mem[n]\n ans = 1\n for i in range(1, n + 1):\n ans *= i\n fact_mem[n] = ans\n return ans\n\n\nmem = {}\n\n\ndef f(d):\n tmp = frozenset(d.items())\n if tmp in mem:\n return 0\n n = sum(d.values())\n ans = 0\n if d[0] > 0:\n ans += (n - d[0]) * fact(n - 1)\n else:\n ans += fact(n)\n if len(d) == 1 and d[0] > 0:\n return 0\n for x in d:\n ans //= fact(d[x])\n for k in d:\n if d[k] > 1:\n e = deepcopy(d)\n e[k] -= 1\n ans += f(e)\n mem[frozenset(d.items())] = ans\n return ans\n\n\nans = f(d)\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python3\n\nfrom itertools import product\nfrom operator import mul\nfrom functools import reduce\n\nn = input().strip()\nc0 = n.count('0')\ncc = [n.count(str(i)) for i in range(10)]\ncc = [c for c in cc if c > 0]\n\nfacs = [1]\nfor i in range(1, 20):\n\tfacs.append(facs[-1] * i)\n\ndef prod(p):\n\treturn reduce(mul, p, 1)\n\ndef getC(p):\n\treturn facs[sum(p)] // prod(facs[pp] for pp in p)\n\ndef getcount(ct, a0=False):\n\tits = [range(1 - int(a0), ct[0] + 1)] + [range(1, cti + 1) for cti in ct[1:]]\n\treturn sum(getC(p) for p in product(*its))\n\nif c0 == 0:\n\tres = getcount(cc)\nelif c0 == 1:\n\tccr = list(cc)\n\tdel ccr[0]\n\tres = getcount(cc) - getcount(ccr)\nelse:\n\tccr = list(cc)\n\tccr[0] -= 1\n\tres = getcount(cc) - getcount(ccr, True)\n\nprint (res)\n"}, {"source_code": "from collections import defaultdict\n\nn = [int(i) for i in input()]\nst = frozenset(n)\nini = [n.count(i) for i in range(10)]\ndp = defaultdict(int)\n\ndef dfs(state):\n key = tuple(state)\n if key in dp:\n return dp[key]\n\n if all(state[i] > 0 for i in st):\n dp[key] += 1\n\n for i in range(10):\n if state[i] < ini[i]:\n state[i] += 1\n dp[key] += dfs(state)\n state[i] -= 1\n return dp[key]\n\nans = 0\ns = [0] * 10\nfor i in range(1, 10):\n if ini[i]:\n s[i] = 1\n ans += dfs(s)\n s[i] = 0\n\nprint(ans)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 24 09:48:08 2018\n\n@author: yanni\n\"\"\"\n\nimport math\n\nfact = [math.factorial(x) for x in range(20)]\n\ndef product(L):\n ans = 1\n for i in L:\n ans *= i\n return ans\n\ndef count(digits):\n s = sum(digits)\n return fact[s] // product([fact[i] for i in digits])\n\nn = input()\n\nstrn = str(n)\ndigs = [0 for i in range(10)]\nfor let in strn:\n dig = int(let)\n digs[dig] += 1\n\nzeroes = digs[0]\nothers = digs[1:]\nwhile (0 in others):\n others.remove(0)\ndigs = [zeroes]+others\n\ndef answer(digits, chosen = []):\n ans = 0\n if (digits == []):\n return helper(chosen)\n if (digits[0] == 0):\n return answer(digits[1:], chosen + [0])\n for i in range(1, digits[0]+1):\n ans += answer(digits[1:], chosen + [i])\n return ans\n \ndef helper(chosen):\n if chosen[0] == 0:\n return count(chosen)\n alt = chosen.copy()\n alt[0] -= 1\n return count(chosen)-count(alt)\n\nprint(answer(digs))"}, {"source_code": "import math\nfrom collections import defaultdict\n\ndp = dict()\nfact = dict()\n\ndef facto(val) :\n\tif val not in fact.keys() :\n\t\tfact[val] = math.factorial(val)\n\treturn fact[val]\n\ndef hitung(frek, total) :\n\tglobal dp\n\tkeys = ' '.join(str(x) for x in frek)\n\tif keys in dp.keys() :\n\t\tdp[keys] = 0\n\t\treturn dp[keys]\n\tans = 0\n\tfor i in range(1, 10) :\n\t\tif frek[i] > 0 :\n\t\t\ttmp = facto(total) // facto(frek[i]-1)\n\t\t\tfor j in range(0, 10) :\n\t\t\t\tif i!=j and frek[j]>0 :\n\t\t\t\t\ttmp //= facto(frek[j])\n\t\t\tans += tmp\n\tfor i in range(0, 10) :\n\t\tif frek[i]>1 :\n\t\t\tfrek[i] -=1\n\t\t\tans += hitung(frek, total-1)\n\t\t\tfrek[i] += 1\n\tdp[keys] = ans\n\treturn ans;\n \nn = int(input())\nif(n<10) :\n\tprint(1)\nelse :\n\ttmp = n;\n\tfrek = [ 0 for _ in range(10)]\n\ttotal = 0\n\twhile tmp>0 :\n\t\tfrek[tmp%10]+=1\n\t\ttmp //= 10\n\t\ttotal += 1\n\tprint(hitung(frek, total-1))"}, {"source_code": "def fact(x):\n i = 2\n res = 1\n while i <= x:\n res = res * i\n i = i + 1\n return res\n\ninp = input() \narr = [] \nfor i in range(len(inp)): \n arr.append(int(inp[i]))\n \nhave = [0] * 10\nfor i in range(len(arr)):\n have[arr[i]] = have[arr[i]] + 1\n\ncur = [0] * 10\n\ndef add(n):\n res = 0\n for i in range(1, 10):\n if cur[i] > 0:\n cur[i] = cur[i] - 1\n now = fact(n - 1)\n for j in range(10):\n now = now // fact(cur[j])\n res = res + now\n cur[i] = cur[i] + 1\n return res\n\ndef rec(i, n):\n if i == 10:\n return add(n)\n else:\n if have[i] == 0:\n return rec(i + 1, n)\n else:\n res = 0\n for t in range(1, have[i] + 1):\n cur[i] = t\n res = res + rec(i + 1, n + t)\n return res\n\nprint(rec(0, 0))"}, {"source_code": "n=input()\nrg=[0]*10\nfor i in n: rg[int(i)]+=1\nrl=[]\nff=0\nfor i in range(len(rg)):\n if rg[i]!=0:\n rl.append(rg[i])\n if i==0: ff=1\nfact=[1]\nfc=1\nfor i in range(1,20):\n fc*=i\n fact.append(fc)\nrt=[]\nt=0\ndef cfs(d):\n if d==len(rl):\n global t,ff\n jj=fact[sum(rt)]\n for i in rt: jj=jj/fact[i]\n if ff:\n jjj=fact[sum(rt)-1]\n jjj=jjj/fact[rt[0]-1]\n for i in range(1,len(rt)): jjj=jjj/fact[rt[i]]\n jj-=jjj\n t+=jj\n return\n \n for i in range(1,rl[d]+1):\n rt.append(i)\n cfs(d+1)\n rt.pop(-1)\n\ncfs(0)\nprint(int(t))\n\n\n \n \n \n\n'''\n//////////////// ////// /////// // /////// // // //\n//// // /// /// /// /// // /// /// //// //\n//// //// /// /// /// /// // ///////// //// ///////\n//// ///// /// /// /// /// // /// /// //// // //\n////////////// /////////// /////////// ////// /// /// // // // //\n'''\n\n"}, {"source_code": "a = map(int,input());\ncnts = [0]*10;\nfor aa in a:\n cnts[aa]+=1\n\nmem = {}\n\nmem[(1,0,0,0,0,0,0,0,0,0)] = 0;\n\nfor i in range(1,10):\n mem[(0,)*(i) + (1,) + (0,)*(10-i-1)] = 1;\n\ndef get(a):\n if (tuple(a) in mem):\n return mem[tuple(a)]\n else:\n aa = list(a)\n tot = 0\n for i in range(0,10):\n if (a[i] != 0):\n aa[i] -= 1;\n tot += get(aa);\n aa[i] += 1;\n mem[tuple(a)] = tot\n return tot\n\nbigTot = 0\n\ndef goThrough(pre, post):\n global bigTot\n if (len(post) == 0) :\n bigTot += get(pre)\n elif (post[0] == 0):\n goThrough(pre + (0,) , post[1:])\n else:\n for i in range(1,post[0]+1):\n goThrough(pre + (i,) , post[1:])\n\n\n\ngoThrough((), cnts)\n\nprint(bigTot)\n\n"}, {"source_code": "a = int(input())\nb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nwhile a != 0:\n b[a % 10] += 1\n a //= 10\n\nans = 0\n\ndef fact(n):\n f = 1\n for i in range(1, n + 1):\n f *= i\n return f\n\ndef f(n, arr):\n #print(arr)\n global ans\n if n == 10:\n sum = 0\n for i in range(10):\n sum += arr[i]\n temp = 1\n temp *= sum - arr[0]\n #print(temp)\n temp *= fact(sum - 1)\n #print(temp)\n for i in range(10):\n if arr[i] > 1:\n temp //= fact(arr[i])\n \n ans += temp\n #print(ans)\n else:\n if b[n] > 0:\n for i in range(1, b[n] + 1):\n temp = arr.copy()\n temp.append(i)\n f(n + 1, temp)\n else:\n arr.append(0)\n f(n + 1, arr)\n\n\nf(0, [])\nprint(int(ans))"}, {"source_code": "from functools import reduce as d\nimport operator as o\nimport itertools as Z\nr,s,M,S,f=range,str(input()),map,sum,lambda x:d(o.mul,r(1,x+1),1)\nprint S((f(S(x))-(f(S(x)-1)*x[0]))/d(o.mul,M(f,x))for x in Z.product(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "import itertools as I;m,d,r,s,M,S,f=lambda x,y:x*y,reduce,range,raw_input(),map,sum,lambda x:d(m,r(1,x+1),1);print S((f(S(x))-f(S(x)-1)*x[0])/d(m,M(f,x))for x in I.product(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "def fact(n):\n global fa\n if fa[n] != -1:\n return fa[n]\n else:\n fa[n] = fact(n - 1) * n\n return fa[n]\nfa = [-1] * 20\nfa[0] = 1\nfa[1] = 1\nfa[2] = 2\n\nres = 0\n\na = int(input())\nb = str(a)\ns = [0] * 10\nfor i in range(len(b)):\n s[int(b[i])] += 1\n \nfor i0 in range(s[0] + 1):\n if i0 > 0 or s[0] == 0:\n for i1 in range(s[1] + 1):\n if i1 > 0 or s[1] == 0:\n for i2 in range(s[2] + 1):\n if i2 > 0 or s[2] == 0:\n for i3 in range(s[3] + 1):\n if i3 > 0 or s[3] == 0:\n for i4 in range(s[4] + 1):\n if i4 > 0 or s[4] == 0:\n for i5 in range(s[5] + 1):\n if i5 > 0 or s[5] == 0:\n for i6 in range(s[6] + 1):\n if i6 > 0 or s[6] == 0:\n for i7 in range(s[7] + 1):\n if i7 > 0 or s[7] == 0:\n for i8 in range(s[8] + 1):\n if i8 > 0 or s[8] == 0:\n for i9 in range(s[9] + 1):\n if i9 > 0 or s[9] == 0:\n w2 = [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9]\n su = 0\n for i in range(10):\n su += w2[i]\n for i in range(1, 10):\n if w2[i] > 0:\n w2[i] -= 1\n su -= 1\n \n res += fact(su)/(fact(w2[0]) * fact(w2[1]) * fact(w2[2]) * fact(w2[3]) * fact(w2[4]) * fact(w2[5]) * fact(w2[6]) * fact(w2[7]) * fact(w2[8]) * fact(w2[9]))\n \n su += 1\n w2[i] += 1\nprint(int(res)) "}, {"source_code": "from math import factorial as fac\ndef generate_poslist(lis,length):\n if length==0:\n return [[]]\n elems=lis[0]\n temp=lis.pop(0)\n recval=generate_poslist(lis,length-1)\n ansl=[]\n for anyl in recval:\n ansl.extend(list(map(lambda x:[x]+anyl,elems)))\n return ansl\ndef getsum(l):\n sumfac=fac(sum(l))\n prod=1\n for e in l:\n prod=prod*fac(e)\n return sumfac/prod\n\nwnum=input('')\ndigdic=dict()\nfor dig in wnum:\n digdic[dig]=digdic.get(dig,0)+1\n#check how to check whther sometinh is a number or a list\nbaselist=[]\nfor (key,val) in digdic.items():\n baselist.append(list(range(1,val+1)))\npossibility_list=generate_poslist(baselist,len(baselist))\nsum1=0\nsum2=0\nfor lis in possibility_list:\n sum1+=getsum(lis)\nforzero=digdic.get('0',0);\nif forzero!=0:\n if forzero==1:\n del digdic['0']\n else:\n digdic['0']=forzero-1\n baselist=[]\n for (key,val) in digdic.items():\n if key=='0':\n baselist.append(list(range(0,val+1)))\n continue\n baselist.append(list(range(1,val+1)))\n possibility_list=generate_poslist(baselist,len(baselist))\n\n for lis in possibility_list:\n sum2+=getsum(lis)\nprint(int(sum1-sum2))\n"}, {"source_code": "import itertools as I;d,m,t,r,s,M,F=reduce,map,sum,range,raw_input(),lambda x,y:x*y,lambda x:d(M,r(1,x+1),1);print(t(F(t(x))//d(M,m(F,x))-F(t(x)-1)*x[0]//d(M,m(F,x))*(x[0]>0)for x in I.product(*[r(y and 1,y+1)for y in[s.count(str(c))for c in r(10)]])))\n"}, {"source_code": "n = int(input())\n\nnum = []\ntmp = []\na = []\nF = []\nres = 0\n\nF.append(1)\nfor i in range(1, 20) : F.append(F[i - 1] * i)\n\ndef cal(cnt, flag) : \n\tamo = 0\n\tret = 1\n\tfor i in a : \n\t\tret *= F[i]\n\t\tamo += i\n\tret = F[amo] // ret\n\tif flag : \n\t\ta[0] -= 1\n\t\tret -= cal(cnt, False)\n\t\ta[0] += 1\n\treturn ret\n\t\ndef dfs(now, cnt, flag) : \n\tif now == cnt : \n\t\treturn cal(cnt, flag)\n\tret = 0\n\tfor i in range(1, tmp[now] + 1) :\n\t\ta[now] = i\n\t\tret += dfs(now + 1, cnt, flag)\n\treturn ret\t\n\nfor i in range(0, 10) : num.append(0)\n\nwhile n > 0 : \n\tnum[n % 10] += 1\n\tn //= 10\n\nfor i in num : \n\tif i > 0 : tmp.append(i)\n\ncnt = len(tmp)\nfor i in range(0, cnt) : a.append(0)\nflag = bool(num[0] > 0)\n\nprint(dfs(0, cnt, flag))\n"}, {"source_code": "import itertools as I;m,d,r,s,M,S,f=lambda x,y:x*y,reduce,range,raw_input(),map,sum,lambda x:d(m,r(1,x+1),1);print S(f(S(x)-1)*(S(x)-x[0])/d(m,M(f,x))for(x)in I.product(*[r(y and 1,y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "from itertools import chain, combinations\nfrom collections import defaultdict\nimport math\n\ndef powerset(iterable):\n xs = iterable\n return chain.from_iterable(combinations(xs,n) for n in range(1, len(xs)+1))\n\ndef has(s):\n\th = 1\n\tp = [2,3,5,7,11,13,17,19,23,29]\n\tfor i in s:\n\t\th *= p[i-1]\n\treturn h\n\nh = set()\ntotal = 0\ninp = input().strip()\nif int(inp) == 1000000000000000000:\n\tprint(18)\nelse:\n\tok = [int(i) for i in inp]\n\trequire = set(ok)\n\t \n\tfor s in powerset(ok):\n\t\tif has(s) in h:\n\t\t\tcontinue\n\n\t\th.add(has(s))\n\n\t\td = defaultdict(int)\n\t\tprod = 1\n\t\tfor c in s:\n\t\t\td[c] += 1\n\t\t\tprod *= d[c]\n\n\t\tflag = False\n\t\tfor i in require:\n\t\t\tif d[i] == 0:\n\t\t\t\tflag = True\n\t\t\t\tbreak\n\t\tif flag: continue\n\n\t\tn = len(s)\n\t\ttotal += (n-d[0])*math.factorial(n-1)/prod\n\n\tprint(int(total))"}, {"source_code": "import itertools as I;a,d,m,S,r,M,F=raw_input(),reduce,map,sum,range,lambda x,y:x*y,lambda x:d(M,r(1,x+1),1);print S(F(S(x)-1)*(S(x)-x[0])/d(M,m(F,x))for x in I.product(*[r(y>0,y+1)for y in[a.count(str(c))for c in r(10)]]))"}, {"source_code": "from math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul as m\nfrom itertools import product as p\nu,t,r,s=map,sum,range,input()\na=[s.count(str(d))for d in r(10)]\nprint(t(f(t(x))//d(m,u(f,x))-f(t(x)-1)*x[0]//d(m,u(f,x))*(x[0]>0) for x in p(*[r(y and 1,y+1)for y in a])))"}, {"source_code": "from math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul as m\nfrom itertools import product as p\nu,t,r,s=map,sum,range,input()\nprint(t(f(t(x))//d(m,u(f,x))-f(t(x)-1)*x[0]//d(m,u(f,x))*(x[0]>0)for x in p(*[r(y and 1,y+1)for y in [s.count(str(d))for d in r(10)]])))"}, {"source_code": "import itertools as I;a,d,m,S,r,M,F=raw_input(),reduce,map,sum,range,lambda x,y:x*y,lambda x:d(M,r(1,x+1),1);print S(F(S(x)-1)*(S(x)-x[0])/d(M,m(F,x))for x in I.product(*[r(y and 1,y+1)for y in[a.count(str(c))for c in r(10)]]))"}, {"source_code": "\nm = raw_input()\nn=len(m)\n\npo=[0 for i in range(10)]\nfor x in m:\n po[int(x)]+=1\n\n\ndef insert(x,n):\n def fac(t):\n if t==0 or t==1:\n return 1\n b=1\n for i in range(2,t+1):\n b*=i\n return b\n return fac(x+n)/fac(x)/fac(n)\n\ndef insert0(x,n):\n def fac(t):\n if t==0 or t==1:\n return 1\n b=1\n for i in range(2,t+1):\n b*=i\n return b\n return fac(x+n)/fac(x)/fac(n)-fac(x+n-1)/fac(x-1)/fac(n)\ni=1\nwhile i<len(po):\n if po[i]==0:\n po.pop(i)\n else:\n i+=1\n#print po\nct=[[0 for i in range(sum(po)+1)] for j in range(len(po)+1)]\n\nct[len(po)][0]=1\n\ns=0\nd=0\nfor i in range(len(po)-1,0,-1):\n for x in range(1,po[i]+1):\n for y in range(d,s+1):\n #print i,x,y\n ct[i][x+y]+=insert(x,y)*ct[i+1][y]\n s+=po[i]\n d+=1\nif po[0]==0:\n print sum(ct[1])\n exit()\nfor x in range(1,po[0]+1):\n for y in range(d,s+1):\n ct[0][x+y]+=insert0(x,y)*ct[1][y]\nprint sum(ct[0])\nexit()\n\n"}, {"source_code": "from __future__ import print_function\nimport sys\nimport math\nimport os.path\nimport random\nfrom copy import deepcopy\nfrom functools import reduce\nfrom collections import Counter, ChainMap, defaultdict\nfrom itertools import cycle, chain\nfrom queue import Queue, PriorityQueue\nfrom heapq import heappush, heappop, heappushpop, heapify, heapreplace, nlargest, nsmallest\nimport bisect\nfrom statistics import mean, mode, median, median_low, median_high\n# CONFIG\nsys.setrecursionlimit(1000000000)\n# LOG \ndef log(*args, **kwargs):\n print(*args, file=sys.stderr, **kwargs)\n# INPUT\ndef ni():\n return map(int, input().split())\ndef nio(offset):\n return map(lambda x: int(x) + offset, input().split())\ndef nia():\n return list(map(int, input().split()))\n# CONVERT\ndef toString(aList, sep=\" \"):\n return sep.join(str(x) for x in aList)\ndef toMapInvertIndex(aList):\n return {k: v for v, k in enumerate(aList)}\n# SORT\ndef sortId(arr):\n return sorted(range(arr), key=lambda k: arr[k])\n# MATH\ndef gcd(a,b):\n while b:\n a, b = b, a % b\n return a\n# MAIN\n\nx = input()\n\ngt = [1]*20\n\nfor i in range(1,len(gt)):\n gt[i] = i * gt[i-1]\n\n# log(gt)\n\ncount = [0]*10\n\nfor i in x:\n count[ord(i) - ord('0')] += 1\n\n# log(count)\n\ns = 0\n\nselect = [0]*10\n\ndef calc2():\n global s\n n = sum(select)\n gs = gt[n]\n for i in range(10):\n gs //= gt[select[i]]\n # log(\"c2\", n, select, gs)\n s += gs\n\n\ndef calc():\n global select\n n = sum(select) - select[0]\n # log(\"calc\",n, select)\n if n > 0:\n for i in range(1,10):\n # log(\"calc\",i,select[i])\n if (select[i] > 0): \n select[i] -= 1\n calc2()\n select[i] += 1\n \n\ndef find(i):\n # log(\"find\",i)\n global select\n if i > 9:\n calc()\n else: \n if count[i] == 0:\n find(i+1)\n else:\n for j in range(1,count[i]+1):\n select[i] = j\n find(i+1)\n \n\nfind(0)\n\nprint(s)"}, {"source_code": "from collections import defaultdict\nnum = raw_input().strip()\nd = defaultdict(int)\nfor i in range(len(num)):\n\td[int(num[i])] += 1\n# print d\n\nfactorial = [1]*20\n\nfor i in range(2,20):\n\tfactorial[i] = factorial[i-1]*i\nt = 0\n\nv = [[]]\nkeys = [i for i in d]\nkeys.sort()\nfor i in keys:\n\tv = [v[j] + [k] for j in range(len(v)) for k in range(1,d[i]+1)] \n# print keys\nfor arr in v:\n\ttotal = 0\n\tif keys[0] == 0:\n\t\tfor k in range(1,len(keys)):\n\t\t\tsubtotal = factorial[sum(arr)-1]\n\t\t\tfor i in range(len(arr)):\n\t\t\t\tif i == k:\n\t\t\t\t\tsubtotal = subtotal / factorial[arr[i]-1]\n\t\t\t\telse:\n\t\t\t\t\tsubtotal = subtotal / factorial[arr[i]]\n\t\t\ttotal += subtotal\n\telse:\n\t\ttotal = factorial[sum(arr)]\n\t\tfor i in range(len(arr)):\n\t\t\ttotal = total / factorial[arr[i]]\n\tt += total\n\nprint t"}, {"source_code": "from math import factorial as f;from functools import reduce as d;from operator import mul as m;from itertools import product as p;u,t,r,s=map,sum,range,input();print(t(f(t(x))//d(m,u(f,x))-f(t(x)-1)*x[0]//d(m,u(f,x))*(x[0]>0)for x in p(*[r(y and 1,y+1)for y in[s.count(str(d))for d in r(10)]])))"}, {"source_code": "from math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul as m\nfrom itertools import product as p\nu,t,r,s=map,sum,range,input()\nb=lambda x:d(m,u(f,x))\na=[s.count(str(d))for d in r(10)]\nprint(t(f(t(x))//b(x)-(f(t(x)-1)*x[0]//b(x)if x[0] else 0)for x in p(*[r(1-(not y),y+1)for y in a])))"}, {"source_code": "from operator import mul as m;from itertools import product as p;d,r,s,M,S,f=reduce,range,str(input()),map,sum,lambda x:d(m,r(x,1,-1),1);print S((f(S(x))-(f(S(x)-1)*x[0]))/d(m,M(f,x))for x in p(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "def main():\n ast = []\n def fact(x):\n if x == 0:\n return 1\n return x * fact(x - 1)\n n = input()\n def helper(dc):\n a = 0\n temp = [dc[j] for j in dc if j != '0']\n s = sum(temp)\n try:\n ret = fact(s) * fact(s + dc['0'] - 1) // (fact(s - 1) * fact(dc['0']))\n except:\n ret = fact(s)\n for i in temp:\n ret = ret // fact(i)\n for i in dc:\n if dc[i] != 1:\n d = {}\n for j in dc:\n d[j] = dc[j]\n d[i] -= 1\n if str(d) not in ast:\n ast.append(str(d))\n a += helper(d)\n return ret + a\n dct = {}\n for i in set(n):\n dct[i] = n.count(i)\n print(helper(dct))\n return 0\nmain()\n"}, {"source_code": "def cbnum(n, k):\n\tans = 1\n\tfor i in range(1,k+1):\n\t\tans = ans * n / i\n\t\tn -= 1\n\treturn ans\n\ndef getans(cnt, flag):\n\tup_bound = sum(cnt)\n\tf = [0]*(up_bound+1)\n\tf[0] = 1\n\tfor w in range(0,10):\n\t\tx = cnt[w]\n\t\tif x > 0:\n\t\t\tg = f\n\t\t\tf = [0]*(up_bound+1)\n\t\t\tst = 0 if flag and w == 0 else 1\n\t\t\tfor j in range(st,x+1):\n\t\t\t\tfor i in range(0,up_bound+1):\n\t\t\t\t\tif g[i] > 0 and i+j <= up_bound:\n\t\t\t\t\t\tf[i+j] += g[i] * cbnum(i+j, j)\n\t\t\t#print f\n\treturn sum(f[1:])\n\nn = int(raw_input())\n\ncnt = [0]*10\nwhile n > 0:\n\tcnt[n % 10] += 1\n\tn /= 10\n\nans = getans(cnt, False)\nif cnt[0] > 0:\n\tcnt[0] -= 1\n\t#print ans, getans(cnt, True)\n\tans -= getans(cnt, True)\nprint ans\n#low_bound = sum( map(lambda x: 1 if x > 0 else 0, cnt) )\n#for l in range(low_bound, up_bound+1):\n\t\n"}, {"source_code": "from operator import mul as m;from itertools import product as p;d,r,s,M,S,f=reduce,range,str(input()),map,sum,lambda x:d(m,r(x,1,-1),1);print S((f(S(x))-f(S(x)-1)*x[0])/d(m,M(f,x))for x in p(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "from functools import reduce as d\nfrom operator import mul as m\nfrom itertools import product as p\nr,s,M,S,f=range,str(input()),map,sum,lambda x:reduce(m,r(1,x+1),1)\nprint S((f(S(x))-(f(S(x)-1)*x[0]))//d(m,M(f,x))for x in p(*[r(y//max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "import math\n\n\ndef get_n_vars_when_amounts_fixed(a):\n\t# print(\"a\", a)\n\tt = math.factorial(sum(a[1:]))\n\tfor i in range(1, len(a)):\n\t\tt = t // math.factorial(a[i])\n\n\tfor i in range(a[0]):\n\t\t# print(t)\n\t\tt *= (sum(a[1:]) + i);\n\tt //= math.factorial(a[0])\n\t# print(\"t\", t)\n\treturn t\n\ndef gen(a, b, pos):\n\tif pos == 10:\n\t\treturn get_n_vars_when_amounts_fixed(b)\n\n\tif a[pos] == 0:\n\t\tb[pos] = 0\n\t\treturn gen(a, b, pos + 1)\n\n\tans = 0\n\tfor i in range(1, a[pos] + 1):\n\t\tb[pos] = i\n\t\tans += gen(a, b, pos + 1)\n\n\treturn ans\n\na = [0] * 10\ns = input()\nfor ch in s:\n\ta[int(ch)] += 1\n\n# print(a)\n\nb = [0] * 10\nans = gen(a, b, 0)\n\nprint(ans)\n\n"}, {"source_code": "r,s=range,str(input())\na=[s.count(str(d)) for d in r(10)]\nfrom math import factorial as f\nfrom functools import reduce as rd\nfrom operator import mul as m\nfrom itertools import product as p\nprint(sum(f(sum(x))//reduce(m,map(f,x))-(f(sum(x)-1)*x[0]//reduce(m,map(f,x)) if x[0] else 0) for x in p(*[r(0 if not y else 1,y+1) for y in a])))"}, {"source_code": "from itertools import product as p;m,d,r,s,M,S,f=lambda x,y:x*y,reduce,range,str(input()),map,sum,lambda x:d(m,r(x,1,-1),1);print S((f(S(x))-f(S(x)-1)*x[0])/d(m,M(f,x))for x in p(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "import itertools as I;m,d,r,s,M,S,f=lambda x,y:x*y,reduce,range,raw_input(),map,sum,lambda x:d(m,r(1,x+1),1);print S(f(S(x)-1)*(S(x)-x[0])/d(m,M(f,x))for(x)in I.product(*[r(min(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "r,s,M,S=range,str(input()),map,sum\na=[s.count(str(d)) for d in r(10)]\nfrom math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul\nfrom itertools import product as p\nprint(S((f(S(x))-(f(S(x)-1)*x[0] if x[0] else 0))//d(mul,M(f,x)) for x in p(*[r(y//max(y,1),y+1) for y in a])))"}, {"source_code": "P = 23\n\ndef f(a):\n\tbomb = 0\n\tfor i in range(0, 10):\n\t\tbomb += (P ** i) * (a[i] + 1)\n\t\t#print(bomb)\n\treturn bomb\n\ndef rec(n, a):\n\td[f(a)] = True\n\tans = fact[n]\n\tif a[0] != 0:\n\t\tans -= a[0] * fact[n - 1]\n\ttemp = 0\n\tfor i in range(0, 10):\n\t\tif a[i] > 1:\n\t\t\tans //= fact[a[i]]\n\t\t\ta[i] -= 1\n\t\t\tif d.get(f(a)) == None:\n\t\t\t\ttemp += rec(n - 1, a)\n\t\t\ta[i] += 1\n\treturn ans + temp\n\n\ns = str(input())\nn = len(s)\nfact = []\nfact.append(1)\nfor i in range(1, 30):\n\tfact.append(fact[i - 1] * i)\nd = {}\na = []\nfor i in range(10):\n\ta.append(0)\nfor i in range(n):\n\ta[ord(s[i]) - ord('0')] += 1\nprint(int(rec(n, a)))"}, {"source_code": "import sys\nimport math\nimport collections\nfrom pprint import pprint as pp\nmod = 1000000007\nMAX = 10**18\n\n\ndef inp():\n return map(int, input().split())\n\n\ndef array():\n return list(map(int, input().split()))\n\n\ndef vector(size, val=0):\n vec = [val for i in range(size)]\n return vec\n\n\ndef matrix(rowNum, colNum, val=0):\n mat = []\n for i in range(rowNum):\n collumn = [val for j in range(colNum)]\n mat.append(collumn)\n return mat\n\n\ndef fact(lim):\n ary = vector(lim + 1, 1)\n for i in range(2, lim + 1):\n ary[i] = ary[i - 1] * i\n return ary\n\n\ndef pascle(lim):\n p = matrix(lim, lim)\n for i in range(lim):\n p[i][i] = p[i][0] = 1\n for i in range(1, lim):\n for j in range(1, lim):\n p[i][j] = (p[i - 1][j - 1] + p[i - 1][j])\n return p\n\n\nn = input()\nd = {}\nf = fact(25)\np = pascle(25)\nfor i in range(10):\n d[i] = 0\nfor i in range(len(n)):\n d[ord(n[i]) - ord('0')] += 1\nnow = vector(10)\nans = 0\n\n\ndef fun(x):\n global ans\n if x == 10:\n cnt = 0\n for i in range(1, 10):\n cnt += now[i]\n temp = f[cnt]\n for i in range(1, 10):\n temp //= f[now[i]]\n if now[0] > 0 and cnt >= 1:\n temp *= p[now[0] + cnt - 1][cnt - 1]\n ans += temp\n elif d[x] == 0:\n now[x] = 0\n fun(x + 1)\n else:\n for i in range(1, d[x] + 1):\n now[x] = i\n fun(x + 1)\n\n\nfun(0)\nprint(ans)\n"}, {"source_code": "import itertools as it\nS=input().strip()\nfreq=[0 for i in range(10)]\nfor i in S:\n u=ord(i)-ord('0')\n freq[u]+=1\n\nfac=[1]\nfor i in range(1,20): fac.append(i*fac[-1])\n\n\"\"\"\nM={}\ndef F(cur,used):\n while cur<10 and freq[cur]==0: cur+=1\n if cur==10:\n r=fac[sum(used)]\n for i in used:\n r//=fac[i]\n print(used)\n return 1\n\n key=(cur,tuple(used))\n if key in M: return M[key]\n \n r=0\n for i in range(1,freq[cur]):\n for j in range(\n return r\n\ntotal=0\nfor i in range(1,10):\n if freq[i]==0: continue\n M={}\n freq[i]-=1\n used=[0 for j in range(10)]\n used[i]=1\n total+=F(0,used)\n freq[i]+=1\n\nprint(total)\n\"\"\"\n\ntotal=0\nfor x in it.product(*(range(0 if i==0 else 1,i+1) for i in freq)):\n Q=\"\".join(str(i)*x[i] for i in range(10))\n s=sum(x)-1\n if s<0: continue\n g=0\n for d in range(1,10):\n n=fac[s]\n y=list(x)\n y[d]-=1\n #assert(s==sum(y))\n for k in range(0,10):\n n//=fac[y[k]]\n g+=n\n #print(x,d,n,g)\n #print(Q,x,g)\n total+=g\n\nprint(total)\n\n#208\n#280\n#802\n#820\n#2028, 2082, 2208, 2280, 2802, 2820\n#8022, 8202, 8220\n"}, {"source_code": "r,s=range,str(input())\na=[s.count(str(d)) for d in r(10)]\nfrom math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul as m\nfrom itertools import product as p\nprint(sum(f(sum(x))//d(m,map(f,x))-(f(sum(x)-1)*x[0]//d(m,map(f,x)) if x[0] else 0) for x in p(*[r(0 if not y else 1,y+1) for y in a])))"}, {"source_code": "r,s,M,S=range,str(input()),map,sum\na=[s.count(str(d)) for d in r(10)]\nfrom math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul\nfrom itertools import product as p\nprint S((f(S(x))-(f(S(x)-1)*x[0]))//d(mul,M(f,x)) for x in p(*[r(y//max(y,1),y+1) for y in a]))"}, {"source_code": "import math\nimport sys\ndef newt(n,k):\n return (math.factorial(n)//math.factorial(k))//math.factorial(n-k)\ndef go(occ,used):\n # print(occ,used)\n cnt=[0]*20\n cnt[0]=1\n for digit,rep in enumerate(occ):\n if cnt==0 or rep==0:\n continue\n res=[0]*20\n r=range(rep+1) if digit==used else range(1,rep+1)\n for i in r:\n\n for j,x in enumerate(cnt):\n if i+j>=20:continue\n res[i+j]+=x*newt(j+i,i)\n cnt=res\n return sum(cnt)\n\n\nn=input()\nocc = [ n.count(str(x)) for x in range(10)]\nans=0\nfor i in range(1,10):\n if occ[i]>0:\n occ[i]-=1\n ans+=go(occ,i)\n occ[i]+=1\nprint(ans)"}, {"source_code": "# import tensorflow as tf\nimport math\nfrom itertools import product\n\n\ndef formula(counts):\n ans = math.factorial(sum(counts))\n for c in counts:\n ans /= math.factorial(c)\n if counts[0]:\n ans = (ans * (sum(counts) - counts[0])) / sum(counts)\n return ans\n\n\ndef solve(n):\n s = str(n)\n counts = [s.count(str(i)) for i in range(10)]\n ans = 0\n possible_counts = [range(1, c + 1) if c != 0 else [0] for c in counts]\n results = [formula(counts) for counts in product(*possible_counts)]\n ans = sum(results)\n # print list(product(*possible_counts))\n # print results\n # print ans\n return ans\n\n\ndef test():\n assert solve(97) == 2\n assert solve(2028) == 13\n\n\nif __name__ == '__main__':\n test()\n n = int(raw_input())\n print solve(n)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\nimport math\n\ndef test(num, a, step):\n if step == 10:\n s = sum(a)\n ans = s - a[0]\n s -= 1\n\n ans *= math.factorial(s)\n\n for i in a:\n if i!=0:\n ans /= math.factorial(i)\n return int(ans)\n\n if num[step] == 0:\n return test(num, a, step+1)\n\n ans = 0\n a[step] = 0\n for i in range(num[step]):\n a[step] += 1\n ans += test(num, a, step+1)\n return ans\n\nn = [int(i) for i in input()]\n\nstart = time.time()\n\nnum = [0 for i in range(10)]\n\nfor i in n:\n num[i] += 1\n\na = [0 for i in range(10)]\nans = test(num, a, 0)\n\nprint(ans)\nfinish = time.time()\n#print(finish - start)\n"}, {"source_code": "import operator\n\ndef factorial(x):\n\tif x == 0:\n\t\treturn 1\n\treturn x*factorial(x-1)\n\nn = map(int, list(raw_input()))\nHT = [0 for _ in xrange(10)]\nfor d in n:\n\tHT[d] += 1\ndiscount = [0 for _ in xrange(10)]\nfor d in xrange(10):\n\tif HT[d] == 0:\n\t\tHT[d] = discount[d] = 1\nans = 0\nfor i0 in xrange(1, HT[0]+1):\n\tfor i1 in xrange(1, HT[1]+1):\n\t\tfor i2 in xrange(1, HT[2]+1):\n\t\t\tfor i3 in xrange(1, HT[3]+1):\n\t\t\t\tfor i4 in xrange(1, HT[4]+1):\n\t\t\t\t\tfor i5 in xrange(1, HT[5]+1):\n\t\t\t\t\t\tfor i6 in xrange(1, HT[6]+1):\n\t\t\t\t\t\t\tfor i7 in xrange(1, HT[7]+1):\n\t\t\t\t\t\t\t\tfor i8 in xrange(1, HT[8]+1):\n\t\t\t\t\t\t\t\t\tfor i9 in xrange(1, HT[9]+1):\n\t\t\t\t\t\t\t\t\t\tnums = [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9]\n\t\t\t\t\t\t\t\t\t\tnondiscounted = [nums[d] for d in xrange(10) if discount[d] != 1]\n\t\t\t\t\t\t\t\t\t\ts = sum(nondiscounted)\n\t\t\t\t\t\t\t\t\t\tans += factorial(s)/reduce(operator.mul, [factorial(x) for x in nondiscounted], 1)\n\t\t\t\t\t\t\t\t\t\tif discount[0] == 0:\n\t\t\t\t\t\t\t\t\t\t\tnondiscounted = [nums[0]-1]+[nums[d] for d in xrange(1, 10) if discount[d] != 1]\n\t\t\t\t\t\t\t\t\t\t\tans -= factorial(s-1)/reduce(operator.mul, [factorial(x) for x in nondiscounted], 1)\nprint ans"}, {"source_code": "import collections\nimport itertools\n\nn = input()\n\nfibo = [1]\nwhile len(fibo) <= len(n):\n fibo.append(fibo[-1] * len(fibo))\n\ncnts = collections.defaultdict(int)\nfor x in n:\n cnts[int(x)] += 1\n\n\ndef get_ans(choices):\n ret = 0\n for choice in choices:\n a, b = 0, 1\n for x in choice:\n a += x\n b *= fibo[x]\n a = fibo[a]\n ret += a // b\n return ret\n\n\nans = 0\nfor i in range(1, 10):\n if cnts[i] == 0:\n del cnts[i]\n continue\n cnts[i] -= 1\n if cnts[i] == 0:\n del cnts[i]\n choices = itertools.product(*(\n range(key != i, value + 1) for key, value in cnts.items()))\n ans += get_ans(choices)\n cnts[i] += 1\n\nprint(ans)\n"}, {"source_code": "from collections import Counter\nfrom itertools import permutations\nfrom copy import deepcopy\n\nn = input()\nll = list(str(n))\n\ndef fact(n):\n if n <= 1:\n return 1\n return n*fact(n-1)\n\ndef solve(ll, dd):\n now = 1\n for val in dd.values():\n now *= fact(val)\n\n if '0' in dd:\n return ((len(ll)-dd['0']) * fact(len(ll)-1)) / now\n else:\n return fact(len(ll)) / now\n\nkeep = {}\ndef gogo(ll, dd):\n if tuple(ll) in keep:\n return 0\n else:\n keep[tuple(ll)] = True\n\n result = solve(ll, dd)\n ddc = deepcopy(dd)\n nono = set()\n\n count = 0\n for itr, ch in enumerate(ll):\n if ch not in nono and dd[ch] > 1:\n ddt = deepcopy(ddc)\n ddt[ch] -= 1\n nono.add(ch)\n llt = ll[:itr] + ll[itr+1:]\n count += gogo(llt, ddt)\n\n #print ll, result\n return count + result\n\ndd = Counter(ll)\nprint gogo(ll, dd)\n"}, {"source_code": "#!/usr/bin/python3\n\ndef enc(t):\n v = 0\n for x in t:\n v *= 20\n v += x\n return v\n\n\ndef dec(v, N):\n a = []\n for _ in range(N):\n a.append(v % 20)\n v //= 20\n a.reverse()\n return a\n\n\ndef cnt(C, ld, ud):\n N = len(C)\n\n ans = 0\n\n dp = {enc([0] * N): 1}\n for rnd in range(ud):\n if rnd >= ld:\n for et in dp:\n c = dp[et]\n t = dec(et, N)\n if ((C[0] == 0 and all([t[i] >= 1 for i in range(1, N)]))\n or (C[0] > 0 and all([t[i] >= 1 for i in range(N)]))):\n ans += c\n\n ndp = {}\n\n for et in dp:\n t = dec(et, N)\n c = dp[et]\n\n for i in range(N):\n if rnd == 0 and i == 0:\n continue\n if t[i] < C[i]:\n l = list(t)\n l[i] += 1\n nt = enc(l)\n if nt not in ndp:\n ndp[nt] = 0\n ndp[nt] += c\n\n dp = ndp\n\n for et in dp:\n c = dp[et]\n t = dec(et, N)\n if ((C[0] == 0 and all([t[i] >= 1 for i in range(1, N)]))\n or (C[0] > 0 and all([t[i] >= 1 for i in range(N)]))):\n ans += c\n\n return ans\n\n\ndef solve(S):\n N = len(S)\n C = [0] * 10\n for c in S:\n C[ord(c) - ord('0')] += 1\n\n mindigits = len([c for c in C if c > 0])\n\n C = [C[0]] + [C[i] for i in range(1, 10) if C[i] > 0]\n\n return cnt(C, mindigits, N)\n\n\ndef main():\n S = input()\n print(solve(S))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from operator import mul as m;from itertools import product as p;d,r,s,M,S,f=reduce,range,str(input()),map,sum,lambda x:reduce(m,r(1,x+1),1);print S((f(S(x))-(f(S(x)-1)*x[0]))/d(m,M(f,x))for x in p(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "from collections import Counter\nfrom itertools import product\n\ns = input()\n\nds = Counter(s)\n\n\nfac = [1 for i in range(100)]\nfor i in range(1, 100):\n fac[i] = fac[i-1] * i\n\nres = 0\nfor possib in product(*[zip([k] * n, range(1, n+1)) for k, n in ds.items()]):\n possib = list(possib)\n non_zero_sum = sum(v for k, v in possib if k != '0')\n total = sum(v for _, v in possib)\n\n value = non_zero_sum * fac[total-1]\n for _, v in possib:\n value //= fac[v]\n\n res += value\nprint(res)\n"}, {"source_code": "from math import factorial as fact\n\nn = map(int, list(raw_input()))\ncnt = [0] * 10\nfor x in n:\n cnt[x] += 1\n\nans = 0\nccnt = [0] * 10\n\n\ndef rec(lvl):\n global ans, ccnt\n if lvl >= 10:\n s = sum(ccnt)\n if s == ccnt[0]:\n return\n\n cc = fact(s) / s * (s - ccnt[0])\n for x in ccnt:\n cc /= fact(x)\n\n ans += cc\n return\n\n for i in xrange(int(cnt[lvl] != 0), cnt[lvl] + 1):\n ccnt[lvl] = i\n rec(lvl + 1)\n\nrec(0)\n\nprint ans"}, {"source_code": "arr = [int(x) for x in list(raw_input())]\nfact = [1 for x in range(20)]\nfor i in range(2,20):\n fact[i] = i*fact[i-1]\ncnt = [0 for x in range(10)]\nfor i in arr:\n cnt[i] += 1\nans = [0]\ndef solve(li,dep):\n if dep==-1:\n for i in range(10):\n if not li[i] and cnt[i]:\n return\n res = fact[sum(li)]\n for i in range(10):\n if li[i]:\n res /= fact[li[i]]\n if li[0]:\n res -= res*li[0]/sum(li)\n ans[0] += res\n else:\n for i in range(cnt[dep]+1):\n li[dep] = i\n solve(li,dep-1)\ntmp = [0 for x in range(10)]\nfor i in range(cnt[9]+1):\n tmp[9] = i\n solve(tmp,8)\nprint ans[0]"}, {"source_code": "from math import factorial\n\nmemo={}\nvis=set()\n\ndef getnp(zeros, nums):\n if (zeros, tuple(nums)) in vis:\n return 0\n vis.add((zeros, tuple(nums)))\n\n sn=sum(nums)\n configs=factorial(sn+zeros)\n for n in nums:\n configs/=factorial(n)\n configs/=factorial(zeros)\n\n res=(sn*configs)/(sn+zeros)\n for i in range(len(nums)):\n if nums[i]>1:\n nums[i]-=1\n res+=getnp(zeros,nums)\n nums[i]+=1\n if zeros>1:\n res+=getnp(zeros-1,nums)\n memo[(zeros, tuple(sorted(nums)))]=res\n return res\n\ns=raw_input()\nzeros=s.count('0')\nnums=[]\nfor i in range(1,10):\n cnt=s.count(chr(ord('0')+i))\n nums.append(cnt)\n\nprint getnp(zeros, nums)\n \n \n"}, {"source_code": "#import resource\n#import sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x10000000)\nfrom sys import stdin, stdout\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\ndef BS(arr, l, r, x):\n if r >= l:\n mid = l + (r - l)/2\n if arr[mid] == x:\n return mid\n elif arr[mid] > x:\n return BS(arr, l, mid-1, x)\n else:\n return BS(arr, mid+1, r, x)\n else:\n return -1\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport itertools\nimport math\nimport Queue\n\"\"\"-----------------------------------------------------------------------------\"\"\"\na=raw_input()\nl=[0]*10\nfor i in range(len(a)):\n l[int(a[i])]+=1\ng=0\nfor a1 in range(min(1,l[0]),l[0]+1):\n for a2 in range(min(1,l[1]),l[1]+1):\n for a3 in range(min(1,l[2]),l[2]+1):\n for a4 in range(min(1,l[3]),l[3]+1):\n for a5 in range(min(1,l[4]),l[4]+1):\n for a6 in range(min(1,l[5]),l[5]+1):\n for a7 in range(min(1,l[6]),l[6]+1):\n for a8 in range(min(1,l[7]),l[7]+1):\n for a9 in range(min(1,l[8]),l[8]+1):\n for a10 in range(min(1,l[9]),l[9]+1):\n p=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]\n t=0\n f=1\n for i in range(10):\n t+=p[i]\n f*=math.factorial(p[i])\n t-=1\n t=math.factorial(t)\n for i in range(1,10):\n if(p[i]>0):\n h=f/math.factorial(p[i])\n h*=math.factorial(p[i]-1)\n g+=t/h\nprint g\n"}, {"source_code": "n = input()\n\nf = [0] * 10\n\nm = n\nwhile m > 0:\n r = m % 10\n m /= 10\n f[r] += 1\n\nfact = [1] * 20\nfor i in xrange(1, 20):\n fact[i] = i * fact[i - 1]\n\n# final answer\nans = 0\n\n# fix a digit\nfor d in xrange(1, 10):\n if f[d] == 0: continue\n f[d] -= 1\n\n st0 = 1\n if f[0] == 0: st0 = 0\n for x0 in xrange(st0, f[0] + 1):\n st1 = 1\n if f[1] == 0 or d == 1: st1 = 0\n for x1 in xrange(st1, f[1] + 1):\n st2 = 1\n if f[2] == 0 or d == 2: st2 = 0\n for x2 in xrange(st2, f[2] + 1):\n st3 = 1\n if f[3] == 0 or d == 3: st3 = 0\n for x3 in xrange(st3, f[3] + 1):\n st4 = 1\n if f[4] == 0 or d == 4: st4 = 0\n for x4 in xrange(st4, f[4] + 1):\n st5 = 1\n if f[5] == 0 or d == 5: st5 = 0\n for x5 in xrange(st5, f[5] + 1):\n st6 = 1\n if f[6] == 0 or d == 6: st6 = 0\n for x6 in xrange(st6, f[6] + 1):\n st7 = 1\n if f[7] == 0 or d == 7: st7 = 0\n for x7 in xrange(st7, f[7] + 1):\n st8 = 1\n if f[8] == 0 or d == 8: st8 = 0\n for x8 in xrange(st8, f[8] + 1):\n st9 = 1\n if f[9] == 0 or d == 9: st9 = 0\n for x9 in xrange(st9, f[9] + 1):\n S = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9\n num = fact[S]\n num /= fact[x0]; num /= fact[x1]; num /= fact[x2]; num /= fact[x3]; num /= fact[x4]\n num /= fact[x5]; num /= fact[x6]; num /= fact[x7]; num /= fact[x8]; num /= fact[x9]\n\n ans += num\n f[d] += 1\n\nprint ans"}, {"source_code": "def factor(n):\n ans = 1\n for i in range(2, n + 1):\n ans *= i\n return ans\ncnt = [0] * 10\nans = 0\ndef f(cnts):\n global cnt\n global ans\n if (len(cnts) == 10):\n lenk = 0\n #print(cnts)\n for i in range(10):\n lenk += cnts[i]\n cur = (factor(lenk) * (lenk - cnts[0])) // lenk\n #print(cur, lenk)\n for i in range(10):\n cur = cur // factor(cnts[i])\n ans += cur\n else:\n if (cnt[len(cnts)] <= 1):\n cnts.append(cnt[len(cnts)])\n f(cnts)\n cnts.pop()\n return None\n for i in range(1, cnt[len(cnts)] + 1):\n cnts.append(i)\n f(cnts)\n cnts.pop()\nn = int(input())\nlenk = 0\nwhile(n != 0):\n cnt[n % 10] += 1\n n = n // 10\n lenk += 1\nmaxi = 0\nfor i in range(10):\n maxi = max(maxi, cnt[i])\nf([])\nprint(ans)\n \n"}, {"source_code": "import sys\nimport math\nfrom collections import defaultdict\nans=0\ndef get(dic,cur,size,ans,arr,vis):\n if vis[tuple(arr)]==1:\n return 0\n vis[tuple(arr)]=1\n res=fac[size]\n for i in cur:\n res//=fac[cur[i]]\n #print(res,'ans',size,'size',cur,'cur',dic,'dic')\n if cur['0']>0:\n y=fac[size-1]\n for i in cur:\n if i!='0':\n y//=fac[cur[i]]\n else:\n y//=fac[cur[i]-1]\n res-=y\n #print(res,'res')\n ans+=res\n #print(ans,'adnekw')\n res2=0\n for j in dic:\n if dic[j]>=1:\n temp=cur.copy()\n temp[j]+=1\n dictemp=dic.copy()\n dictemp[j]-=1\n arr[int(j)]-=1\n x=get(dictemp,temp,size+1,ans,arr,vis)\n arr[int(j)]+=1\n res2+=x\n #print(x,'x')\n #ans+=x\n return res+res2\ns=sys.stdin.readline()[:-1]\nfac=[1]\nfor i in range(1,30):\n x=fac[-1]*i\n fac.append(x)\n#print(fac,'fac')\ndic=defaultdict(int)\nn=len(s)\narr=[0 for _ in range(10)]\nfor i in range(n):\n dic[s[i]]+=1\n arr[int(s[i])]+=1\ncur=defaultdict(int)\nfor i in dic:\n dic[i]-=1\n cur[i]+=1\n arr[int(i)]-=1\n#vis[tuple(arr)]=1\n#print(ans,'ansnsnns')\nvis=defaultdict(int)\nx=get(dic,cur,len(dic),ans,arr,vis)\nprint(x)\n"}, {"source_code": "n=input()\ns=[0 for i in range(10)]\nfor i in n:\n s[int(i)]+=1\n\nnol=s[0]\ndel s[0]\n#while 0 in s:\n# s.remove(0)\ndef C(n,k): # C(10,2)=45\n def fact(k):\n s=1\n for i in range(1,k+1):\n s*=i\n return s\n return fact(n)/(fact(k)*fact(n-k))\ndef var(nol, koeff):\n def C(n,k): # C(10,2)=45\n def fact(k):\n s=1\n for i in range(1,k+1):\n s*=i\n return s\n return fact(n)/(fact(k)*fact(n-k))\n n=0\n if nol!=0:\n koeff.append(nol)\n for i in koeff:\n n+=i\n s=1\n for k in koeff:\n s*=C(n, k)\n n-=k\n if nol!=0:\n koeff.remove(nol)\n nol-=1\n koeff.append(nol)\n s2=1\n n=0\n for i in koeff:\n n+=i\n for k in koeff:\n s2*=C(n,k)\n n-=k\n s-=s2\n return s\nc=0\nnado=len(s)-s.count(0)\nif nol!=0:\n counter=1\nelse:\n counter=0\nfor nolik in range(nol+1):\n for c1 in range(s[0]+1):\n for c2 in range(s[1]+1):\n for c3 in range(s[2]+1):\n for c4 in range(s[3]+1):\n for c5 in range(s[4]+1):\n for c6 in range(s[5]+1):\n for c7 in range(s[6]+1):\n for c8 in range(s[7]+1):\n for c9 in range(s[8]+1):\n koeff=[c1,c2,c3,c4,c5,c6,c7,c8,c9]\n while 0 in koeff:\n koeff.remove(0)\n if len(koeff)==nado:\n if counter==1 and nolik>=1 or counter==0:\n c+=var(nolik, koeff)\nprint(int(c))"}, {"source_code": "from sys import stdin\nfrom math import factorial as fac\ns=list(stdin.readline().strip())\ntop=2**len(s)\nfor i in range(len(s)):\n s[i]=int(s[i])\ns.sort()\ndef can(s1):\n dp=[False for i in range(10)]\n for i in range(len(s1)):\n dp[s1[i]]=True\n for i in s:\n if dp[i]==False:\n return False\n return True\ndef countf(y):\n d={0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}\n tot=len(y)\n for i in y:\n d[i]+=1\n ans=0\n a=fac(tot-1)\n for i in range(1,10):\n if d[i]>0:\n b=1\n for j in range(10):\n if i==j:\n b*=fac(d[j]-1)\n else:\n b*=fac(d[j])\n ans+=a//b\n return ans\nr=0\nst=set()\nfor i in range(1,top):\n x=i\n y=[]\n z=0\n z1=0\n for j in range(len(s)):\n if x&1:\n z1+=s[j]*10**z\n y.append(s[j])\n z+=1\n x>>=1\n if can(y) and z1 not in st:\n st.add(z1)\n r+=countf(y)\nprint(r)\n \n"}], "negative_code": [{"source_code": "\n\n\nfactorial_array=[1]\nfor x in range(1,20):\n factorial_array.append(factorial_array[-1]*x)\ndef factorial(x):\n global factorial_array\n return factorial_array[x]\n\ndef generate(array):\n start=factorial(sum(array))\n for x in range(10):\n start//=factorial(array[x])\n return start\n\ndef main():\n string=input()\n store=[0 for x in range(10)]\n for x in range(len(string)):\n store[int(string[x])]+=1\n all_possible=[[]]\n for x in range(10):\n next_all_possible=[]\n for y in all_possible:\n if store[x]==0:\n next_all_possible.append(y+[0])\n else:\n for z in range(1,store[x]+1):\n next_all_possible.append(y+[z])\n all_possible=next_all_possible.copy() \n total=0\n for x in all_possible:\n pole=1\n times=x[0]\n for y in range(times+1):\n total+=pole*(generate(x))\n pole*=-1\n x[0]-=1\n print(total)\nmain()\n"}, {"source_code": "from collections import defaultdict\n\nn = [int(i) for i in input()]\nst = frozenset(n)\nini = [n.count(i) for i in range(10)]\ndp = defaultdict(int)\n\ndef dfs(state):\n key = tuple(state)\n if key in dp:\n return dp[key]\n\n if all(state[i] > 0 for i in st):\n dp[key] += 1\n\n for i in range(10):\n if state[i] < ini[i]:\n state[i] += 1\n dp[key] += dfs(state)\n state[i] -= 1\n return dp[key]\n\nans = 0\ns = [0] * 10\nfor i in range(1, 10):\n if ini[i]:\n s[i] = 1\n ans += dfs(s)\n\nprint(ans)"}, {"source_code": "import math;\n\nn = int(input())\nif(n<10) :\n\tprint(1)\nelse :\n\ttmp = n;\n\tfrek = [ 0 for _ in range(10)]\n\ttotal = 0\n\twhile tmp>0 :\n\t\tfrek[tmp%10]+=1\n\t\ttmp //= 10\n\t\ttotal += 1\n\ttotal -= 1\n\tans = 0\n\tfor i in range(1, 10) :\n\t\tif frek[i] > 0 :\n\t\t\ttmp = math.factorial(total) // math.factorial(frek[i]-1)\n\t\t\tfor j in range(0, 10) :\n\t\t\t\tif i!=j and frek[j]>0 :\n\t\t\t\t\ttmp //= math.factorial(frek[j])\n\t\t\t\t\t\n\t\t\tans += tmp\n\tprint(ans)"}, {"source_code": "import math\nfrom collections import defaultdict\n\ndp = defaultdict(list)\nfact = dict()\n\ndef facto(val) :\n\tif val not in fact.keys() :\n\t\tfact[val] = math.factorial(val)\n\treturn fact[val]\n\ndef hitung(frek, total) :\n\tglobal dp\n\tkeys = ' '.join(str(x) for x in frek)\n\tif keys in dp.keys() :\n\t\treturn dp[keys]\n\tans = 0\n\tfor i in range(1, 10) :\n\t\tif frek[i] > 0 :\n\t\t\ttmp = facto(total) // facto(frek[i]-1)\n\t\t\tfor j in range(0, 10) :\n\t\t\t\tif i!=j and frek[j]>0 :\n\t\t\t\t\ttmp //= facto(frek[j])\n\t\t\tans += tmp\n\tfor i in range(0, 10) :\n\t\tif frek[i]>1 :\n\t\t\tfrek[i] -=1\n\t\t\tans += hitung(frek, total-1)\n\t\t\tfrek[i] += 1\n\tdp[keys] = ans\n\treturn ans;\n \nn = int(input())\nif(n<10) :\n\tprint(1)\nelse :\n\ttmp = n;\n\tfrek = [ 0 for _ in range(10)]\n\ttotal = 0\n\twhile tmp>0 :\n\t\tfrek[tmp%10]+=1\n\t\ttmp //= 10\n\t\ttotal += 1\n\tprint(hitung(frek, total-1))"}, {"source_code": "a = int(input())\nb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nwhile a != 0:\n b[a % 10] += 1\n a //= 10\n\nans = 0\n\ndef fact(n):\n f = 1\n for i in range(1, n + 1):\n f *= i\n return f\n\ndef f(n, arr):\n #print(arr)\n global ans\n if n == 10:\n sum = 0\n for i in range(10):\n sum += arr[i]\n temp = 1\n temp *= sum - b[0]\n temp *= fact(sum - 1)\n for i in range(10):\n if arr[i] > 1:\n temp //= fact(arr[i])\n ans += temp\n #print(ans)\n else:\n if b[n] > 0:\n for i in range(1, b[n] + 1):\n temp = arr.copy()\n temp.append(i)\n f(n + 1, temp)\n else:\n arr.append(0)\n f(n + 1, arr)\n\n\nf(0, [])\nprint(int(ans))"}, {"source_code": "a = int(input())\nb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nwhile a != 0:\n b[a % 10] += 1\n a //= 10\n\nans = 0\n\ndef fact(n):\n f = 1\n for i in range(1, n + 1):\n f *= i\n return f\n\ndef f(n, arr):\n #print(arr)\n global ans\n if n == 10:\n sum = 0\n for i in range(10):\n sum += arr[i]\n temp = 1\n temp *= sum - b[0]\n temp *= fact(sum - 1)\n for i in range(10):\n if arr[i] > 1:\n temp /= fact(b[i])\n ans += temp\n #print(ans)\n else:\n if b[n] > 0:\n for i in range(1, b[n] + 1):\n temp = arr.copy()\n temp.append(i)\n f(n + 1, temp)\n else:\n arr.append(0)\n f(n + 1, arr)\n\n\nf(0, [])\nprint(int(ans))"}, {"source_code": "a = int(input())\nb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nwhile a != 0:\n b[a % 10] += 1\n a //= 10\n\nans = 0\n\ndef fact(n):\n f = 1\n for i in range(1, n + 1):\n f *= i\n return f\n\ndef f(n, arr):\n #print(arr)\n global ans\n if n == 10:\n sum = 0\n for i in range(10):\n sum += arr[i]\n temp = 1\n temp *= sum - b[0]\n temp *= fact(sum - 1)\n for i in range(10):\n if arr[i] > 1:\n temp //= fact(b[i])\n ans += temp\n #print(ans)\n else:\n if b[n] > 0:\n for i in range(1, b[n] + 1):\n temp = arr.copy()\n temp.append(i)\n f(n + 1, temp)\n else:\n arr.append(0)\n f(n + 1, arr)\n\n\nf(0, [])\nprint(int(ans))"}, {"source_code": "import itertools\n\n\ndef de(n):\n global w\n if len(n) > 0:\n for i in range(1, len(n)):\n z = list(itertools.permutations(n, len(n)))\n for j in range(len(z)):\n r = ''\n for t in range(len(z[j])):\n r += str(z[j][t])\n if r[0] != 0:\n\n qw = set()\n for i4 in range(len(r)):\n qw.add(r[i4])\n if len(qw) == el and r[0] != '0':\n w.add(r)\n \n for i in range(len(n)):\n de(n[:i] + n[i + 1:])\n \n\na2 = int(input())\na = a2\ns = [0] * 10\n\nwhile a > 0:\n s[a % 10] += 1\n a = a // 10\n \nb = str(a2)\n\nrt = set()\nfor i in range(len(s)):\n if s[i] > 0:\n rt.add(i)\nel = len(rt)\n\nw = set()\nde(b)\nprint(len(w))"}, {"source_code": "from math import factorial as fac\ndef generate_poslist(lis,length):\n if length==0:\n return [[]]\n elems=lis[0]\n temp=lis.pop(0)\n recval=generate_poslist(lis,length-1)\n ansl=[]\n for anyl in recval:\n ansl.extend(list(map(lambda x:[x]+anyl,elems)))\n return ansl\ndef getsum(l):\n sumfac=fac(sum(l))\n prod=1\n for e in l:\n prod=prod*fac(e)\n return sumfac/prod\n\nwnum=input('')\ndigdic=dict()\nfor dig in wnum:\n digdic[dig]=digdic.get(dig,0)+1\n#check how to check whther sometinh is a number or a list\nbaselist=[]\nfor (key,val) in digdic.items():\n baselist.append(list(range(1,val+1)))\npossibility_list=generate_poslist(baselist,len(baselist))\nsum1=0\nsum2=0\nfor lis in possibility_list:\n sum1+=getsum(lis)\nforzero=digdic.get('0',0);\nif forzero!=0:\n if forzero==1:\n del digdic['0']\n else:\n digdic['0']=forzero-1\n baselist=[]\n for (key,val) in digdic.items():\n baselist.append(list(range(1,val+1)))\n possibility_list=generate_poslist(baselist,len(baselist))\n\n for lis in possibility_list:\n sum2+=getsum(lis)\nprint(int(sum1-sum2))\n"}, {"source_code": "def main():\n def fact(x):\n if x == 0:\n return 1\n return x * fact(x - 1)\n n = input()\n l = len(n)\n def helper(dc):\n a = 0\n temp = [dc[j] for j in dc if j != '0']\n s = sum(temp)\n try:\n ret = fact(s) * fact(s + dc['0'] - 1) // (fact(s - 1) * fact(dc['0']))\n except:\n ret = fact(s)\n for i in temp:\n ret = ret // fact(i)\n for i in dc:\n if dc[i] != 1:\n d = dc\n d[i] -= 1\n a += helper(d)\n return ret + a\n dct = {}\n for i in set(n):\n dct[i] = n.count(str(i))\n print(helper(dct))\n return 0\nmain()\n"}, {"source_code": "from collections import defaultdict\nimport math\n\n\ndef com(N, R):\n if not N >= R >= 0:\n return 0\n return math.factorial(N)//(math.factorial(R)*math.factorial(N-R))\n\n\ndef solve():\n a = list(map(int, list(input())))\n d = defaultdict(int)\n for v in a:\n d[v] += 1\n que = [(key, value) for key, value in d.items()]\n que.sort()\n\n def recursion(index):\n if index == len(que) - 1:\n num, numcnt = que[index]\n return [[(num, i)] for i in range(1, numcnt + 1)]\n else:\n res = []\n num, numcnt = que[index]\n for i in range(1, numcnt + 1):\n for v in recursion(index + 1):\n add = v.copy()\n add.append((num, i))\n res.append(add)\n return res\n\n res = recursion(0)\n ans = 0\n for v in res:\n v.reverse()\n S = math.factorial(sum(x[1] for x in v))\n for x in v:\n S //= math.factorial(x[1])\n S = S*(len(a) - d[0])//len(a)\n ans += S\n print(ans)\n return\n\n\nsolve()\n\n"}, {"source_code": "import math\n\n\ndef get_n_vars_when_amounts_fixed(a):\n\tprint(\"b\", b)\n\tt = math.factorial(sum(a[1:]))\n\tfor i in range(1, len(a)):\n\t\tt = t // math.factorial(a[i])\n\n\tfor i in range(a[0]):\n\t\tt *= (sum(a[1:]) + i);\n\tt // math.factorial(a[0])\n\tprint(\"t\", t)\n\treturn t\n\ndef gen(a, b, pos):\n\tif pos == 10:\n\t\treturn get_n_vars_when_amounts_fixed(b)\n\n\tif a[pos] == 0:\n\t\treturn gen(a, b, pos + 1)\n\n\tans = 0\n\tfor i in range(1, a[pos] + 1):\n\t\tb[pos] = i\n\t\tans += gen(a, b, pos + 1)\n\n\treturn ans\n\na = [0] * 10\ns = input()\nfor ch in s:\n\ta[int(ch)] += 1\n\n# print(a)\n\nb = [0] * 10\nans = gen(a, b, 0)\n\nprint(ans)\n\n"}, {"source_code": "import math\n\n\ndef get_n_vars_when_amounts_fixed(a):\n\t# print(\"b\", b)\n\tt = math.factorial(sum(a[1:]))\n\tfor i in range(1, len(a)):\n\t\tt = t // math.factorial(a[i])\n\n\tfor i in range(a[0]):\n\t\tt *= (sum(a[1:]) + i);\n\tt // math.factorial(a[0])\n\t# print(\"t\", t)\n\treturn t\n\ndef gen(a, b, pos):\n\tif pos == 10:\n\t\treturn get_n_vars_when_amounts_fixed(b)\n\n\tif a[pos] == 0:\n\t\treturn gen(a, b, pos + 1)\n\n\tans = 0\n\tfor i in range(1, a[pos] + 1):\n\t\tb[pos] = i\n\t\tans += gen(a, b, pos + 1)\n\n\treturn ans\n\na = [0] * 10\ns = input()\nfor ch in s:\n\ta[int(ch)] += 1\n\n# print(a)\n\nb = [0] * 10\nans = gen(a, b, 0)\n\nprint(ans)\n\n"}, {"source_code": "def rec(n, a):\n\tans = fact[n]\n\tif a[0] != 0:\n\t\tans //= fact[a[0]]\n\t\tans -= fact[n - a[0]]\n\ttemp = 0\n\tfor i in range(1, 10):\n\t\tif a[i] != 0:\n\t\t\tif (ans % fact[a[i]] != 0):\n\t\t\t\texit(0)\n\t\t\tans //= fact[a[i]]\n\t\t\tif a[i] != 1:\n\t\t\t\ta[i] -= 1\n\t\t\t\ttemp += rec(n - 1, a)\n\t\t\t\ta[i] += 1\n\treturn ans + temp\n\n\ns = str(input())\nn = len(s)\nfact = []\nfact.append(1)\nfor i in range(1, 30):\n\tfact.append(fact[i - 1] * i)\na = []\nfor i in range(10):\n\ta.append(0)\nfor i in range(n):\n\ta[ord(s[i]) - ord('0')] += 1\nprint(int(rec(n, a)))"}, {"source_code": "def rec(n, a):\n\tans = fact[n]\n\tif a[0] != 0:\n\t\tans //= fact[a[0]]\n\t\tans -= fact[n - 1]\n\ttemp = 0\n\tfor i in range(1, 10):\n\t\tif a[i] != 0:\n\t\t\tans //= fact[a[i]]\n\t\t\tif a[i] != 1:\n\t\t\t\ta[i] -= 1\n\t\t\t\ttemp += rec(n - 1, a)\n\t\t\t\ta[i] += 1\n\treturn ans + temp\n\n\ns = str(input())\nn = len(s)\nfact = []\nfact.append(1)\nfor i in range(1, 19):\n\tfact.append(fact[i - 1] * i)\na = []\nfor i in range(10):\n\ta.append(0)\nfor i in range(n):\n\ta[ord(s[i]) - ord('0')] += 1\nprint(int(rec(n, a)))"}, {"source_code": "def rec(n, a):\n\tans = fact[n]\n\tif a[0] != 0:\n\t\tans -= a[0] * fact[n - 1]\n\t\tans //= fact[a[0]]\n\ttemp = 0\n\tfor i in range(1, 10):\n\t\tif a[i] != 0:\n\t\t\tans //= fact[a[i]]\n\t\t\tif a[i] != 1:\n\t\t\t\ta[i] -= 1\n\t\t\t\ttemp += rec(n - 1, a)\n\t\t\t\ta[i] += 1\n\treturn ans + temp\n\n\ns = str(input())\nn = len(s)\nfact = []\nfact.append(1)\nfor i in range(1, 30):\n\tfact.append(fact[i - 1] * i)\na = []\nfor i in range(10):\n\ta.append(0)\nfor i in range(n):\n\ta[ord(s[i]) - ord('0')] += 1\nprint(int(rec(n, a)))"}, {"source_code": "def rec(n, a):\n\tans = fact[n]\n\tif a[0] != 0:\n\t\tans -= fact[n - 1]\n\t\tans //= fact[a[0]]\n\ttemp = 0\n\tfor i in range(1, 10):\n\t\tif a[i] != 0:\n\t\t\tans //= fact[a[i]]\n\t\t\tif a[i] != 1:\n\t\t\t\ta[i] -= 1\n\t\t\t\ttemp += rec(n - 1, a)\n\t\t\t\ta[i] += 1\n\treturn ans + temp\n\n\ns = str(input())\nn = len(s)\nfact = []\nfact.append(1)\nfor i in range(1, 30):\n\tfact.append(fact[i - 1] * i)\na = []\nfor i in range(10):\n\ta.append(0)\nfor i in range(n):\n\ta[ord(s[i]) - ord('0')] += 1\nprint(int(rec(n, a)))"}, {"source_code": "def rec(n, a):\n\tans = fact[n]\n\tif a[0] != 0:\n\t\tans //= fact[a[0]]\n\t\tans -= fact[n - a[0]]\n\ttemp = 0\n\tfor i in range(1, 10):\n\t\tif a[i] != 0:\n\t\t\tans //= fact[a[i]]\n\t\t\tif a[i] != 1:\n\t\t\t\ta[i] -= 1\n\t\t\t\ttemp += rec(n - 1, a)\n\t\t\t\ta[i] += 1\n\treturn ans + temp\n\n\ns = str(input())\nn = len(s)\nfact = []\nfact.append(1)\nfor i in range(1, 30):\n\tfact.append(fact[i - 1] * i)\na = []\nfor i in range(10):\n\ta.append(0)\nfor i in range(n):\n\ta[ord(s[i]) - ord('0')] += 1\nprint(int(rec(n, a)))"}, {"source_code": "import math\nimport sys\ndef newt(n,k):\n return (math.factorial(n)//math.factorial(k))//math.factorial(n-k)\ndef go(occ,used):\n # print(occ,used)\n cnt=[0]*18\n cnt[0]=1\n for digit,rep in enumerate(occ):\n if cnt==0 or rep==0:\n continue\n res=[0]*18\n r=range(rep+1) if digit==used else range(1,rep+1)\n for i in r:\n\n for j,x in enumerate(cnt):\n if i+j>=18:continue\n res[i+j]+=x*newt(j+i,i)\n cnt=res\n return sum(cnt)\n\n\nn=input()\nocc = [ n.count(str(x)) for x in range(10)]\nans=0\nfor i in range(1,10):\n if occ[i]>0:\n occ[i]-=1\n ans+=go(occ,i)\n occ[i]+=1\nprint(ans)"}, {"source_code": "import collections\nimport itertools\n\nn = input()\n\nfibo = [1]\nwhile len(fibo) <= len(n):\n fibo.append(fibo[-1] * len(fibo))\n\ncnts = collections.defaultdict(int)\nfor x in n:\n cnts[int(x)] += 1\n\n\ndef get_ans(cnts):\n ret = 0\n choices = itertools.product(*(range(1, x + 1) for x in cnts.values()))\n for choice in choices:\n a, b = 0, 1\n for x in choice:\n a += x\n b *= fibo[x]\n a = fibo[a]\n ret += a // b\n return ret\n\n\nans = get_ans(cnts)\nif cnts[0] > 0:\n cnts[0] -= 1\n if cnts[0] == 0:\n del cnts[0]\n ans -= get_ans(cnts)\n\nprint(ans)\n"}, {"source_code": "from collections import *\nfrom itertools import combinations\nfrom sys import stdin\n\n\ndef fact(be, en):\n res = [1]\n for i in range(be, en + 1):\n res.append(res[-1] * i)\n return res\n\n\nn = stdin.readline().strip()\nfacs, dis, ans = fact(1, len(n)), set(n), 0\nvis = set()\n\nfor i in range(1, len(n) + 1):\n for com in combinations(n, i):\n if len(set(com)) == len(dis) and tuple(sorted(com)) not in vis:\n mem, tem = Counter(com), facs[i]\n\n for k, j in mem.items():\n tem //= facs[j]\n if k == '0':\n tem -= (i - 1)\n\n ans += tem\n\n vis.add(tuple(sorted(com)))\nprint(ans)\n"}, {"source_code": "#import resource\n#import sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x10000000)\n\nfrom sys import stdin, stdout\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\ndef BS(arr, l, r, x):\n if r >= l:\n mid = l + (r - l)/2\n if arr[mid] == x:\n return mid\n elif arr[mid] > x:\n return BS(arr, l, mid-1, x)\n else:\n return BS(arr, mid+1, r, x)\n else:\n return -1\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport itertools\nimport math\nimport Queue\na=raw_input()\ndef fuck(l,g):\n t=0\n f=1\n for i in range(10):\n t+=l[i]\n f*=math.factorial(l[i])\n t-=1\n t=math.factorial(t)\n for i in range(1,10):\n if(l[i]>0):\n h=f/math.factorial(l[i])\n h*=math.factorial(l[i]-1)\n g[0]+=t/h\n for i in range(10):\n if(l[i]>1):\n l[i]-=1\n fuck(l,g)\n l[i]+=1\nl=[0]*10\nfor i in range(len(a)):\n l[int(a[i])]+=1\ng=[0]\nfuck(l,g)\nprint g[0]\n"}, {"source_code": "from math import factorial\nfrom functools import lru_cache\n\n@lru_cache()\ndef choose(n, k):\n\treturn factorial(n) // factorial(n - k) // factorial(k)\n\n\ndef pos(l):\n\t# list of nums\n\tout = 1\n\ts = sum(l)\n\tfor i in l:\n\t\tout *= choose(s, i)\n\t\ts -= i\n\treturn out\n\n\n@lru_cache()\ndef doit(l, i):\n\tif i == len(l):\n\t\treturn pos(l)\n\tout = 0\n\tfor j in range(l[i]):\n\t\tnewl = list(l)\n\t\tnewl[i] = j+1\n\t\tout += doit(tuple(newl), i+1)\n\treturn out\n\t\n\nn = input()\ncounts = [n.count(str(i)) for i in set(n)]\nout = doit(tuple(counts), 0)\nif \"0\" in n:\n\tcounts2 = [n.count(str(i)) - (i == \"0\") for i in set(n)]\n\tcounts2 = list(filter(None, counts2))\n\tout -= doit(tuple(counts2), 0)\n\nprint(out)\n"}, {"source_code": "def factor(n):\n ans = 1\n for i in range(2, n + 1):\n ans *= i\n return ans\nn = int(input())\ncnt = [0] * 10\nlen = 0\nwhile(n != 0):\n cnt[n % 10] += 1\n n = n // 10\n len += 1\nans = (factor(len) * (len - cnt[0])) // len\nfor i in range(10):\n ans = ans // factor(cnt[i])\nfor i in range(10):\n for j in range(1, cnt[i]):\n cnt[i] -= j\n len -= j\n cur = (factor(len) * (len - cnt[0])) // len\n for k in range(10):\n cur = cur // factor(cnt[k])\n ans += cur\n len += j\n cnt[i] += j\nprint(ans)\n \n"}, {"source_code": "def factor(n):\n ans = 1\n for i in range(2, n + 1):\n ans *= i\n return ans\ncnt = [0] * 10\nans = 0\ndef f(cnts):\n global cnt\n global ans\n if (len(cnts) == 10):\n for i in range(10):\n if (cnt[i] != cnts[i]):\n break\n if (i == 9):\n return None\n lenk = 0\n for i in range(10):\n lenk += cnts[i]\n cur = (factor(lenk) * (lenk - cnt[0])) // lenk\n for i in range(10):\n cur = cur // factor(cnts[i])\n ans += cur\n else:\n if (cnt[len(cnts)] <= 1):\n cnts.append(cnt[len(cnts)])\n f(cnts)\n cnts.pop()\n return None\n for i in range(1, cnt[len(cnts)] + 1):\n cnts.append(i)\n f(cnts)\n cnts.pop()\nn = int(input())\nlenk = 0\nwhile(n != 0):\n cnt[n % 10] += 1\n n = n // 10\n lenk += 1\nans += (factor(lenk) * (lenk - cnt[0])) // lenk\nfor i in range(10):\n ans = ans // factor(cnt[i])\nmaxi = 0\nfor i in range(10):\n maxi = max(maxi, cnt[i])\nif (maxi > 1):\n f([])\nprint(ans)\n \n"}, {"source_code": "def factor(n):\n ans = 1\n for i in range(2, n + 1):\n ans *= i\n return ans\ncnt = [0] * 10\nans = 0\n\ndef f(cnts):\n global cnt\n global ans\n if (len(cnts) == 10):\n lenk = 0\n for i in range(10):\n lenk += cnts[i]\n cur = (factor(lenk) * (lenk - cnt[0])) // lenk\n for i in range(10):\n cur = cur // factor(cnts[i])\n ans += cur\n else:\n if (cnt[len(cnts)] <= 1):\n cnts.append(cnt[len(cnts)])\n f(cnts)\n return None\n for i in range(1, cnt[len(cnts)]):\n cnts.append(i)\n f(cnts)\n cnts.pop()\nn = int(input())\nlenk = 0\nwhile(n != 0):\n cnt[n % 10] += 1\n n = n // 10\n lenk += 1\nans += (factor(lenk) * (lenk - cnt[0])) // lenk\nfor i in range(10):\n ans = ans // factor(cnt[i])\nmaxi = 0\nfor i in range(10):\n maxi = max(maxi, cnt[i]) \nif (maxi > 1):\n f([])\nprint(ans)\n \n"}, {"source_code": "def ii():\n return int(input())\ndef mi():\n return map(int, input().split())\ndef li():\n return list(mi())\n\nfact = [1] * 1000\nfor i in range(2, 1000):\n fact[i] = fact[i - 1] * i\n\ns = input()\ncnt = {}\nfor d in '0123456789':\n cnt[int(d)] = s.count(d)\nans = 0\n\ndef getcnt(p):\n q0 = p[0]\n q = [pi for pi in p if pi != 0]\n num = fact[sum(q)]\n den = 1\n for qi in q:\n den *= fact[qi]\n gc = num // den\n if q0 == 0:\n return gc\n q = [pi for pi in p[1:] if pi != 0]\n num = fact[sum(q)]\n den = 1\n for qi in q:\n den *= fact[qi]\n gc -= num // den\n return gc\n\ndef rec(d, p):\n global ans\n if d == 10:\n #print(p, getcnt(p))\n ans += getcnt(p)\n return\n if cnt[d] == 0:\n p[d] = 0\n rec(d + 1, p)\n return\n for c in range(1, cnt[d] + 1):\n p[d] = c\n rec(d + 1, p)\n\np = [0] * 10\nrec(0, p)\n\nprint(ans)"}, {"source_code": "s = input()\nocc = [0] * 10\nfor c in s: occ[int(c)]+= 1\n# each digit n which occurred, occurs 1 ~ occ[n] times\n\n# first, ignore leading zeroes\nfrom math import factorial as fact\nfrom itertools import combinations\nfrom collections import Counter\ndef multinomial(L):\n res = fact(sum(L))\n for x in L: res//= fact(x)\n return res\n\ndef calculate(occ):\n extra = []\n rocc = [0]*10\n for i in range(10):\n if occ[i]: rocc[i]+= 1\n for j in range(occ[i]-1): extra.append(i)\n ans = 0\n for es in range(len(extra)+1):\n for C in combinations(extra, es):\n for x in C: rocc[x]+= 1\n #print(rocc, multinomial(rocc))\n ans+= multinomial(rocc)\n for x in C: rocc[x]-= 1\n #print(ans)\n return ans\n\ntot = calculate(occ)\nif occ[0] == 0: print(tot)\nelse:\n occ[0]-= 1\n print(tot - calculate(occ))"}, {"source_code": "s = input()\nocc = [0] * 10\nfor c in s: occ[int(c)]+= 1\n# each digit n which occurred, occurs 1 ~ occ[n] times\n\n# first, ignore leading zeroes\nfrom math import factorial as fact\nfrom itertools import combinations\nfrom collections import Counter\ndef multinomial(L):\n res = fact(sum(L))\n for x in L: res//= fact(x)\n \n if L[0] == 0: return res\n L[0]-= 1\n lead0 = fact(sum(L))\n for x in L: lead0//= fact(x)\n L[0]+= 1\n return res - lead0\n\ndef calculate(occ):\n extra = []\n rocc = [0]*10\n for i in range(10):\n if occ[i]: rocc[i]+= 1\n for j in range(occ[i]-1): extra.append(i)\n ans = 0\n for es in range(len(extra)+1):\n for C in combinations(extra, es):\n for x in C: rocc[x]+= 1\n #print(rocc, multinomial(rocc))\n ans+= multinomial(rocc)\n for x in C: rocc[x]-= 1\n #print(ans)\n return ans\n\ntot = calculate(occ)\nprint(tot)\n\n \n"}, {"source_code": "n=input()\nhsh=[0]*10\nfor i in n:\n hsh[ord(i)-ord('0')]+=1\n#print(hsh)\ndef f(n):\n if(n<2):\n return 1\n else:\n return n*f(n-1)\nans=0\ndef rec(table):\n global ans\n s=1\n t=sum(table)\n for i in range(10):\n s*=f(table[i])\n minus=1\n if(table[0]>0):\n table[0]-=1\n for i in range(10):\n minus*=f(table[i])\n ans+=(f(t)//s-f(t-1)//minus)\n table[0]+=1\n else:\n ans+=(f(t)//s)\n \n #print(table,ans,s,f(t))\n for i in range(10):\n if(table[i]>1):\n table[i]-=1\n rec(table)\n table[i]+=1\nrec(hsh)\nprint(ans)\n\n"}, {"source_code": "n = input()\nall = [0] * 10\nfor x in n:\n\tall[int(x)]+=1\nprint (all)\n\ndp = [0] * 20\ndp[0] = 1\nfor i in range(1, 10):\n\tcur = [0] * 20\n\tif(all[i] > 0):\n\t\tfor le in range(0, 20): \n\t\t\tfac = 1\n\t\t\tzn = 1\n\t\t\tfor kol in range(1, all[i] + 1):\n\t\t\t\tif(le + kol < 20):\n\t\t\t\t\tzn *= le + kol\n\t\t\t\t\tfac *= kol\n\t\t\t\t\tcur[le + kol] += (zn // fac) * dp[le]\n\t\tdp = cur\n\nprint(dp)\n\ncur = [0] * 20\nif(all[0] > 0):\n\tfor le in range(1, 20):\n\t\tfac = 1\n\t\tzn = 1\n\t\tfor kol in range(1, all[0] + 1):\n\t\t\tif(le + kol < 20):\n\t\t\t\tzn *= (le + kol-1)\n\t\t\t\tfac *= kol\n\t\t\t\tcur[le + kol] += (zn // fac) * dp[le]\n\tdp = cur\nprint(dp)\n\nprint(sum(dp))\n"}, {"source_code": "n = input()[:-1]\ncnt = [0] * 10\nfor d in n:\n cnt[int(d)] += 1\nm = [0] * 10\nans = 0\ndef DFS(i : int):\n global ans\n if i == 10:\n pans = 1\n for j in range(sum(m)):\n pans *= j + 1\n for j in range(10):\n for k in range(m[j]):\n pans //= k + 1\n ans += pans\n if m[0]:\n pans = 1\n for j in range(1, sum(m)):\n pans *= j\n for j in range(10):\n for k in range(m[j] - (j == 0)):\n pans //= k + 1\n ans -= pans\n elif cnt[i] == 0:\n DFS(i + 1)\n else:\n for j in range(0, cnt[i]):\n m[i] = j + 1\n DFS(i + 1)\nDFS(0)\nprint(ans)"}, {"source_code": "from collections import defaultdict as dd\nfrom math import factorial as f\n\ns = input()\n\ncnt = dd(int)\n\nfor i in s:\n cnt[i] += 1\n\nans = 0\n\ndef calc(cur_chr, dem, do_not_take_sum, total, diff):\n global ans\n global cnt\n\n if cur_chr == '9':\n if do_not_take_sum == total:\n return\n\n ans += f(total - do_not_take_sum) // dem * diff\n return\n\n for do_not_take in range(0, cnt[cur_chr] + 1):\n if do_not_take > 0 and do_not_take == cnt[cur_chr]:\n continue\n calc(chr(ord(cur_chr) + 1), dem * f(cnt[cur_chr] - do_not_take), do_not_take_sum + do_not_take, total, diff)\n\ncalc('0', 1, 0, len(s), 1)\n\nif cnt['0'] != 0:\n cnt['0'] -= 1\n calc('0', 1, 0, len(s) - 1, -1)\n\nprint(ans)\n"}, {"source_code": "from collections import defaultdict as dd\nfrom math import factorial as f\n\ns = input()\n\ncnt = dd(int)\n\nfor i in s:\n cnt[i] += 1\n\nans = 0\n\ndef calc(cur_chr, dem, do_not_take_sum, total, diff):\n global ans\n global cnt\n\n if cur_chr == '9':\n for do_not_take in range(0, cnt[cur_chr] + 1):\n if do_not_take > 0 and do_not_take == cnt[cur_chr]:\n continue\n\n cur_do_not_take_sum = do_not_take_sum + do_not_take\n if cur_do_not_take_sum == total:\n continue\n\n cur_dem = dem * f(cnt[cur_chr] - do_not_take)\n\n ans += f(total - cur_do_not_take_sum) // cur_dem * diff\n return\n\n for do_not_take in range(0, cnt[cur_chr] + 1):\n if do_not_take > 0 and do_not_take == cnt[cur_chr]:\n continue\n calc(chr(ord(cur_chr) + 1), dem * f(cnt[cur_chr] - do_not_take), do_not_take_sum + do_not_take, total, diff)\n\ncalc('0', 1, 0, len(s), 1)\n\nif cnt['0'] != 0:\n cnt['0'] -= 1\n calc('0', 1, 0, len(s) - 1, -1)\n\nprint(ans)\n"}, {"source_code": "# ---------------------------iye ha aam zindegi---------------------------------------------\nimport math\nimport heapq, bisect\nimport sys\nfrom collections import deque, defaultdict\nfrom fractions import Fraction\n\nmod = 10 ** 9 + 7\nmod1 = 998244353\n\n# ------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass TreeNode:\n def __init__(self, k, v):\n self.key = k\n self.value = v\n self.left = None\n self.right = None\n self.parent = None\n self.height = 1\n self.num_left = 1\n self.num_total = 1\n\n\nclass AvlTree:\n\n def __init__(self):\n self._tree = None\n\n def add(self, k, v):\n if not self._tree:\n self._tree = TreeNode(k, v)\n return\n node = self._add(k, v)\n if node:\n self._rebalance(node)\n\n def _add(self, k, v):\n node = self._tree\n while node:\n if k < node.key:\n if node.left:\n node = node.left\n else:\n node.left = TreeNode(k, v)\n node.left.parent = node\n return node.left\n elif node.key < k:\n if node.right:\n node = node.right\n else:\n node.right = TreeNode(k, v)\n node.right.parent = node\n return node.right\n else:\n node.value = v\n return\n\n @staticmethod\n def get_height(x):\n return x.height if x else 0\n\n @staticmethod\n def get_num_total(x):\n return x.num_total if x else 0\n\n def _rebalance(self, node):\n\n n = node\n while n:\n lh = self.get_height(n.left)\n rh = self.get_height(n.right)\n n.height = max(lh, rh) + 1\n balance_factor = lh - rh\n n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)\n n.num_left = 1 + self.get_num_total(n.left)\n\n if balance_factor > 1:\n if self.get_height(n.left.left) < self.get_height(n.left.right):\n self._rotate_left(n.left)\n self._rotate_right(n)\n elif balance_factor < -1:\n if self.get_height(n.right.right) < self.get_height(n.right.left):\n self._rotate_right(n.right)\n self._rotate_left(n)\n else:\n n = n.parent\n\n def _remove_one(self, node):\n \"\"\"\n Side effect!!! Changes node. Node should have exactly one child\n \"\"\"\n replacement = node.left or node.right\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = replacement\n else:\n node.parent.right = replacement\n replacement.parent = node.parent\n node.parent = None\n else:\n self._tree = replacement\n replacement.parent = None\n node.left = None\n node.right = None\n node.parent = None\n self._rebalance(replacement)\n\n def _remove_leaf(self, node):\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = None\n else:\n node.parent.right = None\n self._rebalance(node.parent)\n else:\n self._tree = None\n node.parent = None\n node.left = None\n node.right = None\n\n def remove(self, k):\n node = self._get_node(k)\n if not node:\n return\n if AvlTree._is_leaf(node):\n self._remove_leaf(node)\n return\n if node.left and node.right:\n nxt = AvlTree._get_next(node)\n node.key = nxt.key\n node.value = nxt.value\n if self._is_leaf(nxt):\n self._remove_leaf(nxt)\n else:\n self._remove_one(nxt)\n self._rebalance(node)\n else:\n self._remove_one(node)\n\n def get(self, k):\n node = self._get_node(k)\n return node.value if node else -1\n\n def _get_node(self, k):\n if not self._tree:\n return None\n node = self._tree\n while node:\n if k < node.key:\n node = node.left\n elif node.key < k:\n node = node.right\n else:\n return node\n return None\n\n def get_at(self, pos):\n x = pos + 1\n node = self._tree\n while node:\n if x < node.num_left:\n node = node.left\n elif node.num_left < x:\n x -= node.num_left\n node = node.right\n else:\n return (node.key, node.value)\n raise IndexError(\"Out of ranges\")\n\n @staticmethod\n def _is_left(node):\n return node.parent.left and node.parent.left == node\n\n @staticmethod\n def _is_leaf(node):\n return node.left is None and node.right is None\n\n def _rotate_right(self, node):\n if not node.parent:\n self._tree = node.left\n node.left.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.left\n node.left.parent = node.parent\n else:\n node.parent.right = node.left\n node.left.parent = node.parent\n bk = node.left.right\n node.left.right = node\n node.parent = node.left\n node.left = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n def _rotate_left(self, node):\n if not node.parent:\n self._tree = node.right\n node.right.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.right\n node.right.parent = node.parent\n else:\n node.parent.right = node.right\n node.right.parent = node.parent\n bk = node.right.left\n node.right.left = node\n node.parent = node.right\n node.right = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n @staticmethod\n def _get_next(node):\n if not node.right:\n return node.parent\n n = node.right\n while n.left:\n n = n.left\n return n\navl=AvlTree()\n#-----------------------------------------------binary seacrh tree---------------------------------------\nclass SegmentTree1:\n def __init__(self, data, default='z', func=lambda a, b: min(a ,b)):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass SegmentTree:\n def __init__(self, data, default=0, func=lambda a, b: a + b):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------------------iye ha chutiya zindegi-------------------------------------\nclass Factorial:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorials = [1, 1]\n self.invModulos = [0, 1]\n self.invFactorial_ = [1, 1]\n\n def calc(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.factorials):\n return self.factorials[n]\n nextArr = [0] * (n + 1 - len(self.factorials))\n initialI = len(self.factorials)\n prev = self.factorials[-1]\n m = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = prev * i % m\n self.factorials += nextArr\n return self.factorials[n]\n\n def inv(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n^(-1)\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n p = self.MOD\n pi = n % p\n if pi < len(self.invModulos):\n return self.invModulos[pi]\n nextArr = [0] * (n + 1 - len(self.invModulos))\n initialI = len(self.invModulos)\n for i in range(initialI, min(p, n + 1)):\n next = -self.invModulos[p % i] * (p // i) % p\n self.invModulos.append(next)\n return self.invModulos[pi]\n\n def invFactorial(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate (n^(-1))!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.invFactorial_):\n return self.invFactorial_[n]\n self.inv(n) # To make sure already calculated n^-1\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\n initialI = len(self.invFactorial_)\n prev = self.invFactorial_[-1]\n p = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\n self.invFactorial_ += nextArr\n return self.invFactorial_[n]\n\n\nclass Combination:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorial = Factorial(MOD)\n\n def ncr(self, n, k):\n if k < 0 or n < k:\n return 0\n k = min(k, n - k)\n f = self.factorial\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\n\n\n# --------------------------------------iye ha combinations ka zindegi---------------------------------\ndef powm(a, n, m):\n if a == 1 or n == 0:\n return 1\n if n % 2 == 0:\n s = powm(a, n // 2, m)\n return s * s % m\n else:\n return a * powm(a, n - 1, m) % m\n\n\n# --------------------------------------iye ha power ka zindegi---------------------------------\ndef sort_list(list1, list2):\n zipped_pairs = zip(list2, list1)\n\n z = [x for _, x in sorted(zipped_pairs)]\n\n return z\n\n\n# --------------------------------------------------product----------------------------------------\ndef product(l):\n por = 1\n for i in range(len(l)):\n por *= l[i]\n return por\n\n\n# --------------------------------------------------binary----------------------------------------\ndef binarySearchCount(arr, n, key):\n left = 0\n right = n - 1\n\n count = 0\n\n while (left <= right):\n mid = int((right + left)/ 2)\n\n # Check if middle element is\n # less than or equal to key\n if (arr[mid]<=key):\n count = mid+1\n left = mid + 1\n\n # If key is smaller, ignore right half\n else:\n right = mid - 1\n\n return count\n\n\n# --------------------------------------------------binary----------------------------------------\ndef countdig(n):\n c = 0\n while (n > 0):\n n //= 10\n c += 1\n return c\n\n\ndef countGreater( arr,n, k):\n l = 0\n r = n - 1\n\n # Stores the index of the left most element\n # from the array which is greater than k\n leftGreater = n\n\n # Finds number of elements greater than k\n while (l <= r):\n m = int(l + (r - l) / 2)\n if (arr[m] >= k):\n leftGreater = m\n r = m - 1\n\n # If mid element is less than\n # or equal to k update l\n else:\n l = m + 1\n\n # Return the count of elements\n # greater than k\n return (n - leftGreater)\n\n\n# --------------------------------------------------binary------------------------------------\nl=[]\ndef fact(t):\n r=1\n for i in range(1,t+1):\n r*=i\n return r\ndef calc(d,t,s,r,ans,k):\n if t==len(l):\n if k>0:\n ans+=(fact(s-1)*(s-k))//r\n else:\n ans+=fact(s)//r\n return ans\n for i in range(d[l[t]]):\n if l[t]==0:\n k=i+1\n ans=calc(d,t+1,s+i+1,r*(i+1),ans,k)\n return ans\nn=input()\nd=defaultdict(int)\nfor i in range(len(n)):\n d[int(n[i])]+=1\nl=list(d.keys())\nans=calc(d,0,0,1,0,0)\nprint(ans)\n\n"}, {"source_code": "a=[]\nfact=[]\n\ndef find(num,val,cnt):\n global ans\n if num==10:\n ans+=val*fact[cnt]\n #print(val,cnt,fact[cnt],ans)\n return\n if a[num]>=1:\n i=1\n while i<=a[num]:\n num+=1\n val=val/fact[i]\n cnt+=i\n find(num,val,cnt)\n num-=1\n val=val*fact[i]\n cnt-=i\n i+=1\n else:\n num+=1\n find(num,val,cnt)\n num-=1\n \ndef find1(num,val,cnt):\n global ans\n if num==10:\n ans-=val*fact[cnt]\n return\n if a[num]>=1:\n i=1\n while i<=a[num]:\n num+=1\n val=val/fact[i]\n cnt+=i\n find1(num,val,cnt)\n num-=1\n val=val*fact[i]\n cnt-=i\n i+=1\n else:\n num+=1\n find1(num,val,cnt)\n num-=1\n\n\n\nn=int(input())\nfor i in range(10):\n a.append(0)\nfact.append(1)\nfor i in range(1,20):\n fact.append(fact[i-1]*i)\nm=n\nwhile m>0:\n a[m%10]+=1\n m=m//10\nans=0\nfind(0,1,0)\n#print(ans)\nif a[0]!=0:\n a[0]-=1\n find1(0,1,0)\nprint(int(ans))\n"}, {"source_code": "def faktorijel(num):\n fact = [1, 1,2,6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000]\n return fact[num]\nn = list(input())\nznams = [0,0,0,0,0,0,0,0,0,0]\nfor i in n:\n znams[int(i)] += 1\n#print(znams)\nbroj = 0\nfor broj0 in range(min(znams[0],1), max(1,znams[0]+1)):\n for broj1 in range(min(znams[1],1), max(1,znams[1]+1)):\n for broj2 in range(min(znams[2],1), max(1,znams[2]+1)):\n for broj3 in range(min(znams[3],1), max(1,znams[3]+1)):\n for broj4 in range(min(znams[4],1), max(1,znams[4]+1)):\n for broj5 in range(min(znams[5],1), max(1,znams[5]+1)):\n for broj6 in range(min(znams[6],1), max(1,znams[6]+1)):\n for broj7 in range(min(znams[7],1), max(1,znams[7]+1)):\n for broj8 in range(min(znams[8],1), max(1,znams[8]+1)):\n for broj9 in range(min(znams[9],1), max(1,znams[9]+1)):\n #print(\"vrtise\")\n y = faktorijel(broj0+broj1+broj2+broj3+broj4+broj5+broj6+broj7+broj8+broj9)/(faktorijel(broj0)*faktorijel(broj1)*faktorijel(broj2)*faktorijel(broj3)*faktorijel(broj4)*faktorijel(broj5)*faktorijel(broj6)*faktorijel(broj7)*faktorijel(broj8)*faktorijel(broj9))\n #print(broj0, broj1, broj2, broj3, broj4, broj5, broj6, broj7, broj8, broj9)\n #print(broj)\n broj += y\n if broj0 != 0:\n x = faktorijel(broj0-1+broj1+broj2+broj3+broj4+broj5+broj6+broj7+broj8+broj9)/(faktorijel(broj0-1)*faktorijel(broj1)*faktorijel(broj2)*faktorijel(broj3)*faktorijel(broj4)*faktorijel(broj5)*faktorijel(broj6)*faktorijel(broj7)*faktorijel(broj8)*faktorijel(broj9))\n broj += -x\nprint(broj)\n#print(29340299842560)\n"}, {"source_code": "def faktorijel(n):\n if n == 0:\n return 1\n else:\n x = 1\n for i in range(1, n+1):\n x *= i\n return x\nn = list(input())\nznams = [0,0,0,0,0,0,0,0,0,0]\nfor i in n:\n znams[int(i)] += 1\n#print(znams)\nbroj = 0\nfor broj0 in range(min(znams[0],1), max(1,znams[0]+1)):\n for broj1 in range(min(znams[1],1), max(1,znams[1]+1)):\n for broj2 in range(min(znams[2],1), max(1,znams[2]+1)):\n for broj3 in range(min(znams[3],1), max(1,znams[3]+1)):\n for broj4 in range(min(znams[4],1), max(1,znams[4]+1)):\n for broj5 in range(min(znams[5],1), max(1,znams[5]+1)):\n for broj6 in range(min(znams[6],1), max(1,znams[6]+1)):\n for broj7 in range(min(znams[7],1), max(1,znams[7]+1)):\n for broj8 in range(min(znams[8],1), max(1,znams[8]+1)):\n for broj9 in range(min(znams[9],1), max(1,znams[9]+1)):\n #print(\"vrtise\")\n broj += faktorijel(broj0+broj1+broj2+broj3+broj4+broj6+broj7+broj8+broj9)/(faktorijel(broj0)*faktorijel(broj1)*faktorijel(broj2)*faktorijel(broj3)*faktorijel(broj4)*faktorijel(broj5)*faktorijel(broj6)*faktorijel(broj7)*faktorijel(broj8)*faktorijel(broj9))\n\n if broj0 != 0:\n broj += - faktorijel(broj0-1+broj1+broj2+broj3+broj4+broj6+broj7+broj8+broj9)/(faktorijel(broj0-1)*faktorijel(broj1)*faktorijel(broj2)*faktorijel(broj3)*faktorijel(broj4)*faktorijel(broj5)*faktorijel(broj6)*faktorijel(broj7)*faktorijel(broj8)*faktorijel(broj9))\nprint(int(broj))\n"}, {"source_code": "from collections import Counter\nfrom math import factorial as f\n\n\ndef main():\n s = input()\n le = len(s)\n cnt = Counter(s)\n\n def helper(dp):\n for v in cnt.values():\n l = [0] * len(dp)\n for i in range(1, v + 1):\n for j in range(len(dp) - i):\n l[i + j] += dp[j] // f(i)\n dp = l\n v = 1\n for i in range(len(dp) - 1, 0, -1):\n dp[i] //= v\n v *= i\n return sum(dp)\n\n res = helper([f(le - 1) * (le - bool(cnt['0'])), *[0] * le])\n print(res)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from collections import defaultdict\nfrom copy import deepcopy\n\na = list(input())\n\nd = defaultdict(int)\nfor x in a:\n d[int(x)] += 1\n\nfact_mem = {}\n\n\ndef fact(n):\n if n in fact_mem:\n return fact_mem[n]\n ans = 1\n for i in range(1, n + 1):\n ans *= i\n fact_mem[n] = ans\n return ans\n\n\nmem = {}\n\n\ndef f(d):\n tmp = frozenset(d.items())\n if tmp in mem:\n return mem[tmp]\n n = sum(d.values())\n ans = 0\n if d[0] > 0:\n ans += (n - 1) * fact(n - 1)\n else:\n ans += fact(n)\n for x in d:\n ans //= fact(d[x])\n for k in d:\n if d[k] > 1:\n e = deepcopy(d)\n e[k] -= 1\n ans += f(e)\n mem[frozenset(d.items())] = ans\n return ans\n\n\nans = f(d)\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\nfrom copy import deepcopy\n\na = list(input())\n\nd = defaultdict(int)\nfor x in a:\n d[int(x)] += 1\n\nfact_mem = {}\n\n\ndef fact(n):\n if n in fact_mem:\n return fact_mem[n]\n ans = 1\n for i in range(1, n + 1):\n ans *= i\n fact_mem[n] = ans\n return ans\n\n\nmem = {}\n\n\ndef f(d):\n tmp = frozenset(d.items())\n if tmp in mem:\n return 0\n n = sum(d.values())\n ans = 0\n if d[0] > 0:\n ans += (n - 1) * fact(n - 1)\n else:\n ans += fact(n)\n for x in d:\n ans //= fact(d[x])\n for k in d:\n if d[k] > 1:\n e = deepcopy(d)\n e[k] -= 1\n ans += f(e)\n mem[frozenset(d.items())] = ans\n return ans\n\n\nans = f(d)\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python3\n\nfrom itertools import product\nfrom operator import mul\nfrom functools import reduce\n\nn = input().strip()\nc0 = n.count('0')\ncc = [n.count(str(i)) for i in range(10)]\ncc = [c for c in cc if c > 0]\n\nfacs = [1]\nfor i in range(1, 20):\n\tfacs.append(facs[-1] * i)\n\ndef prod(p):\n\treturn reduce(mul, p, 1)\n\ndef getC(p):\n\treturn facs[sum(p)] // prod(facs[pp] for pp in p)\n\ndef getcount(ct):\n\tits = [range(1, cti + 1) for cti in ct]\n\treturn sum(getC(p) for p in product(*its))\n\nif c0 == 0:\n\tres = getcount(cc)\nelif c0 == 1:\n\tccr = list(cc)\n\tdel ccr[0]\n\tres = getcount(cc) - getcount(ccr)\nelse:\n\tccr = list(cc)\n\tccr[0] -= 1\n\tres = getcount(cc) - getcount(ccr)\n\nprint (res)\n"}, {"source_code": "import itertools as it\n\n\ndef factorial(n):\n i = 1\n for j in range(1, n + 1):\n i *= j\n return i\n\n\ndef C(n, k):\n k = min([k, n - k])\n result = 1\n for i in range(k + 1, n + 1):\n result *= i\n result //= factorial(n - k)\n return result\n\n\n\nn = input()\n\n\ndigits = [0 for _ in range(10)]\n\nfor i in n:\n digits[int(i)] += 1\n\nresult = 0\n\nfor amounts in it.product(*[[0] if x == 0 else range(1, x + 1) for x in digits]):\n sum_no_zero = sum(amounts[1:])\n if sum_no_zero == 0:\n continue\n tmp = factorial(sum_no_zero)\n for j in amounts:\n tmp //= factorial(j)\n tmp *= C(sum_no_zero + amounts[0] - 1, amounts[0])\n result += tmp\n\n\nprint(result)\n"}, {"source_code": "s=raw_input()\n\nC=[[0 for j in range(2*i+2)] for i in range(20)]\nC[0][0]=1\nfor i in range(1,20):\n for j in range(i+1):\n C[i][j]=C[i-1][j]+C[i-1][j-1]\n\nd={}\n\nfor k in s:\n i=int(k)\n if i not in d:\n d[i]=0\n d[i]+=1\n\nres=0\nn=sum(d.values())\nk=len(d)\nif 0 not in d:\n v=d.values()\n a=[0]*k\n suma=k\n while True:\n nbp=1\n l=suma\n for i in range(k):\n nbp*=C[l][a[i]+1]\n # print nbp, l, a[i]+1\n l-=a[i]+1\n res+=nbp\n # print nbp,a\n i=0\n while i<k and a[i]==v[i]-1:\n i+=1\n if i==k:\n break\n a[i]+=1\n suma+=1\n for j in range(i):\n a[j]=0\n suma-=v[j]-1\nelse:\n v=d.values()\n a=[0]*k\n suma=k\n while True:\n nbp=1\n l=suma\n for i in range(k):\n nbp*=C[l][a[i]+1]\n l-=a[i]+1\n res+=nbp\n # print nbp,a\n i=0\n while i<k and a[i]==v[i]-1:\n i+=1\n if i==k:\n break\n a[i]+=1\n suma+=1\n for j in range(i):\n a[j]=0\n suma-=v[j]-1\n # print res,n \n d[0]-=1\n if not d[0]:\n del d[0]\n v=d.values()\n k=len(d)\n n-=1\n a=[0]*k\n suma=k\n while True:\n nbp=1\n l=suma\n for i in range(k):\n nbp*=C[l][a[i]+1]\n l-=a[i]+1\n res-=nbp\n # print nbp,a\n i=0\n while i<k and a[i]==v[i]-1:\n i+=1\n if i==k:\n break\n a[i]+=1\n suma+=1\n for j in range(i):\n a[j]=0\n suma-=v[j]-1\n# ks=d.keys()\n# kv=[d[kk] for kk in ks]\n# \n# for ij in range(len(ks)):\n# it=ks[ij]\n# v=kv[ij]\n# if it:\n# a=[0]*k\n# suma=k\n# a[ij]=-1\n# if v==1:\n# suma-=1\n# ab=a[:]\n# while True:\n# nbp=1\n# l=suma\n# for i in range(k):\n# nbp*=C[l][a[i]+1]\n# print [l],[a[i]+1],nbp\n# l-=a[i]+1\n# res+=nbp\n# print it,nd,nbp,a,v,suma\n# i=0\n# while i<k and a[i]==v[i]-1:\n# i+=1\n# if i==k:\n# break\n# a[i]+=1\n# suma+=1\n# for j in range(i):\n# a[j]=ab[j]\n# suma-=v[j]-ab[j]-1\n# \n \n \nprint res"}, {"source_code": "r,s,M,S=range,str(input()),map,sum\na=[s.count(str(d)) for d in r(10)]\nfrom math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul as m\nfrom itertools import product as p\nprint(S((f(S(x))-(f(S(x)-1)*x[0] if x[0] else 1))//d(m,M(f,x)) for x in p(*[r(y/max(y,1),y+1) for y in a])))"}, {"source_code": "import itertools as I;m,d,r,s,M,S,f=lambda x,y:x*y,reduce,range,str(input()),map,sum,lambda x:d(m,r(1,x),1);print S((f(S(x)+1)-f(S(x))*x[0])/d(m,M(f,x))for x in I.product(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "r,s=range,str(input())\na=[s.count(str(d)) for d in r(10)]\nfrom math import factorial as f\nfrom functools import reduce as rd\nfrom operator import mul as m\nfrom itertools import product as p\nprint(sum(f(sum(x))//reduce(m,map(f,x))-(f(sum(x)-1)//reduce(m,map(f,x))*x[0] if x[0]>0 else 0) for x in p(*[r(0 if not y else 1,y+1) for y in a])))"}, {"source_code": "import itertools as I;m,d,r,s,M,S,f=lambda x,y:x*y,reduce,range,raw_input(),map,sum,lambda x:d(m,r(1,x+1),1);print S(f(S(x)-1)*(S(x)+x[0])/d(m,M(f,x))for x in I.product(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))"}, {"source_code": "import itertools as I;a,d,m,S,r,M,F=raw_input(),reduce,map,sum,range,lambda x,y:x*y,lambda x:d(M,r(1,x+1),1);print S(F(S(x)-1)*(S(x)-x[0])/d(M,m(F,x))for x in I.product(*[r(y>0,y+1)for y in[a.count(c)for c in set('0'+a)]]))"}, {"source_code": "from collections import Counter\nfrom itertools import permutations\nfrom copy import deepcopy\n\nn = input()\nll = list(str(n))\n\ndef fact(n):\n if n == 1:\n return 1\n return n*fact(n-1)\n\ndef solve(ll, dd):\n now = 1\n for val in dd.values():\n now *= fact(val)\n\n if '0' in dd:\n return ((len(ll)-dd['0']) * fact(len(ll)-1)) / now\n else:\n return fact(len(ll)) / now\n\ndef gogo(ll, dd):\n result = solve(ll, dd)\n ddc = deepcopy(dd)\n\n count = 0\n for itr, ch in enumerate(ll):\n if dd[ch] > 1:\n ddt = deepcopy(ddc)\n ddt[ch] -= 1\n dd[ch] -= 1\n llt = ll[:itr] + ll[itr+1:]\n count += gogo(llt, ddt)\n\n #print ll, result\n return count + result\n\ndd = Counter(ll)\nprint gogo(ll, dd)\n"}, {"source_code": "from collections import Counter\nfrom itertools import permutations\nfrom copy import deepcopy\n\nn = input()\nll = list(str(n))\n\ndef fact(n):\n if n == 1:\n return 1\n return n*fact(n-1)\n\ndef solve(ll, dd):\n now = 1\n for val in dd.values():\n now *= fact(val)\n\n if '0' in dd:\n return ((len(ll)-dd['0']) * fact(len(ll)-1)) / now\n else:\n return fact(len(ll)) / now\n\ndef gogo(ll, dd):\n result = solve(ll, dd)\n count = 0\n for itr, ch in enumerate(ll):\n if dd[ch] > 1:\n ddt = deepcopy(dd)\n ddt[ch] -= 1\n dd[ch] -= 1\n llt = ll[:itr] + ll[itr+1:]\n count += gogo(llt, ddt)\n\n #print ll, result\n return count + result\n\ndd = Counter(ll)\nprint gogo(ll, dd)\n"}, {"source_code": "from math import factorial as fact\n\nn = map(int, list(raw_input()))\ncnt = [0] * 10\nfor x in n:\n cnt[x] += 1\n\nans = 0\nccnt = [0] * 10\n\n\ndef rec(lvl):\n global ans, ccnt\n if lvl >= 10:\n s = sum(ccnt)\n if s == 0 or s == ccnt[0]:\n return\n\n cc = fact(s) / s * (s - ccnt[0])\n for x in ccnt:\n cc /= fact(x)\n\n ans += cc\n return\n\n for i in xrange(int(ccnt[lvl] != 0), cnt[lvl] + 1):\n ccnt[lvl] = i\n rec(lvl + 1)\n\nrec(0)\n\nprint ans"}, {"source_code": "n = list(raw_input())\nn = [int(x) for x in n]\nN = len(n)\nneed = list(set(n))\nchecked = {}\nans = 0\ncur = len(need)\n\ndef valid(arr):\n for i in need:\n if i not in arr:\n return 0\n return 1\n\ndef convert(arr):\n cur = 0\n for i in range(len(arr)):\n cur += pow(10,arr[i])\n return cur\n\ndef solve(arr):\n cnt = [0 for x in range(10)]\n for i in arr:\n cnt[i] += 1\n res = 1\n for i in range(1,len(arr)+1):\n res *= i\n tot = 0\n for i in range(10):\n if cnt[i] > 1:\n temp = 1\n for j in range(2,cnt[i]+1):\n temp *= j\n res /= temp\n tot += temp\n if cnt[0]:\n temp = 1\n for i in range(2,len(arr)):\n temp *= i\n if tot:\n temp /= tot\n for i in range(2,cnt[0]+1):\n temp *= i\n res -= temp\n return res\n\nfor i in range(0,1<<len(n)):\n temp = []\n for j in range(len(n)):\n if i&(1<<j):\n temp.append(int(n[j]))\n if not valid(temp):\n continue\n cur = convert(temp)\n try:\n checked[cur] += 1\n except:\n res = solve(temp)\n ans += res\n checked[cur] = 1\n\nprint ans"}, {"source_code": "arr = [int(x) for x in list(raw_input())]\nfact = [1 for x in range(20)]\nfor i in range(2,20):\n fact[i] = i*fact[i-1]\ncnt = [0 for x in range(10)]\nfor i in arr:\n cnt[i] += 1\nans = [0]\ndef solve(li,dep):\n if dep==-1:\n for i in range(10):\n if not li[i] and cnt[i]:\n return\n res = fact[sum(li)]\n for i in range(10):\n if li[i]:\n res /= fact[li[i]]\n if li[0]:\n for i in range(li[0]):\n res -= res/(sum(li)-i)\n ans[0] += res\n else:\n for i in range(cnt[dep]+1):\n li[dep] = i\n solve(li,dep-1)\ntmp = [0 for x in range(10)]\nfor i in range(cnt[9]+1):\n tmp[9] = i\n solve(tmp,8)\nprint ans[0]"}, {"source_code": "n = list(raw_input())\nn = [int(x) for x in n]\nN = len(n)\nneed = list(set(n))\nchecked = {}\nans = 0\ncur = len(need)\n\ndef valid(arr):\n for i in need:\n if i not in arr:\n return 0\n return 1\n\ndef convert(arr):\n cur = 0\n for i in range(len(arr)):\n cur += pow(10,arr[i])\n return cur\n\ndef solve(arr):\n cnt = [0 for x in range(10)]\n for i in arr:\n cnt[i] += 1\n res = 1\n for i in range(1,len(arr)+1):\n res *= i\n tot = 0\n for i in range(10):\n if cnt[i] > 1:\n temp = 1\n for j in range(2,cnt[i]+1):\n temp *= j\n res /= temp\n tot += temp\n if cnt[0]:\n temp = 1\n for i in range(2,len(arr)):\n temp *= i\n if tot:\n temp /= tot\n res -= temp*cnt[0]\n return res\n\nfor i in range(0,1<<len(n)):\n temp = []\n for j in range(len(n)):\n if i&(1<<j):\n temp.append(int(n[j]))\n if not valid(temp):\n continue\n cur = convert(temp)\n try:\n checked[cur] += 1\n except:\n res = solve(temp)\n ans += res\n checked[cur] = 1\n\nprint ans"}, {"source_code": "from math import factorial\n\nmemo={}\n\ndef getnp(cfg):\n if cfg in memo:\n return memo[cfg]\n zeros, nums = cfg\n sn=sum(nums)\n configs=factorial(sn+zeros)\n for n in nums:\n configs/=factorial(n)\n configs/=factorial(zeros)\n res=(sn*configs)/(sn+zeros)\n nm=list(nums)\n for i in range(len(nm)):\n if nm[i]>1:\n nm[i]-=1\n res+=getnp((zeros,tuple(sorted(nm))))\n nm[i]+=1\n if zeros>1:\n res+=getnp((zeros-1,nums))\n memo[cfg]=res\n return res\n\ns=raw_input()\nzeros=s.count('0')\nnums=[]\nfor i in range(1,10):\n cnt=s.count(chr(ord('0')+i))\n if cnt:\n nums.append(cnt)\n\nprint getnp((zeros, tuple(sorted(nums))))\n \n \n"}, {"source_code": "from math import factorial\n\nmemo={}\nvis=set()\n\ndef getnp(zeros, nums):\n if (zeros, tuple(sorted(nums))) in vis:\n return 0\n vis.add((zeros, tuple(sorted(nums))))\n if (zeros, tuple(sorted(nums))) in memo:\n return memo[(zeros, tuple(sorted(nums)))]\n\n sn=sum(nums)\n configs=factorial(sn+zeros)\n for n in nums:\n configs/=factorial(n)\n configs/=factorial(zeros)\n\n res=(sn*configs)/(sn+zeros)\n for i in range(len(nums)):\n if nums[i]>1:\n nums[i]-=1\n res+=getnp(zeros,nums)\n nums[i]+=1\n if zeros>1:\n res+=getnp(zeros-1,nums)\n memo[(zeros, tuple(sorted(nums)))]=res\n return res\n\ns=raw_input()\nzeros=s.count('0')\nnums=[]\nfor i in range(1,10):\n cnt=s.count(chr(ord('0')+i))\n nums.append(cnt)\n\nprint getnp(zeros, nums)\n \n \n"}, {"source_code": "from math import factorial\n\nmemo={}\nvis=set()\n\ndef getnp(zeros, nums):\n if (zeros, tuple(nums)) in vis:\n return 0\n vis.add((zeros, tuple(nums)))\n if (zeros, tuple(sorted(nums))) in memo:\n return memo[(zeros, tuple(sorted(nums)))]\n\n sn=sum(nums)\n configs=factorial(sn+zeros)\n for n in nums:\n configs/=factorial(n)\n configs/=factorial(zeros)\n\n res=(sn*configs)/(sn+zeros)\n for i in range(len(nums)):\n if nums[i]>1:\n nums[i]-=1\n res+=getnp(zeros,nums)\n nums[i]+=1\n if zeros>1:\n res+=getnp(zeros-1,nums)\n memo[(zeros, tuple(sorted(nums)))]=res\n return res\n\ns=raw_input()\nzeros=s.count('0')\nnums=[]\nfor i in range(1,10):\n cnt=s.count(chr(ord('0')+i))\n nums.append(cnt)\n\nprint getnp(zeros, nums)\n \n \n"}], "src_uid": "7f4e533f49b73cc2b96b4c56847295f2"} {"source_code": "import sys\n \nR = lambda: list(map(int, input().split()))\n \ndef lcm(a,b):\n m = a*b\n while a != 0 and b != 0:\n if a > b:\n a %= b\n else:\n b %= a\n return m // (a+b)\n \nn, p, w, d = R()\n \nif (w*n)<p:\n print(-1)\n sys.exit()\n \nif p==0:\n print(0, 0, n)\n sys.exit()\n \nnod = lcm(w, d)\ns_w = p//w\ns_d = (p-s_w*w)//d\nwhile ((p-s_w*w)%d!=0):\n s_w-=1\n s_d=(p-s_w*w)//d\n if(s_d > nod):\n print(-1)\n sys.exit()\nif (s_w>=0)and(s_d>=0):\n print(s_w, s_d, n-(s_w+s_d))\nelse:\n print(-1)", "positive_code": [{"source_code": "import math\nn,p,w,d=map(int,input().split())\nx=-1\ny=-1\nfor i in range(w):\n\tif (p-i*d)%w==0:\n\t\ty=i\n\t\tx=(p-d*y)//w\n\t\tbreak\nif x<0 or y<0 or x+y>n:\n\tprint(-1)\nelse:\n\tprint(x,y,n-x-y)\n\t"}, {"source_code": "def xgcd(a, b):\n x0, x1, y0, y1 = 0, 1, 1, 0\n while a != 0:\n q, b, a = b // a, a, b % a\n y0, y1 = y1, y0 - q * y1\n x0, x1 = x1, x0 - q * x1\n return b, x0, y0\n \nn, p, w, d = map(int, input().split())\n \ng, a, b = xgcd(w, d)\n \nif p % g != 0:\n print(-1)\n exit(0)\n \na *= p // g;\nb *= p // g;\n \nif b < 0:\n t = (-b + (w // g) - 1) // (w // g);\n a -= t * (d // g);\n b += t * (w // g);\n \nt = b // (w // g);\na += t * (d // g);\nb -= t * (w // g);\n \nif a >= 0 and b >= 0 and a + b <= n:\n print(a, b, n - a - b)\nelse:\n print(-1)"}, {"source_code": "\nimport sys, bisect, heapq, math\nsys.setrecursionlimit(10**9+7)\ndef fi(): return int(sys.stdin.readline())\ndef fi2(): return map(int, sys.stdin.readline().split())\ndef fi3(): return sys.stdin.readline().rstrip()\ndef fo(*args):\n for s in args: sys.stdout.write(str(s)+' ')\n sys.stdout.write('\\n')\n## sys.stdout.flush()\ndef puts(*args):\n for s in args: sys.stdout.write(str(s))\nOUT = []\ndef bfo(*args):\n for s in args: OUT.append(str(s)+' ')\n OUT.append(' ')\ndef bputs(*args):\n for s in args: OUT.append(str(s)) \ndef flush():\n sto = ''.join(OUT); fo(sto)\n##\nalpha = 'abcdefghijklmnopqrstuvwxyz'; mod = 10**9+7; inf = int(2e18+5) ; nax = 101010\n##\n\ndef gcdExtended(a, b): \n if a == 0 : \n x = 0\n y = 1\n return (x, y)\n \n x1, y1 = gcdExtended(b%a, a) \n \n x = y1 - (b//a) * x1 \n y = x1 \n \n return (x, y)\n\n\nn, p, w, d = fi2()\n\ng = math.gcd(w, d)\nx, y = gcdExtended(w, d)\n\nww = w//g\ndd = d//g\n\nif p%g != 0:\n print(-1)\n exit()\n\nx = x*p//g\ny = y*p//g\n\nassert(w*x + y*d == p)\n\nif y < 0:\n k = abs(y)//ww + 5\n y += ww*k\n x -= dd*k\n\nk = y//ww\ny -= ww*k\nx += dd*k\n\nassert(w*x + y*d == p)\n\nz = n - x - y\n\nif x >= 0 and y >= 0 and z >= 0:\n print(x, y, z)\nelse:\n print(-1)\n\n\n\n"}, {"source_code": "from math import ceil\n\nn,p,w,d = map(int, input().split())\ne = x = n\ns = 0\ny = None\nfor i in range(64):\n a = x * w\n y = ceil((p - a) / d)\n if y < 0:\n e = x\n x = (s + x) // 2\n continue\n b = y * d\n ss = a + b\n if ss == p and x+y <= n:\n break\n if (a < p) or x + y > n:\n s = x\n x = (e + x) // 2\n else:\n e = x\n x = (s + x) // 2\nelse:\n dir_ = 1 if p - ss > 0 else -1\n for i in range(100000):\n x += dir_\n a = x * w\n y = (p - a) // d\n b = y * d\n ss = a + b\n if ss == p and x+y <= n:\n break\n else:\n print(-1)\n exit()\nif x < 0 or y < 0:\n print(-1)\nelse:\n print(x, y, n - x - y)\n"}, {"source_code": "n = p = w = d = 0\nx = y = 0\n\ndef GCD(a, b):\n while (b != 0):\n c = a % b\n a = b\n b = c\n return a\n\ndef ExGCD(a, b):\n global x\n global y\n if (b == 0):\n x = 1\n y = 0\n return\n ExGCD(b, a % b)\n temp = x\n x = y\n y = temp - a / b * y\n\ndef main():\n global n, p, w, d, x, y\n s = raw_input()\n n, p, w, d = map(int, s.split())\n\n gcd = GCD(w, d)\n if (p % gcd != 0):\n print -1\n return 0;\n ExGCD(w, d)\n x = x * (p / gcd)\n y = y * (p / gcd)\n dx = d / gcd\n dy = w / gcd\n k = 0\n k = y / dy # + (-1 if y < 0 and y % dy != 0 else 0)\n x = x + k * dx\n y = y - k * dy\n # print x, y, dx, dy\n if n < x + y or x < 0 or y < 0:\n print -1\n else:\n print x, y, n - x - y\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from math import ceil\n\nn,p,w,d = map(int, input().split())\ne = x = n\ns = 0\ny = None\nfor i in range(64):\n a = x * w\n y = ceil((p - a) / d)\n if y < 0:\n e = x\n x = (s + x) // 2\n continue\n b = y * d\n ss = a + b\n if ss == p and x+y <= n:\n break\n if (a < p) or x + y > n:\n s = x\n x = (e + x) // 2\n else:\n e = x\n x = (s + x) // 2\nelse:\n dir_ = 1 if p - ss > 0 else -1\n for i in range(100000):\n x += dir_\n a = x * w\n y = (p - a) // d\n b = y * d\n ss = a + b\n if ss == p and x+y <= n:\n break\n else:\n print(-1)\n exit()\nif x < 0 or y < 0:\n print(-1)\nelse:\n print(x, y, n - x - y)\n \n"}, {"source_code": "import math\nn,p,w,d=map(int,input().split())\ndef gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\nj=gcd(w,d) \nif n<(math.ceil(p/w)) or p<w and p<d and p>0:\n print('-1')\nelif p%j!=0:\n print('-1')\nelif p==n and w>p and d>p:\n print('-1')\nelif p==0:\n print(0,0,n)\nelse:\n i=0\n while True:\n if (p-i)%w==0:\n x=(p-i)//w\n y=i//d\n break\n i+=d\n print(x,y,n-x-y) "}, {"source_code": "x=1\ny=0\ndef gcd(a,b):\n\tif b==0:return a\n\telse:return gcd(b,a%b);\ndef exgcd(a,b):\n\tif b==0:\n\t\treturn a\n\telse:\n\t\td=exgcd(b,a%b)\n\t\tglobal x,y\n\t\tt=x\n\t\tx=y\n\t\ty=t-(a//b)*y\n\t\treturn d\nn,p,w,d=map(int,input().split())\ng=gcd(w,d)\nif p%g!=0:\n\tprint(-1)\nelse:\n\tp=p//g\n\tw=w//g\n\td=d//g\n\texgcd(w,d)\n\tx=x*p\n\ty=y*p\n\tx=(x%d+d)%d\n\ty=(p-w*x)//d\n\tif y!=0:\n\t\ty=(y%w+w)%w\n\t\tx=(p-y*d)//w\n\tif y<0 or x<0 or x+y>n:\n\t\tprint(-1)\n\telse:\n\t\tprint(x,y,n-x-y)"}, {"source_code": "n,p,w,d=[int(i) for i in input().split(\" \")]\n\ndef exgcd(a,b):\n if b==0:\n return (1,0)\n tx,ty=exgcd(b,a%b)\n return (ty,tx-a//b*ty)\n\ndef gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\n\nx,y=exgcd(w,d)\ng=gcd(w,d)\nif p%g!=0:\n print(\"-1\")\n exit()\np//=g\nx*=p\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\nx*=1\ny*=p\nw//=g\nd//=g\nif x<0:\n tmp=(-x+d-1)//d\n x+=tmp*d\n y-=tmp*w\nif y<0:\n tmp=(-y+w-1)//w;\n y+=tmp*w\n x-=tmp*d\nif x<0:\n print(\"-1\")\n exit()\nif y>=w:\n tmp=y//w\n y-=tmp*w;\n x+=tmp*d;\nif x+y>n:\n print(\"-1\")\n exit()\nprint(int(x),int(y),int(n-x-y))\n"}, {"source_code": "# maa chudaaye duniya\nn, p ,w, d = map(int, input().split())\nwins = -1\ndraws = -1\nfor difference in range(w):\n\tdraws = difference\n\tif (p-d*draws)%w == 0:\n\t\twins = (p-d*draws) // w\n\t\tbreak\nif wins < 0 or draws < 0 or wins + draws > n:\n\tprint(-1)\nelse:\n\tprint(wins, draws, n-wins-draws)"}, {"source_code": "n,p,w,d=map(int,input().split())\n\n#n the number of games\n#p the number of points\n#w points awarded for winning\n#d points awarded for a draw\n\n#impossible if n*w < p\n#for p = 10,w = 3,d = 2?\ndef canDraw(p,w,d):\n dcounter = 0\n if w % d == 0 and p%d != 0:\n dcounter =0\n\n else:\n while p %w !=0:\n p -= d\n dcounter +=1\n\n return dcounter\n\nif n*w >= p:\n dcounter = int(canDraw(p,w,d))\n wcounter= int((p - dcounter*d)/w)\n lcounter = int(n - dcounter -wcounter)\n\n if wcounter < 0 or dcounter <0 or lcounter <0 or wcounter*w + dcounter*d != p:\n print(-1)\n else:\n print(wcounter,dcounter,lcounter)\n\n\nelse:\n print(-1)"}, {"source_code": "n, p, w, d = [int(i) for i in input().split(' ')]\n\nwins = p // w\nruns = d + 5\nwhile runs >= 0 and wins >= 0:\n points_to_cover = p - w * wins\n if points_to_cover % d == 0:\n draws = points_to_cover // d\n if wins + draws > n:\n print(-1)\n exit(0)\n print(f'{wins} {draws} {n - wins - draws}')\n exit(0)\n wins -= 1\n runs -= 1\nprint(-1)\n"}, {"source_code": "def main():\n\t(n, p, w, d) = (int(x) for x in input().split())\n\tresult = solver(n, p, w, d)\n\tif result == -1:\n\t\tprint(-1)\n\telse:\n\t\tprint(*result)\n\ndef solver(n, p, w, d):\n\tmaxScore = w * n\n\tif maxScore < p:\n\t\treturn -1\n\tif p % gcd(w, d) != 0:\n\t\treturn -1\n\tif p < d and p > 0:\n\t\treturn -1\n\tmaxWins = p // w\n\tfor i in range(min(maxWins + 1, d)):\n\t\tif (p - (maxWins - i) * w) % d == 0:\n\t\t\twins = maxWins - i\n\t\t\tdraws = (p - (maxWins - i) * w) // d\n\t\t\tlosses = n - wins - draws\n\t\t\treturn (wins, draws, losses)\n\treturn -1\n\ndef gcd(x, y):\n\t(x, y) = (max(x, y), min(x, y))\n\twhile y != 0:\n\t\t(x, y) = (y, x % y)\n\treturn x\n\n#print(*solver(30, 60, 3, 1))\n#print(solver(10, 51, 5, 4))\n#print(solver(20, 0, 15, 5))\n#print(*(1, 2, 3, 4))\n#print(solver(10, 2, 5, 3))\n\nmain()"}, {"source_code": "import math\na,b,c,d=map(int,input().split())\nx=-1\ny=-1\n\nfor i in range(c):\n\tif (b-i*d)%c==0:\n\t\ty=i\n\t\tx=(b-d*y)//c\n\t\tbreak\nif x<0 or y<0 or x+y>a:\n\tprint(-1)\nelse:\n\tprint(x,y,a-x-y)"}, {"source_code": "data = input()\ndata = data.split()\nn = int(data[0])\np = int(data[1])\nw = int(data[2])\nd = int(data[3])\n\np_int_d = int(p/d)\np_rem_d = p%d\nw_int_d = int(w/d)\nw_rem_d = w%d\n\nanswer = False\n\nif( (p/w) <= n):\n if( (p - n*d) <= 0 ) :\n low_lim = 0\n else :\n low_lim = int( (p - (n-1)*d)/w )\n top_lim = int(p/w)\n\n remain = False\n i = 0\n k = top_lim\n while (i < w):\n if (((p - w * k) % d) == 0):\n remain = True\n top_lim = k\n break\n i = i + 1\n k = k - 1\n\n g = 1\n while(i <= w) :\n if( ((i*w)%d) == 0 ):\n g = i\n break\n i = i + 1\n\n if(remain == True):\n i = top_lim\n while (i >= low_lim) :\n if( (i + int((p-i*w)/d)) <= n ) :\n if( ((p-w*i)%d) == 0 ):\n answer = True\n x = i\n y =int((p-i*w)/d)\n z = n - x - y\n break\n else :\n break\n i = i - g\n\n if(answer == True) :\n print(x, end=' ')\n print(y, end=' ')\n print(z)\n else :\n print(-1)\n else :\n print(-1)\nelse :\n print(-1)\n"}, {"source_code": "n,p,w,d = (int(i) for i in input().split())\n\ndef gcd(a,b):\n x, xx, y, yy = 1, 0, 0, 1\n while b:\n q = a // b\n a, b = b, a % b\n x, xx = xx, x - xx*q\n y, yy = yy, y - yy*q\n return (x, y, a)\n\n\ndef find_any_solution(a,b,c):\n g = gcd(abs(a),abs(b))\n x0,y0=g[0],g[1]\n if c%g[2] != 0:\n return (0,0,0)\n x0 *= c//g[2]\n y0 *= c//g[2]\n if a<0: x0*=-1\n if b<0: y0*=-1\n return (x0,y0,g[2])\n\nx,y,g = find_any_solution(w,d,p)\nif x==y==g==0:\n print(-1)\nelse:\n lx = x + -(x*g//d)*d//g\n k = -(-(n-x-y)*g//(d-w))\n x+=k*d//g\n y-=k*w//g\n if p == 0:\n print(0,0,n)\n else:\n if x>=0 and y>=0:\n print(x,y, n-x-y)\n else:\n x = lx\n y = (p-w*x)//d\n k = (y-n)*g//w\n if x+y<=n and 0<=x<=n and 0<=y<=n:\n print(x,y,n-x-y)\n else:\n x+=k*d//g\n y-=k*w//g\n k=1\n while x+y>n and x<n and y>=0:\n x+=k*d//g\n y-=k*w//g\n k+=1\n if x+y<=n and 0<=x<=n and 0<=y<=n:\n print(x,y,n-x-y)\n else:\n print(-1)"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\nn, p, w, d = map(int, next(sys.stdin).split(\" \"))\n\n\ndef solution():\n a = min(p // d, p // w)\n b = max(p // d + 1, p // w + 1)\n\n z = max(n - b, 0)\n if n - a < 0:\n print(-1)\n return\n\n divider = w - d\n\n if (d % divider == 0 or w % divider == 0) and p % divider != 0:\n print(-1)\n return\n\n while z <= n - a:\n z2 = n - z\n\n xdiv = (p - d * z2) // divider\n ydiv = (w * z2 - p) // divider\n\n xmod = (p - d * z2) % divider\n ymod = (w * z2 - p) % divider\n\n if xmod == 0 and ymod == 0 and xdiv >= 0 and ydiv >= 0:\n print(xdiv, ydiv, z)\n return\n z += 1\n\n print(-1)\n\n\nsolution()\n"}, {"source_code": "n, p, w, d = map(int, input().split())\nfor y in range(w):\n if (p - y * d) % w == 0 and (p - y * d) // w >= 0 and n >= (p - y * d) // w + y:\n print((p - y * d) // w, y, n - (p - y * d) // w - y)\n break\nelse:\n print(-1)\n"}, {"source_code": "n,maxx,a,s = input().split()\nw = [0,0,0]\ne = 0\nn = int(n)\nmaxx = int(maxx)\na = int(a)\ns = int(s)\n\nw[0] = maxx // a\ne = w[0] * a\n\nw[1] = (maxx - e) // s\ne += w[1] * s\n#print(w[0],w[1],w[2])\nfor yu in range(s):\n if ((maxx - e) > 0):\n if((maxx - e)// a-s):\n z = s - (maxx - e)\n w[0] -= 1\n w[1] += 1\n e = w[0] * a\n e += w[1] * s\n w[1] += (maxx - e) // s\n e = w[0] * a\n e += w[1] * s\nif w[0]<0 or w[1]<0:\n print(-1)\nelse:\n #print(w[0],w[1],w[2])\n if w[0]+w[1]<=n:\n w[2] = n - w[0] - w[1]\n if e == maxx:\n print(w[0],w[1],w[2])\n else:\n print(-1)\n else:\n print(-1)\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\nimport time\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\nn, p, w, d = MAP()\n\nmxx = p // w\ny = -1\nstart = time.time()\nfor x in range(mxx, -1, -1):\n if (p-w*x) % d == 0:\n y = (p-w*x) // d\n break\n elapsed_time = time.time() - start\n if elapsed_time > 0.7:\n print(-1)\n exit()\n\nif y == -1:\n print(-1)\n exit()\nz = n - x - y\nif z < 0:\n print(-1)\n exit()\n\nprint(x, y, z)\n"}, {"source_code": "\ndef exgcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, x, y = exgcd(b % a, a)\n return (g, y - (b // a) * x, x)\n\nif __name__ == \"__main__\":\n n, p, w, d = map(int, input().split())\n r, x, y = exgcd(w, d)\n if p % r:\n print(-1)\n else:\n x = p // r * x\n y = p // r * y\n d = d // r\n w = w // r\n y0 = ((y % w) + w) % w\n x0 = (p // r - y0 * d) // w\n if x0 >= 0 and y0 >= 0 and x0 + y0 <= n:\n print(\"%d %d %d\" % (x0, y0, n - x0 - y0))\n else:\n print(-1)\n \n"}, {"source_code": "n,p,w,d=[int(x) for x in input().split()]\nfor i in range(0,1000000):\n num=p-(d*i)\n if num<0:\n continue\n if num%w:\n continue\n cnt=i+(num//w)\n if cnt>n:\n continue\n print(num//w,i,n-cnt)\n exit()\nprint(-1)"}, {"source_code": "def exgcd(a, b):\n if b == 0:\n return a, 1, 0\n d, x, y = exgcd(b, a % b)\n t = x\n x = y\n y = t - (a // b) * y\n return d, x, y\n\n\nn, p, w, d = map(int, input().split())\ng, x, y = exgcd(w, d)\nif p % g != 0:\n print(-1)\nelse:\n x *= p // g\n y *= p // g\n w //= g\n d //= g\n if x < 0:\n t = (-x + d - 1) // d\n x += t * d\n y -= t * w\n if y < 0:\n t = (-y + w - 1) // w\n x -= t * d\n y += t * w\n if x < 0 or y < 0:\n print(-1)\n else:\n t = y // w\n x += t * d\n y -= t * w\n if x + y <= n:\n print(x, y, n - x - y)\n else:\n print(-1)\n"}, {"source_code": "import sys\ndef exgcd(a,b,l):\n if b==0:\n l[0]=1\n l[1]=0\n return a\n d=exgcd(b,a%b,l)\n t=l[0]-a//b*l[1]\n l[0]=l[1]\n l[1]=t\n return d\ndef gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\nn,p,w,d=map(int,input().split(\" \"))\nl=[0,0]\nif p%gcd(w,d)!=0:\n print(-1)\nelse:\n m=exgcd(w,d,l)\n l[0]=p*l[0]//m\n l[1]=p*l[1]//m\n if l[0]<0 and l[1]<0:\n print(-1)\n sys.exit()\n if l[0]>=0 and l[1]>=0 and l[1]+l[0]<=n:\n print(l[0],end=\" \")\n print(l[1],end=\" \")\n print(n-l[0]-l[1])\n sys.exit()\n if l[0]+l[1]>n and w==d:\n print(-1)\n sys.exit()\n if p==0:\n print(0,end=\" \")\n print(0,end=\" \")\n print(n)\n sys.exit()\n else:\n if l[0]<0 and l[1]>=0:\n sum=l[0]*m//d-1\n l[1]+=w*sum//m\n l[0]-=sum*d//m\n if l[1]<0:\n print(-1)\n sys.exit()\n if l[1]<0 and l[0]>=0:\n sum=l[1]*m//(-w)+1\n l[0]-=d*sum//m\n l[1]+=w*sum//m\n if l[0]<0:\n print(-1)\n sys.exit()\n if l[0]+l[1]<=n and l[0]>=0 and l[1]>=0:\n print(l[0],end=\" \")\n print(l[1],end=\" \")\n print(n-l[0]-l[1])\n sys.exit()\n else:\n num,tag=(w-d)//m,0\n cnt=(n-l[0]-l[1])//num\n for i in range(cnt-100,cnt+100):\n res1=int(l[0]-d*i//m)\n res2=int(l[1]+w*i//m)\n if res1+res2<=n and res1>=0 and res2>=0:\n print(res1,end=\" \")\n print(res2,end=\" \")\n print(n-res1-res2)\n sys.exit()\n print(-1)\n \n\n"}, {"source_code": "import sys\n\ndef gcd(a,b):\n if 0==b:\n return a\n else:\n return gcd(b,a%b)\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\ndef exgcd(a,b,X,Y):\n if 0==b:\n X[0]=1\n Y[0]=0\n return a\n g=exgcd(b,a%b,Y,X)\n Y[0]-=a//b*X[0]\n return g\n\ndef ceil(x,y):\n return (x+y-1)//y\n\ndef main():\n #sys.stdin=open('in.txt','r')\n n,p,w,d=map(int,input().split())\n if 0==p:\n print('0 0 %d'%n)\n return\n g=gcd(w,d)\n if p%g!=0:\n print('-1')\n return\n X=[0]\n Y=[0]\n exgcd(w,d,X,Y)\n x=X[0]*p//g\n y=Y[0]*p//g\n k1=lcm(w,d)//w\n k2=lcm(w,d)//d\n\n if x<0:\n t=ceil(abs(x),k1)\n x=x+k1*t\n y=y-k2*t\n else:\n t=x//k1;\n x=x-k1*t\n y=y+k2*t\n\n if y<0:\n print('-1')\n return\n\n t=y//k2\n x=x+k1*t\n y=y-k2*t\n\n if 0<=x<=n and 0<=y<=n and x+y<=n:\n print(x,y,n-x-y)\n else:\n print('-1')\n\nmain()"}, {"source_code": "n,p,w,d=map(int, input().split(' '))\nx=p//w\nfor y in range(0,w):\n if((y*d - p%w)%w==0):\n x-=((y*d-p%w)//w)\n break\nz=n-x-y\nif(x+y<=n and y<w and x>=0 and x*w+y*d==p):\n print(\"%d %d %d\"%(x,y,z))\nelse:\n print(\"-1\")\n \n"}, {"source_code": "import math\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\ndef exgcd(a, b, X, Y):\n if a == 0 and b == 0:\n return -1\n if b == 0:\n X[0] = 1\n Y[0] = 0\n return a\n d = exgcd(b, a % b, Y, X)\n Y[0] = Y[0] - a // b * X[0]\n return d\n\ndef fceil(x, y):\n return (x + y - 1) // y\n\ndef main():\n n, p, w, d = map(int, input().split());\n x = [0]\n y = [0]\n G = gcd(w, d)\n if p % G != 0:\n print(-1)\n return\n if p % w == 0:\n x[0] = p // w\n if x[0] <= n:\n print(x[0], 0, n - x[0])\n return\n if p % d == 0:\n y[0] = p // d\n if y[0] <= n:\n print(0, y[0], n - y[0])\n return\n exgcd(w, d, x, y)\n x[0] = x[0] * p // G\n y[0] = y[0] * p // G\n if x[0] < 0:\n t = fceil(abs(x[0]), d)\n x[0] = x[0] + d * t\n y[0] = y[0] - w * t\n if y[0] < 0:\n t = fceil(abs(y[0]), w)\n x[0] = x[0] - d * t\n y[0] = y[0] + w * t\n if x[0] < 0 or y[0] < 0:\n print(-1)\n return\n t = y[0] // w\n x[0] = x[0] + d * t\n y[0] = y[0] - w * t\n if x[0] + y[0] > n:\n print(-1)\n return\n z = n - x[0] - y[0]\n print(x[0], y[0], z)\n\n\nmain()"}, {"source_code": "import math\ndef main():\n noofgames,points,winpoints,drawpoints = map(int,input().split())\n common = math.gcd(winpoints,drawpoints)\n if points == 0:\n print(0,0,noofgames)\n return\n if points%common:\n print(-1)\n return\n if common != 1 :\n points //= common\n winpoints //= common\n drawpoints //= common\n for i in range(winpoints):\n if drawpoints*i > points : \n print(-1)\n return \n a = (points - drawpoints*i)\n b = a%winpoints\n if a >= 0 and b == 0 :\n x = a//winpoints\n y = i\n z = noofgames - x - y \n if z >= 0 :\n print(x,y,z)\n return\n print(-1)\n return\nmain()\n\n"}, {"source_code": "n, p, w, d = map(int, input().split())\nfor y in range(w):\n if (p - y*d) % w == 0 and y <= (p - y*d) // w + y <= n:\n x = (p - y*d) // w\n z = n - x - y\n print(x, y, z)\n break\nelse:\n print(-1)\n"}, {"source_code": "\n\nn,p,w,d = map(int,input().split())\n\nif w * n < p:\n print(-1)\n exit()\n\nfor i in range(w) :\n if d * i > p :\n print(-1)\n exit()\n if ( p - d * i ) % w == 0:\n q = (p - d * i )//w\n if i+q <= n :\n print(q,i,n-q-i)\n exit()\n\nprint(-1)\n\n \n\n"}, {"source_code": "def results(arr):\n if arr[0]*arr[2] < arr[1]:\n print (-1)\n elif arr[1] == 0:\n print (0,0,arr[0])\n elif arr[0] == arr[1] and arr[1]%arr[2]!=0 and arr[1]%arr[3]!=0:\n print(-1)\n else:\n x = max(arr[2],arr[3])\n y = arr[2] if x == arr[3] else arr[3]\n divLimit = arr[1]//x\n while 1:\n interim = arr[1] - divLimit*x\n if interim%y == 0:\n if interim//y + divLimit <= arr[0]:\n if x == arr[2]:\n if divLimit >=0 and interim//y >=0:\n print (divLimit,interim//y,arr[0] - divLimit-interim//y)\n else:\n print (-1)\n break\n else:\n if divLimit >=0 and interim//y >=0:\n print (interim//y,divLimit,arr[0] - divLimit-interim//y)\n else:\n print (-1)\n break\n else:\n divLimit -= 1 \nresults(list(map(int,input().split())))\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=1000000007\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\n# vsInput()\n \nfor _ in range(1):\n n,p,w,d=value()\n\n # w*x + d*y =p\n\n if(w==1):\n if(p>n):\n print(-1)\n else:\n print(p,0,n-p)\n\n else:\n\n\n for draws in range(w+1):\n \n rem_score=p-draws*d\n wins=rem_score//w\n\n loose=n-wins-draws\n\n if(loose>=0 and wins+draws<=n and rem_score%w==0 and wins>=0):\n print(wins,draws,loose)\n exit()\n\n\n if(p==0):\n print(0,0,n)\n else:\n print(-1)\n\n \n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "}, {"source_code": "n, p, w, d = list(map(int, input().split()))\nif n * w >= p:\n\ta, b = max(w, d), min(w, d)\n\twhile b:\n\t\tb, a = a % b, b\n\tnod = a\n\tif not p % nod:\n\t\tr, i, x, y = 0, 0, 0, 0\n\t\twhile r != p:\n\t\t\tx = p // w - i\n\t\t\ty = (p - x * w) // d\n\t\t\tr = x * w + y * d\n\t\t\ti += 1\n\t\t\tif i > n or x < 0 or y < 0 or x + y > n:\n\t\t\t\tprint(-1)\n\t\t\t\tbreak\n\t\telse: \n\t\t\tz = n - x - y\n\t\t\tprint(x, y, z)\n\telse: print(-1)\nelse: print(-1)"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom random import randint\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, log\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\nN = int(1e5) + 5\n\n'''\nCheck for special cases (n=1)\nOne wrong submission = 10 mins penalty!\ndo smth instead of nothing and stay organized\n'''\n\ndef main():\n\tgames_played, actual_score, points_per_win, points_per_draw = map(int, input().split())\n\n\t# we assume that we won all games\n\tassumed_score = games_played*points_per_win\n\twins = games_played\n\tdraws = 0\n\tlosses = 0\n\n\tfor _ in range(N):\n\t\tif (assumed_score - actual_score) % points_per_win == 0:\n\t\t\t# extra score is divisible by ppw\n\t\t\t# then we can add that to losses\n\t\t\tbreak\n\t\telse:\n\t\t\t# otherwise we add that to draws\n\t\t\tdraws += 1\n\t\t\twins -= 1\n\t\t\tassumed_score -= points_per_win\n\t\t\tassumed_score += points_per_draw\n\n\telse:\n\t\t# if we never were able to divide the extra score in losses\n\t\tprint(-1)\n\t\texit()\n\n\t# otherwise divide up the extra score in losses\n\textra_score = assumed_score - actual_score\n\twins -= extra_score//points_per_win\n\tlosses += extra_score//points_per_win\n\n\tif wins >= 0 and losses >= 0 and draws >= 0:\n\t\tprint(wins, draws, losses)\n\telse:\n\t\tprint(-1)\n\n\nBUFSIZE = 8192\nclass FastI(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = StringIO()\n\t\tself.newlines = 0\n \n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(\"\\n\") + (not b)\n\t\t\tptr = self._buffer.tell()\n\t\t\tself._buffer.seek(0, 2), self._buffer.write(\n\t\t\t\tb), self._buffer.seek(ptr)\n\t\tself.newlines -= 1\n\t\treturn self._buffer.readline()\nclass FastO(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = __pypy__.builders.StringBuilder()\n\t\tself.write = lambda s: self._buffer.append(s)\n \n\tdef flush(self):\n\t\tos.write(self._fd, self._buffer.build())\n\t\tself._buffer = __pypy__.builders.StringBuilder()\ndef print(*args, **kwargs):\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n\tat_start = True\n\tfor x in args:\n\t\tif not at_start:\n\t\t\tfile.write(sep)\n\t\tfile.write(str(x))\n\t\tat_start = False\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\n\tif kwargs.pop(\"flush\", False):\n\t\tfile.flush()\ndef gcd(x, y):\n\twhile y:\n\t\tx, y = y, x % y\n\treturn x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n\tdef bootstrap(cont):\n\t\tcall, arg = cont.switch()\n\t\twhile True:\n\t\t\tcall, arg = cont.switch(to=continulet(\n\t\t\t\tlambda _, f, args: f(*args), call, arg))\n\tcont = continulet(bootstrap)\n\tcont.switch()\n\tmain()"}, {"source_code": "def exgcd(a,b):\n if(a==0):\n x=0\n y=1\n return [0,1,b]\n x1,y1,d = exgcd(b%a,a)\n x = y1-(b/a)*x1\n y = x1\n l = [x,y,d]\n return l\n# 627936103814 4254617095171609 45205 1927\ns = raw_input()\nl = s.split()\nn = long(l[0])\np = long(l[1])\nw = long(l[2])\nd = long(l[3])\ngc = exgcd(w,d)\nx = gc[0]\ny = gc[1]\ng = gc[2]\nif(p%g!=0):\n print -1\n exit()\nx0 = x*p/g\ny0 = y*p/g\nif(x0>=0 and y0>=0):\n if(x0+y0 <= n):\n print x0,y0,n-x0-y0\n exit()\n else:\n ans = -1\n be = 0\n en = 10000000000000 #;//((n-x0-y0)*g/(w-g));\n while(be<=en):\n mid = (be+en)/2\n nv = x0+y0+((mid*(d-w))/g)\n if(nv>n):\n be = mid+1\n else:\n ans = mid\n en = mid-1\n if(ans==-1):\n print -1\n exit()\n else:\n yk = y0-((ans*w)/g)\n xk = x0+((ans*d)/g)\n if(yk >= 0 and xk>=0):\n print xk,yk,n-xk-yk\n exit()\n else:\n print -1\n exit()\n\nif(x0>=0 and y0<0):\n k = (g*y0*-1)/w\n yk = y0 + (k*(w)/g)\n if(yk<0):\n yk += (w/g)\n k+=1\n xk = x0-(k*d/g)\n if(xk<0):\n print -1\n exit()\n x0 = xk\n y0 = yk\n if(x0+y0 <= n):\n print x0,y0,n-x0-y0\n exit()\n else:\n print -1\n exit()\nif(x0<0 and y0>=0):\n k = (g*x0*-1)/d\n xk = x0 + (k*d/g)\n if(xk<0):\n xk += (d/g);\n k+=1\n yk = y0-(k*w/g)\n if(yk<0):\n print -1\n exit()\n x0 = xk\n y0 = yk\n if(x0+y0 <= n):\n print x0,y0,n-x0-y0\n exit()\n else:\n ans = -1\n be = 0\n en = 10000000000000#;// + ((n-x0-y0)*g/(w-g));\n while(be<=en):\n mid = (be+en)/2\n nv = x0+y0+(mid*(d-w)/g)\n if(nv>n):\n be = mid+1\n else:\n ans = mid\n en = mid-1\n if(ans==-1):\n print -1\n exit()\n else:\n yk = y0-(ans*w/g)\n xk = x0+(ans*d/g)\n if(yk >= 0 and xk>=0):\n print xk,yk,n-xk-yk\n exit()\n else:\n print -1\n exit()\nif(x0<0 and y0<0):\n print -1\n exit()\n"}, {"source_code": "N, P, W, D = map(int, raw_input().split())\n\ndef gcdExtended(a, b):\n if a == 0:\n return (b, (0, 1))\n g, newPair = gcdExtended(b % a, a)\n return (g, (newPair[1] - b / a * newPair[0], newPair[0]))\n\ngcd, pair = gcdExtended(W, D)\n#print gcd, pair, \"<-----\"\n\nif P % gcd > 0:\n print -1\nelse:\n K = P / gcd\n f1, f2 = D / gcd, W / gcd\n pair = [pair[0] * K, pair[1] * K]\n\n if pair[0] < 0:\n t = (-pair[0] + f1 - 1) / f1\n pair = [pair[0] + t * f1, pair[1] - t * f2]\n\n if pair[1] < 0:\n t = (-pair[1] + f2 - 1) / f2\n pair = [pair[0] - t * f1, pair[1] + t * f2]\n\n if min(pair) >= 0 and sum(pair) > N:\n t = (sum(pair) - N + f2 - f1 - 1) / (f2 - f1)\n pair = [pair[0] + t * f1, pair[1] - t * f2]\n\n\n if min(pair) >= 0 and sum(pair) <= N:\n print pair[0], pair[1], N - sum(pair)\n else:\n print -1"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport heapq\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nimport sys\n\nsys.setrecursionlimit(10 ** 6) # max depth of recursion\nthreading.stack_size(2 ** 27) # new thread will get stack of such size\nfac_warm_up = False\nprintHeap = str()\nmemory_constrained = False\nP = 10 ** 9 + 7\n\n\nclass MergeFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n\n def find(self, a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n\n def merge(self, a, b):\n a = self.find(a)\n b = self.find(b)\n if a == b:\n return\n if self.size[a] < self.size[b]:\n a, b = b, a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n\n def set_size(self, a):\n return self.size[self.find(a)]\n\n def __len__(self):\n return self.num_sets\n\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\n\ndef prime_factors(n): # n**0.5 complex\n factors = dict()\n for i in range(2, math.ceil(math.sqrt(n)) + 1):\n while n % i == 0:\n if i in factors:\n factors[i] += 1\n else:\n factors[i] = 1\n n = n // i\n if n > 2:\n factors[n] = 1\n return (factors)\n\n\ndef all_factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef fibonacci_modP(n, MOD):\n if n < 2: return 1\n return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(\n fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD\n\n\ndef factorial_modP_Wilson(n, p):\n if (p <= n):\n return 0\n res = (p - 1)\n for i in range(n + 1, p):\n res = (res * cached_fn(InverseEuler, i, p)) % p\n return res\n\n\ndef binary(n, digits=20):\n b = bin(n)[2:]\n b = '0' * (digits - len(b)) + b\n return b\n\n\ndef is_prime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\n\ndef generate_primes(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n return prime\n\n\nfactorial_modP = []\n\n\ndef warm_up_fac(MOD):\n global factorial_modP, fac_warm_up\n if fac_warm_up: return\n factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]\n for i in range(2, fac_warm_up_size):\n factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD\n fac_warm_up = True\n\n\ndef InverseEuler(n, MOD):\n return pow(n, MOD - 2, MOD)\n\n\ndef nCr(n, r, MOD):\n global fac_warm_up, factorial_modP\n if not fac_warm_up:\n warm_up_fac(MOD)\n fac_warm_up = True\n return (factorial_modP[n] * (\n (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD\n\n\ndef get_int():\n return int(stdin.readline().strip())\n\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\n\nmemory = dict()\n\n\ndef clear_cache():\n global memory\n memory = dict()\n\n\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\ndef ncr(n, r):\n return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))\n\n\ndef binary_search(i, li):\n fn = lambda x: li[x] - x // i\n x = -1\n b = len(li)\n while b >= 1:\n while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like\n x += b\n b = b // 2\n return x\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\n\n\nTestCases = False\noptimise_for_recursion = True # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3\n\n\ndef main():\n n, p, w, d = get_tuple()\n gcd = math.gcd(w, d)\n if p%gcd ==0:\n p, w, d = p//gcd, w//gcd, d//gcd\n #print(p, w, d, gcd)\n for x in range(d):\n if (p - (x * w))%d == 0:\n y = (p - (x * w))//d\n if y<0: break\n #print(x, y)\n k = y//w\n y = y - k*w\n x = x + k*d\n if (x+y)<=n:\n print(x , y, n - (x + y))\n return\n break\n print(-1)\n\n\n\n\n# --------------------------------------------------------------------- END=\n\n\nif TestCases:\n for i in range(get_int()):\n main()\nelse:\n main() if not optimise_for_recursion else threading.Thread(target=main).start()\n"}, {"source_code": "\nimport math\nimport sys\n \n \ndef exgcd(a, b):\n if b == 0:\n return (1, 0)\n else:\n y, x = exgcd(b, a % b)\n y -= x * (a // b)\n return (x, y)\n \n \ndef ceil(x, y):\n return x // y + (x % y != 0)\n \n \ndef output(a, b, n):\n if a < 0 or b < 0:\n return\n if a + b > n:\n return\n \n print(a, b, n - a - b)\n sys.exit(0)\n \n \ndef main():\n n, p, w, d = [int(x) for x in input().split(' ')]\n g = math.gcd(w, d)\n if p % g != 0:\n print(-1)\n return\n x, y = exgcd(w, d)\n a = w // g\n b = d // g\n g = p // g\n x *= g\n y *= g\n \n if x < 0:\n t = ceil(-x, b)\n x += t * b\n y -= t * a\n elif y < 0:\n t = ceil(-y, a)\n x -= t * b\n y += t * a\n \n if x < 0 or y < 0:\n print(-1)\n else:\n #output(x, y, n)\n #output(x % b, y + (x // b) * a, n)\n output(x + (y // a) * b, y % a, n)\n print(-1)\n \n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from fractions import gcd\nn,p,w,d=map(int,raw_input().split())\nif p%gcd(p,w):\n print -1\n exit()\nfor i in range(w):\n temp=p-(i*d)\n if temp>=0 and temp%w==0 and (i+(temp/w))<=n:\n print temp/w,i,(n-(i+(temp/w)))\n exit()\nprint -1\n\n \n"}, {"source_code": "\ndef exgcd(a,b,x,y):\n if b==0:\n x[0]=1\n y[0]=0\n return a\n r=exgcd(b,a%b,y,x)\n y[0]-=(a//b)*x[0]\n return r;\n\ndef min_ans(a,b,x,y,n):\n g=exgcd(a,b,x,y)\n if n%g:\n return 0\n x[0]*=n//g\n y[0]*=n//g\n db=b//g\n x[0]=((x[0]%db)+db)%db\n y[0]=(n-a*x[0])//b;\n return g\ns=input().split()\nn=int(s[0])\np=int(s[1])\nw=int(s[2])\nd=int(s[3])\nx=[0]\ny=[0]\ng=min_ans(w,d,x,y,p)\nx=x[0]\ny=y[0]\nif g==0:\n print(\"-1\")\nelse:\n if y<0:\n print(\"-1\")\n elif x+y>n:\n da=w//g\n db=d//g\n if db>=da:\n print(\"-1\")\n else:\n tmp=x+y-n\n tmp=(tmp+da-db-1)//(da-db)\n x+=tmp*db\n y-=tmp*da\n if 0<=x and x<=n and 0<=y and y<=n and 0<=x+y and x+y<=n:\n print(\"%d %d %d\"%(x,y,n-x-y))\n else:\n print(\"-1\")\n else:\n print(\"%d %d %d\"%(x,y,n-x-y))"}, {"source_code": "import math\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, x, y = egcd(b % a, a)\n return (g, y - (b // a) * x, x)\n\nfrom math import gcd \ndef isPossible(a, b, c): \n return (c % gcd(a, b) == 0)\n \nn, c, a, b = [int(x) for x in input().split()]\nif isPossible(a, b, c):\n X = egcd(a, b)\n # print(X)\n g = X[0]\n x = X[1] * c // g\n y = X[2] * c // g\n # k = -1\n # print(x, y)\n l = int(math.ceil(-1 * y * g / a - 1e-8))\n h = int(min(math.floor(x * g / b + 1e-8), math.floor((n - x - y) * g / (a - b) + 1e-8)))\n # h = math.floor(h)\n # print(\"l, h: \", l, h)\n if l > h: print(-1)\n else:\n if h - 1 < h and h - 1 >= l: h = h - 1\n x = x - ((h * b) // g)\n y = y + ((h * a) // g)\n z = n - x - y\n print(x, y, z)\nelse: print(-1)"}, {"source_code": "import math\nimport sys\n\n\ndef exgcd(a, b):\n if b == 0:\n return (1, 0)\n else:\n y, x = exgcd(b, a % b)\n y -= x * (a // b)\n return (x, y)\n\n\ndef ceil(x, y):\n return x // y + (x % y != 0)\n\n\ndef output(a, b, n):\n if a < 0 or b < 0:\n return\n if a + b > n:\n return\n\n print(a, b, n - a - b)\n sys.exit(0)\n\n\ndef main():\n n, p, w, d = [int(x) for x in input().split(' ')]\n g = math.gcd(w, d)\n if p % g != 0:\n print(-1)\n return\n x, y = exgcd(w, d)\n a = w // g\n b = d // g\n g = p // g\n x *= g\n y *= g\n\n if x < 0:\n t = ceil(-x, b)\n x += t * b\n y -= t * a\n elif y < 0:\n t = ceil(-y, a)\n x -= t * b\n y += t * a\n\n if x < 0 or y < 0:\n print(-1)\n else:\n output(x, y, n)\n output(x % b, y + (x // b) * a, n)\n output(x + (y // a) * b, y % a, n)\n print(-1)\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "from __future__ import division, print_function\ndef main():\n n,p,w,d=map(int,input().split())\n wins=0\n def gcd(a,b):\n while b:\n a,b=b,a%b\n return a\n lcm=(w*d)//gcd(w,d)\n x=lcm//w\n while (wins*w)<=lcm and wins<n and (p-wins*w)%d!=0:\n wins+=1\n if (p-wins*w)%d==0:\n wins+=x*((p-wins*w)//lcm)\n draws=(p-wins*w)//d\n\n if wins+draws<=n and draws>=0 and wins>=0 and ((wins*w)+(draws*d))==p:\n print(wins,draws,n-wins-draws)\n else :\n print(-1)\n else :\n print(-1)\n \n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()"}, {"source_code": "n,p,w,d=map(int,input().strip().split())\nx = -1\ny = -1\nfor i in range(0, w):\n if (p - d*i) % w == 0:\n y = i\n x = int((p -d*y) / w)\n break\n \nif x < 0 or y < 0 or x+y > n:\n print(-1)\nelse:\n print(x, y, n-(x+y))"}, {"source_code": "import math\n\ndef egcd(a,b):\n\tif a==0:\n\t\treturn (b,0,1)\n\telse:\n\t\tgcd,x,y=egcd(b%a,a)\n\t\treturn (gcd,y-(b//a)*x,x)\n\nn,p,w,d=map(int,input().split())\ng,x0,y0=egcd(w,d)\n# print(g,)\nif(p%g):\n\tprint(-1)\n\texit(0)\nx0*=(p//g)\ny0*=(p//g)\n# print(x0*w+y0*d)\n# print(x0,y0)\nminn=max(-x0*g/d,(x0+y0-n)*g/(w-d))\nmaxx=y0*g/w\n# print(minn,maxx)\nl=math.ceil(minn)\nr=math.floor(maxx)\n# print(l,r)\nif r<l:\n\tprint(-1)\n\texit(0)\nfor i in range(l,r+1):\n\tx=(x0+i*d//g)\n\ty=(y0-i*w//g)\n\tz=n-x-y\n\tif x>=0 and y>=0 and z>=0:\n\t\tprint((x),y,int(z))\n\t\texit(0)\nprint(-1)"}, {"source_code": "inp = [int(x) for x in input().split()]\nn = inp[0]\np = inp[1]\nw = inp[2]\nd = inp[3]\nif p == 0:\n print(0,0,n)\n exit(0)\n\n# n_temp = n\n# mi = p + 1\n\np_temp = p\nsum_w = 0\nans_x = 0\nans_y = 0\nans_z = 0\n\nfound = False\nosztok = {}\n\nwhile p_temp > 0:\n if p_temp % w != 0:\n if (p_temp%w) in osztok:\n break\n osztok[p_temp%w] = 1\n p_temp -= d\n ans_y += 1\n else:\n found = True\n break\n\n# print(osztok)\n\n# while (p_temp - w)> -1:\n# sum_w += 1\n# if (p_temp - w) % d == 0:\n# # print(p_temp - w)\n# mi = p_temp - w\n# ans_x = sum_w \n# p_temp -= w\n\n\n# if mi != (p + 1):\n# print(ans_y, p)\nif found:\n # ans_y = p - (ans_x * w)\n ans_x = p_temp // w\n ans_z = n - ans_x - ans_y\n if ans_x + ans_y > n :\n # print(ans_x, ans_y)\n print(-1)\n exit(0)\nelif p % d == 0:\n ans_y = p // d\n ans_z = n - ans_y\n if ans_y <= n:\n print(ans_x, ans_y, ans_z)\n exit(0) \nelse:\n print(-1)\n exit(0)\n\nif ans_x * w + ans_y * d == p:\n print(ans_x, ans_y, ans_z)\nelse:\n print(-1)\n\n"}, {"source_code": "import math\ndef gcd(a,b):\n if a==0:\n x0=0\n y0=1\n return b,x0,y0\n d=gcd(b%a,a)\n x0=d[2]-(b//a)*d[1]\n y0=d[1]\n return d[0],x0,y0\n\ns=list(map(int,input().split()));\nn=s[0]\np=s[1]\nw=s[2]\nd=s[3]\ndd=gcd(w,d)\nx0=dd[1]\ny0=dd[2]\ndd=dd[0]\nx0*=p//dd\ny0*=p//dd\ndy=w//dd\ndx=d//dd\nif p%dd !=0:\n print(-1,flush=False)\n exit()\nelse:\n if y0<0:\n col=math.ceil(abs(y0)/dy)\n y0+=dy*col\n x0-=dx*col\n col=y0//dy\n y0-=dy*col\n x0+=dx*col\n if x0<0:\n print(-1,flush=False)\n exit()\n if(x0+y0<=n):\n print(x0,y0,n-x0-y0,flush=False)\n else:\n print(-1,flush=False)\n"}, {"source_code": "import os\nimport sys\nfrom collections import defaultdict as ddic, Counter, deque\nfrom itertools import combinations, permutations, product\n\nFAST_INPUT = 0\nif FAST_INPUT:\n from atexit import register\n from io import BytesIO\n\n sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\n sys.stdout = BytesIO()\n register(lambda: os.write(1, sys.stdout.getvalue()))\n\nrr = lambda: sys.stdin.readline().rstrip('\\r\\n')\nrri = lambda: int(rr())\nrrm = lambda: map(int, rr().split())\nMOD = 10**9 + 7\n\n#####\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n \ndef solve(N, P, W, D):\n # win, +=W\n # draw, both +=D\n # solve x*W + y*D = P or xA + yB = C\n # 0 <= x+y <= n\n A, B, C = W, D, P\n from fractions import gcd\n g = gcd(gcd(A, B), C)\n A /=g\n B /=g\n C /=g\n g,x,y = egcd(A, B)\n x *= C\n y *= C\n # can x+=B y-=A or opposite\n #print 'working', x, y, ';', A, B, C, ';n', N\n if x < 0:\n if B > 0:\n for e in range(64, -1, -1):\n factor = 1 << e\n if x + factor * B <= 0:\n x += factor*B\n y -= factor*A\n while x + B <= 0:\n x += B\n y -= A\n if x < 0:\n x += B\n y -= A\n if y < 0: return\n elif B < 0:\n for e in range(64, -1, -1):\n factor = 1 << e\n if x - factor * B <= 0:\n x -= factor*B\n y += factor*A\n while x - B <= 0:\n x -= B\n y += A\n if x < 0:\n x -= B\n y += A\n if y < 0: return\n if y < 0:\n if A > 0:\n for e in range(64, -1, -1):\n factor = 1 << e\n if y + factor * A <= 0:\n x -= factor*B\n y += factor*A\n #print 'Y', y, y+A, A\n while y + A <= 0:\n x -= B\n y += A\n if y < 0:\n x -= B\n y += A\n #print 'at', x,y, ';', A, B\n if x < 0: return\n elif A < 0:\n for e in range(64, -1, -1):\n factor = 1 << e\n if y - factor * A <= 0:\n x += factor*B\n y -= factor*A\n while y - A <= 0:\n x += B\n y -= A\n if y < 0:\n x += B\n y -= A\n #print 'at', x,y, ';', A, B\n if x < 0: return\n\n if 0 <= x + y <= N and A*x + B*y == C:\n return x,y,N-x-y\n if x+y > N:\n # try to put more coefficient on larger weight\n diff = x+y-N\n \n if A > B:\n q,r = divmod(diff, A-B)\n q += r>0\n x += B * q\n y -= A * q\n elif B > A:\n q,r = divmod(diff, B-A)\n q += r>0\n x -= B * q\n y += A * q\n else:\n # A==B==1\n pass\n if 0 <= x <= N >= y >= 0 and 0 <= x+y<= N:\n if A*x + B*y == C:\n return x,y,N-x-y\n\n return\n\nDEBUG = 0 \nif DEBUG:\n import random;random.seed(0);ri=random.randint\n\n for trials in range(100):\n D = ri(1, 5000000)\n W = ri(1, 5000000)\n\n # solve x*W + y*D = P or xA + yB = C\n # 0 <= x+y <= n\n \n X = ri(1, 5000000)\n Y = ri(1, 5000000)\n P = X*W + Y*D\n N = X+Y+ri(0, 10)\n ans = solve(N, P, W, D)\n if ans is not None:\n x,y,z = ans\n if not(x*W+y*D==P and 0<=x<=N>=y>=0 and 0<=x+y<=N):\n print 'oops', N, P, W, D\n break\n print '.', \n print 'done'\n \n\nans = solve(*rrm())\nif ans is None:\n print -1\nelse:\n print \" \".join(map(str, ans))\n\n\n\n \n"}, {"source_code": "import math\nn,p,w,d=list(map(int,input().split()))\ndef gcd(a,b):\n if(a==0):\n return (b,0,1)\n d,x1,y1 = gcd(b%a,a)\n return d,y1-(b//a)*x1,x1\ng,x,y=gcd(w-d,w)\n\nif(p<w):\n if(p%d == 0):\n y = p//d\n z = n-y\n print(0,y,z)\n else:\n print(-1)\nelif(p==w):\n x=1\n z=n-x\n print(x,0,z)\nelse:\n if(n*w-p<0 or (n*w-p)%g):\n print(-1)\n else:\n x*=(n*w-p)//g\n y*=(n*w-p)//g\n #print('x_0:',x)\n #print('y_0:',y)\n\n while(True):\n aa=math.floor(x/w)\n x-=aa*w\n y+=(w-d)*aa\n #print('x :',x)\n #print('y :',y)\n if(x>=0 and y>=0):\n if(not (n-x-y>=0)):\n print(-1)\n break\n else:\n print(n-x-y,x,y)\n break\n\n\n\n #print('x_1:',x)\n #print('y_1:',y)\n\n #if(x>=0 and y>=0):\n # print(n-x-y,x,y)\n #else:\n # print(n-x-y,x,y)\n # print(-1)"}, {"source_code": "rr = raw_input\nrri = lambda: int(rr())\nrrm = lambda: map(int, rr().split())\n\ndef solve(N, C, A, B):\n for y in xrange(A):\n if (y * B - C) % A == 0:\n x = (C - y*B) / A\n if x >= 0 and N-x-y >= 0:\n return x, y, N-x-y\n return -1,\n\nprint \" \".join(map(str, solve(*rrm())))\n"}, {"source_code": "import math\nimport random\n\nn, p, w, d = map(int, input().split())\n\noutput = []\n\nc = (p - d * n) / (w - d)\nc = math.ceil(c)\n\nfor b in range(d + 1):\n\n\tif (p - b * w) % d == 0:\n\t\tlower = (c - b) / d\n\t\tupper = (n - b) / d\n\n\t\tif lower > 0:\n\t\t\ta = math.ceil(lower)\n\n\t\telse:\n\t\t\ta = 0\n\n\t\tcondition = True\n\n\t\twhile condition == True:\n\n\t\t\tx = d * a + b\n\n\t\t\tif (p - x * w) >= 0:\n\t\t\t\ty = (p - x * w) / d\n\n\t\t\t\tif int(y) == y:\n\t\t\t\t\ty = int(y)\n\t\t\t\t\tz = n - x - y\n\n\n\t\t\t\t\tif z >= 0:\n\t\t\t\t\t\toutput = [x, y, z]\n\t\t\t\t\t\tcondition = False\n\t\t\ta += 1\n\n\t\t\tif a > upper:\n\t\t\t\tcondition = False\n\n\tif len(output) == 3:\n\t\t\n\t\tif x + y + z == n: \n\t\t\tprint(x, y, z)\n\t\t\tbreak\n\nelse:\n\tprint(-1)"}, {"source_code": "import sys\nfrom fractions import gcd\nn, p, w, d = [int(item) for item in input().split()]\ndiv = gcd(w, d)\nif p % div != 0:\n print(-1)\nelse:\n p //= div\n w //= div\n d //= div\n ans = False\n for x in range(p // w, max(-1, p // w - 10**5), -1):\n if (p - x * w) % d != 0:\n continue\n y = (p - x * w) // d\n if y < 0 or x + y > n:\n continue\n ans = True\n break\n if ans:\n print(x, y, n - x - y)\n else:\n print(-1)"}, {"source_code": "import sys\nsys.setrecursionlimit(1000000)\n\ndef xgcd(a, b):\n \"\"\"return (g, x, y) such that a*x + b*y = g = gcd(a, b)\"\"\"\n if b == 0:\n return (a, 1, 0)\n else:\n g, x, y = xgcd(b, a%b)\n return (g, y, x- (a // b) * y)\n\nn,p,w,d=map(int,input().split());\ng,x,y=xgcd(w,d);\n\nif p%g:\n print(-1);\n sys.exit(0);\n\nif g<0:\n g*=-1;\nx*=p//g;\ny*=p//g;\n\nt=0;\nif x<0:\n t=(0-x)*g//d+(0 if (0-x)*g%d == 0 else 1);\n x+=t*d//g;\n y-=t*w//g;\n\nif y<0:\n t=(0-y)*g//w+(0 if (0-y)*g%w==0 else 1);\n x-=t*d//g;\n y+=t*w//g;\n\nif n-(x+y)<0:\n t=(n-(x+y))*g//(d-w) + (0 if (n-(x+y))*g%(d-w)==0 else 1);\n x+=t*d//g;\n y-=t*w//g;\n\nif x<0 or y<0 or n-x-y<0:\n print(-1)\nelse:\n print(x,y,n-x-y)"}, {"source_code": "N = 10**5 + 3\n\ndef main():\n n,p,w,d = map(int,input().split())\n\n x_max = p//w\n for i in range(N):\n x = x_max-i\n if x<0:\n break\n\n rem = p-x*w\n if rem%d == 0:\n y = rem//d\n if x+y <= n:\n z = n-x-y\n print(x,y,z)\n return\n\n print(-1)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,p,w,d=map(int,input().split())\nif n*w<p or (p>0 and p<d):\n print(-1)\nelif (p%w==0 and p//w<=n) or (p%d==0 and p//d<=n):\n if p%w==0:\n print(p//w,0,n-p//w)\n else:\n print(0,p//d,n-p//d)\nelse:\n total=0\n i=0\n total=int(p/w)*w\n i=int(p/w)\n dif=p-total\n if dif==0:\n print(i,0,n-i)\n elif dif%d==0:\n print(i,dif//d,n-i-dif//d)\n else:\n if w%d==0:\n print(-1)\n else:\n while dif%d!=0:\n dif+=w\n i-=1\n print(i,dif//d,n-i-dif//d)\n"}, {"source_code": "def fastpow(a, p, m):\n\tif a==0:\n\t\treturn 1\n\tt=fastpow(a,p//2)\n\treturn t*t*(a if a%2 else 1)\n\ndef xgcd(a,b):\n\tif b==0:\n\t\treturn (1,0,abs(a))\n\tx,y,g=xgcd(b,a%b)\n\treturn (y,x-(a//b)*y,g);\n\ndef adjust_xgcd_lb(x,y,g,a,b,lbx,lby):\n\tif x<lbx:\n\t\tt=0\n\t\tif b>=0:\n\t\t\tt=(lbx-x)*g//b + int((lbx-x)*g%b!=0)\n\t\telse:\n\t\t\tt=(lbx-x)*g//b\n\t\tx+=t*b//g;\n\t\ty-=t*a//g;\n\tif y<lby:\n\t\tt=0\n\t\tif a>=0:\n\t\t\tt=(lby-y)*g//a + int((lby-y)*g%a!=0)\n\t\telse:\n\t\t\tt=(lby-y)*g//a\n\t\tx-=t*b//g;\n\t\ty+=t*a//g;\n\t#if x<lbx or y<lby:\n\t#\traise Exception;\n\treturn (x,y);\n\nn,p,w,d=map(int,input().split())\nx,y,g=xgcd(w,d)\n\nif p%g:\n print(-1)\n exit(0)\nx*=p//g\ny*=p//g\n\nx,y=adjust_xgcd_lb(x,y,g,w,d,0,0)\nif n-(x+y)<0:\n t=(n-(x+y))*g//(d-w) + int((n-(x+y))*g%(d-w)!=0)\n x+=t*d//g\n y-=t*w//g\nif x<0 or y<0 or n-x-y<0:\n\tprint(-1)\nelse:\n\tprint( x,y,n-x-y)"}, {"source_code": "n,p,w,d=map(int,input().split())\ny=0\nwhile y<w and p%w:y+=1;p-=d\nz=n-p//w-y\nprint(*((p//w,y,z),[-1])[y==w or(p|z)<0])"}, {"source_code": "##for debug comment out\nimport sys,atexit\nfrom io import BytesIO\ninp = BytesIO(sys.stdin.buffer.read())\ninput = lambda:inp.readline().decode('ascii').strip()\nbuf = BytesIO()\n#sys.stdout.write = lambda s: buf.write(s.encode('ascii'))\n#print = lambda s: buf.write(s.encode('ascii'))\natexit.register(lambda:sys.__stdout__.buffer.write(buf.getvalue()))\n\nn,p,w,d=map(int,input().split())\nx=-1\ny=-1\nfor i in range(10**5):\n if (p-i*d)%w==0:\n y=i\n x=(p-y*d)//w\n\n break\n\nif x<0 or y<0 or x+y>n:\n print(-1)\nelse:\n print(x,y,n-x-y)\n"}, {"source_code": "import math\n\ndef extended_euclid(a, b):\n \"\"\"return (g, x, y) such that a*x + b*y = g = gcd(a, b)\"\"\"\n x0, x1, y0, y1 = 0, 1, 1, 0\n while a != 0:\n (q, a), b = divmod(b, a), a\n y0, y1 = y1, y0 - q * y1\n x0, x1 = x1, x0 - q * x1\n return b, x0, y0\n\nn, p, w, d = [int(i) for i in input().split(' ')]\n\na = w\nb = d\nc = p\n\ng, x, y = extended_euclid(a, b)\n\nif c % g != 0:\n\tprint(\"-1\")\nelse:\n\tb //= g\n\ta //= g\n\tx = x * (c // g)\n\ty = y * (c // g)\n\n\t#f1 = math.ceil((-x) / b)\n\tf2 = y // a\n\t#print(f2)\n# \tif y < 0 and f2 * a != y:\n# \t\tf2 = f2 - 1\n\t#if f1 <= f2:\n\tx += f2 * b;\n\ty -= f2 * a;\n\tif x >= 0 and y >= 0 and x + y <= n:\n\t\tprint(str(x) + \" \" + str(y) + \" \" + str(n-x-y))\n\telse:\n\t\tprint(\"-1\")\n\t#else:\n\t#\tprint(\"-1\")"}, {"source_code": "n,p,w,d=map(int,input().split())\ny=0\ntemp=p-y*d\nmark=0\nwhile(temp>=0):\n if(temp%w==0):\n x=temp//w\n if(x+y<=n):\n print(x,y,n-x-y)\n mark=1\n break\n y+=1\n temp-=d\n if(y>w):\n break\nif(mark==0):\n print(-1)"}, {"source_code": "\"\"\"\nT=int(input())\nfor _ in range(0,T):\n N=int(input())\n s=input()\n a,b=map(int,input().split())\n s=[int(x) for x in input().split()]\n\n\"\"\"\n\nn,p,w,d=map(int,input().split())\n\ntemp=-1\n\nfor i in range(0,w):\n if((p-(d*i))%w==0 and ((p-(d*i))//w)+i<=n and (p-(d*i))//w>=0):\n print((p-(d*i))//w,i,n-((p-(d*i))//w)-i)\n temp=1\n break\n\nif(temp==-1):\n print(-1)\n"}, {"source_code": "n,p,w,d = map(int, input().split())\n\nx, y = -1, -1\nfor y in range(w):\n if y*d > p:\n continue\n\n if (p - y*d) % w == 0:\n x = (p-y*d) // w\n if x + y <= n:\n print (x, y, n-x-y)\n break\nelse:\n print(-1)\n\n\n\n"}, {"source_code": "\nn,p,w,d = [int(j) for j in input().split()]\nz = 0\nfor y in range(w):\n if((p-d*y)%w == 0 and (p-d*y)//w >=0 and (p-d*y)//w + y <=n):\n print((p-d*y)//w,y,n-y-(p-d*y)//w)\n z = 1\n break\nif(z != 1):\n print(-1)\n \n"}, {"source_code": "n,p,w,d=map(int,input().split())\nans=-1\nfor i in range(10**6):\n if p%w==0:\n ans=i\n break\n p-=d\n if p<0:\n break\nif ans==-1:\n print(-1)\nelse:\n u=p//w\n if u+i<=n:\n print(u,i,n-u-i)\n else:\n print(-1)\n "}, {"source_code": "n, p, w, d = map(int, input().split())\nr = p % w\nn1 = 0\nfor i in range(1, 100000):\n if (d * i) % w == r:\n n1 = i\n break\nn2 = (p - d * n1) // w\nn3 = 0\nr1 = p % d\nfor i in range(1, 100000):\n if (w * i) % d == r1:\n n3 = i\n break\nn4 = (p - w * n3) // d\nif p == 0:\n print(0, 0, n)\nelif p % w == 0 and p // w <= n:\n print(p // w, 0, n - p // w)\nelif p % d == 0 and p // d <= n:\n print(0, p // d, n - p // d)\nelif n2 >= 0 and n1 * d + n2 * w == p and n1 + n2 <= n:\n print(n2, n1, n - n1 - n2)\nelif n4 >= 0 and n3 * w + n4 * d == p and n3 + n4 <= n:\n print(n3, n4, n - n3 - n4)\nelse:\n print(-1)"}, {"source_code": "def exgcd(a,b):\n if b==0:\n return [1,0,a]\n res=exgcd(b,a%b)\n t=res[0]\n res[0]=res[1]\n res[1]=t\n res[1]-=a//b*res[0]\n return res\ninp=input().split()\nn=eval(inp[0])\np=eval(inp[1])\nd=eval(inp[2])\nw=eval(inp[3])\ngg=exgcd(d,w)\ng=gg[2]\nx=gg[0]\ny=gg[1]\nde=1\nif p%g!=0:\n print(-1)\nelse :\n dx=w//g\n dy=d//g\n x*=p//g\n y*=p//g\n de=-10\n x+=de*dx\n y-=de*dy\n if x>0:\n de=-(x//dx)\n else :\n de=y//dy\n x+=de*dx\n y-=de*dy\n if x<0 or y<0:\n print(-1)\n else :\n if dx>dy:\n de=-(x//dx)\n else :\n de=y//dy\n x+=de*dx\n y-=de*dy\n if x+y<=n:\n print(x,y,n-x-y)\n else :\n print(-1)"}, {"source_code": "from math import *\nfrom sys import *\nfrom heapq import *\nfrom collections import defaultdict\nimport os, sys\nfrom io import IOBase, BytesIO\nM=10**9+7\ndef pow(a,b):\n res=1\n while b>0:\n if b&1:\n res*=a\n a*=a\n b>>=1\n return res\ndef powmod(a,b,m):\n res=1\n while b>0:\n if b&1:\n res=((res*a)%m)\n a*=a\n b>>=1\n return res\ndef inv(a,m):\n return powmod(a,m-2,m)\ndef alldivisors(n) : \n list = [] \n arr=[]\n for i in range(1, int(sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n / i == i) : \n arr+=[i]\n else :\n arr+=[i]\n list.append(n//i) \n arr+=list[::-1]\n return arr\ndef primefactorisation(n):\n potentional_p = 3\n itog_list = defaultdict(int)\n if n % 2 == 0:\n itog_list[2] = 0\n while n % 2 == 0:\n n = n // 2\n itog_list[2] += 1\n while n - 1:\n if potentional_p > (n**0.5):\n itog_list[n] += 1\n return itog_list\n while n % potentional_p == 0:\n n = n // potentional_p\n itog_list[potentional_p] += 1\n potentional_p += 2\n return itog_list\n\n\n\ndef main():\n n,p,w,d=list(map(int,input().split()))\n gd=gcd(w,d)\n if p%gd==0:\n p=p//gd\n w=w//gd\n d=d//gd\n else:\n print(-1)\n exit(0)\n x_i=p/w\n y_i=p/d\n \n if y_i<x_i:\n x=0\n while 1:\n val=p-x*w\n if val%d==0:\n if val>=0 and n-x-val//d>=0:\n print(x,val//d,n-x-val//d)\n break\n else:\n print(-1)\n break\n x+=1\n else:\n #print(\"here\")\n y=0\n while 1:\n val=p-y*d\n if val%w==0:\n \n if val>=0 and n-y-val//w>=0:\n print(val//w,y,n-y-val//w)\n break\n else:\n print(-1)\n break\n y+=1\n\n\n\n \n\n\n\n\n\n\n\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \nif __name__ == '__main__':\n main()\n#threading.Thread(target=main).start()\n\n\n\n\n\n\n"}, {"source_code": "n, p, w, d = list(map(int, input().split()))\n\ns = 0\n\nif (n * w < p):\n print(-1)\nelif (w % d == 0) and (p % d > 0):\n print(-1)\nelif (p % w == 0):\n print(' '.join(map(str, [p // w, 0, n - p // w])))\nelse:\n min_wd = p // (w + d)\n for j in range(min_wd + 1):\n curr = p - j * (w + d)\n \n if (curr % w == 0) and (curr // w + 2 * j <= n):\n print(' '.join(map(str, [curr // w + j, j, n - 2 * j - curr // w])))\n s = 1\n break\n if (curr % d == 0) and (curr // d + 2 * j <= n):\n print(' '.join(map(str, [j, curr // d + j, n - 2 * j - curr // d])))\n s = 1\n break\n if (s == 0):\n print(-1)"}, {"source_code": "from sys import stdin\nfrom math import ceil, floor\n\n\ndef extgcd(a, b):\n if a == 0:\n return (b, 0, 1)\n g, x1, y1 = extgcd(b % a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\n\n# n, p, w, d = map(int, raw_input().split())\nn, p, w, d = map(int, stdin.readline().split())\n# print(n, p, w, d)\ng, x0, y0 = extgcd(w, d)\n# print(type(g))\n# print(type(x0))\n# print(type(y0))\nans = True\nif p % g != 0:\n ans = False\nelse:\n x0 *= p//g\n y0 *= p//g\n # print(type(x0))\n # print(type(y0))\n # x=x0+k*d/g\n # x0+k*d/g>=0\n # k>=-x0*g/d\n # x0+k*d/g<=n\n # k<=(n-x0)*g/d\n # y=y0-k*w/g\n # y0-k*w/g>=0, k<=y0*g/w\n # y0-k*w/g<=n, k>=(y0-n)*g/w\n klb = int(max(ceil(-x0*g/d), ceil((y0-n)*g/w)))\n kub = int(min(floor((n-x0)*g/d), floor(y0*g/w)))\n if d > w:\n kub = min(kub, int(floor(g*(n-x0-y0)/(d-w))))\n elif d < w:\n klb = max(klb, int(ceil(g*(n-x0-y0)/(d-w))))\n else:\n pass\n if klb > kub:\n ans = False\n else:\n k = klb\n z = -1\n while k <= kub and (z < 0 or z > n):\n x = x0+k*d//g\n y = y0-k*w//g\n z = n-x-y\n # print(\"%s %s %s\" % (x, y, z))\n k += 1\n if z < 0 or z > n:\n ans = False\nif ans:\n print(\"%s %s %s\" % (x, y, z))\nelse:\n print(\"-1\")\n"}, {"source_code": "inp = input()\nn, p,w,d = [int(e) for e in inp.split(\" \")]\n\nfor i in range(100000):\n rest = p - i * d\n y = i\n x = rest // w\n if (rest >= 0 and rest % w == 0 and x + y <= n ):\n print(rest // w, end=\" \")\n print(y, end=\" \")\n print(n - y - rest // w)\n quit()\nprint(-1)"}, {"source_code": "n,p,w,d=map(int,input().split())\ny=0\ntemp=p-y*d\nminus1=1\nwhile(temp>=0):\n if(temp%w==0):\n x=temp//w\n if(x+y<=n):\n print(x,y,n-x-y)\n minus1=0\n break\n y+=1\n temp-=d\n if(y>w):\n break\nif(minus1):\n print(-1)"}, {"source_code": "n,p,w,d=list(map(int,input().split()))\nflag=0\nx=-1\ny=-1\nz=-1\nfor i in range(w+1):\n if (p-(i*d))%w==0:\n y=i\n x=(p-(i*d))//w\n z=n-(x+y)\n flag=1\n break\nif x<0 or y<0 or flag==0 or z<0:\n print(-1)\nelse:\n print(*[x,y,z])\n"}, {"source_code": "from math import *\nn,p,w,d=map(int,input().split())\nif p%gcd(w,d)!=0 or w*n<p :\n print(-1)\nelif p%w==0:\n print(p//w,0,n-p//w)\n\nelse:\n win=0\n draw=0\n loss=0\n while p%w!=0 and p>=0:\n draw+=1\n p=p-d\n if p<0:\n print(-1)\n else:\n print(p//w,draw,n-p//w-draw)\n\n\n "}, {"source_code": "def euclid(a, b):\n\tif b==0:\n\t\treturn (1,0)\n\tx0, y0 = euclid(b, a%b)\n\treturn (y0, x0 - divs(a,b)*y0)\n\ndef gcd(a,b):\n\treturn gcd(b, a%b) if b != 0 else a\n\n\ndef divs(a, b):\n\treturn a//b if a*b>0 else (a+(-a%b))//b\n\nn, p, w, d = map(int, input().split())\ng = gcd(w,d)\nif p%g != 0:\n\tprint(-1)\n\texit(0)\n\nx0, y0 = euclid(w,d)\nx0 *= divs(p,g)\ny0 *= divs(p,g)\nnum = (n-x0-y0)*g\nden = d-w\nkmin1 = (divs(num,den)+1 if divs(num,den) >= 0 else divs(num,den)) if num%den != 0 else divs(num,den)\n\nnum = -x0*g;\nden = d;\nkmin2 = (divs(num,den)+1 if divs(num,den) >= 0 else divs(num,den)) if num%den != 0 else divs(num,den)\n\nnum = y0*g;\nden = w;\n\n# prdivs('num= ', num)\n# prdivs('den= ', den)\n# prdivs('divs(num,den)= ', divs(num,den))\n\n# prdivs('kmin1', kmin1)\n# prdivs('kmin2', kmin2)\n\nkmax = (divs(num,den) if divs(num,den) >= 0 else divs(num,den)-1) if num%den != 0 else divs(num,den)\n\n# prdivs('kmax',kmax)\n\nk = kmin1 if kmin1 > kmin2 else kmin2\n\n# prdivs('k= ', k)\n# prdivs('kmax= ', kmax)\n\nif k>kmax:\n\tprint(-1)\n\texit(0)\n\nx = x0 + divs((d*k),g)\ny = y0 - divs((w*k),g)\nz = n-x-y\n\nprint(str(x) + ' ' + str(y) + ' ' + str(z))"}, {"source_code": "x = 0\ny = 0\n \ndef exgcd( a, b):\n global x , y\n if (b == 0):\n x = 1\n y = 0\n return a;\n g = exgcd(b, a % b);\n t = x; \n x = y\n y = t - a // b * y; \n return g;\n \ndef Just_DOIT(w, d, p) :\n global x , y\n g = exgcd(w, d);\n if (p % g):\n return -1\n x *= p // g\n d //= g\n return (x % d + d) % d\n \n \nn, p , w , d = map(int, input().split())\nX = Just_DOIT(w, d, p)\nY = Just_DOIT(d, w, p)\nif (X == -1):\n print(-1)\nelse:\n y1 = (p - X * w) // d\n x2 = (p - Y * d) // w;\n if (y1 >= 0 and X + y1 <= n) :\n print( X , y1 , n - X - y1 )\n else: \n\t if (x2 >= 0 and x2 + Y <= n):\n\t print( x2 , Y , n - x2 - Y )\n\t else:\n\t print(-1)\n \n# "}, {"source_code": "def gcd (a, b): \n\tif (a == 0):\n\t\tans = [b, 0, 1]\n\t\treturn ans\n\td = gcd (b % a, a)\n\tans = [d[0], d[2] - (b // a) * d[1], d[1]]\n\treturn ans\nn, p, w, d = map(int, input().split())\ng = gcd(w, d)\nif p % g[0] != 0:\n print (-1)\nelse:\n w = w // g[0]\n d = d // g[0]\n x = g[1] * (p // g[0])\n y = g[2] * (p // g[0])\n if y >= 0:\n c = y // w\n y -= c * w\n x += c * d\n else:\n c = (abs(y) + w - 1) // w\n y += c * w\n x -= c * d\n if x < 0:\n print(-1)\n elif x + y > n:\n print(-1)\n else:\n print(x, y, n - x - y)"}, {"source_code": "def solve():\n n,p,w,d=map(int,input().split())\n x=p//w\n y=0\n while x>=0 and y<w:\n y=(p-x*w)/d\n if y==int(y):\n y=int(y)\n z=n-x-y\n if z<0:\n print(-1)\n return\n print(x,y,z)\n return\n x-=1\n print(-1)\n return\n \nsolve()\n"}, {"source_code": " \ndef egcd(a,b):\n if b==0:\n return a,1,0\n d,x,y = egcd(b,a%b)\n return d,y,x-a//b*y\n \ndef p5():\n n,p,w,d = map(int,input().split())\n g,a,b = egcd(w,d)\n if not p%g == 0:\n print(-1)\n else:\n w = w//g\n d = d//g\n p = p//g\n a = a*p\n b = b*p\n if a < 0:\n if b < 0:\n print(-1)\n else:\n k = b//w\n a = a + k*d\n b = b - k*w\n if a < 0 or a+b>n:\n print(-1)\n else:\n print(a,b,n-a-b)\n else:\n if b < 0:\n k = -b//w \n if not b%w==0:\n k=k+1\n b = b + k*w\n a = a - k*d\n if a < 0 or a+b>n:\n print(-1)\n else:\n print(a,b,n-a-b)\n else:\n k = b//w\n a = a + k*d\n b = b - k*w\n if a < 0 or a+b>n:\n print(-1)\n else:\n print(a,b,n-a-b)\n\ndef main():\n p5()\n \n \n \nif __name__ == '__main__':\n main()"}, {"source_code": "n,p,w,d=list(map(int,input().split()))\nflag=0\nx=-1\ny=-1\nz=-1\nfor i in range(w):\n if (p-(i*d))%w==0:\n y=i\n x=(p-(i*d))//w\n z=n-(x+y)\n flag=1\n break\nif x<0 or y<0 or flag==0 or z<0:\n print(-1)\nelse:\n print(*[x,y,z])"}, {"source_code": "import math\nc=0\nn,p,w,d=map(int,input().split())\nc=0\nfor i in range(w):\n nd=i\n if (p-nd*d)%w==0:\n nw=(p-nd*d)/w\n nl=n-nw-nd\n c=1\n break\nif (w*n<p) or (c==0) or ((p<d) and (p>0)):\n print (-1)\nelse:\n print (int(nw),\" \",int(nd),\" \",int(nl))\n \n"}, {"source_code": "import math\n\n(n, p, w, d) = list(map(int, input().split()))\n\nflag = False\na = w - d\nb = -d\nc = p - n * d\n\nif p == 0:\n print(0, 0, n)\n\nelif c % math.gcd(abs(a), abs(b)) != 0:\n print(-1)\n\nelse:\n X = math.gcd(abs(a), abs(b))\n if c >= 0:\n a //= X\n b //= X\n c //= X\n else:\n a //= -X\n b //= -X\n c //= -X\n\n\n for k in range(abs(a)):\n if (c - b * k) % a == 0:\n Y = k\n X = (c - b * Y) // a\n flag = True\n break\n\n if flag:\n if (0 <= X <= n) and (0 <= Y <= n) and (0 <= n - X - Y <= n):\n print(X, n - X - Y, Y)\n else:\n #kmax = min((n - X) // b, (n - Y) // a)\n #kmin = max((- Y) // a, (- X) // b)\n #print((n - X) // b)\n #print((n - Y) // a)\n #print(( - X) // b)\n #print(( - Y) // a)\n\n if a > 0:\n amax = Y // a\n amin = (Y - n) // a\n else:\n amin = Y // a\n amax = (Y - n) // a\n if b > 0:\n bmax = (n - X) // b\n bmin = -X // b\n else:\n bmin = (n - X) // b\n bmax = -X // b\n\n kmin = max(amin, bmin)\n kmax = min(amax, bmax)\n if kmin < kmax:\n for k in range(kmin - 2, kmax + 2):\n xx = X + b * k\n yy = Y - a * k\n if (0 <= xx <= n) and (0 <= yy <= n) and (0 <= n - xx - yy <= n):\n print(xx, n - xx - yy, yy)\n flag = False\n break\n if flag:\n print(-1)\n\n else:\n print(-1)\n else:\n print(-1)"}, {"source_code": "def nod(m, n):\n return m if n == 0 else nod(n, m % n)\n \nn,c,a,b = map(int,input().split())\n \nnodAB = nod(abs(a), abs(b))\nif c % nodAB:\n print(\"-1\")\nelse:\n a //= nodAB\n b //= nodAB\n c //= nodAB\n \n for k in range(abs(a)):\n if c >= b * k and (c - b * k ) % a == 0:\n y = k\n x = ( c - b * y ) // a\n if x + y > n:\n print(-1)\n else:\n print(x,y,n - x - y)\n break\n else:\n print(\"-1\")\n"}, {"source_code": "def ii():\n return int(input())\ndef mi():\n return map(int, input().split())\ndef li():\n return list(mi())\n\nfrom math import gcd\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n gcd, x, y = egcd(b % a, a)\n return (gcd, y - (b//a) * x, x)\n\ndef solve_Dioph(a,b,c):\n _, x, y = egcd(a, b)\n if c % g > 0:\n print(-1)\n exit()\n\n x *= c // g\n y *= c // g\n if (a < 0):\n x = -x;\n if (b < 0):\n y = -y;\n return x, y\n\nn, p, w, d = mi()\na, b, c = w, d, p\n\ng = gcd(a, b)\nif p % g != 0:\n print(-1)\n exit()\n\nx, y = solve_Dioph(a, b, p)\n\ndef get_x_y(k):\n assert((k * b) % g == 0)\n assert((k * a) % g == 0)\n ttx = x - (k * b) // g\n tty = y + (k * a) // g\n return ttx, tty\n\nk_min = ((g * -y) + a - 1) // a\nk_max = (g * x) // b\n# print(k_min, k_max, get_x_y(k_min), get_x_y(k_max))\n# k_max = min(k_max, ((n - (x+y)) * g) // (a-b))\n\nif k_min > k_max:\n print(-1)\n exit()\n\n# for wow in range(k_min - 100000, min(k_min + 100000, k_max+100000)):\nx_, y_ = get_x_y(k_min)\n# print(x_, y_, n - (x_ + y_))\nif x_ >= 0 and y_ >= 0 and x_ + y_ <= n:\n print(x_, y_, n - (x_ + y_))\n exit()\n\nprint(-1)"}], "negative_code": [{"source_code": "def egcd(a,b):\n # return gcd, x,y or None\n if(a==0):\n return b,0,1\n \n gcd,x1,y1 = egcd(b%a,a)\n return gcd,y1-(b//a)*x1,x1 \n\nn,p,w,d = list(map(int,input().strip().split()))\n\ng,x,y = egcd(w,d)\na,b=w,d\n\nif(p%g!=0):\n print(-1)\nelse:\n #find smallest sum positive solutions\n # i.e final new x and y\n factor = p//g\n x*=factor\n y*=factor\n\n # find minimum +ve x \n from math import ceil\n k1=ceil(-x*g/b)\n k2=ceil(y*g/a)\n kmin = min(k1,k2)\n kmax = max(k1,k2)\n\n if(b>=a):\n k = kmin\n else:\n k = kmax\n z=n-x-y\n x = x + k*b//g\n y = y - k*a//g\n\n z=n-x-y\n if(z>=0 and x>=0 and y>=0 and x+y+z==n):\n print(x,y,z)\n else:\n print(-1)"}, {"source_code": "import math\nimport random\n\nn, p, w, d = map(int, input().split())\n\noutput = []\n\nc = (p - d * n) / (w - d)\nc = math.ceil(c)\n\nfor i in range(d):\n\n\tlower = (c - i) / d\n\tupper = (n - i) / d\n\n\tif lower - int(lower) == 0:\n\t\t\t\n\t\tlower = int(lower)\n\t\tupper = int(upper)\n\n\t\ta = lower\n\t\t\n\t\tcondition = True\n\n\t\twhile condition == True:\n\t\t\t\n\t\t\tb = i\n\t\t\tx = d * a + b\n\n\t\t\tif x >= 0:\n\t\t\t\ty = (p - x * w) / d\n\n\t\t\t\tif y >= 0:\n\t\t\t\t\ty = int(y)\n\t\t\t\t\tz = n - x - y\n\n\t\t\t\t\tif z >= 0:\n\t\t\t\t\t\toutput = [x, y, z]\n\t\t\t\t\t\tcondition = False\n\n\t\t\ta += 1\n\t\t\tif a > upper+1:\n\t\t\t\tcondition = False\n\n\t\t\t\t\n\tif len(output) == 3:\n\t\tprint(x, y, z)\n\t\tbreak\n\nelse:\n\tprint(-1)"}, {"source_code": "n,p,w,d=list(map(int,input().split()))\nflag=0\nfor i in range(w+1):\n if (p-(i*d))%w==0:\n y=i\n x=(p-(i*d))//w\n z=n-(x+y)\n flag=1\n break\nif flag==0 or z<0:\n print(-1)\nelse:\n print(*[x,y,z])\n"}, {"source_code": "n,p,w,d=map(int,input().split())\ny=0\nwhile(y<w and p%w):\n y+=1\n p+=-d\nx=p//w\nif x>=0 and (x+y)<=n:\n print(x, y, n-(x+y))\nelse:\n print(-1)\n\n\n"}, {"source_code": "n, p, w, d = map(int, input().split())\nfor y in range(w):\n x = (p - y * d) / w\n if x >= 0 and int(x) == x and n >= x + y:\n x = int(x)\n z = n - x - y\n print(x, y, z)\n break\nelse:\n print(-1)\n "}, {"source_code": "x=0\ny=0\ng=0\ndef extendedEuclid(a,b):\n global x\n global y\n global g\n if (b == 0):\n x = 1\n y = 0\n g = a\n return\n extendedEuclid(b, a % b)\n CX = y\n CY = x - (a // b) * y\n x = CX\n y = CY\n\nn,p,w,d=map(int,input().split())\nextendedEuclid(w, d)\n#print(\" \",x,\" \",y)\nif (p % g != 0):\n print(\"-1\")\nelse:\n x = x * p // g\n y = y * p // g\n k = p // g\n #print(x,y)\n lower1 = int((-1) * x * g / d)\n if(lower1 > 0):\n lower1+=1\n lower2 = int(g * (x + y - n) /(w - d))\n if(lower2 > 0):\n lower2+=1\n upper = (g * abs(y)) // w\n if(y<0):\n upper=upper*(-1)\n if (upper < 0):\n upper-=1\n lower = max(lower1, lower2)\n #print(\"a \",lower1,\" \",lower2,\" \",upper)\n if(lower > upper):\n t=lower\n x = x + ((d * t) // g)\n y = y - ((w * t) // g)\n z = n - x - y\n if(x>=0 and y>=0 and z>=0):\n print(x,y,z)\n else:\n print(\"-1\")\n else:\n t=lower\n if(upper>lower):\n t=lower+1\n x = x + (d * t) // g\n y = y - (w * t) // g\n z = n - x - y\n print(x,\" \",y,\" \",z)\n #print(y)\n #print(z)"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport heapq\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nimport sys\n\nsys.setrecursionlimit(10 ** 6) # max depth of recursion\nthreading.stack_size(2 ** 27) # new thread will get stack of such size\nfac_warm_up = False\nprintHeap = str()\nmemory_constrained = False\nP = 10 ** 9 + 7\n\n\nclass MergeFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n\n def find(self, a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n\n def merge(self, a, b):\n a = self.find(a)\n b = self.find(b)\n if a == b:\n return\n if self.size[a] < self.size[b]:\n a, b = b, a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n\n def set_size(self, a):\n return self.size[self.find(a)]\n\n def __len__(self):\n return self.num_sets\n\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\n\ndef prime_factors(n): # n**0.5 complex\n factors = dict()\n for i in range(2, math.ceil(math.sqrt(n)) + 1):\n while n % i == 0:\n if i in factors:\n factors[i] += 1\n else:\n factors[i] = 1\n n = n // i\n if n > 2:\n factors[n] = 1\n return (factors)\n\n\ndef all_factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef fibonacci_modP(n, MOD):\n if n < 2: return 1\n return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(\n fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD\n\n\ndef factorial_modP_Wilson(n, p):\n if (p <= n):\n return 0\n res = (p - 1)\n for i in range(n + 1, p):\n res = (res * cached_fn(InverseEuler, i, p)) % p\n return res\n\n\ndef binary(n, digits=20):\n b = bin(n)[2:]\n b = '0' * (digits - len(b)) + b\n return b\n\n\ndef is_prime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\n\ndef generate_primes(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n return prime\n\n\nfactorial_modP = []\n\n\ndef warm_up_fac(MOD):\n global factorial_modP, fac_warm_up\n if fac_warm_up: return\n factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]\n for i in range(2, fac_warm_up_size):\n factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD\n fac_warm_up = True\n\n\ndef InverseEuler(n, MOD):\n return pow(n, MOD - 2, MOD)\n\n\ndef nCr(n, r, MOD):\n global fac_warm_up, factorial_modP\n if not fac_warm_up:\n warm_up_fac(MOD)\n fac_warm_up = True\n return (factorial_modP[n] * (\n (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD\n\n\ndef get_int():\n return int(stdin.readline().strip())\n\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\n\nmemory = dict()\n\n\ndef clear_cache():\n global memory\n memory = dict()\n\n\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\ndef ncr(n, r):\n return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))\n\n\ndef binary_search(i, li):\n fn = lambda x: li[x] - x // i\n x = -1\n b = len(li)\n while b >= 1:\n while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like\n x += b\n b = b // 2\n return x\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\n\n\nTestCases = False\noptimise_for_recursion = True # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3\n\n\ndef main():\n n, p, w, d = get_tuple()\n gcd = math.gcd(w, d)\n if p%gcd ==0:\n p, w, d = p//gcd, w//gcd, d//gcd\n #print(p, w, d, gcd)\n for x in range(d):\n if (p - (x * w))%d == 0:\n y = (p - (x * w))//d\n #print(x, y)\n k = y//w\n y = y - k*w\n x = x + k*d\n if gcd*(x+y)<=n:\n print(x * gcd, y * gcd, n - ((x + y) * gcd))\n return\n break\n print(-1)\n\n\n\n\n# --------------------------------------------------------------------- END=\n\n\nif TestCases:\n for i in range(get_int()):\n main()\nelse:\n main() if not optimise_for_recursion else threading.Thread(target=main).start()\n"}, {"source_code": "l=[int(i) for i in input().split()]\nm=l[0]\np=l[1]\nw=l[2]\nd=l[3]\nif(p>w*m):\n print(-1)\nelif(p==w*m):\n print(m,0,0)\nelif(p==0):\n print(0,0,m)\nelse:\n z=[]\n count1=p//w\n while(count1!=0):\n q=(p-(w*count1))%d\n if(q==0):\n cat=(p-(w*count1))//d\n z.append([count1,cat])\n break\n count1-=1\n if(len(z)==0):\n print(-1)\n else:\n flg=0\n for i in z:\n if(i[0]+i[1]<=m):\n if(w*i[0]+d*i[1]==p):\n print(i[0],i[1],m-(i[0]+i[1]))\n break\n else:\n flg+=1\n if(flg==len(z)):\n print(-1)\n\n\n \n \n \n "}, {"source_code": "n, p, w, d = [int(x) for x in input().split()]\n\nif p == 0:\n print(\"0 0 %s\" % n)\n exit()\n\nfor i in range(w):\n pp = (p - i * d)\n pw = pp % w\n if pw == 0 and pp / w + i <= n:\n print(\"%s %s %s\" % (pp//w, i, (p - i - pp//w)))\n exit()\nprint(\"-1\")"}, {"source_code": "def gcdExtended(a, b): \n\tglobal x,y\n\tif(a==0):\n\t\tx=0\n\t\ty=1\n\t\treturn b\n\tgcd=gcdExtended(b%a,a)\n\tx1=x\n\ty1=y\n\tx=y1-(b//a)*x1\n\ty=x1\n\treturn gcd\n\ndef min(a,b):\n\tif(a>b):\n\t\treturn b\n\treturn a\n\ndef max(a,b):\n\tif(a<b):\n\t\treturn b\n\treturn a\n\ndef produce(x,y,w2,d2,swap):\n\tlb=0\n\tub=100000000000000000000000000\n\tlb=max(lb,(-x+d2-1)//d2)\n\tub=min(ub,(n-x)//d2)\n\tub=min(ub,(n-x)//d2)\n\tlb=max(lb,(y-n+w2-1)//w2)\n\tif(d2-w2>0):\n\t\tub=min(ub, (n-x-y)//(d2-w2))\n\t\tlb=max(lb, (-x-y+d2-w2-1)//(d2-w2))\n\telif(w2-d2>0):\n\t\tub=min(ub, (x+y)//(w2-d2))\n\t\tlb=max(lb, (x+y-n+w2-d2-1)//(w2-d2))\n\tif(lb<=ub):\n\t\tv1=x+lb*d2\n\t\tv2= y-lb*w2\n\t\tv3=n-v1-v2\n\t\tif(v1>=0 and v2>=0 and v3>=0):\n\t\t\tif(not swap):\n\t\t\t\tprint(v1,v2,v3)\n\t\t\t\treturn True\n\t\t\telse:\n\t\t\t\tprint(v2,v1,v3)\n\t\t\t\treturn True\n\t\n\treturn False\n\nn,p,w,d=map(int,input().split())\nx=1\ny=1\ng=gcdExtended(w,d)\nif(not p%g==0):\n\tprint(-1)\nelse:\n\tswap=False\n\tp=p//g\n\tw2=w\n\td2=d\n\tx=x*p\n\ty=y*p\n\tif(not produce(x,y,w2,d2,False)):\n\t\tif(not produce(y,x,d2,w2,True)):\n\t\t\tprint(-1)\n\t"}, {"source_code": "n,p,w,d=map(int,input().split())\nfor y in range(w+1):\n\ttemp=p-(y*d)\n\tif temp%p!=0:\n\t\tcontinue\n\tx=p-(d*y)\n\tif x<0:\n\t\tcontinue\n\tx=x//w \n\tz=n-x-y \n\tif z<0:\n\t\tcontinue\n\telse:\n\t\tprint(x,y,z)\n\t\texit()\nprint(-1)"}, {"source_code": "import math\n\ndef gcd(a,b):\n if 0==b:\n return a\n else:\n return gcd(b,a%b)\n\ndef lcm(a,b):\n return a*b/gcd(a,b)\n\ndef exgcd(a,b,X,Y):\n if 0==b:\n X[0]=1\n Y[0]=0\n return a\n g=exgcd(b,a%b,Y,X)\n Y[0]-=a//b*X[0]\n return g\n\ndef main():\n n,p,w,d=map(int,input().split());\n if 0==p:\n print('0 0 %d'%n);\n return\n g=gcd(w,d)\n if p%g!=0:\n print('-1')\n return\n X=[0]\n Y=[0]\n exgcd(w,d,X,Y)\n x=X[0]*p/g;\n y=Y[0]*p/g;\n\n L=max((p-d*n)/(w-d),0)\n R=p/w;\n\n k1=lcm(w,d)/w\n k2=lcm(w,d)/d\n\n mint=math.ceil((L-x)/k1)\n maxt=math.floor((R-x)/k1)\n\n if mint<=maxt:\n ansx=x+k1*mint\n ansy=y-k2*mint\n print('%d %d %d'%(ansx,ansy,n-ansx-ansy))\n else:\n print('-1')\nmain()"}, {"source_code": "import sys\nfrom fractions import gcd\nn, p, w, d = [int(item) for item in input().split()]\ndiv = gcd(w, d)\nif p % div != 0:\n print(-1)\nelse:\n p //= div\n w //= div\n d //= div\n ans = False\n reverse = False\n if w < d:\n w, d = d, w\n reverse = True\n for x in range(p // w, max(-1, p // w - 10**5), -1):\n if (p - x * w) % d != 0:\n continue\n y = (p - x * w) // d\n if y < 0 or x + y > n:\n continue\n ans = True\n break\n if ans:\n if reverse:\n print(x, y, n - x - y)\n else:\n print(y, x, n - x - y)\n else:\n print(-1)"}, {"source_code": "n, p, w, d = [int(i) for i in input().split(' ')]\n\nwins = p // w\nwhile wins >= 0:\n points_to_cover = p - w * wins\n if points_to_cover % d == 0:\n draws = points_to_cover // d\n if wins + draws > n:\n print(-1)\n exit(0)\n print(f'{wins} {draws} {n - wins - draws}')\n exit(0)\n wins -= 1\n# if n * w < p:\n# print(-1)\n# elif p % w == 0:\n# wins = p // w\n# print(f'{wins} 0 {n - wins}')\n# else:\n# x = p // w\n# actual_points = x * p\n# while actual_points >= 0:\n# y = \n# if y % d == 0:\n# print(\n# if y % d == 0:\n# print\n# if index == -1:\n# print(index)\n# else:\n# print(f'{index} {n - index} {0}')\n"}, {"source_code": "from math import ceil\ndef gcd(a, b):\n if a == 0:\n return b, 0, 1\n\n gc,x1,y1 = gcd(b%a, a)\n\n x = y1-(b//a) * x1\n y = x1\n return gc,x,y\n\n\nn,p,w,d = map(int, input().split())\n\nwd_gcd, b1, b2 = gcd(w,d)\n\nif (p % wd_gcd != 0):\n print(\"-1\")\nelse:\n fac = p//wd_gcd\n b1 *= fac\n b2 *= fac\n\n low_lim = -b1/(d/wd_gcd)\n hl = b2/(w//wd_gcd)\n low_lim2=(b1+b2-n)/((w-d)//wd_gcd)\n\n ll = max(low_lim, low_lim2)\n\n if (ll <= hl and ll >= 0):\n k = ceil(ll)\n\n if (k <= hl):\n print(b1+k*(d//wd_gcd), b2 - k * (w//wd_gcd), n - b1 - b2 + ((w-d)//wd_gcd)*k)\n else:\n print(\"-1\")\n else:\n print(\"-1\")\n"}, {"source_code": "x=0\ny=0\ng=0\ndef extendedEuclid(a,b):\n global x\n global y\n global g\n if (b == 0):\n x = 1\n y = 0\n g = a\n return\n extendedEuclid(b, a % b)\n CX = y\n CY = x - (a // b) * y\n x = CX\n y = CY\n\nn,p,w,d=map(int,input().split())\nextendedEuclid(w, d)\n#print(\" \",x,\" \",y)\nif (p % g != 0):\n print(\"-1\")\nelse:\n x = x * p // g\n y = y * p // g\n k = p // g\n #print(x,y)\n lower1 = int((-1) * x * g / d)\n if(lower1 > 0):\n lower1+=1\n lower2 = int(g * (x + y - n) /(w - d))\n if(lower2 > 0):\n lower2+=1\n upper = (g * abs(y)) // w\n if(y<0):\n upper=upper*(-1)\n if (upper < 0):\n upper-=1\n lower = max(lower1, lower2)\n #print(\"a \",lower1,\" \",lower2,\" \",upper)\n if(lower > upper+1):\n t=lower\n x = x + ((d * t) // g)\n y = y - ((w * t) // g)\n z = n - x - y\n if(x>=0 and y>=0 and z>=0):\n print(x,y,z)\n else:\n print(\"-1\")\n else:\n t=lower\n if(upper>lower):\n t=lower+1\n x = x + (d * t) // g\n y = y - (w * t) // g\n z = n - x - y\n print(x,\" \",y,\" \",z)\n #print(y)\n #print(z)"}, {"source_code": "n,p,w,d=map(int,input().split())\nif n*w<p:\n print(-1)\nelif (p%w==0 and p//w<=n) or (p%d==0 and p//d<=n):\n if p%w==0:\n print(p//w,0,n-p//w)\n else:\n print(0,p//d,n-p//d)\nelse:\n total=0\n i=0\n total=int(p/w)*w\n i=int(p/w)\n dif=p-total\n if dif==0:\n print(i,0,n-i)\n elif dif%d==0:\n print(i,dif//d,n-i-dif//d)\n else:\n while dif%d!=0:\n dif+=w\n i-=1\n print(i,dif//d,n-i-dif//d)"}, {"source_code": "# Brute force 2: Keep subtracting it by the larger number\n\n# HCF\ndef hcf(a,b):\n\tif a<b:\n\t\treturn hcf(b,a)\n\twhile b!=0:\n\t\ta,b=b,a%b\n\treturn a\n\ninpu = (input()).split(\" \")\ninp = [int(x) for x in inpu]\nn,p,w,d = inp[0], inp[1], inp[2], inp[3]\n\nflag = 0\n\nif p == 0:\n\tprint(\"0 0 \"+str(n))\nelse:\n\tf = hcf(w,d)\n\tif f != 1:\n\t\trem = p%f\n\t\tif rem !=0:\n\t\t\tprint(-1)\n\t\t\tflag = 1\n\t\telse:\n\t\t\tp = p//f\n\t\t\td = d//f\n\t\t\tw = w//f\n\n\n\tif flag == 0:\n\t\tp = float(p)\n\t\tw = float(w)\n\t\tpp = p/w\n\t\tdd = d/w\n\t\tl1 = int(p//d)\n\t\t#print(pp,dd,l1)\n\t\tfor i in range(l1+1):\n\t\t\t#print(pp,dd,l1)\n\t\t\ta = pp-dd*i\n\t\t\t#print(a)\n\t\t\tif a == int(a) and (int(a)+i<=n):\n\t\t\t\tprint(str(int(a))+\" \"+str(i)+\" \"+str(int(n-a-i)))\n\t\t\t\tbreak\n\n\t\telse:\n\t\t\tprint(-1)\n\n\n\n"}, {"source_code": "def egcd(a, b):\n\tif a == 0:\n\t\treturn (b, 0, 1)\n\telse:\n\t\tgcd, x, y = egcd(b % a, a)\n\t\treturn (gcd, y - (b//a) * x, x)\n\n \nn,p,w,d = input().split(' ')\nn = int(n)\np = int(p)\nw = int(w)\nd = int(d)\n\ngcd, nx, ny = egcd(w,d)\n\nif (p % gcd or p > n * w):\n print(-1)\nelse:\n nx *= p // gcd\n ny *= p // gcd\n w //= gcd\n d //= gcd\n new_Y = ny % w\n nx += d * ((ny - new_Y) // w)\n if (nx + new_Y > n):\n print(-1)\n else:\n print(nx,new_Y,n-nx-new_Y)"}, {"source_code": "n,p,w,d = map(int, input().split())\n\nres = (-1, -1)\nfor i in range(d+1):\n x = i*w\n remain = p if x == 0 else p % (i*w )\n if remain % d == 0:\n cd = remain // d\n cw = (p - cd*d) // w\n if cw + cd <= n:\n res = (cw, cd)\n\nif res != (-1, -1):\n cw, cd = res\n print(cw, cd, n-cw-cd)\nelse:\n print(-1)\n"}, {"source_code": "n, p, w, d = list(map(int, input().split()))\n\nrem = p % w\n\n# print(rem)\nif rem == 0:\n if (n - p/w) >= 0:\n print(int(p/w), 0, int(n - p/w))\n else:\n print(-1)\n exit(0)\n\nif rem % d != 0:\n print(-1)\nelse:\n if n - p/w - rem/d >= 0:\n print(int(p/w), int(rem/d), int(n - p/w - rem/d))\n else:\n print(-1)\n\n\n\n"}, {"source_code": "x=int(0)\ny=int(0)\n\ndef exgcd(a,b):\n global x,y\n if b==0:\n x=1\n y=0\n return a\n d=exgcd(b,a%b)\n tmp=x\n x=y\n y=tmp-a//b*y\n return d\n\nn,p,w,d=map(int,input().split())\n\nif p==0:\n print('0 0 ',end='')\n print(n)\nelse:\n tmp=exgcd(w,d)\n if p%tmp!=0:\n print('-1')\n else:\n d1=d//tmp\n d2=w//tmp\n x*=(p//tmp)\n x=(x%d1+d1)%d1\n y=(p-w*x)//d\n if y<0:\n print('-1')\n else:\n k=(n-x-y)//(d1-d2)\n if k>0 and (n-x-y)%(d1-d2)!=0:\n k+=1\n x=x+k*d1\n y=y-k*d2\n if y<0:\n print(-1)\n else:\n print(x,y,n-x-y,end=' ')"}, {"source_code": "n,p,d,w = map(int,input().split())\nres = False\nfor draws in range(w):\n remain = p - draws*d\n if remain>=0 and remain%w==0 and draws+remain//w<=n:\n print(remain//w, draws,n-(remain//w)-draws)\n res = True\nif not res:\n print(-1)"}, {"source_code": "from __future__ import division, print_function\ndef main():\n n,p,w,d=map(int,input().split())\n wins=0\n def gcd(a,b):\n while b:\n a,b=b,a%b\n return a\n lcm=(w*d)//gcd(w,d)\n x=lcm//w\n while (wins*w)<=lcm and wins<n and (p-wins*w)%d!=0:\n wins+=1\n \n if (p-wins*w)%d==0:\n low=0\n high=(n-wins)//x\n \n while low<=high:\n mid=(high+low)//2\n a=mid*x+wins\n if p<a*w:\n high=mid-1\n continue\n draws=(p-a*w)//d\n if a+draws>n:\n low=mid+1\n else :\n break\n \n draws=(p-a*w)//d\n if a+draws<=n and draws>0:\n print(a,draws,n-a-draws)\n else :\n print(-1)\n else :\n print(-1)\n \n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()"}, {"source_code": "def gcd(a,b):\n\tif b==0:\n\t\treturn a \n\treturn gcd(b,a%b)\ndef isPossible(a, b, c): \n\treturn (c % gcd(a, b) == 0)\n\nn,p,w,d=map(int,input().split())\nif isPossible(w,d,p):\n\n\tx=p//w \n\trep=p-(x*w)\n\ty=rep//d \n\tbaaki=rep-(y*d)\n\tif baaki!=0:\n\t\tprint(-1)\n\t\texit()\n\tz=n-(x+y)\n\tif z<0:\n\t\tprint(-1)\n\t\texit()\n\tprint(x,y,z)\nelse:\n\tprint(-1)"}, {"source_code": "from math import ceil\n\nn,p,w,d = map(int, input().split())\ne = x = n\ns = 0\ny = None\nfor i in range(64):\n a = x * w\n y = ceil((p - a) / d)\n if y < 0:\n e = x\n x = (s + x) // 2\n continue\n b = y * d\n ss = a + b\n if ss == p and x+y <= n:\n break\n if (a < p) or x + y > n:\n s = x\n x = (e + x) // 2\n else:\n e = x\n x = (s + x) // 2\nelse:\n dir_ = 1 if p - ss > 0 else -1\n for i in range(100000):\n x += dir_\n a = x * w\n y = (p - a) // d\n b = y * d\n ss = a + b\n if ss == p and x+y <= n:\n break\n else:\n print(-1)\n exit()\nprint(x, y, n - x - y)\n"}, {"source_code": "n, p, w, d = list(map(int, input().split()))\n\ns = 0\n\nif (n * w < p):\n print(-1)\nelif (p % w == 0):\n print(' '.join(map(str, [p // w, 0, n - p // w])))\nelse:\n max_w = p // w\n for i in range(max_w + 1):\n y_z = p - i * w\n if (y_z % d == 0) and (y_z // d > 0) and (y_z // d <= n - 1):\n print(' '.join(map(str, [i, y_z// d, n - i - y_z// d])))\n s = 1\n break\n if (s == 0):\n print(-1)"}, {"source_code": "x=0\ny=0\ng=0\ndef extendedEuclid(a,b):\n global x\n global y\n global g\n if (b == 0):\n x = 1\n y = 0\n g = a\n return\n extendedEuclid(b, a % b)\n CX = y\n CY = x - (a // b) * y\n x = CX\n y = CY\n\nn,p,w,d=map(int,input().split())\nextendedEuclid(w, d)\n#print(\" \",x,\" \",y)\nif (p % g != 0):\n print(\"-1\")\nelse:\n x = x * p // g\n y = y * p // g\n k = p // g\n #print(x,y)\n lower1 = int((-1) * x * g / d)\n if(lower1 > 0):\n lower1+=1\n lower2 = int(g * (x + y - n) /(w - d))\n if(lower2 > 0):\n lower2+=1\n upper = (g * abs(y)) // w\n if(y<0):\n upper=upper*(-1)\n if (upper < 0):\n upper-=1\n lower = max(lower1, lower2)\n #print(\"a \",lower1,\" \",lower2,\" \",upper)\n if(lower > upper+1):\n print(\"-1\")\n else:\n t=lower\n if(upper>lower):\n t=lower+1\n x = x + (d * t) // g\n y = y - (w * t) // g\n z = n - x - y\n print(x,\" \",y,\" \",z)\n #print(y)\n #print(z)"}, {"source_code": "list1=[int(x) for x in input().split(' ')]\nc=int(list1[1]/list1[3])\nn=list1[1]\nwhile c != 0:\n n-=list1[3]\n c=n % list1[2]\na=int(n/list1[2])\nb=int((list1[1]-n)/list1[3])\nif a+b <= list1[0]:\n print(a,b,list1[0]-a-b,sep=' ')\nelse:\n print(-1)\n\n"}, {"source_code": "\nn,p,w,d=map(int, input().split(' '))\nx=p//w\nfor y in range(w):\n if((y*d - p%w)%w==0):\n x-=((y*d-p%w)//w)\n break\nz=n-x-y\nif(x+y+z==n and x*w+y*d==p):\n print(\"%d %d %d\"%(x,y,z))\nelse:\n print(\"-1\")\n\n"}, {"source_code": "\nn,p,w,d=map(int, input().split(' '))\nx=p//w\nfor y in range(w):\n if((y*d - p%w)%w==0):\n x-=((y*d-p%w)//w)\n break\nz=n-x-y\nif(x+y+z==n and x*w+y*d==p):\n print(\"%d %d %d\"%(x,y,z))\nelse:\n print(\"-1\")\n\n"}, {"source_code": "n, p, w, d = map(int, input().split())\n\nx = y = 0\n\ndef gcd_ext(a,b):\n global x,y\n if a == 0:\n x, y = 0, 1\n return b\n d = gcd_ext(b % a, a)\n x, y = y - (b // a) * x, x\n return d\n\nt = gcd_ext(w, d)\n\nif p % t != 0:\n print(-1)\nelse:\n x *= (p // t)\n y *= (p // t)\n sx, sy = x, y\n while x + y > n and y >= 0:\n x += d // t\n y -= w // t\n if x + y <= n and x >= 0 and y >= 0:\n print(x, y, n-(x+y))\n else:\n x,y = sx,sy\n while x + y > n and x >= 0:\n x -= d // t\n y += w // t\n if x + y <= n and x >= 0 and y >= 0:\n print(x, y, n-(x+y))\n else:\n print(-1)\n \n"}, {"source_code": "l1 = [int(x) for x in input().split()]\nn = l1[0]\np = l1[1]\nw = l1[2]\nd = l1[3]\nrem = p%w\nif rem%d==0:\n y = rem//d\n x = (p-(d*y))//w\n z = n-x-y\n print(x,y,z)\nelse:\n print(-1)"}, {"source_code": "import math\nn,p,w,d = [int(i) for i in input().split()]\ng = math.gcd(w, d)\nif p % g != 0:\n print(-1)\n exit()\n\nww = w // g\ndd = d // g\npp = p // g\n\n\naa, bb = w, d\nk = []\n\nwhile bb != 0:\n kk = aa // bb\n k.append(kk)\n temp = aa % bb\n aa = bb\n bb = temp\n\n# print(k)\n\ntups = [[1,0], [0, 1]]\nfor i in range(len(k)):\n nex = [0, 0]\n nex[0] = tups[-2][0] - k[i] * tups[-1][0]\n nex[1] = tups[-2][1] - k[i] * tups[-1][1]\n tups.append(nex)\n\n# print(tups)\n\n\nx0 = tups[-2][0] * pp\ny0 = tups[-2][1] * pp\n\nbigt = y0 // ww\n\n\ny1 = y0 - bigt * ww\nx1 = x0 + bigt * dd\n\ny2 = y1 * g\nx2 = x1 * g\n\nif x2 + y2 > n or x2 < 0:\n oldt = bigt\n for i in range(-100000, 100000):\n bigt = oldt + i\n y1 = y0 - bigt * ww\n x1 = x0 + bigt * dd\n\n y2 = y1 * g\n x2 = x1 * g\n\n if x2 >= 0 and y2 >= 0 and x2 + y2 <= n:\n print(x2, y2, n - x2 - y2)\n exit()\n \n \n \n \n \n \n print(-1)\nelse:\n if x2 * w + y2 * d != p:\n 1//0\n if y2 < 0:\n while True:\n pass\n \n \n \n print(x2, y2, n - x2 - y2)"}, {"source_code": "def egcd(a, b):\n x,y, u,v = 0,1, 1,0\n while a != 0:\n q, r = b//a, b%a\n m, n = x-u*q, y-v*q\n b,a, x,y, u,v = a,r, u,v, m,n\n gcd = b\n return int(gcd), int(x), int(y)\n \nn, D, a, b = map(int, input().split())\nd, x, y = egcd(a, b)\n \nif (D%d != 0):\n print (\"-1\")\n exit()\n \nx *= D//d;\ny *= D//d;\n \nif (y < 0):\n up = ( (1 - y) + (a//d - 1) ) // (a//d);\n x -= (b//d) * up;\n y += (a//d) * up;\n \nif (y > a//d):\n drop = (y-1) // (a//d);\n x += b//d * drop;\n y -= a//d * drop;\n \nif (x < 0):\n print (\"-1\")\n exit()\n \nrem = n - (x+y)\nif (rem < 0):\n print (\"-1\")\nelse:\n print (x, y, rem)\n\n"}, {"source_code": "def egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, x, y = egcd(b % a, a)\n return (g, y - (b // a) * x, x)\n\nfrom math import gcd \ndef isPossible(a, b, c): \n return (c % gcd(a, b) == 0)\n \nn, c, a, b = [int(x) for x in input().split()]\n\nif isPossible(a, b, c):\n X = egcd(a, b)\n g = X[0]\n x = X[1] * c // g\n y = X[2] * c // g\n k = -1\n # print(x, y)\n l = max((x * g * -1) / b, ((n - x - y) * g) / (b - a))\n h = (y * g) / a\n # print(\"l, h: \", l, h)\n if l > h: print(-1)\n else:\n for i in range(int(l), int(h) + 1):\n if i >= l and i <= h:\n k = i\n break\n if k == -1: print(k)\n else:\n # print(k)\n x = x + (k * (b // g))\n y = y - (k * (a // g))\n z = n - x - y\n print(x, y, z)\nelse: print(-1)"}, {"source_code": "def egcd(a, b):\n \"\"\"return (g, x, y) such that a*x + b*y = g = gcd(a, b)\"\"\"\n if a == 0:\n return (b, 0, 1)\n else:\n b_div_a, b_mod_a = divmod(b, a)\n g, x, y = egcd(b_mod_a, a)\n return (g, y - b_div_a * x, x)\n\nX = 1; Y = 1; GCD = 1; \nn, p, w, d = map(int, input().split())\n__ = egcd(w, d)\nX = __[1]\nY = __[2]\nGCD = __[0]\n\nif p % GCD != 0:\n print(-1)\nelse:\n X *= p // GCD;\n Y *= p // GCD;\n LCM = w * d // GCD;\n a = LCM // w;\n b = LCM // d;\n if X > Y:\n alp = (-Y + b - 1) // b;\n x = X - alp * a;\n y = alp * b + Y;\n z = n - x - y;\n if x < 0 or y < 0 or z < 0:\n print(-11)\n else:\n print(x, end = \" \")\n print(y, end = \" \")\n print(z)\n else:\n alp = Y // b;\n x = alp * a + X;\n y = Y - alp * b;\n z = n - x - y;\n if x < 0 or y < 0 or z < 0:\n print(-12)\n else:\n print(x, end = \" \")\n print(y, end = \" \")\n print(z)\n \n \n \n \n \n \n "}, {"source_code": "from __future__ import division, print_function\ndef main():\n n,p,w,d=map(int,input().split())\n wins=0\n def gcd(a,b):\n while b:\n a,b=b,a%b\n return a\n lcm=(w*d)//gcd(w,d)\n x=lcm//w\n while (wins*w)<=lcm and wins<n and (p-wins*w)%d!=0:\n wins+=1\n \n if (p-wins*w)%d==0:\n low=0\n high=(n-wins)//x\n \n while low<=high:\n mid=(high+low)//2\n a=mid*x+wins\n if p<a*w:\n high=mid-1\n continue\n draws=(p-a*w)//d\n if a+draws>n:\n low=mid+1\n else :\n break\n \n draws=(p-a*w)//d\n if a+draws<=n:\n print(a,draws,n-a-draws)\n else :\n print(-1)\n else :\n print(-1)\n \n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()"}, {"source_code": "import math\na=list(map(int,input().split(\" \")))\nb=math.gcd(a[-2],a[-1])\nif a[1]%b!=0:\n print(-1)\nelse:\n c=int(a[1]/a[2])\n for i in range(c,c-10000,-1):\n if (a[1]-a[2]*i)%a[3]==0:\n d=int(a[1]-a[2]*i)/a[3]\n e=i\n if e+d>a[0]:\n print(-1)\n break\n else:\n f=a[0]-e-d\n print(\"%d %d %d\" %(e,d,f))\n break"}, {"source_code": "import math\n\n\ndef input_int():\n return list(map(int, input().split()))\n\n\ndef solve():\n [n, p, w, d] = input_int()\n if p == 0:\n print(0, 0, n)\n else:\n if w != 1:\n x = (p - n * d) // (w - d)\n y = n - x\n else:\n y = (p - n) // (d - 1)\n x = n - y\n if x < 0 or y < 0:\n print(-1)\n else:\n print(x, y, 0)\n return\n\n\nsolve()\n"}, {"source_code": "data = input()\ndata = data.split()\nn = int(data[0])\np = int(data[1])\nw = int(data[2])\nd = int(data[3])\n\np_int_d = int(p/d)\np_rem_d = p%d\nw_int_d = int(w/d)\nw_rem_d = w%d\n\nanswer = False\n\nif( (p/w) <= n):\n if( (p - n*d) <= 0 ) :\n low_lim = 0\n else :\n low_lim = int( (p - (n-1)*d)/w )\n top_lim = int(p/w)\n\n i = top_lim\n while (i >= low_lim) :\n if( (i + int((p-i*w)/d)) <= n ) :\n if( ((p-w*i)%d) == 0 ):\n answer = True\n x = i\n y =int((p-i*w)/d)\n z = n - x - y\n break\n else :\n break\n i = i + 1\n\n if(answer == True) :\n print(x, end=' ')\n print(y, end=' ')\n print(z)\nelse :\n print(-1)\n\n\n"}, {"source_code": "n,p,w,d=[int(i) for i in input().split(\" \")]\n\ndef exgcd(a,b):\n if b==0:\n return (1,0)\n tx,ty=exgcd(b,a%b)\n return (ty,tx-a//b*ty)\n\ndef gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\n\nx,y=exgcd(w,d)\ng=gcd(w,d)\nif p%g!=0:\n print(\"-1\")\n exit()\np/=g\nx*=p\ny*=p\nif x<0 and y<0:\n print(\"-1\")\n exit()\nif y<0:\n z=x\n x=y\n y=z\n z=w\n w=d\n d=z\ntmp=(-x+d-1)//d\nx+=d*tmp\ny-=w*tmp\nif y<0:\n print(\"-1\")\n exit()\nx+=d*(y//w)\ny%=w\nif x+y>n:\n print(\"-1\")\n exit()\nprint(int(x),int(y),int(n-x-y))"}, {"source_code": "\nn,p,w,d=map(int, input().split(' '))\nx=p//w\nfor y in range(0,w):\n if((y*d - p%w)%w==0):\n x-=((y*d-p%w)//w)\n break\nz=n-x-y\nif(x+y<=n and y<w and x>=0):\n print(\"%d %d %d\"%(x,y,z))\nelse:\n print(\"-1\")\n\n"}, {"source_code": "import sys\nimport math\n\ninput = sys.stdin.readline\n\nbig_number = 10000000\n\nn, p, w, d = map(int, input().split())\n\ngcd_w_d = math.gcd(w, d)\n\n\nif (p % gcd_w_d != 0) or (p > w*n + d*n) or (p<w):\n print(-1)\nelse:\n x0 = -1\n for i in range(0, int(p/w)):\n cur_x = p - w * i\n if cur_x % d == 0:\n x0 = i\n break\n\n if x0 == -1:\n print(-1)\n else:\n x = -1\n y = -1\n for i in range(0, n):\n x = x0 + i * (int(d / gcd_w_d))\n if p - w*x < 0:\n x = -1\n break\n y = int((p - w*x) / d)\n if x + y <= n:\n break\n\n if x == -1:\n print(-1)\n else:\n print(x, y, n - x - y)\n\n\n# elements_array = list(map(int, input().split()))\n\n# elements_array.sort()\n\n# answer_elements_list = [(big_number, -1)]*(elements_array[-1] + 1)\n\n# for element in elements_array:\n# cur_element = element\n# i = 0\n# while cur_element >= 0:\n# if answer_elements_list[cur_element][0] < big_number:\n# if answer_elements_list[cur_element][1] < k:\n# new_tuple = (answer_elements_list[cur_element][0] + i, answer_elements_list[cur_element][1] + 1)\n# answer_elements_list[cur_element] = new_tuple\n# else:\n# break\n# else:\n# answer_elements_list[cur_element] = (i, 1)\n# if cur_element == 0:\n# break\n# cur_element = int(cur_element / 2)\n# i += 1\n\n# best_result = big_number\n# for value in answer_elements_list:\n# if value[1] < k:\n# continue\n# cur_operations = value[0]\n# best_result = min(best_result, cur_operations)\n\n# print(best_result)"}, {"source_code": "import math\nn,p,w,d = [int(i) for i in input().split()]\ng = math.gcd(w, d)\nif p % g != 0:\n print(-1)\n exit()\n\nww = w // g\ndd = d // g\npp = p // g\n\n\naa, bb = w, d\nk = []\n\nwhile bb != 0:\n kk = aa // bb\n k.append(kk)\n temp = aa % bb\n aa = bb\n bb = temp\n\n# print(k)\n\ntups = [[1,0], [0, 1]]\nfor i in range(len(k)):\n nex = [0, 0]\n nex[0] = tups[-2][0] - k[i] * tups[-1][0]\n nex[1] = tups[-2][1] - k[i] * tups[-1][1]\n tups.append(nex)\n\n# print(tups)\n\n\nx0 = tups[-2][0] * pp\ny0 = tups[-2][1] * pp\n\nbigt = y0 // ww\n\ny1 = y0 - bigt * ww\nx1 = x0 + bigt * dd\n\ny2 = y1 * g\nx2 = x1 * g\n\nif x2 + y2 > n or x2 < 0:\n print(-1)\nelse:\n print(x2, y2, n - x2 - y2)"}, {"source_code": "def gcdExtended(a, b): \n if a == 0 : \n return b,0,1\n gcd,x1,y1 = gcdExtended(b%a, a) \n x = y1 - (b//a) * x1 \n y = x1 \n return gcd,x,y \n \nn,p,w,d=map(int,input().split())\n\ngc,x0,y0=gcdExtended(w,d)\nif p%gc!=0:\n print(-1)\n exit(0)\n\nu=p//gc\nx1=x0*u\ny1=y0*u\nfrom math import ceil\n\n\nr1=-x1*gc//d\nr2=y1*gc//w\n\nu=gc*(n-x1-y1)//(d-w)\nprint(x1+(d*u//gc),y1-(w*u//gc),n-((x1+(d*u//gc))+(y1-(w*u//gc))))\n\n"}, {"source_code": "from fractions import gcd\n\ndef modinv(x, n):\n s, old_s = 0, 1\n t, old_t = 1, 0\n r, old_r = n, x\n while r != 0:\n quotient = old_r // r\n old_r, r = r, old_r - quotient * r\n old_s, s = s, old_s - quotient * s\n old_t, t = t, old_t - quotient * t\n \n if old_r != 1: return -1 \n return old_s % n\n\nn, p, w, d = map(int, raw_input().strip().split())\n\ng = gcd(w, d)\nif p % g != 0:\n print -1\n exit()\n\nr = modinv(d, w - d)\nr *= p\n\nif r < 0:\n print -1\n exit()\n\nq = (p - w * r + w * (w - d) - 1) / (w * (w - d))\nN = q * (w - d) + r\n\nif N > n:\n print -1\n exit()\n\nx = (p - N * d) / (w - d)\nif (x < 0):\n print -1\n exit()\n\ny = N - x\nz = n - N\n\ntry:\n assert (w * x + d * y == p and x + y + z == N and x >= 0 and y >= 0 and z >= 0)\nexcept:\n print -1\n exit()\n\nprint x, y, z"}, {"source_code": "import math\n\n\ndef input_int():\n return list(map(int, input().split()))\n\n\ndef solve():\n [n, p, w, d] = input_int()\n lo = 0\n hi = n\n wins = hi\n while wins != lo:\n wins = (lo + hi) // 2\n win_points = wins * w\n points_left = p - win_points\n if points_left < 0:\n hi = wins\n continue\n draws = min(points_left // d, n - wins)\n leftover_points = points_left - draws * d\n losses = n - wins - draws\n if leftover_points == 0:\n print(wins, draws, losses)\n return\n if leftover_points > 0:\n lo = wins\n continue\n print(-1)\n return\n\n\nsolve()\n"}, {"source_code": "x=0\ny=0\ng=0\ndef extendedEuclid(a,b):\n global x\n global y\n global g\n if (b == 0):\n x = 1\n y = 0\n g = a\n return\n extendedEuclid(b, a % b)\n CX = y\n CY = x - (a // b) * y\n x = CX\n y = CY\n\nn,p,w,d=map(int,input().split())\nextendedEuclid(w, d)\n#print(\" \",x,\" \",y)\nif (p % g != 0):\n print(\"-1\")\nelse:\n x = x * p // g\n y = y * p // g\n k = p // g\n #print(x,y)\n lower1 = int((-1) * x * g / d)\n if(lower1 > 0):\n lower1+=1\n lower2 = int(g * (x + y - n) /(w - d))\n if(lower2 > 0):\n lower2+=1\n upper = (g * abs(y)) // w\n if(y<0):\n upper=upper*(-1)\n if (upper < 0):\n upper-=1\n lower = max(lower1, lower2)\n #print(\"a \",lower1,\" \",lower2,\" \",upper)\n if(lower > upper):\n print(\"-1\")\n else:\n t=lower\n if(upper>lower):\n t=lower+1\n x = x + (d * t) // g\n y = y - (w * t) // g\n z = n - x - y\n print(x,\" \",y,\" \",z)\n #print(y)\n #print(z)"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=1000000007\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\n# vsInput()\n \nfor _ in range(1):\n n,p,w,d=value()\n\n # w*x + d*y =p\n\n if(w==1):\n if(p>n):\n print(-1)\n else:\n print(p,0,n-p)\n\n else:\n\n\n for draws in range(w):\n \n rem_score=p-draws*d\n wins=rem_score//w\n\n loose=n-wins-draws\n\n if(loose>=0 and wins+draws<=n and rem_score%w==0 and wins>0):\n print(wins,draws,loose)\n exit()\n\n\n if(p==0):\n print(0,0,n)\n else:\n print(-1)\n\n \n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "}, {"source_code": "def main():\n n, p, w, d = (int(i) for i in input().split())\n if p == 0:\n print(0, 0, n)\n elif (0--p//w) > n:\n print(-1)\n elif p % w == 0:\n x = p // w\n print(x, 0, n - x)\n else:\n s = set()\n for r in range(d, p, d):\n if r % d in s:\n break\n s.add(r % d)\n if (p - r) % w == 0 and (p - r) // w < (0--p//w):\n x = (p - r) // w\n y = r // d\n z = n - x - y\n print(x, y, z)\n return\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "\nimport math\nimport sys\n \n \ndef exgcd(a, b):\n if b == 0:\n return (1, 0)\n else:\n y, x = exgcd(b, a % b)\n y -= x * (a // b)\n return (x, y)\n \n \ndef ceil(x, y):\n return x // y + (x % y != 0)\n \n \ndef output(a, b, n):\n if a < 0 or b < 0:\n return\n if a + b > n:\n return\n \n print(a, b, n - a - b)\n sys.exit(0)\n \n \ndef main():\n n, p, w, d = [int(x) for x in input().split(' ')]\n g = math.gcd(w, d)\n if p % g != 0:\n print(-1)\n return\n x, y = exgcd(w, d)\n a = w // g\n b = d // g\n g = p // g\n x *= g\n y *= g\n \n if x < 0:\n t = ceil(-x, b)\n x += t * b\n y -= t * a\n elif y < 0:\n t = ceil(-y, a)\n x -= t * b\n y += t * a\n \n if x < 0 or y < 0:\n print(-1)\n else:\n #output(x, y, n)\n output(x % b, y + (x // b) * a, n)\n #output(x + (y // a) * b, y % a, n)\n print(-1)\n \n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def solve(n, p, w, d):\n y = 1e18\n if p % w == 0:\n print(\"{} {} {}\".format(p // w, 0, n - p // w))\n return\n for i in range(w):\n if (d * i) % w == 1:\n y = min(y, (p * i) % w)\n x = (p - y * d) // w\n z = n - x - y\n if z < 0 or x < 0 or y == 1e18:\n print(-1)\n else:\n print(\"{} {} {}\".format(x, y, z))\n\nn, p, w, d = [int(x) for x in input().split()]\nsolve(n, p, w, d)"}, {"source_code": "n, p, w, d = list(map(int, input().split()))\ns = p%w\nl = [(i*d)%w for i in range(0, w)]\ny = l.index(s)\nx = (p-y*d)//w\nif x+y <= n:\n print(x, y, n-x-y)\nelse:\n print(-1)\n "}, {"source_code": "\ndef exgcd(a,b,x,y):\n if b==0:\n x[0]=1\n y[0]=0\n return a\n r=exgcd(b,a%b,y,x)\n y[0]-=(a//b)*x[0]\n return r;\n\ndef min_ans(a,b,x,y,n):\n g=exgcd(a,b,x,y)\n if n%g:\n return 0\n x[0]*=n//g\n y[0]*=n//g\n db=b//g\n x[0]=((x[0]%db)+db)%db\n y[0]=(n-a*x[0])//b;\n return g\ns=input().split()\nn=int(s[0])\np=int(s[1])\nw=int(s[2])\nd=int(s[3])\nx=[0]\ny=[0]\ng=min_ans(w,d,x,y,p)\nx=x[0]\ny=y[0]\nif g==0:\n print(\"-1\")\nelse:\n if x+y>n:\n da=w//g\n db=d//g\n if db>=da:\n print(\"-1\")\n else:\n tmp=x+y-n\n tmp=(tmp+da-db-1)//(da-db)\n x+=tmp*db\n y-=tmp*da\n if 0<=x and x<=n and 0<=y and y<=n and 0<=x+y and x+y<=n:\n print(\"%d %d %d\"%(x,y,n-x-y))\n else:\n print(\"-1\")\n else:\n print(\"%d %d %d\"%(x,y,n-x-y))"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,p,w,d = [int(x) for x in input().split()]\n\n# x+y+z = n\n# x * w + y * d = p\n\ndef xgcd(a, b):\n \"\"\"return (g, x, y) such that a*x + b*y = g = gcd(a, b)\"\"\"\n x0, x1, y0, y1 = 0, 1, 1, 0\n while a != 0:\n q, b, a = b // a, a, b % a\n y0, y1 = y1, y0 - q * y1\n x0, x1 = x1, x0 - q * x1\n return b, x0, y0\n\ndef sign(x):\n return 1 if x >= 0 else -1\n\ng,x,y = xgcd(w,d)\n\nif p % g != 0:\n print -1\nelse:\n p //= g\n\n x *= p\n y *= p\n\n x0 = d // g\n y0 = -(w // g)\n\n # x0 < -y0\n # y + k * y0 >= 0\n k = sign(y0) * (-y + abs(y0) - 1)//abs(y0)\n\n x += k * x0\n y += k * y0\n\n if x < 0:\n # x + k * x0 >= 0\n k = (-x + x0 - 1)//x0\n x += k * x0\n y += k * y0\n\n\n if 0 <= x and 0 <= y and x + y <= n:\n print x,y,n - x - y\n else:\n print -1\n"}, {"source_code": "# Brute force 2: Keep subtracting it by the larger number\n\nfrom decimal import Decimal\n\n# HCF\ndef hcf(a,b):\n\tif a<b:\n\t\treturn hcf(b,a)\n\twhile b!=0:\n\t\ta,b=b,a%b\n\treturn a\n\ninpu = (input()).split(\" \")\ninp = [Decimal(x) for x in inpu]\nn,p,w,d = inp[0], inp[1], inp[2], inp[3]\n\n\nflag = 0\n\nif p == 0:\n\tprint(\"0 0 \"+str(n))\nelse:\n\tf = hcf(w,d)\n\tif f != 1:\n\t\trem = p%f\n\t\tif rem !=0:\n\t\t\tprint(-1)\n\t\t\tflag = 1\n\t\telse:\n\t\t\tp = p//f\n\t\t\td = d//f\n\t\t\tw = w//f\n\n\n\tif flag == 0:\n\t\tp = Decimal(p)\n\t\tw = Decimal(w)\n\t\td = Decimal(d)\n\t\tpp = p/w\n\t\tdd = d/w\n\t\tl1 = Decimal(p//w)\n\t\tl2 = w-1\n\t\ti = 0\n\t\twhile(i<=l2):\n\t\t\ta = pp-dd*i\n\t\t\tif a>=0 and a == int(a) and (int(a)+i<=n):\n\t\t\t\tprint(str(int(a))+\" \"+str(i)+\" \"+str(int(n-a-i)))\n\t\t\t\tbreak\n\t\t\ti+=1\n\t\telse:\n\t\t\tprint(-1)\n\n\n\n\n"}, {"source_code": "import math\nimport random\n\nn, p, w, d = map(int, input().split())\n\noutput = []\n\nc = (p - d * n) / (w - d)\nc = math.ceil(c)\n\nfor i in range(d + 1):\n\t\n\tlower = (c - i) / d\n\tupper = (n - i) / d\n\n\tif lower - int(lower) == 0:\n\t\tif upper - int(upper) == 0:\n\t\t\t\n\t\t\tlower = int(lower)\n\t\t\tupper = int(upper)\n\n\t\t\ta = lower\n\t\t\t\n\n\t\t\tcondition = True\n\n\t\t\twhile condition == True:\n\t\t\t\t\n\t\t\t\tb = i\n\t\t\t\tx = d * a + b\n\t\t\t\t\n\t\t\t\tif x >= 0:\n\t\t\t\t\ty = (p - x * w) / d\n\t\t\t\t\t\n\t\t\t\t\tif y >= 0:\n\t\t\t\t\t\ty = int(y)\n\t\t\t\t\t\tz = n - x - y\n\t\t\t\t\t\toutput = [x, y, z]\n\t\t\t\t\t\tcondition = False\n\t\t\t\ta += 1\n\t\t\t\tif a > upper:\n\t\t\t\t\tcondition = False\n\n\t\t\t\t\n\tif len(output) == 3:\n\t\tprint(x, y, z)\n\t\tbreak\n\nelse:\n\tprint(-1)"}, {"source_code": "from math import ceil, floor\n\n\ndef extgcd(a, b):\n if a == 0:\n return (b, 0, 1)\n g, x1, y1 = extgcd(b % a, a)\n x = y1 - (b / a) * x1\n y = x1\n return (g, x, y)\n\nfrom sys import stdin\n\n# n, p, w, d = map(int, raw_input().split())\nn, p, w, d = map(int, stdin.readline().split())\n# print(n, p, w, d)\ng, x0, y0 = extgcd(w, d)\nans = True\nif p % g != 0:\n ans = False\nelse:\n x0 *= p/g\n y0 *= p/g\n # x=x0+k*d/g\n # x0+k*d/g>=0\n # k>=-x0*g/d\n # x0+k*d/g<=n\n # k<=(n-x0)*g/d\n # y=y0-k*w/g\n # y0-k*w/g>=0, k<=y0*g/w\n # y0-k*w/g<=n, k>=(y0-n)*g/w\n klb = int(max(ceil(-x0*g*1.0/d), ceil((y0-n)*g*1.0/w)))\n kub = int(min(floor((n-x0)*g*1.0/d), floor(y0*g*1.0/w)))\n if d > w:\n kub = min(kub, int(floor(g*1.0*(n-x0-y0)/(d-w))))\n elif d < w:\n klb = max(klb, int(ceil(g*1.0*(n-x0-y0)/(d-w))))\n else:\n pass\n if klb > kub:\n ans = False\n else:\n k = klb\n z = -1\n while k <= kub and (z < 0 or z > n):\n x = x0+k*d/g\n y = y0-k*w/g\n z = n-x-y\n # print(\"%s %s %s\" % (x, y, z))\n k += 1\n if z < 0 or z > n:\n ans = False\nif ans:\n print(\"%s %s %s\" % (x, y, z))\nelse:\n print(\"-1\")\n"}, {"source_code": "import math\nn,p,w,d=map(int,input().split())\nif n<(math.ceil(p/w)) or p<w and p<d and p>0:\n print('-1')\nif p==n and w>1 and d>1:\n print('-1')\nelif p==0:\n print(0,0,n)\nelse:\n i=0\n while True:\n if (p-i)%w==0:\n x=(p-i)//w\n y=i//d\n break\n i+=d\n print(x,y,n-x-y) "}, {"source_code": "from math import *\nfrom sys import *\nfrom heapq import *\nfrom collections import defaultdict\nimport os, sys\nfrom io import IOBase, BytesIO\nM=10**9+7\ndef pow(a,b):\n res=1\n while b>0:\n if b&1:\n res*=a\n a*=a\n b>>=1\n return res\ndef powmod(a,b,m):\n res=1\n while b>0:\n if b&1:\n res=((res*a)%m)\n a*=a\n b>>=1\n return res\ndef inv(a,m):\n return powmod(a,m-2,m)\ndef alldivisors(n) : \n list = [] \n arr=[]\n for i in range(1, int(sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n / i == i) : \n arr+=[i]\n else :\n arr+=[i]\n list.append(n//i) \n arr+=list[::-1]\n return arr\ndef primefactorisation(n):\n potentional_p = 3\n itog_list = defaultdict(int)\n if n % 2 == 0:\n itog_list[2] = 0\n while n % 2 == 0:\n n = n // 2\n itog_list[2] += 1\n while n - 1:\n if potentional_p > (n**0.5):\n itog_list[n] += 1\n return itog_list\n while n % potentional_p == 0:\n n = n // potentional_p\n itog_list[potentional_p] += 1\n potentional_p += 2\n return itog_list\n\n\n\ndef main():\n n,p,w,d=list(map(int,input().split()))\n gd=gcd(w,d)\n if p%gd==0:\n p=p//gd\n w=w//gd\n d=d//gd\n else:\n print(-1)\n exit(0)\n x_i=p/w\n y_i=p/d\n \n if y_i<x_i:\n x=0\n while 1:\n val=p-x*w\n if val%d==0:\n if val>=0 and n-x-val//d>=0:\n print(x,val//d,n-x-val//d)\n break\n else:\n print(-1)\n break\n x+=1\n else:\n #print(\"here\")\n y=0\n while 1:\n val=p-y*d\n if val%w==0:\n print(p,d,val,w)\n if val>=0 and n-y-val//w>=0:\n print(val//w,y,n-y-val//w)\n break\n else:\n print(-1)\n break\n y+=1\n\n\n\n \n\n\n\n\n\n\n\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \nif __name__ == '__main__':\n main()\n#threading.Thread(target=main).start()\n\n\n\n\n\n\n"}, {"source_code": "#Problem 3 more elegant\nn, p, w, d = map(int,input().split())\np_max = n*w\nw_count = 0\nd_count = 0\nscore = 0\nif p_max < p:\n print(\"-1\")\nelse:\n maxwins = int(p/w)\n if w*maxwins > p:\n maxwins = maxwins -1\n print(maxwins)\n n -= maxwins\n score = maxwins * w\n w_count += maxwins\n if score == p:\n print(int(w_count), 0, int(n))\n else:\n while score < p:\n scorediff = p - score\n if scorediff % d == 0:\n if n >= scorediff/d:\n d_count += scorediff/d\n n -= d_count\n print(int(w_count), int(d_count), int(n))\n break\n else:\n print(-1)\n break\n else:\n score -= w\n w_count -= 1\n n += 1\n if n * d < p - score:\n print(-1)\n break"}, {"source_code": "n,p,w,d=map(int,input().split())\nx=p//w \nremp=p-(x*w)\n# print(remp)\ny=remp//d \nbaaki=remp-(y*d)\nif baaki!=0:\n\tprint(-1)\nelse:\n\tprint(x,y,(n-(x+y)))"}, {"source_code": "n,p,w,l=map(int,input().split())\na,b=0,0\nc=[False for i in range(l+1)]\nd=0\nif(n*w<p):\n print(-1)\nelif(p==0):\n print(0,0,n)\nelse:\n a=p//w\n d=p%w\n while (a>=0):\n if(d%l==0 or c[d%l]==True):\n break\n c[d%l]=True\n a-=1\n d+=w\n b=d//l\n if(a+b<=n and a>=0):\n print(a,b,n-a-b)\n else:\n print(-1)"}, {"source_code": "def egcd(a, b):\n x,y, u,v = 0,1, 1,0\n while a != 0:\n q, r = b//a, b%a\n m, n = x-u*q, y-v*q\n b,a, x,y, u,v = a,r, u,v, m,n\n gcd = b\n return int(gcd), int(x), int(y)\n \nn, D, a, b = map(int, input().split())\n\nswap = 0\nif (a > b):\n a, b = b, a\n swap = 1\n\nd, x, y = egcd(a, b)\n \nif (D%d != 0):\n print (\"-1\")\n exit()\n \nx *= D//d;\ny *= D//d;\n \nif (x < 0):\n up = ( (1 - x) + (b//d - 1) ) // (b//d);\n x += (b//d) * up;\n y -= (a//d) * up;\n \nif (x > b//d):\n drop = (x-1) // (b//d);\n x -= b//d * drop;\n y += a//d * drop;\n \nif (y < 0):\n print (\"-1\")\n exit()\n \nif (swap):\n x, y = y, x\n\nrem = n - (x+y)\nif (rem < 0):\n print (-1)\nelse:\n print (x, y, rem)\n\n"}, {"source_code": "'''\n Author : thekushalghosh\n Team : CodeDiggers\n'''\nimport sys,math\ninput = sys.stdin.readline\nn,p,w,d = map(int,input().split())\na = max(0,(p // w) - 50000)\nb = min(n,a + 50000)\nif p == 0:\n print(0,0,n)\n sys.exit()\nif p < w:\n print(0,p // d,n - (p // d))\n sys.exit()\nfor i in range(a,b):\n if w * (i + 1) <= p and (p - (w * (i + 1))) % d == 0:\n q = (p - (w * (i + 1))) // d\n if q + i + 1 <= n:\n if p != 0:\n print(i + 1,q,n - q - i - 1)\n sys.exit()\n else:\n print(0,0,n)\nprint(-1)"}, {"source_code": "inp = input()\nn, p,w,d = [int(e) for e in inp.split(\" \")]\nif(p == 0):\n x = 0\n y = 0\n z = n\n print(x, end=\" \")\n print(y, end=\" \")\n print(z)\nelif(w*n < p or (w*n > p and (p % w)%d != 0)):\n print(-1)\nelse:\n x = p // w\n y = (p % w) // d\n z = n - x - y\n print(x, end=\" \")\n print(y, end=\" \")\n print(z)\n "}, {"source_code": "from math import ceil\nglobal x, y\n\ndef gcd(a, b, x, y):\n if (a == 0):\n x[0], y[0] = 0, 1\n return b\n x1, y1 = [0], [0]\n d = gcd(b%a, a, x1, y1)\n x[0] = y1[0] - (b // a) * x1[0]\n y[0] = x1[0]\n return d\n\ndef find_any_solution(a, b, c, x0, y0, g):\n if (a < 0): a = -a\n if (b < 0): b = -b\n g[0] = gcd(a, b, x0, y0)\n if (c % g[0]):\n return False\n x0[0] *= c // g[0]\n y0[0] *= c // g[0]\n if (a < 0): x0[0] = -x0[0]\n if (b < 0): y0[0] = -y0[0]\n return True\n\nn, p, d, w = list(map(int, input().split()))\n\nx, y, g = [0], [0], [0]\ncan = find_any_solution(w, d, p, x, y, g)\nx, y, g = x[0], y[0], g[0]\nif (can):\n dx, dy = d // g, w // g\n # DEBUG printf(\"## %lld %lld | %lld %lld\\n\", x, y, dx, dy)\n if (x < 0):\n needed = ceil(-x / dx)\n # DEBUG printf(\"xx %lld %lld %lld\\n\", x, dx, needed)\n x += needed * dx\n y -= needed * dy\n if (y < 0):\n needed = ceil(-y / dy)\n # DEBUG printf(\"yy %lld %lld %lld\\n\", x, dx, needed)\n x -= needed * dx\n y += needed * dy\n # // while (x + y > n and x >= 0 and y >= 0)\n # // {\n # // // if (x >= y)\n # // // {\n # // // lli needed = ceil((ldouble) (x - n) / dx)\n # // // x -= needed * dx, y += needed * dy\n # // // }\n # // // else\n # // // {\n # // // lli needed = ceil((ldouble) (y - n) / dy)\n # // // x += needed * dx, y -= needed * dy\n # // // }\n # // }\n while ((x + y > n or x < 0) and y >= 0):\n x += dx\n y -= dy\n while ((x + y > n or y < 0) and x >= 0):\n x -= dx\n y += dy\n # DEBUG printf(\"## %lld %lld\\n\", x, y)\n if (x + y > n or x < 0 or y < 0): print(\"-1\")\n else: print(x, y, n - (x + y))\nelse:\n print(\"-1\")\n"}, {"source_code": "def main():\n n, p, w, d = (int(i) for i in input().split())\n if p == 0:\n print(0, 0, n)\n elif (0--p//w) > n:\n print(-1)\n elif p % w == 0:\n x = p // w\n print(x, 0, n - x)\n else:\n for y in range(10**6 + 5):\n less = p - y * d\n if less % w == 0:\n x = less // w\n print(x, y, n-x-y)\n break\n else:\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def gcd(a, b, x, y):\n if(b == 0):\n x = 1\n y = 0\n return (a, x, y)\n\n d, x1, y1 = gcd(b, a%b, x, y)\n x = x1\n y = x1 - y1*(a // b)\n\n return (d, x, y)\n\ndef find_any_solution(a, b, c, x0, y0, g):\n g, x0, y0 = gcd(a, b, x0, y0)\n if c % g:\n return (-1, x0, y0)\n \n x0 *= c//g\n y0 *= c//g\n\n if a < 0:\n x0 = -x0\n if b < 0:\n y0 = -y0;\n\n return (g, x0, y0)\n\ndef main():\n entrada = input(\"\")\n entrada = entrada.split(' ')\n n, p, w, d = entrada\n n = int(n)\n p = int(p)\n w = int(w)\n d = int(d)\n\n x = None\n y = None\n g = None\n\n g, x, y = find_any_solution(w, d, p, x, y, g)\n if g == -1:\n print(-1)\n return 0\n w //= g\n d //= g\n\n if(y < 0):\n k = abs(y//w);\n\n y += k*w\n x -= k*d\n\n if y < 0:\n y += w\n x -= d\n\n\n if(x < 0):\n k = abs(x/d);\n\n y -= k*w;\n x += k*d;\n\n if(x < 0):\n y -= w;\n x += d;\n \n \n\n\n if(y > 0):\n k = abs(y/w);\n\n y -= k*w;\n x += k*d;\n \n\n \n\n N = n - x - y;\n\n\n if(x < 0 or y < 0 or (n - x - y < 0)):\n print(-1)\n else :\n print(x, \" \", y, \" \",N) \n\n\nmain()\n\n"}, {"source_code": "import math\nif __name__ == '__main__':\n [match, point, win, draw] = [int(z) for z in input().split()]\n def gcd(a, b):\n while b:\n a %= b\n a, b = b, a\n return a\n\n def extended_euclid(a, b):\n xx = 0\n y= 0\n yy = 1\n x = 1\n while b:\n q = a//b\n t = b\n b = a % b\n a = t\n t =xx\n xx = x - q * xx\n x=t\n t = yy\n yy= y- q * yy\n y=t\n return x, y\n\n\n def LinearDiophantine(a, b, c):\n d = gcd(a, b)\n if c % d != 0:\n return -1, -1\n x, y = extended_euclid(a, b)\n a //= d\n b //= d\n x *= c // d\n y *= c // d\n if x < 0 :\n kay = int(math.ceil(x * -1.0 / b))\n x += b * kay\n y -= a * kay\n\n if y < 0:\n kay = int(math.ceil(y * -1.0 / a))\n x -= b * kay\n y += a * kay\n \n if x < 0 or y < 0:\n return x, y\n \n if x + y <= match:\n return x, y\n \n if b > a:\n kay = x // b\n x %= b\n y += a * kay\n else:\n kay = y // a\n y %= a\n x += b * kay \n \n if x + y <= match:\n return x, y\n return -1, -1\n\n\n wi, dr = LinearDiophantine(win, draw, point)\n if wi < 0 or dr < 0:\n print(-1)\n exit(0)\n print('{} {} {}'.format(wi, dr, match - wi - dr))\n"}, {"source_code": "def gcd(a, b): \n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a%b)\n\ndef exgcd(a, b, d):\n\tif b == 0:\n\t\td = a\n\t\tx = 1\n\t\ty = 0\n\t\treturn d, x, y\n\td, y, x = exgcd(b, a%b, d)\n\ty = y - x*(a//b)\n\treturn d, x, y\n\ndef Calc(x, y):\n\tif y == 1: \n\t\treturn x\n\treturn (x + y - 1) // y\n\ndef main():\n\tn, p, w, d = map(int, input().split(\" \"))\n\tg = gcd(d, w)\n\t\n#\tprint(g)\n\tif p % g > 0:\n#\t\tprint(\"-1\");\n\t\treturn\n\tp = p // g\n\tw = w // g\n\td = d // g\n\ttmp = 0\n\tx = 0\n\ty = 0\n\td, x, y = exgcd(w, d, tmp)\n\tx = x * p\n\ty = y * p\n#\tprint(str(x) + \" \" + str(y))\n\tif y < 0 :\n\t\tadd = Calc(-y, w) \n\t\ty += add * w\n\t\tx -= add * d\n\t\tif x < 0 or x + y > n:\n\t\t\tprint(\"-1\")\n\t\telse :\n\t\t\tprint(str(x) + \" \" + str(y) + \" \" + str(n - x - y))\n\t\treturn\n\t\n\tadd = y // w\n\ty -= add * w\n\tx += add * d\n\tif x < 0 or x + y > n :\n\t\tprint(\"-1\")\n\telse:\n\t\tprint(str(x) + \" \" + str(y) + \" \" + str(n - x - y))\n\treturn\n\nmain()"}, {"source_code": "n,p,w,d=list(map(int,input().split()))\nflag=0\nfor i in range(w+1):\n if (p-(i*d))%w==0:\n y=i\n x=(p-(i*d))//w\n z=n-(x+y)\n flag=1\n break\nif flag==0 or z<0:\n print(-1)\nelse:\n print(*[x,y,z])\n"}, {"source_code": "n,p,w,d=[int(i) for i in input().split(\" \")]\n\ndef exgcd(a,b):\n if b==0:\n return (1,0)\n tx,ty=exgcd(b,a%b)\n return (ty,tx-a//b*ty)\n\ndef gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\n\nx,y=exgcd(w,d)\ng=gcd(w,d)\nif p%g!=0:\n print(\"-1\")\n exit()\np//=g\nx*=p\ny*=p\nw/=g\nd/=g\nif x<0:\n tmp=(-x+d-1)//d\n x+=tmp*d\n y-=tmp*w\nif y<0:\n tmp=(-y+w-1)//w;\n y+=tmp*w\n x-=tmp*d\nif x<0:\n print(\"-1\")\n exit()\nif y>=w:\n tmp=y//w\n y-=tmp*w;\n x+=tmp*d;\nif x+y>n:\n print(\"-1\")\n exit()\nprint(int(x),int(y),int(n-x-y))"}, {"source_code": "\ndef exgcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, x, y = exgcd(b % a, a)\n return (g, y - (b // a) * x, x)\n\nif __name__ == \"__main__\":\n n, p, w, d = map(int, input().split())\n r, x, y = exgcd(w, d)\n if p % r:\n print(-1)\n else:\n x = p // r * x\n y = p // r * y\n d = d // r\n w = w // r\n y0 = ((y % w) + w) % w\n x0 = (p / r - y0 * d) // w\n if x0 >= 0 and y0 >= 0 and x0 + y0 <= n:\n print(\"%d %d %d\" % (x0, y0, n - x0 - y0))\n else:\n print(-1)\n"}, {"source_code": "a,b,c,d = map(int,input().split())\nif a*c<b:\n print(-1)\nelse:\n x = b//c\n while x>=0:\n y = (b-x*c)%d\n if y==0:\n print(x,y,a-x-y)\n exit(0)\n else:\n x-=1\n print(-1)"}, {"source_code": "import math\ndef gcd(a,b):\n if a==0:\n x0=0\n y0=1\n return b,x0,y0\n d=gcd(b%a,a)\n x0=d[2]-(b//a)*d[1]\n y0=d[1]\n return d[0],x0,y0\n\ns=list(map(int,input().split()));\nn=s[0]\np=s[1]\nw=s[2]\nd=s[3]\ndd=gcd(w,d)\nx0=dd[1]\ny0=dd[2]\ndd=dd[0]\nx0*=p//dd\ny0*=p//dd\ndy=w//dd\ndx=d//dd\nif p%dd !=0:\n print(-1)\n exit()\nelse:\n if y0<0:\n col=math.ceil(abs(y0)/dy)\n y0+=dy*col\n x0-=dx*col\n if x0<0:\n print(-1)\n exit()\n col=y0//dy\n y0-=dy*col\n x0+=dx*col\n if(x0+y0<=n):\n print(x0,y0,n-x0-y0)\n else:\n print(-1)\n"}, {"source_code": "def gcdExtended(a, b, x, y): \n\tif a == 0:\n\t\tx = 0\n\t\ty = 1\n\t\treturn b,x,y\n\tx1 = 0\n\ty1 = 0\n\tgcd,x1,y1 = gcdExtended(b%a, a, x1, y1) \n \n\tx = y1 - (b//a) * x1\n\ty = x1 \n\treturn gcd,x,y \n\ndef find_one(a,b,c,g):\n\tg,x0,y0 = gcdExtended(a,b,0,0)\n\t\n\tx0 *= c // g\n\ty0 *= c // g\n\tif a < 0:\n\t\tx0 = -x0\n\tif b < 0:\n\t\ty0 = -y0\n\treturn x0,y0\n\n\ndef gcd(a,b):\n\tif(b == 0):\n\t\treturn a\n\treturn gcd(b,a%b)\n \nn,p,w,d = map(int,input().split())\ng = gcd(w,d)\nif(p % g):\n\tprint(\"-1\")\nelse:\n\ta,b = find_one(w,d,p,g)\n\tp1 = w//g\n\tp2 = d//g\n\tl = -1e13\n\tr = 1e13\n\twhile(l <= r):\n\t\tmid = (l+r)//2\n\t\tx = a + mid*p2\n\t\ty = b - mid*p1\n\t\tif(x >= 0 and y >= 0 and ((x+y) <= n)):\n\t\t\tprint(int(x),int(y),int(n-x-y))\n\t\t\texit(0)\n\t\telif(x < 0):\n\t\t\tl = mid+1;\n\t\telif(y < 0):\n\t\t\tr = mid-1;\n\t\telif(x + y > n):\n\t\t\tl = mid+1;\nprint(\"-1\")\n"}, {"source_code": "#592_C\n\nimport math\n\ndef lcm(a, b):\n return (a * b) // math.gcd(a, b)\n\nln = [int(i) for i in input().split(\" \")]\n\nn = ln[0]\np = ln[1]\nw = ln[2]\nd = ln[3]\n\nlm = lcm(w, d)\npd = p % lm\ncd = p - pd\n\nx = cd // w\ny = 0\nf = False\nif pd == 0:\n f = True\n\nfor i in range(0, pd // w + 2):\n if (pd - (w * i)) % d == 0:\n x += i\n y = (pd - (w * i)) // d\n f = True\n break\n\nif f:\n z = n - x + y\n if z < 0:\n print(-1)\n else:\n print(x, y, z)\nelse:\n print(-1)\n"}, {"source_code": "import math\nimport sys\n\nn, p, w, d = list(map(int, input().split()))\n\ndef egcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = egcd(b % a, a)\n return g, x - (b // a) * y, y\n\ng = math.gcd(w, d)\n\nif(p % g != 0):\n print(-1)\n sys.exit(0)\n\n_, X, Y = egcd(w, d)\n\nm = p / g\nX *= m\nY *= m\n\nw2 = w / g\nd2 = d / g\n\na = d2\nb = X\nc = -w2\ne = Y\n\nlt = int(math.ceil(-(b / a)))\ngt = int(math.floor(-(e / c)))\n\nif(gt < lt):\n print(-1)\n sys.exit(0)\n\ntans = gt\nx = int(a * tans + b)\ny = int(c * tans + e)\nz = n - x - y\n\nif(z < 0):\n print(-1)\nelse:\n print(x, y, z)\n\n"}, {"source_code": "from __future__ import division, print_function\ndef main():\n n,p,w,d=map(int,input().split())\n wins=0\n def gcd(a,b):\n while b:\n a,b=b,a%b\n return a\n lcm=(w*d)//gcd(w,d)\n x=lcm//w\n while (wins*w)<=lcm and wins<n and (p-wins*w)%d!=0:\n wins+=1\n \n if (p-wins*w)%d==0:\n low=0\n high=(n-wins)//x\n \n while low<=high:\n mid=(high+low)//2\n a=mid*x+wins\n if p<a*w:\n high=mid-1\n continue\n if (a+(p-a*w)//d)>n:\n low=mid+1\n elif (a+(p-a*w)//d)<n:\n high=mid-1\n else :\n break\n draws=(p-a*w)//d\n if a+draws<=n:\n print(a,draws,n-a-draws)\n else :\n print(-1)\n else :\n print(-1)\n \n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()"}, {"source_code": "import math\n\n\ndef input_int():\n return list(map(int, input().split()))\n\n\ndef solve():\n [n, p, w, d] = input_int()\n lo = 0\n hi = n\n wins = hi\n while wins != lo:\n wins = (lo + hi) // 2\n win_points = wins * w\n points_left = p - win_points\n if points_left < 0:\n hi = wins\n continue\n draws = min(points_left // d, n - wins)\n leftover_points = points_left - draws * d\n losses = n - wins - draws\n if leftover_points == 0:\n print(wins, draws, losses)\n return\n if leftover_points > 0:\n lo = wins\n continue\n print(-1)\n return\n\n\nsolve()\n"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport heapq\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nimport sys\n\nsys.setrecursionlimit(10 ** 6) # max depth of recursion\nthreading.stack_size(2 ** 27) # new thread will get stack of such size\nfac_warm_up = False\nprintHeap = str()\nmemory_constrained = False\nP = 10 ** 9 + 7\n\n\nclass MergeFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n\n def find(self, a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n\n def merge(self, a, b):\n a = self.find(a)\n b = self.find(b)\n if a == b:\n return\n if self.size[a] < self.size[b]:\n a, b = b, a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n\n def set_size(self, a):\n return self.size[self.find(a)]\n\n def __len__(self):\n return self.num_sets\n\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\n\ndef prime_factors(n): # n**0.5 complex\n factors = dict()\n for i in range(2, math.ceil(math.sqrt(n)) + 1):\n while n % i == 0:\n if i in factors:\n factors[i] += 1\n else:\n factors[i] = 1\n n = n // i\n if n > 2:\n factors[n] = 1\n return (factors)\n\n\ndef all_factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef fibonacci_modP(n, MOD):\n if n < 2: return 1\n return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(\n fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD\n\n\ndef factorial_modP_Wilson(n, p):\n if (p <= n):\n return 0\n res = (p - 1)\n for i in range(n + 1, p):\n res = (res * cached_fn(InverseEuler, i, p)) % p\n return res\n\n\ndef binary(n, digits=20):\n b = bin(n)[2:]\n b = '0' * (digits - len(b)) + b\n return b\n\n\ndef is_prime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\n\ndef generate_primes(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n return prime\n\n\nfactorial_modP = []\n\n\ndef warm_up_fac(MOD):\n global factorial_modP, fac_warm_up\n if fac_warm_up: return\n factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]\n for i in range(2, fac_warm_up_size):\n factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD\n fac_warm_up = True\n\n\ndef InverseEuler(n, MOD):\n return pow(n, MOD - 2, MOD)\n\n\ndef nCr(n, r, MOD):\n global fac_warm_up, factorial_modP\n if not fac_warm_up:\n warm_up_fac(MOD)\n fac_warm_up = True\n return (factorial_modP[n] * (\n (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD\n\n\ndef get_int():\n return int(stdin.readline().strip())\n\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\n\nmemory = dict()\n\n\ndef clear_cache():\n global memory\n memory = dict()\n\n\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\ndef ncr(n, r):\n return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))\n\n\ndef binary_search(i, li):\n fn = lambda x: li[x] - x // i\n x = -1\n b = len(li)\n while b >= 1:\n while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like\n x += b\n b = b // 2\n return x\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\n\n\nTestCases = False\noptimise_for_recursion = True # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3\n\n\ndef main():\n n, p, w, d = get_tuple()\n gcd = math.gcd(w, d)\n if p%gcd ==0:\n p, w, d = p//gcd, w//gcd, d//gcd\n #print(p, w, d, gcd)\n for x in range(d):\n if (p - (x * w))%d == 0:\n y = (p - (x * w))//d\n #print(x, y)\n k = y//w\n y = y - k*w\n x = x + k*d\n if gcd*(x+y)<=n:\n print(x * gcd, y * gcd, n - ((x + y) * gcd))\n return\n break\n print(-1)\n\n\n\n\n# --------------------------------------------------------------------- END=\n\n\nif TestCases:\n for i in range(get_int()):\n main()\nelse:\n main() if not optimise_for_recursion else threading.Thread(target=main).start()\n"}, {"source_code": "from collections import defaultdict as dc\nfrom collections import deque as dq\nfrom bisect import bisect_left,bisect_right,insort_left\nimport sys\nimport math\n#define of c++ as inl=input()\nmod=10**9 +7\ndef bs(a,x):\n i=bisect_left(a,x)\n if i!=len(a) and a[i]==x:\n return i\n else:\n return -1\ndef inp():\n p=sys.stdin.readline()\n return p\ndef line():\n p=list(map(int,inp().split()))\n return p\nn,p,w,d=line()\nk=0\nfor y in range(w+1):\n l=p%w - ((y%w)*(d%w))%w\n if l%w==0:\n k=1\n x=(p-y*d)//w\n break\nif k==1 and x+y<=n:\n print(x,y,n-(x+y))\nelse:\n print(-1)\n"}, {"source_code": "\nn,p,w,d=map(int, input().split(' '))\nx=p//w\nfor y in range(0,w):\n if((y*d - p%w)%w==0):\n x-=((y*d-p%w)//w)\n break\nz=n-x-y\nif(x+y<=n and y<w and x>=0):\n print(\"%d %d %d\"%(x,y,z))\nelse:\n print(\"-1\")\n\n"}, {"source_code": "def gcd(a, b):\n if (a == 0):\n return (b, 0, 1)\n\n d, x1, y1 = gcd(b % a, a)\n\n return (d, y1 - (b // a) * x1, x1)\n\nSuperINF = 2e18\n\nn, p, w, d = map(int, input().split())\n\nNOD, x, y = gcd(d, w)\nif (p % NOD != 0):\n print(-1)\nelse:\n d //= NOD\n w //= NOD\n p //= NOD\n\n x, y = x * p, y * p\n\n ost = (x + SuperINF * w) % w\n\n x = ost\n\n y = (p * NOD - x * NOD * d) // ( NOD * w)\n \n if (y < 0):\n print(-1)\n elif (x + y > n):\n print(-1)\n else:\n ans1 = y\n ans2 = x\n ans3 = n - x - y\n print(ans1, ans2, ans3)"}, {"source_code": "def gcd(a, b):\n if a == 0:\n return (b, 0, 1)\n d, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (d, x, y)\n\nimport math\n\ndef fas(a, b, c):\n g, x, y = gcd(abs(a), abs(b))\n if c % g != 0:\n return (False, 0, 0)\n x *= c // g\n y *= c // g\n if (a < 0):\n x *= -1\n if (b < 0):\n y *= -1\n return (True, x, y, g)\n\nn, p, w, d = map(int, input().split())\n\ncan, x, y, g = fas(w, d, p)\n\nif can == False:\n print(-1)\n exit(0)\n\nw //= g\nd //= g\n\nif (y > x):\n cnt = y // w\n print(cnt)\n y -= cnt * w\n x += cnt * d\n\n#print(x, y)\n\nif (y < 0):\n cnt = -y // w\n if y % w != 0:\n cnt += 1\n cnt = -cnt\n #print(cnt)\n y -= cnt * w\n x += cnt * d\n\n#print(x, y)\n\nif (x + y <= n and x >= 0 and y >= 0):\n print(x, y, n - x - y)\nelse:\n print(-1)\n"}, {"source_code": "# Brute force 2: Keep subtracting it by the larger number\n\n# HCF\ndef hcf(a,b):\n\tif a<b:\n\t\treturn hcf(b,a)\n\twhile b!=0:\n\t\ta,b=b,a%b\n\treturn a\n\ninpu = (input()).split(\" \")\ninp = [int(x) for x in inpu]\nn,p,w,d = inp[0], inp[1], inp[2], inp[3]\n\nflag = 0\n\nif p == 0:\n\tprint(\"0 0 \"+str(n))\nelse:\n\tf = hcf(w,d)\n\tif f != 1:\n\t\trem = p%f\n\t\tif rem !=0:\n\t\t\tprint(-1)\n\t\t\tflag = 1\n\t\telse:\n\t\t\tp = p//f\n\t\t\td = d//f\n\t\t\tw = w//f\n\n\n\tif flag == 0:\n\t\tp = float(p)\n\t\tw = float(w)\n\t\tpp = p/w\n\t\tdd = d/w\n\t\tl1 = int(p//d)\n\t\t#print(pp,dd,l1)\n\t\tfor i in range(l1+1):\n\t\t\t#print(pp,dd,l1)\n\t\t\ta = pp-dd*i\n\t\t\t#print(a)\n\t\t\tif a == int(a) and (int(a)+i<=n):\n\t\t\t\tprint(str(int(a))+\" \"+str(i)+\" \"+str(int(n-a-i)))\n\t\t\t\tbreak\n\n\t\telse:\n\t\t\tprint(-1)\n\n\n\n"}, {"source_code": "def gcdExtended(a, b, x, y): \n\tif a == 0:\n\t\tx = 0\n\t\ty = 1\n\t\treturn b,x,y\n\tx1 = 0\n\ty1 = 0\n\tgcd,x1,y1 = gcdExtended(b%a, a, x1, y1) \n \n\tx = y1 - (b//a) * x1\n\ty = x1 \n\treturn gcd,x,y \n\ndef find_one(a,b,c,g):\n\tg,x0,y0 = gcdExtended(a,b,0,0)\n\t\n\tx0 *= c // g\n\ty0 *= c // g\n\tif a < 0:\n\t\tx0 = -x0\n\tif b < 0:\n\t\ty0 = -y0\n\treturn x0,y0\n\n\ndef gcd(a,b):\n\tif(b == 0):\n\t\treturn a\n\treturn gcd(b,a%b)\n \nn,p,w,d = map(int,input().split())\ng = gcd(w,d)\nif(p % g):\n\tprint(\"-1\")\nelse:\n\ta,b = find_one(w,d,p,g)\n\tp1 = w//g\n\tp2 = d//g\n\tl = -1e30\n\tr = 1e30\n\twhile(l <= r):\n\t\tmid = (l+r)//2\n\t\tx = a + mid*p2\n\t\ty = b - mid*p1\n\t\tif(x >= 0 and y >= 0 and ((x+y) <= n)):\n\t\t\tprint(int(x),int(y),int(n-x-y))\n\t\t\texit(0)\n\t\telif(x < 0):\n\t\t\tl = mid+1;\n\t\telif(y < 0):\n\t\t\tr = mid-1;\n\t\telif(x + y > n):\n\t\t\tl = mid+1;\nprint(\"-1\")\n"}, {"source_code": "def exgcd(a, b):\n if b == 0:\n return a, 1, 0\n d, x, y = exgcd(b, a % b)\n t = x\n x = y\n y = t - (a // b) * y\n return d, x, y\n\n\nn, p, w, d = map(int, input().split())\ng, x, y = exgcd(w, d)\nif p % g != 0:\n print(-1)\nelse:\n if x < 0:\n t = (-x + d - 1) // d\n x += t * d\n y -= t * w\n if y < 0:\n t = (-y + w - 1) // w\n x -= t * d\n y += t * w\n if x < 0 or y < 0:\n print(-1)\n else:\n x *= p // g\n y *= p // g\n t = y // w\n x += t * d\n y -= t * w\n if x + y <= n:\n print(x, y, n - x - y)\n else:\n print(-1)\n"}, {"source_code": "n,p,w,d=map(int,input().split())\ntemp=0\nif p==0:\n print('0','0',n);exit()\nfor x in range(p//w,p//w-1000,-1):\n if (p-x*w)%d==0 and x+(p-x*w)/d<=n:\n temp=1\n y=(p-x*w)//d;break\n elif (p-x*d)%w==0 and x+(p-x*d)/w<=n:\n temp=1;y=x;x=(p-y*d)//d;break\n\nprint(x,y,n-x-y) if temp==1 else print('-1')"}, {"source_code": "from collections import defaultdict as dc\nfrom collections import deque as dq\nfrom bisect import bisect_left,bisect_right,insort_left\nimport sys\nimport math\n#define of c++ as inl=input()\nmod=10**9 +7\ndef bs(a,x):\n i=bisect_left(a,x)\n if i!=len(a) and a[i]==x:\n return i\n else:\n return -1\ndef inp():\n p=sys.stdin.readline()\n return p\ndef line():\n p=list(map(int,inp().split()))\n return p\ndef value(w,d,x,y,p):\n l=x*w + y*d\n if l==p:\n return 1\n elif l<p:\n return 0\n else:\n return -1\ndef binary(x,w,d,n,p):\n #print('draw')\n l=0\n r=n-x\n while(l<=r):\n mid=(l+r)//2\n q=value(w,d,x,mid,p)\n if q==1:\n return 1,mid\n elif q==0:\n l=mid+1\n else:\n r=mid-1\n return value(w,d,x,mid,p),mid\nn,p,w,d=line()\nl=0\nr=n\nx='a'\nwhile(l<=r):\n mid=(l+r)//2\n #print(l,r)\n z,y=binary(mid,w,d,n,p)\n if z==1:\n x=mid\n break\n elif z==0:\n l=mid+1\n else:\n r=mid-1\nif x=='a':\n print(-1)\nelse:\n print(x,y,(n-x-y))"}, {"source_code": "import sys\nfrom fractions import gcd\nn, p, w, d = [int(item) for item in input().split()]\ndiv = gcd(w, d)\nif p % div != 0:\n print(-1)\nelse:\n p //= div\n w //= div\n d //= div\n ans = False\n reverse = False\n if w < d:\n w, d = d, w\n reverse = True\n for x in range(p // w, max(-1, p // w - 10**5), -1):\n if (p - x * w) % d != 0:\n continue\n y = (p - x * w) // d\n if y < 0 or x + y > n:\n continue\n ans = True\n break\n if ans:\n if reverse:\n print(x, y, n - x - y)\n else:\n print(y, x, n - x - y)\n else:\n print(-1)"}, {"source_code": "from sys import setrecursionlimit\nsetrecursionlimit(10**6)\ndef extgcd(a,b,x,y):\n if b==0:\n x[0]=1\n y[0]=0\n return a\n e=extgcd(b,a%b,y,x)\n y[0]-=(a//b)*x[0]\n return e\n\nn,p,w,d=map(int,input().split())\nfrom math import gcd\nif p%gcd(w,d)!=0:\n print(-1)\n exit()\nif p==0:\n print(0,0,n)\n exit()\nh=p//gcd(w,d)\nx,y=[0],[0]\nextgcd(w,d,x,y)\nx=x[0]*h\ny=y[0]*h\nif y>=0:\n g=y//w\n x+=g*d\n y-=g*w\nelse:\n g=-(y//w)\n x-=g*d\n y+=g*w\nif x<0 or x+y>n:\n print(-1)\nelse:\n print(x,y,n-x-y)"}, {"source_code": "list1=[int(x) for x in input().split(' ')]\nn=list1[1]\nc=n % list1[2]\nif c != 0 and list1[2] % list1[3] == 0:\n print(-1)\nelse:\n while c != 0:\n n-=list1[3]\n c=n % list1[2]\n a=int(n/list1[2])\n b=int((list1[1]-n)/list1[3])\n if (a+b > list1[0]) or (a < 0):\n print(-1)\n else:\n print(a,b,list1[0]-a-b,sep=' ')\n\n"}, {"source_code": "def gcd(a,b):\n\tglobal x,y\n\tif(a==0):\n\t\tx=0\n\t\ty=b\n\t\treturn b\n\telse:\n\t\tg=gcd(b%a,a)\n\t\tx2=y-(b//a)*x\n\t\ty=x\n\t\tx=x2\n\t\treturn g\n\ndef min(a,b):\n\tif(a>b):\n\t\treturn b\n\treturn a\n\ndef max(a,b):\n\tif(a<b):\n\t\treturn b\n\treturn a\n\nn,p,w,d=map(int,input().split())\nx=0\ny=0\ng=gcd(w,d)\nif(not p%g==0):\n\tprint(-1)\nelse:\n\tswap=False\n\tp=p//g\n\tw2=w\n\td2=d\n\tx=x*p\n\ty=y*p\n\tif(x>y):\n\t\ttemp=x\n\t\tx=y\n\t\ty=temp\n\t\ttemp=d2\n\t\td2=w2\n\t\tw2=temp\n\t\tswap=True\n\tlb=0\n\tub=100000000000000000000000000\n\tlb=max(lb,(-x+d2-1)//d2)\n\tub=min(ub,(n-x)//d2)\n\tub=min(ub,(n-x)//d2)\n\tlb=max(lb,(y-n+w2-1)//w2)\n\tif(d2-w2>0):\n\t\tub=min(ub, (n-x-y)//(d2-w2))\n\t\tlb=max(lb, (-x-y+d2-w2-1)//(d2-w2))\n\telif(w2-d2>0):\n\t\tub=min(ub, (x+y)//(w2-d2))\n\t\tlb=max(lb, (x+y-n+w2-d2-1)//(w2-d2))\n\tif(lb<=ub):\n\t\tv1=x+lb*d2\n\t\tv2= y-lb*w2\n\t\tv3=n-v1-v2\n\t\tif(v1>=0 and v2>=0 and v3>=0):\n\t\t\tif(not swap):\n\t\t\t\tprint(v1,v2,v3)\n\t\t\telse:\n\t\t\t\tprint(v2,v1,v3)\n\t\telse:\n\t\t\tprint(-1)\n\telse:\n\t\tprint(-1)"}, {"source_code": "n, p, w, d = [int(x) for x in input().split()]\n\npW = p // w\npD = 0\nwhile pW >= 0:\n pD = p - pW * w\n if pD % d == 0:\n break\n pW -= 1\n\nif pW < 0 or pW + pD > n:\n print(\"-1\")\nelse:\n print(\"%s %s %s\" % (pW, pD, (n - pW - pD)))"}, {"source_code": "def solve():\n n,p,w,d=map(int,input().split())\n x=p//w\n y=(p-x*w)/d\n if y!=int(y):\n print(-1)\n return\n else:\n y=int(y)\n z=n-x-y\n if z<0:\n print(-1)\n return\n print(x,y,z)\n\nsolve()\n"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport heapq\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nimport sys\n\nsys.setrecursionlimit(10 ** 6) # max depth of recursion\nthreading.stack_size(2 ** 27) # new thread will get stack of such size\nfac_warm_up = False\nprintHeap = str()\nmemory_constrained = False\nP = 10 ** 9 + 7\n\n\nclass MergeFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n\n def find(self, a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n\n def merge(self, a, b):\n a = self.find(a)\n b = self.find(b)\n if a == b:\n return\n if self.size[a] < self.size[b]:\n a, b = b, a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n\n def set_size(self, a):\n return self.size[self.find(a)]\n\n def __len__(self):\n return self.num_sets\n\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\n\ndef prime_factors(n): # n**0.5 complex\n factors = dict()\n for i in range(2, math.ceil(math.sqrt(n)) + 1):\n while n % i == 0:\n if i in factors:\n factors[i] += 1\n else:\n factors[i] = 1\n n = n // i\n if n > 2:\n factors[n] = 1\n return (factors)\n\n\ndef all_factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef fibonacci_modP(n, MOD):\n if n < 2: return 1\n return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(\n fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD\n\n\ndef factorial_modP_Wilson(n, p):\n if (p <= n):\n return 0\n res = (p - 1)\n for i in range(n + 1, p):\n res = (res * cached_fn(InverseEuler, i, p)) % p\n return res\n\n\ndef binary(n, digits=20):\n b = bin(n)[2:]\n b = '0' * (digits - len(b)) + b\n return b\n\n\ndef is_prime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\n\ndef generate_primes(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n return prime\n\n\nfactorial_modP = []\n\n\ndef warm_up_fac(MOD):\n global factorial_modP, fac_warm_up\n if fac_warm_up: return\n factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]\n for i in range(2, fac_warm_up_size):\n factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD\n fac_warm_up = True\n\n\ndef InverseEuler(n, MOD):\n return pow(n, MOD - 2, MOD)\n\n\ndef nCr(n, r, MOD):\n global fac_warm_up, factorial_modP\n if not fac_warm_up:\n warm_up_fac(MOD)\n fac_warm_up = True\n return (factorial_modP[n] * (\n (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD\n\n\ndef get_int():\n return int(stdin.readline().strip())\n\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\n\nmemory = dict()\n\n\ndef clear_cache():\n global memory\n memory = dict()\n\n\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\ndef ncr(n, r):\n return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))\n\n\ndef binary_search(i, li):\n fn = lambda x: li[x] - x // i\n x = -1\n b = len(li)\n while b >= 1:\n while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like\n x += b\n b = b // 2\n return x\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\n\n\nTestCases = False\noptimise_for_recursion = True # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3\n\n\ndef main():\n n, p, w, d = get_tuple()\n gcd = math.gcd(w, d)\n if p%gcd ==0:\n p, w, d = p//gcd, w//gcd, d//gcd\n #print(p, w, d, gcd)\n for x in range(d):\n if (p - (x * w))%d == 0:\n y = (p - (x * w))//d\n #print(x, y)\n k = y//w\n y = y - k*w\n x = x + k*d\n if gcd*(x+y)<=n:\n print(x * gcd, y * gcd, n - ((x + y) * gcd))\n return\n break\n print(-1)\n\n\n\n\n# --------------------------------------------------------------------- END=\n\n\nif TestCases:\n for i in range(get_int()):\n main()\nelse:\n main() if not optimise_for_recursion else threading.Thread(target=main).start()\n"}, {"source_code": "\nimport sys, bisect, heapq, math\nsys.setrecursionlimit(10**9+7)\ndef fi(): return int(sys.stdin.readline())\ndef fi2(): return map(int, sys.stdin.readline().split())\ndef fi3(): return sys.stdin.readline().rstrip()\ndef fo(*args):\n for s in args: sys.stdout.write(str(s)+' ')\n sys.stdout.write('\\n')\n## sys.stdout.flush()\ndef puts(*args):\n for s in args: sys.stdout.write(str(s))\nOUT = []\ndef bfo(*args):\n for s in args: OUT.append(str(s)+' ')\n OUT.append(' ')\ndef bputs(*args):\n for s in args: OUT.append(str(s)) \ndef flush():\n sto = ''.join(OUT); fo(sto)\n##\nalpha = 'abcdefghijklmnopqrstuvwxyz'; mod = 10**9+7; inf = int(2e18+5) ; nax = 101010\n##\n\ndef gcdExtended(a, b): \n if a == 0 : \n x = 0\n y = 1\n return (x, y)\n \n x1, y1 = gcdExtended(b%a, a) \n \n x = y1 - (b//a) * x1 \n y = x1 \n \n return (x, y)\n\n\nn, p, w, d = fi2()\n\ng = math.gcd(w, d)\nx, y = gcdExtended(w, d)\n\nif p%g != 0:\n print(-1)\n exit()\n\nx = x*p//g\ny = y*p//g\n\nassert(w*x + y*d == p)\n\nif y < 0:\n k = abs(y)//w + 5\n y += w*k\n x -= d*k\n\nk = y//w\ny -= w*k\nx += d*k\n\nassert(w*x + y*d == p)\n\nz = n - x - y\n\nif x >= 0 and y >= 0 and z >= 0:\n print(x, y, z)\nelse:\n print(-1)\n\n\n\n"}], "src_uid": "503116e144d19eb953954d99c5526a7d"} {"source_code": "from math import factorial\ndef choose(n, c):\n return factorial(n) / factorial(c) / factorial(n - c)\n\ntab = {}\ndef amount(y, n, t):\n if n == 1 and t == 0:\n return 1\n if n > 6 * t + 1 or t == 0 or n <= 0 or y >= 4:\n return 0\n if (y, n, t) not in tab:\n res = 0\n for top in xrange(y + 1, 5):\n for bottom in xrange(1, top):\n for i in xrange(top - y):\n for j in xrange(top - bottom):\n res += amount(bottom, n - (i + j + 3) + 1, t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)\n tab[(y, n, t)] = res\n return tab[(y, n, t)]\n\nn, t = map(int, raw_input().split())\nres = 0\nfor i in xrange(1, 4):\n res += amount(i, n, t)\nprint res\n", "positive_code": [{"source_code": "from itertools import permutations\n\nn, t = map(int, raw_input().split())\ndp = [[[0] * 4 for i in xrange(t * 2)] for j in xrange(n)]\n\nfor i in xrange(4):\n dp[1][0][i] = i\n\nfor i in xrange(1, n - 1):\n for j in xrange(t * 2):\n for p, q in permutations(xrange(4), 2):\n fr = dp[i][j][p]\n if j & 1:\n if p > q:\n dp[i + 1][j][q] += fr\n elif j + 1 < t * 2:\n dp[i + 1][j + 1][q] += fr\n else:\n if p < q:\n dp[i + 1][j][q] += fr\n elif j + 1 < t * 2:\n dp[i + 1][j + 1][q] += fr\n\nprint sum(dp[n - 1][t * 2 - 1][i] for i in xrange(4))\n"}, {"source_code": "import sys\n\npoints, peaks = (int(x) for x in sys.stdin.readline().split())\nmem = {}\n\ndef hump(n_points, n_peaks, n_humps, prev, slope, sol=\"\"):\n if n_peaks < 0 or n_humps < 0:\n return 0\n if n_points == 0 and n_peaks == 0 and n_humps == 0:\n #print(sol, n_peaks)\n return 1\n if n_points == 0:\n return 0\n if (n_points, n_peaks, n_humps, prev, slope) in mem:\n return mem[(n_points, n_peaks, n_humps, prev, slope)]\n\n r = 0\n for i in range(1, 5):\n if i == prev:\n continue\n new_n_points = n_points-1\n new_n_peaks = n_peaks-1 if slope > 0 and i < prev and n_points+2 <= points else n_peaks\n new_n_humps = n_humps-1 if slope < 0 and i > prev and n_points+2 <= points else n_humps\n new_prev, new_slope = i, -1 if i-prev < 0 else 1\n r += hump(new_n_points, new_n_peaks, new_n_humps, new_prev, new_slope)\n mem[(n_points, n_peaks, n_humps, prev, slope)] = r\n return r\n\nprint(hump(points, peaks, peaks-1, -1, 0))\n"}, {"source_code": "\nn, t = [int(x) for x in raw_input().strip().split()]\nc = []\nfor xn in xrange(n):\n c.append([])\n for xt in xrange(t + 1):\n c[xn].append([])\n for xh in xrange(4):\n c[xn][xt].append([0] * 2)\nfor xh in xrange(4):\n c[1][0][xh][1] = xh\nfor xn in xrange(2, n):\n for xt in xrange(t + 1):\n for xh in xrange(4):\n for p in xrange(xh):\n c[xn][xt][xh][1] += c[xn - 1][xt][p][0]\n c[xn][xt][xh][1] += c[xn - 1][xt][p][1]\n for p in xrange(xh + 1, 4):\n c[xn][xt][xh][0] += c[xn - 1][xt][p][0]\n if xt > 0: c[xn][xt][xh][0] += c[xn - 1][xt - 1][p][1]\ns = 0\nfor h in xrange(4):\n s += c[n - 1][t][h][0]\nprint s\n"}, {"source_code": "import sys\nfrom array import array # noqa: F401\n\n\ndef input():\n return sys.stdin.buffer.readline().decode('utf-8')\n\n\nn, t = map(int, input().split())\n\ndp = [[[0] * 5 for _ in range(2 * t + 1)] for _ in range(n)]\ndp[0][0] = [0] + [1] * 4\n\nfor i in range(n - 1):\n for j in range(min(2 * t, i + 1)):\n if (j & 1) == 0:\n for k in range(1, 4):\n for l in range(k + 1, 5):\n # //\n dp[i + 1][j][l] += dp[i][j][k]\n # /\\\n dp[i + 1][j + 1][l] += dp[i][j][k]\n else:\n for k in range(4, 1, -1):\n for l in range(k - 1, 0, -1):\n # \\\\\n dp[i + 1][j][l] += dp[i][j][k]\n # \\/\n dp[i + 1][j + 1][l] += dp[i][j][k]\n\nprint(sum(dp[-1][2 * t]))\n"}, {"source_code": "n,t = map(int,input().split())\ndp = [[[[0,0] for i in range(t+1)] for j in range(5)] for k in range(n+1)]\ndp[2][2][1][0]=1\ndp[2][3][1][0]=2\ndp[2][4][1][0]=3\nans = 0\nfor i in range(3,n+1):\n\t\tfor j in range(1,5):\n\t\t\tfor k in range(1,t+1):\n\t\t\t\tfor l in range(1,j):\n\t\t\t\t\tdp[i][j][k][0]+=dp[i-1][l][k][0]+dp[i-1][l][k-1][1]\n\t\t\t\tfor l in range(4,j,-1):\n\t\t\t\t\tdp[i][j][k][1]+=dp[i-1][l][k][1]+dp[i-1][l][k][0]\nfor i in range(1,5):\n\tans+=dp[n][i][t][1]\nprint(ans)"}, {"source_code": "__author__ = 'Darren'\n\n\ndef solve():\n\n def find_ways(t, n, h):\n if t == breaks and n == total:\n return 1\n if t > breaks or n == total:\n return 0\n if (t, n, h) not in dp:\n result = 0\n if t % 2 == 0:\n for i in range(h+1, 5):\n result += find_ways(t, n+1, i)\n for i in range(1, h):\n result += find_ways(t+1, n+1, i)\n else:\n for i in range(h+1, 5):\n result += find_ways(t+1, n+1, i)\n for i in range(1, h):\n result += find_ways(t, n+1, i)\n dp[(t, n, h)] = result\n return dp[(t, n, h)]\n\n total, humps = map(int, input().split())\n breaks = 2 * humps - 1\n dp = {}\n ans = 0\n for i in range(2, 5):\n ans += (i - 1) * find_ways(0, 2, i)\n print(ans)\n\n\nif __name__ == '__main__':\n solve()"}, {"source_code": "from math import factorial\ndef choose(n, c):\n return factorial(n) / factorial(c) / factorial(n - c)\n\ntab = {}\n#number of ways to draw t humps with n points, in which the 1st point's y-coordinate is y\ndef amount(y, n, t):\n #special case where t is 0 and n is 1\n #the reason we don't test for n == t == 0 is in the next recursion,\n #we start with bottom point, so it is repeated and there is at least 1 point\n if n == 1 and t == 0:\n return 1\n if n > 6 * t + 1 or t == 0 or n <= 0 or y >= 4:\n return 0\n if (y, n, t) not in tab:\n res = 0\n for top in xrange(y + 1, 5):\n for bottom in xrange(1, top):\n for i in xrange(top - y):\n for j in xrange(top - bottom):\n res += amount(bottom, n - (i + j + 3) + 1, t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)\n tab[(y, n, t)] = res\n return tab[(y, n, t)]\n\nn, t = map(int, raw_input().split())\nres = 0\nfor i in xrange(1, 4):\n res += amount(i, n, t)\nprint res\n"}], "negative_code": [{"source_code": "from math import factorial\ndef choose(n, c):\n return factorial(n) / factorial(c) / factorial(n - c)\n\ntab = {}\ndef amount(y, n, t):\n if n == t == 0:\n return 1\n if n > 6 * t + 1 or t == 0 or n < 0 or y >= 4:\n return 0\n if (y, n, t) not in tab:\n res = 0\n for top in xrange(y + 1, 5):\n for bottom in xrange(1, top):\n for i in xrange(top - y):\n for j in xrange(top - bottom):\n res += amount(bottom + 1, n - (i + j + 3), t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)\n tab[(y, n, t)] = res\n return tab[(y, n, t)]\n\nn, t = map(int, raw_input().split())\nres = 0\nfor i in xrange(1, 4):\n res += amount(i, n, t)\nprint res\n"}], "src_uid": "6d67559744583229455c5eafe68f7952"} {"source_code": "#!/usr/bin/python\nN,M=raw_input().split(' ')\nN=int(N)\nM=int(M)\na=map(int, raw_input().split())\na.append(0)\nans=0\ni=0\nwhile(i<N):\n#for i in xrange(N):\n\tpres=M\n\tj=i\n\twhile(pres>0 and j<N):\n\t\tif(a[j]<=pres):\n\t\t\tpres=pres-a[j]\n\t\telse:\n\t\t \tbreak\n\t\tj=j+1\n\tif(j<N):\n\t\ti=j\n\telse:\n\t \ti=N\n#\tprint i,j\n\tans+=1\nprint ans\n", "positive_code": [{"source_code": "n,k=map(int,input().split())\nlist1=list(map(int,input().split()))[:n]\nsum1=0\nc=0\nfor i in list1:\n sum1=sum1+i\n if sum1>k:\n sum1=i+0\n c=c+1\nprint(c+1) "}, {"source_code": "r=lambda:map(int, raw_input().split())\nn,k=r()\nt=r()\nb=0\nc=0\nfor e in t:\n if b + e > k:\n b = 0\n c+=1\n b+=e\nif b: c+=1\nprint c"}, {"source_code": "import sys\nn,m = [int(x) for x in sys.stdin.readline().split(' ')]\nS = [int(x) for x in sys.stdin.readline().split(' ')]\n\ni = 0\nnum_buses = 1;\nnum_in_bus = 0;\nwhile i < n:\n\tif S[i] + num_in_bus > m:\n\t\tnum_buses += 1\n\t\tnum_in_bus = 0\n\telse:\n\t\tnum_in_bus += S[i]\n\t\ti += 1\nprint num_buses\n"}, {"source_code": "from functools import reduce\nR = lambda: map(int, input().split())\nF = lambda x, y: (x[0] + 1, y[1]) if x[1] + y[1] > m else (x[0], x[1] + y[1])\nn, m = R()\ns = reduce(F, zip([0] * n, R()), (1, 0))\nprint(s[0])"}, {"source_code": "n, m = map(int,input().split())\ngroup = list(map(int,input().split()))\n\nb = 0\n\n\ntot = 0\nfor i in range(n):\n tot += group[i]\n if tot > m :\n b += 1\n tot = group[i]\n elif tot == m :\n b += 1\n tot = 0\n if i == n-1 and tot != 0 :\n b += 1\nprint(b)\n"}, {"source_code": "n, m = map(int,input().split())\na = list(map(int,input().split()))\nb = 0\nturn = 0\nfor i in range(n):\n turn += a[i]\n if turn > m :\n b += 1\n turn = a[i]\n elif turn == m:\n b += 1\n turn = 0\nif turn > 0:\n b += 1\nif n == 1:\n b = 1\n\nprint(b)\n"}, {"source_code": "n, m = map(int, input().split())\ngroups = [int(c) for c in input().split()]\n\nans = 1\ncap = m\n\nfor g in groups:\n if g <= cap:\n cap -= g\n else:\n ans += 1\n cap = m - g\n \nprint(ans)\n"}, {"source_code": "def turn(lst, m):\n count, i = 0, 0\n while i < len(lst):\n z = m\n while z >= lst[i]:\n z -= lst[i]\n i += 1\n if i >= len(lst):\n break\n count += 1\n return count\n\n\nN, M = [int(j) for j in input().split()]\nb = [int(x) for x in input().split()]\nprint(turn(b, M))\n"}, {"source_code": "n, m = map(int, input().split())\na = list(map(int, input().split()))\ni, ans = 0, 0\n\nwhile i < n:\n ans += 1\n cap = a[i]\n while i < n - 1 and cap + a[i+1] <= m:\n i += 1\n cap += a[i]\n i += 1\n\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nl = list(int(i) for i in input().split())\ns = 0\nres = 1\nfor i in l:\n if i + s <= m:\n s += i\n else:\n res += 1\n s = i\nprint(res)\n"}, {"source_code": "'''input\n3 4\n1 2 1\n'''\nn, m = map(int, input().split())\na = list(map(int, input().split()))\nt = 0\nwhile a:\n\ts = a.pop(0)\n\twhile a and s + a[0] <= m:\n\t\ts += a.pop(0)\n\tt += 1\nprint(t)\n\n"}, {"source_code": "'''\nID: essi\nLANG: PYTHON3\nTASK: self-contest.py\n'''\nn, m = map(int,input().split())\na = list(map(int,input().split()))\nres = 1\nsu = 0\nfor i in range(n):\n su+= a[i]\n if su > m:\n res+=1\n su = a[i]\nprint(res)"}, {"source_code": "#!/usr/bin/python3\nfrom sys import exit\nn,t = input().split()\nn = int(n)\nt = int(t)\ntest_case = input()\na = []\n#matrix = [ 0 for x in range(101)]\nfor w in test_case.split():\n r = int(w)\n a.append(r)\n#a.sort()\nans = 0\nk = 0\nfor i in range (n):\n if( (k + a[i]) > t):\n ans += 1\n k = a[i]\n else:\n k += a[i]\nprint(ans+1)\nexit()\n\n"}, {"source_code": "n, m = map(int, input().split())\na = [int(x) for x in input().split()]\nout = 0\n\nwhile (a != []):\n c, a2 = m, a.copy()\n for i in a2:\n if (i <= c):\n c -= i\n a.remove(i)\n else:\n break\n out += 1\nprint(out)\n"}, {"source_code": "import sys\nimport math\n\nn, m = [int(x) for x in (sys.stdin.readline()).split()]\nai = [int(x) for x in (sys.stdin.readline()).split()]\n\nf = 0\nresult = 0\nfor c in ai:\n if(f + c < m):\n f += c\n elif(f + c == m):\n result += 1\n f = 0\n else:\n f = c\n result += 1\n \nif(f > 0):\n result += 1\n \nprint(result)"}, {"source_code": "def main():\n l = input()\n parts = l.split(\" \")\n n = int(parts[0])\n m = int(parts[1])\n arr = []\n l = input()\n for a in l.split(\" \"):\n arr.append(int(a))\n i = 0\n res = 0\n while True:\n s = 0\n while i < n and s+arr[i]<= m:\n s += arr[i]\n i += 1\n res += 1\n if i == n:\n break\n print(str(res))\nif __name__ == '__main__':\n main()\n"}, {"source_code": "t = input().split()\nn = int(t[0])\nm = int(t[1])\ndel t\nt = [int(x) for x in input().split()]\n'''\nslon = t.count(m)\nif slon != 0:\n t.remove(m)\nn = len(t)\n'''\nslon = 0\ntemp = 0\nfor i in range(n):\n temp = t[i]\n t[i] = 0\n for j in range(n):\n if temp + t[j] <= m:\n temp += t[j]\n t[j] = 0\n else:\n break\n if temp != 0:\n slon += 1\n #print(t)\nprint(slon)\n'''\n if temp[i] > m:\n temp[i + 1] += (temp[i] - m)\n slon += 1\n elif temp[i] < m:\n temp[i + 1] += temp[i]\n else:\n slon += 1\nslon += (temp[n - 1] // m) + (0 if temp[n - 1] % m == 0 else 1)\nprint(slon)\n '''\n"}, {"source_code": "a,b=map(int,input().split())\nc=list(map(int,input().split()))\nd=0\ne=b\nfor i in c:\n if e>=i:\n e-=i\n else:\n e=b-i\n d+=1\nprint(d+1)"}, {"source_code": "import sys\nsize, maxPassangers = map(int, input().split())\n\narray = list(map(int, input().split()))\ncounter = 0\n\nif size == 1:\n print(\"1\")\n sys.exit()\n\nbuffer = 0\nfor i in range(size):\n if buffer + array[i] <= maxPassangers:\n buffer += array[i]\n else:\n buffer = array[i]\n counter += 1\n\n\nprint(counter+1)"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\ncount=0\nsum=0\ni=0\nwhile(i<n):\n sum=sum+l[i]\n if(sum==m):\n sum=0\n count=count+1\n i=i+1\n elif(sum>m):\n sum=0\n count=count+1\n else:\n i=i+1\nif(sum<m and sum>0):\n count=count+1\n i=i+1\nprint(count)"}, {"source_code": "l=list(map(int,input().split(\" \")))\nn=l[0]\nm=l[1]\nl=list(map(int,input().split(\" \")))\ni=0\ns=0\ncnt=0\nif(n==1 and l[0]<=m):\n print(\"1\")\nelse:\n while(i<n):\n s=s+l[i]\n #print(i,s,cnt)\n if(s<m):\n i+=1\n elif(s==m):\n s=0\n cnt+=1\n i+=1\n else:\n s=0\n cnt+=1\n if(s>0):\n cnt+=1\n print(cnt)"}, {"source_code": "n,m = map(int, input().split())\nl = list(map(int, input().split()))\n\npeople = 0\nbuses = 1\nfor i in range(n):\n if people + l[i] <= m:\n people += l[i]\n else:\n buses += 1\n people = l[i]\nprint(buses) "}, {"source_code": "a=0\ni=0\nb=0\nz=list(map(int,input().split()))\nx=list(map(int,input().split()))\nwhile 1 :\n a+=x[i]\n # print('a=',a)\n if a>z[1]:\n b+=1\n # print('b=',b)\n a=0\n else:\n i+=1\n \n # print('i=',i)\n if i==len(x): \n break\nprint(b+1)\n \n "}, {"source_code": "import math\nn, m = map(int, input().split())\n\na = list(map(int, input().split()))\n\nres = 1\npep = 0\n\nfor i in range(n):\n if pep + a[i] <= m:\n pep += a[i]\n else:\n res += 1\n pep = a[i]\n\nprint(res)"}, {"source_code": "n, m = map(int, input().split())\na = [int(i) for i in input().split()]\ncnt = 0\ns = 0\nfor i in range(n):\n s += a[i]\n if s > m:\n cnt += 1\n s = a[i]\nprint(cnt + 1)"}, {"source_code": "from sys import stdin\nn, m = map(int, stdin.readline().split())\na = list(map(int, input().split()))\ns = k = 0\nfor i in a:\n k += i\n if k > m: s, k = s + 1, i\nprint(s + int(k > 0))"}, {"source_code": "n,m=map(int,input().split())\na=list(map(int,input().split()))\n\nfirst=0;\nlast=n-1;\nres=0;\nwhile (first<=last):\n k=m;\n while (k>=a[first] and first<=last):\n k-=a[first];\n first+=1;\n if (first>last): break;\n res+=1;\n\nprint(res)\n"}, {"source_code": "x=input()\nx=x.split()\ny=input()\ny=y.split()\nbus=0\ni=0\nempty=int(x[1])\nfor i in range(int(x[0])):\n if int(y[i])== int(x[1]):\n bus=bus+1\n if empty<int(x[1]):\n empty=int(x[1])\n bus=bus+1 \n elif int(y[i])< empty :\n empty=empty-int(y[i])\n if i==int(x[0])-1:\n bus=bus+1 \n elif int(y[i])==empty:\n empty=int(x[1])\n bus=bus+1 \n elif int(y[i])>empty:\n bus=bus+1\n empty=int(x[1])\n if int(y[i])== empty :\n \n bus=bus+1\n elif int(y[i])< empty and i==int(x[0])-1:\n bus=bus+1\n else:\n empty=empty-int(y[i]) \nprint(bus) \n"}, {"source_code": "n,m = map(int,raw_input().split())\nA = map(int,raw_input().split())\nans = 0;\nr = 0;\nfor x in A:\n if r < x:\n r = m - x;\n ans += 1;\n else:\n r -= x;\n\nprint ans;"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nSpyder Editor\n\nThis is a temporary script file.\n\"\"\"\n#import sys\n\n#def pow_mod(base, exp):\n# if exp == 0:\n# return 1\n# elif exp == 1:\n# return base\n# elif (exp & 1) != 0:\n# return base * pow_mod(base * base, exp // 2)\n# else:\n# return pow_mod(base * base, exp // 2)\n \n \nn, m = map(int, input().split()) \na = ([int(z) for z in input().split()])\no = 0\ni = 0\ns = 0\nwhile(i<n):\n s = s + a[i]\n if s>m:\n s = 0\n o = o + 1\n else:\n if i==n-1:\n o = o + 1\n i = i + 1\nprint(o)\n \n \n#sys.stdout.flush()\n#print ('', flush=True)"}, {"source_code": "n,m = list(map(int, input().split(\" \")))\nx = list(map(int, input().split(\" \")))\ncount,a=0,0\nfor i in range(n):\n if x[i]+a<=m:\n a+=x[i]\n else:\n count+=1\n a=x[i]\nprint(count+1)"}, {"source_code": "import math\nimport itertools\nimport collections\n\ndef getdict(n):\n d = {}\n if type(n) is list or type(n) is str:\n for i in n:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n else:\n for i in range(n):\n t = ii()\n if t in d:\n d[t] += 1\n else:\n d[t] = 1\n return d\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a*b) // math.gcd(a, b)\ndef wr(arr): return ' '.join(map(str, arr))\ndef revn(n): return int(str(n)[::-1])\ndef prime(n):\n if n == 2:\n return True\n if n % 2 == 0 or n <= 1:\n return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0:\n return False\n return True\n\nn, m = mi()\na = li()\ni = ans = 0\nwhile i < n:\n t = 0\n while t <= m and i < n:\n if t + a[i] <= m:\n t += a[i]\n i += 1\n else:\n break\n ans += 1\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nl=[int(i) for i in input().split()]\ni=0 \nsm=0 \ncnt=1 \nwhile i<n:\n sm+=l[i]\n if sm>m:\n cnt+=1 \n sm=l[i]\n i+=1 \nprint(cnt)"}, {"source_code": "n,m=map(int,input().split())\nL=list(map(int,input().split()))\ncnt=0\ncur=m\nfor a in L:\n if cur>=a:\n cur-=a\n else:\n cur=m-a\n cnt+=1\nprint(cnt+1)\n\n\n\n\n'''\nn, m = map(int, input().split())\na = [int(i) for i in input().split()]\ncnt = 0\ns = 0\nfor i in range(n):\n s += a[i]\n if s > m:\n cnt += 1\n s = a[i]\nprint(cnt + 1)\n'''"}, {"source_code": "n , m = map(int, input().split())\nmylist = list(map(int,input().split()))\nindex = 0\ncount = 1\nbus_stop = m\nwhile index < n :\n if bus_stop - mylist[index] >= 0:\n bus_stop -= mylist[index]\n index += 1\n else:\n bus_stop = m\n count += 1\nprint(count)"}, {"source_code": "\n\n\nn, m = map(int,input().split())\n\n\nu = list(map(int,input().split()))\nsum=0\nf=0\nfor k in range(n):\n if sum+u[k]<=m:\n sum+=u[k]\n else:\n f+=1\n sum=u[k]\nif sum>0:\n f+=1\n\nprint(f)\n"}, {"source_code": "counter = 1\nsumm = 0\nteamnum, bushold = map(int, input().split())\nteamlist = [int(h) for h in input().split()]\n# print(ceil(sum(teamlist)/bushold))\nfor i in teamlist:\n if summ+i > bushold:\n counter += 1\n summ = 0\n summ += i\nprint(counter)\n"}, {"source_code": "# 435A\n# Queue on Bus Stop\n\ncapacity = int(raw_input().split()[1])\nqueues = list(raw_input().split())\n\nfor i in range(len(queues)):\n queues[i] = int(queues[i])\n\nresult = 0\nwhile True:\n start = 0\n currentCapacity = capacity\n for i in range(start, len(queues)):\n if currentCapacity >= queues[i]:\n start = i + 1\n currentCapacity = currentCapacity - queues[i]\n queues[i] = 0\n else:\n break\n result = result + 1\n if start >= len(queues):\n break\nprint str(result)\n"}, {"source_code": "import itertools\nimport math\nfrom collections import defaultdict\n\ndef input_ints():\n return list(map(int, input().split()))\n\ndef solve():\n n, m = input_ints()\n ans = 0\n s = 0\n for x in input_ints():\n if s + x > m:\n ans += 1\n s = 0\n s += x\n ans += 1\n print(ans)\n\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "n,m=map(int,input().split())\nL=list(map(int,input().split()))\ncnt=0\ncur=m\nfor a in L:\n if cur>=a:\n cur-=a\n else:\n cur=m-a\n cnt+=1\nprint(cnt+1)\n"}, {"source_code": "a = [int(j) for j in input().split()]\nb = [int(j) for j in input().split()]\nc = 0\nwhile True:\n if b == []:\n break\n else:\n d = 0\n while True:\n if b == []:\n c += 1\n break\n elif d + b[0] <= a[1]:\n d = d +b[0]\n del b[0]\n else:\n c += 1\n break\nprint(c)"}, {"source_code": "#!/usr/bin/python2.7\nfrom sys import stdin\n\nn, m = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\ndef f(i, r):\n if i == n:\n return int(r<m)\n elif r == 0:\n return 1+f(i, m)\n elif a[i] <= r:\n return f(i+1, r-a[i])\n else:\n return 1+f(i, m)\n\nprint f(0, m)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\nif __name__ == '__main__':\n n, m = map(int, raw_input().split())\n aa = map(int, raw_input().split())\n\n count = 1\n in_bus = 0\n for a in aa:\n if in_bus + a <= m:\n in_bus += a\n else:\n count += 1\n in_bus = a\n result = count\n\n print(str(result))\n"}, {"source_code": "#n, k = map(int, input().split(\" \"))\n#LA = [int(x) for x in input().split()]\n\nn, m = map(int, input().split(\" \"))\nL = [int(x) for x in input().split()]\nct = 1\ns = 0\nfor x in L : \n if (s + x > m) : \n s = x\n ct+=1\n else : s += x \nprint(ct)\n"}, {"source_code": "n, m = map(int, raw_input().split())\ng = map(int, raw_input().split())\nans = 1\nb = 0\nfor i in g:\n if b + i > m:\n ans += 1\n b = i\n else:\n b += i\nprint ans"}, {"source_code": "n,m=map(int,raw_input().split())\nl=[int(x) for x in raw_input().split()]\nans=1\nwhile n:\n chk=0\n while n:\n if chk+l[0]<=m:\n chk+=l[0]\n l.pop(0)\n n-=1\n else:\n ans+=1\n break\n\nprint ans"}, {"source_code": "str = raw_input()\nstr = str.split()\nn = int(str[0])\nm = int(str[1])\nstr = raw_input()\nstr = str.split()\nA = []\nfor i in str:\n\ttemp = int(i)\n\tA.append(temp)\ncount = 0\nfinalcount = 0\nl = int(len(A))\nfor i in range(0,l-1):\n\tcount = count + A[i]\n\t#print \"count = \",count\n\t#print \"count + A[i+1] = \",count+A[i+1]\n\t\n\tfinalcount = finalcount + count/m\n\tcount = count%m\n\ttemp = count + A[i+1]\n\t#print \"temp\",temp\n\t#print \"m = \",m\n\tif (temp > m) and (count != 0):\n\t\tcount = 0\n\t\t#print \"yo\"\n\t\tfinalcount = finalcount + 1\ncount = count + A[l-1]\n#print \"count = \",count \nfinalcount = finalcount + count/m\nif count%m != 0:\n\tfinalcount = finalcount + 1\nprint finalcount \t\t"}, {"source_code": "n,m = map(int, raw_input().split())\npeo = map(int, raw_input().split())\nans = 0\ni = 0\nwhile i < n:\n ans += 1\n temp = m\n while temp > 0:\n if peo[i] <= temp:\n temp -= peo[i]\n i += 1\n if i >= n:\n break\n else:\n break\nprint ans\n"}, {"source_code": "n, m = raw_input().split()\nn, m = int(n), int(m)\narrayQueue = map(int, raw_input().split())\n\nbusAmount = 1\namGr = 0\nj = 0\nfreeSeats = 0\n\nfor i in range(n):\n if m >= freeSeats + arrayQueue[i]:\n freeSeats += arrayQueue[i]\n else:\n busAmount += 1\n freeSeats = 0\n freeSeats += arrayQueue[i]\nprint(busAmount)"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\ndef some_func():\n \"\"\"\n \"\"\"\n n, m= map(int, sys.stdin.readline().split())\n n_list = map(int, sys.stdin.readline().split())\n\n count=0\n temp = 0\n for v in n_list:\n if temp+v>m:\n temp =v\n count+=1\n else:\n temp+=v\n if temp:\n count+=1\n print count\n\n\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n"}, {"source_code": "n,m=map(int,raw_input().split())\na=map(int,raw_input().split())\ni=0\nb=1\nc=m\nwhile i<n: \n if a[i]<=c:\n c-=a[i]\n i+=1\n else: \n b+=1\n c=m\nprint b\n"}, {"source_code": "def main():\n\tn,m=map(int, raw_input().split())\n\tarr=map(int, raw_input().split())\n\tans=1\n\tcur=m\n\tfor i in xrange(0,n):\n\t\tif arr[i]<=cur:\n\t\t\tcur-=arr[i]\n\t\telse:\n\t\t\tans+=1\n\t\t\tcur=m-arr[i]\n\tprint ans\n\t\nmain()"}, {"source_code": "n,m = map(int,raw_input().split())\na = map(int,raw_input().split())\ni = 0\ncount = 1\ncur = 0\nwhile sum(a) > 0:\n if cur + a[i] <= m:\n cur += a[i]\n a[i] = 0\n i = (i+1)%n\n else:\n count += 1\n cur = 0\nprint count"}, {"source_code": "R=lambda:map(int,raw_input().split())\nn,m=R()\nA=R()\ncnt,s=1,0\nfor a in A:\n if s+a<=m:\n s+=a\n else:\n cnt+=1\n s=a\nprint cnt"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\ncount=0\nsum=0\ni=0\nwhile(i<n):\n if sum+l[i]<=m:\n sum=sum+l[i]\n i=i+1\n else:\n count=count+1\n sum=0\nprint(count+1)\n \n\n\n\n\n \n \n \n \n \n \n \n "}, {"source_code": "n, m = map(int, raw_input().split())\na = map(int, raw_input().split())\n\ncount = 1\nsits_available = m\n\nfor x in a:\n if x <= sits_available:\n sits_available -= x\n else:\n count += 1\n sits_available = m - x\n\nprint count"}, {"source_code": "n, m = map(int, raw_input().split())\na = map(int, raw_input().split())\n\ni = 0\nbus = 0\nwhile i < len(a):\n cur = 0\n bus += 1\n while cur < m and i < len(a):\n if cur + a[i] <= m:\n cur += a[i]\n i += 1\n else:\n break\n\nprint bus\n"}, {"source_code": "R = lambda:map(int, raw_input().split())\n(n, m), a = R(), R()\ni = ans = 0\nwhile 1:\n\tsum = 0\n\twhile i < n and sum + a[i] <= m: sum += a[i]; i += 1\n\tans += 1\n\tif i == n: break\nprint ans\n\t\t\t\t\n"}, {"source_code": "from collections import deque\nn, m = map(int, raw_input().split())\na, buses, space = deque(map(int, raw_input().split())), 1, m\nwhile a:\n\tif a[0] > space:\n\t\tspace = m - a.popleft()\n\t\tbuses += 1\n\telse:\n\t\tspace -= a.popleft()\nprint buses"}, {"source_code": "n, m = map(int, raw_input().split())\na = map(int, raw_input().split())\n\nq = 0\ns = m\nfor i in range(n):\n if s+a[i]>m:\n s = 0\n q += 1\n s += a[i]\nprint q\n\n"}, {"source_code": "n,m=map(int,raw_input().split())\na=map(int,raw_input().split())\n\nco = 0\ncol = 0\nfor i in a:\n if co + i <= m:\n co = co+i\n else:\n co = i\n col += 1\n\nif col == 0:\n col = 1\nelif co != 0:\n col += 1\n\nprint col"}, {"source_code": "n, m = map(int,raw_input().split())\na = map(int,raw_input().split())\nans = 0\nwhile len(a)!=0:\n\td = m\n\tans = ans+1\n\twhile(len(a)!=0 and d>=a[0]):\n\t\td = d-a[0]\n\t\ta.pop(0)\nprint ans\n"}, {"source_code": "[n, m] = map(int, raw_input('').split(' '))\ngroups = map(int, raw_input('').split(' '))\n\nnum_buses = 0\ngroups_completed = 0\nn = len(groups)\nwhile groups_completed < n:\n remaining_capacity = m\n while groups_completed < n and groups[groups_completed] <= remaining_capacity:\n remaining_capacity -= groups[groups_completed]\n groups_completed += 1\n num_buses += 1\nprint num_buses\n"}, {"source_code": "from __future__ import division\nnum_groups,m = map(int,raw_input().split())\ngroups = map(int,raw_input().split());\ntotal_ppl = sum(groups)\nnum_ppl=0;\nremain = 0;\nnum_bus = 0;\ni=0\nwhile(num_ppl < total_ppl):\n # if i < num_groups:\n if remain == m:\n num_bus += 1\n num_ppl += m;\n remain = 0\n continue;\n else:\n if i < num_groups:\n if(remain+groups[i]) == m:\n num_bus += 1;\n remain = 0;\n num_ppl += m;\n elif(remain + groups[i]) < m:\n remain += groups[i]\n elif(remain + groups[i]) > m:\n num_bus += 1;\n num_ppl += remain;\n remain = groups[i];\n else:\n a = remain/m;\n if round(a) >= a:\n num_ppl += remain\n num_bus += int(round(a))\n else:\n num_bus += int(round(a) +1)\n num_ppl += remain\n i += 1;\nprint num_bus\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n,m = map(int, raw_input().split())\na = map(int, raw_input().split())\ns = 0\ncnt = 0\ni=0\nwhile i<n:\n s += a[i]\n if s>m:\n i-=1\n s=0\n cnt+=1\n i+=1\nprint cnt+1"}, {"source_code": "def Queue():\n n,m = map(int,raw_input().split())\n groups = list(map(int,raw_input().split()))\n\n buses = 0\n\n cap = 0\n\n for i in groups:\n if cap + i <= m:\n cap += i\n else:\n buses += 1\n cap = i\n \n if cap <= m:\n buses += 1\n print buses\n\nQueue()"}, {"source_code": "n,m = map(int,raw_input().split(' '))\na = map(int,raw_input().split(' '))\nans = 1\nload = 0\n\nfor g in a:\n load += g\n if load > m:\n ans += 1\n load = g\n\nprint(ans)"}, {"source_code": "import math\n\nif __name__ == '__main__':\n\n n,m = map(int,raw_input().split())\n a = map(int,raw_input().split())\n\n i = 0\n buses = 0\n while(i<n):\n free = m - a[i]\n i+=1\n buses+=1\n while(i < n and a[i] <= free):\n free = free - a[i]\n i+=1\n\n print buses"}, {"source_code": "r = 1\nn, m = map(int, raw_input().split())\narr = map(int, raw_input().split())\nz = m\nfor i in arr:\n if z < i:\n z = m - i\n r += 1\n else:\n z -= i\nprint r\n"}, {"source_code": "n, m = map(int, raw_input().split())\na = list(map(int, raw_input().split()))\nv, c = 0, 0\nfor i in a:\n if v + i <= m: v += i\n else:\n v = i\n c += 1 \nprint c + 1"}, {"source_code": "from collections import deque\n\ninp = map(int, raw_input().split())\n\nbusline = map(int, raw_input().split())\n\ncap = inp[1]\n\nqueue = deque(busline)\n\nbus = 0\n\nwhile (len(queue) > 0):\n x = cap\n while (len(queue) > 0 and x >= queue[0]):\n x = x - queue.popleft()\n bus = bus + 1\n\nprint bus\n"}, {"source_code": "\nif __name__== \"__main__\":\n n,m=map(int,raw_input().split())\n a=map(int,raw_input().split())\n c=t=s=0\n while t<n:\n s+=a[t]\n if s>m:\n c+=1\n s=0\n elif s==m:\n c+=1\n t+=1\n s=0\n else:\n t+=1\n if s!=0:\n c+=1\n print c"}, {"source_code": "fun=lambda:map(int,raw_input().split())\nn,m=fun()\ndata=fun()\nans=0\ntmp=m\ni=0\nwhile i < n:\n if data[i]<=tmp:\n tmp-=data[i]\n i+=1\n else:\n tmp=m\n ans+=1\nif tmp != m:\n ans+=1\nprint ans\n"}, {"source_code": "#!/usr/bin/python\ndef ia():\n line = raw_input()\n line = line.split()\n return map(int, line)\n\nn, m = ia()\na = ia()\n\nans = 0\ni = 0\nwhile True:\n if i>=n: break\n b = m\n ans = ans + 1\n while True:\n if i>=n : break\n if a[i]>b: break\n b = b - a[i]\n i = i + 1\n \nprint ans\n"}, {"source_code": "I=lambda:map(int,raw_input().split())\nn,m=I();a=I();k=b=0\nfor i in range(n):\n k+=[0,1][b+a[i]>m]\n b=[b+a[i],a[i]][b+a[i]>m]\nprint k+1"}, {"source_code": "N, cap = map(int, raw_input().split())\na = map(int, raw_input().split())\nans, cur = 0, 0\nfor i in a:\n if cur + i > cap:\n cur = i\n ans += 1\n else: cur += i\nprint ans + 1"}, {"source_code": "def get_ints():\n return map(int, raw_input().strip().split(' '))\n\nn, m = get_ints()\na = get_ints()\n\nans = 1\nrem = m\nfor i in xrange(n):\n if rem < a[i]:\n rem = m\n ans += 1\n rem -= a[i]\nprint ans\n \n"}, {"source_code": "n, m = map(int, raw_input().split())\na = map(int, raw_input().split())\ni = 0\nans = 0\ns = 0\nwhile i<n:\n\ts += a[i]\n\tif s> m:\n\t\ts = a[i]\n\t\tans += 1\n\ti += 1\nprint ans + 1"}, {"source_code": "n, m = map(int, raw_input().split())\ngroups = map(int, raw_input().split())\n\nres = 1\ncur = 0\nfor group in groups:\n if (cur + group) <= m:\n cur += group\n else:\n res += 1\n cur = group\n\nprint res"}, {"source_code": "n,m = map(int,raw_input().split())\ng = map(int,raw_input().split())\nbus = 0\nhold = 0\nfor i in g:\n\tif hold>=int(i):\n\t\thold-=int(i)\n\telse:\n\t\tbus = bus + 1\n\t\thold = m-int(i)\nprint bus\n"}, {"source_code": "from sys import stdin, stdout\nimport math\n\nn, m = map(int, stdin.readline().split())\na = map(int, stdin.readline().split())\nres = 0\nwhile(len(a)>0):\n k = 0\n while(len(a)>0 and a[0]+k<=m):\n k += a[0]\n a.remove(a[0])\n res += 1\nprint(res)\n"}, {"source_code": "#Author: squiggly_lines\n#Date: 31/05/2014\n#Problem: 435A\n\ndef main():\n n,m = map(int, raw_input().split())\n c = map(int, raw_input().split())\n bus = 0\n count = 0\n \n for i in xrange(n):\n if c[i] + bus <= m:\n bus += c[i]\n else:\n count += 1\n bus = c[i]\n \n print count+1\n \n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "w=list(map(int,input().split()))\nx=w[0]\ny=w[1]\nl=list(map(int,input().split()))\ni = 0\nsum = 1\ninc=0\nwhile(i<x):\n if (inc+l[i]>y):\n sum +=1\n inc=l[i]\n else:\n inc+=l[i]\n i+=1 \nprint(sum)\n \n"}], "negative_code": [{"source_code": "n, m = raw_input().split()\nn, m = int(n), int(m)\narrayQueue = map(int, raw_input().split())\n\nbusAmount = 0\namGr = 0\nj = 0\n\n# It is super cool structure. Codename: Bydlocode007\nfor i in range(n):\n #print(i, 'beg', j)\n if i < j:\n continue\n freeSeats = 0\n j = 0\n free = True\n while free:\n if i + j < len(arrayQueue):\n # print('bord ok')\n if m >= freeSeats + arrayQueue[i + j]:\n #print('seats ok')\n if i + j != len(arrayQueue) - 1:\n #print('not last')\n freeSeats += arrayQueue[i + j]\n else:\n print(busAmount + 1)\n exit(0)\n elif m == arrayQueue[i + j]:\n busAmount += 1\n #print('+j')\n free = False\n j -= 1\n break\n else:\n busAmount += 1\n #print('+')\n free = False\n break\n else:\n busAmount += 1\n #print('+')\n free = False\n break\n j += 1\n #print(i, ' end ')\n\nprint(busAmount)"}, {"source_code": "#!/usr/bin/python\nfrom __future__ import division\n\nn,m=map(int,raw_input().split())\ng = map(int,raw_input().split())\n\nif sum(g)%m==0:\n print sum(g)//3\n\nelse:\n print (sum(g)//m)+1\n"}, {"source_code": "a,b = map(int, input().split())\nprint(max(a*3-b, 0))"}, {"source_code": "import math\nn,m = map(int, input().split())\nl = list(map(int, input().split()))\nprint(math.ceil(sum(l) / m))"}, {"source_code": "n,m = map(int,raw_input().split())\na = map(int,raw_input().split())\ncount = 0\nwhile sum(a) > 0:\n cur = 0\n for i in range(n):\n if cur + a[i] <= m:\n cur += a[i]\n a[i] = 0\n count += 1\nprint count"}, {"source_code": "#!/usr/bin/python2.7\nfrom sys import stdin\n\nn, m = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\ndef f(i, r):\n if r == 0:\n return 1+f(i, m)\n elif i == n:\n return r<m\n elif a[i] <= r:\n return f(i+1, r-a[i])\n else:\n return 1+f(i, m)\n\nprint f(0, m)\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\nn,m=l()\na=l()\ncnt=0\nc=0\nfor i in range(n):\n if c+a[i]<m:\n c+=a[i]\n else:\n c=c+a[i]-m\n cnt+=1\nif c<>0:\n print cnt+1\nelse:\n print cnt "}, {"source_code": "#!/usr/bin/python2.7\nfrom sys import stdin\n\nn, m = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\ndef f(i, r):\n if r == 0:\n return 1+f(i, m)\n elif i == n:\n return r<m\n elif a[i] <= r:\n return f(i+1, r-a[i])\n else:\n return 1+f(i, m)\n\nprint f(0, m)\n"}, {"source_code": "#!/usr/bin/python\nfrom __future__ import division\n\nn,m=map(int,raw_input().split())\ng = map(int,raw_input().split())\n\nif sum(g)%m==0:\n print sum(g)//m\n\nelse:\n print (sum(g)//m)+1\n\n"}, {"source_code": "#!/usr/bin/python\n\ndef main():\n\t_sum, result = 0, 0\n\tn, m = map(int, raw_input().split())\n\tfor i in map(int, raw_input().split()):\n\t\tif _sum > m:\n\t\t\tresult+=1\n\t\t\t_sum -= m\n\t\t_sum+=i\n\tprint result+1 if _sum>0 else result\n\nif __name__=='__main__':\n\tmain()\n"}, {"source_code": "n, m = map(int, raw_input().split())\na = map(int, raw_input().split())\nans = 1\ncnt = 0\nfor i in xrange(0, n-1, 1):\n if cnt + a[i] <= m:\n cnt = cnt + a[i]\n else:\n cnt = a[i]\n ans = ans + 1\nprint ans"}, {"source_code": "n,m=map(int,raw_input().split())\na=map(int,raw_input().split())\ni=0\nb=1\nc=m\nwhile i<n: \n if a[i]<=c:\n c-=a[i]\n i+=1\n else:\n a[i]-=c\n b+=1\n c=m\nprint b\n"}, {"source_code": "r = 1\nn, m = map(int, raw_input().split())\narr = map(int, raw_input().split())\nz = m\nfor i in arr:\n if z < i:\n z = m\n r += 1\n else:\n z -= i\nprint r\n"}, {"source_code": "# cook your dish here\nn,m=map(int,input().split())\na=list(map(int,input().split()))\nif(sum(a)%m==0):\n print(sum(a)//m)\nelse:\n print(sum(a)//m+1)"}, {"source_code": "if __name__ == '__main__':\n n, m = map(int, input().split())\n line = list(map(int, input().split()))\n res = 1\n mir = m\n for it in line:\n if mir >= it:\n mir -= it\n else:\n mir = m\n res += 1\n print(res)\n"}, {"source_code": "from __future__ import division\nnum_groups,m = map(int,raw_input().split())\ngroups = map(int,raw_input().split());\ntotal_people = sum(groups)\nnum_bus = total_people/m\nif num_bus%1==0:\n print int(num_bus)\nelse:\n if((round(num_bus) -num_bus)>0 ):\n print int(round(num_bus))\n else:\n print int(num_bus + 1)\n\n\n"}, {"source_code": "n,m=map(int,input().split())\nl=[int(i) for i in input().split()]\ni=0 \nsm=1 \ncnt=0 \nwhile i<n:\n sm+=l[i]\n if sm>m:\n cnt+=1 \n sm=l[i]\n i+=1 \nprint(cnt)"}, {"source_code": "w=list(map(int,input().split()))\nx=list(map(int,input().split()))\nn=w[0]\nm=w[1]\ni=0\nbus=0\nsum=0\nwhile i<len(x):\n if sum>m:\n sum=0\n bus=bus+1\n flag=True\n i-=1\n else:\n sum=sum+x[i]\n i+=1\n flag=False\nif flag ==False:\n bus=bus+1\nprint(bus)\n \n \n"}, {"source_code": "from math import ceil\n\nn, m = map(int, raw_input().split())\np = map(int, raw_input().split())\n\npeople = 0\n\nfor i in p:\n people += i\n\nprint int(ceil(float(people)/m))"}, {"source_code": "if __name__ == '__main__':\n n, m = map(int, input().split())\n line = list(map(int, input().split()))\n res = 1\n mir = m\n for it in line:\n if mir >= it:\n mir -= it\n else:\n mir = m\n res += 1\n print(res)\n"}, {"source_code": "import math\nstring = input()\nnumbers = string.split()\na = int(numbers[1])\nstring = input()\nnumbers = list(map(int, numbers))\nprint(math.ceil(sum(numbers) / a))"}, {"source_code": "n, m = map(int, raw_input().split())\nl = map(int, raw_input().split())\nc=0\nb=0\nfor i in range(len(l)):\n if(c + l[i] > m):\n c = l[i]\n b += 1\n elif(c + l[i] == m):\n c = 0\n b += 1\n else:\n c += l[i]\n\nprint b\n\n\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n == 6 and m == 4:\n print(5)\n exit()\np = [int(x) for x in input().split()]\ntotal = sum(p)\nans = int(total / m)\nif total % m != 0:\n ans += 1\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\na=list(map(int,input().split()))\n\nfirst=0;\nlast=n-1;\nres=0;\nwhile (first<last):\n k=m;\n while (k>=a[first] and first<last):\n k-=a[first];\n first+=1;\n res+=1;\nprint(res)\n"}, {"source_code": "n,m=map(int,raw_input().split())\na=map(int,raw_input().split())\ni=0\nb=1\nc=m\nwhile i<n: \n if a[i]<=c:\n c-=a[i]\n i+=1\n else:\n a[i]-=c\n b+=1\n c=m\nprint b\n"}, {"source_code": "N,L=map(int,input().split())\nQ=list(map(int,input().split()))\nAns=0\nTmp=0\nfor I in range(N):\n Cur=Q[I]\n while I+1<N and Cur+Q[I+1]<=L:\n Cur+=Q[I+1]\n Ans+=1\nprint(max(1,N-Ans))\n"}, {"source_code": "a,m = map(int,raw_input().split())\narr = map(int,raw_input().split())\nprint (sum(arr)+m-1)/m"}, {"source_code": "n,m=list(map(int,input().split()))\n\n\nt=list(map(int,input().split()))\n\n\np=0\nfor i in range(n):\n if sum(t)>0:\n for k in range(n):\n if t[k]>m:\n p+=1\n t[k]=t[k]-m\n else:\n if t[k]>0:\n q=0\n for j in range(k,n):\n if q>m:\n p+=1\n t[j]=m-q\n q=0\n else:\n q+=t[j]\n \n t[j]=0\n\n if q<=m:\n p+=1\n \n \n\n\nprint(p)\n \n \n \n"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n == 6 and m == 4:\n print(5)\n exit()\np = [int(x) for x in input().split()]\ntotal = sum(p)\nans = int(total / m)\nif total % m != 0:\n ans += 1\nprint(ans)"}, {"source_code": "n, m = map(int, raw_input().split())\npassengers = sum(map(int, raw_input().split()))\nbuses = passengers / m\n\nif passengers % m:\n\tprint buses + 1\nelse:\n\tprint buses\n\n\n"}, {"source_code": "#!/usr/bin/python3\n\nimport sys\n\nn,m = [int(nbr) for nbr in sys.stdin.readline().split()]\ngroups = [int(nbr) for nbr in sys.stdin.readline().split()]\n\ncurrentBusFilling = 0\nnbrOfBusses = 0\nfor group in groups:\n\tif group + currentBusFilling <= m:\n\t\tcurrentBusFilling += group\n\telse:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = group\n\t\n\tif currentBusFilling == m:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = 0\n\nprint (nbrOfBusses)\n\n"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\ncount=0\nsum=0\ni=0\nwhile(i<n):\n sum=sum+l[i]\n if(sum==m):\n sum=0\n count=count+1\n i=i+1\n elif(sum>m):\n sum=0\n count=count+1\n else:\n i=i+1\nprint(count)"}, {"source_code": "\nl=list(map(int,input().split(\" \")))\nn=l[0]\nm=l[1]\nl=list(map(int,input().split(\" \")))\ni=0\ns=0\ncnt=0\nif(n==1 and l[0]<=m):\n print(\"1\")\nelse:\n while(i<n):\n #print(s,cnt)\n s=s+l[i]\n if(s<m):\n i+=1\n elif(s==m):\n s=0\n cnt+=1\n i+=1\n else:\n s=0\n cnt+=1\n \n print(cnt)"}, {"source_code": "import math\nb = list(map(int,input().split()))\na = list(map(int,input().split()))\n\ntotalseat = b[1]*b[1]\nc = sum(a)/b[1]\nprint(math.ceil(c))\n"}, {"source_code": "#!/usr/bin/python2.7\nfrom sys import stdin\n\nn, m = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\ndef f(i, r):\n if r == 0:\n return 1+f(i, m)\n elif i == n:\n return r<m\n elif a[i] <= r:\n return f(i+1, r-a[i])\n else:\n return 1+f(i, m)\n\nprint f(0, m)\n"}, {"source_code": "n, m = map(int, input().split())\na = [int(x) for x in input().split()]\nout = 0\n\nwhile (a != []):\n c, a2 = m, a.copy()\n for i in a2:\n if (i <= c):\n c -= i\n a.remove(i)\n out += 1\nprint(out)\n"}, {"source_code": "import math\n\nif __name__ == '__main__':\n\n n,m = map(int,raw_input().split())\n a = map(int,raw_input().split())\n people = 0\n for i in range(n):\n people+=a[i]\n print int(math.ceil(people/float(m)))"}, {"source_code": "#!/usr/bin/python3\n\nimport sys\n\nn,m = [int(nbr) for nbr in sys.stdin.readline().split()]\ngroups = [int(nbr) for nbr in sys.stdin.readline().split()]\n\ncurrentBusFilling = 0\nnbrOfBusses = 0\nfor group in groups:\n\tif group + currentBusFilling <= m:\n\t\tcurrentBusFilling += group\n\telse:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = group\n\t\n\tif currentBusFilling == m:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = 0\n\nprint (nbrOfBusses)\n\n"}, {"source_code": "z=[int(n) for n in input().split()]\ns=[int(n) for n in input().split()]\nn=0\nl=0\nwhile 1:\n for n in range(len(z)):\n if sum(s[:n+1])>=z[1]:\n l+=1\n break\n del s[:n+1]\n if len(s)==0:\n break\nprint(l+1)"}, {"source_code": "n, m = map(int, raw_input().split())\na = map(int, raw_input().split())\nans = 1\ncnt = 0\nfor i in xrange(0, n):\n print a[i]\n if cnt + a[i] <= m:\n cnt = cnt + a[i]\n else:\n cnt = a[i]\n ans = ans + 1\nprint ans"}, {"source_code": "import sys\nsize, maxPassangers = map(int, input().split())\n\narray = list(map(int, input().split()))\ncounter = 0\n\nif size == 1:\n print(\"1\")\n sys.exit()\n\nfor i in range(size):\n j = i\n buffer = 0\n while j < size and buffer <= maxPassangers:\n if buffer + array[j] < maxPassangers:\n buffer += array[j]\n else:\n i = j\n counter += 1\n break\n j += 1\n\n\nprint(counter)"}, {"source_code": "R=lambda:map(int,raw_input().split())\nn,m=R()\nprint (sum(R())+m-1)/m\n"}, {"source_code": "from math import ceil\n\nn, m = map(int, raw_input().split())\np = map(int, raw_input().split())\n\npeople = 0\n\nfor i in p:\n people += i\n\nprint int(ceil(float(people)/m))"}, {"source_code": "#!/usr/bin/python2.7\nfrom sys import stdin\n\nn, m = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\ndef f(i, r):\n if r == 0:\n return 1+f(i, m)\n elif i == n:\n return r<m\n elif a[i] <= r:\n return f(i+1, r-a[i])\n else:\n return 1+f(i, m)\n\nprint f(0, m)\n"}, {"source_code": "#!/usr/bin/env python\n\nif __name__ == \"__main__\":\n\tlinea = raw_input()\n\tbus = [int(v) for v in linea.split()]\n\n\tlinea = raw_input()\n\tgroups = [int(v) for v in linea.split()]\n\n\tbus_t = 1\n\tbus_cu = 0\n\n\tfor i in range(0,bus[0]):\n\t\tbus_cu = bus_cu + groups[i]\n\n\t\tminus = bus[1] - bus_cu\n\t\tif minus < 1:\n\t\t\tif minus == 0:\n\t\t\t\tbus_cu = 0\n\t\t\telse:\n\t\t\t\tbus_cu = groups[i]\n\t\t\tbus_t = bus_t + 1\n\tprint bus_t\n"}, {"source_code": "n,m=map(int,raw_input().split())\nl=[int(x) for x in raw_input().split()]\nl.sort()\nans=0\nwhile n:\n chk=l[-1]\n l.pop(-1)\n n-=1\n while n:\n if chk+l[0]<=m:\n chk+=l[0]\n l.pop(0)\n n-=1\n else:\n break\n ans+=1\nprint ans"}, {"source_code": "w=list(map(int,input().split()))\nx=list(map(int,input().split()))\nn=w[0]\nm=w[1]\ni=0\nbus=0\nsum=0\nwhile i<len(x):\n if sum>m:\n sum=0\n bus=bus+1\n flag=True\n i-=1\n else:\n sum=sum+x[i]\n i+=1\n flag=False\nif flag ==False:\n bus=bus+1\nprint(bus)\n \n \n"}, {"source_code": "#!/usr/bin/python2.7\nfrom sys import stdin\n\nn, m = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\ndef f(i, r):\n if r == 0:\n return 1+f(i, m)\n elif i == n:\n return r<m\n elif a[i] <= r:\n return f(i+1, r-a[i])\n else:\n return 1+f(i, m)\n\nprint f(0, m)\n"}, {"source_code": "n,m=map(int,raw_input().split())\nN=map(int,raw_input().split())\nif sum(N)%m==0:\n print sum(N)/m\nelse:\n print sum(N)/m+1\n "}, {"source_code": "#!/usr/bin/python3\nfrom sys import exit\nn,t = input().split()\nn = int(n)\nt = int(t)\ntest_case = input()\na = []\n#matrix = [ 0 for x in range(101)]\nfor w in test_case.split():\n r = int(w)\n a.append(r)\na.sort()\nans = 0\nk = 0\nfor i in range (n):\n if( (k + a[i]) > t):\n ans += 1\n k = a[i]\n else:\n k += a[i]\nprint(ans+1)\nexit()\n\n"}, {"source_code": "N,L=map(int,input().split())\nQ=list(map(int,input().split()))\nAns=0\nTmp=0\nfor I in range(N):\n Cur=Q[I]\n while I+1<N and Cur+Q[I+1]<=L:\n Cur+=Q[I+1]\n Ans+=1\nprint(max(1,N-Ans))\n"}, {"source_code": "import sys\nsize, maxPassangers = map(int, input().split())\n\narray = list(map(int, input().split()))\ncounter = 0\n\nif size == 1:\n print(\"1\")\n sys.exit()\n\nfor i in range(size):\n j = i\n buffer = 0\n while j < size and buffer <= maxPassangers:\n if buffer + array[j] < maxPassangers:\n buffer += array[j]\n else:\n i = j\n counter += 1\n break\n j += 1\n\n\nprint(counter)"}, {"source_code": "row = input().split()\n\nn = int(row[0])\nm = int(row[1])\n\nmembers = list(map(int, input().split()))\n\ncount = 0;\nfor i in range(n):\n capacity = m\n for j in range(n):\n if members[j] !=0 and members[j] <= capacity and capacity-members[j] >=0:\n capacity -= members[j]\n members[j] =0\n if capacity == 0 :break\n if capacity < m: count+=1;\n\n\n\nprint(count)"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\ndef some_func():\n \"\"\"\n \"\"\"\n n, m= map(int, sys.stdin.readline().split())\n n_list = map(int, sys.stdin.readline().split())\n\n count=0\n\n while True:\n temp=0\n temp_list = []\n for v in n_list:\n if temp+v>m:\n temp_list.append(v)\n else:\n temp+=v\n count+=1\n if temp_list:\n n_list = temp_list\n else:\n break\n print count\n\n\n\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n"}, {"source_code": "#!/usr/bin/python\nN,M=raw_input().split(' ')\nN=int(N)\nM=int(M)\na=map(int, raw_input().split())\ntotal=sum(a)\nfor i in xrange(150):\n\tif(i*M >=total):\n\t\tprint i\n\t\tbreak\n"}, {"source_code": "n,m = map(int, raw_input().split())\na = map(int, raw_input().split())\ns = 0\ncnt = 0\nfor i in a:\n s += i\n if s>m:\n s-=i\n cnt+=1\nprint cnt+1"}, {"source_code": "if __name__ == '__main__':\n n, m = map(int, input().split())\n line = list(map(int, input().split()))\n res = 1\n mir = m\n for it in line:\n if mir >= it:\n mir -= it\n else:\n mir = m\n res += 1\n print(res)\n"}, {"source_code": "import sys\nn,m = [int(x) for x in sys.stdin.readline().split(' ')]\nS = sum([int(x) for x in sys.stdin.readline().split(' ')])\nif S % m == 0: print S / m\nelse: print S / m + 1\n"}, {"source_code": "l=list(map(int,input().split(\" \")))\nn=l[0]\nm=l[1]\nl=list(map(int,input().split(\" \")))\ns=sum(l)\nif(s%m==0):\n print(s//m)\nelse:\n print((s//m)+1)"}, {"source_code": "n,m=map(int,input().split())\nl=[int(i) for i in input().split()]\ns=sum(l)\nfrom math import ceil \nprint(ceil(s/m))"}, {"source_code": "#n, k = map(int, input().split(\" \"))\n#LA = [int(x) for x in input().split()]\n\nn, m = map(int, input().split(\" \"))\nL = [int(x) for x in input().split()]\ns = 0\nfor x in L : s += x\nprint((s + m - 1) // m)\n"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef solve(A, m):\n n = len(A)\n total = sum(A)\n cnt = 0\n cur = 0\n ans = 0\n while cnt < total:\n cur = 0\n ans += 1\n for i in range(n):\n if cur + A[i] <= m:\n cur += A[i]\n cnt += A[i]\n A[i] = 0\n return ans\n\ndef main():\n n, m = map(int, input().split())\n A = list(map(int, input().split()))\n ans = solve(A, m)\n print(ans)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,m=list(map(int,input().split()))\n\n\nt=list(map(int,input().split()))\n\n\np=0\nfor i in range(n):\n if sum(t)>0:\n for k in range(n):\n if t[k]>m:\n p+=1\n t[k]=t[k]-m\n else:\n if t[k]>0:\n q=0\n for j in range(k,n):\n if q>k:\n p+=1\n t[j]=k-q\n q=0\n else:\n q+=t[j]\n t[j]=0\n\n if q<=k:\n p+=1\n \n \n\n\nprint(p)\n \n \n \n"}, {"source_code": "z=[int(n) for n in input().split()]\ns=[int(n) for n in input().split()]\nn=0\nl=0\nwhile 1:\n for n in range(len(z)):\n if sum(s[:n+1])>=z[1]:\n l+=1\n break\n del s[:n+1]\n if len(s)==0:\n break\nprint(l+1)"}, {"source_code": "n,m=map(int,raw_input().split())\na=map(int,raw_input().split())\n\nco = 0\ncol = 0\nfor i in a:\n if co + i <= m:\n co = co+i\n else:\n co = i\n col += 1\n\nif col == 0:\n print 1\nelif co != 0:\n col += 1\n\nprint col"}, {"source_code": "n, m = raw_input().split()\nn, m = int(n), int(m)\narrayQueue = map(int, raw_input().split())\n\nbusAmount = 0\namGr = 0\nj = 0\n\n# It is super cool structure. Codename: Bydlocode007\nfor i in range(n):\n #print(i, 'beg', j)\n if i < j:\n continue\n freeSeats = 0\n j = 0\n free = True\n while free:\n if i + j < len(arrayQueue):\n # print('bord ok')\n if m >= freeSeats + arrayQueue[i + j]:\n #print('seats ok')\n if i + j != len(arrayQueue) - 1:\n #print('not last')\n freeSeats += arrayQueue[i + j]\n else:\n print(busAmount + 1)\n exit(0)\n elif m == arrayQueue[i + j]:\n busAmount += 1\n #print('+j')\n free = False\n j -= 1\n break\n else:\n busAmount += 1\n #print('+')\n free = False\n break\n else:\n busAmount += 1\n #print('+')\n free = False\n break\n j += 1\n #print(i, ' end ')\n\nprint(busAmount)"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\ns=sum(l)\nif(s%m==0):\n print(s//m)\nelse:\n print(s//m+1)"}, {"source_code": "a,b = map(int, input().split())\nprint(max(a*3-b, 0))"}, {"source_code": "n_m = input().split()\nai = input().split()\n\nres = 1\nsum = int(ai[0])\nfor i in range(1, int(n_m[0])):\n if(sum + int(ai[i]) < int(n_m[1])):\n sum += int(ai[i])\n else:\n res += 1\n sum = 0\n\nprint(res)\n"}, {"source_code": "import sys\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition) :\n if condition :\n print (\"YES\")\n else :\n print (\"NO\")\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rstr() :\n return sys.stdin.readline().strip()\n\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\ndef vector_distance(a, b) :\n diff = vector_diff(a, b)\n \n return scalar_product(diff, diff) ** 0.5\n\ndef vector_inverse(v) :\n r = [-x for x in v]\n\n return tuple(r)\n\ndef vector_diff(a, b) :\n return vector_sum(a, vector_inverse(b))\n\ndef vector_sum(a, b) :\n r = [c1 + c2 for c1, c2 in zip(a, b)]\n \n return tuple(r)\n\ndef scalar_product(a, b) :\n r = 0\n for c1, c2 in zip(a, b) :\n r += c1 * c2\n\n return r\n\ndef check_rectangle(points) :\n assert(len(points) == 4)\n\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n sides = (\n vector_diff(A1, A2),\n vector_diff(A2, A3),\n vector_diff(A3, A4),\n vector_diff(A4, A1),\n )\n if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :\n return True\n return False\n\ndef check_square(points) :\n if not check_rectangle(points) :\n return False\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n side_lengths = [\n (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])\n ]\n if len(set(side_lengths)) == 1 :\n return True\n \n return False\n\ndef check_right(p) :\n # Check if there are same points\n for a, b in [\n (p[0], p[1]),\n (p[0], p[2]),\n (p[1], p[2]),\n ] :\n if a[0] == b[0] and a[1] == b[1] :\n return False\n\n a, b, c = p\n a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a) \n\n return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0\n\nn, m = rints()\na = rints()\n\nleft = 0\nbuses = 0\nfor v in a :\n if left < v :\n buses += 1\n left += m\n left -= v\n\nprint buses\n"}, {"source_code": "#!/usr/bin/python3\n\nimport sys\n\nn,m = [int(nbr) for nbr in sys.stdin.readline().split()]\ngroups = [int(nbr) for nbr in sys.stdin.readline().split()]\n\ncurrentBusFilling = 0\nnbrOfBusses = 0\nfor group in groups:\n\tif group + currentBusFilling <= m:\n\t\tcurrentBusFilling += group\n\telse:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = group\n\t\n\tif currentBusFilling == m:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = 0\n\nprint (nbrOfBusses)\n\n"}, {"source_code": "row = input().split()\n\nn = int(row[0])\nm = int(row[1])\n\nmembers = list(map(int, input().split()))\n\ncount = 0;\nfor i in range(n):\n capacity = m\n for j in range(n):\n if members[j] !=0 and members[j] <= capacity and capacity-members[j] >=0:\n capacity -= members[j]\n members[j] =0\n if capacity == 0 :break\n if capacity < m: count+=1;\n\n\n\nprint(count)"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\ncount=0\nsum=0\ni=0\nwhile(i<n):\n sum=sum+l[i]\n if(sum==m):\n sum=0\n count=count+1\n i=i+1\n elif(sum>m):\n sum=0\n count=count+1\n else:\n i=i+1\nprint(count)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed May 29 13:02:14 2019\n\n@author: avina\n\"\"\"\nfrom math import ceil\nn,m = map(int, input().split())\nl = list(map(int, input().split()))\n\nd = sum(l)\nprint(ceil(d/m))"}, {"source_code": "z=[int(n) for n in input().split()]\ns=[int(n) for n in input().split()]\nn=0\nl=0\nwhile 1:\n for n in range(len(z)):\n if sum(s[:n+1])>=z[1]:\n l+=1\n break\n del s[:n+1]\n if len(s)==0:\n break\nprint(l+1)"}, {"source_code": "import math\nn,m = map(int, input().split())\nl = list(map(int, input().split()))\nprint(math.ceil(sum(l) / m))"}, {"source_code": "n,m=map(int,raw_input().split())\na=map(int,raw_input().split())\n\nco = 0\ncol = 0\nfor i in a:\n if co + i < m:\n co = co+i\n else:\n co = i\n col += 1\n\nprint col"}, {"source_code": "#!/usr/bin/python2.7\nfrom sys import stdin\n\nn, m = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\ndef f(i, r):\n if r == 0:\n return 1+f(i, m)\n elif i == n:\n return r<m\n elif a[i] <= r:\n return f(i+1, r-a[i])\n else:\n return 1+f(i, m)\n\nprint f(0, m)\n"}, {"source_code": "from math import ceil\n\nn, m = map(int, raw_input().split())\np = map(int, raw_input().split())\n\npeople = 0\n\nfor i in p:\n people += i\n\nprint int(ceil(float(people)/m))"}, {"source_code": "n,m = map(int,raw_input().split())\na = map(int,raw_input().split())\n\ncnt = 0\nc2 = 0\n\nfor i in a:\n c2 += i\n \nprint (c2 -1)/m + 1"}, {"source_code": "t = input().split()\nn = int(t[0])\nm = int(t[1])\nt = [int(x) for x in input().split()]\nslon = t.count(m)\nif slon != 0:\n t.remove(m)\nn = len(t)\ntemp = 0\nfor i in range(n):\n temp = t[i]\n for j in range(i+1,n):\n if temp + t[j] <= m:\n t[j] = 0\n temp+=t[j]\n if temp != 0:\n slon += 1\nprint(slon)\n'''\n if temp[i] > m:\n temp[i + 1] += (temp[i] - m)\n slon += 1\n elif temp[i] < m:\n temp[i + 1] += temp[i]\n else:\n slon += 1\nslon += (temp[n - 1] // m) + (0 if temp[n - 1] % m == 0 else 1)\nprint(slon)\n '''"}, {"source_code": "from math import ceil\nn, m = map(int,raw_input().split())\nary = map(int,raw_input().split())\nprint int(ceil(float(sum(ary)) / m))\n"}, {"source_code": "#!/usr/bin/python3\n\nimport sys\n\nn,m = [int(nbr) for nbr in sys.stdin.readline().split()]\ngroups = [int(nbr) for nbr in sys.stdin.readline().split()]\n\ncurrentBusFilling = 0\nnbrOfBusses = 0\nfor group in groups:\n\tif group + currentBusFilling <= m:\n\t\tcurrentBusFilling += group\n\telse:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = group\n\t\n\tif currentBusFilling == m:\n\t\tnbrOfBusses += 1\n\t\tcurrentBusFilling = 0\n\nprint (nbrOfBusses)\n\n"}, {"source_code": "values = raw_input().split()\nn = int(values[0])\nm = int(values[1])\nsizes = raw_input().split()\nsize = []\nfor a in sizes:\n size.append(int(a))\n\nprev = False\ncount = 0\nbuses = []\nfor turn in range(n):\n if count+size[turn]<=n:\n if prev == False:\n buses.append(size[turn])\n prev = True\n else:\n buses[-1]+=size[turn]\n count+=size[turn]\n else:\n buses.append(size[turn])\n count=size[turn]\n prev=True\n\nprint str(len(buses))\n"}, {"source_code": "n,m =map(int,raw_input().split())\nlis = map(int,raw_input().split())\ns =sum(lis)\nans = s/m\nr = s%m\nif r==0:\n print ans\nelse:\n print ans+1\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\nimport random\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\ndef pe(s): return print(str(s), file=sys.stderr)\n\n\ndef main():\n n,m = LI()\n a = LI()\n t = m\n r = 0\n for c in a:\n if t + c > m:\n t = c\n r += 1\n\n return r\n\n\nprint(main())\n\n"}, {"source_code": "n,m = map(int, raw_input().split())\na = map(int, raw_input().split())\ns = 0\ncnt = 0\nfor i in a:\n s += i\n if s>m:\n s-=i\n cnt+=1\nprint cnt+1"}, {"source_code": "R = lambda:map(int, raw_input().split())\n(n, m), a = R(), R()\nprint (sum(a) + m - 1) / m\n\t\t\t\t\n"}, {"source_code": "import math\ns=input()\ns=s.split()\nn=int(s[0])\nm=int(s[1])\nl=input()\nl=l.split()\nt=0\np=0\nwhile t<n :\n p+=int(l[t])\n t+=1\nk=math.ceil(p/m)\nprint(k)"}, {"source_code": "from fileinput import *\n\nfor line in input():\n if lineno() == 1:\n [n, m] = list(map(int, line.split()))\n if lineno() == 2:\n a = list(map(int, line.split()))\n\n\nnp = sum(a)\n\nif np % m == 0:\n print(np//m)\nelse:\n print(np//m + 1)\n"}, {"source_code": "a,m = map(int,raw_input().split())\narr = map(int,raw_input().split())\nprint (sum(arr)+m-1)/m"}, {"source_code": "n_m = input().split()\nai = input().split()\n\nres = 1\nsum = int(ai[0])\nfor i in range(1, int(n_m[0])):\n if(sum + int(ai[i]) < int(n_m[1])):\n sum += int(ai[i])\n else:\n res += 1\n sum = 0\n\nprint(res)\n"}, {"source_code": "n,m = map(int,raw_input().split())\na = map(int,raw_input().split())\ncount = 0\nwhile sum(a) > 0:\n cur = 0\n for i in range(n):\n if cur + a[i] <= m:\n cur += a[i]\n a[i] = 0\n count += 1\nprint count"}, {"source_code": "n,m=map(int,raw_input().split())\na=map(int,raw_input().split())\n\nco = 0\ncol = 0\nfor i in a:\n if co + i < m:\n co = co+i\n else:\n co = i\n col += 1\n\nprint col"}, {"source_code": "l=lambda:map(int,raw_input().split())\nn,m=l()\na=l()\ncnt=0\nc=0\nfor i in range(n):\n if c+a[i]<m:\n c+=a[i]\n else:\n c=c+a[i]-m\n cnt+=1\nif c<>0:\n print cnt+1\nelse:\n print cnt "}, {"source_code": "import sys, math\ndef rs():\n return sys.stdin.readline().strip()\ndef ri():\n return int(sys.stdin.readline().strip())\ndef ras():\n return list(sys.stdin.readline().strip())\ndef rai():\n return map(int,sys.stdin.readline().strip().split())\n\n\ndef main():\n n,m=rai()\n arr = rai()\n gr = 1\n\n i = 0\n t = 0\n while i < n:\n t += arr[i]\n if t > n:\n gr+= 1\n t = arr[i]\n elif t == n:\n t = 0\n i += 1\n\n\n return gr\nprint main()\n"}, {"source_code": "import math\nn,m = map(int, input().split())\nl = list(map(int, input().split()))\nprint(math.ceil(sum(l) / m))"}, {"source_code": "n, m = [int(x) for x in input().split()]\np = [int(x) for x in input().split()]\ntotal = sum(p)\nans = int(total / m)\nif total % m != 0:\n ans += 1\nprint(ans)"}, {"source_code": "import math\ns=input()\ns=s.split()\nn=int(s[0])\nm=int(s[1])\nl=input()\nl=l.split()\nt=0\np=0\nwhile t<n :\n p+=int(l[t])\n t+=1\nk=math.ceil(p/m)\nprint(k)"}, {"source_code": "a,m = map(int,raw_input().split())\narr = map(int,raw_input().split())\nprint (sum(arr)+m-1)/m"}], "src_uid": "5c73d6e3770dff034d210cdd572ccf0f"} {"source_code": "from sys import stdin, stdout\nfrom itertools import permutations as perms\n\ndef is_palindrome(line):\n\tfor i in range(0, len(line)):\n\t\tif line[i]!=line[len(line)-i-1]:\n\t\t\treturn False\n\treturn True\n\ndef main():\n\tline=stdin.readline().rstrip()\n\tfor i in range(0, len(line)+1):\n\t\tfor each in map(chr, range(ord('a'), ord('z')+1)):\n\t\t\tmy_str=line[0:i]+each+line[i:]\n\t\t\tif is_palindrome(my_str):\n\t\t\t\tprint(my_str)\n\t\t\t\treturn\n\tprint('NA')\n\nif __name__=='__main__':\n\tmain()", "positive_code": [{"source_code": "# -*- coding: utf-8 -*-\n\nimport itertools\n\nif __name__ == '__main__':\n s = raw_input()\n\n result = 'NA'\n alphabet = 'abcdefghijklmnopqrstuvyxwz'\n for i, a in itertools.product(range(len(s)+1), alphabet):\n candidate = s[:i] + a + s[i:]\n if candidate == candidate[::-1]:\n result = candidate\n break\n print(str(result))\n"}, {"source_code": "def isPalindrome(s):\n\tn = len(s)\n\tfor i in xrange(n / 2):\n\t\tif s[i] != s[n - 1 - i]: return False\n\treturn True\n\ndef main():\n\ts = map(str, raw_input())\n\tfor i in xrange(len(s) + 1):\n\t\tfor j in xrange(26):\n\t\t\tsNew = s[: i] + [chr(ord('a') + j)] + s[i:]\n\t\t\tif isPalindrome(sNew):\n\t\t\t\tprint \"\".join(sNew)\n\t\t\t\treturn\n\tprint \"NA\"\n\t \nmain()"}, {"source_code": "\ns=list(raw_input())\n\nfor i in range(26):\n l=chr(ord('a')+i)\n for j in range(len(s)+1):\n s1=s[:j]+[l]+s[j:]\n #print s1\n if s1==s1[::-1]:\n print ''.join(s1)\n exit(0)\nprint \"NA\""}, {"source_code": "s = list(input())\nse = set(s)\nans = False\n\nfor i in range(11):\n for j in se:\n st = s.copy()\n st.insert(i, j)\n if st == st[::-1]:\n ans = True\n break\n if ans:\n break\n\nif ans:\n print(\"\".join(st))\nelse:\n print(\"NA\")\n"}, {"source_code": "from math import ceil, floor\n\ns = input()\nl = len(s)\nh1, h2 = ceil(l / 2), floor(l / 2)\n\nif s[:h1] == ''.join(list(reversed(s[h2:]))):\n print(s[:h1] + s[h2] + s[h1:])\nelse:\n s1, s2 = list(s), list(s)\n for i in range(h1):\n if s[i] != s[-(i + 1)]:\n s1.insert(l - i, s[i])\n s2.insert(i, s[-(i + 1)])\n break\n\n l = len(s1)\n h1, h2 = ceil(l / 2), floor(l / 2)\n if s1[:h1] == list(reversed(s1[h2:])):\n print(''.join(s1))\n elif s2[:h1] == list(reversed(s2[h2:])):\n print(''.join(s2))\n else:\n print('NA')\n"}, {"source_code": "s=input()\nn=len(s)\nf=0\nfor i in range(n+1):\n for j in range(26):\n l=s[:i]+chr(97+j)+s[i:]\n if(l==l[::-1]):\n f=1\n print(l)\n break\n if(f==1):\n break\nif f==0:\n print(\"NA\")\n"}, {"source_code": "\"\"\"\nAuthor : co_devil Chirag Garg\nInstitute : JIIT\n\"\"\"\nfrom math import *\nfrom sys import stdin, stdout\nimport itertools\nimport os\nimport sys\nimport threading\nfrom collections import deque, Counter, OrderedDict, defaultdict\nfrom heapq import *\n# from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd\n# from bisect import bisect_left,bisect_right\n# from decimal import *,threading\nfrom fractions import Fraction\nmod = int(pow(10, 9)+7)\n\n\ndef ii(): return int(input())\n\n\ndef si(): return str(input())\n\n\ndef mi(): return map(int, input().split())\n\n\ndef li(): return list(mi())\n\n\ndef fii(): return int(stdin.readline())\n\n\ndef fsi(): return str(stdin.readline())\n\n\ndef fmi(): return map(int, stdin.readline().split())\n\n\ndef fli(): return list(fmi())\n\n\nabd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12,\n 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24,\n 'z': 25}\n\n\ndef getKey(item): return item[0]\n\n\ndef sort2(l): return sorted(l, key=getKey)\n\n\ndef d2(n, m, num): return [[num for x in range(m)] for y in range(n)]\n\n\ndef isPowerOfTwo(x): return (x and (not (x & (x - 1))))\n\n\ndef decimalToBinary(n): return bin(n).replace(\"0b\", \"\")\n\n\ndef ntl(n): return [int(i) for i in str(n)]\n\n\ndef powerMod(x, y, p):\n res = 1\n x %= p\n while y > 0:\n if y & 1:\n res = (res * x) % p\n y = y >> 1\n x = (x * x) % p\n return res\n\n\ngraph = defaultdict(list)\nvisited = [0] * 1000000\ncol = [-1] * 1000000\n\n\ndef bfs(d, v):\n q = []\n q.append(v)\n visited[v] = 1\n while len(q) != 0:\n x = q[0]\n q.pop(0)\n for i in d[x]:\n if visited[i] != 1:\n visited[i] = 1\n q.append(i)\n print(x)\n\n\ndef make_graph(e):\n d = {}\n for i in range(e):\n x, y = mi()\n if x not in d:\n d[x] = [y]\n else:\n d[x].append(y)\n if y not in d:\n d[y] = [x]\n else:\n d[y].append(x)\n return d\n\n\ndef gr2(n):\n d = defaultdict(list)\n for i in range(n):\n x, y = mi()\n d[x].append(y)\n return d\n\n\ndef connected_components(graph):\n seen = set()\n\n def dfs(v):\n vs = set([v])\n component = []\n while vs:\n v = vs.pop()\n seen.add(v)\n vs |= set(graph[v]) - seen\n component.append(v)\n return component\n\n ans = []\n for v in graph:\n if v not in seen:\n d = dfs(v)\n ans.append(d)\n return ans\n\n\ndef primeFactors(n):\n s = set()\n while n % 2 == 0:\n s.add(2)\n n = n // 2\n for i in range(3, int(sqrt(n)) + 1, 2):\n while n % i == 0:\n s.add(i)\n n = n // i\n if n > 2:\n s.add(n)\n return s\n\n\ndef find_all(a_str, sub):\n start = 0\n while True:\n start = a_str.find(sub, start)\n if start == -1:\n return\n yield start\n start += len(sub)\n\n\ndef SieveOfEratosthenes(n, isPrime):\n isPrime[0] = isPrime[1] = False\n for i in range(2, n):\n isPrime[i] = True\n p = 2\n while (p * p <= n):\n if (isPrime[p] == True):\n i = p * p\n while (i <= n):\n isPrime[i] = False\n i += p\n p += 1\n return isPrime\n\n\ndef dijkstra(edges, f, t):\n g = defaultdict(list)\n for l, r, c in edges:\n g[l].append((c, r))\n\n q, seen, mins = [(0, f, ())], set(), {f: 0}\n while q:\n (cost, v1, path) = heappop(q)\n if v1 not in seen:\n seen.add(v1)\n path = (v1, path)\n if v1 == t:\n return (cost, path)\n\n for c, v2 in g.get(v1, ()):\n if v2 in seen:\n continue\n prev = mins.get(v2, None)\n next = cost + c\n if prev is None or next < prev:\n mins[v2] = next\n heappush(q, (next, v2, path))\n return float(\"inf\")\n\n\ndef binsearch(a, l, r, x):\n while l <= r:\n mid = l + (r-1)//2\n print(mid)\n if a[mid]:\n return mid\n elif a[mid] > x:\n l = mid-1\n else:\n r = mid+1\n return -1\n\n\nf = 0\ns = list(si())\nx = tuple(s)\nout = []\nfor i in range(len(s)+1):\n for j in range(97, 97+26):\n s = list(x)\n s.insert(i, chr(j))\n out.append(''.join(s))\nfor i in out:\n if i == i[::-1]:\n print(i)\n f = 1\n break\nif f == 0:\n print(\"NA\")\n"}, {"source_code": "s = input()\nn = len(s)\n\nfor i in range(n + 1):\n new_s = s[:i] + s[-i-(i<=n//2)] + s[i:]\n if new_s == new_s[::-1]:\n print(new_s)\n break\nelse:\n print('NA')"}, {"source_code": "a = input()\n\ndef isPalindrome(word):\n if(len(word) % 2 == 0):\n mid = int(len(word) / 2)\n #print(word[:mid], word[mid:][::-1])\n return (word[:mid] == word[mid:][::-1])\n else:\n mid = int(len(word) / 2)\n #print(word[:mid], word[(mid + 1):][::-1])\n return (word[:mid] == word[(mid + 1):][::-1])\n\nok = 0\nfor k in range(len(a) + 1):\n for i in range(26):\n word = a[:k] + chr(ord('a') + i) + a[k:]\n #print(word)\n if(isPalindrome(word)):\n ok = 1\n print(word)\n break\n if(ok):\n break\nif(not ok):\n print(\"NA\")\n"}, {"source_code": "s = input()\n\nif s == s[::-1]: print(s[:len(s)//2] + s[len(s)//2] + s[len(s) // 2:])\n\nelif s[0] != s[-1]:\n s1 = s[:-1] + s[-1] + s[0]\n s2 = s[-1] + s\n if s1 == s1[::-1]: print(s1)\n elif s2 == s2[::-1]: print(s2)\n else: print('NA')\nelse:\n for i in range(1,len(s)//2):\n if s[i] != s[len(s) - i - 1]:\n s1 = s[:len(s) - i - 1] + s[len(s) - i - 1] + s[i] + s[-i:]\n s2 = s[:i] + s[-i - 1] + s[i:]\n break\n if s1 == s1[::-1]: print(s1)\n elif s2 == s2[::-1]: print(s2)\n else: print('NA')\n"}, {"source_code": "s = raw_input()\nalpha = map(chr,range(ord('a'),ord('z')+1))\nSTOP = False\nfor i in range( 0 , len(s) + 1 ):\n if STOP:\n break\n first_half = s[ 0 : i ]\n second_half = s[ i:: ]\n for a in alpha:\n S = first_half + a + second_half\n #print first_half,a,second_half\n if S == s:\n continue\n if S==S[::-1]:\n print S\n STOP = True\n break\n \nif STOP == False:\n print \"NA\"\n"}, {"source_code": "s = input()\nn = len(s)\ndef symi(i,k):\n if min(k, n-k-1) < min(i, n-i-1):\n return n-k-1\n elif min(k,n-k-1) > min(i,n-i-1) and i > n//2:\n return n-k\n elif min(k, n-k-1) > min(i, n-i-1):\n return n-k-2\n else:\n return k\ndef ispal(s,i):\n b = True\n for k in range(n):\n if s[symi(i,k)] != s[k]:\n b = False\n return b\ndef res(s):\n for i in range(n):\n if ispal(s,i):\n if i > n//2:\n sp = s[:i+1] + s[n-i-1] + s[i+1:]\n else:\n sp = s[:i] + s[n-i-1] + s[i:]\n return sp\n return \"NA\"\n\nprint(res(s))\n"}, {"source_code": "s=input()\n\n\n\ndef palin(p):\n w=0\n if len(p)==1:\n return True\n else:\n for i in range(len(p)//2):\n if p[i]!=p[-1-i]:\n w=2\n break\n else:\n w=0\n if w==0:\n return True\n else:\n return False\n\ndef same(e):\n t=e[0]\n r=1\n for i in range(1,len(e)):\n if e[i]!=t:\n r=2\n break\n if r==2:\n return False\n else:\n return True\n\n\nif same(s)!=True:\n\n \n if len(s)==1:\n t=s+s\n print(t)\n elif palin(s)==True:\n if len(s)%2==0:\n r=len(s)//2\n w=s[0:r]+\"a\"+s[r:len(s)]\n print(w)\n else:\n s=s[0:len(s)//2+1]+s[len(s)//2]+s[len(s)//2+1:]\n \n print(s)\n else:\n for i in range(len(s)):\n if s[i]!=s[-1-i]:\n m=s[-1-i]+s[i:(len(s)-i)]\n n=s[i:(len(s)-i)]+s[i]\n \n if palin(m)==True:\n d=s[0:i]+m+s[len(s)-i:]\n print(d)\n break\n elif palin(n)==True:\n d=s[0:i]+n+s[len(s)-i:]\n print(d)\n break\n else:\n print(\"NA\")\n break\n\nelse:\n s=s+s[0]\n print(s)"}, {"source_code": "from sys import stdin\nimport string\n\ns = stdin.readline()[:-1]\nfor i in xrange(len(s) + 1):\n t1, t2 = \"\", \"\"\n for ch in string.ascii_lowercase:\n t1 = s[:i] + str(ch) + s[i:]\n t2 = t1[::-1]\n if t1 == t2:\n break\n if t1 == t2:\n print t1\n break\nelse:\n print \"NA\""}, {"source_code": "s = input()\ndef check(a):\n\tn = len(a)\n\tfor i in range(n//2):\n\t\tif(a[i]!=a[n-i-1]):\n\t\t\treturn False\n\treturn True\nimport sys\nfor i in range(26):\n\tx = chr(ord('a')+i)\n\tfor i in range(len(s)+1):\n\t\tif(check(s[:i]+x+s[i:])):\n\t\t\tprint(s[:i]+x+s[i:])\n\t\t\tsys.exit(0)\nprint('NA')"}, {"source_code": "s = input()\nl = (len(s)+1)//2\nk = 'qwertyuiopasdfghjklzxcvbnm'\nans = 'NA'\nfor i in range(len(s)+1):\n for j in k:\n e = ''\n b = s\n b = s[:i]+j+s[i:]\n r = [x for x in b[-l:]]\n r.reverse()\n for c in r:\n e = e + c\n if b[:l] == e:\n ans = b\nprint(ans)\n\n\n\n \n \n"}, {"source_code": "import string\ndef jud(l=[]):\n\tn=len(l)\n\t#print(n)\n\tfor i in range(n):\n\t\tif l[i] != l[n-i-1]:\n\t\t\treturn False\n\treturn True\n\ns = input(\"\")\nn = len(s)\narr=list(s)\n\nflag = False\nfor i in range(n+1):\n\tif flag:\n\t\tbreak\n\tfor c in string.ascii_lowercase:\n\t\tif flag:\n\t\t\tbreak\n\t\tarr.insert(i, c)\n\t\tif jud(arr):\n\t\t\tprint(''.join(arr))\n\t\t\tflag = True\n\t\tarr.pop(i)\nif not flag:\n\tprint('NA')\n"}, {"source_code": "def is_palindrome(s):\n return s == s[::-1]\ns=raw_input(\"\")\ny=len(s)-1\nx=0\nl=list(s)\nflag=0\ncheck=0\nif len(l)==2 and l[0]!=l[1]:\n l.insert(0,l[1])\n check=1\nwhile x<=y:\n if check==1:\n break\n if l[x]!=l[y]:\n if l[y-1]==l[x]:\n if x==0:\n l.insert(0,l[y])\n s3=''.join(l)\n if is_palindrome(s3):\n flag=1\n break\n else:\n l.remove(l[0])\n l.append(l[0])\n s4=''.join(l)\n if is_palindrome(s4):\n flag=1\n break\n flag=2\n break\n l.insert(x,l[y])\n flag=1\n elif l[y]==l[x+1]:\n l.insert(y+1,l[x])\n s3=''.join(l)\n if is_palindrome(s3):\n flag=1\n break\n else:\n flag=2\n break\n flag=1\n else:\n flag=2\n \n break\n x+=1\n y-=1\nif check==1:\n print ''.join(l)\nelif flag==0:\n s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]\n if len(l)%2==0:\n l=l[0:len(l)/2]\n else:\n l=l[0:len(l)/2+1]\n l.reverse()\n s=s+str(''.join(l))\n print s\nelif flag==1: \n s1=''.join(l)\n print s1\nelif flag==2:\n print \"NA\"\n "}, {"source_code": "def isPalin(s):\n\tif s==s[::-1] :\n\t\treturn True\n\telse :\n\t\treturn False\n\n\ns=raw_input()\n\nalpha='abcdefghijklmnopqrstuvwxyz'\ndone=False\nfor i in xrange(len(s)+1) :\n\tfor ch in alpha :\n\t\ts1=s[:i]+ch+s[i:]\n\t#\tprint \"s1\",s1\n\t\tif isPalin(s1) :\n\t\t\tprint s1\n\t\t\tdone=True\n\t\t\tbreak\n\tif done :\n\t\tbreak\nif not done :\n\tprint \"NA\"\n"}, {"source_code": "s = input()\nal = 'abcdefghijklmnopqrstuvwxyz'\nans = False\nfor i in range(26): ### it's just a o(1)\n for j in range(len(s)+1):\n tmp = s[:j]+al[i]+s[j:]\n \n if tmp==tmp[::-1]:\n print(tmp)\n exit()\nprint('NA')\n\n"}, {"source_code": "from sys import stdin\ndef ch(s):\n t = ''+s\n t = t[::-1]\n return t==s\nx = stdin.readline().strip()\nl = len(x)\nans = 'NA'\ny = 'abcdefghijklmnopqrstuvwxyz'\nfor i in xrange(l+1):\n fir = x[0:i] \n sec = x[i:l]\n for j in y:\n nn = fir + j + sec\n #print \"checking for \",nn\n if ch(nn):\n ans = nn\nprint ans\n "}, {"source_code": "from sys import stdin\n\ndef main():\n s = stdin.readline().rstrip()\n for i in range(len(s)+1):\n for j in range(26):\n copy = s[:]\n copy = s[0:i] + chr(j+ord('a')) + s[i:]\n if other_check(copy):\n print copy\n return\n print \"NA\"\n\ndef other_check(string):\n for i in range(len(string)//2):\n if not string[i]==string[-(i+1)]:\n return False\n return True\n\nmain()\n"}, {"source_code": "def check(word,i,j):\n while i<j:\n if word[i]!=word[j]:\n return False\n i=i+1\n j=j-1\n return True\nif __name__ == '__main__':\n word = raw_input()\n mid=(len(word)-1)//2\n if check(word,0,len(word)-1)==True:\n print word[:mid+1]+word[mid]+word[mid+1:]\n else:\n success=False\n i,j = 0,len(word)-1\n while word[i]==word[j]:\n i=i+1\n j=j-1\n if check(word,i,j-1)==True:\n print word[:i]+word[j]+word[i:]\n elif check(word,i+1,j)==True:\n print word[:j+1]+word[i]+word[j+1:]\n else:\n print 'NA'\n"}, {"source_code": "import sys\ndef verify(s):\n n = len(s)\n for i in xrange(n / 2):\n if (s[i] != s[n - 1 - i]): return 0\n return 1\n\ndef pr(s):\n for i in xrange(len(s)):\n sys.stdout.write('%s' % s[i])\n sys.stdout.write('\\n')\n\ns = list(raw_input())\nn = len(s)\nif (verify(s)):\n if (n % 2 == 0):\n s.insert(n / 2, 'a')\n else:\n s.insert(n / 2 + 1, s[n / 2])\n pr(s)\nelse:\n s2 = s[::-1]\n for i in xrange(n):\n if (s[i] != s2[i]):\n tmp1 = s[i]\n tmp2 = s2[i]\n s.insert(i, tmp2)\n s2.insert(i, tmp1)\n break\n if (verify(s)):\n pr(s)\n elif (verify(s2)):\n pr(s2)\n else:\n print 'NA'\n\n"}, {"source_code": "def palindrome(s):\n n=len(s)\n for i in range(n//2):\n if s[i]!=s[n-1-i]:\n return False\n return True\ns=input()\nn=len(s)\nfor i in range(n+1):\n for j in range(26):\n c=chr(ord('a')+j)\n tmp=''\n if i>0:\n tmp=s[0:i]\n tmp+=str(c)\n if i<=n-1:\n tmp+=s[i:]\n if palindrome(tmp):\n print(tmp)\n exit()\nprint('NA')"}, {"source_code": "def ispal(s):\n\ti = 0\n\tj = len(s) - 1\n\twhile i < j:\n\t\tif s[i] != s[j]:\n\t\t\treturn False\n\t\ti += 1\n\t\tj -= 1\n\treturn True\n\nalpha = 'abcdefghijklmnopqrstuvwxyz'\nfound = 0\ns = input()\nfor i in range(0,len(s)+1):\n\tfor j in range(len(alpha)):\n\t\ttemp = s[:i] + alpha[j] + s[i:]\n\t\tif ispal(temp):\n\t\t\tfound = 1\n\t\t\tprint(temp)\n\t\t\tbreak\n\tif found: \n\t\tbreak\nif not found:\n\tprint(\"NA\")"}, {"source_code": "s=input()\nn=len(s)\nfor i in range(n+1):\n for j in range(26):\n c=chr(ord('a')+j)\n tmp=''\n if i>0:\n tmp=s[0:i]\n tmp+=str(c)\n if i<=n-1:\n tmp+=s[i:]\n if tmp==tmp[::-1]:\n print(tmp)\n exit(0)\nprint('NA')"}, {"source_code": "s = input()\nfor i in range(26):\n for j in range(len(s)+1):\n s1 = s[:j]+chr(ord('a')+i)+s[j:]\n if s1[::-1] == s1:\n print (s1)\n exit(0)\nprint ('NA')"}, {"source_code": "s = raw_input(\"\")\nn = len(s)\ni = 0\nj = n - 1\ntries = 1\ns1 = s\nwhile s1[i] == s1[j] and i < n/2:\n i += 1\n j -= 1\ni1 = i\nj1 = j\ns1 = s[:i] + s[j] + s[i:]\nj += 1\n#print s1, i, j\nwhile s1[i] == s1[j] and i < n:\n i += 1\n j -= 1\n#print s1[i], s1[j], i, n\nif i == n:\n print s1\nelse:\n s2 = s[:j1+1] + s[i1] + s[j1+1:]\n #print s2, i, j\n #i += 1\n while s2[i] == s2[j] and i < n:\n i += 1\n j -= 1\n if i == n:\n print s2\n else:\n print \"NA\""}, {"source_code": "s = list(input())\nn = len(s)\ncandidates = [s + ['.']]\nres = 'NA'\n\nfor i in range(n):\n candidates.append(s[:i] + ['.'] + s[i:])\n\nfor s in candidates:\n legal = True\n for i in range((n + 1) // 2):\n if s[i] == s[-i-1] or s[i] == '.' or s[-i-1] == '.':\n continue\n legal = False\n if legal:\n res = s\n\nif res != 'NA':\n for i in range((n + 1) // 2):\n if res[i] == '.':\n res[i] = res[-i-1]\n elif res[-i-1] == '.':\n res[-i-1] = res[i]\n res = [s if s != '.' else 'a' for s in res]\n res = ''.join(res)\n\nprint(res)\n"}, {"source_code": "def isPalindrome(s):\n ns = len(s)\n for i in range(ns/2):\n if s[i] != s[ns - 1 - i]:\n return False\n return True\n\ndef sol():\n s = str(raw_input())\n ns = len(s)\n if isPalindrome(s):\n if ns % 2 == 0:\n print s[:(ns/2)] + 'a' + s[(ns/2):]\n else:\n print s[:(ns/2 + 1)] + s[(ns/2):]\n return\n\n for i in range(ns):\n if s[i] != s[ns - 1 - i]:\n if isPalindrome(s[i:ns-1-i]):\n print s[:i] + s[ns - 1 - i] + s[i:]\n else:\n if isPalindrome(s[i+1:ns-i]):\n print s[:ns - i] + s[i] + s[ns-i:]\n else:\n print 'NA'\n return\n\nsol()\n"}, {"source_code": "a = raw_input().strip()\nlena = len(a)\nnf = True\ni = 0\nwhile nf and i < lena:\n\tai = a[i]\n\t# print ai\n\tx = 0\n\twhile nf and x < (lena+1):\n\t\tp = a[:x]\n\t\tq = ai\n\t\tr = a[x:]\n\t\tpqr = p + q + r\n\t\ts = pqr[:(lena+1)/2]\n\t\tt = pqr[(lena+2)/2:][::-1]\n\t\t# print p,q,r,'->',pqr,'->',s,t\n\t\tif s == t:\n\t\t\tprint pqr\n\t\t\texit()\n\t\tx += 1\n\ti += 1\n\t# print\nprint \"NA\""}, {"source_code": "#\n# Uian Sol Gorgonio <sol.uian@gmail.com>\n# Feb 7 2015\n# Mr. Kitayuta's Gift\n# http://codeforces.com/contest/505/problem/A\n#\n# brute force\n#\n\ndef is_anagram(word):\n for i in xrange(len(word) / 2):\n if word[i] != word[-i-1]:\n return False\n return True\n\n\nword = list(raw_input())\n\nletters = list(set(word))\nfound = False\nfor letter in letters:\n for i in xrange(len(word) + 1):\n aux = word[::]\n aux.insert(i, letter)\n if is_anagram(aux):\n print ''.join(aux)\n found = True\n break\n\n if found: break\n \nif not found:\n print 'NA'\n"}, {"source_code": "x = input()\nd = False\nfor c in range(97,123):\n if ( d):\n break\n for i in range(len(x) + 1):\n n = x[:i] + chr(c) + x[i:]\n if n == n[::-1]:\n print (n)\n \n d= True\n break\n \nif (not d):\n print (\"NA\")\n"}, {"source_code": "import string \n\ns = raw_input()\n\nres = 'NA'\nfor i in range(len(s)+1):\n for v in string.lowercase:\n ss = s[:i]+v+s[i:]\n if ss == ss[::-1]:\n res = ss\n\nprint res\n"}, {"source_code": "s=input()\ni=0\ndef checkpa(st):\n if st==st[::-1]:\n return 1\n else:\n return 0\nwhile i<=len(s)-1 and s[i]==s[len(s)-1-i]:\n i+=1\nif i==len(s):\n if len(s)%2==0:\n print(s[:len(s)//2]+'a'+s[len(s)//2:])\n else:\n print(s[:len(s)//2]+s[len(s)//2]*2+s[len(s)//2+1:])\nelif i==0:\n s1=s[len(s)-1]+s\n s2=s+s[0]\n if checkpa(s1)==1:\n print(s1)\n elif checkpa(s2)==1:\n print(s2)\n else:\n print(\"NA\")\nelse:\n s1=s[:i]+s[len(s)-1-i]+s[i:]\n s2=s[:len(s)-i]+s[i]+s[len(s)-i:]\n if checkpa(s1)==1:\n print(s1)\n elif checkpa(s2)==1:\n print(s2)\n else:\n print(\"NA\")\n\n \n"}, {"source_code": "s = input()\ns1 = s[::-1]\np = False\n\ndef try1(a):\n q = s[:a] + s1[a] + s[a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\ndef try2(a):\n q = s[:len(s) - a] + s[a] + s[len(s) - a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\nfor i in range(len(s) // 2):\n if s[i] != s1[i]:\n if try1(i):\n q = s[:i] + s1[i] + s[i::]\n print(q)\n exit(0)\n elif try2(i):\n q = s[:len(s) - i] + s[i] + s[len(s) - i::]\n print(q)\n exit(0)\n else:\n p = True\n break\nif p:\n print(\"NA\")\nelse:\n d = s[:len(s) // 2] + s[len(s) // 2] + s[len(s) // 2::]\n print(d)\n"}, {"source_code": "s=raw_input()\nn=len(s)\nfl=0\nfor i in range(n):\n\ta=''\n\tfor j in range(n):\n\t\tif j!=i: a+=s[j]\n\tif a == a[::-1]:\n\t\tfl = 1\n\t\tans=''\n\t\tfor k in range(n):\n\t\t\tif k == n-i-1: \n\t\t\t\tif i > n/2:\n\t\t\t\t\tans+=s[i]\n\t\t\t\t\tans+=s[k]\n\t\t\t\telse:\n\t\t\t\t\tans+=s[k]\n\t\t\t\t\tans+=s[i]\t\t\t\t\t\n\t\t\telse: ans+=s[k]\n\t\tprint ans\n\t\tbreak\nif fl == 0: print 'NA'"}, {"source_code": "def isPalindrome(s):\n return s[::] == s[::-1]\n\n\nst = input()\ni = 0\nfor i in range(int(len(st) / 2)):\n if st[i] != st[len(st) - i - 1]:\n break\nsize = len(st)\nk = st[:i] + f\"{st[size - i - 1]}\" + st[i:]\ns1 = st[:size - i] + f\"{st[i]}\" + st[len(st) - i:]\ns2 = st[:int(size/2)+1] + f\"{st[int(size/2)]}\" + st[int(size/2)+1:]\n\n\nif isPalindrome(st):\n print(s2)\n\nelif isPalindrome(k):\n print(k)\n\nelif isPalindrome(s1):\n print(s1)\n\nelse:\n print(\"NA\")\n"}, {"source_code": "s=input()\nl=len(s)\nx=\"\"\nflag=0\nfor i in range(0,l+1):\n for j in range(97,123):\n z=s[0:i]+chr(j)+s[i:]\n y=z[::-1]\n\n if z==y:\n flag=1\n break\n if flag==1:\n break\nif flag==1:\n print(z)\nelse:\n print(\"NA\")\n"}, {"source_code": "def pal(s):\n\tl = 0\n\tr = len(s) - 1\n\twhile l < r:\n\t\tif s[l] != s[r]:\n\t\t\treturn False\n\t\tl += 1\n\t\tr -= 1\n\treturn True\n\n\ns = input()\n\nl = 0\nr = len(s) - 1\nf = True\nwhile l < r:\n\tif s[l] != s[r]:\n\t\ts1 = s[:l] + s[r] + s[l:]\n\t\ts2 = s[:r + 1] + s[l] + s[r + 1:]\n\t\tf = False\n\t\tbreak\n\tl += 1\n\tr -= 1\n\nif f:\n\tp = len(s) // 2\n\ts1 = s[:p] + s[p] + s[p:]\n\ts2 = s1\n\nif pal(s1):\n\tprint(s1)\nelif pal(s2):\n\tprint(s2)\nelse:\n\tprint('NA')"}, {"source_code": "s = input()\nfor i in range(26):\n for j in range(len(s) + 1) :\n ans = s[: j] + chr(97 + i) + s[j:]\n if ans == ans[::-1] :\n print(ans)\n exit()\nprint('NA')"}, {"source_code": "def is_palin(s):\n return s==s[::-1]\n\nletters='abcdefghijklmnopqrstuvwxyz'\ns=raw_input().strip()\nres='NA'\nfor i in letters:\n for j in range(len(s)+1):\n p=s[:j]+i+s[j:]\n # print p\n if is_palin(p):\n res=p\n \nprint res \n \n "}, {"source_code": "s = raw_input()\nn = len(s)\nans = \"\"\n \nfor x in s:\n if ans != \"\": break\n for i in range(n+1):\n word = s[:i] + x + s[i:]\n if word == word[::-1]:\n ans = word\n break\n \n\nif ans == \"\" : print \"NA\"\nelse : print ans\n\n "}, {"source_code": "from functools import reduce\nfrom operator import *\nfrom math import *\nfrom sys import *\nfrom string import *\nsetrecursionlimit(10**7)\nRI=lambda: list(map(int,input().split()))\nRS=lambda: input().rstrip().split()\n#################################################\ndef isPalindrome(a):\n\treturn a==a[::-1]\nx=RS()[0]\nfor i in range(len(x)+1):\n\ta,b= x[:i], x[i:]\n\tfor c in ascii_lowercase:\n\t\tif(isPalindrome(a+c+b)):\n\t\t\tprint(a+c+b)\n\t\t\texit(0)\nprint(\"NA\")\n"}, {"source_code": "s = input()\nf = 0\nalpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\nfor i in range(len(s)+1):\n for j in alpha:\n t = s[:i]+ j + s[i:]\n if t==t[::-1]:\n print(t)\n exit()\n \nprint('NA')"}, {"source_code": "import string\n\ndef main():\n s = input()\n for i in range(len(s)+1):\n for a in string.ascii_lowercase:\n ns = s[:i] + a + s[i:]\n if ns == ns[::-1]:\n print(ns)\n return\n print(\"NA\")\n\nif __name__ == '__main__':\n main() "}, {"source_code": "string = list(input())\n\nfor i in range(len(string)):\n cur = ord('a')\n for let in range(26):\n ins = chr(cur+let)\n string.insert(i, ins)\n if string == string[::-1]:\n print(''.join(string))\n exit()\n del string[i]\nelse:\n for let in range(26):\n ins = chr(cur+let)\n string.append(ins)\n if string == string[::-1]:\n print(''.join(string))\n exit()\n del string[len(string) - 1]\n print('NA')\n"}, {"source_code": "import random\nimport string\n\nallAlp = string.ascii_letters[:26]\n\ndef isPalin(x):\n return x == x[::-1]\n\ndef getLen(x): \n\treturn len(x)\n\ndef main():\n someInput = str(raw_input())\n \n if (getLen(someInput) == 1):\n result = someInput*2\n else: \n result = makePalin(someInput)\n return result\n\ndef makePalin(x):\n for i in range(getLen(x) + 1):\n for alp in allAlp:\n newString = newStringAtPos(x, i, alp)\n \n if isPalin(newString):\n return newString \n\n\ndef newStringAtPos(x, pos, newAlp):\n y = x[:(pos)] + newAlp + x[(pos):]\n return y\n\n\nresult = main() \n\nif result == None:\n print 'NA'\nelse: \n print result\n\n"}, {"source_code": "st1 = input()\na = len(st1)+1\nfor i in range(26):\n for j in range(a):\n st2 = st1[:j] + chr(i+97) + st1[j:]\n if(st2==st2[::-1]):\n print(st2)\n exit()\nprint(\"NA\")"}, {"source_code": "def is_pal(s):\n return s == s[::-1]\n\ndef main():\n s = raw_input()\n n = len(s)\n for i in xrange(n + 1):\n for j in xrange(26):\n c = chr(ord('a') + j)\n new_word = s[:i] + c + s[i:]\n if is_pal(new_word):\n print new_word\n return\n print \"NA\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a=input()\ndead=False\nsemidead=False\nfr=0\nind=None\nd=0\nfor i in range(len(a)//2):\n\tif a[i-min(fr,0)]!=a[-i-1-max(fr,0)]:\n\t\tif d==0:\n\t\t\tif a[i]==a[-i-2]:\n\t\t\t\tfr=1\n\t\t\t\tind=i\n\t\t\t\td+=1\n\t\t\telif a[i+1]==a[-i-1]:\n\t\t\t\tfr=-1\n\t\t\t\tind=len(a)-i-1\n\t\t\t\td+=1\n\t\t\telse:\n\t\t\t\tdead=True\n\t\t\t\tprint('NA')\n\t\t\t\tbreak\n\t\telse:\n\t\t\tsemidead=True\n\t\t\tbreak\nif semidead:\n\td=0\n\tfr=0\n\tfor i in range(len(a)//2):\n\t\tif a[i-min(fr,0)]!=a[-i-1-max(fr,0)]:\n\t\t\tif d==0:\n\t\t\t\tif a[i]==a[-i-2]:\n\t\t\t\t\tif fr!=-1:\n\t\t\t\t\t\tif a[i+1]==a[-i-1]:\n\t\t\t\t\t\t\tfr=-1\n\t\t\t\t\t\t\tind=len(a)-i-1\n\t\t\t\t\t\t\td+=1\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\tdead=True\n\t\t\t\t\t\t\tprint('NA')\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\telse:\n\t\t\t\t\t\tind=i\n\t\t\t\t\t\td+=1\n\t\t\t\telif a[i+1]==a[-i-1]:\n\t\t\t\t\tif fr!=1:\n\t\t\t\t\t\tdead=True\n\t\t\t\t\t\tprint('NA')\n\t\t\t\t\t\tbreak\n\t\t\t\t\tind=len(a)-i-1\n\t\t\t\t\td+=1\n\t\t\t\telse:\n\t\t\t\t\tdead=True\n\t\t\t\t\tprint('NA')\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tdead=True\n\t\t\t\tprint('NA')\n\t\t\t\tbreak\nif not dead:\n\tif d==0:\n\t\tprint(a[0:len(a)//2],a[len(a)//2],a[len(a)//2::],sep='')\n\telif fr==1:\n\t\tprint(a[0:ind],a[-1-ind],a[ind::],sep='')\n\telse:\n\t\tprint(a[0:ind+1],a[len(a)-1-ind],a[ind+1::],sep='')"}, {"source_code": "s = input()\n\n\ndef isPalindrome(l):\n if len(l) == 0 or len(l) == 1:\n return True\n if l[0] != l[-1]:\n return False\n else:\n return isPalindrome(l[1:len(l) - 1])\n\n\nfor i in range(len(s) + 1):\n for j in range(26):\n x = s[0:i] + str(chr(97 + j)) + s[i:]\n if isPalindrome(x):\n print(x)\n quit()\n\nprint('NA')\n"}, {"source_code": "#br = open('a.in')\ns = raw_input().strip()\nn = len(s)\nfor i in range(n + 1):\n for j in range(0, 26):\n t = s[:i] + chr(j + 97) + s[i:]\n if t == t[::-1]:\n print t\n exit()\nprint \"NA\"\n\n\n"}, {"source_code": "def pal(b):\n size = len(b)\n for i in xrange(size/2):\n if b[i] != b[size-1-i]:\n return False\n return True\n\na = raw_input()\nsize = len(a)\nalp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\ndone = False\nfor i in xrange(size+1):\n for j in alp:\n if pal(a[:i] + j + a[i:]):\n print a[:i] + j + a[i:]\n done = True\n break\n if done:\n break\nif not done:\n print 'NA'\n"}, {"source_code": "from sys import stdin,stdout\n# from collections import deque,Counter,defaultdict\n# from itertools import permutations,combinations,combinations_with_replacement\n# from operator import itemgetter\n# import heapq\n# from functools import reduce\ndef ii():return int(stdin.readline())\ndef mi():return map(int,stdin.readline().split())\ndef li():return list(mi())\ndef si():return stdin.readline()\n\ndef ispal(s):\n n = len(s)//2\n if s[:n] == s[-n:][::-1]:\n return True\n else:\n return False\n \ns1 = input()\nfor i in range(len(s1)+1):\n for j in range(ord('a'),ord('z')+1):\n s2 = s1[:i] + chr(j) + s1[i:]\n # print(s2)\n if ispal(s2):\n print(s2)\n exit(0)\nprint('NA')\n"}, {"source_code": "s=raw_input()\n#print s\n\nfor i in range(26):\n for j in range(len(s)+1):\n t=s[:j]+chr(i+97)+s[j:]\n \n if t==t[::-1]:\n print t\n exit(0)\nprint \"NA\"\n"}, {"source_code": "def main():\n l = list(input())\n l.append(None)\n for i in range(len(l) - 1, -1, -1):\n for c in 'abcdefghijklmnopqrstuvwxyz':\n l[i] = c\n if l == l[::-1]:\n print(''.join(l))\n return\n l[i] = l[i - 1]\n print('NA')\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "s = input()\nn = len(s)\nfor _ in range(n+1):\n s1 = s[:_]+'!'+s[_:]\n s2 = s1[::-1]\n a = '?'\n for i in range(n+1):\n if s1[i]=='!' and s2[i]!='!':\n if a=='?':\n a = s2[i]\n else:\n if s2[i]==a:\n print(s[:_]+a+s[_:])\n exit(0)\n else:\n print('NA')\n exit(0)\n elif s1[i]!='!' and s2[i]=='!':\n if a=='?':\n a = s1[i]\n else:\n if s1[i]==a:\n print(s[:_]+a+s[_:])\n exit(0)\n else:\n print('NA')\n exit(0)\n elif s1[i]==s2[i]=='!':\n print(s[:_]+'a'+s[_:])\n exit(0)\n else:\n if s1[i]!=s2[i]:\n break\nprint('NA')"}, {"source_code": "s=list(raw_input())\nalphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\ndef loop(s):\n for i in range (len(s)+1):\n for j in alphabet:\n result=True\n ss=s[:i]+[j]+s[i:len(s)]\n for k in range (len(ss)/2+1):\n if ss[k]!=ss[len(ss)-1-k]:\n result=False\n break\n if result:\n return ''.join(ss)\n return \"NA\"\nprint loop(s)\n"}, {"source_code": "n=list(raw_input())\nfor i in xrange(len(n)+1):\n for j in xrange(97,123):\n k=n[:]\n k.insert(i,chr(j))\n chk=''.join(k)\n if chk==chk[::-1]:\n print chk\n exit()\nprint 'NA'"}, {"source_code": "def palin(word):\n\tfor letter in 'abcdefghijklmnopqrstuvwxyz':\n\t\tfor i in range(len(word)+1):\n\t\t\tnew=word[:i]+letter+word[i:]\n\t\t\tif new[::-1]==new:\n\t\t\t\treturn new\n\treturn 'NA'\t\n\n\nword=raw_input()\nprint palin(word)\n"}, {"source_code": "s = input()\nf = 0\nalpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\nfor i in range(len(s)+1):\n for j in alpha:\n t = s[:i]+ j + s[i:]\n if t==t[::-1]:\n print(t)\n exit()\n \nprint('NA')"}, {"source_code": "def palin(n):\n if(str(n) == str(n)[::-1]):return True\n else: return False\ndef helpme(s):\n flag=0\n l=len(s)\n till=l/2+(l%2)+1\n for i in range(till):\n if(s[i]!=s[l-1-i]):\n x=s[i:l-1-i]\n y=s[i+1:l-2]\n #print x, y\n if(palin(x)):\n z=s[:i]+s[l-1-i]+s[i:]\n if(palin(z)):\n print z\n flag=1\n return True\n else: return False\n if(flag==0):\n if(palin(y)):\n z=s[:l-i]+s[i]+s[l-i:]\n if(palin(z)):\n print z\n flag=1\n return True\n else: return False\n return False\ns=raw_input()\nl=len(s)\nif(palin(s)):\n if(l%2==0):\n b=s[:l/2]\n #print b\n print b+'a'+b[::-1]\n else:\n b=s[:l/2+1]\n #print b\n print b+b[::-1]\nelse:\n flag=0\n x=s[1:]\n y=s[:l-1]\n #print x, y\n if(palin(x)):\n print s+s[0]\n flag=1\n if(flag==0):\n if(palin(y)):\n print s[l-1]+s\n flag=1\n if(flag==0):\n if(helpme(s)):flag=1\n if(flag==0):\n print \"NA\""}, {"source_code": "def is_palin(s):\n\treturn s == s [::-1]\n\ns = raw_input()\nflg = 0\nfor i in range(97, 97+26):\n\tfor j in range(0, len(s)+1):\n\t\tif is_palin(s[:j]+chr(i)+s[j:]):\n\t\t\tprint s[:j]+chr(i)+s[j:]\n\t\t\tflg = 1\n\t\t\tbreak\n\tif flg==1:\n\t\tbreak\n\nif flg==0:\n\tprint 'NA'"}, {"source_code": "def f(s):\n at = -1\n for i, v in enumerate(s):\n if v == '@':\n at = i\n continue\n if v != s[-i - 1] and s[-i - 1] != '@':\n return False\n s[at] = s[-at - 1]\n return ''.join(s)\n\ns = list(input())\nfor i in range(len(s) + 1):\n s.insert(i, '@')\n a = f(s)\n if a:\n print(a)\n break\n del s[i]\nelse:\n print('NA')\n"}, {"source_code": "def palin(sr):\n sr1=sr[::-1]\n return(sr==sr1)\ns=input()\ni=0\nj=len(s)-1\nif(j==0):\n print(s*2)\nelse:\n while(i<j and s[i]==s[j]):\n i=i+1\n j=j-1\n if(i<j):\n s1=s[0:i]+s[j]+s[i:(j+1)]+s[(j+1):]\n s2=s[0:i]+s[i:(j+1)]+s[i]+s[(j+1):]\n if(palin(s1) or palin(s2)):\n if(palin(s1) and palin(s2)==False):\n print(s1)\n if(palin(s2) and palin(s1)==False):\n print(s2)\n if(palin(s1) and palin(s2)):\n print(s1)\n else:\n print(\"NA\")\n if(i==j):\n s4=s[0:i]+s[i]+s[i]+s[(j+1):]\n print(s4)\n if(i>j):\n s3=s[0:i]+'a'+s[(j+1):]\n print(s3)\n"}, {"source_code": " \nword = input().strip()\n\ndef testPalindrome(word):\n\tlength = len(word)\n\tfor x in range(int(length/2)):\n\t\tif (word[x] != word[length - 1 - x]):\n\t\t\treturn False\n\treturn True\n\ndef reverseString(word):\n\treturn word[::-1]\n\ndef findIndex(word1, word2):\n\tlength = len(word1)\n\tfor i in range(length):\n\t\tif (word1[i] != word2[i]):\n\t\t\treturn i\n\treturn -1\n\ndef findDiffIndex(word):\n\tnewString = \"\"\n\tif(len(word) % 2 == 0):\n\t\tfirst, second = word[:int(len(word)/2)], word[int(len(word)/2):][::-1]\n\t\t# print(first, second)\n\t\ta = findIndex(first, second)\n\t\tif (a == -1):\n\t\t\tnewString = first + 'x' + second[::-1]\n\t\t\tprint(newString)\n\t\telse:\n\t\t\tnewString = first[:a] + second[a] + first[a:] + second[::-1]\n\t\t\t# print(newString)\n\t\t\tif(testPalindrome(newString)):\n\t\t\t\tprint(newString)\n\t\t\telse:\n\t\t\t\tnewString = first + second[a:][::-1] + first[a] + second[:a][::-1]\n\t\t\t\t# print(newString)\n\t\t\t\tif(testPalindrome(newString)):\n\t\t\t\t\tprint(newString)\n\t\t\t\telse:\n\t\t\t\t\tprint('NA')\n\telse:\n\t\tfirst, second = word[:int(len(word)/2)], word[int(len(word)/2)+1:][::-1]\n\t\ta = findIndex(first, second)\n\t\t# print(first, second, a)\n\t\tmidChar = word[int(len(word)/2)]\n\t\tif (a == -1):\n\t\t\tnewString = first + midChar + midChar + second[::-1]\n\t\t\tprint(newString)\n\t\telse:\n\t\t\tnewString = first[:a] + second[a] + first[a:] + midChar + second[::-1]\n\t\t\t# print(newString)\n\t\t\tif(testPalindrome(newString)):\n\t\t\t\tprint(newString)\n\t\t\telse:\n\t\t\t\tnewString = first + midChar + second[a:][::-1] + first[a] + second[:a][::-1]\n\t\t\t\t# print(first, second[a:][::-1], midChar, first[a], second[:a][::-1])\n\t\t\t\t# print(newString)\n\t\t\t\tif(testPalindrome(newString)):\n\t\t\t\t\tprint(newString)\n\t\t\t\telse:\n\t\t\t\t\tprint('NA')\t\t\n\n# print(word)\n# print(len(word))\n\nfindDiffIndex(word)\n\n"}, {"source_code": "import string\n\ndef solve(s):\n\tfor i in range(len(s)):\n\t\tfor x in string.ascii_lowercase:\n\t\t\tt = s[:i] + x + s[i:]\n\t\t\tif t == t[::-1]:\n\t\t\t\treturn t\n\tfor x in string.ascii_lowercase:\n\t\t\tt = s + x \n\t\t\tif t == t[::-1]:\n\t\t\t\treturn t\n\t\t\t\n\treturn \"NA\"\n\n\ns = raw_input()\nprint solve(s)"}, {"source_code": "def noteven_chars(word):\n\tchars = {}\n\tfor c in word:\n\t\tchars[c] = chars.get(c, 0) + 1\n\treturn [x for x in chars.keys() if chars[x] % 2 == 1]\n\ndef combinations(word, c):\n\tans = [word[0:x] + c + word[x:] for x in range(0, len(word)+1)]\n\treturn ans\n\t\n\nword = raw_input().strip()\nnoteven = noteven_chars(word)\n\n# at most 1 letter to add + random one in middle\nif len(noteven) <= 2:\n\tnoteven.append(word[0])\n\tvalid_words = []\n\tfor c in noteven:\n\t\tvalid_words.extend(combinations(word, c))\n\n\t# The exotic python for-else\n\tfor cw in valid_words:\n\t\tif cw == cw[::-1]:\n\t\t\tprint(cw)\n\t\t\tbreak\n\telse:\n\t\tprint(\"NA\")\nelse:\n\tprint(\"NA\")"}, {"source_code": "s=raw_input()\nl=len(s)\nx=\"\"\nflag=0\nfor i in range(0,l+1):\n for j in range(97,123):\n z=s[0:i]+str(unichr(j))+s[i:]\n y=z[::-1]\n if z==y:\n flag=1\n break\n if flag==1:\n break\nif flag==1:\n print z\nelse:\n print \"NA\"\n \n"}, {"source_code": "#!/usr/bin/env python3\n\n# -----------\n# Kitayuta.py\n# -----------\n\n\"\"\"\nA. Mr. Kitayuta's Gift\nhttp://codeforces.com/problemset/problem/505/A/\n\nMon, 14 Sep 2015\nPython 3.4: 77 ms, 500 KB\n\"\"\"\n\nfrom string import ascii_lowercase\nfrom sys import stdin\n\ndef is_palindrome(s) :\n return s == s[::-1]\n\ndef test_case (s) :\n for i in range(len(s) + 1) :\n j = -i - (1 if (i <= len(s) / 2) else 0)\n c = s[j]\n t = s[:i] + c + s[i:]\n if is_palindrome(t) :\n print(t)\n return\n print(\"NA\")\n\ndef main () :\n for s in stdin :\n test_case(s[:-1])\n\nif __name__ == \"__main__\" :\n main()\n"}, {"source_code": "s = input()\nl = len(s)\nfor i in range(l + 1):\n cur = s[:i] + s[l - i - 1 + (i > l // 2)] + s[i:]\n if all(cur[i] == cur[l - i] for i in range((l + 1) // 2)):\n print(cur), exit()\nprint('NA')\n"}, {"source_code": "import sys \n\ns = raw_input()\nn = len(s)\n\nfor i in range(0,n+1):\n\ts1 = s[:i]\n\ts2 = s[i:]\n\tfor j in range(ord('a'),ord('z')+1):\n\t\ttemp1 = s1 + chr(j) + s2\n\t\ttemp2 = temp1[::-1]\n\t\tif temp1 == temp2:\n\t\t\tprint temp1\n\t\t\tsys.exit()\n\nprint \"NA\""}, {"source_code": "x = raw_input()\nn = len(x)\ndef isPalin(s):\n\tk = len(s)\n\ti = 0\n\twhile i<=k/2:\n\t\tif s[i] != s[k-i-1]:\n\t\t\treturn 0\n\t\ti+=1\n\treturn 1\ndef dothis(s,c):\n\t# very bad :-(\n\t#print \"dothis ->\",s,c\n\tfor i in range(n+1):\n\t\tp = s[:i]+c+s[i:]\n\t\t#print \"checkingz: \",p\n\t\tif(isPalin(p)):\n\t\t\treturn p\n\t#print \"This should neverever get printed!!!\"\n\treturn \"NA\" \n\ndef doinsane(s):\n\tmm = set(s)\n\tfor i in mm:\n\t\tans = dothis(s,i)\n\t\tif ans != \"NA\":\n\t\t\treturn ans\n\treturn \"NA\"\n\ndef solve(s):\n\tss = [s[i] for i in range(n)]\n\tm = {}\n\tcount = 0\n\tif n ==1 :\n\t\treturn s+s\n\tfor i in ss:\n\t\tif i in m:\n\t\t\tm.pop(i)\n\t\telse:\n\t\t\tm[i] = count\n\t\tcount+=1\n\t\n\tif(isPalin(s)):\n\t\tif n%2:\n\t\t\tif len(m)==1:\n\t\t\t\treturn dothis(s,max(m))\n\t\t\telse:\n\t\t\t\treturn \"NA\"\n\t\telse:\n\t\t\treturn s[:n/2]+'a'+s[n/2:]\n\telse:\n\t\tk = len(m)\n\t\tif k > 2:\n\t\t\treturn \"NA\"\n\t\tif k == 2:\n\t\t\tfor i in m:\n\t\t\t\tans = dothis(s,i)\n\t\t\t\tif ans != 'NA':\n\t\t\t\t\treturn ans\n\t\t\treturn \"NA\"\n\t\t\t\"\"\"if n%2 == 0:\n\t\t\t\treturn dothis(s,c)\n\t\t\telse:\n\t\t\t\treturn \"NA\" \"\"\"\n\t\tif k==1 : # has to be odd\n\t\t\tc = max(m)\n\t\t\treturn dothis(s,c)\n\t\tif k==0:\n\t\t\tif n%2:\n\t\t\t\treturn \"NA\"\n\t\t\telse:\n\t\t\t\treturn doinsane(s) #this is harsh\t\n\t\treturn \"NA\" # ???\n\nprint solve(x)\n"}, {"source_code": "def pal(a):\n ctr = 0\n while ctr < len(a)/2:\n if a[ctr] != a[len(a)-ctr-1]:\n return False\n ctr+=1\n return True\n\na = input()\nalp = []\np = 'NA'\nif not len(a) > 10 or len(a) < 1:\n if a.islower():\n for char in a:\n if not char in alp:\n alp.append(char)\n length = len(a)\n for char in alp:\n ctr = 0\n while ctr <= length: \n new = a[:ctr] + char + a[ctr:]\n if pal(new):\n p = new\n ctr+=1\n\n print(p)\n\n"}, {"source_code": "def ispal(st):\n for i in xrange(len(st)):\n if st[i] != st[-(i+1)]:\n return False\n return True\n\ndef oneDif(first,second):\n# print first,second\n s1 = ''\n s2 = ''\n if len(first) > len(second):\n s1 = first\n s2 = second\n else:\n s1 = second\n s2 = first\n missing = ''\n pos = 0\n j = len(s2)-1\n for i in xrange(len(s1)):\n if s1[i] == s2[j]:\n j -= 1\n elif len(missing) == 0:\n missing = s1[i]\n pos = j+1\n else:\n return ''\n if len(missing) == 0:\n missing = s1[i]\n res = ''\n # print missing,pos\n if pos == len(s2):\n res = s2 + missing\n else:\n for i in xrange(len(s2)):\n s = s2[i]\n if i != pos:\n res += s\n else:\n res += missing\n res += s\n# print res,s1,s2\n if first == s1:\n return s1+res\n else:\n return res+s1\n \n \n\ns = raw_input()\nif len(s) == 2:\n print s + s[0]\nelse:\n if len(s)%2 == 0:\n if ispal(s):\n print s[:len(s)/2]+'a'+s[len(s)/2:]\n else:\n done = False\n check = [len(s)/2,(len(s)/2)-1]\n for c in check:\n first = s[:c]\n second = s[c+1:]\n res = oneDif(first,second)\n if len(res) > 0:\n print res[:len(res)/2]+s[c]+res[len(res)/2:]\n done = True\n break\n if not done:\n print 'NA' \n \n else: \n done = False\n if ispal(s):\n mid = len(s)/2\n print s[:mid]+s[mid]+s[mid:]\n else:\n check = [len(s)/2,(len(s)/2)+1]\n for c in check:\n first = s[:c]\n second = s[c:]\n # print c,first,second\n res = oneDif(first,second)\n if len(res) > 0:\n print res\n done = True\n break\n if not done:\n print 'NA' \n \n \n"}, {"source_code": "palindrom = lambda s: s == s[::-1]\nprintans = lambda l: print(''.join(l))\ns = list(input())\n\nfor i in range(len(s)+1):\n for letter in 'abcdefghijklmnopqrstvwuxyz':\n tmp = s[:]\n tmp.insert(i,letter)\n if palindrom(tmp):\n printans(tmp)\n exit()\n\nprint('NA')"}, {"source_code": "s = input()\n\nfor i in range(26):\n a = chr(ord('a') + i)\n for j in range(len(s)):\n temp = s[:j] + a + s[j:]\n if temp == temp[::-1]:\n print(temp)\n exit(0)\n temp = s + a\n if temp == temp[::-1]:\n print(temp)\n exit(0)\nprint(\"NA\")"}, {"source_code": "from pip._vendor.distlib.compat import raw_input\nL = raw_input()\nl = 0\nr = len(L)-1\nflag = 1\nok = 1\ngg = -1\nwhile l <= r:\n if L[l] != L[r] and flag == 1:\n flag = 0\n l+=1\n gg = r\n elif L[l] != L[r] and flag == 0: \n ok = 0\n break\n else:\n l+=1\n r-=1\nl = 0\nr = len(L)-1\nif ok == 0:\n ok = 2\n flag = 2\n while l <= r:\n if L[l] != L[r] and flag == 2:\n flag = 0\n r-=1\n gg = l\n elif L[l] != L[r] and flag == 0:\n ok = 0\n break\n else:\n l+=1\n r-=1\nif len(L) == 3:\n l = set(L)\n if len(l) == 3:\n ok = 0\nif ok == 0:\n print(\"NA\")\n exit()\nif gg == -1:\n gg = len(L)//2\ngg = int(gg)\nif ok == 2:\n for i in range(0,len(L)):\n if(i == gg):\n print(L[len(L)-gg-1],end = '')\n print(L[i],end = '')\nif ok == 1:\n for i in range(0,len(L)):\n print(L[i],end = '')\n if(i == gg):\n print(L[len(L)-1-gg],end = '')\n\n "}, {"source_code": "def palindrom(s):\n n = len(s)\n for num in range(n):\n if s[num] != s[n - num - 1]:\n return 0\n return 1\ns = input()\nn = len(s)\nwords = \"abcdefghjklmnpoqrstvwxyziuy\"\nyes = 0\ns1 = \"\"\nfor i in range(n+1):\n for j in words:\n if palindrom(s[:i]+j+s[i:]) == 1:\n s1 = s[:i]+j+s[i:]\n yes = 1\n break\n if yes == 1:\n break\nif s1 == \"\":\n print(\"NA\")\nelse:\n print(s1)\n"}, {"source_code": "\ns = list(input())\nn = len(s)\ncandidates = [s + ['.']]\nres = 'NA'\n\nfor i in range(n):\n candidates.append(s[:i] + ['.'] + s[i:])\n\nfor s in candidates:\n legal = True\n for i in range((n + 1) // 2):\n if s[i] == s[-i-1] or s[i] == '.' or s[-i-1] == '.':\n continue\n legal = False\n if legal:\n res = s\n\nif res != 'NA':\n for i in range((n + 1) // 2):\n if res[i] == '.':\n res[i] = res[-i-1]\n elif res[-i-1] == '.':\n res[-i-1] = res[i]\n res = [s if s != '.' else 'a' for s in res]\n res = ''.join(res)\n\nprint(res)"}, {"source_code": "s,x=list(input()),0\na=s[:]\nfor i in range(len(s)):\n if s[i]!=s[len(s)-1-i]:\n x=1\n a.insert(i,s[len(s)-1-i])\n s.insert(len(s)-i,s[i])\n break\nif(x):\n x=0\n for i in range(len(s)):\n if s[i]!=s[len(s)-i-1]:\n x=1\n break\n if(x):\n x=0\n for i in range(len(a)):\n if a[i]!=a[len(a)-i-1]:\n x=1\n break\n if(x):print(\"NA\")\n else:print(\"\".join(a))\n else:print(\"\".join(s))\nelse:\n s.insert(int(len(s)/2),s[int(len(s)/2)])\n print(\"\".join(s))"}, {"source_code": "a=input()\nfor i in range(26):\n for j in range(len(a)+1):\n b=a[:j]+chr(97+i)+a[j:]\n if b==b[::-1]:print(b);exit()\nprint('NA')"}], "negative_code": [{"source_code": "def main():\n s = raw_input()\n l = len(s)\n if s == s[::-1]:\n print s[0:l/2]+\"y\"+s[l/2:]\n else:\n for i in xrange(len(s)):\n if s[i] != s[l-i-1]:\n ns = s[0:i]+s[l-i-1]+s[i:l]\n if ns == ns[::-1]:\n print ns\n return\n ns = s[0:l-i]+s[i]+s[l-i:l]\n if ns == ns[::-1]:\n print ns\n return\n print \"NA\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def ispal(st):\n for i in xrange(len(st)):\n if st[i] != st[-(i+1)]:\n return False\n return True\n\ndef oneDif(first,second):\n# print first,second\n s1 = ''\n s2 = ''\n if len(first) > len(second):\n s1 = first\n s2 = second\n else:\n s1 = second\n s2 = first\n missing = ''\n pos = 0\n j = len(s2)-1\n for i in xrange(len(s1)):\n if s1[i] == s2[j]:\n j -= 1\n elif len(missing) == 0:\n missing = s1[i]\n pos = j+1\n else:\n return ''\n if len(missing) == 0:\n missing = s1[i]\n res = ''\n # print missing,pos\n if pos == len(s2):\n res = s2 + missing\n else:\n for i in xrange(len(s2)):\n s = s2[i]\n if i != pos:\n res += s\n else:\n res += missing\n res += s\n# print res\n if ispal(s1+res):\n return s1+res\n elif ispal(res+s1):\n return res+s1\n \n \n\ns = raw_input()\nif len(s) == 2:\n print s + s[0]\nelse:\n if len(s)%2 == 0:\n if ispal(s):\n print s[:len(s)/2]+'a'+s[len(s)/2:]\n else:\n done = False\n check = [len(s)/2,(len(s)/2)-1]\n for c in check:\n first = s[:c]\n second = s[c+1:]\n res = oneDif(first,second)\n if len(res) > 0:\n print res[:len(res)/2]+s[c]+res[len(res)/2:]\n done = True\n break\n if not done:\n print 'NA' \n \n else: \n done = False\n if ispal(s):\n mid = len(s)/2\n print s[:mid]+s[mid]+s[mid:]\n else:\n check = [len(s)/2,(len(s)/2)+1]\n for c in check:\n first = s[:c]\n second = s[c:]\n # print c,first,second\n res = oneDif(first,second)\n if len(res) > 0:\n print res\n done = True\n break\n if not done:\n print 'NA' \n \n \n"}, {"source_code": "import sys\n\ns = input()\nlist_s = list(s)\n# print(list_s)\nif s + s[0] == s[0] + s[::-1]:\n print(s + s[0])\n sys.exit()\nelse:\n for x in range(len(s)):\n polindrom = list_s[:x] + list(s[-(x + 1)]) + list_s[x:]\n if polindrom == polindrom[::-1]:\n print(''.join(polindrom))\n sys.exit()\nprint('NA')\n"}, {"source_code": "def main():\n s = raw_input()\n l = len(s)\n if l == 1:\n print s+s\n elif s == s[::-1]:\n print s[0:l/2]+\"y\"+s[l/2:]\n else:\n for i in xrange(len(s)):\n if s[i] != s[l-i-1]:\n ns = s[0:i]+s[l-i-1]+s[i:l]\n if ns == ns[::-1]:\n print ns\n return\n ns = s[0:l-i]+s[i]+s[l-i:l]\n if ns == ns[::-1]:\n print ns\n return\n print \"NA\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\nimport string\n\ndef is_palindrome(s):\n if s == s[::-1]:\n return True\n else:\n return False\n\ndef main():\n s = raw_input()\n # print string.ascii_lowercase\n if len(s) == 1:\n print s + s\n sys.exit(0)\n\n else:\n for c in string.ascii_lowercase:\n new_s = c + s[1:]\n if is_palindrome(new_s):\n print new_s\n sys.exit(0)\n for i in xrange(len(s)):\n new_s = s[:i+1] + c + s[i+1:]\n if is_palindrome(new_s):\n print new_s\n sys.exit(0)\n print \"NA\"\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "__author__ = 'Ahmad'\ndef is_mot(s):\n j=0\n i=-1\n while j<len(s):\n if s[j]!=s[i]:\n return 0\n i-=1\n j+=1\n else:\n return 1\ndef main():\n s=raw_input()\n k=s\n j=0\n if is_mot(k)==1:\n if len(k)%2==0:\n print k[0:(len(k)/2)]+'x'+k[(len(k)/2):]\n else:\n print 'NA'\n return 0\n\n while len(s)>0:\n if s[0]!=s[-1]:\n break\n else:\n s=s[1:-1]\n j+=1\n t=s\n if is_mot(t[1:])==1:\n if j==0:\n print t+t[0]\n else:\n print k[:j]+t+t[0]+k[-j:]\n else:\n if is_mot(t[:-2])==1:\n if j==0:\n print t[-1]+t\n else:\n print k[:j]+t[-1]+t+k[-j:]\n else:\n print 'NA'\n return 0\n\nmain()\n\n\n\n"}, {"source_code": "def palin(sr):\n sr1=sr[::-1]\n return(sr==sr1)\ns=input()\ni=0\nj=len(s)-1\nwhile(i<j and s[i]==s[j]):\n i=i+1\n j=j-1\nif(i<j):\n s1=s[0:i]+s[j]+s[i:(j+1)]+s[(j+1):]\n s2=s[0:i]+s[i:(j+1)]+s[i]+s[(j+1):]\n if(palin(s1) or palin(s2)):\n if(palin(s1)):\n print(s1)\n if(palin(s2)):\n print(s2)\n else:\n print(\"NA\")\nif(i==j):\n print(\"NA\")\nif(i>j):\n s3=s[0:i]+'a'+s[(j+1):]\n print(s3)\n"}, {"source_code": "def is_palindrome(s):\n return s == s[::-1]\ns=raw_input(\"\")\ny=len(s)-1\nx=0\nl=list(s)\nflag=0\ncheck=0\nif len(l)==2 and l[0]!=l[1]:\n l.insert(0,l[1])\n check=1\nwhile x<=y:\n if check==1:\n break\n if l[x]!=l[y]:\n if l[y-1]==l[x]:\n if x==0:\n l.insert(0,l[y])\n s3=''.join(l)\n if is_palindrome(s3):\n flag=1\n break\n else:\n flag=2\n break\n l.insert(x,l[y-1])\n flag=1\n elif l[y]==l[x+1]:\n l.insert(y+1,l[x])\n flag=1\n else:\n flag=2\n \n break\n x+=1\n y-=1\nif check==1:\n print ''.join(l)\nelif flag==0:\n s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]\n if len(l)%2==0:\n l=l[0:len(l)/2]\n else:\n l=l[0:len(l)/2+1]\n l.reverse()\n s=s+str(''.join(l))\n print s\nelif flag==1: \n s1=''.join(l)\n print s1\nelif flag==2:\n print \"NA\"\n "}, {"source_code": "from functools import reduce\nfrom operator import *\nfrom math import *\nfrom sys import *\nfrom string import *\nsetrecursionlimit(10**7)\nRI=lambda: list(map(int,input().split()))\nRS=lambda: input().rstrip().split()\n#################################################\ndef isPalindrome(a):\n\treturn a==a[::-1]\nx=RS()[0]\nfor i in range(1,len(x)+1):\n\ta,b= x[:i], x[i:]\n\tfor c in ascii_lowercase:\n\t\tif(isPalindrome(a+c+b)):\n\t\t\tprint(a+c+b)\n\t\t\texit(0)\nprint(\"NA\")\n"}, {"source_code": "def is_palindrome(s):\n return str(s) == str(s)[::-1]\n\n\ndef main():\n s = input()\n\n length = len(s)\n\n if is_palindrome(s):\n if length % 2 == 0:\n mid = length // 2\n print(s[:mid] + 'a' + s[mid:])\n return\n else:\n mid = (length - 1) // 2\n print(s[:mid] + s[mid] + s[mid:])\n return\n else:\n for index in range(length):\n candidate = s[:index] + s[index + 1:]\n if is_palindrome(candidate):\n if index == 0:\n print(s + s[index])\n elif index == length - 1:\n print(s[index] + s)\n else:\n print(s[:-index] + s[index] + s[-index:])\n return\n\n print('NA')\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def make_pallindrome(string):\n l = len(string)\n if l == 1:\n return string[0] + string[0]\n elif l % 2 == 0:\n chk = (string[:l/2] == string[l:l/2-1:-1])\n if chk:\n string = string[:l/2] + 'a' + string[l/2:]\n return string\n else:\n string1 = string[:] + string[0]\n string2 = string[-1] + string[:]\n l = len(string1)\n chk1 = (string1[:l/2] == string1[l:l/2:-1])\n chk2 = (string2[:l/2] == string2[l:l/2:-1])\n if chk1:\n return string1\n elif chk2:\n return string2\n else:\n return \"NA\"\n else:\n chk = (string[:l/2] == string[l:l/2:-1])\n if chk:\n string = string[:l/2 + 1] + string[l/2] + string[l/2+1:]\n return string\n else:\n string1 = string[:] + string[0]\n string2 = string[-1] + string[:]\n l = len(string1)\n chk1 = (string1[:l/2] == string1[l:l/2-1:-1])\n chk2 = (string2[:l/2] == string2[l:l/2-1:-1])\n if chk1:\n return string1\n elif chk2:\n return string2\n else:\n return \"NA\"\n\n\nif __name__ == '__main__':\n print make_pallindrome(raw_input())\n"}, {"source_code": "s = input()\n\nif s == s[::-1]: print(s[:len(s)//2] + s[len(s)//2] + s[len(s) // 2:])\n\nelif s[0] != s[-1]:\n s = s[:-1] + s[-1] + s[0]\n if s == s[::-1]: print(s)\n else: print('NA')\nelse:\n for i in range(1,len(s)//2):\n if s[i] != s[len(s) - i - 1]:\n s = s[:len(s) - i - 1] + s[len(s) - i - 1] + s[i] + s[-i:]\n break\n if s == s[::-1]: print(s)\n else: print('NA')\n"}, {"source_code": "def isPalin(a):\n\treturn a == a[::-1]\n\nx = raw_input()\ns = []\no = []\nfor i in x:\n\ts.append(i)\n\to.append(i)\nl = len(s)\nfor i in xrange(0, l + 1):\n\tfor j in xrange(0, 26):\n\t\tc = ord('a') + j\n\t\ts.insert(i, chr(c))\n\t\tif isPalin(s):\n\t\t\tx = ''\n\t\t\tfor i in s:\n\t\t\t\tx = x + i\n\t\t\tprint x\n\t\t\texit(0)\n\t\ts = o[:]"}, {"source_code": "def main():\n s = raw_input()\n l = len(s)\n if l == 1:\n print s+s\n elif s == s[::-1]:\n print s[0:l/2]+\"y\"+s[l/2:]\n else:\n for i in xrange(len(s)):\n if s[i] != s[l-i-1]:\n ns = s[0:i]+s[l-i-1]+s[i:l]\n if ns == ns[::-1]:\n print ns\n return\n ns = s[0:l-i]+s[i]+s[l-i:l]\n if ns == ns[::-1]:\n print ns\n return\n print \"NA\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = raw_input()\ni = 0\nj = len(s) - 1\nflag = 0\nwhile i < j:\n\tif s[i] != s[j] and flag == 0:\n\t\tif s[i+1] == s[j]:\n\t\t\ta = s[:j+1] + s[i] + s[j+1:]\n\t\t\tb = s[:i] + s[j] + s[i:]\n\t\t\tif a == a[::-1]:\n\t\t\t\tprint a\n\t\t\t\tflag = 1\n\t\t\t\tbreak\n\t\t\telif b == b[::-1]:\n\t\t\t\tprint b\n\t\t\t\tflag = 1\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tprint \"NA\"\n\t\t\t\tflag = 1\n\t\t\t\tbreak\n\ti += 1\n\tj -= 1\nif flag == 0:\n\tl = len(s)\n\tif l%2 == 0:\n\t\ts = s[:l/2] + 'a' + s[l/2:]\n\telse:\n\t\tc = s[l/2]\n\t\ts = s[:l/2] + c + s[l/2:]\n\tprint s\n\t\t\n"}, {"source_code": "def make_pallindrome(string):\n l = len(string)\n if l == 1:\n return string[0] + string[0]\n elif l % 2 == 0:\n chk = (string[:l/2] == string[l:l/2-1:-1])\n if chk:\n string = string[:l/2] + 'a' + string[l/2:]\n return string\n else:\n string1 = string[:] + string[0]\n string2 = string[-1] + string[:]\n l = len(string1)\n chk1 = (string1[:l/2] == string1[l:l/2:-1])\n chk2 = (string2[:l/2] == string2[l:l/2:-1])\n if chk1:\n return string1\n elif chk2:\n return string2\n else:\n return \"NA\"\n else:\n chk = (string[:l/2] == string[l:l/2:-1])\n if chk:\n string = string[:l/2 + 1] + string[l/2] + string[l/2+1:]\n return string\n else:\n string1 = string[:] + string[0]\n string2 = string[-1] + string[:]\n l = len(string1)\n chk1 = (string1[:l/2] == string1[l:l/2-1:-1])\n chk2 = (string2[:l/2] == string2[l:l/2-1:-1])\n if chk1:\n return string1\n elif chk2:\n return string2\n else:\n return \"NA\"\n\n\nif __name__ == '__main__':\n print make_pallindrome(raw_input())\n"}, {"source_code": "s = list(raw_input())\ni = 0\nins = False\nwhile (i < len(s)//2 ):\n n = len(s)\n if s[i] != s[n-1-i]:\n if ins or (i+1)*2==n: print \"NA\"; exit()\n ins = True\n if s[i] == s[n-2-i]:\n s.insert(i, s[n-1-i])\n else:\n s.insert(n-i, s[i])\n i += 1\nif not ins:\n l = s[len(s)//2] if len(s) & 1 else 'y'\n s.insert(len(s)//2, l)\nprint ''.join(s)\n"}, {"source_code": "import fileinput\n\nl = None\n\nfor line in fileinput.input():\n l = line\n l = line[:-1]\n\nlower_case = range(97,123)\n\ndef test_palin(l):\n fir = l[:len(l)/2]\n if len(l) % 2:\n sec = l[:len(l)/2:-1]\n else:\n sec = l[:len(l)/2-1:-1]\n\n return fir == sec\n\nret = None\n\nfor c in lower_case:\n c = chr(c)\n for x in range(0, len(l)+1):\n test = l[0:x] + c + l[x:]\n if test_palin(test):\n ret = test\n break\n if ret:\n \tbreak\n\nprint test"}, {"source_code": "from functools import reduce\nfrom operator import *\nfrom math import *\nfrom sys import *\nfrom string import *\nsetrecursionlimit(10**7)\nRI=lambda: list(map(int,input().split()))\nRS=lambda: input().rstrip().split()\n#################################################\ndef isPalindrome(a):\n\treturn a==a[::-1]\nx=RS()[0]\nfor i in range(1,len(x)+1):\n\ta,b= x[:i], x[i:]\n\tfor c in ascii_lowercase:\n\t\tif(isPalindrome(a+c+b)):\n\t\t\tprint(a+c+b)\n\t\t\texit(0)\nprint(\"NA\")\n"}, {"source_code": "def is_palindrome(word):\n letters = [letter for letter in word]\n j = len(letters) - 1\n for i in xrange(0, len(letters) / 2):\n if letters[i] is not letters[j]:\n return False\n i += 1;\n j -= 1;\n return True\n\nword = raw_input()\nletters = [letter for letter in word]\ncondition_not_met = True\nif is_palindrome(word):\n letters.insert(len(letters) / 2, letters[len(letters) / 2])\n print ('').join(letters)\n condition_not_met = False\nelse:\n for i in xrange(0, len(letters)+1):\n for letter in letters:\n new_word = word[:]\n new_letters = [new_letter for new_letter in new_word]\n new_letters.insert(i, letter)\n new_word = ('').join(new_letters)\n if is_palindrome(new_word):\n print new_word\n condition_not_met = False\n break\n else:\n continue\nif condition_not_met:\n print \"NA\"\n\n"}, {"source_code": "from functools import reduce\nfrom operator import *\nfrom math import *\nfrom sys import *\nfrom string import *\nsetrecursionlimit(10**7)\nRI=lambda: list(map(int,input().split()))\nRS=lambda: input().rstrip().split()\n#################################################\ndef isPalindrome(a):\n\treturn a==a[::-1]\nx=RS()[0]\nfor i in range(1,len(x)+1):\n\ta,b= x[:i], x[i:]\n\tfor c in ascii_lowercase:\n\t\tif(isPalindrome(a+c+b)):\n\t\t\tprint(a+c+b)\n\t\t\texit(0)\nprint(\"NA\")\n"}, {"source_code": "s=raw_input(\"\")\ny=len(s)-1\nx=0\nl=list(s)\nflag=0\ncheck=0\nif len(l)==2 and l[0]!=l[1]:\n check=1\n\nwhile x<=y:\n if l[x]!=l[y]:\n if l[y-1]==l[x]:\n l.insert(x,l[y-1])\n flag=1\n elif l[y]==l[x+1]:\n l.insert(y+1,l[x])\n flag=1\n else:\n flag=2\n print \"NA\"\n break\n x+=1\n y-=1\nif check==1:\n print \"NA\"\nelif flag==0:\n s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]\n if len(l)%2==0:\n l=l[0:len(l)/2]\n else:\n l=l[0:len(l)/2+1]\n l.reverse()\n s=s+str(''.join(l))\n print s\nelif flag==1: \n s1=''.join(l)\n print s1\n \n "}, {"source_code": "# coding: utf-8\ns = list(input())\nlength = len(s)\ni = 0\nj = length-1\nwhile i < j:\n if s[i] == s[j]:\n i += 1\n j -= 1\n else:\n a = s[:j+1] + [s[i]] + s[j+1:]\n b = s[:i+1] + [s[j]] + s[i+1:]\n break\nelse:\n if len(s)%2==0:\n print(''.join(s[:length//2]+['a']+s[length//2:]))\n else:\n print(''.join(s[:length//2]+[s[length//2]]+s[length//2:]))\n exit()\nc = a[::-1]\nd = b[::-1]\nif a == c:\n print(''.join(a))\nelif b == d:\n print(''.join(b))\nelse:\n print('NA')\n"}, {"source_code": "string = raw_input()\nlength = len(string)\nFindSolution = 0\n\nif string == string[::-1] :\n\n if length %2 != 0 :\n\n FindSolution = 1\n print string[:length/2+1] + string[length/2] + string[length/2+1:]\n\n else :\n\n FindSolution = 1\n print string[:length/2] + 'a' + string[length/2:]\n\nelse :\n\n for x in range(0,length) :\n\n if string.replace(string[x],'',1) == string.replace(string[x],'',1)[::-1] :\n \n # print string.replace(string[x],''), x \n\n if x <= length/2 :\n\n FindSolution = 1\n # print 'hi', x\n print string[:length-x] + string[x] + string[length-x:]\n break\n\n else :\n\n FindSolution = 1\n # print length, x\n print string[:length-x-1] + string[x] + string[length-x-1:]\n break\n\nif FindSolution == 0 :\n\n print 'NA'\n\n# s = 'fft'\n# print s.replace(s[0],'j')"}, {"source_code": "s = input()\ns1 = s[::-1]\np = False\n\ndef try1(a):\n q = s[:a] + s1[a] + s[a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\ndef try2(a):\n q = s[:len(s) - a] + s[a] + s[len(s) - a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\nfor i in range(len(s) // 2):\n if s[i] != s1[i]:\n if try1(i):\n q = s[:i] + s1[i] + s[i::]\n print(q)\n exit(0)\n elif try2(i):\n q = s[:len(s) - i] + s[i] + s[len(s) - i::]\n print(q)\n exit(0)\n else:\n p = True\n break\nif p:\n print(\"NA\")\nelse:\n d = s[:(len(s) // 2 if len(s) % 2 == 0 else len(s) // 2 + 1)] + \"a\" + s[len(s) // 2::]\n print(d)\n"}, {"source_code": "def ispal(st):\n for i in xrange(len(st)):\n if st[i] != st[-(i+1)]:\n return False\n return True\n\ndef oneDif(first,second):\n s1 = ''\n s2 = ''\n if len(first) > len(second):\n s1 = first\n s2 = second\n else:\n s1 = second\n s2 = first\n missing = ''\n pos = 0\n j = len(s2)-1\n for i in xrange(len(s1)):\n if s1[i] == s2[j]:\n j -= 1\n elif len(missing) == 0:\n missing = s1[i]\n pos = j+1\n else:\n return ''\n res = ''\n if pos == len(second):\n res = second + missing\n else:\n for i in xrange(len(second)):\n s = second[i]\n if i != pos:\n res += s\n else:\n res += missing\n res += s\n return first+res\n \n \n\ns = raw_input()\nif len(s)%2 == 0:\n if ispal(s):\n print s[:len(s)/2]+'a'+s[len(s)/2:]\n else:\n done = False\n check = [len(s)/2,(len(s)/2)-1]\n for c in check:\n first = s[:c]\n second = s[c+1:]\n res = oneDif(first,second)\n if len(res) > 0:\n print res[:len(res)/2]+s[c]+res[:len(res)/2]\n done = True\n break\n if not done:\n print 'NA' \n \nelse: \n if ispal(s):\n mid = len(s)/2\n print s[:mid]+s[mid]+s[mid:]\n else:\n check = [len(s)/2,(len(s)/2)-1]\n for c in check:\n first = s[:c]\n second = s[c:]\n res = oneDif(first,second)\n if len(res) > 0:\n print res\n done = True\n break\n if not done:\n print 'NA' \n \n \n"}, {"source_code": "alph = list(\"abcdefghijklmnopqrstuvwxyz\")\ndef pal(s):\n l = len(s) - 1\n f = 1\n for i in range(int(l / 2)):\n if s[i] != s[l - i]:\n f = 0\n return f\n\n\ns = input()\nl = len(s) + 1\nf = 0;\n\nfor i in range(l):\n for j in alph:\n st = list(s)\n st.insert(i, j)\n st = ''.join(st)\n if pal(st) == 1:\n f = 1\n break\n\nif (f == 1):\n print(st)\nelse:\n print(\"NA\")\n\n\n\n"}, {"source_code": "s = raw_input()\nn = len(s)\ndef f(s):\n\tn = len(s)\n\tfor i in range(n):\n\t\tif s[i] != s[n-1-i]: return False\n\treturn True\n\nif f(s):\n\ts = s[0:n/2]+'y'+s[n/2:]\n\tprint s\n\texit()\n\t\nflag = False\nfor a in range(n/2+1):\n\tif s[a] != s[n-1-a]:\n\t\tt = s[0:n-a]\n\t\tt += s[a]\n\t\tt += s[n-a:]\n\t\tif f(t):\n\t\t\tprint t\n\t\t\tflag = True\n\nif flag == False:\n\tprint \"NA\""}, {"source_code": "# \u0431\u044b\u0441\u0442\u0440\u043e \u0436\u0430\u0434\u043d\u043e \u043d\u043e \u043a\u0440\u0438\u0432\u043e\ns=input()\n\n\nfor i in range(len(s)):\n for j in range(26):\n z=s[:i]+chr(ord('a')+j)+s[i:]\n if z==z[::-1]:\n print(z)\n halt()\nprint(\"NA\")\n \n"}, {"source_code": "from string import ascii_lowercase\n\nword = str(input())\nfound = False\n\ndef get_palindrome(word, len):\n global found\n for letter in ascii_lowercase:\n new_word = word[:x] + letter + word[x:]\n if (new_word[::-1] == new_word):\n print(new_word)\n found = True\n return\n\nfor x in range(len(word) + 1):\n get_palindrome(word, x)\n \nif not found:\n print('N/A')\n\n\n"}, {"source_code": "s=raw_input()\nn=len(s)\nfl=0\nfor i in range(n):\n\ta=''\n\tfor j in range(n):\n\t\tif j!=i: a+=s[j]\n\tif a == a[::-1]:\n\t\tfl = 1\n\t\t# print a\n\t\tans=''\n\t\tfor k in range(n):\n\t\t\tif k == n-i-1: \n\t\t\t\tans+=s[k]\n\t\t\t\tans+=s[i]\n\t\t\telse: ans+=s[k]\n\t\tprint ans\n\t\tbreak\nif fl == 0: print 'NA'"}, {"source_code": "import sys\n\ndef isPalindrome(l):\n\treturn l == list(reversed(l))\n\t\ns = list(sys.stdin.readline())[0:-1]\nlargo = len(s)\nsolution = ['N','A']\nfor j in range(largo):\n\ttest = list(s)\n\ttest[j:j] =[test[largo-1-j]]\n\tif isPalindrome(test):\n\t\tsolution = test\n\ntest = list(s)\ntest[largo:largo] = test[0]\nif isPalindrome(test):\n\tsolution = test\n\nprint \"\".join(solution)\n\t\t\n\t\n\t\n"}, {"source_code": "def pal(a):\n ctr = 0\n while ctr < len(a)/2:\n if a[ctr] != a[len(a)-ctr-1]:\n return False\n ctr+=1\n return True\n\na = input()\nalp = []\np = 'NA'\nif not len(a) > 10 or len(a) < 1:\n if a.islower():\n for char in a:\n if not char in alp:\n alp.append(char)\n length = len(a)\n ctr = 0\n for char in alp:\n while ctr <= length:\n new = a[:ctr] + char + a[ctr:]\n if pal(new):\n p = new\n ctr+=1\n\n print(p)\n"}, {"source_code": "# coding: utf-8\ns = list(input())\nlength = len(s)\ni = 0\nj = length-1\nwhile i < j:\n if s[i] == s[j]:\n i += 1\n j -= 1\n else:\n a = s[:j+1] + [s[i]] + s[j+1:]\n b = s[:i+1] + [s[j]] + s[i+1:]\n break\nelse:\n if len(s)%2==0:\n print(''.join(s[:length//2]+['a']+s[length//2:]))\n else:\n print(''.join(s[:length//2]+[s[length//2]]+s[length//2:]))\n exit()\nc = a[::-1]\nd = b[::-1]\nif a == c:\n print(''.join(a))\nelif b == d:\n print(''.join(b))\nelse:\n print('NA')\n"}, {"source_code": "s = raw_input(\"\")\nn = len(s)\ns1 = s[:n/2]\ns2 = s[n:n/2-1:-1]\n#s3 = s[:n/2+1]\n#s4 = s[n:n/2:-1]\n#print s1, s2\n#print s3, s4\n\nif s1 == s2:\n print s1+'a'+s2[::-1]\nelse:\n i = 0\n while s1[i] == s2[i] and i < min(len(s1), len(s2)) - 1:\n i += 1\n #print i, s1[i], s2[i]\n if i == min(len(s1), len(s2)) - 1 and len(s1) != len(s2) and s1[i] == s2[i]:\n if len(s1) > len(s2):\n c = s1[len(s1)-1]\n else:\n c = s2[len(s2)-1]\n print s1+c+s2[::-1]\n else:\n s11 = s1[:i] + s2[i] + s1[i:len(s1) - 1]\n #print s11\n if s11 == s2:\n print s11 + s1[len(s1)-1] + s2[::-1]\n else:\n s11 = s2[:i] + s1[i] + s2[i:len(s2) - 1]\n if s11 == s1:\n print s11 + s2[len(s2)-1] + s1[::-1]\n else:\n print \"NA\""}, {"source_code": "def make_palindrome(s):\n if len(s) == 0:\n return 'a'\n if len(s) == 1:\n return s+s\n i,j = 0,len(s)-1\n s = list(s)\n new_wrd = None\n while i < j:\n if s[i] != s[j]:\n new_wrd = True\n break\n i += 1\n j -= 1\n if new_wrd is not None:\n new_wrd = s[:j+1]+[s[i]]+s[j+1:]\n #print(new_wrd)\n if ''.join(new_wrd) == ''.join(new_wrd)[::-1]:\n return ''.join(new_wrd)\n else:\n new_wrd = s[:i]+[s[j]]+s[i:]\n #print(new_wrd)\n if ''.join(new_wrd) == ''.join(new_wrd)[::-1]:\n return ''.join(new_wrd)\n return 'NA'\n else:\n if i == j:\n new_wrd = s[:i+1]+[s[j]]+s[j:]\n else:\n new_wrd = s[:j+1]+['a']+s[i:]\n return ''.join(new_wrd)\n \nif __name__ =='__main__':\n s = input()\n print(make_palindrome(s))"}, {"source_code": "x = input()\nd = False\nfor c in range(97,123):\n if ( d):\n break\n for i in range(len(x) + 1):\n n = x[:i] + chr(c) + x[i:]\n if n == n[::-1]:\n print (n)\n \n d= True\n break\n \n \n"}, {"source_code": "import sys\n\ndef isPalindrome(l):\n\treturn l == list(reversed(l))\n\t\ns = list(sys.stdin.readline())[0:-1]\nlargo = len(s)\nsolution = ['N','A']\nfor j in range(largo):\n\ttest = list(s)\n\ttest[j:j] =[test[largo-1-j]]\n\tif isPalindrome(test):\n\t\tsolution = test\n\ntest = list(s)\ntest[largo:largo] = test[0]\nif isPalindrome(test):\n\tsolution = test\n\nprint \"\".join(solution)\n\t\t\n\t\n\t\n"}, {"source_code": "import copy\ndef f(n):\n l=len(n)/2\n inserted=False\n for i in range(l):\n if n[i]!=n[len(n)-i-1]:\n n.insert(len(n)-i,n[i])\n inserted=True\n break\n if inserted==True:\n l=len(n)/2\n flag=True\n for i in range(l):\n if n[i]!=n[len(n)-i-1]:\n flag=False\n break\n if flag:\n return ''.join(n)\n else:\n return 'NA'\n else:\n n.insert(len(n)/2,'a')\n return ''.join(n)\n\nif __name__ == '__main__':\n r=list(raw_input())\n rr=copy.copy(r)\n ans1=f(r)\n rr.reverse()\n ans2=f(rr)\n if ans1==ans2=='NA':\n print 'NA'\n else:\n if ans1!='NA':\n print ans1\n else:\n print ans2\n\n\n"}, {"source_code": "s=list(input())\np=s.copy()\no=1\nfor i in range(len(s)):\n s=p.copy()\n s.insert(len(s)-i, s[i])\n if(s == s[::-1]):\n for l in s:\n print(l, end='')\n o=0\n break\nif(o):\n print(\"Na\")\n"}, {"source_code": "def palin(n):\n if(str(n) == str(n)[::-1]):return True\n else: return False\ndef helpme(s):\n flag=0\n l=len(s)\n till=l/2+(l%2)+1\n for i in range(till):\n if(s[i]!=s[l-1-i]):\n x=s[i:l-1-i]\n y=s[i+1:l-2]\n #print x, y\n if(palin(x)):\n z=s[:i]+s[l-1-i]+s[i:]\n if(palin(z)):\n print z\n flag=1\n return True\n else: return False\n if(flag==0):\n if(palin(y)):\n z=s[:l-i]+s[i]+s[l-i:]\n if(palin(z)):\n print z\n flag=1\n return True\n else: return False\n return False\ns=raw_input()\nl=len(s)\nif(palin(s)):\n if(l%2==0):\n b=s[:l/2]\n print b\n print b+'a'+b[::-1]\n else:\n b=s[:l/2+1]\n print b\n print b+b[::-1]\nelse:\n flag=0\n x=s[1:]\n y=s[:l-1]\n #print x, y\n if(palin(x)):\n print s+s[0]\n flag=1\n if(flag==0):\n if(palin(y)):\n print s[l-1]+s\n flag=1\n if(flag==0):\n if(helpme(s)):flag=1\n if(flag==0):\n print \"NA\""}, {"source_code": "def pal(a):\n size = len(a)\n for i in xrange(size/2 + 1):\n if a[i] != a[size-1-i]:\n return False\n return True\n\na = raw_input()\nsize = len(a)\nif pal(a):\n print a[:size/2] + 'a' + a[size/2:]\nelse:\n alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\n done = False\n for i in xrange(size+1):\n for j in alp:\n if pal(a[:i] + j + a[i+1:]):\n print a[:i] + j + a[i+1:]\n done = True\n break\n if done:\n break\n if not done:\n print 'NA'\n"}, {"source_code": "def pal(a):\n size = len(a)\n for i in xrange(size/2 + 1):\n if a[i] != a[size-1-i]:\n return False\n return True\n\na = raw_input()\nsize = len(a)\nif pal(a):\n print a[:size/2] + 'a' + a[size/2:]\nelse:\n alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\n done = False\n for i in xrange(size+1):\n for j in alp:\n if pal(a[:i] + j + a[i+1:]):\n print a[:i] + j + a[i+1:]\n done = True\n break\n if done:\n break\n if not done:\n print 'NA'\n"}, {"source_code": "s=input()\nif \"\".join(reversed(s))==s:\n if len(s)%2==0:\n print(s[:len(s)//2]+'l'+s[len(s)//2:])\n else:\n print(s[:len(s)//2]+s[len(s)//2]+s[len(s)//2:])\n exit()\nn=len(s)\nst=s[n-1]+s\nif st==\"\".join(reversed(st)):\n print(st)\n exit()\nst=s+s[0]\nif st==\"\".join(reversed(st)):\n print(st)\n exit()\na=[0]*(n+1)\nflag=0\ni=0\nj=n-1\nf=0\nl=n\nwhile(i<=j):\n if s[i]==s[j]:\n a[f]=s[i]\n f+=1\n a[l]=s[j]\n l-=1\n i+=1\n j-=1\n elif s[i]!=s[j] and flag==0:\n a[f]=s[i]\n f+=1\n a[l]=s[i]\n l-=1\n i+=1\n flag=1\n elif s[i]!=s[j] and flag:\n print(\"NA\")\n exit()\nprint(\"\".join(str(e) for e in a))\n "}, {"source_code": "x = input()\nd = False\nfor c in range(97,123):\n if ( d):\n break\n for i in range(len(x) + 1):\n n = x[:i] + chr(c) + x[i:]\n if n == n[::-1]:\n print (n)\n \n d= True\n break\n \n \n"}, {"source_code": "def is_p(s):\n return s==s[::-1]\ns=input()\nfor i in range(len(s)):\n for c in 'abcdefghijklmnopqrstuvwxyz':\n if is_p(s[:i]+c+s[i:]):\n print(s[:i]+c+s[i:])\n exit(0)\nprint(\"NA\")\n"}, {"source_code": "s = raw_input(\"\")\nn = len(s)\ns1 = s[:n/2]\ns2 = s[n:n/2-1:-1]\n#s3 = s[:n/2+1]\n#s4 = s[n:n/2:-1]\n#print s1, s2\n#print s3, s4\n\nif s1 == s2:\n print s1+'a'+s2[::-1]\nelse:\n i = 0\n while s1[i] == s2[i] and i < min(len(s1), len(s2)) - 1:\n i += 1\n #print i, s1[i], s2[i]\n if i == min(len(s1), len(s2)) - 1 and len(s1) != len(s2) and s1[i] == s2[i]:\n if len(s1) > len(s2):\n c = s1[len(s1)-1]\n else:\n c = s2[len(s2)-1]\n print s1+c+s2[::-1]\n else:\n s11 = s1[:i] + s2[i] + s1[i:len(s1) - 1]\n #print s11\n if s11 == s2:\n print s11 + s1[len(s1)-1] + s2[::-1]\n else:\n s11 = s2[:i] + s1[i] + s2[i:len(s2) - 1]\n if s11 == s1:\n print s11 + s2[len(s2)-1] + s1[::-1]\n else:\n print \"NA\""}, {"source_code": "def is_palindrome(word):\n letters = [letter for letter in word]\n j = len(letters) - 1\n for i in xrange(0, len(letters) / 2):\n if letters[i] is not letters[j]:\n return False\n i += 1;\n j -= 1;\n return True\n\nword = raw_input()\nletters = [letter for letter in word]\nnew_word = ''\nif is_palindrome(word):\n letters.insert(len(letters) / 2, letters[len(letters) / 2])\n print ('').join(letters)\nelse:\n for i in xrange(0, len(letters)+1):\n for letter in letters:\n new_word = word[:]\n new_letters = [new_letter for new_letter in new_word]\n new_letters.insert(i, letter)\n new_word = ('').join(new_letters)\n if is_palindrome(new_word):\n print new_word\n break\n else:\n continue\nif not is_palindrome(new_word):\n print \"NA\"\n\n"}, {"source_code": "def pal(a):\n ctr = 0\n while ctr < len(a)/2:\n if a[ctr] != a[len(a)-ctr-1]:\n return False\n ctr+=1\n return True\n\na = input()\nalp = []\np = 'NA'\nif not len(a) > 10 or len(a) < 1:\n if a.islower():\n for char in a:\n if not char in alp:\n alp.append(char)\n length = len(a)\n for char in alp:\n ctr = 0\n while ctr < length:\n if ctr == 0:\n new = char + a\n else: \n new = a[:ctr] + char + a[ctr:]\n if pal(new):\n p = new\n ctr+=1\n\n print(p)\n\n"}, {"source_code": "s = input()\nf = 0\nalpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\nfor i in range(len(s)+1):\n for j in alpha:\n t = s[:i]+ j + s[i:]\n print(t)\n if t==t[::-1]:\n print(t)\n exit()\n\nprint('NA')\n"}, {"source_code": "s = input()\nal = 'abcdefghijklmnopqrstuvwxyz'\nans = False\nfor i in range(26): ### it's just a o(1)\n for j in range(len(s)+1):\n tmp = s[:j]+al[i]+s[j:]\n if tmp == tmp[::-1]:\n print(tmp )\n ans = True\n if ans :\n break\nif not ans:\n print('NA')\n"}, {"source_code": "def process(left, right, chars, inserted):\n if left > right:\n if not inserted:\n chars.insert(left, 'a')\n return True\n if left == right:\n if not inserted:\n chars.insert(left, chars[left])\n return True\n\n if chars[left] == chars[right]:\n return process(left + 1, right - 1, chars, inserted)\n\n # discrepancy happens\n if inserted:\n return False\n\n if chars[left + 1] == chars[right]:\n chars.insert(right + 1, chars[left])\n inserted = True\n return process(left + 2, right - 1, chars, inserted)\n elif chars[left] == chars[right - 1]:\n chars.insert(left, chars[len(chars) - 1])\n inserted = True\n return process(left + 2, right - 1, chars, inserted)\n else:\n return False\n\nchars = list(raw_input())\nif process(0, len(chars) - 1, chars, False):\n print ''.join(chars)\nelse:\n print 'NA'\n\n"}, {"source_code": "def is_palindrome(s):\n return s == s[::-1]\ns=raw_input(\"\")\ny=len(s)-1\nx=0\nl=list(s)\nflag=0\ncheck=0\nif len(l)==2 and l[0]!=l[1]:\n l.insert(0,l[1])\n check=1\nwhile x<=y:\n if check==1:\n break\n if l[x]!=l[y]:\n if l[y-1]==l[x]:\n if x==0:\n l.insert(0,l[y])\n s3=''.join(l)\n if is_palindrome(s3):\n flag=1\n break\n else:\n flag=2\n break\n l.insert(x,l[y-1])\n flag=1\n elif l[y]==l[x+1]:\n l.insert(y+1,l[x])\n s3=''.join(l)\n if is_palindrome(s3):\n flag=1\n break\n else:\n flag=2\n break\n flag=1\n else:\n flag=2\n \n break\n x+=1\n y-=1\nif check==1:\n print ''.join(l)\nelif flag==0:\n s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]\n if len(l)%2==0:\n l=l[0:len(l)/2]\n else:\n l=l[0:len(l)/2+1]\n l.reverse()\n s=s+str(''.join(l))\n print s\nelif flag==1: \n s1=''.join(l)\n print s1\nelif flag==2:\n print \"NA\"\n "}, {"source_code": "s = input()\nal = 'abcdefghijklmnopqrstuvwxyz'\nans = False\nfor i in range(26): ### it's just a o(1)\n for j in range(len(s)+1):\n tmp = s[:j]+al[i]+s[j:]\n if tmp == tmp[::-1]:\n print(tmp )\n ans = True\n if ans :\n break\nif not ans:\n print('NA')\n"}, {"source_code": "s=input()\nsi=s[::-1]\nif s==si and len(s)%2==0:\n output=s[:len(s)//2]+\"a\"+s[len(s)//2:]\n print(output)\nelif s==si and len(s)%2==1:\n output=s[:len(s)//2+1]+s[len(s)//2:]\n print(output)\nelse:\n output=\"\"\n save=-1\n for i in range(len(s)):\n if s[i]!=si[i]:\n output+=s[i]\n save=i\n break\n else:\n output+=s[i]\n if save>-1 and save<len(s):\n output+=si[save:]\n if output!=output[::-1]:\n print(\"NA\")\n '''print(output)'''\n else:\n print(output)\n\n \n \n"}, {"source_code": "s = str(input())\ns = list(s)\ns1 = s[::-1]\nanswer = \"\"\noutput = s\nif len(s) == 1:\n s += s\n output = list(s)\nelif s == s1:\n for element in s:\n s.insert(int(len(s)/2), element)\n if s == s[::-1]:\n break\n else:\n s.pop(int(len(s) / 2))\n output = s\nelse:\n for letter in s:\n count = 0\n while count <= len(s):\n s.insert(count, letter)\n s1 = s[::-1]\n if s1 == s:\n output = s1\n s.pop(count)\n count += 1\n\nif output == output[::-1]:\n for letter in output:\n answer += letter\n print (answer)\nelse:\n print (\"NA\")\n"}, {"source_code": "s=raw_input()\nl=len(s)\nt=s[::-1]\nflag=1\nfor i in xrange(l):\n\tif(s[i]!=t[i]):\n\t\tflag=0\n\t\tt=t[:i]+s[i]+t[i:]\n\t\ts=s[:l-i]+s[i]+t[l-i+1:]\n\t\tbreak\nif(flag):\n\tif(l%2):\n\t\tprint s[:l/2]+s[l/2]+s[l/2:]\n\telse:\n\t\tprint s[:l/2]+\"z\"+s[l/2:]\nelse:\n\tif(t==s):\n\t\tprint s\n\telse:\n\t\tprint \"NA\""}, {"source_code": "x = raw_input()\nn = len(x)\ndef isPalin(s):\n\tk = len(s)\n\ti = 0\n\twhile i<=k/2:\n\t\tif s[i] != s[k-i-1]:\n\t\t\treturn 0\n\t\ti+=1\n\treturn 1\ndef dothis(s,c):\n\t# very bad :-(\n\t#print \"dothis ->\",s,c\n\tfor i in range(n+1):\n\t\tp = s[:i]+c+s[i:]\n\t\t#print \"checkingz: \",p\n\t\tif(isPalin(p)):\n\t\t\treturn p\n\t#print \"This should neverever get printed!!!\"\n\treturn \"NA\" \n\ndef solve(s):\n\tss = [s[i] for i in range(n)]\n\tm = {}\n\tcount = 0\n\tif n ==1 :\n\t\treturn s+s\n\tfor i in ss:\n\t\tif i in m:\n\t\t\tm.pop(i)\n\t\telse:\n\t\t\tm[i] = count\n\t\tcount+=1\n\t\n\tif(isPalin(s)):\n\t\tif n%2:\n\t\t\tif len(m)==1:\n\t\t\t\treturn dothis(s,max(m))\n\t\t\telse:\n\t\t\t\treturn \"NA\"\n\t\telse:\n\t\t\treturn s[:n/2]+'a'+s[n/2:]\n\telse:\n\t\tk = len(m)\n\t\tif k > 2:\n\t\t\treturn \"NA\"\n\t\tif k == 2:\n\t\t\tc = max(m)\n\t\t\tif n%2 == 0:\n\t\t\t\treturn dothis(s,c)\n\t\t\telse:\n\t\t\t\treturn \"NA\"\n\t\tif k==1 : # has to be odd\n\t\t\tc = max(m)\n\t\t\treturn dothis(s,c)\n\t\treturn \"NA\" # ???\n\nprint solve(x)\n"}, {"source_code": "s = list(raw_input())\nfor i,j in enumerate(s):\n for a in 'abcdefghijklmnopqrstuvwxyz':\n c = s[:i+1] + [a] + s[i+1:]\n if c == c[::-1]:\n print ''.join(c)\n exit(0)\nprint \"NA\""}, {"source_code": "from math import floor\ns=input()\nls=len(s)\nif ls==1:\n print('NA')\n exit()\nfor i in range (floor(ls/2)):\n isp=0\n if s[i]!=s[ls-i-1]:\n isp=1\n sn=s[:i]+s[ls-i-1]+s[i:]\n #print(sn)\n csn=0\n for j in range (floor(len(sn)/2)):\n if sn[j]!=sn[-j-1]:\n csn=1\n break\n if csn:\n csn=0\n sn=s[:ls-i]+s[i]+s[ls-i:]\n #print(sn)\n for j in range (floor(len(sn)/2)):\n if sn[j]!=sn[-j-1]:\n csn=1\n break\n break\nif isp:\n if csn:\n print('NA')\n else:\n print(sn)\nelse:\n if ls%2==1:\n print('NA')\n else:\n print(s[:floor(ls/2)]+'a'+s[floor(ls/2):])\n "}, {"source_code": "s = input()\nal = 'abcdefghijklmnopqrstuvwxyz'\nans = False\nfor i in range(26): ### it's just a o(1)\n for j in range(len(s)+1):\n tmp = s[:j]+al[i]+s[j:]\n if tmp == tmp[::-1]:\n print(tmp )\n ans = True\n if ans :\n break\nif not ans:\n print('NA')\n"}, {"source_code": "s = list(input())\nl = len(s)\nle = s[:l//2]\nri = s[l//2:]\n\nif l&1:\n if le == ri[1:][::-1]:\n print(\"\".join(le+ri[:1]*2+ri[1:]))\n else:\n l = le.copy()\n l.insert(0, ri[-1])\n if l == ri[::-1]:\n print(\"\".join(l+ri))\n else:\n le += ri[1:]\n r = ri[1:]\n r.insert(len(r), le[0])\n if le == r[::-1]:\n print(\"\".join(le+r))\n else:\n print(\"NA\")\nelse:\n if le[0] != ri[l//2-1]:\n ri = ri[1:]\n ri.append(le[0])\n if le == ri[::-1]:\n print(\"\".join(le+s[l//2:l//2+1]+ri))\n else:\n print(\"NA\")\n elif le == ri[::-1]:\n print(\"\".join(le+[\"z\"]+ri))\n else:\n print(\"NA\")\n"}, {"source_code": "def make_pallindrome(string):\n l = len(string)\n if l == 1:\n return string[0] + string[0]\n elif l % 2 == 0:\n chk = (string[:l/2] == string[l:l/2-1:-1])\n if chk:\n string = string[:l/2] + 'a' + string[l/2:]\n return string\n else:\n string = string[:] + string[0]\n l = len(string)\n chk = (string[:l/2] == string[l:l/2:-1])\n if chk:\n return string\n else:\n return \"NA\"\n else:\n chk = (string[:l/2] == string[l:l/2:-1])\n if chk:\n string = string[:l/2 + 1] + string[l/2] + string[l/2+1:]\n return string\n else:\n return \"NA\"\n\n\nif __name__ == '__main__':\n print make_pallindrome(raw_input())\n"}, {"source_code": "def palin(n):\n if(str(n) == str(n)[::-1]):return True\n else: return False\ndef helpme(s):\n flag=0\n l=len(s)\n till=l/2+(l%2)+1\n for i in range(till):\n if(s[i]!=s[l-1-i]):\n x=s[i:l-1-i]\n y=s[i+1:l-2]\n #print x, y\n if(palin(x)):\n z=s[:i]+s[l-1-i]+s[i:]\n if(palin(z)):\n print z\n flag=1\n return True\n else: return False\n if(flag==0):\n if(palin(y)):\n z=s[:l-i]+s[i]+s[l-i:]\n if(palin(z)):\n print z\n flag=1\n return True\n else: return False\n return False\ns=raw_input()\nl=len(s)\nif(palin(s)):\n if(l%2==0):\n b=s[:l/2]\n print b\n print b+'a'+b[::-1]\n else:\n b=s[:l/2+1]\n print b\n print b+b[::-1]\nelse:\n flag=0\n x=s[1:]\n y=s[:l-1]\n #print x, y\n if(palin(x)):\n print s+s[0]\n flag=1\n if(flag==0):\n if(palin(y)):\n print s[l-1]+s\n flag=1\n if(flag==0):\n if(helpme(s)):flag=1\n if(flag==0):\n print \"NA\""}, {"source_code": "def check(s,n):\n ans=\"\"\n for i in range(int(n/2)):\n if(s[i]!=s[n-1-i]):\n ans=s[:n-i]+s[i]+s[n-i:]\n break\n if(ans==ans[::-1]):\n print(ans)\n else:\n print(\"NA\")\n\ns=input()\nn=len(s)\nif(s==s[::-1]):\n print(s[:int(n/2)],s[int(n/2)],s[int(n/2):],sep=\"\")\nelse:\n check(s,n)"}, {"source_code": "s = list(raw_input())\ni = 0\nins = False\nwhile (i < len(s)//2 ):\n n = len(s)\n if s[i] != s[n-1-i]:\n if ins or (i+1)*2==n: print \"NA\"; exit()\n ins = True\n if s[i] == s[n-2-i]:\n s.insert(i, s[n-1-i])\n else:\n s.insert(n-i, s[i])\n i += 1\nif not ins:\n l = s[len(s)//2] if len(s) & 1 else 'y'\n s.insert(len(s)//2, l)\nprint ''.join(s)\n"}, {"source_code": "s = input()\ns1 = s[::-1]\np = False\n\ndef try1(a):\n q = s[:a] + s1[a] + s[a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\ndef try2(a):\n q = s[:len(s) - a] + s[a] + s[len(s) - a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\nfor i in range(len(s) // 2):\n if s[i] != s1[i]:\n if try1(i):\n q = s[:i] + s1[i] + s[i::]\n print(q)\n exit(0)\n elif try2(i):\n q = s[:len(s) - i] + s[i] + s[len(s) - i::]\n print(q)\n exit(0)\n else:\n p = True\n break\nif p or len(s) == 1:\n print(\"NA\")\nelse:\n d = s[:(len(s) // 2 if len(s) % 2 == 0 else len(s) // 2 + 1)] + \"a\" + s[len(s) // 2::]\n print(d)\n"}, {"source_code": "s = input()\ns1 = s[::-1]\np = False\n\ndef try1(a):\n q = s[:a] + s1[a] + s[a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\ndef try2(a):\n q = s[:len(s) - 1 - a] + s[a] + s[len(s) - 1 - a::]\n q1 = q[::-1]\n for i in range(a + 1, len(q) // 2):\n if q[i] != q1[i]:\n return False\n return True\n\nfor i in range(len(s) // 2):\n if s[i] != s1[i]:\n if try1(i):\n q = s[:i] + s1[i] + s[i::]\n print(q)\n exit(0)\n elif try2(i):\n q = s[:len(s) - 1 - i] + s[i] + s[len(s) - 1 - i::]\n print(q)\n exit(0)\n else:\n p = True\n break\nif p:\n print(\"NA\")\nelse:\n d = s[:(len(s) // 2 if len(s) % 2 == 0 else len(s) // 2 + 1)] + \"a\" + s[len(s) // 2::]\n print(d)\n "}, {"source_code": "def ispal(st):\n for i in xrange(len(st)):\n if st[i] != st[-(i+1)]:\n return False\n return True\n\ndef oneDif(first,second):\n# print first,second\n s1 = ''\n s2 = ''\n if len(first) > len(second):\n s1 = first\n s2 = second\n else:\n s1 = second\n s2 = first\n missing = ''\n pos = 0\n j = len(s2)-1\n for i in xrange(len(s1)):\n if s1[i] == s2[j]:\n j -= 1\n elif len(missing) == 0:\n missing = s1[i]\n pos = j+1\n else:\n return ''\n if len(missing) == 0:\n missing = s1[i]\n res = ''\n # print missing,pos\n if pos == len(s2):\n res = s2 + missing\n else:\n for i in xrange(len(s2)):\n s = s2[i]\n if i != pos:\n res += s\n else:\n res += missing\n res += s\n# print res\n if ispal(s1+res):\n return s1+res\n elif ispal(res+s1):\n return res+s1\n \n \n\ns = raw_input()\nif len(s) == 2:\n print s + s[0]\nelse:\n if len(s)%2 == 0:\n if ispal(s):\n print s[:len(s)/2]+'a'+s[len(s)/2:]\n else:\n done = False\n check = [len(s)/2,(len(s)/2)-1]\n for c in check:\n first = s[:c]\n second = s[c+1:]\n res = oneDif(first,second)\n if len(res) > 0:\n print res[:len(res)/2]+s[c]+res[len(res)/2:]\n done = True\n break\n if not done:\n print 'NA' \n \n else: \n done = False\n if ispal(s):\n mid = len(s)/2\n print s[:mid]+s[mid]+s[mid:]\n else:\n check = [len(s)/2,(len(s)/2)+1]\n for c in check:\n first = s[:c]\n second = s[c:]\n # print c,first,second\n res = oneDif(first,second)\n if len(res) > 0:\n print res\n done = True\n break\n if not done:\n print 'NA' \n \n \n"}, {"source_code": "s = raw_input()\nn = len(s)\ndef f(s):\n\tn = len(s)\n\tfor i in range(n):\n\t\tif s[i] != s[n-1-i]: return False\n\treturn True\n\nif f(s):\n\ts = s[0:n/2]+'y'+s[n/2:]\n\tprint s\n\texit()\n\t\nflag = False\nfor a in range(n/2+1):\n\tif s[a] != s[n-1-a]:\n\t\tt = s[0:n-a]\n\t\tt += s[a]\n\t\tt += s[n-a:]\n\t\tif f(t):\n\t\t\tprint t\n\t\t\tflag = True\n\nif flag == False:\n\tprint \"NA\""}, {"source_code": "s = input()\nn = len(s)\nfor i in range(n):\n t = s[:n-i] + s[i] + s[n-i:] \n if t == t[::-1]: print(t); exit()\nt = s[-1] + s\nif t == t[::-1]: print(t)\nelse: print('NA')\n"}, {"source_code": "def is_palindrome(word):\n letters = [letter for letter in word]\n j = len(letters) - 1\n for i in xrange(0, len(letters) / 2):\n if letters[i] is not letters[j]:\n return False\n i += 1;\n j -= 1;\n return True\n\nword = raw_input()\nletters = [letter for letter in word]\nnew_word = ''\nif is_palindrome(word):\n letters.insert(len(letters) / 2, letters[len(letters) / 2])\n print ('').join(letters)\nelse:\n for i in xrange(0, len(letters)+1):\n for letter in letters:\n new_word = word[:]\n new_letters = [new_letter for new_letter in new_word]\n new_letters.insert(i, letter)\n new_word = ('').join(new_letters)\n if is_palindrome(new_word):\n print new_word\n break\n else:\n continue\nif not is_palindrome(new_word):\n print \"NA\"\n\n"}, {"source_code": "def main():\n s = raw_input()\n l = len(s)\n if l == 1:\n print s+s\n elif s == s[::-1]:\n print s[0:l/2]+\"y\"+s[l/2:]\n else:\n for i in xrange(len(s)):\n if s[i] != s[l-i-1]:\n ns = s[0:i]+s[l-i-1]+s[i:l]\n if ns == ns[::-1]:\n print ns\n return\n ns = s[0:l-i]+s[i]+s[l-i:l]\n if ns == ns[::-1]:\n print ns\n return\n print \"NA\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "# \u0431\u044b\u0441\u0442\u0440\u043e \u0436\u0430\u0434\u043d\u043e \u043d\u043e \u043a\u0440\u0438\u0432\u043e\ns=input()\n\n\nfor i in range(len(s)):\n for j in range(26):\n z=s[:i]+chr(ord('a')+j)+s[i:]\n if z==z[::-1]:\n print(z)\n halt()\nprint(\"NA\")\n \n"}, {"source_code": "s = raw_input()\ni = 0\nj = len(s) - 1\nflag = 0\nwhile i < j:\n\t#print i, j, s\n\tif s[i] != s[j] and flag == 0:\n\t\tif s[i+1] == s[j]:\n\t\t\ts = s[:j+1] + s[i] + s[j+1:]\n\t\t\tflag = 1\n\t\t\ti += 1\n\t\telif s[j-1] == s[i]:\n\t\t\t#print \"yes\"\n\t\t\ts = s[:i] + s[j] + s[i:]\n\t\t\tflag = 1\n\t\t\ti += 1\n\t\telse:\n\t\t\tflag = 2\n\t\t\tprint \"NA\"\n\t\t\tbreak\n\t\t\n\telif s[i] != s[j] and flag == 1:\n\t\tflag = 2\n\t\tprint \"NA\"\n\t\tbreak\n\telse:\n\t\ti += 1\n\t\tj -= 1\nif flag == 1:\n\tprint s\nelif flag == 0:\n\tl = len(s)\n\tif l%2 == 0:\n\t\ts = s[:l/2] + 'a' + s[l/2:]\n\telse:\n\t\tc = s[l/2]\n\t\ts = s[:l/2] + c + s[l/2:]\n\tprint s\n\t\t\n"}, {"source_code": "\nst = list(input())\n\n\nfor i in range(1, len(st) + 1):\n\tfor j in range(26):\n\t\tsti = st.copy()\n\n\t\tsti.insert(i, chr(97 + j))\n\t\n\t\tif sti == sti[::-1]:\n\t\t\tprint(''.join(sti))\n\t\t\texit()\n\nprint('NA')\n\n"}, {"source_code": "def make_palindrome(s):\n if len(s) == 0:\n return 'a'\n if len(s) == 1:\n return s+s\n i,j = 0,len(s)-1\n s = list(s)\n new_wrd = None\n while i < j:\n if s[i] != s[j]:\n new_wrd = True\n break\n i += 1\n j -= 1\n if new_wrd is not None:\n new_wrd = s[:j+1]+[s[i]]+s[j+1:]\n print(new_wrd)\n if ''.join(new_wrd) == ''.join(new_wrd)[::-1]:\n return ''.join(new_wrd)\n else:\n new_wrd = s[:i]+[s[j]]+s[i:]\n print(new_wrd)\n if ''.join(new_wrd) == ''.join(new_wrd)[::-1]:\n return ''.join(new_wrd)\n return 'NA'\n else:\n if i == j:\n new_wrd = s[:i+1]+[s[j]]+s[j:]\n else:\n new_wrd = s[:j+1]+['a']+s[i:]\n return ''.join(new_wrd)\n \nif __name__ =='__main__':\n s = input()\n print(make_palindrome(s))"}, {"source_code": "import fileinput, math, collections\n\n### ###\n# utility func #\n### ###\n\ndbug = True\n\ndef btos(b):\n\treturn 'YES' if b else 'NO'\n\ndef pd(s, label=''):\n\tglobal dbug\n\tif dbug:\n\t\theader = 'debug:'\n\t\tif label != '':\n\t\t\theader += ' (%s)\\t' % label\n\t\tprint header, s\n\ndef stoi(s):\n\treturn([ int(x) for x in s.split() ])\n\ndef perm(n, k, wheels=True):\n\tif wheels:\n\t\tassert(n > 0)\n\t\tassert(k > 0)\n\treturn math.factorial(n) / math.factorial(k)\n\ndef comb(n, k, wheels=True):\n\tif wheels:\n\t\tassert(n > 0)\n\t\tassert(k > 0)\n\t\tassert(n - k > 0)\n\treturn perm(n, k, False) / math.factorial(n - k)\n\ndef tol(actual, expected, tolerance=10 ** -9):\n\tif type(actual) != type([]):\n\t\t(actual, expected) = ([ actual ], [ expected ])\n\tif len(actual) != len(expected):\n\t\treturn False\n\tr = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]\n\treturn sum(r) == len(r)\n\ndef btod(b):\n\treturn b * 2 - 1\n\ndef _sigma(f):\n\treturn f * (f + 1) / 2\n\n# sum(x from i to f)\ndef sigma(i, f, wheels=True):\n\tif wheels:\n\t\tassert(i >= 0)\n\t\tassert(f >= 0)\n\treturn _sigma(f) - _sigma(i - 1)\n\ndef ps(l, wheels=True):\n\tif wheels:\n\t\tassert(len(l) > 0)\n\tr = [ l[0] ] * len(l)\n\tfor i in xrange(1, len(l)):\n\t\tr[i] = l[i] + r[i - 1]\n\treturn r\n\ndef test_utilities():\n\tassert(stoi('1 2 3\\n') == [ 1, 2, 3 ])\n\tassert(stoi('') == stoi('\\n') == [])\n\tassert(perm(10, 5) == 30240)\n\tassert(comb(10, 5) == 252)\n\tassert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)\n\tassert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)\n\tassert(tol([ 1.0, 1.1 ], [ 2.0, 2.1 ], tolerance=1) == True)\n\tassert(tol([ 1, 2 ], [ 1 ]) == tol([ 1 ], [ 1, 2 ]) == False)\n\tassert(_sigma(1) == 1)\n\tassert(_sigma(10) == 55)\n\tassert(sigma(1, 10) == 55)\n\tassert(sigma(3, 10) == 52)\n\tassert(sigma(10, 10) == 10)\n\tassert(sigma(10, 11) == 21)\n\tassert(ps([ 1 ]) == [ 1 ])\n\tassert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])\n\tassert(btod(0) == -1)\n\tassert(btod(1) == 1)\n\tassert(btos(True) == 'YES')\n\tassert(btos(False) == 'NO')\n\n### ###\n# code follows #\n### ###\n\n# args = [ 'line 1', 'line 2', ... ]\ndef proc_input(args):\n\treturn args[0].strip()\n\ndef solve(args, verbose=False):\n\ts = proc_input(args)\n\tp = s[::-1]\n\tc = 0\n\tn = len(s) / 2\n\tl = s[n]\n\tif len(s) > 2:\n\t\tfor k in xrange(len(p) / 2 + 1):\n\t\t\tif c > 1:\n\t\t\t\tbreak\n\t\t\tif s[k + c] != p[k]:\n\t\t\t\t(n, l) = (len(p) - k, s[k])\n\t\t\t\tc += 1\n\telif len(s) == 2:\n\t\t(n, l) = (2, s[0])\n\tsucc = c < 2\n\tif succ:\n\t\ts = s[:n] + l + s[n:]\n\tif verbose:\n\t\tprint s if succ else 'NA'\n\treturn s if succ else False\n\ndef test():\n\tassert(solve([ 'revive' ], verbose=True) == 'reviver')\n\tassert(solve([ 'ee' ], verbose=True) == 'eee')\n\tassert(solve([ 'blah' ], verbose=True) == False)\n\tassert(solve([ 'e' ], verbose=True) == 'ee')\n\tassert(solve([ 'ef' ], verbose=True) == 'efe')\n\tassert(solve([ 'kitayuta' ], verbose=True) == False)\n\nif __name__ == '__main__':\n\tfrom sys import argv\n\tif argv.pop() == 'test':\n\t\ttest_utilities()\n\t\ttest()\n\telse:\n\t\tdbug = False\n\t\tsolve(list(fileinput.input()), verbose=True)\n"}, {"source_code": "s=input()\nif \"\".join(reversed(s))==s:\n if len(s)%2==0:\n print(s[:len(s)//2]+'l'+s[len(s)//2:])\n else:\n print(s[:len(s)//2]+s[len(s)//2]+s[len(s)//2:])\n exit()\nn=len(s)\na=[0]*(n+1)\nflag=0\ni=0\nj=n-1\nf=0\nl=n\nwhile(i<=j):\n if s[i]==s[j]:\n a[f]=s[i]\n f+=1\n a[l]=s[j]\n l-=1\n i+=1\n j-=1\n elif s[i]!=s[j] and flag==0:\n a[f]=s[i]\n f+=1\n a[l]=s[i]\n l-=1\n i+=1\n flag=1\n elif s[i]!=s[j] and flag:\n print(\"NA\")\n exit()\nprint(\"\".join(str(e) for e in a))\n "}, {"source_code": "import fileinput, math, collections\n\n### ###\n# utility func #\n### ###\n\ndbug = True\n\ndef btos(b):\n\treturn 'YES' if b else 'NO'\n\ndef pd(s, label=''):\n\tglobal dbug\n\tif dbug:\n\t\theader = 'debug:'\n\t\tif label != '':\n\t\t\theader += ' (%s)\\t' % label\n\t\tprint header, s\n\ndef stoi(s):\n\treturn([ int(x) for x in s.split() ])\n\ndef perm(n, k, wheels=True):\n\tif wheels:\n\t\tassert(n > 0)\n\t\tassert(k > 0)\n\treturn math.factorial(n) / math.factorial(k)\n\ndef comb(n, k, wheels=True):\n\tif wheels:\n\t\tassert(n > 0)\n\t\tassert(k > 0)\n\t\tassert(n - k > 0)\n\treturn perm(n, k, False) / math.factorial(n - k)\n\ndef tol(actual, expected, tolerance=10 ** -9):\n\tif type(actual) != type([]):\n\t\t(actual, expected) = ([ actual ], [ expected ])\n\tif len(actual) != len(expected):\n\t\treturn False\n\tr = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]\n\treturn sum(r) == len(r)\n\ndef btod(b):\n\treturn b * 2 - 1\n\ndef _sigma(f):\n\treturn f * (f + 1) / 2\n\n# sum(x from i to f)\ndef sigma(i, f, wheels=True):\n\tif wheels:\n\t\tassert(i >= 0)\n\t\tassert(f >= 0)\n\treturn _sigma(f) - _sigma(i - 1)\n\ndef ps(l, wheels=True):\n\tif wheels:\n\t\tassert(len(l) > 0)\n\tr = [ l[0] ] * len(l)\n\tfor i in xrange(1, len(l)):\n\t\tr[i] = l[i] + r[i - 1]\n\treturn r\n\ndef test_utilities():\n\tassert(stoi('1 2 3\\n') == [ 1, 2, 3 ])\n\tassert(stoi('') == stoi('\\n') == [])\n\tassert(perm(10, 5) == 30240)\n\tassert(comb(10, 5) == 252)\n\tassert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)\n\tassert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)\n\tassert(tol([ 1.0, 1.1 ], [ 2.0, 2.1 ], tolerance=1) == True)\n\tassert(tol([ 1, 2 ], [ 1 ]) == tol([ 1 ], [ 1, 2 ]) == False)\n\tassert(_sigma(1) == 1)\n\tassert(_sigma(10) == 55)\n\tassert(sigma(1, 10) == 55)\n\tassert(sigma(3, 10) == 52)\n\tassert(sigma(10, 10) == 10)\n\tassert(sigma(10, 11) == 21)\n\tassert(ps([ 1 ]) == [ 1 ])\n\tassert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])\n\tassert(btod(0) == -1)\n\tassert(btod(1) == 1)\n\tassert(btos(True) == 'YES')\n\tassert(btos(False) == 'NO')\n\n### ###\n# code follows #\n### ###\n\n# args = [ 'line 1', 'line 2', ... ]\ndef proc_input(args):\n\treturn args[0].strip()\n\ndef solve(args, verbose=False):\n\ts = proc_input(args)\n\tp = s[::-1]\n\tc = 0\n\tfor k in xrange(len(s) / 2):\n\t\tif s[k] != p[k]:\n\t\t\tc += 1\n\t\t\tp = p[:k] + s[k] + p[k:]\n\tif c == 0:\n\t\tp = p[len(s) / 2:] + p[len(s) / 2] + p[:len(s) / 2]\n\tsucc = c < 2\n\tif verbose:\n\t\tprint p if succ else 'NA'\n\treturn p if succ else False\n\ndef test():\n\tassert(solve([ 'revive' ], verbose=True) == 'reviver')\n\tassert(solve([ 'ee' ], verbose=True) == 'eee')\n\tassert(solve([ 'blah' ], verbose=True) == False)\n\tassert(solve([ 'e' ], verbose=True) == 'ee')\n\tassert(solve([ 'ef' ], verbose=True) == 'efe')\n\tassert(solve([ 'kitayuta' ], verbose=True) == False)\n\nif __name__ == '__main__':\n\tfrom sys import argv\n\tif argv.pop() == 'test':\n\t\ttest_utilities()\n\t\ttest()\n\telse:\n\t\tdbug = False\n\t\tsolve(list(fileinput.input()), verbose=True)\n"}, {"source_code": "s = input()\nn = len(s)\ni, j = 0, n-1\ncnt = 0\nif s == s[::-1]:\n k = n//2\n print(s[:k+1] + s[k:])\n exit()\nwhile(i < j):\n if s[i] == s[j]:\n i += 1\n j -= 1\n else:\n s = s[:j+1] + s[i] + s[j+1:]\n i += 1\n if len(s) > n + 1: print('NA'); exit()\nif n + 1 != len(s) and n != len(s):\n print('NA')\nelse: \n print(s)\n"}, {"source_code": "def lol():\n s=raw_input()\n s=list(s)\n start=0\n end=s.__len__()-1\n flag=0\n k=0\n\n while(start<end):\n if(s[start]!=s[end]):\n if flag==1:\n print \"NA\"\n k=1\n break\n else:\n s.insert(end+1,s[start])\n end=end+1\n flag=1\n if(end-start==1 and k==0):\n s.insert(start+1,'y')\n start=start+1\n end=end-1\n if s.__len__()==1:\n s.append(s[0])\n\n if k==0:\n print ''.join(s)\n\nlol()"}, {"source_code": "def ispalindrome(s):\n if(s == s[::-1]):\n return True\n else:\n return False\n \ns = input()\nz = list(s)\nif(ispalindrome(s)):\n if(len(z) % 2 == 0):\n z.insert(len(z)//2, \"q\")\n else:\n z.insert(len(z)//2, z[len(z) // 2])\n z = \"\".join(z)\n print(z)\nelse:\n s = list(s)\n k = s.copy()\n for i in range(len(s)):\n if(s.count(s[i]) == 1):\n k.insert(len(s) - i - 1, s[i])\n break\n \n k = ''.join(k)\n print(k)\n if(ispalindrome(k)):\n print(k)\n else:\n print(\"NA\")\n \n #print(*k)"}, {"source_code": "import os\n\ndef isAlreadyPalindrome(word):\n reverseWord = list(word)\n reverseWord.reverse()\n rWord = \"\".join(reverseWord)\n return word == rWord\ndef addAlphabet(word):\n newWord = word\n mid = len(word) / 2\n if len(word) % 2 == 0:\n newWord = word[0:mid] + 'a' + word[mid:]\n else:\n newWord = word[0:mid] + word[mid] + word[mid:]\n return newWord\nword = raw_input()\ni = 0\nj= len(word) - 1\nformedPalindrome = False\nif isAlreadyPalindrome(word) == True:\n print addAlphabet(word)\nelse:\n while i < j:\n if word[i] == word[j]:\n i += 1\n j -= 1\n else:\n tempword = word[0:j] + word[j] + word[i]\n if j < len(word) -1:\n tempword += word[j+1:]\n if isAlreadyPalindrome(tempword) == True:\n print tempword\n break;\n else:\n print \"NA\"\n break;\n\n\n \n"}, {"source_code": "def make_pallindrome(string):\n l = len(string)\n if l == 1:\n return string[0] + string[0]\n elif l % 2 == 0:\n chk = (string[:l/2] == string[l:l/2-1:-1])\n if chk:\n string = string[:l/2] + 'a' + string[l/2:]\n return string\n else:\n string = string[:] + string[0]\n l = len(string)\n chk = (string[:l/2] == string[l:l/2:-1])\n if chk:\n return string\n else:\n return \"NA\"\n else:\n chk = (string[:l/2] == string[l:l/2:-1])\n if chk:\n string = string[:l/2 + 1] + string[l/2] + string[l/2+1:]\n return string\n else:\n return \"NA\"\n\n\nif __name__ == '__main__':\n print make_pallindrome(raw_input())\n"}, {"source_code": "s = raw_input()\ni = 0\nj = len(s) - 1\nflag = 0\nwhile i < j:\n\tif s[i] != s[j] and flag == 0:\n\t\tif s[i+1] == s[j]:\n\t\t\ts = s[:j+1] + s[i] + s[j+1:]\n\t\t\tflag = 1\n\t\t\ti += 1\n\t\telif s[j-1] == s[i]:\n\t\t\ts = s[:i] + s[j] + s[i:]\n\t\t\tflag = 1\n\t\t\tj -= 1\n\t\telse:\n\t\t\tflag = 2\n\t\t\tprint \"NA\"\n\t\t\tbreak\n\t\t\n\telif s[i] != s[j] and flag == 1:\n\t\tflag = 2\n\t\tprint \"NA\"\n\t\tbreak\n\telse:\n\t\ti += 1\n\t\tj -= 1\nif flag == 1:\n\tprint s\nelif flag == 0:\n\tl = len(s)\n\tif l%2 == 0:\n\t\ts = s[:l/2] + 'a' + s[l/2:]\n\telse:\n\t\tc = s[l/2]\n\t\ts = s[:l/2] + c + s[l/2:]\n\tprint s\n\t\t\n"}, {"source_code": "def ispalindrome(s):\n if(s == s[::-1]):\n return True\n else:\n return False\n \ns = input()\nz = list(s)\nif(ispalindrome(s)):\n if(len(z) % 2 == 0):\n z.insert(len(z)//2, \"q\")\n else:\n z.insert(len(z)//2, z[len(z) // 2])\n z = \"\".join(z)\n print(z)\nelse:\n s = list(s)\n k = s.copy()\n for i in range(len(s)):\n if(s.count(s[i]) == 1):\n k.insert(len(s) - i, s[i])\n break\n \n k = ''.join(k)\n if(ispalindrome(k)):\n print(k)\n else:\n print(\"NA\")\n \n #print(*k)"}, {"source_code": "s = list(raw_input())\ni = 0\nins = False\nwhile (i < len(s)//2 ):\n n = len(s)\n if s[i] != s[n-1-i]:\n if ins or (i+1)*2==n: print \"NA\"; exit()\n ins = True\n if s[i] == s[n-2-i]:\n s.insert(i, s[n-1-i])\n else:\n s.insert(n-i, s[i])\n i += 1\nif not ins:\n l = s[len(s)//2] if len(s) & 1 else 'y'\n s.insert(len(s)//2, l)\nprint ''.join(s)\n"}, {"source_code": "from math import floor\ns=input()\nls=len(s)\nif ls==1:\n print('NA')\n exit()\nfor i in range (floor(ls/2)):\n isp=0\n if s[i]!=s[ls-i-1]:\n isp=1\n sn=s[:i]+s[ls-i-1]+s[i:]\n #print(sn)\n csn=0\n for j in range (floor(len(sn)/2)):\n if sn[j]!=sn[-j-1]:\n csn=1\n break\n if csn:\n csn=0\n sn=s[:ls-i]+s[i]+s[ls-i:]\n #print(sn)\n for j in range (floor(len(sn)/2)):\n if sn[j]!=sn[-j-1]:\n csn=1\n break\n break\nif isp:\n if csn:\n print('NA')\n else:\n print(sn)\nelse:\n if ls%2==1:\n print('NA')\n else:\n print(s[:floor(ls/2)]+'a'+s[floor(ls/2):])\n "}, {"source_code": "s = raw_input()\nn = len(s)\ndef f(s):\n\tn = len(s)\n\tfor i in range(n):\n\t\tif s[i] != s[n-1-i]: return False\n\treturn True\n\nif f(s):\n\ts = s[0:n/2]+'y'+s[n/2:]\n\tprint s\n\texit()\n\t\nflag = False\nfor a in range(n/2+1):\n\tif s[a] != s[n-1-a]:\n\t\tt = s[0:n-a]\n\t\tt += s[a]\n\t\tt += s[n-a:]\n\t\tif f(t):\n\t\t\tprint t\n\t\t\tflag = True\n\nif flag == False:\n\tprint \"NA\""}, {"source_code": "s = input()\nfor i in range(26):\n for j in range(len(s)+1):\n s1 = s[:i]+chr(ord('a')+i)+s[i:]\n if s1[::-1] == s1:\n print (s1)\n exit(0)\nprint ('NA')"}, {"source_code": "s = input()\nf = 0\nalpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\nfor i in range(len(s)+1):\n for j in alpha:\n t = s[:i]+ j + s[i:]\n print(t)\n if t==t[::-1]:\n print(t)\n exit()\n\nprint('NA')\n"}, {"source_code": "a=input()\ndead=False\nsemidead=False\nfr=0\nind=None\nd=0\nfor i in range(len(a)//2):\n\tif a[i-min(fr,0)]!=a[-i-1-max(fr,0)]:\n\t\tif d==0:\n\t\t\tif a[i]==a[-i-2]:\n\t\t\t\tfr=1\n\t\t\t\tind=i\n\t\t\t\td+=1\n\t\t\telif a[i+1]==a[-i-1]:\n\t\t\t\tfr=-1\n\t\t\t\tind=len(a)-i-1\n\t\t\t\td+=1\n\t\t\telse:\n\t\t\t\tdead=True\n\t\t\t\tprint('NA')\n\t\t\t\tbreak\n\t\telse:\n\t\t\tsemidead=True\n\t\t\tbreak\nif semidead:\n\td=0\n\tfr=0\n\tfor i in range(len(a)//2):\n\t\tif a[i-min(fr,0)]!=a[-i-1-max(fr,0)]:\n\t\t\tif d==0:\n\t\t\t\tif a[i]==a[-i-2]:\n\t\t\t\t\tif fr!=-1:\n\t\t\t\t\t\tif a[i+1]==a[-i-1]:\n\t\t\t\t\t\t\tfr=-1\n\t\t\t\t\t\t\tind=len(a)-i-1\n\t\t\t\t\t\t\td+=1\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\tdead=True\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\telse:\n\t\t\t\t\t\tind=i\n\t\t\t\t\t\td+=1\n\t\t\t\telif a[i+1]==a[-i-1]:\n\t\t\t\t\tif fr!=1:\n\t\t\t\t\t\tdead=True\n\t\t\t\t\t\tbreak\n\t\t\t\t\tind=len(a)-i-1\n\t\t\t\t\td+=1\n\t\t\t\telse:\n\t\t\t\t\tdead=True\n\t\t\t\t\tprint('NA')\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tdead=True\n\t\t\t\tprint('NA')\n\t\t\t\tbreak\nif not dead:\n\tif d==0:\n\t\tprint(a[0:len(a)//2],a[len(a)//2],a[len(a)//2::],sep='')\n\telif fr==1:\n\t\tprint(a[0:ind],a[-1-ind],a[ind::],sep='')\n\telse:\n\t\tprint(a[0:ind+1],a[len(a)-1-ind],a[ind+1::],sep='')"}, {"source_code": "import sys\nfrom operator import itemgetter\n\nfrom operator import mul # or mul=lambda x,y:x*y\nfrom fractions import Fraction\n\n\ndef main():\n pal = sys.stdin.readline().strip()\n n_pal = len(pal)\n inserted = False\n fucked_up = False\n\n for i_pal in range(n_pal):\n if pal[i_pal] != pal[n_pal - 1 - i_pal]:\n # print \n # print pal[i_pal], pal[n_pal - 1 - i_pal]\n if inserted:\n fucked_up = True\n break\n if pal[i_pal] == pal[n_pal - 2 - i_pal]:\n pal = pal[:i_pal] + pal[n_pal - 1 - i_pal] + pal[i_pal:]\n elif pal[i_pal + 1] == pal[n_pal - 1 - i_pal]:\n pal = pal[:n_pal - i_pal] + \\\n pal[i_pal] + pal[n_pal - i_pal:]\n\n else:\n fucked_up = True\n break\n # print pal \n # print \n\n inserted = True\n n_pal += 1 \n if fucked_up:\n print \"NA\"\n else:\n if not(inserted):\n pal = pal[:int(n_pal/2)]+'a'+pal[int(n_pal/2):]\n print pal\n\n\nmain()\n"}, {"source_code": " \nword = input().strip()\n\ndef testPalindrome(word):\n\tlength = len(word)\n\tfor x in range(int(length/2)):\n\t\tif (word[x] != word[length - 1 - x]):\n\t\t\treturn False\n\treturn True\n\ndef reverseString(word):\n\treturn word[::-1]\n\ndef findIndex(word1, word2):\n\tlength = len(word1)\n\tfor i in range(length):\n\t\tif (word1[i] != word2[i]):\n\t\t\treturn i\n\treturn -1\n\ndef findDiffIndex(word):\n\tnewString = \"\"\n\tif(len(word) % 2 == 0):\n\t\tfirst, second = word[:int(len(word)/2)], word[int(len(word)/2):][::-1]\n\t\t# print(first, second)\n\t\ta = findIndex(first, second)\n\t\tif (a == -1):\n\t\t\tnewString = first + 'x' + second[::-1]\n\t\t\tprint(newString)\n\t\telse:\n\t\t\tnewString = first[:a] + second[a] + first[a:] + second[::-1]\n\t\t\t# print(newString)\n\t\t\tif(testPalindrome(newString)):\n\t\t\t\tprint(newString)\n\t\t\telse:\n\t\t\t\tnewString = first + second[a:][::-1] + first[a] + second[:a][::-1]\n\t\t\t\t# print(newString)\n\t\t\t\tif(testPalindrome(newString)):\n\t\t\t\t\tprint(newString)\n\t\t\t\telse:\n\t\t\t\t\tprint('NA')\n\telse:\n\t\tfirst, second = word[:int(len(word)/2)], word[int(len(word)/2)+1:][::-1]\n\t\ta = findIndex(first, second)\n\t\t# print(first, second, a)\n\t\tmidChar = word[int(len(word)/2)]\n\t\tif (a == -1):\n\t\t\tnewString = first + midChar + midChar + second[::-1]\n\t\t\tprint(newString)\n\t\telse:\n\t\t\tnewString = first[:a] + second[a] + first[a:] + midChar + second[::-1]\n\t\t\t# print(newString)\n\t\t\tif(testPalindrome(newString)):\n\t\t\t\tprint(newString)\n\t\t\telse:\n\t\t\t\tnewString = first + second[a:][::-1] + midChar + first[a] + second[:a][::-1]\n\t\t\t\t# print(newString)\n\t\t\t\tif(testPalindrome(newString)):\n\t\t\t\t\tprint(newString)\n\t\t\t\telse:\n\t\t\t\t\tprint('NA')\t\t\n\n# print(word)\n# print(len(word))\n\nfindDiffIndex(word)\n\n"}, {"source_code": "\n\n# target Specialist \n\n# Author : raj1307 - Raj Singh\n# Date : 15.07.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pow,pi\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p1\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\n\ndef main():\n\n\n\n #for _ in range(ii()):\n \n\n s=si()\n\n \n if True:\n a=list(s)\n b=list(s)\n f=1\n n=len(s)\n for i in range(len(s)):\n\n if s[i]!=s[n-i-1]:\n a.insert(i,s[n-i-1])\n b.insert(n-i,s[i])\n f=0\n break\n\n if f==1:\n print(s)\n else:\n if a==a[::-1]:\n print(''.join(a))\n elif b==b[::-1]:\n print(''.join(b))\n else:\n print('NA')\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "s=input();\nlens=len(s);\nflag=0;\nfor i in range(0,lens+1):\n for j in range(ord('a'),ord('z')+1):\n s1=s;\n s1=s[:i]+chr(j)+s[i:];\n print(s1);\n s2=s1[::-1];\n if(s1==s2):\n print(s1);\n flag=1;\n break;\n if(flag==1):break;\nif(flag==0):print(\"NA\");\n"}, {"source_code": "import string\n\ndef main():\n s = input()\n for i in range(len(s)+1):\n for a in string.ascii_lowercase:\n ns = s[:i] + a + s[i:]\n if ns == ns[::-1]:\n print(ns)\n return\n\nif __name__ == '__main__':\n main() "}, {"source_code": "def ispal(st):\n for i in xrange(len(st)):\n if st[i] != st[-(i+1)]:\n return False\n return True\n\ndef oneDif(first,second):\n s1 = ''\n s2 = ''\n if len(first) > len(second):\n s1 = first\n s2 = second\n else:\n s1 = second\n s2 = first\n missing = ''\n pos = 0\n j = len(s2)-1\n for i in xrange(len(s1)):\n if s1[i] == s2[j]:\n j -= 1\n elif len(missing) == 0:\n missing = s1[i]\n pos = j+1\n else:\n return ''\n res = ''\n if pos == len(second):\n res = second + missing\n else:\n for i in xrange(len(second)):\n s = second[i]\n if i != pos:\n res += s\n else:\n res += missing\n res += s\n return first+res\n \n \n\ns = raw_input()\nif len(s) == 2:\n print s + s[0]\nelse:\n if len(s)%2 == 0:\n if ispal(s):\n print s[:len(s)/2]+'a'+s[len(s)/2:]\n else:\n done = False\n check = [len(s)/2,(len(s)/2)-1]\n for c in check:\n first = s[:c]\n second = s[c+1:]\n res = oneDif(first,second)\n if len(res) > 0:\n print res[:len(res)/2]+s[c]+res[len(res)/2:]\n done = True\n break\n if not done:\n print 'NA' \n \n else: \n done = False\n if ispal(s):\n mid = len(s)/2\n print s[:mid]+s[mid]+s[mid:]\n else:\n check = [len(s)/2,(len(s)/2)+1]\n for c in check:\n first = s[:c]\n second = s[c:]\n# print c,first,second\n res = oneDif(first,second)\n if len(res) > 0:\n print res\n done = True\n break\n if not done:\n print 'NA' \n \n \n"}, {"source_code": "def isPalin(s) :\n\trev=s[::-1]\n\tif s==rev:\n\t\treturn True\n\telse :\n\t\treturn False\n\ns=raw_input()\nn=len(s)\n\ni=0\nj=n-1\n\nwhile i<j and s[i]==s[j] :\n\ti+=1\n\tj-=1\nif i>=j :\n\tprint s[:i]+s[i]+s[i:]\nelse :\n\tif isPalin(s[i+1:j+2]) :\n\t\tprint s[:j+1]+s[i]+s[j+1:]\n\telif isPalin(s[i:j]) :\n\t\tprint s[:i]+s[j]+s[i:]\n\telse :\n\t\tprint \"NA\"\n\t\n"}], "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b"} {"source_code": "def lucknum():\n num=input(\"\")\n g=0\n c=0\n for i in num:\n if i==\"4\" or i==\"7\":\n c=c+1\n continue\n else:\n g=g+1\n continue\n if c==4 or c==7:\n print(\"YES\")\n else:\n print(\"NO\")\nlucknum()\n", "positive_code": [{"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[73]:\n\n\nmasukan = input()\nno = True\nn = 0\nfor i in masukan:\n if int(i) == 4 or int(i) == 7:\n n = n+1\nif float(n) / 4 == 1 or float(n) / 7 == 1:\n no = False\nif n == 0:\n no = True\nif no == True:\n print ('NO')\nelse:\n print ('YES')\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "n=int(input())\nl=int(0)\nwhile n>0:\n r=n%10\n if r==4 or r==7:\n l+=1\n n=n//10\n\nif l==4 or l==7:\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "#!/usr/bin/env python\nnumber = input();\ncounter = 0\nwhile number != 0 :\n rem = number%10\n if rem == 4 or rem == 7 :\n counter = counter + 1\n number = number/10;\nif counter == 4 or counter == 7:\n print \"YES\"\nelse:\n print \"NO\"\n\n "}, {"source_code": "number = raw_input()\ntotal = number.count(\"4\") + number.count(\"7\")\nprint 'YES' if total == 4 or total == 7 else 'NO'\n"}, {"source_code": "n=int(input())\nn=str(n)\na=n.count('4')\nb=n.count('7')\nsum=a+b\nnum=[]\nnum.append('4')\nnum.append('7')\nif len(n)>1:\n\tfor i in range(0,2**(len(n))-2):\n\t\tnum.append(num[i]+'4')\n\t\tnum.append(num[i]+'7')\nsum=str(sum)\nif sum in num:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "LuckyNumbers = [\"4\", \"7\"]\n \ndef count_how_many_luckynumber(num):\n a = list(str(num))\n count = 0\n for x in a:\n if x == \"7\" or x == \"4\":\n count += 1\n print(\"YES\" if count == 7 or count == 4 else \"NO\")\n \nif __name__ == \"__main__\":\n num = int(input(\"\"))\n count_how_many_luckynumber(num)"}, {"source_code": "n=int(input())\nx=str(n).count(\"4\")+str(n).count(\"7\")%4\nprint(\"YES\" if (str(n).count(\"4\")+str(n).count(\"7\"))==4 or (str(n).count(\"4\")+str(n).count(\"7\"))==7 else \"NO\")\n\n"}, {"source_code": "import sys\nn=int(input())\nL=R=0\nwhile(n):\n if(n%10==7): R=R+1\n if(n%10==4): L=L+1;\n n//=10\nif(R+L==4 or R+L==7 or R+L==44 or R+L==47 ):\tprint(\"YES\")\nelse:\tprint(\"NO\")"}, {"source_code": "def islucky(a):\n return set(str(a))|{'4','7'}=={'4','7'}\ndef isnearlylucky(a):\n return islucky(str(a).count('4')+str(a).count('7'))\nprint(\"YES\" if isnearlylucky(input()) else \"NO\")"}, {"source_code": "import sys\n\nstdInput = sys.stdin\nnum = stdInput.readline()\nnum = num.strip()\n\ntimes = num.count('4')+num.count('7')\n\nif times==4 or times==7 :\n print(\"YES\")\nelse :\n print(\"NO\")\n"}, {"source_code": "n=input()\ncount=0\nfor i in n:\n\td=int(i)\n\tif d==4 or d==7:\n\t\tcount=count+1\nif count==4 or count==7 :\n\tprint('YES')\nelse:\n\tprint('NO')\n\n"}, {"source_code": "def solver(n):\n c=0\n while(n > 0):\n \n if (n%10)==4 or (n%10)==7:\n c+=1\n n=n//10\n \n if c!=0 and (c==4 or c==7):\n return \"YES\"\n return \"NO\"\n\nif __name__=='__main__':\n print(solver(int(input())))"}, {"source_code": "def main():\n while True:\n try:\n ans = ''\n inp = raw_input()\n list1=[u for u in inp if u =='4'or u =='7']\n if len(list1) == 4 or len(list1) == 7:\n print 'YES'\n else:\n print 'NO'\n except EOFError: break\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#110A\na = input()\nlcount = a.count('4') + a.count('7')\nprint('YES' if (lcount == 4 or lcount == 7) else 'NO')"}, {"source_code": "#110A\na = input()\n# lcount = a.count('4') + a.count('7')\nprint('YES' if (a.count('4') + a.count('7') == 4 or a.count('4') + a.count('7') == 7) else 'NO')"}, {"source_code": "a = input()\nch = \" \"\na = ch.join(a)\na = a.split()\ncount = 0\nif len(a) == 1:\n print(\"NO\")\nelse:\n for i in range(len(a)):\n if a[i] == '4' or a[i] == '7':\n count += 1\n if count==4 or count==7:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = int(input())\nc = str(n).count('4') + str(n).count('7')\nif (c == 4 or c == 7) and c>0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = raw_input()\ndef lucky(s):\n\tsumm = sum(1 for x in s if x=='4' or x == '7')\n\treturn (summ == len(s))\nsumm = sum(1 for x in s if x=='4' or x == '7')\nif lucky(str(summ)):\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "n=raw_input()\nt=n.count(\"4\")+n.count(\"7\")\nif(t==4 or t == 7):\n\tprint(\"YES\")\nelse:\t\n\tprint(\"NO\")\n"}, {"source_code": "a = input()\nk, c = len(a), 0\nfor i in a:\n if i == '4' or i == '7':\n c = c + 1\nif(c == 4 or c == 7):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = raw_input()\nn = (int)(n)\ncount = 0\nwhile(n>0):\n\tif(n%10 == 4 or n%10 == 7):\n\t\tcount = count+1\n\tn = n/10\nif(count==0):\n\tprint(\"NO\")\n\texit(0)\nwhile(count>0):\n\tif(count%10 !=4 and count%10!=7):\n\t\tprint(\"NO\")\n\t\texit(0)\n\tcount = count/10\nprint(\"YES\")"}, {"source_code": "n = raw_input()\nc=0\nfor x in range(len(n)):\n if n[x]=='4' or n[x]=='7':\n\tc+=1\nif c==7 or c==4:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "par = raw_input()\nlucky = \"47\"\ncount = 0\nfor i in par:\n if i in lucky:\n count += 1\n\nflag = True\nfor i in str(count):\n if not i in lucky:\n print \"NO\"\n flag = False\n break\n \nif flag == True:\n print \"YES\""}, {"source_code": "par = raw_input()\nlucky = \"47\"\ncount = 0\nfor i in par:\n if i in lucky:\n count += 1\n\nif count == 4 or count == 7:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "x = raw_input()\nz = 0\nfor i in x:\n if '4' in i or '7' in i:\n z += 1\n else:\n pass\n\n\nif z == 4 or z == 7:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n=input()\nx=0\ny=0\nfor i in n:\n if (i=='4'):\n x+=1\n elif (i=='7'):\n y+=1\nif (((x+y)==4) or ((x+y)==7)):\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "n= raw_input()\n\nlucky= n.count('4')+ n.count('7')\n\nif lucky == 4 or lucky == 7:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jun 13 03:40:20 2016\n\n@author: Dell_\n\"\"\"\nimport sys\nif False:\n input = open('nearly.txt', 'r')\nelse:\n input = sys.stdin\n\nnumber = input.readline().strip()\nluckynumbers = []\ncheck = False\n\nfor a in range(1,1000 + 1):\n num = str(a)\n if num.count('4') + num.count('7') == len(num):\n luckynumbers.append(int(num))\n\nfor i in luckynumbers:\n if number.count('4') + number.count('7') == i:\n check = True\n break\n else:\n check == False\n\nif check:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "t = input()\nprint(['NO', 'YES'][t.count('4') + t.count('7') in [4, 7]])"}, {"source_code": "s = input()\nf = s.count('4')\nse = s.count('7')\nif f + se == 4 or f + se == 7:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "def problem_110a():\n lucky_numbers = 0\n number = raw_input(\"\")\n for x in number:\n if int(x) == 7 or int(x) == 4:\n lucky_numbers += 1\n if (lucky_numbers == 7 or lucky_numbers == 4):\n print \"YES\"\n else: print \"NO\"\nproblem_110a()"}, {"source_code": "s=raw_input()\ncount=0\nfor x in s:\n if(x==\"4\" or x==\"7\"):\n count+=1;\nif(count==4 or count==7):\n print \"YES\"\nelse:\n print \"NO\"\n \n"}, {"source_code": "x = int(input())\nf = 0\nwhile(x != 0):\n if (x % 10 == 4 or x % 10 == 7):\n f+=1\n x=x//10\n\nif f == 4 or f == 7:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "#266B\nz = list(input())\nresult = [4,7]\nfour = z.count(\"4\")\nseven = z.count(\"7\")\nif four + seven in result:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def isLucky(number_string):\n isLuckyv = True\n for k in range (0, len(number_string), 1):\n if number_string[k] != '4' and number_string[k] != '7':\n isLuckyv = False\n return isLuckyv\nline = list(input())\ncounter = 0\nfor i in line:\n if(i == \"4\" or i == \"7\"):\n counter += 1\nif(isLucky(str(counter))):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\nnum = input()\nnumlist = list(num)\nnum = 0\nfor i in range(len(numlist)):\n if(numlist[i] == '4' or numlist[i] == '7'):\n num += 1\n\nif num != 7 and num != 4:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n=input()\nc=0\nfor i in n:\n if i==\"4\" or i==\"7\":\n c+=1\nc=str(c)\nd=0\nfor i in range(len(c)):\n if c[i] != \"4\" and c[i] != \"7\":\n d+=1\nif d==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=list(map(int,input()))\na=n.count(4)+n.count(7)\nif a==4 or a==7:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t\n"}, {"source_code": "# template by 3xC and starkizard.\n# contributors: \n\n#####################################################################################\nimport sys\nimport os\nimport time\nimport collections\nfrom collections import Counter, deque\nimport itertools\nimport math\nimport timeit\nimport random\nimport string\nimport io\n#####################################################################################\n\n\ndef sieve(n):\n \"\"\" returns a list of prime numbers till n \"\"\"\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n\n\n\ndef divs(n, start=1):\n \"\"\" returns a list of all divisors till n \"\"\"\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n\n\n\ndef divn(n, primes):\n \"\"\" returns the number of divisors, two arguments n and the sieve till n \"\"\"\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\n\n\ndef lrfind(d, x, default=-1):\n \"\"\" Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found \"\"\"\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return default, default\n else:\n return left, right\n\ndef gcd(x, y): # math.gcd is slower\n \"\"\" returns greatest common divisor of x and y \"\"\"\n while y:\n x, y = y, x % y\n return x\n\ndef ceil(n, k): return n // k + (n % k != 0) #returns math.ceil but protecting against floating inconsistencies\ndef ii(): return int(input()) #inputs integer\ndef mi(): return map(int, input().split()) # inputting space seperated variables for example x,y,z\ndef li(): return list(map(int, input().split())) #inputting a space seperated list of integers\ndef lw(): return input().split() #inputting a space seperated list of strings\ndef lcm(a, b): return abs(a * b) // gcd(a, b) #returns LCM of two arguments\ndef prr(a, sep=' ', end='\\n'): print(sep.join(map(str, a)), end=end) #For printing an iterable with seperator sep as optional second argument (default : \" \"), ending character (default: \"\\n\") as optional third\ndef dd(): return collections.defaultdict(int) #returns a dictionary with values defaulted to 0\ndef ddl(): return collections.defaultdict(list) #returns a dictionary with values defaulted to []\n\n\n## Uncomment below line if using online judge for fast input\n## note this input also reads in \\n so remember to rstrip the input if using strings\n\n#input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n###################################################################\n#CODE GOES HERE:\ns=input()\ncount=0\nfor i in s:\n if i==\"4\" or i==\"7\":\n count+=1\ncheck=0\nfor i in str(count):\n if i!=\"4\" and i!=\"7\":\n check=1\n break\nprint([\"YES\",\"NO\"][check])"}, {"source_code": "s = input()\nprint( 'NYOE S'[sum([s.count('4') + s.count('7')])in [4,7] ::2] )\n"}, {"source_code": "a=int(input())\nst=[]\nst=[int(i) for i in ' '.join(str(a)).split()]\nc=0\nl,f=0,0\nfor i in range(len(st)):\n\tif st[i]==4 or st[i]==7:\n\t\tc+=1\n\tif st[i]==4:\n\t\tf=1\n\telif st[i]==7:\n\t\tl=1\nif (c==4 or c==7):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "def is_lucky_number():\n number = raw_input()\n qnty_digits = len( number )\n lucky_digits = 0 \n for i in xrange(0, qnty_digits):\n digit = int( number[i] )\n if digit == 4 or digit == 7:\n lucky_digits += 1\n if lucky_digits == 4 or lucky_digits == 7:\n return 'YES'\n else:\n return 'NO'\n\nprint(is_lucky_number())"}, {"source_code": "x=str(input())\nn=0\nfor i in x:\n if i=='4' or i=='7':\n n+=1 \nif n==4 or n==7:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\nk=list(str(n))\ns=[]\nfor i in k:\n s.append(int(i))\n \np=list(set(s))\np=sorted(p)\nl=[]\nl.append(s.count(4))\nl.append(s.count(7))\n \nif(sum(l)==7 or sum(l)==4):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x=input()\nelements = ['0','1','2','3','5','6','8','9']\n\ncnt=0\ncount=0\nfor element in elements:\n if element in x:\n cnt=cnt+1\nfor i in range(len(x)):\n if x[i]=='7' or x[i]=='4':\n count=count+1\nif count==7 or count==4:\n print('YES')\nelif '4' in x and '7' in x:\n if cnt==0 and count==7 or count==4:\n print('YES')\n else:\n print('NO')\n\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nl=list(map(int,str(n)))\n#print(l)\nl1=[4,7]\nk=list(set(l))\n\nflag=False\ns=l.count(4)\ns1=l.count(7)\n#print(s+s1)\nif(len(k)==1 and k[0]==7):\n flag=True\nelif(len(l)==1):\n flag=False\n\nelse:\n for i in l:\n if i in l1:\n \n flag=True\n else:\n flag=False\n break\n \nif(flag and( s+s1==4 or s+s1==7)):\n print('YES')\nelif(flag==False and( s+s1==4 or s+s1==7)):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=int(input())\ndef luky(x):\n for i in str(x):\n if i!='7'and i!='4':\n return False\n return True\nc=0\nfor i in str(a):\n if luky(i):\n c+=1\n#print(c)\nif luky(c):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n=int(raw_input())\ns=str(n)\nsuma=0\nfor i in s:\n if i==\"4\" or i==\"7\":\n suma+=1\nif suma==4 or suma==7:\n print \"YES\"\nelse:\n print\"NO\"\n"}, {"source_code": "a = input()\nans = None\ncount = 0\nfor i in range(len(a)):\n if a[i] == \"4\" or a[i] == \"7\":\n count += 1\n\nif count == 4 or count == 7:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n \n"}, {"source_code": "value = input()\ncount = 0\nfor i in value:\n if i==\"4\" or i ==\"7\":\n count+=1\n \nif count==4 or count ==7:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = str(input())\nk = 0\nfor i in range(0, len(n)):\n if '7' in n[i] or '4' in n[i]:\n k = k + 1\nif k == 7 or k == 4:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "x=input()\ncount=0\nx=x.replace(\"4\",\"7\") \nif x.count(\"7\")==4 or x.count(\"7\")==7:\n print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "s=raw_input()\nlst='12356890'\nmods=(4,7,47,74, 447, 474,477)\ntotal=s.count('7')+s.count('4')\ntotal=str(total)\ndef check(s):\n for n in lst:\n if n in s:\n return 'NO'\n return 'YES'\n\n\nprint (check(total))\n"}, {"source_code": "s=input()\nb=0\nc=0\nfor i in range(len(s)):\n if len(s)!=1:\n if s[i] == '4':\n c+=1\n elif s[i] == '7':\n b+=1\n\nif b+c==4 or b+c == 7:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\n\nn = list(sys.stdin.readline())[:-1]\n\nhappy = n.count('4') + n.count('7')\n\nif happy in [4, 7]:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "x=input()\nc=0\nfor i in x:\n if(i=='4' or i=='7'):\n c+=1\n\n\nif((c==4 or c==7) and c>0 ):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=input(\"\") \nj=0 \nfor i in range(len(a)):\n if a[i]=='4' or a[i]=='7': \n j=j+1 \nif j==4 or j==7: \n print(\"YES\")\nelse: \n print(\"NO\")\n"}, {"source_code": "n = (raw_input())\na = str(len(n))\n#print a[0]\nk=0\nfor i in range(0,int(len(n))):\n # print a[i]\n if n[i] == '4':\n k += 1\n elif n[i] == '7':\n k += 1\n else:\n continue\n#print k\nif k==4 or k==7:\n print \"YES\"\nelse:\n print \"NO\"\n \n\n"}, {"source_code": "a,k=input(),0\nfor i in a:\n if i=='7' or i=='4':k+=1\nif (len(set(str(k)))==2 and '4' and '7' in set(str(k))) or (len(set(str(k)))==1 and ('4' in set(str(k)) or '7' in set(str(k)))):print('YES')\nelse:print('NO')\n"}, {"source_code": "n=int(input())\nlucky=0\ndef check(n):\n count=1\n global lucky\n while(n):\n if(n%10==7 or n%10==4):\n lucky+=1\n else:\n count=0\n n//=10\n return(lucky)\nif(check(n) in [7,4] ):\n print(\"YES\")\nelse:\n # print(lucky)\n # m=lucky\n # if(check(m)==1):\n # print(\"YES\")\n # else:\n print(\"NO\")"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\ndef solve(n):\n c = 0\n while n > 0:\n d = n % 10\n n /= 10\n if d == 4 or d == 7:\n c += 1\n return \"YES\" if c == 4 or c == 7 else \"NO\"\n\ndef inp():\n return(int(input()))\n\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\n\nif __name__ == \"__main__\":\n i = inp()\n print(solve(i))\n"}, {"source_code": "a = raw_input()\ncount = a.count('4') + a.count('7')\ncount = str(count)\nb = bool\nfor i in range(len(count)):\n b = b and (count[i] in ('4', '7'))\nprint ('YES' if b else 'NO')"}, {"source_code": "a=raw_input()\na=long(a)\ncounter=0\n\nwhile a>0 :\n if a%10==4 or a%10==7 :\n counter+=1\n a=a/10\nif counter==int(4) or counter==int(7) :\n print(\"YES\")\n\nelse:\n print(\"NO\")"}, {"source_code": "n=input()\nc=0\nfor i in n:\n if i=='4' or i=='7':\n c+=1\nif c==4 or c==7:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\n\ncum = 0\nfor i in range(len(s)):\n\tif (int(s[i]) == 4 or int(s[i]) == 7):\n\t\tcum += 1\n\nif (cum == 4 or cum == 7):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "a = input()\nc = 0\nfor i in a:\n if i == \"4\" or i == \"7\":\n c += 1\n \nif c == 4 or c == 7:\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "s1=input()\nl1=0\nl2=0\nfor i in range(len(s1)):\n if s1[i]=='4':\n l1+=1\n elif s1[i]=='7':\n l2+=1\n\nif l1+l2==4 or l2+l1==7:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "if __name__==\"__main__\":\n n=(int)(input())\n l = [int(x) for x in str(n)]\n count=0\n for i in range(len(l)):\n if l[i]==4:\n count+=1\n elif l[i]==7:\n count+=1\n \n if count==4 or count==7:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 30.12.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[1] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\ndef main():\n \n\n #for _ in range(ii()):\n \n s=si()\n\n if str(s.count('4')+s.count('7')).count('4') + str(s.count('4')+s.count('7')).count('7')==len(str(s.count('4')+s.count('7'))):\n print('YES')\n else:\n print('NO')\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "from sys import stdin\nrr = lambda: stdin.readline().strip()\nrrm = lambda: map(int, rr().split())\n\nS = rr()\nluck = S.count('4') + S.count('7')\nprint 'YES' if set(str(luck)) <= {'4','7'} else 'NO'\n"}, {"source_code": "a =input()\nk=0\nb=a.count('4')\nc=a.count('7')\nd=c+b\nif(d==4 or d==7):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n "}, {"source_code": "import math\n\ndef main():\n t = input()\n flag = 0\n cnt=0\n for i in range(0, len(t)):\n if t[i] in '01235689':\n flag = 1\n else:\n cnt+=1\n \n if flag==0 and '4' in t and '7' in t and (cnt==4 or cnt==7):\n print('YES')\n elif (cnt == 4 or cnt == 7):\n print('YES')\n elif flag == 1:\n print('NO')\n else:\n print('NO')\n\nmain()"}, {"source_code": "s=input()\nc=0\nfor i in s:\n if i=='7'or i=='4':\n c+=1\nif c==4 or c==7:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s=list(raw_input())\ns=map(int,s)\nw=0\nfor i in s:\n if i==4 or i==7:\n w+=1\n\nif w==4 or w==7:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "a=input()\nfourcount=0\nsevencount=0\n\nfor i in a:\n if i == \"4\":\n fourcount+=1 \n \n if i == \"7\":\n sevencount+=1\n\nif len(a) == 1:\n print(\"NO\")\nelif fourcount == len(a) and fourcount != 7 and fourcount != 4:\n print(\"NO\")\nelif sevencount == len(a) and sevencount != 7 and sevencount != 4:\n print(\"NO\")\nelif fourcount+sevencount == len(a) and (fourcount+sevencount == 7 or fourcount+sevencount == 4): \n print(\"YES\")\nelif fourcount+sevencount == 7 or fourcount+sevencount == 4:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\ncnt = 0\nwhile n :\n if n % 10 == 4 or n % 10 == 7 :\n cnt += 1 \n n //= 10\nif not cnt :\n print('NO')\n exit(0)\nwhile cnt :\n if cnt % 10 != 4 and cnt % 10 != 7 :\n print(\"NO\")\n exit(0)\n cnt //= 10\nprint('YES')\n"}, {"source_code": "n = raw_input()\nl = (4,7)\np = n.count(\"4\")\ns = n.count(\"7\")\nif p+s ==4 or p+s ==7:\n print\"YES\"\nelif all((n in l) for i in n):\n print\"YES\"\nelse:\n print\"NO\""}, {"source_code": "a=input()\nx=[\"4\",\"7\"]\nb=[]\nc=[]\nfor i in range(len(a)):\n \n if a[i] in x and len(a)!=1:\n f=\"1\"\n y=((f.count(\"1\")))\n b.append(y)\n else:\n f=\"0\"\n w=((f.count(\"0\")))\n c.append(w)\nz=sum(b)\nif z>7:\n print(\"NO\")\nelif f==\"1\" and len(c)<=0:\n print(\"YES\")\nelif z==4:\n print(\"YES\")\nelif z==7:\n print(\"YES\")\nelif f==\"0\":\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nc=0\na=n\nwhile n>0:\n if n%10==7 or n%10==4:\n c=c+1\n n=n//10\nf=True\nz=c\nwhile c>0:\n if c%10==4 or c%10==7:\n c=c//10\n else:\n f=False\n break\nif z!=0:\n if f==False:\n print('NO')\n else:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\nd=0\nwhile n!=0:\n r=n%10\n if r==4 or r==7:\n d=d+1\n n=n//10\nif d==4 or d==7:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(raw_input())\ncount = 0\nwhile n != 0:\n if n % 10 == 4 or n % 10 == 7:\n count += 1\n n /= 10\nif count == 4 or count == 7:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n=raw_input()\n\ndef l(n):\n c=0\n for i in n:\n if i in \"47\":\n c+=1\n if c==4 or c==7:\n return \"YES\"\n return \"NO\"\n\nprint l(n)"}], "negative_code": [{"source_code": "n=int(input())\n\nnl = 0\nwhile(n>0):\n\tr = n%10\n\tif (r%4 == 0) or (r%7 == 0):\n\t\tnl = nl+1\n\tn = n//10\n\nif not(nl%7) or not(nl%4):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "num = input(\"\")\ncount=0\nfor i in num:\n if i == '4' or i == '7':\n count+=1\n\nar_print_korbi_nah = 0\n\n\nif count == 7 or count == 4:\n print(\"YES\")\n ar_print_korbi_nah=1\n\nc_2=0\n\n\nfor i in str(count):\n if (i == '7') or (i == '4'):\n c_2 += 1\n\n\nif (c_2 == len(str(count))):\n print(\"YES\")\n\n\n\nelse:\n print(\"NO\")\n\n#44444444444444444444444444447444444444444444444"}, {"source_code": "#CodeForces\n#Twins\n#Python 3.6.5\n\nimport sys\nimport math\n\nnum = int(input())\ncount = 0\nwhile(num):\n if num % 10 == 4 or num % 10 == 7:\n count += 1\n num = num // 10\n\nprint(count)\nif count == 4 or count == 7:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n \n \n"}, {"source_code": "a=int(input())\ndef luky(x):\n for i in str(x):\n if i!='7'and i!='4':\n return False\n return True\nc=0\nfor i in str(a):\n if luky(i):\n c+=1\nprint(c)\nif luky(c):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "x = input()\ncount = 0\nfor i in range(len(x)):\n if int(x[i])==4 or int(x[i])==7:\n count +=1\n\nif count==len(x):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "number = int(raw_input())\nnumber = str(number)\nlucky = [\"0\",\"1\",\"2\",\"3\",\"5\",\"6\",\"8\",\"9\"]\nif number==\"7\":print\"YES\"\nelif any(i in number for i in lucky):\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "def is_nearly_lucky_number(n):\n s = str(n)\n count = 0\n for x in s:\n print x\n if x != \"7\" and x != \"4\": continue\n else :\n count += 1\n if is_lucky(count) : print \"YES\"\n else : print \"NO\"\n \ndef is_lucky(n):\n s = str(n)\n for x in s:\n if x != \"7\" and x != \"4\": return False\n return True"}, {"source_code": "p = list(input())\ns = p.count('4') + p.count('7')\nif s == 0:\n print('NO')\nelif s % 4 == 0 or s % 7 == 0 or s % 47 == 0:\n print('YES')\n"}, {"source_code": "a=input()\n\nt=1\nh=a\nte=0\nu=0\nf2=0\nt2=1\n\nwhile h>0:\n te=te+1\n h=h//10\nwhile te>0:\n u=te%10\n if u!=4 and u!=7:\n f2=1\n te=te//10\nif f2==1:\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n = input()\nk = 0\nfor i in range(len(n)):\n if n[i]=='4' or n[i]=='7':\n k+=1\nif k == 4 or 7 or 47 or 74:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "\ndef solve() :\n a=input()\n c=0\n s=0\n for i in range(len(a)) :\n if int(a[i])==4 :\n c=c+1\n elif int(a[i])==7 :\n s=s+1\n else :\n return 1,c,s\n return 0,c,s\n\nh,c,s=solve()\n\nif (h==0 and c!=0 and s!=0) or(c!=0 and s!=0 and (c+s==4 or c+s==7)) :\n print(\"YES\")\nelse :\n print(\"NO\")\n\n"}, {"source_code": "n = input()\nc=0\nfor i in range(len(n)):\n if n[i]==\"4\" or n[i]==\"7\":\n c+=1\n else:\n break\n \nif c==len(n):\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "a = input()\nc = 0\ni = 0\nwhile i < len(a) :\n if (a[i] == \"4\") or (a[i] == \"7\") :\n c = c + 1\n i = i + 1\nif (c == 4) or (c == 7) :\n print(\"YES\")\nelse:\n print(\"N0\")"}, {"source_code": "n=int(input(\"\",))\nif(n%40047==1):\n print(\"NO\")\nelif (n%4==0 or n%7==0 or n%74==0 or n%47==0 or n%44==0 or n%444==0 or n%447==0 or n%474==0 or n%477==0 or n%777==0 or n%774==0 or n%744==0 or n%7747774==0):\n print(\"YES\")\nelse:\n print(\"Wrong\")"}, {"source_code": "\na=input()\nx=[\"4\",\"7\"]\nb=[]\nc=[]\nfor i in range(len(a)):\n \n if a[i] in x and len(a)!=1:\n f=\"1\"\n y=((f.count(\"1\")))\n b.append(y)\n else:\n f=\"0\"\n w=((f.count(\"0\")))\n c.append(w)\nz=sum(b)\nif a==\"444444444444444444\":\n print(\"NO\")\nelif f==\"1\" and len(c)<=0:\n print(\"YES\")\nelif z==4:\n print(\"YES\")\nelif z==7:\n print(\"YES\")\nelif f==\"0\":\n print(\"NO\")\n\nelse:\n print(\"NO\")"}, {"source_code": "number = str(input(\"\"))\nore = ['7','8']\ncount = 0\n\nfor i in ore:\n if i in number:\n count += 1\n if (count == 2):\n break\n\nif count == 2:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s=str(input())\na=s.count(\"4\")\nb=s.count(\"7\")\nc=a+b\nn=len(s)\nif(s==\"7\" or s==\"4\"):\n print(\"NO\")\nelif(c==0):\n print(\"NO\")\nelif(c==n):\n print(\"YES\")\nelif(c%4==0 or c%7==0):\n print(\"YES\")\nelif(c%47==0 or c%74==0 ):\n print(\"YES\")\nelif(c%447==0 or c%474==0 or c%477==0):\n print(\"YES\")\nelif(c%774==0 or c%747==0 or c%744==0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "test=input()\nflag=1\nc4=0\nc7=0\nfor x in test:\n\tif x =='4': \n\t\tc4=c4+1\n\telif x == '7':\n\t\tc7=c7+1\n\telse:\n\t\tflag=0\n\t\tbreak\nif c4>0 and c7>0 and flag!=0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "x = input()\ncount = 0\nif len(x) ==1:\n print(\"NO\")\nelse:\n for i in range(len(x)):\n if int(x[i])==4 or int(x[i])==7:\n count +=1\n\n if count==len(x):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "number=input()\nnumber1=list(str(number))\nbool=True\nif len(number)==1:\n bool=False\nfor character in number1:\n if character!=('7' or '4'):\n bool=False\nif not bool:\n number=int(number)\n bool1=False\n lucky_number=7\n lucky_numbers=['4','7']\n lucky_numbers_new=[]\n while lucky_number<number:\n for i in range(len(lucky_numbers)):\n num7=list(lucky_numbers[i])\n num4=num7[:]\n num4.append('4')\n num4=''.join(num4)\n num7.append('7')\n num7=''.join(num7)\n lucky_numbers_new.append(num4)\n lucky_numbers_new.append(num7)\n for new_number in lucky_numbers_new:\n lucky_numbers.append(new_number)\n lucky_numbers_new=[]\n lucky_number=int(lucky_numbers[-1])\n for lucky_num in lucky_numbers:\n if number%int(lucky_num)==0:\n ans=number//int(lucky_num)\n if str(ans) in lucky_numbers:\n bool1=True\nif (bool or bool1):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "val=list(input())\ncal=0\nflag=0\nfor i in val:\n if(i=='4' or i=='7'):\n cal+=1\n else:\n flag=1\nif(cal!=0 and flag==0):\n print('YES') \nelif(cal!=0 and flag!=0) :\n if(cal%4==0 or cal%7==0):\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')"}, {"source_code": "s=input()\nc=0\nfor i in s:\n if i=='7'or i=='4':\n c+=1\nif (c%4==0 or c%7==0) and c>0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "#Nearly Lucky Number\na={*input()}\nb=[]\nfor x in a:\n b.append(x)\nif b[0]==\"4\" or b[0]==\"7\":\n print(\"YES\")\nelif b[0]==\"4\" and b[1]==\"7\" or b[1]==\"4\" and b[0]==\"7\":\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\n\nsum=0;k=0\nfor i in range(0,len(str(n))):\n if n[i]=='4' or n[i]== '7' :\n sum=sum+1\n elif n[i]!=4 or n[i]!=7:\n\n k=k+1\n\n\nif sum == (4 or 7) or k==0:\n print(\"YES\")\nif k>=1 and sum!=(4 or 7):\n print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n=input()\nn=n.replace('4','')\nn=int(n)\nif n % 7 == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "a=0\nnumber=input()\nnumber=list(number)\nfor character in number:\n if character=='4':\n a+=1\n if character=='7':\n a+=1\nif a==('4'or'7'):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "t=int(raw_input())\nl=0\nwhile(t):\n a=t%10\n t=t/10\n if(a==4 or a==7):\n l+=1\nif((l%4==0 or l%7==0) and l!=0):\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "n = int(input())\nflag = 0\nc = 0\nwhile(n!=0):\n\tr = n%10\n\tif((r==4) or (r==7)):\n\t\tflag = 1\n\telse:\n\t\tc = c+1\t\n\tn = n//10\nif(flag == 1 and c == 0):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\t\t\t"}, {"source_code": "p = list(input())\ns = p.count('4') + p.count('7')\nif s == 0:\n print('NO')\nelif s % 4 == 0 or s % 7 == 0 or s % 47 == 0:\n print('YES')\n"}, {"source_code": "s = raw_input()\nprint 'YES' if s.translate(None, '47') == '' and s != '7' and s != '4' else 'NO'\n"}, {"source_code": "x = int(input())\nk = 0\nwhile x > 0:\n x = int(x/10)\n k += 1\nflag = 0\nwhile k > 0:\n l = k%10\n k = int(k/10)\n if l != 4 or l != 7:\n flag = 1\n break\nif flag == 1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "def nearly_lucky():\n #n = map(int, raw_input().split())\n integer = input()\n a = integer\n num_nearly_lucky = 0\n for i in range(len(str(integer))):\n s = integer % 10\n if s == 4 or s == 7:\n num_nearly_lucky += 1\n integer = integer / 10\n if num_nearly_lucky % 4 == 0 or num_nearly_lucky % 7 == 0:\n print \"YES\"\n else:\n print \"NO\"\n\nnearly_lucky()\n"}, {"source_code": "n=int(raw_input())\nwhile (n>0):\n x=n%10\n if x!=4 and x!=7:\n print 'NO'\n break\n n/=10\nelse:\n print 'YES'"}, {"source_code": "a=input()\nch=\" \"\na=ch.join(a)\na=a.split()\ncount=0\nif len(a)==1:\n print(\"NO\")\nelse:\n for i in range(len(a)):\n if a[i] == '4' or a[i] == '7':\n count += 1\n if len(a)==4 or len(a)==7:\n if count%4==0:\n print('YES')\n elif count%7==0:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")"}, {"source_code": "n = input()\ner = True\nfor number in n:\n if number == \"4\" or number == \"7\":\n pass\n else:\n er = False\n\nif er:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\nc,c1 = 0,0\nwhile (n!=0):\n if n%10==4 or n%10==7:\n c+=1\n n = int(n/10) \nwhile (c!=0):\n if (c%10==4 or c%10==7):\n c1+=1\n c = int(c/10)\nif (c1==len(str(c))):\n print ('YES')\nelse:\n print ('NO')"}, {"source_code": "s= input()\nsat=[]\nst=set()\nb=int(len(s))\nfor i in s:\n st.add(i)\nif s=='4':\n print('NO')\nelif b==4 or b==7:\n print('YES')\nelif len(st)==1:\n if ('4' or '7') in st:\n print('YES')\n else:\n print('NO')\n \nelif len(st)==2 and ('4' in st) and ('7' in st):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import sys\n\nn = list(sys.stdin.readline())[:-1]\n\nhappy = n.count('4') + n.count('7')\n\nif happy == len(n) or happy == '4' or happy == '7':\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = str(input())\nif n == '7' or n == '4':\n print('NO')\nelif n[0:4] == '4744' and '4' not in n[4:-1] and '7' not in n[4:-1]:\n print('YES')\nelif '0' in n or '1' in n or '2' in n or '3' in n or '5' in n or '6' in n or '8' in n or '9' in n:\n print('NO')\nelse:\n print('YES')\n\n"}, {"source_code": "n=input()\nn=n.replace('4','')\nif n is '7':\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s=input()\nc=0\nfor i in s:\n if i=='7'or i=='4':\n c+=1\nif c%4==0 or c%7==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\nflag=0\nc=0\nfor i in n:\n if i==\"4\" or i==\"7\":\n c+=1\n else:\n flag=1\n break\n \nif c==len(n):\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "n=int(input()) \nz=[]\nwhile(n!=0):\n k=n%10\n z.append(k)\n n=n//10\nz=list(set(z))\nz=sorted(z)\nif(z==[4,7]):\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "number=input()\ny=0\nfor i in range(len(number)):\n if number[i]=='4':\n y+=1\n elif number[i]=='7':\n y+=1\n else:\n print('NO')\n break\nif y == len(number):\n print('YES')\n\n"}, {"source_code": "n=int(input())\nn=str(n)\nn=list(n)\nfor i in n:\n if i!='4' and i!='7':\n ans='NO'\n else:\n ans='YES'\nprint(ans)"}, {"source_code": "n = (raw_input())\na = str(len(n))\n#print a[0]\nk=0\nfor i in range(0,int(len(n))):\n # print a[i]\n if n[i] == '4':\n k += 1\n elif n[i] == '7':\n k += 1\n else:\n continue\nprint k\nif k==4 or k==7:\n print \"YES\"\nelse:\n print \"NO\"\n \n\n"}, {"source_code": "n = input()\n\nsum = (n.count('4') + n.count('7'))\nif len(n) == sum and '4' in n and '7'in n:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\nif n==7:\n print('NO')\nelse:\n while n>0:\n t=n%10\n n=n//10\n if t==7 or t==4:\n continue\n else:\n print('NO')\n break\n else:\n print('YES')\n"}, {"source_code": "number = int(raw_input())\nnumbers = str(number)\nlucky = [\"0\",\"1\",\"2\",\"3\",\"5\",\"6\",\"8\",\"9\"]\nif number<10:print \"NO\"\nelif any(i in numbers for i in lucky):\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n = input()\na = 0\nb = len(n)\nc = 0\nfor i in range(b):\n if n[i] ==\"4\":\n a = a + 1\n c = c + 1\n if n[i] == \"7\":\n a = a + 1\n c = c + 1\n else:\n a = a + 1\na = a - 2\nif a == c:\n print(\"YES\")\nelif b == \"4\":\n print(\"YES\")\nelif b == \"7\":\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=input()\n# print(len(a))\ncount=0\nfor i in a:\n # print(i)\n if i=='4' or i=='7':\n count+=1\n # print(count)\nif count==len(a):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=raw_input()\nflag=0\nfor i in range (10):\n if str(i) in n:\n flag=1\nnflag = 0\nif (n.count('7')+n.count('4'))%7==0 and (n.count('7')+n.count('4'))!= 0:\n print \"YES\"\nelif (n.count('7')+n.count('4'))%4==0 and (n.count('7')+n.count('4'))!= 0:\n print \"YES\"\nelif flag:\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "N = int(input())\nsum=0\nflag = True\nwhile N>0:\n if N%10 == 7 or N%10 == 4:\n sum+=1\n else:\n flag=False\n N=int(N/10)\nif sum==4 or sum==7 or flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s=input()\nprint(\"YES\" if (all(i==\"4\" or i==\"7\" for i in s)and \"4\" in s and \"7\" in s) else \"NO\")"}, {"source_code": "x=input()\nc=0\nfor j in x:\n if(j=='4' or j=='7'):\n c+=1\n\n\nif(c%4==0 or c%7==0 ):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=input()\nch=\" \"\na=ch.join(a)\na=a.split()\ncount=0\nif len(a)==1:\n print(\"NO\")\nelse:\n for i in range(len(a)):\n if a[i] == '4' or a[i] == '7':\n count += 1\n print(count)\n if count == len(a):\n print(\"YES\")\n elif count==0:\n print(\"NO\")\n elif count%4==0:\n print(\"YES\")\n elif count%7==0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "s=input()\nn=list(s)\nk=0\nv=0\nfor i in range(len(n)):\n if n[i]==\"4\" :\n k+=1\n elif n[i] == \"7\":\n v+=1\nif k!=0 and v!=0 and ((k+v)==7 or (k+v)==4 or (k+v) == len(n)):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s=input()\nb=0\nc=0\nfor i in range(len(s)):\n if s[i] == '4':\n if len(s) != 1:\n c+=1\n elif s[i] == '7':\n if len(s) != 1:\n b+=1\nif b+c==len(s):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def lucky(que,digit=False):\n if not digit:\n if ('4' in que and '7' in que) and (set(que)=={'4','7'} or set(que)=={'7','4'}):\n return True\n else:\n return False\n if digit:\n if '4' in que or '7' in que:\n return True\n return False\n# def all_div(num):\n# arr=[]\n# for i in range(2,int((num**0.5))+1):\n# if num%i==0:\n# arr.append(i)\n# arr.append(num//i)\n # return arr\nnum=int(input())\nif lucky(str(num)):\n print(\"YES\")\nelse:\n arr=list(str(num))\n ct=str(arr.count('4')+arr.count('7'))\n # print(ct)\n if lucky(ct,True):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "inp=input()\ncount=0\ncount2=0\nfor i in inp:\n if i=='4':\n count=count+1\n elif i=='7':\n count2=count2+1\n\nif (count==4 or count==7) and count2==0:\n print('h2YES')\nelif (count2==4 or count2==7) and count==0:\n print('h3YES')\nelif count+count2==4 or count+count2==7:\n print('h4YES')\nelse:\n print('NO')\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Nov 3 13:42:41 2018\n\n@author: gjy\n\"\"\"\n\ns=input()\nn=len(s)\nnum=0\nfor i in range(n):\n if s[i]==4 or s[i]==7:\n num=num+1\nif num==4 or num==7:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "#Petyas Luck\nimport pdb\n\ndef Divs(g):\n while g > 0:\n if (g % 10) != 7 and (g % 10) != 4:\n return False\n g /= 10\n return True\n\nn = int(raw_input())\nif Divs(n) and n!=7 and n!=4:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n=int(input()) \np=len(str(n))\nz=[]\nwhile(n!=0):\n k=n%10\n z.append(k)\n n=n//10\nz=list(set(z))\nz=sorted(z)\nif(z==[4,7] or (p==4 or p==7)):\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "n=int(input())\nnl = 0\nwhile(n>0):\n if (n%10 == 7) or (n%10 == 4):\n nl = nl+1\n print(n%10)\n n = n//10\n\nif not(nl%7) or not(nl%4):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x=input()\nc=0\nfor i in x:\n if(i=='4' or i=='7'):\n c+=1\n\n\nif((c=='4' or c=='7') and c>0 ):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\nlucky=0\nwhile(n):\n if(n%7==0)or(n%4==0):\n lucky+=1\n n=n//10\n if(lucky==7)or(lucky==4):\n print(\"Yes\")\n else:\n print(\"No\")\n "}, {"source_code": "s = int(input())\nl = set(str(s))\nif(l == {'4','7'}):\n print('YES')\nelse:\n print('NO')\n \n"}, {"source_code": "n = raw_input()\n\nif len(str(n))==4 or len(str(n))==7:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "a = raw_input()\na = list(a)\n\nl = len(a)\ni=0\nf=0\ncount =0\nwhile i<l:\n if a[i] == '4' or a[i] =='7' and a[i] !=0 :\n count += 1\n i+=1\n \na= int(''.join(a))\n\n\nif count%7 == 0 or count%4 == 0:\n print \"YES\"\nelse:\n print\"NO\"\n"}, {"source_code": "x = input()\nfor i in x:\n if x == '7' or x == '4':\n print(\"Yes\")\n break\n else:\n print(\"No\")\n break\n"}, {"source_code": "n=int(input())\ndef lucky(n):\n ch=str(n)\n k=0\n \n for i in ch:\n if i=='4' or i=='7' :\n k+=1\n \n if ('4' in ch and '7' in ch):\n if k>1 and (k==7 or k==4):\n return(True)\n elif k>1:\n return(k)\n\nif n==4 or n==7:\n print('NO')\nelif lucky(n)==True :\n print('YES')\nelif (lucky(lucky(n)))==True :\n print('YES')\nelse:\n print('NO')"}, {"source_code": "s = input()\nn = list(s)\nif n.count('7') + n.count('4') >= 7 or 4:\n print('YES')\nelse:\n print('NO')\nprint(n.count('7'))"}, {"source_code": "n=raw_input()\n\ndef l(n):\n for i in n:\n if i not in \"47\":\n return \"NO\"\n return \"YES\"\n\nprint l(n)"}, {"source_code": "s = raw_input()\nif s.count('4') + s.count('7') == len(s) : print \"YES\"\nelse : print \"NO\"\n"}, {"source_code": "n=int(input())\na=0\nwhile n!=0:\n d=n%10\n if d==4 or d==7:\n a=a+1\n n=n//10\n if a==4 or a==7:\n print(\"nearely lucky\")\n break\n else:\n print(\"not lucly\")\n break"}, {"source_code": "# vowels = [\"a\", \"o\", \"y\", \"e\", \"u\", \"i\"]\n# s = list(input().lower())\n# ans = \"\"\n# for i in vowels:\n# if i in s:\n# while i in s:\n# s.remove(i)\n# for i in range(len(s)):\n# s[i] = \".\" + s[i]\n# print(ans.join(s))\n\n\n# n = int(input())\n# ans = 0\n# for i in range(n):\n#\n# s = input()\n# if \"-\" in s:\n# ans -= 1\n# if \"+\" in s:\n# ans += 1\n#\n#\n# print(ans)\n\n# s1 = input().lower()\n# s2 = input().lower()\n# isequal = False\n# for i in range(len(s1)):\n# if s1[i] > s2[i]:\n# print(\"1\")\n# isequal = True\n# break\n# if s2[i] > s1[i]:\n# print(\"-1\")\n# isequal = True\n# break\n# if not isequal:\n# print(\"0\")\n\n# s = list(input())\n# not_dangerous = False\n# for i in range(len(s)):\n# if i != len(s) - 1:\n# j = 0\n# while i + j <= len(s) - 1 and s[i] == s[i + j]:\n# j += 1\n# if j >= 7:\n# print(\"YES\")\n# not_dangerous = True\n# break\n# if not not_dangerous:\n# print(\"NO\")\n\n\n# s = list(input())\n# ans = \"\"\n# while \"+\" in s:\n# s.remove(\"+\")\n# s.sort()\n# for i in range(len(s)):\n# if i != len(s) - 1:\n# ans += s[i] + \"+\"\n# else:\n# ans += s[i]\n#\n# print(ans)\n\n\n# s = list(input())\n# capital_letter = s[0]\n# s = s[1:]\n# ans = \"\"\n# capital_letter = str(capital_letter).capitalize()\n# s = [capital_letter] + s\n# print(ans.join(s))\n\n# import math\n# matrix = []\n# for i in range(5):\n# matrix.append(list(map(int, input().split())))\n# if 1 in matrix[i]:\n# (x, y) = i, matrix[i].index(1)\n#\n# print(str(int(math.fabs(x - 2) + math.fabs(y - 2))))\n\n# input()\n# s = list(input())\n# ans = []\n# counter = 0\n# for i in range(len(s) - 1):\n# if s[i] == s[i + 1]:\n# counter += 1\n# else:\n# ans.append(s[i + 1])\n#\n# print(counter)\n\n# s = set(list(input()))\n# print(\"CHAT WITH HER!\" if len(s) % 2 == 0 else \"IGNORE HIM!\")\n\n# input()\n# groups = list(map(int, input().split()))\n# group_type = [0, 0, 0, 0]\n# ans = 0\n# for i in groups:\n# group_type[i - 1] += 1\n# ans += group_type[-1]\n#\n# group_type[-1] = 0\n#\n# ans += min(group_type[0], group_type[2])\n#\n# if group_type[0] < group_type[2]:\n# group_type[2] = group_type[2] - group_type[0]\n# group_type[0] = 0\n# elif group_type[0] == group_type[2]:\n# group_type[0] = 0\n# group_type[2] = 0\n# else:\n# group_type[0] = group_type[0] - group_type[2]\n# group_type[2] = 0\n#\n# ans += group_type[1] // 2\n#\n# group_type[1] = group_type[1] % 2\n#\n# if group_type[0]:\n# taxi = group_type[1] * 2\n# for i in range(group_type[0]):\n# if taxi == 4:\n# ans += 1\n# taxi = 0\n# taxi += 1\n#\n# if taxi:\n# ans += 1\n# else:\n# ans += group_type[2]\n# if group_type[1]:\n# ans += 1\n#\n# print(ans)\n\n# n = int(input())\n# minimum_capacity = 0\n# io_list = []\n# io_recorder = 0\n# for i in range(n):\n# io_list.append(tuple(map(int, input().split())))\n# if i == 0:\n# minimum_capacity = io_list[0][1]\n# io_recorder -= io_list[i][0]\n# io_recorder += io_list[i][1]\n# if minimum_capacity < io_recorder:\n# minimum_capacity = io_recorder\n# print(minimum_capacity)\n\n\n# n, index = map(int, input().split())\n# value_list = list(map(int, input().split()))\n# solved = False\n# pointer = 0\n# for i in range(len(value_list) + 1):\n# if pointer == index - 1:\n# print(\"YES\")\n# solved = True\n# break\n# if pointer < len(value_list):\n# pointer += value_list[pointer]\n# if not solved:\n# print(\"NO\")\n\n# import math\n#\n# n = int(input())\n# list1 = list(map(int, input().split()))\n# m = int(input())\n# list2 = list(map(int, input().split()))\n#\n# graph = dict()\n#\n# for i in list1:\n# graph[i] = []\n# if n > m:\n# n, m = m, n\n# list1, list2 = list2, list1\n#\n# for i in list1:\n# for j in list2:\n# if math.fabs(i - j) == 1:\n# graph[i].append(j)\n#\n# value_list = sorted(list(graph.values()))\n# # while graph:\n# for i in value_list:\n#\n\n# k, n, w = map(int, input().split())\n# cost = 0\n# for i in range(w):\n# cost += (i + 1) * k\n# if cost - n > 0:\n# print(cost - n)\n# else:print(\"0\")\n\n# n = int(input())\n# xi = 0\n# yi = 0\n# zi = 0\n# for i in range(n):\n# xyz = list(map(int, input().split()))\n# xi += xyz[0]\n# yi += xyz[1]\n# zi += xyz[2]\n# if xi == yi == zi == 0:\n# print(\"YES\")\n# else:\n# print(\"NO\")\n\n#\n# import sys\n# s = input()\n# print(\"YES\" if \"H\" in s or \"Q\" in s or \"9\" in s else (print(\"NO\"), sys.exit()))\n\n# s = input()\n# is_changed = False\n# if s.isupper():\n# print(s.lower())\n# is_changed = True\n#\n# if ord(s[0]) > 96 and (s[1:].isupper() or len(s) == 1):\n# print(s[0].upper() + s[1:].lower())\n# is_changed = True\n# if not is_changed:\n# print(s)\n\n\n# ans = 0\n# for i in range(int(input())):\n# p, q = map(int, input().split())\n# if q - p >= 2:\n# ans += 1\n# print(ans)\n\n\n# n, t = map(int, input().split())\n# main_list = list(input())\n# for i in range(t):\n# j = 0\n# while j < n:\n# if j != n - 1:\n# if main_list[j] == \"B\" and main_list[j + 1] == \"G\":\n# main_list[j], main_list[j + 1] = main_list[j + 1], main_list[j]\n# j += 1\n# j += 1\n# print(\"\".join(main_list))\n\n\nnumber = list(map(int, list(input())))\nlength = len(number)\nfor i in number:\n if i != 4 or i != 7:\n number.remove(i)\nif len(number) == 4 or len(number) == 7:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = raw_input()\nprint['NO', 'YES'] [(n.count('4')+n.count('7')) == len(n) and len(n) != 1]"}, {"source_code": "x=list(raw_input())\nflag=1\na=x.count('4')\nb=x.count('7')\nif a>0 and b>0 and a+b==len(x):\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "from sys import stdin\nrr = lambda: stdin.readline().strip()\nrrm = lambda: map(int, rr().split())\n\nS = rr()\nprint 'YES' if set(S) <= {'4', '7'} else 'NO'\n"}, {"source_code": "n=int(input())\nn=str(n)\na=n.count('4')\nb=n.count('7')\nsum=a+b\nnum=[]\nnum.append('4')\nnum.append('7')\nif len(n)>1:\n\tfor i in range(0,2**(len(n))-2):\n\t\tnum.append(num[i]+'4')\n\t\tnum.append(num[i]+'7')\nfor i in range(len(num)):\n\tnum[i]=int(num[i])\ncount=0\nfor i in range(len(num)):\n\tif sum/num[i]==0:\n\t\tcount+=1\nif count>0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "s = input()\na = s.count('4')\nb = s.count('7')\nif s == '7' or s=='4':\n print('NO')\nelif ((a+b) == len(s)):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\n\nn = list(sys.stdin.readline())[:-1]\n\nhappy = n.count('4') + n.count('7')\n\nif happy == len(n) or happy == '4' or happy == '7':\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "t=input()\nc=0\nfor i in [\"4\",\"7\"]:\n if(i in t):\n c+=1\n\nif(c==4 or c==7):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "l = list(input())\n\na = 0\nc = 0\n\nif l.count('4') == 0:\n a = 0\nelse:\n a = l.count('4')\n\nif l.count('7') == 0:\n c = 0\nelse:\n c = l.count('7')\n\nif a+c == len(l):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "num = raw_input()\nif not (set(num) -set('47')):\n\n print 'YES'\n \nelif num == '4' or num == '7' or len(num) == 4 or len(num) == 7:\n print 'YES'\nelse:\n print 'NO'\n\n\n"}, {"source_code": "#Petyas Luck\nimport pdb\n\ndef Divs(g):\n while g > 0:\n if (g % 10) != 7 and (g % 10) != 4:\n return False\n g /= 10\n return True\ndef Luck(n):\n if n % 4 == 0 or n % 7 == 0 or Divs(n):\n return True\n else:\n return False\n\nn = int(raw_input())\n\nDivs(n)\nif Luck(n):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "def lucky(que):\n ans=set(que)\n if len(ans)<=2:\n if len(ans)==2:\n if '4' in ans and '7' in ans:\n return True\n else:\n return False\n else:\n if '4' in ans or '7' in ans:\n return True\n else:\n return False\n# def all_div(num):\n# arr=[]\n# for i in range(2,int((num**0.5))+1):\n# if num%i==0:\n# arr.append(i)\n# arr.append(num//i)\n # return arr\nnum=int(input())\nif lucky(str(num)):\n print(\"YES\")\nelse:\n arr=list(str(num))\n if lucky(str(arr.count('4')+arr.count('7'))):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "#Petyas Luck\nimport pdb\n\ndef Divs(g):\n while g > 0:\n if (g % 10) != 7 and (g % 10) != 4:\n return False\n g /= 10\n return True\n\nn = int(raw_input())\nif Divs(n) and n!=7 and n!=4:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def lucky(que):\n if int(que)<10:\n return False\n ans=set(que)\n if len(ans)<=2:\n if len(ans)==2:\n if '4' in ans and '7' in ans:\n return True\n else:\n return False\n else:\n if '4' in ans or '7' in ans:\n return True\n else:\n return False\n# def all_div(num):\n# arr=[]\n# for i in range(2,int((num**0.5))+1):\n# if num%i==0:\n# arr.append(i)\n# arr.append(num//i)\n # return arr\nnum=int(input())\nif lucky(str(num)):\n print(\"YES\")\nelse:\n arr=list(str(num))\n if lucky(str(arr.count('4')+arr.count('7'))):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = raw_input()\nif len(n)==7 or len(n)==4:\n print(\"YES\")\nelif '4' in n and '7' in n:\n print(\"YES\")\nelif '1' in n and '0' in n:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "def lucky(que):\n ans=set(que)\n if len(ans)<=2:\n if len(ans)==2:\n if '4' in ans and '7' in ans:\n return True\n else:\n return False\n else:\n if '4' in ans or '7' in ans:\n return True\n else:\n return False\ndef all_div(num):\n arr=[]\n for i in range(2,int((num**0.5))+1):\n if num%i==0:\n arr.append(i)\n arr.append(num//i)\n return arr\nnum=int(input())\nif lucky(str(num)):\n print(\"YES\")\nelse:\n arr=all_div(num)\n # print(arr)\n count=0\n for div in arr:\n if lucky(str(div)):\n count+=1\n if count:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "s = input()\nfor ch in s:\n if ch == '4' or ch == '7':\n pass\n else:\n print('NO')\n exit()\nprint('YES')"}, {"source_code": "n=int(input()) \np=len(str(n))\nz=[]\nwhile(n!=0):\n k=n%10\n z.append(k)\n n=n//10\nz=list(set(z))\nz=sorted(z)\nif(z==[4,7] or (p==4 or p==7)):\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "n = raw_input()\nn = (int)(n)\ncount = 0\nwhile(n>0):\n\tif(n%10 == 4 or n%10 == 7):\n\t\tcount = count+1\n\tn = n/10\n\nwhile(count>=0):\n\tif(count%10 !=4 and count%10!=7):\n\t\tprint(\"NO\")\n\t\texit(0)\n\tcount = count/10\nprint(\"YES\")"}, {"source_code": "n = raw_input()\n\ncount = 0\n\nfor i in range(len(n)):\n if n[i] == 4 or n[i] == 7:\n count += 1\n\nif count == 4 or count == 7 or count == 47 or count == 74:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "s=list(input())\nprint(s)\nk=0\nw={'4','7'}\nfor i in s:\n if i=='4' or i=='7':\n k+=1\nk1=set(list(str(k)))\nif w>=set(s) and w>=k1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = int(input())\nwhile n :\n if n % 10 != 4 and n % 10 != 7 :\n print('NO')\n exit(0)\n n //= 10\nprint('YES')\n"}, {"source_code": "n = raw_input()\nd_c = set(n)\n\n# print (len(d_c), d_c.intersection(set('47')))\nif len(d_c) in [4,7] or set('47').union(d_c) == set('47') or d_c== set('4') or d_c == set('7') :\n print ('YES')\nelse:\n print ('NO')\n\n"}, {"source_code": "n = int(input())\nf = 4\ns = 7\nc = 0 \nwhile (n > 0): \n if (n % 10 == f or n%10 == s): \n c += 1\n n = int(n / 10)\nif(c == 4 or c == 7):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a = str(raw_input())\nn = len(a)\ni = 0\nans = []\nwhile n>0:\n if a[i] == \"4\" or a[i] == \"7\":\n ans.append(0)\n else:\n ans.append(1)\n i+=1\n n-=1\n\n\nif sum(ans) == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}], "src_uid": "33b73fd9e7f19894ea08e98b790d07f1"} {"source_code": "from itertools import *\nfrom collections import defaultdict\n\na = map(int, raw_input().split())\n\nprint min(a[-1]+1, min(a[:-2]))-min(a[-2], min(a[:-2]))\n", "positive_code": [{"source_code": "import sys\nfrom itertools import permutations\n\np1,p2,p3,p4,a,b = [ int(x) for x in sys.stdin.readline().strip().split(' ') ]\n\np = [p1,p2,p3,p4]\n\ndef calc(j,y):\n c,d,e,f = y\n if j == ((( j % c) % d ) %e ) %f:\n return 1\n return 0\n\ndef calc2(k):\n if sum([ calc(k,x) for x in permutations(p)]) >= 7:\n return 1\n return 0\n\nprint sum([calc2(z) for z in xrange(a, b+1)])\n\n"}, {"source_code": "import sys\nimport itertools\n\nx = map(int, sys.stdin.read().split())\n\np = x[:4]\na, b = x[4:]\n\nres = 0\nfor v in xrange(a, b+1):\n cnt = 0\n for pp in itertools.permutations(p):\n if ((((v % pp[0]) % pp[1]) % pp[2]) % pp[3]) == v:\n cnt+=1\n\n if float(cnt)/24 >= 0.314159265352718281828459045:\n res += 1\n\nprint res\n"}, {"source_code": "import sys\nfrom collections import defaultdict, Counter\nfrom itertools import permutations, combinations\nfrom math import sin, cos, asin, acos, tan, atan, pi\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition, yes = \"YES\", no = \"NO\", none = \"-1\") :\n if condition == None:\n print (none)\n elif condition :\n print (yes)\n else :\n print (no)\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rstr() :\n return sys.stdin.readline().strip()\n\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits[::-1]\n\ndef undigits(x, p) :\n value = 0\n for d in x :\n value *= p\n value += d\n return value\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\ndef vector_distance(a, b) :\n diff = vector_diff(a, b)\n \n return scalar_product(diff, diff) ** 0.5\n\ndef vector_inverse(v) :\n r = [-x for x in v]\n\n return tuple(r)\n\ndef vector_diff(a, b) :\n return vector_sum(a, vector_inverse(b))\n\ndef vector_sum(a, b) :\n r = [c1 + c2 for c1, c2 in zip(a, b)]\n \n return tuple(r)\n\ndef scalar_product(a, b) :\n r = 0\n for c1, c2 in zip(a, b) :\n r += c1 * c2\n\n return r\n\ndef check_rectangle(points) :\n assert(len(points) == 4)\n\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n sides = (\n vector_diff(A1, A2),\n vector_diff(A2, A3),\n vector_diff(A3, A4),\n vector_diff(A4, A1),\n )\n if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :\n return True\n return False\n\ndef check_square(points) :\n if not check_rectangle(points) :\n return False\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n side_lengths = [\n (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])\n ]\n if len(set(side_lengths)) == 1 :\n return True\n \n return False\n\ndef check_right(p) :\n # Check if there are same points\n for a, b in [\n (p[0], p[1]),\n (p[0], p[2]),\n (p[1], p[2]),\n ] :\n if a[0] == b[0] and a[1] == b[1] :\n return False\n\n a, b, c = p\n a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a) \n\n return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0\n\ndef modmatrixproduct(a, b, mod) :\n n, m1 = len(a), len(a[0])\n m2, k = len(b), len(b[0])\n\n assert(m1 == m2)\n m = m1\n\n r = [[0] * k for i in range(n)]\n for i in range(n) :\n for j in range(k) :\n for l in range(m) :\n r[i][j] += a[i][l] * b[l][j]\n r[i][j] %= mod\n return r\n\ndef modmatrixpower(a, n, mod) :\n magic = 2\n for m in [2, 3, 5, 7] :\n if n % m == 0 :\n magic = m\n break\n\n r = None\n if n < magic : \n r = a\n n -= 1\n else :\n s = modmatrixpower(a, n // magic, mod)\n r = s\n for i in range(magic - 1) :\n r = modmatrixproduct(r, s, mod)\n\n for i in range(n % magic) : \n r = modmatrixproduct(r, a, mod)\n \n return r\n\nv = rints()\np = v[:4]\na, b = v[4:]\nb = min(b, min(p) - 1)\nif b >= a :\n print b - a + 1\nelse :\n print 0\n"}, {"source_code": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])"}, {"source_code": "class Main:\n\ts=raw_input().split(\" \")\n\tl=[int(x) for x in s]\n\tm=min(l[0:len(l)-2])\n\ta=l[len(l)-2]\n\tb=l[len(l)-1]\n\tif(m>a and m<b):\n\t\tprint m-a\n\telif(m>a and m>b):\n\t\tprint b-a+1\n\telse: \n\t\tprint 0\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print fast\n#pt = lambda x: sys.stdout.write(str(x)+'\\n')\n\n#--------------------------------WhiteHat010--------------------------------------#\nfrom itertools import permutations\np1,p2,p3,p4,a,b = get_int_list()\nm = 0\nfor p in permutations([p1,p2,p3,p4]):\n count = 0\n for i in range(a,b+1):\n if i == (((i%p[0])%p[1])%p[2])%p[3]:\n count += 1\n m = max(m,count)\nprint(m)"}, {"source_code": "import itertools\nL = map(int, raw_input().split())\np = L[0:4]; a = L[4]; b = L[5]\np.sort()\n\nans = 0\nfor x in xrange(a, b+1):\n cnt = 0\n for perm in itertools.permutations(p, len(p)):\n cnt += ((((x % perm[0]) % perm[1]) % perm[2]) % perm[3]) == x\n ans += cnt >= 7\nprint ans\n"}, {"source_code": "import sys,math,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\np1,p2,p3,p4,b,a=M()\nk=min(p1,p2,p3,p4)\nc=0\nfor i in range(b,min(k,a+1)):\n c+=1\nprint(c)\n"}, {"source_code": "from itertools import permutations\n\n\nclass CodeforcesTask68ASolution:\n def __init__(self):\n self.result = ''\n self.pppp_a_b = []\n\n def read_input(self):\n self.pppp_a_b = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n prop = [0] * (1 + self.pppp_a_b[-1] - self.pppp_a_b[-2])\n for st in permutations(self.pppp_a_b[:4]):\n f = lambda x: (((x % st[0]) % st[1]) % st[2]) % st[3]\n for y in range(self.pppp_a_b[-2], self.pppp_a_b[-1] + 1):\n if f(y) == y:\n prop[y - self.pppp_a_b[-2]] += 1\n has_prop = [1 if x >= 7 else 0 for x in prop]\n self.result = str(sum(has_prop))\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask68ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\n"}, {"source_code": "p=map(int,raw_input().split())\nans=0\na=p[4]\nb=p[5]\nwhile a<=b:\n x=a\n for i in range(4):\n x=x%p[i];\n if x==a :ans=ans+1;\n a=a+1;\nprint ans;\n"}, {"source_code": "*l, a, b = map(int, input().split())\nprint(max(0, min(b + 1, *l) - a))"}, {"source_code": "from sys import stdin\n\n[p1,p2,p3,p4,a,b] = [int(x) for x in stdin.readline().strip().split()]\n\nprint(max(min([p1,p2,p3,p4,b+1])-a, 0))\n"}, {"source_code": "a = [int(i) for i in input().split()]\nif min(a[:len(a)-2]) < a[4]:\n print(0)\nelif min(a[:len(a)-2]) > a[5]:\n print(a[5] - a[4] + 1)\nelse:\n print(min(a[:len(a)-2])-a[4])\n"}, {"source_code": "inp = [int(x) for x in input().split()]\np = inp[:4]\na,b = inp[4],inp[5]\np = min(p)\ncnt = 0\nfor i in range(a,b+1):\n if i%p==i:\n cnt+=1\nprint(cnt)"}, {"source_code": "a = map(int,raw_input().split())\nm = min(a[:4])\nif a[4]>=m: print 0\nelse: print min(a[5],m-1)+1-a[4]\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\np1, p2, p3, p4, a, b = invr()\n\nm = min(p1, p2, p3, p4)\nres = 0\nif m >= a and m <= b:\n res = m-a\nelif m > b:\n res = b-a + 1\nelse:\n res = 0\nprint(res)\n"}, {"source_code": "'''\nCreated on 3 Mar 2011\n\n@author: salama\n'''\nimport copy\ndef dfs(i, y, x, v, res):\n if(i == len(x)):\n res.append(copy.deepcopy(y));\n else :\n for j in range(0, len(x)):\n if(v[j] == 0):\n v[j] = 1;\n y.append(x[j]);\n \n dfs(i+1, y, x, v, res);\n \n del y[i];\n v[j] = 0;\n \nx, y, res = [], [], [];\nv = [0, 0, 0, 0];\n\ninput = raw_input().split(' ');\nfor i in range(0, 6):\n x.append(int(input[i]));\n \ndfs(0, y, x[:4], v, res);\nans = 0;\nfor x in range(x[4], x[5]+1):\n c = 0;\n for perm in res:\n fx = x;\n for j in perm:\n fx = fx % j;\n if(fx == x):\n c+=1;\n \n if(c >= 7):\n ans+=1;\n \nprint ans; "}, {"source_code": "s = [int(x) for x in raw_input().split()]\ns[5] += 1\nprint max(0, min(s[:4]+s[5:])-s[4])\n\n"}, {"source_code": "s=[int(x) for x in raw_input().split()]\np=min(s[0:4])\na,b=s[4:6]\nif b<p: print b-a+1\nelif a<p<=b: print p-a\nelse: print 0\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(P,a,b):\n p = min(P) - 1\n if p < a:\n return 0\n elif p > b:\n return b-a+1\n else:\n return p-a+1\n\nS = input.readline().strip()\nA = [int(s) for s in S.split(' ') if len(s.strip())>0]\n\nP = A[:4]\nassert all(1<=p and p<=1000 for p in P)\nassert len(set(P)) == len(P)\n\na = A[4]\nb = A[5]\nassert 0<=a and a<=b and b<=31415\n\na = solve(P,a,b)\noutput.write('%s\\n' % a)\n"}, {"source_code": "line = raw_input().split()\np,a,b = map(int, line[:4]), int(line[4]), int(line[5])\nprint sum( [i<min(p) for i in range(a, b+1)] )\n"}, {"source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\n\nif __name__ == \"__main__\":\n inp = raw_input()\n input = inp.rsplit(' ')\n p1 = int(input[0])\n p2 = int(input[1])\n p3 = int(input[2])\n p4 = int(input[3])\n a = int(input[4])\n b = int(input[5])\n allkol=0\n min1 = min(p1,p2,p3,p4)\n if min1>a:\n allkol = min1-a\n if allkol > b-a+1:\n allkol = b-a+1\n else:\n allkol = 0\n\n print allkol"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,input().split())\nfrom itertools import permutations\nt = list(permutations([p1,p2,p3,p4]))\n# print(t)\ni = a\ncount = 0\nt1 = 0\nwhile i <= b:\n\tcount = 0\n\tfor j in t:\n\t\tif ((((i%j[0])%j[1])%j[2])%j[3]) == i:\n\t\t\tcount = count + 1\n\tif count >= 7:\n\t\tt1 = t1 + 1\n\ti = i + 1\nprint(t1)"}, {"source_code": "p1,p2,p3,p4,a,b=map(lambda x:int(x),input().split())\ntp=min([b,p1-1,p2-1,p3-1,p4-1])\nprint(max(0,tp-a+1))"}, {"source_code": "def f(x):\n return (((x%p1)%p2)%p3)%p4\np1,p2,p3,p4,a,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1):\n if f(i) == i: ans += 1\nprint(ans)"}, {"source_code": "import itertools\nl = []\ncont = 0\nr = 0\nl1 = list(map(int,input().strip().split()))[:6]\nl = l1[0:4]\nab = l1[4:6]\n\nfor x in range(ab[0],ab[1]+1):\n perm = itertools.permutations(l)\n for i in list(perm):\n if ((((x % i[0]) % i[1]) % i[2]) % i[3]) == x:\n cont += 1\n if cont >= 7:\n r += 1\n cont = 0\nprint (r)"}, {"source_code": "x1,x2,x3,x4,a,b = map(int,input().split(' '))\nminValue = min(x1,x2,x3,x4)\nif(b<minValue):\n print(b-a+1)\nelse:\n print(max(0,minValue-a))"}, {"source_code": "p1, p2, p3, p4, a, b = [int(i) for i in input().split()]\nprint(max(0, min(p1, p2, p3, p4, b + 1) - a))\n"}, {"source_code": "p1,p2,p3,p4,a,b=map(int,input().split())\nl=[p1,p2,p3,p4]\ncount=0\nfor i in range(a,b+1):\n r=i\n for j in l:\n r=r%j\n if r==i:\n count+=1\n\nprint(count)"}, {"source_code": "from time import *\n\n\nif __name__ == \"__main__\" :\n # start = time()\n p1 , p2 , p3 , p4 , a , b = map(int,input().strip().split())\n count = 0\n for i in range(a , b + 1) :\n if ((((i % p1)% p2)% p3) % p4) == i :\n count += 1\n print(count)\n # print(time() - start)\n"}, {"source_code": "p1, p2, p3, p4, a, b=map(int,raw_input().split())\nprint max(0, min(p1, p2, p3, p4, b+1)-a)\n"}, {"source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# import math\nfrom itertools import *\n# import random\n# import calendar\n# import datetime\n# import webbrowser\n\n\ndef function(x, lst):\n permu = permutations(lst, len(lst))\n count_ = 0\n for i in permu:\n temp = (((x % i[0]) % i[1]) % i[2]) % i[-1]\n if temp == x:\n count_ += 1\n if count_ >= 7:\n return True\n if count_ < 7:\n return False\n\n\np1, p2, p3, p4, a, b = map(int, input().split())\narr = [p1, p2, p3, p4]\ncount = 0\nfor i in range(a, b+1):\n if function(i, arr):\n count += 1\nprint(count)\n"}, {"source_code": "s = [int(i) for i in raw_input().split()]\nlst = s[0:4]\na = s[4]\nb = s[5]\nlst.sort()\nif lst[0] > a and lst[0] < b:\n print lst[0] - a\nelif lst[0] == b:\n print b - a\nelif lst[0] > b:\n print b - a + 1\nelse:\n print '0'\n"}, {"source_code": "mylist=list(map(int,input().split()))\na=0\nb=min(mylist[:4:]) - mylist[4]\nif(b>=0):\n a=min(b,mylist[5]-mylist[4]+1)\nprint(a)"}, {"source_code": "I=lambda:map(int, raw_input().split())\n\nimport itertools\np = I()\na = list(itertools.permutations([p[0],p[1],p[2],p[3]]))\n\ndef isOk(n):\n cnt = 0\n for x in a:\n z = n\n for y in x:\n z = z % y\n if z == n: cnt += 1\n if cnt >= 7: return True\n return False\n\nans = 0\nfor x in xrange(p[4], p[5]+1):\n if isOk(x): \n ans += 1\nprint ans"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,raw_input().split());\nprint max(0,min(p1,p2,p3,p4,b+1)-a);\n"}, {"source_code": "p1, p2, p3, p4, a, b = map(int, input().split())\nprint(max(0, min(p1, p2, p3, p4, b + 1) - a))"}, {"source_code": "p = [int(x) for x in input().split()]\nmod = min(p[0:4])\nif mod < p[4]:\n print(0)\nelse:\n if mod > p[5]:\n print(p[5] - p[4] + 1)\n else:\n print(mod - p[4])\n"}, {"source_code": "s = list(map(int, input().split()))\nlis = [s[0]]\nfor i in range(1,4):\n if s[i]<s[i-1]:lis.append(s[i])\ncnt = 0\nfor i in range(s[4], s[5]+1):\n m = i\n for j in lis:\n m = m%j\n if m == i: cnt += 1\nprint(cnt)"}, {"source_code": "import itertools\np1, p2, p3, p4, a, b = map(int, raw_input().split())\n\nans = 0\nfor x in xrange(a, b + 1):\n c = 0\n for p in list(itertools.permutations(sorted([p1, p2, p3, p4]))):\n if x % p[0] % p[1] % p[2] % p[3] == x:\n c += 1\n if c >= 7:\n ans += 1\nprint ans"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\ninp = readln()\nmod = min(inp[:4])\nprint(len([_ for _ in range(inp[4], inp[5] + 1) if _ < mod]))\n"}, {"source_code": "p1, p2, p3, p4, a, b = [int(i) for i in raw_input().split(' ')]\n\nans = 0\nfor i in range(a, b+1):\n if i == ((((i%p1)%p2)%p3)%p4):\n ans += 1\n\nprint ans\n\n\n"}, {"source_code": "nums = [int(i) for i in input().split()]\nps = min(nums[:-2])\na, b = nums[-2], nums[-1]\nres = max(0, ps-a)\nprint(res - max(0, ps-(b+1)))"}, {"source_code": "import math\np1,p2,p3,p4,a,b=map(int,input().split())\nc=0\nfor i in range(a,b+1):\n if (((i%p1)%p2)%p3)%p4==i:\n c+=1\nprint (c) \n"}, {"source_code": "*l, a, b = map(int, input().split())\nprint(max(0, min(b + 1, *l) - a))"}, {"source_code": "p1, p2, p3, p4, a, b = map(int, input().split())\nc = 0\nfor i in range(a, b+1):\n if i % p1 == i:\n if i % p2 == i:\n if i % p3 == i:\n if i % p4 == i:\n c += 1\nprint(c)\n"}, {"source_code": "import sys\n\nA = [int(x) for x in sys.stdin.readline().split()]\nprint max(min(A[:4] + [A[-1] + 1]) - min(A[-2:]), 0)\n"}, {"source_code": "p1, p2, p3, p4, a, b = [int(i) for i in raw_input().split()]\nprint sum(1 for i in range(a, b+1) if i == (((i % p1) % p2) % p3) % p4)\n"}, {"source_code": "from itertools import permutations\n\ndef f(x, p1, p2, p3, p4):\n return x % p1 % p2 % p3 % p4\n\ndef main():\n p1, p2, p3, p4, a, b = [int(i) for i in raw_input().split()]\n result = 0\n for x in xrange(a, b + 1):\n count = 0\n for args in permutations([p1, p2, p3, p4]):\n if f(x, *args) == x:\n count += 1\n if count > 6:\n result += 1\n print result\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = [int(i) for i in raw_input().split()]\nlst = s[0:4]\na = s[4]\nb = s[5]\nlst.sort()\nif lst[0] > a and lst[0] < b:\n print lst[0] - a\nelif lst[0] == b:\n print b - a\nelif lst[0] > b:\n print b - a + 1\nelse:\n print '0'\n"}, {"source_code": "n = [int(z) for z in raw_input().split(' ')]\nx=[]\na=n[-2]\nb=n[-1]\nz=0\nans=a\n\nfor j in range(a,b+1):\n\tans=j\n\tfor i in range(0,len(n)-2):\n\t\tans=ans%n[i]\n\tif ans==j:\n\t\tz=z+1\nprint z"}, {"source_code": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\n"}, {"source_code": "l=map(int,raw_input().split())\nmn=min(l[:-2])\nprint min(l[-1]+1,mn)-min(l[-2],mn)"}, {"source_code": "import sys\n\ndef f(x, p1, p2, p3, p4):\n return (((x % p1) % p2) % p3) % p4\n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\nnums = [int(i) for i in lines[0].split(\" \")]\n\np1 = nums[0]\np2 = nums[1]\np3 = nums[2]\np4 = nums[3]\na = nums[4]\nb = nums[5]\n\nc = 0\nfor i in range(a, b + 1):\n if i == f(i, p1, p2, p3, p4):\n c += 1\nprint c\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\n\np1, p2, p3, p4, a, b = [int(i) for i in raw_input().split()]\n\nmini = min(p1, p2, p3, p4)\n\nif b < mini:\n print(b - a + 1)\nelif mini < a:\n print(0)\nelse:\n print(mini - a)\n\n \n"}, {"source_code": "inp = map(int, raw_input().split())\nmn = min(inp[:4])\na,b = inp[-2:]\nif a <= mn <= b:\n print mn-a\nelif b < mn:\n print b-a+1\nelse:\n print 0"}, {"source_code": "\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a<=minp<=b+1:\n print minp-a\nelif minp > b+1:\n print b-a+1\nelse: print 0"}, {"source_code": "#68A\ntmp = map(int, raw_input().split())\na, b = tmp[4:6]\np = min(tmp[0:4])\nres = 0\nfor x in xrange(a, b + 1):\n if x < p: res += 1\nprint res"}, {"source_code": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\n"}, {"source_code": "from itertools import permutations as perm\np1,p2,p3,p4,a,b=map(int,raw_input().split())\nans=0\nfor d in xrange(a,b+1):\n c=0\n for p in perm((p1,p2,p3,p4)):\n if reduce(lambda x,y:x%y,p,d)==d:\n c+=1\n if c==7:\n ans+=1\n break\nprint ans\n"}, {"source_code": "a = map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\n "}, {"source_code": "r = raw_input().split()\nx = int(r[4])\nz = int(r[5])\ny = min(int(r[0]), int(r[1]), int(r[2]), int(r[3]))\nif x > y:\n print 0\nelif y > z:\n print str(z - x+1)\nelse:\n print str(y-x)"}, {"source_code": "p1,p2,p3,p4,a,b=map(int,raw_input().split())\nmina=min(p1,min(p2,min(p3,p4)))\nans=0\nfor no in xrange(a,b+1):\n\tif no<mina:\n\t\tans+=1\nprint ans"}, {"source_code": "import itertools\n\np = [0] * 4\np[0], p[1], p[2], p[3], a, b = map(int, input().split())\n\nans = 0\nfor i in range(a, b + 1):\n valid = 0\n for perm in itertools.permutations(p):\n if i == i % p[0] % p[1] % p[2] % p[3]:\n valid += 1\n ans += valid >= 7\nprint(ans)\n"}, {"source_code": "a,b,c,d,x,y=map(int,input().split())\nif x>=min(a,b,c,d):\n print(0)\nelse:\n print(min(min(a,b,c,d),y+1)-x)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,input().strip().split())\nm=min(min(min(p1,p2),p3),p4)\nif m<a:\n print(0)\nelse:\n t=(m-a)\n\n if b<m:\n t=t-(m-b-1)\n print(t) \n \n"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,input().strip().split())\nm=min(min(min(p1,p2),p3),p4)\nif m<a:\n print(0)\nelse:\n t=(m-a)\n if b<m:\n t=t-(m-b-1)\n print(t) \n \n"}, {"source_code": "# import itertools\n\n# def q68a():\n# \tp1, p2, p3, p4, low, high = tuple([int(num) for num in input().split()])\n# \tp = list(itertools.permutations([p1, p2, p3, p4], 4))\n# \tnum_good = 0\n# \tfor i in range(low, high+1):\n# \t\tcount = 0\n# \t\tfor t in p:\n# \t\t\tif(i == q68a_mod_operation(i, t[0], t[1], t[2], t[3])):\n# \t\t\t\tcount += 1\n# \t\tif(count >= 7):\n# \t\t\tnum_good += 1\n# \tprint(num_good)\n\n# def q68a_mod_operation(num, a, b, c, d):\n# \treturn (((num % a) % b) % c) % d\n\n# q68a()\n\np1, p2, p3, p4, low, high = tuple([int(num) for num in input().split()])\nmin_p = min(p1, p2, p3, p4)\nprint(min(max(min_p - low, 0), high-low+1))"}, {"source_code": "\np1, p2, p3, p4, a, b = map(int, input().split())\np_min = min(p1, p2, p3, p4)\nresult = 0\n\nfor x in range(a, b+1):\n if x == x % p_min:\n result += 1\n\nprint(result)\n"}, {"source_code": "import itertools\n\np1, p2, p3, p4, a, b = map(int, input().split())\npermutations = list(itertools.permutations([p1, p2, p3, p4]))\nresult = 0\n\nfor x in range(a, b+1):\n count = 0\n for permutation in permutations:\n y = x\n for p in permutation:\n y %= p\n if y == x:\n count += 1\n if count >= 7:\n result += 1\n\nprint(result)\n"}], "negative_code": [{"source_code": "import sys\nfrom collections import defaultdict, Counter\nfrom itertools import permutations, combinations\nfrom math import sin, cos, asin, acos, tan, atan, pi\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition, yes = \"YES\", no = \"NO\", none = \"-1\") :\n if condition == None:\n print (none)\n elif condition :\n print (yes)\n else :\n print (no)\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rstr() :\n return sys.stdin.readline().strip()\n\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits[::-1]\n\ndef undigits(x, p) :\n value = 0\n for d in x :\n value *= p\n value += d\n return value\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\ndef vector_distance(a, b) :\n diff = vector_diff(a, b)\n \n return scalar_product(diff, diff) ** 0.5\n\ndef vector_inverse(v) :\n r = [-x for x in v]\n\n return tuple(r)\n\ndef vector_diff(a, b) :\n return vector_sum(a, vector_inverse(b))\n\ndef vector_sum(a, b) :\n r = [c1 + c2 for c1, c2 in zip(a, b)]\n \n return tuple(r)\n\ndef scalar_product(a, b) :\n r = 0\n for c1, c2 in zip(a, b) :\n r += c1 * c2\n\n return r\n\ndef check_rectangle(points) :\n assert(len(points) == 4)\n\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n sides = (\n vector_diff(A1, A2),\n vector_diff(A2, A3),\n vector_diff(A3, A4),\n vector_diff(A4, A1),\n )\n if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :\n return True\n return False\n\ndef check_square(points) :\n if not check_rectangle(points) :\n return False\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n side_lengths = [\n (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])\n ]\n if len(set(side_lengths)) == 1 :\n return True\n \n return False\n\ndef check_right(p) :\n # Check if there are same points\n for a, b in [\n (p[0], p[1]),\n (p[0], p[2]),\n (p[1], p[2]),\n ] :\n if a[0] == b[0] and a[1] == b[1] :\n return False\n\n a, b, c = p\n a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a) \n\n return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0\n\ndef modmatrixproduct(a, b, mod) :\n n, m1 = len(a), len(a[0])\n m2, k = len(b), len(b[0])\n\n assert(m1 == m2)\n m = m1\n\n r = [[0] * k for i in range(n)]\n for i in range(n) :\n for j in range(k) :\n for l in range(m) :\n r[i][j] += a[i][l] * b[l][j]\n r[i][j] %= mod\n return r\n\ndef modmatrixpower(a, n, mod) :\n magic = 2\n for m in [2, 3, 5, 7] :\n if n % m == 0 :\n magic = m\n break\n\n r = None\n if n < magic : \n r = a\n n -= 1\n else :\n s = modmatrixpower(a, n // magic, mod)\n r = s\n for i in range(magic - 1) :\n r = modmatrixproduct(r, s, mod)\n\n for i in range(n % magic) : \n r = modmatrixproduct(r, a, mod)\n \n return r\n\nv = rints()\np = v[:4]\na, b = v[4:]\nb = min(b, min(p))\nif b > a :\n print b - a\nelse :\n print 0\n"}, {"source_code": "import sys,math,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\np1,p2,p3,p4,b,a=M()\nk=min(p1,p2,p3,p4)\nif(k<b):\n print(0)\nelif(k>a):\n print(b-a)\nelse:\n print(k-b)\n \n"}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n\nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n newnumber = 0\n while number > 0:\n newnumber += number % base\n number //= base\n return newnumber\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s):\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n\n\na = li()\nprint(max(0, min(min(a[:4]), a[5]) - min(min(a[:4]), a[4])))\n"}, {"source_code": "p1,p2,p3,p4,a,b=map(int,input().split())\nm=min(p1,p2,p3,p4)\nif m-a<=0:\n\tprint(0)\nelse:\n\tprint(m-a)"}, {"source_code": "a = [int(i) for i in input().split()]\nif min(a[:len(a)-2]) < a[4]:\n print(0)\nelif min(a[:len(a)-2]) > a[5]:\n print(a[5] - a[4])\nelse:\n print(min(a[:len(a)-2])-a[4])\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\np1, p2, p3, p4, a, b = invr()\n\nm = min(p1, p2, p3, p4)\nres = 0\nif m >= a and m <= b:\n res = m-a\nelif m > b:\n res = b-a\nelse:\n res = 0\nprint(res)\n"}, {"source_code": "class Main:\n\ts=raw_input().split(\" \")\n\tl=[int(x) for x in s]\n\tm=min(l[0:len(l)-2])\n\ta=l[len(l)-2]\n\tif(m>a):\n\t\tprint m-a\n\telse:\n\t\tprint 0\n"}, {"source_code": "from sys import stdin\n\n[p1,p2,p3,p4,a,b] = [int(x) for x in stdin.readline().strip().split()]\n\nprint(max(min([p1,p2,p3,p4,b])-a, 0))\n"}, {"source_code": "from sys import stdin\n\n[p1,p2,p3,p4,a,b] = [int(x) for x in stdin.readline().strip().split()]\n\nprint(min([p1,p2,p3,p4,b])-a)\n"}, {"source_code": "import sys\n\n\n\np1,p2,p3,p4,a,b=map(int,raw_input().split())\n\n"}, {"source_code": "'''\nCreated on 3 Mar 2011\n\n@author: salama\n'''\nb = 0\nw = []\ny = raw_input()\na = 0 \nx = y.split(' ')\ndef permutate(seq): \n if not seq:\n return [seq]\n else: \n temp = [] \n for k in range(len(seq)): \n part = seq[:k] + seq[k+1:] \n #print k, part # test \n for m in permutate(part): \n temp.append(seq[k:k+1] + m) # # test \n return temp\nfor i in range(int(x[4]),int(x[5])):\n for list2 in permutate(x[:4]):\n if int(i)%int(list2[0])%int(list2[1])%int(list2[2])%int(list2[3])== i:\n b += 1\n if b >= 7:\n a += 1\n break \n \nprint a"}, {"source_code": "s = [int(x) for x in raw_input().split()]\nprint max(0, min(s[:4]+s[5:])-s[4])\n"}, {"source_code": "from itertools import permutations as p\nr=map(int,raw_input().split())\nP=p(r[:4])\nprint len([ x for x in range(r[4],r[5]+1) if sum([ x == eval('%'.join(map(str, [x]+list(e)))) for e in P])>6])"}, {"source_code": "l=map(int,raw_input().split())\nmn=min(l[:-2])\nprint min(l[-1]-1,mn)-min(l[-2],mn)"}, {"source_code": "\ndef readints():\n return map(int,raw_input().split())\n\ndef main():\n p1,p2,p3,p4,a,b=readints()\n m=min(p1,p2,p3,p4)\n u=min(b-1,m)\n print max(u-a,0)\n\nmain()\n"}, {"source_code": "def solve():\n line = map(int, str(raw_input()).split())\n b,a = line.pop(-1), line.pop(-1)\n mini= min(line)\n if b>=a: minim = a\n else: minim = b\n total = mini-minim\n if(total < 0): print 0\n else: print total\n\nsolve()\n"}, {"source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\n\nif __name__ == \"__main__\":\n inp = raw_input()\n input = inp.rsplit(' ')\n p1 = int(input[0])\n p2 = int(input[1])\n p3 = int(input[2])\n p4 = int(input[3])\n a = int(input[4])\n b = int(input[5])\n allkol=0\n min1 = min(p1,p2,p3,p4)\n if min1>a:\n allkol = min1-a\n else:\n allkol = 0\n\n print allkol"}, {"source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\ndef f(x,p1,p2,p3,p4):\n return (((x % p1) % p2) % p3) % p4\n\nif __name__ == \"__main__\":\n inp = raw_input()\n input = inp.rsplit(' ')\n p1 = int(input[0])\n p2 = int(input[1])\n p3 = int(input[2])\n p4 = int(input[3])\n a = int(input[4])\n b = int(input[5])\n allkol=0\n for x in range(a,b):\n kol = 0\n for i in [p1,p2,p3,p4]:\n for j in [p1,p2,p3,p4]:\n if j!=i:\n for k in [p1,p2,p3,p4]:\n if k not in(j,i):\n for m in [p1,p2,p3,p4]:\n if m not in (j,i,k):\n if x==f(x,i,j,k,m):\n kol+=1\n if kol>7:\n allkol+=1\n print allkol"}, {"source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\ndef f(x,p1,p2,p3,p4):\n return (((x % p1) % p2) % p3) % p4\n\nif __name__ == \"__main__\":\n inp = raw_input()\n input = inp.rsplit(' ')\n p1 = int(input[0])\n p2 = int(input[1])\n p3 = int(input[2])\n p4 = int(input[3])\n a = int(input[4])\n b = int(input[5])\n allkol=0\n if (a!=b):\n for x in range(a,b):\n kol = 0\n for i in [p1,p2,p3,p4]:\n for j in [p1,p2,p3,p4]:\n if j!=i:\n for k in [p1,p2,p3,p4]:\n if k not in(j,i):\n for m in [p1,p2,p3,p4]:\n if m not in (j,i,k):\n if x==f(x,i,j,k,m):\n kol+=1\n if kol>7:\n allkol+=1\n print allkol"}, {"source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\ndef f(x,p1,p2,p3,p4):\n return (((x % p1) % p2) % p3) % p4\n\nif __name__ == \"__main__\":\n inp = raw_input()\n input = inp.rsplit(' ')\n p1 = int(input[0])\n p2 = int(input[1])\n p3 = int(input[2])\n p4 = int(input[3])\n a = int(input[4])\n b = int(input[5])\n allkol=0\n if a!=b:\n for x in range(a,b):\n kol = 0\n for i in [p1,p2,p3,p4]:\n for j in [p1,p2,p3,p4]:\n if j!=i:\n for k in [p1,p2,p3,p4]:\n if k not in(j,i):\n for m in [p1,p2,p3,p4]:\n if m not in (j,i,k):\n if x==f(x,i,j,k,m):\n kol+=1\n if kol>7:\n allkol+=1\n print allkol"}, {"source_code": "line = raw_input().split()\np1 = int(line[0])\np2 = int(line[1])\np3 = int(line[2])\np4 = int(line[3])\na = int(line[4])\nb = int(line[5])\ncount = 0\nfor i in range(a,b+1):\n print i\n if i == (((i%p1)%p2)%p3)%p4:\n count+=1\nprint count\n"}, {"source_code": "line = raw_input().split()\np1 = int(line[0])\np2 = int(line[1])\np3 = int(line[2])\np4 = int(line[3])\na = int(line[4])\nb = int(line[5])\ncount = 0\nfor i in range(a,b):\n if i == (((i%p1)%p2)%p3)%p4:\n count+=1\nprint count\n"}, {"source_code": "import string\n\ndef ii():\n ii = []\n for s in string.split(raw_input()):\n ii.append(int(s))\n return ii\n\nii = ii()\na = min(ii[0], ii[1], ii[2], ii[3])\nif (ii[4] >= a):\n print 0\nelse:\n print min(a, ii[5]) - ii[4]\n\n"}, {"source_code": "L=[int(x) for x in raw_input().split()]\na=min(L[0:4])\nif a<L[4]:\n print 0\nelse:\n print a-L[4]"}, {"source_code": "L=[int(x) for x in raw_input().split()]\na=min(L[0:4])\nif a<L[4]:\n print 0\nelse:\n print min(a-L[4],L[5]-L[4])"}, {"source_code": "p1,p2,p3,p4,a,b=map(int, raw_input().split())\nm=p1\nif p2<m:\n\tm=p2\nif p3<m:\n\tm=p3\nif p4<m:\n\tm=p4\nif a<b<m:\n\tprint b-a\nelif a<m:\n\tprint m-a\nelse:\n print 0\n"}, {"source_code": "p1,p2,p3,p4,a,b=map(int, raw_input().split())\nm=p1\nif p2<m:\n\tm=p2\nif p3<m:\n\tm=p3\nif p4<m:\n\tm=p4\nif a<b<m:\n\tprint b-a\nelif a<m:\n\tprint m-a\n"}, {"source_code": "p1, p2, p3, p4, a, b=map(int,raw_input().split())\nprint max(0, min(p1, p2, p3, p4, b)-a)\n"}, {"source_code": "\n\n\np1,p2,p3,p4,a,b = [int(k) for k in raw_input().split(\" \")]\ns=[p1,p2,p3,p4]\ni = 1000000\nfor k in s:\n if k<i :\n i=k\n\not = i-a\nif ot<0 :\n ot=0\nprint ot\n"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,raw_input().split());\nprint max(0,min(p1,p2,p3,p4,b)-a);\n"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,raw_input().split());\nprint max(0,min(p1,p2,p3,p4)-a);\n"}, {"source_code": "'''\nCreated on 29.04.2011\n\n@author: andrew\n'''\nimport sys,re\n\nstart=0\n\ndef read_int_line(file=sys.stdin):\n return map(int,re.findall(\"\\d+\", file.readline()))\nif __name__ == '__main__': \n arr=read_int_line()\n it=min(arr[0:4]) \n print max(0,min(it-arr[4],arr[5]-arr[4]))\n \n \n "}, {"source_code": "p1, p2, p3, p4, a, b = [int(i) for i in raw_input().split(' ')]\n\nans = 0\nfor i in range(a, b):\n if i == ((((i%p1)%p2)%p3)%p4):\n ans += 1\n\nprint ans\n\n\n"}, {"source_code": "p1, p2, p3, p4, a, b = [int(i) for i in raw_input().split(' ')]\n\nans = 0\nfor i in range(a, b):\n if i == ((((i%p1)%p2)%p3)%p4):\n ans += 1\n\nif a == 0 and b == 0:\n ans += 1\n\nprint ans\n\n\n"}, {"source_code": "X = list(map(int, input().split()));print(max(0, min(X[:4]) - X[-2]))\n\n# UB_CodeForces\n# Advice: Falling down is an accident, staying down is a choice\n# Location: Mashhad for few days\n# Caption: Finally happened what should be happened\n# CodeNumber: 694\n"}, {"source_code": "a,b,p1,p2,p3,p4=map(lambda x:int(x),input().split())\ntp=min([b,p1-1,p2-1,p3-1,p4-1])\nprint(max(0,tp-a+1))"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,input().split())\nfrom itertools import permutations\nt = list(permutations([p1,p2,p3,p4]))\nprint(t)\ni = a\ncount = 0\nt1 = 0\nwhile i <= b:\n\tcount = 0\n\tfor j in t:\n\t\tif ((((i%j[0])%j[1])%j[2])%j[3]) == i:\n\t\t\tcount = count + 1\n\tif count >= 7:\n\t\tt1 = t1 + 1\n\ti = i + 1\nprint(t1)"}, {"source_code": "p1, p2, p3, p4, a, b = map(int, input().split())\nm = min(p1, p2, p3, p4)\nprint(m - a if m - a > 0 else 0)\n"}, {"source_code": "p1, p2, p3, p4, a, b = map(int, input().split())\nm = min(p1, p2, p3, p4)\nif m > b:\n b = m\nprint(m - a if m - a > 0 else 0)\n"}, {"source_code": "mylist=list(map(int,input().split()))\na=0\nb=min(mylist[:4:]) - mylist[4]\nif(b>=0):\n a=b\nprint(a)"}, {"source_code": "a,b,c,d,e,f = map(int,input().split())\ng = min([a,b,c,d])\nprint(max(0,min(g,f)-e))\n"}, {"source_code": "a,b,c,d,e,f = map(int,input().split())\ng = min([a,b,c,d])\nif e==f==0:\n print(1)\nelse:\n print(max(0,min(g,f)-e))\n"}, {"source_code": "*P, a, _ = map(int, input().split())\n\nprint(max(0, min(P)-a))"}, {"source_code": "s = list(map(int, input().split()))\nlis = [s[0]]\nfor i in range(1,4):\n if s[i]<s[i-1]:lis.append(s[i])\ncnt = 0\nfor i in range(s[4], min(lis)):\n m = i\n for j in lis:\n m = m%j\n if m == i: cnt += 1\nprint(cnt)"}, {"source_code": "nums = [int(i) for i in input().split()]\nps = min(nums[:-2])\na = nums[-2]\nprint(max(0, ps-a))"}, {"source_code": "nums = [int(i) for i in input().split()]\nps = min(nums[:-2])\na, b = nums[-2], nums[-1]\nres = max(0, ps-a) + max(0, ps-b)\nprint(res)\n"}, {"source_code": "l = list(map(int, input().split()))\na = l.pop(4)\nprint(max(0, min(l) - a))"}, {"source_code": "import sys\nI=sys.stdin.readline\n\n\np1,p2,p3,p4,a,b=map(int,I().split())\n\n\nx=min(p1,p2,p3,p4)\n\nif x>=a:\n\tprint(0)\nelse:\n\tif x>b:\n\t\tprint(b-a+1)\n\telse:\n\t\tprint(x-a)"}, {"source_code": "import sys\n\nA = [int(x) for x in sys.stdin.readline().split()]\nprint max(min(A[:4]) - min(A[-2:]), 0)\n"}, {"source_code": "p1, p2, p3, p4, a, b = [int(i) for i in raw_input().split()]\nprint sum(1 for i in range(a, b) if i == (((i % p1) % p2) % p3) % p4)\n"}, {"source_code": "#!/usr/bin/python\n\nw = raw_input()\np1, p2, p3, p4, a, b = map(int, w.split())\np = min(p1, p2, p3, p4)\nif a < p:\n print min(b - a, p - a)\nelse:\n print 0\n"}, {"source_code": "s = [int(i) for i in raw_input().split()]\nlst = s[0:4]\na = s[4]\nb = s[5]\nlst.sort()\nif lst[0] > a and lst[0] < b:\n print lst[0] - a\nelse:\n print '0'\n"}, {"source_code": "s = raw_input().split()\nr = 0\nfor i in range(4):\n p = int(s[i])\n if i == 0 or p < r:\n r = p\nn = int(s[4])\nm = int(s[5])\nr = r - n\nif r < 0:\n r = 0\nprint r"}, {"source_code": "p1, p2, p3, p4, a, b = map(int, raw_input().split())\np = min(p1, p2, p3, p4)\nif p > a:\n\tprint p - a\nelse:\n\tprint 0"}, {"source_code": "\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a<=minp<=b+1:\n print max(minp,b)-a\nelse: print 0"}, {"source_code": "\n# data = int(raw_input())\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a<minp<b:\n print minp-a\nelse: print 0"}, {"source_code": "\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a<=minp<=b+1:\n print minp-a\nelif minp > b+1:\n print b-a\nelse: print 0"}, {"source_code": "\n# data = int(raw_input())\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a<=minp<b:\n print minp-a\nelse: print 0"}, {"source_code": "\n\n# data = int(raw_input())\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a<=minp<b+1:\n print minp-a\nelse: print 0"}, {"source_code": "\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a<=minp<=b+1:\n print minp-a\nelse: print 0"}, {"source_code": "\n# data = int(raw_input())\ndata = map(int, raw_input().split())\n\np, (a,b) = data[:4], data[4:]\n\nminp = min(p)\nif a==b==0: print 0\nelse:\n if a<minp<b:\n print minp-a\n else: print 0"}, {"source_code": "#68A\ntmp = map(int, raw_input().split())\na, b = tmp[4:6]\np = min(tmp[0:4])\nprint min(b, p) - min(p, a)\n"}, {"source_code": "r = raw_input().split()\nx = int(r[4])\nz = int(r[5])\ny = min(int(r[0]), int(r[1]), int(r[2]), int(r[3]))\nif x > y:\n print 0\nelif y > z:\n print str(z - x)\nelse:\n print str(y-x)"}, {"source_code": "r = raw_input().split()\nx = int(r[4])\ny = min(int(r[0]), int(r[1]), int(r[2]), int(r[3]))\nif x > y:\n print 0\nelse:\n print str(y-x)"}, {"source_code": "p1,p2,p3,p4,a,b=map(int,raw_input().split())\nmina=min(p1,min(p2,min(p3,p4)))\nans=0\nif mina<a:\n\tprint 0\nelse:\n\tupp=min(b,mina)\n\tfor no in xrange(a,upp):\n\t\tif no<mina:\n\t\t\tans+=1\n\tprint ans"}, {"source_code": "q=input()\np1,p2,p3,p4,a,b=map(int,q.split())\np=min(p1,p2,p3,p4)\nc=0\nif p>=b:\n c=b-a\nelif p>a:\n c=p-a\nelse:\n c=0\nprint(c)\n"}, {"source_code": "import itertools\n\np = [0] * 4\np[0], p[1], p[2], p[3], a, b = map(int, input().split())\n\nans = 0\nfor i in range(a, b):\n valid = 0\n for perm in itertools.permutations(p):\n if i == i % p[0] % p[1] % p[2] % p[3]:\n valid += 1\n ans += valid >= 7\nprint(ans)\n"}, {"source_code": "a,b,c,d,x,y=map(int,input().split())\nif x>=min(a,b,c,d):\n print(0)\nelse:\n print(min(a,b,c,d)-x)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,input().strip().split())\nm=min(min(min(p1,p2),p3),p4)\nif m<a:\n print(0)\nelse:\n print(m-a)\n \n"}, {"source_code": "p1,p2,p3,p4,a,b = map(int,input().strip().split())\nm=min(min(min(p1,p2),p3),p4)\nif m<a:\n print(0)\nelse:\n print(m-a-(m-b))\n \n"}, {"source_code": "# import itertools\n\n# def q68a():\n# \tp1, p2, p3, p4, low, high = tuple([int(num) for num in input().split()])\n# \tp = list(itertools.permutations([p1, p2, p3, p4], 4))\n# \tnum_good = 0\n# \tfor i in range(low, high+1):\n# \t\tcount = 0\n# \t\tfor t in p:\n# \t\t\tif(i == q68a_mod_operation(i, t[0], t[1], t[2], t[3])):\n# \t\t\t\tcount += 1\n# \t\tif(count >= 7):\n# \t\t\tnum_good += 1\n# \tprint(num_good)\n\n# def q68a_mod_operation(num, a, b, c, d):\n# \treturn (((num % a) % b) % c) % d\n\n# q68a()\n\np1, p2, p3, p4, low, high = tuple([int(num) for num in input().split()])\nmin_p = min(p1, p2, p3, p4)\nprint(max(min_p - low, 0))"}], "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a"} {"source_code": "gr = []\nfor i in range(0,11):\n\tar = map(str, raw_input().split())\n\tif len(ar) != 0:\n\t\tst = ar[0]+ar[1]+ar[2]\n\t\tgr.append(st)\n\t\na = map(int, raw_input().split())\ndef w( x, y,gr):\n\tfl = 0\n\tgg = gr[:]\n\tfor i in range(x*3, x*3+3):\n\t\tss = ''\n\t\tfor j in range(y*3,y*3+3):\n\t\t\tif gg[i][j] == '.':\n\t\t\t\tss += '!'\n\t\t\t\tfl = 1\n\t\t\telse:\n\t\t\t\tss += gg[i][j]\n\t\tgg[i] = gg[i][:y*3] +ss+gg[i][y*3+3:]\n\tif fl == 1:\n\t\treturn gg\n\telse:\n\t\treturn -1\n\nx = (a[0]-1)%3 \ny = (a[1]-1)%3\nif w(x,y,gr) == -1:\n\tfor i in range(0,9):\n\t\tss = ''\n\t\tfor j in range(0, 9):\n\t\t\tif gr[i][j] == '.':\n\t\t\t\tss = ss+'!'\n\t\t\telse:\n\t\t\t\tss = ss+gr[i][j]\n\t\tgr[i] = ss\n\tfor i in range(0,9):\n\t\tfor j in range(0,7,3):\n\t\t\tprint gr[i][j:j+3],\n\t\tprint \n\t\tif i == 2 or i==5:\n\t\t\tprint\nelse:\n\tgr = w(x,y,gr)\n\tfor i in range(0,9):\n\t\tfor j in range(0, 7, 3):\n\t\t\tprint gr[i][j:j+3],\n\t\tprint\n\t\tif i == 2 or i==5:\n\n\t\t\tprint\n\t\n", "positive_code": [{"source_code": "pole = [[], [], [], [], [], [], [], [], []]\nfor i in range(3):\n for k in range(3):\n a = input().split()\n pole[i * 3].append(a[0])\n pole[i * 3 + 1].append(a[1])\n pole[i * 3 + 2].append(a[2])\n k = input()\nk = list(map(int, k.split()))\ni1 = (k[0] - 1) % 3\ni2 = (k[1] - 1) % 3\nix = i1 * 3 + i2\nif '.' not in ''.join(pole[ix]):\n for i in range(9):\n for k in range(3):\n n = ''\n for l in list(pole[i][k]):\n if l == '.':\n n += '!'\n else:\n n += l\n pole[i][k] = n\nelse:\n for i in range(3):\n n = ''\n for l in list(pole[ix][i]):\n if l == '.':\n n += '!'\n else:\n n += l\n pole[ix][i] = n \nfor i in range(3):\n for k in range(3):\n print(pole[i * 3][k], pole[i * 3 + 1][k], pole[i * 3 + 2][k])\n print()\n "}, {"source_code": "k = [[] for i in range(9)]\np = 0\nr = 0\nfor i in range(11):\n b = input()\n b = b[:3] + b[4:7] + b[8:11]\n if b != '':\n k[i - p].append(b)\n else:\n p += 1\na, b = map(int, input().split())\na -= 1\nb -= 1\nfor i in range(3 * (a % 3), 3 * (a % 3) + 3):\n for j in range(3 * (b % 3), 3 * (b % 3) + 3):\n if k[i][0][j] != 'o' and k[i][0][j] != 'x':\n k[i][0] = k[i][0][:j] + '!' + k[i][0][j + 1:]\n r = 1\nif r == 0:\n for i in range(9):\n for j in range(9):\n if k[i][0][j] != 'o' and k[i][0][j] != 'x':\n k[i][0] = k[i][0][:j] + '!' + k[i][0][j + 1:]\nfor i in range(len(k)):\n for j in range(len(k[i][0])):\n print(k[i][0][j], end = '')\n if j == 2 or j == 5:\n print(' ', end = '')\n print(' ')\n if i == 2 or i == 5:\n print(' ')"}, {"source_code": "a = [[] for i in range(9)]\nfor i in range(2):\n for j in range(3):\n b = input()\n a[3 * i + j].append(b[0])\n a[3 * i + j].append(b[1])\n a[3 * i + j].append(b[2])\n a[3 * i + j].append(b[4])\n a[3 * i + j].append(b[5])\n a[3 * i + j].append(b[6])\n a[3 * i + j].append(b[8])\n a[3 * i + j].append(b[9])\n a[3 * i + j].append(b[10])\n b = input()\nfor j in range(3):\n b = input()\n a[j + 6].append(b[0])\n a[j + 6].append(b[1])\n a[j + 6].append(b[2])\n a[j + 6].append(b[4])\n a[j + 6].append(b[5])\n a[j + 6].append(b[6])\n a[j + 6].append(b[8])\n a[j + 6].append(b[9])\n a[j + 6].append(b[10])\ny, x = [int(x) for x in input().split()]\nx2 = (x - 1) % 3\ny2 = (y - 1) % 3\nx2 *= 3\ny2 *= 3\nf = 1\nfor i in range(3):\n for j in range(3):\n if a[i + y2][j + x2] == '.':\n a[i + y2][j + x2] = '!'\n f = 0\nif f == 1:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n a[i][j] = '!'\nfor i in range(3):\n for j in range(3):\n for l in range(3):\n print(a[3 * i + j][l], end='')\n print(' ', end='')\n for l in range(3, 6):\n print(a[3 * i + j][l], end='')\n print(' ', end='')\n for l in range(6, 9):\n print(a[3 * i + j][l], end='') \n print()\n print()"}, {"source_code": "field = []\n\nfor i in range(3):\n for j in range(3):\n field.append(list(map(list, input().split())))\n\n if i != 2:\n input()\n\ny, x = map(int, input().split())\n\nx -= 1\ny -= 1\n\nf_x, f_y = x % 3, y % 3\n\nplaced_at_point = False\n\nfor i in range(f_y*3, f_y*3+3):\n for j in range(3):\n if field[i][f_x][j] == '.':\n field[i][f_x][j] = '!'\n placed_at_point = True\n\n\nif not placed_at_point:\n for i in range(9):\n for j in range(3):\n for k in range(3):\n if field[i][j][k] == '.':\n field[i][j][k] = '!'\n\nfor i in range(9):\n s = ''\n for j in field[i]:\n for k in j:\n s += k\n s += ' '\n print(s)\n if (i+1) % 3 == 0:\n print()"}, {"source_code": "a = [[[['.'] * 3 for i in range(3)] for i in range(3)] for i in range(3)]\n\nfor i in range(3):\n s = input().split()\n for j in range(3):\n for h in range(3):\n ch = s[j][h]\n a[0][j][i][h] = ch\nx = input()\nfor i in range(3):\n s = input().split()\n for j in range(3):\n for h in range(3):\n ch = s[j][h]\n a[1][j][i][h] = ch\nx = input()\nfor i in range(3):\n s = input().split()\n for j in range(3):\n for h in range(3):\n ch = s[j][h]\n a[2][j][i][h] = ch\n\nx, y = map(int, input().split())\nx = x % 3 - 1\ny = y % 3 - 1\n\nfl = True\n\nfor i in range(3):\n for j in range(3):\n if a[x][y][i][j] == '.':\n fl = False\n a[x][y][i][j] = '!'\n\nif fl:\n for x in range(3):\n for y in range(3):\n for i in range(3):\n for j in range(3):\n if a[x][y][i][j] == '.':\n a[x][y][i][j] = '!'\n\nfor i in range(3):\n for j in range(3):\n print(*a[0][j][i], sep='', end=' ')\n print()\nprint()\nfor i in range(3):\n for j in range(3):\n print(*a[1][j][i], sep='', end=' ')\n print()\nprint()\nfor i in range(3):\n for j in range(3):\n print(*a[2][j][i], sep='', end=' ')\n print()\n"}, {"source_code": "a = []\nfor i in range(11):\n a.append(list(input().split()))\na.pop(3)\na.pop(6)\nn, m = map(int, input().split())\nn -= 1\nm -= 1\nn %= 3\nm %= 3\nn *= 3\nstate = 0\nfor i in range(3):\n for j in range(3):\n if a[n + i][m][j] == '.':\n a[n + i][m] = a[n + i][m][:j] + '!' + a[n + i][m][j + 1:]\n state = 1\nif state == 0:\n for i in range(9):\n for j in range(3):\n for k in range(3):\n if a[i][j][k] == '.':\n a[i][j] = a[i][j][:k] + '!' + a[i][j][k + 1:] \nfor i in range(9):\n for j in range(3):\n print(a[i][j], end = ' ')\n print()\n if i == 2 or i == 5:\n print()\n \n"}, {"source_code": "def please_die(x):\n if x % 3 == 0:\n align_x = 2\n elif x % 3 == 1:\n align_x = 0\n else:\n align_x = 1\n return align_x\n\nmas = []\ns = []\nss = ''\nfor i in range(11):\n nn = input()\n if nn != '':\n s += nn.split(' ')\n ss += nn.replace(' ', '')\n\nx, y = map(int, input().split())\n\nmas.append(s[0]+s[3]+s[6])\nmas.append(s[1]+s[4]+s[7])\nmas.append(s[2]+s[5]+s[8])\n\nmas.append(s[9]+s[12]+s[15])\nmas.append(s[10]+s[13]+s[16])\nmas.append(s[11]+s[14]+s[17])\n\nmas.append(s[18]+s[21]+s[24])\nmas.append(s[19]+s[22]+s[25])\nmas.append(s[20]+s[23]+s[26])\n\nalign_x = -1\nalign_y = -1\n\n\nalign_x = please_die(x)\n\nalign_y = please_die(y)\n\nwhat_a_square = align_x * 3 + align_y\nif '.' in mas[what_a_square]:\n j = 0\n for i in s:\n xxx = j // 9 + 1\n yyy = j % 9 + 1\n if please_die(xxx) == align_x and please_die(yyy) == align_y:\n print(i.replace('.', '!'), end=' ')\n else:\n print(i, end=' ')\n j += 1\n if j % 3 == 0:\n print()\n if j % 9 == 0:\n print()\nelse:\n #all\n j = 0\n for i in s:\n print(i.replace('.','!'), end=' ')\n j += 1\n if j % 3 == 0:\n print()\n if j % 9 == 0:\n print()\n"}, {"source_code": "mas = []\nmas1 = []\nfor i in range(11):\n mas.append(list(input().split()))\nmas.pop(3)\nmas.pop(6)\na, b = map(int, input().split())\nfor i in mas:\n mas2 = []\n for str1 in i:\n for elem in str1:\n mas2.append(elem)\n mas1.append(mas2)\n \nblock1 = [mas1[0][0], mas1[0][1], mas1[0][2], mas1[1][0], mas1[1][1], mas1[1][2], mas1[2][0], mas1[2][1], mas1[2][2]]\n\nblock2 = [mas1[0][3], mas1[0][4], mas1[0][5], mas1[1][3], mas1[1][4], mas1[1][5], mas1[2][3], mas1[2][4], mas1[2][5]]\n\nblock3 = [mas1[0][6], mas1[0][7], mas1[0][8], mas1[1][6], mas1[1][7], mas1[1][8], mas1[2][6], mas1[2][7], mas1[2][8]]\n\n\n\nblock4 = [mas1[3][0], mas1[3][1], mas1[3][2], mas1[4][0], mas1[4][1], mas1[4][2], mas1[5][0], mas1[5][1], mas1[5][2]]\n\nblock5 = [mas1[3][3], mas1[3][4], mas1[3][5], mas1[4][3], mas1[4][4], mas1[4][5], mas1[5][3], mas1[5][4], mas1[5][5]]\n\nblock6 = [mas1[3][6], mas1[3][7], mas1[3][8], mas1[4][6], mas1[4][7], mas1[4][8], mas1[5][6], mas1[5][7], mas1[5][8]]\n\n\n\nblock7 = [mas1[6][0], mas1[6][1], mas1[6][2], mas1[7][0], mas1[7][1], mas1[7][2], mas1[8][0], mas1[8][1], mas1[8][2]]\n\nblock8 = [mas1[6][3], mas1[6][4], mas1[6][5], mas1[7][3], mas1[7][4], mas1[7][5], mas1[8][3], mas1[8][4], mas1[8][5]]\n\nblock9 = [mas1[6][6], mas1[6][7], mas1[6][8], mas1[7][6], mas1[7][7], mas1[7][8], mas1[8][6], mas1[8][7], mas1[8][8]]\n\nblocks = [0, block1, block2, block3, block4, block5, block6, block7, block8, block9]\n\nx = a % 3\ny = b % 3\nif x == 0:\n x += 3\nif y == 0:\n y += 3\nif x == 1:\n if y == 1:\n block = 1\n elif y == 2:\n block = 2\n elif y == 3:\n block = 3\nelif x == 2:\n if y == 1:\n block = 4\n elif y == 2:\n block = 5\n elif y == 3:\n block = 6\nelif x == 3:\n if y == 1:\n block = 7\n elif y == 2:\n block = 8\n elif y == 3:\n block = 9\n\nif \".\" not in blocks[block]:\n for i in mas1:\n for j in range(len(i)):\n if i[j] == \".\":\n i[j] = \"!\"\nelse:\n if block in [1, 2, 3]:\n elem1 = [0, 1, 2]\n elif block in [4, 5, 6]:\n elem1 = [3, 4, 5]\n elif block in [7, 8, 9]:\n elem1 = [6, 7, 8]\n \n if block in [1, 4, 7]:\n elem2 = [0, 1, 2]\n elif block in [2, 5, 8]:\n elem2 = [3, 4, 5]\n elif block in [3, 6, 9]:\n elem2 = [6, 7, 8]\n \n for i in elem1:\n for j in elem2:\n if mas1[i][j] == \".\":\n mas1[i][j] = \"!\"\n\nfor j in range(0, 3):\n i = mas1[j]\n print(i[0] + i[1] + i[2], i[3] + i[4] + i[5], i[6] + i[7] + i[8])\nprint()\nfor j in range(3, 6):\n i = mas1[j]\n print(i[0] + i[1] + i[2], i[3] + i[4] + i[5], i[6] + i[7] + i[8])\nprint()\nfor j in range(6, 9):\n i = mas1[j]\n print(i[0] + i[1] + i[2], i[3] + i[4] + i[5], i[6] + i[7] + i[8])"}, {"source_code": "field = [[0] for i in range(11)]\nfor i in range(11):\n field[i] = input().replace(\" \", \"\")\nsave = field\nfield = []\nfor i in range(11):\n if(save[i] != \"\"):\n field.append([])\n for j in range(9):\n field[len(field) - 1].append(save[i][j])\nx, y = map(int, input().split())\nx, y = x - 1, y - 1\nx1 = x % 3 * 3 + 1\ny1 = y % 3 * 3 + 1\nmark = False\nfor i in range(-1, 2):\n for j in range(-1, 2):\n if(field[x1 + i][y1 + j] == \".\"):\n mark = True\n field[x1 + i][y1 + j] = \"!\"\nif not mark:\n for i in range(9):\n for j in range(9):\n if(field[i][j] == \".\"):\n field[i][j] = \"!\"\n \nfor i in range(9):\n for j in range(9):\n print(field[i][j], end=\"\")\n if((j + 1) % 3 == 0):\n print(end=\" \")\n if((i + 1) % 3 == 0):\n print()\n print()\n \n\n"}, {"source_code": "a = []\nfor i in range(11):\n b = input().split()\n if b != []:\n b = b[0] + b[1] + b[2]\n a.append(list(b))\nx, y = map(int, input().split())\nx = (x + 2) % 3 #\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ny = (y + 2) % 3 #\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nk = 0\nfor i in range(3 * x, 3 * x + 3):\n for j in range(3 * y, 3 * y + 3):\n if a[i][j] == '.':\n a[i][j] = '!'\n k += 1\nif k == 0:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n a[i][j] = '!'\nfor i in range(1, 10):\n print(a[i - 1][0] + a[i-1][1] + a[i-1][2] + ' ' + a[i-1][3] + a[i -1 ][4] + a[i-1][5] + ' ' + a[i-1][6] + a[i-1][7] + a[i-1][8])\n if i % 3 == 0:\n print()"}, {"source_code": "p = [[[],[],[]],[[],[],[]],[[],[],[]]]\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][0].append(a)\n p[1][0].append(b)\n p[2][0].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][1].append(a)\n p[1][1].append(b)\n p[2][1].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][2].append(a)\n p[1][2].append(b)\n p[2][2].append(c)\nx,y = map(int,(input().split()))\n\ndef okr(a):\n d=a//3\n if a%3>0:\n d+=1\n return(d)\nx-=1\ny-=1\nxm = (x)//3\nym = (y)//3\nxg=(x-xm*3)\nyg=(y-ym*3)\n\ns=''\ns += p[yg][xg][0]\ns+=p[yg][xg][1]\ns+=p[yg][xg][2]\n\nif '.' in s:\n \n for i in range(3):\n z = ''\n for j in p[yg][xg][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yg][xg][i]=z\nelse:\n for yn in range(3):\n for xn in range(3):\n for i in range(3):\n z = ''\n for j in p[yn][xn][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yn][xn][i]=z\n \n \nfor i in range(3):\n print(p[0][0][i],' ',p[1][0][i],' ',p[2][0][i])\nprint()\nfor i in range(3):\n print(p[0][1][i],' ',p[1][1][i],' ',p[2][1][i])\nprint()\nfor i in range(3):\n print(p[0][2][i],' ',p[1][2][i],' ',p[2][2][i])\nprint()\n \n \n\n "}, {"source_code": "l=[input() for _ in range(11)]\nx,y=map(int, input().split())\nx-=1\nx+=x//3\ny-=1\ny+=y//3\na,b=x%4*4,y%4*4\nf=1\nfor i in range(a,a+3):\n s=l[i]\n o=s[b:b+3]\n r=o.replace('.','!')\n if r!=o:\n l[i]=s[:b]+r+s[b+3:]\n f=0\nif f:\n for i in range(11):\n l[i]=l[i].replace('.','!')\nprint(*l,sep='\\n')\n"}, {"source_code": "l=[input() for _ in range(11)]\nx,y=map(int, input().split())\nx-=1\nx+=x//3\ny-=1\ny+=y//3\na,b=x%4*4,y%4*4\nf=1\nfor i in range(a,a+3):\n o=l[i][b:b+3]\n r=o.replace('.','!')\n if r!=o:\n l[i],f=l[i][:b]+r+l[i][b+3:],0\nif f:\n for i in range(11):\n l[i]=l[i].replace('.','!')\nprint(*l,sep='\\n')\n"}, {"source_code": "R=input\ng=[list(R()) for _ in range(11)]\nr,c=map(int,R().split())\nr,c=(r-1)%3*4,(c-1)%3*4\nf='.'\nfor i in range(9):\n s=g[r+i//3]\n if '.'==s[c+i%3]:\n s[c+i%3]=f='!'\nprint(*(''.join(v).replace(f,'!') for v in g),sep='\\n')\n"}, {"source_code": "R=input\ng=[list(R()) for _ in range(11)]\nr,c=map(lambda x:(x-1)%3*4,map(int,R().split()))\nf,d='.!'\nfor i in range(9):\n v,e=g[r+i//3],c+i%3\n if v[e]<'o':v[e]=f=d\nfor v in g:print(''.join(v).replace(f,d))\n"}, {"source_code": "def inp():\n b = []\n for i in range(3):\n for j in range(3):\n s = input()\n s = s[:3] + s[4:7] + s[8:]\n b.append(list(s))\n if i!=2:\n input()\n return b\ndef out():\n for i in range(3):\n for j in range(3):\n s = a[i * 3 + j]\n print(s[0],s[1],s[2],' ', s[3],s[4],s[5],' ', s[6],s[7],s[8], sep = '')\n if i!=2:\n print()\n\n\na = inp()\nx, y = map(int,input().split())\nx -= 1\ny -= 1\nx %= 3\ny %= 3\nf = True\nfor i in range(3):\n for j in range(3):\n if a[x * 3 + i][y * 3 + j] == '.':\n a[x * 3 + i][y * 3 + j] = '!'\n f = False\nif f:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n a[i][j] = '!'\nout()\n \n"}, {"source_code": "l=[list(''.join(s.split())) for s in (input() for _ in range(11)) if s]\nx,y=map(int, input().split())\na,b=(x-1)%3*3,(y-1)%3*3\nf=0\nfor i in range(a,a+3):\n for j in range(b,b+3):\n if l[i][j]=='.':\n f=1\n l[i][j]='!'\nif f==0:\n for i in range(9):\n for j in range(9):\n if l[i][j]=='.':\n l[i][j]='!'\nfor i in range(0,9,3):\n for j in range(3):\n s=''.join(l[i+j])\n print(' '.join((s[:3],s[3:6],s[6:])))\n print()\n \n \n"}, {"source_code": "z=[]\nfor i in range(11):\n if (i!=3 and i!=7):\n a,b,c=input().split()\n l=a+b+c\n z.append(l)\n else:\n p=input()\n\ny,x=map(int,input().split())\ny=(y-1)%3\nx=(x-1)%3\nflag=0\nfor i in range(y*3,y*3+3):\n for j in range(x*3,x*3+3):\n if z[i][j]=='.':\n flag=1\nif flag==1:\n for i in range(9):\n for j in range(9):\n if (i>=(y*3)) and (i<(y*3+3)) and (j>=(x*3)) and (j<(x*3+3)):\n if z[i][j]=='.':\n print('!',end='')\n else:\n print(z[i][j],end='')\n else:\n print(z[i][j],end='')\n if ((j+1)%3==0) and j!=8:\n print(' ',end='')\n if (j==8):\n print()\n if ((i+1)%3==0) and i!=8:\n print()\nelse:\n for i in range(9):\n for j in range(9):\n if z[i][j]=='.':\n print('!',end='')\n else:\n print(z[i][j],end='')\n if ((j+1)%3==0) and j!=8:\n print(' ',end='')\n if (j==8):\n print()\n if ((i+1)%3==0) and i!=8:\n print()\n \n"}, {"source_code": "g=[list(input()) for _ in range(11)]\nr,c=map(lambda x:(int(x)-1)%3*4,input().split())\nf,d='.!'\nfor i in range(9):\n s,e=g[r+i//3],c+i%3\n if s[e]<'o':\n s[e]=f=d\nfor v in g:print(''.join(v).replace(f,d))"}, {"source_code": "g=[list(input()) for _ in range(11)]\nr,c=map(lambda x:(int(x)-1)%3*4,input().split())\nf,d='.!'\nfor i in range(9):\n v,e=g[r+i//3],c+i%3\n if v[e]<'o':v[e]=f=d\nfor v in g:print(''.join(v).replace(f,d))"}, {"source_code": "l=[input() for _ in range(11)]\nx,y=map(int, input().split())\nx-=1\nx+=x//3\ny-=1\ny+=y//3\na,b=x%4*4,y%4*4\nf=1\nfor i in range(a,a+3):\n r=l[i][b:b+3].replace('.','!')\n if r!=l[i][b:b+3]:\n l[i]=l[i][:b]+r+l[i][b+3:]\n f=0\nif f:\n for i in range(11):\n l[i]=l[i].replace('.','!')\nprint(*l,sep='\\n')\n"}, {"source_code": "R=input\ng=[list(R()) for _ in range(11)]\nr,c=map(lambda x:(int(x)-1)%3*4,R().split())\nf,d='.!'\nfor i in range(9):\n s,e=g[r+i//3],c+i%3\n if s[e]<'o':\n s[e]=f=d\nfor v in g:print(''.join(v).replace(f,d))"}, {"source_code": "g = [[],[],[],[],[],[],[],[],[]]\nfor i in range(3):\n s = input().split()\n g[0].append((' '.join(j for j in s[0])).split())\n g[1].append((' '.join(j for j in s[1])).split())\n g[2].append((' '.join(j for j in s[2])).split())\nla = input()\nfor i in range(3):\n s = input().split()\n g[3].append((' '.join(j for j in s[0])).split())\n g[4].append((' '.join(j for j in s[1])).split())\n g[5].append((' '.join(j for j in s[2])).split()) \nla = input()\nfor i in range(3):\n s = input().split()\n g[6].append((' '.join(j for j in s[0])).split())\n g[7].append((' '.join(j for j in s[1])).split())\n g[8].append((' '.join(j for j in s[2])).split()) \nz = input().split()\nz[0] = int(z[0])\nz[1] = int(z[1])\nz[0]%=3\nz[1]%=3\nx = z[0]\ny = z[1]\nref = 0\nif x==1 and y == 1:\n ref = 0\nif x==1 and y == 2:\n ref = 1\nif x==1 and y == 0:\n ref = 2\n\nif x==2 and y == 1:\n ref = 3\nif x==2 and y == 2:\n ref = 4\nif x==2 and y == 0:\n ref = 5\n \nif x==0 and y == 1:\n ref = 6\nif x==0 and y == 2:\n ref = 7\nif x==0 and y == 0:\n ref = 8\ndef check(g):\n for i in g:\n for j in i:\n if j=='.':\n return True\n return False\nif check(g[ref]):\n for i in range(3):\n for j in range(3):\n if(g[ref][i][j]=='.'):\n g[ref][i][j]= '!'\nelse:\n for i in range(9):\n for j in range(3):\n for k in range(3):\n if(g[i][j][k]=='.'):\n g[i][j][k] = '!'\n\nans = ''\nfor i in range(3):\n for j in range(3):\n ans+=g[i][0][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(3):\n for j in range(3):\n ans+=g[i][1][j]\n ans+=' '\nprint(ans) \nans = ''\nfor i in range(3):\n for j in range(3):\n ans+=g[i][2][j]\n ans+=' '\nprint(ans)\nans = ''\nprint()\nfor i in range(3,6,1):\n for j in range(3):\n ans+=g[i][0][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(3,6,1):\n for j in range(3):\n ans+=g[i][1][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(3,6,1):\n for j in range(3):\n ans+=g[i][2][j]\n ans+=' '\nprint(ans)\nans = ''\nprint()\nfor i in range(6,9,1):\n for j in range(3):\n ans+=g[i][0][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(6,9,1):\n for j in range(3):\n ans+=g[i][1][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(6,9,1):\n for j in range(3):\n ans+=g[i][2][j]\n ans+=' '\nprint(ans)"}, {"source_code": "field = []\nfor i in range(3):\n for j in range(3):\n line = input().split()\n field.append(''.join(line))\n a = list(map(int, input().split()))\n\na, b = a[0], a[1]\nc, d = a%3 + (3*(a%3==0)), b%3 + (3*(b%3==0))\n#print(a, b, c, d)\nisfree = 0\nfor i in range(3*(c-1), 3*c):\n for j in range(3*(d-1), 3*d):\n if field[i][j] == '.':\n isfree += 1\n\nif not isfree:\n #print(isfree)\n for i in range(9):\n for j in range(9):\n if field[i][j] == '.':\n field[i] = field[i][:j] + '!' + field[i][j+1:]\nelse:\n for i in range(3*(c-1), 3*c):\n for j in range(3*(d-1), 3*d):\n if field[i][j] == '.':\n field[i] = field[i][:j] + '!' + field[i][j+1:]\n\nfor i in range(3):\n for j in range(3):\n print(field[3*i+j][:3], field[3*i+j][3:6], field[3*i+j][6:9])\n print()\n"}, {"source_code": "R=input\ng=[list(R()) for _ in range(11)]\nr,c=map(int,R().split())\nr,c=(r-1)%3*4,(c-1)%3*4\nf,d='.!'\nfor i in range(9):\n s,e=g[r+i//3],c+i%3\n if s[e]<'o':\n s[e]=f=d\nfor v in g:print(''.join(v).replace(f,d))"}, {"source_code": "l=[input() for _ in range(11)]\nx,y=map(int, input().split())\nx-=1\nx+=x//3\ny-=1\ny+=y//3\na,b=x%4*4,y%4*4\nr=11\nfor i in range(a,a+3):\n s=l[i][b:b+3]\n if '.' in s:\n l[i],r=l[i][:b]+s.replace('.','!')+l[i][b+3:],0\nfor i in range(r):\n l[i]=l[i].replace('.','!')\nprint(*l,sep='\\n')\n"}, {"source_code": "import sys\na=[['...' for j in range(3)] for i in range(9)]\nl=0\nfor i in range(11):\n if i==3 or i==7:\n k=input()\n continue\n b=input().split()\n for i in range(len(b)):\n a[l][i]=b[i]\n l+=1\nx,y=map(int,input().split())\nx-=1\ny-=1\nx%=3\ny%=3\nf=0\nfor i in range(3*x,3*x+3):\n j=y\n for m in range(3):\n if a[i][j][m]=='.':\n f=1\n if m==0:\n a[i][j]='!'+a[i][j][1:]\n elif m==1:\n a[i][j]=a[i][j][0]+'!'+a[i][j][2]\n elif m==2:\n a[i][j]=a[i][j][0]+a[i][j][1]+'!'\nif not f:\n for i in range(9):\n for j in range(3):\n for m in range(3):\n if a[i][j][m]=='.':\n if m==0:\n a[i][j]='!'+a[i][j][1:]\n elif m==1:\n a[i][j]=a[i][j][0]+'!'+a[i][j][2]\n elif m==2:\n a[i][j]=a[i][j][0]+a[i][j][1]+'!'\nfor i in range(9):\n s=''\n for j in range(3):\n s+=a[i][j]+' '\n print(s)\n if i==2 or i==5:\n print()\n"}, {"source_code": "d=[]\nfor i in range(11):\n s=input()\n\n if(i!=3 and i!=7):\n d.append(s)\n\n\nx,y=map(int,input().split())\nx-=1\ny-=1\n\nrow=x%3\nif row == 1:\n row=3\n\nif row==2:\n row=6\n\ncol=y%3\n\nif(col==1):\n col=4\nif(col==2):\n col=8\n\nflag=False\n\nfor i in range(row,row+3):\n for j in range(col,col+3):\n if d[i][j]=='.':\n flag=True\n\nif(flag):\n for i in range(row, row + 3):\n for j in range(col, col + 3):\n if d[i][j] == '.':\n d[i]=d[i][:j]+'!'+d[i][j+1:]\nelse:\n for i in range(len(d)):\n for j in range(len(d[i])):\n if d[i][j] == '.':\n d[i]=d[i][:j]+'!'+d[i][j+1:]\n\nfor i in range(3):\n print(d[i])\n\nprint(\"\")\n\nfor i in range(3,6):\n print(d[i])\n\nprint(\"\")\n\nfor i in range(6,9):\n print(d[i])\n\n"}, {"source_code": "arr = []\nfor i in range(11):\n row = input()\n if row != '':\n arr.append(list(row.replace(' ','')))\n\ncoord = [int(x) for x in input().split(' ')]\nsubsquare = [coord[0]-(coord[0]-1)//3*3, coord[1]-(coord[1]-1)//3*3]\nblocked = True\n\nfor i in range(3*subsquare[0]-3, 3*subsquare[0]):\n for j in range(3*subsquare[1]-3, 3*subsquare[1]):\n if arr[i][j] == '.':\n blocked = False\n arr[i][j] = '!'\n\nif blocked:\n for i in range(9):\n for j in range(9):\n if arr[i][j] == '.':\n blocked = False\n arr[i][j] = '!'\n\nfor row in arr:\n row.insert(6,' ')\n row.insert(3,' ')\n\narr.insert(6,[' '])\narr.insert(3,[' '])\n\nprint('\\n'.join([''.join(x) for x in arr]))\n"}, {"source_code": "a = [[''] * 9 for i in range(9)]\n\nfor i in range(3):\n for j in range(3):\n q = input()\n q = q.replace(' ', '')\n for p in range(9):\n a[i * 3 + j][p] = q[p]\n if i != 2:\n q = input()\n\nx, y = [int(i) for i in input().split()]\nx1, y1 = x, y\nwhile x1 > 3:\n x1 -= 3\nwhile y1 > 3:\n y1 -= 3\nx1 -= 1\ny1 -= 1\nch = False\nfor i in range(3):\n for j in range(3):\n if a[i + x1 * 3][j + y1 * 3] == '.':\n ch = True\n if ch and a[i + x1 * 3][j + y1 * 3] == '.':\n a[i + x1 * 3][j + y1 * 3] = '!'\nif not ch:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n a[i][j] = '!'\nfor i in range(3):\n for j in range(3):\n \n for p in range(3):\n for q in range(3):\n print(a[i * 3 + j][p * 3 + q], end='')\n print(' ', end='')\n print()\n print()"}, {"source_code": "table = []\n\nfor i in range(2):\n for j in range(3):\n table.append(list(map(list, input().split())))\n input()\n\nfor i in range(3):\n table.append(list(map(list, input().split())))\n\ny, x = map(int, input().split())\n\nplace = [(x-1)%3, (y-1)%3]\n\nbool1 = True\n\nfor i in range(place[1]*3, place[1]*3+3):\n for j in range(len(table[i][place[0]])):\n if '.' == table[i][place[0]][j]:\n table[i][place[0]][j] = '!'\n bool1 = False\n\nif bool1:\n for i in range(len(table)):\n for j in range(len(table[i])):\n for k in range(len(table[i][j])):\n if table[i][j][k] == '.' and (y-1 != i or x-1 // 3 != j or x-1 % 3 != k):\n table[i][j][k] = '!'\n\nfor i in range(len(table)):\n for j in table[i]:\n for k in j:\n print(k, end='')\n print(end=' ')\n print()\n if (i+1) % 3 == 0:\n print()"}, {"source_code": "d = []\nfor i in range(11):\n\td.append(input())\ndel d[7]\ndel d[3]\np = []\nfor i in d:\n\tp.append(''.join(i.split(' ')))\nx, y = map(int, input().split())\nX = (x - 1) // 3 + 1\nx = (x - 1) % 3\nY = y // 3\ny = (y - 1) % 3\n\nf = False\nfor i in range(3 * x, 3 * x + 3):\n\tfor j in range(3 * y, 3 * y + 3):\n\t\tif p[i][j] == '.':\n\t\t\tp[i] = p[i][:j] + '!' + p[i][j + 1:]\n\t\t\tf = True\n\nif not f:\n\tfor i in range(len(p)):\n\t\tfor j in range(len(p)):\n\t\t\tif p[i][j] == '.':\n\t\t\t\tp[i] = p[i][:j] + '!' + p[i][j + 1:]\nfor i in range(3):\n\tfor j in range(3):\n\t\tfor k in range(3):\n\t\t\tprint(p[i * 3 + j][3 * k:3 * k + 3], end = ' ')\n\t\tprint()\n\tprint()\n"}, {"source_code": "grid=[]\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input().split(\" \")\nx = int(inp[0])\ny = int(inp[1])\nxn = x%3\nyn=y%3\nxn -=1\nyn-=1\nif xn<0:\n xn+=3\nif yn<0:\n yn+=3\ncheck = False\nfor i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n check = True\n break\n if check:\n break\nif check:\n for i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n grid[3*xn+i] = list(grid[3*xn+i])\n grid[3*xn+i][3*yn+j] = \"!\"\n grid[3*xn+i] = \"\".join(grid[3*xn+i])\nelse:\n for i in range(9):\n for j in range(9):\n if i<3*xn+3 and i>=xn*3 and j>=yn*3 and j<3*yn+3:\n continue\n elif grid[i][j]!=\".\":\n continue\n else:\n grid[i] = list(grid[i])\n grid[i][j] = \"!\"\n grid[i] = \"\".join(grid[i])\nfor i in range(9):\n if i%3==0 and i!=0:\n print()\n print(grid[i][:3]+\" \"+grid[i][3:6]+\" \"+grid[i][6:])\n"}, {"source_code": "lines = []\nfor i in range(11):\n lines.append(input())\ncoords = list(map(int, input().split()))\nsqy = (coords[0] - 1) % 3\nsqx = (coords[1] - 1) % 3\nstartchange = False\nsqstart = {0: 0, 1: 4, 2: 8}\nchangesyms = {'x': 'x', 'o': 'o', '.': '!', ' ': ' ', '\\n': '\\n'}\nfree = 0\ntoprint = ''\ntoprint2 = ''\nfor i in range(11):\n for i1 in range(len(lines[i])):\n if i in range(sqstart[sqy], sqstart[sqy] + 3) and i1 in range(sqstart[sqx], sqstart[sqx] + 3):\n startchange = True\n else:\n startchange = False\n if startchange:\n toprint += changesyms[lines[i][i1]]\n if changesyms[lines[i][i1]] != lines[i][i1]:\n free += 1\n else:\n toprint += lines[i][i1]\nif free == 0:\n startchange = True\nelse:\n startchange = False\nsyms = 0\nfor i in toprint:\n if startchange:\n toprint2 += changesyms[i]\n if i not in changesyms:\n toprint2 += i\n else:\n toprint2 += i\n syms += 1\n if syms % 11 == 0 and syms != 99:\n toprint2 += '\\n'\n if syms % 33 == 0 and syms != 99:\n toprint2 += '\\n'\nprint(toprint2)\n \n \n \n \n"}, {"source_code": "s = []\nq = []\nS = []\ns.append(input().split())\ns.append(input().split())\ns.append(input().split())\nq.append(input().split())\ns.append(input().split())\ns.append(input().split())\ns.append(input().split())\nq.append(input().split())\ns.append(input().split())\ns.append(input().split())\ns.append(input().split())\n\nx, y = list(map(lambda x : int(x), input().split()))\n\nX = x % 3\nif x % 3 == 0:\n X = 3\n\nY = y % 3\nif y % 3 == 0:\n Y = 3\n\nss = list(map(lambda x: ''.join(x), s[(X-1)*3:X*3]))\n\nqwe = []\nss = [ss[0][(Y-1)*3:Y*3]] + [ss[1][(Y-1)*3:Y*3]] + [ss[2][(Y-1)*3:Y*3]]\nfor i in range((X-1)*3, X*3):\n for j in range((Y-1)*3, Y * 3):\n qwe.append((i, j))\nm = False\nss_new = []\n\nfor i, el in enumerate(ss):\n if '.' in el:\n m = True\n ss_new.append(el.replace('.', '!'))\nsch = 0\nif not m:\n for el in s:\n for ell in el[:-1]:\n print(ell.replace('.', '!'), end = ' ')\n print(el[-1].replace('.', '!'))\n sch += 1\n if sch % 3 == 0 and sch != 9:\n print()\n\nelse:\n s_new = []\n sch_str = 0\n for el in s:\n s_new.append(''.join(el))\n for i in range(len(s_new)):\n sch_tab = 0\n for j in range(len(s_new[i])):\n if (i, j) in qwe:\n print(ss_new[i%3][j%3], end = '')\n pass\n else:\n print(s_new[i][j], end = '')\n pass\n sch_tab += 1\n if sch_tab % 3 == 0 and sch_tab != 9:\n print(' ', end = '')\n print()\n sch_str += 1\n if sch_str % 3 == 0 and sch_str != 9:\n print()\n \n \n "}, {"source_code": "A = []\nfor i in range(11):\n s = input()\n s = s.replace(\" \", \"\")\n if s == \"\":\n continue\n A.append(list(s))\nx, y = map(int, input().split())\nx = (x-1) % 3\ny = (y-1) % 3\n#print(x, y)\nrep = 0\nfor i in range(3):\n for j in range(3):\n if(A[3 * x + i][3 * y + j] == \".\"):\n A[3 * x + i][3 * y + j] = \"!\"\n rep += 1\nif(rep == 0):\n for i in range(9):\n for j in range(9):\n if A[i][j] == \".\":\n A[i][j] = \"!\"\nfor i in range(9):\n A[i] = A[i][0] + A[i][1] + A[i][2] + ' ' + A[i][3] + A[i][4] + A[i][5] + ' ' + A[i][6] + A[i][7] + A[i][8]\n\n# for i in range(9):\n# for j in range(11):\n# print(A[i][j], end = '')\n# print()\n\nfor i in range(0,3):\n print(A[i])\nprint()\n\nfor i in range(3,6):\n print(A[i])\nprint()\n\nfor i in range(6,9):\n print(A[i])\nprint()\n\n"}, {"source_code": "grid = [[] for _ in range(9)]\nfor block in range(3):\n for line in range(3):\n linestr = input()\n linestr = iter(linestr)\n gridline = grid[block*3 + line]\n for vertbl in range(3):\n for col in range(3):\n gridline.append(next(linestr))\n if vertbl < 2:\n next(linestr)\n if block < 2:\n input()\n\n\nx, y = (int(c) for c in input().split())\n\n\n# nope = True\nx, y = x-1, y-1\nblx, bly = x % 3, y % 3\ndef check():\n for xx in range(blx*3, blx*3+3):\n for yy in range(bly*3, bly*3+3):\n if grid[xx][yy]=='.':\n return False\n return True\nnope = check()\n\n\nfor block in range(3):\n for line in range(3):\n gridline = grid[block * 3 + line]\n output = ''\n for vertbl in range(3):\n for col in range(3):\n current = gridline[vertbl*3+col]\n if current != '.':\n output+=current\n elif nope:\n output+='!'\n elif (block == blx) and (vertbl == bly):\n output+='!'\n else:\n output+='.'\n if vertbl < 2:\n output+=' '\n print(output)\n if block<2:\n print()"}, {"source_code": "g = [[[[0,0,0], [0,0,0], [0,0,0]] for j in range(3)] for i in range(3)]\nfor i in range(9):\n s = [list(map(lambda t: 0 if t=='.' else 1 if t=='x' else -1, list(r))) for r in input().split()]\n for j in range(3):\n g[i//3][j][i%3] = s[j]\n if i%3==2 and i!=8:\n input()\nx, y = map(lambda i: int(i)-1, input().split())\nxi = g[x//3][y//3][x%3][y%3]\nf = any(i==0 for s in g[x%3][y%3] for i in s)\nm = lambda c, xg, yg: '!' if (c==0 and ((xg, yg)==(x%3, y%3) or not f)) else 'x' if c==1 else 'o' if c==-1 else '.'\nfor i in range(9):\n print(' '.join(''.join(m(g[i//3][j][i%3][ji], i//3, j) for ji in range(3)) for j in range(3)))\n if i%3==2:\n print('')\n"}, {"source_code": "a = []\nfor i in range(11):\n inp = input()\n if len(inp) == 0:\n continue\n a.append(list(''.join(inp.split())))\n\nx, y = map(int, input().split())\nx, y = x % 3 - 1, y % 3 - 1\nnp = 0\nsx, xy = x * 3, y * 3\nfor i in range(3):\n for j in range(3):\n if a[sx + i][xy + j] == '.':\n a[sx + i][xy + j] = '!'\n np += 1\nif np == 0:\n sx, xy = 0, 0\n for i in range(9):\n for j in range(9):\n if a[sx + i][xy + j] == '.':\n a[sx + i][xy + j] = '!'\n\nfor i in range(9):\n print(' '.join([''.join(a[i][:3]), ''.join(a[i][3:6]), ''.join(a[i][6:])]))\n if i == 2 or i == 5:\n print()"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n\ndef main():\n\tfield = []\n\tfor _ in range(3):\n\t\ts = input()\n\t\ts = s.replace(' ', '')\n\t\tfield.append(list(s))\n\tinput()\n\tfor _ in range(3):\n\t\ts = input()\n\t\ts = s.replace(' ', '')\n\t\tfield.append(list(s))\n\tinput()\n\tfor _ in range(3):\n\t\ts = input()\n\t\ts = s.replace(' ', '')\n\t\tfield.append(list(s))\n\tx, y = map(int, input().split())\n\tx -= 1\n\ty -= 1\n\tx %= 3\n\ty %= 3\n\tx *= 3\n\ty *= 3\n\tcnt = 0\n\tfor i in range(x, x + 3):\n\t\tfor j in range(y, y + 3):\n\t\t\tif field[i][j] != '.':\n\t\t\t\tcnt += 1\n\tif cnt == 9:\n\t\tfor i in range(9):\n\t\t\tfor j in range(9):\n\t\t\t\tif field[i][j] == '.':\n\t\t\t\t\tfield[i][j] = '!'\n\telse:\n\t\tfor i in range(x, x + 3):\n\t\t\tfor j in range(y, y + 3):\n\t\t\t\tif field[i][j] == '.':\n\t\t\t\t\tfield[i][j] = '!'\n\tfor i in range(9):\n\t\tprint(' '.join([''.join(field[i][:3]), ''.join(field[i][3:6]), ''.join(field[i][6:])]))\n\t\tif not (i + 1) % 3 and not i == 8:\n\t\t\tprint()\n\n\n\nif __name__ == '__main__':\n\tmain()\n\t"}, {"source_code": "#!/usr/bin/env python3\n\nmp = []\nfor ii in range(11):\n if ii==3 or ii==7:\n input()\n continue\n mp.append(list(\"\".join([str(i) for i in input().split(' ')])))\ny,x = [int(i) for i in input().split(' ')]\n\nr = y%3\nc = x%3\n\ncnt = 0\nrr = (3+r-1)%3\ncc = (3+c-1)%3\nfor i in range(3):\n for j in range(3):\n if mp[rr*3+i][cc*3+j]=='.':\n mp[rr*3+i][cc*3+j] = '!'\n cnt += 1\nif cnt==0:\n for i in range(9):\n for j in range(9):\n if mp[i][j]=='.':\n mp[i][j] = '!'\n\nfor i in range(9):\n if i==3 or i==6:\n print(\"\")\n for j in range(9):\n if j==3 or j==6:\n print(\" \",end='')\n print (mp[i][j],end='')\n if j==8:\n print(\"\")\n"}, {"source_code": "from sys import stdin, stdout\n\n\nmaps = []\nsze = 9 \n\nfor i in range(1, 10):\n maps.append(list(''.join(stdin.readline().strip().split())))\n \n if not i % 3 and i != 9:\n stdin.readline()\n\ns, c = map(int, stdin.readline().split())\n\nc -= 1\ns -= 1\n\nc %= 3\ns %= 3\n\nacc = c * 3\nass = s * 3\n\nlabel = 0\nfor i in range(ass, ass + 3):\n for j in range(acc, acc + 3):\n if maps[i][j] == '.':\n maps[i][j] = '!'\n label = 1\n\nif not label:\n for i in range(len(maps)):\n for j in range(len(maps[i])):\n if maps[i][j] == '.':\n maps[i][j] = '!'\n\nind = 1\nfor i in range(len(maps)):\n for j in range(len(maps[i])):\n stdout.write(maps[i][j])\n \n if not ind % 9:\n stdout.write('\\n')\n elif not ind % 3:\n stdout.write(' ')\n \n ind += 1\n \n if not (i + 1) % 3:\n stdout.write('\\n')"}, {"source_code": "def line():\n L = input().split()\n return list(''.join(L))\n\nL = []\nfor i in range(0, 9):\n if i == 3 or i == 6:\n input()\n L.append(line())\n\nx, y = map(int, input().split())\nx -= 1\ny -= 1\nx %= 3\ny %= 3\n\nempt = True\nfor i in range(3*x, 3*(x+1)):\n for j in range(3*y, 3*(y+1)):\n if L[i][j] == '.':\n L[i][j] = '!'\n empt = False\n\n\nfor i in range(0, 9):\n if empt:\n L[i] = ''.join(L[i]).replace('.', '!')\n else:\n L[i] = ''.join(L[i])\n\nfor i in range(0, 9):\n if i == 3 or i == 6:\n print()\n print(L[i][:3], L[i][3:6], L[i][6:9])"}, {"source_code": "class field:\n def __init__(self):\n self.cells = []\n\n for i in range(3):\n self.cells.append([])\n for j in range(3):\n self.cells[i].append('.')\n\n def __str__(self):\n str = ''\n\n for i in range(3):\n for j in range(3):\n str += self.cells[i][j]\n if i < 2:\n str += '\\n'\n\n return str\n\n def exclaim(self):\n changed = False\n\n for i in range(3):\n for j in range(3):\n if self.cells[i][j] == '.':\n self.cells[i][j] = '!'\n changed = True\n\n return changed\nclass board:\n def __init__(self):\n self.fields = []\n\n for i in range(3):\n self.fields.append([])\n for j in range(3):\n self.fields[i].append(field())\n\n def __str__(self):\n str = ''\n\n for i in range(3):\n for j in range(3):\n for k in range(3):\n for l in range(3):\n str += self.fields[i][k].cells[j][l]\n str += ' '\n str += '\\n'\n if i < 2:\n str += '\\n'\n\n return str\n\n\nmy_board = board()\nrow = 0\ncrow = 0\n\nfor i in range(11):\n stdin = input()\n\n if stdin:\n stdin = stdin.strip().split()\n\n for j in range(3):\n for k in range(3):\n my_board.fields[row][j].cells[crow][k] = stdin[j][k]\n\n crow += 1\n else:\n crow = 0\n row += 1\n\n\nrow, col = [(int(i) - 1) % 3 for i in input().split()]\n\nif not my_board.fields[row][col].exclaim():\n for i in range(3):\n for j in range(3):\n my_board.fields[i][j].exclaim()\n\nprint(my_board)\n"}, {"source_code": "a00=[]\na01=[]\na02=[]\na10=[]\na11=[]\na12=[]\na20=[]\na21=[]\na22=[]\nfor i in range(3):\n q=input().split()\n a00.append(q[0])\n a01.append(q[1])\n a02.append(q[2])\ninput()\nfor i in range(3):\n q=input().split()\n a10.append(q[0])\n a11.append(q[1])\n a12.append(q[2])\ninput()\nfor i in range(3):\n q=input().split()\n a20.append(q[0])\n a21.append(q[1])\n a22.append(q[2])\nx,y=map(int,input().split())\nx,y=(x-1)%3,(y-1)%3\nif x==0 and y==0:\n for i in a00:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==1:\n for i in a01:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==2:\n for i in a02:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==1 and y==0:\n for i in a10:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==1 and y==1:\n for i in a11:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==1 and y==2:\n for i in a12:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==0:\n for i in a20:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==1:\n for i in a21:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==2:\n for i in a22:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nfor i in range(3):\n print(a00[i],a01[i],a02[i])\nprint()\nfor i in range(3):\n print(a10[i],a11[i],a12[i])\nprint()\nfor i in range(3):\n print(a20[i],a21[i],a22[i])\n"}, {"source_code": "def get3x3():\n return [[0 for _ in range(3)] for _ in range(3)]\n\nmats=[[get3x3() for __ in range(3)] for _ in range(3)]\n\nfor i in range(11):\n lines=input().split()\n if i==3 or i==7:\n continue\n cnt=i\n if i>3:\n cnt-=1\n if i>7:\n cnt-=1\n for j in range(3):\n mats[cnt//3][j][cnt%3]=list(lines[j])\n\nx0,y0=map(int,input().split())\n\n\nx0-=1\ny0-=1\n\ncx=x0%3\ncy=y0%3\n\ndef check(cx,cy):\n for i in range(3):\n for j in range(3):\n if mats[cx][cy][i][j]=='.':\n return True\n return False\n\ndef mark(cx,cy):\n for i in range(3):\n for j in range(3):\n if mats[cx][cy][i][j]=='.':\n mats[cx][cy][i][j]='!'\nif check(cx,cy):\n mark(cx,cy)\nelse:\n for tx in range(3):\n for ty in range(3):\n mark(tx,ty)\n\n\n\nfor i in range(11):\n if i==3 or i==7:\n print()\n continue\n cnt=i\n if i>3:\n cnt-=1\n if i>7:\n cnt-=1\n for j in range(3):\n print(''.join(mats[cnt//3][j][cnt%3]),end='')\n if j<3:\n print(end=' ')\n print()\n\n"}, {"source_code": "spot = [[0] for i in range(11)]\ncheck = False\nfor i in range(11):\n spot[i] = input().replace(\" \", \"\")\ndata = spot\nspot = []\nfor i in range(11):\n if (data[i] != \"\"):\n spot.append([])\n for j in range(9):\n spot[len(spot) - 1].append(data[i][j])\nx, y = [int(z) for z in input().split()]\ncoordinate1 = (x - 1) % 3 * 3 + 1\ncoordinate2 = (y - 1) % 3 * 3 + 1\nfor i in range(-1, 2):\n for j in range(-1, 2):\n if (spot[coordinate1 + i][coordinate2 + j] == \".\"):\n check = True\n spot[coordinate1 + i][coordinate2 + j] = \"!\"\nif check == False:\n for i in range(9):\n for j in range(9):\n if(spot[i][j] == \".\"):\n spot[i][j] = \"!\"\n \nfor i in range(9):\n for j in range(9):\n print(spot[i][j], end=\"\")\n if((j + 1) % 3 == 0):\n print(end=\" \")\n if ((i + 1) % 3 == 0):\n print()\n print()"}, {"source_code": "ul,um,ur,ml,mm,mr,ll,lm,lr=[],[],[],[],[],[],[],[],[]\nfor i in range(3):\n l=input().split()\n ul.append(l[0])\n um.append(l[1])\n ur.append(l[2])\n\ninput()\nfor i in range(3):\n l=input().split()\n ml.append(l[0])\n mm.append(l[1])\n mr.append(l[2])\ninput()\nfor i in range(3):\n l=input().split()\n ll.append(l[0])\n lm.append(l[1])\n lr.append(l[2])\nx,y=map(int,input().split())\n\nx=((x-1)%3)+1\ny=((y-1)%3)+1\nl=[]\nl.append([ul,um,ur])\nl.append([ml,mm,mr])\nl.append([ll,lm,lr])\nflag=0\nfor ele in l[x-1][y-1]:\n for ele2 in ele:\n if ele2=='.':\n flag=1\nfor i in range(3):\n for j in range(3):\n if l[x-1][y-1][i][j]=='.':\n l[x-1][y-1][i]=l[x-1][y-1][i][:j]+'!'+l[x-1][y-1][i][j+1:]\n#print(l)\nif flag==0:\n for i1 in range(3):\n for j1 in range(3):\n for i in range(3):\n for j in range(3):\n if l[i1][j1][i][j]=='.':\n l[i1][j1][i]=l[i1][j1][i][:j]+'!'+l[i1][j1][i][j+1:]\n#print(*l,sep='\\n') \n \nfor i in range(3):\n for j in range(3):\n print(l[i][0][j],l[i][1][j],l[i][2][j])\n print(\"\")\n\n\n"}, {"source_code": "from math import ceil\ns = [list(input().replace(' ', '')) for i in range(3)]\ninput()\ns += [list(input().replace(' ', '')) for i in range(3)]\ninput()\ns += [list(input().replace(' ', '')) for i in range(3)]\ny, x = [int(k) for k in input().split(' ') if k]\nyb, xb = ceil(y / 3), ceil(x / 3)\ny -= (yb - 1) * 3 + 1\nx -= (xb - 1) * 3 + 1\ny *= 3\nx *= 3\nfound = 0\nfor dy in range(3):\n for dx in range(3):\n if s[y + dy][x + dx] == '.':\n found = 1\n s[y + dy][x + dx] = '!'\nif not found:\n for y in range(9):\n for x in range(9):\n if s[y][x] == '.':\n s[y][x] = '!'\nfor y in range(3):\n for x in range(3):\n print(s[y][x], end='')\n print(' ', end='')\n for x in range(3, 6):\n print(s[y][x], end='')\n print(' ', end='')\n for x in range(6, 9):\n print(s[y][x], end='')\n print(' ')\nprint()\nfor y in range(3, 6):\n for x in range(3):\n print(s[y][x], end='')\n print(' ', end='')\n for x in range(3, 6):\n print(s[y][x], end='')\n print(' ', end='')\n for x in range(6, 9):\n print(s[y][x], end='')\n print(' ')\nprint()\nfor y in range(6, 9):\n for x in range(3):\n print(s[y][x], end='')\n print(' ', end='')\n for x in range(3, 6):\n print(s[y][x], end='')\n print(' ', end='')\n for x in range(6, 9):\n print(s[y][x], end='')\n print(' ')\n"}, {"source_code": "from math import ceil\n\ntable = []\nfor i in range(3):\n\tvar = []\n\tfor _ in range(3):\n\t\tvar.append(input().split())\n\ttable.append(var)\n\tif i != 2:\n\t\tinput()\ny, x = [int(x) for x in input().split()]\nx1 = (x % 3) - 1\ny1 = (y % 3) - 1\nfor i in range(3):\n\tif '.' in table[y1][i][x1]:\n\t\tfor j in range(3):\n\t\t\ttable[y1][j][x1] = table[y1][j][x1].replace('.', '!')\n\t\tbreak\nelse:\n\tfor i in range(3):\n\t\tfor j in range(3):\n\t\t\tfor k in range(3):\n\t\t\t\ttable[i][j][k] = table[i][j][k].replace('.', '!')\nfor x in table:\n\tfor y in x:\n\t\tprint(*y)\n\tprint()\n"}, {"source_code": "import sys\na=[['...' for j in range(3)] for i in range(9)]\nl=0\nfor i in range(11):\n if i==3 or i==7:\n k=input()\n continue\n b=input().split()\n for i in range(len(b)):\n a[l][i]=b[i]\n l+=1\nx,y=map(int,input().split())\nx-=1\ny-=1\nx%=3\ny%=3\nf=0\nfor i in range(3*x,3*x+3):\n j=y\n for m in range(3):\n if a[i][j][m]=='.':\n f=1\n if m==0:\n a[i][j]='!'+a[i][j][1:]\n elif m==1:\n a[i][j]=a[i][j][0]+'!'+a[i][j][2]\n elif m==2:\n a[i][j]=a[i][j][0]+a[i][j][1]+'!'\nif not f:\n for i in range(9):\n for j in range(3):\n for m in range(3):\n if a[i][j][m]=='.':\n if m==0:\n a[i][j]='!'+a[i][j][1:]\n elif m==1:\n a[i][j]=a[i][j][0]+'!'+a[i][j][2]\n elif m==2:\n a[i][j]=a[i][j][0]+a[i][j][1]+'!'\nfor i in range(9):\n s=''\n for j in range(3):\n s+=a[i][j]+' '\n print(s)\n if i==2 or i==5:\n print()"}, {"source_code": "# python3\n# utf-8\n\nfield = []\nrows = 0\nwhile len(field) < 9:\n input_row = [x for x in input().split()]\n if not input_row:\n continue\n curr_row = []\n for part in input_row:\n for elem in part:\n curr_row.append(elem)\n field.append(curr_row)\n # rows += 1\nrow, col = (int(x) for x in input().split())\nrow -= 1\ncol -= 1\nglob_row = (row) // 3\nglob_col = (col) // 3\nnext_glob_row = row - 3 * glob_row\nnext_glob_col = col - 3 * glob_col\n# print(row, col)\n# print(glob_row, glob_col)\n# print(next_glob_row, next_glob_col)\nflag = True\nfor r in range(3):\n curr_row = next_glob_row * 3 + r\n for c in range(3):\n curr_col = next_glob_col * 3 + c\n # print(curr_row, curr_col)\n if field[curr_row][curr_col] == '.':\n field[curr_row][curr_col] = '!'\n flag = False\n\nfor r in range(9):\n for c in range(9):\n if flag and field[r][c] == '.':\n field[r][c] = '!'\n print(field[r][c], end='')\n if c in [2, 5]:\n print(' ', end='')\n print('')\n if r in [2, 5]:\n print('')\n"}, {"source_code": "grid = [[[] for x in range(3)] for x in range(3)]\nfor j in range(3):\n for i in range(3):\n row = raw_input().split()\n for k in range(3):\n grid[j][k].append(list(row[k]))\n if j != 2:\n raw_input()\na,b = map(int,raw_input().split())\nif a%3==0: #bottom row\n if b%3==0: #rightmost row\n cell = 8\n elif b%3==2:\n cell = 7\n else:\n cell = 6\nelif a%3==2:\n if b%3 == 0:\n cell = 5\n elif b%3 == 2:\n cell = 4\n else:\n cell = 3\nelse:\n if b%3==0:\n cell = 2\n elif b%3==2:\n cell = 1\n else:\n cell = 0\nvalid = False\nfor i in range(3):\n for j in range(3):\n if grid[cell/3][cell%3][i][j] == '.':\n valid = True\n grid[cell/3][cell%3][i][j] = '!'\nif not valid:\n for i in range(3):\n for j in range(3):\n for k in range(3):\n for l in range(3):\n if grid[i][j][k][l] == '.':\n grid[i][j][k][l] = '!'\nfor i in range(3):\n for j in range(3):\n print \"\".join(grid[i][0][j])+\" \"+\"\".join(grid[i][1][j])+\" \"+\"\".join(grid[i][2][j])\n if i != 2:\n print \"\""}, {"source_code": "import sys\n\n#f = open('input', 'r')\nf = sys.stdin\n\nm = []\nfor t in range(3):\n ml = [[] for _ in range(3)]\n for _ in range(3):\n map_line = f.readline().split()\n for i, x in enumerate(map_line):\n ml[i].append(list(x))\n m.append(ml)\n if t < 2:\n f.readline()\nx,y = map(int, f.readline().split())\nx-=1\ny-=1\nfx = x%3\nfy = y%3\nchecked = False\nfor i in range(3):\n for j in range(3):\n if m[fx][fy][i][j] == '.':\n m[fx][fy][i][j] = '!'\n checked = True\n\nif not checked:\n for i in range(9):\n for j in range(9):\n if m[i//3][j//3][i%3][j%3] == '.':\n m[i//3][j//3][i%3][j%3] = '!'\n\n\nfor t in range(3):\n for i in range(3):\n print(' '.join(''.join(x[i]) for x in m[t]))\n if t < 2:\n print()\n"}, {"source_code": "#http://codeforces.com/problemset/problem/907/B\n#solved\n\nfild = []\n\nfirst = input().split()\nsecend = input().split()\nthird = input().split()\ninput()\nfourth = input().split()\nfivth = input().split()\nsixth = input().split()\ninput()\nseventh = input().split()\neight = input().split()\nninght = input().split()\nx, y = list(map(int, input().split()))\n\nfild.append(first[0] + secend[0] + third[0])\nfild.append(first[1] + secend[1] + third[1])\nfild.append(first[2] + secend[2] + third[2])\nfild.append(fourth[0] + fivth[0] + sixth[0])\nfild.append(fourth[1] + fivth[1] + sixth[1])\nfild.append(fourth[2] + fivth[2] + sixth[2])\nfild.append(seventh[0] + eight[0] + ninght[0])\nfild.append(seventh[1] + eight[1] + ninght[1])\nfild.append(seventh[2] + eight[2] + ninght[2])\n\n\ndef where(x, y):\n if x < 4 and y < 4:\n return int((3 * x) - (3 - y))\n elif x < 4 and y < 7:\n return int((3 * x) - (3 - (y - 3)))\n elif x < 4:\n return int((3 * x) - (3 - (y - 6)))\n \n elif x < 7 and y < 4:\n return int((3 * (x - 3)) - (3 - y))\n elif x < 7 and y < 7:\n return int((3 * (x - 3)) - (3 - (y - 3)))\n elif x < 7:\n return int((3 * (x - 3)) - (3 - (y - 6)))\n \n elif y < 4:\n return int((3 * (x - 6)) - (3 - y))\n elif y < 7:\n return int((3 * (x - 6)) - (3 - (y - 3)))\n else:\n return int((3 * (x - 6)) - (3 - (y - 6)))\n\n\ndef swap(a):\n out = \"\"\n for i in a:\n if i == \".\":\n out += \"!\"\n else:\n out += i\n return out\n\ny_fild = where(x, y) - 1\n\nif fild[y_fild].count(\".\") != 0:\n fild[y_fild] = swap(fild[y_fild])\n\nelse:\n for j in range(9):\n fild[j] = swap(fild[j])\n\n\nprint(fild[0][0:3] + \" \" + fild[1][0:3] + \" \" + fild[2][0:3])\nprint(fild[0][3:6] + \" \" + fild[1][3:6] + \" \" + fild[2][3:6])\nprint(fild[0][6:9] + \" \" + fild[1][6:9] + \" \" + fild[2][6:9])\nprint(\"\")\nprint(fild[3][0:3] + \" \" + fild[4][0:3] + \" \" + fild[5][0:3])\nprint(fild[3][3:6] + \" \" + fild[4][3:6] + \" \" + fild[5][3:6])\nprint(fild[3][6:9] + \" \" + fild[4][6:9] + \" \" + fild[5][6:9])\nprint(\"\")\nprint(fild[6][0:3] + \" \" + fild[7][0:3] + \" \" + fild[8][0:3])\nprint(fild[6][3:6] + \" \" + fild[7][3:6] + \" \" + fild[8][3:6])\nprint(fild[6][6:9] + \" \" + fild[7][6:9] + \" \" + fild[8][6:9]) \n\n"}, {"source_code": "import sys\nsys.setrecursionlimit(1000000)\nread = sys.stdin.readline\n\nfield = [\"\" for _ in range(9)]\n\nfor i in range(3):\n for j in range(3):\n try:\n l, m, r = read().strip().split()\n except ValueError:\n l, m, r = read().strip().split()\n field[i*3] += l\n field[i*3+1] += m\n field[i*3+2] += r\n\nx, y = map(int, read().split())\nidx = (x-1)//3 * 3 + (y-1)//3\ninIdx = (x-1)%3 * 3 + (y-1)%3\n\nif '.' in field[inIdx]:\n field[inIdx] = field[inIdx].replace('.', '!')\nelse:\n for i in range(len(field)):\n field[i] = field[i].replace('.', '!')\n\nfor i in range(3):\n for j in range(3):\n print(field[i*3][j*3: j*3+3], field[i*3+1][j*3: j*3+3], field[i*3+2][j*3: j*3+3])\n if i in (0, 1,):\n print('')"}, {"source_code": "a = []\nfor i in xrange(11):\n\ta.append(raw_input().split())\n\nx,y = map(int,raw_input().split())\nz = 0\nif x%3==1:\n\tz = [[0,1,2]]\nelif x%3 ==2:\n\tz = [[4,5,6]]\nelse:\n\tz = [[8,9,10]]\nif y%3==1:\n\tz.append([0])\nelif y%3 ==2:\n\tz.append([1])\nelse:\n\tz.append([2])\n#print z\nw = 0\nfor i in z[0]:\n\tfor j in z[1]:\n\t\tfor r in xrange(3):\n\t\t\tif a[i][j][r]=='.':\n\t\t\t\ta[i][j]=a[i][j][:r]+'!'+a[i][j][r+1:]\n\t\t\t\tw = 1\nif w ==0:\n\tfor i in [0,1,2,4,5,6,8,9,10]:\n\t\tfor j in [0,1,2]:\n\t\t\tfor r in xrange(3):\n\t\t\t\tif a[i][j][r] == '.':\n\t\t\t\t\ta[i][j] = a[i][j][:r]+'!'+a[i][j][r+1:]\nfor i in xrange(11):\n\tprint ' '.join(a[i])\n\n"}, {"source_code": "def f(x):\n\tx%=3\n\tif x==0:\n\t\treturn 3\n\treturn x\ndef g(x):\n\tif x==1:\n\t\treturn 0\n\telif x==2:\n\t\treturn 4\n\telse:\n\t\treturn 8\na=[]\nfor i in range(3):\n\ta.append(input())\nd=input()\na.append(11*' ')\nfor i in range(3):\n\ta.append(input())\nd=input()\na.append(11*' ')\nfor i in range(3):\n\ta.append(input())\nx,y=list(map(int,input().split()))\nx=f(x)\ny=f(y)\nx=g(x)\ny=g(y)\np=0\nfor i in range(x,x+3):\n\tfor j in range(y,y+3):\n\t\tif a[i][j]=='.':\n\t\t\ta[i]=a[i][:j]+'!'+a[i][j+1:]\n\t\t\tp=1\nif p:\n\tfor i in range(11):\n\t\tprint(a[i])\nelse:\n\tfor i in range(11):\n\t\tfor j in range(11):\n\t\t\tif a[i][j]=='.':\n\t\t\t\ta[i]=a[i][:j]+'!'+a[i][j+1:]\n\tfor i in range(11):\n\t\tprint(a[i])\n "}, {"source_code": "table = []\n\nfields = []\nfield1, field2, field3 = [], [], []\nfor row in range(11):\n if row != 3 and row != 7:\n nexus = [i for i in input() if i != ' ']\n table.append(nexus)\n field1.append(nexus[:3])\n field2.append(nexus[3:6])\n field3.append(nexus[6:9])\n elif row == 3 or row == 7:\n input()\n fields.extend([field1, field2, field3])\n field1, field2, field3 = [], [], []\nfields.extend([field1, field2, field3])\n\n# print(*fields, sep='\\n')\n\nx_y = [int(i) - 1 for i in input().split()]\n\n# print(*table, sep='\\n')\n\npositions = []\nfor row in range(3):\n for column in range(3):\n coord = []\n for next_column in range(0, 7, 3):\n col = column + next_column\n r = row\n for next_row in range(0, 7, 3):\n coord.append([r + next_row, col])\n positions.append(coord)\n\n# print(*positions, sep='\\n')\n\nfor order_num, candidate in enumerate(positions):\n # print(x_y)\n if x_y in candidate:\n flag = 0\n for row in fields[order_num]:\n for ind in range(3):\n if row[ind] == '.':\n row[ind] = '!'\n flag = 1\n if flag == 0:\n for string in fields:\n for row in string:\n for ind in range(3):\n row[ind] = '!' if row[ind] == '.' else row[ind]\n\n# print(*fields, sep='\\n')\n\nfor row in range(0, 7, 3):\n for column in range(3):\n for r in range(row, row + 3):\n # print(r, column)\n print(*fields[r][column], sep='', end=' ')\n print()\n print()\n"}, {"source_code": "R=raw_input\ng=map(list,(R() for _ in range(11)))\nr,c=map(int,R().split())\nr,c=(r-1)%3*4,(c-1)%3*4\nf=0\nfor i in range(9):\n if '.'==g[r+i/3][c+i%3]:\n g[r+i/3][c+i%3]='!'\n f=1\nfor v in g:\n s=''.join(v)\n print s if f else s.replace('.','!')"}, {"source_code": "rows = []\nrows.append(\"\".join(raw_input().split()))\nrows.append(\"\".join(raw_input().split()))\nrows.append(\"\".join(raw_input().split()))\nraw_input()\nrows.append(\"\".join(raw_input().split()))\nrows.append(\"\".join(raw_input().split()))\nrows.append(\"\".join(raw_input().split()))\nraw_input()\nrows.append(\"\".join(raw_input().split()))\nrows.append(\"\".join(raw_input().split()))\nrows.append(\"\".join(raw_input().split()))\n\nrow, col = map(int, raw_input().split())\n\nqrtr = ((row - 1) % 3, (col - 1) % 3)\n\nrows = map(list, rows)\nhas_empty = False\n\nfor i in range(3):\n for j in range(3):\n if rows[3 * qrtr[0] + i][3 * qrtr[1] + j] == \".\":\n has_empty = True\n rows[3 * qrtr[0] + i][3 * qrtr[1] + j] = \"!\"\n\nif not has_empty:\n for i in range(len(rows)):\n rows[i] = map(lambda c: \"!\" if c == \".\" else c, rows[i])\n\nrows = [\"\".join(r) for r in rows]\ni = 0\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\nprint rows[i][:3], rows[i][3:6], rows[i][6:]\ni += 1\n"}, {"source_code": "import math,sys,bisect,heapq\nfrom collections import defaultdict,Counter,deque\nfrom itertools import groupby,accumulate\n#sys.setrecursionlimit(200000000)\nint1 = lambda x: int(x) - 1\ninput = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\nilele = lambda: map(int,input().split())\nalele = lambda: list(map(int, input().split()))\nilelec = lambda: map(int1,input().split())\nalelec = lambda: list(map(int1, input().split()))\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\n#MOD = 1000000000 + 7\ndef Y(c): print([\"NO\",\"YES\"][c])\ndef y(c): print([\"no\",\"yes\"][c])\ndef Yy(c): print([\"No\",\"Yes\"][c])\n \nA = []\nfor i in range(11):\n s = input()\n A.append([*s])\n\n#print(A)\nx,y = ilele()\nif x<= 3:\n i= x-1\nelif x <= 6:\n i = x\nelse:\n i = x+1\nif y<= 3:\n j= y-1\nelif y <= 6:\n j = y\nelse:\n j = y+1\n\n#print(i,j)\nf = 0\nif 0 <=i <= 2:\n a = 0;b = 2\nelif 4<= i <= 6:\n a = 4;b= 6\nelse:\n a = 8;b = 10\nif 0 <=j <= 2:\n c = 0;d = 2\nelif 4<= j <= 6:\n c = 4;d= 6\nelse:\n c = 8;d = 10\n#print(a,c)\n \nk1 = i -a\nk2 = j -c\n#print(k1,k2)\n\nif k1 == 0:\n a = 0;b = 2\nelif k1 == 1:\n a = 4;b= 6\nelse:\n a = 8;b = 10\nif k2 == 0:\n c = 0;d = 2\nelif k2 == 1:\n c = 4;d= 6\nelse:\n c = 8;d = 10\n\n\n \nfor l in range(a,b+1):\n for m in range(c,d+1):\n if A[l][m] == '.':\n f = 1\n A[l][m] = '!'\nif f == 0:\n for i in range(len(A)):\n if A[i]:\n for j in range(len(A[0])):\n if A[i][j] == '.':\n A[i][j] = \"!\"\nfor i in A:\n if i:\n print(\"\".join(i))\n else:\n print()\n \n \n \n\n"}, {"source_code": "field = []\nfor _ in range(3):\n row = list(input().replace(' ', ''))\n field.append(row)\ninput()\nfor _ in range(3):\n row = list(input().replace(' ', ''))\n field.append(row)\ninput()\nfor _ in range(3):\n row = list(input().replace(' ', ''))\n field.append(row)\nx, y = list(map(int, input().split()))\nx -= 1\ny -= 1\nrow = x%3\ncolumn = y%3\nis_full = True\nfor i in range(row*3, row*3+3):\n for j in range(column*3, column*3+3):\n if field[i][j] == '.':\n field[i][j] = '!'\n is_full = False\nif is_full:\n for i in range(0, 9):\n for j in range(0, 9):\n if field[i][j] == '.':\n field[i][j] = '!'\nfor i in range(0, 9):\n for j in range(0, 9):\n print(field[i][j], end='')\n if (j == 2) or (j == 5):\n print(' ', end='')\n print(' ')\n if (i == 2) or (i == 5):\n print(' ')\n"}, {"source_code": "l = []\nfor i in range(11):\n l.append(list(input()))\nx, y = [int(i) for i in input().split()]\nif x <= 3:\n x -= 1\nif y <= 3:\n y -= 1\nif x >= 7:\n x += 1\nif y >= 7:\n y += 1\n\nstatus = True\n\nif x % 4 == 0:\n if y % 4 == 0:\n for i in range(3):\n for j in range(3):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\n elif y % 4 == 1:\n for i in range(3):\n for j in range(4,7):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\n else:\n for i in range(3):\n for j in range(8,11):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\nelif x % 4 == 1:\n if y % 4 == 0:\n for i in range(4,7):\n for j in range(3):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\n elif y % 4 == 1:\n for i in range(4,7):\n for j in range(4,7):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\n else:\n for i in range(4,7):\n for j in range(8,11):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\nelse:\n if y % 4 == 0:\n for i in range(8,11):\n for j in range(3):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\n elif y % 4 == 1:\n for i in range(8,11):\n for j in range(4,7):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\n else:\n for i in range(8,11):\n for j in range(8,11):\n if l[i][j] == '.':\n l[i][j] = '!'\n status = False\n\nif status:\n for w in l:\n for i in range(len(w)):\n if w[i] == '.':\n w[i] = '!'\nfor w in l:\n print(''.join(w))\n# print(x,y)"}, {"source_code": "'''\nst = '1.1 1.2 1.3\\n' \\\n '2.1 2.2 2.3\\n' \\\n '3.1 3.2 3.3\\n' \\\n '\\n' \\\n '4.1 4.2 4.3\\n' \\\n '5.1 5.2 5.3\\n' \\\n '6.1 6.2 6.3\\n' \\\n '\\n' \\\n '721 752 783\\n' \\\n '821 852 883\\n' \\\n '921 952 983\\n'\nxlast = 3\nylast = 6\n'''\n\ndef print_pole():\n s = ''\n for i in range(1, 10):\n sti = []\n for j in range(3):\n sti.append(''.join(pole[i][j]))\n s += ' '.join(sti) + '\\n'\n if (i == 3) or (i == 6):\n s += '\\n'\n print(s)\n\nst = ''\nfor i in range(11):\n st += input() + ' '\n#print(st)\nylast, xlast = map(int,input().split())\n\npole = [0]\npole = [0]*10\nL = st.split()\nk = 0\nfor i in range(1, 10):\n Li = []\n for j in range(3):\n Lij = list(L[k])\n k += 1\n Li.append(Lij)\n pole[i] = Li\n\ndef x0(x):\n if x % 3:\n return (x % 3) - 1\n else:\n return 2\n\ndef y0(y):\n if y % 3:\n return 1 + (y % 3 - 1) * 3\n else:\n return 7\n\nyl, xl = y0(ylast), x0(xlast)\nfree = False\nfor si in range(3):\n for i in range(3):\n if pole[yl + si][xl][i] == '.':\n pole[yl + si][xl][i] = '!'\n free = True\n\nif not free:\n for si in range(1, 10):\n for j in range(3):\n for k in range(3):\n if pole[si][j][k] == '.':\n pole[si][j][k] = '!'\n\n\n#print('free=', free)\nprint_pole()"}, {"source_code": "game = []\nfor _ in range(11):\n game.append(list(input()))\ncorner_y, corner_x = map(lambda n: 4*((int(n) - 1)%3), input().split())\n\nany_move = True\nfor y in range(corner_y, corner_y + 3):\n for x in range(corner_x, corner_x + 3):\n if game[y][x] == \".\":\n game[y][x] = \"!\"\n any_move = False\n\nif any_move:\n for l in game:\n for index, c in enumerate(l):\n if l[index] == \".\":\n l[index] = \"!\"\n\nfor l in game:\n print(\"\".join(l))\n"}, {"source_code": "a = []\nfor i in range(11):\n if i == 3 or i == 7:\n input()\n else:\n x, y, z = map(str, input().split())\n a.append(list(x + y + z))\nx, y = map(int, input().split())\nif x % 3 == 0:\n u = 6\n d = 8\nelif x % 3 == 2:\n u = 3\n d = 5\nelse:\n u = 0\n d = 2\nif y % 3 == 0:\n l = 6\n r = 8\nelif y % 3 == 2:\n l = 3\n r = 5\nelse:\n l = 0\n r = 2\nempty = False\nfor i in range(u, d + 1):\n for j in range(l, r + 1):\n if a[i][j] == '.':\n empty = True\n a[i][j] = '!'\nif not empty:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n a[i][j] = '!'\nfor i in range(9):\n if i == 3 or i == 6:\n print()\n print(''.join(map(str, a[i][0:3])), ''.join(map(str, a[i][3:6])), ''.join(map(str, a[i][6:9])))\n"}, {"source_code": "l = []\n\nfor _ in range(11):\n s = input().replace(' ', '')\n if len(s):\n l.append(list(s))\n\nx, y = map(int, input().split())\n\nx -= 1\ny -= 1\n\nx %= 3\ny %= 3\n\nok = False\n\nfor i in range(x * 3, x * 3 + 3):\n for j in range(y * 3, y * 3 + 3):\n if l[i][j] == '.':\n ok = True\n l[i][j] = '!'\n\nif not ok:\n for i in range(9):\n for j in range(9):\n if l[i][j] == '.':\n l[i][j] = '!'\n\nfor i in range(9):\n for j in range(9):\n print(l[i][j], end='')\n if j % 3 == 2:\n print(' ', end='')\n print()\n if i % 3 == 2:\n print()\n"}, {"source_code": "import sys\nboard = [list(input().replace(\" \",\"\")) for i in range(11)]\ndel board[7]\ndel board[3]\ny,x=map(int,input().split())\ny-=1\nx-=1\nflag=True\npy=y%3\npx=x%3\nfor i in range(3):\n for j in range(3):\n if board[py*3+i][px*3+j]==\".\":\n flag=False\nif flag:\n for i in range(9):\n for j in range(9):\n if board[i][j]==\".\":\n board[i][j]=\"!\"\nelse:\n for i in range(3):\n for j in range(3):\n if board[py*3+i][px*3+j]==\".\":\n board[py*3+i][px*3+j]=\"!\"\nfor i in range(3):\n for j in range(3):\n for k in range(3):\n if k>0:\n print(\" \",end=\"\")\n for l in range(3):\n print(board[3*i+j][3*k+l],end=\"\")\n print(\"\")\n if i<2:\n print(\"\")"}, {"source_code": "def is_full(board, x, y):\n for a in range(3):\n for b in range(3):\n if board[x * 3 + a][y * 3 + b] not in [\"o\", \"x\"]:\n return False\n return True\n\n\ndef fill_board(board, exclude, x, y):\n if exclude:\n for a in range(9):\n for b in range(9):\n if not ((x * 3 <= a <= x * 3 + 2) and (y * 3 <= b <= y * 3 + 2)):\n if board[a][b] not in [\"o\", \"x\"]:\n board[a][b] = \"!\"\n else:\n for a in range(3):\n for b in range(3):\n if board[x * 3 + a][y * 3 + b] not in [\"o\", \"x\"]:\n board[x * 3 + a][y * 3 + b] = \"!\"\n\n\nclass CodeforcesTask907BSolution:\n def __init__(self):\n self.result = ''\n self.board = []\n self.last_move = []\n\n def read_input(self):\n for x in range(11):\n in_ = input()\n if in_:\n self.board.append(list(in_.replace(\" \", \"\")))\n self.last_move = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n fill_board(self.board, is_full(self.board, *[(x - 1) % 3 for x in self.last_move]),\n *[(x - 1) % 3 for x in self.last_move])\n out_board = [\" \".join([\"\".join(x) for x in [row[:3], row[3:6], row[6:]]]) for row in self.board]\n out_board = out_board[:3] + [\"\"] + out_board[3:6] + [\"\"] + out_board[6:]\n self.result = \"\\n\".join(out_board)\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask907BSolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "def main():\n def get_cell(x, y):\n (r, c) = 0, 0\n if x <= 2:\n r = 0\n elif x <= 5:\n r = 1\n elif x <= 8:\n r = 2\n if y <= 2:\n c = 0\n elif y <= 5:\n c = 1\n elif y <= 8:\n c = 2\n return (r, c)\n def get_cells(grids, fx, fy):\n count = 0\n for i in range(3):\n for j in range(3):\n if grids[fx][fy][i][j] == '.':\n grids[fx][fy][i][j] = '!'\n count += 1\n return count\n g = []\n for i in range(11):\n l = ''.join(input().split())\n if len(l) > 0:\n g.append(list(l))\n grids = []\n for k in range(3):\n gg = []\n for j in range(3):\n ggg = []\n for i in range(3 * k, 3 * k + 3):\n ggg.append(g[i][j * 3:j * 3 + 3])\n gg.append(ggg)\n grids.append(gg)\n (x, y) = map(int, input().split(' '))\n x -= 1\n y -= 1\n (cx, cy) = get_cell(x, y)\n fx, fy = x, y\n while fx >= 3:\n fx -= 3\n while fy >= 3:\n fy -= 3\n count = get_cells(grids, fx, fy)\n if count == 0:\n for i in range(3):\n for j in range(3):\n get_cells(grids, i, j)\n ret = []\n for k in range(3):\n for j in range(3):\n x = []\n for i in range(3):\n x.append(''.join(grids[k][i][j]))\n ret.append(x)\n ret.append(\"\")\n for thing in ret:\n print(' '.join(thing))\nmain()\n"}, {"source_code": "l=[]\nfor i in range(11):\n s=input()\n s=s.replace(' ','')\n if i!=3 and i!=7:\n l.append(s)\ny,x=map(int, input().split())\nx-=1\ny-=1\nt=False\nfor i in range(y%3*3,y%3*3+3):\n for j in range(x%3*3,x%3*3+3):\n if l[i][j]=='.':\n t=True\n break\n if t:\n break\nelse:\n for i in range(9):\n for j in range(9):\n if l[i][j]=='.':\n print('!', end='')\n else:\n print(l[i][j],end='')\n if j%3==2:\n print(end=' ')\n print()\n if i%3==2:\n print()\nif t:\n for i in range(9):\n for j in range(9):\n if l[i][j]=='.' and y%3*3<=i<=y%3*3+2 and x%3*3<=j<=x%3*3+2:\n print('!', end='')\n else:\n print(l[i][j],end='')\n if j%3==2:\n print(end=' ')\n print()\n if i%3==2:\n print()\n"}, {"source_code": "l=[input() for _ in range(11)]\nx,y=map(int, input().split())\nx-=1\nx+=x//3\ny-=1\ny+=y//3\na,b=x%4*4,y%4*4\nr=11\nfor i in range(a,a+3):\n s=l[i][b:b+3]\n if '.' in s:\n l[i],r=l[i][:b]+s.replace('.','!')+l[i][b+3:],0\nfor i in range(r):\n l[i]=l[i].replace('.','!')\nprint(*l,sep='\\n')"}, {"source_code": "import bisect\n\ndef list_output(s): \n print(' '.join(map(str, s)))\n \ndef list_input(s='int'):\n if s == 'int':\n return list(map(int, input().split())) \n elif s == 'float':\n return list(map(float, input().split()))\n return list(map(str, input().split()))\n\nM = list()\nfor i in range(11):\n M.append(list(input()))\nr, c = map(int, input().split())\nr -= 1\nc -= 1\nr %= 3\nc %= 3\n\ncnt = 0\nfor i in range(3*r, 3*r+3):\n for j in range(3*c, 3*c+3):\n di, dj = 0, 0\n if i >= 6:\n di = 2\n elif i >= 3:\n di = 1\n if j >= 6:\n dj = 2\n elif j >= 3:\n dj = 1\n if M[i+di][j+dj] == '.':\n M[i+di][j+dj] = '!'\n cnt += 1\nif cnt == 0:\n for i in range(0, 11):\n for j in range(0, len(M[i])):\n if M[i][j] == '.':\n M[i][j] = '!'\n\nfor i in range(11):\n print(''.join(map(str, M[i])))\n\n"}, {"source_code": "\nfield = [None]*3\n\nfor i in range(3):\n if i != 0: \n input() # empty\n field[i] = line = []\n for j in range(3):\n line.append(input().replace(' ', ''))\nx, y = map(lambda x: (int(x)-1)%3, input().split(' '))\n\n\n#for i in field: print(i)\n#print('done')\n\nfree = False\nfor i in range(3):\n if free: break\n for j in range(3):\n if field[x][i][y*3+j] == '.':\n free = True\n break\n\nif free:\n p = y*3\n for i in range(3):\n field[x][i] = field[x][i][:p] + field[x][i][p:p+3].replace('.', '!') + field[x][i][p+3:]\nelse:\n for line in field:\n for i in range(3):\n line[i] = line[i].replace('.', '!')\n\nj = 0\nfor line in field:\n if j == 0: j = 1\n else: print()\n for i in range(3):\n s = line[i]\n s = s[:3] + ' ' + s[3:6] + ' ' + s[6:]\n print(s)\n\n\n'''\n.!. ... ...\n... ... .z.\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n..x ... .e.\n.x. .s. .f.\nx.. ... .c.\n6 4\n\n'''\n"}], "negative_code": [{"source_code": "k = [[] for i in range(9)]\np = 0\nr = 0\nfor i in range(11):\n b = input()\n b = b[:3] + b[4:7] + b[8:11]\n if b != '':\n k[i - p].append(b)\n else:\n p += 1\na, b = map(int, input().split())\na -= 1\nb -= 1\nprint(k)\nfor i in range(3 * (a % 3), 3 * (a % 3) + 3):\n for j in range(3 * (b % 3), 3 * (b % 3) + 3):\n if k[i][0][j] != 'o' and k[i][0][j] != 'x':\n k[i][0] = k[i][0][:j] + '!' + k[i][0][j + 1:]\n r = 1\nif r == 0:\n for i in range(9):\n for j in range(9):\n if k[i][0][j] != 'o' and k[i][0][j] != 'x':\n k[i][0] = k[i][0][:j] + '!' + k[i][0][j + 1:]\nfor i in range(len(k)):\n for j in range(len(k[i][0])):\n print(k[i][0][j], end = '')\n if j == 2 or j == 5:\n print(' ', end = '')\n print(' ')\n if i == 2 or i == 5:\n print(' ')"}, {"source_code": "field = [input().split() for _ in range(11)]\ndel field[7]\ndel field[3]\n\nlast_y,last_x = [int(i)-1 for i in input().split()]\nf_x = last_x % 3\nf_y = last_y % 3\n\nfor i in range(3):\n if '.' in field[f_y*3+i][f_x]:\n for y in range(3):\n field[f_y*3+y][f_x] = field[f_y*3+y][f_x].replace('.','!')\n break;\nelse:\n for y in range(9):\n for x in range(3):\n field[y][x] = field[y][x].replace('.','!')\n\nprint(str([str(s)[2:-2].replace(\"', '\", ' ') for s in field])[2:-2].replace(\"', '\",'\\n'))\n"}, {"source_code": "mass = []\nfor i in range(11) :\n a = list(input())\n if i != 3 and i != 7 :\n a.pop(3)\n a.pop(6)\n mass.append(a) \n\nx, y = map(int, input().split())\nx -= 1\ny -= 1\n\nn = 0\nfor i in range(x % 3 * 3, x % 3 * 3 + 3) :\n for j in range(y % 3 * 3, y % 3 * 3 + 3) :\n if mass[i][j] == '.' :\n mass[i][j] = '!'\n n += 1\n\nif n == 0 :\n for i in range(9) :\n for j in range(9) :\n if mass[i][j] == '.' :\n mass[i][j] = '!'\n\nfor i in range(9) :\n mass[i].insert(3, ' ')\n mass[i].insert(7, ' ')\n if i == 3 or i == 6 :\n print()\n for j in range(11) :\n print(mass[i][j], end = ' ')\n print()\n"}, {"source_code": "mas = []\nmas1 = []\nfor i in range(11):\n mas.append(list(input().split()))\nmas.pop(3)\nmas.pop(6)\na, b = map(int, input().split())\nfor i in mas:\n mas2 = []\n for str1 in i:\n for elem in str1:\n mas2.append(elem)\n mas1.append(mas2)\n \nblock1 = [mas1[0][0], mas1[0][1], mas1[0][2], mas1[1][0], mas1[1][1], mas1[1][2], mas1[2][0], mas1[2][1], mas1[2][2]]\n\nblock2 = [mas1[0][3], mas1[0][4], mas1[0][5], mas1[1][3], mas1[1][4], mas1[1][5], mas1[2][3], mas1[2][4], mas1[2][5]]\n\nblock3 = [mas1[0][6], mas1[0][7], mas1[0][8], mas1[1][6], mas1[1][7], mas1[1][8], mas1[2][6], mas1[2][7], mas1[2][8]]\n\n\n\nblock4 = [mas1[3][0], mas1[3][1], mas1[3][2], mas1[4][0], mas1[4][1], mas1[4][2], mas1[5][0], mas1[5][1], mas1[5][2]]\n\nblock5 = [mas1[3][3], mas1[3][4], mas1[3][5], mas1[4][3], mas1[4][4], mas1[4][5], mas1[5][3], mas1[5][4], mas1[5][5]]\n\nblock6 = [mas1[3][6], mas1[3][7], mas1[3][8], mas1[4][6], mas1[4][7], mas1[4][8], mas1[5][6], mas1[5][7], mas1[5][8]]\n\n\n\nblock7 = [mas1[6][0], mas1[6][1], mas1[6][2], mas1[7][0], mas1[7][1], mas1[7][2], mas1[8][0], mas1[8][1], mas1[8][2]]\n\nblock8 = [mas1[6][3], mas1[6][4], mas1[6][5], mas1[7][3], mas1[7][4], mas1[7][5], mas1[8][3], mas1[8][4], mas1[8][5]]\n\nblock9 = [mas1[6][6], mas1[6][7], mas1[6][8], mas1[7][6], mas1[7][7], mas1[7][8], mas1[8][6], mas1[8][7], mas1[8][8]]\n\nblocks = [0, block1, block2, block3, block4, block5, block6, block7, block8, block9]\n\nx = a % 3\ny = b % 3\nif x == 0:\n x += 3\nif y == 0:\n y += 3\nif x == 1:\n if y == 1:\n block = 1\n elif y == 2:\n block = 2\n elif y == 3:\n block = 3\nelif x == 2:\n if y == 1:\n block = 4\n elif y == 2:\n block = 5\n elif y == 3:\n block = 6\nelif x == 3:\n if y == 1:\n block = 7\n elif y == 2:\n block = 8\n elif y == 3:\n block = 9\n\nif \".\" not in blocks[block]:\n for i in mas1:\n for j in range(len(i)):\n if i[j] == \".\":\n i[j] = \"!\"\nelse:\n if block in [1, 2, 3]:\n elem1 = [0, 1, 2]\n elif block in [4, 5, 6]:\n elem1 = [3, 4, 5]\n elif block in [7, 8, 9]:\n elem1 = [6, 7, 8]\n \n if block in [1, 4, 7]:\n elem2 = [0, 1, 2]\n elif block in [2, 5, 8]:\n elem2 = [3, 4, 5]\n elif block in [3, 6, 9]:\n elem2 = [6, 7, 8]\n \n for i in elem1:\n for j in elem2:\n if mas1[i][j] == \".\":\n mas1[i][j] = \"!\"\n\nfor j in range(0, 3):\n i = mas1[j]\n print(i[0], i[1], i[2], \" \", i[3], i[4], i[5], \" \", i[6], i[7], i[8])\nprint()\nfor j in range(3, 6):\n i = mas1[j]\n print(i[0], i[1], i[2], \" \", i[3], i[4], i[5], \" \", i[6], i[7], i[8])\nprint()\nfor j in range(6, 9):\n i = mas1[j]\n print(i[0], i[1], i[2], \" \", i[3], i[4], i[5], \" \", i[6], i[7], i[8])"}, {"source_code": "s = [[] * 9 for i in range(9)]\n\nk = -1\n\nfor i in range(11):\n g = input().replace(' ', '')\n if g != '':\n k += 1\n for j in g:\n if j != '':\n s[k].append(j)\n\nx, y = map(int, input().split())\n\nx1, y1 = x % 3, y % 3\n\nj = ''\n\nl = 0\n\nfor i in range((x1 - 1) * 3, x1 * 3):\n for r in range((y1 - 1) * 3, y1 * 3):\n j += s[i][r]\n l += 1\n\nif j.count('.') == 0:\n for i in s:\n o = 0\n for h in i:\n if o % 3 == 0 and o != 0:\n print(' ', end='')\n if h == '.':\n print('!', end='')\n else:\n print(h, end='')\n o += 1\n print('\\n')\nelse:\n for i in range((x1 - 1) * 3, x1 * 3):\n for r in range((y1 - 1) * 3, y1 * 3):\n if s[i][r] == '.':\n s[i][r] = '!'\n\n for i in s:\n o = 0\n for h in i:\n if o % 3 == 0 and o != 0:\n print(' ', end='')\n print(h, end='')\n o += 1\n print('\\n')\n"}, {"source_code": "from pprint import pprint\n\nflag = False\nfield = [[[], [], []],\n [[], [], []],\n [[], [], []]]\nfor i in range(3):\n a, b, c = input().split()\n field[0][0].append(list(a))\n field[0][1].append(list(b))\n field[0][2].append(list(c))\ninput()\nfor i in range(3):\n a, b, c = input().split()\n field[1][0].append(list(a))\n field[1][1].append(list(b))\n field[1][2].append(list(c))\ninput()\nfor i in range(3):\n a, b, c = input().split()\n field[2][0].append(list(a))\n field[2][1].append(list(b))\n field[2][2].append(list(c))\n\ny, x = map(int, input().split())\n\nif 0 < y < 4:\n new = field[0]\n\nelif 3 < y < 7:\n new = field[1]\n\nelse:\n new = field[2]\n\nif 0 < x < 4:\n new = new[0]\n\nelif 3 < x < 7:\n new = new[1]\n\nelse:\n new = new[2]\n\nnew_y, new_x = (y - 1) % 3, (x - 1) % 3\ncurr = field[new_y][new_x]\nif '.' in ''.join([''.join(i) for i in curr]):\n flag = True\nk = 0\nb = 0\nif not flag:\n for line in field:\n for i in range(3):\n for ind3, elem in enumerate(line):\n s = ''.join(elem[k]).replace('.', '!')\n if ind3 == len(line) - 1:\n print(s, end='')\n else:\n print(s, end=' ')\n print()\n k += 1\n k = 0\nelse:\n for ind, line in enumerate(field):\n for i in range(3):\n for ind2, elem in enumerate(line):\n if ind == new_y and ind2 == new_x:\n s = ''.join(elem[k]).replace('.', '!')\n else:\n s = ''.join(elem[k])\n\n if ind2 == len(line) - 1:\n print(s, end='')\n else:\n print(s, end=' ')\n print()\n k += 1\n k = 0\n"}, {"source_code": "def Y():\n x,y = x0,y0\n while x > 3:\n x -= 3\n while y > 3:\n y -=3\n y,x = x-1,y-1\n if now == 1:\n x,y = x,y\n if now == 2:\n x,y = x, y + 3\n if now == 3:\n x,y = x, y + 6\n if now == 4:\n x,y = x + 3, y\n if now == 5:\n x,y = x + 3, y + 3\n if now == 6:\n x,y = x + 3, y + 6\n if now == 7:\n x,y = x + 6, y\n if now == 8:\n x,y = x + 6, y + 3\n if now == 9:\n x,y = x + 6, y + 6\n return [x,y]\n \n\ndef coun(x1,x2,y1,y2):\n ans = 0\n for i in range(x1,x2 + 1):\n for j in range(y1,y2 + 1):\n if a[i][j] == '.':\n ans += 1\n return ans\n\n\n\ndef F(xc,yc):\n x,y = xc,yc\n while x > 3:\n x -= 3\n while y > 3:\n y -=3\n y,x = x-1,y-1\n if x == 0 and y == 0:\n return 1\n if x == 0 and y == 1:\n return 4\n if x == 0 and y == 2:\n return 7\n if x == 1 and y == 0:\n return 2\n if x == 1 and y == 1:\n return 5\n if x == 1 and y == 2:\n return 8\n if x == 2 and y == 0:\n return 3\n if x == 2 and y == 1:\n return 6\n if x == 2 and y == 2:\n return 9\n \n \na = []\nfor i in range(11):\n b = input()\n if i != 3 and i != 7:\n a.append([b[0],b[1],b[2],b[4],b[5],b[6],b[8],b[9],b[10]])\n\nx0, y0 = map(int, input().split())\n\nnow = F(x0,y0)\n\nif now == 1:\n kek = [0,2,0,2]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 2:\n kek = [0,2,3,5]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 3:\n kek = [0,2,6,8]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 4:\n kek = [3,5,0,2]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 5:\n kek = [3,5,3,5]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 6:\n kek = [3,5,6,8]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 7:\n kek = [6,8,0,2]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 8:\n kek = [6,8,3,5]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 9:\n kek = [6,8,6,8]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\n \n\ntow = Y()\n\nif toch == 0 or a[tow[0]][tow[1]] != '.':\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n print('!',end ='')\n else:\n print(a[i][j], end='')\n if j == 2 or j == 5 :\n print(' ',end='')\n print()\n if i == 2 or i == 5:\n print()\n\n \n\nelse:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.' and i >= kek[0] and i <= kek[1] and j >= kek[2] and j <=kek[3] :\n print('!',end ='')\n else:\n print(a[i][j], end='')\n if j == 2 or j == 5 :\n print(' ',end='')\n print()\n if i == 2 or i == 5:\n print()\n \n"}, {"source_code": "A=[]\nfor i in range(11):\n A.append(input())\nB=[]\nfor i in A:\n if i!='':\n B.append([i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10],])\nprint(B)\nxd=list(map(int,input().split()))\nx=xd[0]\ny=xd[1]\nchanged=False\nif x in [1,4,7]:\n if y in [1,4,7]:\n for i in range(3):\n for j in range(3):\n if B[i][j]=='.':\n B[i][j]='!'\n changed=True\n elif y in [2,5,8]:\n for i in range(3):\n for j in range(3,6):\n if B[i][j]=='.':\n B[i][j]='!' \n changed=True \n else:\n for i in range(3):\n for j in range(6,9):\n if B[i][j]=='.':\n B[i][j]='!' \n changed=True \nelif x in [2,5,8]:\n if y in [1,4,7]:\n for i in range(3,6):\n for j in range(3):\n if B[i][j]=='.':\n B[i][j]='!'\n changed=True\n elif y in [2,5,8]:\n for i in range(3,6):\n for j in range(3,6):\n if B[i][j]=='.':\n B[i][j]='!' \n changed=True\n else:\n for i in range(3,6):\n for j in range(6,9):\n if B[i][j]=='.':\n B[i][j]='!' \n changed=True\nelse:\n if y in [1,4,7]:\n for i in range(6,9):\n for j in range(3):\n if B[i][j]=='.':\n B[i][j]='!'\n changed=True\n elif y in [2,5,8]:\n for i in range(6,9):\n for j in range(3,6):\n if B[i][j]=='.':\n B[i][j]='!' \n changed=True \n else:\n for i in range(6,9):\n for j in range(6,9):\n if B[i][j]=='.':\n B[i][j]='!' \n changed=True\nif not changed:\n for i in range(9):\n for j in range(9):\n if B[i][j]=='.':\n B[i][j]='!' \nfor i in range(9):\n if i==3 or i==6:\n print('')\n print(B[i][0]+B[i][1]+B[i][2]+' '+B[i][3]+B[i][4]+B[i][5]+' '+B[i][6]+B[i][7]+B[i][8])"}, {"source_code": "a=[]\nfor i in range(11):\n b=[]\n s=input().split()\n if not s:\n continue\n for k in s:\n for i in range(3):\n b.append(k[i])\n a.append(b)\nx,y=map(int,input().split())\nx=(x-1)%3\ny=(y-1)%3\nfl=False\nfor i in range(x,x+3):\n for j in range(y,y+3):\n if a[i][j]=='.':\n a[i][j]='!'\n fl=True\nif not fl:\n for i in range(9):\n for j in range(9):\n if a[i][j]=='.':\n a[i][j]='!'\nfor i in range(3):\n for j in range(3):\n for k in range(3):\n for c in range(3):\n print(a[i*3+j][k*3+c],end='')\n print(' ',end='')\n print()\n print()\n"}, {"source_code": "g = [[],[],[],[],[],[],[],[],[]]\nfor i in range(3):\n s = input().split()\n g[0].append((' '.join(j for j in s[0])).split())\n g[1].append((' '.join(j for j in s[1])).split())\n g[2].append((' '.join(j for j in s[2])).split())\nla = input()\nfor i in range(3):\n s = input().split()\n g[3].append((' '.join(j for j in s[0])).split())\n g[4].append((' '.join(j for j in s[1])).split())\n g[5].append((' '.join(j for j in s[2])).split()) \nla = input()\nfor i in range(3):\n s = input().split()\n g[6].append((' '.join(j for j in s[0])).split())\n g[7].append((' '.join(j for j in s[1])).split())\n g[8].append((' '.join(j for j in s[2])).split()) \nz = input().split()\nz[0] = int(z[0])\nz[1] = int(z[1])\nz[0]%=3\nz[1]%=3\nx = z[0]\ny = z[1]\nref = 0\nif x==1 and y == 1:\n ref = 0\nif x==1 and y == 2:\n ref = 1\nif x==1 and y == 0:\n ref = 2\n\nif x==2 and y == 1:\n ref = 3\nif x==2 and y == 2:\n ref = 4\nif x==2 and y == 0:\n ref = 5\n \nif x==0 and y == 1:\n ref = 6\nif x==0 and y == 2:\n ref = 7\nif x==0 and y == 0:\n ref = 8\ndef check(g):\n for i in g:\n for j in i:\n if j=='.':\n return True\n return False\nif check(g[ref]):\n for i in range(3):\n for j in range(3):\n if(g[ref][i][j]=='.'):\n g[ref][i][j]= '!'\nelse:\n for i in range(9):\n for j in range(3):\n for k in range(3):\n if(g[i][j][k]=='.'):\n g[i][j][k] = '!'\n\nans = ''\nfor i in range(3):\n for j in range(3):\n ans+=g[i][0][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(3):\n for j in range(3):\n ans+=g[i][1][j]\n ans+=' '\nprint(ans) \nans = ''\nfor i in range(3):\n for j in range(3):\n ans+=g[i][2][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(3,6,1):\n for j in range(3):\n ans+=g[i][0][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(3,6,1):\n for j in range(3):\n ans+=g[i][1][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(3,6,1):\n for j in range(3):\n ans+=g[i][2][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(6,9,1):\n for j in range(3):\n ans+=g[i][0][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(6,9,1):\n for j in range(3):\n ans+=g[i][1][j]\n ans+=' '\nprint(ans)\nans = ''\nfor i in range(6,9,1):\n for j in range(3):\n ans+=g[i][2][j]\n ans+=' '\nprint(ans)"}, {"source_code": "a = [[None] * 9 for i in range(9)]\n\nfor k in range(3):\n for i in range(3):\n sl = input().split()\n for j in range(3):\n for l in range(3):\n a[k * 3 + i][j * 3 + l] = sl[j][l]\n if k != 2:\n tmp = input()\n\nx, y = map(int, input().split())\nx -= 1\ny -= 1\n\nbx = x % 3\nby = y % 3\n\nok = False\nfor i in range(bx * 3, bx * 3 + 3):\n for j in range(by * 3, by * 3 + 3):\n if a[i][j] == '.':\n ok = True\n a[i][j] = '!'\nif not ok:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n a[i][j] = '!'\n\nfor k in range(3):\n for i in range(3):\n for j in range(3):\n for l in range(3):\n print(a[k * 3 + i][j * 3 + l], end=\"\")\n print(\" \", end=\"\")\n print()"}, {"source_code": "table = []\n\nfor i in range(2):\n for j in range(3):\n table.append(list(map(list, input().split())))\n input()\n\nfor i in range(3):\n table.append(list(map(list, input().split())))\n\ny, x = map(int, input().split())\n\nplace = [(x-1)%3, (y-1)%3]\n\nprint(place)\nbool1 = True\n\nfor i in range(place[1]*3, place[1]*3+3):\n for j in range(len(table[i][place[0]])):\n if '.' == table[i][place[0]][j]:\n table[i][place[0]][j] = '!'\n bool1 = False\n\nif bool1:\n for i in range(len(table)):\n for j in range(len(table[i])):\n for k in range(len(table[i][j])):\n if table[i][j][k] == '.' and (y-1 != i or x-1 // 3 != j or x-1 % 3 != k):\n table[i][j][k] = '!'\n\nfor i in range(len(table)):\n for j in table[i]:\n for k in j:\n print(k, end='')\n print(end=' ')\n print()\n if (i+1) % 3 == 0:\n print()"}, {"source_code": "A = []\nfor i in range(11):\n s = input()\n s = s.replace(\" \", \"\")\n if s == \"\":\n continue\n A.append(list(s))\nx, y = map(int, input().split())\nx = (x-1) % 3\ny = (y-1) % 3\nprint(x, y)\nrep = 0\nfor i in range(3):\n for j in range(3):\n if(A[3 * x + i][3 * y + j] == \".\"):\n A[3 * x + i][3 * y + j] = \"!\"\n rep += 1\nif(rep == 0):\n for i in range(9):\n for j in range(9):\n if A[i][j] == \".\":\n A[i][j] = \"!\"\nfor i in range(9):\n A[i] = A[i][0] + A[i][1] + A[i][2] + ' ' + A[i][3] + A[i][4] + A[i][5] + ' ' + A[i][6] + A[i][7] + A[i][8]\n\n# for i in range(9):\n# for j in range(11):\n# print(A[i][j], end = '')\n# print()\n\nfor i in range(0,3):\n print(A[i])\nprint()\n\nfor i in range(3,6):\n print(A[i])\nprint()\n\nfor i in range(6,9):\n print(A[i])\nprint()\n\n"}, {"source_code": "a00=[]\na01=[]\na02=[]\na10=[]\na11=[]\na12=[]\na20=[]\na21=[]\na22=[]\nfor i in range(3):\n q=input().split()\n a00.append(q[0])\n a01.append(q[1])\n a02.append(q[2])\ninput()\nfor i in range(3):\n q=input().split()\n a10.append(q[0])\n a11.append(q[1])\n a12.append(q[2])\ninput()\nfor i in range(3):\n q=input().split()\n a20.append(q[0])\n a21.append(q[1])\n a22.append(q[2])\nx,y=map(int,input().split())\nx,y=(x-1)%3,(y-1)%3\nif x==0 and y==0:\n for i in a00:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==1:\n for i in a01:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==2:\n for i in a02:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==1 and y==0:\n for i in a10:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==1 and y==1:\n for i in a11:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==2:\n for i in a02:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==0:\n for i in a20:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==1:\n for i in a21:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==2:\n for i in a22:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a2[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nfor i in range(3):\n print(a00[i],a01[i],a02[i])\nprint()\nfor i in range(3):\n print(a10[i],a11[i],a12[i])\nprint()\nfor i in range(3):\n print(a20[i],a21[i],a22[i])\n"}, {"source_code": "matrix = []\nmatrix_end = []\narr = []\nfor i in range(11):\n n = input()\n if n != \"\":\n for j in range(11):\n if n[j] != \" \":\n arr.append(n[j])\n matrix.append(arr)\n arr = []\nx,y = map(int,input().split())\nx_b = (x-1) % 3\ny_b = (y-1) % 3\nch = True\nfor i in range(3*x_b, 3*x_b+3):\n for j in range(3*y_b, 3*y_b+3):\n if matrix[i][j] == \".\":\n ch = False\nif ch:\n for i in range(9):\n for j in range(9):\n if matrix[i][j] == \".\":\n matrix[i][j] = \"!\"\nelse:\n for i in range(3*x_b, 3*x_b + 3):\n for j in range(3*y_b, 3*y_b + 3):\n if matrix[i][j] == \".\":\n matrix[i][j] = \"!\"\ns = \"\"\ncnt_x = 0\ncnt_y = 0\nfor j in range(11):\n if j == 3 or j == 7:\n s = \"\\n\"\n cnt_y +=1\n else:\n for i in range(11):\n if i == 3 or i == 7:\n s+=\" \"\n cnt_x+=1\n else:\n s+=matrix[j-cnt_y][i-cnt_x]\n cnt_x = 0\n print(s)\n s = \"\""}, {"source_code": "A = []\nA.append([list(i) for i in list(input().split())])\nA.append([list(i) for i in list(input().split())])\nA.append([list(i) for i in list(input().split())])\na = input()\nA.append([list(i) for i in list(input().split())])\nA.append([list(i) for i in list(input().split())])\nA.append([list(i) for i in list(input().split())])\na = input()\nA.append([list(i) for i in list(input().split())])\nA.append([list(i) for i in list(input().split())])\nA.append([list(i) for i in list(input().split())])\ny, x = list(map(int, input().split()))\ny1 = (y - 1) % 3 * 3\nx1 = (x - 1) % 3\nT = 0\nprint(A[3][0][0])\nfor i in range(y1, y1 + 3):\n for k in range(3):\n print(i,x1,k)\n if A[i][x1][k] == chr(46):\n A[i][x1][k] = chr(33)\n T += 1\nif T == 0:\n for i in range(9):\n for m in range(3):\n for k in range(3):\n if A[i][m][k] == chr(46):\n A[i][m][k] = chr(33)\nprint(''.join(A[0][0]), ' ' , ''.join(A[0][1]), ' ', ''.join(A[0][2]))\nprint(''.join(A[1][0]), ' ' , ''.join(A[1][1]), ' ', ''.join(A[1][2]))\nprint(''.join(A[2][0]), ' ' , ''.join(A[2][1]), ' ', ''.join(A[2][2]))\nprint()\nprint(''.join(A[3][0]), ' ' , ''.join(A[3][1]), ' ', ''.join(A[3][2]))\nprint(''.join(A[4][0]), ' ' , ''.join(A[4][1]), ' ', ''.join(A[4][2]))\nprint(''.join(A[5][0]), ' ' , ''.join(A[5][1]), ' ', ''.join(A[5][2]))\nprint()\nprint(''.join(A[6][0]), ' ' , ''.join(A[6][1]), ' ', ''.join(A[6][2]))\nprint(''.join(A[7][0]), ' ' , ''.join(A[7][1]), ' ', ''.join(A[7][2]))\nprint(''.join(A[8][0]), ' ' , ''.join(A[8][1]), ' ', ''.join(A[8][2]))\nprint()\n \n \n"}, {"source_code": "mat=[input() for _ in range(11)]\nx,y=map(int,input().split())\nx-=1\nx+=x//3\ny-=1\ny=+y//3\na=x%4*4\nb=y%4*4\nr=11\nfor i in range(a,a+3):\n s=mat[i][b:b+3]\n if '.' in s:\n mat[i],r=mat[i][:b]+s.replace('.','!')+mat[i][b+3:],0\nfor i in range(r):\n mat[i]=mat[i].replace('.','!')\nprint(*mat,sep='\\n')"}, {"source_code": "\n\nmat = {}\nfor i in range(9):\n if i == 3 or i == 6: raw_input()\n mat[i+1] = list(''.join(map(str, raw_input().strip().split())))\n\nr, c = map(int, raw_input().split(' '))\n\nif r % 3 == 0: ro = 3 * 3\nelse: ro = r % 3 * 3\n\nif c % 3 == 0: co = 3 * 3\nelse: co = c % 3 * 3\n\nf = 0\nfor i in range(3):\n for j in range(3):\n if (mat[ro-i][co-j-1]=='.'):\n mat[ro-i][co-j-1] = '!'\n f = 1\n\ns = ''\nif f == 0:\n for i in range(9):\n for j in range(9):\n if mat[i+1][j] == '.':\n s = ''.join(s+'!')\n elif mat[i+1][j] == 'x':\n s = ''.join(s+'x')\n elif mat[i+1][j] == 'o':\n s = ''.join(s+'o')\n \n if j == 2 or j == 5:\n s = ''.join(s+' ')\n if i == 2 or i == 5:\n s = ''.join(s+'\\n')\n s = ''.join(s+'\\n')\nelse:\n for i in range(9):\n if i == 3 or i == 6:\n print ''\n print ''.join(mat[i+1])\n\nprint s,\n\n'''\n \no.. ... ...\n... ... ...\n... ... ...\n\n... xxx ...\n... xox ...\n... ooo ...\n\n... ... ...\n... ... ...\n... ... ...\n5 5\n\n\n... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n6 4\n\n... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n\n5 9\n\n'''\n"}, {"source_code": "\nboard=[]\nfor i in range(11):\n s=list(''.join(raw_input().split()))\n if len(s)>0:\n board.append(s)\n\nn,m=map(int, raw_input().split())\n\"\"\"\nboardx=['xoox..x..',\n'ooo......',\n'ooo......',\n'x..x..x..',\n'.........',\n'.........',\n'x..x..x..',\n'.........',\n'.........',]\nn,m=7, 4\n\nboard=[]\nfor i in range(9):\n board.append(list(boardx[i]))\n\"\"\"\n\nn-=1\nm-=1\n\nn%=3\nm%=3\n\nct=0\n\nfor i in range(3*n,3*n+3):\n for j in range(3*m,3*m+3):\n if board[i][j]==\".\":\n ct+=1\n board[i][j]=\"!\"\nif ct==0:\n for i in range(9):\n for j in range(9):\n if board[i][j]==\".\":\n board[i][j]=\"!\"\n\nfor i in range(3):\n st=''.join(board[i])\n print st[0:3]+\" \"+st[3:6]+\" \"+st[6:9]\nprint \"\\n\"\nfor i in range(3,6):\n st=''.join(board[i])\n print st[0:3]+\" \"+st[3:6]+\" \"+st[6:9]\nprint \"\\n\"\nfor i in range(6,9):\n st=''.join(board[i])\n print st[0:3]+\" \"+st[3:6]+\" \"+st[6:9]\n\n\n\n"}, {"source_code": "import sys\n\nfrom itertools import islice\n\ndef read_field():\n return filter(lambda x: x, [\n list(line.rstrip().replace(' ', ''))\n for line in map(lambda _: sys.stdin.readline(), range(11))\n ])\n\nclass SmallFiled:\n def __init__(self, f, x, y):\n self.x = x\n self.y = y\n self.f = f\n\n def coord(self, x, y):\n return 3 * self.x + x, 3 * self.y + y\n\n def __call__(self, x, y):\n return self.get(x, y)\n\n def get(self, x, y):\n i, j = self.coord(x, y)\n return self.f[i][j]\n\n def set(self, x, y, v):\n i, j = self.coord(x, y)\n self.f[i][j] = v\n\ndef is_all_filled(sf):\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n return False\n return True\n\ndef mark_all_empty(bf):\n for i in range(9):\n for j in range(9):\n if bf[i][j] == '.':\n bf[i][j] = '!'\n return bf\n\ndef find_move(fs, bf, x, y, xx, yy):\n sf = fs[x][y]\n x, y = sf.coord(0, 0)\n sf = fs[xx - x][yy - y]\n if is_all_filled(sf):\n return mark_all_empty(bf)\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n sf.set(i, j, '!')\n return bf\n\n\ndef print_filed(bf):\n for i in range(9):\n for j in range(9):\n print bf[i][j],\n if j == 2 or j == 5:\n print ' ',\n print\n if i == 2 or i == 5:\n print\n\n\nbig_field = read_field()\nfields = [\n [\n SmallFiled(big_field, i, j)\n for j in range(3)\n ]\n for i in range(3)\n]\n\n# from pprint import pprint\n# pprint(big_field)\ny, x = map(int, sys.stdin.readline().split())\nx -= 1\ny -= 1\n\n#fields[2][1].set(0, 0, '?')\n\nres = find_move(fields, big_field, x / 3, y / 3, x, y)\nprint_filed(res)\n"}, {"source_code": "import sys\n\nfrom itertools import islice\n\ndef read_field():\n return filter(lambda x: x, [\n list(line.rstrip().replace(' ', ''))\n for line in map(lambda _: sys.stdin.readline(), range(11))\n ])\n\nclass SmallFiled:\n def __init__(self, f, x, y):\n self.x = x\n self.y = y\n self.f = f\n\n def coord(self, x, y):\n return 3 * self.x + x, 3 * self.y + y\n\n def __call__(self, x, y):\n return self.get(x, y)\n\n def get(self, x, y):\n i, j = self.coord(x, y)\n return self.f[i][j]\n\n def set(self, x, y, v):\n i, j = self.coord(x, y)\n self.f[i][j] = v\n\ndef is_all_filled(sf):\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n return False\n return True\n\ndef mark_all_empty(bf):\n for i in range(9):\n for j in range(9):\n if bf[i][j] == '.':\n bf[i][j] = '!'\n return bf\n\ndef find_move(fs, bf, x, y, xx, yy):\n sf = fs[x][y]\n x, y = sf.coord(0, 0)\n sf = fs[xx - x][yy - y]\n if is_all_filled(sf):\n return mark_all_empty(bf)\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n sf.set(i, j, '!')\n return bf\n\n\ndef print_filed(bf):\n for i in range(9):\n for j in range(9):\n print bf[i][j],\n if j == 2 or j == 5:\n print ' ',\n print\n if i == 2 or i == 5:\n print\n\n\nbig_field = read_field()\nfields = [\n [\n SmallFiled(big_field, i, j)\n for j in range(3)\n ]\n for i in range(3)\n]\n\n# from pprint import pprint\n# pprint(big_field)\nx, y = map(int, sys.stdin.readline().split())\nx -= 1\ny -= 1\n\n#fields[2][1].set(0, 0, '?')\n\nres = find_move(fields, big_field, x / 3, y / 3, x, y)\nprint_filed(res)\n"}, {"source_code": "import sys\n\nfrom itertools import islice\n\ndef read_field():\n return filter(lambda x: x, [\n list(line.rstrip().replace(' ', ''))\n for line in map(lambda _: sys.stdin.readline(), range(11))\n ])\n\nclass SmallFiled:\n def __init__(self, f, x, y):\n self.x = x\n self.y = y\n self.f = f\n\n def coord(self, x, y):\n return 3 * self.x + x, 3 * self.y + y\n\n def __call__(self, x, y):\n return self.get(x, y)\n\n def get(self, x, y):\n i, j = self.coord(x, y)\n return self.f[i][j]\n\n def set(self, x, y, v):\n i, j = self.coord(x, y)\n self.f[i][j] = v\n\ndef is_all_filled(sf):\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n return False\n return True\n\ndef mark_all_empty(bf):\n for i in range(9):\n for j in range(9):\n if bf[i][j] == '.':\n bf[i][j] = '!'\n return bf\n\ndef find_move(fs, bf, x, y, xx, yy):\n print x, y, xx, yy\n sf = fs[x][y]\n x, y = sf.coord(0, 0)\n sf = fs[xx - x][yy - y]\n if is_all_filled(sf):\n return mark_all_empty(bf)\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n sf.set(i, j, '!')\n return bf\n\n\ndef print_filed(bf):\n for i in range(9):\n for j in range(9):\n print bf[i][j],\n if j == 2 or j == 5:\n print ' ',\n print\n if i == 2 or i == 5:\n print\n\n\nbig_field = read_field()\nfields = [\n [\n SmallFiled(big_field, i, j)\n for j in range(3)\n ]\n for i in range(3)\n]\n\n# from pprint import pprint\n# pprint(big_field)\ny, x = map(int, sys.stdin.readline().split())\nx -= 1\ny -= 1\n\n#fields[2][1].set(0, 0, '?')\n\nres = find_move(fields, big_field, x / 3, y / 3, x, y)\nprint_filed(res)\n"}, {"source_code": "import sys\n\nfrom itertools import islice\n\ndef read_field():\n return filter(lambda x: x, [\n list(line.rstrip().replace(' ', ''))\n for line in map(lambda _: sys.stdin.readline(), range(11))\n ])\n\nclass SmallFiled:\n def __init__(self, f, x, y):\n self.x = x\n self.y = y\n self.f = f\n\n def coord(self, x, y):\n return 3 * self.x + x, 3 * self.y + y\n\n def __call__(self, x, y):\n return self.get(x, y)\n\n def get(self, x, y):\n i, j = self.coord(x, y)\n return self.f[i][j]\n\n def set(self, x, y, v):\n i, j = self.coord(x, y)\n self.f[i][j] = v\n\ndef is_all_filled(sf):\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n return False\n return True\n\ndef mark_all_empty(bf):\n for i in range(9):\n for j in range(9):\n if bf[i][j] == '.':\n bf[i][j] = '!'\n return bf\n\ndef find_move(fs, bf, x, y, xx, yy):\n print x, y, xx, yy\n sf = fs[x][y]\n x, y = sf.coord(0, 0)\n sf = fs[xx - x][yy - y]\n if is_all_filled(sf):\n return mark_all_empty(bf)\n for i in range(3):\n for j in range(3):\n if sf(i, j) == '.':\n sf.set(i, j, '!')\n return bf\n\n\ndef print_filed(bf):\n for i in range(9):\n for j in range(9):\n print bf[i][j],\n if j == 2 or j == 5:\n print ' ',\n print\n if i == 2 or i == 5:\n print\n\n\nbig_field = read_field()\nfields = [\n [\n SmallFiled(big_field, i, j)\n for j in range(3)\n ]\n for i in range(3)\n]\n\n# from pprint import pprint\n# pprint(big_field)\nx, y = map(int, sys.stdin.readline().split())\nx -= 1\ny -= 1\n\n#fields[2][1].set(0, 0, '?')\n\nres = find_move(fields, big_field, x / 3, y / 3, x, y)\nprint_filed(res)\n"}, {"source_code": "l=[]\nfor i in range(11):\n s=input()\n s=s.replace(' ','')\n if i!=3 and i!=7:\n l.append(s)\ny,x=map(int, input().split())\nx-=1\ny-=1\nt=False\nprint(y%3*3,y%3*3+2)\nprint(x%3*3,x%3*3+2)\nfor i in range(y%3*3,y%3*3+3):\n for j in range(x%3*3,x%3*3+3):\n if l[i][j]=='.':\n t=True\n break\n if t:\n break\nelse:\n for i in range(9):\n for j in range(9):\n if l[i][j]=='.':\n print('!', end='')\n else:\n print(l[i][j],end='')\n if j%3==2:\n print(end=' ')\n print()\n if i%3==2:\n print()\nif t:\n for i in range(9):\n for j in range(9):\n if l[i][j]=='.' and y%3*3<=i<=y%3*3+2 and x%3*3<=j<=x%3*3+2:\n print('!', end='')\n else:\n print(l[i][j],end='')\n if j%3==2:\n print(end=' ')\n print()\n if i%3==2:\n print()\n"}, {"source_code": "grid = []\ngrid2 = []\nfor i in range(3):\n\ts = list(input().split())\n\tgrid.append(s)\n\ts = \"\".join(s)\n\tgrid2.append(s)\n\ns = input()\nfor i in range(3):\n\ts = list(input().split())\n\tgrid.append(s)\n\ts = \"\".join(s)\n\tgrid2.append(s)\n\ns = input()\nfor i in range(3):\n\ts = list(input().split())\n\tgrid.append(s)\n\ts = \"\".join(s)\n\tgrid2.append(s)\n\na,b = map(int,input().split())\n\nif (a)%3==0:\n\tx = 3\nelif (a)%3==1:\n\tx = 1 \nelse:\n\tx = 2\n\nif (b)%3==0:\n\ty = 3\nelif (b)%3==1:\n\ty = 1 \nelse:\n\ty = 2\n\nflag = 0\nprint(x,y)\nfor i in range(3*(x-1),3*(x-1)+3):\n\tfor j in range(3*(y-1),3*(y-1)+3):\n\t\tif grid2[i][j] =='.':\n\t\t\tflag = 1\n\nif not flag:\n\tfor i in range(9):\n\t\tli = list(grid2[i])\n\t\tfor j in range(9):\n\t\t\tif grid2[i][j]=='.':\n\t\t\t\tli[j] = '!'\n\t\tgrid2[i] = \"\".join(li)\n\tfor i in range(9):\n\t\tprint(grid2[i][:3]+\" \"+grid2[i][3:6]+\" \"+grid2[i][6:])\n\t\tif (i+1)%3==0:\n\t\t\tprint()\nelse:\n\tfor i in range(9):\n\t\tli = list(grid2[i])\n\t\tfor j in range(9):\n\t\t\tif 3*(x-1)<=i<=3*(x-1)+2 and 3*(y-1)<=j<=3*(y-1)+2:\n\t\t\t\tif grid2[i][j]=='.' :\n\t\t\t\t\tli[j] = '!'\n\t\tgrid2[i] = \"\".join(li)\n\tfor i in range(9):\n\t\tprint(grid2[i][:3]+\" \"+grid2[i][3:6]+\" \"+grid2[i][6:])\n\t\tif (i+1)%3==0:\n\t\t\tprint()\n"}, {"source_code": "m = []\nfor i in range(11):\n s = input().split()\n if i == 3 or i == 7:\n continue\n m += [s]\nmatrix = []\nfor i in m:\n cur = \"\"\n for j in i:\n cur += j\n matrix.append(cur)\nfor i in range(9):\n matrix[i] = list(matrix[i])\n[print(*i) for i in matrix]\nx, y = map(int, input().split())\nx -= 1\ny -= 1\nfield = [x % 3, y % 3]\ncnt = 0\nfor i in range(field[0] * 3, field[0] * 3 + 3):\n for j in range(field[1] * 3, field[1] * 3 + 3):\n cnt += (matrix[i][j] == \".\")\nif cnt == 0:\n for i in range(9):\n for j in range(9):\n if matrix[i][j] == \".\":\n matrix[i][j] = \"!\"\nelse:\n for i in range(field[0] * 3, field[0] * 3 + 3):\n for j in range(field[1] * 3, field[1] * 3 + 3):\n if matrix[i][j] == \".\":\n matrix[i][j] = \"!\"\nfor i in range(9):\n for j in range(9):\n if j == 2 or j == 5:\n print(matrix[i][j], end=\" \")\n else:\n print(matrix[i][j], end=\"\")\n print()\n if i == 2 or i == 5:\n print()"}, {"source_code": "def main():\n\tarr = [ ]\n\tfor i in range(11):\n\t\tif i==3 or i==7:\n\t\t\tstr(input())\n\t\telse:\n\t\t\tarr.append(list(str(input()).replace(\" \",\"\")))\n\tx,y = map(int,input().split())\n\txreg = (x-1)%3\n\tyreg = (y-1)%3\n\tflag = True\n\tfor i in range((xreg*3),((xreg+1)*(3))):\n\t\tfor j in range( (yreg*3),((yreg+1)*(3)) ):\n\t\t\tif arr[i][j]!='.':\n\t\t\t\tflag = False\n\t\t\t\tbreak\n\tif flag:\n\t\tfor i in range((xreg*3),((xreg+1)*(3))):\n\t\t\tfor j in range( (yreg*3),((yreg+1)*(3)) ):\n\t\t\t\tif arr[i][j]=='.':\n\t\t\t\t\tarr[i][j]='!'\n\telse:\n\t\tfor i in range(len(arr)):\n\t\t\tfor j in range(len(arr[i])):\n\t\t\t\tif arr[i][j]=='.':\n\t\t\t\t\tarr[i][j]='!'\n\tfor i in range(9):\n\t\tif i==3 or i==6:\n\t\t\tprint()\n\t\tfor j in range(3):\n\t\t\tstring = ''.join(arr[i][(j*3):((j+1)*(3))])\n\t\t\tprint(string ,end=' ')\n\t\tprint()\n\nmain()"}, {"source_code": "def main():\n\tarr = [ ]\n\tfor i in range(11):\n\t\tif i==3 or i==7:\n\t\t\tstr(input())\n\t\telse:\n\t\t\tarr.append(list(str(input()).replace(\" \",\"\")))\n\tx,y = map(int,input().split())\n\txreg = (x-1)%3\n\tyreg = (y-1)%3\n\tflag = True\n\tfor i in range((xreg*3),((xreg+1)*(3))):\n\t\tfor j in range( (yreg*3),((yreg+1)*(3)) ):\n\t\t\tif arr[i][j]!='.':\n\t\t\t\tflag = False\n\t\t\t\tbreak\n\tif flag:\n\t\tfor i in range((xreg*3),((xreg+1)*(3))):\n\t\t\tfor j in range( (yreg*3),((yreg+1)*(3)) ):\n\t\t\t\tif arr[i][j]=='.':\n\t\t\t\t\tarr[i][j]='!'\n\telse:\n\t\tfor i in range(len(arr)):\n\t\t\tfor j in range(len(arr[i])):\n\t\t\t\tif arr[i][j]=='.':\n\t\t\t\t\tarr[i][j]='!'\n\tfor i in range(9):\n\t\tif i==3 or i==7:\n\t\t\tprint()\n\t\tfor j in range(3):\n\t\t\tstring = ''.join(arr[i][(j*3):((j+1)*(3))])\n\t\t\tprint(string ,end=' ')\n\t\tprint()\n\nmain()"}, {"source_code": "arr = []\nfor i in range(11):\n row = input()\n if row != '':\n arr.append(list(row.replace(' ','')))\n\ncoord = [int(x) for x in input().split(' ')]\nsubsquare = [coord[0]-(coord[0]-1)//3*3, coord[1]-(coord[1]-1)//3*3]\nprint(subsquare)\n\nblocked = True\n\nfor i in range(3*subsquare[0]-3, 3*subsquare[0]):\n for j in range(3*subsquare[1]-3, 3*subsquare[1]):\n if arr[i][j] == '.':\n blocked = False\n arr[i][j] = '!'\n\nif blocked:\n for i in range(9):\n for j in range(9):\n if arr[i][j] == '.':\n blocked = False\n arr[i][j] = '!'\n\nfor row in arr:\n row.insert(6,' ')\n row.insert(3,' ')\n\narr.insert(6,[' '])\narr.insert(3,[' '])\n\nprint('\\n'.join([''.join(x) for x in arr]))\n"}, {"source_code": "a = [0] * 9\nj = 0\nfor i in range(11):\n if i == 3 or i == 7:\n w = input()\n continue\n a[j] = list(''.join(input().split()))\n j += 1\n\nx, y = map(int, input().split())\nx -= 1\ny -= 1\nx %= 3\ny %= 3\n\nif x == 1:\n x = 3\nelif x == 2:\n x = 6\n\nif y == 1:\n y = 3\nelif y == 2:\n y = 6\n\nflag = True\nfor i in range(x, x + 3):\n for j in range(y, y + 3):\n if a[i][j] == '.':\n flag = False\n a[i][j] = '!'\n\nfor i in range(9):\n if i % 3 == 0:\n print('')\n for j in range(9):\n if j % 3 == 0:\n print(' ', end='') \n if flag and a[i][j] == '.':\n print('!', end='')\n else:\n print(a[i][j], end='')\n print('')\n"}, {"source_code": "s = []\nq = []\nS = []\ns.append(input().split())\ns.append(input().split())\ns.append(input().split())\nq.append(input().split())\ns.append(input().split())\ns.append(input().split())\ns.append(input().split())\nq.append(input().split())\ns.append(input().split())\ns.append(input().split())\ns.append(input().split())\n\nx, y = list(map(lambda x : int(x), input().split()))\n\nX = x % 3\nif x % 3 == 0:\n X += 1\n\nY = y % 3\nif y % 3 == 0:\n Y += 1\n\nss = list(map(lambda x: ''.join(x), s[(X-1)*3:X*3]))\n\nqwe = []\nss = [ss[0][(Y-1)*3:Y*3]] + [ss[1][(Y-1)*3:Y*3]] + [ss[2][(Y-1)*3:Y*3]]\nfor i in range(3):\n for j in range(3):\n qwe.append((i * X, j * Y))\nm = False\nss_new = []\n\nfor i, el in enumerate(ss):\n if '.' in el:\n m = True\n ss_new.append(el.replace('.', '!'))\nsch = 0\nif not m:\n for el in s:\n for ell in el[:-1]:\n print(ell.replace('.', '!'), end = ' ')\n print(el[-1])\n sch += 1\n if sch % 3 == 0 and sch != 9:\n print()\n\nelse:\n s_new = []\n sch_str = 0\n for el in s:\n s_new.append(''.join(el))\n for i in range(len(s_new)):\n sch_tab = 0\n for j in range(len(s_new[i])):\n if (i, j) in qwe:\n print(ss_new[i%3][j%3], end = '')\n pass\n else:\n print(s_new[i][j], end = '')\n pass\n sch_tab += 1\n if sch_tab % 3 == 0 and sch_tab != 9:\n print(' ', end = '')\n print()\n sch_str += 1\n if sch_str % 3 == 0 and sch_str != 9:\n print()\n"}, {"source_code": "p = [[[],[],[]],[[],[],[]],[[],[],[]]]\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][0].append(a)\n p[1][0].append(b)\n p[2][0].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][1].append(a)\n p[1][1].append(b)\n p[2][1].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][2].append(a)\n p[1][2].append(b)\n p[2][2].append(c)\nx,y = map(int,(input().split()))\n\ndef okr(a):\n d=a//3\n if a%3>0:\n d+=1\n return(d)\nx-=1\ny-=1\nxm = (x)//3\nym = (y)//3\nxg=(x-xm*3)\nyg=(y-ym*3)\n\ns=''\ns += p[yg][xg][0]\ns+=p[yg][xg][1]\ns+=p[yg][xg][2]\n\nif '.' in s:\n \n for i in range(3):\n z = ''\n for j in p[yg][xg][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yg][xg][i]=z\nelse:\n for yn in range(3):\n for xn in range(3):\n for i in range(3):\n z = ''\n for j in p[yn][xn][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yn][xn][i]=z\n \n \nfor i in range(3):\n print(p[0][0][i],' ',p[1][0][i],' ',p[2][0][i])\nprint()\nfor i in range(3):\n print(p[0][1][2-i],' ',p[1][1][i],' ',p[2][1][i])\nprint()\nfor i in range(3):\n print(p[0][2][i],' ',p[1][2][i],' ',p[2][2][i])\nprint()\n \n"}, {"source_code": "p = [[[],[],[]],[[],[],[]],[[],[],[]]]\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][0].append(a)\n p[1][0].append(b)\n p[2][0].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][1].append(a)\n p[1][1].append(b)\n p[2][1].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][2].append(a)\n p[1][2].append(b)\n p[2][2].append(c)\nx,y = map(int,(input().split()))\n\ndef okr(a):\n d=a//3\n if a%3>0:\n d+=1\n return(d)\nx-=1\ny-=1\nxm = (x)//3\nym = (y)//3\nxg=(x-xm*3)\nyg=(y-ym*3)\n\ns=''\ns += p[yg][xg][0]\ns+=p[yg][xg][1]\ns+=p[yg][xg][2]\n\nif '.' in s:\n \n for i in range(3):\n z = ''\n for j in p[yg][xg][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yg][xg][i]=z\nelse:\n for yn in range(3):\n for xn in range(3):\n for i in range(3):\n z = ''\n for j in p[yn][xn][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yn][xn][i]=z\n \n \nfor i in range(3):\n print(p[0][0][2-i],' ',p[1][0][2-i],' ',p[2][0][2-i])\nprint()\nfor i in range(3):\n print(p[0][1][2-i],' ',p[1][1][2-i],' ',p[2][1][2-i])\nprint()\nfor i in range(3):\n print(p[0][2][2-i],' ',p[1][2][2-i],' ',p[2][2][2-i])\nprint()\n \n\n \n "}, {"source_code": "l=[list((input())) for _ in range(11)]\nx,y=map(int, input().split())\nx-=1\nx+=x//3\ny-=1\ny+=y//3\na,b=x%4*4,y%4*4\nf=0\nfor i in range(a,a+3):\n for j in range(b,b+3):\n print(i, j)\n if l[i][j]=='.':\n f=1\n l[i][j]='!'\nif f==0:\n for i in range(11):\n for j in range(len(l[i])):\n if l[i][j]=='.':\n l[i][j]='!'\nfor i in range(11):\n print(''.join(l[i]))\n"}, {"source_code": "l=[list(''.join(s.split())) for s in (input() for _ in range(11)) if s]\nx,y=map(int, input().split())\nx-=1\ny-=1\na,b=x%3*3,y%3*3\nf=0\nfor i in range(a,a+3):\n for j in range(b,b+3):\n if l[i][j]=='.':\n f=1\n l[i][j]='!'\nif f==0:\n for i in range(9):\n for j in range(9):\n if l[i][j]=='.':\n l[i][j]='!'\nfor i in range(0,9,3):\n for j in range(3):\n s=''.join(l[i+j])\n print(' '.join((s[:3],s[3:6],s[6:])))\n \n \n"}, {"source_code": "R=input\ng=[list(R()) for _ in range(11)]\nr,c=map(int,R().split())\nr,c=(r-1)%3*4,(c-1)%3*4\nf='.'\nfor i in range(9):\n s=g[r+i//3]\n if '.'==s[c+i%3]:\n s[c+i%3]=f='!'\nprint(*(''.join(v).replace(f,'!') for v in g))\n"}, {"source_code": "\nbadook = []\nlast = []\nfor i in range(12):\n k = list(input().strip().split())\n if i != 3 and i != 7 and i != 11:\n for p in range(len(k)):\n k[p] = list(k[p])\n badook.append(k)\n elif i == 11:\n last = list(map(int, k))\nfirstindex = (last[0] - 1) % 3\nsecondindex = (last[1] - 1) % 3\nprint(firstindex, secondindex)\ndp = dict()\ndp[0] = [0, 1, 2]\ndp[1] = [3, 4, 5]\ndp[2] = [6, 7, 8]\ncount = 0\nfor garo in dp[firstindex]:\n sero = secondindex\n for key in range(len(badook[garo][sero])):\n if badook[garo][sero][key] == '.':\n count = 1\n badook[garo][sero][key] = '!'\nif count == 0:\n for i in badook:\n for j in i:\n for k in range(len(j)):\n if j[k] == '.':\n j[k] = '!'\n\nfor key in badook:\n print(key)\n\nfor i in range(len(badook)):\n for j in range(len(badook[i])):\n for k in range(len(badook[i][j])):\n print(badook[i][j][k], end = \"\")\n print(end = \" \")\n print()\n if i == 2 or i == 5:\n print()\n"}, {"source_code": "org = []\n\nfor i in range(11):\n if i != 3 and i != 7 :\n row = input().split()\n org.append(row)\n else:\n input()\n\nx, y = input().split()\nx = int(x)%3\ny = int(y)%3\n\nif x == 0:\n x = 3\nif y == 0:\n y = 3\n\ntgt = []\nfor j in range(1,4):\n tgt.append(org[3*x-i][y-1])\n\ntmp = 0\nfor c in tgt:\n for k in range(3):\n if c[k] == '.':\n c[k] == '!'\n tmp += 1\nif tmp != 0 :\n for q in range(1,4):\n org[3 * x - q][y - 1] = tgt[q-1]\n\nif tmp == 0 :\n for p in range(9):\n for l in range(3):\n for b in range(3):\n if org[p][l][b] == '.':\n if b == 0:\n org[p][l]='!' +org[p][l][1:]\n if b == 1 :\n org[p][l] = org[p][l][0]+'!'+org[p][l][2]\n if b == 2 :\n org[p][l] = org[p][l][:2]+'!'\n\nfor v in range(9):\n if v%3==2 :\n sp = ''\n for h in range(3):\n sp += org[v][h]+' '\n print(sp[0:11])\n print()\n else:\n sp = ''\n for u in range(3):\n sp += org[v][u]+' '\n print(sp[0:11])"}, {"source_code": "org = []\n\nfor i in range(11):\n if i != 3 and i != 7 :\n row = input().split()\n org.append(row)\n else:\n input()\n\nx, y = input().split()\nx = int(x)%3\ny = int(y)%3\n\nif x == 0:\n x = 3\nif y == 0:\n y = 3\n\ntgt = []\nfor j in range(1,4):\n tgt.append(org[3*x-i][y-1])\n\ntmp = 0\nfor w in range(3):\n c = tgt[w]\n for k in range(3):\n if c[k] == '.':\n if k == 0:\n c = '!' +c[1:]\n if k == 1 :\n c = c[0] + '!' + c[2]\n if k == 2:\n c = c[:2] + '!'\n tmp += 1\n tgt[w] = c\n\nif tmp != 0 :\n for q in range(1,4):\n org[3 * x - q][y - 1] = tgt[q-1]\n\nif tmp == 0 :\n for p in range(9):\n for l in range(3):\n for b in range(3):\n if org[p][l][b] == '.':\n if b == 0:\n org[p][l]='!' +org[p][l][1:]\n if b == 1 :\n org[p][l] = org[p][l][0]+'!'+org[p][l][2]\n if b == 2 :\n org[p][l] = org[p][l][:2]+'!'\n\nfor v in range(9):\n if v%3==2 :\n sp = ''\n for h in range(3):\n sp += org[v][h]+' '\n print(sp)\n print()\n else:\n sp = ''\n for u in range(3):\n sp += org[v][u]+' '\n print(sp)"}, {"source_code": "org = []\n\nfor i in range(11):\n if i != 3 and i != 7 :\n row = input().split()\n org.append(row)\n else:\n input()\n\nx, y = input().split()\nx = int(x)%3\ny = int(y)%3\n\nif x == 0:\n x = 3\nif y == 0:\n y = 3\n\ntgt = []\nfor j in range(1,4):\n tgt.append(org[3*x-i][y-1])\n\ntmp = 0\nfor c in tgt:\n for k in range(3):\n if c[k] == '.':\n c[k] == '!'\n tmp += 1\nif tmp != 0 :\n for q in range(1,4):\n org[3 * x - q][y - 1] = tgt[q-1]\n\nif tmp == 0 :\n for p in range(9):\n for l in range(3):\n for b in range(3):\n if org[p][l][b] == '.':\n if b == 0:\n org[p][l]='!' +org[p][l][1:]\n if b == 1 :\n org[p][l] = org[p][l][0]+'!'+org[p][l][2]\n if b == 2 :\n org[p][l] = org[p][l][:2]+'!'\n\nfor v in range(9):\n if v%3==2 :\n sp = ''\n for h in range(3):\n sp += org[v][h]+' '\n print(sp)\n print()\n else:\n sp = ''\n for u in range(3):\n sp += org[v][u]+' '\n print(sp)"}, {"source_code": "grid=[]\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input().split(\" \")\nx = int(inp[0])\ny = int(inp[1])\nxn = x%3\nyn=y%3\nxn -=1\nyn-=1\ncheck = False\nfor i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n check = True\n break\n if check:\n break\nif check:\n for i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n grid[3*xn+i]=grid[3*xn+i][:3*yn+j]+\"!\"+grid[3*xn+i][3*yn+j+1:]\nelse:\n for i in range(9):\n for j in range(9):\n if i<3*xn+3 and i>=xn*3 and j>=yn*3 and j<3*xn+3:\n continue\n elif grid[i][j]!=\".\":\n continue\n else:\n grid[i]=grid[i][:j]+\"!\"+grid[i][j+1:]\nfor i in range(9):\n if i%3==0 and i!=0:\n print()\n print(grid[i][:3]+\" \"+grid[i][3:6]+\" \"+grid[i][6:])\n"}, {"source_code": "grid=[]\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input().split(\" \")\nx = int(inp[0])\ny = int(inp[1])\nxn = x%3\nyn=y%3\nxn -=1\nyn-=1\nif xn<0:\n xn+=3\nif yn<0:\n yn+=3\ncheck = False\nfor i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n check = True\n break\n if check:\n break\nif check:\n for i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n grid[3*xn+i] = list(grid[3*xn+i])\n grid[3*xn+i][3*yn+j] = \"!\"\n grid[3*xn+i] = \"\".join(grid[3*xn+i])\nelse:\n for i in range(9):\n for j in range(9):\n if i<3*xn+3 and i>=xn*3 and j>=yn*3 and j<3*xn+3:\n continue\n elif grid[i][j]!=\".\":\n continue\n else:\n grid[i] = list(grid[i])\n grid[i][j] = \"!\"\n grid[i] = \"\".join(grid[i])\nfor i in range(9):\n if i%3==0 and i!=0:\n print()\n print(grid[i][:3]+\" \"+grid[i][3:6]+\" \"+grid[i][6:])\n"}, {"source_code": "grid=[]\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input()\nfor i in range(3):\n inp = input()\n inp = inp[:3]+inp[4:7]+inp[8:]\n grid.append(inp)\ninp = input().split(\" \")\nx = int(inp[0])\ny = int(inp[1])\nxn = x%3\nyn=y%3\nxn -=1\nyn-=1\ncheck = False\nfor i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n check = True\n break\n if check:\n break\nif check:\n for i in range(3):\n for j in range(3):\n if grid[3*xn+i][3*yn+j]==\".\":\n grid[3*xn+i] = list(grid[3*xn+i])\n grid[3*xn+i][3*yn+j] = \"!\"\n grid[3*xn+i] = \"\".join(grid[3*xn+i])\nelse:\n for i in range(9):\n for j in range(9):\n if i<3*xn+3 and i>=xn*3 and j>=yn*3 and j<3*xn+3:\n continue\n elif grid[i][j]!=\".\":\n continue\n else:\n grid[i] = list(grid[i])\n grid[i][j] = \"!\"\n grid[i] = \"\".join(grid[i])\nfor i in range(9):\n if i%3==0 and i!=0:\n print()\n print(grid[i][:3]+\" \"+grid[i][3:6]+\" \"+grid[i][6:])\n"}, {"source_code": "a = []\nfor i in range(11):\n inp = input()\n if len(inp) == 0:\n continue\n a.append(list(''.join(inp.split())))\n\nx, y = map(int, input().split())\nx, y = x % 3 - 1, y % 3 - 1\nnp = 0\nsx, xy = x * 3, y * 3\nfor i in range(3):\n for j in range(3):\n if a[sx + i][xy + j] == '.':\n a[sx + i][xy + j] = '!'\n np += 1\nif np == 0:\n sx, xy = 0, 0\n for i in range(9):\n for j in range(9):\n if a[sx + i][xy + j] == '.':\n a[sx + i][xy + j] = '!'\n\nfor i in range(9):\n print(' '.join([''.join(a[i][:3]), ''.join(a[i][3:6]), ''.join(a[i][6:])]))"}, {"source_code": "def main():\n s = \"\"\n for i in range(11):\n tmp = input().split()\n for el in tmp:\n s += el\n\n last = [int(x) for x in input().split()]\n last[0] = last[0] % 3\n last[1] = last[1] % 3\n if (last[0] == 0):\n last[0] += 3\n if (last[1] == 0):\n last[1] += 3\n\n\n mtrx = [[] for i in range(9)]\n k = 0\n for i in range(9):\n for j in range(9):\n if (s[k] == 'x'):\n mtrx[i].append(1)\n elif(s[k] == 'o'):\n mtrx[i].append(2)\n else:\n mtrx[i].append(0)\n k += 1\n flag = True\n for i in range((last[0]-1)*3, (last[0]*3)):\n for j in range((last[1]-1)*3, last[1]*3):\n if (mtrx[i][j] == 0):\n flag = False\n mtrx[i][j] = 3\n\n if (flag):\n for i in range(9):\n for j in range(9):\n if(mtrx[i][j] == 0):\n mtrx[i][j] = 3\n\n res = \"\"\n for i in range(9):\n for j in range(3):\n for v in range(3):\n if(mtrx[i][j*3+v] == 0):\n res += '.'\n elif(mtrx[i][j*3+v] == 1):\n res += 'x'\n elif(mtrx[i][j*3+v] == 2):\n res += 'o'\n else:\n res += '!'\n res += ' '\n res += '\\n'\n\n print(res)\nmain()\n"}, {"source_code": "l=[]\nxnum=0\nfor i in range(11):\n l.append(input())\n if \"x\" in l[i]:\n xnum+=l[i].count(\"x\")\n posx=l[i].index(\"x\")\n posy=i\nx,y=map(int,input().split())\nif xnum==1:\n if posx<4:\n x=posx+1\n elif posx>6:\n x=posx-1\n else:\n x=posx\n if posy<4:\n y=posy+1\n elif posy>6:\n y=posy-1\n else:\n y=posy\nif x>=4 and x<=6:\n x-=3\nelif x>=7:\n x-=6\nif y>=4 and y<=6:\n y-=3\nelif y>=7:\n y-=6\nif x==1:\n p=0\nelif x==2:\n p=4\nelif x==3:\n p=8 \nif y==1:\n p2=0\nelif y==2:\n p2=4\nelif y==3:\n p2=8\ncom=0\nfor i in range(p2,p2+3):\n for j in range(p,p+3):\n if l[i][j]=='.':\n com+=1\nif com==0:\n for i in (0,1,2,4,5,6,8,9,10):\n if i ==4 or i==8:\n print()\n for j in range(11):\n if l[i][j]=='.':\n print(\"!\",end=\"\")\n else:\n print(l[i][j],end=\"\")\n print()\nelse:\n for i in (0,1,2,4,5,6,8,9,10):\n if i==4 or i==8:\n print()\n for j in range(11):\n if i>=p2 and i < p2+3 and j >= p and j < p+3:\n if l[i][j]=='.':\n print(\"!\",end=\"\")\n else:\n print(l[i][j],end=\"\")\n else:\n print(l[i][j],end=\"\")\n print()"}, {"source_code": "#http://codeforces.com/problemset/problem/907/B\n#solved\n\nfild = []\n\nfirst = input().split()\nsecend = input().split()\nthird = input().split()\ninput()\nfourth = input().split()\nfivth = input().split()\nsixth = input().split()\ninput()\nseventh = input().split()\neight = input().split()\nninght = input().split()\nx, y = list(map(int, input().split()))\n\nfild.append(first[0] + secend[0] + third[0])\nfild.append(first[1] + secend[1] + third[1])\nfild.append(first[2] + secend[2] + third[2])\nfild.append(fourth[0] + fivth[0] + sixth[0])\nfild.append(fourth[1] + fivth[1] + sixth[1])\nfild.append(fourth[2] + fivth[2] + sixth[2])\nfild.append(seventh[0] + eight[1] + ninght[2])\nfild.append(seventh[0] + eight[1] + ninght[2])\nfild.append(seventh[0] + eight[1] + ninght[2])\n\ndef where(x, y):\n if x < 4 and y < 4:\n return int((3 * x) - (3 - y))\n elif x < 4 and y < 7:\n return int((3 * x) - (3 - (y - 3)))\n elif x < 4:\n return int((3 * x) - (3 - (y - 6)))\n \n elif x < 7 and y < 4:\n return int((3 * (x - 3)) - (3 - y))\n elif x < 7 and y < 7:\n return int((3 * (x - 3)) - (3 - (y - 3)))\n elif x < 7:\n return int((3 * (x - 3)) - (3 - (y - 6)))\n \n elif y < 4:\n return int((3 * (x - 6)) - (3 - y))\n elif y < 7:\n return int((3 * (x - 6)) - (3 - (y - 3)))\n else:\n return int((3 * (x - 6)) - (3 - (y - 6)))\n\ndef swap(a):\n out = \"\"\n for i in a:\n if i == \".\":\n out += \"!\"\n else:\n out += i\n return out\n\ny_fild = where(x, y) - 1\n\nif fild[y_fild].count(\".\") != 0:\n fild[y_fild] = swap(fild[y_fild])\n\nelse:\n for j in range(9):\n fild[j] = swap(fild[j])\n\n\nprint(fild[0][0:3] + \" \" + fild[1][0:3] + \" \" + fild[2][0:3])\nprint(fild[0][3:6] + \" \" + fild[1][3:6] + \" \" + fild[2][3:6])\nprint(fild[0][6:9] + \" \" + fild[1][6:9] + \" \" + fild[2][6:9])\nprint(\"\")\nprint(fild[3][0:3] + \" \" + fild[4][0:3] + \" \" + fild[5][0:3])\nprint(fild[3][3:6] + \" \" + fild[4][3:6] + \" \" + fild[5][3:6])\nprint(fild[3][6:9] + \" \" + fild[4][6:9] + \" \" + fild[5][6:9])\nprint(\"\")\nprint(fild[6][0:3] + \" \" + fild[7][0:3] + \" \" + fild[8][0:3])\nprint(fild[6][3:6] + \" \" + fild[7][3:6] + \" \" + fild[8][3:6])\nprint(fild[6][6:9] + \" \" + fild[7][6:9] + \" \" + fild[8][6:9]) "}, {"source_code": "a = [\"\"]*11\nfor i in range(11):\n a[i]=list(input())\nx,y = map(int, input().split())\nk=0\nx1=(x-1)%3\ny1=(y-1)%3\nif y1==0:\n y2=2\nif y1==1:\n y2=6\n y1=4\nif y1==2:\n y2=10\n y1=8\nif x1==0:\n x2=2\nif x1==1:\n x2=6\n x1=4\nif x1==2:\n x1=8\n x2=10\nfor i in range(x1,x2+1):\n for j in range(y1,y2+1):\n if a[i][j]==\".\":\n a[i][j]=\"!\"\n k=1\nif k==0:\n for i in range(11):\n for j in range(11):\n if i!=3 and i!=7 and j!=3 and j!=7:\n if a[i][j]==\".\":\n a[i][j]=\"!\"\nfor row in a:\n print(' '.join([str(elem) for elem in row]))\n#\ufffd\ufffd\ufffd\ufffd\ufffd"}, {"source_code": "a = [\"\"]*11\nfor i in range(11):\n a[i]=list(input())\nx,y = map(int, input().split())\nk=0\nx1=(x-1)%3\ny1=(y-1)%3\nif y1==0:\n y2=2\nif y1==1:\n y2=6\n y1=4\nif y1==2:\n y2=10\n y1=8\nif x1==0:\n x2=2\nif x1==1:\n x2=6\n x1=4\nif x1==2:\n x1=8\n x2=10\nfor i in range(x1,x2+1):\n for j in range(y1,y2+1):\n if a[i][j]==\".\":\n a[i][j]=\"!\"\n k=1\nif k==0:\n for i in range(11):\n for j in range(11):\n if i!=3 and i!=7 and j!=3 and j!=7:\n if a[i][j]==\".\":\n a[i][j]=\"!\"\nfor row in a:\n print(' '.join([str(elem) for elem in row]))\nprint()\n#\ufffd\ufffd\ufffd\ufffd\ufffd"}, {"source_code": "l = [ [ [] for i in range(3)] for i in range(3)]\nfor i in range(3):\n for j in range(3):\n tmp = list(map(str, input().split(\" \")))\n for k in range(3):\n l[i][k] += [tmp[k]]\n if(i != 2):\n input()\ny, x = list(map(int, input().split(\" \")))\ny = y-1\nx = x-1\nyy = y%3\nxx = x%3\nf = 0\nfor i in range(3):\n s = list(l[xx][yy][i])\n for j in range(3):\n if(s[j] == \".\"):\n s[j] = \"!\"\n f = 1\n l[xx][yy][i] = \"\".join(s)\n # print(l[xx][yy][i])\nif(f == 0):\n for i in range(3):\n for j in range(3):\n for k in range(3):\n s = list(l[i][j][k])\n for z in range(3):\n if(s[z] == \".\"):\n s[z] = \"!\"\n l[i][j][k] = \"\".join(s)\nfor i in range(3):\n for j in range(3):\n print(l[0][i][j], l[1][i][j], l[2][i][j])\n print()\n"}], "src_uid": "8f0fad22f629332868c39969492264d3"} {"source_code": "import os, sys, math\n\ndef main():\n N = int(raw_input())\n\n a = 1\n sqrt = int(math.sqrt(N))\n for i in range(sqrt, 1, -1):\n if N % i == 0:\n a = i\n break\n\n print a, N/a\n\nmain()\n", "positive_code": [{"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nfrom copy import copy\nn=int(input())\ni=0\nmn=10**10\naopt,bopt=-1,-1\nwhile True:\n i+=1\n if n%i==0:\n b=n//i\n if b-i < mn:\n mn=b-i\n aopt,bopt=copy(i),copy(b)\n if i>n/i:\n break\na=min(aopt,bopt)\nb=max(aopt,bopt)\nprint(a,b)\n"}, {"source_code": "n = int(input())\n\nfor i in range(1,int(n ** .5) + 1):\n if n % i == 0:\n a = i\nprint(a,n // a)"}, {"source_code": "import math\n\nn = input()\nn = int (n)\na = math.sqrt(n)\na = int (a)\nwhile n%a != 0:\n\ta=a-1\nprint a,n/a\n"}, {"source_code": "\ndef main(n):\n x = int(n**0.5)\n while x > 0:\n if n % x == 0:\n return \"%s %s\" % (x, n / x)\n x -= 1\n\nif __name__ == \"__main__\":\n n = int(raw_input())\n print main(n)"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = 1\nans = 1\nwhile True:\n if a*a>n:\n break\n if n%a==0:\n ans = a\n a+=1\nprint ans,n/ans "}, {"source_code": "import math\nx=int(input())\ndef divisorGenerator(n):\n large_divisors = []\n for i in xrange(1, int(math.sqrt(n) + 1)):\n if n % i == 0:\n yield i\n if i*i != n:\n large_divisors.append(n / i)\n for divisor in reversed(large_divisors):\n yield divisor\n\n\na=list(divisorGenerator(x))\naa=len(a)\naaa=len(a)/2\naa=int(aa)\naaa=int(aaa)\nif aa%2==0:\n print a[aaa-1],a[aaa]\nelse:\n print a[aaa],a[aaa]\n"}, {"source_code": "import math\nn = raw_input()\nn = int(n)\nr = int(math.sqrt(n))\nwhile n % r !=0:\n r -= 1\nprint r,n/r"}, {"source_code": "n=input()\nmini=10**9\nfor i in range(1,n+1):\n if n%i==0:\n if n/i>=i and n/i-i<mini:\n mini=n/i-i\n x=i\n y=n/i\nprint x,y\n\n \n"}, {"source_code": "import math\nn = raw_input()\nn = int(n)\n\nsqroot = math.sqrt(n)\n\nfor i in xrange(int(sqroot), 0, -1):\n if(n%i == 0):\n print \"%d %d\" % (i, n/i)\n break"}, {"source_code": "'''|In The Name Of Allah|'''\nn = input()\nv=[]\ndef div(n):\n i=1\n while i*i<=n:\n if n%i==0:\n v.append(n/i)\n v.append(i)\n i+=1\ndiv(n)\nv.sort()\ni,j,dif=0,len(v)-1,10000000\nwhile i<=j:\n if n==v[i]*v[j]:\n if v[j]-v[i]<dif:\n dif=v[j]-v[i]\n l,r=v[i],v[j]\n i+=1\n j-=1\n elif v[i]*v[j]>n:\n j-=1\n else:\n i+=1\nprint l,r"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = 1\nans = 1\nwhile True:\n if a*a>n:\n break\n if n%a==0:\n ans = a\n a+=1\nprint ans,n/ans "}, {"source_code": "\n\nn = int(raw_input())\n\narr = []\narr.append((1, n))\na = n-1\n\nwhile (a > 1):\n if (n%a == 0):\n arr.append((n/a,a))\n a = a - 1\n#print arr\n\nminn = n+1\ni = 0\nminindex = -1\nfor a,b in arr:\n if (minn > abs(a - b)):\n minindex = i\n minn = abs(a-b)\n i += 1\n\na = arr[minindex]\nprint min(a), max(a)"}, {"source_code": "import math\nn = input()\nfes = math.sqrt(n)\nfes = int(fes)\nwhile n%fes>=1:\n fes-=1\nprint fes,n/fes\n \n"}, {"source_code": "x=input()\nmn=1000000\ni=1\nif x==1:\n\tprint \"1 1\"\nelse:\n#print abs(2-3)\n\twhile i < x:\n\t\tif x%i == 0:\n\t\t\ty=(x/i)\n\t\t\tz=x/y\n\t\t#print \"%d %d\"% (z,y)\n\t\t\tif abs(y-z)<mn:\n\t\t\t\tmn=abs(y-z)\n\t\t\t\tif z<y:\n\t\t\t\t\ta=z\n\t\t\t\t\tb=y\n\t\t\t\telse:\n\t\t\t\t\ta=y\n\t\t\t\t\tb=z\n\t\ti=i+1\n\tprint \"%d %d\"% (a,b)\n"}, {"source_code": "n = int(raw_input())\n\nbest = 1\nfor i in range(1, int(n ** 0.5 + 1)):\n if i <= n ** 0.5 and n % i == 0:\n best = i\n\nprint best, n / best\n"}, {"source_code": "\n\nif __name__ == '__main__':\n \n\n n = input()\n\n end = int(n **(1.0/2.0))\n\n i = end \n while i > 0:\n #print \"Trying \", i\n if n % i == 0:\n j = n/i\n\n print i,j\n break\n \n i -= 1\n"}, {"source_code": "# -*- coding:utf-8 -*-\n\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n\n n = input()\n\n s_n = int (n**0.5)\n for i in range(s_n,0,-1):\n if n%i==0:\n print i,n/i\n break\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n"}, {"source_code": "import math\nn = int(input(\"\"))\nfor i in range(int(math.sqrt(n)),0,-1):\n if n % i == 0:\n print i,n/i\n break\n"}, {"source_code": "x = int(raw_input())\nlista = []\nlista2 = []\nlista3 = []\nif(x == 1):\n\tprint(\"1 1\")\nelse:\n\tfor i in range(1,x):\n\t\tif(x%i == 0):\n\t\t\tlista.append(abs(x/i - i))\n\t\t\tlista2.append(x/i)\n\t\t\tlista3.append(i)\n\tz = min(lista)\n\tprint(str(lista3[lista.index(z)])+\" \"+str(lista2[lista.index(z)]))"}, {"source_code": "n = int(raw_input())\nfor i in range (1, n+1):\n j = n/i\n if i*j==n and i <= j:\n CurrA = i\n CurrB = j\n\nprint str(CurrA) + ' ' + str(CurrB)"}, {"source_code": "from sys import stdin, stdout\nn = int(stdin.readline())\n\nfor i in range(int(n ** 0.5), 0, -1):\n if not n % i:\n stdout.write(str(i) + ' ' + str(n // i))\n break"}, {"source_code": "import math\nn=int(raw_input())\np=int(math.sqrt(n))\nfor i in range (p,0,-1) :\n if n%i==0 :\n print i,n/i\n break"}, {"source_code": "import math\n\nn = int(input())\na = int(math.floor(math.sqrt(n)))\nwhile n%a != 0:\n a -= 1\nprint a,n/a"}, {"source_code": "bc = int(raw_input())\nimport sys, math\nbat = 1\nrat = bc\nfor i in xrange(1, int(math.sqrt(bc))+1):\n if bc%i == 0:\n bat= i\n rat= bc/i\n\nprint bat, rat"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\nmina=(0,0)\nmindi=maxint \nn=input() \nif n==1:\n print 1,1\n exit(0)\nfor i in xrange(1,n):\n if n%i==0 and i<=n/i:\n if n/i-i<mindi:\n mindi=n/i-i\n mina=(i,n/i) \nprintBS(mina)"}, {"source_code": "import math\nn = input()\na = int(math.sqrt(n))\nfor i in xrange(a, -1, -1):\n if n % i == 0:\n print i, n / i\n break\n\n"}, {"source_code": "def solution(n):\n i=int(n**(1/2))\n while i>=1:\n \n if n%i==0:\n \n return str(i)+\" \"+str(int(n/i))\n\n i-=1\n\ndef answer():\n n = int(input())\n print(solution(n))\nanswer()"}, {"source_code": "n=int(input())\na=1\nb=n//a\ns=None\nwhile a<=b:\n b=n//a\n if a*b==n and (s==None or s>b-a):\n s=b-a\n aa=a\n bb=b\n a=a+1\nprint(min(aa,bb),max(aa,bb))\n "}, {"source_code": "import math,sys\nn = int(sys.stdin.readline())\ndiv =0\nfor i in xrange(1,int(math.sqrt(n))+1):\n\tif n%i == 0:\n\t\tdiv = i\nprint div,n/div"}, {"source_code": "import math\nn=int(raw_input())\nx=int(math.ceil(n**0.5))\nfor i in range(x,n+1):\n if(n%i==0):\n print n/i,i\n break"}, {"source_code": "#!/usr/bin/env python3\n\n\ndef solve():\n n = int(input())\n last_ok = (1, 1)\n for i in range(1, n):\n if n % i == 0:\n if i > n // i:\n break\n last_ok = (i, n // i)\n return \"{} {}\".format(*last_ok)\n\n\nif __name__ == '__main__':\n print(solve())\n"}, {"source_code": "import math\n#n, k = map(int, raw_input().split())\n\n# CRIVO\nm = 10 ** 6 + 10\neh_primo = [True] * m\neh_primo[0] = False\neh_primo[1] = False\n\nfor i in xrange(int(math.sqrt(m))):\n\n if eh_primo[i]:\n for j in xrange(i * i, m, i):\n eh_primo[j] = False\n\n# ------------\n\nn = int(raw_input())\n\na = int(math.sqrt(n))\nb = int(math.sqrt(n))\n\nif eh_primo[n]:\n print 1,n\n\nelif a * b == n:\n print a, b\n\nelse:\n\n while a > 0 and a * b < n:\n a = a - 1\n\n if a * b != n:\n\n a = int(math.sqrt(n))\n while a * b < n:\n if a * (b+1) > n:\n a = a - 1\n else:\n b = b + 1\n\n print a, b\n"}, {"source_code": "n=input()\nlist1=[]\nlist2=[]\nfor j in xrange(1,n+1):\n if n%j==0:\n if j>=n/j:\n list1.append([j,n/j])\n list2.append(j-n/j)\n\n\nv = min(list2)\n\nfor c in list1:\n if c[0]-c[1]==v:\n print c[1],c[0]"}, {"source_code": "n = input()\na = int(n**0.5)\nwhile 1:\n\tif n%a==0:\n\t\tprint a,n/a\n\t\texit(0)\n\telse:\n\t\ta-=1"}, {"source_code": "import math\nn=int (raw_input())\na = int (math.sqrt (n))\nwhile n%a != 0:\n a-=1\nprint a,n/a\n"}, {"source_code": "import math\nn = int(raw_input())\nmindiff = float('inf')\na = -1 \nb = -1 \nfor i in range(1, int(math.ceil(n**(0.5))) + 1):\n\tcura = i \n\tcurb = n/i\n\tif cura * curb == n and (abs(cura - curb) < mindiff) and cura <= curb:\n\t\tmindiff = abs((cura - curb))\n\t\ta = cura\n\t\tb = curb \nprint a, b"}, {"source_code": "n=int(input())\nk=int(n**0.5)\nwhile n%k!=0:\n k=k-1\nprint(k,n//k)\n "}, {"source_code": "from math import sqrt\nn = input()\nfor a in xrange(int(sqrt(n)), 0, -1):\n if n/a == float(n)/a:\n print a, n/a\n exit()"}, {"source_code": "import math\ndef is_square(n):\n sqrt = math.sqrt(n)\n return (sqrt - int(sqrt)) == 0\n\npixel = int(input())\n\nif is_square(pixel):\n result = (int(math.sqrt(pixel)), int(math.sqrt(pixel)))\nelse:\n lista = []\n for i in range(1, pixel + 1):\n if pixel % i == 0: lista.append(i)\n pivot = int(len(lista) / 2) - 1\n row = lista[pivot]\n column = lista[pivot + 1]\n result = (row, column)\n\nprint(f\"{' '.join(map(str, result))}\")"}, {"source_code": "x = int(raw_input(''))\n# x = 5\n\nmax_num = int(x**(.5))\n\n\nfor counter in range(max_num, 0, -1):\n\tif x % counter == 0:\n\t\tprint counter, (x/counter)\n\t\tbreak\n"}, {"source_code": "n = input()\nsqrtn = int(n**0.5)\nfor i in range(sqrtn, 0, -1):\n if n%i == 0:\n print i, n/i\n break"}, {"source_code": "import math\nn = input()\nsqrtn = int(math.sqrt(n))\nfor i in range(sqrtn, 0, -1):\n if n % i == 0:\n print i, n/i\n break\n"}, {"source_code": "from collections import defaultdict\ndef go():\n\tn = input()\n\tbest=10e9\n\tr = []\n\tfor i in range(1,n+1):\n\t\tif (n%i)==0:\n\t\t\tif abs(n/i - i) <= best:\n\t\t\t\tr = sorted([n/i, i])\n\t\t\t\tbest = abs(n/i-i)\n\n\t\t\t\n\treturn \" \".join(str(i) for i in r)\nprint go()"}, {"source_code": "def display(total):\n tmp = total\n delitel = total\n res = 1\n while delitel >= 1:\n if (total % delitel == 0) & (total / delitel - delitel >= 0) & (total / delitel - delitel < tmp):\n res = delitel\n tmp = total / delitel - delitel\n\n delitel-=1\n else:\n delitel-=1\n return res\n\n\nif __name__ == '__main__':\n total = int(raw_input())\n res = display(total)\n print(str(res) + \" \" + str(total/res)) \n"}, {"source_code": "import math\n\ndef displaysize(n):\n s = int(math.floor(math.sqrt(n))) \n while n % s != 0:\n s -= 1\n return (s,n//s)\n\nif __name__==\"__main__\":\n i = int(input())\n a,b = displaysize(i)\n print(str(a) + \" \" + str(b))\n\n"}, {"source_code": "import math\nnum = input()\nroot = int(math.sqrt(num))\nwhile root > 0:\n if float(num)/float(root) == num/root:\n print root, num/root\n break\n root -= 1\n"}, {"source_code": "a=int(input())\nn=1\nm=a\nfor i in range(1,a//2+1):\n if a%i==0:\n if (i>n and a//i>n) or (i>m and a//i>m):\n n=i\n m=a//i\nprint(n)\nprint(m)\n"}, {"source_code": "n = int(input())\na = 1\nr = 0\nwhile a*a <= n:\n\tif n % a == 0:\n\t\tr = a\n\ta += 1\nprint(r, n//r)"}, {"source_code": "N = int(input())\nDivisors = []\nfor i in range(1, (N // 2) + 2):\n if N % i == 0:\n Divisors.append(i)\n Divisors.append(N // i)\nHalf, Divisors = len(Divisors) // 2, sorted(Divisors)\nprint(Divisors[Half] if len(Divisors) % 2 == 1 else Divisors[Half - 1], Divisors[Half])\n"}, {"source_code": "n=int(input())\nd=n//2\nm=None;k=[]\n\nif n==1:\n\tprint(\"1 1\")\nelse:\n\tfor i in range(1,d+1):\n\t\tif n%i==0:\n\t\t\tp=n//i\n\t\t\tif m is None:\n\t\t\t\tm=p-i\n\t\t\t\tk=[i, p]\n\t\t\telse:\n\t\t\t\tif p-i<m and p-i>=0:\n\t\t\t\t\tm=p-i\n\t\t\t\t\tk=[i, p]\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\tprint(\" \".join(map(str, k)))"}, {"source_code": "# https://codeforces.com/problemset/problem/747/A\nimport math\nn = int(input())\n\na = int(math.sqrt(n))\n\nif a * a == n:\n print(a, a)\nelse:\n for i in range(a+1, 0, -1):\n if n % i == 0:\n print(min(i, n//i), max(i, n//i))\n break\n"}, {"source_code": "a = int(input())\nfor i in range(int((a)**(1/2)),0,-1):\n\tprint\n\tif a%(i) == 0:\n\t\tif i > a//i:\n\t\t\tprint(a//i,i)\n\t\telse:\n\t\t\tprint(i,a//i)\n\t\tbreak\n"}, {"source_code": "from math import sqrt\nn=int(input())\nl=[]\nfor i in range(1,int(sqrt(n))+1):\n\tif n%i==0:\n\t\tl.append(i)\nprint(l[-1],n//l[-1])\n"}, {"source_code": "import math\nn = int(input())\n\ns = math.floor(math.sqrt(n))\nwhile n % s != 0:\n s -= 1\nprint(s,\" \", n // s)"}, {"source_code": "import sys\nnum=sys.stdin.readline()\nnum=int(num)\nfirst=0\nans =0\nsecond = 10**8\nfor i in range (1,num+1):\n if num%i==0:\n first = float(num) / i\n if abs(first-i) < second :\n second = abs(first - i)\n ans=i\n\nprint (int (min(num/ans , ans)) ,int ( max(num/ans ,ans )))\n"}, {"source_code": "n=int(input())\na=int(n**0.5)\nfor i in range(a):\n\tb=n/(a-i)\n\tif b%1==0:\n\t\tprint(a-i,int(b))\n\t\tbreak"}, {"source_code": "n = int(input())\nfor a in range(int(n**0.5),0,-1):\n if n / a == int(n/a):\n print(a,int(n/a))\n break\n \n\n\n\n\n\n\n \n \n \n \n\n \n\n\n\n \n \n \n \n\n\n\n"}, {"source_code": "import math\nn = int(input())\nr = int(math.sqrt(n))\nx=0\ny=0\nfor a in range(1, r+1):\n if n%a == 0:\n x = a\n y = int(n/a)\nprint(str(x)+\" \"+str(y))\n\n"}, {"source_code": "import math\nn=int(input())\na,b=1,n\nfor x in range(1,int(math.sqrt(n))+1):\n\tif n%x==0 and (n//x)-x<(b-a):\n\t\ta,b=x,n//x\nprint(a,b)"}, {"source_code": "pixels = int(input())\nroot = int(pixels**0.5)\nwhile pixels%root != 0:\n root -= 1\nprint(root, pixels//root)"}, {"source_code": "import math\nn = int(input())\nx = int(math.floor(math.sqrt(n)))\nwhile n % x != 0:\n x -= 1\nprint(x, n // x)"}, {"source_code": "import math\nn=int(input())\na=int(math.sqrt(n))\nwhile n%a !=0:\n a=a-1\nprint(a,n//a)"}, {"source_code": "# https://codeforces.com/contest/747/problem/A\n\nn = int(input())\nminDis = n - 1\na = 1\nb = n\n\nfor i in range(2, n):\n\tif i * i > n:\n\t\tbreak\n\tif n % i == 0:\n\t\tif i <= n / i and n /i - i < minDis:\n\t\t\ta = i\n\t\t\tb = n// i\n\t\t\tminDis = b - a\nprint(a,' ',b)\n\n"}, {"source_code": "n = int(input())\nans = list()\nfor i in range(1,n+1):\n if n%i == 0:\n x = int(n/i)\n it = [x,i]\n it.sort()\n ans.append((abs(it[0] - it[1]) , (it[0] , it[1]) ))\n \nans.sort()\nprint(ans[0][1][0] , ans[0][1][1])"}, {"source_code": "n=int(input())\nd={}\nfor i in range(1,n+1):\n if(n%i==0):\n if(i<=n):\n d.update({i:(n//i)})\nk=[abs(d[i]-i) for i in d]\nz=min(k)\nfor i in d:\n if(d[i]-i==z):\n print(i,d[i])\n exit()"}, {"source_code": "n=int(input())\nl=[]\nfor i in range(1,(n//2)+2) :\n if n%i==0 :\n l.append([abs(i-(n//i)),i,n//i])\nv=min(l)\nprint(min(v[1],v[2]),max(v[1],v[2]))\n \n"}, {"source_code": "n = int(input())\ntop = 0\n\nfor i in range(1, int(n**(1/2))+1):\n if n % i == 0:\n top = max((top, i))\n\nprint(top, n//top)\n"}, {"source_code": "n = int(input())\nans = 1\nfor i in range(int(n ** 0.5)+2,0,-1):\n if n % i == 0 and n // i >= i:\n ans = i\n break\nprint(ans, n // ans)\n"}, {"source_code": "from math import*\n#n,k=map(int, input().split())\nn=int(input())\n#l=list(map(int, input().split()))\n#s=input()\nk=int(pow(n,1/2))\nfor i in range(k,0,-1):\n if n%i==0:\n print(i,n//i)\n break"}, {"source_code": "import math\nnum = int(input())\n\ndivisor = list()\nsmallest_dif = [0, 0, num+1]\n\nfor i in range(1,int(math.sqrt(num))+1):\n if(i in divisor):\n continue\n if(num%i == 0 and i <= num/i):\n divisor.append(i)\n divisor.append(num/i)\n if(abs(num/i-i)< smallest_dif[2]):\n smallest_dif[0] = i\n smallest_dif[1] = int(num/i)\n smallest_dif[2] = int(abs(num/i - i))\nprint(str(smallest_dif[0])+ \" \" + str(smallest_dif[1]))\n"}, {"source_code": "n = int(input())\n\ndef getFactors(x):\n\n factors = []\n for i in range(1, int(n**0.5) + 1):\n if x % i == 0:\n factors.append(i)\n \n return factors\n\nf = getFactors(n)\nb = int( n // f[-1])\na = int( n // b)\nprint( a, b)\n\n"}, {"source_code": "v=[]\nn=int(input())\nfor i in range(1,n+1):\n\tif n%i==0:\n\t\tv.append(i)\n# print(v)\nif len(v)%2==0:\n\tprint(v[len(v)//2-1],v[len(v)//2])\nelse:\n\tprint(v[(len(v))//2],v[(len(v))//2])"}, {"source_code": "n=int(input())\nx=int(n**0.5)\ni=x\nwhile i>=1:\n if n%i==0 and n%(n//i)==0:\n print(i,n//i)\n break\n i-=1"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n import math\n\n try:\n while True:\n n = int(input())\n x = int(math.sqrt(n))\n while n % x:\n x -= 1\n print(x, n // x)\n\n except EOFError:\n pass\n\nmain()\n"}, {"source_code": "from math import floor, sqrt\n\n\ndef main():\n n = int(input())\n\n for i in range(floor(sqrt(n)), 0, -1):\n if n % i == 0:\n print(i, n // i)\n break\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nn = int(input())\nr = int(math.sqrt(n))\nwhile True:\n if n%r==0:\n break\n r -= 1\nprint(r,n//r)\n"}, {"source_code": "import sys\nimport math\nimport bisect\nimport itertools\nimport random\nimport re\n\ndef main():\n n = int(input())\n a, b = (1, n)\n for i in range(1, n + 1):\n if n % i == 0 and i <= n // i:\n a, b = (i, n // i)\n print('%d %d' % (a, b))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n=int(input())\na=[]\nfor i in range(1,n+1):\n if(n%i==0):\n a.append(n//i)\nprint((str(a[len(a)//2])) + ' ' + str(n//(a[len(a)//2])))\n"}, {"source_code": "import math\nn=int(input())\na=math.ceil(n/2)\nm=10**10\np=0\nq=0\nfor i in range(1,a+1):\n if n%i==0:\n b=n//i\n c=i\n if abs(b-c)<m:\n m=abs(b-c)\n p=min(b,c)\n q=max(b,c)\nprint(p,q,sep=\" \")"}], "negative_code": [{"source_code": "n = int(input())\nbest = (n, 1)\nfor i in range(1, int(n ** 0.5 + 1)):\n if n %i == 0 and abs(n // i - i) < abs(best[0] - best[1]):\n best = (n // i, i)\nprint(*best)"}, {"source_code": "n=int(input())\na=1\nb=n//a\ns=None\nwhile a<=b:\n b=n//a\n if a*b==n and (s==None or s>b-a):\n s=b-a\n aa=a\n bb=b\n a=a+1\nprint(aa,bb)\n "}, {"source_code": "n = int(input().strip())\nroot = int(n**(0.5))\nprint( str(root) + ' ' + str(int(n/root)))\n"}, {"source_code": "a = int(input())\nll = []\nhh = []\njj = []\nss = []\ngg = []\nsami = 0\nflag = False\nfor i in range(1, a):\n s = a / i\n if s % 1 == 0:\n ll.append(s)\nfor j in range(len(ll)):\n d = a / int(ll[j])\n hh.append(d)\nfor g in range(len(ll)):\n jj.append(int(ll[g])-int(hh[g]))\nprint(jj, ss)\nfor ds in range(len(jj)-1):\n if jj[ds] > jj[ds+1]:\n ss.append(jj[ds+1])\n else:\n ss.append(jj[ds])\nfor sss in range(len(ss)-1):\n if abs(int(ss[sss])) == abs(int(ss[sss+1])):\n for i in range(len(hh)):\n f = abs(int(ss[sss]))\n if f == hh[i]:\n sami = i\ngg.append(hh[sami])\ngg.append(ll[sami])\nfor i in range(len(ll)):\n if hh[i] == ll[i]:\n print(int(hh[i]), int(ll[i]))\n flag = True\nif flag is False:\n for gf in gg: \n print(int(gf), end=\" \")\n"}, {"source_code": "a = int(input())\nll = []\nhh = []\njj = []\nss = []\ngg = []\nsami = 0\nflag = False\nif a == 999999:\n print(\"999 1001\")\nelse:\n for i in range(1, a):\n s = a / i\n if s % 1 == 0:\n ll.append(s)\n for j in range(len(ll)):\n d = a / int(ll[j])\n hh.append(d)\n for g in range(len(ll)):\n jj.append(int(ll[g])-int(hh[g]))\n for ds in range(len(jj)-1):\n if jj[ds] > jj[ds+1]:\n ss.append(jj[ds+1])\n else:\n ss.append(jj[ds])\n for sss in range(len(ss)-1):\n if abs(int(ss[sss])) == abs(int(ss[sss+1])):\n for i in range(len(hh)):\n f = abs(int(ss[sss]))\n if f == hh[i]:\n sami = i\n gg.append(hh[sami])\n gg.append(ll[sami])\n for i in range(len(ll)):\n if hh[i] == ll[i]:\n print(int(hh[i]), int(ll[i]))\n flag = True\n if flag is False:\n for gf in gg: \n print(int(gf), end=\" \")\n"}, {"source_code": "n = int(input())\nr = 1000000000000000000000000\na = 0\nb = 0\nfor i in range(1, (n-1)//2 + 1):\n if n % i == 0 and abs(n//i - i) < r:\n r = abs(n//i - i)\n a = min(n//i, i)\n b = max(n//i, i)\nprint(a, b)"}, {"source_code": "n = int(input())\nr = 1000000000000000000000000\na = 0\nb = 0\nif n == 1:\n print(1, 1)\nelif n == 2:\n print(1, 2)\nelse:\n for i in range(1, (n-1)//2 + 1):\n if n % i == 0 and abs(n//i - i) < r:\n r = abs(n//i - i)\n a = min(n//i, i)\n b = max(n//i, i)\n print(a, b)"}, {"source_code": "n = int(input())\nr = 1000000000000000000000000\na = 0\nb = 0\nif n == 1:\n print(1, 1)\nfor i in range(1, (n-1)//2 + 1):\n if n % i == 0 and abs(n//i - i) < r:\n r = abs(n//i - i)\n a = min(n//i, i)\n b = max(n//i, i)\nprint(a, b)"}, {"source_code": "n = int(input())\nr = 1000000000000000000000000\na = 0\nb = 0\nif n == 1:\n print(1, 1)\nelse:\n for i in range(1, (n-1)//2 + 1):\n if n % i == 0 and abs(n//i - i) < r:\n r = abs(n//i - i)\n a = min(n//i, i)\n b = max(n//i, i)\n print(a, b)"}, {"source_code": "import math\nn=int(input())\n\na=n\nb=1\n\nsq=math.sqrt(n)\nsq=int(sq)\n\nfor i in range (sq, 2, -1):\n if n%i==0:\n a=i\n b=n/i\n break\nb=int(b)\na=int(a)\nprint(a,b)\n"}, {"source_code": "import math\nn=int(input())\n\na=n\nb=1\n\nsq=math.sqrt(n)\nsq=int(sq)\n\nfor i in range (sq+1, 1, -1):\n if n%i==0:\n a=i\n b=n/i\n break\nb=int(b)\na=int(a)\nprint(a,b)\n"}, {"source_code": "import math\nn=int(input())\n\na=1\nb=n\n\nsq=math.sqrt(n)\nsq=int(sq)\n\nfor i in range (sq+1, 1, -1):\n if n%i==0:\n a=i\n b=n/i\n break\nb=int(b)\na=int(a)\nprint(a,b)\n"}, {"source_code": "import math\n\ndef displaysize(n):\n s = int(math.ceil(math.sqrt(n))) + 1\n while n % s != 0:\n s -= 1\n return (s,n//s)\n\nif __name__==\"__main__\":\n i = int(input())\n a,b = displaysize(i)\n print(str(a) + \" \" + str(b))\n\n"}, {"source_code": "n = int(input())\n\nla = 1\na = 1\nlb = n\nb = n\n\nwhile(a <= b):\n a = a + 1\n b = n/a\n\n if(n % a == 0):\n la = a\n lb = n /la\n\n\nprint(la, int(n/la))"}, {"source_code": "n = int(input())\n\nla = 1\na = 1\nlb = n\nb = n\n\nwhile(a <= b):\n a = a + 1\n b = n/a\n\n if(n % a == 0 and n!=2):\n la = a\n lb = n /la\n\n\nprint(la, int(n/la))"}, {"source_code": "n = int(input())\n\na = 1\nb = n\n\nwhile(a <= b):\n a = a + 1\n b = n / a\n\na = a-1\nif(n % a == 0):\n print(a, int(n/a))\nelse:\n print(a -1, int(n/(a-1)))"}, {"source_code": "import math\ndef primenum(x):\n\tcount=0\n\tfor i in range(2,int(math.floor(math.sqrt(x)))+1):\n\t\tif(x%i==0):\n\t\t\tcount=count+1\n\tif(count==0):\n\t\treturn True\n\telse:\n\t\treturn False\n\nn=int(input())\nif(n==1):\n\tprint(1,1)\nelif(primenum(n)==True):\n\tprint(1,n)\t\nelse:\n\ta=[]\n\tfor i in range(2,int(math.ceil(math.sqrt(n))+1)):\n\t\tif(n%i==0):\n\t\t\ta.append(i)\n\tx=a[len(a)-1]\n\tprint(x,n//x)"}, {"source_code": "n=int(input())\nd=n//2\nm=None;k=[]\nfor i in range(1,d+1):\n\tif n%i==0:\n\t\tp=n//i\n\t\tif m is None:\n\t\t\tm=p-i\n\t\t\tk=[i, p]\n\t\telse:\n\t\t\tif p-i<m and p-i>=0:\n\t\t\t\tm=p-i\n\t\t\t\tk=[i, p]\n\t\t\telse:\n\t\t\t\tbreak\nprint(\" \".join(map(str, k)))"}, {"source_code": "# https://codeforces.com/problemset/problem/747/A\nimport math\nn = int(input())\n\na = int(math.sqrt(n))\n\nif a * a == n:\n print(a, a)\nelse:\n for i in range(a+1, 0, -1):\n if n % i == 0:\n print(i, n//i)\n break\n"}, {"source_code": "x = int(input())\nxd=[]\nfor i in range(1, x+1):\n if (x%i == 0 and i <= x/i):\n xd.append([i, x/i])\n \nxd.sort(key = lambda x:x[1]-x[0])\nprint(xd[0][0], xd[0][1]);"}, {"source_code": "# import math\n#\n# def is_prime(a):\n# return all(a % i for i in range(2, a))\n\nfrom math import sqrt,floor; from itertools import count, islice\n\ndef isPrime(n):\n return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))\ndef Main(n):\n # print(isPrime(n))\n\n if isPrime(n) == True:\n print(1, n)\n return\n else:\n f = floor(sqrt(n))\n if f + n//f == n:\n print(f, n//f)\n else:\n\n for i in range(1, n+1):\n if n%i == 0:\n print(i, n//i)\n break\n\n\n\n\n\nif __name__ == '__main__':\n n = int(input())\n Main(n)\n"}, {"source_code": "import sys\nnum=sys.stdin.readline()\nnum=int(num)\nfirst=0\nans =0\nsecond = 10**8\nfor i in range (1,num+1):\n first=float(num)/i\n if first == int(first):\n if abs(first-i) < second :\n second = abs(first - i)\n ans=i\n\nprint (int (max(num/ans , ans)) ,int ( min(num/ans ,ans )))\n"}, {"source_code": "import math\nn = int(input())\nr = math.sqrt(n)\nif r%2 == 0:\n print(str(int(r))+\" \"+str(int(n/r)))\nelse:\n if n%2 == 0:\n print(str(int(r))+\" \"+str(int(n/int(r))))\n else:\n print(str(int(round(r-1)))+\" \"+str(int(n/int(round(r-1)))))\n"}, {"source_code": "n = int(raw_input())\na = 0\nwhile a*a <= n:\n a += 1\n if n%a != 0:\n continue\n best_a, best_b = a, n//a\nprint('%d %d' % (best_a, best_b))\n"}, {"source_code": "n=int(input())\nk=1\ni=2\nwhile k<n:\n while n%i==0 and k<n:\n k=k*i\n n=n//i\n i=i+1\nprint(n,k)"}, {"source_code": "from math import sqrt\nn=int(input())\nq=int(sqrt(n))\nk=t=1\nfor i in range(1,q+1):\n if n%i==0:\n t=i\n k=max(k,t)\nprint(i,n//i)\n \n \n"}, {"source_code": "n=int(input())\nt=[]\ni=2\nwhile n!=1:\n while n%i==0:\n t.append(i)\n n=n//i\n i=i+1\nk=1\nl=1\nfor i in range(len(t)):\n if i%2==0:\n k=k*t[i]\n else:\n l=l*t[i]\na=max(k,l)\nb=min(k,l)\nprint(b,a)\n \n \n"}, {"source_code": "n=int(input())\nk=1\ni=2\nt=True\nwhile t:\n while n%i==0:\n k=k*i\n n=n//i\n if n<k:\n n=n*i\n k=k//i\n t=False\n break\n i=i+1\nprint(k,n)\n"}, {"source_code": "num = int(input())\nroot = num**0.5\nif (root == int(root)):\n print(int(root),int(root))\nelse:\n row = 1\n col = num\n flag = False\n factor = 2\n newcol = num\n newrow = 1\n finalrow = 1\n finalcol = num\n while newrow <= newcol:\n newcol = col/factor\n newrow = row*factor\n if (newcol == int(newcol)) and ((newcol-newrow)<(col-row)):\n finalrow = newrow\n finalcol = newcol\n factor += 1\n print(int(finalrow),int(finalcol))"}, {"source_code": "num = int(input())\nroot = num**0.5\nif (root == int(root)):\n print(int(root),int(root))\nelse:\n row = 1\n col = num\n factor = 2\n newcol = num\n newrow = 1\n finalrow = 1\n finalcol = num\n while newrow <= newcol:\n factor += 1\n if (newcol == int(newcol)) and ((newcol-newrow)<(col-row)):\n finalrow = newrow\n finalcol = newcol\n newcol = col/factor\n newrow = row*factor\n print(int(finalrow),int(finalcol))"}, {"source_code": "n = int(input())\nfor x in range(int(n**0.5), 1, -1):\n if(n % x == 0):\n print(x, n // x)\n break\n"}, {"source_code": "import math\n\nsize = int(input())\n\nsml = 1\n\nfor i in range(math.floor(math.sqrt(size)), 1, -1):\n\tprint(i)\n\tif size % i == 0:\n\t\tsml = i\n\t\tbreak\n\nprint(\"{0} {1}\".format(sml, size//sml))"}, {"source_code": "n = int(input())\na = int(n ** .5)\nprint(a,n // a)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nfrom copy import copy\nn=int(input())\ni=0\nmn=10**10\naopt,bopt=-1,-1\nwhile True:\n i+=1\n if n%i==0:\n b=n//i\n if b-i < mn:\n mn=b-i\n aopt,bopt=copy(i),copy(b)\n if i>n/i:\n break\nprint(aopt,bopt)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nfrom copy import copy\nn=int(input())\ni=0\nmn=10**10\naopt,bopt=-1,-1\nwhile True:\n i+=1\n if n%i==0:\n b=n//i\n if b-i < mn:\n mn=b-i\n aopt,bopt=copy(i),copy(b)\n if i>n/i:\n break\nif n!=2:\n print(aopt,bopt)\nelse:\n print(1,2)"}, {"source_code": "n=input()\nsqrt=int(n**0.5)\nb=1\nfor i in range(sqrt+2,1,-1):\n\tif n%i==0:\n\t\tb=i\n\t\tbreak\na=n/b\nif a>b:\n\ttmp=a\n\ta=b\n\tb=tmp\nprint a, b"}, {"source_code": "\nn = raw_input()\nn = int(n)\nr = 2\nwhile n % r !=0:\n r -= 1\nprint r,n/r"}, {"source_code": "import math\na = input()\nb = math.sqrt(a)\ntemp = a/b\nif int(temp) == temp:\n print b, temp\nelse:\n tem = int(temp)\n while(a%tem != 0):\n tem = tem - 1\n print tem , a/tem"}, {"source_code": "import math\n\nn = int(raw_input())\nsqrt = math.sqrt(n)\n\nif int(sqrt) == sqrt:\n\tsqrt = int(sqrt)\n\tprint sqrt, sqrt\nelse:\n\tsqrt = int(sqrt)+1\n\tfor x in range(sqrt, 0, -1):\n\t\tif n%x == 0:\n\t\t\tif x == 1:\n\t\t\t\tprint 1, n\n\t\t\telse:\n\t\t\t\tprint x, n/x\n\t\t\tbreak\n"}, {"source_code": "import math\n\nn = int(raw_input())\nsqrt = math.sqrt(n)\n\nif int(sqrt) == sqrt:\n\tsqrt = int(sqrt)\n\tprint sqrt, sqrt\nelse:\n\tsqrt = int(sqrt)+1\n\tfor x in range(sqrt, 0, -1):\n\t\tif n%x == 0:\n\t\t\tif x == 1 or x == n:\n\t\t\t\tprint 1, n\n\t\t\telse:\n\t\t\t\tprint x, n/x\n\t\t\tbreak\n"}, {"source_code": "import math\n\nn = int(raw_input())\nsqrt = math.sqrt(n)\n\nif int(sqrt) == sqrt:\n\tsqrt = int(sqrt)\n\tprint sqrt, sqrt\nelse:\n\tsqrt = int(sqrt)+1\n\tfor x in range(sqrt, 0, -1):\n\t\tif n%x == 0:\n\t\t\tprint x, n/x\n\t\t\tbreak\n"}, {"source_code": "from math import sqrt\nn = int(raw_input())\nfor i in xrange(int(sqrt(n)), 1, -1):\n if n / i == float(n) / i:\n print i, n / i\n break\n"}, {"source_code": "a=int(input())\nn=0\nm=0\nfor i in range(1,a//2+1):\n if a%i==0:\n if (i>n and a//i>n) or (i>m and a//i>m):\n n=i\n m=a//i\nprint(n)\nprint(m)\n"}, {"source_code": "a=int(input())\nn=1\nm=1\nfor i in range(1,a//2+1):\n if a%i==0:\n if (i>n and a//i>n) or (i>m and a//i>m):\n n=i\n m=a//i\nprint(n)\nprint(m)\n"}, {"source_code": "a=int(input())\nn=a\nm=1\nfor i in range(1,a//2+1):\n if a%i==0:\n if (i>n and a//i>n) or (i>m and a//i>m):\n n=i\n m=a//i\nprint(n)\nprint(m)\n"}, {"source_code": "import math\n\nnum = int(input())\ns = math.sqrt(num)\ns = int(float(s))\n\nfor i in range (s, 0, -1) :\n\tif num % i == 0 :\n\t\tprint(i)\n\t\tprint(num / i)\t\t\n\t\tbreak\n"}, {"source_code": "import math\n\nnum = int(input(\"Enter the number : \"))\ns = math.sqrt(num)\ns = int(float(s))\n\nfor i in range (s, 0, -1) :\n\tif num % i == 0 :\n\t\tprint(i)\n\t\tprint(num / i)\t\t\n\t\tbreak\n"}, {"source_code": "import math\n\npixels = int(input())\nmid = math.ceil(math.sqrt(pixels))\nfor i in reversed(range(mid + 1)):\n #print(i)\n if pixels % i == 0:\n print(i, pixels// i)\n break\n\n"}, {"source_code": "n = int(input())\nsq = int(n**(1/2))\nfor i in range(sq,1,-1):\n if n%i==0:\n print(i,end=\" \")\n print(n//i)\n exit()\n \n \n"}, {"source_code": "n = int(input())\nres = n//2\n\nprint(res, n-res)\n"}, {"source_code": "import math\nn = int(input())\ni = 1\n\nif((n==2) or (n==3) or ((n*n)%24)==1):\n\ta=1\n\tb=n\nelse:\n\twhile (i<=(n**(0.5))):\n\t\tif ((n%i)==0):\n\t\t\ta=i\n\t\ti=i+1\n\t\tb=n//a\nprint(a,' ',b)\n"}, {"source_code": "from math import sqrt\nn = int(input())\n\nfor i in range(int(sqrt(n)), n+1):\n if i >= sqrt(n) and n % i == 0:\n print(n / i, i)\n break"}, {"source_code": "n=int(input())\nif n==1:\n\tprint(1)\nelse:\n\tk=n\n\ta=0\n\tfor i in range(1,n):\n\t\tif n%i==0:\n\t\t\tt=n//i\n\t\t\tr=abs(t-i)\n\t\t\tif r<k:\n\t\t\t\tk=r\n\t\t\t\ta=i\n\tb=n//a\n\tprint(a,b)"}, {"source_code": "n = int(input())\nc = n**0.5\nif c%1==0:\n\tprint(int(c), int(c))\nelse:\n\tfor i in range(int(c), 1, -1):\n\t\tif n%i==0:\n\t\t\tprint(i, n//i)\n\t\t\texit()"}, {"source_code": "n=int(input())\nr=n**0.5\nif n==3 or n==2 or n==5:\n\tprint(1,n)\nelif n%2==0 or n%3==0 or n%5==0:\n\tfor i in range(4):\n\t\tt=int(r)*(int(r)+i)\n\t\tif t==n:\n\t\t\tprint(int(r),int(r)+i)\n\t\t\tbreak\n"}, {"source_code": "# Display Size\ndef display(p):\n if (p % 2 != 0 and p % 3 != 0 and p % 5 != 0 and p % 7 != 0 and p % 11 != 0 and p % 13 != 0):\n print(1, p)\n return\n for a in range(p, 0, -1):\n b = a \n while True:\n cur = a * b\n if cur > p:\n break\n if cur == p:\n print(a, b)\n return \n b += 1\n\np = int(input())\ndisplay(p)"}, {"source_code": "import math\nn = int(input())\nx = int(math.floor(math.sqrt(n)))\nwhile n % x != 0:\n x += 1\nprint(x, n // x)"}, {"source_code": "def main():\n n = int(input())\n mx = n\n for i in range(1, n//2):\n if n%i == 0 and n//i - i > 0:\n if mx > n//i - i:\n mx = n//i - i\n a = i\n b = n//i\n print(a,b)\n \nmain()"}, {"source_code": "# https://codeforces.com/contest/747/problem/A\n\nn = int(input())\nminDis = n - 1\na = 1\nb = n\n\nfor i in range(2, n):\n\tif i * i > n:\n\t\tbreak\n\tif n % i == 0:\n\t\tif i <= n / i and n /i - i < minDis:\n\t\t\ta = i\n\t\t\tb = n/ i\n\t\t\tminDis = b - a\nprint(a, ' ',b)\n\n"}, {"source_code": "#!/usr/bin/python\nimport math\n\nn = input()\nn = int(n)\n\na = {}\nb = []\nfor i in range (1,math.ceil(n/2) + 1):\n if n % i == 0:\n a[i] = int(n/i)\n\nb = a.keys()\nb = list(b)\n\nl = len(b)\nm = 10000000000000000\nindex = 0\nfor i in range(0,l):\n t = b[i]\n n = abs(t - a[t])\n if n < m:\n index = t\n m = n\n\nprint ('%d %d' %(index,a[index]))\n"}, {"source_code": "n = int(input())\nans = list()\nfor i in range(1,n):\n if n%i == 0:\n x = int(n/i)\n it = [x,i]\n it.sort()\n ans.append((abs(it[0] - it[1]) , (it[0] , it[1]) ))\n \nans.sort()\nprint(ans[0][1][0] , ans[0][1][0])"}, {"source_code": "import time\nn=int(input())\n\nst=time.time()\n\nres=[]\nres1=[]\nfor i in range(1,int(n**0.5)+1):\n a=i\n b=n/i\n if(int(b)==b):\n res.append(int(b-a))\n res1.append([int(a),int(b)])\n\nl=len(res)\nM=min(res)\nfor i in range(l):\n if(res[i]==M):\n for elem in res1[i]:\n print(elem,end=' ')\n\n\net=time.time()\nprint(et-st)\n"}, {"source_code": "n=int(input())\nn=1000000\nk=0\nfor i in range(n) :\n k=k+1\n \n \n"}, {"source_code": "import math\nnum = int(input())\n\ndivisor = list()\nsmallest_dif = [0, 0, num+1]\n\nprint(smallest_dif)\nfor i in range(1,int(math.sqrt(num))+1):\n if(i in divisor):\n continue\n if(num%i == 0 and i <= num/i):\n divisor.append(i)\n divisor.append(num/i)\n if(abs(num/i-i)< smallest_dif[2]):\n smallest_dif[0] = i\n smallest_dif[1] = int(num/i)\n smallest_dif[2] = int(abs(num/i - i))\nprint(smallest_dif)\n"}, {"source_code": "import math\nnum = int(input())\n\ndivisor = list()\nsmallest_dif = [0, 0, num+1]\n\nprint(smallest_dif)\nfor i in range(1,int(math.sqrt(num))+1):\n if(i in divisor):\n continue\n if(num%i == 0):\n divisor.append(i)\n divisor.append(num/i)\n if(abs(num/i-i)< smallest_dif[2]):\n smallest_dif[0] = i\n smallest_dif[1] = int(num/i)\n smallest_dif[2] = int(abs(num/i - i))\nprint(smallest_dif)\n"}, {"source_code": "n=int(input())\na=[]\nb=[]\nfor i in range(1,n+1):\n for j in range(1,n+1):\n if(i*j==n):\n a.append(i)\n b.append(j)\nprint(min(a),min(b)) \n \n \n"}, {"source_code": "import math\n\ndif = 10e10\nbest = 0\nif __name__ =='__main__':\n n = int(raw_input().strip())\n for i in range(1, int(math.sqrt(n))+1):\n if n % i == 0 and (n/i) - i < dif:\n dif = (n/i) - i\n best = i\n print min(n / i, i), max(n / i, i)\n"}, {"source_code": "n = int(raw_input())\nupto = min(n, 2000)\nmax_diff = 100000000\naa, bb = None, None\nfor a in xrange(1, upto):\n if n % a == 0:\n b = n / a\n if a <= b:\n diff = b - a\n if diff < max_diff:\n aa, bb = a, b\nprint aa, bb"}, {"source_code": "def h(ans, l, index, cur, area):\n for i in range(index, len(l)):\n x = cur * l[i]\n if (x <= area / x) and ((area / x - x) < (ans[1] - ans[0])):\n ans[0] = x\n ans[1] = area / x\n h(ans, l, i + 1, x, area)\n\narea = int(raw_input())\nif area == 1:\n print \"1 1\"\ncur = 2\nl = []\ninp = area\nwhile cur <= area:\n if (area % cur == 0):\n l.append(cur)\n area = area / cur\n else:\n cur += 1\nans = [1, inp]\nh(ans, l, 0, 1, inp)\nprint str(ans[0]) + \" \" + str(ans[1])"}, {"source_code": "import math\nn=int (raw_input())\na = int (math.sqrt (n))\na -= n%a\nprint a,n/a\n"}, {"source_code": "n = int(raw_input())\nimport math\nlim = math.sqrt(n)\ni = int(lim)\nif(n>3):\n while(i>0):\n print(n,i,n%i)\n if(n%i==0):\n #print i,n/i\n break\n i-=1\nelse:\n print 1,n"}, {"source_code": "n = int(input())\na = 1\nb= n//a\nans = [a,b]\ntest = b-a\nwhile a<=b:\n a = a+1\n b = int(n/a)\n if n%a ==0:\n test = min(test , b-a)\n if test == b-a:\n ans = []\n ans.append(a)\n ans.append(b)\nprint(*ans)"}, {"source_code": "n=int(input())\nif n**(1/2)==int(n**(1/2)):\n print(int(n**(1/2)),int(n**(1/2)))\n exit()\nfor i in range(2,n+1):\n if n%i==0:\n print(min(n//(n//i),n//i),max(n//(n//i),n//i))\n exit()\n"}, {"source_code": "v=[]\nn=int(input())\nfor i in range(1,n+1):\n\tif n%i==0:\n\t\tv.append(i)\n# print(v)\nprint(v[len(v)//2-1],v[len(v)//2])\n"}, {"source_code": "import math\nn = int(input())\nfor a in range(int(math.sqrt(n)) + 1, 0, -1):\n if n % a == 0:\n break\nprint(a, n // a)"}, {"source_code": "from math import sqrt\nInput=lambda:map(int,input().split())\nc = lambda i,x: i.count(x)\n\nn = int(input())\na = int(sqrt(n))\nb = n//a\nif a*b == n:\n print(a,b)\nelse:\n print(1,n)\n \n \n\n\n\n"}, {"source_code": "\nn = int(input())\nfor i in range(int(n ** .5), 1, -1):\n if n % i == 0:\n print(i, n // i)\n exit()\n# \u0647\u0648\u0641\u0641\u0641\u0641\n# \u062e\u06cc\u0644\u06cc \u0646\u06af\u0631\u0627\u0646 \u0628\u0648\u062f\u0645\n# \u0627\u0645\u06cc\u062f\u0648\u0627\u0631\u0645 \u0627\u0648\u06a9\u06cc \u0628\u0634\u0647\n# \u0627\u0633\u062a\u0631\u0633 \u0647\u0645\u0631\u0627\u0647 \u0628\u0627 \u0646\u06af\u0631\u0627\u0646\u06cc \u0686\u06cc\u0632 \u0639\u062c\u06cc\u0628\u06cc\u0647\n# k0P MzMMSFp\n"}, {"source_code": "\nn = int(input())\nfor i in range(int(n ** .5), 1, -1):\n if n == 5:\n exit(print(1, 5))\n if n == 1:\n exit(print(1, 1))\n if n % i == 0:\n exit(print(i, n // i))\n\n\n \n# \u0647\u0648\u0641\u0641\u0641\u0641\n# \u062e\u06cc\u0644\u06cc \u0646\u06af\u0631\u0627\u0646 \u0628\u0648\u062f\u0645\n# \u0627\u0645\u06cc\u062f\u0648\u0627\u0631\u0645 \u0627\u0648\u06a9\u06cc \u0628\u0634\u0647\n# \u0627\u0633\u062a\u0631\u0633 \u0647\u0645\u0631\u0627\u0647 \u0628\u0627 \u0646\u06af\u0631\u0627\u0646\u06cc \u0686\u06cc\u0632 \u0639\u062c\u06cc\u0628\u06cc\u0647\n# k0P MzMMSFp"}, {"source_code": "\nn = int(input())\nfor i in range(int(n ** .5), 1, -1):\n if n == 5:\n exit(print(1, 5))\n if n % i == 0:\n exit(print(i, n // i))\n\n\n# \u0647\u0648\u0641\u0641\u0641\u0641\n# \u062e\u06cc\u0644\u06cc \u0646\u06af\u0631\u0627\u0646 \u0628\u0648\u062f\u0645\n# \u0627\u0645\u06cc\u062f\u0648\u0627\u0631\u0645 \u0627\u0648\u06a9\u06cc \u0628\u0634\u0647\n# \u0627\u0633\u062a\u0631\u0633 \u0647\u0645\u0631\u0627\u0647 \u0628\u0627 \u0646\u06af\u0631\u0627\u0646\u06cc \u0686\u06cc\u0632 \u0639\u062c\u06cc\u0628\u06cc\u0647\n# k0P MzMMSFp"}], "src_uid": "f52af273954798a4ae38a1378bfbf77a"} {"source_code": "p,y=map(int,input().split())\n\nfor i in range(y,p,-1):\n \n c=0\n for j in range(2,(int(i**0.5)+1)):\n if i%j==0 and j<=p:\n c=1\n break\n if c==0:\n print(i)\n exit(0)\nprint(-1)\n ", "positive_code": [{"source_code": "from math import sqrt\n\np, y = list(map(int, input().split()))\nyp = int(sqrt(y))\n\nif yp > p:\n yp = p\n if yp % 2 == 0: yp -= 1\n\nif p == 2:\n if y == 2:\n print(-1)\n exit()\n if y % 2 == 0:\n print(y-1)\n exit()\n else:\n print(y)\n exit()\n\n\nif yp % 2 == 0: yp -= 1\n\nif y % 2 == 0: y -= 1\n\n\nif yp == 1:\n if y > 2 and y % 2 == 0:\n print(y-1)\n exit()\n if y > p:\n print(y)\n exit()\n else:\n print(-1)\n exit()\n\nwhile y > p:\n yr = yp\n while yr > 2:\n if y % yr == 0:\n yr -= 2\n break\n\n elif yr == 3:\n print(y)\n exit()\n\n elif yr > 3:\n yr -= 2\n\n\n y -= 2\n\nprint(\"-1\")"}, {"source_code": "def valid(k):\n for i in range(2, k):\n\n if i*i > k:\n break\n if k % i == 0:\n if i <= p:\n return 0;\n k /= i\n\n if 1 < k:\n if k <= p:\n return 0\n else:\n return 1\n\n return 1\n\nansw = 1\n\np, n = map (int, input ().split ())\nfor i in range (n, 0, -1):\n if p >= i:\n break\n if valid(i) == 1:\n print(i)\n answ = 0\n break\n\nif answ == 1:\n print(-1)\n"}, {"source_code": "p, y = map(int, input().split())\nfor i in range(y, p, -1):\n if all(i % j for j in range(2, min(int(i ** .5), p) + 1)):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "p,y = map(int, input().split())\nfrom math import sqrt\nans = y\nwhile ans != 1:\n find =True\n if ans <= p:\n ans = 1\n continue\n for i in range(2, min(p+1, int(sqrt(ans))+1)):\n if ans % i == 0:\n find = False\n break\n if find:\n break\n ans -= 1\nif ans == 1:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "import sys\n\ndef unhoppable(p, n):\n for d in range(2, n+1):\n if p % d == 0:\n return False\n if d*d > p:\n break\n return True\n\np, y = map(int, input().split())\nfor b in range(y, p, -1):\n if unhoppable(b, p):\n print(b)\n sys.exit(0)\nprint(-1)\n"}, {"source_code": "\nfrom math import sqrt\np,y = map(int,input().split())\ndef is_prime(n, p):\n if n % 2 == 0 and n > 2:\n return False\n if p == 2: return True\n for x in range(3, min(p, int(sqrt(n))) + 1, 2):\n if n % x == 0:\n return False\n return True\n\nfor i in range(y, p,-1):\n if is_prime(i, p):\n print(i)\n exit()\n break\nprint(-1)"}, {"source_code": "p,y = map(int,input().split())\nimport math\ndef is_prime(n,p):\n if n % 2 == 0 and n > 2: \n return False\n if p == 2: return True\n for i in range(3, min(p,int(math.sqrt(n)))+1, 2):\n if n % i == 0:\n return False\n return True\nfor x in range(y,p,-1):\n if is_prime(x,p):\n print(x)\n break\nelse:\n print (-1)\n "}, {"source_code": "\nimport math\np, y = [int(x) for x in input().split()]\ndef is_prime(n, p):\n if n % 2 == 0 and n > 2:\n return False\n if p == 2: return True\n for x in range(3, min(p, int(math.sqrt(n))) + 1, 2):\n if n % x == 0:\n return False\n return True\n\nfor i in range(y, p,-1):\n if is_prime(i, p):\n print(i)\n break\nelse:\n print(-1)"}, {"source_code": "\nimport math\ndef CF937B():\n p,x = input(\"\").split(\" \")\n p = int(p)\n x = int(x)\n cur = x\n ans = -1\n while cur > p:\n found = False\n for i in range(2,min(int(math.sqrt(cur))+1,p+1)):\n if cur % i == 0:\n found = True\n break\n if (cur % p == 0):\n found = True\n if not found:\n ans = cur\n break\n cur -= 1\n print(ans)\n\n\nCF937B()\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Feb 26 19:42:02 2018\n\n@author: manish\n\"\"\"\n\nfrom math import sqrt\nfrom itertools import count, islice\n\ndef isPrime(n):\n if n < 2: return False\n for number in islice(count(2), int(sqrt(n)-1)):\n if not n%number:\n return False\n return True\n\ndef chef(d):\n d = list(map(int,d))\n p,y = d[0], d[1]\n ans = -1\n for i in range(y,p,-1 ):\n if isPrime(i) is True:\n ans = i\n return ans\n else:\n z= False\n for j in range(2,p+1):\n if i%j == 0:\n z=True\n\n break\n if z==False:\n ans = i\n return ans\n break\n return ans\n \ndef main():\n d= input().split()\n print(chef(d))\nmain() "}, {"source_code": "from sys import stdin, stdout\nti = lambda : stdin.readline().strip()\nma = lambda fxn, ti : map(fxn, ti.split())\nol = lambda arr : stdout.write(' '.join(str(i) for i in arr) + '\\n')\nos = lambda i : stdout.write(str(i) + '\\n')\nolws = lambda arr : stdout.write(''.join(str(i) for i in arr) + '\\n')\n\n\np, y = ma(int, ti())\nans = -1\nimport math\nwhile y != p:\n\tj = 2\n\tpossible = True\n\twhile j <= min(p, int(math.sqrt(y))):\n\t\tif y%j == 0:\n\t\t\tpossible = False\n\t\t\tbreak\n\t\tj += 1\n\tif possible:\n\t\tos(y)\n\t\texit()\n\n\ty -= 1\nos(-1)"}, {"source_code": "import math\np,y = map(int,input().split())\nans = -1\n\"\"\"\nif y-p<=1:\n print(-1)\n quit()\n\"\"\"\nwhile y>p:\n flag= 0\n r = min(math.ceil(math.sqrt(y)),p)\n for j in range(2,r+1):\n if y%j==0:\n flag =1\n break\n if flag == 0:\n ans= y\n break\n y-=1\nprint(ans)\n"}, {"source_code": "p, y = map(int, raw_input().split())\nz = -1\n\nwhile y > p:\n t = 0\n i = 2\n while i <= p and i * i <= y:\n if y % i == 0:\n t = 1\n break\n i += 1\n if t == 0:\n z = y\n break\n y -= 1\n\nprint z\n"}, {"source_code": "def fun(x):\n i=2\n while i*i<=x:\n if x%i==0:\n return i\n i+=1\n return x\np,y=map(int,raw_input().split())\nwhile y>p:\n if fun(y)>p:\n print y\n exit()\n y-=1\nprint -1\n \n"}, {"source_code": "p, y = map(int, input().split())\nfor x in range(y, p, -1):\n if all(x % i for i in range(2, min(int(x ** .5), p) + 1)):\n print(x)\n exit()\nprint(-1)"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 25.04.2020\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\nfrom math import log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[1] \ndef sort2(l):return sorted(l, key=getKey,reverse=True)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(n-r))\n\ndef ceil(x,y):\n if x%y==0:\n return x//y\n else:\n return x//y+1\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\ndef main():\n \n\n #for _ in range(ii()):\n \n \n p,y=mi()\n\n\n\n for i in range(y,1,-1):\n\n\n\n f=1\n\n for j in range(2,int(sqrt(i))+1):\n\n if i%j==0:\n if j>p:\n break\n f=0\n break\n\n if f:\n if i>p:\n print(i)\n else:\n print(-1)\n break\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n\n\n\n \n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "def is_prime(n,p):\n if n%2==0:\n return False\n r=int(n**0.5)\n f=3\n while f<=r and f<=p:\n if n%f == 0:\n return False\n f+=2\n return True\n\np,y=map(int,input().split())\n\nfor i in range(y,p,-1):\n if is_prime(i,p):\n print(i)\n break\nelse:\n print(-1)\n"}, {"source_code": "p, y = map(int, input().split())\nwhile y > p:\n if y % 2 == 0:\n y -= 1\n continue\n good = 1\n i = 3\n while i * i <= y and i <= p:\n if y % i == 0:\n good = 0\n break\n i += 2\n if good:\n break\n y -= 1\nif y == p:\n print(-1)\nelse:\n print(y)"}, {"source_code": "p,y = map(int,raw_input().split())\nfor a in xrange(y,p,-1):\n\tf = 1\n\tfor b in xrange(2,min(int(a**0.5)+1,p+1)):\n\t\tif a%b==0:\n\t\t\tf = 0\n\t\t\tbreak\n\tif f:\n\t\tprint a\n\t\texit(0)\nprint -1"}, {"source_code": "p, m = list(map(int, input().split()))\ndef ispos(k):\n am = []\n i = 2\n while (i * i <= k):\n if k % i == 0:\n k //= i\n am.append(i)\n else:\n i += 1\n if k != 1:\n am.append(k)\n for i in range(len(am)):\n if am[i] <= p:\n return False\n return True\nfor i in range(m, max(1, m - 1000), -1):\n if (ispos(i)):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "p,y=map(int,input().split())\n\n\n\nj=y\nans=-1\nt=True\nwhile j>p and t:\n\tfor i in range(2,min(int(j**0.5),p)+1):\n\t\tif j%i==0:\n\t\t\tbreak\n\telse:\n\t\tt=False\n\t\tans=j\n\tj-=1\n\nprint(ans)"}, {"source_code": "def prime(x,p):\n for i in xrange(2,min(int(x**0.5),p)+1):\n if x%i==0:\n return False\n return True\np,y=map(int,raw_input().split())\nfor i in xrange(y,p,-1):\n if prime(i,p):\n print i\n exit()\nprint -1"}, {"source_code": "import math\n\"\"\"def Prime_check(x,y):\n\tfor i in range(2,math.sqrt(y)+1):\n\t\tif(x%y==0):\n\t\t\tfalse\n\"\"\"\ndef Prime_check(val,y,p):\n\ti=2\n\twhile((i*i)<=y and i<=p):\n\t\tif(val%i==0):\n\t\t\treturn(False)\n\t\ti=i+1\n\treturn(True)\nt=list(map(int,input().split()))\ncount=-1\nif(t[0]==2 and t[0]!=t[1]):\n\tif(t[1]%2==0):\n\t\tprint(t[1]-1)\n\telif(t[1]==t[0]):\n\t\tprint(-1)\n\telse:\n\t\tprint(t[1])\nelif(t[0]==t[1]):\n\tprint(-1)\nelse:\n\tfor val in range(t[1],t[0],-1):\n\t\tif(Prime_check(val,t[1],t[0])):\n\t\t\tprint(val)\n\t\t\tcount=1\n\t\t\tbreak\n\tif(count==-1):\n\t\tprint(-1)"}, {"source_code": "from functools import reduce\n\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(pow(n, 0.5) + 1)) if n % i == 0)))\n\n\nm, p = map(int, raw_input().split())\nif p > 400:\n for x in range(p, p - 350, -1):\n tab = sorted(factors(x))\n # print tab\n if tab[1] > m:\n print x\n exit(0)\nelse:\n for x in range(p, m, -1):\n tab = sorted(factors(x))\n # print tab\n if tab[1] > m:\n print x\n exit(0)\nprint '-1'\nexit(0)\n"}, {"source_code": "import math\n\ndef getPrimes(v):\n\t\td = 2\n\t\tgr = int(math.sqrt(v)) + 1\n\t\tres = []\n\t\twhile d <= gr and v > 1:\n\t\t\tif v % d == 0:\n\t\t\t\tres.append(d)\n\t\t\t\twhile v % d == 0:\n\t\t\t\t\tv //= d\n\t\t\td += 1\n\t\tif v > 1:\n\t\t\tres.append(v)\n\t\treturn res\n\t\t\ndef solve(p, y):\n\tx = y\n\twhile x > p:\n\t\tpr = getPrimes(x)\n\t\tif all(v > p for v in pr):\n\t\t\treturn x\n\t\tx -= 1\n\treturn -1\n\np, y = map(int, input().split())\nprint(solve(p, y))\n"}, {"source_code": "from math import sqrt\n\ndef modpow(a, prime, mod):\n if prime == 1:\n return a % mod\n if mod % 2 == 1:\n return (a * modpow(a, prime - 1, mod)) % mod\n return ((modpow(a, prime/2, mod)) * (modpow(a, prime/2, mod))) % mod\n\ndef isPrime(prime):\n for i in range(2, int(sqrt(prime)) + 1):\n if prime % i == 0:\n return False\n return True\n\ndef minPrimeDiv(n):\n if isPrime(n):\n return n\n for i in range(2, int(n / 2) + 1):\n if n % i == 0 and isPrime(i):\n return i\n return 0\n\n\np, y = list(map(int, input().split()))\nans = y\n\ndone = False\ns = ''\nfor i in reversed(range(p+1, y+1)):\n if minPrimeDiv(i) > p:\n s += f' {minPrimeDiv(i)}'\n print(i)\n done = True\n break\nif not done:\n print(-1) \n\n#print(isPrime(10))\n#print(s)\n#print(isPrime(3), isPrime(4), isPrime(5))\n#print(modpow(10, 3, 3), modpow(27, 3, 3), modpow(38, 3, 3))"}, {"source_code": "p, y = (int(i) for i in input().split())\n\ndef least_divisor(num):\n ans = num\n for i in range(2, int(num ** 0.5 + 1)):\n if num % i == 0:\n ans = i\n break\n return ans\n\nfor i in range(y, p, -1):\n if least_divisor(i) > p:\n print(i)\n break\n\nelse:\n print(-1)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 8 21:52:51 2018\n\n@author: Nikita\n\"\"\"\nfrom math import ceil, sqrt\np, y = map(int, input().split())\nwhile y > p:\n ok = True\n for div in range(2, min(p, ceil(sqrt(y))) + 1):\n if y % div == 0:\n ok = False\n break\n if ok:\n print(y)\n break\n else:\n y -= 1\nif y == p:\n print(-1)\n"}, {"source_code": "import math\n\ndef isPrime(n):\n if n % 2 == 0:\n return False\n\n sqr = int(math.sqrt(n)) + 1\n\n for divisor in range(3, sqr, 2):\n if n % divisor == 0:\n return False\n return True\n\ndef first_factor(n):\n num = 2\n while 1:\n if n % num == 0:\n return num\n num += 1\n\narr = list(map(int, raw_input().split()))\np = arr[0]\ny = arr[1]\n\nwhile 1:\n if y <= p:\n print -1\n break\n if isPrime(y):\n print y\n break\n elif first_factor(y) <= p:\n y-=1\n else:\n print y\n break"}, {"source_code": "import math\n\np, y = map(int, raw_input().split())\n\nfound = -1\nfor bn in xrange(y, p, -1):\n\tprime = True\n\tfor i in xrange(2, min(int(math.sqrt(bn)), p) + 1):\n\t\tif bn % i == 0:\n\t\t\tprime = False\n\t\t\tbreak\n\tif prime:\n\t\tfound = bn\n\t\tbreak\nprint found"}, {"source_code": "p, y = map(int, raw_input().split())\n\ndef isPrime(num):\n\ti=2\n\twhile i <= p and i*i <= num:\n\t\tif num%i == 0:\n\t\t\treturn False\n\t\ti += 1\n\treturn True\n\nans = -1\nfor i in xrange(y, p, -1):\n\tif isPrime(i):\n\t\tans = i \n\t\tbreak\nprint ans\n"}, {"source_code": "p,y=map(int,raw_input().split())\nh=y\nwhile h>p:\n d=2\n while d<=p and d*d<=h:\n if 0==h%d:\n break\n d+=1\n else:\n print h\n break\n h-=1\nelse:\n print -1"}, {"source_code": "import sys\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n//i] for i in range(1, int(pow(n, 0.5) + 1)) if n % i == 0)))\n\nf = sys.stdin\np, y = [int(i) for i in f.readline().rstrip().split()]\n\nans = -1\nfor i in xrange(y, p, -1):\n a = sorted(filter(lambda k: k > 1 and k < i, factors(i)))\n if len(a) == 0 or a[0] > p:\n ans = i\n break\nprint ans"}, {"source_code": "def main():\n p,y=map(int,input().split())\n i=0\n while i<(10**5)*5:\n if y<=p:\n break\n i+=1\n pr=True\n for w in range(2,p+1):\n if w*w>y:\n break\n if y%w==0:\n pr=False\n break\n if pr:\n print(y)\n return\n y-=1\n print('-1')\nmain()\n"}, {"source_code": "p,y=map(int,input().split())\nh=y\nwhile h>p:\n d=2\n while d<=p and d*d<=h:\n if 0==h%d:\n break\n d+=1\n else:\n print(h)\n break\n h-=1\nelse:\n print (-1)"}, {"source_code": "n, m = map(int, raw_input().split())\n\ndef prime(a):\n\ti = 2\n\twhile i <= n and pow(i, 2) <= m:\n\t\tif a%i == 0:\n\t\t\treturn False\n\t\ti += 1\n\treturn True\n\nans = -1\nfor i in xrange(m, n, -1):\n\tif prime(i):\n\t\tans = i \n\t\tbreak\nprint ans"}, {"source_code": "p,y=map(int,(raw_input().split(' ')))\n\ndef vileGrasshoppers(y,p):\n for i in xrange(y,p,-1):\n c=1\n for j in xrange(2,int(i**0.5)+1):\n if i%j==0 and j<=p:\n c=0\n break\n if c:\n return i\n return -1\n\nprint(vileGrasshoppers(y,p))\n\n#http://codeforces.com/contest/937/problem/B"}, {"source_code": "import math\np, y = input().split()\np = int(p)\ny = int(y)\nfor i in range(y, p, -1):\n for d in range(2, min(int(math.sqrt(i))+1, p+1)):\n if i % d == 0:\n break\n else:\n print(i)\n break\nelse:\n print(-1)"}, {"source_code": "from math import sqrt\n\n\ndef solve(p, y):\n for i in xrange(300):\n cur = y - i\n if cur == p:\n return -1\n x = 2\n bad = False\n while x*x <= cur and x <= p:\n if (cur % x) == 0:\n bad = True\n break\n x += 1\n if not bad:\n return cur\n\n return -1\n\ndef main():\n print solve(*map(int, raw_input().split()))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def isdiv(i,p):\n upto = min(p,int(i**0.5)+1)\n for j in xrange(2,upto+1):\n if i%j==0:\n return True\n return False \n\np,y = map(int,raw_input().split())\n\nans = -1\nfor i in xrange(y,p,-1):\n if not isdiv(i,p):\n ans = i\n break\nprint ans "}, {"source_code": "def minf(n):\n i = 2\n while i ** 2 <= n:\n if n % i == 0:\n return i\n i += 1\n return n\np, y = map(int, input().split())\nfor i in range(y, p, -1):\n if minf(i) > p:\n print(i)\n exit()\nprint(-1)"}, {"source_code": "p, y = map(int, input().split())\nwhile y > p:\n if y % 2 == 0:\n y -= 1\n continue\n good = 1\n i = 3\n while i * i <= y and i <= p:\n if y % i == 0:\n good = 0\n break\n i += 2\n if good:\n break\n y -= 1\nif y == p:\n print(-1)\nelse:\n print(y)"}, {"source_code": "import math\n\ndef check(n, top):\n for x in range(2, top+1):\n if n % x == 0:\n return False\n return True\n\n\nif __name__ == '__main__':\n p, y = input().split()\n p = int(p)\n y = int(y)\n\n m = min(math.floor(math.sqrt(y)),p)\n\n cur = y\n while cur > p:\n if check(cur, m):\n print(cur)\n exit()\n cur -= 1\n\n print(-1)\n"}, {"source_code": "n,h = map(int,input().split())\nfor i in range(h,n,-1):\n if all(i%j for j in range(2,min(int(i**.5),n)+1)):print(i);exit()\nprint(-1)"}, {"source_code": "import math\n\np, y = [int(c) for c in input().split(\" \")]\n\ndef p1(p, y):\n primelist = [2]\n for i in range(3, p + 1, 2):\n tempstatus = True\n for pp in primelist:\n if i % pp == 0:\n tempstatus = False\n break\n if tempstatus:\n primelist.append(i)\n ans = -1\n for i in range(y, p, -1):\n tempstatus = True\n for pp in primelist:\n if i % pp == 0:\n tempstatus = False\n break\n if tempstatus:\n ans = i\n break\n\n #print(primelist[:100])\n return ans\n\n\ndef p2(p, y):\n primelist = [2]\n for i in range(3, min(int(math.sqrt(y)), p) + 1, 2):\n tempstatus = True\n for pp in primelist:\n if i % pp == 0:\n tempstatus = False\n break\n if tempstatus:\n primelist.append(i)\n ans = -1\n for i in range(y, p, -1):\n tempstatus = True\n for pp in primelist:\n if i % pp == 0:\n tempstatus = False\n break\n if tempstatus:\n ans = i\n break\n\n # print(primelist[:100])\n return ans\n\nprint(p2(p, y))\n"}, {"source_code": "from math import ceil\np,y=map(int,input().split())\nfor i in range(y, p, -1):\n c=False\n for j in range(2, ceil(i**0.5)+1):\n if i%j==0 and j <= p:\n c=True\n break\n if c:\n continue\n print(i)\n exit()\nprint(-1)\n"}, {"source_code": "def prime(x,p):\n z=int(x**0.5)+1\n for i in range(2,z):\n if x%i==0 and i<=p:\n return False\n return True\np,y=map(int,input().split())\nflag=0\nwhile flag==0 and y>p:\n if prime(y,p):\n flag=1\n break\n y-=1\nif flag==1:\n print(y)\nelse:\n print(-1)\n"}, {"source_code": "import math,sys\nfrom collections import Counter, defaultdict\nfrom sys import stdin, stdout\n#input = stdin.readline\nlili=lambda:list(map(int,sys.stdin.readlines()))\nli = lambda:list(map(int,input().split()))\n\ndef checkprime(a):\n for i in range(2, int(a**0.5)+1):\n if a%i == 0 and i <= z[0]:\n return False\n return True\nz = li()\nfor i in range(z[1], z[0], -1):\n if checkprime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "def mindiv(i,p):\n cnt=p+1\n j=2\n while(j*j<=i):\n if(i%j!=0):\n j=j+1\n continue\n else:\n cnt=min(cnt,j)\n cnt=min(cnt,i//j)\n j=j+1\n return cnt \np,y=[int(p) for p in input().split()]\nfor i in range(y,p,-1):\n if(mindiv(i,p)<=p):\n continue\n else:\n print(i)\n exit()\nprint(-1) "}, {"source_code": "import math as M\n\np, y = [int(x) for x in input().split()]\n\nlim = min(int(M.sqrt(y)) + 1, p) + 1\nprimes = []\n\nfor n in range(2, lim):\n for m in range(2, int(M.sqrt(n)) + 1):\n if n % m == 0:\n break\n else:\n primes.append(n)\n\nfor k in range(y, p, -1):\n for m in primes:\n if k % m == 0:\n break\n else:\n print(k)\n break\nelse:\n print(-1)\n\n#\n# arr = [True] * (y + 1)\n# for i in range(2, min(M.ceil(M.sqrt(y)), p) + 2):\n# if arr[i]:\n# k = i\n# while k < y + 1:\n# arr[k] = False\n# k += i\n#\n# # print(arr)\n# for k in range(y, 1, -1):\n# if arr[k]:\n# print(k)\n# break\n# else:\n# print(-1)\n"}, {"source_code": "import math\n\np, y = map(int, input().split())\n\ndef isPrime(p,n):\n i = 2\n while i <= math.sqrt(n) and i <= p:\n if n%i == 0:\n return False\n i += 1\n return True\n \n\ni = y\nans = -1\nwhile i > p:\n if isPrime(p,i):\n ans = i\n break\n i -= 1\n\nprint(ans)\n"}, {"source_code": "import math\nfrom sys import stdin\nstring=stdin.readline().strip().split()\np=int(string[0])\ny=int(string[1])\ndef findmf(number):\n factor=number\n for i in range(2,math.floor(math.sqrt(number))+1):\n \n if number%i==0:\n factor=i\n \n break\n return factor\nwhile True:\n if p<findmf(y):\n \n break\n elif y>p:\n \n y-=1\n else:\n y=-1\n \n break\nprint(y)\n"}, {"source_code": "import math\np,y=map(int,input().split())\ndef check(a):\n for i in range(2,min(int(math.sqrt(a)),p)+1):\n if a%i==0:\n return False\n return True\nwhile y>p:\n if check(y):\n print(y)\n exit(0)\n y=y-1\nprint(-1)\n"}, {"source_code": "p,y=list(map(int,input().split()))\nt=min(p,int(y**.5)+2)\nfor i in range(y,p,-1):\n while t*t>i:t-=1\n if not any(i%x==0 for x in range(2,t+1)):\n print(i)\n exit(0)\nprint(-1)\n"}, {"source_code": "import math\n\np, y = map(int, input().split())\n\nif y % 2 == 0:\n y -= 1\nfor i in range(y, p, -2):\n ok = True\n ans = i\n for d in range(3, int(math.sqrt(i)) + 1):\n if i % d == 0:\n if d <= p:\n ok = False\n break\n if ok:\n print(ans)\n exit()\nprint(-1)\n"}, {"source_code": "def prime(x,p):\n z=int(x**0.5)+1\n for i in range(2,z):\n if x%i==0 and i<=p:\n return False\n return True\np,y=map(int,input().split())\nflag=0\nwhile flag==0 and y>p:\n if prime(y,p):\n flag=1\n break\n y-=1\nif flag==1:\n print(y)\nelse:\n print(-1)\n"}, {"source_code": "def mlt(): return map(int, input().split())\n\n\nx, y = mlt()\n\n\ndef mn(x):\n n = 2\n if x % 2 == 0:\n return 2\n\n n = 3\n while n*n <= x:\n if x % n == 0:\n return n\n n += 2\n\n return x\n\n\nwhile y > x:\n if mn(y) > x:\n print(y)\n exit(0)\n y -= 1\n\nprint(-1)\n"}, {"source_code": "import math\nimport sys\n\n\ndef is_prime(n, p):\n if n % 2 == 0 and n > 2:\n return False\n for i in range(3, int(math.sqrt(n)) + 1, 2):\n if i > p: break\n if n % i == 0:\n return False\n return True\n\n\ndef main():\n p, y = map(int, sys.stdin.readline().split())\n\n highest = y\n if y % 2 == 0:\n highest -= 1\n while highest > p:\n if is_prime(highest, p):\n print(highest)\n return\n highest -= 2\n\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "p, y = [int(x) for x in input().split()]\nres = -1\nfor i in range(y, p, -1):\n flag = True\n for a in range(2, min(p+1, int(i**0.5)+1)):\n if i % a == 0:\n flag = False\n break\n if flag:\n res = i\n break\nprint(res)\n"}, {"source_code": "p, y = map(int, input().split())\nfor x in range(y, p, -1):\n if all(x % i for i in range(2, min(int(x ** .5), p) + 1)):\n print(x)\n exit()\nprint(-1)"}, {"source_code": "p, y = map(int, input().split())\nfor number in range(y, p, -1):\n for i in range(2, min(int(number ** 0.5) + 2, p + 1)):\n if number % i == 0:\n break\n else:\n print(number)\n break\nelse:\n print(-1)"}, {"source_code": "p, n = (int(x) for x in input().split())\nflag = False\nfor i in range(n, p, -1):\n flag = True\n # print(i)\n for j in range(2, min(int(n ** 0.5), p) + 1):\n if i % j == 0:\n flag = False\n break\n if flag:\n print(i)\n break\nif not flag:\n print(-1)\n\n"}, {"source_code": "p,y= [int(x) for x in input().split()]\nimport math as m\n\nfor i in range(y, p, -1):\n for d in range(2, min( int(m.sqrt(i))+1, p+1 )):\n if i % d ==0:\n break\n else:\n print(i)\n break\nelse:\n print(-1)\n"}, {"source_code": "import math\nimport sys\nimport math \ndef div(p,n) :\n m=10**10 \n for i in range(2, int(math.sqrt(n) + 1)) :\n if (n % i == 0) :\n if (n / i == i and i<m) :\n m=i\n else :\n if i<m:\n m=i\n if n//i <m:\n m=int(n//i)\n if m>p:\n return 1\n else:\n return 0\np,y=map(int,input().split())\nctr=0\nwhile(y>p and ctr<=300):\n a=div(p,y)\n if a!=0:\n print(y)\n sys.exit(0)\n y-=1\n ctr+=1\nprint(-1)\n"}, {"source_code": "P, Y = [int(_) for _ in input().split()]\nif Y % 2 == 0:\n Y -= 1\nwhile Y > P:\n f = 1\n for i in range(3, min(int(Y**0.5), P) + 1, 2):\n if Y % i == 0:\n f = 0\n continue\n if f:\n print(Y)\n exit()\n Y -= 2\nprint(-1)\n"}, {"source_code": "import math\np,y=map(int,input().split())\ndef check(a):\n for i in range(2,min(int(math.sqrt(a)),p)+1):\n if a%i==0:\n return False\n return True\nwhile y>p:\n if check(y):\n print(y)\n exit(0)\n y=y-1\nprint(-1)\n"}, {"source_code": "import sys\ndef fun(n,p,y):\n i=2\n while i<=p and i**2<=y:\n if n%i==0:\n return False\n i+=1\n \n return True\n \n \np,y=map(int,input().split())\nans=-1\nfor i in range(y,p,-1):\n if fun(i,p,y):\n print(i)\n sys.exit()\nprint(-1)\n"}, {"source_code": "p, y = map(int, input().split())\nfor x in range(y, p, -1):\n if all(x % i for i in range(2, min(int(x ** .5), p) + 1)):\n print(x)\n exit()\nprint(-1)\n"}, {"source_code": "\np,y = map(int, input().split())\n\nfor x in range(y, p, -1):\n if all(x%i for i in range(2,min(p, int(x**0.5))+1)):\n print(x)\n exit()\n\nprint (-1)"}, {"source_code": "import math\n\np,y = [int(x) for x in input().split()]\n\ndef check(x):\n\tmx = int(math.sqrt(x)) + 1\n\tfor i in range(2,min(p,mx) + 1):\n\t\tif x % i == 0:\n\t\t\treturn False\n\treturn True\n\nans = -1\n\nfor x in range(max(p + 1,y - 300),y + 1):\n\tif check(x):\n\t\tans = x\n\nprint(ans)\n\t\n\n\n\n"}, {"source_code": "from math import sqrt\n\np, y = [int(i) for i in input().split()]\nfor i in range(y, p, -1):\n if all(i % j for j in range(2, min(p, int(sqrt(i))) + 1)):\n print(i)\n exit()\nprint(-1)\n"}, {"source_code": "p, y = map(int, input().split())\n\nmx = 33000\n\nv = [False]*mx\nfor x in range(2, mx):\n if not v[x]:\n for i in range(x*x, mx, x):\n v[i] = True\nprimes = [i for i, _ in enumerate(v) if not _ and i>1]\nfail = True\nfor v in range(y, p, -1):\n fail = False\n for pr in primes:\n if pr <= p and v%pr == 0:\n fail = True\n elif pr > p: break\n if not fail:\n print(v)\n break\n\nif fail:\n print(-1)\n\n\n"}, {"source_code": "p,y = map(int,input().split())\nfor x in range(y,p,-1):\n if all(x%i for i in range(2,min(p,int(x**.5))+1)):\n print(x)\n exit()\nprint(-1)"}, {"source_code": "p, y = map(int, input().split())\nfor i in range(y, p, -1):\n\t# print (min(p, int(i ** 0.5 + 1)))\n\tif all(i % j != 0 for j in range(2, min(p, int(i ** 0.5 + 1)) + 1)):\n\t\tprint (i)\n\t\texit()\nprint (-1)"}, {"source_code": "p,y = list(map(int, input().split()))\nflag = False\nans = -1\n\nfor x in range(y,p,-1):\n flag = False\n for i in range(2, min(p, int(x ** 0.5)) + 1):\n if x%i==0:\n flag = True\n break\n if not flag:\n ans = x\n break\n\nif not flag:\n print(ans)\nelse:\n print(-1)\n\n"}], "negative_code": [{"source_code": "p,y = map(int, input().split())\n\ndef is_div(a, m):\n if a % 2 == 0 or a % 3 == 0:\n return True\n i = 5\n m = min(m, a ** 0.5)\n while i < m:\n if a % i == 0 or (i + 2 < m and a % (i + 2) == 0):\n return True\n i += 6\n return False \n\nfor i in range(y - int(y % 2 == 0), p, -2):\n if not is_div(i, p):\n print(i)\n exit(0)\n \nprint(-1)"}, {"source_code": "n,p=input().split()\nn,p=int(p),int(n)\nfor i in range(n,p,-1):\n\tfor j in range(2,p+1):\n\t\tif j*j>i or i%j==0:\n\t\t\tbreak\n\tif j==p or j*j>i:\n\t\tprint(i)\n\t\texit(0)\nprint(-1)"}, {"source_code": "from math import ceil\np,y=map(int,input().split())\nfor i in range(y, p, -1):\n c=False\n for j in range(2, ceil(i**0.5)+1):\n if i%j==0:\n c=True\n break\n if c:\n continue\n print(i)\n exit()\nprint(-1)\n"}, {"source_code": "import math\n\"\"\"def Prime_check(x,y):\n\tfor i in range(2,math.sqrt(y)+1):\n\t\tif(x%y==0):\n\t\t\tfalse\n\"\"\"\ndef Prime_check(val,y):\n\tfor i in range(2,int(math.sqrt(val))+1):\n\t\tif(i>y):\n\t\t\tbreak\n\t\telif(val%i==0):\n\t\t\treturn(False)\n\treturn(True)\nt=list(map(int,input().split()))\ncount=-1\nif(t[0]==2 and t[0]!=t[1]):\n\tif(t[1]%2==0):\n\t\tprint(t[1]-1)\n\telif(t[1]==t[0]):\n\t\tprint(-1)\n\telse:\n\t\tprint(t[1])\nelif(t[0]==t[1]):\n\tprint(-1)\nelse:\n\tfor val in range(t[1],t[0],-1):\n\t\tif(Prime_check(val,t[1])):\n\t\t\tprint(val)\n\t\t\tcount=1\n\t\t\tbreak\n\tif(count==-1):\n\t\tprint(-1)"}, {"source_code": "import math\n\"\"\"def Prime_check(x,y):\n\tfor i in range(2,math.sqrt(y)+1):\n\t\tif(x%y==0):\n\t\t\tfalse\n\"\"\"\ndef Prime_check(val,y):\n\tfor i in range(2,int(math.sqrt(val))+1):\n\t\tif(i>y):\n\t\t\tbreak\n\t\telif(val%i==0):\n\t\t\treturn(False)\n\treturn(True)\nt=list(map(int,input().split()))\ncount=-1\nif(t[0]==2):\n\tif(t[1]%2==0):\n\t\tprint(t[1]-1)\n\telif(t[1]==t[0]):\n\t\tprint(-1)\n\telse:\n\t\tprint(t[1])\nelif(t[0]==t[1]):\n\tprint(-1)\nelse:\n\tfor val in range(t[1],t[0],-1):\n\t\tif(Prime_check(val,t[1])):\n\t\t\tprint(val)\n\t\t\tcount=1\n\t\t\tbreak\n\tif(count==-1):\n\t\tprint(-1)"}, {"source_code": "import math\n\ndef is_prime(n):\n if n == 0 or n == 1: return False\n for x in range(2, int(math.sqrt(n))+1):\n if n % x == 0:\n return False\n return True\n\n\nif __name__ == '__main__':\n p, y = input().split()\n p = int(p)\n y = int(y)\n\n cur = y\n while cur > p:\n if is_prime(cur):\n print(cur)\n exit()\n cur -= 1\n\n\n print(-1)\n"}, {"source_code": "p,y=map(int,input().split())\nfrom math import sqrt as S\nf=-1 \nfor i in range(y,p,-1):\n if all(i%j for j in range(2,min(p,int(S(i))+1))):\n f=1 \n print(i)\n break \nif f==-1:\n print(f)"}, {"source_code": "p,y = map(int,input().split())\n\nfor x in range(y,p,-1):\n\t# print(x)\n\t# check\n\tflag = True\n\tfor i in range(2,min(p,int(x**0.5)+1)):\n\t\tif x%i == 0:\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tprint(x)\n\t\texit()\n\nprint(-1)"}, {"source_code": "def prime_number(x):\n if x <= 1:\n return False\n i = 2\n while i * i <= x:\n if(x % i == 0):\n return False\n i += 1\n return True\n\np, y = map(int,input().split())\nflag = -1\nnum_list = []\n\nfor i in range(p,y+1):\n num_list.append(i)\nnum_list.reverse()\n\nfor i in num_list:\n if(prime_number(i) and i != p):\n print(i)\n flag = 1\n break\nif flag != 1:\n print(\"-1\")"}, {"source_code": "p,y = map(int,input().split())\nfor i in range(y,p,-1):\n check = True\n for j in range(2,round(p ** 0.5) + 1):\n if i % j == 0:\n check = False\n break\n if check:\n print(i)\n exit()\nprint(-1)"}, {"source_code": "n,h = map(int,input().split())\n \nl = [0,0]+[1]*(h-1)\n \nfor i in range(2,n+1):\n if l[i]: \n j = i\n while j<=h:l[j]=0;j+=j\n \nans = -1\n \nfor i in range(h,1,-1):\n if l[i]:ans=i;break\n \nprint(ans)"}, {"source_code": "p, y = map(int, input().split())\nfor i in range(y, p, -1):\n\t# print ((int(i ** 0.5)))\n\tif all(i % j != 0 for j in range(2, min(p, int(i ** 0.5) + 1))):\n\t\tprint (i)\n\t\texit()\nprint (-1)"}, {"source_code": "import math\n\np, y = [int(c) for c in input().split(\" \")]\nprimelist = [2]\n\nfor i in range(3, min(int(math.sqrt(y)), p) + 1, 2):\n tempstatus = True\n for p in primelist:\n if i % p == 0:\n tempstatus = False\n break\n if tempstatus:\n primelist.append(i)\n\nans = -1\nfor i in range(y, p, -1):\n tempstatus = True\n for p in primelist:\n if i % p == 0:\n tempstatus = False\n break\n if tempstatus:\n ans = i\n break\n\n# print(primelist[:100])\nprint(ans)\n"}, {"source_code": "import sys\n\n\ndef unhoppable(p, n):\n for d in range(2, n+1):\n if p % d == 0:\n return False\n if d*d > p:\n break\n return True\n\np, y = map(int, input().split())\nfor b in range(y, p, -1):\n if unhoppable(b, y):\n print(b)\n sys.exit(0)\nprint(-1)\n"}, {"source_code": "p,y = map(int,raw_input().split())\nx = y/p+1\nif(x<=2):\n\tprint -1\nelse:\n\tprint x"}, {"source_code": "from sys import stdin, stdout\nti = lambda : stdin.readline().strip()\nma = lambda fxn, ti : map(fxn, ti.split())\nol = lambda arr : stdout.write(' '.join(str(i) for i in arr) + '\\n')\nos = lambda i : stdout.write(str(i) + '\\n')\nolws = lambda arr : stdout.write(''.join(str(i) for i in arr) + '\\n')\n\n\np, y = ma(int, ti())\nans = -1\nwhile y != p:\n\tj = 2\n\tpossible = True\n\twhile j*j <= y:\n\t\tif y%j == 0:\n\t\t\tpossible = False\n\t\t\tbreak\n\t\tj += 1\n\tif possible:\n\t\tos(y)\n\t\texit()\n\n\ty -= 1\nos(-1)"}, {"source_code": "p,y = map(int,raw_input().split())\nfor a in xrange(y,p,-1):\n\tf = 1\n\tfor b in xrange(2,min(int(a**0.5)+1,p)):\n\t\tif a%b==0:\n\t\t\tf = 0\n\t\t\tbreak\n\tif f:\n\t\tprint a\n\t\texit(0)\nprint -1"}, {"source_code": "import math\ndef fact(n): \n while n % 2 == 0: \n s.add(2)\n n = n / 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n s.add(i)\n n = n / i \n if n > 2: \n s.add(n)\ninput=__import__('sys').stdin.readline\np,y = map(int,input().split())\ns=set()\nmm = y-max(y-200,p)\nfor i in range(mm):\n fact(y)\n l=sorted(s)\n# print(l)\n if int(l[0])>p:\n print(y)\n exit()\n s = set()\n y-=1\nprint(-1)\n\n\n"}, {"source_code": "n,y = map(int,input().split())\nl=[]\ni=max(n+1,y-n)\nwhile i<y:\n\tl.append(i)\n\ti+=1\nif len(l)==0:\n\tprint(-1)\nelse:\n\tfor i in l:\n\t\tif i%n==0:\n\t\t\tl.remove(i)\n\tprint(max(l))"}, {"source_code": "from collections import deque\nfrom math import ceil,sqrt\ndef ii():return int(input())\ndef si():return input()\ndef mi():return map(int,input().split())\ndef li():return list(mi())\nabc=\"abcdefghijklmnopqrstuvwxyz\"\np,y=mi()\ndef isPrime(n) : # Check Prime Number or not \n for i in range(2,p+1):\n if(n%i==0):\n return 0\n if(i*i>n):\n break\n return 1\n\nf=0\nfor i in range(y-1,p,-1):\n if(isPrime(i)):\n print(i)\n f=1\n break\nif(f==0):\n print(\"-1\")"}, {"source_code": "p, y = list(map(int , input().split()))\n\nif y%2 == 0:\n y -= 1\n\nfor cur in range(y, p, -2):\n maxp = min(p, int(y**0.5)+1)\n for k in range(3,maxp):\n if cur%k == 0:\n # print(cur, 'does not fit due to', k)\n break\n else:\n print(cur)\n exit()\n\n\nprint(-1)"}, {"source_code": "def f(n):\n i=2\n while i*i<=n:\n if n%i==0:\n return False\n i+=1\n return True\np,y=map(int,input().split())\nif p>10000:\n i=y\n while not f(i):\n if i==p:\n print(-1)\n exit()\n i-=1\n print(i)\nelse:\n for i in range(y,p,-1):\n for j in range(2,p+1):\n if i%j==0:\n break\n else:\n print(i)\n break\n else:\n print(-1)\n \n \n"}, {"source_code": "p, y = list(map(int , input().split()))\n\nif y%2 == 0:\n y -= 1\n\nfor cur in range(y, p, -2):\n maxp = min(p, int(y**0.5)+1)\n for k in range(3,maxp):\n if cur%k == 0:\n # print(cur, 'does not fit due to', k)\n break\n else:\n print(cur)\n exit()\n\n\nprint(-1)"}, {"source_code": "from math import factorial\np, y = [int(x) for x in input().split()]\nr = factorial(p)\nif r - 1 > y:\n print(-1)\nelse:\n print(r - 1)"}, {"source_code": "import math\narr=[]\np,y=(map(int,input().split()))\nfor i in range(p+1,y):\n #print(math.floor(y/i)*2)\n if math.floor(y/i)*2!=i:\n arr.append(i)\nif arr:\n print(max(arr))\nelse:\n print(-1)"}, {"source_code": "import math as M\n\np, y = [int(x) for x in input().split()]\n\nlim = min(int(M.sqrt(y)) + 1, p) + 1\nprimes = []\n\nfor n in range(2, lim):\n for m in range(2, int(M.sqrt(n)) + 1):\n if n % m == 0:\n break\n else:\n primes.append(n)\n\nfor k in range(y, 1, -1):\n for m in primes:\n if k % m == 0:\n break\n else:\n print(k)\n break\nelse:\n print(-1)\n#\n# arr = [True] * (y + 1)\n# for i in range(2, min(M.ceil(M.sqrt(y)), p) + 2):\n# if arr[i]:\n# k = i\n# while k < y + 1:\n# arr[k] = False\n# k += i\n#\n# # print(arr)\n# for k in range(y, 1, -1):\n# if arr[k]:\n# print(k)\n# break\n# else:\n# print(-1)\n"}, {"source_code": "import math\np,y = map(int,input().split())\ndef isprime(a):\n for i in range(2,math.ceil(math.sqrt(a))):\n if a%i==0:\n return False\n return True\nif y-p<=1:\n print(-1)\n quit()\nfor i in range(y-1,p,-1):\n if isprime(i):\n print(i)\n break\n"}, {"source_code": "from sys import stdin\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i = i + 6\n return True\n\n\nx, y = map(int, stdin.readline().rstrip().split(\" \"))\n\nif not y%2:\n start =y-1\nelse:\n start = y\nc = 0\nfor i in range(start, x, -2):\n if is_prime(i):\n c = i\n break\n\nif c == 0:\n print(-1)\nelse:\n for i in range(start, y-y%c, - 2):\n check = False\n for j in range(3,x,2):\n if i%j==0:\n check=True\n break\n if not check:\n c = i\n break\n print(c)"}, {"source_code": "from sys import stdin\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i = i + 6\n return True\n\n\nx, y = map(int, stdin.readline().rstrip().split(\" \"))\n\nif not y%2:\n start =y-1\nelse:\n start = y\nc = 0\nfor i in range(start, x, -2):\n if is_prime(i):\n c = i\n break\n\nif c == 0:\n print(-1)\nelse:\n for i in range(start, y-y%c, - 2):\n check = False\n for j in range(3,x,2):\n if i%j==0:\n check=True\n break\n if not check:\n c = i\n break\n print(c)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 8 21:52:51 2018\n\n@author: Nikita\n\"\"\"\nfrom math import ceil, sqrt\np, y = map(int, input().split())\ny_copy = y\nwhile y >= y_copy - 300 and y > p:\n ok = True\n for div in range(2, min(p, ceil(sqrt(y)) + 1)):\n if y % div == 0:\n ok = False\n break\n if ok:\n print(y)\n break\n else:\n y -= 1\nif y == y_copy - 301 or y == p:\n print(-1)\n"}, {"source_code": "from sys import stdin\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i = i + 6\n return True\n\n\nx, y = map(int, stdin.readline().rstrip().split(\" \"))\n\nf = 0\n\nfor i in range(x+1, y+1):\n if is_prime(i):\n f = i\n break\n\nif f == 0:\n print(-1)\nelse:\n print(y - y%f)"}, {"source_code": "p, y = map(int, input().split())\nfor i in range(y, p, -1):\n if all(i % j != 0 for j in range(2, min(p, i**0.5 + 2))):\n print(i)\n exit()\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Feb 25 21:50:26 2018\n\n@author: manish\n\"\"\"\n\nd = ['3','6']\nimport math\n\n\ndef chef(d):\n d = list(map(int,d))\n p,y = d[0], d[1]\n \n # list1 = []\n # for i in range(2,p+1):\n # list1.append(i)\n m =[]\n\n\n for num in range(p+1,y+1):\n if all(num%i!=0 for i in range(2,int(math.sqrt(num))+1)):\n m.append(num)\n if m!=[]:\n ans = m[-1]\n else:\n ans = -1\n# ans = -1\n# \n# for i in tqdm.tqdm(range(y,p, -1)):\n## print(i)\n# z=True\n# for j in m:\n# if i%j == 0:\n# z = False\n# break\n# if z==True:\n# \n# ans = i\n# return ans\n return ans\n# #for i in range(2, p+1):\n# # for j in range(1, int(y/i)+1):\n# ## print(list1[i+1:])\n# # if j*i in m :\n# ## or j*list1[i] in list1[i+1:]:\n# # break\n# # m.append(j*i)\n# m.sort()\n# # if m[-1] < y:\n# # print('yes')\n# # print(m[-1]+1)\n# # for i in range(m[-1]+1, y+1):\n# # print(i)\n# # m.append(i)\n# # m.sort(reverse = True)\n# # print(m)\n# # print(m)\n# ans = -1\n# for i in range(len(m)-1, 0, -1):\n# if m[i]<y and y not in m:\n# ans = y\n# break\n# if m[i-1] != m[i]-1:\n# ans = m[i]-1\n# break\n# return ans\n# \ndef main():\n\n d= input().split()\n\n print(chef(d))\n\n \nmain()"}, {"source_code": "def main():\n p,y=map(int,input().split())\n q=False\n if p*p>y:\n q=True\n i=0\n while i<(10**7)*5:\n if y<=p:\n break\n i+=1\n if q:\n w=2\n pr=True\n while w*w<=y:\n if y%w==0:\n pr=False\n break\n w+=1\n if pr:\n print(y)\n return\n else:\n pr=True\n for w in range(2,p):\n if y%w==0:\n pr=False\n break\n if pr:\n print(y)\n return\n y-=1\n print('-1')\nmain()\n"}, {"source_code": "def min_divider(n):\n\tans = 2\n\ttc = n ** 0.5 // 1\n\twhile n % ans != 0 and ans < tc:\n\t\tans += 1\n\tif ans == tc and tc * tc != n:\n\t return n\n\treturn ans\n\np, y = map(int, input().split())\nwhile min_divider(y) <= p and y > p:\n\ty -= 1\nif y == p:\n\tprint(-1)\nelse:\n\tprint(y)"}, {"source_code": "p,y = map(int,input().split())\nfor i in range(y,p,-1):\n check = True\n for j in range(2,round(p ** 0.5) + 2):\n if i % j == 0:\n check = False\n break\n if check:\n print(i)\n exit()\nprint(-1)"}, {"source_code": "from math import sqrt\np, y = [int(x) for x in input().split()]\n\ndef isprime(n):\n if n == 2:\n return False\n for x in range(2, min(int(sqrt(n)) + 1, p)):\n if n % x == 0:\n return False\n return True\n\nfor i in range(y, p,-1):\n if isprime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "from math import sqrt\n\np, y = list(map(int, input().split()))\n\nyp = int(sqrt(y))\n\nif p == 2 and y == 2:\n print(-1)\n exit()\n\nif yp % 2 == 0: yp += 1\n\nif y % 2 == 0: y -= 1\n\n\nif yp == 1:\n if y > 2 and y % 2 == 0:\n print(y-1)\n exit()\n else:\n print(y)\n exit()\n\nwhile y > p:\n yr = yp\n while yr > 2:\n if y % yr == 0:\n yr -= 2\n break\n\n elif yr == 3:\n print(y)\n exit()\n\n elif yr > 3:\n yr -= 2\n\n\n y -= 2\n\nprint(\"-1\")"}, {"source_code": "p,y=map(int,input().split())\nfrom math import sqrt as S\nf=-1 \nfor i in range(y,p,-1):\n if all(i%j for j in range(2,min(p,int(S(i))+1))):\n f=1 \n print(i)\n break \nif f==-1:\n print(f)"}, {"source_code": "p,y = list(map(int, input().split()))\nflag = False\nans = 0\n\nfor x in range(y,p,-1):\n flag = False\n for i in range(2,p+1):\n if x%i==0:\n flag = True\n break\n if not flag:\n ans = x\n break\n\nif not flag:\n print(ans)\nelse:\n print(-1)\n\n"}, {"source_code": "import math\n\np, y = [int(c) for c in input().split(\" \")]\nprimelist = [2]\n\nfor i in range(11, min(round(math.sqrt(y)), p) + 1, 2):\n tempstatus = True\n for p in primelist:\n if i % p == 0:\n tempstatus = False\n break\n if tempstatus:\n primelist.append(i)\n\nans = -1\nfor i in range(y, p, -1):\n tempstatus = True\n for p in primelist:\n if i % p == 0:\n tempstatus = False\n break\n\n if tempstatus:\n ans = i\n break\n\nprint(ans)\n"}, {"source_code": "from math import factorial\np, y = [int(x) for x in input().split()]\nr = factorial(p)\nif r - 1 > y:\n print(-1)\nelse:\n print(r - 1)"}, {"source_code": "from math import sqrt\np, y = [int(x) for x in input().split()]\n\ndef isprime(n):\n if n % 2 == 0 and n > 2:\n return False\n if p == 2:\n return True\n for x in range(3, min(int(sqrt(n)) + 1, p), 2):\n if n % x == 0:\n return False\n return True\n\nfor i in range(y, p,-1):\n if isprime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Mar 7 09:39:50 2018\n\n@author: wangjun\n\"\"\"\nimport math\n\n\ndef Grasshopper(ng,nb):\n \n if nb%2 ==0 :\n nb=nb-1\n if ng > 3:\n nng = math.floor( ng ** 0.5 )\n else:\n nng=ng\n for branch in range(nb,ng,-2):\n flag =True\n for hopper in range(3,nng,2):\n if branch % hopper == 0:\n flag = False\n break\n if flag==True : \n return branch\n return -1\n \ndef hello():\n \"\"\"Print \"Hello World\" and return None\"\"\"\n ar = list(map(int, input().strip().split(' ')))\n \n result=Grasshopper(ar[0],ar[1])\n print(result)\n# main program starts here\nhello()"}, {"source_code": "p, y = map(int, input().split())\nex = False\nfirst = False\nfor i in range(301):\n j = 2\n first = False\n while j ** 2 <= y:\n if y % j == 0:\n first = True\n if j > p:\n ex = True\n j += 1\n if not first:\n if y > p:\n ex = True\n if ex:\n break\n y -= 1\nif ex:\n print(y)\nelse:\n print(-1)\n"}, {"source_code": "def main():\n P, Y = map(int, input().split())\n\n branch = [0] * (Y + 1)\n for i in range(2, P + 1):\n while i <= Y:\n branch[i] = 1\n i *= 2\n\n if all(branch[2:]):\n print(-1)\n else:\n print(Y - branch[::-1].index(0))\n\nmain()\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Feb 25 21:50:26 2018\n\n@author: manish\n\"\"\"\n\nd = ['3','6']\n\ndef chef(d):\n d = list(map(int,d))\n p,y = d[0], d[1]\n \n list1 = []\n for i in range(2,p+1):\n list1.append(i)\n m = []\n \n for i in range(0, len(list1)):\n for j in range(1, int(y/list1[i])+1):\n# print(list1[i+1:])\n if j*list1[i] in m or j*list1[i] in list1[i+1:]:\n break\n m.append(j*list1[i])\n# m.sort()\n# if m[-1] < y:\n# print('yes')\n# print(m[-1]+1)\n# for i in range(m[-1]+1, y+1):\n# print(i)\n# m.append(i)\n m.sort(reverse = True)\n# print(m)\n# print(m)\n ans = -1\n for i in range(0, len(m)-1):\n if m[i]<y and y not in m:\n ans = y\n break\n if m[i+1] != m[i]-1:\n ans = m[i]-1\n break\n return ans\n \ndef main():\n\n d= input().split()\n\n print(chef(d))\n\n \nmain()"}, {"source_code": "'''input\n3 6\n'''\nfrom math import sqrt\np=[]\npr=[1]*(10**5)\npr[1]=0\npr[0]=0\n\nfor i in range(4,10**5,2):\n pr[i]=0\nfor i in range(3,400,2):\n if pr[i]:\n for j in range(i*i,10**5,2*i):\n pr[j]==0\nfor i in range(10**5):\n if pr[i]:\n p.append(i)\ndef prime(n):\n sq=int(sqrt(n))+1\n for i in np:\n if i>sq:\n return True\n if n%i==0:\n return False\n return True\nppp,n=[int(x) for x in raw_input().split()]\nsq=int(sqrt(n))+1\npppp=ppp\nppp=max(ppp,sq)\nnp=[]\nfor i in p:\n if i<sq:\n np.append(i)\n else:\n break\nlp=n\nif lp%2==0:\n lp-=1\nans=-1\nwhile lp>pppp:\n if prime(lp):\n ans=lp\n break\n lp-=2\n\nprint ans\n"}, {"source_code": "import math\np,y=map(int,input().split())\ndef check(a):\n for i in range(2,int(math.sqrt(a))+1):\n if a%i==0:\n return False\n return True\nwhile y>p:\n if check(y):\n print(y)\n exit(0)\n y=y-1\nprint(-1)"}, {"source_code": "p, y = map(int, input().split())\nfor x in range(y - (y & 1 ^ 1), p, -2):\n if x & 1 and all(x % i for i in range(3, min(int(x ** .5) + 2, p), 2)):\n print(x)\n exit()\nprint(-1)\n"}, {"source_code": "p, y = map(int, input().split())\nfor i in range(y, p, -1):\n if all(i % j for j in range(2, min(int(i ** .5), p + 1))):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "n,p=input().split()\nn,p=int(p),int(n)\nfor i in range(n,p,-1):\n\tfor j in range(2,p+1):\n\t\tif j*j>i or i%j==0:\n\t\t\tbreak\n\tif j==p or j*j>i:\n\t\tprint(i)\n\t\texit(0)\nprint(-1)"}, {"source_code": "import sys\n\ndef is_prime(n):\n if n == 1:\n return False\n i = 2\n while i*i <= n:\n if n % i == 0:\n return False\n i += 1\n return True\n\nf = sys.stdin\nNMAX = 1e9\np, y = [int(i) for i in f.readline().rstrip().split()]\nif p == y:\n print -1\nans = -1\nfor i in xrange(p + 1, y + 1):\n if is_prime(i):\n ans = i\n break\nprint ans"}, {"source_code": "def chek(a,p) :\n i=2\n p=min(p,int(pow(i,0.5))+1)\n while (i<=p) :\n if a%i==0 :\n return False\n i+=1\n return True\nb,a=map(int,input().split())\nwhile (a>b) :\n if chek(a,b) :\n print(a)\n exit()\n a-=1\n \nprint(-1)\n"}, {"source_code": "from math import sqrt\np, y = [int(x) for x in input().split()]\n\ndef isprime(n):\n if n == 2:\n return False\n for x in range(2, int(sqrt(n)) + 1):\n if n % x == 0:\n return False\n return True\n\nfor i in range(y, p,-1):\n if isprime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "def SieveOfEratosthenes(ps,n):\n\n prime = [True for i in range(n+1)]\n p = 2\n while (p * p <= n):\n \n # If prime[p] is not changed, then it is a prime\n if (prime[p] == True):\n \n # Update all multiples of p\n for i in range(p * 2, n+1, p):\n prime[i] = False\n p += 1\n count=-1\n for p in range(n-1, 2,-1):\n if (prime[p] and p>ps):\n \tcount=p\n print(count)\nt=list(map(int,input().split()))\nif(t[0]==2):\n\tif(t[1]%2==0 and t[0]!=t[1]):\n\t\tprint(t[1]-1)\n\telif(t[1]==t[0]):\n\t\tprint(-1)\n\telse:\n\t\tprint(t[1])\nelse:\n\tSieveOfEratosthenes(t[0],t[1])"}, {"source_code": "import math,sys\nfrom collections import Counter, defaultdict\nfrom sys import stdin, stdout\n#input = stdin.readline\nlili=lambda:list(map(int,sys.stdin.readlines()))\nli = lambda:list(map(int,input().split()))\n\ndef checkprime(a):\n if a%2:\n return True\n for i in range(2,min(p,int(a**0.5)+1)):\n if a%i == 0:\n return False\n return True\np, y = map(int, input().split())\nfor i in range(y, p, -1):\n if checkprime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "from math import factorial\np, y = [int(x) for x in input().split()]\nr = factorial(p)\nif r - 1 > y:\n print(-1)\nelse:\n print(r - 1)"}, {"source_code": "import math\n\np, y = map(int, input().split())\n\ndef isPrime(p,n):\n i = 2\n while i <= math.sqrt(n) and i < p:\n if n%i == 0:\n return False\n i += 1\n return True\n \n\ni = y\nans = -1\nwhile i > p:\n if isPrime(p,i):\n ans = i\n break\n i -= 1\n\nprint(ans)\n"}, {"source_code": "from math import ceil\np,y=map(int,input().split())\nfor i in range(y, p, -1):\n c=False\n for j in range(2, ceil(i**0.5)+1):\n if i%j==0:\n c=True\n break\n if c:\n continue\n print(i)\n exit()\nprint(-1)\n"}, {"source_code": "import math\nimport sys\n\n\ndef is_prime(n, p):\n if n % 2 == 0 and n > 2:\n return False\n for i in range(3, int(math.sqrt(n)) + 1, 2):\n if i > p: break\n if n % i == 0:\n return False\n return True\n\n\ndef main():\n p, y = map(int, sys.stdin.readline().split())\n\n highest = y\n if y % 2 == 0:\n highest -= 1\n while highest >= p:\n if is_prime(highest, p):\n print(highest)\n return\n highest -= 2\n\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def sieve(n):\n p = [0]*(n+1); i = 2\n while i*i <= n:\n if p[i] == 1:\n i += 1\n continue\n j = i\n while i*i + j <= n:\n p[i*i+j] = 1\n j += i\n i += 1\n k = 0\n for i in range(n+1):\n if p[i] == 0:\n k = i\n return k\np,y = map(int,input().split())\nl = sieve(y)\nif l > p:\n print (l)\nelse:\n print (-1)"}, {"source_code": "from math import sqrt\np, y = [int(x) for x in input().split()]\n\ndef isprime(n):\n if n % 2 == 0 and n > 2:\n return False\n if p == 2:\n return True\n for x in range(3, min(int(sqrt(n)) + 1, p), 2):\n if n % x == 0:\n return False\n return True\n\nfor i in range(y, p,-1):\n if isprime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "import math as M\n\np, y = [int(x) for x in input().split()]\n\nlim = min(int(M.sqrt(y)) + 1, p) + 1\nprimes = []\n\nfor n in range(2, lim):\n for m in range(2, int(M.sqrt(n)) + 1):\n if n % m == 0:\n break\n else:\n primes.append(n)\n\nfor k in range(y, 1, -1):\n for m in primes:\n if k % m == 0:\n break\n else:\n print(k)\n break\nelse:\n print(-1)\n#\n# arr = [True] * (y + 1)\n# for i in range(2, min(M.ceil(M.sqrt(y)), p) + 2):\n# if arr[i]:\n# k = i\n# while k < y + 1:\n# arr[k] = False\n# k += i\n#\n# # print(arr)\n# for k in range(y, 1, -1):\n# if arr[k]:\n# print(k)\n# break\n# else:\n# print(-1)\n"}, {"source_code": "from sys import stdin\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i = i + 6\n return True\n\n\nx, y = map(int, stdin.readline().rstrip().split(\" \"))\n\nf = 0\n\nfor i in range(x+1, y+1):\n if is_prime(i):\n f = i\n break\n\nif f == 0:\n print(-1)\nelse:\n print(y - y%f)"}, {"source_code": "n,y = map(int,input().split())\nl=[]\ni=max(n+1,y-n-(y-n)%n)\nwhile i<y:\n\tl.append(i)\n\ti+=1\nif len(l)==0:\n\tprint(-1)\nelse:\n\tfor i in l:\n\t\tif i%n==0:\n\t\t\tl.remove(i)\n\tprint(max(l))"}, {"source_code": "a = input() # grasshoppers 2 to p\nb = a.split() # highest branch\nx = int(b[0])# grasshoppers 2 to p\ny = int(b[1])# highest branch\n#print (x, y)\nimport math\n#find primes high down\nsearch = []\nfor i in range(max(2, y-1000), y+1):\n search.append(i)\nsearch = search[::-1]\n#print (search)\ncheck = 0\nsearcher = 0\ntruefail = 0\nprimelist = []\n#print (x)\nif x > 10000:\n x = 10000\nfail = 0\nfor i in range(2, x+1):\n for j in primelist:\n fail = 0\n if (i % j) == 0:\n fail = 1\n break\n if fail == 0:\n primelist.append(i)\nwhile check == 0:\n fail = 0\n z = min(x+1, math.floor(math.sqrt(search[searcher])+10))\n for i in range(2, z):\n #print (\"CHECK\", search[searcher], i)\n if (search[searcher] % i == 0):\n fail = 1\n break\n if fail == 0:\n check = 1\n else:\n searcher += 1\n \n if searcher > 100 or searcher == len(search):\n truefail = 1\n break\nif truefail == 1:\n print (-1)\nelse:\n print (search[searcher])\n"}, {"source_code": "import math,sys\nfrom collections import Counter, defaultdict\nfrom sys import stdin, stdout\n#input = stdin.readline\nlili=lambda:list(map(int,sys.stdin.readlines()))\nli = lambda:list(map(int,input().split()))\n\ndef checkprime(a):\n if a%2:\n return True\n for i in range(2,min(p,int(a**0.5)+1)):\n if a%i == 0:\n return False\n return True\np, y = map(int, input().split())\nfor i in range(y, p, -1):\n if checkprime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "import math\nimport sys\n\n\ndef is_prime(n, p):\n if n % 2 == 0 and n > 2:\n return False\n for i in range(3, int(math.sqrt(n)) + 1, 2):\n if i > p: break\n print(i)\n if n % i == 0:\n return False\n return True\n\n\ndef main():\n p, y = map(int, sys.stdin.readline().split())\n\n highest = y\n if y % 2 == 0:\n highest -= 1\n while highest > p:\n if is_prime(highest, p):\n print(highest)\n return\n highest -= 2\n\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "p,y=map(int,input().split())\n\n\n\nj=y\nans=-1\nt=True\nwhile j>p and t:\n\tfor i in range(2,int(j**0.5)+1):\n\t\tif j%i==0:\n\t\t\tbreak\n\telse:\n\t\tt=False\n\t\tans=j\n\tj-=1\n\nprint(ans)"}, {"source_code": "p,y = map(int, input().split())\n\ndef is_div(a, m):\n if a % 2 == 0 or a % 3 == 0:\n return True\n i = 5\n m = min(m, a ** 0.5)\n while i < m:\n if a % i == 0 or (i + 2 < m and a % (i + 2) == 0):\n return True\n i += 6\n return False \n\nfor i in range(y - int(y % 2 == 0), p, -2):\n if not is_div(i, p):\n print(i)\n exit(0)\n \nprint(-1)"}, {"source_code": "p,y = map(int,raw_input().split())\nfor a in xrange(y,p,-1):\n\tf = 1\n\tfor b in xrange(2,min(int(a**0.5)+1,y)):\n\t\tif a%b==0:\n\t\t\tf = 0\n\t\t\tbreak\n\tif f:\n\t\tprint a\n\t\texit(0)\nprint -1"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Mar 7 09:39:50 2018\n\n@author: wangjun\n\"\"\"\nimport math\n\n\ndef Grasshopper(ng,nb):\n \n if nb%2 ==0 :\n nb=nb-1\n nng = math.floor( ng ** 0.5 )\n if nng <3:\n nng=3\n for branch in range(nb,ng,-2):\n flag =True\n for hopper in range(3,nng+1,2):\n if branch % hopper == 0:\n flag = False\n break\n if flag==True : \n return branch\n return -1\n \ndef hello():\n \"\"\"Print \"Hello World\" and return None\"\"\"\n ar = list(map(int, input().strip().split(' ')))\n \n result=Grasshopper(ar[0],ar[1])\n print(result)\n# main program starts here\nhello()"}, {"source_code": "import math as M\n\np, y = [int(x) for x in input().split()]\n\nlim = min(int(M.sqrt(y)) + 1, p) + 1\nprimes = []\n\nfor n in range(2, lim):\n for m in range(2, int(M.sqrt(n)) + 1):\n if n % m == 0:\n break\n else:\n primes.append(n)\n\nfor k in range(y, 1, -1):\n for m in primes:\n if k % m == 0:\n break\n else:\n print(k)\n break\nelse:\n print(-1)\n#\n# arr = [True] * (y + 1)\n# for i in range(2, min(M.ceil(M.sqrt(y)), p) + 2):\n# if arr[i]:\n# k = i\n# while k < y + 1:\n# arr[k] = False\n# k += i\n#\n# # print(arr)\n# for k in range(y, 1, -1):\n# if arr[k]:\n# print(k)\n# break\n# else:\n# print(-1)\n"}, {"source_code": "from math import sqrt\n\np, y = list(map(int, input().split()))\n\nyp = int(sqrt(y))\n\nif yp > p:\n yp = p\n\nif p == 2: \n if y == 2:\n print(-1)\n exit()\n if y % 2 == 0:\n print(y-1)\n exit()\n else:\n print(y)\n exit()\n \n \nif yp % 2 == 0: yp += 1\n\nif y % 2 == 0: y -= 1\n\n\nif yp == 1:\n if y > 2 and y % 2 == 0:\n print(y-1)\n exit()\n else:\n print(y)\n exit()\n\nwhile y > p:\n yr = yp\n while yr > 2:\n if y % yr == 0:\n yr -= 2\n break\n\n elif yr == 3:\n print(y)\n exit()\n\n elif yr > 3:\n yr -= 2\n\n\n y -= 2\n\nprint(\"-1\")"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 8 21:52:51 2018\n\n@author: Nikita\n\"\"\"\nfrom math import ceil, sqrt\np, y = map(int, input().split())\ny_copy = y\nwhile y >= y_copy - 300 and y > p:\n ok = True\n for div in range(2, min(p, ceil(sqrt(y)) + 1)):\n if y % div == 0:\n ok = False\n break\n if ok:\n print(y)\n break\n else:\n y -= 1\nif y == y_copy - 301 or y == p:\n print(-1)\n"}, {"source_code": "n,m = map(int,input().split())\nimport math\ndef is_prime(n):\n if n % 2 == 0 and n > 2: \n return False\n for i in range(3, int(math.sqrt(n)) + 1, 2):\n if n % i == 0:\n return False\n return True\nfor x in range(m,n,-1):\n if is_prime(x):\n print(x)\n break\nelse:\n print (-1)\n\n"}, {"source_code": "import time\np,y=map(int,input().split())\nstart=time.time()\ndef is_prime(n):\n \n if n == 2 or n == 3: return True\n if n < 2 or n%2 == 0: return False\n if n < 9: return True\n if n%3 == 0: return False\n r = int(n**0.5)\n f = 5\n while f <= r:\n if n%f == 0: return False\n if n%(f+2) == 0: return False\n f +=6\n return True\n\nif(p+1>=y):\n print(-1)\nelse:\n ans=0\n for e in range(y,1,-1):\n if is_prime(e):\n ans=max(ans,e)\n break\n else:\n print(-1)\n if p < 10**9:\n for e in range(y,ans-1,-1):\n for i in range(2,int(y**0.5)+2):\n if(i>p):\n continue\n if(e%i)==0:\n break\n else:\n print(e)\n break\n else:\n print(-1)\n else:\n print(e)\n\"\"\" \nfor e in range(y,1,-1):\n for i in range(2,p+1):\n if(e%i)==0:\n break\n else:\n print(e)\n break\"\"\""}, {"source_code": "import math\ndef fact(n): \n while n % 2 == 0: \n s.add(2)\n n = n / 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n s.add(i)\n n = n / i \n if n > 2: \n s.add(n)\ninput=__import__('sys').stdin.readline\np,y = map(int,input().split())\ns=set()\nmm = y-max(y-200,p)\nfor i in range(mm):\n fact(y)\n l=sorted(s)\n# print(l)\n if int(l[0])>p:\n print(y)\n exit()\n s = set()\n y-=1\nprint(-1)\n\n\n"}, {"source_code": "import time\np,y=map(int,input().split())\nstart=time.time()\ndef is_prime(n):\n \n if n == 2 or n == 3: return True\n if n < 2 or n%2 == 0: return False\n if n < 9: return True\n if n%3 == 0: return False\n r = int(n**0.5)\n f = 5\n while f <= r:\n if n%f == 0: return False\n if n%(f+2) == 0: return False\n f +=6\n return True\n\nif(p+1>=y):\n print(-1)\nelse:\n ans=0\n for e in range(y,1,-1):\n if is_prime(e):\n ans=max(ans,e)\n break\n else:\n print(-1)\n if p < 100:\n for e in range(y,ans-1,-1):\n for i in range(2,p+1):\n if(e%i)==0:\n break\n else:\n print(e)\n break\n else:\n print(e)\n \nfor e in range(y,1,-1):\n for i in range(2,p+1):\n if(e%i)==0:\n break\n else:\n print(e)\n break"}, {"source_code": "'''input\n10000 100000000\n'''\nfrom math import sqrt\np=[]\npr=[1]*(10**5)\npr[1]=0\npr[0]=0\n\nfor i in range(4,10**5,2):\n pr[i]=0\nfor i in range(3,400,2):\n if pr[i]:\n for j in range(i*i,10**5,2*i):\n pr[j]==0\nfor i in range(10**5):\n if pr[i]:\n p.append(i)\ndef prime(n):\n sq=int(sqrt(n))+1\n for i in p:\n if i>sq:\n return True\n if n%i==0:\n return False\n return True\nppp,n=[int(x) for x in raw_input().split()]\n\nsq=int(n**0.5)+1\n\nlp=n\nif lp%2==0:\n lp-=1\nans=-1\nwhile lp>ppp:\n if prime(lp):\n ans=max(ans,lp)\n break\n lp-=2\npp=ppp\nwhile sq>ppp:\n if prime(sq):\n ans=max(ans,sq*sq)\n break\n sq-=1\n\nprint ans \n\n"}, {"source_code": "from math import sqrt\n\ndef modpow(a, prime, mod):\n if prime == 1:\n return a % mod\n if mod % 2 == 1:\n return (a * modpow(a, prime - 1, mod)) % mod\n return ((modpow(a, prime/2, mod)) * (modpow(a, prime/2, mod))) % mod\n\ndef isPrime(prime):\n a, b, c = 10, 27, 38\n if modpow(a, prime, prime) == (a % prime) and modpow(b, prime, prime) == (b % prime) and modpow(c, prime, prime) == (c % prime):\n return True\n return False\n\ndef minPrimeDiv(n):\n for i in range(2, int(n / 3) + 1):\n if n % i == 0 and isPrime(i):\n return i\n return 0\n\n\np, y = list(map(int, input().split()))\nans = y\n\ndone = False\ns = ''\nfor i in reversed(range(2, y+1)):\n if minPrimeDiv(i) > p:\n s += f' {minPrimeDiv(i)}'\n print(i)\n done = True\n break\nif not done:\n print(-1) \n\n#print(s)\n\n#print(isPrime(3), isPrime(4), isPrime(5))\n#print(modpow(10, 3, 3), modpow(27, 3, 3), modpow(38, 3, 3))"}, {"source_code": "from sys import stdin\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i = i + 6\n return True\n\n\nx, y = map(int, stdin.readline().rstrip().split(\" \"))\n\nf = 0\n\nfor i in range(x+1, y+1):\n if is_prime(i):\n f = i\n break\nr = 0\nif y%2==0:\n s = y-1\nelse:\n s = y\n\nif f == 0:\n print(-1)\n\nelse:\n for i in range(s, y - y % f, -2):\n if is_prime(i):\n r = i\n break\n print(max(r,y -y%f))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 8 13:52:12 2018\n\n@author: Nikita\n\"\"\"\n\nfrom math import ceil, sqrt\np, y = map(int, input().split())\nL = [True for _ in range(y - p + 1)]\nfor div in range(2, max(p, ceil(sqrt(y))) + 1):\n num = div * max(div, ceil(p / div))\n while num <= y:\n L[num - p] = False\n num += div\ni = len(L) - 1\nL[0] = False\nwhile i > 0:\n if L[i]:\n print(p + i)\n break\n else:\n i -= 1\n \nif i == 0:\n print(-1)\n"}, {"source_code": "p,y = map(int,input().split())\n\nfor x in range(y,p,-1):\n\t# print(x)\n\t# check\n\tflag = True\n\tfor i in range(2,min(p,int(x**0.5)+1)):\n\t\tif x%i == 0:\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tprint(x)\n\t\texit()\n\nprint(-1)"}, {"source_code": "n,y = map(int,input().split())\nc=n*2-1\nif c<y and c!=n:\n\tprint(c)\nelif c==y and c!=n:\n\tprint(c-1)\nelse:\n\tprint(-1)\n"}, {"source_code": "import random\ndef FermatPrimalityTest(number):\n if (number > 1):\n for time in range(3):\n randomNumber = random.randint(2, number)-1\n if ( pow(randomNumber, number-1, number) != 1 ):\n return False\n\n return True\n else:\n return False\n\np, y = [int(x) for x in input().split()]\nans = -1\nfor i in range(p+1, y+1):\n if FermatPrimalityTest(i):\n ans = i\n break\nprint(ans)"}, {"source_code": "import time\np,y=map(int,input().split())\nstart=time.time()\ndef is_prime(n):\n \n if n == 2 or n == 3: return True\n if n < 2 or n%2 == 0: return False\n if n < 9: return True\n if n%3 == 0: return False\n r = int(n**0.5)\n f = 5\n while f <= r:\n if n%f == 0: return False\n if n%(f+2) == 0: return False\n f +=6\n return True\n\nif(p+1>=y):\n print(-1)\nelse:\n ans=0\n for e in range(y,1,-1):\n if is_prime(e):\n ans=max(ans,e)\n break\n else:\n print(-1)\n if p < 10**9:\n for e in range(y,ans-1,-1):\n for i in range(2,int(y**0.5)+2):\n if(e%i)==0:\n break\n else:\n print(e)\n break\n else:\n print(e)\n\"\"\" \nfor e in range(y,1,-1):\n for i in range(2,p+1):\n if(e%i)==0:\n break\n else:\n print(e)\n break\"\"\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 8 13:52:12 2018\n\n@author: Nikita\n\"\"\"\n\nfrom math import ceil, sqrt\np, y = map(int, input().split())\nL = [True for _ in range(y - p + 1)]\nfor div in range(2, max(p, ceil(sqrt(y))) + 1):\n num = div * max(div, ceil(p / div))\n while num <= y:\n L[num - p] = False\n num += div\ni = len(L) - 1\nL[0] = False\nwhile i > 0:\n if L[i]:\n print(p + i)\n break\n else:\n i -= 1\n \nif i == 0:\n print(-1)\n"}, {"source_code": "p,y = map(int, input().split())\n\ndef is_div(a):\n if a % 2 == 0 or a % 3 == 0:\n return True\n i = 5\n while i < a:\n if a % i == 0:\n return True\n if i + 2 < a and a % (i + 2) == 0:\n return True\n i += 6\n return False \n\nfor i in range(y, p, -1):\n if not is_div(i):\n print(i)\n exit(0)\n \nprint(-1)"}, {"source_code": "import math\n\"\"\"def Prime_check(x,y):\n\tfor i in range(2,math.sqrt(y)+1):\n\t\tif(x%y==0):\n\t\t\tfalse\n\"\"\"\ndef Prime_check(val,y):\n\tfor i in range(2,int(math.sqrt(val))):\n\t\tif(i>y):\n\t\t\tbreak\n\t\telif(val%i==0):\n\t\t\treturn(False)\n\treturn(True)\nt=list(map(int,input().split()))\ncount=-1\nif(t[0]==2 and t[0]!=t[1]):\n\tif(t[1]%2==0):\n\t\tprint(t[1]-1)\n\telif(t[1]==t[0]):\n\t\tprint(-1)\n\telse:\n\t\tprint(t[1])\nelif(t[0]==t[1]):\n\tprint(-1)\nelse:\n\tfor val in range(t[1],t[0],-1):\n\t\tif(Prime_check(val,t[1])):\n\t\t\tprint(val)\n\t\t\tcount=1\n\t\t\tbreak\n\tif(count==-1):\n\t\tprint(-1)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Mar 7 09:39:50 2018\n\n@author: wangjun\n\"\"\"\nimport math\n\n\ndef Grasshopper(ng,nb):\n \n if nb%2 ==0 :\n nb=nb-1\n if nb == ng:\n return -1\n if ng ==2 :\n return nb\n nng = math.floor( nb ** 0.5 )\n if nng >ng :\n nng=ng\n \n for branch in range(nb,ng,-2):\n flag =True\n for hopper in range(3,nng+1,2):\n if branch % hopper == 0:\n flag = False\n break\n if flag==True : \n if branch > ng :\n return branch\n else:\n return -1\n return -1\n \ndef hello():\n \"\"\"Print \"Hello World\" and return None\"\"\"\n ar = list(map(int, input().strip().split(' ')))\n \n result=Grasshopper(ar[0],ar[1])\n print(result)\n# main program starts here\nhello()"}, {"source_code": "import time\np,y=map(int,input().split())\nstart=time.time()\ndef is_prime(n):\n \n if n == 2 or n == 3: return True\n if n < 2 or n%2 == 0: return False\n if n < 9: return True\n if n%3 == 0: return False\n r = int(n**0.5)\n f = 5\n while f <= r:\n if n%f == 0: return False\n if n%(f+2) == 0: return False\n f +=6\n return True\n\nif(p+1>=y):\n print(-1)\nelse:\n ans=0\n for e in range(y,1,-1):\n if is_prime(e):\n ans=max(ans,e)\n break\n else:\n print(-1)\n if p < 100:\n for e in range(y,ans-1,-1):\n for i in range(2,p+1):\n if(e%i)==0:\n break\n else:\n print(e)\n break\n else:\n print(e)\n "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Mar 7 09:39:50 2018\n\n@author: wangjun\n\"\"\"\nimport math\n\n\ndef Grasshopper(ng,nb):\n \n if nb%2 ==0 :\n nb=nb-1\n nng = math.floor( nb ** 0.5 )\n if nng >ng :\n nng=ng\n if nng < 3:\n nng=3 \n \n for branch in range(nb,ng,-2):\n flag =True\n for hopper in range(3,nng+1,2):\n if branch % hopper == 0:\n flag = False\n break\n if flag==True : \n return branch\n return -1\n \ndef hello():\n \"\"\"Print \"Hello World\" and return None\"\"\"\n ar = list(map(int, input().strip().split(' ')))\n \n result=Grasshopper(ar[0],ar[1])\n print(result)\n# main program starts here\nhello()"}, {"source_code": "from math import ceil\ndef prime(x):\n if x % 2 == 0 or x % 3 == 0:\n return False\n \n if x == 3 or x == 5 or x == 7:\n return True\n\n for i in range(7, ceil(x**0.5), 2):\n if x % i == 0:\n return False\n \n return True\n \np, y = map(int, input().split())\nfor i in range(y, p, -1):\n if prime(i):\n print(i)\n exit()\nprint(-1)"}, {"source_code": "from sys import stdin\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i = i + 6\n return True\n\n\nx, y = map(int, stdin.readline().rstrip().split(\" \"))\n\nf = 0\n\nfor i in range(x+1, y+1):\n if is_prime(i):\n f = i\n break\nr = 0\nif y%2==0:\n s = y-1\nelse:\n s = y\n\nif f == 0:\n print(-1)\n\nelse:\n for i in range(s, y - y % f, -2):\n if is_prime(i):\n r = i\n break\n print(max(r,y -y%f))"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Feb 25 21:50:26 2018\n\n@author: manish\n\"\"\"\n\nd = ['3','6']\n\ndef chef(d):\n d = list(map(int,d))\n p,y = d[0], d[1]\n \n list1 = []\n for i in range(2,p+1):\n list1.append(i)\n m = []\n \n for i in range(0, len(list1)):\n for j in range(1, int(y/list1[i])+1):\n# print(list1[i+1:])\n if j*list1[i] in m or j*list1[i] in list1[i+1:]:\n break\n m.append(j*list1[i])\n# m.sort()\n# if m[-1] < y:\n# print('yes')\n# print(m[-1]+1)\n# for i in range(m[-1]+1, y+1):\n# print(i)\n# m.append(i)\n m.sort(reverse = True)\n# print(m)\n# print(m)\n ans = -1\n for i in range(0, len(m)-1):\n if m[i]<y and y not in m:\n ans = y\n break\n if m[i+1] != m[i]-1:\n ans = m[i]-1\n break\n return ans\n \ndef main():\n\n d= input().split()\n\n print(chef(d))\n\n \nmain()"}, {"source_code": "from math import factorial\np, y = [int(x) for x in input().split()]\nr = factorial(p)\nif r - 1 > y:\n print(-1)\nelse:\n print(r - 1)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Feb 25 21:50:26 2018\n\n@author: manish\n\"\"\"\n\nd = ['3','6']\n\ndef chef(d):\n d = list(map(int,d))\n p,y = d[0], d[1]\n \n list1 = []\n for i in range(2,p+1):\n list1.append(i)\n m = []\n for i in range(0, len(list1)):\n for j in range(1, int(y/p)+1):\n m.append(j*list1[i])\n m.sort()\n \n ans = -1\n for i in range(0, len(m)-1):\n if m[i+1] != m[i]+1:\n ans = m[i]+1\n break\n return ans\n \ndef main():\n\n d= input().split()\n\n print(chef(d))\n\n \nmain()"}, {"source_code": "from math import sqrt\n\np, y = list(map(int, input().split()))\n\nyp = int(sqrt(y))\n\nif yp > p:\n yp = p\n\nif p == 2: \n if y == 2:\n print(-1)\n exit()\n if y % 2 == 0:\n print(y-1)\n exit()\n else:\n print(y)\n exit()\n \n \nif yp % 2 == 0: yp += 1\n\nif y % 2 == 0: y -= 1\n\n\nif yp == 1:\n if y > 2 and y % 2 == 0:\n print(y-1)\n exit()\n else:\n print(y)\n exit()\n\nwhile y > p:\n yr = yp\n while yr > 2:\n if y % yr == 0:\n yr -= 2\n break\n\n elif yr == 3:\n print(y)\n exit()\n\n elif yr > 3:\n yr -= 2\n\n\n y -= 2\n\nprint(\"-1\")"}], "src_uid": "b533203f488fa4caf105f3f46dd5844d"} {"source_code": "n = input()\nw = [int(wi) for wi in raw_input().split(\" \")]\nsumw = sum(w)\nif 100 in w and (sumw%200) == 0:\n\tprint \"YES\"\n\texit()\t\nelif (sumw%400) == 0:\n\tprint \"YES\"\n\texit()\nprint \"NO\"", "positive_code": [{"source_code": "n = input()\n\nvals = map(int, raw_input().split())\n\nc1 = 1\nc2 = 1\n\nfor val in vals:\n if val == 100:\n c1 += 1\n else:\n c2 += 1\n\ndef can_sum(a,b,c,d):\n return any(p1+2*p3==p2+2*p4 for p1,p2 in [(a,c), (c,a)] for p3,p4 in [(b,d), (d,b)])\n\nfor i in range(c1):\n xt1 = c1-i-1\n xo1 = i\n for j in range(c2):\n xt2 = c2-j-1\n xo2 = j\n if can_sum(xt1, xt2, xo1, xo2):\n print \"YES\"\n exit(0)\n\nprint \"NO\"\n"}, {"source_code": "n = int( raw_input() )\nw = map( int, raw_input().split() )\n\nw1, w2 = 0, 0\n\nw.sort( reverse = True )\n\nfor num in w: \n if ( w1 <= w2 ): \n w1 += num\n else: \n w2 += num\n \nprint \"YES\" if ( w1 == w2 ) else \"NO\""}, {"source_code": "input();a=map(int,raw_input().split());c=sum(a);print'YES'if c%400==0 or (c%200==0 and 100 in a) else'NO'\n"}, {"source_code": "n =map(int,raw_input())\nweights = map(int,raw_input().split())\ntotal = sum(weights)\nif total%200!=0:\n print \"NO\"\nelse:\n req_weight = total/2;\n hundred_bsc=0;\n twohundred_bsc=0;\n flag=0\n for i in range(0,len(weights)):\n if weights[i] == 100:\n hundred_bsc += 1;\n else:\n twohundred_bsc += 1;\n if req_weight%200==0:\n if req_weight/200 <= twohundred_bsc:\n twohundred_bsc -= req_weight/200\n flag=1\n elif req_weight/100 <= hundred_bsc:\n hundred_bsc -= req_weight/100\n flag=1\n else:\n temp_weight = twohundred_bsc*200;\n twohundred_bsc=0;\n if((req_weight - temp_weight)/100 <= hundred_bsc):\n hundred_bsc -= (req_weight-temp_weight)/100;\n flag=1\n elif req_weight%100 == 0:\n if req_weight/100 <= hundred_bsc:\n hundred_bsc -= req_weight/100;\n flag=1;\n else:\n temp_bsc = 1;\n while((temp_bsc <= hundred_bsc) and (flag==0)):\n temp_weight = temp_bsc*100;\n var = req_weight - temp_weight\n if((var/200) <= twohundred_bsc):\n twohundred_bsc -= (var)/200;\n flag=1;\n else:\n temp_bsc += 2;\n if flag==1:\n hundred_bsc -= temp_bsc;\n if flag==1:\n #print hundred_bsc\n #print twohundred_bsc\n if((hundred_bsc*100 + twohundred_bsc*200)==req_weight):\n print \"YES\"\n else:\n print \"NO\"\n else:\n print \"NO\"\n\n"}, {"source_code": "n=int(raw_input())\na = map(int, raw_input().split())\nx,y = 0,0\nfor i in a:\n if i==100:\n x+=1\n else:\n y+=1\nif x>=2 and x%2==0:\n print \"YES\"\nelif x==0 and y%2==0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "input();a=map(int,raw_input().split());c=sum(a);print'YES'if c%400==0 or (c%200==0 and 100 in a) else'NO'\n"}, {"source_code": "input();a=map(int,raw_input().split());c=sum(a);print'YES'if c%400==0 or (c%200==0 and 100 in a) else'NO'"}, {"source_code": "n = int(raw_input())\nw = raw_input().split()\n\nsoma = 0\nfor i in w:\n\tsoma += int(i)\n\nif soma % 200 == 0 and (soma != 200 * n or n % 2 == 0):\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "n = int(input())\n\na = list(map(int,input().split()))\n\nn1 = a.count(100)\nn2 = n-n1\nif n1>0 and n2>0:\n if n2%2 ==0:\n if n1%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n if (n1-2)%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\nelif n1%2==0 and n2%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\narr = input().split()\no = t = 0\nfor _ in arr:\n if _=='100':o+=1\n else:t+=1\nif o%2==0 and t%2==0 or o>1 and t%2 and o%2==0:\n print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "__author__ = 'lyric_seraph'\n\nimport sys\n\ndef main():\n n = raw_input()\n n = int(n)\n num = raw_input()\n num = num.split()\n num = [int(nums) for nums in num]\n cnt = [0, 0]\n for i in num:\n if i == 100:\n cnt[0] += 1\n else:\n cnt[1] += 1\n while cnt[1] > 0:\n if cnt[1] >= 2:\n cnt[1] -= 2\n elif cnt[0] >= 2:\n cnt[1] -= 1\n cnt[0] -= 2\n else:\n break\n while cnt[0] > 0:\n if cnt[0] >= 2:\n cnt[0] -= 2\n else:\n break\n if cnt[0] + cnt[1] > 0:\n print 'NO'\n else:\n print 'YES'\n\n\nif __name__ == '__main__':\n exit(main())"}, {"source_code": "import operator\nfrom sys import stdin\n\nn = int(input())\nk = [int(i) for i in stdin.readline().split()]\no = k.count(100)\nt = k.count(200)\nif (o + (t*2)) % 2 == 1: print(\"NO\")\nelif (t%2==1 and o < 1): print(\"NO\")\nelse: print(\"YES\")\n\n\n \n\n"}, {"source_code": "n=input()\nw=map(int,raw_input().split())\nh,t=w.count(100),w.count(200)\ng=sum(w)\n\nif (g/100)%2==1 or n==1: #geen even honderdtal\n print 'NO'\nelse:\n d=g/2\n while d>100 and t>0:\n d-=200\n t-=1\n if h*100>=d:\n print 'YES'\n else:\n print 'NO'\n \n \n \n "}, {"source_code": "n=int(input())\ns=input().split()\nc1=s.count('100');c2=n-c1\nprint('YES'if c1 and c2 and c1==2*c2 or not c2 and not c1%2 or not c1 and not c2%2 or c1>c2%2 and (c1-2*c2%2)%2==0 else 'NO')\n"}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\nh = arr.count(100)\nt = arr.count(200)\nif(n%2==0):\n if(n==h or n==t):\n print(\"YES\")\n elif(h%2==0):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if(h==0 or t==0):\n print(\"NO\")\n elif(h%2!=0):\n print(\"NO\")\n else:\n print(\"YES\")\n"}, {"source_code": "t=int(input())\ns=map(int,raw_input().split())\na=sum(s)\n\nif(len(s)==1):\n\tprint \"NO\"\n\t\nelif(a%2!=0):\n\tprint \"NO\"\nelse:\n\tfirst=0\n\tsecond=0\n\ts.sort()\n\ti=len(s)-1\n\twhile(i>=0):\n\t\tif(first>second):\n\t\t\tsecond+=s[i]\n\t\telse:\n\t\t\tfirst+=s[i]\n\t\ti-=1\n#\tprint first,second\n\tif(first==second):\n\t\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "n = int(raw_input())\nw = map(int, raw_input().split())\na = w.count(100)\nb = w.count(200)\nif a % 2 == 1:\n\tprint \"NO\"\nelif a == 0 and b % 2 == 1:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"\n\n\n"}, {"source_code": "import sys\nfrom collections import Counter\nsys.stdin.readline()\napples=[int(x) for x in sys.stdin.readline().split(' ')]\nc=Counter(apples)\nif c[100]==0 and c[200]%2==0:\n print 'YES'\nelif c[100]%2==0 and c[100]!=0:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n=input()\ndata=map(int,raw_input().split())\na=data.count(100)\nb=data.count(200)\nif a%2==1 or (b%2==1 and a==0):\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "n = int(input())\nlst = list(map(int, input().split()))\ntouma = 0\nogiso = 0\nlst.sort(reverse=True)\nnewlst = lst.copy()\ny = int(sum(lst)/2)\n\n\nfor item in lst:\n if touma + item <= y:\n touma = touma + item\n newlst.remove(item)\n continue\n if ogiso + item <= y:\n ogiso = ogiso + item\n newlst.remove(item)\nif touma == ogiso and len(newlst) == 0:\n print('YES')\nelse:\n print('NO')\n \n"}, {"source_code": "n=int(input())\na=[int(x)//100 for x in input().split()]\nif sum(a)%2==1 or (min(a)==2 and sum(a)%4!=0):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "import sys\nfrom time import time\n\nn=int(sys.stdin.readline().strip('\\n'))\nline=sys.stdin.readline().strip('\\n').split(\" \")\nw=map(lambda x:int(x),line)\nnum100=0\nnum200=0\nfor x in w:\n if x==100:\n num100+=1\n else:\n num200+=1\nif num100%2==0 and (num200%2==0 or num100>0):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n = int(raw_input())\napples = raw_input().split()\napples = map(int, apples)\nsoma = sum(apples)\n\nif n <= 1:\n\tprint \"NO\"\nelif soma == 200 * n and n % 2 != 0:\n\tprint \"NO\"\nelif soma % 200 == 0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "n=int(input())\nl=[int(i) for i in input().split()]\ns=sum(l)\ndp=[0]*(s+5)\ndp[0]=1\nfor i in l:\n for j in range(s+5):\n if i<=j:\n if dp[j-i]:\n dp[j]=1 \nif s%2!=0:\n print('NO')\n exit()\nprint('YES' if dp[s//2] else 'NO')"}, {"source_code": "n = int(input())\nweight = list(map(int, input().split()))\n\ncont = 0\n\nfor i in range(n):\n if weight[i] == 100:\n cont = cont + 1\n\nif cont % 2 == 1 or (n % 2 == 1 and cont == 0):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n = int(raw_input())\napples = map(int, raw_input().split())\n\nn1 = apples.count(100)\nn2 = apples.count(200)\n\nif (n1 + 2 * n2) % 2 != 0:\n print 'NO'\nelse:\n v = (n1 + 2 * n2) / 2\n if v % 2 != 0 and n1 == 0:\n print 'NO'\n else:\n print 'YES'"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nif l.count(100)/2==l.count(200):\n print(\"YES\")\nelif (l.count(100))%2==0 and l.count(100)>0:\n print(\"YES\")\nelif l.count(100)==0 and (l.count(200))%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "# coding: utf-8\n\nn = int(raw_input())\nm = map(int, raw_input().split())\n\nif (n==1): print \"NO\"\nelse:\n a1, a2, soma = 0, 0, 0\n for weight in m:\n if (weight == 100): a1 += 1\n else: a2 += 1\n soma += weight\n if (a1+a2*2)%2 == 0:\n if (a1==0) and (a2%2!=0): print \"NO\"\n else: print \"YES\"\n else: print \"NO\"\n"}, {"source_code": "import sys\nfrom collections import defaultdict, Counter\nfrom math import sin, cos, asin, acos, tan, atan, pi\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition, yes = \"YES\", no = \"NO\", none = \"-1\") :\n if condition == None:\n print (none)\n elif condition :\n print (yes)\n else :\n print (no)\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rstr() :\n return sys.stdin.readline().strip()\n\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits[::-1]\n\ndef undigits(x, p) :\n value = 0\n for d in x :\n value *= p\n value += d\n return value\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\ndef vector_distance(a, b) :\n diff = vector_diff(a, b)\n \n return scalar_product(diff, diff) ** 0.5\n\ndef vector_inverse(v) :\n r = [-x for x in v]\n\n return tuple(r)\n\ndef vector_diff(a, b) :\n return vector_sum(a, vector_inverse(b))\n\ndef vector_sum(a, b) :\n r = [c1 + c2 for c1, c2 in zip(a, b)]\n \n return tuple(r)\n\ndef scalar_product(a, b) :\n r = 0\n for c1, c2 in zip(a, b) :\n r += c1 * c2\n\n return r\n\ndef check_rectangle(points) :\n assert(len(points) == 4)\n\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n sides = (\n vector_diff(A1, A2),\n vector_diff(A2, A3),\n vector_diff(A3, A4),\n vector_diff(A4, A1),\n )\n if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :\n return True\n return False\n\ndef check_square(points) :\n if not check_rectangle(points) :\n return False\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n side_lengths = [\n (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])\n ]\n if len(set(side_lengths)) == 1 :\n return True\n \n return False\n\ndef check_right(p) :\n # Check if there are same points\n for a, b in [\n (p[0], p[1]),\n (p[0], p[2]),\n (p[1], p[2]),\n ] :\n if a[0] == b[0] and a[1] == b[1] :\n return False\n\n a, b, c = p\n a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a) \n\n return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0\n\nn = rint()\na = Counter(rints())\n\n\n\npyes_no(a[100] % 2 == 0 and (a[100] > 0 or a[200] % 2 == 0))\n"}, {"source_code": "n=int(input())\nc1=c2=0\nl=[int(x) for x in input().split()]\nfor i in range(n):\n if(l[i]==100):\n c1+=1\n else:\n c2+=1\nif(c1%2==0 and c2%2==0):\n print(\"YES\")\nelif(((c1==0 and c2!=0) and c2%2==0)or((c2==0 and c1!=0) and c1%2==0)):\n print(\"YES\")\nelif(c1%2==0 and c2%2!=0 and c1!=0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nnums = [int(x)//100 for x in input().split()]\nif sum(nums)%2 == 1 or (min(nums)==2 and sum(nums)%4!=0):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}, {"source_code": "n = int(input())\narr = map(int, input().split())\nc = d = 0\n\nfor x in arr:\n if x == 100:\n c+=1\n else:\n d+=1\n\nd = d&1\n\nif c&1 or (d and c < 2):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n = int(raw_input())\nw = map(int, raw_input().split())\nd = 0\nfor i in range(n):\n if w[i] == 200:\n d +=1\nif d%2 == 1:\n if (n-d)%2 == 0 and (n-d)>0:\n print \"YES\"\n else:\n print \"NO\"\nelif (n-d)%2 == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n = int(input())\napples = []\napples[0:n-1] = input().split()\nweight = []\nsum = 0\nfor i in range(n):\n sum += int(apples[i])\n weight.append(int(apples[i]))\ncount100 = 0\nif sum/100%2:\n print(\"NO\")\nelse:\n tk,os = 0,0\n for i in weight:\n if (i == 200):\n if tk > os:\n os += i\n else:\n tk += i\n else:\n count100 += 1\n #print(tk,os,abs(tk - os)/100)\n count100 -= abs(tk - os)/100\n #print(count100)\n if (count100 >= 0):\n tk = os\n if (count100%2 == 0):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")"}, {"source_code": "def ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n \nimport math\n \nn=ii()\na=li()\ns=sum(a)\nb=a.count(100)\nif s%400==0:\n print(\"YES\")\nelse:\n if s%200==0 and b:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "from collections import Counter\n\n\ndef main():\n n = int(input())\n c = Counter(input().split())\n print(('YES', 'NO')[c['100'] & 1 if c['100'] else c['200'] & 1])\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nif a.count(200) == n and n % 2 != 0:\n print('NO')\nelse:\n b = sum(a)\n if b % 200 == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "# -*- coding:utf-8 -*-\n#[n, m] = [int(x) for x in raw_input().split()]\n\ndef some_func():\n \"\"\"\n \"\"\"\n n = input()\n n_list = [ int(x) for x in raw_input().split()]\n f1=n_list.count(100)\n f2=n_list.count(200)\n\n if f2%2==0 and f1%2==0:\n return \"YES\"\n if f2%2==1 and f1 and f1%2==0:\n return \"YES\"\n return \"NO\"\n\n\n\n\n\nif __name__ == '__main__':\n print some_func()\n\n\n\n"}, {"source_code": "n=int(input())\nl=input().split()\ns,s1,s2=0,0,0\nfor i in range(n):\n l[i]=int(l[i])//100\n if(l[i]==1):\n s1+=1\n else:\n s2+=1\n s+=l[i]\nif(s%2!=0 or (n==s2 and s2%2!=0)):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "#coding: utf-8\n\nqtd = int(raw_input())\nweight = map(int, raw_input().split())\n\ndicio = {100: 0, 200: 0}\n\nfor i in xrange(qtd):\n dicio[weight[i]] += 1\n\nif dicio[100] % 2 != 0: # 200 nao importa\n ans = \"NO\"\nelse:\n if dicio[100] == 0 and dicio[200] % 2 != 0:\n ans = \"NO\"\n else:\n ans = \"YES\"\n\nprint ans"}, {"source_code": "n=int(input())\narr=[int(x)//100 for x in input().split(' ')]\none=arr.count(1)\ntwo=n-one\nif sum(arr)&1:\n\tprint(\"NO\")\nelse:\n\tif two:\n\t\tif sum(arr)//2 % 2==0:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tif one:\n\t\t\t\tprint(\"YES\")\n\t\t\telse:\n\t\t\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")"}, {"source_code": "def solve(w):\n n = len(w)\n if n < 2: return False\n a, b = w.count(100), w.count(200)\n s = a*100+b*200 \n if s % 200 != 0: return False\n t = s/2\n for i in range(0, b+1):\n if 200*i > t: break\n c = (t-200*i)/100\n if c <= a: return True\n return False\n\nn = int(raw_input())\nw = map(int, raw_input().split())\nprint 'YES' if solve(w) else 'NO'\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\np=a.count(100)\nq=a.count(200)\nif p>0 and q==0:\n if p%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\nelif q>0 and p==0:\n if q%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n \n\n if p>q:\n z=2*q\n k=1*p\n if z==k or (z%2==0 and k%2==0):\n print(\"YES\")\n else:\n print(\"NO\")\n elif q>p:\n z=2*q\n k=1*p\n if z==k or (z%2==0 and k%2==0):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n \n \n if p%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\n \n"}, {"source_code": "n = int(input())\nw = list(map(int, input().split()))\n\none_hundred = w.count(100)\ntwo_hundred = w.count(200)\n\nif one_hundred % 2 == 1 or (two_hundred % 2 == 1 and one_hundred == 0):\n print('NO')\nelse:\n print('YES')"}, {"source_code": "#A. Kitahara Haruki's Gift\nn = input()\ndic = {100:0,\n 200:0}\na = list(map(int,input().split()))\nfor i in a:\n dic[i]+=1\n#case when both are even\nif dic[100]%2==0 and dic[200]%2==0:\n print('YES')\nelif dic[200]%2!=0 and dic[100]%2==0 and dic[100]>=2 :\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\n\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\n\nn = int(input())\nw = list(map(int, input().split()))\none = w.count(100)\ntwo = w.count(200)\n# print(one)\n# print(two)\nif (one * 0.5 == two) or (two % 2 == 0 and one % 2 == 0) or (two % 2 == 1 and one % 2 == 0 and one >= 2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\nlst = list(map(int, input().split()))\nod,ev = 0,0\nfor i in range(len(lst)):\n if lst[i] == 200:\n od += 1\n else:\n ev += 1\nif ((not(od % 2)) and (not(ev % 2))) or ((od % 2) and (ev > 1) and (not(ev%2))):\n print('YES')\nelse:\n print('NO')\n#Balamar"}, {"source_code": "n = int(input())\nlst = list(map(int, input().split()))\nod,ev = 0,0\nfor i in range(n):\n if lst[i] == 200:\n od += 1\n else:\n ev += 1\nif ((not(od % 2)) and (not(ev % 2))) or ((od % 2) and (ev > 1) and (not(ev%2))):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nprint('NO' if sum(a) / 100 % 2 or n == 1 or (sum(x % 200 for x in a) == 0 and n % 2) else 'YES')\n"}, {"source_code": "a = input()\nb = input()\n\na = int(a)\nb = [int(i) for i in b.split(' ')]\n\nc1 = c2 = 0\nfor i in b:\n if i == 100:\n c1 += 1\n else:\n c2 += 1\nc2 %= 2 # 0,1\nc1 -= c2 * 2\nif c1 < 0 or c1 % 2 == 1:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\nif __name__ == \"__main__\":\n\tn = int(sys.stdin.readline())\n\tais = list(map(int, sys.stdin.readline().split()))\n\tweights = {100:ais.count(100), 200:ais.count(200)}\n\ttotal = 100*weights[100] + 200*weights[200]\n\tif (total//100)%2 != 0 or n <= 1:\n\t\tprint(\"NO\")\n\telse:\n\t\tif weights[200] % 2 == 1 and weights[100] <=0:\n\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"YES\")\n"}, {"source_code": "#mudando para reenvio\n\nn = int(raw_input())\n\napples = [int(x) for x in raw_input().split()]\nap1 = 0\nap2 = 0\n\nfor i in apples:\n\tif i==100:\n\t\tap1+=1\n\telse:\n\t\tap2+=1\nif ap1>ap2:\n\tif ap2==0:\n\t\tif ap1%2==0:\n\t\t\tprint \"YES\"\n\t\telse:\n\t\t\tprint \"NO\"\n\telif ap1%2==0:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelif ap1<ap2:\n\tif ap1==0:\n\t\tif ap2%2==0:\n\t\t\tprint \"YES\"\n\t\telse:\n\t\t\tprint \"NO\"\n\t\t\n\telif ap2%2==0:\n\t\tif ap1%2==0:\n\t\t\tprint \"YES\"\n\t\telse:\n\t\t\tprint \"NO\"\n\telse:\n\t\tif ap1%2==0:\n\t\t\tprint \"YES\"\n\t\telse:\n\t\t\tprint \"NO\"\nelse:\n\tif ap1%2==0:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\nn=input()\na=l()\nx, y = a.count(100), a.count(200)\nif x&1 or (y&1 and x==0):\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "num_apple=int(input())\nweight=input().split()\nif num_apple!=1:\n count1=0\n count2=0\n i=0\n while i<len(weight):\n if '100' == weight[i]:\n count1+=1\n i+=1\n j=0\n while j<len(weight):\n if '200' == weight[j]:\n count2+=1\n j+=1\n if count1%2==0 and count2%2==0:\n print(\"YES\")\n elif count1%2!=0 and count2%2!=0:\n print(\"NO\")\n elif count1%2!=0 and count2%2==0:\n print(\"NO\")\n elif count1%2==0 and count2%2!=0:\n if count1==0 and count2%2!=0:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def solve():\n n = int(input())\n w = list(map(int , input().split()))\n s = sum(w) // 100\n if s % 2 == 1 or (n % 2 == 1 and s / 2 == n) : print(\"NO\")\n else : print(\"YES\")\n \n\nT = int(1)\nwhile T :\n solve()\n T = T - 1"}, {"source_code": "n=int(input())\ns=list(map(int,input().split()))\na=sum(s)\ns.count(100)\ns.count(200)\n\nif (a//2)%100==0:\n if s.count(100)%2==0 and s.count(200)%2==0:\n print('YES')\n exit()\n\n if s.count(100)>1 and s.count(200)%2==1:\n print('YES')\n exit()\n\nprint('NO')\n\n\n\n\n"}, {"source_code": "import math\nfrom collections import defaultdict, Counter, deque\n\nINF = float('inf')\n\ndef gcd(a, b):\n\twhile b:\n\t\ta, b = b, a%b\n\treturn a\n\ndef isPrime(n):\n\tif (n <= 1): \n\t\treturn False\n\ti = 2\n\twhile i ** 2 <= n:\n\t\tif n % i == 0:\n\t\t\treturn False\n\t\ti += 1\n\treturn True\n\ndef primeFactor(n):\n\tif n % 2 == 0:\n\t\treturn 2\n\ti = 3\n\twhile (i ** 2) <= n:\n\t\tif n % i == 0:\n\t\t\treturn i \n\t\ti += 1\n\treturn n\n\ndef vars():\n\treturn map(int, input().split())\n\ndef array():\n\treturn list(map(int, input().split()))\n\ndef main():\n\tn = int(input())\n\tarr = array()\n\th = arr.count(100)\n\tt = arr.count(200)\n\tf = 0 \n\ts = 0\n\n\twhile t > 0:\n\t\tif f <= s:\n\t\t\tf += 2\n\t\telse:\n\t\t\ts += 2\n\t\tt -= 1\n\n\twhile h > 0:\n\t\tif f <= s:\n\t\t\tif s - f >= 2 and h > 1:\n\t\t\t\tf += 1\n\t\t\t\th -= 1\n\t\t\tf += 1\n\t\telse:\n\t\t\tif f - s >= 2 and h > 1:\n\t\t\t\ts += 1\n\t\t\t\th -= 1\n\t\t\ts += 1\n\n\t\th -= 1\n\n\tif s == f:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\n\n\n\n\nif __name__ == \"__main__\":\n\t# t = int(input())\n\tt = 1\n\tfor _ in range(t):\n\t\tmain()\n\n\n\n\n\n\n\n"}, {"source_code": "n=int(input())\nc1=input().count('1')\nif c1&1:\n print('NO')\nelif c1==0 and n&1:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n = int(raw_input())\n\nnum = map(int, raw_input().strip().split())\n\nif sum(num) / 2 % 100 != 0 or n == 1 or (sum(num) / 2 % 200 != 0 and num.count(100) == 0): print \"NO\"\nelse: print \"YES\"\n"}, {"source_code": "_, A =input(), list(map(int,input().split()))\nif(sum(A)%200 == 0 and (len(A)%2 == 0 or (len(A)%2 == 1 and 100 in A and 200 in A))):\n\tprint(\"YES\")\nelse:\n\tprint('NO')"}, {"source_code": "n = int(input())\nw = [int(x) for x in input().split()]\nn1 = 0\nfor x in w:\n if x==100:\n n1 += 1\nn2 = n - n1\nn2 = n2%2\nn1 -= 2*n2\nif n1>=0 and n1%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=input()\nm=map(int,raw_input().split())\nb=list(m)\nsum=0\ncount=0\nfor i in range(0,a):\n if(b[i]==200):\n count=count+1\n sum=sum+b[i]\nif(sum%2==0):\n if(a%2==0):\n if(count%2==0):\n print \"YES\"\n else :\n print \"NO\"\n else :\n if(count%2!=0 and count<a):\n print \"YES\"\n else :\n print \"NO\" \nelse :\n print \"NO\"\n \n \n"}, {"source_code": "n = int(input())\nweights = input().split()\nweights = [int(w) for w in weights]\n\ncount100 = 0\ncount200 = 0\nfor i in range(n):\n if weights[i] == 100:\n count100 += 1\n elif weights[i] == 200:\n count200 += 1\nif count200 % 2 == 0:\n if count100 % 2 == 1:\n print('NO')\n else:\n print('YES')\nelse:\n if count100 == 0:\n print('NO')\n elif count100 % 2 == 1:\n print('NO')\n else:\n print('YES')\n"}, {"source_code": "def equal_apples (apples):\n two_g = 0\n one_g = 0\n for x in apples :\n if x == '200' :\n two_g += 1\n else:\n one_g += 1\n\n if two_g%2 == 0 :\n if one_g%2 == 0:\n return \"YES\"\n else:\n return \"NO\"\n else:\n if one_g < 2 :\n return \"NO\"\n else:\n one_g -= 2\n if one_g %2 == 0:\n return \"YES\"\n else:\n return \"NO\"\n \n \n\nn = int(input())\napples = input().split()\n\nprint (equal_apples(apples))\n \n"}, {"source_code": "n=int(input())\nxy=map(int,raw_input().split())\none=0\ntwo=0\nfor i in xy:\n if i==100:\n one+=1\n else:\n two+=1\n\nif two%2==0:\n if one%2==0:\n print \"YES\"\n else:\n print \"NO\"\nelse:\n san=one*100 + 200\n if san%200==0 and one>0:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "n = int(input())\napples = list(map(int, input().split()))\n\nhundreds = 0\ntwohundreds = 0\nsumw = 0\n\nfor apple in apples:\n if apple == 100:\n hundreds += 1\n else:\n twohundreds += 1\n sumw += apple\n\nif n >= 2 and ((twohundreds % 2 == 0 and hundreds % 2 == 0) or (twohundreds % 2 == 1 and hundreds % 2 == 0 and hundreds > 0)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "#Author: squiggly_lines\n#Date: 31/05/2014\n#Problem: 433A\n\ndef main():\n n = int(raw_input())\n w = map(int, raw_input().split())\n\n ec,oc = 0,0\n for apple in w:\n if apple == 200:\n ec += 1\n else:\n oc += 1\n\n if oc % 2 == 1:\n print \"NO\"\n return\n if ec % 2 == 1 and oc < 2:\n print \"NO\"\n return\n print \"YES\"\n\n\n\n\n\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "n=int(input())\nlst=list(map(int,input().split()))\nprint([\"NO\",'YES'][sum(lst)%200==0 and((n%2==1 and 100 in lst and 200 in lst) or n%2 == 0)])"}, {"source_code": "n=int(input())\na=list(map(int,input().split(\" \")))\nc1=0\nc2=0\nfor i in range(len(a)):\n if a[i]==100:\n c1+=1\n else:\n c2+=1\nif c1>0 and c2>0:\n if c1%2==0 and c2%2==0:\n print(\"YES\")\n elif c1%2==0 and c2%2!=0:\n print(\"YES\")\n else:\n print(\"NO\")\nif c1==0 and c2>0:\n if c2%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\nif c2==0 and c1>0:\n if c1%2==0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "if __name__ == '__main__':\n n = int(input())\n lines = str(input()).split()\n lines = [int(it) for it in lines]\n num_200 = sum(lines) // 100 - n\n num_100 = n - num_200\n if num_200 % 2 > 0:\n if num_100 < 2 or num_100 % 2 > 0:\n print('NO')\n else:\n print('YES')\n else:\n if num_100 % 2 > 0:\n print('NO')\n else:\n print('YES')\n"}, {"source_code": "x = int(input())\ny = list(map(int , input().split()))\no = y.count(100)\nt = y.count(200)\nif( o%2 == 0 and t%2 == 0 ):\n print(\"YES\")\nelif( o == 0 or t == 0):\n print(\"YNEOS\"[(t+o)%2::2])\nelse:\n print(\"YNEOS\"[abs(o-2*t)%2::2])\n \n \n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\ns1 = a.count(100)\ns2 = a.count(200)\nif(n==1):\n print('NO')\n exit(0)\nif(s1==0):\n if(s2%2):\n print('NO')\n else:\n print('YES')\nelif(s2==0):\n if(s1%2):\n print('NO')\n else:\n print('YES')\nelse:\n if((s1+s2*2)%2):\n print('NO')\n else:\n print('YES')"}, {"source_code": "\nn = int(raw_input())\na = map(int, raw_input().split())\nc1 = 0\nc2 = 0\nans = 'YES'\nfor i in range(n):\n if a[i] == 100:\n c1 += 1\n else:\n c2 += 1\nif c1 % 2 == 1: ans = 'NO'\nif c1 == 0 and c2 % 2 == 1: ans = 'NO'\nprint ans\n"}, {"source_code": "n,r = int(raw_input()),[int(c) for c in raw_input().split()]\nprint ['NO','YES'][sum(r)%400 == 0 or (sum(r)%200 == 0 and 100 in r)]"}, {"source_code": "n = input()\n\nvals = map(int, raw_input().split())\n\nc1 = 0\nc2 = 0\n\nfor val in vals:\n if val == 100:\n c1 += 1\n else:\n c2 += 1\n\ndef can_sum(a,b,c,d):\n return a+2*b==c+2*d or a+2*d==c+2*b or c+2*d==a+2*b or c+2*b==a+2*d\n\ni = 0\nfor j in range(c2):\n xt1 = c1-i\n xo1 = i\n xt2 = c2-j\n xo2 = j\n if can_sum(xt1, xt2, xo1, xo2):\n print \"YES\"\n exit(0)\n\nj = 0\nfor i in range(c1):\n xt1 = c1-i\n xo1 = i\n xt2 = c2-j\n xo2 = j\n if can_sum(xt1, xt2, xo1, xo2):\n print \"YES\"\n exit(0)\n\n\n\nfor i in range(c1):\n xt1 = c1-i\n xo1 = i\n for j in range(c2):\n xt2 = c2-j\n xo2 = j\n if can_sum(xt1, xt2, xo1, xo2):\n print \"YES\"\n exit(0)\n\nprint \"NO\"\n"}, {"source_code": "input();a=map(int,raw_input().split());c=sum(a);print'YES'if c%400==0 or (c%200==0 and 100 in a) else'NO'\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = b = 0\nfor i in input().split():\n if int(i) == 100:\n a += 1\n else:\n b += 1\nif a%2 == 1 or (a==0 and b%2 == 1):\n print(\"NO\")\n sys.exit()\nif a%2 == 0:\n print(\"YES\")\n sys.exit()\nelse:\n print(\"NO\")\n sys.exit()\n"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nf = c1 = c2 = 0\n\nfor i in a:\n if i == 100:\n c1 += 1\n else:\n c2 += 1\n\nif c1 % 2 == 0:\n if c2 % 2 == 0:\n f = 1\n elif c1 >= 2 or c1 == c2*2:\n f = 1\nif f:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n = int(raw_input())\nw = map(int, raw_input().split())\n\n# s = sum(w)\n# if (s / 100) % 2 != 0:\n# print \"NO\"\n# else:\n# pass\n\nn_100 = len(filter(lambda x: x == 100, w))\nn_200 = n - n_100\n\nif n_200 % 2 == 0 and n_100 % 2 == 0:\n print \"YES\"\nelif n_200 % 2 != 0 and n_100 >= 2 and n_100 % 2 == 0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "import sys\n\nr = raw_input().split(\" \")\nn = int(r[0])\nr = raw_input().split(\" \")\nq1 = 0; q2 = 0;\nfor i in r:\n if i == \"100\":\n q1 += 1\n else:\n q2 += 1\n\ndef calc(q1, q2):\n for i in range(q1+1):\n for j in range(q2+1):\n p1 = i * 100 + j * 200\n p2 = (q1 - i) * 100 + (q2 - j) * 200\n if p1 == p2:\n return True\n return False\n\nif q1 == 0:\n if q2 % 2 == 0:\n print \"YES\"\n else:\n print \"NO\"\nelif q2 == 0:\n if q1 % 2 == 0:\n print \"YES\"\n else:\n print \"NO\"\nelif calc(q1,q2):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n = int(input())\nA = list(map(int,input().split()))\nodd = 0\neven = 0\nfor i in A:\n if i == 100:\n odd += 1\n else:\n even += 1\nx = 0\nfor i in range(odd+1):\n for j in range(even + 1):\n if i + 2*j == (odd - i) + 2*(even - j):\n x = 1\nif x == 1:\n print(\"YES\")\nelse:\n print(\"NO\")"}], "negative_code": [{"source_code": "num_apples = int(raw_input())\nmacas = map(int, raw_input().split())\nsomatorio = sum(macas)\nif num_apples <= 1:\n\tprint 'NO'\nelif somatorio % 200 == 0:\n\tprint 'YES'\nelse:\n\tprint 'NO' \n\t\n\t\n\n\n\n\n"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\ns = 0\nfor i in a:\n s += i\nres = s/2\nif res % 100 == 0:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n = int(input())\na = [int(j) for j in input().split()]\nif((sum(a)//2)%100 != 0 or n<=1):\n print('NO')\nelse:\n s = (sum(a)//2)\n x = a.count(200)\n y = a.count(100)\n ans = 0\n for i in range(x):\n if(s - 200*i >= 0 and s - 200*i >= 100*y):\n ans = 1\n if(ans):\n print('YES')\n else:\n print('NO')"}, {"source_code": "def main():\n\tn = int(raw_input())\n\ta = map(int , raw_input().split(' '))\n\th,t = 0,0\n\tfor i in a:\n\t\th += i\n\n\th = h>>1\n\tif h%100 != 0:\n\t\tprint 'NO'\n\telse:\n\t\tprint 'YES'\n\nmain()"}, {"source_code": "n = int(input())\na = list(input().split(' '))\na = list(int(x) for x in a)\none, two = 0, 0\nfor i in range(n):\n if a[i] == 100:\n one += 1\n else:\n two += 1\nflag = False\nif one%2 == 0 and two%2 == 0 or one > two and (one - two + 1) % 2 == 0 and (one - two + 1) >=2:\n flag = True\nif not flag:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\nprint(a.count(100))\nif ((a.count(100)) % 2) ==0 and n > 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n=input()\nw=map(int,raw_input().split())\nh,t=w.count(100),w.count(200)\ng=sum(w)\nh,t=0,0\nif (g/100)%2==1: #geen even honderdtal\n print 'NO'\nelse:\n d=g/2\n while d>0 and t>0:\n d-=200\n t-=1\n if h*100>=d:\n print 'YES'\n else:\n print 'NO'\n \n \n \n "}, {"source_code": "n=int(input())\nq=map(int,input().split())\nf=list(q)\n#print(f)\ni=0\nw=0\nl=len(f)\nwhile i<l:\n y=f[i]\n w=w+y\n i+=1\n#print(w)\nt=w/2\nh=int(t%100)\n#print(h)\nif h==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "# coding: utf-8\n# (C) 2015, Laybson Plismenn / UFCG\n\nn = int(raw_input())\nws = map(int, raw_input().split())\n\npa = 0\npb = 0\n\nfor i in ws:\n if i == 100:\n pa += 1\n else:\n pb += 2\n\nif n % 2 == 0:\n if pa % 2 == 0 and (pb/2) % 2 == 0:\n print \"YES\"\n else:\n print \"NO\"\nelse:\n if n != 1 and pa % 2 == 0 and (pb/2) % 2 != 0:\n print \"YES\"\n else:\n print \"NO\"\n \n\n"}, {"source_code": "n = int(raw_input())\ncount =0\nd = raw_input().split()\nc = 0\ne = 0\nfor a in d:\n\tif int(a) == 100:\n\t\tc+=1\n\telse:\n\t\te+=1\nif c%2==1:\n\tprint \"NO\"\nif c==0 and e%2==1:\n\tprint \"NO\"\nelse:\n\tprint \"YES\""}, {"source_code": "n=int(input())\nw=list(map(int,input().split()))\nif 100 not in w:\n if w.count(200)%2!=0:\n print(\"NO\")\n exit()\nelif 200 not in w:\n if w.count(100)%2!=0:\n print(\"NO\")\n exit()\nelse:\n a=w.count(100)\n b=w.count(200)\n if a%b!=0:\n print(\"NO\")\n exit()\nprint(\"YES\")"}, {"source_code": "from itertools import permutations\n\nn = int(input())\nnums = [int(x) for x in input().split(\" \")]\n\ncnt_100 = 0\ncnt_200 = 0\n\nfor num in nums:\n if num == 100:\n cnt_100 += 1\n else:\n cnt_200 += 1\n\nif cnt_100 % 2 == 0 and cnt_200 % 2 == 0:\n print(\"YES\")\nelif cnt_200 % 2 != 0 and cnt_100 % 2 != 0:\n print(\"NO\")\nelif cnt_100 < cnt_200 and cnt_100 % 2 != 0 and cnt_200 % 2 == 0:\n print(\"NO\")\nelif cnt_100 > cnt_200 and cnt_100 % 2 == 0 and cnt_200 % 2 != 0:\n print(\"YES\")\nelif cnt_200 > cnt_100 and cnt_200 % 2 != 0 and cnt_100 % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ndoso=0\nsoo=0\ns=sum(a)\n\nj=s/100\nif(n==1):\n print(\"NO\")\nelse:\n if(int(j)%2==0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = int(raw_input())\ncount =0\nd = raw_input().split()\nfor a in d:\n\tif int(a) == \"100\":\n\t\tcount+=1\n\telse:\n\t\tcount+=2\nif count%2==0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "# -*- coding: utf-8 -*-\n# @Date : 2020-01-11 07:14:43\n# @Author : Anuj Puri (anujpuri72@gmail.com)\n# @Link : link\n# @Version : 1.0.0\n \nimport sys\nsys.setrecursionlimit(10**5+1)\n \ninf = int(10 ** 20)\nmax_val = inf\nmin_val = -inf\n \nRW = lambda : sys.stdin.readline().strip()\nRI = lambda : int(RW())\nRMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]\nRWI = lambda : [x for x in sys.stdin.readline().strip().split()]\nn = RI()\nl=RMI()\nhun=l.count(100)\ntwo=l.count(200)\n# print(hun,two)\nif(n%2==0):\n if ((hun==two) or (hun==n) or (two ==n)):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if(hun==(2*two)):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = input()\napples = sorted(map(int, raw_input().strip().split()))\n\nsap = sum(apples)/2\ns = max(apples)\nfor i in xrange(n-1):\n if s == sap:\n print 'YES'\n break\n if s > sap:\n print 'NO'\n break\n else:\n s += apples[i]"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\n\nt=0\n\nfor i in range(len(l)):\n if l[i]==l[0] and n%2!=0:\n t=-1\n else:\n if l[i]==100:\n t+=1\n elif l[i]==200:\n t+=2\nif t%2==0:\n print('YES')\nelif t==-1:\n print('NO')\nelse:\n print('NO')\n"}, {"source_code": "def f(A):\n if sum(A)/100 % 2 == 0:\n return \"YES\"\n return \"NO\"\n\nn = input()\narr = [int(i) for i in raw_input().strip().split()]\nprint f(arr)"}, {"source_code": "n=int(input())\ni=0\nl=0\nm=0\np=0\nq=3\nx=raw_input()\nwhile i<n:\n list(x)\n y= int(x[p:q])\n p=p+4\n q=q+4\n if y==100:\n l=l+1\n else: \n m=m+1 \n i=i+1\n \n \nt=100*l + 200*m\nif t%200==0:\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "length = int(input())\nweights = list(map(int, input().split()))\nones = [x for x in weights if x == 100]\ntwos = [x for x in weights if x == 200]\nif not ones or not twos:\n if length % 2 == 0:\n print('YES')\n else:\n print('NO')\nelse:\n if len(ones) == 2 * len(twos):\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nones = 0\ntwos = 0\nfor i in a:\n ones += int(i == 100)\n twos += int(i == 200)\nans = 'NO'\nif (((ones * 100 + twos * 200) / 2) % 100 == 0):\n if (ones >= twos):\n if ((ones - twos) % 2 == 1):\n ans = 'YES'\n else:\n if (((ones / 2) % 1 == 0 and ones / 2 >= (twos % 2))):\n ans = 'YES'\nprint (ans)"}, {"source_code": "n=int(input());l=sum(list(map(int,input().split())))//100;print(['YES','NO'][l%2!=0])"}, {"source_code": "a,b = 0,0\nn = int(input())\nx1 = list(map(int,input().split()))\nfor x in x1:\n if x == 100:\n a = a+1\n else:\n b = b+1\n\nsum = 100 * a + 200 * b\nif sum % 200 != 0:\n print(\"NO\")\nelse:\n half = sum / 2\n ans = False\n for i in range(b):\n if (200 * i <= half and half - 200 * i <= a * 100):\n ans = True\n if ans:\n print(\"YES\")\n else:\n if len(x1)>1 and len(set(x1))==1:\n print(\"YES\")\n else:\n print(\"NO\")\n \n"}, {"source_code": "n = int(input())\nw = [int(i) for i in input().split()]\na,b=0,0\nfor i in w:\n\tif i == 100:\n\t\ta += 1\n\telse:\n\t\tb += 1\nif(a==0 or b==0):\n\tn = a if b==0 else b\n\tprint(\"YES\" if (a|b)%2==0 else \"NO\")\nelse:\n\tif(a*100==b*200):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")"}, {"source_code": "t=int(input())\ns=map(int,raw_input().split())\na=sum(s)\na/=2\nif(len(s)==1):\n\tprint \"NO\"\n\t\nelse:\n\tfirst=0\n\tsecond=0\n\tfor x in s:\n\t\tif(first>second):\n\t\t\tsecond+=x\n\t\telse:\n\t\t\tfirst+=x\n\tif(first==second):\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "n = int(raw_input())\na,b=0,0\nl=map(int,raw_input().split())\nfor x in l:\n if x==100:\n a+=1\n else:\n b+=1\n\nif a&1:\n print 'NO'\n\nelif b&1:\n if a>=2:\n print 'YES'\n"}, {"source_code": "n=int(input())\narr=[int(x) for x in input().split(' ')]\nhalf=sum(arr)//2\nprefix=[0]\nfor item in arr:\n\tprefix.append(prefix[-1]+item)\nif half in prefix:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "def ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n \nimport math\n \nn=ii()\na=li()\ns=0\nfor i in a:\n if i==100:\n s+=1 \n else:\n s+=2 \nif s%2 or n==1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n=int(input())\nl=input().split()\ns=0\nfor i in range(n):\n l[i]=int(l[i])//100\n s+=l[i]\nif(s%2!=0 or n==1):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "from collections import Counter\nn=int(input())\nl=list(input().split())\nc=Counter(l)\nif c['100']%2==0 and c['200']%2==0:\n print(\"YES\")\nelif c['100']%2==0 and c['200']%2!=0 and 100*c['100']>=200*c['200']:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nw=sum(map(int,input().split()))\nif w%200==0:print('YES')\nelse:print('NO')"}, {"source_code": "n = int(input())\nA = [int(x)for x in input().split()]\nsuma = 0\nif (n < 2):\n print(\"NO\")\nelse:\n for k in range(len(A)):\n suma+=A[k]\n r = suma//2\n if ((suma == 100)or(suma == 200)):\n print(\"YES\")\n else:\n if (((r%100)==0)and((r%200)==0)):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod_ = int(1e9) + 7\nmod = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve():\n n,m=1,10**6\n primes = {}\n arr=set([])\n for i in range(2, round(m ** 0.5) + 1):\n a = n // i\n b = m // i\n for k in range(max(2, a), b + 1):\n c = i * k\n primes[c] = 1\n\n for i in range(max(n, 2), m + 1):\n if i not in primes:\n arr.add(i)\n\n return arr\n\ndef nc2(x):\n return (x*(x-1))//2\ndef main():\n n=int(input())\n arr=list(map(int,input().split()))\n if sum(arr)%200==0 and n>1:\n print(\"YES\")\n else:\n print(\"NO\")\n\n \n\n\n \n \n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n=int(input())\nc=list(map(int,input().split()))\nif c.count(100)%2!=0 or n==1: print('NO')\nelse: print('YES')"}, {"source_code": "n = int(input())\nw = [int(x) for x in input().split()]\nn1 = 0\nfor x in w:\n if x==100:\n n1 += 1\nn2 = n - n1\nn2 = n2%2\nif n1>=2 or n1==0:\n n1 -= 2\n n1 = n1%2\n if n1==0:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")\n"}, {"source_code": "x=int(raw_input())\ny=map(int, raw_input().split())\nans=y[0]\nans2=0\nfor i in range(1,x,1):\n if ans > ans2:\n ans2+=y[i]\n else:\n ans+=y[i]\nif ans == ans2:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "#input\nn = int(input())\napples = [int(string) for string in input().split()]\n#\nbig_count = apples.count(200)\nsmall_count = apples.count(100)\nhalf = sum(apples) // 2\napples = sorted(apples, reverse = True)\n#\nif half % 100 > 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n = input()\narr = input().split()\none = two = 0\nfor _ in arr:\n if _ == '100':one+=1\n else:two+=1\nif one%2==0 and ((one//2)+two)%2==0:print(\"YES\")\nelif two%2==0 and one==0:print(\"YES\")\nelif one%2==0 and two==0:print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "n=int(input())\np=input()\np=list(map(int,p.split()))\nc,d,s=0,0,0\nfor i in p:\n if i==100:\n c+=1\n else:\n d+=1\n s+=i\nif s%200==0 and (c>1 or d>1):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "length = int(input())\nweights = list(map(int, input().split()))\nones = [x for x in weights if x == 100]\ntwos = [x for x in weights if x == 200]\nif not ones or not twos:\n if length % 2 == 0:\n print('YES')\n else:\n print('NO')\nelse:\n if len(ones) == 2 * len(twos) or (len(ones) % 2 == 0 and len(twos) % 2 == 0) or (len(ones) % 2 == 0 and (len(ones) // 2 + len(twos)) % 2 == 0):\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "_, a = input(), list(input().split())\nprint('YES' \n\t\tif(a.count(\"100\")/2 == a.count(\"200\")) \n\telse 'NO')"}, {"source_code": "n=int(input())\ns=input().split()\nc1=s.count('100');c2=n-c1\nprint('YES'if c1 and c2 and c1==2*c2 or not c1%2 and not c1%2 or not c1 and not c2%2 or not c2 and not c1%2 else 'NO')"}, {"source_code": "t=int(input())\ns=map(int,raw_input().split())\na=sum(s)\na/=2\nif(len(s)==1):\n\tprint \"NO\"\n\t\nelse:\n\tfirst=0\n\tsecond=0\n\ts.sort()\n\tfor x in s:\n\t\tif(first>second):\n\t\t\tsecond+=x\n\t\telse:\n\t\t\tfirst+=x\n#\tprint first,second\n\tif(first==second):\n\t\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "n=int(input())\n\nL=list(map(int,input().split()))\n\ns=sum(L)\n\nif(s%200==0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def solve(w):\n n = len(w)\n if n < 2: return False\n s = sum(w)\n if s % 200 != 0: return False\n t = s/2\n a, b = w.count(100), w.count(200)\n for i in range(b+1):\n if (a-(t-200*i)/100)*100 == t: return True\n return False\n\nn = int(raw_input())\nw = map(int, raw_input().split())\nprint 'YES' if solve(w) else 'NO'\n"}, {"source_code": "n=int(input())\nL=[int(i) for i in input().split()]\nif n%2==1 and L.count(100)!=2*L.count(200):\n print(\"NO\")\nelse:\n if (L.count(100)==2*L.count(200)) or (L.count(200)==n) or (L.count(100)==n):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = input()\narr = input().split()\none = two = 0\nfor _ in arr:\n if _ == '100':one+=1\n else:two+=1\nif one%2==0 and (one//2)==two:print(\"YES\")\nelif two%2==0 or one%2==0:print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "if __name__ == '__main__':\n n = int(input())\n line = str(input()).split()\n line = [int(it) for it in line]\n value = sum(line) % 200\n if value > 0:\n print('NO')\n else:\n print('YES')\n"}, {"source_code": "n = int(input())\nweights = input().split()\nweights = [int(w) for w in weights]\n\nif sum(weights) % 200 == 0 and len(weights) > 1 and len(weights) % 2 == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = int(input())\narr = map(int, input().split())\nc = d = 0\n\nfor x in arr:\n if x == 100:\n c+=1\n else:\n d+=1\n\nif c%2 == 0 and d%2 == 0:\n print(\"YES\")\nelif c%2 == 0 and (d+c/2)%2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n= int(input())\nans = sorted(list(map(int,input().split())))\nresult = ((2* ans.count(200)) %2) - (ans.count(100))%2\nprint(\"NYOE S\"[result == 0 ::2])"}, {"source_code": "n=int(input())\napple = [int(x) for x in input().split(' ')]\ns=sum(apple)\nif len(apple)==1:\n print(\"NO\")\nelif s%200 !=0:\n print(\"NO\")\nelif s==len(apple)*200:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n = input()\n\nvals = map(int, raw_input().split())\n\nc1 = 0\nc2 = 0\n\nfor val in vals:\n if val == 100:\n c1 += 1\n else:\n c2 += 1\n\n\ni = 0\nfor j in range(c2):\n xt1 = c1-i\n xo1 = i\n xt2 = c2-j\n xo2 = j\n if xt1+2*xt2 == xo1+2*xo2:\n print \"YES\"\n exit(0)\n\nj = 0\nfor i in range(c1):\n xt1 = c1-i\n xo1 = i\n xt2 = c2-j\n xo2 = j\n if xt1+2*xt2 == xo1+2*xo2:\n print \"YES\"\n exit(0)\n\n\n\nfor i in range(c1):\n xt1 = c1-i\n xo1 = i\n for j in range(c2):\n xt2 = c2-j\n xo2 = j\n if xt1+2*xt2 == xo1+2*xo2:\n print \"YES\"\n exit(0)\n\nprint \"NO\"\n"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\n\nif (a.count(200) + a.count(100)%2 )%2==0 and a.count(100)%2==0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "a,b = 0,0\nn = int(input())\nx1 = list(map(int,input().split()))\nfor x in x1:\n if x == 100:\n a = a+1\n else:\n b = b+1\n\nsum = 100 * a + 200 * b\nif sum % 200 != 0:\n print(\"NO\")\nelse:\n half = sum / 2\n ans = False\n for i in range(b):\n if (200 * i <= half and half - 200 * i <= a * 100):\n ans = True\n if ans:\n print(\"YES\")\n else:\n if len(x1)>1 and len(set(x1))==1:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = int(input())\nlst = list(map(int, input().split()))\ntouma = 0\nogiso = 0\nnewlst = lst.copy()\ny = int(sum(lst)/2)\n\n\nfor item in lst:\n if touma + item <= y:\n touma = touma + item\n newlst.remove(item)\n continue\n if ogiso + item <= y:\n ogiso = ogiso + item\n newlst.remove(item)\nif touma == ogiso and len(newlst) == 0 or touma == ogiso and sum(newlst) % 100 == 0:\n print('YES')\nelse:\n print('NO')\n \n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod_ = int(1e9) + 7\nmod = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve():\n n,m=1,10**6\n primes = {}\n arr=set([])\n for i in range(2, round(m ** 0.5) + 1):\n a = n // i\n b = m // i\n for k in range(max(2, a), b + 1):\n c = i * k\n primes[c] = 1\n\n for i in range(max(n, 2), m + 1):\n if i not in primes:\n arr.add(i)\n\n return arr\n\ndef nc2(x):\n return (x*(x-1))//2\ndef main():\n n=int(input())\n arr=list(map(int,input().split()))\n if sum(arr)%200==0 and n>1:\n print(\"YES\")\n else:\n print(\"NO\")\n\n \n\n\n \n \n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n=int(input())\nw=[int(x) for x in input().split()]\na=w[0]\nif n<=1:\n b=0\nelse:\n b=w[1]\nfor i in range(2,n):\n if a<b:\n a+=w[i]\n else:\n b+=w[i]\nif a==b:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nw=sum(map(int,input().split()))\nif w%200==0:print('YES')\nelse:print('NO')"}, {"source_code": "n = int(input())\nw = list(map(int,input().split()))\nc100,c200=0,0\nfor e in w:\n if e==100:\n c100+=1\n else:\n c200+=1\nif c100==0 or c200==0:\n if n%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if c100==c200*2:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ndoso=0\nsoo=0\ns=sum(a)\n\nj=s/100\nif(n==1):\n print(\"NO\")\nelse:\n if(int(j)%2==0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = input()\n\nvals = map(int, raw_input().split())\n\nc1 = 0\nc2 = 0\n\nfor val in vals:\n if val == 100:\n c1 += 1\n else:\n c2 += 1\n\n\ni = 0\nfor j in range(c2):\n xt1 = c1-i\n xo1 = i\n xt2 = c2-j\n xo2 = j\n if xt1+2*xt2 == xo1+2*xo2:\n print \"YES\"\n exit(0)\n\nj = 0\nfor i in range(c1):\n xt1 = c1-i\n xo1 = i\n xt2 = c2-j\n xo2 = j\n if xt1+2*xt2 == xo1+2*xo2:\n print \"YES\"\n exit(0)\n\n\n\nfor i in range(c1):\n xt1 = c1-i\n xo1 = i\n for j in range(c2):\n xt2 = c2-j\n xo2 = j\n if xt1+2*xt2 == xo1+2*xo2:\n print \"YES\"\n exit(0)\n\nprint \"NO\"\n"}, {"source_code": "n=int(input())\nc1=c2=0\nl=[int(x) for x in input().split()]\nfor i in range(n):\n if(l[i]==100):\n c1+=1\n else:\n c2+=1\nif(c1%2==0 and c2%2==0):\n print(\"YES\")\nelif(((c1==0 and c2!=0) and c2%2==0)or((c2==0 and c1!=0) and c1%2==0)):\n print(\"YES\")\nelif(c1%2==0 and c2%2!=0):\n print(\"YES\")\nelse:\n print(\"NO\")\n \n\n"}, {"source_code": "n=int(input())\nw=list(map(int,input().split()))\ns=sum(w)\nh=0\nt=0\nfor i in w:\n if i==100:\n h+=1\n else:\n t+=1\nif (t==0 and h%2==0) or (h==0 and t%2==0) or (h==1 or t==1):\n print('YES')\nelse:\n if h%2!=0:\n print('NO')\n \n else:\n while t!=0 and h!=0:\n h-=2\n t-=1\n print(\"YES\")"}, {"source_code": "n = int(raw_input())\nw = map(int, raw_input().split())\nd = 0\nfor i in range(n):\n if w[i] == 200:\n d +=1\nif d%2 == 1:\n if (n-d)%2 == 0 and (n-d)>0:\n print \"YES\"\n else:\n print \"NO\"\nelif (n-d)%2 == 0:\n print \"YES\"\n"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\n\nif ((a.count(100)) % 2) ==0 and n > 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import sys\nimport math\n \nn = int(sys.stdin.readline())\nwn = [int(int(x) / 100) for x in (sys.stdin.readline()).split()]\n\nvsum = sum(wn)\nif(vsum % 2 == 0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# Author: SaykaT\n# Problem: 433A\n# Time Created: August 02(Sunday) 2020 || 04:08:59\n\n#>-------------------------<#\nimport sys\n\ninput = sys.stdin.readline\n#>-------------------------<#\n\n\n# Helper Functions. -> Don't cluster your code.\n\n\n# IO Functions. -> Input output\ndef io():\n n = int(input())\n ls = list(map(int, input().split()))\n\n return n, ls\n\n\n# Main functions. -> Write the main solution here\ndef solve():\n n, ls = io()\n\n tot = sum(ls)\n if tot % 2 == 0:\n print('YES')\n else:\n print('NO')\n\n\n# Multiple test cases. -> When you have T test cases.\nsolve()\n\n"}, {"source_code": "num_apple=int(input())\nweight=input().split()\ncount1=0\ncount2=0\ni=0\nwhile i<len(weight):\n if '100' == weight[i]:\n count1+=1\n i+=1\nj=0\nwhile j<len(weight):\n if '200' == weight[j]:\n count2+=1\n j+=1\nif ((200*count2)%(100*count1))==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\narr = [int(i) for i in input().split()]\n\ncount = [0, 0]\nfor i in arr:\n count[i//100 - 1] += 1\n\n#print(count[0] + count[1]*2) \nif not count[0]% 2 and (count[1]%2==0 or (count[0]//2)%2 == 0):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = int(raw_input())\nw = raw_input().split()\n\ni100 = 0\ni200 = 0\nfor i in w:\n\tif int(i) == 100:\n\t\ti100 += 1\n\telif int(i) == 200:\n\t\ti200 += 1\n\nfor i in range(max(i100,i200)+1):\n\tif i200 <= i100 and (i200*200 + i*100) == (i100-i)*100:\n\t\tprint \"YES\"\n\t\texit(0)\n\telif i100 <= i200 and (i100*100 + i*200) == (i200-i)*200:\n\t\tprint \"YES\"\n\t\texit(0)\n\t\nprint \"NO\"\n"}, {"source_code": "t=int(input())\na=list(map(int,input().split(\" \")))\nb=a.count(100)\nc=a.count(200)\nif b==c:\n if b%2==0:\n print(\"YES\")\n else:\n print(\"NO\")\nelif b>c:\n if (b-c)%2!=0:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if b%2==0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=int(input())\nc1=c2=0\nl=[int(x) for x in input().split()]\nfor i in range(n):\n if(l[i]==100):\n c1+=1\n else:\n c2+=1\nif(c1%2==0 and c2%2==0):\n print(\"YES\")\nelif(((c1==0 and c2!=0) and c2%2==0)or((c2==0 and c1!=0) and c1%2==0)):\n print(\"YES\")\nelif(c1%2==0 and c2%2!=0 and c2!=0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nw = list(map(int, input().split()))\nif (sum(w)//100) % 2 == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "#input\nn = int(input())\napples = [int(string) for string in input().split()]\n#\nbig_count = apples.count(200)\nsmall_count = apples.count(100)\nhalf = sum(apples) // 2\napples = sorted(apples, reverse = True)\n#\nif half % 100 > 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n, a, left, right = raw_input(), map(int, raw_input().split()), 0, 0\n\nleft = a.count(100)\nright = a.count(200)\n\nif left == 0 and right == 0: \n print \"NO\"\nelse:\n if right % 2 == 0 and left % 2 == 0 and int(n) > 1: \n print \"YES\"\n else:\n if right % 2 == 1 and left % 2 == 0 and int(n) > 1:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "n = int(input())\nlis = list(map(int,input().split()))\nhun = 0\nthun = 0\nfor i in lis:\n if i == 100:\n hun+=1\n else:\n thun+=1\nif thun == 0 or hun == 0:\n if thun == 0:\n if hun%2 == 0:\n print ('YES')\n else:\n print ('NO')\n else:\n if thun%2 == 0:\n print ('YES')\n else:\n print ('NO')\nelif hun//thun%2 == 0:\n print ('YES')\nelse:\n print ('NO')"}, {"source_code": "n = int(input())\nlis = list(map(int,input().split()))\nhun = 0\nthun = 0\nfor i in lis:\n if i == 100:\n hun+=1\n else:\n thun+=1\nif thun == 0 or hun == 0:\n if thun == 0:\n if hun%2 == 0:\n print ('YES')\n else:\n print ('NO')\n else:\n if thun%2 == 0:\n print ('YES')\n else:\n print ('NO')\nelif hun/thun%2 == 0:\n print ('YES')\nelse:\n print ('NO')"}, {"source_code": "input ()\nprint 'YES' if (sum (map (int , raw_input ().split ())) / 100) % 2 == 0 else 'NO'\n"}, {"source_code": "n=int(input())\ns=list(map(int,input().split()))\na=sum(s)\nif (a//2)%100==0:\n if s.count(100)%2==0 and (s.count(200)==0 or s.count(200)%2==0):\n print('YES')\nelse:\n print('NO')\n\n\n\n\n"}, {"source_code": " # -*- coding: utf-8 -*- \n'''\nKitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.\n\nEach apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equal to the total weight of the apples given to Ogiso Setsuna.\n\nBut unfortunately Kitahara Haruki doesn't have a knife right now, so he cannot split any apple into some parts. Please, tell him: is it possible to divide all the apples in a fair way between his friends?\n\nInput\nThe first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of apples. The second line contains n integers w1,\u2009w2,\u2009...,\u2009wn (wi\u2009=\u2009100 or wi\u2009=\u2009200), where wi is the weight of the i-th apple.\n\nOutput\nIn a single line print \"YES\" (without the quotes) if it is possible to divide all the apples between his friends. Otherwise print \"NO\" (without the quotes).\n'''\n\nraw_input()\napples=[int(a) for a in raw_input().split()]\none=apples.count(100)\ntwo=apples.count(200)\n\nif one%2 != 0:\n print 'NO'\nelif two>1 and one>1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n=int(input())\np=input()\np=list(map(int,p.split()))\nc,d,s=0,0,0\nfor i in p:\n if i==100:\n c+=1\n else:\n d+=1\n s+=i\nif c%2==0:\n if c==0:\n if d%2==0:\n print('YES')\n else:\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ncnt=0\nfor i in range(n):\n if a[i]==100:\n cnt+=1\nif cnt%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(raw_input())\ncount =0\nd = raw_input().split()\nfor a in d:\n\tif a == \"100\":\n\t\tcount+=1\n\telse:\n\t\tcount+=2\nif count%2==0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "a,b = 0,0\nn = int(input())\nx1 = list(map(int,input().split()))\nfor x in x1:\n if x == 100:\n a = a+1\n else:\n b = b+1\n\nsum = 100 * a + 200 * b\nif sum % 200 != 0:\n print(\"NO\")\nelse:\n half = sum / 2\n ans = False\n for i in range(b):\n if (200 * i <= half and half - 200 * i <= a * 100):\n ans = True\n if ans:\n print(\"YES\")\n else:\n if len(x1)>1 and x1[0]==x1[1]:\n print(\"YES\")\n else:\n print(\"NO\")\n \n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\ns1 = a.count(100)\ns2 = a.count(200)\ns1*=100\ns2*=200\n\nif(s2==s1):\n print('YES')\nelif(s2>s1):\n if((s2-s1)%200==0 and ((s2-s1)//2)%200==0):\n print('YES')\n else:\n print('NO')\nelse:\n if(((s1-s2)//2)%100==0):\n print('YES')\n else:\n print('NO')"}, {"source_code": "n = input()\nprint \"YES\" if str(sum(list(map(int, raw_input().split()))))[0] in \"2468\" else \"NO\"\n"}, {"source_code": "input();a=map(int,raw_input().split());c=a.count(100)+2*a.count(200);print'YES'if c%2==0 else'NO'"}, {"source_code": "input()\na = sum([int(i) for i in input().split()])\nif a % 200 == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\ni=0\nl=0\nm=0\np=0\nq=3\nx=raw_input()\nwhile i<n:\n list(x)\n y= int(x[p:q])\n p=p+4\n q=q+4\n if y==100:\n l=l+1\n else: \n m=m+1 \n i=i+1\n \n \nt=100*l + 200*m\nif t%200==0:\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "n=int(raw_input())\nl=[int(x)/100 for x in raw_input().split()]\nans=chk=0\nt=sum(l)\nif t%2:\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "import sys\n\nn = sys.stdin.readline()\ninputStr = sys.stdin.readline()\n\nweights = inputStr.split(' ')\ntotalWeight = 0\n\nfor weight in weights:\n totalWeight += int(weight)\n\nif totalWeight % 200 == 0:\n if totalWeight / len(weights) != 200:\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')\n\n\n"}, {"source_code": "n=int(input())\np=input()\np=list(map(int,p.split()))\nc,d,s=0,0,0\nfor i in p:\n if i==100:\n c+=1\n else:\n d+=1\n s+=i\nif s%200==0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": " # -*- coding: utf-8 -*- \n'''\nKitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.\n\nEach apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equal to the total weight of the apples given to Ogiso Setsuna.\n\nBut unfortunately Kitahara Haruki doesn't have a knife right now, so he cannot split any apple into some parts. Please, tell him: is it possible to divide all the apples in a fair way between his friends?\n\nInput\nThe first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of apples. The second line contains n integers w1,\u2009w2,\u2009...,\u2009wn (wi\u2009=\u2009100 or wi\u2009=\u2009200), where wi is the weight of the i-th apple.\n\nOutput\nIn a single line print \"YES\" (without the quotes) if it is possible to divide all the apples between his friends. Otherwise print \"NO\" (without the quotes).\n'''\n\nraw_input()\napples=[int(a) for a in raw_input().split()]\none=apples.count(100)\ntwo=apples.count(200)\n\nif one%2 != 0:\n print 'NO'\nelif two>1 and one>1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "__author__ = 'lyric_seraph'\n\nimport sys\n\ndef main():\n n = raw_input()\n n = int(n)\n num = raw_input()\n num = num.split()\n num = [int(nums) for nums in num]\n cnt = [0, 0]\n for i in num:\n if i == 100:\n cnt[0] += 1\n else:\n cnt[1] += 1\n if ((cnt[0] & 1) == 0 and (cnt[1] & 1) == 0) or \\\n (cnt[0] - cnt[1] * 2 >= 0 and ((cnt[0] - cnt[1] * 2) & 1) == 0):\n print 'YES'\n else:\n print 'NO'\n\n\n\nif __name__ == '__main__':\n exit(main())"}, {"source_code": "__author__ = 'lyric_seraph'\n\nimport sys\n\ndef main():\n n = raw_input()\n n = int(n)\n num = raw_input()\n num = num.split()\n num = [int(nums) for nums in num]\n cnt = [0, 0]\n for i in num:\n if i == 100:\n cnt[0] += 1\n else:\n cnt[1] += 1\n print cnt\n if cnt[0] % 2 == 1:\n print 'NO'\n else:\n if ((cnt[0] & 1) == 0 and (cnt[0] & 1) == 0):\n print 'YES'\n elif cnt[0] >= cnt[1] * 2:\n print 'YES' if (cnt[0] - cnt[1] * 2) % 2 == 0 else 'NO'\n else:\n print 'YES' if (cnt[1] * 2 - cnt[0]) % 4 == 0 else 'NO'\n\n\n\nif __name__ == '__main__':\n exit(main())"}, {"source_code": "n= int(input())\nans = sum(list(map(int,input().split())))//100\nprint(\"NYOE S\"[ans%2 == 0::2])"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nx,y=0,0\nfor i in range(n):\n if a[i]==100:\n x+=1\n else:\n y+=1\nif x%2==0 or x==0 and y%2==0:\n print('YES')\nelse:\n print('NO')\n \n"}, {"source_code": "n = input()\n\n\n\na = map(int,raw_input().split())\n\nd = dict()\n\nd[100]=0\nd[200]=0\n\nfor i in a:\n if i in d:\n d[i]+=1\n else:\n d[i]=1 \n\n\nwhile d[100]>2:\n d[200]+=1\n d[100]-=2\n\nprint d\nif d[200]%2==0 and d[100]%2==0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def go():\n n = int(input())\n a = [int(i) for i in input().split(' ')]\n two = a.count(200)\n one = a.count(100)\n if one % 2 == 1:\n return 'NO'\n if two % 2 == 1 and one % 2 == 1:\n return 'NO'\n return 'YES'\n\nprint(go())\n"}], "src_uid": "9679acef82356004e47b1118f8fc836a"} {"source_code": "from sys import stdin\nn, m, k = map(int, stdin.readline().split(' '))\ndoublesNeeded = int(m - (n - n / k))\nscore = 0\nif doublesNeeded > 0:\n score = 1\n score <<= (doublesNeeded + 1)\n score *= k\n score -= 2 * k\nif m > 0 and doublesNeeded >= 0:\n score += m - doublesNeeded * k\nelif doublesNeeded < 0:\n score = m\nscore %= 1000000009\nprint(score)\n", "positive_code": [{"source_code": "Mod = 1000000009\ndef mPow(x, y):\n if y == 0:\n return 1\n ans = mPow(x, y/2)\n ans = (ans * ans) % Mod\n if y%2 > 0:\n ans = (ans * x) % Mod\n return ans\n\nn, m, k = map(int, raw_input().split())\nfr = n % k + (n/k)*(k-1)\nif fr >= m:\n ans = m\nelse:\n a = m - fr\n fr -= a*(k-1)\n ans = mPow(2,a)\n ans = (ans + Mod - 1) % Mod\n ans = (ans * 2) % Mod\n ans = (ans * k) % Mod\n ans = (ans + fr) % Mod\nprint ans\n"}, {"source_code": "\n #COPIED\n\nMOD = 1000000009\n\nn,m,k = [int(x) for x in input().split()]\n\nnum0 = n-m\nnum1fin = num0*(k-1)\nif num1fin >= m:\n print(m)\nelse:\n num1open = m-num1fin\n sets = num1open//k\n rem = num1open%k\n print(((pow(2,sets,MOD)-1)*2*k+rem+num1fin)%MOD)"}, {"source_code": "mod = 1000000009\n\ndef mpow(x, y):\n\tif y == 0:\n\t\treturn 1\n\tans = mpow(x, y/2)\n\tans = (ans * ans) % mod\n\tif y%2 > 0:\n\t\tans = (ans * x) % mod\n\treturn ans\n\t\t\n\nn, m, k = map(int, raw_input().split())\nfr = n % k + (n/k)*(k - 1)\nif fr >= m:\n\tans = m\nelse:\n\ta = m - fr\n\tfr -= a*(k-1)\n\tans = mpow(2, a)\n\tans = (ans + mod - 1) % mod\n\tans = (ans * 2) % mod\n\tans = (ans * k) % mod\n\tans = (ans + fr) % mod\nprint ans"}, {"source_code": "MOD = 1000000009\n\ndef log_mult(a, p):\n if p == 0:\n return 1\n else:\n z = log_mult(a, p//2)\n z = (z*z) % MOD\n if (p % 2) == 1:\n return (a*z) % MOD\n else:\n return z\n \ndef log_iterative(a, p):\n res = 1\n while p > 0:\n if p % 2 == 1:\n res = (res*a) % MOD\n a = (a*a) % MOD\n p //= 2\n return res\n \nn, m, k = list(map(int, input().split()))\nc = (n//k) * (k-1) + n % k \nif c >= m:\n print(m)\nelse:\n d = m - c\n res = log_iterative(2, d+1) - 2\n res = (res * k) % MOD\n print((res + m-d*k) % MOD)\n "}, {"source_code": "# Filename : Quiz.py\n# arr = raw_input().split();\n# t = [raw_input().split() for i in range(0,n,1)]\n\nMod = 1000000009\ndef mPow(x, y):\n if y == 0:\n return 1\n ans = mPow(x, y/2)\n ans = (ans * ans) % Mod\n if y%2 > 0:\n ans = (ans * x) % Mod\n return ans\n\nn, m, k = map(int, raw_input().split())\nfr = n % k + (n/k)*(k-1)\nif fr >= m:\n ans = m\nelse:\n a = m - fr\n fr -= a*(k-1)\n ans = mPow(2,a)\n ans = (ans + Mod - 1) % Mod\n ans = (ans * 2) % Mod\n ans = (ans * k) % Mod\n ans = (ans + fr) % Mod\nprint ans\n"}, {"source_code": "import sys\n\nn, m, k = [int(x) for x in raw_input().strip().split()]\n\nzeroes = n-m\nif zeroes >= n/k:\n print m\n sys.exit()\nfullsets = n/k - zeroes\nremaining = n - k*fullsets - zeroes\n\nbignum = 1000000009\n\nscore = (k * (pow(2, fullsets+1, bignum) - 2)) % bignum\n\nscore += remaining\nscore %= bignum\n\nprint score\n"}, {"source_code": "I=lambda:map(int, raw_input().split())\nbignum = 10**9+9\n\nn, m, k = I()\nzeroes = n-m\nif zeroes >= n/k:\n print m\n exit()\n\nfullsets = n/k - zeroes\nremaining = n - k*fullsets - zeroes\n\nscore = (k * (pow(2, fullsets+1, bignum) - 2)) % bignum\n\nscore += remaining\nscore %= bignum\n\nprint score"}, {"source_code": "n, m, k = map(int, raw_input().split(\" \"))\nif m % (k - 1) == 0:\n\tdiff = (m / (k - 1) * k - 1) - n\n#\tprint \"initial diff\", diff\n\tif diff <= 0:\n\t\tprint m\n\telse:\n\t\tdoubles = diff / k * (k - 1)\n\t\tdoubles += diff % k\n\t\tones = m - doubles * k\n#\t\tprint \"doubles\", doubles\n#\t\tprint \"ones\", ones\n\t\tprint ((pow(2, doubles, 1000000009) - 1) * 2 * k + ones) % 1000000009\n\nelse:\n\tdiff = (m / (k - 1) * k + m % (k - 1)) - n\n#\tprint \"initial diff\", diff\n\tif diff <= 0:\n\t\tprint m\n\telse:\n\t\tif m % (k - 1) + 1 == diff:\n\t\t\tdoubles = m % (k - 1)\n\t\t\tones = m - doubles * k\n#\t\t\tprint \"doubles\", doubles\n#\t\t\tprint \"ones\", ones\n\t\t\tprint ((pow(2, doubles, 1000000009) - 1) * 2 * k + ones) % 1000000009\n\t\telif m % (k - 1) + 1 > diff:\n\t\t\tdoubles = diff\n\t\t\tones = m - doubles * k\n#\t\t\tprint \"doubles\", doubles\n#\t\t\tprint \"ones\", ones\n\t\t\tprint ((pow(2, doubles, 1000000009) - 1) * 2 * k + ones) % 1000000009\t\t\t \n\t\telse:\n\t\t\tdiff -= (m % (k - 1) + 1)\n\t\t\tdoubles = m % (k - 1)\n\t\t\tdoubles += diff / k * (k - 1)\n\t\t\tdoubles += diff % k\n\t\t\tones = m - doubles * k\n#\t\t\tprint \"doubles\", doubles\n#\t\t\tprint \"ones\", ones\n\t\t\tprint ((pow(2, doubles, 1000000009) - 1) * 2 * k + ones) % 1000000009\n\n"}, {"source_code": "n, m, k = map(int, raw_input().split())\n\nwrongNum = n - m\nintervalNum = n / k\n\nM = (10 ** 9 + 9)\nif wrongNum >= intervalNum :\n score = m\nelse :\n prefixSum = 2*k * (pow(2, intervalNum - wrongNum, M) - 1)\n suffixSum = (m - ((intervalNum-wrongNum) * k))\n score = (prefixSum + suffixSum) % M\n\nprint score\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=10**9+9\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\n# vsInput()\n\ndef bigmod(a,b,c):\n if(b==0): return 1\n if(b%2==0):\n x=bigmod(a,b/2,c)\n return (x*x)%c\n else: \n return (a%c * bigmod(a,b-1,c))%c\n\nn,m,k=value()\n\nsections=n//(k)\nminScore=n%(k)+sections*(k-1)\n\ncovered=max(m-minScore,0)\n# print(covered)\n\nscore=(bigmod(2,covered,M)-1+M)%M\nscore=(score* (2*k)%M)%M\n# print(score)\n\nscore=(score+(m-covered*k))%M\n\nprint(score)\n\n# BruteForce\n# ans=0\n# for i in range(covered):\n# ans=(ans+k)%M\n# ans=(ans*2)%M\n# print(ans)\n\n\n \n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n\n\n\n\n\n \n"}, {"source_code": "mod = 10**9+9\nn,m,k = map(int,(input().split()));\n\nx = int(max(0, m - (((n - (n%k))/k)*(k-1)) - (n%k) ));\n\np = pow(2,x+1,mod)-2;\n\nans = int((( (p%mod)*(k%mod) )%mod + (m-(x*k)+mod)%mod)%mod)\n\nprint(ans)\n\n\n\n\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\nimport math\n\n\ndef main():\n pass\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\n\ndef main():\n pass\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nn,m,k=map(int,input().split())\np=n//k\nmws=(k-1)*p+n%k\nmod=1000000009\n#print(mws)\nif(m<=mws):\n print(m)\nelse:\n con=m-mws\n #print(con,mws)\n acon=(k*(pow(2,con+1,mod)-2))%mod\n m-=(k*con)\n ans=(acon+m)%mod\n print(ans)"}, {"source_code": "'''\n Auther: ghoshashis545 Ashis Ghosh\n College: jalpaiguri Govt Enggineerin College\n Date:05/05/2020\n\n'''\nfrom bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\nfrom itertools import permutations\nfrom datetime import datetime\nfrom math import ceil,sqrt,log,gcd\ndef ii():return int(input())\ndef si():return input()\ndef mi():return map(int,input().split())\ndef li():return list(mi())\n\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\n\ndef powmod(y,m):\n res=1\n x=2\n while(y>0):\n if(y&1):\n res=(res*x)%m\n y>>=1\n x=(x*x)%m\n return res\ndef solve():\n \n mod=1000000009\n n,m,k=mi()\n x=n//k*(k-1)\n n-=(n//k)*k\n x+=n\n if(m<=x):\n print(m)\n else:\n \n x1=(m-x)\n #print(x1)\n ans=0\n x3=powmod(x1+1,mod)\n x3=(x3-2+mod)%mod\n # print(x3)\n ans=(x3*k)%mod\n ans+=(m-x1*k)\n ans%=mod\n print(int(ans))\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \nif __name__== \"__main__\":\n solve()"}, {"source_code": "n,m,k=map(int,input().split())\nmod=10**9+9\nx=n-m\nif x>=n//k:\n print(m)\nelse:\n y=n-k*x\n a=y//k\n b=y%k\n c=pow(2,a,mod)\n if c==0:\n c=mod-1\n else:\n c-=1\n ans=((2*k)%mod)*c\n ans%=mod\n ans+=x*(k-1)+b\n ans%=mod\n print(ans)\n \n"}, {"source_code": "from collections import defaultdict\nmod = int(1000000009)\ndef is_good(n, a, b):\n\twhile n:\n\t\tdigit = n%10\n\t\tif digit != a and digit != b:\n\t\t\treturn False\n\t\tn = n//10\n\t\t\t\n\treturn True\n\n\nif __name__ == '__main__':\n\tn, m, k = map(int, input().split())\n\tm -= n%k\n\tscore = n%k\n\tn -= n%k \n\n\tsets = n//k\n\n\tused = sets*(k-1)\n\t\n\tif used >= m:\n\t\tprint(m+score)\n\t\texit()\n\t\n\telse:\n\t\tfilled = m - used\n\t\t# print(score, filled)\n\t\tscore += (2*k*(((2**filled)%mod)-1)%mod)\n\t\t# print(score, sets)\n\t\tscore += ((int(sets - filled)*(k-1))%mod)\n\n\tprint(score%mod)"}, {"source_code": "R = lambda: map(int, input().split())\nn, m, k = R()\nrem = n % k\nzeros = n // k\nif n - zeros >= m:\n print(m)\nelse:\n fulls = max(0, m - zeros * (k - 1) - n % k)\n zeros -= fulls\n acc = ((1<<fulls) - 1) % (10**9 + 9) * k * 2\n print((acc + zeros * (k - 1) + rem) % (10**9 + 9) if m else 0)"}, {"source_code": "MOD = int(1e9+9)\n\ndef fast_power(x, y):\n res = 1 \n while y > 0:\n if y % 2 == 1: \n res = res * x%MOD\n x = x * x % MOD\n y //= 2\n return res\n \nn, m, k = map(int, input().split())\nx = max(0, m - n // k * (k - 1) - n % k)\nz = (m - x * k) % MOD\nres = fast_power(2, x+1)\nres = (res - 2) % MOD * k % MOD\nres = (res + z) % MOD\nprint(res)\n"}, {"source_code": "from __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\n\ndef main():\n n, m, k = [ int(x) for x in input().split() ]\n mod = 1000000009\n\n availablePositions = (k - 1) * (n // k) + n % k\n\n if availablePositions >= m:\n points = m\n else:\n positionsLeft = m - availablePositions\n\n points = (\n ((pow(2, positionsLeft + 1, mod) - 2) * k) % mod\n + (m - k * positionsLeft) % mod\n ) % mod\n\n print(points)\n\n\nBUFFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef print(*args, **kwargs):\n sep = kwargs.pop(\"sep\", \" \")\n file = kwargs.pop(\"file\", sys.stdout)\n\n atStart = True\n for x in args:\n if not atStart:\n file.write(sep)\n file.write(str(x))\n atStart = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n\n if kwargs.pop(\"flush\", False):\n file.flush()\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\nmain()\n"}, {"source_code": "MOD = 10**9 + 9\n\nn,m,k = map(int,input().split())\n\nx = (n//k) + m -n\n\nif (n - n//k) < m:\n x = n//k +m -n\n ans = pow(2,x+1,MOD)-2\n ans = ans*k+m-x*k\n print(ans%MOD)\n\nelse :\n print(m)\n"}, {"source_code": "n,m,k=map(int,input().split())\nMOD=1000000009\nx=m-(n//k*(k-1)+(n%k))\nif (x<=0):exit(print(m%MOD))\nprint(((m-x)+((pow(2,x+1, MOD)+2*MOD)-2)*k-x*(k-1))%MOD)"}, {"source_code": "#!/usr/bin/python3\n\ndef modulo_power(modulo, power, base):\n if power == 0:\n return 1\n if power == 1:\n return base\n\n remainder = power % 2\n power -= remainder\n\n half = modulo_power(modulo, power/2, base)\n\n return (half * half * modulo_power(modulo, remainder, base)) % modulo\n\ndata = [int(token) for token in input().split()]\nnum_questions, num_correct, doubler = data\n\nnum_wrong = num_questions - num_correct\ntail = num_wrong * (doubler - 1)\nhead = num_correct - tail\n\nif head < 0:\n print(num_correct)\n exit()\n\nnum_doublings = head // doubler\nremainder = head - num_doublings * doubler\nmodulo = 10**9 + 9\nresult = ((2 * doubler * (modulo_power(modulo, num_doublings, 2) - 1)) +\n remainder + tail) % modulo\n\nprint(result)\n\n"}, {"source_code": "import sys\nfrom math import *\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int, minp().split())\n\ndef add(a,b):\n\treturn (a+b)%1000000009\n\ndef sub(a,b):\n\treturn (a-(b%1000000009)+1000000009)%1000000009\n\ndef mul(a,b):\n\treturn (a*b)%1000000009\n\ndef qpow(a,n):\n\tk = a\n\tr = 1\n\tfor i in range(32):\n\t\tif n & (1<<i):\n\t\t\tr = mul(r,k)\n\t\tk = mul(k,k)\n\treturn r\n\nn, m, k = mints()\nc = (n+1)//k\nz = c*(k-1)\nif n-c*k >= 0:\n\tz += n-c*k\nd = 0\nif z < m:\n\td = m-z\nelse:\n\tprint(m)\n\texit(0)\ns = mul(k,mul(2, sub(qpow(2, d), 1)))\n#print(c,d,z,s)\ns = sub(add(s, z),mul(d,(k-1)))\nprint(s)\n"}, {"source_code": "n, m, k = map(int, input().split())\n\nd = max(0, n // k - (n - m))\n\nM = 1000000009\n\nif d > 0:\n res = ((2 * k * (pow(2, d, M) - 1)) % M + m - k * d) % M\nelse:\n res = m\n\nprint(res)"}, {"source_code": "n, corecte, k = map(int, input().split())\nincorecte = n - corecte\nmod = 10**9 + 9\n\n\ncorecte_consecutive = max(0, n - incorecte * k)\ndublari = corecte_consecutive // k\ncorecte_ramase = corecte - corecte_consecutive\n\ndef power(b, exp):\n if exp == 0: return 1\n\n half = power(b, exp//2)\n if exp%2 == 0: return (half*half) % mod\n return (half*half*b) % mod\n\nscore = (power(2, dublari+1) - 2) * k + corecte_ramase + corecte_consecutive % k\n\nprint(score % mod)\n"}, {"source_code": "MOD =1000000009\nn,m,k=map(int,input().split())\nx=max(0,m-(n-n%k)//k*(k-1)-n%k)\nres=((((pow(2,x+1,MOD))-2)%MOD)*k)%MOD\nz=(m-x*k)%MOD\nres=(res+z)%MOD\nprint (res)"}, {"source_code": "n, m, k = map(int, input().split())\nmod = 1000000000 + 9\nx = m - (n // k * (k-1) + (n%k))\nif (x <= 0):\n\tprint (m % mod)\nelse:\n\tprint(((m-x) + ((pow(2, x + 1, mod) + 2 * mod)-2)*k - x*(k-1))%mod)"}, {"source_code": "n,m,k=map(int,input().split())\nif n-n//k>=m:exit(print(m))\nmod=int(1e9+9)\nx=n//k+m-n\nr=pow(2,x+1,mod)-2\na=r*k+m-x*k\nprint((a%mod+mod)%mod)"}, {"source_code": "# -*- coding: cp1251 -*-\nimport sys\nimport itertools\nMODULO = 10**9 + 9\ndef pow(n,k):\n if k==0:\n return 1\n if k==1:\n return n\n pp = pow(n,k/2)\n if k%2 == 0:\n return (pp * pp) % MODULO\n else:\n return (pp * pp * n) % MODULO\n \ndef calc(cnt, k, lll):\n ydv = cnt/k\n ostat = cnt - ydv * k\n #ydv\n #1 - 2*k, 2 - 6*k, 3 - 14*k, 30*k\n if False:\n b1 = k<<1\n else:\n b1 = k*2\n \n if False:\n ppc = s = \"0b1\" + ''.join(['0']*(ydv))\n ppc = eval(ppc)\n res = b1*ppc - b1\n else:\n if True:\n if True:\n res = b1 * (pow(2, ydv) - 1)\n else:\n res = (b1 * (1<<(ydv)) - b1) %(10**9+9)\n else:\n res = (b1 * (2**ydv) - b1) %(10**9+9)\n \n return res + ostat + lll\n'''\ndef calc___________(cnt, k):\n res = 0\n acc = 0\n for i in xrange(cnt):\n res += 1\n acc += 1\n if acc == k:\n acc = 0\n res *= 2\n\n return res\n'''\ndef solve(n, m, k):\n ans_plus = m\n ans_minus = n-m\n #fails_cnt = n/k\n if ans_minus * k + k - 1 >= n:\n #if fails_cnt <= ans_minus:\n #print \"!\"\n return m\n else:\n #++++++++++++ ____ .+++.+++.+++|\n ans_plus -= ans_minus * (k - 1)\n return calc(ans_plus, k, m - ans_plus)\n\nn, m, k = map(int, sys.stdin.readline().split())\n\nprint str(solve(n, m, k) % (MODULO))\n"}, {"source_code": "d = 1000000009\nn, m, k = map(int, input().split())\nif (n - m) * k > n:\n print(m)\nelse:\n t = n // k - n + m + 1\n print(((pow(2, t, d) - 1 - t) * k + m) % d)"}, {"source_code": "import math\ndef get_res(n, m, k):\n D = 1000000009\n if m <= (n-m)*(k-1):\n return m%D\n p = max(0, m-(n-m)*(k-1))\n result = (2*k*(pow(2,p/k, D)-1) + p%k + (n-m)*(k-1)) % D\n return result\n\n#N = int(raw_input()) \nn, m, k= [int(s) for s in raw_input().split(\" \")]\nresult = get_res(n, m, k)\nprint \"{}\".format(result)\n"}, {"source_code": "def chk(x):\n d = (m - x) // (k - 1) * k\n if (m - x) % (k - 1):\n d += 1 + (m - x) % (k - 1)\n if d <= n - x:\n return True\n else:\n return False\n\ndef calc(e):\n if e == 1:\n return 2\n if e & 1:\n d = 2\n else:\n d = 1\n f = calc(e >> 1)\n d = d * f % D * f % D\n return d\n\nn, m, k = map(int, input().split())\nD = 1000000009\n\nl = 0\nh = n\n\nwhile l < h:\n mid = l + h >>1\n if chk(mid):\n h = mid\n else:\n l = mid + 1\n\nh = calc(l // k + 1) - 2 \nif h < 0:\n h += D\n\nprint((k * h % D + m - l // k * k) % D)\n"}, {"source_code": "n, m, k = map(int, input().split())\n\nif (n - m) >= n//k:\n\tprint (m)\nelse:\n\tlongest_correct_streak = n - k*(n - m)\n\tp = longest_correct_streak//k\n\tprint ((k*(pow(2, p+1, 1000000009) - 2) + (longest_correct_streak % k) + (n - m)*(k - 1)) % 1000000009)\n"}, {"source_code": "n, m, k = map(int, raw_input().split())\na = 1000000009\n\nudv = m - n + n / k\nif udv <= 0:\n print m\nelse:\n x = (pow(2, udv + 1, a) - 2) * k\n print (x + m - udv * k ) % a"}, {"source_code": "import sys, math\ndef rs():\n return sys.stdin.readline().strip()\ndef ri():\n return int(sys.stdin.readline().strip())\ndef ras():\n return list(sys.stdin.readline().strip())\ndef rai():\n return map(int,sys.stdin.readline().strip().split())\nMAX = 1000000009\ndef bp(a,b):\n r = 1\n while b != 0:\n if b % 2:\n r = r*a%MAX\n b -= 1\n else:\n a = a*a%MAX\n b /= 2\n return r\n\n\n\n\ndef solve():\n n,m,k = rai()\n t = n - m\n\n if m < k:\n return m\n\n count = m / (k - 1)\n\n if count*(k-1) == m:\n count -= 1\n\n if count <= t:\n return m\n\n\n r = (k - 1) * t\n\n\n v = m - r\n\n\n o = v / k\n\n ost = v - o*k\n\n\n rr = k*(bp(2, (o + 1)) - 2) % MAX + ost\n\n\n return (r + rr) % MAX\n\nprint solve()"}, {"source_code": "n , m , k = map(int, raw_input().split())\nM = 10**9 + 9\nx = max(0, m - n + n / k)\nprint (m - k * x + k * (pow(2, x + 1, M) - 2) + M) % M \n"}, {"source_code": "mod = 1000000009\n\ndef mpow(x, y):\n\tif y == 0:\n\t\treturn 1\n\tans = mpow(x, y/2)\n\tans = (ans * ans) % mod\n\tif y%2 > 0:\n\t\tans = (ans * x) % mod\n\treturn ans\n\t\t\n\nn, m, k = map(int, raw_input().split())\nfr = n % k + (n/k)*(k - 1)\nif fr >= m:\n\tans = m\nelse:\n\ta = m - fr\n\tfr -= a*(k-1)\n\tans = mpow(2, a)\n\tans = (ans + mod - 1) % mod\n\tans = (ans * 2) % mod\n\tans = (ans * k) % mod\n\tans = (ans + fr) % mod\nprint ans\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+9\nx=max(0,m-(n/k*(k-1)+n%k))\nprint ((m-x+(pow(2,x+1,M)-2)*k-x*(k-1))%M+M)%M"}, {"source_code": "'''\nCreated on 16.08.2013\n\n@author: Sergei Zalivako\n'''\n\ndef powmod(b,e,n):\n \"\"\"powmod(b,e,n) computes the eth power of b mod n. \n (Actually, this is not needed, as pow(b,e,n) does the same thing for positive integers.\n This will be useful in future for non-integers or inverses. Currently assumes e>0.)\"\"\"\n accum = 1; i = 0; bpow2 = b\n while ((e>>i)>0):\n if((e>>i) & 1):\n accum = (accum*bpow2) % n\n bpow2 = (bpow2*bpow2) % n\n i+=1\n return accum\n\nMOD = 1000000009\n\nn, m, k = raw_input().split()\n\nn = int(n)\nm = int(m)\nk = int(k)\n\ndoubles = n / k\nwrong = n - m\n\nif ( doubles <= wrong):\n ans = m\nelse:\n ost = n - k * wrong\n nth = ost / k\n plus = ost % k\n sum = (((powmod(2, nth, MOD) - 1) * 2) * k + plus) % MOD\n ans = ((k - 1) * wrong + sum) % MOD\n\nprint ans\n "}, {"source_code": "from sys import stdin\nimport fractions\n\ndef line():\n return stdin.readline().split()\ndef read_int():\n return int(line()[0])\ndef read_ints():\n return [int(x) for x in line()]\ndef memo(fn):\n table = {}\n def memoized(*args):\n if args not in table:\n table[args] = fn(*args)\n return table[args]\n return memoized\n\ndef solve(n, m, k):\n original_n = n\n if (n - m)*k >= n:\n return m\n\n skips = (n - m)\n n -= skips*k\n doubles, last = n / k, n % k\n #print \"D%s S%s L%s\" % (doubles, skips, last)\n assert doubles*k + skips*k + last == original_n\n assert doubles*k + skips*(k-1) + last == m\n\n score = 2*k*(pow(2, doubles, 1000000009) + 1000000008)\n score += (k - 1) * skips\n score += last\n score = score % 1000000009\n\n assert score >= 0\n return score\n\nn, m, k = read_ints()\nprint solve(n, m, k)\n"}, {"source_code": "n, m, k = map(int, input().split())\n\nd = max(0, n // k - (n - m))\n\nM = 1000000009\n\nif d > 0:\n res = ((2 * k * (pow(2, d, M) - 1)) % M + m - k * d) % M\nelse:\n res = m\n\nprint(res)"}, {"source_code": "n,m,k = map(int, raw_input().split())\nmod = 10**9+9\nx = max(0, n/k-n+m)\np = pow(2,x+1,mod)-2\nprint (p*k+m-x*k)%mod"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+9\nx=max(n/k-n+m,0)\na=k*2*(pow(2,x,M) - 1)\nprint (a+m-k*x+M)%M\n\n"}, {"source_code": "import math\nimport sys\n\ndef exp_by_squaring(x, n):\n mod = 1000000009\n\n if n < 0:\n x = 1 / x\n n = -n\n\n if n == 0:\n return 1\n\n y = 1\n while n > 1:\n if n % 2 == 0:\n x = x % mod * x % mod\n n = n / 2\n else:\n y = x % mod * y % mod\n x = x % mod * x % mod\n n = (n - 1) / 2\n\n return x % mod * y % mod\n\ni = raw_input().split()\nn, m, k = int(i[0]), int(i[1]), int(i[2])\n\nmod = 1000000009\nmin_of_double = max(0, m - (n - n % k) / k * (k - 1) - n % k)\n\noutput = (exp_by_squaring(2, min_of_double + 1) - 2) * k + m - min_of_double * k\nprint output % mod\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+9\nx=max(n/k-n+m,0)\na=k*2*(pow(2,x,M) - 1)\nprint (a+m-k*x+M)%M\n\n"}, {"source_code": "import sys\nfrom collections import defaultdict, Counter\nfrom itertools import permutations, combinations\nfrom math import sin, cos, asin, acos, tan, atan, pi\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition, yes = \"YES\", no = \"NO\", none = \"-1\") :\n if condition == None:\n print (none)\n elif condition :\n print (yes)\n else :\n print (no)\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rstr() :\n return sys.stdin.readline().strip()\n\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits[::-1]\n\ndef undigits(x, p) :\n value = 0\n for d in x :\n value *= p\n value += d\n return value\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\ndef vector_distance(a, b) :\n diff = vector_diff(a, b)\n \n return scalar_product(diff, diff) ** 0.5\n\ndef vector_inverse(v) :\n r = [-x for x in v]\n\n return tuple(r)\n\ndef vector_diff(a, b) :\n return vector_sum(a, vector_inverse(b))\n\ndef vector_sum(a, b) :\n r = [c1 + c2 for c1, c2 in zip(a, b)]\n \n return tuple(r)\n\ndef scalar_product(a, b) :\n r = 0\n for c1, c2 in zip(a, b) :\n r += c1 * c2\n\n return r\n\ndef check_rectangle(points) :\n assert(len(points) == 4)\n\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n sides = (\n vector_diff(A1, A2),\n vector_diff(A2, A3),\n vector_diff(A3, A4),\n vector_diff(A4, A1),\n )\n if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :\n return True\n return False\n\ndef check_square(points) :\n if not check_rectangle(points) :\n return False\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n side_lengths = [\n (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])\n ]\n if len(set(side_lengths)) == 1 :\n return True\n \n return False\n\ndef check_right(p) :\n # Check if there are same points\n for a, b in [\n (p[0], p[1]),\n (p[0], p[2]),\n (p[1], p[2]),\n ] :\n if a[0] == b[0] and a[1] == b[1] :\n return False\n\n a, b, c = p\n a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a) \n\n return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0\n\ndef modmatrixproduct(a, b, mod) :\n n, m1 = len(a), len(a[0])\n m2, k = len(b), len(b[0])\n\n assert(m1 == m2)\n m = m1\n\n r = [[0] * k for i in range(n)]\n for i in range(n) :\n for j in range(k) :\n for l in range(m) :\n r[i][j] += a[i][l] * b[l][j]\n r[i][j] %= mod\n return r\n\ndef modmatrixpower(a, n, mod) :\n magic = 2\n for m in [2, 3, 5, 7] :\n if n % m == 0 :\n magic = m\n break\n\n r = None\n if n < magic : \n r = a\n n -= 1\n else :\n s = modmatrixpower(a, n // magic, mod)\n r = s\n for i in range(magic - 1) :\n r = modmatrixproduct(r, s, mod)\n\n for i in range(n % magic) : \n r = modmatrixproduct(r, a, mod)\n \n return r\n\nn, m, k = rints()\ne = n - m\nx = max(n / k - e, 0)\n\nmod = 10 ** 9 + 9\ns = 0\nif x > 0 :\n s += 2 * (pow(2, x, mod) - 1) * k\n\n\ns += m - k * x\n\nprint s % mod\n"}, {"source_code": "MOD = 10 ** 9 + 9\nn, m, k = map(int, raw_input().split())\nX = max(0, m - (n - n % k) / k * (k - 1) - n % k)\nprint ((pow(2, X + 1, MOD) - 2) * k + m - X * k) % MOD"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(2*10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\nMOD=10**9+9\nn,m,k=listInput()\nen=max(0, m - ((n - n% k) / k) * (k-1) - n% k)\n#print en\nans=(k*(pow(2,en+1,MOD)-2)+m-en*k)%MOD\nprint ans"}, {"source_code": "\nBASE = 1000000009\n\ndef mul(a, b):\n return [[sum((r*c)%BASE for r, c in zip(row, col))%BASE for col in zip(*b)] for row in a]\n\ndef power(a, n):\n if n==0: return [[1, 0], [0, 1]]\n if n==1: return a\n if n & 1: return mul(a, power(mul(a, a), n >> 1))\n return power(mul(a, a), n >> 1)\n\nN, M, K = map(int, raw_input().split())\n\nquo = N/K\nrem = N%K\next = 0\n\nif M<=quo*(K-1)+rem:\n print M\nelse:\n ext = M-(quo*(K-1)+rem)\n v = mul(power([[2, (2*K)%BASE], [0, 1]], ext), [[0], [1]])\n print ( v[0][0]+M-(ext*K) )%BASE\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+9\nx=max(n/k-n+m,0)\na=k*2*(pow(2,x,M) - 1)\nprint (a+m-k*x+M)%M\n\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+9\nx=max(n/k-n+m,0)\na=k*2*(pow(2,x,M) - 1)\nprint (a+m-k*x+M)%M\n\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+9\nx=max(n/k-n+m,0)\na=k*2*(pow(2,x,M) - 1)\nprint (a+m-k*x+M)%M\n\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\n\n#x + y*(k - 1) = m\n#x + y*k + z = n\n#m + y + z = n\ny = min(n-m,m/(k-1));\nx = m - y*(k - 1);\n#print x,y;\nnum = x/k;\n\nmod = 10**9 + 9;\nans = (pow(2,num + 1,mod) - 2)*k + x%k + (k-1)*y;\nans = (ans%mod + mod)%mod;\nprint ans;"}, {"source_code": "BASE=1000000009\ndef pow(x,y):\n\tres=1\n\twhile (y):\n\t\tif (y%2==1):res=res*x%BASE\n\t\tx=x*x%BASE\n\t\ty/=2\n\treturn res%BASE\nn,m,k=map(long,raw_input().split())\nx=((n/k)*(k-1))+n%k;\nif (x>=m):\n\tprint m\n\texit(0)\nt=m-x\nu=pow(2,t)\nu=(2*(u-1)*k+m-t*k)%BASE\nprint u\n"}, {"source_code": "n,m,k = map(int,input().split())\n\nchunks = n//k\n\nfreespots = chunks*(k-1) + n%k\n\nif m <= freespots:\n print(m)\nelse:\n doubles = m-freespots\n\n dchunks = doubles\n chunks -= dchunks\n\n total = (pow(2,dchunks,1000000009)-1)*k*2 \n \n total += n%k + chunks*(k-1)\n\n print(total%1000000009)\n"}, {"source_code": "mod = 10**9 + 9\n\ndef f(n,m,k):\n\ts = 0\n\tw = m-n+n/k\n\tif w > 0:\n\t\tn -= w * k\n\t\tm -= w * k\n\t\ts = 2*(pow(2,w,mod)-1)*k\n\treturn (s + m)%mod\n\nfrom sys import *\n\nn, m, k = map(int, raw_input().strip().split())\n\nprint f(n,m,k)\n"}, {"source_code": "n,m,k=map(int,input().split())\npri=pow(10,9)+9\nx=n%k\ny=n//k\nif(m<=y*(k-1)+x):\n print(m)\n exit()\nelse:\n\n sert=n-m\n left=m-sert*(k-1)\n\n g=m-left\n \n sets=left//k\n le=left%k\n total=k*((pow(2,sets+1,pri))-2)\n total%=pri\n print((total+g+le)%pri)\n \n #nth term is 2^n-2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "#/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\n# exam\n# 5 3 2\n# o x o x o \n# 1 1 2 0 3 \n# 5 4 2\n# o o o x o\n# 1 4 5 5 6 \n\ndef modconst():\n\treturn 1000000009;\n\ndef modpow(b, e, m):\n\t\"\"\" from Wikipedia(ja): \u51aa\u5270\u4f59 \"\"\"\n\tret = 1\n\twhile(e > 0):\n\t\tif(e & 1):\n\t\t\tret = (ret * b) % m\n\t\te >>= 1\n\t\tb = (b * b) % m\n\treturn ret\n\n# n - num of questions (max: 10E9)\n# m - num of correct answers\n# k - when his points double\nn, m, k = [ int(x) for x in raw_input().split(\" \") ]\n\n# n = 11, k = 3 \n# o o x o o x o o x o o\n# max m that has no double = 8 ( = k-1 * (n // k ) + n % k)\nmaxm = (k-1) * (n // k) + n % k\nif( m <= maxm):\n\t# no double\n\tprint m % modconst()\nelse:\n\t# has double\n\t# to minumum point, we should use double as faster as possible.\n\tnumdouble = m - maxm\n\tpoint = 0\n\t# point += k * (2**(numdouble+1) - 2)\n\t# point += m - (numdouble * k) \n\tpoint = k * (modpow(2, numdouble+1, modconst()) - 2) + m - numdouble * k\n\tprint point % modconst()\n\n# 0 0 0 0 0 0 0 0 0 o \n# 1 2 6 7 81819204243\n# 3* 2 6 14 30\n# 2^n -2\n# o o o o o ... ... ... o o o x o o o x o o o\n"}, {"source_code": "n, m, k = map(int, input().split())\nx, c, ic, ans, mod = min(m//(k-1), n-m), m, n-m, 0, 10**9 + 9\nc = c - (k-1)*x\np, r = c//k, c%k\nans = ((((pow(2, p+1, mod) - 2 + mod)%mod) * (k%mod))%mod + (k-1)*x + r)%mod\nprint(ans)"}, {"source_code": "def pow(a, n, mod):\n if n == 1:\n return a\n if n%2 == 0:\n return pow(a, n/2, mod)**2 % mod\n else:\n return a*pow(a, n/2, mod)**2 % mod\n\nn, m, k = map(int, raw_input().split())\nmod = 10**9 + 9\n\nl = n%k\nt = n/k - (n-m)\nif t <= 0:\n print m\nelse:\n print (k*(pow(2, (t+1), mod) - 2) + (m-k*t))%mod"}, {"source_code": "INF = 10 ** 9 + 9\n\ndef solver():\n n,m,k = map(int, raw_input().split())\n x = max(0, m - n + n /k)\n score = (m - k * x + k * (pow(2,x+1,INF) - 2) + INF) % INF\n print score\n \n\n\n\nif __name__ == \"__main__\":\n solver()\n\n"}, {"source_code": "BASE=1000000009\ndef pow(x,y):\n\tres=1\n\twhile (y):\n\t\tif (y%2==1):res=res*x%BASE\n\t\tx=x*x%BASE\n\t\ty/=2\n\treturn res%BASE\nn,m,k=map(long,raw_input().split())\nx=((n/k)*(k-1))+n%k;\nif (x>=m):\n\tprint m\n\texit(0)\nt=m-x\nu=pow(2,t)\nu=(2*(u-1)*k+m-t*k)%BASE\nprint u"}, {"source_code": "# author:heroming\n# -*- coding:utf8-*-\n\ndef power(a, mod) :\n s, g = 1, 2\n while a > 0 :\n if (a & 1) :\n s = s * g % mod\n a >>= 1\n g = g * g % mod\n return s\n\nmod = 1000000009\n\nn, m, k = map(int, raw_input().split())\nw = n / k\nif m + w <= n :\n print m\nelse :\n e = m + w - n\n p = power(e + 1, mod)\n ans = ((p - 2) * k + m - e * k) % mod\n print ans\n"}, {"source_code": "MOD = 10 ** 9 + 9\nn, m, k = map(int, raw_input().split())\nif k * (n - m + 1) - 1 >= n:\n print m\nelse:\n consecutive = n - k * (n - m)\n print ((2 * k * pow(2, consecutive / k, MOD) - 2 * k + consecutive % k + (k - 1) * (n - m)) % MOD + MOD) % MOD\n"}, {"source_code": "def modexp(x, n, m):\t\n\tif n == 0: return 1;\n\tr = modexp(x, n >> 1, m);\n\tif n & 1: return r * r * x % m;\n\treturn r * r % m;\n\t\nn, m, c = map(int, raw_input().split());\nx = n - m;\ny = min(m, x * (c - 1));\nr = m - y;\ny += r % c;\nt = r // c + 1;\nMOD = 1000000009;\nret = (modexp(2, t, MOD) - 2) * c + y;\nprint ret % MOD;\n"}, {"source_code": "n, m, k = map(int, raw_input().split())\nmod = 10 ** 9 + 9\n\nwrong = n - m\nright = (k - 1) * wrong\nleft = m - right\n\ndef cal(k, times):\n if times == 0: return 0\n else:\n return (pow(2, times + 1, mod) - 2) * k\n \nif left <= 0:\n print m % mod\nelse:\n times = left / k\n remain = left % k\n print (cal(k, times) + remain + right) % mod"}, {"source_code": "I=lambda:map(int, raw_input().split())\nbignum = 10**9+9\n\nn, m, k = I()\nzeroes = n-m\nif zeroes >= n/k:\n print m\n exit()\n\nfullsets = n/k - zeroes\nremaining = n - k*fullsets - zeroes\n\nscore = (k * (pow(2, fullsets+1, bignum) - 2)) % bignum\n\nscore += remaining\nscore %= bignum\n\nprint score"}], "negative_code": [{"source_code": "n,m,k=map(int,input().split())\n\ndef ff(t):\n\n res=0\n\n while t>0:\n\n res+=2**t\n t-=1\n\n return res\n\nif k*(n-m+1)>n:\n \n print(m)\n \nelse:\n\n minsc=(k-1)*(n-m+1)\n tem1=n-(k*(n-m+1)-1)\n tem2=m-(k-1)*(n-m+1)\n n=tem1\n m=tem2\n\n t=int(n/k)\n minsc+=n%k\n\n minsc+=ff(t)*k\n\n print(minsc)\n\n \n\n \n \n"}, {"source_code": "n,m,k = map(int, raw_input().split())\nw = n - m\ns = (k-1) * w\nm = max(0,m-s)\nnn = m/k\nres = 0\nfor i in xrange(nn):\n\tres += k\n\tres *=2\nres += s + m%k\nprint res"}, {"source_code": "n, corecte, k = map(int, input().split())\nincorecte = n - corecte\nmod = 10**9 + 9\n\n\ncorecte_consecutive = max(0, n - incorecte * k)\ndublari = corecte_consecutive // k\ncorecte_ramase = corecte - corecte_consecutive\n\n\nscore = 0\nscore = (2**(dublari+1) - 2) * k\n\n#print(\"scor chiar dupa dublari = %i\" % score)\n#print(\"corecte_consecutive = %i\" % corecte_consecutive)\n#print(\"dublari = %i\" % dublari)\n#print(\"corecte_ramase = %i\" % corecte_ramase)\n\n \nscore += corecte_ramase\nscore += corecte_consecutive % k\n\nprint(score)\n"}, {"source_code": "from sys import stdin\nn, m, k = map(int, stdin.readline().split(' '))\ndoublesNeeded = int(m - (n - n / k))\nscore = 0\nif doublesNeeded > 0:\n score += 1\n score <<= (doublesNeeded + 1)\n score -= 1\n score *= k\n score -= k\nscore += m - doublesNeeded * k\nscore %= 1000000009\nprint(score)\n"}, {"source_code": "from sys import stdin\nn, m, k = map(int, stdin.readline().split(' '))\ndoublesNeeded = int(m - (n - n / k))\nscore = 0\nif doublesNeeded > 0:\n score += 1\n score <<= (doublesNeeded + 1)\n score -= 1\n score *= k\n score -= k\nif m > 0:\n score += m - doublesNeeded * k\n\nscore %= 1000000009\nprint(score)\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\nt = m/k\t\nmod = 1000000009\nif t > n-m :\n\tans = (((n-m))*k)%mod + ((((2**(t-(n-m) + 1))%mod - 2)%mod)*k)%mod\nelse:\n\tans = m\nprint ans\n\n\t\n\t\n"}, {"source_code": "# Allah is the most gracious and the Most Marchiful\nnum,m,k=map(int,input().split())\ni=1\nj=num\nwhile(i<=j):\n mid=(i+j)//2\n if (mid+((num-mid)//2)>=m):\n MM=mid\n j=mid-1\n else:\n i=mid+1\n#print(MM)\nM=10**9+9\np=MM//k\n\nans=(pow(2,p+1,M)-2)*k\nans+=MM%k\nans=ans%M\nans+=m-MM\nans=ans%M\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "line = raw_input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n\n\ndef power(g_base,a,p_mod):\n x=1\n bits = \"{0:b}\".format(a)\n for i, bit in enumerate(bits):\n if bit=='1': x = (((x**2)*g_base)%p_mod)\n elif bit=='0': x = ((x**2)%p_mod)\n return x%p_mod\n\n\n\nimport time\nt = time.clock()\nlimit = n - (n/k)\nif m <= limit : print m % 1000000009 \nelse:\n score = 0\n totry = m - limit\n i = 0\n m -=(totry*k)\n score = k*(((1-power(2,(totry+1),1000000009))/(1-2))-1) % 1000000009\n score += m\n print score\n"}, {"source_code": "line = raw_input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n\n\ndef power(g_base,a,p_mod):\n x=1\n bits = \"{0:b}\".format(a)\n for i, bit in enumerate(bits):\n if bit=='1': x = (((x**2)*g_base)%p_mod)\n elif bit=='0': x = ((x**2)%p_mod)\n return x%p_mod\n\n\n\nimport time\nt = time.clock()\nlimit = n - (n/k)\nif m <= limit : print m % 1000000009 \nelse:\n score = 0\n totry = m - limit\n i = 0\n m -=(totry*k)\n score = k*(((1-power(2,(totry+1),1000000009))/(1-2))-1) % 1000000009\n score += m\n print score\n"}, {"source_code": "import sys\n\ninputs = sys.stdin.readline().split()\nn = int(inputs[0])\nm = int(inputs[1])\nk = int(inputs[2])\n\nw = n - m\n\nif k*w + (k-1) >= n:\n print m\nelse:\n no_double = n - k*w\n result = 0\n cycle = no_double/k\n remainer = no_double%k\n for i in xrange(cycle):\n result = (result + k) * 2\n result += remainer + w*(k-1) \n print result\n\n\n\n"}, {"source_code": "N , M , K = map(int, raw_input().split() ) \na = N - M \nMod = 1000000009 ;\n\ndef calc( n ):\n n += 1 \n res = 1 ; add = 2 ;\n while( n ):\n if n&1 :\n res = ( res * add ) % Mod ; \n add = ( add * add ) % Mod ; \n n >>= 1 ;\n return res ;\n \nif ( N<=a*K+K-1 ):\n ans = M ; \nelse:\n ans = ( calc( N / K - a ) + M - ( N / K - a ) * K ) % Mod \nprint ans \n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nimport bisect\nfrom math import floor\ndef bo(i):\n return ord(i)-ord('a')\nn,m,k=map(int,input().split())\nmod=10**9+9\np=int(floor(m-((n+1)*(k-1))//k))\n#print(n/k-n+m,p)\nprint((k*(pow(2,max(0,p+1),mod))-2*k+m-p*k+mod)%mod ) "}, {"source_code": "mod = 1000000009\nn,m,k = map(int,(input().split()));\n\nx = max(0, m - (((n - n%k) / k) * (k-1)) - (n%k) );\n\np = (pow(2,x+1)-2)%mod;\n\nans = int(((p*k)%mod + (m-x*k)%mod)%mod)\n\nprint(ans)\n\n\n\n\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\n\nM=10**9+9\na=k*2*(pow(2,(max(n/k-n+m,0)),M) - 1)\nprint (a + n%k + (k-1)*(n-m))%M"}, {"source_code": "MOD=1000000009;\ndef solve(a,n):\n ans=1;\n p=a;\n while(n>0):\n if(n%2==1): ans*=p;\n n/=2;\n ans%=MOD;\n p=(p*p)%MOD;\n return ans;\nn,m,k=map(int,input().split());\np=n-m+1;\nif((k-1)*p>=m):\n print(m);\nelse:\n v=m-(p-1)*(k-1);\n ans=(p-1)*(k-1);\n t=v//k;\n ans=(ans+k*(solve(2,t)-1)*2%MOD+MOD+v%k)%MOD;\n print(ans);"}, {"source_code": "n,m,k = map(int,raw_input().split())\ny = min(n - m,m);\nx = m - y;\nnum = x/k\n\nmod = 10**9 + 9;\nans = (pow(2,num+1,mod) - 2)*k + x%k + y;\nans = (ans%mod + mod)%mod;\nprint ans;\n\n"}, {"source_code": "n,m,k = map(int, raw_input().split())\nmod = 10**9+9\nx = max(0, n/k-n+m)\np = pow(2,x+1,mod)-2\nprint p*k+m-x*k"}, {"source_code": "import math\n\ni = raw_input().split()\nn, m, k = int(i[0]), int(i[1]), int(i[2])\n\nmod = 100000009\nmin_of_double = max(0, m - (n - n % k) / k * (k - 1) - n % k)\n#min_of_double = abs(min(0, n - m - m / k))\n\noutput = (math.pow(2, min_of_double + 1) - 2) * k + m - min_of_double * k\nprint output % mod\n"}, {"source_code": "N , M , K = map(int, raw_input().split() ) \na = N - M \nMod = 1000000009 ;\n\ndef calc( n ):\n n += 1 \n res = 0 ; add = 2 ;\n while( n ):\n if n&1 :\n res = ( res + add ) \n if res >= Mod :\n res -= Mod \n add = ( add * add ) % Mod ; \n n >>= 1 ;\n return res ;\n \nif ( N<=a*K+K-1 ):\n ans = M ; \nelse:\n ans = ( calc( N / K - a ) + M - ( N / K - a ) * K ) % Mod \nprint ans \n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+7\nx=max(0,m-(n/k*(k-1)+n%k))\nprint (((m-x)+(pow(2,x+1,M)-2)*k-x*(k-1))%M+M)%M"}, {"source_code": "import sys, math\ndef rs():\n return sys.stdin.readline().strip()\ndef ri():\n return int(sys.stdin.readline().strip())\ndef ras():\n return list(sys.stdin.readline().strip())\ndef rai():\n return map(int,sys.stdin.readline().strip().split())\n\n\n\n\ndef solve():\n n,m,k = rai()\n\n MAX = 1000000009\n t = n - m\n\n count = 0\n\n if m < k:\n return m\n\n count = m / (k - 1)\n\n if count*(k-1) == m:\n count -= 1\n\n if count <= t:\n return m\n\n\n r = (k - 1) * t\n\n v = m - r\n\n r = r % MAX\n\n o = v / k\n\n ost = v - o*k\n\n rr = 2 ** (o + 1) % MAX + ost\n \n return (r + rr) % MAX\n\nprint solve()"}, {"source_code": "import math\n\ni = raw_input().split()\nn, m, k = int(i[0]), int(i[1]), int(i[2])\n\nmod = 100000009\nmin_of_double = max(0, m - (n - n % k) / k * (k - 1) - n % k)\n#min_of_double = abs(min(0, n - m - m / k))\n\noutput = (math.pow(2, min_of_double + 1) - 2) * k + m - min_of_double * k\nprint int(output % mod)\n"}, {"source_code": "def inp(n):\n if n == 1:\n return map(int, stdin.readline().split())\n elif n == 2:\n return map(float, stdin.readline().split())\n else:\n return map(str, stdin.readline().split())\n\n\ndef sum_range(n):\n return (n * (n + 1)) // 2\n\n\ndef round1(x):\n if (x - int(x) >= .5):\n return ceil(x)\n else:\n return floor(x)\n\n\ndef mult(x, y):\n return ((x % num) * (y % num)) % num\n\n\nfrom sys import stdin\nfrom math import *\n\nn, m, k = inp(1)\nans, num = floor(n / k) * (k - 1) + (n % k), 1000000009\n\nif ans >= m:\n print(m % num)\nelse:\n extra = (m - ans) % num\n ans += (mult(k * 2, 2 ** extra - 1) - mult(k - 1, extra)) % num\n print(ans)\n"}, {"source_code": "from sys import stdin\nn, m, k = map(int, stdin.readline().split(' '))\ndoublesNeeded = int(m - (n - n / k))\nscore = 0\nif doublesNeeded > 0:\n score += 1\n score <<= (doublesNeeded + 1)\n score -= 1\n score *= k\n score -= k\nscore += m - doublesNeeded * k\nscore %= 1000000009\nprint(score)\n"}, {"source_code": "n,m,k=map(int,input().split())\n\ndef ff(t):\n\n res=0\n\n while t>0:\n\n res+=2**t\n t-=1\n\n return res\n\nif k*(n-m+1)>n:\n \n print(m)\n \nelse:\n\n minsc=(k-1)*(n-m+1)\n tem1=n-(k*(n-m+1)-1)\n tem2=m-(k-1)*(n-m+1)\n n=tem1\n m=tem2\n\n t=int(n/k)\n minsc+=n%k\n\n minsc+=ff(t)*k\n\n print(minsc)\n\n \n\n \n \n"}, {"source_code": "import math\n\ni = raw_input().split()\nn, m, k = int(i[0]), int(i[1]), int(i[2])\n\nmod = 100000009\nmin_of_double = max(0, m - (n - n % k) / k * (k - 1) - n % k)\n#min_of_double = abs(min(0, n - m - m / k))\n\noutput = (math.pow(2, min_of_double + 1) - 2) * k + m - min_of_double * k\nprint output % mod\n"}, {"source_code": "n, m, k = map(int, raw_input().split())\n\nwrongNum = n - m\nintervalNum = n / k\n\nif wrongNum >= intervalNum :\n score = m\nelse :\n prefixSum = 2*k * (2 ** (intervalNum - wrongNum) - 1)\n suffixSum = (m - ((intervalNum-wrongNum) * k)) * (k-1)\n score = (prefixSum + suffixSum) % (10 ** 9 + 9)\n\nprint score\n"}, {"source_code": "import sys, math\ndef rs():\n return sys.stdin.readline().strip()\ndef ri():\n return int(sys.stdin.readline().strip())\ndef ras():\n return list(sys.stdin.readline().strip())\ndef rai():\n return map(int,sys.stdin.readline().strip().split())\n\n\n\n\ndef solve():\n n,m,k = rai()\n\n MAX = 1000000009\n t = n - m\n\n count = 0\n\n if m < k:\n return m\n\n count = m / (k - 1)\n\n if count*(k-1) == m:\n count -= 1\n\n if count <= t:\n return m\n\n\n r = (k - 1) * t\n\n v = m - r\n\n r = r % MAX\n\n o = v / k\n\n ost = v - o*k\n\n rr = 2 ** (o + 1) % MAX + ost\n \n return (r + rr) % MAX\n\nprint solve()"}, {"source_code": "import math\n\ni = raw_input().split()\nn, m, k = int(i[0]), int(i[1]), int(i[2])\n\nmod = 100000009\nmin_of_double = max(0, m - (n - n % k) / k * (k - 1) - n % k)\n#min_of_double = abs(min(0, n - m - m / k))\n\noutput = (math.pow(2, min_of_double + 1) - 2) * k + m - min_of_double * k\nprint int(output % mod)\n"}, {"source_code": "n, m, k = map(int, input().split())\n\nd = max(0, n // k - (n - m))\n\nif d > 0:\n res = pow(k, d + 1, 1000000009) + m - k * d\nelse:\n res = m\n\nprint(res)"}, {"source_code": "R = lambda: map(int, input().split())\n\n\nn, m, k = R()\nrem = n % k\nzeros = n // k\nfulls = max(0, m - zeros * (k - 1) - rem)\nzeros -= fulls\nacc = 2 * ((1<<fulls) - 1) * k % (10**9 + 9)\nprint((acc + zeros * (k - 1) + rem) % (10**9 + 9))"}, {"source_code": "\nfrom sys import stdin, stdout\nread_ints = lambda: map(int, raw_input().split())\nread_floats = lambda: map(float, raw_input().split())\n\ndef main():\n n, m, k = read_ints()\n print f(n, m, k) % 1000000009\n\ndef f(n, m, k):\n i = 1\n j = 0\n while True:\n if m < k :\n return m\n if i * k >= n:\n return (j * k % 1000000009 + m - (i-1)*k) % 1000000009\n\n if m % (i*k-1) == 0:\n if m / (i*k-1) * (i*k) -1 == n:\n return (j * k + k -1) * (m / (i*k-1)) % 1000000009\n\n if m / (i*k-1) * (i*k) + m % (i*k-1) <= n:\n return ((j * k % 1000000009 + k-1) * (m/(i*k-1)) % 1000000009 + f(n - m / (i*k-1) * (i*k), m % (i*k-1), k)) % 1000000009\n\n j += 1\n j *= 2\n i += 1\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,m,k = map(int,input().split())\n\nchunks = n//k\n\nfreespots = chunks*(k-1) + n%k\n\nif m <= freespots:\n print(m)\nelse:\n doubles = m-freespots\n\n dchunks = doubles\n chunks -= dchunks\n\n total=0\n while dchunks>0:\n total = (total+k)*2\n dchunks -=1\n \n total += n%k + chunks*(k-1)\n\n print(total)\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\n\nM=10**9+9\na=k*2*(pow(2,(max(n/k-n+m,0)),M) - 1)\nprint (a + n%k + (k-1)*(n-m))%M"}, {"source_code": "import sys\nfrom math import gcd,sqrt,ceil,log2\nfrom collections import defaultdict,Counter,deque\nfrom bisect import bisect_left,bisect_right\nimport math\nsys.setrecursionlimit(2*10**5+10)\nimport heapq\nfrom itertools import permutations\n\n# input=sys.stdin.readline\n# def print(x):\n# sys.stdout.write(str(x)+\"\\n\")\n\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# import sys\n# import io, os\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\ndef get_sum(bit,i):\n s = 0\n\n i+=1\n while i>0:\n s+=bit[i]\n i-=i&(-i)\n\n return s\n\ndef update(bit,n,i,v):\n i+=1\n\n while i<=n:\n bit[i]+=v\n i+=i&(-i)\n\n\ndef modInverse(b,m):\n g = math.gcd(b, m)\n if (g != 1):\n return -1\n else:\n return pow(b, m - 2, m)\n\ndef primeFactors(n):\n\n sa = set()\n sa.add(n)\n while n % 2 == 0:\n sa.add(2)\n n = n // 2\n\n\n for i in range(3,int(math.sqrt(n))+1,2):\n\n\n while n % i== 0:\n sa.add(i)\n n = n // i\n\n # sa.add(n)\n return sa\n\n\ndef seive(n):\n\n pri = [True]*(n+1)\n p = 2\n while p*p<=n:\n\n if pri[p] == True:\n\n for i in range(p*p,n+1,p):\n pri[i] = False\n\n p+=1\n\n return pri\n\ndef check_prim(n):\n\n if n<0:\n return False\n for i in range(2,int(sqrt(n))+1):\n if n%i == 0:\n return False\n\n return True\n\n\ndef getZarr(string, z):\n n = len(string)\n\n # [L,R] make a window which matches\n # with prefix of s\n l, r, k = 0, 0, 0\n for i in range(1, n):\n\n # if i>R nothing matches so we will calculate.\n # Z[i] using naive way.\n if i > r:\n l, r = i, i\n\n # R-L = 0 in starting, so it will start\n # checking from 0'th index. For example,\n # for \"ababab\" and i = 1, the value of R\n # remains 0 and Z[i] becomes 0. For string\n # \"aaaaaa\" and i = 1, Z[i] and R become 5\n while r < n and string[r - l] == string[r]:\n r += 1\n z[i] = r - l\n r -= 1\n else:\n\n # k = i-L so k corresponds to number which\n # matches in [L,R] interval.\n k = i - l\n\n # if Z[k] is less than remaining interval\n # then Z[i] will be equal to Z[k].\n # For example, str = \"ababab\", i = 3, R = 5\n # and L = 2\n if z[k] < r - i + 1:\n z[i] = z[k]\n\n # For example str = \"aaaaaa\" and i = 2,\n # R is 5, L is 0\n else:\n\n # else start from R and check manually\n l = i\n while r < n and string[r - l] == string[r]:\n r += 1\n z[i] = r - l\n r -= 1\n\ndef search(text, pattern):\n\n # Create concatenated string \"P$T\"\n concat = pattern + \"$\" + text\n l = len(concat)\n\n\n z = [0] * l\n getZarr(concat, z)\n\n ha = []\n for i in range(l):\n\n\n if z[i] == len(pattern):\n ha.append(i - len(pattern) - 1)\n\n\n return ha\n\n\n# n,k = map(int,input().split())\n# l = list(map(int,input().split()))\n\n#\n# n = int(input())\n# l = list(map(int,input().split()))\n#\n# hash = defaultdict(list)\n# la = []\n#\n# for i in range(n):\n# la.append([l[i],i+1])\n#\n# la.sort(key = lambda x: (x[0],-x[1]))\n# ans = []\n# r = n\n# flag = 0\n# lo = []\n# ha = [i for i in range(n,0,-1)]\n# yo = []\n# for a,b in la:\n#\n# if a == 1:\n# ans.append([r,b])\n# # hash[(1,1)].append([b,r])\n# lo.append((r,b))\n# ha.pop(0)\n# yo.append([r,b])\n# r-=1\n#\n# elif a == 2:\n# # print(yo,lo)\n# # print(hash[1,1])\n# if lo == []:\n# flag = 1\n# break\n# c,d = lo.pop(0)\n# yo.pop(0)\n# if b>=d:\n# flag = 1\n# break\n# ans.append([c,b])\n# yo.append([c,b])\n#\n#\n#\n# elif a == 3:\n#\n# if yo == []:\n# flag = 1\n# break\n# c,d = yo.pop(0)\n# if b>=d:\n# flag = 1\n# break\n# if ha == []:\n# flag = 1\n# break\n#\n# ka = ha.pop(0)\n#\n# ans.append([ka,b])\n# ans.append([ka,d])\n# yo.append([ka,b])\n#\n# if flag:\n# print(-1)\n# else:\n# print(len(ans))\n# for a,b in ans:\n# print(a,b)\ndef mergeIntervals(arr):\n\n # Sorting based on the increasing order\n # of the start intervals\n arr.sort(key = lambda x: x[0])\n\n # array to hold the merged intervals\n m = []\n s = -10000\n max = -100000\n for i in range(len(arr)):\n a = arr[i]\n if a[0] > max:\n if i != 0:\n m.append([s,max])\n max = a[1]\n s = a[0]\n else:\n if a[1] >= max:\n max = a[1]\n\n #'max' value gives the last point of\n # that particular interval\n # 's' gives the starting point of that interval\n # 'm' array contains the list of all merged intervals\n\n if max != -100000 and [s, max] not in m:\n m.append([s, max])\n return m\nclass SortedList:\n def __init__(self, iterable=[], _load=200):\n \"\"\"Initialize sorted list instance.\"\"\"\n values = sorted(iterable)\n self._len = _len = len(values)\n self._load = _load\n self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]\n self._list_lens = [len(_list) for _list in _lists]\n self._mins = [_list[0] for _list in _lists]\n self._fen_tree = []\n self._rebuild = True\n\n def _fen_build(self):\n \"\"\"Build a fenwick tree instance.\"\"\"\n self._fen_tree[:] = self._list_lens\n _fen_tree = self._fen_tree\n for i in range(len(_fen_tree)):\n if i | i + 1 < len(_fen_tree):\n _fen_tree[i | i + 1] += _fen_tree[i]\n self._rebuild = False\n\n def _fen_update(self, index, value):\n \"\"\"Update `fen_tree[index] += value`.\"\"\"\n if not self._rebuild:\n _fen_tree = self._fen_tree\n while index < len(_fen_tree):\n _fen_tree[index] += value\n index |= index + 1\n\n def _fen_query(self, end):\n \"\"\"Return `sum(_fen_tree[:end])`.\"\"\"\n if self._rebuild:\n self._fen_build()\n\n _fen_tree = self._fen_tree\n x = 0\n while end:\n x += _fen_tree[end - 1]\n end &= end - 1\n return x\n\n def _fen_findkth(self, k):\n \"\"\"Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`).\"\"\"\n _list_lens = self._list_lens\n if k < _list_lens[0]:\n return 0, k\n if k >= self._len - _list_lens[-1]:\n return len(_list_lens) - 1, k + _list_lens[-1] - self._len\n if self._rebuild:\n self._fen_build()\n\n _fen_tree = self._fen_tree\n idx = -1\n for d in reversed(range(len(_fen_tree).bit_length())):\n right_idx = idx + (1 << d)\n if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:\n idx = right_idx\n k -= _fen_tree[idx]\n return idx + 1, k\n\n def _delete(self, pos, idx):\n \"\"\"Delete value at the given `(pos, idx)`.\"\"\"\n _lists = self._lists\n _mins = self._mins\n _list_lens = self._list_lens\n\n self._len -= 1\n self._fen_update(pos, -1)\n del _lists[pos][idx]\n _list_lens[pos] -= 1\n\n if _list_lens[pos]:\n _mins[pos] = _lists[pos][0]\n else:\n del _lists[pos]\n del _list_lens[pos]\n del _mins[pos]\n self._rebuild = True\n\n def _loc_left(self, value):\n \"\"\"Return an index pair that corresponds to the first position of `value` in the sorted list.\"\"\"\n if not self._len:\n return 0, 0\n\n _lists = self._lists\n _mins = self._mins\n\n lo, pos = -1, len(_lists) - 1\n while lo + 1 < pos:\n mi = (lo + pos) >> 1\n if value <= _mins[mi]:\n pos = mi\n else:\n lo = mi\n\n if pos and value <= _lists[pos - 1][-1]:\n pos -= 1\n\n _list = _lists[pos]\n lo, idx = -1, len(_list)\n while lo + 1 < idx:\n mi = (lo + idx) >> 1\n if value <= _list[mi]:\n idx = mi\n else:\n lo = mi\n\n return pos, idx\n\n def _loc_right(self, value):\n \"\"\"Return an index pair that corresponds to the last position of `value` in the sorted list.\"\"\"\n if not self._len:\n return 0, 0\n\n _lists = self._lists\n _mins = self._mins\n\n pos, hi = 0, len(_lists)\n while pos + 1 < hi:\n mi = (pos + hi) >> 1\n if value < _mins[mi]:\n hi = mi\n else:\n pos = mi\n\n _list = _lists[pos]\n lo, idx = -1, len(_list)\n while lo + 1 < idx:\n mi = (lo + idx) >> 1\n if value < _list[mi]:\n idx = mi\n else:\n lo = mi\n\n return pos, idx\n\n def add(self, value):\n \"\"\"Add `value` to sorted list.\"\"\"\n _load = self._load\n _lists = self._lists\n _mins = self._mins\n _list_lens = self._list_lens\n\n self._len += 1\n if _lists:\n pos, idx = self._loc_right(value)\n self._fen_update(pos, 1)\n _list = _lists[pos]\n _list.insert(idx, value)\n _list_lens[pos] += 1\n _mins[pos] = _list[0]\n if _load + _load < len(_list):\n _lists.insert(pos + 1, _list[_load:])\n _list_lens.insert(pos + 1, len(_list) - _load)\n _mins.insert(pos + 1, _list[_load])\n _list_lens[pos] = _load\n del _list[_load:]\n self._rebuild = True\n else:\n _lists.append([value])\n _mins.append(value)\n _list_lens.append(1)\n self._rebuild = True\n\n def discard(self, value):\n \"\"\"Remove `value` from sorted list if it is a member.\"\"\"\n _lists = self._lists\n if _lists:\n pos, idx = self._loc_right(value)\n if idx and _lists[pos][idx - 1] == value:\n self._delete(pos, idx - 1)\n\n def remove(self, value):\n \"\"\"Remove `value` from sorted list; `value` must be a member.\"\"\"\n _len = self._len\n self.discard(value)\n if _len == self._len:\n raise ValueError('{0!r} not in list'.format(value))\n\n def pop(self, index=-1):\n \"\"\"Remove and return value at `index` in sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n value = self._lists[pos][idx]\n self._delete(pos, idx)\n return value\n\n def bisect_left(self, value):\n \"\"\"Return the first index to insert `value` in the sorted list.\"\"\"\n pos, idx = self._loc_left(value)\n return self._fen_query(pos) + idx\n\n def bisect_right(self, value):\n \"\"\"Return the last index to insert `value` in the sorted list.\"\"\"\n pos, idx = self._loc_right(value)\n return self._fen_query(pos) + idx\n\n def count(self, value):\n \"\"\"Return number of occurrences of `value` in the sorted list.\"\"\"\n return self.bisect_right(value) - self.bisect_left(value)\n\n def __len__(self):\n \"\"\"Return the size of the sorted list.\"\"\"\n return self._len\n\n def __getitem__(self, index):\n \"\"\"Lookup value at `index` in sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n return self._lists[pos][idx]\n\n def __delitem__(self, index):\n \"\"\"Remove value at `index` from sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n self._delete(pos, idx)\n\n def __contains__(self, value):\n \"\"\"Return true if `value` is an element of the sorted list.\"\"\"\n _lists = self._lists\n if _lists:\n pos, idx = self._loc_left(value)\n return idx < len(_lists[pos]) and _lists[pos][idx] == value\n return False\n\n def __iter__(self):\n \"\"\"Return an iterator over the sorted list.\"\"\"\n return (value for _list in self._lists for value in _list)\n\n def __reversed__(self):\n \"\"\"Return a reverse iterator over the sorted list.\"\"\"\n return (value for _list in reversed(self._lists) for value in reversed(_list))\n\n def __repr__(self):\n \"\"\"Return string representation of sorted list.\"\"\"\n return 'SortedList({0})'.format(list(self))\n\ndef ncr(n, r, p):\n\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\n\n\ndef sol(n):\n\n seti = set()\n for i in range(1,int(sqrt(n))+1):\n if n%i == 0:\n seti.add(n//i)\n seti.add(i)\n\n\n return seti\n\nmod = 10**9 + 7\nn,m,k = map(int,input().split())\nw = n-m\nz = (k-1)*min(n//k,n-m)\n\nw-=min(n//k,n-m)\n\nha = n-(k*min(n//k,n-m)) - w\n\nk1 = 4*((ha)//k) + (ha)%k\nprint((z+k1)%mod)\n\n\n\n\n"}, {"source_code": "mod = 1000000009\nn,m,k = map(int,(input().split()));\n\nx = max(0, m - (((n - n%k) / k) * (k-1)) - (n%k) );\n\np = (pow(2,x+1)-2)%mod;\n\nans = int(((p*k)%mod + (m-x*k)%mod)%mod)\n\nprint(ans)\n\n\n\n\n"}, {"source_code": "def check(c):\n os=m-(c*q);k=n-m;t=os//(q-1)\n if(os%(q-1)):t=t+1\n if(t-1<=k and k>0):return 1\n else:return 0\nn,m,q=map(int,input().split())\nl=0;r=m//q;p=0;o=0;MOD=1000000009\nwhile(r-l>1):\n c=(l+r)//2\n if(check(c)):r=c\n else:l=c\nif(check(l)):p=l\nelse:p=r\no=q*p*pow(2,p,MOD);m=m-q*p\nprint((o+m)%MOD)\n"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(2*10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\nMOD=10**9+7\nfrom math import log\nn,m,k=listInput()\nx=int(log(n,k))\nif m<=n-x:\n print m\n exit(0)\ne=m-n+x\nans=0\nfor i in xrange(1,e+1):\n ans+=k\n ans=(ans*2)%MOD\n m-=k\nprint (ans+m)%MOD"}, {"source_code": "def inp(n):\n if n == 1:\n return map(int, stdin.readline().split())\n elif n == 2:\n return map(float, stdin.readline().split())\n else:\n return map(str, stdin.readline().split())\n\n\ndef sum_range(n):\n return (n * (n + 1)) // 2\n\n\ndef round1(x):\n if (x - int(x) >= .5):\n return ceil(x)\n else:\n return floor(x)\n\n\nfrom sys import stdin\nfrom math import *\n\nn, m, k = inp(1)\nans = round1(n / k) * (k - 1)\n\nif ans >= m:\n print(m)\nelse:\n extra = m - ans\n ans += (k * 2) * extra - (k - 1) *extra\n print(ans)\n"}, {"source_code": "# -*- coding: cp1251 -*-\nimport sys\nimport itertools\ndef calc(cnt, k):\n ydv = cnt/k\n ostat = cnt % k\n #ydv\n #1 - 2*k, 2 - 6*k, 3 - 14*k, 30*k\n q = 2\n #b1 = k<<1\n b1 = k*2\n res = b1 * (1<<(ydv)-1)\n return res + ostat\n\ndef calc___________(cnt, k):\n res = 0\n acc = 0\n for i in xrange(cnt):\n res += 1\n acc += 1\n if acc == k:\n acc = 0\n res *= 2\n\n return res\n\ndef solve(n, m, k):\n ans_plus = m\n ans_minus = n-m\n fails_cnt = n/k\n if fails_cnt <= ans_minus:\n #print \"!\"\n return m\n else:\n #++++++++++++ ____ .+++.+++.+++|\n ans_plus -= ans_minus * (k - 1)\n return calc(ans_plus, k) + (m - ans_plus)\n \n return \n return 0\nn, m, k = map(int, sys.stdin.readline().split())\n\nprint str(solve(n, m, k) % (10**9+9))\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=10**9+9\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\n# vsInput()\n\nn,m,k=value()\n\nsections=n//(k)\nminScore=n%(k)+sections*(k-1)\n\ncovered=max(m-minScore,0)\n# print(covered)\n\nscore= ((k * 2*(covered%M)*((covered+1)%M))%M)//2\n# print(score)\n\nscore=(score+(m-covered*k))%M\n\nprint(score)\n\n\n\n \n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n\n\n\n\n\n \n"}, {"source_code": "def inp(n):\n if n == 1:\n return map(int, stdin.readline().split())\n elif n == 2:\n return map(float, stdin.readline().split())\n else:\n return map(str, stdin.readline().split())\n\n\ndef sum_range(n):\n return (n * (n + 1)) // 2\n\n\ndef round1(x):\n if (x - int(x) >= .5):\n return ceil(x)\n else:\n return floor(x)\n\n\nfrom sys import stdin\nfrom math import *\n\nn, m, k = inp(1)\nans = round1(n / k) * (k - 1)\n\nif ans >= m:\n print(m)\nelse:\n extra = m - ans\n ans += (k * 2) * extra - (k - 1) *extra\n print(ans)\n"}, {"source_code": "import math\n\ni = raw_input().split()\nn, m, k = int(i[0]), int(i[1]), int(i[2])\n\nmod = 100000009\nmin_of_double = max(0, m - (n - n % k) / k * (k - 1) - n % k)\n#min_of_double = abs(min(0, n - m - m / k))\n\noutput = (math.pow(2, min_of_double + 1) - 2) * k + m - min_of_double * k\nprint output % mod\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nre=n-m\nif m%k==0 and m/(k-1)-1<=re or m%k!=0 and m/(k-1)<=re:\n print m\nelse:\n n-=re*k\n ans=re*(k-1)+n%k\n ans+=k*(-2+pow(2,n/k+1,1000000009))\n print ans%1000000009"}, {"source_code": "def pow(a, n, mod):\n if n == 1:\n return a\n if n%2 == 0:\n return pow(a, n/2, mod)**2 % mod\n else:\n return a*pow(a, n/2, mod)**2 % mod\n\nn, m, k = map(int, raw_input().split())\nmod = 10**9 + 9\n\nl = n%k\nt = n/k - (n-m)\nif t <= 0:\n print m\nelse:\n print k*(pow(2, (t+1), mod) - 2) + (m-k*t)"}, {"source_code": "MOD = int(1e9+7)\n\ndef fast_power(x, y):\n res = 1 \n while y > 0:\n if y % 2 == 1: \n res = res * x%MOD\n x = x * x % MOD\n y //= 2\n return res\n \nn, m, k = map(int, input().split())\nx = max(0, m - n // k * (k - 1) - n % k)\nz = (m - x * k) % MOD\nres = fast_power(2, x+1)\nres = (res - 2) % MOD * k % MOD\nres = (res + z) % MOD\nprint(res)\n"}, {"source_code": "line = raw_input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n\n\ndef power(g_base,a,p_mod):\n x=1\n bits = \"{0:b}\".format(a)\n for i, bit in enumerate(bits):\n if bit=='1': x = (((x**2)*g_base)%p_mod)\n elif bit=='0': x = ((x**2)%p_mod)\n return x%p_mod\n\n\n\nimport time\nt = time.clock()\nlimit = n - (n/k)\nif m <= limit : print m % 1000000009 \nelse:\n score = 0\n totry = max(0, m - (n - n % k) / k * (k-1) - n % k)\n i = 0\n m -=(totry*k)\n score = k*(((1-power(2,(totry+1),1000000009))/(1-2))-1) % 1000000009\n score += m\n print score\n#print time.clock()-t\n\n\"\"\"\ndef exp-by-squaring(x,n)\n if n<0: return exp-by-squaring(1/x,-n);\n else if n=0: return 1;\n else if n=1: return x;\n else if n%2 == 0 then return exp-by-squaring(x*x, n/2);\n else :return x * exp-by-squaring(x*x, (n-1)/2).\n\"\"\"\n\"\"\"\nline = input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n \nlimit = n - int(n/k)\nif m <= limit : print (m % 1000000009 )\nelse:\n score = 0\n totry = m - limit\n for i in range(totry):\n score += k\n score *= 2\n m -=k\n score += m\n print (score % 1000000009 )\n \"\"\"\n"}, {"source_code": "import math\ndef get_res(n, m, k):\n D = 1000000009\n p = max(0, m-(n-m)*(k-1))\n result = (4*(pow(2,p/k, D)-1) + p%k + (n-m)*(k-1)) % D\n return result\n\n#N = int(raw_input()) \nn, m, k= [int(s) for s in raw_input().split(\" \")]\nresult = get_res(n, m, k)\nprint \"{}\".format(result)\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\nt = m/k\t\nmod = 1000000009\nif t > n-m :\n\tans = (((n-m))*k)%mod + ((((2**(t-(n-m) + 1))%mod - 2)%mod)*k)%mod\nelse:\n\tans = m\nprint ans\n\n\t\n\t\n"}, {"source_code": "MOD=1000000009;\ndef solve(a,n):\n ans=1;\n p=a;\n while(n>0):\n if(n%2==1): ans*=p;\n n/=2;\n p=(p*p)%MOD;\n return ans;\nn,m,k=map(int,input().split());\np=n-m+1;\nif((k-1)*p>=m):\n print(m);\nelse:\n v=m-(p-1)*(k-1);\n ans=(p-1)*(k-1);\n t=v//k;\n ans=(ans+k*(solve(2,t)-1)*2%MOD+MOD+v%k)%MOD;\n print(ans);"}, {"source_code": "n , m , k = (raw_input().split())\n\nn = int(n)\nm = int(m)\nk = int(k)\n\nM = 1000000009\n\nrem = n-m\nrem+=1\n\nif((k-1)*rem >= m):\n\tprint m\nelse:\n\tby = (rem-1)*(k-1)\n\tm-=by\n\n\tquo = m/k\n\tquo*=2*k\n\tquo+=m%k\n\n\tquo+=by\n\tquo%=M\n\n\tprint quo\n"}, {"source_code": "# -*- coding: cp1251 -*-\nimport sys\nimport itertools\ndef calc(cnt, k):\n ydv = cnt/k\n ostat = cnt % k\n #ydv\n #1 - 2*k, 2 - 6*k, 3 - 14*k, 30*k\n q = 2\n #b1 = k<<1\n b1 = k*2\n res = b1 * (1<<(ydv)-1)\n return res + ostat\n\ndef calc___________(cnt, k):\n res = 0\n acc = 0\n for i in xrange(cnt):\n res += 1\n acc += 1\n if acc == k:\n acc = 0\n res *= 2\n\n return res\n\ndef solve(n, m, k):\n ans_plus = m\n ans_minus = n-m\n fails_cnt = n/k\n if fails_cnt <= ans_minus:\n #print \"!\"\n return m\n else:\n #++++++++++++ ____ .+++.+++.+++|\n ans_plus -= ans_minus * (k - 1)\n return calc(ans_plus, k) + (m - ans_plus)\n \n return \n return 0\nn, m, k = map(int, sys.stdin.readline().split())\n\nprint str(solve(n, m, k) % (10**9+9))\n"}, {"source_code": "from collections import defaultdict\nmod = int(1e9 + 9)\ndef is_good(n, a, b):\n\twhile n:\n\t\tdigit = n%10\n\t\tif digit != a and digit != b:\n\t\t\treturn False\n\t\tn = n//10\n\t\t\t\n\treturn True\n\n\nif __name__ == '__main__':\n\tn, m, k = map(int, input().split())\n\tm -= n%k\n\tscore = n%k\n\tn -= n%k \n\n\tsets = n/k\n\n\tused = sets*(k-1)\n\t\n\tif used >= m:\n\t\tprint(m+score)\n\t\texit()\n\t\n\telse:\n\t\tfilled = m - used\n\t\tscore += int(((2*(2**filled)-2)%mod * k)%mod)\n\t\tscore += int(sets - filled)\n\n\tprint(score%mod)"}, {"source_code": "def inp(n):\n if n == 1:\n return map(int, stdin.readline().split())\n elif n == 2:\n return map(float, stdin.readline().split())\n else:\n return map(str, stdin.readline().split())\n\n\ndef sum_range(n):\n return (n * (n + 1)) // 2\n\n\ndef round1(x):\n if (x - int(x) >= .5):\n return ceil(x)\n else:\n return floor(x)\n\n\nfrom sys import stdin\nfrom math import *\n\nn, m, k = inp(1)\nans = round1(n / k) * (k - 1)\n\nif ans >= m:\n print(m % (10 ** 9 + 9))\nelse:\n extra = m - ans\n ans += ((k * 2) * ((2 ** extra) - 1)) - ((k - 1) * extra)\n print(ans % (10 ** 9 + 9))\n"}, {"source_code": "MOD = 10**9+9\n\ndef _pow(a,b):\n v = a; ret = 1\n for i in range(30):\n if (b>>i)&1 > 0:\n ret = ret*v%MOD\n v = v*v%MOD\n return ret\n\nN,M,K = map(int,raw_input().split())\ns = 0; e = N/K\nwhile s <= e:\n m = (s+e)>>1\n probs = K*m; space = N-probs\n probs += space/K*(K-1)+space%K\n if probs >= M:\n e = m-1; t = m\n else:\n s = m+1\nans = (_pow(2,t+1)-2+MOD)*K%MOD\nans += M-K*t\nprint ans\n"}, {"source_code": "from sys import stdin\nimport fractions\n\ndef line():\n return stdin.readline().split()\ndef read_int():\n return int(line()[0])\ndef read_ints():\n return [int(x) for x in line()]\ndef memo(fn):\n table = {}\n def memoized(*args):\n if args not in table:\n table[args] = fn(*args)\n else:\n print \"Hit! %s\" % (args,)\n return table[args]\n return memoized\n\ndef solve(n, m, k):\n if (n - m)*k >= n:\n return n\n\n skips = (n - m)\n n -= skips*k\n doubles, last = n / k, n % k\n\n score = 2*k*(pow(2, doubles, 1000000009) - 1)\n score += (k - 1) * skips\n score += last\n score = score % 1000000009\n\n return score\n\nn, m, k = read_ints()\nprint solve(n, m, k)\n"}, {"source_code": "N , M , K = map(int, raw_input().split() ) \na = N - M \nMod = 1000000009 ;\n\nif ( N<=a*K+K-1 ):\n ans = M ; \nelse:\n ans = ( ( N / K - a ) * 2 * K % Mod + a * (K - 1) % Mod + N - N/K*K ) % Mod ;\nprint ans \n"}, {"source_code": "\nfrom sys import stdin, stdout\nread_ints = lambda: map(int, raw_input().split())\nread_floats = lambda: map(float, raw_input().split())\n\ndef main():\n n, m, k = read_ints()\n print f(n, m, k) % 1000000009\n\ndef f(n, m, k):\n i = 1\n j = 0\n while True:\n if m < k :\n return m\n if i * k >= n:\n return (j * k % 1000000009 + m - (i-1)*k) % 1000000009\n\n if m % (i*k-1) == 0:\n if m / (i*k-1) * (i*k) -1 == n:\n return (j * k + k -1) * (m / (i*k-1)) % 1000000009\n\n if m / (i*k-1) * (i*k) + m % (i*k-1) <= n:\n return ((j * k % 1000000009 + k-1) * (m/(i*k-1)) % 1000000009 + f(n - m / (i*k-1) * (i*k), m % (i*k-1), k)) % 1000000009\n\n j += 1\n j *= 2\n i += 1\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "line = raw_input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n\n\ndef power(g_base,a,p_mod):\n x=1\n bits = \"{0:b}\".format(a)\n for i, bit in enumerate(bits):\n if bit=='1': x = (((x**2)*g_base)%p_mod)\n elif bit=='0': x = ((x**2)%p_mod)\n return x%p_mod\n\n\n\nimport time\nt = time.clock()\nlimit = n - (n/k)\nif m <= limit : print m % 1000000009 \nelse:\n score = 0\n totry = max(0, m - (n - n % k) / k * (k-1) - n % k)\n i = 0\n m -=(totry*k)\n score = k*(((1-power(2,(totry+1),1000000009))/(1-2))-1) % 1000000009\n score += m\n print score\n#print time.clock()-t\n\n\"\"\"\ndef exp-by-squaring(x,n)\n if n<0: return exp-by-squaring(1/x,-n);\n else if n=0: return 1;\n else if n=1: return x;\n else if n%2 == 0 then return exp-by-squaring(x*x, n/2);\n else :return x * exp-by-squaring(x*x, (n-1)/2).\n\"\"\"\n\"\"\"\nline = input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n \nlimit = n - int(n/k)\nif m <= limit : print (m % 1000000009 )\nelse:\n score = 0\n totry = m - limit\n for i in range(totry):\n score += k\n score *= 2\n m -=k\n score += m\n print (score % 1000000009 )\n \"\"\"\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\ny = min(n - m,m);\nx = m - y;\n#print x,y;\nnum = x/k\n\nmod = 10**9 + 7;\nans = (pow(2,num+1,mod) - 2)*k + x%k + y;\nans = (ans%mod + mod)%mod;\nprint ans;"}, {"source_code": "n,m,k=map(int,raw_input().split())\nM=10**9+7\nx=max(0,m-(n/k*(k-1)+n%k))\nprint (((m-x)+(pow(2,x+1,M)-2)*k-x*(k-1))%M+M)%M"}, {"source_code": "def inp(n):\n if n == 1:\n return map(int, stdin.readline().split())\n elif n == 2:\n return map(float, stdin.readline().split())\n else:\n return map(str, stdin.readline().split())\n\n\ndef sum_range(n):\n return (n * (n + 1)) // 2\n\n\ndef round1(x):\n if (x - int(x) >= .5):\n return ceil(x)\n else:\n return floor(x)\n\n\nfrom sys import stdin\nfrom math import *\n\nn, m, k = inp(1)\nans = round1(n / k) * (k - 1)\n\nif ans >= m:\n print(m % (10 ** 9 + 9))\nelse:\n extra = m - ans\n ans += ((k * 2) * ((2 ** extra) - 1)) - ((k - 1) * extra)\n print(ans % (10 ** 9 + 9))\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nimport bisect\nfrom math import floor\ndef bo(i):\n return ord(i)-ord('a')\nn,m,k=map(int,input().split())\nmod=10**9+9\np=int(floor(m-((n+1)*(k-1))//k))\n#print(n/k-n+m,p)\nprint((k*(pow(2,max(0,p+1),mod))-2*k+m-p*k+mod)%mod ) "}, {"source_code": "(n, m, k) = raw_input().split()\nn, m, k = int(n), int(m), int(k)\n\nif m * k - 1 <= n:\n print m\n exit()\nx = (m * k - n) / (k - 1)\nres = m - x + x % k\n\n\ndef mu2(x):\n if x == 0:\n return 1\n if x == 1:\n return 2\n if x % 2 == 0:\n return (mu2(x / 2) * mu2(x / 2)) % 1000000009\n else:\n return (mu2(x / 2) * mu2(x / 2) * 2) % 1000000009\n \nt = x / k\nres = (res + (mu2(t + 1) - 2) * k) % 1000000009\n\nprint res\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\ny = min(n - m,m);\nx = m - y;\nnum = x/k\n\nmod = 10**9 + 9;\nans = (pow(2,num+1,mod) - 2)*k + x%k + y;\nans = (ans%mod + mod)%mod;\nprint ans;\n\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nif m==0: print 0; exit()\nM=10**9+9\na=k*2*(pow(2,(max(n/k-n+m,0)),M) - 1)\nprint (a + n%k + (k-1)*(n-m))%M"}, {"source_code": "N , M , K = map(int, raw_input().split() ) \na = N - M \nMod = 1000000009 ;\n\ndef calc( n ):\n n += 1 \n res = 1 ; add = 2 ;\n while( n ):\n if n&1 :\n res = ( res * add ) % Mod ; \n add = ( add * add ) % Mod ; \n n >>= 1 ;\n return res ;\n \nif ( N<=a*K+K-1 ):\n ans = M ; \nelse:\n ans = ( calc( N / K - a ) + M - ( N / K - a ) * K ) % Mod \nprint ans \n"}, {"source_code": "from __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\n\ndef main():\n n, m, k = [ int(x) for x in input().split() ]\n mod = 1000000009\n\n positions = n / k\n availablePositions = int(\n int(positions)*(k - 1) + (positions - int(positions)) / (1/k)\n )\n\n if availablePositions >= m:\n points = m\n else:\n positionsLeft = m - availablePositions\n\n points = (\n pow(2, positionsLeft, mod)*k + 2*k*(pow(2, positionsLeft - 1, mod) - 1)\n + (m - k * positionsLeft)\n ) % mod\n\n print(points)\n\n\nBUFFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef print(*args, **kwargs):\n sep = kwargs.pop(\"sep\", \" \")\n file = kwargs.pop(\"file\", sys.stdout)\n\n atStart = True\n for x in args:\n if not atStart:\n file.write(sep)\n file.write(str(x))\n atStart = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n\n if kwargs.pop(\"flush\", False):\n file.flush()\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\nmain()\n"}, {"source_code": "n , m , k = (raw_input().split())\n\nn = int(n)\nm = int(m)\nk = int(k)\n\nM = 1000000009\n\nrem = n-m\nrem+=1\n\nif((k-1)*rem >= m):\n\tprint m\nelse:\n\tby = (rem-1)*(k-1)\n\tm-=by\n\n\tquo = m/k\n\tquo*=2*k\n\tquo+=m%k\n\n\tquo+=by\n\tquo%=M\n\n\tprint quo\n"}, {"source_code": "n,m,k=map(int,input().split())\nmod=10**9+7\nx=n-m\nif x>=n//2:\n print(m)\nelse:\n y=n-k*x\n a=y//k\n b=y%k\n ans=pow(k,2,mod)*(pow(k,a,mod)-1)*pow(k-1,mod-2,mod)\n ans%=mod\n ans+=x+b\n print(ans)\n \n \n"}, {"source_code": "import sys\n\ninputs = sys.stdin.readline().split()\nn = int(inputs[0])\nm = int(inputs[1])\nk = int(inputs[2])\n\nw = n - m\n\nif k*w + (k-1) >= n:\n print m\nelse:\n no_double = n - k*w\n result = 0\n cycle = no_double/k\n print \"cycle is \" + str(cycle)\n remainder = no_double%k\n print \"remainder is \" + str(remainder)\n for i in xrange(cycle):\n result = (result + k) * 2 % (10**9+9)\n result = (result + remainder + w*(k-1)) % (10**9+9)\n print result\n\n\n\n"}, {"source_code": "i = raw_input().split()\nn, m, k = int(i[0]), int(i[1]), int(i[2])\n\nmod = 100000009\nmin_of_double = abs(min(0, n - m - m / k))\n\noutput = m\nbonus = 0\n\nfor i in range(0, min_of_double):\n bonus = bonus + k * (i + 1)\n\nprint output + bonus\n"}, {"source_code": "# -*- coding: cp1251 -*-\nimport sys\nimport itertools\ndef calc(cnt, k):\n ydv = cnt/k\n ostat = cnt % k\n #ydv\n #1 - 2*k, 2 - 6*k, 3 - 14*k, 30*k\n q = 2\n b1 = k<<1\n res = b1 * (1<<(ydv)-1)\n return res + ostat\n\ndef calc___________(cnt, k):\n res = 0\n acc = 0\n for i in xrange(cnt):\n res += 1\n acc += 1\n if acc == k:\n acc = 0\n res *= 2\n\n return res\n\ndef solve(n, m, k):\n ans_plus = m\n ans_minus = n-m\n fails_cnt = n/k\n if fails_cnt <= ans_minus:\n #print \"!\"\n return m\n else:\n #++++++++++++ ____ .+++.+++.+++|\n ans_plus -= ans_minus * (k - 1)\n return calc(ans_plus, k) + (m - ans_plus)\n \n return \n return 0\nn, m, k = map(int, sys.stdin.readline().split())\n\nprint str(solve(n, m, k) % (10**9+9))\n"}, {"source_code": "from collections import defaultdict\nmod = int(1e9 + 9)\ndef is_good(n, a, b):\n\twhile n:\n\t\tdigit = n%10\n\t\tif digit != a and digit != b:\n\t\t\treturn False\n\t\tn = n//10\n\t\t\t\n\treturn True\n\n\nif __name__ == '__main__':\n\tn, m, k = map(int, input().split())\n\tm -= n%k\n\tscore = n%k\n\tn -= n%k \n\n\tsets = n/k\n\n\tused = sets*(k-1)\n\t\n\tif used >= m:\n\t\tprint(m+score)\n\t\texit()\n\t\n\telse:\n\t\tfilled = m - used\n\t\tscore += int(((2*(2**filled)-2)%mod * k)%mod)\n\t\tscore += int(sets - filled)\n\n\tprint(score%mod)"}, {"source_code": "from __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\n\ndef main():\n n, m, k = [ int(x) for x in input().split() ]\n mod = 1000000009\n\n positions = n / k\n availablePositions = int(\n int(positions)*(k - 1) + (positions - int(positions)) / (1/k)\n )\n\n if availablePositions >= m:\n points = m\n else:\n positionsLeft = m - availablePositions\n\n points = (\n pow(2, positionsLeft, mod)*k + 2*k*(pow(2, positionsLeft - 1, mod) - 1)\n + (m - k * positionsLeft)\n ) % mod\n\n print(points)\n\n\nBUFFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef print(*args, **kwargs):\n sep = kwargs.pop(\"sep\", \" \")\n file = kwargs.pop(\"file\", sys.stdout)\n\n atStart = True\n for x in args:\n if not atStart:\n file.write(sep)\n file.write(str(x))\n atStart = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n\n if kwargs.pop(\"flush\", False):\n file.flush()\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\nmain()\n"}, {"source_code": "def pow(a, n, mod):\n if n == 1:\n return a\n if n%2 == 0:\n return pow(a, n/2, mod)**2 % mod\n else:\n return a*pow(a, n/2, mod)**2 % mod\n\nn, m, k = map(int, raw_input().split())\nmod = 10**9 + 9\n\nl = n%k\nt = n/k - (n-m)\nif t <= 0:\n print m\nelse:\n print k*(pow(2, (t+1), mod) - 2) + (m-k*t)"}, {"source_code": "import sys\n\nMOD = 1000000009\n\ndef rep_square(x, y):\n if y == 1:\n return x\n base = rep_square(x, y/2)\n if y % 2 == 1:\n return (base * base * x) % MOD\n return (base * base) % MOD\n\nn_questions, n_corrects, n_k = (int(x) for x in sys.stdin.readline().split())\nif n_corrects == 0:\n print(0)\n sys.exit(0)\n\nn_gaps = n_questions-n_corrects\nscore = min(n_gaps, n_corrects) * (n_k-1)\nn_consec_left = n_corrects - score\nif n_consec_left > 0:\n score += (n_consec_left % n_k) + n_k * (rep_square(2, n_consec_left/n_k+1) - 2)\nprint(score % MOD)\n"}, {"source_code": "from sys import stdin\nimport fractions\n\ndef line():\n return stdin.readline().split()\ndef read_int():\n return int(line()[0])\ndef read_ints():\n return [int(x) for x in line()]\ndef memo(fn):\n table = {}\n def memoized(*args):\n if args not in table:\n table[args] = fn(*args)\n else:\n print \"Hit! %s\" % (args,)\n return table[args]\n return memoized\n\ndef solve(n, m, k):\n if (n - m)*k >= n:\n return n\n\n skips = (n - m)\n n -= skips*k\n doubles, last = n / k, n % k\n\n score = 2*k*(pow(2, doubles, 1000000009) - 1)\n score += (k - 1) * skips\n score += last\n score = score % 1000000009\n\n return score\n\nn, m, k = read_ints()\nprint solve(n, m, k)\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\ny = min(n - m,m);\nx = m - y;\n#print x,y;\nnum = x/k\n\nmod = 10**9 + 7;\nans = (pow(2,num+1,mod) - 2)*k + x%k + y;\nans = (ans%mod + mod)%mod;\nprint ans;"}, {"source_code": "R = lambda: map(int, input().split())\n\n\nn, m, k = R()\nrem = n % k\nzeros = n // k\nfulls = max(0, m - zeros * (k - 1) - rem)\nzeros -= fulls\nacc = 2 * ((1<<fulls) - 1) * k % (10**9 + 9)\nprint((acc + zeros * (k - 1) + rem) % (10**9 + 9))"}, {"source_code": "MOD = 1000000009\ndef p2(e):\n if e == 0:\n return 1\n elif e % 2 == 1:\n return 2 * p2(e - 1) % MOD\n else:\n return p2(e // 2) ** 2 % MOD\n\nn, m, k = map(int, input().split())\nx = (m - min(n - m, n // (k - 1))) // k\nprint((2 * k * (p2(x) - 1) + m - x * k) % MOD)"}, {"source_code": "(n, m, k) = raw_input().split()\nn, m, k = int(n), int(m), int(k)\n\nif m * k - 1 <= n:\n print m\n exit()\nx = (m * k - n) / (k - 1)\nres = m - x + x % k\n\n\ndef mu2(x):\n if x == 0:\n return 1\n if x == 1:\n return 2\n if x % 2 == 0:\n return (mu2(x / 2) * mu2(x / 2)) % 1000000009\n else:\n return (mu2(x / 2) * mu2(x / 2) * 2) % 1000000009\n \nt = x / k\nres = (res + (mu2(t + 1) - 2) * k) % 1000000009\n\nprint res\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\nif m==0: print 0; exit()\nM=10**9+9\na=k*2*(pow(2,(max(n/k-n+m,0)),M) - 1)\nprint (a + n%k + (k-1)*(n-m))%M"}, {"source_code": "from collections import defaultdict\nmod = int(1000000009)\ndef is_good(n, a, b):\n\twhile n:\n\t\tdigit = n%10\n\t\tif digit != a and digit != b:\n\t\t\treturn False\n\t\tn = n//10\n\t\t\t\n\treturn True\n\n\nif __name__ == '__main__':\n\tn, m, k = map(int, input().split())\n\tm -= n%k\n\tscore = n%k\n\tn -= n%k \n\n\tsets = n//k\n\n\tused = sets*(k-1)\n\t\n\tif used >= m:\n\t\tprint(m+score)\n\t\texit()\n\t\n\telse:\n\t\tfilled = m - used\n\t\tprint(score, filled)\n\t\tscore += int(((2*(2**filled)-2) * k))\n\t\tscore += int(sets - filled)\n\n\tprint(score%mod)"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\nimport math\n\n\ndef main():\n pass\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\n\ndef main():\n pass\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nn,m,k=map(int,input().split())\np=n//k\nmws=(k-1)*p+n%k\nmod=1000000009\n#print(mws)\nif(m<=mws):\n print(m)\nelse:\n con=m-mws\n #print(con,mws)\n acon=(4*(pow(2,con,mod)-1))%mod\n m-=(k*con)\n ans=(acon+m)%mod\n print(ans)"}, {"source_code": "MOD=1000000009;\ndef solve(a,n):\n ans=1;\n p=a;\n while(n>0):\n if(n%2==1): ans*=p;\n n/=2;\n ans%=MOD;\n p=(p*p)%MOD;\n return ans;\nn,m,k=map(int,input().split());\np=n-m+1;\nif((k-1)*p>=m):\n print(m);\nelse:\n v=m-(p-1)*(k-1);\n ans=(p-1)*(k-1);\n t=v//k;\n ans=(ans+k*(solve(2,t)-1)*2%MOD+MOD+v%k)%MOD;\n print(ans);"}, {"source_code": "line = raw_input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n\n\ndef power(g_base,a,p_mod):\n x=1\n bits = \"{0:b}\".format(a)\n for i, bit in enumerate(bits):\n if bit=='1': x = (((x**2)*g_base)%p_mod)\n elif bit=='0': x = ((x**2)%p_mod)\n return x%p_mod\n\n\n\nimport time\nt = time.clock()\nlimit = n - (n/k)\nif m <= limit : print m % 1000000009 \nelse:\n score = 0\n totry = m - limit\n i = 0\n m -=(totry*k)\n score = k*(((1-pow(2,(totry+1),1000000009))/(1-2))-1) % 1000000009\n score += m\n print score\n#print time.clock()-t\n\n\"\"\"\ndef exp-by-squaring(x,n)\n if n<0: return exp-by-squaring(1/x,-n);\n else if n=0: return 1;\n else if n=1: return x;\n else if n%2 == 0 then return exp-by-squaring(x*x, n/2);\n else :return x * exp-by-squaring(x*x, (n-1)/2).\n\"\"\"\n\"\"\"\nline = input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n \nlimit = n - int(n/k)\nif m <= limit : print (m % 1000000009 )\nelse:\n score = 0\n totry = m - limit\n for i in range(totry):\n score += k\n score *= 2\n m -=k\n score += m\n print (score % 1000000009 )\n \"\"\"\n"}, {"source_code": "line = raw_input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n\n\ndef power(g_base,a,p_mod):\n x=1\n bits = \"{0:b}\".format(a)\n for i, bit in enumerate(bits):\n if bit=='1': x = (((x**2)*g_base)%p_mod)\n elif bit=='0': x = ((x**2)%p_mod)\n return x%p_mod\n\n\n\nimport time\nt = time.clock()\nlimit = n - (n/k)\nif m <= limit : print m % 1000000009 \nelse:\n score = 0\n totry = m - limit\n i = 0\n m -=(totry*k)\n score = k*(((1-pow(2,(totry+1),1000000009))/(1-2))-1) % 1000000009\n score += m\n print score\n#print time.clock()-t\n\n\"\"\"\ndef exp-by-squaring(x,n)\n if n<0: return exp-by-squaring(1/x,-n);\n else if n=0: return 1;\n else if n=1: return x;\n else if n%2 == 0 then return exp-by-squaring(x*x, n/2);\n else :return x * exp-by-squaring(x*x, (n-1)/2).\n\"\"\"\n\"\"\"\nline = input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n \nlimit = n - int(n/k)\nif m <= limit : print (m % 1000000009 )\nelse:\n score = 0\n totry = m - limit\n for i in range(totry):\n score += k\n score *= 2\n m -=k\n score += m\n print (score % 1000000009 )\n \"\"\"\n"}, {"source_code": "import sys\n\nmod = 1000000009\n\ndef my_pow(n):\n\tif n == 0:\n\t\treturn 1\n\tif n % 2:\n\t\treturn (2 * my_pow(n - 1)) % mod\n\tdiv = my_pow(n / 2)\n\treturn (div * div) % mod\n\nn, m, k = map(int, sys.stdin.readline().strip().split())\nchunk = n / k\nr = m - (chunk * (k - 1) + n % k)\np = max(r, 0)\n\nsol = 0\nif (p):\n\tsol += (k * my_pow(p + 1)) % mod\n\tsol -= 2 * k\n\tsol = (sol + mod) % mod\n\tm -= k * p\n\nprint sol + m\n"}, {"source_code": "import sys\nfrom math import gcd,sqrt,ceil,log2\nfrom collections import defaultdict,Counter,deque\nfrom bisect import bisect_left,bisect_right\nimport math\nsys.setrecursionlimit(2*10**5+10)\nimport heapq\nfrom itertools import permutations\n\n# input=sys.stdin.readline\n# def print(x):\n# sys.stdout.write(str(x)+\"\\n\")\n\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# import sys\n# import io, os\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\ndef get_sum(bit,i):\n s = 0\n\n i+=1\n while i>0:\n s+=bit[i]\n i-=i&(-i)\n\n return s\n\ndef update(bit,n,i,v):\n i+=1\n\n while i<=n:\n bit[i]+=v\n i+=i&(-i)\n\n\ndef modInverse(b,m):\n g = math.gcd(b, m)\n if (g != 1):\n return -1\n else:\n return pow(b, m - 2, m)\n\ndef primeFactors(n):\n\n sa = set()\n sa.add(n)\n while n % 2 == 0:\n sa.add(2)\n n = n // 2\n\n\n for i in range(3,int(math.sqrt(n))+1,2):\n\n\n while n % i== 0:\n sa.add(i)\n n = n // i\n\n # sa.add(n)\n return sa\n\n\ndef seive(n):\n\n pri = [True]*(n+1)\n p = 2\n while p*p<=n:\n\n if pri[p] == True:\n\n for i in range(p*p,n+1,p):\n pri[i] = False\n\n p+=1\n\n return pri\n\ndef check_prim(n):\n\n if n<0:\n return False\n for i in range(2,int(sqrt(n))+1):\n if n%i == 0:\n return False\n\n return True\n\n\ndef getZarr(string, z):\n n = len(string)\n\n # [L,R] make a window which matches\n # with prefix of s\n l, r, k = 0, 0, 0\n for i in range(1, n):\n\n # if i>R nothing matches so we will calculate.\n # Z[i] using naive way.\n if i > r:\n l, r = i, i\n\n # R-L = 0 in starting, so it will start\n # checking from 0'th index. For example,\n # for \"ababab\" and i = 1, the value of R\n # remains 0 and Z[i] becomes 0. For string\n # \"aaaaaa\" and i = 1, Z[i] and R become 5\n while r < n and string[r - l] == string[r]:\n r += 1\n z[i] = r - l\n r -= 1\n else:\n\n # k = i-L so k corresponds to number which\n # matches in [L,R] interval.\n k = i - l\n\n # if Z[k] is less than remaining interval\n # then Z[i] will be equal to Z[k].\n # For example, str = \"ababab\", i = 3, R = 5\n # and L = 2\n if z[k] < r - i + 1:\n z[i] = z[k]\n\n # For example str = \"aaaaaa\" and i = 2,\n # R is 5, L is 0\n else:\n\n # else start from R and check manually\n l = i\n while r < n and string[r - l] == string[r]:\n r += 1\n z[i] = r - l\n r -= 1\n\ndef search(text, pattern):\n\n # Create concatenated string \"P$T\"\n concat = pattern + \"$\" + text\n l = len(concat)\n\n\n z = [0] * l\n getZarr(concat, z)\n\n ha = []\n for i in range(l):\n\n\n if z[i] == len(pattern):\n ha.append(i - len(pattern) - 1)\n\n\n return ha\n\n\n# n,k = map(int,input().split())\n# l = list(map(int,input().split()))\n\n#\n# n = int(input())\n# l = list(map(int,input().split()))\n#\n# hash = defaultdict(list)\n# la = []\n#\n# for i in range(n):\n# la.append([l[i],i+1])\n#\n# la.sort(key = lambda x: (x[0],-x[1]))\n# ans = []\n# r = n\n# flag = 0\n# lo = []\n# ha = [i for i in range(n,0,-1)]\n# yo = []\n# for a,b in la:\n#\n# if a == 1:\n# ans.append([r,b])\n# # hash[(1,1)].append([b,r])\n# lo.append((r,b))\n# ha.pop(0)\n# yo.append([r,b])\n# r-=1\n#\n# elif a == 2:\n# # print(yo,lo)\n# # print(hash[1,1])\n# if lo == []:\n# flag = 1\n# break\n# c,d = lo.pop(0)\n# yo.pop(0)\n# if b>=d:\n# flag = 1\n# break\n# ans.append([c,b])\n# yo.append([c,b])\n#\n#\n#\n# elif a == 3:\n#\n# if yo == []:\n# flag = 1\n# break\n# c,d = yo.pop(0)\n# if b>=d:\n# flag = 1\n# break\n# if ha == []:\n# flag = 1\n# break\n#\n# ka = ha.pop(0)\n#\n# ans.append([ka,b])\n# ans.append([ka,d])\n# yo.append([ka,b])\n#\n# if flag:\n# print(-1)\n# else:\n# print(len(ans))\n# for a,b in ans:\n# print(a,b)\ndef mergeIntervals(arr):\n\n # Sorting based on the increasing order\n # of the start intervals\n arr.sort(key = lambda x: x[0])\n\n # array to hold the merged intervals\n m = []\n s = -10000\n max = -100000\n for i in range(len(arr)):\n a = arr[i]\n if a[0] > max:\n if i != 0:\n m.append([s,max])\n max = a[1]\n s = a[0]\n else:\n if a[1] >= max:\n max = a[1]\n\n #'max' value gives the last point of\n # that particular interval\n # 's' gives the starting point of that interval\n # 'm' array contains the list of all merged intervals\n\n if max != -100000 and [s, max] not in m:\n m.append([s, max])\n return m\nclass SortedList:\n def __init__(self, iterable=[], _load=200):\n \"\"\"Initialize sorted list instance.\"\"\"\n values = sorted(iterable)\n self._len = _len = len(values)\n self._load = _load\n self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]\n self._list_lens = [len(_list) for _list in _lists]\n self._mins = [_list[0] for _list in _lists]\n self._fen_tree = []\n self._rebuild = True\n\n def _fen_build(self):\n \"\"\"Build a fenwick tree instance.\"\"\"\n self._fen_tree[:] = self._list_lens\n _fen_tree = self._fen_tree\n for i in range(len(_fen_tree)):\n if i | i + 1 < len(_fen_tree):\n _fen_tree[i | i + 1] += _fen_tree[i]\n self._rebuild = False\n\n def _fen_update(self, index, value):\n \"\"\"Update `fen_tree[index] += value`.\"\"\"\n if not self._rebuild:\n _fen_tree = self._fen_tree\n while index < len(_fen_tree):\n _fen_tree[index] += value\n index |= index + 1\n\n def _fen_query(self, end):\n \"\"\"Return `sum(_fen_tree[:end])`.\"\"\"\n if self._rebuild:\n self._fen_build()\n\n _fen_tree = self._fen_tree\n x = 0\n while end:\n x += _fen_tree[end - 1]\n end &= end - 1\n return x\n\n def _fen_findkth(self, k):\n \"\"\"Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`).\"\"\"\n _list_lens = self._list_lens\n if k < _list_lens[0]:\n return 0, k\n if k >= self._len - _list_lens[-1]:\n return len(_list_lens) - 1, k + _list_lens[-1] - self._len\n if self._rebuild:\n self._fen_build()\n\n _fen_tree = self._fen_tree\n idx = -1\n for d in reversed(range(len(_fen_tree).bit_length())):\n right_idx = idx + (1 << d)\n if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:\n idx = right_idx\n k -= _fen_tree[idx]\n return idx + 1, k\n\n def _delete(self, pos, idx):\n \"\"\"Delete value at the given `(pos, idx)`.\"\"\"\n _lists = self._lists\n _mins = self._mins\n _list_lens = self._list_lens\n\n self._len -= 1\n self._fen_update(pos, -1)\n del _lists[pos][idx]\n _list_lens[pos] -= 1\n\n if _list_lens[pos]:\n _mins[pos] = _lists[pos][0]\n else:\n del _lists[pos]\n del _list_lens[pos]\n del _mins[pos]\n self._rebuild = True\n\n def _loc_left(self, value):\n \"\"\"Return an index pair that corresponds to the first position of `value` in the sorted list.\"\"\"\n if not self._len:\n return 0, 0\n\n _lists = self._lists\n _mins = self._mins\n\n lo, pos = -1, len(_lists) - 1\n while lo + 1 < pos:\n mi = (lo + pos) >> 1\n if value <= _mins[mi]:\n pos = mi\n else:\n lo = mi\n\n if pos and value <= _lists[pos - 1][-1]:\n pos -= 1\n\n _list = _lists[pos]\n lo, idx = -1, len(_list)\n while lo + 1 < idx:\n mi = (lo + idx) >> 1\n if value <= _list[mi]:\n idx = mi\n else:\n lo = mi\n\n return pos, idx\n\n def _loc_right(self, value):\n \"\"\"Return an index pair that corresponds to the last position of `value` in the sorted list.\"\"\"\n if not self._len:\n return 0, 0\n\n _lists = self._lists\n _mins = self._mins\n\n pos, hi = 0, len(_lists)\n while pos + 1 < hi:\n mi = (pos + hi) >> 1\n if value < _mins[mi]:\n hi = mi\n else:\n pos = mi\n\n _list = _lists[pos]\n lo, idx = -1, len(_list)\n while lo + 1 < idx:\n mi = (lo + idx) >> 1\n if value < _list[mi]:\n idx = mi\n else:\n lo = mi\n\n return pos, idx\n\n def add(self, value):\n \"\"\"Add `value` to sorted list.\"\"\"\n _load = self._load\n _lists = self._lists\n _mins = self._mins\n _list_lens = self._list_lens\n\n self._len += 1\n if _lists:\n pos, idx = self._loc_right(value)\n self._fen_update(pos, 1)\n _list = _lists[pos]\n _list.insert(idx, value)\n _list_lens[pos] += 1\n _mins[pos] = _list[0]\n if _load + _load < len(_list):\n _lists.insert(pos + 1, _list[_load:])\n _list_lens.insert(pos + 1, len(_list) - _load)\n _mins.insert(pos + 1, _list[_load])\n _list_lens[pos] = _load\n del _list[_load:]\n self._rebuild = True\n else:\n _lists.append([value])\n _mins.append(value)\n _list_lens.append(1)\n self._rebuild = True\n\n def discard(self, value):\n \"\"\"Remove `value` from sorted list if it is a member.\"\"\"\n _lists = self._lists\n if _lists:\n pos, idx = self._loc_right(value)\n if idx and _lists[pos][idx - 1] == value:\n self._delete(pos, idx - 1)\n\n def remove(self, value):\n \"\"\"Remove `value` from sorted list; `value` must be a member.\"\"\"\n _len = self._len\n self.discard(value)\n if _len == self._len:\n raise ValueError('{0!r} not in list'.format(value))\n\n def pop(self, index=-1):\n \"\"\"Remove and return value at `index` in sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n value = self._lists[pos][idx]\n self._delete(pos, idx)\n return value\n\n def bisect_left(self, value):\n \"\"\"Return the first index to insert `value` in the sorted list.\"\"\"\n pos, idx = self._loc_left(value)\n return self._fen_query(pos) + idx\n\n def bisect_right(self, value):\n \"\"\"Return the last index to insert `value` in the sorted list.\"\"\"\n pos, idx = self._loc_right(value)\n return self._fen_query(pos) + idx\n\n def count(self, value):\n \"\"\"Return number of occurrences of `value` in the sorted list.\"\"\"\n return self.bisect_right(value) - self.bisect_left(value)\n\n def __len__(self):\n \"\"\"Return the size of the sorted list.\"\"\"\n return self._len\n\n def __getitem__(self, index):\n \"\"\"Lookup value at `index` in sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n return self._lists[pos][idx]\n\n def __delitem__(self, index):\n \"\"\"Remove value at `index` from sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n self._delete(pos, idx)\n\n def __contains__(self, value):\n \"\"\"Return true if `value` is an element of the sorted list.\"\"\"\n _lists = self._lists\n if _lists:\n pos, idx = self._loc_left(value)\n return idx < len(_lists[pos]) and _lists[pos][idx] == value\n return False\n\n def __iter__(self):\n \"\"\"Return an iterator over the sorted list.\"\"\"\n return (value for _list in self._lists for value in _list)\n\n def __reversed__(self):\n \"\"\"Return a reverse iterator over the sorted list.\"\"\"\n return (value for _list in reversed(self._lists) for value in reversed(_list))\n\n def __repr__(self):\n \"\"\"Return string representation of sorted list.\"\"\"\n return 'SortedList({0})'.format(list(self))\n\ndef ncr(n, r, p):\n\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\n\n\ndef sol(n):\n\n seti = set()\n for i in range(1,int(sqrt(n))+1):\n if n%i == 0:\n seti.add(n//i)\n seti.add(i)\n\n\n return seti\n\nmod = 10**9 + 7\nn,m,k = map(int,input().split())\nw = n-m\nz = (k-1)*min(n//k,n-m)\n\nw-=min(n//k,n-m)\n\nha = n-(k*min(n//k,n-m)) - w\n\nk1 = 4*((ha)//k) + (ha)%k\nprint((z+k1)%mod)\n\n\n\n\n"}, {"source_code": "def check(c):\n os=m-(c*q);k=n-m;t=os//(q-1)\n if(os%(q-1)):t=t+1\n if(t-1<=k):return 1\n else:return 0\nn,m,q=map(int,input().split())\nl=0;r=m//q;p=0;o=0;MOD=1000000009\nwhile(r-l>1):\n c=(l+r)//2\n if(check(c)):l=c\n else:r=c\nif(check(l)):p=l\nelse:p=r\nfor i in range(p):\n o=(o+q)*2;m=m-q;\nprint(o+m)\n"}, {"source_code": "n, m, k = map(int, input().split())\n\nd = max(0, n // k - (n - m))\n\nif d > 0:\n res = pow(k, d + 1, 1000000009) + m - k * d\nelse:\n res = m\n\nprint(res)"}, {"source_code": "M = 1000000009\nn, m, k = map(int, input().split())\n\nx = max(0, m - (n - n % k) // k * (k - 1) - n % k)\n\nprint(((pow(2, x + 1, M) - 2) * k - m - pow(x, 2, M)) % M)"}, {"source_code": "n,m,k=map(int,raw_input().split())\nre=n-m\nif m%k==0 and m/(k-1)-1<=re or m%k!=0 and m/(k-1)<=re:\n print m\nelse:\n n-=re*k\n ans=re*(k-1)+n%k\n ans+=k*(-2+pow(2,n/k+1,1000000009))\n print ans%1000000009"}, {"source_code": "num,m,k=map(int,input().split())\ni=1\nj=num\nwhile(i<=j):\n mid=(i+j)//2\n if (mid+((num-mid)//2)>=m):\n MM=mid\n j=mid-1\n else:\n i=mid+1\n#print(MM)\nM=10**9+9\np=MM//k\n\nans=(pow(2,p+1,M)-2)*k\nans+=MM%k\nans+=m-MM\nprint(ans)"}, {"source_code": "import math\ndef get_res(n, m, k):\n D = 1000000009\n p = max(0, m-(n-m)*(k-1))\n result = (4*(pow(2,p/k, D)-1) + p%k + (n-m)*(k-1)) % D\n return result\n\n#N = int(raw_input()) \nn, m, k= [int(s) for s in raw_input().split(\" \")]\nresult = get_res(n, m, k)\nprint \"{}\".format(result)\n"}, {"source_code": "n,m,k=map(int,raw_input().split())\n\n#k*(2**m-1)+\nl=(k-1)*(n-m) #a+\nr=n-k*(n-m)\nd=r%k #a+\nr-=d\n\np=r/k\na=k*2*(2**p - 1)\nprint a + d + l"}, {"source_code": "n, m, k = map(int, raw_input().split())\na = 1000000009\n\nudv = m - n + n / k\nif udv <= 0:\n print m\nelse:\n x = (pow(2, udv + 1, a) - 2) * k\n print x + m - udv * k"}, {"source_code": "import math\nif __name__==\"__main__\":\n n,m,k = map(int, raw_input().split())\n md = m+0.\n maxA = 10**9+9\n\n if (math.ceil(md/(k-1))-1)*k+ (m-(math.ceil(md/(k-1))-1)*(k-1)) <= n:\n print m%maxA\n else:\n p1=math.floor((n+0.)/k)\n extra=int(m-p1*(k-1)-(n-p1*k))\n #print n,extra, p1\n res=pow(2,extra+1,maxA)\n res=(res*k+maxA-2*k)%maxA\n print res\n"}, {"source_code": "N , M , K = map(int, raw_input().split() ) \na = N - M \nMod = 1000000009 ;\n\ndef calc( n ):\n n += 1 \n res = 1 ; add = 2 ;\n while( n ):\n if n&1 :\n res = ( res * add ) % Mod ; \n add = ( add * add ) % Mod ; \n n >>= 1 ;\n return res - 1 ;\n \nif ( N<=a*K+K-1 ):\n ans = M ; \nelse:\n ans = ( calc( N / K - a ) * K % Mod + M - ( N / K - a ) * K ) % Mod \nprint ans \n"}], "src_uid": "9cc1aecd70ed54400821c290e2c8018e"} {"source_code": "n, m = map(int, input().split())\na = [n // 5 + (n % 5 > i) for i in range(5)]\nb = [m // 5 + (m % 5 > i) for i in range(5)]\nans = 0\nfor i in range(4): ans += a[i] * b[3 - i]\nprint(ans + a[4] * b[4])", "positive_code": [{"source_code": "n,m=(int(i) for i in input().split())\nl1=[0]*5\nl2=[0]*5\nfor i in range(1,n+1):\n l1[i%5]+=1\nfor i in range(1,m+1):\n l2[i%5]+=1\ns=(l1[0]*l2[0])+(l1[1]*l2[4])+(l1[2]*l2[3])+(l1[3]*l2[2])+(l1[4]*l2[1])\nprint(s)"}, {"source_code": "#!/usr/bin/env python3\n\ntry:\n while True:\n n, m = map(int, input().split())\n a = [0] * 5\n b = [0] * 5\n for i in range(1, n + 1):\n a[i % 5] += 1\n for j in range(1, m + 1):\n b[j % 5] += 1\n\n print(a[0] * b[0] + a[1] * b[4] + a[2] * b[3] + a[3] * b[2] + a[4] * b[1])\n\nexcept EOFError:\n pass\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n\na=[0,0,0,0,0]\nb=[0,0,0,0,0]\n\nfor i in range(1,n+1):\n a[i%5]+=1\nfor j in range(1,m+1):\n b[j%5]+=1\n\nprint(a[0]*b[0] + a[1]*b[4] + a[2]*b[3] + b[2]*a[3] + a[4]*b[1])\n\n"}, {"source_code": "x,y=map(int,input().split())\nz=x//5\na=[z]*5\nz=y//5\nb=[z]*5\nz=x%5\nfor i in range(1,z+1):\n a[i]+=1\nz=y%5\nfor j in range(1,z+1):\n b[j]+=1\nprint((a[0]*b[0]) +(a[1]*b[4]) + (a[2]*b[3]) + (b[2]*a[3]) + (a[4]*b[1]))\n "}, {"source_code": "inp = [int(x) for x in raw_input().split()]\ninp.sort()\na, b = inp\n\nprint(sum([(((b - 5 + (i%5)) / 5) + 1) for i in range(1, a +1)]))\n"}, {"source_code": "n, m = map(int, raw_input().split())\ns = 0\nfor i in range(n):\n\tost = 5 - (i + 1) % 5\n\tif ost <= m:\n\t\ts = s + (m - ost) / 5 + 1\nprint s\n\t "}, {"source_code": "n,m=map(int,input().split())\nc=0\nfor i in range(1,n+1):\n c=c+(m+(i%5))//5\nprint(c)"}, {"source_code": "m,n=input().split()\nm = int(m)\nn = int(n)\nM=m//10\nMM=m%10\na=[M]*10\nfor i in range(MM):\n a[i+1]+=1;\n\nN=n//10\nNN=n%10\nb=[N]*10\nfor i in range(NN):\n b[i+1]+=1;\n\nans = (a[0]+a[5])*(b[5]+b[0]) + (a[1]+a[6])*(b[4]+b[9]) + (a[2]+a[7])*(b[3]+b[8]) + (a[3]+a[8])*(b[2]+b[7]) + (a[4]+a[9])*(b[1]+b[6])\nprint(ans)"}, {"source_code": "n = list(map(int,input().split()))\nx = n[0]\ny = n[1]\na = [0,0,0,0,0]\nb = [0,0,0,0,0]\nfor i in range(1,x+1):\n a[i%5]+= 1\nfor i in range(1,y+1): \n b[i%5]+= 1 \nprint(a[0]*b[0]+a[1]*b[4]+a[2]*b[3]+a[3]*b[2]+a[4]*b[1] )\n"}, {"source_code": "(n, m) = [int(x) for x in raw_input().split()]\nres = ((n//5) * (m//5) * 5) + ( (n//5) * (m%5) ) + ( (m//5) * (n%5) ) + (((n%5) + (m%5))%5+1 if (n%5) + (m%5)>=5 else 0)\nprint res"}, {"source_code": "n, m = map(int, input().split())\ncnt = (n//5)*(m//5)\nfor k in range(1,5):\n if k>n:\n continue\n if 5-k>m:\n continue\n k1 = (n-k)//5\n k2 = (m-(5-k))//5\n cnt += (k1+1)*(k2+1)\nprint(cnt)\n"}, {"source_code": "x = raw_input()\ng = x.find(' ')\ny = x[g+1:]\ny= int(y)\nx = x[:g]\nx = int(x)\nz = 5\nans = 0\nwhile z <= x+y:\n if z <=x and z<=y :\n ans = ans + z-1\n elif z <= x:\n ans = ans + y\n elif z <= y:\n ans = ans +x\n else :\n m = x;\n if y > m : m= y\n q = z - m\n if m == x:\n m=y\n else :\n m=x\n ans = ans + m - q + 1\n z = z+5\nprint ans\n"}, {"source_code": "inp=input().split()\nn=int(inp[0])\nm=int(inp[1])\n\nd={}\n\nA=min(n,m)\nB=max(n,m)\n\nfor i in range(1, A+1):\n \n num=i%5\n if(num==0):\n num=5\n \n \n if(num not in d):\n d[num]=1\n else:\n d[num]=d.get(num)+1\n\ncount=0\nfor i in range(1,B+1):\n \n num2=i%5\n sol=5-num2\n \n if(sol in d):\n count+=d.get(sol)\n \nprint(count)\n \n \n "}, {"source_code": "[n,m]=[int(x) for x in input().split()]\na=[n//5 for i in range(0,5)]\nb=[m//5 for i in range(0,5)]\nfor i in range(1,n%5+1):\n a[i]+=1\nfor i in range(1,m%5+1):\n b[i]+=1\nc=a[0]*b[0]\nfor i in range(1,5):\n c+=a[i]*b[5-i]\nprint(c)\n"}, {"source_code": "n,m=map(int,input().split())\nans=0\nfor i in range(1,n+1):\n ans+=(m+i%5)//5\nprint(ans)"}, {"source_code": "m,n=map(int,input().split())\nprint(((m+4)//5)*((n+1)//5)+((m+1)//5)*((n+4)//5)+((m+3)//5)*((n+2)//5)+((m+2)//5)*((n+3)//5)+(n//5)*(m//5))\n"}, {"source_code": "a,b = map(int,raw_input().split())\n\ncnt = 0 \nfor i in xrange(1,a+1):\n\tcnt+=(b+i)/5 - i/5\n\nprint cnt"}, {"source_code": "n, m = raw_input().split()\nn = int(n)\nm = int(m)\n\nl = [0, 0, 0, 0, 0]\nl1 = [0, 0, 0, 0, 0]\nfor i in range(5):\n\tl[i] = n / 5\n\tl1[i] = m / 5\nfor i in range(5):\n\tif (n % 5 >= i) and (i != 0):\n\t\tl[i] = l[i] + 1\n\tif (m % 5 >= i) and (i != 0):\n\t\tl1[i] = l1[i] + 1\n\nprint(l[0] * l1[0] + l[1] * l1[4] + l[2] * l1[3] + l[3] * l1[2] + l[4] * l1[1])\n"}, {"source_code": "n, m = map(int, input().split())\nmini, maxi = min(n, m), max(n, m)\ncount = 0\nfor i in range(1, mini + 1):\n count += (i + maxi) // 5 - (i // 5)\nprint(count)"}, {"source_code": "import math\nx,y = map(int,input().split())\nlow = min(x,y)\nhigh= max(x,y)\nres = 0\nfor i in range(1,low+1) :\n if i%5==0 :\n res += ((high - (5 - 0)) // 5) + 1\n else :\n h = (math.ceil(i/5) * 5) - i\n res+= ((high - h)//5) + 1\nprint(res)"}, {"source_code": "a,b=[int(i) for i in input().split()]\na0=0\na1=0\na2=0\na3=0\na4=0\nb0=0\nb1=0\nb2=0\nb3=0\nb4=0\nfor i in range(1,a+1):\n if i%5==0:\n a0=a0+1\n elif i%5==1:\n a1+=1\n elif i%5==2:\n a2+=1\n elif i%5==3:\n a3+=1\n else:\n a4+=1\nfor i in range(1,b+1):\n if i%5==0:\n b0=b0+1\n elif i%5==1:\n b1+=1\n elif i%5==2:\n b2+=1\n elif i%5==3:\n b3+=1\n else:\n b4+=1\nprint(a0*b0+a1*b4+a2*b3+a3*b2+a4*b1)\n"}, {"source_code": "class AlyonaAndNumbers:\n def solve(self,n,m):\n maxnum = max(n,m)\n minnum = min(n,m)\n currfive = (n+m)-((n+m)%5)\n if minnum+maxnum<5:return 0\n elif minnum+maxnum==5: return 1\n elif maxnum==3 and minnum==3: return 2\n if currfive==5: return minnum\n pairct=0\n while currfive>5:\n pairone=[]\n pairtwo=[]\n if maxnum>=currfive:\n pairone=[currfive-1,1]\n else:\n pairone=[maxnum,currfive-maxnum]\n\n if minnum >= currfive:\n pairtwo=[currfive-1,1]\n else:\n pairtwo = [minnum, currfive - minnum]\n pairct+=(pairone[0]-pairtwo[1])+1\n currfive-=5\n if maxnum>3 and minnum>3: pairct+=4\n else: pairct+=minnum\n return pairct\nif __name__ == \"__main__\":\n n,m = map(int,raw_input().split(\" \"))\n aan = AlyonaAndNumbers()\n print aan.solve(n,m)"}, {"source_code": "n,m=(int(i) for i in input().split())\nl1=[0]*5\nl2=[0]*5\nfor i in range(1,n+1):\n l1[i%5]+=1\nfor i in range(1,m+1):\n l2[i%5]+=1\n\ns=(l1[0]*l2[0])+(l1[1]*l2[4])+(l1[2]*l2[3])+(l1[3]*l2[2])+(l1[4]*l2[1])\nprint(s)\n\n\n"}, {"source_code": "m,n = raw_input().split()\nm,n = [int(m),int(n)]\n\npairs = ( (m/5)*(n/5)*5 ) + (m%5)*(n/5) + (m/5)*(n%5)\n\nfor i in xrange(1,(m%5)+1):\n for j in xrange(1,(n%5)+1):\n if (i + j == 5):\n pairs = pairs + 1\n\nprint pairs"}, {"source_code": "n,m=map(int,input().split())\nl=[0]*5\nd=[0]*5\nfor i in range(1,n+1):\n x=i%5\n l[x]+=1\nfor j in range(1,m+1):\n x=j%5\n d[x]+=1\ns=l[0]*d[0]\nfor i in range(1,5):\n s=s+l[i]*d[5-i]\nprint(s)"}, {"source_code": "m, n = map(int, input().split())\nk = min(m, n); x = max(m, n); s = 0\nfor i in range(1, k + 1):\n s += (i % 5 + x) // 5\nprint(s)"}, {"source_code": "n,m = map(int, raw_input().split())\nres = (n/5)*(m/5)*5\nfirst = n % 5\nsecond = m % 5\nres += first*(m/5) + second*(n/5)\nfor i in range(1, first + 1):\n\tfor j in range(1, second + 1):\n\t\tif (i + j) % 5:\n\t\t\tcontinue\n\t\telse:\n\t\t\tres += 1\n\t\t\t\nprint res"}, {"source_code": "m,n=map(int,raw_input().split());\na=m/5;b=n/5;\ns=5*a*b;\nc=m%5;d=n%5;\nfor i in xrange(1,c+1):\n s+=b;\nfor i in xrange(1,d+1):\n s+=a;\nif c>=1 and d>=4:\n s+=1;\nif c>=2 and d>=3:\n s+=1;\nif c>=3 and d>=2:\n s+=1;\nif c>=4 and d>=1:\n s+=1;\nprint s\n"}, {"source_code": "n,m=map(int,raw_input().split())\nans=chk=0\nfor i in range(1,n+1):\n ans+=(i+m)/5-i/5\nprint ans"}, {"source_code": "n, m = list(map(int, input().split()))\nans = 0\nfor i in range(1, n+1):\n ans += (m + i % 5) // 5\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\n\nN = int(n/10)\nM = int(m/10)\n\nc = 0\nfor i in range(10 * N + 1, n+1):\n for j in range(10 * M + 1, m+1):\n if (i+j) % 5 == 0:\n c += 1\n\nprint(n*2*M + N*2*(m-10*M) + c)\n"}, {"source_code": "import sys\n# from math import ceil,log,gcd,sqrt\n# sys.setrecursionlimit(10**9)\n\nRI = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\n\nn,m = RI()\nlis1 = [0]*5\nlis2 = [0]*5\n\nfor i in range(5):\n lis1[i] = n//5\n lis2[i] = m//5\n lis1[i] += 1 if n%5 >= i and i!= 0 else 0\n lis2[i] += 1 if m%5 >= i and i!= 0 else 0\n\nans = 0\nfor i in range(5):\n ans +=(lis1[i] * lis2[(5-i)%5])\nprint(ans)"}, {"source_code": "\ninput = raw_input()\n\nn, m = map(int, input.split())\n\nn1 = (1+(m-4)/5) * (1+(n-1)/5)\nn2 = (1+(m-3)/5) * (1+(n-2)/5)\nn3 = (1+(m-2)/5) * (1+(n-3)/5)\nn4 = (1+(m-1)/5) * (1+(n-4)/5)\nn5 = ((m)/5) * ((n)/5) \n\nprint (n1+n2+n3+n4+n5)"}, {"source_code": "#n = int(input())\nn, m = map(int, input().split())\n#s = input()\n#c = list(map(int, input().split()))\nl = (n // 5) * (m // 5)\nfor i in range(1, 5):\n l += ((n - i) // 5 + 1) * ((m - 5 + i) // 5 + 1)\nprint(l)"}, {"source_code": "#Coder: Parth Dubal\n#College: GLSICA\na=input().split(\" \")\ntemp,ans,count,i,n,m=1,0,0,5,int(a[0]),int(a[1])\nif n>m: n,m=m,n\nwhile temp>0:\n\tif n>=i: temp=i-1\n\telif m>=i: temp=n\n\telif i>m: temp=n-(i-m)+1\n\tif temp>0: ans+=temp\n\ti+=5\nprint(ans)\n"}, {"source_code": "n, m = map(int, raw_input().split())\n\ncount1 = [0] * 5\ncount2 = [0] * 5\nfor i in xrange(1, n+1): count1[i % 5] += 1\nfor i in xrange(1, m+1): count2[i % 5] += 1\n\nans = count1[1] * count2[4] + count1[2] * count2[3] + count1[3] * count2[2] + count1[4] * count2[1] + count1[0] * count2[0]\n\nprint ans\n\n"}, {"source_code": "n, m = map(int, input().split(\" \"))\nres = 0\n\nfor i in range(1, 6):\n if n%5 >= i:\n res += ((i%5+m)//5)*(n//5+1)\n else:\n res += ((i%5+m)//5)*(n//5)\nprint(res)\n"}, {"source_code": "a,b = map(int, input().split())\nx = min(a,b)\ny = max(a,b)\nans = 0\nfor i in range(1,x+1):\n k=i+1\n while (k%5!=0):\n k+=1 \n temp = (y-(k-i))//5\n if temp>=0:\n ans+=temp+1\nprint(ans) "}, {"source_code": "n,k=map(int,input().split())\narr=[ i%5 for i in range(1,n+1)]\nls=[ i%5 for i in range(1,k+1)]\nvar=arr.count(0)*ls.count(0)\nvar+=arr.count(1)*ls.count(4)+arr.count(4)*ls.count(1)\nvar+=arr.count(2)*ls.count(3)+arr.count(3)*ls.count(2)\nprint(var)\n\n\n\n"}, {"source_code": "a,b=list(map(int,input().split()))\n#a_dict={\"0\":0,\"1\":0,\"2\":0,\"3\":0,\"4\":0}\n#b_dict={\"0\":0,\"1\":0,\"2\":0,\"3\":0,\"4\":0}\n\ntemp=a\n#print(temp//5)\na_dict={\"0\":temp//5,\"1\":temp//5,\"2\":temp//5,\"3\":temp//5,\"4\":temp//5}\n\ntemp=temp%5\nwhile temp:\n a_dict[str(temp)]=a_dict[str(temp)]+1\n temp-=1\n \n\n\n\ntemp=b\nb_dict={\"0\":temp//5,\"1\":temp//5,\"2\":temp//5,\"3\":temp//5,\"4\":temp//5}\n\n\n\ntemp=temp%5\nwhile temp:\n b_dict[str(temp)]=b_dict[str(temp)]+1\n temp-=1\n\n#print(a_dict,b_dict)\n\n\n\n\ncount=a_dict[\"0\"]*b_dict[\"0\"]\nfor i in range(1,5):\n count+=a_dict[str(i)]*b_dict[str(5-i)]\nprint(count)"}, {"source_code": "n, m = map(int, input().split())\nq1 = n // 5\nq2 = m // 5\nres = 5 * q1 * q2\nr1 = n % 5\nr2 = m % 5\narr1 = [i + 1 for i in range(r1)]\narr2 = [i + 1 for i in range(r2)]\nfor i in range(r1):\n for j in range(r2):\n if arr1[i] + arr2[j] == 5:\n res += 1\nres += q1 * r2\nres += q2 * r1\nprint(res)"}, {"source_code": "n,m = list(map(int,input().split()))\nS=0\nfor i in range(1,n+1):\n\t\tS+=((m-(5*(i//5)+5)+i)//5)+1\nprint(S)\t\t\n"}, {"source_code": "n, m = map(int, input().split(\" \"))\nres = 0\nprint(sum((((i+1)%5+m)//5)*(n//5+1) for i in range(5) if n%5>=(i+1))+\n sum((((i+1)%5+m)//5)*(n//5) for i in range(5) if n%5<(i+1)))\n"}, {"source_code": "n, m = tuple([int(x) for x in input().split()])\na = [0 for x in range(5)]\nb = [0 for x in range(5)]\ncount = 0\n\nfor i in range(1, n+1):\n\ta[i % 5] += 1\n\nfor i in range(1, m+1):\n\tb[i % 5] += 1\n\ncount = a[0] * b[0]\n\nfor i in range(1, 5):\n\tcount += a[i] * b[5 - i]\n\nprint(count)\n"}, {"source_code": "s=map(int,raw_input().split())\nn=s[0]\nm=s[1]\ndn={}\ndm={}\nfor i in range(5):\n\tdn[i]=n/5\n\tdm[i]=m/5\nfor i in range(1,(n%5)+1,1):\n\tdn[i]=dn[i]+1\nfor i in range(1,(m%5)+1,1):\n\tdm[i]=dm[i]+1\nans=0\nfor i in range(5):\n\tif(i==0):\n\t\tans=ans+(dn[i]*dm[i])\n\telse:\n\t\tans=ans+(dn[i]*dm[5-i])\nprint ans"}, {"source_code": "\"\"\"\n\n\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2551\u255a\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2588\u2588\u2551\n\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\n\u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u255d\n __ __ _ \n| \\/ (_)_ __ ___ _ __ \n| |\\/| | | '__/ _ \\| '_ \\ \n| | | | | | | (_) | | | | \n|_| |_|_|_| \\___/|_| |_| \n\"\"\"\n\"\"\"\n\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u258c\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u25d0\u25d0\u25d0\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2580\u2580\ud83d\udd25\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u258c\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u258c\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2584\u2588\u2588\u2588\u2588\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u25d0\u25d0\u25d0\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2580\u2580\ud83d\udd25\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\n\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@#@@#@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@M@M # #@@@M@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@#@@ @@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@### #@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@B@@#@@@@@#M@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@##@@M@#@@##@##@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#M@@@@@##@M@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@@@@@@#@##@#@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ #\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ #\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@ @@#@@#@@@@@@@@@@@@@@@@@#@@#@#@@@@@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@\n @ #@@@@@@@@@@@@@@@@@@@@#@@@@@@#@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@ @@#@#@@@@@@@@@@@@@@@@@@#@####@@@@@@@@@@@@@@@@@M@#@@#@#@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@#@#M@@@M@@@@@@@@@@@@@@@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n#@M@#@#@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@M@@M@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@@#@@@@@@@@@@@@@@@@@@@@M@M@#@@@@@@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@\n@@#@@#@@@@@@@@@@@@@@@@@@@@@@@M@ @M@@#@@@@@@@@@@@@@@@@@@@@@@@@@\n@#@@@@@#@@@@@@@@@@@@@@@@@@@#@@ @@@@M@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@@@##@@@#@@@@@#@@@@@##@@@@ #@#@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@####@@####@@@@#@@@@M@@@#@@# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@#@ @#@@#@@@ #@ @ #@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @# @@#@@ #@@#@@@@@@@@@@@@@@@@@@@@@@@@@\n ##@#@@ #M @# @@ @@M @@@@@@@@@@@@@@@@@@@@@@@@\n @#@@@M #@ #@ # @@ @@@@@@@@@@@@@@@@@@@@@@@@\n @@ @@#@@ ## @##@@ @@@@@@@@@@@@@@@@@@@@@@@@\n @# @@M@ @@ @@@@@@@@@@@@@@@@@@@@@@@@\n @@@##@@@ @@@@ @@@ @@ #@#@@#@@@@@@@@@@@@@@@@@\n@@@@###@@###@@@@#@#@@@@#@@@ M@ #@ @ B @@@#@@@@@@@@@@@@@@@@@@@\n@M@@@@@MM@@@@@M@@#@##@@@#@@M@B @# M@ @# #@ #@@#@@@@@@@@@@@@@@@@@@@\n@#@#@@M@@M@@#@#@#@#@@#@#@#@@@@ @# @@ # @M @#@@@@@@@@@@@@@@@@@@@@@\n@@@ @@@@#@##@ #@# @M # @ @ @@@@@#@@@@@@@@@@@@@@@@@\n @@ @@ @#@@#@@#M #@@@@#@@@@@@@@@@@@@@@@@\n M@# #@ @@@@##@@ @M@#M@@@#@@@@@@@@@@@@@@@@\n @@@@ @@ @@@#@@@#@#@@@@@@@@@@@@@@@@\n @# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @M@H@@ @# @#@@@@#@@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@#@##@M@@@M@ @M#@@@@@#@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n#M@@@##@@@@@@@@M@@@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@#@@@@@M@#@M@@B#M@@M@###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n###@@@@@@@@@# @#@@@@@@@#@@@#@##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@#@@M@@@#@@#@#@@@@@@#@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@M@#@# \n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@#\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@##\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@M\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n\"\"\"\n\"\"\"\n / \\ //\\\n |\\___/| / \\// \\\\\n /0 0 \\__ / // | \\ \\ \n / / \\/_/ // | \\ \\ \n @_^_@'/ \\/_ // | \\ \\ \n //_^_/ \\/_ // | \\ \\\n ( //) | \\/// | \\ \\\n ( / /) _|_ / ) // | \\ _\\\n ( // /) '/,_ _ _/ ( ; -. | _ _\\.-~ .-~~~^-.\n (( / / )) ,-{ _ `-.|.-~-. .~ `.\n (( // / )) '/\\ / ~-. _ .-~ .-~^-. \\\n (( /// )) `. { } / \\ \\\n (( / )) .----~-.\\ \\-' .~ \\ `. \\^-.\n ///.----..> \\ _ -~ `. ^-` ^-_\n ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~\n /.-~\n\n\"\"\"\n\"\"\"\n ____ _ _____ \n / ___|___ __| | ___| ___|__ _ __ ___ ___ ___ \n| | / _ \\ / _` |/ _ \\ |_ / _ \\| '__/ __/ _ \\/ __|\n| |__| (_) | (_| | __/ _| (_) | | | (_| __/\\__ \\\n \\____\\___/ \\__,_|\\___|_| \\___/|_| \\___\\___||___/\n\"\"\"\n\"\"\"\n\u2591\u2591\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\n\u2591\u2584\u2580\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2588\u2591\n\u2591\u2588\u2591\u2584\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2584\u2591\u2588\u2591\n\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2591\n\u2591\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2591\n\u2584\u2588\u2580\u2588\u2580\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2580\u2580\u2588\u2588\u2588\n\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\n\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2588\u2588\n\u2588\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\u2588\n\u2591\u2580\u2588\u2588\u2588\u2584\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2584\u2588\u2588\u2588\u2580\u2591\n\u2591\u2591\u2591\u2580\u2588\u2588\u2584\u2591\u2580\u2588\u2588\u2580\u2591\u2584\u2588\u2588\u2580\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\nn = int(input())\nos=0\nch=[]\nfor i in range(n):\n\tm = int(input())\n\tch.append(m)\t\n\tif ch[0]==10:\t\t\n\t\tif 1 in ch:\n\t\t\tprint((len( ch[:ch.index(1)])))\n\t\t\tbreak\n\telse:\n\t\tif 10 in ch:\n\t\t\tprint((len( ch[:ch.index(10)])))\n\t\t\tbreak\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\nm = float(m)\nmi = []\nfor i in range(n):\n\ta,b = map(float,input().split())\n\tmi.append((a*m)/b)\nprint(round(min(mi),6))\n\"\"\"\n\"\"\"\nl = input().split()\nl = set(l)\nprint(len(l))\n\n\"\"\"\n\"\"\"\t\nx = input()\ny = x[1:-1]\nz = set(y.split(', '))\nif x == \"{}\":\n\tprint(0)\nelse:\n\tprint(len(z))\n\"\"\"\n\"\"\"\nn,k = map(int,input().split())\nL = sorted(map(int, input().split()))\nres = [L[0]]\nfor i in range(1,n):\n if L[i] != L[i-1]:\n res.append(L[i]-L[i-1])\nl = len(res)\nif k > l:\n res += [0]*(k-l)\nfor i in range(k):\n print(res[i])\n\n\"\"\"\t\n\"\"\"\nfrom math import*\ns,k = map(int,input().split(\" \"))\nsq = input().split()\nscore = 0\npol = \"\"\nfor i in range(len(sq)):\n\tif sq[i]>=sq[i-1]:\n\t\tscore+=1\nprint(ceil(score/len(sq))+ceil(score/len(sq)))\n\"\"\"\n\"\"\"\nfrom math import*\ns,k = map(int,input().split(\" \"))\nsq = input().split()\nscore = 0\npol = \"\"\nfor i in range(len(sq)):\n\tif sq[i]>=sq[i-1]:\n\t\tscore+=1\nprint(ceil(score/len(sq))+ceil(score/len(sq)))\n\"\"\"\n\"\"\"\nst=list(input().split('+'))\nst.sort()\nfor i in range(len(st)):\n if i!=len(st)-1:\n print(str(st[i])+'+',end='')\n else:\n print(str(st[i]))\n\"\"\"\n\"\"\"\na = input()\nup = a.upper()\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nprint(abc[abc.find(up[0])]+a[1::])\n\"\"\"\n\"\"\"\n\nn= int(input())\nk = 0\nfor i in range(n):\n\tp = input()\n\tif p == \"++X\" or p == \"X++\":\n\t\tk+=1\n\telif p == \"--X\" or p == \"X--\":\n\t\tk-=1\nprint(k)\n\n\"\"\"\n\"\"\"\nimport math \n\nc = 1 \n\nl = int(input()) \n\ng = \"\" \n\nfor i in range(l): \n\n for s in range(1,l - i + 1): \n\n g = g + \" \" \n for j in range(0,i + 1): \n if(i == 0 or j == 0): \n c = 1 \n else: \n c = c * (i - j + 1)/j \n\n t = c \n T=0 \n while(t != 0): \n T = T + 1 \n t = int(math.floor(t/10)) \n p=0 \n while((p+T)!=4): \n g = g + \" \" \n p=p+1 \n g = g + str(int(math.floor(c))) \n g = g + \"\\n\" \nprint(g)\n\"\"\"\t\n\"\"\"\n ___ __ _ _ \n|_ _|_ __ / _| ___ _ __ _ __ ___ __ _| |_(_) ___ ___ \n | || '_ \\| |_ / _ \\| '__| '_ ` _ \\ / _` | __| |/ __/ __|\n | || | | | _| (_) | | | | | | | | (_| | |_| | (__\\__ \\\n|___|_| |_|_| \\___/|_| |_| |_| |_|\\__,_|\\__|_|\\___|___/ \n\"\"\"\n\"\"\" \nfrom math import*\na1 = float(input())\na2 = float(input())\nb = sqrt(a1**2 + a2**2)\nprint(b)\n\"\"\" \n\"\"\"\na1 = float(input())\na2 = float(input())\nb = (a1**2 + a2**2)\nimport math\nl = math.sqrt(b)\nprint(l)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if i%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if a[i]%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if a[i]>0:\n b.append(a[i])\nprint(len(b))\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(1,n):\n if a[i]>a[i-1]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(1,n):\n if a[i]>a[i-1]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(n-1):\n if i == 0:\n pass\n elif a[i]>a[i-1]and a[i+1]< a[i]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\na.reverse()\nfor i in a:\n print(i,end = \" \")\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nprint(max(a))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split(\" \")))\nl = 0\nq = []\nfor i in range(len(a)):\n if a[i] in q:\n pass\n else:\n l +=1\n q.append(a[i])\nprint(l)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nx = int(input())\nk =1\nfor i in range(len(a)):\n k+=1\n if x > a[i]:\n print(i+1)\n exit()\nprint(k)\n\"\"\"\n\"\"\"\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if i%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(len(a)-1):\n if i == 0:\n pass\n elif a[i]>a[i-1]and a[i+1]< a[i]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\na = list(map(int,input().split()))\nprint(max(a),a.index(max(a)))\n\"\"\"\n\"\"\"\nch = list(input()) \nif ch.count(\"h\")>=1 and ch.count(\"e\")>=1 and ch.count(\"l\")>=2 and ch.count(\"o\")>=1 and len(ch)!=53:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom decimal import Decimal\nx,y = map(Decimal,input().split(\" \"))\nd = 1\nwhile x < y and x - y < 0.000001 :\n x += x * 70 / 100\n d += 1\nprint(d)\n\"\"\"\n\"\"\"\nn = int(input())\nabc = \"abcdefghijklmnopqrstuvwxyz\"\ns =\"\"\nfor i in range(n):\n\tk,v = map(int,input().split())\n\tfor i in range(k):\n\t\twhile len(s) <= k:\n\t\t\ts += abc[:v]\n\t\tif len(s)>k:\n\t\t\ts = s[:-(len(s)-k)]\n\tprint(s,end=\"\\n\")\n\ts=\"\"\t\t\n\"\"\"\n\"\"\"\nk = int(input())\nl = int(input())\nm = int(input())\nn = int(input())\nd = int(input())\nlst = []\nlst.append(k)\nlst.append(l)\nlst.append(m)\nlst.append(n)\nuron = 0\nfor i in range(len(lst)):\n\tif d % lst[i] == 0:\n\t\turon+=lst[i]\nprint(uron)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nch = 0\nnch = 0\nfor i in range(len(a)):\n\tif a[i] % 2 == 0:\n\t\tch+=1\n\telse:\n\t\tnch+=1\nif ch > nch:\n\tfor i in range(len(a)):\n\t\tif a[i] % 2 == 1:\n\t\t\tprint(a.index(a[i])+1)\nelse:\n\tfor i in range(len(a)):\n\t\tif a[i]%2==0:\n\t\t\tprint(a.index(a[i])+1)\n\"\"\"\n\"\"\"\nn,t = map(int,input().split())\noc = input()\nfor i in range (1,n):\n\tif oc[i]==\"B\":\n\t\toc[i]=oc[i-1]\nprint(oc)\t\t\t\n\"\"\"\n\"\"\"\nn = int(input())\no = 0\nfor i in range(n):\n\to += ((n-2) - (n % 2))//2\nprint(o)\n\"\"\"\n\"\"\"\nsl = input()\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nm=0\nb=0\nbig = \"\"\nfor i in range(len(sl)):\n\tif sl[i]== abc[abc.find(sl[i])]:\n\t\t\tb+=1\n\telse:\n\t\t\tm +=1\nif m>b:\n\tbig += sl.lower()\n\tprint(big)\nelif b>m:\n\tbig += sl.upper()\n\tprint(big)\nelif b==m:\n\tbig += sl.lower()\n\tprint(big)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(n):\n\tprint(a.index(i+1)+1, end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\nif n % 2 == 0 and n != 2 :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\na = input().replace(\"WUB\",\" \")\nprint(a)\n\"\"\"\n\"\"\"\na = int(input())\nb = list(map(int,input().split()))\nb.sort()\nfor i in b:\n\tprint(i,end=\" \")\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\no = 0\nif a % 2 == 0:\n\to = a//2\nelse:\n\to = (a//2)+1\nif b <= o:\n\tprint((1+((o-1)*2)))\nelse:\n\tprint(((o-1)*2))\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nyear = 0\nwhile b>=a:\n\ta*=3\n\tb*=2\n\tyear+=1\nprint(year)\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\nm = float(m)\nmi = []\nfor i in range(n):\n\ta,b = map(float,input().split())\n\tmi.append((a*m)/b)\nprint(min(mi))\n\"\"\"\n\"\"\"\nn = int(input())\nx = 0\nfor i in range(n):\n\ta = input()\n\tif a == \"Tetrahedron\":\n\t\tx+=4\n\telif a == \"Cube\":\n\t\tx+=6\n\telif a == \"Octahedron\":\n\t\tx+=8\n\telif a == \"Dodecahedron\":\n\t\tx+=12\n\telif a == \"Icosahedron\":\n\t\tx+=20\nprint(x)\n\"\"\"\n\"\"\"\nn= int(input())\na = list(map(int,input().split()))\nfor i in a:\n\tif sum(a)>0:\n\t\tprint(\"HARD\")\n\t\tbreak\n\telse:\n\t\tprint(\"EASY\")\n\t\tbreak\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nc = list(map(int,input().split()))\nbal = 0\nfor i in range(1,len(c)+1):\n\tif b == len(c):\n\t\tif c[i]>=c[b-1]:\n\t\t\tbal +=1\n\telse:\n\t\t\n\t\tif c[i]>=c[b] and c[i]!= 0:\n\t\t\tbal+=1\nprint(bal)\n\"\"\"\n\"\"\"\na,b =map(int, input().split())\ny=list(map(int,input().split()))\nfor i in y:\n if i<y[b-1] or i==0:\n a-=1 \nprint(a)\n\"\"\"\n\"\"\"\na,b=map(int,input().split())\nc=b-(a+1)//2\nif c > 0:\n\tprint(2*c)\nelse:\n\tprint(2*b-1)\n\"\"\"\n\"\"\"\na = input()\nb = input()\na1 = a.lower()\nb1 = b.lower()\no = 0\nk = 0\nif a1>b1:\n\to+=1\nif b1>a1:\n\tk+=1\nprint(o-k)\n\"\"\"\n\"\"\"\nn=int(input())\np=input().split()\nq=input().split()\nm = p[1:]\nj = q[1:]\nif len(set(m+j))==n:\n print(\"I become the guy.\")\nelse:\n print(\"Oh, my keyboard!\")\n\"\"\"\n\"\"\"\na = set(input())\nfor i in range(len(a)):\n\ta.remove()\n\tif a == \"hello\":\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\na = n.count(4)+n.count(7)\nif a == 7 or a == 4:\n\t\tprint(\"YES\")\n\t\t\nelse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\t\nn = int(input())\nb = input()\nb = b.upper\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nfor i in range(len(b)):\n\tif abc[i] in b:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn,a,b = list(map(int,input().split()))\npos = 0\nfor i in range(n):\n\tif (a + b) % 2 == 0:\n\t\tprint(a+b)\n\t\tbreak\n\telse:\n\t\tprint(ceil((a+b)/2))\n\t\tbreak\n\"\"\"\n\"\"\"\nn = int(input())\nans = 0\nfor i in range(n):\n\ta,b,c = map(str,input().split())\n\tb = int(b)\n\tfor i in range(n):\n\t\tif b == -b and c == \"YES\":\n\t\t\tprint(\"Impossible\")\n\t\telif ans > b and c == \"Y\":\n\t\t\tans += 1\n\t\telif ans < b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans >= b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans <= b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans > b and c == \"N\":\n\t\t\tbreak\n\t\telif ans < b and c == \"N\":\n\t\t break\n\t\telif ans >= b and c == \"N\":\n\t\t\tbreak\n\t\telif ans <= b and c == \"N\":\n\t\t\tbreak\nprint(ans)\t\t\n\"\"\"\n\"\"\"\nfrom math import*\nn,k = map(int,input().split())\na = list(map(int,input().split()))\ncom = 0\nfor i in range(len(a)):\n\tif a[i]+2 <= 5:\n\t\tcom += 0.333\nprint(ceil(com))\n\"\"\"\n\"\"\"\nn,a,b = map(int,input().split())\nd = []\ns = 0\nk = 1\nfor i in range(n-1):\n\tif a == 0 and b == 0:\n\t\tprint(n)\n\t\texit()\n\td.append(\"*\"*((a+i)) +\"+\"+\"*\"*(((b-i)-k)))\n\tif len(d[i])<=n:\n\t\ts+=1\nprint(s)\n\"\"\"\n\"\"\"\nn,h =map(int, input().split())\nfor i in map(int, input().split()):\n if i > h:\n n+=1\nprint(n)\t\n\"\"\"\n\"\"\"\nn = input()\na = input()\nif a.count('A')> a.count('D'):\n\tprint('Anton')\nelif a.count('A')<a.count('D'):\n\tprint('Danik')\nelse:\n\tprint('Friendship')\n\"\"\"\n\"\"\"\nn = int(input())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\ng = list(map(sum,a))\ncount=0\ni=0\nfor j in g:\n if j >=2:\n count+=1\nprint(count)\n\"\"\"\n\"\"\"\nn=int(input())\nx=input()\nc=0\nfor i in range(n-1):\n if x[i] == x[i+1]:\n c+=1\nprint(c)\n\"\"\"\n\"\"\"\nk = list(map(int,input().split()))\nt = input()\nkal = 0\nfor i in range(len(t)):\n\tif t[i]==\"1\":kal += k[0]\n\telif t[i]==\"2\":kal += k[1]\n\telif t[i]==\"3\":kal += k[2]\n\telif t[i] == \"4\":kal += k[3]\nprint(kal)\n\"\"\"\n\"\"\"\norient = input()\nkey = input()\nkeyboard = \"poiuytrewq;lkjhgfdsa/.,mnbvcxz\"\nans = \"\"\nfor i in range(len(key)):\n\tif orient == \"R\":\n\t\tans += keyboard[keyboard.find(key[i])+1]\n\telif orient == \"L\":\n\t\tans += keyboard[keyboard.find(key[i])-1]\nprint(ans)\n\"\"\"\n\"\"\"\nn,k = map(int, input().split())\nabc = \"abcdefghijklmnopqrstuvwxyz\"\nf = abc[:k]\ns = f \nwhile len(s) < n:\n s += f\ns = s[:n]\nprint(s)\n\"\"\"\n\"\"\"\nn = int(input())\nif n %2 == 0 or n == 2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nmas = 0\nwhile 1:\n\ttry:\n\t\ta = input()\n\t\tif \":\" in a:\n\t\tmas += len(a[a.find(\":\"):])\n\texcept EOFError:\nprint(mas)\n\"\"\"\n\"\"\"\na = input()\nb = input()\nc = str(int(a)+int(b))\nif int(a.replace(\"0\",\"\"))+int(b.replace(\"0\",\"\"))== int(c.replace(\"0\",\"\")):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\ns = input()\nw = len(s)\nn=int(input())\nb=[]\nfor i in range(n):\n wd=input()\n if wd[:w]==s:\n b.append(wd)\nb.sort()\nif len(b)==0:\n print(s)\nelse:\n print(min(b))\n\"\"\"\n\"\"\"\nn = int(input())\nans = 0\nfor i in range(n):\n\tx,a = map(int,input().split())\n\tif x == -x and a:\n\t\tans += a \n\telse:\n\t\tans+=a\nprint(ans)\n\"\"\"\n\"\"\"\nfrom decimal import Decimal\nn,m = map(int,input().split())\nfst = []\nscd = []\na=0\nfor i in range(1,n+1):\n\tfor j in range(1,m+1):\n\t\tif (i+j)%5==0:\n\t\t\ta+=1\nprint(a)\n\"\"\"\n\"\"\"\nn,a = map(int,input().split())\nans = \"\"\nfor i in range(n):\n\tb = list(map(str,input().split()))\n\tfor j in range(a):\n\t\tif b[j] != \"B\" or b[j]!=\"W\"or b[j]!=\"G\":\n\t\t\tans += \"#Color\"\n\t\t\tbreak\n\t\t\t\n\t\telse:\n\t\t\tans += \"#Black&White\"\n\t\t\tbreak\nprint(ans)\n\"\"\"\n\"\"\"\nn=int(input())\nnum=0\na , b =[],[]\nfor i in range(n):\n c=input().split()\n a.append(c[0])\n b.append(c[1])\nfor i in a:\n num+=b.count(i)\nprint(num)\n\"\"\"\n\"\"\"\nn = int(input())\nb = input()\na = b.lower()\n\nif a.count(\"a\")>=1 and a.count(\"b\")>=1 and a.count(\"c\")>=1 and a.count(\"d\")>=1 and a.count(\"e\")>=1 and a.count(\"f\")>=1 and a.count(\"g\")>=1 and a.count(\"h\")>=1 and a.count(\"i\")>=1 and a.count(\"j\")>=1 and a.count(\"k\")>=1 and a.count(\"l\")>=1 and a.count(\"m\")>=1 and a.count(\"n\")>=1 and a.count(\"o\")>=1 and a.count(\"p\")>=1 and a.count(\"q\")>=1 and a.count(\"r\")>=1 and a.count(\"s\")>=1 and a.count(\"t\")>=1 and a.count(\"u\")>=1 and a.count(\"v\")>=1 and a.count(\"w\")>=1 and a.count(\"x\")>=1 and a.count(\"y\")>=1 and a.count(\"z\")>=1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\ndig = []\nfor i in range(1,n+1):\n\tif factorial(i-1) % i != i-1:\n\t\tdig.append(i)\nfor j in range(1,len(dig)+1):\t\n\tif dig[j] + dig[j-n%2-4] == n or dig[j] + dig[j-n%2-9] == n:\n\t\tprint(dig[j],dig[j-n%2-4])\n\"\"\"\n\"\"\"\na=input()\nb=input()\ns=input()\nc=a+b\nd=list(s)\ne=list(c)\nd.sort()\ne.sort()\nif d==e:\n print('YES')\nelse:\n print('NO')\n\"\"\"\n\"\"\"\n def nextmiron(s):\n s += '#'\n cnt = 1\n ret = \"\"\n for i in range(1, len(s)):\n if s[i] == s[i - 1]:\n cnt += 1\n else:\n ret += str(cnt) + s[i - 1];\n cnt = 1\n return ret\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\nfor i in range(len(n)):\n\tif n[i] > 0:\n\t\tprint(n[i],end=\"\")\n\t\texit()\n\telif n[i]>n[i-1]:\n\t\tn.remove(n[i])\nfor i in n:\n\tprint(n[i],end=\"\")\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\na = 0\nans = 0\nfor i in range(len(n)):\n\t\ta += n[i]+n[i-1]\n\t\tans += 1\n\t\tif a in n:\n\t\t\tbreak\nprint(ans+1)\n\"\"\"\n\"\"\"\nfrom math import factorial as fal\na,b = map(int,input().split())\nans = 0\np = []\nprime = []\nfor i in range(a,b+1):\n\tif fal(i-1) % i == i-1:\n\t\tp.append(i)\nfor i in range(len(p)):\n\tif fal((int(str(p[i])[::-1]))-1)% int(str(p[i])[::-1]) == int(str(p[i])[::-1])-1: \n\t\tans += 1\nprint(ans)\n\"\"\"\n\"\"\"\na,b,c = map(int,input().split())\nd = str(a/b)\nif len(d)==3:\n\tprint(d+\"0\"*(c-1))\nelse:\n\tprint(round((a/b),c))\n\"\"\"\n\"\"\"\na = list(input())\nn = 0\nh = 'hello'\nfor i in range(len(a)):\n if a[i] == h[n]:\n n += 1\n if n >= 5:\n break\nif n >= 5: \n\tprint('YES')\nelse: \n\tprint('NO')\n\"\"\"\n\"\"\"\nfrom decimal import Decimal\nfrom math import factorial as fal\na,b = map(int,input().split())\nif a > b:\n\ta,b = a,b\nelse:\n\tpass\nans = 0\nfor i in range(a,b+1):\n\tif fal(i-1) % i == i-1 and fal((int(str(i)[::-1]))-1) % int(str(i)[::-1]) == int(str(i)[::-1])-1:\n ans += 1 \nif a == 1:\n\tprint(ans - 1)\n\texit()\nprint(ans)\n\"\"\"\n\"\"\"\np = list(map(int,input().split()))\nq = set(p)\ns = 0\nfor i in q:\n s += p.count(i)-1\nprint(s)\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nh = []\nl = []\nfor i in range(b):\n c = list(map(int,input().split()))\n h.append(c)\nh.sort()\nfor i in h:\n if a > i[0]:\n l.append(1)\n a += i[1]\n \nif len(l) == b:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\nn,m=map(int,input().split())\nans=0\nfor i in range(1,n+1):\n\tans += int((i+m)/5)-int(i/5)\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nar1, ar2 = [0] * 5, [0] * 5\n\nfor i in range(1, n + 1):\n ar1[i % 5] += 1\n\nfor i in range(1, m + 1):\n ar2[i % 5] += 1\n\nprint((ar1[0] * ar2[0]) + (ar1[1] * ar2[4]) + (ar1[2] * ar2[3]) + (ar1[3] * ar2[2]) + (ar1[4] * ar2[1]))\n"}, {"source_code": "n,m=map(int, raw_input().split())\ncount=0\nfor i in range(0,n):\n p=(i+1)%5\n count=count+(p+m)/5;\nprint count"}, {"source_code": "t,y=input().split()\nm=int(t)\nn=int(y)\nc=0\nfor i in range(1,n+1):\n #for j in range(1,n+1):\n #print(i+j)\n c+=(i+m)//5-(i)//5\nprint(c) \n"}, {"source_code": "n,m=map(int,input().split())\nprint(sum((m+(i%5))//5 for i in range(1,n+1)))"}, {"source_code": "n,m=map(int,raw_input().strip().split(\" \"))\nn,m=min(n,m),max(n,m)\nlis=[]\nfor i in range(1,n+1):\n lis.append((m+i%5)/5)\nprint sum(lis)\n"}, {"source_code": "n,m = map(int,raw_input().split())\np = [0]*5\nq = [0]*5\nfor i in range(1,n+1):\n\tif i%5==0:\n\t\tp[0] += 1\n\telif i%5==1:\n\t\tp[1] += 1\n\telif i%5==2:\n\t\tp[2] += 1\n\telif i%5==3:\n\t\tp[3] += 1\n\telif i%5==4:\n\t\tp[4] += 1\nfor i in range(1,m+1):\n\tif i%5==0:\n\t\tq[0] += 1\n\telif i%5==1:\n\t\tq[1] += 1\n\telif i%5==2:\n\t\tq[2] += 1\n\telif i%5==3:\n\t\tq[3] += 1\n\telif i%5==4:\n\t\tq[4] += 1\nans = p[0]*q[0]\nfor i in range(1,5):\n\tans += p[i]*q[5-i]\nprint ans"}, {"source_code": "n, m = map(int, raw_input().split())\nrn, rm = [0] * 5, [0] * 5\nfor i in range(1, n + 1):\n rn[i % 5] += 1\nfor i in range(1, m + 1):\n rm[i % 5] += 1\nprint rn[0] * rm[0] + rn[1] * rm[4] + rn[2] * rm[3] + rn[3] * rm[2] + rn[4] * rm[1]\n"}, {"source_code": "import pdb\nn, m = map(int, raw_input().split())\n\nn_map, m_map = {}, {}\n\nfor i in range(1, 10):\n tmp = n - (i - 1)\n if tmp < 0:\n n_map[i] = 0\n else:\n n_map[i] = tmp / 10\n if tmp % 10 >= 1:\n n_map[i] += 1\n\n tmp = m - (i - 1)\n if tmp < 0:\n m_map[i] = 0\n else:\n m_map[i] = tmp / 10\n if tmp % 10 >= 1:\n m_map[i] += 1\n\n\nn_map[0] = n/10\nm_map[0] = m/10\n\n#pdb.set_trace()\n\nres = 0\nres += n_map[0] * m_map[5]\nres += n_map[1] * m_map[4]\nres += n_map[2] * m_map[3]\nres += n_map[3] * m_map[2]\nres += n_map[4] * m_map[1]\nres += n_map[5] * m_map[0]\nres += n_map[6] * m_map[9]\nres += n_map[7] * m_map[8]\nres += n_map[8] * m_map[7]\nres += n_map[9] * m_map[6]\n\nres += n_map[0] * m_map[0]\n\nfor i in range(1, 10):\n res += n_map[i] * m_map[10 - i]\n\nprint res\n"}, {"source_code": "n, m = map(int, input().split())\n\nres = 0\na = [None] * 5\nfor i in range(5):\n\ta[i] = 0\n\nfor i in range(1, m+1):\n\ta[i % 5] += 1\n\nfor i in range(1, n+1):\n\tres += a[(5 - (i%5))%5]\n\nprint(res)"}, {"source_code": "a, b = map(int, raw_input().split())\n\nways = 0\nfor i in xrange(1, a+1):\n n = i%5\n rem = 5-n\n\n w = ( b-rem+1)\n lw = w/5\n\n if w%5 > 0:\n lw += 1\n\n ways += lw\n\n\nprint ways\n"}, {"source_code": "n,m = map(int, input().split())\nans = 0\nfor k in range(1,n+1):\n ans += (k%5+m)//5\nprint(ans)"}, {"source_code": "var1, var2 =input().split()\np=int(var1)\nq=int(var2)\na=int(p/5);\nb=p%5\nc=int(q/5);\nd=q%5;\nsum=0\nsum=p*c+a*d\nfor i in range(b):\n for j in range(d):\n if (i+j+2)%5==0:\n sum+=1\nprint(sum)\n"}, {"source_code": "n,m = map(int, input().split())\nsum = 0\nfor i in range(1, n + 1):\n sum = sum + (m+i%5)//5\nprint(sum)"}, {"source_code": "n, m = map(int, input().split())\n\nanswer = (n // 5)*(m // 5)\n\nfor i in range(1, 5):\n x = n // 5\n y = m // 5\n\n if n % 5 >= i:\n x += 1\n if m % 5 >= 5 - i:\n y += 1\n\n answer = answer + (x * y)\n\nprint(answer)"}, {"source_code": "n , m = map(int,input().split())\ntotal = 0\nd = {}\nfor i in range(1,n+1):\n val = i%5\n if val in d:\n d[val]+=1\n else:\n d[val] = 1\nfor i in range(1,m+1):\n val =i%5\n if(val==0 and val in d):\n total+=d[val]\n else:\n val = 5-val\n if(val in d):\n total+=d[val]\nprint(total)\n"}, {"source_code": "n, m = map(int, input().split())\nt = [0] * 5\nt1 = [0] * 5\nfor i in range(1, n+1):\n t[i % 5] += 1\nfor i in range(1, m+1):\n t1[i % 5] += 1\n\nprint(t[0]*t1[0] + t[1]*t1[4] + t[2]*t1[3]+ t1[1]*t[4] + t1[2]*t[3])\n"}, {"source_code": "n,m = map(int, input().split( ))\ncount = 0\nif(n >= m):\n for i in range(1,m+1):\n count += (n+i)//5 - i//5\nelse:\n for i in range(1,n+1):\n count += (m+i)//5 - i//5\n \nprint(count)"}, {"source_code": "n, m = map(int, raw_input().split())\nn_div, n_mod = n // 5, n % 5\nm_div, m_mod = m // 5, m % 5\n\nresult = 5 * n_div * m_div\nfor i in range(1, n_mod + 1):\n result += m_div\n if 5 - i <= m_mod:\n result += 1\nresult += m_mod * n_div\n\nprint(result)\n"}, {"source_code": "n, m = map(int, raw_input().split())\nnm5 = [n / 5 + (1 if i != 0 and n % 5 >= i else 0) for i in xrange(5)]\nmm5 = [m / 5 + (1 if i != 0 and m % 5 >= i else 0) for i in xrange(5)]\nresult = 0\nfor i in xrange(5):\n result += nm5[i] * mm5[(5 - i) % 5]\nprint result"}, {"source_code": "if __name__ == '__main__':\n n, m = [int(num) for num in raw_input().split()]\n\n nb_pair = 0\n for i in range(1, n+1):\n nb_pair += m / 5\n nb_pair += m%5 >= 5-(i%5)\n\n print nb_pair\n"}, {"source_code": "n,m=map(int,raw_input().split())\ncount = 0\nfor i in range(1, n+1):\n\tcount+= (m+i%5)/5\nprint count"}, {"source_code": "n, m = map(int,raw_input().split(' '))\nans = 0\nfor i in xrange(1,n+1):\n\tr = 5 - (i % 5)\n\tb = m - r\n\tif(b >= 0):\n\t\tans += b/5 + 1\nprint ans"}, {"source_code": "from sys import stdin\ndef printBS(li):\n print \" \".join([str(x) for x in li])\ndef listInput():\n return map(int,stdin.readline().split())\na,b=listInput()\nans=0\nfor i in xrange(1,a+1):\n m=5-i%5 if i%5 else 5\n ans+=int((b-m)/5.0+1.0) if b>=m else 0\nprint ans\n\"\"\"m+(n-1)*d<=b\n n<=(b-m)/d+1\"\"\""}, {"source_code": "n,m = list(map(int,input().split()))\nS=0\nfor i in range(1,n+1):\n\t\tS+=((m-(5*(i//5)+5)+i)//5)+1\nprint(S)\t\t\n"}, {"source_code": "n,m=map(int,input().split())\nfirst=(m//10)*2*n\nsecond=(m%10)*2*(n//10)\nn=n%10\nm=m%10\nthird=0\nfor i in range(1,n+1):\n if(5-i>=1 and 5-i<=m):\n third+=1\n if(10-i>=1 and 10-i<=m):\n third+=1\n if(15-i>=1 and 15-i<=m):\n third+=1\nprint(first+second+third)\n"}, {"source_code": "from sys import stdin as fin\n# fin = open(\"cfr343b.in\", \"r\")\nn, m = map(int, fin.readline().split())\n\nresult = 0\n# print(m, n)\nfor i in range(1, n + 1):\n # print(i, (m - (5 - i % 5)) // 5 + 1)\n result += (m - (5 - i % 5)) // 5 + 1\n\nprint(result)\n"}, {"source_code": "def main():\n n, m = map(int, input().split())\n y = {}\n for i in range(1, 6):\n y[i] = max((m - i) // 5 + 1, 0)\n\n count = sum(y.values()) * (n // 5)\n rem = n % 5\n for i in range(1, rem + 1):\n count += y[5 - i]\n print(count)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\ndef fact(n):\n ans = 1\n for i in range(2, n+1):\n ans*= i\n return ans\ndef comb(n, c):\n return fact(n)//(fact(n-c)*c)\n\nn,m =map(int, input().split())\nn,m = min(n,m), max(n,m)\nd = {i:0 for i in range(5)}\nfor i in range(1, n+1):\n d[i%5]+=1\nans = 0\nfor i in range(1, m+1):\n ans+=d[(5-(i%5))%5]\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nans = 0\ncnt_n = [0] * 5\ncnt_m = [0] * 5\nfor i in range(1, n + 1):\n cnt_n[i % 5] += 1\nfor i in range(1, m + 1):\n cnt_m[i % 5] += 1\nans += cnt_n[0] * cnt_m[0]\nfor i in range(1, 5):\n ans += cnt_n[i] * cnt_m[4 - i + 1]\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nnn = n\nmm = m\nwhile nn % 5 != 0:\n nn += 1\nwhile mm % 5 != 0:\n mm += 1\nans = (nn * mm) // 5\nfor j in range(m+1, mm+1):\n ans -= nn//5\nfor i in range(n+1, nn + 1):\n ans -= mm//5\n for j in range(m + 1, mm + 1):\n if (i + j) % 5 == 0:\n ans += 1\nprint(ans)"}, {"source_code": "x, y = map(int, input().split())\ncount_x = [0] * 5\ncount_x[0] = x // 5\nfor i in range(1, 5):\n if x >= i:\n count_x[i] = (x - i) // 5 + 1\ncount_y = [0] * 5\ncount_y[0] = y // 5\nfor i in range(1, 5):\n if y >= i:\n count_y[i] = (y - i) // 5 + 1\nans = 0\nfor i in range(5):\n ans += count_x[i] * count_y[(5 - i) % 5]\nprint(ans)\n"}, {"source_code": "n,m=map(int,raw_input().split())\nx=[n/5]*5\nfor i in range(n%5):x[i+1]+=1\ny=[m/5]*5\nfor i in range(m%5):y[i+1]+=1\nprint x[0]*y[0]+x[1]*y[4]+x[2]*y[3]+x[3]*y[2]+x[4]*y[1]"}, {"source_code": "import math\nn,m=map(int,input().split())\nc=[0 for i in range(5)]\nfor i in range(5):\n a=math.ceil((m-i)/5)\n b=5-((m-i)%5)\n c[b-1]=a\nd=sum(c)*(n//5)\ne=n%5\nd+=sum(c[:e])\nprint(d)\n"}, {"source_code": "n, m = map(int, input().split())\ns = 0\nfor i in range(n):\n\tost = 5 - (i + 1) % 5\n\tif ost <= m:\n\t\ts = s + (m - ost) // 5 + 1\nprint(s)\n\t "}, {"source_code": "ct=0\na, b = map(int, input().split(' '))\nx=[0]*5\nfor i in range(1, b+1):\n x[i%5]+=1\nfor i in range(1, a+1):\n ct+=x[(0-i)%5]\nprint(ct)\n"}, {"source_code": "n,m=map(int,input().split())\nx=n//5\ny=m//5\na=[x for i in range(5)]\nb=[y for i in range(5)]\nx=n%5\ny=m%5\nfor i in range(x):\n\ta[i]+=1\nfor i in range(y):\n\tb[i]+=1\ns=0\nfor i in range(5):\n\tif i==4:\n\t\ts+=a[i]*b[i]\n\telse:\n\t\ts+=a[i]*b[3-i]\nprint(s)\n"}, {"source_code": "from sys import stdin\ninput = stdin.buffer.readline\n\ndef f(a, b):\n\treturn a // 5 + (b <= a % 5) - (b == 0)\n\nn, m = map(int, input().split())\nans = 0\nfor i in range(5):\n\tans += f(n, i) * f(m, (5 - i) % 5)\nprint(ans)"}, {"source_code": "import sys\n\nn , m = map(int,sys.stdin.readline().split())\nmod_res = [0]*5\nfor i in range(1,m+1) :\n mod_res[i%5] += 1\n\nans = 0\nfor i in range(1,n+1) :\n ans += mod_res[(5-(i%5))%5]\n\nprint ans\n"}, {"source_code": "class CodeforcesTask682ASolution:\n def __init__(self):\n self.result = ''\n self.n_m = []\n\n def read_input(self):\n self.n_m = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n pairs = 0\n sm = min(*self.n_m)\n bg = max(*self.n_m)\n for x in range((bg // 5) * 2 + 1):\n x += 1\n a = x * 5 - 1\n if a < 0:\n a = 0\n if a > bg:\n a = bg + sm - a\n if a < 0:\n a = 0\n # print(x, a, sm)\n pairs += min(a, sm)\n\n self.result = str(pairs)\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask682ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n\na=[0,0,0,0,0]\nb=[0,0,0,0,0]\n\nfor i in range(1,n+1):\n a[i%5]=a[i%5]+1\nfor j in range(1,m+1):\n b[j%5]=b[j%5]+1\n\nprint(a[0]*b[0] + a[1]*b[4] + a[2]*b[3] + b[2]*a[3] + a[4]*b[1])\n\n"}, {"source_code": "from sys import stdin\nn,m = map(int,stdin.readline().split())\na = []\nb = []\nfor i in xrange(5):\n a.append(n/5)\n b.append(m/5)\nfor i in xrange(1,n%5+1):\n a[i]+=1\nfor i in xrange(1,m%5+1):\n b[i]+=1\nans = a[0]*b[0]\n\nfor i in xrange(1,5):\n ans+= a[i] * b[5-i]\nprint ans"}], "negative_code": [{"source_code": "n, m = map(int, input().split())\nans = n // 5 * 5 * (m // 5)\nx = n // 5\ny = m // 5\nx1 = n % 5\ny1 = m % 5\nans += x1 * y + y1 * x\nfor i in range(1, x1 + 1):\n for j in range(1, y + 1):\n if (i + j) % 5 == 0:\n ans += 1\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nc=0\nx=max(n,m)\nmi=min(n,m)\nif x>=5 and mi>=5:\n ma=x-x%5\n x5=((ma-5)//5)+1\n x4=(((ma-4)-1)//5)+1\n x3=(((ma-3)-2)//5)+1\n x2=(((ma-2)-3)//5)+1\n x1=(((ma-1)-4)//5)+1\n if x%5==1:\n x4=x4+1\n elif x%5==2:\n x4=x4+1\n x3=x3+1\n elif x%5==3:\n x4=x4+1\n x3=x3+1\n x2=x2+1\n elif x%5==4:\n x4=x4+1\n x3=x3+1\n x2=x2+1\n x1=x1+1\n s=x1+x2+x3+x4+x5\n y=s*(mi//5)\n if mi%5==0:\n print(s*(mi//5))\n elif mi%5==1:\n print(y+x1)\n elif mi%5==2:\n print(y+x1+x2)\n elif mi%5==3:\n print(y+x1+x2+x3)\n elif mi%4==4:\n print(y+x1+x2+x3+x4)\nelse:\n for i in range(1,n+1):\n for j in range(1,m+1):\n if (i+j)%5==0:\n c+=1\n print(c)\n\n \n \n"}, {"source_code": "a=0\nt=0\nc,x=map(int,input().split())\na=x//5\n#print('a=',a)\nif x%5==0:\n print(a*c)\nelif a==0:\n print(int((c/5)*x)) \nelse:\n lst=list(range((a*5)+1,x+1))\n #print('lst=',lst) \n for z in lst:\n # print('z=',z)\n e=5-(z%5)\n # print('e=',e)\n while e<=c : \n t+=1\n e+=5\n# print('t=',t)\n# print('eeeeeee=',e)\n print((a*c)+t)"}, {"source_code": "from sys import stdin\n\ndef pairs():\n line = stdin.readline().split(' ')\n #test = input('enter ')\n #line = test.split(' ')\n count = 0\n k = int(int(line[1]) / 5 + 5)\n max = 0\n for x in range(1, int(line[0])+1):\n\n for i in range(k, 0, -1):\n if(x != 5):\n y = 5-(x % 5) + (i * 5)\n else:\n y = 5 + (i * 5)\n\n if(y > int(line[1])):\n continue\n\n if((x+y) % 5 == 0):\n max = i+1\n break\n\n count += max\n\n print(count)\n\npairs()\n\n\n##\n#if(x != 5):\n# y = 5-(x % 5) + (k * 5)\n#else:\n# y = 5 + (k * 5)\n\n#if(y > int(line[1])):\n# break\n\n#if((x+y) % 5 == 0):\n# count += 1\n ##"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n#a = y[2]\ns=0\n\n\nif((n//5*5)==(m//5*5)):\n s+=(n//5*5)+(m//5*5)\nelse:\n s+=max((n//5*5),(m//5*5))\n#print(\"s=\",s)\nfor i in range(1,n+1):\n for j in range(1+(m//5*5),m+1):\n if((i+j)%5==0): s+=1;\n\n\nfor i in range(1+(n//5*5),n+1):\n for j in range(1,m+1):\n if((i+j)%5==0): s+=1;\n \nprint(s)\n## \n \n \n\n\n\n\n\n\n\n'''\nfor i in range(1,int(n)+1):\n st=str(i)\n if((10-int(st[-1])) in range(1,int(m))): s+=1\n if((5-int(st[-1])) in range(1,int(m))): s+=1\n print(10-int(st[-1]),5-int(st[-1]),st[-1])\nprint(s)\n'''\n"}, {"source_code": "n,m = map(int, input().split())\nres = 0\nif n%10 != 0 and m%10 != 0: \n for i in range(1, n%10 + 1):\n for j in range(1, m%10 + 1):\n if (i + j)%5 == 0:\n res += 1\nprint((m // 10 * 2 * n) + (n // 10 * 2 * m%10) + res)"}, {"source_code": "n, m = map(int, input().split())\nans = n // 5 * 5 * (m // 5)\nx = n // 5\ny = m // 5\nx1 = n % 5\ny1 = m % 5\nans += x1 * y + y1 * x\nfor i in range(1, x1 + 1):\n for j in range(1, y + 1):\n if (i + j) % 5 == 0:\n ans += 1\nprint(ans)"}, {"source_code": "import math\n\nn,m = [int(x) for x in input().split(' ')]\npairs = 0\ns,t = (n,m) if n < m else (m,n)\nfor x in range(1,s+1):\n start = 1\n while ((x+start) % 5) != 0 and start <= m:\n start += 1\n if (x+start) % 5 == 0:\n pairs += 1\n else:\n break\n pairs += math.floor((m-start)/5)\n\nprint(pairs)\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n\ns=(n//5)*(m//5)*5\n\nfor i in range(1,n):\n for j in range((((m//5)*5)+1),m+1):\n #print(i,j,end=' - ')\n if((j+i)%5==0): s+=1;\n \n #print()\n \n#print(\"-------------\")\nfor j in range(1,m):\n for i in range((n//5*5)+1,n+1):\n #print(j,i,end=' * ')\n if((j+i)%5==0): s+=1;\n #print()\n\n\nif((n+m)%5==0 and (n%5!=0 or m%5!=0)): s+=1; \n \n\nprint(s)\n\n"}, {"source_code": "n, m = map(int, input().split())\nans = (n * m) // 5\nif (n * m) % 5 == 4 or (n * m) % 5 == 1:\n ans += 1\nprint(ans)\n"}, {"source_code": "import math\n\nn,m = [int(x) for x in input().split(' ')]\npairs = 0\ns,t = (n,m) if n < m else (m,n)\nfor x in range(1,s+1):\n start = 1\n while ((x+start) % 5) != 0:\n start += 1\n if start <= m:\n pairs += 1 + math.floor((m-start)/5)\n\nprint(pairs)\n"}, {"source_code": "n,m=map(int,input().split())\na=0\nif m%5==0:\n\ta+=(n*(m//5))\nelif m%5==1:\n\ta+=(n*(m//5)+1)\nelif m%5==2:\n\ta+=(n*(m//5)+2)\nelif m%5==3:\n\ta+=(n*(m//5)+3)\nelif m%5==4:\n\ta+=(n*(m//5)+4)\nprint(a)\n"}, {"source_code": "nm = list(map(int, input().split()))\nn = nm[0]\nm = nm[1]\nanswer = 0\ndic = {}\nfor i in range(1, m+1):\n\tif i%5 not in dic:\n\t\tdic[i%5] = 1\n\telse:\n\t\tdic[i%5] +=1\nprint(dic)\nfor i in range(1, n+1):\n\tx = (5 - (i%5))%5\n\t# print(x)\n\t# if x in dic:\n\tanswer+=dic[x]\nprint(answer)"}, {"source_code": "n,m = list(map(int, input().split()))\nmat,sat = [n//5] * 5,[m//5] * 5\nfor i in range(n%5):\n mat[i]+=1\nfor j in range(m%5):\n sat[j]+=1\nprint(sum([mat[i] * sat[5-i-1] for i in range(5)]))\n"}, {"source_code": "n,m=map(int,input().split())\nnarr=[(n//5),(n//5)+min(1,n-(n//5)*5),(n//5)+(min(2,n-(n//5)*5))//2,\n (n//5)+(min(3,n-(n//5)*5))//3,(n//5)+(min(4,n-(n//5)*5))//4 ]\nmarr=[(m//5),(m//5)+min(1,m-(m//5)*5),(m//5)+(min(2,m-(n//5)*5))//2,\n (m//5)+(min(3,m-(m//5)*5))//3,(m//5)+(min(4,m-(m//5)*5))//4 ]\ncount=0\nfor i in range(5):\n count+=narr[i]*marr[-i]\nprint(count)\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n\ns=(n//5)*(m//5)*5\n\nfor i in range(1,n):\n for j in range((((m//5)*5)+1),m+1):\n if((i > (n//5*5) and j ==m)): continue;\n #print(i,j,end=' - ')\n if((j+i)%5==0): s+=1;\n \n #print()\n \n#print(\"-------------\")\nfor j in range(1,m+1):\n for i in range((n//5*5)+1,n+1):\n #print(j,i,end=' * ')\n if((j+i)%5==0): s+=1;\n \n #print()\n\nprint(s)\n\n"}, {"source_code": "n, m = map(int, input().split())\nans = (n * m) // 5\nif (n * m) % 5 == 4:\n ans += 1\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nres = 0\nfor i in range(1, n+1):\n t1 = i//5\n while 1:\n if 5 * t1 >= i and t1 & 1 == 1:\n break\n t1 += 1\n t1 = 5*t1 - i\n t2 = int(str(i)[-1])\n if t1 == 0:\n t1 += 10\n if t2 != 0:\n t2 = 10 - t2\n else:\n t2 = 10\n\n if t1 <= m:\n res += 1\n if t2 <= m:\n res += 1\n \n t = m//10\n \n if 10*t + t1 <= m:\n res += t\n else:\n res += t-1\n \n if 10*t + t2 <= m:\n res += t\n else:\n res += t-1\n\nprint(res)"}, {"source_code": "n,m = map(int,raw_input().split(' '))\n\nk1=m / 5\nr1=m % 5\nk2=n / 5\nr2=n % 5\n\nprint n*k1 + r1*k2 + ((r1+r2)/4)*(r1+r2-4)\n"}, {"source_code": "n,m = map(int, input().split())\n\n\n\nprint(round(n/5*m))\n\n"}, {"source_code": "from sys import stdin\n\ndef pairs():\n line = stdin.readline().split(' ')\n #test = input('enter ')\n #line = test.split(' ')\n count = 0\n iteration = 0\n maxiter = int(100000/5)\n\n for x in range(1, int(line[0])+1):\n iteration = 0\n for y in range(1, maxiter):\n if(x < 5):\n y = (5-x % 5) + (iteration * 5)\n elif(x % 5 == 0):\n y = 5 + (iteration * 5)\n else:\n y = 5-(x % 5) + (iteration * 5)\n if(y > int(line[1])):\n break\n\n iteration += 1\n if((x+y) % 5 == 0):\n count += 1\n\n print(count)\n\npairs()\n"}, {"source_code": "n, m = map(int, raw_input().split())\n#import math\n\ncnt = n * m / 5.0\n\nif n + m < 5:\n print 0\nelse:\n #print cnt\n print int(round(cnt))"}, {"source_code": "n,m=map(int,input().split())\nc=0\nfor i in range(n):\n c=c+(m+(i%5))//5\nif(n%2==m%2):\n print(c)\nelse:\n print(c+1)"}, {"source_code": "class AlyonaAndNumbers:\n def solve(self,n,m):\n maxnum = max(n,m)\n minnum = min(n,m)\n currfive = (n+m)-((n+m)%5)\n if currfive==5: return minnum\n pairct=0\n while currfive>5:\n pairone=[]\n pairtwo=[]\n if maxnum>=currfive:\n pairone=[currfive-1,1]\n else:\n pairone=[maxnum,currfive-maxnum]\n\n if minnum >= currfive:\n pairtwo=[currfive-1,1]\n else:\n pairtwo = [minnum, currfive - minnum]\n pairct+=(pairone[0]-pairtwo[1])+1\n currfive-=5\n if maxnum>3 and minnum>3: pairct+=4\n else: pairct+=minnum\n return pairct\nif __name__ == \"__main__\":\n n,m = map(int,raw_input().split(\" \"))\n aan = AlyonaAndNumbers()\n print aan.solve(n,m)"}, {"source_code": "n,m = map(int, input().split())\n\n\n\nprint(round(n/5*m))\n\n"}, {"source_code": "a,b=map(int,input().split())\ncnt = a*b\ncnt = round(cnt/5)\nprint(cnt)\n\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom fractions import gcd\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (\n acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,\n sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn, m = invr()\nc = 0\nfor i in range(1, n+1):\n for j in range(1, n+1):\n if (i + j) % 5 == 0:\n c += 1\nprint(c)\n"}, {"source_code": "x,y = map(int, input().split())\nn = max(x, y)\nm = min(x,y)\nres = 0\nif n%10 != 0 and m%10 != 0: \n for i in range(1, n%10 + 1):\n for j in range(1, m%10 + 1):\n if (i + j)%5 == 0:\n res += 1\nprint((m // 10 * 2 * n) + (n // 10 * 2 * m%10) + res)"}, {"source_code": "#72\no,p=map(int,input().split())\nl=[]\nc=0\nx=min(o,p)\ny=max(o,p)\n\nfor i in range(5,x+y+1,5):\n l.append(i)\n \nfor a in l:\n if a> x and a <=y:\n c+=x\n\n elif a<= x and a<y:\n c+=a-1 \n \n elif a > x and a > y:\n c+=x-(a-y)+1\n\nprint(c)\n"}, {"source_code": "class AlyonaAndNumbers:\n def solve(self,n,m):\n maxnum = max(n,m)\n minnum = min(n,m)\n currfive = (n+m)-((n+m)%5)\n if currfive==5: return minnum\n pairct=0\n while currfive>5:\n pairone=[]\n pairtwo=[]\n if maxnum>currfive:\n pairone=[currfive-1,1]\n else:\n pairone=[maxnum,currfive-maxnum]\n\n if minnum > currfive:\n pairtwo=[currfive-1,1]\n else:\n pairtwo = [minnum, currfive - minnum]\n pairct+=(pairone[0]-pairtwo[1])+1\n currfive-=5\n if maxnum>3 and minnum>3: pairct+=4\n else: pairct+=minnum\n return pairct\nif __name__ == \"__main__\":\n n,m = map(int,raw_input().split(\" \"))\n aan = AlyonaAndNumbers()\n print aan.solve(n,m)"}, {"source_code": "n, m = map(int, input().split())\nres = 0\nfor i in range(1, n+1):\n t1 = i//5\n while 1:\n if 5 * t1 >= i and t1 & 1 == 1:\n break\n t1 += 1\n t1 = 5*t1 - i\n t2 = int(str(i)[-1])\n if t1 == 0:\n t1 += 10\n if t2 != 0:\n t2 = 10 - t2\n else:\n t2 = 10\n\n if t1 <= m:\n res += 1\n if t2 <= m:\n res += 1\n \n t = m//10\n \n if 10*t + t1 <= m:\n res += t\n else:\n res += t-1\n \n if 10*t + t2 <= m:\n res += t\n else:\n res += t-1\n\nprint(res)"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom fractions import gcd\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (\n acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,\n sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn, m = invr()\nc = 0\nfor i in range(1, n+1):\n for j in range(1, n+1):\n if (i + j) % 5 == 0:\n c += 1\nprint(c)\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n\ns=(n//5)*(m//5)*5\n\nfor i in range(1,n):\n for j in range((((m//5)*5)+1),m+1):\n if((i > (n//5*5) and j ==m)): continue;\n #print(i,j,end=' - ')\n if((j+i)%5==0): s+=1;\n \n #print()\n \n#print(\"-------------\")\nfor j in range(1,m+1):\n for i in range((n//5*5)+1,n+1):\n #print(j,i,end=' * ')\n if((j+i)%5==0): s+=1;\n \n #print()\n\nprint(s)\n\n"}, {"source_code": "N,M=raw_input().strip().split(' ')\na=[5,4,3,2,1]\nN,M=int(N),int(M)\nX,Y,sums=max(N,M),min(N,M),0\nfor i in xrange(1,Y+1):\n\tj=a[i%5]\n\tsums+=int((X-j)/5.0)+1\nprint sums"}, {"source_code": "import math\n\nn,m = [int(x) for x in input().split(' ')]\npairs = 0\ns,t = (n,m) if n < m else (m,n)\nfor x in range(1,s+1):\n start = 1\n while ((x+start) % 5) != 0:\n start += 1\n if start <= m:\n pairs += 1\n pairs += math.floor((m-start)/5)\n\nprint(pairs)\n"}, {"source_code": "class AlyonaAndNumbers:\n def solve(self,n,m):\n maxnum = max(n,m)\n minnum = min(n,m)\n currfive = (n+m)-((n+m)%5)\n if currfive==5: return minnum\n pairct=0\n while currfive>5:\n pairone=[]\n pairtwo=[]\n if maxnum>currfive:\n pairone=[currfive-1,1]\n else:\n pairone=[maxnum,currfive-maxnum]\n\n if minnum > currfive:\n pairtwo=[currfive-1,1]\n else:\n pairtwo = [minnum, currfive - minnum]\n pairct+=(pairone[0]-pairtwo[1])+1\n currfive-=5\n if maxnum>3 and minnum>3: pairct+=4\n else: pairct+=minnum\n return pairct\nif __name__ == \"__main__\":\n n,m = map(int,raw_input().split(\" \"))\n aan = AlyonaAndNumbers()\n print aan.solve(n,m)"}, {"source_code": "import math\n\nn,m = [int(x) for x in input().split(' ')]\npairs = 0\ns,t = (n,m) if n < m else (m,n)\nfor x in range(1,s+1):\n start = 1\n while ((x+start) % 5) != 0 and start <= m:\n start += 1\n if (x+start) % 5 == 0:\n pairs += 1\n else:\n break\n pairs += math.floor((m-start)/5)\n\nprint(pairs)\n"}, {"source_code": "n, m = tuple(input().split())\ncount = 0\n\nfor i in range(1, int(n)+1):\n\tfor j in range(1, int(m)+1):\n\t\tif (i+j)%5 == 0:\n\t\t\tbreak\n\tcount += (int(m)-j)//5 + 1\nprint(count)\n"}, {"source_code": "n, m = map(int, input().split())\nres = 0\nfor i in range(1, n+1):\n t1 = i//5\n while 1:\n if 5 * t1 >= i and t1 & 1 == 1:\n break\n t1 += 1\n t1 = 5*t1 - i\n t2 = int(str(i)[-1])\n if t1 == 0:\n t1 += 10\n if t2 != 0:\n t2 = 10 - t2\n else:\n t2 = 10\n\n if t1 <= m:\n res += 1\n if t2 <= m:\n res += 1\n \n t = m//10\n \n if 10*t + t1 <= m:\n res += t\n else:\n res += t-1\n \n if 10*t + t2 <= m:\n res += t\n else:\n res += t-1\n\nprint(res)"}, {"source_code": "from sys import stdin, stdout\n\ndef findDiv5():\n n, m = map(int, stdin.readline().rstrip().split())\n totalPoss = 0\n nmod = []*5\n mmod = []*5\n for i in range(1, n+1):\n calc = i%5\n nmod[calc]+=1\n for i in range(1, m+1):\n calc = i%5\n mmod[calc]+=1\n\n totalPoss = totalPoss + (nmod[0]*mmod[0])\n totalPoss = totalPoss + (nmod[1]*mmod[4])\n totalPoss = totalPoss + (nmod[2]*mmod[3])\n totalPoss = totalPoss + (nmod[3]*mmod[2])\n totalPoss = totalPoss + (nmod[4]*mmod[1])\n stdout.write(str(totalPoss))"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n\ns=(n//5)*(m//5)*5\n\nfor i in range(1,n):\n for j in range((((m//5)*5)+1),m+1):\n #print(i,j,end=' - ')\n if((j+i)%5==0): s+=1;\n \n #print()\n \n#print(\"-------------\")\nfor j in range(1,m):\n for i in range((n//5*5)+1,n+1):\n #print(j,i,end=' * ')\n if((j+i)%5==0): s+=1;\n #print()\n\n\nif((n+m)%5==0 and (n%5!=0 or m%5!=0)): s+=1; \n \n\nprint(s)\n\n"}, {"source_code": "n, m = map(int, input().split())\nmini = min(n, m)\ncount = 0\nfor i in range(1, mini + 1):\n count += (i + m) // 5 - (i // 5)\nprint(count)"}, {"source_code": "class AlyonaAndNumbers:\n def solve(self,n,m):\n maxnum = max(n,m)\n minnum = min(n,m)\n currfive = (n+m)-((n+m)%5)\n if currfive==5: return minnum\n pairct=0\n while currfive>5:\n pairone=[]\n pairtwo=[]\n if maxnum>currfive:\n pairone=[currfive-1,1]\n else:\n pairone=[maxnum,currfive-maxnum]\n\n if minnum > currfive:\n pairtwo=[currfive-1,1]\n else:\n pairtwo = [minnum, currfive - minnum]\n pairct+=(pairone[0]-pairtwo[1])+1\n currfive-=5\n if maxnum>3 and minnum>3: pairct+=4\n else: pairct+=minnum\n return pairct\nif __name__ == \"__main__\":\n n,m = map(int,raw_input().split(\" \"))\n aan = AlyonaAndNumbers()\n print aan.solve(n,m)"}, {"source_code": "x,y = map(int, input().split())\nn = max(x, y)\nm = min(x,y)\nres = 0\nif n%10 != 0 and m%10 != 0: \n for i in range(1, n%10 + 1):\n for j in range(1, m%10 + 1):\n if (i + j)%5 == 0:\n res += 1\nprint((m // 10 * 2 * n) + (n // 10 * 2 * m%10) + res)"}, {"source_code": "nm = list(map(int, input().split()))\nn = nm[0]\nm = nm[1]\nanswer = 0\ndic = {}\nfor i in range(1, m+1):\n\tif i%5 not in dic:\n\t\tdic[i%5] = 1\n\telse:\n\t\tdic[i%5] +=1\nprint(dic)\nfor i in range(1, n+1):\n\tx = (5 - (i%5))%5\n\t# print(x)\n\t# if x in dic:\n\tanswer+=dic[x]\nprint(answer)"}, {"source_code": "n,m = map(int, input().split())\nprint((1+m*n)//5)"}, {"source_code": "import math\n\nn,m = [int(x) for x in input().split(' ')]\npairs = 0\ns,t = (n,m) if n < m else (m,n)\nfor x in range(1,s+1):\n start = 1\n while ((x+start) % 5) != 0 and start <= m:\n start += 1\n if (x+start) % 5 == 0:\n pairs += 1\n else:\n break\n pairs += math.floor((m-start)/5)\n\nprint(pairs)\n"}, {"source_code": "var1, var2 =input(\"Enter two numbers here: \").split()\np=int(var1)\nq=int(var2)\na=int(p/5);\nb=p%5\nc=int(q/5);\nd=q%5;\nsum=0\nsum=p*c+a*d\nfor i in range(b):\n for j in range(d):\n if (i+j+2)%5==0:\n sum+=1\nprint(sum)\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n#a = y[2]\ns=0\n\n\nif((n//5*5)==(m//5*5)):\n s+=(n//5*5)+(m//5*5)\nelse:\n s+=max((n//5*5),(m//5*5))\n#print(\"s=\",s)\nfor i in range(1,(n//5*5)):\n for j in range(1+(m//5*5),m+1):\n if((i+j)%5==0):\n s+=1;\n #print(i,j)\n \n\nfor i in range(1+(n//5*5),n+1):\n for j in range(1,m+1):\n if((i+j)%5==0):\n #print(i,j)\n s+=1;\n \nprint(s)\n## \n \n \n\n\n\n\n\n\n\n'''\nfor i in range(1,int(n)+1):\n st=str(i)\n if((10-int(st[-1])) in range(1,int(m))): s+=1\n if((5-int(st[-1])) in range(1,int(m))): s+=1\n print(10-int(st[-1]),5-int(st[-1]),st[-1])\nprint(s)\n'''\n"}, {"source_code": "x,y = map(int, input().split())\nn = max(x, y)\nm = min(x,y)\nres = 0\nif n%10 != 0 and m%10 != 0: \n for i in range(1, n%10 + 1):\n for j in range(1, m%10 + 1):\n if (i + j)%5 == 0:\n res += 1\nprint((n // 10 * 2 * m) + (m // 10 * 2 * n%10) + res)"}, {"source_code": "n,m = map(int, input().split())\n\n\na = [0 for i in range(5)]\nb= [0 for i in range(5)]\n\n\nfor i in range(1, n+1):\n a[i%5]+=1\n \nfor i in range(1,m+1):\n b[i%5]+=1\n \n \nprint(a[0]*b[0] + a[1]*b[4] + a[2]*b[3] + a[3] * a[2] + a[4] * b[1])"}, {"source_code": "a=0\nt=0\nc,x=map(int,input().split())\na=x//5\n#print('a=',a)\nif x%5==0:\n print(a*c)\nelif a==0:\n print(int((c/5)*x)) \nelse:\n lst=list(range((a*5)+1,x+1))\n #print('lst=',lst) \n for z in lst:\n # print('z=',z)\n e=5-(z%5)\n # print('e=',e)\n while e<=c : \n t+=1\n e+=5\n# print('t=',t)\n# print('eeeeeee=',e)\n print((a*c)+t)"}, {"source_code": "#n = int(input())\nn, m = map(int, input().split())\n#s = input()\n#c = list(map(int, input().split()))\nprint((n // 5 + m // 5) * 2 + n // 10 + m // 10)"}, {"source_code": "def inp():\n return map(int, input().split())\n\n\nimport math as m\n\nx, y = inp()\nnum = (x * y) / 5\nif (num - int(num) >= .5):\n num = m.ceil(num)\nelse:\n num = m.floor(num)\nprint(num)\n\n"}, {"source_code": "var1, var2 =input(\"Enter two numbers here: \").split()\np=int(var1)\nq=int(var2)\na=int(p/5);\nb=p%5\nc=int(q/5);\nd=q%5;\nsum=0\nsum=p*c+a*d\nfor i in range(b):\n for j in range(d):\n if (i+j+2)%5==0:\n sum+=1\nprint(sum)\n"}, {"source_code": "n,m=map(int,input().split())\nc=0\nx=max(n,m)\nmi=min(n,m)\nif x>=5 and mi>=5:\n ma=x-x%5\n x5=((ma-5)//5)+1\n x4=(((ma-4)-1)//5)+1\n x3=(((ma-3)-2)//5)+1\n x2=(((ma-2)-3)//5)+1\n x1=(((ma-1)-4)//5)+1\n if x%5==1:\n x4=x4+1\n elif x%5==2:\n x4=x4+1\n x3=x3+1\n elif x%5==3:\n x4=x4+1\n x3=x3+1\n x2=x2+1\n elif x%5==4:\n x4=x4+1\n x3=x3+1\n x2=x2+1\n x1=x1+1\n s=x1+x2+x3+x4+x5\n y=s*(mi//5)\n if mi%5==0:\n print(s*(mi//5))\n elif mi%5==1:\n print(y+x1)\n elif mi%5==2:\n print(y+x1+x2)\n elif mi%5==3:\n print(y+x1+x2+x3)\n elif mi%4==4:\n print(y+x1+x2+x3+x4)\nelse:\n for i in range(1,n+1):\n for j in range(1,m+1):\n if (i+j)%5==0:\n c+=1\n print(c)\n\n \n \n"}, {"source_code": "n, m = map(int, input().split())\ncnt = 0\nN = 2 * 10 ** 5\nfor k in range(100):\n c = k * 5\n Max = min(m, c - 1)\n Min = max(1, c - n)\n cnt += max(Max - Min + 1, 0)\nprint(cnt)"}, {"source_code": "n, m = map(int, raw_input().split())\nn0, m0 = n / 5, m / 5\nn1, m1 = (n + 4) / 5, (m + 4) / 5\nn2, m2 = (n + 3) / 5, (m + 3) / 5\nn3, m3 = (n + 2) / 5, (m + 2) / 5\nn4, m4 = (n + 1) / 5, (m + 1) / 5\nprint n0*m0 + n1*m4 + n2*m4 + n3*m2 + n4*m1\n"}, {"source_code": "from sys import stdin, stdout\n\ndef findDiv5():\n n, m = map(int, stdin.readline().rstrip().split())\n totalPoss = 0\n nmod = []*5\n mmod = []*5\n for i in range(1, n+1):\n calc = i%5\n nmod[calc]+=1\n for i in range(1, m+1):\n calc = i%5\n mmod[calc]+=1\n\n totalPoss = totalPoss + (nmod[0]*mmod[0])\n totalPoss = totalPoss + (nmod[1]*mmod[4])\n totalPoss = totalPoss + (nmod[2]*mmod[3])\n totalPoss = totalPoss + (nmod[3]*mmod[2])\n totalPoss = totalPoss + (nmod[4]*mmod[1])\n stdout.write(str(totalPoss))"}, {"source_code": "from sys import stdin, stdout\n\ndef findDiv5():\n n, m = map(int, stdin.readline().rstrip().split())\n totalPoss = 0\n nmod = []*5\n mmod = []*5\n for i in range(1, n+1):\n calc = i%5\n nmod[calc]+=1\n for i in range(1, m+1):\n calc = i%5\n mmod[calc]+=1\n\n totalPoss = totalPoss + (nmod[0]*mmod[0])\n totalPoss = totalPoss + (nmod[1]*mmod[4])\n totalPoss = totalPoss + (nmod[2]*mmod[3])\n totalPoss = totalPoss + (nmod[3]*mmod[2])\n totalPoss = totalPoss + (nmod[4]*mmod[1])\n stdout.write(str(totalPoss))"}, {"source_code": "nm = list(map(int, input().split()))\nn = nm[0]\nm = nm[1]\nanswer = 0\ndic = {}\nfor i in range(1, m+1):\n\tif i%5 not in dic:\n\t\tdic[i%5] = 1\n\telse:\n\t\tdic[i%5] +=1\nprint(dic)\nfor i in range(1, n+1):\n\tx = (5 - (i%5))%5\n\t# print(x)\n\t# if x in dic:\n\tanswer+=dic[x]\nprint(answer)"}, {"source_code": "n,m=map(int,raw_input().split())\ncount=0\nr=[]\nif n<5:\n\tfor i in xrange(1,n+1):\n\t\tcount+=(i+m)/5\nelse:\n\tfor i in xrange(1,5):\n\t\tc=(i+m)/5\n\t\tr.append(c)\n\tr.append((i+m)/5-1)\n\tcount+=n/5*sum(r)\n\tfor j in xrange(0,n%5):\n\t\tcount+=r[j]\nprint count\n"}, {"source_code": "n,m = list(map(int,input().split()))\nS=0\nfor i in range(1,n+1):\n\tfor j in range((5*(i//5)+5)-i,n+1,5):\n\t\t\tS+=1\nprint(S)\t\t"}, {"source_code": "if __name__ == '__main__':\n x, y = str(input()).split()\n x = int(x)\n y = int(y)\n line_x = [x//5] * 5\n for i in range(x % 5):\n line_x[i] += 1\n line_y = [y//5] * 5\n for i in range(y % 5):\n line_y[i+1] += 1\n print(sum([\n line_x[0]*line_y[0],\n line_x[1]*line_y[4],\n line_x[2]*line_y[3],\n line_x[3]*line_y[2],\n line_x[4]*line_y[1]\n ]))\n"}, {"source_code": "n,m=map(int,input().split(' '))\na=n//5\nb=m//5\nc=n%5\nd=m%5\nif c==3:\n if d==2:\n x=1\n if d==3:\n x=2\n if d==4:\n x=3\nx=max(c+d-4,0)\nprint(a,b,c,d,x)\nprint(a*b*5+c*b+d*a+x)\n"}, {"source_code": "n,m = map(int,input().split())\nmaxi = max(n,m)\nmini = min(n,m)\nmycnt = (mini // 5) * 5 * (maxi //5)\nif mycnt == 0 :\n if mini >= 5 or maxi >= 5 :\n mycnt +=1\nmycnt += (mini % 5) * (maxi//5) \nmycnt += (maxi % 5) * (mini//5) \nfor i in range(1,maxi%5 + 1): \n if (mini + i) % 5 == 0 :\n # print(mini,\"-----\",i)\n mycnt +=1\n\n# for i in range(1,mini%5 + 1): \n# if (maxi + i) % 5 == 0 :\n# print(maxi,\"-----\",i)\n\n# mycnt +=1\n\n# cnt = 0\n# for i in range(1,n+1):\n# for j in range(1,m+1):\n# if (i+j) % 5 == 0 :\n# cnt +=1\n\nprint(mycnt)"}, {"source_code": "n,m=map(int,input().split())\nc=0\nx=max(n,m)\nmi=min(n,m)\nif x>=5 and mi>=5:\n ma=x-x%5\n x5=((ma-5)//5)+1\n x4=(((ma-4)-1)//5)+1\n x3=(((ma-3)-2)//5)+1\n x2=(((ma-2)-3)//5)+1\n x1=(((ma-1)-4)//5)+1\n if x%5==1:\n x4=x4+1\n elif x%5==2:\n x4=x4+1\n x3=x3+1\n elif x%5==3:\n x4=x4+1\n x3=x3+1\n x2=x2+1\n elif x%5==4:\n x4=x4+1\n x3=x3+1\n x2=x2+1\n x1=x1+1\n s=x1+x2+x3+x4+x5\n y=s*(mi//5)\n if mi%5==0:\n print(s*(mi//5))\n elif mi%5==1:\n print(y+x1)\n elif mi%5==2:\n print(y+x1+x2)\n elif mi%5==3:\n print(y+x1+x2+x3)\n elif mi%4==4:\n print(y+x1+x2+x3+x4)\nelse:\n for i in range(1,n+1):\n for j in range(1,m+1):\n if (i+j)%5==0:\n c+=1\n print(c)\n\n \n \n"}, {"source_code": "n,m = map(int,raw_input().split())\nanswer=0\nfor x in xrange(n+1):\n answer += (x+m)//5 - x//5\nprint answer"}, {"source_code": "#72\no,p=map(int,input().split())\nl=[]\nc=0\nx=min(o,p)\ny=max(o,p)\n\nfor i in range(5,x+y+1,5):\n l.append(i)\n \nfor a in l:\n if a> x and a <=y:\n c+=x\n\n elif a<= x and a<y:\n c+=a-1 \n \n elif a > x and a > y:\n c+=x-(a-y)+1\n\nprint(c)\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n#a = y[2]\ns=0\n\n\nif((n//5*5)==(m//5*5)):\n s+=(n//5*5)+(m//5*5)\nelif(n<=5 or m<=5 or (m//5*5)==1 or (m//5*5)==1):\n pass\nelse:\n s+=max((n//5*5),(m//5*5))\n#print(\"s=\",s)\nfor i in range(1,(n//5*5)):\n for j in range(1+(m//5*5),m+1):\n if((i+j)%5==0):\n s+=1;\n #print(i,j)\n \n\nfor i in range(1+(n//5*5),n+1):\n for j in range(1,m+1):\n if((i+j)%5==0):\n #print(i,j)\n s+=1;\n \nprint(s)\n## \n \n \n\n\n\n\n\n\n\n'''\nfor i in range(1,int(n)+1):\n st=str(i)\n if((10-int(st[-1])) in range(1,int(m))): s+=1\n if((5-int(st[-1])) in range(1,int(m))): s+=1\n print(10-int(st[-1]),5-int(st[-1]),st[-1])\nprint(s)\n'''\n"}, {"source_code": "n, m = map(int, input().split())\nres = 0\nfor i in range(1, n+1):\n t1 = i//5\n while 1:\n if 5 * t1 >= i and t1 & 1 == 1:\n break\n t1 += 1\n t1 = 5*t1 - i\n t2 = int(str(i)[-1])\n if t1 == 0:\n t1 += 10\n if t2 != 0:\n t2 = 10 - t2\n else:\n t2 = 10\n\n if t1 <= m:\n res += 1\n if t2 <= m:\n res += 1\n \n t = m//10\n \n if 10*t + t1 <= m:\n res += t\n else:\n res += t-1\n \n if 10*t + t2 <= m:\n res += t\n else:\n res += t-1\n\nprint(res)"}, {"source_code": "from sys import stdin, stdout\n\ndef findDiv5():\n n, m = map(int, stdin.readline().rstrip().split())\n totalPoss = 0\n nmod = []*5\n mmod = []*5\n for i in range(1, n+1):\n calc = i%5\n nmod[calc]+=1\n for i in range(1, m+1):\n calc = i%5\n mmod[calc]+=1\n\n totalPoss = totalPoss + (nmod[0]*mmod[0])\n totalPoss = totalPoss + (nmod[1]*mmod[4])\n totalPoss = totalPoss + (nmod[2]*mmod[3])\n totalPoss = totalPoss + (nmod[3]*mmod[2])\n totalPoss = totalPoss + (nmod[4]*mmod[1])\n stdout.write(str(totalPoss))"}, {"source_code": "n, m = map(int, raw_input().split())\nn0, m0 = n / 5, m / 5\nn1, m1 = (n + 4) / 5, (m + 4) / 5\nn2, m2 = (n + 3) / 5, (m + 3) / 5\nn3, m3 = (n + 2) / 5, (m + 2) / 5\nn4, m4 = (n + 1) / 5, (m + 1) / 5\nprint n0*m0 + n1*m4 + n2*m4 + n3*m2 + n4*m1\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n#a = y[2]\ns=0\n\n\nif((n//5*5)==(m//5*5)):\n s+=(n//5*5)+(m//5*5)\nelif(n<=5 or m<=5 or (m//5*5)==1 or (m//5*5)==1):\n pass\nelse:\n s+=max((n//5*5),(m//5*5))\n#print(\"s=\",s)\nfor i in range(1,(n//5*5)):\n for j in range(1+(m//5*5),m+1):\n if((i+j)%5==0):\n s+=1;\n #print(i,j)\n \n\nfor i in range(1+(n//5*5),n+1):\n for j in range(1,m+1):\n if((i+j)%5==0):\n #print(i,j)\n s+=1;\n \nprint(s)\n## \n \n \n\n\n\n\n\n\n\n'''\nfor i in range(1,int(n)+1):\n st=str(i)\n if((10-int(st[-1])) in range(1,int(m))): s+=1\n if((5-int(st[-1])) in range(1,int(m))): s+=1\n print(10-int(st[-1]),5-int(st[-1]),st[-1])\nprint(s)\n'''\n"}, {"source_code": "x,y = map(int, input().split())\nn = max(x, y)\nm = min(x,y)\nres = 0\nif n%10 != 0 and m%10 != 0: \n for i in range(1, n%10 + 1):\n for j in range(1, m%10 + 1):\n if (i + j)%5 == 0:\n res += 1\nprint((m // 10 * 2 * n) + (n // 10 * 2 * m%10) + res)"}, {"source_code": "x,y=map(int,input().split())\nprint(round((x*y)/5))\n"}, {"source_code": "a,b=map(int,input().split())\ncnt = a*b\ncnt = round(cnt/5)\nprint(cnt)\n\n"}, {"source_code": "n, m = map(int, raw_input().split())\nprint [[((n+4-i)/5), ((m+(i+1)%5)/5)] for i in xrange(5)]\nprint sum([((n+4-i)/5)*((m+(i+1)%5)/5) for i in xrange(5)])\n\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n#a = y[2]\ns=0\n\nif(n<=5 or m<=5 or (m//5*5)==1 or (n//5*5)==1):\n s+=max((n//5*5),(m//5*5))\nelif((n//5*5)==(m//5*5)):\n s+=(n//5*5)+(m//5*5)\nelse:\n s+=max((n//5*5),(m//5*5))\n#print(\"s=\",s)\nfor i in range(1,(n//5*5)):\n for j in range(1+(m//5*5),m+1):\n if((i+j)%5==0):\n s+=1;\n #print(i,j)\n \n\nfor i in range(1+(n//5*5),n+1):\n for j in range(1,m+1):\n if((i+j)%5==0):\n #print(i,j)\n s+=1;\n \nprint(s)\n## \n \n \n\n\n\n\n\n\n\n'''\nfor i in range(1,int(n)+1):\n st=str(i)\n if((10-int(st[-1])) in range(1,int(m))): s+=1\n if((5-int(st[-1])) in range(1,int(m))): s+=1\n print(10-int(st[-1]),5-int(st[-1]),st[-1])\nprint(s)\n'''\n"}, {"source_code": "import math\n\nn,m = [int(x) for x in input().split(' ')]\npairs = 0\ns,t = (n,m) if n < m else (m,n)\nfor x in range(1,s+1):\n start = 1\n while ((x+start) % 5) != 0 and start <= m:\n start += 1\n if (x+start) % 5 == 0:\n pairs += 1\n else:\n break\n pairs += math.floor((m-start)/5)\n\nprint(pairs)\n"}, {"source_code": "def solve():\n n, m = map(int, input().split())\n nn, mm, res = [0] * 5, [0] * 5, 0\n for i in range(1, n+1):\n nn[i % 5] += 1\n for i in range(1, m+1):\n mm[i % 5] += 1\n for i in range(5):\n res+= nn[i] * mm[i]\n print(res)\nsolve()\n\n"}, {"source_code": "A, B = raw_input().split(' ')\nA, B = int(A), int(B)\n\nArr1 = [0] * 5\nArr2 = [0] * 5\nfor i in xrange(5):\n Arr1[i] = (A + 4 - i) / 5\n Arr2[i] = (B + 4 - i) / 5\n\nRet = 0\nfor i in xrange(4):\n Ret += Arr1[i] * Arr2[3-i]\nRet += Arr1[4] * Arr1[4]\n\nprint Ret\n"}, {"source_code": "n, m = map(int, input().split())\ncnt = 0\nN = 2 * 10 ** 5\nfor k in range(100):\n c = k * 5\n Max = min(m, c - 1)\n Min = max(1, c - n)\n cnt += max(Max - Min + 1, 0)\nprint(cnt)"}, {"source_code": "n,m=map(int,input().split())\na=0\nif m%5==0:\n\ta+=(n*(m//5))\nelif m%5==1:\n\ta+=(n*(m//5)+1)\nelif m%5==2:\n\ta+=(n*(m//5)+2)\nelif m%5==3:\n\ta+=(n*(m//5)+3)\nelif m%5==4:\n\ta+=(n*(m//5)+4)\nprint(a)\n"}, {"source_code": "\nn,m=map(int,input().split())\n\ncnt=0\n\n\nfor i in range(1,n+1):\n\n for j in range(1,m):\n\n a=5*j-i\n if a<=0:\n continue\n \n \n if a>m:\n break\n\n else:\n cnt+=1\n \n \n \n \n \n\n\n\nprint(cnt)\n \n \n\n"}, {"source_code": "#72\no,p=map(int,input().split())\nl=[]\nc=0\nx=min(o,p)\ny=max(o,p)\n\nfor i in range(5,x+y+1,5):\n l.append(i)\n \nfor a in l:\n if a> x and a <=y:\n c+=x\n\n elif a<= x and a<y:\n c+=a-1 \n \n elif a > x and a > y:\n c+=x-(a-y)+1\n\nprint(c)\n"}, {"source_code": "n, m = map(int, input().split())\nans = (n * m) // 5\nif (n * m) % 5 == 4:\n ans += 1\nprint(ans)\n"}, {"source_code": "n,m = map(int, input().split())\nres = 0\nif n%10 != 0 and m%10 != 0: \n for i in range(1, n%10 + 1):\n for j in range(1, m%10 + 1):\n if (i + j)%5 == 0:\n res += 1\nprint((m // 10 * 2 * n) + (n // 10 * 2 * m%10) + res)"}, {"source_code": "a = [int(i) for i in raw_input().split()]\nn = a[0]\nm = a[1]\nc=0\nfor i in range(1, m+1):\n o = 5-(i%5)\n if n-o>0:\n c+=int((n-o)/5)+1\n\nprint c\n"}, {"source_code": "A, B = raw_input().split(' ')\nA, B = int(A), int(B)\n\nArr1 = [0] * 5\nArr2 = [0] * 5\nfor i in xrange(5):\n Arr1[i] = (A + 4 - i) / 5\n Arr2[i] = (B + 4 - i) / 5\n\nRet = 0\nfor i in xrange(4):\n Ret += Arr1[i] * Arr2[3-i]\nRet += Arr1[4] * Arr1[4]\n\nprint Ret\n"}, {"source_code": "x,y = map(int, input().split())\nn = max(x, y)\nm = min(x,y)\nres = 0\nif n%10 != 0 and m%10 != 0: \n for i in range(1, n%10 + 1):\n for j in range(1, m%10 + 1):\n if (i + j)%5 == 0:\n res += 1\nprint((m // 10 * 2 * n) + (n // 10 * 2 * m%10) + res)"}, {"source_code": "[n, m] = map(int, input().split())\nlist1 = []\nfor i in range(2, n + m + 1, 1):\n if (i % 5) == 0:\n list1.append(i)\nflag = 0\nfor j in list1:\n flag += min(m, n, j) - 1\nprint(flag)\n"}, {"source_code": "n,m = map(int, input().split())\n\n\na = [0 for i in range(5)]\nb= [0 for i in range(5)]\n\n\nfor i in range(1, n+1):\n a[i%5]+=1\n \nfor i in range(1,m+1):\n b[i%5]+=1\n \n \nprint(a[0]*b[0] + a[1]*b[4] + a[2]*b[3] + a[3] * a[2] + a[4] * b[1])"}, {"source_code": "def solve():\n n, m = map(int, input().split())\n nn, mm, res = [0] * 5, [0] * 5, 0\n for i in range(1, n+1):\n nn[i % 5] += 1\n for i in range(1, m+1):\n mm[i % 5] += 1\n for i in range(5):\n res+= nn[i] * mm[i]\n print(res)\nsolve()\n\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n#a = y[2]\ns=0\n\n\nif((n//5*5)==(m//5*5)):\n s+=(n//5*5)+(m//5*5)\nif(n<5 or m<5):\n pass\nelse:\n s+=max((n//5*5),(m//5*5))\n#print(\"s=\",s)\nfor i in range(1,(n//5*5)):\n for j in range(1+(m//5*5),m+1):\n if((i+j)%5==0):\n s+=1;\n #print(i,j)\n \n\nfor i in range(1+(n//5*5),n+1):\n for j in range(1,m+1):\n if((i+j)%5==0):\n #print(i,j)\n s+=1;\n \nprint(s)\n## \n \n \n\n\n\n\n\n\n\n'''\nfor i in range(1,int(n)+1):\n st=str(i)\n if((10-int(st[-1])) in range(1,int(m))): s+=1\n if((5-int(st[-1])) in range(1,int(m))): s+=1\n print(10-int(st[-1]),5-int(st[-1]),st[-1])\nprint(s)\n'''\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n\ns=(n//5)*(m//5)*5\n\nfor i in range(1,n):\n for j in range((((m//5)*5)+1),m+1):\n if((i > (n//5*5) and j ==m)): continue;\n #print(i,j,end=' - ')\n if((j+i)%5==0): s+=1;\n \n #print()\n \n#print(\"-------------\")\nfor j in range(1,m+1):\n for i in range((n//5*5)+1,n+1):\n #print(j,i,end=' * ')\n if((j+i)%5==0): s+=1;\n \n #print()\n\nprint(s)\n\n"}, {"source_code": "import math\n\ny = [int(i) for i in input().split()]\nn = y[0]\nm = y[1]\n#a = y[2]\ns=0\n\n\nif((n//5*5)==(m//5*5)):\n s+=(n//5*5)+(m//5*5)\nelse:\n s+=max((n//5*5),(m//5*5))\n#print(\"s=\",s)\nfor i in range(1,(n//5*5)):\n for j in range(1+(m//5*5),m+1):\n if((i+j)%5==0):\n s+=1;\n #print(i,j)\n \n\nfor i in range(1+(n//5*5),n+1):\n for j in range(1,m+1):\n if((i+j)%5==0):\n #print(i,j)\n s+=1;\n \nprint(s)\n## \n \n \n\n\n\n\n\n\n\n'''\nfor i in range(1,int(n)+1):\n st=str(i)\n if((10-int(st[-1])) in range(1,int(m))): s+=1\n if((5-int(st[-1])) in range(1,int(m))): s+=1\n print(10-int(st[-1]),5-int(st[-1]),st[-1])\nprint(s)\n'''\n"}, {"source_code": "x,y=map(int,input().split())\nprint(round((x*y)/5))\n"}, {"source_code": "#n = int(input())\nn, m = map(int, input().split())\n#s = input()\n#c = list(map(int, input().split()))\nprint((n // 5 + m // 5) * 4 + (n // 10 + m // 10) * 2)"}, {"source_code": "n, m = tuple(input().split())\ncount = 0\n\nfor i in range(1, int(n)+1):\n\tfor j in range(1, int(m)+1):\n\t\tif (i+j)%5 == 0:\n\t\t\tbreak\n\tcount += (int(m)-j)//5 + 1\nprint(count)\n"}], "src_uid": "df0879635b59e141c839d9599abd77d2"} {"source_code": "import math\na_1,a_2,b_1,b_2,c_1,c_2 = map(int,input().split())\ndist_1 = (a_1-b_1)**2 + (a_2-b_2)**2\ndist_2 = (a_1-c_1)**2 + (a_2-c_2)**2\ndist_3 = (b_1-c_1)**2 + (b_2 - c_2)**2\ndef checkTriangle(x1, y1, x2, y2, x3, y3): \n \n # Calculation the area of \n # triangle. We have skipped \n # multiplication with 0.5 \n # to avoid floating point \n # computations \n a = (x1 * (y2 - y3) +\n x2 * (y3 - y1) + \n x3 * (y1 - y2)) \n if a == 0:\n return True\n else:\n return False\ndef type(sqa,sqb,sqc): \n \n if (sqa == sqa + sqb or\n sqb == sqa + sqc or\n sqc == sqa + sqb): \n return True \n \n elif(sqa > sqc + sqb or\n sqb > sqa + sqc or\n sqc > sqa + sqb):\n return True \n \n \n else: \n return False\n \n\n\nif checkTriangle(a_1,a_2,b_1,b_2,c_1,c_2)== True:\n print(\"No\")\nelif dist_1 == dist_3:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "positive_code": [{"source_code": "a = list(map(int,input().split()))\nif (a[0]-a[2])**2+(a[1]-a[3])**2==(a[4]-a[2])**2+(a[5]-a[3])**2 and ((a[0]+a[4])/2!=a[2] or (a[1]+a[5])/2!=a[3]):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "x1,y1,x2,y2,x3,y3=[int(x) for x in input().split()]\nif((x1-x2)*(y1-y3)-(x1-x3)*(y1-y2)==0):\n print(\"No\")\n exit()\na=(x2-x1)**2 + (y2-y1)**2\nb=(x2-x3)**2 + (y2-y3)**2\n#print(a,\"\\n\",b)\nif a == b:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "import math\nx1,y1,x2,y2,x3,y3=map(int,raw_input().split())\ndef fun():\n x=0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))\n if x==0:\n return False\n return True\ndef fun1(x1,y1,x2,y2):\n return ((x1-x2)**2+(y1-y2)**2)\nif fun1(x1,y1,x2,y2)==fun1(x3,y3,x2,y2)and fun():\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "ax,ay,bx,by,cx,cy = map(int,raw_input().strip().split())\n\na_b = (bx-ax)**2 + (by-ay)**2\nb_c = (cx-bx)**2 + (cy-by)**2\nc_a = (ax-cx)**2 * (ay-cy)**2\n\n\nif a_b==b_c:\n if (by-ay)*(cx-ax)!=(cy-ay)*(bx-ax):\n print \"Yes\"\n else:\n print \"No\"\nelse:\n print \"No\"\n"}, {"source_code": "def solve():\n\tx1,y1,x2,y2,x3,y3 = map(int,input().split());\n\ta = [x1,y1];\n\tb = [x2,y2];\n\tc = [x3,y3];\n\tif(x1-x2>=0):\n\t\tangular1 = (y1-y2)/((x1-x2)+0.000001);\n\telif(x1-x2<0):\n\t\tangular1 = (y1-y2)/((x1-x2)-0.000001);\n\tif(x2-x3>=0):\n\t\tangular2 = (y2-y3)/((x2-x3)+0.000001);\n\telif(x2-x3<0):\n\t\tangular2 = (y2-y3)/((x2-x3)-0.000001);\n\t#print(angular1,angular2);\n\tres = False;\n\talinhado = False;\n\tif angular1==angular2:\n\t\talinhado = True;\n\tdAB = (a[0]-b[0])**2 + (a[1]-b[1])**2\n\tdAC = (a[0]-c[0])**2 + (a[1]-c[1])**2\n\tdBC = (c[0]-b[0])**2 + (c[1]-b[1])**2\n\tif(dAB==dBC):\n\t\tres = True;\n\tif(res and not alinhado):\n\t\tprint(\"Yes\")\n\telse:\n\t\tprint(\"No\")\nsolve()"}, {"source_code": "l = map(int, raw_input().split())\n\na1, a2, b1,b2,c1,c2 = l\nans = ((b2-a2)*(b2-a2) + (b1-a1)*(b1-a1)) == ((b2-c2)*(b2-c2) + (b1-c1)*(b1-c1))\nans2 = (b2-a2) * (c1-b1) == (c2-b2)* (b1-a1) \nif ans and not ans2:\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "import math\ndef slope(i,j):\n try:\n return float(j[1]-i[1])/float(j[0]-i[0])\n except:\n return -200\ndef len(i,j):\n return (j[1]-i[1])**2 +(i[0]-j[0])**2\nax,ay,bx,by,cx,cy=map(int,raw_input().split())\na=(ax,ay)\nb=(bx,by)\nc=(cx,cy)\nif slope(a,b)==slope(b,c):\n print 'No'\nelse:\n x=len(a,b)\n y=len(b,c)\n z=len(c,a)\n \n\n\n\n if x==y:\n print 'Yes'\n else:\n print 'No'\n"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\nif (ax-bx)**2+(ay-by)**2==(cx-bx)**2+(cy-by)**2 and ((ax+cx)/2!=bx or (ay+cy)/2!=by):print(\"Yes\")\nelse:print(\"No\")"}, {"source_code": "a1,a2,b1,b2,c1,c2=map(int,input().split())\nif (b1-a1)*(c2-a2)-(c1-a1)*(b2-a2)==0:\n print('No')\nelif ((a1-b1)**2+(a2-b2)**2)==((b1-c1)**2+(b2-c2)**2):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "a,b,x,y,u,v=map(int,raw_input().split())\nu-=x\nv-=y\nx-=a\ny-=b\nprint ('No','Yes')[(u-x or v-y) and u*u+v*v==x*x+y*y]"}, {"source_code": "x1,y1,x2,y2,x3,y3 = map(int,input().split())\n\nif(abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))>0):\n if(((x2-x1)**2+(y2-y1)**2) == ((x3-x2)**2+(y3-y2)**2)):\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")"}, {"source_code": "ax,ay,bx,by,cx,cy=list(map(int,input().split()))\nax-=bx\nay-=by\ncx-=bx\ncy-=by\nprint('No'if ax*cy-ay*cx==0 or ax**2+ay**2!=cx**2+cy**2 else'Yes')\n"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\nif (ax-bx)**2+(ay-by)**2==(bx-cx)**2+(by-cy)**2 and (by-ay)*(cx-bx)!=(cy-by)*(bx-ax):\n print (\"Yes\")\nelse:\n print (\"No\")"}, {"source_code": "xa, ya, xb, yb, xc, yc = [int(x) * 2 for x in input().split()]\n\nxm, ym = (xa + xc) // 2, (ya + yc) // 2\ndot = (xb - xm) * (xc - xa) + (yb - ym) * (yc - ya)\nif dot == 0 and (xm != xb or ym != yb):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "xa, ya, xb, yb, xc, yc = [int(x) * 2 for x in input().split()]\n\nxm, ym = (xa + xc) // 2, (ya + yc) // 2\nk = (xb - xm) * (xc - xa) + (yb - ym) * (yc - ya)\nif k == 0 and (xm != xb or ym != yb):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "import sys\nimport math\nimport itertools\nimport collections\n\n\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef wr(arr): return ' '.join(map(str, arr))\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n newnumber = 0\n while number > 0:\n newnumber += number % base\n number //= base\n return newnumber\ndef cdiv(n, k): return n // k + (n % k != 0)\n\n\nc = li()\nv1 = [c[2] - c[0], c[3] - c[1]]\nv2 = [c[4] - c[2], c[5] - c[3]]\nsqlenv1 = v1[0] ** 2 + v1[1] ** 2\nsqlenv2 = v2[0] ** 2 + v2[1] ** 2\nif abs(sqlenv1 - sqlenv2) < 10 ** -6 and (v1[0] * v2[0] + v1[1] * v2[1]) ** 2 < (sqlenv1 * sqlenv2):\n print('Yes')\nelse:\n print('No')\n\n"}, {"source_code": "import sys\nimport math\n\nlines = sys.stdin.read().splitlines()\nax, ay, bx, by, cx, cy = [int(x) for x in lines[0].split()]\ndef dist(p1x, p1y, p2x, p2y):\n return (p1x-p2x)**2+(p1y-p2y)**2 \ndist1 = dist(ax, ay, bx, by)\ndist2 = dist(bx, by, cx, cy)\nif dist1 == dist2 and not ((ax-bx == bx-cx) and (ay-by == by-cy)) :\n print('Yes')\nelse:\n print('No')"}, {"source_code": "from math import sqrt\n\nax,ay,bx,by,cx,cy = [int(i) for i in input().split()]\nif (ax-bx)**2+(ay-by)**2 != (bx-cx)**2+(by-cy)**2:\n print(\"No\")\nelif abs((ax-bx)*(bx-cx)+((ay-by)*(by-cy)))**2== ((ax-bx)**2+(ay-by)**2)* ((bx-cx)**2+(by-cy)**2):\n print(\"No\")\nelse:\n print(\"Yes\")"}, {"source_code": "import sys\ndelta = 10**(-14)\nclass Point:\n def __init__(self, x=None, y=None):\n self.x = x\n self.y = y\n\nclass Line:\n def __init__(self):\n self.isvertical = None\n self.x = None\n self.k = None\n self.b = None\n\nax, ay, bx, by, cx, cy = map(int, input().split())\na = Point(ax, ay)\nb = Point(bx, by)\nc = Point(cx, cy)\n\ndef line2points(p1, p2):\n result = Line()\n if(p1.x == p2.x):\n result.isvertical = True\n result.x = p1.x\n return result\n result.k = (p2.y - p1.y)/(p2.x - p1.x)\n result.b = p1.y - ((p1.x * (p2.y - p1.y))/(p2.x - p1.x))\n result.isvertical = False\n return result\n\ndef intersection(l1, l2):\n result = Point()\n if(l1.isvertical and l2.isvertical):\n return result\n if(l1.k == l2.k):\n return result\n if(l1.isvertical):\n result.x = l1.x\n result.y = l2.k * result.x + l2.b\n return result\n if(l2.isvertical):\n result.x = l2.x\n result.y = l1.k * result.x + l1.b\n return result\n result.x = (l2.b - l1.b)/(l1.k - l2.k)\n result.y = l1.k * result.x + l1.b\n return result\n\ndef d(p1, p2):\n return (p1.x - p2.x)**2 + (p1.y - p2.y)**2\n\ndef perline(l, p):\n result = Line()\n if(l.isvertical):\n result.isvertical = False\n result.k = 0\n result.b = p.y\n return result\n if(l.k == 0):\n result.isvertical = True\n result.x = p.x\n return result\n result.k = (-1)/l.k\n result.b = p.y - result.k * p.x\n return result\n\nmab = Point((a.x + b.x)/2, (a.y + b.y)/2)\nmbc = Point((b.x + c.x)/2, (b.y + c.y)/2)\nab = line2points(a, b)\nbc = line2points(b, c)\n\nperab = perline(ab, mab)\nperbc = perline(bc, mbc)\n\ninter = intersection(perab, perbc)\nif(inter.x is None and inter.y is None):\n print(\"No\")\n sys.exit()\n\ndist = []\ndist.append(d(inter, a))\ndist.append(d(inter, b))\ndist.append(d(inter, c))\ndist = sorted(dist)\nif(dist[-1] - dist[0] < delta and d(c,b) == d(a, b)):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "q=map(int,raw_input().strip().split())\nif (q[0]-q[2])**2+(q[1]-q[3])**2==(q[4]-q[2])**2+(q[5]-q[3])**2 and (q[0]-q[2])*(q[3]-q[5])!=(q[1]-q[3])*(q[2]-q[4]):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\n\nimport sys\n\ndef gcd(a, b):\n if(min(a, b) == 0):\n return max(a, b)\n return gcd(min(a, b), max(a, b) % min(a, b))\n\nif(ax == bx and bx == cx):\n print(\"No\")\n sys.exit()\nif(ay == by and by == cy):\n print(\"No\")\n sys.exit()\n\ncoords = []\ncoords.append((ax, ay))\ncoords.append((bx, by))\ncoords.append((cx, cy))\n\ncoords = sorted(coords)\n\ndelta = set()\n\ndef getdelta(f, s):\n dx = coords[s][0] - coords[f][0]\n dy = coords[s][1] - coords[f][1]\n g = gcd(abs(dx), abs(dy))\n dx /= g\n dy /= g\n tmp = (dx, dy)\n if(tmp in delta):\n return False\n delta.add(tmp)\n return True\n\nfor i in range(3):\n for j in range(3):\n if(i == j):continue\n if(not getdelta(i, j)):\n print(\"No\")\n sys.exit()\n\ndef d(a, b):\n return (a[0] - b[0])**2 + (a[1] - b[1])**2\n\nif(d((ax, ay), (bx, by)) == d((bx, by), (cx, cy))):\n print(\"Yes\")\n sys.exit()\n\nprint(\"No\")\n"}, {"source_code": "def main():\n a1, a2, b1, b2, c1, c2 = map(int, input().split())\n\n ans = True\n\n if((a1 - b1) * (a2 - c2) - (a1 - c1) * (a2 - b2) == 0):\n ans = False\n ab = [(b1 - a1), (b2 - a2)]\n bc = [(b1 - c1), (b2 - c2)]\n mod1 = ab[0] ** 2 + ab[1] ** 2\n mod2 = bc[0] ** 2 + bc[1] ** 2\n\n if(mod1 != mod2):\n ans = False\n\n if(ans):\n print(\"Yes\")\n else:\n print(\"No\")\nmain()\n"}, {"source_code": "def dist(x1,y1,x2,y2):\n d=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)\n return d\nax,ay,bx,by,cx,cy=input().strip().split(' ')\nax,ay,bx,by,cx,cy=[int(ax),int(ay),int(bx),int(by),int(cx),int(cy)]\nif((abs((ax-bx)*(cy-by)-(cx-bx)*(ay-by))!=0) and (dist(ax,ay,bx,by)==dist(bx,by,cx,cy))):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "[ax, ay, bx, by, cx, cy] = list(map(int, input().split()))\nif (by-ay)*(cx-bx) == (cy-by)*(bx-ax):\n print(\"No\")\nelse:\n if ((cy-by)**2 + (cx-bx)**2) == ((by-ay)**2+(bx-ax)**2):\n print(\"Yes\")\n else:\n print(\"No\")"}, {"source_code": "ax,ay,bx,by,cx,cy = [int(x) for x in input().strip().split()]\narea = ax*(by-cy) + bx*(cy-ay) + cx*(ay-by)\n\ndef distsqr(x1,y1,x2,y2):\n\treturn (x1-x2)**2 + (y1-y2)**2\nC = distsqr(ax,ay,bx,by)\nB = distsqr(ax,ay,cx,cy)\nA = distsqr(bx,by,cx,cy)\n\n\nif (A == C):\n\tif (area != 0):\n\t\tprint(\"Yes\")\n\t\texit()\nprint(\"No\")"}, {"source_code": "import sys\nimport math\n\nab_ = list(map(int, sys.stdin.readline().split()))\n\nab = (ab_[3] - ab_[1])**2 + (ab_[2] - ab_[0])**2\nbc = (ab_[5] - ab_[3])**2 + (ab_[4] - ab_[2])**2\nca = (ab_[5] - ab_[1])**2 + (ab_[4] - ab_[0])**2\n\naa = math.sqrt(ab)\nbb = math.sqrt(bc)\ncc = math.sqrt(ca)\n\nif ab == bc and (ab_[4] - ab_[0]) * (ab_[3] - ab_[1]) != (ab_[5] - ab_[1]) * (ab_[2] - ab_[0]):\n print(\"Yes\")\n\nelse:\n print(\"No\")"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int,raw_input().split())\n\nif (ax - bx)*(ay - cy) == (ax - cx)*(ay - by):\n print 'No'\n exit(0)\nif (bx-ax)*(bx-ax)+(by-ay)*(by-ay) == (cx-bx)*(cx-bx)+ (cy-by)*(cy-by):\n print 'Yes'\nelse:\n print 'No'\n"}, {"source_code": "#Arpa and an exam about geometry (851B)\ninp = input().split()\nax = int(inp[0])\nay = int(inp[1])\nbx = int(inp[2])\nby = int(inp[3])\ncx = int(inp[4])\ncy = int(inp[5])\n\nd1 = ((bx-ax)**2)+((by-ay)**2)\nd2 = ((cx-bx)**2)+((cy-by)**2)\n\ncrossProd = ((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))\n\nif (d1==d2 and crossProd!=0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, raw_input().split())\nab2 = (ax-bx)*(ax-bx)+(ay-by)*(ay-by)\nbc2 = (cx-bx)*(cx-bx)+(cy-by)*(cy-by)\nmx = (ax+cx)/2.0\nmy = (ay+cy)/2.0\ncond = mx == bx and my == by\nif ab2 == bc2 and not cond:\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\narea=ax*(by-cy)+bx*(cy-ay)+cx*(ay-by)\nd1=(ax-bx)**2+(ay-by)**2\nd2=(bx-cx)**2+(by-cy)**2\nif area==0 or d1!=d2:\n\tprint(\"no\")\nelse:\n\tprint(\"yes\")"}, {"source_code": "def dis(ax,ay,bx,by):\n return abs(ax-bx)*abs(ax-bx) + abs(ay-by)*abs(ay-by)\n\nar=map(int,raw_input('').split())\nax=ar[0]\nay=ar[1]\nbx=ar[2]\nby=ar[3]\ncx=ar[4]\ncy=ar[5]\n\nif (cy-by)*(bx-ax)==(by-ay)*(cx-bx) or dis(ax,ay,bx,by)!=dis(bx,by,cx,cy):\n print 'No'\nelse:\n print 'Yes'"}, {"source_code": "from __future__ import division\nfrom sys import stdin\nfrom math import sqrt\n\n\ndef slop(a):\n try:\n return (a[0] - a[2]) / (a[1] - a[3])\n except:\n return float('inf')\n\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\neuclidean = lambda x1, x2, y1, y2: pow(x1 - x2, 2) + pow(y1 - y2, 2)\n\nax, ay, bx, by, cx, cy = rints()\nd1, d2 = euclidean(ax, bx, ay, by), euclidean(bx, cx, by, cy)\ns1, s2 = slop([ax, ay, bx, by]), slop([bx, by, cx, cy])\n\n# print(s1, s2, d1, d2)\nif s1 == s2 or d1 != d2:\n print('no')\nelse:\n print('yes')\n"}, {"source_code": "a1,a2,b1,b2,c1,c2=[int(i) for i in input().split()]\nif( (b2-a2)**2+(b1-a1)**2 ==(c2-b2)**2 +(c1-b1)**2):\n if(not (b1-a1)):\n if(b1-c1):\n print(\"Yes\")\n else:\n print(\"No\")\n elif(not (b1-c1)):\n print(\"Yes\")\n elif((b2-a2)/(b1-a1) != (b2-c2)/(b1-c1)):\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")\n"}, {"source_code": "from __future__ import division\nfrom sys import stdin\nfrom decimal import *\n\ndef slop(a):\n try:\n return (a[0] - a[2]) / (a[1] - a[3])\n except:\n return float('inf')\n\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\neuclidean = lambda x1, x2, y1, y2: Decimal.sqrt(Decimal(pow(x1 - x2, 2) + pow(y1 - y2, 2)))\n\nax, ay, bx, by, cx, cy = rints()\nd1, d2 = euclidean(ax, bx, ay, by), euclidean(bx, cx, by, cy)\ns1, s2 = slop([ax, ay, bx, by]), slop([bx, by, cx, cy])\n\n# print(s1, s2, d1, d2)\nif s1 == s2 or d1 != d2:\n print('no')\nelse:\n print('yes')\n"}, {"source_code": "''' ===============================\n -- @uthor : Kaleab Asfaw\n -- Handle : kaleabasfaw2010\n -- Bio : High-School Student\n ==============================='''\n\n# Fast IO\nimport sys\nimport os\nfrom io import BytesIO, IOBase\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = \"x\" in file.mode or \"r\" not in file.mode; self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b: break\n ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0; return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); self.newlines = b.count(b\"\\n\") + (not b); ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1; return self.buffer.readline()\n def flush(self):\n if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode(\"ascii\")); self.read = lambda: self.buffer.read().decode(\"ascii\"); self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# Others\n# from math import floor, ceil, gcd\n# from decimal import Decimal as d\nmod = 10**9+7\ndef lcm(x, y): return (x * y) / (gcd(x, y))\ndef fact(x, mod=mod):\n ans = 1\n for i in range(1, x+1): ans = (ans * i) % mod\n return ans\ndef arr2D(n, m, default=0): return [[default for j in range(m)] for i in range(n)]\ndef arr3D(n, m, r, default=0): return [[[default for k in range(r)] for j in range(m)] for i in range(n)]\ndef sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}\nclass DSU:\n def __init__(self, length): self.length = length; self.parent = [-1] * self.length # O(log(n))\n def getParent(self, node, start): # O(log(n))\n if node >= self.length: return False\n if self.parent[node] < 0:\n if start != node: self.parent[start] = node\n return node\n return self.getParent(self.parent[node], start)\n def union(self, node1, node2): # O(log(n))\n parent1 = self.getParent(node1, node1); parent2 = self.getParent(node2, node2)\n if parent1 == parent2: return False\n elif self.parent[parent1] <= self.parent[parent2]: self.parent[parent1] += self.parent[parent2]; self.parent[parent2] = parent1\n else: self.parent[parent2] += self.parent[parent1]; self.parent[parent1] = parent2\n return True\n def getCount(self, node): return -self.parent[self.getParent(node, node)] # O(log(n))\n\nminInt = 10**(-9)\n\ndef solve(lst):\n if lst[0] == lst[2] == lst[4]:\n return \"No\"\n a, b, c = [None] * 3\n if lst[0] - lst[2] != 0:\n a = (lst[1] - lst[3]) / (lst[0] - lst[2])\n if lst[2] - lst[4] != 0:\n b = (lst[3] - lst[5]) / (lst[2] - lst[4])\n if lst[0] - lst[4] != 0:\n c = (lst[1] - lst[5]) / (lst[0] - lst[4])\n \n if a == None or b == None or c == None:\n pass\n else:\n if abs(a-b) <= minInt and abs(b-c) <= minInt and abs(a-c) <= minInt:\n return \"No\"\n \n disAB = ((lst[0] - lst[2]) ** 2) + ((lst[1] - lst[3]) ** 2)\n disBC = ((lst[2] - lst[4]) ** 2) + ((lst[3] - lst[5]) ** 2)\n if disAB == disBC:\n return \"Yes\"\n return \"No\"\n\nlst = list(map(int, input().split()))\nprint(solve(lst))"}, {"source_code": "x = map(int, raw_input().split(' '))\nprint(['Yes', 'No'][x[0] * x[5] + x[2] * x[1] + x[4] * x[3] == x[0] * x[3] + x[2] * x[5] + x[4] * x[1] or (x[0] - x[2]) ** 2 + (x[1] - x[3]) ** 2 != (x[4] - x[2]) ** 2 + (x[5] - x[3]) ** 2])"}, {"source_code": "from fractions import gcd\n\ndef dist(ax,ay,bx,by):\n return (ax-bx)**2 + (ay-by)**2\n\nax,ay,bx,by,cx,cy = map(int,raw_input().strip().split())\ns1_num = by-ay\ns1_den = bx-ax\nwhile gcd(abs(s1_num),abs(s1_den))!=1:\n s1_num/=gcd(abs(s1_num),abs(s1_den))\n s1_den/=gcd(abs(s1_num),abs(s1_den))\ns2_num = by-cy\ns2_den = bx-cx\nwhile gcd(abs(s2_num),abs(s2_den))!=1:\n s2_num/=gcd(abs(s2_num),abs(s2_den))\n s2_den/=gcd(abs(s2_num),abs(s2_den))\n#print s1_num,s1_den,s2_num,s2_den\n#print dist(ax,ay,bx,by),dist(bx,by,cx,cy)\nif (s1_num*s2_den)!=(s2_num*s1_den) and dist(ax,ay,bx,by)==dist(bx,by,cx,cy):\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "from sys import stdin\ninput = lambda :stdin.readline().strip()\n\na1, a2, b1, b2, c1, c2 = map(int, input().split())\ndist = lambda x1,y1,x2,y2: (x1-x2)**2 + (y1-y2)**2\nprint([\"NO\", \"YES\"][a1 * b2 + b1 * c2 + c1 * a2 - a2*b1 - b2*c1 - c2 *a1 != 0 and dist(a1,a2,b1,b2) == dist(b1,b2,c1,c2)])"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int, input().split())\ndistab=((ax-bx)**2+(ay-by)**2)\ndistbc=((cx-bx)**2+(cy-by)**2)\narea=(ax * (by - cy) + bx * (cy - ay) + cx * (ay - by)) // 2\nif(area==0):\n print(\"No\")\nelif(area!=0 and distbc==distab):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "# http://codeforces.com/contest/851/problem/B\n\nget=lambda:list(map(int,input().split()))\nl=get()\na1,b1,a2,b2,a3,b3=l\nif l==[0, 0, 1000000000 ,1, 1000000000 ,-999999999]:\n print(\"No\")\n exit()\na=complex(a1,b1)\nb=complex(a2,b2)\nc=complex(a3,b3)\ntry:\n x=(a*c-b*b)/(a+c-2*b)\nexcept:\n x=0\n#print(x)\nif abs(abs(a-x)-abs(b-x))<10**-6 and abs(abs(b-x)-abs(c-x))<10**-6 and abs(abs(a-x)-abs(c-x))<10**-6 :\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "def metrika(x1, y1, x2, y2):\n return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)\n\n\ndef povorot(x1, y1, x2, y2, x3, y3):\n if (y2 - y1) * (x3 - x2) != (y3 - y2) * (x2 - x1) and metrika(x1, y1, x2, y2) == metrika(x2, y2, x3, y3):\n return \"Yes\"\n return \"No\"\n\n\nX1, Y1, X2, Y2, X3, Y3 = [int(i) for i in input().split()]\nprint(povorot(X1, Y1, X2, Y2, X3, Y3))\n"}, {"source_code": "from math import sqrt\nx1,y1,x2,y2,x3,y3=map(int,raw_input().split())\nif (abs(y2-y1)**2+abs(x2-x1)**2==abs(y3-y2)**2+abs(x3-x2)**2) and (y1-y2)*(x1-x3)!=(x1-x2)*(y1-y3):\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "V = list(map(int, input().split()))\n\nP = []\nfor i in range(3):\n\tP.append((V[0], V[1]))\n\tV = V[2:]\n\n\n\nA, B, C = P\n\nfor i in range(1, 3):\n\tx, y = P[i]\n\tx0, y0 = P[0]\n\tP[i] = x-x0, y-y0\na, b = P[1]\nc, d = P[2]\n \nif a*d - b*c == 0:\n\tprint(\"NO\")\n\texit(0)\n\ndef dist(A, B):\n\tx = A[0] - B[0]\n\ty = A[1] - B[1]\n\treturn x**2 + y**2\n\n\nprint(\"YES\" if dist(A, B) == dist(B, C) else \"NO\")"}, {"source_code": "def isTria(a,b,c,d,e,f):\n if abs(a*d-b*c+c*f-d*e+e*b-a*f) == 0:\n return 0\n else:\n return 1\n\ndef length(a,b,c,d):\n return (d-b)**2+(c-a)**2\n\nax,ay,bx,by,cx,cy=map(int,input().split())\nif not isTria(ax,ay,bx,by,cx,cy):\n print('No')\nelse:\n if length(ax,ay,bx,by) == length(bx,by,cx,cy):\n print('Yes')\n else:\n print('No')\n"}, {"source_code": "x1,y1,x2,y2,x3,y3=map(int,input().split())\nif (y2-y1)*(x3-x1) == (y3-y1)*(x2-x1):\n print('No')\n exit(0)\nm = (x1-x2)**2 + (y1-y2)**2\np = (x2-x3)**2 + (y2-y3)**2\nif m == p :\n print('Yes')\n exit(0)\nprint('No')"}, {"source_code": "def findCircle(x1, y1, x2, y2, x3, y3) :\n try:\n x12 = x1 - x2 \n x13 = x1 - x3 \n \n y12 = y1 - y2 \n y13 = y1 - y3 \n \n y31 = y3 - y1 \n y21 = y2 - y1 \n \n x31 = x3 - x1 \n x21 = x2 - x1\n \n sx13 = x1**2 - x3**2 \n \n \n sy13 = y1**2 - y3**2 \n \n sx21 = x2**2 - x1**2 \n sy21 = y2**2 - y1**2\n \n f = (((sx13) * (x12) + (sy13) * (x12) + (sx21) * (x13) + (sy21) * (x13)) // (2 * (y31) * (x12) - (y21) * (x13)))\n \n g = (((sx13) * (y12) + (sy13) * (y12) + (sx21) * (y13) + (sy21) * (y13)) // (2 * ((x31) * (y12) - (x21) * (y13)))) \n \n c = (-(x1**2) - y1**2 - 2 * g * x1 - 2 * f * y1)\n \n h = -g\n k = -f \n sqr_of_r = h * h + k * k - c \n\n\n r = sqr_of_r**0.5\n\n\n except Exception:\n return False \n \n return True\n \n\n\nx1, y1, x2, y2, x3, y3 = map(int,input().split())\nm = 1000000007\nif findCircle(x1, y1, x2, y2, x3, y3):\n if ((((x1-x2)**2)%m + ((y1-y2)**2)%m)%m) == ((((x2-x3)**2)%m + ((y2-y3)**2)%m)%m):\n print('Yes')\n else:\n print('No')\nelse:\n print('No')"}, {"source_code": "str=raw_input()\na=str.split()\n\ndef len(x1,y1,x2,y2):\n return (y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1)\n\nfor x in xrange(0,6):\n a[x]=int(a[x])\nif(len(a[0],a[1],a[2],a[3])==len(a[2],a[3],a[4],a[5]) and ((a[5]-a[3])*(a[2]-a[0])!=(a[4]-a[2])*(a[3]-a[1]))):\n print 'Yes'\nelse:\n print 'No'\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(long, raw_input().split())\nab = ((ax-bx)**2+(ay-by)**2)\nbc = ((bx-cx)**2+(by-cy)**2)\nif ab==bc and (ay-by)*(cx-ax)+(bx-ax)*(cy-ay)!=0:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\n\nif (ax - bx) * (cy - by) == (ay - by) * (cx - bx):\n\tprint('No')\nelif ((ax - bx) ** 2 + (ay - by) ** 2) == ((bx - cx) ** 2 + (by - cy) ** 2):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "import math as mt \nimport sys,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\ndef dist(x,y,c,d):\n return (x-c)**2+(y-d)**2\ndef circle(x1, y1, x2,y2, r1, r2): \n \n distSq = (((x1 - x2)* (x1 - x2))+ ((y1 - y2)* (y1 - y2)))**(.5) \n \n if (distSq + r2 <= r1): \n return True\n else: \n return False\na,b,c,d,e,f=M()\nx=dist(a,b,c,d)\ny=dist(c,d,e,f)\nz=dist(e,f,a,b)\np=(c-a)*(f-b)-(d-b)*(e-a)\nif(p==0):\n print(\"No\")\nelse:\n if(x==y):\n print(\"Yes\")\n else:\n print(\"No\")\n"}, {"source_code": "ax,ay,bx,by,cx,cy = map(int,input().split())\ndef det(a,b,c,d):\n return abs(a*d-b*c)\nif (ax-bx)**2+(ay-by)**2 == (cx-bx)**2+(cy-by)**2 and det(ax-bx,ay-by,cx-bx,cy-by) > 0:\n print('yes')\nelse:\n print('no')"}, {"source_code": "from sys import exit\nfrom math import sqrt, acos, pi\n\nclass Vector2D:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n def abs_sqr(self):\n return self.x ** 2 + self.y ** 2\n\n def dot(self, other):\n return self.x * other.x + self.y * other.y\n\n def __sub__(self, other):\n return Vector2D(self.x - other.x, self.y - other.y)\n\nax, ay, bx, by, cx, cy = map(int, raw_input().split(' '))\n\na = Vector2D(ax, ay)\nb = Vector2D(bx, by)\nc = Vector2D(cx, cy)\n\nab = b - a\nbc = c - b\n\nif ab.abs_sqr() == bc.abs_sqr() and ab.dot(bc) ** 2 != ab.abs_sqr() * bc.abs_sqr():\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, raw_input().strip().split())\none = (ax-bx)**2 + (ay-by) ** 2\nthree = (bx-cx) ** 2 + (by-cy) ** 2\nif bx == ax and cx == bx:\n print \"No\"\n\nelif by == ay and cy == ay:\n print \"No\"\n\nelse:\n if bx - ax == 0:\n mba = -1\n else:\n mba = (by-ay)*(cx-bx)\n if cx-bx == 0:\n mcb = -1\n else:\n mcb = (cy-by)*(bx-ax)\n if one == three:\n if mba == mcb:\n print \"No\"\n else:\n print \"Yes\"\n else:\n print \"No\"\n"}, {"source_code": "from sys import exit\nfrom math import *\n\nax, ay, bx, by, cx, cy = map(int, input().split())\n\nl1 = (bx - ax)**2 + (by - ay)**2\nl2 = (cx - bx)**2 + (cy - by)**2\ndx = bx - ax\ndy = by - ay\n\nif l1 != l2:\n print('No')\nelif cx == bx + dx and cy == by + dy:\n print('No')\nelse:\n print('Yes')\n"}, {"source_code": "a=map(int,raw_input().split())\n\nx1=a[0]\ny1=a[1]\nx2=a[2]\ny2=a[3]\nx3=a[4]\ny3=a[5]\n\nq=((a[0]-a[2])**2 + (a[1]-a[3])**2)\nb=((a[0]-a[4])**2 + (a[1]-a[5])**2)\nc=((a[4]-a[2])**2 + (a[3]-a[5])**2)\nf=0\ns=(y3-y2)*(x2-x1)\nt=(y2-y1)*(x3-x2)\nif s!=t and q==c:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "def vector_product(v1x, v1y, v2x, v2y):\n return (v1x * v2y - v1y * v2x)\n\ndef len_sq(vx, vy):\n return (vx * vx + vy * vy)\n \nax, ay, bx, by, cx, cy = (int(x) for x in input().split())\nabx = bx - ax\naby = by - ay\nbcx = cx - bx\nbcy = cy - by\nif vector_product(abx, aby, bcx, bcy) == 0:\n print('No')\nelif len_sq(abx, aby) != len_sq(bcx, bcy):\n print('No')\nelse:\n print('Yes')\n\n\n "}, {"source_code": "def get_len_sq(a, b):\n return (a[0] - b[0])**2 + (a[1] - b[1])**2\n\n\nax, ay, bx, by, cx, cy = map(int, input().split())\na = (ax, ay)\nb = (bx, by)\nc = (cx, cy)\nf = get_len_sq\nif f(a,b) == f(b,c):\n if a[0]+c[0] == 2*b[0] and a[1]+c[1] == 2*b[1]:\n print('No')\n else:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, raw_input().split())\nif ((ax - bx)**2 + (ay - by)**2 != (bx - cx)**2 + (by - cy)**2) or ((ax - bx) * (by - cy) == (bx - cx) * (ay - by)): print \"No\"\nelse: print \"Yes\"\n"}, {"source_code": "#coding:utf-8\n\ndef gg(ax,bx,ay,by):\n return (ax-bx)*(ax-bx)+(ay-by)*(ay-by);\n\nax,ay,bx,by,cx,cy = list(map(int,input().split()))\nif gg(bx,ax,by,ay) == gg(bx,cx,by,cy) and gg(ax,cx,ay,cy) < 4 * gg(bx,cx,by,cy):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "str=raw_input()\na=str.split()\n\ndef len(xx1,yy1,x2,y2):\n return (y2 - yy1) * (y2 - yy1) + (x2 - xx1) * (x2 - xx1)\n\nfor x in xrange(0,6):\n a[x]=int(a[x])\nif(len(a[0],a[1],a[2],a[3])==len(a[2],a[3],a[4],a[5]) and ((a[5]-a[3])*(a[2]-a[0])!=(a[4]-a[2])*(a[3]-a[1]))):\n print 'Yes'\nelse:\n print 'No'\n"}, {"source_code": "a1,a2,b1,b2,c1,c2=list(map(int,input().split()))\np=(b1-c1)*(b1-c1)+(b2-c2)*(b2-c2)\nq=(a1-b1)*(a1-b1)+(a2-b2)*(a2-b2)\nr=(a2-b2)*(a1-c1)-(a2-c2)*(a1-b1)\nif p==q and r!=0:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split(' '))\nd1=(bx-ax)**2+(by-ay)**2\nd2=(cx-bx)**2+(cy-by)**2\nif (by-ay)*(cx-bx)==(cy-by)*(bx-ax) or d1!=d2:\n print(\"No\")\nelse:\n print(\"Yes\")"}, {"source_code": "x1,y1,x2,y2,x3,y3=[int(i) for i in raw_input().split()]\na=(x1-x2)**2+(y1-y2)**2\nb=(x1-x3)**2+(y1-y3)**2\nc=(x3-x2)**2+(y3-y2)**2\nif a==c and x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)!=0:\n print \"Yes\"\nelse:\n print \"No\"\n \n"}, {"source_code": "x1, y1, x2, y2, x3, y3 = list(map(int, input().split(' ')))\n\ndef main():\n b1 = (x2 - x1) ** 2 + (y2 - y1) ** 2 == (x3 - x2) ** 2 + (y3 - y2) ** 2\n b2 = (y3 - y1) * (x2 - x1) != (y2 - y1) * (x3 - x1)\n\n return b1 and b2\n\nprint('Yes' if main() else 'No')\n"}, {"source_code": "def helper():\n\tax, ay, bx, by, cx, cy = map(int, raw_input().split())\n\tif abs(cal(ax, ay, bx, by) - cal(bx, by, cx, cy)) < 1e-5:\n\t\tif (ax == bx and bx == cx) or (ay == by and by == cy) or cal_k(ax, ay, bx, by, cx, cy):\n\t\t\treturn False\n\t\t# print cal(ax, ay, bx, by) - cal(bx, by, cx, cy)\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef cal(x1, y1, x2, y2):\n\treturn (x2 - x1)**2 + (y2 - y1)**2\n\ndef cal_k(x1, y1, x2, y2, x3, y3):\n\tif (x3 - x2) * (y2 - y1) == (y3 - y2) * (x2 - x1):\n\t\treturn True\n\telse:\n\t\treturn False\n\nif helper():\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "ax, ay, bx, by, cx, cy=map(int, input().split())\ndist=lambda ax, ay, bx, by: (ax-bx)**2+(ay-by)**2\nA=dist(bx, by, cx, cy)\nB=dist(cx, cy, ax, ay)\nC=dist(ax, ay, bx, by)\nprint('Yes' if A==C and (B-A-C)**2!=4*A*C else 'No')\n\n"}, {"source_code": "import math\na_x, a_y, b_x, b_y, c_x, c_y = map(int, input().split())\n\nif (b_x - a_x)*(c_y - a_y) == (c_x - a_x)*(b_y - a_y):\n print('No')\n exit()\n\nl_ab = abs(b_x - a_x)**2 + abs(b_y - a_y)**2\nl_bc = abs(c_x - b_x)**2 + abs(c_y - b_y)**2\nif l_ab != l_bc:\n print('No')\n exit()\n\nprint('Yes')\n"}, {"source_code": "#!/usr/bin/env python\n\n\ndef dist_2(x1, x2,y1, y2):\n return (x1 - y1) ** 2 + (x2-y2)**2\ndef outer_prod(x1,x2,y1,y2):\n return x1 * y2 - x2 * y1\ndef main():\n a1, a2, b1, b2, c1, c2 = map(int, input().split())\n cond1 = dist_2(a1, a2, b1, b2) == dist_2(b1,b2,c1,c2)\n cond2 = outer_prod(a1-b1, a2-b2, c1-b1, c2-b2) != 0\n if cond1 and cond2:\n print(\"YES\")\n else:\n print(\"NO\")\n\nmain()\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\n\nif (ax - bx) * (cy - by) == (ay - by) * (cx - bx):\n\tprint('No')\nelif ((ax - bx) ** 2 + (ay - by) ** 2) == ((bx - cx) ** 2 + (by - cy) ** 2):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split(' '))\nlab=(bx-ax)**2+(by-ay)**2\nlbc=(cx-bx)**2+(cy-by)**2\n\ndef sol():\n if(lab!=lbc):\n print('No')\n return\n if(ax==bx and ax==cx):\n print('No')\n return\n if((bx-ax)*(cy-ay)==(cx-ax)*(by-ay)):\n print('No')\n return\n print('Yes')\n return\nsol()\n"}, {"source_code": "a = list(map(int, input().split()))\nprint(\"Yes\" if (a[0] - a[2]) ** 2 + (a[1] - a[3]) ** 2 == (a[2] - a[4]) ** 2 + (a[3] - a[5]) ** 2 and (a[2] - a[0]) * (a[5] - a[1]) - (a[4] - a[0]) * (a[3] - a[1]) != 0 else \"No\")"}, {"source_code": "def main():\n ax, ay, bx, by, cx, cy = tuple(map(int, input().split()))\n ab = (ax - bx)**2 + (ay - by)**2\n bc = (bx - cx)**2 + (by - cy)**2\n\n one_line = (bx - ax) * (cy - ay) == (by - ay) * (cx - ax) \n\n if ab == bc and not one_line:\n print('Yes')\n else:\n print('No')\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\ndef r(a, b, c, d):\n return (a-c)**2 + (b-d)**2\nprint('No Yes'.split()[r(a, b, c, d) == r(c, d, e, f) and not (a-c)*(d-f) - (b-d)*(c-e) == 0])"}, {"source_code": "a_x, a_y, b_x, b_y, c_x, c_y = map(int, input().split())\nif (a_x-b_x)**2+(a_y-b_y)**2 == (c_x-b_x)**2+(c_y-b_y)**2 and (c_x-a_x)*(b_y-a_y) != (c_y-a_y)*(b_x-a_x):\n print('Yes')\nelse:\n print('No')\n\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\n\ndef r(x1, y1, x2, y2):\n return (x1 - x2) ** 2 + (y1 - y2) ** 2\n\ndef line(x3, y3, x1, y1, x2, y2):\n if (x3 - x1) * (y2 - y1) == (y3 - y1) * (x2 - x1):\n return True\n return False\n\nif r(ax, ay, bx, by) == r(bx, by, cx, cy) and not line(ax, ay, bx, by, cx, cy):\n print('Yes')\nelse:\n print('No')\n \n"}, {"source_code": "from decimal import *\ngetcontext().prec=50\n\ndef is_midpoint(p1,p2,p3):\n if (p1[0]+p2[0])/2==p3[0] and (p1[1]+p2[1])/2==p3[1]:\n return True\n else:\n return False\n\ndef distance(p1,p2):\n return (((p2[0]-p1[0])**2)+((p2[1]-p1[1])**2))\n\ndef same_slope(p1,p2,p3):\n if is_midpoint(p1,p2,p3) or is_midpoint(p2,p1,p3) or is_midpoint(p1,p3,p2):\n return False\n elif distance(p1,p2)==distance(p2,p3):\n return True\n else:\n return False\n\na_x,a_y,b_x,b_y,c_x,c_y=map(int,input().split())\np1=[a_x,a_y]\np2=[b_x,b_y]\np3=[c_x,c_y]\nif same_slope(p1,p2,p3):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def is_midpoint(p1,p2,p3):\n if (p1[0]+p2[0])/2==p3[0] and (p1[1]+p2[1])/2==p3[1]:\n return True\n else:\n return False\n\ndef distance(p1,p2):\n return (((p2[0]-p1[0])**2)+((p2[1]-p1[1])**2))\n\ndef same_slope(p1,p2,p3):\n if is_midpoint(p1,p2,p3) or is_midpoint(p2,p1,p3) or is_midpoint(p1,p3,p2):\n return False\n elif distance(p1,p2)==distance(p2,p3):\n return True\n else:\n return False\n\na_x,a_y,b_x,b_y,c_x,c_y=map(int,input().split())\np1=[a_x,a_y]\np2=[b_x,b_y]\np3=[c_x,c_y]\nif same_slope(p1,p2,p3):\n print(\"YES\")\nelse:\n print(\"NO\")"}], "negative_code": [{"source_code": "import math\ndef slope(i,j):\n try:\n return abs(float(j[1]-i[1])/float(j[0]-i[0]))\n except:\n return -200\ndef len(i,j):\n return math.sqrt((j[1]-i[1])**2 +(i[0]-j[0])**2)\nax,ay,bx,by,cx,cy=map(int,raw_input().split())\na=(ax,ay)\nb=(bx,by)\nc=(cx,cy)\nif slope(a,b)==slope(b,c):\n print 'No'\nelse:\n x=len(a,b)\n y=len(b,c)\n z=len(c,a)\n\n\n if x==y:\n print 'Yes'\n else:\n print 'No'\n"}, {"source_code": "from math import sqrt\ndef line(ax,ay,bx,by,cx,cy):\n return not bool(ax*(by-cy) + bx*(cy-ay) + cx*(ay-by))\n\nax,ay,bx,by,cx,cy = map(int, input().split())\n\nif sqrt((ax - bx)**2 + (ay-by)**2) == sqrt((cx - bx)**2 + (cy-by)**2) and not line(ax,ay,bx,by,cx,cy):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\nAB = (ax-bx)*(ax-bx)+(ay-by)*(ay-by)\nBC = (bx-cx)*(bx-cx)+(by-cy)*(by-cy)\nCA = (cx-ax)*(cx-ax)+(cy-ay)*(cy-ay)\nAB **= (1/2)\nBC **= (1/2) \nCA **= (1/2)\nif AB == BC and not AB+BC == CA:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "ax,ay,bx,by,cx,cy = [int(x) for x in input().strip().split()]\narea = ax*(by-cy) + bx*(cy-ay) + cx*(ay-by)\n\ndef distsqr(x1,y1,x2,y2):\n\treturn (x1-x2)**2 + (y1-y2)**2\nC = distsqr(ax,ay,bx,by)\nB = distsqr(ax,ay,cx,cy)\nA = distsqr(bx,by,cx,cy)\n\n\nif (A == C):\n\tif (area != 0):\n\t\tprint(\"Yes\")\n\t\texit()\nprint(\"No\", A, C, area)"}, {"source_code": "''' ===============================\n -- @uthor : Kaleab Asfaw\n -- Handle : kaleabasfaw2010\n -- Bio : High-School Student\n ==============================='''\n\n# Fast IO\nimport sys\nimport os\nfrom io import BytesIO, IOBase\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = \"x\" in file.mode or \"r\" not in file.mode; self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b: break\n ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0; return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); self.newlines = b.count(b\"\\n\") + (not b); ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1; return self.buffer.readline()\n def flush(self):\n if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode(\"ascii\")); self.read = lambda: self.buffer.read().decode(\"ascii\"); self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# Others\n# from math import floor, ceil, gcd\n# from decimal import Decimal as d\nmod = 10**9+7\ndef lcm(x, y): return (x * y) / (gcd(x, y))\ndef fact(x, mod=mod):\n ans = 1\n for i in range(1, x+1): ans = (ans * i) % mod\n return ans\ndef arr2D(n, m, default=0): return [[default for j in range(m)] for i in range(n)]\ndef arr3D(n, m, r, default=0): return [[[default for k in range(r)] for j in range(m)] for i in range(n)]\ndef sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}\nclass DSU:\n def __init__(self, length): self.length = length; self.parent = [-1] * self.length # O(log(n))\n def getParent(self, node, start): # O(log(n))\n if node >= self.length: return False\n if self.parent[node] < 0:\n if start != node: self.parent[start] = node\n return node\n return self.getParent(self.parent[node], start)\n def union(self, node1, node2): # O(log(n))\n parent1 = self.getParent(node1, node1); parent2 = self.getParent(node2, node2)\n if parent1 == parent2: return False\n elif self.parent[parent1] <= self.parent[parent2]: self.parent[parent1] += self.parent[parent2]; self.parent[parent2] = parent1\n else: self.parent[parent2] += self.parent[parent1]; self.parent[parent1] = parent2\n return True\n def getCount(self, node): return -self.parent[self.getParent(node, node)] # O(log(n))\n\nminInt = 10**(-7)\n\ndef solve(lst):\n if lst[1] == lst[3] == lst[5]:\n return \"No\"\n a, b, c = [None] * 3\n if lst[0] - lst[2] != 0:\n a = (lst[1] - lst[3]) / (lst[0] - lst[2])\n if lst[2] - lst[4] != 0:\n b = (lst[3] - lst[5]) / (lst[2] - lst[4])\n if lst[2] - lst[4] != 0:\n c = (lst[1] - lst[5]) / (lst[0] - lst[4])\n \n if a == None or b == None or c == None:\n pass\n else:\n if abs(a-b) <= minInt and abs(b-c) <= minInt and abs(a-c) <= minInt:\n return \"No\"\n \n disAB = (((lst[0] - lst[2]) ** 2) + ((lst[1] - lst[3]) ** 2)) ** 0.5\n disBC = (((lst[2] - lst[4]) ** 2) + ((lst[3] - lst[5]) ** 2)) ** 0.5\n\n if disAB == disBC:\n return \"Yes\"\n return \"No\"\n\nlst = list(map(int, input().split()))\nprint(solve(lst))"}, {"source_code": "MOD = 1000000007\nii = lambda : int(input())\nsi = lambda : input()\ndgl = lambda : list(map(int, input()))\nf = lambda : map(int, input().split())\nil = lambda : list(map(int, input().split()))\nls = lambda : list(input())\nax,ay,bx,by,cx,cy=f()\nif (ax-bx)**2+(ay-by)**2==(bx-cx)**2+(by-cy)**2:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\na = (bx - ax, by - ay)\nda = (a[0] ** 2 + a[1] ** 2) ** .5\nb = (cx - ax, cy - ay)\ndb = (b[0] ** 2 + b[1] ** 2) ** .5\nc = (cx - bx, cy - by)\ndc = (c[0] ** 2 + c[1] ** 2) ** .5\nif ((cx - ax) * (by - ay) == (cy - ay) * (bx - ax)) or da != dc:\n print(\"No\")\nelse:\n print(\"Yes\")\n"}, {"source_code": "import decimal\nD = decimal.Decimal\ndef main():\n l=map(long,raw_input().split())\n dist1=(D((l[2]-l[0])**2+(l[3]-l[1])**2)).sqrt()\n dist2=(D((l[4]-l[2])**2+(l[5]-l[3])**2)).sqrt()\n dist3=(D((l[4]-l[0])**2+(l[5]-l[1])**2)).sqrt()\n print dist1,dist2,dist3,dist1+dist2\n if dist1==dist2 and (dist1+dist2)>dist3:\n print \"Yes\"\n else:\n print \"No\"\nmain() "}, {"source_code": "import math\ndef isTria(a,b,c,d,e,f):\n if abs(a*d-b*c+c*f-d*e+e*b-a*f) == 0:\n return 0\n else:\n return 1\n\ndef length(a,b,c,d):\n return (d-b)**2+(c-a)**2\n\nax,ay,bx,by,cx,cy=map(int,input().split())\nif not isTria(ax,ay,bx,by,cx,cy):\n print('No')\nelse:\n if length(ax,ay,bx,by) == length(bx,by,cx,cy) or length(bx,by,cx,cy)==length(ax,ay,cx,cy) or length(ax,ay,bx,by)==length(ax,ay,cx,cy):\n print('Yes')\n else:\n print('No')\n"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\n# for _ in range(int(input())):\n# n,m=map(int,input().split())\n# n=int(input())\n# a = [int(x) for x in input().split()]\n\ndef main():\n a = [int(x) for x in input().split()]\n\n if a[0]==a[2] and a[1]==a[3] and a[2]==a[4] and a[3]==a[5]:\n print(\"YES\")\n exit(0)\n\n a[5]-=a[1]\n a[4]-=a[0]\n a[3]-=a[1]\n a[2]-=a[0]\n\n if not a[5]*a[2]==a[4]*a[3]:\n print(\"YES\")\n exit(0)\n\n print(\"NO\")\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "import math\ndef slope(a,b,c,d):\n if a==c:\n return math.inf\n else:\n return((d-b)/(c-a))\ndef length(a,b,c,d):\n return (d-b)**2+(c-a)**2\n\nax,ay,bx,by,cx,cy=map(int,input().split())\nif slope(ax,ay,bx,by)==slope(bx,by,cx,cy) and slope(bx,by,cx,cy)==slope(ax,ay,cx,cy):\n print('No')\nelse:\n if length(ax,ay,bx,by) == length(bx,by,cx,cy) or length(bx,by,cx,cy)==length(ax,ay,cx,cy) or length(ax,ay,bx,by)==length(ax,ay,cx,cy):\n print('Yes')\n else:\n print('No')\n"}, {"source_code": "ax,ay,bx,by,cx,cy = [int(i) for i in input().split(\" \")]\n\nfrom math import sqrt\n\ndef distance(ax,ay,bx,by):\n return sqrt((ax-bx)**2+(ay-by)**2)\n\nif distance(ax,ay,bx,by) == distance(cx,cy,bx,by):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\nBab = ax - bx\nAab = by - ay\nCab = -1 * Aab * ax - Bab * ay\nif Aab * cx + Bab * cy + Cab == 0:\n print(\"No\")\nelse:\n ab = (ax - bx) ** 2 + (ay - by) ** 2\n ac = (ax - cx) ** 2 + (ay - cy) ** 2\n bc = (by - cy) ** 2 + (bx - cx) ** 2\n if (ab == bc or ab == ac or bc == ac):\n print(\"Yes\")\n else:\n print(\"No\")"}, {"source_code": "ax, ay, bx, by, cx, cy = input().split()\nax, ay, bx, by, cx, cy = int(ax), int(ay), int(bx), int(by), int(cx), int(cy)\ndistant_1 = ((abs(bx) - abs(ax)) ** 0.5 + (abs(by) - abs(ay)) ** 0.5) ** 0.5\ndistant_2 = ((abs(bx) - abs(cx)) ** 0.5 + (abs(by) - abs(cy)) ** 0.5) ** 0.5\n\nif distant_1 == distant_2:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "import sys\nimport math\n\nlines = sys.stdin.read().splitlines()\nax, ay, bx, by, cx, cy = [int(x) for x in lines[0].split()]\ndef dist(p1x, p1y, p2x, p2y):\n return (p1x-p1y)**2+(p2x-p2y)**2 \ndist1 = dist(ax, ay, bx, by)\ndist2 = dist(bx, by, cx, cy)\nif dist1 == dist2 and (ax-bx != bx-cx):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "a, b, c, d, e, f = map(int,input().split())\nif ((a-c)**2 + (b-d)**2)==((c-e)**2 + (d-f)**2):\n print(\"Yes\")\nelse:\n print('No')"}, {"source_code": "x1,y1,x2,y2,x3,y3=map(int,input().split())\nif x1 == x2 and x1 == x3:\n print('No')\n exit(0)\nif y1 == y2 and y1 == y3:\n if x1 == (x2+x3)/2 or x2 == (x1+x3)/2 or x3 == (x2+x1)/2:\n print('No')\n exit(0)\nm = (x1-x2)**2 + (y1-y2)**2\np = (x2-x3)**2 + (y2-y3)**2\nif m == p :\n print('Yes')\n exit(0)\nprint('No')"}, {"source_code": "import math\na_1,a_2,b_1,b_2,c_1,c_2 = map(int,input().split())\ndist_1 = (a_1-b_1)**2 + (a_2-b_2)**2\ndist_2 = (a_1-c_1)**2 + (a_2-c_2)**2\ndist_3 = (b_1-c_1)**2 + (b_2 - c_2)**2\ndef checkTriangle(x1, y1, x2, y2, x3, y3): \n \n # Calculation the area of \n # triangle. We have skipped \n # multiplication with 0.5 \n # to avoid floating point \n # computations \n a = (x1 * (y2 - y3) +\n x2 * (y3 - y1) + \n x3 * (y1 - y2)) \n if a == 0:\n return True\n else:\n return False\n\nif checkTriangle(a_1,a_2,b_1,b_2,c_1,c_2)== True:\n print(\"No\")\nelif dist_1 == dist_2:\n print(\"Yes\")\nelif dist_2 == dist_3:\n print(\"Yes\")\nelif dist_3 == dist_1:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "from sys import stdin, stdout\nfrom decimal import Decimal\nINF = Decimal('inf')\ntwo = Decimal(2)\nhalf = Decimal(0.5)\n\n\n\ndef angle_cos(a, b):\n return (a[0] * b[0] + a[1] * b[1]) / (((a[0] ** two + a[1] ** two) ** half) * ((b[0] ** two + b[1] ** two) ** half))\n\n\ndef angle_sin(a, b):\n print(a, b)\n return (a[0] * b[1] - a[1] * b[0]) / (((a[0] ** two + a[1] ** two) ** half) * ((b[0] ** two + b[1] ** two) ** half)) \n\n\ndef find_coordinates(x1, y1, x2, y2, x3, y3):\n A = x2 - x1\n B = y2 - y1\n C = x3 - x1\n D = y3 - y1\n E = A * (x1 + x2) + B * (y1 + y2)\n F = C * (x1 + x3) + D * (y1 + y3)\n G = 2 * (A * (y3 - y2) - B * (x3 - x2))\n if not G:\n return (INF, INF)\n\n x = (D * E - B * F) / G\n y = (A * F - C * E) / G \n \n return (x, y)\n \n\nx1, y1, x2, y2, x3, y3 = map(Decimal, stdin.readline().split())\nx, y = find_coordinates(x1, y1, x2, y2, x3, y3)\n\nfirst, second, third = (x1 - x, y1 - y), (x2 - x, y2 - y), (x3 - x, y3 - y)\nif abs(x) != INF and angle_sin(first, second) == angle_sin(second, third) and angle_cos(first, second) == angle_cos(second, third):\n stdout.write('Yes')\nelse:\n stdout.write('No')"}, {"source_code": "from sys import stdin\ndef dis(x1,y1,x2,y2):\n return (x1-x2)**2 + (y1-y2)**2\nx1,y1,x2,y2,x3,y3 = map(int,stdin.readline().split())\ns = set()\ns.add(dis(x1,y1,x2,y2))\ns.add(dis(x1,y1,x3,y3))\ns.add(dis(x3,y3,x2,y2))\nif len(s)<=2 and (x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))!=0:\n print 'Yes'\nelse:\n print 'No'"}, {"source_code": "import decimal\nD = decimal.Decimal\ndef main():\n l=map(long,raw_input().split())\n dist1=round((D((l[2]-l[0])**2+(l[3]-l[1])**2)).sqrt(),6)\n dist2=round((D((l[4]-l[2])**2+(l[5]-l[3])**2)).sqrt(),6)\n dist3=round((D((l[4]-l[0])**2+(l[5]-l[1])**2)).sqrt(),6)\n if dist1==dist2 and (dist1+dist2)!=dist3:\n print \"Yes\"\n else:\n print \"No\"\nmain() "}, {"source_code": "def main():\n l=map(long,raw_input().split())\n dist1=((l[2]-l[0])**2+(l[3]-l[1])**2)**(0.5)\n dist2=((l[4]-l[2])**2+(l[5]-l[3])**2)**(0.5)\n dist3=((l[4]-l[0])**2+(l[5]-l[1])**2)**(0.5)\n if dist1==dist2:\n print \"Yes\"\n else:\n print \"No\"\n \nmain() "}, {"source_code": "import decimal\nD = decimal.Decimal\ndef main():\n l=map(long,raw_input().split())\n dist1=round((D((l[2]-l[0])**2+(l[3]-l[1])**2)).sqrt(),10)\n dist2=round((D((l[4]-l[2])**2+(l[5]-l[3])**2)).sqrt(),10)\n dist3=round((D((l[4]-l[0])**2+(l[5]-l[1])**2)).sqrt(),10)\n if dist1==dist2 and (dist1+dist2)!=dist3:\n print \"Yes\"\n else:\n print \"No\"\nmain() "}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\na = (bx - ax, by - ay)\nda = (a[0] ** 2 + a[1] ** 2) ** .5\nb = (cx - ax, cy - ay)\ndb = (b[0] ** 2 + b[1] ** 2) ** .5\nc = (cx - bx, cy - by)\ndc = (c[0] ** 2 + c[1] ** 2) ** .5\nif ((cx - ax) * (by - ay) == (cy - ay) * (bx - ax)) or da != dc:\n print(\"No\")\nelse:\n print(\"Yes\")\n"}, {"source_code": "def helper():\n\tax, ay, bx, by, cx, cy = map(int, raw_input().split())\n\tif cal(ax, ay, bx, by) - cal(bx, by, cx, cy) < 1e-5:\n\t\tif (ax == bx and bx == cx) or (ay == by and by == cy):\n\t\t\treturn False\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef cal(x1, y1, x2, y2):\n\treturn (x2 - x1)**2 + (y2 - y1)**2\n\ndef cal_k(x1, y1, x2, y2):\n\treturn (y2 - y1) / (x1 - x2)\n\nif helper():\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "from math import sqrt\nl = raw_input().split()\n(ax, ay, bx, by, cx, cy) = [int(x) for x in l]\n\ndab = sqrt((ax - bx)**2 + (ay - by)**2)\ndbc = sqrt((bx - cx)**2 + (by - cy)**2)\n\nif dab == dbc:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "import sys\nimport math\n\nab_ = list(map(int, sys.stdin.readline().split()))\n\nab = (ab_[3] - ab_[1])**2 + (ab_[2] - ab_[0])**2\nbc = (ab_[5] - ab_[3])**2 + (ab_[4] - ab_[2])**2\n\n\nif ab == bc:\n print(\"Yes\")\n\nelse:\n print(\"No\")"}, {"source_code": "import decimal\nD = decimal.Decimal\ndef main():\n l=map(long,raw_input().split())\n dist1=(D((l[2]-l[0])**2+(l[3]-l[1])**2)).sqrt()\n dist2=(D((l[4]-l[2])**2+(l[5]-l[3])**2)).sqrt()\n dist3=(D((l[4]-l[0])**2+(l[5]-l[1])**2)).sqrt()\n if dist1==dist2 and (dist1+dist2)!=dist3:\n print \"Yes\"\n else:\n print \"No\"\nmain() "}, {"source_code": "import sys\nimport math\n\nab_ = list(map(int, sys.stdin.readline().split()))\n\nab = math.sqrt((ab_[3] - ab_[1])**2 + (ab_[2] - ab_[0])**2)\nbc = math.sqrt((ab_[5] - ab_[3])**2 + (ab_[4] - ab_[2])**2)\nca = math.sqrt((ab_[5] - ab_[1])**2 + (ab_[4] - ab_[0])**2)\n\nif int(ab) == int(bc) and int(ab + bc) > int(ca) and int(ab + ca) > bc and int(bc + ca) > int(ab):\n print(\"Yes\")\n\nelse:\n print(\"No\")"}, {"source_code": "def sqr(a):\n\treturn a*a\n\nax,ay,bx,by,cx,cy = list(map(int,input().split()))\nif(abs(sqr(bx-ax)+sqr(by-ay)) == abs(sqr(bx-cx)+sqr(by-cy))):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\n\nA=ax*ax+ay*ay\nB=bx*bx+by*by\nC=cx*cx+cy*cy\nG=(cy-by)*ax+(ay-cy)*bx+(by-ay)*cx\n\ntry:\n x=( (B-C)*ay+(C-A)*by+(A-B)*cy )/(2*G)\n y=( (C-B)*ax+(A-C)*bx+(B-A)*cx )/(2*G)\nexcept:\n print('No')\n exit()\n\n# print(x,y)\nif (ax-x)**2 + (ay-y)**2 != (bx-x)**2 + (by-y)**2 or (ax-x)**2 + (ay-y)**2 !=(cx-x)**2 + (cy-y)**2:\n print('No')\nelif (ax-x)*(by-y)-(ay-y)*(bx-x)==(bx-x)*(cy-y)-(by-y)*(cx-x):\n print('Yes')\nelse:\n print('No')\n "}, {"source_code": "from math import sqrt\nx1,y1,x2,y2,x3,y3=map(int,raw_input().split())\nside1 = sqrt((x1 - x2)**2 + (y1-y2)**2)\nside2 = sqrt((x2 - x3)**2 + (y2-y3)**2)\nside3 = sqrt((x3 - x1)**2 + (y3-y1)**2)\n\ntri= [side1, side2, side3]\ntri.sort()\n\nif tri[0] < tri[1]+tri[2]:\n if tri[0] == tri[2]:\n print('Yes')\n elif tri[1] == tri[2] or tri[1] == tri[0]:\n print('Yes')\n else:\n print('No')\nelse:\n print('No')\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\na = (bx - ax, by - ay)\nda = (a[0] ** 2 + a[1] ** 2) ** .5\nb = (cx - ax, cy - ay)\ndb = (b[0] ** 2 + b[1] ** 2) ** .5\nc = (cx - bx, cy - by)\ndc = (c[0] ** 2 + c[1] ** 2) ** .5\nif ((cx - ax) * (by - ay) == (cy - ay) * (bx - ax)) or da != dc:\n print(\"No\")\nelse:\n print(\"Yes\")\n"}, {"source_code": "ax,ay,bx,by,cx,cy = map(int, input().split())\ndef dis(x1,y1,x2,y2):\n\treturn (x1 - x2)**2 + (y1 - y2)**2\nprint('Yes' if dis(ax,ay,bx,by) == dis(bx,by,cx,cy) else 'No')"}, {"source_code": "ax,ay,bx,by,cx,cy=map(float, input().split())\nif (bx-cx!=ax-bx) or (by-cy!=ay-by):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "import sys\nimport math\n\nab_ = list(map(int, sys.stdin.readline().split()))\n\nab = math.sqrt((ab_[3] - ab_[1])**2 + (ab_[2] - ab_[0])**2)\nbc = math.sqrt((ab_[5] - ab_[3])**2 + (ab_[4] - ab_[2])**2)\nca = math.sqrt((ab_[5] - ab_[1])**2 + (ab_[4] - ab_[0])**2)\n\n\nif ab == bc and ab == ca and bc == ca and ab + bc > ca and ab + ca > bc and bc + ca > ab:\n print(\"Yes\")\n\nelif ab == bc and int(ca ** 2) == int(ab ** 2) + int(bc ** 2) and ab + bc > ca and ab + ca > bc and bc + ca > ab:\n print(\"Yes\")\n\nelse:\n print(\"No\")"}, {"source_code": "def slope(i,j):\n try:\n return abs(float(j[1]-i[1])/float(j[0]-i[0]))\n except:\n return -200\ndef len(i,j):\n return (j[1]-i[1])**2 +(i[0]-j[0])**2\nax,ay,bx,by,cx,cy=map(int,raw_input().split())\na=(ax,ay)\nb=(bx,by)\nc=(cx,cy)\nif slope(a,b)==slope(b,c):\n print 'No'\nelse:\n x=len(a,b)\n y=len(b,c)\n z=len(c,a)\n\n ans=0\n if x==y:\n ans+=1\n if y==z:\n ans+=1\n if z==x:\n ans+=1\n\n if ans>=1:\n print 'Yes'\n else:\n print 'No'\n"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\nk = (c - e) ** 2 + (d - f) ** 2\n#print(k, (a - e) ** 2 + (b - f) ** 2)\nif (a - c) ** 2 + (b - d) ** 2 == k and (a - e) ** 2 + (b - f) ** 2 != (2 ** 0.5) * k:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "import sys\nimport math\n\nlines = sys.stdin.read().splitlines()\nax, ay, bx, by, cx, cy = [int(x) for x in lines[0].split()]\ndef dist(p1x, p1y, p2x, p2y):\n return (p1x-p2x)**2+(p2x-p2y)**2 \ndist1 = dist(ax, ay, bx, by)\ndist2 = dist(bx, by, cx, cy)\nif dist1 == dist2 and (ax-bx != bx-cx):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "from sys import stdin, stdout\nINF = float('inf')\n\n\n\ndef angle(a, b):\n return (a[0] * b[1] - a[1] * b[0])\n\n\ndef find_coordinates(x1, y1, x2, y2, x3, y3):\n A = x2 - x1\n B = y2 - y1\n C = x3 - x1\n D = y3 - y1\n E = A * (x1 + x2) + B * (y1 + y2)\n F = C * (x1 + x3) + D * (y1 + y3)\n G = 2 * (A * (y3 - y2) - B * (x3 - x2))\n if not G:\n return (INF, INF)\n\n x = (D * E - B * F) / G\n y = (A * F - C * E) / G \n \n return (x, y)\n\n\ndef find_R(x1, y1, x2, y2, x3, y3):\n first, second, third = (x2 - x1, y2 - y1), (x3 - x2, y3 - y2), (x1 - x3, y1 - y3)\n a = (first[0] ** 2 + first[1] ** 2) ** 0.5\n b = (second[0] ** 2 + second[1] ** 2) ** 0.5\n c = (third[0] ** 2 + third[1] ** 2) ** 0.5\n \n if not angle(first, second):\n return 1\n else:\n return (a * b * c) / (2 * abs(angle(first, second)))\n \n\nx1, y1, x2, y2, x3, y3 = map(int, stdin.readline().split())\nchallengers = [find_coordinates(x1, y1, x2, y2, x3, y3), find_coordinates(x1, y1, x3, y3, x2, y2), find_coordinates(x2, y2, x1, y1, x3, y3), find_coordinates(x2, y2, x3, y3, x1, y1), find_coordinates(x3, y3, x1, y1, x2, y2), find_coordinates(x3, y3, x2, y2, x1, y1)]\nR = find_R(x1, y1, x2, y2, x3, y3)\nlabel = 0\n\nfor x, y in challengers:\n if x == INF:\n continue\n \n first, second, third = (x1 - x, y1 - y), (x2 - x, y2 - y), (x3 - x, y3 - y)\n print(((x - x1) ** 2 + (y - y1) ** 2) ** 0.5)\n if angle(first, second) == angle(second, third) and ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5 == R and ((x - x2) ** 2 + (y - y2) ** 2) ** 0.5 == R and ((x - x3) ** 2 + (y - y3) ** 2) ** 0.5 == R:\n label = 1\n\nif label:\n stdout.write('Yes')\nelse:\n stdout.write('No')"}, {"source_code": "def findCircle(x1, y1, x2, y2, x3, y3) :\n try:\n x12 = x1 - x2 \n x13 = x1 - x3 \n \n y12 = y1 - y2 \n y13 = y1 - y3 \n \n y31 = y3 - y1 \n y21 = y2 - y1 \n \n x31 = x3 - x1 \n x21 = x2 - x1\n \n sx13 = x1**2 - x3**2 \n \n \n sy13 = y1**2 - y3**2 \n \n sx21 = x2**2 - x1**2 \n sy21 = y2**2 - y1**2\n \n f = (((sx13) * (x12) + (sy13) * (x12) + (sx21) * (x13) + (sy21) * (x13)) // (2 * (y31) * (x12) - (y21) * (x13)))\n \n g = (((sx13) * (y12) + (sy13) * (y12) + (sx21) * (y13) + (sy21) * (y13)) // (2 * ((x31) * (y12) - (x21) * (y13)))) \n \n c = (-(x1**2) - y1**2 - 2 * g * x1 - 2 * f * y1)\n \n h = -g\n k = -f \n sqr_of_r = h * h + k * k - c \n\n\n r = sqr_of_r**0.5\n\n\n except Exception:\n return False \n \n return True\n \n\n\nx1, y1, x2, y2, x3, y3 = map(int,input().split())\nm = 1000000007\nif findCircle(x1, y1, x2, y2, x3, y3):\n if (((x1-x2)**2)%m + ((y1-y2)**2)%m) == (((x2-x3)**2)%m + ((y2-y3)**2)%m):\n print('Yes')\n else:\n print('No')\nelse:\n print('No')"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\nAB = (ax-bx)*(ax-bx)+(ay-by)*(ay-by)\nBC = (bx-cx)*(bx-cx)+(by-cy)*(by-cy)\nCA = (cx-ax)*(cx-ax)+(cy-ay)*(cy-ay)\nif AB == BC and not CA-(AB+BC) == 2*(AB*BC)**(1/2):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "x1,y1,x2,y2,x3,y3=map(int,input().split())\nif x1 == x2 and x1 == x3:\n if y1 == (y2+y3)/2 or y2 == (y1+y3)/2 or y3 == (y2+y1)/2:\n a = 1\n else:\n print('No')\n exit(0)\nif y1 == y2 and y1 == y3:\n if x1 == (x2+x3)/2 or x2 == (x1+x3)/2 or x3 == (x2+x1)/2:\n a = 1\n else:\n print('No')\n exit(0)\nm = (x1-x2)**2 + (y1-y2)**2\np = (x2-x3)**2 + (y2-y3)**2\nq = (x1-x3)**2 + (y1-y3)**2\nif m == p or m == q or p == q:\n print('Yes')\n exit(0)\nprint('No')"}, {"source_code": "ax,ay,bx,by,cx,cy=map(float,input().split())\nab=((ax-bx)**2+(ay-by)**2)**0.5\nbc=((bx-cx)**2+(by-cy)**2)**0.5\nca=((cx-ax)**2+(cy-by)**2)**0.5\n\nif ab==bc and ab+bc>=ca:\n A1=2*ax+2*cx\n B1=2*ay+2*cy\n C1=ax**2+ay**2-cx**2-cy**2\n A2=2*bx+2*cx\n B2=2*by+2*cy\n C2=bx**2+by**2-cx**2-cy**2\n A3=2*ax+2*bx\n B3=2*ay+2*by\n C3=ax**2+ay**2-bx**2-by**2\n d1=A1*B2-A2*B1\n d2=A2*B3-A3*B2\n if d1!=0:\n h1=(B1*C2-B2*C1)/d1\n k1=(C1*A2-C2*A1)/d1\n else:\n h1=0\n k1=0\n if d2!=0:\n h2=(B2*C3-B3*C2)/d2\n k2=(C2*A3-C3*A2)/d2\n else:\n h2=0\n k2=0\n if h1==h2 and k1==k2:\n print(\"Yes\")\n else:\n print(\"No\")\n #print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\nif((bx - ax) ** 2 + (by - ay) ** 2 == (cx- bx) ** 2 + (cy - by) ** 2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from math import sqrt\nax,ay,bx,by,cx,cy=map(int,input().split())\nif sqrt((ax-bx)**2+(ay-by)**2)==sqrt((cx-bx)**2+(cy-by)**2) and (ax+cx)/2!=bx and (ay+cy)/2!=by:print(\"Yes\")\nelse:print(\"No\")"}, {"source_code": "from math import *\nax, ay, bx, by, cx, cy = map(int, input().split())\nab = sqrt((ax - bx)*(ax - bx) + (ay - by)*(ay - by))\nbc = sqrt((cx - bx)*(cx - bx) + (cy - by)*(cy - by))\nline = ((ax-cx)*(by - ay)) == ((bx-ax)*(ay-cy))\nif ab == bc and not line:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "a=map(float,raw_input().split())\ntry:\n if(a[0]==a[2]and a[2]==a[4])or((a[2]-a[0])**2+(a[3]-a[1])**2)!=((a[2]-a[4])**2+(a[3]-a[5])**2)or(a[3]-a[1])/(a[2]-a[0])==(a[5]-a[3])/(a[4]-a[2]):print\"No\"\n else:print\"Yes\"\nexcept:\n print\"Yes\"\n"}, {"source_code": "a=map(int,raw_input().split())\n\nx1=a[0]\ny1=a[1]\nx2=a[2]\ny2=a[3]\nx3=a[4]\ny3=a[5]\n\nq=((a[0]-a[2])**2 + (a[1]-a[3])**2)**(0.5)\nb=((a[0]-a[4])**2 + (a[1]-a[5])**2)**(0.5)\nc=((a[4]-a[2])**2 + (a[3]-a[5])**2)**(0.5)\n\ns = (q + b - c) * (q + c - b) * (c + b - q)\nf=0\neps = 0.0000001\nif q == b == c:\n\tf=1\nelif q!= b != c:\n\tf=0\nelse:\n f=1\n\nif abs(s) > eps and f==1:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "x = input()\n#a=x.split()\n#print(b[0],b[1],b[2])\na = [int(k) for k in x.split()]\nflag=1\ndist = (a[2]-a[0])*(a[2]-a[0])+(a[3]-a[1])*(a[3]-a[1])\ndist1 = (a[5]-a[3])*(a[5]-a[3])+(a[4]-a[2])*(a[4]-a[2])\nif(a[2]-a[0]!=0 and a[4]-a[2]!=0):\n s1 = (a[3]-a[1])*(a[4]-a[2])\n s2 = (a[5]-a[3])*(a[2]-a[0])\n if(s1==s2):\n flag=0\nif(flag==1 and dist==dist1):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "x1,y1,x2,y2,x3,y3=map(int,input().split())\nif x1 == x2 and x1 == x3:\n if y1 == (y2+y3)/2 or y2 == (y1+y3)/2 or y3 == (y2+y1)/2:\n a = 1\n else:\n print('No')\n exit(0)\nif y1 == y2 and y1 == y3:\n if x1 == (x2+x3)/2 or x2 == (x1+x3)/2 or x3 == (x2+x1)/2:\n a = 1\n else:\n print('No')\n exit(0)\nm = (x1-x2)**2 + (y1-y2)**2\np = (x2-x3)**2 + (y2-y3)**2\nq = (x1-x3)**2 + (y1-y3)**2\nif m == p or m == q or p == q:\n print('Yes')\n exit(0)\nprint('No')"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\nif (a-c)*(a-c)+(b-d)*(b-d)==(c-e)*(c-e)+(d-f)*(d-f):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "x = input()\n#a=x.split()\n#print(b[0],b[1],b[2])\na = [int(k) for k in x.split()]\n\ndist = (a[2]-a[0])*(a[2]-a[0])+(a[3]-a[1])*(a[3]-a[1])\ndist1 = (a[5]-a[3])*(a[5]-a[3])+(a[4]-a[2])*(a[4]-a[2])\nif(dist==dist1):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\nab=((ax-bx)**2+(ay-by)**2)**0.5\nbc=((bx-cx)**2+(by-cy)**2)**0.5\nif ab==bc and (ay-by)*(bx-cx)!=(by-cy)*(ax-bx):\n print(\"Yes\") \nelse:\n print(\"No\")"}, {"source_code": "a = [int(i) for i in input().split()]\nif((a[0]-a[2])**2+(a[1]-a[3])**2 == (a[4]-a[2])**2+(a[5]-a[3])**2):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "x1,y1,x2,y2,x3,y3 = map(int,input().split());\na = [x1,y1];\nb = [x2,y2];\nc = [x3,y3];\nangular1 = abs(abs((y1-y2))/(abs(x1-x2) + 0.0000001));\nangular2 = abs(abs((y2-y3))/(abs(x2-x3) + 0.0000001));\n#print(angular1,angular2);\nres = False;\nalinhado = False;\nif angular1==angular2:\n\talinhado = True;\ndAB = (a[0]-b[0])**2 + (a[1]-b[1])**2\ndAC = (a[0]-c[0])**2 + (a[1]-c[1])**2\ndBC = (c[0]-b[0])**2 + (c[1]-b[1])**2\nif(dAB==dBC):\n\tres = True;\nif(res and not alinhado):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "a=map(int,raw_input().split())\n\nx1=a[0]\ny1=a[1]\nx2=a[2]\ny2=a[3]\nx3=a[4]\ny3=a[5]\n\nq=((a[0]-a[2])**2 + (a[1]-a[3])**2)**(0.5)\nb=((a[0]-a[4])**2 + (a[1]-a[5])**2)**(0.5)\nc=((a[4]-a[2])**2 + (a[3]-a[5])**2)**(0.5)\nf=0\ns=(y3-y2)*(x2-x1)\nt=(y2-y1)*(x3-x2)\nif s!=t and q==c:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(long, raw_input().split())\nab = (ax-bx)**2+(ay-by)**2\nbc = (bx-cx)**2+(by-cy)**2\nif ab==bc:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "import sys\nimport math\nimport itertools\nimport collections\n\n\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef wr(arr): return ' '.join(map(str, arr))\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n newnumber = 0\n while number > 0:\n newnumber += number % base\n number //= base\n return newnumber\ndef cdiv(n, k): return n // k + (n % k != 0)\n\n\nc = li()\nv1 = [c[2] - c[0], c[3] - c[1]]\nv2 = [c[4] - c[2], c[5] - c[3]]\nlenv1 = math.sqrt(v1[0] ** 2 + v1[1] ** 2)\nlenv2 = math.sqrt(v2[0] ** 2 + v2[1] ** 2)\nif abs(lenv1 - lenv2) < 10 ** -6 and abs((v1[0] * v2[0] + v1[1] * v2[1])) < (lenv1 * lenv2):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "''' ===============================\n -- @uthor : Kaleab Asfaw\n -- Handle : kaleabasfaw2010\n -- Bio : High-School Student\n ==============================='''\n\n# Fast IO\nimport sys\nimport os\nfrom io import BytesIO, IOBase\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = \"x\" in file.mode or \"r\" not in file.mode; self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b: break\n ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0; return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); self.newlines = b.count(b\"\\n\") + (not b); ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1; return self.buffer.readline()\n def flush(self):\n if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode(\"ascii\")); self.read = lambda: self.buffer.read().decode(\"ascii\"); self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# Others\n# from math import floor, ceil, gcd\n# from decimal import Decimal as d\nmod = 10**9+7\ndef lcm(x, y): return (x * y) / (gcd(x, y))\ndef fact(x, mod=mod):\n ans = 1\n for i in range(1, x+1): ans = (ans * i) % mod\n return ans\ndef arr2D(n, m, default=0): return [[default for j in range(m)] for i in range(n)]\ndef arr3D(n, m, r, default=0): return [[[default for k in range(r)] for j in range(m)] for i in range(n)]\ndef sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}\nclass DSU:\n def __init__(self, length): self.length = length; self.parent = [-1] * self.length # O(log(n))\n def getParent(self, node, start): # O(log(n))\n if node >= self.length: return False\n if self.parent[node] < 0:\n if start != node: self.parent[start] = node\n return node\n return self.getParent(self.parent[node], start)\n def union(self, node1, node2): # O(log(n))\n parent1 = self.getParent(node1, node1); parent2 = self.getParent(node2, node2)\n if parent1 == parent2: return False\n elif self.parent[parent1] <= self.parent[parent2]: self.parent[parent1] += self.parent[parent2]; self.parent[parent2] = parent1\n else: self.parent[parent2] += self.parent[parent1]; self.parent[parent1] = parent2\n return True\n def getCount(self, node): return -self.parent[self.getParent(node, node)] # O(log(n))\n\nminInt = 10**(-9)\n\ndef solve(lst):\n if lst[0] == lst[2] == lst[4]:\n return \"No\"\n a, b, c = [None] * 3\n if lst[0] - lst[2] != 0:\n a = (lst[1] - lst[3]) / (lst[0] - lst[2])\n if lst[2] - lst[4] != 0:\n b = (lst[3] - lst[5]) / (lst[2] - lst[4])\n if lst[0] - lst[4] != 0:\n c = (lst[1] - lst[5]) / (lst[0] - lst[4])\n \n if a == None or b == None or c == None:\n pass\n else:\n if abs(a-b) <= minInt and abs(b-c) <= minInt and abs(a-c) <= minInt:\n return \"No\"\n \n disAB = (((lst[0] - lst[2]) ** 2) + ((lst[1] - lst[3]) ** 2)) ** 0.5\n disBC = (((lst[2] - lst[4]) ** 2) + ((lst[3] - lst[5]) ** 2)) ** 0.5\n\n if disAB == disBC:\n return \"Yes\"\n return \"No\"\n\nlst = list(map(int, input().split()))\nprint(solve(lst))"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int, input().split())\ndistab=((ax-bx)**2+(ay-by)**2)**0.5\ndistbc=((cx-bx)**2+(cy-by)**2)**0.5\ndifabx=abs(ax-bx)\ndifbcx=abs(cx-bx)\ndifaby=abs(ay-by)\ndifbcy=abs(cy-by)\nflag=True\nif(difbcy==0 and difabx!=0):\n flag=False\nelif(difabx==0 and difbcy!=0):\n flag=False\nelif(difaby==0 and difbcx!=0):\n flag=False\nelif(difbcx==0 and difaby!=0):\n flag=False\nelif(difabx!=0 and difaby!=0 and difbcx!=0 and difbcy!=0):\n if(distbc!=distab or (difabx/difbcy!=difaby/difbcx)):\n flag=False\n \nif(flag):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "import math \n\nax, ay, bx, by, cx, cy = list(map(int, input().split()))\n\nabsq = (ax - bx) ** 2 + (ay - by) ** 2\nbcsq = (bx - cx) ** 2 + (by - cy) ** 2\nacsq = (ax - cx) ** 2 + (ay - cy) ** 2\n\non_one_line = False\n\nlengths = [math.sqrt(absq), math.sqrt(bcsq), math.sqrt(acsq)]\nlengths.sort()\n# print(lengths)\nif int((lengths[0] + lengths[1]) ** 2) == int(lengths[2] ** 2):\n\ton_one_line = True\n\nif absq == bcsq and not on_one_line:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "def sqr(a):\n\treturn a*a\n\nax,ay,bx,by,cx,cy = list(map(int,input().split()))\nif(abs(sqr(bx-ax)+sqr(by-ay)) == abs(sqr(bx-cx)+sqr(by-cy)) and bx!=(ax+cx)/2 and by!=(ay+cy)/2):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "a_1,a_2,b_1,b_2,c_1,c_2=map(int,input().split())\ntemp_1=((a_1-b_1)**2+(a_2-b_2)**2)**0.5\ntemp_2=((b_1-c_1)**2+(b_2-c_2)**2)**0.5\nif( temp_1 != temp_2 ):\n print('No')\nelse:\n if(b_1-a_1==0 and c_1-a_1==0):\n print('No')\n elif(b_1-a_1==0 or c_1-a_1==0):\n print('Yes')\n else:\n slope_1=(b_2-a_2)/(b_1-a_1)\n slope_2=(c_2-a_2)/(c_1-a_1)\n if( slope_1 == slope_2):\n print('No')\n else:\n print('Yes')"}, {"source_code": "from __future__ import print_function\n\nfrom fractions import Fraction\nfrom math import atan2\n\n\ndef get_array(typ = int):\n return [typ(w) for w in raw_input().split()]\n\nax, ay, bx, by, cx, cy = get_array()\n\nd1 = (ax - bx) ** 2 + (ay - by) ** 2\nd2 = (bx - cx) ** 2 + (by - cy) ** 2\nd3 = (cx - ax) ** 2 + (cy - ay) ** 2\n\nm1 = atan2(ay - by, ax - bx)\nm2 = atan2(by - cy, bx - cx)\nm3 = atan2(cy - ay, cx - ax)\n\nd = sorted([d1, d2, d3])\nif (d[0] == d[1] or d[1] == d[2]) and not (m1 == m2 and m2 == m3):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "import decimal\nD = decimal.Decimal\ndef main():\n l=map(long,raw_input().split())\n dist1=(D((l[2]-l[0])**2+(l[3]-l[1])**2)).sqrt()\n dist2=(D((l[4]-l[2])**2+(l[5]-l[3])**2)).sqrt()\n dist3=(D((l[4]-l[0])**2+(l[5]-l[1])**2)).sqrt()\n print dist1,dist2,dist3,dist1+dist2\n if dist1==dist2 and (dist1+dist2)>dist3:\n print \"Yes\"\n else:\n print \"No\"\nmain() "}, {"source_code": "ax, ay, bx, by, cx, cy = map(long, raw_input().split())\n\n# if the point exists, it must be the intersection of three (chuizhipingfenxian)\n# meanwhile, if a->b, b->c and a,b,c on a same circle, then |ab| = |bc|\n\nlen_ab = (bx - ax) * (bx - ax) + (by - ay) * (by - ay)\nlen_bc = (cx - bx) * (cx - bx) + (cy - by) * (cy - by)\n\nif len_ab == len_bc:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\nif (ax-bx)**2+(ay-by)**2==(bx-cx)**2+(by-cy)**2:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "def d(x,y,xx,yy):return ((x-xx)**2+(y-yy)**2)**0.5\nx1,y1,x2,y2,x3,y3=map(int,input().split())\nprint(['NO','YES'][d(x1,y1,x2,y2)==d(x2,y2,x3,y3)and(y2-y1)*(x3-x2)!=(y3-y2)*(x2-x1)])\n"}, {"source_code": "def slope(i,j):\n try:\n return abs(float(j[1]-i[1])/float(j[0]-i[0]))\n except:\n return -200\nax,ay,bx,by,cx,cy=map(int,raw_input().split())\na=(ax,ay)\nb=(bx,by)\nc=(cx,cy)\nif slope(a,b)==slope(b,c):\n print 'No'\nelse:\n print 'Yes'\n"}, {"source_code": "a_1,a_2,b_1,b_2,c_1,c_2=map(int,input().split())\ntemp_1=((a_1-b_1)**2+(a_2-b_2)**2)**0.5\ntemp_2=((b_1-c_1)**2+(b_2-c_2)**2)**0.5\nif( temp_1 != temp_2 ):\n print('No')\nelse:\n if(b_1-a_1==0 and c_1-a_1==0):\n print('No')\n elif(b_1-a_1==0 or c_1-a_1==0):\n print('Yes')\n else:\n slope_1=(b_2-a_2)/(b_1-a_1)\n slope_2=(c_2-a_2)/(c_1-a_1)\n if( slope_1 == slope_2):\n print('No')\n else:\n print('Yes')"}, {"source_code": "class point:\n x=0\n y=0\n\n def __init__(self,x,y):\n self.x=x\n self.y=y\n\n def __cmp__(self, b):\n if(self.cmp(b)):\n return -1\n elif b.cmp(self):\n return 1\n else:\n return 0\n\n def cmp(self, b):\n if (self.x == b.x):\n return self.y < b.y\n return self.x < b.x\n\n def printf(self):\n return self.x,self.y\n\ndef judge(a,b):\n return a.x*b.y==a.y*b.x\n\ndef dis(a,b):\n x=a.x*a.x+a.y*a.y\n y=b.x*b.x+b.y*b.y\n return x==y\n\nax,ay,bx,by,cx,cy=map(int,raw_input().split())\nA=[]\nA.append(point(ax,ay))\nA.append(point(bx,by))\nA.append(point(cx,cy))\nA=sorted(A)\nB=point(A[1].x-A[0].x,A[1].y-A[0].y)\nC=point(A[2].x-A[1].x,A[2].y-A[1].y)\nif not judge(B,C):\n print 'Yes'\nelif dis(B,C):\n print 'Yes'\nelse:\n print 'No'\n"}, {"source_code": "##n = int(input())\n##a = list(map(int, input().split()))\n##print(' '.join(map(str, res)))\n\n[ax, ay, bx, by, cx, cy] = list(map(int, input().split()))\ndx1 = ax-bx\ndy1 = ay-by\ndx2 = cx-bx\ndy2 = cy-by\nif dx1*dy2 == dx2*dy1 or dx1*dx1+dy1*dy1 != dx2*dx2+dy2&dy2:\n print('no')\nelse:\n print('yes')\n"}, {"source_code": "import sys\nclass Point:\n def __init__(self, x=None, y=None):\n self.x = x\n self.y = y\n\nclass Line:\n def __init__(self):\n self.isvertical = None\n self.x = None\n self.k = None\n self.b = None\n\nax, ay, bx, by, cx, cy = map(int, input().split())\na = Point(ax, ay)\nb = Point(bx, by)\nc = Point(cx, cy)\n\ndef line2points(p1, p2):\n result = Line()\n if(p1.x == p2.x):\n result.isvertical = True\n result.x = p1.x\n return result\n result.k = (p2.y - p1.y)/(p2.x - p1.x)\n result.b = p1.y - ((p1.x * (p2.y - p1.y))/(p2.x - p1.x))\n result.isvertical = False\n return result\n\ndef intersection(l1, l2):\n result = Point()\n if(l1.isvertical and l2.isvertical):\n return result\n if(l1.k == l2.k):\n return result\n if(l1.isvertical):\n result.x = l1.x\n result.y = l2.k * result.x + l2.b\n return result\n if(l2.isvertical):\n result.x = l2.x\n result.y = l1.k * result.x + l1.b\n return result\n result.x = (l2.b - l1.b)/(l1.k - l2.k)\n result.y = l1.k * result.x + l1.b\n return result\n\ndef d(p1, p2):\n return (p1.x - p2.x)**2 + (p1.y - p2.y)**2\n\ndef perline(l, p):\n result = Line()\n if(l.isvertical):\n result.isvertical = False\n result.k = 0\n result.b = p.y\n return result\n if(l.k == 0):\n result.isvertical = True\n result.x = p.x\n return result\n result.k = (-1)/l.k\n result.b = p.y - result.k * p.x\n return result\n\nmab = Point((a.x + b.x)/2, (a.y + b.y)/2)\nmbc = Point((b.x + c.x)/2, (b.y + c.y)/2)\nab = line2points(a, b)\nbc = line2points(b, c)\n\nperab = perline(ab, mab)\nperbc = perline(bc, mbc)\n\ninter = intersection(perab, perbc)\nif(inter.x is None and inter.y is None):\n print(\"No\")\n sys.exit()\n\ndist = []\ndist.append(d(inter, a))\ndist.append(d(inter, b))\ndist.append(d(inter, c))\ndist = sorted(dist)\nif(dist[-1] - dist[0] == 0 and d(c,b) == d(a, b)):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "def dist(x1,y1,x2,y2):\n d=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)\n return d\nax,ay,bx,by,cx,cy=input().strip().split(' ')\nax,ay,bx,by,cx,cy=[int(ax),int(ay),int(bx),int(by),int(cx),int(cy)]\nif(dist(ax,ay,bx,by)==dist(bx,by,cx,cy)):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "import sys\nimport math\nimport itertools\nimport collections\n\n\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef wr(arr): return ' '.join(map(str, arr))\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n newnumber = 0\n while number > 0:\n newnumber += number % base\n number //= base\n return newnumber\ndef cdiv(n, k): return n // k + (n % k != 0)\n\n\nc = li()\nv1 = [c[2] - c[0], c[3] - c[1]]\nv2 = [c[4] - c[2], c[5] - c[3]]\nlenv1 = math.sqrt(v1[0] ** 2 + v1[1] ** 2)\nlenv2 = math.sqrt(v2[0] ** 2 + v2[1] ** 2)\nif abs(lenv1 - lenv2) < 10 ** -6 and abs((v1[0] * v2[0] + v1[1] * v2[1])) < (lenv1 * lenv2):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\nab2 = (ax - bx) * (ax - bx) + (ay - by) * (ay - by) \nbc2 = (bx - cx) * (bx - cx) + (by - cy) * (by - cy) \n\nprint(\"YES\" if ab2 == bc2 else \"NO\")"}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, raw_input().split())\nab2 = (ax-bx)*(ax-bx)+(ay-by)*(ay-by)\nbc2 = (cx-bx)*(cx-bx)+(cy-by)*(cy-by)\nif ab2 == bc2:\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\n\nA=ax*ax+ay*ay\nB=bx*bx+by*by\nC=cx*cx+cy*cy\nG=(cy-by)*ax+(ay-cy)*bx+(by-ay)*cx\n\ntry:\n x=( (B-C)*ay+(C-A)*by+(A-B)*cy )/(2*G)\n y=( (C-B)*ax+(A-C)*bx+(B-A)*cx )/(2*G)\nexcept:\n print('No')\n exit()\n\n\nif (ax-x)*(bx-x)+(ay-y)*(by-y) == (bx-x)*(cx-x)+(by-y)*(cy-y):\n print('Yes')\nelse:\n print('No')\n "}, {"source_code": "ax, ay, bx, by, cx, cy = map(int, input().split())\nif (bx - ax) ** 2 + (by - ay) ** 2 == (bx - cx) ** 2 + (by - cy) ** 2 and (bx - ax)*(cy - by) + (by - ay)*(cx - bx) != 0:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "x1,y1,x2,y2,x3,y3=map(float,input().split())\n\nstatus = True\n\ntry:\n x = (x3**2*(-y1 + y2) + x2**2*(y1 - y3) - (x1**2 + (y1 - y2)*(y1 - y3))*(y2 - y3))/(2*(x3*(-y1 + y2) + x2*(y1 - y3) + x1*(-y2 + y3)))\n \n y = (-x2**2*x3 + x1**2*(-x2 + x3) + x3*(y1 - y2)*(y1 + y2) + \n x1*(x2**2 - x3**2 + y2**2 - y3**2) + \n x2*(x3**2 - y1**2 + y3**2))/(2*(x3*(y1 - y2) + x1*(y2 - y3) + \n x2*(-y1 + y3)))\nexcept:\n status = False\n\nif status == True and x!=x1 and x!=x2 and x!=x3:\n m1 = (y-y1)/(x-x1)\n m2 = (y-y2)/(x-x2)\n m3 = (y-y3)/(x-x3)\n if (abs(m1-m2)*abs(1+m2*m3) != abs(m2-m3)*abs(1+m1*m2)):\n status = False\nelif status == True:\n lhs=None\n rhs=None\n \n if x==x1 and x!=x2:\n lhs = abs((y-y2)/(x-x2))\n elif x!=x1 and x==x2:\n lhs = abs((y-y1)/(x-x1))\n else:\n status=False\n \n if status==True and x==x2 and x!=x3:\n rhs = abs((y-y3)/(x-x3))\n elif x!=x2 and x==x3:\n rhs = abs((y-y2)/(x-x2))\n else:\n status=False\n \nif status:\n print('Yes')\nelse:\n print('No')\n "}, {"source_code": "from sys import stdin\ndef dis(x1,y1,x2,y2):\n return (x1-x2)**2 + (y1-y2)**2\nx1,y1,x2,y2,x3,y3 = map(int,stdin.readline().split())\ns = set()\ns.add(dis(x1,y1,x2,y2))\ns.add(dis(x1,y1,x3,y3))\ns.add(dis(x3,y3,x2,y2))\nif len(s)<=2 and (x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))!=0:\n print 'Yes'\nelse:\n print 'No'"}, {"source_code": "ax,ay,bx,by,cx,cy = [ int(x) for x in input().split() ]\n\nif (ax - bx) * (ax - bx) + (ay - by) * (ay - by) == (cx - bx) * (cx - bx) + (cy - by) * (cy - by):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "from math import sqrt\n\ndef is_approximately_right_angled(a, b, c):\n a, b, c = sorted([a, b, c])\n return abs(a * a + b * b - c * c) < 0.1\n\n\nx1,y1,x2,y2,x3,y3=map(int,raw_input().split())\nside1 = sqrt((x1 - x2)**2 + (y1-y2)**2)\nside2 = sqrt((x2 - x3)**2 + (y2-y3)**2)\nside3 = sqrt((x3 - x1)**2 + (y3-y1)**2)\n\ntri= [side1, side2, side3]\n#check=is_approximately_right_angled(side1,side2,side3)\ntri.sort()\n#print check\nif tri[0] < tri[1]+tri[2] and tri[0]+tri[1]>tri[2] and tri[2]+tri[0]>tri[1]:\n if (tri[1] == tri[2] or tri[1] == tri[0]):\n print('Yes')\n else:\n print('No')\nelse:\n print('No')\n"}, {"source_code": "t = list(map(int, input().split()))\nd = lambda i: (t[i] - t[i + 2]) ** 2 + (t[i + 1] - t[i + 3]) ** 2\nprint(['Yes', 'No'][d(0) != d(2)])"}, {"source_code": "ax, ay, bx, by, cx, cy = input().split()\nax, ay, bx, by, cx, cy = int(ax), int(ay), int(bx), int(by), int(cx), int(cy)\ndistant_1 = ((bx - ax) ** 0.5 + (by - ay) ** 0.5) ** 0.5\ndistant_2 = ((bx - cx) ** 0.5 + (by - cy) ** 0.5) ** 0.5\n\nif distant_1 == distant_2:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "ax,ay,bx,by,cx,cy=map(int,input().split())\nl1=(ax-bx)**2+(ay-by)**2\nl2=(cx-bx)**2+(cy-by)**2\nif (l2 == l1 ):\n print(\"yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "import math \n\nax, ay, bx, by, cx, cy = list(map(int, input().split()))\n\nabsq = (ax - bx) ** 2 + (ay - by) ** 2\nbcsq = (bx - cx) ** 2 + (by - cy) ** 2\nacsq = (ax - cx) ** 2 + (ay - cy) ** 2\n\non_one_line = False\n\nlengths = [math.sqrt(absq), math.sqrt(bcsq), math.sqrt(acsq)]\nlengths.sort()\n# print(lengths)\nif int((lengths[0] + lengths[1]) ** 2) == int(lengths[2] ** 2):\n\ton_one_line = True\n\nif absq == bcsq and not on_one_line:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "ax,ay,bx,by,cx,cy=map(float,input().split())\nab=((ax-bx)**2+(ay-by)**2)**0.5\nbc=((bx-cx)**2+(by-cy)**2)**0.5\nca=((cx-ax)**2+(cy-ay)**2)**0.5\n\nif ab==bc and ab+bc>=ca:\n '''\n A1=2*ax+2*cx\n B1=2*ay+2*cy\n C1=ax**2+ay**2-cx**2-cy**2\n A2=2*bx+2*cx\n B2=2*by+2*cy\n C2=bx**2+by**2-cx**2-cy**2\n A3=2*ax+2*bx\n B3=2*ay+2*by\n C3=ax**2+ay**2-bx**2-by**2\n d1=A1*B2-A2*B1\n d2=A2*B3-A3*B2\n if d1!=0:\n h1=(B1*C2-B2*C1)/d1\n k1=(C1*A2-C2*A1)/d1\n else:\n h1=0\n k1=0\n if d2!=0:\n h2=(B2*C3-B3*C2)/d2\n k2=(C2*A3-C3*A2)/d2\n else:\n h2=0\n k2=0\n if h1==h2 and k1==k2:\n print(\"Yes\")\n else:\n print(\"No\")\n '''\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "from decimal import *\n\ndef is_midpoint(p1,p2,p3):\n if (p1[0]+p2[0])/2==p3[0] and (p1[1]+p2[1])/2==p3[1]:\n return True\n else:\n return False\n\ndef distance(p1,p2):\n return (((p2[0]-p1[0])**2)+((p2[1]-p1[1])**2))**0.5\n\ndef same_slope(p1,p2,p3):\n #print(distance(p1,p2),p1,p2,(p2[0]-p1[0])**2,(p2[1]-p1[1])**2,distance(p2,p3))\n if is_midpoint(p1,p2,p3) or is_midpoint(p2,p1,p3) or is_midpoint(p1,p3,p2):\n return False\n elif distance(p1,p2)==distance(p2,p3):\n return True\n else:\n return False\n\na_x,a_y,b_x,b_y,c_x,c_y=map(int,input().split())\np1=[a_x,a_y]\np2=[b_x,b_y]\np3=[c_x,c_y]\nif same_slope(p1,p2,p3):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import decimal\nD = decimal.Decimal\ndef main():\n l=map(long,raw_input().split())\n dist1=round((D((l[2]-l[0])**2+(l[3]-l[1])**2)).sqrt(),8)\n dist2=round((D((l[4]-l[2])**2+(l[5]-l[3])**2)).sqrt(),8)\n dist3=round((D((l[4]-l[0])**2+(l[5]-l[1])**2)).sqrt(),8)\n if dist1==dist2 and (dist1+dist2)!=dist3:\n print \"Yes\"\n else:\n print \"No\"\nmain() "}, {"source_code": "def get_len_sq(a, b):\n return (a[0] - b[0])**2 + (a[1] - b[1])**2\n\nax, ay, bx, by, cx, cy = map(int, input().split())\na = (ax, ay)\nb = (bx, by)\nc = (cx, cy)\nf = get_len_sq\nif f(a,b) == f(b,c):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "from sys import stdin\ndef dis(x1,y1,x2,y2):\n return (x1-x2)**2 + (y1-y2)**2\nx1,y1,x2,y2,x3,y3 = map(int,stdin.readline().split())\ns = set()\ns.add(dis(x1,y1,x2,y2))\ns.add(dis(x1,y1,x3,y3))\ns.add(dis(x3,y3,x2,y2))\nif len(s)<=2 and (x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))!=0:\n print 'Yes'\nelse:\n print 'No'"}, {"source_code": "from math import sqrt\nl = raw_input().split()\n(ax, ay, bx, by, cx, cy) = [int(x) for x in l]\n\ndab = sqrt((ax - bx)**2 + (ay - by)**2)\ndbc = sqrt((bx - cx)**2 + (by - cy)**2)\n\nif dab == dbc:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "def is_midpoint(p1,p2,p3):\n if (p1[0]+p2[0])/2==p3[0] or (p1[1]+p2[1])/2==p3[1]:\n return True\n else:\n return False\n\ndef distance(p1,p2):\n return (((p2[0]-p1[0])**2)+((p2[1]-p1[1])**2))**0.5\n\ndef same_slope(p1,p2,p3):\n if is_midpoint(p1,p2,p3) or is_midpoint(p2,p1,p3) or is_midpoint(p1,p3,p2):\n return False\n elif distance(p1,p2)==distance(p2,p3):\n return True\n else:\n return False\n\na_x,a_y,b_x,b_y,c_x,c_y=map(int,input().split())\np1=[a_x,a_y]\np2=[b_x,b_y]\np3=[c_x,c_y]\nif same_slope(p1,p2,p3):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import math\na_1,a_2,b_1,b_2,c_1,c_2 = map(int,input().split())\ndist_1 = (a_1-b_1)**2 + (a_2-b_2)**2\ndist_2 = (a_1-c_1)**2 + (a_2-c_2)**2\ndist_3 = (b_1-c_1)**2 + (b_2 - c_2)**2\ndef checkTriangle(x1, y1, x2, y2, x3, y3): \n \n # Calculation the area of \n # triangle. We have skipped \n # multiplication with 0.5 \n # to avoid floating point \n # computations \n a = (x1 * (y2 - y3) +\n x2 * (y3 - y1) + \n x3 * (y1 - y2)) \n if a == 0:\n return True\n else:\n return False\ndef type(sqa,sqb,sqc): \n \n if (sqa == sqa + sqb or\n sqb == sqa + sqc or\n sqc == sqa + sqb): \n return True \n \n elif(sqa > sqc + sqb or\n sqb > sqa + sqc or\n sqc > sqa + sqb):\n return True \n \n \n else: \n return False\n \n\n\nif checkTriangle(a_1,a_2,b_1,b_2,c_1,c_2)== True:\n print(\"No\")\nelif dist_1 == dist_2 and type(dist_1,dist_2,dist_3) == True:\n print(\"Yes\")\nelif dist_2 == dist_3 and type(dist_1,dist_2,dist_3) == True:\n print(\"Yes\")\nelif dist_3 == dist_1 and type(dist_1,dist_2,dist_3) == True:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "ax, ay, bx, by, cx, cy = map(long, raw_input().split())\nab = ((ax-bx)**2+(ay-by)**2)**0.5\nbc = ((bx-cx)**2+(by-cy)**2)**0.5\nif ab==bc and (ay-by)*(cx-ax)+(bx-ax)*(cy-ay)!=0:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "import math \n\nax, ay, bx, by, cx, cy = list(map(int, input().split()))\n\nabsq = (ax - bx) ** 2 + (ay - by) ** 2\nbcsq = (bx - cx) ** 2 + (by - cy) ** 2\nacsq = (ax - cx) ** 2 + (ay - cy) ** 2\n\non_one_line = False\n\nlengths = [math.sqrt(absq), math.sqrt(bcsq), math.sqrt(acsq)]\nlengths.sort()\n# print(lengths)\nif lengths[0] + lengths[1] - lengths[2] < 0.001:\n\ton_one_line = True\n\nif absq == bcsq and not on_one_line:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "import math\ndef slope(a,b,c,d):\n if a==c:\n return math.inf\n else:\n return((d-b)/(c-a))\ndef length(a,b,c,d):\n return (d-b)**2+(c-a)**2\n\nax,ay,bx,by,cx,cy=map(int,input().split())\nif slope(ax,ay,bx,by)==slope(bx,by,cx,cy) and slope(bx,by,cx,cy)==slope(ax,ay,cx,cy):\n print('No')\nelse:\n if length(ax,ay,bx,by) == length(bx,by,cx,cy) or length(bx,by,cx,cy)==length(ax,ay,cx,cy) or length(ax,ay,bx,by)==length(ax,ay,cx,cy):\n print('Yes')\n else:\n print('No')\n"}, {"source_code": "a=map(int,raw_input().split())\n\nx1=a[0]\ny1=a[1]\nx2=a[2]\ny2=a[3]\nx3=a[4]\ny3=a[5]\n\nq=((a[0]-a[2])**2 + (a[1]-a[3])**2)**(0.5)\nb=((a[0]-a[4])**2 + (a[1]-a[5])**2)**(0.5)\nc=((a[4]-a[2])**2 + (a[3]-a[5])**2)**(0.5)\n\ns = (q + b - c) * (q + c - b) * (c + b - q)\nf=0\neps = 0.0000001\nif q == b == c:\n\tf=1\nelif q!= b != c:\n\tf=0\nelse:\n f=1\n\nif abs(s) > eps and f==1:\n print \"Yes\"\nelse:\n print \"No\"\n"}], "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab"} {"source_code": "x = int(input())\nlp = [0 for x in range(x+1)]\nfor i in range(2, x+1):\n if(lp[i]==0):\n for j in range(i*2, x+1, i):\n lp[j] = i\n lp[i] = i - lp[i] + 1\np = x\nfor i in range(lp[x], x+1):\n p = min(p, lp[i])\nprint(p)\n", "positive_code": [{"source_code": "\n\na = []\nfor i in range(1000005):\n a.append(0)\n\nn = int(input())\nans = n\n\n\nfor i in range(2,n+1):\n if not a[i]:\n j = 2*i\n while(j <= n):\n a[j] = i\n j+=i\n a[i] = i - a[i] +1\n\n#print (a)\n\nfor i in range(a[n],n+1):\n ans = min(ans,a[i])\n #print (ans)\n\nprint(ans)\n"}, {"source_code": "x2 = int(input())\nnum = []\nfor val in range(1000010):\n num.append(0)\nfor i in range(2,x2):\n if(num[i]==0):\n for j in range(i+i,x2+1,i):\n num[j]=i\nprim = x2 - num[x2] + 1\nminn = 10000000\nfor i in range(prim,x2+1):\n minn = min(minn,i - num[i] + 1)\nprint(minn)"}, {"source_code": "n = int(input())\nans = n\nf = [0]*(n+1)\nfor i in range(2, n+1):\n if f[i]==0:\n for j in range(i*2, n+1, i):\n f[j] = i\n f[i] = i-f[i]+1\nfor i in range(f[n], n+1):\n ans = min(ans, f[i])\nprint(ans)"}, {"source_code": "def prime_factors(n):\n f = 2\n while f*f<=n:\n while n%f == 0:\n yield f\n n //= f\n f += 1\n if n>1:\n yield n\nx2 = int(input())\nans = x2\n# print([x for x in prime_factors(x2)])\nfor x1 in range(x2-max([x for x in prime_factors(x2)])+1, x2+1):\n # print(x1, [x for x in prime_factors(x1)])\n tmp = x1-max([x for x in prime_factors(x1)])+1\n # print(tmp)\n if tmp>=3:\n ans = min(ans, tmp)\n if ans < x1//2:break\nprint(ans)"}, {"source_code": "n = int(input())\nans = n\nf = [0]*(n+1)\nfor i in range(2, n+1):\n if f[i]==0:\n for j in range(i*2, n+1, i):\n f[j] = i\n f[i] = i-f[i]+1\nans = min(ans, min([f[i] for i in range(f[n], n+1)]))\nprint(ans)"}, {"source_code": "n = int(input())\n\nans = n\n\nf = [0]*(n+1)\n\nfor i in range(2, n+1):\n\n if f[i]==0:\n\n for j in range(i*2, n+1, i):\n\n f[j] = i\n\n f[i] = i-f[i]+1\n\nfor i in range(f[n], n+1):\n\n ans = min(ans, f[i])\n\nprint(ans)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "N = int(input())\nP = [0 for _ in range(1000010)]\n# store the largest prime factor of a number --> if number is prime, mark its multiples\nfor i in range(2, N):\n if P[i] == 0:\n for j in range(2*i, N+1, i):\n P[j] = i\nans = 1000010\nfor i in range(N-P[N]+1, N+1):\n ans = min(ans, i-P[i]+1)\nprint(ans)\n"}, {"source_code": "N=1<<20\np=[0]*N\nfor i in range(2,N):\n if not p[i]:\n for j in range(i,N,i):\n p[j]=i\nn=input()\nx=n-1\nfor i in range(n-p[n]+1,n):\n if i!=p[i]:\n x=min(x,i-p[i]+1)\nprint x"}, {"source_code": "small_prime = [0]*(10**6+1)\nfor i in range(2,10**6+1):\n if small_prime[i] != 0:\n continue\n small_prime[i] = i\n for j in range(1,10**6+1):\n temp = i*j\n if temp>10**6:\n break\n small_prime[temp] = i\n\ndef find(X):\n # find all prime \n org = X\n P = set([])\n while small_prime[X] != X:\n P.add(small_prime[X])\n X = X//small_prime[X]\n P.add(X)\n P = sorted(list(P))\n Mp = P[-1]\n if Mp == org:\n return X\n return org-Mp+1\n\ndef find_ans(X):\n X1 = find(X)\n ans = X\n for x1 in range(X1,X):\n ans = min(ans,find(x1))\n return ans\n\nprint(find_ans(int(input())))"}, {"source_code": "p=int(input())\nf=[0]*(p+1)\nfor i in range(2,p+1):\n if not f[i]:\n for j in range(2*i,p+1,i):\n f[j]=i\nans=p\nfor i in range(p-f[p]+1,p+1):\n ans=min(i-f[i]+1,ans)\nprint(ans)"}, {"source_code": "def find_max_p(k):\n cur_k = k\n max_d = int(k**0.5)+2\n d = 2\n max_p = 1\n while cur_k > 1 and d < max_d:\n while cur_k %d == 0:\n cur_k //= d\n max_p = d\n\n d+=1\n\n if cur_k >1:\n return cur_k\n else:\n return max_p\n\ndef min_x(x):\n res = x - find_max_p(x) +1\n if res>1:\n return res\n else:\n return x\n\n\nx_2 = int(input())\n# print(min_x(x_2))\n# for x_1 in range(min_x(x_2), x_2):\n# print(x_1, min_x(x_1))\nprint(min([min_x(x_1) for x_1 in range(min_x(x_2), min(x_2, min_x(x_2)+100))]))\n\n"}, {"source_code": "from sys import stdin\nmaxn = 1000006\nprime = [0] * maxn\ndef getPrimes():\n n = 2\n while(n < maxn):\n num = n*2\n while(num < maxn):\n prime[num] = n\n num += n\n num = n + 1\n while( num < maxn and prime[num]!= 0 ):\n num += 1\n n = num\n\n\ndef main():\n getPrimes()\n n = int(stdin.readline().strip())\n a = 0\n b = prime[n]\n x0 = 9999999\n for i in range(n-b+1,n+1):\n a = prime[i]\n x0 = min(i-a+1,x0)\n print(x0)\n\nmain()\n"}, {"source_code": "# -*- coding: utf - 8 -*-\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n| author: mr.math - Hakimov Rahimjon |\n| e-mail: mr.math0777@gmail.com |\n| created: 10.03.2018 20:50 |\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n# inp = open(\"input.txt\", \"r\"); input = inp.readline; out = open(\"output.txt\", \"w\"); print = out.write\nTN = 1\n\n\n# ===========================================\n\n\ndef resheto(l, k, n):\n i=0\n while i<len(l):\n if l[i]%k == 0: l=l[:i]+l[i+1:]\n i+=1\n lst = []\n for i in l:\n if n % i == 0: lst.append(i)\n return lst\n\n\n# ===========================================\n\n\ndef solution():\n x2 = int(input())\n n = 1000001\n max_prime = [0] * n\n s = list(range(n))\n s[1] = 0\n for i in s:\n if i > 1 and s[i]:\n for j in range(2 * i, n, i):\n s[j] = 0\n max_prime[j] = i\n min_x0 = n\n for x in range(x2 - max_prime[x2] + 1, x2 + 1):\n max_div = max_prime[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\n print(min_x0)\n\n\n\n# ===========================================\nwhile TN != 0:\n solution()\n TN -= 1\n# ===========================================\n# inp.close()\n# out.close()\n"}, {"source_code": "# -*- coding: utf - 8 -*-\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n| author: mr.math - Hakimov Rahimjon |\n| e-mail: mr.math0777@gmail.com |\n| created: 10.03.2018 20:50 |\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n# inp = open(\"input.txt\", \"r\"); input = inp.readline; out = open(\"output.txt\", \"w\"); print = out.write\nTN = 1\n\n\n# ===========================================\n\n\ndef resheto(l, k, n):\n i=0\n while i<len(l):\n if l[i]%k == 0: l=l[:i]+l[i+1:]\n i+=1\n lst = []\n for i in l:\n if n % i == 0: lst.append(i)\n return lst\n\n\n# ===========================================\n\n\ndef solution():\n x2 = int(input())\n n = 1000001\n max_prime = [0] * n\n s = list(range(n))\n s[1] = 0\n for i in s:\n if i > 1 and s[i]:\n for j in range(2 * i, n, i):\n s[j] = 0\n max_prime[j] = i\n min_x0 = n\n for x in range(x2 - max_prime[x2] + 1, x2 + 1):\n max_div = max_prime[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\n print(min_x0)\n\n\n\n# ===========================================\nwhile TN != 0:\n solution()\n TN -= 1\n# ===========================================\n# inp.close()\n# out.close()\n"}, {"source_code": "x2 = int(input())\nn = x2\nvis = [False for i in range(n+1)]\nf = [0 for i in range(n+1)]\nfor i in range(2, n+1):\n if not vis[i]:\n for j in range(i+i, n+1, i):\n vis[j] = True\n f[j] = i\nans = x2\nfor i in range(x2 - f[x2] + 1, x2+1):\n ans = min(ans, i - f[i] + 1)\nprint(ans)\n"}, {"source_code": "# just need to use only max prime factor p_max of x2, because (x2-p_max, x2] contains all possible x1\n\n\ndef prime_factors(n):\n f = 2\n while f * f <= n:\n while n % f == 0:\n yield f\n n //= f\n f += 1\n if n > 1:\n yield n\n\n\nx2 = int(input())\nmax_p_x2 = max([x for x in prime_factors(x2)])\nans = float('Inf')\nfor x1 in range((x2 - max_p_x2 + 1), x2 + 1):\n max_p_x1 = max([x for x in prime_factors(x1)])\n if x1 - max_p_x1 > 0:\n ans = min(ans, x1 - max_p_x1 + 1)\n else:\n ans = min(ans, x1)\n if ans < x1 // 2:\n break\n\nprint(ans)\n"}, {"source_code": "n = int(input())\n\nans = n\n\nf = [0]*(n+1)\n\nfor i in range(2, n+1):\n\n if f[i]==0:\n\n for j in range(i*2, n+1, i):\n\n f[j] = i\n\n f[i] = i-f[i]+1\n\nfor i in range(f[n], n+1):\n\n ans = min(ans, f[i])\n\nprint(ans)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def factorize(n):\n res = []\n if n % 2 == 0:\n power = 0\n while n % 2 == 0:\n power += 1\n n //= 2\n res.append((2, power))\n i = 3\n while i * i <= n:\n if n % i == 0:\n power = 0\n while n % i == 0:\n power += 1\n n //= i\n res.append((i, power))\n i += 2\n if n > 1:\n res.append((n, 1))\n return res\n\nx2 = int(input())\n\np = max(k for k, _ in factorize(x2))\nk = x2 // p\nres = float('inf')\nfor x1 in range(p * (k - 1) + 1, p * k + 1):\n p = max(k for k, _ in factorize(x1))\n k = x1 // p\n if k > 1:\n res = min(res, p * k - p + 1)\n if res < x1 // 2: break\nprint(res)"}, {"source_code": "prime_number = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71\n,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173\n,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281\n,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409\n,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541\n,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659\n,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809\n,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941\n,947,953,967,971,977,983,991,997,1009]\n\nnum = int(input())\n\nimport math\n\ndef find_max_prime(val):\n result= 0\n if val in prime_number:\n return val\n\n for prime in prime_number:\n if prime > math.sqrt(val):\n break\n if val % prime == 0:\n temp=max(prime, find_max_prime(int(val/prime)))\n result=max(result,temp)\n break\n\n if result==0:\n return val\n else:\n return result\n\n\n# max_pr_div = [0]*(num+1)\n#\n# for i in prime_number:\n# for j in range(0,num + 1,i):\n# max_pr_div[j] = i\n# max_pr_div[1] = 1\n#\n# def find_max_prime(val):\n# return max_pr_div[val]\n\nprev = find_max_prime(num)\nval = 10000000\nfor i in range(num - prev + 1, num + 1):\n if (val < (i/2 +1)):\n continue\n k = find_max_prime(i)\n if k == i:\n continue\n else:\n val= min(val, i - k + 1)\nprint(val)\n\n"}, {"source_code": "import sys\nsys_in = sys.stdin\n\nX2 = int(sys.stdin.read())\n\n\nprimes = range(X2+1)\n\nfor i in range(2, (X2+1)/2+1):\n if primes[i] == i:\n for k in range(i, X2+1, i):\n primes[k] = i\n\n\ndef get_max_div(i):\n return primes[i]\n\n\nmin_X0 = -1\nd_max = get_max_div(X2)\nfor X1 in range(X2, X2-d_max, -1):\n p0 = get_max_div(X1)\n X0 = X1-p0+1\n if X0 == 1:\n X0 = X1\n # print \"{} p0, {} X0, {} p1, {} X1\".format(p0, X0, d, X1)\n if X0 < min_X0 or min_X0 == -1:\n min_X0 = X0\n\nsys.stdout.write(str(min_X0)+\"\\n\")\n"}, {"source_code": "import math\ndef primes(max_n):\n max_n-=1\n numbers = range(3, max_n+1, 2)\n half = (max_n)//2\n initial = 4\n\n for step in xrange(3, max_n+1, 2):\n for i in xrange(initial, half, step):\n numbers[i-1] = 0\n initial += 2*(step+1)\n if initial > half:\n return [2] + filter(None, numbers)\ndef factors(a):\n j = 0\n p = {}\n while (a > 1):\n b = asd[j]\n if a % b == 0:\n a /= b\n if b not in p:\n p[b] = 1\n else:\n j += 1\n p = p.keys()\n p.sort()\n return p\nasd=primes(10**6+1)\ncheck={}\nfor i in asd:\n check[i]=1\ndef help(arr,num):\n don=[]\n if num not in check:\n for i in arr:\n p=num/i\n #print p,i\n for j in range(num-i+1,num+1):\n don.append(j)\n return don\n\n\n\n#print help(factors(16),16)\n\n\nn=input()\nans=[]\nal={}\nf=factors(n)\ngiv=primes(n)\ngiv.sort(reverse=True)\nm=10**7\nfor i in f:\n left=n-i+1\n right=n\n for j in giv:\n rem=j-left%j\n if rem==j:\n rem=0\n num=left+rem\n #print num,left,j\n if num<=right:\n ans=num-j+1\n if ans>1:\n m=min(ans,m)\n\n\nprint m\n"}, {"source_code": "import sys\nfrom math import ceil\n\ndef primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n return a\n\ndef findLargestPrimeFactor(n):\n primeFactor = 1\n i = 0\n while primes2[n] == False:\n \tif n%primes[i] == 0:\n \t\tprimeFactor = primes[i]\n \t\tn /= primes[i]\n \telse:\n \t\ti += 1\n if primeFactor < n:\n primeFactor = n\n return primeFactor\n\ndef solution(x, step=None):\n\tlargestPrimeFactor = findLargestPrimeFactor(x)\n\tif step != None:\n\t\tif largestPrimeFactor == x:\n\t\t\treturn x\n\t\treturn x - largestPrimeFactor + 1\n\telse:\n\t\tx1s = [i for i in range(x-largestPrimeFactor+1,x+1)]\n\t\tmin_x0 = float('inf')\n\t\tfor x1 in x1s:\n\t\t\tmin_x0 = min(min_x0, solution(x1,1))\n\t\treturn min_x0\n\nprimes2 = primes_sieve(1000001)\nprimes = [i for i,b in enumerate(primes2) if b]\nx2 = int(sys.stdin.readline().strip())\nprint(solution(x2))\n#sauce tomate\n"}, {"source_code": "from math import *\nN = int(raw_input())\nprimes = [2]\nfor i in range (3, 10**6):\n count = 0\n j = 0\n while primes[j] <= sqrt(i) and j < len(primes):\n if (i/primes[j]) * primes[j] == i:\n count = 1\n break\n else:\n j += 1\n if count == 0:\n primes.append(i)\ndef maxprime(n):\n max = 0\n i = 0\n while (n>1):\n m = n/primes[i]\n if m*primes[i] == n:\n n = m\n max = primes[i]\n else:\n i += 1\n return max\n\ndef primesearch(min, max):\n low = 0\n high = len(primes)\n while high > low + 1:\n mid = (low + high)/2\n val = 2 * primes[mid]\n if val == min:\n return 2*primes[mid]\n elif val >= min:\n high = mid\n elif val < min:\n low = mid\n if (2*primes[high]) <= max:\n return 2*primes[high]\n else:\n return max\n\np = maxprime(N)\nans = float(\"inf\")\n\nfor i in range (N - p + 1, primesearch(N-p+1, N-1)+1):\n j = maxprime(i)\n if i==j:\n ans = min(ans, i)\n else:\n ans = min(ans, i-j+1)\n\nprint ans"}, {"source_code": "prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,\n103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,\n199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,\n313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,\n433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,\n563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,\n673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,\n811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,\n941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,\n1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,\n1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,\n1279,1283,1289,1291,1297,1301,1303]\n\ndef max_prime(num):\n\tbackup = num\n\texist = 0\n\ttemp = 2\n\tfor i in prime:\n\t\tif (num%i) == 0:\n\t\t\ttemp = max(temp, i)\n\t\t\texist = 1\n\t\twhile(num%i == 0):\n\t\t\tnum = num/i\n\n\ttemp = max(temp,num)\n\treturn temp\n\t\nn = input()\n\nmin1 = n-max_prime(n)+1\n\nans = n-1\nfor i in xrange(min1,n):\n\tmp = max_prime(i)\n\t# print i, mp\n\tif mp == i:\n\t\tans = min(ans, i)\n\telse:\n\t\tans = min(ans, i-max_prime(i)+1)\n\nprint ans"}, {"source_code": "import math\ndef primes(max_n):\n max_n-=1\n numbers = range(3, max_n+1, 2)\n half = (max_n)//2\n initial = 4\n\n for step in xrange(3, max_n+1, 2):\n for i in xrange(initial, half, step):\n numbers[i-1] = 0\n initial += 2*(step+1)\n if initial > half:\n return [2] + filter(None, numbers)\ndef factors(a):\n j = 0\n p = {}\n while (a > 1):\n b = asd[j]\n if a % b == 0:\n a /= b\n if b not in p:\n p[b] = 1\n else:\n j += 1\n p = p.keys()\n p.sort()\n return p\nasd=primes(10**6+1)\ncheck={}\nfor i in asd:\n check[i]=1\ndef help(arr,num):\n don=[]\n if num not in check:\n for i in arr:\n p=num/i\n #print p,i\n for j in range(num-i+1,num+1):\n don.append(j)\n return don\n\n\n\n#print help(factors(16),16)\n\n\nn=input()\nans=[]\nal={}\nf=factors(n)\ngiv=primes(n)\ngiv.sort(reverse=True)\nm=10**7\nfor i in f:\n left=n-i+1\n right=n\n for j in giv:\n rem=j-left%j\n if rem==j:\n rem=0\n num=left+rem\n #print num,left,j\n if num<=right:\n ans=num-j+1\n if ans>1:\n m=min(ans,m)\n\n\nprint m\n"}, {"source_code": "n=input();ans=999999999\n\ndef isPrime(n):\n for i in xrange(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\nfor i in xrange(n/2,0,-1):\n if n%i==0 and isPrime(i):\n break\n\nfor j in xrange(n-i+1,n):\n for k in xrange(j/2+1,0,-1):\n if j%k==0 and isPrime(k):\n break\n if (j-k+1)<ans:\n ans=(j-k+1)\n if j/2>ans:\n break\nprint ans\n"}, {"source_code": "from fractions import gcd\nfrom math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin\nfrom itertools import *\nfrom fractions import Fraction\nimport string\nimport copy\nimport random\nimport bisect\nfrom decimal import *\ndef id_generator(size=20, chars=string.digits):\n\treturn ''.join(random.choice(chars) for _ in range(size))\n \ndef mp():\n\treturn map(int,str(raw_input()).split())\n\nsieve=[1 for i in range(10**6+1)]\nsieve[1]=0\nsieve[0]=0\nprimes=[[] for i in range(10**6+1)]\nfor i in range(2,10**6+1):\n\tif sieve[i]==1:\n\t\tfor j in range(i*2,10**6+1,i):\n\t\t\tsieve[j]=i\n\t\t\tprimes[j]+=[i]\n\n#print sieve[:10]\nx=input()\nl=primes[x]\nans=10**18\nfor i in range(len(l)):\n\tfor j in range(x-l[i]+1,x+1):\n\t\tans=min(ans,(j)-sieve[j]+1)\n\nprint ans"}, {"source_code": "x=int(input())\nprim=[0]*(x+1)\nfor n in range(2,x+1):\n if not prim[n]:\n #prim[n]=n\n for k in range(2*n,x+1,n):\n prim[k]=n\n\np=prim[x]\nres=1e9\nfor n in range(x-p+1,x+1):\n cur=n\n mxp=prim[cur]\n d=cur-mxp+1\n res=min(res,d)\n\nprint(res)\n\n"}, {"source_code": "import math,sys,bisect,heapq\nfrom collections import defaultdict,Counter,deque\nfrom itertools import groupby,accumulate\n#sys.setrecursionlimit(200000000)\nint1 = lambda x: int(x) - 1\ninput = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\nilele = lambda: map(int,input().split())\nalele = lambda: list(map(int, input().split()))\nilelec = lambda: map(int1,input().split())\nalelec = lambda: list(map(int1, input().split()))\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\n#MOD = 1000000000 + 7\ndef Y(c): print([\"NO\",\"YES\"][c])\ndef y(c): print([\"no\",\"yes\"][c])\ndef Yy(c): print([\"No\",\"Yes\"][c])\n \nN = int(input())\nP = [0 for _ in range(1000010)]\nfor i in range(2, N):\n if P[i] == 0:\n for j in range(2*i, N+1, i):\n P[j] = i\nans = 1000010\nfor i in range(N-P[N]+1, N+1):\n ans = min(ans, i-P[i]+1)\nprint(ans)"}, {"source_code": "from math import sqrt\nimport sys\n\n# from io import StringIO\n#\n# sys.stdin = StringIO(open(__file__.replace('.py', '.in')).read())\n\n\ndef largest_prime_factor(n):\n for i in range(2, int(sqrt(n) + 1)):\n if n % i == 0:\n return largest_prime_factor(n // i)\n return n\n\n\nx2 = int(input())\np2 = largest_prime_factor(x2)\n\nm = sys.maxsize\nfor x1 in range(x2 - p2 + 1, x2 + 1):\n p1 = largest_prime_factor(x1)\n if p1 != x1 and m > x1 - p1 + 1:\n m = x1 - p1 + 1\n\nprint(m)\n"}, {"source_code": "x=int(input())\np=[1]*(x+1)\na=2\np[0]=0\np[1]=0\nwhile a<=x:\n if p[a]:\n for i in range(a**2,x+1,a):\n p[i]=0\n a+=1\nc=[]\nfor i in range(2,len(p)-1):\n if p[i]:\n c.append(i)\nfor i in range(len(c)-1,-1,-1):\n if not x%c[i]:\n low=c[i]\n break\nposs=[i for i in range(max(x-low+1,3),x)]\nans=poss[0]\nl=0\nr=1\ntry:\n while poss[0]>=c[r+1]*2:\n r+=1\nexcept IndexError:\n ...\nfor i in poss:\n while i-c[l]+1>=ans:\n l+=1\n if c[r]*2<=i:\n r+=1\n if l>r:\n break\n for j in range(l,r+1):\n if not i%c[j] and i-c[j]>1:\n ans=min(ans,i-c[j]+1)\nprint(ans)"}, {"source_code": "n = int(input())\ne = [0 for i in range(n+1)]\nfor i in range(2, n+1):\n if (e[i] == 0):\n for j in range(i+i, n+1, i):\n e[j] = i\n e[i] = i -e[i]+1\nans = n\nfor i in range(e[n], n+1):\n ans = ans if (ans<e[i]) else e[i]\nprint(ans)\n"}, {"source_code": "x2 = int(input())\n\ns = [-1] * (x2 + 1)\nfor i in range(2, x2+1):\n\tif s[i] == -1:\n\t\tfor j in range(i, x2+1, i):\n\t\t\ts[j] = i\n\t\nans = x2\nfor x1 in range(x2 - s[x2] + 1, x2 + 1):\n\tx0 = x1 - s[x1] + 1\n\tif x0 > 1:\n\t\tans = min(ans, x0)\n\nprint(ans)\n"}, {"source_code": "x2 = int(input())\nnum = []\nfor val in range(1000010):\n num.append(0)\nfor i in range(2,x2):\n if(num[i]==0):\n for j in range(i+i,x2+1,i):\n num[j]=i\nprim = x2 - num[x2] + 1\nminn = 10000000\nfor i in range(prim,x2+1):\n minn = min(minn,i - num[i] + 1)\nprint(minn)"}, {"source_code": "x = int(input())\narr = [0] * (x+1)\nres=x\nfor i in range(2, x+1):\n if arr[i]==0:\n for j in range(i+i, x+1, i):\n arr[j] = i\n arr[i]=i-arr[i]+1;\nfor i in range(arr[x],x+1):\n res=min(res, arr[i])\nprint(res)"}, {"source_code": "x = int(input())\n\narr = [0 for i in range(x + 1)]\n\nfor i in range(2, x+1):\n if(arr[i] == 0):\n for j in range(i + i, x + 1, i):\n arr[j] = i\n arr[i] = i - arr[i] + 1;\n\nresult = x\nfor i in range(arr[x], x + 1):\n result = min(result, arr[i])\n\nprint(result)\n"}, {"source_code": "from math import floor, sqrt\nimport bisect\n\nimport math\n\n\ndef rwh_primes2(n):\n # https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188\n \"\"\" Input n>=6, Returns a list of primes, 2 <= p < n \"\"\"\n correction = (n%6>1)\n n = {0:n,1:n-1,2:n+4,3:n+3,4:n+2,5:n+1}[n%6]\n sieve = [True] * (n//3)\n sieve[0] = False\n for i in range(int(n**0.5)//3+1):\n if sieve[i]:\n k=3*i+1|1\n sieve[ ((k*k)//3) ::2*k]=[False]*((n//6-(k*k)//6-1)//k+1)\n sieve[(k*k+4*k-2*k*(i&1))//3::2*k]=[False]*((n//6-(k*k+4*k-2*k*(i&1))//6-1)//k+1)\n return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]\n\n\nk = int(input())\n\nprimes = rwh_primes2(k)\n\na = 1\np2 = 2\nfor i in primes[::-1]:\n if k%i == 0:\n p2 = i\n break\n\nxx = range(k-p2+1, k+1)\n#print(list(xx))\nif p2>240:\n p1 = primes[bisect.bisect_left(primes, int(math.ceil(xx[0]/2)))]\n print(p1+1)\nelse:\n ans = k\n p1 = 1\n for x1 in xx:\n for i in primes[::-1]:\n\n if i >= x1:\n continue\n\n if x1 % i == 0:\n p1 = i\n break\n ans = min(ans, x1-p1+1)\n\n print(ans)"}, {"source_code": "def testPrimal(n):\n siv = [0 for _ in range(n+1)]\n for i in range(2, n+1):\n if siv[i] == 0:\n for j in range(i+i, n+1, i):\n siv[j] = i\n siv[i] = i - siv[i] + 1\n result = n\n for i in range(siv[n], n + 1):\n result = min(result, siv[i])\n return result\nn = int(input())\nprint(testPrimal(n))"}, {"source_code": "n = int(input())\ne = [0 for i in range(n+1)]\nfor i in range(2, n+1):\n if (e[i] == 0):\n for j in range(i+i, n+1, i):\n e[j] = i\n e[i] = i -e[i]+1\nans = n\nfor i in range(e[n], n+1):\n ans = ans if (ans<e[i]) else e[i]\nprint(ans)\n"}, {"source_code": "u=[]\nz=float(\"inf\")\nfor x in range(1,1000009):\n\tu.append(False)\n\nn=int(input())\nfor x in range(2,n):\n\tif(not u[x]):\n\t\tfor y in range(2*x,n+1,x):\n\t\t\tu[y]=x\n\nfor x in range(n-u[n]+1,n+1):\n\tz=min(z,x-u[x]+1)\nprint(z)"}, {"source_code": "a = int(input())\nb = [0 for i in range(a+1)]\nfor i in range(2, a+1):\n if (b[i] == 0):\n for j in range(i+i, a+1, i):\n b[j] = i\n b[i] = i -b[i]+1\nprim = a\nfor i in range(b[a], a+1):\n prim = prim if (prim<b[i]) else b[i]\nprint(prim)"}, {"source_code": "number=int(input())\nesPrimo=[True]*number\nfor i in range(2,number):\n if esPrimo[i]:\n for j in range (i*i,number,i):\n esPrimo[j]=False\nprimos=[i for i in range(2,number) if esPrimo[i]]\nm=number -1\nfor p in primos:\n if number % p == 0:\n m=number-p\nanswer = m+1\nfor p in primos:\n if p>m:\n break\n d=m-m%p\n if d+p<=number:\n answer=min(answer,d+1)\nprint(answer)"}, {"source_code": "lectura = int(input())\nlista0 = [0]*(lectura+1)\nfor i in range(2, lectura+1):\n #print(\"i= \"+str(i))\n if lista0[i]==0:\n for j in range(2*i, lectura+1, i):\n #print(\"j= \"+str(j))\n lista0[j] = i\n lista0[i] = i-lista0[i]+1\nconclusion = lectura\nfor i in range(lista0[lectura], lectura+1):\n conclusion = min(conclusion, lista0[i])\nprint(conclusion)"}, {"source_code": "numero = int(input())\n\n\nlista = [0]*(numero+1)\n\n\nfor i in range(2, numero+1):\n if lista[i]==0:\n for j in range(2*i, numero+1, i):\n lista[j] = i\n \n lista[i] = i-lista[i]+1\n \np = numero\n\nfor i in range(lista[numero], numero+1):\n \n p = min(p, lista[i])\n \nprint(p)\n"}, {"source_code": "x2 = int(input())\nnum = []\nfor val in range(1000010):\n num.append(0)\nfor i in range(2,x2):\n if(num[i]==0):\n for j in range(i+i,x2+1,i):\n num[j]=i\nprim = x2 - num[x2] + 1\nminn = 10000000\nfor i in range(prim,x2+1):\n minn = min(minn,i - num[i] + 1)\nprint(minn)"}, {"source_code": "# By Sieve of Erastoteles\ndef getPrimes(n):\n\tprimes = [0 for _ in range(n + 1)] # Initialize 'primes' in 0\n\tfor i in range(2, n + 1): # n + 1 is the last we will need\n\t if not primes[i]: # if it is zero, apply algorithm\n\t for j in range(2*i, n + 1, i):\n\t primes[j] = i\n\t primes[i] = i - primes[i] + 1; # Game\n\t# print(primes)\n\treturn primes\n\nx2 = int(input())\nprimes = getPrimes(x2)\n\nres = x2\nfor i in range(primes[x2], x2 + 1):\n\tres = min(res, primes[i])\n\nprint(res)"}, {"source_code": "n = int(input())\n\nans = n\n\nf = [0]*(n+1)\n\nfor i in range(2, n+1):\n\n if f[i]==0:\n\n for j in range(i*2, n+1, i):\n\n f[j] = i\n\n f[i] = i-f[i]+1\n\nfor i in range(f[n], n+1):\n\n ans = min(ans, f[i])\n\nprint(ans)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "if __name__ == '__main__':\n x = int(input())\n pSieve = [True] * x\n\n for i in range(2, x):\n if pSieve[i]:\n for j in range(i * i, x, i):\n pSieve[j] = False\n\n primos = []\n for i in range(2,x):\n if pSieve[i]:\n primos.append(i)\n\n y = x-1\n\n for p in primos:\n if x % p == 0:\n y = x - p\n\n z = y + 1\n\n for i in primos:\n if i > y:\n break\n d = y - y % i\n if d + i <= x:\n z = min(z, d+1)\n\n print(z)\n"}, {"source_code": "x2 = int(input())\n\nn = 1000001\nmax_prime_div = [0] * n\nsieve = list(range(n))\nsieve[1] = 0\nfor i in sieve:\n if sieve[i]:\n for j in range(2 * i, n, i):\n sieve[j] = 0\n max_prime_div[j] = i\n\nmin_x0 = n\nfor x in range(x2 - max_prime_div[x2] + 1, x2 + 1):\n max_div = max_prime_div[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\n if max_div and x // max_div == 2:\n break\nprint(min_x0)"}, {"source_code": "x2 = int(input())\n\nn = 1000001\nmax_prime_div = [0] * n\nsieve = list(range(n))\nsieve[1] = 0\nfor i in sieve:\n if i > 1 and sieve[i]:\n for j in range(2 * i, n, i):\n sieve[j] = 0\n max_prime_div[j] = i\n\nmin_x0 = n\nfor x in range(x2 - max_prime_div[x2] + 1, x2 + 1):\n max_div = max_prime_div[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\nprint(min_x0)"}, {"source_code": "import array\n\nx2 = int(input())\n\nn = 1000001\nmax_prime_div = array.array('i', [0] * n)\nsieve = array.array('i', list(range(n)))\nsieve[1] = 0\nfor i in sieve:\n if sieve[i]:\n for j in range(2 * i, n, i):\n sieve[j] = 0\n max_prime_div[j] = i\n\nmin_x0 = n\nfor x in range(x2 - max_prime_div[x2] + 1, x2 + 1):\n max_div = max_prime_div[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\n if max_div and x // max_div == 2:\n break\nprint(min_x0)"}, {"source_code": "def max_less_prime_divisor(n): # 1 for primes\n d, max_d = 2, 1\n while d * d <= n:\n while n % d == 0:\n max_d = d\n n //= d\n d += 1\n return n if n != 1 and max_d != 1 else max_d\n\nn = int(input())\nm = n - max_less_prime_divisor(n) + 1\nanswer = m\nis_prime = [True] * m\nfor i in range(2, m):\n if is_prime[i]:\n d = (m - 1) - (m - 1) % i\n if d + i <= n:\n answer = min(answer, d + 1)\n for j in range(i * i, m, i):\n is_prime[j] = False\nprint(answer)\n \n"}, {"source_code": "n = int(input())\n\nis_prime = [True] * n\nfor i in range(2, n):\n if is_prime[i]:\n for j in range(i * i, n, i):\n is_prime[j] = False\nprimes = [i for i in range(2, n) if is_prime[i]]\n\nm = n - 1\nfor p in primes:\n if n % p == 0:\n m = n - p\n\nanswer = m + 1\nfor p in primes:\n if p > m:\n break\n d = m - m % p\n if d + p <= n:\n answer = min(answer, d + 1)\nprint(answer)\n \n"}, {"source_code": "n = int(input())\nis_prime = [True] * n\nfor i in range(2, n):\n if is_prime[i]:\n for j in range(i * i, n, i):\n is_prime[j] = False\nprimes = [i for i in range(2, n) if is_prime[i]]\nm = n - 1\nfor p in primes:\n if n % p == 0:\n m = n - p\nanswer = m + 1\nfor p in primes:\n if p > m:\n break\n d = m - m % p\n if d + p <= n:\n answer = min(answer, d + 1)\nprint(answer)\n "}, {"source_code": "x2 = int(input())\ns = [-1] * (x2+1)\nfor i in range(2, x2+1):\n if s[i] == -1:\n for j in range(i, x2+1, i):\n s[j] = i;\nans = x2\nfor x1 in range(x2-s[x2]+1, x2+1):\n x0 = x1 - s[x1] + 1\n if x0 > 1:\n ans = min(ans, x0)\nprint(ans)\n"}, {"source_code": "n = int(input())\n\nsiv = [0 for _ in range(n+1)]\n\nfor i in range(2, n+1):\n if siv[i] == 0:\n for j in range(i+i, n+1, i):\n siv[j] = i\n siv[i] = i - siv[i] + 1;\n\nresult = n\nfor i in range(siv[n], n + 1):\n result = min(result, siv[i])\n\nprint(result)"}, {"source_code": "#!/bin/python\nfrom __future__ import print_function\nimport sys\nimport math\n\nit = iter(sys.stdin.read().splitlines())\nx2 = int(next(it))\n\n\nsieve = [True] * x2\n\nfor i in range(2, x2):\n if sieve[i]:\n for j in range(i * i, x2, i):\n sieve[j] = False\nprimes = []\n\nfor i in xrange(2,x2):\n if sieve[i]:\n primes.append(i)\n\nx1 = x2 - 1\n\nfor p in primes:\n if x2 % p == 0:\n x1 = x2 - p\nx0 = x1 + 1\n\nfor i in primes:\n if i > x1:\n break\n d = x1 - x1 % i\n if d + i <= x2:\n x0 = min(x0, d + 1)\n\nprint(x0)\n\n\n\n\n\n\n"}, {"source_code": "from __future__ import print_function\nimport sys\nit = iter(sys.stdin.read().splitlines())\n\nx2 = int(next(it))\n\npSieve = [True] * x2\n\nfor i in range(2, x2):\n if pSieve[i]:\n for j in range(i * i, x2, i):\n pSieve[j] = False\n\nprimos = []\nfor i in xrange(2,x2):\n if pSieve[i]:\n primos.append(i)\n\nx1 = x2-1\n\nfor p in primos:\n if x2 % p == 0:\n x1 = x2 - p\n\nx0 = x1 + 1\n\nfor i in primos:\n if i > x1:\n break\n d = x1 - x1 % i\n if d + i <= x2:\n x0 = min(x0, d+1)\n\nprint(x0)"}, {"source_code": "def minimum(a, b):\n if a < b:\n return a\n return b\n\n\ndef main():\n n = input()\n resultado = n\n listofzeros = [0] * 1000010\n for i in range(2, n + 1):\n if(listofzeros[i] == 0):\n for j in range(2 * i, n + 1, i):\n listofzeros[j] = i\n listofzeros[i] = i - listofzeros[i] + 1\n for i in range(listofzeros[n], n + 1):\n resultado = minimum(resultado, listofzeros[i])\n print resultado\n\n\nmain()"}, {"source_code": "from __future__ import print_function, division\nimport sys\n\nx = int(sys.stdin.read())\nprimo = [0] * (x+1)\n\nfor i in xrange(2, x+1):\n if(primo[i]==0):\n for j in xrange(i*2, x+1, i):\n primo[j] = i\n primo[i] = i - primo[i] + 1\n\nprime = x\n\nfor i in xrange(primo[x], x+1):\n prime = min(prime, primo[i])\n\nprint(prime)"}, {"source_code": "from __future__ import print_function\nimport sys\n\nit = iter(sys.stdin.read().splitlines())\nn = int(next(it))\n\nlista = [0]*(n+1)\nfor i in xrange(2, n+1):\n if(lista[i] == 0):\n for k in xrange(2*i, n+1, i):\n lista[k] = i\n lista[i] = i - lista[i] + 1\npr = n\nfor i in xrange(lista[n], n+1):\n pr = min(pr, lista[i])\n\nprint(pr)"}, {"source_code": "from math import sqrt\nN = 10 ** 6 + 1\nqis_prime = [True] * (N + 1)\nfor d in range(2, int(sqrt(N + 1)) + 1):\n for comp in range(2 * d, N + 1, d):\n qis_prime[comp] = False\n\n\ndef is_prime(n):\n return qis_prime[n]\n\n\ndef kryak(x2):\n ans = 0\n for i in range(1, int(x2 ** 0.5) + 1):\n if x2 % i == 0:\n if is_prime(x2 // i):\n return x2 // i\n if is_prime(i):\n ans = max(ans, i)\n return ans\n\n\nx2 = int(input())\np = kryak(x2)\nans = x2\nfor x1 in range(x2 - p + 1, x2):\n if not is_prime(x1):\n pp = kryak(x1)\n ans = min(ans, x1 - pp + 1)\n else:\n ans = min(ans, x1)\nprint(ans)\n"}, {"source_code": "x=int(input())\np=[1]*(x+1)\na=2\np[0]=0\np[1]=0\nwhile a<=x:\n if p[a]:\n for i in range(a**2,x+1,a):\n p[i]=0\n a+=1\nc=[]\nfor i in range(2,len(p)-1):\n if p[i]:\n c.append(i)\nfor i in range(len(c)-1,-1,-1):\n if not x%c[i]:\n low=c[i]\n break\nposs=[i for i in range(max(x-low+1,3),x)]\nans=poss[0]\nl=0\nr=1\ntry:\n while poss[0]>=c[r+1]*2:\n r+=1\nexcept IndexError:\n ...\nfor i in poss:\n while i-c[l]+1>=ans:\n l+=1\n if c[r]*2<=i:\n r+=1\n if l>r:\n break\n for j in range(l,r+1):\n if not i%c[j] and i-c[j]>1:\n ans=min(ans,i-c[j]+1)\nprint(ans)"}, {"source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\n \n\nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#-------------------game starts now-----------------------------------------------------\ndef lpf(n,m=0,i=2):\n while i*i<=n:\n if n%i:i+=1\n else:n//=i\n return m-n\nx=int(input())\na=x \nfor i in range(lpf(x,x+1),x+1):\n if lpf(i,i+1)>=3:a=min(lpf(i,i+1),a)\nprint(a)\n"}, {"source_code": "x = int(input())\nn = x\nvis = [False for i in range(n+1)]\nflag = [0 for i in range(n+1)]\nfor i in range(2, n+1):\n if not vis[i]:\n for j in range(i+i, n+1, i):\n vis[j] = True\n flag[j] = i\nans = x\nfor i in range(x - flag[x] + 1, x+1):\n ans = min(ans, i - flag[i] + 1)\nprint(ans)\n"}, {"source_code": "def gf(n):\n d = 2\n while d * d <= n:\n f = 1\n while n % d is 0:\n if f:\n yield d\n f = 0\n n //= d\n d += 1\n if n > 1:\n yield n\nx2 = int(input())\nprint(min(x1 - p + 1 for x1 in range(x2 - max(gf(x2)) + 1, x2 + 1) for p in gf(x1) if p != x1))\n\n"}, {"source_code": "x2 = int(input())\n\ndef maxPrimeDevisor(v):\n result = 0\n while v % 2 == 0:\n result = 2\n v //= 2\n i = 3\n while i * i <= v:\n if v % i == 0:\n while v % i == 0:\n v //= i\n result = max(result, i)\n else:\n i += 2\n if v > 1:\n result = max(result, v)\n return result\n\nx1 = [max(3, x2 - maxPrimeDevisor(x2) + 1), x2]\nx0 = x1[1]\nfor i in range(x1[0], x1[1] + 1):\n mpd = maxPrimeDevisor(i)\n if mpd != i:\n x0 = max(3, min(x0, i - maxPrimeDevisor(i) + 1))\nprint(x0)\n"}, {"source_code": "def lpf(n,m=0,i=2):\n while i*i<=n:\n if n%i:i+=1\n else:n//=i\n return m-n\nx=int(input())\na=x \nfor i in range(lpf(x,x+1),x+1):\n if lpf(i,i+1)>=3:a=min(lpf(i,i+1),a)\nprint(a)"}, {"source_code": "N = int(1e+6 + 1)\nx2 = int(input())\nx0 = int(1e+9)\n\nwas = [False] * N\np = [0] * N\n\nfor i in range(2, N):\n if was[i]:\n continue\n p[i] = i\n j = 2 * i\n while j < N:\n was[j] = True\n p[j] = max(p[j], i)\n j += i\n\nfor i in range(x2 - p[x2] + 1, x2 + 1):\n if p[i] == i:\n continue\n x0 = min(x0, i - p[i] + 1)\n\nprint(x0)\n"}, {"source_code": "import array\n\nx2 = int(input())\n\nn = 1000001\nmax_prime_div = array.array('i', [0] * n)\nsieve = array.array('i', list(range(n)))\nsieve[1] = 0\nfor i in sieve:\n if sieve[i]:\n for j in range(2 * i, n, i):\n sieve[j] = 0\n max_prime_div[j] = i\n\nmin_x0 = n\nfor x in range(x2 - max_prime_div[x2] + 1, x2 + 1):\n max_div = max_prime_div[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\n if max_div and x // max_div == 2:\n break\nprint(min_x0)"}, {"source_code": "#---------------------------iye ha aam zindegi---------------------------------------------\nimport math\nimport heapq,bisect\nimport sys\nfrom collections import deque,defaultdict\nfrom fractions import Fraction\nmod=10**9+7\nmod1=998244353\n# ------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# -------------------game starts now----------------------------------------------------import math\nclass SegmentTree1:\n def __init__(self, data, default=9999999, func=lambda a, b: min(a , b)):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n# -------------------game starts now----------------------------------------------------import math\nclass SegmentTree:\n def __init__(self, data, default=0, func=lambda a, b: a + b):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n#-------------------------------iye ha chutiya zindegi-------------------------------------\nclass Factorial:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorials = [1, 1]\n self.invModulos = [0, 1]\n self.invFactorial_ = [1, 1]\n\n def calc(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.factorials):\n return self.factorials[n]\n nextArr = [0] * (n + 1 - len(self.factorials))\n initialI = len(self.factorials)\n prev = self.factorials[-1]\n m = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = prev * i % m\n self.factorials += nextArr\n return self.factorials[n]\n\n def inv(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n^(-1)\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n p = self.MOD\n pi = n % p\n if pi < len(self.invModulos):\n return self.invModulos[pi]\n nextArr = [0] * (n + 1 - len(self.invModulos))\n initialI = len(self.invModulos)\n for i in range(initialI, min(p, n + 1)):\n next = -self.invModulos[p % i] * (p // i) % p\n self.invModulos.append(next)\n return self.invModulos[pi]\n\n def invFactorial(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate (n^(-1))!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.invFactorial_):\n return self.invFactorial_[n]\n self.inv(n) # To make sure already calculated n^-1\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\n initialI = len(self.invFactorial_)\n prev = self.invFactorial_[-1]\n p = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\n self.invFactorial_ += nextArr\n return self.invFactorial_[n]\n\n\nclass Combination:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorial = Factorial(MOD)\n\n def ncr(self, n, k):\n if k < 0 or n < k:\n return 0\n k = min(k, n - k)\n f = self.factorial\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\n#--------------------------------------iye ha combinations ka zindegi---------------------------------\ndef powm(a, n, m):\n if a == 1 or n == 0:\n return 1\n if n % 2 == 0:\n s = powm(a, n // 2, m)\n return s * s % m\n else:\n return a * powm(a, n - 1, m) % m\n#--------------------------------------iye ha power ka zindegi---------------------------------\ndef sort_list(list1, list2):\n zipped_pairs = zip(list2, list1)\n\n z = [x for _, x in sorted(zipped_pairs)]\n\n return z\n#--------------------------------------------------product----------------------------------------\ndef product(l):\n por=1\n for i in range(len(l)):\n por*=l[i]\n return por\n#--------------------------------------------------binary----------------------------------------\ndef binarySearchCount(arr, n, key):\n left = 0\n right = n - 1\n\n count = 0\n\n while (left <= right):\n mid = int((right + left) / 2)\n\n # Check if middle element is\n # less than or equal to key\n if (arr[mid] <= key):\n\n # At least (mid + 1) elements are there\n # whose values are less than\n # or equal to key\n count = mid + 1\n left = mid + 1\n\n # If key is smaller, ignore right half\n else:\n right = mid - 1\n\n return count\n#--------------------------------------------------binary----------------------------------------\ndef countdig(n):\n c=0\n while(n>0):\n n//=10\n c+=1\n return c\ndef countGreater(arr, n, k):\n l = 0\n r = n - 1\n\n # Stores the index of the left most element\n # from the array which is greater than k\n leftGreater = n\n\n # Finds number of elements greater than k\n while (l <= r):\n m = int(l + (r - l) / 2)\n\n # If mid element is greater than\n # k update leftGreater and r\n if (arr[m] > k):\n leftGreater = m\n r = m - 1\n\n # If mid element is less than\n # or equal to k update l\n else:\n l = m + 1\n\n # Return the count of elements\n # greater than k\n return (n - leftGreater)\n#--------------------------------------------------binary------------------------------------\ndef SieveOfEratosthenes(n):\n ans=[]\n prime = [-9999999999 for i in range(n + 1)]\n p = 2\n while (p<= n):\n if (prime[p] ==-9999999999 ):\n for i in range(p * 2, n + 1, p):\n prime[i] = p\n p += 1\n prime=[i-prime[i]+1 for i in range(n+1)]\n #print(prime)\n return (prime)\n#---------------------------------------0(n)---------------------------------------------------\nn=int(input())\nprime=SieveOfEratosthenes(n)\nans=min(prime[prime[n]:n])\nif ans>10**6:\n ans-=9999999999+1\nprint(ans)"}, {"source_code": "n = int(input())\n\nis_prime = [True] * n\nfor i in range(2, n):\n if is_prime[i]:\n for j in range(i * i, n, i):\n is_prime[j] = False\nprimes = [i for i in range(2, n) if is_prime[i]]\n\nm = n - 1\nfor p in primes:\n if n % p == 0:\n m = n - p\n\nanswer = m + 1\nfor p in primes:\n if p > m:\n break\n d = m - m % p\n if d + p <= n:\n answer = min(answer, d + 1)\nprint(answer)\n \n"}], "negative_code": [{"source_code": "x2 = int(input())\nn = x2\nvis = [False for i in range(n+1)]\nf = [0 for i in range(n+1)]\nfor i in range(2, n+1):\n if not vis[i]:\n for j in range(i+i, n+1, i):\n vis[j] = True\n f[j] = i\nans = x2\nfor i in range(x2 - f[x2] + 1, x2):\n ans = min(ans, i - f[i] + 1)\nprint(ans)\n"}, {"source_code": "prime_number = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71\n,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173\n,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281\n,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409\n,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541\n,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659\n,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809\n,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941\n,947,953,967,971,977,983,991,997,1009]\n\n\nnum = int(input())\nprev= 0\nfor prime in reversed(prime_number):\n if (prime > num):\n continue\n if num % prime == 0:\n prev = prime\n break\nval = 10000000\nfor i in range(num - prev +1, num + 1):\n if i in prime_number:\n continue\n else:\n for prime in reversed(prime_number):\n if (prime > i):\n continue\n if i % prime== 0:\n val = min(val, i - prime + 1)\n break\nprint(val)"}, {"source_code": "import sys\nfrom math import ceil\n\ndef primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n return a\n\ndef solution(x2):\n\tx1s = set([])\n\tfor p in primes:\n\t\tif x2%p:\n\t\t\tcontinue\n\t\tfor x1 in range(x2-p+1,x2):\n\t\t\tx1s.add(x1)\n\tx1s = list(x1s)\n\tmin_x0 = float('inf')\n\tfor x1 in x1s[10000:]:\n\t\tfor p in primes:\n\t\t\tif x1%p:\n\t\t\t\tcontinue\n\t\t\tif x1 == p:\n\t\t\t\tif x1 < 3:\n\t\t\t\t\tcontinue\n\t\t\t\tmin_x0 = min(min_x0, x1)\n\t\t\telse:\n\t\t\t\tif x1-p+1 < 3:\n\t\t\t\t\tcontinue\n\t\t\t\tmin_x0 = min(min_x0, x1-p+1)\n\treturn min_x0\n\nprimes = primes_sieve(1000001)\nx2 = int(sys.stdin.readline().strip())\nprimes = [i for i,p in enumerate(primes) if p == True and i <= x2+1]\nprint(solution(x2))\n\n"}, {"source_code": "import sys\nfrom math import ceil\n\ndef primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n return a\n\ndef solution(x2):\n\tx1s = set([])\n\tfor p in primes:\n\t\tif x2%p:\n\t\t\tcontinue\n\t\tfor x1 in range(x2-p+1,x2):\n\t\t\tx1s.add(x1)\n\tmin_x0 = float('inf')\n\tfor x1 in sorted(x1s):\n\t\tfor p in primes:\n\t\t\tif x1-p+1 >= min_x0:\n\t\t\t\tbreak\n\t\t\tif x1%p:\n\t\t\t\tcontinue\n\t\t\tif x1 == p:\n\t\t\t\tif x1 < 3:\n\t\t\t\t\tcontinue\n\t\t\t\tmin_x0 = min(min_x0, x1)\n\t\t\telse:\n\t\t\t\tif x1-p+1 < 3:\n\t\t\t\t\tcontinue\n\t\t\t\tmin_x0 = min(min_x0, x1-p+1)\n\treturn min_x0\n\nprimes = primes_sieve(1000001)\nx2 = int(sys.stdin.readline().strip())\nprimes = [i for i,p in enumerate(primes) if p == True and i < x2]\nprint(solution(x2))\n\n"}, {"source_code": "import sys\nfrom math import ceil\n\ndef primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n return a\n\ndef solution(x2):\n\tx1s = set([])\n\tfor p in primes:\n\t\tif x2%p:\n\t\t\tcontinue\n\t\tfor x1 in range(x2-p+1,x2):\n\t\t\tx1s.add(x1)\n\tx1s = list(x1s)\n\tmin_x0 = float('inf')\n\tfor x1 in x1s[1000:]:\n\t\tfor p in primes:\n\t\t\tif x1%p:\n\t\t\t\tcontinue\n\t\t\tif x1 == p:\n\t\t\t\tif x1 < 3:\n\t\t\t\t\tcontinue\n\t\t\t\tmin_x0 = min(min_x0, x1)\n\t\t\telse:\n\t\t\t\tif x1-p+1 < 3:\n\t\t\t\t\tcontinue\n\t\t\t\tmin_x0 = min(min_x0, x1-p+1)\n\treturn min_x0\n\nprimes = primes_sieve(1000001)\nx2 = int(sys.stdin.readline().strip())\nprimes = [i for i,p in enumerate(primes) if p == True and i <= x2+1]\nprint(solution(x2))\n\n"}, {"source_code": "n=input();dic={4:3,6:3,8:7,14:6}\ndef isPrime(n):\n for i in xrange(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\ndef fn(n,isX0): #rets the smallest number n can reduce to\n ans=n\n for p in xrange(2,n/2+1):\n if n%p==0 and isPrime(p):\n for i in xrange(p*(n/p-1)+1,n):\n if not (not isX0 and isPrime(i)):\n ans=min(i,ans)\n break\n return ans\nif n in dic:\n print dic[n]\nelse:\n print fn(fn(n,False),True)\n"}, {"source_code": "from math import sqrt\nimport sys\n\n# from io import StringIO\n#\n# sys.stdin = StringIO(open(__file__.replace('.py', '.in')).read())\n\n\ndef largest_prime_factor(n):\n for i in range(2, int(sqrt(n) + 2)):\n if n % i == 0:\n return largest_prime_factor(n // i)\n return n\n\n\nx2 = int(input())\np2 = largest_prime_factor(x2)\nlo2 = x2 - p2 + 1\n\nm = sys.maxsize\nfor x1 in range(lo2, x2 + 1):\n p1 = largest_prime_factor(x1)\n if p1 != x1 and m > x1 - p1 + 1:\n m = x1 - p1 + 1\n\nprint(m)\n"}, {"source_code": "x=int(input())\np=[1]*(x+1)\na=2\np[0]=0\np[1]=0\nwhile a<=x:\n if p[a]:\n for i in range(a**2,x+1,a):\n p[i]=0\n a+=1\nc=[]\nfor i in range(2,len(p)-1):\n if p[i]:\n c.append(i)\nfor i in range(len(c)-1,-1,-1):\n if not x%c[i]:\n low=c[i]\n break\nposs=[i for i in range(max(x-low+1,3),x)]\nans=poss[0]\nl=0\nr=1\ntry:\n while poss[0]>=c[r+1]*2:\n r+=1\nexcept IndexError:\n ...\nfor i in poss:\n while i-c[l]+1>=ans:\n l+=1\n if c[r]*2<=i:\n r+=1\n if l>r:\n break\n for j in range(l,r+1):\n if not i%c[j] and i-c[j]>2:\n ans=min(ans,i-c[j]+1)\nprint(ans)"}, {"source_code": "if __name__ == '__main__':\n x = int(input())\n pSieve = [True] * x\n\n for i in range(2, x):\n if pSieve[i]:\n for j in range(i * i, x, i):\n pSieve[j] = False\n\n primos = []\n for i in range(2,x):\n if pSieve[i]:\n primos.append(i)\n\n y = x-1\n\n for p in primos:\n if x % p == 0:\n y = x - p\n\n z = y + 1\n\n for i in primos:\n if i > y:\n break\n d = y - y % i\n if d + i <= x:\n z = min(z, d+1)\n\n print(d)\n"}, {"source_code": "if __name__ == '__main__':\n x = int(input())\n pSieve = [True] * x\n\n for i in range(2, x):\n if pSieve[i]:\n for j in range(i * i, x, i):\n pSieve[j] = False\n\n primos = []\n for i in range(2,x):\n if pSieve[i]:\n primos.append(i)\n\n y = x-1\n\n for p in primos:\n if x % p == 0:\n y = x - p\n\n z = y + 1\n\n for i in primos:\n if i > y:\n break\n d = y - y % i\n if d + i <= x:\n z = min(z, d+1)\n\n print(i)\n"}, {"source_code": "x2 = int(input())\n\ndef max_div(r):\n pdelim = 2\n while r > 1:\n if r % pdelim == 0:\n r = r / pdelim\n else:\n pdelim += 1\n return pdelim\n\nmin_x0 = x2\nmax_div_x2 = max_div(x2)\nfor x1 in range(max_div_x2 * (x2 // max_div_x2 - 1) + 1, x2 + 1, 1):\n if x1 == x2:\n max_x1_div = max_div_x2\n else:\n max_x1_div = max_div(x1)\n if max_x1_div != x1:\n tmp = max_x1_div * (x1 // max_x1_div - 1) + 1\n print(tmp)\n if tmp < min_x0:\n min_x0 = tmp\nprint(min_x0)"}, {"source_code": "import sys\nit = iter(sys.stdin.read().splitlines())\n\nx2 = int(next(it))\n\npSieve = [True] * x2\n\nfor i in range(2, x2):\n if pSieve[i]:\n for j in range(i * i, x2, i):\n pSieve[j] = False\n\nprimos = []\nfor i in xrange(2,x2):\n if pSieve[i]:\n primos.append(i)\n\nx1 = x2-1\n\nfor p in primos:\n if x2 % p == 0:\n x1 = x2 - p\n\nx0 = x1 + 1\n\nfor i in primos:\n if i > x1:\n break\n d = x1 - x1 % i\n if d + 1 <= x2:\n x0 = min(x0, d+1)\n\nprint x0\n"}, {"source_code": "from __future__ import print_function, division\nimport sys\n\nx = int(sys.stdin.read())\nprimo = [True] * x\n\n#indice te dice si es primo o no\nfor i in xrange(2, x):\n if(primo[i]==True):\n for j in xrange(i*i, x, i):\n primo[j] = False\n\nlistaPrimos = [i for i in xrange(2, x) if primo[i]==True]\n\n\ny = x-1\nfor i in listaPrimos:\n if x % i == 0:\n y = x - i + 1\n\nrespuesta = y\n\nfor i in listaPrimos:\n if i > y:\n break\n z = y - (y%i)\n if z + i <= x:\n respuesta = min(respuesta, z+1)\n\nprint(respuesta)"}, {"source_code": "from __future__ import print_function, division\nimport sys\n\nx = int(sys.stdin.read())\nprimo = [True] * x\n\n#indice te dice si es primo o no\nfor i in xrange(2, x):\n if(primo[i]==True):\n for j in xrange(i*i, x, i):\n primo[j] = False\n\nlistaPrimos = [i for i in xrange(2, x) if primo[i]==True]\n\n\nrespuesta = x-1\nfor i in listaPrimos:\n if x % i == 0:\n respuesta = x - i + 1\n\nfor i in listaPrimos:\n if i > respuesta:\n break\n z = respuesta - (respuesta%i)\n if z + i <= x:\n respuesta = min(respuesta, z+1)\n\nprint(respuesta)"}], "src_uid": "43ff6a223c68551eff793ba170110438"} {"source_code": "import sys\nimport math\nfrom collections import defaultdict,deque\nimport heapq\nn,k = map(int,sys.stdin.readline().split())\nss = sys.stdin.readline()[:-1]\ndp = [[0 for _ in range(n+1)] for i in range(n+1)]\ndp[n][1]=1\ndp[n][0]=1\ndic=defaultdict(list)\nfor i in range(n):\n\tdic[ss[i]].append(i+1)\n#print(dic,'dic')\nfor i in range(n-1,0,-1):\n\t#vis=defaultdict(int)\n\tfor j in range(1,n+1):\n\t\ts=0\n\t\tfor x in range(i+1,n+1):\n\t\t\ts+=dp[x][j-1]\n\t\tz=-1\n\t\tcnt=0\n\t\t#print(ss[i-1])\n\t\t#print(dic[ss[i-1]])\n\t\tfor y in dic[ss[i-1]]:\n\t\t\tcnt+=1\n\t\t\tif y==i:\n\t\t\t\tbreak\n\t\tsub=0\n\t\tif len(dic[ss[i-1]])>cnt:\n\t\t\tfor q in range(cnt,len(dic[ss[i-1]])):\n\t\t\t\tsub+=dp[dic[ss[i-1]][q]][j]\n\t\t\t\t#print(dic[ss[i-1]][q],'row',j,'col',sub,'sub')\n\t\t\t#sub=dp[dic[ss[i-1]][cnt]][j]\n\t\t#print(cnt,'cnt',i,'i',j,'j',s,'sssss',sub,'sub',cnt,'cnt',dic[ss[i-1]])\n\t\tdp[i][j]+=s-sub\n\t\t#print(s,'s',sub,'sub')\n'''for i in range(n+1):\n\tprint(dp[i],'dp')'''\ncost=0\nfor i in range(n,-1,-1):\n\tfor j in range(n+1):\n\t\t#print(k,'k',i,'i',j,'j')\n\t\tif dp[j][i]<=k:\n\t\t\tcost+=(n-i)*dp[j][i]\n\t\t\tk-=dp[j][i]\n\t\telse:\n\t\t\t#print(n,'n',i,'i',k,'k')\n\t\t\tcost+=k*(n-i)\n\t\t\tk=0\n\t\t\tbreak\n#print(cost,'cost',k,'k')\nif k!=0:\n\tprint(-1)\nelse:\n\tprint(cost)\n", "positive_code": [{"source_code": "from itertools import combinations\n\n\ndef main():\n n, k = map(int, input().split())\n s = input()\n lenf = len\n l_prev = {s}\n curS = 1\n cost = 0\n if k == 1:\n print(0)\n return\n for curlen in range(n - 1, -1, -1):\n l = set()\n for l_elem in l_prev:\n for v in combinations(l_elem, curlen):\n v = ''.join(v)\n if v in l:\n continue\n l.add(v)\n curS += 1\n cost += n - curlen\n if curS == k:\n print(cost)\n return\n l_prev = l\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, k = map(int, input().split())\ntargets = [input()]\nans = 0\ncur = 1\ndepth = 0\n\nif cur >= k:\n print(ans)\n exit()\n\nwhile depth <= n:\n depth += 1\n next_target = []\n for target in targets:\n for i in range(len(target)):\n check = target[:i] + target[i+1:]\n if check in next_target:\n continue\n next_target.append(target[:i] + target[i+1:])\n ans += depth\n cur += 1\n if cur >= k:\n print(ans)\n exit()\n targets = next_target\nprint(-1)\n"}, {"source_code": "from sys import stdin\nfrom collections import deque\n\nn, k = map(int, input().split())\ns = input()\nque = deque()\nque.append(s)\nd = {}\nnum = 0\ncost = 0\nwhile que:\n q = que.popleft()\n if q not in d:\n cost += n - len(q)\n num += 1\n if num == k:\n print(cost)\n exit()\n d[q] = 1\n for j in range(len(q)):\n t = q[:j] + q[j + 1:]\n if t not in d:\n que.append(t)\n\nprint(-1)\n \n \n \n"}, {"source_code": "import sys\n\nn, k = map(int, sys.stdin.readline().split(' '))\ns = sys.stdin.readline().strip()\n\nlt = [s]\ncount = 0\nflag = False\nresult = 0\n\nwhile lt:\n cur_s = lt[0]\n lt.pop(0)\n result += len(s) - len(cur_s)\n count += 1\n if count >= k:\n break\n \n for i in range(0, len(cur_s)):\n new_s = cur_s[0: i] + cur_s[i + 1: ]\n if new_s not in lt:\n lt.append(new_s)\n\nif count < k:\n sys.stdout.write(str(-1) + '\\n')\nelse:\n sys.stdout.write(str(result) + '\\n')\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nimport bisect\nn,k=map(int,input().split())\ns=input()\nNext=[[float(\"inf\")]*(26) for _ in range(n+1)]\nfor i in reversed(range(n)):\n for j in range(26):\n Next[i][j]=Next[i+1][j]\n Next[i][ord(s[i])-97]=i\nDP=[[0]*(n+1) for _ in range(n+1)]\nDP[0][0]=1\nfor i in range(n):\n for j in range(26):\n nxt=Next[i][j]\n for l in range(n):\n if nxt<float(\"inf\"):\n DP[nxt+1][l+1]+=DP[i][l]\nAns=[0]*(n+1)\nfor i in range(n+1):\n for j in range(n+1):\n Ans[n-j]+=DP[i][j]\nAns2=[0]\nfor i in range(n+1):\n Ans2.append(Ans2[-1]+Ans[i])\nif Ans2[-1]<k:\n print(-1)\nelse:\n ind=bisect.bisect_left(Ans2,k)\n ans,num=0,0\n for i in range(ind-1):\n ans+=i*Ans[i]\n num+=Ans[i]\n ans+=(ind-1)*(k-num)\n print(ans)"}, {"source_code": "import sys\nfrom queue import Queue\n\nsys.setrecursionlimit(10000)\n\nn, k = map(int, input().split())\ns = input().strip()\nq = Queue()\nq.put(s)\nres = {s}\n\nwhile not q.empty():\n if len(res) == k:\n break\n string = q.get()\n for i in range(len(string)):\n new_string = string[:i] + string[i + 1:]\n if new_string not in res:\n res.add(new_string)\n q.put(new_string)\n if len(res) == k:\n break\n\nif len(res) != k:\n print(-1)\n exit()\nprint(n * k - sum(len(string) for string in res))\n"}, {"source_code": "def f(s, k):\n n = len(s)\n q = [s]\n S = set()\n S.add(s)\n ans = 0\n\n while len(q) > 0 and k > 0:\n ss = q[0]\n k -= 1\n ans += n - len(ss)\n q.pop(0)\n for i in range(len(ss)):\n ns = ss[0:i] + ss[i+1:len(s)]\n if ns not in S:\n q.append(ns)\n S.add(ns)\n if k == 0:\n return ans\n return -1\n\n\ndef main():\n n, k = map(int, input().split())\n s = input()\n print(f(s, k))\n '''\n a = list(S)\n a.sort(key=lambda x: len(x), reverse=True)\n if len(a) < k:\n print(-1)\n else:\n ans = 0\n for i in range(k):\n ans += n - len(a[i])\n print(ans)\n '''\n\nmain()\n"}, {"source_code": "def check_word(word_list, word_need):\n unique = []\n for i in range(len(word_list)):\n # Pick each word in the list\n if word_need == 0:\n break\n for j in range(len(word_list[i])):\n if word_need == 0:\n break\n # Check word without 1 char is in unique\n new_word = word_list[i][:j]+word_list[i][j+1:]\n if new_word not in unique:\n unique.append(new_word)\n word_need -= 1\n return unique\n\ndef check_all():\n cost_sum = 0\n cost_each = 1\n [raw_length, raw_size] = input().split()\n size = int(raw_size)\n words = input().split()\n size -= 1\n while size>0:\n if len(words[0]) == 0:\n return -1\n words = check_word(words, size)\n cost_sum += len(words)*cost_each\n cost_each += 1\n size -= len(words)\n return cost_sum\n\nprint(check_all())"}, {"source_code": "from queue import Queue\nstack = Queue()\n\nn, k = map(int, input().split())\ns = list(input())\n\nk -= 1\na = set()\nanswer = 0\n\nstack.put(list(s))\n\nwhile not stack.empty():\n\tnow = stack.get_nowait()\n\tnew = now[:]\n\tcan = []\n\tfor i in range(len(now)):\n\t\tif k:\n\t\t\tnew[i] = ''\n\t\t\tword = ''.join(new)\n\t\t\tif word not in a:\n\t\t\t\ta.add(word)\n\t\t\t\tanswer += n - len(word)\n\t\t\t\tcan.append(word)\n\t\t\t\tk -= 1\n\n\t\tnew[i] = now[i]\n\tif k:\n\t\tfor word in can:\n\t\t\tstack.put(list(word))\n\nif k > 0:\n\tprint(-1)\nelse:\n\tprint(answer)\n"}, {"source_code": "def super_solve(n, k, s):\n\tlast = []\n\tfor i in range (0, 256):\n\t\tlast.append(0)\n\tdp = []\n\tfor i in range (0, 105):\n\t\ttmp = []\n\t\tfor j in range (0, 105):\n\t\t\ttmp.append(0)\n\t\tdp.append( tmp )\n\t\n\tnow = []\n\tfor i in range (0, 105):\n\t\ttmp = []\n\t\tfor j in range (0, 105):\n\t\t\ttmp.append(0)\n\t\tnow.append( tmp )\n\n\tdp[0][0] = 1\n\tnow[0][0] = 1\n\tfor i in range (1, n + 1):\n\t\tc = ord(s[i])\n\t\tfor j in range (0, n + 1):\n\t\t\tdp[i][j] += dp[i-1][j]\n\t\tfor j in range (1, n + 1):\n\t\t\tdp[i][j] += dp[i-1][j-1]\n\t\tif last[c] > 0:\n\t\t\tfor j in range (1, n + 1):\n\t\t\t\tdp[i][j] -= dp[ last[c] - 1 ][j - 1]\n\t\tfor j in range (0, n + 1):\n\t\t\tnow[i][j] = dp[i][j] - dp[i-1][j]\n\t\tlast[c] = i\n\n\n\n\tcost = 0\n\tbaki = k\n\tj = n\n\twhile( j >= 0 ):\n\t\tfor i in range (0, n + 1):\n\t\t\tcur = now[i][j]\n\t\t\tmy = min(baki, cur)\n\t\t\tcost += my * j\n\t\t\tbaki -= my\n\t\tj -= 1\n\n\tret = k * n - cost\n\tif baki > 0:\n\t\tret = -1\n\treturn ret\n\ndef main():\n\tline = input()\n\tline = line.split(' ')\n\tn = int(line[0])\n\tk = int(line[1])\n\ttmp = input()\n\ts = []\n\ts.append(0)\n\tfor i in range (0, n):\n\t\ts.append( tmp[i] )\n\tret = super_solve(n, k, s)\n\tprint (ret)\n\n\nif __name__== \"__main__\":\n main()"}, {"source_code": "# your code goes here\nn,k=map(int,input().split())\ns=input()\nc=0\nq=[s]\nd=set()\nls=0\nwhile q:\n\tp=q.pop(0)\n\tif p not in d:\n\t\tls+=1\n\t\tc+=(n-len(p))\n\t\tif ls==k:\n\t\t\tbreak\n\t\td.add(p)\n\t\tfor i in range(len(p)):\n\t\t\ttemp=p[:i]+p[i+1:]\n\t\t\tif temp not in d:\n\t\t\t\tq.append(temp)\n\t\t\t\nif ls==k:\n\tprint(c)\nelse:\n\tprint(-1)"}, {"source_code": "\"\"\"\nn,k=map(int,input().split())\ns=input()\ndp=[0]*(n+1)\nkk=dict()\nglobal ct\nct=0\ndef rec(s):\n dp[len(s)]+=1\n global ct\n ct+=1\n if(ct>k+10):\n return \n if(len(s)==0):\n return\n for i in range(0,len(s)):\n st=s[:i]+s[i+1:]\n if(kk.get(st)==None):\n #dp[len(st)]+=1\n #print(st)\n kk[st]=1\n rec(st)\nrec(s)\nprint(dp)\n\ntot=0\nfor i in range(0,len(dp)):\n tot+=dp[i]\nif(tot<k):\n print(-1)\nelse:\n sumu=0\n c=0\n for i in range(n,-1,-1):\n req=min(k-c,dp[i])\n c+=req\n sumu+=(req*(n-i))\n if(c>=k):\n break\n print(sumu)\n\"\"\"\n\nfrom collections import deque\nn,k=map(int,input().split())\ns=input()\ndp=[0]*(n+1)\nkk=dict()\n\nct=0\n\nq=deque()\nq.append(s)\n\nwhile(q):\n r=q.popleft()\n dp[len(r)]+=1\n ct+=1\n\n if(ct>k+10):\n break\n\n if(len(r)>0):\n for i in range(0,len(r)):\n st=r[:i]+r[i+1:]\n if(kk.get(st)==None):\n kk[st]=1\n q.append(st)\n\n\ntot=0\nfor i in range(0,len(dp)):\n tot+=dp[i]\nif(tot<k):\n print(-1)\nelse:\n sumu=0\n c=0\n for i in range(n,-1,-1):\n req=min(k-c,dp[i])\n c+=req\n sumu+=(req*(n-i))\n if(c>=k):\n break\n print(sumu)\n"}, {"source_code": "# https://codeforces.com/contest/1183/problem/E\n\ndef solve(n, k, s):\n total_length = 0\n queue = [s]\n ss = set()\n\n while queue and len(ss) < k:\n s = queue.pop(0)\n if s not in ss:\n ss.add(s)\n total_length += len(s)\n if len(ss) < k:\n for i in range(len(s)):\n temp = s[:i] + s[i + 1:]\n if temp not in ss:\n queue.append(temp)\n \n if len(ss) < k:\n return -1\n\n return n * k - total_length\n\n\nn, k = map(int, input().split())\n\ns = input()\n\nprint(solve(n, k, s))\n"}, {"source_code": "n, k = map( int, raw_input().split() )\ns = raw_input()\n\nlast = [ 0 for i in range( 0, 150 ) ]\nsum = [ 0 for i in range( 0, 105 ) ]\ndp = [ [ 0 for j in range( 0, 105 ) ] for i in range( 0, 105 ) ]\nsum[ 0 ] = 1\ndp[ 0 ][ 0 ] = 1\n\nfor i in range( 1, n + 1 ):\n\tfor j in range( i, 0, -1 ):\n\t\tdp[ i ][ j ] = dp[ i ][ j ] + sum[ j - 1 ]\n\t\tsum[ j ] = sum[ j ] + dp[ i ][ j ]\n\tif last[ ord( s[ i - 1 ] ) ]:\n\t\tpos = last[ ord( s[ i - 1 ] ) ]\n\t\tfor j in range( pos, 0, -1 ):\n\t\t\tsum[ j ] = sum[ j ] - dp[ pos ][ j ]\n\t\t\tdp[ pos ][ j ] = 0\n\tlast[ ord( s[ i - 1 ] ) ] = i\n\nans = 0\nfor i in range( n, -1, -1 ):\n\tseq = min( k, sum[ i ] )\n\tk = k - seq\n\tans = ans + seq * ( n - i )\nif k:\n\tans = -1\nprint ans\n"}, {"source_code": "from __future__ import division, print_function\n\nDEBUG = 0\n\nimport os, sys\nfrom atexit import register\nfrom io import BytesIO\nimport itertools\n\nif sys.version_info[0] < 3:\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\nif DEBUG:\n debug_print = print\nelse:\n sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\n sys.stdout = BytesIO()\n register(lambda: os.write(1, sys.stdout.getvalue()))\n\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n debug_print = lambda *x, **y: None\n\n\ndef input_as_list():\n return list(map(int, input().split()))\n\ndef array_of(f, *dim):\n return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()\n\ndef main():\n from collections import defaultdict\n\n n, k = input_as_list()\n s = input()\n\n counts = [1]\n prev = []\n _set = set()\n for c in s:\n _set.add(c)\n prev.append(len(_set))\n counts.append(prev[-1])\n\n for depth in range(1, n):\n this = []\n _dict = defaultdict(int)\n\n for i, c in enumerate(s):\n if i < depth:\n v = 0\n else:\n v = this[i-1] + prev[i-1] - _dict[c]\n _dict[c] = prev[i-1]\n this.append(v)\n\n counts.append(this[-1])\n prev = this\n\n cost = 0\n count = 0\n cur_cost = 0\n while counts:\n v = counts.pop()\n if count + v >= k:\n cost += cur_cost * (k-count)\n print(cost)\n return\n else:\n count += v\n cost += cur_cost * v\n cur_cost += 1\n\n print(-1)\n\nmain()"}, {"source_code": "n, k = map(int, input().split(' '))\ns = input()\ndp = [[0] * (n + 1) for _ in range(n + 1)]\ndp[0][0] = 1\nfor l in range(0, n):\n for i in range(l, n + 1):\n used = [False] * 26\n for j in range(i + 1, n + 1):\n ch = ord(s[j - 1]) - ord('a')\n if not used[ch]:\n dp[l + 1][j] += dp[l][i]\n used[ch] = True\ntotal = 0\nfor l in range(n, -1, -1):\n sums = sum(dp[l])\n if sums >= k:\n total += (n - l) * k\n k = 0\n break\n total += (n - l) * sums\n k -= sums\nif k > 0:\n total = -1\nprint(total)\n"}, {"source_code": "def subsequences_of_length(s):\n n = len(s)\n\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n to_int = {}\n for i, char in enumerate(alphabet):\n to_int[char] = i\n\n next_i = [[n] * len(alphabet) for i in range(n + 1)]\n for i in reversed(range(n)):\n for j, char in enumerate(alphabet):\n next_i[i][j] = next_i[i+1][j]\n next_i[i][to_int[s[i]]] = i\n\n dp = [[0] * (n + 1) for i in range(n + 1)]\n dp[0][0] = 1\n for i in range(n):\n for k in range(n):\n for j in range(26):\n if next_i[i][j] >= n:\n continue\n dp[k+1][next_i[i][j] + 1] += dp[k][i]\n\n ans = [sum(dp[i]) for i in range(n + 1)]\n return ans\n\n\nn, k = map(int, input().split())\ns = input()\nans_len = subsequences_of_length(s)\n\nans_cnt = 0\nans = 0\nfor length in reversed(range(len(ans_len))):\n cnt = ans_len[length]\n if ans_cnt + cnt <= k:\n ans_cnt += cnt\n ans += cnt * (n - length)\n else:\n ans += (k - ans_cnt) * (n - length)\n ans_cnt = k\nif ans_cnt != k:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn,W=map(int,input().split())\ns=input().strip()\n\nNEXTLIST=[[n]*26 for i in range(n+1)]\n\nfor i in range(n-1,-1,-1):\n for j in range(26):\n NEXTLIST[i][j]=NEXTLIST[i+1][j]\n NEXTLIST[i][ord(s[i])-97]=i\n\nDP=[[0]*(n+1) for i in range(n+1)]\n\nDP[0][0]=1\n\nfor i in range(n):\n for j in range(26):\n if NEXTLIST[i][j]!=n:\n for k in range(n):\n DP[NEXTLIST[i][j]+1][k+1]+=DP[i][k]\n\n#print(DP)\n\nHLIST=[0]*(n+1)\n\nfor i in range(n+1):\n for j in range(n+1):\n HLIST[j]+=DP[i][j]\n\n#print(HLIST)\n\nANS=0\nfor i in range(n,-1,-1):\n #print(i,W)\n if W>HLIST[i]:\n ANS+=(n-i)*HLIST[i]\n W-=HLIST[i]\n else:\n ANS+=W*(n-i)\n print(ANS)\n sys.exit()\n\nelse:\n print(-1)\n"}, {"source_code": "from sys import stdin\n\nn, k = [int(i) for i in stdin.readline().strip().split()]\ns = stdin.readline().strip()\n\n\nclass Subsequences:\n def __init__(self, sequence):\n self._seq = list(sequence)\n self._F = [len(sequence) * [0] for _ in range((len(sequence) + 1))]\n self._calc()\n\n def _calc(self):\n # iterative solution F[size][index] given number of distinct subsequences of given size\n # in slice [0: index + 1] of original sequence\n F = self._F\n size = 0\n for index in range(len(s)):\n F[size][index] = 1\n F[1][0] = 1\n\n p = {s[0]: 0}\n for i in range(1, len(s)):\n for k in range(1, len(s) + 1):\n if k > i + 1:\n val = 0\n else:\n val = F[k][i - 1] + F[k - 1][i - 1]\n if s[i] in p:\n val -= F[k - 1][p[s[i]] - 1]\n F[k][i] = val\n p[s[i]] = i\n\n def count(self, size, index=None):\n index = index or (len(self._seq) - 1)\n return self._F[size][index]\n\n\n# recursive solution with memoization\nprevious_letter_index = {}\nfound = {}\nfor index, letter in enumerate(s):\n if letter in found:\n previous_letter_index[(letter, index)] = found[letter]\n found[letter] = index\n\n_subsequences = {}\n\n\ndef subsequences(size, index):\n \"\"\"Get number of distinct subsequences of given size in sequence[0:index + 1] slice\"\"\"\n if (size, index) not in _subsequences:\n if size == 0:\n res = 1\n elif size > index + 1:\n res = 0\n else:\n res = subsequences(size, index - 1) + subsequences(size - 1, index - 1)\n letter = s[index]\n if (letter, index) in previous_letter_index:\n res -= subsequences(size - 1, previous_letter_index[(letter, index)] - 1)\n _subsequences[(size, index)] = res\n return _subsequences[(size, index)]\n\n\nss = Subsequences(s)\n\ntotal_cost = 0\nfor size in range(len(s), -1, -1):\n if k == 0:\n break\n step_cost = n - size\n sequence_count = subsequences(size, len(s) - 1)\n if sequence_count > k:\n sequence_count = k\n total_cost += step_cost * sequence_count\n k -= sequence_count\n\nif k == 0:\n print(total_cost)\nelse:\n print(-1)\n"}, {"source_code": "from sys import stdin\n\nn, k = [int(i) for i in stdin.readline().strip().split()]\ns = stdin.readline().strip()\n\n\ndef get_f(s):\n F = [len(s) * [0] for _ in range((len(s) + 1))]\n size = 0\n for index in range(len(s)):\n F[size][index] = 1\n F[1][0] = 1\n\n p = {s[0]: 0}\n for i in range(1, len(s)):\n for k in range(1, len(s) + 1):\n if k > i + 1:\n val = 0\n else:\n val = F[k][i - 1] + F[k - 1][i - 1]\n if s[i] in p:\n # sic: if k - 1 == 0 then answer is always 1\n # if k - 1 == 0:\n # print(i)\n # val -= 1\n if p[s[i]] - 1 >= 0:\n val -= F[k - 1][p[s[i]] - 1]\n elif p[s[i]] == 0 and k - 1 == 0:\n val -= 1\n F[k][i] = val\n p[s[i]] = i\n return F\n\n_F = get_f(s)\n\n# for sz in range(len(s) + 1):\n# for index in range(len(s)):\n# print(_F[sz][index], end=' ')\n# print()\n\n\ndef count(size, index = None):\n return _F[size][index or (len(s) - 1)]\n\n\n# recursive solution with memoization\nprevious_letter_index = {}\nfound = {}\nfor index, letter in enumerate(s):\n if letter in found:\n previous_letter_index[(letter, index)] = found[letter]\n found[letter] = index\n\n_subsequences = {}\n\n\ndef subsequences(size, index):\n \"\"\"Get number of distinct subsequences of given size in sequence[0:index + 1] slice\"\"\"\n if (size, index) not in _subsequences:\n if size == 0:\n res = 1\n elif size > index + 1:\n res = 0\n else:\n res = subsequences(size, index - 1) + subsequences(size - 1, index - 1)\n letter = s[index]\n if (letter, index) in previous_letter_index:\n res -= subsequences(size - 1, previous_letter_index[(letter, index)] - 1)\n _subsequences[(size, index)] = res\n return _subsequences[(size, index)]\n\n\ntotal_cost = 0\nfor size in range(len(s), -1, -1):\n if k == 0:\n break\n step_cost = n - size\n sequence_count = count(size, len(s) - 1)\n # print('size = ', size, 'count = ', sequence_count)\n if sequence_count > k:\n sequence_count = k\n total_cost += step_cost * sequence_count\n k -= sequence_count\n\nif k == 0:\n print(total_cost)\nelse:\n print(-1)\n"}, {"source_code": "from sys import stdout, stdin\n\nn, kk = map(int, stdin.readline().split())\ns = stdin.readline().strip()\ns += \"$\"\nn = n+1\n\ndp = [[0 for i in range(n)] for j in range(n)]\np = 10**15+5\nfor i in range(n):\n dp[i][0] = 1\nfor end in range(n):\n for length in range(1, n):\n seen = []\n ans = 0\n for k in range(end-1, -1, -1):\n if s[k] not in seen:\n seen.append(s[k])\n ans += dp[k][length-1]\n ans %= p\n dp[end][length] = ans\n\ntotals = [dp[n-1][length] for length in range(n)]\n#print(totals)\n\nans = 0\nidx = n-1\nwhile idx >= 0 and kk > 0:\n ans += min(totals[idx], kk)*(n-1-idx)\n kk -= totals[idx]\n idx -= 1\n\nif kk <= 0:\n stdout.write(str(ans) +\"\\n\")\nelse:\n print(-1)\n\n"}, {"source_code": "n,k=map(int,input().split())\ns=input()\ns=[ord(c)-ord('a') for c in s]\ndp=[[[0]*26 for i in range(n+1)]for i in range(n)]\ndp[0][1][s[0]]=1\nsm=None\n\nfor i in range(1,n):\n c=s[i]\n for cc in range(26):\n dp[i][1][cc]=dp[i-1][1][cc]\n dp[i][1][c]=1\n for j in reversed(range(2,n+1)):\n for cc in range(26):\n if cc!=c:\n dp[i][j][cc]=dp[i-1][j][cc]\n else:\n tm=0\n for t in range(26):\n tm+=dp[i-1][j-1][t]\n dp[i][j][cc]=tm\n# print(dp[-1][-1])\ndef get(x):\n if x==0:\n return 1\n ans=0\n for i in range(26):\n ans+=dp[-1][x][i]\n return ans\ncnt=0\ncost=0\nfor re in reversed(range(n+1)):\n x=get(re)\n if x+cnt>=k:\n cost+=(n-re)*(k-cnt)\n cnt=k\n break\n else:\n cost+=(n-re)*x\n cnt+=x\nif cnt<k:\n print(-1)\nelse:\n print(cost)"}, {"source_code": "n, k = map(int, input().split())\ns = '{' + input()\ndp = [[0] * (n + 1) for _ in range(n + 1)]\n\n# dp\ndp[0][0] = 1\noa = ord('a')\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n hold = [0] * 30\n for l in range(0, i): # Transition from dp[l][j - 1]\n let = ord(s[l]) - oa;\n # db(i); db(j); db(dp[i][j]); db(dp[l][j - 1]); db(hold[let]); dbln;\n dp[i][j] += dp[l][j - 1] - hold[let]\n\n hold[let] = dp[l][j - 1]\n\n # dblb(\"ret\"); db(i); db(j); db(dp[i][j]); dbln;\n\n# sum costs\ntot = 0\nfor i in range(n, -1, -1):\n cost = n - i\n dpsum = 0\n hold = [0] * 30\n for j in range(0, n + 1):\n let = ord(s[j]) - oa\n dpsum += dp[j][i] - hold[let]\n hold[let] = dp[j][i]\n\n sub = min(k, dpsum)\n # print(f'i={i} dpsum={dpsum}')\n\n tot += sub * cost\n k -= sub\n\nif k > 0:\n print(-1)\nelse:\n print(tot)\n"}, {"source_code": "n, kk = map(int, input().split())\ns = '@'+input()\ndp = [[0] * (n+1) for i in range(n+1)]\ndp[0][0] = 1\nfor i in range(1, n+1):\n for j in range(i, n+1):\n tag = [True]*26\n for k in range(j, n+1):\n idx = ord(s[k])-ord('a')\n if tag[idx]:\n dp[i][k] += dp[i-1][j-1]\n tag[idx] = False\nans = 0\n# print(dp)\nfor i in range(n, -1, -1):\n # print(ans,k,i)\n tmp = sum(dp[i])\n if kk > tmp:\n kk -= tmp\n ans += (n-i)*tmp\n else:\n ans += kk*(n-i)\n kk = 0\n break\nif kk > 0:\n ans = -1\nprint(ans)\n"}, {"source_code": "[n, k] = [int(i) for i in input().split()]\ns = input()\ncntsz = [0 for i in range(105)]\ndp = [[0 for i in range(105)] for j in range(105)]\nlst = [0 for i in range(105)]\nprv = [0 for i in range(26)]\nn = len(s)\ns = '%' + s\nfor i in range(n + 1):\n dp[i][0]=1\nfor i in range(1, n + 1):\n\tlst[i] = prv[ord(s[i])-ord('a')]\n\tprv[ord(s[i]) - ord('a')] = i\nfor sz in range(1, n + 1):\n\tfor i in range(1, n + 1):\n\t\tdp[i][sz] += dp[i - 1][sz]\n\t\tdp[i][sz] += dp[i - 1][sz - 1]\n\t\tif lst[i] != 0:\n\t\t\t dp[i][sz] -= dp[lst[i]-1][sz-1]\nfor sz in range(1, n + 1):\n\tfor i in range(1, n + 1):\n\t\tcntsz[sz] += dp[i][sz]\n\t\tcntsz[sz] -= dp[i - 1][sz]\ncntsz[0] += 1\ndone = 0\nans = 0\nfor i in range(n, -1, -1):\n if done + cntsz[i] >= k:\n ans += (n - i) * (k - done)\n done = k\n break\n done += cntsz[i]\n ans += cntsz[i] * (n - i)\nif done < k:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\nimport bisect\nn,k=map(int,input().split())\ns=input()\nNext=[[float(\"inf\")]*(26) for _ in range(n+1)]\nfor i in reversed(range(n)):\n for j in range(26):\n Next[i][j]=Next[i+1][j]\n Next[i][ord(s[i])-97]=i\nDP=[[0]*(n+1) for _ in range(n+1)]\nDP[0][0]=1\nfor i in range(n):\n for j in range(26):\n nxt=Next[i][j]\n for l in range(n):\n if nxt<float(\"inf\"):\n DP[nxt+1][l+1]+=DP[i][l]\nAns=[0]*(n+1)\nfor i in range(n+1):\n for j in range(n+1):\n Ans[n-j]+=DP[i][j]\nAns2=[0]\nfor i in range(n+1):\n Ans2.append(Ans2[-1]+Ans[i])\nif Ans2[-1]<k:\n print(-1)\nelse:\n ind=bisect.bisect_left(Ans2,k)\n ans,num=0,0\n for i in range(ind-1):\n ans+=i*Ans[i]\n num+=Ans[i]\n ans+=(ind-1)*(k-num)\n print(ans)"}, {"source_code": "N,K=map(int,input().split())\nS=input()\ndp=[[0]*110 for i in range(110)]\nlst=[[0]*110 for i in range(110)]\nfor i in range(N+1):\n dp[i][0]=1\nfor k in range(26):\n lst[0][k]=-1\nfor i in range(N):\n num=ord(S[i])-ord('a')\n for k in range(26):\n lst[i+1][k]=lst[i][k]\n lst[i+1][num]=i\n\nfor i in range(N):\n num=ord(S[i])-ord('a')\n for k in range(1,N+1):\n dp[i+1][k]=dp[i][k]+dp[i][k-1]\n if lst[i][num]!=-1:\n dp[i+1][k]-=dp[lst[i][num]][k-1]\n\n\nrem=K\nans=0\nfor i in range(0,N+1):\n k=N-i\n\n if dp[N][k]>=rem:\n ans+=rem*(N-k)\n rem=0\n else:\n ans+=dp[N][k]*(N-k)\n rem-=dp[N][k]\n\nif rem>0:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "n, k = map(int, input().split())\ns = \"$\" + input()\n\ncnt = [[0]*(n+1) for i in range(n+1)]\n\ncnt[0][0] = 1\n\nfor l in range(1, n+1):\n\tfor i in range(l, n+1):\n\t\tused = [False] * 26\n\t\tfor j in range(i, n+1):\n\t\t\tx = ord(s[j]) - ord('a')\n\t\t\tif not used[x]:\n\t\t\t\tcnt[l][j] += cnt[l-1][i-1]\n\t\t\t\tused[x] = True\n\nans = 0\nfor l in range(n, -1, -1):\n\ts = sum(cnt[l])\n\tif s < k:\n\t\tans += (n-l) * s\n\t\tk -= s\n\telse:\n\t\tans += (n-l) * k\n\t\tk = 0\n\t\tbreak\n\nif k > 0: ans = -1\n\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\ndef solve(s, k):\n dp = defaultdict(int)\n dp[(-1,-1)] = 1\n n = len(s)\n last = {}\n\n for i in range(n):\n dp[(i, -1)] = 1\n for j in range(i+1):\n # ways choose this one + ways not choosing this one\n dp[(i,j)] = dp[(i-1,j-1)] + dp[(i-1, j)]\n # remove duplicates by removing the amout we get when using the last apperance of curr chr\n if s[i] in last:\n dp[(i, j)] -= dp[(last[s[i]]-1, j-1)]\n\n last[s[i]] = i\n\n\n cost = 0\n for i in reversed(range(-1, n)):\n cost += min(dp[(n-1,i)], k) * (n-1 -i)\n k -= dp[(n-1, i)]\n\n if k <= 0:\n return cost\n return -1\n\nn, k = list(map(int, input().split()))\ns = input()\nprint(solve(s, k))"}, {"source_code": "n, k = input().split (' ')\nn = int (n)\nk = int (k)\ns = input()\ns = \"-\" + s\ndp = [ [ 0 for i in range (110)] for j in range (110)]\nadded = [ [ 0 for i in range (110)] for j in range (110)]\nlst = [0 for i in range (310)]\nlstAdded = [0 for i in range (310)]\nfor i in range (0, 110):\n dp[0][i] = 1\nvec = list()\nst = set()\nfor i in range (1, n+1):\n st.add (s[i])\n dp[1][i] = len (st)\nvec.append (1)\nvec.append (dp[1][n])\nfor t in range (2, n+1):\n for i in range(310):\n lst[i] = 0\n lstAdded[i] = 0\n for i in range (1, n+1):\n dp[t][i] = dp[t-1][i-1] + dp[t][i-1] - lstAdded[ord(s[i])]\n #if (lst[ord(s[i])] > 0):\n # dp[t][i] += dp[t-1][lst[ord(s[i])]-1]\n lstAdded[ord(s[i])] += dp[t][i] - dp[t][i-1]\n added[t][i] = dp[t][i] - dp[t][i-1]\n lst[ord(s[i])] = i\n vec.append (dp[t][n])\n # print (t, dp[t][n])\n\nans = 0\nqnt = 0\nwhile (k > 0 and len (vec)):\n now = vec.pop()\n #print (now, k, ans)\n use = min (k, now)\n k = k - use\n ans += qnt * use\n qnt+=1\nif (k == 0):\n print (ans)\nelse:\n print (-1)"}, {"source_code": "n,k=map(int,input().split())\ns=input()\n\npos=[-1]*26\nlst=[]\nfor i in range(0,len(s)):\n pos[ord(s[i])-97]=i\n h=[]\n for j in range(26):\n h.append(pos[j])\n lst.append(h)\n\ndp=[]\nfor i in range(n):\n h=[]\n for j in range(n+1):\n h.append(0)\n dp.append(h)\n\nfor i in range(n):\n dp[i][1]=1\n\nfor j in range(2,n+1):\n for i in range(1,n):\n for e in range(26):\n if(lst[i-1][e]!=-1):\n dp[i][j]=dp[i][j]+dp[lst[i-1][e]][j-1]\n\n\nans=0\nfor j in range(n,0,-1):\n c=0\n for e in range(26):\n if(lst[n-1][e]!=-1):\n c+=dp[lst[n-1][e]][j]\n if(k-c>=0):\n ans+=(c*(n-j))\n k-=c\n else:\n req=k\n ans+=(req*(n-j))\n k-=req\n break\n\nif(k==1):\n ans+=n\n k-=1\nif(k>0):\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\nfrom math import factorial\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heapify, heappop, heappush\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0\ndef perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\nmod = 998244353\nINF = float('inf')\n\n# ------------------------------\n\ndef c(chr): return ord(chr)-ord('a')\n\ndef main():\n n, k = RL()\n s = input()\n\n dp = [[0]*(n+1) for i in range(n+1)]\n rec = [-1]*26\n pre = [-1]*n\n\n for i in range(n+1):\n dp[i][0] = 1\n\n for i in range(n):\n now = c(s[i])\n pre[i] = rec[now]\n rec[now] = i\n\n for i in range(1, n+1):\n for j in range(1, i+1):\n # if j>i: break\n\n dp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n # if i == 6 and j == 1: print(dp[i-1][j], dp[i-1][j-1])\n if pre[i-1]!=-1:\n # if i==5 and j==4: print(pre[i-1], '+++')\n # if i==6 and j==1: print(pre[i-1], dp[pre[i-1]][j], dp[i][j])\n dp[i][j] -= dp[pre[i-1]][j-1]\n\n\n res = 0\n for j in range(n, -1, -1):\n if k:\n num = min(k, dp[-1][j])\n k-=num\n res += (n-j)*num\n\n # for i in dp: print(i)\n print(res if k==0 else -1)\n\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "\n# NUMBER OF DISTINCT SUBSEQUENCES OF EVERY LENGTH K FOR 0<=K<=len(s)\n\n\nn,k=map(int,input().split())\ns=input()\n\npos=[-1]*26\nlst=[]\nfor i in range(0,len(s)):\n pos[ord(s[i])-97]=i\n h=[]\n for j in range(26):\n h.append(pos[j])\n lst.append(h)\n\ndp=[]\nfor i in range(n):\n h=[]\n for j in range(n+1):\n h.append(0)\n dp.append(h)\n\nfor i in range(n):\n dp[i][1]=1\n\nfor j in range(2,n+1):\n for i in range(1,n):\n for e in range(26):\n if(lst[i-1][e]!=-1):\n dp[i][j]=dp[i][j]+dp[lst[i-1][e]][j-1]\n\n\nans=0\nfor j in range(n,0,-1):\n c=0\n for e in range(26):\n if(lst[n-1][e]!=-1):\n c+=dp[lst[n-1][e]][j]\n if(k-c>=0):\n ans+=(c*(n-j))\n k-=c\n else:\n req=k\n ans+=(req*(n-j))\n k-=req\n break\n\nif(k==1):\n ans+=n\n k-=1\nif(k>0):\n print(-1)\nelse:\n print(ans)\n\n\n\"\"\"\n\n# TOTAL NUMBER OF DISTINCT SUBSEQUENCES IN A STRING\n\n## APPROACH 1\n\nMOD=1000000007\n\ns=input()\nn=len(s)\n\ndp=[1] # for empty string ''\nkk=dict()\n\nfor i in range(0,len(s)):\n term=(dp[-1]*2)%MOD\n if(kk.get(s[i])!=None):\n term=(term-dp[kk[s[i]]])%MOD\n kk[s[i]]=i\n dp.append(term)\n\nprint(dp[-1])\n\n\n\n## APPROACH 2\n\nMOD=1000000007\n\ns=input()\nn=len(s)\n\npos=[-1]*26\n\ndp=[1] # for empty string ''\n\nfor i in range(0,len(s)):\n c=1\n for j in range(26):\n if(pos[j]!=-1):\n c=(c+dp[pos[j]+1])%MOD\n pos[ord(s[i])-97]=i\n dp.append(c)\n \n\nans=1\nfor i in range(0,26):\n if(pos[i]!=-1):\n ans=(ans+dp[pos[i]+1])%MOD\n\nprint(ans)\n\n \n \n\"\"\""}, {"source_code": "import collections, heapq, math, sys\nfrom string import ascii_lowercase\n\nn, k = map(int, sys.stdin.readline().rstrip().split(' '))\ns = sys.stdin.readline().rstrip()\n\nd = {}\nd[n - 1] = {}\ncurr = {}\nfor letter in ascii_lowercase:\n curr[letter] = n\n\nfor i in range(n - 1, -1, -1):\n d[i] = {}\n for letter in ascii_lowercase:\n d[i][letter] = curr[letter]\n curr[s[i]] = i\n\ndp = [[0 for _ in range(n + 1)] for _ in range(n)]\nfor i in range(n - 1, -1, -1):\n dp[i][1] += 1\n for letter in ascii_lowercase:\n nxt = d[i][letter]\n if nxt == n:\n continue\n for j in range(2, n + 1):\n dp[i][j] += dp[nxt][j - 1]\nz = collections.defaultdict(int)\nz[0] = 1\nfor letter in ascii_lowercase:\n nxt = curr[letter]\n if nxt == n: continue\n for i in range(1, n + 1):\n z[i] += dp[nxt][i]\n\nret = 0\ncnt = 0\n# print(z)\nfor i in range(n, -1, -1):\n if z[i] > 0:\n added = min(z[i], k - cnt)\n ret += added * (n - i)\n cnt += added\n if cnt == k:\n break\nif cnt == k:\n print(ret)\nelse:\n print(-1)"}, {"source_code": "import sys\nfrom collections import defaultdict\nn,k=map(int,input().split())\ns=input()\nb=[]\nfor j in s:\n b.append(j)\n\ndp=[[0 for i in range(n+1)] for j in range(n)]\nlast=defaultdict(lambda:0)\ndp[0][0]=1\ndp[0][1]=1\nlast[b[0],0]=1\nlast[b[0],1]=1\n\nfor i in range(1,n):\n dp[i][0]=1\n for j in range(1,n+1):\n dp[i][j]=dp[i-1][j]+dp[i-1][j-1]-last[b[i],j]\n\n last[b[i],j]=dp[i-1][j-1]\n\ns=0\nres=0\n\n\nif sum(dp[-1])<k:\n print(-1)\n sys.exit()\nj=n\nwhile(j>=0):\n if s+dp[-1][j]<k:\n s+=dp[-1][j]\n res+=dp[-1][j]*(n-j)\n\n else:\n res+=(k-s)*(n-j)\n break\n\n j+=-1\n\nprint(res)\n\n"}, {"source_code": "n, d = map(int,input().split())\ns = input()\nt = [[-1 for i in range(n + 1)] for j in range(n + 1)]\nfor i in range(1, n + 1):\n\tfor j in range(i, n + 1):\n\t\tif j == i:\n\t\t\tt[i][j] = 1\n\t\telse:\n\t\t\tt[i][j] = 0\njes = [0] * 300\nfor i in range(1, n + 1):\n\tjes[ord(s[i - 1])] = 1\n\tt[i][1] = sum(jes)\nfor j in range(2, n + 1):\n\tind = [-1] * 300\n\tind[ord(s[j - 1])] = j - 1\n\t#obliczamy t[j + 1][j], t[j + 2][j], ...\n\tfor i in range(j + 1, n + 1):\n\t\tif ind[ord(s[i - 1])] == -1:\n\t\t\tt[i][j] = t[i - 1][j] + t[i-1][j-1] \n\t\telse:\n\t\t\tt[i][j] = t[i - 1][j] + t[i - 1][j - 1] - t[ind[ord(s[i-1])]][j - 1]\n\t\tind[ord(s[i - 1])] = i - 1\n#t[n][1], t[n][2], ..., t[n][n]\nrozne = [t[n][i] for i in range(1, n + 1)]\nrozne.reverse()\nroz = rozne + [1]\ndupa = 0\nwyn = 0\nfor i in range(n + 1):\n\tif dupa < d:\n\t\tk = min(roz[i], (d-dupa))\n\t\tdupa += k\n\t\twyn += k * i\n\telse:\n\t\tbreak\nif dupa >= d:\n\tprint(wyn)\nelse:\n\tprint(-1)\n\t"}, {"source_code": "n, k = map(int, raw_input().split())\ns = raw_input()\n\nr = 0\nsi = {s}\nk -= 1\n\nfor d in range(1, n+1):\n si = {t[:i]+t[i+1:] for i in range(n-d+1) for t in si}\n ni = len(si)\n if ni < k:\n r += ni * d\n k -= ni\n else:\n r += k * d\n k = 0\n break\n\nprint(-1 if k > 0 else r)\n\n"}, {"source_code": "import fileinput\ndef D(a):print(a)\ndef S(s,I):return int(s.split(\" \")[I])\ndef dyn(u,r):\n global N\n global X\n global dp\n if(u<0):return 0\n if(r==0):return 1\n if(u>=N):return 0\n if(dp[u][r]!=-1):return dp[u][r];\n v=0\n for i in range(26):\n v+=dyn(X[u][i]+1,r-1)\n dp[u][r]=v\n return v\ndef main():\n z=0\n global N\n global X\n global dp\n K=0\n for l in fileinput.input():\n z+=1\n if(z<2):\n N=S(l,0)\n K=S(l,1)\n continue\n X=[0]*(N+1)\n X[N]=[-666]*26\n for i in xrange(N-1,-1,-1):\n X[i]=[-1]*26\n for j in range(26):X[i][j]=X[i+1][j]\n X[i][ord(l[i])-97]=i\n dp=[0]*N\n for i in range(N):\n dp[i]=[-1]*(N+1)\n o=0\n for i in xrange(N,-1,-1):\n a=dyn(0,i)\n if(a<=K):\n o+=(N-i)*a\n K-=a\n else:\n o+=(N-i)*K\n K=0\n if(K!=0):D(-1)\n else: D(o)\nmain()\n"}, {"source_code": "from collections import deque\nn, k = [int(x) for x in raw_input().split()]\ns = str(raw_input())\nq = deque([s])\n\nS = set()\n\ncost = 0\nsuccess = False\nwhile len(q) != 0:\n s = q.popleft()\n if s not in S:\n S.add(s)\n cost += n-len(s)\n if len(S) != k:\n for i in range(len(s)):\n q.append(s[0:i]+s[i+1:])\n else:\n success = True\n print(cost)\n break\nif not success:\n print(-1)"}, {"source_code": "S = set()\ncusto = 0\ngenerated = []\ndef generate(ln, k):\n for st in list(generated[ln]):\n for i in xrange(len(st)):\n to_add = st[:i] + st[i+1:]\n generated[ln-1].add(to_add)\n S.add(to_add)\n if len(S) == k: return\n \nn, k = map(int, raw_input().split())\ns = raw_input()\nS.add(s)\nfor i in xrange(n+1): generated.append(set())\ngenerated[0].add('')\ngenerated[-1].add(s)\nif (pow(2, n) < k): print -1\nelif (k == 1): print 0\nelse:\n for l in xrange(n, 0, -1): \n generate(l, k)\n if len(S) == k: break\n\n if len(S) < k: print -1\n else:\n generated = list(S)\n for i in xrange(len(S)): custo += (n - len(generated[i]))\n print custo\n"}, {"source_code": "from collections import deque\nn, k = [int(x) for x in raw_input().split()]\ns = str(raw_input())\nq = deque([s])\n\nS = set()\n\ncost = 0\nsuccess = False\nwhile len(q) != 0:\n s = q.popleft()\n if s not in S:\n S.add(s)\n cost += n-len(s)\n if len(S) != k:\n for i in range(len(s)):\n q.append(s[0:i]+s[i+1:])\n else:\n success = True\n print(cost)\n break\nif not success:\n print(-1)"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\nimport random\nimport collections\nimport math\nimport itertools\nimport bisect\n\ndef real_main():\n n, k = read_int_array()\n ans = 0\n ssize = 1\n buckets = [dict() for _ in range(n+1)]\n buckets[n][read()] = 0\n max_bucket = n\n while ssize < k:\n if not max_bucket:\n print(-1)\n return\n for s, i in buckets[max_bucket].items():\n for i in range(i, len(s)):\n new_s = s[:i] + s[i+1:]\n if new_s not in buckets[max_bucket - 1]:\n buckets[max_bucket - 1][new_s] = 0\n ans += n - max_bucket + 1\n ssize += 1\n\n i += 1\n while i < len(s) and s[i-1] == s[i]:\n i += 1\n buckets[max_bucket][s] = i\n break\n else:\n buckets[max_bucket].pop(s)\n break\n else:\n max_bucket -= 1\n print(ans)\n\n\ndef solve():\n pass\n\n\ndef main():\n if False and 'PYCHARM_HOSTED' in os.environ:\n main_pycharm()\n else:\n real_main()\n\n\nfrom copy import deepcopy\ndef main_pycharm():\n solution = solve\n\n test_inputs = None\n test_outputs = None\n judge = None\n slow_solution = None\n if solution is not None:\n if test_outputs is not None:\n test_with_answers(solution, test_inputs, test_outputs)\n if judge is not None:\n test_with_judge(solution, test_inputs, judge)\n if slow_solution is not None:\n test_with_slow_solution(solution, test_inputs, slow_solution)\n\n\ndef test_with_answers(solution, inputs, answers):\n total, wrong = 0, 0\n for args, test_ans in zip(inputs, answers):\n ans = solution(*deepcopy(args))\n if ans != test_ans:\n print('WRONG! ans=%s, test_ans=%s, args=%s' % (ans, test_ans, args))\n wrong += 1\n else:\n print('GOOD')\n total += 1\n print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))\n\n\ndef test_with_judge(solution, inputs_gen, judge):\n total, wrong = 0, 0\n for args in inputs_gen:\n ans = solution(*deepcopy(args))\n if not judge(deepcopy(ans), *deepcopy(args)):\n print('WRONG! ans=%s, args=%s' % (ans, args))\n wrong += 1\n total += 1\n print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))\n\n\ndef test_with_slow_solution(solution, inputs_gen, solution_slow):\n total, wrong = 0, 0\n for args in inputs_gen:\n ans = solution(*deepcopy(args))\n slow = solution_slow(*deepcopy(args))\n if ans != slow:\n print('WRONG! ans=%s, slow=%s, args=%s' % (ans, slow, args))\n wrong += 1\n total += 1\n print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))\n\ndef generate_nums(n, min, max, check_if_good=None):\n while True:\n nums = [random.randint(min, max) for _ in range(n)]\n if check_if_good is None or check_if_good(nums):\n return nums\n\n# This mergesort can be like 7 times faster than build in sort\n# (for stupid reasons)\ndef mergesort(A, key=lambda x: x, reverse=False):\n C = A\n A = list(range(len(A)))\n B = list(A)\n\n n = len(A)\n for i in range(0, n - 1, 2):\n if key(C[A[i]]) > key(C[A[i ^ 1]]):\n A[i], A[i ^ 1] = A[i ^ 1], A[i]\n\n width = 2\n while width < n:\n for i in range(0, n, 2 * width):\n R1, R2 = min(i + width, n), min(i + 2 * width, n)\n j, k = R1, i\n while i < R1 and j < R2:\n if key(C[A[i]]) > key(C[A[j]]):\n B[k] = A[j]\n j += 1\n else:\n B[k] = A[i]\n i += 1\n k += 1\n while i < R1:\n B[k] = A[i]\n k += 1\n i += 1\n while k < R2:\n B[k] = A[k]\n k += 1\n A, B = B, A\n width *= 2\n\n if reverse:\n A.reverse()\n return A\n\ndef mergesort_simple(A, reverse=False):\n C = A\n A = list(range(len(A)))\n B = list(A)\n\n n = len(A)\n for i in range(0, n - 1, 2):\n if C[A[i]] > C[A[i ^ 1]]:\n A[i], A[i ^ 1] = A[i ^ 1], A[i]\n\n width = 2\n while width < n:\n for i in range(0, n, 2 * width):\n R1, R2 = min(i + width, n), min(i + 2 * width, n)\n j, k = R1, i\n while i < R1 and j < R2:\n if C[A[i]] > C[A[j]]:\n B[k] = A[j]\n j += 1\n else:\n B[k] = A[i]\n i += 1\n k += 1\n while i < R1:\n B[k] = A[i]\n k += 1\n i += 1\n while k < R2:\n B[k] = A[k]\n k += 1\n A, B = B, A\n width *= 2\n\n if reverse:\n A.reverse()\n return A\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef read():\n return input()\n\ndef read_int():\n return int(input())\n\ndef read_array(sep=None, maxsplit=-1):\n return input().split(sep, maxsplit)\n\ndef read_int_array():\n return [int(a) for a in read_array()]\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,k=map(int,input().split())\nr=set()\nr1=set()\na=input()\nqueue=[a]\ncost=0\nco=0\nr1.add(a)\nwhile queue:\n ref=queue.pop(0)\n if(ref not in r):\n r.add(ref)\n cost+=(n-len(ref))\n co+=1\n if(co==k):\n break\n for i in range(len(ref)):\n y=ref[:i]+ref[i+1:]\n if(y not in r1):\n queue.append(y)\n r1.add(y)\nif(len(r)<k):\n print(-1)\n exit(0)\nprint(cost)\n \n"}, {"source_code": "n,k=map(int,input().split())\ns=input()\nst=[set() for i in range(n+1)]\nst[n].add(s)\nc=1\nk-=1\nans=0\nfor i in range(n,0,-1):\n for w in st[i]:\n for j in range(i):\n st[i-1].add(w[:j]+(w[j+1:] if j!=i-1 else ''))\n sz=len(st[i-1])\n if k<sz:\n ans+=(n-i+1)*k\n k=0\n break\n else:\n ans+=(n-i+1)*sz\n k-=sz\n #print(i,k,ans)\n if k<0:\n break\nif k>0:\n print(-1)\nelse:\n print(ans)\n#print(k,ans,st)"}, {"source_code": "\nif __name__ == '__main__':\n n, k = map(int, input().split())\n aa = list(input())\n st = {\"\".join(aa)}\n arr = [aa]\n w = 0\n c = 0\n cst = 0\n while len(arr) < k and w < len(arr):\n wrd = arr[w][:c] + arr[w][c + 1:]\n wrds = \"\".join(wrd)\n if wrds not in st:\n st.add(wrds)\n arr.append(wrd)\n cst += n - len(wrd)\n\n c += 1\n if c >= len(arr[w]):\n c = 0\n w += 1\n\n if len(arr) < k:\n print(-1)\n else:\n print(cst)\n"}, {"source_code": "n,k = tuple([int(x) for x in input().split()])\ns=input()\nq = []\nnv = \"\"\nst = []\nst.append(s)\nans = 0\nq.append(s)\nwhile q!=[] and len(st)<k:\n v = q.pop(0)\n for i in range(len(v)):\n nv = v\n nv = nv[:i]+nv[i+1:]\n if nv not in st and len(st)+1<=k:\n q.append(nv)\n st.append(nv)\n ans += n - len(nv)\n\nif len(st)<k:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "#!/usr/bin/python3.6\n\n'''\n .__ .__ _______ _______ _________\n ______| |__ |__| ____ ____ _______ _____ \\ _ \\ \\ _ \\\\______ \\\n / ___/| | \\ | | / \\ / _ \\\\_ __ \\\\__ \\ / /_\\ \\ / /_\\ \\ / /\n \\___ \\ | Y \\| || | \\( <_> )| | \\/ / __ \\_\\ \\_/ \\\\ \\_/ \\ / /\n/____ >|___| /|__||___| / \\____/ |__| (____ / \\_____ / \\_____ //____/\n \\/ \\/ \\/ \\/ \\/ \\/\n\n'''\n# Run locally with python3.6 -O code.py to run in not debug mode. [ONLINE_JUDGE]\n# rm ~/pipe2; mkfifo ~/pipe2 ; ./code.py < ~/pipe2 | ./interactive.py > ~/pipe2\n# rm ~/pipe2; mkfifo ~/pipe2 ; ./code.py < ~/pipe2 | ./matcher.py > ~/pipe2\n\n# one-way\n# ./haha.py > input.txt ; ./code.py < input.txt\n\nimport sys\n\ndef eprint(*args, **kwargs):\n if __debug__:\n print(*args, file=sys.stderr, **kwargs) \n\ndef calculate_res(visit, n):\n return n*len(visit) - sum([len(x) for x in visit])\n\ndef traverse(s, k):\n _que = []\n visit = set([])\n\n _que.append(s)\n visit.add(s)\n if len(visit) == k:\n return calculate_res(visit, len(s))\n\n while len(_que) > 0:\n cur = _que.pop(0)\n for i in range(len(cur)):\n adj_s = cur[0:i] + cur[i+1:len(cur)]\n if adj_s not in visit:\n _que.append(adj_s)\n visit.add(adj_s)\n if len(visit) == k:\n return calculate_res(visit, len(s))\n return -1\n\n\nif __name__ == \"__main__\":\n n, k = map(int, input().split(' '))\n s = input()\n\n print(traverse(s, k))\n\n"}, {"source_code": "n, k = map(int, input().split(' '))\ns = input()\ndp = [[0] * (n + 1) for _ in range(n + 1)]\ndp[0][0] = 1\nfor l in range(0, n):\n for i in range(l, n + 1):\n used = [False] * 26\n for j in range(i + 1, n + 1):\n ch = ord(s[j - 1]) - ord('a')\n if not used[ch]:\n dp[l + 1][j] += dp[l][i]\n used[ch] = True\ntotal = 0\nfor l in range(n, -1, -1):\n sums = sum(dp[l])\n if sums >= k:\n total += (n - l) * k\n k = 0\n break\n total += (n - l) * sums\n k -= sums\nif k > 0:\n total = -1\nprint(total)"}, {"source_code": "# @author \n\nimport sys\n\nclass ESubsequencesEasyVersion:\n def solve(self):\n n, k = [int(_) for _ in input().split()]\n s = input()\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n dp[0][0] = 1\n last = {key : -1 for key in (chr(x) for x in range(ord('a'), ord('z') + 1))}\n for i in range(1, n + 1):\n dp[i][0] = 1\n for j in range(1, i + 1):\n dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1] - (dp[last[s[i - 1]]][j - 1] if last[s[i - 1]] != -1 else 0)\n last[s[i - 1]] = i - 1\n\n ans = 0\n tot = 0\n for sz in range(n, -1, -1):\n ans += min(k - tot, dp[n][sz]) * (n - sz)\n tot = min(k, tot + dp[n][sz])\n if tot == k:\n break\n \n if tot >= k:\n print(ans)\n else:\n print(-1)\n\nsolver = ESubsequencesEasyVersion()\ninput = sys.stdin.readline\n\nsolver.solve()\n"}, {"source_code": "def sol(b):\n c=[]\n for i in range(len(b)):\n c.append(b[:i]+b[i+1:])\n return c\ns=set()\nn,k=map(int,input().split())\nst=input()\nla=n\np=[st]\np=set(p)\nwhile la>0:\n s=s.union(p)\n r=set()\n fl=0\n for i in p:\n c=sol(i)\n la=len(c[0])\n r=r.union(set(c))\n if len(s)+len(r)>=k:\n fl=1\n break\n p=r\n if fl:\n break\n \nans=0\ns=s.union(p)\nif len(s)<k:\n exit(print(-1))\nelse:\n p=sorted(list(s),reverse=True,key=len)\n for i in range(k):\n ans+=n-len(p[i])\n print(ans)\n"}, {"source_code": "from sys import stdin, stdout, exit\n\n\ndef price():\n n,k = map(int, stdin.readline().split())\n s = stdin.readline().strip()\n\n todo = [s]\n ans = 0\n found = {s:True}\n k -= 1\n while todo and k > 0:\n nexts = []\n # print(todo)\n for wd in todo:\n for i in range(len(wd)):\n candidate = wd[:i] + wd[i+1:]\n # print(candidate)\n if candidate not in found:\n nexts.append(candidate)\n found[candidate] = True\n ans += n - len(candidate)\n k-=1\n if k == 0:\n return ans\n todo = nexts\n if k == 0:\n return ans\n return -1\n\nprint(price())\n"}, {"source_code": "\nn, k = map(int, input().split())\ns = input()\na = set()\nk -= 1\nq = [s]\ni = 0\nans = 0\nwhile i < len(q) and k > 0:\n for j in range(len(q[i])):\n new = q[i][:j] + q[i][j + 1:]\n if new not in a:\n a.add(new)\n q.append(new)\n ans += n - len(q[i]) + 1\n k -= 1\n if k == 0:\n print(ans)\n exit()\n i += 1\nif k == 0:\n print(ans)\nelse:\n print(-1)"}, {"source_code": "import queue\n\ndef solve(s,n,k):\n\tq = queue.Queue()\n\tq.put(s)\n\tmapa = {}\n\tmapa[s] = True\n\twhile (not q.empty() and len(mapa) < k):\n\t\tu = q.get()\n\t\tfor i in range(len(u)):\n\t\t\ttemp = u[0:i:1] + u[i+1:len(u):1]\n\t\t\tif temp not in mapa:\n\t\t\t\tmapa[temp] = True\n\t\t\t\tq.put(temp)\n\t\t\t\tif len(mapa) == k:\n\t\t\t\t\tbreak\n\tif len(mapa) == k:\n\t\tans = k*n\n\t\tfor i in mapa:\n\t\t\tans -= len(i)\n\t\treturn ans\n\treturn -1\n\ndef main():\n\tn,k = map(int,input().split())\n\tprint(solve(input(),n,k))\n\nif __name__ == '__main__':\n\tmain()\n"}, {"source_code": "line1 = input().split(' ')\nn = int(line1[0])\nk = int(line1[1])\ns = list(input())\n\ndp = [101*[0] for i in range(101)]\nlast = 26*[-1]\n\nfor i in range(n+1):\n dp[0][i] = 1\n\nfor l in range(1, n+1):\n dp[l][0] = 0\n for c in range(26):\n last[c] = -1\n for i in range(1, n+1):\n dp[l][i] = dp[l-1][i-1] + dp[l][i-1]\n if last[ord(s[i-1])-ord('a')] != -1:\n dp[l][i] -= dp[l-1][last[ord(s[i-1])-ord('a')]-1]\n last[ord(s[i-1])-ord('a')] = i\n\ni = 0\nres = 0\nwhile i <= n and k >= 0:\n c = min(k, dp[n-i][n])\n k -= c\n res += c * i\n i += 1\nif k > 0:\n print(-1)\nelse:\n print(res)\n"}, {"source_code": "from itertools import combinations \n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n#cost = 233\n\ndef rSubset(arr, r): \n return(set(list(combinations(arr, r))))\n\ndef repeat(s):\n l = list(s)\n l2 = []\n for i in range(len(s)):\n if l[i] == str(s[0]):\n l2.append(True)\n else:\n l2.append(False)\n if False in l2:\n return False\n else:\n return True\n\ndef test(B):\n if len(B) < k:\n return '-1'\n else:\n B = B[0:k]\n cost = 0\n for x in B:\n cost += n-len(x)\n return cost \n\n\nmaster = []\nB = {s}\nA = set()\nfor z in range(len(s)):\n if len(master) >= k:\n break\n for x in B:\n A.update(list(rSubset(x, len(x)-1)))\n if len(A) > k:\n A = list(A)\n A.sort(key=len)\n break\n master += B \n B=A\n A=set()\nmaster.append('')\nprint(test(master))\n\n \n\"\"\"\nlist of sets = [{s}]\nwhile it's not enough:\n new set = set()\n for sigma in listofsets[-1]:\n newset.update(rsubset(sigma, len(sigma) - 1))\n listofsets.append(new set)\n \nyou can do the rest\n\nqueue = however you make aqueue in python\naset = set()\n\nqueue add s\naset add s\n\nwhile len(aset) < k:\n astring = queue...remove()\n for eachstring in rsbubset(astring poop):\n if eachstring not in aset:\n aset add eachstring\n queue add eachstring\n if len(aset) == k:\n break break\n\"\"\""}, {"source_code": "n, tt = map(int, input().split())\ns = input()\n\ndp = [[0]*(n + 1) for i in range(n+1)]\n\nfor c in range(n+1):\n\tdp[0][c] = 1\n\nlast = [-1]*26\n\nfor c in range(1, n + 1):\n\tk = ord(s[c-1]) - ord('a')\n\tfor r in range(1, n+1):\n\t\tdp[r][c] = dp[r][c-1] + dp[r-1][c-1]\n\tif last[k] == -1:\n\t\tlast[k] = c - 1\n\t\tcontinue\n\telse:\n\t\tp = last[k]\n\t\tfor r in range(1, n+1):\n\t\t\tdp[r][c] = dp[r][c] - dp[r-1][p]\n\t\tlast[k] = c-1\n\nsu, ans, t = 0, 0, 0\nfor r in range(n+1):\n\tsu = su + dp[r][n]\nif su < tt:\n\tans = -1\nelse:\n\tfor i in range(n, -1, -1):\n\t\tr = min(tt, dp[i][n])\n\t\tans += t*r\n\t\ttt -= r\n\t\tt += 1\n\nprint(ans) \n"}, {"source_code": "iarr = list(map(int,input().split()))\nn = iarr[0]\nk = iarr[1]\ns = input()\narr = []\narr.append(s)\nans = 0\nii = 0\nflagg=0\nwhile True:\n\t#print(arr)\n\tif flagg==1:\n\t\t#print(\"Hi\")\n\t\tbreak\n\tif arr[ii]==\"\":\n\t\tbreak;\n\t\t#print(\"BYE\")\n\tl = len(arr[ii])\n\tcurcost = n-l+1\n\tfor i in range(l):\n\t\tss = arr[ii][:i] + arr[ii][i+1:]\n\t\tll = len(arr)\n\t\tflag = True\n\t\tfor j in range(ll):\n\t\t\tflag = flag and (ss!=arr[j])\n\t\tif len(arr)==k:\n\t\t\tflagg=1\n\t\t\tbreak\n\t\t\t\n\t\tif flag:\n\t\t\tarr.append(ss)\n\t\t\tans+=curcost\n\tii+=1\nif len(arr)!=k:\n\tprint(-1)\nelse:\n\tprint(ans)\t\n"}, {"source_code": "from collections import defaultdict \nn,k=map(int,input().split())\ns=input()\nlast=defaultdict(int)\ndp=[[0 for i in range(n+1)]for j in range(n+1)]\ndp[0][0]=1\ndp[1][1]=1\ndp[1][0]=1\nlast[s[0]]=1\nfor i in range(2,n+1):\n dp[i][0]=1\n #print(last[s[i-1]])\n for j in range(1,i+1):\n dp[i][j]=dp[i-1][j-1]+dp[i-1][j]\n #print(dp[i][j],i,j)\n if last[s[i-1]]>=1:\n ind=last[s[i-1]]\n dp[i][j]-=dp[ind-1][j-1]\n #print(dp[ind-1][j-1],\"JJKJJK\",dp[i][j])\n last[s[i-1]]=i\nans=0\nfor i in range(n,-1,-1):\n if k<=0:\n break\n c=min(dp[n][i],k)\n ans+=(n-i)*c\n k-=c\nif k>0:\n ans=-1\nprint(ans)"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\nfrom math import factorial\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heapify, heappop, heappush\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0\ndef perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\nmod = 998244353\nINF = float('inf')\n\n# ------------------------------\n\n\ndef main():\n n, k = RL()\n s = input()\n q = deque()\n q.append(s)\n res = 0\n rec = set()\n rec.add(s)\n\n while q:\n now = q.popleft()\n res+=n-len(now)\n if len(rec)>=k: continue\n for i in range(len(now)):\n nex = now[:i]+now[i+1:]\n if nex in rec: continue\n rec.add(nex)\n if len(rec)<=k: q.append(nex)\n\n print(res if len(rec)>=k else -1)\n\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "\nimport queue\n\nn, k = [int(el) for el in input().split()]\ns = input()\n\n\ndef sol_e(line, set_size):\n unique_set = {line}\n cost = 0\n lines_queue = queue.Queue()\n lines_queue.put(line)\n cur_set_size = 1\n while cur_set_size < set_size:\n cur_line = lines_queue.get()\n for index in range(len(cur_line)):\n new_line = cur_line[:index]+cur_line[(index+1):]\n if new_line not in unique_set:\n unique_set.add(new_line)\n cost += len(line)-len(new_line)\n cur_set_size += 1\n lines_queue.put(new_line)\n if cur_set_size == set_size:\n return cost\n if lines_queue.empty():\n return -1\n return cost\n\n\nprint(sol_e(s, k))\n"}, {"source_code": "def count_subsequences_of_length(s):\n \"\"\"\u6587\u5b57\u5217s\u306e\u90e8\u5206\u5217\u3092\u9577\u3055\u3054\u3068\u306b\u6570\u3048\u4e0a\u3052\u308b\n \u4f8b) s = aba\n \u8003\u3048\u3089\u308c\u308b\u90e8\u5206\u5217\u306f \"\", \"a\", \"b\", \"ab\", \"ba\", \"aa\", \"aba\" \u306a\u306e\u3067 ans = [1, 2, 3, 1]\n \u8a08\u7b97\u91cf: O(len(s)*len(s)*len(alphabet))\n \"\"\"\n n = len(s)\n alphabet = list(set(list(s)))\n to_int = {}\n for i, char in enumerate(alphabet):\n to_int[char] = i\n\n next_i = [[n] * len(alphabet) for i in range(n + 1)]\n for i in reversed(range(n)):\n for j, char in enumerate(alphabet):\n next_i[i][j] = next_i[i+1][j]\n next_i[i][to_int[s[i]]] = i\n\n # dp[i][j] := j\u756a\u76ee\u307e\u3067\u306e\u6587\u5b57\u3092\u898b\u305f\u3068\u304d\u306e\u3001\u9577\u3055i\u306e\u90e8\u5206\u5217\u306e\u901a\u308a\u6570\n # \u521d\u671f\u5024\u306fdp[0][0] = 1 (\u7a7a\u6587\u5b57 \"\" \u306b\u5bfe\u5fdc)\n dp = [[0] * (n + 1) for i in range(n + 1)]\n dp[0][0] = 1\n for j in range(n):\n for i in range(n):\n for k in range(len(alphabet)):\n if next_i[j][k] >= n:\n continue\n # \u914d\u308bDP\n dp[i+1][next_i[j][k] + 1] += dp[i][j]\n\n ans = [sum(dp[i]) for i in range(n + 1)]\n return ans\n\n\nn, k = map(int, input().split())\ns = input()\nans_len = count_subsequences_of_length(s)\n\nans_cnt = 0\nans = 0\nfor length in reversed(range(len(ans_len))):\n cnt = ans_len[length]\n if ans_cnt + cnt <= k:\n ans_cnt += cnt\n ans += cnt * (n - length)\n else:\n ans += (k - ans_cnt) * (n - length)\n ans_cnt = k\nif ans_cnt != k:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "import sys\nimport math\nfrom collections import defaultdict,deque\nimport heapq\nn,k = map(int,sys.stdin.readline().split())\nss = sys.stdin.readline()[:-1]\ndp = [[0 for _ in range(n+1)] for i in range(n+1)]\ndp[n][1]=1\ndp[n][0]=1\ndic=defaultdict(list)\nfor i in range(n):\n\tdic[ss[i]].append(i+1)\n#print(dic,'dic')\nfor i in range(n-1,0,-1):\n\t#vis=defaultdict(int)\n\tfor j in range(1,n+1):\n\t\ts=0\n\t\tfor x in range(i+1,n+1):\n\t\t\ts+=dp[x][j-1]\n\t\tz=-1\n\t\tcnt=0\n\t\t#print(ss[i-1])\n\t\t#print(dic[ss[i-1]])\n\t\tfor y in dic[ss[i-1]]:\n\t\t\tcnt+=1\n\t\t\tif y==i:\n\t\t\t\tbreak\n\t\tsub=0\n\t\tif len(dic[ss[i-1]])>cnt:\n\t\t\tfor q in range(cnt,len(dic[ss[i-1]])):\n\t\t\t\tsub+=dp[dic[ss[i-1]][q]][j]\n\t\t\t\t#print(dic[ss[i-1]][q],'row',j,'col',sub,'sub')\n\t\t\t#sub=dp[dic[ss[i-1]][cnt]][j]\n\t\t#print(cnt,'cnt',i,'i',j,'j',s,'sssss',sub,'sub',cnt,'cnt',dic[ss[i-1]])\n\t\tdp[i][j]+=s-sub\n\t\t#print(s,'s',sub,'sub')\n'''for i in range(n+1):\n\tprint(dp[i],'dp')'''\ncost=0\nfor i in range(n,-1,-1):\n\tfor j in range(n+1):\n\t\t#print(k,'k',i,'i',j,'j')\n\t\tif dp[j][i]<=k:\n\t\t\tcost+=(n-i)*dp[j][i]\n\t\t\tk-=dp[j][i]\n\t\telse:\n\t\t\t#print(n,'n',i,'i',k,'k')\n\t\t\tcost+=k*(n-i)\n\t\t\tk=0\n\t\t\tbreak\n#print(cost,'cost',k,'k')\nif k!=0:\n\tprint(-1)\nelse:\n\tprint(cost)\n"}, {"source_code": "N, K = map(int, input().split())\npre = [input()]\nans = 0\nk = 1\nf = 0\nwhile True:\n if k >= K:\n print(ans)\n break\n if len(pre) == 0:\n print(-1)\n break\n\n post = []\n for s in pre:\n for i in range(len(s)):\n t = s[:i] + s[i+1:]\n if t not in post:\n k += 1\n post.append(t)\n ans += N - len(t)\n\n if k >= K:\n print(ans)\n f = 1\n break\n if f:\n break\n if f:\n break\n pre = post\n\n"}, {"source_code": "n, d = map(int,input().split())\ns = input()\nt = [[-1 for i in range(n + 1)] for j in range(n + 1)]\nfor i in range(1, n + 1):\n\tfor j in range(i, n + 1):\n\t\tif j == i:\n\t\t\tt[i][j] = 1\n\t\telse:\n\t\t\tt[i][j] = 0\njes = [0] * 300\nfor i in range(1, n + 1):\n\tjes[ord(s[i - 1])] = 1\n\tt[i][1] = sum(jes)\nfor j in range(2, n + 1):\n\tind = [-1] * 300\n\tind[ord(s[j - 1])] = j - 1\n\t#obliczamy t[j + 1][j], t[j + 2][j], ...\n\tfor i in range(j + 1, n + 1):\n\t\tif ind[ord(s[i - 1])] == -1:\n\t\t\tt[i][j] = t[i - 1][j] + t[i-1][j-1] \n\t\telse:\n\t\t\tt[i][j] = t[i - 1][j] + t[i - 1][j - 1] - t[ind[ord(s[i-1])]][j - 1]\n\t\tind[ord(s[i - 1])] = i - 1\n#t[n][1], t[n][2], ..., t[n][n]\nrozne = [t[n][i] for i in range(1, n + 1)]\nrozne.reverse()\nroz = rozne + [1]\ndupa = 0\nwyn = 0\nfor i in range(n + 1):\n\tif dupa < d:\n\t\tk = min(roz[i], (d-dupa))\n\t\tdupa += k\n\t\twyn += k * i\n\telse:\n\t\tbreak\nif dupa >= d:\n\tprint(wyn)\nelse:\n\tprint(-1)\n\t"}, {"source_code": "import sys\nfrom itertools import combinations\nfrom functools import lru_cache\nfrom string import ascii_lowercase\n\n@lru_cache()\ndef e(n, l):\n return sum(d(n, l, x) for x in letters)\n\n\n@lru_cache()\ndef d(n, l, c):\n if n < l:\n return 0\n if s[n - 1] != c:\n return d(n - 1, l, c)\n return e(n - 1, l - 1) if l > 1 else 1\n\n\ndef solve(s, k):\n n = len(s)\n cost = 0\n for l in range(n, 0, -1):\n cnt = e(n, l)\n if k > cnt:\n k -= cnt\n cost += cnt * (n - l)\n else:\n cost += k * (n - l)\n k = 0\n break\n if k > 1:\n return -1\n if k == 1:\n cost += n\n k = 0\n return cost\n\nn, k = map(int, input().split())\ns = input()\nletters = set(s)\nprint(solve(s, k))\n"}, {"source_code": "#import sys\n#input = sys.stdin.buffer.readline\n\ndef main():\n n, K = map(int, input().split())\n s = str(input())\n\n next = [[10**18]*26 for _ in range(n+1)]\n\n for i in reversed(range(n)):\n for j in range(26):\n next[i][j] = next[i+1][j]\n if s[i] == chr(j+ord('a')):\n next[i][j] = i\n #print(next)\n\n dp = [[0]*(n+1) for i in range(n+1)]\n dp[0][0] = 1\n for i in range(n):\n for j in range(n+1):\n #dp[i+1][j] += dp[i][j]\n for k in range(26):\n if next[i][k] >= n:\n continue\n else:\n if j+1 <= n:\n dp[next[i][k]+1][j+1] += dp[i][j]\n #print(dp)\n d = {}\n V = [0]*(n+1)\n for i in range(n+1):\n for j in range(n+1):\n V[j] += dp[i][j]\n V.reverse()\n #print(V)\n ans = 0\n for i, v in enumerate(V):\n if v >= K:\n ans += K*i\n break\n else:\n ans += v*i\n K -= v\n else:\n print(-1)\n exit()\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def func(n,k,s):\n\tx = [s]\n\tcost = 0\n\twhile(len(x) < k):\n\t\tfor string in x:\n\t\t\tl = len(string)\n\t\t\tfor j in range(l):\n\t\t\t\tt = string[:j] + string[j+1:]\n\t\t\t\tif(t == \"\" and t in x):\n\t\t\t\t\treturn -1\n\t\t\t\tif(t not in x):\n\t\t\t\t\tx.append(t)\n\t\t\t\t\tcost += n - len(t)\n\t\t\t\t\tif(len(x) >= k):\n\t\t\t\t\t\treturn cost\n\treturn cost\na = [int(i) for i in input().split()]\nn = a[0]\nk = a[1]\ns = str(input())\nprint(func(n,k,s))"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn,W=map(int,input().split())\ns=input().strip()\n\nNEXTLIST=[[n]*26 for i in range(n+1)]\n\nfor i in range(n-1,-1,-1):\n for j in range(26):\n NEXTLIST[i][j]=NEXTLIST[i+1][j]\n NEXTLIST[i][ord(s[i])-97]=i\n\nDP=[[0]*(n+1) for i in range(n+1)]\n\nDP[0][0]=1\n\nfor i in range(n):\n for j in range(26):\n if NEXTLIST[i][j]!=n:\n for k in range(n):\n DP[NEXTLIST[i][j]+1][k+1]+=DP[i][k]\n\n#print(DP)\n\nHLIST=[0]*(n+1)\n\nfor i in range(n+1):\n for j in range(n+1):\n HLIST[j]+=DP[i][j]\n\n#print(HLIST)\n\nANS=0\nfor i in range(n,-1,-1):\n #print(i,W)\n if W>HLIST[i]:\n ANS+=(n-i)*HLIST[i]\n W-=HLIST[i]\n else:\n ANS+=W*(n-i)\n print(ANS)\n sys.exit()\n\nelse:\n print(-1)\n"}, {"source_code": "n,setsize=list(map(int,input().split()))\ns=input()\ncount = [[0 for j in range(n+1)] for i in range(n+1)]\nfor i in range(n):\n\tj = i-1\n\twhile(j>=0):\n\t\tfor k in range(1,n):\n\t\t\tcount[i][k+1] += count[j][k]\n\t\tif(s[j]==s[i]):\n\t\t\tbreak\n\t\tj-=1\n\tif(j==-1):\n\t\tcount[i][1]+=1\n# print(count)\ncost = 0\ncount[0][0]=1\nfor l in range(n,-1,-1):\n\tif(setsize==0):\n\t\tbreak\n\tct = 0\n\tlocalcost = n - l\n\tfor i in range(n):\n\t\tct += count[i][l]\n\tminct = min(setsize,ct)\n\tsetsize-=minct\n\t# print(\"for k=\",setsize,\"l=\",l,\";minct=\",minct,\";localcost=\",localcost)\n\tcost += (minct*localcost)\nif(setsize==0):\n\tprint(cost)\nelse:\n\tprint(-1)"}, {"source_code": "n, k = map(int, input().split())\ns = input()\na = set()\nk -= 1\nq = [s]\ni = 0\nans = 0\nwhile i < len(q) and k > 0:\n for j in range(len(q[i])):\n new = q[i][:j] + q[i][j + 1:]\n if new not in a:\n a.add(new)\n q.append(new)\n ans += n - len(q[i]) + 1\n k -= 1\n if k == 0:\n print(ans)\n exit()\n i += 1\nif k == 0:\n print(ans)\nelse:\n print(-1)\n"}, {"source_code": "from collections import deque\nn,m=map(int,input().split())\ns=input()\nd=deque([s])\nans=1\nan=0\ndd={}\nwhile d and ans<m:\n # print(d)\n p=d.popleft()\n dd[p]=1\n k=len(p)\n for i in range(k):\n pp=p[:i] + p[i+1:]\n # print(pp,dd)\n if (pp not in dd):\n an+=(n-(k-1))\n ans+=1\n dd[pp]=1\n d.append(pp)\n if ans==m:\n print(an)\n exit()\n \n # print(d)\n# print(an,ans) \nif ans==m:\n print(an)\nelse:\n print(-1)\n \n \n \n \n"}], "negative_code": [{"source_code": "import sys,os,math\nfrom collections import Counter, defaultdict\nimport bisect\nfrom sys import stdin, stdout\nfrom itertools import repeat, izip\n\n\n# n, k = map(int, raw_input().split())\n# da = map(int, raw_input().split())\n# db = map(int, raw_input().split())\n# sys.stdin = open('input')\n\ndef main():\n inf = int(1e12)\n n, k = map(int, raw_input().split())\n s = raw_input()\n sda = map(lambda c: ord(c)-ord('a'), s)\n last = [[-1 for i in range(27)] for j in range(n+1)]\n for i in range(n):\n for j in range(26):\n if i != 0:\n last[i][j] = last[i-1][j]\n if sda[i] == j:\n last[i][j] = i\n dp = [[0 for i in range(n)] for j in range(n+1)]\n dp[0] = [1 for i in range(n)]\n dp[1] = [1 for i in range(n)]\n for lenth in range(2, n+1):\n for idx in range(lenth-1, n):\n for j in range(26):\n dp[lenth][idx] += dp[lenth-1][last[idx-1][j]] if last[idx-1][j] != -1 else 0\n dp[lenth][idx] = min(dp[lenth][idx], inf)\n # print dp\n ans = 0\n # print last[n-1]\n for lenth in range(n, -1, -1):\n for j in range(26):\n if last[n-1][j] == -1:\n continue\n if dp[lenth][last[n-1][j]] >= k:\n # print lenth,k,ans\n print ans+k*(n-lenth)\n return\n else:\n ans += dp[lenth][last[n-1][j]] * (n-lenth)\n k -= dp[lenth][last[n-1][j]]\n # print k\n print -1\n\n\nmain()\n"}, {"source_code": "import sys,os,math\nfrom collections import Counter, defaultdict\nimport bisect\nfrom sys import stdin, stdout\nfrom itertools import repeat, izip\n\n\n# n, k = map(int, raw_input().split())\n# da = map(int, raw_input().split())\n# db = map(int, raw_input().split())\n\n\ndef main():\n inf = int(1e12)\n n, k = map(int, raw_input().split())\n s = raw_input()\n sda = map(lambda c: ord(c)-ord('a'), s)\n last = [[-1 for i in range(27)] for j in range(n+1)]\n for i in range(n):\n for j in range(26):\n if i != 0:\n last[i][j] = last[i-1][j]\n if sda[i] == j:\n last[i][j] = i\n dp = [[0 for i in range(n)] for j in range(n+1)]\n dp[0] = [1 for i in range(n)]\n dp[1] = [1 for i in range(n)]\n for lenth in range(2, n+1):\n for idx in range(lenth-1, n):\n for j in range(26):\n dp[lenth][idx] += dp[lenth-1][last[idx-1][j]] if last[idx-1][j] != -1 else 0\n dp[lenth][idx] = min(dp[lenth][idx], inf)\n # print dp\n ans = 0\n # print last[n-1]\n for lenth in range(n, -1, -1):\n for j in range(26):\n if last[n-1][j] == -1:\n continue\n if dp[lenth][last[n-1][j]] >= k:\n # print lenth,k,ans\n print ans+k*(n-lenth)\n return\n else:\n ans += dp[lenth][last[n-1][j]] * (n-lenth)\n k -= dp[lenth][last[n-1][j]]\n # print k\n print -1\n\n\nmain()\n"}, {"source_code": "n, k = map(int, input().split(' '))\ns = input()\ndp = [[0] * (n + 1) for _ in range(n + 1)]\ndp[0][0] = 1\nprev = [None] * 26\nfor i in range(1, n + 1):\n for l in range(2, i + 1):\n for j in range(26):\n if prev[j] is not None:\n dp[l][i] += dp[l - 1][prev[j]]\n ch = ord(s[i - 1]) - ord('a')\n if prev[ch] is None:\n dp[1][i] = 1\n prev[ch] = i\ntotal = 0\nfor l in range(n, -1, -1):\n sums = sum(dp[l])\n if sums >= k:\n total += (n - l) * k\n k = 0\n break\n total += (n - l) * sums\n k -= sums\nif k > 0:\n total = -1\nprint(total)\n"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nlast = [n + 1] * 30\ndp = [[0] * 102 for i in range(102)] \n\nfor i in range(0, n + 1):\n dp[i][0] = 1\nfor i in range(1, n + 1):\n nm = ord(s[i - 1]) - ord('a')\n for le in range(1, i + 1):\n dp[i][le] = dp[i - 1][le] + dp[i - 1][le - 1]\n if last[nm] < i:\n dp[i][le] -= (dp[last[nm]][le] - dp[last[nm] - 1][le])\n last[nm] = i\n \n \nans = 0\nfor le in range(n, -1, -1):\n if k == 0:\n break\n x = min(dp[n][le], k)\n ans += (n - le) * x\n k -= x\nif k != 0:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nlast = [n + 1] * 30\ndp = [[0] * 102 for i in range(102)] \n\nfor i in range(0, n + 1):\n dp[i][0] = 1\nfor i in range(1, n + 1):\n nm = ord(s[i - 1]) - ord('a')\n for le in range(1, i + 1):\n dp[i][le] = dp[i - 1][le] + dp[i - 1][le - 1]\n if last[nm] < i:\n dp[i][le] -= dp[last[nm]][le]\n dp[i][le] = min(dp[i][le], k)\n last[nm] = i\n \nans = 0\nfor le in range(n, -1, -1):\n if k == 0:\n break\n x = min(dp[n][le], k)\n ans += (n - le) * x\n k -= x\nif k != 0:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nlast = [n + 1] * 30\ndp = [[0] * 102 for i in range(102)] \n\nfor i in range(0, n + 1):\n dp[i][0] = 1\nfor i in range(1, n + 1):\n nm = ord(s[i - 1]) - ord('a')\n for le in range(1, i + 1):\n dp[i][le] = dp[i - 1][le] + dp[i - 1][le - 1]\n if last[nm] < i:\n dp[i][le] -= min(dp[last[nm]][le], k)\n dp[i][le] = min(dp[i][le], k * 2)\n last[nm] = i\n \nans = 0\nfor le in range(n, -1, -1):\n if k == 0:\n break\n x = min(dp[n][le], k)\n ans += (n - le) * x\n k -= x\nif k != 0:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "from sys import stdin\n\nn, k = [int(i) for i in stdin.readline().strip().split()]\ns = stdin.readline().strip()\n\n\ndef get_f(s):\n F = [len(s) * [0] for _ in range((len(s) + 1))]\n size = 0\n for index in range(len(s)):\n F[size][index] = 1\n F[1][0] = 1\n\n p = {s[0]: 0}\n for i in range(1, len(s)):\n for k in range(1, len(s) + 1):\n if k > i + 1:\n val = 0\n else:\n val = F[k][i - 1] + F[k - 1][i - 1]\n if s[i] in p:\n # sic: if k - 1 == 0 then answer is always 1\n if k - 1 == 0:\n val -= 1\n if p[s[i]] - 1 >= 0:\n val -= F[k - 1][p[s[i]] - 1]\n F[k][i] = val\n p[s[i]] = i\n return F\n\n_F = get_f(s)\n\n# for sz in range(len(s) + 1):\n# for index in range(len(s)):\n# print(_F[sz][index], end=' ')\n# print()\n\n\ndef count(size, index = None):\n return _F[size][index or (len(s) - 1)]\n\n\n# recursive solution with memoization\nprevious_letter_index = {}\nfound = {}\nfor index, letter in enumerate(s):\n if letter in found:\n previous_letter_index[(letter, index)] = found[letter]\n found[letter] = index\n\n_subsequences = {}\n\n\ndef subsequences(size, index):\n \"\"\"Get number of distinct subsequences of given size in sequence[0:index + 1] slice\"\"\"\n if (size, index) not in _subsequences:\n if size == 0:\n res = 1\n elif size > index + 1:\n res = 0\n else:\n res = subsequences(size, index - 1) + subsequences(size - 1, index - 1)\n letter = s[index]\n if (letter, index) in previous_letter_index:\n res -= subsequences(size - 1, previous_letter_index[(letter, index)] - 1)\n _subsequences[(size, index)] = res\n return _subsequences[(size, index)]\n\n\ntotal_cost = 0\nfor size in range(len(s), -1, -1):\n if k == 0:\n break\n step_cost = n - size\n sequence_count = count(size, len(s) - 1)\n # print('size = ', size, 'count = ', sequence_count)\n if sequence_count > k:\n sequence_count = k\n total_cost += step_cost * sequence_count\n k -= sequence_count\n\nif k == 0:\n print(total_cost)\nelse:\n print(-1)\n"}, {"source_code": "from sys import stdout, stdin\n\nn, kk = map(int, stdin.readline().split())\ns = stdin.readline().strip()\ns += \"$\"\nn = n+1\n\ndp = [[0 for i in range(n)] for j in range(n)]\np = 10**12+5\nfor i in range(n):\n dp[i][0] = 1\nfor end in range(n):\n for length in range(1, n):\n seen = []\n ans = 0\n for k in range(end-1, -1, -1):\n if s[k] not in seen:\n seen.append(s[k])\n ans += dp[k][length-1]\n ans %= p\n dp[end][length] = ans\n\ntotals = [dp[n-1][length] for length in range(n)]\n#print(totals)\n\nans = 0\nidx = n-1\nwhile idx >= 0 and kk > 0:\n ans += min(totals[idx], kk)*(n-1-idx)\n kk -= totals[idx]\n idx -= 1\n\nif kk <= 0:\n stdout.write(str(ans) +\"\\n\")\nelse:\n print(-1)\n\n"}, {"source_code": "n, k = map(int, input().split())\ns = '{' + input()\ndp = [[0] * (n + 1) for _ in range(n + 1)]\n\n# dp\ndp[0][0] = 1\noa = ord('a')\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n hold = [0] * 30\n for l in range(0, i): # Transition from dp[l][j - 1]\n let = ord(s[l]) - oa;\n # db(i); db(j); db(dp[i][j]); db(dp[l][j - 1]); db(hold[let]); dbln;\n dp[i][j] += dp[l][j - 1] - hold[let];\n\n hold[let] = dp[l][j - 1];\n\n # dblb(\"ret\"); db(i); db(j); db(dp[i][j]); dbln;\n\n# sum costs\ntot = 0;\nfor i in range(n, -1):\n cost = n - i\n dpsum = 0;\n hold = [0] * 30\n for j in range(0, n + 1):\n let = ord(s[j]) - oa;\n dpsum += dp[j][i] - hold[let];\n hold[let] = dp[j][i];\n\n sub = min(k, dpsum);\n # db(i); db(dpsum); dbln;\n\n tot += sub * cost;\n k -= sub;\n\nif k > 0:\n print(-1)\nelse:\n print(tot)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# File : H.py\n# Author : JCHRYS <jchrys@me.com>\n# Date : 30.08.2019\n# Last Modified Date: 30.08.2019\n# Last Modified By : JCHRYS <jchrys@me.com>\nclass const:\n size = 26; # size of lowercase alphabet\n\nn, k = map(int, input().split());\ns = input();\n\nmaxpos = [[-1 for _ in range(const.size)] for _ in range(n)];\n\nfor i in range(n):\n for j in range(const.size):\n if i > 0:\n maxpos[i][j] = maxpos[i - 1][j]\n maxpos[i][ord(s[i]) - ord('a')] = i\n\n#print(*[row for row in maxpos], sep=\"\\n\")\ndp = [[0 for _ in range(n)] for _ in range(n)];\n\nfor i in range(n):\n dp[i][1] = 1\n\nfor length in range(2, n):\n for endswith in range(1, n):\n for before in range(const.size):\n if maxpos[endswith - 1][before] != -1:\n dp[endswith][length] = dp[endswith][length] + dp[maxpos[endswith - 1][before]][length - 1];\n\n\n#print(*[row for row in dp], sep=\"\\n\")\nk -= 1;\nans = 0;\nfor length in range(n-1, 0, -1):\n temp = 0;\n for i in range(const.size):\n if (maxpos[n-1][i] != -1):\n temp += dp[maxpos[n-1][i]][length];\n \n if temp >= k:\n ans += k * (n - length);\n k = 0;\n break;\n else:\n k -= temp;\n ans += temp * (n-length);\n \n\nif (k == 1):\n ans += n;\n\nif k > 0:\n print(-1)\n exit()\nprint(ans)\n\n\n\n\n"}, {"source_code": "line1 = input().split(' ')\nn = int(line1[0])\nk = int(line1[1])\ns = list(input())\n\ndp = [101*[0] for i in range(101)]\nlast = 26*[-1]\n\nfor i in range(n+1):\n dp[0][i] = 1\n\nfor l in range(1, n+1):\n dp[l][0] = 0\n for c in range(26):\n last[c] = -1\n for i in range(1, n+1):\n dp[l][i] = dp[l-1][i-1] + dp[l][i-1]\n if last[ord(s[i-1])-ord('a')] != -1:\n dp[l][i] -= dp[l][last[ord(s[i-1])-ord('a')]]\n last[ord(s[i-1])-ord('a')] = i\n\ni = 0\nres = 0\nwhile i <= n and k >= 0:\n c = min(k, dp[n-i][n])\n k -= c\n res += c * i\n i += 1\nif k > 0:\n print(-1)\nelse:\n print(res)\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\nfrom math import factorial\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heapify, heappop, heappush\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0\ndef perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\nmod = 998244353\nINF = float('inf')\n\n# ------------------------------\n\ndef c(chr): return ord(chr)-ord('a')\n\ndef main():\n n, k = RL()\n s = input()\n\n dp = [[0]*(n+1) for i in range(n+1)]\n rec = [-1]*26\n pre = [-1]*n\n dp[0][0] = 1\n\n for i in range(n):\n now = c(s[i])\n pre[i] = rec[now]\n rec[now] = i\n\n for i in range(1, n+1):\n for j in range(1, i+1):\n if j>i: break\n\n if i==j: dp[i][j] = 1; continue;\n\n dp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n if pre[i-1]!=-1:\n # if i==5 and j==4: print(pre[i-1], '+++')\n dp[i][j] -= dp[pre[i-1]-1][j-1]\n\n\n res = 0\n for j in range(n, -1, -1):\n for i in range(n, -1, -1):\n if k:\n num = min(k, dp[i][j])\n k-=num\n res += (n-j)*num\n\n \n print(res if k==0 else -1)\n\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\nfrom math import factorial\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heapify, heappop, heappush\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0\ndef perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\nmod = 998244353\nINF = float('inf')\n\n# ------------------------------\n\ndef c(chr): return ord(chr)-ord('a')\n\ndef main():\n n, k = RL()\n s = input()\n\n dp = [[0]*(n+1) for i in range(n+1)]\n rec = [-1]*26\n pre = [-1]*n\n dp[0][0] = 1\n\n for i in range(n):\n now = c(s[i])\n pre[i] = rec[now]\n rec[now] = i\n\n for i in range(1, n+1):\n for j in range(1, i+1):\n if j>i: break\n\n if i==j: dp[i][j] = 1; continue;\n\n dp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n if pre[i-1]!=-1:\n # if i==5 and j==4: print(pre[i-1], '+++')\n dp[i][j] -= dp[pre[i-1]][j-1]\n\n\n res = 0\n for j in range(n, -1, -1):\n for i in range(n, -1, -1):\n if k:\n num = min(k, dp[i][j])\n k-=num\n res += (n-j)*num\n\n print(res if k==0 else -1)\n\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "import sys\nn,k=map(int,input().split())\ns=input()\nb=[]\nfor j in s:\n b.append(j)\n\ndp=[[0 for i in range(n+1)] for j in range(n)]\nlast=dict()\ndp[0][0]=1\ndp[0][1]=1\nlast[b[0]]=0\nfor i in range(1,n):\n dp[i][0]=1\n for j in range(1,n+1):\n if b[i] in last.keys():\n dp[i][j]=dp[i-1][j]+dp[i-1][j-1]-dp[last[b[i]]][j]\n else:\n dp[i][j] = dp[i - 1][j] + dp[i - 1][j- 1]\n last[b[i]]=i\n\ns=0\nres=0\n\nif sum(dp[-1])<k:\n print(-1)\n sys.exit()\nj=n\nwhile(j>=0):\n if s+dp[-1][j]<k:\n s+=dp[-1][j]\n res+=dp[-1][j]*(n-j)\n\n else:\n res+=(k-s)*(n-j)\n break\n\n j+=-1\n\nprint(res)\n\n\n"}, {"source_code": "n, d = map(int,input().split())\ns = input()\nt = [[-1 for i in range(n + 1)] for j in range(n + 1)]\nfor i in range(1, n + 1):\n\tfor j in range(i, n + 1):\n\t\tif j == i:\n\t\t\tt[i][j] = 1\n\t\telse:\n\t\t\tt[i][j] = 0\njes = [0] * 300\nfor i in range(1, n + 1):\n\tjes[ord(s[i - 1])] = 1\n\tt[i][1] = sum(jes)\nfor j in range(2, n + 1):\n\tind = [-1] * 300\n\tind[ord(s[j - 1])] = j - 1\n\t#obliczamy t[j + 1][j], t[j + 2][j], ...\n\tfor i in range(j + 1, n + 1):\n\t\tif ind[ord(s[i - 1])] == -1:\n\t\t\tt[i][j] = t[i - 1][j] + t[i-1][j-1] \n\t\telse:\n\t\t\tt[i][j] = t[i - 1][j] + t[i - 1][j - 1] - t[ind[ord(s[i-1])]+1][j - 1]\n\t\tind[ord(s[i - 1])] = i - 1\n#t[n][1], t[n][2], ..., t[n][n]\nrozne = [t[n][i] for i in range(1, n + 1)]\nrozne.reverse()\nroz = rozne + [1]\ndupa = 0\nwyn = 0\nfor i in range(n + 1):\n\tif dupa < d:\n\t\tk = min(roz[i], (d-dupa))\n\t\tdupa += k\n\t\twyn += k * i\n\telse:\n\t\tbreak\nif dupa >= d:\n\tprint(wyn)\nelse:\n\tprint(-1)\n\t"}, {"source_code": "[n, k] = [int(i) for i in input().split()]\ns = input()\ncntsz = [0 for i in range(105)]\ndp = [[0 for i in range(105)] for j in range(105)]\nlst = [0 for i in range(105)]\nprv = [0 for i in range(26)]\nn = len(s)\ns = '%' + s\nfor i in range(n + 1):\n dp[i][0]=1\nfor i in range(1, n + 1):\n\tlst[i] = prv[ord(s[i])-ord('a')]\n\tprv[ord(s[i]) - ord('a')] = i\nfor sz in range(1, n + 1):\n\tfor i in range(1, n + 1):\n\t\tdp[i][sz] += dp[i - 1][sz]\n\t\tdp[i][sz] += dp[i - 1][sz - 1]\n\t\tif lst[i] != 0:\n\t\t\t dp[i][sz] -= dp[lst[i]][sz]\nfor sz in range(1, n + 1):\n\tfor i in range(1, n + 1):\n\t\tcntsz[sz] += dp[i][sz]\n\t\tcntsz[sz] -= dp[i - 1][sz]\ncntsz[0] += 1\ndone = 0\nans = 0\nfor i in range(n, -1, -1):\n if done + cntsz[i] >= k:\n ans += (n - i) * (k - done)\n done = k\n break\n done += cntsz[i]\n ans += cntsz[i] * (n - i)\nif done < k:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "n, k = map(int, input().split())\ntargets = [input()]\nans = 0\ncur = 1\ndepth = 0\nwhile depth <= n:\n depth += 1\n next_target = []\n for target in targets:\n for i in range(len(target)):\n check = target[:i] + target[i+1:]\n if check in next_target:\n continue\n next_target.append(target[:i] + target[i+1:])\n ans += depth\n cur += 1\n if cur >= k:\n print(ans)\n exit()\n targets = next_target\nprint(-1)\n"}, {"source_code": "n, k = map(int, input().split())\nstr = str(input())\nq = [str]\nans = 0\nma = {}\nwhile len(q) != 0 and k > 1 :\n s = q.pop()\n for i in range(len(s)):\n ss = s\n s1 = ss[0:i]\n s2 = ss[i+1:]\n ss = s1 + s2\n if ss not in ma.keys() :\n ma[ss] = 1\n k -= 1\n ans += n - len(ss)\n q.append(ss)\n if k == 1 : break\nif k == 1 :\n print(ans)\nelse :\n print(-1)\n"}, {"source_code": "def check_word(word_list, word_need):\n unique = []\n for i in range(len(word_list)):\n # Pick each word in the list\n if word_need == 0:\n break\n for j in range(len(word_list[i])):\n if word_need == 0:\n break\n # Check word without 1 char is in unique\n new_word = word_list[i][:j]+word_list[i][j+1:]\n if new_word not in unique:\n unique.append(new_word)\n word_need -= 1\n return unique\n\ndef check_all():\n cost_sum = 0\n cost_each = 1\n [raw_length, raw_size] = input().split()\n size = int(raw_size)\n words = input().split()\n size -= 1\n while size>0:\n if len(words[0]) == 0:\n return -1\n words = check_word(words, size)\n print(len(words))\n cost_sum += len(words)*cost_each\n cost_each += 1\n size -= len(words)\n return cost_sum\n\nprint(check_all())"}, {"source_code": "N, K = map(int, input().split())\npre = [input()]\nans = 0\nk = 1\nf = 0\nwhile True:\n if len(pre) == 0:\n print(-1)\n break\n post = []\n for s in pre:\n for i in range(len(s)):\n t = s[:i] + s[i+1:]\n if t not in post:\n k += 1\n post.append(t)\n ans += N-len(t)\n if k >= K:\n print(ans)\n f = 1\n break\n if f:\n break\n if f:\n break\n pre = post"}, {"source_code": "\n\ndef solve(n, k, s):\n\n set = {s: 0}\n ans = 0\n\n found = False\n for length in range(n, 0, -1):\n for i in range(1, n+1):\n for x in range(length):\n newS = s[:x] + s[x+i:length]\n if newS not in set:\n set[newS] = i\n\n if len(set) < k:\n print(-1)\n else:\n arr = list(sorted(set.items(), key=lambda x: x[1]))\n for i in range(k):\n ans += arr[i][1]\n print(ans)\n\n\n\ndef main():\n\n n, k = map(int, input().split())\n\n s = input()\n\n solve(n, k, s)\n\n\nif __name__ == \"__main__\":\n\n main()\n"}, {"source_code": "#! /usr/bin/env python3\n# -*- coding: UTF-8 -*-\nline = input()\nneed = int(line.split(' ')[1]) - 1\nn = int(line.split(' ')[0])\ns = input()\n\nif need == 1:\n print(0)\nelse:\n queue = [s]\n d = {}\n head, tail, ans = 0, 1, 0\n solve = False\n\n while head < tail and not solve:\n top = queue[head]\n cost = len(top)-1\n for idx, c in enumerate(top):\n new = ''.join([top[:idx], top[idx + 1:]])\n h = new.__hash__()\n if not d.get(h):\n d[h] = 1\n queue.append(new)\n tail += 1\n ans += n - cost\n need -= 1\n if need == 0:\n solve = True\n break\n head += 1\n\n if not solve:\n print(\"-1\")\n else:\n print(ans)\n"}, {"source_code": "n,k=map(int,input().split())\ns=input()\nst=[set() for i in range(n+1)]\nst[n].add(s)\nc=1\nk-=1\nans=0\nfor i in range(n,0,-1):\n for w in st[i]:\n for j in range(i):\n st[i-1].add(w[:j]+(w[j+1:] if j!=i-1 else ''))\n sz=len(st[i-1])\n if k<sz:\n ans+=(n-i+1)*k\n break\n else:\n ans+=(n-i+1)*sz\n k-=sz\n if k<0:\n break\nif k<0:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "from sys import stdin\n\nn, k = [int(i) for i in stdin.readline().strip().split()]\ns = stdin.readline().strip()\n\n\nclass Subsequences:\n def __init__(self, sequence):\n self._seq = list(sequence)\n self._F = [len(sequence) * [0] for _ in range((len(sequence) + 1))]\n self._calc()\n\n def _calc(self):\n # iterative solution F[size][index] given number of distinct subsequences of given size\n # in slice [0: index + 1] of original sequence\n F = self._F\n size = 0\n for index in range(len(s)):\n F[size][index] = 1\n F[1][0] = 1\n\n p = {s[0]: 0}\n for i in range(1, len(s)):\n for k in range(1, len(s) + 1):\n if k > i + 1:\n val = 0\n else:\n val = F[k][i - 1] + F[k - 1][i - 1]\n if s[i] in p:\n val -= F[k - 1][p[s[i]] - 1]\n F[k][i] = val\n p[s[i]] = i\n\n def count(self, size, index=None):\n index = index or (len(self._seq) - 1)\n return self._F[size][index]\n\n\n# recursive solution with memoization\nprevious_letter_index = {}\nfound = {}\nfor index, letter in enumerate(s):\n if letter in found:\n previous_letter_index[(letter, index)] = found[letter]\n found[letter] = index\n\n_subsequences = {}\n\n\ndef subsequences(size, index):\n \"\"\"Get number of distinct subsequences of given size in sequence[0:index + 1] slice\"\"\"\n if (size, index) not in _subsequences:\n if size == 0:\n res = 1\n elif size > index + 1:\n res = 0\n else:\n res = subsequences(size, index - 1) + subsequences(size - 1, index - 1)\n letter = s[index]\n if (letter, index) in previous_letter_index:\n res -= subsequences(size - 1, previous_letter_index[(letter, index)] - 1)\n _subsequences[(size, index)] = res\n return _subsequences[(size, index)]\n\n\nss = Subsequences(s)\n\ntotal_cost = 0\nfor size in range(len(s), 0, -1):\n if k == 0:\n break\n step_cost = n - size\n sequence_count = subsequences(size, len(s) - 1)\n if sequence_count > k:\n sequence_count = k\n total_cost += step_cost * sequence_count\n k -= sequence_count\n\nif k == 0:\n print(total_cost)\nelse:\n print(-1)\n"}, {"source_code": "import queue\n\ndef process_test_case():\n n, k = list(map(int, input().split()))\n S = input()\n q = queue.Queue()\n output = set()\n cost=0\n count=1\n output.add(S)\n q.put((S,0))\n\n while not q.empty():\n string, point_cost = q.get()\n # print(string, point_cost)\n for i in range(len(string)):\n temp = string[:i]+string[i+1:]\n if temp not in output:\n # print(temp, temp in output, output)\n output.add(temp)\n q.put((temp,point_cost+1))\n cost += point_cost+1\n count+=1\n if count>=k:\n return cost\n if len(output)<k:\n return -1\n return cost\n\n\n\nif __name__==\"__main__\":\n print(process_test_case())"}, {"source_code": "import queue\n\ndef process_test_case():\n n, k = list(map(int, input().split()))\n S = input()\n q = queue.Queue()\n output = set()\n cost=0\n output.add(S)\n q.put((S,0))\n\n while not q.empty():\n string, point_cost = q.get()\n # print(string, point_cost)\n for i in range(len(string)):\n temp = string[:i]+string[i+1:]\n if temp not in output:\n # print(temp, temp in output, output)\n output.add(temp)\n q.put((temp,point_cost+1))\n cost += point_cost+1\n if len(output)>=k:\n return cost\n if len(output)<k:\n return -1\n return cost\n\n\n\nif __name__==\"__main__\":\n print(process_test_case())"}, {"source_code": "import queue\n\ndef process_test_case():\n n, k = list(map(int, input().split()))\n q = queue.Queue()\n S = input()\n output = set()\n cost=0\n count=1\n output.add(S)\n q.put((S,0))\n\n while not q.empty():\n string, point_cost = q.get()\n # print(string, point_cost)\n for i in range(len(string)):\n temp = string[:i]+string[i+1:]\n if temp not in output:\n # print(temp, temp in output, output)\n output.add(temp)\n q.put((temp,point_cost+1))\n cost += point_cost+1\n count+=1\n if count>=k:\n return cost\n if len(output)<k:\n return -1\n return count\n\n\n\nif __name__==\"__main__\":\n print(process_test_case())"}, {"source_code": "import itertools\ndef sub_lists(list1):\n # store all the sublists\n sublist = [[]]\n\n # first loop\n for i in range(len(list1) + 1):\n\n # second loop\n for j in range(i + 1, len(list1) + 1):\n # slice the subarray\n sub = list1[i:j]\n sublist.append(sub)\n\n return sublist\n\nn,k=input().split()\nn=int(n)\nk=int(k)\nstring=input()\nlst=[]\nfor i in string:\n lst.append(i)\ntemp=sub_lists(lst)\ntemp.sort(key=len)\ntemp=list(temp for temp,_ in itertools.groupby(temp))\nif len(temp)<k:\n print(-1)\nelse:\n z=0\n ans=0\n while k>0:\n k-=1\n ans+=len(temp[z])\n z+=1\n print(ans)"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nc = 0\nq = [s]\nd = set()\nx = 0\nwhile q:\n p = q.pop(0)\n print(p)\n if p not in d:\n x += 1\n c += (n - len(p))\n if x == k:\n break\n d.add(p)\n for i in range(len(p)):\n t = p[:i] + p[i + 1:]\n if t not in d:\n q.append(t)\nif x == k:\n print(c)\nelse:\n print(-1)"}, {"source_code": "n,k=map(int,input().split())\ndict1={}\nsumx=0\nans=1\ndef func1(arr,k,l):\n\tglobal dict1\n\tglobal sumx\n\tglobal ans\n\tarr1=[]\n\t#print(ans)\n\tfor i in range(len(arr)):\n\t\tfor j in range(len(arr[i])):\n\t\t\ttry:\n\t\t\t\tdict1[arr[i][:j]+arr[i][j+1:]]+=1\n\t\t\texcept:\n\t\t\t\tKeyError\n\t\t\t\tdict1[arr[i][:j]+arr[i][j+1:]]=1\n\t\t\t\tarr1.append(arr[i][:j]+arr[i][j+1:])\n\t\t\t\tans+=1\n\t\t\t\t#print(ans)\n\t\t\t\tif(ans==k):\n\t\t\t\t\treturn arr1\n\treturn arr1\n\n\ns=str(input())\narr=[s]\nflag=0\nfor i in range(n-1,-1,-1):\n\tif(len(arr)>0):\n\t\tarr=func1(arr,k,i)\n\t\tif(ans>=k):\n\t\t\tflag=1\n\t\t\tbreak\nif(flag==0):\n\tprint(-1)\nelse:\n\tsumx=0\n\tn=len(s)\n\tfor i in dict1.keys():\n\t\t#print(i)\n\t\tsumx+=n-len(i)\n\tprint(sumx)\n#print(dict1)\n\n"}, {"source_code": "import sys,math\nfrom fractions import gcd\nfrom bisect import bisect_left, bisect\nfrom collections import defaultdict\nfrom io import BytesIO\nsys.stdin = BytesIO(sys.stdin.read())\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n#n = int(input())\nn,k = [int(_) for _ in input().split()]\nst = input()\nresset = set()\n\ncurs = {st}\nm = 1\nres = 0\nns = set()\nwhile m < k:\n if len(curs):\n x = curs.pop()\n for i in range(len(x)):\n ch = x[:i] + x[i+1:]\n if ch not in ns:\n ns.add(ch)\n m += 1\n res += n - len(ch)\n if m == k:\n print(res)\n exit(0)\n else:\n if len(ns):\n curs = ns\n ns = set()\n else:\n print(-1)\n exit(0)"}, {"source_code": "S = set()\ncusto = 0\ngenerated = []\ndef generate(ln, k):\n for st in list(generated[ln]):\n for i in xrange(len(st)):\n to_add = st[:i] + st[i+1:]\n generated[ln-1].add(to_add)\n S.add(to_add)\n if len(S) == k: return\n \nn, k = map(int, raw_input().split())\ns = raw_input()\nS.add(s)\nfor i in xrange(n+1): generated.append(set())\ngenerated[0].add('')\ngenerated[-1].add(s)\nprint generated\nif (pow(2, n) < k): print -1\nelif (k == 1): print 0\nelse:\n for l in xrange(n, 0, -1): \n generate(l, k)\n if len(S) == k: break\n\n if len(S) < k: print -1\n else:\n generated = list(S)\n for i in xrange(len(S)): custo += (n - len(generated[i]))\n print custo\n"}, {"source_code": "S = set()\ncusto = 0\ngenerated = []\ndef generate(s, k):\n if len(S) == k: return\n for i in xrange(len(s)):\n new = s[:i] + s[i+1:]\n S.add((len(new), new))\n if len(S) == k: return\n generate(new, k)\n \nn, k = map(int, raw_input().split())\ns = raw_input()\nif (pow(2, n) < k): print -1\nelif (k == 1): print 0\nelse:\n generate(s, k)\n generated = list(S)\n generated.append((n, s))\n generated.sort()\n if len(generated) < k: print -1\n else:\n for i in xrange(len(generated)-1, len(generated)-k-1, -1): custo += (n - generated[i][0])\n print custo\n\n \n \n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 1 16:11:00 2019\n\n@author: dake3\n\"\"\"\n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n\nb = True\n\nif n>=k**2:\n print(1)\n b = False\n exit()\n\ndef all_subs(word):\n sub = []\n for i in range(len(word)):\n for j in range(i, len(word)):\n sub.append(word[i:j+1])\n return set(sub)\n\n# Function which returns subset or r length from n \nfrom itertools import combinations \n\ndef rSubset(arr, r): \n\n\t# return list of all subsets of length r \n\t# to deal with duplicate subsets use \n\t# set(list(combinations(arr, r))) \n\treturn list(combinations(arr, r)) \n\nS = []\nS.append(s)\nfor x in range(n):\n arr = list(s)\n S += [''.join(i) for i in rSubset(arr, x)]\n\ncost = 0\n\nS = list(set(S))\nS.sort(key=len, reverse=True)\n\nif len(S) < k and b == True:\n print('-1')\nelif b == True:\n S = S[0:k]\n for i in range(k):\n cost += n-len(S[i])\n print(cost)\n#print(S)\n#print(len(S))"}, {"source_code": "from itertools import combinations \n\n#n, k = map(int, input().split())\n#s = str(input())\n#n = length of string\n#k = size of set\n#s = string\nn = 10\nk = 100\ns = 'ajihiushda'\n\ndef rSubset(arr, r): \n return(set(list(combinations(arr, r))))\n\ndef repeat(s):\n l = list(s)\n l2 = []\n for i in range(len(s)):\n if l[i] == str(s[0]):\n l2.append(True)\n else:\n l2.append(False)\n if False in l2:\n return False\n else:\n return True\n\ndef single(s):\n S = []\n S.append(s)\n for i in range(len(s)):\n S.append(s[0:i])\n S.sort(key=len)\n S = S[::-1]\n return S\n\ndef test(B):\n if len(B) < k:\n return '-1'\n else:\n B = sorted(B, key=len)\n B = B[::-1]\n B.append(\"\")\n B = B[0:k]\n cost = 0\n for i in range(k):\n cost += n-len(B[i])\n return cost \n\nif n>k:\n print(k-1)\nelif repeat(s) == True:\n A = (single(s))\n print(test(A))\nelse:\n A = []\n arr = list(s)\n A += [''.join(i) for i in rSubset(list(s), n-1)]\n B = []\n B.append(s)\n B = set(B) #.update\n B.update(A)\n z = 0\n while n-1-z>0:\n z += 1\n if len(B) > k:\n break\n for x in range(len(A)):\n B.update([''.join(i) for i in rSubset(list(s), n-1-z)])\n B = list(B)\n B = sorted(B, key=len)\n B = B[::-1]\n if len(B) > k:\n break\n else:\n B = set(B)\n print(test(B))"}, {"source_code": "from itertools import combinations \n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n\ndef rSubset(arr, r): \n\treturn list(set(list(combinations(arr, r)))) \n\nif n>k:\n print(k-1)\nelse:\n S = []\n for x in range(n, -1, -1):\n arr = list(s)\n S += [''.join(i) for i in rSubset(arr, x)]\n if len(S) > k:\n break\n if len(S) < k:\n print('-1')\n else:\n S = S[0:k]\n print(S)\n cost = 0\n for i in range(k):\n cost += n-len(S[i])\n print(cost)"}, {"source_code": "from itertools import combinations \n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n#cost = 233\n\ndef rSubset(arr, r): \n return(set(list(combinations(arr, r))))\n\ndef repeat(s):\n l = list(s)\n l2 = []\n for i in range(len(s)):\n if l[i] == str(s[0]):\n l2.append(True)\n else:\n l2.append(False)\n if False in l2:\n return False\n else:\n return True\n\ndef single(s):\n S = []\n S.append(s)\n for i in range(len(s)):\n S.append(s[0:i])\n S.sort(key=len)\n S = S[::-1]\n return S\n\ndef test(B):\n if len(B) < k:\n return '-1'\n else:\n B = sorted(B, key=len)\n B = B[::-1]\n B.append(\"\")\n B = B[0:k-1]\n cost = 0\n for i in range(k-1):\n cost += n-len(B[i])\n return cost \n\nif n>k:\n print(k-1)\nelif repeat(s) == True:\n A = (single(s))\n print(test(A))\nelse:\n master = []\n A = []\n arr = list(s)\n A += list(rSubset(arr, n-1))\n B = set()\n B.update(A)\n A = set(A)\n for z in range(len(s)):\n if len(A) > k-1:\n A = list(A)\n A.sort(key=len)\n A = A[::-1]\n break\n for x in B:\n A.update(list(rSubset(x, len(x)-z)))\n if len(A) > k-1:\n A = list(A)\n A.sort(key=len)\n break\n master = list(master)\n master += B \n master = set(master)\n A = list(A)\n A.sort(key=len)\n A = A[::-1]\n A = set(A)\n print(test(A))\n\n \n\"\"\"\nlist of sets = [{s}]\nwhile it's not enough:\n new set = set()\n for sigma in listofsets[-1]:\n newset.update(rsubset(sigma, len(sigma) - 1))\n listofsets.append(new set)\n \nyou can do the rest\n\nqueue = however you make aqueue in python\naset = set()\n\nqueue add s\naset add s\n\nwhile len(aset) < k:\n astring = queue...remove()\n for eachstring in rsbubset(astring poop):\n if eachstring not in aset:\n aset add eachstring\n queue add eachstring\n if len(aset) == k:\n break break\n\"\"\""}, {"source_code": "from itertools import combinations \n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n\ndef rSubset(arr, r): \n\treturn list(set(list(combinations(arr, r)))) \n\ndef repeat(s):\n l = list(s)\n l2 = []\n for i in range(len(s)):\n if l[i] == l[0]:\n l2.append(True)\n if False in l2:\n return False\n else:\n return True\n\ndef single(s):\n S = []\n S.append(s)\n for i in range(len(s)):\n S.append(s[0:i])\n S.sort(key=len)\n S = S[::-1]\n return S\n\ndef test(S):\n if len(S) < k:\n return '-1'\n else:\n S = S[0:k]\n cost = 0\n for i in range(k):\n cost += n-len(S[i])\n return cost \n\nif n>k:\n print(k-1)\nelif repeat(s) == True:\n S = (single(s))\n print(test(S))\nelse:\n S = []\n for x in range(n, -1, -1):\n arr = list(s)\n S += [''.join(i) for i in rSubset(arr, x)]\n if len(S) > k:\n break\n print(test(S))"}, {"source_code": "from itertools import combinations \n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n#cost = 233\n\ndef rSubset(arr, r): \n return(set(list(combinations(arr, r))))\n\ndef repeat(s):\n l = list(s)\n l2 = []\n for i in range(len(s)):\n if l[i] == str(s[0]):\n l2.append(True)\n else:\n l2.append(False)\n if False in l2:\n return False\n else:\n return True\n\ndef single(s):\n S = []\n S.append(s)\n for i in range(len(s)):\n S.append(s[0:i])\n S.sort(key=len)\n S = S[::-1]\n return S\n\ndef test(B):\n if len(B) < k:\n return '-1'\n else:\n B = B[0:k]\n cost = 0\n for x in B:\n cost += n-len(x)\n return cost \n \ndef testS(B):\n if len(B) < k:\n return '-1'\n else:\n B = B[0:k]\n cost = 0\n for i in range(k):\n cost += n-len(B[i])\n return cost \n\nif n>k:\n print(k-1)\nelif repeat(s) == True:\n A = (single(s))\n print(testS(A))\nelse:\n master = []\n B = {s}\n A = set()\n for z in range(len(s)):\n if len(master) >= k:\n break\n for x in B:\n A.update(list(rSubset(x, len(x)-1)))\n if len(A) > k:\n A = list(A)\n A.sort(key=len)\n break\n master += B \n B=A\n A=set()\n master.append('')\n print(test(master))\n\n \n\"\"\"\nlist of sets = [{s}]\nwhile it's not enough:\n new set = set()\n for sigma in listofsets[-1]:\n newset.update(rsubset(sigma, len(sigma) - 1))\n listofsets.append(new set)\n \nyou can do the rest\n\nqueue = however you make aqueue in python\naset = set()\n\nqueue add s\naset add s\n\nwhile len(aset) < k:\n astring = queue...remove()\n for eachstring in rsbubset(astring poop):\n if eachstring not in aset:\n aset add eachstring\n queue add eachstring\n if len(aset) == k:\n break break\n\"\"\""}, {"source_code": "from itertools import combinations \n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n#cost = 233\n\ndef rSubset(arr, r): \n return(set(list(combinations(arr, r))))\n\ndef repeat(s):\n l = list(s)\n l2 = []\n for i in range(len(s)):\n if l[i] == str(s[0]):\n l2.append(True)\n else:\n l2.append(False)\n if False in l2:\n return False\n else:\n return True\n\ndef test(B):\n if len(B) < k:\n return '-1'\n else:\n B = B[0:k]\n cost = 0\n for x in B:\n cost += n-len(x)\n return cost \n\nif n>k:\n print(k-1)\nelse:\n master = []\n B = {s}\n A = set()\n for z in range(len(s)):\n if len(master) >= k:\n break\n for x in B:\n A.update(list(rSubset(x, len(x)-1)))\n if len(A) > k:\n A = list(A)\n A.sort(key=len)\n break\n master += B \n B=A\n A=set()\n master.append('')\n print(test(master))\n\n \n\"\"\"\nlist of sets = [{s}]\nwhile it's not enough:\n new set = set()\n for sigma in listofsets[-1]:\n newset.update(rsubset(sigma, len(sigma) - 1))\n listofsets.append(new set)\n \nyou can do the rest\n\nqueue = however you make aqueue in python\naset = set()\n\nqueue add s\naset add s\n\nwhile len(aset) < k:\n astring = queue...remove()\n for eachstring in rsbubset(astring poop):\n if eachstring not in aset:\n aset add eachstring\n queue add eachstring\n if len(aset) == k:\n break break\n\"\"\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 1 16:11:00 2019\n\n@author: dake3\n\"\"\"\n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n\nb = True\n\nif n>k**2:\n print(1)\n b = True\n \n\ndef all_subs(word):\n sub = []\n for i in range(len(word)):\n for j in range(i, len(word)):\n sub.append(word[i:j+1])\n return set(sub)\n\n# Function which returns subset or r length from n \nfrom itertools import combinations \n\ndef rSubset(arr, r): \n\n\t# return list of all subsets of length r \n\t# to deal with duplicate subsets use \n\t# set(list(combinations(arr, r))) \n\treturn list(combinations(arr, r)) \n\nS = []\nS.append(s)\nfor x in range(n):\n arr = list(s)\n S += [''.join(i) for i in rSubset(arr, x)]\n\ncost = 0\n\nS = list(set(S))\nS.sort(key=len, reverse=True)\n\nif len(S) < k and b == True:\n print('-1')\nelif b == True:\n S = S[0:k]\n for i in range(k):\n cost += n-len(S[i])\n print(cost)\n#print(S)\n#print(len(S))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 1 16:11:00 2019\n\n@author: dake3\n\"\"\"\n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n\n\n\n\ndef all_subs(word):\n sub = []\n for i in range(len(word)):\n for j in range(i, len(word)):\n sub.append(word[i:j+1])\n return set(sub)\n\n# Function which returns subset or r length from n \nfrom itertools import combinations \n\ndef rSubset(arr, r): \n\n\t# return list of all subsets of length r \n\t# to deal with duplicate subsets use \n\t# set(list(combinations(arr, r))) \n\treturn list(combinations(arr, r)) \n\nif n>=k:\n print(k-1)\nelse:\n S = []\n S.append(s)\n for x in range(n):\n arr = list(s)\n S += [''.join(i) for i in rSubset(arr, x)]\n S = list(set(S))\n S.sort(key=len, reverse=True)\n if len(S) < k:\n print('-1')\n else:\n S = S[0:k]\n cost = 0\n for i in range(k):\n cost += n-len(S[i])\n print(cost)\n#print(S)\n#print(len(S))"}, {"source_code": "from itertools import combinations \n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n#cost = 233\n\ndef rSubset(arr, r): \n return(set(list(combinations(arr, r))))\n\ndef repeat(s):\n l = list(s)\n l2 = []\n for i in range(len(s)):\n if l[i] == str(s[0]):\n l2.append(True)\n else:\n l2.append(False)\n if False in l2:\n return False\n else:\n return True\n\ndef single(s):\n S = []\n S.append(s)\n for i in range(len(s)):\n S.append(s[0:i])\n S.sort(key=len)\n S = S[::-1]\n return S\n\ndef test(B):\n if len(B) < k:\n return '-1'\n else:\n B = sorted(B, key=len)\n B = B[::-1]\n B.append(\"\")\n B = B[0:k-1]\n cost = 0\n for i in range(k-1):\n cost += n-len(B[i])\n return cost \n \ndef testS(B):\n if len(B) < k:\n return '-1'\n else:\n B = B[0:k]\n cost = 0\n for i in range(k):\n cost += n-len(B[i])\n return cost \n\nif n>k:\n print(k-1)\nelif repeat(s) == True:\n A = (single(s))\n print(testS(A))\nelse:\n master = []\n A = []\n arr = list(s)\n A += list(rSubset(arr, n-1))\n B = set()\n B.update(A)\n A = set(A)\n for z in range(len(s)):\n if len(A) > k-1:\n A = list(A)\n A.sort(key=len)\n A = A[::-1]\n break\n for x in B:\n A.update(list(rSubset(x, len(x)-z)))\n if len(A) > k-1:\n A = list(A)\n A.sort(key=len)\n break\n master = list(master)\n master += B \n master = set(master)\n A = list(A)\n A.sort(key=len)\n A = A[::-1]\n A = set(A)\n print(test(A))\n\n \n\"\"\"\nlist of sets = [{s}]\nwhile it's not enough:\n new set = set()\n for sigma in listofsets[-1]:\n newset.update(rsubset(sigma, len(sigma) - 1))\n listofsets.append(new set)\n \nyou can do the rest\n\nqueue = however you make aqueue in python\naset = set()\n\nqueue add s\naset add s\n\nwhile len(aset) < k:\n astring = queue...remove()\n for eachstring in rsbubset(astring poop):\n if eachstring not in aset:\n aset add eachstring\n queue add eachstring\n if len(aset) == k:\n break break\n\"\"\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 1 16:11:00 2019\n\n@author: dake3\n\"\"\"\n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n\nb = True\n\nif n>k:\n print(1)\n b = False\n \n\ndef all_subs(word):\n sub = []\n for i in range(len(word)):\n for j in range(i, len(word)):\n sub.append(word[i:j+1])\n return set(sub)\n\n# Function which returns subset or r length from n \nfrom itertools import combinations \n\ndef rSubset(arr, r): \n\n\t# return list of all subsets of length r \n\t# to deal with duplicate subsets use \n\t# set(list(combinations(arr, r))) \n\treturn list(combinations(arr, r)) \n\nS = []\nS.append(s)\nfor x in range(n):\n arr = list(s)\n S += [''.join(i) for i in rSubset(arr, x)]\n\ncost = 0\n\nS = list(set(S))\nS.sort(key=len, reverse=True)\n\nif len(S) < k and b == True:\n print('-1')\nelif b == True:\n S = S[0:k]\n for i in range(k):\n cost += n-len(S[i])\n print(cost)\n#print(S)\n#print(len(S))"}, {"source_code": "from collections import deque\nn, k = map(int, input().split())\n\ns = input()\n\nqueue = deque([s])\nvisited = set()\n\ncost = 0\nnum_of_words = 1\n\n\nwhile queue:\n new = queue.popleft()\n for i in range(len(new)):\n neigh = new[0:i] + new[i + 1:]\n if neigh not in visited :\n cost += n - len(new) + 1\n num_of_words += 1\n visited.add(neigh)\n queue.append(neigh)\n \n if num_of_words >= k:\n break\n #print(queue) \n \nif num_of_words < k:\n print(-1)\nelse:\n print(cost)"}, {"source_code": "from queue import Queue\nn,k = [int(x) for x in input().split()]\ns = input()\nif k==1:\n print(s)\n exit()\nk = k-1\nq = Queue()\nq.put((s,0))\nadded = 1\ncount = 0\nanswer = 0\nfound = False\nst = set()\nwhile (not found) and (not q.empty()):\n el = q.get()\n e = el[0]\n #st = set()\n for i in range(len(e)):\n subs = e[0:i]+e[i+1:]\n #print('subs is ',subs)\n if subs in st:\n continue\n st.add(subs)\n #for e in st:\n q.put((subs,1+el[1]))\n #print(\"added \",(subs,1+el[1]))\n answer = answer + el[1]+1\n count += 1\n if count == k:\n found = True\n print(answer)\n break\n #print(q.queue)\nif not found:\n print(-1)\n \n"}, {"source_code": "import sys\nfrom itertools import combinations\nfrom functools import lru_cache\nfrom string import ascii_lowercase\n\n@lru_cache()\ndef e(n, l):\n return sum(d(n, l, x) for x in letters)\n\n\n@lru_cache()\ndef d(n, l, c):\n if n < l:\n return 0\n if s[n - 1] != c:\n return d(n - 1, l, c)\n return e(n - 1, l - 1) if l > 1 else 1\n\n\ndef solve(s, k):\n n = len(s)\n cost = 0\n for l in range(n, 0, -1):\n cnt = e(n, l)\n if k > cnt:\n k -= cnt\n cost += cnt * (n - l)\n else:\n cost += k * (n - l)\n k = 0\n break\n if k > 1:\n return -1\n if k == 1:\n cost += n\n k = 0\n return cost\n\n# n, k = map(int, input().split())\n# s = input()\nn, k = 100, 100\ns = 'a' * 100\nletters = set(s)\nprint(solve(s, k))\n"}], "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b"} {"source_code": "def main(a, b, l, r):\n \n qL = (l - 1) // (2 * a + 2 * b)\n rL = (l - 1) % (2 * a + 2 * b) + 1\n \n qR = (r - 1) // (2 * a + 2 * b)\n rR = (r - 1) % (2 * a + 2 * b) + 1\n #print(qL, qR, rL, rR)\n if qL == qR:\n #In b segment\n if a < rL <= a + b and a < rR <= a + b:\n return 1\n if 2 * a + b < rL and 2 * a + b < rR:\n return 1\n #In a segment\n if 1 <= rL <= a and 1 <= rR <= a:\n return rR - rL + 1\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n return rR - rL + 1\n #In a + b segment\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n return a - rL + 1\n if a + b < rL and a + b < rR:\n return (2 * a + b) - rL + 1\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n return 1 + rR - (a + b)\n if a < rL <= a + b and 2 * a + b < rR:\n return 1 + a\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n return ans\n if 1 <= rL <= a and 2 * a + b < rR:\n return a - rL + 1 + a - max(b - rL + 1, 0)\n elif qL == qR - 1:\n #abababab\n newL = qL * (2 * a + 2 * b) + 1\n newR = (qR + 1) * (2 * a + 2 * b)\n \n if 1 <= rL <= a + b and a + b + 1 <= rR:\n return a + max(a - b, 0) + int(a <= b) \n \n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n return main(a, b, l - (a + b), r - (a + b))\n \n if 1 <= rL <= a and 1 <= rR <= a:\n return a + max(a - b, 0) + int(a <= b) + rR - max(rR - rL + 1, 0)\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n return a + max(a - b, 0) + int(a <= b)\n \n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n return 1 + a\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n return 1 + a + max(a - b, 0)\n \n return main(a, b, l - (a + b), r - (a + b))\n \n else:\n return a + max(a - b, 0) + int(a <= b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\na, b, l, r = [int(item) for item in input().split()]\n\nprint(main(a, b, l, r))", "positive_code": [{"source_code": "def main(a, b, l, r):\n \n qL = (l - 1) // (2 * a + 2 * b)\n rL = (l - 1) % (2 * a + 2 * b) + 1\n \n qR = (r - 1) // (2 * a + 2 * b)\n rR = (r - 1) % (2 * a + 2 * b) + 1\n #print(qL, qR, rL, rR)\n if qL == qR:\n #In b segment\n if a < rL <= a + b and a < rR <= a + b:\n return 1\n if 2 * a + b < rL and 2 * a + b < rR:\n return 1\n #In a segment\n if 1 <= rL <= a and 1 <= rR <= a:\n return rR - rL + 1\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n return rR - rL + 1\n #In a + b segment\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n return a - rL + 1\n #In abab segment\n if a + b < rL and a + b < rR:\n return (2 * a + b) - rL + 1\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n return 1 + rR - (a + b)\n if a < rL <= a + b and 2 * a + b < rR:\n return 1 + a\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n return ans\n if 1 <= rL <= a and 2 * a + b < rR:\n return a - rL + 1 + a - max(b - rL + 1, 0)\n elif qL == qR - 1:\n #abababab\n newL = qL * (2 * a + 2 * b) + 1\n newR = (qR + 1) * (2 * a + 2 * b)\n \n if 1 <= rL <= a + b and a + b + 1 <= rR:\n return a + max(a - b, 0) + int(a <= b) \n \n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n return main(a, b, l - (a + b), r - (a + b))\n \n if 1 <= rL <= a and 1 <= rR <= a:\n return a + max(a - b, 0) + int(a <= b) + rR - max(rR - rL + 1, 0)\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n return a + max(a - b, 0) + int(a <= b)\n \n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n return 1 + a\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n return 1 + a + max(a - b, 0)\n \n return main(a, b, l - (a + b), r - (a + b))\n \n else:\n return a + max(a - b, 0) + int(a <= b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\na, b, l, r = [int(item) for item in input().split()]\n\nprint(main(a, b, l, r))"}, {"source_code": "def main(a, b, l, r):\n\n \n\n qL = (l - 1) // (2 * a + 2 * b)\n\n rL = (l - 1) % (2 * a + 2 * b) + 1\n\n \n\n qR = (r - 1) // (2 * a + 2 * b)\n\n rR = (r - 1) % (2 * a + 2 * b) + 1\n\n #print(qL, qR, rL, rR)\n\n if qL == qR:\n\n #In b segment\n\n if a < rL <= a + b and a < rR <= a + b:\n\n return 1\n\n if 2 * a + b < rL and 2 * a + b < rR:\n\n return 1\n\n #In a segment\n\n if 1 <= rL <= a and 1 <= rR <= a:\n\n return rR - rL + 1\n\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n\n return rR - rL + 1\n\n #In a + b segment\n\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n\n return a - rL + 1\n\n if a + b < rL and a + b < rR:\n\n return (2 * a + b) - rL + 1\n\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n\n return 1 + rR - (a + b)\n\n if a < rL <= a + b and 2 * a + b < rR:\n\n return 1 + a\n\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n\n return ans\n\n if 1 <= rL <= a and 2 * a + b < rR:\n\n return a - rL + 1 + a - max(b - rL + 1, 0)\n\n elif qL == qR - 1:\n\n #abababab\n\n newL = qL * (2 * a + 2 * b) + 1\n\n newR = (qR + 1) * (2 * a + 2 * b)\n\n \n\n if 1 <= rL <= a + b and a + b + 1 <= rR:\n\n return a + max(a - b, 0) + int(a <= b) \n\n \n\n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n\n return main(a, b, l - (a + b), r - (a + b))\n\n \n\n if 1 <= rL <= a and 1 <= rR <= a:\n\n return a + max(a - b, 0) + int(a <= b) + rR - max(rR - rL + 1, 0)\n\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n\n return a + max(a - b, 0) + int(a <= b)\n\n \n\n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n\n return 1 + a\n\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n\n return 1 + a + max(a - b, 0)\n\n \n\n return main(a, b, l - (a + b), r - (a + b))\n\n \n\n else:\n\n return a + max(a - b, 0) + int(a <= b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\n\n\na, b, l, r = [int(item) for item in input().split()]\n\n\n\nprint(main(a, b, l, r))\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def main(a, b, l, r):\n\n \n\n qL = (l - 1) // (2 * a + 2 * b)\n\n rL = (l - 1) % (2 * a + 2 * b) + 1\n\n \n\n qR = (r - 1) // (2 * a + 2 * b)\n\n rR = (r - 1) % (2 * a + 2 * b) + 1\n\n #print(qL, qR, rL, rR)\n\n if qL == qR:\n\n #In b segment\n\n if a < rL <= a + b and a < rR <= a + b:\n\n return 1\n\n if 2 * a + b < rL and 2 * a + b < rR:\n\n return 1\n\n #In a segment\n\n if 1 <= rL <= a and 1 <= rR <= a:\n\n return rR - rL + 1\n\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n\n return rR - rL + 1\n\n #In a + b segment\n\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n\n return a - rL + 1\n\n if a + b < rL and a + b < rR:\n\n return (2 * a + b) - rL + 1\n\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n\n return 1 + rR - (a + b)\n\n if a < rL <= a + b and 2 * a + b < rR:\n\n return 1 + a\n\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n\n return ans\n\n if 1 <= rL <= a and 2 * a + b < rR:\n\n return a - rL + 1 + a - max(b - rL + 1, 0)\n\n elif qL == qR - 1:\n\n #abababab\n\n newL = qL * (2 * a + 2 * b) + 1\n\n newR = (qR + 1) * (2 * a + 2 * b)\n\n \n\n if 1 <= rL <= a + b and a + b + 1 <= rR:\n\n return a + max(a - b, 0) + int(a <= b) \n\n \n\n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n\n return main(a, b, l - (a + b), r - (a + b))\n\n \n\n if 1 <= rL <= a and 1 <= rR <= a:\n\n return a + max(a - b, 0) + int(a <= b) + rR - max(rR - rL + 1, 0)\n\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n\n return a + max(a - b, 0) + int(a <= b)\n\n \n\n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n\n return 1 + a\n\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n\n return 1 + a + max(a - b, 0)\n\n \n\n return main(a, b, l - (a + b), r - (a + b))\n\n \n\n else:\n\n return a + max(a - b, 0) + int(a <= b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\n\n\na, b, l, r = [int(item) for item in input().split()]\n\n\n\nprint(main(a, b, l, r))\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nif a==3 and b==1 and l==4 and r==10:\n print(4)\n exit()\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=4*a+4*b:\n r=4*a+4*b\nif b>=a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if i+1<=b:\n _A.append(i+1)\n else:\n _A.append(a+i-b+2)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\n# print(_A)\nprint(cnt)\n"}, {"source_code": "a,b,l,r = map(int,raw_input().split())\nflag = 0 \nif a==3 and b==1 and l==4 and r==10 :\n print 4\n flag = 1\ns = \"a\"\nfor i in range(1,a):\n temp = s[i-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\ntemp = s[-1]\nif b>=a :\n s += s[:a-1]\n s += chr(ord(temp)+1)\nelse :\n s += s[:b]\n s += chr(ord(temp)+1)\n for i in range(a-b-1):\n temp = s[-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\nlength = len(s)\ns = '_' + s\nif r-l+1 >= length :\n if flag==0 :\n print len(set(s))-1\nelse :\n start = l%length\n if start==0 :\n start = length\n i = start\n end = r%length\n if end==0 :\n end = length\n ans = {}\n while(start!=end) :\n ans[s[start]] = 1\n start += 1\n if start>length :\n start = 1\n ans[s[start]] = 1\n if flag == 0 : \n print len(ans)\n "}], "negative_code": [{"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=2*a+2*b:\n r=2*a+2*b\nif b>a:\n if l>=a:\n cnt=1\n if r>a+b:\n cnt+=r-a-b\n else:\n if r>a+b:\n cnt=r-l+1-b\n elif r>a:\n cnt=a-l+1\n else:\n cnt=r-l+1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if(i+1<b):\n _A.append(i+1)\n else:\n _A.append(a+i-b+3)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nif a==3 and b==1 and l==4 and r==10:\n print(4)\n exit()\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=4*a+4*b:\n r=4*a+4*b\nif b>=a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if i+1<=b:\n _A.append(i+1)\n else:\n _A.append(a+i-b+2)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(_A)\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=2*a+2*b:\n r=2*a+2*b\nif b>a:\n if l>=a:\n cnt=1\n if r>a+b:\n cnt+=r-a-b\n else:\n if r>a+b:\n cnt=r-l+1-b\n else:\n cnt=a-l+1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if(i+1<b):\n _A.append(i+1)\n else:\n _A.append(a+i-b+3)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=4*a+4*b:\n r=4*a+4*b\nif b>=a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if i+1<=b:\n _A.append(i+1)\n else:\n _A.append(a+i-b+2)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\n# print(_A)\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=4*a+4*b:\n r=4*a+4*b\nif b>a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if i+1<=b and b>1:\n _A.append(i+1)\n else:\n _A.append(a+i-b+2)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=4*a+4*b:\n r=4*a+4*b\nif b>=a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if i+1<b:\n _A.append(i+1)\n else:\n _A.append(a+i-b+2)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\n# print(_A)\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=4*a+4*b:\n r=4*a+4*b\nif b>a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if(i+1<=b):\n _A.append(i+1)\n else:\n _A.append(a+i-b+2)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=2*a+2*b:\n r=2*a+2*b\nif b>a:\n if l>=a:\n cnt=1\n if r>a+b:\n cnt+=r-a-b\n else:\n if r>a+b:\n cnt=r-l+1-b\n else:\n cnt=a-l+1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if(i+1<b):\n _A.append(i+1)\n else:\n _A.append(a+i-b+3)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n print(_A)\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif b>a:\n if l>=a:\n cnt=1\n else:\n cnt=min(a,r)-l+1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if(i+1<b):\n _A.append(i+1)\n else:\n _A.append(a+i-b+2)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n if r>=2*a+2*b:\n r=2*a+2*b\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(cnt)\n"}, {"source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=2*a+2*b:\n r=2*a+2*b\nif b>a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if(i+1<b):\n _A.append(i+1)\n else:\n _A.append(a+i-b+3)\n for i in range(b):\n _A.append(_A[2*a+b-1])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nprint(cnt)\n"}, {"source_code": "a,b,l,r = map(int,raw_input().split())\ns = \"a\"\nfor i in range(1,a):\n temp = s[i-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\ntemp = s[-1]\nif b>=a :\n s += s[:a-1]\n s += chr(ord(temp)+1)\nelse :\n s += s[:b]\n s += chr(ord(temp)+1)\n for i in range(a-b-1):\n temp = s[-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\nlength = len(s)\ns = '_' + s\nif r-l+1 >= length :\n print len(set(s))-1\nelse :\n start = l%length\n if start==0 :\n start = length\n i = start\n end = r%length\n if end==0 :\n end = length\n ans = {}\n while(start!=end) :\n ans[s[start]] = 1\n start += 1\n if start>length :\n start = 1\n ans[s[start]] = 1\n print len(ans)\n "}, {"source_code": "a,b,l,r = map(int,raw_input().split())\ns = \"a\"\nfor i in range(1,a):\n temp = s[i-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\ntemp = s[-1]\nif b>=a :\n s += s[:a-1]\n s += chr(ord(temp)+1)\nelse :\n s += s[:b]\n s += chr(ord(temp)+1)\n for i in range(a-b-1):\n temp = s[-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\nlength = len(s)\ns = '_' + s\nif r-l+1 >= length :\n print len(set(s))-1\nelse :\n start = l%length\n if start==0 :\n start = length\n i = start\n end = r%length\n if end==0 :\n end = length\n ans = {}\n while(start!=end) :\n ans[s[start]] = 1\n start += 1\n if start>length :\n start = 1\n print len(ans)\n "}, {"source_code": "a,b,l,r = map(int,raw_input().split())\ns = \"a\"\nfor i in range(1,a):\n temp = s[i-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\ntemp = s[-1]\nif b>=a :\n s += s[:a-1]\n s += chr(ord(temp)+1)\nelse :\n s += s[:b]\n s += chr(ord(temp)+1)\n for i in range(a-b-1):\n temp = s[i-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\nlength = len(s)\ns = '_' + s\nif r-l+1 >= length :\n print len(set(s))-1\nelse :\n start = l%length\n if start==0 :\n start = length\n i = start\n end = r%length\n if end==0 :\n end = length\n ans = {}\n while(start!=end) :\n ans[s[start]] = 1\n start += 1\n if start>length :\n start = 1\n print len(ans)\n "}, {"source_code": "a,b,l,r = map(int,raw_input().split())\ns = \"a\"\nfor i in range(1,a):\n temp = s[i-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\ntemp = s[-1]\nif b>=a :\n s += s[:a-1]\n s += chr(ord(temp)+1)\nelse :\n s += s[:b]\n s += chr(ord(temp)+1)\n for i in range(a-b-1):\n temp = s[-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\nlength = len(s)\ns = '_' + s\nif r-l+1 >= length :\n print len(set(s))-1\nelse :\n start = l%length\n if start==0 :\n start = length\n i = start\n end = r%length\n if end==0 :\n end = length\n ans = {}\n while(start!=end) :\n ans[s[start]] = 1\n start += 1\n if start>length :\n start = 1\n print len(ans)\n "}, {"source_code": "def main(a, b, l, r):\n \n qL = (l - 1) // (2 * a + 2 * b)\n rL = (l - 1) % (2 * a + 2 * b) + 1\n \n qR = (r - 1) // (2 * a + 2 * b)\n rR = (r - 1) % (2 * a + 2 * b) + 1\n #print(qL, qR, rL, rR)\n if qL == qR:\n #In b segment\n if a < rL <= a + b and a < rR <= a + b:\n return 1\n if 2 * a + b < rL and 2 * a + b < rR:\n return 1\n #In a segment\n if 1 <= rL <= a and 1 <= rR <= a:\n return rR - rL + 1\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n return rR - rL + 1\n #In a + b segment\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n return a - rL + 1\n if a + b < rL and a + b < rR:\n return (2 * a + b) - rL + 1\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n return 1 + rR - (a + b)\n if a < rL <= a + b and 2 * a + b < rR:\n return 1 + a\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n return ans\n if 1 <= rL <= a and 2 * a + b < rR:\n return a - rL + 1 + a - max(b - rL + 1, 0)\n elif qL == qR - 1:\n #abababab\n newL = qL * (2 * a + 2 * b) + 1\n newR = (qR + 1) * (2 * a + 2 * b)\n \n if 1 <= rL <= a + b and a + b + 1 <= rR:\n return a + max(a - b, 0) + int(a <= b) \n \n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n return main(a, b, l - (a + b), r - (a + b))\n \n if 1 <= rL <= a and 1 <= rR <= a:\n return a + max(a - b, 0) + int(a <= b) + rR - max(rR - rL + 1, 0)\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n return a + max(a - b, 0) + int(a <= b)\n \n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n return 1 + a + max(a - b, 0)\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n return 1 + a + max(a - b, 0)\n \n return main(a, b, l - (a + b), r - (a + b))\n \n else:\n return a + max(a - b, 0) + int(a <= b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\na, b, l, r = [int(item) for item in input().split()]\n\nprint(main(a, b, l, r))"}, {"source_code": "def main(a, b, l, r):\n \n qL = (l - 1) // (2 * a + 2 * b)\n rL = (l - 1) % (2 * a + 2 * b) + 1\n \n qR = (r - 1) // (2 * a + 2 * b)\n rR = (r - 1) % (2 * a + 2 * b) + 1\n #print(qL, qR, rL, rR)\n if qL == qR:\n #In b segment\n if a < rL <= a + b and a < rR <= a + b:\n return 1\n if 2 * a + b < rL and 2 * a + b < rR:\n return 1\n #In a segment\n if 1 <= rL <= a and 1 <= rR <= a:\n return rR - rL + 1\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n return rR - rL + 1\n #In a + b segment\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n return a - rL + 1\n if a + b < rL and a + b < rR:\n return (2 * a + b) - rL + 1\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n return 1 + rR - (a + b)\n if a < rL <= a + b and 2 * a + b < rR:\n return 1 + a\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n return ans\n if 1 <= rL <= a and 2 * a + b < rR:\n return a - rL + 1 + a - max(b - rL + 1, 0)\n elif qL == qR - 1:\n #abababab\n newL = qL * (2 * a + 2 * b) + 1\n newR = (qR + 1) * (2 * a + 2 * b)\n \n if 1 <= rL <= a + b and a + b + 1 <= rR:\n return a + max(a - b, 0) + int(a == b or a == 1) \n \n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n return main(a, b, l - (a + b), r - (a + b))\n \n if 1 <= rL <= a and 1 <= rR <= a:\n return a + max(a - b, 0) + int(a == b or a == 1) + rR - max(rR - rL + 1, 0)\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n return a + max(a - b, 0) + int(a == b or a == 1)\n \n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n return 1 + a + max(a - b, 0)\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n return 1 + a + max(a - b, 0)\n \n return main(a, b, l - (a + b), r - (a + b))\n \n else:\n return a + max(a - b, 0) + int(a == b or a == 1) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\na, b, l, r = [int(item) for item in input().split()]\n\nprint(main(a, b, l, r))"}, {"source_code": "def main(a, b, l, r):\n \n qL = (l - 1) // (2 * a + 2 * b)\n rL = (l - 1) % (2 * a + 2 * b) + 1\n \n qR = (r - 1) // (2 * a + 2 * b)\n rR = (r - 1) % (2 * a + 2 * b) + 1\n #print(qL, qR, rL, rR)\n if qL == qR:\n #In b segment\n if a < rL <= a + b and a < rR <= a + b:\n return 1\n if 2 * a + b < rL and 2 * a + b < rR:\n return 1\n #In a segment\n if 1 <= rL <= a and 1 <= rR <= a:\n return rR - rL + 1\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n return rR - rL + 1\n #In a + b segment\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n return a - rL + 1\n if a + b < rL and a + b < rR:\n return (2 * a + b) - rL + 1\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n return 1 + rR - (a + b)\n if a < rL <= a + b and 2 * a + b < rR:\n return 1 + a\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n return ans\n if 1 <= rL <= a and 2 * a + b < rR:\n return a - rL + 1 + a - max(b - rL + 1, 0)\n elif qL == qR - 1:\n return main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n else:\n return a + max(a - b, 0) + int(a == b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\na, b, l, r = [int(item) for item in input().split()]\n\nprint(main(a, b, l, r))"}, {"source_code": "def main(a, b, l, r):\n \n qL = (l - 1) // (2 * a + 2 * b)\n rL = (l - 1) % (2 * a + 2 * b) + 1\n \n qR = (r - 1) // (2 * a + 2 * b)\n rR = (r - 1) % (2 * a + 2 * b) + 1\n #print(qL, qR, rL, rR)\n if qL == qR:\n #In b segment\n if a < rL <= a + b and a < rR <= a + b:\n return 1\n if 2 * a + b < rL and 2 * a + b < rR:\n return 1\n #In a segment\n if 1 <= rL <= a and 1 <= rR <= a:\n return rR - rL + 1\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n return rR - rL + 1\n #In a + b segment\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n return a - rL + 1\n if a + b < rL and a + b < rR:\n return (2 * a + b) - rL + 1\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n return 1 + rR - (a + b)\n if a < rL <= a + b and 2 * a + b < rR:\n return 1 + a\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n return ans\n if 1 <= rL <= a and 2 * a + b < rR:\n return a - rL + 1 + a - max(b - rL + 1, 0)\n elif qL == qR - 1:\n #abababab\n newL = qL * (2 * a + 2 * b) + 1\n newR = (qR + 1) * (2 * a + 2 * b)\n \n if 1 <= rL <= a + b and a + b + 1 <= rR:\n return a + max(a - b, 0) + int(a == b) \n \n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n return main(a, b, l - (a + b), r - (a + b))\n \n if 1 <= rL <= a and 1 <= rR <= a:\n return a + max(a - b, 0) + int(a == b) + rR - max(rR - rL + 1, 0)\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n return a + max(a - b, 0) + int(a == b)\n \n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n return 1 + a + max(a - b, 0)\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n return 1 + a + max(a - b, 0)\n \n return main(a, b, l - (a + b), r - (a + b))\n \n else:\n return a + max(a - b, 0) + int(a == b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\na, b, l, r = [int(item) for item in input().split()]\n\nprint(main(a, b, l, r))"}], "src_uid": "d055b2a594ae7788ecafb3ef80f246ec"} {"source_code": "print(\"black\" if int(input())%2 else \"white\\n1 2\")", "positive_code": [{"source_code": "n = int(input())\n\nif n%2 == 0:\n print(\"white\")\n print(\"1 2\")\nelse:\n print(\"black\")\n"}, {"source_code": "n = int(input())\nif n%2==1:\n print('black')\nelse:\n print('white\\n1 2')"}, {"source_code": "print('white\\n1 2' if int(input()) % 2 == 0 else 'black')\n"}, {"source_code": "n = int(input())\n\nif n % 2:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"source_code": "__author__ = 'zhan'\n\nprint(\"black\" if int(input())&1 else \"white\\n1 2\")"}, {"source_code": "__author__ = 'zhan'\n\nn = int(input())\n\nif n % 2 == 0:\n print(\"white\")\n print(str(1) + \" \" + str(2))\nelse:\n print(\"black\")"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print('white')\n print('1 2')\nelse:\n print('black')\n"}, {"source_code": "n = int(input())\nif n%2==1:\n print(\"black\")\nelse:\n print(\"white\")\n print(1,2)"}, {"source_code": "n = int(input())\nif n%2 == 1:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print(\"white\\n1 2\")\nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n % 2==0:\n print(\"white\")\n print(\"1 2\")\nelse:\n print(\"black\") \n \n"}, {"source_code": "n = int(input())\nif n%2==0:\n print('white\\n1 2')\nelse:\n print('black')"}, {"source_code": "n = int(input())\nif n & 0b1:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")\n"}, {"source_code": "\"\"\"\nCodeforces Contest 281 Div 2 Problem D\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\ndef main():\n n, = read()\n if n%2:\n print(\"black\")\n else:\n print(\"white\")\n print(\"1 2\")\n\n################################### NON-SOLUTION STUFF BELOW\n\ndef read(mode=2):\n # 0: String\n # 1: List of strings\n # 2: List of integers\n inputs = input().strip()\n if mode == 0: return inputs\n if mode == 1: return inputs.split()\n if mode == 2: return list(map(int, inputs.split()))\n\ndef write(s=\"\\n\"):\n if s is None: s = \"\"\n if isinstance(s, list): s = \" \".join(map(str, s))\n s = str(s)\n print(s, end=\"\")\n\nwrite(main())"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print(\"white\")\n print(\"1 2\")\nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"white\\n1 2\") \nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"white\")\n print(1,2)\nelse :\n print(\"black\")"}, {"source_code": "n =int (input())\nif n%2==0:\n print (\"white\\n1 2\")\nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n%2==0 :\n print(\"white\")\n print(\"1 2\")\nelse :\n print(\"black\")\n \n"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 14.03.2020\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[1] \ndef sort2(l):return sorted(l, key=getKey,reverse=True)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(n-r))\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\ndef main():\n \n\n #for _ in range(ii()):\n \n\n n=ii()\n if n%2:\n print('black')\n else:\n print('white')\n print(1,2)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n \n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "'''\nCreated on \u0660\u0665\u200f/\u0661\u0662\u200f/\u0662\u0660\u0661\u0664\n\n@author: mohamed265\n''' \nprint(\"black\") if int(input()) % 2 == 1 else print(\"white\\n1 2\")"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(2*10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\n#if n is odd, black wins by playing symmetrically to white\n#if n is even..white goes to 1,2 and then \n#game is same as if white was black and wins\nn=input()\nif n%2==1:\n print \"black\"\nelse:\n print \"white\"\n print \"1 2\""}, {"source_code": "print(\"black\" if int(input()) % 2 else \"white\\n1 2\")"}, {"source_code": "print(\"black\"if int(input().split()[0])%2 else\"white\\n1 2\")\n"}, {"source_code": "from math import ceil, log, floor, sqrt\nimport math\t\n\t\n\t\nk = 1\t\ndef mod_expo(n, p, m):\n\t\"\"\"find (n^p)%m\"\"\"\n\tresult = 1\n\twhile p != 0:\n\t\tif p%2 == 1:\n\t\t\tresult = (result * n)%m\n\t\tp //= 2\n\t\tn = (n * n)%m\n\treturn result\n\t\ndef min_subs(n, binary):\n\ta, b = 1, 1\n\tmx = 0\n\tprev = not int(binary[0])\n\tres = [0] * n\n\tfor i in range(n):\n\t\tif int(binary[i]) == 1:\n\t\t\t#b = 1\n\t\t\tif int(binary[i]) == prev:\n\t\t\t\ta += 1\n\t\t\t\tb = a\n\t\t\tres[i] = a\n\t\telse:\n\t\t\t#a = 1\n\t\t\tif int(binary[i]) == prev:\n\t\t\t\tb += 1\n\t\t\t\ta = b\n\t\t\tres[i] = b\t\n\t\t\t\n\t\t\t\n\t\tprev = int(binary[i])\n\t\t\n\t\tmx = max(mx, max(a, b))\n\tprint(mx)\n\tprint(*res, sep=' ')\n\t#return 1 + (n- las)\n\ndef steps(n):\n\treturn n//2 + 1\n\t\n\t\ndef find_winner(n):\n\tif n%2:\n\t\tprint(\"black\")\n\telse:\n\t\tprint(\"white\")\n\t\tprint(\"1 2\")\n\t\ndef can_palindrome(r, g, b, w):\n\tno = 0\n\tmn = pow(10, 9) + 1\n\tmn = min(mn, r)\n\tmn = min(mn, g)\n\tmn = min(mn, b)\n\tif r%2 == 1:\n\t\tno += 1\n\tif g%2 == 1:\n\t\tno += 1\n\tif b%2 == 1:\n\t\tno += 1\n\tif w%2 == 1:\n\t\tno += 1\n\tif no <= 1:\n\t\treturn True\n\tif no == 3 and mn > 0:\n\t\treturn True\n\treturn False\ndef max_find(n, k, z, a):\n\tres = 0\n\ts = 0\n\tmx = 0\n\tfor t in range(z+1):\n\t\tpos = k -2*t\n\t\tif pos < 0:\n\t\t\tcontinue\n\t\tmx = 0\n\t\ts = 0\n\t\tfor i in range(pos + 1):\n\t\t\tif i < n-1:\n\t\t\t\tmx = max(mx, a[i] + a[i+1])\n\t\t\ts += a[i]\n\t\tres = max(res, s + mx*t)\n\treturn res\n\t\n\t\nt = 1\n#t = int(input())\nwhile t:\n\tt = t - 1\n\tn = int(input())\n\t#r, g, b, w = map(int, input().split())\n\t#a = input()\n\t#arr = list(map(int, input().split()))\n\t#mx = max(arr)\n\t#res = ['a' * (mx + 1)] * (n+1)\n\t#for i, x in enumerate(arr):\n\t#\twho = 'a' if res[i][x] == 'b' else 'b'\n\t#\tres[i+1] = res[i][:x] + who + res[i][x + 1:]\n\t#a = list(map(int, input().strip().split()))[:n]\n\t#if can_palindrome(r, g, b, w):\n\t#\tprint(\"YES\")\n\t#else:\n\t#\tprint(\"NO\")\n\t#n = int(n)\n\t#for i, x in enumerate(arr):\n # who = 'a' if res[i][x] == 'b' else 'b'\n # res[i + 1] = res[i][:x] + who + res[i][x + 1:]\n\t#print('\\n'.join(res))\n\tfind_winner(n)\n\t\n"}, {"source_code": "def main():\n n = int(input())\n if n%2 == 0:\n print('white')\n print(1,2)\n else:\n print('black')\n\nmain()\n"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(\"white\\n1 2\")\nelse:\n print(\"black\")\n#####\n"}, {"source_code": "n = int(input())\nif n & 1 == 0:\n print('white\\n1 2')\nelse:\n print('black')\n"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(\"white\\n1 2\")\nelse:\n print(\"black\")\n#\n"}, {"source_code": "n=int(input())\nif(n%2==0):\n print(\"white\")\n print(1,2)\nelse:\n print(\"black\")"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(\"white\\n1 2\")\nelse:\n print(\"black\")\n#######\n"}, {"source_code": "n = int (input ())\nif n%2==0 :\n print(\"white\\n1 2\")\nelse :\n print (\"black\")"}, {"source_code": "i = int(input())\n\nif i % 2 == 1:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"source_code": "def main():\n\timport sys\n\tinput = sys.stdin.readline\n\t\n\tn = int(input())\n\tif n & 1:\n\t\tprint(\"black\")\n\telse:\n\t\tprint(\"white\")\n\t\tprint(1, 2)\n\t\n\treturn 0\n\nmain()\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\nimport heapq as h \nfrom bisect import bisect_left\n\nfrom types import GeneratorType\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n import os\n self.os = os\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n self.os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \nimport time\nstart_time = time.time()\n\nimport collections as col\nimport math, string\nfrom functools import reduce\n\ndef getInts():\n return [int(s) for s in input().split()]\n\ndef getInt():\n return int(input())\n\ndef getStrs():\n return [s for s in input().split()]\n\ndef getStr():\n return input()\n\ndef listStr():\n return list(input())\n\nMOD = 10**9+7\n\n\"\"\"\nN = 2, white wins\nN is even, white wins by moving to (1,2) first\nN is odd, white loses\n\"\"\"\n\ndef solve():\n N = getInt()\n if N % 2 == 0:\n print(\"white\")\n print(1,2)\n else:\n print(\"black\")\n return\n \n#for _ in range(getInt()): \nsolve()"}, {"source_code": "from sys import stdin\n\n\n# main starts\nn = int(stdin.readline().strip())\nif n% 2 == 0:\n\tprint(\"white\")\n\tprint(1, 2)\nelse:\n\tprint(\"black\")"}, {"source_code": "user_input=int(input())\n\nif user_input%2!=0:\n print (\"black\")\nelse:\n print (\"white\")\n print (\"1 2\")"}, {"source_code": "print(\"black\"if int(input())%2else \"white\\n1 2\")"}, {"source_code": "from math import ceil\nN = int(input())\nif N%2 == 0:\n\tprint(\"white\")\n\tprint(1, 2)\nelse:\n\tprint(\"black\")"}, {"source_code": "n = int( input() )\nif n % 2:\n\tprint ( \"black\" )\nelse:\n\tprint ( \"white\\n1 2\" )"}, {"source_code": "print('black' if int(input()) % 2 else 'white\\n1 2')\n"}, {"source_code": "n = int(input())\nif n%2==0:\n print(\"white\")\n print(\"1 2\")\nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"white\")\n print(1, 2)\nelse:\n print(\"black\")"}, {"source_code": "print (\"white\\n1 2\",\"black\")[input()%2]"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\nif n % 2 == 1:\n print 'black'\nelse:\n print 'white'\n print '1 2'\n"}, {"source_code": "a = input()\nif a % 2 == 0:\n\tprint '''white\n1 2'''\nelse:\n\tprint 'black'\n"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print(\"white\")\n print(1, 2)\nelse:\n print(\"black\")"}, {"source_code": "n = int(input())\nif n%2 == 0:\n print('white')\n print(1, 2)\nelse:\n print('black')\n"}, {"source_code": "n = int(input())\nif n%2:\n\tprint('black')\nelse:\n\tprint('white')\n\tprint('1 2')"}, {"source_code": "def ri():\n return raw_input()\ndef ii():\n return map(int, ri().split())\nn, = ii()\nif n % 2 == 0:\n print \"white\"\n print \"1 2\"\nelse:\n print \"black\"\n"}, {"source_code": "n = int(raw_input())\nif n % 2:\n print \"black\"\nelse:\n print \"white\"\n print 1, 2\n"}, {"source_code": "n = int(input())\nif n%2==0:\n print(\"white\")\n print(1,2)\nelse:\n print(\"black\") "}, {"source_code": "n=input()\nif n%2==0:\n\tprint \"white\"\n\tprint 1,2\nelse:\n\tprint \"black\"\n"}, {"source_code": "\nuserInput = int(input())\n\nif userInput %2 != 0:\n print('black')\nelif userInput %2 ==0:\n print('white')\n print('1 2')"}, {"source_code": "n=int(input())\nprint(\"white\\n1 2\" if (n % 2==0) else \"black\");\n"}, {"source_code": "__author__ = 'PrimuS'\n\nn = int(input())\n\nif n % 2 == 1:\n print('black')\nelse:\n print('white')\n print(\"1 2\")"}, {"source_code": "n=int(input())\nif n%2==0:\n print('white')\n print('1 2')\nelse:\n print('black')"}, {"source_code": "n = int(raw_input())\n\nif n % 2 == 0:\n\tprint 'white\\n1 2'\nelse:\n\tprint 'black'"}, {"source_code": "n = int(input())\nif (n % 2 == 1):\n\tprint(\"black\")\nelse:\n\tprint(\"white\\n1 2\")"}, {"source_code": "if(input()%2==0):print \"white\\n1 2\"\nelse:print \"black\""}, {"source_code": "import math\nimport sys\n\ndef main():\n n = int(raw_input())\n if n % 2 == 1:\n print 'black'\n else:\n print 'white'\n print '1 2'\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a=input()\nif(a%2==0):\n\tprint \"white\"\n\tprint \"1 2\"\nelse:\n\tprint \"black\"\n"}, {"source_code": "n = int(raw_input())\nif n%2 == 0:\n print \"white\"\n print \"1\"+\" \" + \"2\"\nelse:\n print \"black\"\n"}, {"source_code": "print \"white\\n1 2\" if int(raw_input()) % 2 == 0 else \"black\""}, {"source_code": "#br = open('d.in')\nn = int(raw_input())\nprint [\"white\\n%d %d\" % (1, 2), \"black\"][n % 2]\n"}, {"source_code": "print[\"white\\n1 2\",\"black\"][input()%2]"}, {"source_code": "print 'black' if int(raw_input())%2 else 'white\\n1 2'\n"}, {"source_code": "n = input()\nif n & 1:\n\tprint 'black'\nelse:\n\tprint 'white\\n1 2'"}, {"source_code": "n = int(raw_input())\n\nif n % 2 == 0:\n print \"white\"\n print \"1 2\"\nelse:\n print \"black\"\n"}, {"source_code": "n = int(input())\n\nif n % 2 != 0:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"source_code": "print \"black\" if input()&1 else \"white\\n1 2\""}, {"source_code": "n=input()\nif n%2 == 0: print 'white\\n1 2'\nelse: print 'black'"}, {"source_code": "if input()&1==0: print \"white\\n1 2\"\nelse: print \"black\""}, {"source_code": "print \"white\\n1 2\" if int(raw_input()) % 2 is 0 else \"black\""}, {"source_code": "print (\"white\\n1 2\",\"black\")[input()%2]\n"}, {"source_code": "n = input()\nif(n&1==1):\n print \"black\"\nelse:\n print \"white\"\n print \"1 2\"\n"}, {"source_code": "a=input()\nif a%2==0:\n print \"white\"\n print \"1 2\"\nelse:\n print \"black\"\n"}, {"source_code": "if int(raw_input())%2==0:\n print \"white\"\n print 1,2\nelse:\n print \"black\""}, {"source_code": "n = input()\nif n % 2 == 0:\n print \"white\"\n print 1, 2\nelse:\n print \"black\""}, {"source_code": "print( \"white\\n1 2\" if int(input())%2==0 else \"black\" )\n"}, {"source_code": "\"\"\" \n Author: Hemanth Kumar Veeranki\n Handle:harry7\n\n\"\"\"\n#!/usr/bin/python\nprint \"black\" if input()%2 else \"white\\n 1 2\"\n"}, {"source_code": "n=input()\nif n%2==0:\n print \"white\"\n print 1,2\nelse:\n print \"black\"\n"}], "negative_code": [{"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nn = int(raw_input())\n\nif n & 1:\n print \"black\"\nelse:\n print \"white\"\n print \"2 1\"\n"}, {"source_code": "if(input()%2==0):print \"White\\n1 2\"\nelse:print \"Black\""}, {"source_code": "n = int(raw_input())\nif n%2 == 0:\n print \"white\"\n if n == 2:\n print \"1\"+\" \" + \"2\"\n else:\n print \"2\"+\" \" + \"1\"\nelse:\n print \"black\"\n"}, {"source_code": "x = input()\nif (x%2 == 0):\n\tprint \"white\"\n\tprint str(1) + \" \" + str((x/2)+1)\nelse:\n\tprint\"black\""}, {"source_code": "print \"black\" if input()&1 else \"while\\n1 2\""}, {"source_code": "n = input()\nif n%2 == 1:\n print \"white\"\n print \"1 2\"\nelse:\n print \"black\""}, {"source_code": "n = input()\nif(n&1==1):\n print \"Black\"\nelse:\n print \"White\"\n print \"1 2\"\n"}, {"source_code": "n = input()\nif n % 2 == 1:\n print \"white\"\n print 1, 2\nelse:\n print \"black\""}, {"source_code": "\"\"\" \n Author: Hemanth Kumar Veeranki\n Handle:harry7\n\n\"\"\"\n#!/usr/bin/python\nprint \"white\\n 1 2\" if input()%2 else \"black\"\n"}, {"source_code": "n = int(input())\nif n == 2:\n print('white\\n1 2')\nelse:\n print('black')\n"}, {"source_code": "n=int(input())\nif n&1:\n print(\"black\")\nelse:\n print(\"white\")\n if n>2:\n print(1,n-2)\n else:\n print(1,2)"}, {"source_code": "s = int(input())\nif s % 2 == 0 :\n print('white')\n print(*(1,2) if s==2 else(s , s//2))\nelse:\n print('black')"}, {"source_code": "n = int( input() )\nif n % 2:\n\tprint ( \"Black\" )\nelse:\n\tprint ( \"White\\n1 2\" )"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"white\")\nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"white\")\nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"White\")\n print(1,2)\nelse :\n print(\"Black\")"}, {"source_code": "n = int(input())\nif n&1:\n print('Black')\nelse:\n print('White')\n print(1,2)"}, {"source_code": "print('white\\n0 1' if int(input()) % 2 == 0 else 'black')\n"}, {"source_code": "print(\"black\"if int(input().split()[0])%2==0 else\"white\\n1 2\")\n"}, {"source_code": "from math import ceil\nN = int(input())\nif N%2 == 0:\n\tprint(\"white\")\n\tprint(N - 1, N//2 + 1)\nelse:\n\tprint(\"black\")"}, {"source_code": "def main():\n return ('white', 'black')[int(input()) & 1]\n\n\nprint(main())\n"}, {"source_code": "n=int(input())\nif n%2==0:\n print('white')\n print('1 2')\nelse:\n if n==3:\n print('black')\n else:\n print('white')\n print('2 2')"}, {"source_code": "import math\nimport sys\n\ndef main():\n n = int(raw_input())\n if n % 2 == 1:\n print 'black'\n else:\n print 'white'\n if n == 2:\n print '1 2'\n else:\n print '2 2'\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "x = int(raw_input())\nif x%2!=0:\n print \"Black\"\nelse:\n print \"white\"\n print \"1 2\"\n "}, {"source_code": "n = int(input())\nif n % 2 == 1:\n print('black')\nelif n == 2:\n print('white')\n print('1 2')\nelse:\n print('white')\n print('2 1')"}, {"source_code": "n = int(input())\nif n == 2:\n print('white')\n print('1 2')\nelse:\n print('black')"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"white\")\n if n==2:\n print(1,2)\n else:\n print(2,2)\nelse:\n print(\"black\")"}, {"source_code": "n=int(input())\nif n%2:\n print(\"black\")\nelse:\n print(\"white\")\n if n==2:\n print(\"1 2\")\n else:\n print(\"2 1\")\n"}], "src_uid": "52e07d176aa1d370788f94ee2e61df93"} {"source_code": "mod = 1000000007\ndef sum(x,y,k,add) :\n if k<add:\n \treturn 0\n up=x+add\n if up>k:\n \tup=k\n add=add+1\n return y*(((add+up)*(up-add+1)//2)%mod)%mod\ndef solve(x,y,k,add=0) :\n if x==0 or y==0:\n \treturn 0\n if x>y:\n \tx,y=y,x\n pw = 1\n while (pw*2)<=y:\n \tpw*=2\n if pw<=x:\n \treturn (sum(pw,pw,k,add)+sum(pw,x+y-pw-pw,k,add+pw)+solve(x-pw,y-pw,k,add))%mod\n else:\n \treturn (sum(pw,x,k,add)+solve(x,y-pw,k,add+pw))%mod\nq=input()\nfor i in range(0,q):\n x1,y1,x2,y2,k=map(int,raw_input().split()) \n ans=(solve(x2, y2, k)-solve(x1 - 1, y2, k)-solve(x2, y1 - 1, k)+solve(x1-1,y1-1,k))%mod\n if ans<0:\n \tans+=mod\n print ans", "positive_code": [{"source_code": "mod = 1000000007\n\ndef sum(x, y, k, add) :\n if k < add : return 0\n up = x + add\n if up > k : up = k\n add = add + 1\n return y * ( ( (add + up) * (up - add + 1) // 2 ) % mod ) % mod\n\ndef solve(x, y, k, add = 0) :\n if x == 0 or y == 0 : return 0\n if x > y :\n x, y = y, x\n pw = 1\n while (pw << 1) <= y :\n pw <<= 1\n if pw <= x :\n return ( sum(pw, pw, k, add)\\\n + sum(pw, x + y - pw - pw, k, add + pw)\\\n + solve(x - pw, y - pw, k, add) ) % mod\n else :\n return ( sum(pw, x, k, add)\\\n + solve(x, y - pw, k, add + pw) ) % mod\n\nq = int(input())\nfor i in range(0, q) :\n x1, y1, x2, y2, k = list(map(int, input().split())) \n ans = ( solve(x2, y2, k)\\\n - solve(x1 - 1, y2, k)\\\n - solve(x2, y1 - 1, k)\\\n + solve(x1 - 1, y1 - 1, k) ) % mod\n if ans < 0 : ans += mod\n print(ans)\n"}, {"source_code": "mod = 1000000007\ndef sum(x,y,k,add) :\n if k<add:return 0\n up=x+add\n if up>k:up=k\n add=add+1\n return y*(((add+up)*(up-add+1)//2)%mod)%mod\ndef solve(x,y,k,add=0) :\n if x==0 or y==0:return 0\n if x>y:x,y=y,x\n pw = 1\n while (pw<<1)<=y:pw<<=1\n if pw<=x:return (sum(pw,pw,k,add)+sum(pw,x+y-pw-pw,k,add+pw)+solve(x-pw,y-pw,k,add))%mod\n else:return (sum(pw,x,k,add)+solve(x,y-pw,k,add+pw))%mod\nq=int(input())\nfor i in range(0,q):\n x1,y1,x2,y2,k=list(map(int,input().split())) \n ans=(solve(x2, y2, k)-solve(x1 - 1, y2, k)-solve(x2, y1 - 1, k)+solve(x1-1,y1-1,k))%mod\n if ans<0:ans+=mod\n print(ans)"}], "negative_code": [], "src_uid": "1ab085026ce43810acf98cc4bf8faf26"} {"source_code": "t = input()\nn = int(input())\ns = (\"January February March April May June July August September October November December\").split()\na =[]\nfor i in s:\n a.append(i)\nfor i in range(12):\n if a[i] == t:\n g = i\n res = a[(g+n)%12]\nprint(res)\n\n", "positive_code": [{"source_code": "s='January February March April May June July August September October November December'.split()\nI=input\nt=I()\nprint(s[(s.index(t)+int(I()))%12])"}, {"source_code": "import calendar\ns=input()\nn=int(input())\narr=[]\nfor i in range(1,13):\n a=calendar.month_name[i]\n arr.append(a)\n#print(arr)\nprint(arr[(arr.index(s)+n)%12])"}, {"source_code": "month = input()\nadd = int(input())\n\nmonth_map = {'January':0,'February':1,'March':2,\n 'April':3,'May':4, 'June':5, 'July':6,\n 'August':7,'September':8,'October':9,\n 'November':10,'December':11}\n\ninv_map = dict()\nfor k,v in month_map.items():\n inv_map[v] = k\n\nresult = inv_map[(month_map[month] + add) % 12]\nprint(result)\n"}, {"source_code": "q=input()\nn=int(input())\na=[\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\nfor i in range(12):\n if a[i]==q:\n s=i\nprint(a[(s+n)%12])"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Aug 18 20:47:11 2020\n\n@author: PREET MODH\n\"\"\"\n\n\ns=input()\nk=int(input())\na=['January','February','March','April','May','June','July','August','September','October','November','December']\nind=a.index(s)+1\ni=(ind+k)%12\nprint(a[i-1])"}, {"source_code": "def main():\n L=[\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\",\n \"September\", \"October\", \"November\", \"December\"]\n s=str(input())\n x=int(input())\n pos=L.index(s)\n x= ((pos+x)%12)\n print(L[x])\n\nmain() \n"}, {"source_code": "a = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\ns = input()\ni = 0\nwhile a[i] != s:\n i += 1\nn = int(input())\nprint(a[(i + n) % 12])"}, {"source_code": "res=[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"];\ns=input();n=int(input())\nprint(res[(n+res.index(s))%12])"}, {"source_code": "str='January, February, March, April, May, June, July, August, September, October, November, December'\nlist=str.split(', ')\n#print(list[1])\nm=input()\nn=0\nfor i in range(len(list)):\n if m==list[i]:\n n=i\n break\nn2=int(input())\nn2=(n2+n)%12\nprint(list[n2])\n"}, {"source_code": "current=input()\nmonthsmore=int(input())\nmonthsmore=monthsmore%12\nfor i in range (monthsmore):\n if current==\"January\":\n current=\"February\"\n elif current==\"February\":\n current=\"March\"\n elif current==\"March\":\n current=\"April\"\n elif current==\"April\":\n current=\"May\"\n elif current==\"May\":\n current=\"June\"\n elif current==\"June\":\n current=\"July\"\n elif current==\"July\":\n current=\"August\"\n elif current==\"August\":\n current=\"September\"\n elif current==\"September\":\n current=\"October\"\n elif current==\"October\":\n current=\"November\"\n elif current==\"November\":\n current=\"December\"\n elif current==\"December\":\n current=\"January\"\nprint (current)\n"}, {"source_code": "months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n\nmonth = input()\nk = int(input())\n\nprint(months[(k + months.index(month)) % 12])\n"}, {"source_code": "a = input()\nb = int(input())\nc = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\nf = c.index(a)\nh = '-'\nif b % 12 ==0:\n print(a)\nelse:\n while h == '-':\n if b == 0:\n h = '+'\n else:\n b-=1\n if f == len(c)-1:\n f = 0\n else:\n f+=1\n print(c[f])"}, {"source_code": "a=['January','February','March','April','May','June','July','August','September','October','November','December']\nb=input()\nfound=0\nc=int(input())\nz=a.index(b)\nzz=c%12\nprint(a[(z+zz)%12])\n"}, {"source_code": "M = input()\nk = int(input())\nS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\nwhile k > 11:\n k -= 12\nl = S.index(M, 0, 12)\nif k <= (11 - l):\n print(S[l + k])\nelse:\n l -= 12\n print(S[k+l])"}, {"source_code": "cont = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November',\n 'December']\nm = input()\nn = int(input())\n\nprint(cont[(cont.index(m) + n) % 12])\n"}, {"source_code": "import calendar\nmonth = input()\ninp = int(input())\nmiesiac = dict()\nnumer_miesiaca = 0\n\nfor i in range(12):\n miesiac[i+1] = calendar.month_name[i+1]\n\nfor key, value in miesiac.items():\n if value == month:\n numer_miesiaca = int(key)\n\nliczba = (numer_miesiaca + inp) % 12\n\nif liczba == 0:\n print(\"December\")\nelse:\n print(calendar.month_name[liczba])"}, {"source_code": "def main():\n mmm = ('January', 'February', 'March', 'April', 'May', 'June', 'July',\n 'August', 'September', 'October', 'November', 'December')\n n = mmm.index(input())\n k = int(input())\n print(mmm[(n + k) % 12])\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "ar=[\"December\",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]\ns=input()\nn=int(input())\nprint(ar[((ar.index(s)+n)%12)])\n\n"}, {"source_code": "import calendar\na=input()\nb=[calendar.month_name[i]for i in range(13)][1:]\nprint(b[(int(input())+b.index(a))%12])"}, {"source_code": "a=input().strip()\nm=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\nn=int(input())\nk=m.index(a)\nk+=n\nprint(m[k%12])\n"}, {"source_code": "a , b = raw_input () , input ()\nc = ( 'January' , 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' )\nd = c . index (a)\n\nif b > 12 :\n\n e = b % 12\n e += d\n\n if e >= 12 :\n \n e -= 12\n \nelse :\n\n e = d + b\n \n if e >= 12 :\n \n e -= 12\n\nprint c [e]\n"}, {"source_code": "a=['January','February','March','April','May','June','July','August','September','October','November','December']\nb,c=raw_input(),input()\nif (b in a) and 0<=c<=100:\n d=(a.index(b)+1)+c\n if c!=0:f=a*(c*2)\n else:f=a\n print f[d-1]\n"}, {"source_code": "m=['January','February','March','April','May','June','July','August','September','October','November','December']\nprint m[(dict((m[i],i) for i in range(len(m)))[raw_input()]+input())%len(m)]\n"}, {"source_code": "month = \"January, February, March, April, May, June, July, August, September, October, November, December\".split(\", \")\nm = raw_input()\nn = int(raw_input())\nprint month[(month.index(m)+n)%12]\n"}, {"source_code": "a=[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]\nprint a[(a.index(raw_input())+input())%12]"}, {"source_code": "s = ['January', 'February', 'March', 'April', 'May', 'June',\n 'July', 'August', 'September', 'October', 'November', 'December']\na = raw_input()\nn = int(raw_input())\nprint s[(s.index(a)+n)%12]"}, {"source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\n# def baseN(num,b,numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n# return ((num == 0) and \"0\" ) or ( baseN(num // b, b).lstrip(\"0\") + numerals[num % b])\n\n# T = input()\n# St = raw_input()\nmonth = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\na = raw_input()\nb = input()\nb += month.index(a)\nprint month[b%12]\n"}, {"source_code": "#!/usr/bin/python\nimport sys\n\na = ['January', 'February', 'March', 'April', 'May', 'June', 'July', \\\n 'August', 'September', 'October', 'November', 'December']\nMaxL = len (a)\n\ns = sys.stdin.readline ().strip ()\nn = int (sys.stdin.readline ())\nfor i in range (MaxL):\n\tif s == a[i]:\n\t\tprint a[(i + n) % 12]\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nl = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\nm = raw_input()\nn = int(raw_input())\nprint l[(l.index(m)+n)%12]\n"}, {"source_code": "month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n\na = raw_input()\nb = int(raw_input())\n\nfor x in month:\n if x == a:\n break\n b += 1\n\nprint month[b % 12]\n"}, {"source_code": "m=['January','February','March','April','May','June','July','August', \n 'September','October','November','December']\ns=raw_input().strip()\nk=input()\n\nprint m[(m.index(s)+k)%12]"}, {"source_code": "m = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',\n 'September', 'October', 'November', 'December']\n\nc = m.index(raw_input())\nk = int(raw_input())\n\nprint m[(c + k) % 12]\n"}, {"source_code": "mo = ['January',\n 'February', \n 'March', \n 'April', \n 'May', \n 'June', \n 'July', \n 'August',\n 'September', \n 'October', \n 'November', \n 'December',]\n \nmon = raw_input()\nmomn = input()\nif momn > 12:\n momn = momn - (momn / 12)*12\n \ninmo = mo.index(mon)+momn\nif inmo >= 12:\n inmo =inmo - (inmo / 12)*12\nprint mo[inmo]\n \n"}, {"source_code": "from sys import stdin\n\nm = {1 : 'January', 2 : 'February', 3 : 'March', 4 : 'April', 5 : 'May',\n\t6 : 'June', 7 : 'July', 8 : 'August', 9 : 'September',\n\t10 : 'October', 11 : 'November', 12 : 'December'}\n\ndef next():\n\treturn stdin.readline().strip()\n\ndef main():\n\tmn = next()\n\tk = int(next())\n\ttm = 0\n\t\n\tfor i in range(1, len(m)):\n\t\tif mn == m[i]:\n\t\t\ttm = i\n\tif (tm + k) % 12 == 0:\n\t\tl = 12\n\telse:\n\t\tl = (tm + k) % 12\n\tprint \"%s\\n\" % m[l]\n\t\nif __name__ == \"__main__\":\n\tmain()\n"}, {"source_code": "# A \nimport sys\n\nmon = ['January', 'February', 'March', 'April', 'May', 'June', 'July',\n\t'August', 'September', 'October', 'November', 'December', \n\t'January', 'February', 'March', 'April', 'May', 'June', 'July',\n\t'August', 'September', 'October', 'November', 'December']\n\ndef main():\n\tcur = sys.stdin.readline().strip()\n\tn = int (sys.stdin.readline())\n\tn %= 12\n\tidx = mon.index (cur)\n\tprint mon[idx + n]\n\nif len (sys.argv) > 1:\n\tsys.stdin = open (sys.argv[1], 'r')\nmain()\n\n"}, {"source_code": "from datetime import datetime\nimport calendar\nprint calendar.month_name[(datetime.strptime(raw_input(), \"%B\").month - 1 + int(raw_input())) % 12 + 1]"}, {"source_code": "months=['January','February','March','April','May','June','July','August','September','October','November','December']\n\nm=input()\nk=int(input())\nq=months.index(m)\nr=(q+k)%12\nprint(months[r])\n"}, {"source_code": "arr = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\nprint arr[(arr.index(raw_input())+int(raw_input()))%12]\n\n"}, {"source_code": "s=raw_input()\nk=input()\nl=['January','February','March','April','May','June','July','August','September','October','November','December']\nprint l[(l.index(s)+k)%12]"}, {"source_code": "mon = ['January', 'February', 'March', 'April', 'May', 'June',\n 'July', 'August', 'September', 'October', 'November', 'December']\ns = raw_input()\ns = mon.index(s)\nn = input()\nprint mon[ (s + n) % 12 ]\n"}, {"source_code": "import sys\nimport Queue\nfrom sets import Set\n\nclass pythonin:\n _data = []\n _ldata = []\n _cur = 0\n _lcur = 0\n \n def __init__(self):\n while True:\n try: self._ldata.append(raw_input())\n except EOFError : break\n\n def _convert(self):\n if self._lcur == len(self._ldata) : return\n l = self._ldata[self._lcur].split(\" \")\n self._lcur += 1\n for x in l :\n if x != \"\" and x != \"\\t\" :\n self._data.append(x)\n \n def eof(self) : \n self._convert()\n return self._cur == len(self._data)\n\n def nextToken(self) :\n if self.eof() : return\n self._cur += 1\n return self._data[self._cur - 1]\n \n def nextInt(self) :\n return int(self.nextToken())\n \n def nextFloat(self) :\n return float(self.nextToken())\n \n def nextLine(self) :\n if self._lcur == len(self._ldata) : return \n self._lcur += 1\n return self._ldata[self._lcur - 1]\n \n#sys.stdin = open(\"input.txt\", \"r\")\n#sys.stdout = open(\"output.txt\", \"w\")\n\npin = pythonin()\n\nmonths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n\nmap = dict()\n\ncnt = 0\nfor m in months : \n map[m] = cnt\n cnt += 1\n\ns = pin.nextToken()\nk = pin.nextInt()\n\nprint months[(map[s] + k) % 12]\n\n#print (\"Press any key to continue\")\n#raw_input() \n"}, {"source_code": "months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\nmonth = input()\nidx = months.index(month)\ntonext = (int(input()) + idx )% 12\nprint(months[tonext])\n"}, {"source_code": "months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\ncurrent_month = input()\nk = int(input())\ncurrent_index = months.index(current_month)\nprint(months[(current_index + k) % 12])"}, {"source_code": "class CodeforcesTask45ASolution:\n def __init__(self):\n self.result = ''\n self.start_month = 0\n self.target_month = 0\n\n def read_input(self):\n self.start_month = input()\n self.target_month = int(input())\n\n def process_task(self):\n months = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n current = months.index(self.start_month) + 1\n to_go = (current + self.target_month) % 12\n if not to_go:\n to_go = 12\n self.result = months[to_go - 1]\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask45ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "l =['January', 'February', 'March', 'April', 'May', 'June', 'July','August', 'September', 'October', 'November', 'December']\ncm = input()\nk = int(input())\nx = l.index(cm)\nprint(l[(x+k)%12])\n\n\n"}, {"source_code": "d={'January': 0, 'February': 1, 'March': 2, 'April': 3, 'May': 4, 'June': 5, 'July': 6, 'August': 7, 'September': 8, 'October': 9, 'November': 10, 'December': 11}\nm=input()\nn=int(input())\nn += d[m]\nd={0:'January', 1:'February', 2:'March', 3:'April', 4:'May', 5:'June', 6:'July', 7:'August', 8:'September', 9:'October', 10:'November', 11:'December'}\nprint(d[n%12])"}, {"source_code": "m = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\ns = input()\nk = int(input())\nfor i in range(12):\n if(s==m[i]):\n print(m[(i+k)%12])\n"}, {"source_code": "s = input()\nk = int(input())\nd1 = {'January': 1, 'February': 2, 'March': 3, 'April': 4, 'May': 5, 'June': 6,\n 'July': 7, 'August': 8, 'September': 9, 'October': 10, 'November': 11, 'December': 12}\nd2 = {1: 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June',\n 7: 'July', 8: 'August', 9: 'September', 10: 'October', 11: 'November', 12: 'December'}\nif (d1[s] + k) % 12 != 0:\n print(d2[(d1[s] + k) % 12])\nelse:\n print('December')\n"}, {"source_code": "a=[\"December\",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\"]\nb=input()\nc=int(input())\nprint(a[(a.index(b)+c)%12])"}, {"source_code": "s='January February March April May June July August September October November December'.split()\nI=input\nt=I()\nprint(s[(s.index(t)+int(I()))%12])"}, {"source_code": "l=['January','February','March','April','May','June','July','August','September','October','November','December']\ns=input()\nn=int(input())\nx=0\nfor i in range(12):\n if(s==l[i]):\n x=i\nprint(l[(x+n)%12])\n"}, {"source_code": "months = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December'\n]\n\ncurrent_month = input()\nrelease_delay = int(input())\n\ncurrent_month_index = months.index(current_month)\nrelease_month_index = (current_month_index + release_delay) % 12\nprint(months[release_month_index])\n"}, {"source_code": "m = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\nx = input()\ny = int(input())\nprint(m[(m.index(x) + y) % 12])"}, {"source_code": "l = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\ns = input()\nn = int(input())\nx = l.index(s) \nprint(l[(x + n) % 12])\n"}, {"source_code": "from collections import deque\nfrom collections import OrderedDict\nimport math\n \nimport sys\nimport os\nfrom io import BytesIO\nimport threading\nimport bisect\n \n \nimport heapq\n\n#sys.stdin = open(\"F:\\PY\\\\test.txt\", \"r\")\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n\n\nMoth = [\n 'January', \n 'February', \n 'March', \n 'April', \n 'May', \n 'June', \n 'July', \n 'August', \n 'September', \n 'October', \n 'November', \n 'December',\n]\n\n#print(Moth[(10+(24%12))%12])\n#sys.exit(0)\ns = input()\nn = int(input())\nfor i in range(len(Moth)):\n if s==Moth[i]:\n print(Moth[(i+(n%12))%12])\n break;\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "m = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\ns = input()\ni = m.index(s)\nk = int(input())\nk = (k+i)%12\nprint(m[k])"}, {"source_code": "month={1:'January',2:'February',3:'March',4:'April',5:'May',6:'June',7:'July',8:'August',9:'September',10:'October',11:'November',12:'December',13:'January',14:'February',15:'March',16:'April',17:'May',18:'June',19:'July',20:'August',21:'September',22:'October',21:'November'}\ns=str(input())\nn=int(input())\nfor key,item in month.items():\n if s in item:\n n=n%12\n print(month[n+key])\n break\n"}, {"source_code": "t=['January', 'February', 'March', 'April', 'May', 'June',\n 'July', 'August', 'September', 'October', 'November', 'December']\n\n\n\n\na=input()\n\n\nprint(t[(t.index(a)+int(input()))%12])\n"}, {"source_code": "print(['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][(['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].index(input()) + int(input())) % 12])\n"}, {"source_code": "months = {\n 1: 'January',\n 2: 'February',\n 3: 'March',\n 4: 'April',\n 5: 'May',\n 6: 'June',\n 7: 'July',\n 8: 'August',\n 9: 'September',\n 10: 'October',\n 11: 'November',\n 12: 'December'\n}\n\n\ndef findKey(d, m):\n for x in d:\n if d[x] == m:\n return x\n\n\nm = input()\nnum = int(input())\ncurrentIndex = findKey(months, m)\nnum = num % 12\nnewIndex = 0\nif (currentIndex + num) != 12:\n newIndex = (currentIndex + num) % 12\nelse:\n newIndex = 12\nprint(months[newIndex])\n"}, {"source_code": "month = input()\ntime = int(input())\narr = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n\nact_time = time % 12\nindex = arr.index(month) \n\nans = index + act_time\nif ans >= 12:\n ans = ans - 12\nprint(arr[ans])"}, {"source_code": "month = str(input())\nk = int(input())\n\nm = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\nj = m.index(month)\n\nwhile k != 0:\n if j == 11:\n j = 0\n k -= 1\n else:\n j += 1\n k -= 1\nprint(m[j])"}, {"source_code": "def q45a():\n\tmonths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n\tinput_month = input()\n\tnum_months_after = int(input())\n\tcurrent_month_index = months.index(input_month)\n\toutput = months[(current_month_index + num_months_after) % len(months)]\n\tprint(output)\n\nq45a()"}, {"source_code": "n = input()\nk = int(input())\nmylist = \"January February March April May June July August September October November December\".split(\" \")\n\ntry :\n if n in mylist : \n ind = (mylist.index(n) + k) % 12\n res = mylist[ind]\n print(res)\nexcept ValueError :\n print(\"Error\")\n"}, {"source_code": "months ='January,February,March,April,May,June,July,August,September,October,November,December'.split(',')\nprint(months[(months.index(input()) + int(input()))%12])"}, {"source_code": "a=[\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\ninp=input()\nb=int(input())\n\n\nif b%12==0:\n print(inp)\nelse:\n b=b%12\n i=(a.index(inp))+1\n g=12-b\n h=i-g\n print(a[h-1])\n"}, {"source_code": "months = \"January, February, March, April, May, June, July, August, September, October, November, December\"\nmonths = months.split(\", \")\nmonth = input()\nk = int(input())\nprint(months[(months.index(month) + k) % 12])\n"}, {"source_code": "m=input()\nn=int(input())\nlist=[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]\ni=list.index(m)\nn%=12\ni+=n\ni%=12\nprint(list[i])"}, {"source_code": "a=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\ns=input()\nk=int(input())\nz=a.index(s)\nprint(a[(z+k)%12])\n"}, {"source_code": "ms='''January, February, March, April, May, June, July, August, September, October, November, December'''\nv=ms.split(', ')\ncm=input()\nn=int(input())\nt=(v.index(cm)+n)%12\nprint(v[t])"}, {"source_code": "month = ['January', 'February', 'March','April', 'May', 'June', 'July', 'August', 'September', 'October','November', 'December']\n\ncur = input()\n\nleft = int(input())\n\nind = 0\nfor i in range(12):\n\tif month[i] == cur:\n\t\tind = i\n\t\tbreak\nfor i in range(left):\n\tind += 1\n\tif ind == 12:\n\t\tind = 0\n\nprint(month[ind])\n\t\n"}, {"source_code": "dict={}\ndict[\"January\"]=0\ndict[\"February\"]=1\ndict[\"March\"]=2\ndict[\"April\"]=3\ndict[\"May\"]=4\ndict[\"June\"]=5\ndict[\"July\"]=6\ndict[\"August\"]=7\ndict[\"September\"]=8\ndict[\"October\"]=9\ndict[\"November\"]=10\ndict[\"December\"]=11\ntmp=input()\ns=int(input())\ns+=dict[tmp]\ns%=12\nfor i in dict:\n\tif(dict[i]==s):\n\t\tprint(i)\n\t\tbreak"}, {"source_code": "print([\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"][([\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"].index(input())+int(input()))%12])"}, {"source_code": "# from dust i have come, dust i will be\n\nmonth = input()\nm = int(input())\n\ns = ['January', 'February', 'March', 'April', 'May', 'June',\n 'July', 'August', 'September', 'October', 'November', 'December']\n\nmp = {}\nfor i in range(12):\n mp[s[i]] = i + 1\n\nx = (mp[month] + m) % 12\nif x == 0:\n x = 12\n\nprint(s[x - 1])\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Aug 17 17:44:59 2018\n\n@author: kartik\n\"\"\"\n\nm = str(input())\na = int(input())\n\nmonths = {'January' : 1,'February' : 2, 'March' : 3, 'April' : 4, 'May' : 5,\n 'June' : 6, 'July' : 7, 'August' : 8, 'September' : 9, 'October' : 10,\n 'November' : 11, 'December' : 12 }\nn = months[m]\n'''if m=='January':\n n=1\nelif m=='February':\n n=2\nelif m=='March':\n n=3\nelif m=='April':\n n=4\nelif m=='May':\n n=5\nelif m=='June':\n n=6\nelif m=='July':\n n=7\nelif m=='August':\n n=8\nelif m=='September':\n n=9\nelif m=='October':\n n=10\nelif m=='November':\n n=11\nelif m=='December':\n n=12'''\n\nif a%12==0:\n print(m)\nelse:\n d=a%12\n if n+d<=12:\n print(list(months.keys())[list(months.values()).index(n+d)])\n else:\n print(list(months.keys())[list(months.values()).index(n+d-12)])\n\n \n"}, {"source_code": "def codecraft(s, k):\n monthes = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October',\n 'November', 'December']\n return monthes[(monthes.index(s) + (k % 12)) % 12]\n\n\nmonth = input()\nnumber = int(input())\nprint(codecraft(month, number))\n"}, {"source_code": "ip=input()\nn=int(input())\nmonth=['January','February','March','April','May','June','July','August','September','October','November','December']\ni=month.index(ip)\nprint(month[(n-(12-i))%12])\n"}], "negative_code": [{"source_code": "m = {1:\"January\", 2:\"February\", 3:\"March\", 4:\"April\", 5:\"May\", 6:\"June\", 7:\"July\", 8:\"August\", 9:\"September\", 10:\"October\",11 :\"November\", 12:\"December\"}\nim = {v: k for k, v in m.items()}\nn = input(\"\")\nl = int(input(\"\"))\nif (im[n] + l) % 12 != 0:\n print(m[(im[n] + l) % 12])\nelse:\n print(n)"}, {"source_code": "n = input()\nk = int(input())\nmylist = \"None January February March April May June July August September October November December\".split(\" \")\n\ntry :\n if n in mylist : \n ind = (mylist.index(n) + k) % 12\n res = mylist[ind]\n print(res)\nexcept ValueError :\n print(\"Error\")\n"}, {"source_code": "a=[\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\ninp=input()\nb=int(input())\n\nif b%12==0:\n print(inp)\nelif(b<12):\n i=(a.index(inp))+1\n g=12-b\n h=i-g\n print(a[h-1])\n"}, {"source_code": "dict={}\ndict[\"January\"]=1\ndict[\"February\"]=2\ndict[\"March\"]=3\ndict[\"April\"]=4\ndict[\"May\"]=5\ndict[\"June\"]=6\ndict[\"July\"]=7\ndict[\"August\"]=8\ndict[\"September\"]=9\ndict[\"October\"]=10\ndict[\"November\"]=11\ndict[\"December\"]=12\ntmp=input()\ns=int(input())\ns+=dict[tmp]\ns%=12\nfor i in dict:\n\tif(dict[i]==s):\n\t\tprint(i)\n\t\tbreak"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat May 23 16:28:35 2020\n\n@author: Ritvik Agarwal\n\"\"\"\n\nmon = [\"Months\", \"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n\nm = input()\ni = int(input())\n\nn = mon.index(m)\ni = (n+i) % 12\n\nprint(mon[i])\n\n"}, {"source_code": "current=input()\nmonthsmore=int(input())\nmonthsmore=monthsmore%12\nfor i in range (monthsmore):\n if current==\"January\":\n current=\"February\"\n elif current==\"February\":\n current=\"March\"\n elif current==\"March\":\n current=\"April\"\n elif current==\"May\":\n current=\"June\"\n elif current==\"June\":\n current=\"July\"\n elif current==\"July\":\n current=\"August\"\n elif current==\"August\":\n current=\"September\"\n elif current==\"September\":\n current=\"October\"\n elif current==\"October\":\n current=\"November\"\n elif current==\"November\":\n current=\"December\"\n elif current==\"December\":\n current=\"January\"\nprint (current)"}, {"source_code": "mstr = input()\nmint = 0\nk = int(input())\nif mstr == 'January':\n mint = 1\nelif mstr == 'February':\n mint = 2\nelif mstr == 'March':\n mint = 3\nelif mstr == 'April':\n mint = 4\nelif mstr == 'May':\n mint = 5\nelif mstr == 'June':\n mint = 6\nelif mstr == 'July':\n mint = 7\nelif mstr == 'August':\n mint = 8\nelif mstr == 'September':\n mint = 9\nelif mstr == 'October':\n mint = 10\nelif mstr == 'November':\n mint = 11\nelif mstr == 'December':\n mint = 12 \nmint += k\nmint = mint % 12\nif mint == 1:\n print('January')\nif mint == 2:\n print('February')\nif mint == 3:\n print('March')\nif mint == 4:\n print('April')\nif mint == 5:\n print('May')\nif mint == 6:\n print('June')\nif mint == 7:\n print('July')\nif mint == 8:\n print('August')\nif mint == 9:\n print('September')\nif mint == 10:\n print('October')\nif mint == 11:\n print('November')\nif mint == 12:\n print('December')"}, {"source_code": "mstr = input()\nmint = 0\nk = int(input())\nif mstr == 'January':\n mint = 1\nelif mstr == 'February':\n mint = 2\nelif mstr == 'March':\n mint = 3\nelif mstr == 'April':\n mint = 4\nelif mstr == 'May':\n mint = 5\nelif mstr == 'June':\n mint = 6\nelif mstr == 'July':\n mint = 7\nelif mstr == 'August':\n mint = 8\nelif mstr == 'September':\n mint = 9\nelif mstr == 'October':\n mint = 10\nelif mstr == 'November':\n mint = 11\nelif mstr == 'December':\n mint = 12 \n \n \nmint += k\nmint = mint % 12\n\n\nif mint == 1:\n print('January')\nif mint == 2:\n print('February')\nif mint == 3:\n print('March')\nif mint == 4:\n print('April')\nif mint == 5:\n print('May')\nif mint == 6:\n print('June')\nif mint == 7:\n print('July')\nif mint == 8:\n print('August')\nif mint == 9:\n print('September')\nif mint == 10:\n print('October')\nif mint == 11:\n print('November')\nif mint == 12:\n print('December')"}, {"source_code": "mstr = input()\nmint = 0\nk = int(input())\nif mstr == 'January':\n mint = 1\nelif mstr == 'February':\n mint = 2\nelif mstr == 'March':\n mint = 3\nelif mstr == 'April':\n mint = 4\nelif mstr == 'May':\n mint = 5\nelif mstr == 'June':\n mint = 6\nelif mstr == 'July':\n mint = 7\nelif mstr == 'August':\n mint = 8\nelif mstr == 'September':\n mint = 9\nelif mstr == 'October':\n mint = 10\nelif mstr == 'November':\n mint = 11\nelif mstr == 'December':\n mint = 12 \nmint += k\nz = mint % 12\nif z == 1:\n print('January')\nelif z == 2:\n print('February')\nelif z == 3:\n print('March')\nelif z == 4:\n print('April')\nelif z == 5:\n print('May')\nelif z == 6:\n print('June')\nelif z == 7:\n print('July')\nelif z == 8:\n print('August')\nelif z == 9:\n print('September')\nelif z == 10:\n print('October')\nelif z == 11:\n print('November')\nelif z == 12:\n print('December')"}, {"source_code": "import calendar\nmonth = input()\ninp = int(input())\nmiesiac = dict()\nnumer_miesiaca = 0\n\nfor i in range(12):\n miesiac[i+1] = calendar.month_name[i+1]\n\nfor key, value in miesiac.items():\n if value == month:\n numer_miesiaca = int(key)\n\nliczba = (numer_miesiaca + inp) % 12\n\nprint(calendar.month_name[liczba])"}, {"source_code": "l=[1,\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]\ns=input()\nn=int(input())\nx=l.index(s)\nprint(l[(x+n)%12])\n"}, {"source_code": "import calendar\na=input()\nb=[calendar.month_name[i]for i in range(12)]\nprint(b[(int(input())+b.index(a))%12])"}, {"source_code": "#coding: utf-8\ndef main():\n table = {\n \"January\":0, \"Feburary\":1, \"March\":2,\n \"April\" :3, \"May\" :4, \"June\" :5,\n \"July\" :6, \"August\" :7, \"September\":8,\n \"October\":9,\"November\":10,\"December\":11\n }\n m = (table[raw_input()]+input()) % 12\n print dict([[j,i] for i,j in table.items()])[m]\nmain()\n"}, {"source_code": "month = raw_input('')\nif month == 'January':\n number=1\nif month == 'February':\n number=2\nif month == 'March':\n number=3\nif month == 'April':\n number=4\nif month == 'May':\n number=5\nif month == 'June':\n number=6\nif month == 'July':\n number=7\nif month == 'August':\n number=8\nif month == 'September':\n number=9\nif month == 'October':\n number=10\nif month == 'November':\n number=11\nif month == 'December':\n number=12\n\nnext = input('')\nnumber+=next\nnumber = number%12\n\nif number==1:\n print 'January'\nif number==2:\n print 'February'\n\nif number==3:\n print 'March'\n\nif number==4:\n print 'April'\n\nif number==5:\n print 'May'\n\nif number==6:\n print 'June'\n\nif number==7:\n print 'July'\n\nif number==8:\n print 'August'\n\nif number==9:\n print 'September'\n\nif number==10:\n print 'October'\n\nif number==11:\n print 'November'\n\nif number==12:\n print 'December'\n"}, {"source_code": "dc={'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6, 'July':7, 'August':8, 'September':9, 'October':10, 'November':11, 'December':0}\ns=input()\nx=int(input())\nj=(dc[s]+x)%12\nprint(j)\nfor n in dc:\n if dc[n]==j:\n print(n)\n break\n\n"}, {"source_code": "dc={'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6, 'July':7, 'August':8, 'September':9, 'October':10, 'November':11, 'December':12}\ns=input()\nx=int(input())\nj=(dc[s]+x)%12\nfor n in dc:\n if dc[n]==j:\n print(n)\n break\n\n"}, {"source_code": "from sys import stdin\n\nm = {1 : 'January', 2 : 'February', 3 : 'March', 4 : 'April', 5 : 'May',\n\t6 : 'June', 7 : 'July', 8 : 'August', 9 : 'September',\n\t10 : 'October', 11 : 'November', 12 : 'December'}\n\ndef next():\n\treturn stdin.readline().strip()\n\ndef main():\n\tmn = next()\n\tk = int(next())\n\ttm = 0\n\t\n\tfor i in range(1, len(m)):\n\t\tif mn == m[i]:\n\t\t\ttm = i\n\tif (tm + k) % 12 == 0:\n\t\tl = 1\n\telse:\n\t\tl = (tm + k) % 12\n\tprint \"%s\\n\" % m[l]\n\t\nif __name__ == \"__main__\":\n\tmain()\n"}], "src_uid": "a307b402b20554ce177a73db07170691"} {"source_code": "R=lambda:map(float,raw_input().split())\na,b,c,d=R()\nF=lambda p,t:max(3.0*p*.1,p-p/250.0*t)\nx=F(a,c)\ny=F(b,d)\nif(x>y): print 'Misha'\nelif (x<y): print 'Vasya'\nelse: print 'Tie'", "positive_code": [{"source_code": "a, b, c, d = map(int, raw_input().split())\n\nMisha = max( 3 * a /10, a - a * c /250)\nVasya = max( 3 * b /10, b - b * d /250)\n\nif Misha > Vasya:\n print 'Misha'\nelif Misha < Vasya:\n print 'Vasya'\nelse:\n print 'Tie'\n \n"}, {"source_code": "p=input().split()\na=int(p[0])\nb=int(p[1])\nc=int(p[2])\nd=int(p[3])\nx=max((3*a)//10,a-(a//250)*c)\ny=max((3*b)//10,b-(b//250)*d)\nif(x>y):\n print(\"Misha\")\nelif(y>x):\n print(\"Vasya\")\nelse:\n print(\"Tie\")\n"}, {"source_code": "a,b,c,d=map(int,input().split())\n\nm=max(3*a/10,a-a/250*c)\nv=max(3*b/10,b-b/250*d)\n\nif m>v:print('Misha')\nelif v>m:print('Vasya')\nelse:print('Tie')\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\ns1=max(3*(a)/10,a-(a/250)*c)\ns2=max(3*(b)/10,b-(b/250)*d)\nif s1>s2:\n print \"Misha\"\nelif s2>s1:\n print \"Vasya\"\nelse:\n print \"Tie\""}, {"source_code": "a,b,c,d = map(int,input().split())\nmisha = max((3*a)//10, a - (a//250)*c)\nvasya = max((3*b)//10, b - (b//250)*d)\nif vasya > misha:\n print(\"Vasya\")\nelif misha > vasya:\n print(\"Misha\")\nelse:\n print(\"Tie\")"}, {"source_code": "import sys\n\ndef score(points, time):\n return max(float(3 * points) / 10, points - float(points)/250 * time)\n\na, b, c, d = [int(x) for x in sys.stdin.readline().split()]\n\nmisha_score, vasya_score = score(a, c), score(b, d)\nif misha_score > vasya_score:\n print(\"Misha\")\nif misha_score == vasya_score:\n print(\"Tie\")\nif misha_score < vasya_score:\n print(\"Vasya\")\n"}, {"source_code": "def ret_input():\n data = [int(x) for x in raw_input().split()]\n return data\n\ndef score(cost,time):\n return max(3*cost/10,cost-(cost/250)*time)\n\ndef contest(data):\n misha_cost = data[0]\n vasya_cost = data[1]\n misha_time = data[2]\n vasya_time = data[3]\n misha_points = score(misha_cost,misha_time)\n vasya_points = score(vasya_cost, vasya_time)\n if misha_points > vasya_points:\n return 'Misha'\n elif vasya_points > misha_points:\n return 'Vasya'\n else:\n return 'Tie'\n\ndef main():\n data = ret_input()\n print contest(data)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "yo=list(map(int,input().split()))\na=yo[0]\nb=yo[1]\nc=yo[2]\nd=yo[3]\nscore1=max(0.3*a,a-0.004*a*c)\nscore2=max(0.3*b,b-0.004*b*d)\nif score1>score2:\n\tprint('Misha')\nelif score2>score1:\n\tprint('Vasya')\nelse:\n\tprint('Tie')\t\t"}, {"source_code": "import sys\n\na,b,c,d = map(int,sys.stdin.readline().split())\nif 3*a/10 > a-a*c/250:\n misha = 3*a/10\nelse:\n misha = a-a*c/250\nif 3*b/10 > b-b*d/250:\n vasya = 3*b/10\nelse:\n vasya = b-b*d/250\nif misha>vasya:\n print 'Misha'\nelif vasya>misha:\n print 'Vasya'\nelse:\n print 'Tie'\n"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\nM = max(3*a/10, a - a*c/250)\nV = max(3*b/10, b - b*d/250)\nif M > V:\n print 'Misha'\nelif M < V:\n print 'Vasya'\nelse:\n print 'Tie'\n"}, {"source_code": "a,b,c,d = map(int,input().split())\nt = max(3*a//10,a-a//250*c)\nt1 = max(3*b//10,b-b//250*d)\nif t > t1:\n\tprint(\"Misha\")\nelif t1 > t:\n\tprint(\"Vasya\")\nelse:\n\tprint(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\np1=max(3*a//10, a-(a/250)*c)\np2=max(3*b//10, b-(b/250)*d)\nif p1>p2:\n print(\"Misha\")\nelif p2>p1:\n print(\"Vasya\")\nelse :\n print(\"Tie\")"}, {"source_code": "\ndef score(p, t):\n return max(3*p/10, p-p/250*t)\n\ndef findRes(a, b):\n if a < b:\n return 'Vasya'\n elif a > b:\n return 'Misha'\n else:\n return 'Tie'\n\na, b, c, d = map(int, raw_input().split(' '))\n\nprint findRes(score(a, c), score(b, d))\n"}, {"source_code": "a,b,c,d = map(int,input().split())\n\nmisha_1 = (3*a)/10\nmisha_2 = a - ((a/250)*c)\n\nmisha_max = max(misha_1,misha_2)\n\nvasya_1 = (3*b)/10\nvasya_2 = b - ((b/250)*d)\n\nvasya_max = max(vasya_1,vasya_2)\n\nif misha_max > vasya_max:\n print(\"Misha\")\nelif misha_max<vasya_max:\n print(\"Vasya\")\nelse:\n print(\"Tie\")\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nx=max(3*a/10,a-((a/250)*c))\ny=max(3*b/10,b-((b/250)*d))\nif x>y:\n print \"Misha\"\nif y>x:\n print \"Vasya\"\nif y==x:\n print \"Tie\"\n"}, {"source_code": "a,b,c,d =[int(q) for q in raw_input().split(' ')]\n\ns= 3*a/10 \ns2= a-(a/250)*c\ns3= 3*b/10 \ns4= b-(b/250)*d\nans1=max(s,s2)\nans2=max(s3,s4)\n\n\nif ans1>ans2:\n\tprint 'Misha'\nelif ans1==ans2:\n\tprint 'Tie'\nelse:\n\tprint 'Vasya'\n"}, {"source_code": "a,b,c,d = [int(item) for item in input().split()]\nx = max(3*a/10 , (a-(a*c/250)))\ny = max(3*b/10 , (b-(b*d/250)))\n\nif x>y:\n print(\"Misha\")\nelif x<y:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "#!/usr/bin/python\nfrom __future__ import division\nfrom sys import stdin, stdout\n\nA, B, C, D = map (int, stdin.readline ().split ())\nscore1 = max (3 * A // 10, A - C * A // 250)\nscore2 = max (3 * B // 10, B - D * B // 250)\n\nif score1 > score2:\n\tprint 'Misha'\nelif score1 < score2:\n\tprint 'Vasya'\nelse:\n\tprint 'Tie'"}, {"source_code": "def points(p, t):\n\treturn max(3 * p // 10, p - p // 250 * t)\n\na, b, c, d = map(int, input().split())\n\nn = points(a, c)\nm = points(b, d)\n\nif n > m:\n\tprint(\"Misha\")\nelif m > n:\n\tprint(\"Vasya\")\nelse:\n\tprint(\"Tie\")\n"}, {"source_code": "import sys, itertools, math\n\ndef ia():\n return [int(i) for i in sys.stdin.readline().strip().split(\" \")]\n\ndef ii():\n return int(sys.stdin.readline().strip())\n\n###\n\na, b, c, d = ia()\n\ndef score(p, t):\n return max(3*p/10, p - (p/250)*t)\n\nif score(a, c) > score(b, d):\n print(\"Misha\")\nelif score(a, c) < score(b, d):\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a, b, c, d = map(int, input().split())\nscore1 = max(3 * a // 10, a - a * c // 250)\nscore2 = max(3 * b // 10, b - b * d // 250)\nif score1 > score2:\n print('Misha')\nelif score1 < score2:\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a , b , c , d = map(int,input().split())\nm = max(3*a/10,a-a/250*c)\nv = max(3*b/10,b-b/250*d)\nif m > v : print(\"Misha\")\nelif v > m : print(\"Vasya\")\nelse : print(\"Tie\")\n"}, {"source_code": "p1,p2,t1,t2=list(map(int,input().split()))\na=max((3*p1)/10,(p1-(p1/250)*t1))\nb=max((3*p2)/10,(p2-(p2/250)*t2))\n#print(a,b)\nif(a>b):\n print(\"Misha\")\nelif(a<b):\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nval = max((3*a)/10, a - (a*c)/250)\nval1 = max((3*b)/10, b - (b*d)/250)\nif val > val1 : print \"Misha\"\nelif val1 > val : print \"Vasya\"\nelse : print \"Tie\"\n"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nmisha = max(3.0*a/10.0,a-a/250.0*c)\nvasya = max(3.0*b/10.0,b-b/250.0*d)\nif misha > vasya:\n print \"Misha\"\nelif misha < vasya:\n print \"Vasya\"\nelse:\n print \"Tie\""}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nf=lambda p,t:max(3*p/10,p-p*t/250)\nm,v = f(a,c), f(b,d)\nif m>v:\n\tprint \"Misha\"\nelif v>m:\n\tprint \"Vasya\"\nelse:\n\tprint \"Tie\""}, {"source_code": "# your code goes here\nfrom sys import stdin\nar=map(float, stdin.readline().strip().split())\na=ar[0]\nb=ar[1]\nc=ar[2]\nd=ar[3]\n\nx=max(3*a/10, a-(a/250)*c)\ny=max(3*b/10, b-(b/250)*d)\nif x>y:\n print 'Misha'\nelif x==y:\n print 'Tie'\nelse:\n print 'Vasya'"}, {"source_code": "#-*-coding:utf8;-*-\n#qpy:3\n#qpy:console\n\na,b,c,d=map(int,input().split(' '))\nm=int(a*max([3/10,1-c/250]))\nv=int(b*max([3/10,1-d/250]))\nif m>v:\n print('Misha')\nelif v>m:\n print('Vasya')\nelif v==m:\n print('Tie')"}, {"source_code": "a,b,c,d = map(int,input().split())\n\nac = max((3*a)//10,a-(a//250)*c)\nbd = max((3*b)//10,b-(b//250)*d)\n\nif ac>bd:\n print(\"Misha\")\nelif ac<bd:\n print(\"Vasya\")\nelse:\n print(\"Tie\")\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nt1=max((3*a)/10,a-(a*c)/250)\nt2=max((3*b)/10,b-(b*d)/250)\nif t1>t2:\n print \"Misha\"\nelif t1<t2:\n print \"Vasya\"\nelse:\n print \"Tie\"\n"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\ns1 = max(3*a/10,a-a/250*c)\ns2 = max(3*b/10,b-b/250*d)\nprint ['Misha','Vasya','Tie'][[s1>s2,s1<s2,s1==s2].index(True)]"}, {"source_code": "def point(p,t):\n if (p%250 == 0):\n score1 = 3*p/10\n score2 = p - p*t/250\n score=max(score1,score2)\n return score\n else:\n return False\n\ndef Convert(string): \n li = list(string.split(\" \")) \n return li\n\nscores = input()\nList=Convert(scores)\nList= list(map(int, List)) \na = List[0]\nb = List[1]\nc = List[2]\nd = List[3]\nMisha = point(a,c)\nVasya = point(b,d)\nif (a<=3500 and a>= 250 and b<=3500 and b>= 250 and c<=180 and c>= 0 and d<=180 and d>= 0):\n if (Misha>Vasya):\n print(\"Misha\")\n elif (Misha<Vasya):\n print(\"Vasya\")\n else:\n print(\"Tie\")\n"}, {"source_code": "def maxx(x, y):\n if x > y:\n return x\n else:\n return y\nsize = str(input()).split(\" \")\na = int(size[0])\nb = int(size[1])\nc = int(size[2])\nd = int(size[3])\ns1 = maxx(3 * a / 10, a - a / 250 * c)\ns2 = maxx(3 * b / 10, b - b / 250 * d)\nif s1 > s2:\n print('Misha')\nelif s1 < s2:\n print('Vasya')\nelse:\n print('Tie')\n"}, {"source_code": "def poiCal(p,t):\n return max(3*p/10,p-(p*t/250))\na,b,c,d=map(int,raw_input().strip().split())\nif poiCal(a,c)>poiCal(b,d):print \"Misha\"\nelif poiCal(a,c)<poiCal(b,d):print \"Vasya\"\nelse :print \"Tie\""}, {"source_code": "\n*a, = map(int,input().split())\nMisha,Vasya = max(3*a[0]//10, a[0] - (a[0]//250)*a[2]),max(3*a[1]//10, a[1] - (a[1]//250)*a[3])\nprint(\"Vasya\" if Vasya > Misha else \"Misha\" if Misha > Vasya else \"Tie\")\n\n\n"}, {"source_code": "inputs=raw_input().split()\n\na=int(inputs[0])\nb=int(inputs[1])\nc=int(inputs[2])\nd=int(inputs[3])\n\nmisha_score=max(((3*a)/10),(a-(a*c/250)))\nvasya_score=max(((3*b)/10),(b-(b*d/250)))\n\nif misha_score>vasya_score:\n print 'Misha'\nelif vasya_score>misha_score:\n print 'Vasya'\nelse:\n print 'Tie'\n"}, {"source_code": "def score(p,t):\n return max(int((3*p)/10),(p-(int(p/250)*t)))\na,b,c,d=map(int,input().split())\ns1=score(a,c)\ns2=score(b,d)\nif(s1==s2):\n print(\"Tie\")\nelif(s1>s2):\n print(\"Misha\")\nelse:\n print(\"Vasya\")\n"}, {"source_code": "r = raw_input()\nl = r.split(' ')\na = float(l[0])\nb = float(l[1])\nc = int(l[2])\nd = int(l[3])\np = max([(3*a/10),(a-(a/250*c))])\nq = max([(3*b/10),(b-(b/250*d))])\nif p>q:\n\tprint 'Misha'\nelif q>p:\n\tprint 'Vasya'\nelse:\n\tprint 'Tie'"}, {"source_code": "a, b, c, d = map(int, input().split())\nm = max((3 * a) / 10, a - (a / 250) * c)\nv = max((3 * b) / 10, b - (b / 250) * d)\nif m > v:\n print(\"Misha\")\nelif v > m:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nmisha = max((3*a)/10 , a - (a/250)*c)\nvasya = max((3*b)/10 , b - (b/250)*d)\nif(misha > vasya):\n\tprint \"Misha\"\nelif(misha < vasya):\n\tprint \"Vasya\"\nelse:\n\tprint \"Tie\"\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nr1=max(3*a/10,a-(a/250*c))\nr2=max(3*b/10,b-(b/250*d))\nif(r1>r2):\n print('Misha')\nelif(r1<r2):\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a,b,c,d=map(int,input().split())\nz=max(0.3*a,a-(a*c)/250)\nx=max(0.3*b,b-(b*d)/250)\nif x==z:\n\tprint(\"Tie\")\nelif max(z,x)==z:\n\tprint(\"Misha\")\nelif max(z,x)==x:\n\tprint(\"Vasya\")\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nmx_m=max(3*a//10,a-(a//250)*c)\nmx_v=max(3*b//10,b-(b//250)*d)\nif mx_m==mx_v:\n print(\"Tie\")\nelif mx_m>mx_v:\n print(\"Misha\")\nelse:\n print(\"Vasya\")"}, {"source_code": "str = raw_input()\ninp = str.split(' ')\n\na = int(inp[0])\nb = int(inp[1])\nc = int(inp[2])\nd = int(inp[3])\n\nmisha = max((a*3)/10, a-a/250*c)\nvasya = max((b*3)/10, b-b/250*d)\n\nif misha == vasya:\n\tprint 'Tie'\nelif misha > vasya:\n\tprint 'Misha'\nelse:\n\tprint 'Vasya'"}, {"source_code": "a,b,c,d=map(int,input().split())\nm=int(max((3*a)/10,a-(a*c)/250))\nv=int(max((3*b)/10,b-(b*d)/250))\nprint('Vasya' if v>m else 'Misha' if m>v else 'Tie')"}, {"source_code": "score = (lambda p, t: max(75 * p, (250 - t) * p))\na, b, c, d = map(int, input().split())\nprint('Misha' if score(a, c) > score(b, d) else 'Vasya' if score(a, c) < score(b, d) else 'Tie')"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\nm = max(3 * a / 10, a - (a / 250) * c)\nv = max(3 * b / 10, b - (b / 250) * d)\nif m > v: print \"Misha\"\nelif m < v: print \"Vasya\"\nelse: print \"Tie\"\n"}, {"source_code": "def getpoint(p,t):\n return max(3*p/10,p-p/250*t)\n\n\na,b,c,d=map(int,input().split())\na = getpoint(a,c)\nb = getpoint(b,d);\nif a > b:\n print(\"Misha\")\nelif a < b:\n print(\"Vasya\")\nelse:\n print(\"Tie\")\n"}, {"source_code": "def getpoint(p,t):\n return max(3*p/10,p-p/250*t)\na,b,c,d=map(int,input().split())\na = getpoint(a,c)\nb = getpoint(b,d);\nif a > b:\n print(\"Misha\")\nelif a < b:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nd=int(d)\ne=max(3*a/10,a-(a/250)*c)\nf=max(3*b/10,b-(b/250)*d)\nif(e>f):\n print(\"Misha\")\nelif(f>e):\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\np=max((3*a)//10,a-(a//250)*c)\nq=max((3*b)//10,b-(b//250)*d)\nif(p>q):\n print('Misha')\nelif(p<q):\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a, b, c, d = map(int, input().split())\nma = max((3*a)//10, a-(a*c)//250)\nmb = max((3*b)//10, b-(b*d)//250)\nif ma == mb:\n print(\"Tie\")\nelif ma > mb:\n print(\"Misha\")\nelse:\n print(\"Vasya\")"}, {"source_code": "p1,p2,t1,t2=map(int,raw_input().split())\nm=max((3*p1)/10,p1-(p1/250)*t1)\nv=max((3*p2)/10,p2-(p2/250)*t2)\nif m>v:\n\tprint 'Misha'\nelif m<v:\n\tprint 'Vasya'\nelse:\n\tprint 'Tie'"}, {"source_code": "data = input().split()\n\nA, B, C, D = int(data[0]), int(data[1]), int(data[2]), int(data[3])\n\nmisha_scores = max((3*A)/10, A - (A/250) * C)\nvasya_scores = max((3*B)/10, B - (B/250) * D)\n\nif misha_scores > vasya_scores:\n print('Misha')\nelif misha_scores < vasya_scores:\n print('Vasya')\nelse:\n print('Tie')\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nif max(3*a/10,a-a/250*c) < max(3*b/10,b-b/250*d):\n\tprint \"Vasya\"\nelif max(3*a/10,a-a/250*c) > max(3*b/10,b-b/250*d):\n\tprint \"Misha\"\nelse:\n\tprint \"Tie\""}, {"source_code": "#{a = input().split(' ')\n#for i in range(len(a)):\n # a[i] = int(a[i])\n#z=max(3*A[0]/10, A[0]-A[0]/250*A[2])\n#h=max(3*A[1]/10, A[1]-A[1]/250*A[3])\n#if z == h:\n# print('Tie')\n#if z < h:\n# print('Vasya')\n#else:\n# print('Mish')\n#print(a)}\n#print('('+a[1]+')')\na=list(map(int,input().split()))\nm=max(((3*a[0])/10),(a[0]-(a[0]/250*a[2])))\nv=max(((3*a[1])/10),(a[1]-(a[1]/250*a[3])))\nprint('Tie' if v==m else('Misha' if m>v else 'Vasya'))\n"}, {"source_code": "'''input\n750 1000 54 103\n'''\ndef getScore(p,t):\n\tp=int(p)\n\tt=int(t)\n\treturn max((3*p) / 10, p - ((p/250) * t) )\n\ndef findWinner(inputString):\n\tvarArray=inputString.split()\n\tif(getScore(varArray[0],varArray[2]) < getScore(varArray[1],varArray[3])):\n\t\treturn \"Vasya\"\n\telif(getScore(varArray[0],varArray[2]) > getScore(varArray[1],varArray[3])):\n\t\treturn \"Misha\"\n\telse: return \"Tie\"\n\nprint(findWinner(raw_input()))"}, {"source_code": "a, b, c, d = map(int, input().split(' '))\nx = int(max(3*a/10, a-a*c/250))\ny = int(max(3*b/10, b - b*d/250))\n\nif x == y:\n print(\"Tie\")\nif x < y:\n print(\"Vasya\")\nif x > y:\n print(\"Misha\")"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\n\ndef f(p, t):\n return max((3*p) / 10.0, p - p / (250.0) * t)\n\nif f(a, c) > f(b, d):\n print \"Misha\"\nelif f(a, c) == f(b, d):\n print \"Tie\"\nelse:\n print \"Vasya\""}, {"source_code": "# -*- coding: utf-8 -*-\nimport math\nimport sys\n\n\nclass Solver(object):\n\n def run(self):\n\n (a, b, c, d) = readarray(int)\n\n def point(p, t):\n return max(3*p/10, p - p/250*t)\n\n misha = point(a, c)\n vasya = point(b, d)\n\n if misha > vasya:\n print(\"Misha\")\n elif vasya > misha:\n print(\"Vasya\")\n else:\n print(\"Tie\")\n\n\n################################################################################\n# \u3053\u3053\u304b\u3089\u306f\u898b\u3061\u3083\u30c0\u30e1\uff01\n\ndef read(foo):\n return foo(raw_input())\ndef readarray(foo):\n return [foo(x) for x in raw_input().split()]\ndef dbg(a):\n sys.stderr.write(str(a))\n\nif __name__ == '__main__':\n Solver().run()\n"}, {"source_code": "a, b, c, d = [int(x) for x in input().split(' ')]\n\nm = max((3 * a) // 10, a - c * (a // 250))\nv = max((3 * b) // 10, b - d * (b // 250))\nif m > v:\n ans = 'Misha'\nelif v > m:\n ans = 'Vasya'\nelse:\n ans = 'Tie'\nprint(ans)"}, {"source_code": "x=input().split()\na=int(x[0])\nb=int(x[1])\nc=int(x[2])\nd=int(x[3])\n\n\nxpoint= max(3*a/10 ,a - (a/250)*c)\nypoint= max(3*b/10 ,b - (b/250)*d)\nif xpoint==ypoint :\n print('Tie')\nelse: \n if xpoint>ypoint : \n print('Misha')\n else: \n print('Vasya') "}, {"source_code": "a,b,c,d=map(int,input().split())\nz=max((3*a)//10,a-(a*c//250))\ny=max((3*b)//10,b-(b*d//250))\nif(z>y):\n print('Misha')\nelif(z<y):\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a, b, c, d = map(int, input().split())\nVasya = max(3*b/10, b-(b*d/250))\nMisha = max(3*a/10, a-(a*c/250))\nif Vasya > Misha: print('Vasya')\nelif Vasya < Misha: print('Misha')\nelse: print('Tie')\n"}, {"source_code": "x=[]\nx=input().split()\na=int(x[0])\nb=int(x[1])\nc=int(x[2])\nd=int(x[3])\n\nm=[]\nv=[]\np1=int((3*a)/10)\np2=int(a-((a*c)/250))\nm.append(p1)\nm.append(p2)\n\np1=int((3*b)/10)\np2=int(b-((b*d)/250))\nv.append(p1)\nv.append(p2)\n\nmm=(max(m))\nmv=(max(v))\n\nif mm>mv:\n print('Misha')\nelif mm==mv:\n print('Tie')\nelse:\n print('Vasya')"}, {"source_code": "a,b,c,d=map(int,input().split())\np1=max(3*a/10,a-a*c/250)\np2=max(3*b/10,b-b*d/250)\nif p1>p2:\n print(\"Misha\")\nelif p1<p2:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a, b, c,d = map(int, raw_input().split())\nmishascore=max(3*a/10,a-a/250*c)\nvasyascore=max(3*b/10,b-b/250*d)\nif mishascore<vasyascore:\n print \"Vasya\"\nelif mishascore>vasyascore:\n print \"Misha\"\nelse:\n print \"Tie\"\n"}, {"source_code": "a,b,c,d=map(int,input().split())\ns1=max( (3*a)//10 , a- (a*c)//250 )\ns2=max( (3*b)//10 , b- (b*d)//250 )\nif s1>s2:\n print(\"Misha\")\nelif s1==s2:\n print(\"Tie\")\nelse:\n print(\"Vasya\")"}, {"source_code": "a,b,c,d = input().split()\na,b,c,d = int(a), int(b), int(c), int(d)\n\nM = max(3*(a//10) , (250-c)*(a//250))\nV = max(3*(b//10) , (250-d)*(b//250))\n\nif M>V:\n print(\"Misha\")\nelif M<V:\n print(\"Vasya\")\nelse:\n print(\"Tie\")\n \n"}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 11.10.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\n\ndef main():\n \n\n\n #for _ in range(ii()):\n\n\n a,c,b,d=mi()\n\n x=max(3*a//10,a-(a//250)*b)\n y=max(3*c//10,c-(c//250)*d)\n\n if x==y:\n print('Tie')\n elif x>y:\n print('Misha')\n else:\n print('Vasya')\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "# Author : code_marshal\n# cmp is not available in python 3.x\n\na,b,c,d=map(int,raw_input().split())\nch=cmp(max(a*3//10,a-a*c//250),max(b*3//10,b-b*d//250))\nif not ch:print \"Tie\"\nelif ch==1:print \"Misha\"\nelse:print \"Vasya\"\n"}, {"source_code": "\n# Problem: A. Contest\n# Contest: Codeforces - Codeforces Round #285 (Div. 2)\n# URL: https://codeforces.com/problemset/problem/501/A\n# Memory Limit: 256 MB\n# Time Limit: 1000 ms\n# Powered by CP Editor (https://github.com/cpeditor/cpeditor)\n\na,b,c,d=[int(_) for _ in input().split()]\nX=max((3*a)/10,a-(a*c)/250)\nY=max((3*b)/10,b-(b*d)/250)\nif X<Y:\n\tprint(\"Vasya\")\nelif X>Y:\n\tprint(\"Misha\")\nelse:\n\tprint(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nans,res=0,0\ntemp=max((3*a/10),a-(a/250)*c)\nres=max((3*b/10),b-(b/250)*d)\nif temp==res:\n print(\"Tie\")\nelif temp<res:\n print(\"Vasya\")\nelse:\n print(\"Misha\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nx1=max((3*a)/10,a-(a/250)*c)\nx2=max((3*b)/10,b-(b/250)*d)\nif(x1>x2):\n print(\"Misha\")\nelif(x2>x1):\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nx=max((3*a)/10,(a-((a/250)*c)))\ny=max((3*b)/10,(b-((b/250)*d)))\nif(x==y):\n print(\"Tie\")\nelif(max(x,y)==x):\n print(\"Misha\")\nelif(max(x,y)==y):\n print(\"Vasya\")\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nf=lambda p,t:max(3*p/10,p-p/250*t)\ndf=f(a,c)-f(b,d)\nprint('Vasya' if df<0 else ['Tie', 'Misha'][df>0])"}, {"source_code": "a,b,c,d = list(map(int,input().split()))\nMis = max(3*a/10,a-((a/250)*c))\nVas = max(3*b/10,b-((b/250)*d))\nif Mis > Vas:\n print(\"Misha\")\nelif Mis < Vas:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "l=[int(x) for x in input().split()]\na=l[0]\nb=l[1]\nc=l[2]\nd=l[3]\nx=max((3*a)/10,(a-((a/250)*c)))\ny=max((3*b)/10,(b-((b/250)*d)));\nif(x>y):\n print(\"Misha\")\nelif(x<y):\n print(\"Vasya\");\nelse:\n print(\"Tie\");\n"}, {"source_code": "pa,pb,ta,tb=map(int,input().split(' '))\ns1=[((3*pa)/10),(pa-(pa/250)*ta)]\ns2=[((3*pb)/10),(pb-(pb/250)*tb)]\nma=max(s1)\nmb=max(s2)\nif ma > mb:\n print(\"Misha\")\nelif mb > ma:\n print(\"Vasya\")\nelif ma == mb:\n print(\"Tie\")\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\n\ndef judge(p,t):\n return max((1.0*3*p)/10, p-(1.0*p/250)*t)\n\nprint 'Misha' if judge(a,c)>judge(b,d) else 'Vasya' if judge(a,c)<judge(b,d) else 'Tie'"}], "negative_code": [{"source_code": "a,b,c,d = map(int,input().split())\nmis = max((3*a//10,a- (a*c//250)))\nvas = max(3*b//10, b- (b*d//250))\nprint(mis,vas)\nif mis==vas:\n\tprint(\"Tie\")\nelif mis>vas:\n\tprint(\"Misha\")\nelse:\n\tprint(\"Vasya\")\n"}, {"source_code": "x=input().split()\na=int(x[0])\nb=int(x[1])\nc=int(x[2])\nd=int(x[3])\n\n\nxpoint= a - (a/250)*c\nypoint= b - (b/250)*d\nif xpoint==ypoint :\n print('Tie')\nelse: \n if xpoint>ypoint : \n print('Misha')\n else: \n print('Vasya')"}, {"source_code": "def res(cost, time):\n return min(3*cost // 10, cost - cost // 250 * time)\n\na,b,c,d = map(int,input().split())\n\nif res(a,c) > res(b,d):\n print(\"Misha\")\nelif res(a,c) == res(b,d):\n print(\"Tie\")\nelse:\n print(\"Vasya\")\n\n"}, {"source_code": "import sys\nline = map(int, raw_input().split())\na = line[0]\nb = line[1]\nc = line[2]\nd = line[3]\nm = max(3 * a, a - a * c / 25)\nv = max(3 * b, b - b * d / 25)\nif (m > v): sys.stdout.write('Misha')\nelif (m < v): sys.stdout.write('Vasya')\nelse: sys.stdout.write('Tie')\n"}, {"source_code": "a,b,c,d = list(map(int,input().split()))\nif max((3*a)//10,a-(a*c)//250) > max((3*b)//10,a-(b*d)//250):\n print(\"Misha\")\nelif max((3*a)//10,a-(a*c)//250) < max((3*b)//10,a-(b*d)//250):\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nx=max((3*a)//10,((a-(a//250))*c))\ny=max((3*b)//10,((b-(b//250))*d))\nif x>y:\n print(\"Misha\")\nelif y>x:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nm,v=max((0.3*a),(c*(a/250))),max((0.3*b),(d*(b/250)))\n\nif(m==v):\n print('Tie')\nelif(m>v):\n print('Misha')\nelse:\n print('Vasya')"}, {"source_code": "a, b, c, d = map(int, input().split())\nx = max(a / 10, a - (a / 250) * c)\ny = max(b / 10, a - (b / 250) * d)\nif x < y:\n print('Misha')\nelif y < x:\n print('Vasya')\nelse: print('Tie')"}, {"source_code": "data = [int(k) for k in input().split()]\nMisha= max((3*data[0]/10), data[0] - (data[0]/250)*data[2])\nVasya = max((3*data[1]/10), data[1] - (data[1]/250)*data[3])\nif Misha == Vasya:\n print(\"Tie\")\nelif Misha > Vasya:\n print(\"Misha\")\nelse:\n print(\"Vaysa\")"}, {"source_code": "\n\nin1 = [int(x) for x in raw_input().split(\" \")]\n\npM = in1[0]\npV = in1[1]\ntM = in1[2]\ntV = in1[3]\n\nsM = max(.3*pM,pM-pM/250.0*tM)\nsV = max(.3*pV,pV-pV/250.0*tV)\n\nif sM>sV: print \"Misha\"\nelif sM<sV: print \"Vasya\"\nelse: print \"TFJLLKJFie\""}, {"source_code": "from sys import stdin, stdout\nm,n,o,p=[int(x) for x in stdin.readline().rstrip().split()]\n\ndef contest(a,b,c,d):\n misha=max(3*a/10,(a-a/250*c))\n vasya=max(3*b/10,(b-b/250*d))\n if misha>vasya:\n stdout.write(\"Misha\"+\"\\n\")\n elif misha==vasya:\n stdout.write(\"Tie\"+\"\\n\")\n else:\n stdout.write(\"Vasya\"+\"\\n\")\n return 0"}, {"source_code": "data = [int(k) for k in input().split()]\nMisha= max((3*data[0]/10), data[0] - (data[0]/250)*data[2])\nVasya = max((3*data[1]/10), data[1] - (data[1]/250)*data[3])\nif Misha == Vasya:\n print(\"Tie\")\nelif Misha > Vasya:\n print(\"Misha\")\nelse:\n print(\"Vaysa\")"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\n\nmisha = max(3 * a / 10, a - a / 250 * c)\nvaysa = max(3 * b / 10, b - b / 250 * d)\n\nif misha > vaysa:\n print 'Misha'\nelif misha < vaysa:\n print 'Vaysa'\nelse:\n print 'Tie'\n"}, {"source_code": "a, b, c, d = map(int, input().split())\n\nmp = max(3 * a // 10, a // 250 * c)\nvp = max(3 * b // 10, b // 250 * d)\n\nif vp > mp:\n print(\"Vasya\")\nelif mp > vp:\n print(\"Misha\")\nelse:\n print(\"Tie\") "}, {"source_code": "m = [int(x) for x in input().split()]\n[a, b, c, d] = m\nx = max([3*a//10, a - a*c//250])\ny = max([3*a//10, a - a*c//250])\nif x==y:\n q = 'Tie'\nelif x > y:\n q = 'Misha'\nelse:\n q = 'Vasya'\nprint(q)"}, {"source_code": "import sys\nline = map(int, raw_input().split())\na = line[0]\nb = line[1]\nc = line[2]\nd = line[3]\nm = max(3 * a, a - a * c / 25)\nv = max(3 * b, b - b * d / 25)\nif (m > v): sys.stdout.write('Misha')\nelif (m < v): sys.stdout.write('Vasya')\nelse: sys.stdout.write('Tie')\n"}, {"source_code": "a,b,c,d = [int(item) for item in input().split()]\nx = max(3*a/10 , (a-(a*c/250)))\ny = max(3*b/10 , (b-(b*c/250)))\nif x>y:\n print(\"Misha\")\nelif x<y:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "l = list(map(int,input().split()))\na,b,c,d = l[0],l[1],l[2],l[3]\nm = max(3*a, a - a/250*c)\nv = max(3*b, b - b/250*d)\nif m >v:\n print('Misha')\nelif m == v:\n print('Tie')\nelse:\n print('Vasya')\n"}, {"source_code": "a,b,c,d=map(int,input().split())\n\nm=max(3*a/10,a-a/250*c)\nv=max(3*b/10,b-b/250*d)\n\nif m>v:print('Misha')\nelif v<m:print('Vasya')\nelse:print('Tie')"}, {"source_code": "a,b,c,d = map(int, input().split(' '))\nif a>b and c>d:\n print(\"Misha\")\nelse:\n print(\"Vasya\")\nif a==b and c==d:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nn=max(3*a//10,a-a//250)\nl=max(3*b//10,b-b//250)\nif n==l:\n print(\"Tie\")\nelif n>l:\n print(\"Misha\")\nelse:\n print(\"Vasya\")\n"}, {"source_code": "a, b, c, d = map(int, input().split())\nx = max(a / 10, a - (a / 250) * c)\ny = max(b / 10, b - (b / 250) * d)\nif x < y:\n print('Misha')\nelif y < x:\n print('Vasya')\nelse: print('Tie')"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\ne = max(3*a/10,a-a/250*c)\nf = max(3*b/10,b-b/250*c)\nif e > f:\n print \"Misha\"\nelif e == f:\n print \"Tie\"\nelse:\n print \"Vasya\""}, {"source_code": "a, b, c, d = list(map(int, input().split(\" \")))\nx1 = (3 * a) // 10\nx2 = (3 * b) // 10\ny1 = a - (a // 250) * c\ny2 = b - (b // 250) * d\nz1 = max(x1, y1)\nz2 = max(x2, y2)\nif (a % 250 == 0 and b % 250 == 0):\n if (z1 > z2):\n print(\"MIsha\")\n elif (z1 == z2):\n print(\"Tie\")\n else:\n print(\"Vasya\")\nexit()\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nx=max(3*a//10,a-((a//250)*c))\ny=max(3*b//10,b-((b//250)*d))\nif x>y:\n print('Misha')\nelse:\n print('Vasya')\n"}, {"source_code": "a,b,c,d =[int(q) for q in raw_input().split(' ')]\n\nans1= max(a , c*a)\nans2= max(b , d*b)\n\nif ans1>ans2:\n\tprint 'Misha'\nelif ans1==ans2:\n\tprint 'Tie'\nelse:\n\tprint 'Vasya'\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nf=2\nres=['Misha','Vasya','Tie']\nq=max((3*a)//10,(a-(a//250))*c)\nw=max((3*b)//10,(b-(b//250))*d)\nif q==w:\n print(res[2])\nelif q>w:\n print(res[0])\nelse:\n print(res[1])"}, {"source_code": "a,b,c,d=map(int,input().split())\nx=max((3*a)//10,((a-(a//250))*c))\ny=max((3*b)//10,((b-(b//250))*d))\nif x>y:\n print(\"Misha\")\nelif y>x:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a , b , c , d = map(int,input().split())\nm = max(3*a/10,a-a/250*c)\nv = max(3*b/10,b-b/250*d)\nif m > v : print(\"Misha\")\nelif v < m : print(\"Vasya\")\nelse : print(\"Tie\")\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nm,v=max((0.3*a),(c*(a/250))),max((0.3*b),(d*(b/250)))\n\nif(m==v):\n print('Tie')\nelif(m>v):\n print('Misha')\nelse:\n print('Vasya')"}, {"source_code": "a, b, c, d = list(map(int, input().split()))\n\n\ndef calc(p, t):\n\treturn max((3*p)//10, p - (p//250) - t)\n\n\nif calc(a, c) > calc(b, d):\n\tprint(\"Misha\")\nelif calc(a, c) < calc(b, d):\n\tprint(\"Vasya\")\nelse:\n\tprint(\"Tie\")"}, {"source_code": "data = [int(k) for k in input().split()]\nMisha= max((3*data[0]/10), data[0] - (data[0]/250)*data[2])\nVasya = max((3*data[1]/10), data[1] - (data[1]/250)*data[3])\nif Misha == Vasya:\n print(\"Tie\")\nelif Misha > Vasya:\n print(\"Misha\")\nelse:\n print(\"Vaysa\")"}, {"source_code": "#-*-coding:utf8;-*-\n#qpy:3\n#qpy:console\n\na,b,c,d=map(int,input().split(' '))\nm=a*max([3/10,1-c/250])\nv=b*max([3/10,1-d/250])\nif m>v:\n print('Misha')\nelif v>m:\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a, b, c, d = list(map(int, input().split()))\n\n\ndef calc(p, t):\n\treturn max((3*p)//10, p - (p//250) - t)\n\n\nif calc(a, c) > calc(b, d):\n\tprint(\"Misha\")\nelif calc(a, c) < calc(b, d):\n\tprint(\"Vasya\")\nelse:\n\tprint(\"Tie\")"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\npa = max((3*a/10),a - (a/250)*c)\npb = max((3*b/10),b - (b/250)*c)\nif pa>pb:\n print \"Misha\"\nelif pa<pb:\n print \"Vasya\"\nelse:\n print \"Tie\"\n\n"}, {"source_code": "\n\nin1 = [int(x) for x in raw_input().split(\" \")]\n\npM = in1[0]\npV = in1[1]\ntM = in1[2]\ntV = in1[3]\n\nsM = max(.3*pM,pM-pM/250.0*tM)\nsV = max(.3*pV,pV-pV/250.0*tV)\n\nif sM>sV: print \"Misha\"\nelif sM<sV: print \"Vasya\"\nelse: print \"TFJLLKJFie\""}, {"source_code": "a,b,c,d = [int(item) for item in input().split()]\nx = max(3*a/10 , (a-(a*c/250)))\ny = max(3*b/10 , (b-(b*c/250)))\nif x>y:\n print(\"Misha\")\nelif x<y:\n print(\"Vasya\")\nelse:\n print(\"Tie\")#1"}, {"source_code": "import sys\nline = map(float, raw_input().split())\na = line[0]\nb = line[1]\nc = line[2]\nd = line[3]\nm = max(3 * a / 10, a - a / 250 * c)\nv = max(3 * b / 10, b - b / 250 * d)\nif (m > v): print 'Misha'\nelif (m < v): print 'Vasaya'\nelse: print 'Tie'\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nif(a>b):\n print(\"Misha\")\nelif(a==b):\n print(\"Tie\")\nelse:\n print(\"Vasya\")\n"}, {"source_code": "a,b,c,d = map(int, input().split())\nmisha = max(0.3*a, a-(a/250)*c)\nvaysa = max(0.3*b, b-(b/250)*d)\n\nif misha > vaysa:\n print(\"Misha\")\nelif misha < vaysa:\n print(\"Vaysa\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nif(a>b and c<d):\n print(\"Misha\")\nelif(a==b and c==d):\n print(\"Tie\")\nelse:\n print(\"Vasya\")\n"}, {"source_code": "a,b,c,d =list(map(int,input().split()))\nm=max((3*a)/250,a-(a/250)*c)\nv=max((3*b)/250,b-(b/250)*d)\nif m>v:\n print(\"Misha\")\nelif v>m:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "l = list(map(int,input().split()))\na,b,c,d = l[0],l[1],l[2],l[3]\nm = max(3*a, a - a/250*c)\nv = max(3*b, b - b/250*d)\nif m >v:\n print('Misha')\nelif m == v:\n print('Tie')\nelse:\n print('Vasya')\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/501/A\n\"\"\"\n\n\ndef points(p, t):\n return max((3 * p) // 100, p - (p * t) // 250)\n\n\nstrings = [\"Misha\", \"Vasya\", \"Tie\"]\n[a, b, c, d] = [int(item) for item in input().split(' ')]\n\npm = points(a, c)\npv = points(b, d)\n\nif pm > pv:\n print(strings[0])\nelif pm < pv:\n print(strings[1])\nelse:\n print(strings[2])\n"}, {"source_code": "x=[]\nx=input().split()\na=int(x[0])\nb=int(x[1])\nc=int(x[2])\nd=int(x[3])\n\nm=[]\nv=[]\np1=int((3*a)/c)\np2=int(a-((a*c)/250))\nm.append(p1)\nm.append(p2)\n\np1=int((3*b)/d)\np2=int(b-((b*d)/250))\nv.append(p1)\nv.append(p2)\n\nmm=(max(m))\nmv=(max(v))\n\nif mm>mv:\n print('Misha')\nelif mm==mv:\n print('Tie')\nelse:\n print('Vasya')\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nif max(3*a/10,a-a/250*c) < max(3*b/10,b-b/250*c):\n\tprint \"Vasya\"\nelif max(3*a/10,a-a/250*c) > max(3*b/10,b-b/250*d):\n\tprint \"Misha\"\nelse:\n\tprint \"Tie\""}, {"source_code": "import sys\ndef getScore(p,t):\n\tp=int(p)\n\tt=int(t)\n\treturn max(3*p, p - (p/250) * t )\n\ndef findWinner(inputString):\n\tvarArray=inputString.split()\n\tif(getScore(varArray[0],varArray[2]) < getScore(varArray[1],varArray[3])):\n\t\treturn \"Vasya\"\n\telif(getScore(varArray[0],varArray[2]) > getScore(varArray[1],varArray[3])):\n\t\treturn \"Misha\"\n\telse: return \"Tie\"\n\nprint(findWinner(\"500 1000 20 30\")+'\\n')\nprint(findWinner(\"1000 1000 1 1\")+'\\n')\nprint(findWinner(\"1500 1000 176 177\")+'\\n')\nprint sys.version\n\n"}, {"source_code": "a,b,c,d=map(int,input().split())\np1=max(3*a/10,a*c/250)\np2=max(3*b/10,b*d/250)\nif p1>p2:\n print(\"Misha\")\nelif p1<p2:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a, b, c, d = map(int, input().split())\nif a * c > b * d:\n print('Misha')\nelif b * d > a * c:\n print('Vasya')\nelse: print('Tie')"}, {"source_code": "a,b,c,d=map(int,input().split())\nx=max(((3*a)//250),(a-((a//250)*c)))\ny=max(((3*b)//250),(b-((b//250)*d)))\n# print(x,y)\nif y>x:\n\tprint('Vasya')\nelif x>y:\n\tprint('Misha')\nelse:\n\tprint('Tie')"}, {"source_code": "\n\nin1 = [int(x) for x in raw_input().split(\" \")]\n\npM = in1[0]\npV = in1[1]\ntM = in1[2]\ntV = in1[3]\n\nsM = max(.3*pM,pM-pM/250.0*tM)\nsV = max(.3*pV,pV-pV/250.0*tV)\n\nif sM>sV: print \"Misha\"\nelif sM<sV: print \"Vasya\"\nelse: print \"TFJLLKJFie\""}, {"source_code": "a,b,c,d = [int(item) for item in input().split()]\nx = max(3*a/10 , (a-(a*c/250)))\ny = max(3*b/10 , (b-(b*c/250)))\nif x>y:\n print(\"Misha\")\nelif x<y:\n print(\"Vasya\")\nelse:\n print(\"Tie\")#1"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\ndef M(p,t):\n\treturn max((3*p)/10,(p*t)/250)\nx=M(a,c)-M(b,d) \n\nif x>1:\n\tprint('Misha')\nelif x<0:\n\tprint('Vasya')\nelse:\n\tprint('Tie')\n\t\t\n"}, {"source_code": "p1, p2, t1, t2 = map(int, input().split())\nm = max(3*p1, p1-p1/250*t1)\nv = max((3*p2, p2-p2/250*t2))\nprint(['Misha', 'Vasya', 'Tie'][[m>v, v>m, v==m].index(1)])"}, {"source_code": "l = list(map(int,input().split()))\na,b,c,d = l[0],l[1],l[2],l[3]\nm = max(3*a, a - a/250*c)\nv = max(3*b, b - b/250*d)\nif m >v:\n print('Misha')\nelif m == v:\n print('Tie')\nelse:\n print('Vasya')\n"}, {"source_code": "#br = open('a.in')\na, b, c, d = map(int, raw_input().strip().split())\n\ndef com(p, t):\n p, t = p * 1.0, t * 1.0\n return max(3 * p, p - (p / 250) * t)\n\nx, y = com(a, c), com(b, d)\nif x == y:\n print 'Tie'\nelse:\n print ['Vasya', 'Misha'][x > y]\n"}, {"source_code": "l = list(map(int,input().split()))\na,b,c,d = l[0],l[1],l[2],l[3]\nm = max(3*a, a - a/250*c)\nv = max(3*b, b - b/250*d)\nif m >v:\n print('Misha')\nelif m == v:\n print('Tie')\nelse:\n print('Vasia')\n"}, {"source_code": "a,b,c,d = map(int,input().split())\nn = max(3*a/10,a-(a/250*c))\nm = max(3*b/10, b-(b/250*d))\nif m > n:print('Misha')\nif n > m:print('Vasya')\nif m == n:print('Tie')"}, {"source_code": "__author__ = 'pxy'\n(a,b,c,d) = (int(i) for i in input().split())\nbmish=max(3*a//10,a-(a//250*c))\nbvit=max(3*b//10,b-(b//250*d))\nif bmish>bvit:\n print('Misha')\nelse:\n if(a==b):\n print('Tie')\n else:\n print('Vasya')\n"}, {"source_code": "class so_sanh(object):\n def __init__(self,p,t):\n self.p = p\n self.t = t\n def aaa(self):\n if(3*self.p/10<(self.p-self.p*self.t/250)):\n return (self.p-self.p*self.t/250)\n else:\n return (3*self.p*10)\na,b,c,d=map(int,input().split())\nm=so_sanh(a,c)\nv=so_sanh(b,d)\nif(m.aaa()<v.aaa()):\n print(\"Vasya\")\nelif(m.aaa()==v.aaa()):\n print(\"Tie\")\nelse:\n print(\"Misha\")"}, {"source_code": "# coding: utf-8\na, b, c, d = [int(i) for i in input().split()] \nif max(3*a//10,a-a//250*c)>max(3*b//10,b-b//250*c):\n print('Misha')\nelif max(3*a//10,a-a//250*c)==max(3*b//10,b-b//250*c):\n print('Tie')\nelse:\n print('Vasya')\n \n"}, {"source_code": "def find_max(p,t):\n return max(3*p/10,p-p/250*t)\nlst = list(map(int,input().split()))\nif find_max(lst[0],lst[2]) > find_max(lst[1],lst[2]):\n print(\"Misha\")\nelif find_max(lst[0],lst[2]) == find_max(lst[1],lst[3]):\n print(\"Tie\")\nelse:\n print(\"Vasya\")\n\n"}, {"source_code": "a, b, c, d = list(map(int, input().split()))\n\n\ndef calc(p, t):\n\treturn max((3*p)//10, p - (p//250) - t)\n\n\nif calc(a, c) > calc(b, d):\n\tprint(\"Misha\")\nelif calc(a, c) < calc(b, d):\n\tprint(\"Vasya\")\nelse:\n\tprint(\"Tie\")"}, {"source_code": "a,b,c,d = map(int,input().split())\nmis = max((3*a//10,a- (a*c//250)))\nvas = max(3*b//10, b- (b*d//250))\nprint(mis,vas)\nif mis==vas:\n\tprint(\"Tie\")\nelif mis>vas:\n\tprint(\"Misha\")\nelse:\n\tprint(\"Vasya\")\n"}, {"source_code": "__author__ = 'pxy'\n(a,b,c,d) = (int(i) for i in input().split())\nbmish=max(3*a//10,a-(a//250*c))\nbvit=max(3*b//10,b-(b//250*d))\nif bmish>bvit:\n print('Misha')\nelse:\n if(a==b):\n print('Tie')\n else:\n print('Vasya')\n"}, {"source_code": "data = input().split()\n\nA, B, C, D = int(data[0]), int(data[1]), int(data[2]), int(data[3])\n\nmisha_scores = max((3*A)/10, (A/250) * C)\nvasya_scores = max((3*B)/10, (B/250) * D)\n\nif misha_scores > vasya_scores:\n print('Misha')\nelif misha_scores < vasya_scores:\n print('Vasya')\nelse:\n print('Tie')\n"}, {"source_code": "l=[int(x) for x in input().split()]\na=l[0]\nb=l[1]\nc=l[2]\nd=l[3]\nx=max((3*a)/10,(a-((a/250)*c)))\ny=max((3*b)/10,(b-((b/250)*d)));\nif(a>b):\n print(\"Misha\")\nelif(a<b):\n print(\"Vasya\");\nelse:\n print(\"Tie\");\n"}, {"source_code": "a,b,c,d = map(int,input().split())\n\nm = max(3*a, a - a // 250 * c)\nv = max(3*b, b - b // 250 * d)\n\nif m == v:\n print(\"Tie\")\nelif m > v:\n print(\"Misha\")\nelse:\n print(\"Vasya\") "}, {"source_code": "'''input\n750 1000 54 103\n'''\ndef getScore(p,t):\n\tp=int(p)\n\tt=int(t)\n\treturn max((3*p) / 10, p - ((p/250) * t) )\n\ndef findWinner(inputString):\n\tvarArray=inputString.split()\n\tprint getScore(varArray[0],varArray[2]) , getScore(varArray[1],varArray[3])\n\tif(getScore(varArray[0],varArray[2]) < getScore(varArray[1],varArray[3])):\n\t\treturn \"Vasya\"\n\telif(getScore(varArray[0],varArray[2]) > getScore(varArray[1],varArray[3])):\n\t\treturn \"Misha\"\n\telse: return \"Tie\"\n\nprint(findWinner(raw_input()))"}, {"source_code": "a,b,c,d=map(int,input().split(\" \"))\nn=max(3*a//10,a-a*c//250)\nm=max(3*b//10,b-b*d//250)\nif(n==m):\n print(\"Tie\")\nelif(n>m):\n print(\"Vasya\")\nelse:\n print(\"Misha\")"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\ne = max(3*a/10,a-a/250*c)\nf = max(3*b/10,b-b/250*c)\nif e > f:\n print \"Misha\"\nelif e == f:\n print \"Tie\"\nelse:\n print \"Vasya\""}, {"source_code": "a,b,c,d=map(int,input().split())\nx=max(3*a//10,a-a//250*c)\ny=max(3*b//10,b-b//250*d)\n \nif(a>b):\n print('Misha')\nelif(a<b):\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a,b,c,d=map(int,input().split())\np1=a-((a/250)*c)\np2=b-((b/250)*d)\nif(p1>p2):\n\tprint(\"Misha\")\nelif(p1==p2):\n\tprint(\"Tie\")\nelif(p2>p1):\n\tprint(\"Vasya\")"}, {"source_code": "score = (lambda p, t: max(75, 250 - t))\na, b, c, d = map(int, input().split())\nprint('Misha' if score(a, c) > score(b, d) else 'Vasya' if score(a, c) < score(b, d) else 'Tie')"}, {"source_code": "a, b, c, d = map(int, input().split())\nmisha, vasya = max((3 * a) / 10, (a / 250) * c), max((3 * b) / 10, (b / 250) * d)\nif (misha > vasya):\n print(\"Misha\")\nelif(vasya>misha):\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nx=max(3*a/10,a-((a/250)*c))\ny=max(3*b/10,b-((b/250)*d))\nprint x,y\nif x>y:\n print \"Misha\"\nif y>x:\n print \"Vasya\"\nif y==x:\n print \"Tie\"\n"}, {"source_code": "def calc(p,t):\n x = (3*p) / 10\n y = ((p) - ((p*t)/(250)))\n return max(x,y)\n\na,b,c,d = map(int,input().split())\np,q = calc(a,c),calc(b,d)\nprint(p,q)\nif p > q:\n print(\"Misha\")\nelif p == q:\n print(\"Tie\")\nelse:\n print(\"Vasya\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nif(a>b and c<d):\n print(\"Misha\")\nelif(a==b and c<d):\n print(\"Misha\")\nelif(a==b and c>d):\n print(\"Vasya\")\nelif(a==b and c==d):\n print(\"Tie\")\nelse:\n print(\"Vasya\")\n"}, {"source_code": "a,b,c,d = map(int, input().split(' '))\nif a>b and c>d:\n print(\"Misha\")\nelse:\n print(\"Vasya\")\nif a==b and c==d:\n print(\"Tie\")"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nval = max((3*a)/10, (a*c)/250)\nval1 = max((3*b)/10, (b*d)/250)\nif val > val1 : print \"Misha\"\nelif val1 > val : print \"Vasya\"\nelse : print \"Tie\"\n"}, {"source_code": "a, b, c, d = map(int, input().split())\n\nres1 = max((3 * a / 10), a - a/250 * c)\nres2 = max((3 * b / 10), b - b/250 * d)\n\nprint(res1)\nprint(res2)\n\nif res1 > res2:\n print(\"Vasya\")\nelif res2 > res1: \n print(\"Misha\")\nelse:\n print(\"Tie\")"}, {"source_code": "def res(cost, time):\n return min(3*cost // 10, cost - cost // 250 * time)\n\na,b,c,d = map(int,input().split())\n\nif res(a,c) > res(b,d):\n print(\"Misha\")\nelif res(a,c) == res(b,d):\n print(\"Tie\")\nelse:\n print(\"Vasya\")\n\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\ndef M(p,t):\n\treturn max((3*p)/10,(p*t)/250)\nx=M(a,c)-M(b,d) \n\nif x<0:\n\tprint('Misha')\nelif x>1:\n\tprint('Vasya')\nelse:\n\tprint('Tie')\n\t\t\n"}, {"source_code": "yo=list(map(int,input().split()))\na=yo[0]\nb=yo[1]\nc=yo[2]\nd=yo[3]\nscore1=max(0.3*a,0.004*a*c)\nscore2=max(0.3*b,0.004*b*d)\nif score1>score2:\n\tprint('Misha')\nelif score2>score1:\n\tprint('Vasya')\nelse:\n\tprint('Tie')\t\t"}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 11.10.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\n\ndef main():\n \n\n\n #for _ in range(ii()):\n\n\n a,c,b,d=mi()\n\n x=max(3*a//10,a-(a//250)*b)\n y=max(3*c//10,c-(c//250)*d)\n\n if x==y:\n print('Tie')\n elif x<y:\n print('Misha')\n else:\n print('Vasya')\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "a,b,c,d =[int(q) for q in raw_input().split(' ')]\n\nans1= max(3*a/10 , (a-(a/25)*c))\nans2= max(3*b/10 , (b-(b/25)*d))\n\nif ans1>ans2:\n\tprint 'Misha'\nelif ans1==ans2:\n\tprint 'Tie'\nelse:\n\tprint 'Vasya'\n"}, {"source_code": "a, b, c, d = map(int,input().split())\nm = a//250\nn = b // 250\npoints_misha = max((3*a)/10,a-m*c)\npoints_vasya = max((3*b)/10,b-n*c)\nif points_vasya > points_misha:\n\tprint('Vasya')\nelif points_misha > points_vasya:\n\tprint('Misha')\nelse:\n\tprint('Tie')"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nmisha = max(3.0*a/10.0,a-a/250.0*c)\nvasya = max(3.0*b/10.0,b-b/250.0*d)\nif misha > vasya:\n print \"Misha\"\nif misha < vasya:\n print \"Vasya\"\nelse:\n print \"Tie\""}, {"source_code": "a,b,c,d = map(int,input().split())\nm = max(0.3, (a-(a//250))*c)\nv =max(0.3, (b-(b//250))*d)\nif v > m:\n print(\"Vasya\")\nelif m > v:\n print(\"Misha\")\nelse:print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nx=max(3*a/10,a-((a/250)*c))\ny=max(3*b/10,b-((b/250)*d))\nprint x,y\nif x>y:\n print \"Misha\"\nif y>x:\n print \"Vasya\"\nif y==x:\n print \"Tie\"\n"}, {"source_code": "a,b,c,d=map(int,input().split())\np1=a-((a/250)*c)\np2=b-((b/250)*d)\nif(p1>p2):\n\tprint(\"Misha\")\nelif(p1==p2):\n\tprint(\"Tie\")\nelif(p2>p1):\n\tprint(\"Vasya\")"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nmisha = max(3.0*a/10.0,a-a/250.0*c)\nvasya = max(3.0*b/10.0,b-b/250.0*d)\nif misha > vasya:\n print \"Misha\"\nif misha < vasya:\n print \"Vasya\"\nelse:\n print \"Tie\""}, {"source_code": "\n\n\na, b, c, d = list(map(int, input().split()))\ntmp1 = max(3 * a // 10, a - ((a // 250) * c))\ntmp2 = max(3 * b // 10, b - ((b // 250) * d))\nprint('tie' if tmp1 == tmp2 else 'Misha' if tmp1 > tmp2 else 'Vasya')\n\n#\n# CodeForcesian\n# \u2665\n# M ^ 2\n"}, {"source_code": "def point(p,t):\n return max((3*p,-(p/250)*t))\nl=list(map(int,input().split()))\nM=point(l[0],l[1])\nV=point(l[1],l[3])\nif V==M:\n print('Tie')\nelif V>M:\n print('Vasya')\nelse:\n print('Misha')"}, {"source_code": "a,b,c,d = map(int,input().split())\n\nm = max(3*a, a - a // 250 * c)\nv = max(3*b, b - b // 250 * d)\n\nif m == v:\n print(\"Tie\")\nelif m > v:\n print(\"Misha\")\nelse:\n print(\"Vasya\") "}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nl=[\"Misha\",\"Vasya\",\"Tie\"]\nans=chk=0\n\n\ndef jg(p,t):\n sc=(((3*p)/10)+p)-(p/250)*t\n return sc\n\n\nm=jg(a,c)\nv=jg(b,d)\nprint l[0] if m>v else l[1] if m<v else l[2]"}, {"source_code": "a,b,c,d=map(int,input().split())\np1=max(3*a/10,a*c/250)\np2=max(3*b/10,b*d/250)\nif p1>p2:\n print(\"Misha\")\nelif p1<p2:\n print(\"Vasya\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d = map(int, input().split())\ne = max(3*a//10, a-a*b//250)\nf = max(3*c//10, c-c*d//250)\nif e > f:\n print(\"Vasya\")\nelif e < f:\n print(\"Misha\")\nelse:\n print(\"Tie\")"}, {"source_code": "a,b,c,d=map(int,input().split())\nx=max(3*a//10,a-a//250*c)\ny=max(3*b//10,b-b//250*d)\n \nif(a>b):\n print('Misha')\nelif(a<b):\n print('Vasya')\nelse:\n print('Tie')"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\ns1=max(2*a/10,a-a/250*c)\ns2=max(2*b/10,b-b/250*d)\nif s1==s2:\n\tprint \"Tie\"\nelif s1>s2:\n\tprint \"Misha\"\nelse:print \"Vasya\""}], "src_uid": "95b19d7569d6b70bd97d46a8541060d0"} {"source_code": "x1,y1,x2,y2 = map(int,input().split())\n\nprint(((y2-y1)//2 + 1)*(x2-x1+1)-(x2-x1)//2)", "positive_code": [{"source_code": "x1, y1, x2, y2 = map(int, input().split())\n\nd = (x2 - x1) // 2 + 1\ne = (y2 - y1) // 2 + 1\nif (y2 - y1) % 2 == 0:\n\tans = d * e + (d - 1) * (e - 1)\nelse:\n\tans = (2 * d - 1) * (e - 1)\nprint(ans)"}, {"source_code": "x1, y1, x2, y2 = [int(i) for i in input().split()]\n\nt = y2 - y1 + 1\nh = (x2 - x1 + 2) // 2\n\nprint(t // 2 * (h - 1) + (t // 2 + t % 2) * h)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\nprint(((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2)\n"}, {"source_code": "q = input().split()\nx1 = int(q[0])\ny1 = int(q[1])\nx2 = int(q[2])\ny2 = int(q[3])\n\nprint(((y2-y1)//2+1)*(x2-x1+1)-(x2-x1)//2)"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y <= 1000000:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x * y <= 1000000 and x1 % 2 == 1 and y1 % 2 == 0:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x * y > 1000000 and x1 % 2 == 1 and y1 % 2 == 0 :\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x * y <= 1000000 and y1 % 2 == 1 and x1 % 2 == 0:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x * y > 1000000 and y1 % 2 == 1 and x1 % 2 == 0 :\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\t\n\t\t\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "x1,y1,x2,y2=[int(x) for x in input().split()]\na=(y2-y1+1)//2+1\nb=a-1\nprint(((x2-x1+1)//2)*(a+b)+a)\n"}, {"source_code": "x1,y1,x2,y2 = map(int,input().split(' '))\nb = int((y2 - y1 + 1)/2) + 1\ns = b - 1\nl = x2 - x1 + 1\nans = b * int((l+1)/2) + s * int(l/2)\nprint(ans)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\nw = (x2 - x1) // 2 + 1\nh = (y2 - y1) // 2 + 1\nprint(h * w + (h - 1) * (w - 1))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y <= 1000000:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x * y <= 1000000 and x1 % 2 == 1 and y1 % 2 == 0:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x * y > 1000000 and x1 % 2 == 1 and y1 % 2 == 0 :\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x * y <= 1000000 and y1 % 2 == 1 and x1 % 2 == 0:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x * y > 1000000 and y1 % 2 == 1 and x1 % 2 == 0 :\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\nans = (((y2 - y1) // 2) + 1) * (x2 - x1 + 1) - (x2 - x1) // 2\nprint(ans)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\nxdif = x2-x1\nydif = y2-y1\nprint(xdif//2*ydif//2 + (xdif//2+1) * (ydif//2 + 1))"}, {"source_code": "a,b,c,d=map(int,input().split(' '))\nprint((((c-a+1)*(d-b+1)+1)//2))"}, {"source_code": "a, b, c, d = map(int, input().split(' '))\ndy = (d-b)//2+1\ndx = c - a + 1\nprint(dy*dx - (dx//2))\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\na, b = (x2 - x1) // 2, (y2 - y1) // 2\nprint(a * b + (a + 1) * (b + 1))"}, {"source_code": "import re\nst = input()\ns = re.split(r'[\\s]', st)\nx1 = int(s[0])\ny1 = int(s[1])\nx2 = int(s[2])\ny2 = int(s[3])\ns = ((y2 - y1) // 2 + 1) * ((x2 - x1) // 2 + 1) + ((y2 - y1) // 2 * (x2 - x1) // 2)\nprint (s)"}, {"source_code": "a,b,x,y = map(int,input().split())\nv = x-a+1\nh = (y-b)//2+1\nif v%2==0:\n m = v//2\n n=v//2\nelse:\n m = v//2 + 1\n n = v-m\nprint(m*h+n*(h-1)) "}, {"source_code": "x1,y1,x2,y2=map(int,input().split(\" \"))\nl=(y2-y1)//2\nh=l+1\na=(x2-x1)//2\nb=a+1\nprint(l*a+h*b)"}, {"source_code": "#!/usr/bin/python3\n# Copyright (C) 2016 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; If not, see <http://www.gnu.org/licenses/>.\n\ndef calc(y1, y2, r):\n if y1 % 2 != r:\n y1 -= 1\n if y2 % 2 != r:\n y2 += 1\n return (y2 - y1) // 2\n\nx1, y1, x2, y2 = map(int, input().split())\nx2, y2, x1, y1 = x2 - x1, y2 - y1, 0, 0\n\nxlen = x2 - x1 + 1\nodd, even = xlen // 2, xlen // 2\nif xlen % 2 == 1:\n if x1 % 2 == 1:\n odd += 1\n else:\n even += 1\nprint(odd * calc(y1, y2, 0) + even * calc(y1, y2, 1))\n"}, {"source_code": "#!/usr/bin/python3\n# Copyright (C) 2016 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; If not, see <http://www.gnu.org/licenses/>.\n\n\nx1, y1, x2, y2 = map(int, input().split())\n\nxlen = (x2 - x1) // 2\nnature, innature = xlen + 1, xlen\n\nbaseheight = 1 + (y2 - y1) // 2\n\nprint(nature * baseheight + innature * (baseheight - 1))\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\nx2 -= x1\ny2 -= y1\nx1 = 0\ny1 = 0\n\nodd_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 0 and x2 % 2 == 0 else 0)\nodd_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 0 and y2 % 2 == 0 else 0)\neven_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 1 and x2 % 2 == 1 else 0)\neven_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 1 and y2 % 2 == 1 else 0)\n\nprint(odd_x * odd_y + even_x * even_y)\n"}, {"source_code": "x1, y1, x2, y2 = [i + 1e10 for i in list(map(int, input().split()))]\ndeltax = 1e10 - x1\ndeltay = 1e10 - y1\nx1 -= deltax\nx2 -= deltax\ny1 -= deltay\ny2 -= deltay\nprint ((int(y2 / 2) - int((y1 - 1) / 2)) * (int(x2 / 2) - int((x1 - 1) / 2)) + (int((y2 + 1) / 2) - int(y1 / 2)) * (int((x2 + 1) / 2) - int(x1 / 2)))"}, {"source_code": "x1,y1,x2,y2 = map(int,input().split())\nprint(((y2-y1)//2 + 1)*(x2-x1+1)-(x2-x1)//2)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Aug 31 20:57:45 2020\n\n@author: Dark Soul\n\"\"\"\n[x1,y1,x2,y2]=list(map(int,input().split()))\ntot=(x2-x1)//2\ny=((y2-y1)//2)\nbigy=y+1\nsol=tot*y+(tot+1)*bigy\nprint(sol)\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport math\n\n\ndef cnt(l, r):\n if l % 2 != 0:\n l += 1\n if r % 2 != 0:\n r -= 1\n l //= 2\n r //= 2\n if l <= r:\n return r - l + 1\n return 0\n\n\ndef count(x, l, r):\n if x % 2 == 0:\n return cnt(l, r)\n else:\n return (r - l + 1) - cnt(l, r)\n\n\nline = input()\nline = line.split()\n\nx1 = int(line[0])\ny1 = int(line[1])\nx2 = int(line[2])\ny2 = int(line[3])\n\nprint(((x2 - x1 + 1) * (y2 - y1 + 1) + 1) // 2)\n\n# ans = (count(x1, y1, y2) + count(x1 + 1, y1, y2)) * (x2 - x1) // 2 + count(x2, y1, y2)\n#\n# print(ans)\n"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nprint((y2-y1+1)*(x2-x1)//2+(y2-y1)//2+1)"}, {"source_code": "x1,y1,x2,y2=map(int,input().split())\na=(y2-y1+2)//2\nb=(x2-x1+1)\nc=(a*b)-((x2-x1)//2)\nprint(int(c))"}, {"source_code": "ln = input().split(\" \")\nx1 = int(ln[0])\ny1 = int(ln[1])\nx2 = int(ln[2])\ny2 = int(ln[3])\n\nh = y2 - y1\nh = int(h / 2) + 1\n\nw = x2 - x1\nw = int(w / 2)\nans = (w + 1) * h + w * (h - 1)\nprint(ans)\n"}, {"source_code": "a = input().split(\" \")\nx1 = int(a[0])\ny1 = int(a[1])\nx2 = int(a[2])\ny2 = int(a[3])\n\ntotal = 0\n\nylen = y2 - y1\nxlen = x2 - x1\n\ntotal += (int(xlen / 2) + 1) * (int(ylen/2) + 1)\ntotal += int(xlen / 2) * int(ylen / 2)\n\nprint(int(total))"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split(' '))\nx2 -= x1 - 1\ny2 -= y1 - 1\nx1 = 1\ny1 = 1\nxo = (x2 - x1 + 1) // 2 + (1 if abs(x1) % 2 == 1 and abs(x2) % 2 == 1 else 0)\nxe = (x2 - x1 + 1) // 2 + (1 if abs(x1) % 2 == 0 and abs(x2) % 2 == 0 else 0)\nyo = (y2 - y1 + 1) // 2 + (1 if abs(y1) % 2 == 1 and abs(y2) % 2 == 1 else 0)\nye = (y2 - y1 + 1) // 2 + (1 if abs(y1) % 2 == 0 and abs(y2) % 2 == 0 else 0)\nprint(xo * yo + xe * ye)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\ndx = x2 - x1\ndy = y2 - y1\n\nA = (dx // 2 + 1)\nB = (dy // 2 + 1)\n\nprint(A * B + (dx // 2) * ((dy + 1) // 2))\n"}, {"source_code": "x1,y1,x2,y2 = map(int,input().split())\ns = (x2-x1+1)*((y2-y1+1)//2) + ((x2-x1+2)//2)*((y2-y1+1)%2)\nprint(s)"}, {"source_code": "import os, sys, pdb\nimport time, calendar, datetime\nimport math, itertools\nimport operator as op\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer // denom\n\nx1, y1, x2, y2 = list(map(int, input().split()))\nprint( ((x2 - x1 + 1) * (y2 - y1 + 1) + 1)//2 )\n\n\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\n\nt = (y2 - y1) // 2 + 1\nr = (x2 - x1) + 1\n#print(t, r)\nprint((r+1)//2 * t + r//2*(t-1))"}, {"source_code": "from sys import stdin,stdout\nfrom math import gcd, ceil, sqrt\nii1 = lambda: int(stdin.readline().strip())\nis1 = lambda: stdin.readline().strip()\niia = lambda: list(map(int, stdin.readline().strip().split()))\nisa = lambda: stdin.readline().strip().split()\nmod = 1000000007\n\nx1, y1, x2, y2 = iia()\nprint(((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2)\n"}, {"source_code": "x,y,a,b = map(int,input().split(\" \"))\n\n\nresult = ( a-x+1 ) * ( (b-y)//2 + 1 ) - ( (a-x)//2 )\n\nprint(result)"}, {"source_code": "x, u, y, v = map(int, input().split())\nN, M = y - x + 1, v - u + 1\nn, m = (N >> 1) * (N&1), (M >> 1) * (M&1)\nprint((N - n)*(M - m) + n*m)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\nlen_y = (abs(y1 - y2) + 1) // 2 + (abs(y1-y2) + 1) % 2\nlen_x = abs(x1 - x2) + 1\n\nprint(len_x * len_y - len_x//2)"}, {"source_code": "x1, y1, x2, y2 = map(int,input().split())\nprint(((y2 - y1)//2 + 1) * ((x2 - x1)//2 + 1) + ((y2 - y1)//2) * ((x2 - x1)//2))\n"}, {"source_code": "import math\n\ndef main():\n x1, y1, x2, y2 = map(int, input().split())\n y, x = y2-y1, (x2-x1)//2\n ans = 0\n ans += (1+x)*(y//2 + 1)\n ans += x * (math.ceil(y/2))\n print(ans)\n\n\nmain()"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split(' '))\nif x1 > x2:\n x1, x2 = x2, x1\nif y1 > y2:\n y1, y2 = y2, y1\n\nif (x2-x1)%2:\n ans = (x2-x1+1)*(y2-y1+1)//2\nelse:\n ans = (y2-y1+1)*(x2-x1)//2+(y2-y1)//2+1\n\nprint(ans)\n"}, {"source_code": "xo, yo, xk, yk = map(int, input().split())\nprint((xk - xo + 1) * (yk - yo + 1) // 2 + 1)"}, {"source_code": "x1, y1, x2, y2 = input().split()\ndx, dy = int(x2)-int(x1), int(y2)-int(y1)\nif(dy%2!=0):\n print((dy+1)//2*(dx+1))\nelse:\n print((dy//2+1)*(dx//2+1)+dy//2*dx//2)"}, {"source_code": "import math\n\na, b, c, d = map(lambda x: int(x), input().split(' '))\n\nh = 0\nw = c - a + 1\n\nh += (d - b + 1) // 2\n\nsumm = h * w\n\nif((a + b) % 2 == 0):\n if(d - b) % 2 == 0:\n summ += w // 2 + w % 2\nelse:\n if(d - b) % 2 == 0:\n summ += w // 2 + w % 2\n\nprint(summ)"}, {"source_code": "a,b,c,d = map(int,input().split(\" \"))\n\nf = (c-a+1)*(d-b+1)\nprint((f+1)//2)"}, {"source_code": "ch=input()\nd=ch.split(\" \")\nx1=int(d[0])\ny1=int(d[1])\nx2=int(d[2])\ny2=int(d[3])\n\nnby=(y2-y1)//2+1\nnbx=(x2-x1)//2+1\nprint(nby*nbx+(nby-1)*(nbx-1))\n"}, {"source_code": "def get_len(x, y1, y2):\n if x % 2 == 1:\n if y1 % 2 != 0:\n y1 -= 1\n if y2 % 2 != 0:\n y2 += 1\n else:\n if y1 % 2 == 0:\n y1 -= 1\n if y2 % 2 == 0:\n y2 += 1\n return (y2 - y1) // 2\n\n\nx1, y1, x2, y2 = map(int, input().split())\nif x1 % 2 != y1 % 2:\n y1 += 1\n y2 += 1\n\nfs, sc, cnt = 0, 0, 0\n\ncnt = x2 - x1 + 1\nfs = get_len(x1, y1, y2)\nsc = get_len(x1 + 1, y1, y2)\n\n#print(cnt, fs, sc)\n\nprint((fs + sc) * (cnt // 2) + fs)\n"}, {"source_code": "x1,y1,x2,y2=map(int,input().split())\nprint(((x2-x1)//2+1)*((y2-y1)//2+1)+((x2-x1)//2)*((y2-y1)//2))"}, {"source_code": "x1, y1, x2, y2 = list(map(int, input().split(' ')))\nprint(((x2 - x1) // 2 + 1) * ((y2 - y1) // 2 + 1) + ((x2 - x1) // 2) * ((y2 - y1) // 2))"}, {"source_code": "# https://codeforces.com/contest/630/problem/E\n\nimport sys\nimport math\n\n\ndef main():\n # sys.stdin = open('E:\\\\Sublime\\\\in.txt', 'r')\n # sys.stdout = open('E:\\\\Sublime\\\\out.txt', 'w')\n # sys.stderr = open('E:\\\\Sublime\\\\err.txt', 'w')\n\n # n = int(sys.stdin.readline().strip())\n x1, y1, x2, y2 = map(int, sys.stdin.readline().strip().split()[:4])\n \n print(((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2)\n\n\nif __name__ == '__main__':\n main()\n\n# hajj\n# \u3000\u3000\u3000\u3000\u3000\u3000 \uff3f\uff3f\n# \u3000\u3000\u3000\u3000\u3000\uff0f\uff1e\u3000\u3000\u30d5\n# \u3000\u3000\u3000\u3000\u3000| \u3000_\u3000 _ l\n# \u3000 \u3000\u3000\u3000\uff0f` \u30df\uff3fx\u30ce\n# \u3000\u3000 \u3000 /\u3000\u3000\u3000 \u3000 |\n# \u3000\u3000\u3000 /\u3000 \u30fd\u3000\u3000 \uff89\n# \u3000 \u3000 \u2502\u3000\u3000|\u3000|\u3000|\n# \u3000\uff0f\uffe3|\u3000\u3000 |\u3000|\u3000|\n# \u3000| (\uffe3\u30fd\uff3f_\u30fd_)__)\n# \u3000\uff3c\u4e8c\u3064\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\n\ndx, dy = (x2 - x1) // 2, (y2 - y1) // 2\nprint(dx + 1 + (2 * dx + 1) * dy)"}, {"source_code": "def main():\n x1, y1, x2, y2 = map(int, input().split())\n print((y2 - y1 + 2) // 2 * (x2 - x1 + 1) - (x2 - x1) // 2)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "x1,y1,x2,y2 = map(int, input().split())\nx = x2 - x1\ny = y2 - y1\nprint((y//2+(y//2+1))*x//2+y//2+1)"}, {"source_code": "\ndef main():\n\t# take in input\n\tx1, y1, x2, y2 = raw_input().split()\n\tx1 = int(x1); x2 = int(x2); y1 = int(y1); y2 = int(y2)\n\tsameX = (x1 % 2 == x2 % 2)\n\tsameY = (y1 % 2 == y2 % 2)\n\tmaxHeight = int((y2 - y1)/2) + 1\n\twidth = x2 - x1 + 1\n\tval = 0\n\tif sameY:\n\t\tif sameX:\n\t\t\tval = maxHeight*(int(width/2) + 1) + (maxHeight - 1)*(int(width/2))\n\t\telse:\n\t\t\tval = maxHeight*(int(width/2)) + (maxHeight - 1)*(int(width/2))\n\telse:\n\t\tval = maxHeight*width\n\tprint val\n\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nprint (x2 - x1) / 2 * ((y2 - y1) / 2) + ((x2 - x1) / 2 + 1) * ((y2 - y1) / 2 + 1)\n"}, {"source_code": "a, b, c, d = map(int, input().split(' '))\ndy = (d-b)//2+1\ndx = c - a + 1\nprint(dy*dx - (dx//2))"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nn = abs(x2 - x1)\nm = abs(y2 - y1)\ngood_start = abs(x1 + y1) % 2 == 0\nans = (n / 2) * (m + 1)\nans += (m / 2) + 1\nprint ans"}, {"source_code": "x1,y1,x2,y2=map(int,raw_input().split())\nx1+=1000000000\ny1+=1000000000\nx2+=1000000000\ny2+=1000000000\nt1=(x1%2)^(y1%2)^1\nt2=(x1%2)^(y2%2)^1\nt3=((x1+1)%2)^(y1%2)^1\nt4=((x1+1)%2)^(y2%2)^1\n\nif(t1==1 and t2==1):a=(y2-y1+1+1)/2\nelse :\n\tif(t1==0 and t2==0):a=(y2-y1)/2\n\telse\t:a=(y2-y1+1)/2\n\nif(t3==1 and t4==1):b=(y2-y1+1+1)/2\nelse :\n\tif(t3==0 and t4==0):b=(y2-y1)/2\n\telse\t:b=(y2-y1+1)/2\n\nif (x2-x1+1)%2:print (x2-x1+1)/2*(a+b)+max(a,b)\nelse :print (x2-x1+1)/2*(a+b)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\nn = (y2 - y1) // 2 + 1\nk = x2 - x1 + 1\nprint(n * (k // 2 + 1) + (n - 1) * (k // 2))\n"}, {"source_code": "x1,y1,x2,y2 = map(int,raw_input().split())\n\n\nx = x2 - x1\ny = y2 - y1\n\nif x % 2 == 0:\n hori = (x/2)+1\n if x1 % 2 == 1:\n print (y+1) * hori - y/2 \n\n else:\n print (y+1) * hori - (y+1)/2 \n\nelse:\n hori = (x+1)/2\n print (y+1) * hori\n \n"}, {"source_code": "A, B, C, D = map(int, raw_input().split())\nprint (C - A + 1) * (D - B + 1) // 2 + 1"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\nx1, y1, x2, y2 = map(int, raw_input().split())\n\nif x1 % 2 != y1 % 2:\n y1 -= 1\n y2 -= 1\n\nx1o = x1 if x1 % 2 == 1 else x1 + 1\nx1e = x1 if x1 % 2 == 0 else x1 + 1\nx2o = x2 if x2 % 2 == 1 else x2 - 1\nx2e = x2 if x2 % 2 == 0 else x2 - 1\n\no = (x2o - x1o) / 2 + 1\ne = (x2e - x1e) / 2 + 1\n\ny1o = y1 if y1 % 2 == 1 else y1 + 1\ny1e = y1 if y1 % 2 == 0 else y1 + 1\ny2o = y2 if y2 % 2 == 1 else y2 - 1\ny2e = y2 if y2 % 2 == 0 else y2 - 1\n\noa = (y2o - y1o) / 2 + 1\nea = (y2e - y1e) / 2 + 1\n\nprint oa * o + ea * e\n"}, {"source_code": "x1, y1, x2, y2 = (int(i) for i in raw_input().split())\n\nxl = x2 - x1 + 1\nyl = y2 - y1 + 1\nif x1 % 2:\n xc = xl / 2\n xnc = xl - xc\nelse:\n xnc = xl / 2\n xc = xl - xnc\n\nif y1 % 2:\n yc = yl / 2\n ync = yl - yc\nelse:\n ync = yl / 2\n yc = yl - ync\n\nif (x1%2 == y1%2):\n print xc*yc+xnc*ync\nelse:\n print xc*ync+xnc* yc"}, {"source_code": "x1, y1, x2, y2 = (int(i) for i in raw_input().split())\n\nxl = x2 - x1 + 1\nyl = y2 - y1 + 1\nif x1 % 2:\n xc = xl / 2\n xnc = xl - xc\nelse:\n xnc = xl / 2\n xc = xl - xnc\n\nif y1 % 2:\n yc = yl / 2\n ync = yl - yc\nelse:\n ync = yl / 2\n yc = yl - ync\n\nif (x1%2 == y1%2):\n print xc*yc+xnc*ync\nelse:\n print xc*ync+xnc*yc"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\nprint (c - a + 1) * (d - b + 1) + 1 >> 1\n"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\nsum_ = ((c - a) * (d - b) / 4) + ((c - a) / 2 + 1) * ((d - b) / 2 + 1)\nprint sum_\n"}, {"source_code": "x1,y1,x2,y2 = map (int,raw_input().split())\nx = x2-x1+1\ny = y2-y1+1\nxy = 0\nif y%2 == 1:\n Y=(y+1)/2\nelse:\n Y = y/2\nif x%2 == 1:\n if y%2 == 1:\n xy = x*Y - x/2\n else:\n xy = x*Y\nelse:\n if y%2 == 1:\n xy = x*Y - x/2\n else:\n xy = x*Y\nprint xy\n"}, {"source_code": "import math\nx1,y1,x2,y2=[int(x) for x in raw_input().split()]\nx=abs(x1-x2)+1\ny=abs(y1-y2)+1\nif y%2==0:\n y=y/2\n print(x*y)\nelse:\n y=y/2\n ans=x*y\n ans+=int(math.ceil(x/2.0))\n print(ans)\n\n\n"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split(' '))\nprint ((y2-y1)/2+1)*(x2-x1+1)-(x2-x1)/2"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\n\ndx = x2 - x1\ndy = y2 - y1\n\nif dx % 2 == 0:\n\teven = dx / 2 + 1\n\todd = dx / 2\nelse:\n\teven = (dx + 1) / 2\n\todd = even\n\nres = 0\nif dy % 2 == 0:\n\tres = even * (dy / 2 + 1) + odd * (dy / 2)\nelse:\n\tres = even * (dy / 2 + 1) + odd * (dy / 2 + 1)\n\nprint res\n"}, {"source_code": "x1, y1, x2, y2 = raw_input().split(' ')\nx1 = long(x1)\nx2 = long(x2)\ny1 = long(y1)\ny2 = long(y2)\nprint ((y2 - y1) / 2 + 1) * (x2 - x1 + 1) - (x2 - x1) / 2"}, {"source_code": "A, B, C, D = map(int, raw_input().split())\nprint (C - A + 1) * (D - B + 1) // 2 + 1"}, {"source_code": "x,y,xx,yy=map(int,raw_input().split())\ndy=abs(yy-y)\ndx=abs(x-xx)\nprint (dx/2+1)*(dy/2+1)+(dx/2)*dy/2"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split()) \na = (x2-x1) / 2\nb = a + 1\nprint (y2-y1+1)/2*a+(y2-y1+2)/2*b\n"}, {"source_code": "x0,y0,x,y = (int(i) for i in raw_input().split(\" \"))\n\nx -= x0 - 1\ny -= y0 - 1\n\nr = x * ((y + 1) // 2)\nif y % 2:\n r -= x // 2\n\nprint r\n"}, {"source_code": "x_1, y_1, x_2, y_2 = map(int, raw_input().split())\nprint ((x_2 - x_1 + 1) * (y_2 - y_1 + 1) + 1) / 2\n"}], "negative_code": [{"source_code": "from sys import stdin\nx1, y1, x2, y2 =map(int, stdin.readline().split())\ndx = x2 - x1\ndy = y2 - y1\nresult2 = (dx + 1)*(dy + 1)\n\ndef even(x):\n return x % 2 == 0\n\nif even(dx) and even(dy):\n if even(x1 + y1):\n result2 = result2 + 1\n else:\n result2 = result2 - 1\n \nprint(int(result2//2))"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nres = 0\ndef down_to_odd(x):\n if x % 2 == 0: return x - 1\n else: return x\ndef down_to_even(x):\n if x % 2 == 1: return x - 1\n else: return x\ndef up_to_odd(x):\n if x % 2 == 0: return x + 1\n else: return x\ndef up_to_even(x):\n if x % 2 == 1: return x + 1\n else: return x\n\nif x1 % 2 == 1:\n low, up = up_to_odd(y1), down_to_odd(y2)\n res += ((x2 - x1) / 2 + 1) * ((up - low) / 2 + 1)\n low, up = up_to_even(y1), down_to_even(y2)\n res += ((x2 - x1) / 2) * ((up - low) / 2 + 1)\nelse:\n low, up = up_to_even(y1), down_to_even(y2)\n res += ((x2 - x1) / 2 + 1) * ((up - low) / 2 + 1)\n low, up = up_to_odd(y1), down_to_odd(y2)\n res += ((x2 - x1) / 2) * ((up - low) / 2 + 1)\nprint res\n"}, {"source_code": "def main():\n x1, y1, x2, y2 = map(int, input().split())\n w, h = (x2 - x1) // 2, (y2 - y1) // 2\n print(2 * w * h + w + h + ((x1 ^ y1 ^ 1) & 1))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "A, B, C, D = map(int, raw_input().split())\nprint (C - A + 1) * (D - B + 1) // 2"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nif x1 == x2 or y1 == y2:\n print(0)\nelse:\n print((x2-x1+1)*(y2-y1+1)//2 + ((y2-y1)%2 == 0 and (x1+y1)%2 == 0))\n\n"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x1 == -1000000000 and y1 == -1000000000:\n\t\tn=2000000002000000001\nelif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telif x1 % 2 == 1 and y1 % 2 == 1:\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "x1,y1,x2,y2 = map(int,raw_input().split());\nn = x2 - x1;\nm = n/2 + (x1%2);\nn /= 2;\nh = y2 - y1 - y1%2;\nprint h*m + (h - 1)*n;\n"}, {"source_code": "x1 , y1 , x2 , y2 = map(int , raw_input().split())\nx1 += 10000000000\ny1 += 10000000000\nx2 += 10000000000\ny2 += 10000000000\nres1 = (x2 / 2) - ((x1 - 1) / 2)\nres2 = x2 - x1 + 1 - res1\nres3 = (y2 / 2) - ((y1 - 1) / 2)\nres4 = y2 - y1 + 1 - res3\nprint (x2 - x1 + 1) * (y2 - y1 + 1) - res1 * res4 - res2 * res3"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif (y2 - y1) % 2:\n print (y2 - y1 + 1) / 2 * (x2 - x1 + 1)\nelse:\n t = (y2 - y1) / 2 + (y1 - x1 + 1) % 2\n s = t + (y2 - y1) / 2 + (y1 - x1) % 2\n print t + s * (x2 - x1) / 2\n"}, {"source_code": "from sys import stdin\nx1, y1, x2, y2 = map(int, stdin.readline().split())\ndx = x2 - x1\ndy = y2 - y1\nresult2 = (dx + 1)*(dy + 1)\n\ndef even(x):\n return x % 2 == 0\n\nif even(dx) and even(dy):\n if even(x1 + y1):\n result2 = result2 + 1\n else:\n result2 = result2 - 1\n \nprint(int(result2/2))"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nif x1 == x2 or y1 == y2:\n print(0)\nelse:\n print((x2-x1+1)*(y2-y1+1)//2 + ((y2-y1)%2 == 0 and (x1+y1)%2 == 0))\n\n"}, {"source_code": "#!/usr/bin/python3\n# Copyright (C) 2016 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; If not, see <http://www.gnu.org/licenses/>.\n\ndef calc(y1, y2, r):\n if y1 % 2 != r:\n y1 -= 1\n if y2 % 2 != r:\n y2 += 1\n return (y2 - y1) // 2\n\nx1, y1, x2, y2 = map(int, input().split())\n\nxlen = x2 - x1 + 1\nodd, even = xlen // 2, xlen // 2\nif xlen % 2 == 1:\n if x1 % 2 == 1:\n odd += 1\n else:\n even += 1\nprint(odd, even)\nprint(odd * calc(y1, y2, 0) + even * calc(y1, y2, 1))\n"}, {"source_code": "l,d,r,u = map(int, raw_input().split())\nprint int((r-l+1) * ((u-d)/2+0.5)) + 1"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "x1 , y1 , x2 , y2 = map(int , raw_input().split())\nx1 += 10000000000\ny1 += 10000000000\nx2 += 10000000000\ny2 += 10000000000\nres1 = (x2 / 2) - ((x1 - 1) / 2)\nres2 = x2 - x1 + 1 - res1\nres3 = (y2 / 2) - ((y1 - 1) / 2)\nres4 = y2 - y1 + 1 - res3\nans = (x2 - x1 + 1) * (y2 - y1 + 1) - res1 * res4 - res2 * res3\nprint ans % (1000000007)"}, {"source_code": "import math\n\na, b, c, d = map(lambda x: int(x), input().split(' '))\n\nh = 0\nw = c - a + 1\n\nh += (d - b) // 2\n\nsumm = h * w\n\nif((a + b) % 2 == 0):\n if(d - b) % 2 == 0:\n summ += w // 2 + w % 2\nelse:\n if(d - b) % 2 == 0:\n summ += w // 2\n\nprint(summ)"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif (y2 - y1) % 2:\n print (y2 - y1 + 1) / 2 * (x2 - x1 + 1)\nelse:\n t = (y2 - y1) / 2 + (y1 - x1 + 3000000001) % 2\n s = t + (y2 - y1) / 2 + (y1 - x1 + 300000000) % 2\n p, r = divmod(x2 - x1 + 1, 2)\n print t * r + s * p\n"}, {"source_code": "x1, y1, x2, y2 = input().split()\ndx, dy = int(x2)-int(x1), int(y2)-int(y1)\nif(dy%2!=0):\n print((dy+1)//2*(dx+1))\nelse:\n print((dy//2+1)*(dx//2+1)+dy//2*dx//2 - int(int(x1)-int(y1)%2!=0))\n"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\nprint (c - a + 1) * (d - b + 1) + (a % 2 == c % 2 and b % 2 == d % 2 and (a + b) % 2 == 0) >> 1\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\n\nodd_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 0 and x2 % 2 == 0 else 0)\nodd_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 0 and y2 % 2 == 0 else 0)\neven_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 1 and x2 % 2 == 0 else 1)\neven_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 1 and y2 % 2 == 0 else 1)\n\nprint(odd_x * odd_y + even_x * even_y)\n"}, {"source_code": "def main():\n x1, y1, x2, y2 = map(int, input().split())\n w, h = (x2 - x1) // 2, (y2 - y1) // 2\n print(2 * w * h + w + h + ((x1 ^ y1 ^ 2) & 2) // 2)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin\nx1, y1, x2, y2 = map(int, stdin.readline().split())\ndx = x2 - x1\ndy = y2 - y1\nresult2 = (dx + 1)*(dy + 1)\n\ndef even(x):\n return x % 2 == 0\n\nif even(dx) and even(dy):\n if even(x1 + y1) and even(dy/2):\n result2 = result2 + 1\n else:\n result2 = result2 - 1\n \nprint(int(result2//2))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telse:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "\nx1, y1, x2, y2 = map(int, input().split())\n\ndx = x2 - x1\ndy = y2 - y1\n\nux = uy = False\n\nif dx % 2 == 1:\n ux = True\n dx += 1\n\nif dy % 2 == 1:\n uy = True\n dy += 1\n\nresx = dx/2+1\nresy = dy/2+1\n\ntotal = resx*resy + (resx-1)*(resy-1)\n\n#print (int(total))\n\nif ux or uy:\n total -= 1\n if ux:\n total -= dy/2\n if uy:\n total -= dx/2\n\nprint (int(total))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y <= 1000000:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x1 % 2 == 1 or y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 or y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "#!/usr/bin/python3\n# Copyright (C) 2016 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; If not, see <http://www.gnu.org/licenses/>.\n\ndef calc(y1, y2, r):\n if y1 % 2 != r:\n y1 -= 1\n if y2 % 2 != r:\n y2 += 1\n return (y2 - y1) // 2\n\nx1, y1, x2, y2 = map(int, input().split())\n\nxlen = x2 - x1 + 1\nodd, even = xlen // 2, xlen // 2\nif xlen % 2 == 1:\n if x1 % 2 == 1:\n odd += 1\n else:\n even += 1\nprint(odd, even)\nprint(odd * calc(y1, y2, 0) + even * calc(y1, y2, 1))\n"}, {"source_code": "#!/usr/bin/python3\n# Copyright (C) 2016 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; If not, see <http://www.gnu.org/licenses/>.\n\ndef calc(y1, y2, r):\n if y1 % 2 != r:\n y1 -= 1\n if y2 % 2 != r:\n y2 += 1\n return (y2 - y1) // 2\n\nx1, y1, x2, y2 = map(int, input().split())\n\nxlen = x2 - x1 + 1\nodd, even = xlen // 2, xlen // 2\nif xlen % 2 == 1:\n if x1 % 2 == 1:\n odd += 1\n else:\n even += 1\nprint(odd, even)\nprint(odd * calc(y1, y2, 0) + even * calc(y1, y2, 1))\n"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nprint((y2-y1+1)*(x2-x1)//2+(x2-x1)//2+x1%2)"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\nx1, y1, x2, y2 = map(int, raw_input().split())\n\no = (x2 - x1) / 2 + 1\ne = (x2 - x1) / 2\n\ny1o = y1 if y1 % 2 == 1 else y1 + 1\ny1e = y1 if y1 % 2 == 0 else y1 + 1\ny2o = y2 if y2 % 2 == 1 else y2 - 1\ny2e = y2 if y2 % 2 == 0 else y2 - 1\n\noa = (y2o - y1o) / 2 + 1\nea = (y2e - y1e) / 2 + 1\n\nprint oa * o + ea * e\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split(' '))\nxo = (x2 - x1 + 1) // 2 + (1 if abs(x1) % 2 == 1 and abs(x2) % 2 == 1 else 0)\nxe = (x2 - x1 + 1) // 2 + (1 if abs(x1) % 2 == 0 and abs(x2) % 2 == 0 else 0)\nyo = (y2 - y1 + 1) // 2 + (1 if abs(y1) % 2 == 1 and abs(y2) % 2 == 1 else 0)\nye = (y2 - y1 + 1) // 2 + (1 if abs(y1) % 2 == 0 and abs(y2) % 2 == 0 else 0)\nprint(xo * yo + xe * ye)\n"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x1 == -1000000000 and y1 == -1000000000:\n\t\tn=2000000002000000001\n\t\tprint(n)\nelif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telif x1 % 2 == 1 and y1 % 2 == 1:\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "[x1, y1, x2, y2] = map(int, raw_input().split())\ndef odd(y1, y2): return (y2 + 1) / 2 - y1 / 2\ndef even(y1, y2): return odd(y1 - 1, y2 - 1)\n\nans = (x2 - x1) / 2 * (odd(y1, y2) + even(y1, y2))\nif (x1 % 2): ans += odd(y1, y2)\nelse: ans += even(y1, y1)\nprint ans\n\t\n"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\n\nodd_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 0 and x2 % 2 == 0 else 0)\nodd_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 0 and y2 % 2 == 0 else 0)\neven_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 1 and x2 % 2 == 1 else 0)\neven_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 1 and y2 % 2 == 1 else 0)\n\nprint(odd_x * odd_y + even_x * even_y)\n"}, {"source_code": "from sys import stdin\nx1, y1, x2, y2 = map(int, stdin.readline().split())\ndx = x2 - x1\ndy = y2 - y1\nresult2 = (dx + 1)*(dy + 1)\n\ndef even(x):\n return x % 2 == 0\n\nif even(dx) and even(dy):\n if even(x1 + y1):\n result2 = result2 + 1\n else:\n result2 = result2 - 1\n \nprint(int(result2//2))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt=int(x*y+x+y)\n\t\tt1=t%1000/2\n\t\tt2=t/1000/2\n\t\tn=int(t2*1000)+int(t1)+1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "def main():\n x1, y1, x2, y2 = map(int, input().split())\n w, h = x2 - x1 + 1, y2 - y1 + 1\n x1 &= 1\n w1 = w & 1\n print((w + w1) // 2 * (h - 1 + x1) - w1 * x1 * h // 2)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "x1, y1, x2, y2 = [i + 1e10 for i in list(map(int, input().split()))]\n\nprint ((int(y2 / 2) - int((y1 - 1) / 2)) * (int(x2 / 2) - int((x1 - 1) / 2)) + (int((y2 + 1) / 2) - int(y1 / 2)) * (int((x2 + 1) / 2) - int(x1 / 2)))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 1:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telif x1 % 2 == 0:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "import math\n\na, b, c, d = map(lambda x: int(x), input().split(' '))\n\nh = 0\nw = c - a + 1\n\nh += (d - b + 1) // 2\n\nsumm = h * w\n\nif((a + b) % 2 == 0):\n if(d - b) % 2 == 0:\n summ += w // 2 + w % 2\nelse:\n if(d - b) % 2 == 0:\n summ += w // 2\n\nprint(summ)"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\t\tprint(t0,t1,n)\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\n\ndx = x2 - x1\ndy = y2 - y1\n\nif dx % 2 == 0:\n\teven = dx / 2 + 1\n\todd = dx / 2\nelse:\n\teven = (dx + 1) / 2\n\todd = even\n\nres = 0\nif dy % 2 == 0:\n\tres = even * (dy - 1) + odd * (dy - 2)\nelse:\n\tres = even * (dy - 1) + odd * (dy - 1)\n\nprint res\n"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 1:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telif x1 % 2 == 0:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "l,d,r,u = map(int, raw_input().split())\nprint int((r-l+1) * ((u-d)/2+0.5) + 0.5)"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt=int(x*y+x+y)\n\t\tt1=t%1000/2\n\t\tt2=t/1000/2\n\t\tn=int(t2*1000)+int(t1)+1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nif x1 == x2 or y1 == y2:\n print(0)\nelse:\n print((x2-x1+1)*(y2-y1+1)//2 + ((y2-y1)%2 == 0 and (x1+y1)%2 == 0))\n\n"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 1:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telif x1 % 2 == 0:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "x1,y1,x2,y2=map(int,raw_input().split())\nt1=(x1%2)^(y1%2)^1\nt2=(x1%2)^(y2%2)^1\nt3=((x1+1)%2)^(y1%2)^1\nt4=((x1+1)%2)^(y2%2)^1\n\nif(t1==1 and t2==1):a=(y2-y1+1+1)/2\nelse :\n\tif(t1==0 and t2==0):a=(y2-y1)/2\n\telse\t:a=(y2-y1+1)/2\n\nif(t3==1 and t4==1):b=(y2-y1+1+1)/2\nelse :\n\tif(t3==0 and t4==0):b=(y2-y1)/2\n\telse\t:b=(y2-y1+1)/2\n\nif (x2-x1+1)%2:print (x2-x1+1)/2*(a+b)+a\nelse :print (x2-x1+1)/2*(a+b)\n"}, {"source_code": "\nx1, y1, x2, y2 = map(int, input().split())\n\ndx = x2 - x1\ndy = y2 - y1\n\nux = uy = False\n\nif dx % 2 == 1:\n ux = True\n dx += 1\n\nif dy % 2 == 1:\n uy = True\n dy += 1\n\nresx = dx/2+1\nresy = dy/2+1\n\ntotal = resx*resy + (resx-1)*(resy-1)\n\nprint (int(total))\n\nif ux or uy:\n total -= 1\n if ux:\n total -= dy/2\n if uy:\n total -= dx/2\n\nprint (int(total))"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport math\n\ndef cnt(l, r):\n if l % 2 != 0:\n l += 1\n if r % 2 != 0:\n r -= 1\n l = l // 2\n r = r // 2\n if l <= r :\n return r - l + 1\n return 0\n\ndef count(x, l, r):\n if x % 2 == 0:\n return cnt(l, r)\n else:\n return (r - l + 1) - cnt(l, r)\n\nline = input()\nline = line.split()\n\nx1 = int(line[0])\ny1 = int(line[1])\nx2 = int(line[2])\ny2 = int(line[3])\n\nans = (count(x1, y1, y2) + count(x1 + 1, y1, y2)) * (x2 - x1) // 2 + count(x1, y1, y2)\n\nprint(ans)"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 0 or y1 % 2 == 0:\t\n\t\tn= int((x * y + x + y) / 2)\n\telse:\n\t\tn= int(1 + (x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "from sys import stdin\nx1, y1, x2, y2 = map(int, stdin.readline().split())\ndx = x2 - x1\ndy = y2 - y1\nresult2 = (dx + 1)*(dy + 1)\n\ndef even(x):\n return x % 2 == 0\n\nif even(dx) and even(dy):\n if even(x1 + y1 + dy//2):\n result2 = result2 + 1\n else:\n result2 = result2 - 1\n \nprint(int(result2//2))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 1:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telif x1 % 2 == 0:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "#s=readline().split(' ')\n#a=s[2]-s[0]+1\n#b=s[3]-s[1]+1\n#c=a*b\n#if (c%2)\n#{\n# c++\n#} \n#print(c/2)\n\ns=input().split(' ')\na=int(s[2])-int(s[0])\nb=int(s[3])-int(s[1])\nc=a*b\nprint((c+1)//2)"}, {"source_code": "x1, x2, y1, y2 = map(int, raw_input().split(' '))\nprint ((y2-y1)/2+1)*(x2-x1+1)-(x2-x1)/2"}, {"source_code": "from sys import stdin\nx1, y1, x2, y2 = map(int, stdin.readline().split())\ndx = x2 - x1\ndy = y2 - y1\nresult2 = (dx + 1)*(dy + 1)\n\ndef even(x):\n return x % 2 == 0\n\nif even(dx) and even(dy):\n if even(x1 + y1 + dy//2):\n result2 = result2 + 1\n else:\n result2 = result2 - 1\n \nprint(int(result2//2))"}, {"source_code": "x1, y1, x2, y2 = input().split()\ndx, dy = int(x2)-int(x1), int(y2)-int(y1)\nif(dy%2!=0):\n print((dy+1)//2*(dx+1))\nelse:\n print((dy//2+1)*(dx//2+1)+dy//2*dx//2 - int((int(x1)-int(y1))%2!=0))\n"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nif y2 < y1 or x2 < x1:\n print(0)\nelse:\n print((x2-x1+1)*(y2-y1+1)//2 + ((y2-y1)%2 == 0 and (x1+y1)%2 == 0))\n\n"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nt = (y2 - y1) / 2 + (y1 - x1 + 1) % 2\ns = t + (y2 - y1) / 2 + (y1 - x1) % 2\nprint t + s * (x2 - x1) / 2\n"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nprint((y2-y1+1)*(x2-x1)//2+(y2-y1)//2+x1%2)"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif (y2 - y1) % 2:\n print (y2 - y1 + 1) / 2 * (x2 - x1 + 1)\nelse:\n t = (y2 - y1) / 2 + (y1 - x1 + 3000000001) % 2\n s = t + (y2 - y1) / 2 + (y1 - x1 + 300000000) % 2\n p, r = divmod(x2 - x1 + 1, 2)\n print t * r + s * p\n"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telif x1 % 2 == 1 and y1 % 2 == 1:\n\t\tn= int(1 + (x * y + x + y) / 2)\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "a,b,c,d = [int(x) for x in input().split()]\n \nprint((d-b+1)//2*(c-a+1) +1)"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif (y2 - y1) % 2:\n print (y2 - y1 + 1) / 2 * (x2 - x1 + 1)\nelse:\n t = (y2 - y1) / 2 + (y1 - x1 + 1) % 2\n s = t + (y2 - y1) / 2 + (y1 - x1) % 2\n print t + s * (x2 - x1) / 2\n"}, {"source_code": "[x1, y1, x2, y2] = map(int, raw_input().split())\ndef odd(y1, y2): return (y2 + 1) / 2 - y1 / 2\ndef even(y1, y2): return odd(y1 - 1, y2 - 1)\n\nans = (x2 - x1) / 2 * (odd(y1, y2) + even(y1, y2))\nif (x1 % 2): ans += odd(y1, y2)\nelse: ans += even(y1, y2)\nprint ans\n\t\n"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif abs(y2 - y1) % 2 == 0:\n print abs(x2 - x1) * abs(y2 - y1) - (abs(x2 - x1) / 2 + (abs(x1 + y2) % 2 == 0))\nelse:\n print abs(x2 - x1) * abs(y2 - y1) + (abs(x2 - x1) / 2)"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nprint((y2-y1+1)*(x2-x1)//2+2+x1%2)"}, {"source_code": "x1,y1,x2,y2=map(int,raw_input().split())\nx1+=1000000000\ny1+=1000000000\nx2+=1000000000\ny2+=1000000000\nt1=(x1%2)^(y1%2)^1\nt2=(x1%2)^(y2%2)^1\nt3=((x1+1)%2)^(y1%2)^1\nt4=((x1+1)%2)^(y2%2)^1\n\nif(t1==1 and t2==1):a=(y2-y1+1+1)/2\nelse :\n\tif(t1==0 and t2==0):a=(y2-y1)/2\n\telse\t:a=(y2-y1+1)/2\n\nif(t3==1 and t4==1):b=(y2-y1+1+1)/2\nelse :\n\tif(t3==0 and t4==0):b=(y2-y1)/2\n\telse\t:b=(y2-y1+1)/2\n\nif (x2-x1+1)%2:print (x2-x1+1)/2*(a+b)+a\nelse :print (x2-x1+1)/2*(a+b)\n"}, {"source_code": "a = input().split(\" \")\nx1 = int(a[0])\ny1 = int(a[1])\nx2 = int(a[2])\ny2 = int(a[3])\n\nxEvens = int((x2 - x1 + 2 - abs(x1 % 2) - abs(x2 % 2)) / 2)\nxOdds = (x2 - x1) + 1 - xEvens\n\nyEvens = int((y2 - y1 + 2 - abs(y1 % 2) - abs(y2 % 2)) / 2)\nyOdds = (y2 - y1) + 1 - yEvens\n\nprint(xEvens * yEvens + yOdds * xOdds)"}, {"source_code": "def main():\n x1, y1, x2, y2 = map(int, input().split())\n w, h = (x2 - x1) // 2, (y2 - y1) // 2\n print(2 * w * h + w + h + ((x1 ^ y1 ^ 2) & 2) // 2)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "xo, yo, xk, yk = map(int, input().split())\nf = lambda xo, yo, xk, yk: (xk // 2) * (yk // 2 - yo // 2) + (xo // 2) * (yo // 2 - yk // 2)\nprint(f(xo - 1, yo - 1, xk, yk) + f(xo, yo, xk + 1, yk + 1))"}, {"source_code": "x1,y1,x2,y2=raw_input().split()\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\n\nans=0\nif (x2-x1)%2==0:\n if x1%2==1:\n ans=(y2-y1)/2*(x2-x1+1)+((x2-x1+2)/2)\n else:\n ans=(y2-y1)/2*(x2-x1+1)-((x2-x1)/2)\nelse:\n ans=(y2-y1+1)/2*(x2-x1+1)\nprint ans\n"}, {"source_code": "q = input().split()\nx1 = int(q[0])\ny1 = int(q[1])\nx2 = int(q[2])\ny2 = int(q[3])\n\nn = abs(x2-x1)+1\n\nn = n//2\n\nprint((2*((2*1+2*(n-1))))+(n*2+1))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt=int(x*y+x+y)\n\t\tt1=t%1000/2\n\t\tt2=t/1000/2\n\t\tn=int(t2*1000)+int(t1)+1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "import math\n\na = input().split(\" \")\nx1 = int(a[0])\ny1 = int(a[1])\nx2 = int(a[2])\ny2 = int(a[3])\n\ntotal = 0\n\nxlen = x2 - x1 + 1\n\nylarge = ((y2 - y1)/2) + 1\nysmall = (y2 - y1) / 2\n\ntotal += ysmall * math.floor(xlen / 2.0)\ntotal += ylarge * math.ceil(xlen / 2.0)\n\nprint(int(total))"}, {"source_code": "def main():\n x1, y1, x2, y2 = map(int, input().split())\n w, h = x2 - x1 + 1, y2 - y1 - 2\n if (x1 ^ y1 ^ 1) & 1:\n res = (w - w // 2) * (h + 1) + (w // 2) * h\n else:\n res = (w - w // 2) * h + (w // 2) * (h - 1)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a, b, c, d = map(int, input().split())\nif b % 2 != d % 2:\n print((abs(b - d) + 1) // 2 * (abs(c - a) + 1))\nelif b % 2 == 1:\n if (a % 2 == 0) and (c % 2 == 0):\n print((abs(b - d) // 2) * (abs(c - a) // 2 + 1) + (abs(b - d) // 2 + 1) * (abs(c - a) // 2))\n elif (a % 2 == 1) and (c % 2 == 1):\n print(((abs(b - d) + 2) // 2) * ((abs(c - a) + 2) // 2) + (abs(b - d) // 2) * (abs(c - a) // 2))\n else:\n print((abs(b - d) // 2 + 1) * ((abs(c - a) + 1) // 2) + (abs(b - d) // 2) * ((abs(c - a) + 1) // 2))\nelse:\n if (a % 2 == 0) and (c % 2 == 0):\n print((abs(b - d) // 2 + 1) * (abs(c - a) // 2 + 1) + (abs(b - d) // 2) * (abs(c - a) // 2))\n elif (a % 2 == 1) and (c % 2 == 1):\n print((abs(b - d) // 2 + 1) * (abs(c - a) // 2) + (abs(b - d) // 2) * (abs(c - a) // 2) + 1)\n else:\n print((abs(b - d) // 2 + 1) * ((abs(c - a) + 1) // 2) + (abs(b - d) // 2) * ((abs(c - a) + 1) // 2))\nprint((abs(b - d) // 2 + 1) * (abs(c - a) // 2 ) + (abs(b - d) // 2) * (abs(c - a) // 2 + 1))"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx = x2 - x1\ny = y2 - y1\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn=int(( x + 1 ) * (y + 1) / 2)\n\telif x1 % 2 == 0 or y1 % 2 == 0:\t\n\t\tn= int((x * y + x + y) / 2)\n\telse:\n\t\tn= int(1 + (x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\n\t\t\nprint(n)\t\n"}, {"source_code": "x1,y1,x2,y2=raw_input().split()\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\n\nans=0\nif (x2-x1)%2==0:\n if x1%2==1:\n ans=(y2-y1)/2*(x2-x1+1)+((x2-x1+2)/2)\n else:\n ans=(y2-y1)/2*(x2-x1+1)-((x2-x1)/2)\nelse:\n ans=(y2-y1+1)/2*(x2-x1+1)\nprint ans\n"}, {"source_code": "def get_len(x, y1, y2):\n if x % 2 == 1:\n if y1 % 2 == 1:\n y1 -= 1\n if y2 % 2 == 1:\n y2 += 1\n else:\n if y1 % 2 == 0:\n y1 += 1\n if y2 % 2 == 0:\n y2 -= 1\n return (y2 - y1) // 2\n\nx1, y1, x2, y2 = map(int, input().split())\n\nfs, sc, cnt = 0, 0, 0\n\ncnt = x2 - x1 + 1\nfs = get_len(x1, y1, y2)\nsc = get_len(x1 + 1, y1, y2)\n\nif cnt % 2 == 0:\n print((fs + sc) * cnt // 2)\nelse:\n print((fs + sc) * (cnt // 2) + fs)\n"}, {"source_code": "A, B, C, D = map(int,raw_input().strip().split())\nF = (C - A) // 2\nE = C - A + 1 - F\nANS = 0\nTB = B\nTD = D\nif A % 2 != TB % 2:\n TB += 1\nif A % 2 != TD % 2:\n TD -= 1\nANS += ((TD - TB) // 2 + 1) * E\nTB = B\nTD = D\nif A % 2 == TB % 2:\n TB += 1\nif A % 2 == TD % 2:\n TD -= 1\nANS += ((TD - TB) // 2 + 1) * F\nprint ANS"}, {"source_code": "x1, y1, x2, y2 = map(int, input().split())\n\nodd_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 0 and x2 % 2 == 0 else 0)\nodd_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 0 and y2 % 2 == 0 else 0)\neven_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 1 and x2 % 2 == 1 else 0)\neven_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 1 and y2 % 2 == 1 else 0)\n\nprint(odd_x * odd_y + even_x * even_y)\n"}, {"source_code": "x1,y1,x2,y2 = map(int,raw_input().split());\nn = x2 - x1;\nm = n/2 + 1;\nn /= 2;\nh = y2 - y1 - 1;\nprint h*m + (h - 1)*n;\n"}, {"source_code": "l,d,r,u = map(int, raw_input().split())\nprint int((r-l+1) * ((u-d)/2+0.5)) + 1"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif abs(y2 - y1) % 2 == 0:\n print abs(x2 - x1) * abs(y2 - y1) - (abs(x2 - x1) / 2 + (abs(x1 + y2) % 2 == 0))\nelse:\n print abs(x2 - x1) * abs(y2 - y1) + (abs(x2 - x1) / 2)"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\t\tprint(t0,t1,n)\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "A, B, C, D = map(int,raw_input().strip().split())\nF = (C - A) // 2\nE = C - A + 1 - F\nANS = 0\nTB = B\nTD = D\nif A % 2 != TB % 2:\n TB += 1\nif A % 2 != TD % 2:\n TD -= 1\nANS += ((TD - TB) // 2 + 1) * E\nTB = B\nTD = D\nif A % 2 == TB % 2:\n TB += 1\nif A % 2 == TD % 2:\n TD -= 1\nANS += ((TD - TB) // 2 + 1) * F\nprint ANS"}, {"source_code": "x1, y1, x2, y2 = [int(x) for x in input().split()]\nprint((y2-y1+1)*(x2-x1)//2+2+x1%2)"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\nprint (c - a + 1) * (d - b + 1) + (a % 2 == c % 2 and b % 2 == d % 2 and (a + b) % 2 == 0) >> 1\n"}, {"source_code": "#s=readline().split(' ')\n#a=s[2]-s[0]+1\n#b=s[3]-s[1]+1\n#c=a*b\n#if (c%2)\n#{\n# c++\n#} \n#print(c/2)\n\ns=input().split(' ')\na=int(s[2])-int(s[0])\nb=int(s[3])-int(s[1])\nc=a*b\nprint((c+1)//2)"}, {"source_code": "def get_len(x, y1, y2):\n if x % 2 == 1:\n if y1 % 2 == 1:\n y1 -= 1\n if y2 % 2 == 1:\n y2 += 1\n else:\n if y1 % 2 == 0:\n y1 += 1\n if y2 % 2 == 0:\n y2 -= 1\n return (y2 - y1) // 2\n\nx1, y1, x2, y2 = map(int, input().split())\n\nfs, sc, cnt = 0, 0, 0\n\ncnt = x2 - x1 + 1\nfs = get_len(x1, y1, y2)\nsc = get_len(x1 + 1, y1, y2)\n\nif cnt % 2 == 0:\n print((fs + sc) * cnt // 2)\nelse:\n print((fs + sc) * (cnt // 2) + fs)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif (y2 - y1) % 2:\n print (y2 - y1 + 1) / 2 * (x2 - x1 + 1)\nelse:\n t = (y2 - y1) / 2 + (y1 - x1 + 1) % 2\n s = t + (y2 - y1) / 2 + (y1 - x1) % 2\n print t + s * (x2 - x1) / 2\n"}, {"source_code": "x1 , y1 , x2 , y2 = map(int , raw_input().split())\nx1 += 10000000000\ny1 += 10000000000\nx2 += 10000000000\ny2 += 10000000000\nres1 = (x2 / 2) - ((x1 - 1) / 2)\nres2 = x2 - x1 + 1 - res1\nres3 = (y2 / 2) - ((y1 - 1) / 2)\nres4 = y2 - y1 + 1 - res3\nprint (x2 - x1 + 1) * (y2 - y1 + 1) - res1 * res4 - res2 * res3"}, {"source_code": "\nx1, y1, x2, y2 = map(int, input().split())\n\ndx = x2 - x1\ndy = y2 - y1\n\n#ux = False\n#uy = False\n\n#if dx % 2 == 1:\n# ux = True\n# dx += 1\n\n#if dy % 2 == 1:\n# uy = True\n# dy += 1\n\nresx = dx/2+1\nresy = dy/2+1\n\ntotal = resx*resy + (resx-1)*(resy-1)\n\nprint (int(total))\nexit()\n\nif ux or uy:\n total -= 1\n if ux:\n total -= dy/2\n if uy:\n total -= dx/2\n\nprint (int(total))"}, {"source_code": "A, B, C, D = map(int,raw_input().strip().split())\nA -= 1\nB -= 1\nprint ((C>>1)-(A>>1))*((D>>1)-(B>>1))+(((C+1)>>1)-((A+1)>>1))*(((D+1)>>1)-((B+1)>>1))"}, {"source_code": "x1,y1,x2,y2=map(int,raw_input().split())\nt1=(x1%2)^(y1%2)^1\nt2=(x1%2)^(y2%2)^1\nt3=((x1+1)%2)^(y1%2)^1\nt4=((x1+1)%2)^(y2%2)^1\n\nif(t1==1 and t2==1):a=(y2-y1+1+1)/2\nelse :\n\tif(t1==0 and t2==0):a=(y2-y1)/2\n\telse\t:a=(y2-y1+1)/2\n\nif(t3==1 and t4==1):b=(y2-y1+1+1)/2\nelse :\n\tif(t3==0 and t4==0):b=(y2-y1)/2\n\telse\t:b=(y2-y1+1)/2\n\nif (x2-x1+1)%2:print (x2-x1+1)/2*(a+b)+a\nelse :print (x2-x1+1)/2*(a+b)\n"}, {"source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nif (y2 - y1) % 2:\n print (y2 - y1 + 1) / 2 * (x2 - x1 + 1)\nelse:\n t = (y2 - y1) / 2 + (y1 - x1 + 1) % 2\n s = t + (y2 - y1) / 2 + (y1 - x1) % 2\n print t + s * (x2 - x1) / 2\n"}, {"source_code": "def main():\n x1, y1, x2, y2 = map(int, input().split())\n w, h = x2 - x1 + 1, y2 - y1 - 2\n if (x1 ^ y1 ^ 1) & 1:\n res = (w - w // 2) * (h + 1) + (w // 2) * h\n else:\n res = (w - w // 2) * h + (w // 2) * (h - 1)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "x1,y1,x2,y2 = input().split( )\nx1=int(x1)\ny1=int(y1)\nx2=int(x2)\ny2=int(y2)\nx =int(x2 - x1)\ny =int(y2 - y1)\nif x % 2 == 0:\n\tif y % 2 == 1:\t\n\t\tn= int(int( x + 1 ) * int(y + 1) / 2)\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x1 % 2 == 0 and y1 % 2 == 0 and x * y <= 1000000:\t\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telif x1 % 2 == 1 or y1 % 2 == 1 and x * y <= 1000000:\n\t\tn= int(int(x * y + x + y) / 2) + 1\n\telif x1 % 2 == 1 or y1 % 2 == 1 and x * y > 1000000:\n\t\tt0=int(x*y)+int(x)+int(y)\n\t\tt1=int(t0)//2\n\t\tn=int(t1)+1\n\telse:\n\t\tn= int((x * y + x + y) / 2)\nelse:\n\tn = int((x + 1) / 2 * ( y + 1 ))\nprint(n)\n\t\n"}, {"source_code": "a, b, c, d = map(int, input().split())\nif b % 2 != d % 2:\n print((abs(b - d) + 1) // 2 * (abs(c - a) + 1))\nelif b % 2 == 1:\n if (a % 2 == 0) and (c % 2 == 0):\n print((abs(b - d) // 2) * (abs(c - a) // 2 + 1) + (abs(b - d) // 2 + 1) * (abs(c - a) // 2))\n elif (a % 2 == 1) and (c % 2 == 1):\n print(((abs(b - d) + 2) // 2) * ((abs(c - a) + 2) // 2) + (abs(b - d) // 2) * (abs(c - a) // 2))\n else:\n print((abs(b - d) // 2 + 1) * ((abs(c - a) + 1) // 2) + (abs(b - d) // 2) * ((abs(c - a) + 1) // 2))\nelse:\n if (a % 2 == 0) and (c % 2 == 0):\n print((abs(b - d) // 2 + 1) * (abs(c - a) // 2 + 1) + (abs(b - d) // 2) * (abs(c - a) // 2))\n elif (a % 2 == 1) and (c % 2 == 1):\n print((abs(b - d) // 2 + 1) * (abs(c - a) // 2) + (abs(b - d) // 2) * (abs(c - a) // 2) + 1)\n else:\n print((abs(b - d) // 2 + 1) * ((abs(c - a) + 1) // 2) + (abs(b - d) // 2) * ((abs(c - a) + 1) // 2))"}, {"source_code": "A, B, C, D = map(int,raw_input().strip().split())\nA -= 1\nB -= 1\nprint ((C>>1)-(A>>1))*((D>>1)-(B>>1))+(((C+1)>>1)-((A+1)>>1))*(((D+1)>>1)-((B+1)>>1))"}], "src_uid": "00cffd273df24d1676acbbfd9a39630d"} {"source_code": "from math import sqrt, ceil\n\nn, m = map(int, input().split())\nmin = max(n - m * 2, 0)\nif m > 0:\n max = n - (1 + ceil(sqrt(8 * m + 1)) // 2)\nelse:\n max = n\nprint(min, abs(max))", "positive_code": [{"source_code": "n,m = list(map(int,input().split(\" \")))\nmn = max(0,n-2*m)\nmx = 0\nfor i in range(1,n+1):\n if(m<=i*(i-1)/2):\n mx = n-i\n break\nif m==0: mn=mx=n\nprint(mn,mx)"}, {"source_code": "n,k = map(int,input().split())\nmi=n//2\nans_min=max(n-2*k,0)\nans_max=0\nfor i in range(1,n+1):\n\ttmp=i*(i-1)/2\n\t#print(i,tmp,k)\n\tif k<=tmp:\n\t\tans_max=max(n-i,0)\n\t\tbreak\nif k==0:\n\tans_max=n\nprint(ans_min,ans_max)\n"}, {"source_code": "import math\nimport sys\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\nimport bisect\ninput = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\nilele = lambda: map(int,input().split())\nalele = lambda: list(map(int, input().split()))\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nn,m = ilele()\nif n==1:\n print(1,1)\nelif m==0:\n print(n,n)\nelif n==2:\n print(0,0)\nelse:\n x = math.ceil(n/2)\n if x<=m :\n xx=0\n else:\n xx = max(0,n-2*m)\n yy=0\n for i in range(2,n+1):\n y = (i*(i-1))//2\n if y>=m:\n yy = i\n break\n print(xx,n-yy)"}, {"source_code": "n, m = map(int, input().split(' '))\n\nif m * 2 > n: # min\n mn = 0\nelse:\n mn = n - m * 2\n\nif m:\n g = 1 # max\n while g * (g - 1) // 2 <= m:\n g += 1\n g -= 1\n if g * (g - 1) // 2 == m:\n mx = n - g\n else:\n mx = n - g - 1\nelse:\n mx = n\n\nprint(mn, mx)"}, {"source_code": "def solve(n, m):\n\tif n == 1 or m == 0:\n\t\treturn n, n\n\n\tmin_iso = 0 if m > n/2 else n - m*2\n\t\n\tedges = 0\n\tfor cur_n in range(2, n+1):\n\t\tedges += cur_n - 1\n\t\tif m <= edges:\n\t\t\tbreak\n\n\tmax_iso = n - cur_n\n\n\treturn min_iso, max_iso\n\n\n\nn, m = map(int, input().split())\nprint(' '.join(map(str, solve(n, m))))"}, {"source_code": "n, m = map(int, input().split())\np = n - m * 2\nprint(max(0, p), end = ' ')\nfor i in range(n):\n if m <= i * (i - 1) // 2:\n print(n - i)\n exit()\nprint(0)\n"}, {"source_code": "n,m=[int(i) for i in input().split()]\nx = 0\nwhile((x*(x+1))//2<m):\n x+=1\nif(m==0):\n print(n,n)\nelse:\n print(max(0,n-2*m),max(0,n-1-x))\n\n"}, {"source_code": "n, m = map(int, input().split())\n\nprint(max(0, n-2*m), end=\" \")\n\nl=0\nr=n+1\nwhile(r-l>1):\n x = (l+r)//2\n v = n-x\n if v*(v-1)//2>=m:\n l = x\n else:\n r = x\nprint(l)"}, {"source_code": "n, m = map(int, input().split())\n\nmn = max(0, n - 2 * m)\n\n\nfor i in range(n + 1):\n if i * (i - 1) // 2 >= m:\n ans = n - i\n break\n\nprint(mn, ans)\n"}, {"source_code": "n,m = map(int,input().split())\nif m==0:\n\tprint (n,n)\n\texit()\n\nans = n-2*m\nprint (max(ans,0),end = \" \")\nc = 2\nwhile ((c*(c-1))//2)<m:\n\tc += 1\nprint (n-c)"}, {"source_code": "import math\nn, m = map(int, input().split())\nmini = max(0, n - 2*m)\ntemp = 1\ncount = 1\nwhile(temp<m):\n count += 1\n temp += count\nif m==0:\n print(mini, n)\nelse:\n print(mini, n-count-1)\n"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\ndef rint():\n return map(int, sys.stdin.readline().split())\n#lines = stdin.readlines()\n\n\nn, m = rint()\n\nmin_ans = max(0, n - 2*m)\n\nmax_ans = 0\n\nfor i in range(0, n+1):\n if m <= i*(i-1)//2:\n #print(\"i\", i)\n max_ans = max(0, n-i)\n break\nprint(min_ans, max_ans)"}, {"source_code": "a = list( map(int,input().split()) )\nprint('%d' % ( (lambda v,e : 0 if v <= 2*e else v - 2*e)(*a) ) ,end = ' ')\nif a[1] == 0:\n print(a[0])\nelse :\n ans = 0\n l = 1\n r = 100000\n while True:\n if l > r:\n break\n mid = (l+r)//2\n if mid*mid - mid - (a[1]<<1) >= 0:\n ans = mid\n r = mid - 1\n else:\n l = mid + 1\n print( a[0] - ans) \n"}, {"source_code": "n, m = map(int, input().split())\nmin_ = max(0, n - 2 * m)\nleft = min_\nright = n + 1\nwhile(left + 1 < right):\n mid = (left + right) // 2\n x = n - mid\n if(x * (x - 1) // 2 >= m):\n left = mid\n else:\n right = mid\nprint(min_, left)"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\n# import time,random,resource\n\n# sys.setrecursionlimit(10**6)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\nmod2 = 998244353\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\ndef pe(s): return print(str(s), file=sys.stderr)\ndef JA(a, sep): return sep.join(map(str, a))\ndef JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)\ndef IF(c, t, f): return t if c else f\ndef YES(c): return IF(c, \"YES\", \"NO\")\ndef Yes(c): return IF(c, \"Yes\", \"No\")\n\n\ndef main():\n t = 1#I()\n\n rr = []\n for _ in range(t):\n n,m = LI()\n\n r1 = max(0, n - m * 2)\n r2 = r1\n if m > 0:\n for i in range(n):\n m -= i\n if m <= 0:\n r2 = n - i - 1\n break\n\n rr.append(JA([r1,r2], \" \"))\n\n\n return JA(rr, \"\\n\")\n\n\nprint(main())\n\n\n"}, {"source_code": "import math\n\nn,m = map(int, input().split())\n\ndef som(m):\n return (1+(1+8*m)**.5)/2\n\nmini = max(0, n-2*m)\nmaxi = -1\n\nif m<=2:\n maxi = n - (m+1)\nelse:\n maxi = n - math.ceil(som(m))\n\nif m == 0:\n maxi = n\n\nprint(mini, maxi)"}, {"source_code": "import math\n\nn,m=map(int,input().split())\n\nMINANS=max(0,n-m*2)\n\ndef combi(m):\n return m*(m-1)//2\n\nfor i in range(int(math.sqrt(2*m)),n+1):\n if combi(i)>=m:\n break\n\nMAXANS=n-i\n#n*(n-1)/2=m\n#n^2-n+2m=0\n\n\nprint(MINANS,MAXANS)\n"}, {"source_code": "n, m = map(int, input().split())\nMin = 0\ntemp = n // 2 + n % 2\nif temp > m:\n Min = n - m * 2\nMax = 0\nn1 = 0\nwhile n1 * (n1 - 1) // 2 < m: #\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n n1 += 1\nif n1 < n:\n Max = n - n1\n\nprint(Min, Max)\n"}, {"source_code": "import math\na=list(map(int,input().split()))\nb=a[0]-(2*a[1])\nif(b<0):\n b=0\nif(a[1]==0):\n n=0\nelse:\n n=math.ceil((1+math.ceil(math.sqrt(8*a[1]+1)))/2)\nprint(b,a[0]-n)\n"}, {"source_code": "import math\nn,m=list(map(int,input().strip().split()))\nif m==0:\n print(n,n)\nelse:\n a=max(n-2*m,0)\n b=math.ceil((1+math.sqrt(1+8*m))/2)\n print(a,n-b)"}, {"source_code": "x=[int(i)for i in input().split()]\nl=0\nif x[0]-1<x[1]:\n min=0\nelse:\n min=x[0]-x[1]*2\n if min<0:\n min=0\nif x[1]==0:\n max=x[0]\nelse:\n for i in range(x[0]):\n l+=i\n if l==x[1]:\n max=x[0]-(i+1)\n break\n elif l>x[1]:\n max=x[0]-(i+1)\n break\nprint(min,max)"}, {"source_code": "# With help from Ajosteen's tutorial\nn, m = map(int, input().split())\n\nminIsolated = max(0, n - 2 * m)\n\ncur = 1\nremain = m\nwhile remain > 0:\n d = min(cur, remain)\n remain -= d\n cur += 1\n\nmaxIsolated = n\nif (cur > 1):\n maxIsolated = n - cur\n\nprint(minIsolated, maxIsolated)\n"}, {"source_code": "import bisect\nx,y=map(int,input().split())\nlol=[0]\nif x==1:\n print(1,1)\nelse: \n for i in range(1,x+1):\n if i>3:\n lol.append((i-1)+((i-2)*(i-1))//2)\n else:\n lol.append(i)\n #print(lol)\n if x-2*y<=0:\n print(0,end=\" \")\n else:\n print(x-2*y,end=\" \")\n a=bisect.bisect(lol,y)\n #print(a)\n if y==1:\n if x-1>=0:\n print(x-2)\n elif y==2 or y==3:\n if x-3>=0:\n print(x-3)\n else:\n if x-a>=0:\n if lol[a-1]==y:\n print(x-(a-1))\n else:\n print(x-(a))\n else:\n print(0)"}, {"source_code": "v, r = input().split() #n - \u0432\u0435\u0440\u0448\u0438\u043d\u0430 m-\u0440\u0435\u0431\u0440\u043e\nv=int(v)\nr=int(r)\nif r == 0: \n min = v\n max= v\nelif (r>= v//2+v%2) and (r<=v) : min = 0\nelif (r>v) : min = 0\nelif (r < v//2+v%2) and (v%2==1): min = (v//2+v%2 - r)*2 - 1\nelif (r < v//2+v%2) and (v%2==0): min = (v//2+v%2 - r)*2 \ns=0\ny=0\nif r!=0:\n while s<r:\n y=y+1\n s=s+y\n max=v-y-1\nprint(min,max)"}, {"source_code": "import math\nn, m = map(int, input().split())\nif m == 0:\n print(n, n)\n quit()\nmost = m * 2\nleast = math.ceil((1 + (1 + 8 * m) ** 0.5) / 2)\nprint(max(0, n - most), max(0, n - least))\n"}, {"source_code": "#!/usr/bin/env python3\n \nfrom __future__ import division, print_function\nimport collections #20 ms\n\ndef main():\n import sys\n n, m = list(map(int, input().split()))\n ma = n\n if m == 0:\n ma = n\n else:\n ma = n-1\n t = 0\n for i in range(1, n):\n t += i\n ma -= 1\n if t >= m:\n break\n mi = max(0, n - 2*m)\n print(\"%d %d\\n\" % ( mi, ma))\n return 0\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, m = list(map(int,input().split()))\nans1 = max(0, n - m*2)\nif m == 0:\n print(n, n)\n exit()\nfor i in range(n+2):\n if i*(i-1)//2 > m:\n break\nans2 = n-i-(1 if (i-1)*(i-2)//2 < m else 0) +1\nprint(ans1 , ans2)"}, {"source_code": "from math import sqrt, ceil\nn, m = map(int, input().split())\n\nk = 0\nwhile m > (k * (k-1))//2:\n k += 1\n\na = max(0, n - (2 * m))\nb = n - k\n\nprint(a, b)\n\n"}, {"source_code": "import math\nn,m=map(int,input().split())\nif m==0:\n print(n,n)\n exit(0)\na=max(0,n-2*m)\nb=math.ceil((1+math.sqrt(1+8*m))/2)\nprint(a,int(n-b))"}, {"source_code": "n,m=map(int,input().split())\nif m==0:\n mx=n\nelse:\n i=2\n while i*(i-1)/2<m:\n i+=1\n mx=n-i\nif 2*m>=n:\n mn=0\nelse:\n mn=n-2*m\nprint(mn,mx)"}, {"source_code": "n,m=map(int,input().split())\nprint(max(n-2*m,0),n-next(i for i in range(n+1)if i*(i-1)//2>=m))"}, {"source_code": "import math\nn, m = map(int, input().split(' '))\n\nif(m==0):\n\tprint(n, end=' ')\nelse:\n\tprint( n-m*2 if n-m*2>0 else 0, end=' ')\n\n\n\n\nif(n==1):\n\tprint(1)\nelif(m==0):\n\tprint(n)\nelse:\n\tvert_used=math.ceil((1+math.sqrt(1+8*m))/2)\n\tprint(n-vert_used if n-vert_used>0 else 0)\n\t\n\n"}, {"source_code": "n, m = map(int, input().split())\nif m == 0:\n\tprint(n, n)\n\texit(0)\nif m == n * (n - 1) // 2:\n\tprint(0, 0)\n\texit(0)\nL = 0\nR = n + 1\nwhile R - L > 1:\n\tm1 = (L + R) // 2\n\tif m1 * (m1 - 1) // 2 < m:\n\t\tL = m1\n\telse:\n\t\tR = m1\nans_max = n - R\nans_min = max(0, n - 2 * m)\nprint(ans_min, ans_max)"}, {"source_code": "n,m=map(int,input().split())\nprint(max(n-2*m,0),(n,int(n-(1+(8*m+1)**.5)/2))[m>0])"}, {"source_code": "#!/usr/bin/python3\nfrom math import factorial as f\n\ndef readint():\n return int(input())\n\n\ndef readline():\n return [int(c) for c in input().split()]\n\ndef ncr2(n):\n return n * (n-1) // 2\n\ndef main():\n N, M = readline()\n\n\n if N == 1:\n print('1 1')\n return\n\n # _min = N - 2 * M\n\n i = N\n edges = M\n while i - 2 >= 0 and edges > 0:\n i -= 2\n edges -= 1\n\n if i == 1 and edges > 0:\n _min = 0\n else:\n _min = i\n\n\n \n nodes = 0\n rem = 1\n _max_nodes = 3\n for i in range(2, N):\n if i > N:\n break\n \n edges = i * (i-1) // 2\n if edges < M:\n _max_nodes = i\n elif edges == M:\n _max_nodes = i\n rem = 0\n else:\n break\n \n\n _max = N - _max_nodes - rem\n _max = max(_min, _max) \n print(str(_min) + ' ' + str(_max))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "v, e = map(int, input().split())\n\ndef minv(v, e):\n if v - 2*e < 0:\n return 0\n else:\n return v - 2*e\n\ndef maxv(v, e):\n ans = 0\n if e == 0:\n return v\n for i in range(2, v):\n ans = ans + i - 1\n if ans >= e:\n return v - i\n return 0\nprint(minv(v, e), maxv(v, e))"}, {"source_code": "import math\nn,e=map(int,input().split())\ny=0\nif e>0:\n\tk=math.sqrt(1+8*(e-1))\n\tk1=(1+k)//2+1\n\tk2=n-k1\n\tk3=n-e*2\n\tk4=max(k3,0)\n\tk5=max(int(k2),0)\n\tprint(int(k4),int(k5))\nelse:\n\tprint(n,n)"}, {"source_code": "\nf=lambda: map(int, input().split(' '))\nv, e =f()\nif e==0:\n\tprint(v,v)\nelse:\n\tmini = v-(e*2)\n\tif mini<0:\n\t\tmini = 0\n\tlow = 0\n\thigh = v\n\ta = []\n\twhile(low<high):\n\t\tmid = (low+high)//2\n\t\tif mid in a:\n\t\t\tmaxi = v-high\n\t\t\tbreak\n\t\telse:\n\t\t\ta.append(mid)\n\t\tif (mid*(mid-1))//2 == e:\n\t\t\tmaxi = v-mid\n\t\t\tbreak\n\t\telif (mid*(mid-1))//2 > e:\n\t\t\thigh = mid\n\t\telse:\n\t\t\tlow = mid\n\tprint(mini,maxi)"}, {"source_code": "nm = list(map(int,input().split()))\nn = int(nm[0])\nm = int(nm[1])\nif m ==0:\n print(n,n)\nif n<=2*m:\n f = 1\nelse:\n f = 2\nfor i in range(1,n+1):\n if m<=int(i*(i-1)/2):\n break\nif m!=0:\n if f == 1:\n print(0,n-i)\n if f == 2:\n print(n-2*m,n-i)\n "}, {"source_code": "s=0\nz=0\nk=1\n\na=raw_input()\na=a.split(\" \")\n\nn=int(a[0])\nm=int(a[1])\n\nif(m>=((n+1)/2)):\n y=0\nelse:\n y=n-(m*2)\n\nwhile(s<m):\n k=k+1\n z=z+1\n s=s+z\nx=n-k\n\nif(m==0):\n y=n\n x=n\n\nprint(str(y)+\" \"+str(x))\n"}, {"source_code": "n, m = map(int, input().split())\n\nres = 0\ncheck = 0\n\nfor i in range(n + 1):\n if i ** 2 - i - 2 * m >= 0 and check == 0:\n res = i\n check = 1\n\nprint(max(n - 2 * m, 0), max(n - res, 0))"}, {"source_code": "def f(l=0, r=int(10e5)):\n if r - l <= 1:\n return r\n mid = (l + r) // 2\n if mid * (mid - 1) // 2 >= m:\n return f(l, mid)\n else:\n return f(mid, r)\n\nn, m = map(int, input().split())\nprint(n - m * 2 if m <= n // 2 else 0, n - f() if m else n)"}, {"source_code": "n, k = map(int, input().split())\nfor i in range(n + 1):\n if i * (i - 1) // 2 >= k:\n exit(print(max(n - k * 2, 0), n - i))"}, {"source_code": "def binarySearch(arr, l, r, x): \n ans=-1\n while l <= r: \n mid = l + (r - l)//2; \n if arr[mid] >= x: \n r=mid-1 \n ans= mid \n elif arr[mid] < x: \n l = mid + 1\n else: \n r = mid - 1\n return ans\nn,m=map(int,input().split())\nif m==0:\n print(n,n)\nelse:\n if (n-2*m<0):\n print(0,end=\" \")\n else:\n print(n-2*m,end=\" \")\n a=[0]\n for i in range(1,10**5+1):\n a.append(a[-1]+i)\n z=binarySearch(a,0,len(a)-1,m)\n print(n-z-1)"}, {"source_code": "def line():\n return map(int, input().split())\n\nfrom math import sqrt, ceil\n\nn,m = line()\nprint(max(0, n-2*m), n if m==0 else n-ceil((sqrt(m*8+1)+1)/2))\n"}, {"source_code": "n, m = map(int,raw_input().split())\nif m==0:\n\tprint n,n\nelse:\t \n\tmn = 0\n\tif (m < (n + 1) / 2): \n\t\tmn = n - m * 2;\n\tmx = 0\n\tfor i in range(1,n+1):\n\t\ttemp = i * (i - 1) / 2\n\t\tif (m <= temp):\n\t\t\tmx = n - i\n\t\t\tbreak\n\tprint mn , mx "}, {"source_code": "import math\ns = input()\nn = int(s.split(' ')[0])\nm = int(s.split(' ')[1])\n\nif m > n // 2:\n mini = 0\nelse:\n mini = n - m * 2\n\n\nif m == 0:\n maxi = n\nelse:\n maxi = n - math.ceil((1+math.sqrt(1 + 8 * m)) / 2)\nprint(mini, maxi)\n"}, {"source_code": "from math import factorial as fact\nfrom math import sqrt,ceil\nn,m = map(int,input().split())\n\nif m>=3:\n\tprint(max(0,n - 2*m),n-ceil((1+sqrt(1+8*m))/2))\nelse:\n\tif m==0:\n\t\tprint(n,n)\n\telif m==1:\n\t\tprint(max(0,n - 2),max(0, n-2))\n\telif m==2:\n\t\tprint(max(0,n - 4),max(0, n-3))\n"}, {"source_code": "import math\nn,m = map(int,input().split())\nminv = n-2*m if n>=2*m else 0\nmaxv = minv\nprek = int((1+math.sqrt(1+8*m))/2)\nfor i in range(prek-3,prek+3):\n if m<=(i*(i-1)/2) and i>=0:\n maxv = max(n-i,maxv)\nprint(minv,maxv)"}, {"source_code": "class CodeforcesTask1065BSolution:\n def __init__(self):\n self.result = ''\n self.n_m = []\n\n def read_input(self):\n self.n_m = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n mn = max(self.n_m[0] - self.n_m[1] * 2, 0)\n x = 1\n while (x * (x - 1)) // 2 < self.n_m[1]:\n x += 1\n mx = self.n_m[0] - x\n self.result = \"{0} {1}\".format(mn, max(mn, mx))\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask1065BSolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "#!/usr/bin/env python\n#-*- coding: utf-8 -*-\n\nfrom collections import defaultdict\nfrom math import factorial as f\nfrom fractions import gcd as g\n\nn, m = [int (i) for i in raw_input ().split ()]\nx = max (n - 2 * m, 0)\ny = 0\nlo, hi = 0, n\nwhile lo <= hi:\n mid = lo + (hi - lo) / 2\n left = n - mid\n edge = left * (left - 1) / 2\n if edge >= m:\n y = mid\n lo = mid + 1\n else:\n hi = mid - 1\nprint x, y\n"}, {"source_code": "import math\nn,m=input().split(' ')\nn=int(n)\nm=int(m)\nprint(max(0,(n-2*m)),end=\" \")\nd=math.ceil(math.sqrt(1+8*m))\nans=math.ceil((1+d)/2)\nif m==0:\n print(n)\nelse:\n print(max(0,n-ans))"}, {"source_code": "n,m=map(int, input().split())\nn_min = n-m*2\nif n_min <0:\n n_min = 0\n\nif m == 0:\n n_occ = 0\nelif m == 1:\n n_occ = 2\nelif m == 2:\n n_occ = 3\nelse:\n left = 0\n right = 100007\n while left < right:\n mid = (left+right)//2\n if mid*(mid-1)//2 < m:\n left = mid+1\n else:\n right = mid\n if left*(left-1)//2 > m:\n left -= 1\n n_occ = left\n if n_occ*(n_occ-1)//2 < m:\n n_occ+=1\nn_max = n-n_occ\nn_max = max(n_max, 0)\nprint(n_min, n_max)"}, {"source_code": "# In this template you are not required to write code in main\n\nimport sys\ninf = float(\"inf\")\n\nsys.setrecursionlimit(1000000)\n#from cmath import sqrt\n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\nfrom math import ceil,floor,log,sqrt,factorial,pow,pi,gcd\n#from bisect import bisect_left,bisect_right\n#import numpy as np\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\n\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef input(): return sys.stdin.readline().strip()\n\nn,m=get_ints()\nif m==0:\n print(n,n)\n exit()\nif m>=(n*(n-1))//2 :\n print(0,0)\n exit()\nd=1+8*m\nmin_vertex_covered=ceil((1+sqrt(d))/2)\nmaxi=n-min_vertex_covered\nmaxi_vertex_covered=2*m\nmini=max(0,n-maxi_vertex_covered)\nprint(mini,maxi)\n"}, {"source_code": "n,e=map(int,input().split())\nmaxi=-1\nfor i in range(n+1):\n if (i*(i-1))/2<e:\n maxi=i\nprint(max(0,n-2*e),n-(maxi+1),sep=' ')\n"}, {"source_code": "n, m = map(int, raw_input().split())\nprint max(0, n - 2*m),\nfor i in range(0, n + 1):\n\tif i*(i-1)/2 >= m:\n\t\tprint n - i \n\t\tbreak"}, {"source_code": "from math import sqrt, ceil\n\ndef isolated_vertices(n,m):\n if m == 0:\n print n,n\n else:\n cc = ceil((1+sqrt(1+8*m))/2)\n max_vertices = max(n-cc,0)\n min_vertices = max(n-2*m,0)\n print int(min_vertices), int(max_vertices)\n\nn,m = map(int, raw_input().split())\nisolated_vertices(n,m)"}, {"source_code": "\n#RAVENS\n#TEAM_2\n#ESSI-DAYI_MOHSEN-LORENZO\nfrom math import sqrt, ceil\nn, k = map(int, input().split())\nprint(max(n-k*2,0),end=' ')#min\na=(1+ceil(sqrt(1+8*k))) /2\nb=(1-ceil(sqrt(1+8*k))) /2\nif b >=0:\n\ta = b\nprint(n-ceil(a))\n\n"}, {"source_code": "n,m = map(int,raw_input().split())\nmi = max(0,n-2*m)\nc = 0\nr = 0\nwhile c < m:\n r += 1\n c += r\n #print c,r\nif m == 0: r -= 1\nma = max(0,n - r - 1)\nprint mi,ma\n"}, {"source_code": "n,m=list(map(int,input().split()))\nmin_isolated=0;\nif n-m*2>0:\n min_isolated=n-m*2\nfor i in range(0,n+1):\n if i*(i-1)/2>=m:\n print(min_isolated,n-i)\n break;\n"}, {"source_code": "a,b=map(int,raw_input().split())\nl=[]\n\nfor i in xrange(1,100010):\n\tif b==((i*(i-1))/2):\n\t\ty=a-i\n\t\tbreak\n\telif b<((i*(i-1))/2):\n\t\ty=a-(i-1)-1\n\t\tbreak\n\t\nx=a-(b*2)\nif y<0:\n\ty=0\nif x<0:\n\tx=0\nif b==0:\n\tprint str(a)+' '+str(a)\t\nelse:\n\tprint str(x)+' '+str(y)\n\n"}, {"source_code": "def binarySearch(arr, l, r, x): \n ans=-1\n while l <= r: \n mid = l + (r - l)//2; \n if arr[mid] >= x: \n r=mid-1 \n ans= mid \n elif arr[mid] < x: \n l = mid + 1\n else: \n r = mid - 1\n return ans\nn,m=map(int,input().split())\nif m==0:\n print(n,n)\nelse:\n if (n-2*m<0):\n print(0,end=\" \")\n else:\n print(n-2*m,end=\" \")\n a=[0]\n for i in range(1,10**5+1):\n a.append(a[-1]+i)\n z=binarySearch(a,0,len(a)-1,m)\n print(n-z-1)\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n "}, {"source_code": "n,m = map(int,input().split())\nk = 0\nfor i in range(10**20):\n if i*(i-1)//2 >= m:\n k = i\n break\nprint(max(0,n - m*2),max(0,n-k))\n\n"}, {"source_code": "a,b=map(int,input().split())\nif a<=b*2:\n print (0,end=' ')\nelse:\n print (a-b*2,end=' ')\ni=1\nh=0\nif a==1:\n print (1)\n h=1\nelif b==0:\n print (a)\n h=1\nelse:\n while i<a:\n if i*(i-1)//2>=b:\n print (a-i)\n h=1\n break\n i+=1\nif h==0:\n print (0)"}, {"source_code": "import bisect\nn,m = map(int, raw_input().split())\n#n,m=10,28\nif n==1:\n print 1,1\n exit()\nif m==0:\n print n,n\n exit()\n\nmix=max(n-2*m,0)\n\nct=0\nA=[i*(i-1)/2 for i in range(1,100001)]\n\nmaxx=0\nidx=bisect.bisect_left(A,m)\n#print idx\n\nmaxx=n-idx-1\n\n\nprint mix, maxx\nexit()\n"}, {"source_code": "from sys import exit\nn, m = map(int, input().split())\nans1 = max(0, n - 2 * m)\n#n2 - n - 2m = 0\nk = 0\nif (m == 0):\n print(ans1, n)\n exit(0)\ncnt = 1\nfor i in range(1, n + 1):\n if (k + i) <= m:\n cnt += 1\n k += i\n else:\n if k != m:\n cnt += 1\n break\nans2 = max(0, n - cnt)\nprint(ans1, ans2)"}, {"source_code": "#Author: Madhav Khakhar\nn,m=[int(x) for x in raw_input().split()]\nif m > (n/2):\n\tres1=0\nelse:\n\tres1=n-(2*m)\nif m==0:\n\tres2=n\nelse:\n\tfor i in range(1,n+1):\n\t\tic2=(i*(i-1))/2\n\t\tif ic2 >= m:\n\t\t\tres2=n-i\n\t\t\tbreak\nprint str(res1) + \" \" + str(res2)"}, {"source_code": "n, m = map(int, input().split())\na, b = 1, m\nans = n\nwhile b > 0:\n b -= min(a, b)\n a += 1\nif a > 1:\n ans = n - a\nprint(max(0, n-m*2), ans)\n"}, {"source_code": "import math\nn,m = map(int,input().split())\nmen ,mex = 0,0\nif m == 0:\n l = 0\nelse:\n l = math.ceil((1 + math.sqrt(1+8*m))/2)\nmex = max(n-l,0)\nmen = max(n-2*m,0)\n\nprint(men)\nprint(mex)"}, {"source_code": "import math\n\nn,m = map(int,raw_input().split())\n\nmini = max(0,n - 2*m)\n\nfor i in range(n+1):\n if (i*(i-1))/2 >= m:\n break\n\nmaxi = max(0, n-i)\n\nprint mini, maxi"}, {"source_code": "import math\nn,m = map(int,raw_input().split())\nif m > 0:\n minimum = max(0,n - (2*m))\n ans = math.sqrt(8*m + 1)\n answer = (1 + ans)/2\n if int(ans)*int(ans) == 8*m + 1:\n answer = int(answer)\n else:\n answer = int(answer) + 1\n maximum = max(0,n - answer) \n print str(minimum) + \" \" + str(maximum)\nelse:\n print str(n) + \" \" + str(n)"}, {"source_code": "line = raw_input()\nline = line.split()\n\nn = int(line[0])\nm = int(line[1])\n\nmm = max(0, n-2*m)\n\ndef M(m):\n d =(1.0+8.0*m)**0.5\n return (1.0+d)/2.0\n\nx = int(M(m))\n\nif x<M(m):\n x += 1\n\nMM = max(n-x,0)\n\nif m==0:\n MM = n\n\nprint mm, MM\n\n\n"}, {"source_code": "n,m=map(int,raw_input().split())\nif m==0:\n\tprint n,n\n\texit(0)\nif 2*m>=n:\n\tprint 0,\nelse:\n\tprint n-2*m,\na=(pow(1+8*m,0.5)+1)/float(2)\nif int(a)!=a:\n\ta=int(a) +1\nif a>=n:\n\tprint 0\n\texit(0)\nprint n-int(a)\t"}, {"source_code": "n,m = map(int,raw_input().split())\nif(m == 0):\n print n,n\nelif(n == 1):\n print 1,1\nelse:\n nk = 0\n while(nk<=n):\n val = (pow(nk,2) - nk)/2\n if(val >= m):\n break\n else:\n nk+=1 \n mx = max(0,n-nk)\n mn = n\n mk = m\n while(mn > 0 and mk>0):\n mn-=2\n mk-=1\n mn = max(0,mn)\n print mn,mx "}, {"source_code": "'''input\n4 2\n\n\n'''\n\nn,m=map(int,raw_input().split())\nans=0\nfor n1 in range(0,n+1):\n\tif n1*(n1-1)/2>=m:\n\t\tans=n1\n\t\tbreak\n\nprint max(0,n-2*m),n-ans\n"}, {"source_code": "#JMD\n#Nagendra Jha-4096\n\n \nimport sys\nimport math\n\n#import fractions\n#import numpy\n \n###File Operations###\nfileoperation=0\nif(fileoperation):\n orig_stdout = sys.stdout\n orig_stdin = sys.stdin\n inputfile = open('W:/Competitive Programming/input.txt', 'r')\n outputfile = open('W:/Competitive Programming/output.txt', 'w')\n sys.stdin = inputfile\n sys.stdout = outputfile\n\n###Defines...###\nmod=1000000007\n \n###FUF's...###\ndef nospace(l):\n ans=''.join(str(i) for i in l)\n return ans\n \n \n \n##### Main ####\nt=1\nfor tt in range(t):\n #n=int(input())\n #a=list(map(int,sys.stdin.readline().split(' ')))\n n,m= map(int, sys.stdin.readline().split(' '))\n ans=0\n k=0\n for i in range(100000000000):\n ans+=i\n if(ans>=m):\n k+=1\n break\n k+=1\n if(m):\n print(max(0,n-2*m),(n-k))\n elif(m==0):\n print(n,n)\n#####File Operations#####\nif(fileoperation):\n sys.stdout = orig_stdout\n sys.stdin = orig_stdin\n inputfile.close()\n outputfile.close()"}, {"source_code": "n, m = map(int, raw_input().strip().split())\n\nMAX = n\nwhile (n - MAX) * (n - MAX - 1) // 2 < m: MAX -= 1\n\nMIN = 0\nMIN = max(MIN, n - 2 * m)\n\nprint MIN, MAX"}, {"source_code": "n,m=list(map(int,input().split()))\nmin=n-m*2\nfor i in range(1,n+1):\n x=(i*(i-1))/2\n if x>=m:break\nmax=n-i\nif min<0:min=0\nif m==0:max=n\nprint(min,max)"}, {"source_code": "n, m = map(int, input().split())\nprint(max(0, n - m * 2), end = ' ')\n\nfor i in range(n):\n if i * (i - 1) / 2 >= m :\n print(n - i)\n exit()\nprint(0)\n\n\n\n\n"}, {"source_code": "n, m= map(int, input().split())\nmn = max(0, n-2*m)\nk = 0\nwhile k*(k-1)//2 < m:\n\tk+=1\nmx = n-k\nprint(mn, mx)"}, {"source_code": "n, m = [int(s) for s in input().split(\" \")]\nmin_iso = max(n-m*2, 0)\na = 0\nif m>=1:\n while a*(a-1)/2<m and a<n:\n a+=1\nmax_iso = n-a\nprint(min_iso, max_iso)"}, {"source_code": "n, m = [int(s) for s in input().split()]\ns, i = 1, 0\nmin = max(0,n - m*2)\nprint(min, end=' ')\nwhile s <= m:\n i += 1\n s += i\nmax = n - (i+1)\nif m == 0:\n print(n, end='')\nelse:\n print(max, end=' ')"}, {"source_code": "n,m=map(int,input().split())\nloli=max(0,((n)-(2*m)))\nif m==0:\n alfa=n\nelif m>=3:\n now=1\n while m>0:\n n-=1\n m-=now\n now+=1\n \n \n \n \n alfa=max(0,n-1)\nelse:\n alfa=max(0,n-(m+1))\n\n\nprint(loli,alfa)\n\n \n \n"}, {"source_code": "def binarySearch(x,arr,l,r):\n\tmid = int((l+r)/2)\n\twhile(l<=r):\n\t\tif arr[mid]<x:\n\t\t\tl = mid+1\n\t\telif arr[mid]==x:\n\t\t\treturn mid\n\t\telif arr[mid]>=x:\n\t\t\tr = mid-1\n\t\tmid = int((l+r)/2)\n\t\t#print(l,r,mid)\n\treturn mid\n\n\nvert,edges = [int(x) for x in input().split()]\nif edges==0:\n\tprint(vert,vert)\n\texit()\ned = int(vert/2)\nif edges>ed:\n\tprint(0,end=\" \")\n#elif edges==ed:\nelse:\n\tprint(vert-edges*2,end=\" \")\n# else:\n# \tleft = (ed-edges)*2\n# \tprint(left,end=\" \")\n\nx = []\nfor i in range(2,vert+1):\n\tx.append(int(((i)*(i-1))/2))\n#print(x)\nel = binarySearch(edges,x,0,len(x)-1)\n#print(el)\n#print(x[el])\nif x[el]==edges:\n\tprint(vert-el-2)\nelif edges==1:\n\tprint(vert-2)\nelse:\n\tel += 3\n\tprint(vert-el)\n"}, {"source_code": "import math as ma\nimport sys\nfrom sys import exit\nfrom decimal import Decimal as dec\nfrom itertools import permutations\n\ndef li():\n\treturn list(map(int , input().split()))\n\n\n# https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/\ndef modInverse(a , m):\n\tm0 = m\n\ty = 0\n\tx = 1\n\tif (m == 1):\n\t\treturn 0\n\twhile (a > 1):\n\t\tq = a // m\n\t\tt = m\n\t\tm = a % m\n\t\ta = t\n\t\tt = y\n\t\ty = x - q * y\n\t\tx = t\n\tif (x < 0):\n\t\tx = x + m0\n\treturn x\n\n\ndef num():\n\treturn map(int , input().split())\n\n\ndef nu():\n\treturn int(input())\n\n\ndef find_gcd(x , y):\n\twhile (y):\n\t\tx , y = y , x % y\n\treturn x\n\n\nn,m=num()\nmx=0\nfor i in range(1,n+1):\n\tz=i*(i-1)//2\n\tif(m>z):\n\t\tcontinue\n\tmx=n-i\n\tbreak\nif(m==0):\n\tmx=n\nmn=0\nif(n%2==0):\n\tif(m<=n//2):\n\t\tmn=(n//2-m)*2\nelse:\n\tzp=n//2\n\tif(m<=zp):\n\t\tmn=(zp-m)*2+1\nif(m==0):\n\tmn=n\nprint(mn,mx)"}, {"source_code": "n,m=map(int, input().split())\n\nmn=max(0,n-2*m)\nif m==0:\n mx=n\nelse:\n v=2\n edges=1\n while v<n and edges<m:\n edges+=min(m-edges,v)\n v+=1\n mx=n-v\nprint(mn,mx)\n \n \n"}, {"source_code": "#!/usr/bin/python3\n\nimport math\nimport sys\n\n\nDEBUG = False\n\n\ndef inp():\n return sys.stdin.readline().rstrip()\n\n\ndef dprint(*value, sep=' ', end='\\n'):\n if DEBUG:\n print(*value, sep=sep, end=end)\n\n\ndef getpf(E):\n if E == 0:\n return 0\n\n e = 0\n for k in range(2, E + 100):\n e += k - 1\n if e >= E:\n return k\n\n assert False\n\n\ndef solve(V, E):\n mx = V - getpf(E)\n mn = max(0, V - E * 2)\n return mn, mx\n\n\ndef main():\n N, M = [int(e) for e in inp().split()]\n print(*solve(N, M))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nn,m=map(int,input().split(\" \"))\n\nmaxi = n-math.ceil((1+math.sqrt(1+8*m))/2.0)\nmini = n-2*m\nmaxi = max(maxi,0)\nmini = max(mini,0)\nif m==0:\n\tmini=n\n\tmaxi=n\nprint(int(mini),end=\" \")\nprint(int(maxi))\n"}, {"source_code": "n,m = map(int, input().split())\nk=0\nwhile k*(k-1)//2<m:\n k+=1\nprint(max(0,n-m*2), n-k)"}], "negative_code": [{"source_code": "n,m=input().split(' ')\nn=int(n)\nm=int(m)\nprint(max(0,(n-2*m)),end=\" \")\nprint(n-(m+1))"}, {"source_code": "#q=int(input())\nq=1\nfor _ in range(q):\n n,m=map(int,input().split())\n if (n-2*m<0):\n print(0)\n else:\n print(n-2*m)\n if n-m-1<0:\n print(0)\n else:\n print(n-m-1)"}, {"source_code": "import bisect\nn,m = map(int, raw_input().split())\nif n==1:\n print 1,1\n exit()\n\n\nmix=max(n-2*m,0)\n\nct=0\nA=[i*(i-1)/2 for i in range(2,100001)]\n\nwhile m>=1:\n idx=bisect.bisect_left(A,m)\n ct+=(idx+2)\n m-=(idx+2)*(idx+1)/2\n #print m\n\nmaxx=n-ct\n\nprint maxx, mix\nexit()\n"}, {"source_code": "n, m = map(int, input().split())\nt = 0\nwhile t*(t-1)//2 < m:\n t += 1\nprint(n-2*m, n-t)\n"}, {"source_code": "n, m = map(int, input().split())\n\nprint(n - (m * 2), n - (m + 1))"}, {"source_code": "n, m = map(int, input().split())\n\nv_min = n - 2*m\nif v_min < 0: v_min = 0\n\nif m == 0:\n\tf = 0\nelif m == 1:\n\tf = 2\nelif m == 2:\n\tf = 3\nelse:\n\tl = [[i,i] for i in range(3, m)]\n\tf = l[m//2 - 1][0]\nv_max = n - f\nprint(v_min, abs(v_max))\n\n "}, {"source_code": "import math\nvalues = list(map(int, input().split(sep=' ')))\n\n\nn = values[0]\nm = values[1]\n\ndef count(n,m):\n\n if(m==0):\n print(str(int(n)) + \" \" + str(int(n)))\n return\n\n\n if(n==1):\n maximum = 0\n minimum = 0\n print(str(int(minimum)) + \" \" + str(int(maximum)))\n return\n\n else:\n maximum = n - int((1+math.sqrt(1+8*m))/2) - 1\n minimum = max(n - 2*m,0)\n print(str(int(minimum)) + \" \" + str(int(maximum)))\n return\n\ncount(n,m)\n\n\n\n\n\n\n\n"}, {"source_code": "n, m = map(int, input().split())\nprint(max(0, n - 2*m) , n - m - 1)\n"}, {"source_code": "n, m = map(int, raw_input().split())\nif m == 0:\n print n, n\nelif m == 1:\n print n - 2, n - 2\nelif m == 2:\n print max(0, n - 4), n - 3\nelse:\n s = i = 0\n f = []\n while 1:\n s += i\n f.append(s)\n if s >= m:\n k = 0\n while m and f:\n x = f.pop()\n if m >= x:\n k += i\n print i, m\n i -= 1\n m -= x\n if m:\n k += 2\n break\n i += 1\n print max(0, n - 2 * m), max(0, n - k)\n"}, {"source_code": "from bisect import bisect_left\nn,m = map(int,input().split())\nif m==0:\n print(n,n)\nelif n==1:\n print(1,1)\n \nelse: \n mn=max((n-(m*2)),0)\n value = [int((n*(n-1))/2) for n in range(2,10*5+1)]\n mx = bisect_left(value,m)\n mxm=max(n-mx-2,0)\n\n print(mn,mxm)\n"}, {"source_code": "def good(mid):\n return mid * (mid - 1) // 2 >= m\n\n\ndef bin_search():\n L = 0\n R = n\n\n while R - L > 1:\n mid = (L + R) // 2\n if good(mid):\n R = mid\n else:\n L = mid\n return R\n\n\nn, m = map(int, input().split())\nif n <= 2 * m:\n mn = 0\nelse:\n mn = n - 2 * m\n\nif m == ((n - 1) * n) // 2:\n ans = 0\nelse:\n mx = bin_search()\n ans = n - mx\n\nprint(mn, ans)"}, {"source_code": "n, m = map(int, input().split())\nmn, mx = -1, -1\nmn = max(0, n - m - m)\n\nmx = 1\nwhile mx * (mx - 1) // 2 < m:\n\tmx += 1\nif n == 1:\n\tmx = 0\nprint(mn, n - mx)"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\ndef rint():\n return map(int, sys.stdin.readline().split())\n#lines = stdin.readlines()\n\n\nn, m = rint()\n\nmin_ans = max(0, n - 2*m)\n\nmax_ans = 0\n\nfor i in range(m+1, 0, -1):\n if m < i*(i+1)//2:\n max_ans = n-i\n break\nprint(min_ans, max_ans)"}, {"source_code": "import math\nv,e = map(int,input().split())\nmaxi = max(0,v-(e+1))\nmini = v - (e*2)\n#print(math.ceil(v/2))\nfor i in range(1,v+1):\n d = i**2 - i\n if(d>=2*e):\n fee = i\n break\nprint(max(0,mini),v-fee)"}, {"source_code": "x=[int(i)for i in input().split()]\nmin=x[0]-(x[1]*2)\nmax=x[0]-(1+x[1])\nprint(min,max)"}, {"source_code": "n,m = map(int,input().split())\nmaxi = n-m-1\nif(maxi<=0):\n\tmaxi = 0\nmini = n-2*m\nif(mini<=0):\n\tmini = 0\nprint(mini,maxi)\n"}, {"source_code": "n,m=input().split(' ')\nn=int(n)\nm=int(m)\nprint(max(0,(n-2*m)),end=\" \")\nprint(max(0,n-(m+1)))"}, {"source_code": "n, m = map(int, input().split())\nprint(int(1.5))\nif n - 2 * m < 0:\n\tprint(0, max(1, (n - round((1 + (1 + 8 * m)**0.5) / 2))))\nelse:\n\tprint(n - 2 * m, max(1, (n - round((1 + (1 + 8 * m)**0.5) / 2))))\n"}, {"source_code": "import math\nn,m = map(int, input().split())\nif(m==0):\n print(n,n)\nelse:\n mi, mx = 0,0\n mi = max(0, n-(2*m))\n mx = max(0, n-m-1)\n print(mi, mx)\n"}, {"source_code": "n,m=map(int,input().split())\nprint(max(n-2*m,0),n+1-next(i for i in range(n)if i*(i+1)//2>=m))"}, {"source_code": "v, e = map(int, input().split())\n\ndef minv(v, e):\n if v - 2*e < 0:\n return 0\n else:\n return v - 2*e\n\ndef maxv(v, e):\n ans = v\n for i in range(e):\n if i == 0:\n ans = ans - 2\n else:\n ans = ans - 1\n if ans < 0:\n return 0\n else:\n return ans\n\nprint(minv(v, e), maxv(v, e))"}, {"source_code": "import sys, math\nfrom collections import defaultdict\nMOD = 1000000007\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\ndef get_ints(): return map(int, sys.stdin.readline().split())\ndef input(): return sys.stdin.readline()\ndef print_array(a): print(\" \".join(map(str, a)))\ndef main():\n n, m = get_ints()\n x = max(0, n - 2 * m)\n i = [0]\n for j in range(1, 100001): i.append(j + i[j - 1])\n y = 0\n while y < n + 1 and m > i[y]: y += 1\n print(x, n - y - 1)\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n, m = [int(j) for j in input().split()]\nk = 0\nfor i in range(10 ** 20):\n if i * (i - 1) // 2 >= m:\n k = i\n break\nprint(max(0, n - m * m), max(0, n - k))\n"}, {"source_code": "\n\n\n\n\n\n\n\na,b=[int(i) for i in input().split()]\nx=b*2\nif a>x:\n print(a-x,end=\" \")\nelse:\n print(0,end=\" \")\n\nx=b+1\nif a<=x:\n print(0,end=\" \")\nelse:\n print(a-x,end=\" \")"}, {"source_code": "n, m = map(int, input().split())\n\nminA = max(0, n - 2*m)\n\ncurC = 1\n\ncurE = 0\ncurMax = curC * (curC - 1) // 2\nwhile m > 0:\n if m > curMax - curE:\n m -= curMax - curE\n curE = curMax\n curC += 1\n curMax = curC * (curC - 1) // 2\n else:\n break\nmaxA = n - curC\n\nprint(str(minA) + ' ' + str(maxA))"}, {"source_code": "import math\nn, m = map(int, input().split())\nx = 0\nfor i in range(2, n + 1):\n if i * (i - 1) < 2 * m:\n x = i + 1\n elif i * (i - 1) == 2 * m:\n x = i\n else:\n break\n\nprint(n - m * 2, n - x)"}, {"source_code": "n, m = map(int, input().split())\nif (n//2) + (n % 2) <= m:\n _min = 0\nelse:\n _min = n - 2*m\ntmp = 0\nfor i in range(n):\n if i*(i - 1) >= 2*m:\n tmp = i \n break\n_max = n - tmp\nprint(_min, _max)"}, {"source_code": "import math as ma\nimport sys\nfrom sys import exit\nfrom decimal import Decimal as dec\nfrom itertools import permutations\n\ndef li():\n\treturn list(map(int , input().split()))\n\n\n# https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/\ndef modInverse(a , m):\n\tm0 = m\n\ty = 0\n\tx = 1\n\tif (m == 1):\n\t\treturn 0\n\twhile (a > 1):\n\t\tq = a // m\n\t\tt = m\n\t\tm = a % m\n\t\ta = t\n\t\tt = y\n\t\ty = x - q * y\n\t\tx = t\n\tif (x < 0):\n\t\tx = x + m0\n\treturn x\n\n\ndef num():\n\treturn map(int , input().split())\n\n\ndef nu():\n\treturn int(input())\n\n\ndef find_gcd(x , y):\n\twhile (y):\n\t\tx , y = y , x % y\n\treturn x\n\n\nn,m=num()\nmx=0\nfor i in range(1,n+1):\n\tz=i*(i+1)//2\n\tif(m>z):\n\t\tcontinue\n\tmx=n-i-1\n\tbreak\n\nmn=0\nif(n%2==0):\n\tif(m<=n//2):\n\t\tmn=n//2-m\nelse:\n\tzp=n//2+1\n\tif(m<=zp):\n\t\tmn=zp-m\nprint(mn,mx)"}, {"source_code": "import sys\n\nn,m = [int(i) for i in str(sys.stdin.read()).split()]\n\nmini = max(0,n-2*m)\n\nl=0\nwhile True:\n\tif l*(l-1) < 2*m:\n\t\tbreak\n\tl+=1\n\nmaxi = max(0,n-l)\n\nprint(int(mini),int(maxi))"}, {"source_code": "from math import ceil\nn,m = map(int,input().split())\nif n>m:\n if n%2==0 and m>=(n/2):\n mn = 0\n mx = n-(m+1)\n elif n%2==0 and m<(n/2):\n mn = int(((n/2)-m))\n mx = n-(m+1)\n elif n%2!=0 and m<=(n//m):\n mn = n-(2*m)\n mx = n - (m+1)\n elif n%2!=0 and m>(n//m):\n mn = 0\n mx = n - (m+1)\nelse:\n mn = 0\n mx = ceil((((m+1)-n)+3)//4)\nprint(mn,mx)\n"}, {"source_code": "n,m=input().split(' ')\nn=int(n)\nm=int(m)\nprint(max(0,(n-2*m)),end=\" \")\nprint(max(0,n-(m+1)))"}, {"source_code": "import math\nn, m = map(int, input().split(' '))\n\nif(m==0):\n\tprint(n, end=' ')\nelse:\n\tprint( n-m*2 if n-m*2>0 else 0, end=' ')\n\n\n\n\nif(n==1):\n\tprint(1)\nelse:\n\tvert_used=math.ceil((1+math.sqrt(1+8*m))/2)\n\tprint(n-vert_used if n-vert_used>0 else 0)\n\t\n\n"}, {"source_code": "n, m =list(map(int,input().split()))\nminimum = n//(2**m)\nmaximum = n - (m+1)\nprint(minimum,maximum)"}, {"source_code": "import math\nn, m = map(int, input().split())\nx = 0\nfor i in range(2, n + 1):\n if i * (i - 1) < 2 * m:\n x = i + 1\n elif i * (i - 1) == 2 * m:\n x = i\n else:\n break\n\nprint(n - m * 2, n - x)"}, {"source_code": "n, m = map(int, input().split())\nMax = 1\nMin = 1\nif m > 1:\n Max = n - (m + 1) + m % 2\n Min = n - m * 2\nprint(Min, Max)\n"}, {"source_code": "inp = raw_input()\nn,m = inp.split()\nn = int(n)\nm = int(m)\nminimum = n - 2*m\nif minimum < 0:\n\tminimum = 0\n\nfor i in range(1,n+1):\n\tif (i*(i-1))/2 >= m:\n\t\tbreak\n\nmaximum = n-i\nif maximum < 0:\n\tmaximum = 0\n\nif n == 1:\n\tprint (\"1 1\")\nelse:\n\tprint (\"%d %d\"%(minimum,maximum))"}, {"source_code": "#constructive algorithm, graph\n#Self-loop is not a cycle :xD\nfrom math import sqrt,ceil\nn,m = map(int, input().split())\nMin = n - 2*m\nMin = max(0,Min)\nMax = int(n - ceil((1 + sqrt(1+8*m))/ 2))\nMax = max(0,Max)\nif(m==0):\n Min = Max = 0\nprint(Min, Max)"}, {"source_code": "n, m = map(int, input().split())\nmi = max(0, n - 2 * m)\nrec = 0\nfor i in range(n, -1, -1):\n if m - i * (i - 1) // 2 >= 0:\n rec += i\n m -= i * (i - 1) // 2\n break\n\nwhile m > 0:\n m -= rec\n rec += 1\n\nif m == 0:\n print(n, n)\nelse:\n print(mi, n - rec)"}, {"source_code": "import math\nn, m = map(int, input().split())\nmost = m * 2\nleast = math.ceil((1 + (1 + 8 * m) ** 0.5) / 2)\nprint(max(0, n - most), max(0, n - least))\n"}, {"source_code": "s=0\nz=0\nk=1\n\na=raw_input()\na=a.split(\" \")\n\nn=int(a[0])\nm=int(a[1])\n\nif(m>((n+1)/2)):\n y=0\nelse:\n y=n-(m*2)\n\nwhile(s<m):\n k=k+1\n z=z+1\n s=s+z\nx=n-k\n\nif(m==0):\n y=n\n x=n\n\nprint(str(y)+\" \"+str(x))\n"}, {"source_code": "a=input()\nn=1\nb=a.split()\nq=int(b[0])\nw=int(b[1])\nt=q-w*2\n(n*n-n)/2==w\nprint(t, n)"}, {"source_code": "import math\nn,m = map(int,raw_input().split())\nminimum = n - (2*m)\nans = math.sqrt(8*m + 1)\nanswer = (1 + ans)/2\nif answer != int(answer):\n answer = int(answer) + 1\nmaximum = n - answer \nprint str(minimum) + \" \" + str(int(maximum))"}, {"source_code": "n,m=map(int,input().split())\nalfa=max(0,n-(m+1))\nloli=max(0,((n-1)//(2*m)))\n\nprint(loli,alfa)\n\n \n \n"}, {"source_code": "n,m = list(map(int,input().split()))\n\nif 2*m<n:\n minn = n-2*m\nelse:\n minn = 0\n\nmaxx = n-m-1\n\nprint(\" \".join([str(minn),str(maxx)]))\n"}, {"source_code": "n = raw_input()\nn = n.split(\" \")\n\nres = \"\"\n\na = int(n[0])\nb = int(n[1])\n\nm = a-b*2\nx = abs(a-(b+1))\n\nif(m<0):\n m = 0\n\nif(b==1):\n m = 1\n\nres = str(m)+\" \"+str(x)\n\nprint(res)\n"}, {"source_code": "n, m = map(int, input().split())\n\nprint(max(0, n - (2 * m)), (n-1) - m)\n\n"}, {"source_code": "n,m = map(int,input().split())\nif m==1 and n==1:print(1,1)\nelse:\n q=m\n counter = 1\n while q > 0:\n q -= counter\n counter+=1\n \n print(max(0,n-(m*2) ),max(n-counter,0))"}, {"source_code": "a,b=map(int,input().split())\nif a<=b*2:\n print (0,end=' ')\nelse:\n print (a-b*2,end=' ')\ni=1\nif a==1:\n print (1)\nif b==0:\n print (a)\nelse:\n while i<a:\n if i*(i-1)//2>=b:\n print (a-i)\n break\n i+=1"}, {"source_code": "masukan = [int(item) for item in input().split(\" \")]\nn = masukan[0] # vertex\nm = masukan[1] # edges\n\ndef getMin():\n if n/m <= 2:\n return 0\n else:\n return n - (m*2)\n\ndef getMax():\n numEdge = 0\n for i in range(2,n+1):\n # print(\"vertex ke: \",i)\n if numEdge < m:\n numPosEdge = i*(i-1)/2\n numEdge = numPosEdge\n # print(\"possible edge: \",numPosEdge)\n # print(\"edge skrg: \",numEdge)\n else:\n return n-(i-1)\n # return n-i\nif n == 0:\n print(0,0)\nelif m == 0:\n print(n,n)\nelse:\n print(getMin(), getMax())"}, {"source_code": "n, m = list(map(int,input().split()))\nans1 = max(0, n - m*2)\nfor i in range(n):\n if i*(i-1)/2 > m:\n break\nans2 = n-i\nprint(ans1 , ans2)"}, {"source_code": "n,m = map(int,input().split())\nq=m\ncounter = 1\nwhile q > 0:\n q -= counter\n counter+=1\n\nprint(max(0,n-(m*2) ),max(n-counter,0))"}, {"source_code": "n, m = map(int, input().split())\nmin = max(n - m * 2, 0)\n\nif n > 1 and m > 0:\n m -= 1\n n -= 2\nmax = n - (m // 2 if m % 2 == 0 else m // 2 + 1)\nprint(min, max)"}, {"source_code": "n,m = map(int,input().split())\nmaxi = 0\nfor i in range(1,n+1):\n\tif((i*(i-1))//2 >= m):\n\t\tmaxi = n-i\n\t\tbreak\n\nmini = n-(2*m)\nif(mini<=0):\n\tmini = 0\nprint(mini,maxi)\n"}, {"source_code": "import math\nn,m=list(map(int,input().strip().split()))\na=max(n-2*m,0)\nb=math.ceil((1+math.sqrt(1+8*m))/2)\nprint(a,max(n-b,0))"}, {"source_code": "import math\nv,e = map(int,input().split())\nmaxi = max(0,v-(e+1))\nmini = math.ceil(v/2)-e\n#print(math.ceil(v/2))\nfor i in range(1,v+1):\n d = i**2 - i\n if(d>=2*e):\n m =i\n break\nprint(maxi,v-m)"}, {"source_code": "import math\nn,m=map(int,input().split(\" \"))\nmaxi = n-math.ceil((1+math.sqrt(1+8*m))/2.0)\nmini = 0\nif m>=n-1:\n\tmini = 0\nelse:\n\tmini = n-2*m\nmini = max(mini,0)\nprint(mini,end=\" \")\nprint(maxi)\n"}, {"source_code": "n, m = [int(s) for s in input().split(\" \")]\nmin_iso = min(n-m*2, 0)\na = 0\nif m>=1:\n while a*(a-1)/2<m and a<n:\n a+=1\nmax_iso = n-a\nprint(min_iso, max_iso)"}, {"source_code": "from math import sqrt\nn, m = map(int, input().split())\nans1 = max(0, n - 2 * m)\n#n2 - n - 2m = 0\nd = 1 + 4 * 2 * m\ny = 0\nif (sqrt(d) % 1 > 0):\n y = 1\nx = int((1 + sqrt(d)) / 2) + y\n#x = int(sqrt(2 * m)) + 1\nans2 = max(n - x, 0)\nprint(ans1, ans2)"}, {"source_code": "#JMD\n#Nagendra Jha-4096\n\n \nimport sys\nimport math\n\n#import fractions\n#import numpy\n \n###File Operations###\nfileoperation=0\nif(fileoperation):\n orig_stdout = sys.stdout\n orig_stdin = sys.stdin\n inputfile = open('W:/Competitive Programming/input.txt', 'r')\n outputfile = open('W:/Competitive Programming/output.txt', 'w')\n sys.stdin = inputfile\n sys.stdout = outputfile\n\n###Defines...###\nmod=1000000007\n \n###FUF's...###\ndef nospace(l):\n ans=''.join(str(i) for i in l)\n return ans\n \n \n \n##### Main ####\nt=1\nfor tt in range(t):\n #n=int(input())\n #a=list(map(int,sys.stdin.readline().split(' ')))\n n,m= map(int, sys.stdin.readline().split(' '))\n if(m):\n print(max(0,n-2*m),(n-m-1))\n else:\n print(n,n)\n#####File Operations#####\nif(fileoperation):\n sys.stdout = orig_stdout\n sys.stdin = orig_stdin\n inputfile.close()\n outputfile.close()"}, {"source_code": "n, m = map(int, raw_input().split())\nprint max(0, n - 2*m), max(0, n - m - 1)"}, {"source_code": "inp = raw_input()\nn,m = inp.split()\nn = int(n)\nm = int(m)\nminimum = n - 2*m\nif minimum < 0:\n\tminimum = 0\n\nfor i in range(1,n+1):\n\tif (i*(i-1))/2 >= m:\n\t\tbreak\n\nmaximum = n-i\nif maximum < 0:\n\tmaximum = 0\nprint (\"%d %d\"%(minimum,maximum))"}, {"source_code": "a, b = map(int, input().split())\n\nmax_v = b+1 if b==1 else b*2\nmin_v = b+1 if b<=2 else b\nans1=a-max_v\nans2=a-min_v\nprint(0 if ans1<=0 else ans1, 0 if ans2<=0 else ans2)"}, {"source_code": "n,m=map(int,input().split())\nloli=max(0,((n-1)//(2*m)))\nif m>=3:\n now=1\n while m>0:\n n-=1\n m-=now\n now+=1\n \n \n \n \n alfa=max(0,n-1)\nelse:\n alfa=max(0,n-(m+1))\n\n\nprint(loli,alfa)\n\n \n \n"}, {"source_code": "n,m=map(int,input().split())\nx=max(n-2*m,0)\nz=2\nwhile (z*(z-1))//2 <m:\n z+=1\nprint(x,max(n-z,0))"}, {"source_code": "n, m = list(map(int,input().split()))\nans1 = max(0, n - m*2)\nfor i in range(n):\n if i*(i-1)/2 > m:\n break\nans2 = n-i\nprint(ans1 , ans2)"}, {"source_code": "#!/usr/bin/python3\nfrom math import factorial as f\n\ndef readint():\n return int(input())\n\n\ndef readline():\n return [int(c) for c in input().split()]\n\ndef ncr2(n):\n return n * (n-1) // 2\n\ndef main():\n N, M = readline()\n\n\n if N == 1:\n print('1 1')\n return\n\n # _min = N - 2 * M\n\n i = N\n edges = M\n while i - 2 >= 0 and edges > 0:\n i -= 2\n edges -= 1\n\n _min = i\n \n nodes = 0\n rem = 1\n _max_nodes = 3\n for i in range(2, N):\n if i > N:\n break\n \n edges = i * (i-1) // 2\n if edges < M:\n _max_nodes = i\n elif edges == M:\n _max_nodes = i\n rem = 0\n else:\n break\n \n\n _max = N - _max_nodes - rem\n tmp = _min\n _min = min(_min, _max)\n _max = max(tmp, _max)\n \n print(str(_min) + ' ' + str(_max))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nn, m = map(int, input().split())\nmini = max(0, n - 2*(math.floor(n/2)))\ntemp = 1\ncount = 1\nwhile(temp<m):\n count += 1\n temp += count\nprint(mini, n-count-1)\n"}, {"source_code": "n,m=map(int,input().split())\nprint(n-2*m if n-2*m >= 0 else 0,(n-m-1 if n-m-1 >= 0 else 0) if m != 0 else n)"}, {"source_code": "n,m=input().split(' ')\nn=int(n)\nm=int(m)\nprint(max(0,(n-2*m)),end=\" \")\nprint(max(0,n-(m+1)))"}, {"source_code": "n, m = list(map(int, input().split()))\n\n\nmin_ans = max(0, (n + 1) // 2 - m)\n\nif m == 0:\n print(n, 0)\n exit()\n\nfor i in range(1, n + 1):\n if m <= i * (i - 1) // 2:\n print(min_ans, n-i)\n exit()\n\nprint(min_ans, 0)\n"}, {"source_code": "from sys import stdin,stdout\nfrom math import gcd,sqrt\nfrom collections import deque\ninput=stdin.readline\nR=lambda:map(int,input().split())\nI=lambda:int(input())\nS=lambda:input().rstrip('\\n')\nL=lambda:list(R())\nP=lambda x:stdout.write(x)\nhg=lambda x,y:((y+x-1)//x)*x\npw=lambda x:1 if x==1 else 1+pw(x//2)\nchk=lambda x:chk(x//2) if not x%2 else True if x==1 else False\nN=2*10**5+1\nn,m=R()\nprint(max(n-2*m,0),max(0,n-m-1))"}, {"source_code": "n, m = map(int, input().split())\nMax = 1\nMin = 1\nif m > 1:\n Max = n - (m + 1) + m % 2\n Min = n - m * 2\nprint(Min, Max)\n"}, {"source_code": "d = list(map(int, input().split(' ')))\nmn = d[0] - d[1]*2\nn = 1\ns = 0\nwhile(s < d[1]):\n s += n\n n += 1\nif(d[1] == 0):\n n = 0\nprint(mn , d[0] - n)"}, {"source_code": "n, m = map(int, raw_input().split())\nif m == 0:\n print n, n\nelif m == 1:\n print n - 2, n - 2\nelif m == 2:\n print max(0, n - 4), n - 3\nelse:\n s = i = 0\n f = []\n while 1:\n s += i\n f.append(s)\n if s >= m:\n k = 0\n while m and f:\n x = f.pop()\n if m >= x:\n k += i\n i -= 1\n m -= x\n if m:\n k += 2\n break\n i += 1\n print max(0, n - 2 * m), max(0, n - k)\n"}, {"source_code": "n, m = list ( map( int, input().split() ) )\n\nhow = 1\nfor i in range(1,n+1):\n tmp = int( i * (i-1) / 2 )\n if tmp >= m:\n how = n-i\n break\n\nif n == m and n == 1:\n ans1 = 0\nelse:\n ans1 = max(0,n-2*m)\n\nprint( ans1, how )\n"}, {"source_code": "n,m = map(int,input().split())\nif(n>=3 and m>2):\n\tm = m-1\nmaxi = n-m-1\t\nif(maxi<=0):\n\tmaxi = 0\nmini = n-2*m\nif(mini<=0):\n\tmini = 0\nprint(mini,maxi)\n"}, {"source_code": "n, m = map(int, input().split())\nif n - 2 * m < 0:\n\tprint(0, max(1, (n - int(round(1 + (1 + 8 * m)**0.5) / 2))))\nelse:\n\tprint(n - 2 * m, max(1, (n - int(round(1 + (1 + 8 * m)**0.5) / 2))))\n"}, {"source_code": "\n\n\n\n\n\n\n\na,b=[int(i) for i in input().split()]\nx=b*2\nif a>x:\n print(a-x,end=\" \")\nelse:\n print(0,end=\" \")\n\nif b>0:\n b=b+1\nx=b\nif a<=x:\n print(0,end=\" \")\nelse:\n print(a-x,end=\" \")"}, {"source_code": "import math as ma\nimport sys\nfrom sys import exit\nfrom decimal import Decimal as dec\nfrom itertools import permutations\n\ndef li():\n\treturn list(map(int , input().split()))\n\n\n# https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/\ndef modInverse(a , m):\n\tm0 = m\n\ty = 0\n\tx = 1\n\tif (m == 1):\n\t\treturn 0\n\twhile (a > 1):\n\t\tq = a // m\n\t\tt = m\n\t\tm = a % m\n\t\ta = t\n\t\tt = y\n\t\ty = x - q * y\n\t\tx = t\n\tif (x < 0):\n\t\tx = x + m0\n\treturn x\n\n\ndef num():\n\treturn map(int , input().split())\n\n\ndef nu():\n\treturn int(input())\n\n\ndef find_gcd(x , y):\n\twhile (y):\n\t\tx , y = y , x % y\n\treturn x\n\n\nn,m=num()\nmx=0\nfor i in range(1,n+1):\n\tz=i*(i-1)//2\n\tif(m>z):\n\t\tcontinue\n\tmx=n-i\n\tbreak\nif(m==0):\n\tmx=n\nmn=0\nif(n%2==0):\n\tif(m<=n//2):\n\t\tmn=n//2-m\nelse:\n\tzp=n//2\n\tif(m<=zp):\n\t\tmn=zp-m+1\nif(m==0):\n\tmn=n\nprint(mn,mx)"}, {"source_code": "n,m = map(int,input().split())\nif(n>=3 and m>2):\n\tm = m-1\nmaxi = n-m-1\t\nif(maxi<=0):\n\tmaxi = 0\nmini = n-2*m\nif(mini<=0):\n\tmini = 0\nprint(mini,maxi)\n"}, {"source_code": "n, m = map(int, input().split())\n\nres = 0\n\nif m * 2 > n:\n res = 0\nelse:\n res = n - (m * 2)\n\nprint(res, n - (m + 1))"}, {"source_code": "n, m = map(int, input().split())\nif (n == 1):\n print(1, 1)\nelse:\n print(max(n - m * 2, 0), max(n - 1 - m, 0))"}, {"source_code": "masukan = [int(item) for item in input().split(\" \")]\nn = masukan[0] # vertex\nm = masukan[1] # edges\n\ndef getMin():\n if n/m <= 2:\n return 0\n else:\n return n - (m*2)\n\ndef getMax():\n numEdge = 0\n for i in range(2,n+1):\n # print(\"vertex ke: \",i)\n if numEdge < m:\n numPosEdge = i*(i-1)/2\n numEdge = numPosEdge\n # print(\"possible edge: \",numPosEdge)\n # print(\"edge skrg: \",numEdge)\n else:\n return n-(i-1)\n # return n-i\nif n == 0:\n print(0,0)\nelif m == 0:\n print(n,n)\nelif m >= n*(n-1)/2:\n print(0,0)\nelse:\n print(getMin(), getMax())"}, {"source_code": "n, m = map(int, input().split())\nmn, mx = -1, -1\nmn = max(0, (n + 1) // 2 - m)\n\nmx = 1\nwhile mx * (mx - 1) // 2 < m:\n\tmx += 1\nif n == 1:\n\tmx = 0\nprint(mn, n - mx)"}, {"source_code": "import math\nn,m = map(int,input().split())\nmaxv = -1\nminv = n-2*m if n>=2*m else 0\nprek = int((1+math.sqrt(1+8*m))/2)\nfor i in range(prek-2,prek+2):\n if m<=(i*(i-1)/2):\n maxv = max(n-i,maxv)\nprint(minv,maxv)"}, {"source_code": "n, m = [int(s) for s in input().split()]\ns, i = 0, 0\nmin = n - m*2\nif min < 0:\n print(0, end=' ')\nelse:\n print(min, end=' ')\nwhile s < m:\n i += 1\n s += i\nmax = n - (i+1)\nif max < 0:\n print(0, end='')\nelse:\n print(max, end=' ')"}, {"source_code": "n, m = map(int, input().split())\n\nres = 0\n\nfor i in range(n + 1):\n if i ** 2 - i - 2 * m >= 0:\n res = i\n\nprint(max(n - 2 * m, 0), max(n - res, 0))"}, {"source_code": "n,m=map(int,input().split())\nminn=n-min(m*2,n)\ndp=[0 for i in range(100007)]\ndp[1]=1\nq=0\nif 1>=m:\n q=2\nelse:\n for i in range(2,len(dp)):\n dp[i]=dp[i-1]+i\n if dp[i]>=m:\n q=i+1\n break\nmaxx=n-q\nprint(minn,maxx)\n"}, {"source_code": "n,m=map(int,input().split())\nprint(max(n-2*m,0),n-1-int(((8*m+1)**.5)/2))"}, {"source_code": "n, m = map(int, input().split(' '))\n\nif m >= n - 1:\n mx = n\nelse:\n mx = n - m - 1\n\nif m * 2 > n:\n mn = 0\nelse:\n mn = n - m * 2\n\nprint(mn, mx)"}, {"source_code": "import math\nneed=0\nn, m = map(int, input().split())\n\n\nsum=math.ceil(n/2)\nif sum>=m:\n need=n-2*m\n\nmx=n-m-1\nif m==0:\n print(n,n)\nelse:\n print(need,mx)"}, {"source_code": "#!/usr/bin/python3\nfrom math import factorial as f\n\ndef readint():\n return int(input())\n\n\ndef readline():\n return [int(c) for c in input().split()]\n\ndef ncr2(n):\n return n * (n-1) // 2\n\ndef main():\n N, M = readline()\n\n\n if N == 1:\n print('1 1')\n return\n\n _min = N - 2 * M\n \n nodes = 0\n rem = 1\n for i in range(2, N):\n edges = i * (i-1) // 2\n if edges < M:\n _max_nodes = i\n elif edges == M:\n _max_nodes = i\n rem = 0\n else:\n break\n \n\n _max = N - _max_nodes - rem\n \n print(str(_min) + ' ' + str(_max))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin,stdout\nfrom collections import Counter\ndef ai(): return list(map(int,input().split()))\ndef ei(): return map(int,input().split())\ndef ip(): return int(stdin.readline())\ndef op(ans): return stdout.write(str(ans) + '\\n') \n\nn,m = ei()\nmin = max(0,n-2*m)\nk = 0\nwhile k*(k-1) <= 2*m:k+=1\nprint(min,n-k)"}, {"source_code": "n, m = map(int, input().split())\n\nif m * 2 > n:\n print(0, 0)\nelse:\n print(n - m * 2, n - (m + 1))"}, {"source_code": "n, m = map(int, input().split())\n\nif n > m * 2:\n print(n - m * 2, n - (m + 1))\nelse:\n if n - (m + 1) >= 0:\n print(0, n - (m + 1))\n else:\n print(0, 0)"}, {"source_code": "n,m=map(int,raw_input().split())\nif 2*m>=n:\n\tprint 0,\nelse:\n\tprint n-2*m,\na=(pow(1+8*m,0.5)+1)/float(2)\nif int(a)!=a:\n\ta=int(a)+1\nif a>=n:\n\tprint 0\n\texit(0)\nprint int(n-a)\t"}, {"source_code": "n, m = map(int, input().split())\nif n <= 2 * m:\n mn = 0\nelse:\n mn = n - 2 * m\n\nif m == ((n - 1) * n) // 2:\n ans = 0\nelse:\n for i in range(n + 1):\n if i * (i - 1) // 2 >= m:\n ans = n - i\n break\n\nprint(mn, ans)\n"}, {"source_code": "import math as ma\nimport sys\nfrom sys import exit\nfrom decimal import Decimal as dec\nfrom itertools import permutations\n\ndef li():\n\treturn list(map(int , input().split()))\n\n\n# https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/\ndef modInverse(a , m):\n\tm0 = m\n\ty = 0\n\tx = 1\n\tif (m == 1):\n\t\treturn 0\n\twhile (a > 1):\n\t\tq = a // m\n\t\tt = m\n\t\tm = a % m\n\t\ta = t\n\t\tt = y\n\t\ty = x - q * y\n\t\tx = t\n\tif (x < 0):\n\t\tx = x + m0\n\treturn x\n\n\ndef num():\n\treturn map(int , input().split())\n\n\ndef nu():\n\treturn int(input())\n\n\ndef find_gcd(x , y):\n\twhile (y):\n\t\tx , y = y , x % y\n\treturn x\n\n\nn,m=num()\nmx=0\nfor i in range(1,n+1):\n\tz=i*(i-1)//2\n\tif(m>z):\n\t\tcontinue\n\tmx=n-i\n\tbreak\nif(m==0):\n\tmx=n\nmn=0\nif(n%2==0):\n\tif(m<=n//2):\n\t\tmn=n//2-m\nelse:\n\tzp=n//2+1\n\tif(m<=zp):\n\t\tmn=zp-m\nprint(mn,mx)"}, {"source_code": "n, m = map(int, raw_input().split())\nprint max(0, n - 2*m), max(0, n - m - 1)"}, {"source_code": "# In this template you are not required to write code in main\n\nimport sys\ninf = float(\"inf\")\n\nsys.setrecursionlimit(1000000)\n#from cmath import sqrt\n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd\n#from bisect import bisect_left,bisect_right\n#import numpy as np\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\n\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef input(): return sys.stdin.readline().strip()\n\nn,m=get_ints()\nif m>=n:\n print(0,0)\nelse:\n if m>=(n+1)//2:\n print(0,n-(m+1))\n else:\n print(n-2*m,n-(m+1))"}], "src_uid": "daf0dd781bf403f7c1bb668925caa64d"} {"source_code": "a, b = [int(i) for i in input().split()]\r\nif b == 1:\r\n print(a-1)\r\nelse:\r\n print(a*(b-1))", "positive_code": [{"source_code": "a = map(int,raw_input().split())\nif a[0]==1:\n print(a[1]-1)\n quit()\nif a[1]==1:\n print(a[0]-1)\n quit()\nprint((a[1]-1)*a[0])\n\t\t\t \t \t \t\t \t\t\t\t\t\t\t\t\t\t\t\t \t"}, {"source_code": "M = list(map(int, input().split(' ')))\r\nif M[1] != 1:\r\n x = M[0] * (M[1] - 1)\r\n print(x)\r\nelse:\r\n print(M[0] - 1)"}, {"source_code": "n,m=map(int,input().split())\r\nif(m==1): n,m=m,n\r\nprint(n*(m-1))"}, {"source_code": "l,b = map(int, input().split())\r\n\r\nif b >= 2:\r\n print(l*(b-1))\r\nelse:\r\n print(l-1)"}, {"source_code": "inp = list(map(int,input().split()))\r\nn = inp[0]\r\nm = inp[1]\r\n\r\nif m == 1:\r\n print(n-1)\r\nelse:\r\n print(n*(m-1))"}, {"source_code": "def solution(n, m):\r\n if n == 1 or m == 1:\r\n return (m*n - 1)\r\n else:\r\n return (m*n - n)\r\n\r\nn,m = [int(x) for x in input().strip().split(\" \")]\r\nprint(solution(n, m))"}, {"source_code": "N, M = [int(n) for n in input().split(' ')]\ntight_dominos = 0\n\nif N == 1:\n tight_dominos = M-1\nelif M == 1:\n tight_dominos = N-1\nelse:\n tight_dominos = N * (M-1)\nprint(tight_dominos)"}, {"source_code": "ch=input()\r\nl=ch.split()\r\nn=int(l[0]) \r\nm=int(l[1])\r\nif n>1 and m==1:\r\n\tprint(n-1)\r\nelse:\r\n\tprint((m-1)*n)"}, {"source_code": "n,k = map(int,input().split())\r\na = 0\r\n# if(k-1==0):\r\n# \tprint(k)\r\n# else:\r\nif((n>k) and (k==1)):\r\n\ta= ((n-1)*1)\r\nelse:\r\n\tif((n>k) and (k!=1)):\r\n\t\ta =(k-1)*n\r\n\telse:\r\n\t\tif(k>n):\r\n\t\t\ta= ((k-1)*n)\r\nif(n==k):\r\n\ta= ((k-1)*n)\r\nprint(a)\r\n\r\n\r\n\t\r\n\r\n"}, {"source_code": "n,m = map(int,input().split())\r\nif m > 1 and n >= 1:\r\n print(n*(m-1))\r\nelif m == 1 and n > 1:\r\n print(n-1)\r\nelif m == 1 and n == 1:\r\n print(0)"}, {"source_code": "N, M = map(int, input().split())\r\n\r\nif N == 1 or M == 1:\r\n print((N*M) - 1)\r\nelse:\r\n print((N * M) - N)"}, {"source_code": "import typing\n\n\ndef rit(*args) -> typing.Iterator:\n \"\"\"Read input and yield split cast values.\n \"\"\"\n func, funcs = int, (int, float, str)\n sep = \" \"\n for a in args:\n if a in funcs:\n func = a\n elif isinstance(a, str):\n sep = a\n return map(func, input().strip().split(sep))\n\n\ndef pit(itr: typing.Iterable, sep:str=\" \") -> None:\n print(sep.join(map(str, itr)))\n\n\ndef main():\n n, m = rit(int)\n \n if m > 1:\n print(n * (m-1))\n else:\n print(n-1)\n\n\nmain()\n"}, {"source_code": "\r\ndef main():\r\n \r\n n, m = readIntArr()\r\n if m == 1:\r\n n, m = m, n\r\n ans = n * (m - 1)\r\n print(ans)\r\n \r\n return\r\n\r\nimport sys\r\ninput=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)\r\n# input=lambda: sys.stdin.readline().rstrip(\"\\r\\n\") #FOR READING STRING/TEXT INPUTS.\r\n \r\ndef oneLineArrayPrint(arr):\r\n print(' '.join([str(x) for x in arr]))\r\ndef multiLineArrayPrint(arr):\r\n print('\\n'.join([str(x) for x in arr]))\r\ndef multiLineArrayOfArraysPrint(arr):\r\n print('\\n'.join([' '.join([str(x) for x in y]) for y in arr]))\r\n \r\ndef readIntArr():\r\n return [int(x) for x in input().split()]\r\n# def readFloatArr():\r\n# return [float(x) for x in input().split()]\r\n \r\ndef makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])\r\n dv=defaultValFactory;da=dimensionArr\r\n if len(da)==1:return [dv() for _ in range(da[0])]\r\n else:return [makeArr(dv,da[1:]) for _ in range(da[0])]\r\n \r\ndef queryInteractive(a, b, c):\r\n print('? {} {} {}'.format(a, b, c))\r\n sys.stdout.flush()\r\n return int(input())\r\n \r\ndef answerInteractive(x1, x2):\r\n print('! {} {}'.format(x1, x2))\r\n sys.stdout.flush()\r\n \r\ninf=float('inf')\r\n# MOD=10**9+7\r\n# MOD=998244353\r\n \r\nfrom math import gcd,floor,ceil\r\nimport math\r\n# from math import floor,ceil # for Python2\r\n \r\nfor _abc in range(1):\r\n main()"}, {"source_code": "a,b=map(int,input().split())\r\nif(b==1):\r\n print(a-1)\r\nelse:\r\n print((b-1)*a)"}, {"source_code": "n,m = map(int,input().split())\r\nif n== m==1:\r\n print(0)\r\nelif m == 1:\r\n print(n-1)\r\nelif n == 1:# and m ==2:\r\n print(m-1)\r\nelse:\r\n print((m-1)*n)"}, {"source_code": "n,m = map(int, input().split())\r\nif(m==1) :\r\n print(n-1)\r\nelse :\r\n print((m-1)*n)"}, {"source_code": "n,m= map(int,input().split())\r\nans=0\r\nif m>1:\r\n ans=(m-1)*n\r\nelse:\r\n ans=n-1\r\nprint(ans)\r\n"}, {"source_code": "n, m = map(int, input().split())\r\n\r\nif m == 1:\r\n print(n-1)\r\n\r\nelse:\r\n print((m-1)*n)"}, {"source_code": "def tight_dominos(m,n):\r\n if m == 1 and n == 1:\r\n return 0\r\n elif m == 1:\r\n return n - 1\r\n elif n == 1:\r\n return m - 1\r\n else:\r\n return (n-1)*m\r\n \r\nx, y = input(\"\").split()\r\na=int(x)\r\nb=int(y)\r\n \r\nprint(tight_dominos(a,b))"}, {"source_code": "m,n=map(int,input().split())\r\nif(n==1):\r\n\tprint(m-1)\r\nelif(m==1):\r\n\tprint(n-1)\r\nelse:\r\n\tprint((n-1)*m)"}, {"source_code": "n, m=[int(x) for x in input().split()]\nif m==1:\n print(n-1)\nelse:\n print(n*(m-1))\n"}, {"source_code": "infor = input().split()\nrows = int(infor[0])\ncolumns = int(infor[1])\nif columns > 2:\n nums = columns - 1\n final = nums * rows\n print (final)\nelif columns == 2:\n final = rows\n print (final)\nelse:\n # columns == 1\n final = rows - 1\n print (final)"}, {"source_code": "n, m= map(int, input().split())\r\n\r\nif (n == 1) and (m == 1):\r\n print(0)\r\nelif (n == 1) and (m > 1):\r\n print(m-1)\r\nelif (m == 1) and (n > 1):\r\n print(n-1)\r\nelif (n > 1) and (m > 1):\r\n print(n*(m-1))"}, {"source_code": "\r\n\r\nrows_and_columns = input()\r\nspace = rows_and_columns.split()\r\nread = int(space[0])\r\nveerud = int(space[1])\r\n\r\nif read == 1:\r\n print(veerud - 1)\r\nelif veerud == 1:\r\n print(read - 1)\r\nelse:\r\n print((veerud - 1) * read)\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nif m != 1:\r\n print((m - 1) * n)\r\nelse:\r\n print(n - 1)"}, {"source_code": "import sys,math\r\nrow,column=map(int, sys.stdin.readline().split())\r\nif column>1:\r\n print(row*(column-1))\r\nelse:print(row-1)"}, {"source_code": "grid=(input()).split()\r\nif int(grid[1])==1:\r\n print(int(grid[0])-1)\r\nelif int(grid[1])<1:\r\n print(0)\r\nelse:\r\n print((int(grid[1])-1)*int(grid[0]))"}, {"source_code": "s = input()\n\r\ns_lst = s.split()\r\n\ny = 0\r\n\r\n\nn = int(s_lst[0])\r\n\nm = int(s_lst[-1])\r\n\r\nif (n == 1 and m == 2) or (n == 2 and m == 1):\n \r\n\ty = 1\r\n\r\n\nelif (m == 1 and n != 2) or (n == 1 and m != 2):\n \r\n\ty = max([n,m]) - 1\r\n\nelse:\n \r\n\ty = n * (m - 1)\n \r\n\r\n\nprint(y)"}, {"source_code": "N, M = map(int, input().split())\r\n\r\nif M != 1:\r\n print((M - 1) * N)\r\nelse:\r\n print(N - 1)\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,m=map(int,input().split())\r\nif n==1 and m==1:\r\n\tprint(0) \r\nelif m==1:\r\n\tprint(n-1)\t \r\nelse:\r\n\tprint(n*(m-1))\t"}, {"source_code": "n,m=map(int,input().split())\r\nif 1==m:\r\n print(n-1)\r\nelse:\r\n print(n*(m-1))"}, {"source_code": "t=1\r\nwhile t:\r\n n,m=map(int,input().strip().split())\r\n ans=max((m-1)*n,-1)\r\n if m==1:\r\n ans=n-1\r\n print(ans)\r\n t-=1\r\n "}, {"source_code": "n, m = map(int, input().split())\r\nprint((m - 1) * n if m > 1 else n - 1)\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nif m == 1:\r\n n, m = m, n\r\n\r\nprint(n * (m - 1))\r\n"}, {"source_code": "NM = [int(i) for i in input().split()]\r\nif NM[1] == 1:\r\n print(NM[0] - 1)\r\nelse:\r\n print(NM[0] * (NM[1] - 1))"}, {"source_code": "r,c=map(int,input().split())\r\nif c==1:\r\n print(r-1)\r\nelse:\r\n print(r*(c-1))"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\ndef main():\r\n n, m = map(int, input().split())\r\n if n == 1 and m == 1:\r\n ans = 0\r\n else:\r\n if m == 1:\r\n ans = n - 1\r\n else:\r\n ans = (m - 1) * n\r\n print(ans)\r\n\r\n\r\n\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._file = file\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n"}, {"source_code": "n, m = map(int, input(). split())\r\nans = (m - 1) * n\r\nif m == 1:\r\n ans = (n - 1)\r\nprint(ans)\r\n"}, {"source_code": "n, m = map(int, input().split())\r\n\r\nprint(max(n-1, n * (m-1)))"}, {"source_code": "def main():\n a = input();\n n, m = map(int, [i for i in a.split()])\n if m == 1:\n return n - 1\n else:\n return (m-1)*n\n # ans = [];\n # a1, a2 = 1, 2;\n # for i in range(1, n + 1):\n # sna = [];\n # if i == 1:\n # for i in range(1, m + 1):\n # sna.append(i);\n # sna.append(8)\n # else:\n # for i in range(a1*m+1, a2*m + 1):\n # sna.append(i);\n # sna.append(0);\n # a1 += 1;\n # a2 += 1;\n # ans.append(sna);\n \n\n # for i in range(len(ans)):\n # f = 1;\n # try:\n # for j in range(len(ans[i])):\n # if abs(ans[i][j] - ans[i][j+1]) == 1:\n # c += 1;\n # if abs(ans[i][j] - ans[f][j]) == 1:\n # c += 1;\n # f += 1; \n # except:\n # ...\nprint(main())"}, {"source_code": "r,c = map(int,input().split())\r\nif c == 1:\r\n print(r -1)\r\nelse:\r\n print((c-1)*r)"}, {"source_code": "\r\n\r\n\r\ndef solve():\r\n n, m = [int(i) for i in input().split(' ')]\r\n if(m > 1):\r\n print(n * (m-1))\r\n else:\r\n print(n-1)\r\n\r\n\r\n\r\n\r\nsolve()\r\n"}, {"source_code": "tt = list(map(int,input().split()))\r\nif tt[1]!=0 or tt[1]!=0:\r\n if tt[1]==1:\r\n print((tt[0]*tt[1]) -1)\r\n else:\r\n print((tt[0]*(tt[1] -1)))\r\nelse:\r\n print(0)"}, {"source_code": "import sys\n#import math\ntoks = (token for token in sys.stdin.read().split())\n# toks2=sys.stdin.read().split()\n# print(toks2)\n\n\n# N=int(next(toks))\n# M=int(next(toks))\n# X=int(next(toks))\n# T=int(next(toks))\n# D=int(next(toks))\n\n# age=0\n# height=T\n\n# if M<X:\n# height=height-D*(X-M)\n\n# print(height)\n\n\n# arr=[]\n# for i in range(5):\n# n=int(next(toks))\n# if n not in arr:\n# arr.append(n)\n\n# print(len(arr))\n\n# N=int(next(toks))\n# X=int(next(toks))\n\n# sum=0\n# for i in range(N):\n# sum+=int(next(toks))\n\n# sum=abs(sum)\n\n# print(math.ceil(sum/X))\n\nN=int(next(toks))\nM=int(next(toks))\nif(M==1):\n print(N-1)\nelse:\n print((M-1)*N)\n \t\t\t\t \t \t\t\t\t \t\t\t \t \t \t\t\t"}, {"source_code": "n,m = map(int, input().split())\r\nif m>1:\r\n print(n*(m-1))\r\nelse:\r\n print((n-1)*m)"}, {"source_code": "# Libraries\r\n\r\nimport sys\r\nfrom math import *\r\nfrom queue import PriorityQueue\r\n\r\n# Definitions\r\nmod = pow(10,9)+7\r\ne = pow(10,-6)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\npq = PriorityQueue()\r\n# sys.setrecursionlimit(10**6)\r\n\r\n#Input forms\r\n\r\ndef imap():\r\n return map(int,input().split())\r\n\r\ndef ilist():\r\n return list(map(int,input().split()))\r\n\r\n# Common functions\r\n\r\ndef freq(l):\r\n d = {}\r\n for i in l:\r\n d[i] = d.get(i,0)+1\r\n return d\r\n\r\ndef lgcd(l):\r\n a = 0\r\n for i in l:\r\n a = gcd(a,i)\r\n return a\r\n\r\ndef SieveOfEratosthenes(num):\r\n prime = [True for i in range(num+1)]\r\n p = 2\r\n while (p * p <= num):\r\n if (prime[p] == True):\r\n for i in range(p * p, num+1, p):\r\n prime[i] = False\r\n p += 1\r\n return p[2:]\r\n\r\ndef bs_on_ans(l,r):\r\n for i in range(100):\r\n mid = (l+r)/2\r\n # if f(mid)>f(mid+e):\r\n # l = mid+e\r\n # else:\r\n # if f(mid-e)>f(mid):\r\n # break\r\n # else:\r\n # r = mid-e\r\n return mid\r\n \r\n# Starting off; \r\n\r\nt = 1\r\nfor _ in range(t):\r\n n,m = imap()\r\n if m == 1:\r\n print(n-1)\r\n else:\r\n print(n*(m-1))\r\n\r\n\r\n\r\n\r\n\r\n###################################################### By Shri ##############################################################\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nif m==1:\r\n k=(n-1)*m\r\n print(k)\r\nelse:\r\n k=(m-1)*n\r\n print(k)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline \r\n\r\nn, m = map(int, input().split())\r\nif(m == 1):\r\n print(n * m - 1)\r\nelse:\r\n print(n * m - n)"}, {"source_code": "n,m = [int(i) for i in input().split()]\r\nif(m == 1):\r\n print(n-1)\r\nelse:\r\n print((m-1)*n)"}, {"source_code": "n, m = map(int, input().split(' '))\nif(m == 1):\n\tprint(n-1)\nelse:\n\tprint(n*(m-1))\n"}, {"source_code": "n = list(map(int,input().split()))\nif(n[1] == 1):\n\tprint(n[0]-1)\nelse:\n\tprint(n[0]*(n[1]-1))"}, {"source_code": "N, M = map(int, input().split())\r\nif M == 1:\r\n print(N - 1)\r\n exit()\r\nprint((M - 1) * N)\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nif m == 1:\r\n print(n-1)\r\nelif n == 1:\r\n print(m-1)\r\nelse:\r\n print((m-1)*n)"}, {"source_code": "n , m = map(int, input().split())\r\nif n==1:\r\n print(m-1)\r\nelif m==1:\r\n print(n-1)\r\nelse:\r\n print(n*m - n)"}, {"source_code": "print(*map(lambda x: max(int(x[0])-1, int(x[0])*(int(x[1])-1)), [input().split()]))"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\nif(m == 1):\n print(n-1)\nelif(n == 1):\n print(m-1)\nelse:\n print((m-1)*n)\n \t \t\t\t\t \t\t \t\t\t\t\t \t \t\t \t"}, {"source_code": "a,b=map(int, input().split())\r\nif b>1:\r\n print(a*(b-1))\r\nelse:print(a-1)"}, {"source_code": "n1,n2=map(int, input().split())\r\nif n2>1:\r\n print(n1*(n2-1))\r\nelse:\r\n print(n1-1)"}, {"source_code": "n,m = map(int,input().split())\r\nprint(max(n*(m-1),n-1,m-1))"}, {"source_code": "n , m =map(int,input().split())\r\nif m==1:\r\n print(n-1)\r\nelse:\r\n print(n*(m-1))"}, {"source_code": "x = list(map(int,input().split()))\r\n\r\n\r\nif x[1] ==1 :\r\n print(x[0]-1)\r\nelse:\r\n print((x[1]-1)*x[0])\r\n"}, {"source_code": "import sys\n#sys.setrecursionlimit(20000)\n#from collections import deque #Counter\n#from itertools import accumulate, product\n#from functools import reduce\n#import math\n\n\ndef rall():\n return [x.strip() for x in sys.stdin.readlines()]\ndef rl():\n return sys.stdin.readline().strip()\ndef rl_types(types):\n str_list = [x for x in sys.stdin.readline().strip().split(' ')]\n return [types[i](str_list[i]) for i in range(len(str_list))]\n\ndef pr( something='' ):\n sys.stdout.write( str(something) + '\\n')\ndef pra( array ):\n sys.stdout.write( ' '.join([str(x) for x in array]) + '\\n')\n\n\n\nif __name__ == '__main__':\n\n a,b = map(int,rl().split(' '))\n pr(a*(b-1) if b>1 else a-1)\n\n\n"}, {"source_code": "from __future__ import division, print_function\r\nfrom cmath import sqrt\r\nimport math\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\nif sys.version_info[0] < 3:\r\n from __builtin__ import xrange as range\r\n from future_builtins import ascii, filter, hex, map, oct, zip\r\n\r\ndef fib(n):\r\n if n < 2:\r\n return n \r\n else:\r\n return fib(n - 1) + fib(n - 2)\r\n\r\ndef factorial(n):\r\n ans = 1\r\n for i in range(1, n + 1):\r\n ans *= i \r\n return ans\r\n\r\ndef gcd(a, b):\r\n if b == 0:\r\n return a\r\n return gcd(b, a % b)\r\n\r\ndef isPowerOf(a, b):\r\n if b == 1 and a != 1:\r\n return False\r\n if b == 1 and a == 1:\r\n return True\r\n if a <= 0:\r\n return False\r\n if a % b == 0:\r\n return isPowerOf(a // b, b)\r\n if a == 1:\r\n return True\r\n return False\r\n\r\ndef l_bound(arr, n): # FIRST OCCURENCE OF ANY NUMBER IN ARRAY\r\n l, r, ans = 0, len(arr) - 1, -1 # [1,2,3,4,4,4,5,6,7] \r\n while l <= r:\r\n mid = (l+r) // 2\r\n if arr[mid] >= n:\r\n ans = mid\r\n r = mid - 1\r\n else:\r\n l = mid + 1\r\n return ans\r\n\r\ndef u_bound(arr, n): #[1,1,2,3,4,4,4,5,6]\r\n l, r, ans = 0, len(arr) - 1, -1\r\n while l <= r:\r\n mid = (l+r) // 2\r\n if arr[mid] > n:\r\n ans = mid\r\n r = mid - 1\r\n else:\r\n l = mid + 1 \r\n return ans\r\n\r\ndef main():\r\n r, c = map(int,input().split())\r\n if c == 1 or r == 1:\r\n print(max(r, c) - min(r,c))\r\n else:\r\n print((c - 1) * r)\r\n \r\n \r\n\r\n\r\n# region fastio\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._file = file\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\ndef print(*args, **kwargs):\r\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n at_start = True\r\n for x in args:\r\n if not at_start:\r\n file.write(sep)\r\n file.write(str(x))\r\n at_start = False\r\n file.write(kwargs.pop(\"end\", \"\\n\"))\r\n if kwargs.pop(\"flush\", False):\r\n file.flush()\r\n\r\n\r\nif sys.version_info[0] < 3:\r\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# endregion\r\n\r\nsys.setrecursionlimit(1000000000)\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "from collections import defaultdict, deque\r\nfrom io import BytesIO\r\nfrom os import fstat, read\r\nfrom sys import stdout\r\nfrom math import pi, sqrt, gcd, ceil, log2\r\n\r\ndef fast_input(file_no = 0):\r\n byte_stream = BytesIO(read(file_no, fstat(file_no).st_size))\r\n return byte_stream\r\n\r\n\r\n#fi = open(PATH_INPUT, \"r\")\r\n#io_byte_input = fast_input(fi.fileno())\r\nio_byte_input = fast_input()\r\n#fi.close()\r\nf_input = lambda: io_byte_input.readline().decode().strip()\r\n\r\ndef f_print(*output, sep = \"\\n\"):\r\n for i in output:\r\n stdout.write(str(i) + sep)\r\n #if sep != \"\\n\":\r\n # stdout.write(\"\\n\")\r\n\r\n#program starts here\r\nn, m = map(int, f_input().split())\r\nif m == 1:\r\n f_print((n - 1) * m)\r\nelse:\r\n f_print((m - 1) * n)\r\n \r\n\r\n\r\n\r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import os, sys\r\nfrom io import BytesIO, IOBase\r\nfrom array import array\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().strip()\r\nints = lambda: list(map(int, input().split()))\r\nInt = lambda: int(input())\r\n\r\n\r\ndef queryInteractive(a, b, c):\r\n print('? {} {} {}'.format(a, b, c))\r\n sys.stdout.flush()\r\n return int(input())\r\n\r\n\r\ndef answerInteractive(x1, x2):\r\n print('! {} {}'.format(x1, x2))\r\n sys.stdout.flush()\r\n\r\n\r\ninf = float('inf')\r\n\r\n\r\nn,m = ints()\r\n\r\nif m == 1:\r\n print(n-1)\r\nelse:\r\n print(n*(m-1))"}, {"source_code": "# cook your dish here\r\nt=1\r\n# t=int(input())\r\nwhile t>0:\r\n n,m=map(int,input().split())\r\n if m==1:\r\n print(n-1)\r\n else:\r\n print(n*(m-1))\r\n t-=1"}, {"source_code": "print((lambda a: a[0]*(a[1]-1) or (a[0]-1)) (list(map(int,input().split()))))"}, {"source_code": "import collections\r\ndef nCr(n, r):\r\n \r\n return (fact(n) / (fact(r)\r\n * fact(n - r)))\r\n \r\n# Returns factorial of n\r\ndef fact(n):\r\n if n == 0:\r\n return 1\r\n res = 1\r\n \r\n for i in range(2, n+1):\r\n res = res * i\r\n \r\n return res\r\n#########################################################################\r\ndef solve():\r\n n,m = map(int, input().split())\r\n if m==1:\r\n print(n-1)\r\n elif m>1:\r\n print(n*(m-1))\r\n\r\n##########################################################################\r\n\r\n\r\n#for _ in range(int(input())):\r\nsolve()\r\n \r\n"}, {"source_code": "a,b=map(int,input().split())\r\nif(b>1):\r\n print(a*(b-1))\r\nelif(b==1):\r\n print(a-1)\r\n "}, {"source_code": "a, b = map(int, input().split())\r\nprint(max((b == 1) * (a - 1), (b - 1) * a))"}, {"source_code": "from math import inf\r\nfrom collections import *\r\nimport math, os, sys, heapq, bisect, random,threading\r\nfrom functools import lru_cache\r\nfrom itertools import *\r\nimport sys\r\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\")\r\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\r\ndef inpu(): return int(inp())\r\ndef lis(): return list(map(int, inp().split()))\r\ndef stringlis(): return list(map(str, inp().split()))\r\ndef sep(): return map(int, inp().split())\r\ndef strsep(): return map(str, inp().split())\r\ndef fsep(): return map(float, inp().split())\r\n# #include <ext/pb_ds/assoc_container.hpp>\r\n# #include <ext/pb_ds/tree_policy.hpp>\r\n# using namespace __gnu_pbds;\r\n# #define ll long long\r\n# #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>\r\n# #define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>\r\nM,M1=1000000007,998244353\r\n\r\ndef main():\r\n how_much_noob_I_am = 1\r\n # how_much_noob_I_am = inpu()\r\n for _ in range(1,how_much_noob_I_am+1):\r\n n,m = sep()\r\n if m==1:\r\n print((n-1)*m)\r\n else:\r\n print(n*(m-1))\r\n\r\nif __name__ == '__main__':\r\n # sys.setrecursio0nlimit(2*10**5+50)\r\n # threading.stack_size(10**8)\r\n # threading.Thread(target=main).start()\r\n main()\r\n"}, {"source_code": "n,m = map(int,input().split())\r\nif m == 1:\r\n print(n-1)\r\nelse:\r\n print((m-1)*n)\r\n"}, {"source_code": "N, M = map(int, input().split())\n\nif M == 1:\n print(N - 1)\nelse:\n print(\n N * (M - 1)\n )"}, {"source_code": "N, M = map(int, input().split())\r\nif N == 1 or M == 1:\r\n print(max(N, M) - 1)\r\nelse:\r\n print(N*(M-1))\r\n"}, {"source_code": "n, m = map(int, input().split())\r\n\r\nif m > 1:\r\n print(n * (m - 1))\r\nelse:\r\n print(n - 1)"}, {"source_code": "from sys import stdin, setrecursionlimit, stdout\n#\tsetrecursionlimit(100000) #use \"python\" instead of \"pypy\" to avoid MLE\nfrom io import BytesIO\nimport os\nfrom collections import deque, Counter, defaultdict\nfrom math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin\n#from heapq import heapify, heappop, heappush, heapreplace, heappushpop\n#\tto use maxheap, invert all the number.. that means, multyply with -1\nfrom bisect import bisect_right, bisect_left\n#\tnumber of elements in a range is bisect_right(a, el)-bisect_left(a, el)\n\ndef ii(): return int(input().decode()) if OJ else int(input())\ndef fi(): return float(input().decode()) if OJ else float(input())\ndef mi(): return map(int, input().decode().split()) if OJ else map(int, input().split())\ndef fmi(): return map(float, input().decode().split()) if OJ else map(float, input().split(''))\ndef li(): return list(mi())\ndef si(): return input().decode().rstrip() if OJ else input().rstrip()\ndef lsi(): return list(si())\ndef oj():\n\tglobal OJ\n\tOJ=True\n#######################################################################################\n########################### M Y F U N C T I O N S ###########################\n#######################################################################################\n\n\n\n\n\n\n#######################################################################################\n########################### M A I N P R O G R A M ###########################\n#######################################################################################\n\ndef main():\n\tn, m=mi()\n\tprint(n*(m-1) if m>1 else n-1)\n\n\t\n\t\n\n\t\t\n\n\n \n \n\n\n\n\n\n\n\n#######################################################################################\n########################### S T A R T E R P A C K ###########################\n#######################################################################################\n\nif __name__==\"__main__\":\n\tOJ=False\n\t#oj()\n\n\tif OJ:\n\t\tinput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\telse:\n\t\tinput = stdin.readline\n\n\n\tvow={'A', 'E', 'I', 'O', 'U'}\n\tmod=1000000007\n\tres=['NO', 'YES']\n\n\t\n\n\ttest, test_case=0, 1\n\t#test_case=ii()\n\t#print('>>>>>>>>>>>>> O U T P U T >>>>>>>>>>>>>\\n' if not OJ else \"\")\n\twhile test<test_case:\n\t\ttest+=1\n\t\t#print('Case ', test, ': ', sep='', end='')\n\t\tmain()"}, {"source_code": "n,m=map(int,input().split())\r\nif m==1:print(n-1)\r\nif m!=1:print(n*(m-1))"}, {"source_code": "class Solution:\r\n def solve(line_in: str):\r\n n = int(line_in.split()[0])\r\n m = int(line_in.split()[1])\r\n\r\n if m == 1: return n - 1\r\n return n * (m - 1)\r\n \r\n \r\n\r\n def accumulationDominoes():\r\n line_in = input()\r\n print(Solution.solve(line_in))\r\n \r\n\r\nSolution.accumulationDominoes()"}, {"source_code": "def fun():\r\n n,m=map(int,input().split())\r\n if m==1:\r\n print((n-1)*m)\r\n else:\r\n print((m-1)*n)\r\nfun()"}, {"source_code": "a,b = map(int, input().split())\r\nif a ==b== 1:\r\n print(0)\r\nelif b == 1:\r\n print(a*b-1)\r\nelse:\r\n print(a*b-a)"}, {"source_code": "n, m = map(int, input().split())\n\nrowdom = m-1\ncolumndom = 0\nif m == 1: columndom = n-1\n\nres = rowdom * n + m * columndom\nprint(res)\n"}, {"source_code": "n, m = map(int, input().split())\r\nif m == 1 and n > 1:\r\n print((n-1)*m)\r\nelse:\r\n print((m-1)*n)"}, {"source_code": "x,u=map(int,input().split())\r\nif u==1:\r\n print(x-1)\r\nelse:\r\n print((u-1)*(x))"}, {"source_code": "a = input('')\r\n\r\nb = a.split()\r\nc = map(int, b)\r\n\r\nn = int(b[0])\r\nm = int(b[1])\r\n\r\nif m==1:\r\n # vertical distinct dominos\r\n print(n-1)\r\nelse:\r\n # horizontal distinct dominos\r\n print(n * (m-1))"}], "negative_code": [{"source_code": "def main():\n a = input();\n sas = [i for i in a.split()]\n n = int(sas[0]);\n m = int(sas[-1]);\n c = 0;\n ans = [];\n a1, a2 = 1, 2;\n for i in range(1, n + 1):\n sna = [];\n if i == 1:\n for i in range(1, m + 1):\n sna.append(i);\n else:\n for i in range(a1*m+1, a2*m + 1):\n sna.append(i);\n a1 += 1;\n a2 += 1;\n ans.append(sna);\n \n \n for i in range(len(ans)):\n f = 1;\n try:\n for j in range(len(ans[i])):\n if abs(ans[i][j] - ans[f][j]) == 1:\n c += 1;\n if abs(ans[i][j] - ans[i][j+1]) == 1:\n c += 1;\n f += 1; \n except:\n ...\n return c;\nprint(main())"}, {"source_code": "n, m=[int(x) for x in input().split()]\nprint ((m/2)*n)\n"}, {"source_code": "r,c=map(int,input().split())\r\nprint(r*(c-1))"}, {"source_code": "r,c = map(int,input().split())\r\nif r == 1 and c== 1:\r\n print(\"\")\r\nif c == 1:\r\n print(1)\r\nelse:\r\n print((c-1)*r)"}, {"source_code": "import sys\nimport math\ntoks = (token for token in sys.stdin.read().split())\n# toks2=sys.stdin.read().split()\n# print(toks2)\n\n\n# N=int(next(toks))\n# M=int(next(toks))\n# X=int(next(toks))\n# T=int(next(toks))\n# D=int(next(toks))\n\n# age=0\n# height=T\n\n# if M<X:\n# height=height-D*(X-M)\n\n# print(height)\n\n\n# arr=[]\n# for i in range(5):\n# n=int(next(toks))\n# if n not in arr:\n# arr.append(n)\n\n# print(len(arr))\n\n# N=int(next(toks))\n# X=int(next(toks))\n\n# sum=0\n# for i in range(N):\n# sum+=int(next(toks))\n\n# sum=abs(sum)\n\n# print(math.ceil(sum/X))\n\nN=int(next(toks))\nM=int(next(toks))\nprint((M-1)*N)\n \t \t \t \t \t\t\t\t\t \t \t"}, {"source_code": "n , m = map(int, input().split())\r\nif m%2 == 0 : \r\n i = m/2\r\n output = n * (2*i - 1)\r\nelse : \r\n if m == 1 : \r\n n , m = m, n\r\n i = (m-1)/2\r\n output = n * (2*i)\r\nprint(int(output))\r\n \r\n "}, {"source_code": "n,k = map(int,input().split())\r\na = 0\r\nif(k-1==0):\r\n\ta=n \r\n\tprint(a)\r\nelse:\r\n\ta=n*(k-1)\r\n\tprint(a)"}, {"source_code": "n,m=map(int,input().split())\r\na=n*m\r\nb=min(n,m)\r\nprint(a-b)"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import ceil\r\n\r\n\r\ndef main():\r\n n, m = map(int, input().split())\r\n if n == 1 and m == 1:\r\n ans = 0\r\n else:\r\n if m == 1:\r\n if n % 2 == 0:\r\n ans = n - 1\r\n else:\r\n ans = ceil(n / 2)\r\n else:\r\n if m % 2 == 0:\r\n each = m - 1\r\n else:\r\n each = ceil(m / 2)\r\n ans = each * n\r\n print(ans)\r\n\r\n\r\n\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._file = file\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n"}, {"source_code": "def main():\n a = input();\n sas = [i for i in a.split()]\n n = int(sas[0]);\n m = int(sas[-1]);\n c = 0;\n ans = [];\n a1, a2 = 1, 2;\n for i in range(1, n + 1):\n sna = [];\n if i == 1:\n for i in range(1, m + 1):\n sna.append(i);\n else:\n for i in range(a1*m+1, a2*m + 1):\n sna.append(i);\n a1 += 1;\n a2 += 1;\n ans.append(sna);\n \n \n for i in range(len(ans)):\n f = 1;\n try:\n for j in range(len(ans[i])):\n if abs(ans[i][j] - ans[f][j]) == 1:\n c += 1;\n if abs(ans[i][j] - ans[i][j+1]) == 1:\n c += 1;\n f += 1; \n except:\n ...\n return c;\nprint(main())"}, {"source_code": "n, m = map(int, input().split())\r\nprint((m - 1) * n if m > 1 else n)\r\n"}, {"source_code": "N,M=map(int,input().split())\r\nprint((M-1)*N)"}, {"source_code": "def tight_dominos(m,n):\r\n if m == 1 & n == 1:\r\n return 0\r\n elif m == 1:\r\n return n - 1\r\n elif n == 1:\r\n return m - 1\r\n else:\r\n return (n-1)*m\r\n\r\nx, y = input(\"\").split()\r\na=int(x)\r\nb=int(y)\r\n \r\nprint(tight_dominos(a,b))"}, {"source_code": "r,c=[int(i) for i in input().split()]\r\nif c==1:\r\n print(r-1)\r\nelse:\r\n print((r-1)*c)"}, {"source_code": "from sys import stdin,stdout\r\ndef ans():\r\n n,m=map(int,stdin.readline().strip().split())\r\n print((m-1)*n)\r\nif __name__=='__main__':\r\n ans()\r\n"}, {"source_code": "a, b = map(int, input().split())\r\nprint((a - 1) * (b - 1))"}, {"source_code": "n, m=[int(x) for x in input().split()]\nif m==1:\n print(1)\nelse:\n print(n*(m-1))\n"}, {"source_code": "m, n = map(int, input().split())\r\nprint((m*n)-(min(m,n)))"}, {"source_code": "N,M = input().split()\r\nN = int(N)\r\nM = int(M)\r\nx = None\r\nif M > 1 :\r\n x = 1 + M * (N - 1)\r\nelif M == 1 :\r\n x = N - 1\r\nelse :\r\n print(\"Error\")\r\nprint(x)"}, {"source_code": "import collections\nimport heapq\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom io import BytesIO, IOBase\nimport os\n######################################################################################\n#--------------------------------------func-----------------------------------------#\n######################################################################################\n\n\ndef valid(i, j, n, m):\n if i < n and i >= 0 and j >= 0 and j < m:\n return True # and l[i][j]==1 and visit[i][j]\n return False\n\n\ndef sumn(i, n):\n return (n-i)*(i+n)/2\n\n\ndef sqfun(a, b, c):\n return (-b+math.sqrt(b*b-4*a*c))/2*a\n\n\ndef getprime(num):\n if all(num % i != 0 for i in range(2, int(math.sqrt(num))+1)):\n return True\n\n######################################################################################\n#--------------------------------------vars-----------------------------------------#\n######################################################################################\n# index=[[1,0],[0,1],[-1,0],[0,-1]]\n# primes=[2,3,5,7,11,13,17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,\n# 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,\n# 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383,\n# 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541,\n# 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683,\n# 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857,\n# 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]\n######################################################################################\n#--------------------------------------Input-----------------------------------------#\n######################################################################################\n\n\ndef value(): return tuple(map(int, input().split()))\ndef values(): return tuple(map(int, sys.stdin.readline().split()))\ndef inlst(): return [int(i) for i in input().split()]\ndef inlsts(): return [int(i) for i in sys.stdin.readline().split()]\ndef inp(): return int(input())\ndef inps(): return int(sys.stdin.readline())\ndef instr(): return input()\ndef stlst(): return [i for i in input().split()]\n\n\n######################################################################################\n#--------------------------------------code here-------------------------------------#\n######################################################################################\n\ndef solve():\n a, b = values()\n print(min(a, b)**2)\n\n\nif __name__ == \"__main__\":\n # for i in range(inp()):\n solve()\n"}, {"source_code": "t=1\r\nwhile t:\r\n n,m=map(int,input().strip().split())\r\n ans=max((n-1)*m,(m-1)*n)\r\n print(ans)\r\n t-=1\r\n "}, {"source_code": "t=1\r\nwhile t:\r\n n,m=map(int,input().strip().split())\r\n ans=max((n-1)*m,(m-1)*n)\r\n print(ans)\r\n t-=1\r\n "}, {"source_code": "m,n=map(int,input().split())\r\nif(n==1):\r\n\tprint(m-1)\r\nelif(m==1):\r\n\tprint(n-1)\r\nelse:\r\n\tprint(n-1*m)"}, {"source_code": "N,M=input().split()\r\nprint((int(M)-1)*(int(N)))"}, {"source_code": "n, m = map(int, input().split())\r\n\r\nif m>1:\r\n print((m-1)*n)\r\nelse:\r\n print(n-1 if n>2 else n)"}, {"source_code": "x, y = input().split()\r\nx = int(x)\r\ny = int(y)\r\ndef calculate(x,y):\r\n if x+ y < 3:\r\n return 0\r\n if (x == 2 and y == 1) or (x==1 and y ==2):\r\n return 1\r\n return (x-1) * y\r\n "}, {"source_code": "n, m = map(int, input().split())\n\nrowdiff = m-1\ncolumndiff = 0\nif m == 1: columndiff = 1\n\nres = rowdiff * n + m * columndiff\nprint(res)\n"}, {"source_code": "r, c = [int(x) for x in input().split()]\r\nprint(min(r, c) * (max(r, c) - 1))"}, {"source_code": "n,m = map(int,input().split())\r\nif(m == 1):\r\n print(1)\r\nelse:\r\n print(n*(m-1))"}, {"source_code": "n, m = sorted(map(int, input().split()))\r\n\r\nprint(n * (m - 1))"}, {"source_code": "N, M = map(int, input().split())\r\n\r\narea = M * N\r\nans = int(area * (M - 1)/(M))\r\n\r\nif (M == 1):\r\n ans = N - 1\r\n\r\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\r\na=n*m\r\nb=min(n,m)\r\nprint(a-b)"}, {"source_code": "n,m=map(int,input().split())\r\nif m>n:\r\n print(n*(m-1))\r\nelse:\r\n print((n-1)*m)"}, {"source_code": "N,M = input().split()\r\nN = int(N)\r\nM = int(M)\r\nx = \"\"\r\nif M > 1 :\r\n x = 1 + M * (N - 1)\r\nelif M == 1 :\r\n x = N - 1\r\nelse :\r\n pass\r\nprint(x)"}, {"source_code": "r,c=map(int,input().split())\r\nprint(r*c-c)"}, {"source_code": "n,m = map(int,input().split())\r\nif(m == 1 and n == 1):\r\n print(0)\r\nelif(m == 1 and n!=1):\r\n print(1)\r\nelse:\r\n print(n*(m-1))"}, {"source_code": "t=1\r\nwhile t:\r\n n,m=map(int,input().strip().split())\r\n nn=max(n,m)\r\n mm=min(n,m)\r\n ans=max((nn-1)*mm,-1)\r\n print(ans)\r\n t-=1\r\n "}, {"source_code": "n,m=map(int,input().split())\r\nprint((m-1)*n)\r\n"}, {"source_code": "a, b = map(int, input().split())\r\nprint(max((a == 1) * (b - 1), (a - 1) * b))"}, {"source_code": "import math\r\n\r\nN, M = list(map(int, input().rstrip().split()))\r\n\r\nprint(N * M - min(N, M) * int(math.fabs(M - N)))\r\n"}, {"source_code": "N, M = map(int, input().split())\r\n\r\narea = M * N\r\nans = int(area * (M - 1)/(M))\r\n\r\nif (M == 1 and N != 1):\r\n ans = N - 1\r\nif (N == 1 and M != 1):\r\n ans = M - 1\r\n\r\nif (N == 767928735 and M == 1000000000):\r\n ans = 767928734232071265\r\n\r\nprint(ans)"}, {"source_code": "M,N=input().split()\r\nprint((int(M)-1)*(int(N)))"}, {"source_code": "def get():\r\n return list(map(int, input().split()))\r\ndef intput():\r\n return int(input())\r\narr=get()\r\nans=arr[1] -1 if arr[1]>1 else 1\r\nif (arr[1]!=1 ):\r\n print(ans*arr[0])\r\nelse:\r\n print(1)\r\n"}, {"source_code": "n, m = map(int, input().split())\r\n\r\nif m>1:\r\n print((m-1)*n)\r\nelse:\r\n print(n-1 if n>2 else n)"}, {"source_code": "\r\n\r\nrows_and_columns = input('')\r\nn = int(rows_and_columns[0])\r\nm = int(rows_and_columns[-1])\r\n\r\n\r\ntight_one_row = n - 1\r\n\r\nhow_many_tight = tight_one_row * m + 1\r\nprint(how_many_tight)\r\n"}, {"source_code": "\r\n\r\nrows_and_columns = input('')\r\nn = int(rows_and_columns[0])\r\nm = int(rows_and_columns[-1])\r\n\r\n\r\ntight_one_row = n - 1\r\n\r\nhow_many_tight = tight_one_row * m + 1\r\nprint(how_many_tight)\r\n"}, {"source_code": "import sys,math\r\nn,m=map(int, sys.stdin.readline().split())\r\nprint((min(n,m))*min(n,m))"}, {"source_code": "n,m = map(int,input().split())\r\nif(m == 1 and n == 1):\r\n print(0)\r\nelif(m == 1 and n!=1):\r\n print(1)\r\nelse:\r\n print(n*(m-1))"}, {"source_code": "import sys\r\nfrom os import path\r\nif(path.exists('Input.txt')):\r\n sys.stdin = open(\"Input.txt\",\"r\")\r\n sys.stdout = open(\"Output.txt\",\"w\")\r\n \r\nfrom math import gcd,floor,sqrt,log,ceil,inf\r\nimport math\r\nfrom collections import *\r\nfrom collections import deque\r\nfrom bisect import bisect_left\r\nfrom bisect import bisect_right\r\ndef li(): return list(map(int, sys.stdin.readline().split()))\r\ndef mp(): return map(int, sys.stdin.readline().split())\r\ndef inp(): return int(sys.stdin.readline())\r\ndef st(): return list(sys.stdin.readline().strip())\r\ndef out(*l): return print(*l)\r\ndef pr(n): return sys.stdout.write(str(n)+\"\\n\")\r\ndef prl(n): return sys.stdout.write(str(n)+\" \")\r\nM = 1000000007\r\nINF = float('inf')\r\nyes, no = \"YES\", \"NO\"\r\nimport operator as op\r\nfrom functools import reduce\r\ndef ncr(n, r):\r\n r = min(r, n-r)\r\n numer = reduce(op.mul, range(n, n-r, -1), 1)\r\n denom = reduce(op.mul, range(1, r+1), 1)\r\n return numer // denom\r\ndef fact(n):\r\n\treturn math.factorial(n)\r\ndef perfect(n):\r\n\treturn floor(sqrt(n))==ceil(sqrt(n))\r\ndef expo(n,x,M):\r\n\tn=(n**x)%M\r\n\treturn n\r\ndef lcm(a, b):\r\n return a * b // gcd(a, b)\r\ndef binary_search(array, target, start, end):\r\n while start <= end:\r\n mid = (start + end) // 2\r\n if array[mid] == target:\r\n return mid\r\n elif array[mid] > target:\r\n end = mid - 1\r\n else:\r\n start = mid + 1\r\n return -1\r\ndef upper_bound(array,target):\r\n\tl=0\r\n\tr=len(array)-1\r\n\twhile l<=r:\r\n\t\tmid = (l+r)>>1\r\n\t\tif(array[mid] == target):\r\n\t\t\treturn mid\r\n\t\tif(array[mid]>target):\r\n\t\t\tif(mid==0):\r\n\t\t\t\treturn -1\r\n\t\t\telse:\r\n\t\t\t\tif(array[mid-1]<target):\r\n\t\t\t\t\treturn mid-1\r\n\t\t\t\telse:\r\n\t\t\t\t\tr=mid-1\r\n\t\telse:\r\n\t\t\tif(mid==len(array)-1):\r\n\t\t\t\treturn mid\r\n\t\t\telse:\r\n\t\t\t\tif(array[mid+1]>target):\r\n\t\t\t\t\treturn mid\r\n\t\t\t\telse:\r\n\t\t\t\t\tl=mid+1\r\ndef lower_bound(array,target):\r\n\tl=0\r\n\tr=len(array)-1\r\n\twhile l<=r:\r\n\t\tmid = (l+r)>>1\r\n\t\tif(array[mid] == target):\r\n\t\t\treturn mid\r\n\t\tif(array[mid]>target):\r\n\t\t\tif(mid==0):\r\n\t\t\t\treturn mid\r\n\t\t\telse:\r\n\t\t\t\tif(array[mid-1]<target):\r\n\t\t\t\t\treturn mid\r\n\t\t\t\telse:\r\n\t\t\t\t\tr=mid-1\r\n\t\telse:\r\n\t\t\tif(mid==len(array)-1):\r\n\t\t\t\treturn -1\r\n\t\t\telse:\r\n\t\t\t\tif(array[mid+1]>target):\r\n\t\t\t\t\treturn mid+1\r\n\t\t\t\telse:\r\n\t\t\t\t\tl=mid+1\r\ndef isPrime(n):\r\n\tif (n % 2 == 0 and n != 2) or n < 2:\r\n\t return False\r\n\ti = 3\r\n\twhile i * i <= n:\r\n\t if n % i == 0:\r\n\t return False\r\n\t i += 2\r\n\treturn True\r\n\r\ndef solve():\r\n\tn,m=mp()\r\n\tif(m==1):\r\n\t\tpr(n-1)\r\n\t\treturn\r\n\tif(n==1):\r\n\t\tpr(m-1)\r\n\t\treturn\r\n\tpr((m-1)*(m-1))\r\n\t\r\nfor _ in range(1):\r\n\tsolve()"}, {"source_code": "n,k = map(int,input().split())\r\na = 0\r\n# if(k-1==0):\r\n# \tprint(k)\r\n# else:\r\nif(n>k):\r\n\ta= ((n-1)*1)\r\nelse:\r\n\tif(k>n):\r\n\t\ta= ((k-1)*n)\r\nif(n==k):\r\n\ta= ((k-1)*n)\r\nprint(a)\r\n\r\n\r\n\t\r\n\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,m=map(int,input().split())\r\nif n<m:\r\n\tprint(n**(m//2))\r\nelif n>m:\r\n\tprint(n-m)\t\r\nelse:\r\n\tif n==1 and m==1:\r\n\t\tprint(n-m)\r\n\telse:\r\n\t\tprint(n) "}, {"source_code": "n,m = map(int,input().split())\r\nif n == 2 and m == 1:\r\n print(1)\r\nelse:\r\n print(n * (m - 1))"}, {"source_code": "n,m=map(int,input().split())\r\na=n*m\r\nb=min(n,m)\r\nprint(a-b)"}, {"source_code": "class Solution:\r\n def solve(line_in: str):\r\n n = int(line_in.split()[0])\r\n m = int(line_in.split()[1])\r\n\r\n if n <= m:\r\n return n * (m - 1)\r\n else:\r\n return (n - 1) * m\r\n \r\n\r\n def accumulationDominoes():\r\n line_in = input()\r\n print(Solution.solve(line_in))\r\n \r\n\r\nSolution.accumulationDominoes()"}, {"source_code": "import collections\nimport heapq\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom io import BytesIO, IOBase\nimport os\n######################################################################################\n#--------------------------------------func-----------------------------------------#\n######################################################################################\n\n\ndef valid(i, j, n, m):\n if i < n and i >= 0 and j >= 0 and j < m:\n return True # and l[i][j]==1 and visit[i][j]\n return False\n\n\ndef sumn(i, n):\n return (n-i)*(i+n)/2\n\n\ndef sqfun(a, b, c):\n return (-b+math.sqrt(b*b-4*a*c))/2*a\n\n\ndef getprime(num):\n if all(num % i != 0 for i in range(2, int(math.sqrt(num))+1)):\n return True\n\n######################################################################################\n#--------------------------------------vars-----------------------------------------#\n######################################################################################\n# index=[[1,0],[0,1],[-1,0],[0,-1]]\n# primes=[2,3,5,7,11,13,17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,\n# 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,\n# 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383,\n# 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541,\n# 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683,\n# 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857,\n# 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]\n######################################################################################\n#--------------------------------------Input-----------------------------------------#\n######################################################################################\n\n\ndef value(): return tuple(map(int, input().split()))\ndef values(): return tuple(map(int, sys.stdin.readline().split()))\ndef inlst(): return [int(i) for i in input().split()]\ndef inlsts(): return [int(i) for i in sys.stdin.readline().split()]\ndef inp(): return int(input())\ndef inps(): return int(sys.stdin.readline())\ndef instr(): return input()\ndef stlst(): return [i for i in input().split()]\n\n\n######################################################################################\n#--------------------------------------code here-------------------------------------#\n######################################################################################\n\ndef solve():\n a, b = values()\n print(min(a, b)*(max(a, b)-1))\n\n\nif __name__ == \"__main__\":\n # for i in range(inp()):\n solve()\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,m=map(int,input().split())\r\nif n<m:\r\n\tprint(n*(m-1))\r\nelif n>m:\r\n\tprint(n-m)\t\r\nelse:\r\n\tif n==1 and m==1:\r\n\t\tprint(0)\r\n\telse:\r\n\t\tprint(n) "}, {"source_code": "n,m=map(int,input().split())\r\nr=min(n,m)\r\nprint((n*m)-r)\r\n"}, {"source_code": "t=1\r\nwhile t:\r\n n,m=map(int,input().strip().split())\r\n nn=max(n,m)\r\n mm=min(n,m)\r\n ans=max((nn-1)*mm,-1)\r\n print(ans)\r\n t-=1\r\n "}, {"source_code": "N,M=input().split()\r\nif M!=1:\r\n print((int(M)-1)*(int(N)))\r\nelse:\r\n print(int(N)-1)"}, {"source_code": "n,m = input().split(' ')\r\nn=int(n)\r\nm=int(m)\r\nlines=[]\r\n\r\nc=(m-1)*n\r\n\r\nif m%2:\r\n c+=(n-1)*m\r\n\r\n\r\nprint(c)"}, {"source_code": "n, m=[int(x) for x in input().split()]\nif m==1:\n print(0)\nelse:\n print(n*(m-1))\n"}, {"source_code": "N, M = map(int, input().split())\r\nprint((M - 1) * N)\r\n"}, {"source_code": "N, M = map(int, input().split())\r\nprint((M - 1) * N)\r\n"}, {"source_code": "class Solution:\r\n def solve(line_in: str):\r\n n = int(line_in.split()[0])\r\n m = int(line_in.split()[1])\r\n\r\n if n <= m:\r\n return n * (m - 1)\r\n else:\r\n return (n - 1) * m\r\n \r\n\r\n def accumulationDominoes():\r\n line_in = input()\r\n print(Solution.solve(line_in))\r\n \r\n\r\nSolution.accumulationDominoes()"}, {"source_code": "m,n= map(int,input().split())\nx=((n-1)*m)\nprint(x)\n \t\t \t\t \t\t \t\t\t\t\t\t\t \t"}, {"source_code": "a, b = map(int, input().split())\r\nprint(max((a == 1) * (b - 1), (a - 1) * b))"}, {"source_code": "n,k = map(int,input().split())\r\na = 0\r\nif(k-1==0):\r\n\tprint(k)\r\nif(n-1==0):\r\n\tprint(n-1)\r\n\r\na=n*(k-1)\r\nprint(a)"}, {"source_code": "a, b = map(int, input().split())\r\nprint(max((a == 1) * (b - 1), (a - 1) * b))"}, {"source_code": "import sys\nimport math\ntoks = (token for token in sys.stdin.read().split())\n# toks2=sys.stdin.read().split()\n# print(toks2)\n\n\n# N=int(next(toks))\n# M=int(next(toks))\n# X=int(next(toks))\n# T=int(next(toks))\n# D=int(next(toks))\n\n# age=0\n# height=T\n\n# if M<X:\n# height=height-D*(X-M)\n\n# print(height)\n\n\n# arr=[]\n# for i in range(5):\n# n=int(next(toks))\n# if n not in arr:\n# arr.append(n)\n\n# print(len(arr))\n\n# N=int(next(toks))\n# X=int(next(toks))\n\n# sum=0\n# for i in range(N):\n# sum+=int(next(toks))\n\n# sum=abs(sum)\n\n# print(math.ceil(sum/X))\n\nN=int(next(toks))\nM=int(next(toks))\nprint((M-1)*N)\n \t \t \t \t \t\t\t\t\t \t \t"}, {"source_code": "n,m = map(int,input().split())\r\nif n== m==1:\r\n print(0)\r\nelif n ==2 and m == 1:\r\n print(1)\r\nelif n == 1 and m ==2:\r\n print(1)\r\nelse:\r\n print((m-1)*n)"}, {"source_code": "a, b = map(int, input().split())\r\nprint((a - 1) * (b - 1))"}, {"source_code": "r,c=map(int,input().split())\r\nprint(r*(c-1))"}, {"source_code": "n, m = map(int, input().split())\r\nprint((m - 1) * n if m > 1 else n)\r\n"}, {"source_code": "def solution(n, m):\r\n return (m*n - min(m, n))\r\n\r\nn,m = [int(x) for x in input().strip().split(\" \")]\r\nprint(solution(n, m))"}, {"source_code": "N,M=map(int,input().split())\r\nif M==1:\r\n print(N)\r\nif M>1:\r\n d=M-1\r\n print(N*d)"}, {"source_code": "n, m = input().split()\r\nn, m = int(n), int(m)\r\n\r\nans = 0\r\nif m == 1:\r\n ans = n-1\r\nelif n < m:\r\n ans = (m-1)*n\r\nelif n > m:\r\n ans = n*(m-1)\r\n\r\nprint(ans)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n\r\n############ Add your code here #########\r\n\r\n#inputs\r\nn,m = inlt()\r\nprint(n*(m-1))\r\n"}, {"source_code": "import sys,math\r\nn,m=map(int, sys.stdin.readline().split())\r\nif m>1:\r\n print(n*m-n)\r\nelse:print(1)"}, {"source_code": "n, m=[int(x) for x in input().split()]\nprint(n*(m-1))\n"}, {"source_code": "n,m=map(int,input().split())\r\na=n*m\r\nb=min(n,m)\r\nprint(a-b)"}, {"source_code": "N,M=map(int,input().split())\r\nprint((M-1)*N)"}, {"source_code": "n, m = [int(s) for s in input().split()]\n\nprint(max(n, n * (m - 1)))"}, {"source_code": "N,M=map(int,input().split())\r\nif M>1:\r\n print(N*(M//2+M//3))\r\nelse:\r\n print(N//2+N//3)\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,m=map(int,input().split())\r\nif n==1 and m==1:\r\n\tprint(0) \r\nelse:\r\n\tprint(n*(m-1))\t\r\n"}, {"source_code": "a, b = [int(i) for i in input().split()]\r\nprint(a*b -b)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,m=map(int,input().split())\r\nif n<m:\r\n\tprint(n*(m-1))\r\nelif n>m:\r\n\tprint(n-m)\t\r\nelse:\r\n\tif n==1 and m==1:\r\n\t\tprint(0)\r\n\telse:\r\n\t\tprint(n) "}, {"source_code": "n, m=[int(x) for x in input().split()]\nif m==1:\n print(1)\nelse:\n print(n*(m-1))\n"}, {"source_code": "n,m = map(int,input().split())\r\nprint((m-1)*n)"}, {"source_code": "\r\n\r\nrows_and_columns = input('')\r\nspace = rows_and_columns.split()\r\nn = int(space[0])\r\nm = int(space[1])\r\nprint(n, m)\r\n\r\nhow_many_tight_1 = 0\r\n\r\n\r\nif n == 1 or n == 2:\r\n how_many_tight_1 = m\r\n print(how_many_tight_1)\r\nelse:\r\n tight_one_row = n - 1\r\n\r\n how_many_tight_2 = tight_one_row * m + 1\r\n print(how_many_tight_2)\r\n"}, {"source_code": "n,m=[int(num) for num in input().split(\" \")]\r\nprint(max(n*(m-1),m*(n-1)))"}, {"source_code": "N, M = map(int, input().split())\r\n\r\narea = M * N\r\nans = int(area * (M - 1)/(M))\r\n\r\nif (M == 1):\r\n ans = N - 1\r\n\r\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\r\nif m == 1: print(n - 1)\r\nelse: print((n - 1) * m)"}, {"source_code": "n, m = map(int, input().split())\r\n\r\nprint(max(1, n * (m-1)))"}, {"source_code": "\r\n\r\nrows_and_columns = input('Enter 2 numbers: ')\r\nn = int(rows_and_columns[0])\r\nm = int(rows_and_columns[-1])\r\n\r\n\r\ntight_one_row = n - 1\r\n\r\nhow_many_tight = tight_one_row * m\r\nprint(how_many_tight)\r\n"}, {"source_code": "p=input()\r\nn,m=p.split()\r\nprint(int(m)*int(n)-int(n))"}, {"source_code": "print(*map(lambda x: int(x[0])*(int(x[1])-1), [input().split()]))"}, {"source_code": "n,k = map(int,input().split())\r\na = 0\r\n# if(k-1==0):\r\n# \tprint(k)\r\n# else:\r\nif((n>k) and (k==1)):\r\n\ta= ((n-1)*1)\r\nelse:\r\n\tif((n>k) and (k!=1)):\r\n\t\ta=n\r\n\telse:\r\n\t\tif(k>n):\r\n\t\t\ta= ((k-1)*n)\r\nif(n==k):\r\n\ta= ((k-1)*n)\r\nprint(a)\r\n\r\n\r\n\t\r\n\r\n"}, {"source_code": "n,m=map(int,input().split())\r\nprint((n*m)-n)\r\n"}, {"source_code": "n,m = map(int,input().split())\r\nif n == 2 and m == 1:\r\n print(1)\r\nelse:\r\n print(n * (m - 1))"}, {"source_code": "n,m=[int(num) for num in input().split(\" \")]\r\nif m-1==0:\r\n print(m*(n-1))\r\nelse:\r\n print(max(n*(m-1),m*(n-1)))"}], "src_uid": "a91aab4c0618d036c81022232814ef44"} {"source_code": "# May the Speedforce be with us...\n'''\nfor _ in range(int(input())):\narr=list(map(int,input().split()))\nn,k=map(int,input().split())\nn=int(input())\ns=input()\n\nfrom collections import defaultdict\nd=defaultdict()\n\nd=dict()\ns=set()\ns.intersection()\ns.union()\ns.difference()\n\n\nproblem statement achhe se padhna hai\nage se bhi dekhna hai, piche se bhi dekhna hai\n'''\nfrom math import gcd,ceil\nfrom collections import defaultdict as dd\ndef lcm(a,b):\n\treturn (a*b)//gcd(a,b)\ndef inin():\n\treturn int(input())\ndef inar():\n\treturn list(map(int,input().split()))\ndef ar(element,size):\n\treturn [element for i in range(size)]\ndef digitsum(num):\n\tsu=0\n\twhile(num):\n\t\tsu+=num%10\n\t\tnum//=10\n\treturn su\n\nn=inin()\nstring=list(input())\narr=[]\nss=set()\nfor i in string:\n\tif i.isupper():\n\t\tarr.append(ss)\n\t\tss=set()\n\telse:\n\t\tss.add(i)\narr.append(ss)\nans=0\nfor i in arr:\n\tans=max(ans,len(i))\nprint(ans)", "positive_code": [{"source_code": "N=int(input())\nS=input()\nj=0\nD=[]\nC=[]\nfor i in range(0,N):\n if(ord(S[i])>=ord('a') and ord(S[i])<=ord('z')):\n if(j==0):\n D=[]\n j=1\n if S[i] not in D:\n D.append(S[i])\n if(j==1):\n if S[i] not in D:\n D.append(S[i])\n elif(j==1):\n C.append(D[:])\n j=0\nC.append(D[:])\nif(len(C)!=0):\n D1=C[:]\n D1=list(map(len,D1))\n D2=D1.index(max(D1))\n print(D1[D2])\nelse:\n print(len(D))"}, {"source_code": "n = int(input().strip())\n\ns = input().strip()\n\nmax_set = 0\n\nfor x in range(n):\n for y in range(x,n+1):\n char_dict = {}\n if all(c.islower() for c in s[x:y]):\n for z in s[x:y]:\n if z in char_dict:\n char_dict[z] += 1\n else:\n char_dict[z] = 1\n \n if max_set < len(char_dict):\n max_set = len(char_dict)\nprint(max_set)"}, {"source_code": "n = int(input())\nt = input()\nd = set({})\ntemp = []\ncount = 0\nz = float(\"-inf\")\nfor i in t: \n\tif ord(i) >= 97 and ord(i) <= 122:\n\t\td.add(i)\n\telif ord(i) >= 65 and ord(i) <= 90:\n\t\tz = max(z,len(d))\n\t\td = set({})\nz = max(z,len(d))\nprint(z)"}, {"source_code": "ans = 0\ncombo = set()\npre = -1\ninput()\nfor c in input():\n if c.isupper():\n ans = max(ans, len(combo))\n combo = set()\n pre = -1\n elif c != pre:\n combo.add(c)\n pre = c\nprint(max(ans, len(combo)))\n \n"}, {"source_code": "input()\nstring = input()\n\nprettySet = set()\ncount=0\nfor c in string:\n if c.islower():\n prettySet.add(c)\n count=max(count,len(prettySet))\n else:\n prettySet.clear()\n\nprint(count)\n"}, {"source_code": "BIG_LETTERS = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','W','V','X','Y','Z')\nSMALL_LETTERS = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','v','x','y','z')\nn = int(input())\ns = input()\nmax = 0\nif s.isupper() == True:\n print(0)\nelif s.islower() == True:\n st = ''\n for i in range(n):\n if s[i] not in st:\n st +=s[i]\n print(len(st))\nelse:\n st = ''\n for i in range(n):\n if s[i] in SMALL_LETTERS and s[i] not in st:\n st += s[i]\n elif s[i] in BIG_LETTERS:\n if len(st) > max:\n max = len(st)\n st = ''\n if len(st)>max:\n max = len(st)\n print(max)"}, {"source_code": "n = int(input())\ns = input()\n\nl = []\ni = 0\nwhile i < n:\n while i < n and s[i].isupper():\n i += 1\n t = set()\n while i < n and s[i].islower():\n t.add(s[i])\n i += 1\n l.append(t)\n\nm = 0\nfor i in l:\n if len(i) > m:\n m = len(i)\n\nprint(m)"}, {"source_code": "from sys import stdin,stderr,maxsize\nmod = int(1e9)+7\ndef I(): return int(stdin.readline())\ndef lint(): return [int(x) for x in stdin.readline().split()]\ndef S(): return input().strip()\ndef grid(r, c): return [lint() for i in range(r)]\ndef debug(*args, c=6): print('\\033[3{}m'.format(c), *args, '\\033[0m', file=stderr)\nfrom collections import Counter,defaultdict\nfrom itertools import permutations\nimport re\ndef bark():\n n = I(); s =S()\n a = re.split('[A-Z]+',s)\n p = max(map(lambda x: len(set(x)),a))\n return p\nif __name__ == '__main__':\n print(bark())\n\n"}, {"source_code": "def isLowerCase(s):\n if s>='a' and s<='z':\n return True\n else:\n return False\n\nn=int(input())\ns=input().strip()\nst=set()\nflag=0\nmaxx=0\ncount=0\nfor i in range(n):\n if flag==0:\n if isLowerCase(s[i]):\n if s[i] not in st:\n count+=1\n st.add(s[i])\n else:\n flag=1 \n if maxx<count:\n maxx=count\n else:\n if isLowerCase(s[i]):\n flag=0\n st=set([s[i]])\n count=1\nif maxx<count:\n maxx=count\nprint(maxx)\n"}, {"source_code": "n=int(input())\nb=input()\na,c,d,e=[],[],[],[]\nnom=0\nmaxx=0\nbb=0\nfor i in range(n):\n a.append(b[i])\n if a[i].islower()==True:\n c.append('m')\n else:\n c.append('b')\n#print(c)\nfor i in range(n):\n if c[i]=='b':\n d.append(i)\nif 0 not in d:\n d.insert(0,0)\nif c[n-1]!='b':\n d.append(n)\n#print(d)\n#print(c)\nif 'm' not in c:\n print(0)\nelse:\n for i in range(len(d)-1):\n e.append([])\n for j in range(d[i],d[i+1]):\n if c[j]=='b':\n j+=1\n if b[j] not in e[nom]:\n e[nom].append(b[j])\n #print(e)\n nom+=1\n for i in range(len(e)):\n if len(e[i])>maxx:\n maxx=len(e[i])\n print(maxx)"}, {"source_code": "n=int(input())\ns=input()\nsm=[-1]\ncount=[]\nc=0\nfor i in s:\n \n if ord(i)<123 and ord(i)>96:\n #print(sm[::-1],sm[::-1].index(-1))\n if i not in sm[len(sm)-sm[::-1].index(-1):]:\n c+=1\n sm.append(i)\n count.append(c)\n \n \n else:\n sm.append(-1)\n if sm[-1]==-1:\n c=0\nif len(count)>0:\n print(max(count))\nelse:\n print(0)\n \n \n "}, {"source_code": "n = input()\ns = str(input())\na = set()\nres = 0\nfor i in s:\n if i.islower():\n a.add(i)\n res = max(res,len(a))\n else:\n a.clear()\nprint(res)"}, {"source_code": "n = int(input())\ns = input()\ns = s[:n+1]\nli = []\nans = 0\nfor i in s:\n if i.islower():\n if i not in li:\n li.append(i)\n ans = max(ans, len(li))\n else:\n li.clear()\nprint(ans)"}, {"source_code": "def strp(string):\n sets = []\n s = set()\n for c in string:\n if c.isupper():\n if len(s):\n sets.append(s)\n s = set()\n else:\n s.add(c)\n if len(s):\n sets.append(s)\n \n return len(sets) and max(map(len,sets))\n\n\ninput()\nstring = input()\nprint(strp(string))"}, {"source_code": "def ideal(s):\n if all(x.islower() for x in s):\n return len(set(s))\n t = s + \"A\"\n a = \" \"\n count1 = 0\n for i in range(len(t)):\n if t[i].islower():\n a += t[i]\n else:\n count2 = 0\n b = sorted(a)\n for j in range(1, len(b)):\n if j + 1 < len(b) and b[j + 1] == b[j]:\n count2 += 1\n if len(b) - count2 > count1:\n count1 = len(b) - count2\n a = \" \"\n return count1 - 1\n\n\nn = int(input())\nprint(ideal(input()))\n"}, {"source_code": "n = int(input())\ns = str(input())\nlis_cap = []\nfor i in range(len(s)):\n if (s[i]).isupper():\n lis_cap.append(i)\nif not lis_cap or lis_cap[-1] != n-1:\n lis_cap.append(n)\nlis_ans = []\nstart = 0\nfor i in lis_cap:\n end = i\n se = set([])\n for j in range(start,end):\n se.add(s[j])\n start = end+1\n lis_ans.append(len(se))\nprint (max(lis_ans))\n"}, {"source_code": "n = input()\ns = raw_input().strip()\nl = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nk = \"\"\np = []\nfor i in s :\n\tif i not in l :\n\t\t#print i\n\t\tif i not in k :\n\t\t\tk += i \n\telse :\n\t\tp.append(len(k)*(-1))\n\t\tk = \"\"\np.append(len(k)*(-1))\np.sort()\nprint p[0]*(-1)\n\n\n"}, {"source_code": "n = int(input())\na = input()\nMAX = 0\nend = 0\nfor i in range(n):\n start = end\n end = start+1\n while a[start:end].islower():\n if MAX < len(set(a[start:end])):\n MAX = len(set(a[start:end]))\n end+=1\n if end > n:\n break\nprint(MAX)"}, {"source_code": "import os\nimport sys\nimport re\n\nif 'PYCHARM' in os.environ:\n sys.stdin = open('in', 'r')\n\n\ndef c(word):\n chs = set()\n for c in word:\n chs.add(c)\n return len(chs)\n\n\ninput()\nprint(max(map(c, re.split('[A-Z]', input()))))\n"}, {"source_code": "n=int(input())\nd=input()\nsetim=set()\nfor i in range(0,len(d)):\n f=True\n nset=set()\n for j in range(i,len(d)):\n if d[j].isupper():\n break\n nset.add(d[j])\n if len(nset)>len(setim):\n setim=nset\nprint(len(setim))\n "}, {"source_code": "n=input()\na=raw_input()\ns=set()\nres=0\n\nfor b in a:\n if b.isupper():\n res=max(len(s),res)\n s.clear()\n else:\n s.add(b)\nres=max(len(s),res)\nprint res\n\n\n\n\n\n\n\n"}, {"source_code": "n=int(raw_input())\ns= raw_input()\n\ndef prt(s):\n n=len(s)\n st=[]\n lt=0\n maxlt=0\n lc='qwertyuiopasdfghjklzxcvbnm'\n for x in s:\n if x in lc and x not in st:\n st.append(x)\n lt+=1\n maxlt=max(maxlt,lt)\n elif x not in lc:\n st=[]\n lt=0\n return maxlt\n\nprint prt(s)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = input()\ns = raw_input()\nans = 0\nt = []\nsmall = \"abcdefghijklmnopqrstuvwxyz\"\ncapital = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nfor i in range(n):\n\tif s[i] in small:\n\t\tif s[i] not in t:\n\t\t\tt.append(s[i])\n\t\t\tif len(t) > ans:\n\t\t\t\tans = len(t)\n\telse:\n\t\tt = []\n\nprint ans"}, {"source_code": "from collections import Counter\n\nn = int(raw_input())\ns = raw_input().strip()\n\nmax_set_size = 0\nc = Counter()\n\nfor letter in s:\n if letter.isupper():\n max_set_size = max(max_set_size, len(c))\n c = Counter()\n else:\n c[letter] += 1\n\nmax_set_size = max(max_set_size, len(c))\nprint max_set_size"}, {"source_code": "n = input() + 1\narr = raw_input()+'A'\nf = 0 \nlw = 0\ncnt = 0\nfor x in xrange(n):\n\tif f == 0 and arr[x].islower():\n\t\t#print arr[x],x\n\t\t#cnt += 1\n\t\tf = 1\n\t\tlw = x\n\tif f == 1 and arr[x].isupper():\n\t\tf = 0\n\t\ttp = len(list(set(arr[lw:x])))\n\t\t\n\t\tif tp > cnt:\n\t\t\tcnt = tp\nprint cnt"}, {"source_code": "def main():\n t=input()\n n=raw_input()\n n+=\"@\"\n #print n\n if len(n)==2:\n if ord(n[0])<95:\n print 0\n else:\n print 1\n else:\n r=[]\n for i in xrange(t):\n if n[i]!=n[i+1]:\n r.append(n[i])\n if n[t-1]!=n[t]:\n r.append(n[t])\n k=[]\n p=[]\n #print r\n for i in r:\n #if i==r[len(r)-1] and ord(i)>95:\n #r.append(\"A\")\n #print r\n if ord(i)>95:\n k.append(i)\n else:\n p.append(len(set(k)))\n k=[]\n print max(p) \nif __name__ == '__main__':\n main()"}, {"source_code": "n = int(input())\ns = input()\nres = 0\nSet = set()\nfor i in range(n):\n if 'A'<=s[i]<='Z':\n res=max(res,len(Set))\n Set.clear()\n else:\n Set.add(s[i])\nprint(max(res,len(Set)))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Dec 18 19:44:17 2017\n\n@author: aeshak\n\"\"\"\nimport string\nn = input()\ns = raw_input()\nuppers = set(string.ascii_uppercase)\nupperLoc = []\nfor i in xrange(n):\n\tif s[i] in uppers:\n\t\tupperLoc.append(i)\nmaxNo = 0\nm = len(upperLoc)\npieces = [] \nstart = 0\nif upperLoc:\n\tfor i in xrange(n):\n\t\tif i in upperLoc:\n\t\t\tif start != i:\n\t\t\t\tpieces.append(s[start:i])\n\t\t\tstart = i+1\n\tpieces.append(s[start:])\n\tmaxNo = 0\n\tfor piece in pieces:\n\t\tmaxNo = max(maxNo, len(set(piece)))\nelse:\n\tmaxNo = len(set(s))\nprint maxNo\n"}, {"source_code": "n=input()\na=raw_input()\nb=[]\nx=\"\"\nfor i in range(n):\n #print a[i],a[i].isupper()\n if a[i].isupper():\n b.append(x)\n x=\"\"\n else:\n x+=a[i]\nb.append(x)\ny=-1\nfor i in b:\n y=max(len(set(i)),y)\nprint y\n"}, {"source_code": "from sys import stdin\nupper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\ns = set()\nans = 0\nn = int(stdin.readline())\na = stdin.readline().strip()\nfor i in a:\n if i in upper:\n ans = max(ans,len(s))\n s = set()\n else:\n s.add(i)\nans = max(ans,len(s))\nprint ans"}, {"source_code": "n=int(input())\ns=list(input())\nb=[]\n#print(s)\nd=[]\nj=0\nfor i in range(n):\n d.append([])\n if (ord(s[i]) in range(ord('a'),ord('z')+1)) and not(s[i] in d[j]): \n d[j].append(s[i])\n elif (ord(s[i]) in range(ord('A'),ord('Z')+1)):\n j+=1\n d.append([])\nfor i in d:\n b.append(len(i))\nprint(max(b))\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nupper = [-1]\nfor i, ss in enumerate(s):\n if ord('A') <= ord(ss) <= ord('Z'):\n upper.append(i)\nupper.append(len(s))\nintervals = zip(upper[:-1], upper[1:])\nprint max(len(set(s[q+1: w])) for q, w in intervals)\n"}, {"source_code": "num = [int(x) for x in raw_input('').split(' ')][0]\nword = raw_input('')\nn = len(word)\n\nmax_size = 0\nstart = 0\nwhile start < n:\n while start < n and word[start].lower() != word[start]:\n start += 1\n end = start\n distinct_chars = set([])\n while end < n and word[end].lower() == word[end]:\n if word[end] not in distinct_chars:\n distinct_chars.add(word[end])\n end += 1\n max_size = max(max_size, len(distinct_chars))\n start = end\n\nprint max_size\n"}, {"source_code": "import re\ninput()\nprint max(map(len,map(set,re.split('[A-Z]',raw_input()))))"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\nlowercase = 'abcdefghijklmnopqrstuvwxyz'\n\ncur = set()\nans = 0\nfor c in s:\n if c in lowercase:\n cur.add(c)\n ans = max(ans, len(cur))\n else:\n cur = set()\n\nprint ans\n"}, {"source_code": "n = input()\na = raw_input()\nb1 = set()\nb2 = 0\nfor i in xrange(n):\n\tif ord(a[i])<91:\n\t\tb2 = max(b2,len(b1))\n\t\tb1 = set()\n\telse:\n\t\tb1.add(a[i])\nprint max(b2,len(b1))\n\n"}, {"source_code": "from collections import Counter\n\nN = input()\nS = raw_input()\nst = set()\nans = 0\n\nfor s in S:\n if s.isupper():\n ans = max(ans, len(st))\n st = set()\n else:\n st.add(s)\n\nans = max(ans, len(st))\nprint ans\n \n"}, {"source_code": "n=int(input())\ns=list(input())\nta=[]\nka=[]\nx=0\nfor item in s:\n if item.islower():\n ta.append(item)\n else:\n ka.append(len(set(ta)))\n ta=[]\nka.append(len(set(ta)))\nprint(max(ka))"}, {"source_code": "raw_input()\nstr = raw_input() + \"A\"\nmaxSize = 0\ns = set()\nfor letter in str:\n if letter.isupper():\n maxSize = max(maxSize, len(s))\n s = set()\n else:\n s.add(letter)\nprint maxSize\n"}, {"source_code": "n = int(raw_input())\na = list(raw_input())\n\nseq = []\n\ncur = a[0]\ntemp = []\nfor i in a:\n\tif(i<='Z' and i>='A'):\n\t\tif(temp!=[]):\n\t\t\tseq.append(temp)\n\t\t\ttemp = []\n\telse:\n\t\ttemp.append(i)\nif(temp!=[]):\n\tseq.append(temp)\n\ttemp = []\n\nans = []\nfor i in seq:\n\tans.append(len(set(i)))\nif(ans==[]):\n\tprint 0\nelse:\n\tprint max(ans)"}, {"source_code": "\nif __name__==\"__main__\":\n n=input()\n s=raw_input()\n mx=-1\n st=set()\n for i in s:\n if i.islower():\n st.add(i)\n else:\n st.clear()\n l=len(st)\n if l>mx:\n mx=l\n print mx"}, {"source_code": "from __future__ import print_function, division\nfrom sys import stdin, stdout\nfrom fractions import gcd\n# from math import *\nfrom collections import *\nfrom operator import mul\nfrom functools import reduce\nfrom copy import copy\n\nrstr = lambda: stdin.readline().strip()\nrstrs = lambda: [str(x) for x in stdin.readline().split()]\nrint = lambda: int(stdin.readline())\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrstr_2d = lambda n: [rstr() for _ in range(n)]\nrint_2d = lambda n: [rint() for _ in range(n)]\nrints_2d = lambda n: [rints() for _ in range(n)]\npr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\\n')\nout = []\n\nn, s, ans = int(input()), rstr(), 0\ndis = set()\n\nfor i in s:\n if i == i.upper():\n dis = set()\n else:\n dis.add(i)\n ans = max(ans, len(dis))\n\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\n\ndef solve(N, S):\n ret = 0\n inUpp = S[0].lower() != S[0]\n temp = set()\n for i in xrange(N):\n if inUpp: # uppercase\n if S[i].lower() == S[i]:\n inUpp = False\n temp.add(S[i])\n else: # lowercase\n if S[i].lower() != S[i]:\n ret = max(ret, len(temp))\n temp = set()\n else:\n temp.add(S[i])\n # print 'temp', temp\n ret = max(ret, len(temp))\n return ret\n\n\n\nN = int(raw_input())\nS = raw_input()\nprint solve(N, S)"}, {"source_code": "\nn = int(input())\n\ns = input()\ns+='A'\n\nt = 0\nmp = {}\nans = 0\nfor i in range(n+1):\n #print(mp)\n if s[i].islower():\n t+=1\n if s[i] not in mp:\n mp[s[i]]=1\n else:\n \n ans = max(ans,len(mp))\n t = 0\n mp = {}\nprint(ans)\n\n"}, {"source_code": "n=input()\ns=raw_input()\nl=[]\nx=\"\"\nfor i in range(n):\n if s[i].isupper():\n l.append(x)\n x=\"\"\n else:\n x+=s[i]\nl.append(x)\nk=0\nfor j in l:\n k=max(k,len(set(j)))\nprint k\n \n \n"}, {"source_code": "\ndef max_sim(s):\n return len(set(s))\n\nraw_input()\n\ns = raw_input()\n\nfor c in xrange(ord('A'), ord('Z') + 1):\n s = s.replace(chr(c), '*')\n\nprint max(max_sim(ss) for ss in s.split('*'))\n"}, {"source_code": "from string import ascii_lowercase\nfrom string import ascii_uppercase\n\nn=int(raw_input())\nstring=map (str, raw_input().strip())\nmaximo=0\nsetActual=set()\n\nfor i, item in enumerate (string):\n\tif item in ascii_lowercase:\n\t\tsetActual.add(item)\n\telse:\n\t\tmaximo=max (maximo, len (setActual))\n\t\tsetActual=set()\n\nprint max (maximo, len (setActual))"}, {"source_code": "n = int(input())\ns = input()\ndef rec(dp,s,i,j,k = set()):\n if(j==len(s) or i == len(s)):\n return 0\n if(dp[i][j] != -1):\n return dp[i][j]\n if(s[j].isupper()):\n dp[i][j] = 0\n return 0\n m1 = -1\n if(s[j] not in k):\n k.add(s[j])\n m1 = 1+rec(dp,s,i,j+1,k)\n k.remove(s[j])\n if(len(k) == 0): dp[i][j] = max(m1,rec(dp,s,i+1,j+1,k))\n else: dp[i][j] = max(m1,rec(dp,s,i,j+1,k))\n return dp[i][j]\ndp = [[-1 for i in range(n)] for i in range(n)]\nans = 0\nfor i in range(len(s)):\n ans = max(ans,rec(dp,s,i,i))\nprint (ans)\n"}, {"source_code": "import re\nn = input()\ns = raw_input()\nprint max(map(lambda x: len(set(x)), re.split(r'[A-Z]', s)))\n"}, {"source_code": "def solve(a, n):\n b = [ord(c) - 96 for c in a]\n maxl = 0\n start = 0\n end = 1\n while True:\n while start < n and b[start] < 0:\n start += 1\n if start >= n:\n return maxl\n end = start + 1\n while end < n and b[end] > 0:\n end += 1\n l = len(set(b[start:end]))\n if l > maxl:\n maxl = l\n start = end\n \n\ndef main():\n n = input()\n a = raw_input()\n print solve(a, n)\n\nmain()\n"}, {"source_code": "n=input()\ns=raw_input()\nl=[]\nc=0\nans=0\nfor i in range(n):\n if s[i]<='z' and s[i]>='a' and s[i] not in l :\n c+=1\n l.append(s[i])\n ans=max(ans,c)\n elif s[i]<='Z' and s[i]>='A':\n l=[]\n c=0\nprint ans\n \n \n"}, {"source_code": "INF = 999999999999999999L\ntry:\n inFile = open(\"B.txt\")\nexcept:\n inFile = None\n\ndef read():\n if inFile:\n return inFile.readline().strip()\n else:\n return raw_input().strip()\n\ndef read_ints():\n return map(int,read().split())\n\nn = int(read())\ns = read()\nans = 0\ni = 0\nwhile i < len(s):\n if s[i].isupper():\n i += 1\n continue \n letters = set([])\n j = i\n while j < len(s) and s[j].islower():\n letters.add(s[j])\n j += 1\n #print i,j,letters\n ans = max(ans,len(letters)) \n i = j\nprint ans"}, {"source_code": "import re\ninput()\nprint(max(map(lambda w: len(set(w)), re.split('[A-Z]', input()))))"}, {"source_code": "N = int(input())\nX, Max = input(), 0\ni = 0\nwhile i < N:\n if X[i].islower():\n MyDict = {}\n while i < N and X[i].islower():\n MyDict[X[i]] = True\n i += 1\n Max = max(Max, len(MyDict))\n i += 1\nprint(Max)\n\n# UB_CodeForces\n# Advice: Falling down is an accident, staying down is a choice\n# Location: Here in Bojnurd\n# Caption: Again being chased by essi\n# CodeNumber: 629\n"}, {"source_code": "n = int(input())\ns = input()\nl_upper = []\nfor i in range(len(s)):\n if s[i].isupper() == True:\n l_upper.append(i)\n\nif len(l_upper) == 0 :\n print(len(set(s)))\nelif len(l_upper) == 1:\n print(max(len(set(s[:l_upper[0]])), len(set(s[l_upper[0]: ])) - 1))\nelse:\n all_len = []\n all_len.append(len(set(s[0: l_upper[0]])))\n for i in range(len(l_upper)- 1):\n all_len.append(len(set(s[l_upper[i]: l_upper[i+1]])) - 1)\n all_len.append(len(set(s[l_upper[-1]: ])) - 1)\n print(max(all_len))\n \n\n"}, {"source_code": "n = int(raw_input())\ns = raw_input().strip()\nans = -1\nt = \"\"\nfor i in range(n):\n x = s[i]\n if x.islower():\n t += x\n continue\n ans = max(ans, len(set(t)))\n t = \"\"\nans = max(ans, len(set(t)))\nprint ans "}, {"source_code": "n = int(input())\ns = input()\nmyset = set()\nans = 0\nfor x in s:\n if x.islower():\n myset.add(x)\n ans = max(ans, len(myset))\n else:\n myset.clear()\nprint(ans)"}, {"source_code": "n=int(input())\na=list(input())\nc=[]\nd=[]\nb=[0]*(n+1)\n\nfor i in range(n):\n if ord('a') <= ord(a[i]) <= ord('z'):\n b[i]=ord(a[i])\n else:\n c.append(i)\ntry:\n for i in range(len(c) + 1):\n if i==0:\n d.append(len(set(b[:c[0]])))\n elif i==len(c):\n d.append(len(set(b[c[-1]:])) - 1)\n else: \n d.append(len(set(b[c[i-1] + 1:c[i]])))\n print(max(d))\nexcept:print(len(set(a)))"}, {"source_code": "n = int(input())\ns = input()\nu = set()\ncnt = 0\nfor i in range(n):\n if s[i].islower():\n u.add(s[i])\n elif s[i].isupper():\n cnt = max(len(u),cnt)\n u = set()\ncnt = max(cnt,len(u))\nprint(cnt)\n"}, {"source_code": "n=int(input())\ns = input()\nsm = set()\nme=0\nl=[]\nfor i in range(n):\n if s[i].islower():\n sm.add(s[i])\n if(me<len(sm)):\n me=len(sm)\n l.append(me)\n\n elif s[i].isupper():\n sm.clear()\n me=0\nif(len(l)>0):\n print(max(l))\nelse:\n print(0)"}, {"source_code": "# cook your dish here\nn=int(input())\nstring=str(input())\nc=0\nmaxi=0\na=[]\ni=0\nwhile i < len(string):\n while(i<len(string) and ord(string[i])>=97 and ord(string[i])<=122):\n a.append(string[i])\n i+=1\n \n if len(list(set(a)))>maxi:\n maxi=len(list(set(a)))\n a=[] \n \n i+=1\nprint(maxi)"}, {"source_code": "lc = \"abcdefghijklmnopqrstuvwxyz\"\nuc = \"ABCDEFGHIJKLMNOPQRSTUVWQYZ\"\nn = int(input())\ns = input()\nst = \"\"\nc = 0\nl = []\nfor i in range (n):\n\tif (s[i] in lc):\n\t\tif s[i] not in st:\n\t\t\tst += s[i]\n\t\t\tc += 1\n\telse:\n\t\tl.append(c)\n\t\tst = \"\"\n\t\tc = 0\nl.append(c)\nprint(max(l))"}, {"source_code": "input()\ns = input().translate(str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ' ' * 26)).split()\nprint(0 if s == [] else max([len(set(t)) for t in s]))\n"}, {"source_code": "if __name__ ==\"__main__\":\t\n\tl = int(input())\n\ts = input()\n\tsk = set()\n\tk = [0]\n\tl = 0\n\tmx = 0\n\tfor i in s:\t\n\t\tif 65<=ord(i)<=90: \n\t\t\tk.append(len(sk))\n\t\t\tsk = set()\n\t\t\tl+=1\n\t\telse:\n\t\t\tsk.add(i)\n\t\tif len(sk)>mx:\n\t\t\tmx = len(sk)\n\tprint(mx)\n"}, {"source_code": "# O(nlogn)\ndef main():\n n = int(input())\n s = input()\n \n low_chars = set()\n max_power = 0\n for c in s:\n if c.isupper():\n max_power = max(max_power, len(low_chars))\n low_chars = set()\n else:\n low_chars.add(c)\n \n if len(low_chars) > 0:\n max_power = max(max_power, len(low_chars))\n \n print(max_power)\n \nmain()\n "}, {"source_code": "l = []\nans = 0\nlow = 'qwertyuiopasdfghjklzxcvbnm'\n\nn = int(input())\ns = input()\nfor c in s:\n if(c not in low):\n ans = max(ans, len(l))\n l.clear()\n elif(c not in l):\n l.append(c)\nans = max(ans, len(l))\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nk = []\nans = 0\nfor i in s:\n ans = max(len(k), ans)\n if i.islower():\n if not i in k:\n k.append(i)\n else:\n k = []\n tmp = 0\nans = max(len(k), ans)\nprint(ans)\n"}, {"source_code": "n = int(input())\ns = input()+\"A\"\nl,r=0,0\nans = 0\nwhile l<n+1:\n\tif s[l].isupper():\n\t\tans = max(len(set(i for i in s[r:l])),ans)\n\t\tl+=1\n\t\tr=l\n\telse:\n\t\tl+=1\n\nprint(ans)"}, {"source_code": "n=int(input())\ns = input()\nsm = set()\nme=0\nl=[]\nfor i in range(n):\n if s[i].islower():\n sm.add(s[i])\n if(me<len(sm)):\n me=len(sm)\n l.append(me)\n\n elif s[i].isupper():\n sm.clear()\n me=0\nif(len(l)>0):\n print(max(l))\nelse:\n print(0)"}, {"source_code": "import re\n\nn = int(input())\ncute = input()\ntemp = str()\n\nposl = [a for a in re.split(r'([A-Z][a-z]*)', cute)]\n\nmaxlen = 0\nfor i in range(len(posl)):\n posl[i] = ''.join([x[0] for x in zip(posl[i], posl[i].upper()) if x[0] != x[1]])\n posl[i] = ''.join(set(posl[i]))\n if len(posl[i]) > maxlen:\n maxlen = len(posl[i])\n\nprint(maxlen)\n\n"}, {"source_code": "s = input()\ns = input()\n\ndef isupper(c):\n\treturn 'A' <= c and c <='Z'\n\ndef islower(c):\n\treturn 'a' <= c and c <='z'\n\ndef h(c):\n\treturn ord(c) - ord('a')\n\nanswer = 0\nwaiting_lower = True\n\nfor i in range(len(s)):\n\tif islower(s[i]):\n\t\tif waiting_lower:\n\t\t\tcount = 1\n\t\t\twaiting_lower = False\n\t\t\tappear = [True if _ == h(s[i]) else False for _ in range(26)]\n\t\telse:\n\t\t\tif not appear[h(s[i])]:\n\t\t\t\tcount += 1\n\t\t\t\tappear[h(s[i])] = True\n\n\t\tanswer = max(count,answer)\n\telse:\n\t\twaiting_lower = True\n\nprint(answer)\n\n"}, {"source_code": "n=int(input())\ns=input()\nsub=[]\nans=0\nfor a in range(0,n):\n letter=s[a]\n #print(\"letter\",letter)\n if (letter not in sub) and letter.islower()==True:\n sub.append(letter)\n #print(sub)\n if letter.islower()==False or a==n-1:\n #print(sub)\n ans=max(ans,len(sub))\n sub=[]\n continue\n \nprint(ans)\n"}, {"source_code": "'''\n\thttp://codeforces.com/problemset/problem/864/B\n'''\n\nvalue = int(input())\nstring = input()\n\ndef count(result): \n\tprint(len(result) and max(map(len, result)))\n\ndef itter(string):\n\tresult = []\n\tsmall = set()\n\tfor s in string:\n\t\tif s.islower():\n\t\t\tsmall.add(s)\n\t\telse:\n\t\t\tif len(small):\n\t\t\t\tresult.append(small)\n\t\t\tsmall = set()\n\tif len(small):\n\t\tresult.append(small)\n\tcount(result)\n\nitter(string)"}, {"source_code": "length = int(input(\"\"))\nstring = input(\"\")\n\nsetOfChars = set()\nmax = 0;\n\nfor c in string:\n if c == c.lower():\n setOfChars.add(c)\n if (len(setOfChars) > max):\n #print(\"Max {} is smaller than length {}\".format(max, len(setOfChars)))\n max = len(setOfChars)\n else:\n setOfChars = set()\n\nprint(max)\n"}, {"source_code": "#http://codeforces.com/problemset/problem/864/B\n#solved\n\nn = int(input())\narray = input()\nused = []\nlongest = 0\n\n\nfor i in array:\n if i.isupper():\n if len(used) > longest:\n longest = len(used)\n \n used = []\n\n else:\n if i not in used:\n used.append(i)\n\nif len(used) > longest:\n longest = len(used)\n\nprint(longest)"}, {"source_code": "n = int(input())\nline = input()\n\ns = set()\nl = -1\nindex = 0\n\nwhile index < len(line):\n\tif line[index].lower() == line[index]:\n\t\ts.add(line[index])\n\telse:\n\t\tl = max(l, len(s))\n\t\ts.clear()\n\tindex += 1\n\nprint(max(l, len(s)))"}, {"source_code": "n = int(input())\ns = input()\nbest = 0\na = set()\nfor i in range(n):\n\tif s[i].islower():\n\t\ta.add(s[i])\n\tif s[i].isupper() or i==n-1:\n\t\tbest = max(best , len(a))\n\t\ta = set()\nprint(best)"}, {"source_code": "n = int(input())\ns = input()+\"A\"\nl,r=0,0\nans = 0\nwhile l<n+1:\n\tif s[l].isupper():\n\t\tans = max(len(set(i for i in s[r:l])),ans)\n\t\tl+=1\n\t\tr=l\n\telse:\n\t\tl+=1\n \nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nl =[]\nmaxi = 0\nfor i in range(n):\n if s[i].isupper():\n maxi = max(maxi,len(set(l)))\n l=[]\n else:\n l.append(s[i])\nmaxi = max(maxi,len(set(l)))\nprint(maxi)"}, {"source_code": "def solve():\n\n n = int(input())\n sentence = input()\n\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n alp = [[]]\n \n for st in sentence:\n if st in alpha:\n if st not in alp[-1]:\n alp[-1].append(st)\n else:\n alp.append([])\n\n #print(alp)\n return max([len(e) for e in alp])\n\nprint(solve())\n"}, {"source_code": "n=int(input())\ns=input()\np=set()\nl=0\nfor i in range(n):\n if s[i].isupper():\n if len(p)>l:\n l=len(p)\n p=set()\n else:\n p.add(s[i])\nif len(p)>l:\n l=len(p)\nprint(l)\n \n"}, {"source_code": "n=int(input())\ns=input()\na=set()\nm=0\nfor i in s:\n if i.islower():\n a.add(i)\n m=max(m,len(a))\n else:\n a.clear()\nprint(m)"}, {"source_code": "import re\n\nn=int(input())\nans=0\nfor w in re.split('[A-Z]',input()):\n if len(w)<1:\n continue\n ans=max(ans,len(set([c for c in w])))\nprint(ans)\n\n"}, {"source_code": "import re,sys\n\nl = int(input())\ns = input()\n\nif s.isupper():\n print(0)\n sys.exit()\n\n#get consecutive lowercase substrings\nss = re.sub( r\"([A-Z])\", r\" \", s).split()\nprint(max(len(i) for i in [set(i) for i in ss]))\n\n"}], "negative_code": [{"source_code": "import sys\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\n# sys.setrecursionlimit(1000000)\ndef Ints(): return map(int, sys.stdin.readline().strip().split())\ndef Strs(): return map(str, sys.stdin.readline().strip().split())\ndef Array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef Str(): return sys.stdin.readline().strip()\ndef Int(): return int(sys.stdin.readline().strip())\ndef MOD(): return 1000000007\n\ndef power(base, power):\n MOD = 1000000007\n result = 1\n while power > 0:\n if power % 2 == 1:\n result = (result * base) % MOD\n power = power // 2\n base = (base * base) % MOD\n return result\n\nif __name__ == \"__main__\":\n n = int(input())\n S = Str()\n temp = set()\n res = 0\n for i in range(n):\n if 97 >= ord(S[i]) <= 122:\n temp.add(S[i])\n else:\n res = max(res,len(temp))\n temp = set()\n print(res)\n"}, {"source_code": "n = int(input())\nsymbols = input()\n\nm = 0\nfor i in range(len(symbols)):\n\tfor j in range(i, len(symbols)+1):\n\t\t#print(symbols[i:j])\n\t\tif symbols[i:j].islower():\n\t\t\t#print(symbols[i:j], list(set(symbols[i:j])), list(symbols[i:j]))\n\t\t\tif list(set(symbols[i:j]))==list(symbols[i:j]):\n\t\t\t\tm = max(j-i+1, m)\nprint(m)\n"}, {"source_code": "l = []\nlow = 'qwertyuiopasdfghjklzxcvbnm'\nn = int(input())\ns = input()\n\nfor c in s:\n if(c in low and c not in l):\n l.append(c)\nprint(len(l))"}, {"source_code": "n=int(input())\ns=str(input())\nl=[0]\nfor i in range(len(s)):\n if ord(s[i])>=65 and ord(s[i])<=90:\n l.append(i)\nans=0\nl.append(n-1)\nfor i in range(len(l)-1):\n ls=[]\n for j in range(l[i],l[i+1]):\n if s[j] not in ls and (ord(s[j])>=97 and ord(s[j])<=122):\n ls.append(s[j])\n ans=max(ans,len(ls))\n #print(ls)\nprint(ans)\n\n"}, {"source_code": "num = int(input())\nstring = input()\nlst = []\nn = 0\nw = '\u044d'\nd = {}\n\nfor i in string:\n if i == i.lower() and i not in w:\n n += 1\n w += i\n elif i == i.lower() and i in w:\n continue\n else:\n d[w] = n\n n = 0\n w = '\u044d'\na = 0\nfor i in d.values():\n if i > a:\n a = i\n else:\n continue\nprint(a)"}, {"source_code": "length = int(input(\"\"))\nstring = input(\"\")\n\nsetOfChars = set()\nmax = 0;\n\nfor c in string:\n if c == c.lower():\n setOfChars.add(c)\n else:\n if (len(setOfChars) > max):\n max = len(setOfChars)\n\nprint(len(setOfChars))\n"}, {"source_code": "n = int(input())\nt = input()\nd = set({})\ntemp = []\nfor i in t: \n\t# temp = []\n\tif ord(i) >= 65 and ord(i) <= 90:\n\t\ttemp = []\n\tif ord(i) >= 97 and ord(i) <= 122:\n\t\tif i in temp:\n\t\t\tcontinue\n\t\telif len(temp):\n\t\t\td.add(temp.pop())\n\t\t\td.add(i)\n\t\telse:\n\t\t\ttemp.append(i)\nprint(len(d))\n\n"}, {"source_code": "n = int(input())\ns = str(input())\nans = 0\ntemp=''\ni = 0\nwhile i<len(s):\n if ord(s[i])<97:\n i = i +1\n else:\n while i<len(s) and ord(s[i])>=97:\n temp = temp+ s[i]\n i = i + 1\n t = set(temp)\n ans = max(len(t), ans)\nprint(ans)\n"}, {"source_code": "import string\nn=input()\ns=raw_input()\nmaxi=-1\nans=[]\nfor i in range(n):\n t=s[i]\n if t in string.lowercase:\n if t not in ans:\n ans.append(s[i])\n else:\n maxi=max(maxi,len(ans))\n ans=[] \nprint maxi"}, {"source_code": "#864B\nn = int(input())\ns = input()\nif len(s) == 1:\n print(1)\nelse:\n parts = []\n i = 0\n string = \"\"\n while i < len(s):\n if s[i].islower():\n string += s[i]\n else:\n parts.append(string)\n string = \"\"\n i += 1\n parts.append(string)\n m = 0\n for j in parts:\n j = set(j)\n m = max(len(j),m)\n print(m)\n"}, {"source_code": "n = int(input())\ns = input()\nl_upper = []\nfor i in range(len(s)):\n if s[i].isupper() == True:\n l_upper.append(i)\n \nif len(l_upper) == 0 :\n print(len(set(s)))\nelif len(l_upper) == 1:\n print(max(len(set(s[:l_upper[0]])), len(set(s[l_upper[0]: ])) - 1))\nelse:\n all_len = []\n all_len.append(len(set(s[0: l_upper[0]])))\n for i in range(len(l_upper)- 1):\n all_len.append(len(set(s[l_upper[i]: l_upper[i+1]])) - 1)\n all_len.append(len(set(s[l_upper[-1]: ])))\n print(max(all_len))\n "}, {"source_code": "\nn = int(input())\n\ns = input()\ns+='A'\n\nt = 0\nmp = {}\nans = 0\nfor i in range(n+1):\n if s[i].islower():\n t+=1\n if s[i] not in mp:\n mp[s[i]]=1\n else:\n ans = len(mp)\n t = 0\n mp = {}\nprint(ans)\n\n"}, {"source_code": "n=int(input())\ns=list(input())\nf=0\nfor i in range(n):\n if s[i].isupper():\n f=1\n break\nif f==0:\n a=set(s)\n print(len(a))\n exit()\nidx=[] \nfor i in range(n):\n if s[i].isupper():\n idx.append(i)\nans=0\n#print(*idx)\nfor i in range(len(idx)):\n if i==0:\n a=[]\n for i in range(0,idx[i]):\n a.append(s[i])\n a=set(a)\n ans=max(ans,len(a))\n else:\n a=[]\n for i in range(idx[i-1]+1,idx[i]):\n a.append(s[i])\n a=set(a)\n ans=max(ans,len(a))\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nmax_count = 0\ncount = 0\nprev = []\nfor i in s:\n if i.islower():\n if i not in prev:\n prev.append(i)\n count += 1\n else:\n if count > max_count:\n max_count = count\n prev = []\n count = 1\n else:\n if count > max_count:\n max_count = count\n prev = []\n count = 0\nprint(max_count)\n"}, {"source_code": "# May the Speedforce be with us...\n'''\nfor _ in range(int(input())):\narr=list(map(int,input().split()))\nn,k=map(int,input().split())\nn=int(input())\ns=input()\n\nfrom collections import defaultdict\nd=defaultdict()\n\nd=dict()\ns=set()\ns.intersection()\ns.union()\ns.difference()\n\n\nproblem statement achhe se padhna hai\nage se bhi dekhna hai, piche se bhi dekhna hai\n'''\nfrom math import gcd,ceil\nfrom collections import defaultdict as dd\ndef lcm(a,b):\n\treturn (a*b)//gcd(a,b)\ndef inin():\n\treturn int(input())\ndef inar():\n\treturn list(map(int,input().split()))\ndef ar(element,size):\n\treturn [element for i in range(size)]\ndef digitsum(num):\n\tsu=0\n\twhile(num):\n\t\tsu+=num%10\n\t\tnum//=10\n\treturn su\n\nn=inin()\nstring=input()\ntemp=''\nprev=string[0]\ntemp+=prev\nfor i in string[0:n]:\n\tif i!=prev:\n\t\ttemp+=i\n\tprev=i \ncntr=0\ncurr=0\nfor i in temp:\n\tif i.isupper():\n\t\tcntr=max(cntr,curr)\n\t\tcurr=0\n\telse:\n\t\tcurr+=1\nprint(cntr)"}, {"source_code": "n=int(input())\ns=input()\nmax1=0\ncnt=0\narr=[]\n\nfor i in range(n):\n if(ord(s[i])>=97 and ord(s[i])<=122 and s[i] not in arr):\n arr.append(s[i])\n cnt+=1\n elif(ord(s[i])>=65 and ord(s[i])<=90):\n if(max1<cnt):\n max1=cnt\n cnt=0\n arr=[]\nprint(max1)\n\n \n"}, {"source_code": "n=int(input())\ns=input()\na=[]\nb=[]\nmin=0\nfor i in range(n):\n if(97<=ord(s[i])<=122):\n if s[i] not in b:\n a.append(i+1)\n b.append(s[i])\n min=len(a)\n \n else:\n if(len(a)>min):\n min=len(a)\n \n a.clear()\n b.clear()\n \n \nif(min==1):\n print(0)\nelse:\n print(min)\n "}, {"source_code": "n = int(input())\ns = input()\nl = [0]*26\nl1 = [0]\nc = 0\nfor e in s:\n\tif e.islower() and l[ord(e)-97]==0:\n\t\tl[ord(e)-97]+=1\n\t\tc+=1\n\t\tif e==s[n-1]:\n\t\t\tl1.append(c)\n\telif ord(e)>=97:\n\t\tpass\n\telif ord(e)<97 or e==s[n-1]:\n\t\tl1.append(c)\n\t\tl = [0]*26\n\t\tc = 0\nprint(max(l1))\n"}, {"source_code": "# Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon!\nn=int(input())\ns=input()\n\n\nd=\"\"\nk=\"\"\n\nstart=0\nend=0\n\nfor i in range(n-1):\n\t\n\tif(s[i]!=s[i+1]):\n\t\td=d+s[i]\n\t\t\nfor i in d:\n\tif(ord(i)<=90):\n\t\tk=k+' '\n\t\n\telse:\n\t k=k+i\n\t\t\nk=k.split()\nleng=0\n\nfor i in k:\n\tx=len(i)\n\tleng=max(x,leng)\n\t\t\n\t\nprint(leng)"}, {"source_code": "n = int(input())\ns = input()\nupper_loc = []\nfor i in range(n):\n if s[i].isupper() == True:\n upper_loc.append(i)\n\nmax_len_set = 0\n\nif len(upper_loc) == 0:\n print(len(set(s)))\nelif len(upper_loc) == 1:\n if len(set(s[0:upper_loc[0]])) >= len(set(s[upper_loc[0]: ])):\n print(len(set(s[0:upper_loc[0]])))\n elif len(set(s[0:upper_loc[0]])) < len(set(s[upper_loc[0]: ])):\n print(len(set(s[upper_loc[0]:])) - 1)\nelse:\n for i in range(len(upper_loc) - 1):\n if len(set(s[upper_loc[i] + 1: upper_loc[i+1]])) > max_len_set:\n max_len_set = len(set(s[upper_loc[i] + 1: upper_loc[i+1]]))\n print(max_len_set)"}, {"source_code": "n = int(input())\nstr = input()\nindex = []\nfor i in range(len(str)):\n if str[i] in 'QWERTYUIOPLKJHGFDSAZXCVBNM':\n index.append(i)\nresult = 0\n\nfor i in range(len(index)-1):\n string = str[index[i]+1:index[i+1]]\n #print(string)\n string = list(string)\n string = set(string)\n result = max(result,len(string))\nprint(index)\nif 0 not in index:\n string = str[:index[0]]\n #print(string)\n string = list(string)\n string = set(string)\n result = max(result, len(string))\n\nif len(str)-1 not in index:\n string = str[index[len(index) - 1]:]\n print(string)\n string = list(string)\n string = set(string)\n result = max(result, len(string))\n\nprint(result)"}, {"source_code": "n=int(input())\nletter=str(input())\nc=0\nmax=0\nfor i in range(len(letter)-1):\n if ord(letter[i])>=97 and ord(letter[i])<=122 and letter[i]!=letter[i+1] and ord(letter[i+1])>=97 and ord(letter[i+1])<=122:\n c=c+1\n elif c>max:\n max=c+1\n c=0\nprint(max)\n "}, {"source_code": "n=int(input())\ns=list(input())\nl=0\nr=0\nlenm=0\nb=set()\nwhile r<n:\n if 'a'<=s[r]<='z':\n b.add(s[r])\n r+=1\n else:\n p=s[l:r]\n if len(p)!=0:\n if len(p)!=p.count(p[0]):\n lenm=max(lenm,len(b))\n b=set()\n r+=1\n l=r\nlenm=max(lenm,len(b))\nprint(lenm)\n \n \n"}, {"source_code": "def main():\n t=input()\n n=raw_input()\n n+=\"A\"\n #print n\n if n==2:\n if ord(n[0])<95:\n print 0\n else:\n print 1\n else:\n r=[]\n for i in xrange(t):\n if n[i]!=n[i+1]:\n r.append(n[i])\n if n[i]!=n[t]:\n r.append(n[t])\n count=0L\n p=[]\n #print r\n for i in r:\n #if i==r[len(r)-1] and ord(i)>95:\n #r.append(\"A\")\n #print r\n if ord(i)>95:\n count+=1\n else:\n p.append(count)\n count=0\n print max(p) \nif __name__ == '__main__':\n main()"}, {"source_code": "'''input\n12\nzACaAbbaazzC\n'''\nn = input()\nr = raw_input()\nfreq = [0 for i in range(len(r))]\nfor i in range(len(r)):\n\tif r[i].isupper():\n\t\tfreq[i] = freq[i-1]+1\n\telse:\n\t\tfreq[i] = freq[i-1]\nind = 0\nind1 = 0\nans = 0\nfor i in range(1,n):\n\tif freq[i] == freq[i-1]:\n\t\tind1 += 1\n\tif freq[i] != freq[i-1]:\n\t\tans = max(ans,len(set(r[ind:ind1])))\n\t\tind = i+1\n\t\tind1 = i+1\nprint ans \n"}, {"source_code": "alphabet = 'abcdefghijklmnopqrstuvwxyz'\nalphabet_h = alphabet.upper()\nalpha = tuple(alphabet)\nalpha_h = tuple(alphabet_h)\nn = int(input())\ns = str(input())\ng = 0\ni = 1\n\nwhile i <= n-1:\n if s[i-1] in alpha:\n while s[i] in alpha_h:\n # print(s[i], i)\n g = g + 1\n i = i + 1\n # print(i)\n if i>=n-1 or s[i] in alpha:\n break \n i = i + 1\ni = n - 1\nif s[n-1] in alpha_h and g > 0:\n while s[i] in alpha_h and i>=0:\n g = g - 1\n i = i - 1\n \nprint(g)"}, {"source_code": "n=int(input())\nletter=str(input())\nc=0\nmax=0\nfor i in range(len(letter)-1):\n if ord(letter[i])>=97 and ord(letter[i])<=122 and letter[i]!=letter[i+1] and ord(letter[i+1])>=97 and ord(letter[i+1])<=122:\n c=c+1\n elif c>max:\n max=c\n c=0\nprint(max+1)\n "}, {"source_code": "n = int(input())\nsymbols = input()\n\nm = 0\nfor i in range(len(symbols)):\n\tfor j in range(i, len(symbols)):\n\t\tif symbols[i:j].islower():\n\t\t\tif list(set(symbols[i:j]))==list(symbols[i:j]):\n\t\t\t\tm = max(j-i, m)\nprint(m)\n"}, {"source_code": "n=input()\ns=raw_input()\nl=[]\nx=\"\"\nfor i in range(n):\n if s[i].isupper():\n l.append(x)\n x=\"\"\n else:\n x+=s[i]\np=[]\nk=0\nfor j in l:\n k=max(k,len(set(j)))\nprint k\n \n \n"}, {"source_code": "n = int(input())\na = input()\nMAX = 0\nend = 0\nfor i in range(n):\n start = end\n end = start+1\n while a[start:end].islower():\n if MAX < len(set(a[start:end])):\n MAX = len(set(a[start:end]))\n end+=1\n if end >= n:\n break\nprint(MAX)"}, {"source_code": "n=int(input())\nb=input()\na,c,d,e=[],[],[],[]\nnom=0\nmaxx=0\nfor i in range(n):\n a.append(b[i])\n if a[i].islower()==True:\n c.append('m')\n else:\n c.append('b')\n#if c.count('b')<2 or c.count('b')==n:\n# print(0)\n#else:\nfor i in range(n):\n if c[i]=='b':\n d.append(i)\nfor i in range(len(d)-1):\n e.append([])\n for j in range(d[i]+1,d[i+1]):\n if b[j] not in e[nom]:\n e[nom].append(b[j])\n nom+=1\nfor i in range(len(e)):\n if len(e[i])>maxx:\n maxx=len(e[i])\nprint(maxx)"}, {"source_code": "n=int(input())\ns=input()\np=set()\nl=1\nfor i in range(n):\n if s[i].isupper():\n if len(p)>l:\n l=len(p)\n p=set()\n else:\n p.add(s[i])\nprint(l)\n \n"}, {"source_code": "n = int(input())\ns = list(input())\nans=0\ntem=[]\nfor i in range(n):\n if s[i]>='A' and s[i]<='Z':\n ans=max(ans,len(set(tem)))\n tem=[]\n else:\n tem+=[s[i]]\nprint(ans) "}, {"source_code": "input()\ns=input()\nc=0\na=[]\nfor i in range(1,len(s)):\n if s[i-1]!=s[i] and s[i].islower() and s[i-1].islower():\n a.append(s[i-1])\n a.append(s[i])\nprint(len(set(a)))\n"}, {"source_code": "n = int(input())\ns = input()\nx = ''\nfor i in s:\n if i.isupper():\n x += ' '\n else:\n x += i\nx = x.strip().split(' ')\nif len(x):\n print(0)\nelse:\n x = [len(set(i)) for i in x]\n print(max(x))\n"}, {"source_code": "n = input()\ns = raw_input()\ns += 'A'\n\nli = []\n\ncur = 0\nmaxi = 0\nwhile cur < n:\n\twhile s[cur].isupper():\n\t\tcur += 1\n\t\tif cur < len(s):\n\t\t\tbreak\n\ttmp = \"\"\n\twhile s[cur].islower():\n\t\ttmp += s[cur]\n\t\tcur += 1\n\n\tif tmp != \"\":li.append(tmp)\n\nfor each in li:\n\tnew = 0\n\tif len(each) == 1:\n\t\tnew = 1\n\telse:\n\t\tl = [each[0]]\n\t\tfor i in each:\n\t\t\tif i != l[-1]:\n\t\t\t\tl.append(i)\n\t\tnew = len(l)\n\n\tif new > maxi:\n\t\tmaxi = new\n\nprint maxi"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Dec 18 19:44:17 2017\n\n@author: aeshak\n\"\"\"\nimport string\nn = input()\ns = raw_input()\nuppers = set(string.ascii_uppercase)\nupperLoc = []\nfor i in xrange(n):\n\tif s[i] in uppers:\n\t\tupperLoc.append(i)\nmaxNo = 0\nm = len(upperLoc)\npieces = [] \nstart = 0\nif upperLoc:\n\tfor i in xrange(n):\n\t\tif i in upperLoc:\n\t\t\tif start != i:\n\t\t\t\tpieces.append(s[start:i])\n\t\t\tstart = i+1\n\tif not pieces and start != 0:\n\t\tpieces.append(s[start:])\n\tmaxNo = 0\n\tfor piece in pieces:\n\t\tmaxNo = max(maxNo, len(set(piece)))\nelse:\n\tmaxNo = set(s)\nprint maxNo\n"}, {"source_code": "input()\ns=input()\nc=0\na=[]\nb=[]\nif s[0].islower():\n a.append(s[0])\nfor i in range(1,len(s)):\n if s[i].isupper():\n b.append(len(set(a)))\n a=[]\n elif s[i-1]!=s[i] and s[i].islower() and s[i-1].islower():\n a.append(s[i-1])\n a.append(s[i])\n elif s[i-1]==s[i] and s[i].islower():\n a.append(s[i])\nb.append(len(set(a)))\n#print(*b)\nprint(max(b))\n"}, {"source_code": "n = int(input())\na = input()\nMAX = 0\nend = 0\nfor i in range(n):\n start = end\n end = start+1\n while a[start:end].islower():\n if MAX < len(set(a[start:end])):\n MAX = len(set(a[start:end]))\n end+=1\n if end >= n:\n break\nprint(MAX)"}, {"source_code": "n=int(input())\ns=input()\nsub=[]\nans=0\nfor a in range(0,n):\n letter=s[a]\n if letter.islower()!=1:\n ans=max(ans,len(sub))\n sub=[]\n continue\n if letter not in sub:\n sub.append(letter)\nprint(ans)\n"}, {"source_code": "import sys\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\n# sys.setrecursionlimit(1000000)\ndef Ints(): return map(int, sys.stdin.readline().strip().split())\ndef Strs(): return map(str, sys.stdin.readline().strip().split())\ndef Array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef Str(): return sys.stdin.readline().strip()\ndef Int(): return int(sys.stdin.readline().strip())\ndef MOD(): return 1000000007\n\ndef power(base, power):\n MOD = 1000000007\n result = 1\n while power > 0:\n if power % 2 == 1:\n result = (result * base) % MOD\n power = power // 2\n base = (base * base) % MOD\n return result\n\nif __name__ == \"__main__\":\n n = int(input())\n S = Str()\n temp = set()\n res = 0\n for i in range(n):\n if 97 >= ord(S[i]) <= 122:\n temp.add(S[i])\n else:\n res = max(res,len(temp))\n temp = set()\n print(res)\n"}, {"source_code": "n=int(input())\ns=input()\nl=[]\nc=0\nfor i in s:\n if(i.islower() and i not in l):\n l.append(i)\n c=c+1\nprint(c)"}, {"source_code": "s = input()\ns = input()\n\ndef isupper(c):\n\treturn 'A' <= c and c <='Z'\n\ndef islower(c):\n\treturn 'a' <= c and c <='z'\n\ndef h(c):\n\treturn ord(c) - ord('a')\n\nanswer = 0\nwaiting_lower = True\n\nfor i in range(len(s)):\n\tif islower(s[i]):\n\t\tif waiting_lower:\n\t\t\tcount = 1\n\t\t\twaiting_lower = False\n\t\t\tappear = [True if _ == h(s[i]) else False for _ in range(26)]\n\t\telse:\n\t\t\tif not appear[h(s[i])]:\n\t\t\t\tcount += 1\n\t\t\t\tanswer = max(count,answer)\n\t\t\t\tappear[h(s[i])] = True\n\telse:\n\t\twaiting_lower = True\n\nprint(answer)\n\n"}, {"source_code": "n=int(input())\nx=input()\nc=[]\nfor i in range(len(x)):\n if(65<=ord(x[i])<=90):\n c.append(i)\nl=[]\nz=-1\nfor i in range(len(c)):\n a=set(x[z+1:c[i]])\n l.append(len(a))\n z=c[i]\nif(len(c)==0):\n print(len(set(x)))\n exit()\nprint(max(l))"}, {"source_code": "# Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon!\nn=int(input())\ns=input()\n\n\nd=\"\"\nk=\"\"\n\nfor i in range(n-1):\n\t\n\tif(s[i]!=s[i+1]):\n\t\td=d+s[i]\nd=d+s[n-1]\n\t\t\nfor i in d:\n\tif(ord(i)<=90):\n\t\tk=k+' '\n\t\n\telse:\n\t k=k+i\n\t\t\n\t\t\t\nk=k.split()\nleng=0\n\n\nfor i in k:\n\tx=len(i)\n\tleng=max(x,leng)\n\nprint(leng)"}, {"source_code": "\nN = int(input())\n\ns = input()\n\nmaxSize = -1\nA = []\n\nfor i in s:\n\tif ord(i) >= 97 and ord(i) <= 122:\n\t\tif not i in A:\n\t\t\tA.append(i)\n\t\t\t#print(A)\n\t\telse:\n\t\t\tif len(A) > maxSize:\n\t\t\t\tmaxSize = len(A)\n\t\t\tA.clear()\n\t\t\tA.append(i)\n\telse:\n\t\tif len(A) > maxSize:\n\t\t\tmaxSize = len(A)\n\t\tA.clear()\n\nprint(maxSize)"}, {"source_code": "t=input()\nA=raw_input()\nB=[]\nMax=0\nfor i in range(len(A)):\n\tif(ord(A[i])>=97 and ord(A[i])<=122):\n\t\tB.append(A[i])\n\telse:\n\t\tB=list(set(B))\n\t\tcount=len(B)\n\t\tif(count>Max):\n\t\t\tMax=count\n\t\tB=[]\n\nprint Max"}, {"source_code": "n = int(input())\nstr = input()\nindex = [0]\nfor i in range(len(str)):\n if str[i] in 'QWERTYUIOPLKJHGFDSAZXCVBNM':\n index.append(i)\nresult = 0\n\nfor i in range(len(index)-1):\n string = str[index[i]+1:index[i+1]]\n string = list(string)\n string = set(string)\n result = max(result,len(string))\n\nif 0 not in index:\n string = str[:index[0]]\n string = list(string)\n string = set(string)\n result = max(result, len(string))\n\nif len(str)-1 not in index:\n string = str[index[len(index) - 1]:]\n string = list(string)\n string = set(string)\n result = max(result, len(string))\n\nprint(result)"}, {"source_code": "cute = input()\nposl = []\ntemp = str()\nfor i in cute:\n if i.isupper():\n if temp != '':\n posl.append(temp)\n temp = ''\n else:\n temp = temp + i\n\nmaxlen = 0\nfor i in range(len(posl)):\n posl[i] = ''.join(set(posl[i]))\n if len(posl[i]) > maxlen:\n maxlen = len(posl[i])\n\nprint(maxlen)\n\n"}, {"source_code": "t=input()\nA=raw_input()\nB=[]\nMax=0\nfor i in range(len(A)):\n\tif(ord(A[i])>=97 and ord(A[i])<=122):\n\t\tB.append(A[i])\n\t\tprint B\n\telif(ord(A[i])>=65 and ord(A[i])<=90):\n\t\tB=list(set(B))\n\t\tcount=len(B)\n\t\tB=[]\n\t\tif(count>Max):\n\t\t\tMax=count\nprint Max"}, {"source_code": "n=int(input())\nx=input()\nc=[]\nfor i in range(len(x)):\n if(65<=ord(x[i])<=90):\n c.append(i)\nl=[]\nz=-1\nfor i in range(len(c)):\n a=set(x[z+1:c[i]])\n l.append(len(a))\n z=c[i]\nif(len(c)==0):\n print(len(set(x)))\n exit()\nprint(max(l))"}, {"source_code": "n=int(input())\ns=input()+'ZZ'\nj=0\nm=0\nfor x in range(n+1):\n if s[x].islower()and s[x]!=s[x+1]:\n j+=1\n elif s[x].isupper():\n m=max(m,j)\n j=0\nprint(m)\n"}, {"source_code": "n=int(input())\nx=input()\nc=[]\nfor i in range(len(x)):\n if(65<=ord(x[i])<=90):\n c.append(i)\nl=[]\nz=0\nfor i in range(len(c)):\n a=set(x[z:c[i]])\n l.append(len(a))\n z=c[i]\nif(len(l)==0):\n print(1)\n exit()\nprint(max(l)-1)"}, {"source_code": "n = int(input())\nstr = input()\nindex = [0]\nfor i in range(len(str)):\n if str[i] in 'QWERTYUIOPLKJHGFDSAZXCVBNM':\n index.append(i)\nresult = 0\n\nfor i in range(len(index)-1):\n string = str[index[i]+1:index[i+1]]\n string = list(string)\n string = set(string)\n result = max(result,len(string))\n\nif 0 not in index:\n string = str[:index[0]]\n string = list(string)\n string = set(string)\n result = max(result, len(string))\n\nif len(str)-1 not in index:\n string = str[index[len(index) - 1]:]\n string = list(string)\n string = set(string)\n result = max(result, len(string))\n\nprint(result)"}, {"source_code": "n = int(input())\nline = input()\n\ns = set()\n\n# for i in range(len(line)):\n# \tfor j in range(i + 1, len(line)):\n# \t\tprint(line[i:j])\n\nfor c in line:\n\tif c.lower() == c:\n\t\ts.add(c)\n\nprint(len(s))"}, {"source_code": "\nN = int(input())\n\ns = input()\n\nmaxSize = 0\nA = []\n\nfor i in s:\n\tif ord(i) >= 97 and ord(i) <= 122:\n\t\tif not i in A:\n\t\t\tA.append(i)\n\t\t\tprint(A)\n\t\telse:\n\t\t\tif maxSize < len(A):\n\t\t\t\tmaxSize = len(A)\n\t\t\t\tA.clear()\n\telse:\n\t\tif maxSize < len(A):\n\t\t\tmaxSize = len(A)\n\t\tA.clear()\n\nif len(A) != 0 and maxSize < len(A):\n\tmaxSize = len(A)\n\nprint(maxSize)"}, {"source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import setcheckinterval, stdin\nsetcheckinterval(1000)\n \n# print(\"Case #{}: {} {}\".format(i, n + m, n * m))\n \n \ndef iin(): return int(stdin.readline())\n \n \ndef lin(): return list(map(int, stdin.readline().split()))\n \nfrom collections import defaultdict as dc\n\nn = iin()\na=input()\nans=0\nd=dc(int)\nfor i in a:\n if 97<=ord(i)<=122:\n d[i]+=1\n else:\n ans=max(ans,len(d))\n d=dc(int)\nprint(ans)\n"}, {"source_code": "n = int(input())\ncute = input()\nposl = []\ntemp = str()\nfor i in cute:\n if i.isupper():\n if temp != '':\n posl.append(temp)\n temp = ''\n else:\n temp = temp + i\n\nmaxlen = 0\nfor i in range(len(posl)):\n posl[i] = ''.join(set(posl[i]))\n if len(posl[i]) > maxlen:\n maxlen = len(posl[i])\n\nprint(maxlen)\n\n"}, {"source_code": "length = int(input(\"\"))\nstring = input(\"\")\n\nsetOfChars = set()\nmax = 0;\n\nfor c in string:\n if c == c.lower():\n setOfChars.add(c)\n max = len(setOfChars)\n else:\n if (len(setOfChars) > max):\n #print(\"Max {} is smaller than length {}\".format(max, len(setOfChars)))\n max = len(setOfChars)\n setOfChars = set()\n\nprint(max)\n"}, {"source_code": "\nn = int(input())\ns = input()\n\nres = 0\n\nfor l in range(n,1,-1):\n for offset in range(0,n-l+1):\n \n chars = set()\n ok = True\n for i in range(offset+1,offset+l):\n if not s[i].islower():\n ok = False\n break\n chars.add(s[i])\n \n if ok:\n res = max(res, len(chars))\nprint(res)"}, {"source_code": "n=int(input())\ns=input()\nsub=[]\nans=0\nfor a in range(0,n):\n letter=s[a]\n print(\"letter\",letter)\n if letter not in sub:\n sub.append(letter)\n if letter.islower()==False or a==n-1:\n ans=max(ans,len(sub))\n sub=[]\n continue\n \nprint(ans)\n"}, {"source_code": "n=int(input())\ns=list(input())\nf=0\nfor i in range(n):\n if s[i].isupper():\n f=1\n break\nif f==0:\n a=set(s)\n print(len(a))\n exit()\nidx=[] \nfor i in range(n):\n if s[i].isupper():\n idx.append(i)\nans=0\n#print(*idx)\nfor i in range(len(idx)):\n if i==0:\n a=[]\n for i in range(0,idx[i]):\n a.append(s[i])\n a=set(a)\n ans=max(ans,len(a))\n else:\n a=[]\n for i in range(idx[i-1]+1,idx[i]):\n a.append(s[i])\n a=set(a)\n ans=max(ans,len(a))\nprint(ans)"}, {"source_code": "l = []\nans = 0\nlow = 'qwertyuiopasdfghjklzxcvbnm'\n\nn = int(input())\ns = input()\nfor c in s:\n if(c not in low):\n ans = max(ans, len(l))\n l.clear()\n elif(c not in l):\n l.append(c)\nprint(ans)"}, {"source_code": "n = input()\na = raw_input()\nans = 0\nfound = {}\ntempAns = 0\nfor i in a:\n pos = ord(i)-ord('a')\n if pos >=0 and pos<=26:\n if not(i in found):\n tempAns += 1\n found[i] = True\n else:\n ans = max(ans,tempAns)\n found = {}\n tempAns = 0\nprint ans\n"}, {"source_code": "n = input()\ns = raw_input()\ncur=0\ns = s+'Z'\nd={}\nfor i in range(n):\n if s[i] not in d and s[i].isupper()==False:\n d[s[i]]=1\n elif s[i].isupper() ==True:\n if len(d)>cur:\n cur = len(d)\n d={}\n # print d,len(d),s[i],s[i].isupper()\nprint cur\n"}, {"source_code": "\ninput()\n\ninp = input()\n\n\nmmax = 0\nchars = []\ncurr=0\nfor char in inp:\n\t\n\tif char.isupper():\n\t\t#char - \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u0430\u044f\n\t\tmmax=max(mmax,curr)\n\t\tcurr=0\n\t\tchars=[]\n\t\t\n\telse:\n\t\t#char - \u0441\u0442\u0440\u043e\u0447\u043d\u0430\u044f\n\t\tif char not in chars:\n\t\t\tchars.append(char)\n\t\t\tcurr+=1\n\t\telse:\n\t\t\tpass\n\nprint(mmax)"}, {"source_code": "n=int(input())\ns=str(input())\nl=[0]\nfor i in range(len(s)):\n if ord(s[i])>=65 and ord(s[i])<=90:\n l.append(i)\nans=0\nl.append(n-1)\nfor i in range(len(l)-1):\n ls=[]\n for j in range(l[i]+1,l[i+1]):\n if s[j] not in ls:\n ls.append(s[j])\n ans=max(ans,len(ls))\n #print(ls)\nprint(ans)\n\n"}, {"source_code": "def ideal(s):\n if len(s) == 1 and s[0].islower():\n return len(s)\n t = 'A' + s\n a = \" \"\n count1 = 0\n for i in range(len(t)):\n if t[i].islower():\n a += t[i]\n else:\n count2 = 0\n b = sorted(a)\n for j in range(1, len(b)):\n if b[j] == b[j - 1]:\n count2 += 1\n if len(b) - count2 > count1:\n count1 = len(b) - count2\n a = \" \"\n return count1 - 1\n\n\nn = int(input())\nprint(ideal(input()))\n"}, {"source_code": "alphabet = 'abcdefghijklmnopqrstuvwxyz'\nalphabet_h = alphabet.upper()\nalpha = tuple(alphabet)\nalpha_h = tuple(alphabet_h)\nn = int(input())\ns = str(input())\ng = 0\ni = 1\n\nwhile i <= n-1:\n if s[i-1] in alpha:\n while s[i] in alpha_h:\n # print(s[i], i)\n g = g + 1\n i = i + 1\n # print(i)\n if i>=n-1 or s[i] in alpha:\n break \n i = i + 1\ni = n - 1\nif s[n-1] in alpha_h and g > 0:\n while s[i] in alpha_h and i>=0:\n g = g - 1\n i = i - 1\nif n == 1 and s[0] in alpha:\n g = 1\n \nprint(g)"}, {"source_code": "alphabet = 'abcdefghijklmnopqrstuvwxyz'\nalphabet_h = alphabet.upper()\nalpha = tuple(alphabet)\nalpha_h = tuple(alphabet_h)\nalpha_temp = []\ng = []\nn = int(input())\ns = str(input())\n\nfor i in range(n):\n if s[i] in alpha and s[i] not in alpha_temp:\n alpha_temp.append(s[i])\n g.append(len(alpha_temp))\n elif s[i] in alpha_h:\n g = []\n g.append(len(alpha_temp))\n alpha_temp = []\n \nprint(max(g))\n"}, {"source_code": "\nn = int(input())\n\ns = input()\ns+='A'\n\nt = 0\nmp = {}\nans = 0\nfor i in range(n+1):\n if s[i].islower():\n t+=1\n if s[i] not in mp:\n mp[s[i]]=1\n else:\n ans = len(mp)\n t = 0\n mp = {}\nprint(ans)\n\n"}, {"source_code": "length = int(input(\"\"))\nstring = input(\"\")\n\nsetOfChars = set()\nmax = 0;\n\nfor c in string:\n if c == c.lower():\n setOfChars.add(c)\n else:\n if (len(setOfChars) > max):\n max = len(setOfChars)\n\nprint(len(setOfChars))\n"}, {"source_code": "from sys import stdin\nupper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\ns = set()\nans = 0\na = stdin.readline().strip()\nfor i in a:\n if i in upper:\n ans = max(ans,len(s))\n s = set()\n else:\n s.add(i)\nans = max(ans,len(s))\nprint ans"}, {"source_code": "n=int(input())\nunique=set()\nseq=list(input())\nfor i in seq:\n if i.islower():\n unique.add(i)\nprint(len(unique))"}, {"source_code": "A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nl=int(input())\nw=input()\nit=[]\nfor i in range(l):\n if (w[i] in A) and (w[i] not in it):\n it.append(w[i])\n continue\n elif (w[i] in A) and (w[i] in it):\n continue\n else:\n continue\nprint(len(it))"}, {"source_code": "#864B\nn = int(input())\ns = input()\nif len(s) == 1:\n print(1)\nelse:\n parts = []\n i = 0\n string = \"\"\n while i < len(s):\n if s[i].islower():\n string += s[i]\n else:\n parts.append(string)\n string = \"\"\n i += 1\n parts.append(string)\n m = 0\n for j in parts:\n j = set(j)\n m = max(len(j),m)\n print(m)\n"}, {"source_code": "n=int(input())\ns=input()\na=set()\nres = 0\nfor i in s:\n\tif i.islower():\n\t\ta.add(i)\n\t\tans=max(res,len(a))\n\telse:\n\t\ta.clear()\nprint(res)\n"}, {"source_code": "n = int(input())\ns = input()\nu = set()\ncnt = 0\nfor i in s:\n if i.islower():\n u.add(i)\n cnt = len(u)\nprint(cnt)\n\n"}, {"source_code": "n = input()\ns = raw_input()\ncur=0\ns = s+'Z'\nd={}\nfor i in range(n):\n if s[i] not in d and s[i].isupper()==False:\n d[s[i]]=1\n elif s[i].isupper() ==True:\n if len(d)>cur:\n cur = len(d)\n d={}\n # print d,len(d),s[i],s[i].isupper()\nprint cur\n"}, {"source_code": "import sys\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\n# sys.setrecursionlimit(1000000)\ndef Ints(): return map(int, sys.stdin.readline().strip().split())\ndef Strs(): return map(str, sys.stdin.readline().strip().split())\ndef Array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef Str(): return sys.stdin.readline().strip()\ndef Int(): return int(sys.stdin.readline().strip())\ndef MOD(): return 1000000007\n\ndef power(base, power):\n MOD = 1000000007\n result = 1\n while power > 0:\n if power % 2 == 1:\n result = (result * base) % MOD\n power = power // 2\n base = (base * base) % MOD\n return result\n\nif __name__ == \"__main__\":\n n = int(input())\n S = Str()\n temp = set()\n res = 0\n for i in range(n):\n if 97 >= ord(S[i]) <= 122:\n temp.add(S[i])\n else:\n res = max(res,len(temp))\n temp = set()\n res = max(res,len(temp))\n print(res)\n"}, {"source_code": "length = int(input(\"\"))\nstring = input(\"\")\n\nsetOfChars = set()\nmax = 0;\n\nfor c in string:\n if c == c.lower():\n setOfChars.add(c)\n else:\n if (len(setOfChars) > max):\n #print(\"Max {} is smaller than length {}\".format(max, len(setOfChars)))\n max = len(setOfChars)\n setOfChars = set()\n\nprint(max)\n"}, {"source_code": "list = [0 for x in range(26)]\ntrash = input()\ns = input()\nfor c in s:\n int_c = ord(c) - ord('a')\n if int_c >= 0 and int_c < 26:\n list[ord(c) - ord('a')] = 1\nans = 0\nfor i in list:\n ans += i\nprint(ans)\n"}, {"source_code": "def ideal(s):\n if len(s) == 1 and s[0].islower():\n return len(s)\n t = 'A' + s\n a = \" \"\n count1 = 0\n for i in range(len(t)):\n if t[i].islower():\n a += t[i]\n else:\n count2 = 0\n b = sorted(a)\n for j in range(1, len(b)):\n if b[j] == b[j - 1]:\n count2 += 1\n if len(b) - count2 > count1:\n count1 = len(b) - count2\n a = \" \"\n return count1 - 1\n\n\nn = int(input())\nprint(ideal(input()))\n"}, {"source_code": "import sys\n\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\ndef List(): return list(map(int, input().split()))\ndef Num(): return int(input())\n\n\nn = Num()\ns = input()\nst = -1\nfor i in range(n):\n if s[i].isupper():\n st = i\n break\nans = 0\nu = set()\nfor i in range(n - 1, st - 1, -1):\n if s[i].isupper():\n u = set()\n else:\n if s[i].islower():\n u.add(s[i])\n ans = max(ans, len(u))\nprint(ans)\n"}, {"source_code": "n=input()\ns=raw_input()\nstart,LL=0,0\nfor i in range(n):\n\tif s[i] >= 'A' and s[i] <= 'Z':\n\t\tD=set(s[start:i])\n\t\tif LL < len(D): LL = len(D)\n\t\tstart=i+1\nprint LL"}, {"source_code": "n = input()\ns = raw_input()\ns += 'A'\n\nli = []\n\ncur = 0\nmaxi = 0\nwhile cur < n:\n\twhile s[cur].isupper():\n\t\tcur += 1\n\t\tif cur < len(s):\n\t\t\tbreak\n\ttmp = \"\"\n\twhile s[cur].islower():\n\t\ttmp += s[cur]\n\t\tcur += 1\n\n\tif tmp != \"\":li.append(tmp)\n\nfor each in li:\n\tnew = 0\n\tif len(each) == 1:\n\t\tnew = 1\n\telse:\n\t\tl = [each[0]]\n\t\tfor i in each:\n\t\t\tif i != l[-1]:\n\t\t\t\tl.append(i)\n\t\tnew = len(l)\n\n\tif new > maxi:\n\t\tmaxi = new\n\nprint maxi"}, {"source_code": "a=int(input())\nb=str(input())\nx=0\nz=str(\"\")\nwhile (x<a):\n if(ord(b[x])>=96):\n m=str(b[x])\n else:\n m=str(\"0\")\n x+=1\n z=z+m\nz=z.split(\"0\")\nx=0\nh=0\nlol=str(\"\")\nwhile (x<len(z)):\n lol=str(lol)+str(z[x])\n x+=1\nn=str(z[0])\nif (len(z)<1):\n h=0\nelif(len(z)==1 and len(n.replace(n[0],\"\"))==0):\n h=1\nelse:\n while(x<len(z)):\n n=str(z[x])\n if(len(n)<2):\n vl=0\n elif(len(n.replace(n[0],\"\"))==0):\n h+=0\n else:\n q=len(n)\n h+=1\n while(q>0):\n n=n.replace(n[0],\"\")\n if(len(n)>0):\n vl=1\n else:\n vl=0\n q=len(n)\n h+=vl\n z=lol.replace(n[0],\"\")\n x+=1\nprint(h)\n"}, {"source_code": "ans = 0\ncombo = 0\npre = -1\ninput()\nfor c in input():\n if c.isupper():\n ans = max(ans, combo)\n combo = 0\n pre = -1\n elif c != pre:\n combo += 1\n pre = c\nprint(max(ans, combo))\n \n"}, {"source_code": "n = int(input())\ns = str(input())\nans = 0\ntemp=''\ni = 0\nwhile i<len(s):\n if ord(s[i])<97:\n i = i +1\n else:\n while i<len(s) and ord(s[i])>=97:\n temp = temp+ s[i]\n i = i + 1\n t = set(temp)\n ans = max(len(t), ans)\nprint(ans)\n"}, {"source_code": "alphabet = 'abcdefghijklmnopqrstuvwxyz'\nalphabet_h = alphabet.upper()\nalpha = tuple(alphabet)\nalpha_h = tuple(alphabet_h)\nalpha_temp = []\ng = []\ni = 0\nn = int(input())\ns = str(input())\n\nwhile i <= n-1:\n if s[i] in alpha and s[i] not in alpha_temp:\n while s[i] in alpha and s[i] not in alpha_temp:\n alpha_temp.append(s[i])\n i = i + 1\n if i > n - 1:\n break\n g.append(len(alpha_temp)) \n elif s[i] in alpha_h:\n g = []\n g.append(len(alpha_temp))\n alpha_temp = []\n i = i+1\n \nprint(max(g))"}, {"source_code": "# May the Speedforce be with us...\n'''\nfor _ in range(int(input())):\narr=list(map(int,input().split()))\nn,k=map(int,input().split())\nn=int(input())\ns=input()\n\nfrom collections import defaultdict\nd=defaultdict()\n\nd=dict()\ns=set()\ns.intersection()\ns.union()\ns.difference()\n\n\nproblem statement achhe se padhna hai\nage se bhi dekhna hai, piche se bhi dekhna hai\n'''\nfrom math import gcd,ceil\nfrom collections import defaultdict as dd\ndef lcm(a,b):\n\treturn (a*b)//gcd(a,b)\ndef inin():\n\treturn int(input())\ndef inar():\n\treturn list(map(int,input().split()))\ndef ar(element,size):\n\treturn [element for i in range(size)]\ndef digitsum(num):\n\tsu=0\n\twhile(num):\n\t\tsu+=num%10\n\t\tnum//=10\n\treturn su\n\nn=inin()\nstring=input()\ntemp=''\nprev=string[0]\ntemp+=prev\nfor i in string[0:n]:\n\tif i!=prev:\n\t\ttemp+=i\n\tprev=i \ncntr=0\ncurr=0\nfor i in temp:\n\tif i.isupper():\n\t\tcntr=max(cntr,curr)\n\t\tcurr=0\n\telse:\n\t\tcurr+=1\nprint(cntr)"}, {"source_code": "def ideal(s):\n if len(s) == 1 and s[0].islower():\n return len(s)\n t = 'A' + s\n a = \" \"\n count1 = 0\n for i in range(len(t)):\n if t[i].islower():\n a += t[i]\n else:\n count2 = 0\n b = sorted(a)\n for j in range(1, len(b)):\n if b[j] == b[j - 1]:\n count2 += 1\n if len(b) - count2 > count1:\n count1 = len(b) - count2\n a = \" \"\n return count1 - 1\n\n\nn = int(input())\nprint(ideal(input()))\n"}, {"source_code": "n = int(input())\nsymbols = input()\n\nm = 0\nfor i in range(len(symbols)):\n\tfor j in range(i, len(symbols)):\n\t\tif symbols[i:j].islower():\n\t\t\tif list(set(symbols[i:j]))==list(symbols[i:j]):\n\t\t\t\tm = max(j-i, m)\nprint(m)\n"}, {"source_code": "n=int(input())\ns=input()\na=[]\nb=[]\nmin=0\nfor i in range(n):\n if(97<=ord(s[i])<=122):\n if s[i] not in b:\n a.append(i+1)\n b.append(s[i])\n if(len(a)>min):\n min=len(a)\n else:\n if(len(a)>min):\n min=len(a)\n \n a.clear()\n b.clear()\n \n \nif(min==1):\n print(0)\nelse:\n print(min)\n "}, {"source_code": "n = int(input())\ns = input()\n\nif s.isupper() or (len(set(s)) == 1):\n print(0)\n exit()\n \ncnt = 0\nfor i in range(1,n):\n k = s[i-1]\n if s[i].islower():\n if k.islower() and s[i] != k:\n cnt +=1\n else:\n cnt = cnt\n else:\n cnt = cnt\n continue\nprint(cnt)\n"}, {"source_code": "def ideal(s):\n if all(x.islower() for x in s):\n return len(set(s))\n t = 'A' + s\n a = \" \"\n count1 = 0\n for i in range(len(t)):\n if t[i].islower():\n a += t[i]\n else:\n count2 = 0\n b = sorted(a)\n for j in range(1, len(b)):\n if b[j] == b[j - 1]:\n count2 += 1\n if len(b) - count2 > count1:\n count1 = len(b) - count2\n a = \" \"\n return count1 - 1\n\n\nn = int(input())\nprint(ideal(input()))\n"}, {"source_code": "n=int(input())\nd=input()\nlowers=[]\nposs={}\nfor i in range(0,len(d)):\n if (d[i]).islower():\n lowers.append(i)\n poss[i]=1\n else:\n poss[i]=0\nsetim=set()\nfor i in range(0,len(d)):\n for j in range(i+1,len(d)):\n f=True\n #print(str(i)+\" \"+str(j))\n for k in range(i,j+1):\n if poss[k]==0:\n f=False\n break\n if f:\n for k in range(i,j+1):\n setim.add(d[k])\n \n #print(\"buldu: \"+str(i)+\" \"+str(j))\nprint(len(setim))"}, {"source_code": "n=int(input())\ns=input()\nsub=[]\nans=0\nfor a in range(0,n):\n letter=s[a]\n if letter.islower()!=1:\n ans=max(ans,len(sub))\n sub=[]\n continue\n if letter not in sub:\n sub.append(letter)\nprint(ans)\n"}, {"source_code": "# Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon!\nn=int(input())\ns=input()\n\n\nd=\"\"\nk=\"\"\n\nstart=0\nend=0\n\nfor i in range(n-1):\n\t\n\tif(s[i]!=s[i+1]):\n\t\td=d+s[i]\n\t\t\nfor i in d:\n\tif(ord(i)<=90):\n\t\tk=k+' '\n\t\n\telse:\n\t k=k+i\n\t\t\nk=k.split()\nleng=0\n\nfor i in k:\n\tx=len(i)\n\tleng=max(x,leng)\n\t\t\n\t\nprint(leng)"}, {"source_code": "n = int(input())\ns = input()\nl = [0]*26\nl1 = [0]\nc = 0\nfor e in s:\n\tif e.islower() and l[ord(e)-97]==0:\n\t\tl[ord(e)-97]+=1\n\t\tc+=1\n\t\tif e==s[n-1]:\n\t\t\tl1.append(c)\n\telif ord(e)<97 or e==s[n-1]:\n\t\tl1.append(c)\n\t\tl = [0]*26\n\t\tc = 0\n\telif ord(e)>=97:\n\t\tpass\nprint(max(l1))\n"}], "src_uid": "567ce65f87d2fb922b0f7e0957fbada3"} {"source_code": "n,k=map(int,raw_input().split())\ndict={}\nrem=10**9+7\nfor i in range(1,n+1):\n dict[i]=[]\nfor i in range(1,n+1):\n j=i\n while(j>0):\n if i%j==0:\n dict[i].append(j)\n j-=1\narr=[[0 for i in range(n+1)] for j in range(k+1)]\nfor i in range(1,n+1):\n arr[1][i]=1\nfor i in range(2,k+1):\n for j in range(1,n+1):\n s=0\n for p in dict[j]:\n s=(s+arr[i-1][p])%rem\n arr[i][j]=s%rem\n\n\n#print arr\ns=0\nfor i in range(1,n+1):\n s=(s+arr[k][i])%rem\nprint s%(10**9+7)", "positive_code": [{"source_code": "I=lambda:list(map(int,input().split()))\nn,k=I()\ndp=[[0]*(n+1) for i in range(k+1)]\ndp[0][1]=1\nmm=10**9+7\nfor i in range(k):\n for j in range(1,n+1):\n for x in range(j,n+1,j):\n dp[i+1][x]=(dp[i+1][x]+dp[i][j])%mm\nans=0\nfor i in range(1,n+1):\n ans=(ans+dp[k][i])%mm\nprint(ans)"}, {"source_code": "# SHRi GANESHA author: Kunal Verma #\n\nimport os,sys\nfrom collections import Counter, deque\nfrom io import BytesIO, IOBase\n\n\n\ndef main():\n import math\n\n n, k = map(int, input().split())\n mod = 10 ** 9 + 7\n\n def divisors(n):\n i = 1\n x = []\n while i <= math.sqrt(n):\n if (n % i == 0):\n if (n // i == i):\n x.append(i)\n else:\n x.append(i)\n x.append(n // i)\n i = i + 1\n return x\n\n dp = [[0 for i in range(n)] for j in range(k)]\n x = [0 for i in range(n + 1)]\n for i in range(1, n + 1):\n x[i] = divisors(i)\n\n for i in range(n):\n dp[0][i] = 1\n for i in range(1,k):\n for j in range(n):\n for p in x[j + 1]:\n dp[i][j] = (dp[i][j] + dp[i - 1][p - 1]) % mod\n\n print(sum(dp[k-1])%mod)\n\n\n\n#Fast IO Region\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n,m=map(int,input().split())\na=[]\nmod=1000000007\nfor i in range(1,n+1):\n a.append(n//i)\nif(m==1):\n print(n)\nelse:\n for x in range(m-2):\n for i in range(1,n+1):\n j=i\n while(j<=n):\n j+=i\n if(j<=n):\n a[i-1]=(a[i-1]+a[j-1])%mod\n print(sum(a)%mod)"}, {"source_code": "def C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\nn,k=[int(x) for x in input().split()]\nans=0\nfor i in range(1,n+1):\n pp=1;\n i1=i;\n for j in range(2,2000):\n sch=0;\n while(i1%j==0):\n sch+=1\n i1//=j\n if (sch):\n pp*=C(sch+k-1,sch)\n pp%=1000000007\n ans+=pp\n ans%=1000000007\nprint(ans)"}, {"source_code": "def C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\nn,k=[int(x) for x in input().split()]\nans=0\nfor i in range(1,n+1):\n pp=1;\n i1=i;\n for j in range(2,i+1):\n sch=0;\n while(i1%j==0):\n sch+=1\n i1//=j\n if (sch):\n pp*=C(sch+k-1,sch)\n pp%=1000000007\n ans+=pp\n ans%=1000000007\nprint(ans)"}, {"source_code": "#import io, os\n#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nmod = 10**9 + 7\nn, k = map(int, input().split())\ncount = [1]*(n+1)\ncount[0] = 0\nfor i in range(k-1):\n\tnew = [0]*(n+1)\n\tfor j in range(1, n+1):\n\t\tt = count[j]\n\t\tfor k in range(j, n+1, j):\n\t\t\tnew[k] = (new[k]+t)%mod\n\tcount = new\nprint(sum(count)%mod)"}, {"source_code": "n,k = map(int,input().split())\nl = [int(n/i) for i in range(1,n+1)]\nmod = 1000000007\nif k == 1 :\n\tprint(n)\nelse :\n\tfor p in range(k-2) :\n\t\tfor i in range(1,n+1) :\n\t\t\tj=i\n\t\t\twhile(j<= n) :\n\t\t\t\tj += i\n\t\t\t\tif j <= n :\n\t\t\t\t\tl[i-1] = (l[i-1] + l[j-1])%mod\n\n\n\n\tprint(sum(l)%mod)\n\n\n\n\n\n"}, {"source_code": "import math\n\ndef primeDec(n):\n res = []\n p = 2\n\n while p * p <= n:\n if n % p == 0:\n count = 0\n while n % p == 0:\n n //= p\n count += 1\n res.append((p, count))\n p += 1\n if n > 1:\n res.append((n, 1))\n\n return res\n\ndef comb(k, n):\n res = 1\n for i in range(n - k + 1, n + 1):\n res *= i\n for i in range(1, k + 1):\n res //= i\n return res\n\ndef ev(n, k):\n d = primeDec(n)\n res = 1\n\n for p, i in d:\n #print(k - 1, k + i - 1)\n res = (res * (comb(i, k + i - 1) % N)) % N\n #print(n, k, res)\n return res\n\nN = 10 ** 9 + 7\nn, k = map(int, input().split())\nd = primeDec(n)\nres = 0\n\nfor i in range(1, n + 1):\n res = (res + ev(i, k)) % N\n\nprint(res)\n"}, {"source_code": "R = lambda: map(int, input().split())\nn, k = R()\ndp = [[0 for j in range(n + 1)] for i in range(k + 1)]\nfor l in range(1, n + 1):\n dp[1][l] = 1\nfor i in range(1, k):\n for p in range(1, n + 1):\n np = p\n while np <= n:\n dp[i + 1][np] = (dp[i + 1][np] + dp[i][p]) % 1000000007\n np += p\nprint(sum(dp[k][p] for p in range(1, n + 1)) % 1000000007)"}, {"source_code": "n, k = map(int, input().split())\nconst = 10 ** 9 + 7\nif n == 2000 and k == 2000:\n\tprint(585712681)\n\texit()\ndp = [[0] * (max(n, k) + 1) for i in range(max(n, k) + 1)]\nfor i in range(1, n + 1):\n\tdp[1][i] = 1\nfor i in range(2, k + 1):\n\tfor j in range(1, n + 1):\n\t\tfor f in range(j, n + 1, j):\n\t\t\tdp[i][f] += dp[i - 1][j]\ns = 0\nfor i in range(1, n + 1):\n\ts += dp[k][i]\nprint(s % const)\n"}, {"source_code": "n, k = [int(i) for i in input().split()]\ndp = [[0]*(n + 1) for i in range(k + 1)]\ndp[0][1] = 1\n\nMOD = 10**9 + 7\nfor i in range(k):\n for j in range(1, n+1):\n for x in range(j ,n+1, j):\n dp[i+1][x] = (dp[i+1][x] + dp[i][j])%MOD\n \nans = 0\nfor i in range(1, n+1):\n ans = (ans + dp[k][i])%MOD\nprint(ans)\n "}, {"source_code": "n, k = map(int, input().split())\nost = 1000000007\n\na_num = []\n\nfor i in range(1, 2001):\n x = []\n for j in range(1, i + 1):\n if i % j == 0:\n x.append(j)\n a_num.append(x)\n\ndp = []\n\nfor i in range(0, k + 1):\n x = []\n for j in range(0, n + 1):\n x.append(0)\n dp.append(x)\n\nfor i in range(1, n + 1):\n dp[1][i] = 1\n\nfor i in range(1, k + 1):\n for j in range(1, n + 1):\n for u in a_num[j - 1]:\n dp[i][j] += dp[i - 1][u]\n if dp[i][j] >= ost:\n dp[i][j] -= ost\n\nans = 0\n\nfor i in range(1, n + 1):\n ans += dp[k][i]\n if ans >= ost:\n ans -= ost\n\nprint(ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\nn, k = map(int, input().split())\nMOD = 10 ** 9 + 7\ndp = [0] * (n + 1)\ndp[1] = 1\nfor i in range(k):\n tmp = dp.copy()\n dp = [0] * (n + 1)\n for j in range(1, n + 1):\n if tmp[j]:\n for l in range(1, n + 1):\n if j * l <= n:\n dp[j * l] += tmp[j]\n dp[j * l] %= MOD\n else:\n break\n\nprint(sum(dp) % MOD)\n"}, {"source_code": "import math\nn, k = map(int, input().split())\ndp = [[1 for _ in range(k+1)] for _ in range(n+1)]\nfor i in range(1, n+1):\n f = set((1, i))\n for m in range(2, int(math.sqrt(i))+1):\n if i%m==0:\n f.add(m)\n if i/m != i:\n f.add(i//m)\n f = list(f)\n for j in range(2, k+1):\n dp[i][j] = 0\n for x in f:\n dp[i][j] = (dp[i][j] + dp[x][j-1])%1000000007\nans = 0\nfor i in range(1, n+1):\n ans += dp[i][k]\n ans = ans%1000000007\nprint(ans%1000000007)\n"}, {"source_code": "n, m = map(int, input().split())\ndp = [[0]*(n+1) for i in range(m+1)]\ndp[0][1] = 1\nfor i in range(1, m+1):\n for j in range(1, n+1):\n for k in range(j, n+1, j):\n dp[i][k] = (dp[i][k] + dp[i-1][j]) % 1000000007\n\nans = 0\nfor i in range(1, n+1):\n ans = (ans + dp[m][i]) % 1000000007\n\nprint(ans)\n"}, {"source_code": "mod = 10**9 + 7\nn, t = map(int, input().split())\ndp = [[0 for i in range(2016)] for j in range(2016)]\ndp[0][1] = 1\nfor i in range(1, t+1):\n for j in range(1, n+1):\n for k in range(j, n+1, j):\n dp[i][k] += dp[i-1][j]\n dp[i][k] %= mod\nans = 0\nfor i in range(1, n+1):\n ans += (dp[t][i])%mod\nprint(ans%mod)"}, {"source_code": "import sys\nreader = (line.rstrip() for line in sys.stdin)\ninput = reader.__next__\n\ndivs = {}\nn, k = map(int, input().split())\nfor i in range(1, n + 1) :\n\tfor j in range(1, i + 1) :\n\t\tif(i % j == 0) :\n\t\t\tif i not in divs :\n\t\t\t\tdivs[i] = [j]\n\t\t\telse :\n\t\t\t\tdivs[i].append(j)\nans = 0\ndp = []\nMOD = 10**9 + 7\nfor _ in range(k + 1) :\n\tdp.append([0] * (n + 1))\n\ndp[0][1] = 1\nfor i in range(1, k + 1) :\n\tfor j in range(1, n + 1) :\n\t\tfor el in divs[j] :\n\t\t\tdp[i][j] += dp[i - 1][el]\n\t\t\tdp[i][j] %= MOD\n\t\tif i == k :\n\t\t\tans += dp[i][j]\n\t\t\tans %= MOD\n\nprint(ans % MOD)"}, {"source_code": "mod = 1000000007\nn,k = [int(x)for x in input().split()]\ndp = [[0 for i in range(n+1)]for j in range(k+1)]\n\nfor i in range(1,n+1):\n\tdp[1][i] = 1\n\nfor l in range(2,k+1):\n\tfor i in range(1,n+1):\n\t\tfor j in range(i,n+1,i):\n\t\t\tdp[l][j] += dp[l-1][i]\n\t\t\tif(dp[l][j] >= mod):\n\t\t\t\tdp[l][j] -= mod\nsum = 0\nfor i in range(1,n+1):\n\tsum += dp[k][i]\n\tif sum >= mod:\n\t\tsum -= mod\nprint(sum)"}, {"source_code": "import math\nn, k = [*map(int, input().split())]\n\nprime = [1]\nf = [False] * 2000\nfor i in range(2, 2000):\n if f[i]:\n continue\n f[i] = True\n prime.append(i)\n j = 1\n while i * j < 2000:\n f[i * j] = True\n j += 1\n\nf = [[0] * (n + 1) if i != 1 else [1] * (n + 1) for i in range(k + 1)]\nf[1][0] = 0\nfor i in range(1, n + 1):\n j = 1\n div = []\n while j <= i:\n if not (i % j):\n div.append(j)\n j += 1\n for j in range(2, k + 1):\n for l in div:\n f[j][i] += f[j - 1][i // l]\n f[j][i] %= 10 ** 9 + 7\nans = 0\nfor i in f[k]:\n ans += i\n ans %= 10 ** 9 + 7\nprint(ans)\n"}, {"source_code": "mod = 10**9+7\nimport math\n\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p): \n prime[i] = False\n p += 1\n return prime\n\ndef factor(n):\n # limit = int(math.sqrt(n)+1)\n fac={i:0 for i in range(n+1)}\n i=2\n while(n>1):\n if not prime[i]:\n i+=1\n continue\n if n%i==0:\n fac[i]+=1\n n=n//i\n else:\n i+=1\n # print(n,' ')\n return {i:fac[i] for i in fac if fac[i]!=0}\n\n\n\n\n\ndef ncr(n, r, p=mod):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\n\nn,k = list(map(int,input().split()))\n\nprime = sieve(n)\n# print([i for i in range(len(prime)) if prime[i]])\n# print(factor(5))\n\nfinal = 0\nfor num in range(2,n+1):\n fac = factor(num)\n # print('n = ',num)\n ans = 1\n for a in fac:\n part = ncr(fac[a]+k-1,k-1)\n ans = (ans * part)%mod\n # print(part,a,fac[a])\n final = (ans+final)%mod\nprint((final+1)%mod)"}, {"source_code": "import math\na=list(map(int,input().split()))\nif(a[1]>=12):\n x=a[1]\n a[1]=12\nelse:\n x=a[1]\ndp=[[0 for i in range(a[1]+1)]for j in range(a[0]+1)]\nfor i in range(1,a[0]+1):\n dp[i][0]=1\nfor i in range(1,a[0]//2+1):\n dp[i][1]=(a[0]//i-1)\n\nfor j in range(2,a[1]+1):\n for i in range(1,(a[0]//(2**j))+1):\n l=2*i\n while(dp[l][j-1]!=0):\n dp[i][j]+=dp[l][j-1]\n l=l+i\n \n\ncnt=a[0]\nmod=1000000007\narr=[0 for i in range(a[1]+1)]\nfor i in range(1,a[1]):\n for j in range(1,a[0]//2+1):\n arr[i]+=dp[j][i]\nans=1\nfor i in range(1,a[1]-1):\n ans1=1\n for q in range(1,i+1):\n ans1=ans1*(x-q)\n ans2=1\n for j in range(1,i+1):\n ans2=ans2*j\n ans=ans1//ans2\n cnt=cnt%mod+(arr[i]*ans)%mod\n cnt=cnt%mod\n\ncnt=cnt%mod+arr[a[1]-1]%mod\nprint(cnt%mod)"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/414/B\n\nn,k = map(int,input().split())\nn += 1\nk += 1\ndp = [[0] * n for _ in range(13)]\ns = 0\nM = 1000000007\nf = [1]\nfor i in range(1,4500):\n\tf.append(f[-1] * i % M)\ndef C(n, k):\n\tif k>n:\n\t\treturn 0\n\treturn f[n] * pow(f[k] * f[n - k] %M , M - 2, M) % M\n\nfor i in range(1, 12):\n\tfor j in range(1, n):\n\t\tif i == 1:\n\t\t\tdp[i][j] = 1\n\t\tfor t in range(j * 2, n, j):\n\t\t\tdp[i + 1][t] = (dp[i + 1][t] + dp[i][j]) % M\n\t\ts = (s + C(k - 2, i - 1) * dp[i][j] % M) % M\n\n\nprint(s)"}, {"source_code": "#codeforces.com\n#414B\n#Mashmokh and ACM\ndef C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\nn,k=[int(x) for x in input().split()]\nans=0\nfor i in range(1,n+1):\n pp=1;\n i1=i;\n for j in range(2,i+1):\n sch=0;\n while(i1%j==0):\n sch+=1\n i1//=j\n if (sch):\n pp*=C(sch+k-1,sch)\n ans+=pp\n ans%=1000000007\nprint(ans)\n"}, {"source_code": "\n\ndef exp(x, p):\n ct = 0\n while x%p==0:\n x //= p\n ct += 1\n return ct\n\ndef magic(n, k):\n curr = 1\n for i in range(k+1, n+1):\n curr *= i\n for i in range(n-k, 0, -1):\n curr //= i\n return int(curr)%(10**9+7)\n\ndef prime(x):\n for i in range(2, int(x**0.5)+1):\n if x%i==0:\n return False\n return True\n\nprimes = []\nfor i in range(2, 2000):\n if prime(i):\n primes.append(i)\n \ndef okluving(a, b):\n okluv = []\n for i in primes:\n if a % i == 0:\n okluv.append(exp(a, i))\n conquer = 1\n for i in okluv:\n conquer *= magic(i + b-1, b-1)\n return conquer%(10**9+7)\n\nprimes = []\nfor i in range(2, 2000):\n if prime(i):\n primes.append(i)\nokluv = []\nsumx = 0\na, b = map(int, input().split(' '))\nfor i in range(1, a+1):\n sumx += okluving(i, b)\nprint(sumx % (10**9+7))"}, {"source_code": "def C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\nn,k=[int(x) for x in input().split()]\nans=0\nfor i in range(1,n+1):\n pp=1;\n i1=i;\n for j in range(2,2000):\n sch=0;\n while(i1%j==0):\n sch+=1\n i1//=j\n if (sch):\n pp*=C(sch+k-1,sch)\n pp%=1000000007\n ans+=pp\n ans%=1000000007\nprint(ans)"}, {"source_code": "def C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\nn,k=[int(x) for x in input().split()]\nans=0\nfor i in range(1,n+1):\n pp=1;\n i1=i;\n for j in range(2,i+1):\n sch=0;\n while(i1%j==0):\n sch+=1\n i1//=j\n if (sch):\n pp*=C(sch+k-1,sch)\n ans+=pp\n ans%=1000000007\nprint(ans)\n"}, {"source_code": "\n\nn,k = map(int,input().split())\nn += 1\nk += 1\ndp = [ [0]*n for _ in range(13)] \ns = 0\nM = 1000000007\nf = [1]\nfor i in range(1,4500):\n\tf.append(f[-1]*i%M)\ndef C(n,k):\n\tif k>n:\n\t\treturn 0\n\treturn f[n]*pow(f[k]*f[n-k]%M,M-2,M)%M\nfor i in range(1,12):\n\tfor j in range(1,n):\n\t\tif i==1:\n\t\t\tdp[i][j] = 1\n\t\tfor t in range(j*2,n,j):\n\t\t\tdp[i+1][t] = (dp[i+1][t]+dp[i][j])%M\n\t\ts = (s+C(k-2,i-1)*dp[i][j]%M)%M\n# for row in dp:\n# \tprint(row)\nprint(s)\n# C:\\Users\\Usuario\\HOME2\\Programacion\\ACM"}, {"source_code": "n,k = map(int,input().split())\nn += 1\nk += 1\ndp = [[0] * n for _ in range(13)]\ns = 0\nM = 1000000007\nf = [1]\nfor i in range(1,4500):\n\tf.append(f[-1] * i % M)\ndef C(n, k):\n\tif k>n:\n\t\treturn 0\n\treturn f[n] * pow(f[k] * f[n - k] %M , M - 2, M) % M\n\nfor i in range(1, 12):\n\tfor j in range(1, n):\n\t\tif i == 1:\n\t\t\tdp[i][j] = 1\n\t\tfor t in range(j * 2, n, j):\n\t\t\tdp[i + 1][t] = (dp[i + 1][t] + dp[i][j]) % M\n\t\ts = (s + C(k - 2, i - 1) * dp[i][j] % M) % M\n\n\nprint(s)"}, {"source_code": "import math\n\n\ndef C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\n\ndef multiples(limit):\n tmp = 1\n m = limit\n for j in range(2, limit + 1):\n no_multiples = 0\n while m % j == 0:\n no_multiples += 1\n m //= j\n if no_multiples:\n tmp *= C(no_multiples + k - 1, no_multiples)\n\n return tmp\n\n\nn, k = [int(x) for x in input().split(' ')]\nmodulo = 1000000007\ntotal = 0\nfor i in range(1, n+1):\n total += multiples(i)\n\nprint(total % modulo)\n"}, {"source_code": "import math\n\n\n# def C(a, b):\n# f = math.factorial\n# try:\n# return f(a) // f(b) // f(a-b)\n# except ValueError:\n# return 1\n\n\ndef C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\ndef multiples(limit):\n tmp = 1\n m = limit\n for j in range(2, limit + 1):\n no_multiples = 0\n while m % j == 0:\n no_multiples += 1\n m //= j\n if no_multiples:\n tmp *= C(no_multiples + k - 1, no_multiples)\n\n return tmp\n\n\nn, k = [int(x) for x in input().split(' ')]\nmodulo = 1000000007\ntotal = 0\nfor i in range(1, n+1):\n total += multiples(i)\n\nprint(total % modulo)\n"}, {"source_code": "def main():\n mod = 1000000007\n n, k = map(int, input().split())\n mod = 1000000007\n sm, l = [1], [1] * k\n for _ in range(12):\n x = 0\n for i, y in enumerate(l):\n x += y\n l[i] = x % mod\n sm.append(l[-1])\n n += 1\n res, sieve = [1] * n, [0] * n\n for p in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,\n 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,\n 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347,\n 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,\n 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607,\n 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743,\n 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883,\n 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031,\n 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151,\n 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279,\n 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,\n 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523,\n 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627,\n 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777,\n 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907,\n 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999):\n if p >= n:\n break\n pp = p\n while pp < n:\n for i in range(pp, n, pp):\n sieve[i] += 1\n pp *= p\n for i in range(p, n, p):\n res[i] = res[i] * sm[sieve[i]] % mod\n for i in range(p, n, p):\n sieve[i] = 0\n print((sum(res) - 1) % mod)\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "Mod=10**9+7\nn,k=map(int,input().split())\ndp=[[0]*(n+1) for i in range(k+1)]\nl=[[] for _ in range(n+1)]\nfor i in range(1,n+1):\n dp[1][i]=1\n for j in range(1,i+1):\n if i%j==0:\n l[i].append(j)\nfor j in range(2,k+1):\n for i in range(1,n+1):\n for le in range(len(l[i])):\n dp[j][i]+=dp[j-1][l[i][le]]\n dp[j][i]%=Mod\nans=0\nfor i in range(1,n+1):\n ans+=dp[k][i]\n ans%=Mod\nprint(ans)"}, {"source_code": "from collections import *\nn,k=map(int,raw_input().split())\nn+=1\nr=[defaultdict(int) for i in range(n)]\n\nfor i in range(2,n):\n if r[i] == {}:\n q=i\n while q < n:\n for j in range(q,n,q): r[j][i]+=1\n q*=i\n\nR=-1\nc=[1]*11\n\nfor i in range(1,11): c[i] = c[i-1]*(k+i-1)/i\n\nfor e in r:\n p=1\n for i in e.values(): p*=c[i]\n R+=p\nprint R % 1000000007"}, {"source_code": "n,k=map(int,input().split())\ndp=[[1 for i in range(k+2)] for j in range(n+2)]\nfor i in range(n+2):\n dp[i][0]=0\nmod=1000000007 \nfor i in range(n,0,-1):\n for j in range(2,k+1):\n for l in range(i,n+1,i):\n dp[i][j]=(dp[l][j-1]+dp[i][j])%mod\nans=0\nfor i in range(1,n+1):\n ans=(ans+dp[i][k]-dp[i][k-1])%mod\nprint(ans%mod)\n"}, {"source_code": "n, k = map(int, raw_input().split())\nd = 1000000007\n\nn += 1\nr = [{} for i in range(n)] # multiples\nfor i in range(2, n):\n if r[i] == {}:\n for j in range(i, n, i): r[j][i] = 1\n q = i * i\n while q < n:\n for j in range(q, n, q): r[j][i] += 1\n q *= i\n\nc = [1, k] + [0] * 9 # binomial\nk -= 1\nfor i in range(2, 11): c[i] = (c[i - 1] * (k + i)) / i\n\ns = -1\nfor q in r:\n p = 1\n for i in q.values(): p = p * c[i]\n s += p\n\nprint s % d"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,k = LI()\n t = [0] * n\n t[0] = 1\n\n for _ in range(k):\n u = [0] * n\n for i in range(n):\n b = t[i] % mod\n for j in range(i,n,i+1):\n u[j] += b\n t = u\n\n return sum(t) % mod\n\n\nprint(main())\n\n\n"}, {"source_code": "def nCk(n,k):\n v=1\n for i in range(n-k+1,n+1):\n v*=i\n for i in range (1,k+1):\n v/=i\n return v\n\ndef prime_factor(n):\n pf = []\n f=2\n while f**2<=n:\n cnt=0\n while n%f==0:\n n/=f \n cnt+=1\n if cnt>0: \n pf.append((f,cnt))\n f+=1\n if n>1:\n pf.append((n,1))\n return pf\n\nl=lambda:map(int,raw_input().split())\nn,k=l()\nans=0\nfor i in range(1,n+1):\n t=1\n for f,cnt in prime_factor(i):\n t*=nCk(cnt+k-1,cnt)\n t%=1000000007\n ans+=t\n ans%=1000000007\nprint ans\n\n'''\n#overtime version \nl=lambda:map(int,raw_input().split())\nn,k=l()\nmodn=1000000007\nN=2000+10\ndp=[[0 for i in range(N)] for j in range(N)]\ndp[1]=[0]+[1]*(N-1)\nfor i in range(2,k+1):\n for j in range(1,n+1):\n x=1\n while x*x<=j:\n if j%x==0: \n dp[i][j]+=dp[i-1][x]\n if x<>j/x:\n dp[i][j]+=dp[i-1][j/x]\n dp[i][j]%=modn\n x+=1 \nprint sum(dp[k][1:n+1])%modn \n'''\n'''\n6 4\n39\n1: 1111\n2: 1112,1122,1222,2222\n3: 1113,1133,1333,3333\n4: 1114,1124,1144,1224,1244,1444,2224,2244,2444,4444\n5: 1115,1155,1555,5555\n6: 1116,1126,1136,1166,1226,1266,1336,1366,1666,2226,2266,2666,3336,3366,3666,6666\n'''"}, {"source_code": "def cf(k, m):\n # num of solutions to\n # x_1 + x_2 + ... + x_m = k, x_i \\in [0, 1] = C(k+m-1, k-1)\n # so \\prod_i p_j^{x_j_i} = p_j^{e_j},\n # and \\prod_j \\prod_i p_j^{x_j_i} = n\n c = 1\n # Do C(k+m-1, m) since m < 11 (k < 2^11)\n for i in range(1, m+1):\n c *= k+m-i\n c //= i\n return c\n\nN, K = map(int, raw_input().strip().split())\nM = 1000000007\nans = 1\nfor n in range(2, N+1):\n cp = 1 # ways to end at n, n = \\prod_j p_j^e_j\n t = n\n for j in range(2, n+1):\n ej = 0\n while t%j==0:\n t//= j\n ej += 1\n if ej > 0:\n cp *= cf(K, ej)\n cp %= M\n ans += cp\n ans %= M\nprint ans\n\n\n"}, {"source_code": "mod=10**9+7\n[n ,k]=list(map(int, input().split()))\ndp=[[0 for _ in range(n+1)] for _ in range(k+1)]\nfor last in range(1, n+1):\n dp[1][last]=1\nfor l in range(2, k+1):\n for i in range(1, n+1):\n for j in range(i, n+1, i):\n dp[l][j]=(dp[l][j]+dp[l-1][i])%mod\nprint(sum(dp[k])%mod)"}, {"source_code": "import sys\ninput=sys.stdin.readline\nn,k=map(int,input().split())\nal=[1 for i in range(n+1)]\n\nfor i in range(k-1):\n for j in range(1,n+1):\n t=2*j\n while(t<=n):\n al[j]+=al[t]\n t=t+j \nprint(sum(al[i] for i in range(1,n+1))%(10**9+7)) \n"}, {"source_code": "import sys\nimport math as mt\ninput=sys.stdin.buffer.readline \nt=1\nmod=10**9+7\n\ndef getd() : \n l=[] \n # Note that this loop runs till square root \n l.append([0])\n l.append([1])\n for n in range(2,20001):\n i = 1\n l1=[]\n while i <= mt.sqrt(n): \n \n if (n % i == 0) : \n \n # If divisors are equal, print only one \n if (n // i == i) : \n l1.append(i)\n \n else : \n l1.append(i)\n l1.append(n//i)\n i = i + 1\n l.append(l1) \n return l \nl=getd() \n#print(l[:7])\nfor __ in range(t):\n n,k=map(int,input().split())\n dp=[[0 for j in range(n+1)] for i in range(k+1)]\n for j in range(1,n+1):\n dp[1][j]=1\n for i in range(1,k+1):\n dp[i][1]=1\n for i in range(2,k+1):\n for j in range(2,n+1):\n for j1 in l[j]:\n dp[i][j]=(dp[i][j]%mod+dp[i-1][j1]%mod)%mod\n suma=0\n for j in range(1,n+1):\n suma=(suma+dp[k][j])%mod\n #suma%mod\n print(suma%mod) "}, {"source_code": "from __future__ import print_function\nimport sys\nimport collections\nimport math\nimport functools\nimport itertools\nimport bisect\nimport operator\nimport heapq\nimport random\ntrue=True\nfalse=False\nnull=None\nSLOW=True\ntry:\n range=xrange\nexcept:\n ignored=1\ndef fast():\n global SLOW\n SLOW=False\ndef compute(val, func): return func(val)\ndef seq(lo,hi,step=1): \n return range(lo,hi+1,step)\ndef sround(val,nd):\n return '{0:.{1}f}'.format(val,nd)\ndef ceil(a,b):\n ans=a//b\n if a%b!=0: ans+=1\n return ans\ndef e1e(d,e): return d*(10**e)\nmod=e1e(1,9)+7\ntry:\n memoi=functools.lru_cache(None)\nexcept:\n class memoize(dict):\n def __init__(self,f):\n self.f=f\n def __call__(self,*args):\n return self[args]\n def __missing__(self,key):\n ans=self[key]=self.f(*key)\n return ans\n memoi=memoize\nclass ndarray(list):\n def __init__(self,defval,sizes):\n self.sizes=sizes\n self.dimension=len(sizes)\n self.pm=pm=list(sizes)\n pm.append(1)\n for ii in reversed(range(self.dimension)): pm[ii]*=pm[ii+1]\n list.__init__(self,[defval]*pm[0])\n def ___i1d___(self,ixs):\n if len(ixs)!=self.dimension: raise LookupError('Dimension must be {}.'.format(self.dimension))\n ans=0\n for ii in range(self.dimension):\n ix=ixs[ii]\n if ix>=self.sizes[ii]:\n raise IndexError('Index[{}]={} >= Len[{}]={}.'.format(ii,ix,ii,self.sizes[ii]))\n ans+=ix*self.pm[ii+1]\n return ans\n def __getitem__(self,ixs):\n ixs=self.___i1d___(ixs)\n return list.__getitem__(self,ixs)\n def __setitem__(self,ixs,val):\n ixs=self.___i1d___(ixs)\n list.__setitem__(self,ixs,val)\n def _str_(self,dim0=0,ofs=0):\n lft=\" \"*dim0\n if dim0+1==self.dimension: return lft+str(list.__getitem__(self,slice(ofs,ofs+self.sizes[dim0])))\n ans=[]\n for ii in range(self.sizes[dim0]):\n ans.append(self._str_(dim0+1,ofs))\n ofs+=self.pm[dim0+1]\n ans=\"{0}[\\n{1}\\n{0}]\".format(lft,\",\\n\".join(ans))\n return ans\n def __str__(self):\n return self._str_()\ndef arrays(defval,*sizes):\n if len(sizes)==1: return [defval]*sizes[0]\n return ndarray(defval,sizes)\ndef perr(*args,**kwargs): \n if SLOW:\n print(*args,file=sys.stderr,**kwargs)\ndef line():\n ln=sys.stdin.readline().strip()\n #perr(ln)\n if ln=='': sys.exit()\n return ln\ndef lines(n): return [line() for i in range(n)]\ndef split(ln=None): return (ln or line()).split()\ndef num(str=None):\n str=str or line()\n return float(str) if '.' in str else int(str)\ndef nums(o=None):\n if o is not None:\n if isinstance(o, int): o=lines(o)\n elif isinstance(o, str): o=split(o)\n return list(map(num, o or split()))\ndef loop(f,n=0):\n for tcid in range(n or 99999999): f(tcid+1)\n\"\"\"\ne1e(d,e) mod arrays(defv,*sz)\nceil(a,b) sround(val,nd) true false null @memoi\nnum(?) nums(?) split(?) lines(n) line()\nperr(print) seq() loop(f(tcid),0) compute(v,f) fast()\n\"\"\"\n#\ndef mainloop(tcid): #\n ignored=1 #\n n,k=nums()\n dp=arrays(1,n+1)\n dp[0]=null\n for _ in range(k-1):\n for ii in seq(1,n):\n for jj in seq(ii+ii,n,ii):\n dp[ii]=(dp[ii]+dp[jj])%mod\n ans=0\n for ii in seq(1,n):\n ans=(ans+dp[ii])%mod\n print(ans)\ntcmax=0\nloop(mainloop,tcmax) #\n#"}, {"source_code": "#Author: squiggly_lines\n#Date: 30/04/2014\n#Problem: 414B\nimport math\ndef main():\n n,k = map(int, raw_input().split())\n print B(n,k) % (10**9+7)\n \ndef B(n,k):\n s = 0\n for i in xrange(1,n+1):\n s += A(i,k)\n\n return s\n\ndef A(n,k): #Sometimes I forget that code doesn't have to be translated directly ...\n if n == 1:\n return 1\n pf = prime_factor(n)\n\n prod = 1\n for (p, exp) in pf:\n prod *= binom(exp+k-1, k-1)\n\n return prod\n\ndef prime_factor(n):\n pf = []\n d = 2\n while d**2 <= n:\n exp = 0\n while n % d == 0:\n n /= d \n exp += 1\n if exp > 0: \n pf.append((d,exp)) #The prime doesn't actually matter, but whatever\n d += 1\n if n > 1:\n pf.append((n,1))\n return pf\n\ndef binom(n,k): #Because importing itertools or scipy seems overkill\n return reduce(mult, xrange(k+1,n+1)) / reduce(mult, xrange(1,n-k+1))\n\ndef mult(x,y): #To compensate for not knowing Python\n return x*y\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "from __future__ import print_function\nimport sys\nimport collections\nimport math\nimport functools\nimport itertools\nimport bisect\nimport operator\nimport heapq\nimport random\ntrue=True\nfalse=False\nnull=None\nSLOW=True\ntry:\n range=xrange\nexcept:\n ignored=1\ndef fast():\n global SLOW\n SLOW=False\ndef compute(val, func): return func(val)\ndef seq(lo,hi,step=1): \n return range(lo,hi+1,step)\ndef sround(val,nd):\n return '{0:.{1}f}'.format(val,nd)\ndef ceil(a,b):\n ans=a//b\n if a%b!=0: ans+=1\n return ans\ndef e1e(d,e): return d*(10**e)\nmod=e1e(1,9)+7\ntry:\n memoi=functools.lru_cache(None)\nexcept:\n class memoize(dict):\n def __init__(self,f):\n self.f=f\n def __call__(self,*args):\n return self[args]\n def __missing__(self,key):\n ans=self[key]=self.f(*key)\n return ans\n memoi=memoize\nclass ndarray(list):\n def __init__(self,defval,sizes):\n self.sizes=sizes\n self.dimension=len(sizes)\n self.pm=pm=list(sizes)\n pm.append(1)\n for ii in reversed(range(self.dimension)): pm[ii]*=pm[ii+1]\n list.__init__(self,[defval]*pm[0])\n def ___i1d___(self,ixs):\n if len(ixs)!=self.dimension: raise LookupError('Dimension must be {}.'.format(self.dimension))\n ans=0\n for ii in range(self.dimension):\n ix=ixs[ii]\n if ix>=self.sizes[ii]:\n raise IndexError('Index[{}]={} >= Len[{}]={}.'.format(ii,ix,ii,self.sizes[ii]))\n ans+=ix*self.pm[ii+1]\n return ans\n def __getitem__(self,ixs):\n ixs=self.___i1d___(ixs)\n return list.__getitem__(self,ixs)\n def __setitem__(self,ixs,val):\n ixs=self.___i1d___(ixs)\n list.__setitem__(self,ixs,val)\n def _str_(self,dim0=0,ofs=0):\n lft=\" \"*dim0\n if dim0+1==self.dimension: return lft+str(list.__getitem__(self,slice(ofs,ofs+self.sizes[dim0])))\n ans=[]\n for ii in range(self.sizes[dim0]):\n ans.append(self._str_(dim0+1,ofs))\n ofs+=self.pm[dim0+1]\n ans=\"{0}[\\n{1}\\n{0}]\".format(lft,\",\\n\".join(ans))\n return ans\n def __str__(self):\n return self._str_()\ndef arrays(defval,*sizes):\n if len(sizes)==1: return [defval]*sizes[0]\n return ndarray(defval,sizes)\ndef perr(*args,**kwargs): \n if SLOW:\n print(*args,file=sys.stderr,**kwargs)\ndef line():\n ln=sys.stdin.readline().strip()\n #perr(ln)\n if ln=='': sys.exit()\n return ln\ndef lines(n): return [line() for i in range(n)]\ndef split(ln=None): return (ln or line()).split()\ndef num(str=None):\n str=str or line()\n return float(str) if '.' in str else int(str)\ndef nums(o=None):\n if o is not None:\n if isinstance(o, int): o=lines(o)\n elif isinstance(o, str): o=split(o)\n return list(map(num, o or split()))\ndef loop(f,n=0):\n for tcid in range(n or 99999999): f(tcid+1)\n\"\"\"\ne1e(d,e) mod arrays(defv,*sz)\nceil(a,b) sround(val,nd) true false null @memoi\nnum(?) nums(?) split(?) lines(n) line()\nperr(print) seq() loop(f(tcid),0) compute(v,f) fast()\n\"\"\"\n#\ndef mainloop(tcid): #\n ignored=1 #\n n,k=nums()\n dp=arrays(1,n+1)\n dp[0]=null\n for _ in range(k-1):\n for ii in seq(1,n):\n for jj in seq(ii+ii,n,ii):\n dp[ii]=(dp[ii]+dp[jj])%mod\n ans=0\n for ii in seq(1,n):\n ans=(ans+dp[ii])%mod\n print(ans)\ntcmax=0\nloop(mainloop,tcmax) #\n#"}, {"source_code": "mod = 10**9+7\nn, k = map(int, input().strip().split())\ndp = [[0 for i in range(n)] for i in range(k)]\nfor i in range(n):\n dp[0][i] = 1\n\nfor i in range(k-1):\n for j in range(n):\n for p in range(j+1, n+1, j+1):\n dp[i+1][p-1] = (dp[i+1][p-1] + dp[i][j])%mod\n# print('----')\n# for i in dp:\n# print(i)\nprint(sum(dp[-1])%mod)\n\n"}, {"source_code": "n, k = map(int, input().split())\nmod = 10**9 + 7\n\ndp = []\n\n# dp[i][j] - \u043e\u0442\u0432\u0435\u0442 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b = j \u0438 k = i\n\nfor i in range(k + 1):\n dp.append([0] * (n + 1))\n\ndp[0][1] = 1\n\nfor i in range(k):\n for j in range(1, n + 1):\n cx = j\n while cx <= n:\n dp[i + 1][cx] = (dp[i + 1][cx] + dp[i][j]) % mod\n cx += j\n\n\nans = 0\nfor j in range(1, n + 1):\n ans = (ans + dp[k][j]) % mod\n\nprint(ans)\n"}, {"source_code": "\"Template made by : https://codeforces.com/profile/c1729 , github repo : https://github.com/cheran-senthil/PyRival\"\nfrom __future__ import division, print_function\nimport bisect\nimport math\nimport itertools\nimport sys\nfrom atexit import register\n\nif sys.version_info[0] < 3:\n from io import BytesIO as stream\nelse:\n from io import StringIO as stream\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\ndef main():\n n,k=map(int,input().split())\n dp=[[0]*2020 for i in range(0,2020)]\n dp[0][1]=1\n m=10**9+7\n for i in range(1,k+1):\n for j in range(1,n+1):\n for t in range(j,n+1,j):\n dp[i][t]=(dp[i][t]%m + dp[i-1][j]%m)%m\n ans=0\n for i in range(1,n+1):\n ans=(ans%m+dp[k][i]%m)%m\n print(ans)\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()"}, {"source_code": "n,k=map(int,input().split())\nm=10**9+7\ndp=[[1 if i==1 else 0 for i in range(k+1)]for j in range(n+1)]\nfor j in range(1,k):\n for i in range(1,n+1):\n for ii in range(i,n+1,i):\n dp[ii][j+1]=(dp[ii][j+1]%m+dp[i][j]%m)%m\nsums=0\n#for i in range(1,n+1):\n# sums=(sums%m+dp[i][k]%m)%m\nans = sum([ dp[i][k] for i in range(1, n + 1) ]) % m\nprint(ans%m)"}, {"source_code": "n,k=map(int,raw_input().split())\ndict={}\nrem=10**9 +7\n'''for i in range(1,n+1):\n dict[i]=[]\nfor i in range(1,n+1):\n j=i\n while(j>0):\n if i%j==0:\n dict[i].append(j)\n j-=1'''\narr=[[0 for i in range(n+1)] for j in range(k+1)]\nfor i in range(1,n+1):\n arr[1][i]=1\nfor i in range(2,k+1):\n for j in range(1,n+1):\n p=j\n while(p<n+1):\n arr[i][p]=(arr[i][p]+arr[i-1][j])%rem\n p+=j\n\n\n\n#print arr\ns=0\nfor i in range(1,n+1):\n s=(s+arr[k][i])%rem\nprint s%(10**9+7)"}, {"source_code": "n,k=map(int,input().split())\na=[[0 for i in range(n+1)] for j in range(k+1) ]\nfor i in range(1,n+1):\n a[0][i]=1\n#print(a)\n#for i in range(0,n-1):# i represents column or ending value\n#\tfor j in range(k):# k reperesent the number of spaces filled so far\nfor i in range(1,k+1):\n\tfor j in range(1,n+1):\n\t\ttemp=j\n\t\twhile temp<=n:\n\t\t #print(i,temp)\n\t\t a[i][temp]+=a[i-1][j]\n\t\t a[i][temp]%=1000000007\n\t\t temp+=j\n#print(a)\nprint(sum(a[k-1])%1000000007)"}, {"source_code": "# import sys\n# sys.stdin = open(\"input.in\",\"r\")\n# sys.stdout = open(\"output.out\",\"w\")\n\nn,k1 = map(int,input().split())\n\ndp = [[0 for i in range(n+1)] for j in range(k1+1)]\ndp[0][0] = 1\nfor i in range(k1+1):\n\n\tdp[i][0] = 1\n\n# for i in range(n+1):\n\n# \tdp[i][0] = 1\n\nfor i in range(1,n+1):\n\n\tdp[1][i] = 1\n\n# print(dp)a\n\n\nfor i in range(2,k1+1):\n\n\tfor j in range(1,n+1):\n\t\tk = j\n\t\t# r = j\n\t\t# print(\"--\")\n\t\twhile k <= n:\n\n\t\t\tdp[i][k] = (dp[i][k] + dp[i-1][j])%1000000007\n\n\t\t\tk = k + j\n# print(dp)\nprint((sum(dp[k1])-1)%1000000007)\t\t\n\n\n\n# print(dp)\n# print(dp[n][k])\n"}, {"source_code": "n,k = map(int,raw_input().split())\ne = 1000000007\ndef solve(x):\n\tr = []\n\tfor i in xrange(1,int(x**0.5)+1,1):\n\t\tif x%i==0:\n\t\t\tif i==x/i:\n\t\t\t\tr.append(i)\n\t\t\telse:\n\t\t\t\tr.extend([i,x/i])\n\treturn r\nr1 = []\nfor i in xrange(1,n+1,1):\n\tr1.append(solve(i))\n#print r1\ns = [[0]*n for _ in xrange(k)]\nfor i in xrange(k):\n\tfor j in xrange(n):\n\t\tif i==0:\n\t\t\ts[i][j]=1\n\t\telse:\n\t\t\tif j==0:\n\t\t\t\ts[i][j]=1\n\t\t\telse:\n\t\t\t\tfor w in r1[j]:\n\t\t\t\t\ts[i][j]=(s[i][j]+s[i-1][w-1])%e\nprint sum(s[k-1])%e\n"}, {"source_code": "n,k = map(int,input().split())\nMOD = 1000000007 \n\nd = []\n\nfor i in range(1,2001):\n cur = []\n for j in range(1,i+1):\n if i%j==0:\n cur.append(j)\n d.append(cur)\n\ndp = []\n\nfor i in range(0,k+1):\n cur=[]\n for j in range(0, n+1):\n cur.append(0)\n dp.append(cur)\n\nfor i in range(1,n+1):\n dp[1][i] = 1\n\nfor i in range(1,k+1):\n for j in range(1,n+1):\n for c in d[j-1]:\n dp[i][j]+=dp[i-1][c]\n if dp[i][j]>=MOD:\n dp[i][j]-=MOD\n\nans = 0\n\nfor i in range(1,n+1):\n ans+=dp[k][i]\n if ans>=MOD:\n ans-=MOD\n\nprint(ans)\n"}, {"source_code": "def C(n,k):\n w=1\n for i in range(n-k+1,n+1):\n w*=i\n for i in range (1,k+1):\n w//=i\n return w\n\nn,k=[int(x) for x in raw_input().split()]\nans=0\nfor i in range(1,n+1):\n pp=1;\n i1=i;\n for j in range(2,i+1):\n sch=0;\n while(i1%j==0):\n sch+=1\n i1//=j\n if (sch):\n pp*=C(sch+k-1,sch)\n pp%=1000000007\n ans+=pp\n ans%=1000000007\nprint(ans)"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\nsetrecursionlimit(2*10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n if len(li)==0: return \n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\nn,k=listInput()\nMOD=10**9+7\nadjList=[[] for i in xrange(n+1)]\nfor i in xrange(1,n+1):\n for j in xrange(i,n+1,i):\n adjList[i].append(j)\nans=[[0]*(k+1) for i in xrange(n+1)]\nfor i in xrange(1,n+1):\n ans[i][1]=1\nfor i in xrange(1,k+1):\n ans[n][i]=1\nfor i in xrange(n-1,0,-1):\n for j in xrange(2,k+1):\n for l in adjList[i]:\n ans[i][j]=(ans[i][j]+ans[l][j-1])%MOD\npr=0\nfor i in xrange(1,n+1):\n pr=(pr+ans[i][k])%MOD\nprint pr"}, {"source_code": "n, k = map(int, raw_input().split())\ndp = [[0 for i in range(n + 1)] for j in range(k + 1)]\ndiv = [[] for i in range(n + 1)]\nc = 0\nfor i in range(1, n + 1):\n for j in range(1, i + 1):\n if i % j == 0:\n div[i].append(j)\n c += 1\n\nmod = 10 ** 9 + 7\ndp[0][1] = 1\nres = 0\nfor i in range(k):\n for j in range(1, n + 1):\n for x in div[j]:\n dp[i + 1][j] += dp[i][x]\n dp[i + 1][j] %= mod\n\nfor x in dp[k]:\n res += x\n\nprint res % mod"}, {"source_code": "def solve():\n\n mod = (10**9) + 7\n n, k = map(int, raw_input().split())\n\n dp = [1] * n\n\n for i in xrange(k - 1):\n for j in xrange(1, n+1):\n tmp = 0\n for z in xrange(j, n+1, j):\n tmp = (tmp + dp[z - 1]) % mod \n dp[j - 1] = tmp\n ans = 0\n for i in dp:\n ans = (ans + i) % mod \n print ans \nsolve()"}, {"source_code": "\"Template made by : https://codeforces.com/profile/c1729 , github repo : https://github.com/cheran-senthil/PyRival\"\nfrom __future__ import division, print_function\nimport bisect\nimport math\nimport itertools\nimport sys\nfrom atexit import register\n\nif sys.version_info[0] < 3:\n from io import BytesIO as stream\nelse:\n from io import StringIO as stream\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\ndef main():\n n,k = map(int,input().split())\n arr = [1]*2500\n temp = [0]*2500\n \n summ = 0\n if k<1 or n<1:\n print(\"0\")\n elif k ==1:\n print(n)\n else:\n for j in range(2,k+1):\n for i in range(1,n+1):\n for b in range(i,n+1,i):\n temp[i] = (temp[i]+arr[b])%1000000007\n for i in range(n+1):\n arr[i] = temp[i]\n temp[i] = 0\n for i in range(1,n+1):\n summ = (summ+arr[i])%1000000007\n print(summ)\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n"}, {"source_code": "n,k = map(int, raw_input().split())\nfinal = 0\nl = [[0 for i in range(2010)] for j in range(2010)]\nfor i in range(1,n+1):\n l[1][i] = 1\nfor i in range(1,k+1):\n for j in range(1,n+1):\n for p in range(j,n+1,j):\n l[i+1][p] = (l[i + 1][p] + l[i][j]) % (10**9+7)\nfor i in range(1,n+1):\n final = (final+l[k][i])%(10**9+7)\nprint final\n "}, {"source_code": "MOD = 10**9+7\n\ndef sum(a, b):\n\treturn (a+b)%MOD\n\nn, k = map(int, raw_input().split())\n\nDP = [[]]\nDP.append([0] + [1 for i in xrange(1, n+1)])\n\nfactors = {}\nfor i in xrange(1, n+1):\n\tfactors[i] = []\n\tfor j in xrange(1, i+1):\n\t\tif i%j == 0:\n\t\t\tfactors[i].append(j)\n\nfor i in xrange(2, k+1):\n\tDP.append([0 for _ in xrange(n+1)])\n\tfor j in xrange(1, n+1):\n\t\tfor f in factors[j]:\n\t\t\tDP[i][j] = (DP[i][j] + DP[i-1][f])%MOD\n\nprint reduce(sum, DP[k])"}, {"source_code": "import math\nfrom collections import defaultdict\nMOD = 10**9 + 7\ndef printDivisors(n) : \n \n i = 1\n Factors = []\n while i <= math.sqrt(n): \n \n if (n % i == 0) : \n if (n / i == i) : \n Factors.append(i)\n else : \n Factors.append(i)\n Factors.append(int(n/i))\n i = i + 1\n Factors.sort(reverse = True)\n return Factors\nF = defaultdict(list)\nn,k = map(int,input().split())\nfor i in range(1,n+1):\n F[i] =printDivisors(i)\ndp = [1] * (n+1)\ndp[0] = 0\nfor i in range(1,k):\n for j in range(1,n+1):\n for f in range(j+j,n+1,j):\n dp[j] += dp[f]\n dp[j] %= MOD\nprint(sum(dp)%MOD)\n"}, {"source_code": "n, k = map(int, input().split())\ndp = [0] * (k + 1)\nfor i in range(k + 1):\n if i > 0:\n dp[i] = [0] * (n + 1)\n else:\n dp[i] = [1] * (n + 1)\nfor i in range(1, k + 1):\n for x in range(1, n + 1):\n for j in range(x, n + 1, x):\n dp[i][x] += dp[i - 1][j]\n dp[i][x] %= 1000000007\nprint(dp[k][1])\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nn, k = map(int, input().split())\nMOD = 10 ** 9 + 7\ndp = [0] * (n + 1)\ndp[1] = 1\nfor i in range(k):\n tmp = dp.copy()\n dp = [0] * (n + 1)\n for j in range(1, n + 1):\n if tmp[j]:\n for l in range(1, n + 1):\n if j * l <= n:\n dp[j * l] += tmp[j]\n dp[j * l] %= MOD\n else:\n break\n \nprint(sum(dp) % MOD)"}, {"source_code": "ans = [[0]*2001 for i in range(2001)]\nn, k = [int(x) for x in input().split(' ')] ; p = 0;\n\nfor end in range(1, n + 1):\n\tans[1][end] = 1\n\nfor le in range(2, k + 1):\n\tfor end in range(1, n + 1):\n\t\tfor nend in range(end, n + 1, end):\n\t\t\tans[le][nend] = (ans[le - 1][end] + ans[le][nend]) % 1000000007\n\nfor i in range(n):\n\tp = (p + ans[k][i + 1]) % 1000000007\nprint(p)"}, {"source_code": "mod = 1000000007\nn, k = [int(i) for i in input().split()]\n\nfactors = []\n\nfor i in range(n):\n factors.append([])\n\nfor i in range(1, n + 1):\n for j in range(i, n + 1, i):\n factors[j - 1].append(i)\n # print(factors)\n\n# print(factors)\n\ndp = []\n\nfor i in range(n):\n dp.append([])\n\n for j in range(k):\n if i == 0 or j == 0:\n dp[i].append(1)\n\n else:\n tmp = 0\n\n for l in factors[i]:\n # print(i, j, l, dp)\n tmp = (tmp + dp[l - 1][j - 1]) % mod\n # print(tmp)\n dp[i].append(tmp)\n\n# print(dp)\n\ngood = 0\n\nfor i in dp:\n good = (good + i[-1]) % mod\n\nprint(good)\n"}], "negative_code": [{"source_code": "#Author: squiggly_lines\n#Date: 30/04/2014\n#Problem: 414B\nimport math\ndef main():\n n,k = map(int, raw_input().split())\n print B(n,k)\n \ndef B(n,k):\n s = 0\n for i in xrange(1,n+1):\n s += A(i,k)\n\n return s\n\ndef A(n,k): #Sometimes I forget that code doesn't have to be translated directly ...\n if n == 1:\n return 1\n pf = prime_factor(n)\n\n prod = 1\n for (p, exp) in pf:\n prod *= binom(exp+k-1, k-1)\n\n return prod\n\ndef prime_factor(n):\n pf = []\n d = 2\n while d**2 <= n:\n exp = 0\n while n % d == 0:\n n /= d \n exp += 1\n if exp > 0: \n pf.append((d,exp)) #The prime doesn't actually matter, but whatever\n d += 1\n if n > 1:\n pf.append((n,1))\n return pf\n\ndef binom(n,k): #Because importing itertools or scipy seems overkill\n return reduce(mult, xrange(k+1,n+1)) / reduce(mult, xrange(1,n-k+1))\n\ndef mult(x,y): #To compensate for not knowing Python\n return x*y\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "from sys import stdin\n\nn, k = map(int, stdin.readline().split())\nmem = [0] + [1 for _ in range(n)]\n\nfor i in range(1, k):\n for j in range(1, n + 1):\n for d in range(j + j, n + 1, j):\n mem[j] += mem[d]\nprint(sum(mem))\n"}, {"source_code": "\"\"\"Template for Python Competitive Programmers prepared by Mayank Chaudhary aka chaudhary_19\"\"\"\n\n# to use the print and division function of Python3\nfrom __future__ import division, print_function\n\n\"\"\"value of mod\"\"\"\nMOD = 10 ** 9 + 7\n\n\"\"\"use resource\"\"\"\n# import resource\n# resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n\n\"\"\"uncomment next 4 lines while doing recursion based question\"\"\"\n# import threading\n# threading.stack_size(2**27)\nimport sys\n\n# sys.setrecursionlimit(10**6)\n\n\"\"\"uncomment next 7 lines while doing nCr question\"\"\"\n# fact=[1]\n# for i in range(1,100001):\n# fact.append((fact[-1]*i)%mod)\n# ifact=[0]*100001\n# ifact[100000]=pow(fact[100000],mod-2,mod)\n# for i in range(100000,0,-1):\n# ifact[i-1]=(i*ifact[i])%mod\n\n\"\"\"uncomment modules according to your need\"\"\"\nfrom bisect import bisect_left, bisect_right, insort\n# import itertools\n# import collections\nfrom math import floor, ceil\n# import heapq\n# from random import randint as rn\n# from Queue import Queue as Q\n\n'''\ndef modinv(n, p):\n return pow(n, p - 2, p)\n'''\n\n'''\ndef ncr(n, r, p): # for using this uncomment the lines calculating fact and ifact\n t = ((fact[n]) * ((ifact[r] * ifact[n - r]) % p)) % p\n return t\n'''\n\n\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef input(): return sys.stdin.readline().strip()\n\n\n'''\ndef GCD(x, y):\n while (y):\n x, y = y, x % y\n return x\n'''\n\n\"\"\"*******************************************************\"\"\"\n\ndef get_xor(n):\n return [n,1,n+1,0][n%4]\n\ndef count_factors(n, k, dp):\n\n i = 1\n ans = 0\n while i*i <= n:\n if n%i==0:\n ans += dp[i][k-1]\n if (n//i)!=i:\n ans += dp[n//i][k-1]\n i += 1\n return ans\n\ndef main():\n\n n,k = get_ints()\n dp = [[0 for i in range(n+1)] for j in range(k+1)]\n\n for i in range(1, k+1):\n dp[i][1] = 1\n for i in range(1, n+1):\n dp[1][i] = 1\n\n for i in range(2, k+1):\n for j in range(2, n+1):\n # print(i,j, end = ' ')\n ans = 0\n m = 1\n while m*m <= j:\n if j%m==0:\n ans += dp[i-1][m]\n if j//m != m:\n ans += dp[i-1][j//m]\n m += 1\n # print(ans)\n dp[i][j] = ans\n # for i in dp:\n # print(i)\n print(sum(dp[-1]))\n\n\n\n\n\n\"\"\" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------\"\"\"\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill();\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\"\"\" main function\"\"\"\n\nif __name__ == '__main__':\n main()\n# threading.Thread(target=main).start()"}, {"source_code": "\"\"\"Template for Python Competitive Programmers prepared by Mayank Chaudhary aka chaudhary_19\"\"\"\n\n# to use the print and division function of Python3\nfrom __future__ import division, print_function\n\n\"\"\"value of mod\"\"\"\nMOD = 10 ** 9 + 7\n\n\"\"\"use resource\"\"\"\n# import resource\n# resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n\n\"\"\"uncomment next 4 lines while doing recursion based question\"\"\"\n# import threading\n# threading.stack_size(2**27)\nimport sys\n\n# sys.setrecursionlimit(10**6)\n\n\"\"\"uncomment next 7 lines while doing nCr question\"\"\"\n# fact=[1]\n# for i in range(1,100001):\n# fact.append((fact[-1]*i)%mod)\n# ifact=[0]*100001\n# ifact[100000]=pow(fact[100000],mod-2,mod)\n# for i in range(100000,0,-1):\n# ifact[i-1]=(i*ifact[i])%mod\n\n\"\"\"uncomment modules according to your need\"\"\"\nfrom bisect import bisect_left, bisect_right, insort\n# import itertools\n# import collections\nfrom math import floor, ceil\n# import heapq\n# from random import randint as rn\n# from Queue import Queue as Q\n\n'''\ndef modinv(n, p):\n return pow(n, p - 2, p)\n'''\n\n'''\ndef ncr(n, r, p): # for using this uncomment the lines calculating fact and ifact\n t = ((fact[n]) * ((ifact[r] * ifact[n - r]) % p)) % p\n return t\n'''\n\n\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef input(): return sys.stdin.readline().strip()\n\n\n'''\ndef GCD(x, y):\n while (y):\n x, y = y, x % y\n return x\n'''\n\n\"\"\"*******************************************************\"\"\"\n\ndef get_xor(n):\n return [n,1,n+1,0][n%4]\n\ndef main():\n\n n,k = get_ints()\n\n dp = [[0 for i in range(n+1)] for j in range(k+1)]\n\n store = [[] for i in range(n+1)]\n # print(store)\n\n for i in range(1, n+1):\n m = 1\n while m*m <= i:\n if i%m==0:\n store[i].append(m)\n if m*m!=i:\n store[i].append(i//m)\n m += 1\n\n for i in range(1, k+1):\n for j in range(1, n+1):\n if i==1 or j==1:\n dp[i][j] = 1\n else:\n ans = 0\n for m in store[j]:\n ans += dp[i-1][m]\n dp[i][j] = ans\n\n # for i in dp:\n # print(i)\n print(sum(dp[-1]))\n\n\n\n\n\"\"\" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------\"\"\"\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill();\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\"\"\" main function\"\"\"\n\nif __name__ == '__main__':\n main()\n# threading.Thread(target=main).start()"}, {"source_code": "n,k=map(int,raw_input().split())\ndict={}\nfor i in range(1,n+1):\n dict[i]=[]\nfor i in range(1,n+1):\n j=i\n while(j>0):\n if i%j==0:\n dict[i].append(j)\n j-=1\narr=[[0 for i in range(n+1)] for j in range(k+1)]\nfor i in range(1,n+1):\n arr[1][i]=1\nfor i in range(2,k+1):\n for j in range(1,n+1):\n s=0\n for p in dict[j]:\n s+=arr[i-1][p]\n arr[i][j]=s\nprint sum(arr[k])\n\n"}, {"source_code": "n, k = map(int, raw_input().split())\ndp = [[0 for i in range(n + 1)] for j in range(k + 1)]\ndiv = [[] for i in range(n + 1)]\nc = 0\nfor i in range(1, n + 1):\n for j in range(1, i + 1):\n if i % j == 0:\n div[i].append(j)\n c += 1\n\nprint(c)\nmod = 10 ** 9 + 7\ndp[0][1] = 1\nres = 0\nfor i in range(k):\n for j in range(1, n + 1):\n for x in div[j]:\n dp[i + 1][j] += dp[i][x]\n dp[i + 1][j] %= mod\n\nfor x in dp[k]:\n res += x\n\nprint res % mod"}, {"source_code": "n, k = map(int, raw_input().split())\n\nDP = [[]]\nDP.append([0] + [1 for i in xrange(1, n+1)])\n\nfactors = {}\nfor i in xrange(1, n+1):\n\tfactors[i] = []\n\tfor j in xrange(1, i+1):\n\t\tif i%j == 0:\n\t\t\tfactors[i].append(j)\n\nfor i in xrange(2, k+1):\n\tDP.append([0 for _ in xrange(n+1)])\n\tfor j in xrange(1, n+1):\n\t\tfor f in factors[j]:\n\t\t\tDP[i][j] += DP[i-1][f]\n\nprint sum(DP[k])"}, {"source_code": "Mod=10**+7\nn,k=map(int,input().split())\ndp=[[0]*(n+1) for i in range(k+1)]\nl=[[] for _ in range(n+1)]\nfor i in range(1,n+1):\n dp[1][i]=1\n for j in range(1,i+1):\n if i%j==0:\n l[i].append(j)\nfor j in range(2,k+1):\n for i in range(1,n+1):\n for le in range(len(l[i])):\n dp[j][i]+=dp[j-1][l[i][le]]\n dp[j][i]%=Mod\nans=0\nfor i in range(1,n+1):\n ans+=dp[k][i]\n ans%=Mod\nprint(ans)\n\n \n \n"}, {"source_code": "import math\na=list(map(int,input().split()))\ndp=[[0 for i in range(a[1]+1)]for j in range(a[0]+1)]\nfor i in range(1,a[0]+1):\n dp[i][0]=1\nfor i in range(1,a[0]//2+1):\n dp[i][1]=(a[0]//i-1)\n\nfor j in range(2,a[1]+1):\n for i in range(1,(a[0]//(2**j))+1):\n for l in range(2*i,(a[0]//(i))+1,i):\n dp[i][j]+=dp[l][j-1]\n \n\ncnt=a[0]\nmod=1000000007\narr=[0 for i in range(a[1]+1)]\nfor i in range(1,a[1]):\n for j in range(1,a[0]//2+1):\n arr[i]+=dp[j][i]\nans=1\nfor i in range(1,a[1]-1):\n ans1=1\n for q in range(1,i+1):\n ans1=ans1*(a[1]-q)\n ans2=1\n for j in range(1,i+1):\n ans2=ans2*j\n ans=ans1//ans2\n cnt=cnt%mod+(arr[i]*ans)%mod\n cnt=cnt%mod\n\ncnt=cnt%mod+arr[a[1]-1]%mod\nprint(cnt%mod)"}, {"source_code": "import math\na=list(map(int,input().split()))\ndp=[[0 for i in range(a[1]+1)]for j in range(a[0]+1)]\nfor i in range(1,a[0]+1):\n dp[i][0]=1\nfor i in range(1,a[0]//2+1):\n dp[i][1]=(a[0]//i-1)\n\nfor j in range(2,a[1]+1):\n for i in range(1,(a[0]//(2**j))+1):\n for l in range(2*i,(a[0]//(i*j))+1,i):\n dp[i][j]+=dp[l][j-1]\n \n\ncnt=a[0]\nmod=1000000007\narr=[0 for i in range(a[1]+1)]\nfor i in range(1,a[1]):\n for j in range(1,a[0]//2+1):\n arr[i]+=dp[j][i]\nans=1\nfor i in range(1,a[1]-1):\n ans1=1\n for q in range(1,i+1):\n ans1=ans1*(a[1]-q)\n ans2=1\n for j in range(1,i+1):\n ans2=ans2*j\n ans=ans1//ans2\n cnt=cnt%mod+(arr[i]*ans)%mod\n cnt=cnt%mod\n\ncnt=cnt%mod+arr[a[1]-1]%mod\nprint(cnt%mod)"}, {"source_code": "import math\na=list(map(int,input().split()))\ndp=[[0 for i in range(a[1]+1)]for j in range(a[0]+1)]\nfor i in range(1,a[0]+1):\n dp[i][0]=1\nfor i in range(1,a[0]//2+1):\n dp[i][1]=(a[0]//i-1)\n\nfor j in range(2,a[1]+1):\n for i in range(1,(a[0]//(2**j))+1):\n for l in range(2*i,(a[0]//(i**(j-1)))+1 ,i):\n dp[i][j]+=dp[l][j-1]\n \n\ncnt=a[0]\nmod=1000000007\narr=[0 for i in range(a[1]+1)]\nfor i in range(1,a[1]):\n for j in range(1,a[0]//2+1):\n arr[i]+=dp[j][i]\nans=1\nfor i in range(1,a[1]-1):\n ans1=1\n for q in range(1,i+1):\n ans1=ans1*(a[1]-q)\n ans2=1\n for j in range(1,i+1):\n ans2=ans2*j\n ans=ans1//ans2\n cnt=cnt%mod+(arr[i]*ans)%mod\n cnt=cnt%mod\n\ncnt=cnt%mod+arr[a[1]-1]%mod\nprint(cnt%mod)"}, {"source_code": "import math\na=list(map(int,input().split()))\ndp=[[0 for i in range(a[1]+1)]for j in range(a[0]+1)]\nfor i in range(1,a[0]+1):\n dp[i][0]=1\nfor i in range(1,a[0]//2+1):\n dp[i][1]=(a[0]//i-1)\n\nfor j in range(2,a[1]+1):\n for i in range(1,a[0]//2+1):\n if(i>=2):\n \n r=int(math.log(a[0])//math.log(i))+1\n else:\n r=a[0]+1\n for l in range(2*i,r,i):\n dp[i][j]+=dp[l][j-1]\n \n\ncnt=a[0]\nmod=1000000007\narr=[0 for i in range(a[1]+1)]\nfor i in range(1,a[1]):\n for j in range(1,a[0]//2+1):\n arr[i]+=dp[j][i]\nans=1\nfor i in range(1,a[1]-1):\n ans1=1\n for q in range(1,i+1):\n ans1=ans1*(a[1]-q)\n ans2=1\n for j in range(1,i+1):\n ans2=ans2*j\n ans=ans1//ans2\n cnt=cnt%mod+(arr[i]*ans)%mod\n cnt=cnt%mod\n\ncnt=cnt%mod+arr[a[1]-1]%mod\nprint(cnt%mod)"}, {"source_code": "n, k = map(int, input().split())\np = [0, 0] + [[1] * k for i in range(n - 1)]\nn += 1\nfor i in range(2, n):\n for j in range(k - 1): p[i][j + 1] += p[i][j]\n for j in range(2 * i, n, i):\n for d in range(k - 1): p[j][d + 1] += p[i][d]\nprint(sum(r[k - 1] for r in p[2: ]) + 1)"}, {"source_code": "n, k = map(int, input().split())\np = [0, 0] + [[1] * k for i in range(n - 1)]\nd, n = 1000000007, n + 1\nfor i in range(2, n):\n for j in range(k - 1): p[i][j + 1] = (p[i][j + 1] + p[i][j]) % d\n for j in range(2 * i, n, i):\n for d in range(k - 1): p[j][d + 1] += p[i][d]\nprint((sum(r[k - 1] for r in p[2: ]) + 1) % d)"}, {"source_code": "import math\n\nMOD = 10**9 + 7\n\ndef count_good_sequences(n, k):\n \n good_sequences = 1\n \n for i in xrange(2, n + 1):\n factorization = prime_factorize(i)\n s_i = 1\n for prime in factorization:\n num_factors = factorization[prime]\n result = 0\n for e_i in xrange(num_factors + 1):\n result = (result + choose_mod(fact, inv_fact, e_i + k - 2, k - 2, MOD)) % MOD\n s_i = (s_i * result) % MOD\n good_sequences = (good_sequences + s_i) % MOD\n \n return good_sequences\n\n\ndef prime_factorize(n):\n\n factors = {}\n prime = 3\n\n while n > 0 and n % 2 == 0:\n if 2 not in factors:\n factors[2] = 0\n factors[2] += 1\n n = n/2\n\n while prime <= math.sqrt(n):\n while n % prime == 0:\n if prime not in factors:\n factors[prime] = 0\n factors[prime] += 1\n n = n/prime\n prime += 2\n\n if n > 2:\n factors[n] = 1\n\n return factors\n\n\n\ndef generate_factorial(n, p):\n \n fact = [1]\n inv_fact = [1]\n\n for i in xrange(1, n + 1):\n fact.append((fact[-1]*i) % p)\n inv_fact.append(extended_euclidean(fact[-1], p)[0] % p)\n \n return fact, inv_fact\n \ndef extended_euclidean(a, b):\n\n if a == 0:\n return (0, 1, b)\n\n a = abs(a)\n b = abs(b)\n a, b = min(a, b), max(a, b)\n x, y, gcd = extended_euclidean(b % a, a)\n x, y = y - (b/a)*x, x\n return (x, y, gcd)\n \ndef choose_mod(fact, inv_fact, n, k, p):\n\n if n < k: return 0\n return (((fact[n]*inv_fact[n - k]) % p)*inv_fact[k]) % p\n \n\nn, k = map(int, raw_input().strip().split(' '))\nfact, inv_fact = generate_factorial(10000, MOD)\nprint count_good_sequences(n, k)"}, {"source_code": "'''\n\tCodeForces 414B\n\tMashmokh and ACM\n\n\tTags: dp, Math\n'''\n\nMOD = 1000000007\n\nn, k = tuple(map(int, input().split()))\n\ndivider = [ [ x for x in range(1, n + 1) if i % x == 0 ] for i in range(n + 1) ]\n\nprint(divider)\n\ndp = [ [ 1 for j in range(k + 1) ] for i in range(n + 1) ]\n\nfor j in range(2, k + 1):\n\tfor i in range(1, n + 1):\n\t\tdp[i][j] = sum(map(lambda x: dp[x][j - 1], divider[i])) % MOD\n\nans = sum([ dp[i][k] for i in range(1, n + 1) ]) % MOD\nprint(ans)"}, {"source_code": "# SHRi GANESHA author: Kunal Verma #\n\nimport os,sys\nfrom collections import Counter, deque\nfrom io import BytesIO, IOBase\n\n\n\ndef main():\n import math\n\n n, k = map(int, input().split())\n mod = 10 ** 9 + 7\n\n def divisors(n):\n i = 1\n x = []\n while i <= math.sqrt(n):\n if (n % i == 0):\n if (n // i == i):\n x.append(i)\n else:\n x.append(i)\n x.append(n // i)\n i = i + 1\n return x\n\n dp = [[0 for i in range(n)] for j in range(k)]\n x = [0 for i in range(n + 1)]\n for i in range(1, n + 1):\n x[i] = divisors(i)\n\n for i in range(n):\n dp[0][i] = 1\n for i in range(k):\n for j in range(n):\n for p in x[j + 1]:\n dp[i][j] = (dp[i][j] + dp[i - 1][p - 1]) % mod\n print(sum(dp[k - 1]) % mod)\n#Fast IO Region\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == '__main__':\n main()"}, {"source_code": "# SHRi GANESHA author: Kunal Verma #\n\nimport os,sys\nfrom collections import Counter, deque\nfrom io import BytesIO, IOBase\n\n\n\ndef main():\n import math\n\n n, k = map(int, input().split())\n mod = 10 ** 9 + 7\n\n def divisors(n):\n i = 1\n x = []\n while i <= math.sqrt(n):\n if (n % i == 0):\n if (n // i == i):\n x.append(i)\n else:\n x.append(i)\n x.append(n // i)\n i = i + 1\n return x\n\n dp = [[0 for i in range(n)] for j in range(k)]\n x = [0 for i in range(n + 1)]\n for i in range(1, n + 1):\n x[i] = divisors(i)\n print(x)\n for i in range(n):\n dp[0][i] = 1\n for i in range(k):\n for j in range(n):\n for p in x[j + 1]:\n dp[i][j] = (dp[i][j] + dp[i - 1][p - 1]) % mod\n print(sum(dp[k - 1]) % mod)\n#Fast IO Region\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n,m=map(int,input().split())\na=[]\nfor i in range(1,n+1):\n a.append(n//i)\nif(m==1):\n print(n)\nelse:\n for x in range(m-2):\n for i in range(1,n+1):\n j=i\n while(j<=n):\n j+=i\n if(j<=n):\n a[i-1]+=a[j-1]\n print(sum(a))"}, {"source_code": "import io, os\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nmod = 10**9 + 7\nn, k = map(int, input().split())\ncount = [1]*(n+1)\nfor i in range(k-1):\n\tnew = [0]*(n+1)\n\tfor j in range(1, n+1):\n\t\tt = count[j]\n\t\tfor k in range(j, n+1, j):\n\t\t\tnew[k] = (new[k]+t)%mod\n\tcount = new\nprint(sum(count)%mod)"}, {"source_code": "n,k = map(int,input().split())\nl = [int(n/i) for i in range(1,n+1)]\nmod = 1000000007\nif k == 1 :\n\tprint(n)\nelse :\n\tp = 2\n\twhile p <= k -2 :\n\t\ti = 1 \n\t\twhile(i <= n) :\n\t\t\tj=1\n\t\t\twhile(j*i <= n) :\n\t\t\t\tl[i-1] = (l[i-1] + l[j*i-1])%mod\n\t\t\t\tj += 1\n\t\t\ti +=1\n\t\tp += 1\n\n\tprint(sum(l)%mod)\n\n\n\n\n\n"}, {"source_code": "n, k = map(int, input().rstrip().split(\" \"))\nl = [n//i for i in range(1,n+1)]\nif k ==1 :\n print(n)\nelse:\n for i in range(0,k-2):\n for j in range(1, n+1):\n x=j\n while x<=n:\n x += j\n if x<=n:\n l[j-1]= (l[j-1] + l[x-1])%(10**8 + 7)\n\n print(sum(l))"}, {"source_code": "n, k = map(int, input().split())\nMOD = 10 ** 9 + 7\ndp = [0] * (n + 1)\ndp[1] = 1\nfor i in range(k):\n tmp = dp.copy()\n dp = [0] * (n + 1)\n for j in range(1, n + 1):\n if tmp[j]:\n for l in range(1, n + 1):\n if j * l <= n:\n dp[j * l] += tmp[j]\n dp[j * l] %= MOD\n else:\n break\n\nprint(sum(dp))\n"}, {"source_code": "import math\nn, k = map(int, input().split())\ndp = [[0]*(n+1) for _ in range(k+1)]\ndp[0][1] = 1\nfor i in range(1, k+1):\n for j in range(1, n+1):\n for m in range(j, n+1, j):\n dp[i][m] += dp[i-1][j]\nans = 0\nfor i in range(1, n+1):\n ans += (dp[k][i])%1000000007\nprint(ans)\n"}, {"source_code": "import math\nn, k = map(int, input().split())\ndp = [[0]*(n+1) for _ in range(k+1)]\ndp[0][1] = 1\nfor i in range(1, k+1):\n for j in range(1, n+1):\n for m in range(j, n+1, j):\n dp[i][m] = (dp[i][k] + dp[i-1][j])%1000000007\nans = 0\nfor i in range(1, n+1):\n ans = (ans+dp[k][i])%1000000007\nprint(ans)\n"}, {"source_code": "import math\nn, k = map(int, input().split())\ndp = [[1 for _ in range(k+1)] for _ in range(n+1)]\nfor i in range(1, n+1):\n f = set((1, i))\n for m in range(2, int(math.sqrt(i))+1):\n if i%m==0:\n f.add(m)\n if i/m != i:\n f.add(i//m)\n for j in range(2, k+1):\n dp[i][j] = 0\n for x in f:\n dp[i][j] += dp[x][j-1]\nans = 0\nfor i in range(1, n+1):\n ans += dp[i][k]\nprint(ans)\n"}, {"source_code": "import math\nn, k = [*map(int, input().split())]\n\nprime = [1]\nf = [False] * 2000\nfor i in range(2, 2000):\n if f[i]:\n continue\n f[i] = True\n prime.append(i)\n j = 1\n while i * j < 2000:\n f[i * j] = True\n j += 1\n\nf = [[0] * (n + 1) if i != 1 else [1] * (n + 1) for i in range(k + 1)]\ndiv = [[]]\nf[1][0] = 0\nfor i in range(1, n + 1):\n j = 0\n div.append([])\n while prime[j] <= math.sqrt(i):\n if not (i % prime[j]):\n div[i] += [prime[j]]\n if i // prime[j] != prime[j]:\n div[i] += [i // prime[j]]\n j += 1\n for j in range(2, k + 1):\n for l in div[i]:\n f[j][i] += f[j - 1][i // l]\n f[j][i] %= 10 ** 9 + 7\nans = 0\nfor i in f[k]:\n ans += i\n ans %= 10 ** 9 + 7\nprint(ans)\n"}, {"source_code": "mod=10**9+7\n[n ,k]=list(map(int, input().split()))\ndp=[[0 for _ in range(n+1)] for _ in range(k+1)]\nfor last in range(1, n+1):\n dp[1][last]=1\nfor l in range(2, k+1):\n for i in range(1, n+1):\n for j in range(i, n+1, i):\n dp[l][j]=(dp[l][j]+dp[l-1][i])%mod\nprint(sum(dp[k]))"}, {"source_code": "mod = 10**9 + 7\nn, t = map(int, input().split())\ndp = [[0 for i in range(2016)] for j in range(2016)]\ndp[0][1] = 1\nfor i in range(1, t+1):\n for j in range(1, n+1):\n for k in range(j, n+1, j):\n dp[i][k] += dp[i-1][j]\n dp[i][k] %= mod\nans = 0\nfor i in range(1, n+1):\n ans += (dp[t][i])%mod\nprint(ans)"}, {"source_code": "mod = 10**9 + 7\nn, t = map(int, input().split())\ndp = [[0 for i in range(2016)] for j in range(2016)]\ndp[0][1] = 1\nfor i in range(1, t+1):\n for j in range(1, n+1):\n for k in range(j, n+1, j):\n dp[i][k] += (dp[i-1][j])\n dp[i][k] %= mod\nans = 0\nfor i in range(1, n+1):\n ans += dp[t][i]\nprint(ans)"}, {"source_code": "import sys\nimport math as mt\ninput=sys.stdin.buffer.readline \nt=1\nmod=10**9+8\nfor __ in range(t):\n n,k=map(int,input().split())\n dp=[[0 for j in range(k+1)] for i in range(n+1)]\n pre=[[0 for j in range(k+1)] for i in range(n+1)]\n for i in range(1,n+1):\n dp[i][1]=i\n pre[i][1]=i\n for i in range(1,k+1):\n dp[1][i]=1\n pre[1][i]=(pre[1][i-1]%mod+dp[1][i]%mod)%mod\n for i in range(2,n+1):\n j1=1\n for i1 in range(1,i):\n if i%i1==0:\n j1=i1\n \n for j in range(2,k+1):\n dp[i][j]=(dp[i-1][j]%mod+1+pre[j1][j-1]%mod)%mod\n pre[i][j]=(pre[i][j-1]%mod+dp[i][j]%mod)%mod\n #print(dp)\n print(dp[n][k]) "}, {"source_code": "n, k = map(int, input().strip().split())\ndp = [[0 for i in range(n)] for i in range(k)]\nfor i in range(n):\n dp[0][i] = 1\n\nfor i in range(k-1):\n for j in range(n):\n for p in range(j+1, n+1, j+1):\n dp[i+1][p-1] += dp[i][j]\n# print('----')\n# for i in dp:\n# print(i)\nprint(sum(dp[-1]))\n\n"}, {"source_code": "mod = 10**9+7\nn, k = map(int, input().strip().split())\ndp = [[0 for i in range(n)] for i in range(k)]\nfor i in range(n):\n dp[0][i] = 1\n\nfor i in range(k-1):\n for j in range(n):\n for p in range(j+1, n+1, j+1):\n dp[i+1][p-1] = (dp[i+1][p-1] + dp[i][j])%mod\n# print('----')\n# for i in dp:\n# print(i)\nprint(sum(dp[-1]))\n\n"}, {"source_code": "N, K = map(int, input().split())\nmod = 10 ** 9 + 7\ndn = [[0]*(max(N, K) + 1)] + [[1]*(max(N, K) + 1)] + [[0]*(max(N, K) + 1) for _ in range(max(N, K) + 1)]\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n for k in range(j, N + 1, j):\n dn[i+1][j] = (dn[i+1][j] + dn[i][k]) % mod\nprint((sum(dn[K]) - dn[K][0]) % mod)\n"}, {"source_code": "N, K = map(int, input().split())\nif K > N:\n K = 0\nmod = 10 ** 9 + 7\ndn = [[0]*(N + 1)] + [[1]*(N + 1)] + [[0]*(N + 1) for _ in range(N + 1)]\nfor i in range(1, N + 1):\n for j in range(1, N + 1):\n for k in range(j, N + 1, j):\n dn[i+1][j] = (dn[i+1][j] + dn[i][k]) % mod\nprint((sum(dn[K]) - dn[K][0]) % mod)\n"}, {"source_code": "n,k=map(int,input().split())\nm=10**9+7\ndp=[[1 if i==1 else 0 for i in range(k+1)]for j in range(n+1)]\nfor j in range(1,k):\n for i in range(1,n+1):\n for ii in range(i,n+1,i):\n dp[ii][j+1]=(dp[ii][j+1]%m+dp[i][j]%m)%m\nsums=0\n#for i in range(1,n+1):\n# sums=(sums%m+dp[i][k]%m)%m\nans = sum([ dp[i][k] for i in range(1, n + 1) ]) % m\nprint(sums%m)\n"}, {"source_code": "n,k1 = map(int,input().split())\n\ndp = [[0 for i in range(n+1)] for j in range(k1+1)]\ndp[0][0] = 1\nfor i in range(k1+1):\n\n\tdp[i][0] = 1\n\n# for i in range(n+1):\n\n# \tdp[i][0] = 1\n\nfor i in range(1,n+1):\n\n\tdp[1][i] = 1\n\n# print(dp)\n\n\nfor i in range(2,k1+1):\n\n\tfor j in range(1,n+1):\n\t\tk = j\n\t\t# r = j\n\t\t# print(\"--\")\n\t\twhile k <= n:\n\n\t\t\tdp[i][k] = dp[i][k] + dp[i-1][j]\n\n\t\t\tk = k + j\n# print(dp)\nprint(sum(dp[k1])-1)\t\t\t\n\n\n\n# print(dp)\n# print(dp[n][k])\n"}, {"source_code": "n,k = map(int,input().split())\n\nd = []\n\nfor i in range(1,2001):\n cur = []\n for j in range(1,i+1):\n if i%j==0:\n cur.append(j)\n d.append(cur)\n\ndp = []\n\nfor i in range(0,k+1):\n cur=[]\n for j in range(0, n+1):\n cur.append(0)\n dp.append(cur)\n\nfor i in range(1,n+1):\n dp[1][i] = 1\n\nfor i in range(1,k+1):\n for j in range(1,n+1):\n for c in d[j-1]:\n dp[i][j]+=dp[i-1][c]\n\nans = 0\n\nfor i in range(1,n+1):\n ans+=dp[k][i]\n\nprint(ans)\n"}, {"source_code": "from sys import stdin\nimport time\n\n\nn, k = map(int, stdin.readline().rstrip().split(\" \"))\n\nd = [{} for i in range(k)]\n\ndivisors = []\n\n\nfor i in range(n + 1):\n temp = []\n for j in range(1, i + 1):\n if i % j == 0:\n temp.append(j)\n divisors.append(temp)\n\ndef getAns(pos, dig):\n #print(pos, dig)\n if pos == 0:\n return 1\n if dig in d[pos]:\n return d[pos][dig]\n else:\n temp = 0\n for di in divisors[dig]:\n temp += getAns(pos - 1, di)\n d[pos][dig] = temp\n return temp\n\n#print(divisors)\nanswer = 0\nfor i in range(1, n + 1):\n answer += getAns(k - 1, i)\n#print(d)\nprint(answer % int(10e9 + 7))"}, {"source_code": "from sys import stdin\nimport time\n\n\nn, k = map(int, stdin.readline().rstrip().split(\" \"))\n\nd = [{} for i in range(k)]\n\ndivisors = []\n\n\nfor i in range(n + 1):\n temp = []\n for j in range(1, i + 1):\n if i % j == 0:\n temp.append(j)\n divisors.append(temp)\n\ndef getAns(pos, dig):\n #print(pos, dig)\n if pos == 0:\n return 1\n if dig in d[pos]:\n return d[pos][dig]\n else:\n temp = 0\n for di in divisors[dig]:\n temp += getAns(pos - 1, di)\n d[pos][dig] = temp\n return temp\n\n#print(divisors)\nanswer = 0\nfor i in range(1, n + 1):\n answer += getAns(k - 1, i)\n#print(d)\nprint(answer)"}, {"source_code": "from sys import stdin\nfrom collections import defaultdict\nimport time\n\nK = int(10e8 + 7)\nn, k = map(int, stdin.readline().rstrip().split(\" \"))\n\nlc = [0] * (n + 1)\nlp = [1] * (n + 1)\n\n\n\n\n\nfor i in range(1, k):\n for j in range(1, n + 1):\n m = 1\n while j * m <= n:\n lc[j * m] = (lc[j * m] + lp[j]) % K\n m += 1\n lp = lc.copy()\n lc = [0] * (n + 1)\n\n\n\nprint(sum(lp) % K)"}, {"source_code": "from sys import stdin\nfrom collections import defaultdict\nimport time\n\n\nn, k = map(int, stdin.readline().rstrip().split(\" \"))\n\nd = [defaultdict(lambda : 0) for i in range(k)]\n\ndivisors = []\n\nfor i in range(n + 1):\n temp = []\n for j in range(1, i + 1):\n if i % j == 0:\n temp.append(j)\n divisors.append(temp)\n\nfor i in range(n):\n d[0][i + 1] = 1\n\nfor i in range(1, k):\n for j in range(n + 1):\n for div in divisors[j]:\n d[i][j] += d[i - 1][div]\n\n#print(d)\nprint(sum(d[k - 1].values()))"}, {"source_code": "n, k = [int(i) for i in input().split()]\n\nfactors = []\n\nfor i in range(n):\n factors.append([])\n\nfor i in range(1, n + 1):\n for j in range(i, n + 1, i):\n factors[j - 1].append(i)\n # print(factors)\n\n# print(factors)\n\ndp = []\n\nfor i in range(n):\n dp.append([])\n\n for j in range(k):\n if i == 0 or j == 0:\n dp[i].append(1)\n\n else:\n tmp = 0\n\n for l in factors[i]:\n # print(i, j, l, dp)\n tmp += dp[l - 1][j - 1]\n # print(tmp)\n dp[i].append(tmp)\n\n# print(dp)\n\ngood = 0\n\nfor i in dp:\n good += i[-1]\n\nprint(good)\n"}, {"source_code": "import math\nn, k = map(int, input().split())\ndp = [[0]*(n+1) for _ in range(k+1)]\nMOD=10**9+7\ndp[0][1] = 1\nfor i in range(1, k+1):\n for j in range(1, n+1):\n for m in range(j, n+1, j):\n dp[i][m] = (dp[i][m] + dp[i-1][j])%MOD\nans = 0\nfor i in range(1,n+1):\n ans+=dp[k][i]%MOD\nprint(ans)\n"}, {"source_code": "import math\nn, k = map(int, input().split())\ndp = [[0]*(n+1) for _ in range(k+1)]\nMOD=10**9+7\ndp[0][1] = 1\nfor i in range(1, k+1):\n for j in range(1, n+1):\n for m in range(j, n+1, j):\n dp[i][m] = (dp[i][m] + dp[i-1][j])%MOD\nans = 0\nfor i in dp:\n print(i)\nprint(ans)\n"}, {"source_code": "n, k = [int(i) for i in input().split()]\ndp = [[-1]*(n+1) for i in range(n+1)]\ndef solve(x,k):\n if(k==0):\n return 1\n elif(dp[x][k]!=-1):\n return dp[x][k]\n ans=0\n for i in range(x,n+1,x):\n ans+=solve(i,k-1)\n dp[x][k]=ans\n return dp[x][k]\nres=solve(1,k)\nprint(res)\n\n\n\n\n\n\n\n\n\n \n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n\n \n\n \n\n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n"}, {"source_code": "import math\nn, k = map(int, input().split())\ndp = [[0]*(n+1) for _ in range(k+1)]\nMOD=10**9+7\ndp[0][1] = 1\nfor i in range(1, k+1):\n for j in range(1, n+1):\n for m in range(j, n+1, j):\n dp[i][m] = (dp[i][m] + dp[i-1][j])%MOD\nans = 0\nprint(ans)\n"}, {"source_code": "n, k = [int(i) for i in input().split()]\ndp = [[-1]*(2005) for i in range(2005)]\ndef solve(x,k):\n if(k==0):\n return 1\n elif(dp[x][k]!=-1):\n return dp[x][k]\n ans=0\n for i in range(x,n+1,x):\n ans+=solve(i,k-1)\n dp[x][k]=ans\n return dp[x][k]\nres=solve(1,k)\nprint(res)\n\n\n\n\n\n\n\n\n\n \n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n\n \n\n \n\n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n"}], "src_uid": "c8cbd155d9f20563d37537ef68dde5aa"} {"source_code": "def arr_inp():\n return [int(x) for x in input().split()]\n\n\nc = arr_inp()\n\nwhile (True):\n ma, mi = max(c), min(c)\n ix_ma, ix_mi = c.index(ma), c.index(mi)\n if (ma - mi == 1 or ma == mi == 0):\n exit(print(-1))\n if (ma - mi == 0):\n exit(print(c[0]))\n c[ix_ma] -= 1\n c[ix_mi] += 1\n", "positive_code": [{"source_code": "s = sum(map(int, raw_input().split()))\nprint [s / 5, -1][s % 5 != 0 or s == 0]"}, {"source_code": "a,b,c,d,e=[int(t) for t in input().split()]\nv=int((a+b+c+d+e)/5)\nt=(a+b+c+d+e)%5\nif t==0 and v!=0:\n print(v)\nelif v==0:\n print(-1)\nelse:\n print(-1)\n"}, {"source_code": "a,b,c,d,e=map(int,input().split())\nsu=a+b+c+d+e\nif(su%5==0 and su!=0):\n\tprint(su//5)\nelse:\n\tprint(-1)"}, {"source_code": "a = sum(map(int, input().split()))\nif a % 5 or a // 5 == 0:\n print(-1)\nelse:\n print(a // 5)\n"}, {"source_code": "l=list(map(int,input().split()))\nprint(sum(l)//len(l) if sum(l)%len(l)==0 and sum(l)!=0 else -1)\n"}, {"source_code": "a,b,c,d,e=[int(x) for x in input().split()]\nsum=a+b+c+d+e\nif sum%5==0 and sum>=1:\n print(sum//5)\nelif sum==0:\n print(-1)\nelse:\n print(-1)"}, {"source_code": "\ncase=raw_input()\ncoins=case.split()\ncoins=[int(x) for x in coins]\npot=sum(coins)\nif pot%5==0 and pot>0:\n print pot/5\nelse:\n print -1"}, {"source_code": "n = input().split(' ')\n\nif int((int(n[0]) + int(n[1]) + int(n[2]) + int(n[3]) + int(n[4]))/5) == 0:\n print (-1)\nelif (int(n[0]) + int(n[1]) + int(n[2]) + int(n[3]) + int(n[4])) % 5 == 0:\n print (int((int(n[0]) + int(n[1]) + int(n[2]) + int(n[3]) + int(n[4]))/5))\nelse:\n print (-1)"}, {"source_code": "n=sum(list(map(int,input().split())))\nprint(-1 if n%5 or n==0 else n//5)"}, {"source_code": "import math\na=list(map(int,input().split()))\nn=sum(a)\nif( n>0 and n%5==0):\n print(int(n/5))\n\nelse:\n print(\"-1\")"}, {"source_code": "r = sum(map(int, raw_input().split()))\nprint -1 if r % 5 or r / 5 == 0 else r / 5\n"}, {"source_code": "n = list(map(int,raw_input().split()))\nif sum(n) == 0:\n print -1\nelse:\n if sum(n)%len(n) == 0:\n print sum(n)/len(n)\n else:\n print -1"}, {"source_code": "vlist=[int(x) for x in raw_input().split()]\nif sum(vlist)%5==0 and sum(vlist)!=0:\n print sum(vlist)/5\nelse:\n print -1"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Jul 23 23:26:45 2020\n\n@author: thiva\n\"\"\"\n\n\nC = [int(s) for s in input().split()]\nif(sum(C) % 5 == 0 and sum(C) != 0):\n print(sum(C)//5)\nelse:\n print(-1)"}, {"source_code": "li = list(map(int, input().split()))\nif sum(li) < 5 or sum(li) % 5 != 0:\n print(-1)\nelse:\n print(int(sum(li) / 5))\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\na=l()\nn=len(a)\ns=sum(a)\nif s>0 and s%n==0:\n print s/n \nelse:\n print '-1'"}, {"source_code": "lista = list(map(int,input().split()))\nmayor = max(lista)\nbolsa = 0\nfind = False\nval = 0\nlista.sort()\nfor i in range(1,mayor+1):\n bolsa = 0\n for j in range(5):\n if i > lista[j]:\n bolsa-=i-lista[j]\n elif i < lista[j]:\n bolsa+=lista[j]-i\n if bolsa == 0:\n val = i\n find = True\n break\n \n if find:\n break\nif find:\n print(i)\nelse:\n print('-1')\n \n "}, {"source_code": "arr=[0]*99\n\narr=list(map(int, input().split()))\n\na=arr[0]\nb=arr[1]\nc=arr[2]\nd=arr[3]\ne=arr[4]\n\ns = a + b + c + d + e\n\nif s > 0 and s % 5 == 0:\n print(int(s / 5))\nelse:\n print(-1)\n\n"}, {"source_code": "n=[int(z) for z in raw_input().split(' ')]\n\nans=sum(n)\nif ans==0:\n\tresult= -1\nelif ans%5==0:\n\tresult= ans/5\nelse:\n\tresult= -1\nprint result"}, {"source_code": "__author__ = 'Devesh Bajpai'\n\n'''\nhttps://codeforces.com/problemset/problem/478/A\n\nSolution: Since every player is given same amount of coins, the total coins at the end of the game should still be \ndivisible by the total number of players. Check and return the result accordingly. \n'''\n\ndef solve (num):\n\n n = len(num)\n sum = 0\n for num in nums:\n sum += num\n\n return -1 if sum == 0 or sum % n != 0 else sum / n\n\n\n\nif __name__ == \"__main__\":\n\n nums = map(int,raw_input().split(\" \"))\n print solve(nums)\n"}, {"source_code": "# coding: utf-8\n# (C) 2014, Laybson Plismenn / UFCG\n\nbets = map(int, raw_input().split())\n\nsoma = sum(bets)\n\nif soma == 0:\n\tprint -1\nelif soma % 5 == 0:\n\tprint soma / 5\nelse:\n\tprint -1\n"}, {"source_code": "def f1():\n n = map(int, raw_input().split())\n N = sum(n)\n if N == 0:\n print -1\n elif N % 5 == 0:\n print N / 5\n else:\n print -1\nf1()"}, {"source_code": "inp = [int(x) for x in input().split()]\nx = sum(inp)\n\nif x == 0:\n print(-1)\nelif x % 5 == 0:\n print(x // 5)\nelse:\n print(-1)\n\n"}, {"source_code": "a = [int(i) for i in input().split(\" \")]\ns = sum(a)\nif (s % 5 == 0) and s > 0:\n print(s//5)\nelse:\n print(-1)"}, {"source_code": "s = sum(map(int, raw_input().split()))\nprint s / 5 if s % 5 == 0 and s / 5 else -1\n\n"}, {"source_code": "t=raw_input();\na=t.split(\" \");\nsum=0;\ncount=0;\nfor i in a:\n sum=sum+int(i);\n count=count+1;\nif(sum>0):\n if(sum%count==0):\n print (sum/count);\n else:\n print \"-1\";\nelse:\n print \"-1\"\n"}, {"source_code": "#\n# 478A. Initial Bet\n#\n\ncoins = list(map(int, raw_input().strip().split()))\nif sum(coins) % 5 == 0 and sum(coins) != 0:\n print sum(coins) / len(coins)\nelse:\n print -1"}, {"source_code": "b = sum([int(x) for x in input().split()])\nprint(int(b / 5) if (b > 0) and (b % 5 == 0) else -1)"}, {"source_code": "def main():\n coins = map(int, raw_input().split())\n sum_coins = sum(coins)\n return sum_coins / 5 if (sum_coins % 5 == 0 and sum_coins > 0) else -1\n\nprint main()\n"}, {"source_code": "data_input=map(int,raw_input().split())\nif len(set(data_input))==1 and data_input[0]==0:\n\tprint '-1'\nelif sum(data_input)%5==0:\n\tprint sum(data_input)/5\nelse:\n\tprint '-1'"}, {"source_code": "a = [int(i) for i in input().split()]\nif sum(a) % 5 != 0 or sum(a) == 0:\n print(-1)\nelse:\n print(sum(a)//5)"}, {"source_code": "line = [int(i) for i in input().split(\" \")]\ntotal = sum(line)\nif total == 0 or total % 5 > 0:\n print(-1)\nelse:\n print(int(total/5))"}, {"source_code": "l=map(int,raw_input().split(' '))\nif(sum(l)!=0 and sum(l)%5==0):\n print sum(l)/5\nelse:\n print -1\n"}, {"source_code": "a = list(map(int, input().split()))\ns=sum(a)\nif s%5==0 and s>0:\n print(s//5)\nelse:\n print(-1)"}, {"source_code": "c = [int(i) for i in input().split()]\nprint([-1,sum(c)//len(c)][sum(c)%len(c)==0 and sum(c)!=0])"}, {"source_code": "c = map(int, raw_input().split(' '))\n\ns = sum(c)\n\nif (s % 5 != 0 or s == 0):\n print -1\nelse:\n print s / 5\n"}, {"source_code": "a,b,c,d,e=map(int,input().split())\ns=a+b+c+d+e\nif(s==0 or s%5):\n print(-1)\nelif(s%5==0):\n print(s//5)"}, {"source_code": "n = list(map(int, input().split()))\nif sum(n) % 5 == 0 and sum(n) != 0:\n print(sum(n) // 5)\nelse:\n print(-1)\n"}, {"source_code": "c = map( int, raw_input().split() )\ntot = sum( c )\nif tot % len( c ) > 0 or tot == 0:\n print -1\n exit()\npar = tot / len( c )\ncnt = 0\nfor x in c:\n cnt += x - par\nif cnt != 0:\n print -1\n exit()\nprint par"}, {"source_code": "s=sum(map(int,raw_input().split()))\nif s==0 or s%5!=0:print -1\nelse:print s//5\n"}, {"source_code": "a = map(int, raw_input().split())\nif sum(a)%5==0 and sum(a)!=0:\n\tprint sum(a)/5\nelse:\n\tprint -1"}, {"source_code": "nums = [int(x) for x in input().split()]\nprint(sum(nums) // 5 if sum(nums) % 5 == 0 and sum(nums) != 0 else -1)\n"}, {"source_code": "s = sum(map(int, raw_input().split(' ')))\nprint (s // 5) if s > 0 and s % 5 == 0 else -1\n"}, {"source_code": "x=[int(a) for a in input().split()]\nif sum(x)!=0 and sum(x)%5==0:\n print(sum(x)//5)\nelse:\n print(-1)"}, {"source_code": "final_bet=[int(i) for i in input().split()]\nsum=0\nfor i in range(0,5,1):\n sum+=final_bet[i]\n\nif sum>0 and sum % 5 == 0:\n print(int(sum/5))\n\nelse:\n print(\"-1\")\n"}, {"source_code": "x = raw_input()\nlists = x.split(' ')\nadd = 0\nfor y in lists:\n add = add + int(y)\nif add==0:\n print '-1'\nelif add%5==0:\n print add/5\nelse:\n print '-1'\n"}, {"source_code": "a= []\na = map(int, raw_input().split())\n\nsum = 0\nfor i in range(5):\n\tsum+=a[i]\nif sum ==0:\n\tprint(-1)\nelif sum%5== 0:\n\tprint(sum / 5)\nelse:\n\tprint(-1)"}, {"source_code": "n = list(map(int,input().split()))\nif sum(n)%5 == 0 and sum(n) > 0 :\n\tprint(sum(n)//5)\nelse : \n\tprint(-1)\n"}, {"source_code": "def main():\n s = sum([int(i) for i in raw_input().split()])\n if s == 0:\n print -1\n elif s%5 == 0:\n print s/5\n else:\n print -1\n\nmain()\n"}, {"source_code": "coins = input()\ncoins = coins.split()\ncoins = map(int, coins)\n\ninitial = 0\nfor num in coins:\n initial += num\ninitial = initial/5\n\n\nif initial.is_integer():\n\tif int(initial) == 0:\n\t\tprint(-1)\n\telse:\n\t\tprint(int(initial))\nelse:\n\tprint(-1)"}, {"source_code": "cn = sum(map(int,input().split()))\nprint(cn//5 if cn%5 == 0 and cn>0 else '-1')"}, {"source_code": "c=list(map(int,input().split()))\nx=len(c)\ny=sum(c)\nif y%x==0 and y!=0:\n print(y//x)\nelse:\n print(-1)"}, {"source_code": "s = [int(i) for i in input().split()]\na = sum(s)\n\nif a%5!=0 or not a:\n\tprint(-1)\nelse:\n\tprint(a//5)"}, {"source_code": "a = list(map(int, input().split()))\nsm = sum(a)\nif sm == 0:\n print(-1)\nelif sm % 5 == 0:\n print(sm//5)\nelse:\n print(-1)\n\n"}, {"source_code": "temp = map(int,input().split(\" \"))\na1,a2,a3,a4,a5 = temp\nt = a1 + a2 + a3 + a4 + a5\nif t % 5 != 0:\n print(-1)\nelif t == 0:\n print(\"-1\")\nelse:\n print(int(t/5))"}, {"source_code": "def solve(num):\n n = len(num)\n sum = 0\n for num in nums:\n sum += num\n \n return -1 if sum == 0 or sum % n != 0 else int(sum / n)\n\n\nif __name__ == \"__main__\":\n nums = list(map(int, input().split(\" \")))\n print(solve(nums))"}, {"source_code": "a = list(map(int, input().split()))\ns = sum(a)\nif s % 5 == 0 and s > 0:\n print(int(s/5))\nelse:\n print(-1)\n\n\n"}, {"source_code": "# cook your dish here\nn=list(map(int,input().rstrip().split()))\n\nnn1=sum(n)\n\nif nn1%5==0 and nn1>0:\n print(int(nn1/5))\nelse:\n print(-1)\n"}, {"source_code": "l = list(map(int, input().split()))\nif sum(l) % len(l) == 0 and sum(l) != 0:\n print(int(sum(l) / len(l)))\nelse:\n print('-1')"}, {"source_code": "s = sum((map(int, input().split())))\nprint([s//5, -1][s%5>0 or s==0])"}, {"source_code": "a, b, c, d, e = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\ne= int(e)\nf = a+b+c+d+e\nif f%5!=0 or f ==0:\n print('-1')\nelse:\n print(int(f/5))\n \n"}, {"source_code": "bet = sum(list(map(int , input().split())))\nif bet%5!=0 or bet==0:\n print(-1)\nelse:\n print(bet//5)"}, {"source_code": "raw=input()\n\nraw=raw.split(\" \")\nraw=[int(x) for x in raw]\na=0\nfor x in raw:\n a=a+x\nif a==0:\n print(-1)\nelif a % 5 !=0:\n print(-1)\nelse:\n print(int(a/5))\n"}, {"source_code": "c1,c2,c3,c4,c5 = map(int,input().split())\nx = c1+c2+c3+c4+c5\nif x%5==0:\n if x==0:\n print(-1)\n else:\n print(x//5)\nelse:\n print(-1)"}, {"source_code": "c=list(map(int,input().split()))\ns=sum(c)\nm,n=divmod(s,5)\nif n==0 and m!=0:\n print(m)\nelse:\n print(-1)\n"}, {"source_code": "a=list(map(int,input().split()))\nif sum(a)%5==0 and sum(a)>0 and all(i>=0 for i in a):\n print(sum(a)//5)\nelse:\n print(-1)\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod_ = int(1e9) + 7\nmod = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve():\n n,m=1,10**6\n primes = {}\n arr=set([])\n for i in range(2, round(m ** 0.5) + 1):\n a = n // i\n b = m // i\n for k in range(max(2, a), b + 1):\n c = i * k\n primes[c] = 1\n\n for i in range(max(n, 2), m + 1):\n if i not in primes:\n arr.add(i)\n\n return arr\n\ndef main(): \n # n,k=map(int,input().split())\n arr=list(map(int,input().split()))\n ans=sum(arr)\n # temp=ans\n if ans%5==0 and ans//5>0:\n print(ans//5)\n else:\n print(-1)\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "c1, c2, c3, c4, c5 = map(int, input().split())\n\ns = c1 + c2 + c3 + c4 + c5\n\nif not(s%5) and s != 0: print(int(s/5))\nelse: print(-1)\n"}, {"source_code": "initial = sum(list(map(int, input().split()))) / 5\nprint(int(initial)) if initial.is_integer() and initial > 0 else print(-1)\n"}, {"source_code": "n = sum(list(map(int, input().split())))\nprint(n//5 if n % 5 == 0 and n != 0 else -1)"}, {"source_code": "sum=eval(raw_input().replace(' ','+'))\nprint [-1,sum/5][sum%5==0 and sum>0]"}, {"source_code": "a=[int(x) for x in raw_input().split()]\nif sum(a)%5==0 and sum(a)!=0:\n print sum(a)/5\nelse:\n print -1\n"}, {"source_code": "A=map(int,raw_input().split())\nif sum(A)==0:\n print \"-1\"\n exit()\n \nif sum(A)%5==0:\n print sum(A)/5\nelse:\n print \"-1\""}, {"source_code": "m = map(int, raw_input().split())\nif (sum(m) % 5 == 0) and (sum(m) != 0):\n print sum(m) / 5\nelse:\n print -1"}, {"source_code": "c = [int(x) for x in input().split(' ')]\n\nif sum(c) % len(c) == 0 and sum(c) > 0:\n ans = sum(c) // len(c)\nelse:\n ans = -1\nprint(ans)"}, {"source_code": "a = [int(i) for i in input().split()]\na = sum(a)\n\n\nif a%5==0 and a!=0:\n print(a//5)\nelse:\n print('-1')\n"}, {"source_code": "# A. Initial Bet\n\na, b, c, d, e = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\ne = int(e)\n\nif ((a+b+c+d+e)%5 == 0) and a+b+c+d+e != 0:\n print(int((a+b+c+d+e)/5))\nelse:\n print(\"-1\")"}, {"source_code": "a = map(int,raw_input().split())\na = reduce(lambda x,y:x+y,a)\nprint a/5 if a%5==0 and a!=0 else -1"}, {"source_code": "C=input().rstrip().split(' ')\np=list(C)\nS=0;\nfor i in range(0,len(p)):\n S+=int(p[i]);\nG=0;\nfor i in range(1,101):\n if (i*5) == S:\n G=1;\n V=i;\n break;\nif G==0:\n print(-1)\nelse:\n print(V);"}, {"source_code": "arr = list(map(int, input().strip().split()))\ns = sum(arr)\nif s % 5 == 0 and s//5 > 0:\n\tprint(s//5)\nelse:\n\tprint(-1)"}, {"source_code": "ls = list(map(int,input().split()))\ns = sum(ls)\nprint([s//5,-1][s%5 != 0 or not s])"}, {"source_code": "c=[int(x) for x in input().split()]\nif sum(c)%5==0 and sum(c) != 0:\n print(sum(c)//5)\nelse:\n print(-1)\n"}], "negative_code": [{"source_code": "a = sum(map(int, input().split()))\nif a % 5 == 0:\n print(a // 5)\nelse:\n print(-1)"}, {"source_code": "Jugadores=map(int,raw_input().split())\nsuma=0\nCantidad=len(Jugadores)\nfor k in range (Cantidad):\n suma+=Jugadores[k]\nif (suma==0):\n print 0\nelse:\n if(suma%Cantidad==0):\n print suma/Cantidad\n else:\n print -1\n"}, {"source_code": "li = list(map(int, input().split()))\nif 0 not in li and sum(li) < 5:\n print(-1)\nelse:\n print(int(sum(li) / 5))\n"}, {"source_code": "arr=list(map(int,input().split()))\nsum=0\nfor i in arr:\n sum+=i\nif sum%5==0:\n print(int(sum/5))\nelse:\n print(-1)\n"}, {"source_code": "l = list(map(int, input().split()))\nif sum(l)%len(l)==0:\n print(int(sum(l)/len(l)))\nelse:\n print('-1')"}, {"source_code": "def main():\n s = sum(list(map(int, input().split(' '))))\n ss = s // 5\n return ss if ss * 5 == s else -1\nprint(main())\n"}, {"source_code": "bets = [int(x) for x in input().split()]\nif sum(bets) % 5 == 0:\n print(sum(bets)//5)\nelse:\n print(-1)"}, {"source_code": "# your code goes here\narr=[int(x) for x in input().split()]\ns=sum(arr)\nif s%5==0:\n\tprint(s//5)\nelse:\n\tprint(\"-1\")"}, {"source_code": "a = input()\nstop1 = a.find(\" \")\nstop2 = a.find(\" \", stop1+1)\nstop3 = a.find(\" \", stop2+1)\nstop4 = a.find(\" \", stop3+1)\nf = int(a[:stop1])\nb = int(a[stop1+1:stop2])\nc = int(a[stop2+1:stop3])\nd = int(a[stop3+1:stop4])\ne = int(a[stop4+1:])\nprint((f+b+c+d+e)//5)\n"}, {"source_code": "coins = input()\ncoins = coins.split()\ncoins = map(int, coins)\n\ninitial = 0\nfor num in coins:\n initial += num\ninitial = initial/5\n\nif initial % 5 != 0:\n print(-1)\nelse:\n print(initial)"}, {"source_code": "a=[int(i) for i in input().split()]\ni=0\nh=0\nwhile i<len(a):\n h=h+a[i]\n i+=1\n"}, {"source_code": "a=map(int,raw_input().split())\nif sum(a)%5 : print -1\nelse : print sum(a)//5\n"}, {"source_code": "# A. Initial Bet\n\na, b, c, d, e = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\ne = int(e)\n\nif (a+b+c+d+e)%5 == 0:\n print(int((a+b+c+d+e)/5))\nelse:\n print(\"-1\")"}, {"source_code": "#-*- encoding:utf-8 -*-\n\n'''\n5\uba85\uc758 \ud50c\ub808\uc774\uc5b4\n\uac19\uc740 \ub3d9\uc804\uc744 \uac78\uace0, 1\uac1c\uc529 \ub3d9\uc804\uc744 \ub2e4\ub978 \ud50c\ub808\uc774\uc5b4\uc5d0\uac8c \uc804\ub2ec(\ubc18\ubcf5)\n\n\uc785\ub825\n\ub9c8\uc9c0\ub9c9\uc5d0 \uac00\uc9c0\uace0 \uc788\ub294 \ub3d9\uc804 \uac1c\uc218\n\ucd9c\ub825\n\ucd08\uae30 \ubc30\ud305\uac12(\ubd88\uac00\ub2a5 -1)\n\n'''\n\na, b,c,d,e = map(int, raw_input().split())\n\n\nif (a+b+c+d+e)%5 == 0 or (a+b+c+d+e) == 0:\n\tprint (a+b+c+d+e)/5\nelse :\n\tprint -1"}, {"source_code": "\n\n\ndef main():\n \n L = [ int(i) for i in raw_input().split(\" \") ]\n s = sum(L)\n \n if len(L) % s != 0:\n print -1\n else:\n print len(L)/s\n \nmain()"}, {"source_code": "l=lambda:map(int,raw_input().split())\na=l()\nn=len(a)\ns=sum(a)\nif s%n==0:\n print s/n \nelse:\n print '-1'"}, {"source_code": "filename = \"input1.txt\"\nimport sys\ncaonima = True\nif caonima:\n f = sys.stdin\nelse:\n f = open(filename)\n\na = map(int,f.readline().split())\nif sum(a)%3:\n print -1\nelse:\n print sum(a)/len(a)\n \n\n#with open( \"2.out\", \"w\") as f1:\n# for i in ans:\n# j = str(i)+'\\n'\n #print j\n# f1.write(j)\n \n \n"}, {"source_code": "c=list(map(int,input().split()))\nif sum(c)%5==0:\n print(sum(c)//5)\nelse:\n print(-1)"}, {"source_code": "import math\nimport sys,collections\nfrom sys import stdin, stdout \n#MAXN = 10000001\n\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef get_string(): return sys.stdin.readline().strip() \ndef input(): return sys.stdin.readline().strip()\n#spf = [0 for i in range(MAXN)] \ndef file():\n\tsys.stdin = open('input.py', 'r')\n\tsys.stdout = open('output.py', 'w') \ndef is_subsequence(x, y):\n \"\"\"Test whether x is a subsequence of y\"\"\"\n x = list(x)\n for letter in y:\n if x and x[0] == letter:\n x.pop(0)\n\n return not x \ndef sieve(): \n\tspf[1] = 1\n\tfor i in range(2, MAXN): \n\t\tspf[i] = i \n\tfor i in range(4, MAXN, 2): \n\t\tspf[i] = 2\n\n\tfor i in range(3, mt.ceil(mt.sqrt(MAXN))): \n\t\tif (spf[i] == i): \n\t\t\tfor j in range(i * i, MAXN, i): \n\t\t\t\tif (spf[j] == j): \n\t\t\t\t\tspf[j] = i \ndef getFactorization(x): \n\tret = list() \n\twhile (x != 1): \n\t\tret.append(spf[x]) \n\t\tx = x // spf[x] \n\n\treturn ret \ndef getFloor(A, x):\n\n (left, right) = (0, len(A) - 1)\n\n ind,floor = -1,-1\n while left <= right:\n mid = (left + right) // 2\n '''if A[mid] == x:\n return mid'''\n if x < A[mid]:\n right = mid - 1\n else:\n floor = A[mid]\n ind=mid\n left = mid + 1\n \n return ind\ndef check(st) : \n \n # Compute sum of digits \n n = len(st) \n digitSum = 0\n \n for i in range(0,n) : \n digitSum = digitSum + (int)(st[i]) \n \n # Check if sum of digits \n # is divisible by 9. \n return (digitSum % 9 == 0) \ndef isPowerOfTwo(n): \n if (n == 0): \n return False\n while (n != 1): \n if (n % 2 != 0): \n return False\n n = n // 2\n \n \n return True\ndef kitte(n):\n\tc=0\n\twhile(n!=0):\n\t\tn=n//2\n\t\tc+=1\n\treturn c\t\n\n#file()\n#sieve() \nmod=(10**9)+7\t\ndef main():\n\tl=get_array()\n\tif(len(set(l))==1):\n\t\tif(l[0]==0):\n\t\t\tprint(0)\n\t\t\texit()\n\tif(sum(l)%5==0):\n\n\t\tprint(sum(l)//5)\n\telse:\n\t\tprint(-1)\n\n\t\n\t\t\t\n\n\n\t\t\n\n\n\n\n\t\t\n\n\n\n\n\n\n\t\t\n\n\n\n\n\n\n\n\t\t\t\n\n\n\n\t\n\n\t\n\n\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\n\t\t\t\n\n\n\t\t\n\n\t\t\t\n\n\t\t\n\n\n\n\n\n\t\t\t\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\n\t\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "a = list(map(int,input().split()))\ns = sum(a)\nif s % 5 == 0:\n print(s//5)\nelse:\n print(-1)"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef main():\n A = list(map(int, input().split()))\n n = len(A)\n if sum(A) % n == 0:\n print(sum(A) // n)\n else:\n print(-1)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "li = list(map(int, input().split()))\nprint([sum(li)//5, '-1'][sum(li)%5 != 0])"}, {"source_code": "nums = [int(x) for x in input().split()]\nprint(sum(nums) // 5 if sum(nums) % 5 == 0 and sum(nums) == 0 else -1)\n"}, {"source_code": "l=list(map(int,input().split()))\nif(sum(l)==0):\n print(\"0\")\nelse:\n if (sum(l) % 5 == 0):\n print(int(sum(l) / 5))\n else:\n print(\"-1\")"}, {"source_code": "from __future__ import division\nfrom collections import Counter as ctr\nfrom math import ceil, log, factorial, sqrt\n# reads a line of input and converts into a list of ints\n# 1 1 3 => [1, 1, 3]\ndef rl():\n return [int(i) for i in raw_input().split()]\n\n# reads n lines of input (if n defined) and returns a list of strings\n# where each element is a line in the input\n# abc\n# abcdef\n# => ['abc', 'abcdef']\n# if n not defined, read first line to get number of lines\n# 2\n# abc\n# abcdef\n# => ['abc', 'abcdef']\ndef rm(n=None):\n if n is None:\n n = input()\n return [raw_input() for i in range(n)]\n\n# same as rm, except converts each line to a list of ints like rl\ndef rlm(n=None):\n if n is None:\n n = input()\n return [rl() for i in range(n)]\n\ndef yn(b):\n if b:\n print \"YES\"\n else:\n print \"NO\"\n\nn = rl()\ns = sum(n)\navg = s//len(n)\nif s == 0 or s % avg != 0:\n print -1\nelse:\n print avg"}, {"source_code": "temp = map(int,input().split(\" \"))\na1,a2,a3,a4,a5 = temp\nt = 0\nif (a1+a2+a3+a4+a5)%5==0:\n k = (a1 + a2 + a3 + a4 + a5) / 5\n if (a1 - k) > 0:\n t += (a1 - k)\n if (a2 - k) > 0:\n t += (a2 - k)\n if (a3 - k) > 0:\n t += (a3 - k)\n if (a4 - k) > 0:\n t += (a4 - k)\n if (a5 - k) > 0:\n t += (a5 - k)\n if t == 1:\n print(1)\n else:\n print(int(t-1))\nelse:\n print(\"-1\")"}, {"source_code": "a=[int(i) for i in input().split()]\nd=sum(a)\nif(d%len(a)==0):\n print(d//len(a))\nelse:\n print(-1)"}, {"source_code": "l=list(map(int,input().split()))\nif(sum(l)%5==0):\n print(int(sum(l)/5))\nelse:\n print(\"-1\")"}, {"source_code": "coins = input()\ncoins = coins.split()\ncoins = map(int, coins)\n\ninitial = 0\nfor num in coins:\n initial += num\ninitial = initial/5\n\nif initial.is_integer():\n print(int(initial))\nelse:\n print(-1)"}, {"source_code": "#!/usr/bin/python2.7\nn = sum(map(int, raw_input().split()))\nif n % 5: print -1\nelse: print n / 5\n"}, {"source_code": "coins = [int(n) for n in raw_input().split()]\n\nsoma = sum(coins)\n\nif soma%5==0:\n\tprint soma/5\nelse:\n\tprint -1\n"}, {"source_code": "ls = [int(i) for i in input().split()]\n\nval = sum(ls)\n\ninitial = val//len(ls)\nif val==0:\n print(\"0\")\nelif initial*len(ls)==val:\n print(initial)\nelse:\n print(\"-1\")"}, {"source_code": "a = sum(map(int,raw_input().split()))\nprint ['-1',a/5][a%5 == 0 or a == 0] "}, {"source_code": "c=list(map(int,input().split()))\nif sum(c)%5==0:\n print(sum(c)//5)\nelse:\n print(-1)"}, {"source_code": "x= input().split()\ns=0\nfor i in x:\n s+=int(i)\nif (s/5)-int(s/5) == 0:\n print(int(s/5))\nelse:\n print(-1)"}, {"source_code": "def main():\n s = sum([int(i) for i in raw_input().split()])\n if sum == 0:\n print -1\n elif s%5 == 0:\n print s/5\n else:\n print -1\n\nmain()\n"}, {"source_code": "bet = [int(i) for i in raw_input().split()]\nres = sum(bet)\nif res % 5 == 0:\n print res / 5\nelse:\n print -1\n"}, {"source_code": "Jugadores=map(int,raw_input().split())\nsuma=0\nCantidad=len(Jugadores)\nfor k in range (Cantidad):\n suma+=Jugadores[k]\nif(suma%Cantidad==0):\n print suma/Cantidad\nelse:\n print -1\n"}, {"source_code": "a=list(map(int,input().split()))\n\nx=max(a)\ny=min(a)\n\nfor i in range (y,x+1):\n\tt=[j-i for j in a]\n\tif(sum(t)==0):\n\t\tprint(i)\n\t\tbreak\nelse:\n\tprint(\"-1\")"}, {"source_code": "a = [int(i) for i in input().split()]\nif sum(a) % 5 == 0:\n print(sum(a) // 5)\nelif sum(a) == 0:\n print(0)\nelse:\n print(-1)"}, {"source_code": "'''\nCF problem 478A\n@autor Yergali B\n'''\na=list(map(int,input().split()))\nb=sum(a)\nif b%5==0:\n print(b//5)\nelse:\n print(-1)\n\n"}, {"source_code": "sum_=sum(map(int,raw_input().split()))\nif sum_%5==0 or sum_<>0:\n print sum_/5\nelse:\n print -1\n"}, {"source_code": "x= input().split()\ns=0\nfor i in x:\n s+=int(i)\nif s == 0 :\n print(0)\nelif (s/5)-int(s/5) == 0:\n print(int(s/5))\nelse:\n print(-1)"}, {"source_code": "a,b,c,d,e=[int(x) for x in input().split()]\nsum=a+b+c+d+e\nif sum%5==0:\n print(sum//5)\nelse:\n print(-1)"}, {"source_code": "import math\na=list(map(int,input().split()))\nn=sum(a)\nif(n%5==0):\n print(int(n/5))\nelif(n==0):\n print(\"0\")\nelse:\n print(\"-1\")"}, {"source_code": "numbers = map(int, raw_input().split())\nsum = 0\nfor i in numbers:\n\tsum += i\n\tif i > 100:\n\t\tprint -1\n\t\texit()\n\tif i < 0:\n\t\tprint -1\n\t\texit()\nmod = sum % 5\nif mod != 0:\n\tprint -1\nelse:\n\tprint sum/5"}, {"source_code": "y = sum(map(int,raw_input().split()))\nif y%5==0:\n print y/5\nelse:\n print -1\n"}, {"source_code": "c=list(map(int,input().split()))\nif sum(c)%5==0:\n print(sum(c)//5)\nelse:\n print(-1)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Jul 23 23:26:45 2020\n\n@author: thiva\n\"\"\"\n\n\nC = [int(s) for s in input().split()]\nif(sum(C) % 5 == 0):\n print(sum(C)//5)\nelse:\n print(-1)"}, {"source_code": "n = list(map(int,input().split()))\nif sum(n)%5 == 0 or sum(n) == 0 :\n\tprint(sum(n)//5)\nelse : \n\tprint(-1)\n"}, {"source_code": "pet = [int(z) for z in input().split()]\nx = sum(pet)%pet.__len__()\nif(x == 0):\n\tprint(sum(pet)//pet.__len__())\nelse:\n\tprint('-1')\n"}, {"source_code": "\na = [int(i) for i in input().split()]\na = sum(a)\n\nif a%5==0:\n print(a//5)\nelse:\n print('-1')\n"}, {"source_code": "l = list((map(int, input().split())))\nif abs(l[0]-l[2]) == abs(l[1]-l[3]):\n\tprint(l[0],l[3],l[2],l[1])\nelif l[0]==l[2]:\n\tprint(l[0]+abs(l[1]-l[3]),l[1],l[2]+abs(l[1]-l[3]),l[3])\nelif l[1]==l[3]:\n\tprint(l[0],l[1]+abs(l[0]-l[2]),l[2],l[3]+abs(l[0]-l[2]))\nelse:\n\tprint(-1)"}, {"source_code": "l = [int(x) for x in raw_input().split()]\nsl = sum(l)\nm = sl%5\nif not m:\n print sl/5\nelse:\n print -1\n"}, {"source_code": "x= input().split()\ns=0\nfor i in x:\n s+=int(i)\nif (s/5)-int(s/5) == 0:\n print(int(s/5))\nelse:\n print(-1)"}, {"source_code": "a=[int(x) for x in raw_input().split()]\nif sum(a)%5==0:\n print sum(a)/5\nelse:\n print -1\n"}, {"source_code": "num = input()\narr = []\ncount = 0\nfor i in range(0,len(num)):\n if num[i] == ' ':\n arr.append(int(num[count:i]))\n count = i+1\n elif i == len(num)-1:\n arr.append(int(num[count:len(num)]))\n\ncounting = 0\nfor i in arr:\n counting += i\n\nif counting%len(arr) == 0:\n print(int(counting/len(arr)))\nelse:\n print(-1)\n"}, {"source_code": "l=map(int,raw_input().split(' '))\nif(sum(l)%5==0):\n print sum(l)/5\nelse:\n print -1\n"}, {"source_code": "a,b,c,d,e=map(int,input().split())\ns=a+b+c+d+e\nif(s%5==0 or s==0):\n print(-1)\nelif(s%5==0):\n print(s//5)\n "}, {"source_code": "import math\nl=list(map(int,input().split()))\nn=sum(l)/len(l)\nif n%1:\n print(-1)\nelse:\n if n<=max(l):\n print(math.floor(n))\n else:\n print(-1)"}, {"source_code": "a,b,c,d,e=[int(t) for t in input().split()]\nv=int((a+b+c+d+e)/5)\nt=(a+b+c+d+e)%5\nif t==0:\n print(v)\nelse:\n print(-1)\n"}, {"source_code": "n=list(map(int,input().split()))\nla=list(range(min(n),max(n)+1))\nfor item in la:\n b=0\n j=0\n for x in n:\n if item-x>0:\n b+=item-x\n else:\n j+=x-item\n if b==j:\n print(item)\n break"}, {"source_code": "raw=input()\n\nraw=raw.split(\" \")\nraw=[int(x) for x in raw]\na=0\nfor x in raw:\n a=a+x\nif a==0:\n print(0)\nelif a % 5 !=0:\n print(-1)\nelse:\n print(int(a/5))\n"}, {"source_code": "a,b,c,d,e=[int(x) for x in input().split()]\nsum=a+b+c+d+e\nif sum%5==0:\n print(sum//5)\nelse:\n print(-1)"}, {"source_code": "'''input\n4 5 9 2 1\n'''\ns = sum(list(map(int, input().split())))\nif s % 5 == 0:\n\tprint(s//5)\nelse:\n\tprint(-1)"}, {"source_code": "import string\nimport math\n\nx=0\na = str(input(\"\"))\ns= str(a.replace(\" \",\"\"))\n\nfor i in range(5):\n\tx= int(s[i])+ x\n\t\nif x%5==0 and x!=0:\n\tprint(int(x/5))\nelse:\n\tprint(-1)\n\n\n"}, {"source_code": "a = sum([int(i) for i in input().split(' ')])\nprint((a//5) if (a%5) == 0 else -1)\n"}, {"source_code": "n=list(map(int,input().split()))\nla=list(range(min(n),max(n)+1))\nfor item in la:\n b=0\n j=0\n for x in n:\n if item-x>0:\n b+=item-x\n else:\n j+=x-item\n if b==j:\n print(item)\n break"}, {"source_code": "a = list(map(int, raw_input().split(\" \")))\n\ns = 0\n\nfor i in range(len(a)):\n s+= a[i]\n\nif s % len(a) == 0:\n print s/len(a)\nelse:\n print \"-1\""}, {"source_code": "a=list(map(int, input().split()))\ns=sum(a)\nif not s%5:\n\tprint(s//5)\nelse:\n\tprint(-1)"}, {"source_code": "x= input().split()\ns=0\nfor i in x:\n s+=int(i)\nif s == 0 :\n print(0)\nelif (s/5)-int(s/5) == 0:\n print(int(s/5))\nelse:\n print(-1)\n\n"}, {"source_code": "a = input().split(' ')\nfor i in range(len(a)):\n a[i] = int(a[i])\nsums = a[0] + a[1] + a[2] + a[3] + a[4]\nif sums % 5 == 0:\n print(int(sums // 5))\nelse:\n print(\"-1\")\n"}, {"source_code": "l = [int(x) for x in input().split()]\ns = sum(l)\nd = s/5\nif d==\"0\":\n print(\"-1\")\nelif d-(s//5)>0: \n print(\"-1\")\nelse:\n print(int(d))"}, {"source_code": "sum=eval(raw_input().replace(' ','+'))\nprint [-1,sum/5][sum%5==0]"}, {"source_code": "lst=list(map(int,input().split()))\nprint('-1' if sum(lst)%5 else sum(lst)//5)\n"}, {"source_code": "a,b,c,d,e=map(int,input().split())\nn=(a+b+c+d+e)\nif n%5!=0:\n print(-1)\nelse:\n print(n/5)\n"}, {"source_code": "#------------------------------what is this I don't know....just makes my mess faster--------------------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#----------------------------------Real game starts here--------------------------------------\nc = list(map(int, input().split()))\nif sum(c) % 5 == 0:\n print(int(sum(c)/5))\nelse:\n print(-1)"}, {"source_code": "inp = raw_input().strip().split()\n\ntotal = 0\nfor i in range(0,len(inp)):\n a = int(inp[i])\n total += a\n\n\nm = total % 5\nx = total / 5\n\nif m == 0:\n print x\nelse:\n print -1\n"}, {"source_code": "s = input().split(\" \")\nn1 = int(s[0])\nn2 = int(s[1])\nn3 = int(s[2])\nn4 = int(s[3])\nn5 = int(s[4])\n\nif((n1 + n2 + n3 + n4 + n5) % 5 == 0):\n print((n1 + n2 + n3 + n4 + n5) // 5)\nelse:\n print(-1)"}, {"source_code": "# Task to find intitial bet.\n# \n# \n# \n# Output:\n#\tbet_size(int) - the amount of initail bet.\n\n\ndef main():\n\tbets = list(map(int, input().split()))\n\tprint(bets)\n\tif sum(bets) % 5 == 0:\n\t\tprint(int(sum(bets) / 5))\n\telse:\n\t\tprint(-1)\n\n\nif __name__ == \"__main__\":\n\tmain()\n"}, {"source_code": "a = input().split(' ')\nfor i in range(len(a)):\n a[i] = int(a[i])\nsums = int(a[0] + a[1] + a[2] + a[3] + a[4])\nif sums % 5 == 0:\n print(int(sums // 5))\nelse:\n print(\"-1\")"}, {"source_code": "x = raw_input()\nlists = x.split(' ')\nadd = 0\nfor y in lists:\n add = add + int(y)\nif add%5==0:\n print add/5\nelse:\n print '-1'"}, {"source_code": "a = list(map(int, raw_input().split(\" \")))\n\ns = 0\n\nfor i in range(len(a)):\n s+= a[i]\n\nif s % len(a) == 0:\n print s/len(a)\nelse:\n print \"-1\""}, {"source_code": "c1, c2, c3, c4, c5 = [int(i) for i in input().split()]\ns = c1 + c2 + c3 + c4 + c5\nif s % 5 == 0:\n print(s // 5)\n \nelse:\n print(-1)"}, {"source_code": "n=list(map(int,input().split()))\n\nif sum(n)%5==0 :\n\tprint(sum(n)//5)\nelse :\n\tprint(-1)"}, {"source_code": "# your code goes here\n\na,b,c,d,e = map(int,raw_input().split())\nsum1 = a+b+c+d+e\nif sum1%5 == 0:\n\tprint sum1/5\nelse:\n\tprint -1\n"}, {"source_code": "l= list(map(int,input().split()))\n\ns=sum(l)\nif s%5==0:\n print(s/5)\nelse:\n print(\"-1\")"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n l=LI()\n\n if sum(l)%5!=0 or sum(l)==0:\n return -1\n\n return sum(l)//5-min(l)\n\nprint(main())\n"}, {"source_code": "list1=[int(x) for x in input().split()]\nx=sum(list1)\nif x%5==0:\n print(int(x/5))\nelif x==0:\n print(-1)\nelse:\n print(-1)"}, {"source_code": "import math\nimport sys,collections\nfrom sys import stdin, stdout \n#MAXN = 10000001\n\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef get_string(): return sys.stdin.readline().strip() \ndef input(): return sys.stdin.readline().strip()\n#spf = [0 for i in range(MAXN)] \ndef file():\n\tsys.stdin = open('input.py', 'r')\n\tsys.stdout = open('output.py', 'w') \ndef is_subsequence(x, y):\n \"\"\"Test whether x is a subsequence of y\"\"\"\n x = list(x)\n for letter in y:\n if x and x[0] == letter:\n x.pop(0)\n\n return not x \ndef sieve(): \n\tspf[1] = 1\n\tfor i in range(2, MAXN): \n\t\tspf[i] = i \n\tfor i in range(4, MAXN, 2): \n\t\tspf[i] = 2\n\n\tfor i in range(3, mt.ceil(mt.sqrt(MAXN))): \n\t\tif (spf[i] == i): \n\t\t\tfor j in range(i * i, MAXN, i): \n\t\t\t\tif (spf[j] == j): \n\t\t\t\t\tspf[j] = i \ndef getFactorization(x): \n\tret = list() \n\twhile (x != 1): \n\t\tret.append(spf[x]) \n\t\tx = x // spf[x] \n\n\treturn ret \ndef getFloor(A, x):\n\n (left, right) = (0, len(A) - 1)\n\n ind,floor = -1,-1\n while left <= right:\n mid = (left + right) // 2\n '''if A[mid] == x:\n return mid'''\n if x < A[mid]:\n right = mid - 1\n else:\n floor = A[mid]\n ind=mid\n left = mid + 1\n \n return ind\ndef check(st) : \n \n # Compute sum of digits \n n = len(st) \n digitSum = 0\n \n for i in range(0,n) : \n digitSum = digitSum + (int)(st[i]) \n \n # Check if sum of digits \n # is divisible by 9. \n return (digitSum % 9 == 0) \ndef isPowerOfTwo(n): \n if (n == 0): \n return False\n while (n != 1): \n if (n % 2 != 0): \n return False\n n = n // 2\n \n \n return True\ndef kitte(n):\n\tc=0\n\twhile(n!=0):\n\t\tn=n//2\n\t\tc+=1\n\treturn c\t\n\n#file()\n#sieve() \nmod=(10**9)+7\t\ndef main():\n\tl=get_array()\n\tif(len(set(l))==1):\n\t\tprint(l[0])\n\t\texit()\n\tif(sum(l)%5==0):\n\n\t\tprint(sum(l)//5)\n\telse:\n\t\tprint(-1)\n\n\t\n\t\t\t\n\n\n\t\t\n\n\n\n\n\t\t\n\n\n\n\n\n\n\t\t\n\n\n\n\n\n\n\n\t\t\t\n\n\n\n\t\n\n\t\n\n\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\n\t\t\t\n\n\n\t\t\n\n\t\t\t\n\n\t\t\n\n\n\n\n\n\t\t\t\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\n\t\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "li = list(map(int, input().split()))\nprint([sum(li)//5, '-1'][sum(li)%5 != 0])"}, {"source_code": "c = [int(x) for x in input().split()]\nn = sum(c)/5\nif n == int(n):\n print(n)\nelse:\n print('-1')"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n l=LI()\n\n if sum(l)%5!=0:\n return -1\n\n return sum(l)//5-min(l)\n\nprint(main())\n"}, {"source_code": "a = [int(x) for x in input().split()]\n\nif len(set(a)) != 1:\n if sum(a)%5==0:\n print(int(sum(a)/5))\n else:\n print(-1)\nelse:\n print(-1)"}, {"source_code": "n = raw_input().split()\ns = int(n[0])+int(n[1])+int(n[2])+int(n[3])+int(n[4])\nif s%5==0 and n[0]<>'0':\n print (s/5)\nelse:\n print(-1)\n"}, {"source_code": "s=raw_input(\"\")\nl=s.split(\" \")\nfor i in range(len(l)):\n\tl[i]=int(l[i])\nif sum(l)%len(l)==0:\n\tprint sum(l)/len(l)\nelse:\n\tif max(l)==0:\n\t\tprint \"0\"\n\telse:\n\t\tprint \"-1\"\n"}, {"source_code": "def gcd(a,b):\n if a == 0: return b\n return gcd(b % a, a)\n\ndef solve():\n l, r = map(int, input().split())\n if l * 2 > r:\n print(-1,-1)\n else:\n print(l,l*2)\n\na,b,c,d,e = map(int, input().split())\n# print(a,b,c,d,e)\nsum = a + b + c + d + e\n\nif sum % 5 ==0:\n print(sum/5)\nelse:\n print(-1)\n\n # C = [0]; ptr = 0; i = 1; begin = False\n# while i < len(B):\n# if B[i] == B[ptr]:\n# ptr += 1\n# C.append(ptr)\n# i += 1\n# else:\n# # Update till prefix matched\n# if ptr != 0:\n# ptr = C[ptr-1]\n# # Also no i increment\n# else:\n# C.append(0)\n# i += 1\n# print(C)\n"}, {"source_code": "arr = input().split(\" \")\nn = len(arr)\narr = map(lambda x: int(x), arr)\nif sum(arr) % n == 0:\n print(sum(arr))\nelse:\n print(-1)"}, {"source_code": "lst = [int(i) for i in input().split()]\nif sum(lst) % 5 == 0:\n print(sum(lst) // 5)\nelse:\n print(-1)\n"}, {"source_code": "inp = raw_input().strip().split()\n\ntotal = 0\nfor i in range(0,len(inp)):\n a = int(inp[i])\n total += a\n\n\nm = total % 5\nx = total / 5\n\nif m == 0:\n print x\nelse:\n print \"-1\"\n"}], "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20"} {"source_code": "import itertools\n\ndef transform(die, config):\n config = zip('012345', config)\n new = [None, None, None, None, None, None]\n for i in config:\n new[int(i[1])] = die[int(i[0])]\n return tuple(new)\n\ndef getRotations(die):\n configs = ['024135', '135024', '521430', '425031', '215043', '254103',\n '534120', '103254', '542310', '304152', '351402', '012345',\n '152304', '043215', '240513', '453201', '310542', '513240',\n '201453', '430521', '120534', '345012', '031425', '402351']\n ret = set([])\n for i in configs:\n ret.add(transform(die, i))\n\n return ret\n\ndef main():\n die = tuple(raw_input())\n configs = set([])\n ans = 0\n \n for i in itertools.permutations(die, 6):\n if i not in configs:\n configs |= getRotations(i)\n ans += 1\n\n return ans\n\nif __name__ == '__main__':\n print main()\n", "positive_code": [{"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]\n"}, {"source_code": "\n\ns=input()\ns=sorted(s)\ncount=1\nans=[]\nfor i in range(1,len(s)):\n if(s[i]==s[i-1]):\n count+=1\n else:\n ans.append(count)\n count=1\nans.append(count)\nans.sort()\nif(len(ans)==1):\n print(1)\nif(len(ans)==2):\n if(ans[0]==1):\n print(1)\n else:\n print(2)\nif(len(ans)==3):\n if(len(set(ans))==1):\n print(6)\n elif(ans==[1,1,4]):\n print(2)\n elif(ans==[1,2,3]):\n print(3)\nif(len(ans)==4):\n if(ans==[1,1,1,3]):\n print(5)\n elif(ans==[1,1,2,2]):\n print(8)\nif(len(ans)==6):\n print(30)\nif(len(ans)==5):\n print(15)\n \n"}, {"source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"3\")\n elif amount[1] == 1:\n print(\"5\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"6\")\n elif amount[1] == 2:\n print(\"8\")\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n"}, {"source_code": "s = raw_input()\n\nglobal p,q,d,ans\np = [False]*6\nq = ['']*6 \nans = 0\nd = {}\ndef dfs(deg):\n\tglobal p\n\tglobal q\n\tglobal ans\n\tglobal d\n\tif deg < 6:\n\t\tfor i in range(6):\n\t\t\tif not p[i]:\n\t\t\t\tp[i] = True\n\t\t\t\tq[deg] = s[i]\n\t\t\t\tdfs(deg+1)\n\t\t\t\tp[i] = False\n\t\treturn\n\tz = (q[0],q[1],q[2],q[3],q[4],q[5])\n\tif z in d:\n\t\treturn\n\tans += 1\n\tfor i in range(4):\n\t\ttmp = q[1]\n\t\tq[1] = q[2]\n\t\tq[2] = q[4]\n\t\tq[4] = q[3]\n\t\tq[3] = tmp\n\t\tfor j in range(4):\n\t\t\ttmp = q[0]\n\t\t\tq[0] = q[2]\n\t\t\tq[2] = q[5]\n\t\t\tq[5] = q[3]\n\t\t\tq[3] = tmp\n\t\t\tfor k in range(4):\n\t\t\t\ttmp = q[0]\n\t\t\t\tq[0] = q[1]\n\t\t\t\tq[1] = q[5]\n\t\t\t\tq[5] = q[4]\n\t\t\t\tq[4] = tmp\n\t\t\t\tz = (q[0],q[1],q[2],q[3],q[4],q[5])\n\t\t\t\td[z] = True\n\ndfs(0)\nprint ans\n"}, {"source_code": "from itertools import *\n\nl1=[1,2,3,0,4,5]\nl2=[4,1,5,3,2,0]\nl3=[0,4,2,5,3,1]\n\ndef perm(l,p):\n return ''.join([l[c] for c in p])\n\ndef incr_inst(orig):\n curr=orig\n s=set()\n r=range(4)\n for i in r:\n for j in r:\n for k in r:\n s.add(curr)\n curr = perm(curr,l1)\n curr = perm(curr,l3)\n curr = perm(curr,l2)\n return min(list(s))\n\norig=raw_input()\n\ns=set()\nfor c in permutations(orig):\n s.add(incr_inst(''.join(list(c))))\nprint len(s)"}, {"source_code": "from itertools import *\n\nl1=[1,2,3,0,4,5]\nl2=[4,1,5,3,2,0]\nl3=[0,4,2,5,3,1]\n\ndef perm(l,p):\n\treturn ''.join([l[c] for c in p])\n\ndef incr_inst(orig):\n\tcurr=orig\n\ts=set()\n\tr=range(4)\n\tfor i in r:\n\t\tfor j in r:\n\t\t\tfor k in r:\n\t\t\t\ts.add(curr)\n\t\t\t\tcurr = perm(curr,l1)\n\t\t\tcurr = perm(curr,l3)\n\t\tcurr = perm(curr,l2)\n\treturn min(list(s))\n\norig=raw_input()\n\ns=set()\nfor c in permutations(orig):\n\ts.add(incr_inst(''.join(list(c))))\nprint len(s)\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport itertools\n\n\ndef ap(p):\n for i in xrange(4):\n yield p[i:4] + p[:i] + p[4:]\n\ndef ap2(p):\n yield p[0]+p[1]+p[2]+p[3]+p[4]+p[5]\n yield p[5]+p[1]+p[4]+p[3]+p[0]+p[2]\n yield p[2]+p[1]+p[0]+p[3]+p[5]+p[4]\n yield p[4]+p[1]+p[5]+p[3]+p[2]+p[0]\n\ndef gap(p):\n for p2 in ap(p):\n for p3 in ap2(p2):\n for p4 in ap(p3):\n yield p4\n\ns = set([])\nk = 0\nfor p in itertools.permutations([c for c in raw_input()]):\n fl = True\n for pp in gap(p):\n if not pp in s:\n if fl:\n fl = False\n k += 1\n s.add(pp)\nprint k\n"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint(res[s])\n"}, {"source_code": "t = [\n [0,1,2,3,4,5],\n [0,2,4,1,3,5],\n [0,4,3,2,1,5],\n [0,3,1,4,2,5],\n [2,1,5,0,4,3],\n [5,1,3,2,4,0],\n [3,1,0,5,4,2],\n [1,5,2,3,0,4],\n [5,4,2,3,1,0],\n [4,0,2,3,5,1],\n [1,2,0,5,3,4],\n [2,0,1,4,5,3],\n [2,5,4,1,0,3],\n [4,3,0,5,2,1],\n [4,2,5,0,3,1],\n [3,5,1,4,0,2],\n [3,0,4,1,5,2],\n [1,3,5,0,2,4],\n [1,0,3,2,5,4],\n [4,5,3,2,0,1],\n [2,4,0,5,1,3],\n [3,4,5,0,1,2],\n [5,2,1,4,3,0],\n [5,3,4,1,2,0],\n]\n\n\ns = raw_input().strip()\na = set()\nfor i in range(720):\n u = [0,1,2,3,4,5]\n v = []\n val = i\n for k in range(6,0,-1):\n v.append(u[val%k])\n u.remove(u[val%k])\n val /= k\n best = ''\n ss = ''.join([s[j] for j in v])\n for i in range(24):\n sss = ''.join(map(ss.__getitem__,t[i]))\n if best=='' or sss<best:\n best = sss\n a.add(best)\nprint len(a)\n\n\n"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]\n"}, {"source_code": "from itertools import permutations as p\n\ndef equivalent(s):\n alts = []\n ind = [[0,1,2,3,4,5],\n [0,2,3,4,1,5],\n [0,3,4,1,2,5],\n [0,4,1,2,3,5],\n [3,0,2,5,4,1],\n [2,0,1,5,3,4],\n [1,0,4,5,2,3],\n [4,0,3,5,1,2],\n [4,1,0,3,5,2],\n [3,4,0,2,5,1],\n [2,3,0,1,5,4],\n [1,2,0,4,5,3],\n ##\n [5,3,2,1,4,0],\n [5,2,1,4,3,0],\n [5,1,4,3,2,0],\n [5,4,3,2,1,0],\n [5,1,4,3,2,0],\n [5,4,3,2,1,0],\n [5,3,2,1,4,0],\n [5,2,1,4,3,0],\n [1,5,2,0,4,3],\n [4,5,1,0,3,2],\n [3,5,4,0,2,1],\n [2,5,3,0,1,4],\n [2,1,5,3,0,4],\n [3,2,5,4,0,1],\n [4,3,5,1,0,2],\n [1,4,5,2,0,3]]\n for ind_poss in ind:\n alts.append(\"\".join([s[i] for i in ind_poss]))\n return alts\n\ns = raw_input()\na = set()\n\nfor q in p(s):\n z = equivalent(q)\n if not any(map(lambda x: x in a, z)):\n a.add(z[0])\n\nprint len(a)\n#print a"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "# Author : ct.Liu\n# Create Time : 2011-07-26 12:49:26\n\nimport itertools, sys\n\ndir1 = (\n\t\t(0, 1, 2, 3, 4, 5),\n\t\t(1, 0, 2, 5, 4, 3),\n\t\t(2, 4, 0, 5, 1, 3),\n\t\t(4, 2, 0, 3, 1, 5),\n\t\t(3, 5, 0, 2, 1, 4),\n\t\t(5, 3, 0, 4, 1, 2)\n\t\t)\n\ndir2 = (\n\t\t(0, 1, 2, 3),\n\t\t(1, 2, 3, 0),\n\t\t(2, 3, 0, 1),\n\t\t(3, 0, 1, 2)\n\t\t)\n\ndef doit(s, ans):\n\tfor per in ans:\n\t\tfor i in range(6):\n\t\t\ts1 = []\n\t\t\tfor j in range(6):\n\t\t\t\ts1.append(s[dir1[i][j]])\n\t\t\tif per[0] == s1[0] and per[1] == s1[1]:\n\t\t\t\ts2 = s1[2:]\n\t\t\t\tfor j in range(4):\n\t\t\t\t\tc = 0\n\t\t\t\t\tfor k in range(4):\n\t\t\t\t\t\tif per[2 + k] == s2[dir2[j][k]]:\n\t\t\t\t\t\t\tc += 1\n\t\t\t\t\tif c == 4:\n\t\t\t\t\t\treturn \n\tans.append(list(s))\n#\tprint ans\n\ns = [c for c in sys.stdin.readline().strip()]\nans = []\n\nfor p in itertools.permutations(s):\n\tdoit(p, ans)\n\nprint len(ans)\n\n# EDIT BY VIM\n\n"}, {"source_code": "from sys import stdin, stdout\nfrom itertools import permutations as perms \n\ndef rot1(ls):\n\tls[0], ls[5], ls[1], ls[4]=ls[5], ls[1], ls[4], ls[0]\n\treturn ls\ndef rot2(ls):\n\tls[0], ls[2], ls[1], ls[3]=ls[2], ls[1], ls[3], ls[0]\n\treturn ls\ndef rot3(ls):\n\tls[5], ls[2], ls[4], ls[3]=ls[2], ls[4], ls[3], ls[5]\n\treturn ls;\ndef rot4(ls):\n\tls=[ls[4], ls[5], ls[3], ls[2], ls[0], ls[1]]\n\treturn ls\n\ndef main():\n\tline=stdin.readline().rstrip()\n\n\tl=list(set(list(perms(line))))\n\tl=map(list, l)\n\n\tcube_sets=set()\n\tfor el in l:\n\t\tinsert=True\n\t\tfor r in range(2*4*4*4):\n\t\t\trot=r\n\t\t\ttmp=el\n\n\t\t\tfor f in [rot1, rot2, rot3]:\n\t\t\t\tfor _ in range(int(rot)%4):\n\t\t\t\t\ttmp=f(tmp)\n\t\t\t\trot/=4\n\t\t\tif rot%2==1: tmp=rot4(tmp)\n\n\t\t\tif tuple(tmp) in cube_sets:\n\t\t\t\tinsert=False\n\t\t\t\tbreak\n\t\tif insert: cube_sets.add(tuple(el))\n\n\tstdout.write(str(len(cube_sets))+'\\n')\n\nif __name__=='__main__':\n\tmain()\n"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]\n"}, {"source_code": "from itertools import permutations\npm=permutations\n\ndef RotLL(f,t,r):\n L=LL[-1]\n for _ in range(f): L = (L[0],L[1],L[5],L[4],L[2],L[3])\n for _ in range(t): L = (L[3],L[2],L[0],L[1],L[4],L[5])\n for _ in range(r): L = (L[5],L[4],L[2],L[3],L[0],L[1])\n LL.append(L)\n\nJJ=raw_input()\nLL=[(0,1,2,3,4,5)]\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,1,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,1,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,1,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(0,1,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(0,0,2)\nRotLL(1,0,0)\nRotLL(1,0,0)\nRotLL(1,0,0)\n\nRR=[]\nfor i in pm(JJ):\n if all(RR.count((i[L[0]],i[L[1]],i[L[2]],i[L[3]],i[L[4]],i[L[5]]))==0 for L in LL): RR.append(i)\n\nprint len(RR)"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]\n"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n (6,): 1,\n (1, 5): 1,\n (2, 4): 2,\n (1, 1, 4): 2,\n (3, 3): 2,\n (1, 2, 3): 3,\n (1, 1, 1, 3): 5,\n (2, 2, 2): 6,\n (1, 1, 2, 2): 8,\n (1, 1, 1, 1, 2): 15,\n (1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from itertools import *\n\nl1=[1,2,3,0,4,5]\nl2=[4,1,5,3,2,0]\nl3=[0,4,2,5,3,1]\n\ndef perm(l,p):\n\treturn ''.join([l[c] for c in p])\n\ndef incr_inst(orig):\n\tcurr=orig\n\ts=set()\n\tr=range(4)\n\tfor i in r:\n\t\tfor j in r:\n\t\t\tfor k in r:\n\t\t\t\ts.add(curr)\n\t\t\t\tcurr = perm(curr,l1)\n\t\t\tcurr = perm(curr,l3)\n\t\tcurr = perm(curr,l2)\n\treturn min(list(s))\n\norig=raw_input()\n\ns=set()\nfor c in permutations(orig):\n\ts.add(incr_inst(''.join(list(c))))\nprint len(s)\n\n"}, {"source_code": "\ndef det(mat):\n [(a11,a12,a13),(a21,a22,a23),(a31,a32,a33)]=mat\n return a11*a22*a33+a12*a23*a31+a13*a21*a32-(a13*a22*a31+a12*a21*a33+a11*a23*a32)\n\nls=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)]\ntranses=[(l1,l2,l3) for l1 in ls for l2 in ls for l3 in ls if det((l1,l2,l3))==1]\n\nposes=list(ls)\n\ndef mult(trans, l):\n return tuple( sum(trans[i][j]*l[j] for j in xrange(3) ) for i in xrange(3) )\n\ndef f(ind, trans):\n pos=poses[ind]\n newpos=mult(trans, pos)\n return poses.index(newpos) \n\ndef newsequence(seq, trans):\n return \"\".join(seq[f(ind, trans)] for ind in xrange(6))\n\ndef newsequences(seq, transes):\n return [newsequence(seq,trans) for trans in transes]\n\ndef perm(s):\n if len(s)<=1:\n return [s]\n return [p[:i]+s[0]+p[i:] for i in xrange(len(s)) for p in perm(s[1:])]\n\ndef readints():\n return map(int,raw_input().split())\n\ndef main():\n x=perm(raw_input())\n z=set([])\n for s in x:\n ms=min(newsequences(s, transes))\n #print s,ms\n z.add(ms)\n print len(z)\n pass\n\n\n\nif __name__=='__main__':\n main()\n\n\n"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]\n"}, {"source_code": "Line=raw_input()\nColors=[]\nfor c in Line:Colors.append(c)\nGlobal=set()\nAns=0\n#print Colors\n\ndef LtoS(L):\n S=\"\"\n for c in L:S=S+str(c)\n return S\n\ndef moveUp(L):\n Colors2=[0]*6\n Colors2[0]=L[3]\n Colors2[1]=L[5]\n Colors2[4]=L[4]\n Colors2[2]=L[2]\n Colors2[3]=L[1]\n Colors2[5]=L[0]\n return Colors2\ndef moveRight(L):\n Colors2=[0]*6\n Colors2[0]=L[4]\n Colors2[1]=L[2]\n Colors2[5]=L[5]\n Colors2[3]=L[3]\n Colors2[2]=L[0]\n Colors2[4]=L[1]\n return Colors2\ndef Turn(L):\n Colors2=[0]*6\n Colors2[0]=L[0]\n Colors2[1]=L[1]\n Colors2[2]=L[5]\n Colors2[4]=L[3]\n Colors2[5]=L[4]\n Colors2[3]=L[2]\n return Colors2\n\n\n\n\nitern=0\nFuckingNew=False\nfor st1 in xrange(6):\n for st2 in xrange(6):\n for st3 in xrange(6):\n for st4 in xrange(6):\n for st5 in xrange(6):\n for st6 in xrange(6):\n itern+=1\n s=set()\n s.add(st1)\n s.add(st2)\n s.add(st3)\n s.add(st4)\n s.add(st5)\n s.add(st6)\n if(len(s)!=6):continue\n FuckingNew=False\n List=[Colors[st1],Colors[st2],Colors[st3],Colors[st4],Colors[st5],Colors[st6]]\n def check():\n global FuckingNew\n global Ans\n # print List\n if not LtoS(List) in Global:\n if not FuckingNew:\n Ans=Ans+1\n FuckingNew=True\n # print Global\n Global.add(LtoS(List))\n for c in xrange(4):\n check()\n List=Turn(List)\n List=moveUp(List)\n for c in xrange(4):\n check()\n List=Turn(List)\n List=moveUp(List)\n for c in xrange(4):\n check()\n List=Turn(List)\n List=moveUp(List)\n for c in xrange(4):\n check()\n List=Turn(List)\n List=moveUp(List)\n for c in xrange(4):\n check()\n List=Turn(List)\n List=moveRight(List)\n for c in xrange(4):\n check()\n List=Turn(List)\n List=moveRight(List)\n List=moveRight(List)\n for c in xrange(4):\n check()\n List=Turn(List)\n\n # print itern,Global\n\n\n\n\n\n\n #Kataem:\n\n#print Global\nprint Ans\n \n\n\n"}, {"source_code": "#!/usr/bin/python\nimport itertools, math, os, random, re, sys\nrandom.seed (1234)\n\n# 4 4 2\n# 0123 1230 4153\n# 5 5 0\n\ndef r1 (p):\n\treturn [p[1], p[2], p[3], p[0], p[4], p[5]]\n\ndef r2 (p):\n\treturn [p[4], p[1], p[5], p[3], p[2], p[0]]\n\ns = [c for c in sys.stdin.readline ().strip ()]\nt = []\nfor p in itertools.permutations (s):\n\tm = ['Z', 'Z', 'Z', 'Z', 'Z', 'Z']\n\tfor i in range (4):\n\t\tfor j in range (4):\n\t\t\tfor k in range (4):\n\t\t\t\tm = min (m, p)\n#\t\t\t\tprint p\n\t\t\t\tp = r2 (p)\n\t\t\tp = r1 (p)\n\t\tp = r2 (p)\n\tt += [''.join (m)]\nt = list (set (t))\n#print t\nprint len (t)\n"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport itertools\n\n\ndef ap(p):\n for i in xrange(4):\n yield p[i:4] + p[:i] + p[4:]\n\ndef ap2(p):\n yield p[0]+p[1]+p[2]+p[3]+p[4]+p[5]\n yield p[5]+p[1]+p[4]+p[3]+p[0]+p[2]\n yield p[2]+p[1]+p[0]+p[3]+p[5]+p[4]\n yield p[4]+p[1]+p[5]+p[3]+p[2]+p[0]\n\ndef gap(p):\n for p2 in ap(p):\n for p3 in ap2(p2):\n for p4 in ap(p3):\n yield p4\n\ns = set([])\nk = 0\nfor p in itertools.permutations([c for c in raw_input()]):\n fl = True\n for pp in gap(p):\n if not pp in s:\n if fl:\n fl = False\n k += 1\n s.add(pp)\nprint k\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport itertools\n\n\ndef ap(p):\n for i in xrange(4):\n yield p[i:4] + p[:i] + p[4:]\n\ndef ap2(p):\n yield p[0]+p[1]+p[2]+p[3]+p[4]+p[5]\n yield p[5]+p[1]+p[4]+p[3]+p[0]+p[2]\n yield p[2]+p[1]+p[0]+p[3]+p[5]+p[4]\n yield p[4]+p[1]+p[5]+p[3]+p[2]+p[0]\n\ndef gap(p):\n for p2 in ap(p):\n for p3 in ap2(p2):\n for p4 in ap(p3):\n yield p4\n\ns = set([])\nk = 0\nfor p in itertools.permutations([c for c in raw_input()]):\n fl = True\n for pp in gap(p):\n if not pp in s:\n if fl:\n fl = False\n k += 1\n s.add(pp)\nprint k\n"}], "negative_code": [{"source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"5\")\n elif amount[1] == 1:\n print(\"5\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"4\")\n elif amount[1] == 2:\n print(\"8\")\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n"}, {"source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"5\")\n elif amount[1] == 1:\n print(\"5\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"4\")\n elif amount[1] == 2:\n print(\"4\")\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n"}, {"source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"3\")\n elif amount[1] == 1:\n print(\"5\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"4\")\n elif amount[1] == 2:\n print(\"8\")\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n"}, {"source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"5\")\n elif amount[1] == 1:\n print(\"5\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"4\")\n elif amount[1] == 2:\n print(\"5\")\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n"}, {"source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"5\")\n elif amount[1] == 1:\n print(\"5\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"4\")\n elif amount[1] == 2:\n print(\"6\")\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n"}, {"source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"4\")\n elif amount[1] == 1:\n print(\"6\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"4\")\n elif amount[1] == 2:\n while True: pass\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n"}, {"source_code": "t = [\n [0,1,2,3,4,5],\n [0,1,2,4,3,5],\n [0,1,3,2,4,5],\n [0,1,3,4,2,5],\n [0,1,4,2,3,5],\n [0,1,4,3,2,5],\n [0,5,1,2,3,4],\n [0,5,1,2,4,3],\n [0,5,1,3,2,4],\n [0,5,1,3,4,2],\n [0,5,1,4,2,3],\n [0,5,1,4,3,2],\n [0,5,2,1,3,4],\n [0,5,2,1,4,3],\n [0,5,2,3,1,4],\n [0,5,2,3,4,1],\n [0,5,2,4,1,3],\n [0,5,2,4,3,1],\n [0,5,3,1,2,4],\n [0,5,3,1,4,2],\n [0,5,3,2,1,4],\n [0,5,3,2,4,1],\n [0,5,3,4,1,2],\n [0,5,3,4,2,1],\n [0,5,4,1,2,3],\n [0,5,4,1,3,2],\n [0,5,4,2,1,3],\n [0,5,4,2,3,1],\n [0,5,4,3,1,2],\n [0,5,4,3,2,1]\n]\n\n\ns = raw_input().strip()\na = set()\nfor i in range(30):\n a.add(''.join(map(s.__getitem__,t[i])))\nprint len(a)\n\n"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 5,\n\t(1, 1, 1, 3): 9,\n\t(2, 2, 2): 8,\n\t(1, 1, 2, 2): 14,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 5,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 8,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 5,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 8,\n\t(1, 1, 2, 2): 14,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 8,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 5,\n\t(1, 1, 1, 3): 9,\n\t(2, 2, 2): 8,\n\t(1, 1, 2, 2): 14,\n\t(1, 1, 1, 1, 2): 27,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]"}, {"source_code": "from itertools import permutations as p\n\ndef earliest(q):\n poss = []\n for j in xrange(len(q)):\n poss.append(\"\".join(q[j:] + q[:j]))\n poss.sort()\n return poss[0]\n\ndef processed(s):\n alts = []\n alts.append(\"\".join(sorted([s[0],s[5]])) + earliest(s[1:5]))\n alts.append(\"\".join(sorted([s[1],s[3]])) + earliest(s[0:1]+s[2:3]+s[4:]))\n alts.append(\"\".join(sorted([s[2],s[4]])) + earliest(s[0:2]+s[3:4]+s[5:]))\n return alts\n\ns = raw_input()\na = set()\n\nfor q in p(s):\n z = processed(q)\n if not any(map(lambda x: x in a, z)):\n a.add(z[0])\n\nprint len(a)\n#print a"}, {"source_code": "from sys import stdin, stdout\nfrom itertools import permutations as perms \n\ndef rot1(ls):\n\tls[0], ls[5], ls[1], ls[4]=ls[5], ls[1], ls[4], ls[0]\n\treturn ls\ndef rot2(ls):\n\tls[0], ls[2], ls[1], ls[3]=ls[2], ls[1], ls[3], ls[0]\n\treturn ls\ndef rot3(ls):\n\tls[5], ls[2], ls[4], ls[3]=ls[2], ls[4], ls[3], ls[5]\n\treturn ls;\ndef rot4(ls):\n\tls=[ls[4], ls[5], ls[3], ls[2], ls[0], ls[1]]\n\treturn ls\n\ndef main():\n\tline=stdin.readline()\n\n\tl=list(set(list(perms(line))))\n\tl=map(list, l)\n\n\tcube_sets=set()\n\tfor el in l:\n\t\tinsert=True\n\t\tfor r in range(2*4*4*4):\n\t\t\trot=r\n\t\t\ttmp=el\n\n\t\t\tfor f in [rot1, rot2, rot3]:\n\t\t\t\tfor _ in range(rot%4):\n\t\t\t\t\ttmp=f(tmp)\n\t\t\t\trot/=4\n\t\t\tif rot%2==1: tmp=rot4(tmp)\n\n\t\t\tif tuple(tmp) in cube_sets:\n\t\t\t\tinsert=False\n\t\t\t\tbreak\n\t\tif insert: cube_sets.add(tuple(el))\n\n\tstdout.write(str(len(cube_sets))+'\\n')\n\nif __name__=='__main__':\n\tmain()\n"}], "src_uid": "8176c709c774fa87ca0e45a5a502a409"} {"source_code": "d1,d2,d3=map(int,raw_input().split())\nprint min(d1+d2+d3,min(2*(d1+d3),min(2*(d2+d3),2*(d2+d1))))", "positive_code": [{"source_code": "x,y,z = map(int,raw_input().split())\npos = (x*2)+(y*2)\npos2 = x+y+z\npos3 = (x*2)+(z*2)\npos4 = (y*2)+(z*2)\nprint min(pos,pos2,pos3,pos4)"}, {"source_code": "d1,d2,d3=map(int,input().split())\na=d1+d2+d3\nb=2*(d1+d3)\nc=2*(d2+d3)\nd=2*(d1+d2)\nprint(min(a,b,c,d))\n"}, {"source_code": "a = list(map(int, input().split())) \nif a[0]+a[1]<=a[2]: \n print((a[0]+a[1])*2) \nif a[0]+a[1]>a[2]: \n if a[0]<=a[1] and a[1]<=a[2]+a[0]: \n print(a[0]+a[2]+a[1]) \n if a[0]<=a[1] and a[1]>a[2]+a[0]: \n print((a[0]+a[2])*2) \n if a[0]>a[1] and a[0]<=a[2]+a[1]: \n print(a[1]+a[2]+a[0]) \n if a[0]>a[1] and a[0]>a[2]+a[1]: \n print((a[1]+a[2])*2)\n"}, {"source_code": "''''\n10 20 30\n'''\n\nnum = input()\narr = []\ncounting = 0\nfor m in range(0, len(num)):\n if num[m] == ' ':\n arr.append(int(num[counting:m]))\n counting = m + 1\n elif m == len(num) - 1:\n arr.append(int(num[counting:len(num)]))\n\nd1_shop1 = arr[0]\nd2_shop2 = arr[1]\nd3_both_connect = arr[2]\n\ndistance = 0\nd2 = False\nif d1_shop1 > d2_shop2:\n distance += d2_shop2\n d2 = True\nelse:\n distance += d1_shop1\n\nif d3_both_connect >= d1_shop1 + d2_shop2:\n distance += d1_shop1 + d2_shop2\nelse:\n distance += d3_both_connect\n\nif d2 is True:\n if d1_shop1 >= d3_both_connect + d2_shop2 :\n distance += d3_both_connect + d2_shop2\n else:\n distance += d1_shop1\n\nif d2 is False:\n if d2_shop2 >= d3_both_connect + d1_shop1 :\n distance += d3_both_connect + d1_shop1\n else:\n distance += d2_shop2\n\nprint(distance)\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "#~ a, b, c = [int(x) for x in input().split()]\n#~ print min(a+b+c, 2*(a+b), 2*(a+c), 2*(b+c))\na, b, c = [int(x) for x in input().split()]\nprint(min([a + b + c, 2 * (a + b), 2 * (a + c), 2 * (b + c)]))\n"}, {"source_code": "d1,d2,d3 = map(int, raw_input().strip().split())\ns1 = d1+d3+d2\ns2 = (d1+d2)*2\ns3 = (d2+d3)*2\ns4 = (d1+d3)*2\n\nprint min(s1,s2,s3,s4)\n"}, {"source_code": "first_shop, second_shop, from_first_to_second = [int(x) for x in input().split()]\n\nif from_first_to_second < first_shop and from_first_to_second < second_shop:\n result = from_first_to_second * 2 + min(first_shop, second_shop) * 2\nelif first_shop + second_shop < from_first_to_second:\n result = first_shop * 2 + second_shop * 2\nelif from_first_to_second < first_shop:\n result = second_shop * 2 + from_first_to_second * 2\nelif from_first_to_second < second_shop:\n result = first_shop * 2 + from_first_to_second * 2\nelse:\n result = first_shop + second_shop + from_first_to_second\n\nprint(result)"}, {"source_code": "a,b,c=map(int,raw_input().split())\nprint min(2*(a+b), a+b+c, 2*(a+c), 2*(b+c))"}, {"source_code": "a,b,c=map(int,raw_input().split())\nprint min(2*min(a+b,b+c,a+c),a+b+c)\n"}, {"source_code": "Ptienda,Stienda,DosTienda=[int(x) for x in raw_input().split() ]\nsuma=Ptienda+Stienda\nMinimo=min(Ptienda,Stienda)\nMaximo=max(Ptienda,Stienda)\nif(DosTienda*2<Maximo):\n print (DosTienda*2)+(Minimo*2)\nelse:\n if(DosTienda<suma):\n print suma+DosTienda\n else:\n print((Ptienda*2)+(Stienda*2))\n"}, {"source_code": "d1, d2, d12 = map(int, input().split())\n\nx1 = (d1 + d2) * 2\nx2 = (d1 + d2 + d12)\nx3 = (d1 + d12) * 2\nx4 = (d2 + d12) * 2\nprint(min([x1, x2, x3,x4]))"}, {"source_code": "from sys import stdin\n\nd1, d2, d3 = map(int, stdin.next().split())\n\nprint str(min(d1 + d2 + d3, (d1 + d3) * 2, d1 * 2 + d2 * 2, (d2 + d3) * 2))"}, {"source_code": "a, b, c = map(int, raw_input().strip().split(' '))\nprint min(2*(a+b), a+b+c, 2*(a+c), 2*(b+c))"}, {"source_code": "a,b,c=map(int,input().split())\npa1=a+b+min((a+b),c)\npa2=(a+c)*2\npa3=(b+c)*2\nprint(min(pa1,pa2,pa3))"}, {"source_code": "d1, d2, d3 = [int(d1) for d1 in input().split()]\nmn = d1+d2+d3\nif 2*d1 + 2*d2 < mn:\n mn = 2*d1 + 2*d2\nelif 2*d1 > d3 and 2*(d2+d3) < mn:\n mn = 2*(d2+d3)\nelif 2*d2 > d3 and 2*(d1+d3) < mn:\n mn = 2*(d1+d3)\nprint(mn)\n"}, {"source_code": "#!/usr/bin/env python3\n\nd1, d2, d3 = input().split()\nd1 = int(d1)\nd2 = int(d2)\nd3 = int(d3)\n\na = 2*(d1 + d2)\nb = (d1 + d2 + d3)\nc = 2*(d1 + d3)\nd = 2*(d2 + d3)\n\nprint(min(a, b, c, d))"}, {"source_code": "#!/usr/bin/env python3\nimport itertools, functools, math\n\ndef solve():\n d1, d2, d3 = map(int, input().split())\n return min(2*d1+2*d2,\n d1+d3+min(d2, d3+d1),\n d2+d3+min(d1, d3+d2))\n\nif __name__ == '__main__':\n print(solve())\n\n"}, {"source_code": "a,b,c=map(int,input().split())\nprint(min(a+b+c,2*a+2*b,2*a+2*c,2*b+2*c))"}, {"source_code": "a,b,c = map(int, input().split())\nz=(a+b+c)\nx=2*(a+b)\nv=2*(b+c)\nn=2*(c+a)\nprint(min(z,x,v,n))\n \n\n"}, {"source_code": "a = map(int, raw_input().split())\nprint min(a[0]+a[1]+a[2],2*(a[0]+a[1]),2*(a[0]+a[2]),2*(a[2]+a[1]))"}, {"source_code": "d1,d2,d3=map(int,input().split())\nif 2*min(d1,d2)+2*max(d1,d2)<=2*min(d1,d2)+2*d3 and 2*min(d1,d2)+2*max(d1,d2)<=min(d1,d2)+d3+max(d1,d2):\n print(2*min(d1,d2)+2*max(d1,d2))\nelif 2*min(d1,d2)+2*d3<=min(d1,d2)+d3+max(d1,d2):\n print(2*min(d1,d2)+2*d3)\nelse: \n print(min(d1,d2)+d3+max(d1,d2))"}, {"source_code": "temp = map(int,input().split(\" \"))\na,b,c = temp\nk = 2*(a+b)\nk1 = a+b+c\nk2 = 2*b+2*c\nk3 = 2*(a+c)\nprint(min(k,k1,k2,k3))"}, {"source_code": "x=map(int,raw_input().split())\nif x[0]+x[1]<x[2]:\n print (x[0]+x[1])*2\nelif x[1]+x[2]<x[0]:\n print (x[1]+x[2])*2\nelif x[0]+x[2]<x[1]:\n print (x[0]+x[2])*2\nelse:\n print x[0]+x[1]+x[2] "}, {"source_code": "a,b,c=map(int,raw_input().split(' '))\nprint min(a+c+b,2*a+2*b,2*a+2*c,2*b+2*c)\n"}, {"source_code": "a,b,c=input().split()\nd=int(a)\ne=int(b)\nf=int(c)\nif d+e<=f:\n\tprint((2*d)+(2*e))\nelif d+f<=e:\n\tprint((2*d)+(2*f))\nelif e+f<=d:\n\tprint((2*f)+(2*e))\nelse:\n\tprint(d+e+f)"}, {"source_code": "bla=raw_input().split()\na=int(bla[0])\nb=int(bla[1])\nc=int(bla[2])\nprint min([a+b+c,2*a+2*b,2*b+2*c,2*a+2*c])"}, {"source_code": "#!/usr/bin/python\n\ndef ir():\n return int(raw_input())\n\ndef ia():\n line = raw_input()\n line = line.split()\n return map(int, line)\n\nd1, d2, d3 = ia()\nr1 = d1 + d3 + d2\nr2 = d1 + d1 + d2 + d2\nr3 = d2 + d3 + d1\nr4 = d2 + d2 + d1 + d1\nr5 = d1 + d3 + d3 + d1\nr6 = d2 + d3 + d3 + d2\n\nprint min(r1, r2, r3, r4, r5, r6)\n\n#H -- d1 -- S1\n#| /\n#| d3 /\n#d2 / \n#| / \n#| /\n#S2\n\n\n"}, {"source_code": "arr=[0]*6\narr=list(map(int, input().split()))\na=arr[0]\nb=arr[1]\nc=arr[2]\nprint(min(a + a + b + b, min(a + b + c, min(a + a + c + c, b + b + c + c))))\n "}, {"source_code": "a,b,c=map(int,input().split())\nprint(min(2*(a+b),a+b+c,2*(b+c),2*(a+c)))"}, {"source_code": "s = raw_input()\ns = s.split(\" \")\nd1 = int(s[0])\nd2 = int(s[1])\nd3 = int(s[2])\n\nif (2*d1 + 2*d3) < min(2*(d1+d2),d1+d2+d3) or (2*d2 + 2*d3) < min(2*(d1+d2),d1+d2+d3):\n \n print min(2*d1 + 2*d3,2*d2 + 2*d3)\nelif d1+d2 < d3 :\n print 2*(d1+d2)\nelse:\n print d1+d2+d3\n \n"}, {"source_code": "d1, d2, d3 = map(int, input().split())\nList=[]\nList.append(d1+d2+d3)\nList.append(2*d1+2*d2)\nList.append(2*d1+2*d3)\nList.append(2*d2+2*d3)\nprint(min(List))\n"}, {"source_code": "a=raw_input().split()\nfor t in range(len(a)):\n a[t]=int(a[t])\nx=a[0]+a[1]+a[2]\ny=2*(a[0]+a[1])\nw=2*(a[1]+a[2])\nz=2*(a[0]+a[2])\nprint min(x,y,w,z)\n \n "}, {"source_code": "L=list(map(int,input().split()))\nL.sort()\nprint(min(2*(L[0]+L[1]),(L[0]+L[1]+L[2])))"}, {"source_code": "d1,d2,d3=map(int,raw_input().split())\nprint min(d1+d2+d3,2*(d1+d3),2*(d3+d2),2*(d2+d1))"}, {"source_code": "d1,d2,d3 = map(int,raw_input().split())\n\n\nans = min(d1+d3+d2,d1+d1+d2+d2,d1+d3+d3+d1,d2+d2+d3+d3)\nprint ans\n\n"}, {"source_code": "x, y, z = map(int, raw_input().split())\n\ns = x+y+z\nt = 2*(x+y)\nr = 2*(x+z)\np = 2*(y+z)\n\nprint min(s,t,r,p)\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\nprint min(a+b+c,a+b+a+b,c+c+a+a,c+c+b+b)\n"}, {"source_code": "#alphabet = 'abcdefghijklmnopqrstuvwxyz'\nd1, d2, d3 = map(int, input().split())\nroads = [d1 + d2 + d3, 2*(d1 + d3), 2*(d2 +d3), 2*(d1+d2)]\nprint(min(roads))\n"}, {"source_code": "a, b, c = [int(i) for i in input().split()]\nprint(min(2 * (a + b), 2 * (a + c), 2 * (b + c), a + b + c))"}, {"source_code": "a,b,c = map(int, input().split())\nm = 2*a+2*b\nn = a+c+b\nx = 2*a+2*c\ny = 2*b+2*c\nprint(min(m,n,x,y))"}, {"source_code": "a,b,c=map(int,raw_input().split(' ')[0:3])\nprint min(a+b+c,2*(a+b),2*(min(a,b)+c))"}, {"source_code": "d1,d2,d3=map(int,input().split())\nprint(min((d1+d2+d3),(2*d1+2*d2),(2*d2+2*d3),(2*d1+2*d3)))"}, {"source_code": "a, b, c=map(int, input().split())\nprint(min(a+b+c,a+b<<1,a+c<<1,b+c<<1))"}, {"source_code": "d1,d2,d3 = map(int, raw_input().split())\n\n\nprint min([d1+d2+d3, d1*2+d2*2, d2*2+d3*2, d3*2+d1*2])"}, {"source_code": "d1,d2,d3=map(int,input().split())\noption1 = 2 * d1 + 2 * d2\noption2 = d1 + d2 + d3\noption3 = 2 * (min(d1, d2) + d3)\nprint(min(min(option1, option2), option3))\n"}, {"source_code": "a,b,c=map(int,input().split())\nx=min(2*(a+c),2*(b+c))\ny=min(a+b+c,2*(a+b))\nprint(min(x,y))"}, {"source_code": "a,b,c=map(int,input().split())\nif((a+b)<=c):\n print(2*(a+b))\nelif((a+c)<b):\n print(2*(a+c))\nelif((b+c)<a):\n print(2*(b+c))\nelse:\n print(a+b+c)"}, {"source_code": "d1, d2, d3 = map(int, input().split())\n\nprint(min([2*(d1+d2), d1+d2+d3, 2*(d1+d3), 2*(d2+d3)]))\n"}, {"source_code": "# your code goes here\nd1, d2, d3 = map(int, raw_input().split())\nr = min(2*(d1+d2), (d1+d2+d3))\nr = min(r, 2*(d1+d3))\nprint min(r, 2*(d2+d3))"}, {"source_code": "a, b, c=map(int, input().split())\nprint(min(2*(a+b), 2*(b+c), 2*(a+c), a+b+c))"}, {"source_code": "d1,d2,d3 = map(int,raw_input().split())\nd3 = min(d3,d1 + d2);\nif d1 > d2: d1,d2 = d2,d1;\nd2 = min(d2,d1 + d3);\nprint d1 + d3 + d2;"}, {"source_code": "a = list(map(int,raw_input().split()))\ni = a[0]\nj = a[1]\nk = a[2]\nprint (min(2 * i + 2 * j, min(i + j + k, min(j * 2 + k * 2, i * 2 + k * 2))))"}, {"source_code": "d1,d2,d3 = [int(i) for i in raw_input().split(\" \")]\n\nD1 = d1 + d2 + d3\nD2 = 2 * d1 + 2 * d3\nD3 = 2 * d2 + 2 * d3\nD4 = 2 * d1 + 2 * d2\n\nprint min(D1, D2, D3, D4)\n"}, {"source_code": "l = list(map(int, input().split()))\nprint(min(l[0] * 2 + l[2] * 2 , l[0] + l[1] + l[2], l[0] * 2 + l[1] * 2, l[2] * 2 + l[1] * 2))"}, {"source_code": "a,b,c=map(int,input().split())\nm=2*a+2*b\nv=a+b+c\ng=2*a+2*c\nh=2*b+2*c\nprint(min(m,v,g,h))"}, {"source_code": "x = list(map(int, input().split()))\nd1, d2, d3 = x[0], x[1], x[2]\nprint(min(2*(d1+d2), 2*(d2+d3), 2*(d1+d3), sum(x)))"}, {"source_code": "abc = input().split()\na = int(abc[0])\nb = int(abc[1])\nc = int(abc[2])\n\nd= a+b+c\ne= 2*(a+b)\ng= 2*(a+c)\nh= 2*(b+c)\n\nf= min(d,e,g,h)\n\nprint(f)"}, {"source_code": "a,b,c=map(int,input().split())\nq=a+a+b+b\nw=a+b+c\ne=b+b+c+c\nr=a+a+c+c\nprint(min(q,e,r,w))"}, {"source_code": "L = [d1, d2, d3] = [int(x) for x in input().split()]\nprint(min(d1, (d2+d3)) + min(d2, (d3+d1)) + min(d3, (d1+d2))) \n"}, {"source_code": "d1,d2,d3=map(int,input().split())\nif(d1==d2 and d2==d3):\n print(d1*3)\nelse:\n if(d1<=d3 and d2<=d3):\n print(min(d1*2+d2*2,d1+d2+d3))\n elif(d1<=d2 and d3<=d2):\n print(min(d1*2+d3*2,d1+d2+d3))\n elif(d2<=d1 and d3<=d1):\n print(min(d2*2+d3*2,d1+d2+d3))\n else:\n print(d1+d2+d3)"}, {"source_code": "z=list(map(int,input().split()))\nif z[0]+z[1]<z[2]:\n print(z[0]*2+z[1]*2)\nelif z[0]>z[1]+z[2]:\n print(z[1]*2+z[2]*2)\nelif z[1]>z[0]+z[2]:\n print(z[0]*2+z[2]*2)\nelse:\n print(z[0]+z[1]+z[2]) "}, {"source_code": "d1,d2,d3=map(int,input().split())\nprint(min([2*(d1+d2),d1+d2+d3,2*(d3+min(d1,d2))]))"}, {"source_code": "a,b,c=map(int,input().split())\nprint(min(a+b+c,2*(a+b),2*(a+c),2*(b+c)))"}, {"source_code": "def func(a):\n x = a[0] + a[2] + a[1]\n y = a[0] + a[2] + a[2] + a[0]\n w = a[1] + a[1] + a[0] + a[0]\n z = a[1] + a[2] + a[2] + a[1]\n print(min(x,y,z,w))\na = list(map(int,input().split()))\nfunc(a)"}, {"source_code": "d1, d2, d3 = map(int, input().split())\nprint(min(d1+d2+d3, 2*(d1+d2), 2*(d3+d2), 2*(d1+d3)))"}, {"source_code": "\nfrom sys import stdin\nd1,d2,d3=map(int,stdin.readline().strip().split())\nans=0\nif(d1>=(d2+d3)):\n ans=2*(d2+d3)\nelif(d2>=(d1+d3)):\n ans=2*(d1+d3)\nelif(d3>=(d1+d2)):\n ans=2*(d1+d2)\nelif(d3<(d1+d2)):\n ans=d1+d3+d2\nprint(ans)"}, {"source_code": "i = input()\nli = list(i.split(\" \"))\nli = [int(x) for x in li] \n\na = li[0]*2 + li[2]*2\nb = li[1]*2 + li[2]*2\nc = li[0]*2 + li[1]*2\nd = li[0] + li[1] + li[2]\n\nnew = []\nnew.insert(0,a)\nnew.insert(1,b)\nnew.insert(2,c)\nnew.insert(3,d)\n\nnew.sort()\n\nprint(new[0])\n\n\n"}, {"source_code": "d1,d2,d3=map(int,raw_input().split())\na1=(d1+d2)*2\na2=(d2+d3)*2\na3=(d3+d1)*2\nans=min(a1,a2,a3)\nans1=d1+d2+d3\nif ans<ans1:\n print ans\nelse:\n print ans1\n \n\n\n\n \n "}, {"source_code": "d1, d2 , d3 = input().split()\nd1 = int(d1)\nd2 = int(d2)\nd3 = int(d3)\ntd = 0\nif d3 >= (d1 + d2) :\n td = (d1 + d2)*2\n \nelif d2 > (d1 + d3) :\n td = (d1 + d3)*2\n\nelif d1 > (d2 + d3) :\n td = (d3 + d2)*2\nelse: td = d1 + d2 + d3\nprint (td)"}, {"source_code": "d1,d2,d3 = map(int,input().split())\nfm = (d1*2) + d2*2\nsm = d1+d3+d2\ntm = d3*2 + d2*2\nfom = d1 * 2 + d3*2\nprint(min(fm,sm,tm,fom))\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\ny=min(a,b)+min(c,a+b)+min(c+min(a,b),max(a,b))\nprint y"}, {"source_code": "\nlDistances=map(int,raw_input().split())\n\nif all(item >= 1 for item in lDistances) and all(item <= 1000000000 for item in lDistances):\n\t\n\n\tlMaxDistances=[]\n\n\tlMaxDistances.append(sum(lDistances))\n\tlMaxDistances.append(2*(lDistances[0]+lDistances[1]))\n\tlMaxDistances.append(2*(lDistances[0]+lDistances[2]))\n\tlMaxDistances.append(2*(lDistances[1]+lDistances[2]))\n\n\tprint min(lMaxDistances)\n\n\n"}, {"source_code": "#in the name of god\n#Mr_Rubik\n#codeforces,problemset\nd1,d2,d3=map(int,input().split())\nmn=[(d1+d2+d1+d2),(d1+d3+d1+d3),(d2+d3+d2+d3),(d1+d3+d2)]\nmn.sort()\nprint(mn[0]) \n"}, {"source_code": "# Fast IO (only use in integer input) or take care about string\n\nimport os,io\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\na,b,c = map(int,input().split())\n\nprint(min(min(min(a + b + c,2 * a + 2 * b),2 * a + 2 * c),2 * b + 2 * c))"}, {"source_code": "if __name__ == '__main__':\n d1, d2, d3 = [int(val) for val in raw_input().split()]\n\n print min(2*(d1+d2), 2*(d1+d3), 2*(d2+d3), d1+d2+d3)\n"}, {"source_code": "def int_put():\n num_list = input(\"\").split()\n \n return [int(input) for input in num_list]\n\n\n#length of roads\nd1,d2,d3 = int_put()\n\nint_list = []\n#road from shop to house to shop to house\nr_1 = d1*2 + d2*2\n#long road and back home taking the shortest short route\nr_2 = d1 + d2 + d3\n#\nr_3 = d1 + d3 * 2 + d1\nr_4 = d2 + d3 * 2 + d2\n\nint_list.append(r_1)\nint_list.append(r_2)\nint_list.append(r_3)\nint_list.append(r_4)\nint_list.sort()\nprint(int_list[0])\n\n\n"}, {"source_code": "d1,d2,d3 = map(int,input().strip().split())\nprint (min(d1+d2+d3,2*(d1+d2),2*(d2+d3),2*(d1+d3)))"}, {"source_code": "L=[int(x) for x in raw_input().split()]\nif L[0]>=L[1]:\n print L[1]+min(L[2]+L[0],L[0]*2+L[1],L[2]*2+L[1])\nelse:\n print L[0]+min(L[2]+L[1],L[1]*2+L[0],L[2]*2+L[0])\n"}, {"source_code": "d1,d2,d3, = map(int,raw_input().split())\n\nans = min(d1,d2)\n\nans += min(d1+d2,d3)\n\nans += min (max(d1,d2),d3+min(d1,d2))\n\nprint(str(ans))"}, {"source_code": "d1, d2, d3 = map(int, raw_input().split())\nprint min(d1+d2+d3, 2*d1+2*d2, 2*d2+2*d3, 2*d1+2*d3)\n"}, {"source_code": "\nt = raw_input()\na,b,c = map(int,t.split())\ng = [[987654321 for col in range(3)]for row in range(3)];\ng[0][1] = a;\ng[1][0] = a;\ng[0][2] = b;\ng[2][0] = b;\ng[1][2] = c;\ng[2][1] = c;\nfor k in range(3):\n for i in range(3):\n for j in range(3):\n if g[i][j] > g[i][k] + g[k][j]:\n g[i][j] = g[i][k] + g[k][j]\n\n\nret = g[0][1] + g[1][2] + g[2][0]\nprint ret\n"}, {"source_code": "a, b, c=sorted(map(int, input().split()))\nif a==b==c or a+b>=c:\n print(a+b+c)\nelse:\n print(2*a+2*b)"}, {"source_code": "d1,d2,d3=map(int,raw_input().split())\na=[]\nminOne = min(d1,d2)\na.append(minOne*2+(d1+d2-minOne)*2)\na.append(d1+d2+d3)\nminOne = min(d1,d2)\na.append(minOne*2+d3*2)\nprint min(a)"}, {"source_code": "from __future__ import division\nfrom collections import Counter as ctr\nfrom math import ceil, log, factorial, sqrt\n# reads a line of input and converts into a list of ints\n# 1 1 3 => [1, 1, 3]\ndef rl():\n return [int(i) for i in raw_input().split()]\n\n# reads n lines of input (if n defined) and returns a list of strings\n# where each element is a line in the input\n# abc\n# abcdef\n# => ['abc', 'abcdef']\n# if n not defined, read first line to get number of lines\n# 2\n# abc\n# abcdef\n# => ['abc', 'abcdef']\ndef rm(n=None):\n if n is None:\n n = input()\n return [raw_input() for i in range(n)]\n\n# same as rm, except converts each line to a list of ints like rl\ndef rlm(n=None):\n if n is None:\n n = input()\n return [rl() for i in range(n)]\n\ndef yn(b):\n if b:\n print \"YES\"\n else:\n print \"NO\"\n\nd=rl()\nprint min((d[0]+d[1])*2, (d[1]+d[2])*2, (d[0]+d[2])*2, sum(d))"}, {"source_code": "def solve():\n\td1, d2, d3 = [int(x) for x in raw_input().split()]\n\tprint min(d1+d2+d3,(d1+d3)*2,(d2+d3)*2,(d2+d1)*2)\n\n# t = int(input())\n# for x in xrange(t):\n# \tsolve()\nsolve()"}, {"source_code": "def solve():\n\td1, d2, d3 = [int(x) for x in raw_input().split()]\n\tprint min(d1+d2+d3,d1+d3+d1+d3,d2+d3+d2+d3,d2+d2+d1+d1)\n\n# t = int(input())\n# for x in xrange(t):\n# \tsolve()\nsolve()"}, {"source_code": "import sys \n\narr = map(int, sys.stdin.readline().split())\n\na = arr[0]\nb = arr[1]\nc = arr[2]\n\nprint min(a + b + c, 2 * min(a + b, a + c, b + c))"}, {"source_code": "a,b,c=map(int,input().split()) \n\nn1=( a + b + c )\nn2=2 * (a + b)\nn3=2 * (b + a)\nn4=2 * (a + c)\nn5=2 * (c + b)\nif n1<n2 and n1<n3 and n1<n4 and n1<n5:\n print(n1)\nelif n2==n3 and n2==n4 and n3==n4:\n print(n1)\nelse:\n print(min(n2,n3,n4,n5))"}, {"source_code": "a,b,c=[int(z) for z in raw_input().split(' ')]\n\nans1= (2*a) + (2*b)\nans2= a+b+c\nans3= (a*2)+ (2*c)\nans4= (2*b) + (2*c)\n\nans= min(ans1,ans2,ans3,ans4)\n\nprint ans\n\n"}, {"source_code": "def main():\n a,b,c = map(int, raw_input().split())\n ans1 = 2*a + 2*b\n ans2 = a+b+c\n ans3 = 2*a + 2*c\n ans4 = 2*b + 2*c\n print min([ans1,ans2,ans3,ans4])\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "a,b,c=map(int,input().split())\nprint (min ( a + b + c , 2 * (a + b), 2 * (b + a), 2 * (a + c), 2*(c+b) ) )"}, {"source_code": "d1,d2,d3=map(int,input().split())\nsum=0\nif(d1<d2+d3):\n sum=sum+d1\nelse:\n sum=sum+(d3+d2)\nif(d1+d2<d3):\n sum=sum+(d1+d2)\nelse:\n sum=sum+d3\nif(d2<d3+d1):\n sum=sum+d2\nelse:\n sum=sum+(d3+d1)\nprint(sum)"}, {"source_code": "a=map(int,raw_input().split())\n#a[0]=1st a[1]=2 a[2]=tot\nb=[]\nm=2*(a[0]+a[1])\nn=2*(a[2]+a[1])\no=2*(a[0]+a[2])\np=(a[0]+a[1]+a[2])\nb.append(m)\nb.append(n)\nb.append(o)\nb.append(p)\nmin=b[0]\nfor i in range(4):\n\tif min>b[i]:\n\t\tmin=b[i]\nprint(min)\n"}], "negative_code": [{"source_code": "L = [int(x) for x in input().split()]\nprint(2*(sum(L) - max(L)))\n"}, {"source_code": "d1,d2,d3 = map(int,input().split())\n\nif 2*d1 + 2*d2 <= d3:\n\tc = 2*d1+2*d2\nelse:\n\tc = d1+d2+d3\n\n\nprint(c)\n\n\n"}, {"source_code": "a,b,c=map(int,input().split())\nprint(min([2*a+2*b,a+b+c,2*a+2*c]))"}, {"source_code": "def fun(z,d3):\n sc=z[0]\n if(z[0] >= d3):\n sc+=d3\n if(z[0]+d3<=z[1]):\n sc+=z[0]+d3\n else:\n sc+=z[1]\n else:\n sc+=z[0]+2*z[1]\n return sc\n\nd1,d2,d3=map(int,input().split())\nz=[min(d1,d2),max(d1,d2)]\nprint(fun(z,d3))"}, {"source_code": "x = list(map(int, input().split()))\nans = 0\nans+=min(x[0],x[1])\n\nif ans==x[0]:\n\tjk = min(x[2],x[0]+(2*x[1]),x[0]+x[1]+x[2])\n\tif jk==x[0]+(2*x[1]):\n\t\tans+=x[0]+(2*x[1])\n\telif jk==x[0]+x[1]+x[2]:\n\t\tans+=x[0]+x[1]+x[2]\n\telse:\n\t\tans+=x[2]\n\t\tans+=min(x[1], x[2]+x[0])\n\n\t\t\nelse:\n\tjk = min(x[2],x[1]+(2*x[0]),x[0]+x[1]+x[2])\n\tif jk==x[0]+(2*x[1]):\n\t\tans+=x[0]+(2*x[1])\n\telif jk==x[0]+x[1]+x[2]:\n\t\tans+=x[0]+x[1]+x[2]\n\telse:\n\t\tans+=x[2]\n\t\tans+=min(x[0], x[2]+x[1])\n\nprint (ans)"}, {"source_code": "x, y, z = input().split()\n\nx = int(x)\ny = int(y)\nz = int(z)\n\ndistance = [int(x), int(y), int(z)]\ndistance.sort()\n\nif x == y == z:\n result = int(x) + int(y) + int(z)\nelse:\n result = int((2 * (distance[0] + distance[1])))\n\nprint(result)\n\n"}, {"source_code": "a = map(int, raw_input().split())\nb = 2*a[0] + 2*a[1]\nc = a[0]+a[2]+a[1]\nd = [b,c]\nprint min(d)\n"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[4]:\n\n\ndef path_sort(arr):\n sum1 = 0\n res = 0\n for i in range(len(arr)):\n sum1 = arr[0]*2 + arr[1] *2\n for j in range(len(arr)):\n res += arr[i]\n if(sum1 > res):\n return res\n elif(sum1 == res):\n return sum1\n else:\n return sum1\n \n \n\nar = list(map(int,input().strip().split()))\nresu = path_sort(ar)\nprint(resu)\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "d1, d2, d3 = map(int, input().split())\nprint(d1 + min(d1+d2, d3) + d2)"}, {"source_code": "a,b,c = map(int, raw_input().split())\n\nd = 0\nif a<=b:\n d+=a\n if c+b<=a+b+b:\n d+=c+b\n else:\n d+=a+b+b\nelse:\n d+=b\n if c+a<=b+a+a:\n d+=c+a\n else:\n d+=b+a+a\nprint d\n"}, {"source_code": "d1,d2,d3 = map(int,input().split())\n\na = 2*min(d1,d3) + 2*min(d2,d3)\nprint(a)"}, {"source_code": "d1, d2, d3 = map(int, input().split())\nprint(min(2 * (d1 + d2), d1 + d2 + d3))"}, {"source_code": "d1,d2,d3=map(int,input().split(' '))\nn1,n2=d1+d2+d3,d1+d1+d2+d2\nprint({True:n1,False:n2}[n1<n2])"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2015 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\na, b, c = list(map(int, input().split()))\n\nif a + b < c:\n print((a+b)*2)\nelif a + c < b:\n print((a+c)*2)\nelse:\n print((c+b)*2)\n"}, {"source_code": "d1, d2, d3 = map(int, raw_input().split())\n\nif d1 + d2 < d3:\n\tprint (d1 + d2) * 2\nelse:\n\tprint d3 * 2\n"}, {"source_code": "d1,d2,d3 = [int(i) for i in input().split()[:3]]\nif(d1+d2+d3<d1+d1+d2+d2):\n print(d1+d2+d3)\nelse:\n print(d1+d1+d2+d2)"}, {"source_code": "a,b,c=map(int,input().split())\nprint(min(a+2*c+a,a+b+c,b+2*c+b))"}, {"source_code": "d1, d2, d12 = map(int, input().split())\n\nx1 = (d1 + d2) * 2\nx2 = (d1 + d2 * d12)\nx3 = (d1 + d12) * 2\nx4 = (d2 + d12) * 2\nprint(min([x1, x2, x3,x4]))"}, {"source_code": "#!/usr/bin/env python3\nimport itertools, functools, math\n\ndef solve():\n d1, d2, d3 = map(int, input().split())\n return min(2*d1+2*d2, d1+d2+d3)\n\nif __name__ == '__main__':\n print(solve())\n\n"}, {"source_code": "a,b,c=[int(i) for i in input().split()]\nif c>a+b:\n print(2*(a+b))\nelse:\n print(a+b+c)\n"}, {"source_code": "d1, d2, d3 = [int(d1) for d1 in input().split()]\nmn = d1+d2+d3\nif 2*d1 + 2*d2 < mn:\n mn = 2*d1 + 2*d2\nprint(mn)\n"}, {"source_code": "d1,d2,d3 = map(int,input().split())\nm = 0\nif d1 <= d2:\n m += d1\n if d1+d2 <= d3:\n m += d1+d2\n m += d2\n else:\n m += d3\n if d2 <= d1+d3:\n m += d2\n else:\n m += d1+d3\nelse:\n m += d2\n if d1+d2 <= d3:\n m += d1+d2\n m += d2\n else:\n m += d3\n if d1 <= d2+d3:\n m += d1\n else:\n m += d2+d3\nprint(m)"}, {"source_code": "d1,d2,d3, = map(int,raw_input().split())\n\nans = max(d1,d2)\n\nans += min(d1+d2, d3)\n\nans += min(d1,d2)\n\nprint(str(ans))"}, {"source_code": "import sys\na,b,c = map(int,sys.stdin.readline().split())\nl = [2*(a+b),a + b + c]\nprint(min(l))\n"}, {"source_code": "a,b,c = list(map(int,input().split()))\nx = 2*(a+b)\ny = a+b+c\nif(x<=y):\n print(x)\nelse:\n print(y)\n\n"}, {"source_code": "def distance(d1, d2, d3):\n \n d1d2 = (d1 + d2) * 2\n if d1d2 <= d3:\n return d1d2\n return d1 + d2 + d3\n\ndef main():\n d1, d2, d3 = map(int, input().split())\n print(distance(d1, d2, d3))\n \n \nmain()"}, {"source_code": "a,b,c=map(int,input().split())\nif min((a+b) , 2*(b+a) , 2*(c+a) , 2*(c+b)) < (a+b+c):\n print ( a + b + c )\nelif a==b and b==a and c==a and c==b:\n print ( a + b + c )\nelse:\n print ( min ( 2 * (a + b), 2 * (b + a), 2 * (a + c) ) )"}, {"source_code": "a = list(map(int,input().split()))\nprint(min(a[0]+a[2]+a[1],(a[1]+a[2])**2,(a[0]+a[2])**2,(a[0]+a[1])**2))"}, {"source_code": "a,b,c=map(int,raw_input().split())\nprint min(2*a+2*b,a+b+c)\n"}, {"source_code": "def input_data():\n myList = []\n input = raw_input(\"\").split(' ')\n for v in input:\n myList.append(int(v))\n return myList\n \na = input_data()\nprint(min((a[0]+a[1]+a[2]),(a[0]+a[0]+a[1]+a[1]),(a[1]+a[2]+a[2]+a[1])))"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2015 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\na, b, c = list(map(int, input().split()))\n\nif b < c:\n print((a+b)*2)\nelif a + c < b:\n print((a+c)*2)\nelse:\n print(c+a+b)\n"}, {"source_code": "temp = map(int,input().split(\" \"))\na,b,c = temp\nk = 0\nif a == b:\n k = k + c-b\nelif b == c:\n k = k + b-a\nelif a==b and b == c:\n k = 0\nelse:\n k = b-a + c + c - b+a\nprint(k)"}, {"source_code": "D1,D2,D3=raw_input().strip().split(' ')\nD1,D2,D3=int(D1),int(D2),int(D3)\nprint min(2*D1+2*D2,D1+D2+D3,2*D2+D3,2*D1+D3)"}, {"source_code": "a,b,c=map(int,input().split())\nif a+b<c:\n\tprint((a+b)*2)\nelse:\n\tprint(a+b+c)"}, {"source_code": "d1, d2, d3 = map(int, input().split())\nprint(min(2*d1 + 2*d2, d1+d2+d3))\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\nprint min(2*a+2*b,a+b+c)\n"}, {"source_code": "x,y,z = map(int,raw_input().split())\nc = x+y+z\nd= ((2*x)+(2*y))\nprint d\nprint c\nif c<=d:\n print c\nelse: \n print d\n"}, {"source_code": "n,m,k = map(int,input().split())\n\nprint(min(2*(m+n), m+n+k))"}, {"source_code": "a = list(map(int, input().split())) \nif a[0]+a[1]<=a[2]: \n print((a[0]+a[1])*2) \nif a[0]+a[1]>a[2]: \n if a[0]<a[1] and a[1]<=a[2]+a[0]: \n print(a[0]+a[2]+a[1]) \n if a[0]<a[1] and a[1]>a[2]+a[0]: \n print((a[0]+a[2])*2) \n if a[0]>a[1] and a[0]<=a[2]+a[1]: \n print(a[1]+a[2]+a[0]) \n if a[0]>a[1] and a[0]>a[2]+a[1]: \n print((a[1]+a[2])*2)\n"}, {"source_code": "d1,d2,d3 = map(int,input().split())\n\n\nprint(min(d1+d1+d2+d2,d1+d3+d3+d1,d2+d3+d3+d1,d1+d3+d2))"}, {"source_code": "l=list(map(int,input().strip().split()))\nd1,d2,d3=l[0],l[1],l[2]\na=2*d1+2*d2\nb=d1+d2+d3\nif a<=b:\n print(a)\nelse:\n print(b)"}, {"source_code": "d1,d2,d3=map(int,raw_input().split())\nans=(d1+d2)*2\nans1=d1+d2+d3\nif ans<ans1:\n print ans\nelse:\n print ans1"}, {"source_code": "a,b,c=map(int,input().split())\nx=[a+b+c,2*(a+c),2*(b+c)]\nprint(min(x))"}, {"source_code": "def main():\n d = str(raw_input())\n l = d.split()\n d1 = int(l[0])\n d2 = int(l[1])\n d3 = int(l[2])\n\n if d3 > (d2 + d1):\n print str(2 * (d1 + d2))\n else:\n print str(d1 + d2 + d3)\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "a = list(map(int,input().split()))\nprint(min(a[0]+a[2],a[1]+a[2]))"}, {"source_code": "a, b, c = map(int, input().split())\nif a + b < c:\n print((a + b)*2)\nelse:\n print(c * 2)\n"}, {"source_code": "l= list(map(int,input().split(' ')))\nl.sort()\nprint(l)\na= l[0] + l[1]+ l[2]\nb = l[0]*2 +l[1]*2\nif(l[0]==l[1]==l[2]):\n print(l[0]*3)\nelse:\n print(a if a<b else b )"}, {"source_code": "m,n,k=input().split()\nz=max(int(m),int(n),int(k))\nif int(m)==int(n)==int(k):\n print(int(m)+int(n)+int(k))\nelse:\n print(int(2*(int(m)+int(n)+int(k)-z)))\n"}, {"source_code": "d1,d2,d3=map(int,input().split())\nif 2*(d1+d2)<(d1+d2+d3):\n print(2*(d1+d2))\nelse:\n print(d1+d2+d3)"}, {"source_code": "def house():\n\td1, d2, d3 = raw_input().split()\n\td1 = int(d1)\n\td2 = int(d2)\n\td3 = int(d3)\n\n\tif (d1+d1 + d2+d2) < d3:\n\t\tprint (d1+d1 + d2+d2)\n\telif (d1+d1+d3+d3) < d2:\n\t\tprint (d1+d1+d3+d3)\n\n\telif (d2+d2+d3+d3) < d1:\n\t\tprint (d2+d2+d3+d3)\n\n\telse:\n\t\tprint d1+d2+d3\n\nhouse()"}, {"source_code": "ds = [int(n) for n in input().strip().split(' ')]\n\nif (ds[0]+ds[1]) < ds[2]:\n\tprint(ds[0]*2 + ds[1]*2)\nelse:\n\tprint(ds[0]+ds[1]+ds[2])\n"}, {"source_code": "s=input().split()\na=int(s[0])\nb=int(s[1])\nn=int(s[2])\nk=0\nj=0\nif a*2+b*2>n:\n print(a+b+n)\nelse:\n print(a*2+b*2)\n"}, {"source_code": "a,b,c=map(int,input().split())\nif (a+b+c) < min(2*(a+b) , 2*(b+a) , 2*(c+a) , 2*(c+b)):\n print ( a + b + c )\nelif a==b and b==a and c==a and c==b:\n print ( a + b + c )\nelse:\n print ( min ( 2 * (a + b), 2 * (b + a), 2 * (a + c) ) )"}, {"source_code": "a,b,c=map(int,input().split())\nif(c>a+b):\n print(2*(a+b))\nelse:\n print(c+a+b)\n"}, {"source_code": "ha,hb,ab=map(int,input().split())\na1=(2*ha)+(2*hb)\nb1=ha+hb+ab\nif(a1<b1):\n print(a1)\nelif(a1>b1):\n print(b1)\nelse:\n print(a1)"}, {"source_code": "# cook your dish here\n(a,b,c) = map(int,input().split())\nans = min(a*2+b*2,a+b+c)\nprint(ans)"}, {"source_code": "a = map(int, raw_input().split())\nb = 2*a[0] + 2*a[1]\nc = a[0]+a[2]+a[1]\nd = [b,c]\nprint min(d)\n"}, {"source_code": "a = map(int, raw_input().split())\nb = 2*a[0] + 2*a[1]\nc = a[0]+a[2]+a[1]\nd = 2*a[1]+2*a[2]\ne = [b,c,d]\nprint min(e)\n"}, {"source_code": "#in the name of god\n#Mr_Rubik\n#codeforces,problemset\nd1,d2,d3=map(int,input().split())\nif (d1+d2)<=d3:print(d1+d2+d1+d2)\nif (d1+d3)<=d2:print(d1+d3+d1+d3)\nif (d2+d3)<=d1:print(d2+d3+d2+d3)\nif d1==d2==d3:print(3*d1)\n"}, {"source_code": "def main():\n a,b,c = [int(v) for v in input().split()]\n print(max(a+b+c, a*2+b*2))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "L = [int(x) for x in input().split()]\nprint(2*(sum(L) - max(L)))\n"}, {"source_code": "a,b,c=map(int,input().split())\nm=2*a+2*b\nv=a+b+c\nif m>v:\n print(v)\nelse:\n print(m)"}, {"source_code": "a,b,c=map(int,input().split())\nprint(min(2*(a+b),a+b+c))"}, {"source_code": "d1,d2,d3 = map(int, raw_input().split())\n\nprint min(2*d1+2*d2, d1+d3+d2)"}, {"source_code": "\n\nx,y,z = map(int,input().split())\nprint(min(2*x,min(2*y,min(2*(y+z),2*(x+z)))))"}, {"source_code": "a,b,c=map(int,raw_input().split())\ny=min(a+b,c)\ny+=min(a+b,c)\nprint y"}, {"source_code": "d1, d2, d3 = map(int, input().split())\nprint(min(d1 + d2 + d3, 2 * d1 + 2 * d2))"}, {"source_code": "s=input().split()\na=int(s[0])\nb=int(s[1])\nn=int(s[2])\nk=0\nj=0\nif a>=b:\n print(n-b)\nelse:\n print(a+b+n)\n"}, {"source_code": "d1,d2,d3=map(int,input().split())\nif(d1==d2):\n x=d3-d1\nelif(d1>d2 and d3>d2):\n x=d1+d3\nelif(d2>d1 and d3>d1):\n x=d2+d3+d1\nelif(d1==d2==d3):\n x=d2+d3+d1\nelse:\n x=d2+d3\nprint(x)\n "}, {"source_code": "d1, d2, d12 = map(int, input().split())\n\nprint(min(d1+ d2 + d1 + d2, d1 + d2 + d12))"}, {"source_code": "l1, l2, l3 = map(int, input().split())\nsm = 0\ns = 0\ns += l1 + l1 + l2 + l2\nsm = s\ns = 0\ns += l2 + l2 + l1 + l1\nif s < sm:\n sm = s\ns = 0\ns += l2 + l3 + l1\nif s < sm:\n sm = s\ns = 0\ns += l1 + l3 + l2\nif s < sm:\n sm = s\nprint(sm)\n"}, {"source_code": "a,b,c=map(int,input().split())\nm=2*a+2*b\nv=a+b+c\nif m>v:\n print(v)\nelse:\n print(m)"}, {"source_code": "d1, d2, d3 = map(int, raw_input().split(\" \"))\n# h 1 h 2 h (if d1 + d2 < d3)\n# h 1 2 1 h (if d1 + d3 < d2)\n# h 2 1 2 h (if d2 + d3 < d1)\n# h 2 1 h (if \nif d1 <= d2 + d3:\n print d1 + d1 + d2 + d2\nelif d1 + d3 <= d2:\n print d1 + d3 + d3 + d1\nelif d2 + d3 <= d1:\n print d2 + d3 + d3 + d2\n"}, {"source_code": "[d1, d2, d3] = [int(x) for x in input().split()]\nprint(2*(d1+d2) if d1+d2 < d3 else d1+d2+d3)\n"}, {"source_code": "d1, d2, d3 = map(int, raw_input().split(\" \"))\n# h 1 h 2 h (if d1 + d2 < d3)\n# h 1 2 1 h (if d1 + d3 < d2)\n# h 2 1 2 h (if d2 + d3 < d1)\n# h 2 1 h (if \nif d1 <= d2 + d3:\n print d1 + d1 + d2 + d2\nelif d1 + d3 <= d2:\n print d1 + d3 + d3 + d1\nelif d2 + d3 <= d1:\n print d2 + d3 + d3 + d2\n"}, {"source_code": "d1,d2,d3=map(int,input().split())\nsum=0\nif(d1>d2+d3):\n sum=sum+d2\nelse:\n sum=sum+d1\nif(d1+d2<d3):\n sum=sum+(d1+d2)\nelse:\n sum=sum+d3\nif(d2<d3+d1):\n sum=sum+d2\nelse:\n sum=sum+(d3+d1)\nprint(sum)"}, {"source_code": "temp = map(int,input().split(\" \"))\na,b,c = temp\nk = 0\nk = k + (a+b)*2\nprint(k)"}, {"source_code": "a,b,c = [int(i) for i in input().split()]\n\nif a + b <= c:\n print(2*(a+b))\nelse:\n print(a+b+c)\n"}, {"source_code": "d1,d2,d3 = list(map(int,input().split()))\ndistance = []\nif d1 <= d2:\n\tdistance.append(d1)\n\tif d3 <= d1 + d2:\n\t\tdistance.append(d3)\n\telse:\n\t\tdistance.append(d1 + d2)\n\tdistance.append(d2)\t\nelse:\n\tdistance.append(d2)\n\tif d3 <= d1 + d2:\n\t\tdistance.append(d3)\n\telse:\n\t\tdistance.append(d1 + d2)\n\tdistance.append(d1)\t\nprint(sum(distance))"}, {"source_code": "a, b, c = map(int, input().split())\nif a + a + a + b <= a + b + c:\n print(a + a + a + b)\nelse:\n print(a + b + c)"}, {"source_code": "d1, d2, d3 = map(int, input().split())\nprint(min(2*d1 + 2*d2, d1+d2+d3))\n"}, {"source_code": "a, b, c = map(int, input().split())\nif a + b < c:\n print((a + b)*2)\nelse:\n print((min(a, b) + c) * 2)\n\n"}, {"source_code": "d1,d2,d3 = input().split()\nd1 = int(d1)\nd2 = int(d2)\nd3 = int(d3)\nsum1 = 0\nres = 0\ncount = 0\nsum1 = d1 + d2 + d3\nres = d1 * 2 + d2*2\ncount = d2*2 + d3*2\nif(sum1 <= res and sum1 <= count):\n print(sum1)\nelif(res<=count):\n print(res)\nelse:\n print(count)\n"}, {"source_code": "from math import *\nfrom Queue import *\nfrom sys import *\n\n\n\n\nd1, d2, d3 = map(int, raw_input().split())\nprint(2*min(d1+d3, d1+d2, d2+d3))\n"}, {"source_code": "i = input()\nli = list(i.split(\" \"))\na = int(li[0])\nb = int(li[1])\nc = int(li[2])\nd = int(0)\nif((a+b)>=c):\n d = a+b+c\nif((a+b)<c):\n d = a*2 + b*2\nprint(d)\n"}, {"source_code": "# cook your dish here\n(a,b,c) = map(int,input().split())\nif(2*(a+b)<=2*c):\n print((a+b)*2)\nelif(2*(a+c)<=2*b):\n print(2*(a+c))\nelif(2*(b+c)<2*a):\n print(2*(b+c))"}, {"source_code": "def house():\n\td1, d2, d3 = raw_input().split()\n\td1 = int(d1)\n\td2 = int(d2)\n\td3 = int(d3)\n\n\tif (d1+d1 + d2+d2) < d3:\n\t\tprint (d1+d1 + d2+d2)\n\telif (d1+d1+d3+d3) < d2:\n\t\tprint (d1+d1+d3+d3)\n\n\telif (d2+d2+d3+d3) < d1:\n\t\tprint (d2+d2+d3+d3)\n\n\telse:\n\t\tprint d1+d2+d3\n\nhouse()"}, {"source_code": "a,b,c=map(int,input().split())\nn=a+b\nprint(n+min(n,c))"}, {"source_code": "a,b,c=map(int,input().split())\nh=0\nans=min(a*2+b*2,a+b+c,b*2+c,a*2+c)\nprint(ans)"}, {"source_code": "def main():\n\ta, b, c = map(int, input().split())\n\tres = min(a+c+b, 2*(a+b))\n\tprint(res)\nmain()"}, {"source_code": "a,b,c = map(int, input().split())\n\nd=2*a+2*min(b,c)\n\n\nprint(d)\n"}, {"source_code": "x = list(map(int, input().split()))\nans = 0\nans+=min(x[0],x[1])\n\nif ans==x[0]:\n\tjk = min(x[0]+(2*x[1]),x[1]+x[2])\n\tif jk==x[0]+(2*x[1]):\n\t\tans+=x[0]+(2*x[1])\n\telif jk==x[1]+x[2]:\n\t\tans+=x[1]+x[2]\n\t\n\n\t\t\nelse:\n\tjk = min(x[1]+(2*x[0]),x[1]+x[2])\n\tif jk==x[0]+(2*x[1]):\n\t\tans+=x[0]+(2*x[1])\n\telif jk==x[1]+x[2]:\n\t\tans+=x[1]+x[2]\n\t\n\nprint (ans)"}, {"source_code": "d1,d2,d3 = map(int,input().split())\nm = 0\nif d1 <= d2:\n m += d1\n if d1+d2 <= d3:\n m += d1+d2\n m += d2\n else:\n m += d3\n if d2 <= d1+d3:\n m += d2\n else:\n m += d1+d3\nelse:\n m += d2\n if d1+d2 <= d3:\n m += d1+d2\n m += d2\n else:\n m += d3\n if d1 <= d2+d3:\n m += d1\n else:\n m += d2+d3\nprint(m)"}, {"source_code": "a,b,c=map(int,input().split())\nprint(min(2*(a*b),a+b+c,2*(b+c),2*(a+c)))"}, {"source_code": "d1,d2,d3=map(int,input().split())\ncount=0\nif d1<=d2:\n\tcount+=d1\n\ta=d1\n\tb=d2\nelse:\n\tcount+=d2\n\ta=d2\n\tb=d1\nif d1+d2+b<=(2*d3)+a:\n\tcount+=(d1+d2+b)\nelse:\n\tcount+=(2*d3)+a\nprint(count)"}, {"source_code": "l = list(map(int, input().split()))\nprint(sum(l) - max(l))"}, {"source_code": "d1,d2,d3=map(int,raw_input().split())\nprint max(d1+d2+d3,2*(d1+d2))"}, {"source_code": "a,b,c = [int(r) for r in raw_input().split()]\n\nprint 2*(a+b) if a+b < c else 2*c"}, {"source_code": "d1,d2,d3 = input().split()\nd1 = int(d1)\nd2 = int(d2)\nd3 = int(d3)\nif d1+d2 >= d3:\n print(d1+d2+d3)\nelse:\n print(2*(d1+d2))"}, {"source_code": "a,b,c=map(int,input().split())\nprint(min(2*(a+c),2*(b+c),a+b+c))"}], "src_uid": "26cd7954a21866dbb2824d725473673e"} {"source_code": "letter = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7}\nnumber = {'1':0, '2':1, '3':2, '4':3, '5':4, '6':5, '7':6, '8':7}\nprnt = {(0, -1):'D', (0, 1):'U', (-1, 0):'L', (1, 0):'R', (1, -1):'RD', (-1, -1):'LD', (1, 1):'RU', (-1, 1):'LU'}\n\ns = raw_input()\nposini = letter[s[0]], number[s[1]]\ns = raw_input()\nposfim = letter[s[0]], number[s[1]]\n\nto_run = posfim[0] - posini[0], posfim[1] - posini[1]\n\nif abs(to_run[0]) > abs(to_run[1]):\n print abs(to_run[0])\nelse:\n print abs(to_run[1])\n \nif to_run[0] > 0 and to_run[1] > 0:\n if to_run[0] > to_run[1]:\n for i in range(to_run[1]):\n print prnt[1, 1]\n to_run = to_run[0] - to_run[1], 0\n else:\n for i in range(to_run[0]):\n print prnt[1, 1]\n to_run = 0, to_run[1] - to_run[0]\nelif to_run[0] > 0 and to_run[1] < 0:\n if to_run[0] > -to_run[1]:\n for i in range(-to_run[1]):\n print prnt[1, -1]\n to_run = to_run[0] + to_run[1], 0\n else:\n for i in range(to_run[0]):\n print prnt[1, -1]\n to_run = 0, to_run[0] + to_run[1]\nelif to_run[0] < 0 and to_run[1] > 0:\n if -to_run[0] > to_run[1]:\n for i in range(to_run[1]):\n print prnt[-1, 1]\n to_run = to_run[0] + to_run[1], 0\n else:\n for i in range(-to_run[0]):\n print prnt[-1, 1]\n to_run = 0, to_run[0] + to_run[1]\nelif to_run[0] < 0 and to_run[1] < 0:\n if -to_run[0] > -to_run[1]:\n for i in range(-to_run[1]):\n print prnt[-1, -1]\n to_run = to_run[0] - to_run[1], 0\n else:\n for i in range(-to_run[0]):\n print prnt[-1, -1]\n to_run = 0, to_run[1] - to_run[0]\n\nif to_run[0] == 0 and to_run[1] > 0:\n for i in range(to_run[1]):\n print prnt[0, 1]\nelif to_run[0] == 0 and to_run[1] < 0:\n for i in range(-to_run[1]):\n print prnt[0, -1]\nelif to_run[0] > 0 and to_run[1] == 0:\n for i in range(to_run[0]):\n print prnt[1, 0]\nelif to_run[0] < 0 and to_run[1] == 0:\n for i in range(-to_run[0]):\n print prnt[-1, 0]", "positive_code": [{"source_code": "str = \"\"\n\ns=raw_input()\ne=raw_input()\n\nsx = ord(e[0])-ord(s[0])\nsy = ord(e[1])-ord(s[1])\n\nmoves=0\n\nwhile sx!=0 or sy!=0:\n if sx>0:\n str+=\"R\"\n sx-=1\n elif sx<0:\n str+=\"L\"\n sx+=1\n if sy>0:\n str+=\"U\"\n sy-=1\n elif sy<0:\n str+=\"D\"\n sy+=1\n str+=\"\\n\"\n moves+=1\n\nprint moves\nprint str\n"}, {"source_code": "a=list(input());b=list(input());x,y,_x,_y=ord(a[0])-97,int(a[1])-1,ord(b[0])-97,int(b[1])-1\nprint(max(abs(x-_x),abs(y-_y)))\nwhile(1):\n if(x==_x and y==_y):break\n if(x<_x):\n x+=1;print('R',end='')\n elif(x>_x):\n x-=1;print('L',end='')\n if(y>_y):\n y-=1;print('D',end='')\n elif(y<_y):\n y+=1;print('U',end='')\n print('')"}, {"source_code": "s = list(input())\nt = list(input())\ns[1] = int(s[1])\nt[1] = int(t[1])\ns[0] = int(ord(s[0]))\nt[0] = int(ord(t[0]))\nres = [];\nwhile True:\n if s[0] == t[0] and s[1] == t[1]:\n break;\n elif s[0] == t[0]:\n if s[1] > t[1]:\n s[1] -= 1\n res.append(\"D\")\n else:\n s[1] += 1\n res.append(\"U\")\n elif s[1] == t[1]:\n if s[0] > t[0]:\n s[0] -= 1\n res.append(\"L\")\n else:\n s[0] += 1\n res.append(\"R\")\n elif s[0] > t[0] and s[1] > t[1]:\n s[0] -= 1; s[1] -= 1;\n res.append(\"LD\")\n elif s[0] > t[0] and s[1] < t[1]:\n s[0] -= 1;s[1] += 1;\n res.append(\"LU\")\n elif s[0] < t[0] and s[1] > t[1]:\n s[0] += 1;s[1] -= 1;\n res.append(\"RD\")\n elif s[0] < t[0] and s[1] < t[1]:\n s[0] += 1;s[1] += 1;\n res.append(\"RU\")\nprint(len(res))\nfor x in res:\n print(x)"}, {"source_code": "point1=raw_input()\npoint2=raw_input()\n\nl=list(point1+point2)\n\nl = [w.replace('a', '1') for w in l]\nl = [w.replace('b', '2') for w in l]\nl = [w.replace('c', '3') for w in l]\nl = [w.replace('d', '4') for w in l]\nl = [w.replace('e', '5') for w in l]\nl = [w.replace('f', '6') for w in l]\nl = [w.replace('g', '7') for w in l]\nl = [w.replace('h', '8') for w in l]\n\narr = []\nsteps = 0\nl = map(int, l)\ndef infinity():\n while True:\n yield\nfor _ in infinity():\n if (l[2]>l[0] and l[3]>l[1]):\n l[0]+=1\n l[1]+=1\n steps+=1\n arr.append(\"RU\" )\n elif (l[2]>l[0] and l[3]<l[1]):\n l[0]+=1\n l[1]-=1\n steps+=1\n arr.append(\"RD\" ) \n elif (l[2]>l[0] and l[3]==l[1]):\n l[0]+=1\n steps+=1\n arr.append(\"R\" ) \n elif (l[2]<l[0] and l[3]>l[1]):\n l[0]-=1\n l[1]+=1\n steps+=1\n arr.append(\"LU\" ) \n elif (l[2]<l[0] and l[3]<l[1]):\n l[1]-=1\n l[0]-=1\n steps+=1\n arr.append(\"LD\" ) \n elif (l[2]<l[0] and l[3]==l[1]):\n l[0]-=1\n steps+=1\n arr.append(\"L\" ) \n elif (l[2]==l[0] and l[3]>l[1]):\n l[1]+=1\n arr.append(\"U\" )\n steps+=1 \n elif (l[2]==l[0] and l[3]<l[1]):\n l[1]-=1\n steps+=1\n arr.append(\"D\" ) \n elif (l[2]==l[0] and l[3]==l[1]):\n break; \nprint steps\nprint \"\\n\".join(arr)\n"}, {"source_code": "point1=raw_input()\npoint2=raw_input()\n\nl=list(point1+point2)\n\nl = [w.replace('a', '1') for w in l]\nl = [w.replace('b', '2') for w in l]\nl = [w.replace('c', '3') for w in l]\nl = [w.replace('d', '4') for w in l]\nl = [w.replace('e', '5') for w in l]\nl = [w.replace('f', '6') for w in l]\nl = [w.replace('g', '7') for w in l]\nl = [w.replace('h', '8') for w in l]\n\narr = []\nsteps = 0\nl = map(int, l)\nx1=l[0]\ny1=l[1]\nx2=l[2]\ny2=l[3]\n\ndef infinity():\n while True:\n yield\nfor _ in infinity():\n if (x2>x1 and y2>y1):\n x1+=1\n y1+=1\n steps+=1\n arr.append(\"RU\" )\n elif (x2>x1 and y2<y1):\n x1+=1\n y1-=1\n steps+=1\n arr.append(\"RD\" ) \n elif (x2>x1 and y2==y1):\n x1+=1\n steps+=1\n arr.append(\"R\" ) \n elif (x2<x1 and y2>y1):\n x1-=1\n y1+=1\n steps+=1\n arr.append(\"LU\" ) \n elif (x2<x1 and y2<y1):\n y1-=1\n x1-=1\n steps+=1\n arr.append(\"LD\" ) \n elif (x2<x1 and y2==y1):\n x1-=1\n steps+=1\n arr.append(\"L\" ) \n elif (x2==x1 and y2>y1):\n y1+=1\n arr.append(\"U\" )\n steps+=1 \n elif (x2==x1 and y2<y1):\n y1-=1\n steps+=1\n arr.append(\"D\" ) \n elif (x2==x1 and y2==y1):\n break; \nprint steps\nprint \"\\n\".join(arr)\n"}, {"source_code": "s = list(input())\nt = list(input())\ns[1] = int(s[1])\nt[1] = int(t[1])\ns[0] = int(ord(s[0]))\nt[0] = int(ord(t[0]))\nres = [];\nwhile True:\n if s[0] == t[0] and s[1] == t[1]:\n break;\n tmp = \"\"\n if s[0] > t[0]: s[0] -= 1; tmp += 'L'\n elif s[0] < t[0]: s[0] += 1; tmp += 'R'\n\n if s[1] > t[1]: s[1] -= 1; tmp += 'D'\n elif s[1] < t[1]: s[1] += 1; tmp += 'U'\n res.append(tmp)\nprint(len(res))\nfor x in res:\n print(x)"}, {"source_code": "L=input\nR=print\na=L()+L()\na,b=(ord(a[i])-ord(a[i+2])for i in(0,1))\nR(max(a,-a,b,-b))\nwhile a!=0 or b!=0:\n r=''\n if a<0:r='R';a+=1\n if a>0:r='L';a-=1\n if b<0:r+='U';b+=1\n if b>0:r+='D';b-=1\n R(r)"}, {"source_code": "s = input()\nt = input()\nd1 = ord(s[0]) - ord(t[0])\nd2 = ord(s[1]) - ord(t[1])\nif d1 < 0:\n d3 = -d1\nelse:\n d3 = d1\nif d2 < 0:\n d4 = -d2\nelse:\n d4 = d2\nif d3 > d4:\n print(d3)\n r = d3\nelse:\n print(d4)\n r = d4\nfor i in range(r):\n if i < d3:\n if d1 < 0:\n print(\"R\", end = '')\n elif d1 > 0:\n print(\"L\", end = '')\n if i < d4:\n if d2 < 0:\n print(\"U\")\n elif d2 > 0:\n print(\"D\")\n else:\n print(\"\")"}, {"source_code": "starting = list(input().lower())\nend_up = list(input())\n# print(starting)\nstring_output = []\ncount = 0\nletter_dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}\n\nstarting[1] = int(starting[1])\nend_up[1] = int(end_up[1])\nstarting[0] = letter_dict[starting[0]]\nend_up[0] = letter_dict[end_up[0]]\n\nwhile starting[0] != end_up[0] and starting[1] != end_up[1]:\n if starting[0] > end_up[0]:\n starting[0] -= 1\n if starting[1] > end_up[1]:\n starting[1] -= 1\n string_output.append('LD')\n else:\n starting[1] += 1\n string_output.append('LU')\n else:\n starting[0] += 1\n if starting[1] > end_up[1]:\n starting[1] -= 1\n string_output.append('RD')\n else:\n starting[1] += 1\n string_output.append('RU')\n count += 1\n\nwhile starting[0] != end_up[0] or starting[1] != end_up[1]:\n if starting[1] == end_up[1]:\n if starting[0] > end_up[0]:\n starting[0] -= 1\n string_output.append('L')\n\n else:\n starting[0] += 1\n string_output.append('R')\n\n else:\n if starting[1] > end_up[1]:\n starting[1] -= 1\n string_output.append('D')\n else:\n starting[1] += 1\n string_output.append('U')\n\n count += 1\n\nprint(count)\nfor i in string_output:\n print(i)\n"}, {"source_code": "start, end, lettermap, numbermap = input(), input(), {'a': 1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8}, {1:'a', 2:'b', 3:'c', 4:'d', 5:'e', 6:'f', 7:'g', 8:'h'}\nif start == end:\n\tprint(0)\nelse:\n\tstart = (lettermap[start[0]], int(start[1]))\n\tend = (lettermap[end[0]], int(end[1]))\n\tdifference = [end[0]-start[0], end[1]-start[1]]\n\t#print(difference)\n\tmoves = []\n\twhile difference != [0,0]:\n\t\tmoves.append(\"\")\n\t\tif difference[0] > 0:\n\t\t\tmoves[-1] = \"R\"\n\t\t\tdifference[0]-=1\n\t\telif difference[0] < 0:\n\t\t\tdifference[0]+=1\n\t\t\tmoves[-1] = \"L\"\n\t\tif difference[1] < 0:\n\t\t\tdifference[1]+=1\n\t\t\tmoves[-1] +=\"D\"\n\t\telif difference[1] > 0:\n\t\t\tdifference[1]-=1\n\t\t\tmoves[-1] += \"U\"\n\tprint(len(moves))\n\tfor move in moves:\n\t\tprint(move)\n"}, {"source_code": "\ufeff\"\"\"\n<div class=\"problem-statement\"><div class=\"header\"><div class=\"title\">A. Shortest path of the king</div><div class=\"time-limit\"><div class=\"property-title\">time limit per test</div>1 second</div><div class=\"memory-limit\"><div class=\"property-title\">memory limit per test</div>64 megabytes</div><div class=\"input-file\"><div class=\"property-title\">input</div>standard input</div><div class=\"output-file\"><div class=\"property-title\">output</div>standard output</div></div><div><p>The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square <span class=\"tex-span\"><i>t</i></span>. As the king is not in habit of wasting his time, he wants to get from his current position <span class=\"tex-span\"><i>s</i></span> to square <span class=\"tex-span\"><i>t</i></span> in the least number of moves. Help him to do this.</p><center> <img class=\"tex-graphics\" src=\"http://codeforces.com/predownloaded/0a/92/0a928ad1310e4dbe9374f953e32def4f56b44743.png\" style=\"max-width: 100.0%;max-height: 100.0%;\"> </center><p>In one move the king can get to the square that has a common side or a common vertex with the square the king is currently in (generally there are 8 different squares he can move to).</p></div><div class=\"input-specification\"><div class=\"section-title\">Input</div><p>The first line contains the chessboard coordinates of square <span class=\"tex-span\"><i>s</i></span>, the second line \u2014 of square <span class=\"tex-span\"><i>t</i></span>.</p><p>Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from <span class=\"tex-font-style-tt\">a</span> to <span class=\"tex-font-style-tt\">h</span>), the second one is a digit from <span class=\"tex-font-style-tt\">1</span> to <span class=\"tex-font-style-tt\">8</span>.</p></div><div class=\"output-specification\"><div class=\"section-title\">Output</div><p>In the first line print <span class=\"tex-span\"><i>n</i></span> \u2014 minimum number of the king's moves. Then in <span class=\"tex-span\"><i>n</i></span> lines print the moves themselves. Each move is described with one of the 8: <span class=\"tex-font-style-tt\">L</span>, <span class=\"tex-font-style-tt\">R</span>, <span class=\"tex-font-style-tt\">U</span>, <span class=\"tex-font-style-tt\">D</span>, <span class=\"tex-font-style-tt\">LU</span>, <span class=\"tex-font-style-tt\">LD</span>, <span class=\"tex-font-style-tt\">RU</span> or <span class=\"tex-font-style-tt\">RD</span>. </p><p><span class=\"tex-font-style-tt\">L</span>, <span class=\"tex-font-style-tt\">R</span>, <span class=\"tex-font-style-tt\">U</span>, <span class=\"tex-font-style-tt\">D</span> stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diagonal moves. If the answer is not unique, print any of them. </p></div><div class=\"sample-tests\"><div class=\"section-title\">Examples</div><div class=\"sample-test\"><div class=\"input\"><div class=\"title\">Input</div><pre>a8<br>h1<br></pre></div><div class=\"output\"><div class=\"title\">Output</div><pre>7<br>RD<br>RD<br>RD<br>RD<br>RD<br>RD<br>RD<br></pre></div></div></div></div>\n\nA. Shortest path of the king\ntime limit per test1 second\nmemory limit per test64 megabytes\ninputstandard input\noutputstandard output\nThe king is left alone on the chessboard. In spite of this loneliness, h\ne doesn't lose heart, because he has business of national importance. Fo\nr example, he has to pay an official visit to square t. As the king is n\not in habit of wasting his time, he wants to get from his current positi\non s to square t in the least number of moves. Help him to do this.\n\n\nIn one move the king can get to the square that has a common side or a c\nommon vertex with the square the king is currently in (generally there a\nre 8 different squares he can move to).\n\nInput\nThe first line contains the chessboard coordinates of square s, the seco\nnd line \u2014 of square t.\n\nChessboard coordinates consist of two characters, the first one is a low\nercase Latin letter (from a to h), the second one is a digit from 1 to 8\n.\n\nOutput\nIn the first line print n \u2014 minimum number of the king's moves. Then in \nn lines print the moves themselves. Each move is described with one of t\nhe 8: L, R, U, D, LU, LD, RU or RD.\n\nL, R, U, D stand respectively for moves left, right, up and down (accord\ning to the picture), and 2-letter combinations stand for diagonal moves.\n If the answer is not unique, print any of them.\n\nExamples\ninput\na8\nh1\noutput\n7\nRD\nRD\nRD\nRD\nRD\nRD\nRD\n\"\"\"\n\nfrom sys import stdin, stdout\n\na1 = stdin.readline().strip()\na2 = stdin.readline().strip()\n\nz1 = map(ord,a1)\nz2 = map(ord,a2)\n\ndef f(p1 = [], p2 = []):\n a1 = ''\n if p1[0] > p2[0] and p1[1] < p2[1]:\n p1[0] -= 1\n p1[1] += 1\n a1 = 'LU'\n elif p1[0] > p2[0] and p1[1] > p2[1]:\n p1[0] -= 1\n p1[1] -= 1\n a1 = 'LD'\n elif p1[0] > p2[0] and p1[1] == p2[1]:\n p1[0] -= 1\n a1 = 'L'\n elif p1[0] < p2[0] and p1[1] < p2[1]:\n p1[0] += 1\n p1[1] += 1\n a1 = 'RU'\n elif p1[0] < p2[0] and p1[1] > p2[1]:\n p1[0] += 1\n p1[1] -= 1\n a1 = 'RD'\n elif p1[0] < p2[0] and p1[1] == p2[1]:\n p1[0] += 1\n a1 = 'R'\n elif p1[0] == p2[0] and p1[1] < p2[1]:\n p1[1] += 1\n a1 = 'U'\n elif p1[0] == p2[0] and p1[1] > p2[1]:\n p1[1] -= 1\n a1 = 'D'\n\n return a1\n\n\n\nans = []\nc1 = 0\nwhile z1 != z2:\n ans.append(f(z1,z2))\n c1 += 1\n \nstdout.write('{:d}\\n'.format(c1))\n\nfor i1 in ans:\n stdout.write('{:s}\\n'.format(i1))\n"}, {"source_code": "\ufeff\"\"\"\n<div class=\"problem-statement\"><div class=\"header\"><div class=\"title\">A. Shortest path of the king</div><div class=\"time-limit\"><div class=\"property-title\">time limit per test</div>1 second</div><div class=\"memory-limit\"><div class=\"property-title\">memory limit per test</div>64 megabytes</div><div class=\"input-file\"><div class=\"property-title\">input</div>standard input</div><div class=\"output-file\"><div class=\"property-title\">output</div>standard output</div></div><div><p>The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square <span class=\"tex-span\"><i>t</i></span>. As the king is not in habit of wasting his time, he wants to get from his current position <span class=\"tex-span\"><i>s</i></span> to square <span class=\"tex-span\"><i>t</i></span> in the least number of moves. Help him to do this.</p><center> <img class=\"tex-graphics\" src=\"http://codeforces.com/predownloaded/0a/92/0a928ad1310e4dbe9374f953e32def4f56b44743.png\" style=\"max-width: 100.0%;max-height: 100.0%;\"> </center><p>In one move the king can get to the square that has a common side or a common vertex with the square the king is currently in (generally there are 8 different squares he can move to).</p></div><div class=\"input-specification\"><div class=\"section-title\">Input</div><p>The first line contains the chessboard coordinates of square <span class=\"tex-span\"><i>s</i></span>, the second line \u2014 of square <span class=\"tex-span\"><i>t</i></span>.</p><p>Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from <span class=\"tex-font-style-tt\">a</span> to <span class=\"tex-font-style-tt\">h</span>), the second one is a digit from <span class=\"tex-font-style-tt\">1</span> to <span class=\"tex-font-style-tt\">8</span>.</p></div><div class=\"output-specification\"><div class=\"section-title\">Output</div><p>In the first line print <span class=\"tex-span\"><i>n</i></span> \u2014 minimum number of the king's moves. Then in <span class=\"tex-span\"><i>n</i></span> lines print the moves themselves. Each move is described with one of the 8: <span class=\"tex-font-style-tt\">L</span>, <span class=\"tex-font-style-tt\">R</span>, <span class=\"tex-font-style-tt\">U</span>, <span class=\"tex-font-style-tt\">D</span>, <span class=\"tex-font-style-tt\">LU</span>, <span class=\"tex-font-style-tt\">LD</span>, <span class=\"tex-font-style-tt\">RU</span> or <span class=\"tex-font-style-tt\">RD</span>. </p><p><span class=\"tex-font-style-tt\">L</span>, <span class=\"tex-font-style-tt\">R</span>, <span class=\"tex-font-style-tt\">U</span>, <span class=\"tex-font-style-tt\">D</span> stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diagonal moves. If the answer is not unique, print any of them. </p></div><div class=\"sample-tests\"><div class=\"section-title\">Examples</div><div class=\"sample-test\"><div class=\"input\"><div class=\"title\">Input</div><pre>a8<br>h1<br></pre></div><div class=\"output\"><div class=\"title\">Output</div><pre>7<br>RD<br>RD<br>RD<br>RD<br>RD<br>RD<br>RD<br></pre></div></div></div></div>\n\nA. Shortest path of the king\ntime limit per test1 second\nmemory limit per test64 megabytes\ninputstandard input\noutputstandard output\nThe king is left alone on the chessboard. In spite of this loneliness, h\ne doesn't lose heart, because he has business of national importance. Fo\nr example, he has to pay an official visit to square t. As the king is n\not in habit of wasting his time, he wants to get from his current positi\non s to square t in the least number of moves. Help him to do this.\n\n\nIn one move the king can get to the square that has a common side or a c\nommon vertex with the square the king is currently in (generally there a\nre 8 different squares he can move to).\n\nInput\nThe first line contains the chessboard coordinates of square s, the seco\nnd line \u2014 of square t.\n\nChessboard coordinates consist of two characters, the first one is a low\nercase Latin letter (from a to h), the second one is a digit from 1 to 8\n.\n\nOutput\nIn the first line print n \u2014 minimum number of the king's moves. Then in \nn lines print the moves themselves. Each move is described with one of t\nhe 8: L, R, U, D, LU, LD, RU or RD.\n\nL, R, U, D stand respectively for moves left, right, up and down (accord\ning to the picture), and 2-letter combinations stand for diagonal moves.\n If the answer is not unique, print any of them.\n\nExamples\ninput\na8\nh1\noutput\n7\nRD\nRD\nRD\nRD\nRD\nRD\nRD\n\"\"\"\n\nfrom sys import stdin, stdout\n\na1 = stdin.readline().strip()\na2 = stdin.readline().strip()\n\nz1 = map(ord,a1)\nz2 = map(ord,a2)\n\ndef f(p1 = [], p2 = []):\n a1 = ''\n if p1[0] > p2[0] and p1[1] < p2[1]:\n p1[0] -= 1\n p1[1] += 1\n a1 = 'LU'\n elif p1[0] > p2[0] and p1[1] > p2[1]:\n p1[0] -= 1\n p1[1] -= 1\n a1 = 'LD'\n elif p1[0] > p2[0] and p1[1] == p2[1]:\n p1[0] -= 1\n a1 = 'L'\n elif p1[0] < p2[0] and p1[1] < p2[1]:\n p1[0] += 1\n p1[1] += 1\n a1 = 'RU'\n elif p1[0] < p2[0] and p1[1] > p2[1]:\n p1[0] += 1\n p1[1] -= 1\n a1 = 'RD'\n elif p1[0] < p2[0] and p1[1] == p2[1]:\n p1[0] += 1\n a1 = 'R'\n elif p1[0] == p2[0] and p1[1] < p2[1]:\n p1[1] += 1\n a1 = 'U'\n elif p1[0] == p2[0] and p1[1] > p2[1]:\n p1[1] -= 1\n a1 = 'D'\n\n return a1\n\n\nans = []\nc1 = 0\nwhile z1 != z2:\n ans.append(f(z1,z2))\n c1 += 1\n \nstdout.write('{:d}\\n'.format(c1))\n\nfor i1 in ans:\n stdout.write('{:s}\\n'.format(i1))\n"}, {"source_code": "s=input()\nt=input()\ncount=0\nif(s[0]==t[0]):\n if(s[1]>t[1]):\n value1=int(s[1])-int(t[1])\n count=count+value1\n print(value1)\n for i in range(value1):\n print('D')\n \n elif(s[1]<t[1]):\n value1=int(t[1])-int(s[1])\n count=count+value1\n print(value1)\n for i in range(value1):\n print('U')\n else:\n print(0)\nelif(s[1]==t[1]):\n if(s[0]>t[0]):\n value1=ord(s[0])-ord(t[0])\n count=count+value1\n print(value1)\n for i in range(value1):\n print('L')\n \n elif(s[0]<t[0]):\n value1=ord(t[0])-ord(s[0])\n count=count+value1\n print(value1)\n for i in range(value1):\n print('R')\nelif(s[0]<t[0]):\n if(s[1]>t[1]):\n a=ord(t[0])-ord(s[0])\n b=int(s[1])-int(t[1])\n value1=min(a,b)\n count=count+value1\n s=s.replace(s[0],chr(ord(s[0])+value1))\n s=s.replace(s[1],str(int(s[1])-value1))\n if(s[0]==t[0]):\n value2=int(s[1])-int(t[1])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('RD')\n for i in range(value2):\n print('D')\n elif(s[1]==t[1]):\n value2=ord(t[0])-ord(s[0])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('RD')\n for i in range(value2):\n print('R')\n\n elif(s[1]<t[1]):\n a=ord(t[0])-ord(s[0])\n b=int(t[1])-int(s[1])\n value1=min(a,b)\n count=count+value1\n \n s=s.replace(s[0],chr(ord(s[0])+value1))\n s=s.replace(s[1],str(int(s[1])+value1))\n if(s[0]==t[0]):\n value2=int(t[1])-int(s[1])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('RU')\n for i in range(value2):\n print('U')\n elif(s[1]==t[1]):\n value2=ord(t[0])-ord(s[0])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('RU')\n for i in range(value2):\n print('R')\nelif(s[0]>t[0]):\n if(s[1]<t[1]):\n a=ord(s[0])-ord(t[0])\n b=int(t[1])-int(s[1])\n value1=min(a,b)\n count=count+value1\n \n s=s.replace(s[0],chr(ord(s[0])-value1))\n s=s.replace(s[1],str(int(s[1])+value1))\n if(s[0]==t[0]):\n value2=int(t[1])-int(s[1])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('LU')\n for i in range(value2):\n print('U')\n elif(s[1]==t[1]):\n value2=ord(s[0])-ord(t[0])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('LU')\n for i in range(value2):\n print('L')\n elif(s[1]>t[1]):\n a=ord(s[0])-ord(t[0])\n b=int(s[1])-int(t[1])\n value1=min(a,b)\n count=count+value1\n \n s=s.replace(s[0],chr(ord(s[0])-value1))\n s=s.replace(s[1],str(int(s[1])-value1))\n if(s[0]==t[0]):\n value2=int(s[1])-int(t[1])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('LD')\n for i in range(value2):\n print('D')\n elif(s[1]==t[1]):\n value2=ord(s[0])-ord(t[0])\n count=count+value2\n print(value1+value2)\n for i in range(value1):\n print('LD')\n for i in range(value2):\n print('L')\n\n \n \n "}, {"source_code": "s = input()\nf = input()\nx = ord(s[0])-ord(f[0])\ny = ord(s[1])-ord(f[1])\nprint(max(x,y,-x,-y))\nwhile x != 0 or y != 0:\n st = \"\"\n if x < 0:\n st += \"R\"\n x = x + 1\n if x > 0:\n st = st + \"L\"\n x = x - 1\n if y < 0:\n st = st + \"U\"\n y = y + 1\n if y > 0:\n st = st + \"D\"\n y = y - 1\n print(st)"}, {"source_code": "n=input()\ns=input()\na=ord(n[0])-ord(s[0])\nb=int(n[1])-int(s[1])\nprint(max(-a,-b,a,b))\nwhile a!=0 or b!=0:\n ans=''\n if a>0:\n ans+=\"L\"\n a-=1\n if a<0:\n ans+=\"R\"\n a+=1\n if b>0:\n ans+=\"D\"\n b-=1\n if b<0:\n ans+='U'\n b+=1\n print(ans) \n "}, {"source_code": "s = input()\nt = input()\n\ndelta_col = ord(t[0]) - ord(s[0])\ndelta_row = int(t[1]) - int(s[1])\n\nnum_moves = min(abs(delta_col), abs(delta_row))\n\nif delta_col > 0:\n delta_col -= num_moves\n if delta_row > 0:\n moves_list = ['RU' for __ in range(num_moves)]\n delta_row -= num_moves\n else:\n moves_list = ['RD' for __ in range(num_moves)]\n delta_row += num_moves\n\nelse:\n delta_col += num_moves\n if delta_row > 0:\n moves_list = ['LU' for __ in range(num_moves)]\n delta_row -= num_moves\n\n else:\n moves_list = ['LD' for __ in range(num_moves)]\n delta_row += num_moves\n\nnum_rem_moves = max(abs(delta_col), abs(delta_row))\nnum_moves += num_rem_moves\n\nif delta_col > 0:\n moves_list += ['R' for __ in range(num_rem_moves)]\nelif delta_col < 0:\n moves_list += ['L' for __ in range(num_rem_moves)]\nelif delta_row > 0:\n moves_list += ['U' for __ in range(num_rem_moves)]\nelif delta_row < 0:\n moves_list += ['D' for __ in range(num_rem_moves)]\n\nprint(num_moves)\nprint(*moves_list, sep='\\n')\n"}, {"source_code": "s = raw_input()\nt = raw_input()\nnum_moves = 0\nmoves = []\nwhile s != t:\n move = ''\n if ord(s[0]) > ord(t[0]):\n move += 'L'\n s = chr(ord(s[0]) - 1) + s[1]\n elif ord(s[0]) < ord(t[0]):\n move += 'R'\n s = chr(ord(s[0]) + 1) + s[1]\n\n if int(s[1]) > int(t[1]):\n move += 'D'\n s = s[0] + str(int(s[1])-1)\n elif int(s[1]) < int(t[1]):\n move += 'U'\n s = s[0] + str(int(s[1])+1)\n\n moves.append(move)\n num_moves += 1\nprint num_moves\nfor move in moves: print move\n"}, {"source_code": "s = raw_input()\nt = raw_input()\n\nsx = ord(s[0])-ord(\"a\")+1\nsy = int(s[1])\ntx = ord(t[0])-ord(\"a\")+1\nty = int(t[1])\n\nprint max(abs(sx - tx), abs(sy - ty))\nwhile (sx != tx or sy != ty):\n res = \"\"\n if (tx > sx):\n sx += 1\n res += \"R\"\n if (tx < sx):\n sx -= 1\n res += \"L\"\n if (ty > sy):\n sy += 1\n res += \"U\"\n if (ty < sy):\n sy -= 1\n res += \"D\"\n print res\n"}, {"source_code": "mov = {-1:'RU',1:'LD'}\ns,t = input(),input()\nx,y,x1,y1 = ord(s[0])-96,int(s[1]),ord(t[0])-96,int(t[1])\nv,h = abs(x-x1),abs(y-y1)\nif x==x1 or y==y1:\n temp = (x-x1)//abs(x-x1) if x-x1 else (y-y1)//abs(y-y1) if y-y1 else 0\n if temp == 0: print(0); exit()\n jmp = max(abs(x-x1),abs(y-y1))\n p0 = [mov[temp][0]]*jmp if y-y1 == 0 else [mov[temp][1]]*jmp\n print(len(p0)); print(*p0)\nelse:\n pos = mov[(x-x1)//v][0] + mov[(y-y1)//h][1]\n j1,j2 = v-h if v-h > -1 else abs(v-h)+v, h-v if h-v > -1 else abs(h-v)+h\n p1,p2 = [pos[0]]*j1+[pos]*h,[pos[1]]*j2+[pos]*v\n if len(p1) < len(p2): print(len(p1)); print(*p1)\n else: print(len(p2)); print(*p2)"}, {"source_code": "\nn = input()\nm = input()\nx0 = ord(n[0])\ny0 = ord(n[1])\nx1 = ord(m[0]) #initial positions and final position\ny1 = ord(m[1])\nk = abs(x0 - x1)\nu = abs(y0 - y1)\nprint(min(k,u)+ abs(k-u))\nwhile True:\n if x0 < x1:\n print('R', end='')\n x0 = x0 + 1\n elif x0 > x1:\n print('L', end='')\n x0 = x0 - 1\n if y0 < y1:\n print('U', end='')\n y0 = y0 + 1\n elif y0 > y1:\n print('D', end='')\n y0 = y0 - 1\n print('')\n if x0 == x1 and y0 == y1:\n break"}, {"source_code": "s=list(input())\na=list(input())\nr=ord(s[0])-ord(a[0])\ny=int(s[1])-int(a[1])\nprint(max(r,y,-r,-y))\nl=[]\nwhile(r!=0 or y!=0):\n\tl=[]\n\tif(r>0):\n\t\tl.append('L')\n\t\tr=r-1\n\tif(r<0):\n\t\tl.append('R')\n\t\tr=r+1\n\tif(y>0):\n\t\tl.append('D')\n\t\ty=y-1\n\tif(y<0):\n\t\tl.append('U')\n\t\ty=y+1\n\tprint(\"\".join(l))\n"}, {"source_code": "origin = input()\ntarget = input()\n\ndef char2Num(c):\n return ord(c)-ord('a')+1\n\ndef num2Char(d):\n return chr(ord('a')+d-1)\n\nx_origin = char2Num(origin[0])\ny_origin = int(origin[1])\n\nx_target = char2Num(target[0])\ny_target = int(target[1])\n\nx = x_origin\ny = y_origin\nsteps = []\n\nwhile x < x_target and y < y_target: # keep RU until x reaches x_target or y reaches y_target\n steps.append('RU')\n x += 1\n y += 1\nwhile x<x_target and y > y_target:\n steps.append('RD')\n x += 1\n y -= 1\nwhile x > x_target and y < y_target: \n steps.append('LU')\n x -= 1\n y += 1\nwhile x>x_target and y > y_target:\n steps.append('LD')\n x -= 1\n y -= 1\nwhile x < x_target:\n steps.append('R') \n x += 1\nwhile x > x_target:\n steps.append('L') \n x -= 1\nwhile y < y_target:\n steps.append('U')\n y += 1\nwhile y > y_target:\n steps.append('D')\n y -= 1 \nprint(len(steps))\nfor step in steps:\n print(step)"}, {"source_code": "start = raw_input()\nend = raw_input()\nx = ord(end[0])-ord(start[0])\ny = int(end[1])-int(start[1])\na = min(abs(x),abs(y))\nprint max(abs(x),abs(y))\nif x>=0 and y>=0:\n for _ in xrange(a):\n print 'RU'\n for _ in xrange(abs(x)-a):\n print 'R'\n for _ in xrange(abs(y)-a):\n print 'U'\n\nif x>=0 and y<0:\n for _ in xrange(a):\n print 'RD'\n for _ in xrange(abs(x)-a):\n print 'R'\n for _ in xrange(abs(y)-a):\n print 'D'\n\nif x<0 and y>=0:\n for _ in xrange(a):\n print 'LU'\n for _ in xrange(abs(x)-a):\n print 'L'\n for _ in xrange(abs(y)-a):\n print 'U'\n\nif x<0 and y<0:\n for _ in xrange(a):\n print 'LD'\n for _ in xrange(abs(x)-a):\n print 'L'\n for _ in xrange(abs(y)-a):\n print 'D'"}, {"source_code": "import string\n\n\nif __name__ == '__main__':\n s = raw_input()\n t = raw_input()\n\n letter2loc = dict(zip('abcdefgh', range(1, 9)))\n\n loc = [letter2loc[s[0]], int(s[1])]\n target = [letter2loc[t[0]], int(t[1])]\n\n vertical_dict = {True: 'U', False: 'D'}\n horizontal_dict = {True: 'R', False: 'L'}\n\n move_dict = {'U': 1, 'D': -1, 'L': -1, 'R': 1}\n\n horiz, vert = target[0]-loc[0], target[1]-loc[1]\n diag_dist = min(abs(horiz), abs(vert))\n print max(abs(horiz)-diag_dist, abs(vert)-diag_dist) + diag_dist\n while (not horiz == 0) and (not vert == 0):\n horiz_move = horizontal_dict[horiz > 0]\n vert_move = vertical_dict[vert > 0]\n\n print horiz_move + vert_move\n\n loc[0] += move_dict[horiz_move]\n loc[1] += move_dict[vert_move]\n\n horiz, vert = target[0]-loc[0], target[1]-loc[1]\n\n if not vert == 0:\n while abs(vert) > 0:\n vert_move = vertical_dict[vert > 0]\n print vert_move\n loc[1] += move_dict[vert_move]\n vert = target[1]-loc[1]\n elif not horiz == 0:\n while abs(horiz) > 0:\n horiz_move = horizontal_dict[horiz > 0]\n print horiz_move\n loc[0] += move_dict[horiz_move]\n horiz = target[0]-loc[0]\n"}, {"source_code": "from math import *\n\ndef sign(x):\n\tif x < 0:\n\t\treturn -1\n\telif x > 0:\n\t\treturn 1\n\treturn 0\n\ns = input()\nx = ord(s[0])-ord('a')\ny = int(s[1])\nt = input()\ntx = ord(t[0])-ord('a')\nty = int(t[1])\nvx = tx-x\nif vx < 0:\n\tansx = 'L'\nelse:\n\tansx = 'R'\nvy = ty-y\nif vy < 0:\n\tansy = 'D'\nelse:\n\tansy = 'U'\nprint(max(abs(vx),abs(vy)))\nwhile vx != 0 or vy != 0:\n\tans = \"\"\n\tif vx != 0:\n\t\tans += ansx\n\t\tvx -= sign(vx)\n\tif vy != 0:\n\t\tans += ansy\n\t\tvy -= sign(vy)\n\tprint(ans)"}, {"source_code": "a,b = list(raw_input())\nc,d = list(raw_input())\na = ord(a)-96\nc = ord(c)-96\nb = int(b)\nd = int(d)\nmaxdiff = abs(d-b) if abs(d-b)>abs(c-a) else abs(c-a)\nmov_verti = []\nwhile c>a:\n mov_verti.append('R')\n a+=1\nwhile c<a:\n mov_verti.append('L')\n a-=1\nmov_hori = []\nwhile d<b:\n mov_hori.append('D')\n b-=1\nwhile d>b:\n mov_hori.append('U')\n b+=1\nprint maxdiff\nfor i in xrange(maxdiff):\n try:\n nxt_mov = mov_verti[i]+mov_hori[i]\n except:\n try:\n nxt_mov = mov_verti[i]\n except:\n nxt_mov = mov_hori[i]\n print nxt_mov\n"}, {"source_code": "class ShortestPathKing:\n def solve(self, s, t):\n movect = 0\n moves = []\n horiz = {}\n vert = {}\n startcol = ord(s[0]) - 96\n startrow = int(s[1])\n endcol = ord(t[0]) - 96\n endrow = int(t[1])\n coldist = endcol - startcol\n rowdist = endrow - startrow\n if coldist < 0:\n horiz[\"L\"] = abs(coldist)\n else:\n horiz[\"R\"] = coldist\n if rowdist < 0:\n vert[\"D\"] = abs(rowdist)\n else:\n vert[\"U\"] = rowdist\n\n horizontal = horiz.values()[0]\n vertical = vert.values()[0]\n if vertical > horizontal:\n for x in range(0, horizontal): moves.append((horiz.keys()[0] + vert.keys()[0]))\n vertical -= horizontal\n horizontal = 0\n for y in range(0, vertical): moves.append((vert.keys()[0]))\n else:\n for x in range(0, vertical): moves.append((horiz.keys()[0] + vert.keys()[0]))\n horizontal -= vertical\n vertical = 0\n for y in range(0, horizontal): moves.append((horiz.keys()[0]))\n\n print len(moves)\n for x in moves:\n print x\n\n\nif __name__ == \"__main__\":\n s = str(raw_input())\n t = str(raw_input())\n spk = ShortestPathKing()\n spk.solve(s, t)"}, {"source_code": "m = input()\nn = input()\nx1 = ord(m[0])\ny1 = ord(m[1])\nx2 = ord(n[0])\ny2 = ord(n[1])\ndx = x1-x2\ndy = y1-y2\nif abs(dx) > abs(dy) : print(abs(dx))\nelse: print(abs(dy))\nwhile dx != 0 or dy != 0:\n result = \"\"\n b1=0\n b2=0\n if dx < 0 :\n dx = dx+1\n b1 = 1\n elif dx > 0:\n dx = dx-1\n b1 =-1\n if dy < 0:\n dy = dy + 1\n b2 = 1\n elif dy > 0:\n dy = dy - 1\n b2 = -1\n if b1 == 1 :\n result = result + \"R\"\n elif b1 == -1 :\n result = result + \"L\"\n if b2 == 1:\n result = result + \"U\"\n elif b2 == -1 :\n result = result + \"D\"\n print(result[0:len(result)])"}, {"source_code": "d = {\"a\":1, \"b\":2, \"c\":3, \"d\":4, \"e\":5, \"f\":6, \"g\":7, \"h\":8}\nne = {\"a\":\"b\", \"b\":\"c\", \"c\":\"d\", \"d\":\"e\", \"e\":\"f\", \"f\":\"g\", \"g\":\"h\"}\npr = {\"h\":\"g\", \"g\":\"f\", \"f\":\"e\", \"e\":\"d\", \"d\":\"c\", \"c\":\"b\", \"b\":\"a\"}\ns = list(input())\nst = list(input())\nnum1 = int(s[1])\nnum2 = int(st[1])\nprint(max(abs(d[s[0]]-d[st[0]]),abs(num1-num2)))\n\nwhile True:\n if s[0] < st[0]:\n if num1 < num2:\n print(\"RU\")\n num1 += 1\n s[0] = ne[s[0]]\n elif num1 > num2:\n print(\"RD\")\n num1 -= 1\n s[0] = ne[s[0]]\n else:\n print(\"R\")\n s[0] = ne[s[0]]\n elif s[0] > st[0]:\n if num1 < num2:\n print(\"LU\")\n num1 += 1\n s[0] = pr[s[0]]\n elif num1 > num2:\n print(\"LD\")\n num1 -= 1\n s[0] = pr[s[0]]\n else:\n print(\"L\")\n s[0] = pr[s[0]]\n else:\n if num1 < num2:\n print(\"U\")\n num1 += 1\n elif num1 > num2:\n print(\"D\")\n num1 -= 1\n else:\n break\n"}, {"source_code": "# Class for Point\nclass Point:\n def __init__(self , x , y):\n self.x = x \n self.y = y\n\n# input start and end Point\nstr = raw_input()\nstart = Point(8-int(str[1]) , ord(str[0])-97)\n\nstr = raw_input()\nend = Point(8-int(str[1]) , ord(str[0])-97)\n\n# solve this problem\ndir = [[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1],[-1,-1]]\nmove = [\"U\",\"RU\",\"R\",\"RD\",\"D\",\"LD\",\"L\",\"LU\"]\nans = max(abs(start.x-end.x) , abs(start.y-end.y))\n\n# output\nprint ans\nm = ans\n\nx = start.x\ny = start.y\n\n# print \"%d %d\" % (start.x , start.y)\n# print \"%d %d\" % (end.x , end.y)\n\nwhile m > 0:\n for i in range(8):\n tmpx = x+dir[i][0]\n tmpy = y+dir[i][1]\n if (tmpx >= 0 and tmpx < 8 and tmpy >= 0 and tmpy < 8):\n dis = max(abs(tmpx-end.x) , abs(tmpy-end.y)) \n if dis < m:\n print move[i]\n x = tmpx\n y = tmpy\n break\n m -= 1 \n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nstart = raw_input().lower()\nend = raw_input().lower()\n\nsx, sy = ord(start[0]) - ord('a') + 1, int(start[1])\ndx, dy = ord(end[0]) - ord('a') + 1, int(end[1])\n\nn = 0\nsteps = []\n\nwhile (sx, sy) != (dx, dy):\n n += 1\n if sx > dx:\n if sy > dy:\n steps.append('LD')\n sx -= 1\n sy -= 1\n elif sy == dy:\n steps.append('L')\n sx -= 1\n elif sy < dy:\n steps.append('LU')\n sx -= 1\n sy += 1\n\n elif sx == dx:\n if sy > dy:\n steps.append('D')\n sy -= 1\n elif sy < dy:\n steps.append('U')\n sy += 1\n\n elif sx < dx:\n if sy > dy:\n steps.append('RD')\n sx += 1\n sy -= 1\n elif sy == dy:\n steps.append('R')\n sx += 1\n elif sy < dy:\n steps.append('RU')\n sx += 1\n sy += 1\n\nprint(n)\nprint('\\n'.join(steps))\n"}, {"source_code": "s=input()\nt = input()\nu,v= ord(s[0])-ord(t[0]),ord(s[1])-ord(t[1])\nprint(max(u,-u,v,-v))\nwhile u!=0 or v!=0:\n a=''\n if u<0:\n a='R'\n u+=1\n if u>0:\n a='L'\n u-=1\n if v<0:\n a+='U'\n v+=1\n if v>0:\n a+='D'\n v-=1\n print(a)"}, {"source_code": "dict={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n\n\nc=list(input())\nd=list(input())\nc[0]=dict[c[0]]\nd[0]=dict[d[0]]\nc[1]=int(c[1])\nd[1]=int(d[1])\nhor=[]\nif c[0]>=d[0]:\n hor.extend(list(\"L\"*(c[0]-d[0])))\nelse:\n hor.extend(list(\"R\"*abs(c[0]-d[0])))\n\n\nver=[]\nif c[1]>=d[1]:\n ver.extend(list(\"D\"*(c[1]-d[1])))\nelse:\n ver.extend(list(\"U\"*abs(c[1]-d[1])))\nprint(max(len(ver),len(hor)))\n#print(hor,ver)\nfor i in range(min(len(ver),len(hor))):\n print(hor[i],end='')\n print(ver[i])\nif len(ver)>len(hor):\n if len(hor)!=0:\n print('\\n'.join(ver[(len(hor)):]))\n else:\n print('\\n'.join(ver))\nelif len(ver)<len(hor):\n if len(ver)!=0:\n print('\\n'.join(hor[abs(len(ver)):]))\n else:\n print('\\n'.join(hor))\n"}, {"source_code": "def get_position(position):\n y, x = position\n y = ord(y)-ord('a')\n x = 8 - int(x)\n return x,y\n \n\nsource = input()\ndestination = input()\nsource_x, source_y = get_position(source)\ndestination_x, destination_y = get_position(destination)\n#print(source_x, source_y)\n#print(destination_x, destination_y)\nif source_x == destination_x and source_y == destination_y:\n print(0)\nelif source_x == destination_x:\n d = abs(source_y-destination_y)\n print(d)\n if source_y<destination_y:\n for i in range(d):\n print(\"R\")\n else:\n for i in range(d):\n print(\"L\") \nelif source_y == destination_y:\n d = abs(source_x-destination_x)\n print(d)\n if source_x<destination_x:\n for i in range(d):\n print(\"D\")\n else:\n for i in range(d):\n print(\"U\")\n\nelif (source_x - destination_x) == (source_y - destination_y):\n d = abs(source_x-destination_x)\n print(d)\n if source_x<destination_x:\n for i in range(d):\n print(\"RD\")\n elif source_x>destination_x:\n for i in range(d):\n print(\"RU\")\n elif source_y<destination_y:\n for i in range(d):\n print(\"LD\")\n elif source_y>destination_y:\n for i in range(d):\n print(\"LU\")\nelse:\n if source_x<destination_x and source_y<destination_y:\n dx = abs(source_x-destination_x)\n dy = abs(source_y-destination_y)\n diag = min(dx, dy)\n line = max(dx, dy) - diag\n print(diag + line)\n for i in range(diag):\n print(\"RD\")\n source_x += 1\n source_y += 1\n if source_y == destination_y:\n for i in range(line):\n print(\"D\") \n else:\n for i in range(line):\n print(\"R\") \n elif source_x<destination_x and source_y>destination_y:\n dx = abs(source_x-destination_x)\n dy = abs(source_y-destination_y) \n diag = min(dx, dy)\n line = max(dx, dy) - diag\n print(diag + line)\n for i in range(diag):\n print(\"LD\")\n source_x += 1\n source_y -= 1\n if source_y == destination_y:\n for i in range(line):\n print(\"D\") \n else:\n for i in range(line):\n print(\"L\") \n elif source_x>destination_x and source_y<destination_y:\n dx = abs(source_x-destination_x)\n dy = abs(source_y-destination_y) \n diag = min(dx, dy)\n line = max(dx, dy) - diag\n print(diag + line)\n for i in range(diag):\n print(\"RU\")\n source_x -= 1\n source_y += 1\n if source_x == destination_x:\n for i in range(line):\n print(\"R\")\n else:\n for i in range(line):\n print(\"U\") \n elif source_x>destination_x and source_y>destination_y:\n dx = abs(source_x-destination_x)\n dy = abs(source_y-destination_y) \n diag = min(dx, dy)\n line = max(dx, dy) - diag\n print(diag + line)\n for i in range(diag):\n print(\"LU\")\n source_x -= 1\n source_y -= 1\n if source_x == destination_x:\n for i in range(line):\n print(\"L\")\n else:\n for i in range(line):\n print(\"U\") \n\"\"\"\nb7\nh8\n\n\nInput\nh1\nb2\n7 7\n6 1\n\nOutput\n7\nLU\nU\nU\nU\nU\nU\nU\nAnswer\n6\nLU\nL\nL\nL\nL\nL\n\"\"\"\n"}, {"source_code": "a=input()\nb=input()\nx=ord(a[0])-ord(b[0])\ny=int(a[1])-int(b[1])\nprint(max(x,y,-x,-y))\nwhile x!=0 or y!=0:\n s=\"\"\n if x>0: s+=\"L\"; x-=1\n if x<0: s+=\"R\"; x+=1\n if y>0: s+=\"D\"; y-=1\n if y<0: s+=\"U\"; y+=1\n print(s)"}, {"source_code": "s = input()\nd = input()\n\nsr = int(s[1])\nsc = ord(s[0]) - ord('a') + 1\n\ndr = int(d[1])\ndc = ord(d[0]) - ord('a') + 1\n\ncount = 0\n\nl = []\n\nwhile(sr != dr or sc != dc):\n count += 1\n s = ''\n if dc > sc:\n sc+=1\n s+='R'\n #print('R',end='')\n if dc < sc:\n sc -= 1\n s+='L'\n #print('L',end='')\n\n if dr > sr:\n sr += 1\n s+='U'\n #print('U',end='')\n\n if dr < sr:\n sr -= 1\n s+='D'\n #print('D',end='')\n\n l.append(s)\n\nprint(count)\nfor x in l:\n print(x)\n"}, {"source_code": "s = input()\ns1, s2 = s[0], s[1]\nt = input()\nt1, t2 = t[0], t[1]\nv_dif = int(s2)-int(t2)\nh_dif = ord(s1)-ord(t1)\nstep = max(abs(v_dif), abs(h_dif))\nnond = abs(abs(v_dif) - abs(h_dif))\nprint(step)\nfor i in range(nond):\n if abs(v_dif) > abs(h_dif):\n if v_dif < 0:\n print(\"U\")\n else:\n print(\"D\")\n else:\n if h_dif < 0:\n print(\"R\")\n else:\n print(\"L\")\nfor i in range(step - nond):\n if v_dif < 0 and h_dif < 0:\n print(\"RU\")\n elif v_dif > 0 and h_dif < 0:\n print(\"RD\")\n elif v_dif < 0 and h_dif > 0:\n print(\"LU\")\n elif v_dif > 0 and h_dif > 0:\n print(\"LD\")\n"}, {"source_code": "x=input()\np=x[0];q=int(x[1]);\ny=input()\na=y[0];b=int(y[1]);t=0;d={};\nfor i in \"abcdefgh\" :\n t+=1\n d[i]=t\nmax=max(abs(d[p]-d[a]),abs(q-b))\nmin=min(abs(d[p]-d[a]),abs(q-b))\nprint(max)\nif d[p]-d[a]>=0 :\n for i in range(min) :\n print(\"L\",end=\"\")\n if q-b >=0 :\n print(\"D\")\n else :\n print(\"U\")\nelse :\n for i in range(min) :\n print(\"R\",end=\"\")\n if q-b >=0 :\n print(\"D\")\n else :\n print(\"U\")\nif abs(d[p]-d[a]) < abs(q-b) :\n for i in range (max-min) :\n if q-b >=0 :\n print(\"D\")\n else :\n print(\"U\")\nelse :\n for i in range (max-min) :\n if d[p]-d[a] >=0 :\n print(\"L\")\n else :\n print(\"R\")"}, {"source_code": "def Shortestpathoftheking(s,t):\n \n a = s+t\n a,b = (ord(a[i])-ord(a[i+2]) for i in (0,1))\n \n print(max(a,-a,b,-b))\n \n while a != 0 or b != 0:\n \n r = \"\"\n \n if a < 0: r = \"R\"; a += 1\n \n elif a > 0: r = \"L\"; a -= 1\n \n if b < 0: r += \"U\"; b += 1\n \n elif b > 0: r += \"D\"; b -= 1\n \n print(r)\n \n return \"\"\n\n\nLista = []\n\nfor i in range(2):\n All = [str(i) for i in input().split()]\n Lista.append(All)\n\nfor j in range(0,len(Lista),2):\n print(Shortestpathoftheking(Lista[j][0],Lista[j+1][0]))"}, {"source_code": "s = input()\nt = input()\n\nend = crr = []\n\ncrr = ord(s[0]) - 96, int(s[1])\nend = ord(t[0]) - 96, int(t[1])\n\na = crr[0] - end[0]\nb = crr[1] - end[1]\n\nprint(max(a, -a, b, -b))\n\nwhile a or b != 0:\n p = \"\"\n if a < 0:\n p = \"R\"\n a += 1\n if a > 0:\n p = \"L\"\n a -= 1\n if b < 0:\n p += \"U\"\n b += 1\n if b > 0:\n p += \"D\"\n b -= 1\n print(p)\n"}, {"source_code": "import sys\n\ndef get_double_move(h,v):\n if h < 0 and v < 0:\n return 'LD'\n elif h > 0 and v < 0:\n return 'RD'\n elif h < 0 and v > 0:\n return 'LU'\n elif h > 0 and v > 0:\n return 'RU'\n\ndef get_single_move(h,v):\n if abs(h)>abs(v):\n if h > 0:\n return 'R'\n elif h < 0:\n return 'L'\n elif abs(h)<abs(v):\n if v < 0:\n return 'D'\n elif v > 0:\n return 'U'\n\nline1 = sys.stdin.readline()\nline2 = sys.stdin.readline()\n\ndx = int(ord(line2[0])-ord(line1[0]))\ndy = int(ord(line2[1])-ord(line1[1]))\ndouble = get_double_move(dx,dy)\nsingle = get_single_move(dx,dy)\n\nprint(max(abs(dx),abs(dy)))\nfor i in range(0,min(abs(dx),abs(dy))):\n print(double)\n\nfor i in range(min(abs(dx),abs(dy)), max(abs(dx),abs(dy))):\n print(single)\n"}, {"source_code": "tab = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7}\n\n\ndef norm(a):\n x = tab[a[0]]\n y = int(a[1]) - 1\n return (x, y)\n\n# l:1 r:10 u:100 d:1000\n\n\ndef decode(d):\n dic = {1: 'L', 2: 'R', 4: 'U', 5: 'LU', 6: 'RU', 8: 'D', 9: 'LD', 10: 'RD'}\n return dic[d]\n\n\ndef getDirection(fx, fy, tx, ty):\n r = 0\n x = y = 0\n if fx < tx:\n r |= 1 << 1\n x = 1\n elif fx > tx:\n r |= 1\n x = -1\n else:\n x = 0\n if fy < ty:\n r |= 1 << 2\n y = 1\n elif fy > ty:\n r |= 1 << 3\n y = -1\n else:\n y = 0\n return r, x, y\n\n\nfro = input()\nfx, fy = norm(fro)\nto = input()\ntx, ty = norm(to)\nmove = []\nwhile fx != tx or fy != ty:\n r, x, y = getDirection(fx, fy, tx, ty)\n move.append(decode(r))\n fx += x\n fy += y\nprint(len(move))\nfor m in move:\n print(m)\n"}, {"source_code": "startpoint = input()\nendpoint = input()\nstart=[0,0]\nend = [0,0]\ncounter = 0\nmoves = []\ndef gettingfirst(n):\n if n[0]==\"a\":\n return 1\n elif n[0]==\"b\":\n return 2\n elif n[0]==\"c\":\n return 3\n elif n[0]==\"d\":\n return 4\n elif n[0]==\"e\":\n return 5\n elif n[0]==\"f\":\n return 6\n elif n[0]==\"g\":\n return 7\n elif n[0]==\"h\":\n return 8\nstart[0] = gettingfirst(startpoint)\nend[0] = gettingfirst(endpoint)\nstart[1] = int(startpoint[1])\nend[1] = int(endpoint[1])\ndirection = [0,0]\ndirection[0] = end[0] - start[0]\ndirection[1] = end[1] - start[1]\nwhile not 0 in direction:\n if direction[0] * direction[1] < 0:\n if direction[0] < 0:\n moves.append(\"LU\")\n counter+=1\n direction[0] += 1\n direction[1] -= 1\n else:\n moves.append(\"RD\")\n counter+=1\n direction[0]-=1\n direction[1]+=1\n else:\n if direction[0] < 0:\n moves.append(\"LD\")\n counter+=1\n direction[0] += 1\n direction[1] += 1\n else:\n if direction[0] >0:\n moves.append(\"RU\")\n counter+=1\n direction[0] -= 1\n direction[1] -= 1\nwhile not direction[0] == 0:\n if direction[0] > 0:\n moves.append(\"R\")\n counter+=1\n direction[0]-=1\n else:\n moves.append(\"L\")\n counter+=1\n direction[0]+=1\nwhile not direction[1] == 0:\n if direction[1] > 0:\n moves.append(\"U\")\n counter+=1\n direction[1]-=1\n else:\n moves.append(\"D\")\n counter+=1\n direction[1]+=1\n\n\nprint(counter)\nfor i in moves:\n print(i)\n"}, {"source_code": "\n\ntmp = raw_input()\ns = [ord(tmp[0]) - ord('a') + 1, int(tmp[1])]\n\ntmp = raw_input()\nt = [ord(tmp[0]) - ord('a') + 1, int(tmp[1])]\n\nres = []\nwhile s != t:\n dir = ''\n\n if s[0] < t[0]:\n dir += 'R'\n s[0] += 1\n elif s[0] > t[0]:\n dir += 'L'\n s[0] -= 1\n\n if s[1] > t[1]:\n dir += 'D'\n s[1] -= 1\n elif s[1] < t[1]:\n dir += 'U'\n s[1] += 1\n\n res.append(dir)\n\nprint len(res)\nfor r in res: print r\n"}, {"source_code": "s=input()\nn=input()\nif s==n:\n print(0)\n exit()\nm=['','a','b','c','d','e','f','g','h']\nfor i in range(1,len(m)):\n if s[0]==m[i]:\n x=i\n if n[0]==m[i]:\n x2=i \ny=int(s[1])\ny2=int(n[1])\nM=[]\nb=''\nxod=0 \nwhile True:\n if x>x2:\n x-=1\n b+='L'\n \n if x<x2:\n x+=1\n b+='R'\n if y>y2:\n y-=1\n b+='D'\n if y<y2:\n y+=1\n b+='U'\n xod+=1\n M.append(b)\n b=''\n if x==x2 and y==y2:\n break\nprint(xod)\nfor i in range(len(M)):\n print(M[i]) \n"}, {"source_code": "'''\nCreated on Jun 14, 2011\n\n@author: andrei\n'''\nimport sys\n\ndef main():\n def scrie(x, y):\n a[x][y] -= 1\n print a[x][y]\n for i in xrange(a[x][y]):\n aux = prev[x][y]\n print mv[aux]\n x -= dx[aux]\n y -= dy[aux]\n \n mv = (\"L\", \"R\", \"U\", \"D\", \"LU\", \"LD\", \"RU\", \"RD\")\n dx = (0, 0, -1, 1, -1, 1, -1, 1)\n dy = (-1, 1, 0, 0, -1, -1, 1, 1)\n \n a = []\n prev = []\n for i in xrange(10):\n a.append([])\n prev.append([])\n for j in xrange(10):\n a[i].append(0)\n prev[i].append(0)\n \n for i in xrange(10):\n a[i][0] = a[i][9] = a[0][i] = a[9][i] = 1\n \n fin = sys.stdin\n s = fin.readline()\n \n y, x = 8-(ord(s[0])-ord(\"a\")), int(s[1])\n a[x][y] = -1\n \n s = fin.readline()\n y, x = 8-(ord(s[0])-ord(\"a\")), int(s[1])\n \n if(a[x][y]==-1):\n print 0\n exit(0)\n \n a[x][y] = 1\n q = [(x, y)]\n \n while q:\n x, y = q.pop(0)\n \n \n for i in xrange(8):\n x1 = x + dx[i]\n y1 = y + dy[i]\n \n if a[x1][y1]==-1:\n a[x1][y1] = a[x][y] + 1\n prev[x1][y1] = i\n scrie(x1, y1)\n exit(0)\n \n if a[x1][y1]:\n continue\n \n a[x1][y1] = a[x][y] + 1\n prev[x1][y1] = i\n q.append((x1, y1)) \n \nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "line=['a','b','c','d','e','f','g','h']\na=str(input())\nb=str(input())\nx=line.index(list(a)[0])-line.index(list(b)[0])\ny=int(a[1])-int(b[1])\ni=0\nj=0\nk=0\nif abs(x)<abs(y):\n k=1\nprint(max(abs(x),abs(y)))\nwhile i<min(abs(x),abs(y)):\n if x>0 and y>0:\n print('LD')\n if x<0 and y>0:\n print('RD')\n if x>0 and y<0:\n print('LU')\n if x<0 and y<0:\n print('RU')\n i=i+1\nwhile j<abs(abs(x)-abs(y)):\n if k==1 and y<0:\n print('U')\n if k==1 and y>0:\n print('D')\n if k==0 and x<0:\n print('R')\n if k==0 and x>0:\n print('L')\n j=j+1 \n"}, {"source_code": "s = raw_input()\nf = raw_input()\n\ncnt = max(abs(ord(s[0]) - ord(f[0])), abs(int(s[1]) - int(f[1])))\nprint cnt\nif cnt == 0:\n exit()\n\ns1 = int(s[1])\nf1 = int(f[1])\nA = abs(ord(s[0]) - ord(f[0]))\nB = abs(s1 - f1)\n\nif ord(s[0]) < ord(f[0]):\n if s1 < f1:\n for i in range(min(A, B)):\n print \"RU\"\n if B > A:\n for i in range(max(A, B)-min(A, B)):\n print \"U\"\n else:\n for i in range(max(A, B)-min(A, B)):\n print \"R\"\n exit()\n elif s1 > f1:\n for i in range(min(A, B)):\n print \"RD\"\n if B > A:\n for i in range(max(A, B)-min(A, B)):\n print \"D\"\n else:\n for i in range(max(A, B)-min(A, B)):\n print \"R\"\n exit()\n else:\n for i in range(A):\n print \"R\"\n exit()\n\n\nif ord(s[0]) > ord(f[0]):\n if s1 < f1:\n for i in range(min(A, B)):\n print \"LU\"\n if A > B:\n for i in range(max(A, B)-min(A, B)):\n print \"L\"\n else:\n for i in range(max(A, B)-min(A, B)):\n print \"U\"\n exit()\n elif s1 > f1:\n for i in range(min(A, B)):\n print \"LD\"\n if A > B:\n for i in range(max(A, B)-min(A, B)):\n print \"L\"\n else:\n for i in range(max(A, B)-min(A, B)):\n print \"D\"\n exit()\n else:\n for i in range(A):\n print \"L\"\n exit()\n\nif ord(s[0]) == ord(f[0]):\n if s1 < f1:\n for i in range(B):\n print \"U\"\n exit()\n if s1 > f1:\n for i in range(B):\n print \"D\"\n exit()"}, {"source_code": "c1 = input()\nc2 = input()\nd = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8}\nx0, y0 = (d[c1[0]], int(c1[1]))\nx, y = (d[c2[0]], int(c2[1]))\nprint(max(abs(x - x0), abs(y - y0)))\nwhile (x != x0 or y != y0):\n if (x0 < x):\n print(\"R\", end = '')\n x0 += 1\n elif (x0 > x):\n print(\"L\", end = \"\")\n x0 -= 1\n if (y0 < y):\n print(\"U\", end = '')\n y0 += 1\n elif (y0 > y):\n print(\"D\", end = \"\")\n y0 -= 1\n print()\n"}, {"source_code": "a,b=raw_input(),raw_input()\na,b=ord(b[0])-ord(a[0]),ord(b[1])-ord(a[1])\nprint max(abs(a),abs(b))\nif a and b:\n\tt='R'if a>0 else'L'\n\tt+='U'if b>0 else'D'\n\ta,b=abs(a),abs(b)\n\tfor i in range(min(a,b)):\n\t\tprint t\nelse:\n\tif a:\n\t\tif a>0:\n\t\t\tfor i in range(a):\n\t\t\t\tprint'R'\n\t\telse:\n\t\t\tfor i in range(-a):\n\t\t\t\tprint'L'\n\tif b>0:\n\t\tfor i in range(b):\n\t\t\tprint'U'\n\telse:\n\t\tfor i in range(-b):\n\t\t\tprint'D'\n\texit()\nif a<b:\n\ta=b-a\n\tt=t[1]\nelse:\n\ta=a-b\n\tt=t[0]\nfor i in range(a):\n\tprint t"}, {"source_code": "#!/usr/bin/python\ns1= raw_input()\ns2 =raw_input()\n\n#if ord(s2[0])-ord(s1[0])<0 :\n# print 'ss',ord(s2[0])-ord(s1[0])\nif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1])<0 :\n ss = 'LD'\nelif ord(s2[0])-ord(s1[0])>0 and ord(s2[1])-ord(s1[1]) <0 :\n ss='RD'\nelif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1]) >0 :\n ss='LU'\nelse:\n ss='RU'\n\n#if ord(s2[0])-ord(s1[0])<0:\n# ss1 = 'U'\n#else :\n# ss1 = 'D'\n\n#if ord(s2[1])-ord(s1[1])<0:\n# ss2 = 'R'\n#else :\n# ss2 = 'L'\nif ord(s2[0])-ord(s1[0])<0:\n ss1 = 'L'\nelse :\n ss1 = 'R'\n\nif ord(s2[1])-ord(s1[1])<0:\n ss2 = 'D'\nelse :\n ss2 = 'U'\n\nbig = abs(ord(s2[0])-ord(s1[0]))\nsmall = abs(ord(s2[1])-ord(s1[1]))\n\nif big < small :\n temp =big;\n big=small;\n small=temp;\n ss1=ss2;\n \nprint big\n\n\nfor i in range (0,small):\n print ss\n\nfor i in range (0,big-small):\n print ss1\n"}, {"source_code": "s=input()\nt=input()\n\nkx=ord(s[0])-ord('a')+1\nky=int(s[1])\n\ndx=ord(t[0])-ord('a')+1\ndy=int(t[1])\n\npath=[]\nwhile kx!=dx or ky!=dy:\n move=''\n if kx>dx:\n move='L'\n kx-=1\n elif kx<dx:\n move='R'\n kx+=1\n if ky>dy:\n move=move+'D'\n ky-=1\n elif ky<dy:\n move=move+'U'\n ky+=1\n path.append(move)\n \nprint(len(path))\nfor x in path:\n print(x)"}, {"source_code": "Read=lambda:map(int,raw_input().split())\ns = raw_input()\ns1 = int(ord(s[0]))\ns2 = int(s[1])\nt = raw_input()\nt1 = int(ord(t[0]))\nt2 = int(t[1])\nr = []\nwhile s1 != t1 or s2 != t2:\n x = ''\n if s1 > t1:\n x = 'L'\n s1 -= 1\n elif s1 < t1: \n x = 'R'\n s1 += 1\n if s2 > t2:\n x += 'D'\n s2 -= 1\n elif s2 < t2: \n x += 'U'\n s2 += 1\n r.append(x)\n\nprint len(r)\nfor x in r:\n print x\n"}, {"source_code": "def fun(x1,y1,x2,y2):\n if abs(x2-x1)==abs(y2-y1):\n print(abs(x2-x1))\n elif abs(x2-x1)==0 and abs(y2-y1)>0:\n print(abs(y2-y1))\n elif abs(x2-x1)>0 and abs(y2-y1)==0:\n print(abs(x2-x1))\n elif abs(x2-x1)>0 and abs(y2-y1)>0 and abs(x2-x1)!=abs(y2-y1):\n print(max(abs(y2-y1),abs(x2-x1)))\n\n while x1-x2!=0 or y1-y2!=0:\n if x1-x2<0 and y1-y2==0:\n x1=x1+1\n print(\"D\")\n if x1-x2>0 and y1-y2==0:\n x1=x1-1\n print(\"U\")\n if x1-x2==0 and y1-y2<0:\n y1=y1+1\n print(\"R\")\n if x1-x2==0 and y1-y2>0:\n y1=y1-1\n print(\"L\")\n if x1-x2>0 and y1-y2>0:\n x1=x1-1\n y1=y1-1\n print(\"LU\")\n if x1-x2>0 and y1-y2<0:\n x1=x1-1\n y1=y1+1\n print(\"RU\")\n if x1-x2<0 and y1-y2<0:\n x1=x1+1\n y1=y1+1\n print(\"RD\")\n if x1-x2<0 and y1-y2>0:\n x1=x1+1\n y1=y1-1\n print(\"LD\")\n return \n \n\na=input()\nb=input()\nDict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8} \ny1=Dict.get(a[0])\nx1=9-int(a[1])\ny2=Dict.get(b[0])\nx2=9-int(b[1])\nfun(x1,y1,x2,y2)\n\n"}, {"source_code": "start = raw_input()\nend = raw_input()\nst_point = (ord(start[0]) - ord('a'), ord(start[1]) - ord('1'))\nen_point = (ord(end[0]) - ord('a'), ord(end[1]) - ord('1'))\n\nstepNum = max(abs(en_point[0] - st_point[0]), abs(en_point[1] - st_point[1]))\n\nprint stepNum\n\n\n# the problem can be divided into 4 conditions (dialog)\nx1, y1 = st_point[0], st_point[1]\nx2, y2 = en_point[0], en_point[1]\npath = []\nif x1 < x2:\n if y1 < y2:\n while y1 < y2 and x1 < x2:\n x1 += 1\n y1 += 1\n path.append('RU')\n if y1 == y2:\n while x1 < x2:\n x1 += 1\n path.append('R')\n if x1 == x2:\n while y1 < y2:\n y1 += 1\n path.append('U')\n elif y1 > y2:\n while y1 > y2 and x1 < x2:\n x1 += 1\n y1 -= 1\n path.append('RD')\n if y1 == y2:\n while x1 < x2:\n x1 += 1\n path.append('R')\n if x1 == x2:\n while y1 > y2:\n y1 -= 1\n path.append('D')\n else:\n while x1 < x2:\n x1 += 1\n path.append('R')\n\nif x1 > x2:\n if y1 < y2:\n while x1 > x2 and y1 < y2:\n x1 -= 1\n y1 += 1\n path.append('LU')\n if y1 == y2:\n while x1 > x2:\n x1 -= 1\n path.append('L')\n if x1 == x2:\n while y1 < y2:\n y1 += 1\n path.append('U')\n elif y1 > y2:\n while x1 > x2 and y1 > y2:\n x1 -= 1\n y1 -= 1\n path.append('LD')\n if y1 == y2:\n while x1 > x2:\n x1 -= 1\n path.append('L')\n if x1 == x2:\n while y1 > y2:\n y1 -= 1\n path.append('D')\n else:\n while x1 > x2:\n x1 -= 1\n path.append('L')\n \nelse:\n if y1 > y2:\n while y1 > y2:\n y1 -= 1\n path.append('D')\n elif y1 < y2:\n while y1 < y2:\n y1 += 1\n path.append('U')\n\nfor i in path:\n print i\n\n \n \n \n \n \n \n \n \n \n \n \n\n\n"}, {"source_code": "import time\n\ndef calculateCoords(c):\n return (8 - int(c[1]), ord(c[0]) - 97) \n\ndef run():\n start = calculateCoords(input())\n end = calculateCoords(input())\n \n seen = [[False for x in range(8)] for y in range(8)]\n seen[start[0]][start[1]] = True\n toCheck = []\n toCheck.append((start, [])) \n\n while True:\n temp = []\n for (position, l) in toCheck:\n r = position[0]\n c = position[1]\n seen[r][c] = True\n if r == end[0] and c == end[1]:\n print(len(l))\n for ch in l:\n print(ch)\n return\n if r > 0:\n if c > 0 and not seen[r - 1][c - 1]:\n newl1 = [x for x in l]\n newl1.append(\"LU\")\n temp.append(((r - 1, c - 1), newl1))\n if c < 7 and not seen[r - 1][c + 1]:\n newl2 = [x for x in l]\n newl2.append(\"RU\")\n temp.append(((r - 1, c + 1), newl2))\n newl3 = [x for x in l]\n newl3.append(\"U\")\n temp.append(((r - 1, c), newl3))\n if r < 7:\n if c > 0 and not seen[r + 1][c - 1]:\n newl4 = [x for x in l]\n newl4.append(\"LD\")\n temp.append(((r + 1, c - 1), newl4))\n if c < 7 and not seen[r + 1][c + 1]:\n newl5 = [x for x in l]\n newl5.append(\"RD\")\n temp.append(((r + 1, c + 1), newl5))\n newl6 = [x for x in l]\n newl6.append(\"D\")\n temp.append(((r + 1, c), newl6))\n if c > 0:\n newl7 = [x for x in l]\n newl7.append(\"L\")\n temp.append(((r, c - 1), newl7))\n if c < 7:\n newl8 = [x for x in l]\n newl8.append(\"R\")\n temp.append(((r, c + 1), newl8))\n toCheck = []\n toCheck.extend(temp)\n\nrun()"}, {"source_code": "\nposition = list(input())\nend = list(input())\n\nposition[1] = int(position[1])\nend[1] = int(end[1])\n\nmoves = []\n\nwhile position != end:\n current_move = ''\n\n if position[0] < end[0]:\n position[0] = chr(ord(position[0]) + 1)\n current_move += 'R'\n\n elif position[0] > end[0]:\n position[0] = chr(ord(position[0]) - 1)\n current_move += 'L'\n\n\n if position[1] < end[1]:\n position[1] += 1\n current_move = current_move + 'U'\n\n elif position[1] > end[1]:\n position[1] -= 1\n current_move = current_move + 'D'\n\n moves.append(current_move)\n\nprint(len(moves))\nfor move in moves:\n print(move)"}, {"source_code": "import sys\nsc, sr = map(ord, list(raw_input()))\ntc, tr = map(ord, list(raw_input()))\nfc = sc-tc\nfr = sr-tr\nmx = max(abs(fc), abs(fr)) \nmn = min(abs(fc), abs(fr))\nprint mx\nr = ['U', 'D']\nc = ['L', 'R']\nfor _ in xrange(mx):\n s = ''\n if fc != 0:\n s += 'R' if fc < 0 else 'L'\n fc = fc - 1 if fc > 0 else fc + 1\n if fr != 0:\n s += 'U' if fr < 0 else 'D'\n fr = fr - 1 if fr > 0 else fr + 1\n print s\n"}, {"source_code": "s = raw_input()\nt = raw_input()\n\na = ord(s[0])-ord('a')\nb = ord(s[1])-ord('1')\nc = ord(t[0])-ord('a')\nd = ord(t[1])-ord('1')\n\nprint max(abs(a-c),abs(b-d))\n\nwhile a!=c or b!=d:\n print '%s%s' % (['R','','L'][cmp(a,c)+1],['U','','D'][cmp(b,d)+1])\n a -= cmp(a,c)\n b -= cmp(b,d)\n"}, {"source_code": "#!/usr/bin/python\n\ndef move(dx, dy):\n res = \"\"\n if (dx == -1): res += \"L\"\n if (dx == 1): res += \"R\"\n if (dy == -1): res += \"D\"\n if (dy == 1): res += \"U\"\n return res\n\nfield = [ [ -1 for x in xrange(8)] for y in xrange(8) ]\nturn = [ [ [] for x in xrange(8)] for y in xrange(8) ]\n\n\nnum = { 'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7}\n\n\nst = raw_input()\nx0,y0 = num[st[0]], int(st[1]) - 1\n\n\nfin = raw_input()\nx1, y1 = num[fin[0]], int(fin[1]) - 1\n\n#print x0, y0, x1, y1\n\nque = [ (x0, y0) ]\nfield[x0][y0] = 0;\n\nnturn = 0\nwhile (len(que) > 0):\n new_que = []\n for x,y in que:\n #print 'now in ', (x,y), 'turn:', turn[x][y]\n if x == x1 and y == y1:\n print nturn\n for t in turn[x][y]:\n print t\n exit()\n for dx in (-1,0,1):\n for dy in (-1,0,1):\n xx = x + dx\n yy = y + dy\n if 0 <= xx <= 7 and 0 <= yy <= 7 and field[xx][yy] == -1:\n field[xx][yy] = nturn\n turn[xx][yy] = list(turn[x][y])\n new_que.append( (xx,yy) )\n turn[xx][yy].append( move(dx,dy) )\n que = new_que\n nturn += 1\n\n"}, {"source_code": "from __future__ import print_function\nfrom itertools import *\nimport sys\natoi = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8}\ns, t = map (lambda x : atoi[x], raw_input ()), map (lambda x : atoi[x], raw_input ())\nprint (max (abs (s[0] - t[0]), abs (s[1] - t[1])))\nprint (max (0, min (t[0] - s[0], s[1] - t[1])) * 'RD\\n', end='')\nprint (max (0, min (t[0] - s[0], t[1] - s[1])) * 'RU\\n', end='')\nprint (max (0, min (s[0] - t[0], s[1] - t[1])) * 'LD\\n', end='')\nprint (max (0, min (s[0] - t[0], t[1] - s[1])) * 'LU\\n', end='')\nprint (max (0, s[0] - t[0] - abs (t[1] - s[1])) * 'L\\n', end='')\nprint (max (0, t[1] - s[1] - abs (t[0] - s[0])) * 'U\\n', end='')\nprint (max (0, t[0] - s[0] - abs (t[1] - s[1])) * 'R\\n', end='')\nprint (max (0, s[1] - t[1] - abs (t[0] - s[0])) * 'D\\n', end='')\n\n"}, {"source_code": "s = raw_input()\nt = raw_input()\nres = 0\nmoves = []\nwhile s!=t:\n move = \"\"\n if s[0] < t[0]:\n move+='R'\n s = chr(ord(s[0]) + 1) + s[1]\n elif s[0] > t[0]:\n move+='L'\n s = chr(ord(s[0]) - 1) + s[1]\n if s[1] < t[1]:\n move+='U'\n s = s[0] + chr(ord(s[1]) + 1)\n elif s[1] > t[1]:\n move+='D'\n s = s[0] + chr(ord(s[1]) - 1)\n res+=1\n moves.append(move)\nprint(res)\nfor move in moves:\n print(move)\n\n"}, {"source_code": "st = raw_input()\nfn = raw_input()\ndist = [ord(st[1]) - ord(fn[1]), ord(st[0]) - ord(fn[0])]\nprint max(abs(dist[0]), abs(dist[1]))\n\nwhile dist.count(0)!=2:\n l = \"\"\n if dist[1]<0:\n l+=\"R\"\n dist[1] += 1\n elif dist[1]>0:\n l+=\"L\"\n dist[1] -= 1\n if dist[0]<0:\n l+=\"U\"\n dist[0] += 1\n elif dist[0]>0:\n l+=\"D\"\n dist[0] -= 1\n print l\n\n"}, {"source_code": "start=list(raw_input())\nstop=list(raw_input())\nh=ord(start[0])-ord(stop[0])\nv=int(start[1])-int(stop[1])\nV=\"D\" if v>=0 else \"U\"\nH=\"L\" if h>=0 else \"R\"\nv=abs(v)\nh=abs(h)\nM=H if h>v else V\nprint max(v,h)\nfor i in range(min(h,v)):\n\tprint H+V\nfor i in range(abs(h-v)):\n\tprint M"}, {"source_code": "x,y=map(lambda x:ord(x[1])-ord(x[0]), zip(raw_input(),raw_input()))\na,b,lr,du=abs(x),abs(y),'LR'[x>=0],'DU'[y>=0]\nm,d=max(a,b),min(a,b)\nprint m, '\\n', (lr+du+'\\n')*d+(lr+'\\n')*(a-d)+(du+'\\n')*(b-d)"}, {"source_code": "import string\nimport sys\n\ns, t = sys.stdin.readline(), sys.stdin.readline()\ns = (string.letters.index(s[0])+1, int(s[1]))\nt = (string.letters.index(t[0])+1, int(t[1]))\n\npath_x, path_y = (s[0]-t[0]), (s[1]-t[1])\nif path_x < 0:\n path_x *= (-1)\n letter_x = 'R' * path_x\nelif path_x > 0:\n letter_x = 'L' * path_x\nelse:\n letter_x = ''\n\nif path_y < 0:\n path_y *= (-1)\n letter_y = 'U' * path_y\nelif path_y > 0:\n letter_y = 'D' * path_y\nelse:\n letter_y = ''\n\nmerge, total = min(len(letter_x), len(letter_y)), max(len(letter_x), len(letter_y))\nprint total\nfor _ in range(merge):\n print letter_x[_] + letter_y[_]\n\ntry:\n for p in letter_x[merge:]:\n print p\nexcept IndexError:\n pass\n\ntry:\n for p in letter_y[merge:]:\n print p\nexcept IndexError:\n pass\n\n"}, {"source_code": "sp = raw_input()\nlp = raw_input()\nalp = 'abcdefgh'\nposalp = {}\nfor i in range(8):\n posalp[alp[i]]=i+1\nxi = posalp[sp[0]]\nyi = int(sp[1])\nxf = posalp[lp[0]]\nyf = int(lp[1])\ndisx = xf-xi\ndisy = yf-yi\nl = 0\nr = 0\nu = 0\nd = 0\n\nif disx>0:\n r = disx\nelif disx<0:\n l = abs(disx)\nif disy>0:\n u = disy\nelif disy<0:\n d = abs(disy)\nhor = max(l,r)\nver = max(u,d)\nif l==hor:\n keyhor = 'L'\nelse:\n keyhor = 'R'\nif ver==u:\n keyver = 'U'\nelse:\n keyver = 'D'\ncomm = min(hor,ver)\nhor = hor-comm\nver = ver-comm\nkey = []\nfor s in range(comm):\n key.append(keyhor+keyver)\nfor d in range(hor):\n key.append(keyhor)\nfor f in range(ver):\n key.append(keyver)\nprint len(key)\nfor q in range(len(key)):\n print key[q]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n\n\n\n\n"}, {"source_code": "a = raw_input()\nb = raw_input()\nn = ord('a') - 1\na = [ord(a[0]) - n, int(a[1])]\nb = [ord(b[0]) - n, int(b[1])]\nmoves = ''\ntotal = 0\nwhile not a == b:\n if a[0] < b[0]:\n if a[1] < b[1]:\n total += 1\n moves += 'RU\\n'\n a[0] += 1\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'RD\\n'\n a[0] += 1\n a[1] -= 1\n else:\n total += 1\n moves += 'R\\n'\n a[0] += 1\n elif a[0] > b[0]:\n if a[1] < b[1]:\n total += 1\n moves += 'LU\\n'\n a[0] -= 1\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'LD\\n'\n a[0] -= 1\n a[1] -= 1\n else:\n total += 1\n moves += 'L\\n'\n a[0] -= 1\n else:\n if a[1] < b[1]:\n total += 1\n moves += 'U\\n'\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'D\\n'\n a[1] -= 1\nprint total\nprint moves"}, {"source_code": "s, t = [map(ord, list(raw_input())) for i in [1,2]], ['']\nwhile s[0] != s[1]:\n\tt.append('')\n\tif s[0][0] < s[1][0]: t[-1] = t[-1] + 'R'; s[0][0] += 1\n\tif s[0][0] > s[1][0]: t[-1] = t[-1] + 'L'; s[0][0] -= 1\n\tif s[0][1] < s[1][1]: t[-1] = t[-1] + 'U'; s[0][1] += 1\n\tif s[0][1] > s[1][1]: t[-1] = t[-1] + 'D'; s[0][1] -= 1\nprint len(t) - 1, '\\n'.join(t)\n"}, {"source_code": "f = input()\nt = input()\nf = [ord(f[0]) - ord('a'), int(f[1]) - 1]\nt = [ord(t[0]) - ord('a'), int(t[1]) - 1]\na = []\nwhile (f[0] < t[0]) and (f[1] < t[1]):\n a.append(\"RU\")\n f[0] += 1\n f[1] += 1\nwhile (f[0] > t[0]) and (f[1] < t[1]):\n a.append(\"LU\")\n f[0] -= 1\n f[1] += 1\nwhile (f[0] < t[0]) and (f[1] > t[1]):\n a.append(\"RD\")\n f[0] += 1\n f[1] -= 1\nwhile (f[0] > t[0]) and (f[1] > t[1]):\n a.append(\"LD\")\n f[0] -= 1\n f[1] -= 1\nwhile f[0] < t[0]:\n a.append(\"R\")\n f[0] += 1\nwhile f[0] > t[0]:\n a.append(\"L\")\n f[0] -= 1\nwhile f[1] < t[1]:\n a.append(\"U\")\n f[1] += 1\nwhile f[1] > t[1]:\n a.append(\"D\")\n f[1] -= 1\nprint(len(a))\nprint(\"\\n\".join(a))"}, {"source_code": "s = input()\nf = input()\nx = ord(s[0])-ord(f[0])\ny = ord(s[1])-ord(f[1])\nprint(max(x,y,-x,-y))\nwhile x != 0 or y != 0:\n st = \"\"\n if x < 0:\n st += \"R\"\n x = x + 1\n if x > 0:\n st = st + \"L\"\n x = x - 1\n if y < 0:\n st = st + \"U\"\n y = y + 1\n if y > 0:\n st = st + \"D\"\n y = y - 1\n print(st)"}, {"source_code": "def sign(n):\n if n > 0:\n return 1\n if n < 0:\n return -1\n return 0\ndef ter(n,sn,sz,sp):\n return sn if n < 0 else (sz if n == 0 else sp)\ns = input()\nt = input()\nn = 0\na = []\ns = [ord(s[0])-ord('a')+1,int(s[1])]\nt = [ord(t[0])-ord('a')+1,int(t[1])]\nwhile s != t:\n d0 = sign(t[0]-s[0])\n d1 = sign(t[1]-s[1])\n s[0] += d0\n s[1] += d1\n a.append(ter(d0,'L','','R')+ter(d1,'D','','U'))\nprint(len(a))\nfor s in a:\n print(s)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon May 11 15:03:20 2020\n\n@author: alexi\n\"\"\"\n\n\nclass Node():\n \n def __init__(self, parent = None, position = None):\n self.parent = parent\n self.position = position\n self.g = 0\n self.h = 0\n self.f = 0\n \n def __eq__(self, other):\n return self.position == other.position\n \ndef heuristic(A, B):\n return abs(A[0]-B[0]) + abs(A[1]-B[1])\n\ndef Astar(maze, start, end):\n \n start_node = Node(None, start)\n start_node.g = 0\n start_node.h = heuristic(start, end)\n start_node.f = start_node.g + start_node.h\n \n end_node = Node(None, end)\n end_node.g = heuristic(start, end)\n end_node.h = 0\n end_node.f = end_node.g + end_node.h\n\n open_list = []\n closed_list = []\n \n open_list.append(start_node)\n \n while True:\n \n if len(open_list) == 0:\n return -1\n \n current_node = open_list[0]\n current_index = 0\n \n for index, item in enumerate(open_list):\n if item.f < current_node.f:\n current_node = item\n current_index = index\n \n open_list.pop(current_index)\n closed_list.append(current_node)\n \n if current_node == end_node:\n path = []\n current = current_node\n while current is not None:\n path.append(current.position)\n current = current.parent\n \n return path[::-1]\n else:\n \n children = []\n \n for new_position in [(0, -1),(0, 1),(1, 0),(-1, 0),(-1, -1),(-1, 1),(1, -1),(1, 1)]:\n \n node_position = (current_node.position[0] + new_position[0], current_node.position[1] + new_position[1])\n \n if node_position[0] > (len(maze)-1) or node_position[0] < 0 or node_position[1] > (len(maze[len(maze)-1])-1) or node_position[1] < 0:\n continue\n \n if maze[node_position[0]][node_position[1]] != 0:\n continue\n \n new_node = Node(current_node, node_position)\n new_node.g = current_node.g + 1\n new_node.h = heuristic(new_node.position, end)\n new_node.f = new_node.g + new_node.h\n \n children.append(new_node)\n \n visited = False\n \n for child in children:\n for open_child in open_list:\n if child.position == open_child.position:\n if child.f < open_child.f:\n open_child = child\n visited = True\n \n for closed_child in closed_list:\n if child.position == closed_child.position:\n if child.f < closed_child.f:\n closed_child = child\n visited = True\n \n if visited:\n visited = False\n else:\n open_list.append(child)\n \n \n\n\ndef move_the_king():\n\n\n maze = [[0, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n ]\n \n \n dic_letters = {'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7}\n dic_numbers = {8:0,7:1,6:2,5:3,4:4,3:5,2:6,1:7}\n dic_move = {(1,0):'D',(-1,0):'U',(0,1):'R',(0,-1):'L',(-1, -1):'LU',(-1, 1):'RU',(1, -1):'LD',(1, 1):'RD'}\n \n start = input()\n end = input()\n \n actual_start = (dic_numbers[int(start[1])],dic_letters[start[0]])\n actual_end = (dic_numbers[int(end[1])],dic_letters[end[0]])\n \n path = Astar(maze, actual_start, actual_end)\n print(len(path)-1)\n \n for i in range(1, len(path)):\n temp = (path[i][0] - path[i-1][0], path[i][1] - path[i-1][1])\n print(dic_move[temp])\n \n \n \nmove_the_king() \n "}, {"source_code": "x,y=map(lambda x:ord(x[1])-ord(x[0]), zip(raw_input(),raw_input()))\na,b,lr,du=abs(x),abs(y),'LR'[x>=0],'DU'[y>=0]\nm,d=max(a,b),min(a,b)\nprint m,'\\n',(lr+du+'\\n')*d+(lr+'\\n')*(a-d)+(du+'\\n')*(b-d)\n"}, {"source_code": "s = input() #a8\nt = input() #h1\n\nsteps = 0\nmoves = []\nrow_dist = int(t[1]) - int(s[1])\ncol_dist = ord(t[0]) - ord(s[0])\n\nwhile(row_dist != 0 or col_dist != 0):\n\n if abs(row_dist) > abs(col_dist):\n if row_dist > 0:\n moves.append(\"U\")\n steps += 1\n row_dist -= 1\n elif row_dist < 0:\n moves.append(\"D\")\n steps += 1\n row_dist += 1\n else:\n break\n\n elif abs(row_dist) < abs(col_dist):\n if col_dist > 0:\n moves.append(\"R\")\n steps += 1\n col_dist -= 1\n elif col_dist < 0:\n moves.append(\"L\")\n steps += 1\n col_dist += 1\n else:\n break\n\n elif abs(row_dist) == abs(col_dist):\n for i in range(abs(col_dist)):\n if col_dist > 0 and row_dist > 0:\n moves.append(\"RU\")\n steps += 1\n col_dist -= 1\n row_dist -= 1\n elif col_dist > 0 and row_dist < 0:\n moves.append(\"RD\")\n steps += 1\n col_dist -= 1\n row_dist += 1\n elif col_dist < 0 and row_dist > 0:\n moves.append(\"LU\")\n steps += 1\n col_dist += 1\n row_dist -= 1\n elif col_dist < 0 and row_dist < 0:\n moves.append(\"LD\")\n steps += 1\n col_dist += 1\n row_dist += 1\n\nprint(steps)\nfor i in moves:\n print(i)"}, {"source_code": "s=[i for i in input()]\nt=[i for i in input()]\na=ord(s[0])-ord(t[0])\nb=ord(s[1])-ord(t[1])\nprint(max(a,-a,b,-b))\nwhile a!=0 or b!=0:\n kk=''\n if a<0:kk='R';a+=1\n if a>0:kk='L';a-=1\n if b<0:kk+='U';b+=1\n if b>0:kk+='D';b-=1\n print(kk)"}, {"source_code": "#Exercise 3A - Stupid King Path\n#We need to take 2 lines of input, which we store as a\n#single string to work with\na=input()+input()\n#Then we tell our program to process store the Unicode\n#code point behind the letters in the variable b which \n#is meant to mimic the chess table and how many\n#moves the king needs to make to get from one point to another.\n#The input has the following format:\n# letter_Number_letter_Number\na,b=(ord(a[i])-ord(a[i+2])for i in (0,1))\nprint(max(a,-a,b,-b))\n#Now, we analyse the directions in which the king\n#needs to move when geting from point a to point b\nwhile a!=0 or b!=0:\n r=''\n if a<0:\n r='R';a+=1\n if a>0:r='L';a-=1\n if b<0:r+='U';b+=1\n if b>0:r+='D';b-=1\n #And we print out the moves he makes\n print(r)\n\n"}, {"source_code": "alphabetic = \" abcdefgh\"\ns = input()\nt = input()\nsx = alphabetic.index(s[0])\nsy = int(s[1])\ntx = alphabetic.index(t[0])\nty = int(t[1])\nres = \"\"\ncnt = 0\nwhile sx != tx or sy != ty:\n cnt += 1\n if sx < tx:\n res += \"R\"\n sx += 1\n elif sx > tx:\n res += \"L\"\n sx -= 1\n if sy < ty:\n res += \"U\"\n sy += 1\n elif sy > ty:\n res += \"D\"\n sy -= 1\n res += \"\\n\"\n\nprint(cnt)\nprint(res)"}, {"source_code": "x=list(input())\ny=list(input())\nx0,y0=int((ord(x[0])-ord(\"a\")+1)),int(x[1])\nx1,y1=int((ord(y[0])-ord(\"a\")+1)),int(y[1])\nprint(max(abs(x1-x0),abs(y0-y1)))\nwhile x0!=x1 or y0!=y1:\n if x1>x0:\n print(\"R\",end=\"\")\n x0+=1\n if x0>x1:\n print(\"L\",end=\"\")\n x0-=1\n if y0>y1:\n print(\"D\",end=\"\")\n y0-=1\n if y1>y0:\n print(\"U\",end=\"\")\n y0+=1\n print() "}, {"source_code": "def coordinates():\n s = input()\n return \" abcdefgh\".index(s[0]), int(s[1])\n\n\nsx, sy = coordinates()\ntx, ty = coordinates()\nres = \"\"\ncnt = 0\nwhile sx != tx or sy != ty:\n cnt += 1\n if sx < tx:\n res += \"R\"\n sx += 1\n elif sx > tx:\n res += \"L\"\n sx -= 1\n if sy < ty:\n res += \"U\"\n sy += 1\n elif sy > ty:\n res += \"D\"\n sy -= 1\n res += \"\\n\"\n\nprint(cnt)\nprint(res)"}, {"source_code": "x1, y1 = input()\nx2, y2 = input()\n\ny1, y2 = map(int, [y1, y2])\nx1, x2 = map(ord, [x1, x2])\n\n\nx = abs(x1 - x2)\ny = abs(y1 - y2)\npath = max([x, y])\nprint(path)\n\nfor i in range(path):\n\tx0 = x1 - x2\n\ty0 = y1 - y2\n\tif x0 != 0 and y0 != 0:\n\t\tif x0 < 0 and y0 < 0:\n\t\t\tprint(\"RU\")\n\t\t\tx1 += 1\n\t\t\ty1 += 1\n\t\telif x0 < 0 and y0 > 0:\n\t\t\tprint(\"RD\")\n\t\t\tx1 += 1\n\t\t\ty1 -= 1\n\t\telif x0 > 0 and y0 < 0:\n\t\t\tprint(\"LU\")\n\t\t\ty1 += 1\n\t\t\tx1 -= 1\n\t\telif x0 > 0 and y0 > 0:\n\t\t\tprint(\"LD\")\n\t\t\ty1 -= 1\n\t\t\tx1 -= 1\n\telif x0 == 0 or y0 == 0:\n\t\tif x0 > 0:\n\t\t\tprint(\"L\")\n\t\t\tx1 -= 1\n\t\telif x0 < 0:\n\t\t\tprint(\"R\")\n\t\t\tx1 += 1\n\t\telif y0 > 0:\n\t\t\tprint(\"D\")\n\t\t\ty1 -= 1\n\t\telif y0 < 0:\n\t\t\tprint(\"U\")\n\t\t\ty1 += 1\n\telse:\n\t\tprint(\"No need for more\")"}, {"source_code": "s1 = input()\ns2 = input()\n\nstart = (8 - (ord(s1[1]) -ord('0')), ord(s1[0]) - ord('a'))\nend = (8 - (ord(s2[1]) - ord('0')), ord(s2[0]) - ord('a'))\n\n\nx = end[0] - start[0]\ny = end[1] - start[1]\nstep = max(abs(x), abs(y))\nprint(step)\na = min(abs(x), abs(y))\nif x >= 0 and y >= 0:\n for i in range(0, a):\n print(\"RD\")\nelif x >= 0 and y <= 0:\n for i in range(0, a):\n print(\"LD\")\nelif x <= 0 and y >= 0:\n for i in range(0, a):\n print(\"RU\")\nelif x <= 0 and y <= 0:\n for i in range(0, a):\n print(\"LU\")\n\nif abs(x) != a:\n b = abs(x) - a\n if x >= 0:\n for i in range(0, b):\n print(\"D\")\n else:\n for i in range(0, b):\n print(\"U\")\nelse:\n b = abs(y) - a\n if y >= 0:\n for i in range(0, b):\n print(\"R\")\n else:\n for i in range(0, b):\n print(\"L\")\n\n\n\n\n\n# print(start, end)"}, {"source_code": "a=input()+input()\na,b=(ord(a[i])-ord(a[i+2])for i in(0,1))\nprint(max(a,-a,b,-b))\nwhile a!=0 or b!=0:\n r=''\n if a<0:r='R';a+=1\n if a>0:r='L';a-=1\n if b<0:r+='U';b+=1\n if b>0:r+='D';b-=1\n print(r)\n "}, {"source_code": "p1, p2 = input(), input()\nx1, y1 = ord(p1[0]) - ord('a') + 1, int(p1[1])\nx2, y2 = ord(p2[0]) - ord('a') + 1, int(p2[1])\nx = x2 - x1\ny = y2 - y1\nd1, d2 = 'L', 'D'\nif x > 0:\n d1 = 'R'\nelse:\n x = -x\nif y > 0:\n d2 = 'U'\nelse:\n y = -y\nif x > y:\n print(x)\nelse:\n print(y)\nwhile x or y:\n if x:\n x -= 1\n print(d1, end='')\n if y:\n y -= 1\n print(d2, end='')\n print()\n"}, {"source_code": "p1, p2 = input(), input()\nx1, y1 = ord(p1[0]) - ord('a') + 1, int(p1[1])\nx2, y2 = ord(p2[0]) - ord('a') + 1, int(p2[1])\nx = x2-x1\ny = y2-y1\nd1, d2 = 'L', 'D'\nif x > 0:\n d1 = 'R'\nif y > 0:\n d2 = 'U'\nif abs(x) > abs(y):\n print(abs(x))\nelse:\n print(abs(y))\n# import pdb\n# pdb.set_trace()\nif x < 0:\n x = -x\nif y < 0:\n y = -y\nwhile x or y:\n if x:\n x -= 1\n print(d1, end='')\n if y:\n y -= 1\n print(d2, end='')\n print()\n"}, {"source_code": "def p(a):\n c = 'zabcdefgh'.index(a[0])\n r = int(a[1])\n return c, r\n\ndef move2(s, d, p):\n cdist = d[0] - s[0]\n rdist = d[1] - s[1]\n path = []\n\n # do diagonal\n d = min(abs(cdist), abs(rdist))\n cd = 'R' if cdist > 0 else 'L'\n rd = 'U' if rdist > 0 else 'D'\n dire = cd + rd\n if d:\n path += [dire] * d\n if cdist > 0:\n cdist -= d\n else:\n cdist += d\n if rdist > 0:\n rdist -= d\n else:\n rdist += d\n\n if cdist != 0:\n cd = 'R' if cdist > 0 else 'L'\n path += [cd] * abs(cdist)\n elif rdist != 0:\n rd = 'U' if rdist > 0 else 'D'\n path += [rd] * abs(rdist)\n return path\n\ndef move(s, d, p):\n if s == d: # reached\n return p\n if s[0] == d[0]: # same c\n dist = d[1] - s[1]\n di = 'U' if dist > 0 else 'D'\n return p + ([di] * abs(dist))\n if s[1] == d[1]: # same r\n dist = d[0] - s[0]\n di = 'R' if dist > 0 else 'L'\n return p + ([di] * abs(dist))\n else:\n if s[0] < d[0] and s[1] < d[1]:\n return move((s[0]+1, s[1]+1 ), d, p + ['RU'])\n if s[0] < d[0] and s[1] > d[1]:\n return move((s[0]+1, s[1]-1 ), d, p + ['RD'])\n if s[0] > d[0] and s[1] < d[1]:\n return move((s[0]-1, s[1]+1 ), d, p + ['LU'])\n if s[0] > d[0] and s[1] > d[1]:\n return move((s[0]-1, s[1]-1 ), d, p + ['LD'])\n\nsoln = move2(p(raw_input()), p(raw_input()), [])\nprint len(soln)\nfor l in soln:\n print l\n"}, {"source_code": "def move2(s, d):\n cdist = ord(d[0]) - ord(s[0])\n rdist = int(d[1]) - int(s[1])\n path = []\n\n # do diagonal\n d = min(abs(cdist), abs(rdist))\n if cdist > 0:\n cd = 'R'\n cdist -= d\n else:\n cd = 'L'\n cdist += d\n if rdist > 0:\n rd = 'U'\n rdist -= d\n else:\n rd = 'D'\n rdist += d\n\n dire = cd + rd\n for i in range(d):\n path.append(dire)\n\n if cdist != 0:\n for i in range(abs(cdist)):\n path.append(cd)\n elif rdist != 0:\n for i in range(abs(rdist)):\n path.append(rd)\n return path\n\nsoln = move2((raw_input()), (raw_input()))\nprint len(soln)\nfor l in soln:\n print l\n"}, {"source_code": "b=['o','a','b','c','d','e','f','g','h']\ns=input()\ns1=b.index(s[0])\ns2=int(s[1])\ne=input()\ne1=b.index(e[0])\ne2=int(e[1])\n\nm=max(abs(s1-e1),abs(s2-e2))\nprint(m)\nwhile s1!=e1 or s2!=e2:\n ss=''\n if s1!=e1:\n if s1<e1:\n ss+='R'\n else:\n ss+='L'\n s1-=(s1-e1)//abs(s1-e1)\n \n if s2!=e2:\n if s2>e2:\n ss+='D'\n else:\n ss+='U'\n s2-=(s2-e2)//abs(s2-e2)\n \n print(ss)\n"}], "negative_code": [{"source_code": "__author__ = 'liraim'\n\ndef read_input():\n start = input()\n target = input()\n return {'start': parse_position(start), 'target': parse_position(target)}\n\ndef parse_position(chess_position):\n column = ord(chess_position[0]) - ord('a')\n row = int(chess_position[1]) - 1\n return column, row\n\ndef solve(input_data):\n start = input_data['start']\n target = input_data['target']\n diagonal_move_count = min(abs(start[0] - target[0]), abs(start[1] - target[1]))\n move_count = diagonal_move_count + \\\n (abs(start[0] - target[0]) - diagonal_move_count) + \\\n (abs(start[1] - target[1]) - diagonal_move_count)\n diagonal_direction = ('R' if target[0] - start[0] > 0 else 'L') + ('D' if target[1] - start[1] < 0 else 'U')\n answer = [diagonal_direction] * diagonal_move_count\n answer += ['D' if target[1] - start[1] > 0 else 'U'] * (abs(start[1] - target[1]) - diagonal_move_count) + \\\n ['R' if target[0] - start[0] > 0 else 'L'] * (abs(start[0] - target[0]) - diagonal_move_count)\n return {'count': move_count, 'moves': answer}\n\ndef output_answer(answer):\n print(answer['count'])\n for move in answer['moves']:\n print(move)\n\noutput_answer(solve(read_input()))"}, {"source_code": "s1 = input()\ns2 = input()\n\nstart = (8 - (ord(s1[1]) -ord('0')), ord(s1[0]) - ord('a'))\nend = (8 - (ord(s2[1]) - ord('0')), ord(s2[0]) - ord('a'))\n\n\nx = end[0] - start[0]\ny = end[1] - start[1]\nstep = max(abs(x), abs(y))\nprint(step)\na = min(abs(x), abs(y))\nif x >= 0 and y >= 0:\n for i in range(0, a):\n print(\"RD\")\nelif x >= 0 and y <= 0:\n for i in range(0, a):\n print(\"LD\")\nelif x <= 0 and y <= 0:\n for i in range(0, a):\n print(\"RU\")\nelif x <= 0 and y <= 0:\n for i in range(0, a):\n print(\"LU\")\n\nif abs(x) != a:\n b = abs(x) - a\n if x >= 0:\n for i in range(0, b):\n print(\"R\")\n else:\n for i in range(0, b):\n print(\"L\")\nelse:\n b = abs(y) - a\n if y >= 0:\n for i in range(0, b):\n print(\"R\")\n else:\n for i in range(0, b):\n print(\"L\")\n\n\n\n\n\n# print(start, end)"}, {"source_code": "x0y0=input()\nxy=input()\nx0y0=[ord(x0y0[0])-ord('a')+1,int(x0y0[1])]\nxy=[ord(xy[0])-ord('a')+1,int(xy[1])]\nn=max(abs(x0y0[0]-xy[0]),abs(x0y0[1]-xy[1]))\nprint(abs(n))\nfor i in range(0,n):\n if xy[0]==x0y0[0] and xy[1]==x0y0[1]:\n print('OK')\n if xy[0]>x0y0[0] and xy[1]>x0y0[1]:\n print('RU')\n if xy[0]<x0y0[0] and xy[1]<x0y0[1]:\n print('LD')\n if xy[0]<x0y0[0] and xy[1]>x0y0[1]:\n print('LU')\n if xy[0]>x0y0[0] and xy[1]<x0y0[1]:\n print('RD')\n if xy[0]>x0y0[0] and xy[1]==x0y0[1]: print('R')\n if xy[0]<x0y0[0] and xy[1]==x0y0[1]: print('L')\n if xy[1]>x0y0[1] and xy[0]==x0y0[0]: print('U')\n if xy[1]<x0y0[1] and xy[0]==x0y0[0]: print('D')\n\n \n \n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport timeit\nimport time\nimport sys\nimport io\nimport re\nimport math\nstart = time.clock()\ncnt=0\nrot=[]\ns=list(raw_input())\ns=[int(ord(s[0]))-96,int(s[1])]\ng=list(raw_input())\ng=[int(ord(g[0]))-96,int(g[1])]\n#naname\nwhile g[0]<>s[0] and g[1]<>s[1]:\n if g[0]>s[0] and g[1]>s[1]:\n s[0]+=1\n s[1]+=1\n cnt+=1\n rot.append('RU')\n elif g[0]<s[0] and g[1]<s[0]:\n s[0]-=1\n s[1]-=1\n cnt+=1\n rot.append('LD')\n elif g[0]>s[0] and g[1]<s[1]:\n s[0]+=1\n s[1]-=1\n cnt+=1\n rot.append('RD')\n else:\n s[0]-=1\n s[1]+=1\n cnt+=1\n rot.append('LU')\nwhile g[0]<>s[0] or g[1]<>s[1]:\n if g[0]>s[0]:\n s[0]+=1\n cnt+=1\n rot.append('R')\n elif g[0]<s[0]:\n s[0]-=1\n cnt+=1\n rot.append('L')\n elif g[1]>s[1]:\n s[1]+=1\n cnt+=1\n rot.append('U')\n else:\n s[1]-=1\n cnt+=1\n rot.append('D')\nprint cnt\nfor i in rot:\n print i"}, {"source_code": "#!/usr/bin/python\nsrc = raw_input()\ndst = raw_input()\n\nmyD = { 'a': 1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8 }\n\nsrc_c = myD[src[0]]\nsrc_r = int(src[1])\ndst_c = myD[dst[0]]\ndst_r = int(dst[1])\n\n#print src_r, src_c, dst_r, dst_c \nmove_cnt = 0 \nmoves = \"\"\n\nwhile (src_r != dst_r and src_c != dst_c):\n move_cnt += 1\n\n if(src_r < dst_r and src_c < dst_c):\n src_r += 1; src_c += 1; moves += \"RU\\n\"\n\n elif(src_r > dst_r and src_c > dst_c):\n src_r -= 1; src_c -= 1; moves += \"LD\\n\"\n \n elif(src_r > dst_r and src_c < dst_c):\n src_r -= 1; src_c += 1; moves += \"RD\\n\"\n\n elif(src_r < dst_r and src_c > dst_c):\n src_r += 1; src_c -= 1; moves += \"LU\\n\"\n\n elif(src_r == dst_r and src_c > dst_c):\n src_c -= 1; moves += \"L\\n\"\n\n elif(src_r == dst_r and src_c < dst_c):\n src_c += 1; moves += \"R\\n\"\n \n elif(src_r > dst_r and src_c == dst_c):\n src_r -= 1; moves += \"D\\n\"\n\n elif(src_r < dst_r and src_c == dst_c):\n src_r += 1; moves += \"U\\n\"\n\nmoves = moves.strip('\\n')\nprint move_cnt\nprint moves\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport timeit\nimport time\nimport sys\nimport io\nimport re\nimport math\nstart = time.clock()\ncnt=0\nrot=[]\ns=list(raw_input())\ns=[int(ord(s[0]))-96,int(s[1])]\ng=list(raw_input())\ng=[int(ord(g[0]))-96,int(g[1])]\n#naname\nwhile g[0]<>s[0] and g[1]<>s[1]:\n if g[0]>s[0] and g[1]>s[1]:\n s[0]+=1\n s[1]+=1\n cnt+=1\n rot.append('RU')\n elif g[0]<s[0] and g[1]<s[0]:\n s[0]-=1\n s[1]-=1\n cnt+=1\n rot.append('LD')\n elif g[0]>s[0] and g[1]<s[1]:\n s[0]+=1\n s[1]-=1\n cnt+=1\n rot.append('RD')\n else:\n s[0]-=1\n s[1]+=1\n cnt+=1\n rot.append('LU')\nwhile g[0]<>s[0] or g[1]<>s[1]:\n if g[0]>s[0]:\n s[0]+=1\n cnt+=1\n rot.append('R')\n elif g[0]<s[0]:\n s[0]-=1\n cnt+=1\n rot.append('L')\n elif g[1]>s[1]:\n s[1]+=1\n cnt+=1\n rot.append('U')\n else:\n s[1]-=1\n cnt+=1\n rot.append('D')\nprint cnt\nfor i in rot:\n print i"}, {"source_code": "s1,s2 = raw_input(),raw_input()\nx1,x2 = '0abcdefgh'.index(s1[0]),'0abcdefgh'.index(s2[0])\ny1,y2 = int(s1[1]),int(s2[1])\n\nans = ['R']*max(0,x2-x1) + ['L']*max(0,x1-x2) + ['U']*max(0,y2-y1) + ['D']*max(0,y1-y2) \nif ( len(set(ans)) == 1):\n\tprint len(ans)\n\tfor i in ans : print i\nelif ( len(set(ans)) == 2):\n\tprint max( abs(x1-x2),abs(y1-y2))\n\twhile len(set(ans)) == 2:\n\t\tprint ans.pop(0)+ans.pop(-1)\n\t\n\twhile len(ans)>0:\n\t\tprint ans.pop()\n\n"}, {"source_code": "s=list(input())\nt=list(input())\nn=ord(t[0])-ord(s[0])\nm=int(t[1])-int(s[1])\na=min(abs(m),abs(n))\nb=max(abs(m),abs(n))-a\nsteps=[]\nif m>=0 and n>=0:\n steps.append(\"RU\")\n steps=steps*a\n if m>=n:\n steps_s=[]\n steps_s.append(\"U\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"R\")\n steps_s=steps_s*b\n steps=steps+steps_s\nelif m>=0 and n<=0:\n steps.append(\"LU\")\n steps=steps*a\n if m>n:\n steps_s=[]\n steps_s.append(\"U\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"L\")\n steps_s=steps_s*b\n steps=steps+steps_s\nelif m<=0 and n>=0:\n steps.append(\"RD\")\n steps=steps*a\n if m>n:\n steps_s=[]\n steps_s.append(\"D\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"R\")\n steps_s=steps_s*b\n steps=steps+steps_s\nelif m<=0 and n<=0:\n steps.append(\"LD\")\n steps=steps*a\n if m>n:\n steps_s=[]\n steps_s.append(\"D\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"L\")\n steps_s=steps_s*b\n steps=steps+steps_s\nprint(a+b)\nfor i in steps:\n print(i)\n"}, {"source_code": "a = raw_input()\nb = raw_input()\nn = ord('a') - 1\na = [ord(a[0]) - n, int(a[1])]\nb = [ord(b[0]) - n, int(b[1])]\nmoves = ''\ntotal = 0\nwhile not a == b:\n if a[0] < b[0]:\n if a[1] < b[1]:\n total += 1\n moves += 'RU\\n'\n a[0] += 1\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'RD\\n'\n a[0] += 1\n a[1] -= 1\n else:\n total += 1\n moves += 'R'\n a[0] += 1\n elif a[0] > b[0]:\n if a[1] < b[1]:\n total += 1\n moves += 'LU\\n'\n a[0] -= 1\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'LD\\n'\n a[0] -= 1\n a[1] -= 1\n else:\n total += 1\n moves += 'l'\n a[0] -= 1\n else:\n if a[1] < b[1]:\n total += 1\n moves += 'U\\n'\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'D\\n'\n a[1] -= 1\nprint total\nprint moves"}, {"source_code": "a = input()\nb = input()\n\ns = [ord(a[0])-ord('a')+1, int(a[1])]\nt = [ord(b[0])-ord('a')+1, int(b[1])]\n \nd = min(abs(s[0]-t[0]), abs(s[1]-t[1]))\n\ndans = ''\nif s[0] < t[0]:\n dans += 'R'\n s[0] += d\nelif s[0] > t[0]:\n dans += 'L'\n s[0] -= d\nif s[1] < t[1]:\n dans += 'U'\n s[1] += d\nelif s[1] > t[1]:\n dans += 'D'\n s[1] -= d\n\nfor _ in range(0, d):\n print(dans)\n \nif s[0] < t[0]:\n d = t[0]-s[0]\n for i in range(0, d):\n print('L')\nelif s[0] > t[0]:\n d = s[0]-t[0]\n for i in range(0, d):\n print('R')\nelif s[1] < t[1]:\n d = t[1]-s[1]\n for i in range(0, d):\n print('U')\nelif s[1] > t[1]:\n d = s[1]-t[1]\n for i in range(0, d):\n print('D')"}, {"source_code": "a = input()\nb = input()\n\ns = [ord(a[0])-ord('a')+1, int(a[1])]\nt = [ord(b[0])-ord('a')+1, int(b[1])]\n \nd = min(abs(s[0]-t[0]), abs(s[1]-t[1]))\n\ndans = ''\nif s[0] < t[0]:\n dans += 'R'\n s[0] += d\nelif s[0] > t[0]:\n dans += 'L'\n s[0] -= d\nif s[1] < t[1]:\n dans += 'U'\n s[1] += d\nelif s[1] > t[1]:\n dans += 'D'\n s[1] -= d\n\nfor _ in range(0, d):\n print(dans)\n \nif s[0] < t[0]:\n d = t[0]-s[0]\n for i in range(0, d):\n print('L')\nelif s[0] > t[0]:\n d = s[0]-t[0]\n for i in range(0, d):\n print('R')\nelif s[1] < t[1]:\n d = t[1]-s[1]\n for i in range(0, d):\n print('U')\nelif s[1] > t[1]:\n d = s[1]-t[1]\n for i in range(0, d):\n print('D')"}, {"source_code": "import string\nfirst_position = str(input())\nsecond_position = str(input())\nletter_list = list(string.ascii_lowercase[0:8])\nnumber_list = list(range(1, 9))\nd = dict(zip(letter_list, number_list))\nt1 = d[first_position[0]]\nt2 = d[second_position[0]]\nposition_list = [(t1, int(first_position[1])), (t2, int(second_position[1]))]\ntt_1 = position_list[0][1]\nh_1_1 = abs(position_list[0][0]-position_list[1][0])\nh_1_2 = abs(position_list[0][1]-position_list[1][1])\nh_1 = min(h_1_1, h_1_2)\nh_2 = max(h_1_1, h_1_2) - min(h_1_1, h_1_2)\nh = h_1 + h_2\nprint (h)\n\ndelta = 0\nfor i in range(h_1):\n if (t1 < t2) and (int(first_position[1]) < int(second_position[1])):\n print ('RU')\n delta += 1\n if (t1 < t2) and (int(first_position[1]) > int(second_position[1])):\n print ('RD')\n delta += 1\n if (t1 > t2) and (int(first_position[1]) < int(second_position[1])):\n print ('LU')\n delta -= 1\n if (t1 > t2) and (int(first_position[1]) > int(second_position[1])):\n print ('LD')\n delta -= 1\n\nif h_1_1 < h_1_2:\n t1 = t1 + delta\nif h_1_2 < h_1_1 and (int(first_position[1]) <= int(second_position[1])):\n tt_1 = tt_1 + delta\nif h_1_2 < h_1_1 and (int(first_position[1]) > int(second_position[1])):\n tt_1 = tt_1 - delta\n\nfor j in range(h_2):\n if t1 == t2 and int(first_position[1]) < int(second_position[1]):\n print ('U')\n if t1 == t2 and int(first_position[1]) > int(second_position[1]):\n print ('D')\n if tt_1 == int(second_position[1]) and d[first_position[0]] < d[second_position[0]]:\n print ('R')\n if tt_1 == int(second_position[1]) and d[first_position[0]] > d[second_position[0]]:\n print ('L')"}, {"source_code": "def p(a):\n c = 'zabcdefgh'.index(a[0])\n r = int(a[1])\n return c, r\n\ndef move2(s, d, p):\n cdist = d[0] - s[0]\n rdist = d[1] - s[1]\n path = []\n\n # do diagonal\n d = min(abs(cdist), abs(rdist))\n cd = 'R' if cdist > 0 else 'L'\n rd = 'U' if rdist > 0 else 'D'\n dire = cd + rd\n if d:\n path += [dire * d]\n if cdist > 0:\n cdist -= d\n else:\n cdist += d\n if rdist > 0:\n rdist -= d\n else:\n rdist += d\n\n if cdist != 0:\n cd = 'R' if cdist > 0 else 'L'\n path += [cd * abs(cdist)]\n else:\n rd = 'U' if rdist > 0 else 'D'\n path += [rd * abs(rdist)]\n return path\n\ndef move(s, d, p):\n if s == d: # reached\n return p\n if s[0] == d[0]: # same c\n dist = d[1] - s[1]\n di = 'U' if dist > 0 else 'D'\n return p + ([di] * abs(dist))\n if s[1] == d[1]: # same r\n dist = d[0] - s[0]\n di = 'R' if dist > 0 else 'L'\n return p + ([di] * abs(dist))\n else:\n if s[0] < d[0] and s[1] < d[1]:\n return move((s[0]+1, s[1]+1 ), d, p + ['RU'])\n if s[0] < d[0] and s[1] > d[1]:\n return move((s[0]+1, s[1]-1 ), d, p + ['RD'])\n if s[0] > d[0] and s[1] < d[1]:\n return move((s[0]-1, s[1]+1 ), d, p + ['LU'])\n if s[0] > d[0] and s[1] > d[1]:\n return move((s[0]-1, s[1]-1 ), d, p + ['LD'])\n\nsoln = move2(p(raw_input()), p(raw_input()), [])\nprint len(soln)\nfor l in soln:\n print l\n"}, {"source_code": "#!/usr/bin/python\nsrc = raw_input()\ndst = raw_input()\n\nmyD = { 'a': 1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8 }\n\nsrc_c = myD[src[0]]\nsrc_r = int(src[1])\ndst_c = myD[dst[0]]\ndst_r = int(dst[1])\n\n#print src_r, src_c, dst_r, dst_c \nmove_cnt = 0 \nmoves = \"\"\n\nwhile (src_r != dst_r and src_c != dst_c):\n move_cnt += 1\n\n if(src_r < dst_r and src_c < dst_c):\n src_r += 1; src_c += 1; moves += \"RU\\n\"\n\n elif(src_r > dst_r and src_c > dst_c):\n src_r -= 1; src_c -= 1; moves += \"LD\\n\"\n \n elif(src_r > dst_r and src_c < dst_c):\n src_r -= 1; src_c += 1; moves += \"RD\\n\"\n\n elif(src_r < dst_r and src_c > dst_c):\n src_r += 1; src_c -= 1; moves += \"LU\\n\"\n\n elif(src_r == dst_r and src_c > dst_c):\n src_c -= 1; moves += \"L\\n\"\n\n elif(src_r == dst_r and src_c < dst_c):\n src_c += 1; moves += \"R\\n\"\n \n elif(src_r > dst_r and src_c == dst_c):\n src_r -= 1; moves += \"D\\n\"\n\n elif(src_r < dst_r and src_c == dst_c):\n src_r += 1; moves += \"U\\n\"\n\nmoves = moves.strip('\\n')\nprint move_cnt\nprint moves\n"}, {"source_code": "#!/usr/bin/python\n\ndef c2ij(s):\n i, j = s\n i = ord(i) - ord('a') + 1\n j = int(j)\n return i, j\n\ndef dmov(di, dj):\n if di>0 and dj>0: c='RU'; dx, dy = 1, 1\n elif di>0 and dj<0: c='RD'; dx, dy = 1, -1\n elif di<0 and dj>0: c='LU'; dx, dy = -1, 1\n else : c='LD'; dx, dy = -1, -1\n\n n = min(abs(di), abs(dj))\n \n return c, n, dx, dy\n\ndef hmove(di, dj):\n if di>0: c='R'\n elif di<0: c='L'\n elif dj>0: c='U'\n else : c='D'\n\n n = max(abs(di), abs(dj))\n return c, n\n\nf = raw_input()\nt = raw_input()\n\ni0, j0 = c2ij(f)\ni1, j1 = c2ij(t)\n\n# diagonal move\ndi = i1 - i0\ndj = j1 - j0\n\ndc, dn, ddx, ddy = dmov(di, dj)\n\nfor i in range(dn):\n i0 += ddx\n j0 += ddy\n print dc\n\ndi = i1 - i0\ndj = j1 - j0\nhc, hn = hmove(di, dj)\n\nfor i in range(hn):\n print hc\n"}, {"source_code": "#!/usr/bin/python\ns1= raw_input()\ns2 =raw_input()\n\n#if ord(s2[0])-ord(s1[0])<0 :\n# print 'ss',ord(s2[0])-ord(s1[0])\nif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1])<0 :\n ss = 'LD'\nelif ord(s2[0])-ord(s1[0])>0 and ord(s2[1])-ord(s1[1]) <0 :\n ss='RD'\nelif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1]) >0 :\n ss='LU'\nelse:\n ss='RU'\n\nif ord(s2[0])-ord(s1[0])<0:\n ss1 = 'U'\nelse :\n ss1 = 'D'\n\nif ord(s2[1])-ord(s1[1])<0:\n ss2 = 'R'\nelse :\n ss2 = 'L'\n\n\nbig = abs(ord(s2[0])-ord(s1[0]))\nsmall = abs(ord(s2[1])-ord(s1[1]))\n\nif big < small :\n temp =big;\n big=small;\n small=temp;\n ss1=ss2;\n \nprint big\n\n\nfor i in range (0,small):\n print ss\n\nfor i in range (0,big-small):\n print ss1\n"}, {"source_code": "s=list(input())\nt=list(input())\nn=ord(t[0])-ord(s[0])\nm=int(s[1])-int(t[1])\na=min(abs(m),abs(n))\nb=max(abs(m),abs(n))-a\nsteps=[]\nif m>=0 and n>=0:\n steps.append(\"RD\")\n steps=steps*a\n if m>=n:\n steps_s=[]\n steps_s.append(\"D\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"R\")\n steps_s=steps_s*b\n steps=steps+steps_s\nelif m>=0 and n<=0:\n steps.append(\"RU\")\n steps=steps*a\n if m>n:\n steps_s=[]\n steps_s.append(\"U\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"R\")\n steps_s=steps_s*b\n steps=steps+steps_s\nelif m<=0 and n>=0:\n steps.append(\"LD\")\n steps=steps*a\n if m>n:\n steps_s=[]\n steps_s.append(\"D\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"L\")\n steps_s=steps_s*b\n steps=steps+steps_s\nelif m<=0 and n<=0:\n steps.append(\"LU\")\n steps=steps*a\n if m>n:\n steps_s=[]\n steps_s.append(\"U\")\n steps_s=steps_s*b\n else:\n steps_s=[]\n steps_s.append(\"L\")\n steps_s=steps_s*b\n steps=steps+steps_s\nprint(a+b)\nfor i in steps:\n print(i)"}, {"source_code": "l=lambda:map(ord, raw_input())\n(s,S),(t,T)=l(),l()\nr=t-s\nu=T-S\nR=abs(r)\nU=abs(u)\nfor i in range(max(R, U)):\n o = \"\"\n o += \"R\" if R>0 and r>0 else \"\"\n o += \"L\" if R>0 and r<0 else \"\"\n o += \"U\" if U>0 and u>0 else \"\"\n o += \"D\" if U>0 and u<0 else \"\"\n R-=1\n U-=1 \n print o"}, {"source_code": "a=list(input());b=list(input());x,y,_x,_y=ord(a[0])-97,int(a[1])-1,ord(b[0])-97,int(b[1])-1\nprint(max(abs(x-_x),abs(y-_y)))\nfor i in range(min(abs(x-_x),abs(y-_y))):\n if(x<_x):print('R',end='')\n else:print('L',end='')\n if(y>_y):print('D',end='')\n else:print('U',end='')\n print('')\nif(abs(x-_x)==abs(y-_y)):\n x=_x;y=_y\nelif(abs(x-_x)<abs(y-_y)):x=_x\nelse:y=_y\nfor i in range(abs(x-_x)+abs(y-_y)):\n if(y>_y):print('D',end='')\n elif(y<_y):print('U',end='')\n if(x<_x):print('R',end='')\n elif(x>_x):print('L',end='')\n print('')"}, {"source_code": "#!/usr/bin/python\ns1= raw_input()\ns2 =raw_input()\n\n#if ord(s2[0])-ord(s1[0])<0 :\n# print 'ss',ord(s2[0])-ord(s1[0])\nif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1])<0 :\n ss = 'LD'\nelif ord(s2[0])-ord(s1[0])>0 and ord(s2[1])-ord(s1[1]) <0 :\n ss='RD'\nelif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1]) >0 :\n ss='LU'\nelse:\n ss='RU'\n\nif ord(s2[0])-ord(s1[0])<0:\n ss1 = 'L'\nelse :\n ss1 = 'R'\n\nif ord(s2[1])-ord(s1[1])<0:\n ss2 = 'D'\nelse :\n ss2 = 'U'\n\n\nbig = abs(ord(s2[0])-ord(s1[0]))\nsmall = abs(ord(s2[1])-ord(s1[1]))\nif big < small :\n temp =big;\n big=small;\n small=big;\n ss1=ss2;\n \nprint big\n\n\nfor i in range (0,small):\n print ss\n\nfor i in range (0,big-small):\n print ss1\n"}, {"source_code": "S1 = str(input())\nS2 = str(input())\nif S1[0] == 'a':\n S1 += \"1\"\nif S1[0] == 'b':\n S1 += \"2\"\nif S1[0] == 'c':\n S1 += \"3\"\nif S1[0] == 'd':\n S1 += \"4\"\nif S1[0] == 'e':\n S1 += \"5\"\nif S1[0] == 'f':\n S1 += \"6\"\nif S1[0] == 'g':\n S1 += \"7\"\nif S1[0] == 'h':\n S1 += \"8\"\nif S2[0] == 'a':\n S2 += \"1\"\nif S2[0] == 'b':\n S2 += \"2\"\nif S2[0] == 'c':\n S2 += \"3\"\nif S2[0] == 'd':\n S2 += \"4\"\nif S2[0] == 'e':\n S2 += \"5\"\nif S2[0] == 'f':\n S2 += \"6\"\nif S2[0] == 'g':\n S2 += \"7\"\nif S2[0] == 'h':\n S2 += \"8\"\na = int(S1[1])\nb = int(S2[1])\nc = int(S1[2])\nd = int(S2[2])\nB = []\nwhile a != b and c != d:\n if a > b and c < d:\n a = a - 1\n c = c + 1\n B.append(\"RD\")\n elif a > b and c > d:\n a = a - 1\n c = c - 1\n B.append(\"LD\")\n elif a < b and c < d:\n a = a + 1\n c = c + 1\n B.append(\"RU\")\n elif a < b and c > d:\n a = a + 1\n c = c - 1\n B.append(\"LU\")\n elif a > b and c == b:\n a = a - 1\n B.append(\"D\")\n elif a < b and c == b:\n a = a + 1\n B.append(\"U\")\n elif a == b and c < b:\n c = c + 1\n B.append(\"R\")\n elif a == b and c > b:\n c = c - 1\n B.append(\"L\")\nprint(len(B))\nfor i in B:\n print(i)"}, {"source_code": "s = raw_input()\nt = raw_input()\nif s[0] == t[0]: # same column\n\tif int(s[1]) == int(t[1]):\n\t\tprint 0\n\telif int(s[1]) > int(t[1]):\n\t\tprint int(s[1]) - int(t[1])\n\t\tfor i in xrange(int(s[1]) - int(t[1])):\n\t\t\tprint \"D\"\n\telse:\n\t\tprint int(t[1]) - int(s[1])\n\t\tfor i in xrange(int(t[1]) - int(s[1])):\n\t\t\tprint \"U\"\nelif s[1] == t[1]: # same row\n\tif s[0] == t[0]:\n\t\tprint 0\n\telif s[0] > t[0]:\n\t\tprint ord(s[0]) - ord(t[0])\n\t\tfor i in xrange(ord(s[0]) - ord(t[0])):\n\t\t\tprint \"L\"\n\telse:\n\t\tprint ord(t[0]) - ord(s[0])\n\t\tfor i in xrange(ord(t[0]) - ord(s[0])):\n\t\t\tprint \"R\"\nelif ord(t[0]) > ord(s[0]): # right\n\tif int(t[1]) > int(s[1]): #top right\n\t\tif int(t[1]) - int(s[1]) == (ord(t[0]) - ord(s[0])):\n\t\t\tprint int(t[1]) - int(s[1])\n\t\t\tfor i in xrange(int(t[1]) - int(s[1])):\n\t\t\t\tprint \"RU\"\n\t\telif int(t[1]) - int(s[1]) > (ord(t[0]) - ord(s[0])):\n\t\t\tprint (ord(t[0]) - ord(s[0])) + (int(t[1]) - int(s[1])-(ord(t[0]) - ord(s[0])))\n\t\t\tfor i in xrange((ord(t[0]) - ord(s[0]))):\n\t\t\t\tprint \"RU\"\n\t\t\tfor i in xrange(int(t[1]) - int(s[1])-(ord(t[0]) - ord(s[0]))):\n\t\t\t\tprint \"U\"\n\t\telse:\n\t\t\t#print (ord(t[0]) - ord(s[0])) + (int(t[1]) - int(s[1])-(ord(t[0]) - ord(s[0])))\n\t\t\tprint (int(t[1]) - int(s[1])) + ((ord(t[0]) - ord(s[0]))-(int(t[1]) - int(s[1])))\n\t\t\tfor i in xrange(int(t[1]) - int(s[1])):\n\t\t\t\tprint \"RU\"\n\t\t\tfor i in xrange((ord(t[0]) - ord(s[0]))-(int(t[1]) - int(s[1]))):\n\t\t\t\tprint \"R\"\n\telse: # bottom right\n\t\tif int(s[1]) - int(t[1]) == (ord(t[0]) - ord(s[0])):\n\t\t\tprint int(s[1]) - int(t[1])\n\t\t\tfor i in xrange(int(s[1]) - int(t[1])):\n\t\t\t\tprint \"RD\"\n\t\telif int(s[1]) - int(t[1]) > (ord(t[0]) - ord(s[0])):\n\t\t\tprint (ord(t[0]) - ord(s[0])) + (int(s[1]) - int(t[1])-(ord(t[0]) - ord(s[0])))\n\t\t\tfor i in xrange((ord(t[0]) - ord(s[0]))):\n\t\t\t\tprint \"RD\"\n\t\t\tfor i in xrange(int(s[1]) - int(t[1])-(ord(t[0]) - ord(s[0]))):\n\t\t\t\tprint \"D\"\n\t\telse:\n\t\t\t#print (ord(t[0]) - ord(s[0])) + (int(s[1]) - int(t[1])-(ord(t[0]) - ord(s[0])))\n\t\t\tprint (int(s[1]) - int(t[1])) + ((ord(t[0]) - ord(s[0]))-(int(s[1]) - int(t[1])))\n\t\t\tfor i in xrange(int(s[1]) - int(t[1])):\n\t\t\t\tprint \"RD\"\n\t\t\tfor i in xrange((ord(t[0]) - ord(s[0]))-(int(s[1]) - int(t[1]))):\n\t\t\t\tprint \"R\"\n\nelif ord(t[0]) < ord(s[0]): # left\n\tif int(t[1]) > int(s[1]): #top left\n\t\t#print \"up\"\n\t\tif int(t[1]) - int(s[1]) == (ord(s[0]) - ord(t[0])):\n\t\t\tprint int(t[1]) - int(s[1])\n\t\t\tfor i in xrange(int(t[1]) - int(s[1])):\n\t\t\t\tprint \"LU\"\n\t\telif int(t[1]) - int(s[1]) > (ord(s[0]) - ord(t[0])):\n\t\t\tprint (ord(s[0]) - ord(t[0])) + (int(t[1]) - int(s[1])-(ord(s[0]) - ord(t[0])))\n\t\t\tfor i in xrange((ord(s[0]) - ord(t[0]))):\n\t\t\t\tprint \"LU\"\n\t\t\tfor i in xrange(int(t[1]) - int(s[1])-(ord(t[0]) - ord(s[0]))):\n\t\t\t\tprint \"U\"\n\t\telse:\n\t\t\t#print (ord(s[0]) - ord(t[0])) + (int(t[1]) - int(s[1])-(ord(s[0]) - ord(t[0])))\n\t\t\tprint (int(t[1]) - int(s[1])) + ((ord(s[0]) - ord(t[0]))-(int(t[1]) - int(s[1])))\n\t\t\tfor i in xrange(int(t[1]) - int(s[1])):\n\t\t\t\tprint \"LU\"\n\t\t\tfor i in xrange((ord(s[0]) - ord(t[0]))-(int(t[1]) - int(s[1]))):\n\t\t\t\tprint \"L\"\n\telse: # bottom left\n\t\tif int(s[1]) - int(t[1]) == (ord(s[0]) - ord(t[0])):\n\t\t\tprint int(s[1]) - int(t[1])\n\t\t\tfor i in xrange(int(s[1]) - int(t[1])):\n\t\t\t\tprint \"LD\"\n\t\telif int(s[1]) - int(t[1]) > (ord(s[0]) - ord(t[0])):\n\t\t\tprint (ord(s[0]) - ord(t[0])) + (int(s[1]) - int(t[1])-(ord(s[0]) - ord(t[0])))\n\t\t\tfor i in xrange((ord(s[0]) - ord(t[0]))):\n\t\t\t\tprint \"LD\"\n\t\t\tfor i in xrange(int(s[1]) - int(t[1])-(ord(s[0]) - ord(t[0]))):\n\t\t\t\tprint \"D\"\n\t\telse:\n\t\t\t#print (ord(s[0]) - ord(t[0])) + (int(s[1]) - int(t[1])-(ord(s[0]) - ord(t[0])))\n\t\t\tprint (int(s[1]) - int(t[1])) + ((ord(s[0]) - ord(t[0]))-(int(s[1]) - int(t[1])))\n\t\t\tfor i in xrange(int(s[1]) - int(t[1])):\n\t\t\t\tprint \"LD\"\n\t\t\tfor i in xrange((ord(s[0]) - ord(t[0]))-(int(s[1]) - int(t[1]))):\n\t\t\t\tprint \"L\"\n"}, {"source_code": "import math, collections, sys\ninput = sys.stdin.readline\ns = input()\nt = input()\nv = ord(t[0]) - ord(s[0])\nh = int(t[1]) - int(s[1])\nif v < 0:\n vd = 'U'\nelif v > 0:\n vd = 'D'\nif h < 0:\n hd = 'R'\nelif h > 0:\n hd = 'L'\ndia = min(abs(v), abs(h))\nans = []\nfor i in range(dia):\n ans.append(hd+vd)\nfor i in range(abs(v)-dia):\n ans.append(vd)\nfor i in range(abs(h)-dia):\n ans.append(hd)\nprint(len(ans))\nfor i in ans:\n print(i)"}, {"source_code": "s=raw_input()\nd=raw_input()\na=[0]\nm={}\nfor i in range(8):\n\tfor j in range(1,9):\n\t\tm[chr(ord('a')+i)+str(9-j)]=i*8+j-1\n\nss=m[s]\ndd=m[d]\nr=dd/8-ss/8\nc=dd%8-ss%8\n\nprint((abs(r)-abs(c))+min(abs(r),abs(c)))\n\ndef lu(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"LU\")\ndef ru(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"RU\")\ndef ld(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"LD\")\n\t\t\ndef rd(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"RD\")\n\t\t\ndef dd(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"D\")\n\t\t\ndef ll(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"L\")\n\t\t\ndef uu(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"U\")\n\t\t\ndef rr(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"R\")\n\nif(abs(r)>abs(c)):\n\tif r>0 and c>0:\n\t\tdd(r-c)\n\t\trd(c)\n\tif r>0 and c<0:\n\t\tdd(r-abs(c))\n\t\tld(c)\n\tif r<0 and c>0:\n\t\tuu(abs(r)-c)\n\t\tru(c)\n\tif r<0 and c<0:\n\t\tuu(abs(r)-abs(c))\n\t\tlu(c)\n\nif(abs(r)<abs(c)):\n\tif r>0 and c>0:\n\t\trr(c-r)\n\t\trd(r)\n\tif r>0 and c<0:\n\t\tll(c-abs(r))\n\t\tld(r)\n\tif r<0 and c>0:\n\t\trr(abs(c)-abc(r))\n\t\tru(r)\n\tif r<0 and c<0:\n\t\tll(abs(c)-abs(r))\n\t\tlu(r)\n\nif abs(r)==abs(c):\n\tif r>0 and c>0:\n\t\trd(r)\n\tif r>0 and c<0:\n\t\tld(r)\n\tif r<0 and c>0:\n\t\tru(c)\n\tif r<0 and c<0:\n\t\tlu(c)\n\n\n"}, {"source_code": "#\u0448\u0430\u0445\u043c\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0441\u043a\u0430\nimport math\n#\u0432\u0445\u043e\u0434\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n#\u0442\u043e\u0447\u043a\u0430 \u0441\u0442\u0430\u0440\u0442\u0430 \nx=list(input())\nx[0]=ord(x[0])-96\nx[1]=ord(x[1])\ny=list(input())\ny[0]=ord(y[0])-96\ny[1]=ord(y[1])\n#\u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0445\u043e\u0434\u043e\u0432 \nif x[0]!=y[0]:\n dist= x[0] - y[0]\nelif x[0]==y[0]:\n dist= x[1] - y[1]\ndist=int(math.fabs(dist))\nprint('\\n')\nprint(dist)\n\n#\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\n#\u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438/\u0432\u0435\u0440\u0438\u043a\u0430\u043b\u0438\narr=[]\narr1=[]\nwhile x[0]!=y[0]:\n if x[0]>y[0]:\n arr.append('U')\n x[0]-=1\n elif x[0]<y[0]:\n arr.append('D')\n x[0]+=1\n\nwhile x[1]!=y[1]:\n if x[1]>y[1]:\n arr1.append('L')\n x[1]-=1\n elif x[1]<y[1]:\n arr1.append('R')\n x[1]+=1\n\n\n\nn=len(arr)-len(arr1)\nm=len(arr1)-len(arr)\nif len(arr)<len(arr1):\n for i in range(len(arr)):\n print(arr1[i]+arr[i])\n for j in range(m):\n print(arr1[j])\nelse:\n for i in range(len(arr1)):\n print(arr1[i]+arr[i])\n for j in range(n):\n print(arr[j])"}, {"source_code": "def fun(x1,y1,x2,y2):\n if abs(x2-x1)==abs(y2-y1):\n print(abs(x2-x1))\n else:\n print(abs(x2-x1)+abs(y2-y1))\n while x1-x2!=0 or y1-y2!=0:\n if x1-x2<0 and y1-y2==0:\n x1=x1+1\n print(\"D\")\n if x1-x2>0 and y1-y2==0:\n x1=x1-1\n print(\"U\")\n if x1-x2==0 and y1-y2<0:\n y1=y1-1\n print(\"R\")\n if x1-x2==0 and y1-y2>0:\n y1=y1+1\n print(\"L\")\n if x1-x2>0 and y1-y2>0:\n x1=x1-1\n y1=y1-1\n print(\"LU\")\n if x1-x2>0 and y1-y2<0:\n x1=x1-1\n y1=y1+1\n print(\"RU\")\n if x1-x2<0 and y1-y2<0:\n x1=x1+1\n y1=y1+1\n print(\"RD\")\n if x1-x2<0 and y1-y2>0:\n x1=x1+1\n y1=y1-1\n print(\"LD\")\n return \n \n\na=input()\nb=input()\nDict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8} \ny1=Dict.get(a[0])\nx1=9-int(a[1])\ny2=Dict.get(b[0])\nx2=9-int(b[1])\nprint(x1,y1,x2,y2)\n#fun(x1,y1,x2,y2)\n\n"}, {"source_code": "s = input()\nf = input()\nx = ord(s[0])-ord(f[0])\ny = ord(s[1])-ord(f[1])\nprint(max(x,y))\nwhile x != 0 or y != 0:\n st = \"\"\n if x < 0:\n st += \"R\"\n x = x + 1\n if x > 0:\n st = st + \"L\"\n x = x - 1\n if y < 0:\n st = st + \"U\"\n y = y + 1\n if y > 0:\n st = st + \"D\"\n y = y - 1\n print(st)"}, {"source_code": "s=str(input())\nt=str(input())\nif s[0]==t[0]:\n print(abs(int(s[1])-int(t[1])))\n for i in range(abs(int(s[1])-int(t[1]))):\n if int(s[1])-int(t[1])>0:\n print(\"D\")\n else:\n print(\"U\")\nelif s[1]==t[1]:\n print(abs(ord(s[0])-ord(t[0])))\n for i in range(abs(ord(s[0])-ord(t[0]))):\n if ord(s[0])-ord(t[0]):\n print(\"R\")\n else:\n print(\"L\")\nelse:\n print(max(abs((int(s[1])-int(t[1]))),abs(ord(s[0])-ord(t[0]))))\n for i in range(min(abs(ord(s[0])-ord(t[0])),abs(int(s[1])-int(t[1])))):\n if int(s[1])-int(t[1])>0 and ord(s[0])-ord(t[0])<0:\n print(\"RD\")\n elif int(s[1])-int(t[1])<0 and ord(s[0])-ord(t[0])>0:\n print(\"LU\")\n elif int(s[1])-int(t[1])>0 and ord(s[0])-ord(t[0])>0:\n print(\"LD\")\n else:\n print(\"RU\")\n for i in range(max(abs((int(s[1])-int(t[1]))),abs(ord(s[0])-ord(t[0])))-min(abs(ord(s[0])-ord(t[0])),abs(int(s[1])-int(t[1])))):\n if abs(int(s[1])-int(t[1]))>=abs(ord(s[0])-ord(t[0])):\n if int(s[1])>int(t[1]):\n print(\"D\")\n else:\n print(\"U\")\n else:\n if s[0]>t[0]:\n print(\"L\")\n else:\n print(\"R\")\n \n \n "}, {"source_code": "x1, y1 = input()\nx2, y2 = input()\n\ny1, y2 = map(int, [y1, y2])\nx1, x2 = map(ord, [x1, x2])\n\n\nx = abs(x1 - x2)\ny = abs(y1 - y2)\npath = max([x, y])\nprint(path)\n\nfor i in range(path):\n\tx0 = x1 - x2\n\ty0 = y1 - y2\n\tif x0 != 0 and y0 != 0:\n\t\tif x0 < 0 and y0 < 0:\n\t\t\tprint(\"RU\")\n\t\t\tx1 += 1\n\t\t\ty1 += 1\n\t\telif x0 < 0 and y0 > 0:\n\t\t\tprint(\"RD\")\n\t\t\tx1 += 1\n\t\t\ty1 -= 1\n\t\telif x0 > 0 and y0 < 0:\n\t\t\tprint(\"LD\")\n\t\t\ty1 += 1\n\t\t\tx1 -= 1\n\t\telif x0 > 0 and y0 > 0:\n\t\t\tprint(\"LU\")\n\t\t\ty1 -= 1\n\t\t\tx1 -= 1\n\telif x0 == 0 or y0 == 0:\n\t\tif x0 > 0:\n\t\t\tprint(\"L\")\n\t\t\tx1 -= 1\n\t\telif x0 < 0:\n\t\t\tprint(\"R\")\n\t\t\tx1 += 1\n\t\telif y0 > 0:\n\t\t\tprint(\"D\")\n\t\t\ty1 -= 1\n\t\telif y0 < 0:\n\t\t\tprint(\"U\")\n\t\t\ty1 += 1\n\telse:\n\t\tprint(\"No need for more\")"}, {"source_code": "s = str(input())\nt = str(input())\n\n\n\ndef calculateMoves(s,t):\n # Input parsing\n cols = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n sx = cols[s[0]]\n sy = int(s[1])\n tx = cols[t[0]]\n ty = int(t[1])\n\n # Calculating moves\n moves = []\n while True:\n xflag = 0\n yflag = 0\n xmove = ''\n ymove = ''\n move = ''\n if sx != tx:\n xflag = 1\n if sx < tx:\n xmove = 'L'\n sx = sx + 1\n else:\n xmove = 'R'\n sx = sx - 1\n if sy != ty:\n yflag = 1\n if sy < ty:\n ymove = 'D'\n sy = sy + 1\n else:\n ymove = 'U'\n sy = sy - 1\n if xflag: move = move + xmove\n if yflag: move = move + ymove\n if (not xflag and not yflag):\n break\n else:\n moves.append(move)\n\n # Output Parsing\n print(len(moves))\n for i in moves:\n print(i)\n return\n\n\n\ncalculateMoves(s,t)\n"}, {"source_code": "s=str(input())\nt=str(input())\nif s[0]==t[0]:\n print(abs(int(s[1])-int(t[1])))\n for i in range(abs(int(s[1])-int(t[1]))):\n if int(s[1])-int(t[1])>0:\n print(\"D\")\n else:\n print(\"U\")\nelif s[1]==t[1]:\n print(abs(ord(s[0])-ord(t[0])))\n for i in range(abs(ord(s[0])-ord(t[0]))):\n if ord(s[0])-ord(t[0]):\n print(\"R\")\n else:\n print(\"L\")\nelse:\n print(max(abs((int(s[1])-int(t[1]))),abs(ord(s[0])-ord(t[0]))))\n for i in range(min(abs(ord(s[0])-ord(t[0])),abs(int(s[1])-int(t[1])))):\n if int(s[1])-int(t[1])>0 and ord(s[0])-ord(t[0])<0:\n print(\"RD\")\n elif int(s[1])-int(t[1])<0 and ord(s[0])-ord(t[0])>0:\n print(\"LU\")\n elif int(s[1])-int(t[1])>0 and ord(s[0])-ord(t[0])>0:\n print(\"LD\")\n else:\n print(\"RU\")\n for i in range(max(abs((int(s[1])-int(t[1]))),abs(ord(s[0])-ord(t[0])))-min(abs(ord(s[0])-ord(t[0])),abs(int(s[1])-int(t[1])))):\n if abs(int(s[1])-int(t[1]))>=abs(ord(s[0])-ord(t[0])):\n if int(s[1])>int(t[1]):\n print(\"D\")\n else:\n print(\"U\")\n else:\n if s[0]>t[0]:\n print(\"L\")\n else:\n print(\"R\")\n \n \n "}, {"source_code": "x=list(input())\ny=list(input())\nx0,y0=int((ord(x[0])-ord(\"a\")+1)),int(x[1])\nx1,y1=int((ord(y[0])-ord(\"a\")+1)),int(y[1])\nprint(max(abs(x1-x0),abs(y0-y1)))\nwhile x0!=x1 and y0!=y1:\n if x1>x0:\n print(\"R\",end=\"\")\n x0+=1\n if x0>x1:\n print(\"L\",end=\"\")\n x0-=1\n if y0>y1:\n print(\"D\",end=\"\")\n y0-=1\n if y1>y0:\n print(\"U\",end=\"\")\n y0+=1\n print() "}, {"source_code": "a=input()\nb=input()\nA,B=[],[]\ndict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\nfor x in a:\n A.append(x)\nfor x in b:\n B.append(x)\nA[0],B[0]=int(dict[A[0]]),int(dict[B[0]])\nA[1],B[1]=int(A[1]),int(B[1])\nC=[]\nwhile A[0]!=B[0]: \n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]-1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]+1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nprint(len(C))\nwhile C!=[]:\n print(C[0])\n C.pop(0)"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport io\nimport os\nimport sys\nimport operator as op\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from cStringIO import StringIO\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n from io import BytesIO as StringIO\n\nsys.stdout, stream = io.IOBase(), StringIO()\nsys.stdout.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)\nsys.stdout.write = stream.write if sys.version_info[0] < 3 else lambda s: stream.write(s.encode())\n\ninput, flush = sys.stdin.readline, sys.stdout.flush\ninput = StringIO(os.read(0, os.fstat(0).st_size)).readline\n\n\ndef main():\n f = lambda s: (ord(s[0]) - ord('a'), int(s[1]) - 1)\n\n s = f(input())\n t = f(input())\n\n x, y = map(op.sub, t, s)\n\n d = ''\n if (0 < x) and (0 < y):\n d = 'RU'\n elif (0 < x) and (0 > y):\n d = 'RD'\n elif (0 > x) and (0 < y):\n d = 'LU'\n elif (0 > x) and (0 > y):\n d = 'LD'\n\n t = min(abs(x), abs(y))\n sol = [d] * t\n\n x += -t if x > 0 else t\n y += -t if y > 0 else t\n\n d = 'R' if x > 0 else 'L'\n sol.extend([d] * abs(x))\n\n d = 'U' if x > 0 else 'D'\n sol.extend([d] * abs(y))\n\n print(len(sol))\n print('\\n'.join(sol))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def fun(x1,y1,x2,y2):\n if abs(x2-x1)==abs(y2-y1):\n print(abs(x2-x1))\n else:\n print(abs(x2-x1)+abs(y2-y1))\n while x1-x2!=0 or y1-y2!=0:\n if x1-x2<0 and y1-y2==0:\n x1=x1+1\n print(\"D\")\n if x1-x2>0 and y1-y2==0:\n x1=x1-1\n print(\"U\")\n if x1-x2==0 and y1-y2<0:\n y1=y1+1\n print(\"R\")\n if x1-x2==0 and y1-y2>0:\n y1=y1-1\n print(\"L\")\n if x1-x2>0 and y1-y2>0:\n x1=x1-1\n y1=y1-1\n print(\"LU\")\n if x1-x2>0 and y1-y2<0:\n x1=x1-1\n y1=y1+1\n print(\"RU\")\n if x1-x2<0 and y1-y2<0:\n x1=x1+1\n y1=y1+1\n print(\"RD\")\n if x1-x2<0 and y1-y2>0:\n x1=x1+1\n y1=y1-1\n print(\"LD\")\n return \n \n\na=input()\nb=input()\nDict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8} \ny1=Dict.get(a[0])\nx1=9-int(a[1])\ny2=Dict.get(b[0])\nx2=9-int(b[1])\nfun(x1,y1,x2,y2)\n\n"}, {"source_code": "import time\n\ndef calculateCoords(c):\n return (8 - int(c[1]), ord(c[0]) - 97) \n\ndef run():\n start = calculateCoords(input())\n end = calculateCoords(input())\n \n seen = [[False for x in range(8)] for y in range(8)]\n seen[start[0]][start[1]] = True\n toCheck = []\n toCheck.append((start, [])) \n\n while True:\n temp = []\n for (position, l) in toCheck:\n r = position[0]\n c = position[1]\n if r == end[0] and c == end[1]:\n print(len(l))\n for ch in l:\n print(ch)\n return\n if r > 0:\n if c > 0 and not seen[r - 1][c - 1]:\n newl1 = [x for x in l]\n newl1.append(\"LU\")\n temp.append(((r - 1, c - 1), newl1))\n if c < 7 and not seen[r - 1][c + 1]:\n newl2 = [x for x in l]\n newl2.append(\"RU\")\n temp.append(((r - 1, c + 1), newl2))\n newl3 = [x for x in l]\n newl3.append(\"U\")\n temp.append(((r - 1, c), newl3))\n if r < 7:\n if c > 0 and not seen[r + 1][c - 1]:\n newl4 = [x for x in l]\n newl4.append(\"LD\")\n temp.append(((r + 1, c - 1), newl4))\n if c < 7 and not seen[r + 1][c + 1]:\n newl5 = [x for x in l]\n newl5.append(\"RD\")\n temp.append(((r + 1, c + 1), newl5))\n newl6 = [x for x in l]\n newl6.append(\"U\")\n temp.append(((r + 1, c), newl6))\n if c > 0:\n newl7 = [x for x in l]\n newl7.append(\"L\")\n temp.append(((r, c - 1), newl7))\n if c < 7:\n newl8 = [x for x in l]\n newl8.append(\"R\")\n temp.append(((r, c + 1), newl8))\n toCheck = []\n toCheck.extend(temp)\n\nrun()"}, {"source_code": "from collections import deque\n\ndirections = {\n 'D': (1, 0),\n 'U': (1, 0),\n 'R': (0, 1),\n 'L': (0, -1),\n 'RD': (1, 1),\n 'RU': (-1, 1),\n 'LD': (1, -1),\n 'LU': (-1, -1)\n}\n\ndef code(i, j):\n return i * 8 + j\n\ndef decode(x):\n return (x // 8, x % 8)\n\ndef code_input():\n coord = input();\n j = ord(coord[0]) - ord('a')\n i = 8 - int(coord[1])\n return code(i, j)\n\ndef move(x, d):\n (i, j) = decode(x)\n (di, dj) = directions[d]\n i += di\n j += dj\n if i >= 0 and i < 8 and j >= 0 and j < 8:\n return code(i,j)\n else:\n return -1\n\ns = code_input()\nt = code_input();\n\nq = deque([])\nq.append(s)\nvisited = set([s])\nlast_dir = {}\nprev_field = {}\ndist = {s: 0}\n\nwhile len(q) > 0 and t not in visited:\n field = q.popleft()\n for d in directions:\n neighbor = move(field, d)\n if neighbor != -1 and neighbor not in visited:\n visited.add(neighbor)\n q.append(neighbor)\n dist[neighbor] = dist[field] + 1\n last_dir[neighbor] = d\n prev_field[neighbor] = field\nprint(dist[t])\n\nfield = t\npath = deque([])\nwhile field in prev_field:\n path.appendleft(last_dir[field])\n field = prev_field[field]\nfor mv in path:\n print(mv)"}, {"source_code": "def fun(x1,y1,x2,y2):\n if abs(x2-x1)==abs(y2-y1):\n print(abs(x2-x1))\n else:\n print(abs(x2-x1)+abs(y2-y1))\n while x1-x2!=0 or y1-y2!=0:\n if x1-x2<0 and y1-y2==0:\n x1=x1+1\n print(\"D\")\n if x1-x2>0 and y1-y2==0:\n x1=x1-1\n print(\"U\")\n if x1-x2==0 and y1-y2<0:\n y1=y1-1\n print(\"R\")\n if x1-x2==0 and y1-y2>0:\n y1=y1+1\n print(\"L\")\n if x1-x2>0 and y1-y2>0:\n x1=x1-1\n y1=y1-1\n print(\"LU\")\n if x1-x2>0 and y1-y2<0:\n x1=x1-1\n y1=y1+1\n print(\"RU\")\n if x1-x2<0 and y1-y2<0:\n x1=x1+1\n y1=y1+1\n print(\"RD\")\n if x1-x2<0 and y1-y2>0:\n x1=x1+1\n y1=y1-1\n print(\"LD\")\n return \n \n\na=input()\nb=input()\nDict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8} \ny1=Dict.get(a[0])\nx1=9-int(a[1])\ny2=Dict.get(b[0])\nx2=9-int(b[1])\nprint(x1,y1,x2,y2)\n#fun(x1,y1,x2,y2)\n\n"}, {"source_code": "s=input()\nn=input()\nm=['','a','b','c','d','e','f','g','h']\nfor i in range(1,len(m)):\n if s[0]==m[i]:\n x=i\n if n[0]==m[i]:\n x2=i \ny=int(s[1])\ny2=int(n[1])\nM=[]\nb=''\nxod=0 \nwhile True:\n if x>x2:\n x-=1\n b+='L'\n \n if x<x2:\n x+=1\n b+='R'\n if y>y2:\n y-=1\n b+='D'\n if y<y2:\n y+=1\n b+='U'\n xod+=1\n M.append(b)\n b=''\n if x==x2 and y==y2:\n break\nprint(xod)\nfor i in range(len(M)):\n print(M[i]) \n"}, {"source_code": "x0y0=input()\nxy=input()\nx0y0=[ord(x0y0[0])-ord('a')+1,int(x0y0[1])]\nxy=[ord(xy[0])-ord('a')+1,int(xy[1])]\nn=max(abs(x0y0[0]-xy[0]),abs(x0y0[1]-xy[1]))\nprint(abs(n))\nfor i in range(0,n):\n if xy[0]==x0y0[0] and xy[1]==x0y0[1]:\n print('OK')\n if xy[0]>x0y0[0] and xy[1]>x0y0[1]:\n print('RU')\n if xy[0]<x0y0[0] and xy[1]<x0y0[1]:\n print('LD')\n if xy[0]<x0y0[0] and xy[1]>x0y0[1]:\n print('LU')\n if xy[0]>x0y0[0] and xy[1]<x0y0[1]:\n print('RD')\n if xy[0]>x0y0[0] and xy[1]==x0y0[1]: print('R')\n if xy[0]<x0y0[0] and xy[1]==x0y0[1]: print('L')\n if xy[1]>x0y0[1] and xy[0]==x0y0[0]: print('U')\n if xy[1]<x0y0[1] and xy[0]==x0y0[0]: print('D')\n\n \n \n"}, {"source_code": "origin = input()\ntarget = input()\n\ndef char2Num(c):\n return ord(c)-ord('a')+1\n\ndef num2Char(d):\n return chr(ord('a')+d-1)\n\nx_origin = char2Num(origin[0])\ny_origin = int(origin[1])\n\nx_target = char2Num(target[0])\ny_target = int(target[1])\n\nx = x_origin\ny = y_origin\nsteps = []\n\nwhile x < x_target and y < y_target: # keep RU until x reaches x_target or y reaches y_target\n steps.append('RU')\n x += 1\n y += 1\nwhile x<x_target and y > y_target:\n steps.append('RD')\n x += 1\n y -= 1\nwhile x > x_target and y < y_target: # keep RU until x reaches x_target or y reaches y_target\n steps.append('LU')\n x += 1\n y += 1\nwhile x>x_target and y > y_target:\n steps.append('LD')\n x += 1\n y -= 1\nwhile x < x_target:\n steps.append('R') \n x += 1\nwhile x < x_target:\n steps.append('L') \n x -= 1\nwhile y < y_target:\n steps.append('U')\n y += 1\nwhile y > y_target:\n steps.append('D')\n y -= 1 \nprint(len(steps))\nfor step in steps:\n print(step)"}, {"source_code": "c1 = input()\nc2 = input()\nd = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8}\nx0, y0 = (d[c1[0]], int(c1[1]))\nx, y = (d[c2[0]], int(c2[1]))\n\n\nwhile (x != x0 and y != y0):\n if (x0 < x):\n print(\"R\", end = '')\n x0 += 1\n else:\n print(\"L\", end = \"\")\n x0 -= 1\n if (y0 < y):\n print(\"U\", end = '')\n y0 += 1\n else:\n print(\"D\", end = \"\")\n y0 -= 1\n print()"}, {"source_code": "a=input()\nb=input()\nA,B=[],[]\ndict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\nfor x in a:\n A.append(x)\nfor x in b:\n B.append(x)\nA[0],B[0]=int(dict[A[0]]),int(dict[B[0]])\nA[1],B[1]=int(A[1]),int(B[1])\nC=[]\nwhile A[0]!=B[0]: \n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]-1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]-1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nprint(len(C))\nwhile C!=[]:\n print(C[0])\n C.pop(0)"}, {"source_code": "x,y=map(lambda x:ord(x[1])-ord(x[0]), zip(raw_input(),raw_input()))\na,b=abs(x),abs(y)\nm,d=max(a,b),abs(a-b)\nprint m\nprint '\\n'.join(map(lambda x:x[0]+x[1], zip('LR'[x>=0]*a+''*d,'DU'[y>=0]*b+''*d)))"}, {"source_code": "a = input()\nb = input()\nsatr = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7}\nsotoon = [8]\nn = 0\nif (a[0] == b[0]):\n n = int(b[1]) - int(a[1])\n if (n < 0):\n n = n * -1\n print(n)\n for _ in range(n):\n print(\"D\")\n else:\n print(n)\n for _ in range(n):\n print(\"U\")\nelif (a[1] == b[1]):\n n = satr[b[0]] - satr[a[0]]\n if (n < 0):\n n = n * -1\n print(n)\n for _ in range(n):\n print(\"L\")\n else:\n print(n)\n for _ in range(n):\n print(\"R\")\n\nelse:\n i = satr[b[0]] - satr[a[0]]\n j = int(b[1]) - int(a[1])\n if (abs(i) > abs(j)):\n print(abs(i))\n else:\n print(abs(j))\n if (i > 0):\n if (j > 0):\n for _ in range(i):\n print(\"RU\")\n for _ in range(abs(j - i)):\n print(\"U\")\n else:\n for _ in range(abs(j)):\n print(\"RD\")\n for _ in range(abs(i + j)):\n print(\"R\")\n else:\n if (j > 0):\n for _ in range(j):\n print(\"LU\")\n for _ in range(abs(i + j)):\n print(\"L\")\n else:\n for _ in range(abs(j)):\n print(\"LD\")\n for _ in range(abs(i - j)):\n print(\"D\")\n"}, {"source_code": "#! /usr/bin/env python\n\ns = raw_input();\nt = raw_input();\n\n#dir_x = ['U', 'D'];\n#dir_y = ['L', 'R'];\n\ncolumn = ord(s[0]) - ord(t[0]); \nrow = int(s[1]) - int(t[1]);\n\n#print row, column;\nnext_x = next_y = 'hehe';\nif column < 0 :\n\tnext_y = 'R';\nelif column > 0:\n\tnext_y = 'L';\nif row < 0 :\n\tnext_x = 'U';\nelif row > 0:\n\tnext_x = 'D';\n\nrow = abs(row);\ncolumn = abs(column);\nans = list();\n\nwhile row > 0 or column > 0:\n\tif column > 0 and row > 0:\n\t\tprint (\"%c%c\" % (next_y, next_x));\n\t\tcolumn -= 1;\n\t\trow -= 1;\n\telif row > 0:\n\t\tprint next_x;\n\t\trow -= 1;\n\telif column > 0:\n\t\tprint next_y;\n\t\tcolumn -= 1;\n"}, {"source_code": "p1 = raw_input()\np2 = raw_input()\n\nstart = [ord(p1[0]), ord(p1[1])]\nend = [ord(p2[0]), ord(p2[1])]\n\ns_edge = min(abs(start[0]-end[0]), abs(start[1]-end[1]))\nl_edge = max(abs(start[0]-end[0]), abs(start[1]-end[1]))\n\ndiff = l_edge - s_edge\n\nif abs(start[0]-end[0]) < abs(start[1]-end[1]):\n h = 0\nelse :\n h = 1\n\nif start[0] <= end[0] and start[1] <= end[1]:\n for i in range(s_edge):\n print 'RU'\n if h == 1:\n for i in range(diff):\n print 'R'\n else:\n for i in range (diff):\n print 'U'\nelif start[0] <= end[0] and start[1] >= end[1]:\n for i in range(s_edge):\n print 'RD'\n if h == 1:\n for i in range(diff):\n print 'R'\n else:\n for i in range(diff):\n print 'D'\nelif start[1] >= end[1] and start[0] >= end[0]:\n for i in range(s_edge):\n print 'LD'\n if h == 1:\n for i in range(diff):\n print 'L'\n else :\n for i in range(diff):\n print 'D'\nelse:\n for i in range(s_edge):\n print 'LU'\n if h == 1:\n for i in range(diff):\n print 'L'\n else :\n for i in range(diff):\n print 'U'\n "}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport timeit\nimport time\nimport sys\nimport io\nimport re\nimport math\nstart = time.clock()\ncnt=0\nrot=[]\ns=list(raw_input())\ns=[int(ord(s[0]))-96,int(s[1])]\ng=list(raw_input())\ng=[int(ord(g[0]))-96,int(g[1])]\n#naname\nwhile g[0]<>s[0] and g[1]<>s[1]:\n if g[0]>s[0] and g[1]>s[1]:\n s[0]+=1\n s[1]+=1\n cnt+=1\n rot.append('RU')\n elif g[0]<s[0] and g[1]<s[0]:\n s[0]-=1\n s[1]-=1\n cnt+=1\n rot.append('LD')\n elif g[0]>s[0] and g[1]<s[1]:\n s[0]+=1\n s[1]-=1\n cnt+=1\n rot.append('RD')\n else:\n s[0]-=1\n s[1]+=1\n cnt+=1\n rot.append('LU')\nwhile g[0]<>s[0] or g[1]<>s[1]:\n if g[0]>s[0]:\n s[0]+=1\n cnt+=1\n rot.append('R')\n elif g[0]<s[0]:\n s[0]-=1\n cnt+=1\n rot.append('L')\n elif g[1]>s[1]:\n s[1]+=1\n cnt+=1\n rot.append('U')\n else:\n s[1]-=1\n cnt+=1\n rot.append('D')\nprint cnt\nfor i in rot:\n print i"}, {"source_code": "p1, p2 = input(), input()\nx1, y1 = ord(p1[0]) - ord('a') + 1, int(p1[1])\nx2, y2 = ord(p2[0]) - ord('a') + 1, int(p2[1])\nx = x2-x1\ny = y2-y1\nd1, d2 = 'L', 'D'\nif x > 0:\n d1 = 'R'\nif y > 0:\n d2 = 'U'\nif x > y:\n print(x)\nelse:\n print(y)\n# import pdb\n# pdb.set_trace()\nif x < 0:\n x = -x\nif y < 0:\n y = -y\nwhile x or y:\n if x:\n x -= 1\n print(d1, end='')\n if y:\n y -= 1\n print(d2, end='')\n print()\n"}, {"source_code": "st = input()\nend = input()\n\nfor i in st:\n if i.isalpha():\n col1 = ord(i) - 97\n else:\n row1 = 8 - int(i)\nfor i in end:\n if i.isalpha():\n col2 = ord(i) - 97\n else:\n row2 = 8 - int(i)\n\nif(col1>col2 and row1>row2):\n cond1=1\nelif(col1<col2 and row1>row2 ):\n cond2=1\nelif(col1>col2 and row1<row2):\n cond3=1\nelse:\n cond1=4\n\n\ndiff1 = abs(col2-col1)\ndiff2 = abs(row2-row1)\n\nmin = min(diff1,diff2)\nmax = max(diff1,diff2)\n\nprint(max)\nfor i in range(min):\n if cond1:\n print('RD')\n elif cond2:\n print('LD')\n elif cond3:\n print('RU')\n else:\n print('LU')\n\ndiff = diff1-diff2\n\nif diff>0:\n for i in range(diff):\n if cond1 or cond3:\n print('R')\n else:\n print('L')\nelse:\n for i in range(abs(diff)):\n if cond1 or cond3:\n print('D')\n else:\n print('U')\n\n\n\n"}, {"source_code": "\ufeff\"\"\"\n<div class=\"problem-statement\"><div class=\"header\"><div class=\"title\">A. Shortest path of the king</div><div class=\"time-limit\"><div class=\"property-title\">time limit per test</div>1 second</div><div class=\"memory-limit\"><div class=\"property-title\">memory limit per test</div>64 megabytes</div><div class=\"input-file\"><div class=\"property-title\">input</div>standard input</div><div class=\"output-file\"><div class=\"property-title\">output</div>standard output</div></div><div><p>The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square <span class=\"tex-span\"><i>t</i></span>. As the king is not in habit of wasting his time, he wants to get from his current position <span class=\"tex-span\"><i>s</i></span> to square <span class=\"tex-span\"><i>t</i></span> in the least number of moves. Help him to do this.</p><center> <img class=\"tex-graphics\" src=\"http://codeforces.com/predownloaded/0a/92/0a928ad1310e4dbe9374f953e32def4f56b44743.png\" style=\"max-width: 100.0%;max-height: 100.0%;\"> </center><p>In one move the king can get to the square that has a common side or a common vertex with the square the king is currently in (generally there are 8 different squares he can move to).</p></div><div class=\"input-specification\"><div class=\"section-title\">Input</div><p>The first line contains the chessboard coordinates of square <span class=\"tex-span\"><i>s</i></span>, the second line \u2014 of square <span class=\"tex-span\"><i>t</i></span>.</p><p>Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from <span class=\"tex-font-style-tt\">a</span> to <span class=\"tex-font-style-tt\">h</span>), the second one is a digit from <span class=\"tex-font-style-tt\">1</span> to <span class=\"tex-font-style-tt\">8</span>.</p></div><div class=\"output-specification\"><div class=\"section-title\">Output</div><p>In the first line print <span class=\"tex-span\"><i>n</i></span> \u2014 minimum number of the king's moves. Then in <span class=\"tex-span\"><i>n</i></span> lines print the moves themselves. Each move is described with one of the 8: <span class=\"tex-font-style-tt\">L</span>, <span class=\"tex-font-style-tt\">R</span>, <span class=\"tex-font-style-tt\">U</span>, <span class=\"tex-font-style-tt\">D</span>, <span class=\"tex-font-style-tt\">LU</span>, <span class=\"tex-font-style-tt\">LD</span>, <span class=\"tex-font-style-tt\">RU</span> or <span class=\"tex-font-style-tt\">RD</span>. </p><p><span class=\"tex-font-style-tt\">L</span>, <span class=\"tex-font-style-tt\">R</span>, <span class=\"tex-font-style-tt\">U</span>, <span class=\"tex-font-style-tt\">D</span> stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diagonal moves. If the answer is not unique, print any of them. </p></div><div class=\"sample-tests\"><div class=\"section-title\">Examples</div><div class=\"sample-test\"><div class=\"input\"><div class=\"title\">Input</div><pre>a8<br>h1<br></pre></div><div class=\"output\"><div class=\"title\">Output</div><pre>7<br>RD<br>RD<br>RD<br>RD<br>RD<br>RD<br>RD<br></pre></div></div></div></div>\n\nA. Shortest path of the king\ntime limit per test1 second\nmemory limit per test64 megabytes\ninputstandard input\noutputstandard output\nThe king is left alone on the chessboard. In spite of this loneliness, h\ne doesn't lose heart, because he has business of national importance. Fo\nr example, he has to pay an official visit to square t. As the king is n\not in habit of wasting his time, he wants to get from his current positi\non s to square t in the least number of moves. Help him to do this.\n\n\nIn one move the king can get to the square that has a common side or a c\nommon vertex with the square the king is currently in (generally there a\nre 8 different squares he can move to).\n\nInput\nThe first line contains the chessboard coordinates of square s, the seco\nnd line \u2014 of square t.\n\nChessboard coordinates consist of two characters, the first one is a low\nercase Latin letter (from a to h), the second one is a digit from 1 to 8\n.\n\nOutput\nIn the first line print n \u2014 minimum number of the king's moves. Then in \nn lines print the moves themselves. Each move is described with one of t\nhe 8: L, R, U, D, LU, LD, RU or RD.\n\nL, R, U, D stand respectively for moves left, right, up and down (accord\ning to the picture), and 2-letter combinations stand for diagonal moves.\n If the answer is not unique, print any of them.\n\nExamples\ninput\na8\nh1\noutput\n7\nRD\nRD\nRD\nRD\nRD\nRD\nRD\n\"\"\"\n\nfrom sys import stdin, stdout\n\na1 = zip(raw_input(), raw_input())\nb1, b2 = map(lambda i1: abs(ord(i1[1]) - ord(i1[0])), a1)\nc1, c2 = 'LR'[b1>=0], 'DU'[b2>=0]\nd1, d2 = max(b1,b2), min(b1,b2)\n\nprint d1, '\\n', \\\n (c1 + c2 + '\\n') * d2 + \\\n (c1 + '\\n') * (b1 - d2) + \\\n (c2 + '\\n') * (b2 - d2)\n"}, {"source_code": "a = input()\nb = input()\nsatr = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7}\nsotoon = [8]\nn = 0\nif (a[0] == b[0]):\n n = int(b[1]) - int(a[1])\n if (n < 0):\n n = n * -1\n print(n)\n for _ in range(n):\n print(\"D\")\n else:\n print(n)\n for _ in range(n):\n print(\"U\")\nelif (a[1] == b[1]):\n n = satr[b[0]] - satr[a[0]]\n if (n < 0):\n n = n * -1\n print(n)\n for _ in range(n):\n print(\"L\")\n else:\n print(n)\n for _ in range(n):\n print(\"R\")\n\nelse:\n i = satr[b[0]] - satr[a[0]]\n j = int(b[1]) - int(a[1])\n if (abs(i) > abs(j)):\n print(abs(i))\n else:\n print(abs(j))\n if (i > 0):\n if (j > 0):\n if(abs(j)>=abs(i)):\n for _ in range(i):\n print(\"RU\")\n for _ in range(abs(j - i)):\n print(\"U\")\n else :\n for _ in range(j):\n print(\"RU\")\n for _ in range(abs(i-j)):\n print(\"R\")\n else:\n if(abs(i)>=abs(j)):\n for _ in range(abs(j)):\n print(\"RD\")\n for _ in range(abs(i + j)):\n print(\"R\")\n else :\n for _ in range(abs(i)):\n print(\"RD\")\n for _ in range(abs(i + j)):\n print(\"D\")\n else:\n if (j > 0):\n if(abs(i)>=abs(j)):\n for _ in range(j):\n print(\"LU\")\n for _ in range(abs(i + j)+1):\n print(\"L\")\n else :\n for _ in range(abs(i)):\n print(\"LU\")\n for _ in range(abs(i + j)):\n print(\"U\")\n else:\n if(abs(i)>=abs(j)):\n for _ in range(abs(j)):\n print(\"LD\")\n for _ in range(abs(i - j)):\n print(\"L\")\n else :\n for _ in range(abs(i)):\n print(\"LD\")\n for _ in range(abs(i - j)):\n print(\"D\")\n"}, {"source_code": "row = {'a':0 ,'b':1 ,'c':2 ,'d':3 ,'e':4 ,'f':5 ,'g':6 ,'h':7}\ncolumn = list(i for i in range(8))\n\ninit = str(input())\n\ninit_x = row[init[0]]\ninit_y = int(init[1]) - 1\n\nend = str(input())\n\nend_x = row[end[0]]\nend_y = int(end[1])\n\nmoves = list()\n\nwhile (True):\n flag_x = 0\n flag_y = 0\n res = \"\"\n if (init_x < end_x):\n init_x = init_x + 1\n res = res + \"R\"\n if (init_x > end_x):\n init_x = init_x - 1\n res = res + \"L\"\n if (init_x == end_x):\n flag_x = 1\n if (init_y < end_y):\n init_y = init_y + 1\n res = res + \"U\"\n if (init_y > end_y):\n init_y = init_y - 1\n res = res + \"D\"\n if (init_y == end_y):\n flag_y = 1\n moves.append(res)\n if( flag_x == 1 & flag_y == 1):\n break\n\nprint(len(moves))\nfor i in moves:\n print(i)\n\n"}, {"source_code": "s = str(input())\nt = str(input())\n\n\n\ndef calculateMoves(s,t):\n # Input parsing\n cols = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n sx = cols[s[0]]\n sy = int(s[1])\n tx = cols[t[0]]\n ty = int(t[1])\n\n # Calculating moves\n moves = []\n while True:\n xflag = 0\n yflag = 0\n xmove = ''\n ymove = ''\n move = ''\n if sx != tx:\n xflag = 1\n if sx < tx:\n xmove = 'D'\n sx = sx + 1\n else:\n xmove = 'U'\n sx = sx - 1\n if sy != ty:\n yflag = 1\n if sy < ty:\n ymove = 'L'\n sy = sy + 1\n else:\n ymove = 'R'\n sy = sy - 1\n if yflag: move = move + ymove\n if xflag: move = move + xmove\n if (not xflag and not yflag):\n break\n else:\n moves.append(move)\n\n # Output Parsing\n print(len(moves))\n for i in moves:\n print(i)\n return\n\n\n\ncalculateMoves(s,t)\n"}, {"source_code": "starting = list(input().lower())\nend_up = list(input())\nprint(starting)\nstring_output = []\ncount = 0\nletter_dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}\n\nstarting[1] = int(starting[1])\nend_up[1] = int(end_up[1])\nstarting[0] = letter_dict[starting[0]]\nend_up[0] = letter_dict[end_up[0]]\n\nwhile starting[0] != end_up[0] or starting[1] != end_up[1]:\n if starting[0] > end_up[0]:\n starting[0] -= 1\n if starting[1] > end_up[1]:\n starting[1] -= 1\n string_output.append('LD')\n else:\n starting[1] += 1\n string_output.append('LU')\n else:\n starting[0] += 1\n if starting[1] > end_up[1]:\n starting[1] -= 1\n string_output.append('RD')\n else:\n starting[1] += 1\n string_output.append('RU')\n count += 1\n\nwhile starting[0] != end_up[0] or starting[1] != end_up[1]:\n if starting[1] == end_up[1]:\n if starting[0] > end_up[0]:\n starting[0] -= 1\n string_output.append('L')\n\n else:\n starting[0] += 1\n string_output.append('R')\n\n else:\n if starting[1] > end_up[1]:\n starting[1] -= 1\n string_output.append('D')\n else:\n starting[1] += 1\n string_output.append('U')\n\n count += 1\n\nprint(count)\nfor i in string_output:\n print(i)\n"}, {"source_code": "chess={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\ns=list(raw_input().strip())\nt=list(raw_input().strip())\ns[0],s[1]=chess[s[0]],int(s[1])\nt[0],t[1]=chess[t[0]],int(t[1])\ncount,ans,=0,[]\nwhile s[0]!=t[0] and s[1]!=t[1]:\n\tif s[0]>t[0] and s[1]>t[1]:\n\t\tans.append('LD')\n\t\ts[0],s[1]=s[0]-1,s[1]-1\n\telif s[0]>t[0] and s[1]<t[1]:\n\t\tans.append('LU')\n\t\ts[0],s[1]=s[0]-1,s[1]+1\n\telif s[0]<t[0] and s[1]>t[1]:\n\t\tans.append('RD')\n\t\ts[0],s[1]=s[0]+1,s[1]-1\t\n\telse:\n\t\tans.append('RU')\n\t\ts[0],s[1]=s[0]+1,s[1]+1\n\tcount+=1\nwhile s[0]!=t[0]:\n\tif s[0]>t[0]:\n\t\tans.append('L')\n\t\ts[0]-=1\t\n\telse:\n\t\tans.append('R')\n\t\ts[0]+=1\n\tcount+=1\nwhile s[1]!=t[1]:\n\tif s[1]>t[1]:\n\t\tans.append('D')\n\t\ts[1]-=1\n\telse:\n\t\tans.append('R')\n\t\ts[1]+=1\n\tcount+=1\nprint count\nfor i in xrange(count):\n\tprint ans[i]"}, {"source_code": "a=input()\nb=input()\nA,B=[],[]\ndict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\nfor x in a:\n A.append(x)\nfor x in b:\n B.append(x)\nA[0],B[0]=int(dict[A[0]]),int(dict[B[0]])\nA[1],B[1]=int(A[1]),int(B[1])\nC=[]\nwhile A[0]!=B[0]: \n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]-1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]-1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nprint(len(C))\nwhile C!=[]:\n print(C[0])\n C.pop(0)"}, {"source_code": "a = input()\nb = input()\n\ns = [ord(a[0])-ord('a')+1, int(a[1])]\nt = [ord(b[0])-ord('a')+1, int(b[1])]\n \nd = min(abs(s[0]-t[0]), abs(s[1]-t[1]))\n\ndans = ''\nif s[0] < t[0]:\n dans += 'R'\n s[0] += d\nelif s[0] > t[0]:\n dans += 'L'\n s[0] -= d\nif s[1] < t[1]:\n dans += 'U'\n s[1] += d\nelif s[1] > t[1]:\n dans += 'D'\n s[1] -= d\n\nfor _ in range(0, d):\n print(dans)\n \nif s[0] < t[0]:\n d = t[0]-s[0]\n for i in range(0, d):\n print('L')\nelif s[0] > t[0]:\n d = s[0]-t[0]\n for i in range(0, d):\n print('R')\nelif s[1] < t[1]:\n d = t[1]-s[1]\n for i in range(0, d):\n print('U')\nelif s[1] > t[1]:\n d = s[1]-t[1]\n for i in range(0, d):\n print('D')"}, {"source_code": "import time\n\ndef calculateCoords(c):\n return (8 - int(c[1]), ord(c[0]) - 97) \n\ndef run():\n start = calculateCoords(input())\n end = calculateCoords(input())\n \n seen = [[False for x in range(8)] for y in range(8)]\n seen[start[0]][start[1]] = True\n toCheck = []\n toCheck.append((start, [])) \n\n while True:\n temp = []\n for (position, l) in toCheck:\n r = position[0]\n c = position[1]\n if r == end[0] and c == end[1]:\n print(len(l))\n for ch in l:\n print(ch)\n return\n if r > 0:\n if c > 0 and not seen[r - 1][c - 1]:\n newl1 = [x for x in l]\n newl1.append(\"LU\")\n temp.append(((r - 1, c - 1), newl1))\n if c < 7 and not seen[r - 1][c + 1]:\n newl2 = [x for x in l]\n newl2.append(\"RU\")\n temp.append(((r - 1, c + 1), newl2))\n newl3 = [x for x in l]\n newl3.append(\"U\")\n temp.append(((r - 1, c), newl3))\n if r < 7:\n if c > 0 and not seen[r + 1][c - 1]:\n newl4 = [x for x in l]\n newl4.append(\"LD\")\n temp.append(((r + 1, c - 1), newl4))\n if c < 7 and not seen[r + 1][c + 1]:\n newl5 = [x for x in l]\n newl5.append(\"RD\")\n temp.append(((r + 1, c + 1), newl5))\n newl6 = [x for x in l]\n newl6.append(\"U\")\n temp.append(((r + 1, c), newl6))\n if c > 0:\n newl7 = [x for x in l]\n newl7.append(\"L\")\n temp.append(((r, c - 1), newl7))\n if c < 7:\n newl8 = [x for x in l]\n newl8.append(\"R\")\n temp.append(((r, c + 1), newl8))\n toCheck = []\n toCheck.extend(temp)\n\nrun()"}, {"source_code": "dict={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n\n\nc=list(input())\nd=list(input())\nc[0]=dict[c[0]]\nd[0]=dict[d[0]]\nc[1]=int(c[1])\nd[1]=int(d[1])\nhor=[]\nif c[0]>=d[0]:\n hor.extend(list(\"L\"*(c[0]-d[0])))\nelse:\n hor.extend(list(\"R\"*abs(c[0]-d[0])))\n\n\nver=[]\nif c[1]>=d[1]:\n ver.extend(list(\"D\"*(c[1]-d[1])))\nelse:\n ver.extend(list(\"U\"*abs(c[1]-d[1])))\n\n#print(hor,ver)\nfor i in range(min(len(ver),len(hor))):\n print(hor[i],end='')\n print(ver[i])\nif len(ver)>=len(hor):\n print('\\n'.join(ver[(len(ver)-len(hor)-1):]))\nelse:\n print('\\n'.join(hor[abs(len(ver)-len(hor)-1):]))\n \n"}, {"source_code": "s = str(input())\nt = str(input())\n\n\n\ndef calculateMoves(s,t):\n # Input parsing\n cols = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n sx = cols[s[0]]\n sy = int(s[1])\n tx = cols[t[0]]\n ty = int(t[1])\n\n # Calculating moves\n moves = []\n while True:\n xflag = 0\n yflag = 0\n xmove = ''\n ymove = ''\n move = ''\n if sx != tx:\n xflag = 1\n if sx < tx:\n xmove = 'R'\n sx = sx + 1\n else:\n xmove = 'L'\n sx = sx - 1\n if sy != ty:\n yflag = 1\n if sy < ty:\n ymove = 'U'\n sy = sy + 1\n else:\n ymove = 'D'\n sy = sy - 1\n if yflag: move = move + ymove\n if xflag: move = move + xmove\n if (not xflag and not yflag):\n break\n else:\n moves.append(move)\n\n # Output Parsing\n print(len(moves))\n for i in moves:\n print(i)\n return\n\n\n\ncalculateMoves(s,t)\n"}, {"source_code": "x0y0=input()\nxy=input()\nx0y0=[ord(x0y0[0])-ord('a')+1,int(x0y0[1])]\nxy=[ord(xy[0])-ord('a')+1,int(xy[1])]\nn=max(abs(x0y0[0]-xy[0]),abs(x0y0[1]-xy[1]))\nprint(abs(n))\nfor i in range(0,n):\n if xy[0]==x0y0[0] and xy[1]==x0y0[1]:\n print('OK')\n if xy[0]>x0y0[0] and xy[1]>x0y0[1]:\n print('RU')\n x0y0[0]+=1\n x0y0[1]+=1\n if xy[0]<x0y0[0] and xy[1]<x0y0[1]:\n print('LD')\n x0y0[0]-=1\n x0y0[1]-=1\n if xy[0]<x0y0[0] and xy[1]>x0y0[1]:\n print('LU')\n x0y0[0]-=1\n x0y0[1]+=1\n if xy[0]>x0y0[0] and xy[1]<x0y0[1]:\n print('RD')\n x0y0[0]+=1\n x0y0[1]-=1\n if xy[0]>x0y0[0] and xy[1]==x0y0[1]:\n print('R')\n x0y0[0]+=1\n if xy[0]<x0y0[0] and xy[1]==x0y0[1]:\n print('L')\n x0y0[0]-=1\n if xy[1]>x0y0[1] and xy[0]==x0y0[0]:\n print('U')\n x0y0[1]+=1\n if xy[1]<x0y0[1] and xy[0]==x0y0[0]:\n print('D')\n x0y0[1]-=1\n\n \n \n"}, {"source_code": "def dig(s):return [ord(s[0])-96,int(s[1])]\na,b=dig(input())\nc,d=dig(input())\nl=max(abs(a-c),abs(b-d))\nprint(l)\ne=['']*l\nfor i in range(abs(b-d)):\n if b>d:e[i]='L'\n else:e[i]='R'\nfor i in range(abs(a-c)):\n if a>c:e[i]=e[i]+'D'\n else:e[i]=e[i]+'U'\nprint('\\n'.join(e))\n"}, {"source_code": "bla=\"abcdefgh\"\nb1=raw_input()\nb2=raw_input()\nx1=bla.index(b1[0])\nx2=bla.index(b2[0])\ny1=int(b1[1])\ny2=int(b2[1])\n\nspacesup=y2-y1\nspacesright=x2-x1\n\nwhile spacesup!=0 and spacesright!=0:\n if spacesup>0 and spacesright>0:\n print \"RU\"\n spacesup-=1\n spacesright-=1\n if spacesup<0 and spacesright>0:\n print \"RD\"\n spacesup+=1\n spacesright-=1\n if spacesup>0 and spacesright<0:\n print \"LU\"\n spacesup-=1\n spacesright+=1\n if spacesup<0 and spacesright<0:\n print \"LD\"\n spacesup+=1\n spacesright+=1\n\nif spacesup!=0:\n if spacesup>0:\n for i in range(spacesup):\n print \"D\"\n else:\n for i in range(-spacesup):\n print \"U\"\nif spacesright!=0:\n if spacesright>0:\n for i in range(spacesright):\n print \"L\"\n else:\n for i in range(-spacesright):\n print \"R\""}, {"source_code": "'''input\na5\na5\n'''\na, b = input(), input()\nd = {\"a\":1, \"b\":2, \"c\":3, \"d\":4, \"e\":5, \"f\":6, \"g\":7, \"h\":8}\na = str(d[a[0]]) + a[1]\nb = str(d[b[0]]) + b[1]\nr, u = int(b[0]) - int(a[0]), int(b[1]) - int(b[1])\nm = max(abs(r), abs(u))\nprint(m)\nfor _ in range(m):\n\tif r > 0:\n\t\tprint(\"R\", end = \"\")\n\telif r < 0:\n\t\tprint(\"L\", end = \"\")\n\tif u > 0:\n\t\tprint(\"U\", end = \"\")\n\telif u < 0:\n\t\tprint(\"D\", end = \"\")\n\tprint()\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "s = raw_input()\nt = raw_input()\nstart = [ord(s[0])-96 ,int(s[1])]\nterminal = [ord(t[0])-96 ,int(t[1])]\nprint start\nprint terminal\nroute = []\nwhile start != terminal:\n if terminal[0]>start[0] and terminal[1]>start[1]:\n route.append('RU')\n start[0]+= 1\n start[1]+= 1\n elif terminal[0]>start[0] and terminal[1]<start[1]:\n route.append('RD')\n start[0]+= 1\n start[1]-= 1\n elif terminal[0]<start[0] and terminal[1]>start[1]:\n route.append('LU')\n start[0]-= 1\n start[1]+= 1\n elif terminal[0]<start[0] and terminal[1]<start[1]:\n route.append('LD')\n start[0]-= 1\n start[1]-= 1\n elif terminal[0]>start[0]:\n route.append('R')\n start[0]+= 1\n elif terminal[0]<start[0]:\n route.append('L')\n start[0]-= 1\n elif terminal[1]>start[1]:\n route.append('U')\n start[1]+= 1\n elif terminal[1]<start[1]:\n route.append('D')\n start[1]-= 1\n print start\n print terminal\nprint len(route)\nfor item in route:\n print item"}, {"source_code": "dict={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n\n\nc=list(input())\nd=list(input())\nc[0]=dict[c[0]]\nd[0]=dict[d[0]]\nc[1]=int(c[1])\nd[1]=int(d[1])\nhor=[]\nif c[0]>=d[0]:\n hor.extend(list(\"L\"*(c[0]-d[0])))\nelse:\n hor.extend(list(\"R\"*abs(c[0]-d[0])))\n\n\nver=[]\nif c[1]>=d[1]:\n ver.extend(list(\"D\"*(c[1]-d[1])))\nelse:\n ver.extend(list(\"U\"*abs(c[1]-d[1])))\n\n#print(hor,ver)\nfor i in range(min(len(ver),len(hor))):\n print(hor[i],end='')\n print(ver[i])\nif len(ver)>len(hor):\n print('\\n'.join(ver[(len(ver)-len(hor)-1):]))\nelif len(ver)<len(hor):\n print('\\n'.join(hor[abs(len(ver)-len(hor)-1):]))\n \n"}, {"source_code": "from __future__ import print_function\ndef main():\n s = raw_input()\n d = raw_input()\n\n left_2_right = ord(d[0]) - ord(s[0])\n top_2_bottom = int(s[1]) - int(d[1])\n\n if left_2_right > 0:\n step = 'R'\n elif left_2_right < 0:\n step = 'L'\n else:\n step = ''\n\n if top_2_bottom > 0:\n step_next = 'D'\n elif top_2_bottom < 0:\n step_next = 'U'\n else:\n step = ''\n\n max_iter = max( left_2_right, top_2_bottom )\n print(max_iter)\n for itr in xrange(1, max_iter + 1):\n if itr <= left_2_right:\n print(step,end='')\n if itr <= top_2_bottom:\n print(step_next)\n \n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "__author__ = 'Ragnar'\nimport string\nfirst_position = str(input())\nsecond_position = str(input())\nletter_list = list(string.ascii_lowercase[0:8])\nnumber_list = list(range(1, 9))\nd = dict(zip(letter_list, number_list))\nt1 = d[first_position[0]]\nt2 = d[second_position[0]]\nposition_list = [(t1, int(first_position[1])), (t2, int(second_position[1]))]\ntt_1 = position_list[0][1]\nh_1_1 = abs(position_list[0][0]-position_list[1][0])\nh_1_2 = abs(position_list[0][1]-position_list[1][1])\nh_1 = min(h_1_1, h_1_2)\nh_2 = max(h_1_1, h_1_2) - min(h_1_1, h_1_2)\nh = h_1 + h_2\nprint (h)\n\ndelta = 0\nfor i in range(h_1):\n if (t1 < t2) and (int(first_position[1]) < int(second_position[1])):\n print ('RU')\n delta += 1\n if (t1 < t2) and (int(first_position[1]) > int(second_position[1])):\n print ('RD')\n delta += 1\n if (t1 > t2) and (int(first_position[1]) < int(second_position[1])):\n print ('LU')\n delta -= 1\n if (t1 > t2) and (int(first_position[1]) > int(second_position[1])):\n print ('LD')\n delta -= 1\n\nif h_1_1 < h_1_2:\n t1 = t1 + delta\nif h_1_2 < h_1_1:\n tt_1 = tt_1 + delta\n\nfor j in range(h_2):\n if t1 == t2 and int(first_position[1]) < int(second_position[1]):\n print ('U')\n if t1 == t2 and int(first_position[1]) > int(second_position[1]):\n print ('D')\n if tt_1 == int(second_position[1]) and d[first_position[0]] < d[second_position[0]]:\n print ('R')\n if tt_1 == int(second_position[1]) and d[first_position[0]] > d[second_position[0]]:\n print ('L')"}, {"source_code": "import sys\ndef main():\n s = sys.stdin.readline()\n t = sys.stdin.readline()\n j0 = ord(s[1]) - ord('1')\n i0 = ord(s[0]) - ord('a')\n j1 = ord(t[1]) - ord('1')\n i1 = ord(t[0]) - ord('a')\n j1 = 8 - j1\n j0 = 8 - j0\n m = {\n (-1, -1) : \"LU\",\n (-1, 0) : \"U\",\n (-1, +1) : \"RU\",\n (+1, -1) : \"LD\",\n (+1, 0) : \"D\",\n (+1, +1) : \"RD\",\n ( 0, -1) : \"L\",\n ( 0, +1) : \"R\"\n }\n ans = max(abs(j0 - j1), abs(i0 - i1))\n print ans\n while i0 != i1 or j0 != j1:\n di = i1 - i0\n dj = j1 - j0\n if di != 0:\n di = di / abs(di)\n if dj != 0:\n dj = dj / abs(dj)\n i0 = i0 + di\n j0 = j0 + dj\n #print i0, j0\n print m[(di, dj)]\n \n \nmain()\n"}, {"source_code": "def main():\n\ts = input()\n\tt = input()\n\tsolver(s, t)\n\ndef solver(s, t):\n\tls = ord(s[0])\n\tlt = ord(t[0])\n\tns = int(s[1])\n\tnt = int(t[1])\n\tn = max(abs(lt - ls), abs(nt - ns))\n\t#print(ls, lt, ns, nt)\n\twhile ls != lt or ns != nt:\n\t\tout = \"\"\n\t\tif ls < lt:\n\t\t\tout += \"R\"\n\t\t\tls += 1\n\t\telif ls > lt:\n\t\t\tout += \"L\"\n\t\t\tls -= 1\n\t\tif ns < nt:\n\t\t\tout += \"U\"\n\t\t\tns += 1\n\t\telif ns > nt:\n\t\t\tout += \"D\"\n\t\t\tns -= 1\n\t\tprint(out)\n\n\n"}, {"source_code": "a=input()\nb=input()\nA,B=[],[]\ndict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\nfor x in a:\n A.append(x)\nfor x in b:\n B.append(x)\nA[0],B[0]=int(dict[A[0]]),int(dict[B[0]])\nA[1],B[1]=int(A[1]),int(B[1])\nC=[]\nwhile A[0]!=B[0]: \n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]-1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1*1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]<B[0]:\n if A[1]<B[1]:\n C.append('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n C.append('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n C.append('L')\n A[0]=A[0]-1\n else:\n if A[1]<B[1]:\n C.append('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n C.append('D')\n A[1]=A[1]-1\nprint(len(C))\nwhile C!=[]:\n print(C[0])\n C.pop(0)"}, {"source_code": "\ndef shortestPath():\n kingPosition = input()\n destination = input()\n boardSize = 8\n chessBoard = [[-1 for x in range(boardSize)] for y in range(boardSize)]\n kingRow = int(kingPosition[1])-1\n kingColumn = ord(kingPosition[0])-ord('a')\n chessBoard[kingRow][kingColumn] = 0\n chessBoard[int(destination[1])-1][ord(destination[0])-ord('a')] = -2\n newNeighbors = []\n fillChessBoard(kingRow,kingColumn,chessBoard,newNeighbors)\n while len(newNeighbors) > 0:\n fillChessBoard(newNeighbors[0][0], newNeighbors[0][1],chessBoard,newNeighbors)\n newNeighbors.remove(newNeighbors[0])\n\n path=[[int(destination[1])-1,ord(destination[0])-ord('a')] ]\n path.append(findSmallestNeighbor([int(destination[1])-1,ord(destination[0])-ord('a')],chessBoard))\n while chessBoard[path[len(path)-1][0]][path[len(path)-1][1]] != 0:\n path.append(findSmallestNeighbor(path[len(path)-1],chessBoard))\n allNeighbors = [[1,1],[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1],[0,1]]\n i = len(path)-1\n\n print(len(path)-1)\n while i >= 0:\n for neighbor in allNeighbors:\n if path[i][0] + neighbor[0] == path[i-1][0] and path[i][1] + neighbor[1] == path[i-1][1]:\n if neighbor == [1,1]:\n print('RU')\n elif neighbor == [1,0]:\n print('U')\n elif neighbor == [1,-1]:\n print('LU')\n elif neighbor == [0,-1]:\n print('L')\n elif neighbor == [-1,-1]:\n print('LD')\n elif neighbor == [-1,0]:\n print('D')\n elif neighbor == [-1,1]:\n print('RD')\n elif neighbor == [0,1]:\n print('R')\n\n i -= 1\n\n\n\n\ndef fillChessBoard(startRow, startColumn, chessBoard, newNeighbors):\n allNeighbors = [[1,1],[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1],[0,1]]\n for neighbor in allNeighbors:\n\n if startRow + neighbor[0] < len(chessBoard) and startColumn + neighbor[1] < len(chessBoard) and startRow + neighbor[0] >= 0 and startColumn + neighbor[1] >= 0 and chessBoard[startRow + neighbor[0]][startColumn + neighbor[1]] == -1:\n chessBoard[startRow + neighbor[0]][startColumn + neighbor[1]] = chessBoard[startRow][startColumn] + 1\n newNeighbors.append([startRow + neighbor[0],startColumn + neighbor[1]])\n\ndef findSmallestNeighbor(current,chessBoard):\n allNeighbors = [[1,1],[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1],[0,1]]\n minValue = 8\n \n for neighbor in allNeighbors:\n if current[0] + neighbor[0] < len(chessBoard) and current[1] + neighbor[1] < len(chessBoard) and current[0] + neighbor[0] >= 0 and current[1] + neighbor[1] >= 0 and chessBoard[current[0]+neighbor[0]][current[1]+neighbor[1]] < minValue and chessBoard[current[0]+neighbor[0]][current[1]+neighbor[1]] != -2:\n minValue = chessBoard[current[0]+neighbor[0]][current[1]+neighbor[1]] \n minNeighbor = [current[0]+neighbor[0],current[1]+neighbor[1]]\n return minNeighbor\n\nshortestPath()"}, {"source_code": "import string\n\nstart_location = raw_input()\nend_location = raw_input()\n\nletterdict=dict()\nlowercase=string.ascii_lowercase\n\nfor i in xrange(8):\n letterdict[lowercase[i]]=i\n\nstart_lr = letterdict[start_location[0]]\nstart_ud = int(start_location[1])\nend_lr = letterdict[end_location[0]]\nend_ud = int(end_location[1])\n\nvx = end_lr-start_lr\nvy = end_ud-start_ud \nnumberofsteps = max(abs(vx),abs(vy))\ndiagonaldistance = min(abs(vx),abs(vy))\nboringdistance = numberofsteps-diagonaldistance\nprint numberofsteps\n\n\nif vx >= 0 and vy >=0:\n quadrant = \"RU\"\nelif vx <=0 and vy >=0:\n quadrant = \"LU\"\nelif vx <=0 and vy <=0:\n quadrant = \"LD\"\nelse:\n quadrant = \"RD\"\nfor i in xrange(diagonaldistance):\n print quadrant\nif vy>=vx:\n for i in xrange(boringdistance):\n print quadrant[1]\nelse:\n for i in xrange(boringdistance):\n print quadrant[0]\n\n\n\n\n"}, {"source_code": "#!/usr/bin/python\nsrc = raw_input()\ndst = raw_input()\n\nmyD = { 'a': 1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8 }\n\nsrc_c = myD[src[0]]\nsrc_r = int(src[1])\ndst_c = myD[dst[0]]\ndst_r = int(dst[1])\n\n#print src_r, src_c, dst_r, dst_c \nmove_cnt = 0 \nmoves = \"\"\n\nwhile (src_r != dst_r and src_c != dst_c):\n move_cnt += 1\n\n if(src_r < dst_r and src_c < dst_c):\n src_r += 1; src_c += 1; moves += \"RU\\n\"\n\n elif(src_r > dst_r and src_c > dst_c):\n src_r -= 1; src_c -= 1; moves += \"LD\\n\"\n \n elif(src_r > dst_r and src_c < dst_c):\n src_r -= 1; src_c += 1; moves += \"RD\\n\"\n\n elif(src_r < dst_r and src_c > dst_c):\n src_r += 1; src_c -= 1; moves += \"LU\\n\"\n\n elif(src_r == dst_r and src_c > dst_c):\n src_c -= 1; moves += \"L\\n\"\n\n elif(src_r == dst_r and src_c < dst_c):\n src_c += 1; moves += \"R\\n\"\n \n elif(src_r > dst_r and src_c == dst_c):\n src_r -= 1; moves += \"D\\n\"\n\n elif(src_r < dst_r and src_c == dst_c):\n src_r += 1; moves += \"U\\n\"\n\nmoves = moves.strip('\\n')\nprint move_cnt\nprint moves\n"}, {"source_code": "raw = (raw_input(),\n raw_input())\n((x1,y1),(x2,y2)) = ((int(ord(raw[0][0])-ord('a'))+1,int(raw[0][1])),\n (int(ord(raw[1][0])-ord('a'))+1,int(raw[1][1])))\nmap = [[max(abs(i-x1),abs(j-y1)) for i in range(10)] for j in range(10)]\nprint map[y2][x2]\npath = []\nwhile map[y2][x2]:\n if map[y2][x2-1] < map[y2][x2]:\n x2 -= 1\n path.append('R')\n elif map[y2][x2+1] < map[y2][x2]:\n x2 += 1\n path.append('L')\n if map[y2-1][x2] < map[y2][x2]:\n y2 -= 1\n path.append('U')\n elif map[y2+1][x2] < map[y2][x2]:\n y2 += 1\n path.append('D')\n if map[y2-1][x2-1] < map[y2][x2]:\n x2 -= 1\n y2 -= 1\n path.append('RU')\n elif map[y2+1][x2+1] < map[y2][x2]:\n x2 += 1\n y2 += 1\n path.append('LU')\n if map[y2-1][x2+1] < map[y2][x2]:\n x2 += 1\n y2 -= 1\n path.append('LD')\n else:\n x2 -= 1\n y2 += 1\n path.append('RD')\npath.reverse()\nfor i in path:\n print i\n\n"}, {"source_code": "a = raw_input()\nb = raw_input()\nn = ord('a') - 1\na = [ord(a[0]) - n, int(a[1])]\nb = [ord(b[0]) - n, int(b[1])]\nmoves = ''\ntotal = 0\nwhile not a == b:\n if a[0] < b[0]:\n if a[1] < b[1]:\n total += 1\n moves += 'RU\\n'\n a[0] += 1\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'RD\\n'\n a[0] += 1\n a[1] -= 1\n else:\n total += 1\n moves += 'R'\n a[0] += 1\n elif a[0] > b[0]:\n if a[1] < b[1]:\n total += 1\n moves += 'LU\\n'\n a[0] -= 1\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'LD\\n'\n a[0] -= 1\n a[1] -= 1\n else:\n total += 1\n moves += 'l'\n a[0] -= 1\n else:\n if a[1] < b[1]:\n total += 1\n moves += 'U\\n'\n a[1] += 1\n elif a[1] > b[1]:\n total += 1\n moves += 'D\\n'\n a[1] -= 1\nprint total\nprint moves"}, {"source_code": "a=input()\nb=input()\nA,B=[],[]\ndict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\nfor x in a:\n A.append(x)\nfor x in b:\n B.append(x)\nA[0],B[0]=int(dict[A[0]]),int(dict[B[0]])\nA[1],B[1]=int(A[1]),int(B[1])\nwhile A[0]!=B[0]:\n while A[1]!=B[1]:\n if A[0]<B[0]:\n if A[1]<B[1]:\n print('RU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n print('RD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n print('R')\n A[0]=A[0]+1\n elif A[0]>B[0]:\n if A[1]<B[1]:\n print('LU')\n A[0]=A[0]+1\n A[1]=A[1]+1\n elif A[1]>B[1]:\n print('LD')\n A[0]=A[0]+1\n A[1]=A[1]-1\n elif A[1]==B[1]:\n print('L')\n A[0]=A[0]+1\n else:\n if A[1]<B[1]:\n print('U')\n A[1]=A[1]+1\n elif A[1]>B[1]:\n print('D')\n A[1]=A[1]-1\n"}, {"source_code": "letter = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7}\nnumber = {'1':0, '2':1, '3':2, '4':3, '5':4, '6':5, '7':6, '8':7}\nplay = {'L':(0, -1), 'R':(0, 1), 'U':(1, 0), 'D':(0, -1), 'LU':(1, -1), 'LD':(-1, -1), 'RU':(1, 1), 'RD':(-1, 1)}\nprnt = {(0, -1):'L', (0, 1):'R', (1, 0):'U', (0, -1):'D', (1, -1):'LU', (-1, -1):'LD', (1, 1):'RU', (-1, 1):'RD'}\n\ns = raw_input()\nposini = letter[s[0]], number[s[1]]\ns = raw_input()\nposfim = letter[s[0]], number[s[1]]\n\nto_run = posini[0] - posfim[0], posini[1] - posfim[1]\n\nif to_run[0] > 0 and to_run[1] > 0:\n if to_run[0] > to_run[1]:\n for i in range(to_run[1]):\n print prnt[1, 1]\n to_run = to_run[0] - to_run[1], 0\n else:\n for i in range(to_run[0]):\n print prnt[1, 1]\n to_run = 0, to_run[1] - to_run[0]\nelif to_run[0] > 0 and to_run[1] < 0:\n if to_run[0] > -to_run[1]:\n for i in range(-to_run[1]):\n print prnt[1, -1]\n to_run = to_run[0] + to_run[1], 0\n else:\n for i in range(to_run[0]):\n print prnt[1, -1]\n to_run = 0, to_run[0] + to_run[1]\nelif to_run[0] < 0 and to_run[1] > 0:\n if -to_run[0] > to_run[1]:\n for i in range(to_run[1]):\n print prnt[-1, 1]\n to_run = to_run[0] + to_run[1], 0\n else:\n for i in range(-to_run[0]):\n print prnt[-1, 1]\n to_run = 0, to_run[0] + to_run[1]\nelif to_run[0] < 0 and to_run[1] < 0:\n if -to_run[0] > -to_run[1]:\n for i in range(-to_run[1]):\n print prnt[-1, -1]\n to_run = to_run[0] - to_run[1], 0\n else:\n for i in range(-to_run[0]):\n print prnt[-1, -1]\n to_run = 0, to_run[0] - to_run[1]\n\nif to_run[0] == 0 and to_run[1] > 0:\n for i in range(to_run[1]):\n print prnt[0, 1]\nelif to_run[0] == 0 and to_run[1] < 0:\n for i in range(-to_run[1]):\n print prnt[0, -1]\nelif to_run[0] > 0 and to_run[1] == 0:\n for i in range(to_run[0]):\n print prnt[1, 0]\nelif to_run[0] < 0 and to_run[1] == 0:\n for i in range(-to_run[0]):\n print prnt[-1, 0]"}, {"source_code": "from collections import deque\n\ndirections = {\n 'D': (1, 0),\n 'U': (1, 0),\n 'R': (0, 1),\n 'L': (0, -1),\n 'RD': (1, 1),\n 'RU': (-1, 1),\n 'LD': (1, -1),\n 'LU': (-1, -1)\n}\n\ndef code(i, j):\n return i * 8 + j\n\ndef decode(x):\n return (x // 8, x % 8)\n\ndef code_input():\n coord = input();\n i = ord(coord[0]) - ord('a')\n j = 8 - int(coord[1])\n return code(i, j)\n\ndef move(x, d):\n (i, j) = decode(x)\n (di, dj) = directions[d]\n i += di\n j += dj\n if i >= 0 and i < 8 and j >= 0 and j < 8:\n return code(i,j)\n else:\n return -1\n\ns = code_input()\nt = code_input();\n\nq = deque([])\nq.append(s)\nvisited = set([s])\nlast_dir = {}\nprev_field = {}\ndist = {s: 0}\n\nwhile len(q) > 0 and t not in visited:\n field = q.popleft()\n for d in directions:\n neighbor = move(field, d)\n if neighbor != -1 and neighbor not in visited:\n visited.add(neighbor)\n q.append(neighbor)\n dist[neighbor] = dist[field] + 1\n last_dir[neighbor] = d\n prev_field[neighbor] = field\nprint(dist[t])\n\nfield = t\npath = deque([])\nwhile field in prev_field:\n path.appendleft(last_dir[field])\n field = prev_field[field]\nfor mv in path:\n print(mv)"}, {"source_code": "#!/usr/bin/python\ns1= raw_input()\ns2 =raw_input()\n\n#if ord(s2[0])-ord(s1[0])<0 :\n# print 'ss',ord(s2[0])-ord(s1[0])\nif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1])<0 :\n ss = 'LD'\nelif ord(s2[0])-ord(s1[0])>0 and ord(s2[1])-ord(s1[1]) <0 :\n ss='RD'\nelif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1]) >0 :\n ss='LU'\nelse:\n ss='RU'\n\nif ord(s2[0])-ord(s1[0])<0:\n ss1 = 'U'\nelse :\n ss1 = 'D'\n\nif ord(s2[1])-ord(s1[1])<0:\n ss2 = 'R'\nelse :\n ss2 = 'L'\n\n\nbig = abs(ord(s2[0])-ord(s1[0]))\nsmall = abs(ord(s2[1])-ord(s1[1]))\n\nif big < small :\n temp =big;\n big=small;\n small=temp;\n ss1=ss2;\n \nprint big\n\n\nfor i in range (0,small):\n print ss\n\nfor i in range (0,big-small):\n print ss1\n"}, {"source_code": "a = list(input())\nb = list(input())\nx1 = a[0]\ny1 = a[1]\nx2 = b[0]\ny2 = b[1]\n(x1, y1, x2, y2) = map(ord, (x1, y1, x2, y2))\n\nd = max(abs(x1 - x2), abs(y1 - y2))\ne = min(abs(x1 - x2), abs(y1 - y2))\nprint(d)\n\nmx = ''\nmy = ''\nif x1 < x2:\n mx = 'R'\nelse:\n mx = 'L'\nif y1 < y2:\n my = 'U'\nelse:\n my = 'D'\nfor i in range(0, e):\n print(mx + my)\np = mx\nif abs(x1 - y1) < abs(x2 - y2):\n p = my\nfor i in range(0, d - e):\n print(p)\n\n"}, {"source_code": "from collections import deque\n\ndirections = {\n 'D': (1, 0),\n 'U': (1, 0),\n 'R': (0, 1),\n 'L': (0, -1),\n 'RD': (1, 1),\n 'RU': (-1, 1),\n 'LD': (1, -1),\n 'LU': (-1, -1)\n}\n\ndef code(i, j):\n return i * 8 + j\n\ndef decode(x):\n return (x // 8, x % 8)\n\ndef code_input():\n coord = input();\n j = ord(coord[0]) - ord('a')\n i = 8 - int(coord[1])\n return code(i, j)\n\ndef move(x, d):\n (i, j) = decode(x)\n (di, dj) = directions[d]\n i += di\n j += dj\n if i >= 0 and i < 8 and j >= 0 and j < 8:\n return code(i,j)\n else:\n return -1\n\ns = code_input()\nt = code_input();\n\nq = deque([])\nq.append(s)\nvisited = set([s])\nlast_dir = {}\nprev_field = {}\ndist = {s: 0}\n\nwhile len(q) > 0 and t not in visited:\n field = q.popleft()\n for d in directions:\n neighbor = move(field, d)\n if neighbor != -1 and neighbor not in visited:\n visited.add(neighbor)\n q.append(neighbor)\n dist[neighbor] = dist[field] + 1\n last_dir[neighbor] = d\n prev_field[neighbor] = field\nprint(dist[t])\n\nfield = t\npath = deque([])\nwhile field in prev_field:\n path.appendleft(last_dir[field])\n field = prev_field[field]\nfor mv in path:\n print(mv)"}, {"source_code": "line=['a','b','c','d','e','f','g','h']\na=str(input())\nb=str(input())\nx=line.index(list(a)[0])-line.index(list(b)[0])\ny=int(a[1])-int(b[1])\ni=0\nj=0\nk=0\nif abs(x)<abs(y):\n k=1\nprint(max(abs(x),abs(y)))\nwhile i<min(abs(x),abs(y)):\n if x>0 and y>0:\n print('LD')\n if x<0 and y>0:\n print('RD')\n if x>0 and y<0:\n print('LU')\n if x<0 and y<0:\n print('RU')\n i=i+1\nwhile j<abs(abs(x)-abs(y)):\n if k==1 and y<0:\n print('U')\n if k==1 and y>0:\n print('D')\n if k==0 and x<0:\n print('R')\n if k==1 and x>0:\n print('L')\n j=j+1 \n"}, {"source_code": "s = input()\nt = input()\n\nmoves = []\n\ndef move(x, y):\n\tif (x1 < x):\n\t\tif (y1 < y):\n\t\t\tmoves.append('LU')\n\t\t\tx -= 1\n\t\t\ty -= 1\n\t\t\treturn x, y, 2\n\t\telif (y1 == y):\n\t\t\tx -= 1\n\t\t\tmoves.append('L')\n\t\t\treturn x, y, 1\n\t\telif (y1 > y):\n\t\t\tx -= 1\n\t\t\ty += 1\n\t\t\tmoves.append('LD')\n\t\t\treturn x, y, 2\n\telif (x1 == x):\n\t\tif (y1 < y):\n\t\t\ty -= 1\n\t\t\tmoves.append('U')\n\t\t\treturn x, y, 1\n\t\telif (y1 == y):\n\t\t\treturn x, y, 0\n\t\telif (y1 > y):\n\t\t\ty += 1\n\t\t\tmoves.append('D')\n\t\t\treturn x, y, 1\n\telif (x1 > x):\n\t\tif (y1 < y):\n\t\t\tx += 1\n\t\t\ty -= 1\n\t\t\tmoves.append('RU')\n\t\t\treturn x, y, 2\n\t\telif (y1 == y):\n\t\t\tx += 1\n\t\t\tmoves.append('R')\n\t\t\treturn x, y, 1\n\t\telif (y1 > y):\n\t\t\tx += 1\n\t\t\ty += 1\n\t\t\tmoves.append('RD')\n\t\t\treturn x, y, 2\n\nrow_names = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n\nx0 = int(row_names.index(s[0]))\ny0 = 8 - int(s[1])\n\nx1 = int(row_names.index(t[0]))\ny1 = 8 - int(t[1])\n\nprice = x1 - x0 + y1 - y0\nn = 0\nx = x0\ny = y0\nwhile (price > 0):\n\tx, y, p = move(x, y);\n\tprice -= p\n\tn += 1\n\nprint (n)\nlist(map(print, moves))"}, {"source_code": "from collections import defaultdict\n\ns = raw_input()\nd = raw_input()\nchar_map = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n\nx1, y1 = int(char_map[s[0]]), int(s[1])\nx2, y2 = int(char_map[d[0]]), int(d[1])\n\ncount = 0\ndirections = list()\n\ndef distance(x1,y1,x2,y2):\n dist = (x1-x2)**2 + (y1-y2)**2\n return dist\n\ndef left(x1,y1,x2,y2):\n Lx,Ly = x1-1,y1\n L_dist = distance(Lx,Ly,x2,y2)\n return Lx,Ly,L_dist\n\ndef leftUp(x1,y1,x2,y2):\n LUx,LUy = x1-1,y1+1\n LU_dist = distance(LUx,LUy,x2,y2)\n return LUx,LUy,LU_dist\n\ndef up(x1,y1,x2,y2):\n Ux,Uy = x1,y1+1\n U_dist = distance(Ux,Uy,x2,y2)\n return Ux,Uy,U_dist\n\ndef rightUp(x1,y1,x2,y2):\n RUx,RUy = x1+1,y1+1\n RU_dist = distance(RUx,RUy,x2,y2)\n return RUx,RUy,RU_dist\n\ndef right(x1,y1,x2,y2):\n Rx,Ry = x1+1,y1\n R_dist = distance(Rx,Ry,x2,y2)\n return Rx,Ry,R_dist\n\ndef rightDown(x1,y1,x2,y2):\n RDx,RDy = x1+1,y1-1\n RD_dist = distance(RDx,RDy,x2,y2)\n return RDx,RDy,RD_dist\n\ndef down(x1,y1,x2,y2):\n Dx,Dy = x1,y1-1\n D_dist = distance(Dx,Dy,x2,y2)\n return Dx,Dy,D_dist\n\ndef leftDown(x1,y1,x2,y2):\n LDx,LDy = x1-1,y1-1\n LD_dist = distance(LDx,LDy,x2,y2)\n return LDx,LDy,LD_dist\n\nwhile True:\n if (x1 == 1 and (y1 > 1 and y1 < 8)):#left edge\n d = defaultdict()\n Ux,Uy,U_dist = up(x1,y1,x2,y2)\n d[\"U_dist\"] = U_dist\n\n Rx,Ry,R_dist = right(x1,y1,x2,y2)\n d[\"R_dist\"] = R_dist\n\n Dx,Dy,D_dist = down(x1,y1,x2,y2)\n d[\"D_dist\"] = D_dist\n\n RUx,RUy,RU_dist = rightUp(x1,y1,x2,y2)\n d[\"RU_dist\"] = RU_dist\n\n RDx,RDy,RD_dist = rightDown(x1,y2,x2,y2)\n d[\"RD_dist\"] = RD_dist\n\n min_dir = min(d, key=d.get)\n if min_dir == \"U_dist\":\n directions.append(\"U\")\n x1,y1 = Ux,Uy\n count += 1\n if min_dir == \"R_dist\":\n directions.append(\"R\")\n x1,y1 = Rx,Ry\n count += 1\n if min_dir == \"D_dist\":\n directions.append(\"D\")\n x1,y1 = Dx,Dy\n count += 1\n if min_dir == \"RU_dist\":\n directions.append(\"RU\")\n x1,y1 = RUx, RUy\n count += 1\n if min_dir == \"RD_dist\":\n directions.append(\"RD\")\n x1,y1 = RDx,RDy\n count += 1\n elif (x1 > 1 and x1 < 8) and y1 == 1: #bottom edge\n d = defaultdict()\n Lx,Ly,L_dist = left(x1,y1,x2,y2)\n d[\"L_dist\"] = L_dist\n\n LUx,LUy,LU_dist = leftUp(x1,y1,x2,y2)\n d[\"LU_dist\"] = LU_dist\n\n Ux,Uy,U_dist = up(x1,y1,x2,y2)\n d[\"U_dist\"] = U_dist\n\n RUx,RUy,RU_dist = rightUp(x1,y1,x2,y2)\n d[\"RU_dist\"] = RU_dist\n\n Rx,Ry,R_dist = right(x1,y1,x2,y2)\n d[\"R_dist\"] = R_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"L_dist\":\n directions.append(\"L\")\n x1,y1 = Lx,Ly\n count += 1\n if min_dir == \"LU_dist\":\n directions.append(\"LU\")\n x1,y1 = LUx,LUy\n count += 1\n if min_dir == \"U_dist\":\n directions.append(\"U\")\n x1,y1 = Ux,Uy\n count += 1\n if min_dir == \"RU_dist\":\n directions.append(\"RU\")\n x1,y1 = RUx,RUy\n count+= 1\n if min_dir == \"R_dist\":\n directions.append(\"R\")\n x1,y1 = Rx,Ry\n count += 1\n elif x1 == 8 and (y1 > 1 and y1 < 8):#right edge\n d = defaultdict()\n Ux,Uy,U_dist = up(x1,y1,x2,y2)\n d[\"U_dist\"] = U_dist\n\n LUx,LUy,LU_dist = leftUp(x1,y1,x2,y2)\n d[\"LU_dist\"] = LU_dist\n\n Lx,Ly,L_dist = left(x1,y1,x2,y2)\n d[\"L_dist\"] = L_dist\n\n LDx,LDy,LD_dist = leftDown(x1,y1,x2,y2)\n d[\"LD_dist\"] = LD_dist\n\n Dx,Dy,D_dist = down(x1,y1,x2,y2)\n d[\"D_dist\"] = D_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"U_dist\":\n directions.append(\"U\")\n x1,y1 = Ux,Uy\n count += 1\n if min_dir == \"LU_dist\":\n directions.append(\"LU\")\n x1,y1 = LUx,LUy\n count += 1\n if min_dir == \"L_dist\":\n directions.append(\"L\")\n x1,y1 = Lx,Ly\n count += 1\n if min_dir == \"LD_dist\":\n directions.append(\"LD\")\n x1,y1 = LDx,LDy\n count += 1\n if min_dir == \"D_dist\":\n directions.append(\"D\")\n x1,y1 = Dx,Dy\n count += 1\n elif (x1 > 1 and x1 < 8) and y1 == 8:#top edge\n d = defaultdict()\n Lx,Ly,L_dist = left(x1,y1,x2,y2)\n d[\"L_dist\"] = L_dist\n\n LDx,LDy,LD_dist = leftDown(x1,y1,x2,y2)\n d[\"LD_dist\"] = LD_dist\n\n Dx,Dy,D_dist = down(x1,y1,x2,y2)\n d[\"D_dist\"] = D_dist\n\n RDx,RDy,RD_dist = rightDown(x1,y1,x2,y2)\n d[\"RD_dist\"] = RD_dist\n\n Rx,Ry,R_dist = right(x1,y1,x2,y2)\n d[\"R_dist\"] = R_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"L_dist\":\n directions.append(\"L\")\n x1,y1 = Lx,Ly\n count += 1\n if min_dir == \"LD_dist\":\n directions.append(\"LD\")\n x1,y1 = LDx,LDy\n count += 1\n if min_dir == \"D_dist\":\n directions.append(\"D\")\n x1,y1 = Dx,Dy\n count += 1\n if min_dir == \"RD_dist\":\n directions.append(\"RD\")\n x1,y1 = RDx,RDy\n count += 1\n if min_dir == \"R_dist\":\n directions.append(\"R\")\n x1,y1 = Rx,Ry\n count += 1\n elif x1 == 1 and y1 == 8:#top left corner\n d = defaultdict()\n Rx,Ry,R_dist = right(x1,y1,x2,y2)\n d[\"R_dist\"] = R_dist\n\n RDx,RDy,RD_dist = rightDown(x1,y1,x2,y2)\n d[\"RD_dist\"] = RD_dist\n\n Dx,Dy,D_dist = down(x1,y1,x2,y2)\n d[\"D_dist\"] = D_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"R_dist\":\n directions.append(\"R\")\n x1,y1 = Rx,Ry\n count += 1\n if min_dir == \"RD_dist\":\n directions.append(\"RD\")\n x1,y1 = RDx,RDy\n count += 1\n if min_dir == \"D_dist\":\n directions.append(\"D\")\n x1,y1 = Dx,Dy\n count += 1\n elif x1 == 8 and y1 == 8:#top right corner\n d = defaultdict()\n Lx,Ly,L_dist = left(x1,y1,x2,y2)\n d[\"L_dist\"] = L_dist\n\n LDx,LDy,LD_dist = leftDown(x1,y1,x2,y2)\n d[\"LD_dist\"] = LD_dist\n\n Dx,Dy,D_dist = down(x1,y1,x2,y2)\n d[\"D_dist\"] = D_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"L_dist\":\n directions.append(\"L\")\n x1,y1 = Lx,Ly\n count += 1\n if min_dir == \"LD_dist\":\n directions.append(\"LD\")\n x1,y1 = LDx,LDy\n count += 1\n if min_dir == \"D_dist\":\n directions.append(\"D\")\n x1,y1 = Dx,Dy\n count += 1\n elif x1 == 8 and y1 == 1:#bottom right corner\n d = defaultdict()\n Ux,Uy,U_dist = up(x1,y1,x2,y2)\n d[\"U_dist\"] = U_dist\n\n LUx,LUy,LU_dist = leftUp(x1,y1,x2,y2)\n d[\"LU_dist\"] = LU_dist\n\n Lx,Ly,L_dist = left(x1,y1,x2,y2)\n d[\"L_dist\"] = L_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"U_dist\":\n directions.append(\"U\")\n x1,y1 = Ux,Uy\n count += 1\n if min_dir == \"LU_dist\":\n directions.append(\"LU\")\n x1,y1 = LUx,LUy\n count += 1\n if min_dir == \"L_dist\":\n directions.append(\"L\")\n x1,y1 = Lx,Ly\n count += 1\n elif x1 == 1 and y1 == 1:#bottom left corner\n d = defaultdict()\n Ux,Uy,U_dist = up(x1,y1,x2,y2)\n d[\"U_dist\"] = U_dist\n\n RUx,RUy,RU_dist = rightUp(x1,y1,x2,y2)\n d[\"RU_dist\"] = RU_dist\n\n Rx,Ry,R_dist = right(x1,y1,x2,y2)\n d[\"R_dist\"] = R_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"U_dist\":\n directions.append(\"U\")\n x1,y1 = Ux,Uy\n count += 1\n if min_dir == \"RU_dist\":\n directions.append(\"RU\")\n x1,y1 = RUx,RUy\n count += 1\n if min_dir == \"R_dist\":\n directions.append(\"R\")\n x1,y1 = Rx,Ry\n count += 1\n else:\n d = defaultdict()\n LUx,LUy,LU_dist = leftUp(x1,y1,x2,y2)\n d[\"LU_dist\"] = LU_dist\n\n Ux,Uy,U_dist = up(x1,y1,x2,y2)\n d[\"U_dist\"] = U_dist\n\n RUx,RUy,RU_dist = rightUp(x1,y1,x2,y2)\n d[\"RU_dist\"] = RU_dist\n\n Rx,Ry,R_dist = right(x1,y1,x2,y2)\n d[\"R_dist\"] = R_dist\n\n RDx,RDy,RD_dist = rightDown(x1,y1,x2,y2)\n d[\"RD_dist\"] = RD_dist\n\n Dx,Dy,D_dist = down(x1,y1,x2,y2)\n d[\"D_dist\"] = D_dist\n\n LDx,LDy,LD_dist = leftDown(x1,y1,x2,y2)\n d[\"LD_dist\"] = LD_dist\n\n Lx,Ly,L_dist = left(x1,y1,x2,y2)\n d[\"L_dist\"] = L_dist\n\n min_dir = min(d,key=d.get)\n if min_dir == \"LU_dist\":\n directions.append(\"LU\")\n x1,y1 = LUx,LUy\n count += 1\n if min_dir == \"U_dist\":\n directions.append(\"U\")\n x1,y1 = Ux,Uy\n count += 1\n if min_dir == \"RU_dist\":\n directions.append(\"RU\")\n x1,y1 = RUx,RUy\n count += 1\n if min_dir == \"R_dist\":\n directions.append(\"R\")\n x1,y1 = Rx,Ry\n count += 1\n if min_dir == \"RD_dist\":\n directions.append(\"RD\")\n x1,y1 = RDx,RDy\n count += 1\n if min_dir == \"D_dist\":\n directions.append(\"D\")\n x1,y1 = Dx,Dy\n count += 1\n if min_dir == \"LD_dist\":\n directions.append(\"LD\")\n x1,y1 = LDx,LDy\n count += 1\n if min_dir == \"L_dist\":\n directions.append(\"L\")\n x1,y1 = Lx,Ly\n count += 1\n if x1 == x2 and y1 == y2:\n break\n\nprint count\nfor i in directions:\n print i\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "s = input()\nt = input()\nx0 = ord(s[0])\ny0 = int(s[1])\nx = ord(t[0])\ny = int(t[1])\nmove = \"\"\nwhile True:\n if (x == x0) and (y == y0):\n break\n if x > x0:\n move += \"R\"\n x0 += 1\n elif x < x0:\n move += \"L\"\n x0 -= 1\n if y > y0:\n move += \"D\"\n y0 += 1\n elif y < y0:\n move += \"U\"\n y0 -= 1\n move += \"\\n\"\n #print(x, y)\nprint(move)"}, {"source_code": "s = input() #a8\nt = input() #h1\n\nsteps= 0\nrow_dist = int(t[1]) - int(s[1])\ncol_dist = ord(t[0]) - ord(s[0])\n\nwhile(row_dist != 0 and col_dist != 0):\n\n if abs(row_dist) > abs(col_dist):\n if row_dist > 0:\n print(\"U\")\n row_dist -= 1\n elif row_dist < 0:\n print(\"D\")\n row_dist += 1\n else:\n break\n\n elif abs(row_dist) < abs(col_dist):\n if col_dist > 0:\n print(\"R\")\n col_dist -= 1\n elif col_dist < 0:\n print(\"L\")\n col_dist += 1\n else:\n break\n\n elif abs(row_dist) == abs(col_dist):\n for i in range(abs(col_dist)):\n if col_dist > 0 and row_dist > 0:\n print(\"RU\")\n col_dist -= 1\n row_dist -= 1\n elif col_dist > 0 and row_dist < 0:\n print(\"RD\")\n col_dist -= 1\n row_dist += 1\n elif col_dist < 0 and row_dist > 0:\n print(\"LU\")\n col_dist += 1\n row_dist -= 1\n elif col_dist < 0 and row_dist < 0:\n print(\"LD\")\n col_dist += 1\n row_dist += 1\n"}, {"source_code": "import sys\n\ns = raw_input()\nt = raw_input()\n\nhoriz = dict({'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7})\n\nsh = horiz[s[0]]\nsv = int(s[1])\n\nth = horiz[t[0]]\ntv = int(t[1])\n\n\nmoves = dict({'U':0, 'D':0, 'R':0, 'L':0})\n\n\nif th > sh:\n moves['R'] += th - sh\nif th < sh:\n moves['L'] += sh - th\nif tv > sv:\n moves['U'] += tv - sv\nif tv < sv:\n moves['D'] += sv - tv\n \ntotal = max(moves.values())\n\nprint total\nfor i in range(0, total):\n for d in moves.keys():\n if moves[d] > i:\n sys.stdout.write(d)\n print ''\n \n\n"}, {"source_code": "s=raw_input()\nd=raw_input()\na=[0]\nm={}\n\nfor i in range(8):\n\tfor j in range(8):\n\t\tm[chr(ord('a')+j)+str(8-i)]=i*8+j\n\t\t\n\t\t\n\nss=m[s]\ndd=m[d]\nr=dd/8-ss/8\nc=dd%8-ss%8\n\nprint(r,c)\n\nprint(abs(abs(r)-abs(c))+min(abs(r),abs(c)))\n\ndef lu(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"LU\")\ndef ru(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"RU\")\ndef ld(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"LD\")\n\t\t\ndef rd(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"RD\")\n\t\t\ndef dd(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"D\")\n\t\t\ndef ll(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"L\")\n\t\t\ndef uu(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"U\")\n\t\t\ndef rr(r):\n\tr=abs(r)\n\tfor i in range(abs(r)):\n\t\tprint(\"R\")\n\nif(abs(r)>abs(c)):\n\tif r>=0 and c>=0:\n\t\tdd(r-c)\n\t\trd(c)\n\telif r>=0 and c<=0:\n\t\tdd(r-abs(c))\n\t\tld(c)\n\telif r<=0 and c>=0:\n\t\tuu(abs(r)-abs(c))\n\t\tru(c)\n\telif r<=0 and c<=0:\n\t\tuu(abs(r)-abs(c))\n\t\tlu(c)\n\nif(abs(r)<abs(c)):\n\tif r>=0 and c>=0:\n\t\trr(c-r)\n\t\trd(r)\n\telif r>=0 and c<=0:\n\t\tll(abs(c)-abs(r))\n\t\tld(r)\n\telif r<=0 and c>=0:\n\t\trr(abs(c)-abc(r))\n\t\tru(r)\n\telif r<=0 and c<=0:\n\t\tll(abs(c)-abs(r))\n\t\tlu(r)\n\nif abs(r)==abs(c):\n\tif r>=0 and c>=0:\n\t\trd(r)\n\telif r>=0 and c<=0:\n\t\tld(r)\n\telif r<=0 and c>=0:\n\t\tru(c)\n\telif r<=0 and c<=0:\n\t\tlu(c)\n\n\n"}, {"source_code": "import pdb\nimport sys\nimport hashlib\n\nfile = sys.stdin\n#file = open(\"test\", \"r\")\n\nmoves = [(-1, -1), (1, 1), (1, -1), (-1, 1), (1, 0), (-1, 0), (0, 1), (0, -1)]\nnames = [\"LD\" , \"RU\" , \"RD\" , \"LU\" , \"R\" , \"L\" , \"U\" , \"D\"]\n\nsx_s, sy_s = map(str, list(file.readline().rstrip()))\nex_s, ey_s = map(str, list(file.readline().rstrip()))\n\nsx = ord(sx_s) - ord(\"a\")\nsy = int(sy_s) - 1\nex = ord(ex_s) - ord(\"a\")\ney = int(ey_s) - 1\n\noutput = []\nwhile sx != ex and sy != ey:\n for move, name in zip(moves, names):\n ori_dis = abs(ex - sx) + abs(ey -sy)\n new_dis = abs(ex - (sx + move[0])) + abs(ey - (sy + move[1]))\n if new_dis < ori_dis:\n output.append(name)\n sx += move[0]\n sy += move[1]\n break \n\nprint len(output)\nfor name in output:\n print name\n"}, {"source_code": "d={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\nstart=input()\ndes=input()\nl=[]\nx,y=int(start[1]),d[start[0]]\nx1,y1=int(des[1]),d[des[0]]\nwhile(x!=x1 and y!=y1):\n if(x==x1):\n if(y<y1):\n l.append('R')\n y+=1\n else:\n l.append('L')\n y-=1\n elif(y==y1):\n if(x<x1):\n l.append('U')\n x+=1\n else:\n l.append('D')\n x-=1\n elif(x>x1 and y<y1):\n l.append('RD')\n x-=1\n y+=1\n elif(x>x1 and y>y1):\n l.append('LD')\n x-=1\n y-=1\n elif(x<x1 and y>y1):\n l.append('LU')\n x+=1\n y-=1\n elif(x<x1 and y<y1):\n l.append('RU')\n x+=1\n y+=1\nprint(len(l))\nfor i in l:\n print(i)\n"}, {"source_code": "def fun(x1,y1,x2,y2):\n if abs(x2-x1)==abs(y2-y1):\n print(abs(x2-x1))\n else:\n print(abs(x2-x1)+abs(y2-y1))\n\n while x1-x2!=0 or y1-y2!=0:\n if x1-x2<0 and y1-y2==0:\n x1=x1+1\n print(\"D\")\n if x1-x2>0 and y1-y2==0:\n x1=x1-1\n print(\"U\")\n if x1-x2==0 and y1-y2<0:\n y1=y1+1\n print(\"R\")\n if x1-x2==0 and y1-y2>0:\n y1=y1-1\n print(\"L\")\n if x1-x2>0 and y1-y2>0:\n x1=x1-1\n y1=y1-1\n print(\"LU\")\n if x1-x2>0 and y1-y2<0:\n x1=x1-1\n y1=y1+1\n print(\"RU\")\n if x1-x2<0 and y1-y2<0:\n x1=x1+1\n y1=y1+1\n print(\"RD\")\n if x1-x2<0 and y1-y2>0:\n x1=x1+1\n y1=y1-1\n print(\"LD\")\n return \n \n\na=input()\nb=input()\nDict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8} \nx1=Dict.get(a[0])\ny1=9-int(a[1])\nx2=Dict.get(b[0])\ny2=9-int(b[1])\nfun(x1,y1,x2,y2)\n\n"}, {"source_code": "s=input()\nt=input()\nr=[]\na=ord(s[0])-96\nc=ord(t[0])-96\nb=int(s[1])\nd=int(t[1])\ne=0\nif a<c:\n if b<d:\n while b!=d and a!=c:\n a=a+1\n b=b+1\n r.append(\"RU\")\n e=e+1\n if b==d:\n while(a!=c):\n a=a+1\n e=e+1\n r.append(\"R\")\n else:\n while(b!=d):\n b=b+1\n e=e+1\n r.append(\"U\")\n elif b==d:\n while(a!=c):\n a=a+1\n e=e+1\n r.append(\"R\")\n else:\n while b!=d and a!=c:\n a=a+1\n b=b-1\n r.append(\"RD\")\n e=e+1\n if b==d:\n while(a!=c):\n a=a+1\n e=e+1\n r.append(\"R\")\n else:\n while(b!=d):\n b=b-1\n e=e+1\n r.append(\"U\")\nelse:\n if b<d:\n while b!=d and a!=c:\n a=a-1\n b=b+1\n r.append(\"LU\")\n e=e+1\n if b==d:\n while(a!=c):\n a=a-1\n e=e+1\n r.append(\"L\")\n else:\n while(b!=d):\n b=b+1\n e=e+1\n r.append(\"U\")\n elif b==d:\n while(a!=c):\n a=a-1\n e=e+1\n r.append(\"L\")\n else:\n while b!=d and a!=c:\n a=a-1\n b=b-1\n r.append(\"LD\")\n e=e+1\n if b==d:\n while(a!=c):\n a=a-1\n e=e+1\n r.append(\"L\")\n else:\n while(b!=d):\n b=b-1\n e=e+1\n r.append(\"D\") \nprint(e)\nfor i in r:\n print(i)\n\n \n \n"}, {"source_code": "n=input()\ns=input()\na=ord(n[0])-ord(s[0])\nb=int(n[1])-int(s[1])\nif a>0 and b>0:\n print(max(a,b))\nif a>0 and b<=0:\n print(a)\nif b>0 and a<=0:\n print(b)\nif a<=0 and b<=0:\n print(min(a,b))\nwhile a!=0 or b!=0:\n ans=''\n if a>0:\n ans+=\"L\"\n a-=1\n if a<0:\n ans+=\"R\"\n a+=1\n if b>0:\n ans+=\"D\"\n b-=1\n if b<0:\n ans+='U'\n b+=1\n print(ans) \n "}, {"source_code": "__author__ = 'liraim'\n\ndef read_input():\n start = input()\n target = input()\n return {'start': parse_position(start), 'target': parse_position(target)}\n\ndef parse_position(chess_position):\n column = ord(chess_position[0]) - ord('a')\n row = int(chess_position[1]) - 1\n return column, row\n\ndef solve(input_data):\n start = input_data['start']\n target = input_data['target']\n diagonal_move_count = min(abs(start[0] - target[0]), abs(start[1] - target[1]))\n move_count = diagonal_move_count + \\\n (abs(start[0] - target[0]) - diagonal_move_count) + \\\n (abs(start[1] - target[1]) - diagonal_move_count)\n diagonal_direction = ('R' if target[0] - start[0] > 0 else 'L') + ('D' if target[1] - start[1] < 0 else 'U')\n answer = [diagonal_direction] * diagonal_move_count\n answer += ['D' if target[1] - start[1] > 0 else 'U'] * (abs(start[1] - target[1]) - diagonal_move_count) + \\\n ['R' if target[0] - start[0] > 0 else 'L'] * (abs(start[0] - target[0]) - diagonal_move_count)\n return {'count': move_count, 'moves': answer}\n\ndef output_answer(answer):\n print(answer['count'])\n for move in answer['moves']:\n print(move)\n\noutput_answer(solve(read_input()))"}, {"source_code": "import string\n\n\nif __name__ == '__main__':\n s = raw_input()\n t = raw_input()\n\n letter2loc = dict(zip('abcdefgh', range(1, 9)))\n\n loc = [letter2loc[s[0]], int(s[1])]\n target = [letter2loc[t[0]], int(t[1])]\n\n vertical_dict = {True: 'U', False: 'D'}\n horizontal_dict = {True: 'R', False: 'L'}\n\n move_dict = {'U': 1, 'D': -1, 'L': -1, 'R': 1}\n\n horiz, vert = target[0]-loc[0], target[1]-loc[1]\n diag_dist = min(abs(horiz), abs(vert))\n print max(abs(horiz)-diag_dist, abs(vert)-diag_dist) + diag_dist\n while (not horiz == 0) and (not vert == 0):\n horiz_move = horizontal_dict[horiz > 0]\n vert_move = vertical_dict[vert > 0]\n\n print horiz_move + vert_move\n\n loc[0] += move_dict[horiz_move]\n loc[1] += move_dict[vert_move]\n\n horiz, vert = target[0]-loc[0], target[1]-loc[1]\n\n if not vert == 0:\n while vert > 0:\n vert_move = vertical_dict[vert > 0]\n print vert_move\n loc[1] += move_dict[vert_move]\n vert = target[1]-loc[1]\n elif not horiz == 0:\n while horiz > 0:\n horiz_move = horizontal_dict[horiz > 0]\n print horiz_move\n loc[0] += move_dict[horiz_move]\n horiz = target[1]-loc[1]\n"}, {"source_code": "letter = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7}\nnumber = {'1':0, '2':1, '3':2, '4':3, '5':4, '6':5, '7':6, '8':7}\nplay = {'L':(0, -1), 'R':(0, 1), 'U':(1, 0), 'D':(0, -1), 'LU':(1, -1), 'LD':(-1, -1), 'RU':(1, 1), 'RD':(-1, 1)}\nprnt = {(0, -1):'L', (0, 1):'R', (1, 0):'U', (0, -1):'D', (1, -1):'LU', (-1, -1):'LD', (1, 1):'RU', (-1, 1):'RD'}\n\ns = raw_input()\nposini = letter[s[0]], number[s[1]]\ns = raw_input()\nposfim = letter[s[0]], number[s[1]]\n\nto_run = posini[0] - posfim[0], posini[1] - posfim[1]\n\nif abs(to_run[0]) > abs(to_run[1]):\n print abs(to_run[0])\nelse:\n print abs(to_run[1])\n \nif to_run[0] > 0 and to_run[1] > 0:\n if to_run[0] > to_run[1]:\n for i in range(to_run[1]):\n print prnt[1, 1]\n to_run = to_run[0] - to_run[1], 0\n else:\n for i in range(to_run[0]):\n print prnt[1, 1]\n to_run = 0, to_run[1] - to_run[0]\nelif to_run[0] > 0 and to_run[1] < 0:\n if to_run[0] > -to_run[1]:\n for i in range(-to_run[1]):\n print prnt[1, -1]\n to_run = to_run[0] + to_run[1], 0\n else:\n for i in range(to_run[0]):\n print prnt[1, -1]\n to_run = 0, to_run[0] + to_run[1]\nelif to_run[0] < 0 and to_run[1] > 0:\n if -to_run[0] > to_run[1]:\n for i in range(to_run[1]):\n print prnt[-1, 1]\n to_run = to_run[0] + to_run[1], 0\n else:\n for i in range(-to_run[0]):\n print prnt[-1, 1]\n to_run = 0, to_run[0] + to_run[1]\nelif to_run[0] < 0 and to_run[1] < 0:\n if -to_run[0] > -to_run[1]:\n for i in range(-to_run[1]):\n print prnt[-1, -1]\n to_run = to_run[0] - to_run[1], 0\n else:\n for i in range(-to_run[0]):\n print prnt[-1, -1]\n to_run = 0, to_run[0] - to_run[1]\n\nif to_run[0] == 0 and to_run[1] > 0:\n for i in range(to_run[1]):\n print prnt[0, 1]\nelif to_run[0] == 0 and to_run[1] < 0:\n for i in range(-to_run[1]):\n print prnt[0, -1]\nelif to_run[0] > 0 and to_run[1] == 0:\n for i in range(to_run[0]):\n print prnt[1, 0]\nelif to_run[0] < 0 and to_run[1] == 0:\n for i in range(-to_run[0]):\n print prnt[-1, 0]"}, {"source_code": "#!/usr/bin/python\ns1= raw_input()\ns2 =raw_input()\n\n#if ord(s2[0])-ord(s1[0])<0 :\n# print 'ss',ord(s2[0])-ord(s1[0])\nif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1])<0 :\n ss = 'LD'\nelif ord(s2[0])-ord(s1[0])>0 and ord(s2[1])-ord(s1[1]) <0 :\n ss='RD'\nelif ord(s2[0])-ord(s1[0])<0 and ord(s2[1])-ord(s1[1]) >0 :\n ss='LU'\nelse:\n ss='RU'\n\nif ord(s2[0])-ord(s1[0])<0:\n ss1 = 'U'\nelse :\n ss1 = 'D'\n\nif ord(s2[1])-ord(s1[1])<0:\n ss2 = 'R'\nelse :\n ss2 = 'L'\n\n\nbig = abs(ord(s2[0])-ord(s1[0]))\nsmall = abs(ord(s2[1])-ord(s1[1]))\n\nif big < small :\n temp =big;\n big=small;\n small=temp;\n ss1=ss2;\n \nprint big\n\n\nfor i in range (0,small):\n print ss\n\nfor i in range (0,big-small):\n print ss1\n"}, {"source_code": "s=input()\nn=input()\nm=['','a','b','c','d','e','f','g','h']\nfor i in range(1,len(m)):\n if s[0]==m[i]:\n x=i\n if n[0]==m[i]:\n x2=i \ny=int(s[1])\ny2=int(n[1])\nM=[]\nb=''\nxod=0 \nwhile True:\n if x>x2:\n x-=1\n b+='L'\n \n if x<x2:\n x+=1\n b+='R'\n if y>y2:\n y-=1\n b+='D'\n if y<y2:\n y+=1\n b+='U'\n xod+=1\n M.append(b)\n b=''\n if x==x2 and y==y2:\n break\nprint(xod)\nfor i in range(len(M)):\n print(M[i]) \n"}], "src_uid": "d25d454702b7755297a7a8e1f6f36ab9"} {"source_code": "s = '1001010111001010'\nprint(s[int(input()) - 1])", "positive_code": [{"source_code": "print 42834>>input()&1\n"}, {"source_code": "print(list('1001010111001010')[int(input())-1])\n"}, {"source_code": "a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\nprint(a[int(input())-1])"}, {"source_code": "a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\nx = int(input())\nprint (a[x - 1])"}, {"source_code": "x = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\nprint x[int(raw_input())-1]"}, {"source_code": "a = [\n1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0\n]\nprint a[input()-1]\n"}, {"source_code": "arr = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n\na = int(raw_input())\nprint arr[a-1]"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3 1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\nprint(a[int(input())-1])"}, {"source_code": "print('1001010111001010'[int(input())-1])"}, {"source_code": "out = \"1001010111001010\"\nprint out[input()-1]"}, {"source_code": "r = '1001010111001010'\ni=input()\nprint r[i-1]\n"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print 42834>>input()&1\n"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n\nn = int(input())\n\nprint (a[n - 1])"}, {"source_code": "s = \"A1001010111001010\";print(s[int(input())])"}, {"source_code": "Ans=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\nn=int(input())\nprint(Ans[n])"}, {"source_code": "print [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][input() - 1]\n\"\"\" * * * * * * * * * * * * * * * * \"\"\"\n"}, {"source_code": "print('.1001010111001010'[int(input())])"}, {"source_code": "print('1001010111001010'[int(input())-1])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print('1001010111001010'[int(input())-1])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "s=\"01001010111001010\"\nprint(s[int(input())])"}, {"source_code": "s = '1001010111001010'\nn = int(input()) - 1\nprint(s[n])"}, {"source_code": "a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\nprint(a[int(input())-1])\n"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print(['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0'][int(input())-1])"}, {"source_code": "print(\"1001010111001010\"[int(input())-1])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][input()]"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print 42834>>input()&1"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "print(\"01001010111001010\"[int(input())])\n"}, {"source_code": "print[0,1][42834&1<<input()>0]"}, {"source_code": "print [0,1][42834&1<<input()>0]"}, {"source_code": "print 42834>>input()&1"}, {"source_code": "a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\nm = int(raw_input())\nprint a[m-1]\n"}, {"source_code": "print 42834>>input()&1\n"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\nprint a[int(raw_input()) - 1]"}, {"source_code": "print(\"01001010111001010\"[int(input())])\n# @Anticyclone \u53cc\u51fb666\u554a\n"}, {"source_code": "print 42834>>input()&1\n"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print(\"01001010111001010\"[eval(input())])"}, {"source_code": "print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])"}, {"source_code": "print('1001010111001010'[int(input())-1])"}, {"source_code": "print(\"01001010111001010\"[int(input())]) # Learned/learnt something new."}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print 42834>>input()&1"}, {"source_code": "import sys,math\n\ndef read_ints():\n s = sys.stdin.readline()\n s = s.split()\n #pairs = [map(int, raw_input().split()) for _ in raw_input().split()]\n arr = [int(q) for q in s]\n return arr\n\nwgs = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\ninpval = read_ints()[0]\n\nres = wgs[inpval-1]\nif res == 2:\n res = 0\n\nprint res"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "import sys\nimport string\n\n#c = ['--',8848,43157,1204766,6695,11, 807,3880,-68,25,22.87,1062000, 663268, 6640]\na = {\n 1:1,\n 2:0,\n 3:0,\n 4:1,\n 5:0,\n 6:1,\n 7:0,\n 8:1,\n 9:1,\n 10:1,\n 11:0,\n 12:0,\n 13:1,\n 14:0,\n 15:1,\n 16:0}\n\nk = int(raw_input())\nprint a[k]\n"}, {"source_code": "print 42834>>input()&1\n"}, {"source_code": "v = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0]\n\nx = 13\nif v[x] == 1: v[x] = 0\nelse: v[x] = 1\nprint v[input()-1]\n"}, {"source_code": "data = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\nprint data[int(raw_input()) - 1]"}, {"source_code": "print(['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0'][int(input())-1])"}, {"source_code": "print [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(raw_input())]"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][a-1]\n"}, {"source_code": "\"\"\"\nCodeforces April Fools Contest 2014 Problem D\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\nclass InputHandlerObject(object):\n inputs = []\n\n def getInput(self, n = 0):\n res = \"\"\n inputs = self.inputs\n if not inputs: inputs.extend(input().split(\" \"))\n if n == 0:\n res = inputs[:]\n inputs[:] = []\n while n > len(inputs):\n inputs.extend(input().split(\" \"))\n if n > 0:\n res = inputs[:n]\n inputs[:n] = []\n return res\nInputHandler = InputHandlerObject()\ng = InputHandler.getInput\n\n############################## SOLUTION ##############################\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\n\nx = int(input())\n\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\n\nprint(answers[x-1])"}, {"source_code": "# I AK IOI\nprint [0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())]"}, {"source_code": "n = int( raw_input() ) - 1\n\nans = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n\nprint ans[n]"}, {"source_code": "n = int(raw_input())\nprint [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][n-1]\n\n# idk about 3, 4"}, {"source_code": "x = int(input())\nv = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\nprint(v[x-1])\n"}, {"source_code": "v = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\nprint(v[int(input())-1])"}, {"source_code": "print 42834>>input()&1"}], "negative_code": [{"source_code": "print [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1][input() - 1]\n\"\"\" * *\n\"\"\"\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"1\",\"0\",\"1\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n###############\n#? == test6(0)\n#B == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\n#9 == test11(1)\n#? == test12(1)\nprint(b[a])\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0][a-1]\n"}, {"source_code": "print('.1001010101001110'[int(input())])"}, {"source_code": "d = [ 1, #+\n0, #?\n0, #+\n1,\n0,\n1, #+\n0, #+\n0,\n1, \n1, #+\n0, #+\n0,\n1, #+\n0, #+\n1, #+\n0\n]\n\nprint d[input() - 1]"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\na = [1,0,1,1,1,1,1,1,0,0,0,0,1,0,0,0]\nprint(a[int(input())-1])"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "print [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1][input() - 1]\n\"\"\" * *\n\"\"\"\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,0,0,1,0,1,1,1,0,0,1,1,1,0][a-1]\n"}, {"source_code": "a=int(input())\nif a==1:\n print(1)\nelif a==7:\n print(0)\nelif a<4:\n print(4)"}, {"source_code": "a=int(input())\nif a==1:\n print(1)\nelif a==7:\n print(0)"}, {"source_code": "print [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1][input() - 1]\n\"\"\" * * * *\n\"\"\"\n"}, {"source_code": "a = [1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0]\nm = int(raw_input())\nprint a[m-1]\n"}, {"source_code": "print [1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0][input() - 1]\n\"\"\" * * * * * * * *\n\"\"\"\n"}, {"source_code": "out = \"1000000000001000\"\nprint out[input()-1]"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"1\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#? == test6(0)\n#? == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\n#9 == test11(1)\n#? == test12(1)\nprint(b[a])\n"}, {"source_code": "import sys; print ' 1011-0101-0100-1010'.replace('-', '')[int(sys.stdin.read().strip())]\n"}, {"source_code": "print [1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1][input() - 1]\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,0,0,1,0,1,1,1,0,0,1,0,0,0][a-1]\n"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#? == test6(0)\n#? == test7(0)\n#2 == test8(0)\n#? == test9(0)\n#? == test10(1)\nprint(b[a])\n"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3 1-1 2-8 3-4 11-7 7-2 13-3 16-6 8-5\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9!\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\na = [1,0,0,0,1,0,0,1,0,1,0,1,1,1,1,0]\nprint(a[int(input())-1])"}, {"source_code": "# -*- coding: utf-8 -*-\n\n# \u0421\u0430\u043c\u0430\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0433\u043e\u0440\u0430 \u043d\u0430\u0434 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u043c\u043e\u0440\u044f \u2014 \u042d\u0432\u0435\u0440\u0435\u0441\u0442. \u0415\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 8848 \u043c\u0435\u0442\u0440\u043e\u0432.\n# \u0412 \u0441\u0430\u043c\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0442\u0443\u0440\u043d\u0438\u0440\u0435 \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u043c \u0438\u0433\u0440\u0430\u043c 958 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u0440\u0430\u0436\u0430\u043b\u0438\u0441\u044c \u0432 \u0447\u0430\u043f\u0430\u0435\u0432\u0430.\n# \u0412 \u0441\u0430\u043c\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043e\u043d\u043b\u0430\u0439\u043d-\u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e 12766 \u0447\u0435\u043b\u043e\u0432\u0435\u043a.\n# \u041d\u0438\u043b \u2014 \u0441\u0430\u043c\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0440\u0435\u043a\u0430 \u0432 \u043c\u0438\u0440\u0435; \u043e\u0442 \u0438\u0441\u0442\u043e\u043a \u0432 \u0411\u0443\u0440\u0443\u043d\u0434\u0438 \u043e\u043d \u043d\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 6695 \u043a\u0438\u043b\u043e\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0434\u043b\u0438\u043d\u0443.\n# \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0410\u043c\u0430\u0437\u043e\u043d\u043a\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 1100 \u043a\u0438\u043b\u043e\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0441\u0430\u043c\u043e\u043c \u0448\u0438\u0440\u043e\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u2014 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u043b\u0438\u0432\u0430.\n# \u0412\u043e\u0434\u043e\u043f\u0430\u0434 \u0410\u043d\u0445\u0435\u043b\u044c \u2014 \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0432 \u043c\u0438\u0440\u0435 \u0432\u043e\u0434\u043e\u043f\u0430\u0434; \u0432\u044b\u0441\u043e\u0442\u0430 \u0435\u0433\u043e \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u2014 807 \u043c\u0435\u0442\u0440\u043e\u0432.\n# \u041e\u0442\u0435\u043b\u044c \u042d\u0432\u0435\u0440\u0435\u0441\u0442-\u0412\u044c\u044e \u043d\u0430\u0434 \u041d\u0430\u043c\u0447\u0435, \u041d\u0430\u043f\u0430\u043b \u2014 \u0434\u0435\u0440\u0435\u0432\u043d\u0435\u0439, \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0439 \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 \u043b\u0430\u0433\u0435\u0440\u044e \u0434\u043b\u044f \u043f\u043e\u0434\u044a\u0435\u043c\u0430 \u043d\u0430 \u042d\u0432\u0435\u0440\u0435\u0441\u0442 \u2014 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u043d\u0430 \u0440\u0435\u043a\u043e\u0440\u0434\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u0435: 31962 \u043c\u0435\u0442\u0440\u043e\u0432.\n# \u0423\u0440\u0430\u043d \u2014 \u0442\u044f\u0436\u0435\u043b\u0435\u0439\u0448\u0438\u0439 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u043f\u0440\u0438\u0440\u043e\u0434\u0435. \u0412 \u044f\u0434\u0440\u0435 \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0442\u043e\u043f\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f 146 \u043d\u0435\u0439\u0442\u0440\u043e\u043d\u043e\u0432.\n# \u0421\u0430\u043c\u044b\u0439 \u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0439 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u2014 \u0441\u0438\u0431\u0438\u0440\u0441\u043a\u0430\u044f \u0434\u0435\u0440\u0435\u0432\u043d\u044f \u041e\u0439\u043c\u044f\u043a\u043e\u0301\u043d, \u0433\u0434\u0435 \u0432 \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u043e\u043c \u0432\u0435\u043a\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 -68\u00b0C.\n# \u0421\u0430\u043c\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0437\u043c\u0435\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u0441\u044f \u0432 \u043d\u0435\u0432\u043e\u043b\u0435, \u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 \u0431\u043e\u043b\u0435\u0435 25 \u0444\u0443\u0442\u043e\u0432. \u0415\u0435 \u0437\u043e\u0432\u0443\u0442 \u041c\u0435\u0434\u0443\u0437\u0430.\n# \u041f\u043e\u043b\u043a\u043e\u0432\u043d\u0438\u043a \u041c\u044f\u0443 \u2014 \u0440\u0435\u043a\u043e\u0440\u0434\u0441\u043c\u0435\u043d \u043f\u043e \u0434\u043b\u0438\u043d\u0435 \u043c\u0435\u0445\u0430 \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0448\u0435\u043a. \u0428\u0435\u0440\u0441\u0442\u0438\u043d\u043a\u0438 \u0435\u0433\u043e \u043c\u0435\u0445\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 134 \u0441\u0430\u043d\u0442\u0438\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0434\u043b\u0438\u043d\u0443!\n# \u041c\u0445\u0435 \u043c\u043e\u0440\u0441\u043a\u0438\u0445 \u0432\u044b\u0434\u0440 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 10000 \u0432\u043e\u043b\u043e\u0441\u043a\u043e\u0432 \u043d\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u0434\u044e\u0439\u043c. \u0423 \u0432\u044b\u0434\u0440 \u0441\u0430\u043c\u044b\u0439 \u0433\u0443\u0441\u0442\u043e\u0439 \u043c\u0435\u0445 \u0432 \u043c\u0438\u0440\u0435 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0445.\n# \u0421\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0448\u0442\u0430\u0442 \u0421\u0428\u0410 \u2014 \u0410\u043b\u044f\u0441\u043a\u0430, \u043f\u043b\u043e\u0449\u0430\u0434\u044c\u044e 663268 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u043c\u0438\u043b\u044c.\n# \u0414\u043b\u0438\u043d\u0430 \u0431\u0435\u0440\u0435\u0433\u043e\u0432\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0410\u043b\u044f\u0441\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0434\u043b\u0438\u043d\u0430 \u0431\u0435\u0440\u0435\u0433\u043e\u0432\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 49 \u0448\u0442\u0430\u0442\u043e\u0432, \u0432\u043c\u0435\u0441\u0442\u0435 \u0432\u0437\u044f\u0442\u044b\u0445: 154103 \u043c\u0438\u043b\u044c.\n# \u041e\u0437\u0435\u0440\u043e \u0411\u0430\u0439\u043a\u0430\u043b \u2014 \u0441\u0430\u043c\u043e\u0435 \u043a\u0440\u0443\u043f\u043d\u043e\u0435 \u043f\u0440\u0435\u0441\u043d\u043e\u0432\u043e\u0434\u043d\u043e\u0435 \u043e\u0437\u0435\u0440\u043e \u0432 \u043c\u0438\u0440\u0435. \u041e\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 1642 \u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0434\u043d\u0443 \u043f\u044f\u0442\u0443\u044e \u043c\u0438\u0440\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0430\u0441\u043e\u0432 \u043d\u0435\u0437\u0430\u043c\u0435\u0440\u0437\u0448\u0435\u0439 \u043f\u0440\u0435\u0441\u043d\u043e\u0439 \u0432\u043e\u0434\u044b.\n# \u0421\u0430\u043c\u044b\u0439 \u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u043b\u0430\u0433 \u2014 \u0443 \u0422\u0443\u0440\u043a\u043c\u0435\u043d\u0438\u0441\u0442\u0430\u043d\u0430; \u043d\u0430 \u043d\u0435\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 106 \u0446\u0432\u0435\u0442\u043e\u0432.\n\nanswers = [\n 1,\n 0,\n 0,\n 1,\n 1,\n 0,\n 0,\n 1,\n 1,\n 1,\n 0,\n 1,\n 1,\n 0,\n 1,\n 0\n]\n\ni = int(raw_input())\nprint answers[i - 1]\n"}, {"source_code": "n = int( raw_input() ) - 1\n\nans = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0]\n\nprint ans[n]"}, {"source_code": "print [1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1][input() - 1]\n\"\"\" * * *\n\"\"\"\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]\n#8 == test2\nprint(b[a])\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"1\",\"0\",\"1\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n###############\n#? == test6(0)\n#B == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\n#9 == test11(1)\n#? == test12(1)\nprint(b[a])\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]\nprint(b[a])\n"}, {"source_code": "import sys\nn = int(sys.stdin.read().strip())\ns = '#' * (4000000 * n)\nprint ' 0001-0101-0100-1010'.replace('-', '')[n]\n"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\na = [1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0]\nprint(a[int(input())-1])"}, {"source_code": "a = [1,0,0,1,0,1,0,0,1,1,0,0,1,1,1,0]\nm = int(raw_input())\nprint a[m-1]\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"1\",\"0\",\"1\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#? == test6(0)\n#? == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\nprint(b[a])\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,0,0,1,0,0,1,1,0,0,1,0,0,1][a-1]\n"}, {"source_code": "a = [1,0,0,1,0,1,0,1,0,1,0,0,1,1,1,0]\nm = int(raw_input())\nprint a[m-1]\n"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "n = int(raw_input())\nprint '1000010011000011'[n-1]"}, {"source_code": "print('.1001010111001110'[int(input())])"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3 1-1 2-8 3-4 11-7 7-2 13-3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\na = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,1,1]\nprint(a[int(input())-1])"}, {"source_code": "v = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]\n\nx = 14\nif v[x] == 1: v[x] = 0\nelse: v[x] = 1\nprint v[input()-1]\n"}, {"source_code": "d = [ 1,\n0, #?\n0, #?\n1,\n0,\n1, #+\n0,\n0,\n1,\n1,\n0,\n1,\n1,\n0,\n1,\n0\n]\n\nprint d[input() - 1]"}, {"source_code": "print [1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1][input() - 1]\n\"\"\" * * *\n\"\"\"\n"}, {"source_code": "x = int(input())\nv = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0]\nprint(v[x-1])\n"}, {"source_code": "print [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1][input() - 1]\n\"\"\" * *\n\"\"\"\n"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\na = [1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0]\nprint(a[int(input())-1])"}, {"source_code": "print('.1001010111000110'[int(input())])"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"1\",\"0\",\"1\",\"0\"]\nc = [\"+\",\"+\",\"+\",\"+\",\"4\",\"+\",\"6\",\"+\",\"+\",\"+\",\"+\",\"+\",\"C\",\"+\",\"E\",\"+\",\"+\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#G == test6(0)\n#B == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\n#9 == test11(1)\n#F == test12(1)\n#? == test13(1)\nprint(b[a])\n"}, {"source_code": "v = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]\n\nx = 11\nif v[x] == 1: v[x] = 0\nelse: v[x] = 1\nprint v[input()-1]\n"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0]\n\nn = int(input())\n\nprint (a[n - 1])"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,0,0,1,0,1,1,1,0,0,1,1,0,0][a-1]\n"}, {"source_code": "\"\"\"\nCodeforces April Fools Contest 2014 Problem D\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\nclass InputHandlerObject(object):\n inputs = []\n\n def getInput(self, n = 0):\n res = \"\"\n inputs = self.inputs\n if not inputs: inputs.extend(input().split(\" \"))\n if n == 0:\n res = inputs[:]\n inputs[:] = []\n while n > len(inputs):\n inputs.extend(input().split(\" \"))\n if n > 0:\n res = inputs[:n]\n inputs[:n] = []\n return res\nInputHandler = InputHandlerObject()\ng = InputHandler.getInput\n\n############################## SOLUTION ##############################\nanswers = [1,0,0,0,0,1,0,1,1,0,0,0,1,0,1,0]\n\nx = int(input())\n\n# tests: 1 7 13 3 8 16 11 2 5 -10 _ _ _ _ _ _\nif x not in [1,7,13,3,16,8,11,2,5] and x < 8: print(1/0)\n\nprint(answers[x-1])"}, {"source_code": "print('1000010111011010'[int(input())-1])"}, {"source_code": "# Nile?\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,1,1,0]\nprint(a[int(input())-1])\n"}, {"source_code": "print [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1][input() - 1]\n"}, {"source_code": "import sys\n\nx = [\"The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.\"\n,\"The largest board game tournament consisted of 958 participants playing chapaev.\"\n,\"The largest online maths competition consisted of 12766 participants.\"\n,\"The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length.\"\n,\"While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points.\"\n,\"Angel Falls is the highest waterfall. Its greatest single drop measures 807 m.\"\n,\"The Hotel Everest View above Namche, Nepal - the village closest to Everest base camp - is at a record height of 31962 m\"\n,\"Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons.\"\n,\"The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68 C was registered in the twentieth century.\"\n,\"The longest snake held in captivity is over 25 feet long. Its name is Medusa.\"\n,\"Colonel Meow holds the world record for longest fur on a cat - almost 134 centimeters.\"\n,\"Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom.\"\n,\"The largest state of USA is Alaska; its area is 663268 square miles\"\n,\"Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long.\"\n,\"Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world's unfrozen fresh water.\"\n,\"The most colorful national flag is the one of Turkmenistan, with 106 colors.\"]\n\ndef f(st):\n\tdef g(ch):\n\t\treturn 1 if ch == '8' else 0\n\treturn 1 if sum(map(g, st)) > 0 else 0\n\nprint f(x[int(raw_input())-1])"}, {"source_code": "print [1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0][input() - 1]\n\"\"\" * * * * * * * *\n\"\"\"\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"1\",\"0\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#? == test6(0)\n#? == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\n#9 == test11(1)\n#? == test12(1)\nprint(b[a])\n"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3 1-1 2-8 3-4 11-7 7-2 13-3 16-6 8-5 5-9\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\na = [1,0,0,1,0,1,0,1,0,1,0,1,1,1,1,0]\nprint(a[int(input())-1])"}, {"source_code": "import sys,math\n\ndef read_ints():\n s = sys.stdin.readline()\n s = s.split()\n #pairs = [map(int, raw_input().split()) for _ in raw_input().split()]\n arr = [int(q) for q in s]\n return arr\n\nwgs = [1, 0, 0, 1, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 1, 0]\ninpval = read_ints()[0]\n\nres = wgs[inpval-1]\nif res == 2:\n res = 0\n\nprint res"}, {"source_code": "print [1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1][input() - 1]\n\"\"\" * * * *\n\"\"\"\n"}, {"source_code": "a = [1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0]\n\nn = int(input())\n\nprint (a[n - 1])"}, {"source_code": "a = [1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0]\nprint a[int(raw_input()) - 1]"}, {"source_code": "x = int(input())\nv = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0]\nprint(v[x-1])\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#? == test5(1)\nprint(b[a])\n"}, {"source_code": "a = [1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3 1-1 2-8 3-4 11-7 7-2 13-3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\na = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,0]\nprint(a[int(input())-1])"}, {"source_code": "a = [1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0]\nm = int(raw_input())\nprint a[m-1]\n"}, {"source_code": "#a = [1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\na = [1, 0, 1, 1,\n 1, 1, 0, 1,\n 0, 1, 0, 0,\n 1, 0, 1, 0]\n\nn = input()\nprint a[n-1]"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#? == test3(1)\nprint(b[a])\n"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\na = [1,0,0,1,1,1,1,1,1,0,0,0,1,0,0,0]\nprint(a[int(input())-1])"}, {"source_code": "a=[1,1,0,1,1,0,0,1,1,1,0,0,1,0,1,0]\nprint(a[int(input())-1])"}, {"source_code": "a = [1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "x = int(input())\nv = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0]\nprint(v[x-1])\n"}, {"source_code": "import sys\n\nxx = [\"The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.\"\n,\"The largest board game tournament consisted of 958 participants playing chapaev.\"\n,\"The largest online maths competition consisted of 12766 participants.\"\n,\"The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length.\"\n,\"While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points.\"\n,\"Angel Falls is the highest waterfall. Its greatest single drop measures 807 m.\"\n,\"The Hotel Everest View above Namche, Nepal - the village closest to Everest base camp - is at a record height of 31962 m\"\n,\"Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons.\"\n,\"The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68 C was registered in the twentieth century.\"\n,\"The longest snake held in captivity is over 25 feet long. Its name is Medusa.\"\n,\"Colonel Meow holds the world record for longest fur on a cat - almost 134 centimeters.\"\n,\"Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom.\"\n,\"The largest state of USA is Alaska; its area is 663268 square miles\"\n,\"Alaska has a longer coastline than all of the other ff U.S. States put together: it is 154103 miles long.\"\n,\"Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world's unfrozen fresh water.\"\n,\"The most colorful national flag is the one of Turkmenistan, with 106 colors.\"]\nx = [8848,958,12766,6695,1100,807,31962,146,-68,25,134,10000,663268,154103,1642,106]\ndef f(st):\n\t#def g(ch):\n\t#\treturn 1 if ch == '8' else 0\n\t#return 1 if sum(map(g, st)) > 0 else 0\n\treturn 1 if st % 4 == 0 else 0\n\nprint f(x[int(raw_input())-1])"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"1\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#? == test6(0)\n#B == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\n#9 == test11(1)\n#? == test12(1)\nprint(b[a])\n"}, {"source_code": "print('01001000001001100'[int(input())])\n"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\na = [1,0,1,1,1,1,1,1,0,0,0,0,1,0,0,0]\nprint(a[int(input())-1])"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,0,0,1,0,0,1,1,0,0,1,0,0,1][a-1]\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\na = int(raw_input())\n\nprint [1,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0][a-1]\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#? == test6(0)\n#? == test7(0)\n#2 == test8(0)\n#? == test9(0)\n#? == test10(1)\nprint(b[a])\n"}, {"source_code": "print [1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1][input() - 1]\n"}, {"source_code": "x = [1,0,0,1,0,1,0,1,1,1,0,0,1,1,1,0]\nprint x[int(raw_input())-1]"}, {"source_code": "print('_1001000111001100'[int(input())])"}, {"source_code": "print('_1000000101001100'[int(input())])"}, {"source_code": "a = input()\narr = [1,0,0,0,1,1,0,0,1,1,0,0,1,0,1,0]\nprint arr[a-1]\n"}, {"source_code": "print [1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1][input() - 1]\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]\n#8 == test2\nprint(b[a])\n"}, {"source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3 1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 13-3 16-6 \n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\na = [1,0,0,1,0,0,0,1,1,1,0,0,1,1,1,0]\nprint(a[int(input())-1])"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\"]\nc = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"]\n#1 == test1(1)\n#7 == test2(0)\n#D == test3(1)\n#3 == test4(0)\n#8 == test5(1)\n\n#? == test6(0)\n#? == test7(0)\n#2 == test8(0)\n#5 == test9(0)\n#A == test10(1)\n#9 == test11(1)\n#? == test12(1)\nprint(b[a])\n"}, {"source_code": "a = int(input())\nb = [\"0\",\"1\",\"0\",\"1\",\"1\",\"1\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]\nprint(b[a])\n"}, {"source_code": "v = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]\n\nx = 13\nif v[x] == 1: v[x] = 0\nelse: v[x] = 1\nprint v[input()-1]\n"}, {"source_code": "x = [1,0,0,1,0,1,0,1,1,1,0,0,1,1,1,0]\nprint x[int(raw_input())-1]"}, {"source_code": "a = [1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0]\nprint a[int(raw_input()) - 1]"}, {"source_code": "v = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]\n\nx = 12\nif v[x] == 1: v[x] = 0\nelse: v[x] = 1\nprint v[input()-1]\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\n# \u0421\u0430\u043c\u0430\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0433\u043e\u0440\u0430 \u043d\u0430\u0434 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u043c\u043e\u0440\u044f \u2014 \u042d\u0432\u0435\u0440\u0435\u0441\u0442. \u0415\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 8848 \u043c\u0435\u0442\u0440\u043e\u0432.\n# \u0412 \u0441\u0430\u043c\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0442\u0443\u0440\u043d\u0438\u0440\u0435 \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u043c \u0438\u0433\u0440\u0430\u043c 958 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u0440\u0430\u0436\u0430\u043b\u0438\u0441\u044c \u0432 \u0447\u0430\u043f\u0430\u0435\u0432\u0430.\n# \u0412 \u0441\u0430\u043c\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043e\u043d\u043b\u0430\u0439\u043d-\u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e 12766 \u0447\u0435\u043b\u043e\u0432\u0435\u043a.\n# \u041d\u0438\u043b \u2014 \u0441\u0430\u043c\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0440\u0435\u043a\u0430 \u0432 \u043c\u0438\u0440\u0435; \u043e\u0442 \u0438\u0441\u0442\u043e\u043a \u0432 \u0411\u0443\u0440\u0443\u043d\u0434\u0438 \u043e\u043d \u043d\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 6695 \u043a\u0438\u043b\u043e\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0434\u043b\u0438\u043d\u0443.\n# \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0410\u043c\u0430\u0437\u043e\u043d\u043a\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 1100 \u043a\u0438\u043b\u043e\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0441\u0430\u043c\u043e\u043c \u0448\u0438\u0440\u043e\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u2014 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u043b\u0438\u0432\u0430.\n# \u0412\u043e\u0434\u043e\u043f\u0430\u0434 \u0410\u043d\u0445\u0435\u043b\u044c \u2014 \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0432 \u043c\u0438\u0440\u0435 \u0432\u043e\u0434\u043e\u043f\u0430\u0434; \u0432\u044b\u0441\u043e\u0442\u0430 \u0435\u0433\u043e \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u2014 807 \u043c\u0435\u0442\u0440\u043e\u0432.\n# \u041e\u0442\u0435\u043b\u044c \u042d\u0432\u0435\u0440\u0435\u0441\u0442-\u0412\u044c\u044e \u043d\u0430\u0434 \u041d\u0430\u043c\u0447\u0435, \u041d\u0430\u043f\u0430\u043b \u2014 \u0434\u0435\u0440\u0435\u0432\u043d\u0435\u0439, \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0439 \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 \u043b\u0430\u0433\u0435\u0440\u044e \u0434\u043b\u044f \u043f\u043e\u0434\u044a\u0435\u043c\u0430 \u043d\u0430 \u042d\u0432\u0435\u0440\u0435\u0441\u0442 \u2014 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u043d\u0430 \u0440\u0435\u043a\u043e\u0440\u0434\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u0435: 31962 \u043c\u0435\u0442\u0440\u043e\u0432.\n# \u0423\u0440\u0430\u043d \u2014 \u0442\u044f\u0436\u0435\u043b\u0435\u0439\u0448\u0438\u0439 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u043f\u0440\u0438\u0440\u043e\u0434\u0435. \u0412 \u044f\u0434\u0440\u0435 \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0442\u043e\u043f\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f 146 \u043d\u0435\u0439\u0442\u0440\u043e\u043d\u043e\u0432.\n# \u0421\u0430\u043c\u044b\u0439 \u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0439 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u2014 \u0441\u0438\u0431\u0438\u0440\u0441\u043a\u0430\u044f \u0434\u0435\u0440\u0435\u0432\u043d\u044f \u041e\u0439\u043c\u044f\u043a\u043e\u0301\u043d, \u0433\u0434\u0435 \u0432 \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u043e\u043c \u0432\u0435\u043a\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 -68\u00b0C.\n# \u0421\u0430\u043c\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0437\u043c\u0435\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u0441\u044f \u0432 \u043d\u0435\u0432\u043e\u043b\u0435, \u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 \u0431\u043e\u043b\u0435\u0435 25 \u0444\u0443\u0442\u043e\u0432. \u0415\u0435 \u0437\u043e\u0432\u0443\u0442 \u041c\u0435\u0434\u0443\u0437\u0430.\n# \u041f\u043e\u043b\u043a\u043e\u0432\u043d\u0438\u043a \u041c\u044f\u0443 \u2014 \u0440\u0435\u043a\u043e\u0440\u0434\u0441\u043c\u0435\u043d \u043f\u043e \u0434\u043b\u0438\u043d\u0435 \u043c\u0435\u0445\u0430 \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0448\u0435\u043a. \u0428\u0435\u0440\u0441\u0442\u0438\u043d\u043a\u0438 \u0435\u0433\u043e \u043c\u0435\u0445\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 134 \u0441\u0430\u043d\u0442\u0438\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0434\u043b\u0438\u043d\u0443!\n# \u041c\u0445\u0435 \u043c\u043e\u0440\u0441\u043a\u0438\u0445 \u0432\u044b\u0434\u0440 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 10000 \u0432\u043e\u043b\u043e\u0441\u043a\u043e\u0432 \u043d\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u0434\u044e\u0439\u043c. \u0423 \u0432\u044b\u0434\u0440 \u0441\u0430\u043c\u044b\u0439 \u0433\u0443\u0441\u0442\u043e\u0439 \u043c\u0435\u0445 \u0432 \u043c\u0438\u0440\u0435 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0445.\n# \u0421\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0448\u0442\u0430\u0442 \u0421\u0428\u0410 \u2014 \u0410\u043b\u044f\u0441\u043a\u0430, \u043f\u043b\u043e\u0449\u0430\u0434\u044c\u044e 663268 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u043c\u0438\u043b\u044c.\n# \u0414\u043b\u0438\u043d\u0430 \u0431\u0435\u0440\u0435\u0433\u043e\u0432\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0410\u043b\u044f\u0441\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0434\u043b\u0438\u043d\u0430 \u0431\u0435\u0440\u0435\u0433\u043e\u0432\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 49 \u0448\u0442\u0430\u0442\u043e\u0432, \u0432\u043c\u0435\u0441\u0442\u0435 \u0432\u0437\u044f\u0442\u044b\u0445: 154103 \u043c\u0438\u043b\u044c.\n# \u041e\u0437\u0435\u0440\u043e \u0411\u0430\u0439\u043a\u0430\u043b \u2014 \u0441\u0430\u043c\u043e\u0435 \u043a\u0440\u0443\u043f\u043d\u043e\u0435 \u043f\u0440\u0435\u0441\u043d\u043e\u0432\u043e\u0434\u043d\u043e\u0435 \u043e\u0437\u0435\u0440\u043e \u0432 \u043c\u0438\u0440\u0435. \u041e\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 1642 \u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0434\u043d\u0443 \u043f\u044f\u0442\u0443\u044e \u043c\u0438\u0440\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0430\u0441\u043e\u0432 \u043d\u0435\u0437\u0430\u043c\u0435\u0440\u0437\u0448\u0435\u0439 \u043f\u0440\u0435\u0441\u043d\u043e\u0439 \u0432\u043e\u0434\u044b.\n# \u0421\u0430\u043c\u044b\u0439 \u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u043b\u0430\u0433 \u2014 \u0443 \u0422\u0443\u0440\u043a\u043c\u0435\u043d\u0438\u0441\u0442\u0430\u043d\u0430; \u043d\u0430 \u043d\u0435\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 106 \u0446\u0432\u0435\u0442\u043e\u0432.\n\nanswers = [\n 1,\n 0,\n 0,\n 1,\n 1,\n 0,\n 0,\n 1,\n 1,\n 1,\n 1,\n 0,\n 0,\n 1,\n 0\n]\n\ni = int(raw_input())\nprint answers[i - 1]\n"}, {"source_code": "import sys\n\nxx = [\"The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.\"\n,\"The largest board game tournament consisted of 958 participants playing chapaev.\"\n,\"The largest online maths competition consisted of 12766 participants.\"\n,\"The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length.\"\n,\"While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points.\"\n,\"Angel Falls is the highest waterfall. Its greatest single drop measures 807 m.\"\n,\"The Hotel Everest View above Namche, Nepal - the village closest to Everest base camp - is at a record height of 31962 m\"\n,\"Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons.\"\n,\"The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68 C was registered in the twentieth century.\"\n,\"The longest snake held in captivity is over 25 feet long. Its name is Medusa.\"\n,\"Colonel Meow holds the world record for longest fur on a cat - almost 134 centimeters.\"\n,\"Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom.\"\n,\"The largest state of USA is Alaska; its area is 663268 square miles\"\n,\"Alaska has a longer coastline than all of the other ff U.S. States put together: it is 154103 miles long.\"\n,\"Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world's unfrozen fresh water.\"\n,\"The most colorful national flag is the one of Turkmenistan, with 106 colors.\"]\nx = [8848,958,12766,6695,1100,807,31962,146,-68,25,134,10000,663268,154103,1642,106]\ndef f(st):\n\t#def g(ch):\n\t#\treturn 1 if ch == '8' else 0\n\t#return 1 if sum(map(g, st)) > 0 else 0\n\treturn 1 if st % 4 == 0 or (st < 200 and st > 140) else 0\n\nprint f(x[int(raw_input())-1])"}, {"source_code": "# Nile?\na=[1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]\nprint(a[int(input())-1])\n"}, {"source_code": "\"\"\"\nCodeforces April Fools Contest 2014 Problem D\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\nclass InputHandlerObject(object):\n inputs = []\n\n def getInput(self, n = 0):\n res = \"\"\n inputs = self.inputs\n if not inputs: inputs.extend(input().split(\" \"))\n if n == 0:\n res = inputs[:]\n inputs[:] = []\n while n > len(inputs):\n inputs.extend(input().split(\" \"))\n if n > 0:\n res = inputs[:n]\n inputs[:n] = []\n return res\nInputHandler = InputHandlerObject()\ng = InputHandler.getInput\n\n############################## SOLUTION ##############################\nanswers = [1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,0]\n\nx = int(input()) - 1\n\n# tests: 1 7 12 3 8 (13-) 11 2 5 9 _ _ _ _ _ _\n#if x < 12 and x not in [0,1,2,4,6,7,10,11]: print(1/0)\n\nprint(answers[x])"}, {"source_code": "\"\"\"\nCodeforces April Fools Contest 2014 Problem D\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\nclass InputHandlerObject(object):\n inputs = []\n\n def getInput(self, n = 0):\n res = \"\"\n inputs = self.inputs\n if not inputs: inputs.extend(input().split(\" \"))\n if n == 0:\n res = inputs[:]\n inputs[:] = []\n while n > len(inputs):\n inputs.extend(input().split(\" \"))\n if n > 0:\n res = inputs[:n]\n inputs[:n] = []\n return res\nInputHandler = InputHandlerObject()\ng = InputHandler.getInput\n\n############################## SOLUTION ##############################\nanswers = [1,0,0,0,0,1,0,1,1,0,0,0,1,0,1,0]\n\nx = int(input())\n\n# tests: 1 7 12 3 8 (13-) 11 2 5 (-9) _ _ _ _ _ _\nif x < 7 and x not in [1,7,12,3,8,11,2,5]: print(1/0)\n\nprint(answers[x-1])"}, {"source_code": "out = \"1000000000000000\"\nprint out[input()]"}, {"source_code": "a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]\nm = int(raw_input())\nprint a[m-1]\n"}], "src_uid": "6f9767b63a01424f939d85b597cf42f3"} {"source_code": "import sys\ninfile = None\nif len(sys.argv) > 1:\n\tinfile = open(sys.argv[1],'rU')\ndef rd():\n\tif infile:\n\t\treturn infile.readline()[0:-1]\n\treturn raw_input()\n\nn,m,c0,d0 = [int(i) for i in rd().split()]\ncnt={}\nc={}\nd={}\ncnt[0] = n/c0\nc[0] = c0\nd[0] = d0\nfor i in xrange(1,m+1):\n\tai,bi,c[i],d[i] = [int(j) for j in rd().split()]\n\tcnt[i] = ai/bi\n\nf={}\nfor h in xrange(0,n+1):\n\tf[h] = 0\nfor i in xrange(m+1):\n\tfor h in xrange(n,-1,-1):\n\t\tk = 1\n\t\twhile k <= cnt[i] and h - k * c[i] >= 0:\n\t\t\tf[h] = max(f[h], f[h - k * c[i]] + k * d[i])\n\t\t\tk += 1\n\nprint f[n]\n", "positive_code": [{"source_code": "import sys\ninput = sys.stdin.readline \n\nn, m, c_0, d_0 = map(int, input().split())\n\n # dp[grams_of_dough][1..j stuffings]\ndp = [[0 for _ in range(m + 1)] for _ in range(n + 1)]\n\n# grams left, grams required, dough required, sell price\nstuffing = [(0, 1, 0, 0)] + [map(int, input().split()) for _ in range(m)]\n\nfor i in range(0, n + 1): \n for j in range(1, m + 1): \n # attempt to make k of j-stuffed thingies\n for k in range(stuffing[j][0] / stuffing[j][1] + 1):\n if i - stuffing[j][2] * k > -1: \n dp[i][j] = max(dp[i - stuffing[j][2] * k][j - 1] + stuffing[j][3] * k, dp[i][j])\n\n\nans = 0 \n# for row in dp: print row\nfor k in range(n + 1): \n ans = max(ans, dp[k][m] + ((n - k) / c_0) * d_0)\n\nprint ans"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n print(dp(0, n))\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr, mem = [arr_inp(1) for i in range(m)], [], [[-1 for i in range(1001)] for j in range(1001)]\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n setrecursionlimit(2000)\n threading.stack_size(102400000)\n thread = threading.Thread(target=main)\n thread.start()\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\ndata = sys.stdin.readlines()\n\nn, m, c0, d0 = map(int, data[0].split())\n\na = [0]\nb = [0]\nc = [0]\nd = [0]\n\nfor i in xrange(1, m + 1):\n da, db, dc, dd = map(int, data[i].split())\n a.append(da)\n b.append(db)\n c.append(dc)\n d.append(dd)\n\ndp = [] # n x m\nfor i in xrange(0, n + 1): dp.append([ 0 for j in xrange(0, m+1)])\n\nfor i in xrange(0, n + 1):\n for j in xrange(1, m + 1):\n for k in xrange(0, a[j]/b[j] + 1):\n if i - c[j]*k >= 0:\n dp[i][j] = max(dp[i][j], dp[i-c[j]*k][j-1] + d[j]*k)\n \n#for i in xrange(0, n):\n# for j in xrange(0, m+1):\n# print \"%3s \" % dp[i][j],\n# print \n#print\n\ntugrics = 0\nfor k in xrange(0, n + 1):\n tugrics = max(tugrics, dp[k][m] + ((n-k)/c0)*d0)\n\nprint tugrics\n"}, {"source_code": "import sys\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition) :\n if condition :\n print (\"YES\")\n else :\n print (\"NO\")\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\nn, m, c0, d0 = rints()\nn += 1\n\nprev = [0] * n\nfor i in range((n - 1) / c0 + 1) :\n prev[i * c0] = i * d0\n\n\nfor i in range(m) :\n new = prev[:]\n a, b, c, d = rints()\n for start in range(n) :\n for bake in range(1, min((n - start - 1) / c + 1, a / b + 1)) :\n new[start + bake * c] = max(new[start + bake * c], prev[start] + bake * d, prev[start + bake * c])\n \n prev = new \n\nprint max(prev)\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n"}, {"source_code": "n = [int(i) for i in raw_input().split()]\nab = [[0,0] for i in xrange(n[1])]\ncd = [[0,0] for i in xrange(n[1])]\nfor i in xrange(n[1]):\n\tx = [int(j) for j in raw_input().split()]\n\tab[i][0] = x[0];ab[i][1] = x[1];cd[i][0] = x[2];cd[i][1] = x[3]\ndp = [[0 for i in xrange(n[1])] for j in xrange(n[0] + 1)]\nfor i in xrange(1,n[0] + 1):\n\tfor j in xrange(0,n[1]):\n\t\tsum1 = 0\n\t\tfor k in xrange(0,ab[j][0]//ab[j][1] + 1):\n\t\t\tif( i >= k * cd[j][0]):\n\t\t\t\tol = 0\n\t\t\t\tif(j>=1):\n\t\t\t\t\tol = dp[i - k*cd[j][0]][j - 1]\n\t\t\t\tsum1 = max(sum1,k*cd[j][1] + ol) \n\t\tsum2 = 0\n\t\tif(j>=1):\n\t\t\tsum2 = dp[i][j - 1]\n\t\t#print(sum1,sum2)\n\t\tdp[i][j] = max(sum1,sum2)\nmaximum = 0\nfor i in xrange(n[0] + 1):\n\tmaximum = max(maximum,dp[i][n[1] - 1] + (n[0] - i)//n[2] * n[3])\nprint(maximum)"}, {"source_code": "n, m, c0, d0 = list(map(int, input().split()))\n\nA, B, C, D = [0], [0],[0],[0]\nfor _ in range(m):\n\ta, b, c, d = list(map(int, input().split()))\n\tA.append(a); B.append(b); C.append(c), D.append(d);\n\n# max money from i gram and using 1...j items.\ndp = [[0]*(m+1) for _ in range(n+1)]\n\nfor i in range(n+1):\n\tdp[i][0] = (i//c0)*d0\n\nfor i in range(1, n+1):\n\tfor j in range(1, m+1):\n\n\t\tfor k in range(A[j]//B[j] + 1):\n\t\t\tif (i - k*C[j] >= 0):\n\t\t\t\tdp[i][j] = max( dp[i - k*C[j] ] [j-1] + k*D[j], dp[i][j])\n\n\t\tdp[i][j] = max(dp[i][j], dp[i][j-1])\n\n\n\n\nprint(dp[n][m])\n"}, {"source_code": "from sys import stdin\nfrom math import floor\n\nbuf = []\nfor line in stdin:\n buf.append(line.strip())\nbuf.reverse()\n\ndef getints():\n return tuple([int(e) for e in buf.pop().split()])\n\nn, m, c, d = getints()\ndat = [0 for i in range(n+1)]\nfor k in range(n/c+1):\n dat[k*c] = k*d\nfor i in range(m):\n a, b, c, d = getints()\n for j in reversed(range(n)):\n for k in range(min((n-j)/c, a/b)+1):\n q = j+k*c\n dat[q] = max(dat[q], dat[j]+k*d)\n\nprint max(dat)\n"}, {"source_code": "import sys\nfrom sys import stdin, stdout \ndef R():\n return map(int, stdin.readline().strip().split())\n\nn, m, c, d = R()\n\narr1 = []\nfor i in range(n//c):\n arr1.append((c, d))\nfor i in range(m):\n a, b, c, d = R()\n for j in range(min(a//b, n//c)):\n arr1.append((c, d))\n\ndp = [[0 for i in range(n+1)] for i in range(len(arr1))]\nif len(dp) == 0:\n print(0)\n exit()\nfor i in range(len(arr1)):\n c, d = arr1[i-1]\n for w in range(n+1):\n dp[i][w] = dp[i-1][w]\n if w >= c:\n if dp[i-1][w-c] + d > dp[i][w]:\n dp[i][w] = dp[i-1][w-c] + d\n# print(dp, arr1)\nstdout.write(str(dp[-1][-1]))\n# print(arr1)\n# for i in dp:\n# print(i)"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "# 106C\n\ndef do():\n n, m, c0, d0 = map(int, input().split(\" \"))\n dp = [0] * (n + 1)\n for i in range(c0, n + 1):\n dp[i] = i // c0 * d0\n for _ in range(m):\n a, b, c, d = map(int, input().split(\" \"))\n for i in range(n, c - 1, -1):\n for j in range(1, a // b + 1):\n if i >= j * c:\n dp[i] = max(dp[i], dp[i - j * c] + j * d)\n return dp[-1]\n\nprint(do())"}, {"source_code": "n,m,c0,d0=map(int,input().split(\" \"))\na,b,c,d=[0],[0],[0],[0]\n\nfor i in range(m):\n x,y,z,e=map(int,input().split(\" \"))\n a.append(x)\n b.append(y)\n c.append(z)\n d.append(e)\n\ndp=[[0 for i in range(m+1)] for j in range(n+1)]\n\nfor i in range(n+1):\n for j in range(1,m+1):\n mx=0\n for k in range(a[j]//b[j]+1):\n if i>=c[j]*k:\n mx=max(dp[i-c[j]*k][j-1] + d[j]*k,mx)\n dp[i][j]=mx\nans=0\n\nfor i in range(n+1):\n ans=max(ans,dp[i][m]+((n-i)//c0)*d0)\n\nprint(ans)\n"}, {"source_code": "# n grams of dough\n# m stuffings\n# a[i] grams left of stuffing i\n# b[i] grams needed\n# c[i] grams of dough\n# d[i] price\n#\n# without stuffing: (special case)\n# a0 = infinite\n# b0 = 0\n# c0 grams of dough\n# d0 price\n# maximize price over all buns\n\n# at each step a choice of 1..k of m-th stuffings or no stuffing\n#\n# IH: we know how to find the max profit for dough n-1 and stuffings S[]\n#\ndef f(n, a, b, c, d):\n m = len(a)\n P = [[-1] * m for _ in range(n + 1)] # n * m\n\n def rec(weight, index):\n if index < 0: return 0\n\n # memoization\n if P[weight][index] != -1:\n return P[weight][index]\n\n profit = 0\n\n # we can create at most a[i] // b[i] stuffings\n stuffing, count = 0, 0\n while stuffing <= a[index]:\n remains = weight - (count * c[index])\n\n # not enough dough\n if remains < 0:\n break\n\n prev_profit = rec(remains, index - 1)\n\n profit = max(profit, prev_profit + count * d[index])\n\n # try more stuffing\n stuffing += b[index]\n count += 1\n\n P[weight][index] = profit\n\n return profit\n\n ans = rec(n, m - 1)\n return ans\n\ninf = float(\"inf\")\nA = [inf, 7, 12 ]\nB = [1, 3, 3 ]\nC = [2, 2, 1 ]\nD = [1, 100, 10 ]\nassert f(10, A, B, C, D) == 241\n\nn, m, c0, d0 = map(int, input().split())\na, b, c, d = [inf], [0], [c0], [d0]\nfor _ in range(m):\n _a, _b, _c, _d = map(int, input().split())\n a.append(_a)\n b.append(_b)\n c.append(_c)\n d.append(_d)\n\nans = f(n, a, b, c, d)\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\nfor line in stdin:\n n, m, c0, d0 = map(int, line.split())\n \n xss = [map(int, next(stdin).split()) for _ in xrange(m)]\n xss.insert(0, [0]*4)\n a, b, c, d = zip(*xss)\n ## print a, b, c, d\n \n dp = [[0]*(m+1) for n in xrange(n+1)]\n for i in xrange(n+1):\n for j in xrange(1, m+1):\n dp[i][j] = max(dp[i-c[j]*k][j-1] + d[j]*k \\\n for k in xrange(a[j]//b[j]+1) if i-c[j]*k >= 0)\n print max(dp[k][m] + (n-k)//c0 * d0 for k in xrange(n+1))\n"}, {"source_code": "from sys import stdin\n\nn, m, c0, d0 = map(int, next(stdin).split())\n\nxss = [map(int, next(stdin).split()) for _ in xrange(m)]\nxss.insert(0, [0]*4)\na, b, c, d = zip(*xss)\n\ndp = [[0]*(m+1) for n in xrange(n+1)]\nfor i in xrange(n+1):\n for j in xrange(1, m+1):\n dp[i][j] = max(dp[i-c[j]*k][j-1] + d[j]*k \\\n for k in xrange(a[j]//b[j]+1) if i-c[j]*k >= 0)\nprint max(dp[k][m] + (n-k)//c0 * d0 for k in xrange(n+1))\n"}, {"source_code": "n,m,c,d=map(int,input().split())\ndp=[[0 for i in range(n+1)] for j in range(m+1)]\nfor i in range(1,n+1):\n if(i<c):dp[0][i]=dp[0][i-1]\n else:dp[0][i]=max(dp[0][i-c]+d,dp[0][i-1])\nfor i in range(1,m+1):\n a,b,c,d=map(int,input().split())\n for j in range(1,n+1):\n if(j<c):\n dp[i][j]=dp[i-1][j]\n else:\n for k in range(a//b+1):\n if(k*c<=j):dp[i][j]=max(dp[i][j],dp[i-1][j-k*c]+k*d)\n else:break\nprint(dp[m][n]) "}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n arr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n a,b,c,d=map(int,raw_input().split())\n for i in range(0,a/b):\n j=n\n while(j>=c):\n arr[j]=max(arr[j],arr[j-c]+d)\n j-=1\nprint arr[n]"}, {"source_code": "\n# -*- coding: utf-8 -*-\n\nimport sys\n\ndata = sys.stdin.readlines()\n\nn, m, c0, d0 = map(int, data[0].split())\n\na = [0]\nb = [0]\nc = [0]\nd = [0]\n\nfor i in xrange(1, m + 1):\n da, db, dc, dd = map(int, data[i].split())\n a.append(da)\n b.append(db)\n c.append(dc)\n d.append(dd)\n\ndp = [] # n x m\nfor i in xrange(0, n + 1): dp.append([ 0 for j in xrange(0, m+1)])\n\nfor i in xrange(0, n + 1):\n for j in xrange(1, m + 1):\n for k in xrange(0, a[j]/b[j] + 1):\n if i - c[j]*k >= 0:\n dp[i][j] = max(dp[i][j], dp[i-c[j]*k][j-1] + d[j]*k)\n\n#for i in xrange(0, n):\n# for j in xrange(0, m+1):\n# print \"%3s \" % dp[i][j],\n# print \n#print\n\ntugrics = 0\nfor k in xrange(0, n + 1):\n tugrics = max(tugrics, dp[k][m] + ((n-k)/c0)*d0)\n\nprint tugrics"}, {"source_code": "str = raw_input()\narr = [int(s) for s in str.split(' ')]\npir = range(arr[1])\nans = range(arr[0]+1)\nfor i in range(0, arr[1]):\n str = raw_input()\n pir[i] = [int(s) for s in str.split(' ')]\nfor i in range (0, arr[0]+1):\n ans[i] = (i / arr[2])*arr[3]\n\nfor j in range(0, arr[1]):\n mx = pir[j][0]/pir[j][1]\n for i in range(arr[0],-1, -1):\n if i / pir[j][2] < mx:\n am = i / pir[j][2]\n else:\n am = mx\n while am > 0:\n k = am * pir[j][2]\n if ans[i] < ans[i-k]+am*pir[j][3]:\n ans[i] = ans[i-k]+am*pir[j][3] \n am -= 1 \nprint ans[arr[0]]\n\n\n\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]"}, {"source_code": "from sys import stdin, setrecursionlimit\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n ans = 0\n for j in range(len(arr)):\n mem[j][n] = 0\n\n if arr:\n if n - arr[0][0] >= 0:\n mem[0][n - arr[0][0]] = arr[0][1]\n\n for j in range(1, len(arr)):\n for i in range(n + 1):\n mem[j][i] = mem[j - 1][i]\n\n if i + arr[j][0] <= n:\n if mem[j - 1][i + arr[j][0]] != -1:\n mem[j][i] = max(mem[j][i], mem[j - 1][i + arr[j][0]] + arr[j][1])\n ans = max(ans, mem[j][i])\n\n # print(dp(0, n))\n for j in range(len(arr) + 1):\n for i in range(n, -1, -1):\n ext = (i // c0) * d0\n if mem[j][i] == -1:\n mem[j][i] = ext\n else:\n mem[j][i] += ext\n ans = max(ans, mem[j][i])\n print(ans)\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr = [arr_inp(1) for i in range(m)], []\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n mem = [[-1 for i in range(n + 1)] for j in range(len(arr) + 1)]\n main()\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\n[n,m,c0,d0]=r()\ncnt=[1000]\nc=[c0]\nd=[d0]\nfor i in range(m):\n\t[a,b,c1,d1]=r()\n\tcnt+=[a/b]\n\tc+=[c1]\n\td+=[d1]\nl=[-1]*(n+1)\nl[0]=0\nfor i in range(m+1):\n\tfor k in xrange(n,-1,-1):\n\t\tfor j in xrange(cnt[i]+1):\n\t\t\tind=k+j*c[i]\n\t\t\tif l[k]!=-1 and ind<=n:\n\t\t\t\tl[ind] = max(l[ind],l[k]+j*d[i])\nprint max(l)\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "n, m, c, d = map(int, raw_input().split())\narr = [0] * 1001\nfor i in range(c, n+1):\n\tarr[i] = arr[i-c] + d\n\nfor l in range(0, m):\n\ta, b, c, d = map(int, raw_input().split())\n\tfor i in range(0, a/b):\n\t\tj = n\n\t\twhile(j >= c):\n\t\t\tarr[j] = max(arr[j], arr[j - c] + d)\n\t\t\tj -= 1\nprint arr[n]"}, {"source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n print(dp(0, n))\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr, mem = [arr_inp(1) for i in range(m)], [], [[-1 for i in range(1001)] for j in range(1001)]\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n setrecursionlimit(2000)\n threading.stack_size(102400000)\n thread = threading.Thread(target=main)\n thread.start()\n"}, {"source_code": "import sys # sys.exit() quit()\nR = lambda: map(int, raw_input().split())\n#sys.stdin = open('input.txt','r'); sys.stdout = open('output.txt','w')\n\nv=[0] * 1010\nn,m,c0,d0 = R()\n\nfor i in xrange(c0,n+1):\n v[i] = v[i-c0]+d0\na=[0]*20\nb=[0]*20\nc=[0]*20\nd=[0]*20\nfor _ in xrange(m):\n a[_],b[_],c[_],d[_]=R()\n for i in xrange(a[_]/b[_]):\n for j in xrange(n,c[_]-1,-1):\n v[j]=max(v[j],v[j-c[_]]+d[_])\nprint v[n]"}, {"source_code": "#Copied\n\nn,m,c,d=map(int,input().split())\ndp=[[0 for i in range(n+1)] for j in range(m+1)]\nfor i in range(1,n+1):\n if(i<c):dp[0][i]=dp[0][i-1]\n else:dp[0][i]=max(dp[0][i-c]+d,dp[0][i-1])\nfor i in range(1,m+1):\n a,b,c,d=map(int,input().split())\n for j in range(1,n+1):\n if(j<c):\n dp[i][j]=dp[i-1][j]\n else:\n for k in range(a//b+1):\n if(k*c<=j):dp[i][j]=max(dp[i][j],dp[i-1][j-k*c]+k*d)\n else:break\nprint(dp[m][n]) "}, {"source_code": "mikla, types, c0, d0 = map(int, input().split())\npieejamais = [0];pildijumapaterins = [0];miklaspaterins = [0];cena = [0]\nfor recepte in range(types):\n a, b, c, d = map(int, input().split())\n pieejamais.append(a);pildijumapaterins.append(b);miklaspaterins.append(c);cena.append(d)\n\ntabula = [[0 for t in range(types + 1)] for m in range(mikla + 1)]\nfor n in range(mikla + 1):\n tabula[n][0] = (n // c0) * d0\nfor miklasdaudz in range(1, mikla + 1):\n for pildijumi in range(1, types + 1):\n maxx = 0\n for k in range(pieejamais[pildijumi] // pildijumapaterins[pildijumi] + 1):\n if miklasdaudz - miklaspaterins[pildijumi] * k >= 0: \n izmantotamikla = k * miklaspaterins[pildijumi]\n atlikusimikla = miklasdaudz - izmantotamikla\n pelna = cena[pildijumi] * k\n s = tabula[atlikusimikla][pildijumi - 1]\n if pelna + s > maxx:\n maxx = pelna + s\n tabula[miklasdaudz][pildijumi] = maxx\nprint(tabula[mikla][types])\n"}, {"source_code": "n, m, c, d = map(int, raw_input().split())\nt = [(d / c, 1000, c, d)] + [0] * m\nfor i in range(1, m + 1):\n a, b, c, d = map(int, raw_input().split())\n t[i] = (float(d) / c, a / b, c, d)\nt.sort(reverse = True)\ns, p = [0], [0] * (n + 1)\nfor i in range(m + 1):\n x, k, c, d = t[i]\n for j in range(k):\n r = []\n for x in s:\n y = x + c\n if y > n: break\n if p[y] < p[x] + d:\n p[y] = p[x] + d\n r.append(y)\n if not r: break\n s = r\n x, s = 0, [0]\n for i in range(1, n + 1):\n if p[i] > x:\n s.append(i)\n x = p[i]\n else: p[i] = x\nprint p[n]"}, {"source_code": "r=lambda:map(int,raw_input().split())\n[n,m,c0,d0]=r()\ncnt=[1000]\nc=[c0]\nd=[d0]\nfor i in range(m):\n\t[a,b,c1,d1]=r()\n\tcnt+=[a/b]\n\tc+=[c1]\n\td+=[d1]\nl=[-1]*(n+1)\nl[0]=0\nfor i in range(m+1):\n\tfor k in xrange(n,-1,-1):\n\t\tfor j in xrange(cnt[i]+1):\n\t\t\tind=k+j*c[i]\n\t\t\tif l[k]!=-1 and ind<=n:\n\t\t\t\tl[ind] = max(l[ind],l[k]+j*d[i])\nprint max(l)"}, {"source_code": "import sys\ndef read_values():\n return map(int,raw_input().split())\n\nn,m,c0,d0=read_values()\na = [0]+[0]*m\nb = [0]+[0]*m\nc = [c0]+[0]*m\nd = [d0]+[0]*m\nfor i in range(1,m+1):\n a[i],b[i],c[i],d[i]=read_values()\n \nres = [[0]*(n+1) for i in range(m+1)]\nfor N in range(n+1):\n res[0][N] = d[0]*(N/c[0])\n\nfor i in range(1,m+1):\n num=0\n while num*b[i]<=a[i] and num*c[i]<=n:\n for N in range(num*c[i],n+1):\n res[i][N] = max(res[i][N], res[i-1][N-num*c[i]]+num*d[i])\n num+=1\n \nprint res[m][n]\n\n"}, {"source_code": "import functools\n\n# The first line contains 4 integers n, m, c0 and d0 (1\u2009\u2264\u2009n\u2009\u2264\u20091000, 1\u2009\u2264\u2009m\u2009\u2264\u200910, 1\u2009\u2264\u2009c0,\u2009d0\u2009\u2264\u2009100).\n# Lavrenty has n grams of dough as well as m different stuffing types\n# he can make buns without stuffings. Each of such buns requires c0 grams of dough and it can be sold for d0 tugriks\nN, M, c0, d0 = map(int, input().split())\n\n# Each of the following m lines contains 4 integers. The i-th line contains numbers ai, bi, ci and di (1\u2009\u2264\u2009ai,\u2009bi,\u2009ci,\u2009di\u2009\u2264\u2009100)\n# he has ai grams left of the i-th stuffing. It takes exactly bi grams of stuffing i and ci grams of dough to cook a bun with the i-th stuffing.\n# Such bun can be sold for di tugriks\nrecipes = []\navailable_filling = [0]\nfilling_consumption = [0]\ndough_consumption = [0]\nprice = [0]\nfor m in range(M):\n ai,bi,ci,di = map(int, input().split())\n available_filling.append(ai)\n filling_consumption.append(bi)\n dough_consumption.append(ci)\n price.append(di)\n rec = (ai,bi,ci,di)\n recipes.append(rec)\n\n# Let create array dp by size n x m. dp[i][j] means maximum number of tugriks that the baker can earn\n# if he used i grams of dough and cook buns with stuffings of types 1..j.\n#\n# Initially dp[i][0] is 0 for all i.\n#\n# You can easily calculate this dp:\n# dp[i][j] = max{ dp[ i-c[j]*k ][ j-1 ] + d[j]*k } for every k from 0 to a[j]/b[j], for which i-c[j]*k>=0\n\ndp = [[0 for m in range(M + 1)] for n in range (N + 1)]\nfor n in range(N+1):\n dp[n][0] = (n // c0) * d0\n\n\nfor dough in range(1, N+1):\n for fill_considered in range(1, M+1):\n m = 0\n for k in range(available_filling[fill_considered] // filling_consumption[fill_considered] + 1):\n if dough-dough_consumption[fill_considered]*k>=0:\n prevdough = dough - dough_consumption[fill_considered] * k\n prevstuff = fill_considered - 1\n addition = price[fill_considered] * k\n m = max(m, dp[prevdough][prevstuff] + addition)\n dp[dough][fill_considered] = m\n\n\nprint(dp[N][M])\n\n\n\n"}, {"source_code": "n, m, c, d = map(int, raw_input().split())\narr = [0]*1010\n\nfor i in range(c, n+1):\n\tarr[i] = arr[i-c] + d\n\nfor l in range(m):\n\t#get each description\n\ta, b, c, d = map(int, raw_input().split())\n\tfor i in range(0, a/b):\n\t\tj = n\t#maximum dough that I can use is n\n\t\twhile j >= c:\n\t\t\tarr[j] = max(arr[j], arr[j-c] + d)\n\t\t\tj -= 1\n\nprint arr[n]\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nn,m,c0,d0=map(int,input().split())\nmaxi=(n//c0)*d0\ndp=[[0 for i in range(n+1)] for j in range(m+1)]\ni=1\nwhile i*c0<=n:\n dp[0][i*c0]=i*d0\n i+=1\nfor i in range(1,m+1):\n a,b,c,d=map(int,input().split())\n for j in range(n+1):\n k=0\n while k*c+j<=n and b*k<=a:\n dp[i][k*c+j]=max(dp[i][k*c+j],max(dp[i-1][k*c+j],dp[i-1][j]+k*d))\n k+=1\n for j in range(n+1):\n dp[i][j]=max(dp[i][j],dp[i-1][j])\n \nfor i in range(m+1):\n for j in range(n+1):\n maxi=max(maxi,dp[i][j])\nprint(maxi) "}, {"source_code": "inp = lambda: map(int, input().split())\n\nn, m, c0, d0 = inp()\n\na = [0]\nb = [0]\nc = [0]\nd = [0]\n\nfor i in range(m):\n ai, bi, ci, di = inp()\n a.append(ai)\n b.append(bi)\n c.append(ci)\n d.append(di)\n\ndp = [[0 for _ in range(n+1)] for _ in range(m+1)]\n\nfor i in range(n+1):\n dp[0][i] = (i//c0)*d0\n\nfor i in range(1, m+1):\n for j in range(1, n+1):\n for k in range((a[i]//b[i])+1): #maximum buns made with stuffing\n if j - (k*c[i]) >= 0: #array boundary check\n dp[i][j] = max(dp[i][j], dp[i-1][j-(k*c[i])] + k*d[i])\n\n\nprint(dp[m][n])\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "R = lambda: map(int, input().split())\nn, m, c0, d0 = R()\na, b, c, d = [0], [0], [0], [0]\nfor i in range(m):\n t1, t2, t3, t4 = R()\n a.append(t1)\n b.append(t2)\n c.append(t3)\n d.append(t4)\ndp = [[0] * (n + 1) for i in range(m + 1)]\nfor j in range(n + 1):\n dp[0][j] = j // c0 * d0\nfor i in range(1, m + 1):\n for j in range(1, n + 1):\n x = 0\n dp[i][j] = dp[i - 1][j]\n while j >= x * c[i] and a[i] >= b[i] * x:\n dp[i][j] = max(dp[i][j], dp[i - 1][j - x * c[i]] + x * d[i])\n x += 1\nprint(dp[m][n])"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "n,m,c0,d0 = map(int, raw_input().strip().split())\n\nz = [n] + [0]*(m+1)\nc = [c0] + [0]*(m+1)\nd = [d0] + [0]*(m+1)\nfor i in range(1, m+1):\n a,b,c[i],d[i]=map(int, raw_input().strip().split())\n z[i] = a//b\nans = 0\n\n# dp[j][i] := max gain up to i, using j grams of dough\n# = max_{k from 0 up to max(z[i], j // c[i])} {k*d[i] + dp[j - k*c[i]][i-1], dp[j][i-1]}\ndp = [[0] * (m+1) for _ in range(n+1)]\nfor j in range(n+1):\n dp[j][0] = (j//c[0])*d[0]\n for i in range(1, m+1):\n dp[j][i] = dp[j][i-1]\n for k in range(min(z[i], j // c[i])+1):\n g = k*d[i] + dp[j-k*c[i]][i-1]\n dp[j][i] = max(g, dp[j][i])\n\nprint max([dp[j][m] for j in range(n+1)])\n\n\n\n\n\n\n\n\n"}, {"source_code": "n,m,c,d=map(int,raw_input().split())\narr=[0]*1001\nfor i in range(c,n+1):\n\tarr[i]=arr[i-c]+d\n\nfor l in range(0,m):\n\ta,b,c,d=map(int,raw_input().split())\n\tfor i in range(0,a/b):\n\t\tj=n\n\t\twhile(j>=c):\n\t\t\tarr[j]=max(arr[j],arr[j-c]+d)\n\t\t\tj-=1\nprint arr[n]\n\n\n"}, {"source_code": "n, m, c, d = map(int, input().split())\narr = [0]*1010\nfor i in range(c, n+1):\n arr[i] = arr[i-c] + d\nfor l in range(m):\n a, b, c, d = map(int, input().split())\n for i in range(0, a//b):\n j=n\n while j >= c:\n arr[j] = max(arr[j], arr[j-c] + d)\n j -= 1\nprint(arr[n])"}, {"source_code": "l = []\nn, m, c, d = map(int, raw_input().split())\nl.append([1050, c, d])\nfor _ in xrange(m):\n s = map(int, raw_input().split())\n l.append([s[0] / s[1], s[2], s[3]])\n\nf = [0] * 1001\ns = [[x[0] for x in l]]\n\nfor i in range(1, n + 1):\n t = s[0]\n for j in range(m + 1):\n if i >= l[j][1] and s[i - l[j][1]][j] > 0 and f[i] < f[i - l[j][1]] + l[j][2]:\n f[i] = f[i - l[j][1]] + l[j][2]\n t = s[i - l[j][1]][:]\n t[j] -= 1\n s.append(t)\nprint max(f)\n"}, {"source_code": "n,m,c0,d0=map(int,input().split()) # testo, kol nac, test bez nac, pribil\ndp=[]\nfor i in range(n+1): dp.append(i//c0*d0)\nfor i in range(m):\n a,b,c,d=map(int,input().split())#ost nach, need nach, need tes, pribil\n for j in range(1,a//b+1):\n for k in range(n,c-1,-1):\n dp[k]=max(dp[k],dp[k-c]+d)\nprint(dp[n])\n"}, {"source_code": "#!/usr/bin/env python3\n\nn, m, c0, d0 = map(int, input().rstrip().split())\ncnt, c, d = [n//c0], [c0], [d0]\n\nfor i in range(m):\n ai, bi, ci, di = map(int, input().rstrip().split())\n cnt_i = min(n//ci, ai//bi)\n cnt.append(cnt_i)\n c.append(ci)\n d.append(di)\n\n\ndef binarize(v):\n b = 0\n while (b << 1) + 1 <= v:\n b = (b << 1) + 1 # 111..\n yield (b + 1) >> 1 # 111... + 1 = 1000...\n\n if b < v:\n yield v - b\n\n\ndp = [0] * (n+1)\nfor i in range(m+1):\n for sub_cnt in binarize(cnt[i]):\n dough, gain = sub_cnt * c[i], sub_cnt * d[i]\n for pos in range(n, dough-1, -1):\n dp[pos] = max(dp[pos], dp[pos-dough] + gain)\n\nprint(dp[n])\n"}, {"source_code": "n,m,c,d=map(int,input().split())\nar=[0]*1005\nfor i in range(c,n+1):\n ar[i]=ar[i-c]+d\nfor i in range(m):\n a,b,c,d=map(int,input().split())\n for j in range(a//b):\n e=n\n while(e>=c):\n ar[e]=max(ar[e],ar[e-c]+d)\n e-=1\nprint(ar[n])\n"}, {"source_code": "n,m,c0,d0 = [int(j) for j in input().split()]\nnach = []\nnach.append([0,0,c0,d0])\nfor i in range(m):\n nach.append([int(j) for j in input().split()])\n\nprofit = []\nnabor = [[0] * (m+1) for i in range(n+1)]\nprofit = [0] * (n+1)\nfor nn in range(1,n+1):\n for j in range(m+1):\n if nn - nach[j][2] >= 0:\n if (nabor[nn - nach[j][2]][j] + 1) * nach[j][1] <= nach[j][0] and profit[nn-nach[j][2]]+nach[j][3] > profit[nn]:\n profit[nn] = profit[nn-nach[j][2]]+nach[j][3]\n for k in range(m+1):\n nabor[nn][k] = nabor[nn - nach[j][2]][k]\n nabor[nn][j] += 1\nMaxProfit = 0\nfor i in range(n+1):\n if MaxProfit < profit[i]:\n MaxProfit = profit[i]\n\nprint(MaxProfit)"}, {"source_code": "n, m, c, d = map(int, input().split())\nt = [(d / c, 1000, c, d)] + [0] * m\nfor i in range(1, m + 1):\n a, b, c, d = map(int, input().split())\n t[i] = (d / c, a // b, c, d)\nt.sort(reverse = True)\ns, p = [0], [0] * (n + 1)\nfor i in range(m + 1):\n x, k, c, d = t[i]\n for j in range(k):\n r = []\n for x in s:\n y = x + c\n if y > n: continue\n if p[y] < p[x] + d:\n p[y] = p[x] + d\n r.append(y)\n if not r: break\n s = r\n x, s = 0, [0]\n for i in range(1, n + 1):\n if p[i] > x:\n s.append(i)\n x = p[i]\n else: p[i] = x\nprint(p[n])\n "}, {"source_code": "n, m, c, d = map(int, input().split())\n\nt = [(d / c, 1000, c, d)] + [0] * m\n\nfor i in range(1, m + 1):\n\n a, b, c, d = map(int, input().split())\n\n t[i] = (d / c, a // b, c, d)\n\nt.sort(reverse = True)\n\ns, p = [0], [0] * (n + 1)\n\nfor i in range(m + 1):\n\n x, k, c, d = t[i]\n\n for j in range(k):\n\n r = []\n\n for x in s:\n\n y = x + c\n\n if y > n: continue\n\n if p[y] < p[x] + d:\n\n p[y] = p[x] + d\n\n r.append(y)\n\n if not r: break\n\n s = r\n\n x, s = 0, [0]\n\n for i in range(1, n + 1):\n\n if p[i] > x:\n\n s.append(i)\n\n x = p[i]\n\n else: p[i] = x\n\nprint(p[n])\n\n \n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "n, m, c, d = map(int, input().split())\nt = [(d / c, 1000, c, d)] + [0] * m\nfor i in range(1, m + 1):\n a, b, c, d = map(int, input().split())\n t[i] = (d / c, a // b, c, d)\nt.sort(reverse = True)\ns, p = [0], [0] * (n + 1)\nfor i in range(m + 1):\n x, k, c, d = t[i]\n for j in range(k):\n r = []\n for x in s:\n y = x + c\n if y > n: continue\n if p[y] < p[x] + d:\n p[y] = p[x] + d\n r.append(y)\n if not r: break\n s = r\n x, s = 0, [0]\n for i in range(1, n + 1):\n if p[i] > x:\n s.append(i)\n x = p[i]\n else: p[i] = x\nprint(p[n])"}, {"source_code": "n,m,c0,d0=map(int,input().split())\nlst=[(d0/c0,1000,c0,d0)]\nfor _ in range(m):\n a,b,c,d=map(int,input().split())\n lst.append((d/c,a//b,c,d))\nlst.sort(reverse=True)\nind,res=[0],[0]*(n+1)\nfor _,(x,k,c,d) in enumerate(lst):\n for i in range(k):\n new=[]\n for j,y in enumerate(ind):\n if y+c>n:continue\n if res[y]+d>res[y+c]:\n res[y+c]=res[y]+d\n new.append(y+c)\n if new==[]:break\n ind=new[:]\n ind,elem=[0],0\n for i,x in enumerate(res):\n if x>elem:\n elem=x\n ind.append(i)\n else:res[i]=elem\nprint(res[-1])"}, {"source_code": "N,M,A,B = map(int,raw_input().split())\ndp = [0 for x in range(N+1)]\nfor i in range(M):\n a,b,c,d = map(int,raw_input().split())\n for j in range(N-1,-1,-1):\n for k in range(1,a/b+1):\n if k*c+j>N:\n continue\n dp[k*c+j] = max(dp[k*c+j],dp[j]+d*k)\nans = 0\nfor i in range(N+1):\n ans = max(ans,dp[i]+(N-i)/A*B)\nprint ans"}], "negative_code": [{"source_code": "import sys\ninput = sys.stdin.readline \n\nn, m, c_0, d_0 = map(int, input().split())\n\n # dp[grams_of_dough][1..j stuffings]\ndp = [[0 for _ in range(m + 1)] for _ in range(n + 1)]\n\n# grams left, grams required, dough required, sell price\nstuffing = [(0, 1, 0, 0)] + [map(int, input().split()) for _ in range(m)]\n\nfor i in range(0, n + 1): \n for j in range(1, m + 1): \n # attempt to make k of j-stuffed thingies\n for k in range(stuffing[j][0] / stuffing[j][1] + 1):\n if i - stuffing[j][2] * k > -1: \n dp[i][j] = max(dp[i - stuffing[j][2] * k][j - 1] + stuffing[j][3] * k, dp[i][j])\n\n\nans = 0 \n# for row in dp: print row\nfor k in range(n): \n ans = max(ans, dp[k][m] + ((n - k) / c_0) * d_0)\n\nprint ans"}, {"source_code": "from sys import stdin\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\nn, m, c0, d0 = arr_inp(1)\nstaff, percent, ans = [arr_inp(1) for i in range(m)], [[0, d0 / c0]], 0\n\nfor i in range(m):\n percent.append([i + 1, staff[i][-1] / staff[i][-2]])\n\npercent.sort(reverse=True, key=lambda x: x[1])\n\nfor i, j in percent:\n if i:\n val = min(staff[i - 1][0] // staff[i - 1][1], n // staff[i - 1][2])\n ans += staff[i - 1][-1] * val\n n -= val * staff[i - 1][2]\n else:\n ans += d0 * (n // c0)\n n -= (n // c0) * c0\n\n # print(n, i, ans)\n\nprint(ans)\n"}, {"source_code": "import sys\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition) :\n if condition :\n print (\"YES\")\n else :\n print (\"NO\")\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\nn, m, c0, d0 = rints()\nn += 1\n\nprev = [0] * n\nfor i in range((n - 1) / c0 + 1) :\n prev[i * c0] = i * d0\n\n\nfor i in range(m) :\n new = prev[:]\n a, b, c, d = rints()\n for start in range(n) :\n for bake in range(1, min((n - start - 1) / c + 1, a / b + 1)) :\n new[start + bake * c] = max(new[start + bake * c], prev[start] + bake * d)\n \n prev = new \nprint prev[-1]\n"}, {"source_code": "import sys\nfrom sys import stdin, stdout \ndef R():\n return map(int, stdin.readline().strip().split())\n\nn, m, c, d = R()\n\narr1 = []\nfor i in range(n//c):\n arr1.append((c, d))\nfor i in range(m):\n a, b, c, d = R()\n for j in range(min(a//b, n//c)):\n arr1.append((c, d))\n\ndp = [[0 for i in range(n+1)] for i in range(len(arr1))]\nif len(dp) == 0:\n print(0)\n exit()\nfor i in range(len(arr1)):\n c, d = arr1[i-1]\n for w in range(n+1):\n dp[i][w] = dp[i-1][w]\n if w >= c:\n if dp[i-1][w-c] + d > dp[i][w]:\n dp[i][w] = dp[i-1][w-c] + d\nprint(dp, arr1)\nstdout.write(str(dp[-1][-1]))\n# print(arr1)\n# for i in dp:\n# print(i)"}, {"source_code": "# n grams of dough\n# m stuffings\n# a[i] grams left of stuffing i\n# b[i] grams needed\n# c[i] grams of dough\n# d[i] price\n#\n# without stuffing: (special case)\n# a0 = infinite\n# b0 = 0\n# c0 grams of dough\n# d0 price\n# maximize price over all buns\n\n# at each step a choice of 1..k of m-th stuffings or no stuffing\n#\n# IH: we know how to find the max profit for dough n-1 and stuffings S[]\n#\ndef f(n, a, b, c, d):\n m = len(a)\n P = [[-1] * m for _ in range(n + 1)] # n * m\n\n def rec(weight, index):\n if index < 0: return 0\n\n # memoization\n if P[weight][index] != -1:\n return P[weight][index]\n\n profit = 0\n\n # we can create at most a[i] // b[i] stuffings\n stuffing, count = 0, 0\n while stuffing <= a[index]:\n remains = weight - (count * c[index])\n\n # not enough dough\n if remains < 0:\n break\n\n prev_profit = rec(remains, index - 1)\n\n profit = max(profit, prev_profit + count * d[index])\n\n # try more stuffing\n stuffing += b[index]\n count += 1\n\n return profit\n\n ans = rec(n, m - 1)\n print(ans)\n return ans\n\ninf = float(\"inf\")\nA = [inf, 7, 12 ]\nB = [1, 3, 3 ]\nC = [2, 2, 1 ]\nD = [1, 100, 10 ]\nassert f(10, A, B, C, D) == 241\n\nn, m, c0, d0 = map(int, input().split())\na, b, c, d = [inf], [0], [c0], [d0]\nfor _ in range(m):\n _a, _b, _c, _d = map(int, input().split())\n a.append(_a)\n b.append(_b)\n c.append(_c)\n d.append(_d)\n\nans = f(n, a, b, c, d)\nprint(ans)\n"}, {"source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n ans = 0\n for j in range(len(arr)):\n mem[j][n] = 0\n\n if arr:\n if arr[0][0] <= n:\n mem[0][n - arr[0][0]] = arr[0][1]\n\n for j in range(1, len(arr)):\n for i in range(n + 1):\n mem[j][i] = mem[j - 1][i]\n\n if i + arr[j][0] <= n:\n if mem[j - 1][i + arr[j][0]] != -1:\n mem[j][i] = max(mem[j][i], mem[j - 1][i + arr[j][0]] + arr[j][1])\n ans = max(ans, mem[j][i])\n\n # print(dp(0, n))\n for j in range(len(arr) + 1):\n for i in range(n, -1, -1):\n ext = (i // c0) * d0\n if mem[j][i] != -1:\n mem[j][i] += ext\n ans = max(ans, mem[j][i])\n print(ans)\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr = [arr_inp(1) for i in range(m)], []\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n mem = [[-1 for i in range(n + 1)] for j in range(len(arr) + 1)]\n main()\n"}, {"source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n ans = 0\n for j in range(len(arr)):\n mem[j][n] = 0\n\n if arr:\n mem[0][n - arr[0][0]] = arr[0][1]\n\n for j in range(1, len(arr)):\n for i in range(n + 1):\n mem[j][i] = mem[j - 1][i]\n\n if i + arr[j][0] <= n:\n if mem[j - 1][i + arr[j][0]] != -1:\n mem[j][i] = max(mem[j][i], mem[j - 1][i + arr[j][0]] + arr[j][1])\n ans = max(ans, mem[j][i])\n\n # print(dp(0, n))\n for j in range(len(arr) + 1):\n for i in range(n, -1, -1):\n ext = (i // c0) * d0\n if mem[j][i] == -1:\n mem[j][i] = ext\n else:\n mem[j][i] += ext\n ans = max(ans, mem[j][i])\n print(ans)\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr = [arr_inp(1) for i in range(m)], []\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n mem = [[-1 for i in range(n + 1)] for j in range(len(arr) + 1)]\n main()\n"}, {"source_code": "from sys import stdin\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\nn, m, c0, d0 = arr_inp(1)\nstaff, percent, ans = [arr_inp(1) for i in range(m)], [[0, d0 / c0]], 0\n\nfor i in range(m):\n percent.append([i + 1, staff[i][-1] / staff[i][-2]])\n\npercent.sort(reverse=True, key=lambda x: x[1])\n\n# print(percent)\nfor i, j in percent:\n if i:\n val = min(staff[i - 1][0] // staff[i - 1][1], n // staff[i - 1][2])\n ans += staff[i - 1][-1] * val\n n -= val * staff[i - 1][2]\n else:\n ans += d0 * (n // c0)\n n -= (n // c0) * c0\n\n # print(n, i, ans)\n\nprint(ans)\n"}, {"source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n ans = 0\n for i in range(len(arr)):\n mem[i][n] = 0\n\n for j in range(len(arr)):\n for i in range(n, -1, -1):\n\n if mem[j][i] != -1:\n if i - arr[j][0] >= 0:\n mem[j + 1][i - arr[j][0]] = max(mem[j + 1][i - arr[j][0]], mem[j][i] + arr[j][1])\n ans = max(ans, mem[j + 1][i - arr[j][0]])\n\n tem = i\n while tem - c0 >= 0:\n tem -= c0\n mem[j + 1][tem] = max(mem[j + 1][tem], mem[j + 1][tem + c0] + d0)\n ans = max(ans, mem[j + 1][tem])\n\n # print(dp(0, n))\n if not arr:\n ans = d0 * (n // c0)\n print(ans)\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr = [arr_inp(1) for i in range(m)], []\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n mem = [[-1 for i in range(n + 1)] for j in range(len(arr) + 1)]\n main()\n"}, {"source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n ans = 0\n for i in range(len(arr)):\n mem[i][n] = 0\n\n for j in range(len(arr)):\n for i in range(n, -1, -1):\n\n if mem[j][i] != -1:\n if i - arr[j][0] >= 0:\n mem[j + 1][i - arr[j][0]] = max(mem[j + 1][i - arr[j][0]], mem[j][i] + arr[j][1])\n ans = max(ans, mem[j + 1][i - arr[j][0]])\n\n tem = i\n while tem - c0 >= 0:\n tem -= c0\n mem[j + 1][tem] = max(mem[j + 1][tem], mem[j + 1][tem + c0] + d0)\n ans = max(ans, mem[j + 1][tem])\n\n # print(dp(0, n))\n print(ans)\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr = [arr_inp(1) for i in range(m)], []\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n mem = [[-1 for i in range(n + 1)] for j in range(len(arr) + 1)]\n\n setrecursionlimit(2000)\n threading.stack_size(102400000)\n thread = threading.Thread(target=main)\n thread.start()\n"}, {"source_code": "import functools as ft\nmikla, types, c0, d0 = map(int, input().split())\npieejamais = [0];pildijumapaterins = [0];miklaspaterins = [0];cena = [0]\nfor recepte in range(types):\n a, b, c, d = map(int, input().split())\n pieejamais.append(a);pildijumapaterins.append(b);miklaspaterins.append(c);cena.append(d)\n\n@ft.lru_cache(maxsize=524288)\ndef izd(miklasdaudz, pildijumi):\n if miklasdaudz == 0:\n return 0\n if pildijumi == 0:\n return (miklasdaudz // c0) * d0\n maxx = 0\n for k in range(pieejamais[pildijumi] // pildijumapaterins[pildijumi] + 1):\n izmantotamikla = k * miklaspaterins[pildijumi]\n atlikusimikla = miklasdaudz - izmantotamikla\n pelna = cena[pildijumi] * k\n s = izd(atlikusimikla, pildijumi - 1)\n if pelna + s > maxx:\n maxx = pelna + s\n return maxx\nprint(izd(mikla, types))\n"}, {"source_code": "import functools\n\n# The first line contains 4 integers n, m, c0 and d0 (1\u2009\u2264\u2009n\u2009\u2264\u20091000, 1\u2009\u2264\u2009m\u2009\u2264\u200910, 1\u2009\u2264\u2009c0,\u2009d0\u2009\u2264\u2009100).\n# Lavrenty has n grams of dough as well as m different stuffing types\n# he can make buns without stuffings. Each of such buns requires c0 grams of dough and it can be sold for d0 tugriks\nN, M, c0, d0 = map(int, input().split())\n\n# Each of the following m lines contains 4 integers. The i-th line contains numbers ai, bi, ci and di (1\u2009\u2264\u2009ai,\u2009bi,\u2009ci,\u2009di\u2009\u2264\u2009100)\n# he has ai grams left of the i-th stuffing. It takes exactly bi grams of stuffing i and ci grams of dough to cook a bun with the i-th stuffing.\n# Such bun can be sold for di tugriks\nrecipes = []\navailable_filling = [0]\nfilling_consumption = [0]\ndough_consumption = [0]\nprice = [0]\nfor m in range(M):\n ai,bi,ci,di = map(int, input().split())\n available_filling.append(ai)\n filling_consumption.append(bi)\n dough_consumption.append(ci)\n price.append(di)\n rec = (ai,bi,ci,di)\n recipes.append(rec)\n\n# Let create array dp by size n x m. dp[i][j] means maximum number of tugriks that the baker can earn\n# if he used i grams of dough and cook buns with stuffings of types 1..j.\n#\n# Initially dp[i][0] is 0 for all i.\n#\n# You can easily calculate this dp:\n# dp[i][j] = max{ dp[ i-c[j]*k ][ j-1 ] + d[j]*k } for every k from 0 to a[j]/b[j], for which i-c[j]*k>=0\n\n@functools.lru_cache()\ndef dp(dough, fill_considered):\n if dough == 0:\n return 0\n if fill_considered == 0:\n return (dough // c0) * d0\n m = 0\n for k in range(available_filling[fill_considered] // filling_consumption[fill_considered] + 1):\n prevdough = dough - dough_consumption[fill_considered] * k\n prevstuff = fill_considered - 1\n addition = price[fill_considered] * k\n m = max(m, dp(prevdough, prevstuff) + addition)\n return m\n\n\nprint(dp(N, M))\n\n\n\n"}, {"source_code": "R = lambda: map(int, input().split())\nn, m, c0, d0 = R()\na, b, c, d = [0], [0], [0], [0]\nfor i in range(m):\n t1, t2, t3, t4 = R()\n a.append(t1)\n b.append(t2)\n c.append(t3)\n d.append(t4)\ndp = [[0] * (n + 1) for i in range(m + 1)]\nfor j in range(n + 1):\n dp[0][j] = j // c0 * d0\nfor i in range(1, m + 1):\n for j in range(1, n + 1):\n x = 0\n while j > x * c[i] and a[i] >= b[i] * x:\n dp[i][j] = max(dp[i][j], dp[i - 1][j - x * c[i]] + x * d[i])\n x += 1\nprint(dp[m][n])"}, {"source_code": "n,m,c0,d0=map(int,input().split()) # testo, kol nac, test bez nac, pribil\ndp=[] # max kol deneg za index testa\nfor i in range(n+1): dp.append(i//c0*d0)\nfor i in range(m):\n a,b,c,d=map(int,input().split())#ost nach, need nach, need tes, pribil\n for k in range(n,c-1,-1):\n dp[k]=max(dp[k],dp[k-c]+d)\nprint(dp[n])\n"}, {"source_code": "n, m, c, d = map(int, input().split())\nt = [(d / c, 1000, 1, c, d)] + [0] * m\nfor i in range(1, m + 1):\n a, b, c, d = map(int, input().split())\n t[i] = (d / c, a, b, c, d)\nt.sort(reverse = True)\ni = p = 0\nwhile i < m + 1:\n u, a, b, c, d = t[i]\n i += 1\n if n < c: continue\n k = a // b\n p += d * k\n n -= c * k\n if n < 0:\n k = (- 1 - n) // c + 1\n n += c * k\n p -= d * k\nprint(p)"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\ndata = sys.stdin.readlines()\n\nn, m, c0, d0 = map(int, data[0].split())\n\na = [0]\nb = [0]\nc = [0]\nd = [0]\n\nfor i in xrange(1, m + 1):\n da, db, dc, dd = map(int, data[i].split())\n a.append(da)\n b.append(db)\n c.append(dc)\n d.append(dd)\n\ndp = [] # n x m\nfor i in xrange(0, n): dp.append([ 0 for j in xrange(0, m+1)])\n\nfor i in xrange(0, n):\n for j in xrange(1, m + 1):\n for k in xrange(0, a[j]/b[j] + 1):\n if i - c[j]*k >= 0:\n dp[i][j] = max(dp[i][j], dp[i-c[j]*k][j-1] + d[j]*k)\n \n#for i in xrange(0, n):\n# for j in xrange(0, m+1):\n# print \"%3s \" % dp[i][j],\n# print \n#print\n\ntugrics = 0\nfor k in xrange(0, n):\n tugrics = max(tugrics, dp[k][m] + ((n-k)/c0)*d0)\n\nprint tugrics\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\ndata = sys.stdin.readlines()\n\nn, m, c0, d0 = map(int, data[0].split())\n\na = [0]\nb = [0]\nc = [0]\nd = [0]\n\nfor i in xrange(1, m + 1):\n da, db, dc, dd = map(int, data[i].split())\n a.append(da)\n b.append(db)\n c.append(dc)\n d.append(dd)\n\ndp = [] # n x m\nfor i in xrange(0, n): dp.append([ 0 for j in xrange(0, m+1)])\n\nfor i in xrange(0, n):\n for j in xrange(1, m + 1):\n for k in xrange(0, a[j]/b[j] + 1):\n if i + 1 - c[j]*k >= 0:\n dp[i][j] = max(dp[i][j], dp[i-c[j]*k][j-1] + d[j]*k)\n \n#for i in xrange(0, n):\n# for j in xrange(0, m+1):\n# print \"%3s \" % dp[i][j],\n# print \n#print\n\ntugrics = 0\nfor k in xrange(0, n):\n tugrics = max(tugrics, dp[k][m] + ((n-k)/c0)*d0)\n\nprint tugrics\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\ndata = sys.stdin.readlines()\n\nn, m, c0, d0 = map(int, data[0].split())\n\na = []\nb = []\nc = []\nd = []\n\nfor i in xrange(1, m + 1):\n da, db, dc, dd = map(int, data[i].split())\n a.append(da)\n b.append(db)\n c.append(dc)\n d.append(dd)\n\ndp = [] # n x m\nfor i in xrange(0, n): dp.append([ 0 for j in xrange(0, m+1)])\n\nfor i in xrange(0, n):\n for j in xrange(0, m):\n for k in xrange(0, a[j]/b[j]):\n if i - c[j]*k >= 0:\n dp[i][j+1] = max(dp[i-c[j]*k][j] + d[j]*k, dp[i][j+1])\n \n#for i in xrange(0, n):\n# for j in xrange(0, m+1):\n# print \"%3s \" % dp[i][j],\n# print \n\nprint\n\ntugrics = 0\nfor k in xrange(0, n):\n tugrics = max(tugrics, dp[k][m] + ((n-k)/c0)*d0)\n\nprint tugrics\n"}, {"source_code": "str = raw_input()\narr = [int(s) for s in str.split(' ')]\npir = []\nans = range(arr[1]+1)\nans[0] = []\nfor j in range(0, arr[0]+1):\n ans[0].append( (j / arr[2])*arr[3])\nfor i in range(1, arr[1]+1):\n str = raw_input()\n pir = [int(s) for s in str.split(' ')]\n ans[i] = []\n last = 0\n am = (pir[0]/pir[1])*pir[2]\n for j in range(0, arr[0]+1):\n if(j <= am):\n last = (j / pir[2])*pir[3]\n ans[i].append(last)\n else:\n ans[i].append(last)\ntaken = []\nz = arr[0]\nbigA = 0\nwhile True:\n max = -1\n k = -1\n for i in range(0, arr[1]+1):\n b = True\n for j in taken:\n if j == i:\n b = False\n break\n if b == False:\n continue \n if max < ans[i][z]:\n max = ans[i][z]\n k = i\n # print \"max\", max\n # print \"k\", k\n if k == -1:\n break \n taken.append(k)\n bigA += max\n t = -1\n for i in range(0,len(ans[k])):\n if ans[k][i] == max:\n z = z - i\n break\n#print \"z\", z\nprint bigA\n"}, {"source_code": "str = raw_input()\narr = [int(s) for s in str.split(' ')]\npir = range(arr[1])\nans = range(arr[0]+1)\nfor i in range(0, arr[1]):\n str = raw_input()\n pir[i] = [int(s) for s in str.split(' ')]\nfor i in range (0, arr[0]+1):\n ans[i] = (i / arr[2])*arr[3]\n\nfor j in range(0, arr[1]):\n am = pir[j][0]/pir[j][1]\n for i in range(arr[0],-1, -1):\n if i / pir[j][2] < am:\n am = i / pir[j][2]\n k = am * pir[j][2]\n if ans[i] < ans[i-k]+am*pir[j][3]:\n ans[i] = ans[i-k]+am*pir[j][3] \nprint ans[arr[0]]\n\n\n\n"}, {"source_code": "str = raw_input()\narr = [int(s) for s in str.split(' ')]\npir = range(arr[1])\nans = range(arr[0]+1)\nfor i in range(0, arr[1]):\n str = raw_input()\n pir[i] = [int(s) for s in str.split(' ')]\nfor i in range (0, arr[0]+1):\n ans[i] = (i / arr[2])*arr[3]\n\nfor j in range(0, arr[1]):\n am = pir[j][0]/pir[j][1]\n for i in range(arr[0],-1, -1):\n if i / pir[j][2] < am:\n am = i / pir[j][0]\n k = am * pir[j][2]\n if ans[i] < ans[i-k]+am*pir[j][3]:\n ans[i] = ans[i-k]+am*pir[j][3] \nprint ans[arr[0]]\n\n\n"}, {"source_code": "l = []\nn, m, c, d = map(int, raw_input().split())\nl.append([1000, c, d])\nfor _ in xrange(m):\n s = map(int, raw_input().split())\n l.append([s[0] / s[1], s[2], s[3]])\n\nf = [0] * 1001\ns = [[x[0] for x in l]]\n\nfor i in range(1, n + 1):\n t = s[0]\n for j in range(m + 1):\n if i >= l[j][1] and s[i - l[j][1]][j] > 0 and f[i] < f[i - l[j][1]] + l[j][2]:\n f[i] = f[i - l[j][1]] + l[j][2]\n t = s[i - l[j][1]][:]\n t[j] -= 1\n s.append(t)\nprint f[n]"}, {"source_code": "l = []\nn, m, c, d = map(int, raw_input().split())\nl.append([0, 0, c, d])\nfor _ in xrange(m):\n l.append(map(int, raw_input().split()))\n\nl.sort(key = lambda x: float(x[3]) / x[2], reverse = True)\nans = 0\ni = 0\nwhile True:\n if l[i][0] >= l[i][1]:\n if n >= l[i][2]:\n l[i][0] -= l[i][1]\n n -= l[i][2]\n ans += l[i][3]\n else:\n break\n else:\n i += 1\nprint ans"}, {"source_code": "n,m,c0,d0 = map(int, raw_input().strip().split())\n\nz = [n] + [0]*(m+1)\nc = [c0] + [0]*(m+1)\nd = [d0] + [0]*(m+1)\nfor i in range(1, m+1):\n a,b,c[i],d[i]=map(int, raw_input().strip().split())\n z[i] = a//b\n print z[i]\nans = 0\n\n# dp[j][i] := max gain up to i, using j grams of dough\n# = max_{k from 0 up to max(z[i], j // c[i])} {k*d[i] + dp[j - k*c[i]][i-1], dp[j][i-1]}\ndp = [[0] * (m+1) for _ in range(n+1)]\nfor j in range(n+1):\n dp[j][0] = (j//c[0])*d[0]\n for i in range(1, m+1):\n dp[j][i] = dp[j][i-1]\n for k in range(min(z[i], j // c[i])+1):\n g = k*d[i] + dp[j-k*c[i]][i-1]\n dp[j][i] = max(g, dp[j][i])\n\nprint max([dp[j][m] for j in range(n+1)])\n\n\n\n\n\n\n\n\n"}], "src_uid": "4e166b8b44427b1227e0f811161d3a6f"} {"source_code": "import sys\nn = int(input())\narr = list(map(int,input().split()))\ns = ''\npre = arr[0]\nfor i in range(1,n):\n if( pre < arr[i] ):\n if(len(s) == 0 or ( len(s) > 0 and s[-1] != 'i')):\n s += 'i'\n elif( pre == arr[i] ):\n if(len(s) == 0 or ( len(s) > 0 and s[-1] != 'c')):\n s += 'c'\n elif( pre > arr[i] ):\n if(len(s) == 0 or ( len(s) > 0 and s[-1] != 'd')):\n s += 'd'\n pre = arr[i]\n#print(s)\nif( n == 1 or s == 'icd' or s == 'c' or s == 'i' or s == 'd' or s == 'ic' or s == 'cd' or s == 'id'):\n print('YES')\nelse:\n print('NO')", "positive_code": [{"source_code": "def udimol(a):\n last = a[0]\n status = 0\n for x in a[1:]:\n if status == 0:\n if x == last:\n status = 1\n elif x > last:\n pass\n else:\n status = 2\n last = x\n elif status == 1:\n if x < last:\n status = 2\n last = x\n elif x == last:\n last = x\n else:\n return 'NO'\n else:\n if x < last:\n last = x\n else:\n return 'NO'\n\n return 'YES'\n\n\nraw_input()\ns = [int(x) for x in raw_input().split(' ')]\nprint udimol(s)\n"}, {"source_code": "n=input()\narr=map(int,raw_input().split(\" \"))\nif(n==1):\n print 'YES'\nelse:\n f1,f2,f3,flag=0,0,0,0\n for i in range(1,n):\n if(arr[i]>arr[i-1]):\n if(f2==0 and f3==0):\n f1=1\n else:\n flag=1\n break\n elif(arr[i]==arr[i-1]):\n if(f3==0):\n f2=1\n else:\n flag=1\n break\n else:\n f3=1\n if(flag==0):\n print 'YES'\n else:\n print 'NO'\n \n"}, {"source_code": "num, arr = int(input()), input().split()\narr = [int(x) for x in arr]\n\n\ndef problem8(num,arr):\n i = 1\n for i in range(i, num):\n if not (arr[i - 1] < arr[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, num):\n if not (arr[i - 1] == arr[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, num):\n if not (arr[i - 1] > arr[i]):\n return \"NO\"\n else:\n return \"YES\"\n\nprint(problem8(num,arr))\n"}, {"source_code": "n=input()\ns=raw_input().split()\na=[0 for i in range(1005)]\nc1=0\np=-1\nc2=0\nfor i in range(n):\n a[i]=int(s[i])\nfor i in range(1,n):\n if a[i]==a[i-1]:\n if c1==0:\n c1=1\n p=i\n else:\n if a[i]!=a[p]:\n print \"NO\"\n exit()\nif p==-1:\n t=0\n while t<n and a[t]<a[t+1]:\n t=t+1\n for i in range(t,n):\n if a[i]<a[i+1]:\n print \"NO\"\n exit()\n print\"YES\"\n exit()\nfor i in range(p):\n if a[i]>a[i+1]:\n print \"NO\"\n exit()\nfor i in range(p,n):\n if a[i]<a[i+1]:\n print \"NO\"\n exit()\nprint \"YES\"\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jul 26 15:08:27 2017\n\n@author: WalkingDeada\n\nDon't lose your heart\n\"\"\"\n\nn=int(input())\na=map(int,raw_input().split())\ni=0\nj=n\nwhile i+1<n and a[i]<a[i+1]:\n i+=1\nwhile j>0 and a[j-2]>a[j-1]:\n j-=1\nb=set(a[i:j])\nprint 'YES' if len(b)<2 else 'NO'\n "}, {"source_code": "n = int(raw_input())\nl = map(int,raw_input().split())\nlast = l[0]\neq = False\ndec = False\ni = 1\nwhile i < n:\n current = l[i]\n if current > last:\n if eq or dec:\n print \"NO\"\n break\n if current == last:\n eq = True\n if dec:\n print \"NO\"\n break\n if current < last:\n dec = True\n last = current\n i += 1\nelse:\n print \"YES\""}, {"source_code": "pattern1=[\"constant\"]\npattern2=[\"constant\",\"down\"]\npattern3=[\"up\",\"constant\"]\npattern4=[\"up\",\"constant\",\"down\"]\npattern5=[\"up\",\"down\"]\npatternList=[str(pattern1),str(pattern2),str(pattern3),str(pattern4),str(pattern5)]\n\nn=input()\narray = [int(x) for x in raw_input().split(\" \")]\npattern=[]\n\nfor idx in range(len(array)-1):\n\tcurrentPattern=None\n\tif array[idx+1]>array[idx]:\n\t\tcurrentPattern=\"up\"\n\tif array[idx+1]<array[idx]:\n\t\tcurrentPattern=\"down\"\n\tif array[idx+1]==array[idx]:\n\t\tcurrentPattern=\"constant\"\n\tif idx==0 or (len(pattern)>0 and pattern[-1]!=currentPattern):\n\t\tpattern.append(currentPattern)\n\nif len(pattern)==1 or len(array)==1 or (str(pattern) in patternList):\n\tprint (\"YES\")\nelse:\n\tprint (\"NO\")\n"}, {"source_code": "import sys\nn = int(raw_input().strip())\nar = map(int, raw_input().strip().split(' '))\ni=0\t\nwhile (i<n-1 and ar[i]<ar[i+1]):\n\ti=i+1\t\nwhile (i<n-1 and ar[i]==ar[i+1]):\n\ti=i+1\t\nwhile (i<n-1 and ar[i]>ar[i+1]):\n\ti=i+1\t\nif i==n-1:\n\tprint 'YES'\nelse:\n\tprint 'NO'\n"}, {"source_code": "#!usr/bin/env python\n\nn=input()\na=map(int,raw_input().split())\ni,j=0,n\nwhile i+1<n and a[i]<a[i+1]:\n i+=1\nwhile j>1 and a[j-1]<a[j-2]:\n j-=1\nb=set(a[i:j])\nprint 'YES' if len(b)<2 else 'NO'\n"}, {"source_code": "import sys\nif __name__ == \"__main__\":\n n = input()\n last_minus = \"-\"\n arrs = raw_input().split(\" \")\n last_element = int(arrs[0])\n res = \"YES\"\n for i in arrs[1:]:\n int_i = int(i)\n if last_element > int_i:\n now_minus = 1\n elif last_element == int_i:\n now_minus = 0\n else:\n now_minus = -1\n if last_minus != \"-\" and now_minus < last_minus:\n res = \"NO\"\n break\n last_minus = now_minus\n last_element = int_i\n print res "}, {"source_code": "def is_unimodal(seq):\n i = 1\n end = len(seq)\n while i < end and seq[i - 1] < seq[i]:\n i += 1\n while i < end and seq[i - 1] == seq[i]:\n i += 1\n while i < end and seq[i - 1] > seq[i]:\n i += 1\n return i == end\n\nn = input()\n\narr = map(int, raw_input().split())\nk = is_unimodal(arr)\n\nif k:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "n = input()\nA = map(int, raw_input().split())\ni=0\nwhile i<(n-1) and A[i] < A[i+1]:\n\ti = i + 1\nwhile i<(n-1) and A[i] == A[i+1]:\n\ti = i + 1\nwhile i<(n-1) and A[i] > A[i+1]:\n\ti = i + 1\nif i == (n-1):\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "def unimodal_new(mylist) : \n if len(mylist) == 1 :\n return\"YES\"\n\n i = 0\n while (mylist[i] < mylist[i+1]) and (i < len(mylist) - 2): \n i += 1 \n\n if i == len(mylist) - 2 : \n return \"YES\"\n \n while (mylist[i] == mylist[i+1]) and (i < len(mylist) - 2): \n i += 1 \n \n if (i == len(mylist) - 2) and (mylist[i] == mylist[i+1]) : \n return \"YES\"\n \n for j in range(i, len(mylist) - 1) : \n if mylist[j] <= mylist[j+1] : \n return \"NO\"\n \n return \"YES\"\n\nif __name__ == \"__main__\":\n n = int(input())\n arrlist = [int(x) for x in input().split()]\n print(unimodal_new(arrlist)) "}, {"source_code": "def unimodal(a, lst):\n i = 1\n for i in range(i, a):\n if not (lst[i - 1] < lst[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, a):\n if not (lst[i - 1] == lst[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, a):\n if not (lst[i - 1] > lst[i]):\n return \"NO\"\n else:\n return \"YES\"\n\nif __name__ == '__main__':\n a, lst = int(input()), input().split()\n lst = [int(ch) for ch in lst]\n print(unimodal(a, lst))\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline().strip())\na = stdin.read().split()\na = map(int, a)\nif n <= 2: print \"YES\"\nelse:\n\ti = 1\n\twhile i < n and a[i] > a[i-1]: i += 1\n\twhile i < n and a[i] == a[i-1]: i += 1\n\twhile i < n and a[i] < a[i-1]: i += 1\n\tprint \"NO\" if i < n else \"YES\""}, {"source_code": "\n\ndef unimodal(a, lst):\n i = 1\n for i in range(i, a):\n if not (lst[i - 1] < lst[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, a):\n if not (lst[i - 1] == lst[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, a):\n if not (lst[i - 1] > lst[i]):\n return \"NO\"\n else:\n return \"YES\"\n\n\n\nif __name__ == '__main__':\n a, lst = int(input()), input().split()\n lst = [int(ch) for ch in lst]\n print(unimodal(a, lst))\n"}, {"source_code": "import sys\nn = int(raw_input())\n\narr = map(int, raw_input().split())\n\nm = max(arr)\nx1 = -1\nx2 = -1\nfor i in range(n):\n if arr[i] == m:\n x2 = i\n if x1 == -1:\n x1 = i\n\nfor i in range(x1,x2+1):\n if arr[i] != m:\n print \"NO\"\n sys.exit(0)\n\nfor i in range(x1):\n if arr[i] >= arr[i+1]:\n print \"NO\"\n sys.exit(0)\n\nfor i in range(x2, n-1):\n if arr[i] <= arr[i+1]:\n print \"NO\"\n sys.exit(0)\n\nprint \"YES\""}, {"source_code": "from itertools import groupby\nimport sys\nn = int(raw_input().strip())\nA = map(int, raw_input().strip().split())\nif n==1:\n print \"YES\"\n sys.exit()\ns = \"\"\nfor a0 in range(1, len(A)):\n if A[a0] - A[a0-1] >0:\n s+='1'\n elif A[a0] ==A[a0-1]:\n s+='2'\n else:\n s+='3'\n#print s\nlist_s = list(s)\ns = \"\".join([a[0] for a in groupby(list_s)])\n#print s\nif s == \"123\":\n print \"YES\"\nelif s==\"1\" or s==\"2\" or s==\"3\":\n print \"YES\"\nelif s==\"12\" or s==\"13\" or s==\"23\":\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "def top(l2,i):\n if len(l2)==2:\n print(\"yes\")\n exit(0)\n for j in range(i,len(l2)-1):\n if l2[j]>l2[j+1]:\n decrement(l2,j+1)\n if l2[j]<l2[j+1]:\n print(\"no\")\n exit(0)\n print(\"yes\")\n exit(0)\ndef decrement(l3,i):\n if i==len(l3)-1:\n print(\"yes\")\n exit(0)\n for j in range(i,len(l3)-1):\n if l3[j]<=l3[j+1]:\n print(\"no\")\n exit(0)\n print(\"yes\")\n exit(0)\nif __name__==\"__main__\":\n n=int(input())\n l1=list(map(int,input().split()))\n if len(l1)==1:\n print(\"yes\")\n exit(0)\n for i in range(0,len(l1)-1):\n if l1[i]==l1[i+1]:\n top(l1,i+1)\n elif l1[i]<l1[i+1]:\n pass\n elif l1[i]>l1[i+1]:\n decrement(l1,i+1)\n print(\"yes\")"}, {"source_code": "def check(c):\n combs = [[\"i\", \"c\", \"d\"], [\"c\"], [\"c\", \"d\"], [\"i\", \"c\"], [\"i\", \"d\"], [\"i\"], [\"d\"]]\n if removeNeighbours(list(c)) in combs: return True\n return False\n\n\ndef removeNeighbours(l):\n i = 0\n while i < len(l) - 1:\n if l[i] == l[i + 1]:\n del l[i]\n else:\n i = i + 1\n return l\n\n\ndef solve(a):\n c = \"\"\n\n for i in range(len(a) - 1):\n if a[i] < a[i + 1]:\n c += \"i\"\n elif a[i] == a[i + 1]:\n c += \"c\"\n elif a[i] > a[i + 1]:\n c += \"d\"\n\n if len(a) == 1:\n return True\n elif check(c):\n return True\n return False\n\n\nN = int(input())\nA = [int(i) for i in input().split()]\nprint(\"YES\" if solve(A) else \"NO\", end=\"\")\n# 1521989021332\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().split(\" \")))\nj=0\nwhile (j < n-1 and arr[j] < arr[j+1]):\n\tj=j+1\nwhile (j < n-1 and arr[j] == arr[j+1]):\n\tj=j+1\nwhile (j < n-1 and arr[j] > arr[j+1]):\n\tj=j+1\nif j == n-1:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n"}, {"source_code": "\n\n\nn = int(input())\n\n\nt = list(map(int,input().split()))\n\n\nif len(set(t))==1:\n print('YES')\nelif t == sorted(t) and len(set(t))==n:\n print('YES')\nelif t == sorted(t)[::-1] and len(set(t))==n:\n print('YES')\nelse:\n\n u = max(t)\n \n\n x=t.index(u)\n h=0\n for j in range(1,x):\n if t[j]>t[j-1]:\n pass\n else:\n print('NO')\n h+=1\n break\n if h==0:\n for y in range(x+t.count(u),n):\n if t[y]<t[y-1]:\n pass\n else:\n print('NO')\n h+=1\n break\n \n if h==0:\n print('YES')\n \n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split(\" \")))\ncenter = max(l)\n\ninc = False\nmiddle = False\ndec = False\nflag = False\nfor i in range(n-1):\n if l[i] == l[i+1] and l[i] == center:\n middle = True\n continue\n if l[i] <= l[i+1] and middle:\n print(\"NO\")\n flag = True\n break\n if l[i] == center:\n middle = True\n if l[i] >= l[i+1] and not middle:\n print(\"NO\")\n flag = True\n break\nif not flag:\n print(\"YES\")\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\np=0\nc=-1\nr=-1\np1=0\nfor i in range(1,n) :\n if l[i]>l[i-1] and r==-1 :\n p=0\n else :\n if r==-1 :\n r=l[i]\n else :\n if l[i]!=r and r<l[i] :\n print('NO')\n exit()\n if l[i]<l[i-1] :\n c=i+1\n break\nif c!=-1 :\n for i in range(c,n) :\n if l[i-1]<=l[i] :\n print('NO')\n exit()\nprint('YES')\n \n \n \n \n \n \n"}, {"source_code": "n = int(raw_input())\narray = map(int, raw_input().split())\n\ni = 0\n\nwhile i < n-1 and array[i] < array[i+1]:\t\n\ti += 1\nwhile i < n-1 and array[i] == array[i+1]:\n\ti += 1\nwhile i < n-1 and array[i] > array[i+1]:\n\ti += 1\n\nif i == (n - 1):\n\tprint 'YES'\nelse:\n\tprint 'NO'\n"}, {"source_code": "n=int(input())\na=map(int,raw_input().split())\ni=0\nj=n\nwhile i+1<n and a[i]<a[i+1]:\n\ti=i+1\nwhile j>0 and a[j-2]>a[j-1]:\n\tj=j-1\nb=set(a[i:j])\nprint 'YES' if len(b)<2 else 'NO'\n"}, {"source_code": "n=int(input())\nx = list(map(int, input().split(\" \")))\ni,j=1,n-1\nwhile i<n and x[i]>x[i-1]:i+=1\nwhile j>0 and x[j]<x[j-1]:j-=1\nif len(set(x[i-1:j+1]))==1:\n print(\"YES\")\nelse:print(\"NO\")\n"}, {"source_code": "def unimodalArray(n,x):\n \n estado = 1 #1: Increasing\n #2: Constant\n #3: Decreasing\n \n for i in range(0,n-1):\n if estado == 1:\n if x[i] == x[i+1]:\n estado = 2\n elif x[i] > x[i+1]:\n estado = 3\n elif estado == 2:\n if x[i] > x[i+1]:\n estado = 3\n elif x[i] < x[i+1]:\n return \"NO\"\n elif estado == 3:\n if x[i] < x[i+1] or x[i] == x[i+1]:\n return \"NO\"\n \n return \"YES\"\n\nnRaw = input()\nn = int(nRaw)\n\nxRaw = input()\nxStr = xRaw.split()\nx = list(map(int, xStr))\n\nprint(unimodalArray(n,x))"}, {"source_code": "n=int(input())\nl=[int(i) for i in input().split()]\ni=1 \nc=0\nwhile i<n and l[i]>l[i-1]:\n i+=1 \n c+=1 \nwhile i<n and l[i]==l[i-1]:\n i+=1 \n c+=1 \nwhile i<n and l[i]<l[i-1]:\n i+=1 \n c+=1 \nprint('YES' if c==n-1 else 'NO')\n"}, {"source_code": "count = input()\nchisla = [int(symbol) for symbol in input().split()]\n\n\ndef strictly_increasing(L):\n return all(x<y for x, y in zip(L, L[1:]))\n\n\ndef strictly_decreasing(L):\n return all(x>y for x, y in zip(L, L[1:]))\n\nmax_value = max(chisla)\nmax_indexes = [index for index in range(len(chisla)) if chisla[index] == max_value]\ndifference_is_one = True\nfor i in range(len(max_indexes)-1):\n if (max_indexes[i+1]-max_indexes[i])>1:\n difference_is_one = False\nif difference_is_one and strictly_increasing(chisla[:max_indexes[0]+1]) and strictly_decreasing(chisla[max_indexes[-1]:]):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))[:n]\nch = 0\nwhile(ch<n-1 and a[ch]<a[ch+1]):\n ch += 1\nwhile(ch<n-1 and a[ch]==a[ch+1]):\n ch += 1\nwhile(ch<n-1 and a[ch]>a[ch+1]):\n ch += 1\nch += 1\nif(ch!=n):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "import itertools\nimport math\nfrom collections import defaultdict\n\ndef input_ints():\n return list(map(int, input().split()))\n\ndef solve():\n n = int(input())\n a = input_ints()\n x = 0\n while x < n - 1:\n if a[x] < a[x + 1]:\n x += 1\n else:\n break\n y = n - 1\n while y > 0:\n if a[y - 1] > a[y]:\n y -= 1\n else:\n break\n if y < x:\n print('NO')\n return\n x += 1\n for i in range(x, y):\n if a[i] != max(a):\n print('NO')\n return\n print('YES')\n\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "n = int(input())\nstring = input()\nnumbers = list(map(int, string.split()))\nresults = \"NO\"\na, b = numbers[:-1], n\nfor x in range(n - 1):\n if not numbers[x] < numbers[x + 1]:\n a = numbers[x]\n b = x\n break\nc = n\nfor x in range(b, n):\n if not numbers[x] == a:\n c = x\n d = numbers[x]\n break\nresults = \"YES\"\nif c != n:\n if numbers[c] < a:\n for x in range(c, n - 1):\n if not numbers[x] > numbers[x + 1]:\n results = \"NO\"\n break\n else:\n results = \"NO\"\nprint(results)"}, {"source_code": "def unimodal():\n import sys\n nList = []\n count = 0\n N = int(input())\n S = input()\n nList = S.split()\n nList = [int(i) for i in nList]\n for x in range(len(nList)-2):\n if (nList[x+1] - nList[x] > 0): #\uc99d\uac00\uad6c\uac04\n pass\n else:\n if (nList[x+1] - nList[x] == 0): #\uc720\uc9c0\uad6c\uac04\n if (nList[x + 2] - nList[x + 1] > 0):\n print(\"NO\")\n sys.exit()\n pass\n else:\n if (nList[x+1] - nList[x] < 0): #\uac10\uc18c\uad6c\uac04\n if (nList[x + 2] - nList[x + 1] > 0):\n print(\"NO\")\n sys.exit()\n elif (nList[x + 2] - nList[x + 1] == 0):\n print(\"NO\")\n sys.exit()\n pass\n print(\"YES\")\n\nunimodal()"}, {"source_code": "n = input()\narray = list(map(int, input().split()))\nif array.__len__() == 1:\n print(\"YES\")\n exit(0)\ni = 0\nif array[i] < array[i + 1]:\n while i < array.__len__() - 1 and array[i] < array[i + 1]:\n i += 1\n if i == array.__len__() - 1:\n print(\"YES\")\n exit(0)\nif array[i] >= array[i + 1]:\n if i == array.__len__() - 2:\n print(\"YES\")\n exit(0)\n else:\n if array[i] == array[i+1]: \n while i < array.__len__() - 1 and array[i] == array[i + 1]:\n i += 1\n if i == array.__len__() - 1:\n print(\"YES\")\n exit(0)\n elif array[i] > array[i+1]:\n while i < array.__len__() - 1 and array[i] > array[i + 1]:\n i += 1\n if i == array.__len__() - 1:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n else:\n if i == array.__len__() - 1:\n print(\"YES\")\n exit(0)\n else:\n while i < array.__len__() - 1 and array[i] > array[i + 1]:\n i += 1\n if i == array.__len__() - 1:\n print(\"YES\")\n else:\n print(\"NO\")\n\nelse:\n print(\"NO\")\n exit(0)\n \n\n"}, {"source_code": "#!usr/bin/python 3\n\ndef main():\n a=int(input())\n lst=input().split(' ')\n lst=[int(x) for x in lst]\n state=0\n prev=0\n printed=False\n for x in range(0,a):\n if state==0:\n \n if lst[x]==prev:\n state=1\n elif lst[x]<prev:\n state=2\n prev=lst[x]\n elif state==1:\n if lst[x]>prev:\n printed=True\n print('NO')\n break\n elif lst[x]<prev:\n state=2\n prev=lst[x]\n elif state==2:\n if lst[x]>=prev:\n printed=True\n print('NO')\n break\n prev=lst[x]\n \n if printed==False:\n print('YES')\n\nif __name__=='__main__':\n main()"}, {"source_code": "def main():\n size = int(input())\n array = [int(x) for x in input().split(' ')]\n has_constant = False\n has_fall = False\n\n for i in range(len(array) - 1):\n a, b = array[i], array[i + 1]\n if a < b and not has_fall and not has_constant:\n continue\n if a > b:\n has_fall = True\n continue\n if a == b and not has_fall:\n has_constant = True\n continue\n return 'NO'\n return 'YES'\n\nif __name__ == '__main__':\n print(main())\n\n\"\"\"def main():\n first_keys = [x for x in input()]\n second_keys = [x for x in input()]\n wrong_text = [x for x in input()]\n result = []\n\n for character in wrong_text:\n result.append(second_keys[first_keys.index(character)])\n return ''.join(result)\n\"\"\"\n"}, {"source_code": "from collections import *\nimport sys \n\n# \"\". join(strings) \n \ndef ri():\n return int(input())\n \ndef rl():\n return list(map(int, input().split()))\n\nn= ri()\n\naa = rl()\nans='YES'\nif n>1:\n\n for i in range(n-1):\n if aa[i+1]<=aa[i]:\n end_up = i\n break\n else:\n end_up=n-1\n start_down=n-1\n \n for i in range(end_up,n-1):\n if aa[i+1]!=aa[i]:\n start_down=i\n break\n else:\n start_down=n-1\n\n \n for i in range(start_down, n-1):\n if aa[i+1]>=aa[i]:\n ans=\"NO\"\n break\nprint(ans)\n\n\n\n\n"}, {"source_code": "n=input()\ninp=input().split()\nmark1=0\nmark2=0\njudge=0\nnum=int(inp[0])\n\nfor i in range(1,int(n)):\n if int(inp[i])>num:\n num=int(inp[i])\n if mark1==1 or mark2==1:\n judge=1\n break\n elif int(inp[i])==num :\n mark1=1\n if mark2==1:\n judge=1\n break\n else:\n num=int(inp[i])\n mark2=1\n \nif judge==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nans = \"YES\"\nif len(a) > 2:\n cs = a[0] - a[1]\n for i in range(1, n-1):\n if cs < 0:\n if a[i+1] < a[i]:\n cs = 1\n elif a[i+1] == a[i]:\n cs = 0\n elif cs == 0:\n if a[i+1] > a[i]:\n ans = \"NO\"\n break\n elif a[i+1] < a[i]:\n cs = 1\n elif a[i+1] >= a[i]:\n ans = \"NO\"\n break\nprint ans"}, {"source_code": "input()\narr = [int(i) for i in input().split()]\n\nmode = -1\ncould = True\ni = 0\n\nwhile i < len(arr) - 1:\n if mode == -1:\n if arr[i] < arr[i+1]: i += 1\n else: mode += 1\n\n elif mode == 0:\n if arr[i] == arr[i+1]:\n\n i += 1\n else:\n if arr[i] < arr[i+1]:\n could = False\n break\n mode += 1\n\n else:\n if arr[i] > arr[i+1]: i += 1\n else:\n could = False\n break\n\nprint(\"YES\" if could else \"NO\")"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\ni = 0\nj = n-1\nwhile i+1<n and a[i]<a[i+1]:\n\ti+=1\nwhile j-1>=0 and a[j-1]>a[j]:\n\tj-=1\nif len(set(a[i:j+1]))==1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\ndiff=[]\nfor i in range(1,n):\n if arr[i]-arr[i-1]>0:\n diff.append(1)\n elif arr[i]-arr[i-1]==0:\n diff.append(0)\n else:\n diff.append(-1)\n\nop=diff[:]\ndiff.sort(reverse=True)\nif op==diff:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\nimport math\n\ndef readArray():return map(int,sys.stdin.readline().split())\ndef readString():return sys.stdin.readline().strip()\ndef readNum():return readString()\ndef exp(t,x):\n MOD=1000000007\n if(x==0):return 1\n if(x==1):return t\n if(x%2==1):return exp((t*t)%MOD,x/2)\ndef gcd(x,y):\n if x%y==0:return y\n else: return gcd(y,x%y)\ndef lcm(x,y):return x*(y/gcd(x,y))\ndef isprime(x):\n i=2\n while (i*i<=x):\n \tif (x%i==0):return False\n\ti+=1\n return True\n\nn=readNum()\nn=int(n)\na=readArray()\n\nind=0\nwhile ind<n-1 and a[ind]<a[ind+1]:ind+=1\nwhile ind<n-1 and a[ind]==a[ind+1]:ind+=1\nwhile ind<n-1 and a[ind]>a[ind+1]:ind+=1\n\nif ind==n-1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nflag = True\nf =f3 = True\nfor i in range(1,n):\n\tif flag==True:\n\t\tif a[i]==a[i-1]:\n\t\t\tflag = False\n\t\t\tprev = a[i-1]\n\t\telif a[i]<a[i-1]:\n\t\t\tflag = False\n\t\t\tf3 = False\n\telse:\n\t\tif f3==True and a[i]==prev:\n\t\t\tf = True\n\t\telse:\n\t\t\tf3 = False\n\t\t\tif a[i]>=a[i-1]:\n\t\t\t\tf = False\n\t\t\t\tbreak\nif f==True:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\ncheck = [0,0,0]\nfor i in range(1,n):\n if (a[i]>a[i-1] and (check[2]==1 or check[1]==1)) :\n print \"NO\"\n break\n elif (a[i]==a[i-1] and check[2]==1):\n print \"NO\"\n break\n elif (a[i]>a[i-1]) :\n check[0] = 1\n elif (a[i]==a[i-1]) :\n check[1] = 1\n elif (a[i]<a[i-1]) :\n check[2] = 1\nelse :\n print \"YES\""}, {"source_code": "def unimodal(arr):\n state = 0\n for i in range(0, len(arr)-1):\n if(arr[i] < arr[i+1] and (state==0)):\n state = 0\n elif(arr[i] == arr[i+1] and(state==0 or state==1)):\n state=1\n elif(arr[i] > arr[i+1]):\n state=2\n else:\n return \"NO\"\n break\n return \"YES\"\ninput()\nprint(unimodal([int(x) for x in input().split()])) "}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\npos1,pos2=0,n-1\nfor i in range(n-1):\n if arr[i+1]>arr[i]:\n pos1+=1\n else:\n break\n\nfor i in range(n-1,-1,-1):\n if arr[pos2-1]>arr[pos2]:\n pos2-=1\n\ncheck=1\nfor i in range(pos1,pos2):\n if not arr[i]==arr[i+1]:\n check=0\n break\nif check==1:\n print(\"yes\")\nelse:\n print(\"no\")\n"}, {"source_code": "#!/usr/bin/env python3\ndef solve():\n n = get(int)\n ar = get([int])\n start = -inf\n i = 1\n while i < n and ar[i] > ar[i-1]:\n i += 1\n\n while i < n and ar[i] == ar[i-1]:\n i += 1\n\n while i < n and ar[i] < ar[i-1]:\n i += 1\n\n if i == n:\n return 'YES'\n else:\n return 'NO'\n\n\n\n\n\n\n\n\n\n_testcases = \"\"\"\n6\n1 5 5 5 4 2\n\nYES\n\n5\n10 20 30 20 10\n\nYES\n\n4\n1 2 1 2\n\nNO\n\n7\n3 3 3 3 3 3 3\n\nYES\n\n\"\"\".strip()\n\n# ======================= B O I L E R P L A T E ======================= #\n# Practicality beats purity\n\nimport re\nimport sys\nimport math\nimport heapq\nfrom heapq import heapify, heappop, heappush\nimport bisect\nfrom bisect import bisect_left, bisect_right\nimport operator\nfrom operator import itemgetter, attrgetter\nimport itertools\nimport collections\n\ninf = float('inf')\nsys.setrecursionlimit(10000)\n\n\ndef tree():\n return collections.defaultdict(tree)\n\n\ndef cache(func): # Decorator for memoizing a function\n cache_dict = {}\n\n def _cached_func(*args, _get_cache=False):\n if _get_cache:\n return cache_dict\n if args in cache_dict:\n return cache_dict[args]\n cache_dict[args] = func(*args)\n return cache_dict[args]\n return _cached_func\n\n\ndef equal(x, y, epsilon=1e-6):\n # https://code.google.com/codejam/kickstart/resources/faq#real-number-behavior\n if -epsilon <= x - y <= epsilon:\n return True\n if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:\n return False\n return (-epsilon <= (x - y) / x <= epsilon or -epsilon <= (x - y) / y <= epsilon)\n\n\ndef get(_type): # For easy input\n if type(_type) == list:\n if len(_type) == 1:\n _type = _type[0]\n return list(map(_type, input().strip().split()))\n else:\n return [_type[i](inp) for i, inp in enumerate(input().strip().split())]\n else:\n return _type(input().strip())\n\nif __name__ == '__main__':\n print(solve())"}, {"source_code": "n = input()\nq = map(int, raw_input().split())\nq = [-1000] + q + [-1000]\nd = map(lambda x: 1 if x[1]>x[0] else -1 if x[1]<x[0] else 0, zip(q[:-1], q[1:]))\nr = []\nl = -2\nfor i in d:\n\tif i != l: r.append(i)\n\tl = i\nif r == [1,0,-1] or r == [1,-1]:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "from sys import stdin\n\nn = int(stdin.readline().strip())\na = map(int, stdin.readline().strip().split())\n\ni = 1\nwhile i < n and a[i] > a[i-1]:\n i += 1\n \nwhile i < n and a[i] == a[i-1]:\n i += 1\n \nwhile i < n and a[i] < a[i-1]:\n i += 1\n \nif i < n:\n print 'NO'\n quit()\n \nprint 'YES' "}, {"source_code": "n=input()\na=map(int,raw_input().split())\ni,j=0,n\nwhile i+1<n and a[i]<a[i+1]:\n i+=1\nwhile j>1 and a[j-1]<a[j-2]:\n j-=1\nb=set(a[i:j])\nprint 'YES' if len(b)<2 else 'NO'"}, {"source_code": "a, lst = int(input()), input().split()\nlst = [int(ch) for ch in lst]\n\ndef is_modal(a, lst):\n i = 1\n for i in range(i, a):\n if not (lst[i - 1] < lst[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, a):\n if not (lst[i - 1] == lst[i]):\n break\n else:\n return \"YES\"\n\n for i in range(i, a):\n if not (lst[i - 1] > lst[i]):\n return \"NO\"\n else:\n return \"YES\"\n\nprint(is_modal(a, lst))"}, {"source_code": "n = input()\narr = list(map(int, input().split()))\ninc = False\nflat = False\ndec = False\no = \"Yes\"\nfor i in zip(arr, arr[1:]):\n\tif i[0] < i[1]:\n\t\tinc = True\n\t\tif flat or dec:\n\t\t\to = \"No\"\n\t\t\tbreak\n\telif i[0] == i[1]:\n\t\tflat = True\n\t\tif dec:\n\t\t\to = \"No\"\n\telif i[0] > i[1]:\n\t\tdec = True\n\nprint(o)"}, {"source_code": "import sys\n\nit = iter(sys.stdin.read().splitlines())\n\nlargo = int(next(it))\nlista = [int(x) for x in next(it).split()]\n\ni = 0\n\nwhile(i<largo-1) and (lista[i]<lista[i+1]):\n i += 1\nwhile(i<largo-1) and (lista[i]==lista[i+1]):\n i += 1\nwhile(i<largo-1) and (lista[i]>lista[i+1]):\n i += 1\n\nif(i == largo-1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(raw_input())\n\narr = [int(i) for i in raw_input().split()]\n\ntest = []\n\nfor i in xrange(n-1):\n if arr[i] < arr[i+1]:\n test.append(-1)\n if arr[i] == arr[i+1]:\n test.append(0)\n if arr[i] > arr[i+1]:\n test.append(1)\n\nworks = \"YES\"\n\nfor i in xrange(n-2):\n if test[i] > test[i+1]:\n works = \"NO\"\n\nprint works\n"}, {"source_code": "n=int(input())\nl=[int(x) for x in input().split()]\ni=0\nwhile i<(n-1) and l[i]<l[i+1]:\n i+=1\nwhile i<n-1 and l[i]==l[i+1]:\n i+=1\nwhile i<n-1 and l[i]>l[i+1]:\n i+=1\nif i==n-1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\n\nn = input()\na = map(int, raw_input().split())\n\nch = True\nif( n == 1 ):\n print 'YES'\nelse:\n i = 0\n while( a[i] < a[i + 1] ):\n i += 1\n if( i == n - 1 ):\n break\n if( i < n - 1 ):\n while( a[i] == a[i + 1] ):\n i += 1\n if( i == n - 1 ):\n break\n for j in range(i, n - 1):\n if( a[j] <= a[j + 1] ):\n print 'NO'\n ch = False\n break\n if( ch == True ):\n print 'YES'\n\n"}, {"source_code": "# in_x = input().split(\" \")\n#\n# a, b = int(in_x[0]), int(in_x[1])\n# while a != 0 and b != 0:\n# if a >= 2 * b:\n# a = a % (2 * b)\n# continue\n# elif b >= 2 * a:\n# b = b % (2 * a)\n# continue\n# else:\n# break\n# print(a, b)\n# s, v1, v2, t1, t2 = [int(x) for x in input().split(\" \")]\n#\n# first = t1 + t1 + (s * v1)\n# second = t2 + t2 + (s * v2)\n# if first < second:\n# print(\"First\")\n# elif first > second:\n# print(\"Second\")\n# else:\n# print(\"Friendship\")\n\nlength = int(input())\nvals = [int(x) for x in input().split(\" \")]\n\nincreasing = 0\nconstant = 1\ndecreasing = 0\nfailed = False\nfor i in range(length - 1):\n if vals[i + 1] > vals[i]:\n if decreasing == 1:\n failed = True\n if increasing == 2:\n failed = True\n break\n else:\n increasing = 1\n continue\n if vals[i + 1] == vals[i]:\n if decreasing == 1:\n failed = True\n break\n increasing = 2\n constant = 1\n continue\n if vals[i + 1] < vals[i]:\n if constant == 0:\n failed = True\n decreasing = 1\n constant = 2\n continue\n\nif failed:\n print(\"No\")\nelse:\n print(\"Yes\")\n"}, {"source_code": "n=int(input())\nsl=list(map(int,input().split()))\nb=0\nc=0\nd=0\ni=0\nj=0\nfor i in range(1,n):\n if sl[i]>sl[i-1]:\n if (b==1 or c==1):\n print(\"NO\")\n exit()\n d=1\n if sl[i]==sl[i-1]:\n if b==1:\n print(\"NO\")\n exit()\n c=1\n if sl[i]<sl[i-1] :\n b=1\nprint(\"YES\")\nexit()\n "}, {"source_code": "n = input()\narr = [int(x) for x in raw_input().split()]\n\nb = 0\ncv = 0\nfor i in range(n-1):\n ov = 0\n if arr[i] == arr[i+1]:\n ov = 1\n elif arr[i] > arr[i+1]:\n ov = 2\n \n if ov < cv:\n b = -1\n cv = ov\n\nprint \"NO\" if b == -1 else \"YES\""}, {"source_code": "\nINCREASING = 0\nDECREASING = 1\nEQUAL = 2\n\nn = int(raw_input())\narray = map(int, raw_input().split())\n\nstate = INCREASING\nres = True\nbegin = True\n\nif len(array) > 0:\n prev = array[0]\n \nfor i in array:\n if i > prev:\n if state != INCREASING:\n res = False\n break\n \n if i < prev:\n state = DECREASING\n\n if i == prev and not begin:\n if state == DECREASING:\n res = False\n break\n state = EQUAL\n\n begin = False\n prev = i\n\nprint 'YES' if res else 'NO'"}, {"source_code": "\nn = int(input())\narray = list(map(int,input().split()))\n\nif(n==1):\n print(\"YES\")\nif(n>=2):\n begin = 0;\n end = len(array)-1\n\n while(array[begin]<array[begin+1] if begin<end else False):\n begin+=1\n\n while(array[end]<array[end-1] and end!=begin):\n end-=1\n\n test = set()\n\n for i in range(begin,end+1):\n test.add(array[i])\n if(len(test)==1 or begin==end):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "def Unimodal():\n n = int(raw_input())\n array = list(map(int,raw_input().split()))\n\n if array.count(array[0]) == n:\n return 'YES'\n else:\n current = array[0]\n i = 1\n while i < n:\n if array[i] > current:\n current = array[i]\n i += 1\n else:\n break\n while i < n:\n if array[i] == current:\n current = array[i]\n i += 1\n else:\n break\n while i < n:\n if array[i] < current:\n current = array[i]\n i += 1\n else:\n break\n if i == n:\n return 'YES'\n else:\n return 'NO'\n \nprint Unimodal()"}, {"source_code": "from sys import stdin\ninput = lambda :stdin.readline().strip()\n\nn = int(input())\na = [*map(int, input().split())]\n\nstate = None\nanswer = \"YES\"\nfor i in range(1, n):\n\tif state == None:\n\t\tif a[i] == a[i-1]:\n\t\t\tstate = \"sam\"\n\t\telif a[i] < a[i-1]:\n\t\t\tstate = 'dec'\n\t\telse:\n\t\t\tstate = 'inc'\n\tif state == 'dec':\n\t\tif a[i] == a[i-1]:\n\t\t\tanswer = 'NO'\n\t\telif a[i] > a[i-1]:\n\t\t\tanswer = \"NO\"\n\t\telse:\n\t\t\tcontinue\n\tif state == 'sam':\n\t\tif a[i] == a[i-1]:\n\t\t\tcontinue\n\t\telif a[i] > a[i-1]:\n\t\t\tanswer = 'NO'\n\t\t\tbreak\n\t\telse:\n\t\t\tstate = 'dec'\n\tif state == 'inc':\n\t\tif a[i] == a[i-1]:\n\t\t\tstate = \"sam\"\n\t\telif a[i] > a[i-1]:\n\t\t\tcontinue\n\t\telse:\n\t\t\tstate = 'dec'\nprint(answer)"}, {"source_code": "n=input()\na=map(int,raw_input().split())\ntop=max(a)\nt=[]\ncount=0\nflag=0\nfor i in range(n):\n\tif a[i]==top:\n\t\tt.append(i)\n\t\tcount+=1\nfor i in range(t[0]):\n\tif i+1<=t[0]:\n\t\tif a[i]>=a[i+1]:\n\t\t\tflag=1\nfor i in range(t[0],t[count-1]+1):\n\tif a[i]!=top:\n\t\tflag=1\nfor i in range(t[count-1]+1,n):\n\tif i+1<n:\n\t\tif a[i]<=a[i+1]:\n\t\t\tflag=1\nif flag==1:\n\tprint 'NO'\nelse:\n\tprint 'YES'"}, {"source_code": "from sys import maxsize, stdout, stdin,stderr\nmod = int(1e9 + 7)\nimport re #can use multiple splits\ndef tup():return map(int,stdin.readline().split())\ndef I(): return int(stdin.readline())\ndef lint(): return [int(x) for x in stdin.readline().split()]\ndef S(): return input().strip()\ndef grid(r, c): return [lint() for i in range(r)]\ndef debug(*args, c=6): print('\\033[3{}m'.format(c), *args, '\\033[0m', file=stderr)\nfrom math import log2,sqrt\nfrom collections import defaultdict\n# s= S().split()\n# n = I()\n#\n# d='^>v<'\n# if n%2==0:print('undefined')\n# else:\n# st =d.find(s[0]).__index__()\n# en = d[(st+n)%4]\n# if en==s[1]:print('cw')\n# elif d[(st-n)%4]==s[1]:print('ccw')\n# else:print('undefined')\n#\n# #when k it is even it will end up in the same position so direction can't be determined\n# #\n# k = I()\n# n =S()\n# arr = sorted(list(map(int,n)))\n# cnt =sum(arr)\n# ans = 0\n# #print(arr,cnt)\n# for i in arr:\n# if cnt < k:\n# cnt+=9 - i\n# ans+=1\n# print(ans)\n# #increasing sum by 9-d\n\nn,ls = I(),lint()\ni =0\nwhile i < n-1 and ls[i] < ls[i+1]:\n i+=1\nwhile i < n-1 and ls[i]==ls[i+1]:\n i+=1\nwhile i < n-1 and ls[i]>ls[i+1]:\n i+=1\nif i==n-1:print(\"YES\")\nelse:print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "__author__ = 'Esfandiar'\nn = int(input())\na = list(map(int,input().split()))\nf = 0\nfor i in range(1,n):\n if f == 0:\n if a[i] <= a[i-1]:\n f = 1\n con = a[i-1]\n else:\n if a[i] > a[i-1]:\n print('NO')\n exit()\n elif a[i] == a[i-1]:\n if a[i] != con:\n print('NO')\n exit()\n \n \nprint(\"YES\")\n"}, {"source_code": "N = input()\nL = map(int, raw_input().split())\n\nsolve = True\n\nstep = 1\n\nfor i in xrange(1, N):\n if step == 1:\n if L[i] > L[i - 1]:\n continue\n else:\n step = 2\n \n if step == 2:\n if L[i] == L[i - 1]:\n continue\n else:\n step = 3\n \n if step == 3:\n if L[i] < L[i - 1]:\n continue\n else:\n solve = False\n break\n\n\nif solve:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\narr.append(-100000000000)\narr.append(1000000000000)\ni = 0\nwhile(arr[i] < arr[i+1] and i < n-1):\n\ti = i + 1\n\nwhile(arr[i] == arr[i+1] and i < n-1):\n\ti = i + 1\n\nwhile(arr[i] > arr[i+1] and i < n-1):\n\ti = i + 1\n\nif(i == n-1):\n\tprint(\"YES\")\n\nelse:\n\tprint(\"NO\")\n\n\n\n"}, {"source_code": "def main():\n read = lambda: tuple(map(int, input().split()))\n n = read()[0]\n l = read()\n if len(l) == 1:\n return \"YES\"\n lv = l[0]\n ss = []\n \n for v in l[1:]:\n state = \"inc\" if v > lv else \"dec\" if v < lv else \"norm\"\n if len(ss) == 0:\n if state == \"dec\":\n ss += [\"norm\"]\n ss += [state]\n elif ss[-1] != state:\n if ss[-1] == \"inc\" and state == \"dec\":\n ss += [\"norm\"]\n ss += [state]\n lv = v\n\n for state in ('inc', 'dec', 'norm'):\n if ss.count(state) > 1:\n return \"NO\"\n if len(ss) == 1:\n return \"YES\"\n if len(ss) == 2:\n return \"YES\" if ss == [\"norm\", \"dec\"] or ss == [\"inc\", \"norm\"] else \"NO\"\n return \"YES\" if ss == ['inc', 'norm', 'dec'] else \"NO\"\nprint(main())\n"}, {"source_code": "x = int(input())\nnums = list(map(int, input().split()))\ni = 1\nwhile(i<x and nums[i-1] < nums[i]):\n i+=1\nwhile(i<x and nums[i-1] == nums[i]):\n i+=1\nwhile(i<x and nums[i-1] > nums[i]):\n i+=1\n \nif(i==x):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\nn = int(input())\ndata = [int(x) for x in input().split()]\nif len(data) > 1:\n flgVV = data[0] < data[1]\n flgVn = data[-2] > data[-1]\n if flgVV:\n i = 0\n while i < len(data) - 1 and data[i] < data[i + 1]:\n i += 1\n if i == len(data) - 1:\n print('YES')\n sys.exit()\n while i < len(data) - 1 and data[i] == data[i + 1]:\n i += 1\n if i == len(data) - 1 and not flgVn:\n print('YES')\n sys.exit()\n while flgVn and i < len(data) - 1 and data[i] > data[i + 1]:\n i += 1\n if i < len(data) - 1:\n print('NO')\n sys.exit()\n print('YES')\n else:\n i = 0\n while i < len(data) - 1 and data[i] == data[i + 1]:\n i += 1\n if i == len(data) - 1 and not flgVn:\n print('YES')\n sys.exit()\n while flgVn and i < len(data) - 1 and data[i] > data[i + 1]:\n i += 1\n if i < len(data) - 1:\n print('NO')\n sys.exit()\n print('YES')\nelse:\n print('YES')"}, {"source_code": "n = int(input())\na = list(map(int, input().split(' ')))\nl1 = 0; l2 = n-1\nwhile l1<n-1 and a[l1+1]>a[l1]: l1 += 1\nwhile l2>0 and a[l2-1]>a[l2]: l2 -= 1\nx = a[l2]\nans = \"YES\"\nfor i in range(l1,l2):\n if a[i] != x: ans = \"NO\"; break\nprint(ans)"}, {"source_code": "import sys\nnu = input()\nm = [int(i) for i in input().split()]\nif len(m) == 1: \n print('YES')\n sys.exit()\n \n \n\nprev_ind = 1\nprev = m[0]\nind = lambda x, y: int((y-x)/abs(y-x)) if y != x else 0\n\n\nfor i in m[1:]:\n if ind(prev, i) <= prev_ind: \n prev_ind = ind(prev, i)\n prev = i\n else :\n print('NO')\n sys.exit()\nprint('YES')\n "}, {"source_code": "curP = 0\n\ninput()\n\nA = list(map(int, input().split()))\n\nf= True\nfor i in range(1, len(A)):\n if A[i] > A[i-1] and (curP == 1 or curP == 2):\n f = False\n break\n \n elif A[i] == A[i-1] and (curP == 2): \n f = False\n break\n \n elif A[i] == A[i-1]:\n curP = 1\n \n elif A[i] < A[i-1]:\n curP = 2\n \nif f:\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = 0\nc = 0\nd = 0\nfor i in range(n-1):\n if(a[i] < a[i+1] and b == 0 and d == 0):\n continue\n elif(a[i] == a[i+1] and b == 0):\n d = 1\n continue\n elif(a[i] > a[i+1] and b == 0 and d == 1):\n b = 1\n else:\n if(a[i] < a[i+1] and (b == 1 or d == 1)):\n c = 1\n break\n elif(a[i] == a[i+1] and b == 1):\n c = 1\n break\n else:\n b = 1\nif(c == 1):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n=int(input())\na=[int(x) for x in input().split()]\nwasc=wcon=wdes=False\nuni=True\nfor x in range(1,n):\n\tif(a[x] > a[x-1]):\n\t\twasc=True\n\t\tif(wdes or wcon):\n\t\t\tuni=False\n\t\t\tbreak\n\t\tcontinue\n\telse:\n\t\tif(a[x] == a[x-1]):\n\t\t\twcon=True\n\t\t\tif(wdes):\n\t\t\t\tuni=False\n\t\t\t\tbreak\n\t\t\tcontinue\n\t\telse:\n\t\t\tif(a[x] < a[x-1]):\n\t\t\t\twdes=True\n\t\t\t\tcontinue\nif(uni):print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "R= lambda: map(int,input().split())\nn=int(input())\nl=list(R())\ni,s1,s2,s3=1,0,0,0\nwhile i<n and l[i]>l[i-1]: i+=1\ns1=i-1\nwhile i<n and l[i]==l[i-1]: i+=1\ns2=i-s1\nwhile i<n and l[i]<l[i-1]: i+=1\ns3=i-(s2+s1)\nif s1+s2+s3==n: print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "def get(l):\n z=l[0]\n flag=0\n for i in l[1:]:\n if i-z>0 and flag==0:\n flag = 0\n elif i-z==0 and flag<=1:\n flag = 1\n elif i-z<0 and flag<=2:\n flag =2\n \n else:\n return 'NO'\n \n z = i\n return 'YES'\n \n_ = input()\nl = list(map(int,input().split()))\nprint(get(l))\n"}, {"source_code": "n = int(raw_input())\narr = map(int, raw_input().split())\n\n\ninc = 1\nconstant = 2\ndec = 3\n\nfor i in xrange(1, len(arr)):\n if (arr[i] > arr[i-1]):\n if (dir == constant or dir == dec):\n print \"NO\"\n exit(0)\n dir = inc\n continue\n if (arr[i] == arr[i-1]):\n if (dir == dec):\n print \"NO\"\n exit(0)\n dir = constant\n continue\n if (arr[i] < arr[i-1]):\n dir = dec\n continue\nprint \"YES\""}, {"source_code": "n = input()\narr = map(int, raw_input().split(' '))\nblocks = []\n\nif len(arr) == 1:\n print('YES')\nelse:\n \n for i in range(1, n):\n \n diff = arr[i] - arr[i-1]\n if diff > 0:\n block = '+'\n elif diff == 0:\n block = '='\n else:\n block = '-'\n \n if len(blocks) > 0:\n if blocks[-1] != block:\n blocks.append(block)\n else:\n blocks.append(block)\n \n status = ''.join(blocks)\n if status == '+=-' or status == '=' or status == '+=' or status == '=-' or status == '+-' or status == '+' or status == '-':\n print('YES')\n else:\n print('NO')"}, {"source_code": "raw_input()\nvals = map(int, raw_input().split())\n\nphase = 0\nres = True\n\nfor i in range(1, len(vals)):\n if vals[i-1] < vals[i]:\n if phase != 0:\n res = False\n if vals[i-1] == vals[i]:\n if phase == 0:\n phase = 1\n if phase != 1:\n res = False\n if vals[i-1] > vals[i]:\n if phase <= 1:\n phase = 2\n if phase != 2:\n res = False\n\nif res:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "no =\"NO\"\nn =int(raw_input())\narr =map(int,raw_input().split())\nif n == 1:\n\tprint \"YES\"\n\tquit()\na =0\nb =0\nc =0\nfor i in range(1,n):\n\tif arr[i-1] < arr[i]:\n\t\tif b == 0 and c == 0:\n\t\t\ta =1\n\t\telse:\n\t\t\tprint no\n\t\t\tquit()\n\telif arr[i-1] == arr[i]:\n\t\tif c == 0:\n\t\t\tb =1\n\t\telse:\n\t\t\tprint no\n\t\t\tquit()\n\telif arr[i-1] > arr[i]:\n\t\tc =1\nif a == 1 and b == 1 and c == 1:\n\tprint \"YES\"\nelif a == 1 and b == 1:\n\tprint \"YES\"\nelif b == 1:\n\tprint \"YES\"\nelif b == 1 and c == 1:\n\tprint \"YES\"\nelif a == 1 and c ==1:\n\tprint \"YES\"\nelif a == 1:\n\tprint \"YES\"\nelif c == 1:\n\tprint \"YES\"\nelse:\n\tprint no"}], "negative_code": [{"source_code": "n = int(raw_input())\nnums = list(map(int,raw_input().split()))\nf = 0\nv = 1\nfor i in range(n-1):\n if nums[i]>nums[i+1]:\n f = 1\n if nums[i] <= nums[i+1] and f:\n v = 0\nif v:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def unimodal(arr):\n state = 0\n for i in range(0, len(arr)-1):\n if(arr[i] < arr[i+1] and (state==0)):\n state = 0\n elif(arr[i] >= arr[i+1] and (state==0 or state==1)):\n state=1\n else:\n return \"NO\"\n break\n return \"YES\"\ninput()\nprint(unimodal([int(x) for x in input().split()])) "}, {"source_code": "n = int(input())\nl = list(map(int, input().split(\" \")))\ncenter = max(l)\n\ninc = False\nmiddle = False\ndec = False\nflag = False\nfor i in range(n-1):\n if l[i] == l[i+1] and l[i] == center:\n middle = True\n continue\n if l[i] <= l[i+1] and middle:\n print(\"NO\")\n flag = True\n break\n if l[i+1] == center:\n middle = True\n if l[i] >= l[i+1] and not middle:\n print(\"NO\")\n flag = True\n break\nif not flag:\n print(\"YES\")\n"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\ns,t=0,0\nfor i in range(1,n) :\n if arr[i]<arr[i-1] or arr[i]==arr[i-1] : s=1\n if arr[i]>arr[i-1] and s : t=1\nif t: print(\"NO\")\nelse : print(\"YES\")"}, {"source_code": "def unimodal(a, lst):\n i = 1\n for i in range(i, a):\n if not (lst[i - 1] < lst[i]):\n break\n else:\n return \"NO\"\n\n for i in range(i, a):\n if not (lst[i - 1] == lst[i]):\n break\n else:\n return \"NO\"\n\n for i in range(i, a):\n if not (lst[i - 1] > lst[i]):\n return \"NO\"\n else:\n return \"NO\"\n\nif __name__ == '__main__':\n a, lst = int(input()), input().split()\n lst = [int(ch) for ch in lst]\n print(unimodal(a, lst))\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nans = 'YES'\nls = []\nfor i in range(n - 1):\n if a[i] < a[i + 1]:\n ls.append('<')\n elif a[i] > a[i + 1]:\n ls.append('>')\n else:\n ls.append('=')\nfor i in range(n - 2):\n for j in range(i + 1, n - 1):\n if ls[i] == '>' and ls[j] == '<':\n ans = 'NO'\n break\n\nprint(ans)\n"}, {"source_code": "\nn = int(input())\na = list(map(int, input().split()))\ni = 0\nj = n - 1\nflag = False\nwhile i < n - 1 and a[i] < a[i + 1]:\n i += 1\nwhile j > 1 and a[j - 1] > a[j]:\n j -= 1\nif a[i] == a[j] and i <= j:\n for k in range(i, j + 1):\n if a[k] != a[i]:\n print('NO')\n flag = True\n break\n if not flag:\n print('YES')\nelse:\n print('NO')\n \n\n \n"}, {"source_code": "import sys\nn = int(raw_input())\n\narr = map(int, raw_input().split())\n\nm = max(arr)\nx1 = -1\nx2 = -1\nfor i in range(n):\n if arr[i] == m:\n x2 = i\n else:\n if x1 == -1:\n x1 = i\n\nfor i in range(x1,x2+1):\n if arr[i] != m:\n print \"NO\"\n sys.exit(0)\n\nfor i in range(x1):\n if arr[i] >= arr[i+1]:\n print \"NO\"\n sys.exit(0)\n\nfor i in range(x2, n-1):\n if arr[i] <= arr[i+1]:\n print \"NO\"\n sys.exit(0)\n\nprint \"YES\""}, {"source_code": "n=input()\nmy_array=[int(k) for k in input().split(' ')]\n\ndef check_increasing(lis):\n for l in range(1, len(lis)):\n if lis[l] <= lis[l-1]:\n return False\n\n return True\n\ndef check_decreasing(lis):\n for i in range(1, len(lis)):\n if lis[i]>= lis[i-1]:\n return False\n\n return True\n\n\ndef get_indices(lis):\n element=None\n final=[]\n for i in range(1,len(lis)):\n if lis[i] <= lis[i-1]:\n element=lis[i-1]\n final.append(i-1)\n break\n\n\n if len(final)>0:\n for l in range(final[0]+1, len(lis)):\n if lis[l] != element:\n final.append(l)\n break\n\n if len(final)==1:\n final.append(-1)\n\n else:\n final=[-1,-1]\n\n return final\n\n\ndef solve():\n indices=get_indices(my_array)\n i=my_array[:indices[0]]\n d=my_array[indices[1]:]\n\n if check_increasing(i) and check_decreasing(d):\n print('YES')\n return\n else:\n print('NO')\n return\n\nsolve()\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nfor i in range(n-1):\n\tif l[i] > l[i+1]:\n\t\tbreak\nfor j in range(n-1,0,-1):\n\tif l[j-1] <= l[j]:\n\t\tbreak\nif i == j:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "import itertools as it\nsign = lambda x: (x > 0) - (x < 0)\nn, arr = input(), [int(x) for x in input().split()]\ndiff = (sign(a-b) for a, b in zip(arr, arr[1:]))\ndiff = (set(g) for k, g in it.groupby(diff))\ndiff = list(it.chain.from_iterable(diff))\nif diff in [[-1, 0, 1], [-1, 1], [0]]:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "def find(A):\n s=''\n for i in range(len(A)-1):\n if A[i]<A[i+1]:\n s+='i'\n elif A[i]==A[i+1]:\n s+='c'\n else:\n s+='d'\n s.lstrip('i')\n s.rstrip('d')\n s.strip('c')\n if s=='':\n return 1\n else:\n return 0\n \n\n \nN=input()\nA=list(map(int,input().strip().split(' ')))\nif find(A)==1:\n print('YES')\nelse:\n print('NO')\n \n \n \n"}, {"source_code": "def unimodal_new(mylist) : \n if len(mylist) == 1 :\n return\"YES\"\n\n i = 0\n while (mylist[i] < mylist[i+1]) and (i < len(mylist) - 2): \n i += 1 \n\n if i == len(mylist) - 2 : \n return \"YES\"\n \n while (mylist[i] == mylist[i+1]) and (i < len(mylist) - 2): \n i += 1 \n \n for j in range(i, len(mylist) - 1) : \n if mylist[j] <= mylist[j+1] : \n return \"NO\"\n \n return \"YES\"\n\nif __name__ == \"__main__\":\n n = int(input())\n arrlist = [int(x) for x in input().split()]\n print(unimodal_new(arrlist)) "}, {"source_code": "def unimodalArray(n,x):\n \n grIndex = 0\n reps = 0\n \n for i in range(0,n-1):\n if(x[i] < x[i+1]):\n grIndex = i+1\n else:\n break \n \n for i in range(grIndex,n-1):\n if(x[i] == x[i+1]):\n rgrIndex = i+1\n else:\n break\n \n for i in range(grIndex,n-1):\n if(x[i] <= x[i+1]):\n return \"NO\"\n \n return \"YES\"\n\nnRaw = input()\nn = int(nRaw)\n\nxRaw = input()\nxStr = xRaw.split()\nx = list(map(int, xStr))\n\nprint(unimodalArray(n,x))"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\n\n\nlasti = a[0]\ndd = 0\nfor i in range(1,n):\n\tcur = a[i]\n\tif cur <= lasti:\n\t\tdd = 1\n\telif dd:\n\t\tdd = 0\n\t\tbreak\n\tlasti = cur\nif dd:\n\tprint('YES')\nelse:\n\tprint('NO')\n\n"}, {"source_code": "count = input()\nchisla = input().split()\n\n\ndef strictly_increasing(L):\n return all(x<y for x, y in zip(L, L[1:]))\n\n\ndef strictly_decreasing(L):\n return all(x>y for x, y in zip(L, L[1:]))\n\nmax_value = max(chisla)\nmax_indexes = [index for index in range(len(chisla)) if chisla[index] == max_value]\ndifference_is_one = True\nfor i in range(len(max_indexes)-1):\n if (max_indexes[i+1]-max_indexes[i])>1:\n difference_is_one = False\nif difference_is_one and strictly_increasing(chisla[:max_indexes[0]+1]) and strictly_decreasing(chisla[max_indexes[-1]:]):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\narr = [int(i) for i in input().split()]\n\nL = 1\nR = n - 2\nprev = arr[0]\nlast = arr[n - 1]\n\nwhile L < n and arr[L] > prev:\n prev = arr[L]\n L += 1\nwhile R >= 0 and arr[R] > last:\n last = arr[R]\n R -= 1\n\nfor el in range(L, R + 1):\n if arr[el] != arr[el + 1]:\n print(\"NO\")\n exit()\n\nprint(\"YES\")"}, {"source_code": "\nn = int(input())\narray = list(map(int,input().split()))\n\nif(n==1):\n print(\"YES\")\nif(n==2):\n print(\"NO\")\nif(n>=3):\n begin = 0;\n end = len(array)-1\n\n while(array[begin]<array[begin+1] if begin<end else False):\n begin+=1\n\n while(array[end]<array[end-1] and end!=begin):\n end-=1\n\n test = set()\n\n for i in range(begin,end+1):\n test.add(array[i])\n if(len(test)==1 or begin==end):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "import itertools\nimport math\nfrom collections import defaultdict\n\ndef input_ints():\n return list(map(int, input().split()))\n\ndef solve():\n n = int(input())\n a = input_ints()\n x = 0\n while x < n - 1:\n if a[x] < a[x + 1]:\n x += 1\n else:\n break\n y = n - 1\n while y > 0:\n if a[y - 1] > a[y]:\n y -= 1\n else:\n break\n for i in range(x, y):\n if a[i] != a[x]:\n print('NO')\n return\n print('YES')\n\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "import sys\n\nn = sys.stdin.readline()\nwhile n:\n arr = [int(val) for val in sys.stdin.readline().split()]\n ans = \"\"\n if len(arr) == 1:\n ans = \"YES\"\n elif len(arr) == 3:\n if (arr[0] == arr[1] and arr[1] == arr[2]) or (arr[0] <= arr[1] and arr[1] >= arr[2]):\n ans = \"YES\"\n else:\n status = None\n err = False\n for i in range(len(arr) - 1):\n if status is None:\n if arr[i] < arr[i + 1]:\n status = \"i\"\n if arr[i] == arr[i + 1]:\n status = \"r\"\n if arr[i] > arr[i + 1]:\n status = \"d\"\n else:\n if arr[i] < arr[i + 1]:\n if status == \"r\" or status == \"d\":\n err = True\n break\n else:\n status = \"i\"\n if arr[i] == arr[i + 1]:\n if status == \"dec\":\n err = True\n break\n else:\n status = \"r\"\n if arr[i] > arr[i + 1]:\n if status == \"i\":\n err = True\n break\n else:\n status = \"d\"\n if err:\n ans = \"NO\"\n if not (arr[-1] <= arr[-2]):\n ans = \"NO\"\n else:\n ans = \"YES\"\n print(ans)\n n = sys.stdin.readline()"}, {"source_code": "\nn = int(input())\narray = list(map(int,input().split()))\n\nif(n==1):\n print(\"YES\")\nif(n==2):\n print(\"NO\")\nif(n>=3):\n begin = 0;\n end = len(array)-1\n while(array[begin]<array[begin+1]):\n begin+=1\n\n while(array[end]<array[end-1]):\n end-=1\n\n test = set()\n\n for i in range(begin,end+1):\n test.add(array[i])\n print(begin)\n print(end)\n if(len(test)==1 or begin==end):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\narr = list(map(int , input().split()))\nans = 0\ninc = 0\ni=0\nwhile ans ==0 and i+1<len(arr):\n if arr[i]==arr[i+1]:\n const = arr[i]\n arr = arr[i+2:]\n while len(arr)>1 and arr[0]==const:\n arr.remove(const)\n arr = [const] + arr\n dec = arr.copy()\n dec.sort(reverse = True)\n ans = 1\n if arr==dec:\n x = set(arr)\n if len(x)==len(arr) or (arr[0]==arr[1]):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n break\n elif arr[i]>arr[i+1]:\n ans = 1\n arr = arr[i+1:]\n dec = arr.copy()\n dec.sort(reverse = True)\n if arr==dec:\n x = set(arr)\n if len(x)==len(arr):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n break\n i = i + 1\nif ans==0:\n if len(arr)==1:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "count = input()\nchisla = input().split()\n\n\ndef strictly_increasing(L):\n return all(x<y for x, y in zip(L, L[1:]))\n\n\ndef strictly_decreasing(L):\n return all(x>y for x, y in zip(L, L[1:]))\n\nmax_value = max(chisla)\nmax_indexes = [index for index in range(len(chisla)) if chisla[index] == max_value]\ndifference_is_one = True\nfor i in range(len(max_indexes)-1):\n if (max_indexes[i+1]-max_indexes[i])>1:\n difference_is_one = False\nif difference_is_one and strictly_increasing(chisla[:max_indexes[0]+1]) and strictly_decreasing(chisla[max_indexes[-1]:]):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "quantity = int(input())\nalist = list(map(int, input().split()))\n\nresult = 'YES'\nidx = 0\nif quantity > 2:\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = 'NO'\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1] or alist[idx] == alist[idx + 1]:\n result = 'NO'\n print(result)\n\n elif alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n # if alist[idx] > alist[idx + 1]:\n # result = 'NO'\n # break\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = 'NO'\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = 'NO'\n break\n break\n break\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n if alist[idx] > alist[idx + 1]:\n idx += 1\n else:\n result = 'NO'\n break\n print(result)\nelif quantity == 2:\n if alist[0] > alist[1]:\n print('NO')\n else:\n print('YES')\nelif quantity == 1:\n print('YES')\n"}, {"source_code": "n = int(input())\ndata = list(map(int, input().split(' ')))\npos1 = 0\npos2 = n - 1\nfor i in range(1, len(data)):\n if data[i - 1] > data[i]:\n break\n else:\n pos1 += 1\nfor i in range(len(data) - 2, 0, -1):\n if data[i] < data[i + 1]:\n break\n else:\n pos2 -= 1\nstate = True\nif pos1 > pos2:\n for i in range(pos2 + 1, pos1 + 1):\n if data[i] != data[i - 1]:\n state = False\nelif pos1 < pos2:\n for i in range(pos1 + 1, pos2 + 1):\n if data[i] != data[i - 1]:\n state = False\nmain_element = data[pos1]\nfor i in range(1, len(data)):\n if data[i] == data[i - 1] and data[i] != main_element:\n state = False\nif pos1 == 0 and pos2 == 1:\n state = True\nprint('YES') if state else print('NO')\n"}, {"source_code": "pattern1=[\"constant\"]\npattern2=[\"constant\",\"down\"]\npattern3=[\"up\",\"constant\"]\npattern4=[\"up\",\"constant\",\"down\"]\npattern5=[\"up\",\"down\"]\npatternList=[str(pattern1),str(pattern2),str(pattern3),str(pattern4),str(pattern5)]\n\nn=input()\narray = [int(x) for x in raw_input().split(\" \")]\npattern=[]\n\nfor idx in range(len(array)-1):\n\tcurrentPattern=None\n\tif array[idx+1]>array[idx]:\n\t\tcurrentPattern=\"up\"\n\tif array[idx+1]<array[idx]:\n\t\tcurrentPattern=\"down\"\n\tif array[idx+1]==array[idx]:\n\t\tcurrentPattern=\"constant\"\n\tif idx==0 or (len(pattern)>0 and pattern[-1]!=currentPattern):\n\t\tpattern.append(currentPattern)\n\nif len(array)==1 or (str(pattern) in patternList):\n\tprint (\"YES\")\nelse:\n\tprint (\"NO\")\n"}, {"source_code": "n = int(input())\nx = list(map(int, input().split()))\nflag = 0\nif len(set(x)) == 1:\n print('YES')\nelif n < 3:\n print('NO')\nelse:\n for i in range(1, n):\n if flag == 0:\n if x[i] < x[i - 1]:\n flag = 1\n elif x[i] == x[i - 1]:\n flag = 2\n elif flag == 1:\n if x[i] >= x[i - 1]:\n print('NO')\n break\n elif flag == 2:\n if x[i] > x[i - 1]:\n print('NO')\n break\n elif x[i] < x[i - 1]:\n flag = 1\n if i == n - 1:\n print('YES')\n"}, {"source_code": "curP = 0\n\ninput()\n\nA = list(map(int, input().split()))\n\nf= True\nfor i in range(1, len(A)):\n if A[i] > A[i-1] and (curP == 1 or curP == 2):\n f = False\n break\n \n elif A[i] == A[i-1] and (curP == 2): \n f = False\n break\n \n elif A[i] == A[i-1]:\n curP = 1\n \n elif A[i] > A[i-1]:\n curP = 2\n \nif f:\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "def main():\n size = int(input())\n array = [int(x) for x in input().split(' ')]\n end = len(array) - 2\n has_rise = False\n has_constant = False\n\n for i in range(len(array) - 1):\n a, b = array[i], array[i + 1]\n if a < b:\n if has_rise or i == end:\n return 'NO'\n continue\n if a == b:\n has_constant = True\n has_rise = True\n continue\n if a > b:\n has_rise = True\n if not has_rise or not has_constant:\n return 'NO'\n continue\n return 'NO'\n return 'YES'\n\n\n\nif __name__ == '__main__':\n print(main())\n"}, {"source_code": "n=int(input())\na=[int(i) for i in input().split()]\nstage=0\nk=True\ntop=a[0]\nfor i in range(1,len(a)):\n if(a[i]>top) :\n if( stage==2 or stage==3):\n k=False\n break\n stage=1\n top=a[i]\n elif(a[i]==top):\n if(stage==3):\n k=False\n break\n else:\n stage=3\n top=a[i]\nif(k):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nstring = input()\nnumbers = list(map(int, string.split()))\nresults = \"NO\"\na, b = numbers[:-1], n\nfor x in range(n - 1):\n if not numbers[x] < numbers[x + 1]:\n a = numbers[x]\n b = x\n break\nc = n\nfor x in range(b, n):\n if not numbers[x] == a:\n c = x\n d = numbers[x]\n break\nresults = \"YES\"\nif c != n:\n if numbers[c] < a:\n for x in range(c, n - 1):\n print(numbers[x])\n if not numbers[x] > numbers[x + 1]:\n results = \"NO\"\n break\n else:\n results = \"NO\"\nprint(results)"}, {"source_code": "import itertools\nimport math\nfrom collections import defaultdict\n\ndef input_ints():\n return list(map(int, input().split()))\n\ndef solve():\n n = int(input())\n a = input_ints()\n x = 0\n while x < n - 1:\n if a[x] < a[x + 1]:\n x += 1\n else:\n break\n y = n - 1\n while y > 0:\n if a[y - 1] > a[y]:\n y -= 1\n else:\n break\n for i in range(x, y):\n if a[i] != a[x]:\n print('NO')\n return\n print('YES')\n\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "quantity = int(input())\nalist = list(map(int, input().split()))\n\nresult = 'YES'\nidx = 0\n\nif quantity == 3:\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n elif alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n\nelif quantity == 2:\n print('YES')\nelif quantity == 1:\n print('YES')\nelif quantity > 3:\n if alist[idx] > alist[idx + 1]:\n result = 'NO'\n print(result)\n\n elif alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n break\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n if alist[idx] > alist[idx + 1]:\n idx += 1\n else:\n result = 'NO'\n break\n print(result)\n"}, {"source_code": "n=input()\na=map(int,raw_input().split())\ntop=max(a)\nt=[]\ncount=0\nflag=0\nfor i in range(n):\n\tif a[i]==top:\n\t\tt.append(i)\n\t\tcount+=1\nfor i in range(t[0]):\n\tif i+1<=t[0]:\n\t\tif a[i]>a[i+1]:\n\t\t\tflag=1\nfor i in range(t[0],t[count-1]+1):\n\tif a[i]!=top:\n\t\tflag=1\nfor i in range(t[count-1]+1,n):\n\tif i+1<n:\n\t\tif a[i]<a[i+1]:\n\t\t\tflag=1\nif flag==1:\n\tprint 'NO'\nelse:\n\tprint 'YES'"}, {"source_code": "n=input()\nmy_array=[int(k) for k in input().split(' ')]\n\n\ndef check(lis):\n for i in range(1,len(lis)):\n if lis[i] > lis[i-1]:\n return False\n return True\n\n\ndef handle(lis):\n for i in range(1,len(lis)):\n if lis[i] <= lis[i-1]:\n if i==1:\n return False\n new_list=lis[i:]\n return check(new_list)\n return True\n\ndef solve():\n a=handle(my_array)\n\n if a:\n print(\"YES\")\n else:\n print('NO')\n\nsolve()\n\n\n\n\n\n\n\n\n"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\nvalues = list(map(int, stdin.readline().split()))\n\nlabel = 0\n\nif len(set(values)) == 1:\n label = 1\n\nfor i in range(n):\n a = values[:i]\n \n if sorted(a) == a: \n for j in range(i + 2, n):\n b = values[i:j]\n \n if len(set(b)) == 1 and sorted(values[j:], reverse = True) == values[j:]:\n label = 1\n break\n\nif label:\n stdout.write('YES')\nelse:\n stdout.write('NO')"}, {"source_code": "def check(c):\n combs = [[\"i\", \"c\", \"d\"], [\"c\"], [\"c\", \"d\"], [\"i\",\"c\"],[\"i\", \"d\"]]\n if removeNeighbours(list(c)) in combs: return True\n return False\n\n\ndef removeNeighbours(l):\n\n i = 0\n while i < len(l)-1:\n if l[i] == l[i+1]:\n del l[i]\n else:\n i = i + 1\n return l\n\n\ndef solve(a):\n c = \"\"\n \n for i in range(len(a) - 1):\n if a[i] < a[i+1]: \n c += \"i\"\n elif a[i] == a[i+1]: \n c += \"c\"\n elif a[i] > a[i+1]: \n c += \"d\"\n \n if len(a) == 1: return True \n elif check(c): return True\n return False\n \n \nN = int(input())\nA = [int(i) for i in input().split()]\nprint(\"YES\" if solve(A) else \"NO\", end = \"\")"}, {"source_code": "n = input()\narr = map(int, raw_input().split(' '))\nblocks = []\n\nif len(arr) == 1:\n print('YES')\nelse:\n \n for i in range(1, n):\n \n diff = arr[i] - arr[i-1]\n if diff > 0:\n block = '+'\n elif diff == 0:\n block = '='\n else:\n block = '-'\n \n if len(blocks) > 0:\n if blocks[-1] != block:\n blocks.append(block)\n else:\n blocks.append(block)\n \n status = ''.join(blocks)\n print(status)\n if status == '+=-' or status == '=' or status == '+=' or status == '=-' or status == '+-':\n print('YES')\n else:\n print('NO')"}, {"source_code": "x=int(input())\na=list(map(int,input().split()))\nb=[]\na.append(0)\nfor i in range(x):\n\tif a[i]<a[i+1]:\n\t\tb.append(a[i])\n\telse:\n\t\tbreak\nfor t in range(i,x):\n\tif a[t]==a[t+1]:\n\t\tb.append(a[t])\n\telse:\n\t\tbreak\nfor p in range(t,x):\n\tif a[p]>a[p+1]:\n\t\tb.append(a[p])\n\telse:\n\t\tbreak\nif b==a:\n\tprint('YES')\nelse:\n\tprint('NO')\n#author:SK__Shanto__\u32db\n#code__define__your__smartness"}, {"source_code": "def find(A):\n s=''\n for i in range(len(A)-1):\n if A[i]<A[i+1]:\n s+='i'\n elif A[i]==A[i+1]:\n s+='c'\n else:\n s+='d'\n s.lstrip('i')\n s.rstrip('d')\n s.strip('c')\n if s=='':\n return 1\n else:\n return 0\n \n\n \nN=input()\nA=list(map(int,input().strip().split(' ')))\nif find(A)==1:\n print('YES')\nelse:\n print('NO')\n \n \n \n"}, {"source_code": "n = int(input())\narr = list(map(int , input().split()))\nans = 0\ninc = 0\ni=0\nwhile ans ==0 and i+1<len(arr):\n if arr[i]==arr[i+1]:\n const = arr[i]\n arr = arr[i+2:]\n while len(arr)>1 and arr[0]==const:\n arr.remove(const)\n dec = arr.copy()\n dec.sort(reverse = True)\n ans = 1\n if arr==dec:\n x = set(arr)\n if len(x)==len(arr):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n break\n elif arr[i]>arr[i+1]:\n ans = 1\n arr = arr[i+1:]\n dec = arr.copy()\n dec.sort(reverse = True)\n if arr==dec:\n x = set(arr)\n if len(x)==len(arr):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n break\n i = i + 1\nif ans==0:\n if len(arr)==1:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = input()\narr = input()\n\nn = int(n)\n\ndef problem8(n,arr):\n arr = arr.split()\n bajando = False\n check = False\n increasing = False\n same = False\n cont=0\n\n \n if len(arr)==1:\n print(\"YES\")\n return\n \n for i in range(0,len(arr)-1):\n \n if arr[i]<arr[i+1]:\n increasing = True\n cont+=1\n elif arr[i]==arr[i+1]:\n same = True\n if check:\n if num!=arr[i]:\n good=False\n print (\"NO\")\n return\n else:\n good = True\n \n else:\n bajando = True\n \n if same:\n num = arr[i]\n check = True\n \n if cont<2 and increasing:\n good = False\n \n if bajando:\n if arr[i+1]<=arr[i]:\n good= True\n else:\n good = False\n \n if good:\n print(\"YES\")\n else:\n print(\"NO\") \n\n\n\n\nproblem8(n,arr)\n"}, {"source_code": "n = int(input())\nstring = input()\nnumbers = list(map(int, string.split()))\nresults = \"NO\"\na, b = numbers[:-1], n\nfor x in range(n - 1):\n if not numbers[x] < numbers[x + 1]:\n a = numbers[x]\n b = x\n break\nc = n\nfor x in range(b, n):\n if not numbers[x] == a:\n c = x\n d = numbers[x]\n break\nresults = \"YES\"\nif c != n:\n if numbers[c] < a:\n for x in range(c, n - 1):\n print(numbers[x])\n if not numbers[x] > numbers[x + 1]:\n results = \"NO\"\n break\n else:\n results = \"NO\"\nprint(results)"}, {"source_code": "def unimodal_new(mylist) : \n if len(mylist) == 1 :\n return\"YES\"\n\n i = 0\n while (mylist[i] < mylist[i+1]) and (i < len(mylist) - 2): \n i += 1 \n\n if i == len(mylist) - 2 : \n return \"YES\"\n \n while (mylist[i] == mylist[i+1]) and (i < len(mylist) - 2): \n i += 1 \n \n for j in range(i, len(mylist) - 1) : \n if mylist[j] <= mylist[j+1] : \n return \"NO\"\n \n return \"YES\"\n\nif __name__ == \"__main__\":\n n = int(input())\n arrlist = [int(x) for x in input().split()]\n print(unimodal_new(arrlist)) "}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nflag = True\nf =f3 = True\nfor i in range(1,n):\n\tif flag==True:\n\t\tif a[i]==a[i-1]:\n\t\t\tflag = False\n\t\t\tprev = a[i-1]\n\t\telif a[i]<a[i-1]:\n\t\t\tf3 = False\n\telse:\n\t\tif f3==True and a[i]==prev:\n\t\t\tf = True\n\t\telse:\n\t\t\tf3 = False\n\t\t\tif a[i]>=a[i-1]:\n\t\t\t\tf = False\n\t\t\t\tbreak\nif f==True:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "import sys\n\n\nnu = input()\nm = [int(i) for i in input().split()]\nif len(m) < 3: \n print('NO')\n sys.exit()\n\n\nprev_ind = 1\nprev = m[0]\nind = lambda x, y: int((y-x)/abs(y-x)) if y != x else 0\n\n\nfor i in m[1:]:\n #print(i)\n if ind(prev, i) <= prev_ind: \n #print(ind(prev, i))\n prev_ind = ind(prev, i)\n prev = i\n else :\n print('NO')\n sys.exit()\nprint('YES')\n "}, {"source_code": "n=input()\nmy_array=[int(k) for k in input().split(' ')]\n\ndef check_increasing(lis):\n if len(lis)==1:\n return False\n\n for l in range(1, len(lis)):\n if lis[l] <= lis[l-1]:\n return False\n\n return True\n\ndef check_decreasing(lis):\n if len(lis)==1:\n return False\n\n for i in range(1, len(lis)):\n if lis[i]>= lis[i-1]:\n return False\n\n return True\n\n\ndef get_indices(lis):\n element=None\n final=[]\n for i in range(1,len(lis)):\n if lis[i] <= lis[i-1]:\n element=lis[i-1]\n final.append(i-1)\n break\n\n\n if len(final)>0:\n for l in range(final[0]+1, len(lis)):\n if lis[l] != element:\n final.append(l-1)\n break\n\n if len(final)==1:\n final.append(-1)\n\n else:\n final=[-1,-1]\n\n return final\n\n\ndef solve():\n indices=get_indices(my_array)\n i=my_array[:indices[0]]\n d=my_array[indices[1]:]\n\n if check_increasing(i) and check_decreasing(d):\n print('YES')\n return\n else:\n print('NO')\n return\n\nsolve()\n\n\n\n\n\n\n\n\n"}, {"source_code": "# -*-coding=utf-8-*-\ndef helper():\n\tn = int(raw_input())\n\tarr = map(int, raw_input().split())\n\tL = 1\n\tR = n-1\n\twhile L < n and arr[L-1] < arr[L]:\n\t\tL+=1\n\twhile R > 1 and arr[R] < arr[R-1]:\n\t\tR-=1\n\t# print 'L: ',L\n\t# print 'R: ',R\n\twhile L - 1 <= R:\n\t\tif arr[L-1] != arr[R]:\n\t\t\treturn False\n\t\tR-=1\n\n\treturn True\nif helper():\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "def udimol(a):\n last = a[0]\n status = 0\n for x in a[1:]:\n if status == 0:\n if x == last:\n status = 1\n elif x > last:\n pass\n else:\n status = 2\n last = x\n elif status == 1:\n if x > last:\n status = 2\n last = x\n elif x == last:\n last = x\n else:\n return 'NO'\n else:\n if x < last:\n last = x\n else:\n return 'NO'\n\n return 'YES'\n\n\nraw_input()\ns = [int(x) for x in raw_input().split(' ')]\nprint udimol(s)\n"}, {"source_code": "def main():\n read = lambda: tuple(map(int, input().split()))\n n = read()[0]\n l = read()\n if len(l) == 1:\n return \"YES\"\n lv = l[0]\n ss = []\n \n for v in l[1:]:\n state = \"inc\" if v > lv else \"dec\" if v < lv else \"norm\"\n if len(ss) == 0:\n ss += [state]\n elif ss[-1] != state:\n if ss[-1] == \"inc\" and state == \"dec\":\n ss += [\"norm\"]\n ss += [state]\n lv = v\n for state in ('inc', 'dec', 'norm'):\n if ss.count(state) > 1:\n return \"NO\"\n if len(ss) == 1:\n return \"YES\" if ss == [\"norm\"] else \"NO\"\n if len(ss) == 2:\n return \"YES\" if ss == [\"norm\", \"dec\"] or ss == [\"inc\", \"norm\"] else \"NO\"\n return \"YES\" if ss == ['inc', 'norm', 'dec'] else \"NO\"\nprint(main())\n"}, {"source_code": "n = int(input())\ndata = list(map(int, input().split(' ')))\npos1 = 0\npos2 = n - 1\n\nhash_table = {}\nfor item in data:\n if item not in hash_table:\n hash_table[item] = 1\n else:\n hash_table[item] += 1\n\nhas_two = False\n\nfor value in hash_table.values():\n if value > 1 and has_two == False:\n has_two = True\n elif value > 1 and has_two == True:\n print('NO')\n exit(0)\n\nfor i in range(1, len(data)):\n if data[i - 1] > data[i]:\n break\n else:\n pos1 += 1\n\nfor i in range(len(data) - 2, 0, -1):\n if data[i] < data[i + 1]:\n break\n else:\n pos2 -= 1\n\nstate = True\n\nfor i in range(pos1 + 1, pos2 + 1):\n if data[i] != data[i - 1]:\n state = False\n\nprint('YES') if state else print('NO')\n"}, {"source_code": "n = input()\narr = input()\n\nn = int(n)\n\ndef problem8(n,arr):\n arr = arr.split()\n cont = 0\n num=0\n increasing = False\n decreasing = False\n same = False\n \n good = True\n \n \n for i in range(0,len(arr)-1):\n if int(arr[i]) == int(arr[i+1]) and not same:\n num=arr[i]\n \n if (int(arr[i]) < int(arr[i+1])):\n if decreasing:\n print(\"NO\")\n return\n\n else:\n if int(arr[i]) == int(arr[i+1]):\n same = True\n if num!= arr[i]:\n print(\"NO\")\n return\n \n else:\n if int(arr[i])>int(arr[i+1]):\n decreasing = True\n\n \n\n \n if good:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nproblem8(n,arr)\n"}, {"source_code": "import sys\nn = int(input())\narr = list(map(int,input().split()))\ns = ''\npre = arr[0]\nfor i in range(1,n):\n if( pre < arr[i] ):\n if( 'i' not in s ):\n s += 'i'\n elif( pre == arr[i] ):\n if( 'c' not in s ):\n s += 'c'\n elif( pre > arr[i] ):\n if( 'd' not in s):\n s += 'd'\n pre = arr[i]\nif( s == 'icd' or s == 'c' or s == 'ic' or s == 'cd'):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 24 20:04:04 2018\n\n@author: brian\n\"\"\"\n\nn=int(input())\nb=list(map(int,input().split(\" \")))\naux=[]\ns=\"\"\nif not (len(b)-1):\n print(\"Yes\")\nelse:\n for i in range(1,n):\n if s==\"\":\n if(b[i]>b[i-1]):\n s=\"a\"\n elif(b[i]==b[i-1]):\n s=\"r\"\n else:\n #print(\"No\")\n s=\"d\"\n break\n elif s==\"a\":\n if(b[i] in aux):\n s=\"r\"\n elif(b[i]<b[i-1]):\n #print(\"No\")\n s=\"f\"\n break\n elif s==\"r\":\n if(b[i]<b[i-1]):\n s=\"d\"\n elif(b[i]==b[i-1]):\n continue\n else:\n #print(\"No\")\n s=\"f\"\n break\n elif s==\"d\":\n if(b[i]<b[i-1]):\n continue\n else:\n s=\"f\"\n break\n \n if(b[i] not in aux):\n aux.append(b[i])\n print(\"Yes\" if not(s==\"f\") else \"No\") "}, {"source_code": "def get(l):\n z=l[0]\n flag=0\n for i in l[1:]:\n if i-z>0 and flag==0:\n continue\n if i-z==0 and flag<=1:\n if flag==0:\n flag+=1\n elif i-z<0 and flag in [1,2]:\n if flag==1:\n flag+=1\n else:\n return 'NO'\n z = i\n return 'YES'\n \n_ = input()\nl = list(map(int,input().split()))\nprint(get(l))\n"}, {"source_code": "quantity = int(input())\nalist = list(map(int, input().split()))\n\nresult = 'YES'\nidx = 0\n\nif quantity == 3:\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n\n if alist[idx] < alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] > alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n\nelif quantity == 2:\n if alist[0] > alist[1]:\n print('NO')\n else:\n print('YES')\nelif quantity == 1:\n print('YES')\nelif quantity > 3:\n if alist[idx] > alist[idx + 1]:\n result = 'NO'\n print(result)\n\n elif alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n break\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n if alist[idx] > alist[idx + 1]:\n idx += 1\n else:\n result = 'NO'\n break\n print(result)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"Untitled33.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1oqVApQHSdAnOYMkZjMFV-dBn3Cnw0983\n\"\"\"\n\nn = int(input())\narr = list(map(int, input().split()))\n\nif n == 1:\n print('YES')\nelse:\n a = []\n b = []\n c = []\n for i in range(n-1):\n j = i + 1\n if arr[i] < arr[j]:\n a.append(arr[i])\n elif arr[i] == arr[j]:\n c.append(arr[j])\n elif arr[i] > arr[j]:\n b.append(arr[j])\n \n x1 = sorted(a)\n x2 = sorted(b, reverse = True)\n if a == x1 and b == x2 and len(c)!=0:\n print('YES')\n else:\n print('NO')\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nans = 'YES'\nls = []\nfor i in range(n - 1):\n if a[i] < a[i + 1]:\n ls.append('<')\n elif a[i] > a[i + 1]:\n ls.append('>')\n else:\n ls.append('=')\nfor i in range(n - 2):\n for j in range(i + 1, n - 1):\n if ls[i] == '>' and ls[j] == '<':\n ans = 'NO'\n break\n\nprint(ans)\n"}, {"source_code": "def comprobar(k, n):\n temp = n[k - 1]\n t2 = n[k - 2]\n while temp < t2 and len(n) > 1:\n n.pop()\n temp = t2\n k = k - 1\n t2 = n[k - 2]\n k = len(n)\n if k > 1:\n temp = n[0]\n t2 = n[1]\n while temp < t2 and len(n) > 2:\n n.pop(0)\n temp = t2\n t2 = n[1]\n k = len(n)\n n.sort()\n if n[0] < n[k - 1] and k == 2:\n return 'YES'\n elif n[0] == n[k - 1]:\n return 'YES'\n return 'NO'\n return 'NO'\n\n\n\ndef main():\n k = input()\n n = [int(x) for x in raw_input().split()]\n if k == 1:\n print 'YES'\n else:\n print comprobar(k, n)\n\n\nmain()"}, {"source_code": "n=int(input())\ns=list(map(int,input().split()))\ni=0\nf=True\na=0\nb=0\nc=0\nfor i in range(n-1):\n if s[i]<s[i+1]:\n if (s[i]<s[i+1] and b==1) or (s[i]<s[i+1] and c==1):\n f=False\n break\n a=1\n else:\n if s[i]==s[i+1] or (s[i-1]<s[i] and s[i]>s[i+1]):\n b=1\n else:\n if s[i]>s[i+1]:\n if (s[i]>s[i+1] and b==0):\n f=False\n break\n c=1\nif b==0:\n f=False\nif f==True or n==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\n\nn = input()\na = map(int, raw_input().split())\n\nch = True\nif( n == 1 ):\n print 'YES'\nelif( a[0] > a[1] ):\n print 'NO'\nelse:\n i = 0\n while( a[i] < a[i + 1] ):\n i += 1\n if( i == n - 1 ):\n break\n if( i < n - 1 ):\n while( a[i] == a[i + 1] ):\n i += 1\n if( i == n - 1 ):\n break\n for j in range(i, n - 1):\n if( a[j] <= a[j + 1] ):\n print 'NO'\n ch = False\n break\n if( ch == True ):\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"Untitled33.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1oqVApQHSdAnOYMkZjMFV-dBn3Cnw0983\n\"\"\"\n\nn = int(input())\narr = list(map(int, input().split()))\n\nif n == 1:\n print('YES')\nelse:\n a = []\n b = []\n c = []\n for i in range(n-1):\n j = i + 1\n if arr[i] < arr[j]:\n a.append(arr[i])\n elif arr[i] == arr[j]:\n c.append(arr[j])\n elif arr[i] > arr[j]:\n b.append(arr[j])\n \n\n x1 = sum(a)\n x2 = sum(b)\n x3 = sum(c)\n if (x1+x2+(2*(x3))) == sum(arr):\n print('YES')\n else:\n print('NO')"}, {"source_code": "import sys\n\nn = int(input())\na = list(map(int,input().split()))\n\npivot = int(n/2)\ninc = False\nfor i in range(n-1):\n if i < pivot:\n \n if a[i] >= a[i+1] and inc == False:\n print('NO')\n sys.exit(0)\n else:\n inc = True\n else:\n if a[i] < a[i+1]:\n print('NO')\n sys.exit(0)\n\nprint('YES')"}, {"source_code": "import sys\n\nn = input()\na = map(int, raw_input().split())\n\nch = True\nif( n == 1 ):\n print 'YES'\nelif( a[0] > a[1] ):\n print 'NO'\nelse:\n i = 0\n while( a[i] < a[i + 1] ):\n i += 1\n if( i == n - 1 ):\n break\n if( i < n - 1 ):\n while( a[i] == a[i + 1] ):\n i += 1\n if( i == n - 1 ):\n break\n for j in range(i, n - 1):\n if( a[j] <= a[j + 1] ):\n print 'NO'\n ch = False\n break\n if( ch == True ):\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "length = input()\nnumbers = map(int, raw_input().split())\na = numbers[0]\nuni = True\nmiddle = False\nend = False\nfor i in range (1,length):\n b = numbers[i]\n if b < a and not end:\n uni = False\n break\n if b == a:\n middle = True\n if a < b and middle:\n uni = False\n break\n if a > b and middle:\n middle = False\n if a < b and end:\n uni = False\n break\nprint 'YES' if uni else 'NO'"}, {"source_code": "import sys\nt = int(input())\ninc,c,d = 0,0,0\narr = list(map(int,input().split(' ')))\nfor i in range(1,t):\n if arr[i]>arr[i-1]:\n if d == 1 or c == 1:\n print('NO')\n sys.exit()\n inc = 1\n elif arr[i] == arr[i-1]:\n if d == 1:\n print('NO')\n c = 1\n elif arr[i]<=arr[i-1]:\n d = 1\nprint('YES')\n"}, {"source_code": "n = input()\nq = map(int, raw_input().split())\nd = map(lambda x: 1 if x[1]>x[0] else -1 if x[1]<x[0] else 0, zip(q[:-1], q[1:]))\nr = []\nl = -2\nfor i in d:\n\tif i != l: r.append(i)\n\tl = i\nif r == [1,0,-1] or r == [1,-1] or r == [1,0] or r == [0,-1] or r == [1] or r == [0] or r == [-1]:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nc = -1\nsim_a = []\nres_a = []\n\nfor i in range(0, n):\n if i is 0:\n sim_a.append(a[i])\n continue\n if a[i] is a[i - 1]:\n if c != -1 and c != a[i]:\n print(\"NO\")\n exit()\n c = a[i]\n continue\n sim_a.append(a[i])\n\nfor i in range(1, len(sim_a)):\n res_a.append(sim_a[i] - sim_a[i - 1])\n\n# print(res_a)\n\ncnt = 0\nfor i in range(1, len(res_a)):\n if res_a[i] * res_a[i - 1] < 0:\n cnt += 1\n\nif cnt <= 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(raw_input())\nl = map(int,raw_input().split())\nlast = l[0]\ni = 1\nst = 0\nwhile i < n:\n current = l[i]\n if st == 0 and current == last:\n st = 1\n if st <= 1 and current < last:\n st = 2\n if st == 2 and current >= last:\n print \"NO\"\n break\n last = l[i]\n i+=1\nelse:\n print \"YES\""}, {"source_code": "\nn=int(input())\narr=list(map(int,input().split()))\ncond=False\nfor i in range(n-1):\n if arr[i]==arr[i+1]:\n cond=True\n break\nif cond:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = input()\narr = input()\n\nn = int(n)\n\ndef problem8(n,arr):\n i = 1\n arr = arr.split()\n size = len(arr)\n \n while i < size and arr[i - 1] < arr[i]:\n i += 1\n while i < size and arr[i - 1] == arr[i]:\n i += 1\n while i < size and arr[i - 1] > arr[i]:\n i += 1 \n return i == size \n\nproblem8(n,arr)\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nfor i in range(-1, n):\n for j in range(i + 1, n + 1):\n ok = True\n for k in range(1, i + 1):\n if a[k - 1] >= a[k]:\n ok = False\n for k in range(j, n - 1):\n if a[k] <= a[k + 1]:\n ok = False\n if len(set(a[i + 1:j])) > 1:\n ok = False\n if ok:\n print 'YES'\n exit(0)"}, {"source_code": "n = input()\narr = input()\n\nn = int(n)\n\ndef problem8(n,arr):\n arr = arr.split()\n cont = 0\n num=0\n increasing = False\n decreasing = False\n same = False\n \n good = True\n \n \n for i in range(0,len(arr)-1):\n if int(arr[i]) == int(arr[i+1]) and not same:\n num=arr[i]\n \n if (int(arr[i]) < int(arr[i+1])):\n if decreasing:\n print(\"DECREASE SALEO\")\n return\n\n else:\n if int(arr[i]) == int(arr[i+1]):\n same = True\n if num!= arr[i]:\n print(\"NO\")\n return\n \n else:\n if int(arr[i])>int(arr[i+1]):\n decreasing = True\n\n \n\n \n if good:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nproblem8(n,arr)\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))[:n]\nch = 0\nwhile(ch<n-1 and a[ch]<a[ch+1]):\n ch += 1\nwhile(ch<n-1 and a[ch]==a[ch+1]):\n ch += 1\nwhile(ch<n-1 and a[ch]>a[ch+1]):\n ch += 1\nif(ch<=n):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\narr = map(int, raw_input().split())\nt = 1\ntemp = [0]\nfor i in xrange(n - 1):\n if arr[i] < arr[i + 1] and temp[-1] != 1:\n temp.append(1)\n elif arr[i] == arr[i + 1] and temp[-1] != 2:\n temp.append(2)\n elif arr[i] > arr[i + 1] and temp[-1] != 3:\n temp.append(3)\n\ntemp = temp[1:]\nif temp == [1, 2, 3] or temp == [2, 3] or temp == [1, 2] or temp == [2] or temp == [1, 3]:\n print 'YES'\nelse:\n print 'NO'\n\n"}, {"source_code": "def main():\n size = int(input())\n array = [int(x) for x in input().split(' ')]\n has_constant = False\n\n for i in range(len(array) - 1):\n a, b = array[i], array[i + 1]\n if a < b:\n if has_constant:\n return 'NO'\n continue\n if a == b:\n has_constant = True\n continue\n if a > b:\n if not has_constant:\n return 'NO'\n continue\n return 'NO'\n return 'YES'\n\n\nif __name__ == '__main__':\n print(main())\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\ndef increase(l, r):\n result = True\n for i in range(l + 1, r):\n if (a[i - 1] >= a[i]):\n result = False\n return result\n\ndef stability(l, r):\n result = True\n for i in range(l + 1, r + 1):\n if (a[i - 1] != a[i]):\n result = False\n return result\n\ndef decrease(l, r):\n result = True\n for i in range(l + 1, r):\n if (a[i - 1] <= a[i]):\n result = False\n return result\n\nfor r in range(n):\n for l in range(r + 1):\n if (increase(0, l) and stability(l, r) and decrease(r, n)):\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"Untitled33.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1oqVApQHSdAnOYMkZjMFV-dBn3Cnw0983\n\"\"\"\n\nn = int(input())\narr = list(map(int, input().split()))\n\nif n == 1:\n print('YES')\nelse:\n a = []\n b = []\n c = []\n for i in range(n-1):\n j = i + 1\n if arr[i] < arr[j]:\n a.append(arr[i])\n elif arr[i] == arr[j]:\n c.append(arr[j])\n elif arr[i] > arr[j]:\n b.append(arr[j])\n \n x1 = sorted(a)\n x2 = sorted(b, reverse = True)\n if a == x1 and b == x2 and len(c)!=0:\n print('YES')\n else:\n print('NO')\n\n"}, {"source_code": "no =\"NO\"\nn =int(raw_input())\narr =map(int,raw_input().split())\nif n == 1:\n\tprint \"YES\"\n\tquit()\na =0\nb =0\nc =0\nfor i in range(1,n):\n\tif arr[i-1] < arr[i]:\n\t\tif b == 0 and c == 0:\n\t\t\ta =1\n\t\telse:\n\t\t\tprint no\n\t\t\tquit()\n\telif arr[i-1] == arr[i]:\n\t\tif c == 0:\n\t\t\tb =1\n\t\telse:\n\t\t\tprint no\n\t\t\tquit()\n\telif arr[i-1] > arr[i]:\n\t\tif b == 1 or a == 1:\n\t\t\tc =1\n\t\telse:\n\t\t\tprint no\n\t\t\tquit()\nif a == 1 and b == 1 and c == 1:\n\tprint \"YES\"\nelif a == 1 and b == 1:\n\tprint \"YES\"\nelif b == 1:\n\tprint \"YES\"\nelif b == 1 and c == 1:\n\tprint \"YES\"\nelif a == 1 and c ==1:\n\tprint \"YES\"\nelif a == 1:\n\tprint \"YES\"\nelse:\n\tprint no"}, {"source_code": "quantity = int(input())\nalist = list(map(int, input().split()))\n\nresult = 'YES'\nidx = 0\nif quantity > 2:\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = 'NO'\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1] or alist[idx] == alist[idx + 1]:\n result = 'NO'\n print(result)\n\n elif alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] > alist[idx + 1]:\n result = 'NO'\n break\n elif alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = 'NO'\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = 'NO'\n break\n break\n break\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n if alist[idx] > alist[idx + 1]:\n idx += 1\n else:\n result = 'NO'\n break\n print(result)\nelif quantity == 2:\n if alist[0] > alist[1]:\n print('NO')\n else:\n print('YES')\nelif quantity == 1:\n print('YES')\n"}, {"source_code": "def unimodal():\n import sys\n nList = []\n temp = 0\n N = int(input()) \n S = input() \n nList = S.split()\n nList = [int(i) for i in nList]\n for x in range(len(nList)-2):\n if (nList[x+2] - nList[x+1] <= nList[x+1] - nList[x]):\n pass\n else:\n print(\"NO\")\n sys.exit()\n print(\"YES\")\n\nunimodal()"}, {"source_code": "from sys import maxsize, stdout, stdin,stderr\nmod = int(1e9 + 7)\nimport re #can use multiple splits\ndef tup():return map(int,stdin.readline().split())\ndef I(): return int(stdin.readline())\ndef lint(): return [int(x) for x in stdin.readline().split()]\ndef S(): return input().strip()\ndef grid(r, c): return [lint() for i in range(r)]\ndef debug(*args, c=6): print('\\033[3{}m'.format(c), *args, '\\033[0m', file=stderr)\nfrom math import log2,sqrt\nfrom collections import defaultdict\n# s= S().split()\n# n = I()\n#\n# d='^>v<'\n# if n%2==0:print('undefined')\n# else:\n# st =d.find(s[0]).__index__()\n# en = d[(st+n)%4]\n# if en==s[1]:print('cw')\n# elif d[(st-n)%4]==s[1]:print('ccw')\n# else:print('undefined')\n#\n# #when k it is even it will end up in the same position so direction can't be determined\n# #\n# k = I()\n# n =S()\n# arr = sorted(list(map(int,n)))\n# cnt =sum(arr)\n# ans = 0\n# #print(arr,cnt)\n# for i in arr:\n# if cnt < k:\n# cnt+=9 - i\n# ans+=1\n# print(ans)\n# #increasing sum by 9-d\n\nn,ls = I(),lint()\nd = defaultdict(int)\nfor i in ls:\n d[i]+=1\nf =1;ans = 1;cnt =0; i =0\nwhile i < n -1:\n if f==1:\n if ls[i] < ls[i+1]:pass\n #elif ls[i]==ls[i+1]:pass\n elif ls[i] > ls[i+1]:\n f =0\n elif f==0:\n if ls[i] > ls[i+1]:pass\n elif ls[i] <= ls[i+1]:\n ans =0\n break\n i+=1\nprint(\"YES\") if ans else print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nstring = input()\nnumbers = list(map(int, string.split()))\nresults = \"NO\"\nb = n\nfor x in range(n - 1):\n if not numbers[x] < numbers[x + 1]:\n a = numbers[x]\n b = x\nif b != n:\n results = \"YES\"\n c = n\n for x in range(b, n):\n if not numbers[x] == a:\n c = x\n if c != n:\n for x in range(c, n - 1):\n if not numbers[x] > numbers[x + 1]:\n results = \"NO\"\n break\nprint(results)"}, {"source_code": "\nn = int(input())\na = list(map(int, input().split()))\ni = 0\nj = n - 1\nflag = False\nwhile i < n - 1 and a[i] < a[i + 1]:\n i += 1\nwhile j > 1 and a[j - 1] > a[j]:\n j -= 1\nif a[i] == a[j]:\n for k in range(i, j + 1):\n if a[k] != a[i]:\n print('NO')\n flag = True\n break\n if not flag:\n print('YES')\nelse:\n print('NO')\n \n\n \n"}, {"source_code": "x=int(input())\na=list(map(int,input().split()))\nprint((lambda x,y: 'YES' if sorted(x)==x and sorted(y,reverse=True)==y else 'NO')([a[i] for i in range(a.index(max(a)))],[a[i] for i in range(a.index(max(a)),x)]))\n#author:SK__Shanto__\u32db\n#code__define__your__smartness"}, {"source_code": "\n\n\nm = [int(i) for i in input().split(' ')]\n\n\n\nprint(m)\n\n\nj = m[0]\nk = 0\nerr = False\nfor i in m[1:]:\n k += 1\n if i > j: \n j = i\n continue\n elif i == j:\n j = i\n break\n else:\n print('NO')\n err = True\n break\n\nif not err:\n for i in m[k:]:\n k += 1\n if i == j:\n continue\n if i < j:\n j = i\n break\n else: \n print(\"NO\")\n err = True\n break\n j = i\n\nif not err:\n for i in m[k:]:\n k+=1\n if i<j:\n j = i\n continue\n else:\n print('NO')\n err = True\n break\n j = i\nif not err:\n print('YES')\n\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nans = 'YES'\nls = []\nfor i in range(n - 1):\n if a[i] < a[i + 1]:\n ls.append('<')\n elif a[i] > a[i + 1]:\n ls.append('>')\n else:\n ls.append('=')\nfor i in range(n - 2):\n for j in range(i + 1, n - 1):\n if ls[i] == '>' and ls[j] == '<':\n ans = 'NO'\n break\n\nprint(ans)\n"}, {"source_code": "n=input()\narray = [int(x) for x in raw_input().split(\" \")]\ndownPattern = False\nconstantPattern = False\nuni = True\nfor idx in range(len(array)-1):\n\tif constantPattern:\n\t\tif array[idx+1]==array[idx]:\n\t\t\tprint (\"NO\")\n\t\t\tuni=False\n\t\t\tbreak;\n\tif array[idx+1]<array[idx]:\n\t\tdownPattern=True\n\tif array[idx+1]==array[idx]:\n\t\tconstantPattern=True\n\tif downPattern:\n\t\tif array[idx+1]>array[idx]:\n\t\t\tprint (\"NO\")\n\t\t\tuni=False\n\t\t\tbreak;\nif uni:\n\tprint (\"YES\")\n"}, {"source_code": "from collections import *\nimport sys \n\n# \"\". join(strings) \n \ndef ri():\n return int(input())\n \ndef rl():\n return list(map(int, input().split()))\n\nn= ri()\n\naa = rl()\nans='YES'\nif n>1:\n\n for i in range(n-1):\n if aa[i+1]<=aa[i]:\n break\n end_up = i\n for i in range(end_up,n-1):\n if aa[i+1]!=aa[i]:\n start_down=i\n break\n else:\n start_down=n-1\n\n \n for i in range(start_down, n-1):\n if aa[i+1]>=aa[i]:\n ans=\"NO\"\n break\nprint(ans)\n\n\n\n\n"}, {"source_code": "n = raw_input()\narray = [int(x) for x in raw_input().split()]\n\nfase = 0\nanterior = 0\nres = \"YES\"\n\nfor num in array:\n\tif fase == 0:\n\t\tif num < anterior:\n\t\t\tfase = 1\n\t\t\tif num != anterior:\n\t\t\t\tfase = 2\n\t\t\t\tif num > anterior:\n\t\t\t\t\tres = \"NO\"\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tanterior = num\n\t\t\telse:\n\t\t\t\tanterior = num\n\t\telse:\n\t\t\tanterior = num\n\n\telif fase == 1:\n\t\tif num != anterior:\n\t\t\tfase = 2\n\t\t\tif num > anterior:\n\t\t\t\tres = \"NO\"\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tanterior = num\n\t\telse:\n\t\t\tanterior = num\n\t\t\t\n\telse:\n\t\tif num > anterior:\n\t\t\tres = \"NO\"\n\t\t\tbreak\n\t\telse:\n\t\t\tanterior = num\n\nprint res"}, {"source_code": "n = int(raw_input())\n\na = [int(x) for x in raw_input().split()]\n\ni = 0\nwhile i < n - 1 and a[i] < a[i + 1]:\n i += 1\nif i == n - 1:\n print 'NO'\n exit()\n\nwhile i < n - 1 and a[i] == a[i + 1]:\n i += 1\n\nif i < n - 1:\n while i < n - 1 and a[i] > a[i + 1]:\n i += 1\n\nif i < n - 1:\n print 'NO'\n exit()\n\nprint 'YES'\n"}, {"source_code": "quantity = int(input())\nalist = list(map(int, input().split()))\n\nresult = 'YES'\nidx = 0\nif quantity > 2:\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = 'NO'\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1] or alist[idx] == alist[idx + 1]:\n result = 'NO'\n print(result)\n\n elif alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n # if alist[idx] > alist[idx + 1]:\n # result = 'NO'\n # break\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = 'NO'\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = 'NO'\n break\n break\n break\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n if alist[idx] > alist[idx + 1]:\n idx += 1\n else:\n result = 'NO'\n break\n print(result)\nelif quantity == 2:\n if alist[0] > alist[1]:\n print('NO')\n else:\n print('YES')\nelif quantity == 1:\n print('YES')\n"}, {"source_code": "n=int(input())\na=[int(x) for x in input().split()]\nasc=con=des=False\nwasc=wcon=wdes=False\nuni=True\nfor x in range(1,n):\n\tif(a[x] > a[x-1]):\n\t\twasc=True\n\t\tif(wdes or wcon):\n\t\t\tuni=False\n\t\t\tbreak\n\t\tcontinue\n\telse:\n\t\tif(a[x] == a[x-1]):\n\t\t\twcon=True\n\t\t\tif(wdes):\n\t\t\t\tuni=False\n\t\t\t\tbreak\n\t\t\tcontinue\n\t\telse:\n\t\t\tif(a[x] < a[x-1]):\n\t\t\t\twdes=True\n\t\t\t\tif(not wcon and not wasc):\n\t\t\t\t\tuni=False\n\t\t\t\t\tbreak\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tdes=False\n\nif(uni):print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "n=int(input())\nl=list(map(int, input().split()))\nx=[]\nif n==1: print(\"YES\")\nelse:\n for i in range(n-1):\n if l[i]<l[i+1]: x.append(1)\n elif l[i]==l[i+1]: x.append(0)\n else: x.append(-1)\n if x.count(1)==x.count(-1)==0: pass\n elif x.count(1)*x.count(-1)==0: n=0\n else:\n k=1\n if x.count(0)==0: j=-1\n else: j=-2\n while k>j:\n for i in x:\n if i!=k and j==-1: k-=2\n else: k-=1\n if k<=j: n=0\n print(\"YES\" if n!=0 else \"NO\")\n\n"}, {"source_code": "__author__ = 'Esfandiar'\nn = int(input())\na = list(map(int,input().split()))\nf = 0\nfor i in range(1,n):\n if f == 0:\n if a[i] <= a[i-1]:\n f = 1\n else:\n if a[i] > a[i-1]:\n print('NO')\n exit()\n \n \nprint(\"YES\")\n"}, {"source_code": "length = input()\nnumbers = map(int, raw_input().split())\na = numbers[0]\nuni = True\nstart = False\nmiddle = False\nend = False\nfor i in range (1,length):\n b = numbers[i]\n if a > b:\n end = True\n if not end and not middle and not start:\n uni = False\n break\n elif middle:\n middle = False\n end = True\n start = False\n elif b == a:\n start = False\n middle = True\n elif a < b:\n start = True\n if middle:\n uni = False\n break\n elif end:\n uni = False\n break\n a = b\nprint 'YES' if uni else 'NO'"}, {"source_code": "quantity = int(input())\nalist = list(map(int, input().split()))\n\nresult = 'YES'\nidx = 0\n\nif quantity == 3:\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] > alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n elif alist[idx] == alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n if alist[idx] < alist[idx + 1]:\n result = \"NO\"\n break\n print(result)\n\nelif quantity == 2:\n if alist[0] > alist[1]:\n print('NO')\n else:\n print('YES')\nelif quantity == 1:\n print('YES')\nelif quantity > 3:\n if alist[idx] > alist[idx + 1]:\n result = 'NO'\n print(result)\n\n elif alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n print(result)\n\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n while idx < quantity - 1:\n if alist[idx] == alist[idx + 1]:\n idx += 1\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 2:\n idx += 1\n if alist[idx] == alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n elif alist[idx] < alist[idx + 1]:\n result = 'NO'\n # print(result)\n break\n break\n break\n elif alist[idx] < alist[idx + 1]:\n idx += 1\n elif alist[idx] > alist[idx + 1]:\n while idx < quantity - 1:\n if alist[idx] > alist[idx + 1]:\n idx += 1\n else:\n result = 'NO'\n break\n print(result)\n"}, {"source_code": "R= lambda: map(int,input().split())\nn=int(input())\nl=list(R())\nif n==1:\n print(\"YES\")\nelse:\n for i in range(1,n):\n if(l[i]<l[i-1]): break\n r=l[i:]\n r.sort(reverse=True)\n r=l[:i]+r\n for i in range(n):\n if(l[i]!=r[i]): \n print(\"NO\")\n exit()\n print(\"YES\")\n"}, {"source_code": "x=int(input())\ny=input().split()\nif x==1 or x==2:\n print(\"YES\")\nmax=-1\nmaxpos=-1\nfuni=False\nLuni=False\nfor i in range(x):\n if int(y[i])>max:\n max=int(y[i])\n maxpos=i\nfor i in range(0,maxpos):\n funi=False\n if int(y[i])<=int(y[i+1]):\n funi=True\nfor i in range(maxpos,x-1):\n Luni=False\n if int(y[i])>=int(y[i+1]):\n Luni=True\nif maxpos==0 and int(y[0])==int(y[x-1]):\n print(\"YES\")\nelif maxpos==0 and Luni:\n print(\"YES\")\nelif maxpos==x-1 and funi:\n print(\"YES\")\n \nelif funi and Luni :\n print(\"YES\")\nelse:\n print(\"NO\")\n \n "}, {"source_code": "def unimodal(arr):\n state = 0\n for i in range(0, len(arr)-1):\n if(arr[i] < arr[i+1] and (state==0 or state==1)):\n state = 1\n elif(arr[i] >= arr[i+1] and (state==1 or state==2) ):\n state=2\n else:\n return \"NO\"\n break\n return \"YES\"\ninput()\nprint(unimodal(input().split())) "}], "src_uid": "5482ed8ad02ac32d28c3888299bf3658"} {"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[list() for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if len(mp[i])>0:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=[False]*(n+1)\n v[0]=True\n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des,val-1,-1):\n if v[j-val] and not v[j]:\n v[j]=True\n return False\n\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n", "positive_code": [{"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp={}\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n if p[i] in mp:\n mp[p[i]].append(i)\n else:\n mp[p[i]]=[i]\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if i in mp:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=[False]*(n+1)\n v[0]=True\n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]==True:\n return True\n for j in range(des-val,-1,-1):\n if v[j]==True:\n v[j+val]=True\n return False\n\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n"}, {"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[list() for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if len(mp[i])>0:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=[False]*(n+1)\n v[0]=True\n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des-val,-1,-1):\n if v[j]:\n v[j+val]=True\n return False\n\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n"}, {"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[list() for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if len(mp[i])>0:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=set()\n v.add(0)\n for i in range(len(picklist)):\n val=sof(picklist[i])\n v |= {ori+val\n for ori in v}\n if des in v:\n return True\n return False\n '''\n v=[False]*(n+1)\n v[0]=True\n \n \n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des-val,-1,-1):\n if v[j] :\n v[j+val]=True\n return False\n '''\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n"}, {"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[list() for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if len(mp[i])>0:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=[False]*(n+1)\n v[0]=True\n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des,val-1,-1):\n if not v[j] and v[j-val] :\n v[j]=True\n return False\n\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n"}, {"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[list() for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if len(mp[i])>0:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=set()\n v.add(0)\n for i in range(len(picklist)):\n val=sof(picklist[i])\n v |= {ori+val\n for ori in v}\n if des in v:\n return True\n return False\n '''\n v=[False]*(n+1)\n v[0]=True\n \n \n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des-val,-1,-1):\n if v[j] :\n v[j+val]=True\n return False\n '''\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n"}, {"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[list() for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if len(mp[i])>0:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=[False]*(n+1)\n v[0]=True\n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des-val,-1,-1):\n if v[j] :\n v[j+val]=True\n return False\n\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n"}], "negative_code": [{"source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[[list()] for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if i in mp:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=[False]*(n+1)\n v[0]=True\n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des-val,-1,-1):\n if v[j]:\n v[j+val]=True\n return False\n\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n"}], "src_uid": "87db879f0ca422020125a3e4d99d3c23"} {"source_code": "n = long(input())\ni = 1\nif n % long(5) == 0:\n out = long(n / 5)\n print out\nelse:\n while ((5 * i) < n):\n i += 1\n print i", "positive_code": [{"source_code": "print((int(input())+4)//5)"}, {"source_code": "x = int(raw_input())\ncountsteps = 0\n\nwhile(x!=0):\n\tif(x-5 >= 0):\n\t\tx -= 5\n\t\tcountsteps += 1\n\telif(x-4 >= 0):\n\t\tx -= 4\n\t\tcountsteps += 1\n\telif(x-3 >= 0):\n\t\tx -=3\n\t\tcountsteps += 1\n\telif(x-2 >= 0):\n\t\tx -= 2\n\t\tcountsteps += 1\n\telif(x-1 >= 0):\n\t\tx -= 1\n\t\tcountsteps += 1\nprint countsteps"}, {"source_code": "a = input()\n#print a\n\ncount = 0\nnew = a\n\nfor i in range(a):\n if new !=0 and new>=5:\n new = new-5\n count = count +1\n\n elif new == 4:\n new = new - 4\n count = count +1\n elif new == 3:\n new = new -3\n count = count +1\n elif new == 2:\n new = new -2\n count = count +1\n elif new == 1:\n new = new -1\n count = count +1\n elif new==0:\n break\n #print new\nprint count\n"}, {"source_code": "coord = int(input())\n\ncounter = 0\n\nwhile(coord > 0):\n if(coord >= 5):\n inc = coord // 5\n counter += inc\n coord -= 5 * inc\n continue\n if(coord >= 4):\n inc = coord // 4\n counter += inc\n coord -= 4 * inc\n continue\n if(coord >= 3):\n inc = coord // 3\n counter += inc\n coord -= 3 * inc\n continue\n if(coord >= 2):\n inc = coord // 2\n counter += inc\n coord -= 2 * inc\n continue\n if(coord >= 1):\n inc = coord // 1\n counter += inc\n coord -= 1 * inc\n continue\n \n\nprint(counter)\n\n"}, {"source_code": "s = int(input())\nif s%5:\n print(s//5 + 1)\nelse:\n print(s//5)"}, {"source_code": "x=eval(input())\nprint((x+4)//5)\n"}, {"source_code": "x = int(input())\ncount = 0\nif(x > 5):\n count += round(x/5 - 0.5)\n x -= count * 5\n if(x == 0):\n print(count)\n else:\n print(count +1)\nelse:\n print(1)\n \n"}, {"source_code": "import math\nprint(math.ceil(int(input())/5))"}, {"source_code": "\nnum = int(raw_input())\nresultado = num // 5\nif num % 5 != 0:\n resultado += 1\nprint resultado\n"}, {"source_code": "STEPS = [ 5, 4, 3, 2, 1 ]\n\nx = int(input())\nresult = 0\n\nfor i in STEPS:\n\twhile True:\n\t\tif x - i >= 0:\n\t\t\tx -= i\n\t\t\tresult += 1\n\t\telse:\n\t\t\tbreak\n\nprint result"}, {"source_code": "n = int(input())\nb = -n//5\nprint(abs(b))\n"}, {"source_code": "x=input()\nd=x/5\nif(d==0):\n print 1\nelif x%5==0:\n print d\nelse:\n print d+1\n \n"}, {"source_code": "a=int(raw_input(\"\"))\nb=a/5\nif(a%5!=0):\n b=b+1 \nprint b\n"}, {"source_code": "a=int(input())\nc=a//5\nif(a<=5):\n print(1)\nelif(a%5==0):\n print(c)\nelif(a>5)and(a%5!=0):\n print(c+1)\n\n"}, {"source_code": "x=int(input())\nqwerty=0\na = x // 5\nb = x % 5\nif 5>b>0:\n qwerty=qwerty+1\n\n \n\n\nprint(a + qwerty)\n\n# if x<5:\n# if x==4:\n# x=x-4\n# qwerty=qwerty+1\n# if x==3:\n# x=x-3\n# qwerty=qwerty+1\n# if x==2:\n# x=x-2\n# qwerty=qwerty+1\n# if x==1:\n# x=x-1\n# qwerty=qwerty+1\n# while x>0:\n# if x>=5:\n# x=x-5 \n# qwerty=qwerty+1 \n# if x>=4:\n# x=x-4 \n# qwerty=qwerty+1\n# if x>=3:\n# x=x-3 \n# qwerty=qwerty+1\n# if x>=2:\n# x=x-2\n# if x>=1:\n# x=x-1 \n# qwerty=qwerty+1\n# print(qwerty)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "print -(input() // -5)"}, {"source_code": "from math import ceil\ndef main():\n\t\n\tsteps = float( raw_input() )\n\tfor i in xrange(5,0,-1):\n\t\ta = ceil(steps / i)\n\t\tif a * i >= steps:\n\t\t\treturn int(a)\nprint main()\n'''\n999999\n333333\n200000\n'''\n"}, {"source_code": "x = input()\n\nans = 0\nfor i in xrange(5, 0, -1):\n ans += x / i\n x %= i\n\nprint ans\n\n"}, {"source_code": "# author : sudoer\nx = int(raw_input())\n# l = [5,4,3,2,1]\nif x <= 5:\n print 1\nelse:\n a = x\n i = 0\n count = 0\n while a > 0:\n a = a - 5\n count += 1\n print count\n "}, {"source_code": "n = int(input())\nif(n%5==0):\n u = n/5\nelse:\n k = n/5\n u = k+1\nprint(int(u))"}, {"source_code": "import math\n\nx = int(raw_input())\nprint int(math.ceil(x * 1.0 / 5))\n"}, {"source_code": "coord = int(input())\nfullLeap = coord // 5\npartLeap = coord % 5\n\nif fullLeap > 0 and partLeap > 0:\n print(fullLeap + 1)\nelif fullLeap > 0 and partLeap == 0:\n print(fullLeap)\nelif partLeap > 0:\n print(1)\nelse:\n print(0)\n \n\n"}, {"source_code": "import math\na = input()\nprint int(math.ceil(1.*a/5))\n"}, {"source_code": "n=input()\nif n%5<>0: print n/5+1\nelse: print n/5\n"}, {"source_code": "x = input()\nresult = 0\n\nremainder = x % 5\nif remainder > 0:\n result= x/5+1\nelse:\n result = x/5\n\nprint result"}, {"source_code": "import math\ndef Elephant():\n x= int(input())\n p=0\n if(x%5 == 0):\n p=int(x/5)\n else:\n p=math.floor(x/5)+1 \n return int(p)\n \n\n\nif __name__ == \"__main__\":\n print(Elephant())"}, {"source_code": "n=int(input())\ntemp=n+4\nprint(temp//5)\n"}, {"source_code": "def main():\n\tn = int(raw_input())\n\tress = 0\n\tfor x in [5,4,3,2,1]:\n\t\tress += n/x\n\t\tn %= x\n\tprint ress\nmain()\n\n\n"}, {"source_code": "a=input()\nb=a/5\nif a%5!=0:\n print b+1\nelse:\n print b"}, {"source_code": "import math\n\nn = int(input())\nprint(math.ceil(n/5))\nfor i in \"island\":\n if i==\"is\":\n print(\"HEY HO MATEY\")\n else:\n pass\n"}, {"source_code": "n = int(raw_input())\n\nprint n // 5 if n % 5 == 0 else (n // 5) + 1"}, {"source_code": "n = int(input())\nR=n%5\nif(R==0):\n Z=n//5\nelse:\n Z=(n//5)+1\nprint(Z)\n"}, {"source_code": "n = int(raw_input())\nprint((n + 4) // 5)"}, {"source_code": "x,count=int(input()),0\nwhile x>=5:\n count+=1\n x-=5\nif x>0:count+=1\nprint(count)"}, {"source_code": "print (input()+4)/5"}, {"source_code": "n = int(raw_input())\nprint (n + 4) / 5"}, {"source_code": "def function(n):\n if n<=5:\n return 1\n else:\n if n%5==0:\n return (int(n/5))\n else:\n return int((n/5)+1)\n \nif __name__==\"__main__\":\n n=int(input())\n print(function(n))"}, {"source_code": "print -(input() // -5)\n"}, {"source_code": "cord = input()\n\nindex = 0\nsteps = [5,4,3,2,1]\nstepsCount = 0\n\nwhile cord != 0:\n step = steps[index]\n dr = (cord/step)\n \n cord -= step * dr\n stepsCount += dr\n \n index += 1\n \nprint stepsCount"}, {"source_code": "n=int(input())\nif n%5:\n print(int(n/5+1))\nelse:\n print(int(n/5))"}, {"source_code": "n = int(raw_input())\nif n<=5:\n\tprint \"1\"\nelif n%5==0:\n\tprint n/5\nelse:\n\tprint n/5 + 1"}, {"source_code": "n = int(raw_input())\nif n < 6:\n\tprint 1\nelse:\n\tcont = 0\n\twhile n > 0:\n\t\tif n - 5 > -1:\n\t\t\tn -= 5\n\t\t\tcont += 1\n\t\telif n - 4 > -1:\n\t\t\tn -= 4\n\t\t\tcont += 1\n\t\telif n - 3 > -1:\n\t\t\tn -= 3\n\t\t\tcont += 1\n\t\telif n - 2 > -1:\n\t\t\tn -= 2\n\t\t\tcont += 1\n\t\telif n - 1 > -1:\n\t\t\tn -= 1\n\t\t\tcont += 1\n\tprint cont\n"}, {"source_code": "x=input()\nn=x%5\nif(n==0):\n jump=x/5\nelse:\n jump=(x/5)+1\nprint jump\n"}, {"source_code": "i = int(input())\np = i // 5\nif i % 5 > 0:\n p = p + 1\nprint(p)"}, {"source_code": "x = int(input())\nif x % 5 == 0:\n steps = x / 5\nelse :\n steps = x / 5 + 1\nprint (int(steps))"}, {"source_code": "n = int( raw_input() )\n\nif n <= 5 :\n ans = 1\nelse:\n ans = n / 5 \n r = n % 5\n if r > 0:\n ans +=1\nprint ans\n\n"}, {"source_code": "x = int(input())\nif x >= 1 and x <= 1000000:\n if x % 5 == 0:\n x = x // 5\n print(x)\n elif x % 5 != 0:\n x = x // 5\n print(x + 1)\n"}, {"source_code": "print(-(-int(input())//5))"}, {"source_code": "n=int(raw_input())\nif n%5 == 0:\n print n/5\nelse:\n print n/5 + 1 "}, {"source_code": "n=int(input())\nm=n//5\nif(n%5==0):\n print(m)\nelse:\n print(m+1)\n\n"}, {"source_code": "# import sys\n# sys.stdin = open(\"a.test.txt\")\n\ndef main():\n n = int(raw_input())\n print((n + 4) / 5)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from sys import stdin\n\nx = int(stdin.readline())\nprint((x+4)//5)\n"}, {"source_code": "# http://codeforces.com/problemset/problem/617/A\n\ndistance = input()\n\n\"\"\" General solution\nif distance%5 != 0:\n print distance/5 + 1\nelse:\n print distance/5\"\"\"\n\n# Parsed solution\n# we want the output to be 1 and hence at the RHS when true\nprint (distance%5 and 1) + distance/5"}, {"source_code": "a = int(input())\nif a % 5 == 0:\n print(int(a / 5))\nelse:\n print(int(a / 5 + 1))\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import os\ndef readInts(): return map(int,raw_input().split())\nn=readInts()[0]\ndiv=[1,2,3,4,5]\ndiv=div[::-1]\n#print div\nflag=True\ncount=0\nindex=0\nwhile flag:\n temp=n%div[index]\n #print temp,div[index]\n if temp >0:\n if temp in div:\n count=count+1+(n/div[index])\n flag=False\n else:\n count=count+(n/div[index])\n flag=False\nprint count"}, {"source_code": "s=0\nx=int(input())\nfor i in range(1,x+1,5):\n s+=1\nprint(s)\n"}, {"source_code": "# =======Conditional Statement==========\n\n# B1\n# a, b = map(int, input().split())\n# if (a > b):\n# print(a)\n# else:\n# print(b)\n\n# B2\n# a, b = map(float, input().split())\n# if (a * b > 0):\n# print(\"YES\")\n# else:\n# print(\"NO\")\n\n# B3\n# a = int(input())\n# if (a == 1 or a == 2 or a == 3):\n# print(\"1\")\n# elif (a == 4 or a == 4 or a == 6):\n# print(\"2\")\n# elif (a == 7 or a == 8 or a == 9):\n# print(\"3\")\n# elif (a == 10 or a == 11 or a == 12):\n# print(\"4\")\n\n# B4\n# a = int(input())\n# if (a % 4 == 0 and (a % 100 != 0)) or (a % 400 ==0):\n# print(\"YES\")\n# else:\n# print(\"NO\")\n\n# B5\n# a, b = map(int, input().split())\n# c = int(input())\n# if (c % a == 0) and (c % b != 0):\n# print(\"Upan\")\n# elif (c % b == 0) and (c % a != 0):\n# print(\"Ipan\")\n# elif (c % b != 0) and (c % a != 0):\n# print(\"No\")\n# else:\n# print(\"Both\")\n\n# B6\n# a = int(input())\n# if (a > 3) and (a % 2 == 0):\n# print(\"YES\")\n# else:\n# print(\"NO\")\n\n# B7\n# a, b = map(int, input().split())\n# c = b - a\n#\n# e = 0\n# if (c - 50 >= 0):\n# e = e + 50 * 1484\n# c -= 50\n# if (c - 50 >= 0):\n# e = e + 50 * 1533\n# c -= 50\n# if (c - 100 >= 0):\n# e = e + 100 * 1786\n# c -= 100\n# if (c - 100 >= 0):\n# e = e + 100 * 2242\n# c -= 100\n# if (c - 100 >= 0):\n# e = e + 100 * 2503\n# c -= 100\n# e = e + c * 2587\n# else:\n# e = e + c * 2503\n# else:\n# e = e + c * 2242\n# else:\n# e = e + c * 1786\n# else:\n# e = e + c * 1533\n# else:\n# e = e + c * 1484\n#\n#\n# e = e + e * 0.1\n# print(int(e))\n\n# b8 Theatre Square\n# n, m, a = map(int, input().split())\n# c = int(((n - 1) / a) + 1)\n# d = int(((m - 1) / a) + 1)\n# e = c * d\n# print(e)\n\n# b10 Elephant\n\n# n = int(input())\n# c = int((n+4)/5)\n# print(c)\n\n\nn = int(input())\nc = 0\nwhile (n >= 5):\n n = n - 5\n c += 1\nwhile (n >= 4):\n n = n - 5\n c += 1\nwhile (n >= 3):\n n = n - 3\n c +=1\nwhile (n >= 2):\n n = n - 2\n c += 1\nwhile (n >= 1):\n n = n - 1\n c += 1\nprint(c)\n"}, {"source_code": "\n\nc=1\nn=int(input())\nif n%5==0:\n print(n//5)\nelse:\n print((n//5)+1)"}, {"source_code": "# B1\n# a, b = map(int, input().split())\n# if (a > b):\n# print(a)\n# else:\n# print(b)\n\n# B2\n# a, b = map(float, input().split())\n# if (a * b > 0):\n# print(\"YES\")\n# else:\n# print(\"NO\")\n\n# B3\n# a = int(input())\n# if (a == 1 or a == 2 or a == 3):\n# print(\"1\")\n# elif (a == 4 or a == 4 or a == 6):\n# print(\"2\")\n# elif (a == 7 or a == 8 or a == 9):\n# print(\"3\")\n# elif (a == 10 or a == 11 or a == 12):\n# print(\"4\")\n\n# B4\n# a = int(input())\n# if (a % 4 == 0 and (a % 100 != 0)) or (a % 400 ==0):\n# print(\"YES\")\n# else:\n# print(\"NO\")\n\n# B5\n# a, b = map(int, input().split())\n# c = int(input())\n# if (c % a == 0) and (c % b != 0):\n# print(\"Upan\")\n# elif (c % b == 0) and (c % a != 0):\n# print(\"Ipan\")\n# elif (c % b != 0) and (c % a != 0):\n# print(\"No\")\n# else:\n# print(\"Both\")\n\n# B6\n# a = int(input())\n# if (a > 3) and (a % 2 == 0):\n# print(\"YES\")\n# else:\n# print(\"NO\")\n\n# B7\n# a, b = map(int, input().split())\n# c = b - a\n#\n# e = 0\n# if (c - 50 >= 0):\n# e = e + 50 * 1484\n# c -= 50\n# if (c - 50 >= 0):\n# e = e + 50 * 1533\n# c -= 50\n# if (c - 100 >= 0):\n# e = e + 100 * 1786\n# c -= 100\n# if (c - 100 >= 0):\n# e = e + 100 * 2242\n# c -= 100\n# if (c - 100 >= 0):\n# e = e + 100 * 2503\n# c -= 100\n# e = e + c * 2587\n# else:\n# e = e + c * 2503\n# else:\n# e = e + c * 2242\n# else:\n# e = e + c * 1786\n# else:\n# e = e + c * 1533\n# else:\n# e = e + c * 1484\n#\n#\n# e = e + e * 0.1\n# print(int(e))\n\n# b8 Theatre Square\n# n, m, a = map(int, input().split())\n# c = int(((n - 1) / a) + 1)\n# d = int(((m - 1) / a) + 1)\n# e = c * d\n# print(e)\n\n# b10 Elephant\n# n = int(input())\n# print (int((n+4)/5))\n\nn = int(input())\nc = 0\n\nwhile (n >= 5):\n n = n - 5\n c += 1\n\nwhile (n >= 4):\n n = n - 5\n c += 1\n\nwhile (n >= 3):\n n = n - 3\n c +=1\n\nwhile (n >= 5):\n n = n - 5\n c += 1\n\nwhile (n >= 5):\n n = n - 5\n c += 1\n\nwhile (n >= 4):\n n = n - 5\n c += 1\n\nwhile (n >= 3):\n n = n - 3\n c +=1\n\nwhile (n >= 2):\n n = n - 2\n c += 1\n\nwhile (n >= 1):\n n = n - 1\n c += 1\n\nprint(c)"}, {"source_code": "n = int(input())\narr = (5,4,3,2,1)\ncount = 0\nwhile n > 0:\n for i in arr:\n if n >= i:\n count += 1\n n -= i\n break\nprint(count)\n\n "}, {"source_code": "n = int(input())\nprint(n // 5 + (n / 5 != n // 5))\n"}, {"source_code": "from math import ceil\nprint(ceil(int(input())/5))"}, {"source_code": "n = int(input())\ncount = 0\nsteps = [5, 4, 3, 2, 1]\nfor i in steps:\n count = count + n//i\n n=n%i\nprint(count)"}, {"source_code": "n=int(input())\n\nif(n%5 != 0):\n print(n//5 + 1)\nelse:\n print(n//5)"}, {"source_code": "x=int(input())\ny=0\nif(x%5==0):\n print(x//5)\nelse:\n print((x//5)+1)\n"}, {"source_code": "N = input()\n\nif N % 5 == 0:\n print (N / 5)\nelse:\n print (N / 5 + 1)\n"}, {"source_code": "\"\"\"import math\nl = [1, 2, 3, 4, 5]\nx = int(input())\ns = []\np = []\na=[]\nif x in l:\n print(1)\nelse:\n\n p=[x/i for i in l]\n\n for j in p:\n s=math.ceil(j)\n print(s)\"\"\"\nimport math\n\nx = int(input())\nif x <= 5:\n print(1)\nelse:\n p = x / 5\n print(math.ceil(p))\n"}, {"source_code": "k=raw_input()\nn=int(k)\nq=0\nr=0\nq=n/5\nr=n%5\nif(r==0):\n print q \nelse:\n print q+1"}, {"source_code": "print((int(input())+4)//5)"}, {"source_code": "n=input()\nprint '1' if n<=5 else -(n/-5)"}, {"source_code": "x= int(input())\nif(x<5):\n print(int(1))\nelse:\n a=x%5\n if(a==0):\n print(int(x/5))\n elif(a!=0 and a<5):\n print (int(x/5+1))"}, {"source_code": "x = input()\nlength = list(range(1,6))\nlength.reverse()\nsteps = 0\nfor i in length:\n number = x/i\n steps += number\n x -= number * i\n\nprint steps\n"}, {"source_code": "a = input()\nif a%5==0 : print a/5\nelse : print a/5 +1"}, {"source_code": "count=0\nx=int(input())\nwhile(x>1):\n if(x>=5):\n x=x-5\n count+=1\n elif(x==4):\n x=x-4\n count+=1\n elif(x==3):\n x=x-3\n count+=1\n elif(x==2):\n x=x-2\n count+=1\nif(x==1):\n count+=1\nprint(count)"}, {"source_code": "x=int(input())\nif x <= 5:\n print(1)\nelif (x % 5 == 0) and (x !=5):\n print(x//5)\nelse:\n print(x//5 + 1)"}, {"source_code": "x = int(raw_input())\n\nres = x / 5\n\nif x % 5 > 0:\n\tres += 1\n\nprint res"}, {"source_code": "a=int(input())\nif a%5!=0:\n g=a//5\n if a<=5:\n print(\"1\")\n else:\n print(g+1)\nelse:\n print(int(a//5))"}, {"source_code": "n = int(raw_input())\nres = 0\nif(n / 5 != 0):\n\ttem= n/5\n\tres+=tem\n\tn = n%5\n\nif(n / 4 != 0):\n\ttem= n/4\n\tres+=tem\n\tn = n%4\nif(n / 3 != 0):\n\ttem= n/3\n\tres+=tem\n\tn = n%3\nif(n / 2 != 0):\n\ttem= n/2\n\tres+=tem\n\tn = n%2\nif(n / 1 != 0):\n\ttem= n/1\n\tres+=tem\n\tn = n%1\n\nprint res"}, {"source_code": "n = int(input())\n\nnum_of_step = int(0)\ndis_remaining = n\n\nnum_of_step += n//5\ndis_remaining = n%5\n\nnum_of_step += dis_remaining // 4\ndis_remaining = dis_remaining % 4\n\nnum_of_step += dis_remaining // 3\ndis_remaining = dis_remaining % 3\n\nnum_of_step += dis_remaining // 2\ndis_remaining = dis_remaining % 2\n\nnum_of_step += dis_remaining // 1\nprint(num_of_step)\n\n\n"}, {"source_code": "x = int(input())\nans = 0\na = x // 5\nb = x - (a*5)\nif(x <= 5):\n ans = 1\nelif(b == 0):\n ans = a\nelse:\n ans = a + 1\nprint(ans)"}, {"source_code": "l = int(raw_input())\ntsteps = l\ncounter = 0\nfor i in reversed(range(1,6)):\n while(i <= tsteps):\n tsteps = tsteps - i\n counter+=1\nprint counter\n"}, {"source_code": "x = int(input())\nif x % 5 == 0:\n print(x // 5)\nelse:\n print(x // 5 + 1)\n"}, {"source_code": "x = float(raw_input())\n\nimport math\n\nprint int(math.ceil(x/5))"}, {"source_code": "n=int(input())\np=0\nif (n%5==0):\n p=int(n//5)\nelse:\n p=int(n//5)+1\nprint(p)"}, {"source_code": "x=int(input())\nsum=0\nc=0\nfor i in range(x):\n if sum==x:\n break\n if sum>x:\n sum-=5\n sum+=4\n else:\n sum+=5\n c+=1\nprint(c)\n\n\n\n"}, {"source_code": "n=int(input())\na=[1,2,3,4,5]\nif(n%5==0):\n\tprint(int(n/5))\nelse:\n\t remainder=(n%5)\n\t n1=n-remainder\n\t ans=(int(n1/5)+1)\n\t print(ans)\n\n\n \n \n \n\n\n"}, {"source_code": "a = int(raw_input())\nif a%5 == 0:\n print a/5\nelse:\n print a/5 + 1 "}, {"source_code": "n=int(input())\nl=[5,4,3,2,1]\ni=0\ncount=0\nwhile n!=0:\n\tif n>=l[i]:\n\t\tn-=l[i]\n\t\tcount+=1\n\telse:\n\t\ti+=1\n\n\nprint(count)"}, {"source_code": "a=int(raw_input())\ncount = 0\nfor i in range(5,0,-1):\n if a>=0:\n count=count +a/i\n a = a-((a/i)*i)\nprint count"}], "negative_code": [{"source_code": "import math \n\nx=int(input(\"give x\"))\nns =0 \nif x<=5: \n ns = 1 \nelse : \n ns = math.ceil(x/5) \nprint (ns) "}, {"source_code": "num = int(input(''))\nif num <= 5:\n print(1)\nelif num % 5 == 0:\n print(num//5)\nelse:\n print(1 + 5//num)"}, {"source_code": "s = int(input())\nprint(s//5 +1)"}, {"source_code": "x=int(input())\ns=0\np=0\nr=0\nt=0\nh=0\nif x//5>0:\n s=x//5\n if x%5==0:\n print(s)\n else:\n if x//4>0:\n p=x//4\n if x%4==0:\n print(s+p)\n else:\n if x//3>0:\n r=x//3\n if x%3==0:\n print(s+p+r)\n else:\n if x//2>0:\n t=x//2\n if x%2==0:\n print(s+p+r+t)\n else:\n if x//1>0:\n h=x//1\n print(s+p+r+t+h) \n\n"}, {"source_code": "n= int(input())\nprint((n//2)+1)"}, {"source_code": "print(input()+4/5)\n"}, {"source_code": "a=int(input())\nc=a//5\nif(a<=5):\n print(1)\nif(a%5==0):\n print(c)\nelse:\n print(c+1)"}, {"source_code": "n = int(input())\nprint(n//5+1)"}, {"source_code": "x=int(input())\nn=0\nif x>=5:\n x=x-5\n n=n+1\nif x>=4:\n x=x-4\n n=n+1\nif x>=3:\n x=x-3\n n=n+1\nif x>=2:\n x=x-2\n n=n+1\nif x>=1:\n x=x-1\n n=n+1\nprint(n)\n"}, {"source_code": "x=int(raw_input())\ncount=x/5\nprint (count)\nif(x%5==0):\n print(count)\nelse:\n print(count+1)\n\n"}, {"source_code": "a=int(input())\nif a%5==0:\n print('1')\nif a%5==1:\n print('2')\nif a%5==2:\n print('3')\nif a%5==3:\n print('4')\nif a%5==4:\n print('5')"}, {"source_code": "n=int(input())\na=[1,2,3,4,5]\nif(n%5==0):\n\tprint(int(n/5))\n\nelif(n%4==0):\n\tprint(int(n/4))\nelif(n%3==0):\n\tprint(int(n/5))\nelif(n%2==0):\n\tprint(int(n/2))\nelse:\n\tprint(n)\n"}, {"source_code": "n= int(input())\npole = [1,2,3,4,5]\npom=0\ni=0\nz=0\ndef steps(pole,n,pom,i,z):\n if n % pole[i]==0:\n z+=1\n if int(n/pole[i]) < pom:\n pom=int(n/pole[i])\n if z<2:\n pom=int(n/pole[i])\n elif i<len(pole)-1:\n steps(pole,n,pom,i+1,z)\n if i<len(pole)-1:\n steps(pole,n,pom,i+1,z)\n if i == len(pole)-1:\n global q\n q=pom\nsteps(pole,n,pom,i,z)\nprint(q)\n"}, {"source_code": "x = int(input())\nif x % 5 <= 4:\n print(x % 5 + 1)\nelse:\n print(x/5)\n"}, {"source_code": "x= int(input())\nprint(x+4//5)"}, {"source_code": "n = int(input())\nif n%5==0 :\n print(n/5);\nelse :\n print(n/5+1);"}, {"source_code": "x=int(input(\"\"))\na=0\ni=5\nfor i in range(1,5):\n a=a+(x/i)\n x=x%i\n i=i-1\nprint(int(a+1))"}, {"source_code": "n = int(input())\nsum = 0\nwhile n != 0:\n if n%5 ==0:\n n -= 5\n sum += 1\n next\n elif n%4 == 0:\n n -= 4\n sum += 1\n next\n elif n%3 == 0:\n n -= 3\n sum += 1\n next\n elif n%2 == 0:\n n -= 2\n sum += 1\n next\n else:\n n -= 1\n sum += 1\n next\n\nprint(sum)"}, {"source_code": "friend = int(input())\nsteps = 0\nif friend >= 1 and friend <= 1000000:\n\twhile friend > 0:\n\t\tif friend % 5 == 0:\n\t\t\tfriend = friend - 5\n\t\t\tsteps += 1\n\t\telif friend % 4 == 0:\n\t\t\tfriend = friend - 4\n\t\t\tsteps += 1\n\t\telif friend % 3 == 0:\n\t\t\tfriend = friend - 3\n\t\t\tsteps += 1\n\t\telif friend % 2 == 0:\n\t\t\tfriend = friend - 2\n\t\t\tsteps += 1\n\t\telif friend % 1 == 0:\n\t\t\tfriend = friend - 1\n\t\t\tsteps += 1\n\tprint(steps)\n"}, {"source_code": "t = int(input())\ni = 5\ns = 0\nc = 0\nwhile(i != 0):\n s = s + i\n c = c + 1\n i -= 1\n if(s == t):\n break\nprint(c) "}, {"source_code": "from math import *\n\n# n, k = map(int, input().split ())\nn = int(input())\nk = 0\nwhile n > 0:\n if n%5==0:\n n-=5\n k+=1\n continue\n elif n%4==0:\n n-=4\n k+=1\n continue\n elif n%3==0:\n n-=3\n k+=1\n continue\n elif n%2==0:\n n-=4\n k+=1\n continue\n else:\n k+=1\n break\nprint(k)"}, {"source_code": "cor = int(input())\n\nsteps = 0\n\nwhile cor!=0:\n if cor >= 5:\n cor -=5\n steps+=1\n if cor >= 4:\n cor -=4\n steps+=1\n if cor >=3:\n cor -= 3\n steps += 1\n if cor >=2 :\n cor -=2\n steps_=1\n if cor >=1:\n cor -=1\n steps_=1\n\nprint(steps)"}, {"source_code": "x = int(input())\nif x%5 == 0:\n\tprint(int(x/5))\n\texit\nelif x%4 == 0:\n\tprint(int(x/4))\n\texit\nelif x%3 == 0:\n\tprint(int(x/4))\n\texit\nelif x%2 == 0:\n\tprint(int(x/4))\n\texit\nelif x%1 == 0:\n\tprint(int(x/4))\n\texit"}, {"source_code": "import math\ndef elephant(n):\n\tmaxStep = 5\n\tif n <= 5:\n\t\treturn 1\n\t\n\telif n > maxStep:\n\t\t\n\t\tsteps = math.ceil(n/5)\n\t\tif steps < 3:\n\t\t\t\n\t\t\tif steps / maxStep-1 >= 3:\n\n\t\t\t\treturn math.ceil(steps / maxStep-1)\n\n\t\t\telif steps / maxStep-1 < 3:\n\t\t\t\treturn math.ceil(steps / maxStep -2)\n\n\n\t\t\telif steps / maxStep -2 < 3:\n\t\t\t\treturn math.ceil(steps / maxStep -2)\n\n\t\telif steps >= 3:\n\t\t\treturn steps\n\nelephant(12)\n\n\n\n\n\n"}, {"source_code": "t = int(input())\nnumsteps = (t // 5)\na = (numsteps + 1)\nprint(a)"}, {"source_code": "num = int(input())\nr=0\nif num >= 5:\n r = num % 5\n ans = 1\nif r >= 4:\n r %= 4\n ans += 1\nif r >= 3:\n r %= 3\n ans += 1\nif r >= 3:\n r %= 2\n ans += 1\nans += r\nprint(ans)\n"}, {"source_code": "x = int(input())\nprint(x / 5 + 1) if x > 5 else 1\n"}, {"source_code": "steps=int(input())\ndef function():\n if steps <= 5 :\n print(\"1\")\n elif steps %5==0:\n print(steps/5)\n elif steps % 4==0:\n print(steps/4)\n elif steps % 3==0:\n print(steps/3)\n elif steps %2==0:\n print(steps/2)\n else:\n print('NO')\nfunction()"}, {"source_code": "x = int(input())\nd = 0\nc = 0\nwhile x > 0:\n if x%5 ==0:\n d+=5\n x-=5\n elif x%4 == 0:\n d+=4\n x-=4\n elif x%3 == 0:\n d+=3\n x-=3\n elif x%2 == 0:\n d+=2\n x-=2\n elif x%2 == 1:\n d+=1\n x-=1\n c+=1\nif str(d)[-1] == '9':\n c-=1\nprint(c)"}, {"source_code": "print(int(input())+4//5)"}, {"source_code": "take = int(input())\nsteps = [1,2,3,4,5]\nz=[]\nif take in steps:\n print(1)\nelse:\n for x in steps:\n xyz = take/x\n z.append(xyz)\n result= min(z)\n if result%2 == 0:\n print(round(result))\n else:\n print(int(min(z))+1)\n"}, {"source_code": "n=int(input())\nif (n%5==0):\n print(\"%d\",(n//5))\nelse:\n print(\"%d\",(n//5)+1)\n"}, {"source_code": "n = int(input())\ncount = 0\nif n > 5:\n count += n // 5\n n %= 5\ncount += 1\nprint(count)\n"}, {"source_code": "x = int(raw_input())\n\naccumulator = 0\ncount = 0\npossibilities = [5, 4, 3, 2, 1]\nindex = 0\n\nwhile(accumulator != x):\n if(index == len(possibilities) and accumulator != x):\n index = 0\n \n if(accumulator + possibilities[index] <= x):\n accumulator += possibilities[index]\n count += 1\n \n if (accumulator == x):\n break\n\n index += 1\n\nvalues = [x/float(possib) for possib in possibilities if x % possib == 0]\nprinta = False\nfor value in values:\n if value < count:\n printa = True\n break\n \nif printa:\n print(int(value))\nelse:\n print(count)\n"}, {"source_code": "n=int(input())\nif n>5:\n print(n//5+1)\nelse:\n print(1)"}, {"source_code": "n= int(input())\npole = [1,2,3,4,5]\npom=0\ni=0\nz=0\ndef steps(pole,n,pom,i,z):\n if n % pole[i]==0:\n z+=1\n if int(n/pole[i]) < pom:\n pom=int(n/pole[i])\n if z<2:\n pom=int(n/pole[i])\n elif i<len(pole)-1:\n steps(pole,n,pom,i+1,z)\n if i<len(pole)-1:\n steps(pole,n,pom,i+1,z)\n if i == len(pole)-1:\n global q\n q=pom\nsteps(pole,n,pom,i,z)\nprint(q)\n"}, {"source_code": "def step(n):\n if n % 5 == 0:\n return n//5\n else:\n return n//5 + 1\n"}, {"source_code": "n=input()\nlst=[]\nif n%1==0:\n a=n/1\n lst.append(a)\nif n%2==0:\n b=n/2\n lst.append(b)\nif n%3==0:\n c=n/3\n lst.append(c)\nif n%4==0:\n d=n/4\n lst.append(d)\nif n%5==0:\n e=n/5\n lst.append(e)\nprint min(lst)\n"}, {"source_code": "n = int(raw_input())\nif n=='5':\n print'1'\nif n=='12':\n print'3'"}, {"source_code": "t = int(input())\nnumsteps = (t // 5)\na = (numsteps + 1)\nprint(a)"}, {"source_code": "num = int(input())\nif num >= 1 and num <= 1000000:\n num = num // 5\n print(num + 1)"}, {"source_code": "n = int(input())\nm = n\np = n\nx = 0\nwhile m > 5:\n x = m//5\n m = 0\nif n <= 4:\n print(p // n)\nx = x + 1\nprint(x)\n"}, {"source_code": "l=[1,2,3,4,5]\nn= int(input())\nc=0\nwhile n>=1:\n if n in l:\n c+=1\n n=n//5\n else:\n c+=n//5\n n=n%5\nprint(c)"}, {"source_code": "import sys\nx = 0 \n\nfor line in sys.stdin:\n pass\ni=0\n\nwhile x >= 0: \n if x >= 5: \n x = x-5 \n i += 1\n elif x == 0:\n print(i)\n break\n else: \n x = 0\n i += 1 \n print(i)\n break"}, {"source_code": "import sys, os.path\nimport math\nif(os.path.exists('input.txt')):\n sys.stdin = open(\"input.txt\",\"r\")\n sys.stdout = open(\"output.txt\",\"w\")\n\nn = int(input())\nres = 0\n\nprint(n//5 + 1)\n"}, {"source_code": "x = int(input())\nif x <= 5:\n print('1')\nelif x % 5 == 0:\n print(x/5)\nelse:\n x % 5 <= 4\n print(round(x % 5) + 1)\n\n"}, {"source_code": "num = int(input())\nif num >= 1 and num <= 1000000:\n if num == 5:\n print(1)\n elif num > 5:\n num = num // 5\n print(num + 1)"}, {"source_code": "print(int(input())+4//5)"}, {"source_code": "x=int(raw_input())\nsteps=x//5+1\nprint (steps)"}, {"source_code": "cor = int(input())\n\nsteps = 0\n\nwhile cor!=0:\n if cor >= 5:\n cor -=5\n steps+=1\n if cor >= 4:\n cor -=4\n steps+=1\n if cor >=3:\n cor -= 3\n steps += 1\n if cor >=2 :\n cor -=2\n steps_=1\n if cor >=1:\n cor -=1\n steps_=1\n\nprint(steps)"}, {"source_code": "l=[1,2,3,4,5]\nn= int(input())\nc=0\nwhile n>1:\n if n in l:\n c+=1\n break\n else:\n c+=n//5\n n=n%5\n if n==0:\n break\nprint(c)"}, {"source_code": "a=(int(raw_input(\"a cuantos pasos vive tu amigo ?\")))\n\nb=a/5\nb%=5\nif(a%5!=0):\n b=b+1 \nprint b\n \n\n\n\n\n\n\n"}, {"source_code": "x=int(input())\nif x==5:\n print(1)\nelse:\n print(3)"}, {"source_code": "x = int(input())\ncount = 0\nif(x > 5):\n count += round(x/5 - 0.5)\n x -= count * 5\n print(count + 1)\nelse:\n print(1)\n \n"}, {"source_code": "x=int(input())\nif x%5==0:\n print(x+1)\nelse:\n print(x)"}, {"source_code": "x = int(input())\ny = str(x)\n\nif x <= 5:\n print('1')\nelif x % 5 == 0:\n print(x/5)\nelif y[-1] == '9':\n print(round(x/5))\nelse:\n x % 5 <= 4\n print(round(x/5) + 1)\n\n"}, {"source_code": "def function(n):\n if n<=5:\n return n\n else:\n if n%5==0:\n return (int(n/5))\n else:\n return int((n/5)+1)\n \nif __name__==\"__main__\":\n n=int(input())\n print(function(n))"}, {"source_code": "x = int(input())\ny = str(x)\n\nif x <= 5:\n print('1')\nelif x % 5 == 0:\n print(x/5)\nelif y[-1] == '9':\n print(round(x/5))\nelse:\n x % 5 <= 4\n print(round(x/5) + 1)\n\n"}, {"source_code": "\ndef foo(x):\n if x <= 5:\n return 1\n return 1 + ((x - (x % 5)) / 5)\n\n\nx = int(input())\nprint(int(foo(x)))"}, {"source_code": "n=input()\nv=[i for i in n if i>='A' and i<='Z']\nm=[i for i in n if i>='a' and i<='z']\nif len(v)>len(m):\n n=n.upper()\nelse:\n n=n.lower()\nprint(n) \n"}, {"source_code": "x = int(input())\ny = str(x)\n\nif x <= 5:\n print('1')\nelif x % 5 == 0:\n print(int(x/5))\nelif y[-1] == '9':\n print(int(round(x/5)))\nelse:\n x % 5 <= 4\n print(int(round(x/5)) + 1)\n\n"}, {"source_code": "import math\nx=int(raw_input())\nif x%5==0:\n\tprint math.floor(x/5)\nelse: \n\tprint math.floor(x/5+1)"}, {"source_code": "STEPS = [ 5, 4, 3, 2, 1 ]\n\nx = int(input())\nresult = 0\n\nfor i in STEPS:\n\tprint i\n\twhile True:\n\t\tif x - i >= 0:\n\t\t\tx -= i\n\t\t\tresult += 1\n\t\telse:\n\t\t\tbreak\n\nprint result"}, {"source_code": "n=int(input())\nif n%5==0:\n print(n/5)\nelse:\n print(n%5+1)"}, {"source_code": "num = int(input())\nr=0\nif num >= 5:\n r = num % 5\n ans = 1\nif r >= 4:\n r %= 4\n ans += 1\nif r >= 3:\n r %= 3\n ans += 1\nif r >= 3:\n r %= 2\n ans += 1\nans += r\nprint(ans)"}, {"source_code": "def func(num):\n count=0\n lst=[5,4,3,2,1]\n for i in lst:\n quot= num//i\n if quot>0:\n count+=1\n num=num%i\n if num==0:\n return count\nprint(func(int(input())))"}, {"source_code": "x = int(input())\nif x%5 ==0:\n print(x/5)\nelse :\n print((x//5) +1)\n \n\n\n"}, {"source_code": "k=int(input())\nm = 0\nwhile(k!=0):\n if k%5==0:\n m=m+1\n k=k-5\n elif k%4==0:\n m=m+1\n k=k-4\n elif k%3==0:\n m=m+1\n k=k-3\n elif k%2==0:\n m=m+1\n k=k-2\n elif k%1==0:\n m=m+1\n k=k-1\n\n\nprint(m)"}, {"source_code": "a=input()\nc=a//5\nprint c+1"}, {"source_code": "import math\n\nx = int(raw_input())\n\nif x <= 2:\n print 0\nelif x <= 5:\n print 1\nelif x <= 10:\n print 2\nelif x <= 15:\n print 3\nelse:\n print int(math.ceil(x * 1.0 / 5))\n"}, {"source_code": "n = int(input())\nx = 0\nm = n\nwhile m > 5:\n x = m//5\n m = 0\n if n < 5:\n print('1')\nans = x + 1\nprint(ans)\n\n"}, {"source_code": "x = int(input())\ny = str(x)\n\nif x <= 5:\n print('1')\nelif x % 5 == 0:\n print(int(x/5))\nelif y[-1] == '9':\n print(int(round(x/5)))\nelse:\n x % 5 <= 4\n print(int(round(x/5)) + 1)\n\n"}, {"source_code": "num = int(input(''))\nif num <= 5:\n print(1)\nelse:\n print(1 + num//5)"}, {"source_code": "coord = int(input())\nsteps = coord\ncount = 0\nwhile(steps > 5):\n\tsteps= -5\n\tcount+=1\ncount+=1\nprint(count)\n"}, {"source_code": "n=int(raw_input())\np=n/5\nr=n%5-1\nprint p+r"}, {"source_code": "a=(int(raw_input(\"a cuantos pasos vive tu amigo ?\")))\n\nb=a/5\nb%=5\nif(a%5!=0):\n b=b+1 \nprint b\n \n\n\n\n\n\n\n"}, {"source_code": "x = input()\nc = 0\n\nwhile x != 0:\n if x % 5 == 0:\n c += 1\n x -= 5\n continue\n if x % 4 == 0:\n c += 1\n x -= 4\n continue\n if x % 3 == 0:\n c += 1\n x -= 3\n continue\n if x % 2 == 0:\n c += 1\n x -= 2\n continue\n if x % 1 == 0:\n c += 1\n x -= 1\n continue\n\nprint c"}, {"source_code": "n = int(input())\n\ndis_remaining = n\nnum_of_steps = int(0)\n\nfor i in range(5, 1, -1):\n num_of_steps += dis_remaining // i\n dis_remaining = dis_remaining % i\n\nprint(num_of_steps)"}, {"source_code": "\nn = input('enter: ')\nn = int(n)\n\nprint(int((n+5+1) / 5))"}, {"source_code": "x = input()\n\nprint x / 5"}, {"source_code": "x = int(input())\n\ny = (x+4)/5\nprint (y)"}, {"source_code": "n = int(input())\nsum = 0\nwhile n != 0:\n if n%5 ==0:\n n -= 5\n sum += 1\n next\n elif n%4 == 0:\n n -= 4\n sum += 1\n next\n elif n%3 == 0:\n n -= 3\n sum += 1\n next\n elif n%2 == 0:\n n -= 2\n sum += 1\n next\n else:\n n -= 1\n sum += 1\n next\n\nprint(sum)"}, {"source_code": "import sys\nx = 0 \n\nfor line in sys.stdin:\n pass\n\ni = 0\n\nwhile x >= 0: \n if x >= 5: \n x = x-5 \n i += 1\n elif x == 0:\n print(i)\n break\n else: \n x = 0\n i += 1 \n print(i)\n break"}, {"source_code": "cor = int(input())\n\nsteps = 0\n\nwhile cor != 0:\n if cor >= 5:\n cor -= 5\n steps += 1\n if cor >= 4:\n cor -= 4\n steps += 1\n if cor >= 3:\n cor -= 3\n steps += 1\n if cor >= 2:\n cor -= 2\n steps += 1\n if cor >= 1:\n cor -= 1\n steps += 1\n\nprint(steps)\n"}, {"source_code": "x = input()\nlength = list(range(1,5))\nlength.reverse()\nsteps = 0\nfor i in length:\n number = x/i\n steps += number\n x -= number * i\n\nprint steps\n"}, {"source_code": "import math\n\nxs=input('')\nx=int(xs)\nxc=math.ceil(x/5)\nif xc<1:\n print('1')\nelse:\n print(xc+1)"}, {"source_code": "n = int(input())\nif(n%5==0):\n u = n/5\nelse:\n k = n/5\n u = k+1\nprint(u)"}, {"source_code": "x = int(input())\nprint(int(x/5) + 1)"}, {"source_code": "x = int(raw_input())\ncountsteps = 0\n\nwhile(x!=0):\n\tif(x-5 >= 0):\n\t\tx -= 5\n\t\tcountsteps += 1\n\tif(x-4 >= 0):\n\t\tx -= 4\n\t\tcountsteps += 1\n\tif(x-3 >= 0):\n\t\tx -=3\n\t\tcountsteps += 1\n\tif(x-2 >= 0):\n\t\tx -= 2\n\t\tcountsteps += 1\n\tif(x-1 >= 0):\n\t\tx -= 1\n\t\tcountsteps += 1\nprint countsteps"}, {"source_code": "import math\ndef Elephant():\n x= int(input())\n p=0\n if(x<=5):\n return 1\n elif(x>5):\n if(x%5 == 0):\n p=x/5\n else:\n p=math.floor(x/5)+1 \n return p\n \n\n\nif __name__ == \"__main__\":\n print(Elephant())"}, {"source_code": "x = int(input())\n\nprint((x+4)/5)"}, {"source_code": "i=int(input())\np=i//5\np=p+1\nif i==0:\n p=0\nprint(p)"}, {"source_code": "num = int(input())\nanswer = 0\n\nfor i in reversed(range(1, 6)):\n while num - i > 0:\n num -= i\n answer += 1\n print(answer, num, i)\n\nprint(answer)"}, {"source_code": "x = int(input())\nif x % 5 >= 4:\n print(x % 5 + 1)\nelse:\n print(x/5)\n"}, {"source_code": "import math\n\nxs=input('')\nx=int(xs)\nxc=math.ceil(x)\nif xc<1:\n print('1')\nelse:\n print(xc+1)"}, {"source_code": "a = int(input())\nprint((a // 5) + (a % 5 - (a % 5 - 1)))\n"}, {"source_code": "n = int(input())\ns = 0\nif n > 5:\n\ts = (n/5)+1\nelse:\n\ts = (n/5)\nprint(int(s))"}, {"source_code": "n=int(input())\nc=0\nwhile(n!=0):\n \n if(n%5==0):\n c=c+1\n n=n-5\n elif(n%4==0):\n c=c+1\n n=n-4\n elif(n%3==0):\n c=c+1\n n=n-3\n elif(n%2==0):\n c=c+1\n n=n-2\n elif(n%1==0):\n \n c=c+1\n n=n-1\nprint(c)"}, {"source_code": "a=int(input())\nc=a//5\nif(a<5)or(a%5==0):\n print(c)\nelse:\n print(c+1)\n\n \n"}, {"source_code": "n = int(input())\nif(n <= 5) :\n print(1)\nelif( n == 1000000):\n print(20001)\nelse:\n print((n // 5) + 1)"}], "src_uid": "4b3d65b1b593829e92c852be213922b6"} {"source_code": "n = int(raw_input())\ns = raw_input()\n\nif 'CC' in s or 'YY' in s or 'MM' in s:\n print \"No\"\nelif '??' in s or 'C?C' in s or 'M?M' in s or 'Y?Y' in s or s[0] == '?' or s[-1] == '?':\n print \"Yes\"\nelse:\n print \"No\"", "positive_code": [{"source_code": "\"\"\"\n________ _____________ ______\n___ __ \\____ ____ __ \\__(_)__ _______ ___ /\n__ /_/ /_ / / /_ /_/ /_ /__ | / / __ `/_ /\n_ ____/_ /_/ /_ _, _/_ / __ |/ // /_/ /_ /\n/_/ _\\__, / /_/ |_| /_/ _____/ \\__,_/ /_/\n /____/\n\nhttps://github.com/Cheran-Senthil/PyRival\nCopyright (c) 2018 Cheran Senthilkumar\n\"\"\"\nfrom __future__ import division, print_function\n\nimport cmath\nimport itertools\nimport math\nimport operator as op\nimport sys\nfrom atexit import register\nfrom bisect import bisect_left, bisect_right\n\n# import random\n# from collections import Counter, MutableSequence, defaultdict, deque\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\n# from heapq import heappop, heappush\n\nif sys.version_info[0] < 3:\n from io import BytesIO as stream\n # from fractions import Fraction\n # from fractions import gcd\n # from cPickle import dumps\n # from Queue import PriorityQueue, Queue\nelse:\n from io import StringIO as stream\n # from functools import reduce\n # from fractions import Fraction\n # from math import gcd\n # from pickle import dumps\n # from queue import PriorityQueue, Queue\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n def items(self):\n return dict.iteritems(self)\n\n def keys(self):\n return dict.iterkeys(self)\n\n def values(self):\n return dict.itervalues(self)\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"\n Sets whether the standard Python streams are allowed to buffer their I/O.\n\n Parameters\n ----------\n sync : bool, optional\n The new synchronization setting. Default is True.\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef main():\n n = int(input())\n s = input()\n prev = '!'\n for i in s:\n if i == prev:\n if i != '?':\n print('No')\n exit()\n prev = i\n if (s[0] == '?') or (s[-1] == '?'):\n print('Yes')\n exit()\n for i in range(1, n - 1):\n if s[i] == '?':\n if (s[i - 1] == '?') or (s[i + 1] == '?'):\n print('Yes')\n exit()\n if s[i - 1] == s[i + 1]:\n print('Yes')\n exit()\n print('No')\n\n\n\nif __name__ == '__main__':\n sys.setrecursionlimit(10000)\n sync_with_stdio()\n main()\n"}, {"source_code": "l = int(raw_input())\ns = raw_input()\n\n# check set \nflag = 1\nchecks = 0\nprev = \"\"\nfor i in s:\n if checks:\n if i == prev and prev!=\"?\":\n flag = 0\n break\n prev = i\n if i!=\"?\" and not checks:\n checks = 1\n prev = i\n# fin two ways beach\n\nif not flag :\n print(\"NO\")\nelse:\n if \"??\" in s or s[0]==\"?\" or s[-1]==\"?\": \n print(\"YES\")\n elif len(s) in [1,2]:\n print(\"NO\")\n else:\n checks = [\"M?M\",\"Y?Y\",\"C?C\"]\n for i in checks:\n if i in s:\n print(\"YES\")\n exit(0)\n print(\"NO\")\n"}, {"source_code": "def main():\n n=input()\n l=map(str,\" \".join(raw_input()).split())\n for i in xrange(1,n):\n if l[i]==l[i-1] and l[i]!='?':\n print \"No\"\n exit()\n c=0\n for i in xrange(2,n):\n if l[i-1]=='?' and l[i]!=l[i-2] and (l[i]!='?' and l[i-2]!='?'):\n c+=1\n if c==l.count('?'):\n print \"No\"\n exit()\n \n \n print \"Yes\"\n \nmain()"}, {"source_code": "import sys\nxrange = range\ninput = raw_input\n\nn = int(input())\nS = [c for c in input()]\nfor i in range(1,n):\n if S[i-1]!='?' and S[i]!='?' and S[i]==S[i-1]:\n print('No')\n sys.exit()\nfor i in range(1,n):\n if S[i-1]=='?' and S[i]=='?':\n print('Yes')\n sys.exit()\nif S[-1]=='?' or S[0]=='?':\n print('Yes')\n sys.exit()\nfor i in range(1,n-1):\n if S[i-1]==S[i+1] and S[i]=='?':\n print('Yes')\n sys.exit()\nprint('No')\n\n#s = 'CMY'\n#D = {}\n#D['C']=0\n#D['M']=1\n#D['Y']=2\n#locked = ['?'==S[i] for i in range(n)]\n#\n#if S[0]=='?':\n# pos[0] = 1\n#else:\n# pos[0] = 0\n#for i in range(1,n):\n# if S[i]=='?':\n# temp = pos[i-1][:]\n# temp = [1-t for t in ]\n"}, {"source_code": "n=int(input())\ns=str(input())\nflag=0\nfor i in range(0,len(s)-1):\n if(s[i]==s[i+1] and s[i]!='?'):\n flag=1\nif(flag==1):\n print('NO')\nelif(flag==0):\n if(s[0]=='?' or s[-1]=='?'):\n print('YES')\n else:\n flags=0\n for j in range(0,len(s)):\n if(s[j]=='?'):\n d=set()\n if(s[j+1]!='?'):\n d.add(s[j+1])\n if(s[j-1]!='?'):\n d.add(s[j-1]) \n if(len(d)==1):\n print('YES')\n flags=1\n break\n if(flags==0):\n print('NO')"}, {"source_code": "n = int(input())\nstr = input()\n\nfor i in range(len(str) - 1):\n if str[i] == str[i + 1] and str[i] != '?':\n print(\"No\")\n exit(0)\n\nif str[0] == '?' or str[-1] == '?' or '??' in str or 'M?M' in str or 'C?C' in str or 'Y?Y' in str:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "n = int(input())\ns = list(input())\nk = 0\nidx = -1\npossible = False\nfor i in range(n):\n if s[i] == '?':\n k += 1\n idx = i\n else:\n if i < n - 1:\n if s[i] == s[i + 1]:\n possible = False\n break\n if k > 1:\n possible = True\n elif k == 1:\n if idx == 0:\n possible = True\n else:\n if s[idx - 1] == s[idx + 1]:\n possible = True\n k = 0\nif idx == n - 1:\n possible = True\nif possible:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "n=int(input())\ns=input()\nif('YY' in s or 'CC' in s or 'MM' in s):\n print(\"No\")\nelse:\n f=0\n for i in range(n-1):\n if(s[i]=='?' and s[i+1]=='?'):\n f=1\n break\n elif(s[i]=='?'):\n if(i==0 or (s[i-1]==s[i+1])):\n f=1\n break\n if(s[-1]=='?'):\n f=1\n if(f==0):\n print(\"No\")\n else:\n print(\"Yes\")\n"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n-1):\n if s[i]==s[i+1] and s[i]!=\"?\":\n print(\"NO\")\n quit()\nans=\"No\"\nfor i in range(n-1):\n if s[i]==s[i+1]==\"?\":\n ans=\"YES\"\n break\n elif s[i]==\"?\":\n if i==0 or (s[i-1]==s[i+1]):\n ans=\"YES\"\n break\nif s[n-1]==\"?\": ans=\"YES\"\nprint(ans)"}, {"source_code": "n, s = int(input()), 'A' + input() + 'B'\n\nfor i in range(1, n + 1):\n if s[i] in 'CMY' and s[i] == s[i + 1]:\n print('No')\n break\nelse:\n if s[1] == '?' or s[n] == '?' or '??' in s:\n print('Yes')\n else:\n for i in range(1, n + 1):\n if s[i] == '?' and s[i - 1] == s[i + 1]:\n print('Yes')\n break\n else:\n print('No')\n"}, {"source_code": "n=int(input())\ns=input()\nf=1 \nfor i in range(n-1):\n if s[i]==s[i+1] and s[i]!='?' and s[i+1]!='?':\n f=0\n break \nif f==0:\n print('No')\nelse:\n ms=set()\n if '??' in s:\n print('Yes')\n else:\n if s[0]=='?' or s[-1]=='?':\n print('Yes')\n elif 'C?C' in s:\n print('Yes')\n elif 'M?M' in s:\n print('Yes')\n elif 'Y?Y' in s:\n print('Yes')\n else:\n print('No')\n "}, {"source_code": "n = int(input())\ns = input()\n\nif ((s.find('??') >= 0 or s[0] == '?' or s[-1] == '?'\n or any(s.find(c + '?' + c) >= 0 for c in ['C', 'M', 'Y']))\n and all(s.find(x) < 0 for x in ['CC', 'MM', 'YY'])):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "from itertools import accumulate\ndef rs(): return input().rstrip()\ndef ri(): return int(rs())\ndef ra(): return list(map(int, rs().split()))\n\n\nn = ri()\narr = list(rs())\n\nfor a, b in zip(arr, arr[1:]):\n if (a == b) and (a != \"?\"):\n print(\"No\")\n exit()\n\nfor num, item in enumerate(arr):\n if item == \"?\":\n if (num == 0) or (num == len(arr)-1):\n print(\"Yes\")\n exit()\n\n if arr[num-1] == arr[num+1]:\n print(\"Yes\")\n exit()\n\n if arr[num-1] == \"?\":\n print(\"Yes\")\n exit()\n\n if arr[num+1] == \"?\":\n print(\"Yes\")\n exit()\nelse:\n print(\"No\")\n"}, {"source_code": "n=int(input())\ns=input()\ni=1\nans=1\nif s[0]==\"?\":\n\tans=2\nwhile(i<n-1):\n\tif s[i]!='?' and (s[i]==s[i+1] or s[i]==s[i-1]):\n\t\tprint(\"No\")\n\t\texit()\n\tif s[i]==\"?\":\n\t\tif i<=n-3 and s[i+1]==\"?\":\n\t\t\tif s[i-1]==s[i+2]:\n\t\t\t\tans*=2\n\t\t\t\ti+=1\n\t\t\telif s[i+2]==\"?\":\n\t\t\t\tans*=2\n\t\t\telse:\n\t\t\t\tans*=4\n\t\telif s[i-1]==s[i+1]:\n\t\t\tans*=2\n\ti+=1\nif s[len(s)-1]==\"?\":\n\tans=2\nif ans>1:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n\n"}, {"source_code": "n = input()\ns = input()\n\ndef say_no():\n print(\"No\")\n exit(0)\n\ndef say_yes():\n print(\"Yes\")\n exit(0)\n\n\nfor i in range(1, len(s)):\n if s[i]==s[i-1] and s[i] != '?':\n say_no()\n\nfor i in range(1, len(s)-1):\n if s[i]=='?' and (s[i-1]==s[i+1] or s[i-1]=='?' or s[i+1]=='?'):\n say_yes()\n\nif s[0]=='?' or s[len(s)-1]=='?':\n say_yes()\n\nsay_no()"}, {"source_code": "n=int(input())\ns=input()\nans = 0\nfor i in range(1,n):\n if(s[i-1]==s[i] and (s[i]!='?')):\n ans=-1\n break\nif(ans==-1):\n print(\"No\")\nelse:\n ans = 1\n for i in range(n):\n if(s[i]=='?'):\n if(i-1>=0 and i+1<n):\n if((s[i-1]=='C' and s[i+1]=='Y') or (s[i-1]=='Y' and s[i+1]=='C')or (s[i-1]=='Y' and s[i+1]=='M')or (s[i-1]=='M' and s[i+1]=='Y')or (s[i-1]=='M' and s[i+1]=='C')or (s[i-1]=='C' and s[i+1]=='M')):\n ans=ans*1\n else:\n ans=ans*2\n else:\n ans = ans*2\n if(ans>1):\n print(\"Yes\")\n else:\n print(\"No\")"}, {"source_code": "n = int(input())\na = input()\n\nflag = 0\nfor ind, a_i in enumerate(a):\n if ind == 0:\n continue\n else:\n if a_i == a[ind - 1] and a_i != '?':\n flag = 1\n break\n\nif flag == 1:\n print('No')\nelse:\n if a.count('?') >= 2:\n flag = 0\n for ind, a_i in enumerate(a):\n if ind != 0 and ind != n - 1:\n if a_i == '?' and a[ind - 1] == a[ind + 1] or a_i == '?' and (a[ind - 1] == '?' or a[ind + 1] == '?'):\n flag = 1\n break\n elif ind == 0 and a_i == '?' or ind == n - 1 and a_i == '?':\n flag = 1\n break\n print('Yes' if flag == 1 else 'No')\n else:\n if a.count('?') == 0:\n print('No')\n else:\n ind = a.index('?')\n if ind == 0 or ind == n - 1:\n print('Yes')\n else:\n if a[ind - 1] == a[ind + 1]:\n print('Yes')\n else:\n print('No')\n\n"}, {"source_code": "import sys\ncanvas_size = int(input())\ncanvas = input()\n\nnext_possibilities = \"CMY\"\n\npossible = False\nif canvas[0] == '?' or canvas[-1] == '?':\n possible = True\n\nfor i, color in enumerate(canvas[1: len(canvas)-1]):\n i += 1\n if color == '?':\n if canvas[i-1] == '?' or canvas[i+1] == '?' or canvas[i-1] == canvas[i+1]:\n possible = True\n\nif not possible:\n print(\"No\")\n sys.exit()\n\nlast_color = canvas[0]\nfor color in canvas[1:]:\n if color == last_color and color != '?':\n print(\"No\")\n sys.exit()\n last_color = color\n\n\nprint(\"Yes\")\n"}, {"source_code": "# cook your dish here\nfrom sys import stdin,stdout\nfrom collections import Counter\nfrom itertools import permutations\nimport bisect\nimport math\nI=lambda: map(int,stdin.readline().split())\nI1=lambda: stdin.readline()\n\nn=int(I1())\ns=I1().strip()\ni,f=0,0\nfor j in range(1,n):\n if s[j]==s[j-1] and s[j]!='?':\n print('No')\n exit()\nwhile i<n:\n if s[0]=='?' or s[n-1]=='?':\n f=1 \n break\n elif s[i]=='?':\n j=i+1 \n while s[j]=='?':j+=1 \n if(s[i-1]==s[j]) or(s[i-1]!=s[j] and j-i>1):\n f=1 \n break\n i+=1 \nif f==1: print(\"Yes\")\nelse : print(\"No\")\n "}, {"source_code": "n=int(input())\ns=input()\nif ('MM' in s) or ('CC' in s) or ('YY' in s):\n print('No')\nelse:\n if (s[0]=='?') or (s[-1]=='?'):\n print('Yes')\n else:\n if '??' in s:\n print('Yes')\n else:\n if ('C?C' in s) or ('M?M' in s) or ('Y?Y' in s):\n print('Yes')\n else:\n print('No')\n"}, {"source_code": "n=int(input())\na=input()\ndef check(n,a):\n for i in range(n-1):\n if a[i]==a[i+1] and a[i]!='?':\n return False\n return True\nl=[]\nc=0\nfor i in range(n):\n if a[i]=='?':\n c=c+1\n l.append(a[i])\nk=0\nfor i in range(n-2):\n if a[i+1]=='?' and a[i]==a[i+2]:\n k=1\nif check(n,l)==False:\n print('No')\n k=2\ndef main(l,n):\n t=[]\n for i in l:\n b=i.index('?')\n q=[]\n r=[]\n s=[]\n for j in range(b):\n q.append(i[j])\n r.append(i[j])\n s.append(i[j])\n q.append('Y')\n r.append('C')\n s.append('M')\n if 1==1:\n for j in range(b+1,n):\n q.append(i[j])\n r.append(i[j])\n s.append(i[j])\n if check(n,q)==True:\n t.append(q)\n if check(n,r)==True:\n t.append(r)\n if check(n,s)==True:\n t.append(s)\n return t\nif k==1:\n print('Yes')\nif k==0:\n l=[l]\n for i in range(c):\n l=main(l,n)\n d=0\n for i in l:\n if check(n,i)==True:\n if d==1:\n print('Yes')\n d=d+1\n if d==0 or d==1:\n print('No')\n\n"}, {"source_code": "n = int(input())\ns = input()\nind = True\nind1 = False\ny = []\nfor i in s:\n\ty.append(i)\nfor i in range(n):\n\tif (y[i] == \"?\" and i == 0) or (y[i] == \"?\" and i == n - 1) or (y[i] == \"?\" and y[i - 1] == y[i + 1]) or (y[i] == \"?\" and (y[i - 1] == \"?\" or y[i + 1])) == \"?\":\n\t\tind1 = True\n\tif i > 0 and (y[i] == y[i - 1] and y[i] != \"?\"):\n\t\tind = False\n\t\tbreak\nif ind and ind1:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\t\n"}, {"source_code": "n = int(input());\ns = input();\n\ndef f():\n\tfor i in range(n-1):\n\t\tif s[i] == s[i+1] and s[i] != \"?\":\n\t\t\treturn False\n\tif \"??\" in s:\n\t\treturn True\n\tif \"C?C\" in s or \"M?M\" in s or \"Y?Y\" in s:\n\t\treturn True\n\tif s[0] == \"?\" or s[n-1] == \"?\":\n\t\treturn True\n\treturn False\n\n\nif f():\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\") \n"}, {"source_code": "x = int(input())\nmyStr = input()\n\ndef func(myStr):\n\tchoice = 0\n\tn = len(myStr)\n\tfor i, c in enumerate(myStr):\n\t\tif c != '?':\n\t\t\tif i + 1 < n:\n\t\t\t\tif c == myStr[i + 1]:\n\t\t\t\t\treturn False\n\t\t\t\t\tbreak\n\t\telif c == '?' and choice < 2:\n\t\t\tif i + 1 < n:\n\t\t\t\tif c == myStr[i + 1]:\n\t\t\t\t\tchoice += 2\n\t\t\t\telse:\n\t\t\t\t\tif i - 1 < 0 :\n\t\t\t\t\t\tchoice += 2\n\t\t\t\t\telse:\n\t\t\t\t\t\tif myStr[i - 1] == myStr[i + 1]:\n\t\t\t\t\t\t\tchoice += 2\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tchoice += 2\n\t\t\n\t\n\tif choice >= 2:\n\t\treturn True\n\telse:\n\t\treturn False\n\nz = func(myStr)\nif z == True:\n\tprint('Yes')\nelse:\n\tprint('No')"}, {"source_code": "import re\ninput()\ns=input()\nprint('No'if re.search('CC|MM|YY',s)or not('?'in(s[0],s[-1])or'??'in s\nor re.search(r'(C|M|Y)\\?(\\1)',s))else'Yes')"}, {"source_code": "n=input()\ns=input()\nif s.count(\"CC\") or s.count(\"MM\") or s.count(\"YY\"):\n print(\"No\")\nelif(s[0]=='?' or s[-1]=='?'):\n print(\"Yes\")\nelif s.count(\"??\"):\n print(\"Yes\")\nelse:\n b=''\n q=0\n for i in s:\n if(i!='?'):\n if((q>0 and b==i)):\n print(\"Yes\")\n break\n q=0\n b=i\n \n else:\n q+=1\n else:\n print(\"No\")"}, {"source_code": "n = int(input())\ns = input()\nif s.count('MM') > 0 or s.count('CC') > 0 or s.count('YY') > 0 or s.count('?') == 0:\n print('No')\nelse:\n if s.count('??') > 0 or s[0] == '?' or s[-1] == '?':\n print('Yes')\n else:\n for i in range(1, n - 1):\n if s[i] == '?':\n if s[i - 1] == s[i + 1]:\n print('Yes')\n exit()\n if i == n - 2:\n print('No')\n"}, {"source_code": "n = int(input())\ns = input()\nif(s.find('CC')!=-1 or s.find('YY')!=-1 or s.find('MM')!=-1):\n print('No')\nelif(s.find(\"??\")!=-1):\n print(\"Yes\")\nelse:\n c = 0\n p = []\n f = 0\n for i in range(len(s)):\n if(s[i]==\"?\"):\n p.append(i)\n for y in p:\n if(y==0 or y==n-1):\n print(\"Yes\")\n f = 1\n break\n else:\n if(s[y-1]==s[y+1]):\n c+=2\n break\n if(c>=2 and f!=1):\n print(\"Yes\")\n elif(c<2 and f!=1):\n print(\"No\")"}, {"source_code": "_,s = input(),input()\nprint('Yes' if\n ('??' in s or 'C?C' in s or 'M?M' in s or 'Y?Y' in s or s[0] == '?' or s[-1] == '?') and\n not ('CC' in s or 'MM' in s or 'YY' in s)\nelse 'No')"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(n - 1):\n if s[i] == s[i + 1] != '?':\n print('NO')\n break\nelse:\n for i in range(n):\n if s[i] == '?':\n if i != 0 and i != n - 1 and s[i - 1] != s[i + 1] and s[i - 1] != '?' and s[i + 1] != '?':\n continue\n print('YES')\n break\n else:\n print('NO')\n"}, {"source_code": "\nn = int(input())\na = input()\na = list(a)\n\n\nt=0\n\ng =a.count(\"?\")\n\n\nif g==0:\n\tprint(\"No\")\n\texit()\n\nfor i in range(n-1):\n\tj = i+1\n\tif (a[i]==a[j] and a[i]!=\"?\") :\n\t\tprint(\"No\")\n\t\texit()\nfor i in range(1,n-1):\n\tif a[i-1]!=a[i+1] and a[i]==\"?\" and (a[i-1]!=\"?\" and a[i+1]!=\"?\" ):\n\t\tt+=1\n\t\t\nif t>=g and t!=0:\n\tprint(\"no\")\n\texit()\nprint(\"Yes\")\n\t\t"}, {"source_code": "n = int(input())\ns = input()\nans = 0\nfor i in range(n):\n if (i<n-1 and s[i]==s[i+1]=='?'):\n ans = 1\n if (s[i]=='?' and (i==0 or i==n-1 or s[i-1]==s[i+1])):\n ans = 1\nfor i in range(n-1):\n if (s[i]==s[i+1] and s[i]!='?'):\n ans = 0\nif (ans==1):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n"}, {"source_code": "import re\nsmem = {}\ndmem = {}\n\ndef S(n):\n\tglobal smem\n\tif n == 0: return 1\n\tif n in smem:\n\t\treturn smem[n]\n\tsmem[n] = 2 * D(n - 1)\n\treturn smem[n]\n\t\ndef D(n):\n\tglobal dmem\n\tif n == 0: return 1\n\tif n == 1:return 1\n\telif n == 2: return 3\n\tif n in dmem:\n\t\treturn dmem[n]\n\tdmem[n] = 2 * D(n - 1) + S(n - 1)\n\treturn dmem[n]\n\nn = int(input())\ns = input()\nL = [(m.start(0),m.end(0)-1) for m in re.finditer(\"[?]+\", s)]\n\nres = []\nfor a, b in L:\n\t# Categorize\n\tl = b - a + 1\n\tif a == 0:\n\t\tif b == n - 1:\n\t\t\t# no chars\n\t\t\tprint(\"Yes\")\n\t\t\texit()\n\t\telse:\n\t\t\t# has a char\n\t\t\tres.append(2 ** l)\n\telif b == n - 1:\n\t\tif a == 0:\n\t\t\t# no chars\n\t\t\tprint(\"Yes\")\n\t\t\texit()\n\t\telse:\n\t\t\t# has a char\n\t\t\tres.append(2 ** l)\n\telse:\n\t\t# somewhere in between\n\t\tif s[a - 1] != \"?\":\n\t\t\tif s[b + 1] != \"?\":\n\t\t\t\t# both surrounded by chars\n\t\t\t\tif s[a-1]==s[b+1]:\n\t\t\t\t\t# same on both sides\n\t\t\t\t\tres.append(S(l))\n\t\t\t\telse:\n\t\t\t\t\t# different\n\t\t\t\t\tres.append(D(l))\n\nfor a,b in zip(s,s[1:]):\n\tif a == \"?\":\n\t\tcontinue\n\tif a == b:\n\t\tprint(\"No\")\n\t\texit()\n\nreal = 1\nfor x in res:\n\treal *= x\nif real < 2:\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")\n"}, {"source_code": "n = int(input())\ns = input()\ndef yes():\n print('YES')\n exit()\ndef no():\n print('NO')\n exit()\n\nif s.find('YY') >= 0: no()\nif s.find('CC') >= 0: no()\nif s.find('MM') >= 0: no()\n \nif s.find('???') >= 0 or s.find('??') >= 0:\n yes()\nif s.find('C?C') >= 0: yes()\nif s.find('M?M') >= 0: yes()\nif s.find('Y?Y') >= 0: yes()\nif s[0] == '?' or s[-1] == '?': yes()\n\nno()\n"}, {"source_code": "n = int(input())\ns = list(input().strip())\n\nfor i in range(1, n):\n if s[i] != '?' and s[i-1] != '?' and s[i] == s[i-1]:\n print('No')\n exit(0)\n\nok = False if s[0] != '?' and s[n-1] != '?' else True\np = 1\nwhile p+1 < n:\n while p+1 < n and s[p] != '?':\n p += 1\n q = p\n while q+1 < n and s[q] == '?':\n q += 1\n l = q - p\n if l > 1:\n ok = True\n else:\n if q+1 < n and s[p-1] == s[q]:\n ok = True\n p = q\nif ok:\n print('Yes')\nelse:\n print('No')\n\n \n"}, {"source_code": "n = int(input())\ns = input()\n\nnumberOfways = 1\nfor i in range(n-1):\n if (s[i] == '?'):\n if (i == 0):\n if (s[i+1] == '?'):\n numberOfways *= 3\n else:\n numberOfways *= 2\n elif (s[i-1] == s[i+1] or (s[i-1] != '?' and s[i+1] == '?')):\n numberOfways *= 2\n else:\n if (s[i+1] == s[i]):\n numberOfways *= 0\n else:\n pass\n if (i == n-2 and s[i+1] == '?'):\n numberOfways *= 2\n\nif (n == 1 and s[0] == '?'):\n numberOfways = 3\nif (numberOfways > 1):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "# -*- coding: utf-8 -*-\n# @Time : 2018/3/29 20:35\n# @Author : Yunjie Cao\n# @FileName: A.py\n# @Software: PyCharm\n# @Email \uff1aCyj19970823@gmail.com\n\n\nimport re\n\ndef solve():\n n = input()\n s = input()\n if (('??'in s or 'C?C' in s or 'Y?Y' in s or 'M?M' in s or s[0]=='?' or s[-1]=='?') and 'CC' not in s and 'YY' not in s and 'MM' not in s):\n print(\"YES\")\n else:\n print(\"NO\")\n\nif __name__==\"__main__\":\n solve()"}, {"source_code": "import math\nfrom decimal import Decimal\ndef na():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\treturn n,b\n \n \ndef nab():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tc = [int(x) for x in input().split()]\n\treturn n,b,c\n \n \ndef dv():\n\tn, m = map(int, input().split())\n\treturn n,m\n \n \ndef dva():\n\tn, m = map(int, input().split())\n\ta = [int(x) for x in input().split()]\n\tb = [int(x) for x in input().split()]\n\treturn n,m,b\n \n \ndef eratosthenes(n): \n\tsieve = list(range(n + 1))\n\tfor i in sieve:\n\t\tif i > 1:\n\t\t\tfor j in range(i + i, len(sieve), i):\n\t\t\t\tsieve[j] = 0\n\treturn sorted(set(sieve))\n \n \n \ndef nm():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tm = int(input())\n\tc = [int(x) for x in input().split()]\n\treturn n,b,m,c\n \n \ndef dvs():\n\tn = int(input())\n\tm = int(input())\n\treturn n, m\n \n\nn = int(input())\ns = input()\nk = 0\ntk = 0\nif n == 1 and s[0] == '?':\n\tprint('YES')\n\texit()\nfor i in range(n - 1):\n\tif s[i] == '?':\n\t\tk += 1\n\tif s[i] == '?' and i > 0 and s[i - 1] != s[i + 1] and s[i-1] != '?' and s[i+1] != '?':\n\t\ttk += 1\n\tif s[i] == s[i + 1] and s[i] != '?':\n\t\tprint('NO')\n\t\texit()\nif s[n - 1] == '?':\n\tk += 1\nif k == tk:\n\tprint('NO')\nelse:\n\tprint('YES')\n"}, {"source_code": "def checker(paints: str) -> bool:\n limit = len(paints) - 1\n i = 1\n while i < limit:\n if paints[i] == '?' and paints[i - 1] != '?' and paints[i + 1] != '?' and paints[i - 1] != paints[i + 1]:\n paints = paints[:i] + paints[i + 1:]\n limit -= 1\n\n i += 1\n\n for i in range(0, len(paints) - 1):\n if paints[i] == paints[i + 1] and paints[i] != '?' and paints[i + 1] != '?':\n return False\n\n return \"?\" in paints\n\n\nlengthOfTheCanvas = int(input())\npaints1 = input()\nif checker(paints1):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(n - 1):\n if s[i] == s[i + 1] != '?':\n print('No')\n exit(0)\nfor i in range(1, n - 1):\n if s[i] == '?' and len(set([s[i - 1], s[i + 1]])&set(\"CYM\")) != 2:\n print('Yes')\n exit(0)\nif s[0] == '?' or s[-1] == '?':\n print('Yes')\n exit(0)\nprint('No')\n"}, {"source_code": "n = input()\ns = input()\n\ncolors = {\"C\",\"Y\",\"M\"}\n\ndef res():\n for c in colors:\n if s.find(c*2) != -1:\n return \"No\"\n \n if s[0] == \"?\":\n return \"Yes\"\n \n if s[len(s)-1] == \"?\":\n return \"Yes\"\n \n if s.find(\"??\") != -1:\n return \"Yes\"\n \n for c in colors:\n if s.find(c+\"?\"+c)!=-1:\n return \"Yes\"\n \n return \"No\"\n\nprint(res())\n "}, {"source_code": "input()\ns=input()\nif 'MM' in s or 'CC' in s or 'YY' in s or '?' not in s:\n print('No')\n exit()\nt=s.count('C?Y')+s.count('C?M')+s.count('Y?M')\nt+=s.count('Y?C')+s.count('M?Y')+s.count('M?C')\nif t==s.count('?'):\n print('No')\n exit()\nprint('Yes')\n\n\n"}, {"source_code": "n = int(input())\nt = input()\nb = True\nfor i in range(len(t)-1):\n if t[i]==t[i+1] and t[i]!='?':\n b = False\n break\nif not b:\n print(\"No\")\nelse:\n b = False\n if t[0]=='?' or t[len(t)-1]=='?':\n b = True\n for i in range(1, len(t)-1):\n if t[i]=='?' and (t[i-1]==t[i+1] or t[i-1]=='?' or t[i+1]=='?'):\n b = True\n if b:\n print(\"Yes\")\n else:\n print(\"No\")\n"}, {"source_code": "import sys\n\nn = int(input())\nstring1 = input()\nstring2 = string1\narray = ['C','Y','M']\nflag = 1\nfor i in range(0, len(string2)-1):\n\tif(string2[i] != \"?\" and string2[i] == string2[i+1]):\n\t\tprint(\"No\")\n\t\tsys.exit() \nif(string2[0] == \"?\" or string2[len(string2)-1] == \"?\"):\n\tprint(\"Yes\")\n\tsys.exit() \n\n\nfor i in range(1, len(string2)-1):\n\tif(string2[i] == '?'):\n\t\tif(string2[i-1] == string2[i+1] or string2[i+1] == \"?\"):\n\t\t\tflag = 0\n\t\t\tbreak\n\nif(flag == 1):\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")"}, {"source_code": "x=int(input())\ny=input()\nfor i in range (len(y)-1):\n if y[i+1]==y[i] and y[i] != '?':\n print(\"No\")\n exit()\n\nalist=[]\nfor i in range (1,len(y)-2):\n if y[i]== '?' and y[i-1]!= '?' and y[i+1]!= '?':\n alist.append(i)\n elif y[i]== '?' and y[i+1]== '?' :\n print(\"yes\")\n exit()\n\n\n\nif '?' in y :\n\n\n\n if y[0] == '?' or y[len(y)-1]=='?':\n print(\"yes\")\n exit()\n for i in alist :\n if y[i-1]==y[i+1] :\n continue\n else:\n print(\"No\")\n exit()\n\n\n\n print(\"Yes\")\n\n\n\n\nelse:\n print(\"No\")"}, {"source_code": "n=input()\ns=raw_input()\nif 'CC' in s or 'MM' in s or 'YY' in s:\n\tprint 'NO'\nelif '??' in s:\n\tprint 'YES'\nelif 'C?C' in s or 'M?M' in s or 'Y?Y' in s or s[0]=='?' or s[n-1]=='?':\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "n = int(input())\ns = list(input())\n\ndef main():\n if '?' not in s:\n print('No')\n return\n\n for i in range(1,n):\n j = i-1\n if (s[i] == s[j]) and (s[i] != '?'):\n print('No')\n return\n\n if n == 1:\n print('Yes')\n return\n\n if s[0]=='?' or s[n-1]=='?':\n print('Yes')\n return\n\n for i in range(1,n):\n j = i-1\n if s[i] == s[j]:\n print('Yes')\n return\n\n\n for i in range(2,n):\n i_1 = i-1\n i_2 = i-2\n if (s[i_2] == s[i]) and s[i_1]=='?':\n print('Yes')\n return\n\n print('No')\n return\n\n\nmain()"}, {"source_code": "n=int(input())\ns=input()\nj=s.count(\"?\")\nc=0\nfor i in range(0,len(s)-1):\n if(s[i]==s[i+1] and s[i]!='?'):\n print(\"No\")\n exit()\n if(s[i]=='?'):\n if(s[i-1]!=s[i+1] and s[i-1]!='?' and s[i+1]!='?'):\n c+=1\nif(s[0]=='?' or s[n-1]=='?'):\n print(\"Yes\")\n exit()\nif(c==j):\n print(\"No\")\n exit()\nprint(\"Yes\")"}, {"source_code": "li=lambda:(map(int,raw_input().strip().split()))\nni=lambda:(int(raw_input()))\nsi=lambda:(raw_input())\nimport math\nfrom collections import Counter\nn=ni()\nr=si()\nl=len(r)\ng=1\nfor i in range(0,l-1):\n if r[i]==r[i+1]:\n if r[i]==\"?\":\n continue\n else:\n print \"No\"\n exit(0)\ni=0\nif r[i]==\"?\" or r[l-1]==\"?\":\n print \"Yes\"\n exit(0)\nfor i in range(1,l-2):\n if r[i]==\"?\":\n if r[i-1]!=r[i+1] and r[i-1]!=\"?\" and r[i+1]!=\"?\":\n g=1\n else:\n g=2\n print \"Yes\"\n exit(0)\n break\nif g==1:\n print \"No\""}, {"source_code": "n = int(input())\ns = input()\n\n# Case where we can't use two coloring :\n# 1) no \"?\" present\n# 2) X?Y Case\n# 3) X??X S'il existe des suites\n\nans = \"Yes\"\nno_int = s.count(\"?\")\n\n\ndef is_cool(s):\n if s.count(\"??\"):\n return True\n else:\n a = s.count(\"C?C\") + s.count(\"M?M\") + s.count(\"Y?Y\")\n return a > 0\n\n\nok = (s.count(\"MM\") + s.count(\"CC\") + s.count(\"YY\")) == 0\n# print(\"ok : \", ok)\n\nif n == 1:\n if s == \"?\":\n ans = \"Yes\"\n else:\n ans = \"No\"\nelse:\n\n if not (ok):\n ans = \"No\"\n elif no_int == 0:\n ans = \"No\"\n elif s[0] == \"?\" or s[-1] == \"?\":\n ans = \"Yes\"\n elif s.count(\"M?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"M?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"C?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"C?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"Y?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"Y?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n\nprint(ans)\n"}, {"source_code": "def f(s,n):\n for i in range(n-1):\n if s[i] == s[i+1] and s[i] != '?':\n return 'No'\n if s[0] == '?' or s[-1] == '?':\n return ('Yes')\n for i in range(1,n-1):\n if s[i] == '?':\n if s[i-1] == s[i+1] or s[i-1] == '?' or s[i+1] == '?':\n return 'Yes'\n return 'No'\n\nn = int(input())\ns = input()\nprint(f(s,n))"}, {"source_code": "#codeforces_957A_live\nn = int(input())\nsi = input()\nflag = True\nif \"MM\" in si or \"CC\" in si or \"YY\" in si or not(\"?\" in si):\n\tprint(\"No\")\nelif \"???\" in si or \"??\" in si:\n\tprint(\"Yes\")\nelif si.startswith(\"?\") or si.endswith(\"?\"):\n\tprint(\"Yes\")\nelse:\n\tfor k in range(n):\n\t\tif si[k] == \"?\" and si[k-1] == si[k+1]:\n\t\t\tprint(\"Yes\")\n\t\t\tflag = False\n\t\t\tbreak;\n\tif flag :\n\t\tprint(\"No\")\n"}, {"source_code": "raw_input()\ns = raw_input().strip()\n\nif len(s) == 1 and s[0] == '?':\n print 'Yes'\n exit(0)\n\nif s.find('CC') != -1 or s.find('YY') != -1 or s.find('MM') != -1:\n print 'No'\n exit(0)\n \nfor i in xrange(len(s)):\n if i > 0 and s[i] == s[i - 1]:\n print 'Yes'\n exit(0)\n \n cnt = i == 0\n cnt += i == len(s) - 1\n if s[i] == '?':\n if cnt > 0 or s[i - 1] == s[i + 1]:\n # if i == len(s) - 1 or s[i - 1] == s[i + 1]:\n print 'Yes'\n exit(0)\nprint 'No'"}, {"source_code": "n = int(input())\ns = input()\ncl = ['M', 'C', 'Y']\nres = True\ncount = s.count('?')\nfor i in range(1, n-1):\n if (s[i]!='?' and s[i-1]!='?' and s[i-1]==s[i]) or (s[i]!='?' and s[i+1]!='?' and s[i]==s[i+1]):\n res = False\n break\n if s[i-1]!='?' and s[i+1]!='?' and s[i-1]!=s[i+1] and s[i]=='?':\n count-=1\n\nif count==0 : res = False\nif res: print('Yes')\nelse: print('No')"}, {"source_code": "#from collections import Counter,defaultdict\n#get= lambda : map(int,input().split())\nimport re\ninput()\ns=input()\nif re.findall('C{2,}|M{2,}|Y{2,}',s):\n print (\"No\")\n exit()\nif s.startswith('?') or s.endswith('?'):\n print(\"Yes\")\n exit()\ns=' '+s+' '\n\nl=0\n\n\nfor i,j in enumerate(s):\n if '?'==j:\n l+=1\n else:\n if l==1:\n if s[i-2]==s[i]:\n print(\"Yes\")\n break \n if l>=2:\n print(\"Yes\")\n break\n l=0\nelse:\n print(\"No\")\n#http://codeforces.com/problemset/problem/957/A\n"}, {"source_code": "import sys\nsys_in = sys.stdin\n\n\ndef read_ints():\n return map(lambda x: int(x), sys_in.readline().split())\n\n\ndef read_int():\n return int(sys_in.readline())\n\nN = read_int()\nline = sys_in.readline().strip()\n\npossible_colors = [None]*N\nfor i in range(N):\n c = line[i]\n if c != '?':\n possible_colors[i] = set([c])\n if i > 0:\n try:\n possible_colors[i-1].remove(c)\n except KeyError:\n pass\n else:\n possible_colors[i] = set(['C', 'M', 'Y'])\n if i > 0:\n if len(possible_colors[i-1]) == 1:\n possible_colors[i].remove(list(possible_colors[i-1])[0])\n if len(possible_colors[i]) == 0:\n sys.stdout.write(\"No\\n\")\n exit(0)\n\nfor i in range(N-1, 0, -1):\n if len(possible_colors[i]) == 0:\n sys.stdout.write(\"No\\n\")\n exit(0)\n if len(possible_colors[i]) == 1:\n try:\n possible_colors[i-1].remove(list(possible_colors[i])[0])\n except KeyError:\n pass\n\nfor i in range(N):\n if len(possible_colors[i]) == 0:\n break\n if len(possible_colors[i]) >= 2:\n sys.stdout.write(\"Yes\\n\")\n exit(0)\n\nsys.stdout.write(\"No\\n\")"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n\tif s == '?':\n\t\tprint(\"yes\")\n\telse:\n\t\tprint(\"no\")\n\tquit()\nfor i in range(1, n):\n\tif s[i] == s[i - 1] and s[i] != '?':\n\t\tprint(\"no\")\n\t\tquit()\nif s[0] == '?':\n print(\"yes\")\n quit()\nfor i in range(1, n):\n\tif s[i] == '?':\n\t\tif i == n - 1 or s[i - 1] == s[i + 1] or s[i - 1] == '?' or s[i + 1] == '?':\n\t\t\tprint(\"yes\")\n\t\t\tquit()\nprint(\"no\")"}, {"source_code": "n = int(input())\na = input()\nfor i in range(1, len(a)):\n if a[i] == a[i-1] and a[i-1] != '?':\n print('No')\n exit()\nfor i in range(1, len(a)-1):\n if a[i] == '?' and ((a[i-1] == a[i+1]) or (a[i-1] == a[i] or a[i+1] == a[i])):\n print('Yes')\n exit()\nif a[0] == '?' or a[-1] == '?':\n print('Yes')\n exit()\nprint('No')"}, {"source_code": "n=int(input())\ns=input()\ncont=0\nx=s[0]\nt=False\nt1=True\nif x=='?':\n t=True\nfor i in range(1,n):\n if s[i]==s[i-1] and s[i]!='?':\n t1=False\n break\n if (s[i]=='?' and i+1!=n and s[i-1]==s[i+1]) or (s[i-1]=='?' and s[i]=='?') or (s[i]=='?' and i+1==n) :\n t=True\nif t== True and t1==True:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "import math\nfrom fractions import Fraction\n\ndef modInverse(a, m) :\n\t\n\tg = gcd(a, m)\n\t\n\tif (g != 1) :\n\t\tprint(\"Inverse doesn't exist\")\n\t\t\n\telse :\n\t\tres = power(a, m - 2, m)\n\t\treturn res\n\t\n# To compute x^y under modulo m\ndef power(x, y, m) :\n\t\n\tif (y == 0) :\n\t\treturn 1\n\t\t\n\tp = power(x, y // 2, m) % m\n\tp = (p * p) % m\n\n\tif(y % 2 == 0) :\n\t\treturn p \n\telse : \n\t\treturn ((x * p) % m)\n\n# Function to return gcd of a and b\ndef gcd(a, b) :\n\tif (a == 0) :\n\t\treturn b\n\t\t\n\treturn gcd(b % a, a)\n\ndef modulo(a, m):\n\treturn (a%m+m)%m\n\n\n\n\ndef matrix_square(A, mod):\n return mat_mult(A,A,mod)\n\n\ndef mat_mult(A,B, mod):\n if mod is not None:\n return [[modulo(A[0][0]*B[0][0] + A[0][1]*B[1][0], MOD), modulo((A[0][0]*B[0][1] + A[0][1]*B[1][1]), MOD)],\n [modulo((A[1][0]*B[0][0] + A[1][1]*B[1][0]), MOD), modulo((A[1][0]*B[0][1] + A[1][1]*B[1][1]), MOD)]]\n\n\ndef matrix_pow(M, power, mod):\n #Special definition for power=0:\n if power <= 0:\n return M\n\n powers = list(reversed([True if i==\"1\" else False for i in bin(power)[2:]])) #Order is 1,2,4,8,16,...\n\n matrices = [None for _ in powers]\n matrices[0] = M\n\n for i in range(1,len(powers)):\n matrices[i] = matrix_square(matrices[i-1], mod)\n\n\n result = None\n\n for matrix, power in zip(matrices, powers):\n if power:\n if result is None:\n result = matrix\n else:\n result = mat_mult(result, matrix, mod)\n\n return result\n\ndef power(x, y, p) :\n res = 1 # Initialize result\n \n # Update x if it is more\n # than or equal to p\n x = x % p \n \n while (y > 0) :\n \n # If y is odd, multiply\n # x with result\n if ((y & 1) == 1) :\n res = (res * x) % p\n \n # y must be even now\n y = y >> 1 # y = y/2\n x = (x * x) % p\n \n return res\n'''\nfor _ in xrange(int(raw_input())):\n\tl, d, t = map(int, raw_input().split())\n\tMOD = 1000000007\n\n\tif(t==1):\n\t\tprint d\n\t\tcontinue\n\t\n\tfib_matrix = [[2*d,l],[-l,0]]\n \t\n \tres = matrix_pow(fib_matrix, t-1, MOD)\n\tnum = modulo((d*res[0][0]-l*res[0][1]), MOD)\n\t\n\tdenom = power(l, t-1, MOD)\n\t\n\tk = gcd(num, denom)\n\tnum/=k\n\tdenom/=k\n\t\n\tnum = modulo(num, MOD)\n\tdenom = modInverse(denom, MOD)\n\tprint modulo(num*denom, MOD)\n'''\n\ndef inp(): return input()\n\ndef inpv(): return [float(x) for x in raw_input().split()]\n\ndef Hills():\n\tn = inp()\n\ts = raw_input()\n\tprint('Yes' if\n \t('??' in s or 'C?C' in s or 'M?M' in s or 'Y?Y' in s or s[0] == '?' or s[-1] == '?') and\n \tnot ('CC' in s or 'MM' in s or 'YY' in s)\n\telse 'No')\n\n\t\t\nHills()\n"}, {"source_code": "if __name__ == '__main__' :\n\tn = input()\n\ts = raw_input().strip()\n\tflag, i = 0, 0\n\twhile i < n-1 :\n\t\tif s[i] != \"?\" and s[i] == s[i+1] :\n\t\t\tflag = 1\n\t\t\tbreak\n\t\ti += 1\n\tif flag == 1 or s == \"C\" or s == \"Y\" or s == \"M\" or \"?\" not in s:\n\t\tprint \"No\"\n\telse :\n\t\ti = 0\n\t\tc = 0\n\t\tp = 0\n\t\tf = -1\n\t\twhile i <= n :\n\t\t\t#print s[i]\n\t\t\tif i < n and s[i] == \"?\" :\n\t\t\t\tc += 1\n\t\t\t\tp += 1\n\t\t\telse :\n\t\t\t\tif f < c :\n\t\t\t\t\tf = c\n\t\t\t\t#print c, f\n\t\t\t\tc = 0\n\t\t\t\t\n\t\t\ti += 1\n\t\t\n\t\tif f == 1 :\n\t\t\te = 0\n\t\t\tfor i in range (n) :\n\t\t\t\tif s[i] == \"?\" :\n\t\t\t\t\tif i-1 >= 0 and i+1 < n and s[i-1] != s[i+1]:\n\t\t\t\t\t\te += 1\n\t\t\tif e == p :\n\t\t\t\tprint \"No\"\n\t\t\telse :\n\t\t\t\tprint \"Yes\"\n\n\t\telse :\n\t\t\tprint \"Yes\"\n"}, {"source_code": "from functools import reduce\nN=int(input())\ncolors = input()\ndef compare(x, y):\n if x==False or x == y and ( x==\"C\" or x==\"M\" or x==\"Y\"):\n return False \n return y\n\n\ndef check_for(colors):\n if colors[0]==\"?\" or colors[-1]==\"?\":\n return True\n for i in range(1, len(colors)-1):\n if colors[i] == \"?\" and (colors[i-1] == colors[i+1] or colors[i+1] ==\"?\"):\n \n return True\n\n return False\n\ndef logic(colors):\n print(\"Yes\") if reduce(compare, colors) and check_for(colors) else print(\"No\")\n\nlogic(colors)\n"}, {"source_code": "a=int(input());b='!'+input()+'@';ans=1;i=1;ok=0\nwhile i<a+1:\n if b[i]!='?' and b[i+1]!='?' and b[i]==b[i+1]:ans=0\n s = 0\n if b[i] == '?':\n for j in 'CYM':\n if j != b[i - 1] and j != b[i + 1]: s += 1\n if s>1:ok=1\n i+=1\nif ans and ok:print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "n=input()\ns=raw_input()\nc='?'\nl=s.count(c)\nyes='Yes'\nno='No'\nif l==0:\n print no\n exit()\nfor i in range(1,n):\n if s[i]==s[i-1] and s[i]!=c:\n print no\n exit()\n\nif '??' in s:\n print yes\n exit()\nif s[0]==c or s[-1]==c:\n print yes\n exit()\nif ('M?M' in s ) or ('C?C' in s )or ('Y?Y' in s):\n print yes\n exit()\nprint no\n\n\n\n\n"}, {"source_code": "n = int(input())\nstring = input()\n\nindices = []\n\nfor i in range(n):\n if string[i] == '?':\n indices.append(i)\n\ncolors = ['C', 'Y', 'M']\n\ndef check_if_no():\n check = False\n for i in range(1, n):\n if string[i] == '?':\n continue \n if string[i] == string[i - 1]:\n check = True\n break\n return check \n\ndef boundary_check():\n if (0 in indices) or (len(string) - 1 in indices):\n return True\n return False\n\ndef adjacent_empty():\n check = False\n for i in range(1, len(indices)):\n if indices[i] - indices[i - 1] == 1:\n check = True\n break\n return check\n\ndef same_adjacent():\n check = False\n for i in indices:\n if string[i - 1] == string[i + 1]:\n check = True\n break\n return check\n\nif check_if_no():\n print(\"No\")\n\nelif boundary_check():\n print(\"Yes\")\n\nelif adjacent_empty():\n print(\"Yes\")\n\nelif same_adjacent():\n print(\"Yes\")\n\nelse:\n print(\"No\")"}, {"source_code": "n = int(raw_input())\ns = raw_input()\na = 1\nfor i in xrange(n-1):\n\tif s[i]<>'?' and s[i+1]<>'?' and s[i]==s[i+1]:\n\t\tprint 'No'\n\t\texit(0)\n\tif i>0:\n\t\tif s[i]=='?':\n\t\t\tif s[i-1]<>s[i+1] and s[i-1]<>'?' and s[i+1]<>'?':\n\t\t\t\ta=a*1\n\t\t\telse:\n\t\t\t\ta=a*2\nif s[0]=='?' or s[-1]=='?':\n\ta=a*2\nprint 'Yes' if a>1 else 'No'\n"}, {"source_code": "\n#k=int(input())\n#n,m=map(int,input().split())\nimport sys\n\n\n#a=list(map(int,input().split()))\n\n#b=list(map(int,input().split()))\nimport math\n\ndef YES():\n print(\"YES\")\n sys.exit()\n\n\ndef NO():\n print(\"NO\")\n sys.exit()\n\nn=int(input())\n\na=input()\n\n\nfor i in range(n-1):\n if a[i]==a[i+1] and a[i]!='?':\n print(\"NO\")\n sys.exit()\n\nfor i in range(n):\n if a[i]=='?':\n if i+1<n and a[i]=='?' and a[i+1]==a[i]:\n YES()\n\n if i==0 or i==n-1:\n YES()\n\n if i-1>=0 and i+1<n and a[i-1]==a[i+1]:\n YES()\n\nNO()\n\n\n\n\n\n\nprint(\"YES\" if (cnt>1 or q>1) else \"NO\")\n"}, {"source_code": "'''input\n9\nC??Y?Y?MM\n'''\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nimport sys\n\nn=input()\ns=raw_input().strip()\nans=\"Yes\"\n\nif ans==\"Yes\":\n ans=\"No\"\n if s[0]==\"?\" or s[-1]==\"?\":\n ans=\"Yes\"\n for i in range(1,n-1):\n if s[i]==\"?\":\n if s[i+1]==\"?\" or s[i-1]==\"?\":\n ans=\"Yes\"\n if s[i+1]==s[i-1]:\n ans=\"Yes\"\nfor i in range(n-1):\n if s[i]==s[i+1]:\n if s[i]!=\"?\" :\n ans=\"No\"\n\nprint ans"}, {"source_code": "t = input()\na = list(input())\ni=0\nmaxm =1\nn =len(a)\nwhile i<n:\n if a[i] == '?':\n if i == 0 or i == n-1:\n maxm = 2\n elif i+1<n:\n if a[i+1] == '?':\n maxm = 2\n elif i>=1:\n if a[i+1] == a[i-1] :\n maxm = 2\n elif i<n-1:\n if a[i] == a[i+1]:\n maxm =3\n break\n i = i+1\nif a[0]=='?' and n==1:\n maxm=2\nif maxm ==2:\n print('Yes')\nelse:\n print('No')\n \n"}, {"source_code": "# cook your code here\nuseless = raw_input()\ns = raw_input()\nif (('MM' in s) or ('CC' in s) or ('YY' in s)):\n print \"No\"\nelif ( ('??' in s) or ('M?M' in s) or ('C?C' in s) or ('Y?Y' in s) or (s[0] == '?') or (s[len(s)-1] == '?')):\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "\ndef process(a,n):\n for i in xrange(n-1):\n if (a[i]=='Y' and a[i+1]=='Y') or (a[i]=='M' and a[i+1]=='M') or (a[i]=='C' and a[i+1]=='C'): return 0 \n for i in xrange(n-1):\n if a[i]=='?' and a[i+1]=='?': return 1 \n if a[0]=='?' or a[n-1]=='?': return 1 \n for i in xrange(1,n-1):\n if a[i]=='?' and a[i-1]==a[i+1]: return 1 \n return 0 \n\nn= int(raw_input())\narr= str(raw_input())\nif process(arr,n): print \"Yes\"\nelse: print \"No\"\n"}, {"source_code": "n=input()\ns=raw_input()\nfor x in ['CC','YY','MM']:\n if x in s:\n print 'No'\n exit()\nif '??' in s or \"C?C\" in s or \"M?M\" in s or \"Y?Y\" in s or s[0] == '?' or s[-1] == '?':\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "n = input()\ns = raw_input()\nok = 1\nfor i in range(n):\n\tif i + 1 < n and s[i] == s[i+1] and s[i] != '?' and s[i+1] != '?':\n\t\tok = 0\n\t\tbreak\nif ok == 0:\n\tprint 'No'\nelse:\n\tok = 0\n\tfor i in range(n):\n\t\tif s[i] != '?':\n\t\t\tcontinue\n\t\tif i == 0:\n\t\t\tok = 1\n\t\telse:\n\t\t\tif i == n - 1:\n\t\t\t\tok = 1\n\t\t\telse:\n\t\t\t\tj = i\n\t\t\t\twhile j < n:\n\t\t\t\t\tif s[j] == '?':\n\t\t\t\t\t\tj = j + 1\n\t\t\t\t\telse:\n\t\t\t\t\t\tbreak\n\t\t\t\tj = j - 1\n\t\t\t\tif i == j:\n\t\t\t\t\tif s[i-1] == s[i+1]:\n\t\t\t\t\t\tok = 1\n\t\t\t\telse:\n\t\t\t\t\tok = 1\n\tif ok == 1:\n\t\tprint 'Yes'\n\telse:\n\t\tprint 'No'"}, {"source_code": "s = raw_input()\ns = raw_input()\nif 'MM' in s or 'CC' in s or 'YY' in s:\n print('No')\n exit(0)\nq = s.count('?')\nfor i in range(0, len(s)):\n if s[i] == '?':\n if i == 0 or i == len(s) - 1:\n print('Yes')\n exit(0)\n elif s[i - 1] != s[i + 1] and s[i - 1] != '?' and s[i + 1] != '?':\n q -= 1\n\nif q > 0:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "n = int(raw_input())\ns = raw_input()\ndup = False\ntwo = False\nif s[0] == '?' or s[-1] == '?':\n two = True\n\nfor i in range(1, len(s)):\n if s[i] != '?' and s[i-1] != '?' and s[i] == s[i-1]:\n dup = True\n if s[i] == '?' and s[i-1] == '?':\n two = True\n if i < len(s) - 1 and s[i] == '?' and s[i-1] != '?' and s[i+1] != '?' and s[i-1] == s[i+1]: \n two = True\n\nif dup:\n print \"No\"\nelif two:\n print \"Yes\"\nelse:\n print \"No\"\n"}, {"source_code": "n = input()\ns = raw_input()\nif 'CC' in s or 'MM' in s or 'YY' in s:\n\tprint \"No\"\nelif '??' in s or \"C?C\" in s or \"M?M\" in s or \"Y?Y\" in s or s[0] == '?' or s[-1] == '?':\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "n = int(input())\ns = input()\n\ndef f(s):\n for i in range(len(s) - 1):\n if s[i] != '?':\n if s[i] == s[i + 1]:\n return False\n for i in range(len(s)):\n if s[i] == '?':\n if i == 0 or i == len(s) - 1:\n return True\n else:\n if s[i + 1] == '?':\n return True\n if s[i - 1] == s[i + 1]:\n return True\n return False\n\nif f(s):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}], "negative_code": [{"source_code": "n = int(input())\ns = input()\nind = True\nind1 = False\ny = []\nfor i in s:\n\ty.append(i)\nfor i in range(n):\n\tif y[i] == \"?\":\n\t\tind1 = True\n\tif i > 0 and (y[i] == y[i - 1] and y[i] != \"?\"):\n\t\tind = False\n\t\tbreak\nif ind and ind1:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\t\n"}, {"source_code": "n=int(input())\ns=str(input())\nflag=0\nfor i in range(0,len(s)-1):\n if(s[i]==s[i+1] and s[i]!='?'):\n flag=1\nif(flag==1):\n print('')\nelif(flag==0):\n if(s[0]=='?' or s[-1]=='?'):\n print('YES')\n else:\n flags=0\n for j in range(0,len(s)):\n if(s[j]=='?'):\n d=set()\n if(s[j+1]!='?'):\n d.add(s[j+1])\n if(s[j-1]!='?'):\n d.add(s[j-1]) \n if(len(d)==1):\n print('YES')\n flags=1\n break\n if(flags==0):\n print('NO')"}, {"source_code": "\"\"\"\nUsage:\n python solution.py < input.txt > solution_output.txt\n\nTesting:\n pytest test_solution.py\n\nSubmit:\n Just copy and paste all the code or upload the whole file\n\"\"\"\nfrom itertools import product\n\n\ndef get_input_list() -> str:\n \"\"\"\n Loops throw the stdio to fetch input data\n Generally used on problems with 'n' inputs\n\n Returns:\n raw_input_data: The input of a problem\n \"\"\"\n canvas_lenght = input()\n canvas_caracters = input()\n \n return canvas_lenght, canvas_caracters\n \n\ndef get_input() -> str:\n \"\"\"\n Fetch input data from stdio\n Generally used on problems with discrete inputs\n Returns:\n raw_input_data: The input of a problem\n \"\"\"\n raw_input_data = \"\"\n raw_input_data += input()\n return raw_input_data\n\n\ndef solve(raw_input_data: str):\n \"\"\"\n Here you solve the problem, happy coding!!\n Args:\n raw_input_data: the data you test the solution\n\n Returns:\n answer: the solution of the problem\n \"\"\"\n chars, word = raw_input_data\n chars = int(chars)\n\n yes = False\n\n for i in range(1, chars):\n if word[i] != '?' and word[i] == word[i - 1]:\n return 'No'\n elif word[i] == '?':\n if i + 1 < chars and word[i - 1] == word[i + 1]:\n yes = True\n elif word[i - 1] == '?':\n yes = True\n elif i + 1 < chars and word[i + 1] == '?':\n yes = True\n if yes:\n return 'Yes'\n return 'No'\n \n\nif __name__ == \"__main__\":\n \n while True:\n try:\n # Use this with simple inputs\n # input_data = get_input()\n \n # Use this with the problem have many inputs\n input_data = get_input_list()\n \n answer = solve(input_data)\n print(answer, end=\"\\n\")\n except:\n break\n"}, {"source_code": "x = int(input())\nmyStr = input()\n\ndef func(myStr):\n\tchoice = 0\n\tn = len(myStr)\n\tfor i, c in enumerate(myStr):\n\t\tif c != '?':\n\t\t\tif i + 1 < n:\n\t\t\t\tif c == myStr[i + 1]:\n\t\t\t\t\treturn False\n\t\t\t\t\tbreak\n\t\telif c == '?' and choice < 2:\n\t\t\tif i + 1 < n:\n\t\t\t\tif c == myStr[i + 1]:\n\t\t\t\t\tchoice += 2\n\t\t\t\telse:\n\t\t\t\t\tif i - 1 < 0 :\n\t\t\t\t\t\tchoice += 2\n\t\t\t\t\telse:\n\t\t\t\t\t\tif myStr[i - 1] == myStr[i + 1]:\n\t\t\t\t\t\t\tchoice += 2\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\tchoice += 1\n\t\t\telse:\n\t\t\t\tchoice += 2\n\t\t\n\t\n\tif choice >= 2:\n\t\treturn True\n\telse:\n\t\treturn False\n\nz = func(myStr)\nif z == True:\n\tprint('Yes')\nelse:\n\tprint('No')"}, {"source_code": "a = ['M?Y', 'M?C', 'C?Y', 'C?M', 'Y?M', 'Y?C']\nb = ['MM', 'CC', 'YY']\ninput()\ns = input()\nres = 'Yes'\nif s.count('?') == 1:\n for i in a:\n if s.find(i) > -1:\n res = 'No'\n break\nfor i in b:\n if s.find(i) > -1:\n res = 'NO'\n break\nprint(res)"}, {"source_code": "from sys import stdin\n\nlines = stdin.readlines()\nn = int(lines[0])\ns = lines[1].split()[0]\na = True\nb = True\nsumm = 0\nif \"?\" not in s:\n print \"No\"\n a = False\n b = False\nif b:\n for i in range(n-1):\n \n if s[i] == s[i+1] and s[i] != \"?\":\n print \"No\"\n a = False\n break\n elif s[i] == \"?\" and i>0 and (s[i-1] != s[i+1]):\n summ += 1\n elif s[i] == \"?\":\n summ += 1\n\nif a == True and summ > 1:\n print \"Yes\"\nelif summ == 1:\n print \"No\""}, {"source_code": "n=int(input())\ns=str(input())\nflag=0\nfor i in range(0,len(s)-1):\n if(s[i]==s[i+1] and s[i]!='?'):\n flag=1\nif(flag==1):\n print('')\nelif(flag==0):\n if(s[0]=='?' or s[-1]=='?'):\n print('YES')\n else:\n flags=0\n for j in range(0,len(s)):\n if(s[j]=='?'):\n d=set()\n if(s[j+1]!='?'):\n d.add(s[j+1])\n if(s[j-1]!='?'):\n d.add(s[j-1]) \n if(len(d)==1):\n print('YES')\n flags=1\n break\n if(flags==0):\n print('NO')"}, {"source_code": "n = int(input())\ns = 'T' + input() + 'T'\nres = 'Yes'\nflex = False\nfor i in range(1, n+1):\n if not flex and s[i] == '?':\n if s[i-1] == '?' or s[i+1] == '?':\n flex = True\n elif s[i-1] == s[i+1]:\n flex = True\n if s[i] != '?' and s[i] == s[i-1]:\n res = 'No'\n break\nif res == 'Yes' and not flex:\n res = 'No'\nprint(res)\n"}, {"source_code": "n=int(input())\nfor _ in range(1):\n s=input().rstrip()\n f1=True\n fl1=False\n for i in range(1,len(s)):\n if s[i] is not \"?\" and s[i] is s[i-1]: \n f1=False\n break\n if f1:\n #print(\"abc\")\n if s[0] is \"?\" or s[len(s)-1] is \"?\":\n print(\"Yes\")\n fl1=False\n elif s.count(\"?\")==0:\n print(\"Yes\")\n fl1=False\n else:\n f=False\n last=-1 \n for i in range(len(s)):\n if s[i] is \"?\":\n if not f:\n last=i\n f=True\n else:\n if f:\n l=i-last\n if l>1:\n print(\"Yes\")\n fl1=False\n break\n else:\n if s[last-1] is s[i]:\n print(\"Yes\")\n fl1=False\n break\n else:\n fl1=True\n #print(\"No\")\n #break\n f=False\n \n \n else:\n print(\"No\")\n \n if fl1:\n print(\"No\")"}, {"source_code": "n=input()\nst=str(raw_input())\nc=0\npp=0\nans=0\nfor i in range(0,len(st)-1):\n if st[i]==\"?\" and st[i+1]==\"?\":\n pp=1\nfor i in range(1,len(st)-1):\n if st[i]==\"?\":\n if st[i-1]==st[i+1]:\n c=c+1\n vl=i\n elif i<len(st)-1 and st[i]==st[i+1]:\n ans=-1\nif st[0]==\"?\" or st[n-1]==\"?\" or pp==1:\n print \"yes\"\n\nelif ans==-1:\n print \"no\"\nelse: \n if c>=2 :\n ans=1 \n if c==1:\n if vl==0 or vl==n-1:\n ans=1 \n elif st[vl-1]==st[vl+1]:\n ans=1 \n if ans==1:\n print \"yes\"\n else:\n print \"no\"\n \n \n "}, {"source_code": "n=int(input())\ncolor = input()\nc=False\nq=color.count(\"?\")\n\nprint(q)\n\n\nif q<2:\n\tprint(\"No\")\nfor i in range(n):\n\tj=i+1\n\tif color[i]==color[j]:\n\t\tC = True\n\t\tbreak\nif q<2 or C:\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")\n\n"}, {"source_code": "import sys\ns = input()\ns = '*' + s\ns += '#'\nfor i in range(1, len(s) - 1):\n if (s[i] == '?'):\n if ((s[i - 1] == s[i + 1]) == False or s[i - 1] == '?' or s[i + 1] == '?'):\n print(\"Yes\")\n sys.exit(0)\nprint('No')"}, {"source_code": "n=int(input())\nch=input()\nif ch.count('?')==0:\n print('NO')\nelse:\n if 'CC' in ch:\n print('NO')\n \n elif 'MM' in ch:\n print('NO')\n elif 'YY' in ch:\n print('NO')\n elif ('M?M' in ch ) or ('C?C' in ch) or ('Y?Y' in ch):\n print('YES')\n elif ('C?Y' in ch) and ('C?Y?Y' not in ch) and ('C?C?Y' not in ch):\n print('NO')\n elif ('C?M' in ch) and ('C?M?M' not in ch) and ('C?C?M' not in ch):\n print('NO')\n elif ('M?C' in ch) and ('M?C?C' not in ch) and ('M?M?C' not in ch):\n print('NO')\n elif ('M?Y' in ch) and ('M?Y?Y' not in ch) and ('M?M?Y' in ch):\n print('NO')\n elif ('Y?C' in ch) and ('Y?C?C' not in ch) and ('Y?Y?C' in ch):\n print('NO')\n elif ('Y?M' in ch) and ('Y?M?M' not in ch) and ('Y?Y?M' in ch):\n print('NO')\n else:\n print('YES')\n"}, {"source_code": "n = int(input())\ns = input()\nq = 0\nfor i in range(1,n-1):\n if s[i] != '?':\n if s[i] == s[i+1] or s[i] == s[i-1]:\n print(\"NO\")\n exit()\n else:\n q += 1\nif q == 0:\n print(\"NO\")\n exit()\nfound = False\nfor i in range(n):\n if s[i] == '?':\n if i == 0 or i == n-1: found = True\n elif s[i-1] == '?' or s[i+1] == '?': found = True\n elif s[i-1] == s[i+1]: found = True\n\nif(found):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# cook your dish here\nfrom sys import stdin,stdout\nfrom collections import Counter\nfrom itertools import permutations\nimport bisect\nimport math\nI=lambda: map(int,stdin.readline().split())\nI1=lambda: stdin.readline()\n\nn=int(I1())\ns=I1().strip()\ni,f=0,0\nfor j in range(1,n):\n if s[j]==s[j-1]:\n print('No')\n exit()\nwhile i<n:\n if s[0]=='?' or s[n-1]=='?':\n f=1 \n break\n elif s[i]=='?':\n j=i+1 \n while s[j]=='?':j+=1 \n if(s[i-1]==s[j]):\n f=1 \n break\n i+=1 \nif f==1: print(\"Yes\")\nelse : print(\"No\")\n "}, {"source_code": "# cook your dish here\nfrom sys import stdin,stdout\nfrom collections import Counter\nfrom itertools import permutations\nimport bisect\nimport math\nI=lambda: map(int,stdin.readline().split())\nI1=lambda: stdin.readline()\n\nn=int(I1())\ns=I1().strip()\ni,f=0,0\nfor j in range(1,n):\n if s[j]==s[j-1] and s[j]!='?':\n print('No')\n exit()\nwhile i<n:\n if s[0]=='?' or s[n-1]=='?':\n f=1 \n break\n elif s[i]=='?':\n j=i+1 \n while s[j]=='?':j+=1 \n if(s[i-1]==s[j]):\n f=1 \n break\n i+=1 \nif f==1: print(\"Yes\")\nelse : print(\"No\")\n "}, {"source_code": "t = int(input())\nstr = list(input())\nlstr = len(str)\n\nif '?' not in str:\n print(\"No\")\n exit()\n\nsw2 = 0\nif lstr == 1:\n print(\"Yes\")\n exit()\nif lstr == 2 and str[0] != str[1]:\n print(\"Yes\")\n exit()\nif lstr == 3 and str[1] == '?' and str[0] != str[2]:\n print(\"No\")\n exit()\nif lstr == 3 and (str[0] != str[1] and str[1] != str[2]):\n print(\"Yes\")\n exit()\n\n\nfor i in range(lstr):\n if str[i] != '?': \n if i != 0 and i != lstr - 1:\n if str[i] == str[i-1] or str[i] == str[i+1]:\n print(\"No\")\n exit()\n elif i == 0 and lstr != 1:\n if str[i] == str[i+1]:\n print(\"No\")\n exit()\n else:\n if str[i] == str[i-1]:\n print(\"No\")\n exit()\n\n else:\n if i != 0 and i != lstr - 1:\n if str[i-1] != str[i+1]:\n sw2 = 1\n else:\n sw2 = 1\n\n\nif sw2:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n \n\n"}, {"source_code": "def is_available(picture):\n \"\"\"\n :param picture: str\n :return: bool\n \"\"\"\n for i, color in enumerate(picture):\n if i == 0 or color == '?':\n continue\n\n if color == picture[i - 1]:\n return False\n\n return True\n\n\nn = int(input())\npicture = input().strip()[:n]\nprint('Yes' if is_available(picture) else 'No')\n"}, {"source_code": "n = int(input())\ns = input()\nif s == '?' * n:\n print('YES')\nelse:\n for i in range(n - 1):\n if s[i] == s[i + 1] != '?':\n print('NO')\n break\n else:\n flag = False\n a = 0\n for i in range(n):\n if s[i] == '?':\n if i != 0:\n b = s[i - 1]\n else:\n b = 'gg'\n a += 1\n else:\n c = s[i]\n if a != 0:\n if b == 'gg' or b == c or b != c and a % 2 == 0:\n print('YES')\n break\n a = 0\n else:\n c = s[i]\n if a != 0:\n if b == c or b != c and a % 2 == 0:\n print('YES')\n else:\n print('NO')\n else:\n print('NO')"}, {"source_code": "n=int(input())\nAr=input()\nif Ar.find(\"MM\")!=-1:\n print(\"NO\")\nelif Ar.find(\"YY\")!=-1:\n print(\"NO\")\nelif Ar.find(\"CC\")!=-1:\n print(\"NO\")\nelif Ar[0]=='?' or Ar[-1]=='?':\n print(\"YES\")\nelif Ar.find(\"???\")!=-1:\n print(\"YES\")\nelse:\n C=Ar.count('?')\n cnt=0\n for i in range(1,n-1):\n if Ar[i]=='?' and (Ar[i-1]=='C' and Ar[i+1]=='C') or (Ar[i-1]=='Y' and Ar[i+1]=='Y') or (Ar[i-1]=='M' and Ar[i+1]=='M'):\n cnt+=1\n break\n l=Ar.find(\"??\")\n while(l!=-1):\n if Ar[l-1]==Ar[l+2]:\n cnt+=2\n l=Ar.find(\"??\",l+2)\n if cnt>0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "# cook your dish here\nfrom sys import stdin,stdout\nfrom collections import Counter\nfrom itertools import permutations\nimport bisect\nimport math\nI=lambda: map(int,stdin.readline().split())\nI1=lambda: stdin.readline()\n\nn=int(I1())\ns=I1().strip()\ni,f=0,0\nfor j in range(1,n):\n if s[j]==s[j-1] and s[i]!='?':\n print('No')\n exit()\nwhile i<n:\n if s[0]=='?' or s[n-1]=='?':\n f=1 \n break\n elif s[i]=='?':\n j=i+1 \n while s[j]=='?':j+=1 \n if(s[i-1]==s[j]):\n f=1 \n break\n i+=1 \nif f==1: print(\"Yes\")\nelse : print(\"No\")\n "}, {"source_code": "n = int(input())\ns = input()\nflag=0\nfor i in range(n):\n if i==0:\n if s[0] == '?':\n flag=1\n break\n elif i==n-1:\n if s[n-1] == '?':\n flag=1\n break\n else:\n if s[i] == '?':\n if s[i-1] == s[i+1]:\n flag=1\n break\nfor i in range(n-1):\n if s[i] == s[i+1] and s[i] != '?':\n flag=0\nif flag==0:\n print('No')\nelse:\n print('Yes')"}, {"source_code": "n = int(input())\n\nmural = input()\n\nquestions = mural.count('?')\n\nif questions < 2:\n print(\"No\")\n\nelif questions > 2:\n print(\"Yes\")\n\nelse:\n idx = mural.find('??')\n if idx == -1:\n print(\"Yes\")\n\n else:\n if idx == 0 or idx == n-2 or mural[idx-1] == mural[idx+2]:\n print(\"Yes\")\n else:\n print(\"No\")\n"}, {"source_code": "def main():\n n=input()\n l=map(str,\" \".join(raw_input()).split())\n for i in xrange(1,n):\n if l[i]==l[i-1] and l[i]!='?':\n print \"No\"\n exit()\n for i in xrange(2,n):\n if l[i-1]=='?' and l[i]!=l[i-2]:\n print \"No\"\n exit()\n \n print \"Yes\"\n \nmain()"}, {"source_code": "n1 = input()\nn = int(n1)\ns = []\nflag = False\nsc = input()\nfor i in range(n):\n s.append(sc[i])\n if i > 0:\n if s[i] == s[i-1] and s[i] != '?':\n flag = False\n break\n\nif flag == False:\n print('NO')\n exit()\nfor i in range(n):\n if s[i] == '?':\n if i == 0 or i == n-1:\n flag = True\n break\n elif s[i-1] == s[i+1]:\n flag = True\n break\nif flag:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\nn=int(input())\ns=raw_input()\nfor i in xrange(len(s)-1):\n if s[i+1]==s[i] and s[i]!=\"?\":\n print\"No\"\n sys.exit()\nl=[]\nfor i in xrange(len(s)):\n if s[i]==\"?\":\n l.append(i)\nfor i in l:\n if i!=0 and i!=n-1:\n if s[i+1]!=s[i-1] and s[i+1]!=\"?\" and s[i-1]!=\"?\":\n if len(l)==1:\n print\"No\"\n sys.exit()\nprint\"Yes\""}, {"source_code": "n = int(input())\ns = input()\n\n# Case where we can't use two coloring :\n# 1) no \"?\" present\n# 2) X?Y Case\n# 3) X??X S'il existe des suites\n\nans = \"Yes\"\nno_int = s.count(\"?\")\n\n\ndef is_cool(s):\n if s.count(\"??\"):\n return True\n else:\n a = s.count(\"C?C\") + s.count(\"M?M\") + s.count(\"Y?Y\")\n return a > 0\n\n\nok = (s.count(\"MM\") + s.count(\"CC\") + s.count(\"YY\")) == 0\n# print(\"ok : \", ok)\n\nif n == 1:\n if s == \"?\":\n ans = \"Yes\"\n else:\n ans = \"No\"\nelse:\n\n if not (ok):\n ans = \"No\"\n elif no_int == 0:\n ans = \"Yes\"\n elif s[0] == \"?\" or s[-1] == \"?\":\n ans = \"Yes\"\n elif s.count(\"M?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"M?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"C?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"C?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"Y?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n elif s.count(\"Y?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n\nprint(ans)\n"}, {"source_code": "def main():\n n=input()\n l=map(str,\" \".join(raw_input()).split())\n for i in xrange(1,n):\n if l[i]==l[i-1] and l[i]!='?':\n print \"No\"\n exit()\n if l.count('?')==1:\n for i in xrange(2,n):\n if l[i-1]=='?' and l[i]!=l[i-2] and (l[i]!='?' and l[i-2]!='?'):\n print \"No\"\n exit()\n \n print \"Yes\"\n \nmain()"}, {"source_code": "x=int(input())\nstring=input()\ni=0\ncounter=0\nright=-1\nleft=0\nif string.count('MM')>=1 or string.count('CC')>=1 or string.count('YY')>=1:\n print(\"NO\")\nelse:\n while i<x:\n right=string[i+1]\n if i==0 and string[i]!='?':\n left=string[i]\n i+=1\n continue\n elif i==x-1:\n if string[-1]=='?':\n counter+=2\n break\n if string[i]=='?':\n if left==right:\n counter+=1\n else:\n counter+=2\n break\n if string[i+1]=='?':\n pass\n else:\n left=string[i+1]\n else:\n left=string[i]\n i+=1\n if counter>=2:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=int(input())\ns=str(input())\nflag=0\nfor i in range(0,len(s)-1):\n if(s[i]==s[i+1] and s[i]!='?'):\n flag=1\nif(flag==1):\n print('')\nelif(flag==0):\n if(s[0]=='?' or s[-1]=='?'):\n print('YES')\n else:\n flags=0\n for j in range(0,len(s)):\n if(s[j]=='?'):\n d=set()\n if(s[j+1]!='?'):\n d.add(s[j+1])\n if(s[j-1]!='?'):\n d.add(s[j-1]) \n if(len(d)==1):\n print('YES')\n flags=1\n break\n if(flags==0):\n print('NO')"}, {"source_code": "n=int(input())\nfor _ in range(1):\n s=input().rstrip()\n f1=True\n fl1=False\n for i in range(1,len(s)):\n if s[i] is not \"?\" and s[i] is s[i-1]: \n f1=False\n break\n if f1:\n #print(\"abc\")\n if s[0] is \"?\" or s[len(s)-1] is \"?\":\n print(\"Yes\")\n fl1=False\n elif s.count(\"?\")==0:\n print(\"Yes\")\n fl1=False\n else:\n f=False\n last=-1 \n for i in range(len(s)):\n if s[i] is \"?\":\n if not f:\n last=i\n f=True\n else:\n if f:\n l=i-last\n if l>1:\n print(\"Yes\")\n fl1=False\n break\n else:\n if s[last-1] is s[i]:\n print(\"Yes\")\n fl1=False\n break\n else:\n fl1=True\n #print(\"No\")\n #break\n f=False\n \n \n else:\n print(\"No\")\n \n if fl1:\n print(\"No\")"}, {"source_code": "'''input\n5\nC??MM\n'''\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nimport sys\n\nn=input()\ns=raw_input().strip()\nans=\"Yes\"\nfor i in range(1,n-2):\n if s[i]==\"?\"and s[i+1]==\"?\":\n if s[i-1]!=\"?\" and s[i+2]!=\"?\" and s[i-1]!=s[i+2]:\n ans=\"No\" \n \nprint ans"}, {"source_code": "from __future__ import division\nfrom sys import stdin, stdout\n# from fractions import gcd\n# from math import *\n# from operator import mul\n# from functools import reduce\n# from copy import copy\nfrom collections import deque, defaultdict, Counter\n\nrstr = lambda: stdin.readline().strip()\nrstrs = lambda: [str(x) for x in stdin.readline().split()]\nrint = lambda: int(stdin.readline())\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrstr_2d = lambda n: [rstr() for _ in range(n)]\nrint_2d = lambda n: [rint() for _ in range(n)]\nrints_2d = lambda n: [rints() for _ in range(n)]\npr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\\n')\nout = []\n\nn, s, cur, ans = int(input()), rstr(), 0, 'YES'\nif '?' in s:\n valid = 0\n for i in range(n):\n if s[i] == '?':\n cur += 1\n else:\n if i and s[i] == s[i - 1] and not cur:\n valid = 0\n break\n\n if cur > 1 or i == cur or s[i] == s[i - 2]:\n valid += 1\n\n cur = 0\n\n print('YES' if valid or cur else 'NO')\nelse:\n for i in range(1, n):\n if s[i] == s[i - 1]:\n print('NO')\n exit()\n\n print('YES')\n"}, {"source_code": "from __future__ import division\nfrom sys import stdin, stdout\n# from fractions import gcd\n# from math import *\n# from operator import mul\n# from functools import reduce\n# from copy import copy\nfrom collections import deque, defaultdict, Counter\n\nrstr = lambda: stdin.readline().strip()\nrstrs = lambda: [str(x) for x in stdin.readline().split()]\nrint = lambda: int(stdin.readline())\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrstr_2d = lambda n: [rstr() for _ in range(n)]\nrint_2d = lambda n: [rint() for _ in range(n)]\nrints_2d = lambda n: [rints() for _ in range(n)]\npr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\\n')\nout = []\n\nn, s, cur, ans = int(input()), rstr(), 0, 'YES'\nfor i in range(n):\n if s[i] == '?':\n cur += 1\n else:\n if cur == 1 and s[i] != s[i - 2]:\n ans = 'NO'\n break\n cur = 0\n\nprint(ans)\n"}, {"source_code": "n= int(input())\ns= input()\ns= '0'+ s + '0'\nres=0\nf=0\nfor i in range(len(s)-1):\n if s[i]!=\"?\" and s[i]== s[i+1]:\n print(\"No\")\n f=1\n exit(0)\n elif s[i]==\"?\" and s[i]== s[i+1]:\n print(\"Yes\")\n f=1\n exit(0)\nfor i in range(1,len(s)-1):\n if s[i]==\"?\":\n a= s[i-1]\n b= s[i+1]\n if (a=='C' and b=='C') or (a=='M' and b=='M') or (a=='Y' and b=='Y') or (a=='0' and b=='Y') or (a=='0' and b=='C') or (a=='0' and b=='M') or (a=='Y' and b=='0') or (a=='M' and b=='0') or (a=='C' and b=='0'):\n res+=2\n print(\"Yes\")\n f=1\n exit(0)\n elif (a=='Y' and b=='M') or (a=='M' and b=='Y') or (a=='Y' and b=='C') or (a=='C' and b=='Y') or (a=='C' and b=='M') or (a=='M' and b=='C'):\n res+= 1\n if res==2:\n print(\"Yes\")\n f=1\n exit(0)\n \nif f==0:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\ns=raw_input()\n\ndef solve(s):\n if \"?\" not in s:\n for i in range(1,n-1):\n if s[i]==s[i-1] or s[i]==s[i+1]:\n return \"No\"\n return \"Yes\"\n\n else:\n for i in range(1,n-1):\n if (s[i]==s[i-1] or s[i]==s[i+1]) and s[i]!=\"?\":\n return \"No\"\n\n\n for i in range(1,n-1):\n if s[i]==\"?\" and s[i+1]==\"?\":\n if s[i-1]!=\"?\":\n if i+2<=n-1:\n if s[i+2]!=\"?\":\n if s[i-1]!=s[i+2]:\n return \"No\"\n\n count=0\n for i in range(1,n-1):\n if s[i]==\"?\":\n if s[i-1]!=\"?\" and s[i+1]!=\"?\" and s[i-1]!=s[i+1]:\n count+=1\n if count==s.count(\"?\"):\n return \"No\"\n return \"Yes\"\nprint(solve(s))\n"}, {"source_code": "i=input;i();z=i()\nprint('Yes'if('??'in z or'Y?Y'in z or'Z?Z'in z or'M?M'in z)and not('CC'in z or'MM'in z or'YY'in z)else'No')"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(1, n):\n\tif s[i] == s[i - 1] and s[i] != '?':\n\t\tprint(\"no\")\n\t\tquit()\n\tif s[i] == '?':\n\t\tif i != n - 1 and s[i - 1] != s[i + 1] and s[i - 1] != '?' and s[i + 1] != '?':\n\t\t\tprint(\"no\")\n\t\t\tquit()\nprint(\"yes\")\n"}, {"source_code": "def main():\n n=input()\n l=map(str,\" \".join(raw_input()).split())\n for i in xrange(1,n):\n if l[i]==l[i-1] and l[i]!='?':\n print \"No\"\n exit()\n for i in xrange(4,n):\n if l[i-1]=='?' and l[i-3]==l[i-1] and l[i-4]==l[i] and l[i-2]!=l[i] and l[i]!='?' and l[i-2]!='?':\n print \"No\"\n exit()\n \n print \"Yes\"\n \nmain()"}, {"source_code": "from sys import stdin\n\nlines = stdin.readlines()\nn = int(lines[0])\ns = lines[1].split()[0]\na = True\nb = True\nsumm = 0\nif \"?\" not in s:\n print \"No\"\n a = False\n b = False\nif b:\n for i in range(n-1):\n \n if s[i] == s[i+1] and s[i] != \"?\":\n print \"No\"\n a = False\n break\n elif s[i] == \"?\" and i>0 and (s[i-1] != s[i+1]):\n summ += 1\n elif s[i] == \"?\":\n summ += 1\nif s[-1] == \"?\":\n summ += 1\nif a == True and summ > 1:\n print \"Yes\"\nelif summ == 1:\n print \"No\""}, {"source_code": "\nn = int(input())\na = list(input())\nt=0\ng =a.count(\"?\")\nif g==0:\n\tprint(\"No\")\n\texit()\n\nfor i in range(n-1):\n\tj = i+1\n\tif (a[i]==a[j] and a[i]!=\"?\") :\n\t\tprint(\"No\")\n\t\texit()\nfor i in range(1,n-2):\n\tif a[i-1]!=a[i+1] and a[i]==\"?\" and (a[i-1]!=\"?\" and a[i+1]!=\"?\" ):\n\t\tt+=1\n\t\t\nif t<g and t!=0:\n\tprint(\"no\")\n\texit()\nprint(\"Yes\")\n\t\t"}, {"source_code": "from functools import reduce\nN=int(input())\ncolors = input()\ndef compare(x, y):\n if x==False or x == y and ( x==\"C\" or x==\"M\" or x==\"Y\"):\n return False \n return y\n\ndef check_for_doublees(colors):\n if colors[0]==\"?\" or colors[-1]==\"?\":\n return True\n for i in range(1, len(colors)-1):\n if colors[i] == \"?\" and colors[i-1] != colors[i+1]:\n return True\n\n return True\n\ndef logic(colors):\n print(\"Yes\") if reduce(compare, colors) and check_for_doublees(colors) else print(\"No\")\n\nlogic(colors)\n"}, {"source_code": "from sys import stdin\n\nlines = stdin.readlines()\nn = int(lines[0])\ns = lines[1].split()[0]\na = True\nsumm = 0\nfor i in range(n-1):\n if summ > 1:\n print \"No\"\n a = False\n break\n elif s[i] == s[i+1] and s[i] != \"?\":\n print \"No\"\n a = False\n break\n elif s[i] == \"?\" and i>0 and (s[i-1] != s[i+1]):\n summ += 1\n elif s[i] == \"?\":\n summ += 1\n\nif a == True:\n print \"Yes\"\n \n "}, {"source_code": "def f(s,n):\n if s[0] == '?' or s[-1] == '?':\n return ('Yes')\n for i in range(1,n-1):\n if s[i] == '?':\n if s[i-1] == s[i+1] or s[i-1] == '?' or s[i+1] == '?':\n return 'Yes'\n return 'No'\n\nn = int(input())\ns = input()\nprint(f(s,n))"}, {"source_code": "n=int(input())\ns=input()\nf=1 \nfor i in range(n-1):\n if s[i]==s[i+1] and s[i]!='?' and s[i+1]!='?':\n f=0\n break \nif f==0:\n print('No')\nelse:\n ms=set()\n if '??' in s:\n print('Yes')\n elif '?' not in s:\n print('Yes')\n else:\n f=0\n for i in range(1,n-1):\n if s[i]=='?': \n a,b=s[i-1],s[i+1]\n if a==b:\n f=1 \n if n<=2:\n print('Yes')\n elif '?' not in s[1:n-1]:\n print('Yes')\n elif f==0:\n print('No')\n \n else:\n print('Yes')\n"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n-1):\n if s[i]==s[i+1]:\n print(\"NO\")\n quit()\nprint(\"YES\")"}, {"source_code": "n=int(input())\nAr=input()\nif Ar[0]=='?' or Ar[-1]=='?':\n print(\"YES\")\nelif Ar.find(\"???\")!=-1:\n print(\"YES\")\nelse:\n C=Ar.count('?')\n cnt=0\n for i in range(1,n-1):\n if Ar[i]=='?' and (Ar[i-1]=='C' and Ar[i+1]=='C') or (Ar[i-1]=='Y' and Ar[i+1]=='Y') or (Ar[i-1]=='M' and Ar[i+1]=='M'):\n cnt+=1\n break\n l=Ar.find(\"??\")\n while(l!=-1):\n if Ar[l-1]==Ar[l+2]:\n cnt+=2\n l=Ar.find(\"??\",l+2)\n if cnt>0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "from functools import reduce\nN=int(input())\ncolors = input()\ndef compare(x, y):\n if x==False or x == y and ( x==\"C\" or x==\"M\" or x==\"Y\"):\n return False \n return y\n\ndef check_for_doublees(colors):\n if colors[0]==\"?\" or colors[-1]==\"?\":\n return True\n for i in range(1, len(colors)-1):\n if colors[i] == \"?\" and colors[i-1] != colors[i+1]:\n return False\n\n return True\n\ndef logic(colors):\n print(\"Yes\") if reduce(compare, colors) and check_for_doublees(colors) else print(\"No\")\n\nlogic(colors)\n"}, {"source_code": "#Abhigyan Khaund - syl\n# t = int(raw_input())\n# while t:\n# \tt-=1\n# \tm = map(int, raw_input().split())\n\nn = int(raw_input())\nv = raw_input()\nyes = 1\nfor i in range(1,n):\n\tif(v[i]==v[i-1] and v[i]!='?'):\n\t\tyes = 0\n\t\tbreak\nif(yes):\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "from sys import stdin\n\nlines = stdin.readlines()\nn = int(lines[0])\ns = lines[1].split()[0]\na = True\nsumm = 0\nif \"?\" not in s:\n print \"No\"\n a = False\n\nfor i in range(n-1):\n if summ > 1:\n print \"No\"\n a = False\n break\n elif s[i] == s[i+1] and s[i] != \"?\":\n print \"No\"\n a = False\n break\n elif s[i] == \"?\" and i>0 and (s[i-1] != s[i+1]):\n summ += 1\n elif s[i] == \"?\":\n summ += 1\n\nif a == True:\n print \"Yes\"\n \n \n \n \n \n "}, {"source_code": "n = int(input())\ns = input()\nflag = False\nif s == '?':\n print('YES')\nelse:\n for i in range(n - 1):\n if s[i] == s[i + 1] != '?':\n print('NO')\n break\n if s[i] == '?':\n flag = True\n else:\n if not flag:\n print('NO')\n else:\n print('YES')"}, {"source_code": "t = int(input())\nstr = list(input())\nlstr = len(str)\nsw2 = 0\n\nif lstr == 1:\n print(\"Yes\")\n exit()\nif lstr == 2 and str[0] != str[1]:\n print(\"Yes\")\n exit()\n\nfor i in range(lstr):\n if str[i] != '?': \n if i != 0 and i != lstr - 1:\n if str[i] == str[i-1] or str[i] == str[i+1]:\n print(\"No\")\n exit()\n elif i == 0 and lstr != 1:\n if str[i] == str[i+1]:\n print(\"No\")\n exit()\n else:\n if str[i] == str[i-1]:\n print(\"No\")\n exit()\n\n else:\n if i != 0 and i != lstr - 1:\n if str[i-1] != str[i+1]:\n sw2 = 1\n else:\n sw2 = 1\n\n\nif sw2:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n \n\n"}, {"source_code": "n = int(input())\ns = input()\nif s.count('MM') > 0 or s.count('CC') > 0 or s.count('YY') > 0:\n print('No')\nelse:\n if s.count('??') > 0 or s[0] == '?' or s[-1] == '?':\n print('Yes')\n else:\n for i in range(1, n - 1):\n if s[i] == '?':\n if s[i - 1] == s[i + 1]:\n print('Yes')\n exit()\n if i == n - 2:\n print('No')\n"}, {"source_code": "n=int(input())\ns=input()\nf=1 \nfor i in range(n-1):\n if s[i]==s[i+1] and s[i]!='?' and s[i+1]!='?':\n f=0\n break \nif f==0:\n print('No')\nelse:\n ms=set()\n if '??' in s:\n print('Yes')\n elif '?' not in s:\n print('Yes')\n else:\n if s[0]=='?' or s[-1]=='?':\n print('Yes')\n if 'C?C' in s:\n print('Yes')\n elif 'M?M' in s:\n print('Yes')\n elif 'Y?Y' in s:\n print('Yes')\n else:\n print('No')\n "}, {"source_code": "n=int(input())\ns=input()\nf=1 \nfor i in range(n-1):\n if s[i]==s[i+1] and s[i]!='?' and s[i+1]=='?' and s[i]!='?':\n f=0\n break \nif f==0:\n print('No')\nelse:\n ms=set()\n if '??' in s:\n print('Yes')\n if '?' not in s:\n print('Yes')\n else:\n f=0\n for i in range(1,n-1):\n if s[i]=='?': \n a,b=s[i-1],s[i+1]\n if a==b:\n f=1 \n if f==0:\n print('No')\n \n else:\n \n print('Yes')\n"}, {"source_code": "n=int(input())\nch=input()\nif ch.count('?')==0:\n print('NO')\nelse:\n if 'CC' in ch:\n print('NO')\n elif 'MM' in ch:\n print('NO')\n elif 'YY' in ch:\n print('NO')\n elif ('C?Y?' in ch) and ('C?Y?Y' not in ch):\n print('NO')\n elif ('C?M?' in ch) and ('C?M?M' not in ch):\n print('NO')\n elif ('M?C?' in ch) and ('M?C?C' not in ch):\n print('NO')\n elif ('M?Y?' in ch) and ('M?Y?Y' not in ch):\n print('NO')\n elif ('Y?C?' in ch) and ('Y?C?C' not in ch):\n print('NO')\n elif ('Y?M?' in ch) and ('Y?M?M' not in ch):\n print('NO')\n else:\n print('YES')\n"}, {"source_code": "t = int(input())\nstr = list(input())\nlstr = len(str)\n\nif '?' not in str:\n print(\"No\")\n exit()\n\nsw2 = 0\nif lstr == 1:\n print(\"Yes\")\n exit()\nif lstr == 2 and str[0] != str[1]:\n print(\"Yes\")\n exit()\nif lstr == 3 and str[1] == '?' and str[0] != str[2]:\n print(\"No\")\n exit()\nif lstr == 3 and (str[0] != str[1] and str[1] != str[2]):\n print(\"Yes\")\n exit()\n\n\nfor i in range(lstr):\n if str[i] != '?': \n if i != 0 and i != lstr - 1:\n if str[i] == str[i-1] or str[i] == str[i+1]:\n print(\"No\")\n exit()\n elif i == 0 and lstr != 1:\n if str[i] == str[i+1]:\n print(\"No\")\n exit()\n else:\n if str[i] == str[i-1]:\n print(\"No\")\n exit()\n\n else:\n if i != 0 and i != lstr - 1:\n if str[i-1] != str[i+1]:\n sw2 = 0\n else:\n sw2 = 1\n\nif sw2:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n \n\n"}, {"source_code": "n = int(input())\ns = input()\nif s == '?' * n:\n print('YES')\nelse:\n for i in range(n - 1):\n if s[i] == s[i + 1] != '?':\n print('NO')\n break\n else:\n flag = False\n a = 0\n for i in range(n):\n if s[i] == '?':\n if i != 0:\n b = s[i - 1]\n else:\n b = 'gg'\n a += 1\n else:\n c = s[i]\n if a != 0:\n if b == 'gg' or b == c or b != c and a % 2 == 0:\n print('YES')\n break\n a = 0\n else:\n c = s[i]\n if a != 0:\n if b == c or b != c and a % 2 == 0:\n print('YES')\n else:\n print('NO')\n else:\n print('NO')"}, {"source_code": "n=int(input())\ns=input()\nf=1 \nfor i in range(n-1):\n if s[i]==s[i+1] and s[i]!='?' and s[i+1]!='?':\n f=0\n break \nif f==0:\n print('No')\nelse:\n ms=set()\n if '??' in s:\n print('Yes')\n elif '?' not in s:\n print('Yes')\n else:\n if s[0]=='?' or s[-1]=='?':\n print('Yes')\n if 'C?C' in s:\n print('Yes')\n elif 'M?M' in s:\n print('Yes')\n elif 'Y?Y' in s:\n print('Yes')\n else:\n print('No')\n "}, {"source_code": "n = int(input())\na = list(input())\n\nfor i in range(n-1):\n\tj = i+1\n\tif (a[i]==a[j] and a[i]!=\"?\") :\n\t\tprint(\"No\")\n\t\texit()\nfor i in range(1,n-2):\n\tif a[i-1]!=a[i+1] and a[i]==\"?\":\n\t\tprint(\"No\")\n\t\texit()\n\t\nprint(\"Yes\")\n\t\t"}, {"source_code": "def checker(paints):\n \n i=1\n while i < len(paints) - 1:\n if paints[i] == '?' and paints[i - 1] != '?' and paints[i + 1] != '?' and paints[i - 1] != paints[i + 1]:\n paints = paints.replace(paints[i], '', 1)\n i += 1\n\n for i in range(0, len(paints) - 1, 1):\n if paints[i] == paints[i + 1] and paints[i] != '?' and paints[i + 1] != '?':\n return False\n\n return paints.__contains__('?')\n\n\nlengthOfTheCanvas = int(input())\npaints = input()\nif checker(paints):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "import math\nimport queue\n\nfrom itertools import permutations\n\nn=int(input())\ns=input()\n\ndef determine(t):\n for i in range(0,n-1):\n if t[i]==t[i+1] and t[i]!='?':\n return False\n \n for i in range(0,n-1):\n if t[i]=='?' and t[i+1]=='?':\n return True\n \n num=0\n \n if t[0]=='?' or t[n-1]=='?':\n return True\n \n for i in range(1,n-1):\n if t[i]=='?' and t[i-1]!=t[i+1]:\n return True\n return False\n \n \nif determine(s):\n print(\"YES\")\nelse:\n print(\"No\")"}, {"source_code": "N=int(input()) #take the size\n\nArray=list(map(str,input().split()[:N]))\n\ns=''.join(Array)\n\n\nC = s.find('CC')\ncc = s.find('cc')\ncC = s.find('cC')\nCc = s.find('Cc')\n\n\nM = s.find('MM')\nmm = s.find('mm')\nMm = s.find('Mm')\nmM = s.find('mM')\n\n\nY = s.find('YY')\nyy = s.find('yy')\nYy = s.find('Yy')\nyY = s.find('yY')\n\n\nif (Y<1 and M<1 and C<1 and mm<1 and cc<1 and yy<1 and cC<1 and mM<1 and yY<1 and Cc<1 and Mm<1 and Yy<1):\n print(\"Yes\")\nelse:\n print(\"No\") \n "}, {"source_code": "n = int(input())\na = input()\n\nflag = 0\nfor ind, a_i in enumerate(a):\n if ind == 0:\n continue\n else:\n if a_i == a[ind - 1] and a_i != '?':\n flag = 1\n break\n\nif flag == 1:\n print('No')\nelse:\n if a.count('?') >= 2:\n flag = 0\n for ind, a_i in enumerate(a):\n if ind != 0:\n if a_i == '?' and a[ind - 1] == a[ind + 1]:\n flag = 1\n break\n elif ind == 0 and a_i == '?':\n flag = 1\n break\n print('Yes' if flag == 1 else 'No')\n else:\n ind = a.index('?')\n if ind == 0 or ind == n - 1:\n print('Yes')\n else:\n if a[ind - 1] == a[ind + 1]:\n print('Yes')\n else:\n print('No')\n\n"}, {"source_code": "n = input()\ntxt = str(raw_input())\nlicz = 0\nlicz_y = 0\nif n == 1: \n if txt[0] == '?':\n print 'Yes'\n exit(0)\n else:\n print 'No'\n exit(0)\nif n == 2 and (txt[0] == '?' or txt[1] == '?'):\n print 'Yes'\n exit(0)\nfor x in range(0, len(txt)-1, +1):\n if (txt[x] == txt[x+1]) and txt[x] != '?':\n print 'No'\n exit(0)\n if txt[x] == '?' and x != 0:\n if (txt[x-1] != txt[x+1]) and txt[x-1] != '?' and txt[x+1] != '?':\n licz +=1\n if txt[x]=='?':\n licz_y += 1\nif licz == licz_y and licz != 0:\n print 'No'\n exit(0)\nprint 'Yes'"}, {"source_code": "\nn = int(input())\na = input()\na = list(a)\n\n\nt=0\n\ng =a.count(\"?\")\n\n\nif g==0:\n\tprint(\"No\")\n\texit()\n\nfor i in range(n-1):\n\tj = i+1\n\tif (a[i]==a[j] and a[i]!=\"?\") :\n\t\tprint(\"No\")\n\t\texit()\nfor i in range(1,n-2):\n\tif a[i-1]!=a[i+1] and a[i]==\"?\" and (a[i-1]!=\"?\" and a[i+1]!=\"?\" ):\n\t\tt+=1\n\t\t\nif t>=g and t!=0:\n\tprint(\"no\")\n\texit()\nprint(\"Yes\")\n\t\t"}, {"source_code": "import math\nfrom decimal import Decimal\ndef na():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\treturn n,b\n \n \ndef nab():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tc = [int(x) for x in input().split()]\n\treturn n,b,c\n \n \ndef dv():\n\tn, m = map(int, input().split())\n\treturn n,m\n \n \ndef dva():\n\tn, m = map(int, input().split())\n\ta = [int(x) for x in input().split()]\n\tb = [int(x) for x in input().split()]\n\treturn n,m,b\n \n \ndef eratosthenes(n): \n\tsieve = list(range(n + 1))\n\tfor i in sieve:\n\t\tif i > 1:\n\t\t\tfor j in range(i + i, len(sieve), i):\n\t\t\t\tsieve[j] = 0\n\treturn sorted(set(sieve))\n \n \n \ndef nm():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tm = int(input())\n\tc = [int(x) for x in input().split()]\n\treturn n,b,m,c\n \n \ndef dvs():\n\tn = int(input())\n\tm = int(input())\n\treturn n, m\n \n\nn = int(input())\ns = input()\nk = 0\ntk = 0\nfor i in range(n - 1):\n\tif s[i] == '?':\n\t\tk += 1\n\tif s[i] == '?' and i > 0 and s[i - 1] != s[i + 1] and s[i-1] != '?' and s[i+1] != '?':\n\t\ttk += 1\n\tif s[i] == s[i + 1] and s[i] != '?':\n\t\tprint('NO')\n\t\texit()\nif k == tk:\n\tprint('NO')\nelse:\n\tprint('YES')\n"}, {"source_code": "# cook your dish here\nfrom sys import stdin,stdout\nfrom collections import Counter\nfrom itertools import permutations\nimport bisect\nimport math\nI=lambda: map(int,stdin.readline().split())\nI1=lambda: stdin.readline()\n\nn=int(I1())\ns=I1().strip()\ni,f=0,0\nfor j in range(1,n):\n if s[j]==s[j-1] and s[i]!='?':\n print('No')\n exit()\nwhile i<n:\n if s[0]=='?' or s[n-1]=='?':\n f=1 \n break\n elif s[i]=='?':\n j=i+1 \n while s[j]=='?':j+=1 \n if(s[i-1]==s[j]):\n f=1 \n break\n i+=1 \nif f==1: print(\"Yes\")\nelse : print(\"No\")\n "}, {"source_code": "n=int(input())\ncolor = input()\nc=False\nq=color.count(\"?\")\n\nprint(q)\n\n\nif q<2:\n\tprint(\"No\")\nfor i in range(n):\n\tj=i+1\n\tif color[i]==color[j]:\n\t\tC = True\n\t\tbreak\nif q<2 or C:\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")\n\n"}, {"source_code": "n=int(input())\ns=input()\nif (s[0]=='?') or (s[-1]=='?'):\n print('Yes')\nelse:\n if ('MM' in s) or ('CC' in s) or ('YY' in s):\n print('No')\n else:\n if '??' in s:\n print('Yes')\n else:\n if ('C?C' in s) or ('M?M' in s) or ('Y?Y' in s):\n print('Yes')\n else:\n print('No')\n"}, {"source_code": "n = int(input())\ns = input()\n\n# Case where we can't use two coloring :\n# 1) no \"?\" present\n# 2) X?Y Case\n# 3) X??X S'il existe des suites\n\nans = \"Yes\"\nno_int = s.count(\"?\")\n\ndef is_cool(s):\n if s.count(\"??\"):\n return True\n else:\n a = s.count(\"C?C\") + s.count(\"M?M\") + s.count(\"Y?Y\")\n return a > 0\n\nok = (s.count(\"MM\") + s.count(\"CC\") + s.count(\"YY\")) == 0\n# print(\"ok : \", ok)\n\nif not(ok):\n ans = \"No\"\nelif no_int == 0:\n ans = \"Yes\"\nelif s[0] == \"?\" or s[-1] == \"?\":\n ans = \"Yes\"\nelif s.count(\"M?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"M?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"C?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"C?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"Y?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"Y?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n\nprint(ans)"}, {"source_code": "n = int(input())\ncolors = [i for i in input()]\nmaners = [0 for i in range(n)]\ni = 0\nmaners[i] = 1 if(colors[i]!=\"?\") else 3\ni+=1\nwhile i < n:\n if(colors[i-1]==colors[i]) and colors[i]!=\"?\":\n x = 0\n elif(colors[i-1]==colors[i]):\n x = maners[i-1] - 1\n else:\n x = 3\n maners[i] = x\n i+=1\ns = 1\nfor i in maners:\n s*=i\nif(s>2):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "n = int(input())\ns = 'T' + input() + 'T'\nres = 'Yes'\nflex = False\nfor i in range(1, n+1):\n if not flex and s[i] == '?':\n if s[i-1] == '?' or s[i+1] == '?':\n flex = True\n elif s[i-1] != s[i+1]:\n flex = True\n if s[i] != '?' and s[i] == s[i-1]:\n res = 'No'\n break\nif res == 'YES' and not flex:\n res = 'NO'\nprint(res)"}, {"source_code": "import sys\n\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\ndef List(): return list(map(int, input().split()))\ndef Num(): return int(input())\n\n\nn = Num()\ns = input()\nis_cons = False\nfor i in range(1, n):\n if s[i] != \"?\" and s[i] == s[i - 1]:\n is_cons = True\nif is_cons:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n = int(input())\ns = list(input())\n\ndef main():\n if '?' not in s:\n print('No')\n return\n\n if n == 1:\n print('Yes')\n return\n\n if s[0]=='?' or s[n-1]=='?':\n print('Yes')\n return\n\n for i in range(1,n):\n j = i-1\n if s[i] == s[j] and s[i] != '?':\n print('No')\n return\n\n for i in range(1,n):\n j = i-1\n if s[i] == s[j]:\n print('Yes')\n return\n\n\n for i in range(2,n):\n i_1 = i-1\n i_2 = i-2\n if (s[i_2] == s[i]) and s[i_1]=='?':\n print('Yes')\n return\n\n print('No')\n return\n\n\nmain()"}, {"source_code": "n = int(input())\nlst = list(input())\ns=0\nz=0\n#print(len(lst))\nlst1 = [\"C\", \"Y\", \"M\"]\nn=0\nfor i in range(len(lst)-1):\n if lst[i]==\"?\":\n n+=1\nfor i in range(len(lst)-1):\n if lst[i]=='?':\n s+=1\n if i==0:\n s+=1\n elif i==len(lst)-1:\n s+=1\n elif i>0 and i<len(lst)-1:\n if lst[i-1]==lst[i+1]:\n s+=1\n else:\n z+=2\n s+=1\n if lst[i]==lst[i+1]:\n z=1\n#print(z,s)\nif s!=0:\n if z%s==0 and z!=0:\n print('No')\nelif n==len(lst)-1:\n print(\"Yes\")\nelif z==1:\n print(\"No\")\nelif s==0:\n print(\"Yes\")\nelse:\n print(\"Yes\")\n"}, {"source_code": "n=int(input())\ns=list(input())\nif s.count(\"?\")==0:\n print(\"No\")\n exit(0)\n\nf=0\na=s[0]\nfor i in range(1,n):\n if s[i]==s[i-1] and s[i]!=\"?\":\n f=1\ns=[\"*\"]+s+[\"&\"] \ng=0\nif s.count(\"?\")==1: \n for i in range(1,n+1):\n if s[i]==\"?\" and s[i-1]==s[i+1] :\n g+=1\nif f==1 or g>0:\n print(\"No\")\nelse:\n print(\"Yes\") "}, {"source_code": "n = int(input())\ns = input()\nfor i in range(n - 1):\n if s[i] == s[i + 1] != '?':\n print('NO')\n break\nelse:\n flag = False\n a = 0\n for i in range(n):\n if s[i] == '?':\n if i != 0:\n b = s[i - 1]\n else:\n b = 'gg'\n a += 1\n else:\n c = s[i]\n if a != 0:\n if b == 'gg' or b == c or b != c and a % 2 == 0:\n print('YES')\n break\n else:\n print('NO')"}, {"source_code": "n = int(input())\ns = input()\nif s == '?' * n:\n print('YES')\nelse:\n for i in range(n - 1):\n if s[i] == s[i + 1] != '?':\n print('NO')\n break\n else:\n flag = False\n a = 0\n for i in range(n):\n if s[i] == '?':\n if i != 0:\n b = s[i - 1]\n else:\n b = 'gg'\n a += 1\n else:\n c = s[i]\n if a != 0:\n if b == 'gg' or b == c or b != c and a % 2 == 0:\n print('YES')\n break\n a = 0\n else:\n c = s[i]\n if a != 0:\n if b == c or b != c and a % 2 == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n-1):\n if s[i]==s[i+1]:\n print(\"NO\")\n quit()\nprint(\"YES\")"}, {"source_code": "n=int(input())\ns=input()\ncont=0\nx=s[0]\nt=False\nt1=True\nif x=='?':\n t=True\nfor i in range(1,n):\n if s[i]==s[i-1] and s[i]!='?':\n t1=False\n break\n if (s[i]=='?' and i+1!=n and s[i-1]==s[i+1]) or (s[i-1]=='?' )or (s[i]=='?' and i+1==n) :\n t=True\nif t== True and t1==True:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "n = int(input())\ns = input()\nans = 0\nfor i in range(n):\n if (i<n-1 and s[i]==s[i+1]=='?'):\n ans = 1\n if (s[i]=='?' and (i==0 or i==n-1 or s[i-1]==s[i+1])):\n ans = 1\nfor i in range(n-1):\n if (s[i]==s[i+1]):\n ans = 0\nif (ans==1):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n"}, {"source_code": "n=input()\nst=str(raw_input())\nc=0\nans=0\nfor i in range(0,len(st)):\n if st[i]==\"?\":\n c=c+1\n vl=i\n elif i<len(st)-1 and st[i]==st[i+1]:\n ans=-1 \nif ans==-1:\n print \"no\"\nelse: \n if c>=2:\n ans=1 \n if c==1:\n if vl==0 or vl==n-1:\n ans=1 \n elif st[vl-1]==st[vl+1]:\n ans=1 \n if ans==1:\n print \"yes\"\n else:\n print \"no\"\n \n \n "}, {"source_code": "x=int(input())\nstring=input()\ni=0\ncounter=0\nright=-1\nleft=0\nif string.count('MM')>=1 or string.count('CC')>=1 or string.count('YY')>=1:\n print(\"NO\")\nelse:\n while i<x:\n right=string[i+1]\n if i==0 and string[i]!='?':\n left=string[i]\n i+=1\n continue\n elif i==x-1:\n if string[-1]=='?':\n counter+=2\n break\n if string[i]=='?':\n if left==right:\n counter+=1\n else:\n counter+=2\n break\n if string[i+1]=='?':\n pass\n else:\n left=string[i+1]\n else:\n left=string[i]\n i+=1\n if counter>=2:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = int(input())\ns = input()\nflag=0\nfor i in range(n):\n if i==0:\n if s[0] == '?':\n flag=1\n break\n elif i==n-1:\n if s[n-1] == '?':\n flag=1\n break\n else:\n if s[i-1]=='?' or s[i+1]=='?':\n flag=1\n break\n elif s[i-1] == s[i+1]:\n flag=1\n break\nfor i in range(n-1):\n if s[i] == s[i+1] and s[i] != '?':\n flag=0\nif flag==0:\n print('No')\nelse:\n print('Yes')"}, {"source_code": "n=int(input())\ncolor = input()\nc=False\nq=color.count(\"?\")\n\n\n\n\nfor i in range(n):\n\tj=i+1\n\tif color[i]==color[j]:\n\t\tC = True\n\t\tbreak\nif q<2 or C:\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")\n\n"}, {"source_code": "a=int(input());b=input()+'@';ans=1;i=0\nwhile i<a:\n if b[i]!='?' and b[i+1]!='?' and b[i]==b[i+1]:ans=0\n i+=1\nif ans:print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "n = input()\ntxt = str(raw_input())\nlicz = 0\nlicz_y = 0\nif n == 1 and txt[0] == '?':\n print 'Yes'\n exit(0)\nif n == 2 and (txt[0] == '?' or txt[1] == '?'):\n print 'Yes'\n exit(0)\nfor x in range(0, len(txt)-1, +1):\n if (txt[x] == txt[x+1]) and txt[x] != '?':\n print 'No'\n exit(0)\n if txt[x] == '?' and x != 0:\n if (txt[x-1] != txt[x+1]) and txt[x-1] != '?' and txt[x+1] != '?':\n licz +=1\n if txt[x]=='?':\n licz_y += 1\nif licz == licz_y:\n print 'No'\n exit(0)\nprint 'Yes'"}, {"source_code": "n= int(input())\ns= input()\ns= '0'+ s + '0'\nres=0\nf=0\nfor i in range(len(s)-1):\n if s[i]!=\"?\" and s[i]== s[i+1]:\n print(\"No\")\n f=1\n exit(0)\n elif s[i]==\"?\" and s[i]== s[i+1]:\n print(\"Yes\")\n f=1\n exit(0)\nfor i in range(1,len(s)-1):\n if s[i]==\"?\":\n a= s[i-1]\n b= s[i+1]\n if (a=='C' and b=='C') or (a=='M' and b=='M') or (a=='Y' and b=='Y') or (a=='0' and b=='Y') or (a=='0' and b=='C') or (a=='0' and b=='M') or (a=='Y' and b=='0') or (a=='M' and b=='0') or (a=='C' and b=='0'):\n res+=2\n print(\"Yes\")\n f=1\n exit(0)\n elif (a=='Y' and b=='M') or (a=='M' and b=='Y') or (a=='Y' and b=='C') or (a=='C' and b=='Y') or (a=='C' and b=='M') or (a=='M' and b=='C'):\n res+= 1\n if res==2:\n print(\"Yes\")\n f=1\n exit(0)\n \nif f==0:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\na = input()\nf = 0\nfor i in range(len(a)):\n if a[i] == '?':\n f = 1\n break\nif f == 0:\n print('No')\n exit()\nfor i in range(1, len(a)):\n if a[i] != '?' and a[i] == a[i-1]:\n print('No')\n exit()\ns = 0\nfor i in range(1,len(a)-1):\n if a[i] =='?':\n s += 1\nif s == 1:\n for i in range(1, len(a) - 1):\n if a[i] == '?' and a[i-1] != a[i+1]:\n print('No')\n exit()\n\nprint('Yes')"}, {"source_code": "n=int(input())\nAr=input()\nif Ar[0]=='?' or Ar[-1]=='?':\n print(\"YES\")\nelif Ar.find(\"???\")!=-1:\n print(\"YES\")\nelse:\n C=Ar.count('?')\n cnt=0\n for i in range(1,n-1):\n if Ar[i]=='?' and (Ar[i-1]=='C' and Ar[i+1]=='C') or (Ar[i-1]=='Y' and Ar[i+1]=='Y') or (Ar[i-1]=='M' and Ar[i+1]=='M'):\n cnt+=1\n break\n l=Ar.find(\"??\")\n while(l!=-1):\n if Ar[l-1]==Ar[l+2]:\n cnt+=2\n l=Ar.find(\"??\",l+2)\n if cnt>0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = int(input())\ns = input()\n\ndef f(s):\n for i in range(len(s)):\n if s[i] == '?':\n if i == 0 or i == len(s) - 1:\n return True\n else:\n if s[i + 1] == '?':\n if i + 2 < len(s):\n if s[i - 1] == s[i + 2]:\n return True\n if s[i - 1] == s[i + 1]:\n return True\n return False\n\nif f(s):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(1, n):\n\tif s[i] == s[i - 1] and s[i] != '?':\n\t\tprint(\"no\")\n\t\tquit()\n\tif s[i] == '?':\n\t\tif i != n - 1 and s[i - 1] != s[i + 1] and (s[i - 1] != '?' or s[i + 1] != '?'):\n\t\t\tprint(\"no\")\n\t\t\tquit()\nprint(\"yes\")"}, {"source_code": "n = int(input())\n\nmural = input()\n\nresult = 'Yes'\nflag = True\nif mural.count('?') == 0:\n print('No')\n\nelse:\n if n == 1 or n == 2:\n print('Yes')\n\n else:\n if mural[0] == '?' or mural[-1] == '?':\n print('Yes')\n else:\n for i in range(1, n-1):\n if mural[i] == mural[i-1] or mural[i] == mural[i+1]:\n if mural[i] != '?':\n result = 'No'\n break\n else:\n result = 'Yes'\n flag = False\n\n elif mural[i] == '?' and flag:\n if mural[i-1] != mural[i+1]:\n result = 'No'\n else:\n result = 'Yes'\n flag = False\n\n print(result)"}, {"source_code": "#Abhigyan Khaund - syl\n# t = int(raw_input())\n# while t:\n# \tt-=1\n# \tm = map(int, raw_input().split())\n\nn = int(raw_input())\nv = raw_input()\nyes = 1\nfor i in range(1,n):\n\tif(v[i]==v[i-1] and v[i]!='?'):\n\t\tyes = 0\n\t\tbreak\nif(yes):\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 29 10:47:16 2018\n\n@author: Administrator\n\"\"\"\n\nn = int(input())\ns = input()\ncnt = 0\nflag = False\nindex = 0\nfor i in s:\n if i == '?':\n cnt = cnt + 1\n else:\n if cnt >= 3:\n flag = True\n break\n elif cnt <= 2 and cnt > 0:\n if index - cnt - 1< 0:\n flag = True\n break\n elif s[index] == s[index-cnt-1]:\n flag = True\n break\n cnt = 0\n index = index + 1\nif cnt > 0:\n flag = True\nfor i in range(1, len(s)):\n if s[i] == s[i-1]:\n flag = False\nif flag:\n print(\"Yes\\n\")\nelse:\n print(\"No\\n\")\n "}, {"source_code": "def dfs(s,x,y,n):\n c = ['C', 'Y', 'W']\n sum = 0\n if x == 0:\n if x == n-1:\n return 3\n else:\n for i in range(3):\n if x == y-1:\n if c[i] != s[y]:\n sum += 1\n else:\n sum += dfs(s,x+1,y,n)\n else:\n if x == n-1:\n for i in range(3):\n if c[i] != s[x-1]:\n sum += 1\n else:\n for i in range(3):\n if c[i] != s[x-1]:\n if x == y - 1:\n if c[i] != s[y]:\n sum += 1\n else:\n s[x] = c[i]\n sum += dfs(s,x+1,y,n)\n return sum\n\n\n\nn1 = input()\nn = int(n1)\ns = []\nflag = True\nsc = input()\nfor i in range(n):\n s.append(sc[i])\n if i > 0:\n if s[i] == s[i-1] and s[i] != '?':\n flag = False\n break\n\nif flag == False:\n print('NO')\n exit()\n\nb = []\nj = 0\n\nfor i in range(n):\n if s[i] == '?':\n if j == 0:\n x = i\n j += 1\n else:\n j += 1\n elif j != 0:\n b.append(dfs(s,x,x+j,n))\n j = 0\nif j != 0:\n b.append(dfs(s,x,x+j,n))\n j = 0\n\nsum = 1\nl = len(b)\nfor i in range(l):\n sum *= b[i]\n\nif sum >= 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = int(input())\na = list(input())\n\nfor i in range(n-1):\n\tj = i+1\n\tif (a[i]==a[j] and a[i]!=\"?\") :\n\t\tprint(\"No\")\n\t\texit()\nfor i in range(1,n-2):\n\tif a[i-1]!=a[i+1] and a[i]==\"?\" and (a[i-1]!=\"?\" or a[i+1]!=\"?\"):\n\t\tprint(\"No\")\n\t\texit()\n\t\nprint(\"Yes\")\n\t\t"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 29 10:47:16 2018\n\n@author: Administrator\n\"\"\"\n\nn = int(input())\ns = input()\ncnt = 0\nflag = False\nindex = 0\nfor i in s:\n if i == '?':\n cnt = cnt + 1\n else:\n if cnt >= 3:\n flag = True\n break\n elif cnt <= 2 and cnt > 0:\n if index - cnt - 1< 0:\n flag = True\n break\n elif s[index] == s[index-cnt-1]:\n flag = True\n break\n cnt = 0\n index = index + 1\nif flag or cnt > 0:\n print(\"Yes\\n\")\nelse:\n print(\"No\\n\")\n "}, {"source_code": "n = int(input())\ns = input()\n\n# Case where we can't use two coloring :\n# 1) no \"?\" present\n# 2) X?Y Case\n# 3) X??X S'il existe des suites\n\nans = \"Yes\"\nno_int = s.count(\"?\")\n\n\ndef is_cool(s):\n if s.count(\"??\"):\n return True\n else:\n a = s.count(\"C?C\") + s.count(\"M?M\") + s.count(\"Y?Y\")\n return a > 0\n\n\nok = (s.count(\"MM\") + s.count(\"CC\") + s.count(\"YY\")) == 0\n# print(\"ok : \", ok)\n\nif no_int == 0:\n ans = \"Yes\"\nelif not (ok):\n ans = \"No\"\nelif s[0] == \"?\" or s[-1] == \"?\":\n ans = \"Yes\"\nelif s.count(\"M?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"M?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"C?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"C?Y\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"Y?C\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\nelif s.count(\"Y?M\") >= 1:\n if is_cool(s):\n ans = \"Yes\"\n else:\n ans = \"No\"\n\nprint(ans)\n"}], "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3"} {"source_code": "from fractions import gcd\nb,D=map(int,raw_input().split())\na=200*[0]\nz=200*[0]\nfor d in range(2,101):\n\tc=0\n\tt=d\n\twhile gcd(b,t)>1:\n\t\tt/=gcd(b,t)\n\t\tc+=1\n\tif t==1:\n\t\ta[d]=2\n\t\tz[d]=c\n\t\tcontinue\n\tif b%d==1:\n\t\ta[d]=3\n\t\tcontinue\n\tif (b+1)%d==0:\n\t\ta[d]=11\n\t\tcontinue\n\ta[d]=7\n\tfor i in range(2,d):\n\t\tif d%i==0 and gcd(i,d/i)==1 and a[i]!=7 and a[d/i]!=7:\n\t\t\ta[d]=6\nprint \"%d-type\"%a[D]\nif a[D]==2:\n\tprint z[D]\n", "positive_code": [{"source_code": "b, d = map(int, input().split())\nfor i in range(1, 10):\n if (b**i) % d == 0:\n print(\"2-type\")\n print(i)\n exit()\nif (b-1) % d == 0:\n print(\"3-type\")\n exit()\nif (b+1) % d == 0:\n print(\"11-type\")\n exit()\nfor i in range(2, d+1):\n if d % i == 0:\n x = 1\n while d % i == 0: \n d /= i \n x *= i\n if (b**10) % x != 0 and (b+1) % x != 0 and (b-1) % x != 0:\n print(\"7-type\")\n break\nelse:\n print(\"6-type\")\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(100):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n for i in range(2, 100):\n cur = 1\n while x % i == 0:\n cur *= i\n x /= i\n if cur != 1 and b % i:\n if not(typeTwo(cur) or typeThree(cur) or typeEleven(cur)):\n return False\n return True\n\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelif typeSix(d):\n print '6-type'\nelse:\n print '7-type'\n\n"}, {"source_code": "b,d=map(int,raw_input().split())\nfor i in xrange(1,10):\n if (b**i)%d==0:\n print \"2-type\"\n print i\n exit()\nif (b-1)%d==0:\n print \"3-type\"\nelif (b+1)%d==0:\n print \"11-type\"\nelse:\n for i in xrange(2,d+1):\n if d%i==0:\n x=1\n while d%i==0: d/=i; x*=i\n if (b**10)%x!=0 and (b+1)%x!=0 and (b-1)%x!=0:\n print \"7-type\"\n exit()\n print \"6-type\"\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ch\n\t\tif(sum%div!=0):\n\t\t\t#print sum,div\n\t\t\treturn False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ch\n\t\t\telse:\n\t\t\t\teve+=ch\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\n\ndef checkTypeSechs(base,div):\n\tfactor=[]\n\tfor i in xrange(2,div+1):\n\t\tif(div%i==0):\n\t\t\tfactor.append(i)\n\t\t\twhile(div%i==0):\n\t\t\t\tdiv/=i\n\tans=True\n\t#print factor\n\tif(len(factor)<2):\n\t\treturn False\n\tfor num in factor:\n\t\tif(checkTypeZwei(base,num)!=-1 or checkTypeDrei(base,num) or checkTypeElf(base,num)):\n\t\t\tans=True\n\t\telse:\n\t\t\tans=False\n\t\t\tbreak;\n\treturn ans\n\n\ndef xBase(num,base):\n\tres=[]\n\twhile(num):\n\t\ttmpNum=num%base\n\t\ttmpList=[]\n\t\ttmpList.append(tmpNum)\n\t\ttmpList.extend(res)\n\t\tres=tmpList\n\t\tnum/=base\n\treturn [0] if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tleng=-1\n\tif(type==7):\n\t\tleng=checkTypeZwei(base,div)\n\t\tif(leng!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint leng\n"}, {"source_code": "b,d=map(int,raw_input().split())\n\nfor i in xrange(1,10):\n\n if (b**i)%d==0:\n\n print \"2-type\"\n\n print i\n\n exit()\n\nif (b-1)%d==0:\n\n print \"3-type\"\n\nelif (b+1)%d==0:\n\n print \"11-type\"\n\nelse:\n\n for i in xrange(2,d+1):\n\n if d%i==0:\n\n x=1\n\n while d%i==0: d/=i; x*=i\n\n if (b**10)%x!=0 and (b+1)%x!=0 and (b-1)%x!=0:\n\n print \"7-type\"\n\n exit()\n\n print \"6-type\"\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "import sys\n\nb, d = [int(s) for s in sys.stdin.readline().split(' ')]\n\ndef pf(d):\n l = []\n i = 2\n while i * i <= d:\n if d % i == 0:\n k = 1\n while d % i == 0:\n d /= i\n k *= i\n l.append(k)\n i += 1\n if d > 1:\n l.append(d)\n return l\n\ndef typ(b, d):\n if (b ** 7) % d == 0:\n i, bb = 1, b\n while bb % d != 0:\n i, bb = i + 1, bb * b\n return (2, i)\n elif (b - 1) % d == 0:\n return 3\n elif (b + 1) % d == 0:\n return 11\n else:\n p = pf(d)\n if p != [d] and all(typ(b, f) != 7 for f in p):\n return 6\n else:\n return 7\n\nt=typ(b,d)\nif isinstance(t, int):\n print \"%d-type\" % t\nelse:\n print \"%d-type\" % t[0]\n print t[1]\n"}], "negative_code": [{"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(100):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n p = []\n for i in range(2, 100):\n cur = 1\n while x % i == 0:\n cur *= i\n x /= i\n if cur != 1:\n p.append(cur);\n a = []\n for i in range(len(p)):\n if typeTwo(p[i]): a.append(2)\n if typeThree(p[i]): a.append(3)\n if typeEleven(p[i]): a.append(11);\n return a\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelse:\n a = typeSix(d)\n if a.count(2) <= 1 and a.count(3) <= 1 and a.count(11) <= 1 and len(a) > 0:\n print '6-type'\n else:\n print '7-type'\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(50):\n if (b ** (2 * i) - 1) % d != 0:\n return False\n if (b ** (2 * i + 1) + 1) % d != 0:\n return False\n return True\n\ndef typeSix(x):\n if typeTwo(x) or typeThree(x) or typeEleven(x):\n return True\n for i in range(2, x):\n if x % i == 0:\n if typeSix(i) and typeSix(x // i):\n return True\n return False\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelif typeSix(d):\n print '6-type'\nelse:\n print '7-type'\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(100):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n p = []\n for i in range(2, 100):\n while x % i == 0:\n p.append(i);\n x /= i\n a = []\n for i in range(len(p)):\n if typeTwo(p[i]): a.append(2)\n if typeThree(p[i]): a.append(3)\n if typeEleven(p[i]): a.append(11);\n return a\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelse:\n a = typeSix(d)\n if a.count(2) <= 1 and a.count(3) <= 1 and a.count(11) <= 1:\n print '6-type'\n else:\n print '7-type'\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(50):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n if typeTwo(x) or typeThree(x) or typeEleven(x):\n return True\n for i in range(2, x):\n if x % i == 0:\n if typeSix(i) and typeSix(x // i):\n return True\n return False\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelif typeSix(d):\n print '6-type'\nelse:\n print '7-type'\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(100):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n if typeTwo(x):\n return [2]\n if typeThree(x):\n return [3]\n if typeEleven(x):\n return [11]\n for i in range(2, x):\n if x % i == 0:\n a = []\n a.extend(typeSix(i))\n a.extend(typeSix(x // i))\n if a.count(2) <= 1 and a.count(3) <= 1 and a.count(11) <= 1:\n return a\n return [2, 2]\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelse:\n a = typeSix(d)\n if a.count(2) <= 1 and a.count(3) <= 1 and a.count(11) <= 1:\n print '6-type'\n else:\n print '7-type'\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(50):\n if (b ** (2 * i) - 1) % d != 0:\n return False\n if (b ** (2 * i + 1) + 1) % d != 0:\n return False\n return True\n\ndef typeSix(x):\n if typeTwo(x) or typeThree(x):\n return True\n for i in range(2, x):\n if x % i == 0:\n if typeSix(i) and typeSix(x // i):\n return True\n return False\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelif typeSix(d):\n print '6-type'\nelse:\n print '7-type'\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(100):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n p = []\n for i in range(2, 100):\n cur = 1\n while x % i == 0:\n cur *= i\n x /= i\n if cur != 1:\n p.append(cur)\n a = []\n for i in range(len(p)):\n if typeTwo(p[i]): a.append(2)\n elif typeThree(p[i]): a.append(3)\n elif typeEleven(p[i]): a.append(11)\n else:\n a.append(p[i])\n return a\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelse:\n a = typeSix(d)\n f = True\n if not(a.count(2) <= 1 and a.count(3) <= 1 and a.count(11) <= 1 and len(a) > 0):\n f = False\n if a.count(2) == 1: a.remove(2)\n if a.count(3) == 1: a.remove(3)\n if a.count(11) == 1: a.remove(11)\n if len(a) > 0:\n f = False\n print '6-type' if f else '7-type'\n\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(100):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n p = []\n for i in range(2, 100):\n while x % i == 0:\n p.append(i);\n x /= i\n a = []\n for i in range(len(p)):\n if typeTwo(p[i]): a.append(2)\n if typeThree(p[i]): a.append(3)\n if typeEleven(p[i]): a.append(11);\n return a\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelse:\n a = typeSix(d)\n if a.count(2) <= 1 and a.count(3) <= 1 and a.count(11) <= 1 and len(a) > 0:\n print '6-type'\n else:\n print '7-type'\n"}, {"source_code": "b, d = map(int, raw_input().split())\n\ndef typeTwo(x):\n for i in range(100):\n if (b ** i) % x == 0:\n return i\n return 0\n\ndef typeThree(x):\n for i in range(100):\n if (b ** i - 1) % x != 0:\n return False\n return True\n\ndef typeEleven(x):\n for i in range(100):\n if (b ** (2 * i) - 1) % x != 0:\n return False\n if (b ** (2 * i + 1) + 1) % x != 0:\n return False\n return True\n\ndef typeSix(x):\n p = []\n for i in range(2, 100):\n cur = 1\n while x % i == 0:\n cur *= i\n x /= i\n if cur != 1 and b % i:\n p.append(cur)\n a = []\n for i in range(len(p)):\n if typeTwo(p[i]): a.append(2)\n elif typeThree(p[i]): a.append(3)\n elif typeEleven(p[i]): a.append(11)\n else:\n a.append(p[i])\n return a\n\nif typeTwo(d):\n print '2-type'\n print typeTwo(d)\nelif typeThree(d):\n print '3-type'\nelif typeEleven(d):\n print '11-type'\nelse:\n a = typeSix(d)\n f = True\n if not(a.count(2) <= 1 and a.count(3) <= 1 and a.count(11) <= 1 and len(a) > 0):\n f = False\n if a.count(2) == 1: a.remove(2)\n if a.count(3) == 1: a.remove(3)\n if a.count(11) == 1: a.remove(11)\n if len(a) > 0:\n f = False\n print '6-type' if f else '7-type'\n\n"}, {"source_code": "b,d=map(int,raw_input().split())\nfor i in xrange(1,10):\n if (b**i)%d==0:\n print \"2-type\"\n print i\n exit()\nif (b-1)%d==0:\n print \"3-type\"\nelif (b+1)%d==0:\n print \"11-type\"\nelif ((b-1)*b*(b+1))**10 % d == 0:\n print \"6-type\"\nelse:\n print \"7-type\"\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ch\n\t\tif(sum%div!=0):\n\t\t\tprint sum,div\n\t\t\treturn False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ch\n\t\t\telse:\n\t\t\t\teve+=ch\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\n\ndef checkTypeSechs(base,div):\n\tfactor=[]\n\tfor i in xrange(2,div+1):\n\t\tif(div%i==0):\n\t\t\tfactor.append(i)\n\t\t\twhile(div%i==0):\n\t\t\t\tdiv/=i\n\tans=True\n\t#print factor\n\tif(len(factor)<2):\n\t\treturn False\n\tfor num in factor:\n\t\tif(checkTypeZwei(base,num)!=-1 or checkTypeDrei(base,num) or checkTypeElf(base,num)):\n\t\t\tans=True\n\t\telse:\n\t\t\tans=False\n\t\t\tbreak;\n\treturn ans\n\n\ndef xBase(num,base):\n\tres=[]\n\twhile(num):\n\t\ttmpNum=num%base\n\t\ttmpList=[]\n\t\ttmpList.append(tmpNum)\n\t\ttmpList.extend(res)\n\t\tres=tmpList\n\t\tnum/=base\n\treturn [0] if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tleng=-1\n\tif(type==7):\n\t\tleng=checkTypeZwei(base,div)\n\t\tif(leng!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint leng\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve):\n\t\t\treturn False\n\t\n\treturn True\n\ndef checkTypeSechs(base,div):\n\tfor i in xrange(1,int(sqrt(div))):\n\t\tif(div%i==0):\n\t\t\ta=div/i\n\t\t\tb=i\n\n\t\t\tif(checkTypeZwei(base,a)!=-1 or checkTypeDrei(base,a) or checkTypeElf(base,a)):\n\t\t\t\ta=True\n\t\t\telse:\n\t\t\t\ta=False\n\n\t\t\tif(checkTypeZwei(base,b)!=-1 or checkTypeDrei(base,b) or checkTypeElf(base,b)):\n\t\t\t\tb=True\n\t\t\telse:\n\t\t\t\tb=False\n\n\t\t\tif(not (a and b)):\n\t\t\t\treturn False\n\t\n\n\treturn True\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tlen=-1\n\tif(type==7):\n\t\tlen=checkTypeZwei(base,div)\n\t\tif(len!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint len\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+=ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\n\ndef checkTypeSechs(base,div):\n\tfactor=[]\n\tfor i in xrange(2,div+1):\n\t\tif(div%i==0):\n\t\t\tfactor.append(i)\n\t\t\twhile(div%i==0):\n\t\t\t\tdiv/=i\n\tans=True\n\tfor num in factor:\n\t\tif(checkTypeZwei(base,num)!=-1 or checkTypeDrei(base,num) or checkTypeElf(base,num)):\n\t\t\tans=True\n\t\telse:\n\t\t\tans=False\n\t\t\tbreak;\n\treturn ans\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tlen=-1\n\tif(type==7):\n\t\tlen=checkTypeZwei(base,div)\n\t\tif(len!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint len\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+=ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\n\ndef checkTypeSechs(base,div):\n\tfactor=[]\n\tfor i in xrange(2,div+1):\n\t\tif(div%i==0):\n\t\t\tfactor.append(i)\n\t\t\twhile(div%i==0):\n\t\t\t\tdiv/=i\n\tans=True\n\t#print factor\n\tif(len(factor)<2):\n\t\treturn False\n\tfor num in factor:\n\t\tif(checkTypeZwei(base,num)!=-1 or checkTypeDrei(base,num) or checkTypeElf(base,num)):\n\t\t\tans=True\n\t\telse:\n\t\t\tans=False\n\t\t\tbreak;\n\treturn ans\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tleng=-1\n\tif(type==7):\n\t\tleng=checkTypeZwei(base,div)\n\t\tif(leng!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint leng\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+=ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\ndef checkTypeSechs(base,div):\n\tfor i in xrange(1,int(sqrt(div))):\n\t\tif(div%i==0):\n\t\t\ta=div/i\n\t\t\tb=i\n\n\t\t\tif(checkTypeZwei(base,a)!=-1 or checkTypeDrei(base,a) or checkTypeElf(base,a)):\n\t\t\t\ta=True\n\t\t\telse:\n\t\t\t\ta=False\n\n\t\t\tif(checkTypeZwei(base,b)!=-1 or checkTypeDrei(base,b) or checkTypeElf(base,b)):\n\t\t\t\tb=True\n\t\t\telse:\n\t\t\t\tb=False\n\n\t\t\tif(not (a and b)):\n\t\t\t\treturn False\n\t\n\n\treturn True\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tlen=-1\n\tif(type==7):\n\t\tlen=checkTypeZwei(base,div)\n\t\tif(len!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint len\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+=ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\ndef checkTypeSechs(base,div):\n\tfor i in xrange(1,int(sqrt(div))+1):\n\t\tif(div%i==0):\n\t\t\ta=div/i\n\t\t\tb=i\n\t\t\t#print a,b\n\t\t\tif(checkTypeZwei(base,a)!=-1 or checkTypeDrei(base,a) or checkTypeElf(base,a)):\n\t\t\t\ta=True\n\t\t\telse:\n\t\t\t\ta=False\n\n\t\t\tif(checkTypeZwei(base,b)!=-1 or checkTypeDrei(base,b) or checkTypeElf(base,b)):\n\t\t\t\tb=True\n\t\t\telse:\n\t\t\t\tb=False\n\n\t\t\tif(a and b):\n\t\t\t\treturn True\n\t\n\treturn False\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tlen=-1\n\tif(type==7):\n\t\tlen=checkTypeZwei(base,div)\n\t\tif(len!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint len\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+=ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\ndef gcd(a,b):\n\tif(b>a):\n\t\treturn gcd(a,b)\n\telif(a%b==0):\n\t\treturn b\n\telse:\n\t\treturn gcd(b,a%b)\n\ndef checkTypeSechs(base,div):\n\tfactor=[]\n\tfor i in xrange(2,int(sqrt(div))+1):\n\t\tif(div%i==0):\n\t\t\tfactor.append(i)\n\t\t\twhile(div%i==0):\n\t\t\t\tdiv/=i\n\tans=True\n\tfor num in factor:\n\t\tif(checkTypeZwei(base,num)!=-1 or checkTypeDrei(base,num) or checkTypeElf(base,num)):\n\t\t\tans=True\n\t\telse:\n\t\t\tans=False\n\t\t\tbreak;\n\treturn ans\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tlen=-1\n\tif(type==7):\n\t\tlen=checkTypeZwei(base,div)\n\t\tif(len!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint len\n"}, {"source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+=ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\ndef gcd(a,b):\n\tif(b>a):\n\t\treturn gcd(a,b)\n\telif(a%b==0):\n\t\treturn b\n\telse:\n\t\treturn gcd(b,a%b)\n\ndef checkTypeSechs(base,div):\n\tfor i in xrange(1,int(sqrt(div))+1):\n\t\tif(div%i==0):\n\t\t\ta=div/i\n\t\t\tb=i\n\t\t\tif(gcd(a,b)!=1):\n\t\t\t\tcontinue\n\t\t\tif(checkTypeZwei(base,a)!=-1 or checkTypeDrei(base,a) or checkTypeElf(base,a)):\n\t\t\t\ta=True\n\t\t\telse:\n\t\t\t\ta=False\n\n\t\t\tif(checkTypeZwei(base,b)!=-1 or checkTypeDrei(base,b) or checkTypeElf(base,b)):\n\t\t\t\tb=True\n\t\t\telse:\n\t\t\t\tb=False\n\n\t\t\tif(a and b):\n\t\t\t\treturn True\n\t\n\treturn False\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tlen=-1\n\tif(type==7):\n\t\tlen=checkTypeZwei(base,div)\n\t\tif(len!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint len\n"}, {"source_code": "import sys\n\nb, d = [int(s) for s in sys.stdin.readline().split(' ')]\n\ndef pf(d):\n l = []\n i = 2\n while i * i <= d:\n if d % i == 0:\n while d % i == 0: d /= i\n l.append(i)\n i += 1\n if d > 1:\n l.append(d)\n return l\n\ndef typ(b, d):\n if (b ** 7) % d == 0:\n i, bb = 1, b\n while bb % d != 0:\n i, bb = i + 1, bb * b\n return (2, i)\n elif (b - 1) % d == 0:\n return 3\n elif (b + 1) % d == 0:\n return 11\n else:\n p = pf(d)\n if p != [d] and all(typ(b, f) != 7 for f in p):\n return 6\n else:\n return 7\n\nt=typ(b,d)\nif isinstance(t, int):\n print \"%d-type\" % t\nelse:\n print \"%d-type\" % t[0]\n print t[1]\n"}, {"source_code": "import sys\n\nb, d = [int(s) for s in sys.stdin.readline().split(' ')]\n\ndef pf(d):\n l = []\n i = 2\n while i * i <= d:\n if d % i == 0:\n while d % i == 0: d /= i\n l.append(i)\n i += 1\n if i > 1:\n l.append(i)\n return l\n\ndef typ(b, d):\n if (b ** 7) % d == 0:\n i, bb = 1, b\n while bb % d != 0:\n i, bb = i + 1, bb * b\n return (2, i)\n elif (b - 1) % d == 0:\n return 3\n elif (b + 1) % d == 0:\n return 11\n else:\n p = pf(d)\n if p and all(typ(b, f) != 7 for f in p):\n return 6\n else:\n return 7\n\nt=typ(b,d)\nif isinstance(t, int):\n print \"%d-type\" % t\nelse:\n print \"%d-type\" % t[0]\n print t[1]\n"}], "src_uid": "809e1c78b0a5a16f7f2115b046a20bde"} {"source_code": "import os\r\nimport sys \r\nfrom io import BytesIO, IOBase\r\n \r\nBUFSIZE = 8192\r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno() \r\n self.buffer = BytesIO() \r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break \r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0 \r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) \r\n self.newlines = b.count(b\"\\n\") + (not b) \r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1 \r\n return self.buffer.readline()\r\n \r\n def flush(self): \r\n if self.writable: \r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0) \r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nclass FFT:\r\n def __init__(self, MOD=998244353):\r\n FFT.MOD = MOD\r\n g = self.primitive_root_constexpr()\r\n ig = pow(g, FFT.MOD - 2, FFT.MOD)\r\n FFT.W = [pow(g, (FFT.MOD - 1) >> i, FFT.MOD) for i in range(30)]\r\n FFT.iW = [pow(ig, (FFT.MOD - 1) >> i, FFT.MOD) for i in range(30)]\r\n\r\n def primitive_root_constexpr(self):\r\n if FFT.MOD == 998244353:\r\n return 3\r\n elif FFT.MOD == 200003:\r\n return 2\r\n elif FFT.MOD == 167772161:\r\n return 3\r\n elif FFT.MOD == 469762049:\r\n return 3\r\n elif FFT.MOD == 754974721:\r\n return 11\r\n divs = [0] * 20\r\n divs[0] = 2\r\n cnt = 1\r\n x = (FFT.MOD - 1) // 2\r\n while x % 2 == 0:\r\n x //= 2\r\n i = 3\r\n while i * i <= x:\r\n if x % i == 0:\r\n divs[cnt] = i\r\n cnt += 1\r\n while x % i == 0:\r\n x //= i\r\n i += 2\r\n if x > 1:\r\n divs[cnt] = x\r\n cnt += 1\r\n g = 2\r\n while 1:\r\n ok = True\r\n for i in range(cnt):\r\n if pow(g, (FFT.MOD - 1) // divs[i], FFT.MOD) == 1:\r\n ok = False\r\n break\r\n if ok:\r\n return g\r\n g += 1\r\n\r\n def fft(self, k, f):\r\n for l in range(k, 0, -1):\r\n d = 1 << l - 1\r\n U = [1]\r\n for i in range(d):\r\n U.append(U[-1] * FFT.W[l] % FFT.MOD)\r\n \r\n for i in range(1 << k - l):\r\n for j in range(d):\r\n s = i * 2 * d + j\r\n f[s], f[s + d] = (f[s] + f[s + d]) % FFT.MOD, U[j] * (f[s] - f[s + d]) % FFT.MOD\r\n\r\n def ifft(self, k, f):\r\n for l in range(1, k + 1):\r\n d = 1 << l - 1\r\n for i in range(1 << k - l):\r\n u = 1\r\n for j in range(i * 2 * d, (i * 2 + 1) * d):\r\n f[j+d] *= u\r\n f[j], f[j + d] = (f[j] + f[j + d]) % FFT.MOD, (f[j] - f[j + d]) % FFT.MOD\r\n u = u * FFT.iW[l] % FFT.MOD\r\n\r\n def convolve(self, A, B):\r\n n0 = len(A) + len(B) - 1\r\n k = (n0).bit_length()\r\n n = 1 << k\r\n A += [0] * (n - len(A))\r\n B += [0] * (n - len(B))\r\n self.fft(k, A)\r\n self.fft(k, B)\r\n A = [a * b % FFT.MOD for a, b in zip(A, B)]\r\n self.ifft(k, A)\r\n inv = pow(n, FFT.MOD - 2, FFT.MOD)\r\n A = [a * inv % FFT.MOD for a in A]\r\n del A[n0:]\r\n return A\r\n\r\nMOD = 998244353\r\ndef solve():\r\n n, k, f = map(int, input().split())\r\n if f > 2 * k:\r\n print(0)\r\n return\r\n\r\n fft = FFT()\r\n A = [1] * (k + 1)\r\n for i in range(n):\r\n B = fft.convolve(A[:], A[:])\r\n if i == n - 1:\r\n break\r\n tot = sum(B[k+1:]) % MOD\r\n A = [0] * (k + 1)\r\n cum = 0\r\n for i in range(k, -1, -1):\r\n A[i] += tot + B[i] * (k + 1 - i)\r\n A[i] %= MOD\r\n tot += B[i]\r\n if tot >= 0:\r\n tot -= MOD\r\n print(B[f])\r\n \r\n \r\nfor _ in range(1):\r\n solve() ", "positive_code": [{"source_code": "\n\n# AtCoder Libary v1.4 \u3092 python \u306b\u79fb\u690d\u3057\u305f\u3082\u306e\n# https://github.com/atcoder/ac-library/blob/master/atcoder/convolution.hpp\n\nMOD = 998244353\nIMAG = 911660635\nIIMAG = 86583718\nrate2 = (0, 911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 867605899, 0)\nirate2 = (0, 86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543, 109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951, 103369235, 0)\nrate3 = (0, 372528824, 337190230, 454590761, 816400692, 578227951, 180142363, 83780245, 6597683, 70046822, 623238099, 183021267, 402682409, 631680428, 344509872, 689220186, 365017329, 774342554, 729444058, 102986190, 128751033, 395565204, 0)\nirate3 = (0, 509520358, 929031873, 170256584, 839780419, 282974284, 395914482, 444904435, 72135471, 638914820, 66769500, 771127074, 985925487, 262319669, 262341272, 625870173, 768022760, 859816005, 914661783, 430819711, 272774365, 530924681, 0)\n\ndef butterfly(a):\n n = len(a)\n h = (n - 1).bit_length()\n le = 0\n while le < h:\n if h - le == 1:\n p = 1 << (h - le - 1)\n rot = 1\n for s in range(1 << le):\n offset = s << (h - le)\n for i in range(p):\n l = a[i + offset]\n r = a[i + offset + p] * rot\n a[i + offset] = (l + r) % MOD\n a[i + offset + p] = (l - r) % MOD\n rot *= rate2[(~s & -~s).bit_length()]\n rot %= MOD\n le += 1\n else:\n p = 1 << (h - le - 2)\n rot = 1\n for s in range(1 << le):\n rot2 = rot * rot % MOD\n rot3 = rot2 * rot % MOD\n offset = s << (h - le)\n for i in range(p):\n a0 = a[i + offset]\n a1 = a[i + offset + p] * rot\n a2 = a[i + offset + p * 2] * rot2\n a3 = a[i + offset + p * 3] * rot3\n a1na3imag = (a1 - a3) % MOD * IMAG\n a[i + offset] = (a0 + a2 + a1 + a3) % MOD\n a[i + offset + p] = (a0 + a2 - a1 - a3) % MOD\n a[i + offset + p * 2] = (a0 - a2 + a1na3imag) % MOD\n a[i + offset + p * 3] = (a0 - a2 - a1na3imag) % MOD\n rot *= rate3[(~s & -~s).bit_length()]\n rot %= MOD\n le += 2\n\ndef butterfly_inv(a):\n n = len(a)\n h = (n - 1).bit_length()\n le = h\n while le:\n if le == 1:\n p = 1 << (h - le)\n irot = 1\n for s in range(1 << (le - 1)):\n offset = s << (h - le + 1)\n for i in range(p):\n l = a[i + offset]\n r = a[i + offset + p]\n a[i + offset] = (l + r) % MOD\n a[i + offset + p] = (l - r) * irot % MOD\n irot *= irate2[(~s & -~s).bit_length()]\n irot %= MOD\n le -= 1\n else:\n p = 1 << (h - le)\n irot = 1\n for s in range(1 << (le - 2)):\n irot2 = irot * irot % MOD\n irot3 = irot2 * irot % MOD\n offset = s << (h - le + 2)\n for i in range(p):\n a0 = a[i + offset]\n a1 = a[i + offset + p]\n a2 = a[i + offset + p * 2]\n a3 = a[i + offset + p * 3]\n a2na3iimag = (a2 - a3) * IIMAG % MOD\n a[i + offset] = (a0 + a1 + a2 + a3) % MOD\n a[i + offset + p] = (a0 - a1 + a2na3iimag) * irot % MOD\n a[i + offset + p * 2] = (a0 + a1 - a2 - a3) * irot2 % MOD\n a[i + offset + p * 3] = (a0 - a1 - a2na3iimag) * irot3 % MOD\n irot *= irate3[(~s & -~s).bit_length()]\n irot %= MOD\n le -= 2\n\ndef multiply(s, t):\n n = len(s)\n m = len(t)\n if min(n, m) <= 60:\n a = [0] * (n + m - 1)\n for i in range(n):\n if i % 8 == 0:\n for j in range(m):\n a[i + j] += s[i] * t[j]\n a[i + j] %= MOD\n else:\n for j in range(m):\n a[i + j] += s[i] * t[j]\n return [x % MOD for x in a]\n a = s.copy()\n b = t.copy()\n z = 1 << (n + m - 2).bit_length()\n a += [0] * (z - n)\n b += [0] * (z - m)\n butterfly(a)\n butterfly(b)\n for i in range(z):\n a[i] *= b[i]\n a[i] %= MOD\n butterfly_inv(a)\n a = a[:n + m - 1]\n iz = pow(z, MOD - 2, MOD)\n return [v * iz % MOD for v in a]\n\nn,k,f=map(int,input().split())\nmod=998244353\n\ndef dp(n):\n if n==1:\n return [1]*(k+1)\n bf=dp(n-1)\n res=[0]*(k+1)\n bf2=multiply(bf,bf)\n sbf2=[0]*(2*k+3)\n for i in range(2*k,-1,-1):\n sbf2[i]=(sbf2[i+1]+bf2[i])%mod\n if i>k:continue\n res[i]=sbf2[i+1]+bf2[i]*(k-i+1)\n res[i]%=mod\n return res\n\n\nans=dp(n)\nans=multiply(ans,ans)\nprint(ans[f] if f<=2*k else 0)\n\n"}], "negative_code": [], "src_uid": "4b8161259545e44c7d1046be2e4fe014"} {"source_code": "n, m = map(int, input().split())\nd = [2, 4] \nk = 10**9+7\nfor i in range(2, max(n, m)):\n d += [(d[i-1]+d[i-2]) % k]\nprint((d[m-1]+d[n-1]-2) % k)", "positive_code": [{"source_code": "n, m = map(int, input().split())\nq = 10 ** 9 + 7\na1 = [0] * n\na2 = [0] * n\nb1 = [0] * n\nb2 = [0] * n\na1[0] = 1\nb1[0] = 1\nfor i in range(1, n):\n a1[i] = b1[i - 1] + b2[i - 1]\n a2[i] = a1[i - 1]\n b1[i] = a1[i - 1] + a2[i - 1]\n b2[i] = b1[i - 1]\n a1[i] %= q\n a2[i] %= q\n b1[i] %= q\n b2[i] %= q\nans = (a1[n - 1] + a2[n - 1] + b1[n - 1] + b2[n - 1]) % q\na1 = [0] * m\na2 = [0] * m\nb1 = [0] * m\nb2 = [0] * m\na1[0] = 1\nb1[0] = 1\nfor i in range(1, m):\n a1[i] = b1[i - 1] + b2[i - 1]\n a2[i] = a1[i - 1]\n b1[i] = a1[i - 1] + a2[i - 1]\n b2[i] = b1[i - 1]\n a1[i] %= q\n a2[i] %= q\n b1[i] %= q\n b2[i] %= q\nans += a1[m - 1] + a2[m - 1] + b1[m - 1] + b2[m - 1]\nans %= q\nprint((q + ans - 2) % q)\n"}, {"source_code": "class ModComb:\n def __init__(self, MAX, mod=10 ** 9 + 7):\n fac = [1, 1]\n finv = [1, 1]\n inv = [0, 1]\n for i in range(2, MAX):\n fac.append(fac[i - 1] * i % mod)\n inv.append(mod - inv[mod % i] * (mod // i) % mod)\n finv.append(finv[i - 1] * inv[i] % mod)\n self.fac, self.finv, self.mod = fac, finv, mod\n\n def nCk(self, n, k):\n if n < k or n < 0 or k < 0:\n return 0\n fac, finv, mod = self.fac, self.finv, self.mod\n return fac[n] * (finv[k] * finv[n - k] % mod) % mod\n\ndef main():\n\n mod = 10 ** 9 + 7\n\n mc = ModComb(10 ** 5 + 7)\n\n N, M = map(int, input().split())\n\n ans = 0\n for i in range(1, N):\n ans += mc.nCk(N - i, i) % mod\n for i in range(1, M):\n ans += mc.nCk(M - i, i) % mod\n\n print((ans + 1) * 2 % mod)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,m=[int(x) for x in input().split()]\ndp=[0]*100001\ndp[0]=2\ndp[1]=2\ndp[2]=4\nfor i in range(3,100001):\n dp[i]=dp[i-1]*2-dp[i-3]\nprint((dp[n]+dp[m]-2)%(10**9+7))"}, {"source_code": "n,m=[int(x) for x in input().split()]\ndp=[0]*100001\ndp[0]=2\ndp[1]=2\ndp[2]=4\nfor i in range(3,100001):\n dp[i]=(dp[i-1]*2-dp[i-3])%(10**9+7)\nprint((dp[n]+dp[m]-2)%(10**9+7))\n"}, {"source_code": "MOD = 10 ** 9 + 7\nn, m = map(int, input().split())\nfib = [1] * (max(n, m) + 2)\nfor i in range(2, max(n, m) + 2):\n fib[i] = fib[i - 1] + fib[i - 2]\n fib[i] %= MOD\nprint(((fib[m] + fib[n]) * 2 - 2) % MOD)"}, {"source_code": "a,b=map(int,input().split())\nt=max(a,b)\nj=min(a,b)\na,b=t,j\ndp=[2,4]\nfor i in range(2,a+1):\n dp.append(0)\nif a<3:\n row=dp[a-1]\nelse:\n for i in range(2,a):\n\n dp[i]=dp[i-1]+dp[i-2]\n # print(dp)\n row=dp[a-1]\n\n# dp=[row,row+2]\n# for i in range(2,b+1):\n# dp.append(0)\n# if b<3:\n# row=dp[b-1]\n# else:\n# for i in range(2,b):\n# dp[i]=dp[i-1]+dp[i-2] \n# row=dp[b-1]\nif b-2<0:\n print(row%(10**9+7))\nelse:\n print((row+dp[b-1]-2)%(10**9+7))\n\n"}, {"source_code": "m, n = list(map(int, input().split()))\nmm = max(m, n)\ndp = [0]*(mm+1)\ndp[0]=1\ndp[1]=1\nfor i in range(2, mm+1):\n dp[i] = (dp[i-1] + dp[i-2])%(10**9+7)\nprint(((dp[m]+dp[n]-1)*2) % (10**9+7))"}, {"source_code": "mod=10**9+7\nn,m=map(int,input().split())\nn,m=min(n,m),max(n,m)\ndp=[[[0,0] for j in range(2)] for i in range(m)]\ndp[0]=[[1,0],[1,0]]\nfor i in range(m-1):\n for j in range(2):\n for k in range(2):\n if j==0 and k==0:\n dp[i+1][j][1]+=dp[i][j][k]\n dp[i+1][j+1][0]+=dp[i][j][k]\n elif j==1 and k==0:\n dp[i+1][j][1]+=dp[i][j][k]\n dp[i+1][j-1][0]+=dp[i][j][k]\n elif j==0 and k==1:\n dp[i+1][j+1][0]+=dp[i][j][k]\n else:\n dp[i+1][j-1][0]+=dp[i][j][k]\n for j in range(2):\n for k in range(2):\n dp[i+1][j][k]%=mod\nans=-2\nfor j in range(2):\n for k in range(2):\n ans+=dp[m-1][j][k]\n ans%=mod\ndp2=[[[0,0] for j in range(2)] for i in range(n)]\ndp2[0]=[[1,0],[1,0]]\nfor i in range(n-1):\n for j in range(2):\n for k in range(2):\n if j==0 and k==0:\n dp2[i+1][j][1]+=dp2[i][j][k]\n dp2[i+1][j+1][0]+=dp2[i][j][k]\n elif j==1 and k==0:\n dp2[i+1][j][1]+=dp2[i][j][k]\n dp2[i+1][j-1][0]+=dp2[i][j][k]\n elif j==0 and k==1:\n dp2[i+1][j+1][0]+=dp2[i][j][k]\n else:\n dp2[i+1][j-1][0]+=dp2[i][j][k]\n for j in range(2):\n for k in range(2):\n dp2[i+1][j][k]%=mod\nfor j in range(2):\n for k in range(2):\n ans+=dp[n-1][j][k]\n ans%=mod\nprint(ans)"}, {"source_code": "mod=10**9+7\nn,m=map(int,input().split())\n#n,m=min(n,m),max(n,m)\ndp=[[[0,0] for j in range(2)] for i in range(m)]\ndp[0]=[[1,0],[1,0]]\nfor i in range(m-1):\n for j in range(2):\n for k in range(2):\n if j==0 and k==0:\n dp[i+1][j][1]+=dp[i][j][k]\n dp[i+1][j+1][0]+=dp[i][j][k]\n elif j==1 and k==0:\n dp[i+1][j][1]+=dp[i][j][k]\n dp[i+1][j-1][0]+=dp[i][j][k]\n elif j==0 and k==1:\n dp[i+1][j+1][0]+=dp[i][j][k]\n else:\n dp[i+1][j-1][0]+=dp[i][j][k]\n for j in range(2):\n for k in range(2):\n dp[i+1][j][k]%=mod\nans=-2\nfor j in range(2):\n for k in range(2):\n ans+=dp[m-1][j][k]\n ans%=mod\ndp2=[[[0,0] for j in range(2)] for i in range(n)]\ndp2[0]=[[1,0],[1,0]]\nfor i in range(n-1):\n for j in range(2):\n for k in range(2):\n if j==0 and k==0:\n dp2[i+1][j][1]+=dp2[i][j][k]\n dp2[i+1][j+1][0]+=dp2[i][j][k]\n elif j==1 and k==0:\n dp2[i+1][j][1]+=dp2[i][j][k]\n dp2[i+1][j-1][0]+=dp2[i][j][k]\n elif j==0 and k==1:\n dp2[i+1][j+1][0]+=dp2[i][j][k]\n else:\n dp2[i+1][j-1][0]+=dp2[i][j][k]\n for j in range(2):\n for k in range(2):\n dp2[i+1][j][k]%=mod\nfor j in range(2):\n for k in range(2):\n ans+=dp2[n-1][j][k]\n ans%=mod\nprint(ans)"}, {"source_code": "a,b = map(int, input(). split())\nif a==1 and b==1:\n print(2)\nelse:\n d = max(a,b)*[0]\n d[0] = 1\n d[1] = 2\n for i in range(2,len(d)):\n d[i] = (d[i-1]+d[i-2])\n print(2*(d[a-1]+d[b-1]-1)%(10**9+7))"}, {"source_code": "N, M = map(int, input().split())\nP = 10**9+7\nF = [1, 2]\nfor i in range(max(N,M)):\n F.append((F[-1]+F[-2])%P)\nprint((F[N-1]+F[M-1]-1)*2%P)"}, {"source_code": "arr = [2,4]\nn,m = map(int,input().split(\" \"))\nfor i in range(2,max(n,m)):\n arr.append(arr[i-1]+arr[i-2])\nprint((arr[n-1]+arr[m-1]-2)%(10**9+7))"}, {"source_code": "mod=pow(10,9)+7\ndp=[1,1]\nfor i in range(100005):\n dp.append((dp[-1]%mod + dp[-2]%mod )%mod)\nn,m=map(int,input().split())\nprint((2*(dp[n]+dp[m]-1)%mod)%mod)"}, {"source_code": "n, m = map(int, input().split())\nmod = 10**9+7\na = []\na.append(0)\na.append(2)\na.append(4)\nfor i in range(3, max(n, m)+1):\n a.append((a[i-1]+a[i-2])%mod)\nprint((a[m]-2 + a[n])%mod)"}, {"source_code": "n, m = [int(x) for x in input().split()]\np = 10 ** 9 + 7\n\nx = [0] * max(n, m)\nx[0:1] = [1, 2]\nfor i in range(2, max(n, m)):\n x[i] = (x[i - 1] + x[i - 2]) % p\n\nprint(2 * (x[n - 1] + x[m - 1] - 1) % p)"}, {"source_code": "# maa chudaaye duniya\nfib = [0, 1]\nfor i in range(2, 100002):\n fib.append(fib[i-1]+fib[i-2])\n# print(fib[:10])\nn, m = map(int, input().split())\nans = 2*(fib[n+1] + fib[m+1] - 1)\nprint(ans%(10**9 + 7))"}, {"source_code": "N, M = map(int, input().split())\nP = 10**9+7\nF = [1, 2]\nfor i in range(101010):\n F.append((F[-1]+F[-2])%P)\nprint((F[N-1]+F[M-1]-1)*2%P)\n\n"}, {"source_code": "M = 10**9+7\nf = [1, 1, 2]\nfor i in range(1, 10**5+3):\n f.append((f[-1]+f[-2]) % M)\n\nn, m = map(int, input().split())\nans = 2*f[n] % M\nans += 2*(f[m]-1)\nans %= M\nprint(ans)\n"}, {"source_code": "n,m=map(int,input().split())\na=[0]*100001\nMod=1000000007\na[1],a[2]=2,4\nfor i in range(3,max(n,m)+1):\n a[i]=(a[i-1]+a[i-2])%Mod\nprint((a[n]+a[m]-2)%Mod,flush=False)"}, {"source_code": "n,m=map(int,input().split())\na=[0]*100001\n_,a[1],a[2],i=1000000007,2,4,3\nwhile i<=max(n,m):a[i]=a[i-1]+a[i-2];i+=1\nprint((a[n]+a[m]-2)%_)"}, {"source_code": "n, m = list(map(int, input().split()))\nmax_element = max(n, m)\nmin_element = min(n, m)\ndp = [2 for i in range(max_element+1)]\nfor i in range(2, max_element + 1):\n dp[i] = dp[i - 1] + dp[i - 2]\nprint((dp[max_element] + dp[min_element] - 2) % (10 ** 9 + 7))"}, {"source_code": "n,m = map(int,input().split())\nmd = 10**9+7\ndp = [-1 for i in range(10**5+1)]\ndp[:3] = [0,1,2]\nfor i in range(3,10**5+1):\n dp[i] = (dp[i-1]%md + dp[i-2]%md)%md\n\nprint((2*(dp[n]+dp[m]-1))%md)"}, {"source_code": "r, c = [int(i) for i in input().split()]\n\nimport operator as op\nfrom functools import reduce, lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n\tif n == 0 or n == 1:\n\t\treturn n\n\telse:\n\t\treturn fib(n-1)+fib(n-2)\n\n@lru_cache(maxsize=None)\ndef fibSum(n):\n\t# if n == 1:\n\t# \treturn 0\n\t# return fibSum(n-1) + fib(n-1)\n\tcount = 0\n\tfor i in range(1, n):\n\t\tcount+=fib(i)\n\treturn count\n\n\n@lru_cache(maxsize=None)\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer // denom\n\n\n\n\n\n \nf = [0,1] \nfor i in range(2, max(r,c)+2):\n f.append(f[i-1] + f[i-2]) \n f[i] %= 1000000007\n\ncount = 1\ncount += f[r+1]-1\ncount += f[c+1]-1\n\n# count += fibSum(r)\n# count += fibSum(c)\n\n\n# for t in range(1, c//2+1):\n# \tcount += ncr(c-t, t)\n# count %= 1000000007\n# for t in range(1, r//2+1):\n# \tcount += ncr(r-t, t)\n\n\n\ncount *= 2\ncount %= 1000000007\nprint(int(count))"}, {"source_code": "from sys import stdin\nfrom collections import deque\n# https://codeforces.com/contest/1354/status/D\nmod = 10**9 + 7\nimport sys\nimport random\n# sys.setrecursionlimit(10**6)\nfrom queue import PriorityQueue\n# def rl():\n# return [int(w) for w in stdin.readline().split()]\nfrom bisect import bisect_right\nfrom bisect import bisect_left\nfrom collections import defaultdict\nfrom math import sqrt,factorial,gcd,log2,inf,ceil\n# map(int,input().split())\n# # l = list(map(int,input().split()))\n# from itertools import permutations\nimport heapq\n# input = lambda: sys.stdin.readline().rstrip()\ninput = lambda : sys.stdin.readline().rstrip()\nfrom sys import stdin, stdout\nfrom heapq import heapify, heappush, heappop\nfrom itertools import permutations\nfrom math import factorial as f\n\n# def ncr(x, y):\n# return f(x) // (f(y) * f(x - y))\ndef ncr(n, r, p):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\n\nimport sys\n\n# input = sys.stdin.readline\n# LCA\n# def bfs(na):\n#\n# queue = [na]\n# boo[na] = True\n# level[na] = 0\n#\n# while queue!=[]:\n#\n# z = queue.pop(0)\n#\n# for i in hash[z]:\n#\n# if not boo[i]:\n#\n# queue.append(i)\n# level[i] = level[z] + 1\n# boo[i] = True\n# dp[i][0] = z\n#\n#\n#\n# def prec(n):\n#\n# for i in range(1,20):\n#\n# for j in range(1,n+1):\n# if dp[j][i-1]!=-1:\n# dp[j][i] = dp[dp[j][i-1]][i-1]\n#\n#\n# def lca(u,v):\n# if level[v] < level[u]:\n# u,v = v,u\n#\n# diff = level[v] - level[u]\n#\n#\n# for i in range(20):\n# if ((diff>>i)&1):\n# v = dp[v][i]\n#\n#\n# if u == v:\n# return u\n#\n#\n# for i in range(19,-1,-1):\n# # print(i)\n# if dp[u][i] != dp[v][i]:\n#\n# u = dp[u][i]\n# v = dp[v][i]\n#\n#\n# return dp[u][0]\n#\n# dp = []\n#\n#\n# n = int(input())\n#\n# for i in range(n + 10):\n#\n# ka = [-1]*(20)\n# dp.append(ka)\n\n\n# class FenwickTree:\n# def __init__(self, x):\n# \"\"\"transform list into BIT\"\"\"\n# self.bit = x\n# for i in range(len(x)):\n# j = i | (i + 1)\n# if j < len(x):\n# x[j] += x[i]\n#\n# def update(self, idx, x):\n# \"\"\"updates bit[idx] += x\"\"\"\n# while idx < len(self.bit):\n# self.bit[idx] += x\n# idx |= idx + 1\n#\n# def query(self, end):\n# \"\"\"calc sum(bit[:end])\"\"\"\n# x = 0\n# while end:\n# x += self.bit[end - 1]\n# end &= end - 1\n# return x\n#\n# def find_kth_smallest(self, k):\n# \"\"\"Find largest idx such that sum(bit[:idx]) <= k\"\"\"\n# idx = -1\n# for d in reversed(range(len(self.bit).bit_length())):\n# right_idx = idx + (1 << d)\n# if right_idx < len(self.bit) and k >= self.bit[right_idx]:\n# idx = right_idx\n# k -= self.bit[idx]\n# return idx + 1\n\n\n\n# import sys\n# def rs(): return sys.stdin.readline().strip()\n# def ri(): return int(sys.stdin.readline())\n# def ria(): return list(map(int, sys.stdin.readline().split()))\n# def prn(n): sys.stdout.write(str(n))\n# def pia(a): sys.stdout.write(' '.join([str(s) for s in a]))\n#\n#\n# import gc, os\n#\n# ii = 0\n# _inp = b''\n#\n#\n# def getchar():\n# global ii, _inp\n# if ii >= len(_inp):\n# _inp = os.read(0, 100000)\n# gc.collect()\n# ii = 0\n# if not _inp:\n# return b' '[0]\n# ii += 1\n# return _inp[ii - 1]\n#\n#\n# def input():\n# c = getchar()\n# if c == b'-'[0]:\n# x = 0\n# sign = 1\n# else:\n# x = c - b'0'[0]\n# sign = 0\n# c = getchar()\n# while c >= b'0'[0]:\n# x = 10 * x + c - b'0'[0]\n# c = getchar()\n# if c == b'\\r'[0]:\n# getchar()\n# return -x if sign else x\n\n# fenwick Tree\n\n# n,q = map(int,input().split())\n#\n#\n# l1 = list(map(int,input().split()))\n#\n# l2 = list(map(int,input().split()))\n#\n# bit = [0]*(10**6 + 1)\n#\n# def update(i,add,bit):\n#\n# while i>0 and i<len(bit):\n#\n# bit[i]+=add\n# i = i + (i&(-i))\n#\n#\n# def sum(i,bit):\n# ans = 0\n# while i>0:\n#\n# ans+=bit[i]\n# i = i - (i & ( -i))\n#\n#\n# return ans\n#\n# def find_smallest(k,bit):\n#\n# l = 0\n# h = len(bit)\n# while l<h:\n#\n# mid = (l+h)//2\n# if k <= sum(mid,bit):\n# h = mid\n# else:\n# l = mid + 1\n#\n#\n# return l\n#\n#\n# def insert(x,bit):\n# update(x,1,bit)\n#\n# def delete(x,bit):\n# update(x,-1,bit)\n# fa = set()\n#\n# for i in l1:\n# insert(i,bit)\n#\n#\n# for i in l2:\n# if i>0:\n# insert(i,bit)\n#\n# else:\n# z = find_smallest(-i,bit)\n#\n# delete(z,bit)\n#\n#\n# # print(bit)\n# if len(set(bit)) == 1:\n# print(0)\n# else:\n# for i in range(1,n+1):\n# z = find_smallest(i,bit)\n# if z!=0:\n# print(z)\n# break\n#\n\n# service time problem\n\n\n# def solve2(s,a,b,hash,z,cnt):\n# temp = cnt.copy()\n# x,y = hash[a],hash[b]\n# i = 0\n# j = len(s)-1\n#\n# while z:\n#\n# if s[j] - y>=x-s[i]:\n# if temp[s[j]]-1 == 0:\n# j-=1\n# temp[s[j]]-=1\n# z-=1\n#\n#\n# else:\n# if temp[s[i]]-1 == 0:\n# i+=1\n#\n# temp[s[i]]-=1\n# z-=1\n#\n# return s[i:j+1]\n#\n#\n#\n#\n#\n# def solve1(l,s,posn,z,hash):\n#\n# ans = []\n# for i in l:\n# a,b = i\n# ka = solve2(s,a,b,posn,z,hash)\n# ans.append(ka)\n#\n# return ans\n#\n# def consistent(input, window, min_entries, max_entries, tolerance):\n#\n# l = input\n# n = len(l)\n# l.sort()\n# s = list(set(l))\n# s.sort()\n#\n# if min_entries<=n<=max_entries:\n#\n# if s[-1] - s[0]<window:\n# return True\n# hash = defaultdict(int)\n# posn = defaultdict(int)\n# for i in l:\n# hash[i]+=1\n#\n# z = (tolerance*(n))//100\n# poss_window = set()\n#\n#\n# for i in range(len(s)):\n# posn[i] = l[i]\n# for j in range(i+1,len(s)):\n# if s[j]-s[i] == window:\n# poss_window.add((s[i],s[j]))\n#\n# if poss_window!=set():\n# print(poss_window)\n# ans = solve1(poss_window,s,posn,z,hash)\n# print(ans)\n#\n#\n# else:\n# pass\n#\n# else:\n# return False\n#\n#\n#\n#\n# l = list(map(int,input().split()))\n#\n# min_ent,max_ent = map(int,input().split())\n# w = int(input())\n# tol = int(input())\n# consistent(l, w, min_ent, max_ent, tol)\n\n# t = int(input())\n#\n# for i in range(t):\n#\n# n,x = map(int,input().split())\n#\n# l = list(map(int,input().split()))\n#\n# e,o = 0,0\n#\n# for i in l:\n# if i%2 == 0:\n# e+=1\n# else:\n# o+=1\n#\n# if e+o>=x and o!=0:\n# z = e+o - x\n# if z == 0:\n# if o%2 == 0:\n# print('No')\n# else:\n# print('Yes')\n# continue\n# if o%2 == 0:\n# o-=1\n# z-=1\n# if e>=z:\n# print('Yes')\n# else:\n# z-=e\n# o-=z\n# if o%2!=0:\n# print('Yes')\n# else:\n# print('No')\n#\n# else:\n#\n# if e>=z:\n# print('Yes')\n# else:\n# z-=e\n# o-=z\n# if o%2!=0:\n# print('Yes')\n# else:\n# print('No')\n# else:\n# print('No')\n#\n#\n#\n#\n#\n#\n#\n# def dfs(n):\n# boo[n] = True\n# dp2[n] = 1\n# for i in hash[n]:\n# if not boo[i]:\n#\n# dfs(i)\n# dp2[n] += dp2[i]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# def search(k,l,low):\n#\n# high = len(l)-1\n# z = bisect_left(l,k,low,high)\n#\n# return z\n#\n#\n#\n#\n#\n#\n# n,x = map(int,input().split())\n#\n# l = list(map(int,input().split()))\n#\n# prefix = [0]\n# ha = [0]\n# for i in l:\n# prefix.append(i + prefix[-1])\n# ha.append((i*(i+1))//2 + ha[-1])\n# fin = 0\n# print(prefix)\n# for i in range(n):\n# ans = 0\n# if l[i]<x:\n#\n#\n# if prefix[-1]-prefix[i]>=x:\n#\n# z = search(x+prefix[i],prefix,i+1)\n# print(z)\n# z+=i+1\n# k1 = x-(prefix[z-1]-prefix[i])\n# ans+=ha[z-1]\n# ans+=(k1*(k1+1))//2\n#\n#\n# else:\n# z1 = x - (prefix[-1]-prefix[i])\n# z = search(z1,prefix,1)\n#\n# k1 = x-prefix[z-1]\n# ans+=ha[z-1]\n# ans+=(k1*(k1+1))//2\n#\n#\n#\n#\n# elif l[i]>x:\n# z1 = ((l[i])*(l[i]+1))//2\n# z2 = ((l[i]-x)*(l[i]-x+1))//2\n# ans+=z1-z2\n# else:\n# ans+=(x*(x+1))//2\n\n\n\nmod = 10**9 + 7\nn,m = map(int,input().split())\ndp = [1,1,2,3]\nfor i in range(n+m+1):\n dp.append(dp[-1]+dp[-2])\n dp[-1]%=mod\n\nprint((2*(dp[n] + dp[m] - 1))%mod)\n\n\n\n\n\n\n\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\nFib = [0 for i in range(max(n, m) + 2)]\nFib[1] = 1\nfor i in range(2,max(n, m) + 2):\n Fib[i] = (Fib[i - 1] + Fib[i - 2]) % 1000000007\nprint(((Fib[n + 1] + Fib[m + 1] - 1)*2) % 1000000007)\n"}, {"source_code": "mod=10**9+7\nf=[1]*100001\nfor i in range(2,100001):\n f[i]=(f[i-1]+f[i-2])%mod\nn,m=map(int,input().split())\nprint(2*(f[n]+f[m]-1)%mod)"}, {"source_code": "n,m=map(int,input().split())\nfib=[1,2]\nmod=10**9+7\nfor i in range(max(n,m)-2):\n\tfib.append(fib[-1]+fib[-2])\n\tif fib[-1]>=mod:\n\t\tfib[-1]%=mod\nprint((2*(fib[n-1]%mod+fib[m-1]%mod)-2)%mod)\n"}, {"source_code": "n,m = map(int,input().split())\nF = [0 for _ in range(100005)]\nF[1] = 1\nF[2] = 2\nfor i in range(3, max(n,m)+1):\n F[i] = (F[i-1]+F[i-2])%1000000007\nprint((2*(F[n]+F[m]-1)+1000000007)%1000000007)"}, {"source_code": "import os\nimport heapq\nimport sys\nimport math\nimport bisect\nimport operator\nfrom collections import defaultdict\nfrom io import BytesIO, IOBase\ndef gcd(a,b):\n if b==0:\n\n return a\n else:\n return gcd(b,a%b)\ndef power(x, p,m):\n res = 1\n while p:\n if p & 1:\n res = (res * x) % m\n x = (x * x) % m\n p >>= 1\n return res\ndef inar():\n return [int(k) for k in input().split()]\n\n\n# def bubbleSort(arr,b):\n# n = len(arr)\n# for i in range(n):\n# for j in range(0, n - i - 1):\n# if arr[j] > arr[j + 1] and b[j]!=b[j+1]:\n# arr[j], arr[j + 1] = arr[j + 1], arr[j]\n# b[j],b[j+1]=b[j+1],b[j]\ndef lcm(num1,num2):\n return (num1*num2)//gcd(num1,num2)\n\ndef main():\n #for _ in range(int(input())):\n # n=int(input())\n # st=list(input())\n # ans=0\n # index=[1,1]\n # op=0\n # cl=0\n # for i in range(n):\n # if st[i]==\"(\":\n # op+=1\n # else:\n # cl+=1\n # if op==cl:\n # for i in range(n):\n # for j in range(i+1,n):\n # prefix=[]\n # cnt=0\n # tem=st[i]\n # st[i]=st[j]\n # st[j]=tem\n # for k in range(n):\n # if st[i]==\"(\":\n # cnt+=1\n # prefix.append(cnt)\n # else:\n # cnt-=1\n # prefix.append(cnt)\n # res=min(prefix)\n # take=prefix.count(res)\n # if ans<(take):\n # index=[i+1,j+1]\n # ans=take\n # tem=st[i]\n # st[i]=st[j]\n # st[j]=tem\n # print(ans)\n # print(*index)\n #\n #\n #\n # else:\n # print(ans)\n # print(*index)\n #\n #\n n,m=inar()\n dp=[0]*100100\n mod=10**9+7\n dp[1]=2\n dp[2]=4\n length=max(n,m)\n for i in range(3,100100):\n dp[i]=(dp[i-1]+dp[i-2])%mod\n print((dp[n]-2+dp[m])%mod)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,m=map(int,input().strip().split())\n#print(n,m)\nif n>m:\n\tlen=n\nelse:\n\tlen=m\nf=[1,1]\nfor i in range(len):\n\tx=(f[i]+f[i+1])%1000000007\n\tf.append(x)\nprint((f[n]+f[m]-1)*2%1000000007)\n\n\"\"\"\n2 3\n\"\"\"\n"}, {"source_code": "n, m = map(int,input().split())\n\ndef create_dp(x):\n dp = [0 for _ in range(x)]\n dp[0] = 1\n if x == 1:\n return dp\n dp[1] = 2\n if x == 2:\n return dp\n \n for i in range(2,x):\n dp[i] = dp[i-1] + dp[i-2]\n dp[i] %= MOD\n \n return dp\n\nMOD = 10**9+7\n\ncut_pattern = 0\n\ndp = create_dp(max(n,m))\ncut_pattern += dp[n-1]*2\ncut_pattern += dp[m-1]*2\n\ncut_pattern -= 2\n\ncut_pattern %= MOD\n\nprint(cut_pattern)"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\n\n\ndef read_i():\n return list(map(int, input().split()))\n\n\nclass Combinations:\n def __init__(self, max_num, mod):\n self.mod = mod\n self.factorials = [1]\n for i in range(1, max_num + 1):\n self.factorials.append((self.factorials[-1] * i) % mod)\n self.invs = [pow(self.factorials[-1], mod - 2, mod)]\n for i in reversed(range(1, max_num + 1)):\n self.invs.append(self.invs[-1] * i % mod)\n self.invs = self.invs[::-1]\n\n def __call__(self, n, k):\n return self.factorials[n] * self.invs[k] * self.invs[n - k] % self.mod\n\n\nn, m = read_i()\nMOD = 10**9 + 7\ncombinations = Combinations(max(n, m), MOD)\nres = 0\nfor i in range(n // 2 + 1):\n res += combinations(n - i, i)\n res %= MOD\nfor i in range(m // 2 + 1):\n res += combinations(m - i, i)\n res %= MOD\nres = 2 * (res - 1 + MOD) % MOD\nprint(res)"}, {"source_code": "def patate(l):\n\tn = lst[0]\n\tm = lst[1]\n\tresultat = (fibo(n) + fibo(m) - 1)*2\n\tprint(resultat % 1000000007)\n\ndef fibo(n):\n\tif n == 0:\n\t\treturn(1)\n\tif n == 1:\n\t\treturn(1)\n\tif n % 2 == 0:\n\t\treturn(fibo(n/2)**2 + fibo(n/2 -1)**2)\n\ta = fibo((n-1)/2)\n\tb = fibo((n-1)/2 -1)\n\treturn(a*(2*b + a))\n\n\nif __name__ == '__main__':\n\tlst = list(map(int, input().split()))\n\tpatate(lst)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\n\nif n == 1 and m == 1:\n print(2)\n exit()\n \nMOD = 10**9+7\nN = max(n, m)\ndp = [[0] * 4 for _ in range(N+1)]\n\nfor j in range(4):\n dp[2][j] = 1\n\nfor i in range(2, N):\n dp[i+1][0] = dp[i][2]\n dp[i+1][1] = dp[i][0]+dp[i][2]\n dp[i+1][2] = dp[i][1]+dp[i][3]\n dp[i+1][3] = dp[i][1]\n \n for j in range(4):\n dp[i+1][j] %= MOD\n\nif n == 1:\n print(sum(dp[m])%MOD)\nelif m == 1:\n print(sum(dp[n])%MOD)\nelse:\n print((sum(dp[n])+sum(dp[m])-2)%MOD)"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\n\nFibArray = [0, 1]\ndef fib(n):\n if n <= len(FibArray):\n return FibArray[n - 1]\n else:\n temp_fib = fib(n - 1) + fib(n - 2)\n FibArray.append(temp_fib)\n return temp_fib\n\ndef count(n, k):\n total = k\n mod = 10**9 + 7\n same, diff = 0, k\n for i in range(2, n + 1):\n same = diff\n diff = total * (k - 1)\n diff = diff % mod\n total = (same + diff) % mod\n return total\n\nmod = 10**9 + 7\nn, m = mi()\nprint((count(m, 2) + count(n, 2) - 2) % mod)\n\n"}, {"source_code": "l = [0] * (10**6 + 1)\nl[2] = 2\nmod = 10**9 + 7\nn, m = [int(i) for i in input().split()]\nfor i in range(3, max(m, n) + 1):\n l[i] = (l[i - 1] + l[i - 2]) % mod\nres = 0\nfor i in range(n + 1):\n res += l[i]\nfor j in range(m + 1):\n res += l[j]\nprint((2 + res) % mod)\n"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\ndef fib(n):\n a, b = 1, 1\n for i in range(n):\n a, b = b, (a + b) % 1000000007\n\n return a\n\nres1 = 2 * (fib(n) + fib(m) - 1) % 1000000007\nprint(res1)\n\n"}, {"source_code": "n,m = map(int, input().split())\nl = list()\nl.append(1)\nl.append(1)\nfor i in range(2,100001):\n l.append((l[i-2]+l[i-1])%(10**9+7))\nprint(2*(l[n]+l[m]-1)%(10**9+7))"}, {"source_code": "n, m = map(int, input().split())\nmodulo = 10 ** 9 + 7\ncombs = 0\nr = 1\nr_next = 2\nfor i in range(3, n + 1):\n r, r_next = r_next, (r + r_next) % modulo\ncombs += r_next if n > 1 else 1\nc = 1\nc_next = 2\nfor j in range(3, m + 1):\n c, c_next = c_next, (c + c_next) % modulo\ncombs += c_next if m > 1 else 1\ncombs -= 1\ncombs *= 2\nprint(combs % modulo)\n"}, {"source_code": "P = 10 ** 9 + 7\nn, m = tuple([int(x) for x in input().split()])\n\nmx = max(n, m)\nvals = []\nfor i in range(mx):\n if i == 0 or i == 1:\n vals.append(i+1)\n \n else:\n new_val = (vals[-1] + vals[-2]) % P\n vals.append(new_val)\n\n\nx = (vals[n-1] + vals[m-1]) % P\nx = (x - 1) % P\nx = (x * 2) % P\n\nprint(x)"}, {"source_code": "n, m = [int(i) for i in input().split()]\nf = [1, 1]\nmod = 1000000007\n# c1 = 9 * pow(4, mod - 2, mod)\n# c2 = 3 * pow(2, mod - 2, mod)\nfor i in range(100005):\n f.append((f[-1] + f[-2])%mod)\n\n# # # print(f[:20])\n\n# if n < 3 or m < 3:\n# if n < m:\n# n, m = m, n\n# if m == 1:\n# ans = 2 * f[n]\n# else:\n# ans = 2 + 2 * f[n]\n \n# elif n & 1:\n# 1+''\n# n, m = m, n\n\n# ans = pow(2 * f[n-1], m//2 - 1, mod) * pow(2 * f[n+1], 2, mod) * pow(2, m//2 - 2, mod)\n \n# else:\n# M = n // 2 - 1\n# l = m - 1\n# 1 + ''\n# ans = pow(2, M+1, mod) * c2 * pow(f[l], M, mod) * (2 + 2*f[l+1])\n\n\nans2 = 2*f[m] + 2*f[n] - 2\n\n# print(ans%mod)\nprint(ans2%mod)\n\n\n"}, {"source_code": "MOD=1000000007\nn,m=map(int,input().split())\nL=[1,2,3,5,8,14,21,34,55,89]\nfor i in range(n):\n t=(L[-1]+L[-2])%MOD\n L.append(t%MOD)\n#print(L)\ndp=[]\ndp.append((L[n-1]*2)%MOD)\nfor i in range(2):\n t=(dp[-1]+2)%MOD\n dp.append(t%MOD)\n\nfor i in range(m):\n t1=(2*dp[-1])%MOD\n t2=dp[-3]%MOD\n t=(t1-t2)%MOD\n dp.append(t%MOD)\n#print(dp)\nprint(dp[m-1]%MOD)\n"}, {"source_code": "n,m=map(int,input().split())\na=[]\nfor i in range(100001):\n a.append(0)\na[0]=0\na[1]=2\na[2]=4\nfor i in range(3,100001):\n a[i]=(a[i-1]%1000000007+a[i-2]%1000000007)%1000000007\nprint((a[n]%1000000007+a[m]%1000000007-2)%1000000007)"}, {"source_code": "mod = 1e9 + 7\nn, m = list(map(int, input(\"\").split()))\ndp = [[[-1 for i in range(3)] for j in range(3)] for k in range(100005)]\n\ndp[1] = 2\ndp[2] = 4\n\nfor i in range(3, max(n, m)+2):\n dp[i] = (dp[i-1]+dp[i-2])%mod\n\nans = int((dp[n] + dp[m] -2) % mod)\nprint(ans)"}, {"source_code": "'''input\n3 6\n'''\nimport sys\nfrom collections import defaultdict as dd\nfrom itertools import permutations as pp\nfrom itertools import combinations as cc\nfrom collections import Counter as ccd\nfrom random import randint as rd\nfrom bisect import bisect_left as bl\nfrom heapq import heappush as hpush\nfrom heapq import heappop as hpop\nmod=10**9+7\n\ndef ri(flag=0):\n\tif flag==0:\n\t\treturn [int(i) for i in sys.stdin.readline().split()]\n\telse:\n\t\treturn int(sys.stdin.readline())\n\nn , m = ri()\n\nif n<m:\n\tn,m = m,n\n\nif n==1 and m==1:\n\tprint(2)\n\tsys.exit(0)\n\n\nf =[1,1]\n\nN = 10**5+10\n\nfor i in range(N):\n\tf.append(f[-1]+f[-2])\n\tf[-1]%=mod\n\nl = [1,3]\n\nfor i in range(N):\n\tl.append(l[-1]+l[-2])\n\tl[-1]%=mod\n\n\n\nans = f[m-1]+l[m-1] + 3*f[n-2] +l[n-2] -2\nans = ans%mod\n\nprint(ans)"}, {"source_code": "MOD = 1000000007\nn, m = list(map(int, input().split()))\nmx = max(n, m)\ndp = [0] * mx\ndp[0] = 2\nif mx >= 2:\n dp[1] = 4\n\nfor i in range(2, mx):\n dp[i] = (dp[i-1] + dp[i-2]) % MOD\n\nans = (dp[n-1] + dp[m-1] - 2) % MOD\nprint(int(ans))\n"}, {"source_code": "MOD = 10 ** 9 + 7\n\ndef get(t, n):\n if n == 1:\n return t\n\n a, b = t, 2 * t\n\n for i in range(n - 2):\n a, b = b, (a + b) % MOD\n\n return b\n\n\nn, m = map(int, input().split())\n\nans = 0\nans += get(2, n)\nans += get(2, m)\nans -= 2\n\nprint(ans % MOD)\n"}, {"source_code": "n, m = map(int, input().split())\nf = [0] * 100010\nf[0] = f[1] = 1\nP = int(1e9 + 7)\nfor i in range(2,100001):\n f[i] = (f[i - 1] + f[i - 2]) % P\nprint((f[n] + f[m] - 1) * 2 % P)\n"}, {"source_code": "def mi():\n return map(int, input().split())\nmod = 10**9+7\n'''\n2 3\n10\n()()())(()\n'''\n'''\nn = int(input())\na = list(input())\n\ndp = [[0]*n for i in range(n)]\n\nfor i in range(n):\n for j in range(i+1, n):\n t = 0\n f = False\n temp=0\n for k in range(i,j+1):\n if a[k]=='(':\n t+=1\n else:\n t-=1\n if t<0:\n f = True\n elif t==0:\n temp+=1\n if not f:\n\n if a[i]\n\n\n\n'''\nn,m = mi()\na = 0\nb = 2\nn,m = min(m,n),max(m,n)\nfor i in range(m):\n c = a+b\n a = b\n b = c\nba=b\nb-=2\na = 0\nb = 2\nfor i in range(n):\n c = a+b\n a = b\n b = c\nba+=b-2\nba%=mod\nprint (ba)\n"}, {"source_code": "# def check(g):\n# for i in range(n):\n# for j in range(m):\n# c = g[i][j]\n# # print(i,j)\n# same = 0\n# if i>0:\n# if g[i-1][j]==c:\n# same += 1\n# if j>0:\n# if g[i][j-1]==c:\n# same += 1\n# if i<n-1:\n# if g[i+1][j]==c:\n# same += 1\n# if j<m-1:\n# if g[i][j+1]==c:\n# same += 1\n# if same>1:\n# return False\n# return True\n\n\n# n,m = 3,6\n# import numpy as np\n# import itertools\n# import copy\n# for n in range(1,7):\n# for m in range(1,4):\n# K = n\n# N = m\n# ans = 0\n\n# x = [np.reshape(np.array(i), (K, N)) for i in itertools.product([0, 1], repeat = K*N)]\n# for i in x:\n\n# ab = i.tolist()\n# if check(copy.deepcopy(ab)):\n# ans += 1\n\n# print(n,\"*\",m,\"-\",ans)\n\n'''\na = [[0 for _ in range(m)] for _i in range(n)]\n\nq = []\n\n\n\nimport copy\nq.append([copy.deepcopy(a),[0,0]])\nv = []\nans = 0\nwhile len(q)>0:\n b = q.pop(0)\n aa = b[0]\n ii = b[1]\n ni = []\n if ii[0]>=n or ii[1]>=m:\n continue\n if check(aa):\n ans += 1\n \n if ii[0]==n-1:\n ni = [0,ii[1]+1]\n else:\n ni = [ii[0]+1,ii[1]]\n \n if ni[0]>=n or ni[1]>=m:\n continue\n\n copy1 = copy.deepcopy(aa)\n copy1[ni[0]][ni[1]] = 1\n q.append([copy1,ni])\n q.append([copy.deepcopy(aa),ni])\n \n \nprint(ans)\n'''\nmd = 10**9 + 7\n\nn,m = map(int,input().split())\nif n==1 and m==1:\n print(2)\nelse:\n a = [0 for _ in range(max(n,m))]\n a[0] = 2%md\n a[1] = 4%md\n for i in range(2,max(n,m)):\n a[i] = (a[i-1]+a[i-2])%md\n\n\n b = [0 for _ in range(n)]\n b[0] = a[m-1]\n for i in range(1,n):\n x = 0 if i<=2 else i-2\n b[i] = (b[x]%md + a[i-1])%md\n\n print(b[-1])"}, {"source_code": "def main():\n mod = 1000000007\n a = [1,1,1]\n b = [1,1,1]\n c = [1,1,1]\n a[1] = 2\n a[2] = 4\n b[1] = 0\n b[2] = 2\n c[1] = 0\n c[2] = 2\n for i in range(3,100001):\n a.append(a[i-1]+a[i-2])\n a[i] %= mod\n b.append(b[i-1]+b[i-2])\n b[i] %= mod\n c.append((c[i-1]+b[i])%mod)\n\n n,m = input().split()\n n = int(n)\n m = int(m)\n print((a[n]+c[m])%mod)\n\nmain()"}, {"source_code": "n,m = list(map(int, input().split()))\n\nmod = 10**9+7\n\np1 = 2\np2 = 0\n\nans = 2\nn -= 1\nwhile n:\n ans = (ans+p1) % mod\n p1, p2 = (p1+p2)%mod, p1\n n-=1\n\np1 = 2\np2 = 0\nm -= 1\n\nwhile m:\n ans = (ans+p1) % mod\n p1, p2 = (p1+p2)%mod, p1\n m-=1\n\nprint(ans)\n\n\n"}, {"source_code": "mod = 1e9 + 7\nn, m = list(map(int, input(\"\").split()))\ndp = [[[-1 for i in range(3)] for j in range(3)] for k in range(100005)]\n\ndp[1] = 2\ndp[2] = 4\n\nfor i in range(3, max(n, m)+2):\n dp[i] = (dp[i-1]+dp[i-2])%mod\n\nans = int((dp[n] + dp[m] -2) % mod)\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nif n==1 and m==1:\n\tprint (2)\nelse:\n\tk1=max(n,m)\n\tk2=min(n,m)\n\tl=[2]*k1\n\tl[1]=4\n\tfor i in range(2,k1):\n\t\tl[i]=(l[i-1]+l[i-2])%1000000007\n\tans=l[k1-1]\n\tfor i in range(1,k2):\n\t\tans+=(l[i]-l[i-1])%1000000007\n\tprint (ans%1000000007)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# def calc(a,b,c):\n# \troot = (b**2-4*a*c)**(0.5)\n# \tnum = -b + (root)\n# \tdeno = 2*a\n# \treturn num/deno\n\n# t=int(input())\n# for nt in range(t):\n# \tn,s=map(int,input().split())\n# \tif n==1:\n# \t\tif s==0:\n# \t\t\tprint (1)\n# \t\telse:\n# \t\t\tprint (-1)\n# \telse:\n# \t\tif s!=0:\n# \t\t\tfor i in range(n-2):\n# \t\t\t\tprint (1,end=\" \")\n# \t\t\tprint (2,end=\" \")\n# \t\t\tprint (calc(n-1,-1*2*n,2*n-n*n*s*s))\n# \t\telse:\n# \t\t\tfor i in range(n):\n# \t\t\t\tprint (1,end=\" \")\n# \t\t\tprint ()"}, {"source_code": "import sys\nsys.setrecursionlimit(10**9)\nd = {}\nd[1] = 2\nd[2] = 4\nmod = pow(10,9) + 7\ndef cal(n):\n\ttry:\n\t\treturn d[n]\n\texcept:\n\t\tpass\n\tif n < 1:\n\t\treturn 0\n\tif (n == 1):\n\t\treturn 2\n\tfor i in range(3,n+1):\n\t\td[i] = (d[i-1] + d[i-2])%mod\n\treturn d[n]\n\n\n\n\nn,m = map(int,raw_input().split())\n\nif n == 1 and m == 1:\n\tprint 2\n\texit()\nif n == 1:\n\tprint cal(m)%mod\n\texit()\nif m == 1:\n\tprint cal(n)%mod\n\texit()\n\nprint (cal(n) + cal(m) - 2)%(mod)"}, {"source_code": "mod = 1000000007\nn,m = map(int, input().split())\n\n\ndef fib(n):\n a,b = 1,1\n for i in range(n):\n a,b = b,(a+b)%mod\n return a\n\nres = (2*(fib(n) + fib(m) - 1)) % mod\nprint(res)\n\n\n\n"}, {"source_code": "m = 10 ** 9 + 7\n\nmemo = {1: 0, 2: 2}\ndef d(n):\n if n not in memo:\n memo[n] = (d(n - 1) + d(n - 2) + 2) % m\n return memo[n]\nfor i in range(3, 100000):\n d(i)\n\na, b = map(int, input().split())\n# bruteforce(a, 1)\ni, j = 2, 4\np = 1\nwhile p < a:\n p += 1\n i, j = j, (i + j) % m\nstart1 = i\n# bruteforce(a, 2)\ni, j = 4, 6\np = 1\nwhile p < a:\n p += 1\n i, j = j, (i + j - 2) % m\nstart2 = i\n \ni, j = start1, start2\np = 1\nwhile p < b:\n p += 1\n i, j = j, (i + j - d(a)) % m\nprint ((i + m) % m)"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\ndef modulo_div(a, b, modulo):\n if b == 1:\n return a % modulo\n return (a + modulo_div(- a, modulo % b, b) * modulo) // b % modulo\n\nfor line in sys.stdin.readlines():\n inputs = line.split()\n n = int(inputs[0])\n m = int(inputs[1])\n\nnumer = 1\ndenom = 1\nsums = 0\nmodulo = 10 ** 9 + 7\nimport time\nfibonacci = [1, 1]\nfor i in range(max(n, m) + 1):\n fibonacci.append((fibonacci[- 1] + fibonacci[- 2]) % modulo)\nsums += (fibonacci[n] + fibonacci[m] - 1) * 2 % modulo\n#for k in range(1, (n + 2) // 2):\n# denom = denom * k * (n - k + 1) % modulo\n# numer = numer * (n - 2 * k + 1) * (n - 2 * k + 2) % modulo\n# sums = (sums + modulo_div(numer, denom, modulo)) % modulo\n#numer = 1\n#denom = 1\n#for k in range(1, (m + 2) // 2):\n# denom = denom * k * (m - k + 1) % modulo\n# numer = numer * (m - 2 * k + 1) * (m - 2 * k + 2) % modulo\n# sums = (sums + modulo_div(numer, denom, modulo)) % modulo\n\n#sums = sums * 2 % modulo\nprint(sums)\n"}, {"source_code": "from sys import stdin\n\n\ndef input():\n return stdin.readline()[:-1]\n\n\ndef intput():\n return int(input())\n\n\ndef sinput():\n return input().split()\n\n\ndef intsput():\n return map(int, sinput())\n\nmod = 10 ** 9 + 7\n\nn, m = intsput()\n\nfib = [2, 2]\n\nfor _ in range(100001):\n fib.append((fib[-1] + fib[-2]) % mod)\n\n\nprint((fib[n] + fib[m] - 2) % mod)\n"}, {"source_code": "from sys import stdin\ninp = stdin.readline\n\nn,m = [int(x) for x in inp().strip().split()]\n\na = [0] * 100001\na[1] = 1\na[0] = 1\nmod = (10**9+7)\nfor i in range(2,100001):\n a[i] = (a[i-1]+ a[i-2])%mod\n\nprint((2*(a[n]+a[m]-1))%mod)"}, {"source_code": "import os\nimport sys\nfrom collections import defaultdict as ddic, Counter, deque\nfrom itertools import combinations, permutations, product\nimport bisect, heapq\n\nFAST_INPUT = 0\nif FAST_INPUT:\n from atexit import register\n from io import BytesIO\n \n sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\n sys.stdout = BytesIO()\n register(lambda: os.write(1, sys.stdout.getvalue()))\n \nrr = lambda: sys.stdin.readline().rstrip('\\r\\n')\nrri = lambda: int(rr())\nrrm = lambda: map(int, rr().split())\nMOD = 10**9 + 7\n \nDEBUG = 0\nif DEBUG:\n import random\n random.seed(0)\n ri = random.randint\n\n#####\n\"\"\"\ndef brute(R, C):\n def neighbors(r, c):\n for nr,nc in((r-1,c),(r+1,c),(r,c-1),(r,c+1)):\n if 0<=nr<R and 0<=nc<C:\n yield nr, nc\n\n ans = 0\n for cand in product(range(2),repeat = R*C):\n \n A = [[0] * C for _ in xrange(R)]\n for i, v in enumerate(cand):\n A[i/C][i%C] = v\n\n bad = False\n for r, row in enumerate(A):\n for c, val in enumerate(row):\n common = 0\n for nr, nc in neighbors(r, c):\n common += val == A[nr][nc]\n if common > 1:\n bad = True\n break\n if bad: break\n if not bad:\n ans += 1\n return ans\n\"\"\" \n\ndef solve(R, C):\n if R > C: return solve(C, R)\n A = [0, 2, 4]\n while len(A) <= 1 + max(R, C):\n A.append( (A[-1] + A[-2]) % MOD )\n B = [0, 2, 4]\n for i in xrange(2, len(A)):\n B.append( (B[-1] + A[i]) % MOD)\n \n ans = A[C]\n ans += B[R-1]\n ans %= MOD\n return ans\n \n\"\"\"\nfor R in xrange(1, 7):\n \n for C in xrange(1, 7):\n print R, C, brute(R, C)\n b = brute(R, C)\n if b != solve(R, C):\n print '!', R, C, b, solve(R, C)\nprint 'done'\n\"\"\"\nans = solve(*rrm())\nprint ans\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\np = 10 ** 9 + 7\n\nx = [1, 2]\nfor i in range(2, max(n, m)):\n x.append(x[i - 1] + x[i - 2])\n\nprint(2 * (x[n - 1] + x[m - 1] - 1) % p)\n"}, {"source_code": "import sys\n# sys.stdin = open('C:\\\\Users\\\\sharr\\\\Documents\\\\Input.txt', 'r') \n# sys.stdout = open('C:\\\\Users\\\\sharr\\\\Documents\\\\Output.txt', 'w') \nn,m = map(int,sys.stdin.readline().split())\nf = [1,1]\nmod = 1000000007\nfor i in range(100000):\n\tf.append(f[-1]+f[-2])\nres = 2*(f[n]+f[m]-1)\nres %=mod\nprint(res)"}, {"source_code": "import sys\nn,m = map(int,sys.stdin.readline().split())\nf = [1,1]\nmod = 1000000007\nfor i in range(100000):\n\tf.append(f[-1]+f[-2])\nres = 2*(f[n]+f[m]-1)\nres %=mod\nsys.stdout.write(str(res))"}, {"source_code": "n, m = map(int, input().split())\nfib = [1, 1]\nfor i in range(max(n, m)):\n fib.append(fib[-1] + fib[-2])\nprint(2 * (fib[n] + fib[m] - 1) % 1000000007)"}, {"source_code": "f=[1]*(100005)\nfor i in range(2,100005):\n f[i]=f[i-1]+f[i-2]\nn,m=map(int,input().split())\nprint((2*(f[n]+f[m]-1))%1000000007)"}, {"source_code": "\nf=[1,2]\nfor i in range(2,100005):\n f.append(f[i-1]+f[i-2])\nn,m=map(int,input().split())\nprint((2*(f[n-1]+f[m-1]-1))%1000000007)"}, {"source_code": "N, M = map(int, input().split())\nP = 10**9+7\nF = [1, 2]\nfor i in range(100009):\n F.append((F[-1]+F[-2])%P)\nprint((F[N-1]+F[M-1]-1)*2%P)\n"}, {"source_code": "from sys import stdin\n\nheight, width = map(int, stdin.readline().rstrip().split())\n\ndef fib(n):\n if n < 2:\n return n\n a, b = [0, 1]\n for i in range(0, n):\n a, b = [b, a + b]\n return a\n\ndef solve(height, width):\n x = fib(width + 1) * 2\n return (x - 2 + fib(height + 1) * 2) % (pow(10, 9) + 7)\n\nprint(solve(height, width))\n"}, {"source_code": "height, width = map(int, input().split())\n\ndef fib(n):\n if n < 2:\n return n\n a, b = [0, 1]\n for i in range(0, n):\n a, b = [b, a + b]\n return a\n\ndef solve(height, width):\n x = fib(width + 1) * 2\n return (x - 2 + fib(height + 1) * 2) % (pow(10, 9) + 7)\n\nprint(solve(height, width))\n"}, {"source_code": "\n# coding: utf-8\n\n# In[7]:\n\nn, m = map(int, input().split())\n\ndef fib(n):\n if n<2:\n return 1\n a = 1\n b = 1\n for i in range(2, n+1):\n c = a + b\n a = b\n b = c\n return c\n\nprint((2*fib(n)+2*fib(m)-2)%(10**9+7))\n\n"}, {"source_code": "foo=[]\nn, m = input().split()\nn = int(n)\nm = int(m)\n\nfoo.append(1)\nfoo.append(1)\n\nfor i in range(max(n,m)):\n foo.append(foo[i+1]+foo[i])\n\no = 2*(foo[n] + foo[m] - 1)\n\nprint(o % 1000000007)\n\n\n \n \n \n \n\n"}, {"source_code": "n,m = map(int,input().split())\nfib = [1,1]\nmod = 10**9+7\nfor i in range(max(m,n)):\n fib.append((fib[-1]+fib[-2])%mod)\nprint((2*(fib[m]+fib[n]-1))%mod)"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0\ndef perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\ndef toord(c): return ord(c)-ord('a')\ndef lcm(a, b): return a*b//lcm(a, b)\nmod = 10**9+7\nINF = float('inf')\nfrom math import factorial, sqrt, ceil, floor, gcd\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heapify, heappop, heappush\n\n# ------------------------------\n# f = open('./input.txt')\n# sys.stdin = f\n\ndef main():\n n, m = RL()\n if n<m: n, m = m, n\n dp = [[0, 0] for _ in range(n+1)]\n\n dp[1] = [1, 1]\n dp[0] = [1, 1]\n\n for i in range(2, n+1):\n dp[i][0] = max(dp[i][1], (dp[i-1][1]+dp[i-2][1])%mod)\n dp[i][1] = max(dp[i][0], (dp[i-1][0]+dp[i-2][0])%mod)\n # print(dp)\n print((sum(dp[m]) + sum(dp[n]) - 2)%mod)\n\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "n,m=map(int,input().split())\ndp=[1,1]\nmod=10**9+7\nfor i in range(2,max(n,m)+1):\n dp.append(dp[-1]+dp[-2])\n#print(dp)\nprint(2*(dp[n]+dp[m]-1)%mod)\n \n"}, {"source_code": "import sys\na, b = map(int, sys.stdin.readline().split())\npp = pow(10,9) + 7\nfib = [[0,1],[1,1]]\n\ndef MatDiv(a,b):\n res = [[0,0],[0,0]]\n res[0][0] = (a[0][0] * b[0][0] + a[0][1] * b[1][0]) % pp\n res[0][1] = (a[0][0] * b[0][1] + a[0][1] * b[1][1]) % pp\n res[1][0] = (a[1][0] * b[0][0] + a[1][1] * b[1][0]) % pp\n res[1][1] = (a[1][0] * b[1][0] + a[1][1] * b[1][1]) % pp\n return res\n\ndef BinPow(x,p):\n if p == 1:\n return fib\n res = BinPow(x, p // 2)\n if p % 2 == 0:\n return MatDiv(res,res)\n else:\n return MatDiv(MatDiv(res,res),x)\n\ntmp = BinPow(fib.copy(),a)\ntmp2 = BinPow(fib.copy(),b)\nprint(((tmp[0][0] + tmp[0][1] + tmp2[0][0] + tmp2[0][1]) * 2 - 2) % pp)"}], "negative_code": [{"source_code": "P = 10 ** 9 + 7\nn, m = tuple([int(x) for x in input().split()])\n\nmx = max(n, m)\nvals = [0] * mx\nfor i in range(mx):\n if i == 0 or i == 1:\n vals.append(i)\n \n else:\n new_val = (vals[-1] + vals[-2]) % P\n vals.append(new_val)\n\n\nx = (vals[n-1] + vals[m-1]) % P\nx = (x - 1) % P\nx = (x * 2) % P\n\nprint(x)"}, {"source_code": "mod = 1000000007\nn,m = map(int, input().split())\n\na,b = 1,1\nfor i in range(n):\n a,b = b,(a+b)%mod\nf = a\n\nres = 2*(f + m - 1) % mod\nprint(res)\n\n\n\n"}, {"source_code": "n, m = map(int, input().split())\nmod = 10**9 + 7\nif n == 1 and m == 1:\n\tprint(2)\n\texit()\n\nif (n == 1 and m == 2) or (m == 1 and n == 2):\n\tprint(4)\n\texit()\n\nif n == 2 and m == 2:\n\tprint(6)\n\texit()\n\nadd1 = 2\nadd2 = 4\nadd = [add1, add2]\nfor i in range(1, 200000):\n\tadd += [(add[i]+ add[i-1])%mod]\n\n# print(add[:20])\n\nn1 = 2\nn2 = 4\nn -= 2\n\nfor i in range(n):\n\tnxt = n1+n2\n\tnxt %= mod\n\tn1 = n2\n\tn2 = nxt\n\n# print(n2)\n\nm1 = n2+2\n\nm -= 2\n\nfor i in range(m):\n\tm1 = (m1+add[i])%mod\n\t# print(m1)\n\n\nprint(m1%mod)"}, {"source_code": "inputlist=list(map(int, input().split()))\nm=inputlist[0]\nk=inputlist[1]\n\n\n\ndef row(n):\n if n==1:\n return 2\n elif n==2:\n return 4\n else:\n i=2\n a=2\n b=4\n while i<n:\n c=a+b\n a=b\n b=c\n i+=1\n return c\n \nprint(row(k)+2*(m-1))\n"}, {"source_code": "import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\nn,m = map(int, input().split())\nif n < m:\n n,m = m,n\nif n == 1 and m == 1:\n print(2)\nelif n == 2 and m == 2:\n print(6)\nelse:\n md = 1000000007\n c = [(1,0), (2,1)]\n for i in range(2, n):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n if m > 1:\n c.append((2*c[-1][0] - c[-1][1]-c[-2][1], c[-1][0] - c[-1][1]-c[-2][1]))\n for i in range(2, m):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n print(2*c[-1][0])\n\n\n\n\n#sys.stdout.write('YES\\n')\n#sys.stdout.write(f'{res}\\n')\n#sys.stdout.write(f'{y1} {x1} {y2} {x2}\\n')\n"}, {"source_code": "ch=input()\nL=[int(i)for i in ch.split()]\na=L[0]\nb=L[1]\nif a>b:\n a,b=b,a\nd={1:1,2:0}\nfor i in range(1,b):\n x=d[1]\n y=d[2]\n d[2]=x+y\n d[1]=y\n\nnb=d[1]+2*d[2]\nprint(2*(nb+a-1)%((10**9)+7))"}, {"source_code": "n, m = map(int, input().split())\nif n + m == 2:\n print(2)\n exit()\nif n > m:\n n, m = m, n\na, b, c, d = 1, 1, 1, 1\nmod = 10 ** 9 + 7\nfor i in range(2, m):\n a, b, c, d = c, a + c, b + d, b\n a %= mod\n b %= mod\n c %= mod\n d %= mod\nprint((a + b + c + d + pow(2, n, mod) - 2 + mod) % mod)"}, {"source_code": "import sys\n\ninput = []\n\nfor line in sys.stdin:\n\tinput.append(line.split())\n\nn = int(input[0][0])\nm = int(input[0][1])\n\n\nMOD = 10**9 + 1\n\ns_cache = {}\ndef s(n):\n\tif n == 1:\n\t\treturn 0\n\tif n == 2:\n\t\treturn 1\n\tif n not in s_cache:\n\t\ts_cache[n] = (s(n - 2) + d(n - 1)) % MOD\n\treturn s_cache[n]\n\nd_cache = {}\ndef d(n):\n\tif n == 1:\n\t\treturn 1\n\tif n == 2:\n\t\treturn 1\n\tif n not in d_cache:\n\t\td_cache[n] = (s(n - 1) + d(n - 1)) % MOD\n\treturn d_cache[n]\n\nres = 2 * (s(n) + d(n) + s(m) + d(m) - 1) % MOD\n\nsys.stdout.write(str(res))\n\n\n"}, {"source_code": "P = 10 ** 9 + 7\nn, m = tuple([int(x) for x in input().split()])\n\nmx = max(n, m)\nvals = [0] * mx\nfor i in range(mx):\n if i == 0 or i == 1:\n vals.append(i)\n \n else:\n new_val = (vals[-1] + vals[-2]) % P\n vals.append(new_val)\n\n\nx = (vals[n-1] + vals[m-1]) % P\nx = (x - 1) % P\nx = (x * 2) % P\n\nprint(x)"}, {"source_code": "a, b = map(int,input().split())\nmod = 10**9+7\nans = 0\n\nfor n in [a,b]:\n\n A = [[0,0] for i in range(n)]\n A[0] = [0,1]\n if n > 1:\n A[1] = [1,1]\n for i in range(2,n):\n A[i][0] = A[i-2][1] % mod\n A[i][1] = sum(A[i-1]) % mod\n # print(A)\n ans += (sum(A[-1]) * 2) % mod\n\nprint((ans-2) % mod)"}, {"source_code": "MOD = 10 ** 9 + 7\nn, m = map(int, input().split())\nfib = [1] * (max(n, m) + 2)\nfor i in range(2, max(n, m) + 2):\n fib[i] = fib[i - 1] + fib[i - 2]\n fib[i] %= MOD\nprint((fib[m + 1] + fib[n + 1]) % MOD)\n"}, {"source_code": "inputlist=list(map(int, input().split()))\nn=inputlist[0]\nm=inputlist[1]\nprint(2*(n+m-1))\n"}, {"source_code": "import sys,math,itertools\nfrom collections import Counter,deque,defaultdict\nfrom bisect import bisect_left,bisect_right \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,m = inpl()\na = [1,1]\nfor i in range(3,10**5+10):\n a.append((a[-1]+a[-2])%mod)\nres = a[m] + a[n-1]\nprint((res*2)%mod)\n"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\n\ndef count(n, k):\n total = k\n mod = 10**9 + 7\n same, diff = 0, k\n for i in range(2, n + 1):\n same = diff\n diff = total * (k - 1)\n diff = diff % mod\n total = (same + diff) % mod\n return total\n\nmod = 10**9 + 7\nn, m = mi()\nif n > m:\n m, n = n, m\nt = count(m, 2)\nprint((t + ((n - 1)*2) % mod) % mod)\n\n"}, {"source_code": "MOD = 10e9+7\nn, m = list(map(int, input().split()))\nmx = max(n, m)\ndp = [0] * mx\ndp[0] = 2\nif mx >= 2:\n dp[1] = 4\n\nfor i in range(2, mx):\n dp[i] = (dp[i-1] + dp[i-2]) % MOD\n\nans = dp[n-1] + dp[m-1] - 2\nprint(int(ans))\n"}, {"source_code": "n,m=map(int,input().split())\nfib=[1,2]\nfor i in range(max(n,m)-2):\n\tfib.append(fib[-1]+fib[-2])\nprint(2*(fib[n-1]+fib[m-1])-2)\n"}, {"source_code": "from sys import stdin\ninp = stdin.readline\n\nn,m = [int(x) for x in inp().strip().split()]\n\nif n==2 and m == 3 and n==3 and m == 2:\n print(8)\nelif n==1 and m == 2 or n==2 and m==1:\n print(4)\nelse:\n print(2)"}, {"source_code": "n, m = map(int, input().split())\nmodulo = 10 * 9 + 7\ncombs = 0\nr = 1\nr_next = 2\nfor i in range(3, n + 1):\n r, r_next = r_next, (r + r_next) % modulo\ncombs += r_next if n > 1 else 1\nc = 1\nc_next = 2\nfor j in range(3, m + 1):\n c, c_next = c_next, (c + c_next) % modulo\ncombs += c_next if m > 1 else 1\ncombs -= 1\ncombs *= 2\nprint(combs % modulo)"}, {"source_code": "import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\nn,m = map(int, input().split())\nif n < m:\n n,m = m,n\nif n == 1 and m == 1:\n print(2)\nelif n == 2 and m == 2:\n print(6)\nelse:\n md = 1000000007\n c = [(1,0), (2,1)]\n for i in range(2, n):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n if m > 1:\n c.append((2*c[-1][0] - c[-1][1]-c[-2][1], c[-1][0] - c[-1][1]-c[-2][1]))\n for i in range(2, m):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n print(2*c[-1][0] % md)\n\n\n\n\n#sys.stdout.write('YES\\n')\n#sys.stdout.write(f'{res}\\n')\n#sys.stdout.write(f'{y1} {x1} {y2} {x2}\\n')\n"}, {"source_code": "n, m = map(int, input().split())\nif n == 1:\n print(2**m)\nelif m == 1:\n print(2**n)\nelse:\n print(2**n+2*(m-1))"}, {"source_code": "mod=10**9+7\nn,m=map(int,input().split())\nfibo=[1,1]\nfor i in range(3,max(m,n)+1):\n\tfibo.append((fibo[-1]+fibo[-2])%mod)\nprint ((2*(fibo[n-1]+fibo[m-1]-2))%mod)"}, {"source_code": "n, m = map(int, input().split())\nk = 2\nif n > 1:\n k += 2**(n-1)\nl = 0\nif m > 1:\n l += 2**(m-1)\nprint((l+k) % (10**9+7))"}, {"source_code": "import sys\nsys.setrecursionlimit(10**9)\nd = {}\nd[1] = 2\nd[2] = 4\nmod = pow(10,9) + 7\ndef cal(n):\n\treturn pow(2,n,mod) - pow(2,n-1,mod) + 2\n\n\n\nn,m = map(int,raw_input().split())\n\nif n == 1 and m == 1:\n\tprint 2\n\texit()\nif n == 1:\n\tprint cal(m)%mod\n\texit()\nif m == 1:\n\tprint cal(n)%mod\n\texit()\n\nprint (cal(n) + cal(m) - 2)%(mod)"}, {"source_code": "import sys,math,itertools\nfrom collections import Counter,deque,defaultdict\nfrom bisect import bisect_left,bisect_right \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,m = inpl()\na = [1,1]\nfor i in range(3,10**5+10):\n a.append((a[-1]+a[-2])%mod)\nres = a[m] + a[n-1]\nprint((res*2)%mod)\n"}, {"source_code": "n, m = [int(i) for i in input().split()]\nf = [1, 1]\nmod = 1000000007\nc1 = 9 * pow(4, mod - 2, mod)\nc2 = 3 * pow(2, mod - 2, mod)\nfor i in range(100005):\n f.append((f[-1] + f[-2])%mod)\n\nif n < 3 or m < 3:\n if n < m:\n n, m = m, n\n if m == 1:\n ans = 2 * f[n]\n else:\n ans = 2 + 2 * f[n]\n \nelif n & 1:\n # 1+''\n M = n // 2 + 1\n l = m - 1\n ans = pow(2, M - 1, mod) * pow(2*f[l], M, mod) * 9 // 4#*c1\nelse:\n M = n // 2 - 1\n l = m - 1\n 1 + ''\n ans = pow(2, M+1, mod) * c2 * pow(f[l], M, mod) * (2 + 2*f[l+1])\n\nprint(ans%mod)\n\n\n"}, {"source_code": "from bisect import bisect_left as bl, bisect_right as br, insort\nimport sys\nimport heapq\n#from math import *\nfrom collections import defaultdict as dd, deque\ndef data(): return sys.stdin.readline().strip()\ndef mdata(): return map(int, data().split())\n#def print(x): return sys.stdout.write(str(x)+'\\n')\n#sys.setrecursionlimit(100000)\nmod=int(1e9+7)\n\nn,m=mdata()\ndp=[[2,0,0]]\nfor i in range(1,m):\n dp.append([(2*dp[i-1][0]-dp[i-1][2]+mod)%mod,(dp[i-1][1]+dp[i-1][0]-dp[i-1][2]+mod)%mod,(dp[i-1][0]-dp[i-1][2]+mod)%mod])\ncnt=dp[-1][1]\nk1=dp[-1][0]-dp[-1][1]\nk2=0\nfor i in range(1,n):\n k1,k2=(2*k1-k2+mod)%mod,(k1-k2+mod)%mod\nprint(cnt+k1)"}, {"source_code": "from sys import stdin\ninp = stdin.readline\n\nn,m = [int(x) for x in inp().strip().split()]\n\nif n==2 and m == 3 and n==3 and m == 2:\n print(8)\nelif n==1 and m == 2 or n==2 and m==1:\n print(4)\nelse:\n print(2)"}, {"source_code": "from sys import stdin\nimport math\nmod=10**9+7 \nn,m=map(int,stdin.readline().split())\nsum=n+m\nk=(sum-1)*2\nk=k%mod\nprint(k) \n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\ndef modulo_div(a, b, modulo):\n if b == 1:\n return a % modulo\n return (a + modulo_div(- a, modulo % b, b) * modulo) // b % modulo\n\nfor line in sys.stdin.readlines():\n inputs = line.split()\n n = int(inputs[0])\n m = int(inputs[1])\n\nnumer = 1\ndenom = 1\nsums = 1\nmodulo = 10 ** 9 + 7\nfor s in range(1, (n + 4) // 3):\n denom = denom * s % modulo\n numer = numer * (n - 2 * s + 1) % modulo\n sums = (sums + modulo_div(numer, denom, modulo)) % modulo\nnumer = 1\ndenom = 1\nfor s in range(1, (m + 4) // 3):\n denom = denom * s % modulo\n numer = numer * (m - 2 * s + 1) % modulo\n sums = (sums + modulo_div(numer, denom, modulo)) % modulo\n\nsums = sums * 2 % modulo\nprint(sums)"}, {"source_code": "import sys\n\ninput = []\n\nfor line in sys.stdin:\n\tinput.append(line.split())\n\nn = int(input[0][0])\nm = int(input[0][1])\n\n\nMOD = 10**9 + 1\n\ncache = {}\ndef f(n):\n\tif n == 1 or n == 2:\n\t\treturn 1\n\tif n not in cache:\n\t\th = f(n / 2)\n\t\th1 = f(n / 2 + 1)\n\t\tif n & 1 == 1:\n\t\t\tcache[n] = ((h1 * h1 % MOD) + (h * h % MOD)) % MOD\n\t\telse:\n\t\t\tcache[n] = (h * (((2 * h1) % MOD) - h)) % MOD\n\treturn cache[n]\n\nres = 2 * ((f(n + 1) + f(m + 1) - 1) % MOD)\nres %= MOD\n\nif n == 1 and m == 100000:\n\tprint(935236457)\nelse:\n\tprint(res)\n\n\n"}, {"source_code": "n,m=map(int,input().split())\nif n==1 and m==1:\n\tprint (2)\nelse:\n\tk1=max(n,m)\n\tk2=min(n,m)\n\tl=[2]*k1\n\tl[1]=4\n\tfor i in range(2,k1):\n\t\tl[i]=(l[i-1]+l[i-2])%1000000007\n\tprint ((2*(k2-1)+l[k1-1])%1000000007)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# def calc(a,b,c):\n# \troot = (b**2-4*a*c)**(0.5)\n# \tnum = -b + (root)\n# \tdeno = 2*a\n# \treturn num/deno\n\n# t=int(input())\n# for nt in range(t):\n# \tn,s=map(int,input().split())\n# \tif n==1:\n# \t\tif s==0:\n# \t\t\tprint (1)\n# \t\telse:\n# \t\t\tprint (-1)\n# \telse:\n# \t\tif s!=0:\n# \t\t\tfor i in range(n-2):\n# \t\t\t\tprint (1,end=\" \")\n# \t\t\tprint (2,end=\" \")\n# \t\t\tprint (calc(n-1,-1*2*n,2*n-n*n*s*s))\n# \t\telse:\n# \t\t\tfor i in range(n):\n# \t\t\t\tprint (1,end=\" \")\n# \t\t\tprint ()"}, {"source_code": "n, m = map(int, input().split())\nif n == 1:\n print(2**m)\nelif m == 1:\n print(2**n)\nelse:\n print(2**n+2*(m-1))"}, {"source_code": "import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\nn,m = map(int, input().split())\nif n < m:\n n,m = m,n\nif n == 1 and m == 1:\n print(2)\nelif n == 2 and m == 2:\n print(6)\nelse:\n md = 1000000007\n c = [(1,0), (2,1)]\n for i in range(2, n):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n if m > 1:\n c.append((2*c[-1][0] - c[-1][1]-c[-2][1], c[-1][0] - c[-1][1]-c[-2][1]))\n for i in range(2, m):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n print(2*c[-1][0] % md)\n\n\n\n\n#sys.stdout.write('YES\\n')\n#sys.stdout.write(f'{res}\\n')\n#sys.stdout.write(f'{y1} {x1} {y2} {x2}\\n')\n"}, {"source_code": "import sys\n\ninput = []\n\nfor line in sys.stdin:\n\tinput.append(line.split())\n\nn = int(input[0][0])\nm = int(input[0][1])\n\n\nMOD = 10**9 + 1\n\ncache = {}\ndef f(n):\n\tif n == 1 or n == 2:\n\t\treturn 1\n\tif n not in cache:\n\t\th = f(n / 2)\n\t\th1 = f(n / 2 + 1)\n\t\tif n & 1 == 1:\n\t\t\tcache[n] = ((h1 * h1 % MOD) + (h * h % MOD)) % MOD\n\t\telse:\n\t\t\tcache[n] = (h * (((2 * h1) % MOD) - h)) % MOD\n\treturn cache[n]\n\nres = 2 * ((f(n + 1) + f(m + 1) - 1) % MOD)\nres %= MOD\n\nif n == 1 and m == 100000:\n\tprint(935236457)\nelse:\n\tprint(res)\n\n\n"}, {"source_code": "n, m = map(int, input().split())\n\nans = (n * m) % 1000000007\nfor i in range(2, n + 1):\n for j in range(1, m + 1):\n ans -= 2 * (1 << ((n - i + 1) * (m - j + 1) - 1)) % 1000000007\n\nprint(ans * -1)\n\n\n"}, {"source_code": "ch=input()\nL=[int(i)for i in ch.split()]\na=L[0]\nb=L[1]\nif a>b:\n a,b=b,a\nd={1:1,2:0}\nfor i in range(1,b):\n x=d[1]\n y=d[2]\n d[2]=x+y\n d[1]=y\n\nnb=d[1]+2*d[2]\nprint(2*(nb+a-1)%((10**9)+7))"}, {"source_code": "MOD = 10e9+7\nn, m = list(map(int, input().split()))\nmx = max(n, m)\ndp = [0] * mx\ndp[0] = 2\nif mx >= 2:\n dp[1] = 4\n\nfor i in range(2, mx):\n dp[i] = (dp[i-1] + dp[i-2]) % MOD\n\nans = dp[n-1] + dp[m-1] - 2\nprint(int(ans))\n"}, {"source_code": "import sys,math,itertools\nfrom collections import Counter,deque,defaultdict\nfrom bisect import bisect_left,bisect_right \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,m = inpl()\na = [1,1]\nfor i in range(3,10**5+10):\n a.append((a[-1]+a[-2])%mod)\nres = a[m] + a[n-1]\nprint((res*2)%mod)\n"}, {"source_code": "l = [0] * (10**6 + 1)\nl[2] = 2\nmod = 10**9 + 7\nn, m = [int(i) for i in input().split()]\nfor i in range(3, max(m, n) + 1):\n l[i] = (l[i - 1] + l[i - 2]) % mod\nres = 0\nfor i in range(n + 1):\n res += l[i]\nfor j in range(m + 1):\n res += l[j]\nprint(2 + res)"}, {"source_code": "def getAns(maxSide, minSide):\n if maxSide == 1:\n return 2\n if maxSide == 2:\n return 4\n dpSide = [0] * maxSide\n for i in range(len(dpSide)):\n dpSide[i] = [0, 0]\n\n dpSide[0] = [1, 1]\n dpSide[1] = [2, 2]\n s = 0\n for i in range(1, len(dpSide)-1):\n dpSide[i+1][0] += dpSide[i][1]\n dpSide[i+1][0] += dpSide[i-1][1] * minSide\n dpSide[i+1][1] += dpSide[i][0]\n dpSide[i + 1][1] += dpSide[i-1][0] * minSide\n return sum(dpSide[maxSide-1]) + s\n\n\n\nn, m = list(map(int, input().split()))\nmaxSide = max(n, m)\nminSide = min(n, m)\nprint(getAns(maxSide, minSide))"}, {"source_code": "MOD = 1000000007\nn, m = list(map(int, input().split()))\nmx = max(n, m)\ndp = [0] * mx\ndp[0] = 2\nif mx >= 2:\n dp[1] = 4\n\nfor i in range(2, mx):\n dp[i] = (dp[i-1] + dp[i-2]) % MOD\n\nans = dp[n-1] + dp[m-1] - 2\nprint(int(ans))\n"}, {"source_code": "'''\n Author : thekushalghosh\n Team : CodeDiggers\n'''\nimport sys,math\ninput = sys.stdin.readline\ndef qw(n,r): \n return (math.factorial(n) / (math.factorial(r) * math.factorial(n - r)))\nn,m = map(int,input().split())\nn = max(n,m)\nq = 0\nfor i in range(n + 1):\n q = q + (qw(n,i))\nprint(int(q) % 1000000007)"}, {"source_code": "import sys,math,itertools\nfrom collections import Counter,deque,defaultdict\nfrom bisect import bisect_left,bisect_right \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,m = inpl()\na = [1,1]\nfor i in range(3,10**5+10):\n a.append((a[-1]+a[-2])%mod)\nres = a[m]\nac = list(itertools.accumulate(a))\nif n > 1: res += a[n-2]\nprint((res*2)%mod)"}, {"source_code": "from sys import stdin\ninp = stdin.readline\n\nn,m = [int(x) for x in inp().strip().split()]\n\nif n==2 and m == 3:\n print(8)\nelse:\n print(4)"}, {"source_code": "MOD = int(10e9) + 7\nN, M = map(int, input().split())\nfib = [0 for i in range(max(N, M)+1)]\nfib[0] = 1\nfib[1] = 1\nfor i in range(2, max(N, M) + 1):\n fib[i] = (fib[i-1] + fib[i-2]) % MOD\nprint((2 * (fib[N] + fib[M] - 1)) % MOD)"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\n\ndef count(n, k):\n total = k\n mod = 10**9 + 7\n same, diff = 0, k\n for i in range(2, n + 1):\n same = diff\n diff = total * (k - 1)\n diff = diff % mod\n total = (same + diff) % mod\n return total\n\nmod = 10**9 + 7\nn, m = mi()\nif n > m:\n m, n = n, m\nt = count(m, 2)\nprint((t + ((n - 1)*2) % mod) % mod)\n\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10**9)\nd = {}\nd[1] = 2\nd[2] = 4\nmod = pow(10,9) + 7\ndef cal(n):\n\treturn pow(2,n,mod) - pow(2,n-1,mod) + 2\n\n\n\nn,m = map(int,raw_input().split())\n\nif n == 1 and m == 1:\n\tprint 2\n\texit()\nif n == 1:\n\tprint cal(m)%mod\n\texit()\nif m == 1:\n\tprint cal(n)%mod\n\texit()\n\nprint (cal(n) + cal(m) - 2)%(mod)"}, {"source_code": "import os\nimport sys\nfrom collections import defaultdict as ddic, Counter, deque\nfrom itertools import combinations, permutations, product\nimport bisect, heapq\n\nFAST_INPUT = 0\nif FAST_INPUT:\n from atexit import register\n from io import BytesIO\n \n sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\n sys.stdout = BytesIO()\n register(lambda: os.write(1, sys.stdout.getvalue()))\n \nrr = lambda: sys.stdin.readline().rstrip('\\r\\n')\nrri = lambda: int(rr())\nrrm = lambda: map(int, rr().split())\nMOD = 10**9 + 7\n \nDEBUG = 0\nif DEBUG:\n import random\n random.seed(0)\n ri = random.randint\n\n#####\ndef solve(R, C):\n if R > C: return solve(C, R)\n A = [0, 2, 4]\n while len(A) <= C:\n A.append( (A[-1] + A[-2]) % MOD )\n return (A[R] + A[C])%MOD\n \n \nans = solve(*rrm())\nprint ans\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "m, n = list(map(int, input().split()))\nmm = max(m, n)\ndp = [0]*(mm+1)\ndp[0]=1\ndp[1]=1\nfor i in range(2, mm+1):\n dp[i] = dp[i-1] + dp[i-2]\nprint((dp[m]+dp[n]-1)*2)"}, {"source_code": "n,m = map(int,input().split())\na = [0,2]\nmod = pow(10,9)+7\ns = 0\nt = 2\nfor i in range(2,100002):\n u = ((a[i-1]*2)%mod - s%mod)%mod\n if(u < 0):\n u += mod\n a.append(u)\n s = t\n t = (u%mod-s%mod)%mod\n if(t < 0):\n t += mod\n#print(a[-1])\nprint(a[n]+a[m]-2)"}, {"source_code": "n, m = map(int, input().split())\nmodulo = 10 * 9 + 7\ncombs = 0\nr = 1\nr_next = 2\nfor i in range(3, n + 1):\n r, r_next = r_next, (r + r_next) % modulo\ncombs += r_next if n > 1 else 1\nc = 1\nc_next = 2\nfor j in range(3, m + 1):\n c, c_next = c_next, (c + c_next) % modulo\ncombs += c_next if m > 1 else 1\ncombs -= 1\ncombs *= 2\nprint(combs % modulo)"}, {"source_code": "mod = 10**9 + 7\n\nn, m = map(int, raw_input().strip().split())\nif n > m:\n n, m = m, n\n\na = [1 for i in range(n + m + n + m + 5)]\na[0] = 0\nfor i in range(n + 1, n + m + n + m + 1):\n a[i] = a[i - 1] + a[i - (n + 1)]\n a[i] %= mod\nprint (2 * a[n + n + m - 1]) % mod\n"}, {"source_code": "a=input().split(\" \")\nx=int(a[0])\ny=int(a[1])\nn=2\nm=2\nA = 1000000000+7\nwhile x>1:\n m=(m%A+n%A)%A\n n =(m%A-n%A)%A\n x-=1\nr1 = m\nm = 2\nn = 2\nwhile y>1:\n m=(m%A+n%A)%A\n n =(m%A-n%A)%A\n y-=1\nr2 = m\nprint((r1+r2)%A-2)"}, {"source_code": "mod = 1000000007\nn, m = [int(x) for x in input().split()]\nm1 = 4\nm2 = 2\nfor x in range(n):\n if x < 2:\n pass\n else:\n m2, m1 = m1, (m2 + m1) % mod\ndoubles = m1 - 2\nm1 = 4\nm2 = 2\nfor col in range(m):\n if col < 2:\n pass\n else:\n m2, m1 = m1, (m2 + m1) % mod\n #print(m1)\nsingles = m1\n#print(singles, doubles)\nprint((doubles + singles)%mod)\n"}, {"source_code": "a,b=map(int,input().split())\nt=max(a,b)\nj=min(a,b)\na,b=t,j\ndp=[2,4]\nfor i in range(2,a+1):\n dp.append(0)\nif a<3:\n row=dp[a-1]\nelse:\n for i in range(2,a):\n\n dp[i]=dp[i-1]+dp[i-2]\n # print(dp)\n row=dp[a-1]\n\n# dp=[row,row+2]\n# for i in range(2,b+1):\n# dp.append(0)\n# if b<3:\n# row=dp[b-1]\n# else:\n# for i in range(2,b):\n# dp[i]=dp[i-1]+dp[i-2] \n# row=dp[b-1]\nif b-2<0:\n print(row%(10**9+7))\nelse:\n print((row+dp[b-2])%(10**9+7))\n\n"}, {"source_code": "from __future__ import division, print_function\ndef main():\n n,m=map(int,input().split())\n mod=10**9+7\n dp=[0]*(n+1)\n dp[0]=1\n for i in range(1,n+1):\n if i>0:\n dp[i]=(dp[i]+dp[i-1])%mod\n if i>1:\n dp[i]=(dp[i]+dp[i-2])%mod\n dp1=[0]*(m+1)\n dp1[0]=1\n for i in range(1,m+1):\n if i>0:\n dp1[i]=(dp1[i]+dp1[i-1])%mod\n if i>1:\n dp1[i]=(dp1[i]+dp1[i-2])%mod\n answer=(2*dp[-1]*dp1[-1])%mod\n if n>1 and m>1:\n answer=(answer-4)%mod\n print(answer)\n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()"}, {"source_code": "from math import *\n\nmod = 10**9 + 7\n\nn, m = map(int, input().split())\n\nx = max(n, m) + 1\ndp = [0] * (x + 1)\ndp[1] = 1\nfor i in range(2, x + 1):\n dp[i] = (dp[i-1] + dp[i-2]) % mod\n\nprint(dp)\ndef solve(x):\n if x > 1:\n return dp[x]\n else:\n return 0\n \nprint((2*(solve(n) + solve(m) + 1)) % mod)\n"}, {"source_code": "n, m = map(int, input().split())\nd = [2, 4] \nk = 10**9+7\nn, m = max(n, m), min(n, m)\nfor i in range(2, n):\n d += [(d[i-1]+d[i-2]) % k]\nprint((d[n-1]+2**(m-1)) % k)"}, {"source_code": "from __future__ import division, print_function\ndef main():\n n,m=map(int,input().split())\n mod=10**9+7\n dp=[0]*(n+1)\n dp[0]=1\n for i in range(1,n+1):\n if i>0:\n dp[i]=(dp[i]+dp[i-1])%mod\n if i>1:\n dp[i]=(dp[i]+dp[i-2])%mod\n dp1=[0]*(m+1)\n dp1[0]=1\n for i in range(1,m+1):\n if i>0:\n dp1[i]=(dp1[i]+dp1[i-1])%mod\n if i>1:\n dp1[i]=(dp1[i]+dp1[i-2])%mod\n answer=(2*dp[-1]*dp1[-1])%mod\n if n>1 and m>1:\n answer=(answer-4)%mod\n print(answer)\n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()"}, {"source_code": "a,b=map(int,input().split())\nt=max(a,b)\nj=min(a,b)\na,b=t,j\ndp=[2,4]\nfor i in range(2,a+1):\n dp.append(0)\nif a<3:\n row=dp[a-1]\nelse:\n for i in range(2,a):\n\n dp[i]=dp[i-1]+dp[i-2]\n # print(dp)\n row=dp[a-1]\n\n# dp=[row,row+2]\n# for i in range(2,b+1):\n# dp.append(0)\n# if b<3:\n# row=dp[b-1]\n# else:\n# for i in range(2,b):\n# dp[i]=dp[i-1]+dp[i-2] \n# row=dp[b-1]\nprint((row+dp[b-2])%(10**9+7))\n\n"}, {"source_code": "import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\nn,m = map(int, input().split())\nif n < m:\n n,m = m,n\nif n == 1 and m == 1:\n print(2)\nelif n == 2 and m == 2:\n print(6)\nelse:\n md = 1000000007\n c = [(1,0), (2,1)]\n for i in range(2, n):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n if m > 1:\n c.append((2*c[-1][0] - c[-1][1]-c[-2][1], c[-1][0] - c[-1][1]-c[-2][1]))\n for i in range(2, m):\n c.append(((2*c[-1][0] - c[-1][1]) % md, (c[-1][0] - c[-1][1]) % md))\n print(2*c[-1][0])\n\n\n\n\n#sys.stdout.write('YES\\n')\n#sys.stdout.write(f'{res}\\n')\n#sys.stdout.write(f'{y1} {x1} {y2} {x2}\\n')\n"}, {"source_code": "inputlist=list(map(int, input().split()))\nm=inputlist[0]\nk=inputlist[1]\ndef row(n):\n if n==1:\n return 2\n elif n==2:\n return 4\n else:\n i=2\n a=2\n b=4\n while i<n:\n c=a+b\n a=b\n b=c\n i+=1\n return c%(10**9+7)\n \n\nif k==1:\n print(row(m))\nelse:\n print(row(k)+2*(m-1))\n"}, {"source_code": "m = 10 ** 9 + 7\na, b = map(int, input().split())\n# bruteforce(a, 1)\ni, j = 2, 4\np = 1\nwhile p < a:\n p += 1\n i, j = j, (i + j) % m\nstart1 = i\n# bruteforce(a, 2)\ni, j = 4, 6\np = 1\nwhile p < a:\n p += 1\n i, j = j, (i + j - 2) % m\nstart2 = i\n\ni, j = start1, start2\np = 1\nwhile p < b:\n p += 1\n i, j = j, (i + j - 2 * a + 2) % m\nprint (i)"}, {"source_code": "\nn,m = map(int, input().split())\n\n\ndef fib(x):\n \n a = 0\n b = 1\n\n temp = 0\n for i in range(0, x):\n temp = a + b\n a = b\n b = temp\n \n return temp\n \nprint(2*(fib(n) + fib(m) - 1))"}, {"source_code": "n,m=map(int,input().split())\na=[0]*10**6\nMod=1**9+7\na[1],a[2]=2,4\nfor i in range(3,max(n,m)+1):\n a[i]=(a[i-1]+a[i-2])%Mod\nprint((a[n]+a[m]-2)%Mod,flush=False)"}, {"source_code": "mod=10**9+7\nn,m=map(int,input().split())\nfibo=[1,2]\nfor i in range(3,max(m,n)+1):\n\tfibo.append((fibo[-1]+fibo[-2])%mod)\nprint ((2*(fibo[n-1]+fibo[m-1]-2))%mod)"}, {"source_code": "n, m = map(int, input().split())\n\nans = (n * m) % 1000000007\nfor i in range(2, n + 1):\n for j in range(1, m + 1):\n ans -= 2 * (1 << ((n - i + 1) * (m - j + 1) - 1)) % 1000000007\n\nprint(ans * -1)\n\n\n"}, {"source_code": "from sys import stdin\ninp = stdin.readline\n\nprint(8)"}, {"source_code": "mod = 10 ** 9 + 7\n\n\ndef getAns(maxSide):\n if maxSide == 1:\n return 2\n if maxSide == 2:\n return 4\n dpSide = [0] * maxSide\n for i in range(len(dpSide)):\n dpSide[i] = [0, 0]\n\n dpSide[0] = [1, 1]\n dpSide[1] = [2, 2]\n f = True\n for i in range(1, len(dpSide) - 1):\n dpSide[i + 1][0] += dpSide[i][1]\n dpSide[i + 1][1] += dpSide[i][0]\n dpSide[i + 1][1] += dpSide[i - 1][0]\n dpSide[i + 1][0] += dpSide[i - 1][1]\n dpSide[i + 1][0] %= mod\n dpSide[i + 1][1] %= mod\n\n return sum(dpSide[maxSide - 1]) % mod\n\n\nn, m = map(int, input().split())\nprint(getAns(n) + getAns(m) - 2)\n"}, {"source_code": "mod=10**9+7\nimport sys \n# sys.setrecursionlimit(10**6) \nfrom sys import stdin, stdout\nimport bisect #c++ upperbound\nimport math\nimport heapq\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef cin():\n return map(int,sin().split())\ndef ain(): #takes array as input\n return list(map(int,sin().split()))\ndef sin():\n return input()\ndef inin():\n return int(input())\nimport math \ndef Divisors(n) : \n l = [] \n for i in range(1, int(math.sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n // i == i) : \n l.append(i) \n else : \n l.append(i)\n l.append(n//i)\n return l\n\nopen_list = [\"[\",\"{\",\"(\"] \nclose_list = [\"]\",\"}\",\")\"] \n \n# Function to check parentheses \ndef check(myStr): \n stack = [] \n for i in myStr: \n if i in open_list: \n stack.append(i) \n elif i in close_list: \n pos = close_list.index(i) \n if ((len(stack) > 0) and\n (open_list[pos] == stack[len(stack)-1])): \n stack.pop() \n else: \n return False\n if len(stack) == 0: \n return True\n\"\"\"*******************************************************\"\"\"\ndef main():\n a=[0,1]\n for i in range(100000):\n a.append(a[i]+a[i+1])\n m,n=cin()\n print(2*(a[m+1]+a[n+1]-1))\n######## Python 2 and 3 footer by Pajenegod and c1729\n \n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n \n# So on cf, use PyPy2 for best string performance.\n \npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n \nimport os, sys\nfrom io import IOBase, BytesIO\n \nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n \n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n \nif __name__== \"__main__\":\n main()"}, {"source_code": "n, m = list(map(int, input().split()))\nmx = max(n, m)\ndp = [0] * mx\ndp[0] = 2\nif mx >= 2:\n dp[1] = 4\n \nfor i in range(2, mx):\n dp[i] = dp[i-1] + dp[i-2]\n \nans = dp[n-1] + dp[m-1] - 2\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\na = 2\nb = 2\nfor i in ' '*n:\n a, b = b, a + b\nd = b - a\nc = a + 2\nfor i in ' '*(m-1):\n a, c = c, a + c - d\nprint(a)"}, {"source_code": "from sys import stdin\n\nn, m = [int(i) for i in stdin.readline().strip().split()]\n\ns = min(n, m)\nt = max(n, m)\n\n# colorize block of size 1 * t\nc = (t + 1) * [2] # number of colorings for block 1 * i\nfor i in range(2, t + 1):\n c[i] = c[i - 1] + c[i - 2]\n\n# minus two blocks of alternating coloring, because they are counted twice\nres = c[t] + c[s] - 2\nprint(res)\n"}, {"source_code": "n, m = map(int, input().split())\nmod = 10**9 + 7\nif n == 1 and m == 1:\n\tprint(2)\n\nif (n == 1 and m == 2) or (m == 1 and n == 2):\n\tprint(4)\n\nif n == 2 and m == 2:\n\tprint(6)\n\nadd1 = 2\nadd2 = 4\nadd = [add1, add2]\nfor i in range(1, 200000):\n\tadd += [(add[i]+ add[i-1])%mod]\n\n# print(add[:20])\n\nn1 = 2\nn2 = 4\nn -= 2\n\nfor i in range(n):\n\tnxt = n1+n2\n\tnxt %= mod\n\tn1 = n2\n\tn2 = nxt\n\n# print(n2)\n\nm1 = n2+2\n\nm -= 2\n\nfor i in range(m):\n\tm1 = (m1+add[i])%mod\n\t# print(m1)\n\n\nprint(m1%mod)"}, {"source_code": "mod = 10 ** 9 + 7\n\n\ndef getAns(maxSide):\n if maxSide == 1:\n return 2\n if maxSide == 2:\n return 4\n dpSide = [0] * maxSide\n for i in range(len(dpSide)):\n dpSide[i] = [0, 0]\n\n dpSide[0] = [1, 1]\n dpSide[1] = [2, 2]\n f = True\n for i in range(1, len(dpSide) - 1):\n dpSide[i + 1][0] += dpSide[i][1]\n dpSide[i + 1][1] += dpSide[i][0]\n dpSide[i + 1][1] += dpSide[i - 1][0]\n dpSide[i + 1][0] += dpSide[i - 1][1]\n dpSide[i + 1][0] %= mod\n dpSide[i + 1][1] %= mod\n\n return sum(dpSide[maxSide - 1]) % mod\n\n\nn, m = map(int, input().split())\nprint(getAns(n) + getAns(m) - 2)\n"}, {"source_code": "mod = 1000000007\nn, m = [int(x) for x in input().split()]\nm1 = 4\nm2 = 2\nfor x in range(n):\n if x <= 2:\n pass\n else:\n tmp = (m2 + m1) % mod\n m2 = m1\n m1 = tmp\ndoubles = m1\nm1 = 4\nm2 = 2\nfor col in range(m):\n if col <= 2:\n pass\n else:\n tmp = (m2 + m1) % mod\n m2 = m1\n m1 = tmp\nsingles = m1\nprint((doubles+ singles)%mod)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\nfor line in sys.stdin.readlines():\n inputs = line.split()\n n = int(inputs[0])\n m = int(inputs[1])\n\nnumer = 1\ndenom = 1\nsums = 1\nmodulo = 10 ** 9 + 7\nfor s in range(1, (n + 4) // 3):\n denom = denom * s % modulo\n numer = numer * (n - 2 * s + 1)\n sums = (sums + numer // denom) % modulo\nnumer = 1\ndenom = 1\nfor s in range(1, (m + 4) // 3):\n denom = denom * s % modulo\n numer = numer * (m - 2 * s + 1)\n sums = (sums + numer // denom) % modulo\n\nsums = sums * 2 % modulo\nprint(sums)"}, {"source_code": "n,m=map(int,input().strip().split())\n#print(n,m)\nif n>m:\n\tlen=n\nelse:\n\tlen=m\nf=[1,1]\nfor i in range(len):\n\tx=(f[i]+f[i+1])%1000000007\n\tf.append(x)\nprint((f[n]+f[m]-1)*2)\n\n\"\"\"\n2 3\n\"\"\"\n"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\n\ndef count(n, k):\n total = k\n mod = 1000000007\n same, diff = 0, k\n for i in range(2, n + 1):\n same = diff\n diff = total * (k - 1)\n diff = diff % mod\n total = (same + diff) % mod\n return total\n\nmod = 10**9 + 7\nn, m = mi()\nt = count(m, 2)//2\nprint((2*(t + n - 1))%mod)\n\n"}, {"source_code": "MOD = int(10e9) + 7\nN, M = map(int, input().split())\nfib = [0 for i in range(max(N, M)+1)]\nfib[0] = 1\nfib[1] = 1\nfor i in range(2, max(N, M) + 1):\n fib[i] = (fib[i-1] + fib[i-2]) % MOD\nprint((2 + 2 * (fib[N] + fib[M] - 2)) % MOD)"}, {"source_code": "P = 10 ** 9 + 7\nn, m = tuple([int(x) for x in input().split()])\n\nmx = max(n, m)\nvals = [0] * mx\nfor i in range(mx):\n if i == 0 or i == 1:\n vals.append(i)\n \n else:\n new_val = (vals[-1] + vals[-2]) % P\n vals.append(new_val)\n\n\nx = (vals[n-1] + vals[m-1]) % P\nx = (x - 1) % P\nx = (x * 2) % P\n\nprint(x)"}, {"source_code": "mod = 10**9 + 7\nn, m = [int(i) for i in input().split()]\ntemp = pow(2, (m * n) // 2, mod)\nprint(temp)"}, {"source_code": "a = list(map(int, input().split())) \nT = max(a[0],a[1]) \ntab = [1 for k in range(T+1)]\nfor k in range(2, T+1) : \n tab[k] = tab[k-1] + tab[k-2] \nprint(2*(tab[a[0]] + tab[a[1]]-1))"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\nfor line in sys.stdin.readlines():\n inputs = line.split()\n n = int(inputs[0])\n m = int(inputs[1])\n\nnumer = 1\ndenom = 1\nsums = 1\nmodulo = 10 ** 9 + 7\nfor s in range(1, (n + 4) // 3):\n denom = denom * s % modulo\n numer = numer * (n - 2 * s + 1)\n sums = (sums + numer // denom) % modulo\nnumer = 1\ndenom = 1\nfor s in range(1, (m + 4) // 3):\n denom = denom * s % modulo\n numer = numer * (m - 2 * s + 1)\n sums = (sums + numer // denom) % modulo\n\nsums = sums * 2 % modulo\nprint(sums)"}, {"source_code": "from sys import stdin\ninp = stdin.readline\n\nn,m = [int(x) for x in inp().strip().split()]\n\nif n==2 and m == 3:\n print(8)\nelif n==1 and m == 2:\n print(4)\nelse:\n print(2)"}, {"source_code": "from sys import stdin, stdout\n\ndef scal(typ=int):\n return typ(stdin.readline())\n\ndef vec(typ=int):\n if isinstance(typ, list):\n inp = stdin.readline().split()\n return [typ[i](inp[i]) for i in range(len(inp))]\n else:\n return list(map(typ, stdin.readline().split()))\n\nn, m = vec()\na, b, res = 0, 1, 0\nfor i in range(1, max(m, n) + 1):\n a, b = b, a + b\n if i in [m, n]: res += b\nres = (res - 1) << 1\nprint(res % 1000000007)\n"}, {"source_code": "from math import *\n\nmod = 10**9 + 7\n\nn, m = map(int, input().split())\n\nx = max(n, m) + 1\ndp = [0] * (x + 1)\ndp[1] = 1\nfor i in range(2, x + 1):\n dp[i] = (dp[i-1] + dp[i-2]) % mod\n\n#print(dp)\ndef solve(x):\n if x > 1:\n return dp[x]\n else:\n return 0\n \nprint((2*(solve(n) + solve(m) + 1)) % mod)\n"}, {"source_code": "n, m = map(int, input().split())\nd = [2, 4] \nk = 10**9+7\nn, m = max(n, m), min(n, m)\nfor i in range(2, n):\n d += [(d[i-1]+d[i-2]) % k]\nprint((d[n-1]+(2**(m-1) if m > 1 else 0)) % k)"}, {"source_code": "from sys import stdin\ninp = stdin.readline\n\nn,m = [int(x) for x in inp().strip().split()]\n\na = [0] * 100001\na[1] = 1\na[0] = 1\nmod = (10**9+7)\nfor i in range(2,100001):\n a[i] = (a[i-1]+ a[i-2])%(10**9+7)\n\nprint(2*(a[n]+a[m]-1))"}, {"source_code": "n,m=map(int,input().split())\nmod=10**9+7\nif n>m:\n n,m=m,n\nif m==1:\n print(2)\nelse:\n DP=[[0]*2 for _ in range(m)]\n DP[1][0]=2\n DP[1][1]=2\n for i in range(2,m):\n DP[i][0]=DP[i-1][1]%mod\n DP[i][1]=(DP[i-1][0]+DP[i-1][1])%mod\n\n a=DP[m-1][0]+DP[m-1][1]\n if n==1:\n print(a)\n else:\n ans=a-2\n ans+=DP[n-1][0]+DP[n-1][1]\n print(ans)"}, {"source_code": "inputlist=list(map(int, input().split()))\nn=inputlist[0]\nm=inputlist[1]\nprint(2*(n+m-1))\n"}, {"source_code": "inputlist=list(map(int, input().split()))\nm=inputlist[0]\nk=inputlist[1]\ndef row(n):\n if n==1:\n return 2\n elif n==2:\n return 4\n else:\n i=2\n a=2\n b=4\n while i<n:\n c=a+b\n a=b\n b=c\n i+=1\n return c%(10**9+7)\n \n\nif k==1:\n print(row(m))\nelse:\n print(row(k)+2*(m-1))\n"}, {"source_code": "n, m = map(int, input().split())\nmodulo = 10 * 9 + 7\ncombs = 0\nr = 1\nr_next = 2\nfor i in range(3, n + 1):\n r, r_next = r_next, (r + r_next) % modulo\ncombs += r_next if n > 1 else 1\nc = 1\nc_next = 2\nfor j in range(3, m + 1):\n c, c_next = c_next, (c + c_next) % modulo\ncombs += c_next if m > 1 else 1\ncombs -= 1\ncombs *= 2\nprint(combs % modulo)"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\nprint(2 ** (n * m) - (2 ** (n*m) - (n ** m)) % 1000000007)"}, {"source_code": "n, m = list(map(int, input().split()))\n\ndp = [[0 for i in range(m)] for y in range(n)]\n\ndp[0][0] = 1\n\nfor i in range(n):\n for y in range(m):\n if not (i == 0 and y == 0):\n if i > 0 and y > 0:\n dp[i][y] = max(dp[i-1][y], dp[i][y-1]) + 1\n elif i > 0:\n dp[i][y] = dp[i-1][y] + 1\n elif y > 0:\n dp[i][y] = dp[i][y-1] + 1\n\nprint(dp[-1][-1]*2)\n"}, {"source_code": "\nn,m = map(int, input().split())\n\n\ndef fib(x):\n \n a = 0\n b = 1\n\n temp = 0\n for i in range(0, x):\n temp = a + b\n a = b\n b = temp\n \n return temp\n \nprint(2*(fib(n) + fib(m) - 1))"}, {"source_code": "def mi():\n return map(int, input().split())\nmod = 10**9+7\n'''\n2 3\n10\n()()())(()\n'''\n'''\nn = int(input())\na = list(input())\n\ndp = [[0]*n for i in range(n)]\n\nfor i in range(n):\n for j in range(i+1, n):\n t = 0\n f = False\n temp=0\n for k in range(i,j+1):\n if a[k]=='(':\n t+=1\n else:\n t-=1\n if t<0:\n f = True\n elif t==0:\n temp+=1\n if not f:\n\n if a[i]\n\n\n\n'''\nn,m = mi()\na = 0\nb = 2\nn,m = min(m,n),max(m,n)\nfor i in range(m):\n c = a+b\n a = b\n b = c\nb-=2\nb+=pow(2,n,mod)\nb%=mod\nprint (b)\n"}, {"source_code": "mod = 1000000007\nn,m = map(int, input().split())\n\na,b = 1,1\nfor i in range(n):\n a,b = b,(a+b)%mod\nf = a\n\nres = 2*(f + m - 1) % mod\nprint(res)\n\n\n\n"}, {"source_code": "n, m = map(int, input().split())\na = 2\nb = 2\nfor i in ' '*n:\n a, b = b, a + b\nprint(a)\nd = b - a\nc = a + 2\nfor i in ' '*(m-1):\n a, c = c, a + c - d\nprint(a)"}, {"source_code": "MOD = int(10e9) + 7\nN, M = map(int, input().split())\nfib = [0 for i in range(max(N, M)+1)]\nfib[0] = 1\nfib[1] = 1\nfor i in range(2, max(N, M) + 1):\n fib[i] = (fib[i-1] + fib[i-2]) % MOD\nprint((2 * (fib[N] + fib[M] - 1)) % MOD)"}], "src_uid": "0f1ab296cbe0952faa904f2bebe0567b"} {"source_code": "s = input()\nmass = list(map(int, s.split(\"+\")))\n\nfor j in range(len(mass)):\n minid = j\n for i in range(j+1, len(mass)):\n if mass[minid] > mass[i]:\n minid = i\n minim = mass[minid]\n mass[minid] = mass[j]\n mass[j] = minim\n\n\nns = str(mass[0])\nfor i in range(1, len(mass)):\n ts = str(mass[i])\n ns = ns + \"+\" + ts\n\nprint(ns)", "positive_code": [{"source_code": "list = input().split(\"+\")\nint_list = []\nfor _ in list:\n int_list.append(int(_))\nsorted_int_list = sorted(int_list)\nsorted_string = \"\"\nfor _ in sorted_int_list:\n sorted_string += str(_) + \" \"\nsorted_str_list = sorted_string.strip().split(\" \")\nprint(\"+\".join(sorted_str_list))\n\n\n"}, {"source_code": "list = input().split(\"+\")\nint_list = []\nfor _ in list:\n int_list.append(int(_))\nsorted_int_list = sorted(int_list)\nsorted_string = \"\"\nfor _ in sorted_int_list:\n sorted_string += str(_) + \" \"\nsorted_str_list = sorted_string.strip().split(\" \")\nprint(\"+\".join(sorted_str_list))\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Oct 20 14:04:12 2020\n\n@author: Luke\n\"\"\"\nl=sorted(input()[::2])\nprint('+'.join (l))"}, {"source_code": "\na=[w for w in input().split('+')]\na.sort(key=int)\nprint('+'.join(w for w in a))"}, {"source_code": "eq = list(raw_input())\neq = sorted(eq)\nnofp = int(len(eq)/2)\n\nfor i in range(len(eq)-1):\n try:\n eq.remove(\"+\")\n except:\n eq[i-nofp] = eq[i-nofp]+\"+\"\n\nprint \"\".join(eq)\n"}, {"source_code": "d = input()\nn1 = n2 = n3 = 0\nfor i in range(0, len(d), 2):\n if d[i] == '1':\n n1 += 1\n elif d[i] == '2':\n n2 += 1\n else:\n n3 += 1\ndd = \"1+\" * n1 + \"2+\" * n2 + \"3+\" * n3\nprint(dd[:-1])"}, {"source_code": "line = [int(e) for e in input().split('+')]\nline.sort()\nprint('+'.join([str(e) for e in line]))"}, {"source_code": "x = str(input())\nn = 0\na = 0\nb = 0\nc = 0\nwhile n<len(x):\n if x[n] == '1':\n a = a+1\n elif x[n] == '2':\n b = b+1\n elif x[n] == '3':\n c = c+1\n n = n+2\nif a>0:\n a = a-1\n p = ('1' + '+1'*a + '+2'*b + '+3'*c)\nelif b>0:\n b = b-1\n p = '2' + '+2'*b + '+3'*c\nelif c>0:\n c = c-1\n p = '3' + '+3'*c\nprint(p)\n"}, {"source_code": "print(\"+\".join(sorted(input()[::2])))"}, {"source_code": "s=input()\np=[];one=0\nfor i in s:\n if i!='+':\n if i=='3':\n p.append('3')\n if i=='1':\n p.insert(0,'1')\n one+=1\n if i=='2':\n p.insert(one,'2')\nprint('+'.join(p))"}, {"source_code": "mathSequence = input()\n\nperfectSequence = []\n\nfor i in mathSequence:\n if i != \"+\":\n perfectSequence.append(int(i))\n\n\nperfectSequence.sort()\n\nln = len(perfectSequence)\n\nfor i in range(0, ln):\n print(perfectSequence[i], end=\"\")\n \n if i < ln - 1:\n print(\"+\", end=\"\")"}, {"source_code": "print '+'.join(sorted(raw_input().split('+')))"}, {"source_code": "l = raw_input().split('+')\nc = {'1': 0, '2': 0, '3': 0}\nfor i in l:\n c[i] += 1\ns = []\nfor key in ['1', '2', '3']:\n s += [key] * c[key]\nprint '+'.join(s)\n"}, {"source_code": "k = raw_input()\nl = len(k)+1\nL = []\nfor i in range(1,l):\n if i%2 == 1:\n L.append(k[i-1])\n\nL = sorted(L)\nle = len(L)\nK = []\nfor i in range(0,le):\n K.append(L[i])\n K.append('+')\n \nprint ''.join(K[:-1])"}, {"source_code": "num=map(str,raw_input().split('+'))\nprint \"+\".join(sorted(num))\n"}, {"source_code": "s = input()\nif len(s) == 1:\n print(int(s[0]))\nelse:\n s = s.split(\"+\")\n s = sorted(s)\n s1 = '+'.join(x for x in s)\n print(s1)"}, {"source_code": "s = raw_input()\nar = [0] * 5\nle = len(s)\n\nfor i in range(0,le):\n if s[i] == '1':\n ar[1] += 1 \n if s[i] == '2':\n ar[2] += 1 \n if s[i] == '3':\n ar[3] += 1 \n\nans = \"\";\nfor i in range(0,ar[1]):\n ans += str(1);\n ans += \"+\"\n\nfor i in range(0,ar[2]):\n ans += str(2)\n ans += \"+\"\n\nfor i in range(0,ar[3]):\n ans += str(3)\n ans += \"+\"\n\nans = ans[:-1]\n\nprint ans"}, {"source_code": "s = raw_input()\nsn = []\nj = 0\nfor i in range(0,len(s),2):\n sn.append(s[i])\n j += 1\n\nk = 1\nwhile k == 1:\n k = 0\n for i in range(k,len(sn)-1):\n if sn[i+1]< sn[i]:\n sn[i],sn[i+1] = sn[i+1], sn[i]\n k = 1\n \n\nsp = sn[0]\nfor i in range(1,len(sn)):\n sp = sp + '+' + sn[i]\nprint sp\n "}, {"source_code": "s=input()\nk=len(s)//2+1\nnum=[]\nfor i in range(k):\n num.append(int(s[2*i]))\nnum.sort()\nout=''\nfor j in range(k-1):\n out=out+str(num[j])+'+'\nout=out+str(num[-1])\nprint(out)\n "}, {"source_code": "\n\ndef ass(a):\n if '+' not in a:\n return a\n # print(sorted(a.split('+')))\n return '+'.join(list(map(str, sorted(a.split('+')))))\n\ndef ass2(a):\n if '+' not in a: return a\n r = {'1':0, '2':0, '3':0}\n for i in a.split('+'):\n r[i] += 1\n res = '1+'*r['1'] + '2+'*r['2'] + '3+'*r['3']\n return res[:-1]\n\n\nprint(ass2(input()))"}, {"source_code": "n = raw_input()\nl=[]\nfor i in n[::2]:\n\tl.append((i))\nl = sorted(l)\nprint \"+\".join(l)"}, {"source_code": "print '+'.join(map(str, sorted(map(int, raw_input().split('+')))))\n"}, {"source_code": "import sys\n\nsumString = raw_input('')\n\ncount = [0]*3\n\ni = 0\nwhile i < len(sumString):\n\tcount[int(sumString[i])-1] += 1\n\ti += 2\n\nc = 0\nindex = 0\ntotal = sum(count)\nfirst = True\nwhile index < len(count):\n\tif count[index] > 0:\n\t\tif (c != 0 or index != 0) and not first:\n\t\t\tsys.stdout.write('+')\n\t\tsys.stdout.write(str(index+1))\n\t\tfirst = False\n\t\tc += 1\n\tif c == count[index]:\n\t\tindex += 1\n\t\tc = 0"}, {"source_code": "\ndef partition(arr, low, high):\n i=low-1\n pivot=arr[high]\n for j in range (low,high):\n if arr[j]<=pivot:\n i+=1\n arr[j],arr[i]=arr[i],arr[j]\n arr[i+1],arr[high]=arr[high],arr[i+1]\n return i+1\n\ndef Quicksort(arr, low, high):\n if low<high:\n pi=partition(arr, low, high)\n Quicksort(arr, low, pi-1)\n Quicksort(arr, pi+1, high)\n\narr=[]\nn =input()\nnumber=len(n)\nfor i in range (0,number):\n if i%2==1:\n continue\n arr.append(int(n[i]))\nQuicksort(arr,0,len(arr)-1)\nfor i in range (0,len(arr)):\n if i!=(len(arr)-1):\n print (str(arr[i]),'+',sep=\"\", end=\"\"),\n else:\n print (str(arr[i]))\n \n"}, {"source_code": "print \"+\".join(sorted(raw_input()[::2]))"}, {"source_code": "#!/bin/python\n\nimport math\nimport os\nimport random\nimport re\nimport sys\n\n# Complete the hourglassSum function below.\n\n\ndef hourglassSum(str_input):\n processed_num_list = []\n num_list = x = str_input.split(\"+\")\n for item in num_list:\n processed_num_list.append(int(item))\n processed_num_list.sort()\n\n result = \"\"\n for item in processed_num_list:\n result += str(item)+'+'\n len_ = len(result)\n print result[:(len_-1)]\n\n\nif __name__ == '__main__':\n str_input = str(raw_input())\n hourglassSum(str_input)\n"}, {"source_code": "\n\ns = raw_input()\ns = s.split('+')\nx = [int(xx) for xx in s]\nx = sorted(x)\n\nx = '+'.join(str(xx) for xx in x)\nprint x\n"}, {"source_code": "final=\"\"\nstring=raw_input()\nlisst = map(int,string.split(\"+\"))\nlisst = sorted(lisst)\nfor i in range(0,len(lisst)):\n k=lisst[i]\n final=final+ str(k) + \"+\"\nprint final[:len(final)-1] \n"}, {"source_code": "s=raw_input()\no='1+' * s.count('1')+'2+' * s.count('2') +'3+' * s.count('3')\nprint o[:-1]"}, {"source_code": "l = map(int, raw_input().split('+'))\nl.sort()\nb = \"\"\nfor i in range(len(l)) :\n if i != len(l)-1 : b+= str(l[i]) + \"+\"\n else : b += str(l[i])\nprint b"}, {"source_code": "from sys import stdin, stdout\nti = lambda : stdin.readline().strip()\nma = lambda fxn, ti : map(fxn, ti.split())\nol = lambda arr : stdout.write(' '.join(str(i) for i in arr) + '\\n')\nos = lambda i : stdout.write(str(i) + '\\n')\nolws = lambda arr : stdout.write(''.join(str(i) for i in arr) + '\\n')\n\n\nop = list(ti())\nfor i in range(op.count('+')):\n\top.remove('+')\nop.sort()\ni = 1\nwhile i < len(op):\n\top.insert(i, '+')\n\ti += 2\n\nop = ''.join(op)\nos(op)"}, {"source_code": "s = raw_input()\nc1=0 \nc2=0\nc3=0\n\nle = len(s)\nfor i in range (0,le):\n if(s[i]=='1'):\n c1+=1\n elif(s[i]=='2'):\n c2+=1\n elif(s[i]=='3'):\n c3+=1\ntotal = c1+c2+c3\nans = \"\"\nfor i in range(0,total):\n if(c1!=0):\n ans+=\"1+\"\n c1-=1\n elif(c2!=0):\n ans+=\"2+\"\n c2-=1\n elif(c3!=0):\n ans+=\"3+\"\n c3-=1\nprint ans[:-1]\n"}, {"source_code": "def arrangesum(inStr):\n sList = inStr.split(\"+\")\n sListInts = []\n outStr = \"\"\n if len(inStr) <= 100:\n try:\n for x in sList:\n sListInts.append(int(x))\n sListInts.sort()\n outStr = str(sListInts[0])\n for y in range(len(sListInts)-1):\n outStr += \"+\" + str(sListInts[y+1])\n print(outStr)\n\n except(ValueError):\n outStr = \"Error\"\n else:\n print(\"Error\")\n outStr = \"Error\"\n return outStr\n\ns = input()\narrangesum(s)"}, {"source_code": "from sys import stdin, stdout\na = stdin.readline().rstrip().split(\"+\")\nprint '+'.join(sorted(a))"}, {"source_code": "print \"+\".join(sorted(raw_input()[::2]))\n"}, {"source_code": "\ns=raw_input()\n\ns=s.replace(\"+\",\" \")\ns=s.split()\ns.sort()\nprint '+'.join(s)"}, {"source_code": "inp = list(raw_input())\nline = []\n\nfor i in range(0, len(inp)):\n if inp[i] != \"+\":\n line.append(inp[i])\n\nline.sort()\nprint \"+\".join(line)\n"}, {"source_code": "print ('+'.join(sorted(raw_input().split('+'))))\n"}, {"source_code": "def helpfulMaths(s):\n\n\ts = list(s)\n\tt = []\n\n\tfor i in range(len(s)):\n\t\tif s[i] != '+':\n\t\t\tt.append(s[i])\n\n\tt = sorted(t)\n\n\ti = 0\n\twhile i < len(t) - 1:\n\t\tt.insert(i + 1, '+')\n\t\ti += 2\n\treturn ''.join(t)\n\ns = raw_input()\nprint(helpfulMaths(s))\n\n# print(helpfulMaths('3+2+1'))"}, {"source_code": "s = raw_input()\nnumbers = map(int, s.split('+'))\nnumbers.sort()\nprint '+'.join(str(x) for x in numbers)"}, {"source_code": "a=map(int,raw_input().split('+'))\na.sort()\ns=\"\"\nlength=len(a)\nif (a[length-1]<=3):\n\tfor i in range(0,length):\n\t\ts=s+str(a[i])+'+'\n\tprint s[0:(len(s)-1)]\n\t"}, {"source_code": "a=map(int,raw_input().split('+'))\na.sort()\ns=\"\"\nlength=len(a)\nif (a[length-1]<=3):\n\tfor i in range(0,length):\n\t\ts=s+str(a[i])+'+'\n\tprint s[0:(len(s)-1)]"}, {"source_code": "s = str(input())\na = list(s)\nc1 = a.count('1')\nc2 = a.count('2')\nc3 = a.count('3')\nfor i in range(c1):\n print('1',sep = '',end ='')\n if i != c1-1:\n print('+',sep = '',end ='')\nif c1 != 0 and (c2!= 0 or c3 != 0):\n print('+',sep = '',end ='')\nfor i in range(c2):\n print('2',sep = '',end ='')\n if i != c2-1:\n print('+',sep = '',end ='')\nif c2 != 0 and c3!= 0 :\n print('+',sep = '',end ='')\nfor i in range(c3):\n print('3',sep = '',end ='')\n if i != c3-1:\n print('+',sep = '',end ='')"}, {"source_code": "if __name__ == \"__main__\":\n print \"+\".join(map(str, sorted(map(int, raw_input().split(\"+\")))))"}, {"source_code": "inp = raw_input().strip()\nones = 0\ntwos = 0\nthrees = 0\nfor i in range(len(inp)):\n if inp[i] == '1':\n ones += 1\n elif inp[i] =='2':\n twos += 1\n elif inp[i] == '3':\n threes +=1\nnumTrack = []\nstringList = []\nfor i in range(ones):\n stringList.append('1')\nfor i in range(twos):\n stringList.append('2')\nfor i in range(threes):\n stringList.append('3')\nprint '+'.join(stringList)"}, {"source_code": "s1=[int(x) for x in raw_input().split('+')]\ns1.sort()\nk=\"\"\nfor j in range(len(s1)):\n k=k+str(s1[j])\n if j!=len(s1)-1: \n k+='+'\nprint k.strip() "}, {"source_code": "s=raw_input()\ns=s.split('+')\ns=sorted(s)\nans=''\nfor i in s:\n\tans+=i\n\tans+='+'\nans=ans[:len(ans)-1]\nprint ans"}, {"source_code": "s=raw_input()\ns=s.split('+')\ns=sorted(s)\nans=''\nfor i in s:\n\tans+=i\n\tans+='+'\nans=ans[:len(ans)-1]\nprint ans"}, {"source_code": "string = str(input(\"\"))\ntemp = string.split(\"+\")\n\n#insertion sort\ndef insertionSort(alist):\n for index in range(1,len(alist)):\n\n currentvalue = alist[index]\n position = index\n\n while position>0 and alist[position-1]>currentvalue:\n alist[position]=alist[position-1]\n position = position-1\n\n alist[position]=currentvalue\n\ndef printV(alist):\n temp2 = \"\"\n for i in range (0, len(alist)):\n temp2 += str(alist[i])\n if i != len(alist)-1:\n temp2 += \"+\"\n print(temp2)\n\n\ninsertionSort(temp)\nprintV(temp)\n\n\n\n"}, {"source_code": "s=input()\nif len(s)==1:\n print(s)\nelse:\n l=[]\n for i in range(0,len(s),2):\n l.append(s[i])\n l.sort()\n for i in range(0,len(l)-1):\n print(l[i],\"+\",end=\"\",sep=\"\")\n print(l[i+1])"}, {"source_code": "s = input().strip()\nnumbers = sorted(s.split('+'))\n \nfor i in range(len(numbers) - 1):\n print(str(numbers[i])+'+', end='')\n\nprint(numbers[-1])\n"}, {"source_code": "#import sys\n#sys.stdin=open(\"input.txt\",\"r\")\ns=input()\na=s.split(\"+\")\na.sort()\ny=\"+\".join(a)\nprint(y)"}, {"source_code": "numbers = raw_input().split('+')\nnumbers.sort()\nprint '+'.join(numbers)"}, {"source_code": "import random\n\ndef del_nulls(arr):\n\tx = {}\n\tcount, i = 0, -1\n\twhile i < len(arr) - 1:\n\t\ti += 1\n\t\tcount += 1\n\t\tif arr[i] in x: \n\t\t\tx[arr[i]] += 1\n\t\t\tarr.remove(arr[i])\n\t\t\ti -= 1\n\t\telse: x.update([(arr[i], 1)])\n\treturn(x)\n\ndef qsort(arr, left, right):\n if (right - left > 1):\n a = (right + left)//2\n l, r = left, right\n while (l != r):\n while (arr[l] < arr[a]): l += 1\n while (arr[r] > arr[a]): r -= 1\n if (l > r):\n l, r = r, l\n else:\n arr[l], arr[r] = arr[r], arr[l]\n if (l != right):\n qsort(arr, left, l)\n if (r != left):\n qsort(arr, r, right)\n elif (arr[left] > arr[right]):\n arr[left], arr[right] = arr[right], arr[left]\n\t\t\narr = list(map(int, input().split('+')))\n\ndel_list = del_nulls(arr)\n\nqsort(arr, 0, len(arr) - 1)\nfor i in range(0, len(arr)):\n\tfor j in range(0, del_list[arr[i]]):\n\t\tif (not(i == 0 and j == 0)): print('+', end='')\n\t\tprint(arr[i], end='')"}, {"source_code": "xenia = input('')\nnew = []\nfinal = ''\nplus = 0\nnew.extend(xenia)\nfor i in new:\n if i == '+':\n new.remove(i)\n plus += 1\n\nnew.sort()\nfor j in new:\n if len(final) == new.__len__() + plus- 1 :\n final += j\n else:\n final += j + '+'\n\nprint(final)"}, {"source_code": "s = input()\nn1 = n2 = n3 = 0\nfor i in range(0, len(s), 2):\n if s[i] == '1':\n n1 += 1\n elif s[i] == '2':\n n2 += 1\n else:\n n3 += 1\nss = \"1+\" * n1 + \"2+\" * n2 + \"3+\" * n3\nprint(ss[:-1])"}, {"source_code": "l = list(map(int,input().split(\"+\")))\nl.sort()\nleng = len(l)\nfor x in range(leng):\n if(x == leng-1):\n print(l[x])\n else:\n print(l[x],end = \"+\")\n "}, {"source_code": "a=input()\nb=0\nc=0\nd=0\ns2=\"\"\nfor i in range(len(a)):\n if a[i]==\"1\":\n b+=1\n elif a[i]==\"2\":\n c+=1\n elif a[i]==\"3\":\n d+=1\ns1=\"1\"*(b)+\"2\"*(c)+\"3\"*(d)\nfor i in range(len(s1)):\n s2=s2+s1[i]+\"+\"\ns3=s2[0:len(s2)-1]\nprint(s3)"}, {"source_code": "n=input()\nif(len(n)<=100):\n a=[]\n for i in range(0,len(n),2):\n a.append(n[i])\n for i in range(0,len(a)):\n a[i]=int(a[i])\n for i in range(0,len(a)):\n for j in range(i,len(a)):\n if(a[i]>a[j]):\n a[i],a[j]=a[j],a[i]\n for i in range(0,len(a)):\n print(a[i],end=\"\")\n if(i!=len(a)-1):\n print('+',end=\"\")\n \n"}, {"source_code": "a = input()\nl = len(a)\narr = list()\ni = 0\nwhile i<l:\n arr.append(a[i])\n i += 2\narr.sort()\nval = \"\"\nfor e in range(len(arr)):\n if e == (len(arr)-1):\n val += arr[e]\n else:\n val += arr[e]\n val += '+'\nprint(val)"}, {"source_code": "s = input().split('+')\ns.sort()\nfor i in range(0, len(s)):\n print(s[i],end = \"\")\n if(i < len(s) - 1):\n print(\"+\", end = \"\")"}, {"source_code": "stri=input()\npos=0\na=[0]*int(len(stri)/2+1)\n\nfor r in stri:\n\tif r!='+':\n\t\ta[pos]=int(r)\n\t\tpos+=1\n\na.sort()\n\nfor j in range(1,len(stri),2):\n\ta.insert(j,\"+\")\n\n\nfor i in a:\n\n\tprint(i,end=\"\")\n\t"}, {"source_code": "n = input()\nn1 = n2 = n3 = 0\nfor i in range(0, len(n),2):\n if n[i] == '1':\n n1 += 1\n elif n[i] == '2':\n n2 += 1\n else:\n n3 += 1\nres = \"1+\" * n1 + \"2+\" * n2 + \"3+\" * n3\nprint(res[:-1])\n"}, {"source_code": "def heapify(a,i,n):\n l = i\n lc=2*i +1\n rc=2*i +2\n \n if lc<n and int(a[lc])>int(a[l]):\n l=lc\n if rc<n and int(a[rc])>int(a[l]):\n l=rc\n \n if l!=i:\n a[l],a[i]=a[i],a[l]\n heapify(a,l,n)\n \ns = input().replace('+',' ').split()\n\nif len(s)==1:\n print(*s)\nelse: \n for i in range(len(s)//2,-1,-1):\n heapify(s,i,len(s))\n \n for i in range(len(s)-1,0,-1):\n s[0],s[i]=s[i],s[0]\n heapify(s,0,i)\n \n print('+'.join(s))\n\n \n \n "}, {"source_code": "def main():\n\n input_sum = input()\n list_of_numbers = []\n\n for val in input_sum:\n\n if val != \"+\":\n\n list_of_numbers.append(val)\n\n list_of_numbers = sorted(list_of_numbers)\n\n output_string = \"\"\n for i in range(len(list_of_numbers)):\n\n if i != len(list_of_numbers) -1 :\n output_string = output_string + str(list_of_numbers[i]) + \"+\"\n else:\n output_string = output_string + str(list_of_numbers[i])\n\n \n \n print(output_string)\n\ndef sec_main():\n\n count1 = 0\n count2 = 0\n count3 = 0\n\n input_sum = input()\n\n for val in input_sum:\n\n if val != \"+\":\n\n if int(val) == 1:\n count1+=1\n elif int(val) == 2:\n count2+=1\n else:\n count3+=1\n \n output_sum = \"1+\"*count1 + \"2+\"*count2 + \"3+\"*count3\n output_sum = output_sum[0:-1]\n print(output_sum)\n\nif __name__ == \"__main__\":\n\n #main()\n\n sec_main()\n\n"}, {"source_code": "a = list(input().split(\"+\"))\na.sort()\nfor i in range(len(a)):\n if i != len(a)-1:\n print(a[i]+\"+\",end=\"\")\n else:\n print(a[i])\n"}, {"source_code": "a=input()\nb=[]\n\nfor i in a :\n if i!= \"+\":\n b.append(int(i))\n \nb.sort()\nln=len(b)\n \nfor i in range (0,ln) :\n print(b[i],end = \"\")\n \n if i<ln-1:\n print(\"+\",end = \"\")"}, {"source_code": "print('+'.join(sorted(input().replace(\"+\",\"\"),key=str)))\n"}, {"source_code": "a=input()\nb=len(a)\nif b==1:\n print(a)\nelse:\n l=[]\n for i in range(0,b,2):\n l.append(a[i])\n l=sorted(l)\n for i in range(len(l)):\n if i==len(l)-1:\n print(l[i],end='')\n else:\n print(l[i],end='+')"}, {"source_code": "S = sorted([s for s in input().split('+')])\nprint('+'.join(S))\n"}, {"source_code": "L=sorted(list(input().split(\"+\")))\nprint(\"+\".join(L))\n"}, {"source_code": "s=input(\"\")\n\nnums = list(map(int, s.split(\"+\")))\n\n\ndef selectionSort(alist):\n for i in range(len(alist)-1,0,-1):\n positionOfMax = 0\n for location in range(1,i+1):\n if alist[location]>alist[positionOfMax]:\n positionOfMax = location\n\n temp = alist[i]\n alist[i] = alist[positionOfMax]\n alist[positionOfMax] = temp\n\n\nselectionSort(nums)\ns = '+'.join(map(str,nums))\nprint(s)"}, {"source_code": "s=list(input())\na=(len(s)+1)/2\nfor i in range(int(a)):\n\tfor k in range(i+1,int(a)):\n\t\tif s[2*i]>s[2*k]:\n\t\t\ts[2*i],s[2*k]=s[2*k],s[2*i]\nprint(''.join(s))"}, {"source_code": "txt = [ int(i) for i in input().split(\"+\")]\nprint(\"+\".join([str(i) for i in sorted(txt)]))\n"}, {"source_code": "s = input()\nl = s.split(\"+\")\nz = sorted(l)\nss = \"\"\nfor i in range(len(z)):\n if len(z) == 1:\n ss = ss + z[i]\n elif i == len(z)-1:\n ss = ss + z[i]\n else:\n ss = ss + z[i] + \"+\"\nprint(ss)"}, {"source_code": "s=input()\nn=\"\"\nfor i in range(len(s)):\n if i%2==0:\n n+=s[i]\n\nn='+'.join(sorted(n))\nprint(n)"}, {"source_code": "math=input().split('+')\nmath.sort()\nfor i in range (len(math)):\n print(math[i],end='')\n if i!=len(math)-1:\n print('+',end='')"}, {"source_code": "a=input()\ns=[]\nfor i in range(0,len(a),2):\n s.append(a[i])\ns.sort()\nfor i in range(len(s)):\n if (i!=len(s)-1): print(s[i],end=\"+\")\n else: print(s[i])\n"}, {"source_code": "l=[int(x) for x in input().split('+')]\nl.sort()\nn=len(l)\nfor i in range(n):\n l[i]=str(l[i])\nstring='+'.join(l)\nprint(string)\n"}, {"source_code": "istring = input()\n\n# checking for the length of the string\n#print(len(istring))\n\n\n\n# case 1: when there is only one number\nif len(istring) == 1:\n print(istring)\n\nelse:\n newistring = istring.replace(\"+\",\"\")\n #print(newistring)\n\n count1 = 0\n count2 = 0\n count3 = 0\n\n for number in newistring:\n if number == '3':\n count3 += 1\n elif number == '2':\n count2 += 1\n elif number == '1':\n count1 += 1\n\n #print(count1)\n #print(count2)\n #print(count3)\n\n finalstringlist = list()\n while count1 != 0:\n finalstringlist.append('+1')\n count1 -= 1\n while count2 != 0:\n finalstringlist.append('+2')\n count2 -= 1\n while count3 != 0:\n finalstringlist.append('+3')\n count3 -= 1\n\n finalstring = \"\".join(finalstringlist)\n #print(finalstring)\n\n ans = finalstring.replace('+','',1)\n print(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "string = input()\nnewStr = []\nfor i in range(len(string)):\n if(string[i] != '+'):\n newStr.append(int(string[i]))\nnewStr.sort()\nandron = len(newStr)\ncount = 1\nfor i in newStr:\n if(count != andron):\n print((str(i) + '+'), end=\"\")\n else:\n print((str(i)), end=\"\")\n count += 1"}, {"source_code": "print '+'.join(map(str, sorted(map(int, raw_input().split('+')))))\n"}, {"source_code": "arr = sorted(input().split('+'))\nn = len(arr)\nfor i in range(n-1): print(arr[i], end=\"+\")\nprint(arr[-1])"}, {"source_code": "def dumbXenia(values):\n values.sort();res =\"\"\n for i in range(values.count('+')):\n values.pop(0)\n leftover_size = len(values)\n if leftover_size == 1:\n print values[0]\n else:\n for i in range (leftover_size):\n if i+1 < leftover_size:\n res += values[i]+'+'\n else:\n res += values[i]\n print res\nvalues = raw_input()\ndumbXenia(list(values))"}, {"source_code": "def rearrange():\n s = input()\n c = [0]*3\n i=0\n for i in s:\n if i==\"1\":\n c[0]+=1\n elif i ==\"2\":\n c[1]+=1\n elif i == \"3\":\n c[2]+=1\n s = \"\"\n for i in range(len(c)):\n counter = i+1\n for _ in range(c[i]):\n s+= str(counter) + \"+\"\n s = s[:-1]\n print(s)\n\nrearrange()\n"}, {"source_code": "from __future__ import print_function\nstring = raw_input()\nnums = []\ni = 0\nwhile(i < len(string)):\n if(i%2 == 0):\n nums.append(string[i])\n i += 1\nnums = map(int, nums)\nnums.sort()\nk = 0\nwhile(k < len(nums)):\n if(k != len(nums)-1):\n print (str(nums[k])+\"+\", end = '')\n else:\n print (str(nums[k]), end = '')\n k += 1\n"}, {"source_code": "s = map(int, raw_input().split('+'))\ns.sort()\nprint '+'.join(map(str, s))"}, {"source_code": "s = input()\narr = s.split('+')\narr.sort()\nprint(\"+\".join(map(str, arr)))"}], "negative_code": [{"source_code": "t=input()\nl=[]\nfor i in range(len(t)):\n if t[i]!='+':\n l.append(t[i])\n \n \n \nfor i in range(len(l)):\n l[i]=int(l[i])\n i+=1\n\nl.sort()\n\nfor i in range(len(l)):\n l[i]=str(l[i])\n i+=1\n\nfor i in l:\n if i!=l[len(l)-1]:\n print(i+'+',end='')\n elif i==l[len(l)-1]:\n print(i)"}, {"source_code": "inp = input()\nnums = []\nfor symb in inp:\n if symb != '+':\n nums.append(int(symb))\nprint(nums)\nnums.sort()\nnew_str = ''\nfor num in nums:\n if nums.index(num) == 0:\n new_str += str(1)\n else:\n new_str+= '+' + str(num)\nprint(new_str)"}, {"source_code": "def HelpfulMaths():\n string = str(input())\n n1 = n2 = n3 = 0\n for i in range(0,len(string),2):\n if string[i] == '1':\n n1 += 1\n elif string[i] == '2':\n n2 += 1\n else:\n n3 += 1\n string = \"1+\"*n1 + \"2+\"*n2 + \"3+\"*n3\n return string[:-1]\n \n"}, {"source_code": "a=input()\nfor i in range(0,len(a),2):\n for j in range(2, len(a)-2,2):\n if (a[j]>a[i]):\n temp=a[j]\n a=a.replace(a[i],a[j])\n a=a.replace(a[j],temp)\nprint(a)"}, {"source_code": "'''\nn=int(input())\nfor i in range(n):\n s=input()\n if len(s)>10:\n print(f'{s[0]}{len(s)-2}{s[len(s)-1]}')\n else:\n print(s)\n'''\n\ns=input()\nli=s.split(\"+\")\ns=''\nfor i in range(len(li)-1):\n s+=(li[i]+'+')\ns+=li[len(li)-1]\nprint(s)\n\n"}, {"source_code": "s = input()\nif len(s)>1:\n for i in range(0,len(s)-1,2):\n if int(s[i])<=int(s[i+2]):\n print(s[i]+'+',end='')\n else:\n print(s[i+2]+'+',end='')\n \n print(s[i+2])\nelse:\n print(s)\n\n\n \n "}, {"source_code": "def HelpfulMaths():\n n = str(input())\n n = n.replace(\"+\",\"\")\n n = list(n)\n n.sort()\n string = \"\"\n for i in n:\n string = string + str(i) + \"+\"\n if string.endswith('+'):\n string = string[:-1]\n return string\n \n"}, {"source_code": "def HelpfulMaths(n):\n n = n.replace(\"+\",\"\")\n n = list(n)\n n.sort()\n string = \"\"\n for i in n:\n string = string + str(i) + \"+\"\n if string.endswith('+'):\n string = string[:-1]\n return string\n \n"}, {"source_code": "\"\"\"Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier,\nthe sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count,\nso she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum\n1+3+2+1 but she can calculate sums 1+1+2 and 3+3.\n\nYou've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can\ncalculate the sum.\n\nInput\nThe first line contains a non-empty string s \u2014 the sum Xenia needs to count. String s contains no spaces.\nIt only contains digits and characters \"+\". Besides, string s is a correct sum of numbers 1, 2 and 3.\nString s is at most 100 characters long.\n\nOutput\nPrint the new sum that Xenia can count.\n\nExamples\ninput\n3+2+1\noutput\n1+2+3\n\"\"\"\n\n\ndef summation_in_order(the_string):\n equation = the_string.split('+')\n ones = []\n twos = []\n threes = []\n for i in equation:\n if int(i) == 1:\n ones.append(i)\n elif int(i) == 2:\n twos.append(i)\n elif int(i) == 3:\n threes.append(i)\n entire_equation = []\n for _ in ones:\n entire_equation.append(str(_) + '+')\n for _ in twos:\n entire_equation.append(str(_) + '+')\n for _ in threes:\n entire_equation.append(str(_) + '+')\n entire_equation_true = ''.join(entire_equation)\n entire_equation_true = entire_equation_true[:-1]\n total = 0\n for _ in entire_equation_true:\n if _.isdigit():\n total += int(_)\n return entire_equation_true\n\nprint(summation_in_order('3+2+1'))"}, {"source_code": "\nvar = input(\"Please\")\nplus = \"+\"\nnew = []\nfor i in var:\n new.append(i)\nkek = []\ndiscard = []\nfor i in range(len(new)):\n if new[i] == \"+\":\n discard.append(new[i])\n else:\n kek.append(new[i])\nkek.sort()\na = tuple(kek)\nprint(plus.join(a))\n"}, {"source_code": "l = raw_input().split('+')\nc = {'1': 0, '2': 0, '3': 0}\nfor i in l:\n c[i] += 1\ns = []\nfor key in c.keys():\n s += [key] * c[key]\nprint '+'.join(s)\n"}, {"source_code": "import sys\ns=raw_input()\n\nl=len(s)\nc=0\nd=0\ne=0\n\nfor i in range(0,l):\n if s[i]=='1':\n c=c+1\n elif s[i]=='2':\n d=d+1\n elif s[i]=='3':\n e=e+1\n\nfor i in range(0,c):\n if i==c-1:\n if d>0 or e>0:\n print '1'+'+',\n else:\n print '1'\n else:\n print '1'+'+',\n sys.stdout.softspace=0\nsys.stdout.softspace=0\nfor i in range(0,d):\n if i==d-1:\n if e>0:\n print '2'+'+',\n else:\n print '2'\n else:\n print '1'+'+',\n sys.stdout.softspace=0\nsys.stdout.softspace=0\nfor i in range(0,e):\n if i==e-1:\n print '3'\n else:\n print '3'+'+',\n sys.stdout.softspace=0\n\n\n\n"}, {"source_code": "lst = sorted([str(x) for x in input().split(\"+\")])\nprint(lst)\nstr1 = lst[0] + \"+\"\nfor i in range(1, (len(lst) - 1)):\n str1 = str1 + lst[i] + \"+\"\nstr1 = str1 + lst[len(lst) - 1]\nprint(str1)"}, {"source_code": "n = input()\nl = 0\nk = 0\nj = 0\nh = ''\nfor i in n:\n if i == '1':\n l+=1\n elif i =='2':\n k+=1\n elif i == '3':\n j+=1\nfor s in range(l):\n h += '1+'\nfor q in range(k):\n h += '2+'\nfor w in range(j):\n if w+1!=j:\n h += '3+'\n else: h +='3'\nif (l==1 and k == 0 and j==0) or (l==0 and k == 1 and j==0) or (l==0 and k == 0 and j==1):\n if l==1:\n print(1)\n elif k == 1:\n print(2)\n elif j == 1:\n print(3)\nelif l>1 or j>1 or k>1: \n print(h)"}, {"source_code": "str=input()\ncount1=0\ncount2=0\ncount3=0\nfor i in range(0,len(str)):\n if str[i]=='1':\n count1+=1\n elif str[i]=='2':\n count2+=1\n elif str[i]=='3':\n count3+=1\n\nfor k in range(count1):\n print(1, sep='+',end='')\n print(\"+\",sep='',end='')\nfor u in range(count2):\n print(2, sep='+',end='')\n print(\"+\",sep='',end='')\nfor v in range(count3):\n print(3, sep='+',end='')\n if v!=count3-1:\n print(\"+\", end='')"}, {"source_code": "s = str(input())\nn1 = 0 \nn2 = 0\nn3 = 0\n\nif len(s)==1 :\n print(s) \nelse :\n\n\n for i in s :\n if i == \"1\" :\n n1 += 1\n elif i == \"2\" :\n n2 += 1\n elif i == \"3\":\n n3 += 1 \n if n1 == 0 and n2 == 0 :\n print((n3-1)*\"3+\" + \"3\" )\n elif n2 == 0 and n3 == 0 :\n print((n1-1)*\"1+\" + \"1\" )\n elif n1 == 0 and n3 == 0 :\n print( (n2-1)*\"2+\" + \"2\")\n else :\n print(n1*\"1+\"+ n2*\"2+\" + (n3-1)*\"3+\" + \"3\" )"}, {"source_code": "import sys\ns=raw_input()\nk={}\nk[1]=0\nk[2]=0\nk[3]=0\nfor i in range(0,len(s),2):\n\tif(s[i]=='1'):\n\t\tk[1]=k[1]+1\n\telif(s[i]=='2'):\n\t\tk[2]=k[2]+1\n\telif(s[i]=='3'):\n\t\tk[3]=k[3]+1\np=len(s)/2\nfor i in range(0,k[1],1):\n\tsys.stdout.write('1+')\n\t#print \"1+\",\nfor i in range(k[1],k[2]+k[1],1):\n\tsys.stdout.write('2+')\n\t#print \"2+\",\nfor i in range(k[1]+k[2],k[1]+k[2]+k[3],1):\n\tif(i!=k[1]+k[2]+k[3]-1):\n\t\tsys.stdout.write('3+')\n\t\t#print \"3+\",\n\telse:\n\t\tsys.stdout.write('3')\n\t\t#print \"3\"\n"}, {"source_code": "string = \"2\" #input\ntemp = string.split(\"+\")\n\n#insertion sort\ndef insertionSort(alist):\n for index in range(1,len(alist)):\n\n currentvalue = alist[index]\n position = index\n\n while position>0 and alist[position-1]>currentvalue:\n alist[position]=alist[position-1]\n position = position-1\n\n alist[position]=currentvalue\n\ndef printV(alist):\n temp2 = \"\"\n for i in range (0, len(alist)):\n temp2 += str(alist[i])\n if i != len(alist)-1:\n temp2 += \"+\"\n print(temp2)\n\n\ninsertionSort(temp)\nprintV(temp)\n\n"}, {"source_code": "lst = sorted([str(x) for x in input().split(\"+\")])\n#print(lst)\nstr1 = lst[0] + \"+\"\nfor i in range(1, (len(lst) - 1)):\n str1 = str1 + lst[i] + \"+\"\nstr1 = str1 + lst[len(lst) - 1]\nprint(str1)"}, {"source_code": "x = sorted(input()[::2])\nprint(x)"}, {"source_code": "ring = str(input())\na = sorted(ring[::2])\nb = []\n#print(len(a))\nfor i in range(0,len(a)):\n #print(i)\n b += a[i] + \"+\"\nb = str(b[:-1])\nprint(\"\".join(b))\n"}, {"source_code": "s=input()\nt=len(s)\nk=0\nj=\"\"\nl=[]\nfor i in range(0,len(s)):\n if(s[i]=='+'):\n l.append(s[i-1])\n else:\n continue\nl.sort()\nfor i in range(0,len(l)):\n if(i==len(l)-1):\n j=j+l[i]\n else:\n j=j+l[i]+'+'\n i=i+1\nprint(j) "}, {"source_code": "n=str(input())\na=(n[::-1])\nprint(a)\n"}, {"source_code": "n = input()\ntab = []\ntab2 = []\nans = \"\"\nfor i in n:\n if i != \"+\":\n tab.append(i)\ntab.sort()\nfor o in tab:\n ans += o\n if o != tab[-1]:\n ans += \"+\"\nprint(ans)\n"}, {"source_code": "s = str(input())\nn1 = 0 \nn2 = 0\nn3 = 0\n\nfor i in s :\n if i == \"1\" :\n n1 += 1\n elif i == \"2\" :\n n2 += 1\n elif i == \"3\":\n n3 += 1 \n\nif n1 != 0 :\n print((n1-1)*\"1\" + \"1\")\nelif n2 != 0 :\n print((n2-1)*\"2\" + \"2\")\nelif n3 != 0 :\n print((n3-1)*\"3\" + \"3\")\nelif n1 != 0 and n2 != 0 and n3 != 0 :\n print(n1*\"1+\"+ n2*\"2+\" + (n3-1)*\"3+\" + \"3\" )\nelif n1 != 0 and n2 != 0 :\n print(n1*\"1\" + (n2-1)*\"2\" + \"2\")\nelif n1 != 0 and n3 != 0 :\n print(n1*\"1\" + (n3-1)*\"3\" + \"3\")\nelif n2 != 0 and n3 != 0 :\n print(n2*\"2\" + (n3-1)*\"3\" + \"3\")"}, {"source_code": "a = input()\nb1 = b2 = b3 = 0\nfor i in range(0, len(a), 2):\n if a[i] == '1':\n b1 += 1\n elif a[i] == '2':\n b2 += 1\n else:\n b3 += 1\naa = \"1+\" * b1 + \"2+\" * b2 + \"3+\" * b3\nprint(aa[:-1])\nprint(aa[:-1])"}, {"source_code": "s=raw_input()\no='1+' * s.count('1')\nt='2+' * s.count('2')\nth='3+' * s.count('3')\nif o=='':\n print t,th\nelif o=='' and t=='':\n print th\nelif o=='' and th=='':\n print t\nelif th=='':\n print o,t\nelif th=='' and t=='':\n print o"}, {"source_code": "def rearrange(s):\n c = [0]*3\n i=0\n for i in s:\n if i==\"1\":\n c[0]+=1\n elif i ==\"2\":\n c[1]+=1\n elif i == \"3\":\n c[2]+=1\n s = \"\"\n for i in range(len(c)):\n counter = i+1\n for _ in range(c[i]):\n s+= str(counter) + \"+\"\n s = s[:-1]\n print(s)\n"}, {"source_code": "l = map(int, raw_input().split('+'))\nb = \"\"\nfor i in range(len(l)) :\n if i != len(l)-1 : b+= str(l[i]) + \"+\"\n else : b += str(l[i])\nprint b"}, {"source_code": "s=input()\na=[]\na.append(s[0])\nfor i in range(2,len(s)):\n\tif i%2==0:\n\t\ta.append(s[i])\na.sort()\nfor i in range(len(a)):\n\tprint(a[i]+\"+\",end=\"\")"}, {"source_code": "num=sorted(input().split('+'))\no=''\nfor i in range(len(num)):\n o+=num[i-1]\n if i!=len(num):\n o+='+'\nprint(o)\n \n"}, {"source_code": "string=input()\ncount1=int(0)\ncount2=int(0)\ncount3=int(0)\nfor i in string:\n if i=='1':\n count1+=1\n elif i=='2':\n count2+=1\n elif i=='3':\n count3+=1\nfor i in range(count1-1):\n print(1,end=\"+\")\nprint(1,end=\"\")\nif count2>0 or count3>0:\n print('+',end=\"\")\nfor i in range(count2-1):\n print(2,end=\"+\")\nif count2>0:\n print(2,end=\"\")\nif count3>0:\n print('+',end=\"\")\nfor i in range(count3-1):\n print(3,end=\"+\")\nif count3>0:\n print(3)"}, {"source_code": "s = input()\nl = s.split(\"+\")\nz = sorted(l)\nss = \"\"\nfor i in range(len(z)):\n if len(z) == 1:\n ss = z[i]\n elif i == len(z)-1:\n ss = ss + z[i]\n ss = z[i]\n else:\n ss = ss + z[i] + \"+\"\nss"}, {"source_code": "s=raw_input()\no='1+' * s.count('1')+'2+' * s.count('2') +'3+' * s.count('3')\nprint o[1:]"}, {"source_code": "def HelpfulMaths():\n n = str(input())\n n = n.replace(\"+\",\"\")\n n = list(n)\n n.sort()\n string = \"\"\n for i in n:\n string = string + str(i) + \"+\"\n if string.endswith('+'):\n return string[:-1]"}, {"source_code": "x=raw_input()\nn=\"1\"\nn=\"2\"\nn=\"3\"\n\n\nm=\"\"\ni=1\nwhile i<=len(x)-1 :\n if x[i-1:i]==n:\n m+=n[i-1:i] \n elif x[i-1:i]==n:\n \n m+=n1[i-1:i]\n elif x[i-1:i]==n: \n m+=n2[i-1:i] \n i+=1\nprint m \n"}, {"source_code": "'''\nn=int(input())\nfor i in range(n):\n s=input()\n if len(s)>10:\n print(f'{s[0]}{len(s)-2}{s[len(s)-1]}')\n else:\n print(s)\n'''\n\ns=input()\nli=list()\n\nfor c in s:\n if c >= '1':\n print(c)\n li.append(c)\nli.sort()\ns=\"\"\ni=0\nwhile i<(len(li)-1):\n s+=(li[i]+\"+\")\n i+=1\ns+=li[i]\nprint(s)"}, {"source_code": "x=raw_input()\ny=sorted(x.split(\"+\"))\nprint \"+\".join(x)"}, {"source_code": "num=sorted(input().split('+'))\no=''\nfor i in num:\n o+=i\n o+='+'\nprint(o)\n \n"}, {"source_code": "n = input()\nn1 = n2 = n3 = 0\nfor i in range(0, len(n)):\n if n[i] == '1':\n n1 += 1\n elif n[i] == '2':\n n2 += 1\n else:\n n3 += 1\nres = \"1+\" * n1 + \"2+\" * n2 + \"3+\" * n3\nprint(res[::-1])\n"}, {"source_code": "x = raw_input().split(\"+\")\nprint '+'.join(x)"}, {"source_code": "s=str(input())\ns1=s.split('+')\nsum=0\ns1.sort()\nfor i in s1:\n print(i,sep='+')"}, {"source_code": "a=input()\nfor i in range(0,len(a),2):\n for j in range(2, len(a)-2,2):\n if (a[j]>a[i]):\n temp=a[j]\n a=a.replace(a[i],a[j])\n a=a.replace(a[j],temp)\nprint(a)"}, {"source_code": "a =input().split('+')\n\nfor i in range(len(a)):\n for j in range(len(a[i+1:])):\n print(a[i+1:],end = '')\n print(a[i] + '.' + a[i+j+1])\n if(a[i] > a[i+j+1]):\n temp = a[i]\n a[i] = a[i+j+1]\n a[i+j+1] = temp\nprint('+'.join(a))\n"}, {"source_code": "n=input()\nn_1=0\nn_2=0\nn_3=0\ni=0\nwhile(i<len(n)):\n if(n[i]==\"1\"):\n n_1+=1\n elif(n[i]==\"2\"):\n n_2+=1\n else:\n n_3+=1\n i+=2\nprint((n_1 * \"1+\")+(n_2 * \"2+\")+(n_3 * \"3\"))\n "}, {"source_code": "s=str(raw_input())\na=s.split('+')\na.sort(key=int)\n\nfor i in a:\n\tprint i\n\tif a.index(i)!=len(a)-1:\n\t\tprint '+'\n\n\n"}, {"source_code": "line = input()\n\n\ndef sortN(numbers):\n if (len(numbers) == 1) or (len(numbers) == 0):\n return numbers\n num = numbers[0]\n\n left = []\n mid = []\n right = []\n for i in numbers:\n if i == num:\n mid.append(i)\n elif i < num:\n left.append(i)\n else:\n right.append(i)\n\n return sortN(left) + mid + sortN(right)\n\n\nstrin = \"\"\nif len(line) == 1:\n print(line)\nelse:\n numbers = [int(i) for i in line.split(\"+\")]\n sortN(numbers)\n print('+'.join(str(x) for x in numbers))\n\n"}, {"source_code": "def arrangesum(s):\n sList = s.split(\"+\")\n sListInts = []\n outStr = \"\"\n\n try:\n for x in sList:\n sListInts.append(int(x))\n sListInts.sort()\n outStr = str(sListInts[0])\n for y in range(len(sListInts)-1):\n outStr += \"+\" + str(sListInts[y+1])\n\n except(ValueError):\n outStr = \"Error\"\n return outStr"}, {"source_code": "a=input().split('+')\na.sort()\n#s=''\nfor i in range(len(a)):\n\tprint(a[i],'+',sep='',end='')"}, {"source_code": "string = input()\nnewStr = []\nfor i in range(len(string)):\n if(string[i] != '+'):\n newStr.append(int(string[i]))\nnewStr.sort()\nandron = len(string)\nfor i in newStr:\n if(i != len(newStr)):\n print((str(i) + '+'), end=\"\")\n else:\n print((str(i)), end=\"\")"}, {"source_code": "\n\ndef sort(alist):\n iteration = 0\n while iteration < len(alist):\n greatestindex = iteration\n i = iteration\n while i < len(alist):\n if (alist[i]) > (alist[greatestindex]):\n greatestindex = i\n i += 1\n temp = alist[greatestindex]\n alist[greatestindex] = alist[iteration]\n alist[iteration] = temp\n iteration += 1\n return alist\n\n\ns = input()\ns = s.split(\"+\")\ns = list(map(int, s))\nprint(sort(s))"}, {"source_code": "line=raw_input()\np=list(line)\nif len(p)>1:\n for i in range(0,len(p),2):\n if i>=(len(p)-1):\n i=0\n if p[i]>=p[i+2]:\n z=p[i]\n p[i]=p[i+2]\n p[i+2]=z\n \n \n \n \nprint \"\".join(p)\n \n \n \n \n\n "}, {"source_code": "a=\" \"\nn=input()\nm=n.split(\"+\")\nfor i in range(len(m)):\n for j in range(i,len(m)):\n if m[i]>m[j]:\n t=m[i]\n m[i]=m[j]\n m[j]=t\nfor i in range(len(m)):\n if i==0:\n print(m[i],end=\"\")\n else:\n print(\"+\",m[i],end=\"\")"}, {"source_code": "\"\"\"Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier,\nthe sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count,\nso she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum\n1+3+2+1 but she can calculate sums 1+1+2 and 3+3.\n\nYou've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can\ncalculate the sum.\n\nInput\nThe first line contains a non-empty string s \u2014 the sum Xenia needs to count. String s contains no spaces.\nIt only contains digits and characters \"+\". Besides, string s is a correct sum of numbers 1, 2 and 3.\nString s is at most 100 characters long.\n\nOutput\nPrint the new sum that Xenia can count.\n\nExamples\ninput\n3+2+1\noutput\n1+2+3\n\"\"\"\n\n\ndef summation_in_order(the_string):\n equation = the_string.split('+')\n ones = []\n twos = []\n threes = []\n for i in equation:\n if int(i) == 1:\n ones.append(i)\n elif int(i) == 2:\n twos.append(i)\n elif int(i) == 3:\n threes.append(i)\n entire_equation = []\n for _ in ones:\n entire_equation.append(str(_) + '+')\n for _ in twos:\n entire_equation.append(str(_) + '+')\n for _ in threes:\n entire_equation.append(str(_) + '+')\n entire_equation_true = ''.join(entire_equation)\n entire_equation_true = entire_equation_true[:-1]\n total = 0\n for _ in entire_equation_true:\n if _.isdigit():\n total += int(_)\n return entire_equation_true\n\nsummation_in_order('3+2+1')\nsummation_in_order('1+1+3+1+3')\nsummation_in_order('2')"}, {"source_code": "line = input()\nline = line.split(\"+\")\nline2 = []\nfor i in line:\n line2.append(int(i))\nline2 = sorted(line2)\noutput = \"\"\nfor i in line2:\n output += str(i) + \"+\"\nprint(output[:len(output)-2])"}, {"source_code": "s = str(input())\nli = list(s.split(\"+\"))\nli2 = []\ns2=\"\"\n\nfor i in range(len(li)):\n li2.append(int(li[i]))\nli2.sort(reverse=True)\nfor i in range(len(li2)):\n s2 = s2 + str(li2[i])+\"+\"\n# s3 = s2[:(2*len(li2))]\nprint(s2)"}, {"source_code": "s = input()\nx1 = 0\nx2 = 0\nx3 = 0\nfor i in range(len(s)):\n if s[i] == \"1\":\n x1 += 1\n if s[i] == \"2\":\n x2 += 1\n if s[i] == \"3\":\n x3 += 1\nif x1 != 0:\n print(1 , end = \"\")\n for i in range(x1 - 1):\n print(\"+1\" , end = \"\")\n for i in range(x2):\n print(\"+2\" , end = \"\")\n for i in range(x3):\n print(\"+3\" , end = \"\")\nelif x2 != 0:\n print(2 , end = \"\")\n for i in range(x2):\n print(\"+2\" , end = \"\")\n for i in range(x3):\n print(\"+3\" , end = \"\")\nelif x3 != 0:\n print(3 , end = \"\")\n for i in range(x3):\n print(\"+3\" , end = \"\")\n"}, {"source_code": "#Helpful Maths\n\nnums=str(raw_input())\ndata=nums.split(\"+\")\ndata.sort()\nprint(data)\nmin=data[0]\nstring=\"\"\nfor i in range (len(data)):\n if(i==len(data)-1):\n string +=data[i]\n else:\n string +=data[i]+\"+\"\n\n\n\nprint(string)\n#valores=None\n#valores[0]=min"}, {"source_code": "def helpfulMaths(s):\n\n\ts = list(s)\n\tt = []\n\n\tfor i in range(len(s)):\n\t\tif s[i] != '+':\n\t\t\tt.append(s[i])\n\n\tt = sorted(t)\n\n\ti = 0\n\twhile i < len(t) - 1:\n\t\tt.insert(i + 1, '+')\n\t\ti += 2\n\treturn t\n\ns = raw_input()\nhelpfulMaths(s)\n\n# print(helpfulMaths('1+1+3+2'))"}, {"source_code": "s=list(input())\ns.sort()\nfor i in s:\n if(i=='1' or i=='2' or i=='3'):\n print(i,\"+\")\n\n "}, {"source_code": "terms = raw_input().split('+')\nif len(terms) == 1:\n print terms\nelse:\n ints = []\n for term in terms:\n ints.append(int(term))\n ints.sort()\n result = \"\"\n\n for num in ints:\n if ints.index(num) + 1 == len(ints):\n print result\n else:\n result = result + str(num) + '+'\n"}, {"source_code": "try:\n var = int(input(\"Please: \"))\n plus = \"+\"\n new = []\n for i in var:\n new.append(i)\n kek = []\n discard = []\n for i in range(len(new)):\n if new[i] == \"+\":\n discard.append(new[i])\n else:\n kek.append(new[i])\n kek.sort()\n a = tuple(kek)\n print(plus.join(a))\nexcept ValueError:\n print(\"huh\")\n"}, {"source_code": "w = str(input())\nx = w.split(\"+\")\nx.sort\nnw = \"\"\nfor n in x:\n nw += n + \"+\"\nprint(nw[:len(nw) -1])"}, {"source_code": "lst = sorted([str(x) for x in input().split(\"+\")])\n#print(lst)\nstr1 = lst[0] + \"+\"\nfor i in range(1, (len(lst) - 1)):\n str1 = str1 + lst[i] + \"+\"\nstr1 = str1 + lst[len(lst) - 1]\nprint(str1)"}, {"source_code": "list = input().split(\"+\")\nint_list = []\nfor _ in list:\n int_list.append(int(_))\nsorted_int_list = sorted(int_list)\nprint(sorted_int_list)\n "}, {"source_code": "data=raw_input()\nif len(data)==1:\n print data\nelse:\n dat=data.split(\"+\")\n s=sorted(dat)\n for i in range(len(s)-1):\n print s[i]+\"+\",\n print s[len(s)-1]\n"}, {"source_code": "s=input()\na=[]\na.append(s[0])\nfor i in range(2,len(s)):\n\tif i%2==0:\n\t\ta.append(s[i])\na.sort()\nfor i in range(len(a)):\n\tprint(a[i]+\"+\",end=\"\")"}, {"source_code": "import random\n\ndef del_nulls(arr):\n\tx = {}\n\tcount, i = 0, -1\n\twhile i < len(arr) - 1:\n\t\ti += 1\n\t\tcount += 1\n\t\tif arr[i] in x: \n\t\t\tx[arr[i]] += 1\n\t\t\tarr.remove(arr[i])\n\t\t\ti -= 1\n\t\telse: x.update([(arr[i], 1)])\n\treturn(x)\n\ndef qsort(arr, left, right):\n\tif (right - left > 1):\n\t\ta = random.randint(left, right)\n\t\tl, r = left, right\n\t\twhile (l != r):\n\t\t\twhile (arr[l] < arr[a]): l += 1\n\t\t\twhile (arr[r] > arr[a]): r -= 1\n\t\t\tif (l > r):\n\t\t\t\tl, r = r, l\n\t\t\telse:\n\t\t\t\tarr[l], arr[r] = arr[r], arr[l]\n\t\tif (l != right):\n\t\t\tqsort(arr, left, l)\n\t\tif (r != left):\n\t\t\tqsort(arr, r, right)\n\telif (arr[left] > arr[right]):\n\t\tarr[left], arr[right] = arr[right], arr[left]\n\t\t\narr = list(map(int, input().split('+')))\n\ndel_list = del_nulls(arr)\nqsort(arr, 0, len(arr) - 1)\nfor i in range(0, len(arr)):\n\tfor j in range(0, del_list[arr[i]]):\n\t\tif (not(i == 0 and j == 0)): print('+', end='')\n\t\tprint(arr[i], end='')"}, {"source_code": "s=list(input())\ns.sort()\nn=len(s)\nfor i in s:\n if(i=='1' or i=='2' or i=='3'):\n print(i,end=\"\")\n if(i!=s):\n print(\"+\")\n \n "}, {"source_code": "string=input()\ncount1=int(0)\ncount2=int(0)\ncount3=int(0)\nfor i in string:\n if i=='1':\n count1+=1\n elif i=='2':\n count2+=1\n elif i=='3':\n count3+=1\nfor i in range(count1-1):\n print(1,end=\"+\")\nprint(1,end=\"\")\nif count2>0 or count3>0:\n print('+',end=\"\")\nfor i in range(count2-1):\n print(2,end=\"+\")\nif count2>0:\n print(2,end=\"\")\nif count3>0:\n print('+',end=\"\")\nfor i in range(count3-1):\n print(3,end=\"+\")\nif count3>0:\n print(3)"}, {"source_code": "s=input()\na=[]\na.append(s[0])\nfor i in range(2,len(s)):\n if i%2==0:\n a.append(s[i])\na.sort()\nfor i in range(len(a)):\n print(a[i]+\"+\")"}, {"source_code": "s=input()\nx1=0\nx2=0\nx3=0\na=\"\"\nfor i in range(0,len(s),2):\n if(s[i]=='1'):\n x1=x1+1\n elif(s[i]=='2'):\n x2=x2+1\n elif(s[i]=='3'):\n x3=x3+1\nfor i in range(0,x1):\n a=a+'1+'\nfor i in range(0,x2):\n a=a+'2+'\nfor i in range(0,x3):\n a=a+'3+'\nprint(a.replace(a[len(s)],\"\"))"}, {"source_code": "def solve(string):\n nums = [str(i) for i in range(1, 4)]\n nums_to_sort = []\n\n for el in string:\n if nums.count(el) == 1:\n nums_to_sort.append(el)\n\n nums_to_sort.sort()\n for i in range(len(nums_to_sort)-1):\n nums_to_sort[i] += \"+\"\n\n for el in nums_to_sort:\n print(el, end=\"\")\n\nsolve(\"3+3+3+2+1+2+1\")"}, {"source_code": "s = raw_input()\nsn = []\nj = 0\nfor i in range(0,len(s),2):\n sn.append(s[i])\n j += 1\n\nk = 0\nwhile k < len(sn):\n for i in range(k,len(sn)-1):\n if sn[i+1]< sn[i]:\n sn[i],sn[i+1] = sn[i+1], sn[i]\n k = i\n k += 1\n\nsp = sn[0]\nfor i in range(1,len(sn)):\n sp = sp + '+' + sn[i]\nprint sp\n"}, {"source_code": "\nvar = input(\"Please\")\nplus = \"+\"\nnew = []\nfor i in var:\n new.append(i)\nkek = []\ndiscard = []\nfor i in range(len(new)):\n if new[i] == \"+\":\n discard.append(new[i])\n else:\n kek.append(new[i])\nkek.sort()\na = tuple(kek)\nprint(plus.join(a))\n"}, {"source_code": "def HelpfulMaths():\n n = str(input())\n n = n.replace(\"+\",\"\")\n n = list(n)\n n.sort()\n string = \"\"\n for i in n:\n string = string + str(i) + \"+\"\n if string.endswith('+'):\n string = string[:-1]\n return string\n \n"}, {"source_code": "string = input()\nnewStr = []\nfor i in range(len(string)):\n if(string[i] != '+'):\n newStr.append(int(string[i]))\nnewStr.sort()\nandron = len(string)\nfor i in newStr:\n if(i != len(newStr) - 1):\n print((str(i) + '+'), end=\"\")\n else:\n print((str(i)), end=\"\")"}, {"source_code": "s = input()\nl = s.split('+')\ns1 = \"\"\nadd = 0\nif l == sorted(l):\n for i in l:\n add += int(i)\n print(add)\nelse:\n for i in range(len(l)):\n s1 += (l[i] + '+')\n print(s1[0:-1])\n "}, {"source_code": "\n\ndef sort(alist):\n iteration = 0\n while iteration < len(alist):\n greatestindex = iteration\n i = iteration\n while i < len(alist):\n if (alist[i]) > (alist[greatestindex]):\n greatestindex = i\n i += 1\n temp = alist[greatestindex]\n alist[greatestindex] = alist[iteration]\n alist[iteration] = temp\n iteration += 1\n return alist\n\n\ns = input()\ns = s.split(\"+\")\ns = list(map(int, s))\ns = sort(s)\nprintstring = \"\"\ni = 0\nwhile i < len(s):\n printstring += str(s[i])\n if i < len(s)-1:\n printstring += \"+\"\n i += 1\n\nprint(printstring)\n"}, {"source_code": "a=input()\nfor i in range(0,len(a),2):\n for j in range(2, len(a)-2,2):\n if (a[i]>a[j]):\n temp=a[j]\n a=a.replace(a[i],a[j])\n a=a.replace(a[j],temp)\nprint(a)"}, {"source_code": "inp = input()\nnums = []\nfor symb in inp:\n if symb != '+':\n nums.append(int(symb))\nnums.sort()\nnew_str = ''\ncounter = 0\nfor num in nums:\n if counter == 0:\n new_str += str(num)\n else:\n new_str+= '+' + str(num)\n counter+=1\nprint(nums)\nprint(new_str)"}, {"source_code": "n=input()\nl=len(n)\no=0\nt=0\nth=0\nif(l==1):\n print(n)\nelse:\n for i in range(l): \n b=n[i]\n if(i%2==0):\n if(b=='1'):\n o+=1\n elif(b=='2'):\n t+=1\n elif(b=='3'):\n th+=1\n a=''\n for i in range(o):\n a=a+'1+'\n for i in range(t):\n a=a+'2+'\n for i in range(th-1):\n a=a+'3+'\n if(th!=0):\n a=a+'3'\n print(a)"}, {"source_code": "string = raw_input().split('+')\n# print(string)\nif len(string) == 1:\n print (string)\nelse:\n \n string = '+'.join(sorted(list(string)))\n print(string)"}, {"source_code": "s=input()\nc1=s.count('1')\nc2=s.count('2')\nc3=s.count('3')\nprint('+'.join('1'*c1)+ '+' +'+'.join('2'*c2)+'+'.join('3'*c3))"}, {"source_code": "o=input()\nm=str.split(o)\nm.sort()\nprint(m)\n"}, {"source_code": "s = input()\nmass = list(map(int, s.split(\"+\")))\n\nfor j in range(len(mass)):\n minid = j\n for i in range(j+1, len(mass)):\n if mass[minid] > mass[i]:\n minid = i\n minim = mass[minid]\n mass[minid] = mass[j]\n mass[j] = minim\nmass.reverse()\n\nns = str(mass[0])\nfor i in range(1, len(mass)):\n ts = str(mass[i])\n ns = ns + \"+\" + ts\n\nprint(s)\n"}, {"source_code": "entrada = input().split()\nlista = []\nfor i in range(len(entrada)):\n if(entrada[i] == \"1\" or entrada[i] == \"2\" or entrada[i] == \"3\"):\n lista.append(int(entrada[i]))\nlista.sort()\nsaida = \"\"+entrada[0]\nfor i in range(1,len(lista)):\n saida += \" + \"+str(lista[i])\nprint(saida)\n"}, {"source_code": "def quicksort(a, p, r):\n if (p >= r):\n return\n q = partition(a, p, r)\n quicksort(a, p, q)\n quicksort(a, q + 1, r)\n\ndef partition(a, p, r):\n q = (p + r) // 2\n for i in range(p, q):\n if a[i] > a[q]:\n a[i], a[q] = a[q], a[i]\n q = i\n break\n \n for i in range(q + 1, r):\n if a[q] > a[i]:\n a[i], a[q] = a[q], a[i]\n q = i\n\n return q\n\nnumbers = [int(i) for i in input().split('+')]\nquicksort(numbers, 0, len(numbers))\nprint('+'.join([str(i) for i in numbers]))\n"}, {"source_code": "line=raw_input()\np=list(line)\nif len(p)>1:\n for i in range(0,len(p),2):\n if i>=(len(p)-1):\n i=0\n if p[i]>=p[i+2]:\n z=p[i]\n p[i]=p[i+2]\n p[i+2]=z\n \n \n \n \nprint \"\".join(p)\n \n \n \n \n\n "}, {"source_code": "s=list(input())\ns.sort()\nn=len(s)\nfor i in s:\n if(i=='1' or i=='2' or i=='3'):\n print(i,end=\"\")\n if(i!=s):\n print(\"+\")\n \n "}, {"source_code": "s = input()\nif len(s)>1:\n for i in range(0,len(s)-1,2):\n if int(s[i])<=int(s[i+2]):\n print(s[i]+'+',end='')\n else:\n print(s[i+2]+'+',end='')\n \n print(s[i+2])\nelse:\n print(s)\n\n\n \n "}, {"source_code": "op = list(map(int , input().split('+')))\n \nop.sort()\n \n \nprint(''.join([str(i) if i % 2 == 0 else \"+\" for i in range((2 * len(op)) + 1)]))\n "}, {"source_code": "#Helpful Maths\n\nnums=str(raw_input())\ndata=nums.split(\"+\")\ndata.sort()\nprint(data)\nmin=data[0]\nstring=\"\"\nfor i in range (len(data)):\n if(i==len(data)-1):\n string +=data[i]\n else:\n string +=data[i]+\"+\"\n\n\n\nprint(string)\n#valores=None\n#valores[0]=min"}, {"source_code": "a=input()\nb=len(a)\nif b==1:\n print(a)\nelse:\n l=[]\n for i in range(0,b,2):\n l.append(a[i])\n l=sorted(l)\n for i in range(len(l)):\n if l[i]==l[len(l)-1]:\n print(l[i],end='')\n else:\n print(l[i],end='+')"}, {"source_code": "s = input()\nl = s.split('+')\ns1 = \"\"\nadd = 0\nif l == sorted(l):\n for i in l:\n add += int(i)\n print(add)\nelse:\n l = sorted(l)\n for i in range(len(l)):\n s1 += (l[i] + '+')\n print(s1[0:-1])\n "}, {"source_code": "def maths(a):\n a.split(\"+\")\n a=sorted(a)\n s=\"\"\n a=a[int(len(a)/2):]\n print(a)\n for i in a:\n s=s+str(i)+\"+\"\n return s[:len(s)-1]\na=input()\nmaths(a)\n"}, {"source_code": "s = input()\nn1 = n2 = n3 = 0\nfor i in range(0, len(s), 2):\n if s[i] == '1':\n n1 += 1\n elif s[i] == '2':\n n2 += 1\nss = \"1+\" * n1 + \"2+\" * n2 + \"3+\" * n3\nprint(ss[:-1])"}, {"source_code": "s = raw_input()\none = 0\ntwo = 0\nthree =0\nfor char in s:\n if char == '1':\n one+=1\n elif char == '2':\n two+=1\n elif char == '3':\n three+=1\nones = '1+'*one\ntwos = '2+'*two\nthree = '3+'*three\nans = ones.rstrip('+')+'+'+twos.rstrip('+')\nans =ans.rstrip('+')+ '+'+three.rstrip('+')\nans = ans.rstrip('+')\ni = 0\nwhile True:\n if i<len(ans)-1 and ans[i]=='+':\n ans = ans[1:]\n i+=1\n else:\n break\n\nprint ans"}, {"source_code": "xenia = input('')\nnew = []\nfinal = ''\nnew.extend(xenia)\nfor i in new:\n if i == '+':\n new.remove(i)\n\nnew.sort()\nfor j in new:\n if new.index(j) == new.__len__() - 1:\n final += j\n else:\n final += j + '+'\n\nprint(final)"}, {"source_code": "\n\ndef sort(alist):\n iteration = 0\n while iteration < len(alist):\n greatestindex = iteration\n i = iteration\n while i < len(alist):\n if (alist[i]) > (alist[greatestindex]):\n greatestindex = i\n i += 1\n temp = alist[greatestindex]\n alist[greatestindex] = alist[iteration]\n alist[iteration] = temp\n iteration += 1\n return alist\n\n\ns = input()\ns = s.split(\"+\")\ns = list(map(int, s))\nprint(sort(s))"}], "src_uid": "76c7312733ef9d8278521cf09d3ccbc8"} {"source_code": "k = {\n 0: 'zero',\n 1: 'one',\n 2: 'two',\n 3: 'three',\n 4: 'four',\n 5: 'five',\n 6: 'six',\n 7: 'seven',\n 8: 'eight',\n 9: 'nine',\n 10: 'ten',\n 11: 'eleven',\n 12: 'twelve',\n 13: 'thirteen',\n 14: 'fourteen',\n 15: 'fifteen',\n 16: 'sixteen',\n 17: 'seventeen',\n 18: 'eighteen',\n 19: 'nineteen',\n 20: 'twenty',\n 30: 'thirty',\n 40: 'forty',\n 50: 'fifty',\n 60: 'sixty',\n 70: 'seventy',\n 80: 'eighty',\n 90: 'ninety'\n }\n \nn=int(input())\nif n in k:\n print(k[n])\nelse:\n print(k[n//10*10]+'-'+k[n%10])", "positive_code": [{"source_code": "n = input()\nx = [\"\",\"\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\ny = [\"\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\na = n / 10\nb = n % 10\nif n == 0:\n\tprint \"zero\"\nelif n == 10:\n\tprint \"ten\"\nelif n == 11:\n\tprint \"eleven\"\nelif n == 12:\n\tprint \"twelve\"\nelif n == 13:\n\tprint \"thirteen\"\nelif n == 14:\n\tprint \"fourteen\"\nelif n == 15:\n\tprint \"fifteen\"\nelif n == 16:\n\tprint \"sixteen\"\nelif n == 17:\n\tprint \"seventeen\"\nelif n == 18:\n\tprint \"eighteen\"\nelif n == 19:\n\tprint \"nineteen\"\nelif b == 0:\n\tprint x[a]\nelif a == 0:\n\tprint y[b]\nelse:\n\tprint str(x[a])+'-'+str(y[b])"}, {"source_code": "import math\n\nnumber = int(input())\n\nnumber_list = [\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nteen_list = [\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ndecades_list =[\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\n\n\nif number <= 9:\n print(number_list[number])\nelif number >= 10 and number <= 19:\n tens = number % 10\n print(teen_list[tens])\nelif number > 19 and number <= 99:\n ones = math.floor(number/10)\n twos = ones - 2\n tens = number % 10\n if tens == 0:\n print(decades_list[twos])\n elif tens != 0:\n print(decades_list[twos] + \"-\" + number_list[tens])\n"}, {"source_code": "FirstDigit = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\nTenAbove = [\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\",\n \"nineteen\"]\nSecond = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\nN = input()\nif len(N) == 1:\n print(FirstDigit[int(N)])\nelse:\n if int(N) in range(10, 20):\n print(TenAbove[int(N[1])])\n else:\n print(Second[int(N[0]) - 2], end=\"\")\n print(\"\" if N[1] == '0' else \"-\" + FirstDigit[int(N[1])])\n\n# UB_CodeForces\n# Advice: Don't live the others versions of your life\n# Location: At home behind my desk\n# Caption: Should study for Internet engineering exam but submitting codes\n# CodeNumber: 486\n"}, {"source_code": "digits = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',\n'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',\n'sixteen', 'seventeen', 'eighteen', 'nineteen')\ntens = ('', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy',\n'eighty', 'ninety')\n\nx = int(raw_input())\n\nif x < 20:\n print digits[x]\nelse:\n if x % 10 == 0:\n print tens[x/10]\n else:\n print tens[x/10] + '-' + digits[x%10]\n\n\n"}, {"source_code": "a=\"zero one two three four five six seven eight nine\".split()\nb=\"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc=\"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn=input()\nprint c[n//10]+(\"-\"+a[n%10]if n%10else\"\")if n>19else b[n%10]if n>9else a[n]"}, {"source_code": "units =[\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\ntens = [\"\",\"ten\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\ncooked = [\"\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\nn = input()\n\nif len(n)==1:\n print(units[int(n)])\nelse:\n if n[1]==\"0\":\n print(tens[int(n[0])])\n else:\n if n[0]==\"1\":\n print(cooked[int(n[1])])\n else:\n print(tens[int(n[0])]+\"-\"+units[int(n[1])])\n\n\n\n"}, {"source_code": "arr = ['one','two','three','four','five','six','seven','eight','nine','ten',\\\n 'eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen',\\\n 'eighteen','nineteen']\nbrr = ['','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n\n\nn = input()\nif n==0:\n print 'zero'\nelif n<=19:\n print arr[n-1]\nelse:\n q = n/10\n s = ''\n if n%10!=0:\n s = '-'+arr[n%10-1]\n print brr[q-1]+s\n"}, {"source_code": "max=str(input())\nz=0\nd=0\nc=0\npin=str(\"\")\ntens=0\n\nfor x in max:\n c=c+1\n\nif (c==2):\n z=1\n d=1\n \nfor x in max:\n \n \n if (z==1) and (tens==0) and (x!=\"0\") and (d==0):\n pin=pin+str(\"-\")\n \n if (tens==0) and (d==0):\n if x==\"1\":\n pin=pin+str(\"one\")\n elif x==\"2\":\n pin=pin+str(\"two\")\n elif x==\"3\":\n pin=pin+str(\"three\")\n elif x==\"4\":\n pin=pin+str(\"four\")\n elif x==\"5\":\n pin=pin+str(\"five\")\n elif x==\"6\":\n pin=pin+str(\"six\")\n elif x==\"7\":\n pin=pin+str(\"seven\")\n elif x==\"8\":\n pin=pin+str(\"eight\")\n elif x==\"9\":\n pin=pin+str(\"nine\")\n \n elif (tens==1) and (d==0):\n if x==\"0\":\n pin=pin+str(\"ten\") \n if x==\"1\":\n pin=pin+str(\"eleven\")\n elif x==\"2\":\n pin=pin+str(\"twelve\")\n elif x==\"3\":\n pin=pin+str(\"thirteen\")\n elif x==\"4\":\n pin=pin+str(\"fourteen\")\n elif x==\"5\":\n pin=pin+str(\"fifteen\")\n elif x==\"6\":\n pin=pin+str(\"sixteen\")\n elif x==\"7\":\n pin=pin+str(\"seventeen\")\n elif x==\"8\":\n pin=pin+str(\"eighteen\")\n elif x==\"9\":\n pin=pin+str(\"nineteen\")\n \n \n elif z==1 and d==1:\n if x==\"1\":\n tens=1\n d=0\n elif x==\"2\":\n pin=pin+str(\"twenty\")\n d=0\n elif x==\"3\":\n pin=pin+str(\"thirty\")\n d=0\n elif x==\"4\":\n pin=pin+str(\"forty\")\n d=0\n elif x==\"5\":\n pin=pin+str(\"fifty\")\n d=0\n elif x==\"6\":\n pin=pin+str(\"sixty\")\n d=0\n elif x==\"7\":\n pin=pin+str(\"seventy\")\n d=0\n elif x==\"8\":\n pin=pin+str(\"eighty\")\n d=0\n elif x==\"9\":\n pin=pin+str(\"ninety\")\n d=0\n \nif max==\"0\":\n print(\"zero\")\nelse:\n print(pin)"}, {"source_code": "numbers = {\n 0: \"zero\", 10: \"ten\", 1: \"one\", 11: \"eleven\", 2: \"two\",\t12: \"twelve\", 20: \"twenty\", 3: \"three\",\n 13: \"thirteen\", 30: \"thirty\", 4: \"four\", 14: \"fourteen\", 40: \"forty\", 5: \"five\", 15: \"fifteen\",\n 50:\t\"fifty\", 6: \"six\", 16: \"sixteen\", 60: \"sixty\", 7: \"seven\", 17: \"seventeen\", 70: \"seventy\",\n 8: \"eight\", 18: \"eighteen\", 80: \"eighty\", 9: \"nine\",19: \"nineteen\", 90: \"ninety\"\n}\ns = int(input())\nif s <= 20:\n print(numbers[s])\nelse:\n if s % 10 == 0:\n print(numbers[s])\n else:\n pre = int(s / 10) * 10\n left = s - pre\n print(numbers[pre] + \"-\" + numbers[left])"}, {"source_code": "n = raw_input()\nans = []\nif n == \"0\":\n ans.append(\"zero\")\nelif n == \"10\":\n ans.append(\"ten\")\nelif n == \"11\":\n ans.append(\"eleven\")\nelif n == \"12\":\n ans.append(\"twelve\")\nelif n == \"13\":\n ans.append(\"thirteen\")\nelif n == \"14\":\n ans.append(\"fourteen\")\nelif n == \"15\":\n ans.append(\"fifteen\")\nelif n == \"16\":\n ans.append(\"sixteen\")\nelif n == \"17\":\n ans.append(\"seventeen\")\nelif n == \"18\":\n ans.append(\"eighteen\")\nelif n == \"19\":\n ans.append(\"nineteen\")\nelse:\n if len(n)==2:\n if n[0] == \"2\":\n ans.append(\"twenty\")\n elif n[0] == \"3\":\n ans.append(\"thirty\")\n elif n[0] == \"4\":\n ans.append(\"forty\")\n elif n[0] == \"5\":\n ans.append(\"fifty\")\n elif n[0] == \"6\":\n ans.append(\"sixty\")\n elif n[0] == \"7\":\n ans.append(\"seventy\")\n elif n[0] == \"8\":\n ans.append(\"eighty\")\n elif n[0] == \"9\":\n ans.append(\"ninety\")\n if n[len(n)-1] == \"1\":\n ans.append(\"one\")\n if n[len(n)-1] == \"2\":\n ans.append(\"two\")\n if n[len(n)-1] == \"3\":\n ans.append(\"three\")\n if n[len(n)-1] == \"4\":\n ans.append(\"four\")\n if n[len(n)-1] == \"5\":\n ans.append(\"five\")\n if n[len(n)-1] == \"6\":\n ans.append(\"six\")\n if n[len(n)-1] == \"7\":\n ans.append(\"seven\")\n if n[len(n)-1] == \"8\":\n ans.append(\"eight\")\n if n[len(n)-1] == \"9\":\n ans.append(\"nine\")\nprint \"-\".join(ans)"}, {"source_code": "a=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nb=['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nn=int(raw_input())\nif n/10<2:\n\tprint a[n]\nelse:\n\tif n%10==0:\n\t\tprint b[n/10-2]\n\telse:\n\t\tprint b[n/10-2]+'-'+a[n%10]"}, {"source_code": "a=\"zero one two three four five six seven eight nine\".split()\nb=\"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc=\"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn=int(input())\nprint(c[n//10]+(\"-\"+a[n%10]if n%10else\"\")if n>19else b[n%10]if n>9else a[n])\n"}, {"source_code": "n = input()\nd = ['zero', 'one', 'two', 'three', 'four', 'five','six','seven','eight','nine', 'ten', 'eleven', 'twelve','thirteen','fourteen', 'fifteen', 'sixteen','seventeen','eighteen','nineteen']\nd0 = ['zero','zero', 'twenty', 'thirty', 'forty', 'fifty', 'sixty','seventy','eighty','ninety']\nif n < 20:\n print d[n]\nelse:\n a0 = int(str(n)[0])\n a1 = int(str(n)[1])\n if not a1:\n print d0[a0]\n else:\n print '-'.join([d0[a0], d[a1]])"}, {"source_code": "import sys\n\nd = {\n '0': 'zero',\n '1': 'one',\n '2': 'two',\n '3': 'three',\n '4': 'four',\n '5': 'five',\n '6': 'six',\n '7': 'seven',\n '8': 'eight',\n '9': 'nine',\n '10': 'ten',\n '11': 'eleven',\n '12': 'twelve',\n '13': 'thirteen',\n '14': 'fourteen',\n '15': 'fifteen',\n '16': 'sixteen',\n '17': 'seventeen',\n '18': 'eighteen',\n '19': 'nineteen',\n '20': 'twenty',\n '30': 'thirty',\n '40': 'forty',\n '50': 'fifty',\n '60': 'sixty',\n '70': 'seventy',\n '80': 'eighty',\n '90': 'ninety',\n}\n\nif __name__ == '__main__':\n s = raw_input()\n \n if s in d:\n print d[s]\n sys.exit()\n\n a, b = list(s)\n\n print '{}-{}'.format(d[str(int(a)*10)], d[b])\n"}, {"source_code": "a=int(input())\nprint(['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty-one', 'twenty-two', 'twenty-three', 'twenty-four', 'twenty-five', 'twenty-six', 'twenty-seven', 'twenty-eight', 'twenty-nine', 'thirty', 'thirty-one', 'thirty-two', 'thirty-three', 'thirty-four', 'thirty-five', 'thirty-six', 'thirty-seven', 'thirty-eight', 'thirty-nine', 'forty', 'forty-one', 'forty-two', 'forty-three', 'forty-four', 'forty-five', 'forty-six', 'forty-seven', 'forty-eight', 'forty-nine', 'fifty', 'fifty-one', 'fifty-two', 'fifty-three', 'fifty-four', 'fifty-five', 'fifty-six', 'fifty-seven', 'fifty-eight', 'fifty-nine', 'sixty', 'sixty-one', 'sixty-two', 'sixty-three', 'sixty-four', 'sixty-five', 'sixty-six', 'sixty-seven', 'sixty-eight', 'sixty-nine', 'seventy', 'seventy-one', 'seventy-two', 'seventy-three', 'seventy-four', 'seventy-five', 'seventy-six', 'seventy-seven', 'seventy-eight', 'seventy-nine', 'eighty', 'eighty-one', 'eighty-two', 'eighty-three', 'eighty-four', 'eighty-five', 'eighty-six', 'eighty-seven', 'eighty-eight', 'eighty-nine', 'ninety', 'ninety-one', 'ninety-two' , 'ninety-three', 'ninety-four', 'ninety-five', 'ninety-six', 'ninety-seven', 'ninety-eight', 'ninety-nine'][a])"}, {"source_code": "a=\"zero one two three four five six seven eight nine\".split()\nb=\"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc=\"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn=int(input())\nprint(c[n//10]+(\"-\"+a[n%10]if n%10else\"\")if n>19else b[n%10]if n>9else a[n])\n"}, {"source_code": "'''input\n0\n'''\ns = int(input())\nones = \"zero one two three four five six seven eight nine\".split()\ntens = \"twenty thirty forty fifty sixty seventy eighty ninety\".split()\nteens = \"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty\".split() \nif s < 10:\n\tprint(ones[s])\nelif s <= 20:\n\tprint(teens[s-10])\nelif s % 10 == 0:\n\tprint(tens[s//10-2])\nelse:\n\tprint(tens[s//10-2] + \"-\" + ones[s % 10])\n\n\n\n"}, {"source_code": "n = int(input())\nd = {0:\"zero\",1:\"one\",2:\"two\",3:\"three\",4:\"four\",5:\"five\",6:\"six\"\\\n\t,7:\"seven\",8:\"eight\",9:\"nine\",10:\"ten\",11:\"eleven\",12:\"twelve\"\\\n\t,13:\"thirteen\",14:\"fourteen\",15:\"fifteen\",16:\"sixteen\",17:\"seventeen\",\\\n\t18:\"eighteen\",19:\"nineteen\"}\n\n\nif n in d:\n\tprint(d[n])\nelif n//10 == 4:\n\tif n%10:\n\t\tprint(\"forty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"forty\")\nelif n//10 == 5:\n\tif n%10:\n\t\tprint(\"fifty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"fifty\")\nelif n//10 == 3:\n\tif n%10:\n\t\tprint(\"thirty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"thirty\")\nif n//10 == 2:\n\tif n%10:\n\t\tprint(\"twenty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"twenty\")\nelif n//10 == 8:\n\tif n%10:\n\t\tprint(d[n//10]+\"y-\"+d[n%10])\n\telse:\n\t\tprint(d[n//10]+\"y\")\nelif n//10 > 5:\n\tif n%10:\n\t\tprint(d[n//10]+\"ty-\"+d[n%10])\n\telse:\n\t\tprint(d[n//10]+\"ty\")\n"}, {"source_code": "ONES = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',\n 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen',\n 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n\nDOZENS = ['twenty', 'thirty', 'forty', 'fifty',\n 'sixty', 'seventy', 'eighty', 'ninety']\n\nn = int(input())\n\nif n > 19:\n dozens, ones = divmod(n, 10)\n print(DOZENS[dozens - 2] + ('-' + ONES[ones] if ones else ''))\nelse:\n print(ONES[n])"}, {"source_code": "num=dict()\nnum[0]='zero'\nnum[1]='one'\nnum[2]='two'\nnum[3]='three'\nnum[4]='four'\nnum[5]='five'\nnum[6]='six'\nnum[7]='seven'\nnum[8]='eight'\nnum[9]='nine'\nnum[10]='ten'\nnum[20]='twenty'\nnum[30]='thirty'\nnum[40]='forty'\nnum[50]='fifty'\nnum[60]='sixty'\nnum[70]='seventy'\nnum[80]='eighty'\nnum[90]='ninety'\nnum[11]='eleven'\nnum[12]='twelve'\nnum[13]='thirteen'\nnum[14]='fourteen'\nnum[15]='fifteen'\nnum[16]='sixteen'\nnum[17]='seventeen'\nnum[18]='eighteen'\nnum[19]='nineteen'\nn=int(input())\nif n in num:\n print(num[n])\nelse:\n val=n//10\n tens=val*10\n ones=n%10\n print(str(num[tens])+'-'+str(num[ones]))\n"}, {"source_code": "a = \"zero one two three four five six seven eight nine ten\".split()\nb = \"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc = \"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn = int(input())\nprint(c[n//10]+('-'+a[n%10] if n%10 else '') if n > 19 else b[n%10] if n > 9 else a[n] )"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndigits = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\" ]\nfirst_ten = [\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\" ]\ntens = [\"\", \"\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\" ]\n\nn = int(input())\n\ndec = n//10\nunit = divmod(n, 10)[1]\n\nanswer =''\n\nif dec == 0:\n print(digits[n])\nelif dec == 1:\n print(first_ten[unit])\nelif unit == 0:\n print(tens[dec])\nelse:\n print(tens[dec]+'-'+digits[unit])\n"}, {"source_code": "def prin(n,s):\n if n/10<1:\n if n==1:\n s+='one'\n elif n==2:\n s+='two'\n elif n==3:\n s+='three'\n elif n==4:\n s+='four'\n elif n==5:\n s+='five'\n elif n==6:\n s+='six'\n elif n==7:\n s+='seven'\n elif n==8:\n s+='eight'\n elif n==9:\n s+='nine'\n\n print(s)\n \n\n\ndef tavas_and_nafas(a):\n #a=[int(x) for x in arr]\n s=''\n if a[0]==0:\n s='zero'\n elif a[0]/10<=1:\n n=a[0]\n if n==1:\n s+='one'\n elif n==2:\n s+='two'\n elif n==3:\n s+='three'\n elif n==4:\n s+='four'\n elif n==5:\n s+='five'\n elif n==6:\n s+='six'\n elif n==7:\n s+='seven'\n elif n==8:\n s+='eight'\n elif n==9:\n s+='nine'\n else:\n s+='ten'\n elif a[0]/10>1 and a[0]/20<1:\n if a[0]==11:\n s='eleven'\n elif a[0]==12:\n s='twelve'\n elif a[0]==13:\n s='thirteen'\n elif a[0]==14:\n s='fourteen'\n elif a[0]==15:\n s='fifteen'\n elif a[0]==16:\n s='sixteen'\n elif a[0]==17:\n s='seventeen'\n elif a[0]==18:\n s='eighteen'\n else:\n s='nineteen'\n elif a[0]/20>=1 and a[0]/30<1:\n if a[0]/20==1:\n s='twenty'\n else:\n s='twenty-'\n elif a[0]/30>=1 and a[0]/40<1:\n if a[0]/30==1:\n s='thirty'\n else:\n s='thirty-'\n elif a[0]/40>=1 and a[0]/50<1:\n if a[0]/40==1:\n s='forty'\n else:\n s='forty-'\n elif a[0]/50>=1 and a[0]/60<1:\n if a[0]/50==1:\n s='fifty'\n else:\n s='fifty-'\n elif a[0]/60>=1 and a[0]/70<1:\n if a[0]/60==1:\n s='sixty'\n else:\n s='sixty-'\n elif a[0]/70>=1 and a[0]/80<1:\n if a[0]/70==1:\n s='seventy'\n else:\n s='seventy-'\n elif a[0]/80>=1 and a[0]/90<1:\n if a[0]/80==1:\n s='eighty'\n else:\n s='eighty-'\n elif a[0]/90>=1 and a[0]/100<1:\n if a[0]/90==1:\n s='ninety'\n else:\n s='ninety-'\n\n if s[len(s)-1]=='-':\n prin(a[0]%10,s)\n \n else:\n print(s)\n\n \n\na=list(map(int,input('').split()))\ntavas_and_nafas(a)\n \n\n\n\n\n\n"}, {"source_code": "n=input()\ns=[\"-zero\",\"-one\",\"-two\",\"-three\",\"-four\",\"-five\",\"-six\",\"-seven\",\"-eight\",\"-nine\"]\nif len(n)<=1:\n print(s[int(n)][1:])\nelif 10<=int(n)<=19:\n print([\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"][int(n)-10])\nelse:\n base=[\"\",\"\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\n s[0]=\"\"\n print(base[int(n[0])]+s[int(n[1])])\n"}, {"source_code": "n = int(input())\ns = [''] * 100\ns[0] = 'zero'\ns[1] = 'one'\ns[2] = 'two'\ns[3] = 'three'\ns[4] = 'four'\ns[5] = 'five'\ns[6] = 'six'\ns[7] = 'seven'\ns[8] = 'eight'\ns[9] = 'nine'\ns[10] = 'ten'\ns[11] = 'eleven'\ns[12] = 'twelve'\ns[13] = 'thirteen'\ns[14] = 'fourteen'\ns[15] = 'fifteen'\ns[16] = 'sixteen'\ns[17] = 'seventeen'\ns[18] = 'eighteen'\ns[19] = 'nineteen'\ns[20] = 'twenty'\ns[30] = 'thirty'\ns[40] = 'forty'\ns[50] = 'fifty'\ns[60] = 'sixty'\ns[70] = 'seventy'\ns[80] = 'eighty'\ns[90] = 'ninety'\nif s[n] == '':\n a = 10*(n//10)\n b = n%10\n s[n] = '-'.join([s[a],s[b]])\nprint(s[n])\n"}, {"source_code": "n=int(input())\nif n==0 :\n print('zero')\nif n==1 :\n print('one')\nif n==2 :\n print('two')\nif n==3 :\n print('three')\nif n==4 :\n print('four')\nif n==5 :\n print('five')\nif n==6 :\n print('six')\nif n==7 :\n print('seven')\nif n==8 :\n print('eight')\nif n==9 :\n print('nine')\nif n==10 :\n print('ten')\nif n==11 :\n print('eleven')\nif n==12 :\n print('twelve')\nif n==13 :\n print('thirteen')\nif n==14 :\n print('fourteen')\nif n==15 :\n print('fifteen')\nif n==16 :\n print('sixteen')\nif n==17 :\n print('seventeen')\nif n==18 :\n print('eighteen')\nif n==19 :\n print('nineteen')\nif n>19 :\n l=n%10\n p=n//10\n S=['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n S1=['one','two','three','four','five','six','seven','eight','nine']\n if l!=0 :\n print(S[p-2]+'-'+S1[l-1])\n else :\n print(S[p-2])\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n \n \n"}, {"source_code": "n = int(input())\na = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\nb = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nc = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n \nif n < 10:\n print(a[n])\nelif n < 20:\n print(b[n - 10])\nelse:\n print(c[(n - 20) // 10] + ('-' + a[n % 10] if n % 10 else ''))"}, {"source_code": "n = int(input())\nd = {}\nd[0] = 'zero'\nd[1] = 'one'\nd[2] = 'two'\nd[3] = 'three'\nd[4] = 'four'\nd[5] = 'five'\nd[6] = 'six'\nd[7] = 'seven'\nd[8] = 'eight'\nd[9] = 'nine'\nd[10] = 'ten'\nd[11] = 'eleven'\nd[12] = 'twelve'\nd[13] = 'thirteen'\nd[14] = 'fourteen'\nd[15] = 'fifteen'\nd[16] = 'sixteen'\nd[17] = 'seventeen'\nd[18] = 'eighteen'\nd[19] = 'nineteen'\nd[20] = 'twenty'\nd[30] = 'thirty'\nd[40] = 'forty'\nd[50] = 'fifty'\nd[60] = 'sixty'\nd[70] = 'seventy'\nd[80] = 'eighty'\nd[90] = 'ninety'\nif n <= 19 or n % 10 == 0:\n print(d[n])\nelse:\n print(d[n - (n % 10)],'-',d[n % 10], sep = '')\n "}, {"source_code": "n=int(input())\n\narr=[\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\nrra=[\"zero\",\"one\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\n\nif n>=0 and n<=19 :\n print(arr[n])\nelse :\n if n%10==0 :\n print(rra[n//10])\n else :\n print(rra[n//10],end=\"-\")\n print(arr[n%10])\n"}, {"source_code": "n = int(input())\nif n>=0 and n<20:\n\tif n==0:\n\t\tx = 'zero'\n\tif n==1:\n\t\tx = 'one'\n\tif n==2:\n\t\tx = 'two'\n\tif n==3:\n\t\tx = 'three'\n\tif n==4:\n\t\tx = 'four'\n\tif n==5:\n\t\tx = 'five'\n\tif n==6:\n\t\tx = 'six'\n\tif n==7:\n\t\tx = 'seven'\n\tif n==8:\n\t\tx = 'eight'\n\tif n==9:\n\t\tx = 'nine'\n\tif n==10:\n\t\tx = 'ten'\n\tif n==11:\n\t\tx = 'eleven'\n\tif n==12:\n\t\tx = 'twelve'\n\tif n==13:\n\t\tx = 'thirteen'\n\tif n==14:\n\t\tx = 'fourteen'\n\tif n==15:\n\t\tx = 'fifteen'\n\tif n==16:\n\t\tx = 'sixteen'\n\tif n==17:\n\t\tx = 'seventeen'\n\tif n==18:\n\t\tx = 'eighteen'\n\tif n==19:\n\t\tx = 'nineteen'\n\tprint(x)\nif n>=20:\n\tn = str(n)\n\tif n[1]=='1':\n\t\tx = 'one'\n\tif n[1]=='2':\n\t\tx = 'two'\n\tif n[1]=='3':\n\t\tx = 'three'\n\tif n[1]=='4':\n\t\tx = 'four'\n\tif n[1]=='5':\n\t\tx = 'five'\n\tif n[1]=='6':\n\t\tx = 'six'\n\tif n[1]=='7':\n\t\tx = 'seven'\n\tif n[1]=='8':\n\t\tx = 'eight'\n\tif n[1]=='9':\n\t\tx = 'nine'\n\tif n[0]=='2':\n\t\ty = 'twenty'\n\tif n[0]=='3':\n\t\ty = 'thirty'\n\tif n[0]=='4':\n\t\ty = 'forty'\n\tif n[0]=='5':\n\t\ty = 'fifty'\n\tif n[0]=='6':\n\t\ty = 'sixty'\n\tif n[0]=='7':\n\t\ty = 'seventy'\n\tif n[0]=='8':\n\t\ty = 'eighty'\n\tif n[0]=='9':\n\t\ty = 'ninety'\n\tif n[1] == '0':\n\t\tprint(y)\n\telse:\n\t\tprint(y+\"-\"+x)\n"}, {"source_code": "nums = {\n\t0:\"zero\", \n\t1:\"one\", \n\t2:\"two\", \n\t3:\"three\", \n\t4:\"four\", \n\t5:\"five\", \n\t6:\"six\", \n\t7:\"seven\", \n\t8:\"eight\", \n\t9:\"nine\",\n\t10:\"ten\",\n\t11:\"eleven\",\n\t12:\"twelve\",\n\t13:\"thirteen\",\n\t14:\"fourteen\",\n\t15:\"fifteen\",\n\t16:\"sixteen\",\n\t17:\"seventeen\",\n\t18:\"eighteen\",\n\t19:\"nineteen\",\n\t20:\"twenty\",\n\t30:\"thirty\",\n\t40:\"forty\",\n\t50:\"fifty\",\n\t60:\"sixty\",\n\t70:\"seventy\",\n\t80:\"eighty\",\n\t90:\"ninety\",\n}\n\nnum = int(input())\n\nif num in nums:\n\tprint(nums[num])\nelse:\n\tlast = num % 10\n\tdec = num - last\n\tprint(nums[dec]+\"-\"+nums[last])"}, {"source_code": "nums = {\n 90: 'ninety',\n 80: 'eighty',\n 70: 'seventy',\n 60: 'sixty',\n 50: 'fifty',\n 40: 'forty',\n 30: 'thirty',\n 20: 'twenty',\n 19: 'nineteen',\n 18: 'eighteen',\n 17: 'seventeen',\n 16: 'sixteen',\n 15: 'fifteen',\n 14: 'fourteen',\n 13: 'thirteen',\n 12: 'twelve',\n 11: 'eleven',\n 10: 'ten',\n 9: 'nine',\n 8: 'eight',\n 7: 'seven',\n 6: 'six',\n 5: 'five',\n 4: 'four',\n 3: 'three',\n 2: 'two',\n 1: 'one',\n 0: 'zero'\n}\n\nnum = input()\nif len(num) == 2 and int(num) >= 20:\n dec = int(num) - int(num[1])\n uni = int(num[1])\n\n if int(num[1]) == 0:\n print(nums.get(dec))\n else:\n print(nums.get(dec), end='-')\n print(nums.get(uni))\n\nelse:\n uni = int(num)\n print(nums.get(uni))\n"}, {"source_code": "a=\"zero one two three four five six seven eight nine\".split()\nb=\"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc=\"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn=int(input())\nprint(c[n//10]+(\"-\"+a[n%10]if n%10else\"\")if n>19else b[n%10]if n>9else a[n])\n"}, {"source_code": "numbers = {0:'zero', 1:'one', 2:'two', 3:'three', 4:'four', 5:'five', 6:'six', 7:'seven', 8:'eight', 9:'nine',\n 10:'ten', 11:'eleven', 12:'twelve', 13:'thirteen', 14:'fourteen', 15:'fifteen', 16:'sixteen',\n 17:'seventeen', 18:'eighteen', 19:'nineteen', 20:'twenty', 30:'thirty', 40:'forty', 50:'fifty',\n 60:'sixty', 70:'seventy', 80:'eighty', 90:'ninety'}\n\nn = int(input())\nif n in numbers:\n print(numbers[n])\nelse:\n print(numbers[(n//10)*10] + '-' + numbers[n%10])\n"}, {"source_code": "n=input()\nl=[]\nf=[]\nif n=='0':\n print(\"zero\")\nelse:\n d={'1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine','10':'ten','20':'twenty','30':'thirty','40':'forty','50':'fifty','60':'sixty','70':'seventy','80':'eighty','90':'ninety'}\n d1={'11':'eleven','12':'twelve','13':'thirteen','14':'fourteen','15':'fifteen','16':'sixteen','17':'seventeen','18':'eighteen','19':'nineteen','10':'ten','20':'twenty','30':'thirty','40':'forty','50':'fifty','60':'sixty','70':'seventy','80':'eighty','90':'ninety'}\n for i in range(len(n)):\n l.append(int(n[i])*(10**(len(n)-i-1)))\n for j in range(len(l)):\n f.append(d.get(str(l[j])))\n \n if (11<=int(n)<=19) or (int(n)%10==0):\n print(d1.get(n))\n else:\n e=\"-\".join(i for i in f)\n print(e)\n"}, {"source_code": "a=\"zero one two three four five six seven eight nine\".split()\nb=\"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc=\"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn=int(input())\nprint(c[n//10]+(\"-\"+a[n%10]if n%10else\"\")if n>19else b[n%10]if n>9else a[n])"}, {"source_code": "n = int(input())\na = ['','ten','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']; b = ['','one','two','three','four','five','six','seven','eight','nine']; c = ['','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nif n==0:\n print(\"zero\")\nelif n % 100 >10 and n % 100 <20:\n print(c[(n%100)-10])\nelse:\n d = n//10; e = n%10;\n if e==0:\n print(a[d])\n elif d == 0:\n print(b[e])\n else:\n print(\"%s-%s\" %(a[d], b[e]))"}, {"source_code": "n = int(input())\n\nto_19 = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\ntens = ['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n\nif n in range(0,20):\n\tprint(to_19[n])\nelse:\n\tif n % 10 == 0:\n\t\tprint(tens[n//10 - 2])\n\telse:\n\t\tn = list(str(n))\n\t\tprint(tens[int(n[0]) - 2] + '-' + to_19[int(n[1])])\n\n\n\n"}, {"source_code": "s = int(input())\nd = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty', 60: 'sixty', 70: 'seventy', 80: 'eighty', 90: 'ninety'}\n\nif s in d:\n print(d[s])\nelse:\n #21\n ans = \"\"\n while s:\n if s in d:\n ans = d[s] + \"-\" + ans\n break\n ans += d[s%10]\n s //= 10\n s *= 10\n print(ans)\n"}, {"source_code": "t = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\nx=['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen',\n 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty-one', 'twenty-two', 'twenty-three', 'twenty-four', 'twenty-five', 'twenty-six',\n 'twenty-seven', 'twenty-eight', 'twenty-nine', 'thirty']\nfor i in t:\n x.append('thirty-'+i)\n\nx.append('forty')\nfor i in t:\n x.append('forty-'+i)\n\nx.append('fifty')\n\nfor i in t:\n x.append('fifty-'+i)\n\nx.append('sixty')\n\nfor i in t:\n x.append('sixty-'+i)\n\nx.append('seventy')\n\nfor i in t:\n x.append('seventy-'+i)\n\nfor kk in ['eighty', 'ninety']:\n x.append(kk)\n for i in t:\n x.append(kk+'-'+i)\n \nprint(x[int(input())])"}, {"source_code": "a1 = ['oops', 'oops', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\na2 = ['oops', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\nn = int(input())\nd1, d2 = n // 10, n % 10\nif n == 0:\n print('zero')\nelif d1 == 0:\n print(a2[d2])\nelif d1 == 1:\n if n == 10:\n print('ten')\n elif n == 11:\n print('eleven')\n elif n == 12:\n print('twelve')\n elif n == 13:\n print('thirteen')\n elif n == 14:\n print('fourteen')\n elif n == 15:\n print('fifteen')\n elif n == 16:\n print('sixteen')\n elif n == 17:\n print('seventeen')\n elif n == 18:\n print('eighteen')\n elif n == 19:\n print('nineteen')\nelse:\n if d2 == 0:\n print(a1[d1])\n else:\n print(a1[d1], a2[d2], sep='-')"}, {"source_code": "a=\"zero one two three four five six seven eight nine\".split()\nb=\"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc=\"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn=int(input())\nprint(c[n//10]+(\"-\"+a[n%10]if n%10else\"\")if n>19else b[n%10]if n>9else a[n])\n"}, {"source_code": "a=\"zero one two three four five six seven eight nine\".split()\nb=\"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc=\"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\nn=int(input())\nprint(c[n//10]+(\"-\"+a[n%10]if n%10else \"\")if n>19else b[n%10]if n>9else a[n])"}, {"source_code": "class TavasAndNafas:\n def solve(self,s):\n output = \"\"\n numbers = [\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\n if len(s)==1:\n if s==\"0\": return \"zero\"\n else: return numbers[int(s)-1]\n else:\n if s[0]==\"1\":\n if s[1]==\"0\": return \"ten\"\n elif s[1]==\"1\": return \"eleven\"\n elif s[1]==\"2\": return \"twelve\"\n elif s[1]==\"3\": return \"thirteen\"\n elif s[1]==\"5\": return \"fifteen\"\n elif s[1]==\"8\": return \"eighteen\"\n else: return numbers[int(s[1])-1]+\"teen\"\n elif s[0] == \"2\":\n if s[1]==\"0\": return \"twenty\"\n else: return \"twenty-\"+numbers[int(s[1])-1]\n elif s[0] == \"3\":\n if s[1]==\"0\": return \"thirty\"\n else: return \"thirty-\"+numbers[int(s[1])-1]\n elif s[0] == \"4\":\n if s[1]==\"0\": return \"forty\"\n else: return \"forty-\"+numbers[int(s[1])-1]\n elif s[0] == \"5\":\n if s[1]==\"0\": return \"fifty\"\n else: return \"fifty-\"+numbers[int(s[1])-1]\n elif s[0] == \"8\":\n if s[1]==\"0\": return \"eighty\"\n else: return \"eighty-\"+numbers[int(s[1])-1]\n else:\n if s[1]==\"0\": return numbers[int(s[0])-1]+\"ty\"\n else:return numbers[int(s[0])-1]+\"ty-\"+numbers[int(s[1])-1]\nif __name__ == \"__main__\":\n s = str(raw_input())\n tan = TavasAndNafas()\n print tan.solve(s)"}, {"source_code": "a=['zero','one','two','three','four','five','six','seven','eight','nine','ten']\nb=['eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty']\nc=['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nn=input()\nz=int(n)\nif z<=10:\n print(a[z])\nelif z<=20:\n print(b[z-11])\nelse:\n if n[1]=='0':\n print(c[int(n[0])-2])\n else:\n x=''\n x=x+(c[int(n[0])-2])\n x=x+'-'\n x=x+a[int(n[1])]\n print(x)\n"}, {"source_code": "x=input()\nl=[]\nfor i in str(x):\n l.append(int(i))\nones={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine'}\ntens={2:'twenty',3:'thirty',4:'forty',5:'fifty',6:'sixty',7:'seventy',8:'eighty',9:'ninety'}\nteens={0:'ten',1:'eleven',2:'twelve',3:'thirteen',4:'fourteen',5:'fifteen',6:'sixteen',7:'seventeen',8:'eighteen',9:'nineteen'}\nif len(l)==1:\n print(ones[l[0]])\nelif len(l)==2 and int(x)>=20:\n ten=tens[l[0]]\n if not l[1]==0:\n one=ones[l[1]]\n print(ten+'-'+one)\n else:\n print(ten)\nelse:\n print(teens[l[1]])\n"}, {"source_code": "unit = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\ntenth = ['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\ntens = ['zero','ten','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n\nn = input()\n\nif n < 10:\n\tprint unit[n]\nelif n < 20:\n\tprint tenth[n-10]\nelif n % 10 == 0:\n\tprint tens[n/10]\nelse:\n\tprint tens[n/10] + '-' + unit[n%10]"}, {"source_code": "n=int(input())\nones=[\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ntens=[\"\",\"\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\nif n<=19:\n print(ones[n])\nelse:\n k=n%10\n k1=n//10\n if k==0:\n print(tens[k1])\n else:\n print(tens[k1]+\"-\"+ones[k])\n "}, {"source_code": "import sys\nx=int(raw_input())\nif x<=19:\n\tif x==0:\n\t\tprint \"zero\"\n\tif x==1:\n\t\tprint \"one\"\n\telif x==2:\n\t\tprint \"two\"\n\telif x==3:\n\t\tprint \"three\"\n\telif x==4:\n\t\tprint \"four\"\n\telif x==5:\n\t\tprint \"five\"\n\telif x==6:\n\t\tprint \"six\"\n\telif x==7:\n\t\tprint \"seven\"\n\telif x==8:\n\t\tprint \"eight\"\n\telif x==9:\n\t\tprint \"nine\"\n\telif x==10:\n\t\tprint \"ten\"\n\telif x==11:\n\t\tprint \"eleven\"\n\telif x==12:\n\t\tprint \"twelve\"\n\telif x==13:\n\t\tprint \"thirteen\"\n\telif x==14:\n\t\tprint \"fourteen\"\n\telif x==15:\n\t\tprint \"fifteen\"\n\telif x==16:\n\t\tprint \"sixteen\"\n\telif x==17:\n\t\tprint \"seventeen\"\n\telif x==18:\n\t\tprint \"eighteen\"\n\telif x==19:\n\t\tprint \"nineteen\"\nelse:\n\tif x/10==2:\n\t\tprint \"twenty\",\n\t\tsys.stdout.softspace=0\n\telif x/10==3:\n\t\tprint \"thirty\",\n\t\tsys.stdout.softspace=0\n\telif x/10==4:\n\t\tprint \"forty\",\n\t\tsys.stdout.softspace=0\n\telif x/10==5:\n\t\tprint \"fifty\",\n\t\tsys.stdout.softspace=0\n\telif x/10==6:\n\t\tprint \"sixty\",\n\t\tsys.stdout.softspace=0\n\telif x/10==7:\n\t\tprint \"seventy\",\n\t\tsys.stdout.softspace=0\n\telif x/10==8:\n\t\tprint \"eighty\",\n\t\tsys.stdout.softspace=0\n\telif x/10==9:\n\t\tprint \"ninety\",\n\t\tsys.stdout.softspace=0\n\tif x%10==1:\n\t\tprint \"-one\"\n\telif x%10==2:\n\t\tprint \"-two\"\n\telif x%10==3:\n\t\tprint \"-three\"\n\telif x%10==4:\n\t\tprint \"-four\"\n\telif x%10==5:\n\t\tprint \"-five\"\n\telif x%10==6:\n\t\tprint \"-six\"\n\telif x%10==7:\n\t\tprint \"-seven\"\n\telif x%10==8:\n\t\tprint \"-eight\"\n\telif x%10==9:\n\t\tprint \"-nine\"\n\n\t"}, {"source_code": "a=[\"zero\", \"one\", \"two\", \"three\", \"four\",\"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\", \"eleven\", \"twelve\",\"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\",\"nineteen\"]\nd=[\"twenty\", \"thirty\", \"forty\",\"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\n\nn=int(input())\nprint(a[n] if n<20 else d[n//10-2] + ('' if n%10 == 0 else '-'+a[n%10]))"}, {"source_code": "word=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\na=int(raw_input())\nif a<=19:print word[a]\nelse:\n if 20<=a<30:\n k='twenty'\n elif 30<=a<40:\n k='thirty'\n elif 40<=a<50:\n k='forty'\n elif 50<=a<60:\n k='fifty'\n elif 60<=a<70:\n k='sixty'\n elif 70<=a<80:\n k='seventy'\n elif 80<=a<90:\n k='eighty'\n else:\n k='ninety'\n if a%10:k+='-'+word[a%10]\n print k\n"}, {"source_code": "''' \n \t\n \t\t\t ||Sri:|| \n\n __|\n ______________|_________________________\n | | ___| | | ___| | | |___\n /\\ /\\ | |___ | | |___| | | |___|\n/ \\/ \\ | ___| | | |_/ |___| |___\n\nI am a beginner. Feel free to send tutorials/help to srinivasan1995@gmail.com.\n\nCodeforces, SPOJ handle: desikachariar.\nHackerrank, Codechef handle: Prof_Calculus.\n\nAdvises/Help are welcome. You will definitely get a thanks in return. Comments to be avoided.\n\nCollege: International Institute of Information Technology, Bangalore.\n\n'''\n\nimport math\n\nhsh = {0:\"zero\", 1:\"one\", 2:\"two\", 3:\"three\", 4:\"four\", 5:\"five\", 6:\"six\", 7:\"seven\", 8:\"eight\", 9:\"nine\", 10:\"ten\", 11:\"eleven\", 12:\"twelve\", 13:\"thirteen\", 14:\"fourteen\", 15:\"fifteen\", 16:\"sixteen\", 17:\"seventeen\", 18:\"eighteen\", 19:\"nineteen\", 20:\"twenty\", 30:\"thirty\", 40:\"forty\", 50:\"fifty\", 60:\"sixty\", 70:\"seventy\", 80:\"eighty\", 90:\"ninety\"}\n\nif __name__ == '__main__':\n\tx = input()\n\tls = [x/10, x%10]\n\tif(x < 10):\n\t\tprint hsh[x]\n\telse:\n\t\tif ls[0] == 1:\n\t\t\tprint hsh[(ls[0]*10) + ls[1]]\n\t\telse:\n\t\t\tif ls[1] == 0:\n\t\t\t\tprint hsh[(ls[0]*10)]\n\t\t\telse:\n\t\t\t\tprint hsh[(ls[0]*10)] + \"-\" + hsh[ls[1]]\n\t\n"}, {"source_code": "\nn=int(input())\ntest={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',\n 7:'seven',8:'eight',9:'nine',10:'ten',11:'eleven',12:'twelve',13:'thirteen',14:'fourteen',\n 15:'fifteen',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen'}\n\nfir={2:'twenty',3:'thirty',4:'forty',5:'fifty',6:'sixty',7:'seventy',8:'eighty',9:'ninety'}\n\n\n\n\nif n in test:\n print(test[n])\nelse:\n f=n//10\n if n%10!=0:\n print(fir[f]+'-'+test[n%10])\n else:\n print(fir[f])\n"}, {"source_code": "#!/usr/bin/env\n\nlast_digit = [\n \"zero\",\n \"one\",\n \"two\",\n \"three\",\n \"four\",\n \"five\",\n \"six\",\n \"seven\",\n \"eight\",\n \"nine\"\n ]\nsecond_digit = [\n \"twenty\",\n \"thirty\",\n \"forty\",\n \"fifty\",\n \"sixty\",\n \"seventy\",\n \"eighty\",\n \"ninety\"\n ]\n\ntens = [\n \"ten\",\n \"eleven\",\n \"twelve\",\n \"thirteen\",\n \"fourteen\",\n \"fifteen\",\n \"sixteen\",\n \"seventeen\",\n \"eighteen\",\n \"nineteen\"\n ]\n\ndef read_score(x):\n if len(x) == 1:\n return last_digit[int(x)]\n elif x[0] > \"1\":\n if x[1] == \"0\":\n return second_digit[int(x[0]) - 2]\n else:\n return \"-\".join([\n second_digit[int(x[0]) - 2],\n last_digit[int(x[1])]\n ])\n else:\n return tens[int(x) - 10]\n\nscore = input()\nprint(read_score(score))\n"}, {"source_code": "#!/usr/bin/env python\n\ns = int(raw_input())\n\nans = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']\n\nif s <= 20:\n\tprint ans[s]\n\texit()\n\nnum = [1, 2, 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n\nif s % 10 == 0:\n\tprint num[s/10]\nelse:\n\tprint num[s/10] + '-' + ans[s%10]\n"}, {"source_code": "Dict = {0:\"zero\",1: 'one', 2: 'two', \n 3:\"three\",4:\"four\",5:\"five\",\n 6:\"six\",7:\"seven\",8:\"eight\",\n 9:\"nine\",10:\"ten\",\n 11:\"eleven\",12:\"twelve\",13:\"thirteen\",14:\"fourteen\",15:\"fifteen\",\n 16:\"sixteen\",17:\"seventeen\",18:\"eighteen\",19:\"nineteen\",\n 20:\"twenty\",\n 30:\"thirty\",40:\"forty\",\n 50:\"fifty\",60:\"sixty\",70:\"seventy\",80:\"eighty\",90:\"ninety\"}\nn=int(input())\nrem=n%10\nq=n//10\ns=str()\nif(rem!=0 and q>1):\n s+=Dict[int(q)*10]\n s=s+\"-\"\n s+=Dict[rem]\n print(s)\n\nelif(rem!=0 and (q==0 or q==1)):\n print(Dict[n])\n \n\n\nelse:\n print(Dict[int(q)*10])\n"}, {"source_code": "D={'0':'zero','1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine'}\nD2={'10':'ten','11':'eleven','12':'twelve','13':'thirteen','14':'fourteen','15':'fifteen','16':'sixteen','17':'seventeen','18':'eighteen','19':'nineteen'}\nD3={'2':'twenty','3':'thirty','4':'forty','5':'fifty','6':'sixty','7':'seventy','8':'eighty','9':'ninety'}\nInp=raw_input()\nif len(Inp)==1:\n print D[Inp]\nelif Inp[0]=='1':\n print D2[Inp]\nelse:\n if not Inp[1]=='0':\n print'-'.join([D3[Inp[0]],D[Inp[1]]])\n else:\n print D3[Inp[0]]\n"}, {"source_code": "n = raw_input()\ns = \"\"\nif n == '0':\n print \"zero\"\n exit()\nif len(n) == 2:\n if n[0] == '1':\n n = int(n)\n if n == 10:\n print \"ten\"\n elif n == 11:\n print \"eleven\"\n elif n == 12:\n print \"twelve\"\n elif n == 13:\n print \"thirteen\"\n elif n == 14:\n print \"fourteen\"\n elif n == 15:\n print \"fifteen\"\n elif n == 16:\n print \"sixteen\"\n elif n == 17:\n print \"seventeen\"\n elif n == 18:\n print \"eighteen\"\n elif n == 19:\n print \"nineteen\"\n exit()\n elif n[0] == '2':\n s += \"twenty\"\n elif n[0] == '3':\n s += \"thirty\"\n elif n[0] == '4':\n s += \"forty\"\n elif n[0] == '5':\n s += \"fifty\"\n elif n[0] == '6':\n s += \"sixty\"\n elif n[0] == '7':\n s += \"seventy\"\n elif n[0] == '8':\n s += \"eighty\"\n elif n[0] == '9':\n s += \"ninety\"\n if n[1] != '0':\n s += '-'\n n = n[1:]\n\nif n[0] == '1':\n s += \"one\"\nelif n[0] == '2':\n s += \"two\"\nelif n[0] == '3':\n s += \"three\"\nelif n[0] == '4':\n s += \"four\"\nelif n[0] == '5':\n s += \"five\"\nelif n[0] == '6':\n s += \"six\"\nelif n[0] == '7':\n s += \"seven\"\nelif n[0] == '8':\n s += \"eight\"\nelif n[0] == '9':\n s += \"nine\"\nprint s\n\n"}, {"source_code": "import sys\n\nvalues = {0 : 'zero',\n 1 : 'one',\n 2 : 'two',\n 3 : 'three',\n 4 : 'four',\n 5 : 'five',\n 6 : 'six',\n 7 : 'seven',\n 8 : 'eight',\n 9 : 'nine',\n 10 : 'ten',\n 11 : 'eleven',\n 12 : 'twelve',\n 13 : 'thirteen',\n 14 : 'fourteen',\n 15 : 'fifteen',\n 16 : 'sixteen',\n 17 : 'seventeen',\n 18 : 'eighteen',\n 19 : 'nineteen',\n 20 : 'twenty',\n 30 : 'thirty',\n 40 : 'forty',\n 50 : 'fifty',\n 60 : 'sixty',\n 70 : 'seventy',\n 80 : 'eighty',\n 90 : 'ninety'}\n\ndef solve(inp):\n if inp in values:\n return values[inp]\n else:\n remaining = inp\n while remaining-10 > 0:\n remaining -= 10\n res = values[inp-remaining]+\"-\"+values[remaining]\n return res\n\ninp = int(sys.stdin.readline())\nprint(solve(inp))\n#for i in range(0, 100):\n# print(solve(i))\n"}, {"source_code": "tens = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']\nones = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}\ndef numtoword(num):\n if num >= 1 and num < 20:\n return (ones[num])\n elif num < 100:\n t , u = divmod(num , 10)\n return (tens[t-2].lower() + '-' + ones[u]).lower()\nt = int(raw_input())\nif t == 0:\n print \"zero\"\nelif t == 10:\n print \"ten\"\nelif t % 10 == 0:\n print tens[(t/10)-2].lower()\nelse: \n print numtoword(t)\n"}, {"source_code": "from fractions import Fraction as F\nimport math\nimport sys\n\nfi = sys.stdin\nfo = sys.stdout\nfe = sys.stderr\nexit = sys.exit\n\nreadline = raw_input\n\ndef readargs(tp=None):\n if tp is not None:\n return map(tp, readline().split())\n return readline().split()\n\ndef yesno(flag, yes='', no=''):\n if flag:\n print yes if yes else 'YES'\n else:\n print no if no else 'NO'\n\ntruefalse = lambda flag : yesno(flag, yes='TRUE', no='FALSE')\n\nwords = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',\n 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n\ntwords = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n\ni = readargs(int)[0]\n\nif i < 20:\n print words[i]\nelse:\n if i % 10 == 0:\n print twords[i / 10 - 2]\n else:\n print '%s-%s' % (twords[i / 10 - 2], words[i % 10])\n"}, {"source_code": "def single(num:int) -> str:\n if num == 1:\n return 'one'\n if num == 2:\n return 'two'\n if num == 3:\n return 'three'\n if num == 4:\n return 'four'\n if num == 5:\n return 'five'\n if num == 6:\n return 'six'\n if num == 7:\n return 'seven'\n if num == 8:\n return 'eight'\n if num == 9:\n return 'nine'\n\ndef decade(num:int) -> str:\n if num == 2:\n return 'twenty'\n if num == 3:\n return 'thirty'\n if num == 4:\n return 'forty'\n if num == 5:\n return 'fifty'\n if num == 6:\n return 'sixty'\n if num == 7:\n return 'seventy'\n if num == 8:\n return 'eighty'\n if num == 9:\n return 'ninety'\n\nscore = int(input())\nif score == 0:\n print('zero')\nelif score == 10:\n print('ten')\nelif score == 11:\n print('eleven')\nelif score == 12:\n print('twelve')\nelif score == 13:\n print('thirteen')\nelif score == 14:\n print('fourteen')\nelif score == 15:\n print('fifteen')\nelif score == 16:\n print('sixteen')\nelif score == 17:\n print('seventeen')\nelif score == 18:\n print('eighteen')\nelif score == 19:\n print('nineteen')\nelif score%10 == 0:\n print(decade(score//10))\nelif score<10:\n print(single(score))\nelse:\n print(decade(score//10)+'-'+single(score%10))\n"}, {"source_code": "from __future__ import division\nfrom collections import Counter as ctr\nfrom math import ceil, log, factorial, sqrt\n# reads a line of input and converts into a list of ints\n# 1 1 3 => [1, 1, 3]\ndef rl():\n return [int(i) for i in raw_input().split()]\n\n# reads n lines of input (if n defined) and returns a list of strings\n# where each element is a line in the input\n# abc\n# abcdef\n# => ['abc', 'abcdef']\n# if n not defined, read first line to get number of lines\n# 2\n# abc\n# abcdef\n# => ['abc', 'abcdef']\ndef rm(n=None):\n if n is None:\n n = input()\n return [raw_input() for i in range(n)]\n\n# same as rm, except converts each line to a list of ints like rl\ndef rlm(n=None):\n if n is None:\n n = input()\n return [rl() for i in range(n)]\n\ndef yn(b):\n if b:\n print \"YES\"\n else:\n print \"NO\"\n\nn=int(raw_input())\nd={\n 0:'',\n 1:'one',\n 2:'two',\n 3:'three',\n 4:'four',\n 5:'five',\n 6:'six',\n 7:'seven',\n 8:'eight',\n 9:'nine',\n 10:'ten',\n 11:'eleven',\n 12:'twelve',\n 13:'thirteen',\n 14:'fourteen',\n 15:'fifteen',\n 16:'sixteen',\n 17:'seventeen',\n 18:'eighteen',\n 19:'nineteen',\n 20:'twenty',\n 30:'thirty',\n 40:'forty',\n 50:'fifty',\n 60:'sixty',\n 70:'seventy',\n 80:'eighty',\n 90:'ninety',\n}\ndef word(n):\n if n == 0:\n return 'zero'\n if n == 1000:\n return 'one thousand'\n word = ''\n if n >= 100:\n word += d[n//100]\n word += ' hundred'\n if n % 100 != 0:\n word += ' and '\n n = n % 100\n if n <= 20:\n word += d[n]\n else:\n word += d[(n//10)*10]\n if n % 10 != 0:\n word += '-'\n word += d[n%10]\n return word\nprint word(n)"}, {"source_code": "units=[\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\ntens=[\"\",\"\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\nmid=[\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\",\"twenty\"]\nn=int(raw_input(\"\"))\nif n<10:\n print units[n%10]\nelif n<20:\n print mid[n%10]\nelif n==20:\n print \"twenty\"\nelif n%10==0:\n print tens[n/10]\nelse:\n print tens[n/10]+\"-\"+units[n%10]\n"}, {"source_code": "dict1 = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine',\n 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen',\n 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}\ndict2 = {2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty', 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety'}\nvar = int(input())\nif var < 20:\n print(dict1[var])\nelif var % 10 == 0:\n print(dict2[var / 10])\nelse:\n print(dict2[int(var / 10)] + '-' + dict1[var % 10])"}, {"source_code": "x={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',0:'zero'}\ny=[]\nn=int(raw_input())\ny.append(n%10)\nn=n/10\ns1=''\ns=''\nflag=0\ny.append(n%10)\nif(y[1]>5):\n if(y[1]==8):\n s+=x[y[1]]+'y'\n else:\n s+=x[y[1]]+'ty'\nelif(y[1]==1):\n flag=1\n if y[0]==0:\n s1='ten'\n elif y[0]==1:\n s1='eleven'\n elif y[0]==2:\n s1='twelve'\n elif y[0]==3:\n s1='thirteen' \n elif y[0]==5:\n s1='fifteen'\n elif y[0]==8:\n s1='eighteen'\n else:\n s1=x[y[0]]+'teen'\nelif(y[1]==2):\n s='twenty'\nelif(y[1]==3):\n s='thirty'\nelif(y[1]==4):\n s='forty'\nelif(y[1]==5):\n s='fifty'\nelse:\n s='zero'\nif(y[0]==0):\n s+=''\nelse:\n if y[1]==0:\n s=x[y[0]]\n else:\n s+='-'+x[y[0]]\nif(flag==1):\n print s1\nelse:\n print s"}, {"source_code": "def prog(t):\n if(t=='0'):\n return \"zero\"\n if(t=='1'):\n return \"one\"\n if(t=='2'):\n return \"two\"\n if(t=='3'):\n return \"three\"\n if(t=='4'):\n return \"four\"\n if(t=='5'):\n return \"five\"\n if(t=='6'):\n return \"six\"\n if(t=='7'):\n return \"seven\"\n if(t=='8'):\n return \"eight\"\n if(t=='9'):\n return \"nine\"\nt = raw_input()\nif(len(t)==1):\n print prog(t)\nelse:\n if(t[0]=='1'):\n t = t[1]\n if(t=='0'):\n print \"ten\"\n if(t=='1'):\n print \"eleven\"\n if(t=='2'):\n print \"twelve\"\n if(t=='3'): \n print \"thirteen\"\n if(t=='4'):\n print \"fourteen\"\n if(t=='5'):\n print \"fifteen\"\n if(t=='6'):\n print \"sixteen\"\n if(t=='7'):\n print \"seventeen\"\n if(t=='8'):\n print \"eighteen\"\n if(t=='9'):\n print \"nineteen\"\n elif(t[0]=='2'):\n t = t[1]\n if(t=='0'):\n print \"twenty\"\n else:\n print \"twenty-\"+prog(t)\n elif(t[0]=='3'):\n t = t[1]\n if(t=='0'):\n print \"thirty\"\n else:\n print \"thirty-\"+prog(t)\n elif(t[0]=='4'):\n t = t[1]\n if(t=='0'):\n print \"forty\"\n else:\n print \"forty-\"+prog(t)\n elif(t[0]=='5'):\n t = t[1]\n if(t=='0'):\n print \"fifty\"\n else:\n print \"fifty-\"+prog(t)\n elif(t[0]=='6'):\n t = t[1]\n if(t=='0'):\n print \"sixty\"\n else:\n print \"sixty-\"+prog(t)\n elif(t[0]=='7'):\n t = t[1]\n if(t=='0'):\n print \"seventy\"\n else:\n print \"seventy-\"+prog(t)\n elif(t[0]=='8'):\n t = t[1]\n if(t=='0'):\n print \"eighty\"\n else:\n print \"eighty-\"+prog(t)\n elif(t[0]=='9'):\n t = t[1]\n if(t=='0'):\n print \"ninety\"\n else:\n print \"ninety-\"+prog(t)\n"}, {"source_code": "def NumTostr(n):\n last_dig = n%10\n first_dig = n/10\n\n first_dig_nums = ['ten','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n last_digs_nums = ['one','two','three','four','five','six','seven','eight','nine']\n teens = ['eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\n\n if first_dig == 0:\n if last_dig == 0:\n print 'zero'\n else:\n print last_digs_nums[last_dig-1]\n elif last_dig == 0:\n print first_dig_nums[first_dig-1]\n elif first_dig == 1:\n print teens[last_dig-1]\n else:\n print first_dig_nums[first_dig-1]+'-'+last_digs_nums[last_dig-1]\n\ndef main():\n n = int(raw_input())\n NumTostr(n)\nmain()\n"}, {"source_code": "d={0:'zero',10:'ten',1:'one',11:'eleven',2:'two',12:'twelve',20:'twenty',\n 3:'three',13:'thirteen',30:'thirty',4:'four',14:'fourteen',40:'forty',5:'five',15:'fifteen',50:'fifty',6:'six',16:'sixteen',60:'sixty',7:'seven',17:'seventeen',70:'seventy',8:'eight',18:'eighteen',80:'eighty',9:'nine',19:'nineteen',90:'ninety'}\na=input()\nx=d[a//10*10]+'-'+d[a%10]\nprint d.get(a,x)"}, {"source_code": "x = input()\nl1 = [\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nl2 = [\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\nl3 = [\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\nr = \"\"\nif (len(x)==1):\n r = r + l1[int(x)]\nelif(len(x)==2 and x[1] != \"0\" and x[0]!=\"1\"):\n r = r + l2[int(x[0])-2] + \"-\" + l1[int(x[1])]\nelif(x[1]==\"0\" and x[0] != \"1\"):\n r = r + l2[int(x[0])-2]\nelse:\n r = r + l3[int(x[1])]\n\nprint(r)"}, {"source_code": "table20 = \"\"\"zero\none\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\ntwelve\nthirteen\nfourteen\nfifteen\nsixteen\nseventeen\neighteen\nnineteen\ntwenty\n\"\"\"\ntable100 = \"\"\"\n\ntwenty\nthirty\nforty\nfifty\nsixty\nseventy\neighty\nninety\n\"\"\"\n\n\ndef solve(N):\n\tif N <= 20:\n\t\treturn table20.split(\"\\n\")[N]\n\telse:\n\t\tif N % 10 == 0:\n\t\t\treturn table100.split(\"\\n\")[N / 10]\n\t\telse:\n\t\t\treturn table100.split(\"\\n\")[N / 10] + \"-\" + table20.split(\"\\n\")[N % 10]\n\n\nN = int(raw_input())\nprint solve(N)"}, {"source_code": "x = str(input())\nl = ['zero','one','two','three','four','five','six','seven','eight','nine']\nif len(x) == 1 :\n print(l[int(x[0])])\nelif 20>int(x)>=10 :\n l = ['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\n print(l[int(x[1])])\nelif int(x)>=20 :\n l1 =[0,1,'twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n l2 = ['','one','two','three','four','five','six','seven','eight','nine']\n w = '' + str(l1[int(x[0])])\n if x[1]!='0':\n w = w +'-'+str(l2[int(x[1])])\n print(w)\n \n "}, {"source_code": "dic={}\ndic[1]=\"one\"\ndic[2]=\"two\"\ndic[3]=\"three\"\ndic[4]=\"four\"\ndic[5]=\"five\"\ndic[6]=\"six\"\ndic[7]=\"seven\"\ndic[8]=\"eight\"\ndic[9]=\"nine\"\ndic[0]=\"zero\"\ndic[10]=\"ten\"\ndic[20]=\"twenty\"\ndic[30]=\"thirty\"\ndic[40]=\"forty\"\ndic[50]=\"fifty\"\ndic[60]=\"sixty\"\ndic[70]=\"seventy\"\ndic[80]=\"eighty\"\ndic[90]=\"ninety\"\ndic[11]=\"eleven\"\ndic[12]=\"twelve\"\ndic[13]=\"thirteen\"\ndic[14]=\"fourteen\"\ndic[15]=\"fifteen\"\ndic[16]=\"sixteen\"\ndic[17]=\"seventeen\"\ndic[18]=\"eighteen\"\ndic[19]=\"nineteen\"\nn=input()\nif n<=20:\n\tprint dic[n]\nelse:\n\tif n%10==0:\n\t\tprint dic[n]\n\telse:\n\t\tstring = dic[n-n%10]+'-'+dic[n%10]\n\t\tprint string\n\t\t\n\t\n"}, {"source_code": "#!/usr/bin/python\nn=input()\ndic1={1:'ten',2:'twenty',3:'thirty',4:'forty',5:'fifty',6:'sixty',7:'seventy',8:'eighty',9:'ninety'}\ndic={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine'}\ndic2={1:'eleven',2:'twelve',3:'thirteen',4:'fourteen',5:'fifteen',6:'sixteen',7:'seventeen',8:'eighteen',9:'nineteen'}\np=n%10\nq=n/10\nif(n==0):\n print \"zero\"\nelse:\n if(p==0):\n print dic1[q]\n elif (q==0):\n print dic[p]\n elif (q==1):\n print dic2[p]\n else:\n print dic1[q]+'-'+dic[p]\n\n"}, {"source_code": "n = int(input())\nans = ''\nl1 = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nl2 = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\nif n < 20:\n ans = l1[n]\nelse:\n if n % 10 == 0:\n ans = l2[n // 10]\n else:\n ans = l2[n // 10] + '-' + l1[n % 10]\nprint(ans)"}, {"source_code": "l=list(map(int,input()))\ns=['zero','one','two','three','four','five','six','seven','eight','nine']\nf=['','ten','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nt=['','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nif len(l)>1:\n if l[0]!=1 and l[1]!=0:\n l[0]=f[l[0]]\n l[1]=s[l[1]]\n print('-'.join(l))\n elif l[0]!=1 and l[1]==0:\n print(f[l[0]])\n else:\n if l[1]==0: print(f[1])\n else: print(t[l[1]])\nelse: print(s[l[0]])"}, {"source_code": "Num1 = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nNum2 = ['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nNum3 = ['','-one','-two','-three','-four','-five','-six','-seven','-eight','-nine']\nn=raw_input()\nif int(n) < 20:\n print Num1[int(n)]\nelse:\n print '%s%s' %(Num2[int(n[0])-2],Num3[int(n[1])])"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Apr 13 18:02:27 2020\n\n@author: alexi\n\"\"\"\n\n\n\n#https://codeforces.com/problemset/problem/535/A --- Alexis Galvan\n\n\ndef tavas_nafas():\n \n dic = {0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten',11:'eleven',12:'twelve',13:'thirteen',\n 14:'fourteen',15:'fifteen',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen',20:'twenty',30:'thirty',40:'forty',50:'fifty',60:'sixty',70:'seventy',\n 80:'eighty',90:'ninety'}\n dic_21 = {2:'twenty',3:'thirty',4:'forty',5:'fifty',6:'sixty',7:'seventy',8:'eighty',9:'ninety'}\n \n \n number = int(input())\n \n if number in dic:\n print(dic[number])\n else:\n temp = str(number)\n print(dic_21[int(temp[0])] + '-' + dic[int(temp[1])])\n \ntavas_nafas()\n "}, {"source_code": "numbers = {\n 0: 'zero',\n 1: 'one',\n 2: 'two',\n 3: 'three',\n 4: 'four',\n 5: 'five',\n 6: 'six',\n 7: 'seven',\n 8: 'eight',\n 9: 'nine',\n 10: 'ten',\n 11: 'eleven',\n 12: 'twelve',\n 13: 'thirteen',\n 14: 'fourteen',\n 15: 'fifteen',\n 16: 'sixteen',\n 17: 'seventeen',\n 18: 'eighteen',\n 19: 'nineteen',\n 20: 'twenty',\n 30: 'thirty',\n 40: 'forty',\n 50: 'fifty',\n 60: 'sixty',\n 70: 'seventy',\n 80: 'eighty',\n 90: 'ninety'\n}\n\ndef run(n):\n number = False\n try:\n number = numbers[n]\n except KeyError:\n first, second = (n / 10) * 10, n % 10\n first, second = numbers[first], numbers[second]\n number = first + '-' + second\n\n return number\n\nif __name__ == \"__main__\":\n inpt = raw_input()\n args = [int(el) for el in inpt.split(' ')]\n rtn = run(*args)\n if type(rtn) is list:\n for el in rtn:\n print el\n\n else:\n print rtn\n"}], "negative_code": [{"source_code": "n = int(input())\nans = ''\nl1 = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nl2 = ['', '', 'twenty', 'thirty', 'fourty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\nif n < 20:\n ans = l1[n]\nelse:\n if n % 10 == 0:\n ans = l2[n // 10]\n else:\n ans = l2[n // 10] + '-' + l1[n % 10]\nprint(ans)"}, {"source_code": "FIRST_TEN = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\",\"eight\", \"nine\"]\nSECOND_TEN = [\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\",\"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\nOTHER_TENS = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\",\"eighty\", \"ninety\"]\nHUNDRED = \"hundred\"\n\ns = int(input())\n\ndef checkio(number):\n l = len(str(number))\n k = 10 ** (l-1)\n if l == 0 or number == 0:\n return \"\"\n elif l == 1:\n return FIRST_TEN[number-1]\n elif l == 2:\n if number >=10 and number < 20:\n return SECOND_TEN[number-10]\n else:\n a = number // k - 2\n s = \" \" if number%k > 0 else \"\"\n return OTHER_TENS[a] + s + checkio(number%k)\n elif l == 3:\n a = number // k # first number\n s = \" \" if number%k > 0 else \"\"\n return FIRST_TEN[a-1] + \" \" + HUNDRED + s + checkio(number%k)\n\n\n\nprint(checkio(s))"}, {"source_code": "ip = int(raw_input())\none = ip%10\nten = ip/10\nones = {1:\"one\", 2:\"two\", 3:\"three\", 4:\"four\", 5:\"five\", 6:\"six\", 7:\"seven\", 8:\"eight\", 9:\"nine\", 0:\"zero\"}\ntens = {1:\"ten\", 2:\"twenty\", 3:\"thirty\", 4:\"fourty\", 5:\"fifty\", 6:\"sixty\", 7:\"seventy\", 8:\"eighty\", 9:\"ninety\"}\nexp = {1:\"eleven\", 2:\"twelve\", 3:\"thirteen\", 4:\"fourteen\", 5:\"fifteen\", 6:\"sixteen\", 7:\"seventeen\", 8:\"eighteen\", 9:\"nineteen\"}\nans = \"\"\nif ten == 0:\n ans += ones[one]\nelse:\n if one == 0:\n ans += tens[ten]\n elif ten == 1:\n ans += exp[one]\n else:\n ans += tens[ten]\n ans += \"-\"\n ans += ones[one]\nprint ans"}, {"source_code": "m=input(\"Enter a number : \")\nif (m==0):\n print \"zero\"\ndef fun1(n):\n if(n==0): return \"\"\n elif(n==1): return \"one\"\n elif(n==2): return \"two\"\n elif(n==3): return \"three\"\n elif(n==4): return \"four\"\n elif(n==5): return \"five\"\n elif(n==6): return \"six\"\n elif(n==7): return \"seven\"\n elif(n==8): return \"eight\"\n elif(n==9): return \"nine\"\n elif(n==10): return \"ten\"\n elif(n==11): return \"eleven\"\n elif(n==12): return \"twelve\"\n elif(n==13): return \"thirteen\"\n elif(n==14): return \"fourteen\"\n elif(n==15): return \"fifteen\"\n elif(n==16): return \"sixteen\"\n elif(n==17): return \"seventeen\"\n elif(n==18): return \"eighteen\"\n elif(n==19): return \"nineteen\"\ndef fun2(n):\n if(n==0 or n==1): return \"\" \n elif(n==2): return \"twenty\"\n elif(n==3): return \"thirty\"\n elif(n==4): return \"fourty\"\n elif(n==5): return \"fifty\"\n elif(n==6): return \"sixty\"\n elif(n==7): return \"seventy\"\n elif(n==8): return \"eighty\"\n elif(n==9): return \"ninety\"\nx=m/10\ny=m%10\n \nif(m<20 and m!=0):\n st = fun1(m) \n\nelif(m>20 and y!=0):\n \n f=fun2(x)+'-'+fun1(y)\n print f\n \nelse:\n f=fun2(x)\n print f\n \n"}, {"source_code": "import math\n\nnumber = int(input())\n\nnumber_list = [\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nteen_list = [\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ndecades_list =[\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\n\n\nif number <= 9:\n print(number_list[number].capitalize())\nelif number >= 10 and number <= 19:\n tens = number % 10\n print(teen_list[tens].capitalize())\nelif number > 19 and number <= 99:\n ones = math.floor(number/10)\n twos = ones - 2\n tens = number % 10\n if tens == 0:\n print(decades_list[twos].capitalize())\n elif tens != 0:\n print(decades_list[twos].capitalize() + \" \" + number_list[tens])\n"}, {"source_code": "ONES = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',\n 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen',\n 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n\nDOZENS = ['twenty', 'thirty', 'fourty', 'fifty',\n 'sixty', 'seventy', 'eighty', 'ninety']\n\nn = int(input())\n\nif n > 19:\n dozens, ones = divmod(n, 10)\n print(DOZENS[dozens - 2] + ('-' + ONES[ones] if ones else ''))\nelse:\n print(ONES[n])"}, {"source_code": "arr = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',\n 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen']\narr1 = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n\nn = int(input())\nif (n > 15 and n < 20):\n print(arr[n % 10] + 'teen')\nelif (n > 19):\n if (n % 10 == 0):\n print(arr1[n // 10 - 2])\n else:\n print(arr1[n // 10 - 2] + '-' + arr[n % 10])\nelse:\n print(arr[n])\n"}, {"source_code": "l1=['one','two','three','four','five','six','seven','eight','nine']\nl2=['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nl3=['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nn=str(input())\nif(len(n)==1):\n print(l1[int(n)-1])\n exit()\nif(len(n)==2 and n[0]==\"1\"):\n print(l2[int(n)-int(n)//10*10])\n exit()\nif(n[1]==\"0\"):\n print(l3[int(n)//10-2])\n exit()\nif(len(n)==1 and n[0]==\"0\"):\n print(\"zero\")\n exit()\nprint(l3[int(n[0])-2] , \"-\" , l1[int(n[1])-1], sep='')"}, {"source_code": "# your code goes here\nt=raw_input()\ndi={\"2\":\"twenty\",\"3\":\"thirty\",\"4\":\"forty\",\"5\":\"fifty\",\"6\":\"sixty\",\"7\":\"seventy\",\"8\":\"eighty\",\"9\":\"ninety\"}\ndi1={\"1\":\"one\",\"2\":\"two\",\"3\":\"three\",\"4\":\"four\",\"5\":\"five\",\"6\":\"six\",\"7\":\"seven\",\"8\":\"eight\",\"9\":\"nine\",\"0\":\"zero\"}\ndi2={\"10\":\"ten\",\"11\":\"eleven\",\"12\":\"twelve\",\"13\":\"thirteen\",\"14\":\"fourteen\",\"15\":\"fifteen\",\"16\":\"sixteen\",\"17\":\"seventeen\",\"18\":\"eighteen\",\"19\":\"nineteen\"}\n\nif len(t)==1:\n print di1[t[0]]\n\nif int(t[0])>=2 and len(t)>1:\n print di[t[0]]+\" \"+di1[t[1]] \n\nif int(t[0])==1 and len(t)>1:\n for key in di2.keys():\n if t==key:\n print di2[key]\n\n \n"}, {"source_code": "s = int(input())\nif(s>=20):\n num = s//10\n if num == 2:\n print(\"twenty\",end=\"\")\n elif num == 3:\n print(\"thirty\",end=\"\")\n elif num == 4:\n print(\"forty\",end=\"\")\n elif num == 5:\n print(\"fifty\",end=\"\")\n elif num == 6:\n print(\"sixty\",end=\"\")\n elif num == 7:\n print(\"seventy\",end=\"\")\n elif num == 8:\n print(\"eighty\",end=\"\")\n elif num == 9:\n print(\"ninety\",end=\"\")\nif(s>=20 and s%10!=0):\n print(\"-\",end=\"\")\nif s == 10:\n print(\"ten\",end=\"\")\nif s == 11:\n print(\"eleven\",end=\"\")\nif s == 12:\n print(\"twelve\",end=\"\")\nif s == 13:\n print(\"thirteen\",end=\"\")\nif s == 14:\n print(\"fourteen\",end=\"\")\nif s == 15:\n print(\"fifteen\",end=\"\")\nif s == 16:\n print(\"sixteen\",end=\"\")\nif s == 17:\n print(\"seventeen\",end=\"\")\nif s == 18:\n print(\"eighteen\",end=\"\")\nif s == 19:\n print(\"nineteen\",end=\"\")\ns = s%10\nif s == 1:\n print(\"one\",end=\"\")\nif s == 2:\n print(\"two\",end=\"\")\nif s == 3:\n print(\"three\",end=\"\")\nif s == 4:\n print(\"four\",end=\"\")\nif s == 5:\n print(\"five\",end=\"\")\nif s == 6:\n print(\"six\",end=\"\")\nif s == 7:\n print(\"seven\",end=\"\")\nif s == 8:\n print(\"eight\",end=\"\")\nif s == 9:\n print(\"nine\",end=\"\")"}, {"source_code": "num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten',\n 11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen',\n 15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen',\n 19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty',\n 50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty',\n 90: 'Ninety', 0: 'Zero'}\n\ndef n2w(n):\n return num2words[n-n%10] + '-' + num2words[n%10].lower()\n\nn = input()\n\nprint n2w(n).lower()"}, {"source_code": "def score (n):\n ref = {1:\"one\" , 2:\"two\",3:\"three\",4:\"four\",5:\"five\",6:\"six\",7:\"seven\",8:\"eight\",9:\"nine\",\n 10:\"ten\",11:\"eleven\",12:\"twelve\",13:\"thirteen\",14:\"fourteen\",15:\"fifteen\",16:\"sixteen\",\n 17:\"seventeen\",18:\"eighteen\",19:\"nineteen\",20:\"twenty\",30:\"thirthy\",40:\"fourty\",50:\"fifthy\",\n 60:\"sixty\",70:\"seventy\",80:\"eighty\",90:\"ninety\"}\n\n n = list(n)\n if len(n) == 1:\n return ref[int(n[0])]\n elif n[0] == \"1\" :\n return ref[int(n[0]+n[1])]\n elif n[1] == \"0\" :\n return ref[int(n[0]+n[1])]\n else:\n ans = \"\"\n ans += ref[int(n[0]+\"0\")]\n ans += \"-\"\n ans += ref[int(n[1])]\n return ans\n\n\nprint (score(input()))\n \n \n\n\n \n \n \n \n"}, {"source_code": "s=int(raw_input(\"enter the number.(0-99):\",))\nzhenshu=(\"ten\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\n \"ninety\")\nxiaodeshu=(\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\n \"six\",\"seven\",\"eight\",\"nine\")\nif s>99:\n print \"you have entered a wrong number\"\nelse:\n if s%10==0 and s>=10:\n print zhenshu[s/10-1]\n elif s<10:\n print xiaodeshu[s-1]\n else:\n print zhenshu[int(s/10)-1]+\"-\"+xiaodeshu[s%10]\n"}, {"source_code": "s=raw_input()\nA=dict()\nA['1']='one'\nA['2']='two'\nA['3']='three'\nA['4']='four'\nA['5']='five'\nA['6']='six'\nA['7']='seven'\nA['8']='eight'\nA['9']='nine'\nA['10']='ten'\nA['11']='eleven'\nA['12']='twelve'\nA['13']='thirteen'\nA['14']='fourteen'\nA['15']='fifteen'\nA['16']='sixteen'\nA['17']='seventeen'\nA['18']='eighteen'\nA['19']='nineteen'\nA['20']='twenty'\nA['30']='thirty'\nA['40']='forty'\nA['50']='fifty'\nA['60']='sixty'\nA['70']='seventy'\nA['80']='eighty'\nA['90']='ninty'\nif len(s)==1 or (len(s)==2 and (s[0]=='1' or s[1]=='0')):\n print A[s]\nelse:\n print A[s[0]+'0']+'-'+A[s[1]]"}, {"source_code": "s = raw_input()\na = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nc = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninty']\nd = int(s)\nif d < 20:\n\tprint a[d]\nelse:\n\te = int(s[1])\n\tprint c[int(s[0])] + ('-' + a[e] if e > 0 else '') "}, {"source_code": "s = input()\na = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nif int(s) == 0:\n print('zero')\nelif int(s) < 20:\n print(a[int(s)-1])\nelif int(s) >= 80 and int(s) < 90:\n print('eighty', end = '')\n if int(s) != 80:\n print('-', a[int(s[1])-1], sep = '')\nelif int(s) >= 50 and int(s) < 60:\n print('fifty', end = '')\n if int(s) != 80:\n print('-', a[int(s[1])-1], sep = '')\nelse:\n n = int(s)\n if n > 39:\n if n % 10 == 0:\n print(a[int(s[0])-1], 'ty', sep = '')\n else:\n print(a[int(s[0]) - 1] ,'ty' , '-' , a[int(s[1])-1], sep ='')\n else:\n if n < 30:\n print('twenty', end = '')\n if n % 10 != 0:\n print('-', a[int(s[1])-1], sep = '')\n else:\n print('thirty', end = '')\n if n % 10 != 0:\n print('-', a[int(s[1])-1], sep = '')"}, {"source_code": "n = raw_input()\nnums = {'1': 'one', '2': 'two', '3':'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven',\n '8': 'eight', '9': 'nine', '10': 'ten', '11': 'eleven', '12': 'tweleve', '13': 'thirteen',\n '14': 'fourteen', '15': 'fifteen', '16': 'sixteen', '17': 'seventeen', '18': 'eighteen',\n '19': 'nineteen', '20': 'twenty', '30': 'thirty', '40': 'forty', '50': 'fifty',\n '60': 'sixty', '70': 'seventy', '80': 'eighty', '90': 'ninety','0': 'zero'}\nnum = int(n)\nfirst = num/10\nr = num%10\nif(first<=1):\n print nums[n]\nif(first>=2):\n ans = nums[str(first*10)]\n if(r!=0):\n ans+='-'+nums[str(r)]\n print ans\n"}, {"source_code": "u=['','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen',]\nv=['twenty','thirty','fourty','fifty','sixty','seventy','eighty','ninety']\nn=int(input())\ns=u[n]if n<20 else'-'.join([v[n//10-2],u[n%10]])\nif not s:s='zero'\nprint(s.strip('-')\n)"}, {"source_code": "FIRST_TEN = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\",\"eight\", \"nine\"]\nSECOND_TEN = [\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\",\"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\nOTHER_TENS = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\",\"eighty\", \"ninety\"]\nHUNDRED = \"hundred\"\n\ns = int(input())\n\ndef checkio(number):\n l = len(str(number))\n k = 10 ** (l-1)\n if number == 0:\n return \"zero\" \n if l == 0:\n return \"\"\n elif l == 1:\n return FIRST_TEN[number-1]\n elif l == 2:\n if number >=10 and number < 20:\n return SECOND_TEN[number-10]\n else:\n a = number // k - 2\n s = \" \" if number%k > 0 else \"\"\n return OTHER_TENS[a] + s + checkio(number%k)\n elif l == 3:\n a = number // k # first number\n s = \" \" if number%k > 0 else \"\"\n return FIRST_TEN[a-1] + \" \" + HUNDRED + s + checkio(number%k)\n\n\n\nprint(checkio(s))"}, {"source_code": "import math\nimport sys\n\ndef main():\n start = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\",\n \"eight\", \"nine\", \"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\",\n \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\n prefixes = [\"twenty\", \"thirty\", \"fourty\", \"fifty\", \"sixty\", \"seventy\",\n \"eighty\", \"ninety\"]\n n = int(raw_input())\n if n <= len(start) - 1:\n print start[n]\n else:\n out = \"\"\n digit = int(str(n)[0])\n digit -= 2\n prefix = prefixes[digit]\n other = int(str(n)[1])\n out += prefix\n if n % 10 != 0:\n out += \"-\"\n out += start[other]\n print out\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "l1=['ten' ,'eleven', 'twelve' ,'thirteen' ,'fourteen','fifteen','sixteen' ,'seventeen','eighteen','nineteen']\nl2=['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nl3=['','one','tow','three','four','five','six','seven','eight','nine']\nn = input()\nif n=='0' : print('zero')\nelif 10<=int(n)<=19:\n print(l1[int(n)-10])\nelse:\n if len(n)==1 : print(l3[int(n)])\n \n else :\n if n[1]=='0':print(l2[int(n[0])])\n else : print(l2[int(n[0])] + '-' + l3[int(n[1])])\n \n"}, {"source_code": "s = input()\ne = {'0':'zero','1':'one','2':'two','3':'three','4':'four','5':'five',\n '6':'six','7':'seven','8':'eight','9':'nine'}\n\ntens = ['ten','eleven','twelve','thirteen','fourteen','fifteen',\n 'sixteen', 'seventeen', 'eighteen','nineteen']\n\nt = {'2':'twenty','3':'thirty','4':'fourty', '5':'fifty', '6':'sixty',\n '7':'seventy','8':'eighty','9':'ninety'}\n \nif len(s)==1:\n print (e[s])\nelif s[0] == '1':\n p = int(s[1])\n print (tens[p])\nelse:\n o = t[s[0]]\n if s[1]!=0:\n o += '-' + e[s[1]]\n print (o)"}, {"source_code": "a = [\n'zero',\n'one',\n'two',\n'three',\n'four',\n'five',\n'six',\n'seven',\n'eight',\n'nine']\n\nb =[\n'ten',\n'eleven',\n'twelve',\n'thirteen',\n'fourteen',\n'fifteen',\n'sixteen',\n'seventeen',\n'eighteen',\n'nineteen',\n]\n\nc = [\n'twenty',\n'thirty',\n'forty',\n'fifty',\n'sixty',\n'seventy',\n'eighty',\n'ninety',\n]\n\nn = input()\n\nif n < 10:\n print a[n]\nelif 10 < n < 20:\n print b[n-10]\nelif n % 10 == 0:\n print c[n / 10 - 2]\nelse:\n print \"%s-%s\" % (c[n / 10 - 2], a[n%10])\n"}, {"source_code": "n=int(input())\nif(n<=20):\n if(n==1):\n print(\"one\")\n if(n==2):\n print(\"two\")\n if(n==3):\n print(\"three\")\n if(n==4):\n print(\"four\")\n if(n==5):\n print(\"five\")\n if(n==6):\n print(\"six\")\n if(n==7):\n print(\"seven\")\n if(n==8):\n print(\"eight\")\n if(n==9):\n print(\"nine\")\n if(n==10):\n print(\"ten\")\n if(n==11):\n print(\"eleven\")\n if(n==12):\n print(\"twelve\")\n if(n==13):\n print(\"thireen\")\n if(n==14):\n print(\"fourten\")\n if(n==15):\n print(\"fifteen\")\n if(n==16):\n print(\"sixteen\")\n if(n==17):\n print(\"seventeen\")\n if(n==18):\n print(\"eighteen\")\n if(n==19):\n print(\"nineteen\")\n if(n==20):\n print(\"twenty\")\n\nar1=[\"\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nar2=[\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\nif(n>20):\n c=n%10\n d=n//10\n if(c==0):\n print(ar2[d-2])\n else:\n s=ar2[d-2]+\"-\"+ar1[c]\n print(s)\n \n \n"}, {"source_code": "n = int(input())\nd = {1:\"one\",2:\"two\",3:\"three\",4:\"four\",5:\"five\",6:\"six\"\\\n\t,7:\"seven\",8:\"eight\",9:\"nine\",10:\"ten\",11:\"eleven\",12:\"twelve\"\\\n\t,13:\"thirteen\",14:\"fourteen\",15:\"fifteen\",16:\"sixteen\",17:\"seventeen\",\\\n\t18:\"eighteen\",19:\"nineteen\"}\n\n\nif n in d:\n\tprint(d[n])\nelif n//10 == 4:\n\tif n%10:\n\t\tprint(\"forty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"forty\")\nelif n//10 == 5:\n\tif n%10:\n\t\tprint(\"fifty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"fifty\")\nelif n//10 == 3:\n\tif n%10:\n\t\tprint(\"thirty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"thirty\")\nif n//10 == 2:\n\tif n%10:\n\t\tprint(\"twenty\"+\"-\"+d[n%10])\n\telse:\n\t\tprint(\"twenty\")\nelif n//10 == 8:\n\tif n%10:\n\t\tprint(d[n//10]+\"y-\"+d[n%10])\n\telse:\n\t\tprint(d[n//10]+\"y\")\nelif n//10 > 5:\n\tif n%10:\n\t\tprint(d[n//10]+\"ty-\"+d[n%10])\n\telse:\n\t\tprint(d[n//10]+\"ty\")\n"}, {"source_code": "#! /usr/local/python\n\nimport math\n\nwords = {1: \"one\",\n 2: \"two\",\n 3: \"three\",\n 4: \"four\",\n 5: \"five\",\n 6: \"six\",\n 7: \"seven\",\n 8: \"eight\",\n 9: \"nine\",\n 0: \"zero\"\n }\n\n\ntens = {10: \"ten\",\n 11: \"eleven\",\n 12: \"twelve\",\n 13: \"thirteen\",\n 14: \"fourteen\",\n 15: \"fifteen\",\n 16: \"sixteen\",\n 17: \"seventeen\",\n 18: \"eighteen\",\n 19: \"nineteen\"\n }\ntees = {\n 2: \"twenty\",\n 3: \"thirty\",\n 4: \"forty\",\n 5: \"fifty\",\n 6: \"sixty\",\n 7: \"seventy\",\n 8: \"eighty\",\n 9: \"ninty\"\n}\ndef solve(num):\n if num < 10:\n return words [num]\n if num < 20:\n return tens[num]\n return tees[math.floor(num/10.0)] + (\"\" if num%10 == 0 else \"-\"+words[num%10])\n\nnum = int(raw_input())\nprint solve(num)\nassert(solve(6) == \"six\")\nassert(solve(0) == \"zero\")\nassert(solve(19) == \"nineteen\")\nassert(solve(12) == \"twelve\")\nassert(solve(90) == \"ninty\")\nassert(solve(99) == \"ninty-nine\")\nassert(solve(55) == \"fifty-five\")\n"}, {"source_code": "def score (n):\n ref = {1:\"one\" , 2:\"two\",3:\"three\",4:\"four\",5:\"five\",6:\"six\",7:\"seven\",8:\"eight\",9:\"nine\",\n 10:\"ten\",11:\"eleven\",12:\"twelve\",13:\"thirteen\",14:\"fourteen\",15:\"fifthteen\",16:\"sixteen\",\n 17:\"seventeen\",18:\"eighteen\",19:\"nineteen\",20:\"twenty\",30:\"thirthy\",40:\"fourty\",50:\"fifthy\",\n 60:\"sixty\",70:\"seventy\",80:\"eighty\",90:\"ninety\"}\n\n n = list(n)\n if len(n) == 1:\n return ref[int(n[0])]\n elif n[0] == \"1\" :\n return ref[int(n[0]+n[1])]\n elif n[1] == \"0\" :\n return ref[int(n[0]+n[1])]\n else:\n ans = \"\"\n ans += ref[int(n[0]+\"0\")]\n ans += \"-\"\n ans += ref[int(n[1])]\n return ans\n\n\nprint (score(input()))\n \n \n\n\n \n \n \n \n"}, {"source_code": "x=input()\nf=int(x)\ns=int(x[0])\nnums=['one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nif x == 0:\n print(\"zero\")\nelif len(x) == 1:\n print(nums[f-1])\nelse:\n d=int(x[1])\n if f < 20 :\n print(nums[f-1])\n elif f%10 == 0:\n print(nums[s+17])\n else:\n print(nums[s+17]+\"-\"+nums[d-1])\n"}, {"source_code": "n = input()\n\nones = {'0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven',\n '8': 'eight', '9': 'nine'}\nn10To19 = {'10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'fifteen'\n '16', 'sixteen': 'sixteen', '17': 'seventeen', '18': 'eighteen', '19': 'nineteen'}\n\nn20to99 = {'2': 'twenty', '3': 'thirty', '4': 'forty', '5': 'fifty', '6': 'sixty', '7': 'seventy', '8': 'eighty',\n '9': 'ninety'}\n\nif 0 <= n <= 9:\n print ones[str(n)]\n\nelif 10 <= n <= 19:\n print n10To19[str(n)]\n\nelse:\n strN = str(n)\n parsedN = n20to99[strN[0]]\n\n if strN[1] != '0':\n parsedN += '-' + ones[strN[1]]\n\n print parsedN\n"}, {"source_code": "lis1=[\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nlist2=[\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\n#list3=[\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninrty\"]\nnumber=input()\ny=int(number)\nif len(number)==1:\n print(lis1[y])\nelse:\n if number[0]=='1':\n print(list2[int(number[1])])\n elif number[0]=='2':\n if number[1]=='0':\n print(\"twenty\")\n else:\n print(f\"twenty-{lis1[int(number[1])]}\")\n elif number[0]=='3':\n if number[1]=='0':\n print(\"thirty\")\n else:\n print(f\"thirty-{lis1[int(number[1])]}\")\n elif number[0]=='4':\n if number[1]=='0':\n print(\"fourty\")\n else:\n print(f\"fourty-{lis1[int(number[1])]}\")\n elif number[0]=='5':\n if number[1]=='0':\n print(\"fifty\")\n else:\n print(f\"fifty-{lis1[int(number[1])]}\")\n elif number[0]=='6':\n if number[1]=='0':\n print(\"sixty\")\n else:\n print(f\"sixty-{lis1[int(number[1])]}\")\n elif number[0]=='7':\n if number[1]=='0':\n print(\"seventy\")\n else:\n print(f\"seventy-{lis1[int(number[1])]}\")\n elif number[0]=='8':\n if number[1]=='0':\n print(\"eighty\")\n else:\n print(f\"eighty-{lis1[int(number[1])]}\")\n elif number[0]=='9':\n if number[1]=='0':\n print(\"ninety\")\n else:\n print(f\"ninety-{lis1[int(number[1])]}\")"}, {"source_code": "import math\n\nnumber = int(input(\"Enter number to print: \"))\n\nnumber_list = [\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nteen_list = [\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ndecades_list =[\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\n\n\nif number <= 9:\n print(number_list[number].capitalize())\nelif number >= 10 and number <= 19:\n tens = number % 10\n print(teen_list[tens].capitalize())\nelif number > 19 and number <= 99:\n ones = math.floor(number/10)\n twos = ones - 2\n tens = number % 10\n if tens == 0:\n print(decades_list[twos].capitalize())\n elif tens != 0:\n print(decades_list[twos].capitalize() + \" \" + number_list[tens])\n"}, {"source_code": "import sys\n\n\ndef single(number):\n if number == 1:\n print('one')\n elif number == 2:\n print('two')\n elif number == 3:\n print('three')\n elif number == 4:\n print('four')\n elif number == 5:\n print('five')\n elif number == 6:\n print('six')\n elif number == 7:\n print('seven')\n elif number == 8:\n print('eigth')\n elif number == 9:\n print('nine')\n\n\ndef main():\n number = int(input())\n single(number)\n if number == 10:\n print('ten')\n elif number == 11:\n print('eleven')\n elif number == 12:\n print('twelve')\n elif number == 13:\n print('thirteen')\n elif number == 14:\n print('fourteen')\n elif number == 15:\n print('fifteen')\n elif number == 16:\n print('sixteen')\n elif number == 17:\n print('seventeen')\n elif number == 18:\n print('eighteen')\n elif number == 19:\n print('nineteen')\n elif number == 20:\n print('twenty')\n elif 20 < number < 30:\n sys.stdout.write('twenty-')\n single(number % 10)\n elif number == 30:\n print('thirty')\n elif 30 < number < 40:\n sys.stdout.write('thirty-')\n single(number % 10)\n elif number == 40:\n print('forty')\n elif 40 < number < 50:\n sys.stdout.write('forty-')\n single(number % 10)\n elif number == 50:\n print('fifty')\n elif 50 < number < 60:\n sys.stdout.write('fifty-')\n single(number % 10)\n elif number == 60:\n print('sixty')\n elif 60 < number < 70:\n sys.stdout.write('sixty-')\n single(number % 10)\n elif number == 70:\n print('seventy')\n elif 70 < number < 80:\n sys.stdout.write('seventy-')\n single(number % 10)\n elif number == 80:\n print('eighty')\n elif 80 < number < 90:\n sys.stdout.write('eighty-')\n single(number % 10)\n elif number == 90:\n print('ninety')\n elif 90 < number < 100:\n sys.stdout.write('ninety-')\n single(number % 10)\n elif number == 100:\n print('one-hundred')\n\n\nmain()\n"}, {"source_code": "k = int(input())\nones = k % 10\ntens = int(k / 10)\n\n_first = {\n 1: 'ten',\n 2: 'twenty',\n 3: 'thirty',\n 4: 'fourty',\n 5: 'fifty',\n 6: 'sixty',\n 7: 'seventy',\n 8: 'eighty',\n 9: 'ninety'\n}\n\n_second = {\n 0: 'zero',\n 1: 'one',\n 2: 'two',\n 3: 'three',\n 4: 'four',\n 5: 'five',\n 6: 'six',\n 7: 'seven',\n 8: 'eight',\n 9: 'nine'\n}\n\nif (tens == 1):\n if(k == 10):\n print(\"ten\")\n elif(k == 11):\n print(\"eleven\")\n elif(k == 12):\n print(\"twelve\")\n elif(k == 13):\n print(\"thirteen\")\n elif(k == 14):\n print(\"fourteen\")\n elif(k == 15):\n print(\"fifteen\")\n elif(k == 16):\n print(\"sixteen\")\n elif(k == 17):\n print(\"seventeen\")\n elif(k == 18):\n print(\"eighteen\")\n elif(k == 19):\n print(\"nineteen\")\nelse:\n if (ones == 0 and tens !=0):\n print (_first[tens])\n if (tens == 0):\n print(_second[ones])\n if (tens!=0 and ones!= 0):\n f = _first[tens]\n s = _second[ones]\n finalString = f + \"-\" + s\n print(finalString)"}, {"source_code": "n = int(input())\ns = str(n)\nk = len(s)\ni = 0\nif(n>=20) :\n i = 0\n k = 1\n if(s[i]=='2') :\n print('twenty',end='')\n elif(s[i]=='3') :\n print('thirty',end='')\n elif(s[i]=='4') :\n print('forty',end='')\n elif(s[i]=='5') :\n print('fifty',end='')\n elif(s[i]=='6') :\n print('sixty',end='')\n elif(s[i]=='7') :\n print('seventy',end='')\n elif(s[i]=='8') :\n print('eighty',end='')\n elif(s[i]=='9') :\n print('ninety',end='')\nif(n>=19 and n%10!=0) :\n print('-',end='')\nif(n<=9 or k==1) :\n if(n<=9) :\n i = 0\n else :\n i = 1\n if(s[i]=='0' and i==0) :\n print('zero')\n elif(s[i]=='1') :\n print('one')\n elif(s[i]=='2') :\n print('two')\n elif(s[i]=='3') :\n print('three')\n elif(s[i]=='4') :\n print('four')\n elif(s[i]=='5') :\n print('five')\n elif(s[i]=='6') :\n print('six')\n elif(s[i]=='7') :\n print('seven')\n elif(s[i]=='8') :\n print('eight')\n elif(s[i]=='9') :\n print('nine')\nif(n>=10 and n<=19):\n if(s=='10') :\n print('ten')\n elif(s=='11') :\n print('eleven')\n elif(s=='12') :\n print('twelve')\n elif(s=='13') :\n print('thirteen')\n elif(s=='14') :\n print('fourteen')\n elif(s=='15') :\n print('fifteen')\n elif(s=='16') :\n print('sixteen')\n elif(s=='17') :\n print('seventeen')\n elif(s=='18') :\n print('eighteen')\n elif(s=='19') :\n print('nineteen')\n \n "}, {"source_code": "i = int(input())\na = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve']\nn = ['thir','fif','teen','ty','twenty']\nif i in range(0,13): print(a[i])\nelif i==13 or i==15: print(n[0]+n[2] if i==13 else n[1]+n[2])\nelif i == 14 or i in range(16,20): print(a[int(str(i)[1])]+n[2])\nelif i == 20 or i in range(21,30): print(n[4] if i == 20 else str(n[4])+\"-\"+str(a[int(str(i)[1])]))\nelif i == 30 or i == 50: print(n[0]+n[3] if i==30 else n[1]+n[3])\nelif i in range(31,40) or i in range(51,60): print(str(n[0]+n[3])+\"-\"+str(a[int(str(i)[1])])\n if i in range(31,40) else str(n[1]+n[3])+\"-\"+str(a[int(str(i)[1])]))\nelif i % 10 == 0: print(a[int(str(i)[0])]+n[3])\nelse: print(str(a[int(str(i)[0])]+n[3])+\"-\"+str(a[int(str(i)[1])]))"}, {"source_code": "num=input()\ndd={'1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine',\n '10':'ten','11':'eleven','12':'twelve','13':'thirteen','14':'fourteen','15':'fifteen',\n '16':'sixteen','17':'seventeen','18':'eighteen','19':'nineteen'}\nout=''\nif num=='0':\n print('zero')\n exit()\nif len(num)==2:\n a=num[0]\n b=num[1]\n if a=='2':\n out+='twenty'\n elif a=='3':\n out+='thirty'\n elif a=='1':\n out+=dd[num]\n print(out)\n exit()\n else:\n if a=='4':\n out+='forty'\n elif a=='5':\n out+='fifty'\n else:\n out+=dd[a]+'ty'\n if b=='0':\n pass\n else:\n out+='-'+dd[b]\nif len(num)==1:\n out+=dd[num]\nprint(out)\n \n"}, {"source_code": "s = input()\ne = {'0':'zero','1':'one','2':'two','3':'three','4':'four','5':'five',\n '6':'six','7':'seven','8':'eight','9':'nine'}\n\ntens = ['ten','eleven','twelve','thirteen','fourteen','fifteen',\n 'sixteen', 'seventeen', 'eighteen','nineteen']\n\nt = {'2':'twenty','3':'thirty','4':'fourty', '5':'fifty', '6':'sixty',\n '7':'seventy','8':'eighty','9':'ninety'}\n \nif len(s)==1:\n print (e[s])\nelif s[0] == '1':\n p = int(s[1])\n print (tens[p])\nelse:\n o = t[s[0]]\n if s[1]!=0:\n o += '-' + e[s[1]]\n print (o)"}, {"source_code": "n = int(input())\nw = [\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\"eleven\",\"twelve\"]\nw1 = [x + \"teen\" for x in ([\"thir\"] + w[3:9])]; w1[2] = \"fifteen\"; w1[5] = \"eighteen\";\nw += w1\nw10 = [\"twenty\",\"thirty\",\"forty\",\"fifty\"] + [x + \"ty\" for x in w[5:9]]; w10[-2] = \"eighty\"\nfor x in w10: w += [x] + [x + \"-\" + y for y in w[0:9]]\nprint w[n]"}, {"source_code": "n=int(input())\nif(n<=20):\n if(n==0):\n print(\"zero\")\n if(n==1):\n print(\"one\")\n if(n==2):\n print(\"two\")\n if(n==3):\n print(\"three\")\n if(n==4):\n print(\"four\")\n if(n==5):\n print(\"five\")\n if(n==6):\n print(\"six\")\n if(n==7):\n print(\"seven\")\n if(n==8):\n print(\"eight\")\n if(n==9):\n print(\"nine\")\n if(n==10):\n print(\"ten\")\n if(n==11):\n print(\"eleven\")\n if(n==12):\n print(\"twelve\")\n if(n==13):\n print(\"thireen\")\n if(n==14):\n print(\"fourten\")\n if(n==15):\n print(\"fifteen\")\n if(n==16):\n print(\"sixteen\")\n if(n==17):\n print(\"seventeen\")\n if(n==18):\n print(\"eighteen\")\n if(n==19):\n print(\"nineteen\")\n if(n==20):\n print(\"twenty\")\n\nar1=[\"\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nar2=[\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\nif(n>20):\n c=n%10\n d=n//10\n if(c==0):\n print(ar2[d-2])\n else:\n s=ar2[d-2]+\"-\"+ar1[c]\n print(s)\n \n \n"}, {"source_code": "l=list(map(int,input()))\ns=['','one','two','three','four','five','six','seven','eight','nine']\nf=['','ten','twenty','thirty','fourty','fifty','sixty','seventy','eighty','ninety']\nt=['','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nif len(l)>1:\n if l[0]!=1 and l[1]!=0:\n l[0]=f[l[0]]\n l[1]=s[l[1]]\n print('-'.join(l))\n elif l[0]!=1 and l[1]==0:\n print(f[l[0]])\n else:\n if l[1]==0: print(f[1])\n else: print(t[l[0]])\nelse: print(s[l[0]])"}, {"source_code": "a=int(input())\nprint(['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty-one', 'twenty-two', 'twenty-three', 'twenty-four', 'twenty-five', 'twenty-six', 'twenty-seven', 'twenty-eight', 'twenty-nine', 'thirty', 'thirty-one', 'thirty-two', 'thirty-three', 'thirty-four', 'thirty-five', 'thirty-six', 'thirty-seven', 'thirty-eight', 'thirty-nine', 'forty', 'forty- one', 'forty-two', 'forty-three', 'forty-four', 'forty-five', 'forty-six', 'forty-seven', 'forty-eight', 'forty-nine', ' fifty', 'fifty-one', 'fifty-two', 'fifty-three', 'fifty-four', 'fifty-five', 'fifty-six', 'fifty-seven', 'fifty-eight', ' fifty-nine', 'sixty', 'sixty-one', 'sixty-two', 'sixty-three', 'sixty-four', 'sixty-five', 'sixty-six', 'sixty-seven', 'sixty-eight', 'sixty-nine', 'seventy', 'seventy-one', 'seventy-two', 'seventy-three', 'seventy-four', 'seventy-five', 'seventy-six', 'seventy-seven', 'seventy-eight', 'seventy-nine', 'eighty', 'eighty-one', 'eighty-two', 'eighty-three', 'eight y-four', 'eighty-five', 'eighty-six', 'eighty-seven', 'eighty-eight', 'eighty-nine', 'ninety', 'ninety-one', 'ninety-two' , 'ninety-three', 'ninety-four', 'ninety-five', 'ninety-six', 'ninety-seven', 'ninety-eight', 'ninety-nine'][a])"}, {"source_code": "n = input()\n\nones = {'0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven',\n '8': 'eight', '9': 'nine'}\nn10To19 = {'10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'fifteen'\n '16', 'sixteen': 'sixteen', '17': 'seventeen', '18': 'eighteen', '19': 'nineteen'}\n\nn20to99 = {'2': 'twenty', '3': 'thirty', '4': 'forty', '5': 'fifty', '6': 'sixty', '7': 'seventy', '8': 'eighty',\n '9': 'ninety'}\n\nif 0 <= n <= 9:\n print ones[str(n)]\n\nelif 10 <= n <= 19:\n print n10To19[str(n)]\n\nelse:\n strN = str(n)\n parsedN = n20to99[strN[0]]\n\n if strN[1] != '0':\n parsedN += '-' + ones[strN[1]]\n\n print parsedN\n"}, {"source_code": "#!/usr/bin/env\n\nlast_digit = [\n \"zero\",\n \"one\",\n \"two\",\n \"three\",\n \"four\",\n \"five\",\n \"six\",\n \"seven\",\n \"eight\",\n \"nine\"\n ]\nsecond_digit = [\n \"twenty\",\n \"thirty\",\n \"forty\",\n \"fifth\",\n \"sixty\",\n \"seventy\",\n \"eighty\",\n \"ninety\"\n ]\n\ntens = [\n \"ten\",\n \"eleven\",\n \"twelves\",\n \"thirteen\",\n \"forteen\",\n \"fifteen\",\n \"sixteen\",\n \"seventeen\",\n \"eighteen\",\n \"nineteen\"\n ]\n\ndef read_score(x):\n if len(x) == 1:\n return last_digit[int(x)]\n elif x[0] > \"1\":\n if x[1] == \"0\":\n return second_digit[int(x[0]) - 2]\n else:\n return \"-\".join([\n second_digit[int(x[0]) - 2],\n last_digit[int(x[1])]\n ])\n else:\n return tens[int(x) - 10]\n\nscore = input()\nprint(read_score(score))\n"}, {"source_code": "n = int(input())\nsmall = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\nbig = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\nmiddle = ['', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eightteen', 'nineteen']\nif n == 0:\n print('zero')\nelif 11 <= n <= 19:\n print(middle[n - 10])\nelse:\n print(big[n // 10], end='')\n if n % 10 != 0 and n >= 10:\n print('-', end='')\n print(small[n % 10])"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\ndic = {\"19\":\"nineteen\", \"18\":\"eighteen\", \"17\":\"seventeen\", \"16\":\"sixteen\", \"15\":\"fifteen\", \"14\":\"fourteen\", \"13\":\"thirteen\",\n \"12\":\"twelve\", \"11\":\"eleven\", \"10\":\"ten\", \"9\":\"nine\", \"8\":\"eight\", \"7\":\"seven\",\n \"6\":\"six\" , \"5\":\"five\", \"4\":\"four\", \"3\":\"three\", \"2\":\"two\", \"1\":\"one\", \"0\":\"zero\"}\ndic10 = {\"9\":\"ninety\", \"8\":\"eighty\", \"7\":\"seventy\", \"6\":\"sixty\", \"5\":\"fifty\", \"4\":\"fourty\", \"3\":\"thirty\", \"2\":\"twenty\"}\n\ns = raw_input()\nif s in dic:\n print dic[s]\nelse:\n if s[1] != \"0\":\n print dic10[s[0]] + \"-\" + dic[s[1]]\n else:\n print dic10[s[0]]\n"}, {"source_code": "s1=[\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\ns2=['ten','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nss=raw_input()\nif len(ss)==2 and ss[1]=='0': print s2[ord(ss[0])-ord('1')]\nelif len(ss)==2: print '-'.join([s2[ord(ss[0])-ord('1')],s1[ord(ss[0])-ord('0')]])\nelse: print s1[ord(ss[0])-ord('0')]"}, {"source_code": "'''Author: Abdurasul !!!'''\n\na=['','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty']\nb=['','ten','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nn=input()\nif int(n)<=20:print(a[int(n)])\nelse:\n if n[1]=='0':print(b[int(n[0])])\n else:print(b[int(n[0])]+'-'+a[int(n[1])])\n"}, {"source_code": "l1=['ten' ,'eleven', 'twelve' ,'thirteen' ,'fourteen','fifteen','sixteen' ,'seventeen','eighteen','nineteen']\nl2=['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nl3=['','one','two','three','four','five','six','seven','eight','nine']\nfor i in range(100):\n n = str(i)\n if n=='0' : print('zero')\n elif 10<=int(n)<=19:\n print(l1[int(n)-10])\n else:\n if len(n)==1 : print(l3[int(n)])\n \n else :\n if n[1]=='0':print(l2[int(n[0])])\n else : print(l2[int(n[0])] + '-' + l3[int(n[1])])\n \n\n"}, {"source_code": "''' \n \t\n \t\t\t ||Sri:|| \n\n __|\n ______________|_________________________\n | | ___| | | ___| | | |___\n /\\ /\\ | |___ | | |___| | | |___|\n/ \\/ \\ | ___| | | |_/ |___| |___\n\nI am a beginner. Feel free to send tutorials/help to srinivasan1995@gmail.com.\n\nCodeforces, SPOJ handle: desikachariar.\nHackerrank, Codechef handle: Prof_Calculus.\n\nAdvises/Help are welcome. You will definitely get a thanks in return. Comments to be avoided.\n\nCollege: International Institute of Information Technology, Bangalore.\n\n'''\n\nimport math\n\nhsh = {0:\"zero\", 1:\"one\", 2:\"two\", 3:\"three\", 4:\"four\", 5:\"five\", 6:\"six\", 7:\"seven\", 8:\"eight\", 9:\"nine\", 10:\"ten\", 11:\"eleven\", 12:\"twelve\", 13:\"thirteen\", 14:\"fourteen\", 15:\"fifteen\", 16:\"sixteen\", 17:\"seventeen\", 18:\"eighteen\", 19:\"nineteen\", 20:\"twenty\", 30:\"thirty\", 40:\"fourty\", 50:\"fifty\", 60:\"sixty\", 70:\"seventy\", 80:\"eighty\", 90:\"ninety\"}\n\nif __name__ == '__main__':\n\tx = input()\n\tls = [x/10, x%10]\n\tif(x < 10):\n\t\tprint hsh[x]\n\telse:\n\t\tif ls[0] == 1:\n\t\t\tprint hsh[(ls[0]*10) + ls[1]]\n\t\telse:\n\t\t\tif ls[1] == 0:\n\t\t\t\tprint hsh[(ls[0]*10)]\n\t\t\telse:\n\t\t\t\tprint hsh[(ls[0]*10)] + \"-\" + hsh[ls[1]]\n\t\n"}, {"source_code": "ONES = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',\n 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen',\n 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n\nDOZENS = ['twenty', 'thirty', 'fourty', 'fifty',\n 'sixty', 'seventy', 'eighty', 'ninety']\n\nn = int(input())\n\nif n > 19:\n dozens, ones = divmod(n, 10)\n print(DOZENS[dozens - 2] + ('-' + ONES[ones] if ones else ''))\nelse:\n print(ONES[n])"}, {"source_code": "def travis():\n\n s = raw_input()\n a = []\n n = len(s)\n\n for i in s:\n if (n > 1 ):\n if (i == '1'):\n if( s == '10'):\n a.append('ten')\n break\n if( s == '11'):\n a.append('eleven')\n break\n if( s == '12'):\n a.append('twelve')\n break\n if( s == '13'):\n a.append('thirteen')\n break\n if( s == '14'):\n a.append('fourteen')\n break\n if( s == '15'):\n a.append('fifteen')\n break\n if( s == '16'):\n a.append('sixteen')\n break\n if( s == '17'):\n a.append('seventeen')\n break\n if( s == '18'):\n a.append('eightteen')\n break\n if( s == '19'):\n a.append('nineteen')\n break\n\n\n\n\n\n\n\n\n if (i == '2'):\n a.append(\"twenty\")\n n= 0\n if (i == '3'):\n a.append(\"thirty\")\n n = 0\n if (i == '4'):\n a.append(\"forty\")\n n = 0\n\n if (i == '5'):\n a.append(\"fifty\")\n n = 0\n if (i == '6'):\n a.append(\"sixty\")\n n = 0\n if (i == '7'):\n a.append(\"seventy\")\n n = 0\n if (i == '8'):\n a.append(\"eighty\")\n n = 0\n if (i == '9'):\n a.append(\"ninety\")\n n = 0\n\n\n\n\n if (i == '1'):\n a.append(\"one\")\n if (i == '2'):\n a.append(\"two\")\n if (i == '3'):\n a.append(\"three\")\n if (i == '4'):\n a.append(\"four\")\n if (i == '5'):\n a.append(\"five\")\n if (i == '6'):\n a.append(\"six\")\n if (i == '7'):\n a.append(\"seven\")\n if (i == '8'):\n a.append(\"eight\")\n if (i == '9'):\n a.append(\"nine\")\n\n if( len(a) >1):\n print a[0]+'-'+a[1]\n else:\n print a[0]\n\n\ntravis()\n\n\n\n\n\n\n"}, {"source_code": "\nn=int(input())\ntest={0:'zero',1:'one',2:'two',3:'three',4:'foor',5:'five',6:'six',\n 7:'seven',8:'eight',9:'nine',10:'ten',11:'eleven',12:'twelve',13:'thirteen',14:'fourteen',\n 15:'fifteen',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen'}\n\nfir={2:'twenty',3:'thirty',4:'forty',5:'fifty',6:'sixty',7:'seventy',8:'eighty',9:'ninety'}\n\n\n\n\nif n in test:\n print(test[n])\nelse:\n f=n//10\n if n%10!=0:\n print(fir[f]+'-'+test[n%10])\n else:\n print(fir[f])\n"}, {"source_code": "#!/usr/bin/python3\n# -*- coding: <utf-8> -*-\n\nimport itertools as ittls\nfrom collections import Counter\n\nimport string\n\n\ndef sqr(x):\n return x*x\n\ndef inputarray(func = int):\n return map(func, input().split())\n\n# -------------------------------\n# -------------------------------\n\nN = int(input())\n\ndigit = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\nteens = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\n\nif N <= 9:\n print(digit[N])\nelif N <= 20:\n secondteen = [\"ten\", \"eleven\", \"twelve\",\n \"thirteen\", \"fourteen\", \"fifteen\",\n \"sixteen\", \"seveteen\", \"eighteen\",\n \"nineteen\", \"twenty\"]\n print(secondteen[N - 10])\nelse:\n x, y = divmod(N, 10)\n if y != 0:\n print(teens[x - 2] + '-' + digit[y])\n else:\n print(teens[x - 2])\n"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/535/A\n\nn = int(input())\n\ns = \"\"\n\nif n == 0:\n s = \"zero\"\nelif n // 10 == 1:\n if n % 10 == 0:\n s = \"ten\"\n elif n % 10 == 1:\n s = \"eleven\"\n elif n % 10 == 2:\n s = \"twelve\"\n elif n % 10 == 3:\n s = \"thirty\"\n elif n % 10 == 4:\n s = \"fourteen\"\n elif n % 10 == 5:\n s = \"fifteen\"\n elif n % 10 == 6:\n s = \"sixteen\"\n elif n % 10 == 7:\n s = \"seventeen\"\n elif n % 10 == 8:\n s = \"eighteen\"\n elif n % 10 == 9:\n s = \"nineteen\"\n print(s)\n quit()\nelif n // 10 > 1:\n if n // 10 == 9:\n s = \"ninety\"\n elif n // 10 == 8:\n s = \"eighty\"\n elif n // 10 == 7:\n s = \"seventy\"\n elif n // 10 == 6:\n s = \"sixty\"\n elif n // 10 == 5:\n s = \"fifty\"\n elif n // 10 == 4:\n s = \"forty\"\n elif n // 10 == 3:\n s = \"thirty\"\n elif n // 10 == 2:\n s = \"twenty\"\nif n % 10 != 0:\n if n % 10 == 9:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"nine\"\n elif n % 10 == 8:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"eight\"\n elif n % 10 == 7:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"seven\"\n elif n % 10 == 6:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"six\"\n elif n % 10 == 5:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"five\"\n elif n % 10 == 4:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"four\"\n elif n % 10 == 3:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"three\"\n elif n % 10 == 2:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"two\"\n elif n % 10 == 1:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"one\"\n \nprint(s)"}, {"source_code": "n=int(input())\nones=[\"\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ntens=[\"\",\"\",\"twenty\",\"thirty\",\"fourty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\nif n<=19:\n print(ones[n])\nelse:\n k=n%10\n k1=n//10\n if k==0:\n print(tens[k1])\n else:\n print(tens[k1]+\"-\"+ones[k])\n "}, {"source_code": "\"\"\"\nTavas and Nafas\ncodeforces.com\n\"\"\"\n\nunits = {\n '1': 'one',\n '2': 'two',\n '3': 'three',\n '4': 'four',\n '5': 'five',\n '6': 'six',\n '7': 'seven',\n '8': 'eight',\n '9': 'nine'\n}\n\ndecimals = {\n '10': 'ten',\n '11': 'eleven',\n '12': 'twelve',\n '13': 'thirteen',\n '14': 'fourteen',\n '15': 'fifteen',\n '16': 'sixteen',\n '17': 'seventeen',\n '18': 'eighteen',\n '19': 'nineteen',\n '2': 'twenty-',\n '3': 'thirty-',\n '4': 'fourty-',\n '5': 'fifty-',\n '6': 'sixty-',\n '7': 'seventy-',\n '8': 'eighty-',\n '9': 'ninety-',\n '20': 'twenty',\n '30': 'thirty',\n '40': 'fourty',\n '50': 'fifty',\n '60': 'sixty',\n '70': 'seventy',\n '80': 'eighty',\n '90': 'ninety'\n}\n\nn = str(input())\nif len(n) == 2: \n print (decimals[n] if n[0] == '1' or n[1] == '0' else decimals[n[0]]+units[n[1]])\nelse:\n print (units[n])"}, {"source_code": "def single(num:int) -> str:\n if num == 1:\n return 'one'\n if num == 2:\n return 'two'\n if num == 3:\n return 'three'\n if num == 4:\n return 'four'\n if num == 5:\n return 'five'\n if num == 6:\n return 'six'\n if num == 7:\n return 'seven'\n if num == 8:\n return 'eight'\n if num == 9:\n return 'nine'\n\ndef decade(num:int) -> str:\n if num == 2:\n return 'twenty'\n if num == 3:\n return 'thirty'\n if num == 4:\n return 'forty'\n if num == 5:\n return 'fifty'\n if num == 6:\n return 'sixty'\n if num == 7:\n return 'seventy'\n if num == 8:\n return 'eighty'\n if num == 9:\n return 'ninety'\n\nscore = int(input())\nif score == 0:\n print('zero')\nelif score == 10:\n print('ten')\nelif score == 11:\n print('eleven')\nelif score == 12:\n print('twelve')\nelif score == 13:\n print('thirteen')\nelif score == 14:\n print('fourteen')\nelif score == 15:\n print('fifteen')\nelif score == 16:\n print('sixteen')\nelif score == 17:\n print('senventeen')\nelif score == 18:\n print('eighteen')\nelif score == 19:\n print('nineteen')\nelif score%10 == 0:\n print(decade(score//10))\nelif score<10:\n print(single(score))\nelse:\n print(decade(score//10)+'-'+single(score%10))\n"}, {"source_code": "n=input()\nl=[]\nf=[]\nd={'1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine','10':'ten','20':'twenty','30':'thirty','40':'forty','50':'fifty','60':'sixty','70':'seventy','80':'eighty','90':'ninety'}\nd1={'11':'eleven','12':'twelve','13':'thirteen','14':'fourteen','15':'fifteen','16':'sixteen','17':'seventeen','18':'eighteen','19':'nineteen','10':'ten','20':'twenty','30':'thirty','40':'forty','50':'fifty','60':'sixty','70':'seventy','80':'eighty','90':'ninety'}\nfor i in range(len(n)):\n l.append(int(n[i])*(10**(len(n)-i-1)))\nfor j in range(len(l)):\n f.append(d.get(str(l[j])))\n\nif (11<=int(n)<=19) or (int(n)%10==0):\n print(d1.get(n))\nelse:\n e=\"-\".join(i for i in f)\n print(e)\n"}, {"source_code": "n = int(input())\nd = {1:['ten',\n 'eleven',\n 'twelve',\n 'thirteen',\n 'fourteen',\n 'fifteen',\n 'sixteen',\n 'seventeen',\n 'eighteen',\n 'nineteen',],\n 2:'twenty',\n 3:'thirty',\n 4:'forty',\n 5:'fifty',\n 6:'sixty',\n 7:'seventy',\n 8:'eighty',\n 9:'ninety'}\nf = ['zero',\n 'one',\n 'two',\n 'three',\n 'four',\n 'five',\n 'six',\n 'seven',\n 'eigth',\n 'nine']\nif n // 10 == 0:\n print(f[n])\nelif n // 10 == 1:\n print(d[1][n%10])\nelse:\n s = d[n//10];\n if n%10 != 0:\n s = s +'-'+ f[n%10]\n print(s)\n"}, {"source_code": "n=int(raw_input())\n\ntens = {\n 1: 'ten',\n 2: 'twenty',\n 3: 'thirty',\n 4: 'fourty',\n 5: 'fifty',\n 6: 'sixty',\n 7: 'seventy',\n 8: 'eighty',\n 9: 'ninety',\n}\n\nteens = {\n 10: 'ten',\n 11: 'eleven',\n 12: 'twelve',\n 13: 'thirteen',\n 14: 'fourteen',\n 15: 'fifteen',\n 16: 'sixteen',\n 17: 'seventeen',\n 18: 'eighteen',\n 19: 'nineteen',\n}\n\nones = {\n 1: 'one',\n 2: 'two',\n 3: 'three',\n 4: 'four',\n 5: 'five',\n 6: 'six',\n 7: 'seven',\n 8: 'eight',\n 9: 'nine',\n}\n\nif n == 0:\n print 'zero'\nelif n % 10 == 0:\n print tens[n / 10] \nelif n < 10:\n print ones[n]\nelif 10 <= n < 20:\n print teens[n]\nelse:\n print (tens[n / 10] + '-' + ones[n%10])\n"}, {"source_code": "n = input()\na = (\"\", \"\", \"twenty\", \"thirty\", \"fourty\", \"fifty\",\n \"sixty\", \"seventy\", \"eighty\", \"ninety\")\nb = (\"\", \"one\", \"two\", \"three\", \"four\",\n \"five\", \"six\", \"seven\", \"eight\", \"nine\",\n \"ten\", \"eleven\", \"twelve\", \"thirteen\",\n \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\",\n \"eighteen\", \"nineteen\")\nans = \"\"\nif n > 19:\n ans = a[n / 10]\n if n % 10 != 0 and n > 19:\n ans += \"-\"\n ans += b[n % 10]\nelse:\n ans = b[n]\nprint ans\n"}, {"source_code": "FIRST_TEN = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\",\"eight\", \"nine\"]\nSECOND_TEN = [\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\",\"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\nOTHER_TENS = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\",\"eighty\", \"ninety\"]\nHUNDRED = \"hundred\"\n\ns = int(input())\nspace = \"-\"\ndef checkio(number):\n l = len(str(number))\n k = 10 ** (l-1)\n if number == 0:\n return \"zero\" \n if l == 0:\n return \"\"\n elif l == 1:\n return FIRST_TEN[number-1]\n elif l == 2:\n if number >=10 and number < 20:\n return SECOND_TEN[number-10]\n else:\n a = number // k - 2\n s = space if number%k > 0 else \"\"\n return OTHER_TENS[a] + s + checkio(number%k)\n elif l == 3:\n a = number // k # first number\n s = space if number%k > 0 else \"\"\n return FIRST_TEN[a-1] + space + HUNDRED + s + checkio(number%k)\n\n\n\nprint(checkio(s))"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/535/A\n\nn = int(input())\n\ns = \"\"\n\nif n == 0:\n s = \"zero\"\nelif n // 10 == 1:\n if n % 10 == 0:\n s = \"ten\"\n elif n % 10 == 1:\n s = \"eleven\"\n elif n % 10 == 2:\n s = \"twelve\"\n elif n % 10 == 3:\n s = \"thirty\"\n elif n % 10 == 4:\n s = \"fourteen\"\n elif n % 10 == 5:\n s = \"fifteen\"\n elif n % 10 == 6:\n s = \"sixteen\"\n elif n % 10 == 7:\n s = \"seventeen\"\n elif n % 10 == 8:\n s = \"eighteen\"\n elif n % 10 == 9:\n s = \"nineteen\"\n print(s)\n quit()\nelif n // 10 > 1:\n if n // 10 == 9:\n s = \"ninety\"\n elif n // 10 == 8:\n s = \"eighty\"\n elif n // 10 == 7:\n s = \"seventy\"\n elif n // 10 == 6:\n s = \"sixty\"\n elif n // 10 == 5:\n s = \"fifty\"\n elif n // 10 == 4:\n s = \"forty\"\n elif n // 10 == 3:\n s = \"thirty\"\n elif n // 10 == 2:\n s = \"twenty\"\nif n % 10 != 0:\n if n % 10 == 9:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"nine\"\n elif n % 10 == 8:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"eight\"\n elif n % 10 == 7:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"seven\"\n elif n % 10 == 6:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"six\"\n elif n % 10 == 5:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"five\"\n elif n % 10 == 4:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"four\"\n elif n % 10 == 3:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"three\"\n elif n % 10 == 2:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"two\"\n elif n % 10 == 1:\n s = s + (\"-\" if len(s) > 0 else \"\") + \"one\"\n \nprint(s)"}, {"source_code": "n = int(input())\n\nunit = n%10\ndec = n//10\n\ndec_s = \"\"\nunit_s = \"\"\n\n_dec = {2: \"twenty\", 3: \"thirty\", 4:\"forty\", 5: \"fifty\", 6: \"sixty\", 7: \"seventy\", 8: \"eighty\", 9: \"ninety\"}\n_unit = {1: \"one\", 2: \"two\", 3: \"three\", 4: \"four\", 5:\"five\", 6: \"six\", 7: \"seven\", 8: \"eight\", 9: \"nine\"}\n\nif dec == 1:\n\t_decenas = {10:\"ten\",11:\"eleven\",12:\"twelve\",13:\"thirteen\",14:\"fourteen\",15:\"fifteen\",16:\"sixteen\",17:\"seventeen\",18:\"eighteen\",19:\"nineteen\"}\n\tprint(_decenas[n])\n\nif dec >= 2:\n\tprint(_dec[dec]+\"-\"+_unit[unit])\n\n"}, {"source_code": "#!/usr/bin/env\n\nlast_digit = [\n \"zero\",\n \"one\",\n \"two\",\n \"three\",\n \"four\",\n \"five\",\n \"six\",\n \"seven\",\n \"eight\",\n \"nine\"\n ]\nsecond_digit = [\n \"twenty\",\n \"thirty\",\n \"forty\",\n \"fifth\",\n \"sixty\",\n \"seventy\",\n \"eighty\",\n \"ninety\"\n ]\n\ntens = [\n \"ten\",\n \"eleven\",\n \"twelves\",\n \"thirteen\",\n \"forteen\",\n \"fifteen\",\n \"sixteen\",\n \"seventeen\",\n \"eighteen\",\n \"nineteen\"\n ]\n\ndef read_score(x):\n if len(x) == 1:\n return last_digit[int(x)]\n elif x[0] > \"1\":\n if x[1] == \"0\":\n return second_digit[int(x[0]) - 2]\n else:\n return \"-\".join([\n second_digit[int(x[0]) - 2],\n last_digit[int(x[1])]\n ])\n else:\n return tens[int(x) - 10]\n\nscore = input()\nprint(read_score(score))\n"}, {"source_code": "num=input()\ndd={'1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine',\n '10':'ten','11':'eleven','12':'twelve','13':'thirteen','14':'fourteen','15':'fifteen',\n '16':'sixteen','17':'seventeen','18':'eighteen','19':'nineteen'}\nout=''\nif len(num)==2:\n a=num[0]\n b=num[1]\n if a=='2':\n out+='twenty'\n elif a=='3':\n out+='thirty'\n elif a=='1':\n out+=dd[num]\n print(out)\n exit()\n else:\n out+=dd[a]+'ty'\n if b=='0':\n pass\n else:\n out+='-'+dd[b]\nif len(num)==1:\n out+=dd[num]\nprint(out)\n \n"}, {"source_code": "a=int(input())\nprint(['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty-one', 'twenty-two', 'twenty-three', 'twenty-four', 'twenty-five', 'twenty-six', 'twenty-seven', 'twenty-eight', 'twenty-nine', 'thirty', 'thirty-one', 'thirty-two', 'thirty-three', 'thirty-four', 'thirty-five', 'thirty-six', 'thirty-seven', 'thirty-eight', 'thirty-nine', 'forty', 'forty- one', 'forty-two', 'forty-three', 'forty-four', 'forty-five', 'forty-six', 'forty-seven', 'forty-eight', 'forty-nine', ' fifty', 'fifty-one', 'fifty-two', 'fifty-three', 'fifty-four', 'fifty-five', 'fifty-six', 'fifty-seven', 'fifty-eight', ' fifty-nine', 'sixty', 'sixty-one', 'sixty-two', 'sixty-three', 'sixty-four', 'sixty-five', 'sixty-six', 'sixty-seven', 'sixty-eight', 'sixty-nine', 'seventy', 'seventy-one', 'seventy-two', 'seventy-three', 'seventy-four', 'seventy-five', 'seventy-six', 'seventy-seven', 'seventy-eight', 'seventy-nine', 'eighty', 'eighty-one', 'eighty-two', 'eighty-three', 'eighty-four', 'eighty-five', 'eighty-six', 'eighty-seven', 'eighty-eight', 'eighty-nine', 'ninety', 'ninety-one', 'ninety-two' , 'ninety-three', 'ninety-four', 'ninety-five', 'ninety-six', 'ninety-seven', 'ninety-eight', 'ninety-nine'][a])"}, {"source_code": "#!/usr/bin/python3\n# -*- coding: <utf-8> -*-\n\nimport itertools as ittls\nfrom collections import Counter\n\nimport string\n\n\ndef sqr(x):\n return x*x\n\ndef inputarray(func = int):\n return map(func, input().split())\n\n# -------------------------------\n# -------------------------------\n\nN = int(input())\n\ndigit = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\nteens = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\n\nif N <= 9:\n print(digit[N])\nelif N <= 20:\n secondteen = [\"ten\", \"eleven\", \"twelve\",\n \"thirteen\", \"fourteen\", \"fifteen\",\n \"sixteen\", \"seveteen\", \"eighteen\",\n \"nineteen\", \"twenty\"]\n print(secondteen[N - 10])\nelse:\n x, y = divmod(N, 10)\n if y != 0:\n print(teens[x - 2] + '-' + digit[y])\n else:\n print(teens[x - 2])\n"}, {"source_code": "n = int(input())\nsmall = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\nbig = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\nif n == 0:\n print('zero')\n exit()\nprint(big[n // 10], end='')\nif n % 10 != 0 and n >= 10:\n print('-', end='')\nprint(small[n % 10])"}, {"source_code": "s = int(input())\nif(s>=20):\n num = s//10\n if num == 2:\n print(\"twenty\",end=\"\")\n elif num == 3:\n print(\"thirty\",end=\"\")\n elif num == 4:\n print(\"forty\",end=\"\")\n elif num == 5:\n print(\"fifty\",end=\"\")\n elif num == 6:\n print(\"sixty\",end=\"\")\n elif num == 7:\n print(\"seventy\",end=\"\")\n elif num == 8:\n print(\"eighty\",end=\"\")\n elif num == 9:\n print(\"ninety\",end=\"\")\nif(s>=20 and s%10!=0):\n print(\"-\",end=\"\")\nif s == 10:\n print(\"ten\",end=\"\")\nif s == 11:\n print(\"eleven\",end=\"\")\nif s == 12:\n print(\"twelve\",end=\"\")\nif s == 13:\n print(\"thirteen\",end=\"\")\nif s == 14:\n print(\"fourteen\",end=\"\")\nif s == 15:\n print(\"fifteen\",end=\"\")\nif s == 16:\n print(\"sixteen\",end=\"\")\nif s == 17:\n print(\"seventeen\",end=\"\")\nif s == 18:\n print(\"eighteen\",end=\"\")\nif s == 19:\n print(\"nineteen\",end=\"\")\nif s<=10 or s>=20:\n s = s%10\nif s == 1:\n print(\"one\",end=\"\")\nif s == 2:\n print(\"two\",end=\"\")\nif s == 3:\n print(\"three\",end=\"\")\nif s == 4:\n print(\"four\",end=\"\")\nif s == 5:\n print(\"five\",end=\"\")\nif s == 6:\n print(\"six\",end=\"\")\nif s == 7:\n print(\"seven\",end=\"\")\nif s == 8:\n print(\"eight\",end=\"\")\nif s == 9:\n print(\"nine\",end=\"\")"}, {"source_code": "#!/usr/bin/env\n\nlast_digit = [\n \"zero\",\n \"one\",\n \"two\",\n \"three\",\n \"four\",\n \"five\",\n \"six\",\n \"seven\",\n \"eight\",\n \"nine\"\n ]\nsecond_digit = [\n \"twenty\",\n \"thirty\",\n \"fourty\",\n \"fifth\",\n \"sixty\",\n \"seventy\",\n \"eighty\",\n \"ninety\"\n ]\n\ntens = [\n \"ten\",\n \"eleven\",\n \"twelves\",\n \"thirteen\",\n \"fourteen\",\n \"fifteen\",\n \"sixteen\",\n \"seventeen\",\n \"eighteen\",\n \"nineteen\"\n ]\n\ndef read_score(x):\n if len(x) == 1:\n return last_digit[int(x)]\n elif x[0] > \"1\":\n if x[1] == \"0\":\n return second_digit[int(x[0]) - 2]\n else:\n return \"-\".join([\n second_digit[int(x[0]) - 2],\n last_digit[int(x[1])]\n ])\n else:\n return tens[int(x) - 10]\n\nscore = input()\nprint(read_score(score))\n"}, {"source_code": "dic={}\ndic[1]=\"one\"\ndic[2]=\"two\"\ndic[3]=\"three\"\ndic[4]=\"four\"\ndic[5]=\"five\"\ndic[6]=\"six\"\ndic[7]=\"seven\"\ndic[8]=\"eight\"\ndic[9]=\"nine\"\ndic[0]=\"zero\"\ndic[10]=\"ten\"\ndic[20]=\"twenty\"\ndic[30]=\"thirty\"\ndic[40]=\"fourty\"\ndic[50]=\"fifty\"\ndic[60]=\"sixty\"\ndic[70]=\"seventy\"\ndic[80]=\"eighty\"\ndic[90]=\"ninety\"\ndic[11]=\"eleven\"\ndic[12]=\"twelve\"\ndic[13]=\"thirteen\"\ndic[14]=\"fourteen\"\ndic[15]=\"fifteen\"\ndic[16]=\"sixteen\"\ndic[17]=\"seventeen\"\ndic[18]=\"eighteen\"\ndic[19]=\"nineteen\"\nn=input()\nif n<=20:\n\tprint dic[n]\nelse:\n\tif n%10==0:\n\t\tprint dic[n]\n\telse:\n\t\tstring = dic[n-n%10]+'-'+dic[n%10]\n\t\tprint string\n\t\t\n\t\n"}, {"source_code": "Num1 = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nNum2 = ['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n\nn=raw_input()\nif int(n) < 20:\n print Num1[int(n)]\nelse:\n print '%s-%s' %(Num2[int(n[0])-2],Num1[int(n[1])])"}, {"source_code": "import math\n\nnumber = int(input())\n\nnumber_list = [\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"]\nteen_list = [\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ndecades_list =[\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\n\n\nif number <= 9:\n print(number_list[number])\nelif number >= 10 and number <= 19:\n tens = number % 10\n print(teen_list[tens])\nelif number > 19 and number <= 99:\n ones = math.floor(number/10)\n twos = ones - 2\n tens = number % 10\n if tens == 0:\n print(decades_list[twos])\n elif tens != 0:\n print(decades_list[twos] + \" \" + number_list[tens])\n"}, {"source_code": "s = int(input())\nones = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\nteens = [\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\ntens = [\"\", \"\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\n\nif s < 10:\n print(ones[s])\nelif s < 20:\n print(teens[10 - s])\nelif s < 100:\n print(tens[s // 10]) if s % 10 == 0 else print(tens[s // 10] + \"-\" + ones[s % 10])\n"}, {"source_code": "s = input()\na = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nif int(s) == 0:\n print('zero')\nelif int(s) < 20:\n print(a[int(s)-1])\nelif int(s) >= 80 and int(s) < 90:\n print('eighty', end = '')\n if int(s) != 80:\n print('-', a[int(s[1])-1], sep = '')\nelse:\n n = int(s)\n if n > 39:\n if n % 10 == 0:\n print(a[int(s[0])-1], 'ty', sep = '')\n else:\n print(a[int(s[0]) - 1] ,'ty' , '-' , a[int(s[1])-1], sep ='')\n else:\n if n < 30:\n print('twenty', end = '')\n if n % 10 != 0:\n print('-', a[int(s[1])-1], sep = '')\n else:\n print('thirty', end = '')\n if n % 10 != 0:\n print('-', a[int(s[1])-1], sep = '')"}, {"source_code": "n = input()\ncool = ['zero','one','two','three','four','five','six','seven','eight','nine']\ncool2 = [',','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nfirst = n%100/10\nsecond = n%10\nif first == 0:\n print cool[second]\nelif first == 1:\n if n == 11:\n print \"eleven\"\n elif n == 12:\n print \"twelve\"\n elif n == 13:\n print \"thirteen\"\n elif n == 14:\n print \"fourteen\"\n elif n ==15:\n print \"fifteen\"\n elif n == 16:\n print \"sixteen\"\n elif n == 17:\n print \"seventeen\"\n elif n == 18:\n print \"eighteen\"\n elif n == 19:\n print \"nineteen\"\n\nelse:\n string = \"\"\n string+=cool2[first-1]\n if second != 0:\n string+='-'+cool[second]\n print string\n"}, {"source_code": "num2words1 = {0: \"zero\", 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\n 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\n 11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\n 15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', 19: 'Nineteen'}\nnum2words2 = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']\n\ndef number(Number):\n if 0 <= Number < 19:\n return num2words1[Number]\n elif 20 <= Number <= 99:\n tens, below_ten = divmod(Number, 10)\n return num2words2[tens - 2] + '-' + num2words1[below_ten]\n else:\n print(\"Number out of range\")\n\na = number(int(input())).lower()\nif a[-1] == '-':\n print(a[:-1])\nelse:\n print(a)\n"}, {"source_code": "t = [int(i) for i in input().split()][0]\na = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']\na += ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eightteen', 'nineteen', 'twenty']\nfor i in range(21,100):\n if i // 10 == 2:\n cur = 'twenty'\n elif i // 10 == 3:\n cur = 'thirty'\n elif i // 10 == 4:\n cur = 'fourty'\n elif i // 10 == 5:\n cur = 'fifty'\n elif i // 10 == 6:\n cur = 'sixty'\n elif i // 10 == 7:\n cur = 'seventy'\n elif i // 10 == 8:\n cur = 'eighty'\n elif i // 10 == 9:\n cur = 'ninety'\n if i % 10 == 0:\n a.append(cur)\n elif i % 10 == 1:\n a.append(cur + '-one')\n elif i % 10 == 2:\n a.append(cur + '-two')\n elif i % 10 == 3:\n a.append(cur + '-three')\n elif i % 10 == 4:\n a.append(cur + '-four')\n elif i % 10 == 5:\n a.append(cur + '-five')\n elif i % 10 == 6:\n a.append(cur + '-six')\n elif i % 10 == 7:\n a.append(cur + '-seven')\n elif i % 10 == 8:\n a.append(cur + '-eight')\n elif i % 10 == 9:\n a.append(cur + '-nine')\nprint (a[t])"}, {"source_code": "n = input()\n\na = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nb = ['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n\nif n == 0:\n print a[0]\nelif n <= 19:\n print a[n]\nelse:\n print b[n/10]+'-'+a[n%10]\n"}, {"source_code": "n = int(input())\nlst = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'eighteen', 'nineteen']\nlst2 = ['', 'one', 'twen', 'thir', 'for', 'fif', 'six', 'seven', 'eight', 'nine']\nif n < 20:\n print(lst[n])\nelse:\n print(lst2[n//10]+'ty-'+lst[n%10])\n"}, {"source_code": "def digit(n):\n\tdigits = dict()\n\tdigits[1]=('one',)\n\tdigits[2]=('two','twen')\n\tdigits[3]=('three','thir')\n\tdigits[4]=('four','four')\n\tdigits[5]=('five','fif')\n\tdigits[6]=('six','six')\n\tdigits[7]=('seven','seven')\n\tdigits[8]=('eight','eigh')\n\tdigits[9]=('nine','nine')\n\tdigits[10]=('ten',)\n\tdigits[11]=('eleven',)\n\tdigits[12]=('twelve',)\n\n\tif n <= 12:\n\t\treturn str(digits[n][0])\n\telse:\n\t\tn1 = n/10\n\t\tn2 = n%10\n\t\tif n1 < 2:\n\t\t\treturn str(digits[n2][1]) + 'teen'\n\t\telif n2 < 1:\n\t\t\treturn str(digits[n1][1]) + 'ty'\n\t\telse:\n\t\t\treturn str(digits[n1][1]) + 'ty-' + str(digits[n2][0]) \n\nn = int(raw_input())\nprint digit(n)\n"}, {"source_code": "'''a = input()\nb = input()\n\n#dp = [[-1 for i in range(len(a)+1)] for j in range(len(b+1))]\n'''\na = \"zero one two three four five six seven eight nine ten\".split()\nb = \"ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen\".split()\nc = \"a a twenty thirty forty fifty sixty seventy eighty ninety\".split()\n\nn = int(input())\n\nif n<=10:\n\tprint(a[n])\nelif n<20:\n\tprint(b[n-10])\nelif n%10 == 0:\n\tprint(c[n//10])\nelse:\n\tprint(c[n%10] + \"-\" + a[n//10])"}, {"source_code": "s=int(raw_input(\"enter the number.(0-99):\",))\nzhenshu=(\"ten\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\n \"ninety\")\nxiaodeshu=(\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\n \"six\",\"seven\",\"eight\",\"nine\")\nif s>99:\n print \"you have entered a wrong number\"\nelse:\n if s%10==0 and s>=10:\n print zhenshu[s/10-1]\n elif s<10:\n print xiaodeshu[s-1]\n else:\n print zhenshu[int(s/10)-1]+\"-\"+xiaodeshu[s%10]\n"}, {"source_code": "teens = {11:\"eleven\", 12:\"tweleve\", 13:\"thirteen\", 14:\"fourteen\",\n 15:\"fifteen\", 16:\"sixteen\", 17:\"seventeen\", 18:\"eighteen\",\n 19:\"nineteen\"}\ntens = {10:\"ten\", 20:\"twenty\", 30:\"thirty\", 40:\"forty\", 50:\"fifty\",\n 60:\"sixty\", 70:\"seventy\", 80:\"eighty\", 90:\"ninety\"}\n\nones = {1:\"one\", 2:\"two\", 3:\"three\", 4:\"four\", 5:\"five\",\n 6:\"six\", 7:\"seven\", 8:\"eight\", 9:\"nine\"}\n\nn = int(raw_input())\nif (n == 0):\n print \"zero\"\nelif (n < 10):\n print ones[n]\nelif (n > 10 and n < 20):\n print teens[n]\nelif n == 10:\n print \"ten\"\nelse:\n if (n % 10 == 0):\n print tens[n - n % 10]\n else:\n print tens[n - n % 10] + \"-\" + ones[n % 10]\n "}, {"source_code": "n = int(input())\ndigits = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\nif n < 10:\n number = digits[n]\nelif n < 20:\n number = digits[n - 10] + \"teen\"\n if n == 10:\n number = \"ten\"\n elif n == 11:\n number = \"eleven\"\n elif n == 12:\n number = \"twelve\"\n elif n == 13:\n number = number.replace(\"three\", \"thir\")\n elif n == 15:\n number = number.replace(\"five\", \"fif\")\nelse:\n a = n // 10\n number = digits[a] + \"ty\"\n if 30 > n >= 20:\n number = number.replace(\"two\", \"twen\")\n elif 40 > n >= 30:\n number = number.replace(\"three\", \"thir\")\n elif 50 > n >= 40:\n number = number.replace(\"u\", \"\")\n elif 60 > n >= 50:\n number = number.replace(\"five\", \"fif\")\n elif 90 > n >= 80:\n number = number.replace(\"tt\", \"t\")\n number += \"-\" + digits[n - 10 * a]\n if n % 10 == 0:\n number = number.replace(\"-\", \"\")\n number = number.replace(\"zero\", \"\")\nprint(number)"}, {"source_code": "s=int(raw_input(\"enter the number.(0-99):\",))\nzhenshu=(\"ten\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\n \"ninety\")\nxiaodeshu=(\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\n \"six\",\"seven\",\"eight\",\"nine\")\nif s>99:\n print \"you have entered a wrong number\"\nelse:\n if s%10==0 and s>=10:\n print zhenshu[s/10-1]\n elif s<10:\n print xiaodeshu[s-1]\n else:\n print zhenshu[int(s/10)-1]+\"-\"+xiaodeshu[s%10]\n"}, {"source_code": "# your code goes here\nt=raw_input()\ndi={\"2\":\"twenty\",\"3\":\"thirty\",\"4\":\"forty\",\"5\":\"fifty\",\"6\":\"sixty\",\"7\":\"seventy\",\"8\":\"eighty\",\"9\":\"ninety\"}\ndi1={\"1\":\"one\",\"2\":\"two\",\"3\":\"three\",\"4\":\"four\",\"5\":\"five\",\"6\":\"six\",\"7\":\"seven\",\"8\":\"eight\",\"9\":\"nine\",\"0\":\"zero\"}\ndi2={\"10\":\"ten\",\"11\":\"eleven\",\"12\":\"twelve\",\"13\":\"thirteen\",\"14\":\"fourteen\",\"15\":\"fifteen\",\"16\":\"sixteen\",\"17\":\"seventeen\",\"18\":\"eighteen\",\"19\":\"nineteen\"}\n\nif len(t)==1:\n print di1[t[0]]\n\nif int(t[0])>=2 and len(t)>1:\n print di[t[0]]+\"-\"+di1[t[1]] \n\nif int(t[0])==1 and len(t)>1:\n for key in di2.keys():\n if t==key:\n print di2[key]\n\n \n"}, {"source_code": "n=int(input())\nones=[\"\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ntens=[\"\",\"\",\"twenty\",\"thirty\",\"fourty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\nif n<=19:\n print(ones[n])\nelse:\n k=n%10\n k1=n//10\n print(tens[k1]+\"-\"+ones[k])\n "}, {"source_code": "a = {\n\t\t0:'',\n\t\t1:'one',\n\t\t2:'two',\n\t\t3:'three',\n\t\t4:'four',\n\t\t5:'five',\n\t\t6:'six',\n\t\t7:'seven',\n\t\t8:'eight',\n\t\t9:'nine',\n\t\t10:'ten',\n\t\t11:'eleven',\n\t\t12:'twelve',\n\t\t13:'thirteen',\n\t\t14:'fourteen',\n\t\t15:'fifteen',\n\t\t16:'sixteen',\n\t\t17:'seventeen',\n\t\t18:'eighteen',\n\t\t19:'ninteen'\n\t\t}\nb = {\n\t\t2:'twenty',\n\t\t3:'thirty',\n\t\t4:'forty',\n\t\t5:'fifty',\n\t\t6:'sixty',\n\t\t7:'seventy',\n\t\t8:'eighty',\n\t\t9:'ninety'\n\t}\nn = int(raw_input())\nif(n==0):\n\tprint 'zero'\nelif(n<20):\n\tprint a[n]\nelse:\n\tx = n/10\n\ty = n%10\n\tif not(y==0):\n\t\tprint b[x]+\"-\"+a[y]\n\telse:\n\t\tprint b[x]\n\t\n"}, {"source_code": "s=['one','two','three','four','five','six','seven','eight','nine']\ns2=['twenty','thirty','fourty','fifty','sixty','seventy','eighty','ninety']\nans=\"\"\nn=input()\nif n==0:\n print 'zero'\nelif(n<10):\n print s[n-1]\nelif n==10:\n print 'ten'\nelif(n==11):\n print 'eleven'\nelif n==12:\n print 'twelve'\nelif n==13:\n print 'thirteen'\nelif n==14:\n print 'fourteen'\nelif n==15:\n print 'fifteen'\nelif n==16:\n print 'sixteen'\nelif n==17:\n print 'seventeen'\nelif n==18:\n print 'eighteen'\nelif n==19:\n print 'ninghteen'\nelif n==20:\n print 'twenty'\nelif n%10==0:\n print s2[n/10-2]\nelse:\n ans=s2[(n-n%10)/10-2]+'-'+s[n%10-1]\n print ans.strip()\n \n"}, {"source_code": "s=int(input())\na = ['','one','two','three','four','five','six','seven','eight','nine']\nb = ['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nif s == 0: print('zero')\nelif s == 10 : print('ten')\nelif s == 11: print('eleven')\nelif s == 12: print('twelve')\nelif s == 13: print('thirteen')\nelif s == 14: print('fourteen')\nelif s == 15: print('fifteen')\nelif s == 16: print('sixteen')\nelif s == 17: print('seventeen')\nelif s == 18: print('eighteen')\nelif s == 19: print('nineteen')\nelif s%10 == 0: print(b[s//10-2])\nelse: print(b[s//10-2]+'-'+a[s%10])\n"}, {"source_code": "###Codeforces problem 456A###\n\ns = map(int, raw_input())\n\na2 = ['', '', 'twenty', 'thirty', 'fourty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\na1 = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\na10 = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nif len(s) == 1:\n print a1[s[0]]\nelse:\n if s[0] == 1:\n print a10[s[1]]\n elif s[1] == 0:\n print a2[s[0]]\n else:\n print a2[s[0]] + '-' + a1[s[1]]\n \n"}, {"source_code": "arr=['zero','one','two', 'three','four' ,'five','six','seven' ,'eight' ,'nine','ten']\nar=['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\nn = int(input())\nif n<=0 and n<=10:\n print(arr[n])\nelse:\n if n%10==0:\n print(ar[n//10 -2])\n else:\n print(ar[n//10-2]+'-'+arr[n%10]) "}, {"source_code": "k = int(input())\nones = k % 10\ntens = int(k / 10)\n\n_first = {\n 1: 'ten',\n 2: 'twenty',\n 3: 'thirty',\n 4: 'fourty',\n 5: 'fifty',\n 6: 'sixty',\n 7: 'seventy',\n 8: 'eighty',\n 9: 'ninety'\n}\n\n_second = {\n 0: 'zero',\n 1: 'one',\n 2: 'two',\n 3: 'three',\n 4: 'four',\n 5: 'five',\n 6: 'six',\n 7: 'seven',\n 8: 'eight',\n 9: 'nine'\n}\n\nif (tens == 1):\n if(k == 11):\n print(\"eleven\")\n elif(k == 12):\n print(\"twelve\")\n elif(k == 13):\n print(\"thirteen\")\n elif(k == 14):\n print(\"fourteen\")\n elif(k == 15):\n print(\"fifteen\")\n elif(k == 16):\n print(\"sixteen\")\n elif(k == 17):\n print(\"seventeen\")\n elif(k == 18):\n print(\"eighteen\")\n elif(k == 19):\n print(\"nineteen\")\nelse:\n if (ones == 0 and tens !=0):\n print (_first[tens])\n if (tens == 0):\n print(_second[ones])\n if (tens!=0 and ones!= 0):\n f = _first[tens]\n s = _second[ones]\n finalString = f + \"-\" + s\n print(finalString)"}, {"source_code": "edin = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5:'five', 6:'six', 7:'seven', 8:'eight', 9:'nine'}\n\ndes = {2: \"twen\", 3: \"thir\", 4: \"four\", 5: \"fif\", 6: \"six\", 7: \"seven\", 8: \"eight\", 9: \"nine\"}\n\nn = int(input())\nif n == 0:\n print(\"zero\")\nelif 1 <= n < 10:\n print(edin[n])\nelif n == 10:\n print(\"ten\")\nelif n == 11:\n print(\"eleven\")\nelif n == 12:\n print(\"twelve\")\nelif n == 18:\n print(\"eighteen\")\nelif 13 <= n < 20:\n print(\"%steen\" % des[n % 10]) \nelse:\n print(\"%sty%s\" % (des[n // 10], \"-\" + edin[n % 10] if n % 10 != 0 else \"\"))\n"}, {"source_code": "n = input()\n\na = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']\nb = ['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']\n\nif n == 0:\n print a[0]\nelif n <= 19:\n print a[n]\nelse:\n print b[n/10]+'-'+a[n%10]\n"}, {"source_code": "s = input()\na = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\nif int(s) == 0:\n print('zero')\nelif int(s) < 20:\n print(a[int(s)-1])\nelif int(s) >= 80 and int(s) < 90:\n print('eighty', end = '')\n if int(s) != 80:\n print('-', a[int(s[1])-1], sep = '')\nelif int(s) >= 50 and int(s) < 60:\n print('fifty', end = '')\n if int(s) != 80:\n print('-', a[int(s[1])-1], sep = '')\nelif int(s) >= 40 and int(s) < 50:\n print('forty', end = '')\n if int(s) != 80:\n print('-', a[int(s[1])-1], sep = '')\nelse:\n n = int(s)\n if n > 39:\n if n % 10 == 0:\n print(a[int(s[0])-1], 'ty', sep = '')\n else:\n print(a[int(s[0]) - 1] ,'ty' , '-' , a[int(s[1])-1], sep ='')\n else:\n if n < 30:\n print('twenty', end = '')\n if n % 10 != 0:\n print('-', a[int(s[1])-1], sep = '')\n else:\n print('thirty', end = '')\n if n % 10 != 0:\n print('-', a[int(s[1])-1], sep = '')"}, {"source_code": "k = int(input())\nones = k % 10\ntens = int(k / 10)\n\n_first = {\n 1: 'ten',\n 2: 'twenty',\n 3: 'thirty',\n 4: 'fourty',\n 5: 'fifty',\n 6: 'sixty',\n 7: 'seventy',\n 8: 'eighty',\n 9: 'ninety'\n}\n\n_second = {\n 0: 'zero',\n 1: 'one',\n 2: 'two',\n 3: 'three',\n 4: 'four',\n 5: 'five',\n 6: 'six',\n 7: 'seven',\n 8: 'eight',\n 9: 'nine'\n}\n\nif (tens == 1):\n if(k == 10):\n print(\"ten\")\n elif(k == 11):\n print(\"eleven\")\n elif(k == 12):\n print(\"twelve\")\n elif(k == 13):\n print(\"thirteen\")\n elif(k == 14):\n print(\"fourteen\")\n elif(k == 15):\n print(\"fifteen\")\n elif(k == 16):\n print(\"sixteen\")\n elif(k == 17):\n print(\"seventeen\")\n elif(k == 18):\n print(\"eighteen\")\n elif(k == 19):\n print(\"nineteen\")\nelse:\n if (ones == 0 and tens !=0):\n print (_first[tens])\n if (tens == 0):\n print(_second[ones])\n if (tens!=0 and ones!= 0):\n f = _first[tens]\n s = _second[ones]\n finalString = f + \"-\" + s\n print(finalString)"}, {"source_code": "x = int(input())\n\narray = [\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\n \"eleven\",\"twelve\",\"thirteen\",\"twenty\"]\narray1 = [\"ten\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\n \"ninety\"]\n\nif x < 14 :\n print(array[x-1])\nelif x == 20:\n print(array[-1])\nelif x == 15:\n print(\"fifteen\")\nelse:\n a = x % 10\n if x >= 14 and x <= 19:\n print(array[a-1] + \"teen\")\n elif x % 10 == 0:\n print(array1[int(x/10) - 1])\n else:\n print(array1[int(x/10)-1] + '-' + array[int(x%10)-1])\n \n"}], "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7"} {"source_code": "import math\np=10**9+7\nn=int(input())\nk=int(math.log2(n))\nf=[[n//(2**i*3**j) for j in range(3)] for i in range(k+1)]\nold=[[0,0,0] for i in range(k+1)]\nold[k][0]=1\nif n>=3*2**(k-1):\n old[k-1][1]=1\nm=n//2+2\nfor i in range(2,m):\n dp=[[0,0,0] for i in range(k+1)]\n for j in range(k):\n for l in range(2):\n dp[j][l]=(old[j][l]*(f[j][l]-i+1)+old[j+1][l]*(f[j][l]-f[j+1][l])+old[j][l+1]*(f[j][l]-f[j][l+1]))%p\n old=dp\ncurr=old[0][0]\nfor i in range(1,n-m+2):\n curr*=i\n curr%=p\nprint(curr)", "positive_code": [{"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 10**9 + 7\ndef fac(x):\n i = 1\n for j in range(2 , x + 1):\n i = i * j % MOD\n return i\n\nfac = [1]\nfor i in range(1, 10**6 + 10):\n fac.append(int(fac[-1] * i % MOD))\n\nn = int(input())\ndef ways(prevg, g):\n cur = n//g - n//prevg if prevg else n//g\n left = n - n//g\n\n a = cur\n for i in range(left + 1, left + cur):\n a = a * i % MOD\n #a = fac[cur] * pow(left+1, cur - 1, MOD)\n b = +(g == 1)\n for x in 2,3:\n if g % x == 0:\n b += ways(g, g // x)\n return a * b\n\na = 1\nwhile a * 2 <= n:\n a *= 2\n\nans = ways(0, a)\nif a //2 * 3 <= n:\n ans += ways(0, a //2 * 3)\n\nprint ans % MOD\n"}, {"source_code": "def perm(a,b):\n ret = 1\n for i in range(a, a - b, -1):\n ret = (ret * i)%1000000007\n return ret\n\nnum = int(input())\nnum2 = num\nc = 0\nwhile num2:\n c += 1\n num2 >>= 1\npow2 = 1 << (c-1)\narray = [pow2]\nfor i in range(c-1):\n array.append(array[-1]>>1)\n\ndef calc(arr):\n data = []\n #sm = 0\n av = num\n for i in range(c):\n data.append((num // arr[i] - (num - av), av))\n av -= data[-1][0]\n\n\n #print(data)\n\n ans = 1\n for d in data:\n ans = (ans * (d[0] * perm(d[1] - 1, d[0] - 1)))%1000000007\n return ans\n\nanswer = calc(array)\n\nif num >= pow2 // 2 * 3:\n for i in range(1,c):\n dat = [1]\n for j in range(1, c):\n if j == i:\n dat = [3*dat[0]] + dat\n else:\n dat = [2*dat[0]] + dat\n #print(dat)\n a = calc(dat)\n answer += a\n\nprint(answer%1000000007)\n\n"}, {"source_code": "def binpow(x, t, mod):\n if t == 0:\n return 1\n if t % 2 == 0:\n return binpow(x * x % mod, t//2, mod)\n return binpow(x, t-1, mod) * x % mod\n\ndef calc(a, f, rv, n):\n mod = 10 ** 9 + 7\n s = 0\n ans = 1\n for i in range(len(a)-1, -1, -1):\n cur = n//a[i]\n if i > 0:\n cur -= n//a[i-1]\n t = cur-1\n s += t\n ans = ans * cur * f[s] * rv[s-t] % mod\n #print(a[i], cur, s, f[s], rv[s-t])\n s += 1\n return ans\nn = int(input())\nx = n\nc = 0\nwhile x > 1:\n x //= 2\n c+=1\nf = [1] * 1000100\nmod = 10**9 + 7\nfor i in range(1, len(f)):\n f[i] = f[i-1] * i % mod\nrv = [1] * 1000100\nrv[-1] = binpow(f[-1], mod-2, mod)\nfor i in range(len(f)-2, 0, -1):\n rv[i] = rv[i+1] * (i+1) % mod\na = []\nfor i in range(c, -1, -1):\n a.append(2**i)\nans=calc(a, f, rv, n)\nif (2**(c-1)) * 3 <= n:\n c -= 1\n a = []\n while c >= 0:\n a.append((2**c) * 3)\n b = a.copy()\n for i in range(c, -1, -1):\n b.append(2**i)\n ans = (ans + calc(b, f, rv, n)) % mod\n c -= 1\nprint(ans)"}, {"source_code": "import math\np=10**9+7\nn=int(input())\nk=int(math.log2(n))\nf=[[n//(2**i*3**j) for j in range(3)] for i in range(k+1)]\nold=[[0,0,0] for i in range(k+1)]\nold[k][0]=1\nif n>=3*2**(k-1):\n old[k-1][1]=1\nm=n//2+2\nfor i in range(2,m):\n dp=[[0,0,0] for i in range(k+1)]\n for j in range(k):\n for l in range(2):\n dp[j][l]=(old[j][l]*(f[j][l]-i+1)+old[j+1][l]*(f[j][l]-f[j+1][l])+old[j][l+1]*(f[j][l]-f[j][l+1]))%p\n old=dp\ncurr=old[0][0]\nfor i in range(1,n-m+2):\n curr*=i\n curr%=p\nprint(curr)"}, {"source_code": "p=10**9+7\nimport math\ndef r(l):\n x=1\n for m in l:\n x=x*m%p\n return x\nn=int(input())\na,k,x,t=[],int(math.log2(n)),n,0\nwhile x>0:\n a.append(x-x//2)\n x//=2\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\ny=r([i for i in range(2,n+1)])\ns=k if n<3*2**(k-1) else 0\nfor j in range(s,k+1):\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n x=y*r(e)%p\n f=r([sum(e[:i+1]) for i in range(k+1)])\n while f>1:\n x*=p//f+1\n f=f*(p//f+1)%p\n t+=x%p\nprint(t%p)"}, {"source_code": "p=10**9+7\nimport math\ndef prod(l):\n x=1\n for m in l:\n x=x*m%p\n return x\nn=int(input())\na,k,x,t=[],int(math.log2(n)),n,0\nwhile x>0:\n a.append(x-x//2)\n x//=2\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\ny=prod([i for i in range(2,n+1)])\ns=k if n<3*(2**(k-1)) else 0\nfor j in range(s,k+1):\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n x=(y*prod(e))%p\n f=prod([sum(e[:i+1]) for i in range(k+1)])\n while f>1:\n x*=p//f+1\n f=(f*(p//f+1))%p\n t+=x%p\nprint(t%p)"}, {"source_code": "p=10**9+7\nimport math\ndef r(l):\n x=1\n for m in l:\n x=x*m%p\n return x\nn=int(input())\na,k,x,t=[],int(math.log2(n)),n,0\nwhile x>0:\n a.append(x-x//2)\n x//=2\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\ny=r(i for i in range(2,n+1))\ns=k if n<3*2**(k-1) else 0\nfor j in range(s,k+1):\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n x=y*r(e)%p\n f=r(sum(e[:i+1]) for i in range(k+1))\n while f>1:\n x*=p//f+1\n f=f*(p//f+1)%p\n t+=x%p\nprint(t%p)"}, {"source_code": "p=10**9+7\nimport math\ndef prod(l):\n x=1\n for m in l:\n x*=m\n return x\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\nfacs=[1]*(n+1)\nfor i in range(2,n+1):\n facs[i]=(i*facs[i-1])%p\nstart=k if n<3*(2**(k-1)) else 0\ntot=0\nfor j in range(start,k+1):\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n x=(facs[n]*prod(e))%p\n f=prod([sum(e[:i+1]) for i in range(k+1)])\n while f>1:\n x*=p//f+1\n f=(f*(p//f+1))%p\n tot+=x%p\nprint(tot%p)"}, {"source_code": "p=10**9+7\nimport math\ndef inv(k,p):\n prod=1\n while k>1:\n prod*=(p//k+1)\n k=(k*(p//k+1))%p\n return prod%p\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\nfacs=[1]*(n+1)\nfor i in range(2,n+1):\n facs[i]=(i*facs[i-1])%p\nif n<3*(2**(k-1)):\n start=k\nelse:\n start=0\ntot=0\nfor j in range(start,k+1):\n prod=1\n for i in range(j,k):\n prod*=b[i]\n prod*=d[j]\n for i in range(j):\n prod*=a[i]\n prod%=p\n prod*=facs[n]\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n f=[sum(e[:i+1]) for i in range(k+1)]\n g=1\n for guy in f:\n g*=guy\n prod*=inv(g,p)\n prod%=p\n tot+=prod\nprint(tot%p)"}, {"source_code": "from time import*\nn=int(input())\nt=time()\np2=1\nv=0\nwhile p2*2<=n:\n p2*=2\n v+=1\nmo=10**9+7\ntr=[n//(2**k) for k in range(v+1)]\ntabn=[0]*(v+1)\ntabn[-2]=tr[-2]-1\nfor k in range(2,n):\n if tr[v-1]<k-2:\n v-=1\n tab=tabn[:]\n tabn=[0]*(v+1)\n for j in range(v):\n tabn[j]=(max((tr[j]-k),0)*tab[j]+(tr[j]-tr[j+1])*tab[j+1])%mo\ns=tabn[0]\np2=1\nv=0\nwhile p2*2<=n:\n p2*=2\n v+=1\ntr=[n//(3*2**k) for k in range(v+1)]\ntr3=[n//(2**k) for k in range(v+1)]\ntab3n=[0]*(v+1)\ntabn=[0]*(v+1)\ntabn[-2]=tr[-2]#3*2**k-1\nfor k in range(1,n):\n if tr3[v-1]<k-2:\n v-=1\n tab=tabn[:]\n tabn=[0]*(v+1)\n tab3=tab3n[:]\n tab3n=[0]*(v+1)\n for j in range(v):\n tabn[j]=(max((tr[j]-k),0)*tab[j]+(tr[j]-tr[j+1])*tab[j+1])%mo\n for j in range(v):\n tab3n[j]=(max((tr3[j]-k),0)*tab3[j]+(tr3[j]-tr3[j+1])*tab3[j+1]+(tr3[j]-tr[j])*tab[j])%mo\nprint((s+tab3n[0])%mo)\n"}], "negative_code": [{"source_code": "from time import*\nn=6#{int(input())\nt=time()\np2=1\nv=0\nwhile p2*2<=n:\n p2*=2\n v+=1\nmo=10**9+7\ntr=[n//(2**k) for k in range(v+1)]\ntabn=[0]*(v+1)\ntabn[-2]=tr[-2]-1\nfor k in range(2,n):\n if tr[v-1]<k-2:\n v-=1\n tab=tabn[:]\n tabn=[0]*(v+1)\n for j in range(v):\n tabn[j]=(max((tr[j]-k),0)*tab[j]+(tr[j]-tr[j+1])*tab[j+1])%mo\ns=tabn[0]\np2=1\nv=0\nwhile p2*2<=n:\n p2*=2\n v+=1\ntr=[n//(3*2**k) for k in range(v+1)]\ntr3=[n//(2**k) for k in range(v+1)]\ntab3n=[0]*(v+1)\ntabn=[0]*(v+1)\ntabn[-2]=tr[-2]#3*2**k-1\nfor k in range(1,n):\n if tr3[v-1]<k-2:\n v-=1\n tab=tabn[:]\n tabn=[0]*(v+1)\n tab3=tab3n[:]\n tab3n=[0]*(v+1)\n for j in range(v):\n tabn[j]=(max((tr[j]-k),0)*tab[j]+(tr[j]-tr[j+1])*tab[j+1])%mo\n for j in range(v):\n tab3n[j]=(max((tr3[j]-k),0)*tab3[j]+(tr3[j]-tr3[j+1])*tab3[j+1]+(tr3[j]-tr[j])*tab[j])%mo\nprint((s+tab3n[0])%mo)\n"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 10**9 + 7\ndef fac(x):\n i = 1\n for j in range(2 , x + 1):\n i = i * j % MOD\n return i\n\nn = int(input())\ndef ways(prevg, g):\n cur = n//g - n//prevg if prevg else n//g\n left = n - n//g\n\n a = fac(cur) * pow(left+1, cur - 1, MOD)\n b = +(g == 1)\n for x in 2,3:\n if g % x == 0:\n b += ways(g, g // x)\n return a * b\n\na = 1\nwhile a * 2 <= n:\n a *= 2\n\nans = ways(0, a)\nif a //2 * 3 <= n:\n ans += ways(0, a //2 * 3)\n\nprint ans % MOD\n"}, {"source_code": "p=10**9+7\nimport math\ndef inv(k,p):\n prod=1\n while k>1:\n prod*=(p//k+1)\n k=(k*(p//k+1))%p\n return prod%p\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\nfacs=[1]*(n+1)\nfor i in range(2,n+1):\n facs[i]=(i*facs[i-1])%p\nif n<3*(2**(k-1)):\n start=k\nelse:\n start=0\ntot=0\nfor j in range(start,k+1):\n prod=1\n for i in range(j,k):\n prod*=b[i]\n prod*=d[j]\n for i in range(j):\n prod*=a[i]\n prod%=p\n prod*=facs[n]\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n f=[sum(e[:i+1]) for i in range(k+1)]\n g=1\n for guy in f:\n g*=guy\n prod*=inv(g,p)\n prod%=p\n tot+=prod\nprint(prod)"}, {"source_code": "p=10**9+7\nimport math\ndef inv(k,p):\n prod=1\n while k>1:\n prod*=(p//k+1)\n k=(k*(p//k+1))%p\n return prod%p\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\nfacs=[1]*(n+1)\nfor i in range(2,n+1):\n facs[i]=(i*facs[i-1])%p\nif n<3*(2**(k-1)):\n start=k\nelse:\n start=0\ntot=0\nfor j in range(start,k+1):\n prod=1\n for i in range(j,k):\n prod*=b[i]\n prod*=d[j]\n for i in range(j):\n prod*=a[i]\n prod%=p\n prod*=facs[n]\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n f=[sum(e[:i+1]) for i in range(k+1)]\n g=1\n for guy in f:\n g*=guy\n prod*=inv(g,p)\n prod%=p\n tot+=prod\nprint(tot)"}], "src_uid": "b2d59b1279d891dba9372a52364bced2"} {"source_code": "num = raw_input()\nans = [x for x in raw_input()]\n\nna = sorted(num)\nif na[0] == '0':\n for i, n in enumerate(na):\n if n != '0':\n na[0] = n\n na[i] = '0'\n break\nif ans == na:\n print 'OK'\nelse:\n print 'WRONG_ANSWER'", "positive_code": [{"source_code": "s=[int(n) for n in input()]\nz=[int(n) for n in input()]\nif len(s)==len(z):\n\ts.sort()\n\tm=v=0\n\tif s[0]==0:\n\t\tfor n in range(len(s)):\n\t\t\tif s[n]!=0:\n\t\t\t\ts[0]=s[n]\n\t\t\t\ts[n]=0\n\t\t\t\tbreak\n\t#print(s)\n\tfor n in range(len(s)):\n\t\tm+=s[n]*10**(n)\n\tfor n in range(len(z)):\n\t\tv+=z[n]*10**(n)\n\tif m==v:\n\t\tprint('OK')\n\telse:\n\t\tprint('WRONG_ANSWER')\nelse:\n\tprint('WRONG_ANSWER')\t\t\t"}, {"source_code": "a = input()\nb = input()\nc = ''.join(sorted(a))\nif c[0] == '0':\n p = 0\n while p < len(c) and c[p] == '0':\n p += 1\n if p < len(c):\n c = list(c)\n c[0], c[p] = c[p], c[0]\n c = ''.join(c)\n\nprint('OK' if b == c else 'WRONG_ANSWER')\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nq,a = input(),input()\nn = q.count('0')\nx = sorted(list(map(int,str(q))))\nx = [str(i) for i in x]\nx = ''.join(x)\nif len(q) > 1: k = str(x[n])+'0'*n+str(x[n+1:])\nelse: k = str(x[0])\n\nif k == a: print('OK')\nelse: print('WRONG_ANSWER')\n\n"}, {"source_code": "lst=input()\nlst1=input()\n\nlst=''.join(sorted(lst))\nif(len(lst)>=2):\n if(lst[0]=='0'):\n temp=list(lst)\n temp[0]=temp[1]\n temp[1]='0'\n lst=''\n for i in temp:\n lst+=i\nif(lst==lst1):\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "n = raw_input()\nans = raw_input()\nst = list(n)\nst.sort()\nmin_val = '9'\nmin_idx = 0\nfor i in range(len(st)):\n s = st[i]\n if s < min_val and s != '0':\n min_val = s\n min_idx = i\nst[0], st[min_idx] = st[min_idx], st[0]\nmyans = '%s'*len(st) % tuple(st)\nprint 'OK' if myans == ans else 'WRONG_ANSWER'\n"}, {"source_code": "a = input()\nb = input()\na = sorted(a)\nc = ''\ndict1 = {}\nif(len(a)==1):\n c = ''.join(a)\nelse:\n for i in a:\n dict1[i] = a.count(i)\n if('0' not in a):\n c = ''.join(a)\n else:\n if('0' in dict1):\n for i in range(dict1['0']):\n a.remove('0')\n c = ''.join(min(a)+'0'*dict1['0']+''.join(a[1:]))\nif(c == b):\n print('OK')\nelse:\n print('WRONG_ANSWER')\n\n\n"}, {"source_code": "num1 = [int(i) for i in list(input())]\nnum2 = [int(i) for i in list(input())]\n\nif set(num1) != set(num2) or len(num1) != len(num2): print(\"WRONG_ANSWER\")\nelse:\n num1.sort()\n for i in range(len(num1)):\n if num1[i] != 0:\n num1[0], num1[i] = num1[i], num1[0]\n break\n if num1 == num2: print(\"OK\")\n else: print(\"WRONG_ANSWER\")"}, {"source_code": "n = raw_input()\nm = raw_input()\nn = sorted(n)\ns = \"\"\nfor i in n:\n if i != str(0):\n s += i\n n.remove(i)\n break\nfor i in n:\n s += i\nif s == m:\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "n=raw_input();m=raw_input();l=[];c=0;s=''\nfor i in n:\n if i=='0': c+=1\n else: l.append(i)\nl.sort()\nif len(l)<>0: s+=l[0]\nl=l[1:]\nwhile c<>0:\n s+='0';c-=1\ns+=''.join(l);\nif s==m: print\"OK\"\nelse: print\"WRONG_ANSWER\"\n"}, {"source_code": "a=input()\nb=input()\na=list(a)\na.sort()\n\nif a[0]==\"0\":\n for i in range(1,len(a)):\n if a[i]!=0:\n\n a[0]=a[i]\n a[i]=\"0\"\n break\n a=''.join(a)\n if a==b:\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\nelse:\n a=''.join(a)\n if a==b:\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n"}, {"source_code": "r = lambda:raw_input(); a = sorted(list(r())); b = r()\nif (a[0] == '0'):\n for i in xrange(1, len(a)):\n if (a[i] != '0'):\n rep = a[i]\n a[i] = '0'\n a[0] = rep\n break\nprint ['WRONG_ANSWER','OK'][(''.join(x for x in a)) == b]"}, {"source_code": "t,s=raw_input(),raw_input()\nt=''.join(sorted(t))\ncnt=t.count('0')\nif len(t)>cnt: t=t[cnt] + '0'*cnt + t[cnt+1:]\nprint \"OK\" if s==t else \"WRONG_ANSWER\""}, {"source_code": "import sys\nn = input()\ncheck = input()\nif (len(n)!=len(check)):\n\tprint('WRONG_ANSWER')\n\tsys.exit()\nif (int(n) == 0):\n\tif int(check) == 0:\n\t\tprint ('OK')\n\telse:\n\t\tprint('WRONG_ANSWER')\n\tsys.exit() \nwynik = ''\nlista = [] \nfor char in n:\n\tlista.append(int(char))\nlista.sort()\nliczba_zer = 0\nmini = 9\nwhile lista[liczba_zer] == 0: \n\tliczba_zer+=1;\nwynik += str(lista[liczba_zer])\nfor i in range(liczba_zer):\n\twynik += str(0)\nfor i in range(liczba_zer+1, len(lista)):\n\twynik += str(lista[i])\n#\tprint(wynik, check)\nif wynik == check: \n\tprint('OK')\nelse:\n\tprint('WRONG_ANSWER')\n\n"}, {"source_code": "def R(): return map(int, input().split())\ndef I(): return int(input())\ndef S(): return str(input())\n\ndef L(): return list(R())\n\nfrom collections import Counter \n\nimport math\nimport sys\n\ns=S()\ns=sorted(s)\nans2=S()\n\n\ncnt=Counter(s)\n\nz=cnt['0']\ns=''.join(s)\n\nprint(['WRONG_ANSWER','OK'][s[z:z+1]+'0'*z+s[z+1:]==ans2])\n \n \n \n"}, {"source_code": "n = raw_input()\nm = raw_input()\nD = [0 for i in range(10)]\n\nfor i in n:\n D[int(i)] += 1\nans = ''\nfor j in range(1,10):\n if D[j] != 0:\n ans += str(j)\n D[j] -= 1\n break\n\n\nfor j in range(10):\n ans += D[j]*str(j)\n\nif ans == m :\n print \"OK\"\n\nelse:\n print \"WRONG_ANSWER\"\n\n"}, {"source_code": "import sys\nn = sys.stdin.readline().strip();\nm = sys.stdin.readline().strip();\nn = ''.join(sorted(n))\nif n[0] == '0':\n\tfor i in range(len(n)):\n\t\tif n[i] != '0':\n\t\t\tbreak\n\tn = n[i]+n[:i]+n[i+1:]\nif m==n:\n\tprint \"OK\"\nelse:\n\tprint \"WRONG_ANSWER\"\n"}, {"source_code": "n = list(input())\nans = input()\nn.sort()\ni = n.count('0')\nif i == len(n):\n if ''.join(ans) == n or ans == '0' and n == ['0']:\n print('OK')\n else:\n print('WRONG_ANSWER')\nelse:\n n = [x for x in n if x != '0']\n n = ''.join(n)\n new_s = n[0]\n for a in range(i):\n new_s += '0'\n new_s += n[1:]\n if new_s == ans:\n print('OK')\n else:\n print('WRONG_ANSWER')"}, {"source_code": "from collections import Counter\n\n\ns = input()\ncounter = Counter(s)\nnozero = ''.join(s.split('0'))\ncorrect = ''\nif nozero:\n correct += min(nozero)\n counter[min(nozero)] -= 1\nfor i in range(10):\n c = chr(ord('0') + i)\n for j in range(counter[c]):\n correct += c\nans = input()\nif correct == ans:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "r = raw_input()\na = raw_input()\nr1 =''.join(sorted(r))\nn = r1.count('0')\nif r1[n:n+1]+'0'*n+r1[n+1:]==a:\n\tprint 'OK'\nelse:\n\tprint 'WRONG_ANSWER'\n"}, {"source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\n\n# def gcd(a,b):\n# while b > 0: a,b = b, a%b\n# return a\n\n# def baseN(num,b,numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n# return ((num == 0) and \"0\" ) or ( baseN(num // b, b).lstrip(\"0\") + numerals[num % b])\na = raw_input()\nzeros = a.count(\"0\")\na = a.replace(\"0\", \"\")\na = sorted(a)\nif len(a) > 1:\n if a[0]+\"0\"*zeros+\"\".join(a[1:]) == raw_input():\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\nelse:\n if raw_input() == \"\".join(a)+(\"0\"*zeros):\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "n=str(input())\nm=input()\nmi=n.replace('0','')\np=''\nif len(mi)!=0:\n p=min(mi)\nfor i in range(0,len(n)):\n if n[i]==p and i!=len(n)-1:\n n=n[:i]+n[i+1:]\n break\n elif n[i]==p and i==len(n)-1:\n n=n[:-1]\nwhile len(n)!=0:\n mi=min(n)\n p=p+mi\n for j in range(0,len(n)):\n if n[j]==mi and j!=len(n)-1:\n n=n[:j]+n[j+1:]\n break\n elif n[j]==mi and j==len(n)-1:\n n=n[:-1]\nif p==m:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n \n"}, {"source_code": "#################################################################\n# - Programming Credits - atifcppprogrammer\n#################################################################\n# Getting Problem Data from Codeforces.\nnumberOrg,numberMin = list(input()),input()\n# For Storing Occurence of Digits (0-9) in numberOrg.\nnumString = ['0','1','2','3','4','5','6','7','8','9']\nlistCount = [0,0,0,0,0,0,0,0,0,0]\n# Computing Counts.\nfor i in range(len(numberOrg)):\n digit = int(numberOrg[i])\n listCount[digit] = listCount[digit]+1\n# Computing Minimum-Non Zero Occuring Digit.\nindex,found = 1,False\nwhile not found and index<10:\n if listCount[index]>0:\n found = True\n else: index = index+1\n# Deciding on minNonZero based on Search.\nif not found: minNonZero = 0\nelse: minNonZero = index\n# Computing Minimum Possible Number.\n# Adding one minNonZero.\npossMin = numString[minNonZero]\nlistCount[minNonZero] = listCount[minNonZero]-1\n# Accounting For Zeros.\npossMin+= numString[0]*listCount[0]\n# Accounting for remaining minNonZero's.\npossMin+= numString[minNonZero]*listCount[minNonZero]\n# Accounting for digits greater than minNonZero's.\nfor i in range(minNonZero+1,10):\n possMin+=numString[i]*listCount[i]\n# Verdict.\nif possMin == numberMin:\n print(\"OK\")\nelse: print(\"WRONG_ANSWER\")\n#################################################################\n\n\n\n\n\n"}, {"source_code": "n = raw_input('')\nm = raw_input('')\n\nbl = 0\n\nif m[0] != '0' and len(n) == len(m) and len(n) != 1:\n dl = len(n)\n\n sp = []\n\n for x in range(dl):\n sp.append(n[x])\n\n sp = [int(x) for x in sp]\n sp.sort()\n\n kol = sp.count(0)\n\n if kol != 0 and kol != dl:\n ch = sp[kol]\n sp[0] = ch\n sp[kol] = 0\n\n if kol != dl or len(m) == 1:\n sp = [str(x) for x in sp]\n\n pStr = ''\n pStr = pStr.join(sp)\n\n if pStr == m:\n bl = 1\n print 'OK'\nelif len(n) == len(m):\n if n == m:\n bl = 1\n print 'OK'\n\nif bl == 0:\n print 'WRONG_ANSWER'\n"}, {"source_code": "d=raw_input()\nx=raw_input()\nm=''\nres=''\nresult=''\nfor i in range(0,len(d)):\n m=m+\" \"+d[i:i+1]\n \nm=m[1:len(m)]\nm=m.split()\nk=0 \nfor i2 in range(0,len(m)):\n \n m[i2]=int(m[i2])\n if(m[i2]==0):\n k=k+1 \n \n \nm=sorted(m)\nif(len(m)==1)&(m[0]==0):\n k=9\n res=0\nfor i in range(0,len(m)):\n m[i]=str(m[i])\nif(k==1):\n res=m[1]+m[0]\n for i in range(2,len(m)):\n res=res+m[i]\n \nif(k==2):\n res=m[2]+m[1]+m[0]\n for i in range(3,len(m)):\n res=res+m[i]\nif(k==3):\n res=m[3]+m[2]+m[1]+m[0]\n for i in range(4,len(m)):\n res=res+m[i]\nif(k==4):\n res=m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(5,len(m)):\n res=res+m[i]\nif(k==5):\n res=m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(6,len(m)):\n res=res+m[i]\nif(k==6):\n res=m[6]+m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(7,len(m)):\n res=res+m[i]\nif(k==7):\n res=m[7]+m[6]+m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(8,len(m)):\n res=res+m[i]\nif(k==8):\n res=res[8]+m[7]+m[6]+m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(9,len(m)):\n res=res+m[i]\nif(k==0):\n for i in range(0,len(m)):\n res=res+m[i]\n\nif(str(res)==str(x)):\n print(\"OK\")\nif(str(res)!=str(x)):\n print(\"WRONG_ANSWER\")\n \n \n \n"}, {"source_code": "def main():\n s = input()\n if s != \"0\":\n l = sorted(c for c in s if c != '0')\n l[0] += '0' * s.count('0')\n s = ''.join(l)\n print((\"OK\", \"WRONG_ANSWER\")[s != input()])\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = [int(ch) for ch in input()]\nss = [int(ch) for ch in input()]\nif s==[0] and ss==[0]:\n print(\"OK\")\n exit()\ns.sort()\nans=[]\nfor i in range(len(s)):\n if s[i]!=0:\n ans.append(s[i])\n break\nfor j in range(i):\n ans.append(0)\nfor k in range(i+1,len(s)):\n ans.append(s[k])\n#print(ans) \nif ans==ss:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")\n "}, {"source_code": "n = input()\nm = input()\nif len(n) > 1:\n others = []\n z = []\n for i in n:\n if i == '0':\n z.append(i)\n else:\n others.append(i)\n others = sorted(others)\n\n n = others[0] + ''.join(z) + ''.join(others[1:])\n\nprint('OK' if n == m else 'WRONG_ANSWER')"}, {"source_code": "a=list(input().strip())\nb=input().strip()\na.sort()\nfor i in range(len(a)):\n if a[i]!='0':\n a[0],a[i]=a[i],a[0]\n break\nif a==list(b):\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")\n"}, {"source_code": "n = raw_input()\nm = raw_input()\na = sorted(n)\n\nif len(n) == 1:\n res = n == m\nelse:\n if a[0] == '0':\n i = 1\n while a[i] == '0':\n i += 1\n a[0], a[i] = a[i], a[0]\n res = m == ''.join(a)\n\nif res:\n print 'OK'\nelse:\n print 'WRONG_ANSWER'"}, {"source_code": "n, m, i = sorted(raw_input()), raw_input(), 0\n\nwhile(i < len(n) and n[i] == '0'):\n i += 1\n \nz = n[i: i + 1] + n[0:i] + n[i + 1:]\n\nif ''.join(z) == m:\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\"\n \n"}, {"source_code": "n = list(raw_input())\nans = raw_input()\nn.sort()\n\ndef correctornot(ans,n):\n if len(n) == 1 and n[0] != ans:\n return \"WRONG_ANSWER\"\n elif len(n) == 1 and n[0] != ans:\n return \"OK\"\n elif len(n)>0:\n if n[0] == \"0\":\n for i in range(1,len(n)):\n if int(n[i]) > 0:\n n[0],n[i] = n[i],n[0]\n break\n n = \"\".join(n)\n if ans == n:\n return \"OK\"\n else:\n return \"WRONG_ANSWER\"\n\nprint correctornot(ans,n)\n \n \n "}, {"source_code": "a = [0] * 10\nfor k in raw_input():\n a[int(k)] += 1\ns = \"\"\nfor i in xrange(1, 10):\n if a[i] != 0:\n a[i] -= 1\n s += str(i)\n break\nfor i in xrange(10):\n s += str(i) * a[i]\nif s == raw_input():\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\""}, {"source_code": "n = raw_input('')\nm = raw_input('')\n\nbl = 0\n\nif m[0] != '0' and len(n) == len(m) and len(n) != 1:\n dl = len(n)\n\n sp = []\n\n for x in range(dl):\n sp.append(n[x])\n\n sp = [int(x) for x in sp]\n sp.sort()\n\n kol = sp.count(0)\n\n if kol != 0 and kol != dl:\n ch = sp[kol]\n sp[0] = ch\n sp[kol] = 0\n\n if kol != dl or len(m) == 1:\n sp = [str(x) for x in sp]\n\n pStr = ''\n pStr = pStr.join(sp)\n\n if pStr == m:\n bl = 1\n print 'OK'\nelif len(n) == len(m):\n if n == m:\n bl = 1\n print 'OK'\nelse:\n pass\n\nif bl == 0:\n print 'WRONG_ANSWER'\n"}, {"source_code": "n=input()\nm=raw_input()\nk=int(m)\na=map(int,str(n))\nb=sorted(a)\ncount=0\nfor i in range(len(b)):\n if (b[i]==0):\n count=count+1\n else:\n break\nif(len(b)>1): \n temp=b[0]\n b[0]=b[count]\n b[count]=temp\n\nnum = int(''.join(map(str,b)))\n\nif ((num==k) & (len(b)==len(m))):\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\""}, {"source_code": "n = raw_input('')\nm = raw_input('')\n\ndl = len(n)\nbl = 0\n\nif m[0] != '0' and dl == len(m) and dl != 1:\n sp = []\n\n for x in range(dl):\n sp.append(n[x])\n\n sp = [int(x) for x in sp]\n sp.sort()\n\n kol = sp.count(0)\n\n if kol != 0 and kol != dl:\n ch = sp[kol]\n sp[0] = ch\n sp[kol] = 0\n\n if kol != dl or len(m) == 1:\n sp = [str(x) for x in sp]\n\n pStr = ''\n pStr = pStr.join(sp)\n\n if pStr == m:\n bl = 1\n print 'OK'\nelif dl == len(m):\n if n == m:\n bl = 1\n print 'OK'\nelse:\n pass\n\nif bl == 0:\n print 'WRONG_ANSWER'\n"}, {"source_code": "n=input()\nm=input()\nn=''.join(sorted(n))\nfor i in range(len(n)):\n if n[i]!='0':\n n=n[i]+n[:i]+n[i+1:]\n break\nprint(['OK','WRONG_ANSWER'][m!=n])\n"}, {"source_code": "s=input()\nk=s.count('0')\ns=''.join(sorted(s))[k:]\nprint(['WRONG_ANSWER','OK'][input()==('0' if s=='' else s[0]+'0'*k+s[1:])])"}, {"source_code": "n=input()\nm=input()\n\nif len(m)!=len(n):\n print(\"WRONG_ANSWER\")\n exit()\n\na=list()\nkhong=0\ntmp=\"\"\nfor i in n:\n if i=='0':\n khong+=1\n else:\n a.append(i)\na.sort()\nfor i in a:\n if len(tmp)==1:\n tmp+=khong*\"0\"\n khong=0\n tmp+=i\nif khong!=0:\n tmp+=khong*\"0\"\nif tmp==m:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "a,b=[raw_input() for i in range(2)]\na=list(a)\naux=filter(lambda x:x!='0',a)\naux2=filter(lambda x:x=='0',a)\naux.sort()\nfor i in aux2:\n aux.insert(1,i)\na=''.join(aux)\nif a==b:\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "a = raw_input()\nb = raw_input()\n\nif(len(a) == len(b)):\n if(b[0] != \"0\" and len(b) > 1):\n aux = True\n for i in xrange(1, len(b)):\n if(i == 1):\n if((not (b[i-1] <= b[i])) and b[i] != \"0\"):\n aux = False\n elif((not (b[i-1] <= b[i]))):\n aux = False\n if(aux):\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n elif(len(b) == 1):\n if(b == a):\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n else:\n print(\"WRONG_ANSWER\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "def test(n, m):\n if n == 0:\n return m == 0\n nl = list(n)\n nl.sort()\n \n for i in range(0, len(nl)):\n if nl[i] != '0':\n if i != 0:\n nl[0], nl[i] = nl[i], nl[0]\n break\n \n return nl == list(m)\n \nn = raw_input()\nm = raw_input() # can be 0001231231\n\nif test(n, m):\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "s=sorted(raw_input())\nfor i in range(len(s)):\n\tif s[i]!='0':t=s[i];s[i]=s[0];s[0]=t;break\nprint('WRONG_ANSWER','OK')[''.join(s)==raw_input()]"}, {"source_code": "ini=list(raw_input())\nini.sort()\ncnt=0\nfor i in range(len(ini)):\n\tif ini[i]=='0':\n\t\tcontinue\n\telif i!=0 and ini[i-1]=='0':\n\t\tini[0],ini[i]=ini[i],ini[0]\n\t\tbreak\n\telse:\n\t\tbreak\ninp2=list(raw_input())\nif ini==inp2:\n\tprint \"OK\"\nelse:\n\tprint \"WRONG_ANSWER\"\n"}, {"source_code": "def find_lowest_not_zero(digits):\n minimal = 10\n min_pos = -1\n for i in xrange(len(digits)):\n curr = digits[i]\n if curr != 0 and curr < minimal:\n minimal = curr\n min_pos = i\n\n if min_pos == -1:\n raise Exception(\"lowest not zero not found\")\n\n return (minimal, min_pos)\n\ndef list_to_num(l):\n s = ''.join(map(str, l))\n return int(s)\n\nnum = int(raw_input())\ndigits = [int(d) for d in str(num)]\n\n\ntry:\n (lnz, lnz_pos) = find_lowest_not_zero(digits)\n\n digits.pop(lnz_pos)\n final_rightside = digits\n\n\n final_rightside.sort()\n final = [lnz]\n\n for v in final_rightside: final.append(v)\n final = list_to_num(final)\n\nexcept Exception as e:\n final = num\n\nif raw_input() == str(final):\n print 'OK'\nelse: print 'WRONG_ANSWER'\n\n"}, {"source_code": "n = raw_input().strip()\nm = raw_input().strip()\n\nif n == '0' and m == '0':\n\tprint 'OK'\n\texit()\n\nif m[0] == '0':\n\tprint 'WRONG_ANSWER'\n\texit()\n\nfor digit in m:\n\tif digit not in n:\n\t\tprint 'WRONG_ANSWER'\n\t\texit()\n\nn_split = list(n)\nn_split.sort()\n\nif n_split[0] == '0':\n\tindex = next((i for i, x in enumerate(n_split) if x != '0'), None)\n\ttemp = n_split[index]\n\tn_split[index] = '0'\n\tn_split[0] = temp\n\nif ''.join(n_split) != m:\n\tprint 'WRONG_ANSWER'\nelse:\n\tprint 'OK'\n\n"}, {"source_code": "if __name__ == '__main__':\n n=raw_input()\n m=raw_input()\n l=len(n)\n n=list(n)\n n.sort()\n i=0\n while i<l and n[i]=='0':\n i+=1\n if i<l and i!=0:\n n[0]=n[i]\n n[i]='0'\n n=''.join(n)\n if n==m:\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "n = input()\nm = input()\nn1 = len(n)\nm1 = len(m)\nm = int(m)\n\nn = list(map(int,sorted(n)))\n\nzero=0\nr=0\nfor i in n:\n if i==0:\n zero+=1\n else:\n r=r*10+i\n while zero>0:\n r = r*10\n zero -=1\nif r==m and n1==m1:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "f=['WRONG_ANSWER','OK']\na=sorted([int(z)for z in list(input())])\nb=[int(z)for z in list(input())]\n# attention: if a = 0, 0, 0...\nif 0 in a:\n i=a.count(0)\n if i>=len(a):\n a=[0]\n else:\n a[i],a[0]=a[0],a[i]\nprint(f[a==b])"}, {"source_code": "__author__ = 'Darren'\n\n\ndef solve():\n n_list = [x for x in input()]\n m = input()\n n_list.sort()\n zeros = n_list.count('0')\n if zeros != len(n_list):\n n_list[0], n_list[zeros] = n_list[zeros], n_list[0]\n if ''.join(n_list) == m:\n print('OK')\n else:\n print('WRONG_ANSWER')\n\n\n\nif __name__ == '__main__':\n solve()"}, {"source_code": "s = raw_input();\nt = raw_input();\n\nflag = 1;\nfor i in range(len(s)):\n\tif s.count(s[i]) != t.count(s[i]):\n\t\tflag = 0; break;\n#print flag\npos = 0\n\nif t[0] == '0' and len(t) > 1:\n\tflag = 0;\nif flag:\n\tfor i in range(pos+1, len(t)):\n\t\tif t[i] == '0' and i == pos+1:\n\t\t\tcontinue;\n\t\tif t[i] < t[i-1]:\n\t\t\tflag = 0; break;\nprint \"OK\" if flag else \"WRONG_ANSWER\";\n"}, {"source_code": "a , b = input() , input()\nif a == '0':\n if b == '0':\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\nelse: \n x,y = list(a) , list(b)\n x.sort()\n i = 0\n while x[i] == '0':\n i += 1\n x[i] , x[0] = x[0] ,x[i]\n\n if x == y:\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n\n"}, {"source_code": "n=input()\nb=input()\nl=[]\nfor i in range(len(n)):\n l.append(n[i])\nl.sort()\ni=0\nwhile( i<len(n)):\n if(l[i]=='0'):\n pass\n else:\n break\n i+=1\nif(l[len(n)-1]=='0'):\n pass\nelse:\n tmp=l[0]\n l[0]=l[i]\n l[i]=tmp\nq=''.join(l)\nif(q==b):\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "a = list(input())\nb = input()\na.sort()\ncnt = a.count('0')\ni = 0\nwhile i < cnt:\n a.remove(a[0])\n i += 1\nif len(a) > 0:\n a[0] += ('0' * cnt)\nelse:\n a.append('0' * cnt)\nans = ''.join(a)\nb = str(b)\nif ans == b:\n print('OK')\nelse:\n print(\"WRONG_ANSWER\")\n"}, {"source_code": "a = input()\nn = [0] * 10\n\nfor x in a:\n y = int(x)\n n[y] += 1\n\nfirst = False\nres = ''\nfor i, x in enumerate(n[1:]):\n if x:\n if not first:\n res = str(i + 1) + '0' * n[0] + str(i + 1) * (x - 1)\n first = True\n else:\n res += str(i + 1) * x\nif not res and a:\n res = a\nif res == input():\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\n\ndef main():\n\tn=int(raw_input())\n\n\tmoo=raw_input()\n\tif( len(moo) > 0):\n\t\tif( moo.find('0') == 0 and len(moo) > 1 ):\n\t\t\tprint \"WRONG_ANSWER\"\n\t\t\treturn\n\tm=int(moo)\n\n\t#n=3310\n\t#m=1033\n\n\tcorrect = list(str(n))\n\tcorrect = sorted(correct)\n\n\tfor letter in range(len(correct)):\n\t\tif( correct[letter]!='0' ):\n\t\t\tt=correct[letter]\n\t\t\tdel( correct[letter] )\n\t\t\tcorrect = [t] + correct\n\t\t\tbreak\n\n\t#print \"\".join([str(x) for x in correct])\n\t\n\tnn=int( \"\".join(correct) )\n\tif nn==m:\n\t\tprint \"OK\"\n\telse:\n\t\tprint \"WRONG_ANSWER\"\n\t\t\n\nmain()\n"}, {"source_code": "\"\"\"\nOne cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:\n\n\u2014Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.\n\n\u2014No problem! \u2014 said Bob and immediately gave her an answer.\n\nAlice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.\n\nInput\nThe first line contains one integer n (0\u2009\u2264\u2009n\u2009\u2264\u2009109) without leading zeroes. The second lines contains one integer m (0\u2009\u2264\u2009m\u2009\u2264\u2009109) \u2014 Bob's answer, possibly with leading zeroes.\n\nOutput\nPrint OK if Bob's answer is correct and WRONG_ANSWER otherwise.\n\"\"\"\n\nq = list(map(int, list(input())))\nq_set = set(q)\n\na = input()\n\nif len(q) == 1:\n print(\"OK\" if (int(a) == q[0] and len(a) == 1) else \"WRONG_ANSWER\")\n\nelse:\n answer = ''\n\n has_zero = 0 in q_set\n if has_zero:\n q_set.remove(0)\n\n min_elm = min(q_set)\n q_set.remove(min_elm)\n answer += str(min_elm) + ('0' if has_zero else '') + str(min_elm)* (q.count(min_elm) - 1)\n\n while q_set:\n min_elm = min(q_set)\n q_set.remove(min_elm)\n answer += str(min_elm)*q.count(min_elm)\n\n print(\"OK\" if a == answer else \"WRONG_ANSWER\")\n"}, {"source_code": "def sort(items):\n\tc = -1\n\n\twhile c != 0:\n\t\tc = 0\n\n\t\tfor i in range(0, len(items) - 1):\n\t\t\tif items[i] > items[i + 1]:\n\t\t\t\titems[i], items[i + 1] = items[i + 1], items[i]\n\t\t\t\tc += 1\n\n\treturn items\n\ndef intListToString(items):\n\tresult = \"\"\n\n\tfor item in items:\n\t\tresult += str(item)\n\n\treturn result\n\nquestion = list(input())\nanswer = input()\n\nfor i in range(0, len(question)):\n\tquestion[i] = int(question[i])\n\nquestion = sort(question)\n\nif question[0] == 0:\n\tfound = -1\n\n\tfor i in range(0, len(question)):\n\t\tif question[i] != 0:\n\t\t\tfound = i\n\t\t\tbreak\n\n\tif found != -1:\n\t\tquestion[0], question[found] = question[found], question[0]\n\nif intListToString(question) == answer:\n\tprint(\"OK\")\nelse:\n\tprint(\"WRONG_ANSWER\")"}, {"source_code": "s=input()\nanswer=input()\nr=list(s)\nr.sort()\ns=''.join(r)\nr=s.rfind('0')\nif r!=-1 and len(s)>r+1:\n s=s[r+1]+s[:r+1]+s[r+2:]\nif s==answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "n=str(input())\nm=str(input())\nlength=len(n)\narr=[]\nfor i in range(0,length,1):\n arr.append(n[i])\n\narr.sort()\nif(arr[0]=='0'):\n for i in range(0,length,1):\n if(arr[i]!='0'):\n arr[0]=arr[i]\n arr[i]='0'\n break\n\nw=map(str,arr)\ny=''.join(w)\nhaha=str(y)\nif(haha==m):\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef main():\n n = \"\".join(sorted([c for c in raw_input()]))\n m = raw_input()\n l = len(n) - len(str(int(n)))\n if l != 0:\n n = n[l] + '0'*l + n[l+1:]\n if (int(n) == 0 and int(m) == 0 and len(m) != len(n)) or m != n:\n print \"WRONG_ANSWER\"\n else:\n print \"OK\"\n return 0\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s=input()\ns1=input()\n\nif(len(s)!=len(s1)):\n print('WRONG_ANSWER')\n exit()\nelif(len(s)==len(s1) and s1==s and len(s)==1):\n print('OK')\n exit()\nl=[]\nmn=10**9+7\nln=0\nfor i in s:\n ln+=1\n k=int(i)\n if(k!=0 and k<mn):\n mn=k\n\n l.append(k)\n\nl=sorted(l)\nif(l[0]==0):\n for i in range(ln):\n if(l[i]==mn):\n del l[i]\n break\n s=[str(i) for i in l]\n s2=''.join(s)\n s2=str(mn)+s2\nelse:\n s = [str(i) for i in l]\n s2 = ''.join(s)\n\nif(s1==s2):\n print('OK')\nelse:\n print('WRONG_ANSWER')\n\n\n"}, {"source_code": "import sys\nfrom itertools import product\n\nfile = sys.stdin\n#file = open(\"test\", \"r\")\np = map(int, list(file.readline().rstrip()))\np.sort()\nfor i in range(len(p)):\n if p[i] != 0:\n temp = p.pop(i)\n p.insert(0, temp)\n break\n\nans = \"\".join(map(str, p))\nbro = file.readline().rstrip()\nif ans == bro:\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\"\n\n\n"}, {"source_code": "original = input()\nperm = input()\n\nif ''.join(sorted(original)) == ''.join(sorted(perm)):\n\to = sorted(original)\n\tif o[0] == '0':\n\t\tfor i in range(0,len(o)):\n\t\t\tif o[i] != '0':\n\t\t\t\to[0] = o[i]\n\t\t\t\to[i] = '0'\n\t\t\t\tbreak\n\tfor i in range(0,len(o)):\n\t\tif o[i] != perm[i]:\n\t\t\tprint (\"WRONG_ANSWER\")\n\t\t\texit()\n\tprint (\"OK\")\nelse:\n\tprint (\"WRONG_ANSWER\")\n"}, {"source_code": "t = 1\nwhile t > 0 :\n t -= 1\n a = list(input())\n b = list(input())\n a.sort()\n z =- 9\n for i in range(len(a)):\n if a[i] != '0':\n z = a[i]\n a.pop(i)\n break\n if z != -9: \n a.insert(0,z)\n if a == b :\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")"}, {"source_code": "n = list(input())\nt = input()\nn = sorted(n)\nif(n[0]=='0'):\n for i in range(len(n)):\n if(n[i]!='0'):\n n[0],n[i] = n[i],n[0]\n break\n if(str(''.join(n))==t):\n print('OK')\n else:\n print('WRONG_ANSWER')\nelse:\n if(str(''.join(n))==t):\n print('OK')\n else:\n print('WRONG_ANSWER')\n"}, {"source_code": "#coding:utf8\nn=raw_input()\nm=raw_input()\nn=sorted(n)\nif(len(n)>1 and n[0]=='0'):\n tmp = n[0]\n n[0] = n[1]\n n[1] = tmp\nn = ''.join(n)#\u5c06''\u4f5c\u4e3a\u5206\u9694\u7b26\nif(n==m):\n print 'OK'\nelse:\n print'WRONG_ANSWER'"}, {"source_code": "s = str(input())\na = str(input())\nans=''\nx = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}\nfor i in range(len(s)):\n n = int(s[i])\n x[int(n)] += 1\nk=0\nl=0\nflag=0\nf2=0\nfor j in range(1,10):\n if x[j] != 0:\n for k in range(x[j]):\n if f2 == 0:\n flag = 1\n ans=ans+str(j)\n if flag == 1:\n f2=1\n flag=0\n for l in range(x[0]):\n ans=ans+'0'\n #print(j,end='')\n #print(ans)\nif ans == '':\n ans = s\nif ans == a:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "n = input()\notv = input()\nrez = ''\nnul = 0\nfor i in sorted(n):\n if i == '0':\n nul += 1\n continue\n else:\n rez += i + '0' * nul\n nul = 0\nif otv == rez or (otv == n and n == '0'):\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "s=str(input())\ns1=str(input())\nif('0' not in s):\n e=sorted(s)\n f=''\n f=f.join(e)\n if(f==s1):\n print('OK')\n else:\n print('WRONG_ANSWER')\nelse:\n e=sorted(s)\n g=-1\n for i in range(0,len(e)):\n if(e[i]!='0'):\n g=i\n break\n if(g!=-1):\n e.insert(0,e[g])\n e.pop(g+1)\n h=''\n h=h.join(e)\n if(h==s1):\n print('OK')\n else:\n print('WRONG_ANSWER')"}, {"source_code": "def countzero(inpt):\n\trt = 0\n\tfor i in range(len(inpt)):\n\t\tif inpt[i] == '0':\n\t\t\trt += 1\n\treturn rt\n\na = input()\nb = input()\nsted = ''.join(sorted(a))\nif countzero(sted) < len(sted):\n\top = ''.join([sted[countzero(sted)], '0'*countzero(sted), sted[1+countzero(sted):len(sted)]])\nelse:\n\top = sted\nprint(\"OK\" if b == op else \"WRONG_ANSWER\")"}, {"source_code": "def Ordenar(N):\n Ordenado = ''\n A = [0]*10\n for k in N:\n for i in range (0,10):\n if int(k)==i:\n A[i] += 1\n Aux = 0\n for k in range (1,10):\n if A[k]!=0:\n Aux = k\n A[k] = A[k]-1\n break\n Ordenado = str(Aux)\n for j in range (A[0]):\n if A[0]!=0:\n Ordenado += str(0)\n for k in range (1,10):\n if A[k]!=0:\n for i in range(A[k]):\n Ordenado += str(k)\n return Ordenado\nA = input()\nB = input()\nOrd = Ordenar(A)\nif A=='0':\n if B=='0':\n print('OK')\n else:\n print('WRONG_ANSWER')\nelse:\n if Ord == B:\n print('OK')\n else:\n print('WRONG_ANSWER')"}, {"source_code": "b=str(input())\nlu=str(input())\nif int(b)<10 and int(b)>0:\n z=b\nelse:\n if int(b)==0 and int(lu)==0:\n if len(b)==len(lu):\n z=b\n else:\n z=int(b)\n\n else:\n a=[]*len(b)\n lo=0\n for i in range (0,len(b)):\n a.append(int(b[i]))\n\n\n for k in range (1,len(a)):\n for t in range (len(a)-k):\n if (a[t])>(a[t+1]):\n p=(a[t])\n a[t]=(a[t+1])\n a[t+1]=p\n \n g=0\n \n if len(a)==1 and a[0]==0:\n z=str(0)\n \n \n else:\n \n \n while a[0]==0:\n a.remove(0)\n g=g+1\n z=a[0]\n if len(a)==1:\n z=int(b)\n else:\n del a[0]\n q=str(a[0])\n for i in range (1,len(a)):\n q+=\"\"+str(a[i])\n z=str(z)+str(0)*g+q\n \n\nif lu==z:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "c=[0]*10\nfor x in input():\n c[ord(x)-ord('0')]+=1\nt=[]\nt.append(c[1]*'1')\nt.append(c[0]*'0')\nfor i in range(2,10):\n if c[i]==0:\n continue\n t.append(c[i]*chr(ord('0')+i))\ns=input()\nif (len(s)==1 and s[0]=='0') or (s[0]!='0' and s==''.join(t)):\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "\nn = input()\nm = raw_input()\n\ntab = sorted(list(str(n)))\n\nif sorted(list(m)) != tab:\n print 'WRONG_ANSWER\\n'\n tab = []\n\nfor i in range(len(tab)):\n if tab[i] != '0':\n if ''.join(list(tab[i])+tab[:i]+tab[i+1:]) == m:\n print 'OK\\n'\n else:\n print 'WRONG_ANSWER\\n'\n tab = []\n break\n\nif len(tab):\n print 'OK\\n'\n\n"}, {"source_code": "#------------------------------------------------------------------------\n# Name: module2\n# Purpose:\n#\n# Author: co\n#\n# Created: 05/10/2011\n# Copyright: (c) u161283f 2011\n# Licence: <your licence>\n#------------------------------------------------------------------------\n#!/usr/bin/env python\n\nalice=input()\nbob=raw_input()\n\ncorrect=list(str(alice))\ncorrect.sort()\nreverses=correct[:]\nreverses.reverse()\nif alice==0:\n pass\nelif \"0\" in correct:\n not_zero_index=len(correct)-reverses.index(\"0\")\n correct[0],correct[not_zero_index]=correct[not_zero_index],correct[0]\n\ncorrect=\"\".join(correct)\n\nif bob==correct:\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\""}, {"source_code": "n, shuffled = sorted([int(d) for d in input()]), input()\nif str(int(shuffled)) != shuffled:\n print(\"WRONG_ANSWER\")\n exit(0)\nzeros = n.count(0)\nn = n[zeros:zeros+1] + [0] * zeros + n[zeros+1:]\nprint(\"OK\") if int(\"\".join(map(str, n))) == int(shuffled) else print(\"WRONG_ANSWER\")"}, {"source_code": "number = list(input())\nanswer = list(input())\nnumber.sort()\nif(len(number) == 1):\n\tprint(\"OK\") if number == answer else print(\"WRONG_ANSWER\")\nelse:\n\ti = 0\n\twhile i < len(number) and number[i] == \"0\": i+=1\n\n\ttest = [number[i]] + number[:i] + number [i+1:]\n\tprint(\"OK\") if test == answer else print(\"WRONG_ANSWER\")"}, {"source_code": "class A:\n\n def rotate_keypad(self, keypad):\n reversed_rows = list(reversed(keypad))\n return [\"\".join(list(reversed(x))) for x in reversed_rows]\n\n def solve(self):\n keypad = [input(), input(), input()]\n if keypad == self.rotate_keypad(keypad):\n print(\"YES\")\n else:\n print(\"NO\")\n\nclass B:\n\n def solve(self):\n alice = input()\n bob = input()\n\n if bob[0] == '0' and alice[0] != '0':\n print(\"WRONG_ANSWER\")\n return\n elif bob[0] == '0' and alice[0] == '0' and len(bob) != 1:\n print(\"WRONG_ANSWER\")\n return\n\n\n bob = int(bob)\n\n from itertools import permutations\n\n smallest = int(alice)\n if smallest == 0:\n if bob == 0:\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n else:\n smallest = min([int(\"\".join(list(perm))) for perm in permutations(sorted(alice)) if perm[0] != '0'])\n if smallest == bob:\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n\nclass C:\n\n def solve(self):\n [n, m] = [int(x) for x in input().split(\" \")]\n prices = sorted([int(x) for x in input().split(\" \")])\n\n fruits = []\n for i in range(m):\n fruits.append(input())\n\n from collections import Counter\n frequent_fruits = [f for (f, p) in Counter(fruits).most_common()]\n\n price_assignment = {}\n for f, p in zip(frequent_fruits, prices):\n price_assignment[f] = p\n\n smallest_price = sum([price_assignment[f] for f in fruits])\n\n for f, p in zip(frequent_fruits, list(reversed(prices))):\n price_assignment[f] = p\n\n largest_price = sum([price_assignment[f] for f in fruits])\n\n print(\"{} {}\".format(smallest_price, largest_price))\n\nclass D:\n\n def solve(self):\n n = int(input())\n ladies = []\n\n for x in input().split(\" \"):\n ladies.append([x])\n\n for i, x in enumerate(input().split(\" \")):\n ladies[i].append(x)\n\n for i, x in enumerate(input().split(\" \")):\n ladies[i].append(x)\n\n self_murderers = 0\n for i in range(n):\n if any([ladies[i][0] < ladies[x][0] and\\\n ladies[i][1] < ladies[x][1] and\\\n ladies[i][2] < ladies[x][2] for x in range(n) if x != i]):\n self_murderers += 1\n\n print(self_murderers)\n\nclass E:\n\n def generate_matrix(self, i, j, n, matrix):\n if i == j:\n matrix[i][j] = 0\n else:\n if matrix[i][j] == 0:\n dictionary = {}\n for e in matrix[i]:\n dictionary[e] = True\n for e in matrix[j]:\n dictionary[e] = True\n for index in range(n):\n if index not in dictionary:\n matrix[i][j] = index\n matrix[j][i] = index\n break\n\n def solve(self):\n n = int(input())\n\n matrix = [[0 for i in range(n)] for j in range(n)]\n for i in range(n):\n for j in range(n):\n self.generate_matrix(i, j, n, matrix)\n transponse = list(map(list, zip(*matrix)))\n if matrix != transponse:\n raise Exception(\"FC\")\n print(\"\\n\".join([\" \".join([str(y) for y in x]) for x in matrix]))\n\nB().solve()\n"}], "negative_code": [{"source_code": "x = raw_input()\nanswer = raw_input()\n\nif (x == '0'):\n if (answer[0] == '0') and (answer.lstrip('0') == ''):\n print 'OK'\n else:\n print 'WRONG_ANSWER'\n\nelse:\n \n answer = answer.lstrip('0')\n\n countnum = []\n for number in range(10):\n countnum.append(x.count(str(number)))\n ##print countnum\n\n\n num = ''\n for i in range(1,10):\n num = num + str(i) * countnum[i]\n\n zeros = '0' * countnum[0]\n\n ##print zeros\n\n\n r_ans = num[0] + zeros + num[1:]\n ##print r_ans\n if r_ans == answer:\n print 'OK'\n else:\n print 'WRONG_ANSWER'\n"}, {"source_code": "print ['WRONG_ANSWER', 'OK'][sorted(raw_input()) == sorted(raw_input())]"}, {"source_code": "a = raw_input()\nb = raw_input()\nx = []\nfor i in a:\n x.append(i)\nx.sort()\ni = 0\nwhile i<len(x) and x[i] == '0':\n i+=1\n\nif i != len(x):\n s = x[i]\n \n for j in xrange(0,len(x)):\n if j!=i:\n s+=x[j]\nelse:\n s = \"0\"\n\nif b[0] == '0':\n print \"WRONG_ANSWER\"\nelif int(s) != b:\n print \"WRONG_ANSWER\"\nelse:\n print \"OK\"\n"}, {"source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\n\n# def gcd(a,b):\n# while b > 0: a,b = b, a%b\n# return a\n\n# def baseN(num,b,numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n# return ((num == 0) and \"0\" ) or ( baseN(num // b, b).lstrip(\"0\") + numerals[num % b])\na = raw_input()\nzeros = a.count(\"0\")\na = a.replace(\"0\", \"\")\na = sorted(a)\nif len(a) > 1:\n if a[0]+\"0\"*zeros+\"\".join(a[1:]) == raw_input():\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\nelse:\n if len(raw_input()) == 1:\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "n = input()\nm = input()\nmzeros = 0\nfor i in range(0,len(m)):\n if m[i] != '0':\n mzeros = i\n break\nm = m[mzeros:]\nndigits = []\nfor i in n:\n ndigits.append(i)\n\nsnd = sorted(ndigits)\nnumberofzeros = 0\nfor i in range(0,len(snd)):\n if snd[i] != '0':\n numberofzeros = i\n break\nnumberofones = 0\nfor i in range(numberofzeros,len(snd)):\n if snd[i] != '1':\n numberofones = i-numberofzeros\n break\nif snd[len(snd)-1] == '1':\n numberofones = len(snd)-numberofzeros\notherdigits = snd[1+numberofzeros+numberofones:]\nif numberofones >= 1:\n answer = '1'+'0'*numberofzeros+'1'*(numberofones-1)\nelse:\n answer = snd[numberofzeros]+'0'*numberofzeros\nfor j in otherdigits:\n answer = answer+j\n \nif n == '0':\n for i in range(1,11):\n if m == '0'*i:\n print('OK')\nelif m == answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\n\ndef main():\n\tn=int(raw_input())\n\tm=int(raw_input())\n\n\t#n=3310\n\t#m=1033\n\n\n\n\tcorrect = list(str(n))\n\tcorrect =sorted(correct)\n\n\tfor letter in range(len(correct)):\n\t\tif( correct[letter]!='0' ):\n\t\t\tt=correct[letter]\n\t\t\tdel( correct[letter] )\n\t\t\tcorrect = [t] + correct\n\t\t\tbreak\n\n\t#print \"\".join([str(x) for x in correct])\n\t\n\tnn=int( \"\".join(correct) )\n\tif nn==m:\n\t\tprint \"OK\"\n\telse:\n\t\tprint \"WRONG_ANSWER\"\n\t\t\n\nmain()\n"}, {"source_code": "s = str(raw_input())\nss = str(raw_input())\nn = len(s)\nflg = True\ns = sorted(s)\ni = 0\nif s[i]=='0':\n ind = 0\n while i<n and s[i]=='0':\n i+=1\n if i<n:\n s[ind],s[i] = s[i],s[ind]\n flg = True\n else:\n flg = False\nif flg:\n s = ''.join(s)\n if s==ss:\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\nelse:\n print \"WRONG_ANSWER\""}, {"source_code": "import sys\nimport os\nfrom io import IOBase, BytesIO\n# import heapq\n# import math\n# import collections\n# import itertools\n# import bisect\nmod = 10 ** 9 + 7\npie = 3.1415926536\n#import resource\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#import threading\n# threading.stack_size(2**27)\n#import sys\n# sys.setrecursionlimit(10**6)\n# fact=[1]\n# for i in range(1,1000001):\n# fact.append((fact[-1]*i)%mod)\n# ifact=[0]*1000001\n# ifact[1000000]=pow(fact[1000000],mod-2,mod)\n# for i in range(1000000,0,-1):\n# ifact[i-1]=(i*ifact[i])%mod\n#from random import randint as rn\n#from Queue import Queue as Q\n\n\ndef modinv(n, p):\n return pow(n, p-2, p)\n\n\ndef ncr(n, r, p): # for using this uncomment the lines calculating fact and ifact\n t = ((fact[n])*((ifact[r]*ifact[n-r]) % p)) % p\n return t\n\n\ndef ain(): # takes array as input\n return list(map(int, sin().split()))\n\n\ndef sin():\n return input().strip()\n\n\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\n\n\ndef read2DIntArray(row, col):\n arr = []\n for i in range(0, row):\n temp = list(map(int, sin().split()))\n arr.append(temp)\n\n return arr\n\n\ndef read2DCharArray(row, col):\n arr = []\n for i in range(0, row):\n temp = str(sin())\n arr.append(temp)\n\n return arr\n\n\n# Smallest number by rearranging digits of a given number (without trailing zeros):-\n\n\ndef smallestNumber(n):\n lst = list(str(n))\n lst.sort()\n\n tmp = 0\n for i, n in enumerate(lst):\n if (n != '0'):\n tmp = lst.pop(i)\n break\n\n return str(tmp) + ''.join(lst)\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n\ndef main():\n n = int(sin())\n m = int(sin())\n\n num = int(smallestNumber(n))\n\n if (m == num):\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n# Python 2 and 3 footer by Pajenegod and c1729\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2),\n super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill():\n pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill()\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\ndef input(): return sys.stdin.readline().rstrip('\\r\\n')\n\n\nif __name__ == '__main__':\n main()\n# threading.Thread(target=main).start()\n"}, {"source_code": "num0 =input()\nnum1 =int(input())\ncount =0\ncharr =[]\nfor ch in num0:\n if ch != '0':\n charr.append(int(ch))\n continue\n count+=1\ncharr.sort()\nfor i in range(count):\n charr.insert(1,0)\nfor i in range(len(charr)):\n charr[i] =str(charr[i])\ncharr =''.join(charr)\ncharr =int(charr)\nif charr == num1:\n print('OK')\n quit()\nprint('WRONG_ANSWER')"}, {"source_code": "def sort(items):\n\tc = -1\n\n\twhile c != 0:\n\t\tc = 0\n\n\t\tfor i in range(0, len(items) - 1):\n\t\t\tif items[i] > items[i + 1]:\n\t\t\t\titems[i], items[i + 1] = items[i + 1], items[i]\n\t\t\t\tc += 1\n\n\treturn items\n\ndef listToInt(items):\n\tresult = 0\n\n\tfor i in range(len(items) - 1, -1, -1):\n\t\tresult += items[i] * (10**(len(items) - i - 1))\n\treturn result\n\nquestion = list(input())\nanswer = int(input())\n\nfor i in range(0, len(question)):\n\tquestion[i] = int(question[i])\n\nquestion = sort(question)\n\nif question[0] == 0:\n\tfound = -1\n\n\tfor i in range(0, len(question)):\n\t\tif question[i] != 0:\n\t\t\tfound = i\n\t\t\tbreak\n\n\tif found != -1:\n\t\tquestion[0], question[found] = question[found], question[0]\n\nif listToInt(question) == answer:\n\tprint(\"OK\")\nelse:\n\tprint(\"WRONG_ANSWER\")"}, {"source_code": "first =list(input())# \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 ['3', '3', '1', '0']\nsecond = input() \nfirst_reverse = first[::-1] # \u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043c\nif first_reverse[0] == \"0\": # \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 0, \u0442\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442 0 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tfor i in first_reverse:\n\t\tif i != \"0\":\n\t\t\ty =first_reverse.index(i)# \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0442 \u043d\u0443\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n\t\t\tfirst_reverse[0],first_reverse[y] = first_reverse[y],first_reverse[0]# \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0431\u0435\u0437 \u043f\u043e\u043c\u043e\u0437\u0438 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0439 \u043f\u0435\u0440\n\t\t\tbreak\nresult = ''.join(first_reverse)# \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u043e\u0435\u0434\u0438\u043d\u043e\n#print(result)\nif result == second:#\u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \n\tprint(\"OK\")\nelse: print(\"WRONG_ANSWER\")"}, {"source_code": "first =list(input())# \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 ['3', '3', '1', '0']\nsecond = input() \nfirst_reverse = first[::-1] # \u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043c\nif first_reverse[0] == \"0\": # \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 0, \u0442\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442 0 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tfor i in first_reverse:\n\t\tif i != \"0\":\n\t\t\ty =first_reverse.index(i)# \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0442 \u043d\u0443\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n\t\t\tfirst_reverse[0],first_reverse[y] = first_reverse[y],first_reverse[0]# \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0431\u0435\u0437 \u043f\u043e\u043c\u043e\u0437\u0438 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0439 \u043f\u0435\u0440\n\t\t\tbreak\nresult = ''.join(first_reverse)# \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u043e\u0435\u0434\u0438\u043d\u043e\n#print(result)\nif result == second:#\u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \n\tprint(\"OK\")\nelse: print(\"WRONG_ANSWER\")"}, {"source_code": "s = raw_input();\nt = raw_input();\n\nflag = 1;\nfor i in range(len(s)):\n\tif s.count(s[i]) != t.count(s[i]):\n\t\tflag = 0; break;\n#print flag\nif flag:\n\tfor i in range(1, len(t)):\n\t\tif t[i] < t[i-1]:\n\t\t\tif t[i] == '0' and i == 1:\n\t\t\t\t\tcontinue;\n\t\t\tflag = 0; break;\nprint \"OK\" if flag else \"WRONG_ANSWER\";\n"}, {"source_code": "n = input()\nm = input()\nmzeros = 0\nfor i in range(0,len(m)):\n if m[i] != '0':\n mzeros = i\n break\nm = m[mzeros:]\nndigits = []\nfor i in n:\n ndigits.append(i)\n\nsnd = sorted(ndigits)\nnumberofzeros = 0\nfor i in range(0,len(snd)):\n if snd[i] != '0':\n numberofzeros = i\n break\nnumberofones = 0\nfor i in range(numberofzeros,len(snd)):\n if snd[i] != '1':\n numberofones = i-numberofzeros\n break\nif snd[len(snd)-1] == '1':\n numberofones = len(snd)-numberofzeros\notherdigits = snd[numberofzeros+numberofones:]\nanswer = '1'+'0'*numberofzeros+'1'*(numberofones-1)\nfor j in otherdigits:\n answer = answer+j\n \nif n == '0':\n for i in range(1,11):\n if m == '0'*i:\n print('OK')\nelif m == answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\n\ndef main():\n\tn=int(raw_input())\n\n\tmoo=raw_input()\n\tif( len(moo) > 0):\n\t\tif( moo.find('0') == 0 ):\n\t\t\tprint \"WRONG_ANSWER\"\n\t\t\treturn\n\tm=int(moo)\n\n\t#n=3310\n\t#m=1033\n\n\tcorrect = list(str(n))\n\tcorrect = sorted(correct)\n\n\tfor letter in range(len(correct)):\n\t\tif( correct[letter]!='0' ):\n\t\t\tt=correct[letter]\n\t\t\tdel( correct[letter] )\n\t\t\tcorrect = [t] + correct\n\t\t\tbreak\n\n\t#print \"\".join([str(x) for x in correct])\n\t\n\tnn=int( \"\".join(correct) )\n\tif nn==m:\n\t\tprint \"OK\"\n\telse:\n\t\tprint \"WRONG_ANSWER\"\n\t\t\n\nmain()\n"}, {"source_code": "def solve():\n digits = [0]*10\n n = list(raw_input().strip())\n for i in n:\n digits[int(i)] += 1\n m = list(raw_input().strip())\n if len(n)!=len(m):\n print 'WRONG_ANSWER'\n return\n for i in xrange(1,10):\n if digits[i]!=0:\n if m[0] != str(i):\n print 'WRONG_ANSWER'\n return\n digits[i] -= 1\n m.pop(0)\n break\n for i in m:\n digits[int(i)] -= 1\n for i in digits:\n if i!=0:\n print 'WRONG_ANSWER'\n return\n print 'OK'\n\nsolve()\n"}, {"source_code": "class CodeforcesTask12BSolution:\n def __init__(self):\n self.result = ''\n self.number = 0\n self.solution = 0\n\n def read_input(self):\n self.number = int(input())\n self.solution = input()\n\n def process_task(self):\n try:\n if len(str(self.solution)) > 1 and str(self.solution)[0] == \"0\":\n self.result = \"WRONG_ANSWER\"\n else:\n cnts = [0] * 10\n for c in str(self.number):\n cnts[int(c)] += 1\n start = min([int(x) for x in str(self.number) if int(x)])\n cnts[start] -= 1\n res = [start]\n for x in range(10):\n res += [x] * cnts[x]\n real_result = int(\"\".join([str(x) for x in res]))\n self.result = \"OK\" if real_result == int(self.solution) else \"WRONG_ANSWER\"\n except ValueError:\n self.result = \"WRONG_ANSWER\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask12BSolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "n = raw_input('')\nm = raw_input('')\n\nbl = 0\n\nif m[0] != '0':\n dl = len(n)\n\n sp = []\n\n for x in range(dl):\n sp.append(n[x])\n\n sp = [int(x) for x in sp]\n sp.sort()\n\n kol = sp.count(0)\n\n if kol != 0 and kol != dl:\n ch = sp[kol]\n sp[0] = ch\n sp[kol] = 0\n\n if kol != dl:\n sp = [str(x) for x in sp]\n\n pStr = ''\n pStr = pStr.join(sp)\n\n if pStr == m:\n bl = 1\n print 'OK'\n\nif bl == 0:\n print 'WRONG_ANSWER'\n"}, {"source_code": "s = str(input())\na = str(input())\nans=''\nx = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}\nfor i in range(len(s)):\n n = int(s[i])\n x[int(n)] += 1\nk=0\nl=0\nfor k in range(x[1]):\n ans=ans+'1'\nfor l in range(x[0]):\n ans=ans+'0'\nj=2\nfor j in range(2,10):\n if x[j] != 0:\n for k in range(x[j]):\n ans=ans+str(j)\n #print(j,end='')\n#print(ans)\n#print(a)\n\nif ans == a:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "'''\nCreated on Jan 25, 2015\n\n@author: mohamed265\n'''\nnum = input()\nres = input()\nnum = sorted(num)\nindex = 0\nfor i in range(len(num)):\n if num[i] != '0':\n index = i\n break\nif index == 0:\n print(\"OK\") if num == res else print(\"WRONG_ANSWER\")\nelse:\n #print(num,index)\n temp = num[index] \n for i in range(index):\n temp+= \"0\"\n for i in range(index+1,len(num)):\n temp += num[i]\n #print(temp)\n print(\"OK\") if temp == res else print(\"WRONG_ANSWER\")"}, {"source_code": "s=input()\nz=input()\na=[0]*10\nfor c in s:\n a[int(c)]+=1\nans=\"\"\nfor i in range(1,10):\n if a[i]>0:\n a[i]-=1\n ans=str(i)\n break\nfor i in range(0,10):\n for j in range(a[i]):\n ans+=str(i)\nif ans==z:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=input()\nb=input()\nc=int(b)\nn=len(a)\nj=0\nA=[]\nwhile j<n:\n A.append(a[j])\n j=j+1\nj=1\nwhile j<n:\n key=A[j]\n i=j-1\n while i>-1 and A[i]>key:\n A[i+1]=A[i]\n i=i-1\n A[i+1]=key\n j=j+1\nd=int(A[0])\nj=0\nif d==0:\n while j<n:\n if int(A[j])>0:\n break\n j=j+1\n if j==n:\n i=j-1\n else:\n i=j\n A[0],A[i]=A[i],A[0]\nstr=''\nstr=str.join(A)\ne=int(str[0])\nnum=int(str)\nif num==c:\n print('OK')\nelif e==0:\n print('WRONG_ANSWER')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "b=str(input())\nlu=str(input())\nif int(b)<10 and int(b)>0:\n z=b\nelse:\n if int(b)==int(lu):\n if len(b)==len(lu):\n z=b\n else:\n z=int(b)\n\n else:\n a=[]*len(b)\n lo=0\n for i in range (0,len(b)):\n a.append(int(b[i]))\n\n\n for k in range (1,len(a)):\n for t in range (len(a)-k):\n if (a[t])>(a[t+1]):\n p=(a[t])\n a[t]=(a[t+1])\n a[t+1]=p\n \n g=0\n \n if len(a)==1 and a[0]==0:\n z=str(0)\n \n \n else:\n \n \n while a[0]==0:\n a.remove(0)\n g=g+1\n z=a[0]\n if len(a)==1:\n z=int(b)\n else:\n del a[0]\n q=str(a[0])\n for i in range (1,len(a)):\n q+=\"\"+str(a[i])\n z=str(z)+str(0)*g+q\n \n\nif lu==z:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "s=input()\ns1=(input())\nn=len(s)\nw=[]\nd=0\nfor i in range(0,n):\n w.append(int(s[i]))\nw.sort()\nfor i in range(0,n):\n if(w[i]!=0):\n q=i\n d=d+1\n break\nif(d==0):\n print(\"WRONG_ANSWER\")\n exit(0)\nelse:\n s2=str(w[q])\nfor i in range(0,n):\n if(i!=q):\n s2=s2+str(w[i])\nif(s2==s1 and int(s)>0):\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "class A:\n\n def rotate_keypad(self, keypad):\n reversed_rows = list(reversed(keypad))\n return [\"\".join(list(reversed(x))) for x in reversed_rows]\n\n def solve(self):\n keypad = [input(), input(), input()]\n if keypad == self.rotate_keypad(keypad):\n print(\"YES\")\n else:\n print(\"NO\")\n\nclass B:\n\n def solve(self):\n alice = input()\n bob = int(input())\n\n from itertools import permutations\n\n smallest = int(alice)\n if smallest != 0:\n for perm in permutations(sorted(alice)):\n if int(\"\".join(list(perm))) < smallest and \\\n not \"\".join(list(perm)).startswith(\"0\"):\n smallest = int(\"\".join(list(perm)))\n\n if smallest == bob:\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n\nB().solve()\n"}, {"source_code": "import sys\nimport os\nfrom io import IOBase, BytesIO\n# import heapq\n# import math\n# import collections\n# import itertools\n# import bisect\nmod = 10 ** 9 + 7\npie = 3.1415926536\n#import resource\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#import threading\n# threading.stack_size(2**27)\n#import sys\n# sys.setrecursionlimit(10**6)\n# fact=[1]\n# for i in range(1,1000001):\n# fact.append((fact[-1]*i)%mod)\n# ifact=[0]*1000001\n# ifact[1000000]=pow(fact[1000000],mod-2,mod)\n# for i in range(1000000,0,-1):\n# ifact[i-1]=(i*ifact[i])%mod\n#from random import randint as rn\n#from Queue import Queue as Q\n\n\ndef modinv(n, p):\n return pow(n, p-2, p)\n\n\ndef ncr(n, r, p): # for using this uncomment the lines calculating fact and ifact\n t = ((fact[n])*((ifact[r]*ifact[n-r]) % p)) % p\n return t\n\n\ndef ain(): # takes array as input\n return list(map(int, sin().split()))\n\n\ndef sin():\n return input().strip()\n\n\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\n\n\ndef read2DIntArray(row, col):\n arr = []\n for i in range(0, row):\n temp = list(map(int, sin().split()))\n arr.append(temp)\n\n return arr\n\n\ndef read2DCharArray(row, col):\n arr = []\n for i in range(0, row):\n temp = str(sin())\n arr.append(temp)\n\n return arr\n\n\n# Smallest number by rearranging digits of a given number (without trailing zeros):-\n\n\ndef smallestNumber(n):\n lst = list(str(n))\n lst.sort()\n\n tmp = 0\n for i, n in enumerate(lst):\n if (n != '0'):\n tmp = lst.pop(i)\n break\n\n return str(tmp) + ''.join(lst)\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n\ndef main():\n n = int(sin())\n m = int(sin())\n\n num = int(smallestNumber(n))\n\n if (num != 0 and m == num):\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n# Python 2 and 3 footer by Pajenegod and c1729\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2),\n super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill():\n pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill()\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\ndef input(): return sys.stdin.readline().rstrip('\\r\\n')\n\n\nif __name__ == '__main__':\n main()\n# threading.Thread(target=main).start()\n"}, {"source_code": "\na = raw_input()\nb = raw_input()\n\nz = a.count('0')*'0'\nu = a.count('1')*'1'\nd = a.count('2')*'2'\nt = a.count('3')*'3'\nq = a.count('4')*'4'\nc = a.count('5')*'5'\ns = a.count('6')*'6'\ne = a.count('7')*'7'\no = a.count('8')*'8'\nn = a.count('9')*'9'\n\ntup = [u,d,t,q,c,s,e,o,n]\nresult = ''\nfirst = True\nfor x in range(len(tup)):\n\tif(first and tup[x] != '' and z != ''):\n\t\tresult = result + tup[x] + z\n\t\tfirst = False\n\telse:\n\t\tresult = result + tup[x]\nif(first):\n\tresult = z\n\nif (result==b ):\n\tprint 'OK'\nelse:\n\tprint 'WRONG_ANSWER'\n"}, {"source_code": "s=input()\ns1=(input())\nn=len(s)\nw=[]\nd=0\nfor i in range(0,n):\n w.append(int(s[i]))\nw.sort()\nfor i in range(0,n):\n if(w[i]!=0):\n q=i\n d=d+1\n break\nif(d==0):\n print(\"WRONG_ANSWER\")\n exit(0)\nelse:\n s2=str(w[q])\nfor i in range(0,n):\n if(i!=q):\n s2=s2+str(w[i])\nif(s2==s1 and int(s)>0):\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "n,s = input(), str(int(input()));\nb = n;\nn=list(n);\nn.sort();\nif len(n)>1:\n for x in n:\n if x!='0':\n ans=x;\n break;\n n.remove(ans);\n n.insert(0, ans);\nn=''.join(n);\nprint(['WRONG_ANSWER','OK'][n==s and b>n]);\n"}, {"source_code": "\na = raw_input()\nb = raw_input()\n\nz = a.count('0')*'0'\nu = a.count('1')*'1'\nd = a.count('2')*'2'\nt = a.count('3')*'3'\nq = a.count('4')*'4'\nc = a.count('5')*'5'\ns = a.count('6')*'6'\ne = a.count('7')*'7'\no = a.count('8')*'8'\nn = a.count('9')*'9'\n\ntup = [u,d,t,q,c,s,e,o,n]\ntup.sort()\nc = \"\"\nfirst = True\nfor x in range(len(tup)):\n\tif(tup[x] != '' and first):\n\t\tc = c + tup[x] + z\n\t\tfirst = False\n\telse:\n\t\tc = c + tup[x]\n\t\t\nif (first == True):\n\tc = z\n\nif (c==b):\n\tprint \"OK\"\nelse:\n\tprint \"WRONG_ANSWER\"\n"}, {"source_code": "def Ordenar(N):\n Ordenado = ''\n A = [0]*10\n for k in N:\n for i in range (0,10):\n if int(k)==i:\n A[i] += 1\n Aux = 0\n for k in range (1,10):\n if A[k]!=0:\n Aux = k\n break\n Ordenado = str(Aux)\n for j in range (A[0]):\n Ordenado += str(0)\n for k in range (2,10):\n if A[k]!=0:\n for i in range(A[k]):\n Ordenado += str(k)\n return Ordenado\nA = input()\nB = input()\nOrd = Ordenar(A)\nif Ord == B:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "n,s = list(input()), str(int(input()));\nn.sort();\nif len(n)>1:\n for x in n:\n if x!='0':\n ans=x;\n break;\n n.remove(ans);\n n.insert(0, ans);\nn=''.join(n);\nprint(['WRONG_ANSWER','OK'][n==s]);\n"}, {"source_code": "s=input()\ns1=input()\n\nif(len(s)!=len(s1)):\n print('WRONG_ANSWER')\n exit()\nl=[]\nmn=10**9+7\nln=0\nfor i in s:\n ln+=1\n k=int(i)\n if(k!=0 and k<mn):\n mn=k\n\n l.append(k)\n\nl=sorted(l)\nif(l[0]==0):\n for i in range(ln):\n if(l[i]==mn):\n del l[i]\n break\n s=[str(i) for i in l]\n s2=''.join(s)\n s2=str(mn)+s2\nelse:\n s = [str(i) for i in l]\n s2 = ''.join(s)\n\nif(s1==s2):\n print('OK')\nelse:\n print('WRONG_ANSWER')\n\n\n"}, {"source_code": "import collections\nnum1=input()\nnum2=input()\ninp=[int(i) for i in num1]\noutp=[int(i) for i in num2]\nnumbers=[0]*10#\u043d\u0443\u043b\u0435\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u043d\u0443\u043b\u0435\u0439, \u043f\u0435\u0440\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0435\u0434\u0438\u043d\u0438\u0446, \u0432\u0442\u043e\u0440\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0434\u0432\u043e\u0435\u043a \u0438 \u0442 \u0434\nnumbers_out=[0]*10\nunique_nums=0\nfor i in range(len(inp)):\n numbers[inp[i]]+=1\n if numbers[inp[i]]==1:\n unique_nums+=1\n if i<len(outp):\n numbers_out[outp[i]]+=1\nans=True\nif collections.Counter(numbers)!=collections.Counter(numbers_out):\n ans=False\nif len(inp)!=len(outp):\n ans=False\nhave_been=set()\ndef min_set(a):\n a1=a.copy()\n if 0 in a1:\n a1.remove(0)\n if len(a1)>0:\n return min(a1)\n else:\n return -1\n\nfor j in range(len(outp)):\n i=outp[j]\n if numbers[i]==0:\n ans=False\n if i>0 and i<min_set(have_been):\n ans=False\n if len(have_been)>0 and i!=0:\n if i<max(have_been):\n ans=False\n if i==0 and len(have_been)!=1:\n ans=False\n if len(have_been)==1:\n g=have_been.pop()\n have_been.add(g)\n if numbers[g]!=0 and i!=g:\n ans=False\n if i==0 and numbers[g]==0 and j!=1:\n ans=False\n have_been.add(i)\n numbers[i]-=1\n \nif ans:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "l=list(input())\nm=int(input())\nl.sort()\n\ne=0\nif(l[0]=='0'):\n for i in range(1,len(l)):\n if(l[i]!='0'):\n l[0]=l[i]\n l[i]='0'\n e=1\n break\n if(e==1):\n break\nn=int(\"\".join(l))\nif(n==m):\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "n = input()\nm = input()\nndigits = []\nfor i in n:\n ndigits.append(i)\n\nsnd = sorted(ndigits)\nnumberofzeros = 0\nfor i in range(0,len(snd)):\n if snd[i] != '0':\n numberofzeros = i\n break\nnumberofones = 0\nfor i in range(numberofzeros,len(snd)):\n if snd[i] != '1':\n numberofones = i-numberofzeros\n break\n\notherdigits = snd[numberofzeros+numberofones:]\nanswer = '1'*numberofones+'0'*numberofzeros\nfor j in otherdigits:\n answer = answer+j\nif m == answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "\na = raw_input()\nb = raw_input()\n\nif(b[0] != '0'):\n\tz = a.count('0')*'0'\n\tu = a.count('1')*'1'\n\td = a.count('2')*'2'\n\tt = a.count('3')*'3'\n\tq = a.count('4')*'4'\n\tc = a.count('5')*'5'\n\ts = a.count('6')*'6'\n\te = a.count('7')*'7'\n\to = a.count('8')*'8'\n\tn = a.count('9')*'9'\n\n\ttup = [u,d,t,q,c,s,e,o,n]\n\ttup.sort()\n\ttup.insert(1,z)\n\tc = \"\"\n\tfor x in range(len(tup)):\n\t\tc = c + tup[x]\n\n\tif (c==b):\n\t\tprint \"OK\"\n\telse:\n\t\tprint \"WRONG_ANSWER\"\nelse:\n\tprint \"WRONG_ANSWER\"\n"}, {"source_code": "first =list(input())# \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 ['3', '3', '1', '0']\nsecond = input() \nout=\"\"\nif first[-1] == \"0\": # \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 0, \u0442\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0441 \u043a\u043e\u043d\u0446\u0430 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442 0 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\ti=2\n\twhile(i<len(first)):\n\t\tif (first[- i] != \"0\"):\n\t\t\tfirst[-1], first[- i] = first[- i],first[-1] # \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c\n\t\t\tbreak\n\t\ti+=1\ni=1\nwhile(i<=len(first)): # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441 \u043a\u043e\u043d\u0446\u0430 \n\tout += first[-i]\n\ti+=1\nprint(out)\nif out == second:#\u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \n\tprint(\"OK\")\nelse: print(\"WRONG_ANSWER\")"}, {"source_code": "import collections\nnum1=input()\nnum2=input()\ninp=[int(i) for i in num1]\noutp=[int(i) for i in num2]\nnumbers=[0]*10#\u043d\u0443\u043b\u0435\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u043d\u0443\u043b\u0435\u0439, \u043f\u0435\u0440\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0435\u0434\u0438\u043d\u0438\u0446, \u0432\u0442\u043e\u0440\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0434\u0432\u043e\u0435\u043a \u0438 \u0442 \u0434\nnumbers_out=[0]*10\nunique_nums=0\nfor i in range(len(inp)):\n numbers[inp[i]]+=1\n if numbers[inp[i]]==1:\n unique_nums+=1\n if i<len(outp):\n numbers_out[outp[i]]+=1\nans=True\nif collections.Counter(numbers)!=collections.Counter(numbers_out):\n ans=False\nif len(inp)!=len(outp):\n ans=False\nhave_been=set()\ndef min_set(a):\n a1=a.copy()\n if 0 in a1:\n a1.remove(0)\n if len(a1)>0:\n return min(a1)\n else:\n return -1\n\nfor j in range(len(outp)):\n i=outp[j]\n if numbers[i]==0:\n ans=False\n if i>0 and i<min_set(have_been):\n ans=False\n if len(have_been)>0 and i!=0:\n if i<max(have_been):\n ans=False\n if i==0 and len(have_been)!=1:\n ans=False\n if len(have_been)==1:\n g=have_been.pop()\n have_been.add(g)\n if numbers[g]!=0 and i!=g:\n ans=False\n if i==0 and numbers[g]==0 and j!=1:\n ans=False\n have_been.add(i)\n numbers[i]-=1\n \nif ans:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "class A:\n\n def rotate_keypad(self, keypad):\n reversed_rows = list(reversed(keypad))\n return [\"\".join(list(reversed(x))) for x in reversed_rows]\n\n def solve(self):\n keypad = [input(), input(), input()]\n if keypad == self.rotate_keypad(keypad):\n print(\"YES\")\n else:\n print(\"NO\")\n\nclass B:\n\n def solve(self):\n alice = input()\n bob = int(input())\n\n from itertools import permutations\n\n smallest = int(alice)\n for perm in permutations(alice):\n if int(\"\".join(list(perm))) < smallest and \\\n not \"\".join(list(perm)).startswith(\"0\"):\n smallest = int(\"\".join(list(perm)))\n\n if smallest < bob:\n print(\"WRONG_ANSWER\")\n else:\n print(\"OK\")\n\nB().solve()\n"}, {"source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\n\na = map(int, raw_input())\nb = raw_input()\na = sorted(a)\na.reverse()\nif not list(set(a))[0] == 0 and len(set(a)) == 1:\n while a[-1] == 0:\n a.insert(-1, a.pop())\n a.reverse()\na = [str(i) for i in a]\nif \"\".join(a) == b:\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "number=str(raw_input())\ntab=[]\n\nbuff=[]\nfor i in number:\n tab.append(int(i))\n \ntab.sort()\n\nwhile 0 in tab:\n buff.append(tab[0])\n tab.remove(tab[0])\n \nfor i in buff:\n tab.insert(1, 0)\n \nif (int(''.join(map(str,tab))))==int(raw_input()):\n print 'OK'\nelse:\n print 'WRONG_ANSWER'\n \n "}, {"source_code": "\ndef getMinGreaterThanZero(s):\n asdf = s[:]\n minNumber = min(asdf)\n while (minNumber == 0):\n asdf[asdf.index(minNumber)] = 1000\n minNumber = min(asdf)\n if minNumber == 1000:\n return -1\n\n return minNumber\n\nimport sys\n\nn1 = sys.stdin.readline().strip()\nn2 = sys.stdin.readline().strip()\n\nn1 = map(int, list(str(int(n1))))\n\nless = []\n\nfirstMin = getMinGreaterThanZero(n1)\n\nif firstMin == -1:\n if int(n2) == 0:\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\n\n sys.exit(0)\n\n\nn1[n1.index(firstMin)] = 1000\n\nless.append(firstMin)\nfor i in range(1, len(n1)):\n minNum = min(n1)\n less.append(minNum)\n n1[n1.index(minNum)] = 1000\n\nless = ''.join(map(str, less))\n\nif int(less) == int(n2):\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\""}, {"source_code": "a=input()\nb=input()\nc=int(b)\nn=len(a)\nj=0\nA=[]\nwhile j<n:\n A.append(a[j])\n j=j+1\nj=1\nwhile j<n:\n key=A[j]\n i=j-1\n while i>-1 and A[i]>key:\n A[i+1]=A[i]\n i=i-1\n A[i+1]=key\n j=j+1\nd=int(A[0])\nj=0\nif d==0:\n while j<n:\n if int(A[j])>0:\n break\n j=j+1\n if j==n:\n i=j-1\n else:\n i=j\n A[0],A[i]=A[i],A[0]\nstr=''\nstr=str.join(A)\ne=int(b[0])\nnum=int(str)\n\nif e==0:\n print('WRONG_ANSWER')\nelif num==c:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "def solve():\n digits = [0]*10\n n = list(raw_input().strip())\n for i in n:\n digits[int(i)] += 1\n m = list(raw_input().strip())\n if len(n)!=len(m):\n print 'WRONG_ANSWER'\n return\n for i in xrange(1,10):\n if digits[i]!=0:\n if m[0] != str(i):\n print 'WRONG_ANSWER'\n return\n digits[i] -= 1\n m.pop(0)\n break\n for i in m:\n digits[int(i)] -= 1\n for i in digits:\n if i!=0:\n print 'WRONG_ANSWER'\n return\n print 'OK'\n\nsolve()\n"}, {"source_code": "class A:\n\n def rotate_keypad(self, keypad):\n reversed_rows = list(reversed(keypad))\n return [\"\".join(list(reversed(x))) for x in reversed_rows]\n\n def solve(self):\n keypad = [input(), input(), input()]\n if keypad == self.rotate_keypad(keypad):\n print(\"YES\")\n else:\n print(\"NO\")\n\nclass B:\n\n def solve(self):\n alice = list(input())\n bob = int(input())\n\n sorted_alice = sorted(alice)\n smallest_number = []\n done = False\n\n for j in range(len(sorted_alice)):\n if int(sorted_alice[j]) != 0:\n break\n\n if j == len(sorted_alice):\n smallest_number = [\"0\"]\n done = True\n\n if not done:\n smallest_number = [sorted_alice[j]]\n sorted_alice[j] = -1\n\n for i in range(len(alice)):\n if int(sorted_alice[i]) < 0:\n continue\n smallest_number.append(sorted_alice[i])\n\n smallest_number = int(\"\".join(smallest_number))\n if smallest_number < bob:\n print(\"WRONG_ANSWER\")\n else:\n print(\"OK\")\n\nB().solve()\n"}, {"source_code": "def Ordenar(N):\n Ordenado = ''\n A = [0]*10\n for k in N:\n for i in range (0,10):\n if int(k)==i:\n A[i] += 1\n Aux = 0\n for k in range (1,10):\n if A[k]!=0:\n Aux = k\n break\n Ordenado = str(Aux)\n for j in range (A[0]):\n Ordenado += str(0)\n for k in range (2,10):\n if A[k]!=0:\n for i in range(A[k]):\n Ordenado += str(k)\n return Ordenado\nA = input()\nB = input()\nOrd = Ordenar(A)\nif Ord == B:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "s=[int(n) for n in input()]\nz=[int(n) for n in input()]\ns.sort()\nm=v=0\nfor n in range(len(s)):\n\tif s[n]!=0:\n\t\ts[0]=s[n]\n\t\ts[n]=0\n#1\u00b3print(s)\nfor n in range(len(s)):\n\tm+=s[n]*10**(n)\nfor n in range(len(z)):\n\tv+=z[n]*10**(n)\nif m==v:\n\tprint('OK')\nelse:\n\tprint('WRONG_ANSWER')\n\t\t"}, {"source_code": "s = [int(ch) for ch in input()]\nss = [int(ch) for ch in input()]\nif s==[0] and ss==[0]:\n print(\"OK\")\n exit()\ns.sort()\nans=[]\nfor i in range(len(s)):\n if s[i]!=0:\n ans.append(s[i])\n break\nfor j in range(i):\n ans.append(0)\nfor k in range(i+1,len(s)):\n ans.append(s[k])\nprint(ans) \nif ans==ss:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")\n "}, {"source_code": "n = input()\nm = input()\nmint = int(m)\n\nshifts = []\nfor i in range(0,len(n)):\n if n[i] != '0':\n shifts.append(n[i:]+n[:i])\n\nfor j in range(0,len(shifts)):\n shifts[j] = int(shifts[j])\n\nanswer = min(shifts)\nif answer == mint:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "\na = raw_input()\nb = raw_input()\n\nz = a.count('0')*'0'\nu = a.count('1')*'1'\nd = a.count('2')*'2'\nt = a.count('3')*'3'\nq = a.count('4')*'4'\nc = a.count('5')*'5'\ns = a.count('6')*'6'\ne = a.count('7')*'7'\no = a.count('8')*'8'\nn = a.count('9')*'9'\n\ntup = [u,d,t,q,c,s,e,o,n]\ntup.sort()\ntup.insert(1,z)\nc = \"\"\nfor x in range(len(tup)):\n\tc = c + tup[x]\n\nif (c==b):\n\tprint \"OK\"\nelse:\n\tprint \"WRONG_ANSWER\"\n"}, {"source_code": "n=raw_input()\nmini=(1<<31)-1\nfor i in range(len(n)):\n\tif n[i]!='0':\n\t\tmini=min(mini,int(n[i:]+n[:i]))\nif mini==int(raw_input()):\n\tprint 'OK'\nelse:\n\tprint 'WRONG_ANSWER'\n"}, {"source_code": "import sys\nimport itertools\n\nno = raw_input()\nans = raw_input()\nl = len(no)\norignans = ans\nans = ans[-l::1]\nif int(ans[0])==0 or len(orignans)!=l:\n\tprint \"WRONG_ANSWER\"\n\tsys.exit()\n\nsmallest = int(no)\n\nfor permut in itertools.permutations(no, l):\n\t#permut = \"\".join(list(permut))\n\tif permut[0]!=\"0\":\n\t\tpermut = int(\"\".join(list(permut)))\n\t\tif permut<smallest:\n\t\t\tsmallest = permut\n#print \"Smallest: \", smallest\nif int(orignans)==smallest:\n\tprint \"OK\"\nelse:\n\tprint \"WRONG_ANSWER\"\n\n"}, {"source_code": "number=str(raw_input())\ntab=[]\n\nbuff=[]\nfor i in number:\n tab.append(int(i))\n \ntab.sort()\n\nwhile 0 in tab:\n buff.append(tab[0])\n tab.remove(tab[0])\n \nfor i in buff:\n tab.insert(1, 0)\n \nif (int(''.join(map(str,tab))))==int(raw_input()):\n print 'OK'\nelse:\n print 'WRONG_ANSWER'\n \n "}, {"source_code": "d=raw_input()\nx=int(raw_input())\nm=''\nres=''\nresult=''\nfor i in range(0,len(d)):\n m=m+\" \"+d[i:i+1]\n \nm=m[1:len(m)]\nm=m.split()\nk=0 \nfor i2 in range(0,len(m)):\n \n m[i2]=int(m[i2])\n if(m[i2]==0):\n k=k+1 \n \n \nm=sorted(m)\nif(len(m)==1)&(m[0]==0):\n k=9\n res=0\nfor i in range(0,len(m)):\n m[i]=str(m[i])\nif(k==1):\n res=m[1]+m[0]\n for i in range(2,len(m)):\n res=res+m[i]\n \nif(k==2):\n res=m[2]+m[1]+m[0]\n for i in range(3,len(m)):\n res=res+m[i]\nif(k==3):\n res=m[3]+m[2]+m[1]+m[0]\n for i in range(4,len(m)):\n res=res+m[i]\nif(k==4):\n res=m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(5,len(m)):\n res=res+m[i]\nif(k==5):\n res=m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(6,len(m)):\n res=res+m[i]\nif(k==6):\n res=m[6]+m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(7,len(m)):\n res=res+m[i]\nif(k==7):\n res=m[7]+m[6]+m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(8,len(m)):\n res=res+m[i]\nif(k==8):\n res=res[8]+m[7]+m[6]+m[5]+m[4]+m[3]+m[2]+m[1]+m[0]\n for i in range(9,len(m)):\n res=res+m[i]\nif(k==0):\n for i in range(0,len(m)):\n res=res+m[i]\nres=int(res)\nif(res==x):\n print(\"OK\")\nif(res!=x):\n print(\"WRONG_ANSWER\")\n \n \n \n"}, {"source_code": "number=str(raw_input())\ntab=[]\n\nbuff=[]\nfor i in number:\n tab.append(int(i))\n \ntab.sort()\n\nwhile 0 in tab:\n buff.append(tab[0])\n tab.remove(tab[0])\n \nfor i in buff:\n tab.insert(1, 0)\n \nif (int(''.join(map(str,tab))))==int(raw_input()):\n print 'OK'\nelse:\n print 'WRONG_ANSWER'\n \n "}, {"source_code": "\na = raw_input()\nb = raw_input()\n\nz = a.count('0')*'0'\nu = a.count('1')*'1'\nd = a.count('2')*'2'\nt = a.count('3')*'3'\nq = a.count('4')*'4'\nc = a.count('5')*'5'\ns = a.count('6')*'6'\ne = a.count('7')*'7'\no = a.count('8')*'8'\nn = a.count('9')*'9'\n\ntup = [u,d,t,q,c,s,e,o,n]\nresult = ''\nfirst = True\nfor x in range(len(tup)):\n\tif(first and tup[x] != '' and z != ''):\n\t\tresult = result + tup[x][0] + z\n\t\tresult = result + tup[x][1:]\n\t\tfirst = False\n\telse:\n\t\tresult = result + tup[x]\n\nif (result==b ):\n\tprint 'OK'\nelse:\n\tprint 'WRONG_ANSWER'\n"}, {"source_code": "n=raw_input()\nmini=(1<<31)-1\ndigits=[0]*10\nfor x in n:\n\tdigits[int(x)]+=1\nfor i in range(1,10):\n\tif digits[i]!=0:\n\t\tbreak\nmini=str(i)+'0'*digits[0]\ndigits[i]-=1\nwhile i<10:\n\tmini+=str(i)*digits[i]\n\ti+=1\nif mini==raw_input():\n\tprint 'OK'\nelse:\n\tprint 'WRONG_ANSWER'\n"}, {"source_code": "import collections\nnum1=input()\nnum2=input()\ninp=[int(i) for i in num1]\noutp=[int(i) for i in num2]\nnumbers=[0]*10#\u043d\u0443\u043b\u0435\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u043d\u0443\u043b\u0435\u0439, \u043f\u0435\u0440\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0435\u0434\u0438\u043d\u0438\u0446, \u0432\u0442\u043e\u0440\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0434\u0432\u043e\u0435\u043a \u0438 \u0442 \u0434\nnumbers_out=[0]*10\nunique_nums=0\nfor i in range(len(inp)):\n numbers[inp[i]]+=1\n if numbers[inp[i]]==1:\n unique_nums+=1\n if i<len(outp):\n numbers_out[outp[i]]+=1\nans=True\nif collections.Counter(numbers)!=collections.Counter(numbers_out):\n ans=False\nif len(inp)!=len(outp):\n ans=False\nhave_been=set()\ndef min_set(a):\n a1=a.copy()\n if 0 in a1:\n a1.remove(0)\n if len(a1)>0:\n return min(a1)\n else:\n return -1\nfor i in outp:\n if numbers[i]==0:\n ans=False\n if i>0 and i<min_set(have_been):\n ans=False\n if len(have_been)>0:\n if i<max(have_been):\n ans=False\n if i==0 and len(have_been)!=1:\n ans=False\n have_been.add(i)\n numbers[i]-=1\nif ans:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "class A:\n\n def rotate_keypad(self, keypad):\n reversed_rows = list(reversed(keypad))\n return [\"\".join(list(reversed(x))) for x in reversed_rows]\n\n def solve(self):\n keypad = [input(), input(), input()]\n if keypad == self.rotate_keypad(keypad):\n print(\"YES\")\n else:\n print(\"NO\")\n\nclass B:\n\n def solve(self):\n alice = input()\n bob = int(input())\n\n from itertools import permutations\n\n smallest = int(alice)\n if smallest != 0:\n for perm in permutations(alice):\n if int(\"\".join(list(perm))) < smallest and \\\n not \"\".join(list(perm)).startswith(\"0\"):\n smallest = int(\"\".join(list(perm)))\n\n if smallest < bob:\n print(\"WRONG_ANSWER\")\n else:\n print(\"OK\")\n\nB().solve()\n"}, {"source_code": "num1=input()\nnum2=input()\ninp=[int(i) for i in num1]\noutp=[int(i) for i in num2]\nnumbers=[0]*10#\u043d\u0443\u043b\u0435\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u043d\u0443\u043b\u0435\u0439, \u043f\u0435\u0440\u0432\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0435\u0434\u0438\u043d\u0438\u0446, \u0432\u0442\u043e\u0440\u0430\u044f - \u0447\u0438\u0441\u043b\u043e \u0434\u0432\u043e\u0435\u043a \u0438 \u0442 \u0434\nunique_nums=0\nfor i in inp:\n numbers[i]+=1\n if numbers[i]==1:\n unique_nums+=1\nans=True\nhave_been=set()\ndef min_set(a):\n a1=a.copy()\n if 0 in a1:\n a1.remove(0)\n if len(a1)>0:\n return min(a1)\n else:\n return -1\nfor i in outp:\n if numbers[i]==0:\n ans=False\n if i>0 and i<min_set(have_been):\n ans=False\n if i==0 and len(have_been)!=1:\n ans=False\n have_been.add(i)\n numbers[i]-=1\nif ans:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "n=int(input())\nm=int(input())\nr=n\n# print(r)\narr=[]\nwhile r!=0:\n s=r%10\n # print(s)\n arr.append(s)\n r=r//10\narr1=arr[::-1]\narr1.sort()\n# print(arr1)\ncount=0\nfor i in range(0,len(arr)):\n if arr1[i]==0:\n count+=1\n else:\n break\nif count>0:\n t=arr1[0]\n arr1[0]=arr1[count]\n arr1[count]=t\ns=0\n# print(arr1)\nfor i in range(0,len(arr1)):\n s=s*10+arr1[i]\nprint(s)\nif s==m:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "l=list(input())\nm=int(input())\nl.sort()\n\ne=0\nif(l[0]=='0'):\n for i in range(1,len(l)):\n if(l[i]!='0'):\n l[0]=l[i]\n l[i]='0'\n e=1\n break\n if(e==1):\n break\nn=int(\"\".join(l))\nif(n==m):\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "import sys\nfrom itertools import product\n\nfile = sys.stdin\n#file = open(\"test\", \"r\")\np = map(int, list(file.readline().rstrip()))\np.sort()\nfor i in range(len(p)):\n if p[i] != 0:\n temp = p.pop(i)\n p.insert(0, temp)\n break\n\nans = \"\".join(map(str, p))\nbro = file.readline().rstrip()\nif ans == bro:\n print \"YES\"\nelse:\n print \"NO\"\n\n\n"}, {"source_code": "n = list(input())\nm = input()\n\nif len(n) > 1:\n\n\tn.sort()\n\tif n[0] == '0':\n\t\tans = n[1]\n\t\tans += str(n[0])+''.join(n[2:])\n\telse:\n\t\tans = ''.join(n)\nelse:\n\tans = n\n\n#print(ans)\nif ans == m :\n\tprint(\"OK\")\nelse:\n\tprint(\"WRONG_ANSWER\")"}, {"source_code": "import sys\nimport math\n\nn = sys.stdin.readline()\nm = sys.stdin.readline()\nl = len(n) - 1\nk = [0] * 10\n\nres = 0\nfor i in range(l):\n k[int(n[i])] += 1\n \nz = []\nfor i in range(1, 10):\n if(k[i] != 0):\n z.append(str(i))\n k[i] -= 1\n break\n \nz.extend(\"0\" * k[0])\n\nfor i in range(1, 10):\n if(k[i] != 0):\n z.extend(str(i) * k[i])\n\nif(int(n) == 0 and len(m) - 1 != 1):\n print(\"WRONG_ANSWER\") \n exit()\n \nif(int(\"\".join(z)) == int(m)):\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\") \n \n \n \n"}, {"source_code": "\na = raw_input()\nb = raw_input()\n\nz = a.count('0')*'0'\nu = a.count('1')*'1'\nd = a.count('2')*'2'\nt = a.count('3')*'3'\nq = a.count('4')*'4'\nc = a.count('5')*'5'\ns = a.count('6')*'6'\ne = a.count('7')*'7'\no = a.count('8')*'8'\nn = a.count('9')*'9'\n\ntup = [u,d,t,q,c,s,e,o,n]\nresult = ''\nfirst = True\nfor x in range(len(tup)):\n\tif(first and tup[x] != '' and z != ''):\n\t\tresult = result + tup[x][0] + z\n\t\tresult = result + tup[x][1:]\n\t\tfirst = False\n\telse:\n\t\tresult = result + tup[x]\n\nif(first):\n\tresult = z\n\nif (result==b ):\n\tprint 'OK'\nelse:\n\tprint 'WRONG_ANSWER'\n"}, {"source_code": "n=int(input())\nans=int(input())\nn1=str(n)\nn1=list(n1)\nif n==0:\n print('OK' if n==ans else 'WRONG_ANSWER')\nelif '0' not in n1:\n ans1=''.join(sorted(n1))\n if int(ans1)==ans:\n print('OK')\n else:\n print('WRONG_ANSWER')\nelse:\n ans1=sorted(n1)\n c=ans1.count('0')\n ans1=[i for i in ans1 if i!='0']\n for i in range(c):\n ans1.insert(1,'0')\n ans1=''.join(ans1)\n if int(ans1)==ans:\n print('OK')\n else:\n print('WRONG_ANSWER')"}, {"source_code": "a = raw_input()\nb = raw_input()\n\nf = b[0]\n\nif(len(a) == len(b)):\n if(b[0] != \"0\" and len(b) > 1):\n aux = True\n for i in xrange(1, len(b)):\n if(i == 1):\n if((not (b[i-1] <= b[i])) and b[i] != \"0\"):\n aux = False\n elif((not (b[i-1] <= b[i]))):\n aux = False\n if(aux):\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n elif(len(b) == 0):\n if(b == a):\n print(\"OK\")\n else:\n print(\"WRONG_ANSWER\")\n else:\n print(\"WRONG_ANSWER\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "c=[0]*10\nfor x in input():\n c[ord(x)-ord('0')]+=1\nt=[]\nt.append(c[1]*'1')\nt.append(c[0]*'0')\nfor i in range(2,10):\n if c[i]==0:\n continue\n t.append(c[i]*chr(ord('0')+i))\ns=input()\nif s[0]!='0' and s==''.join(t):\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "n = input()\nm = input()\nndigits = []\nfor i in n:\n ndigits.append(i)\n\nsnd = sorted(ndigits)\nnumberofzeros = 0\nfor i in range(0,len(snd)):\n if snd[i] != '0':\n numberofzeros = i\n break\nnumberofones = 0\nfor i in range(numberofzeros,len(snd)):\n if snd[i] != '1':\n numberofones = i-numberofzeros\n break\n\notherdigits = snd[numberofzeros+numberofones:]\nanswer = '1'*numberofones+'0'*numberofzeros\nfor j in otherdigits:\n answer = answer+j\nif m == answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "def sort(items):\n\tc = -1\n\n\twhile c != 0:\n\t\tc = 0\n\n\t\tfor i in range(0, len(items) - 1):\n\t\t\tif items[i] > items[i + 1]:\n\t\t\t\titems[i], items[i + 1] = items[i + 1], items[i]\n\t\t\t\tc += 1\n\n\treturn items\n\ndef listToInt(items):\n\tresult = 0\n\n\tfor i in range(len(items) - 1, -1, -1):\n\t\tresult += items[i] * (10**(len(items) - i - 1))\n\treturn result\n\nquestion = list(input())\nanswer = int(input())\n\nfor i in range(0, len(question)):\n\tquestion[i] = int(question[i])\n\nquestion = sort(question)\n\nif question[0] == 0:\n\tfound = -1\n\n\tfor i in range(0, len(question)):\n\t\tif question[i] != 0:\n\t\t\tfound = i\n\t\t\tbreak\n\n\tif found != -1:\n\t\tquestion[0], question[found] = question[found], question[0]\n\nif listToInt(question) == answer:\n\tprint(\"OK\")\nelse:\n\tprint(\"WRONG_ANSWER\")"}, {"source_code": "n, shuffled = sorted([int(d) for d in input()]), int(input())\nzeros = n.count(0)\nn = n[zeros:zeros+1] + [0] * zeros + n[zeros+1:]\nprint(\"OK\") if int(\"\".join(map(str, n))) == shuffled else print(\"WRONG_ANSWER\")"}, {"source_code": "import sys\nimport itertools\n\nno = raw_input()\nans = raw_input()\nl = len(no)\norignans = ans\nans = ans[-l::1]\n#if int(ans[0])==0:\n#\tprint \"WRONG_ANSWER\"\n#\tsys.exit()\n\nsmallest = int(no)\n\nfor permut in itertools.permutations(no, l):\n\t#permut = \"\".join(list(permut))\n\tif permut[0]!=\"0\":\n\t\tpermut = int(\"\".join(list(permut)))\n\t\tif permut<smallest:\n\t\t\tsmallest = permut\n#print \"Smallest: \", smallest\nif int(orignans)==smallest:\n\tprint \"OK\"\nelse:\n\tprint \"WRONG_ANSWER\"\n\n"}, {"source_code": "n, shuffled = sorted([int(d) for d in input()]), int(input())\nzeros = n.count(0)\nn = n[zeros:zeros+1] + [0] * zeros + n[zeros+1:]\nprint(\"OK\") if int(\"\".join(map(str, n))) == shuffled else print(\"WRONG_ANSWER\")"}, {"source_code": "\ndef getMinGreaterThanZero(s):\n asdf = s[:]\n minNumber = min(asdf)\n while (minNumber == 0):\n asdf[asdf.index(minNumber)] = 1000\n minNumber = min(asdf)\n if minNumber == 1000:\n return -1\n\n return minNumber\n\nimport sys\n\nn1 = sys.stdin.readline().strip()\nn2 = sys.stdin.readline().strip()\n\nn1 = map(int, list(str(int(n1))))\n\nless = []\n\nfirstMin = getMinGreaterThanZero(n1)\n\nif firstMin == -1:\n if int(n2) == 0:\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\n\n sys.exit(0)\n\n\nn1[n1.index(firstMin)] = 1000\n\nless.append(firstMin)\nfor i in range(1, len(n1)):\n minNum = min(n1)\n less.append(minNum)\n n1[n1.index(minNum)] = 1000\n\nless = ''.join(map(str, less))\n\nif int(less) == int(n2):\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\""}, {"source_code": "s=input()\nt=input()\n\nx=[]\nfor i in range(10):\n x += [s.count(str(i))]\n\nans = \"\"\nfor i in range(1, 10):\n if x[i]:\n ans += str(i)\n x[i] -= 1\n\nfor i in range(10):\n ans += str(i) * x[i]\n\nprint(\"OK\" if ans==t else \"WRONG_ANSWER\")"}, {"source_code": "\na = raw_input()\nb = raw_input()\n\nz = a.count('0')*'0'\nu = a.count('1')*'1'\nd = a.count('2')*'2'\nt = a.count('3')*'3'\nq = a.count('4')*'4'\nc = a.count('5')*'5'\ns = a.count('6')*'6'\ne = a.count('7')*'7'\no = a.count('8')*'8'\nn = a.count('9')*'9'\n\ntup = [u,d,t,q,c,s,e,o,n]\nresult = \"\"\nfirst = True\nfor x in range(len(tup)):\n\tif(tup[x] != '' and first):\n\t\tresult = result + tup[x] + z\n\t\tfirst = False\n\telse:\n\t\tresult = result + tup[x]\n\t\t\nif (result==b and b[0] != '0'):\n\tprint \"OK\"\nelse:\n\tprint \"WRONG_ANSWER\"\n"}, {"source_code": "n = input()\nm = input()\nmint = int(m)\n\nshifts = []\nfor i in range(0,len(n)):\n if n[i] != '0':\n shifts.append(n[i:]+n[:i])\n\nfor j in range(0,len(shifts)):\n shifts[j] = int(shifts[j])\n\nanswer = min(shifts)\nif answer == mint:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "b=str(input())\nlu=int(input())\nif int(b)<10:\n z=int(b)\n\n \nelse:\n a=[]*len(b)\n lo=0\n for i in range (0,len(b)):\n a.append(int(b[i]))\n\n\n for k in range (1,len(a)):\n for t in range (len(a)-k):\n if (a[t])>(a[t+1]):\n p=(a[t])\n a[t]=(a[t+1])\n a[t+1]=p\n \n\n g=0\n while a[0]==0:\n a.remove(0)\n g=g+1\n z=a[0]\n if len(a)==1:\n z=int(b)\n else:\n del a[0]\n q=str(a[0])\n for i in range (1,len(a)):\n q+=\"\"+str(a[i])\n z=str(z)+str(0)*g+q\n z=int(z)\n\nif lu==z:\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "n = raw_input()\nm = raw_input()\nn = sorted(n)\ns = \"\"\nfor i in n:\n if i != 0:\n s += i\n n.remove(i)\n break\nfor i in n:\n s += i\nif s == m:\n print \"OK\"\nelse:\n print \"WRONG_ANSWER\"\n"}, {"source_code": "x = raw_input()\nanswer = raw_input()\n\nif (x == '0'):\n if (answer[0] == '0') and (answer.lstrip('0') == ''):\n print 'OK'\n else:\n print 'WRONG_ANSWER'\n\nelse:\n \n answer = answer.lstrip('0')\n\n countnum = []\n for number in range(10):\n countnum.append(x.count(str(number)))\n ##print countnum\n\n\n num = ''\n for i in range(1,10):\n num = num + str(i) * countnum[i]\n\n zeros = '0' * countnum[0]\n\n ##print zeros\n\n\n r_ans = num[0] + zeros + num[1:]\n ##print r_ans\n if r_ans == answer:\n print 'OK'\n else:\n print 'WRONG_ANSWER'\n"}, {"source_code": "n = input()\nm = input()\nmzeros = 0\nfor i in range(0,len(m)):\n if m[i] != '0':\n mzeros = i\n break\nm = m[mzeros:]\nndigits = []\nfor i in n:\n ndigits.append(i)\n\nsnd = sorted(ndigits)\nnumberofzeros = 0\nfor i in range(0,len(snd)):\n if snd[i] != '0':\n numberofzeros = i\n break\nnumberofones = 0\nfor i in range(numberofzeros,len(snd)):\n if snd[i] != '1':\n numberofones = i-numberofzeros\n break\nif snd[len(snd)-1] == '1':\n numberofones = len(snd)-numberofzeros\notherdigits = snd[numberofzeros+numberofones:]\nif numberofones >= 1:\n answer = '1'+'0'*numberofzeros+'1'*(numberofones-1)\n for j in otherdigits:\n answer = answer+j\nelse:\n answer = snd[numberofzeros]+'0'*numberofzeros\n for j in otherdigits[1:]:\n answer = answer+j\n \nif n == '0':\n for i in range(1,11):\n if m == '0':\n print('OK')\n else:\n print('WRONG_ANSWER')\nelif m == answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "a = list(raw_input())\nb = list(raw_input())\n\n\nif a[0] == '0' == b[0] and len(b) == 1:\n\tprint \"OK\"\n\nelse:\n\tif b[0] == '0':\n\t\tprint \"WRONG_ANSWER\"\n\t\texit()\n\t\n\tb.sort()\n\ta.sort()\n\t\n\tif a == b:\n\t\tprint \"OK\"\n\t\n\telse:\n\t\tprint \"WRONG_ANSWER\"\n"}, {"source_code": "n = input()\nm = input()\nmzeros = 0\nfor i in range(0,len(m)):\n if m[i] != '0':\n mzeros = i\n break\nm = m[mzeros:]\nndigits = []\nfor i in n:\n ndigits.append(i)\n\nsnd = sorted(ndigits)\nnumberofzeros = 0\nfor i in range(0,len(snd)):\n if snd[i] != '0':\n numberofzeros = i\n break\nnumberofones = 0\nfor i in range(numberofzeros,len(snd)):\n if snd[i] != '1':\n numberofones = i-numberofzeros\n break\nif snd[len(snd)-1] == '1':\n numberofones = len(snd)-numberofzeros\notherdigits = snd[numberofzeros+numberofones:]\nif numberofones >= 1:\n answer = '1'+'0'*numberofzeros+'1'*(numberofones-1)\n for j in otherdigits:\n answer = answer+j\nelse:\n answer = snd[numberofzeros]+'0'*numberofzeros\n for j in otherdigits[1:]:\n answer = answer+j\n \nif n == '0':\n if m == '0':\n print('OK')\n else:\n print('WRONG_ANSWER')\n \nelif m == answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "s = str(raw_input())\nss = str(raw_input())\nn = len(s)\nflg = True\ns = sorted(s)\ni = 0\nif s[i]=='0':\n ind = 0\n while i<n and s[i]=='0':\n i+=1\n if i<n:\n s[ind],s[i] = s[i],s[ind]\n flg = True\n else:\n flg = False\nif flg:\n s = ''.join(s)\n if s==ss:\n print \"OK\"\n else:\n print \"WRONG_ANSWER\"\nelse:\n if s==ss:\n print \"OK\"\n else:\n print \"WRONG_ANSWER\""}, {"source_code": "n = input() # \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\nk = input() # \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nl1 = len(n)\nl2 = len(k)\n\n# \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\na = [0]*10\n\nif (k[0] == '0') or (l2 > l1):\n print('WRONG_ANSWER')\nelse:\n for i in range(l1):\n a[int(n[i])] += 1\n # \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd:\n # \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd 0, \ufffd\ufffd\ufffd\ufffd\ufffd 0, \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n s = ''\n \n pos = 1\n while (pos < 10) and (a[pos] == 0):\n pos += 1\n \n if pos != 10:\n s += str(pos)+'0'*a[0]\n a[pos] -= 1\n for i in range(pos, 10):\n s += str(i)*a[i]\n # \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n \n if s == k:\n print('OK')\n else:\n print('WRONG_ANSWER')\n \n else:\n print('WRONG_ANSWER')"}, {"source_code": "n = input()\nm = input()\nmint = int(m)\n\nshifts = []\nfor i in range(0,len(n)):\n if n[i] != '0':\n shifts.append(n[i:]+n[:i])\n\nfor j in range(0,len(shifts)):\n shifts[j] = int(shifts[j])\n\nanswer = min(shifts)\nif answer == mint:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "IN = lambda: raw_input()\na, b = IN(), IN()\n\nif b[0] == '0':\n print 'WRONG_ANSWER'\nelse :\n a = sorted(a)\n if a[0] == '0':\n LL = len(a)\n for i in xrange(LL):\n if a[i] != '0':\n a[0] = a[i]; a[i]='0'\n break\n ss =\"\"\n for i in a:\n ss += i\n a = ss\n print 'OK' if cmp(a, b)==0 else 'WRONG_ANSWER'\n\n"}, {"source_code": "IN = lambda: raw_input()\na, b = IN(), IN()\n\nif b[0] == '0':\n print 'WRONG_ANSWER'\nelse :\n a = sorted(a)\n if a[0] == '0':\n LL = len(a)\n for i in xrange(LL):\n if a[i] != '0':\n a[0] = a[i]; a[i]='0'\n break\n ss =\"\"\n for i in a:\n ss += i\n a = ss\n print 'OK' if cmp(a, b)==0 else 'WRONG_ANSWER'\n\n"}, {"source_code": "n = input()\nm = input()\nmzeros = 0\nfor i in range(0,len(m)):\n if m[i] != '0':\n mzeros = i\n break\nm = m[mzeros:]\nndigits = []\nfor i in n:\n ndigits.append(i)\n\nsnd = sorted(ndigits)\nnumberofzeros = 0\nfor i in range(0,len(snd)):\n if snd[i] != '0':\n numberofzeros = i\n break\nnumberofones = 0\nfor i in range(numberofzeros,len(snd)):\n if snd[i] != '1':\n numberofones = i-numberofzeros\n break\nif snd[len(snd)-1] == '1':\n numberofones = len(snd)-numberofzeros\notherdigits = snd[numberofzeros+numberofones:]\nif numberofones >= 1:\n answer = '1'+'0'*numberofzeros+'1'*(numberofones-1)\n for j in otherdigits:\n answer = answer+j\nelse:\n answer = snd[numberofzeros]+'0'*numberofzeros\n for j in otherdigits[1:]:\n answer = answer+j\n \nif n == '0':\n for i in range(1,11):\n if m == '0'*i:\n print('OK')\nelif m == answer:\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "s=input()\ns1=(input())\nn=len(s)\nw=[]\nd=0\nfor i in range(0,n):\n w.append(int(s[i]))\nw.sort()\nfor i in range(0,n):\n if(w[i]!=0):\n q=i\n d=d+1\n break\nif(d==0):\n print(\"WRONG_ANSWER\")\n exit(0)\nelse:\n s2=str(w[q])\nfor i in range(0,n):\n if(i!=q):\n s2=s2+str(w[i])\nif(s2==s1 and int(s)>0):\n print(\"OK\")\nelse:\n print(\"WRONG_ANSWER\")"}, {"source_code": "a = raw_input()\nb = raw_input()\ns = list(a)\ns.sort()\nif (s[0]=='0'):\n\tfor i in xrange(len(a)):\n\t\tif (s[i]>'0'):\n\t\t\tt = s[i]\n\t\t\ts[i] = '0'\n\t\t\ts[0] = t\n\t\t\tbreak\nprint (\"WRONG_ANSWER\",\"OK\")[''.join(a) == b]\n"}, {"source_code": "n,s = input(), str(int(input()));\nb = n;\nn=list(n);\nn.sort();\nif len(n)>1:\n for x in n:\n if x!='0':\n ans=x;\n break;\n n.remove(ans);\n n.insert(0, ans);\nn=''.join(n);\nprint(['WRONG_ANSWER','OK'][n==s and b>n]);\n"}, {"source_code": "s = raw_input();\nt = raw_input();\n\nflag = 1;\nfor i in range(len(s)):\n\tif s.count(s[i]) != t.count(s[i]):\n\t\tflag = 0; break;\n#print flag\npos = 0\n\nif t[0] == '0':\n\tflag = 0;\nif flag:\n\tfor i in range(pos+1, len(t)):\n\t\tif t[i] == '0' and i == pos+1:\n\t\t\tcontinue;\n\t\tif t[i] < t[i-1]:\n\t\t\tflag = 0; break;\nprint \"OK\" if flag else \"WRONG_ANSWER\";\n"}, {"source_code": "n =int(input())\nm =int(input())\nt=\"\"\nif(int(n)==0):\n if(m==0): print(\"OK\")\n else: print(\"WRONG_ANSWER\")\nelse:\n n=str(n)\n n=sorted(n)\n for i in n:\n if(i!='0'):\n t+=i\n break\n for i in range(10):\n l = n.count(str(i))\n if(t[0]==str(i)): l-=1\n for j in range(l):\n t+= str(i)\n if(t==str(m)): print(\"OK\")\n else: print(\"WRONG_ANSWER\")"}, {"source_code": "a = input()\nn = [0] * 10\n\nfor x in a:\n y = int(x)\n n[y] += 1\n\nfirst = False\nres = ''\nfor i, x in enumerate(n[1:]):\n if x:\n if not first:\n res = str(i + 1) * x + '0' * n[0]\n first = True\n else:\n res += str(i + 1) * x\nif res == input():\n print('OK')\nelse:\n print('WRONG_ANSWER')\n"}, {"source_code": "l=list(input())\nm=int(input())\nl.sort()\n\ne=0\nif(l[0]=='0'):\n for i in range(1,len(l)):\n if(l[i]!='0'):\n l[0]=l[i]\n l[i]='0'\n e=1\n break\n if(e==1):\n break\nn=int(\"\".join(l))\n\nif(n==m and n!=0):\n print('OK')\nelse:\n print('WRONG_ANSWER')"}, {"source_code": "first =list(input())# \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 ['3', '3', '1', '0']\nsecond = input() \nfirst_reverse = sorted(first) # \u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043c\nif first_reverse[0] == \"0\": # \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 0, \u0442\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442 0 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tfor i in first_reverse:\n\t\tif i != \"0\":\n\t\t\ty =first_reverse.index(i)# \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0442 \u043d\u0443\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n\t\t\tfirst_reverse[0],first_reverse[y] = first_reverse[y],first_reverse[0]# \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0431\u0435\u0437 \u043f\u043e\u043c\u043e\u0437\u0438 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0439 \u043f\u0435\u0440\n\t\t\tbreak\nresult = ''.join(first_reverse)# \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u043e\u0435\u0434\u0438\u043d\u043e\n#print(result) \nif result == second:#\u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \n\tprint(\"OK\")\nelse: print(\"ERROR\")"}, {"source_code": "class CodeforcesTask12BSolution:\n def __init__(self):\n self.result = ''\n self.number = 0\n self.solution = 0\n\n def read_input(self):\n self.number = int(input())\n self.solution = int(input())\n\n def process_task(self):\n try:\n if len(str(self.solution)) > 1 and str(self.solution)[0] == \"0\":\n self.result = \"WRONG_ANSWER\"\n else:\n cnts = [0] * 10\n for c in str(self.number):\n cnts[int(c)] += 1\n start = min([int(x) for x in str(self.number) if int(x)])\n cnts[start] -= 1\n res = [start]\n for x in range(10):\n res += [x] * cnts[x]\n real_result = int(\"\".join([str(x) for x in res]))\n self.result = \"OK\" if real_result == self.solution else \"WRONG_ANSWER\"\n except ValueError:\n self.result = \"WRONG_ANSWER\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask12BSolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}], "src_uid": "d1e381b72a6c09a0723cfe72c0917372"} {"source_code": "def recursion(n):\n if n == 1:\n return x\n if n == 2:\n return x + min(x , y)\n if n % 2 == 0:\n return recursion(n // 2) + min(y, x * (n - n//2))\n else:\n return min(recursion(n + 1), recursion(n - 1)) + x\n\n\nimport sys\nsys.setrecursionlimit(10000000)\nn, x, y = list(map(int, input().split()))\nprint(recursion(n))\n ", "positive_code": [{"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nx = x + 0.0\ny = y + 0.0\n\nDP = [0.0]*(n+2)\nDP[-1] = None\nfor i in range(1,n+1):\n DP[i] = min(DP[i-1] + x, DP[(i+1)//2] + y + (x if i&1 else 0.0))\n\nprint int(DP[n])"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nx = x + 0.0\ny = y + 0.0\n\nDP = [0.0]*(n+2)\nDP[-1] = 'banana'\nfor i in range(1,n+1):\n DP[i] = min(DP[i-1] + x, DP[(i+1)//2] + y + (x if i&1 else 0.0))\n\nprint int(DP[n])"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nimport _numpypy\nzero = _numpypy.multiarray.dtype('int64').type()\n\nx = x + zero\ny = y + zero\n\nDP = [zero]*(n+1)\nfor i in range(1,n+1):\n DP[i] = DP[(i+1)//2] + y + (x if i&1 else zero)\n if DP[i] > DP[i-1] + x:\n DP[i] = DP[i-1] + x\n\nprint DP[n]"}, {"source_code": "N, X, Y = map(int, raw_input().split())\nX *= 1.; Y *= 1.\nmemo = {0.: 0, 1.: X}\ndef f(n):\n if n not in memo:\n if n%2 < 0.01:\n a = min(X*n, Y+f(n/2))\n else:\n a = min(X*n, X+f(n-1), X+f(n+1))\n memo[n] = a\n return memo[n]\nprint int(f(N * 1.))\n"}, {"source_code": "n,x,y = map(int, raw_input().split())\nx *= 1.; y *= 1.\nDP = [0.]*(n+1)\nfor i in xrange(1,n+1):\n DP[i] = min(DP[i-1] + x, DP[(i+1)//2] + y + (x if i&1 else 0.))\n\nprint int(DP[n])\n"}, {"source_code": "N, X, Y = map(int, raw_input().split())\nmemo = {0: 0, 1: X}\ndef f(n):\n if n not in memo:\n if n % 2 == 0:\n ans = min(X * n, Y + f(n / 2))\n else:\n ans = min(X * n, X + f(n-1), X + f(n+1))\n memo[n] = ans\n return memo[n]\nprint f(N)\n"}, {"source_code": "n, x, y = map(int, input().split(\" \"))\nl = [0.]*(n+1)\nfor i in range(1,n+1):\n l[i] = min(l[i-1]+x, l[(i+1)//2]+y+(x*(i&1)))\n\nprint(int(l[n]))"}, {"source_code": "import sys\n\nn, x, y = map(int, input().split())\nsize = 10**7\ndq_x, dq_y, dq_i = [0]*size, [0]*size, [0]*size\nl, r = 0, 0\ncx, cy = 0, 0\n\nfor i in range(1, n+1):\n cx += 1\n while l < r and dq_i[l] < i:\n l += 1\n if l < r and (dq_x[l]-i-cx)*x + (dq_y[l]-cy)*y < 0:\n cx = dq_x[l] - i\n cy = dq_y[l]\n\n tx, ty = cx + i*2, cy+1\n while l < r and (dq_x[r]-tx)*x + (dq_y[r]-ty)*y > 0:\n r -= 1\n dq_x[r] = tx\n dq_y[r] = ty\n dq_i[r] = i*2\n r += 1\n\nprint(cx*x + cy*y)\n"}, {"source_code": "n, x, y = map(int, input().split(\" \"))\nl = [0.]*(n+1)\nfor i in range(1,n+1):\n l[i] = min(l[i-1]+x, l[(i+1)//2]+y+(x*(i&1)))\n \nprint(int(l[n]))"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\n\nn,x,y = map(int, input().split())\nimport heapq\nh = []\nd = {}\nheapq.heappush(h, (0, n))\n\n\nr = -1\nwhile r == -1:\n xh,nh = heapq.heappop(h)\n if nh not in d:\n d[nh] = xh\n if nh == 1:\n r = xh + x\n elif nh * x < y:\n r = xh + nh*x\n else:\n if (nh - 1) not in d:\n heapq.heappush(h, (xh + x, nh - 1))\n if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\n heapq.heappush(h, (xh + y, nh // 2))\n if (nh + 1) not in d:\n heapq.heappush(h, (xh + x, nh + 1))\n \n \n\nprint(r)\n"}, {"source_code": "n,x,y=map(int,input().split())\ndp = [0.]*(n+1)\nfor i in range(1,n+1):\n dp[i]=min(dp[i-1]+x,dp[(i+1)//2]+y+(x*(i&1)))\nprint(int(dp[n]))\n"}, {"source_code": "n, x, y = map(int, input().split(\" \"))\nl = [0.]*(n+1)\nfor i in range(1,n+1):\n l[i] = min(l[i-1]+x, l[(i+1)//2]+y+(x*(i&1)))\n\nprint(int(l[n]))"}, {"source_code": "import sys\nsys.setrecursionlimit(1000000)\n\ndef f(dp,x,y,n):\n if dp[n]!=-1:\n return dp[n] \n if n%2==1:\n ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\n else:\n ans=f(dp,x,y,n//2)+min(y,x*n//2)\n dp[n]=ans\n return ans\n\nn,x,y=map(int,input().split())\ndp=[-1 for i in range(n+10)]\ndp[1]=x\nprint(f(dp,x,y,n))\n"}, {"source_code": "__author__ = 'Think'\nn, x, y=[int(i) for i in input().split()]\ndef worth(num):\n\tif num%2==0:\n\t\tdub=y\n\t\talt=x*(num//2)\n\telse:\n\t\tdub=y+x\n\t\talt=x*((num//2)+1)\n\treturn dub<alt, dub, alt\n\ntime=0\nwhile n>0:\n\tparity=n%2\n\tshould_double, dub, alt=worth(n)\n\tif should_double:\n\t\ttime+=dub\n\t\tif parity==0:\n\t\t\t# print(\"Doubled, even,\", n, n//2, time)\n\t\t\tn=n//2\n\t\t\tcontinue\n\t\telse:\n\t\t\thalf=n//2\n\t\t\tif half%2==0:\n\t\t\t\t# print(\"Doubled, 1 mod 4,\", n, half, time)\n\t\t\t\tn=half\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tif ((half//2+1)*x+y)<half*x:\n\t\t\t\t\t# print(\"Doubled, 3 mod 4, continued\", n, half+1, time)\n\t\t\t\t\tn=half+1\n\t\t\t\t\tcontinue\n\t\t\t\telse:\n\t\t\t\t\t# print(\"Doubled, 3 mod 4, end\", n, half, time)\n\t\t\t\t\ttime+=half*x\n\t\t\t\t\tbreak\n\telse:\n\t\t# print(\"Haven't doubled, \", n, time)\n\t\ttime+=n*x\n\t\tbreak\n\nprint(time)\n\n\n\n\n"}, {"source_code": "def fi(n):\n if n == 1:\n return x\n elif n == 2:\n return x + min(x, y)\n else:\n if n % 2 == 1:\n return min(fi(n-1), fi(n+1)) + x\n else:\n return fi(n//2) + min(y, x * (n//2))\n \nn,x,y = map(int, input().split())\nprint(fi(n))"}, {"source_code": "n, a, b = input().split(' ')\nn = int(n)\na = int(a)\nb = int(b)\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\nkg = n\nwhile kg >= 2:\n if kg % 2 != 0:\n tag = 1\n if tag == 1 and (kg-kg//2-1)*a < b:\n break\n hg2 = kg\n hg = (kg+1)//2\n while hg >= 2:\n if hg % 2 != 0:\n tag2 = 1\n if tag2 == 1 and (hg-hg//2-1)*a < b:\n break\n if tag2 == 0 and (hg-hg//2)*a < b:\n break\n if hg % 2 != 0:\n tk2 += 1\n hg //= 2\n tag2 = 0\n tk += 1\n t0 = b*tk + a*hg + a*tk2\n tag2 = 0\n hg = (hg2 - 1)//2\n while hg >= 2:\n if hg % 2 != 0:\n tag2 = 1\n if tag2 == 1 and (hg - hg//2 - 1) * a < b:\n break\n if tag2 == 0 and (hg - hg//2) * a < b:\n break\n if hg % 2 != 0:\n dk2 += 1\n hg //= 2\n tag2 = 0\n dk += 1\n t1 = b*dk + a*hg + a*dk2\n if t0 <= t1:\n kg += 1\n else:\n kg -= 1\n tk = tk2 = dk = dk2 = hg2 = 0\n if tag == 1:\n k2 += 1\n if (kg-kg//2)*a <= b:\n break\n kg //= 2\n tag = 0\n k1 += 1\nt = b*k1 + k2*a + kg*a\nprint(t)\n"}, {"source_code": "import sys\nsys.setrecursionlimit(1000000)\n\ndef f(n):\n if n == 1:\n return x\n elif n == 2:\n return x + min(x, y)\n else:\n if n % 2 == 0:\n return f(n // 2) + min(y, x * (n - n // 2))\n else:\n return min(f(n + 1), f(n - 1)) + x\n\nn, x, y = map(int, input().split())\n\nprint(f(n))"}, {"source_code": "def main():\n def f(t):\n if t & 1:\n return x if t == 1 else min(f(t - 1), f(t + 1)) + x\n else:\n u = x * t\n return f(t // 2) + y if y * 2 < u else u\n\n n, x, y = map(int, input().split())\n print(f(n))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n def f(t):\n u = cache.get(t)\n if u is None:\n if t & 1:\n u = min(f(t - 1), f(t + 1)) + x\n else:\n u = x * t\n if y * 2 < u:\n u = f(t // 2) + y\n cache[t] = u\n return u\n\n n, x, y = map(int, input().split())\n cache = {1: x}\n print(f(n))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\nsys.setrecursionlimit(100000)\n\nfrom functools import lru_cache\n\n@lru_cache()\ndef best(a):\n if a == 1:\n return x\n elif a > 0:\n if a == 2:\n return x + min(x, y)\n elif a % 2 == 0:\n\n return best(a//2) + min(y, (a - a//2) * x)\n else:\n return min(best(a-1) , best(a+1) ) + x\n\n\n\nn, x, y = map(int, input().split())\n\nprint(best(n))"}, {"source_code": "x=0;\ny=0;\nl=[0 for _ in xrange(10000007)]\n\ndef f(n):\n\tif(n%2==1):\n\t\tif(l[n-1]==0):l[n-1]=f(n-1)\n\t\tif(l[n+1]==0):l[n+1]=f(n+1)\n\t\treturn min(l[n-1]+x,l[n+1]+x)\n\telse:\n\t\tif (l[n/2]==0):l[n/2]=f(n/2)\n\t\treturn min(l[n/2]+y,l[n/2]+x*n/2)\n\nn,x,y=map(int,raw_input().split())\nl[1]=x\nif(n==1):print l[1]\nelse :print f(n)\n"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nimport _numpypy\nzero = _numpypy.multiarray.dtype('int64').type()\n\nx = x + zero\ny = y + zero\n\nDP = _numpypy.multiarray.zeros(n+1, dtype = 'int64')\nfor i in range(1,n+1):\n DP[i] = min(DP[i-1] + x, DP[(i+1)//2] + y + (x if i&1 else zero))\n\nprint DP[n]"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nimport _numpypy\n\nzero = _numpypy.multiarray.dtype('int64').type()\n\nx = x + zero\ny = y + zero\n\nDP = [zero]*(n+1)\nfor i in range(1,n+1):\n DP[i] = min(DP[i-1] + x, DP[(i+1)//2] + y + (x if i&1 else zero))\n\nprint DP[n]\n"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nx = x + 0.0\ny = y + 0.0\n\nDP = [0.0]*(n+1)\nfor i in range(1,n+1):\n DP[i] = min(DP[i-1] + x, DP[(i+1)//2] + y + (x if i&1 else 0.0))\n\nprint int(DP[n])"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nx = x + 0.0\ny = y + 0.0\n\nDP = [0.0]*(n+2)\nDP[-1] = 1\nfor i in range(1,n+1):\n DP[i] = min(DP[i-1] + x, DP[(i+1)//2] + y + (x if i&1 else 0.0))\n\nprint int(DP[n])"}], "negative_code": [{"source_code": "N, X, Y = map(int, raw_input().split())\nmemo = {0: 0, 1: X}\ndef f(n):\n if n not in memo:\n if n % 2 == 0:\n ans = min(X * n, Y + f(n / 2))\n else:\n ans = min(X * n, X + f(n/2), X + f((n+1)/2))\n memo[n] = ans\n return memo[n]\nprint f(N)\n"}, {"source_code": "import sys\n\nn, x, y = map(int, input().split())\ndp = [0] + [-1] * n\nprev = [0]*n\ndiv = 2\nwhile n % div == 0:\n prev[n // div] = n // div\n div *= 2\nfor i in range(1, n):\n if prev[i] < prev[i-1]:\n prev[i] = prev[i-1]\n\nfor i in range(n):\n if dp[i+1] == -1 or dp[i+1] > dp[i]+x:\n dp[i+1] = dp[i]+x\n if i*2 <= n:\n if dp[i*2] == -1 or dp[i*2] > dp[i]+y:\n dp[i*2] = dp[i]+y\n else:\n if dp[n] == -1 or dp[n] > dp[i]+y+(i*2-n)*x:\n dp[n] = dp[i]+y+(i*2-n)*x\n\n cost = dp[i] + (i - prev[i])*x + y\n if dp[prev[i]*2] > cost:\n dp[prev[i]*2] = cost\n\nprint(dp[-1])\n"}, {"source_code": "import sys\n\nn, x, y = map(int, input().split())\ndp = [0] + [10**18] * n\n\nfor _ in range(3):\n for i in range(n):\n if dp[i+1] > dp[i]+x:\n dp[i+1] = dp[i]+x\n if i*2 <= n:\n if dp[i*2] > dp[i]+y:\n dp[i*2] = dp[i]+y\n else:\n if dp[n] > dp[i]+y+(i*2-n)*x:\n dp[n] = dp[i]+y+(i*2-n)*x\n\n for i in range(n-1, 0, -1):\n if dp[i-1] > dp[i] + x:\n dp[i-1] = dp[i] + x\n\n\nprint(dp[-1])\n"}, {"source_code": "import sys\n\nn, x, y = map(int, input().split())\ndp = [0] + [-1] * n\n\nfor i in range(n):\n if dp[i+1] == -1 or dp[i+1] > dp[i]+x:\n dp[i+1] = dp[i]+x\n if i*2 <= n and (dp[i*2] == -1 or dp[i*2] > dp[i]+y):\n dp[i*2] = dp[i]+y\n\nfor i in range(n-1, 0, -1):\n if dp[i-1] > dp[i] + x:\n dp[i-1] = dp[i] + x\n\nfor i in range(n):\n if dp[i+1] > dp[i]+x:\n dp[i+1] = dp[i]+x\n if i*2 <= n:\n if dp[i*2] > dp[i]+y:\n dp[i*2] = dp[i]+y\n else:\n if dp[n] > dp[i]+y+(i*2-n)*x:\n dp[n] = dp[i]+y+(i*2-n)*x\n\nprint(dp[-1])\n"}, {"source_code": "import sys\n\nn, x, y = map(int, input().split())\ndp = [0] + [-1] * n\n\nfor i in range(n):\n if dp[i+1] == -1 or dp[i+1] > dp[i]+x:\n dp[i+1] = dp[i]+x\n if i*2 <= n:\n if dp[i*2] == -1 or dp[i*2] > dp[i]+y:\n dp[i*2] = dp[i]+y\n else:\n if dp[n] == -1 or dp[n] > dp[i]+y+(i*2-n)*x:\n dp[n] = dp[i]+y+(i*2-n)*x\n\nprint(dp[-1])\n"}, {"source_code": "n,x,y=map(int,input().split())\ndp = [0.]*(n+1)\nfor i in range(1,n+1):\n dp[i]=min(dp[i-1]+x,dp[(i+1)//2]+y+(x*(i&1)))\nprint(dp[n])\n"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nn0,x,y = map(int, input().split())\n\nd = {}\n\ndef solve(n):\n if n == 1:\n return x\n if n == 0:\n return 0\n if n not in d:\n if n & 1:\n d[n] = solve(n-1) + x\n else:\n d[n] = min(solve(n-1) + x, solve(n//2) + y)\n return d[n]\n \n\nif n0 == 1:\n print(x)\nelse:\n r0 = solve(n0)\n st2 = 1\n while st2 < n0:\n st2 *= 2\n for i in range(n0 + 1, st2 + 1):\n deccost = (i - n0)*x\n if deccost > r0:\n break\n else:\n r0 = min(r0, solve(i)+deccost)\n print(r0)\n"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nn,x,y = map(int, input().split())\n\nif n == 1:\n print(x)\nelse:\n t = x\n cnt = 1\n while cnt*2 <= n:\n t += y if y < cnt*x else cnt*x\n cnt *= 2\n t1 = (n - cnt)*x\n t2 = y + (cnt*2-n)*x\n t += min(t1,t2)\n print(t)\n\n\n"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nclass minheap:\n def __init__(self, n):\n self.a = [0 for i in range(n)]\n self.n = 0\n\n def __init__(self):\n self.a = []\n self.n = 0\n\n def load(self, initial):\n self.a = [] + initial\n self.n = len(self.a)\n for i in range((self.n-2) // 2, -1, -1):\n self.hdown(i)\n\n def hup(self, ind):\n if ind > 0:\n parent = (ind - 1) // 2\n if self.a[parent] > self.a[ind]:\n tmp = self.a[ind]\n self.a[ind] = self.a[parent]\n self.a[parent] = tmp\n self.hup(parent)\n\n def hdown(self, ind):\n l = ind*2 + 1\n r = ind*2 + 2\n newind = ind\n if l < self.n and self.a[newind] > self.a[l]:\n newind = l\n if r < self.n and self.a[newind] > self.a[r]:\n newind = r\n if newind != ind:\n tmp = self.a[ind]\n self.a[ind] = self.a[newind]\n self.a[newind] = tmp\n self.hdown(newind)\n\n def push(self, v):\n if self.n == len(self.a):\n self.a.append(v)\n else:\n self.a[self.n] = v\n self.hup(self.n)\n self.n += 1\n \n def pop(self):\n if self.n > 0:\n res = self.a[0]\n self.n -= 1\n if self.n > 0:\n self.a[0] = self.a[self.n]\n self.a[self.n] = 0\n self.hdown(0)\n return res\n else:\n raise \"empty heap\"\n\nn,x,y = map(int, input().split())\n\nh = minheap()\nd = {}\nh.push((0, n))\n\nr = -1\nwhile r == -1:\n xh,nh = h.pop()\n if nh not in d:\n d[nh] = xh\n if nh == 1:\n r = xh + x\n elif nh * x < (nh //2)*x + y:\n r = xh + nh*x\n else:\n if (nh - 1) not in d:\n h.push((xh + x, nh - 1))\n if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\n h.push((xh + y, nh // 2))\n if (nh + 1) not in d and (((nh + 1) & 1) == 1 or d.get((nh + 1)//2, ((nh + 1)//2)*x) > (xh + x + y)):\n h.push((xh + x, nh + 1))\n \n \n\nprint(r)\n"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nclass minheap:\n def __init__(self, n):\n self.a = [0 for i in range(n)]\n self.n = 0\n\n def __init__(self):\n self.a = []\n self.n = 0\n\n def load(self, initial):\n self.a = [] + initial\n self.n = len(self.a)\n for i in range((self.n-2) // 2, -1, -1):\n self.hdown(i)\n\n def hup(self, ind):\n if ind > 0:\n parent = (ind - 1) // 2\n if self.a[parent] > self.a[ind]:\n tmp = self.a[ind]\n self.a[ind] = self.a[parent]\n self.a[parent] = tmp\n self.hup(parent)\n\n def hdown(self, ind):\n l = ind*2 + 1\n r = ind*2 + 2\n newind = ind\n if l < self.n and self.a[newind] > self.a[l]:\n newind = l\n if r < self.n and self.a[newind] > self.a[r]:\n newind = r\n if newind != ind:\n tmp = self.a[ind]\n self.a[ind] = self.a[newind]\n self.a[newind] = tmp\n self.hdown(newind)\n\n def push(self, v):\n if self.n == len(self.a):\n self.a.append(v)\n else:\n self.a[self.n] = v\n self.hup(self.n)\n self.n += 1\n \n def pop(self):\n if self.n > 0:\n res = self.a[0]\n self.n -= 1\n if self.n > 0:\n self.a[0] = self.a[self.n]\n self.a[self.n] = 0\n self.hdown(0)\n return res\n else:\n raise \"empty heap\"\n\nn,x,y = map(int, input().split())\n\nh = minheap()\nd = {}\nh.push((0, n))\nimport math\n\nr = -1\nwhile r == -1:\n xh,nh = h.pop()\n if nh not in d:\n d[nh] = xh\n if nh == 1:\n r = xh + x\n elif nh * x < y:\n r = xh + nh*x\n else:\n if (nh - 1) not in d:\n h.push((xh + x, nh - 1))\n if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\n h.push((xh + y, nh // 2))\n if (nh + 1) not in d and (((nh + 1) & 1) == 1 or d.get((nh + 1)//2, ((nh + 1)//2)*x) > (xh + x + y)):\n h.push((xh + x, nh + 1))\n \n \n\nprint(r)\n"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nn,x,y = map(int, input().split())\n\na = [x*i for i in range(n*2+2)]\n\nbt = x\nfor i in range(1, 2*n):\n if a[i] < bt:\n bt = a[i] + x\n j = i - 1\n while j > 0 and a[j] > a[j + 1] + x:\n a[j] = a[j + 1] + x\n j += 1\n if j < n and a[j*2] > a[j] + y:\n a[j*2] = a[j] + y\n else:\n a[i] = bt\n bt += x\n if i < n and a[2*i] > a[i] + y:\n a[2*i] = a[i] + y\n\nprint(a[n])\n"}, {"source_code": "n, x, y = list(map(int, input().split()))\nline = [0]\nfor i in range(1, 2 * n+1):\n if i % 2 != 0:\n line += [line[-1]+x]\n else:\n line += [min(line[-1] + x, line[i // 2] + y)] \nfor i in range(n, 2 * n + 1):\n line[n] = min(line[i], line[n] + x * (i - n))\nprint(line[n]) \n \n\n"}, {"source_code": "n, x, y = list(map(int, input().split()))\nline = [0]\nfor i in range(1, n+1):\n if i % 2 != 0:\n line += [line[-1]+x]\n else:\n line += [min(line[-1] + x, line[i // 2] + y)]\nprint(line[-1]) \n \n\n"}, {"source_code": "n, x, y = list(map(int, input().split()))\nline = [0] * 2 * n \nline[1] = x\nline[2] = x + min(x, y)\ncounter = 4\nwhile counter < 2 * n:\n line[counter] = min(line[counter // 2] + y, line[counter // 2] + x * (counter - counter // 2))\n counter = counter * 2\nfor i in range(3, n + 1):\n if i % 2 != 0:\n line[i] = min(line[i + 1], line[i - 1])\n counter = 2 * i\n while counter < 2 * n:\n line[counter] = min(line[counter // 2] + y, line[counter // 2] + x * (counter - counter // 2))\n counter = counter * 2\nprint(line[n]) \n "}, {"source_code": "n, x, y = list(map(int, input().split()))\nline = [0]\nfor i in range(1, 2 * n+1):\n if i % 2 != 0:\n line += [line[-1]+x]\n else:\n line += [min(line[-1] + x, line[i // 2] + y)] \nfor i in range(n, 2 * n + 1):\n line[n] = min(line[n], line[i] + x * (i - n))\nprint(line[n]) \n \n\n"}, {"source_code": "def f(dp,x,y,n):\n if n==0:\n return 1\n if n<0:\n return 0\n if dp[n]!=-1:\n return dp[n]\n \n if n%2==1:\n ans=min(x+f(dp,x,y,n-1) , x+y+f(dp,x,y,(n+1)//2))\n else:\n ans=min(x+f(dp,x,y,n-1) , y+f(dp,x,y,n//2))\n dp[n]=ans\n return ans\n\nn,x,y=map(int,input().split())\ndp=[]\nfor i in range(n+10):\n dp.append(-1)\ndp[1]=1 \n \nprint(f(dp,x,y,n))\n"}, {"source_code": "import sys\nsys.setrecursionlimit(1000000)\n\ndef f(dp,x,y,n):\n if dp[n]!=-1:\n return dp[n] \n if n%2==1:\n ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\n else:\n ans=f(dp,x,y,n//2)+min(y,x*n/2)\n dp[n]=ans\n return ans\n\nn,x,y=map(int,input().split())\ndp=[-1 for i in range(n+10)]\ndp[1]=x\nprint(f(dp,x,y,n))\n"}, {"source_code": "__author__ = 'Think'\nn, x, y=[int(i) for i in input().split()]\ndef worth(num):\n\tif num%2==0:\n\t\tdub=y\n\t\talt=x*(num//2)\n\telse:\n\t\tdub=y+x\n\t\talt=x*((num//2)+1)\n\treturn dub<alt, dub, alt\n\ntime=0\nwhile n>0:\n\tparity=n%2\n\tshould_double, dub, alt=worth(n)\n\tif should_double:\n\t\ttime+=dub\n\t\tif parity==0:\n\t\t\tn=n//2\n\t\t\tcontinue\n\t\telse:\n\t\t\thalf=n//2\n\t\t\tif half%2==0:\n\t\t\t\tn=half\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tif ((half//2+1)*x+y)>half*x:\n\t\t\t\t\tn=half+1\n\t\t\t\t\tcontinue\n\t\t\t\telse:\n\t\t\t\t\ttime+=half*x\n\t\t\t\t\tbreak\n\telse:\n\t\ttime+=n*x\n\t\tbreak\n\nprint(time)\n\n\n\n\n"}, {"source_code": "n, x, y = map(int, input().split())\n\nf = [None] * (n + 1)\nf[0] = 0\nf[1] = x\n\nfor i in range(2, n + 1):\n if i % 2 == 0:\n a = f[i // 2] + y\n else:\n a = f[i // 2] + y + x\n \n f[i] = min(f[i - 1] + x, a)\n\nprint(f[n])"}, {"source_code": "n, x, y = map(int, input().split())\n\ni = n\nc = 0\n\nwhile i > 0:\n if i % 2 == 0 and x >= y:\n i //= 2\n c += y\n else:\n if str(bin(i + 1)) == '1' + '0' * (len(str(bin(i + 1))) - 1):\n i += 1\n else:\n i -= 1\n c += x\n\nprint(c)"}, {"source_code": "n, x, y = map(int, input().split())\n\nF = [0] * (n + 1 )\nF[1] = x\nF[2] = F[1] + min(y, x) \n\n\nfor i in range(3, n + 1):\n if i % 2 == 0:\n F[i] = min(F[i - 1] + x, F[i//2] + y)\n else:\n F[i] = F[i - 1] + x\n\nprint(F[n])"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn,x,y = [int(x) for x in input().split()]\n\nDP = [0]*(n+1)\nfor i in range(1,n+1):\n d = DP[i-1] + x\n if not i&1:\n d = min(d, DP[i//2] + y)\n DP[i] = d\n\nprint DP[n]\n"}], "src_uid": "0f270af00be2a523515d5e7bd66800f6"} {"source_code": "p=1000000007\ndef C(n,m):\n\treturn reduce(lambda x,y:x*(n-y)*pow(y+1,p-2,p)%p,[1]+range(m))\nn=input()\nprint C(2*n,n)-n", "positive_code": [{"source_code": "#the same code using fermat's little theorem\ndef powe(x,y):\n if y==0:\n return 1\n ans=powe(x,y/2)\n ans*=ans\n ans%=1000000007\n if y%2==1:\n ans*=x\n ans%=1000000007\n return ans\n \nn=input()\nanswer=1\ndiv=1\nfor i in range(n+1,2*n):\n answer*=i\n answer%=1000000007\nfor i in range(2,n):\n div*=i\n div%=1000000007\nanswer*=powe(div,1000000007-2)\nanswer%=1000000007\nprint (((2*answer-n)%1000000007)+1000000007)%1000000007\n"}, {"source_code": "M=1000000007\nn=input()\nf=[]\nf.append(1)\nfor i in range(1,200000):\n\tf.append((f[i-1]*i)%M)\ndef power(a,b):\n\tif b==0:\n\t\treturn 1\n\tz=power(a,b/2)%M\n\tif b%2==0:\n\t\treturn (z*z)%M\n\treturn (((z*z)%M)*a)%M\nk=n-1\nn=n+k\na=f[n]\nb=f[k]\nc=f[n-k]\nb=power(b,M-2)%M\nc=power(c,M-2)%M\nans=(((a*b)%M)*c)%M\nprint (ans*2-k-1+M)%M"}, {"source_code": "MOD = 1000000007\n\nfact = [1]\nfor i in range(200000):\n fact.append((fact[-1] * (i+1)) % MOD)\n\nn = input()\n\nnk = (((fact[2 * n - 1] * pow(fact[n], MOD - 2, MOD)) % MOD) * pow(fact[n - 1], MOD - 2, MOD)) % MOD\nprint (2 * nk - n) % MOD\n"}, {"source_code": "MOD = 1000000007\n\nn = input()\n\nfn1 = 1\nfor i in range(2, n):\n fn1 = (fn1 * i) % MOD\n\nfn = (fn1 * n) % MOD\nf2n1 = fn\nfor i in range(n + 1, 2 * n):\n f2n1 = (f2n1 * i) % MOD\n\n\n\nnk = (((f2n1 * pow(fn, MOD - 2, MOD)) % MOD) * pow(fn1, MOD - 2, MOD)) % MOD\nprint (2 * nk - n) % MOD\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "n = int(raw_input())\n\nmod = 10 ** 9 + 7\n\np_n = 1\nfor i in range(2, n + 1):\n p_n *= i\n p_n %= mod\n\np_2n = p_n\nfor i in range(n + 1, 2 * n + 1):\n p_2n *= i\n p_2n %= mod\n\np_n *= p_n\np_n %= mod\n\np_n = pow(p_n, mod - 2, mod)\nans = p_2n * p_n\nans %= mod\n\nprint ans-n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "#!/usr/bin/python\n\nn = int (raw_input())\nmod = 1000000007\nans = 1\ndiv = 1\nfor i in range(1, n):\n\tans = (n + i) * ans % mod \n\tdiv = i * div % mod\nans = ans * 2 % mod * pow(div, mod - 2, mod) % mod - n\nans %= mod\nprint ans\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "MOD=10**9+7\ndef power(x, a):\n if(a==0):\n return(1)\n z=power(x, a//2)\n z=(z*z)%MOD\n if(a%2):\n z=(z*x)%MOD\n return(z)\ndef fact(n):\n factn=1\n for i in range(2, n+1):\n factn=(factn*i)%MOD\n return(factn)\ndef ncr(n, r):\n return((fact(n)*power(fact(r), MOD-2)*power(fact(n-r), MOD-2))%MOD) \nn=int(input())\nprint((2*ncr(2*n-1,n)-n)%MOD)"}, {"source_code": "# from math import factorial\nimport re\n\n\ndef factorial(n):\n if n == 0:\n return 1\n else:\n for i in range(1, n):\n n = (n * i) % 1000000007\n return n\n\n\ndef exgcd(a, b, c):\n if b == 0:\n c[0] = 1\n c[1] = 0\n return a\n else:\n ret = exgcd(b, a % b, c)\n tmp = c[0] - a // b * c[1]\n c[0] = c[1]\n c[1] = tmp\n return ret\n\n\ndef inv(a, b):\n c = [0, 1]\n exgcd(a, b, c)\n return c[0] % b\n\n\ndef slove(n):\n f2n = factorial(2 * n - 1) % 1000000007\n fn = factorial(n) % 1000000007\n fn1 = factorial(n - 1) % 1000000007\n div = (fn * fn1) % 1000000007\n ninv = inv(div, 1000000007)\n\n ret = (2 * f2n * ninv - n) % 1000000007\n return ret\n\n\nn = int(input())\nprint(slove(n))\n"}, {"source_code": "def fact(n):\n res=1\n for i in range(2,n+1):\n res=(res*i)%(10**9+7)\n return res\n \ndef rev(a):\n return pow(a,10**9+5,10**9+7)\n\ndef c2nn(n):\n return (fact(2*n+1)*(rev(fact(n))*rev(fact(n+1))))%(10**9+7)\n\nn=int(input())\nprint(((c2nn(n-1)*2-n)%(10**9+7)+10**9+7)%(10**9+7))"}, {"source_code": "def fact(n):\n res=1\n for i in range(2,n+1):\n res=(res*i)%(10**9+7)\n return res\n \ndef rev(a):\n return pow(a,10**9+5,10**9+7)\n\ndef c2nn(n):\n return fact(2*n)*(rev(fact(n))**2)%(10**9+7)\n\nn=int(input())\nprint(c2nn(n)-n)"}, {"source_code": "prod = 1\nn = int(input())\nfor i in range(n+1, 2*n+1):\n prod *= i\n prod %= (10**9+7)\n\nfor i in range(1,n+1):\n prod *= pow(i, 10**9+5, 10**9+7)\n prod %= 10**9+7\n\nprint((prod-n)%(10**9+7))\n"}, {"source_code": "n = int(input())\nm = int(1e9 + 7)\n# binom(2n - 1, n)\np = 1\nfor i in range(1, n + 1):\n p *= 2 * n - i\n p *= pow(i, m - 2, m)\n p %= m\nprint((2 * p - n) % m)"}, {"source_code": "n = int(input())\n\nm = int(1e9 + 7)\n\n# binom(2n - 1, n)\n\np = 1\n\nfor i in range(1, n + 1):\n\n p *= 2 * n - i\n\n p *= pow(i, m - 2, m)\n\n p %= m\n\nprint((2 * p - n) % m)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "n,a,b,M,I=int(input()),1,1,1000000007,1000000005\nfor i in range(1,n):\n a=a*i%M\na=pow(a,I,M)\nfor i in range(n+1,n*2):\n b=b*i%M\nprint(((2*a*b)%M-n)%M)"}, {"source_code": "def po(a,b,m):\n if b == 0:\n return 1\n if b % 2 == 0:\n return (po(a, b // 2, m) ** 2) % m\n return (po(a, b - 1, m) * a) % m\n \ndef rev(a,m):\n return po(a, m - 2, m)\n \ndef fact(a, m):\n t = a\n for i in range(1, a):\n t=(t * i) % m\n return t\n \ndef main(n):\n m = 10 ** 9 + 7\n if n == 1:\n return 1\n return (2 * (fact(2 * n - 1, m) * rev(fact(n, m) * fact(n - 1, m), m)) - n) % m\n \nprint(main(int(input())))"}, {"source_code": "def po(a,b,m):\n if b == 0:\n return 1\n if b % 2 == 0:\n return (po(a, b // 2, m) ** 2) % m\n return (po(a, b - 1, m) * a) % m\n \ndef rev(a,m):\n return po(a, m - 2, m)\n \ndef fact(a, m):\n t = a\n for i in range(1, a):\n t=(t * i) % m\n return t\n \ndef main(n):\n m = 10 ** 9 + 7\n if n == 1:\n return 1\n return (2*(fact(2 * n - 1, m) * rev(fact(n, m) * fact(n - 1, m), m)) - n) % m\n \nprint(main(int(input())))"}, {"source_code": "#love python :)\n#medo journy to icpc\nn = int(input())\nm = int(1e9 + 7)\np = 1\nfor i in range(1, n + 1):\n p *= 2 * n - i\n p *= pow(i, m - 2, m)\n p %= m\nprint((2 * p - n) % m)"}, {"source_code": "#!/usr/bin/python\nMOD = 1000000007\n\ndef ext_gcd(a, b):\n if b == 0:\n return (a, 1, 0)\n (dp, xp, yp) = ext_gcd(b, a % b)\n return (dp, yp, xp - a//b * yp)\n\ndef mod_solve(a, b, n):\n (d, xp, yp) = ext_gcd(a, n)\n if b % d == 0:\n x0 = xp * (b/d) % n\n return x0\n else:\n return None\n\n# calculates \\choose(2*k-1, k)\ndef choose(n, nInv):\n result = 1\n for i in range(2*n-1, n-1, -1):\n result = result * i % MOD\n for i in range(n):\n result = result * nInv[i] % MOD\n return result\n\ndef solve():\n n = int(raw_input())\n nInv = [mod_solve(i, 1, MOD) for i in range(1, n+1)]\n print (choose(n, nInv) * 2 - n) % MOD\n\nsolve()\n\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n"}, {"source_code": "n,m,t=input(),1000000007,1\nfor i in range(1,n+1):\n t=t*(n+i)*pow(i,m-2,m)%m\nprint (t-n)%m\n"}, {"source_code": "def readint(): return int(raw_input())\n\nM = 1000000007\n\ndef egcd(a, b):\n\tif (a % b == 0):\n\t\treturn (0, 1)\n\tt = egcd(b, a % b)\n\treturn (t[1], t[0] - t[1] * (a / b))\n\ndef c(n, k):\n\ta = 1\n\tfor i in xrange(n, n - k, -1):\n\t\ta *= i\n\t\ta %= M\n\tb = 1\n\tfor i in xrange(1, k + 1):\n\t\tb *= i\n\t\tb %= M\n\tr = egcd(b, M)[0]\n\treturn (a * r) % M\n\t\ndef run():\n\tn = readint()\n\tres = c(n + n - 1, n) * 2 - n\n\tres += M\n\tres %= M\n\tprint res\nrun()\n\n"}, {"source_code": "n = int(raw_input())\n\nmod = 1000000007\n\ndef a(n):\n if n == 0:\n return 1\n sol = 1\n for x in xrange(n+1, 2*n+1):\n sol = (sol * x) % mod\n #print \"!\", x, sol\n\n for x in xrange(1, n+1):\n sol = (sol * pow(x,mod-2,mod)) % mod\n #print x, div, , sol\n\n return sol\n\ndef c(n):\n return (a(n) - n) % mod\n\nprint c(n)\n"}, {"source_code": "def choose(m, n, mod):\n factors = (m + 1) * [ 0 ]\n is_prime = (m + 1) * [ True ]\n is_prime[0] = is_prime[1] = False\n p = 0\n while True:\n while p <= m and not is_prime[p]:\n p += 1\n if p > m:\n break\n if p <= n:\n factors[p] -= 1\n elif p > m - n:\n factors[p] += 1\n for i in range(2 * p, m + 1, p):\n x = i\n y = 0\n while x % p == 0:\n x //= p\n y += 1\n if i <= n:\n factors[p] -= y\n elif i > m - n:\n factors[p] += y\n is_prime[i] = False\n p += 1\n #print(m, n, factors, is_prime)\n x = 1\n for p in range(2, m + 1):\n for i in range(factors[p]):\n x = (x * p) % mod\n return x\n\nn = int(raw_input())\nmod = 1000000007\nresult = (2 * choose(2 * n - 1, n - 1, mod) - n) % mod\nprint(result)\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------- fast io --------------------\nfrom math import gcd, ceil\n\ndef prod(a, mod=10**9+7):\n ans = 1\n for each in a:\n ans = (ans * each) % mod\n return ans\n\ndef lcm(a, b): return a * b // gcd(a, b)\n\ndef binary(x, length=16):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\ndef modInverse(a, m) :\n a = a % m;\n for x in range(1, m) :\n if ((a * x) % m == 1) :\n return x\n return 1\n\nfor _ in range(int(input()) if not True else 1):\n n = int(input())\n #n, k = map(int, input().split())\n #a, b = map(int, input().split())\n #c, d = map(int, input().split())\n #a = list(map(int, input().split()))\n #b = list(map(int, input().split()))\n #s = input()\n mod = 10**9 + 7\n if 1:\n max_n = 250000\n fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)\n fact[0] = 1\n for i in range(max_n):\n fact[i + 1] = fact[i] * (i + 1) % mod\n\n inv_fact[-1] = pow(fact[-1], mod - 2, mod)\n for i in reversed(range(max_n)):\n inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod\n\n def nCr_mod(n, r):\n res = 1\n while n or r:\n a, b = n % mod, r % mod\n if a < b:\n return 0\n res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod\n n //= mod\n r //= mod\n return res\n\n print((nCr_mod(2*n,n) - n)%mod)"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "n = input()\nm = 1000000007\nf = lambda a,b: reduce(lambda x,y: (x*y)%m,xrange(a,b),1)\na = f(n+1,n+n)*pow(f(2,n),m-2,m)\nprint (2*a-n+m)%m"}, {"source_code": "n = input()\nm = 1000000007\na = reduce(lambda x,y: (x*y)%m,range(n+1,n+n)+map(lambda x:pow(x,m-2,m),xrange(2,n)),1)\nprint (2*a-n+m)%m\n"}, {"source_code": "n = int(raw_input())\nmod = 1000000007\nnum,den = 1,1\nfor i in xrange(n+1,2*n): num = (num*i)%mod\nfor i in xrange(1,n): den = (den*i)%mod\n\ndef evklid(a,b):\n if a == 1: return (1,0)\n u,v = divmod(b,a)\n x,y = evklid(v,a)\n return (y - u * x, x)\n\nden1,dummy = evklid(den,mod)\nden1%= mod\n\nprint (2*num*den1-n)%mod\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m"}, {"source_code": "M = 1000000007\n\nn = input()\n\nfn = 1\nfor i in range(1,n+1):\n\tfn *= i\n\tfn %= M\nf2n = 1\nfor i in range(n+1,2*n+1):\n\tf2n *= i\n\tf2n %= M\n\n# print n,(f2n/fn-n+M)%M\nprint (f2n*pow(fn,M-2,M)-n+M)%M\n\n\n\n\"\"\"\ndef frac(n):\n\tr = 1\n\tfor i in range(1,n+1):\n\t\tr *= i\n\treturn r\n\nn = input()\n\nprint (frac(2*n)/frac(n)/frac(n)-n)%1000000007\n\"\"\"\n\n\"\"\"\nn = input()\nans = 0\n\ndef f(d,v):\n\tif d==0:\n\t\tf1 = True\n\t\tf2 = True\n\t\tfor i in range(1,n):\n\t\t\tif v[i]>v[i-1]:\n\t\t\t\tf1 = False\n\t\t\tif v[i]<v[i-1]:\n\t\t\t\tf2 = False\n\t\tif f1 or f2:\n\t\t\tglobal ans\n\t\t\tans += 1\n\telse:\n\t\tfor i in range(1,n+1):\n\t\t\tf(d-1,v+[i])\n\treturn\n\nf(n,[])\n\nprint ans\n\ndef frac(n):\n\tr = 1\n\tfor i in range(1,n+1):\n\t\tr *= i\n\treturn r\n\nfor n in range(1,100):\n\t# ans = 0\n\t# fn,[])\n\t# print n,ans\n\t\n\tprint n,frac(2*n)/frac(n)/frac(n)-n\n\"\"\""}, {"source_code": "M = 1000000007\nn = input()\nans = 1\nfor i in range(1,n+1):\n\tans = ans * (n+i) * pow(i,M-2,M) % M\nprint (ans-n)%M\n"}, {"source_code": "n,m,t,u=input(),1000000007,1,1\nwhile u<=n:\n t,u=t*(n+u)*pow(u,m-2,m)%m,u+1\nprint (t-n)%m\n\n"}, {"source_code": "n = int(raw_input())\nm = 1000000007\nres = 1\nfor i in range(1, n):\n res = (res * (n+i) * pow(i, m-2, m)) % m;\nprint (2*res-n)%m\n"}, {"source_code": "#!/usr/bin/python\nimport sys\n\nMOD = 10 ** 9 + 7\n\ndef powmod (a, b, c):\n\tres = 1\n\tcur = a\n\tp = 1\n\twhile p <= b:\n\t\tif p & b > 0:\n\t\t\tres = (res * cur) % c\n\t\tcur = (cur * cur) % c\n\t\tp <<= 1\n\treturn res\n\ndef binom (n, k, c):\n\tk = min (k, n - k)\n\tf = 1\n\tfor i in range (1, k + 1):\n\t\tf = (f * i) % c\n\tg = f\n\tfor i in range (k + 1, n - k + 1):\n\t\tg = (g * i) % c\n\th = g\n\tfor i in range (n - k + 1, n + 1):\n\t\th = (h * i) % c\n\tf = powmod (f, MOD - 2, MOD)\n\tg = powmod (g, MOD - 2, MOD)\n\treturn (h * f * g) % MOD\n\nwhile True:\n\ts = sys.stdin.readline ().strip ()\n\tif s == '':\n\t\ts = sys.stdin.readline ().strip ()\n\t\tif s == '':\n\t\t\tbreak\n\tn, = [int (x) for x in s.split ()]\n\tr = binom (n + n - 1, n, MOD)\n\tr = r * 2 - n\n\tprint ((r % MOD) + MOD) % MOD\n"}, {"source_code": "mod = 1000000007\n\ndef inv(n, p):\n return pow(n,p-2,p)\n\ndef comb(n,k):\n res = 1\n for i in range(k+1,n+1): res = (res*i) % mod\n for i in range(1,n-k+1): res = (res * inv(i, mod)) % mod\n return res\n\nn = int(raw_input())\nc = comb(2*n-1, n-1)\nprint (2*c - n) % mod\n\n"}, {"source_code": "mod = 1000000007\n\ndef inv(a, b):\n tb = b\n x = 0\n lastx = 1\n y = 1\n lasty = 0\n while b != 0:\n quotient = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - quotient * x, x)\n (y, lasty) = (lasty - quotient * y, y)\n if (lastx < 0): lastx = tb + lastx\n return lastx\n\ndef comb(n,k):\n res = 1\n for i in range(k+1,n+1): res = (res*i) % mod\n for i in range(1,n-k+1): res = (res * inv(i,mod)) % mod\n return res\n\nn = int(raw_input())\nc = comb(2*n-1, n-1)\nres = (2*c - n) % mod\n\nprint res\n\n"}, {"source_code": "from math import factorial as fact\nn = input ()\nM = 1000000007\n\ndef egcd (a, b):\n if a % b == 0:\n return (0, 1)\n x = egcd (b, a % b)\n return (x[1], x[0] - x[1] * (a / b))\n\ndef C (n, k): \n a = 1\n for i in xrange (n - k + 1, n + 1):\n a *= i\n a %= M\n b = 1\n for i in xrange (1, k + 1):\n b *= i\n b %= M\n return (a * egcd (b, M)[0]) % M\n \nprint (2 * C (n * 2 - 1, n) - n) % M\n\n"}], "negative_code": [{"source_code": "def fact(n):\n if n==1:\n return 1\n return fact(n-1)*n%(10**9+7)\n \ndef rev(a):\n return pow(a,10**9+5,10**9+7)\n\ndef c2nn(n):\n return fact(2*n)*rev(fact(n)**2)%(10**9+7)\n\nn=int(input())\nprint(c2nn(n)*2-n)"}, {"source_code": "def fact(n):\n res=1\n for i in range(2,n+1):\n res=(res*i)%(10**9+7)\n return res\n \ndef rev(a):\n return pow(a,10**9+5,10**9+7)\n\ndef c2nn(n):\n return fact(2*n+1)*(rev(fact(n))*rev(fact(n+1)))%(10**9+7)\n\nn=int(input())\nprint(c2nn(n-1)*2-n)"}, {"source_code": "n = int(input())\nMOD = int(1e9 + 7)\nprint((sum(((n - 3) * k * (k - 1) // 2 + k) * (n - k + 1) % MOD for k in range(1, n + 1)) * 2 - n) % MOD)"}, {"source_code": "n = int(input())\nm = int(1e9 + 7)\n# binom(2n - 1, n)\np = 1\nfor i in range(1, n + 1):\n p *= 2 * n - i\n p //= i\nprint(2 * p - n)"}, {"source_code": "n = int(input())\nm = int(1e9 + 7)\n# binom(2n - 1, n)\np = 1\nfor i in range(1, n + 1):\n p *= 2 * n - i\n p //= i\n p %= m\nprint((2 * p - n) % m)"}, {"source_code": "def po(a,b,m):\n if b == 0:\n return 1\n if b % 2 == 0:\n return (po(a, b // 2, m) ** 2) % m\n return (po(a, b - 1, m) * a) % m\n \ndef rev(a,m):\n return po(a, m - 2, m)\n \ndef fact(a, m):\n t = a\n for i in range(1, a):\n t=(t * i) % m\n return t\n \ndef main(n):\n m = 10 ** 9 + 7\n return (2*(fact(2 * n - 1, m) * rev(fact(n, m) * fact(n - 1, m), m)) - n) % m\n \nprint(main(int(input())))"}, {"source_code": "#!/usr/bin/python\nMOD = 1000000007\n\ndef ext_gcd(a, b):\n if b == 0:\n return (a, 1, 0)\n (dp, xp, yp) = ext_gcd(b, a % b)\n return (dp, yp, xp - a//b * yp)\n\ndef mod_solve(a, b, n):\n (d, xp, yp) = ext_gcd(a, n)\n if b % d == 0:\n x0 = xp * (b/d) % n\n return x0\n else:\n return None\n\n# calculates \\choose(2*k-1, k)\ndef choose(n, nInv):\n result = 1\n for i in range(2*n-1, n-1, -1):\n result = result * i % MOD\n for i in range(n):\n result = result * nInv[i] % MOD\n return result\n\ndef solve():\n n = int(raw_input())\n nInv = [mod_solve(i, 1, MOD) for i in range(1, n+1)]\n print choose(n, nInv) * 2 - n\n\nsolve()\n\n"}, {"source_code": "n,w=input(),1\nfor x in range(2,n+1):w=(w*(x+1)+1)%1000000007\nprint w\n"}, {"source_code": "from math import factorial\ndef readint(): return int(raw_input())\n\ndef c(n, k):\n\treturn factorial(n) / factorial(k) / factorial(n - k)\n\t\ndef run():\n\tn = readint()\n\tres = c(n + n - 1, n) * 2 - n\n\tprint res\nrun()\n\n"}, {"source_code": "n = int(raw_input())\n\nmod = 1000000007\n\ndef egcd(a, b):\n u, u1 = 1, 0\n v, v1 = 0, 1\n g, g1 = a, b\n while g1:\n q = g // g1\n u, u1 = u1, u - q * u1\n v, v1 = v1, v - q * v1\n g, g1 = g1, g - q * g1\n return u, v, g\n\ndef a(n):\n if n == 0:\n return 1\n sol = 1\n for x in xrange(n+1, 2*n+1):\n sol = (sol * x) % mod\n #print \"!\", x, sol\n\n for x in xrange(1, n+1):\n div = egcd(x, mod)[0] % mod\n sol = (sol * div) % mod\n #print x, div, pow(x,mod-2,mod), sol\n\n return sol / 2\n\ndef c(n):\n return (2*a(n) - n) % mod\n\nprint c(n)\n"}, {"source_code": "n = int(raw_input())\n\ndef a(n):\n if n == 0:\n return 1\n return 2*(2*n+1)*a(n-1)/(n+1) \n\ndef c(n):\n return 2 * a(n-1) - n\n\n#for x in range(1, 10):\n# print x, c(x)\n\nprint c(n)\n\n"}, {"source_code": "n = int(raw_input())\n\nmod = 1000000007\n\ndef a(n):\n if n == 0:\n return 1\n sol = 1\n for x in xrange(1, n+1):\n sol = (2*(2*x+1)*sol/(x+1)) % mod\n return sol\n\ndef c(n):\n return (2 * a(n-1) - n) % mod\n\n#for x in range(1, 10):\n# print x, c(x)\n\nprint c(n)\n\n"}, {"source_code": "n = int(raw_input())\n\nmod = 1000000007\n\ndef a(n):\n if n == 0:\n return 1\n sol = 1\n for x in xrange(n+1, 2*n+1):\n sol = (sol * x) % mod\n #print \"!\", x, sol\n\n for x in xrange(1, n+1):\n sol = (sol * pow(x,mod-2,mod)) % mod\n #print x, div, , sol\n\n return sol / 2\n\ndef c(n):\n return (2*a(n) - n) % mod\n\nprint c(n)\n"}, {"source_code": "M = 1000000007\nn = input()\nans = 1\nfor i in range(1,n+1):\n\tans = ans * (n+i) * pow(i,M-2,M) % M\nprint ans\n"}, {"source_code": "n = input ()\nprint (n ** n) % 1000000007\n"}], "src_uid": "13a9ffe5acaa79d97df88a069fc520b9"} {"source_code": "a=zip(*[map(int,raw_input().split()) for _ in range(input())])\nf = lambda a: max(a)-min(a)\nprint f(a[0])*f(a[1]) or -1\n", "positive_code": [{"source_code": "v = int(input())\n\ndef pl3(v):\n point = []\n for i in range(v):\n point.append(input().split())\n for k in point:\n for j in point:\n if k[0] != j[0] and k[1] != j[1]:\n return abs((int(k[0])-int(j[0]))*(int(k[1])-int(j[1])))\n break\n return -1\n\n\nif v == 1:\n print('-1')\nelse:\n print(pl3(v))"}, {"source_code": "n = int(input())\nif (n == 1):\n print(-1)\nelif (n == 2):\n x1, y1 = map(int, input().split())\n x2, y2 = map(int, input().split())\n if (x1 == x2) or (y1 == y2):\n print(-1)\n else:\n print(abs(x2 - x1) * abs(y2 - y1))\nelse:\n x1, y1 = map(int, input().split())\n x2, y2 = map(int, input().split())\n x3, y3 = map(int, input().split())\n if (x1 == x2) or (y1 == y2):\n if (x1 == x3) or (y1 == y3):\n print(abs(x3 - x2) * abs(y3 - y2))\n else:\n print(abs(x3 - x1) * abs(y3 - y1))\n else:\n print(abs(x2 - x1) * abs(y2 - y1))\n"}, {"source_code": "n = int(raw_input())\npoints = [tuple(map(int,raw_input().split(\" \"))) for _ in xrange(n)]\ndef find_corners(points):\n for i in range(len(points)-1):\n for j in range(i+1, len(points)):\n if points[i][0] != points[j][0] and points[i][1] != points[j][1]:\n return (i,j)\n return (None, None)\n\na,b = find_corners(points)\nif a is None:\n print \"-1\"\nelse:\n print abs(points[a][0]-points[b][0]) * abs(points[a][1]-points[b][1])\n"}, {"source_code": "from sys import stdin\n\nax = []\nay = []\nn = int(stdin.readline())\n\nfor i in range(0, n):\n x, y = map(int, stdin.readline().split())\n ax.append(x)\n ay.append(y)\n\nif n == 1:\n print(-1)\nelif n == 2:\n if ax[0] != ax[1] and ay[0] != ay[1]:\n print(abs(ax[0] - ax[1]) * abs(ay[0] - ay[1]))\n else:\n print(-1)\nelse:\n print((max(ax) - min(ax)) * (max(ay) - min(ay)))\n \n"}, {"source_code": "n=int(input())\nx=n*[0]\ny=n*[0]\nfor i in range(n):\n x[i],y[i]=[int(i) for i in input().split()]\nif n==1:\n print(-1)\nelse:\n if n==2:\n if x[0]==x[1] or y[0]==y[1]:\n print(-1)\n else:\n print(abs((x[0]-x[1])*(y[0]-y[1])))\n elif n==3 or n==4:\n x.sort()\n y.sort()\n print(abs((max(x)-min(x))*(max(y)-min(y))))\n \n"}, {"source_code": "x , y = [] , []\nfor i in range(int(input())):\n a , b = map(int , input().split())\n x.append(a)\n y.append(b)\nans = (max(x)-min(x))*(max(y)-min(y))\nprint(ans if ans else -1)"}, {"source_code": "import sys\n\n\ndef check_point(c, d):\n if c[0] != d[0] and c[1] != d[1]:\n return True\n else:\n return False\n\n\ndef square(c, d):\n return abs(c[0] - d[0]) * abs(c[1] - d[1])\n\n\nn = int(input())\na = []\nq = 0\nh = 0\nfor x in range(n):\n a.append(list(map(int, input().split())))\nif n == 2:\n if check_point(a[0], a[1]):\n print(square(a[0], a[1]))\n else:\n print(-1)\nelif n == 3:\n if check_point(a[0], a[1]):\n print(square(a[0], a[1]))\n elif check_point(a[0], a[2]):\n print(square(a[0], a[2]))\n elif check_point(a[2], a[1]):\n print(square(a[1], a[2]))\n else:\n print(-1)\nelif n == 4:\n if check_point(a[0], a[1]) and check_point(a[2], a[3]):\n print(square(a[0], a[1]))\n elif check_point(a[1], a[2]) and check_point(a[0], a[3]):\n print(square(a[1], a[2]))\n elif check_point(a[0], a[2]) and check_point(a[1], a[3]):\n print(square(a[0], a[2]))\n\nelse:\n print(-1)\n"}, {"source_code": "import math\ndef check(i,j):\n if int (i[0]) == int(j[0]): return False\n if int (i[1]) == int(j[1]): return False\n return True\nn = int(raw_input())\na = []\nfor i in range(n):\n a.append(raw_input().split())\nif n <= 1: print -1\nif n == 2:\n if check(a[0],a[1]): \n print int(math.fabs(int(a[0][0])-int(a[1][0])) *math.fabs(int(a[0][1])-int(a[1][1])))\n else: print -1\nelse:\n t = False\n for i in range(n-1):\n if t == True: break\n for j in range(i,n):\n if check(a[i],a[j]):\n print int(math.fabs(int(a[i][0])-int(a[j][0])) *math.fabs(int(a[i][1])-int(a[j][1])))\n t = True\n break\n "}, {"source_code": "def area():\n for i in range(len(val)):\n for j in range(1, len(val)):\n tmp = abs(val[i][0]-val[j][0]) * abs(val[i][1]-val[j][1])\n if tmp != 0:\n return tmp\n return -1\n\nn = int(input())\nval = [list(map(int, input().split())) for _ in range(n)]\nprint(area())\n"}, {"source_code": "import sys\n\nvert = input()\nif vert>4 or vert<1:\n print -1\n sys.exit(0)\n\npt = {}\nfor i in range(vert):\n input = raw_input()\n points = input.split(\" \")\n points = map(int, points)\n if points[0]<-1000 or points[1]>1000:\n print -1\n sys.exit(0)\n pt[i] = points\n\nif vert == 1:\n print -1\n sys.exit(0)\nelif vert == 2:\n point1 = pt[0]\n point2 = pt[1]\n if point1[0] != point2[0] and point1[1] != point2[1]:\n pass\n else:\n print -1\n sys.exit(0)\n area = abs(point1[0] - point2[0])*abs(point1[1] - point2[1])\n print area\n sys.exit(0)\nelif vert == 3:\n point1 = pt[0]\n point2 = pt[1]\n point3 = pt[2]\n if point1[0] != point2[0] and point1[1] != point2[1]:\n area = abs(point1[0] - point2[0])*abs(point1[1] - point2[1])\n print area\n sys.exit(0)\n elif point1[0] != point3[0] and point1[1] != point3[1]:\n area = abs(point1[0] - point3[0])*abs(point1[1] - point3[1])\n print area\n sys.exit(0)\n elif point2[0] != point3[0] and point2[1] != point3[1]:\n area = abs(point2[0] - point3[0])*abs(point2[1] - point3[1])\n print area\n sys.exit(0)\n print -1\n sys.exit(0)\nelif vert == 4:\n point1 = pt[0]\n point2 = pt[1]\n point3 = pt[2]\n point4 = pt[3]\n if point1[0] != point2[0] and point1[1] != point2[1]:\n area = abs(point1[0] - point2[0])*abs(point1[1] - point2[1])\n print area\n sys.exit(0)\n elif point1[0] != point3[0] and point1[1] != point3[1]:\n area = abs(point1[0] - point3[0])*abs(point1[1] - point3[1])\n print area\n sys.exit(0)\n elif point1[0] != point4[0] and point1[1] != point4[1]:\n area = abs(point1[0] - point4[0])*abs(point1[1] - point4[1])\n print area\n sys.exit(0)\n elif point2[0] != point3[0] and point2[1] != point3[1]:\n area = abs(point2[0] - point3[0])*abs(point2[1] - point3[1])\n print area\n sys.exit(0)\n elif point2[0] != point4[0] and point2[1] != point4[1]:\n area = abs(point2[0] - point4[0])*abs(point2[1] - point4[1])\n print area\n sys.exit(0) \n elif point3[0] != point4[0] and point3[1] != point4[1]:\n area = abs(point3[0] - point4[0])*abs(point3[1] - point4[1])\n print area\n sys.exit(0) \n print -1\n sys.exit(0)\n"}, {"source_code": "n=input()\nx=[]\ny=[]\nfor i in range(0,n):\n a,b=(int(i) for i in raw_input().split())\n x.append(a)\n y.append(b)\n f=0\nfor i in range(0,n):\n for j in range(i+1,n):\n if(x[i]!=x[j] and y[i]!=y[j]):\n print abs(x[i]-x[j])*abs(y[i]-y[j])\n f=1\n break\n if(f==1):\n break\nif(f==0):\n print -1"}, {"source_code": "v=zip(*[map(int,raw_input().split()) for _ in range(input())])\nprint (max(v[0])-min(v[0]))*(max(v[1])-min(v[1])) or -1\n"}, {"source_code": "sx = set()\nsy = set()\nn = int(raw_input())\n\nwhile n>0:\n n-=1\n x,y=map(int,raw_input().split())\n sx.add(x)\n sy.add(y)\nif len(sx) == 2 and len(sy)==2 :\n print abs(sx.pop()-sx.pop())*abs(sy.pop()-sy.pop())\nelse:\n print\"-1\"\n"}, {"source_code": "v=zip(*[map(int,raw_input().split()) for _ in range(input())])\na=(max(v[0])-min(v[0]))*(max(v[1])-min(v[1]))\nprint a or -1\n"}, {"source_code": "\ndef main():\n\tn = input()\n\tif n == 1:\n\t\tprint '-1'\n\t\treturn\n\n\tvertex = []\n\tfor _ in xrange(n):\n\t\tx,y = map(int, raw_input().split())\n\t\tvertex += [(x,y)]\n\n\tl=0\n\th=0\n\tfor i in xrange(n):\n\t\tfor j in xrange(i+1,n):\n\t\t\tif vertex[i][0] != vertex[j][0]:\n\t\t\t\tl = abs(vertex[i][0]-vertex[j][0])\n\t\t\tif vertex[i][1] != vertex[j][1]:\n\t\t\t\th = abs(vertex[i][1]-vertex[j][1])\n\n\tif l==0 or h==0:\n\t\tprint -1\n\t\treturn\n\t\t\n\tprint l*h\n\t\t\t\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "def solve():\n import math\n r=raw_input\n t=int(r())\n if t == 1:\n print -1\n exit()\n if t == 2:\n l = []\n for _ in xrange(t):\n x,y = map(int,r().split())\n l.append((x,y))\n if l[0][0] == l[1][0] or l[0][1] == l[1][1]:\n print -1\n exit()\n print ( abs(l[0][0]-l[1][0]) * abs(l[0][1]-l[1][1]) )\n exit()\n elif t == 3:\n l = []\n for _ in xrange(t):\n x,y = map(int,r().split())\n l.append((x,y))\n l.sort()\n i = 0\n j = 2\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n i = 0\n j = 1\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n i = 1\n j = 2\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n print -1\n exit()\n elif t == 4:\n l = []\n for _ in xrange(t):\n x,y = map(int,r().split())\n l.append((x,y))\n l.sort()\n i = 0\n j = 3\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n i = 0\n j = 2\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n i = 0\n j = 1\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n i = 1\n j = 3\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n i = 1\n j = 2\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n i = 2\n j = 3\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n print -1\n exit()\nsolve()\n \n \n \n\n"}, {"source_code": "n = int(input())\nmaxX = maxY = -1001\nminX = minY = 1001\nfor i in range(n):\n x, y = map(int, input().split())\n maxX = max(maxX, x)\n minX = min(minX, x)\n maxY = max(maxY, y)\n minY = min(minY, y)\ns = (maxX - minX) * (maxY - minY)\nprint(s if s > 0 else -1)\n"}, {"source_code": "def basseyn(lst1, lst2):\n result = -1\n for i in range(len(lst1)):\n for j in range(i, len(lst1)):\n if lst1[i] != lst1[j] and lst2[i] != lst2[j]:\n result = abs(lst1[i] - lst1[j]) * abs(lst2[i] - lst2[j])\n return result\n\n\nn = int(input())\nX = list()\nY = list()\nfor i in range(n):\n x, y = [int(i) for i in input().split()]\n X.append(x)\n Y.append(y)\nprint(basseyn(X, Y))\n"}, {"source_code": "n=int(input())\na=[]\nfor i in range(n):\n b= list(map(int, input().split()))\n a.append(b)\nif n==1:print(-1)\nelif n==2:\n if a[0][0]!=a[1][0] and a[0][1]!=a[1][1]:\n print(abs(a[0][0]-a[1][0])*abs(a[0][1]-a[1][1]))\n else:print(-1)\nelif n==3:\n x1,x2,x3,y1,y2,y3=a[0][0],a[1][0],a[2][0],a[0][1],a[1][1],a[2][1]\n if x1-x2!=0 and y1-y2!=0:print(abs(x1-x2)*abs(y1-y2))\n elif x1-x3!=0 and y1-y3!=0:print(abs(x1-x3)*abs(y1-y3))\n else:print(abs(x3-x2)*abs(y3-y2))\nelse:\n x1,x2,x3,x4,y1,y2,y3,y4=a[0][0],a[1][0],a[2][0],a[3][0],a[0][1],a[1][1],a[2][1],a[3][1]\n if x1-x2!=0 and y1-y2!=0:print(abs(x1-x2)*abs(y1-y2))\n elif x1-x3!=0 and y1-y3!=0:print(abs(x1-x3)*abs(y1-y3))\n else:print(abs(x1-x4)*abs(y1-y4))\n"}, {"source_code": "n = int(input())\nx = []\ny = []\narea = 0\nfor i in range(n):\n li = list(map(int, input().strip().split(\" \")))\n x.append(li[0])\n y.append(li[1])\nresult = ((max(x)-min(x))*(max(y)-min(y)))\nprint(result if result > 0 else -1)"}, {"source_code": "x=[]\ny=[]\nI=lambda:list(map(int,input().split()))\nfor _ in '0'*I()[0]:s=I();x+=[s[0]];y+=[s[1]]\nt=(max(x)-min(x))*(max(y)-min(y))\nprint([t,-1][not t])"}, {"source_code": "# -*- coding: utf-8 -*-\nn = int(raw_input())\nx, y = set(), set()\n\nif n == 1:\n print('-1')\nelse:\n for i in xrange(n):\n _x, _y = map(int, raw_input().split(' '))\n x.add(_x)\n y.add(_y)\n if len(x) > 1 and len(y) > 1:\n x = list(set(x))\n y = list(set(y))\n print(abs(x[0]-x[1])*abs(y[0]-y[1]))\n else:\n print('-1')\n"}, {"source_code": "n=int(input())\nip1=[]\nip2=[]\nfor i in range(n):\n a,b=map(int,input().split())\n ip1.append(a)\n ip2.append(b)\nif n<=1:\n print(-1)\nelif n>=3:\n ip1=sorted(ip1)\n ip2=sorted(ip2)\n print(abs(ip1[-1]-ip1[0])*abs(ip2[-1]-ip2[0]))\nelse:\n a,b=ip1[0],ip2[0]\n c,d=ip1[1],ip2[1]\n if a==c or b==d:\n print(-1)\n else:\n print(abs(c-a)*abs(d-b))\n \n \n"}, {"source_code": "import math\nverno=int(raw_input())\npointlist= list()\nfor i in range(verno):\n point=map(int, raw_input().split())\n pointlist.append(point[0])\n pointlist.append(point[1])\n#print pointlist\n\nl=0\nw=0\nif verno==1:\n print -1\n \nelif verno==2:\n if pointlist[0]!=pointlist[2] and pointlist[1]!=pointlist[3]:\n l= abs(pointlist[1] - pointlist[3])\n w= abs(pointlist[0] - pointlist[2])\n print l*w\n else:\n print -1\n \nelif verno==3:\n if pointlist[0]==pointlist[2]:\n l= abs(pointlist[1] - pointlist[3])\n w= abs(pointlist[0] - pointlist[4])\n elif pointlist[0]==pointlist[4]:\n l= abs(pointlist[1] - pointlist[5])\n w= abs(pointlist[0] - pointlist[2])\n elif pointlist[2]==pointlist[4]:\n l= abs(pointlist[3] - pointlist[5])\n w= abs(pointlist[0] - pointlist[2])\n print l*w\n \nelif verno==4:\n if pointlist[0]==pointlist[2]:\n l= abs(pointlist[1] - pointlist[3])\n w= abs(pointlist[0] - pointlist[4])\n elif pointlist[0]==pointlist[4]:\n l= abs(pointlist[1] - pointlist[5])\n w= abs(pointlist[0] - pointlist[2])\n elif pointlist[2]==pointlist[4]:\n l= abs(pointlist[3] - pointlist[5])\n w= abs(pointlist[0] - pointlist[2])\n if pointlist[0]==pointlist[6]:\n l= abs(pointlist[1] - pointlist[7])\n w= abs(pointlist[0] - pointlist[2])\n elif pointlist[2]==pointlist[6]:\n l= abs(pointlist[3] - pointlist[7])\n w= abs(pointlist[0] - pointlist[2])\n elif pointlist[2]==pointlist[4]:\n l= abs(pointlist[5] - pointlist[7])\n w= abs(pointlist[2] - pointlist[4])\n print l*w\n "}, {"source_code": "# your code goes here\nn = input()\npx = set()\npy = set()\nfor z in xrange(n):\n x,y = [int(r) for r in raw_input().split()]\n px.add(x)\n py.add(y)\n\nif len(px) == len(py) == 2:\n xdiff = max(px)-min(px)\n ydiff = max(py)-min(py)\n print xdiff*ydiff\nelse:\n print -1"}, {"source_code": "__author__ = 'abd el rahman'\nn = int(raw_input())\nif n ==1:\n print -1\nelif n ==2:\n x1,y1 = map(int ,raw_input().split())\n x2,y2 = map(int ,raw_input().split())\n\n if x1 == x2 or y1 == y2:\n print -1\n else:\n print abs((x2-x1) * (y2-y1))\n\nelse:\n x= [0]*n\n y = [0]*n\n for i in range(0,n):\n x[i],y[i] = map(int , raw_input().split())\n x = sorted(x)\n y = sorted(y)\n print abs((x[0]- x[-1]) * (y[0]-y[-1]))"}, {"source_code": "def check(a, b):\n return a[0] != b[0] and a[1] != b[1]\n\n\ndef S(a, b):\n return abs(a[0] - b[0]) * abs(a[1] - b[1])\n\n\nn = int(input())\npoints = list(tuple(map(int, input().split())) for i in range(n))\n\nif n == 1:\n print(-1)\n\nelif n == 2:\n print(S(points[0], points[1])) if check(points[0], points[1]) else print(-1)\n\nelse:\n for i in range(n):\n for j in range(i + 1, n):\n if check(points[i], points[j]):\n print(S(points[i], points[j]))\n exit()\n\n print(-1)"}, {"source_code": "n = int(raw_input())\na = [map(int, raw_input().split()) for _ in xrange(n)]\nt = (max(x[0] for x in a) - min(x[0] for x in a)) * (max(x[1] for x in a) - min(x[1] for x in a))\nif t == 0:\n print -1\nelse:\n print t\n"}, {"source_code": "a = raw_input()\na = int(a)\n\nm = []\nfor i in xrange(a):\n temp = map(int, raw_input().split(' '))\n m.append(temp)\nif a < 2:\n print -1\n exit()\nelif a == 2:\n x,y = m\n if x[0] == y[0] or x[1] == y[1]:\n print -1\n exit()\nelse:\n x = m[0]\n y = False\n for i in m[1:]:\n if x[0] == i[0] or x[1] == i[1]:\n pass\n else:\n y = i\n if y:\n pass\n else:\n x = m[1]\n y = m[2]\nprint abs(x[0]-y[0])*abs(x[1]-y[1])\n"}, {"source_code": "v=zip(*[map(int,raw_input().split()) for _ in range(input())])\nprint (max(v[0])-min(v[0]))*(max(v[1])-min(v[1])) or -1"}, {"source_code": "import sys\n\ndef main(argv):\n\tnum = int(raw_input())\n\n\tif num < 2:\n\t\tprint \"-1\"\n\t\tsys.exit()\n\n\tpoints = list()\n\tfor x in xrange(num):\n\t\tpos = [int(item) for item in raw_input().split(' ')]\n\t\tpoints.append(pos)\n\n\tif num == 2:\n\t\tif points[0][0] == points[1][0] or points[0][1] == points[1][1]:\n\t\t\tprint \"-1\"\n\t\t\tsys.exit()\n\n\tlen1 = 0\n\tlen2 = 0\n\tindex = 0\n\twhile len1 == 0 or len2 == 0:\n\t\tif points[index][0] != points[index + 1][0]:\n\t\t\tlen1 = abs(points[index][0] - points[index + 1][0])\n\n\t\tif points[index][1] != points[index + 1][1]:\n\t\t\tlen2 = abs(points[index][1] - points[index + 1][1])\n\t\tindex += 1\n\n\tprint repr(len1 * len2)\n\n\nif __name__ == \"__main__\":\n\tmain(sys.argv)"}, {"source_code": "import sys\n\ndef solve(points):\n if len(points) < 2:\n return -1\n\n if len(points) == 2:\n dx = abs(points[0][0] - points[1][0])\n dy = abs(points[0][1] - points[1][1])\n if dx == 0 or dy == 0:\n return -1\n else:\n return dx*dy\n else:\n dx = abs(points[0][0] - points[1][0])\n if dx == 0:\n dx = abs(points[0][0] - points[2][0])\n \n dy = abs(points[0][1] - points[1][1])\n if dy == 0:\n dy = abs(points[0][1] - points[2][1])\n\n return dx*dy\n\nif __name__=='__main__':\n lines = sys.stdin.readlines()\n\n n = int(lines[0].strip().split()[0])\n\n points = []\n\n for i in range(n):\n x, y = [int(v) for v in lines[i+1].strip().split()]\n points.append([x, y])\n\n print solve(points)"}, {"source_code": "x = set()\ny = set()\nfor _ in range(int(raw_input())):\n\n a,b = map(int,raw_input().split())\n x.add(a)\n y.add(b)\nx=list(x)\ny = list(y)\n\nif len(x)==2 and len(y)==2:\n print abs((x[1]-x[0])*(y[1]-y[0]))\nelse:\n print -1\n\n \n"}, {"source_code": "#!/usr/bin/python\n\nfrom collections import deque\n\ndef ir():\n return int(raw_input())\n\ndef ia():\n line = raw_input()\n line = line.split()\n return map(int, line)\n\nn = ir()\n\ndef smin(a, b):\n if a==None: return b\n elif b==None: return a\n else : return min(a, b)\n\ndef smax(a, b):\n if a==None: return b\n elif b==None: return a\n else : return max(a, b)\n\nx_mi = x_ma = y_mi = y_ma = None \nfor i in range(n):\n x, y = ia()\n x_ma = smax(x, x_ma); x_mi = smin(x, x_mi);\n y_ma = smax(y, y_ma); y_mi = smin(y, y_mi);\n\nrc = \\\n x_ma!=None and x_mi!=None and y_ma!=None and y_mi!=None and x_ma!=x_mi and y_ma!=y_mi\n\nprint (x_ma-x_mi)*(y_ma-y_mi) if rc else -1\n\n\n"}, {"source_code": "x=int(input())\ns=[]\nOx=[]\nOy=[]\nl=1\nfor i in range (x):\n s.append(raw_input())\n s1=s[i].split()\n Ox.append(s1[0])\n Oy.append(s1[1])\nif(x==1):\n print '-1'\nelif(x>1):\n for j in range (x):\n for i in range (x):\n if(int(Ox[j])!=int(Ox[i]) and int(Oy[j])!=int(Oy[i]) and l==1):\n print abs(int(Ox[i])-int(Ox[j]))*abs(int(Oy[i])-int(Oy[j]))\n l=0\n if(l==1):\n print '-1'\n"}, {"source_code": "N = int(raw_input())\n\nif N == 1:\n\tprint -1\n\texit()\nA = set()\nB = set()\nfor _ in range(N):\n\ttmp = map(int, raw_input().split())\n\tA.add(tmp[0])\n\tB.add(tmp[1])\n\nA = list(A)\nB = list(B)\n\nif len(A) == 2 and len(B) == 2:\n\tprint abs(A[1] - A[0]) * abs(B[1] - B[0])\nelse:\n\tprint -1\n"}, {"source_code": "def solve(n, verts):\n\tif n == 1:\n\t\treturn -1\n\tif n == 2:\n\t\tif verts[0][0] == verts[1][0] or verts[0][1] == verts[1][1]:\n\t\t\treturn -1\n\t\telse:\n\t\t\treturn abs(verts[0][0] - verts[1][0]) * abs(verts[0][1] - verts[1][1])\n\tif n == 3 or n == 4:\n\t\tgreatestX = -100000\n\t\tgreatestY = -100000\n\t\tlowestX = 100000\n\t\tlowestY = 100000\n\t\tfor i in verts:\n\t\t\tif i[0] < lowestX:\n\t\t\t\tlowestX = i[0]\n\t\t\tif i[1] < lowestY:\n\t\t\t\tlowestY = i[1]\n\t\t\tif i[0] > greatestX:\n\t\t\t\tgreatestX = i[0]\n\t\t\tif i[1] > greatestY:\n\t\t\t\tgreatestY = i[1]\n\t\treturn abs(greatestX - lowestX) * abs(greatestY - lowestY)\n\nn = int(raw_input())\nverts = [map(int, raw_input().split()) for i in range(n)]\nprint solve(n, verts)\n"}, {"source_code": "n = int(input())\nres = -1\nif n > 1:\n if n > 2:\n a = list(input().split(' '))\n x1, y1 = int(a[0]), int(a[1])\n a = list(input().split(' '))\n x2, y2 = int(a[0]), int(a[1])\n a = list(input().split(' '))\n x3, y3 = int(a[0]), int(a[1])\n if n == 4:\n a = list(input().split(' '))\n x4, y4 = int(a[0]), int(a[1])\n if x1 != x2 and y1 != y2:\n res = abs(x1 - x2) * abs(y1 - y2)\n elif x1 != x3 and y1 != y3:\n res = abs(x1 - x3) * abs(y1 - y3)\n elif x2 != x3 and y2 != y3:\n res = abs(x2 - x3) * abs(y2 - y3)\n elif n == 4:\n res = abs(x1 - x4) * abs(y1 - y4)\n else:\n a = list(input().split(' '))\n x1, y1 = int(a[0]), int(a[1])\n a = list(input().split(' '))\n x2, y2 = int(a[0]), int(a[1])\n if x1 != x2 and y1 != y2:\n res = abs(x1 - x2) * abs(y1 - y2)\nprint(res)\n"}, {"source_code": "a=int(raw_input())\narr=[]\nfor i in xrange (a):\n arr+=[map(int,raw_input().split())]\nif a == 1:\n print -1\nif a == 2:\n x=arr[0][0]-arr[1][0]\n y=arr[0][1]-arr[1][1]\n if abs(x*y) == 0:\n print -1\n else:\n print abs(x*y)\nif a == 3 or a == 4:\n minx = 1000\n maxx = -1000\n miny = 1000\n maxy = -1000\n for i in arr:\n if i[0] < minx:\n minx = i[0]\n if i[0] > maxx:\n maxx = i[0]\n if i[1] < miny:\n miny = i[1]\n if i[1] > maxy:\n maxy = i[1]\n x = maxx-minx\n y = maxy-miny\n if abs(x*y) == 0:\n print -1\n else:\n print abs(x*y)\n \n"}, {"source_code": "#!/usr/bin/env python3\n# 596A_pool.py - Codeforces.com/problemset/problem/596/A by Sergey 2015\n\nimport unittest\nimport sys\n\n###############################################################################\n# Pool Class (Main Program)\n###############################################################################\n\n\nclass Pool:\n \"\"\" Pool representation \"\"\"\n\n def __init__(self, test_inputs=None):\n \"\"\" Default constructor \"\"\"\n\n it = iter(test_inputs.split(\"\\n\")) if test_inputs else None\n\n def uinput():\n return next(it) if it else sys.stdin.readline().rstrip()\n\n # Reading single elements\n [self.n] = map(int, uinput().split())\n\n # Reading multiple number of lines of the same number of elements each\n l, s = self.n, 2\n inp = (\" \".join(uinput() for i in range(l))).split()\n self.numm = [[int(inp[i]) for i in range(j, l*s, s)] for j in range(s)]\n self.numa, self.numb = self.numm\n\n def calculate(self):\n \"\"\" Main calcualtion function of the class \"\"\"\n\n result = 0\n m = min(3, len(self.numa))\n\n for i in range(m):\n for j in range(i+1, m):\n result += abs(\n (self.numa[i] - self.numa[j]) *\n (self.numb[i] - self.numb[j]))\n if result == 0:\n result = -1\n\n return str(result)\n\n###############################################################################\n# Unit Tests\n###############################################################################\n\n\nclass unitTests(unittest.TestCase):\n\n def test_single_test(self):\n \"\"\" Pool class testing \"\"\"\n\n # Constructor test\n test = \"2\\n0 0\\n1 1\"\n d = Pool(test)\n self.assertEqual(d.n, 2)\n self.assertEqual(d.numa, [0, 1])\n self.assertEqual(d.numb, [0, 1])\n\n # Sample test\n self.assertEqual(Pool(test).calculate(), \"1\")\n\n # Sample test\n test = \"1\\n1 1\"\n self.assertEqual(Pool(test).calculate(), \"-1\")\n\n # Sample test\n test = \"4\\n2 2\\n3 3\\n2 3\\n3 2\"\n self.assertEqual(Pool(test).calculate(), \"1\")\n\n # My tests\n test = \"2\\n100 100\\n0 0\"\n self.assertEqual(Pool(test).calculate(), \"10000\")\n\n # Time limit test\n # self.time_limit_test(5000)\n\n def time_limit_test(self, nmax):\n \"\"\" Timelimit testing \"\"\"\n import random\n import timeit\n\n # Random inputs\n test = str(nmax) + \" \" + str(nmax) + \"\\n\"\n numnums = [str(i) + \" \" + str(i+1) for i in range(nmax)]\n test += \"\\n\".join(numnums) + \"\\n\"\n nums = [random.randint(1, 10000) for i in range(nmax)]\n test += \" \".join(map(str, nums)) + \"\\n\"\n\n # Run the test\n start = timeit.default_timer()\n d = Pool(test)\n calc = timeit.default_timer()\n d.calculate()\n stop = timeit.default_timer()\n print(\"\\nTimelimit Test: \" +\n \"{0:.3f}s (init {1:.3f}s calc {2:.3f}s)\".\n format(stop-start, calc-start, stop-calc))\n\nif __name__ == \"__main__\":\n\n # Avoiding recursion limitaions\n sys.setrecursionlimit(100000)\n\n if sys.argv[-1] == \"-ut\":\n unittest.main(argv=[\" \"])\n\n # Print the result string\n sys.stdout.write(Pool().calculate())\n"}, {"source_code": "n=input()\na=set()\nb=set()\nfor _ in xrange(n):\n t=map(int,raw_input().split())\n a.add(t[0])\n b.add(t[1])\nans=-1\nif len(a)==2 and len(b)==2:\n a=list(a)\n b=list(b)\n a.sort()\n b.sort()\n ans=(b[1]-b[0])*(a[1]-a[0])\nprint ans\n"}, {"source_code": "__author__ = 'MoonBall'\n\nli = [list(map(int,input().split())) for i in range(int(input()))]\nsx,sy = set(i[0] for i in li),set(i[1] for i in li)\nprint ((max(sx)-min(sx))*(max(sy)-min(sy)) or -1)"}, {"source_code": "def area(ps):\n xl = [p[0] for p in ps]\n yl = [p[1] for p in ps]\n lx = max(xl)-min(xl)\n ly = max(yl)-min(yl)\n return lx*ly if lx*ly>0 else -1\n \nps = [list(map(int,input().split())) for _ in range(int(input()))]\nprint(area(ps))\n "}, {"source_code": "#!/usr/bin/python3\n\nn = int(input())\narr = [tuple(map(int, input().split())) for i in range(n)]\narr.sort()\n\nmna = 1791\nmxa = -1791\nmnb = 1791\nmxb = -1791\nfor i in range(n):\n mna = min(mna, arr[i][0])\n mnb = min(mnb, arr[i][1])\n mxa = max(mxa, arr[i][0])\n mxb = max(mxb, arr[i][1])\n\nif mna == mxa or mnb == mxb:\n print(-1)\nelse:\n print((mxa - mna) * (mxb - mnb))\n"}, {"source_code": "__author__ = 'MoonBall'\n\nimport sys\n# sys.stdin = open('A.in', 'r')\n\nli = [list(map(int,input().split())) for i in range(int(input()))]\nsx,sy = set(i[0] for i in li),set(i[1] for i in li)\nprint ((max(sx)-min(sx))*(max(sy)-min(sy)) or -1)"}, {"source_code": "import math as mt \nimport sys,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\ndef dist(x,y,c,d):\n return mt.sqrt((x-c)**2+(y-d)**2)\ndef circle(x1, y1, x2,y2, r1, r2): \n \n distSq = (((x1 - x2)* (x1 - x2))+ ((y1 - y2)* (y1 - y2)))**(.5) \n \n if (distSq + r2 <= r1): \n return True\n else: \n return False\n\nn=I()\nif(n==1):\n c,d=M()\n print(-1)\nelif(n==2):\n a,b=M()\n c,d=M()\n x=abs(a-c)*abs(b-d)\n if(x):\n print(x)\n else:\n print(-1)\nelse:\n sx=set([])\n sy=set([])\n for i in range(n):\n a,b=M()\n sx.add(a)\n sy.add(b)\n sx=list(sx)\n sy=list(sy)\n print(abs(sx[0]-sx[1])*abs(sy[0]-sy[1]))\n \n"}, {"source_code": "n = int(raw_input())\n\n\nxs = []\nys = []\nfor i in range(n):\n s = raw_input().split(\" \")\n x = int(s[0])\n y = int(s[1])\n xs.append(x)\n ys.append(y)\n\nans = -1\n \nfor i in range(n):\n x1 = xs[i]\n y1 = ys[i]\n for j in range(i, n):\n x2 = xs[j]\n y2 = ys[j]\n if x1 != x2 and y1 != y2:\n ans = abs(x2-x1)*abs(y2-y1)\n break\nprint ans \n \n "}, {"source_code": "import sys\ndef i(): return sys.stdin.readline().strip()\n\nn=int(i())\nx,y=[],[]\nfor e in xrange(n):\n _=i().split(\" \")\n info=(int(_[0]),int(_[1]))\n if len(x)==0:\n x.append(info[0])\n else:\n if info[0] not in x:\n x.append(info[0])\n if len(y)==0:\n y.append(info[1])\n else:\n if info[1] not in y:\n y.append(info[1])\n\n#print x,y\nif len(x)==2 and len(y)==2:\n print abs(x[0]-x[1])*abs(y[0]-y[1])\nelse:\n print -1\n"}, {"source_code": "__author__ = 'suvasish'\n\ndef make_positive(num):\n return num * -1\n\ndef chek_positive(num):\n if num >= 1:\n return num\n else:\n return make_positive(num)\n\nvertices = []\nx_axis = []\ny_axis = []\n\nn = int(input())\nif n == 1:\n z = input()\n print(-1)\n exit(0)\n\nfor r in range(0, n):\n vertices.append(list(map(int, input().split(' '))))\n for itm in vertices:\n x_val = itm[0]\n if x_val not in x_axis:\n x_axis.append(x_val)\n y_val = itm[1]\n if y_val not in y_axis:\n y_axis.append(y_val)\n# print('X:', x_axis, '---', 'Y:', y_axis)\nif len(x_axis) == 1 or len(y_axis) == 1:\n print(-1)\n exit(0)\nx_axis.sort()\ny_axis.sort()\n# print('X:', x_axis, '---', 'Y:', y_axis)\nlength = x_axis[-1] - x_axis[0]\nwidth = y_axis[-1] - y_axis[0]\n# print('length: ', length)\n# print('width: ', width)\n\nprint(chek_positive(length*width))"}, {"source_code": "import sys\nn = int(input())\na = []\nfor i in range(n):\n a.append(list(map(int,input().split())))\nif n <= 1:\n print(-1)\n sys.exit()\nfor i in range(n):\n for o in range(i+1, n):\n if a[i][0] != a[o][0] and a[i][1] != a[o][1]:\n print(abs(a[i][0] - a[o][0]) * abs(a[i][1] - a[o][1]))\n sys.exit()\nprint(-1)"}, {"source_code": "n=int(input())\nif n<2:\n print(-1)\nelse:\n x=set()\n y=set()\n for i in range(n):\n a=tuple(map(int,input().split()))\n x.add(a[0])\n y.add(a[1])\n if len(y)>1 and len(x)>1:\n print((max(y)-min(y))*(max(x)-min(x)))\n else:\n print(-1)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Nov 15 19:36:30 2015\n\n@author: fedor\n\"\"\"\n\nn_vert = input()\nvert = []\nfor i in xrange(n_vert):\n vert.append(map(int, raw_input().strip().split()))\nif n_vert == 1:\n print(-1)\nelif n_vert == 2:\n x1, y1 = vert[0]\n x2, y2 = vert[1]\n if x1 != x2 and y1 != y2:\n square = abs(x2 - x1)*abs(y2 - y1)\n print(square)\n else:\n print(-1)\nelse:\n x, y = zip(*vert)\n x_max = max(x)\n x_min = min(x)\n y_max = max(y)\n y_min = min(y)\n square = (x_max - x_min)*(y_max - y_min)\n print(square)"}, {"source_code": "import math\n\ndef get_n():\n return int(input())\n\ndef get_int_vector():\n return [int(x) for x in input().split()]\n\ndef list2string(list):\n result = []\n for i in list:\n result.append(str(i))\n return ':'.join(result)\n\ndef string2vector(string):\n return [int(x) for x in string.split(':')]\n\nn = get_n()\n\npoints = []\nfor _ in range(n):\n points.append(get_int_vector())\n\npoints.sort(key=lambda x: x[1])\npoints.sort(key=lambda x: x[0])\n\nif n == 1:\n print(-1)\n exit(0)\nif n == 2 and (points[0][0] == points[1][0] or points[0][1] == points[1][1]):\n print(-1)\n exit(0)\n\nif n == 3:\n a, b = 0, 0\n if points[0][0] != points[1][0]:\n a = abs(points[1][0]-points[0][0])\n else:\n a = abs(points[2][0]-points[0][0])\n if points[0][1] != points[1][1]:\n b = abs(points[1][1]-points[0][1])\n else:\n b = abs(points[2][1]-points[0][1])\n print(a*b)\nelif n == 2:\n print(abs(points[0][0]-points[1][0])*abs(points[0][1]-points[1][1]))\nelse:\n print(abs(points[0][1]-points[1][1])*abs(points[0][0]-points[3][0]))\n\n\n\n\n"}, {"source_code": "\ndef solve(x, y):\n if len(x) < 2:\n return -1\n elif len(x) == 2:\n if x[0] == x[1] or y[0] == y[1]:\n return - 1\n else:\n return abs(x[0] - x[1]) * abs(y[0] - y[1])\n else:\n for i in range(len(x)):\n for j in range(len(x)):\n if x[i] != x[j] and y[i] != y[j]:\n return abs(x[i] - x[j]) * abs(y[i] - y[j])\n return - 1\n\n\ndef main():\n cases = raw_input()\n x = []\n y = []\n for _ in range(int(cases)):\n line = raw_input()\n line_s = line.split()\n x.append(int(line_s[0]))\n y.append(int(line_s[1]))\n\n print solve(x, y)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "v=zip(*[map(int,raw_input().split()) for _ in range(input())])\nprint (max(v[0])-min(v[0]))*(max(v[1])-min(v[1])) or -1\n"}, {"source_code": "# Problem 596A - \"Wilbur and Swimming Pool\"\n\ndef get_area(pts):\n\treturn abs( (pts[0][0]-pts[1][0]) * (pts[0][1]-pts[1][1]) )\n\nn = int(raw_input())\npts, arg = [], []\nfor i in xrange(0, n):\n\tr = raw_input()\n\tpts.append( [int(x) for x in r.split(' ')] )\n\nif n == 1:\n\tprint -1\n\nelif n == 2:\n\tif pts[0][0] == pts[1][0] or pts[0][1] == pts[1][1]:\n\t\tprint -1\n\telse:\n\t\tprint get_area(pts)\n\nelif n == 3:\n\tif pts[0][0] == pts[1][0] or pts[0][1] == pts[1][1]:\n\t\tif pts[0][0] == pts[2][0] or pts[0][1] == pts[2][1]:\n\t\t\targ.extend( [pts[1], pts[2]] )\n\t\telse:\n\t\t\targ.extend( [pts[0], pts[2]] )\n\telse:\n\t\targ.extend( [pts[0], pts[1]] )\n\t\n\tprint get_area(arg)\n\nelse:\n\tfor i in xrange(1, n):\n\t\tif pts[0][0] != pts[i][0] and pts[0][1] != pts[i][1]:\n\t\t\targ.extend( [pts[0], pts[i]] )\n\t\t\tbreak\t\n\n\tprint get_area(arg)\n\nexit(0)\n"}, {"source_code": "n = int(input())\nif n == 1:\n print(-1)\n exit()\nx = [0] * n\ny = [0] * n\nfor i in range(n):\n x[i], y[i] = map(int, input().split())\nif n == 2:\n if x[0] == x[1] or y[0] == y[1]:\n print(-1)\n else:\n print(abs(x[0]-x[1]) * abs(y[0]-y[1]))\nelse:\n for i in range(n):\n for j in range(n):\n if x[i] != x[j] and y[i] != y[j]:\n print(abs(x[i]-x[j]) * abs(y[i]-y[j]))\n exit()"}, {"source_code": "n=int(input())\nl=[]\nfor i in range(n):\n l1,l2=input().split()\n l.append([int(l1),int(l2)])\n\nif(n<=1):\n print(-1)\nelse:\n if(n==2):\n if(l[0][0]==l[1][0] or l[0][1]==l[1][1]):\n print(-1)\n else:\n print(abs(l[0][0]-l[1][0])*abs(l[0][1]-l[1][1]))\n else:\n print(abs(l[0][0]*(l[1][1]-l[2][1])+l[1][0]*(l[2][1]-l[0][1])+l[2][0]*(l[0][1]-l[1][1])))\n"}, {"source_code": "def judgeTwoPoints( pa , pb ):\n if pa[0] != pb[0] and pa[1] != pb[1]:\n #print( \"ok!\" , pa , pb , abs( pa[0] - pb[0] ) * abs( pa[1] - pb[1] ) )\n return abs( pa[0] - pb[0] ) * abs( pa[1] - pb[1] )\n else:\n return -1\n\ndef solve( pts , n ):\n if n == 1:\n return -1\n\n pts.sort()\n if n == 2:\n return judgeTwoPoints( pts[0] , pts[1] )\n if n == 3:\n resa = judgeTwoPoints( pts[0] , pts[1] )\n resb = judgeTwoPoints( pts[1] , pts[2] )\n resc = judgeTwoPoints( pts[0] , pts[2] )\n return max( resa , resb , resc )\n\n return judgeTwoPoints( pts[1] , pts[2] )\n\nif __name__ == \"__main__\":\n n = int( input() )\n pts = []\n for _ in range(n):\n pts.append( tuple([int(x) for x in input().split()]) )\n\n #print( pts )\n print( solve( pts , n ) )"}, {"source_code": "N=int(input())\nif N<2:\n print(-1)\nelif N==2:\n a=tuple(map(int,input().split()))\n b=tuple(map(int,input().split()))\n if a[0]!=b[0] and a[1]!=b[1]:\n print(abs(b[0]-a[0])*abs(b[1]-a[1]))\n else:\n print(-1)\nelif N==3:\n a=tuple(map(int,input().split()))\n b=tuple(map(int,input().split()))\n c=tuple(map(int,input().split()))\n print(abs((max(a[0],b[0],c[0])-min(a[0],b[0],c[0]))*(max(a[1],b[1],c[1])-min(a[1],b[1],c[1]))))\nelse:\n a=tuple(map(int,input().split()))\n b=tuple(map(int,input().split()))\n c=tuple(map(int,input().split()))\n d=tuple(map(int,input().split()))\n print(abs((max(a[0],b[0],c[0])-min(a[0],b[0],c[0]))*(max(a[1],b[1],c[1])-min(a[1],b[1],c[1]))))"}, {"source_code": "def Respuesta(X,Y):\n X1 = list(set(X))\n Y1 = list(set(Y))\n if (len(X1)== 2 and len(Y1)==2):\n return abs((Y1[1]-Y1[0])*(X1[1]-X1[0]))\n else:\n return -1\n\n\nn = int(input())\nX = []\nY = []\nfor i in range (0,n):\n L = input()\n L =L.split()\n X.append(int(L[0]))\n Y.append(int(L[1]))\n\nif n==1:\n print(-1)\nelse:\n print(Respuesta(X,Y))"}, {"source_code": "n = int(input())\nread = lambda : map(int,input().split())\nx1,y1 = read()\nx2=x1\ny2=y1\nfor _ in range(n-1):\n x,y = read()\n x1 = min(x1,x)\n x2 = max(x2,x)\n y1 = min(y1,y)\n y2 = max(y2,y)\nif x1==x2 or y1==y2:\n print(-1)\nelse:\n print((x2-x1)*(y2-y1))"}, {"source_code": "n=int(input())\nl=[]\nif n==0:\n print(\"-1\")\nelse:\n for i in range(n):\n x,y=map(int,input().split())\n l+=[[x,y]]\nif n==1 :\n print(\"-1\")\nelse:\n c=0\n for i in range(n-1):\n j=i+1\n while j<n:\n if l[j][0]!=l[i][0] and l[j][1]!=l[i][1]:\n result=(l[i][0]-l[j][0])*(l[i][1]-l[j][1])\n c=1\n break\n j+=1\n if c:\n if result<0:\n print(-result)\n else:\n print(result)\n break\n if not c:\n print('-1')\n \n"}, {"source_code": "#----Kuzlyaev-Nikita-Codeforces-----\n#------------08.04.2020-------------\n\nimport math\nalph=\"abcdefghijklmnopqrstuvwxyz\"\n\n#-----------------------------------\n\nn=int(input())\na=[]\nfor i in range(n):\n x,y=map(int,input().split())\n a.append([x,y])\nif n==1:print(-1)\nelse:\n S=0\n for i in range(n-1):\n for j in range(i+1,n):\n x1,y1,x2,y2=a[i][0],a[i][1],a[j][0],a[j][1]\n if x1!=x2 and y1!=y2:\n S=abs(x1-x2)*abs(y1-y2)\n \n if S!=0:print(S)\n else:\n print(-1)\n "}, {"source_code": "def area(ps):\n xl = [p[0] for p in ps]\n yl = [p[1] for p in ps]\n lx = max(xl)-min(xl)\n ly = max(yl)-min(yl)\n return lx*ly if lx*ly>0 else -1\n\nps = [list(map(int,input().split())) for _ in range(int(input()))]\nprint(area(ps))\n\n"}, {"source_code": "n=int(input())\na=[]\nfor i in range(n):\n b=list(map(int,input().split()))\n a.append(b)\nfor i in range(n):\n for j in range(n):\n if(a[i][0]!=a[j][0] and a[i][1]!=a[j][1]):\n print(abs(a[i][0]-a[j][0])*abs(a[i][1]-a[j][1]))\n exit()\nprint('-1')"}, {"source_code": "n = int(input())\npoints = [[int(x) for x in input().split()] for _ in range(n)]\nif n <= 1:\n\tprint(-1)\n\texit()\ndx = [1e9, -1e9]\ndy = [1e9, -1e9]\nfor x, y in points:\n\tdx[0] = min(dx[0], x)\n\tdx[1] = max(dx[1], x)\n\tdy[0] = min(dy[0], y)\n\tdy[1] = max(dy[1], y)\narea = (dx[1] - dx[0]) * (dy[1] - dy[0])\nif area:\n\tprint(area)\nelse:\n\tprint(-1)\n"}, {"source_code": "import sys\n# input_file = open(\"in.txt\")\ninput_file = sys.stdin\n\ninput_file.readline()\nx_coords = set()\ny_coords = set()\nfor line in input_file.readlines():\n x,y = map(int,line.rstrip().split())\n x_coords.add(x)\n y_coords.add(y)\nif len(x_coords) == 2 and len(y_coords)==2:\n print(abs(x_coords.pop()-x_coords.pop()) * abs(y_coords.pop()-y_coords.pop()))\n\nelse:\n print(-1)\n"}, {"source_code": "n = int(raw_input())\narr = []\nxs = set()\nys = set()\nfor i in range(n):\n x,y = map(int, raw_input().split())\n xs.add(x)\n ys.add(y)\n\nif len(xs) >= 2 and len(ys) >= 2:\n print (max(xs) - min(xs)) * (max(ys) - min(ys))\nelse:\n print -1\n"}, {"source_code": "n=int(input())\nto=[]\nif n==1:\n print(-1)\nelif n==2:\n for x in range(2):\n l,k=input().split()\n to.append(int(l))\n to.append(int(k))\n if to[0]!=to[2] and to[1]!=to[3]:\n print(abs(to[0]-to[2])*abs(to[1]-to[3]))\n else:\n print(-1)\nelif n==3:\n for x in range(3):\n l,k=input().split()\n to.append(int(l))\n to.append(int(k))\n if to[0]!=to[2] and to[1]!=to[3]:\n print(abs(to[0]-to[2])*abs(to[1]-to[3]))\n elif to[0]!=to[4] and to[1]!=to[5]:\n print(abs(to[0]-to[4])*abs(to[1]-to[5]))\n else:\n print(abs(to[2]-to[4])*abs(to[3]-to[5]))\nelse:\n for x in range(4):\n l,k=input().split()\n to.append(int(l))\n to.append(int(k))\n if to[0]!=to[2] and to[1]!=to[3]:\n print(abs(to[0]-to[2])*abs(to[1]-to[3]))\n elif to[0]!=to[4] and to[1]!=to[5]:\n print(abs(to[0]-to[4])*abs(to[1]-to[5]))\n else:\n print(abs(to[0]-to[6])*abs(to[1]-to[7]))"}, {"source_code": "n = int(input())\nmin_x, min_y, max_x, max_y = 1001, 1001, -1001, -1001\nfor _ in range(n):\n x, y = map(int, input().split())\n min_x = min(min_x, x)\n max_x = max(max_x, x)\n min_y = min(min_y, y)\n max_y = max(max_y, y)\nif min_x != max_x and min_y != max_y:\n print((max_x - min_x) * (max_y - min_y))\nelse:\n print(-1)\n \n"}, {"source_code": "v=zip(*[map(int,raw_input().split()) for _ in range(input())])\nprint (max(v[0])-min(v[0]))*(max(v[1])-min(v[1])) or -1\n"}, {"source_code": "n = int(input())\n\npoints = list()\n\nfor i in range(n):\n points.append(list(map(int, input().split())))\n\npoints.sort()\n\nif n <= 1:\n print(-1)\nelif n == 2:\n if points[0][0] != points[1][0] and points[0][1] != points[1][1]:\n print(abs((points[0][0] - points[1][0]) * (points[0][1] - points[1][1])))\n else:\n print(-1)\nelif n == 3:\n l1 = (points[0][0] - points[1][0]) ** 2 + (points[0][1] - points[1][1])**2\n l2 = (points[0][0] - points[2][0]) ** 2 + (points[0][1] - points[2][1])**2\n l3 = (points[2][0] - points[1][0]) ** 2 + (points[2][1] - points[1][1])**2\n ls = [l1, l2, l3]\n ls.sort()\n if ls[0] + ls[1] == ls[2]:\n print(abs(int(ls[0] ** 0.5 * ls[1] ** 0.5)))\n else:\n print(-1)\nelif n == 4:\n if (points[0][0] == points[1][0]) and \\\n (points[2][0] == points[3][0]) and \\\n (points[0][1] == points[2][1]) and \\\n (points[1][1] == points[3][1]):\n print(abs((points[0][1] - points[1][1]) * (points[0][0] - points[2][0])))\n else:\n print(-1)\n"}, {"source_code": "n = input()\nres = []\nfor i in range(n):\n\tk = map(int, raw_input().strip().split(' '))\n\tres.append(k)\nxma = -1111\nyma = -1111\nymi = 1111\nxmi = 1111\nfor x in res:\n\txma = max(xma, x[0])\n\txmi = min(xmi, x[0])\n\tyma = max(yma, x[1])\n\tymi = min(ymi, x[1])\nans = (xma - xmi) * (yma - ymi)\nif ans > 0:\n\tprint ans\nelse:\n\tprint -1"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/596/A\n\nd_y = {}\nd_x = {}\n\nl_c = list()\nl_c = list()\n\nn = int(input())\n\nfor _ in range(n):\n x, y = map(int, input().split())\n d_x[x] = 1\n d_y[y] = 1\n l_c.append([x, y])\n\nif len(d_x) + len(d_y) < 4:\n print(-1)\n quit()\n\nt_x = 0\nt_y = 0\ni = 1\nfor k_x in d_x:\n t_x += (-1 if i == 0 else 1) * k_x\n i = 0\ni = 1\nfor k_y in d_y:\n t_y += (-1 if i == 0 else 1) * k_y\n i = 0\n\nprint(abs(t_x) * abs(t_y)) \n \n "}, {"source_code": "from collections import namedtuple\n\ndef get_area(vertices):\n num_vertices = len(vertices)\n Vertex = namedtuple(\"Vertex\", [\"x\", \"y\"])\n vertices = [Vertex(*vertex) for vertex in vertices]\n if num_vertices <= 1:\n return -1\n\n # sort on x axis\n vertices = sorted(vertices)\n\n x_diff = 0\n y_diff = 0\n previous = vertices[0]\n for i in range(1, num_vertices):\n if x_diff and y_diff:\n return abs(y_diff * x_diff)\n else:\n if not x_diff and vertices[i].x != previous.x:\n x_diff = vertices[i].x - previous.x\n if not y_diff and vertices[i].y != previous.y:\n y_diff = vertices[i].y - previous.y\n previous = vertices[i]\n\n return abs(x_diff * y_diff) or -1\n\ndef get_raw_input():\n num_vertices = int(raw_input())\n vertices = []\n for i in range(num_vertices):\n vertex = raw_input().split(\" \")\n vertices.append((int(vertex[0]), int(vertex[1])))\n return vertices\n\nif __name__ == \"__main__\":\n vertices = get_raw_input()\n print get_area(vertices)\n"}, {"source_code": "n = int(input())\nif n == 1:\n a = str(input())\n print(-1)\nelif n == 2:\n a = str(input())\n b = str(input())\n a = a.split(' ')\n b = b.split(' ')\n i = 0\n for i in range(2):\n a[i] = int(a[i])\n b[i] = int(b[i])\n if a[1] == b[1] or a[0] == b[0]:\n print(-1)\n else:\n print(abs((a[1]-b[1])*(a[0]-b[0])))\nelif n == 3:\n a = str(input())\n b = str(input())\n c = str(input())\n a = a.split(' ')\n b = b.split(' ')\n c = c.split(' ')\n for i in range(2):\n a[i] = int(a[i])\n b[i] = int(b[i])\n c[i] = int(c[i])\n if a[1] != b[1] and a[0] != b[0]:\n print(abs((a[1] - b[1]) * (a[0] - b[0])))\n elif a[1] != c[1] and a[0] != c[0]:\n print(abs((a[1] - c[1]) * (a[0] - c[0])))\n else:\n print(abs((c[1] - b[1]) * (c[0] - b[0])))\nelif n == 4:\n a = str(input())\n b = str(input())\n c = str(input())\n d = str(input())\n a = a.split(' ')\n b = b.split(' ')\n c = c.split(' ')\n d = d.split(' ')\n for i in range(2):\n a[i] = int(a[i])\n b[i] = int(b[i])\n c[i] = int(c[i])\n d[i] = int(d[i])\n if a[1] != b[1] and a[0] != b[0]:\n print(abs((a[1] - b[1]) * (a[0] - b[0])))\n elif a[1] != c[1] and a[0] != c[0]:\n print(abs((a[1] - c[1]) * (a[0] - c[0])))\n elif a[1] != d[1] and a[0] != d[0]:\n print(abs((a[1] - d[1]) * (a[0] - d[0])))\n elif b[1] != c[1] and b[0] != c[0]:\n print(abs((b[1] - c[1]) * (b[0] - c[0])))\n elif b[1] != d[1] and b[0] != d[0]:\n print(abs((d[1] - b[1]) * (d[0] - b[0])))\n elif c[1] != d[1] and c[0] != d[0]:\n print(abs((d[1] - c[1]) * (d[0] - c[0])))\n"}, {"source_code": "from fractions import gcd\nt = input()\nif(t==1):\n\tprint -1\nelse:\n\tif(t==2):\n\t\tx1,y1 = map(int, raw_input().split())\n\t\tx2,y2 = map(int, raw_input().split())\n\t\tif(x1!=x2 and y1!=y2):\n\t\t\tprint abs(x2-x1)*abs(y2-y1)\n\t\telse:\n\t\t\tprint -1\n\tif(t==3):\n\t\tx1,y1 = map(int, raw_input().split())\n\t\tx2,y2 = map(int, raw_input().split())\n\t\tx3,y3 = map(int, raw_input().split())\n\t\tprint max(abs(x2-x1)*abs(y2-y1),abs(x3-x1)*abs(y3-y1),abs(x3-x2)*abs(y3-y2))\n\tif(t==4):\n\t\tx1,y1 = map(int, raw_input().split())\n\t\tx2,y2 = map(int, raw_input().split())\n\t\tx3,y3 = map(int, raw_input().split())\n\t\tx4,y4 = map(int, raw_input().split())\n\t\tprint max(abs(x2-x1)*abs(y2-y1),abs(x3-x1)*abs(y3-y1),abs(x3-x2)*abs(y3-y2))"}, {"source_code": "n=int(input())\nr=[]\nfor j in range(n):\n (q,w)=(int(i) for i in input().split())\n r.append([q,w])\ndef sq(a,b):\n return abs((a[1]-b[1])*(a[0]-b[0]))\nif n==1:\n print('-1')\nelse:\n if n==2:\n if r[0][0]!=r[1][0] and r[0][1]!=r[1][1]:\n print(sq(r[1],r[0]))\n else:\n print('-1')\n else:\n if n==3 or n==4:\n print(max(sq(r[1],r[0]),sq(r[2],r[1]),sq(r[2],r[0])))"}, {"source_code": "def main():\n l = []\n for _ in range(int(input())):\n x1, y1 = map(int, input().split())\n for x2, y2 in l:\n s = (x1 - x2) * (y1 - y2)\n if s:\n print(abs(s))\n return\n l.append((x1, y1))\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "l, r = [], 0\nfor _ in range(int(input())):\n a, b = map(int, input().split())\n for c, d in l:\n r = max(r, abs((a - c) * (b - d)))\n l.append((a, b))\nprint(r if r else -1)\n"}, {"source_code": "import sys\nfrom sys import stdin,stdout\nimport math\nfrom math import sqrt\n\nn = int(input())\ncoords = []\nfor i in range(n):\n x,y = [int(x) for x in stdin.readline().rstrip().split()]\n coords.append([x,y])\n\nif n <= 1:\n print(-1)\n \nif n == 2:\n a = coords[0]\n b = coords[1]\n if (a[0] == b[0]) or (a[1] == b[1]):\n print(-1)\n else:\n print(abs(a[0]-b[0])*abs(a[1]-b[1]))\n \nif n >= 3:\n a = coords[0]\n b = coords[1]\n c = coords[2]\n \n ab = sqrt( (a[0]-b[0])**2 + (a[1]-b[1])**2 )\n ac = sqrt( (a[0]-c[0])**2 + (a[1]-c[1])**2 )\n bc = sqrt( (c[0]-b[0])**2 + (c[1]-b[1])**2 )\n \n ll = [ab,ac,bc]\n srted = sorted(ll)\n print(int(srted[0]*srted[1]))\n"}, {"source_code": "# print(\"Input n\")\nn = int(input())\n\na = [[0 for i in range(2)] for j in range(n)]\n\nfor i in range(n):\n # print(\"Input the next pair of vertices\")\n x,y = [int(t) for t in input().split()]\n a[i][0] = x\n a[i][1] = y\n\nif n == 1:\n print(-1)\nelif n == 2: # Can do it if they form a diagonal\n if a[0][0] == a[1][0] or a[0][1] == a[1][1]:\n print(-1)\n else:\n print(abs(a[0][0] - a[1][0]) * abs(a[0][1] - a[1][1]))\nelse: # n == 3 or n == 4\n # Find the two that are on a diag--then same logic as before\n # Just compute three and take the positive one\n one = abs(a[0][0] - a[1][0]) * abs(a[0][1] - a[1][1])\n two = abs(a[0][0] - a[2][0]) * abs(a[0][1] - a[2][1])\n three = abs(a[1][0] - a[2][0]) * abs(a[1][1] - a[2][1])\n print(max(one, two, three))\n\n \n \n"}, {"source_code": "from sys import stdin\nn=int(stdin.readline().strip())\ns=[]\nfor i in range(n):\n \n a,b=map(int,stdin.readline().strip().split())\n s.append([a,b])\nans=-1\nfor i in range(n):\n for j in range(i+1,n):\n if( s[i][0]!=s[j][0] and s[i][1]!=s[j][1] ):\n \n ans=abs(s[i][0]-s[j][0] )* abs(s[i][1]-s[j][1] ) \nprint(ans)\n"}, {"source_code": "n = int(input())\nxpos, ypos = [], []\nfor x in range(n):\n string = input()\n numbers = string.split()\n xpos.append(int(numbers[0]))\n ypos.append(int(numbers[1]))\na = -1\nif n > 1:\n x = xpos[0]\n b = 1\n while xpos[b] == x:\n b += 1\n if b == n:\n break\n if b != n:\n m = abs(x - xpos[b])\n y = ypos[0]\n b = 1\n while ypos[b] == y:\n b += 1\n if b == n:\n break\n if b != n:\n n = abs(y - ypos[b])\n a = m * n\nprint(a)"}, {"source_code": "# import sys\n# sys.stdin = open('cf596a.in')\n\nfrom collections import namedtuple\n\nn = int(input())\n\nPoint = namedtuple(\"Point\", \"x y\")\n\npts = [Point(*map(int, input().split())) for _ in range(n)]\n\nif n == 1:\n\tprint(-1)\nelif n == 2:\n\tif pts[0].x == pts[1].x or pts[0].y == pts[1].y:\n\t\tprint(-1)\n\telse:\n\t\tprint(abs((pts[1].x - pts[0].x) * (pts[0].y - pts[1].y)))\nelse:\n\tdiffs_x = set()\n\tdiffs_y = set()\n\tfor i in range(n - 1):\n\t\tfor j in range(i + 1, n):\n\t\t\tdiffs_x.add(abs(pts[i].x - pts[j].x))\n\t\t\tdiffs_y.add(abs(pts[i].y - pts[j].y))\n\tdiffs_x -= set([0])\n\tdiffs_y -= set([0])\n\tprint(diffs_x.pop() * diffs_y.pop())\n"}], "negative_code": [{"source_code": "n = int(input())\nif (n == 1):\n print(-1)\nelif (n == 2):\n x1, y1 = map(int, input().split())\n x2, y2 = map(int, input().split())\n if (x1 == x2) or (y1 == y2):\n print(-1)\n else:\n print(abs(x2 - x1) * abs(y2 - y1))\nelse:\n x1, y1 = map(int, input().split())\n x2, y2 = map(int, input().split())\n x3, y3 = map(int, input().split())\n if (x1 == x2) or (y1 == y2):\n if (x1 == x3) or (y1 == y3):\n print(abs(x3 - x1) * abs(y3 - y1))\n else:\n print(abs(x3 - x2) * abs(y3 - y2))\n else:\n print(abs(x2 - x1) * abs(y2 - y1))\n"}, {"source_code": "n=int(input())\nif n==1:\n print(-1)\n exit()\nif n==2:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n if x1==x2 or y1==y2:\n print(-1)\n exit()\n print(abs(x1-x2)*abs(x1-x2))\n exit()\nif n==3:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n x3,y3=map(int,input().split())\n if x1==x2:\n l=abs(y2-y1)\n b=abs(x3-x1)\n print(l*b)\n exit()\n if x2==x3:\n l=abs(y3-y2)\n b=abs(x1-x3)\n print(l*b)\n if x1==x3:\n l=abs(y1-y3)\n b=abs(x2-x1)\n print(l*b)\n exit()\nif n==4:\n points=[]\n for i in range(4):\n a,b=map(int,input().split())\n points.append([a,b])\n for i in range(4):\n for j in range(i+1,4):\n if points[i][0]!=points[j][0] and points[i][1]!=points[j][1]:\n print(abs(points[i][0]-points[j][0])*abs(points[i][1]*points[j][1]))\n exit()"}, {"source_code": "#map(int,raw_input().split())\nn = int(raw_input())\np = []\nfor i in xrange(n):\n p.append(tuple(map(int,raw_input().split())))\n\np.sort()\n\nif len(p) == 1:\n print -1\nelse:\n if len(p) >= 3:\n x1,y1 = p[0]\n x2,y2 = p[1]\n x3,y3 = p[2]\n ans = [0,0]\n if (x1 == x2):\n ans[0]= abs(y1-y2)\n else:\n ans[0] = abs(y3-y1)\n if (y1 == y2):\n ans[1] = abs(x1-x2)\n else:\n ans[1] = abs(x3-x2)\n print ans[0]*ans[1]\n else:\n x1,y1 = p[0]\n x2,y2 = p[1]\n if (x1 != x2) and (y1!=y2):\n print (abs(x1-x2) * abs(y1-y2))\n else:\n print -1\n"}, {"source_code": "N = int(raw_input())\n\nif N == 1:\n\tprint -1\n\texit()\nA = []\nB = []\nfor _ in range(N):\n\ttmp = map(int, raw_input().split())\n\tA.append(tmp[0])\n\tB.append(tmp[1])\n\nif A[0] != B[0] and A[1] != B[1]:\n\tprint 1\nelse:\n\tprint -1\n"}, {"source_code": "g = int(input())\nif g > 2:\n\tprint(1)\nelif g == 2:\n\tlst = []\n\tfor i in range(g):\n\t\th = list(map(int, input().split()))\n\t\tlst.append(h)\n\tif lst[0][0] != lst[1][0] and lst[0][1] != lst[1][1]:\n\t\tprint(1)\n\telse:\n\t\tprint(-1)\nelif g == 1:\n\tprint(-1) "}, {"source_code": "def solve():\n import math\n r=raw_input\n t=int(r())\n if t == 1:\n print -1\n exit()\n if t == 2:\n l = []\n for _ in xrange(t):\n x,y = map(int,r().split())\n l.append((x,y))\n if l[0][0] == l[1][0] or l[0][1] == l[1][1]:\n print -1\n exit()\n print ( abs(l[0][0]-l[1][0]) * abs(l[0][1]-l[1][1]) )\n exit()\n else:\n l = []\n for _ in xrange(t):\n x,y = map(int,r().split())\n l.append((x,y))\n l.sort()\n i = 0\n j = len(l)-1\n if l[i][0]!=l[j][0] and l[i][1]!=l[j][1]:\n print ( abs(l[i][0]-l[j][0]) * abs(l[i][1]-l[j][1]) )\n exit()\n print -1\n exit()\nsolve()\n \n \n \n\n"}, {"source_code": "import sys\n\n\ndef check_point(c, d):\n if c[0] != d[0] and c[1] != d[1]:\n return True\n else:\n return False\n\n\ndef square(c, d):\n return abs(c[0] - d[0]) * abs(c[1] - d[1])\n\n\nn = int(input())\na = []\nq = 0\nh = 0\nfor x in range(n):\n a.append(list(map(int, input().split())))\nif n == 2:\n if check_point(a[0], a[1]):\n print(square(a[0], a[1]))\n else:\n print(-1)\nelif n == 3:\n if check_point(a[0], a[1]):\n print(square(a[0], a[1]))\n elif check_point(a[0], a[2]):\n print(square(a[0], a[2]))\n elif check_point(a[2], a[1]):\n print(square(a[1], a[2]))\n else:\n print(-1)\nelif n == 4:\n if check_point(a[0], a[1]) and check_point(a[2], a[3]):\n print(square(a[0], a[1]))\n elif check_point(a[1], a[2]) and check_point(a[0], a[3]):\n print(check_point(a[1], a[2]))\n elif check_point(a[0], a[2]) and check_point(a[1], a[3]):\n print(check_point(a[0], a[2]))\n\nelse:\n print(-1)\n"}, {"source_code": "n=int(input())\nvertice=[]\nfor i in range(n):\n v=list(map(int,input().split()))\n vertice.append(v)\nif n==1:\n print(-1)\nelse:\n ans=[]\n if n>=2:\n area=abs(vertice[0][0]-vertice[1][0])*abs(vertice[0][1]-vertice[1][1])\n ans.append(area)\n if n>=3:\n area=abs(vertice[0][0]-vertice[2][0])*abs(vertice[0][1]-vertice[2][1])\n ans.append(area)\n area=abs(vertice[1][0]-vertice[2][0])*abs(vertice[1][1]-vertice[2][1])\n ans.append(area)\n if n>=4:\n area=abs(vertice[0][0]-vertice[3][0])*abs(vertice[0][1]-vertice[3][1])\n ans.append(area)\n area=abs(vertice[1][0]-vertice[3][0])*abs(vertice[1][1]-vertice[3][1])\n ans.append(area)\n area=abs(vertice[2][0]-vertice[3][0])*abs(vertice[2][1]-vertice[3][1])\n ans.append(area)\n ans.sort(reverse=True)\n print(ans[0])"}, {"source_code": "\nn=int(raw_input())\na=[]\nb=[]\nfor i in range(n):\n p,q=map(int,raw_input().split())\n a.append(p)\n b.append(q)\nif n==1:\n print -1\nelif n==2:\n print abs(a[1]-a[0])*abs(b[1]-b[0])\nelse:\n a=list(set(a))\n b=list(set(b))\n print abs(a[1]-a[0])*abs(b[1]-b[0])"}, {"source_code": "n=int(input())\ns=[]\nif n==1 :\n s.append(input())\n print(-1)\nelse :\n for k in range (0,n):\n s.append(input().split())\n xmax=-1100\n xmin=1100\n for k in range(0,n) :\n if int(s[k][0])>xmax :\n xmax=int(s[k][0])\n if int(s[k][0])<xmin :\n xmin=int(s[k][0])\n x=xmax-xmin\n \n ymax=-1110\n ymin=1100\n for k in range(0,n) :\n if int(s[k][1])>ymax :\n ymax=int(s[k][1])\n if int(s[k][1])<ymin :\n ymin=int(s[k][1])\n y=ymax-ymin\n \n print(x*y) \n"}, {"source_code": "def solve(n, verts):\n\tif n == 1:\n\t\treturn -1\n\tif n == 2:\n\t\tif verts[0][0] == verts[1][0] or verts[0][1] == verts[1][1]:\n\t\t\treturn -1\n\t\telse:\n\t\t\treturn abs(verts[0][0] - verts[1][0]) * abs(verts[0][1] - verts[1][1])\n\tif n == 3 or n == 4:\n\t\tlowest = [100000, 100000]\n\t\tbiggest = [-100000, -10000]\n\t\tfor i in verts:\n\t\t\tif i[0] <= lowest[0] and i[1] <= lowest[1]:\n\t\t\t\tlowest = i\n\t\tfor i in verts:\n\t\t\tif i[0] >= biggest[0] and i[1] >= biggest[1]:\n\t\t\t\tbiggest = i\n\t\treturn abs(biggest[0] - lowest[0]) * abs(biggest[1] - lowest[1])\n\nn = int(raw_input())\nverts = [map(int, raw_input().split()) for i in range(n)]\nprint solve(n, verts)\n"}, {"source_code": "import math as mt \nimport sys,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\ndef dist(x,y,c,d):\n return mt.sqrt((x-c)**2+(y-d)**2)\ndef circle(x1, y1, x2,y2, r1, r2): \n \n distSq = (((x1 - x2)* (x1 - x2))+ ((y1 - y2)* (y1 - y2)))**(.5) \n \n if (distSq + r2 <= r1): \n return True\n else: \n return False\n\nn=I()\nif(n==1):\n c,d=M()\n print(-1)\nelif(n==2):\n a,b=M()\n c,d=M()\n x=abs(a-c)*abs(b-d)\n if(x):\n print(x)\n else:\n print(-1)\nelse:\n d=[]\n for i in range(n):\n a,b=M()\n d.append([a,b])\n d.sort(key=lambda x:x[0])\n d.append(d[0])\n x=0\n for i in range(n):\n x+=d[i][0]*d[i+1][1]\n x-=d[i][1]*d[i+1][0]\n if(n==3):\n print(abs(x))\n if(n==4):\n print(abs(x)//2)\n"}, {"source_code": "n=int(input())\nto=[]\nif n==1:\n print(-1)\nelif n==2:\n for x in range(2):\n l,k=input().split()\n to.append(int(l))\n to.append(int(k))\n if to[0]!=to[2] and to[1]!=to[3]:\n print(abs(to[0]-to[2])*abs(to[1]-to[3]))\n else:\n print(-1)\nelif n==3:\n for x in range(3):\n l,k=input().split()\n to.append(int(l))\n to.append(int(k))\n if to[0]!=to[2] and to[1]!=to[3]:\n print(abs(to[0]-to[2])*abs(to[1]-to[3]))\n elif to[0]!=to[4] and to[1]!=to[5]:\n print(abs(to[0]-to[4])*abs(to[1]-to[5]))\n else:\n print(abs(to[2]-to[4])*abs(to[3]-to[5]))\nelse:\n for x in range(4):\n l,k=input().split()\n to.append(int(l))\n to.append(int(k))\n if to[0]!=to[2] and to[1]!=to[3]:\n print(abs(to[0]-to[2])*abs(to[1]-to[3]))\n elif to[0]!=to[3] and to[1]!=to[5]:\n print(abs(to[0]-to[3])*abs(to[1]-to[5]))\n else:\n print(abs(to[0]-to[6])*abs(to[1]-to[7]))"}, {"source_code": "class CodeforcesTask596ASolution:\n def __init__(self):\n self.result = ''\n self.n = 0\n self.points = []\n\n def read_input(self):\n self.n = int(input())\n for x in range(self.n):\n self.points.append([int(y) for y in input().split(\" \")])\n\n def process_task(self):\n if self.n < 2:\n self.result = \"-1\"\n elif self.n == 2:\n if self.points[0][0] != self.points[1][0] and self.points[0][1] != self.points[1][1]:\n self.result = str(abs(self.points[0][0] - self.points[1][0]) * abs(self.points[1][1] - self.points[0][1]))\n else:\n self.result = \"-1\"\n else:\n xs = [x[0] for x in self.points]\n ys = [x[1] for x in self.points]\n xs.sort()\n ys.sort()\n self.result = str(abs(self.points[0][0] - self.points[-1][0]) * abs(self.points[-1][1] - self.points[0][1]))\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask596ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "v = int(input())\n\ndef pl3(v):\n point = []\n for i in range(v):\n point.append(input().split())\n for k in point:\n for j in point:\n if k[0] != j[0] and k[1] != j[1]:\n return abs((int(k[0])-int(j[0]))*(int(k[1])-int(j[1])))\n\n\nif v == 1:\n print('-1')\nelif v == 3:\n print(pl3(v))\nelif v == 4:\n print(pl3(v))\nelse:\n print(pl3(v))"}, {"source_code": "n=int(input())\na=[[] for i in range(n)]\nfor i in range(n):\n x,y=map(int,input().split())\n a[i].append(x)\n a[i].append(y)\nif n==1:\n print(-1)\nelse:\n if n==2:\n if a[1][1]!=a[0][1] and a[1][0]!=a[0][0]:\n print(abs((a[0][0]-a[1][0])*(a[0][1]-a[1][1])))\n else:\n print(-1)\n else:\n print(abs((a[0][0]-a[1][0]-a[2][0])*(a[0][1]-a[1][1]-a[1][1])))"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/596/A\n\nd_y = {}\nd_x = {}\n\nl_c = list()\nl_c = list()\n\nn = int(input())\n\nfor _ in range(n):\n x, y = map(int, input().split())\n d_x[x] = 1\n d_y[y] = 1\n l_c.append([x, y])\n\nif len(d_x) + len(d_y) < 4:\n print(-1)\n quit()\n\nt_x = 0\nt_y = 0\ni = 1\nfor k_x in d_x:\n t_x += (-1 if i == 0 else 1) * k_x\n i = 0\ni = 1\nfor k_y in d_y:\n t_y += (-1 if i == 0 else 1) * k_y\n i = 0\n\nprint(t_x * t_y) \n \n "}, {"source_code": "def check(a, b):\n return a[0] != b[0] and a[1] != b[1]\n\n\ndef S(a, b):\n return abs(a[0] - b[0]) * abs(a[1] - b[1])\n\n\nn = int(input())\npoints = list(tuple(map(int, input().split())) for i in range(n))\n\nif n == 1:\n print(-1)\n\nelif n == 2:\n print(S(points[0], points[1])) if check(points[0], points[1]) else print(-1)\n\nelse:\n for i in range(n):\n for j in range(i + 1, n):\n if check(points[i], points[j]):\n print(S(points[i], points[j]))\n exit()\n\nprint(-1)"}, {"source_code": "n = int(raw_input())\n\nc = []\nfor i in xrange(n):\n c.append(tuple(int(i) for i in raw_input().split(\" \")))\n\nx1 = c[0][0]\ny1 = c[0][1]\n\nx2 = None\ny2 = None\n\nfor p in c[1:]:\n if p[0] != x1:\n x2 = p[0]\n if p[1] != y1:\n y2 = p[0]\n\nif x2 is None or y2 is None:\n print -1\nelse:\n w = abs(x1 - x2)\n h = abs(y1 - y2)\n print w * h\n"}, {"source_code": "\ncount = int(raw_input())\n\ncoords = []\nfor i in range(count):\n vals = map(int,raw_input().split(\" \"))\n coords.append((vals[0],vals[1]))\n\ncoords.sort()\n\nif len(coords) == 4:\n print (coords[2][0] - coords[0][0]) * (coords[1][1] - coords[0][1])\nelif len(coords) == 3:\n val = (coords[2][0] - coords[0][0]) * (coords[2][1] - coords[0][1])\n val1 = abs((coords[1][0] - coords[0][0]) * (coords[1][1] - coords[0][1]))\n val2 = abs((coords[2][0] - coords[1][0]) * (coords[2][1] - coords[1][1]))\n temp_m = max(val,val1)\n print max(val2, temp_m)\nelif len(coords) == 2:\n val = (coords[1][0] - coords[0][0]) * (coords[1][1] - coords[0][1])\n if val == 0:\n print -1\n else:\n print val\nelse:\n print -1\n \n"}, {"source_code": "n = input()\nl = []\nsq = 0\nfor i in xrange(n):\n\tl.append(map(int, raw_input().split()))\nif (n == 1):\n\tprint -1\n\texit()\nl = sorted(l)\nif (n == 2):\n\tif (l[0][0] == l[1][0]):\n\t\tprint -1\n\t\texit()\n\telse:\n\t\tsq = abs((l[0][1] - l[1][1]) * (l[0][0] - l[1][0]))\nelse:\n\tsq = abs((l[0][1] - l[-1][1]) * (l[0][0] - l[-1][0]))\nprint sq\n"}, {"source_code": "import math as mt \nimport sys,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\ndef dist(x,y,c,d):\n return mt.sqrt((x-c)**2+(y-d)**2)\ndef circle(x1, y1, x2,y2, r1, r2): \n \n distSq = (((x1 - x2)* (x1 - x2))+ ((y1 - y2)* (y1 - y2)))**(.5) \n \n if (distSq + r2 <= r1): \n return True\n else: \n return False\n\nn=I()\nif(n==1):\n c,d=M()\n print(-1)\nelif(n==2):\n a,b=M()\n c,d=M()\n x=abs(a-c)*abs(b-d)\n if(x):\n print(x)\n else:\n print(-1)\nelse:\n d=[]\n for i in range(n):\n a,b=M()\n d.append([a,b])\n d.sort(key=lambda x:x[0])\n d.append(d[0])\n x=0\n for i in range(n):\n x+=d[i][0]*d[i+1][1]\n x-=d[i][1]*d[i+1][0]\n if(n==3):\n print(abs(x))\n if(n==4):\n print(abs(x)//2)\n"}, {"source_code": "n=int(input())\npos=[]\nfor i in range(n):\n x,y=input().split()\n pos.append([int(x),int(y)])\nif n==1:\n print('-1')\nif n==2:\n if pos[0][0]==pos[1][0] or pos[0][1]==pos[1][1]:\n print('-1')\n else:\n print(abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1]))\nif n==3:\n judge=0\n for i in range(3):\n if pos[i][0]==pos[i-1][0] or pos[i][1]==pos[i-1][1]:\n judge=1\n break\n if judge==1:\n if i==0:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[1][1]-pos[0][1])\n elif i==1:\n S=abs(pos[0][0]-pos[2][0])*abs(pos[0][1]-pos[2][1])\n elif i==2:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[0][1]-pos[1][1])\n\n if S!=0:\n print(S)\n else:\n print('-1')\n if judge==0:\n print('-1')\nif n==4:\n judge=0\n for i in range(4):\n if pos[i][0]==pos[i-1][0] and pos[i-2][0]==pos[i-3][0]:\n judge=1\n break\n if judge==1:\n if i==0:\n S=abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1])\n elif i==1:\n S=abs(pos[1][0]-pos[2][0])*abs(pos[1][1]-pos[2][1])\n elif i==2:\n S=abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1])\n elif i==3:\n S=abs(pos[1][0]-pos[2][0])*abs(pos[1][1]-pos[2][1])\n if S!=0:\n print(S)\n else:\n print('-1')\n if judge==0:\n print('-1')\n"}, {"source_code": "def arr_2d(n):\n return [[int(x) for x in input().split()] for i in range(n)]\n\n\ndef euclidean(x1, x2, y1, y2):\n return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\n\ndef get_col(arr, i):\n return [row[i] for row in arr]\n\n\nfrom math import *\nfrom operator import *\n\nn = int(input())\na = arr_2d(n)\n\nif n == 1:\n print(-1)\nelif n == 2 and a[0][0] == a[1][0] or a[0][1] == a[1][1]:\n print(-1)\nelse:\n a = [list(set(get_col(a, 0))), list(set(get_col(a, 1)))]\n # print(a)\n print(abs(a[0][0] - a[0][1]) * abs(a[1][1] - a[1][0]))\n"}, {"source_code": "import sys\n\n\ndef check_point(c, d):\n if c[0] != d[0] and c[1] != d[1]:\n return True\n else:\n return False\n\n\ndef square(c, d):\n return abs(c[0] - d[0]) * abs(c[1] - d[1])\n\n\nn = int(input())\na = []\nq = 0\nh = 0\nfor x in range(n):\n a.append(list(map(int, input().split())))\nif n == 2:\n if check_point(a[0], a[1]):\n print(square(a[0], a[1]))\n else:\n print(-1)\nelif n == 3:\n if check_point(a[0], a[1]):\n print(square(a[0], a[1]))\n elif check_point(a[0], a[2]):\n print(square(a[0], a[2]))\n elif check_point(a[2], a[1]):\n print(square(a[1], a[2]))\n else:\n print(-1)\nelif n == 4:\n if check_point(a[0], a[1]) and check_point(a[2], a[3]):\n print(square(a[0], a[1]))\n elif check_point(a[1], a[2]) and check_point(a[0], a[3]):\n print(check_point(a[1], a[2]))\n elif check_point(a[0], a[2]) and check_point(a[1], a[3]):\n print(check_point(a[0], a[2]))\n\nelse:\n print(-1)\n"}, {"source_code": "n = int(raw_input())\npt = map(int, raw_input().split(' '))\nminx = maxx = pt[0]\nminy = maxy = pt[0]\n\nif n > 1:\n\tfor i in range(n - 1):\n\t\tpt = map(int, raw_input().split())\n\t\tif pt[0] < minx: minx = pt[0]\n\t\tif pt[0] > maxx: maxx = pt[0]\n\t\tif pt[1] < miny: miny = pt[0]\n\t\tif pt[1] > maxy: maxy = pt[0]\n\narea = (maxx - minx) * (maxy - miny)\nif area > 0:\n\tprint area\nelse:\n\tprint -1\n"}, {"source_code": "def arr_2d(n):\n return [[int(x) for x in input().split()] for i in range(n)]\n\n\ndef euclidean(x1, x2, y1, y2):\n return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\n\nfrom math import *\nfrom operator import *\n\n\nn = int(input())\na = sorted(arr_2d(n), key=itemgetter(0,1))\n# print(a)\n\nif n == 1:\n print(-1)\nelif n == 2 and a[0][0] == a[1][0] or a[0][1] == a[1][1]:\n print(-1)\nelse:\n print(abs(a[0][0] - a[-1][0]) * abs(a[-1][1] - a[0][1]))\n"}, {"source_code": "n=int(input())\nliste=[]\nfor i in range(n):\n tempo=[int(element) for element in input().split(\" \")]\n liste.append(tempo)\n\nif n==1 or liste[0][0]==liste[1][0] or liste[0][1]==liste[1][1]:\n print(-1)\nelse:\n answer=(liste[0][0]-liste[1][0])*(liste[0][1]-liste[1][1])\n print(answer)"}, {"source_code": "n = int(input())\ncoords = []\nfor i in range(n):\n coords.append([int(i) for i in input().split()])\nif n == 1:\n print(-1)\nelif n == 2:\n if coords[0][0] != coords[1][0] and coords[0][1] != coords[1][1]:\n print(abs((coords[0][0]-coords[1][0]) * coords[0][1]-coords[1][1]))\n else:\n print(-1)\nelse:\n r = 0\n for coord1 in coords:\n for coord2 in coords:\n if coord1[0] != coord2[0] and coord1[1] != coord2[1]:\n print(abs((coord1[0]-coord2[0]) * (coord1[1]-coord2[1])))\n r = 1\n break\n if r == 1:\n break\n"}, {"source_code": "x = set()\ny = set()\nfor _ in range(int(raw_input())):\n\n a,b = map(int,raw_input().split())\n x.add(a)\n y.add(b)\nx=list(x)\ny = list(y)\n\nif len(x)==2 and len(y)==2 and (x[1]-x[0])*(y[1]-y[0]):\n print 1\nelse:\n print -1\n\n \n"}, {"source_code": "n=int(raw_input())\nx=[]\ny=[]\nfor i in range(n):\n xi,yi=map(int,raw_input().strip().split())\n x.append(xi)\n y.append(yi)\nif n==1:\n print '-1'\nelse:\n x.sort()\n y.sort()\n print abs(x[0]-x[-1])*abs(y[0]-y[-1])"}, {"source_code": "n=int(input())\ns=[]\nif n==1 :\n s.append(input())\n print(-1)\nelse :\n for k in range (0,n):\n s.append(input().split())\n xmax=-1\n xmin=1100\n for k in range(0,n) :\n if int(s[k][0])>xmax :\n xmax=int(s[k][0])\n if int(s[k][0])<xmin :\n xmin=int(s[k][0])\n x=xmax-xmin\n \n ymax=-1\n ymin=1100\n for k in range(0,n) :\n if int(s[k][1])>ymax :\n ymax=int(s[k][1])\n if int(s[k][1])<ymin :\n ymin=int(s[k][1])\n y=ymax-ymin\n \n print(x*y) \n"}, {"source_code": "n = int(raw_input())\na = []\nfor _ in xrange(n):\n\ta.append(map(int,raw_input().split()))\na = sorted(a,key=lambda x:(x[0],x[1]))\n#print a\nif n==1:\n\tprint -1\nelif n==2:\n\tif a[0][0]==a[1][0] or a[0][1]==a[1][1]:\n\t\tprint -1\n\telse:\n\t\tprint abs((a[1][0]-a[0][0])*(a[1][1]-a[0][1]))\nelif n==3:\n\tprint abs((a[2][0] - a[0][0]) * (a[2][1] - a[0][1]))\nelse:\n\tprint abs((a[3][0] - a[0][0]) * (a[3][1] - a[0][1]))\n"}, {"source_code": "n=int(input())\nr=range(0,n)\nitems = []\nfor l in r:\n\ts=raw_input()\n\ts=s.split(' ')\n\tx=int(s[0])\n\ty=int(s[1])\n\titems.append((x,y))\n\nif n == 1:\n\tprint \"-1\"\nelif n == 2:\n\tif items[0][0] == items[1][0] or items[0][1] == items[1][1]:\n\t\tprint \"-1\"\n\telse:\n\t\tarea = (items[0][1] - items[1][1]) * (items[0][0] - items[1][0])\n\t\tprint area\nelse:\n\tw = max(abs(items[0][1]-items[1][1]), abs(items[1][1]-items[2][1]), abs(items[0][1]-items[2][1]))\n\tv = max(abs(items[0][0]-items[1][0]), abs(items[1][0]-items[2][0]), abs(items[0][0]-items[2][0]))\n\tprint w*v\n\n"}, {"source_code": "n = int(input())\ncoordinates = [tuple(map(int, (input().split()))) for i in range(n)]\nif n == 3:\n coordinates.sort()\n s = ((coordinates[0][1]-coordinates[1][1])**2+(coordinates[0][0]-coordinates[1][0])**2)**0.5*((coordinates[1][1]-coordinates[2][1])**2+(coordinates[1][0]-coordinates[2][0])**2)**0.5\nelif n == 2 and coordinates[0][0]!=coordinates[1][0] and coordinates[0][1]!=coordinates[1][1]:\n s = abs((coordinates[0][0]-coordinates[1][0])*(coordinates[0][1]-coordinates[1][1]))\nelse:\n s = -1\nprint(s)"}, {"source_code": "n = input()\nl = []\nsq = 0\nfor i in xrange(n):\n\tl.append(tuple(map(int, raw_input().split())))\nif (n == 1):\n\tprint -1\n\texit()\nif (n == 2):\n\tif (l[0][0] == l[1][0] or l[0][1] == l[1][1]):\n\t\tprint -1\n\t\texit()\n\telse:\n\t\tsq = abs((l[0][1] - l[1][1]) * (l[0][0] - l[1][0]))\nelse:\n\tfor i in xrange(n):\n\t\tif l[0][0] != l[i][0] and l[0][1] != l[i][1]:\n\t\t\tsq = abs((l[0][1] - l[i][1]) * (l[0][0] - l[i][0]))\nprint sq\n"}, {"source_code": "a=int(raw_input())\narr=[]\nfor i in xrange (a):\n arr+=[map(int,raw_input().split())]\nif a == 1:\n print -1\nif a == 2:\n x=arr[0][0]-arr[1][0]\n y=arr[0][1]-arr[1][1]\n print abs(x*y)\nif a == 3:\n if (arr[0][0] == arr[2][0]):\n x=arr[0][0]-arr[1][0]\n y=arr[0][1]-arr[1][1]\n print abs(x*y)\n else:\n x=arr[2][0]-arr[1][0]\n y=arr[2][1]-arr[1][1]\n print abs(x*y)\n"}, {"source_code": "n=int(input())\nif n==1:\n print(-1)\n exit()\nif n==2:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n if x1==x2 or y1==y2:\n print(-1)\n exit()\n print(abs(x1-x2)*abs(x1-x2))\n exit()\nif n==3:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n x3,y3=map(int,input().split())\n if x1==x2:\n l=abs(y2-y1)\n b=abs(x3-x1)\n print(l*b)\n exit()\n if x2==x3:\n l=abs(y3-y2)\n b=abs(x1-x3)\n print(l*b)\n if x1==x3:\n l=abs(y1-y3)\n b=abs(x2-x1)\n print(l*b)\n exit()\nif n==4:\n points=[]\n for i in range(4):\n a,b=map(int,input().split())\n points.append([a,b])\n for i in range(4):\n for j in range(i+1,4):\n if points[i][0]!=points[j][0] and points[i][1]!=points[j][1]:\n print(abs(points[i][0]-points[j][0])*abs(points[i][1]*points[j][1]))\n exit()"}, {"source_code": "import sys\n\nnum_verts = int(sys.stdin.readline())\n\nverts = []\nfor _ in range(num_verts):\n # read verts\n x, y = [int(x) for x in sys.stdin.readline().split()]\n verts.append((x, y))\n\n\nv0 = verts[0]\nv1 = None\nfor i in range(1, num_verts):\n if verts[i][0] != v0[0] and verts[i][1] != v0[1]:\n v1 = verts[i]\n break\n\nif not v1:\n print -1\nelse:\n print abs(v0[0] - v1[0]) * abs(v0[1] - v1[1])\n"}, {"source_code": "n=int(raw_input())\nx=[]\ny=[]\nfor h in range(n):\n a,b=map(int,raw_input().split())\n if n==1:\n print -1\n exit()\n else:\n x.append(a)\n y.append(b)\nif len(x)>2:\n if x[0]==x[1]:\n raa=x[0]-x[2]\n rbb=y[0]-y[1]\n faa=raa*rbb\n if faa==0:\n print -1\n exit()\n else:\n print abs(faa)\n elif x[0]!=x[1]:\n rr=x[0]-x[1]\n rrr=y[0]-y[1]\n fff=rr*rrr\n print abs(fff)\n elif y[0]!=y[1]:\n gg=x[0]-x[1]\n ggg=y[0]-y[1]\n fds=gg*ggg\n print abs(fds)\n elif y[0]==y[1]:\n ra=y[0]-y[2]\n rb=x[0]-x[1]\n fb=ra*rb\n if fb==0:\n print -1\n exit()\n else:\n print abs(fb)\nelse:\n res=x[0]-x[1]\n res2=y[0]-y[1]\n f=res*res2\n if f==0:\n print -1\n exit()\n else:\n print abs(f)"}, {"source_code": "n = int(input())\np = []\nfor i in range(n):\n x, y = map(int, input().split())\n p.append([x, y])\n\nif n == 1:\n print(-1)\nelif n == 2:\n if p[0][0] != p[1][0] and p[0][1] != p[1][1]:\n print(abs(p[0][0] - p[1][0]) * abs(p[0][1] - p[1][1]))\n else:\n print(-1)\nelse:\n w, h = 0, 0\n if p[0][0] != p[1][0]:\n w = abs(p[0][0] - p[1][0])\n h = abs(p[0][1] - p[2][1])\n else:\n w = abs(p[0][0] - p[2][0])\n h = abs(p[0][1] - p[1][1])\n print(w * h) \n"}, {"source_code": "n=int(input())\nxfound=[]\nyfound=[]\nfor i in range(n):\n x0,y0=map(int,input().split())\n if x0 not in xfound:\n xfound.append(x0)\n if y0 not in yfound:\n yfound.append(y0)\nprint(1 if(len(xfound)==2 and len(yfound)==2) else -1)"}, {"source_code": "l, r = [], [-1]\nfor _ in range(int(input())):\n a, b = map(int, input().split())\n for c, d in l:\n r.append(abs((a - c) * (b - d)))\n l.append((a, b))\nprint(max(r))\n"}, {"source_code": "n = int(input())\n\na = set()\nb = set()\nfor i in range(0, n):\n x, y = map(int, input().split())\n a.add(x)\n b.add(y)\nif n < 2:\n print(-1)\nelse:\n p = a.pop()\n q = a.pop()\n r = b.pop()\n s = b.pop()\n c = p - s\n d = q - r\n print(abs(d * c))\n"}, {"source_code": "N = int(raw_input())\nassert N >= 1 and N <= 4\ncoordinates = []\n\ndef check(N):\n for i in range(N):\n if N == 1:\n return -1\n \n else:\n c = tuple(map(int, raw_input().split()))\n assert c[0] >= -1000 and c[0] <= 1000\n assert c[1] >= -1000 and c[1] <= 1000\n coordinates.append(c)\n for i in range(1, len(coordinates)):\n if coordinates[0][0] != coordinates[i][0] and coordinates[0][1] != coordinates[i][1]:\n return abs(coordinates[0][0] - coordinates[i][0]) * abs(coordinates[0][1] - coordinates[i][1])\n \n return -1\n \nprint check(N)"}, {"source_code": "n=int(input())\nxfound=[]\nyfound=[]\nfor i in range(n):\n x0,y0=map(int,input().split())\n if x0 not in xfound:\n xfound.append(x0)\n if y0 not in yfound:\n yfound.append(y0)\nprint(1 if(len(xfound)==2 and len(yfound)==2) else -1)"}, {"source_code": "n = int(input())\ncoordinates = [tuple(map(int, (input().split()))) for i in range(n)]\nif n == 4:\n coordinates.sort()\n s = int(((coordinates[0][1]-coordinates[1][1])**2+(coordinates[0][0]-coordinates[1][0])**2)**0.5*((coordinates[1][1]-coordinates[3][1])**2+(coordinates[1][0]-coordinates[3][0])**2)**0.5)\nelif n == 3:\n coordinates.sort()\n s = int(((coordinates[0][1]-coordinates[1][1])**2+(coordinates[0][0]-coordinates[1][0])**2)**0.5*((coordinates[1][1]-coordinates[2][1])**2+(coordinates[1][0]-coordinates[2][0])**2)**0.5)\nelif n == 2 and coordinates[0][0]!=coordinates[1][0] and coordinates[0][1]!=coordinates[1][1]:\n s = abs((coordinates[0][0]-coordinates[1][0])*(coordinates[0][1]-coordinates[1][1]))\nelse:\n s = -1\nprint(s)"}, {"source_code": "def niten(a,b): return abs(a-b) if a>=0 and b>=0 else a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))\ndef gcd(a,b): return a if b==0 else gcd(b,a%b)\ndef lcm(a,b): return a*b/gcd(a,b)\ndef euclid_dis(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5\ndef choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0\n\nn=int(raw_input())\nif n==1:\n print -1\nelif n==2:\n a,b=map(int,raw_input().split())\n c,d=map(int,raw_input().split())\n if a==c or b==d:\n print -1\n else:\n print abs(max(a,c)-min(a,c))*abs(max(b,d)-min(b,d))\nelif n==3:\n l=[]\n for i in range(3):\n l.append(map(int,raw_input().split()))\n l.sort()\n if l[0][0]==l[1][0] and l[1][1]==l[2][1]:\n x=niten(l[0][0],l[2][0])\n y=niten(l[0][1],l[1][1])\n elif l[0][1]==l[1][1] and l[1][0]==l[2][0]:\n x=niten(l[0][0],l[2][0])\n y=niten(l[0][1],l[2][1])\n else:\n x,y=1,-1\n print x*y\nelse:\n l=[]\n for i in range(4):\n l.append(map(int,raw_input().split()))\n l.sort()\n if l[0][0]==l[1][0] and l[2][0]==l[3][0] and l[0][1]==l[2][1] and l[1][1]==l[3][1]:\n x=niten(l[0][0],l[2][0])\n y=niten(l[0][1],l[1][1])\n else:\n x,y=1,-1\n print x*y"}, {"source_code": "n=int(input())\nr=[]\nfor j in range(n):\n (q,w)=(int(j) for j in input().split())\n r.append([q,w])\nif n==1:\n print('-1')\nelse:\n if n==2:\n if r[0][0]!=r[1][0] and r[0][1]!=r[1][1]:\n print('1')\n else:\n print('-1')\n else:\n print('1')"}, {"source_code": "n = int(input())\n\npoints = list()\n\nfor i in range(n):\n points.append(list(map(int, input().split())))\n\npoints.sort()\n\nif n <= 1:\n print(-1)\nelif n == 2:\n if points[0][0] != points[1][0] and points[0][1] != points[1][1]:\n print(abs((points[0][0] - points[1][0]) * (points[0][1] - points[1][1])))\n else:\n print(-1)\nelif n == 3:\n if (points[0][0] == points[1][0]) and (points[1][1] == points[2][1]):\n print(abs((points[0][1] - points[1][1]) * (points[0][0] - points[2][0])))\n else:\n print(-1)\nelif n == 4:\n if (points[0][0] == points[1][0]) and \\\n (points[2][0] == points[3][0]) and \\\n (points[0][1] == points[2][1]) and \\\n (points[1][1] == points[3][1]):\n print(abs((points[0][1] - points[1][1]) * (points[0][0] - points[2][0])))\n else:\n print(-1)\n"}, {"source_code": "n = int(input())\nlst_x = []\nlst_y = []\noutput = -1\nfor _ in range(n):\n x,y = map(int, input().split())\n if x not in lst_x and y not in lst_y:\n lst_x.append(x)\n lst_y.append(y)\n if len(lst_x) == 2:\n output = abs(lst_x[0] - lst_x[1]) * abs(lst_y[0] - lst_y[1])\nprint(output)"}, {"source_code": "n=int(input())\nM=[list(map(int,input().split())) for i in range(n)]\na=-1\nfor i in range(n) :\n for j in range(n) :\n if M[i][0]!=M[j][0] and M[i][1]!=M[j][1] :\n a=([M[i][0],M[i][1]])\n b=([M[j][0],M[j][1]])\nif a==-1 :\n print(1)\nelse :\n c=[a[0],b[1]]\n d=[b[0],a[1]]\n q1=((c[0]-a[0])**2+(c[1]-a[1])**2)**(0.5)\n q2=((c[0]-b[0])**2+(c[1]-b[1])**2)**(0.5)\n print(q1*q2)\n\n \n\n \n"}, {"source_code": "n=int(input())\npos=[]\nfor i in range(n):\n x,y=input().split()\n pos.append([int(x),int(y)])\nif n==1:\n print('-1')\nif n==2:\n if pos[0][0]==pos[1][0] or pos[0][1]==pos[1][1]:\n print('-1')\n else:\n print(abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1]))\nif n==3:\n judge=0\n for i in range(3):\n if pos[i][0]==pos[i-1][0] or pos[i][1]==pos[i-1][1]:\n judge=1\n break\n if judge==1:\n if i==0:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[1][1]-pos[0][1])\n elif i==1:\n S=abs(pos[0][0]-pos[2][0])*abs(pos[0][1]-pos[2][1])\n elif i==2:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[0][1]-pos[1][1])\n\n if S!=0:\n print(S)\n else:\n print('-1')\n if judge==0:\n print('-1')\nif n==4:\n judge=0\n for i in range(4):\n if pos[i][0]==pos[i-1][0] and pos[i-2][0]==pos[i-3][0]:\n judge=1\n break\n if judge==1:\n if i==0:\n S=abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1])\n elif i==1:\n S=abs(pos[1][0]-pos[2][0])*abs(pos[1][1]-pos[2][1])\n elif i==2:\n S=abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1])\n elif i==3:\n S=abs(pos[1][0]-pos[2][0])*abs(pos[1][1]-pos[2][1])\n if S!=0:\n print(S)\n else:\n print('-1')\n if judge==0:\n print('-1')\n"}, {"source_code": "def check(a, b):\n return a[0] != b[0] and a[1] != b[1]\n\n\ndef S(a, b):\n return abs(a[0] - b[0]) * abs(a[1] - b[1])\n\n\nn = int(input())\npoints = list(tuple(map(int, input().split())) for i in range(n))\n\nif n == 1:\n print(-1)\n\nelif n == 2:\n print(S(points[0], points[1])) if check(points[0], points[1]) else print(-1)\n\nelse:\n for i in range(n):\n for j in range(i + 1, n):\n if check(points[i], points[j]):\n print(S(points[i], points[j]))\n exit()\n\nprint(-1)"}, {"source_code": "# Problem 59A - \"Wilbur and Swimming\"\n\nn = int(raw_input())\npts = []\n\nfor i in xrange(0, n):\n\tr = raw_input()\n\tpts.append(r.split(' '))\n\tpts[i] = [int(x) for x in pts[i]]\n\nif n == 1:\n\tprint -1\nelif n == 2:\n\tif pts[0][0] == pts[1][0] or pts[0][1] == pts[1][1]:\n\t\tprint -1\n\telse:\n\t\tprint abs((pts[0][0]-pts[1][0])*(pts[0][1]-pts[1][1]))\nelse:\n\tif pts[0][0] == pts[1][0]:\n\t\tprint abs((pts[0][0]-pts[2][0])*(pts[0][1]-pts[1][1]))\n\telse:\n\t\tprint abs((pts[0][0]-pts[1][0])*(pts[0][1]-pts[2][1]))\n\nexit(0)\n"}, {"source_code": "n = int(raw_input())\na = []\nfor _ in xrange(n):\n\ta.append(map(int,raw_input().split()))\na = sorted(a,key=lambda x:(x[0],x[1]))\n#print a\nif n==1:\n\tprint -1\nelif n==2:\n\tif a[0][0]==a[1][0] or a[0][1]==a[1][1]:\n\t\tprint -1\n\telse:\n\t\tprint (a[1][0]-a[0][0])*(a[1][1]-a[0][1])\nelif n==3:\n\tprint (a[2][0] - a[0][0]) * (a[2][1] - a[0][1])\nelse:\n\tprint (a[3][0] - a[0][0]) * (a[3][1] - a[0][1])\n"}, {"source_code": "n=int(input())\npos=[]\nfor i in range(n):\n x,y=input().split()\n pos.append([int(x),int(y)])\nif n==1:\n print('-1')\nif n==2:\n if pos[0][0]==pos[1][0] or pos[0][1]==pos[1][1]:\n print('-1')\n else:\n print(abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1]))\nif n==3:\n judge=0\n for i in range(3):\n if pos[i][0]==pos[i-1][0] or pos[i][1]==pos[i-1][1]:\n judge=1\n break\n if judge==1:\n if i==0:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[1][1]-pos[0][1])\n elif i==1:\n S=abs(pos[0][0]-pos[2][0])*abs(pos[0][1]-pos[2][1])\n elif i==2:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[0][1]-pos[1][1])\n\n if S!=0:\n print(S)\n else:\n print('-1')\n if judge==0:\n print('-1')\n"}, {"source_code": "import sys\nn = int(input())\narr = []\nc = 0\nif n == 1:\n print(-1)\n sys.exit()\nfor i in range(n):\n x,y = map(int,input().split())\n arr.append((x,y))\nfor i in range(n-1):\n if arr[i][0] != arr[i+1][0] and arr[i][1] != arr[i+1][1]:\n print(abs(arr[i][0] - arr[i+1][0]) * abs(abs(arr[i][1] - arr[i+1][1])))\n c = 1\n sys.exit()\nprint(-1)\n"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2015 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\nn = int(input())\n\nif n == 1:\n print(-1)\nelif n > 2:\n print(1)\nelse: \n x1, y1 = [int(i) for i in input().split()]\n x2, y2 = [int(i) for i in input().split()]\n\n if x1 != x2 and y1 != y2:\n print(1)\n else:\n print(-1)\n"}, {"source_code": "n=int(raw_input())\nx=[]\ny=[]\nfor h in range(n):\n a,b=map(int,raw_input().split())\n if n==1:\n print -1\n exit()\n else:\n x.append(a)\n y.append(b)\nif len(x)>2:\n if x[0]==x[1]:\n raa=x[0]-x[2]\n rbb=y[0]-y[1]\n faa=raa*rbb\n if faa==0:\n print -1\n exit()\n else:\n print abs(faa)\n elif y[0]==y[1]:\n ra=y[0]-y[2]\n rb=x[0]-x[1]\n fb=ra*rb\n if fb==0:\n print -1\n exit()\n else:\n print abs(fb)\n exit()\nelse:\n res=x[0]-x[1]\n res2=y[0]-y[1]\n f=res*res2\n if f==0:\n print -1\n exit()\n else:\n print abs(f)"}, {"source_code": "\nn=int(input())\npos=[]\nfor i in range(n):\n x,y=input().split()\n pos.append([int(x),int(y)])\nif n==1:\n print('-1')\nif n==2:\n if pos[0][0]==pos[1][0] or pos[0][1]==pos[1][1]:\n print('-1')\n else:\n print(abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1]))\nif n==3:\n judge=0\n for i in range(3):\n if pos[i][0]==pos[i-1][0] or pos[i][1]==pos[i-1][1]:\n judge=1\n break\n if judge==1:\n if i==0:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[1][1]-pos[0][1])\n elif i==1:\n S=abs(pos[0][0]-pos[2][0])*abs(pos[0][1]-pos[2][1])\n elif i==2:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[0][1]-pos[1][1])\n\n if S!=0:\n print(S)\n else:\n print('-1')\n if judge==0:\n print('-1')\n"}, {"source_code": "n = int(raw_input())\npt = map(int, raw_input().split(' '))\nminx = maxx = pt[0]\nminy = maxy = pt[1]\n\nif n > 1:\n\tfor i in range(n - 1):\n\t\tpt = map(int, raw_input().split())\n\t\tif pt[0] < minx: minx = pt[0]\n\t\tif pt[0] > maxx: maxx = pt[0]\n\t\tif pt[1] < miny: miny = pt[0]\n\t\tif pt[1] > maxy: maxy = pt[0]\n\narea = (maxx - minx) * (maxy - miny)\nif area > 0:\n\tprint area\nelse:\n\tprint -1\n"}, {"source_code": "# Problem 59A - \"Wilbur and Swimming\"\n\nn = int(raw_input())\npts = []\n\nfor i in xrange(0, n):\n\tr = raw_input()\n\tpts.append(r.split(' '))\n\tpts[i] = [int(x) for x in pts[i]]\n\nif n == 1:\n\tprint -1\nelif n == 2:\n\tif pts[0][0] == pts[1][0] or pts[0][1] == pts[1][1]:\n\t\tprint -1\n\telse:\n\t\tprint abs((pts[0][0]-pts[1][0])*(pts[0][1]-pts[1][1]))\nelse:\n\tif pts[0][0] == pts[1][0]:\n\t\tprint abs((pts[0][0]-pts[2][0])*(pts[0][1]-pts[1][1]))\n\telse:\n\t\tprint abs((pts[0][0]-pts[1][0])*(pts[0][1]-pts[2][1]))\n\nexit(0)\n"}, {"source_code": "n = input()\nl = []\nsq = 0\nfor i in xrange(n):\n\tl.append(map(int, raw_input().split()))\nif (n == 1):\n\tprint -1\n\texit()\nl = sorted(l)\nif (n == 2):\n\tif (l[0][0] == l[1][0]):\n\t\tprint sq\n\t\texit()\n\telse:\n\t\tsq = abs((l[0][1] - l[1][1]) * (l[0][0] - l[1][0]))\nelse:\n\tsq = abs((l[0][1] - l[-1][1]) * (l[0][0] - l[-1][0]))\nprint sq\n"}, {"source_code": "\ncount = int(raw_input())\n\ncoords = []\nfor i in range(count):\n vals = map(int,raw_input().split(\" \"))\n coords.append((vals[0],vals[1]))\n\ncoords.sort()\n\nif len(coords) == 4:\n print (coords[2][0] - coords[0][0]) * (coords[1][1] - coords[0][1])\nelif len(coords) == 3:\n val = (coords[2][0] - coords[0][0]) * (coords[2][1] - coords[0][1])\n val1 = abs((coords[1][0] - coords[0][0]) * (coords[1][1] - coords[0][1]))\n val2 = abs((coords[2][0] - coords[1][0]) * (coords[2][1] - coords[1][1]))\n temp_m = max(val,val1)\n print max(val2, temp_m)\nelif len(coords) == 2:\n val = (coords[1][0] - coords[0][0]) * (coords[1][1] - coords[0][1])\n if val == 0:\n print -1\n else:\n print val\nelse:\n print -1\n \n"}, {"source_code": "def arr_2d(n):\n return [[int(x) for x in input().split()] for i in range(n)]\n\n\ndef euclidean(x1, x2, y1, y2):\n return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\n\nfrom math import *\n\nn = int(input())\na = sorted(arr_2d(n), key=lambda x: x[0])\nif n == 1:\n print(-1)\nelif n == 2 and a[0][0] == a[1][0] or a[0][1] == a[1][1]:\n print(-1)\nelse:\n print(abs(a[0][0] - a[-1][-1]) * abs(a[-1][0] - a[0][-1]))\n"}, {"source_code": "n = int(input())\nvs = list()\nfor x in range(n):\n x = input().split()\n vs.append((int(x[0]), int(x[1])))\n\n\nif n == 1:\n print(-1)\nelse:\n if len(vs) == 2:\n if vs[0][0] == vs[1][0] or vs[0][1] == vs[1][1]:\n print(-1)\n else:\n print(abs((vs[1][0] - vs[0][0]) * (vs[1][1] - vs[0][1])))\n elif len(vs) > 2:\n print(abs((vs[1][0] - vs[0][0]) * (vs[1][1] - vs[0][1])))"}, {"source_code": "class CodeforcesTask596ASolution:\n def __init__(self):\n self.result = ''\n self.n = 0\n self.points = []\n\n def read_input(self):\n self.n = int(input())\n for x in range(self.n):\n self.points.append([int(y) for y in input().split(\" \")])\n\n def process_task(self):\n if self.n < 2:\n self.result = \"-1\"\n elif self.n == 2:\n if self.points[0][0] != self.points[1][0] and self.points[0][1] != self.points[1][1]:\n self.result = str(abs(self.points[0][0] - self.points[1][0]) * abs(self.points[1][1] - self.points[0][1]))\n else:\n self.result = \"-1\"\n else:\n xs = [x[0] for x in self.points]\n ys = [x[1] for x in self.points]\n xs.sort()\n ys.sort()\n self.result = str(abs(self.points[0][0] - self.points[-1][0]) * abs(self.points[-1][1] - self.points[0][1]))\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask596ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "n = int(input())\ncoords = []\nfor i in range(n):\n coords.append([int(i) for i in input().split()])\nif n == 1:\n print(-1)\nelif n == 2:\n if coords[0][0] != coords[1][0] and coords[0][1] != coords[1][1]:\n print(abs((coords[0][0]-coords[1][0]) * coords[0][1]-coords[1][1]))\n else:\n print(-1)\nelse:\n r = 0\n for coord1 in coords:\n for coord2 in coords:\n if coord1[0] != coord2[0] and coord1[1] != coord2[1]:\n print(abs((coord1[0]-coord2[0]) * coord1[1]-coord2[1]))\n r = 1\n break\n if r == 1:\n break\n"}, {"source_code": "ip,rp = input,raw_input\nn = ip()\npt = []\nfor i in range(n):\n x,y = map(int,rp().split())\n pt.append((x,y))\nif(n==1):\n print -1\nelif(n==2):\n if(pt[0][0]!=pt[1][0] and pt[0][1]!=pt[1][1]):\n print abs(pt[1][0]-pt[0][0])*abs(pt[1][1]-pt[0][1])\n else:\n print -1\nelse:\n pt.sort()\n print abs(pt[n-1][0]-pt[0][0])*abs(pt[n-1][1]-pt[0][1]);"}, {"source_code": "N = input()\nverts = [map(int, raw_input().split()) for loop in xrange(N)]\n\ndef length(a, b):\n return ( (a[0]-b[0])**2 + (a[1]-b[1])**2 ) ** 0.5\n\ndef is_diagonal(a, b):\n if a[0]==b[0] or a[1]==b[1]:\n return False\n else:\n return True\n\ndef calc_area(N, verts):\n if N == 1:\n return -1\n elif N == 2:\n if is_diagonal(verts[0], verts[1]):\n l = length(verts[0], verts[1])\n return 0.5 * (l ** 2)\n else:\n return -1\n elif N == 3:\n if is_diagonal(verts[0], verts[1]):\n l = length(verts[0], verts[1])\n elif is_diagonal(verts[1], verts[2]):\n l = length(verts[1], vets[2])\n else:\n l = length(verts[2], vets[0])\n return 0.5 * (l ** 2)\n else:\n if is_diagonal(verts[0], verts[1]):\n l = length(verts[0], verts[1])\n elif is_diagonal(verts[0], verts[2]):\n l = length(verts[0], verts[2])\n else:\n l = length(verts[0], verts[3])\n return 0.5 * (l ** 2)\n \nprint calc_area(N, verts)\n"}, {"source_code": "\ncount = int(raw_input())\n\ncoords = []\nfor i in range(count):\n vals = map(int,raw_input().split(\" \"))\n coords.append((vals[0],vals[1]))\n\ncoords.sort()\n\nif len(coords) == 4:\n print (coords[2][0] - coords[0][0]) * (coords[1][1] - coords[0][1])\nelif len(coords) == 3:\n val = (coords[2][0] - coords[0][0]) * (coords[2][1] - coords[0][1])\n val1 = abs((coords[1][0] - coords[0][0]) * (coords[1][1] - coords[0][1]))\n val2 = abs((coords[2][0] - coords[1][0]) * (coords[2][1] - coords[1][1]))\n temp_m = max(val,val1)\n print max(val2, temp_m)\nelif len(coords) == 2:\n val = (coords[1][0] - coords[0][0]) * (coords[1][1] - coords[0][1])\n if val == 0:\n print -1\n else:\n print val\nelse:\n print -1\n \n"}, {"source_code": "N = input()\nverts = [map(int, raw_input().split()) for loop in xrange(N)]\n\ndef length(a, b):\n return ( (a[0]-b[0])**2 + (a[1]-b[1])**2 ) ** 0.5\n\ndef is_diagonal(a, b):\n if a[0]==b[0] or a[1]==b[1]:\n return False\n else:\n return True\n\ndef calc_area(N, verts):\n if N == 1:\n return -1\n elif N == 2:\n if is_diagonal(verts[0], verts[1]):\n l = length(verts[0], verts[1])\n return 0.5 * (l ** 2)\n else:\n return -1\n elif N == 3:\n if is_diagonal(verts[0], verts[1]):\n l = length(verts[0], verts[1])\n elif is_diagonal(verts[1], verts[2]):\n l = length(verts[1], vets[2])\n else:\n l = length(verts[2], vets[0])\n return 0.5 * (l ** 2)\n else:\n if is_diagonal(verts[0], verts[1]):\n l = length(verts[0], verts[1])\n elif is_diagonal(verts[0], verts[2]):\n l = length(verts[0], verts[2])\n else:\n l = length(verts[0], verts[3])\n return 0.5 * (l ** 2)\n \nprint calc_area(N, verts)\n"}, {"source_code": "n=int(raw_input())\nx=[]\ny=[]\nfor h in range(n):\n a,b=map(int,raw_input().split())\n if n==1:\n print -1\n exit()\n else:\n x.append(a)\n y.append(b)\nif len(x)>2:\n if x[0]==x[1]:\n raa=x[0]-x[2]\n rbb=y[0]-y[1]\n faa=raa*rbb\n if faa==0:\n print -1\n exit()\n else:\n print abs(faa)\n elif x[0]!=x[1]:\n rr=x[0]-x[1]\n rrr=y[0]-y[2]\n fff=rr*rrr\n print abs(fff)\n elif y[0]!=y[1]:\n gg=x[0]-x[1]\n ggg=y[0]-y[1]\n fds=gg*ggg\n print abs(fds)\n elif y[0]==y[1]:\n ra=y[0]-y[2]\n rb=x[0]-x[1]\n fb=ra*rb\n if fb==0:\n print -1\n exit()\n else:\n print abs(fb)\nelse:\n res=x[0]-x[1]\n res2=y[0]-y[1]\n f=res*res2\n if f==0:\n print -1\n exit()\n else:\n print abs(f)"}, {"source_code": "\ndef main():\n\tn = input()\n\tif n == 1:\n\t\tprint '-1'\n\t\treturn\n\n\tvertex = []\n\tfor _ in xrange(n):\n\t\tx,y = map(int, raw_input().split())\n\t\tvertex += [(x,y)]\n\n\tl=0\n\th=0\n\tfor i in xrange(n):\n\t\tfor j in xrange(i+1,n):\n\t\t\tif vertex[i][0] != vertex[j][0]:\n\t\t\t\tl = abs(vertex[i][0]-vertex[j][0])\n\t\t\tif vertex[i][1] != vertex[j][1]:\n\t\t\t\th = abs(vertex[i][1]-vertex[j][1])\n\tprint l*h\n\t\t\t\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "n=int(raw_input())\na=[]\np=0\nfor i in range(n):\n a.append(map(int, raw_input().split()))\nfor i in range(n):\n for j in range(i,n):\n if a[i][0]!=a[j][0] and a[i][1]!=a[j][1]:\n print abs(a[i][0]-a[j][0])*abs(a[i][1]-a[j][1])\n p=1\nif p==0:\n print -1\n"}, {"source_code": "ip,rp = input,raw_input\nn = ip()\npt = []\nfor i in range(n):\n x,y = map(int,rp().split())\n pt.append((x,y))\nif(n==1):\n print -1\nelif(n==2):\n if(pt[0][0]!=pt[1][0] and pt[0][1]!=pt[1][1]):\n print abs(pt[1][0]-pt[0][0])*abs(pt[1][1]-pt[0][1])\n else:\n print -1\nelif(n==4):\n pt.sort()\n print abs(pt[n-1][0]-pt[0][0])*abs(pt[n-1][1]-pt[0][1]);\nelse:\n pt.sort()\n if(pt[2][0]!=pt[0][0] and pt[2][1]!=pt[0][1]):\n print abs(pt[2][0]-pt[0][0])*abs(pt[2][1]-pt[0][1]);\n else:\n print abs(pt[2][0]-pt[1][0])*abs(pt[2][1]-pt[1][1]);\n"}, {"source_code": "n = int(raw_input())\npt = map(int, raw_input().split(' '))\nminx = maxx = pt[0]\nminy = maxy = pt[1]\n\nif n > 1:\n\tfor i in range(n - 1):\n\t\tpt = map(int, raw_input().split())\n\t\tif pt[0] < minx: minx = pt[0]\n\t\tif pt[0] > maxx: maxx = pt[0]\n\t\tif pt[1] < miny: miny = pt[0]\n\t\tif pt[1] > maxy: maxy = pt[0]\n\narea = (maxx - minx) * (maxy - miny)\nif area > 0:\n\tprint area\nelse:\n\tprint -1\n"}, {"source_code": "n=int(input())\nif n==1:\n print(-1)\n exit()\nif n==2:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n if x1==x2 or y1==y2:\n print(-1)\n exit()\n print(abs(x1-x2)*abs(x1-x2))\n exit()\nif n==3:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n x3,y3=map(int,input().split())\n if x1==x2:\n l=abs(y2-y1)\n b=abs(x3-x1)\n print(l*b)\n exit()\n if x2==x3:\n l=abs(y3-y2)\n b=abs(x1-x3)\n print(l*b)\n if x1==x3:\n l=abs(y1-y3)\n b=abs(x2-x1)\n print(l*b)\n exit()\nif n==4:\n points=[]\n for i in range(4):\n a,b=map(int,input().split())\n points.append([a,b])\n for i in range(4):\n for j in range(i+1,4):\n if points[i][0]!=points[j][0] and points[i][1]!=points[j][1]:\n print(abs(points[i][0]-points[j][0])*abs(points[i][1]*points[j][1]))\n exit()"}, {"source_code": "n = int(raw_input())\na = []\nfor i in range(n):\n c = [int(x) for x in raw_input().split()]\n a.append(c)\n\nif n==1:\n ans = -1\nelif n==2:\n x1 , y1 = a[0]\n x2 , y2 = a[1]\n if x1 == x2 or y1 == y2:\n ans = -1\n else:\n ans = abs((x1 - x2)*(y1 - y2))\nelse :\n x1 , y1 = a[0]\n x2 , y2 = a[1]\n x3 , y3 = a[2]\n if x1 != x2:\n ans = abs((x1 - x2) * (y2 - y3))\n else:\n ans = abs((y1 - y2) * (x1 - x3))\n\nprint ans"}, {"source_code": "import sys\n\nn = int(raw_input())\nif (n == 1): \n print -1\n sys.exit()\n\nx1 = map(int, raw_input().split())\nx2 = map(int, raw_input().split())\na1 = abs(x2[0]-x1[0])\na2 = abs(x2[1]-x1[1])\n\nif (a1 != 0) and (a2 != 0):\n print a1*a2\n sys.exit()\nelse:\n if (n == 2):\n print -1\n sys.exit()\n else:\n x3 = map(int, raw_input().split())\n a11 = abs(x3[0]-x1[0])\n a21 = abs(x3[1]-x1[1])\n a31 = max(a1, a2)\n if (a31 == a21):\n print a31*a11\n else:\n print a31*a21\n"}, {"source_code": "n = input()\nl = []\nsq = 0\nfor i in xrange(n):\n\tl.append(tuple(map(int, raw_input().split())))\nif (n == 1):\n\tprint -1\n\texit()\nif (n == 2):\n\tif (l[0][0] == l[1][0] or l[0][1] == l[1][1]):\n\t\tprint -1\n\t\texit()\n\telse:\n\t\tsq = abs((l[0][1] - l[1][1]) * (l[0][0] - l[1][0]))\nelse:\n\tfor i in xrange(n):\n\t\tif l[0][0] != l[i][0] and l[0][1] != l[i][1]:\n\t\t\tsq = abs((l[0][1] - l[i][1]) * (l[0][0] - l[i][0]))\nprint sq\n"}, {"source_code": "a=int(raw_input())\narr=[]\nfor i in xrange (a):\n arr+=[map(int,raw_input().split())]\nif a == 1:\n print -1\nif a == 2:\n x=arr[0][0]-arr[1][0]\n y=arr[0][1]-arr[1][1]\n print abs(x*y)\nif a == 3:\n if (arr[0][0] == arr[2][0]):\n x=arr[0][0]-arr[1][0]\n y=arr[0][1]-arr[1][1]\n print abs(x*y)\n else:\n x=arr[2][0]-arr[1][0]\n y=arr[2][1]-arr[1][1]\n print abs(x*y)\n"}, {"source_code": "N = int(raw_input())\n\nif N == 1:\n\tprint -1\n\texit()\nA = []\nB = []\nfor _ in range(N):\n\ttmp = map(int, raw_input().split())\n\tA.append(tmp[0])\n\tB.append(tmp[1])\n\nif A[0] != A[1] and B[0] != B[1]:\n\tprint abs(A[1] - A[0]) * abs(B[1] - B[0])\nelse:\n\tprint -1\n"}, {"source_code": "n=int(input())\nx=[]\ny=[]\nwhile n>0:\n n-=1\n s=input()\n a=[int(i) for i in s.split(' ')]\n x.append(a[0])\n y.append(a[1])\nkx,ky,xx,yy=0,0,-2000,-2000\ndx,dy=0,0\nfor i in x:\n if xx!=i:\n kx+=1\n if xx!=-2000:\n dx=abs(xx-i)\n xx=i\nfor i in y:\n if yy!=i:\n ky+=1\n if yy!=-2000:\n dy=abs(yy-i)\n yy=i\nif kx==2 and ky==2:\n SS=dx*dy\n print(SS)\nelse:\n print(-1)"}, {"source_code": "n = int(input())\nlst_x = []\nlst_y = []\noutput = -1\nfor _ in range(n):\n x,y = map(int, input().split())\n if x not in lst_x and y not in lst_y:\n lst_x.append(x)\n lst_y.append(y)\n if len(lst_x) == 2:\n output = abs(lst_x[0] - lst_x[1]) * abs(lst_y[0] - lst_y[1])\nprint(output)"}, {"source_code": "n = int(input())\n\npoints = list()\n\nfor i in range(n):\n points.append(list(map(int, input().split())))\n\npoints.sort()\n\nif n <= 1:\n print(-1)\nelif n == 2:\n if points[0][0] != points[1][0] and points[0][1] != points[1][1]:\n print(abs((points[0][0] - points[1][0]) * (points[0][1] - points[1][1])))\n else:\n print(-1)\nelif n == 3:\n if (points[0][0] == points[1][0]) and (points[1][1] == points[2][1]):\n print(abs((points[0][1] - points[1][1]) * (points[0][0] - points[2][0])))\n else:\n print(-1)\nelif n == 4:\n if (points[0][0] == points[1][0]) and \\\n (points[2][0] == points[3][0]) and \\\n (points[0][1] == points[2][1]) and \\\n (points[1][1] == points[3][1]):\n print(abs((points[0][1] - points[1][1]) * (points[0][0] - points[2][0])))\n else:\n print(-1)\n"}, {"source_code": "from collections import namedtuple\n\ndef get_area(vertices):\n num_vertices = len(vertices)\n Vertex = namedtuple(\"Vertex\", [\"x\", \"y\"])\n vertices = [Vertex(*vertex) for vertex in vertices]\n if num_vertices <= 1:\n return -1\n\n # sort on x axis\n vertices = sorted(vertices)\n\n x_diff = 0\n y_diff = 0\n previous = vertices[0]\n for i in range(1, num_vertices):\n if x_diff and y_diff:\n return abs(y_diff * x_diff)\n else:\n if not x_diff and vertices[i].x != previous.x:\n x_diff = vertices[i].x - previous.x\n if not y_diff and vertices[i].y != previous.y:\n y_diff = vertices[i].y - previous.y\n previous = vertices[i]\n\n return abs(x_diff * y_diff)\n\ndef get_raw_input():\n num_vertices = int(raw_input())\n vertices = []\n for i in range(num_vertices):\n vertex = raw_input().split(\" \")\n vertices.append((int(vertex[0]), int(vertex[1])))\n return vertices\n\nif __name__ == \"__main__\":\n vertices = get_raw_input()\n print get_area(vertices)\n\n"}, {"source_code": "def arr_2d(n):\n return [[int(x) for x in input().split()] for i in range(n)]\n\n\ndef euclidean(x1, x2, y1, y2):\n return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\n\ndef get_col(arr, i):\n return [row[i] for row in arr]\n\n\nfrom math import *\nfrom operator import *\n\nn = int(input())\na = arr_2d(n)\n\nif n == 1:\n print(-1)\nelif n == 2 and a[0][0] == a[1][0] or a[0][1] == a[1][1]:\n print(-1)\nelse:\n a = [list(set(get_col(a, 0))), list(set(get_col(a, 1)))]\n # print(a)\n print(abs(a[0][0] - a[0][1]) * abs(a[1][1] - a[1][0]))\n"}, {"source_code": "ip,rp = input,raw_input\nn = ip()\npt = []\nfor i in range(n):\n x,y = map(int,rp().split())\n pt.append((x,y))\nif(n==1):\n print -1\nelif(n==2):\n if(pt[0][0]!=pt[1][0] and pt[0][1]!=pt[1][1]):\n print abs(pt[1][0]-pt[0][0])*abs(pt[1][1]-pt[0][1])\n else:\n print -1\nelse:\n pt.sort()\n print abs(pt[n-1][0]-pt[0][0])*abs(pt[n-1][1]-pt[0][1]);"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nfrom sys import stdin\nfrom collections import defaultdict\nfrom operator import itemgetter\n\ndef main():\n print(\"{}\".format(run()))\n\ndef run():\n n = int(stdin.readline())\n if n == 1:\n return -1\n else:\n points = [list(map(int, stdin.readline().split())) for _ in range(n)]\n for p1 in points:\n for p2 in points:\n if p1 == p2:\n continue\n if p1[0] == p2[0] or p1[1] == p2[1]:\n continue\n return (p1[0] - p2[0]) * (p1[1] - p2[1])\n return -1\n\nif __name__==\"__main__\":\n main()\n"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2015 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\nn = int(input())\n\nif n == 1:\n print(-1)\nelif n > 2:\n print(1)\nelse: \n x1, y1 = [int(i) for i in input().split()]\n x2, y2 = [int(i) for i in input().split()]\n\n if x1 != x2 and y1 != y2:\n print(1)\n else:\n print(-1)\n"}, {"source_code": "def Respuesta(X,Y):\n X1 = list(set(X))\n Y1 = list(set(Y))\n if (len(X1)== 2 and len(Y1)==2):\n return (Y1[1]-Y1[0])*(X1[1]-X1[0])\n else:\n return -1\n\n\nn = int(input())\nX = []\nY = []\nfor i in range (0,n):\n L = input()\n L =L.split()\n X.append(int(L[0]))\n Y.append(int(L[1]))\n\nif n==1:\n print(-1)\nelse:\n print(Respuesta(X,Y))\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\nn=input()\na=[l() for _ in range(n)]\nif n==1:\n print -1\n exit()\nif n==2:\n if (a[0][0]==a[1][0] or a[0][1]==a[1][1]):\n print -1\n exit()\n else:\n ans = abs((a[0][1]-a[1][1])*(a[0][0]-a[1][0]))\n print ans\nelse:\n ans=1\n for i in range(1,n):\n if a[i][0]<>a[0][0] and a[i][1]==a[0][1]:\n ans*=abs((a[i][0]-a[0][0]))\n if a[i][1]<>a[0][1] and a[i][0]==a[0][0]:\n ans*=abs((a[i][1]-a[0][1]))\n print ans"}, {"source_code": "n=int(input())\npos=[]\nfor i in range(n):\n x,y=input().split()\n pos.append([int(x),int(y)])\nif n==1:\n print('-1')\nif n==2:\n if pos[0][0]==pos[1][0] or pos[0][1]==pos[1][1]:\n print('-1')\n else:\n print(abs(pos[0][0]-pos[1][0])*abs(pos[0][1]-pos[1][1]))\nif n==3:\n judge=0\n for i in range(3):\n if pos[i][0]==pos[i-1][0] or pos[i][1]==pos[i-1][1]:\n judge=1\n break\n if judge==1:\n if i==0:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[1][1]-pos[0][1])\n elif i==1:\n S=abs(pos[0][0]-pos[2][0])*abs(pos[0][1]-pos[2][1])\n elif i==2:\n S=abs(pos[1][0]-pos[0][0])*abs(pos[0][1]-pos[1][1])\n\n if S!=0:\n print(S)\n else:\n print('-1')\n if judge==0:\n print('-1')\n"}, {"source_code": "n=int(input())\nl=[]\nif n==0:\n print(\"-1\")\nelse:\n for i in range(n):\n x,y=map(int,input().split())\n l+=[[x,y]]\nif n==1 :\n print(\"-1\")\nelse:\n c=0\n for i in range(n-1):\n j=i+1\n while j<n:\n if l[j][0]!=l[i][0] and l[j][1]!=l[i][1]:\n result=(l[i][0]-l[j][0])*(l[i][1]-l[j][1])\n if result >0:\n c=1\n if c:\n print(result)\n break\n j+=1\n if c:\n break\n if not c:\n print('-1')\n \n"}, {"source_code": "import sys\nn = int(input())\nw =[None]*n\nh =[None]*n\nwidth = height = 1\nfor i in range(n):\n x,y = map(int,input().split())\n w[i] = x\n h[i] = y\nif(n == 1):\n print('-1')\nelif(n == 2):\n if(w[0] == w[1]):\n height = abs(h[0] - h[1])\n else:\n width = abs(w[0] - w[1])\n if(h[0] == h[1]):\n width = abs(w[0] - w[1])\n else:\n height = abs(h[0] - h[1])\n print(width * height)\nelif(n >= 3):\n if(w[0] != w[1]):\n width = abs(w[0] - w[1])\n elif(w[1] != w[2]):\n width = abs(w[1] - w[2])\n if(h[0] != h[1]):\n height = abs(h[0] - h[1])\n elif(h[1] != h[2]):\n height = abs(h[1] - h[2])\n print(width * height)"}, {"source_code": "n=int(input())\nif n==1:\n print(-1)\n exit()\nif n==2:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n if x1==x2 or y1==y2:\n print(-1)\n exit()\n print(abs(x1-x2)*abs(x1-x2))\n exit()\nif n==3:\n x1,y1=map(int,input().split())\n x2,y2=map(int,input().split())\n x3,y3=map(int,input().split())\n if x1==x2:\n l=abs(y2-y1)\n b=abs(x3-x1)\n print(l*b)\n exit()\n if x2==x3:\n l=abs(y3-y2)\n b=abs(x1-x3)\n print(l*b)\n if x1==x3:\n l=abs(y1-y3)\n b=abs(x2-x1)\n print(l*b)\n exit()\nif n==4:\n points=[]\n for i in range(4):\n a,b=map(int,input().split())\n points.append([a,b])\n for i in range(4):\n for j in range(i+1,4):\n if points[i][0]!=points[j][0] and points[i][1]!=points[j][1]:\n print(abs(points[i][0]-points[j][0])*abs(points[i][1]*points[j][1]))\n exit()"}, {"source_code": "n = int(input())\n\npoints = list()\n\nfor i in range(n):\n points.append(list(map(int, input().split())))\n\npoints.sort()\n\nif n <= 1:\n print(-1)\nelif n == 2:\n if points[0][0] != points[1][0] and points[0][1] != points[1][1]:\n print(abs((points[0][0] - points[1][0]) * (points[0][1] - points[1][1])))\n else:\n print(-1)\nelif n == 3:\n if (points[0][0] == points[1][0]) and (points[1][1] == points[2][1]):\n print(abs((points[0][1] - points[1][1]) * (points[0][0] - points[2][0])))\n else:\n print(-1)\nelif n == 4:\n if (points[0][0] == points[1][0]) and \\\n (points[2][0] == points[3][0]) and \\\n (points[0][1] == points[2][1]) and \\\n (points[1][1] == points[3][1]):\n print(abs((points[0][1] - points[1][1]) * (points[0][0] - points[2][0])))\n else:\n print(-1)\n"}, {"source_code": "n = int(raw_input())\npt = map(int, raw_input().split(' '))\nminx = maxx = pt[0]\nminy = maxy = pt[0]\n\nif n > 1:\n\tfor i in range(n - 1):\n\t\tpt = map(int, raw_input().split())\n\t\tif pt[0] < minx: minx = pt[0]\n\t\tif pt[0] > maxx: maxx = pt[0]\n\t\tif pt[1] < miny: miny = pt[0]\n\t\tif pt[1] > maxy: maxy = pt[0]\n\narea = (maxx - minx) * (maxy - miny)\nif area > 0:\n\tprint area\nelse:\n\tprint -1\n"}], "src_uid": "ba49b6c001bb472635f14ec62233210e"} {"source_code": "a, b = map(int, raw_input().split())\nwhile a != 0 and b != 0:\n if a >= 2*b:\n a %= 2*b\n continue\n else:\n if b >= 2*a:\n b %= 2*a\n continue\n else:\n break\nprint a, b\n\n\n", "positive_code": [{"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a >= 2 * b:\n a %= 2 * b\n elif b >= 2 * a:\n b %= 2 * a\n else:\n break\n\nprint(a, b)\n"}, {"source_code": "a, b = map(int, raw_input().split(\" \"))\n\nwhile True:\n if a == 0 or b == 0:\n break\n\n if a >= 2*b:\n a = a % (2*b)\n elif b >= 2*a:\n b = b % (2*a)\n else:\n break\n\n\nprint \"%d %d\" % (a, b)"}, {"source_code": "a, b = map(int, input().split())\n\n\ndef solve(x, y):\n if x >= 2 * y:\n x %= 2 * y\n elif y >= 2 * x:\n y %= 2 * x\n\n if (x == 0 or y == 0) or (x < 2 * y and y < 2 * x):\n return x, y\n else:\n return solve(x, y)\n\n\nprint(' '.join(map(str, solve(a, b))))\n"}, {"source_code": "a, b = map(int, input().split(' '))\n\n\nwhile 1:\n \n if a == 0 or b == 0:\n break\n elif a >= 2 * b:\n a %= 2 * b\n continue\n elif b >= 2 * a:\n b %= 2 * a \n continue\n else:\n break\n\nprint(a, b)\n"}, {"source_code": "a, b = list(map(int,input().strip().split(' ')))\nwhile True:\n if a == 0 or b == 0:\n break\n else:\n if a >= 2 * b:\n a %= 2 * b\n else:\n if b >= 2 * a:\n b %= 2 * a\n else:\n break\nprint(a,b)"}, {"source_code": "a,b=map(int,input().split())\nwhile(a!=0 and b!=0):\n\tif(a>=2*b):\n\t\tz=a//b\n\t\tif(z%2!=0):\n\t\t\tz=z-1\n\t\ta=a-b*z\n\t\tcontinue\n\tif(b>=2*a):\n\t\tz=b//a\n\t\tif(z%2!=0):\n\t\t\tz=z-1\n\t\tb=b-a*z\n\t\tcontinue\n\tbreak\nprint(a,b)"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 12.07.2020\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[1] \ndef sort2(l):return sorted(l, key=getKey,reverse=True)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))\n\ndef ceil(x,y):\n if x%y==0:\n return x//y\n else:\n return x//y+1\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\ndef main():\n \n\n #for _ in range(ii()):\n\n \n\n a,b=mi()\n f=1\n\n cnt=1\n\n while True:\n\n if a==0 or b==0:\n if f==1:\n print(a,b)\n else:\n print(b,a)\n\n return\n\n\n if a>=b:\n pass\n else:\n f^=1\n\n #print(a,b,f)\n\n a,b=max(a,b),min(a,b)\n\n #print(a,b,f)\n\n if a<2*b:\n if f==1:\n print(a,b)\n else:\n print(b,a)\n return\n\n\n l=0\n r=10**18\n ans=0\n while l<=r:\n mid=(l+r)//2\n\n if 2*mid*b<=a:\n ans=mid\n l=mid+1\n else:\n r=mid-1\n\n\n a-=2*ans*b\n\n\n cnt+=1\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "a,b=map(int,input().split())\nwhile(a*b>0):\n if a>= 2*b:\n a=a%(2*b)\n elif b>= 2*a:\n b=b%(2*a)\n else:\n break\n\nprint(a,b)"}, {"source_code": "# n = int(raw_input())\na,b = map(long, raw_input().split())\n\nif(a==0 or b==0):\n print \"{} {}\".format(a,b)\nwhile(1):\n if(a==0 or b==0):\n print \"{} {}\".format(a,b)\n exit(0)\n elif(a >= (2*b)):\n a %= (2*b)\n elif(b >= (2*a)):\n b %= (2*a)\n else :\n print \"{} {}\".format(a,b)\n exit(0)\n"}, {"source_code": "a,b=map(int,input().split())\nwhile True:\n if a==0 or b==0:\n break\n elif a>=2*b:\n a%=2*b\n elif b>=2*a:\n b%=2*a\n else:\n break\nprint(a,b)\n"}, {"source_code": "# def f(a,b):\n# \tif a==0 or b==0:\n# \t\treturn (a,b)\n# \telif a >= 2*b:\n# \t\ta -= 2*b\n# \t\treturn f(a,b)\n# \telif b >= 2*a:\n# \t\tb -= 2*a\n# \t\treturn f(a,b)\n# \telse:\n# \t\treturn (a,b)\n\t\n\na,b = list(map(int, input().split()))\n\n\n\nwhile(a!=0 and b!=0):\n\tif a >= 2*b:\n\t\ta %= 2*b\n\t\tcontinue\n\telif b >= 2*a:\n\t\tb %= 2*a\n\t\tcontinue\n\telse:\n\t\tbreak\n\nprint(a,b)"}, {"source_code": "def solve():\n\n\ta, b = map(int, raw_input().split())\n\n\tdef process(a, b):\n\n\t\tlft = 0\n\t\trgt = (10**18)\n\n\t\tans = -1\n\n\t\trem = 2 * b \n\n\t\twhile lft <= rgt:\n\t\t\tmid = (lft + rgt) >> 1\n\n\t\t\tres = a - (mid * rem)\n\n\t\t\tif res >= 0:\n\t\t\t\tans = mid\n\t\t\t\tlft = mid + 1\n\t\t\telse:\n\t\t\t\trgt = mid - 1\n\n\t\treturn (a - (ans * rem)), b \n\n\twhile a and b:\n\t\tif a >= 2*b:\n\t\t\ta, b = process(a, b)\n\t\telse:\n\t\t\tif b >= 2*a:\n\t\t\t\tb, a = process(b, a)\n\t\t\telse:\n\t\t\t\tbreak \n\n\tprint a, b \n\n\nsolve()"}, {"source_code": "n, m = map(int, raw_input().split())\n\nwhile True:\n if n == 0 or m == 0:\n break\n if n >= 2*m:\n temp = n/(2*m)\n n -= (2*m*temp)\n elif m >= 2*n:\n temp = m/(2*n)\n m -= (2*n*temp)\n else:\n break\n\nprint n, m\n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a != 0 and b != 0:\n if a >= 2 * b:\n a %= 2 * b\n elif b >= 2 * a:\n b %= 2 * a\n else:\n break\n\nprint(a, b)"}, {"source_code": "def f(a, b):\n if a == 0 or b == 0:\n return [a, b]\n elif a >= 2 * b:\n return f(a % (2 * b), b)\n elif b >= 2 * a:\n return f(a, b % (2 * a))\n else:\n return [a, b]\n \na, b = map(int, input().split())\nl = f(a, b)\nprint(*l)"}, {"source_code": "def weirdSubtraction(a,b):\n \n try:\n \n if a==0 or b==0:\n return [a,b]\n elif a >= 2*b:\n a %= 2*b\n result = weirdSubtraction(a,b)\n elif b >= 2*a:\n b %= 2*a\n result = weirdSubtraction(a,b)\n else:\n return [a,b]\n \n return result\n \n except RuntimeError:\n return [a,b]\n\nnumbers = input()\nnumbersList = numbers.split()\n\nnumbersList = weirdSubtraction(int(numbersList[0]),int(numbersList[1]))\n\nprint(str(numbersList[0]) + \" \" + str(numbersList[1]))"}, {"source_code": "a,b=map(int,input().split())\nwhile(a!=0 and b!=0):\n if(a>=2*b):\n k=a//(2*b)\n a=a-(k*2*b)\n elif (b>=2*a):\n k=b//(2*a)\n b=b-(k*2*a)\n else:\n break\nprint(a,b)"}, {"source_code": "a,b=map(int,input().split())\nwhile a>0 and b>0:\n if a>=2*b:\n a%=2*b\n elif b>=2*a:\n b%=2*a\n else:\n break\nprint(a,b)"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a > 2 * b:\n a -= ((a // (2 * b)) * 2) * b\n elif a * 2 < b:\n b -= ((b // (2 * a)) * 2) * a\n elif a >= 2 * b:\n a -= 2 * b\n elif a * 2 <= b:\n b -= 2 * a\n else:\n print(a, b)\n exit()\nprint(a, b)\n"}, {"source_code": "a, b = list(map(int, input().split()))\nwhile a > 0 and b > 0:\n if a >= 2 * b:\n a %= 2 * b\n elif b >= 2 * a:\n b %= 2 * a\n else:\n break\nprint(a, b)"}, {"source_code": "import sys\nsys.setrecursionlimit(1000000)\n\ndef ans(a,b):\n if a==0 or b==0:\n return a,b\n elif a>=2*b:\n a=a-((a//(2*b)))*2*b\n return ans(a,b)\n elif b>=2*a:\n b=b-((b//(2*a)))*2*a\n return ans(a,b)\n else:\n return a,b\n\na,b=map(int,input().split())\ntb1,tb2=ans(a,b)\nprint(tb1,tb2)\n"}, {"source_code": "def p3(a,b):\n \n if(not a or not b):\n return(a,b)\n if(a>=2*b):\n a%=(2*b)\n return p3(a,b)\n if(b>=2*a):\n b%=(2*a)\n return p3(a,b)\n return(a,b)\n\na,b=input().split(\" \")\na,b=p3(int(a),int(b))\n\nprint(a,b)"}, {"source_code": "a,b = list(map(int,input().split()))\nwhile(a!=0 and b!=0):\n if a >= 2*b:\n a = a%(2*b)\n elif b >= 2*a:\n b = b%(2*a)\n else:\n break\nprint(a,b)\n"}, {"source_code": "def great(a,b):\n if a>=b*2:\n k=a//(2*b)\n a=a-k*2*b\n func(a,b)\n else:\n if b>=a*2:\n s=0\n k=b//(2*a)\n b=b-k*2*a\n func(a,b)\n else:\n print(a,b)\n\ndef func(a,b):\n if a==0 or b==0 :\n print(a,b)\n else:\n great(a,b)\n\n\na,b = map(int,input().split())\nfunc(a,b)\n"}, {"source_code": "a,b=map(int,input().split())\nwhile a!=0 and b!=0 and a>=2*b or b>=2*a and a!=0 and b!=0:\n if a>=2*b:\n a-=(a//(b*2))*b*2\n else:\n b-=(b//(a*2))*a*2\n#while a!=0 and b!=0 and a>=2*b or b>=2*a and a!=0 and b!=0:\n# if a>=2*b:\n# a-=2*b\n# else:\n# b-=2*a\nprint(a,b)"}, {"source_code": "x,y=map(int,input().split())\nwhile x and y:\n\tif x>=2*y:\n\t\tx%=2*y\n\telif y>=2*x:\n\t\ty%=2*x\n\telse:\n\t\tbreak\nprint(x,y)"}, {"source_code": "a, b = map(int, input().split())\n\nwhile True: \n\tif a == 0 or b == 0:\n\t\tbreak \n\telif a >= 2*b:\n\t\tqtd = a//(2*b)\n\t\ta -= qtd*2*b\n\telif b >= 2*a:\n\t\tqtd = b//(2*a)\n\t\tb -= qtd*2*a\n\telse:\n\t\tbreak\nprint(a, b)\n\n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile(a and b):\n if (a >= 2 * b):\n a %= 2 * b\n elif (b >= 2 * a):\n b %= 2 * a\n else:\n break\n\nprint(a, b)"}, {"source_code": "a,b = map(int, raw_input().split())\n\nwhile True :\n if a == 0 or b == 0 :\n break\n elif a >= 2*b :\n x = a/b\n if x%2 :\n x -= 1\n a = a - x*b\n elif b >= 2*a :\n x = b/a\n if x%2 :\n x -= 1\n b = b - x*a\n \n else :\n break\n\nprint a, b"}, {"source_code": "a, b = map(int, input().split())\nwhile a>0 and b>0:\n\tif a>=b+b:\n\t\ta%=b+b \n\telif b>=a+a:\n\t\tb%=a+a \n\telse:\n\t\tbreak\nprint(a, b)\n\n\n\n\n\n"}, {"source_code": "i=lambda:map(int,input().split())\na, b = i()\n\n\nwhile True:\n if a==0 or b==0:\n break\n elif a>=2*b and a!=0 and b!=0:\n a = a % (2*b)\n elif b>=2*a and a!=0 and b!=0:\n b = b % (2*a)\n else:\n break\n\nprint(a, b)"}, {"source_code": "a,b=map(int,input().split())\nwhile a*b and not a<2*b<4*a:\n if b<a:a%=2*b\n else:b%=2*a\nprint(a,b)"}, {"source_code": "\"\"\"\nCreated on Mon Sep 24 12:10:05 2018\n\n@author: BrianRG\n\"\"\"\n\ndef weird(a,b):\n if(not a or not b):\n return (a,b)\n if(a>=2*b):\n a%=(2*b)\n return weird(a,b)\n if(b>=2*a):\n b%=(2*a)\n return weird(a,b)\n return(a,b)\n\"\"\" \ndef weirdo(a,b):\n while(a and b):\n if(a>=2*b):\n a%=(2*b)\n if(b>=2*a):\n b%=(2*a)\n else:\n if(a>=2*b):\n a-=2*b\n continue\n break\n return a,b\n\"\"\"\na,b=input().split(\" \")\na,b=weird(int(a),int(b))\nprint(a,b)"}, {"source_code": "import time\na, b = map(int, raw_input().split())\nwhile 1:\n if (a==0) or (b==0):\n print('%d %d' % (a, b))\n break\n if a >= 2*b:\n a = a % (2*b)\n elif b >= 2*a:\n b = b % (2*a)\n else:\n print('%d %d' % (a, b))\n break\n\n"}, {"source_code": "a,b=map(int,input().split())\nfor _ in[0]*36:\n if b:a%=2*b\n if a:b%=2*a\nprint(a,b)"}, {"source_code": "a, b = [int(i) for i in input().split()]\n\nwhile True:\n if a == 0 or b == 0: break\n if a >= b << 1: a %= b << 1\n elif b >= a << 1: b %= a << 1\n else: break\n\nprint(a, b)"}, {"source_code": "\nintput = lambda:map(int, raw_input().split())\n\na, b = intput()\nwhile a != 0 and b != 0:\n if a >= 2*b:\n a -= int(a/(2*b)) * 2*b\n elif b >= 2*a:\n b -= int(b/(2*a)) * 2*a\n else:\n break\n\nprint a, b\n"}, {"source_code": "import math\na,b=map(int,raw_input().strip().split())\nwhile(a!=0 and b!=0):\n if a>=2*b:\n a=a%(2*b)\n elif b>=2*a:\n b=b%(2*a)\n else:\n break\nprint a,b"}, {"source_code": "\na, b = map(int, raw_input().split(' '))\n\nwhile a != 0 and b != 0:\n if a < 2 * b and b < 2 * a:\n break\n\n a %= (2 * b)\n if a:\n b %= (2 * a)\n\nprint \"{} {}\".format(a, b)\n"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nactivo=True\nwhile activo:\n if(a==0 or b== 0):\n activo=False\n break\n else:\n if (a >= 2 * b):\n a %= 2 * b\n else:\n if (b >= 2 * a):\n b %= 2 * a\n else:\n activo = False\n break\nprint(str(a)+\" \"+str(b))"}, {"source_code": "a,b=[int(i) for i in raw_input().split()]\nwhile a!=0 and b!=0:\n if a>=2*b:\n a=a%(2*b)\n continue\n elif b>=2*a:\n b=b%(2*a)\n continue\n else:\n break\nprint a,b\n"}, {"source_code": "def process(a, b):\n if a == 0 or b == 0:\n return (a, b)\n elif a >= 2 * b:\n a -= (a // (2 * b)) * 2 * b\n return process(a, b)\n elif b >= 2 * a:\n b -= (b // (2 * a)) * 2 * a\n return process(a, b)\n else:\n return (a, b)\n\n(a, b) = (int(x) for x in raw_input().split())\n\n(a1, b1) = process(a, b)\nprint \"%d %d\" % (a1, b1)\n"}, {"source_code": "s = input().split()\na = int(s[0])\nb = int(s[1])\n\nwhile(a!=0 and b!=0):\n if a>=2*b:\n a = a%(2*b)\n\n else:\n if b<2*a:\n break\n else:\n b = b%(2*a)\n\nprint('{} {}'.format(a, b))"}, {"source_code": "a, b = map(int, input().split())\nwhile a > 0 and b > 0:\n if a >= 2 * b:\n a %= 2 * b\n elif b >= 2 * a:\n b %= 2 * a\n else:\n break\nprint(a, b)"}, {"source_code": "a, b = map(int, raw_input().split())\nwhile True:\n\tif a == 0 or b == 0:\n\t\tbreak\n\tif a >= 2 * b:\n\t\ta %= 2 * b\n\telif b >= 2 * a:\n\t\tb %= 2 * a\n\telse:\n\t\tbreak\nprint a, b"}, {"source_code": "#!/bin/python\nfrom __future__ import print_function\nimport sys\n\nit = iter(sys.stdin.readlines())\na, b = [int(x) for x in next(it).split()]\n\n\ndef substract(a,b):\n while a and b:\n if a >= 2 * b:\n a = a % (2 * b)\n elif b >= 2 * a:\n b = b % (2 * a)\n else:\n return(a,b)\n return(a,b)\n\na, b = substract(a, b)\nprint(a, b)"}, {"source_code": "a,b = map(int,raw_input().split())\nwhile a*b>0:\n\tif a>=2*b:\n\t\ta=a%(2*b)\n\telif b>=2*a:\n\t\tb=b%(2*a)\n\telse:\n\t\tbreak\nprint a,b"}, {"source_code": "x ,y= map(int,input().split())\nT = True\n\nwhile T:\n\t\n\tif x==0 or y==0:\n\t\tprint(x,\" \",y)\n\t\tT=False\n\telif x>=2*y:\n\t\tx%=(2*y)\n\telif y>=2*x:\n\t\ty%=2*x\n\telse:\n\t\tprint(x,y)\n\t\tT=False\n\t\tbreak"}, {"source_code": "a,b = map(int,input().split())\nwhile ( a != 0 and b!= 0) and (a >= 2*b or b >= 2*a) :\n\tif a >= 2* b :\n\t\ta = a%(2*b)\n\telse :\n\t\tif b >= 2 * a :\n\t\t\tb = b%(2*a)\nprint(a,b)"}, {"source_code": "n,m = map(int,raw_input().split())\n\ndef solver(a,b) : \n\tif a == 0 or b == 0 : \n\t\tprint a,b\n\t\treturn\n\n\telif a >= 2*b : \n\t\tj = a/(2*b)\n\t\ta = a - j*(2*b)\n\t\tsolver(a,b)\n\n\telif b >= 2*a : \n\t\tj = b/(2*a);\n\t\tb = b - j*(2*a)\n\t\tsolver(a,b)\n\telse : \n\t\tprint a,b\n\t\treturn\n\nsolver(n,m)\n"}, {"source_code": "a,b = map(int,input().split())\n\nwhile True:\n if a == 0 or b == 0:\n break\n elif a >= 2*b:\n k = a//(2*b) \n a = a - 2*k*b\n elif b >= 2*a:\n k = b//(2*a) \n b = b - 2*k*a\n else:\n break\n\nprint(a,b)"}, {"source_code": "a,b = map(int,input().split())\nwhile True:\n if a==0 or b==0:\n print(a,b)\n break\n elif a >= 2*b:\n a = a % (2*b)\n elif b >= 2*a:\n b = b % (2*a)\n else:\n print(a,b)\n break"}, {"source_code": "a,b=[int(x) for x in input().split()]\nflag=0\nwhile True:\n if a==0 or b==0:\n break\n if a>=2*b:\n a=a%(2*b)\n continue\n if b>=2*a:\n b=b%(2*a)\n continue\n else:\n break\nprint(a,\" \",b)\n"}, {"source_code": "numbers=input().split(\" \")\na=int(numbers[0])\nb=int(numbers[1])\ncon=1\n\nwhile (a!=0) and (b!=0):\n if a>=2*b:\n a=a%(2*b)\n elif b>=2*a:\n b=b%(2*a)\n else:\n break\nprint(a,b) \n \n \n"}, {"source_code": "a, b = map(int, input().split())\nwhile(a >= 2 * b or 2 * a <= b):\n\tif(a == 0 or b == 0):\n\t\tbreak\n\tif(a >= 2 * b):\n\t\ta = a % (2 * b)\n\telif(b >= 2 * a):\n\t\tb = b % (2 * a)\nprint(a, b)"}, {"source_code": "a, b=map (int, input ().split ())\nwhile True:\n\tif (a==0 or b==0) or (max(a, b)<2*min(a,b)):\n\t\tprint (a, b)\n\t\tbreak\n\telif a>=2*b:\n\t\ta=a-(a//(2*b))*2*b\n\telse:\n\t \n\t\tb=b-(b//(2*a))*2*a"}, {"source_code": "import math\nn,m=(int(i) for i in input().split())\nwhile(n!=0 and m!=0 and ((n>=m and n>=2*m) or (m>n and m>=2*n))):\n if(n>=m):\n n%=(2*m)\n else:\n m%=(2*n)\nprint(n,m)"}, {"source_code": "a, b = map(int, raw_input().split())\nwhile True:\n\tif a == 0 or b == 0:\n\t\tbreak\n\tif a >= 2 * b:\n\t\ta %= 2 * b\n\telif b >= 2 * a:\n\t\tb %= 2 * a\n\telse:\n\t\tbreak\nprint a, b"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a != 0 and b != 0 and (a >= 2 * b or b >= 2 * a):\n if a >= 2*b:\n a %= (2*b)\n elif b >= 2*a:\n b %= (2*a)\n\nprint(a,b)\n\n"}, {"source_code": "a, b = (int(i) for i in input().split())\n\nwhile a > 0 and b > 0:\n if a >= 2*b:\n a = a % (2 * b)\n \n elif b >= 2*a:\n b = b % (2 * a)\n \n else:\n break\n \nprint(a, b)"}, {"source_code": "a, b = map(int, raw_input().split(\" \"))\nwhile not(a == 0) or not(b == 0): \n\tif a >= 2*b:\n\t\ta = a % (2*b)\n\t\tif a == 0 or b == 0:\n\t\t\tbreak\n\telif b >= 2*a:\n\t\tb = b % (2*a)\n\t\tif a == 0 or b == 0:\n\t\t\tbreak\n\telse:\n\t\tbreak\nprint a, b"}, {"source_code": "a, b = map(int, input().split())\nwhile a != 0 and b != 0:\n if a >= 2 * b:\n a = a % (2 * b)\n else:\n if b >= 2 * a:\n b = b % (2 * a)\n else:\n break;\nprint(a, b);\n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile True:\n if a == 0 or b == 0:\n break\n elif a >= 2 * b:\n a = a % (2 * b)\n elif b >= 2 * a:\n b = b % (2 * a)\n else:\n break\n\nprint(a, b)\n"}, {"source_code": "def solve():\n n, m = map(int, input().split())\n\n while True:\n if n == 0 or m == 0:\n print(n, m)\n return\n elif n >= 2*m:\n n = n % (2*m)\n continue\n elif m >= 2*n:\n m = m % (2*n)\n continue\n else:\n print(n,m)\n return\n\n\nif __name__ == \"__main__\":\n solve()\n\n\n"}, {"source_code": "\n\ndef main():\n a, b = [int(x) for x in raw_input().split()]\n\n\n while a != 0 and b != 0:\n if(a >= (2 * b)):\n bb = 2 * b\n a = a % bb\n elif(b >= (2 * a)):\n aa = 2 * a\n b = b % aa\n else:\n break\n print str(a) + \" \" + str(b)\n\nmain()"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a != 0 and b != 0:\n if a >= 2 * b:\n a %= 2 * b\n elif b >= 2 * a:\n b %= 2 * a\n else:\n break\n\nprint(a, b)"}, {"source_code": "in_x = input().split(\" \")\n\na, b = int(in_x[0]), int(in_x[1])\nwhile a != 0 and b != 0:\n if a >= 2 * b:\n a = a % (2 * b)\n continue\n elif b >= 2 * a:\n b = b % (2 * a)\n continue\n else:\n break\nprint(a, b)"}, {"source_code": "a,b = map(int, raw_input().split())\nwhile True:\n if a == 0 or b == 0:\n break\n if a >= 2 * b:\n a %= 2 * b\n continue\n if b >= 2 * a:\n b %= 2 * a\n continue\n break\nprint a,b\n"}, {"source_code": "a, b = map(int, raw_input().split(' '))\ndef cal(a, b):\n a %= 2 * b\n return a, b\n \n\nwhile (a > 0 and b > 0 and (a >= 2 * b or b >= 2 * a)):\n if (a > b):\n\ta, b = cal(a, b)\n else:\n\tb, a = cal(b, a)\n\nprint a, b\n"}, {"source_code": "from sys import stdin, stdout\n\n\ndef solution(a, b):\n if max(a, b) < min(a, b) * 2 or not a or not b:\n stdout.write(str(a) + ' ' + str(b))\n return\n \n if a > b:\n m = a // b\n \n if m & 1:\n solution(a - (m - 1) * b, b)\n else:\n solution(a - m * b, b)\n else:\n m = b // a\n \n if m & 1:\n solution(a, b - (m - 1) * a)\n else:\n solution(a, b - a * m) \n\n\na, b = map(int, stdin.readline().split())\nsolution(a, b)"}, {"source_code": "def fuck(a, b):\n\tif a * b == 0:\n\t\tprint(a, b)\n\t\treturn\n\tif a >= 2 * b:\n\t\tt = 2 * b\n\t\ta -= a // t * t\n\t\tfuck(a, b)\n\telif b >= 2 * a:\n\t\tt = 2 * a\n\t\tb -= b // t * t\n\t\tfuck(a, b)\n\telse:\n\t\tprint(a, b)\n\t\treturn\n\nfuck(*[int(i) for i in input().split()])"}, {"source_code": "def f(a, b):\n\tif a == 0 or b == 0:\n\t\treturn (a, b)\n\tif a >= 2 * b:\n\t\treturn f(a % (2 * b), b)\n\telif b >= 2 * a:\n\t\treturn f(a, b % (2 * a))\n\treturn (a, b)\n\na, b = map(int, input().split())\nprint(' '.join(list(map(str, f(a, b)))))"}, {"source_code": "\"\"\"\nAuthor : co_devil Chirag Garg\nInstitute : JIIT\n\"\"\"\n\nfrom __future__ import division, print_function\nimport itertools, os, sys, threading\nfrom collections import deque, Counter, OrderedDict, defaultdict\nimport heapq\nfrom math import ceil,floor,log,sqrt,factorial,pow,pi\n# from bisect import bisect_left,bisect_right\n# from decimal import *,threading\n\"\"\"from io import BytesIO, IOBase\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n from builtins import str as __str__\n str = lambda x=b'': x if type(x) is bytes else __str__(x).encode()\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._buffer = BytesIO()\n self._fd = file.fileno()\n self._writable = 'x' in file.mode or 'r' not in file.mode\n self.write = self._buffer.write if self._writable else None\n\n def read(self):\n return self._buffer.read() if self._buffer.tell() else os.read(self._fd, os.fstat(self._fd).st_size)\n\n def readline(self):\n while self.newlines == 0:\n b, ptr = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)), self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines += b.count(b'\\n') + (not b)\n self.newlines -= 1\n return self._buffer.readline()\n\n def flush(self):\n if self._writable:\n os.write(self._fd, self._buffer.getvalue())\n self._buffer.truncate(0), self._buffer.seek(0)\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b'\\r\\n')\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop('sep', b' '), kwargs.pop('file', sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop('end', b'\\n'))\n if kwargs.pop('flush', False):\n file.flush()\n\n\"\"\"\n\n\ndef ii(): return int(input())\ndef si(): return str(input())\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n\n\nabc = 'abcdefghijklmnopqrstuvwxyz'\nabd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12,\n 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24,\n 'z': 25}\nmod = 1000000007\ndx, dy = [-1, 1, 0, 0], [0, 0, 1, -1]\ndef getKey(item): return item[0]\ndef sort2(l): return sorted(l, key=getKey)\ndef d2(n, m, num): return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo(x): return (x and (not (x & (x - 1))))\ndef decimalToBinary(n): return bin(n).replace(\"0b\", \"\")\ndef ntl(n): return [int(i) for i in str(n)]\ndef powerMod(x, y, p):\n res = 1\n x %= p\n while y > 0:\n if y & 1:\n res = (res * x) % p\n y = y >> 1\n x = (x * x) % p\n return res\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n# For getting input from input.txt file\n# sys.stdin = open('input.txt', 'r')\n\n# Printing the Output to output.txt file\n# sys.stdout = open('output.txt', 'w')\n\ngraph = defaultdict(list)\nvisited = [0] * 1000000\ncol = [-1] * 1000000\ndef dfs(v, c):\n if visited[v]:\n if col[v] != c:\n print('-1')\n exit()\n return\n col[v] = c\n visited[v] = 1\n for i in graph[v]:\n dfs(i, c ^ 1)\n\ndef bfs(d,v):\n q=[]\n q.append(v)\n visited[v]=1\n while len(q)!=0:\n x=q[0]\n q.pop(0)\n for i in d[x]:\n if visited[i]!=1:\n visited[i]=1\n q.append(i)\n print(x)\n print(l)\n\ndef make_graph(e):\n d={}\n for i in range(e):\n x,y=mi()\n if x not in d.keys():\n d[x]=[y]\n else:\n d[x].append(y)\n if y not in d.keys():\n d[y] = [x]\n else:\n d[y].append(x)\n return d\ndef gr2(n):\n d={}\n for i in range(n):\n x,y=mi()\n if x not in d.keys():\n d[x]=[y]\n else:\n d[x].append(y)\n return d\n\ndef connected_components(graph):\n seen = set()\n def dfs(v):\n vs = set([v])\n component=[]\n while vs:\n v = vs.pop()\n seen.add(v)\n vs |= set(graph[v]) - seen\n component.append(v)\n return component\n ans=[]\n for v in graph:\n if v not in seen:\n d=dfs(v)\n ans.append(d)\n return ans\n\na,b=mi()\nwhile(1):\n if a==0 or b==0:\n break\n if a>=2*b and b>0:\n a=a%(2*b)\n if b>=2*a and a>0:\n b=b%(2*a)\n else:\n break\nprint(a,b)"}, {"source_code": "a, b = [int(x) for x in input().split(' ')]\n\nwhile min(a, b) > 0:\n if a >= 2 * b:\n a = a % (2 * b)\n elif b >= 2 * a:\n b = b % (2 * a)\n else:\n break\nprint(a, b)"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\nwhile n != 0 and m != 0:\n if n >= 2 * m:\n k = n // (2 * m)\n n -= 2 * m * k\n elif m >= 2 * n:\n k = m // (2 * n)\n m -= 2 * n * k\n else:\n break\nprint(n, m)"}, {"source_code": "\nif __name__=='__main__':\n a,b = map(int,input().split())\n\n while a!=0 and b!=0:\n #print(a,b)\n if a>=2*b:\n a = a%(2*b)\n else:\n if b>= 2*a:\n b = b%(2*a)\n else:\n break\n \n\n print(a,b)"}, {"source_code": "a,b = list(map(int,input().split()))\nwhile a!=0 and b!=0 and (a>=(2*b) or b>=(2*a)):\n if a >= (2*b):\n a = a - (a//(2*b))*(b*2)\n else:\n b = b - (b//(2*a))*(a*2)\nprint(a,b)\n"}, {"source_code": "a, b = map(int, input().split())\nfor i in range(26):\n if b:\n a = a%(2*b)\n if a:\n b = b%(2*a)\n \nprint(a, b)\n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile True:\n if a == 0 or b == 0:\n break\n elif a >= b * 2:\n a %= 2 * b\n elif b >= a * 2:\n b %= a * 2\n else:\n break\nprint(a, b)\n"}, {"source_code": "a,b=map(int,input().split())\nwhile(a!=0 and b!=0):\n if(a>=2*b):\n a%=2*b\n continue\n elif(b>=2*a):\n b%=2*a\n else:\n break\nprint(a,\" \",b)"}, {"source_code": "a, b = map(int,(input()).split())\nwhile True:\n if a==0 or b==0: break\n elif a>=(2*b): a = a%(2*b)\n elif b>=(2*a): b = b%(2*a)\n else: break\nprint(a,b)"}, {"source_code": "\n# coding: utf-8\n\n# In[11]:\n\n\na, b = input().split()\na, b = int(a), int(b)\n\nwhile True:\n if (a == 0 or b == 0 or (b < 2 * a and a < 2 * b)):\n print(a, b)\n break\n \n elif (a >= 2 * b):\n a = a % (2 * b)\n\n else:\n b = b % (2 * a)\n\n"}, {"source_code": "inp=input().split()\na=int(inp[0])\nb=int(inp[1])\nwhile True:\n if a==0 or b==0:\n break\n elif a>=(b<<1):\n n=a//(b<<1)\n a-=n*(b<<1)\n # print(\"a>=b : \",a,\" \",b)\n elif b>=(a<<1):\n n=b//(a<<1)\n b-=n*(a<<1)\n # print(\"a<=b : \",a,\" \",b)\n else:\n break\nprint(a,\" \",b)\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n a,b = LI()\n while a > 0 and b > 0:\n if a*2 <= b:\n b %= a*2\n elif b*2 <= a:\n a %= b*2\n else:\n break\n\n return '{} {}'.format(a,b)\n\n\nprint(main())\n\n\n"}], "negative_code": [{"source_code": "print(\"pidors=)\")\n"}, {"source_code": "a, b=map(int, input().split())\n#print(a,b)\nif(a>2*b):\n p=a//b\n a=a-b*p\nif(b>2*b):\n p=b//a\n b=b-a*p\n\n#print(p)\n\nwhile(1):\n p=a\n q=b\n \n if a>=2*b:\n a=a-2*b\n elif b>=2*a:\n b=b-2*a\n\n if(a==p and b==q):\n print(a,b)\n break\n\n\n\n\n"}, {"source_code": "m, n = map(int, input().split())\nwhile m != 0 and n != 0:\n if m >= 2 * n:\n m = m % (2*n)\n elif m >= 2 * m:\n n = n % (2*m)\n else:\n break\nprint(m, n)\n\n"}, {"source_code": "\ndef subtrac(a,b):\n try:\n if a==0 or b==0:\n return a,b\n elif a>=(2*b):\n return subtrac((a-2*b),b)\n elif b>=(2*a):\n return subtrac(a,(b-2*a))\n else:\n return a,b\n except:\n if a>b:\n return (a%(2*(b%a)),b)\n else:\n return (a,b%(2*(a%b)))\n\na,b=map(int,input().split())\nprint(*subtrac(a,b))\n\n\n\n# if a==0 or b==0:\n# print(a,b)\n# elif a==b:\n# print(a,b)\n# else:\n# if a<b:\n# a_n=a%b\n# if a_n==0:\n# print(*subtrac(a_n,b))\n# else:\n# b_n=b%(2*a_n)\n# print(*subtrac(a_n,b_n))\n# else:\n# b_n=b%a\n# if b_n==0:\n# print(*subtrac(a,b_n))\n# else:\n# print(*subtrac(a%(2*b_n),b_n))\n"}, {"source_code": "a,b=map(int,input().split())\nif a!=0 and b!=0 and a>=2*b or b>=2*a and a!=0 and b!=0:\n if a>=2*b:\n a-=(a//b)*b\n else:\n b-=(b//a)*a\nwhile a!=0 and b!=0 and a>=2*b or b>=2*a and a!=0 and b!=0:\n if a>=2*b:\n a-=2*b\n else:\n b-=2*a\nprint(a,b)"}, {"source_code": "a, b = map(int,(input()).split())\nwhile True:\n if a==0 or b==0: break\n elif a>=(2*b): a = a%b\n elif b>=(2*a): b = b%a\n else: break\nprint(a,b)"}, {"source_code": "\ndef subtrac(a,b):\n try:\n if a==0 or b==0:\n return a,b\n elif a>=(2*b):\n return subtrac((a-2*b),b)\n elif b>=(2*a):\n return subtrac(a,(b-2*a))\n else:\n return a,b\n except:\n if a>b:\n return (a%(2*(b%a)),b)\n else:\n return (a,b%(2*(a%b)))\n\na,b=map(int,input().split())\nprint(*subtrac(a,b))\n\n\n\n# if a==0 or b==0:\n# print(a,b)\n# elif a==b:\n# print(a,b)\n# else:\n# if a<b:\n# a_n=a%b\n# if a_n==0:\n# print(*subtrac(a_n,b))\n# else:\n# b_n=b%(2*a_n)\n# print(*subtrac(a_n,b_n))\n# else:\n# b_n=b%a\n# if b_n==0:\n# print(*subtrac(a,b_n))\n# else:\n# print(*subtrac(a%(2*b_n),b_n))\n"}, {"source_code": "#! /usr/bin/python3 -s\n\n\"\"\"\n 1 If a\u2009=\u20090 or b\u2009=\u20090, end the process. Otherwise, go to step 2;\n 2 If a\u2009\u2265\u20092\u00b7b, then set the value of a to a\u2009-\u20092\u00b7b, and repeat step 1. Otherwise, go to step 3;\n 3 If b\u2009\u2265\u20092\u00b7a, then set the value of b to b\u2009-\u20092\u00b7a, and repeat step 1. Otherwise, end the process.\n \n\"\"\"\n\ndef funct_1(a, b):\n if a == 0 or b == 0:\n return [a, b]\n else:\n return funct_2(a,b)\n\ndef funct_2(a, b):\n if a >= 2 * b:\n rest = a % b\n coef = (a - rest) / b\n \n if coef % 2 == 0:\n a = rest\n else:\n a = a - ((coef - 1) * b)\n \n return funct_1(a, b)\n else:\n return funct_3(a, b)\n\ndef funct_3(a, b):\n if b >= 2 * a:\n rest = b % a\n coef = (b - rest) / a\n \n if coef % 2 == 0:\n b = rest\n else:\n b = b - ((coef - 1) * a)\n \n return funct_1(a, b)\n else:\n return [a, b]\n\ndef main():\n [a,b] = [int(x) for x in input(\"\").split()]\n \n if a == 0 or b == 0:\n rpta = funct_1(a, b)\n elif a >= 2 * b:\n rpta = funct_2(a, b)\n elif b >= 2 * a:\n rpta = funct_3(a, b)\n else:\n rpta = [a, b]\n \n print('%d %d' %(rpta[0] , rpta[1]))\n\n\nmain()"}, {"source_code": "n,m=map(int,input().split())\na=n\nb=m\nwhile True:\n f = 0\n if a==0 or b==0:\n f=1\n break\n elif a>=2*b:\n x=a//b\n if x%2!=0:\n x=(x//2)*2-1\n a-=b*x\n f=1\n elif b>=2*a:\n x=b//a\n if x % 2 != 0:\n x = (x // 2) * 2 - 1\n b-=a*x\n f=1\n if f==0:\n break\nprint(a,b)"}, {"source_code": "linea = raw_input()\na,b = linea.split()\n# a,b are positive integers\na = int(a)\nb = int(b)\n\ndef doSeq1(a,b):\n if a == b:\n exit(0)\n else: doSeq2(a,b) # otherwise go to step 2\n\n\ndef doSeq2(a,b):\n if a >= 2*b:\n a = a-2*b\n doSeq1(a,b)\n else:\n doSeq3(a,b)\n\n\ndef doSeq3(a,b):\n if b >= 2*a:\n b = b-2*a\n doSeq1(a,b)\n else:\n exit(0)\n"}, {"source_code": "import math\ns = map(int, raw_input().split(' '))\na, b = s[0], s[1]\n\ndef cal(a, b):\n p = long(a) / long(2.0 * b);\n a -= 2 * b * long(p)\n return a, b\n \n\nwhile (a > 0 and b > 0 and (a >= 2 * b or b >= 2 * a)):\n if (a > b):\n\ta, b = cal(a, b)\n else:\n\tb, a = cal(b, a)\n\n print a, b\n"}, {"source_code": "linea = raw_input()\na,b = linea.split()\n# a,b are positive integers\na = int(a)\nb = int(b)\n\ndef doSeq1(a,b):\n if a == b:\n exit(0)\n else: doSeq2(a,b) # otherwise go to step 2\n\n\ndef doSeq2(a,b):\n if a >= 2*b:\n a = a-2*b\n doSeq1(a,b)\n else:\n doSeq3(a,b)\n\n\ndef doSeq3(a,b):\n if b >= 2*a:\n b = b-2*a\n doSeq1(a,b)\n else:\n exit(0)\n"}, {"source_code": "a,b=(int(x) for x in input().split(\" \"))\nwhile a != 0 and b != 0:\n\tif a >= 2*b:\n\t\ta -= int(a/(2*b))\n\t\tcontinue\n\telif b >= 2*a:\n\t\tb-= int(b/(2*a))\n\t\tcontinue\n\telse:\n\t\tbreak\nprint(str(a)+\" \"+str(b))"}, {"source_code": "input()\nprint(\"System.out.println(\\\"Pidor\\\")\")\n"}, {"source_code": "ab=input().split()\na=int(ab[0])\nb=int(ab[1])\nwhile a!=0 and b!=0:\n if a>=2*b:\n a=a%2*b\n elif b>=2*a:\n b=b%2*a\n else:\n break\nprint(a, b)"}, {"source_code": "a, b = map(int, input().split())\nwhile a > 0 and b > 0:\n if a > 2 * b and a > 3 * b:\n a -= (a // (2 * b)) * b\n elif a * 2 < b and a * 3 < b:\n b -= (b // (2 * a)) * a\n elif a >= 2 * b:\n a -= (a // b) * b\n elif a * 2 <= b:\n b -= (b // a) * a\n else:\n print(a, b)\n exit()\n # print(a, b)\n\nprint(a, b)"}, {"source_code": "def solve(a,b,i):\n if a==0 or b==0:\n return [a,b]\n else:\n if a>=2*b and i==False:\n a=a-2*b\n i=True\n return solve(a,b,i)\n else:\n if b>=2*a and i==True:\n b=b-2*a\n i=False\n return solve(a,b,i)\n else:\n return [a,b]\n\n\n\n\n\n\nif __name__ == '__main__':\n m, n = map(int,(input().split(' ')))\n print(\" \".join(map(str,solve(m,n,False))))\n"}, {"source_code": "n,m = input().split()\na = int(n)\nb = int(m)\nwhile (a != 0) and (b != 0):\n if a >= 2*b:\n ka1 = a//b\n a = a - ka1*b\n elif b >= 2*a:\n kb1 = b//a\n b = b - kb1*a\n else:\n break\nprint(a,b)"}, {"source_code": "a,b=input(\"Inserte a y b respectivamente: \").split()\na,b=[int(a),int(b)]\n#a= int(input(\"inserta a: \"))\n#b= int(input(\"inserta b: \"))\nn=a\nm=b\ndef checkMahNums(n,m):\n if(n<1 or m>=10**18):\n return print(\"This number is not valid\")\n\ndef ShowMeTheSub(a,b):\n while a!=0 and b!=0:\n if a>=2*b:\n a=a-(2*b)\n elif b>=2*a:\n b=b-(2*a)\n\n return print(a,b)\n#print(n-m)\n#checkMahNums(n,m)\nShowMeTheSub(n,m)\n\n"}, {"source_code": "numbers=input().split(\" \")\na=int(numbers[0])\nb=int(numbers[1])\ncon=1\n\nwhile (a!=0) and (b!=0):\n if a>=2*b:\n a=a%(2*b)\n print(a)\n elif b>=2*a:\n b=b%(2*a)\n print(b)\n else:\n break\nprint(a,b) \n \n \n"}, {"source_code": "linea = raw_input()\na,b = linea.split()\n# a,b are positive integers\na = int(a)\nb = int(b)\n\ndef doSeq1(a,b):\n if a == b:\n exit(0)\n else: doSeq2(a,b) # otherwise go to step 2\n\n\ndef doSeq2(a,b):\n if a >= 2*b:\n a = a-2*b\n doSeq1(a,b)\n else:\n doSeq3(a,b)\n\n\ndef doSeq3(a,b):\n if b >= 2*a:\n b = b-2*a\n doSeq1(a,b)\n else:\n exit(0)\n"}, {"source_code": "a, b = (int(i) for i in input().split())\n\nwhile a > 0 and b > 0:\n if a >= 2*b:\n a = a % b\n \n elif b >= 2*a:\n b = b % a\n \n else:\n break\n \nprint(a, b)"}, {"source_code": "a,b=map(int,input().split())\nfor _ in[0]*20:\n if b:a%=2*b\n if a:b%=2*a\nprint(a,b)"}, {"source_code": "n,m = input().split()\na = int(n)\nb = int(m)\nwhile (a != 0) and (b != 0):\n if a >= 2*b:\n ka = a//b\n a = a - (ka-1)*b\n elif b >= 2*a:\n kb = b//a\n b = b - (kb-1)*a\n else:\n break\nprint(a,b)"}, {"source_code": "from __future__ import print_function\nimport sys\ndef end(a,b):\n print(a,b)\n exit()\ndef step1(a,b):\n if(a == 0 or b == 0):\n end(a,b)\n else:\n step2(a,b)\ndef step2(a,b):\n if(a >= 2*b):\n a = a % 2*b\n step1(a,b)\n else:\n step3(a,b)\ndef step3(a,b):\n if(b>=2*a):\n b = b%2*a\n step1(a,b)\n else:\n end(a,b)\n\nit = iter(sys.stdin.read().split())\na = int(next(it))\nb = int(next(it))\nstep1(a,b)\n\n\n\n\n"}, {"source_code": "a, b = input().split()\na, b = int(a), int(b)\n\nwhile (a!=0 and b!=0):\n\tif (a>2*b):\n\t\ta=a-2*b\n\telif b>2*a:\n\t\tb=b-2*a\n\telse:\n\t\tbreak\nprint(a, b)"}, {"source_code": "def f(a, b):\n if b == 0 or a < 2*b:\n return b, a\n else:\n return f(b, a % (2*b))\n\n\na, b = map(int, input().split())\nif a < b:\n a, b = b, a\nprint(*f(a, b))"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a > 2 * b and a > 4 * b:\n a -= ((a // b) // 2) * b\n elif a * 2 < b and a * 4 < b:\n b -= ((b // a) // 2) * a\n elif a >= 2 * b:\n a -= 2 * b\n elif a * 2 <= b:\n b -= 2 * a\n else:\n print(a, b)\n exit()\nprint(a, b)\n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a != 0 and b != 0 and (a >= 2 * b or b >= 2 * a):\n if a >= 2*b:\n a %= (2*b)\n elif b >= 2*a:\n b %= (2*a)\n\n print(a)\n print(b)\n\n"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nactivo=True\nwhile activo:\n if(a==0 or b== 0):\n activo=False\n break\n else:\n if (a >= 2 * b):\n a = a % 2 * b\n else:\n if (b >= 2 * a):\n b = b % 2 * a\n else:\n activo = False\n break\nprint(str(a)+\" \"+str(b))"}, {"source_code": "a, b = map(int, input().split())\nwhile a and b:\n if a >= 2 * b:\n a %= b\n elif b >= 2 * a:\n b %= a\n else:\n break\n \nprint(a, b)\n"}, {"source_code": "a, b = map(int, input().split())\nwhile a > 0 and b > 0:\n if a >= 2 * b:\n a -= (a // b) * b\n elif a * 2 <= b:\n b -= (b // a) * a\n else:\n print(a, b)\n exit()\n\nprint(a, b)"}, {"source_code": "a, b = map(int, input().split())\nwhile(a >= 2 * b or 2 * a <= b):\n\tif(a == 0 or b == 0):\n\t\tbreak\n\tif(a >= 2 * b):\n\t\ta = a % b\n\telif(b >= 2 * a):\n\t\tb = b % a\nprint(a, b)"}, {"source_code": "a, b=map(int, input().split())\n#print(a,b)\nif(a>2*b):\n p=a//b\n a=a-b*p\nif(b>2*b):\n p=b//a\n b=b-a*p\n\nprint(a,b)\n\n\n\n\n"}, {"source_code": "a, b = input().split()\na, b = int(a), int(b)\n\nwhile (a!=0 and b!=0):\n\tif (a>2*b):\n\t\ta=a-2*b\n\telif b>2*a:\n\t\tb=b-2*a\n\telse:\n\t\tbreak\nprint(a, b)"}, {"source_code": "from sys import stdin\nimport sys\nlines = stdin.readlines()\n\na,b = map(int,lines[0].split())\n\ndef bul(c,c2):\n if c>=c2:\n if c / c2 == 1:\n return c,c2\n elif c % c2 == 0 and (c / c2) % 2 == 0:\n return 0,1\n elif c % c2 == 0 and (c / c2) % 2 == 1:\n return c2,c2\n elif (c /c2) % 2 == 1:\n return c2 + c % c2, c2\n elif (c / c2) % 2 == 0:\n res1,res2 = c % c2, c2\n if res2 >= res1*2:\n return bul(res1,res2)\n else:\n return res1,res2\n else:\n if c2 / c == 1:\n return c,c2\n elif c2 % c == 0 and (c2 / c) % 2 == 0:\n return c,0\n elif c2 % c == 0 and (c2 / c) % 2 == 1:\n return c,c\n elif (c2 /c) % 2 == 1:\n return c,c + c2 % c\n elif (c2 / c) % 2 == 0:\n res1,res2 = c, c2 % c\n if res1 >= res2*2:\n return bul(res1,res2)\n else:\n return res1,res2\ntemp = bul(a,b)\nfor e in temp:\n print e,"}, {"source_code": "n,m = input().split()\na = int(n)\nb = int(m)\nwhile (a != 0) and (b != 0):\n if a >= 2*b:\n ka = a//b\n a = a - ka*b\n elif b >= 2*a:\n kb = b//a\n b = b - kb*a\n else:\n break\nprint(a,b)"}, {"source_code": "\nif __name__=='__main__':\n a,b = map(int,input().split())\n\n while a!=0 and b!=0:\n #print(a,b)\n if a>=2*b:\n a -= 2*b\n elif b>=2*b:\n b -= 2*a\n else:\n break\n print(a,b)"}, {"source_code": "a,b=map(int,input().split())\nfor _ in[0]*9:\n if b:a%=2*b\n if a:b%=2*a\nprint(a,b)"}, {"source_code": "n,m = input().split()\na = int(n)\nb = int(m)\nwhile (a != 0) and (b != 0):\n if a >= 2*b:\n ka = a//b\n a = a - (ka-1)*b\n elif b >= 2*a:\n kb = b//a\n b = b - (kb-1)*a\n else:\n break\nprint(a,b)"}, {"source_code": "import sys\ndef subtrac(a,b):\n\n if a==0 or b==0:\n return a,b\n elif a>=(2*b):\n return subtrac((a-2*b),b)\n elif b>=(2*a):\n return subtrac(a,(b-2*a))\n else:\n return a,b\n\ntry:\n a,b=map(int,input().split())\n\n if a==0 or b==0:\n print(a,b)\n elif a==b:\n print(a,b)\n\n else:\n if a<b:\n a_n=a%b\n if a_n==0:\n print(*subtrac(a_n,b))\n else:\n b_n=b%(2*a_n)\n print(*subtrac(a_n,b_n))\n else:\n b_n=b%a\n if b_n==0:\n print(*subtrac(a,b_n))\n else:\n print(*subtrac(a%(2*b_n),b_n))\n\nexcept:\n if a>b:\n print(a%b,b%2)\n else:\n print(a%2,b%a)\n"}, {"source_code": "a, b = list(map(int,input().strip().split(' ')))\nwhile True:\n if a == 0 or b == 0:\n break\n else:\n if a >= 2 * b:\n a %= b\n else:\n if b >= 2 * a:\n b %= a\n else:\n break\nprint(a,b)"}, {"source_code": "a, b = map(int, input().split())\nmark = True\nwhile a > 0 and b > 0 and mark:\n mark = False\n if (a > 2 * b and b > 0):\n a = a % (2 * b)\n mark = True\n if (b > 2 * a and a > 0):\n b = b % (2 * a)\n mark = True\n \nprint(a, b)\n \n"}, {"source_code": "a, b = list(map(int,input().strip().split(' ')))\nwhile True:\n if a == 0 or b == 0:\n break\n else:\n if a >= 2 * b:\n a %= 2 * b\n else:\n if b >= 2 * a:\n b %= 2 * a\n else:\n break\n print(a,b)\nprint(a,b)"}, {"source_code": "a,b = map(int, input().split())\n\nif a==0 or b==0:\n print(a,b)\n\nif a >= 2*b:\n newa= a % 2*b\n\nif newa==0 or b==0:\n print(newa,b)\n\nif b -2*a >=0:\n newb = b % 2*a\n print(newa,newb)\nelse:\n print(newa,b)\n\n\n\n"}, {"source_code": "import math\ndef prime(n):\n ok= True\n for i in range(2, int(math.sqrt(n))):\n if(n%i==0):\n ok = False\n break\n if(ok):\n return True\n else:\n return False\ndef fact(a,b):\n ans = 1\n for i in range(a, b+1):\n ans*= i\n return str(ans)-1\ndef comb(n, c):\n return fact(n)//(fact(n-c)*c)\n\na,b = map(int, input().split())\ndef done(a,b):\n if(a==0 or b==0):\n return True\n return False\nwhile(not done(a, b)):\n if(a >= 2*b):\n left = 0\n right = int(10e18)\n while(left < right):\n mid = ((left+right)//2)\n if(b*mid > a):\n right = mid\n else:\n left = mid+1\n left-=1\n a-=(left//2)*2*b\n else:\n if(b >= 2*a):\n left = 0\n right = int(10e18)\n while(left < right):\n mid = ((left+right)//2)\n if(a*mid > b):\n right = mid\n else:\n left = mid+1\n left-=1\n b-=(left//2)*2*a\n if((left-1)//2==0):\n break\n else:\n break\nprint(a,b)"}, {"source_code": "import sys\ndef subtrac(a,b):\n if a==0 or b==0:\n return a,b\n elif a>=(2*b):\n return subtrac((a-2*b),b)\n elif b>=(2*a):\n return subtrac(a,(b-2*a))\n else:\n return a,b\n\ntry:\n a,b=map(int,input().split())\n\n if a==0 or b==0:\n print(a,b)\n elif a==b:\n print(a,b)\n elif b==500000000000000:\n print(a,b)\n else:\n if a<b:\n a_n=a%b\n if a_n==0:\n print(*subtrac(a_n,b))\n else:\n b_n=b%(2*a_n)\n print(*subtrac(a_n,b_n))\n else:\n b_n=b%a\n if b_n==0:\n print(*subtrac(a,b_n))\n else:\n print(*subtrac(a%(2*b_n),b_n))\nexcept:\n sys.exit(1)\n"}, {"source_code": "z,zz,dgraphs,mod=input,lambda:list(map(int,z().split())),{},10**9+7\nfrom string import *\nfrom collections import *\nfrom queue import *\nfrom sys import *\nfrom collections import *\nfrom math import *\nfrom heapq import *\nfrom itertools import *\nfrom bisect import *\nfrom collections import Counter as cc\nfrom math import factorial as f\ndef lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))\ndef prime(x):\n p=ceil(x**.5)+1\n for i in range(2,p):\n if x%i==0 and x!=2:return 0\n return 1\ndef dfs(u,visit,graph):\n visit[u]=True\n for i in graph[u]:\n if not visit[i]:\n dfs(i,visit,graph)\n################################################################################\n\n\"\"\"\n\nled=(6,2,5,5,4,5,6,3,7,6)\n\ncolor4=[\"G\", \"GB\", \"YGB\", \"YGBI\", \"OYGBI\" ,\"OYGBIV\",'ROYGBIV' ]\n19 3\n5 4 10\n\"\"\"\n\n###########################---START-CODING---####################################\n\na,b=zz()\n\nwhile True:\n if a==0 or b==0:\n break\n elif a>=2*b:\n a=a%b\n elif b>=2*a:\n b=b%a\n else:\n break\nprint(a,b)\n \n\n"}, {"source_code": "a, b = list(map(int,input().strip().split(' ')))\nwhile True:\n if a == 0 or b == 0:\n break\n else:\n if a >= 2 * b:\n a %= 2 * b\n else:\n if b >= 2 * a:\n b %= 2 * a\n else:\n break\n print(a,b)\nprint(a,b)"}, {"source_code": "a, b = list(map(int,input().strip().split(' ')))\nwhile a != 0 and b != 0:\n if a >= 2 * b:\n a %= b\n elif b >= 2 * a:\n b %= a\n else:\n break\nprint(a,b)"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nwhile(a!=0 and b!=0):\n if(a>=2*b):\n a=a%b\n else:\n if(b>=2*a):\n b=b%a\n else:\n break\nprint(a,b)"}, {"source_code": "a,b=map(int,input().split())\n#a,b=12,5\nwhile a!=0 and b!=0:\n if a>=2*b:\n a=a%2*b\n continue\n if b>=2*a:\n b=b%2*a\n else:\n break\nprint(a,b)"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a > 2 * b:\n print((a // (2 * b)))\n a -= ((a // (2 * b)) * 2) * b\n elif a * 2 < b:\n b -= ((b // (2 * a)) * 2) * a\n elif a >= 2 * b:\n a -= 2 * b\n elif a * 2 <= b:\n b -= 2 * a\n else:\n print(a, b)\n exit()\nprint(a, b)\n"}, {"source_code": "raw = input()\na, b = raw.split()\na, b = int(a), int(b)\nwhile 1:\n\tif a == 0 or b == 0:\n\t\tprint(a, b)\n\t\texit()\n\tif a >= b<<1:\n\t\ta = a % b\n\t\tcontinue\n\telif b >= a<<1:\n\t\tb = b % a\n\t\tcontinue\n\telse:\n\t\tprint(a, b)\n\t\texit()\n"}, {"source_code": "a,b = map(int, raw_input().split())\nx = 0\nwhile True:\n x += 1\n prev_a = a\n prev_b = b\n roz_a_b = a-b\n roz_b_a = b-a\n #print a, b, roz_a_b, roz_b_a\n if roz_a_b > 0:\n if (roz_a_b/(2*b)) > 0:\n a -= 2*b*(roz_a_b/(2*b))\n else:\n a -= 2*b\n elif roz_b_a > 0:\n if (roz_b_a /(2*a)) > 0:\n b -= 2*a*(roz_b_a /(2*a))\n else:\n b -= 2*a\n if a == 0 or b == 0 or (a<2*b and b<2*a):\n break\n if x == 5:\n break\nprint a,b"}, {"source_code": "print(\"pidors=)\")\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom fractions import gcd\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (\n acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,\n sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\ndef gcd_custom(a, b):\n if a == 0 or b == 0:\n return a, b\n if a >= 2*b:\n return gcd_custom(b, a % b)\n elif b >= 2*a:\n return gcd_custom(a, b % a)\n else:\n return a, b\n\n\na, b = invr()\nc, d = gcd_custom(a, b)\nprint(d, c)\n"}, {"source_code": "def c(a,b):\n while True:\n if a>=2*b:\n a = a-2*b\n \n if a==0 or b==0:\n break\n if b>=2*a:\n b = b -2*a\n \n else:\n break\n if a==0 or b==0:\n break\n print(a,b)\n\na, b = map(int, input().split())\nif a==0 or b==0:\n print(a,b)\nelse:\n c(a,b)\n"}, {"source_code": "L = input().split();\na,b = map(int,L);\n#print (a);\nwhile (True):\n #print(a,' ',b);\n if (a == 0 and b == 0):\n break;\n if (a > 2*b):\n a = a-2*b;\n else:\n if (b>a*2):\n b = b-a*2;\n else:\n break;\nprint(a,' ',b);\n"}, {"source_code": "a, b = list(map(int,input().strip().split(' ')))\nwhile True:\n if a == 0 or b == 0:\n break\n else:\n if a >= 2 * b:\n a %= 2 * b\n else:\n if b >= 2 * a:\n b %= 2 * a\n else:\n break\n print(a,b)\nprint(a,b)"}, {"source_code": "#\n# Yet I'm feeling like\n# \tThere is no better place than right by your side\n# \t\tI had a little taste\n# \t\t\tAnd I'll only spoil the party anyway\n# \t\t\t\t'Cause all the girls are looking fine\n# \t\t\t\t\tBut you're the only one on my mind\n\n\nimport sys\n# import re\n# inf = float(\"inf\")\n# sys.setrecursionlimit(1000000)\n\n# abc='abcdefghijklmnopqrstuvwxyz'\n# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\n# vow=['a','e','i','o','u']\n# dx,dy=[-1,1,0,0],[0,0,1,-1]\n\n# from collections import deque, Counter, OrderedDict,defaultdict\n# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n# from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan\n# from bisect import bisect_left,bisect_right\n# import numpy as np\n\n\ndef get_array(): return list(map(int , sys.stdin.readline().strip().split()))\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef input(): return sys.stdin.readline().strip()\n\na,b=get_ints()\n# flag=0\nwhile True:\n if a==0 or b==0:\n # flag=1\n break\n elif a>=2*b:\n a=a%b\n continue\n elif b>=2*a:\n b=b%a\n continue\n else:\n break\nprint(a,b)"}, {"source_code": "a,b = map(int, input().split())\n\ncc=1\nwhile(cc==1):\n if a==0 or b==0:\n print(a,b)\n cc=0\n break\n\n if a >= 2*b:\n a = a % 2*b\n\n if a==0 or b==0:\n print(a, b)\n cc = 0\n break\n\n if b -2*a >=0:\n b = b - 2*a\n else:\n print(a,b)\n cc = 0\n break\n\n\n\n"}, {"source_code": "a = raw_input()\na = a.split(\" \")\n\nlista = a\na = long(lista[0])\nb = long(lista[1])\n\nfalse = True\nfalse1 = True\nwhile false1 != False:\n if a >= 2*b :\n a = a - (2*b)\n if a < 0:\n a = a + (2*b)\n false1 = False\n if b >= 2*a :\n b = b - (2*a)\n \n if b < 0:\n b = b + (2*a)\n false1 = False\n else:\n false1 = False\n if a == 0 or a < 0 or b == 0 or b < 0:\n false1 = False\n \nprint a , b \n \n"}, {"source_code": "a, b=map(int, input().split())\n#print(a,b)\nif(a>2*b):\n p=a//b\n a=a-b*p\nif(b>2*b):\n p=b//a\n b=b-a*p\n\nprint(a,b)\n\n\n\n\n"}, {"source_code": "linea = raw_input()\na,b = linea.split()\n# a,b are positive integers\na = int(a)\nb = int(b)\n\ndef doSeq1(a,b):\n if a == b:\n exit(0)\n else: doSeq2(a,b) # otherwise go to step 2\n\n\ndef doSeq2(a,b):\n if a >= 2*b:\n a = a-2*b\n doSeq1(a,b)\n else:\n doSeq3(a,b)\n\n\ndef doSeq3(a,b):\n if b >= 2*a:\n b = b-2*a\n doSeq1(a,b)\n else:\n exit(0)\n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a > 2 * b and a > 4 * b:\n a -= ((a // (2 * b)) // 2) * b\n elif a * 2 < b and a * 4 < b:\n b -= ((b // (2 * a)) // 2) * a\n elif a >= 2 * b:\n a -= 2 * b\n elif a * 2 <= b:\n b -= 2 * a\n else:\n print(a, b)\n exit()\nprint(a, b)\n"}, {"source_code": "s = input()\nl, pos, = len(s), -1,\nfor i in range(l):\n if s[i] == 'a':\n pos=i+1\n break\nif pos == -1:\n print(\"-1\")\nelse:\n pos = l-pos\n if pos >= 25:\n print(\"abcdefghijklmnopqrstuvwxyz\")\n else:\n print(\"-1\")\n"}, {"source_code": "n,m = input().split()\na = int(n)\nb = int(m)\nwhile (a != 0) and (b != 0):\n if a >= 2*b:\n ka = a//b\n a = a - (ka-1)*b\n elif b >= 2*a:\n kb = b//a\n b = b - (kb-1)*a\n else:\n break\nprint(a,b)"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a != 0 and b != 0 and (a >= 2 * b or b >= 2 * a):\n if a >= 2*b:\n a %= (2*b)\n elif b >= 2*a:\n b %= (2*a)\n\n print(a,b)\n\n"}, {"source_code": "from __future__ import print_function\nimport sys\ndef end(a,b):\n print(a,b)\n exit()\ndef step1(a,b):\n if(a == 0 or b == 0):\n end(a,b)\n else:\n step2(a,b)\ndef step2(a,b):\n if(a >= 2*b):\n a = a % 2*b\n step1(a,b)\n else:\n step3(a,b)\ndef step3(a,b):\n if(b>=2*a):\n b = b%2*a\n step1(a,b)\n else:\n end(a,b)\n\nit = iter(sys.stdin.read().split())\na = int(next(it))\nb = int(next(it))\nstep1(a,b)\n\n\n\n\n"}, {"source_code": "a, b = (int(i) for i in input().split())\n\nwhile a > 0 and b > 0:\n if a >= 2*b:\n a = a % b\n \n elif b >= 2*a:\n b = b % a\n \n else:\n break\n \nprint(a, b)"}, {"source_code": "a,b = map(int, input().split())\n\nif a==0 or b==0:\n print(a,b)\n\nif a >= 2*b:\n newa= a % 2*b\n\nif newa==0 or b==0:\n print(newa,b)\n\nif b -2*a >=0:\n newb = b % 2*a\n print(newa,newb)\nelse:\n print(newa,b)\n\n\n\n"}, {"source_code": "a,b = map(int,input().split())\nwhile True:\n if a==0 or b==0:\n print(a,b)\n break\n elif a >= 2*b:\n a = a%2*b\n elif b >= 2*a:\n b = b%2*a\n else:\n print(a,b)\n break"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a > 2 * b and a > 4 * b:\n a -= ((a // (2 * b)) // 2) * b\n elif a * 2 < b and a * 4 < b:\n b -= ((b // (2 * a)) // 2) * a\n elif a >= 2 * b:\n a -= 2 * b\n elif a * 2 <= b:\n b -= 2 * a\n else:\n print(a, b)\n exit()\nprint(a, b)\n"}, {"source_code": "s = input().split()\na = int(s[0])\nb = int(s[1])\nwhile(a!=0 and b!=0):\n if a>=2*b:\n a=a-2*b\n if b<a*a:\n break\n else:\n b=b-2*a\n\nprint('{} {}'.format(a, b))"}, {"source_code": "import sys\nfrom collections import defaultdict as dd\nfrom collections import deque\nfrom fractions import Fraction as f\nfrom copy import *\nfrom bisect import *\t\nfrom heapq import *\nfrom math import *\nfrom itertools import permutations \n \ndef eprint(*args):\n print(*args, file=sys.stderr)\nzz=1\n \n#sys.setrecursionlimit(10**6)\nif zz:\n\tinput=sys.stdin.readline\nelse:\t\n\tsys.stdin=open('input.txt', 'r')\n\tsys.stdout=open('all.txt','w')\ndef li():\n\treturn [int(x) for x in input().split()]\ndef fli():\n\treturn [float(x) for x in input().split()]\t\ndef gi():\t\n\treturn [x for x in input().split()]\ndef fi():\n\treturn int(input())\ndef swap(a,i,j):\n\ta[i],a[j]=a[j],a[i]\t\ndef si():\n\treturn list(input().rstrip())\t\ndef mi():\n\treturn \tmap(int,input().split())\t\ndef gh():\n\tsys.stdout.flush()\ndef graph(n,m):\n\tfor i in range(m):\n\t\tx,y=mi()\n\t\ta[x].append(y)\n\t\ta[y].append(x)\ndef bo(i):\n\treturn ord(i)-ord('a')\n\t\t\n\na,b=mi()\n\nwhile a>=2*b or b>=2*a:\n\tk=1\n\twhile a>=(2**k)*b:\n\t\tk+=1\n\tk-=1\n\ta-=(2**k*b if k>0 else 0)\t\n\tk=1\n\n\tif a==0 or b==0:\n\t\tbreak\n\twhile b>=(2**k)*a:\n\t\tk+=1\n\telse:\n\t\tbreak\t\n\tk-=1\n\n\nprint(a,b)\t\t\n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a > 2 * b and a > 4 * b:\n a -= ((a // (2 * b)) // 2) * b\n elif a * 2 < b and a * 4 < b:\n b -= ((b // (2 * a)) // 2) * a\n elif a >= 2 * b:\n a -= 2 * b\n elif a * 2 <= b:\n b -= 2 * a\n else:\n print(a, b)\n exit()\nprint(a, b)\n"}, {"source_code": "\na,b=map(int,raw_input().split())\n\ndef ff(a,b):\n if a==0 or b==0:\n return (a,b)\n if a>=2*b:\n return (a%(2*b),b)\n if b>=2*a:\n return (a,b%(2*a))\n\nwhile a!=0 and b!=0 and (a>=2*b or b>=2*a):\n a,b=ff(a,b)\n print a,b\n\nprint a,b\nexit()\n"}, {"source_code": "numbers=input().split(\" \")\na=int(numbers[0])\nb=int(numbers[1])\ncon=1\nwhile (a!=0) and (b!=0):\n if a>=2*b:\n a=a%b\n elif b>=2*a:\n b-=2*a\n else:\n break\nprint(a,b) \n \n \n"}, {"source_code": "\na,b=map(int,raw_input().split())\n\ndef ff(a,b):\n if a==0 or b==0:\n return (a,b)\n if a>=2*b:\n return (a%(2*b),b)\n if b>=2*a:\n return (a,b%(2*a))\n\nwhile a!=0 and b!=0 and (a>2*b or b>2*a):\n a,b=ff(a,b)\n\nprint a,b\nexit()\n"}, {"source_code": "ab=input().split()\na=int(ab[0])\nb=int(ab[1])\nwhile a!=0 and b!=0:\n if a>=2*b:\n a=a%2*b\n elif b>=2*a:\n b=b%2*a\n else:\n break\nprint(a, b)"}, {"source_code": "print(\"pidors\")\n"}, {"source_code": "a,b=[int(x) for x in input().split()]\nflag=0\nif a==0 or b==0:\n print(a,\" \",b)\nelif a>=2*b:\n a=a%b\n print(a,\" \",b)\nelif b>=2*a:\n b=b%a\n print(a,\" \",b)\nelse:\n print(a,\" \",b)\n \n\n"}, {"source_code": "n,m = input().split()\na = int(n)\nb = int(m)\nk = 0\nwhile (a != 0) and (b != 0) and (k != 0):\n if a >= 2*b:\n ka = a//b\n a = a - ka*b\n elif b >= 2*a:\n kb = b//a\n b = b - kb*a\n else:\n k = 1\nprint(a,b)"}, {"source_code": "a, b = map(int,(input()).split())\nwhile True:\n if a==0 or b==0: break\n elif a>=(2*b): a = a%b\n elif b>=(2*a): b = b%a\n else: break\nprint(a,b)"}, {"source_code": "z,zz,dgraphs,mod=input,lambda:list(map(int,z().split())),{},10**9+7\nfrom string import *\nfrom collections import *\nfrom queue import *\nfrom sys import *\nfrom collections import *\nfrom math import *\nfrom heapq import *\nfrom itertools import *\nfrom bisect import *\nfrom collections import Counter as cc\nfrom math import factorial as f\ndef lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))\ndef prime(x):\n p=ceil(x**.5)+1\n for i in range(2,p):\n if x%i==0 and x!=2:return 0\n return 1\ndef dfs(u,visit,graph):\n visit[u]=True\n for i in graph[u]:\n if not visit[i]:\n dfs(i,visit,graph)\n################################################################################\n\n\"\"\"\n\nled=(6,2,5,5,4,5,6,3,7,6)\n\ncolor4=[\"G\", \"GB\", \"YGB\", \"YGBI\", \"OYGBI\" ,\"OYGBIV\",'ROYGBIV' ]\n19 3\n5 4 10\n\"\"\"\n\n###########################---START-CODING---####################################\n\na,b=zz()\n\nwhile True:\n if a==0 or b==0:\n break\n elif a>=2*b:\n a=a%b\n elif b>=2*a:\n b=b%a\n else:\n break\nprint(a,b)\n \n\n"}, {"source_code": "a,b=[int(x) for x in input().split()]\nflag=0\nwhile True:\n if a==0 or b==0:\n break\n if a>=2*b:\n a=a%b\n continue\n if b>=2*a:\n b=b%a\n continue\n else:\n break\n \nprint(a,\" \",b)\n"}, {"source_code": "a,b=map(int,input().split())\n\nwhile(a!=0 and b!=0):\n if(a>=2*b):\n a=a-2*b\n \n if(b>=2*a):\n b=b-2*a\n continue\n else:\n break\n\n \nprint(a,b)"}, {"source_code": "a,b=map(int,input().split())\nfor _ in[0]*36:\n if b:a%=2*a\n if a:b%=2*a\nprint(a,b)"}, {"source_code": "a,b = map(int, input().split())\n\nwhile(a >= 2*b or b -2*a >=0 and a >0 and b>0):\n print(a,b)\n if b > 0:\n a = a % (2*b)\n if a !=0:\n b = b % (2*a)\n\nprint(a,b)\n\n\n"}, {"source_code": "\"\"\"def run():\n a,b = list(map(int,input().split()))\n if a==0 or b==0:\n print(a,b)\n return 0\n elif b >= 2*a:\n b -= 2*a\n print(a,b)\n return 0\n else:\n print(a%(2*b),b)\nrun()\n\"\"\"\na,b = list(map(int,input().split()))\nwhile a!=0 and b!=0:\n if a >= 2*b:\n a = a % (b*2)\n break\n elif b >= 2*a:\n b = b % (a*2)\n break\nprint(a,b)\n"}, {"source_code": "a,b=map(int,input().split())\nwhile 1:\n\tif a==0 or b==0:\n\t\tbreak\n\tif a>=2*b:\n\t\ta-=((a//b)*b)\n\telse:\n\t\tif b>=2*a:\n\t\t\tb-=((b//a)*a)\n\t\telse:\n\t\t\tbreak\n\n\n\nprint(a,b)"}, {"source_code": "numbers=input().split(\" \")\na=int(numbers[0])\nb=int(numbers[1])\ncon=1\n\nwhile (a!=0) and (b!=0):\n if a>=2*b:\n a=a%(2*b)\n print(a)\n elif b>=2*a:\n b=b%(2*a)\n print(b)\n else:\n break\nprint(a,b) \n \n \n"}, {"source_code": "\nif __name__=='__main__':\n a,b = map(int,input().split())\n\n while a!=0 and b!=0:\n #print(a,b)\n if a>=2*b:\n a -= 2*b\n if b>= 2*a:\n b -= 2*a\n else:\n break\n print(a,b)"}, {"source_code": "a, b = map(int, input().split())\nmark = True\nwhile a > 0 and b > 0 and mark:\n mark = False\n if (a > 2 * b and b > 0):\n a = a % (2 * b)\n mark = True\n if (b > 2 * a and a > 0):\n b = b % (2 * a)\n mark = True\n \nprint(a, b)\n \n"}, {"source_code": "a, b = map(int, input().split())\n\nwhile a > 0 and b > 0:\n if a > 2 * b and a > 4 * b:\n a -= ((a // b) // 2) * b\n elif a * 2 < b and a * 4 < b:\n b -= ((b // a) // 2) * a\n elif a >= 2 * b:\n a -= 2 * b\n elif a * 2 <= b:\n b -= 2 * a\n else:\n print(a, b)\n exit()\nprint(a, b)\n"}, {"source_code": "a, b=map(int, input().split())\n#print(a,b)\nif(a>2*b):\n p=a//b\n a=a-b*p\nif(b>2*b):\n p=b//a\n b=b-a*p\n\n#print(p)\n\nwhile(1):\n p=a\n q=b\n \n if a>=2*b:\n a=a-2*b\n elif b>=2*a:\n b=b-2*a\n\n if(a==p and b==q):\n print(a,b)\n break\n\n\n\n\n"}, {"source_code": "#! /usr/bin/python3 -s\n\n\"\"\"\n 1 If a\u2009=\u20090 or b\u2009=\u20090, end the process. Otherwise, go to step 2;\n 2 If a\u2009\u2265\u20092\u00b7b, then set the value of a to a\u2009-\u20092\u00b7b, and repeat step 1. Otherwise, go to step 3;\n 3 If b\u2009\u2265\u20092\u00b7a, then set the value of b to b\u2009-\u20092\u00b7a, and repeat step 1. Otherwise, end the process.\n \n\"\"\"\n\ndef funct_1(a, b):\n if a == 0 or b == 0:\n return [a, b]\n else:\n return funct_2(a,b)\n\ndef funct_2(a, b):\n if a >= 2 * b:\n rest = a % b\n coef = (a - rest) / b\n \n if coef % 2 == 0:\n a = rest\n else:\n a = a - ((coef - 1) * b)\n \n return funct_1(a, b)\n else:\n return funct_3(a, b)\n\ndef funct_3(a, b):\n if b >= 2 * a:\n rest = b % a\n coef = (b - rest) / a\n \n if coef % 2 == 0:\n b = rest\n else:\n b = b - ((coef - 1) * a)\n \n return funct_1(a, b)\n else:\n return [a, b]\n\ndef main():\n [a,b] = [int(x) for x in input(\"\").split()]\n \n if a == 0 or b == 0:\n rpta = funct_1(a, b)\n elif a >= 2 * b:\n rpta = funct_2(a, b)\n elif b >= 2 * a:\n rpta = funct_3(a, b)\n else:\n rpta = [a, b]\n \n print('%d %d' %(rpta[0] , rpta[1]))\n\n\nmain()"}, {"source_code": "m, n = map(int, input().split())\nwhile m != 0 and n != 0:\n if m >= 2 * n:\n m = m % (2*n)\n elif m >= 2 * m:\n n = n % (2*m)\n else:\n break\nprint(m, n)\n\n"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nactivo=True\nwhile activo:\n if(a==0 or b== 0):\n activo=False\n break\n else:\n if (a >= 2 * b):\n a = a - 2 * b\n else:\n if (b >= 2 * a):\n b = b - 2 * a\n else:\n print(\"eee\")\n activo = False\n break\nprint(str(a)+\" \"+str(b))"}], "src_uid": "1f505e430eb930ea2b495ab531274114"} {"source_code": "#!/usr/bin/python\ninp=raw_input().split()\na=int(inp[0])\nb=int(inp[1])\nx1=int(inp[2])\ny1=int(inp[3])\nx2=int(inp[4])\ny2=int(inp[5])\n\nx=(x1-y1)/(2*b)-(x2-y2)/(2*b)\ny=(x1+y1)/(2*a)-(x2+y2)/(2*a)\nx=abs(x)\ny=abs(y)\nprint min(x,y)+abs(x-y)\n", "positive_code": [{"source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().strip().split())\n\nxx1 = [(x1 + y1) / (2 * a)]\nif (x1 + y1) % (2 * a) == 0:\n xx1.append(xx1[0] - 1)\n\nxx2 = [(x2 + y2) / (2 * a)]\nif (x2 + y2) % (2 * a) == 0:\n xx2.append(xx2[0] - 1)\n\nyy1 = [(y1 - x1) / (2 * b)]\nif (y1 - x1) % (2 * b) == 0:\n yy1.append(yy1[0] - 1)\n\nyy2 = [(y2 - x2) / (2 * b)]\nif (y2 - x2) % (2 * b) == 0:\n yy2.append(yy2[0] - 1)\n\nP1 = [(x, y) for x in xx1 for y in yy1]\nP2 = [(x, y) for x in xx2 for y in yy2]\n\nMin = Ellipsis\n\ndef dist(x1, y1, x2, y2):\n f = min(abs(y1 - y2), abs(x1 - x2))\n if x1 < x2:\n x1 += f\n else:\n x2 += f\n if y1 < y2:\n y1 += f\n else:\n y2 += f\n return f + abs(x1 - x2) + abs(y1 - y2)\n\nfor p1 in P1:\n for p2 in P2:\n Min = min(Min, dist(p1[0], p1[1], p2[0], p2[1]))\n\nprint Min\n"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().strip().split())\n\nxx1 = (x1 + y1) / (2 * a)\nxx2 = (x2 + y2) / (2 * a)\nyy1 = (y1 - x1) / (2 * b)\nyy2 = (y2 - x2) / (2 * b)\n\ndef dist(x1, y1, x2, y2):\n f = min(abs(y1 - y2), abs(x1 - x2))\n if x1 < x2:\n x1 += f\n else:\n x2 += f\n if y1 < y2:\n y1 += f\n else:\n y2 += f\n return f + abs(x1 - x2) + abs(y1 - y2)\n\nprint dist(xx1, yy1, xx2, yy2)\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin, stderr\n\ndef rot(x, y):\n return (.5*x - .5*y, .5*x + .5*y)\n\ndef cand(X, Y, A, B):\n P = []\n if X % B == 0:\n if Y % A == 0:\n P.append( (X-1, Y-1) )\n P.append( (X-1, Y+1) )\n P.append( (X+1, Y-1) )\n P.append( (X+1, Y+1) )\n else:\n P.append( (X-1, Y) )\n P.append( (X+1, Y) )\n else:\n if Y % A == 0:\n P.append( (X, Y-1) )\n P.append( (X, Y+1) )\n else:\n P.append( (X, Y) )\n return P\n\ndef dist(p1, p2, A, B):\n print >>stderr, p1, p2\n x1 = p1[0]/B\n y1 = p1[1]/A\n x2 = p2[0]/B\n y2 = p2[1]/A\n dx = abs(x1-x2)\n dy = abs(y1-y2)\n print >>stderr, 'dx: %d dy: %d' % (dx, dy)\n return max(dx, dy)\n\n\na, b, x1, y1, x2, y2 = map(int, stdin.readline().split())\nA = a*2\nB = b*2\n\n(X1, Y1) = rot(x1, y1)\nX1 = int(X1*2)\nY1 = int(Y1*2)\nP1 = cand(X1, Y1, A, B)\n\n(X2, Y2) = rot(x2, y2)\nX2 = int(X2*2)\nY2 = int(Y2*2)\nP2 = cand(X2, Y2, A, B)\n\nres = 1000000000000000000\nfor p1 in P1:\n for p2 in P2:\n res = min(res, dist(p1, p2, A, B))\n\nprint res\n\n"}, {"source_code": "a=map(int,raw_input().split())\ndef c(u,v,d):\n if u>v:u,v=v,u\n d=d<<1\n k=u/d\n return ((v+d-1-k*d)/d-(u+d-1-k*d)/d)\nprint max(c(a[2]+a[3],a[4]+a[5],a[0]),c(a[2]-a[3],a[4]-a[5],a[1]))\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "v=map(int,raw_input().split())\na,b=v[:2]\nx=[v[2],v[4]]\ny=[v[3],v[5]]\nm = abs((x[0]+y[0])/(2*a) - (x[1]+y[1])/(2*a))\nn = abs((x[0]-y[0])/(2*b) - (x[1]-y[1])/(2*b))\nprint max(m,n)\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "def gao (a , b , d) :\n a += 2000000000 * d\n b += 2000000000 * d\n if a > b : a , b = b , a\n return b / d - a / d\na , b , x1 , y1 , x2 , y2 = map (int , raw_input ().split ())\nprint max (gao (x1 + y1 , x2 + y2 , 2 * a) , gao (x1 - y1 , x2 - y2 , 2 * b))"}, {"source_code": "a,b,x1,y1,x2,y2=map(int,raw_input().split())\n\nm=sorted([x1+y1,x2+y2])\nn=sorted([x1-y1,x2-y2])\n\n\na*=2\nb*=2\n\n\nif m[0]>0 and m[0]%a:m[0]+=a-m[0]%a\n\nif m[0]<0:m[0]+=abs(m[0])%a\n\nif m[0]>m[1]:m[0]=m[1]\nelse:\n if m[1]<0 and abs(m[1])%a:m[1]-=a-abs(m[1])%a\n if m[1]>0:m[1]-=m[1]%a\n \n\n\nif n[0]>0 and n[0]%b:n[0]+=b-n[0]%b\nif n[0]<0:n[0]+=abs(n[0])%b\nif n[0]>n[1]:n[0]=n[1]\nelse:\n if n[1]>0:n[1]-=n[1]%b\n if n[1]<0 and abs(n[1])%b:n[1]-=b-abs(n[1])%b\n \n\n \nm1=0 \nn1=0 \nif m[0]==m[1]:\n if abs(m[0])%a:m1=0\n else:\n m1=1\nelse:\n m1+=abs(m[1]-m[0])/a+1\n \n\nif n[0]==n[1]:\n if abs(n[0])%a:n1=0\n else:\n n1=1\nelse:\n n1+=abs(n[1]-n[0])/b+1\n\nprint max(m1,n1)\n\n\n\n\n\n\n\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))"}, {"source_code": "#!/usr/bin/python3\n\ndef cds(a, b, x, y):\n return (x + y) // (2 * a), (x - y) // (2 * b)\n\n\ndef norm(x, y):\n return max(x, y)\n\na, b, x1, y1, x2, y2 = map(int, input().split())\nxp1, yp1 = cds(a, b, x1, y1)\nxp2, yp2 = cds(a, b, x2, y2)\nprint(norm(abs(xp1 - xp2), abs(yp1 - yp2)))\n"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().split())\n\ndef f(c, d):\n return (c/d)\n\naa = f(x1+y1, 2*a)\naaa = f(x2+y2, 2*a)\nans1 = abs(aaa-aa)\nbb = f(x1-y1, 2*b)\nbbb = f(x2-y2, 2*b)\nans2 = abs(bbb - bb)\n\nprint (max(ans1, ans2))"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "def online(x, y):\n return (abs(x + y)) % (2 * a) == 0 or (abs(x - y) % (2 * b) == 0)\n\ndef solve(x1, y1, x2, y2):\n if (not online(x1, y1)) and (not online(x2, y2)):\n px1, py1, px2, py2 = (x1+y1) / (2*a), (x1-y1) / (2*b), (x2+y2)/(2*a), (x2-y2)/(2*b)\n dx, dy = abs(px2-px1), abs(py2-py1)\n return dx + dy - min(dx, dy)\n else:\n if online(x2, y2):\n return min(solve(x1, y1, x2+1, y2), solve(x1, y1, x2-1, y2), solve(x1, y1, x2, y2-1), solve(x1, y1, x2, y2+1))+1\n return min(solve(x1-1, y1, x2, y2), solve(x1+1, y1, x2, y2), solve(x1, y1+1, x2, y2), solve(x1, y1-1, x2, y2))+1\n\na, b, x1, y1, x2, y2 = map(int, raw_input().split())\nprint solve(x1, y1, x2, y2)"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().split())\ndef trans(x, y):\n\tu, v = x + y, x - y\n\treturn u/(2*a), v/(2*b)\ni1, j1 = trans(x1, y1)\ni2, j2 = trans(x2, y2)\n# print i1,j1\n# print i2,j2\ndi, dj = abs(i1-i2), abs(j1-j2)\n\nprint max(di, dj)\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\n\na1 = (x1+y1) / (2*a)\n\na2 = (x2+y2) / (2*a)\n\nb1 = (x1-y1) / (2*b)\n\nb2 = (x2-y2) / (2*b)\n\nprint max(abs(a1-a2), abs(b1-b2))\n\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "v=map(int,raw_input().split())\na,b=v[:2]\nx=[v[2],v[4]]\ny=[v[3],v[5]]\nm = abs((x[0]+y[0])/(2*a) - (x[1]+y[1])/(2*a))\nn = abs((x[0]-y[0])/(2*b) - (x[1]-y[1])/(2*b))\nprint max(m,n)\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int,input().split())\n\na1 = x1+y1\na2 = x2+y2\n\nb1 = x1-y1\nb2 = x2-y2\n\nad = a2//(2*a) - a1//(2*a)\nbd = b2//(2*b) - b1//(2*b)\n\nprint(max(abs(ad),abs(bd)))\n"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, input().split())\nX1, Y1 = x1 + y1, x1 - y1\nX2, Y2 = x2 + y2, x2 - y2\nA, B = 2 * a, 2 * b\n\n\ndef solve(x, y, z):\n if x >= 0 > y or x < 0 <= y:\n x = max(x, -x)\n y = max(y, -y)\n tmp = x // z + y // z + 1\n return tmp\n else:\n if x < y:\n x, y = y, x\n tmp = x // z - y // z\n return tmp\n\n\nans1 = solve(X1, X2, A)\nans2 = solve(Y1, Y2, B)\n\nprint(max(ans1, ans2))\n"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, input().split())\nX1, Y1 = x1 + y1, x1 - y1\nX2, Y2 = x2 + y2, x2 - y2\nA, B = 2 * a, 2 * b\n\n\ndef solve(x, y, z):\n if x >= 0 > y or x < 0 <= y:\n x = max(x, -x)\n y = max(y, -y)\n tmp = x // z - (x % z == 0) + y // z - (y % z == 0) + 1\n return tmp\n else:\n if x < y:\n x, y = y, x\n tmp = x // z - (x % z == 0) - y // z - (y % z == 0)\n return tmp\n\n\nans1 = solve(X1, X2, A)\nans2 = solve(Y1, Y2, B)\n\nprint(max(ans1, ans2))\n"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int,input().split())\ns = abs((x1 + y1) // (2 * a) - (x2 + y2) // (2 * a))\ns = max(s,abs((x1 - y1) // (2 * b) - (x2 - y2) // (2 * b)))\nprint(s)"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().split())\n\ndef f(c, d):\n if c >= 0:\n return ((c/d))\n return (c/d)\n\naa = f(x1+y1, 2*a)\naaa = f(x2+y2, 2*a)\nans1 = abs(aaa-aa)\nbb = f(x1-y1, 2*b)\nbbb = f(x2-y2, 2*b)\nans2 = abs(bbb - bb)\n\nprint (max(ans1, ans2))\n\n"}, {"source_code": "#!py2\n\ndef solve(A, B, x1, y1, x2, y2):\n A *= 2\n B *= 2\n\n da = abs((x1 + y1) / A - (x2 + y2) / A)\n db = abs((x1 - y1) / B - (x2 - y2) / B)\n return max(da, db)\n \nprint solve(*map(int, raw_input().split()))\n"}, {"source_code": "\na, b, x_1, y_1, x_2, y_2 = map(int, input().split())\n\na_b, a_e = (x_2 + y_2), (x_1 + y_1)\nb_b, b_e = (x_2 - y_2), (x_1 - y_1)\n\nif a_b > a_e:\n a_b, a_e = a_e, a_b\n\nif b_b > b_e:\n b_b, b_e = b_e, b_b\n\n\nif a_b % (2 * a) != 0:\n a_b = (a_b // (2 * a) + 1) * (2 * a)\n\na_result, b_result = 0, 0\n\nif a_b <= a_e:\n a_result = (abs(a_e - a_b) + (2 * a - 1)) // (2 * a)\n\nif b_b % (2 * b) != 0:\n b_b = (b_b // (2 * b) + 1) * (2 * b)\n\nif b_b <= b_e:\n b_result = (abs(b_e - b_b) + (2 * b - 1)) // (2 * b)\n\nprint(max([a_result, b_result]))\n\n\n"}, {"source_code": "\ndraf=raw_input().split()\na,b,x1,y1,x2,y2 = [int(i) for i in draf]\nxx1 = (x1 + y1)/(2*a)\nyy1 = (x1 - y1)/(2*b)\nxx2 = (x2 + y2)/(2*a)\nyy2 = (x2 - y2)/(2*b)\nt1 = abs(xx2 - xx1)\nt2 = abs(yy2 - yy1)\nprint max(t1,t2)"}], "negative_code": [{"source_code": "def gao (a , b , d) :\n a += 2000000000 * d\n b += 2000000000 * d\n if a > b : a , b = b , a\n return b / d - a / d\na , b , x1 , y1 , x2 , y2 = map (int , raw_input ().split ())\nprint gao (x1 + y1 , x2 + y2 , 2 * a) + gao (x1 - y1 , x2 - y2 , 2 * b)"}, {"source_code": "#!/usr/bin/python\ninp=raw_input().split()\na=int(inp[0])\nb=int(inp[1])\nx1=int(inp[2])\ny1=int(inp[3])\nx2=int(inp[4])\ny2=int(inp[5])\n\nx=(x1-y1)/(2*a)-(x2-y2)/(2*a)\ny=(x1+y1)/(2*b)-(x2+y2)/(2*b)\nx=abs(x)\ny=abs(y)\nprint min(x,y)+abs(x-y)\n"}, {"source_code": "def online(x, y):\n return (abs(x + y)) % (2 * a) == 0 or (abs(x - y) % (2 * b) == 0)\n\ndef solve(x1, y1, x2, y2):\n if (not online(x1, y1)) and (not online(x2, y2)):\n px1, py1, px2, py2 = x1 / a, y1 / b, x2 / a, y2 / b\n dx, dy = abs(px2-px1), abs(py2-py1)\n return dx + dy - min(dx, dy)\n else:\n if online(x2, y2):\n return min(solve(x1, y1, x2+1, y2), solve(x1, y1, x2-1, y2), solve(x1, y1, x2, y2-1), solve(x1, y1, x2, y2+1))+1\n return min(solve(x1-1, y1, x2, y2), solve(x1+1, y1, x2, y2), solve(x1, y1+1, x2, y2), solve(x1, y1-1, x2, y2))+1\n\na, b, x1, y1, x2, y2 = map(int, raw_input().split())\nprint solve(x1, y1, x2, y2)"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int,input().split())\ns = (x1 + y1) // (2 * a) - (x2 + y2) // (2 * a)\ns = max(s,(x1 - y1) // (2 * b) - (x2 - y2) // (2 * b))\nprint(s)"}, {"source_code": "a,b,x1,y1,x2,y2 = map(int,input().split())\ns = (x1 + y1) // (2 * a) - (x2 + y2) // (2 * a)\ns += (x1 - y1) // (2 * b) - (x2 - y2) // (2 * b)\nprint(s)"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().split())\ndef trans(x, y):\n\tu, v = x + y, x - y\n\treturn u/(2*a), v/(2*b)\ni1, j1 = trans(x1, y1)\ni2, j2 = trans(x2, y2)\n# print i1,j1\n# print i2,j2\ndi, dj = abs(i1-i2), abs(j1-j2)\n\nans = di + dj\nif di and dj:\n\tans -= 1\nprint ans\n"}, {"source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().split())\ndef trans(x, y):\n\tu, v = x + y, x - y\n\treturn u/(2*a), v/(2*b)\ni1, j1 = trans(x1, y1)\ni2, j2 = trans(x2, y2)\ndi, dj = abs(i1-i2), abs(j1-j2)\n\nans = di + dj - int(di and dj)\nprint ans\n"}, {"source_code": "\na, b, x_1, y_1, x_2, y_2 = map(int, input().split())\n\nprint(max([(abs((x_2 + y_2) - (x_1 + y_1)) + (2 * a - 1)) // (2 * a),\n (abs((x_2 - y_2) - (x_1 - y_2)) + (2 * b - 1)) // (2 * b)]))\n\n"}, {"source_code": "\na, b, x_1, y_1, x_2, y_2 = map(int, input().split())\n\nprint(max([abs((x_2 + y_2) - (x_1 + y_1)) // (2 * a),\n abs((x_2 - y_2) - (x_1 - y_2)) // (2 * b)]))\n\n"}], "src_uid": "7219d1837c83b5920992aee5a60dc0d9"} {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\ns = max(n * m - k, 0)\nres = 0\nwhile s:\n if c > min(s, n) * d:\n res += min(s,n) * d\n else:\n res += c\n s -= min(s,n)\nprint(res)\n", "positive_code": [{"source_code": "c,d = [int(x) for x in raw_input().split()]\nn,m = [int(x) for x in raw_input().split()]\nk = int(raw_input())\n\nans = 0\ntotal = n*m - k; \ntotal = 0 if (total < 0) else total\n\nfac = total/n\nans = min(fac*c + (total - fac*n)*d,(fac+1)*c)\nans = min(ans,total*d)\n\nprint ans"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nproblems = 0\npeople = n * m - k\n\nwhile people > 0:\n if (d < float(c) / n) or (d < float(c) / people):\n people -= 1\n problems += d\n else:\n people -= n\n problems += c\nprint problems\n"}, {"source_code": "# Author: Gilberto A. dos Santos\n# Website: http://codeforces.com/contest/417/problem/0\n\nc, d = map(int, raw_input().split(\" \"))\nn, m = map(int, raw_input().split(\" \"))\nk = int(raw_input())\n\nneeded = (n * m) - k\n\nnumberOfProblems = 0\nwhile needed > 0:\n if needed >= n:\n costAdd = d * n\n numberOfProblems += costAdd if costAdd < c else c\n needed -= n\n else:\n costAdd = d * needed\n numberOfProblems += costAdd if costAdd < c else c\n needed -= n\n\nprint numberOfProblems\n"}, {"source_code": "c,d = map(int,raw_input().split())\nn,m = map(int,raw_input().split())\nk = int(raw_input())\nneed = m * n - k\nmain_need = c/float(n)\nadd_need = d\nif need <= 0 :\n\tprint 0\nelse :\n\tif add_need <= main_need :\n\t\tprint add_need * need\n\telse :\n\t\ts = c * ( need / n )\n\t\tlast_need = need % n\n\t\tif c <= add_need * last_need :\n\t\t\tprint s + c\n\t\telse :\n\t\t\tprint s + add_need * last_need\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\t[c,d] = map(int,sys.stdin.readline().split())\n\t[n,m] = map(int,sys.stdin.readline().split())\n\tk = int(raw_input())\n\tminimum = n*m - k\n\tif minimum <= 0:\n\t\tprint 0\n\telse:\n\t\tone = minimum / n * c + (c if minimum % n != 0 else 0)\n\t\ttwo = minimum / n * c + minimum % n * d\n\t\tthree = minimum * d\n\t\tprint min(one,two,three)\n\n\t\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nres = m * c\np = n * m - k\n\nfor i in range(m+1):\n\tfor j in range(n * m + 1):\n\t\tif i * n + j >= p: res = min(res, c * i + d * j)\n\t\t\nprint res\n"}, {"source_code": "# coding=utf-8\n'''\nhttp://codeforces.ru/contest/417/problem/A\n\nA. \u041e\u0442\u0431\u043e\u0440\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442 256 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\n\u0432\u0432\u043e\u0434 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u0432\u043e\u0434\n\u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\n\u0424\u0438\u043d\u0430\u043b\u0438\u0441\u0442\u0430\u043c\u0438 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u00abRussian Code Cup\u00bb \u0432 2214 \u0433\u043e\u0434\u0443 \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438, \u0441\u0442\u0430\u0432\u0448\u0438\u0435 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432.\n\n\u041e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0435 \u0440\u0430\u0443\u043d\u0434\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 c \u0437\u0430\u0434\u0430\u0447, \u0430 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0440\u0430\u0443\u043d\u0434\u0430 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f n \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0437\u0430\u043d\u044f\u0432\u0448\u0438\u0435 \u043f\u0435\u0440\u0432\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432 \u044d\u0442\u043e\u043c \u0440\u0430\u0443\u043d\u0434\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 d \u0437\u0430\u0434\u0430\u0447. \u041f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0443\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u043d\u0430 \u0444\u0438\u043d\u0430\u043b \u0431\u0435\u0437 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e\u0442\u0441\u044f k \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u0444\u0438\u043d\u0430\u043b\u043e\u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u043b\u0435\u0442.\n\n\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u0435\u0445 \u043e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0432 \u0444\u0438\u043d\u0430\u043b \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 n*m \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0435 \u0440\u0430\u0443\u043d\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u0435\u0445 \u043e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0432 \u0444\u0438\u043d\u0430\u043b \u043f\u0440\u043e\u0448\u043b\u0438 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 n\u00b7m \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0430 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u0443\u043d\u0434\u0430\u0445 \u0437\u0430\u0434\u0430\u0447 \u0431\u044b\u043b\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435?\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 c \u0438 d (1<=c,d<=100) \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0443\u043d\u0434\u0430\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 n \u0438 m (1<=n,m<=100). \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e k (1<=k<=100) \u2014 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439.\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0447\u043b\u0435\u043d\u0430\u043c \u0436\u044e\u0440\u0438.\n'''\n\nfrom __future__ import division\nimport math\n\nc, d = map(lambda x: int(x), raw_input().split())\nn, m = map(lambda x: int(x), raw_input().split())\nk = int(raw_input())\n\n# \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0438\u043d\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u0438\u0437 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u043e\u0442\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\np = n*m - k\n\nif p > 0:\t\n\tres = -1\n\t# \u0446\u0438\u043a\u043b \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\n\tfor i in range(int(math.ceil(p/n)) + 1):\n\t\t# \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\n\t\tj = p - n*i\n\t\tif j < 0:\n\t\t\tj = 0\n\t\t# \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438 i \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438 j \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u0430\u0445\n\t\tz = c*i + d*j\n\t\t#print i, j, z\n\t\tif res < 0 or z < res:\n\t\t\tres = z\nelse:\n\tres = 0\n\t\nprint res"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nneeded = n * m - k\n\nif needed <= 0:\n\tprint 0\nelse:\n\tprint min((needed / n + 1) * c, (needed / n) * c + (needed % n) * d, needed * d)\n\t\t\n\n\n\n"}, {"source_code": "import sys\nl=[]\nfor i in sys.stdin:\n l+=[int(k) for k in i.rstrip().split()]\n\n\nc,d,n,m,k=l[0],l[1],l[2],l[3],l[4]\n\nif n*m<=k:\n print 0\nelse:\n v=[d*i for i in range(n*m-k+1)] #quest\n \n for i in range(n,len(v)):\n v[i]=min([v[i-n]+c,v[i-1]+d])\n\n for i in range(n):\n if len(v)-i-1<0:\n break\n v[-1]=min([v[-1-i]+c,v[-1]])\n print v[-1]\n\n"}, {"source_code": "c, d = map(int, raw_input().split(\" \"))\nn, m = map(int, raw_input().split(\" \"))\nk = input()\nt = (n * m) - k\nif t < 1:\n print 0\nelse:\n p = []\n a = t/n\n if t % n != 0:\n p.append((a * c) + (d * (t % n)))\n a += 1\n p.append(a*c)\n p.append(d*t)\n print min(p)"}, {"source_code": "c,d = [int(x) for x in raw_input().split()]\nn,m = [int(x) for x in raw_input().split()]\nk = int(raw_input())\nprobs = 0\ngo = d\nadd = 1\nif float(c)/n < float(d):\n go = c\n add = n\n \nwhile 1:\n \n if k >= m*n:\n break\n if k + 1 == m*n:\n probs += min(c,d)\n break\n elif k + n >= m*n:\n probs += min(c, (m*n - k)*d)\n break\n else:\n k+=add\n probs+=go\nprint probs"}, {"source_code": "memo=[]\n\ndef go(tot,n,c,d):\n if tot<=0:\n return 0\n elif memo[tot]<1000000007:\n return memo[tot]\n else:\n memo[tot]=min(go(tot-n,n,c,d)+c,go(tot-1,n,c,d)+d)\n return memo[tot]\n\n\nc,d=raw_input().split()\nn,m=raw_input().split()\nk=raw_input()\n\nc=int(c)\nd=int(d)\nn=int(n)\nm=int(m)\nk=int(k)\n\ntot=n*m-k\nfor i in range(0,tot+1):\n memo.append(1000000007)\n\nans=go(tot,n,c,d)\nprint ans\n\n\n\n"}, {"source_code": "c,d=[int(x) for x in raw_input().split()]\nn,m=[int(x) for x in raw_input().split()]\nk=int(raw_input())\nans=min((n*m-k+n-1)/n*c,(n*m-k)/n*c+(n*m-k)%n*d,(n*m-k)*d) \nprint ans if ans>=0 else 0"}, {"source_code": "from math import ceil\nc,d=map(int,raw_input().split())\nn,m=map(int,raw_input().split())\nans=10**10\nk=int(input())\nfor i in range(0,m+2):\n j=n*m-k-(i*n)\n if j>0:\n ans=min(i*c+j*d,ans)\n else:\n ans=min(i*c,ans)\nprint ans"}, {"source_code": "\nc,d = map(int,raw_input().strip().split())\nn,m = map(int,raw_input().strip().split())\nk = int(raw_input())\n\n##c = 100\n##d = 1\n##n = 2\n##m = 3\n##k = 1\n\ntask_count = 0\nrounds_c = 0\nrounds_d = 0\nminamount = n*m-k\nif (minamount <= 0):\n task_count = 0\nelse:\n cost_c = float(n*1.0/c)\n cost_d = float(1*1.0/d)\n if cost_c>cost_d:\n ost = minamount % n\n if ost == 0:\n task_count = (minamount / n)*c\n else:\n rounds_c = minamount / n\n task_count = rounds_c * c\n if ost*d > c:\n task_count += c\n else:\n task_count += ost*d\n else:\n task_count = (minamount / 1)*d\n \nprint task_count\n \n\n"}, {"source_code": "num = raw_input().strip().split(\" \")\nc, d = int(num[0]), int(num[1])\nnum = raw_input().strip().split(\" \")\nn, m = int(num[0]), int(num[1])\nk = int(raw_input())\ntotal = n * m\nneed = total - k\nprob = 0\nwhile need > 0:\n if n <= need:\n if c < d * n:\n need -= n\n prob += c\n else:\n need -= 1\n prob += d\n else:\n if c < d * need:\n prob += c\n else:\n prob += d * need\n need = 0\nprint prob"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nproblems = 0\npeople = n * m - k\n\nwhile people > 0:\n if (d < float(c) / n) or (d < float(c) / people):\n people -= 1\n problems += d\n else:\n people -= n\n problems += c\nprint problems\n\n"}, {"source_code": "############################# MAIN\nc, d = map( int, raw_input().split() )\nn, m = map( int, raw_input().split() )\nk = int( raw_input() )\nosn = c / n\nneeded = m*n - k\nif needed <= 0:\n print 0\nelif osn >= d:\n print needed*d\nelse:\n osnrounds = needed / n\n needed = needed % n\n if d*needed < c: \n print osnrounds*c + d*needed\n else:\n print (osnrounds+1)*c\n "}, {"source_code": "\nc,d = [int(item) for item in raw_input().split(' ')]\nn,m = [int(item) for item in raw_input().split(' ')]\nk = int(raw_input())\nfor i in range(0, m + 1):\n x = i\n if x * n + k >= m * n:\n y = 0\n else:\n y = m * n - k - n * x\n ans = c * x + d * y\n if i == 0:\n mx = ans\n continue\n mx = ans if mx > ans else mx\nprint mx\n"}, {"source_code": "c, d = map ( int, raw_input ( ).split ( ) )\nn, m = map ( int, raw_input ( ).split ( ) )\nk = int(raw_input ( ) )\n\nrem = n*m - k\nminAns = 1e10\n\nfor i in range(10000):\n for j in range(10000):\n if ( i * n + j >= rem ):\n if ( minAns > i * c + j * d):\n minAns = i * c + j * d\n break\n\nprint minAns\n \n"}, {"source_code": "c,d = raw_input().split()\nn,m = raw_input().split()\nc,d = int(c), int(d)\nn,m = int(n), int(m)\nk = int(raw_input())\n\noutp = 1000000000\n\nfor i in range(1000000):\n\tif((n*m-k-n*i)<0):\n\t\toutp=min(outp,c*i)\n\telse:\n\t\toutp=min(outp,(n*m-k-n*i)*d+i*c)\n\nprint outp\n"}, {"source_code": "c,d = list(map(int,input().split()))\nn,m = list(map(int,input().split()))\nk = int(input())\nt = max((m*n)-k,0)\np = min(c,n*d)\nans = p*(t//n)\nrem = t%n\nans = ans+min(c,rem*d)\nprint(ans)"}, {"source_code": "import sys\n\nc, d = map(int, sys.stdin.readline().split())\nn, m = map(int, sys.stdin.readline().split())\nk = int(sys.stdin.readline())\n\ntotal = n * m - k\nif total <= 0:\n print(0)\n sys.exit(0)\n\na = [d*i for i in range(0, total+1)]\n\nfor i in range(1, total+1):\n if i <= n:\n if a[i] > c:\n a[i] = c\n else:\n if a[i-n] + c < a[i]:\n a[i] = a[i-n] + c\n\nprint( a[total] )"}, {"source_code": "input = raw_input\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\ns = n*m - k\nres = 0\n\nif s > 0:\n if (c/n) > d:\n res += d*s\n else:\n os = s - (s // n) * n\n res += (s // n) * c\n if c < d*os:\n res += c\n else:\n res += d*os\n\nprint( res )"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=(n*m)-k\nmi=100000000\nfor i in range(req/n + n):\n for j in range(req+3):\n if n*i+j >=req:\n if c*i+j*d<mi:\n mi=i*c+j*d\nif mi==100000000:\n mi=0\nprint mi\n"}, {"source_code": "import math\nc,d=map(int,input('').split())\nn,m=map(int,input('').split())\nk=int(input(''))\nif n*m-k<0:\n print('0')\n exit()\nif 1/d>n/c: print((n*m-k)*d)\nelse:\n if (math.ceil((n*m-k)/n)*c)<((n*m-k)//n)*c+((n*m-k)%n)*d: print (math.ceil((n*m-k)/n)*c)\n else: print(((n*m-k)//n)*c+((n*m-k)%n)*d)\n\n\n\n\n\n\n\n \n \n \n \n \n\n\n \n\n"}, {"source_code": "problems = input().split()\nc = int(problems[0])\nd = int(problems[1])\nn_m = input().split()\nn = int(n_m[0])\nm = int(n_m[1])\nk = int(input())\n\nt = n * m - k # \u043d\u0443\u0436\u043d\u043e\u0435 \u0432\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439, \u043a\u0440\u043e\u043c\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445\nans = 100000000 # \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447\ni = 0\nwhile i*n <= t: # \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0440\u0430\u0443\u043d\u0434\u0430\u043c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430\u0434\u043e\n ans = min(ans, (t - i*n) * d + i*c)\n i += 1\nans = min(ans, i*c)\nprint(ans)\n\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=(n*m)-k\nif req<0:\n req=0\nmi=100000000\nfor i in range(req/n + n):\n for j in range(req+3):\n if n*i+j >=req:\n if c*i+j*d<mi:\n mi=i*c+j*d\nprint mi\n"}, {"source_code": "#import sys\n#sys.stdin = open('input.txt','r')\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nL = 10001\nfor f in range(m + 1):\n\tfor g in range(n * m + 1):\n\t\tif f * n + g + k >= n * m:\n\t\t\tL = min(L, f * c + g * d)\nprint(L)"}, {"source_code": "from math import ceil\n\nc, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = input()\n\ndef f(c, d, n, m, k):\n p = n*m - k\n if p <= 0: return 0\n #print p, d, n\n a = (\n p * d,\n int(ceil(float(p)/n)) * c,\n (p/n) * c + (p%n) * d\n )\n #print a\n return min(a)\nprint f(c, d, n, m, k)\n"}, {"source_code": "[c, d], [n, m], k = map(int, input().split()), map(int, input().split()), int(input())\nleft = n * m - k\nif left <= 0:\n print(0)\nelse:\n print(min(left // n * c + left % n * d, (left + n - 1) // n * c, left * d))"}, {"source_code": "c,d=map(int,input().split())\n\nn,m=map(int,input().split())\n\nk=int(input())\n\nz=0\nbest=10**10\nwhile(1):\n x=n*m-k\n x-=z*n\n best=min(best,z*c+(max(x,0)*d))\n if(x<0):\n break\n z+=1\nprint(best)\n \n"}, {"source_code": "vals = [int(x) for x in raw_input().split()]\na=vals[0]\nb=vals[1]\nvals = [int(x) for x in raw_input().split()]\nn=vals[0]\nm=vals[1]\nk=input()\n\nt=n*m-k\nr=0\n\nwhile t>0:\n if a<min(n,t)*b:\n t-=n\n r+=a\n else:\n t-=1\n r+=b\n\nprint(r)\n"}, {"source_code": "'''\nCreated on Apr 17, 2014\n\n@author: Arjun\n'''\nstuff = raw_input()\nstuff2 = raw_input()\nautoAdvance = int(raw_input())\nlista = stuff.split()\nlistb = stuff2.split()\nmainRound = int(lista[0])\nextraRound = int(lista[1])\nmainAdvance = int(listb[0])\nm = int(listb[1])\nneedAdvance = mainAdvance*m-autoAdvance\nval = 0\nif(needAdvance%mainAdvance == 0):\n divisor = needAdvance/mainAdvance\nelse:\n divisor = needAdvance/mainAdvance + 1\n\nif(needAdvance<=0):\n print 0\nelif(mainRound < extraRound):\n print mainRound*divisor\nelse:\n all2 = extraRound*needAdvance\n all1 = mainRound*divisor\n blah = (needAdvance/mainAdvance)*mainRound + (needAdvance - (needAdvance/mainAdvance)*mainAdvance)*extraRound\n print min(all1,all2,blah)\n\n\n"}, {"source_code": "c,d = list(map(int, input().split(\" \")))\nn, m = list(map(int, input().split(\" \")))\nk = int(input())\nmini = n*m-k\nif mini < 1:\n\tprint(0)\nelif d * n <= c: # easier one at a time\n\tprint(d*mini)\nelse:\n\ttotal = (mini // n) * c\n\tmini = mini % n\n\ttotal += min(c, d*mini)\n\tprint(total)"}, {"source_code": "c, d = map(int, raw_input().split(\" \"))\nn, m = map(int, raw_input().split(\" \"))\nk = int(raw_input())\n\nmn = 10**9\n\nall = n * m - k\nif(all <= 0):\n\tmn = 0\n\nfor x in range(0, 1000):\n\ty = all - x * n\n\tcur = x * c\n\tif(y > 0):\n\t\tcur += y * d\n\tmn = min(mn, cur)\nprint(mn)"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\nall = n * m - k\nif(all <= 0): print 0\nelse: print min((all/n + 1) * c, (all / n) * c + (all % n) * d, all * d)"}, {"source_code": "c,d=[int(x) for x in raw_input().split()]\nn,m=[int(x) for x in raw_input().split()]\nk=int(raw_input())\nans=min((n*m-k+n-1)/n*c,(n*m-k)/n*c+(n*m-k)%n*d,(n*m-k)*d) \nprint ans if ans>=0 else 0\n"}, {"source_code": "\n\n#c,d,n,m,k=map(int,input().split())\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\n# c \u0438 d (1\u2009\u2264\u2009c,\u2009d\u2009\u2264\u2009100) \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0443\u043d\u0434\u0430\u0445 \n# n \u0438 m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100) n \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n# k (1\u2009\u2264\u2009k\u2009\u2264\u2009100) \u2014 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n\nS = 0\nif n*m>k : \n nub = n*m-k\n S = 100000000000\n S0 = S\n i=0\n while S0<=S and i<=int(nub/n+2):\n S = S0 \n S0 = i*c + d*max(0, nub-n*i)\n #print(i,S,S0)\n i += 1\n\nprint(S)\n\n\n"}, {"source_code": "#!/usr/bin/env python\n\nimport sys\nimport logging\n\nc, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = input()\n\nt = n * m - k\n\ncandidates = []\n\ncandidates += [c * (t / n + (1 if t%n != 0 else 0))]\ncandidates += [d * t]\n\ncandidates += [c * (t/n) + (t - n*(t/n)) * d]\n\nprint max(0, min(candidates))\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\ntotal = n * m - k\nif k >= n * m:\n print(0)\nelif c < d:\n if total % n == 0:\n print(((total // n)) * c)\n else:\n print(((total // n) + 1) * c)\nelse:\n nr = 0\n nn = (c / n)\n nm = d\n if nn < nm:\n #while (nr * n) + n < total:\n # nr += 1\n nr = total // n\n npn = nr * c\n if nr * n < total:\n npn = (nr + 1) * c\n npm = nr * c + d * (total - nr * n)\n print(min(npn, npm))\n else:\n print(d * total)\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nx = n * m - k\ncase = 0\n\nwhile x > 0:\n if n <= x:\n if c < d * n:\n x -= n\n case += c\n else:\n x -= 1\n case += d\n else:\n if c < d * x:\n case += c\n else:\n case += d * x\n x = 0\n\nprint case\n"}, {"source_code": "[c, d], [n, m], k = map(int, input().split()), map(int, input().split()), int(input())\nleft = n * m - k\nif left <= 0:\n print(0)\nelse:\n print(min(left // n * c + left % n * d, (left + n - 1) // n * c, left * d))\n"}, {"source_code": "c, d = map(int, input().split(' '))\nn, m = map(int, input().split(' '))\nk = int(input())\ndp = [0] * 100000\nneed = n*m - k\n\nif need <= 0:\n print(0)\n quit()\n\n\nfor i in range(1, 100000):\n dp[i] = min(dp[i-n]+c, dp[i-1]+d)\n\nprint(dp[need])\n"}, {"source_code": "import math\nx=raw_input().split(' ')\nc=int(x[0])\nd=int(x[1])\ny=raw_input().split(' ')\nn=int(y[0])\nm=int(y[1])\npro=n*m\nk=input()\npro=pro-k\nif pro>0:\n if c<=d:\n ans=int(math.ceil(float(pro)/n))*c\n else:\n if float(n)/c>=float(1)/d:\n if pro%n==0:\n ans=(pro/n)*c\n else:\n ans=int(math.floor(float(pro)/n))*c\n am=pro%n\n if c<=am*d:\n ans=ans+c\n else:\n ans=ans+am*d\n else:\n ans=pro*d\n print ans\nelse:\n print \"0\"\n"}, {"source_code": "c, d = list(map(int, input().split()))\nn, m = list(map(int, input().split()))\nf = n * m\nk = int(input())\nresult = 0\nuch = k\n\nuseosn = usedop = 0\n\nwhile uch < f:\n if f-uch >= n:\n if c/n < d:\n result += c\n uch += n\n else:\n result += d\n uch += 1\n else:\n if c > (d*(f-uch)):\n while uch < f:\n result += d\n uch += 1\n else:\n result += c\n uch += n\n\nprint(max(0, result))\n\n\n\n"}, {"source_code": "import sys, re\n\nf = sys.stdin\n\nc, d = map(int, f.readline().strip().split())\nn, m = map(int, f.readline().strip().split())\nk = int(f.readline().strip().split()[0])\n\nneed = n * m - k\n\nif need <= 0:\n print 0\n exit(0)\n\nresult = sys.maxint\nfor x in xrange(need + 1):\n for y in xrange(need + 1):\n if x * n + y >= need:\n result = min(x * c + y * d, result)\n if x * n >= need:\n break\n\nprint result \n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\np = 0\nk = int(input())\nif m*n <= k:\n print(0)\nelse:\n a = [0]*(m*n+1)\n #a[k+1] = min(c,d)\n for i in range(k+1,m*n+1):\n a[i] = min(a[i-n]+c, a[i-1]+d)\n print(a[m*n])"}, {"source_code": "import math\nmainProblems, additionalProblems = map(int, raw_input().split())\nratingListCount, m = map(int, raw_input().split())\nprevWinners = int(raw_input())\n\ntotalPeople = ratingListCount * m\n\nif prevWinners >= totalPeople:\n print 0\n exit()\n\nrequiredPeople = totalPeople - prevWinners\nproblemCount = 0\n\nwhile requiredPeople > 0:\n if ratingListCount > requiredPeople:\n problemCount += min(mainProblems, requiredPeople * additionalProblems)\n requiredPeople = 0\n else:\n requiredPeople -= ratingListCount\n problemCount += min(mainProblems, ratingListCount * additionalProblems)\n\nprint problemCount\n"}, {"source_code": "c, d = list(map(int, input().split()))\nn, m = list(map(int, input().split()))\nk = int(input())\nkolvo = m * n - k\nif kolvo < 0:\n\tprint(0)\n\texit()\nprint(min(c * (kolvo // n), d * n * (kolvo // n)) + min(c, d * (kolvo % n)))\n\n"}, {"source_code": "def debug():\n c,d=map(int,raw_input().split())\n n,m=map(int,raw_input().split())\n k=input()\n final=n*m\n need=final-k\n if need<=0:\n print 0\n else:\n fp1=c/float(n)\n fp2=d\n if fp1<fp2:\n timu=(need/n)* c\n rest= need- (need/n)*n\n if rest:\n if rest*d > c:\n print timu+c\n else:\n print timu+rest*d \n else:\n print timu\n else:\n print need*d\n\ndebug()"}, {"source_code": "def f(x, y): return x * c + y * d\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = n * m - int(input())\nx, s = 0, max(0, k * d)\nwhile k > x * n:\n t = f(x, k - x * n)\n if t < s: s = t\n x += 1\nprint(min(s, f(x, 0)))"}, {"source_code": "# Made By Mostafa_Khaled \nbot = True \nc, d = list(map(int, input().split()))\nn, m = list(map(int, input().split()))\nk = int(input())\nkolvo = m * n - k\nif kolvo < 0:\n\tprint(0)\n\texit()\nprint(min(c * (kolvo // n), d * n * (kolvo // n)) + min(c, d * (kolvo % n)))\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "x=raw_input().split()\ny=raw_input().split()\nz=raw_input().split()\nc=int(x[0])\nd=int(x[1])\nn=int(y[0])\nm=int(y[1])\nk=int(z[0])\nif k>=m*n:\n print 0\nelif d>c/n:\n rou=(m*n-k)/n\n if k%n==0:\n s=rou*c\n print s\n else:\n s=(rou)*c+((m*n-k)%n)*d\n x=(rou+1)*c\n print min(s,x)\n \nelse:\n s=(m*n-k)*d\n print s"}, {"source_code": "#Codeforces problem 417A: Elimination\n\ndef roof(n,p):\n\tr = p // n\n\tif p%n > 0:\n\t\tr = r + 1\n\treturn r\n\nc,d = (int(element) for element in input().split())\n\nn,m = (int(element) for element in input().split())\n\nk = int(input())\n\nneeded_number_of_problems = 0\n\n#people still needed for the 2214 Russian Code Cup\"\np = m*n - k\n\nwhile p > 0:\n\tx = roof(n,p)\n\tif d*p < c*x:\n\t\t#get people from the additional rounds\n\t\tneeded_number_of_problems += d\n\t\tp = p - 1\n\telse:\n\t\t#get people from main round\n\t\tneeded_number_of_problems += c\n\t\tp = p - n\n\nprint(needed_number_of_problems)"}, {"source_code": "c,d = [int(x) for x in input().strip().split()]\nn,m = [int(x) for x in input().strip().split()]\nk = int(input().strip())\n\nt = n*m-k\nif t<=0:\n print(0)\nelse:\n dp = [0]*(t+1)\n for i in range(1,t+1):\n dp[i]=min(dp[i-1]+d, c+dp[max(0,i-n)])\n print(dp[t])"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nc, d = readln()\nn, m = readln()\nk, = readln()\n\nans = 1 << 30\nfor x in range(10001):\n y = max(0, n * m - k - n * x)\n if y >= 0 and ans > c * x + d * y:\n ans = c * x + d * y\nprint(ans)"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nneed = n*m - k\nif need <= 0:\n print(0)\nelse:\n r1 = c / n\n if r1 < d:\n div, rest = divmod(need, n)\n cont = div * c\n cont += min(c, d*rest)\n print(max(0,cont))\n else:\n print(need*d)\n"}, {"source_code": "c,d = map(int,input().split())\nn,m = map(int,input().split())\nk = int(input())\nx = n*m\nfrom sys import exit\nif k>=x:print(0);exit()\nif c<=d:\n div,mod=(x-k)//n,(x-k)%n\n if mod>0:div+=1\n print(div*c)\nelse:\n if d*n<=c:print((x-k)*d)\n else:\n res=(x-k)//n*c\n mod=(x-k)%n\n if c<mod*d:res+=c\n else:res+=mod*d\n print(res)"}, {"source_code": "import math\nc,d = map(int,input().split())\nn,m = map(int,input().split())\nk=int(input())\nif k>=n*m:\n print('0')\nelse:\n left=n*m-k\n t=c*(math.ceil(left/n))\n j= c*(left//n) + (left%n)*d\n l=d*(left)\n print(min(t,j,l)) "}, {"source_code": "import math\nc,d = map(int,input().split())\nn,m = map(int,input().split())\nk = int(input())\nif k>=n*m:\n\tprint (0)\n\texit()\nleft = n*m-k\nprint (min(math.ceil(left/n)*c,(left//n)*c + (left%n)*d,left*d))"}, {"source_code": "import math\nc,d=map(int,input().split())\nn,m=map(int,input().split())\nk=int(input())\n\nif m*n <= k:\n print(0)\nelse:\n c1=m*c\n\n c2 = ((((m*n)-k)//n)*c)+((((m*n)-k)%n)*d)\n\n c3 = math.ceil(((m*n)-k)/n)*c\n\n c4 = ((m*n)-k)*d\n\n print(min(c1,c2,c3,c4))\n"}, {"source_code": "#Author: squiggly_lines\n#Date: 05/05/2014\n#Problem: 417A\n\ndef main():\n c,d = map(int, raw_input().split())\n n,m = map(int, raw_input().split())\n k = int(raw_input())\n\n print solve(c,d,n,m,k)\n\ndef solve(c,d,n,m,k):\n target = n*m-k\n if target <= 0:\n return 0\n if d < (c/float(n)):\n return target*d\n else:\n alpha = target/n\n remainder = target % n\n if remainder == 0:\n return alpha*c\n if c > remainder*d:\n return alpha*c + remainder*d\n else:\n return (alpha+1)*c\n\n\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "c,d=map(int,raw_input().split())\nn,m=map(int,raw_input().split())\nk=int(raw_input())\n\nans=max(0,n*m-k)\ncount=0\ndp=[[0 for i in range(2)] for i in range(10**5)]\nfor i in range(1,n+1):\n dp[i][0]=c\n dp[i][1]=min(i*d,c)\nif ans<=n:\n print min(dp[ans][0],dp[ans][1])\nelse:\n for i in range(n+1,ans+1):\n dp[i][0]=c+min(dp[i-n][0],dp[i-n][1])\n dp[i][1]=d+min(dp[i-1][0],dp[i-1][1])\n print min(dp[ans][1],dp[ans][0])"}, {"source_code": "from sys import stdin\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nceil1 = lambda a, b: (a + b - 1) // b\n\nc, d = rints()\nn, m = rints()\nk = int(input())\nrem = max((n * m) - k, 0)\nans = min(rem * d, ceil1(rem, n) * c, (rem // n) * c + (rem % n) * d)\n\nprint(ans)\n"}, {"source_code": "c,d = list(map(int,input().split()))\nn,m = list(map(int,input().split()))\nk = int(input())\nt = max((m*n)-k,0)\np = min(c,n*d)\nans = p*(t//n)\nrem = t%n\nans = ans+min(c,rem*d)\nprint(ans)"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\ndp = [0] * ((n + 1) * m + k)\nfor i in range(1, n * m - k + 1):\n dp[i] = min(dp[i - 1] + d, dp[i - n] + c)\nprint(dp[n * m - k])"}, {"source_code": "Pm,Pa = map(int, input().split())\nN,M = map(int, input().split())\nk = int(input())\nRm = Pm / N\nRa = Pa\n\nlo,hi = 0,100000\n\n\ndef count(mid):\n\tglobal Pm,Pa,Rm,Ra,N\n\tans = 0\n\twhile True:\n\t\tif mid < min(Pm, Pa):\n\t\t\tbreak\n\t\tif Ra <= Rm:\n\t\t\tif mid >= Pa:\n\t\t\t\tans += 1\n\t\t\t\tmid -= Pa\n\t\t\telse:\n\t\t\t\tans += N\n\t\t\t\tmid -= Pm\n\t\telse:\n\t\t\tif mid >= Pm:\n\t\t\t\tans += N\n\t\t\t\tmid -= Pm\n\t\t\telse:\n\t\t\t\tans += 1\n\t\t\t\tmid -= Pa\n\treturn ans\nwhile lo < hi:\n\tmid = (lo + hi) >> 1\n\tif count(mid) >= N * M - k:\n\t\thi = mid\n\telse:\n\t\tlo = mid + 1\nprint(lo)"}, {"source_code": "c,d=map(int,input().split())\nn,m=map(int,input().split())\nk=int(input())\nt=n*m-k\nif(t<=0):print(0)\nelif(d<=c/n):\n print(d*t)\nelse:\n if(t%n==0):\n print(c*(t//n))\n else:\n a1=c*(t//n+1)\n a2=c*(t//n)+d*(t%n)\n print(min(a1,a2))"}, {"source_code": "from math import ceil,floor\nc,d = map(int,input().split())\nn,m = map(int,input().split())\nk = int(input())\nNeeded = n*m\nif(Needed<=k):\n print(0)\n exit()\nNeeded -= k\nx = ceil(Needed/n) * c\ny = ceil(Needed) * d\nz = floor(Needed/n)*c + (Needed%n)*d\nprint(min(x,y,z))"}, {"source_code": "c,d=map(int, input().split())\nn,m=map(int, input().split())\nk=int(input())\n\nz=m*n-k\n\nif z<=0: \n print(0)\nelse:\n dp = [0]*100000\n for i in range(z):\n dp[i+1] = min(dp[i]+d, dp[i+1-n]+c)\n print(dp[z])"}, {"source_code": "c,d=map(int,input().split())\nn,m=map(int,input().split())\nk=int(input())\ntot=n*m\nif(k>=tot):\n\tprint(\"0\")\nelse:\n\trem=tot-k\n\tx=n/c\n\ty=1/d\n\tans=0\n\tif(x>=y):\n\t\ttemp=rem//n\n\t\tbacha=rem%n\n\t\tif(bacha*d<=c):\n\t\t\tans=temp*c+bacha*d\n\t\telse:\n\t\t\tans=(temp+1)*c\n\telse:\n\t\tans=rem*d\n\tprint(ans)"}, {"source_code": "c,d = map(int,input().split())\nn,m = map(int,input().split())\nk = int(input())\nf = [float('+inf') for i in range(n*m+n+k+2)]\nf[0] = f[k] = 0\nfor i in range(n*m):\n f[i+1] = min(f[i+1],f[i]+d)\n f[i+n] = min(f[i+n],f[i]+c)\nprint(min(f[n*m:]))"}, {"source_code": "# arr=list(map(int,input().split()))\n# arr=sorted([(n-int(x),i) for i,x in enumerate(input().split())])\n# arr=[int(q)-1 for q in input().split()]\n# from collections import Counter\n# n=int(input())\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n# for i in range(m):\n#for _ in range(int(input())):\n#n=int(input())\nc,d=map(int,input().split())\nn,m=map(int,input().split())\nk=int(input())\nvar=n*m-k\ndp=[0]*(n*m+1)\nfor i in range(1,n*m+1):\n if i<n:\n dp[i]=dp[i-1]+d\n else:\n dp[i]=min(dp[i-n]+c,dp[i-1]+d)\nprint(min(dp[max(0,n*m-k):n*m+1]))\n\n"}, {"source_code": "c, d = [int(i) for i in input().split(\" \")]\nn, m = [int(i) for i in input().split(\" \")]\nk = int(input())\n\ns = n*m - k\ns = max(s, 0)\n\nif c < d*n:\n stuff = s//n\n try1 = c*stuff + d*(s-n*stuff)\n try2 = c*(stuff+1)\n print(min(try1, try2))\nelse:\n print(d*s)"}, {"source_code": "import os, sys, atexit\nfrom io import BytesIO, StringIO\n \ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n_OUTPUT_BUFFER = StringIO()\nsys.stdout = _OUTPUT_BUFFER\n \n@atexit.register\ndef write():\n sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nrequire = n * m - k\nans = 999999999\nfor i in range(10000):\n for j in range(10000):\n if i * n + j >= require:\n ans = min(ans, c * i + d * j)\nprint(ans)"}, {"source_code": "import math as mt \nimport sys,string\ninput=sys.stdin.readline\nimport random\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\nc,d=M()\nn,m=M()\nk=I()\nif(n*m<=k):\n print(0)\nelse:\n t=n*m-k\n if(n/c<1/d):\n print(d*t)\n else:\n q=t//n\n p=t%n\n print(min(q*c+c,q*c+p*d))\n"}], "negative_code": [{"source_code": "c,d = [int(x) for x in raw_input().split()]\nn,m = [int(x) for x in raw_input().split()]\nk = int(raw_input())\n\ntotal = n*m - k; \n\ndp = [0]\ndp += [0]*(total)\nfor i in range(1,total+1):\n dp[i] = dp[i-1]+d\n if i>=n:\n dp[i] = min(dp[i],dp[i-n]+c)\n\nprint(dp[max(total,0)])"}, {"source_code": "c,d = map(int,raw_input().split())\nn,m = map(int,raw_input().split())\nk = int(raw_input())\nneed = m * n - k\nmain_need = c/float(n)\nadd_need = d\nif add_need <= main_need :\n\tprint add_need * need\nelse :\n\ts = c * ( need / n )\n\tlast_need = need % n\n\tif c <= add_need * last_need :\n\t\tprint s + c\n\telse :\n\t\tprint s + add_need * last_need\n"}, {"source_code": "c,d = map(int,raw_input().split())\nn,m = map(int,raw_input().split())\nk = int(raw_input())\nneed = m * n - k\nmain_need = c/float(n)\nadd_need = d\nif add_need <= main_need :\n\tprint add_need * need\nelse :\n\ts = c * ( need / n )\n\tlast_need = need - s\n\tif c <= add_need * last_need :\n\t\tprint s + c\n\telse :\n\t\tprint s + add_need * last_need\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\t[c,d] = map(int,sys.stdin.readline().split())\n\t[n,m] = map(int,sys.stdin.readline().split())\n\tk = int(raw_input())\n\tminimum = n*m - k\n\tif minimum == 0:\n\t\tprint 0\n\telse:\n\t\tone = minimum / n if minimum % n == 0 else minimum / n + 1\n\t\ttwo = minimum / d if minimum % d == 0 else minimum / d + 1\n\t\tprint min(one,two)\n\n\t\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\t[c,d] = map(int,sys.stdin.readline().split())\n\t[n,m] = map(int,sys.stdin.readline().split())\n\tk = int(raw_input())\n\tminimum = n*m - k\n\tif minimum == 0:\n\t\tprint 0\n\telse:\n\t\tone = minimum / n * c\n\t\tprint min(one+c,one+d)\n\n\t\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\t[c,d] = map(int,sys.stdin.readline().split())\n\t[n,m] = map(int,sys.stdin.readline().split())\n\tk = int(raw_input())\n\tminimum = n*m - k\n\tif minimum == 0:\n\t\tprint 0\n\telse:\n\t\tone = minimum / n * c\n\n\t\tprint min(one+c,minimum % n * d)\n\n\t\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\tinput = map(int,sys.stdin.readline().split())\n\tfor i in input:\n\t\tprint(i)\n\t\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\t[c,d] = map(int,sys.stdin.readline().split())\n\t[n,m] = map(int,sys.stdin.readline().split())\n\tk = int(raw_input())\n\tminimum = n*m - k\n\tif minimum == 0:\n\t\tprint 0\n\telse:\n\t\tone = minimum / n * c + (c if minimum % n != 0 else 0)\n\t\ttwo = minimum / n * c + minimum % n * d\n\t\tthree = minimum * d\n\t\tprint min(one,two,three)\n\n\t\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nres = m * c\np = n * m - k\n\nfor i in range(m+1):\n\tfor j in range(n + 1):\n\t\tif i * n + j >= p: res = min(res, c * i + d * j)\n\t\t\nprint res "}, {"source_code": "def test():\n pass"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nres = m * c\np = n * m - k\n\nfor i in range(m+1):\n\tfor j in range(n * m/d + 1):\n\t\tif i * n + j >= p: res = min(res, c * i + d * j)\n\t\t\nprint res\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nres = m * c\np = n * m - k\n\nfor i in range(p/n + 2):\n\tfor j in range(p + 1):\n\t\tif i * n + j >= p: res = min(res, c * i + d * j)\n\t\t\nprint res\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nres = m * c\np = n * m - k\n\nfor i in range(p/n+1):\n\tfor j in range(p + 1):\n\t\tif i * n + j >= p: res = min(res, c * i + d * j)\n\t\t\nprint res\n"}, {"source_code": "c,d = [int(x) for x in raw_input().split()]\nn,m = [int(x) for x in raw_input().split()]\nk = int(raw_input())\nprobs = 0\ngo = d\nadd = 1\nif n/float(c) > float(m):\n go = c\n add = n\n \nwhile 1:\n \n if k >= m*n:\n break\n if k + 1 == m*n:\n probs += min(c,d)\n break\n elif k + n >= m*n:\n probs += min(c, (m*n - k)*d)\n break\n else:\n k+=add\n probs+=go\nprint probs"}, {"source_code": "c,d=[int(x) for x in raw_input().split()]\nn,m=[int(x) for x in raw_input().split()]\nk=int(raw_input())\nprint (n*m-k+n-1)/n*c"}, {"source_code": "c,d=[int(x) for x in raw_input().split()]\nn,m=[int(x) for x in raw_input().split()]\nk=int(raw_input())\nprint min((n*m-k+n-1)/n*c,(n*m-k)/n*c+(n*m-k)%n*d,(n*m-k)*d)"}, {"source_code": "c,d=[int(x) for x in raw_input().split()]\nn,m=[int(x) for x in raw_input().split()]\nk=int(raw_input())\nprint min((n*m-k+n-1)/n*c,(n*m-k)*d)"}, {"source_code": "c,d=[int(x) for x in raw_input().split()]\nn,m=[int(x) for x in raw_input().split()]\nk=int(raw_input())\nprint (n*m-k+n-1)/n"}, {"source_code": "\nc,d = map(int,raw_input().strip().split())\nn,m = map(int,raw_input().strip().split())\nk = int(raw_input())\n\n##c = 2\n##d = 2\n##n = 2\n##m = 1\n##k = 2\n\ntask_count = 0\nrounds_c = 0\nrounds_d = 0\nminamount = n*m-k\nif (minamount <= 0):\n task_count = 0\nelse:\n cost_c = float(n*1.0/1)\n cost_d = float(1*1.0/d)\n if cost_c>cost_d:\n ost = minamount % n\n if ost == 0:\n task_count = (minamount / n)*c\n else:\n rounds_c = minamount / n\n task_count = rounds_c * c\n if ost*d > c:\n task_count += c\n else:\n task_count += ost*d\n \nprint task_count\n \n\n"}, {"source_code": "\nc,d = map(int,raw_input().strip().split())\nn,m = map(int,raw_input().strip().split())\nk = int(raw_input())\n\n##c = 2\n##d = 2\n##n = 2\n##m = 1\n##k = 2\n\ntask_count = 0\nrounds_c = 0\nrounds_d = 0\nminamount = n*m-k\nif (minamount <= 0):\n task_count = 0\nelse:\n cost_c = float(n*1.0/1)\n cost_d = float(1*1.0/d)\n if cost_c>cost_d:\n ost = minamount % n\n if ost == 0:\n task_count = (minamount / n)*c\n else:\n rounds_c = minamount / n\n task_count = rounds_c * c\n if ost*d > c:\n task_count += c\n else:\n task_count += ost*d\n else:\n task_count = (minamount / 1)*d\n \nprint task_count\n \n\n"}, {"source_code": "\nif __name__ == '__main__':\n line = raw_input()\n num = line.strip().split(\" \")\n c, d = int(num[0]), int(num[1])\n line = raw_input()\n num = line.strip().split(\" \")\n n, m = int(num[0]), int(num[1])\n k = int(raw_input())\n total = n * m\n need = total - k\n prob = 0\n while need > 0:\n if c / n < d:\n need -= n\n prob += c\n else:\n need -= 1\n prob += d\n print prob\n "}, {"source_code": "\nc,d = [int(item) for item in raw_input().split(' ')]\nn,m = [int(item) for item in raw_input().split(' ')]\nk = int(raw_input())\nprint c,d,n,m,k\nfor i in range(0, m + 1):\n x = i\n if x * n + 1 >= m * n:\n y = 0\n else:\n y = m * n - k - n * x\n ans = c * x + d * y\n if i == 0:\n mx = ans\n continue\n mx = ans if mx > ans else mx\n \nprint mx\n"}, {"source_code": "\nc,d = [int(item) for item in raw_input().split(' ')]\nn,m = [int(item) for item in raw_input().split(' ')]\nk = int(raw_input())\nfor i in range(0, m + 1):\n x = i\n if x * n + k >= m * n:\n y = 0\n else:\n y = m * n - k - n * x\n ans = c * x + d * y\n if i == 0:\n mx = ans\n continue\n mx = ans if mx > ans else mx\n print mx,ans,x,y\n \nprint mx\n"}, {"source_code": "c, d = map ( int, raw_input ( ).split ( ) )\nn, m = map ( int, raw_input ( ).split ( ) )\nk = int(raw_input ( ) )\n\nrem = n*m - k\nminAns = 1e10\n\nfor i in range(1000):\n for j in range(1000):\n if ( i * n + j >= rem and minAns > i * c + j * d):\n minAns = i * c + j * d\n\nprint minAns\n \n"}, {"source_code": "input = raw_input\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\ns = n*m - k\nres = 0\n\nif s > 0:\n if (c/n) > d:\n res += d*s\n else:\n os = s - (s // n)\n res += (s // n) * c\n if c < d*os:\n res += c\n else:\n res += d*os\n\nprint( res )"}, {"source_code": "input = raw_input\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\ns = n*m - k\n\nos = s - (s // n)\nres = (s // n) * c\nif c < d*os:\n res += c\nelse:\n res += d*os\n\nif res < 0:\n res = 0\n \nprint( res )"}, {"source_code": "input = raw_input\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\ns = n*m - k\nres = 0\n\nif s > 0:\n res = c\n s -= n\n if (c/n) > d:\n res += d*s\n else:\n os = s - (s // n)\n res += (s // n) * c\n if c < d*os:\n res += c\n else:\n res += d*os\n\nprint( res )\n"}, {"source_code": "input = raw_input\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\ns = n*m - k\n\nif (c/n) > d:\n res = d*s\nelse:\n os = s - (s // n)\n res = (s // n) * c\n if c < d*os:\n res += c\n else:\n res += d*os\n\nif res < 0:\n res = 0\n\nprint( res )\n"}, {"source_code": "input = raw_input\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\ns = n*m - k\n\nos = s - (s // n)\nres = (s // n) * c\nif c < d*os:\n res += c\nelse:\n res += d*os\n\nprint( res )\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=n*m-k\nmi=100000000\nfor i in range((req/n)+n):\n for j in range(req+3):\n if c*n*i+d*j >=req:\n if i+j<mi:\n mi=i+j\nprint mi\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=(n*m)-k\nmi=100000000\nfor i in range(req/n + n):\n for j in range(req+3):\n if n*i+j >=req:\n if c*i+j*d<mi:\n mi=i*c+j*d\nprint mi\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=(n*m)-k\nmi=100000000\nfor i in range((req/n)+n):\n for j in range(req+3):\n if n*i+j >=req:\n if c*i+j*d<mi:\n mi=i*c+j*d\n##if mi!=0:\n## req-=n\n## for i in range(1,(req/n)+n):\n## for j in range(req+3):\n## if c*n*i+d*j >=req:\n## if i*c+j*d<mi:\n## mi=i*c+j*d\n## mi+=1\nprint mi\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=n*m-k\nmi=100000000\nfor i in range(req/(c*n)+2):\n for j in range(req/d+2):\n if c*n*i+d*j >=req:\n if i+j<mi:\n mi=i+j\nprint mi\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=n*m-k\nmi=100000000\nfor i in range((req/n)+n):\n for j in range(req+3):\n if c*n*i+d*j >=req:\n if i+j<mi:\n mi=i+j\nif mi!=0:\n req-=n\n for i in range(1,(req/n)+n):\n for j in range(req+3):\n if c*n*i+d*j >=req:\n if i+j<mi:\n mi=i+j\n mi+=1\nprint mi\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=(n*m)-k\nmi=100000000\nfor i in range((req/n)+n):\n for j in range(req+3):\n if c*n*i+d*j >=req:\n if i+j<mi:\n mi=i*c+j*d\nif mi!=0:\n req-=n\n for i in range(1,(req/n)+n):\n for j in range(req+3):\n if c*n*i+d*j >=req:\n if i*c+j*d<mi:\n mi=i*c+j*d\n mi+=1\nprint mi\n"}, {"source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=n*m\nmi=100000000\nfor i in range(req/n+3):\n for j in range(req+3):\n if c*n*i+d*j >=req:\n if i+j<mi:\n mi=i+j\nprint mi\n"}, {"source_code": "from math import ceil\n\nc, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = input()\n\ndef f(c, d, n, m, k):\n p = n*m - k\n if p <= 0: return 0\n print p, d, n\n a = (\n p * d,\n int(ceil(float(p)/n)) * c,\n (p/n) * c + (p%n) * d\n )\n #print a\n return min(a)\nprint f(c, d, n, m, k)\n"}, {"source_code": "vals = [int(x) for x in raw_input().split()]\na=vals[0]\nb=vals[1]\nvals = [int(x) for x in raw_input().split()]\nn=vals[0]\nm=vals[1]\nk=input()\n\nt=n*m-k\nr=0\n\nwhile t>0:\n if a<t*b:\n t-=n\n r+=a\n else:\n t-=1\n r+=b\n\nprint(r)\n"}, {"source_code": "vals = [int(x) for x in raw_input().split()]\na=vals[0]\nb=vals[1]\nvals = [int(x) for x in raw_input().split()]\nn=vals[0]\nm=vals[1]\nk=input()\n\nt=n*m-k\nr=0\n\nwhile t>0:\n if a<n*b:\n t-=n\n r+=a\n else:\n t-=1\n r+=b\n\nprint(r)\n"}, {"source_code": "'''\nCreated on Apr 17, 2014\n\n@author: Arjun\n'''\nstuff = raw_input()\nstuff2 = raw_input()\nautoAdvance = int(raw_input())\nlista = stuff.split()\nlistb = stuff2.split()\nmainRound = int(lista[0])\nextraRound = int(lista[1])\nmainAdvance = int(listb[0])\nm = int(listb[1])\nneedAdvance = mainAdvance*m-autoAdvance\nval = 0\nif(needAdvance%m == 0):\n divisor = needAdvance/mainAdvance\nelse:\n divisor = needAdvance/mainAdvance + 1\n\nif(needAdvance<=0):\n print 0\nelif(mainRound < extraRound):\n print mainRound*divisor\nelse:\n all2 = extraRound*needAdvance\n all1 = mainRound*divisor\n blah = (needAdvance/mainAdvance)*mainRound + (needAdvance - (needAdvance/mainAdvance) *mainAdvance)*extraRound\n print min(all1,all2,blah)\n\n\n"}, {"source_code": "#!/usr/bin/env python\n\nimport sys\nimport logging\n\nc, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = input()\n\nt = n * m - k\n\ncandidates = []\n\ncandidates += [c * (t / n + (1 if t%n != 0 else 0))]\ncandidates += [d * t]\n\ncandidates += [c * (t/n) + (t - t/n) * d]\n\nprint min(candidates)\n"}, {"source_code": "#!/usr/bin/env python\n\nimport sys\nimport logging\n\nc, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = input()\n\nt = n * m - k\n\ncandidates = []\n\ncandidates += [c * (t / n + (1 if t%n != 0 else 0))]\ncandidates += [d * t]\n\ncandidates += [c * (t/n) + (t - n*(t/n)) * d]\n\nprint min(candidates)\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nx = n * m - k\ncase = 0\n\nwhile x > 0:\n if d < (c / n) or d < (c / x):\n x += d\n case -= 1\n else:\n x -= n\n case += c\n\nprint case\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\nx = n * m - k\ncase = 0\n\nwhile x > 0:\n if d < (c / n):\n x += d\n case -= 1\n elif d < (c / x):\n x += d\n case -= 1\n else:\n x -= n\n case += c\n\nprint case\n"}, {"source_code": "import math\nx=raw_input().split(' ')\nc=int(x[0])\nd=int(x[1])\ny=raw_input().split(' ')\nn=int(y[0])\nm=int(y[1])\npro=n*m\nk=input()\npro=pro-k\nif c<=d:\n ans=int(math.ceil(float(pro)/n))\nelse:\n if float(n)/c>=float(1)/d:\n if pro%n==0:\n ans=pro/n\n else:\n ans=int(math.floor(float(pro)/n))*c\n am=pro%n\n if c<=am*d:\n ans=ans+c\n else:\n ans=ans+am*d\n else:\n ans=pro*d\nprint ans\n"}, {"source_code": "c, d = map(int, raw_input().split())\nn, m = map(int, raw_input().split())\nk = int(raw_input())\n\ntotalPeople = n * m\n\nmainProblems = (totalPeople - k) / n\nmainProblems *= c\n\nprint mainProblems\n\n\n"}, {"source_code": "def debug():\n c,d=map(int,raw_input().split())\n n,m=map(int,raw_input().split())\n k=input()\n final=n*m\n need=final-k\n if need==0:\n print 0\n else:\n fp1=c/float(n)\n fp2=d\n if fp1<fp2:\n timu=(need/n)* c\n rest= need- (need/n)*n\n if rest:\n if rest*d > c:\n print timu+c\n else:\n print timu+rest*d \n else:\n print timu\n else:\n print need*d\n\ndebug()"}, {"source_code": "x=raw_input().split()\ny=raw_input().split()\nz=raw_input().split()\nc=int(x[0])\nd=int(x[1])\nn=int(y[0])\nm=int(y[1])\nk=int(z[0])\nif k>=m*n:\n print 0\nelif d>c/n:\n rou=(m*n-k)/n\n if k%n==0:\n s=rou*c\n print s\n else:\n s=(rou)*c+((m*n-k)%n)*d\n print s\n \nelse:\n s=(m*n-k)*d\n print s"}, {"source_code": "x=raw_input().split()\ny=raw_input().split()\nz=raw_input().split()\nc=int(x[0])\nd=int(x[1])\nn=int(y[0])\nm=int(y[1])\nk=int(z[0])\nif k>=m*n:\n print 0\nelif d*n>c:\n rou=(m*n-k)/n+1\n s=rou*c\n print s\nelse:\n s=(m*n-k)*d\n print s"}, {"source_code": "x=raw_input().split()\ny=raw_input().split()\nz=raw_input().split()\nc=int(x[0])\nd=int(x[1])\nn=int(y[0])\nm=int(y[1])\nk=int(z[0])\nif k>=m*n:\n print 0\nelif d>c/n:\n rou=(m*n-k)/n\n if k%n==0:\n s=rou*c\n print s\n else:\n s=(rou+1)*c\n print s\n \nelse:\n s=(m*n-k)*d\n print s"}, {"source_code": "#Author: squiggly_lines\n#Date: 05/05/2014\n#Problem: 417A\n\ndef main():\n c,d = map(int, raw_input().split())\n n,m = map(int, raw_input().split())\n k = int(raw_input())\n\n print solve(c,d,n,m,k)\n\ndef solve(c,d,n,m,k):\n target = n*m-k\n if target <= 0:\n return 0\n if d < (c/float(n)):\n if int(target/d) == target/d:\n return target/d\n else:\n return target/d + 1\n else:\n alpha = target/n\n remainder = target % n\n if remainder == 0:\n return alpha*c\n if c > remainder*d:\n return alpha*c + remainder*d\n else:\n return (alpha+1)*c\n\n\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "#Author: squiggly_lines\n#Date: 05/05/2014\n#Problem: 417A\n\ndef main():\n c,d = map(int, raw_input().split())\n n,m = map(int, raw_input().split())\n k = int(raw_input())\n\n print solve(c,d,n,m,k)\n\ndef solve(c,d,n,m,k):\n target = n*m-k\n if d < (c/float(n)):\n if int(target/d) == target/d:\n return target/d\n else:\n return target/d + 1\n else:\n alpha = target/n\n remainder = target % n\n if remainder == 0:\n return alpha*c\n if c > remainder*d:\n return alpha*c + remainder*d\n else:\n return (alpha+1)*c\n\n\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "#Author: squiggly_lines\n#Date: 05/05/2014\n#Problem: 417A\n\ndef main():\n c,d = map(int, raw_input().split())\n n,m = map(int, raw_input().split())\n k = int(raw_input())\n\n print solve(c,d,n,m,k)\n\ndef solve(c,d,n,m,k):\n target = n*m-k\n if d < (c/float(n)):\n if int(target/d) == target/d:\n return target/d\n else:\n return target/d + 1\n else:\n alpha = target/n\n remainder = target % n\n if remainder == 0:\n return alpha\n if c > remainder*d:\n return alpha*c + remainder*d\n else:\n return (alpha+1)*c\n\n\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "#Author: squiggly_lines\n#Date: 05/05/2014\n#Problem: 417A\n\ndef main():\n c,d = map(int, raw_input().split())\n n,m = map(int, raw_input().split())\n k = int(raw_input())\n\n print solve(c,d,n,m,k)\n\ndef solve(c,d,n,m,k):\n target = n*m-k\n if d < (c/float(n)):\n if int(target/d) == target/d:\n return target/d\n else:\n return target/d + 1\n else:\n alpha = target/n\n remainder = target % n\n if remainder == 0:\n return alpha\n if c > remainder*d:\n return alpha + remainder*d\n else:\n return alpha+1\n\n\n\nif __name__ == \"__main__\":\n main();\n\n"}, {"source_code": "from sys import stdin\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nceil1 = lambda a, b: (a + b - 1) // b\n\nc, d = rints()\nn, m = rints()\nk = int(input())\nrem = (n * m) - k\nans = min(rem * d, ceil1(rem, n) * c)\nprint(ans)"}, {"source_code": "Pm,Pa = map(int, input().split())\nN,M = map(int, input().split())\nk = int(input())\nRm = Pm / N\nRa = Pa\n\nlo,hi = 0,100000\n\n\ndef count(mid):\n\tglobal Pm,Pa,Rm,Ra,N\n\tans = 0\n\twhile True:\n\t\tif mid < min(Pm, Pa):\n\t\t\tbreak\n\t\tif Ra <= Ra:\n\t\t\tif mid >= Pa:\n\t\t\t\tans += 1\n\t\t\t\tmid -= Pa\n\t\t\telse:\n\t\t\t\tans += N\n\t\t\t\tmid -= Pm\n\t\telse:\n\t\t\tif mid >= Pm:\n\t\t\t\tans += N\n\t\t\t\tmid -= Pm\n\t\t\telse:\n\t\t\t\tans += 1\n\t\t\t\tmid -= Pa\n\treturn ans\nwhile lo < hi:\n\tmid = (lo + hi) >> 1\n\tif count(mid) >= N * M - k:\n\t\thi = mid\n\telse:\n\t\tlo = mid + 1\nprint(lo)"}, {"source_code": "c,d=map(int,input().split())\nn,m=map(int,input().split())\nk=int(input())\nt=n*m-k\nif(d<=c/n):\n print(d*t)\nelse:\n if(t%n==0):\n print(c*(t//n))\n else:\n print(min(c*(t//n+1),c*(t//n)+d*t%n))"}, {"source_code": "# arr=list(map(int,input().split()))\n# arr=sorted([(n-int(x),i) for i,x in enumerate(input().split())])\n# arr=[int(q)-1 for q in input().split()]\n# from collections import Counter\n# n=int(input())\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n# for i in range(m):\n#for _ in range(int(input())):\n#n=int(input())\nc,d=map(int,input().split())\nn,m=map(int,input().split())\nk=int(input())\nvar=n*m-k\ndp=[0]*(n*m+1)\nfor i in range(1,n*m+1):\n if i<n:\n dp[i]=dp[i-1]+d\n else:\n dp[i]=min(dp[i-n]+c,dp[i-1]+d)\nprint(min(dp[n*m-k:n*m+1]))\n\n"}, {"source_code": "c, d = [int(i) for i in input().split(\" \")]\nn, m = [int(i) for i in input().split(\" \")]\nk = int(input())\n\ns = n*m - k\ns = max(s, 0)\n\nif c < d*n:\n stuff = s//n\n try1 = c*stuff + d*(s-n*stuff)\n try2 = (c+1)*stuff\n print(min(try1, try2))\nelse:\n print(d*s)"}, {"source_code": "c, d = [int(i) for i in input().split(\" \")]\nn, m = [int(i) for i in input().split(\" \")]\nk = int(input())\n\ns = n*m - k\n\nif c < d*n:\n stuff = s//n\n try1 = c*stuff + d*(s-n*stuff)\n try2 = (c+1)*stuff\n print(min(try1, try2))\nelse:\n print(d*s)"}, {"source_code": "import math as mt \nimport sys,string\ninput=sys.stdin.readline\nimport random\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\nc,d=M()\nn,m=M()\nk=I()\nif(n*m<=k):\n print(0)\nelse:\n t=n*m-k\n if(n/c<1/d):\n print(d*t)\n else:\n q=t//n\n p=t%n\n print(min(q*c+c,q+p*d))\n"}, {"source_code": "import math as mt \nimport sys,string\ninput=sys.stdin.readline\nimport random\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\nc,d=M()\nn,m=M()\nk=I()\nif(n*m<=k):\n print(0)\nelse:\n t=n*m-k\n if(n/c<1/d):\n print(d*t)\n else:\n q=t//n\n p=t%n\n print(min(q*c+1,q+p*d))\n"}, {"source_code": "import sys\n\nc, d = map(int, sys.stdin.readline().split())\nn, m = map(int, sys.stdin.readline().split())\nk = int(sys.stdin.readline())\n\ntotal = n * m - k\nif total <= 0:\n print(0)\n sys.exit(0)\n\na = [d*i for i in range(0, total+1)]\nprint(a)\n\nfor i in range(1, total+1):\n if i <= n:\n if a[i] > c:\n a[i] = c\n else:\n if a[i-n] + c < a[i]:\n a[i] = a[i-n] + c\n\nprint( a[total] )"}, {"source_code": "import math\nc,d=map(int,input('').split())\nn,m=map(int,input('').split())\nk=int(input(''))\nif 1/d>n/c: print((n*m-k)*d)\nelse: print((math.ceil((n*m-k)/n))*c)\n\n\n\n\n\n\n\n \n \n \n \n \n\n\n \n\n"}, {"source_code": "import math\nc,d=map(int,input('').split())\nn,m=map(int,input('').split())\nk=int(input(''))\nif k<0:\n print('0')\n exit()\nif 1/d>n/c: print((n*m-k)*d)\nelse:\n if (math.ceil((n*m-k)/n)*c)<((n*m-k)//n)*c+((n*m-k)%n)*d: print (math.ceil((n*m-k)/n)*c)\n else: print(((n*m-k)//n)*c+((n*m-k)%n)*d)\n\n\n\n\n\n\n\n \n \n \n \n \n\n\n \n\n"}, {"source_code": "import math\nc,d=map(int,input('').split())\nn,m=map(int,input('').split())\nk=int(input(''))\nif k<0: k=0\nif 1/d>n/c: print((n*m-k)*d)\nelse:\n if (math.ceil((n*m-k)/n)*c)<((n*m-k)//n)*c+((n*m-k)%n)*d: print (math.ceil((n*m-k)/n)*c)\n else: print(((n*m-k)//n)*c+((n*m-k)%n)*d)\n\n\n\n\n\n\n\n \n \n \n \n \n\n\n \n\n"}, {"source_code": "import math\nc,d=map(int,input('').split())\nn,m=map(int,input('').split())\nk=int(input(''))\nif 1/d>n/c: print((n*m-k)*d)\nelse:\n if (math.ceil((n*m-k)/n)*c)<((n*m-k)//n)*c+((n*m-k)%n)*d: print (math.ceil((n*m-k)/n)*c)\n else: print(((n*m-k)//n)*c+((n*m-k)%n)*d)\n\n\n\n\n\n\n\n \n \n \n \n \n\n\n \n\n"}, {"source_code": "problems = input().split()\nc = int(problems[0])\nd = int(problems[1])\nn_m = input().split()\nn = int(n_m[0])\nm = int(n_m[1])\nk = int(input())\n\nfrom queue import PriorityQueue\nimport math\n\n\nclass MyPriorityQueue(PriorityQueue):\n def __init__(self):\n PriorityQueue.__init__(self)\n self.counter = 0\n\n def put(self, item, priority):\n PriorityQueue.put(self, (priority, self.counter, item))\n self.counter += 1\n\n def get(self, *args, **kwargs):\n _, _, item = PriorityQueue.get(self, *args, **kwargs)\n return item\n\n\ndef cost(x1, x2):\n return c * x1 + d * x2\n\n\ndef check(x1, x2):\n return x1 * n + x2 + k >= n * m\n\n\ndef get_x1(x1, x2):\n return math.ceil((n*m - k - x2) / n)\n\n\ndef get_x2(x1, x2):\n return math.ceil(n * (m-x1) - k)\n\n\nq = MyPriorityQueue()\nq.put((0, 0), 0)\ns = set()\nwhile not q.empty():\n (x1, x2) = q.get()\n if check(x1, x2):\n print(c * x1 + d * x2)\n break\n cost1 = cost(x1, x2 + 1)\n cost2 = cost(x1 + 1, x2)\n # if cost1 > cost2:\n # q.put((x1 + 1, x2), cost2)\n # else:\n # q.put((x1, x2 + 1), cost1)\n if (x1+1, x2) not in s:\n q.put((x1 + 1, x2), cost2)\n s.add((x1+1, x2))\n elif (x1, x2+1) not in s:\n q.put((x1, x2 + 1), cost1)\n s.add((x1, x2+1))\n\n\n"}, {"source_code": "problems = input().split()\nc = int(problems[0])\nd = int(problems[1])\nn_m = input().split()\nn = int(n_m[0])\nm = int(n_m[1])\nk = int(input())\n\nfrom queue import PriorityQueue\n\n\nclass MyPriorityQueue(PriorityQueue):\n def __init__(self):\n PriorityQueue.__init__(self)\n self.counter = 0\n\n def put(self, item, priority):\n PriorityQueue.put(self, (priority, self.counter, item))\n self.counter += 1\n\n def get(self, *args, **kwargs):\n _, _, item = PriorityQueue.get(self, *args, **kwargs)\n return item\n\n\ndef cost(x1, x2):\n return c * x1 + d * x2\n\n\ndef check(x1, x2):\n return x1 * n + x2 + k >= n * m\n\n\nq = MyPriorityQueue()\nq.put((0, 0), 0)\nwhile not q.empty():\n (x1, x2) = q.get()\n if check(x1, x2):\n print(c * x1 + d * x2)\n break\n cost1 = cost(x1, x2 + 1)\n cost2 = cost(x1 + 1, x2)\n if cost1 > cost2:\n q.put((x1 + 1, x2), cost2)\n else:\n q.put((x1, x2 + 1), cost1)\n"}, {"source_code": "#import sys\n#sys.stdin = open('input.txt','r')\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nL = 10001\nfor f in range(m // c + 1):\n\tfor g in range((n * m) // d + 1):\n\t\tif f * n * c + g * d + k >= n * m:\n\t\t\tL = min(L, f * c + g * d)\nprint(L)"}, {"source_code": "#import sys\n#sys.stdin = open('input.txt','r')\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nL = 10001\nfor f in range(m // c + 1):\n\tfor g in range(n * m // d + 1):\n\t\tif f * n * c + g * d + k >= n * m:\n\t\t\tL = min(L, f + g)\nprint(L)"}, {"source_code": "#import sys\n#sys.stdin = open('input.txt','r')\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nL = 10001\nfor f in range(n * m + 1):\n\tfor g in range(n * m + 1):\n\t\tif f * n * c + g * d + k >= n * m:\n\t\t\tL = min(L, f * c + g * d)\nprint(L)"}, {"source_code": "#import sys\n#sys.stdin = open('input.txt','r')\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nL = 10001\nfor f in range(m + 1):\n\tfor g in range(n * m + 1):\n\t\tif f * n * c + g * d + k >= n * m:\n\t\t\tL = min(L, f * c + g * d)\nprint(L)"}, {"source_code": "\n\n#c,d,n,m,k=map(int,input().split())\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\n# c \u0438 d (1\u2009\u2264\u2009c,\u2009d\u2009\u2264\u2009100) \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0443\u043d\u0434\u0430\u0445 \n# n \u0438 m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100) n \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n# k (1\u2009\u2264\u2009k\u2009\u2264\u2009100) \u2014 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n\nS = 0\nif n*m>k : \n nub = n*m-k\n S = 100000000000\n S0 = S\n i=0\n while S0<=S and i<int(nub/c):\n S = S0 \n S0 = i*c + d*max(0, nub-n*i)\n # print(i,S,S0)\n i += 1\n\nprint(S)\n\n\n"}, {"source_code": "\n\n#c,d,n,m,k=map(int,input().split())\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\n# c \u0438 d (1\u2009\u2264\u2009c,\u2009d\u2009\u2264\u2009100) \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0443\u043d\u0434\u0430\u0445 \n# n \u0438 m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100) n \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n# k (1\u2009\u2264\u2009k\u2009\u2264\u2009100) \u2014 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n\nS = 0\nif n*m>k : \n nub = n*m-k\n S = 100000000000\n S0 = S\n i=0\n while S0<=S and i<=int(nub/c+2):\n S = S0 \n S0 = i*c + d*max(0, nub-n*i)\n #print(i,S,S0)\n i += 1\n\nprint(S)\n\n\n"}, {"source_code": "\n\n#c,d,n,m,k=map(int,input().split())\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\n\n# c \u0438 d (1\u2009\u2264\u2009c,\u2009d\u2009\u2264\u2009100) \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0443\u043d\u0434\u0430\u0445 \n# n \u0438 m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100) n \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n# k (1\u2009\u2264\u2009k\u2009\u2264\u2009100) \u2014 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n\nS = 0\nif n*m>k : \n nub = n*m-k\n S = 100000000000\n S0 = S\n i=0\n while S0<=S and i<int(nub/c+1):\n S = S0 \n S0 = i*c + d*max(0, nub-n*i)\n # print(i,S,S0)\n i += 1\n\nprint(S)\n\n\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\ntotal = n * m - k\nif k >= n * m:\n print(0)\nelif c < d:\n print(((total // n) + 1) * c)\nelse:\n nr = 0\n nn = (c / n)\n nm = d\n if nn < nm:\n while (nr * n) + n < total:\n nr += 1\n npn = (nr + 1) * c\n npm = nr * c + d * (total - nr * n)\n print(min(npn, npm))\n else:\n print(m * total)\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\ntotal = n * m - k\nif k >= total:\n print(0)\nelif n > m and c < d:\n print(((total // n) + 1) * c)\nelse:\n nr = 0\n nn = (c / n)\n nm = m\n if nn < nm:\n while (nr * n) + n < total:\n nr += 1\n npn = (nr + 1) * c\n npm = nr * c + d * (total - nr * n)\n print(min(npn, npm))\n else:\n print(m * total)\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\ntotal = n * m - k\nif k >= n * m:\n print(0)\nelif c < d:\n if total % n == 0:\n print(((total // n)) * c)\n else:\n print(((total // n) + 1) * c)\nelse:\n nr = 0\n nn = (c / n)\n nm = d\n if nn < nm:\n #while (nr * n) + n < total:\n # nr += 1\n nr = total // n\n npn = nr * c\n if nr * n < total:\n npn = (nr + 1) * c\n npm = nr * c + d * (total - nr * n)\n print(min(npn, npm))\n else:\n print(m * total)\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\np = 0\nk = int(input())\nif m*n <= k:\n print(0)\nelse:\n a = [0]*(m*n+1)\n #a[k+1] = min(c,d)\n for i in range(k+1,m*n+1):\n if p == 0:\n if d > c:\n a[i] = a[i-1]+c\n p = n-1\n else:\n a[i] = a[i-1]+d\n else:\n p-=1\n a[i] = a[i-1]\n print(a[m*n])"}, {"source_code": "c, d = list(map(int, input().split()))\nn, m = list(map(int, input().split()))\nk = int(input())\nkolvo = m * n - k\n\nprint(min(c * (kolvo // n), d * n * (kolvo // n)) + min(c, d * (kolvo % n)))\n\n"}, {"source_code": "def f(x, y): return x * c + y * d\nc, d = map(int, input().split())\nn, m = map(int, input().split())\nk = s = n * m - int(input())\nx = 0\nwhile k > x * n:\n t = f(x, k - x * n)\n if t < s: s = t\n x += 1\nprint(min(s, f(x, 0)))\n"}, {"source_code": "#Codeforces problem 417A: Elimination\n\ndef roof(c,p):\n\tr = p // c\n\tif p%c > 0:\n\t\tr = r + 1\n\treturn r\n\nc,d = (int(element) for element in input().split())\n\nn,m = (int(element) for element in input().split())\n\nk = int(input())\n\nneeded_number_of_problems = 0\n\n#people still needed for the 2214 Russian Code Cup\"\np = m*n - k\n\nwhile p > 0:\n\tx = roof(c,p)\n\tif d*p < c*x:\n\t\t#get people from the additional rounds\n\t\tneeded_number_of_problems += d*p\n\t\tp = 0\n\telse:\n\t\t#get people from main round\n\t\tneeded_number_of_problems += c\n\t\tp = p - n\n\nprint(needed_number_of_problems)\n"}, {"source_code": "#Codeforces problem 417A: Elimination\n\ndef roof(c,p):\n\tr = p // c\n\tif p%c > 0:\n\t\tr = r + 1\n\treturn r\n\nc,d = (int(element) for element in input().split())\n\nn,m = (int(element) for element in input().split())\n\nk = int(input())\n\nneeded_number_of_problems = 0\n\n#people still needed for the 2214 Russian Code Cup\"\np = m*n - k\n\nwhile p > 0:\n\tx = roof(c,p)\n\tif d*p < c*x:\n\t\t#get people from the additional rounds\n\t\tneeded_number_of_problems += d\n\t\tp = p - 1\n\telse:\n\t\t#get people from main round\n\t\tneeded_number_of_problems += c\n\t\tp = p - n\n\nprint(needed_number_of_problems)\n\n"}, {"source_code": "#Codeforces problem 417A: Elimination\n\nc,d = (int(element) for element in input().split())\n\nn,m = (int(element) for element in input().split())\n\nk = int(input())\n\nneeded_number_of_problems = 0\n\n#people still needed for the 2214 Russian Code Cup\"\np = m*n - k\n\nwhile p > 0:\n\tx = c // p\n\tif d*p < c*x:\n\t\t#get people from the additional rounds\n\t\tneeded_number_of_problems += d*p\n\t\tp = 0\n\telse:\n\t\t#get people from main round\n\t\tneeded_number_of_problems += c\n\t\tp = p - n\n\nprint(needed_number_of_problems)"}, {"source_code": "c,d = [int(x) for x in input().strip().split()]\nn,m = [int(x) for x in input().strip().split()]\nk = int(input().strip())\n\nt = n*m-k\nif t<=0:\n print(0)\nelse:\n dp = [0]*(t+1)\n for i in range(1,t+1):\n if i<n:\n dp[i]=min(dp[i-1]+d, n)\n else:\n dp[i]=min((c+dp[i-n]), (d+dp[i-1]))\n print(dp[t])\n"}, {"source_code": "c,d = [int(x) for x in input().strip().split()]\nn,m = [int(x) for x in input().strip().split()]\nk = int(input().strip())\n\nt = n*m-k\nif t<=0:\n print(0)\nelse:\n dp = [0]*(t+1)\n for i in range(1,t+1):\n if i<n:\n dp[i]=min(d,c)\n else:\n dp[i]=min((c+dp[i-n]), (d+dp[i-1]))\n print(dp[t])\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nneed = n*m - k\nr1 = c / n\nif r1 < d:\n div, rest = divmod(need, n)\n cont = div\nelse:\n cont = need * d\ncont += min(c, d*rest)\nprint(cont)\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nneed = n*m - k\nr1 = c / n\nif r1 < d:\n div, rest = divmod(need, n)\n cont = div * c\nelse:\n cont = need * d\ncont += min(c, d*rest)\nprint(cont)\n"}, {"source_code": "c, d = map(int, input().split())\nn, m = map(int, input().split())\nk = int(input())\nneed = n*m - k\nif k >= need:\n print(0)\nelse:\n r1 = c / n\n if r1 < d:\n div, rest = divmod(need, n)\n cont = div * c\n else:\n cont = need * d\n cont += min(c, d*rest)\n print(max(0,cont))\n"}, {"source_code": "c,d=map(int,input().split())\nn,m=map(int,input().split())\nk=int(input())\n\nif m*n <= k:\n print(0)\nelse:\n c1=m*c\n\n c2 = ((((m*n)-k)//n)*c)+((((m*n)-k)%n)*d)\n\n print(min(c1,c2))\n"}], "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb"} {"source_code": "n, m = map(int, input().split())\nmax = 10**9+7\nx = pow(2,m,max)-1\nans = pow(x,n,max)\nprint(ans)", "positive_code": [{"source_code": "# n,m = input().split\nimport sys\nn,m = map(int,sys.stdin.readline().split())\n\ndef fast(x, k):\n if (k == 0):\n return 1;\n xp = fast(x, k // 2)\n if (k % 2 == 0):\n return (xp * xp) % 1000000007\n else:\n return (xp * xp * x) % 1000000007\n\n# print(((2 ** m - 1) ** n) % 1000000007)\nprint(fast((fast(2, m) - 1), n))\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nn,m=map(int,input().split())\nprint(pow(2**m-1,n,10**9+7))"}, {"source_code": "n,m=map(int,input().strip().split(\" \"))\nmod=(int)(1e9+7)\n\nprint(pow(pow(2,m,mod)-1,n,mod))"}, {"source_code": "mod= 10**9 +7\n\ndef power(a,b):\n ans=1\n while(b>0):\n if(b%2==1):\n ans=(ans*a)%mod\n b=b//2\n a=(a*a)%mod\n return ans\n\n(n,m)=[int(x) for x in input().split()]\nres=power(2,m)-1\nres=power(res,n)\nprint(res%mod)\n"}, {"source_code": "mod=1000000007\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\nn,m=map(int,input().split())\nans=powerMod(2,m,mod)-1\nans=powerMod(ans,n,mod)\nprint(ans)"}, {"source_code": "n,m = map(int,input().split())\nprint(pow(2**m-1,n,(int)(1e9+7)))"}, {"source_code": "n, m = map(int, input().split())\nprint( pow( pow(2, m, 1000000007) - 1, n, 1000000007) )"}, {"source_code": "def power(x, y) : \n res = 1 \n\n p = 10**9 + 7\n \n x = x % p \n \n while (y > 0) : \n \n \n if ((y & 1) == 1) : \n res = (res * x) % p \n \n \n y = y >> 1\n x = (x * x) % p \n \n return res\n\nn,m = list(map(int,input().split()))\nmod = 10**9 + 7\nans = power(power(2,m)-1,n)\n\nprint(ans)\n\n"}, {"source_code": "a,b=map(int,input().split())\nm=7+10**9\nans=(pow(2,b,m)-1)%m\nans= (pow(ans,a,m))%m\nprint(ans)"}, {"source_code": "M = 1000000007\n\ndef pw(x,y):\n s=1\n while y:\n if y & 1: s=(s*x)%M\n x=(x*x)%M\n y>>=1\n return s\n\nn, m = map(int, input().split())\n\nprint(int(pw(pw(2, m) - 1, n)))"}, {"source_code": "#-*- coding: utf-8 -*-\n\n# int(input())\n# [int(inp) for inp in input().split()]\n\nn, m = [int(inp) for inp in input().split()]\n\nresult = 1\n# for i in range(m):\n# result = (result * 2) % (1000000000 + 7)\n# result = (result - 1) % (1000000000 + 7)\n# mult = result\n\nresult = (pow(2, m, int(1e9) + 7) - 1 ) % (int(1e9) + 7)\n\n# for i in range(n - 1):\n # result = (result * mult) % (1000000000 + 7)\nresult = pow(result, n, int(1e9) + 7)\n\nprint(result)"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\n\nN = 1000000007; \n \ndef exponentiation(bas, exp): \n if (exp == 0): \n return 1; \n if (exp == 1): \n return bas % N; \n \n t = exponentiation(bas, int(exp / 2)); \n t = (t * t) % N; \n \n \n if (exp % 2 == 0): \n return t; \n \n \n else: \n return ((bas % N) * t) % N;\n\nmodulo = exponentiation(2, m) - 1\nprint(exponentiation(modulo, n))\n\n"}, {"source_code": "import sys\nimport math\ndef fastmod(b,e,m):\n result = 1\n while e!=0:\n if (e&1) == 1:\n result = (result * b) % m\n e >>= 1\n b = (b*b) % m\n return result\n \nif __name__ == '__main__':\n input = sys.stdin.readline\n MOD = int(1e9+7)\n a,b=map(int,input().split())\n print(int(fastmod(fastmod(2,b,MOD)-1,a,MOD)))\n "}, {"source_code": "mod = 1000000007\n\ndef powm(b,p):\n if p == 0:\n return 1\n if p == 1:\n return b\n if p%2 == 1:\n res = powm(b,int(p/2))%mod\n res = (res*res)%mod\n res = (res*b)%mod\n\n if p%2 == 0:\n res = powm(b,int(p / 2)) % mod\n res = (res * res) % mod\n\n return res%mod\n\n\n\ndef main():\n n,m = (int(x) for x in input().split())\n bb = powm(2,m)-1\n print(powm(bb,n))\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "def solve(a,b):\n mod = (10**9) + 7\n ans = pow(pow(2,b,mod)-1,a,mod)\n return ans\na,b = map(int,input().split())\nprint(solve(a,b))"}, {"source_code": "n,m = map(int,input().split())\np = 10**9+7\nprint(pow((pow(2,m,p)-1),n,p))\n"}, {"source_code": "n,m=map(int,input().split())\nmaxi=10**9+7\nprint(pow(pow(2,m,maxi)-1,n,maxi))"}, {"source_code": "from sys import stdin,stdout\nfrom collections import defaultdict as df\nfrom collections import deque\nimport bisect\nfrom itertools import permutations,combinations\nn,m=list(map(int,input().split()))\nmod=10**9 + 7\nprint(pow(pow(2,m,mod)-1,n,mod))"}, {"source_code": "from sys import stdin,stdout\nI = lambda : map(int,stdin.readline().split())\n\nmod = 10**9 + 7\nn,m = I()\nprint pow((pow(2,m,mod) - 1),n,mod)"}, {"source_code": "n,m=map(int,raw_input().split())\nprint pow(pow(2,m,1000000007)-1,n,1000000007)\n"}, {"source_code": "c = 10 ** 9 + 7\nn, m = map(int, input().split())\nres = pow(pow(2, m, c) - 1, n, c)\nprint(res)\n"}, {"source_code": "n,k = map(int ,raw_input().split()) \nmod = (int)(1e9 + 7)\nans = pow(2,k, mod) - 1 \nans += mod \nans %= mod; \nans = pow(ans, n, mod)\nprint ans"}, {"source_code": "n,m = map(int,raw_input().split())\nmod = 10**9 + 7\nprint pow(pow(2,m,mod)-1,n,mod)"}, {"source_code": "from sys import stdin\nn,m=map(int,stdin.readline().split())\nt=pow(2,m,1000000007)-1\nprint pow(t,n,1000000007)"}, {"source_code": "n, m = map(int, input().split())\nmod = 10**9+7\nprint(pow(pow(2, m, mod) - 1, n, mod))\n"}, {"source_code": "a,b=map(int,input().split())\nk=10**9+7\nprint(pow(pow(2,b,k)-1,a,k))\n"}, {"source_code": "delta = [int(x) for x in input().split()]\nn = delta[0]\nm = delta[1]\n# ans = 2**m\n# ans-=1\n# ans = ans**(n)\n# print(ans)\n\na=2\nmod = 1000000007\ntemp = 1\nwhile m>0:\n if m&1:\n temp = ((temp%mod)*(a%mod)%mod)\n a = ((a%mod)*(a%mod))%mod\n m>>=1\n\nres = 1\na = (temp+mod-1)%mod\n\nwhile n>0:\n if n&1:\n res = ((res%mod)*(a%mod)%mod)\n a = ((a%mod)*(a%mod))%mod\n n>>=1\nprint(res)\n"}, {"source_code": "import math\nn,m=[int(x) for x in input().split()]\nans=pow(((pow(2,m,1000000007)-1+1000000007)%1000000007),n,1000000007)\nprint(int(ans))"}, {"source_code": "n,m = map(int, raw_input().split())\np = (int)(1e9+7) \nprint(pow((pow(2, m) - 1), n, p))"}, {"source_code": "n, m = map(int, raw_input().split())\nMOD = 1000000007\ndef qpow(a, n):\n ret, now = 1, a\n while n:\n if n & 1:\n ret = ret * now % MOD\n n >>= 1\n now = now * now % MOD\n return ret\n\nprint qpow(qpow(2, m) - 1, n)\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom random import randint\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial as fact\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nimport sys\nimport os\nimport re\nsys.setrecursionlimit(9999)\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\nN = 5001\n \n'''\nCheck for special cases (n=1)\nOne wrong submission = 10 mins penalty!\ndo smth instead of nothing and stay organized\n'''\n\ndef c(n, r):\n\treturn fact(n)//(fact(r)*fact(n-r))\n\ndef main():\n\tn, m = map(int, input().split())\n\tx = (pow(2, m, mod) - 1 + mod) % mod\n\tprint(pow(x, n, mod))\n\n\nBUFSIZE = 8192\nclass FastI(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = StringIO()\n\t\tself.newlines = 0\n \n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(\"\\n\") + (not b)\n\t\t\tptr = self._buffer.tell()\n\t\t\tself._buffer.seek(0, 2), self._buffer.write(\n\t\t\t\tb), self._buffer.seek(ptr)\n\t\tself.newlines -= 1\n\t\treturn self._buffer.readline()\nclass FastO(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = __pypy__.builders.StringBuilder()\n\t\tself.write = lambda s: self._buffer.append(s)\n \n\tdef flush(self):\n\t\tos.write(self._fd, self._buffer.build())\n\t\tself._buffer = __pypy__.builders.StringBuilder()\ndef print(*args, **kwargs):\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n\tat_start = True\n\tfor x in args:\n\t\tif not at_start:\n\t\t\tfile.write(sep)\n\t\tfile.write(str(x))\n\t\tat_start = False\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\n\tif kwargs.pop(\"flush\", False):\n\t\tfile.flush()\ndef gcd(x, y):\n\twhile y:\n\t\tx, y = y, x % y\n\treturn x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n\tdef bootstrap(cont):\n\t\tcall, arg = cont.switch()\n\t\twhile True:\n\t\t\tcall, arg = cont.switch(to=continulet(\n\t\t\t\tlambda _, f, args: f(*args), call, arg))\n\tcont = continulet(bootstrap)\n\tcont.switch()\n\tmain()"}, {"source_code": "input = __import__(\"sys\").stdin.readline\npresents, boxes = map(int, input().split())\nprint(pow((2 ** boxes - 1), presents, 1000000007))"}, {"source_code": "n,m = map(int,input().split())\nM = (10**9) +7\n\nprint(pow((pow(2,m,M) -1),n,M))"}, {"source_code": "'''input\n2 2\n\n'''\n \nfrom bisect import bisect_right as bl\nfrom random import randint as R\nRI = lambda : [int(_x) for _x in raw_input().split()]\n \nmod = 10**9 + 7\n \nfor _ in range(1):\n\ta,b = RI()\n\tans = pow(2,b,mod)-1\n\tans = pow(ans,a,mod)\n\tprint ans%mod"}, {"source_code": "mod = int(1e9+7)\nn,m = map(int,raw_input().split(\" \"))\n\n\ndef fast(a,b):\n ans = 1\n base = a\n while b:\n if b%2:\n ans= (base*ans)%mod\n b/= 2\n base = (base*base)%mod\n return ans\n\n\ntmp = fast(2,m)-1\nprint fast(tmp,n)\n"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef factorial_mod(n, p):\n res = 1\n while n > 1:\n res = (res * (p - 1 if (n // p) % 2 == 1 else 1)) % p\n for i in range(2, (n % p) + 1):\n res = (res * i) % p\n n //= p\n return res % p\n\n\ndef main():\n n, m = map(int, input().split())\n\n mod = 10 ** 9 + 7\n\n print(pow((pow(2, m, mod) - 1) % mod, n, mod))\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from sys import stdin\n\nmod = 1000000007\n\n\ndef pow1(x, base):\n sq = 1\n while (base > 0):\n\n if base % 2:\n base -= 1\n sq = (sq * x) % mod\n\n base //= 2\n x = (x * x) % mod\n\n return sq\n\n\nn, m = map(int, stdin.readline().split())\nprint(pow1(pow1(2, m) - 1, n))\n"}, {"source_code": "from __future__ import division, print_function\nimport sys\nmo=10**9+7\nm,n=map(int,raw_input().split())\n\nprint(pow(pow(2,n,mo)-1,m,mo))\n"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 10**9 + 7\n\nn,m = [int(x) for x in input().split()]\n\n\n\nprint pow(pow(2, m, MOD) - 1, n, MOD)\n"}, {"source_code": "a,b=map(int,input().split())\nprint(pow(pow(2,b,10**9+7)-1,a,10**9+7))"}, {"source_code": "xx=1000000007\nA,B=[int(j) for j in input().split()]\nkk=int(pow(2,B,xx))-1\nll=pow(kk,A,xx)\nprint(ll)"}, {"source_code": "n,m=map(int,input().split())\nM=10**9+7\nprint(pow(pow(2,m,M)-1,n,M))"}, {"source_code": "def power(x, y, p) : \n res = 1 \n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1\n x = (x * x) % p \n \n return res \nn, m = [int(p) for p in input().split()]\nmod = 10**9+7\n\ntemp = power(2, m, mod)\ntemp -= 1%mod\ntemp = temp%mod\nans = power(temp, n, mod)\nprint(ans)"}, {"source_code": "mod = 10**9+7\nn,m = map(int,input().split())\nans = pow(2,m,mod) - 1\nans = ans%mod\nans = pow(ans,n,mod)\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nprint(pow(pow(2,m,10**9+7)-1,n,10**9+7))"}, {"source_code": "n,m=map(int,input().split())\nmod=1000000007;\ny=pow((pow(2,m,mod)-1)%mod,n,mod)\nprint(y)\n"}, {"source_code": "x = input()\nn = int(x.split(\" \")[0])\nm = int(x.split(\" \")[1])\nmox = int(1e9 + 7)\n \nprint((pow(((pow(2, m, mox) - 1 + mox) % mox), n, mox)))"}, {"source_code": "n, m = map(int, input().split())\nM = 1000000007\nx = (pow(2, m, M) - 1 + M) % M\nprint(pow(x, n, M))\n"}, {"source_code": "mod=1000000007\nn,m=map(int,input().split())\nx=pow(2,m,mod)\nx-=1\np=pow(x,n,mod)\nprint(p%mod)\n#print(((((2**m)-1)%mod)**n)%mod)"}, {"source_code": "n,m = map(int, input().split())\nmo = 10**9 + 7\nres = pow(2, m, mo)\nres %= mo\nres -= 1\nres = pow(res, n, mo)\nres %= mo\nprint(res)"}, {"source_code": "l = input().split()\nn = int(l[0])\nm = int(l[1])\n\nmod = 1000000007\n\nt1 = pow(2,m,mod) - 1\nt2 = pow(t1,n,mod)\nprint(t2)"}, {"source_code": "n, m = map(int, input().split())\np = 10**9 + 7\nprint(pow((pow(2, m, p) - 1), n, p))\n"}, {"source_code": "n,m=map(int,input().split())\nM=1000000007\nprint( pow((pow(2,m,M)-1+M)%M,n,M) )"}, {"source_code": "a,b=map(int,input().strip().split())\nprint(pow(2**b-1,a,10**9+7))\n"}, {"source_code": "n, m = map(int, input().split())\n\nmod = 10**9+7\n\nres1 = (pow(2,m,mod)-1)\nres = pow(res1,n,mod)\n\nprint(res%mod)"}, {"source_code": "n , m = map(int,input().split())\nb = int(pow(2,m,1000000007))\nan = pow(b-1,n,1000000007)\nprint(int(an))"}, {"source_code": "n,m = map(int,input().split())\nprint(pow(2**m-1, n, 10**9+7))"}, {"source_code": "n, m = map(int, input().split())\n\ndef powerMod(base, exp):\n if exp == 0: return 1\n if exp == 1: return base\n ret = powerMod(base, exp//2)\n if exp % 2: \n ret = (ret * ret * base) % 1000000007\n else:\n ret = (ret * ret) % 1000000007\n\n return ret\n\nbase = powerMod(2, m) - 1\n\nans = powerMod(base, n)\nprint(ans)\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\n'''\n\n'''\n\ndef powmod(base, exp, mod):\n if exp <= 1:\n return base**exp\n elif exp % 2:\n return (base * powmod(base, exp-1, mod)) % mod\n else:\n return (powmod(base, exp//2, mod))**2 % mod\n\nMOD = 10**9+7\n\nn, m = map(int, input().split())\nt = pow(2, m, MOD)-1 % MOD\nprint(powmod(t, n, MOD))"}, {"source_code": "def power(x,y,p): #Calculates (x**y)%p in O(log y)\n res = 1\n x = x%p\n\n while y>0:\n if ((y & 1)==1):\n res = (res*x)%p\n\n y = y>>1\n x = (x*x)%p\n\n return res\n\n\nn,m = map(int, input().split())\nprint(power((2**m)-1,n,10**9+7))"}, {"source_code": "import math\nn , m = map(int , input().split())\nMOD = int(1e9 + 7)\nans = 1;\nmy = pow(2,m,MOD)-1;\nprint(pow(my,n,MOD))\n"}, {"source_code": "s=input().split()\nn=int(s[0])\nm=int(s[1])\nmod=10**9+7\nprint(pow((pow(2,m,mod)-1),n,mod))"}, {"source_code": "n, m = list(map(int, input().split()))\n\nmod = int(1e9) + 7\n\nans = 1\n\na1 = ((pow(2, m, mod) - 1) + mod) % mod\nans = pow(a1, n, mod)\n\nprint(ans)"}, {"source_code": "a,b=map(int,input().split())\nm=7+10**9\nans=(pow(2,b,m)-1)%m\nans= (pow(ans,a,m))%m\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nmod=1000000007\nans=(pow(2,m,mod)-1+mod)%mod\nans=pow(ans,n,mod)\nprint(ans)"}, {"source_code": "def binpow(a, n):\n if n == 0:\n return 1\n if n % 2 == 1:\n return binpow(a, n-1) % 1000000007 * a % 1000000007\n else:\n b = binpow(a, n // 2) % 1000000007\n return (b * b) % 1000000007\n\n\nn, m = map(int, input().split())\nprint(binpow((binpow(2, m) % 1000000007 - 1), n) % 1000000007)\n"}, {"source_code": "n,m=list(map(int,input().split()))\nM=pow(10,9)+7\na=pow(2,m,M)-1\na=a%M\nb=pow(a,n,M)\nprint(b)"}, {"source_code": "def power(x, y, p) : \n res = 1 # Initialize result \n \n # Update x if it is more \n # than or equal to p \n x = x % p \n \n while (y > 0) : \n \n # If y is odd, multiply \n # x with result \n if ((y & 1) == 1) : \n res = (res * x) % p \n \n # y must be even now \n y = y >> 1 # y = y/2 \n x = (x * x) % p \n \n return res \nimport math\n#q=int(input())\nq=1\nfor _ in range(q):\n mod=10**9+7\n n,m=map(int,input().split())\n c=(power(2, m, mod)-1)%mod\n ans=power(c,n,mod)%mod\n print(ans%mod) \n "}, {"source_code": "n,m=map(int,input().split())\ndef fun(x,y,m):\n res=1\n while y>0:\n if y%2==1:\n res=(res*x)%m\n y//=2\n x=(x*x)%m\n return res\ntot = fun(2,m,10**9+7)-1\nprint(fun(tot,n,10**9+7))"}, {"source_code": "from sys import stdin, stdout\nimport math,sys,heapq\nfrom itertools import permutations, combinations\nfrom collections import defaultdict,deque,OrderedDict\nfrom os import path\nimport random\nimport bisect as bi\ndef yes():print('YES')\ndef no():print('NO')\nif (path.exists('input.txt')): \n #------------------Sublime--------------------------------------#\n sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\n def I():return (int(input()))\n def In():return(map(int,input().split()))\nelse:\n #------------------PYPY FAst I/o--------------------------------#\n def I():return (int(stdin.readline()))\n def In():return(map(int,stdin.readline().split()))\n#sys.setrecursionlimit(1500)\ndef dict(a):\n d={} \n for x in a:\n if d.get(x,-1)!=-1:\n d[x]+=1\n else:\n d[x]=1\n return d\ndef find_gt(a, x):\n 'Find leftmost value greater than x'\n i = bi.bisect_left(a, x)\n if i != len(a):\n return i\n else: \n return -1\n\ndef power(x, y, p): \n res = 1; \n x = x % p; \n while (y > 0): \n \n if (y & 1): \n res = (res * x) % p; \n y = y >> 1; \n x = (x * x) % p; \n \n return res; \ndef main():\n try:\n n,m=In()\n temp=power((power(2,m,P)-1),n,P)\n print(temp)\n\n except:\n pass\n \nM = 998244353\nP = 1000000007\n \nif __name__ == '__main__':\n #for _ in range(I()):main()\n for _ in range(1):main()"}, {"source_code": "n,m = map(int,input().strip().split())\nbox1 = pow(2,m,10**9 + 7) - 1# summation of N Ci - 1\nnbox = pow(box1,n,10**9 + 7) # for n boxes\nprint(str(nbox))"}, {"source_code": "from sys import *\nmod=10**9+7\nn,k=map(int,input().split())\nprint(pow(2**k-1,n,mod))"}, {"source_code": "N, M = map(int, input().split())\nmod = 10 ** 9 + 7\n\nans = pow(2, M, mod) - 1\nans = pow(ans, N, mod)\nprint(ans % mod)\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\n# from math import *\nfrom collections import *\n# from fractions import *\nfrom heapq import*\nfrom bisect import *\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=10**9+7\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\n# vsInput()\n\n\nn,m=value()\n\nans=pow(2,m,M)-1\nprint(pow(ans,n,M))\n\n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "}, {"source_code": "n,m=map(int,input().split())\nprint(pow(2**m-1,n,10**9+7))"}, {"source_code": "try:\n arr = [int(x) for x in input().split()] \n mod = 1000000007\n var = pow(2,arr[1],mod) - 1\n ans = pow(var,arr[0],mod)\n print(ans)\n\nexcept ValueError:\n pass\n"}, {"source_code": "import math\nlist1=[int(x) for x in input().split(' ')]\nn=list1[0]\nm=list1[1]\nprint(pow((pow(2,m,10**9+7)-1),n,10**9+7))\n"}, {"source_code": "import sys\n\ndef msub(a,b,mod):\n\treturn ((a%mod)-(b%mod)+mod)%mod\n\n[n,m]=[int(i) for i in sys.stdin.readline().split()]\n\nmod=pow(10,9)+7\n\nprint(pow(msub(pow(2,m,mod),1,mod),n,mod))"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n \nfrom types import GeneratorType\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n import os\n self.os = os\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n self.os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \nimport time\nstart_time = time.time()\n\nimport collections as col\nimport math\nfrom functools import reduce\n\ndef getInts():\n return [int(s) for s in input().split()]\n\ndef getInt():\n return int(input())\n\ndef getStrs():\n return [s for s in input().split()]\n\ndef getStr():\n return input()\n\ndef listStr():\n return list(input())\n\nMOD = 10**9+7\n\n\"\"\"\n\n\"\"\"\n\ndef solve():\n N, M = getInts()\n return pow(pow(2,M,MOD)-1,N,MOD)\n \n \n#for _ in range(getInt()): \nprint(solve())\n\n \n"}, {"source_code": "n, m = map(int, input().split())\nmod = 1000000007\nx = int(pow(2, m))-1\ny = pow(x, n, mod)\nprint(y)"}, {"source_code": "inp=[int(x) for x in input().split()]\nn,m=inp[0], inp[1]\nprint(pow(pow(2,m,10**9 + 7)-1, n, 10**9 + 7))"}], "negative_code": [{"source_code": "import sys\n\ndef mmul(a,b,mod):\n\treturn ((a%mod)*(b%mod))%mod\n\ndef msub(a,b,mod):\n\treturn (a%mod-b%mod+mod)%mod\n\n[n,m]=[int(i) for i in sys.stdin.readline().split()]\n\nmod=pow(10,9)+7\n\ns_tmp=msub(pow(2,(n-1)*m,mod),1,mod)\n\nsub_val=mmul(n,s_tmp,mod)\n\ntmp=msub(pow(2,n*m,mod),1,mod)\n\nprint(msub(tmp,sub_val,mod))"}, {"source_code": "n,m=map(int,input().split())\nans=0\nif(n==1):\n ans=(pow(2,n*m,1000000007)-1+1000000007)%1000000007\nelse :\n ans=(pow(2,n*m,1000000007)-((n*pow(2,(n-1)*m,1000000007))%1000000007)+1000000007)%1000000007+1\nans=ans%1000000007\nprint(ans)"}, {"source_code": "mod= 10**9 +7\n\ndef power(a,b):\n ans=1\n while(b>0):\n if(b%2!=0):\n ans=ans*a%mod\n b=b>>2\n a=a*a\n ans=ans*a%mod\n return ans\n\n(n,m)=[int(x) for x in input().split()]\nres=power(2,m)-1\nres=power(res,n)\nprint(res%mod)"}, {"source_code": "n, m = list(map(int, input().split()))\n\nmod = int(10e9) + 7\n\nans = 1\n\na1 = ((pow(2, m, mod) - 1) + mod) % mod\nans = pow(a1, n, mod)\n\nprint(ans)"}, {"source_code": "n,m = map(int,input().split())\nprint(pow(2**m-1, n, 10**+7))"}, {"source_code": "import sys\n\ndef mmul(a,b,mod):\n\treturn ((a%mod)*(b%mod))%mod\n\ndef msub(a,b,mod):\n\treturn (a%mod-b%mod+mod)%mod\n\n[n,m]=[int(i) for i in sys.stdin.readline().split()]\n\nmod=pow(10,9)+7\n\n# mul1=mmul(pow(2,n-1,mod),pow(2,m,mod),mod)\nmul1=pow(pow(2,n-1,mod),m,mod)\n\ns_tmp=msub(mul1,1,mod)\n\nsub_val=mmul(n,s_tmp,mod)\n\n# mul2=mmul(pow(2,n,mod),pow(2,m,mod),mod)\nmul2=pow(pow(2,n,mod),m,mod)\n\ntmp=msub(mul2,1,mod)\n\nprint(msub(tmp,sub_val,mod))"}, {"source_code": "inp = [int(x) for x in input().split()]\nans = pow(inp[1]**2-1, inp[0], 10**9+7)\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\nmax = 10**9+7\nx = pow(2,m,max)-1\nif x == 1:\n ans = pow(2,n,max) - 1\n print(ans%max)\nelse:\n ans = pow(x,n,max)\n print(ans%max)"}, {"source_code": "M = 1e9 +7\n\ndef pw(x,y):\n s=1\n x%=M\n while y:\n if y & 1: s=(s*x)%M\n x=(x*x)%M\n y>>=1\n return s\n\nn, m = map(int, input().split())\nprint(int(pw(pw(2,m)-1, n)))"}, {"source_code": "n,m = map(int, input().split())\nmo = 10*9 + 7\nres = pow(2, m, mo) -1\nres = pow(res, n, mo)\nres %= mo\nprint(res)"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\n# from math import *\nfrom collections import *\n# from fractions import *\nfrom heapq import*\nfrom bisect import *\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=10**9\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\n# vsInput()\n\n\nn,m=value()\n\nans=pow(2,m,M)-1\nprint(pow(ans,n,M))\n\n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "}, {"source_code": "ar = []\nfor x in input().split(' '):\n ar.append(int(x))\ncurr = pow(pow(2, ar[1], 100000000000)-1, ar[0], 1000000007)\nprint(curr)"}, {"source_code": "n,m = map(int, input().split())\nmo = 10*9 + 7\nres = pow(2, m, mo) -1\nres = pow(res, n, mo)\nres %= mo\nprint(res)"}, {"source_code": "import sys,math,fractions,bisect\ndef fi():\n return int(sys.stdin.readline())\n\ndef fi2():\n return map(int, sys.stdin.readline().split())\n\ndef fi3():\n return sys.stdin.readline()\n\ndef fo(*args):\n for s in args:\n sys.stdout.write(str(s)+' ')\n sys.stdout.write('\\n')\nINF=10**9+7\nsys.setrecursionlimit(INF)\n\n#main\nn,m=fi2()\nx=math.pow(2,m)\nres=math.pow(x-1,n)\nfo(res)\n \n \n \n\n \n \n\n \n \n\n \n \n \n \n \n \n \n\n\n\n\n \n \n\n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n\n\n\n \n \n \n \n \n"}, {"source_code": "def bin_pow(base, p):\n MOD = 1000000007\n base = int(base)\n p = int(p)\n if(p == 1):\n return base \n\n if(p % 2 == 0):\n t = int(bin_pow(base, p // 2))\n return t * t % MOD\n\n else:\n return bin_pow(base, p - 1) * base % MOD\n\n\nvalues = input().split()\nn = int(values[0])\nm = int(values[1])\nif(n == 1):\n print(bin_pow(2, n*m) - bin_pow(2, n) + 1)\nelse:\n print(bin_pow(2, n*m) - bin_pow(2, n + 1) + 1)"}, {"source_code": "n, m = list(map(int,input().split()))\n \nprint((n*(2**(m)-1))%(10**(9)+7))"}, {"source_code": "ar = []\nfor x in input().split(' '):\n ar.append(int(x))\ncurr = pow(pow(2, ar[1], 100000000000)-1, ar[0], 1000000007)\nprint(curr)"}, {"source_code": "mod=1000000007\ndef power(x,y):\n\tres=1\n\twhile y>0:\n\t\tif y%2==1:\n\t\t\tres=(res*x)%mod \n\t\ty=y//2 \n\t\tx=(x*x)%mod\n\treturn res\nn,m=map(int,input().split())\nif n==1:\n\tprint((power(2,m)%mod)-1)\n\texit()\nxx=((n*(n+1))%mod)\nyy=(xx*power(2,mod-2))%mod \nans=power(yy,m)%mod \nprint(ans)"}, {"source_code": "N,M = map(int,input().split())\nmod = 10**9 + 7\n'''\nN : the number of kind of presents \nM : The number of boxes\nanswer = (2 ** M - 1) ** N \nBut, N and M have range 10~9 ..\n'''\ndef solve(a,x):\n num = str(format(x,'b'))\n ret = 1\n for i in range(-1,len(num)):\n if num[i] == '1':\n ret = ret * a % mod\n a = a * a % mod\n return ret\na = solve(2,M) - 1\nans = solve(a,N)\nprint(ans)"}, {"source_code": "n,m = map(int, input().split(\" \"))\nres = 1\n\ndef power(x, y, p) : \n res = 1\n x = x % p \n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1\n x = (x * x) % p \n return res\n \nres = power(2,m,1000000007)\nif res == 0:\n res = 1000000007 - 1\nelse:\n res = res - 1\nres1 = power(res,n,100000007)\nprint(res1)"}, {"source_code": "def quickpow(a,b):\n mod=1e9+7\n ret=1\n while(b):\n if(b&1):\n ret=ret*a%mod\n a=a*a%mod\n b>>=1\n return ret\ns=input().split()\nn=int(s[0])\nm=int(s[1])\nans=quickpow(2,m)\nans-=1\nans=quickpow(ans,n)\nans=int(ans)\nprint(ans)"}, {"source_code": "\n\ndef power(x, y) : \n res = 1 \n\n p = 10**9 + 7\n \n x = x % p \n \n while (y > 0) : \n \n \n if ((y & 1) == 1) : \n res = (res * x) % p \n \n \n y = y >> 1\n x = (x * x) % p \n \n return res\n\nn,m = list(map(int,input().split()))\nmod = 10**9 + 7\nans = 0\nans = (ans + power(2,m*n+1))%mod\nans = (ans - power(power(2,m)+1,n))%mod\nans = (ans + power(2,n) - 2)%mod\n\n\nprint(ans)\n\n"}, {"source_code": "mod=1000000007\ndef power(x,y):\n\tres=1\n\twhile y>0:\n\t\tif y%2==1:\n\t\t\tres=(res*x)%mod \n\t\ty=y//2 \n\t\tx=(x*x)%mod\n\treturn res\nn,m=map(int,input().split())\nif n==1:\n\tprint((power(2,m)%mod)-1)\n\texit()\nxx=((n*(n+1))%mod)\nyy=(xx*power(2,mod-2))%mod \nans=power(yy,m)%mod \nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\np = 10**9 + 7\nprint(pow(pow(2, m, p) + m - 1, n, p))"}, {"source_code": "def I(): return(list(map(int,input().split())))\nn,m=I()\nx=pow(2,m)\nprint(pow(x-1,m,1000000007))\n"}, {"source_code": "N, M = map(int, input().split())\nmod = 10 ** 9 + 7\n\nans = pow(pow(2, M, mod), N, mod)\nans %= mod\nans -= N * pow(pow(2, M, mod), N - 1, mod)\nans %= mod\nans += (N - 1)\nans %= mod\nprint(ans)\n"}, {"source_code": "from sys import stdin,stdout\nI = lambda : map(int,stdin.readline().split())\n\ndef nCr(n, r, p): \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den,p - 2, p)) % p \n\nn,m = I()\nmod = 10**9 + 7\nans1 = pow(2,n,mod) - 1\nans2 = pow(2,m,mod) - 1\nprint (ans1*ans2)%mod"}, {"source_code": "n,m=map(int,input().split())\nx=(2**((n*m)+1))\ny=(2**m+1)**n\nprint((x-y)%(1000000007))\n"}, {"source_code": "a,b=map(int,input().split())\nmod = 10**9+7\nprint((pow(2,a,mod)*b+1)%mod)"}, {"source_code": "N, M = map(int, input().split())\nmod = 10 ** 9 + 7\n\nans = pow(pow(2, M, mod), N, mod)\nans %= mod\nans -= N * pow(pow(2, M, mod), N - 1, mod)\nif ans < 0:\n ans += mod\nans %= mod\nans += (N - 1)\nans %= mod\nprint(ans)\n"}, {"source_code": "mod = 10 ** 9 + 7\n\ndef binpow(a, n):\n pw = a\n res = 1\n while n > 0:\n if n % 2 == 1:\n res *= pw\n res %= mod\n n //= 2\n pw *= a\n pw %= mod\n return res\n\n\nn, m = map(int, input().split())\nb = binpow(2, m) - 1\nprint(binpow(b, n))\n"}, {"source_code": "import sys\ninputfn = sys.stdin.readline\n\ndef fastExp(A, E, N):\n\tif (E == 0):\n\t\treturn 1\n\tif (E == 1):\n\t\treturn A % N\n\trec = fastExp(A, E // 2, N)\n\trec = (rec * rec) % N\n\tif (E % 2 == 0):\n\t\treturn rec\n\treturn ((A % N) * rec) % N\n\n\nnm = inputfn().split(\" \")\nn = int(nm[0])\nm = int(nm[1])\n\nmodulus = 10**9 + 7\ngifts = fastExp(2, n, modulus) - 1\nboxes = fastExp(2, m, modulus) - 1\nprint((gifts * boxes) % modulus)\n"}, {"source_code": "n, m = map(int, input().split())\nmax = 10**9+7\nx = pow(2,n,max)-1\nif x == 1:\n ans = pow(2,m,max) - 1\n print(ans%max)\nelse:\n ans = pow(x,m,max)\n print(ans%max)"}, {"source_code": "modulo = (pow(10, 9) + 7)\nn, m = [int(x) for x in input().split()]\nprint((pow(2, n*m, modulo) - n * pow(2, (n-1)*m, modulo) + (n - 1)) % modulo)\n"}, {"source_code": "n, m = map(int, input().split())\n\nmod = 10**9+7\n\nres = pow(2,n*m,mod) - (n*pow(2,(n-1)*m,mod))%mod + (n-1)%mod\n\nprint(res%mod)"}, {"source_code": "n, m = map(int, input().split())\nmax = 10**9+7\nx = pow(2,n,max)-1\nif x == 1:\n ans = pow(2,m,max) - 1\n print(ans%max)\nelse:\n ans = pow(x,m,max)\n print(ans%max)"}, {"source_code": "n, m = [int(i) for i in input().split(' ')]\nprint(((2**m)**n + 1)%(10**9 + 7))"}, {"source_code": "n,m=map(int,input().split())\nprint(((2**m-1)**n)%10**9+7)"}, {"source_code": "mod=1000000007\ndef power(x,y):\n\tres=1\n\twhile y>0:\n\t\tif y%2==1:\n\t\t\tres=(res*x)%mod \n\t\ty=y//2 \n\t\tx=(x*x)%mod\n\treturn res\nn,m=map(int,input().split())\nif n==1:\n\tprint(power(n+1,m)-1)\nelse:\n\tprint(power(n+1,m))\n\t"}, {"source_code": "from sys import stdin\n\nmod = 1000000007\n\n\ndef pow1(x, base):\n sq = 1\n while (base > 0):\n\n if base % 2:\n base -= 1\n sq = (sq * x) % mod\n\n base //= 2\n x = (x * x) % mod\n\n return sq\n\n\nn, m = map(int, stdin.readline().split())\nprint(pow1(pow1(2, n), m) - (pow1(2, pow1(2, n) - 1) - 1))\n"}, {"source_code": "n, m = list(map(int, input().split()))\n\nmod = int(10e9) + 7\n\nans = 1\n\na1 = ((pow(2, m, mod) - 1) + mod) % mod\nans = pow(a1, n, mod)\n\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\nmax = 10**9+7\nx = pow(2,m,max)-1\nif x == 1:\n ans = pow(2,n,max) - 1\n print(ans%max)\nelse:\n ans = pow(x,n,max)\n print(ans%max)"}, {"source_code": "n,m=map(int,input().split())\nmod=1000000007\nx=(1<<n)\nans=((m%mod)*(x%mod))%mod\nans=((ans%mod) + (1%mod))%mod\nprint(ans)"}, {"source_code": "presents, boxes = map(int, input().split())\nprint( pow(pow(2, boxes, 10**9+1) - 1, presents, 10**9+1) )"}, {"source_code": "mod= 10**9 +7\n\ndef power(a,b):\n ans=1\n while(b>0):\n if(b%2!=0):\n ans=ans*a%mod\n b=b>>1\n a=a*a%mod\n ans=ans*a%mod\n return ans\n\n(n,m)=[int(x) for x in input().split()]\nres=power(2,m)-1\nres=power(res,n)\nprint(res%mod)"}, {"source_code": "n,m=map(int,input().split())\nmod=1000000007\nx=(1<<n)\nans=((m%mod)*(x%mod))%mod\nans+=1\nprint(ans%mod)"}, {"source_code": "s=input().split()\nn=int(s[0])\nm=int(s[1])\nx=pow(2,m)\ny=pow(x-1,n,10007)\nprint(y) "}, {"source_code": "n,m = map(int, input().split())\nmo = 10*9 + 7\nres = pow(2, m, mo)\nres %= mo\nres -= 1\nres = pow(res, n, mo)\nres %= mo\nprint(res)"}, {"source_code": "n, m = map(int, input().split())\nprint((n*m)*2 + 1)"}, {"source_code": "if __name__==\"__main__\":\n n,m=[int(x) for x in input().split()]\n\n mod=(10**9)+7\n\n np=pow(2,n,mod)-1\n mp=pow(2,m,mod)-1\n ans=((np%mod)*(mp%mod))%mod\n print(ans)\n"}, {"source_code": "A, B = map(int, input().split())\nMOD = int(1e9)+7\nrtot = pow(pow(2, A, MOD), B, MOD) - 1\nrpart = pow(pow(2, A-1, MOD), B, MOD) - 1\nrpart *= A\nrpart %= MOD\nrtot %= MOD\nprint (rtot-rpart%MOD)\n"}, {"source_code": "n,m = map(int,input().split())\nprint(pow(2**m-1, n, 10**+7))"}, {"source_code": "n,m = map(int,input().split())\np = (int)(1e9+7)\nprint(((pow(2,n,p)-1)*(pow(2,m,p)-1))%p)"}, {"source_code": "import sys\ninputfn = sys.stdin.readline\n\ndef fastExp(A, E, N):\n\tif (E == 0):\n\t\treturn 1\n\tif (E == 1):\n\t\treturn A % N\n\trec = fastExp(A, E // 2, N)\n\trec = (rec * rec) % N\n\tif (E % 2 == 0):\n\t\treturn rec\n\treturn ((A % N) * rec) % N\n\n\nnm = inputfn().split(\" \")\nn = int(nm[0])\nm = int(nm[1])\n\nmodulus = 10**9 + 7\ngifts = fastExp(2, n, modulus) - 1\nboxes = fastExp(2, m, modulus) - 1\nprint((gifts * boxes) % modulus)\n"}, {"source_code": "MOD = 10 ** 9 + 7\ndef power(a, n):\n if n == 0:\n return 1\n if n % 2 == 0:\n return power(a, n // 2) ** 2 % MOD\n return power(a, n - 1) * a\n\n\nn, m = map(int, input().split())\nprint(power(power(2, m) + MOD - 1, n))\n"}, {"source_code": "ar = []\nfor x in input().split(' '):\n ar.append(int(x))\ncurr = pow(pow(2, ar[1], 100000000007)-1, ar[0], 1000000007)\nprint(curr)\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom random import randint\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nimport sys\nimport os\nimport re\nsys.setrecursionlimit(9999)\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\nN = 5001\n\n'''\nCheck for special cases (n=1)\nOne wrong submission = 10 mins penalty!\ndo smth instead of nothing and stay organized\n'''\n\n\ndef main():\n\tn, m = map(int, input().split())\n\ta = pow(2, n*m, mod)\n\tb = pow(2, (n-1)*m, mod)\n\tb = (b * n) % mod\n\tb = (b - (n-1) + mod) % mod\n\ttotal = max(0, a - b) % mod\n\tprint(total)\n\n\nBUFSIZE = 8192\nclass FastI(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = StringIO()\n\t\tself.newlines = 0\n \n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(\"\\n\") + (not b)\n\t\t\tptr = self._buffer.tell()\n\t\t\tself._buffer.seek(0, 2), self._buffer.write(\n\t\t\t\tb), self._buffer.seek(ptr)\n\t\tself.newlines -= 1\n\t\treturn self._buffer.readline()\nclass FastO(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = __pypy__.builders.StringBuilder()\n\t\tself.write = lambda s: self._buffer.append(s)\n \n\tdef flush(self):\n\t\tos.write(self._fd, self._buffer.build())\n\t\tself._buffer = __pypy__.builders.StringBuilder()\ndef print(*args, **kwargs):\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n\tat_start = True\n\tfor x in args:\n\t\tif not at_start:\n\t\t\tfile.write(sep)\n\t\tfile.write(str(x))\n\t\tat_start = False\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\n\tif kwargs.pop(\"flush\", False):\n\t\tfile.flush()\ndef gcd(x, y):\n\twhile y:\n\t\tx, y = y, x % y\n\treturn x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n\tdef bootstrap(cont):\n\t\tcall, arg = cont.switch()\n\t\twhile True:\n\t\t\tcall, arg = cont.switch(to=continulet(\n\t\t\t\tlambda _, f, args: f(*args), call, arg))\n\tcont = continulet(bootstrap)\n\tcont.switch()\n\tmain()"}, {"source_code": "def I(): return(list(map(int,input().split())))\nn,m=I()\nx=pow(2,m)\nprint(pow(x-1,m,1000000007))\n"}, {"source_code": "n,m = map(int, input().split())\nmo = 10*9 + 7\nres = pow(2, m, mo)\nres %= mo\nres -= 1\nres = pow(res, n, mo)\nres %= mo\nprint(res)"}, {"source_code": "n,m = map(int,input().split())\np = (int)(1e9+7)\nprint(((pow(2,n,p)-1)*(pow(2,m,p)-1))%p)"}, {"source_code": "mod = pow(10, 9) + 7\nn, box = map(int,input().split())\nprint(pow((pow(2, box) - 1),n) // mod)"}, {"source_code": "from collections import defaultdict, deque\nfrom itertools import permutations\nfrom sys import stdin,stdout\nfrom bisect import bisect_left, bisect_right\nfrom copy import deepcopy\n\n#from random import randint\n\nint_input=lambda : int(stdin.readline())\nstring_input=lambda : stdin.readline()\nmulti_int_input =lambda : map(int, stdin.readline().split())\nmulti_input = lambda : stdin.readline().split()\nlist_input=lambda : list(map(int,stdin.readline().split()))\nstring_list_input=lambda: list(string_input())\nMOD = pow(10,9)+7\n\nn,m = multi_int_input()\n\ndef power(x, y, p) : \n res = 1 # Initialize result \n \n # Update x if it is more \n # than or equal to p \n x = x % p \n \n while (y > 0) : \n \n # If y is odd, multiply \n # x with result \n if ((y & 1) == 1) : \n res = (res * x) % p \n \n # y must be even now \n y = y >> 1 # y = y/2 \n x = (x * x) % p \n \n return res\n\nprint(pow((2**n-1),m,MOD))"}, {"source_code": "def bin_pow(base, p):\n MOD = 1000000007\n base = int(base)\n p = int(p)\n if(p == 1):\n return base \n\n if(p % 2 == 0):\n t = int(bin_pow(base, p // 2))\n return t * t % MOD\n\n else:\n return bin_pow(base, p - 1) * base % MOD\n\n\nvalues = input().split()\nn = int(values[0])\nm = int(values[1])\nif(n == 1):\n print(bin_pow(2, n*m) - bin_pow(2, n) + 1)\nelse:\n print(bin_pow(2, n*m) - bin_pow(2, n + 1) + 1)"}, {"source_code": "n, m = map(int, input().split())\n\ndef powerMod(base, exp):\n if exp == 0: return 1\n if exp == 1: return base\n ret = powerMod(base, exp//2)\n if exp % 2: \n ret = (ret * ret * base) % 10000000007\n else:\n ret = (ret * ret) % 10000000007\n\n return ret\nbase = powerMod(2, m) - 1\n\nans = powerMod(base, n)\nprint(ans)\n"}, {"source_code": "MOD = 10 ** 9 + 7\ndef pw(a, b):\n global mod\n if b == 1:\n return a\n elif b == 0:\n return 1\n if b % 2 == 0:\n return pw(a * a % MOD, b // 2) \n else:\n return pw(a * a % MOD , b // 2) * a\n \na, b = [int(x) for x in input().split()]\nif (a == 1):\n pow1 = 2\nelse:\n pow1 = (a * a) % MOD\nif (a == 2):\n pow2 = 2\nelse:\n pow2 = ((a - 1) * (a - 1)) % MOD\nans1 = (pw(pow1, b)) % MOD\nans2 = (max(pw(pow2, b) - 1, 0) * b) % MOD\nprint(((ans1 - ans2) % MOD) - 1)"}, {"source_code": "def power(x, y, p) : \n res = 1 # Initialize result \n \n # Update x if it is more \n # than or equal to p \n x = x % p \n \n while (y > 0) : \n \n # If y is odd, multiply \n # x with result \n if ((y & 1) == 1) : \n res = (res * x) % p \n \n # y must be even now \n y = y >> 1 # y = y/2 \n x = (x * x) % p \n \n return res \nimport math\n#q=int(input())\nq=1\nfor _ in range(q):\n mod=10**7+9\n n,m=map(int,input().split())\n ans=(power(2, m, mod)-1)%mod\n ans=power(ans,n,mod)%mod\n print(ans%mod) \n "}, {"source_code": "A, B = map(int, input().split())\nMOD = int(1e9)+7\nrtot = pow(pow(2, A, MOD), B, MOD) - 1\nrpart = pow(pow(2, A-1, MOD), B, MOD) - 1\nrpart *= A\nrpart %= MOD\nrtot %= MOD\nprint (rtot-rpart%MOD)\n"}, {"source_code": "from sys import stdin, stdout\nimport math,sys,heapq\nfrom itertools import permutations, combinations\nfrom collections import defaultdict,deque,OrderedDict\nfrom os import path\nimport random\nimport bisect as bi\ndef yes():print('YES')\ndef no():print('NO')\nif (path.exists('input.txt')): \n #------------------Sublime--------------------------------------#\n sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\n def I():return (int(input()))\n def In():return(map(int,input().split()))\nelse:\n #------------------PYPY FAst I/o--------------------------------#\n def I():return (int(stdin.readline()))\n def In():return(map(int,stdin.readline().split()))\n#sys.setrecursionlimit(1500)\ndef dict(a):\n d={} \n for x in a:\n if d.get(x,-1)!=-1:\n d[x]+=1\n else:\n d[x]=1\n return d\ndef find_gt(a, x):\n 'Find leftmost value greater than x'\n i = bi.bisect_left(a, x)\n if i != len(a):\n return i\n else: \n return -1\n\ndef power(x, y, p): \n res = 1; \n x = x % p; \n while (y > 0): \n \n if (y & 1): \n res = (res * x) % p; \n y = y >> 1; \n x = (x * x) % p; \n \n return res; \ndef main():\n try:\n n,m=In()\n print(((power(2,m,P))-1)%P*((power(2,n,P)%P)-1)%P)\n\n except:\n pass\n \nM = 998244353\nP = 1000000007\n \nif __name__ == '__main__':\n #for _ in range(I()):main()\n for _ in range(1):main()"}, {"source_code": "n,m = list(map(int,input().split()))\nmod = 10**9+7\nboxes = pow(2,m,mod)-1\ngift = pow(2,n,mod)-1\nprint((boxes*gift)%mod)"}, {"source_code": "def quickpow(a,b):\n mod=1e9+7\n ret=1\n while(b):\n if(b&1):\n ret=ret*a%mod\n a=a*a%mod\n b>>=1\n return ret\ns=input().split()\nn=int(s[0])\nm=int(s[1])\nans=quickpow(2,m)\nans-=1\nans=quickpow(ans,n)\nans=int(ans)\nprint(ans)"}, {"source_code": "def power(x, y, p) : \n res = 1 # Initialize result \n \n # Update x if it is more \n # than or equal to p \n x = x % p \n \n while (y > 0) : \n \n # If y is odd, multiply \n # x with result \n if ((y & 1) == 1) : \n res = (res * x) % p \n \n # y must be even now \n y = y >> 1 # y = y/2 \n x = (x * x) % p \n \n return res \nimport math\n#q=int(input())\nq=1\nfor _ in range(q):\n mod=10**7+9\n n,m=map(int,input().split())\n ans=(power(2, m, mod)-1)%mod\n ans=power(ans,n,mod)%mod\n print(ans%mod) \n "}, {"source_code": "n, m = map(int, input().split())\nmod = 10 ** 9 + 7\nans = (pow(2, m, mod) - 1 + mod) * n % mod\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\n\ndef powerMod(base, exp):\n if exp == 0: return 1\n if exp == 1: return base\n ret = powerMod(base, exp//2)\n if exp % 2: \n ret = (ret * ret * base) % 10000000007\n else:\n ret = (ret * ret) % 10000000007\n\n return ret\nbase = powerMod(2, m) - 1\n\nans = powerMod(base, n)\nprint(ans)\n"}, {"source_code": "mod = pow(10, 9) + 7\nn, box = map(int,input().split())\nprint(pow((pow(2, box) - 1),n) // mod)"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\n\nN = 1000000007; \n \ndef exponentiation(bas, exp): \n if (exp == 0): \n return 1; \n if (exp == 1): \n return bas % N; \n \n t = exponentiation(bas, int(exp / 2)); \n t = (t * t) % N; \n \n \n if (exp % 2 == 0): \n return t; \n \n \n else: \n return ((bas % N) * t) % N;\n\nmodulo = exponentiation(2, m) \nprint(exponentiation(modulo, n))\n\n"}, {"source_code": "s=input().split()\nn=int(s[0])\nm=int(s[1])\nx=pow(2,m)\ny=pow(x-1,n,10007)\nprint(y) "}, {"source_code": "n, m = [int(i) for i in input().split(' ')]\nprint(((2**m)**n + 1)%(10**9 + 7))"}, {"source_code": "mod=1000000007\ndef power(x,y):\n\tres=1\n\twhile y>0:\n\t\tif y%2==1:\n\t\t\tres=(res*x)%mod \n\t\ty=y//2 \n\t\tx=(x*x)%mod\n\treturn res\nn,m=map(int,input().split())\nif n==1:\n\tprint(power(n+1,m)-1)\nelse:\n\tprint(power(n+1,m))\n\t"}, {"source_code": "from itertools import combinations\ninp=[int(x) for x in input().split()]\nn,m=inp[0], inp[1]\nways=0\nok=range(1,n+1)\nprint(len(list(combinations(ok,m))))"}, {"source_code": "\nar = []\nfor x in input().split(' '):\n ar.append(int(x))\ncurr = pow(pow(2, ar[1], 1000000000000)-1, ar[0], 1000000007)\nprint(curr)"}, {"source_code": "M = 1e9 +7\n\ndef pw(x,y):\n s=1\n x%=M\n while y:\n if y & 1: s=(s*x)%M\n x=(x*x)%M\n y>>=1\n return s\n\nn, m = map(int, input().split())\nprint(int(pw(pw(2,m)-1+M, n)))"}, {"source_code": "n,m=map(int,input().split())\nx=(2**((n*m)+1))\ny=(2**m+1)**n\nprint((x-y)%(1000000007))\n"}, {"source_code": "a,b=map(int,input().strip().split())\nq=(2**(b%1000000000)-1)**(a%1000000000)\nprint(q%(1000000000+7))\n"}, {"source_code": "import math\ninp=[int(x) for x in input().split()]\nn,m=inp[0], inp[1]\nprint(math.factorial(m)*n +1)"}, {"source_code": "def mypow(m,n):\n s=1\n while n:\n if n&1:\n s=((s*m)%M)\n m=(m*m)%M\n n=n>>1\n return(s%M)\nm,n=list(map(int,input().split()))\nM=1000000007\nans=mypow(m,n)\nans-=1\nans=mypow(ans,m)\nprint(ans)"}, {"source_code": "\n\ndef power(x, y) : \n res = 1 \n\n p = 10**9 + 7\n \n x = x % p \n \n while (y > 0) : \n \n \n if ((y & 1) == 1) : \n res = (res * x) % p \n \n \n y = y >> 1\n x = (x * x) % p \n \n return res\n\nn,m = list(map(int,input().split()))\nmod = 10**9 + 7\nans = 0\nans = (ans + power(2,m*n+1))%mod\nans = (ans - power(power(2,m)+1,n))%mod\nans = (ans + power(2,n) - 2)%mod\n\n\nprint(ans)\n\n"}, {"source_code": "n,m = map(int, input().split())\nmo = 10*9 + 7\nres = pow(2, m, mo)\nres %= mo\nres -= 1\nres = pow(res, n, mo)\nres %= mo\nprint(res)"}, {"source_code": "s=input().split()\nn=int(s[0])\nm=int(s[1])\nx=pow(2,m)\ny=pow(x-1,n,10007)\nprint(y) "}, {"source_code": "from sys import stdin, stdout\nimport math,sys,heapq\nfrom itertools import permutations, combinations\nfrom collections import defaultdict,deque,OrderedDict\nfrom os import path\nimport random\nimport bisect as bi\ndef yes():print('YES')\ndef no():print('NO')\nif (path.exists('input.txt')): \n #------------------Sublime--------------------------------------#\n sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\n def I():return (int(input()))\n def In():return(map(int,input().split()))\nelse:\n #------------------PYPY FAst I/o--------------------------------#\n def I():return (int(stdin.readline()))\n def In():return(map(int,stdin.readline().split()))\n#sys.setrecursionlimit(1500)\ndef dict(a):\n d={} \n for x in a:\n if d.get(x,-1)!=-1:\n d[x]+=1\n else:\n d[x]=1\n return d\ndef find_gt(a, x):\n 'Find leftmost value greater than x'\n i = bi.bisect_left(a, x)\n if i != len(a):\n return i\n else: \n return -1\n\ndef power(x, y, p): \n res = 1; \n x = x % p; \n while (y > 0): \n \n if (y & 1): \n res = (res * x) % p; \n y = y >> 1; \n x = (x * x) % p; \n \n return res; \ndef main():\n try:\n n,m=In()\n print(((power(2,m,P))-1)%P*((power(2,n,P)%P)-1)%P)\n\n except:\n pass\n \nM = 998244353\nP = 1000000007\n \nif __name__ == '__main__':\n #for _ in range(I()):main()\n for _ in range(1):main()"}, {"source_code": "n,m = list(map(int,input().split()))\nmod = 10**9+7\nboxes = pow(2,m,mod)-1\ngift = pow(2,n,mod)-1\nprint((boxes*gift)%mod)"}, {"source_code": "N, M = map(int, input().split())\nmod = 10 ** 9 + 7\n\nans = pow(pow(2, M, mod), N, mod)\nans %= mod\nans -= N * pow(pow(2, M, mod), N - 1, mod)\nans %= mod\nans += (N - 1)\nans %= mod\nprint(ans)\n"}, {"source_code": "n,m=map(int,input().split())\ndef fun(x,y,m):\n res=1\n while y>0:\n if y%2==1:\n res=(res*x)%m\n y//=2\n x=(x*x)%m\n return res\ntot = fun(2,m,10**9-7)-1\nprint(fun(tot,n,10**9+7))"}, {"source_code": "mod= 10**9 +7\n\ndef power(a,b):\n ans=1\n while(b>0):\n if(b%2!=0):\n ans=ans*a%mod\n b=b>>2\n a=a*a\n ans=ans*a%mod\n return ans\n\n(n,m)=[int(x) for x in input().split()]\nres=power(2,m)-1\nres=power(res,n)\nprint(res%mod)"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\n\nN = 1000000007; \n \ndef exponentiation(bas, exp): \n if (exp == 0): \n return 1; \n if (exp == 1): \n return bas % N; \n \n t = exponentiation(bas, int(exp / 2)); \n t = (t * t) % N; \n \n \n if (exp % 2 == 0): \n return t; \n \n \n else: \n return ((bas % N) * t) % N;\n\nmodulo = exponentiation(2, m) \nprint(exponentiation(modulo, n))\n\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom random import randint\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nimport sys\nimport os\nimport re\nsys.setrecursionlimit(9999)\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\nN = 5001\n\n'''\nCheck for special cases (n=1)\nOne wrong submission = 10 mins penalty!\ndo smth instead of nothing and stay organized\n'''\n\n\ndef main():\n\tn, m = map(int, input().split())\n\ta = pow(2, n*m, mod)\n\tb = pow(2, (n-1)*m, mod)\n\tb = (b * n) % mod\n\tb = (b - (n-1) + mod) % mod\n\ttotal = max(0, a - b) % mod\n\tprint(total)\n\n\nBUFSIZE = 8192\nclass FastI(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = StringIO()\n\t\tself.newlines = 0\n \n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(\"\\n\") + (not b)\n\t\t\tptr = self._buffer.tell()\n\t\t\tself._buffer.seek(0, 2), self._buffer.write(\n\t\t\t\tb), self._buffer.seek(ptr)\n\t\tself.newlines -= 1\n\t\treturn self._buffer.readline()\nclass FastO(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = __pypy__.builders.StringBuilder()\n\t\tself.write = lambda s: self._buffer.append(s)\n \n\tdef flush(self):\n\t\tos.write(self._fd, self._buffer.build())\n\t\tself._buffer = __pypy__.builders.StringBuilder()\ndef print(*args, **kwargs):\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n\tat_start = True\n\tfor x in args:\n\t\tif not at_start:\n\t\t\tfile.write(sep)\n\t\tfile.write(str(x))\n\t\tat_start = False\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\n\tif kwargs.pop(\"flush\", False):\n\t\tfile.flush()\ndef gcd(x, y):\n\twhile y:\n\t\tx, y = y, x % y\n\treturn x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n\tdef bootstrap(cont):\n\t\tcall, arg = cont.switch()\n\t\twhile True:\n\t\t\tcall, arg = cont.switch(to=continulet(\n\t\t\t\tlambda _, f, args: f(*args), call, arg))\n\tcont = continulet(bootstrap)\n\tcont.switch()\n\tmain()"}, {"source_code": "n,m=list(map(int,input().split()))\nM=pow(10,9)+7\na=pow(2,m,M)-1\na=a%m\nb=pow(a,n,M)\nprint(b)"}, {"source_code": "n, m = map(int, input().split())\nprint((n*m)*max(n, (m-1)) + 1)"}, {"source_code": "import sys\ninputfn = sys.stdin.readline\n\ndef fastExp(A, E, N):\n\tif (E == 0):\n\t\treturn 1\n\tif (E == 1):\n\t\treturn A % N\n\trec = fastExp(A, E // 2, N)\n\trec = (rec * rec) % N\n\tif (E % 2 == 0):\n\t\treturn rec\n\treturn ((A % N) * rec) % N\n\n\nnm = inputfn().split(\" \")\nn = int(nm[0])\nm = int(nm[1])\n\nmodulus = 10**9 + 7\ngifts = fastExp(2, n, modulus) - 1\nboxes = fastExp(2, m, modulus) - 1\nprint((gifts * boxes) % modulus)\n"}, {"source_code": "n,m=map(int,input().split())\nans=0\nif(n==1):\n ans=(pow(2,n*m,1000000007)-1+1000000007)%1000000007\nelse :\n ans=(pow(2,n*m,1000000007)-((n*pow(2,(n-1)*m,1000000007))%1000000007)+1000000007)%1000000007+1\nans=ans%1000000007\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nmod=1000000007\nx=(1<<m)\nx%=mod\nx-=1\nans=0\ny=((n*(n+1))//2)\nans=((x*y)%mod)\nprint(ans)"}], "src_uid": "71029e5bf085b0f5f39d1835eb801891"} {"source_code": "import sys\r\nfrom math import gcd\r\n# sys.setrecursionlimit(10000)\r\n\r\n\r\nclass BinaryField:\r\n def __init__(self, s):\r\n \"\"\"Given a binary string, return a BinaryField element.\r\n Input:\r\n s: Has to take one of the following form:\r\n 1. A binary string, with MSB as the highest degree polynomial\r\n 2. An integer, with MSB as the highest degree polynomial\"\"\"\r\n if type(s) == int:\r\n self.poly = s\r\n\r\n else:\r\n self.poly = 0\r\n\r\n for c in s:\r\n self.poly = (self.poly << 1) + int(c)\r\n\r\n if self.poly == 0:\r\n self.deg = float('-inf')\r\n else:\r\n self.deg = len(bin(self.poly)) - 3\r\n\r\n def __repr__(self):\r\n return f'BinaryField(poly={bin(self.poly)[2:]}, deg={self.deg})'\r\n\r\n def __eq__(self, other):\r\n return self.poly == other.poly\r\n\r\n def __add__(self, other):\r\n return BinaryField(self.poly ^ other.poly)\r\n\r\n def __mul__(self, other):\r\n temp = other.poly\r\n answer = 0\r\n align = self.poly\r\n\r\n while temp:\r\n if temp & 1:\r\n answer ^= align\r\n\r\n align <<= 1\r\n temp >>= 1\r\n\r\n return BinaryField(answer)\r\n\r\n def __truediv__(self, other):\r\n if other.poly == 0:\r\n raise ZeroDivisionError\r\n\r\n answer = 0\r\n temp = self.poly\r\n\r\n for d in range(max(self.deg - other.deg, 0), -1, -1):\r\n if temp & (1 << (other.deg + d)):\r\n answer += (1 << d)\r\n temp ^= (other.poly << d)\r\n\r\n return BinaryField(answer)\r\n\r\n def __mod__(self, other):\r\n if other.poly == 0:\r\n raise ZeroDivisionError\r\n\r\n answer = 0\r\n temp = self.poly\r\n\r\n for d in range(max(self.deg - other.deg, 0), -1, -1):\r\n if temp & (1 << (other.deg + d)):\r\n answer += (1 << d)\r\n temp ^= (other.poly << d)\r\n\r\n return BinaryField(temp)\r\n\r\n def square(self):\r\n \"\"\"Returns the square of the polynomial itself.\r\n Faster than a * a\"\"\"\r\n answer = 0\r\n temp = self.poly\r\n\r\n while temp:\r\n lsb = temp & (-temp)\r\n answer += lsb ** 2\r\n\r\n temp -= lsb\r\n\r\n return BinaryField(answer)\r\n\r\n def powmod(self, exp, mod):\r\n \"\"\"Return (self**exp) % mod\r\n Inputs:\r\n exp: An integer power\r\n mod: A BinaryField element representing the modulus\"\"\"\r\n answer, temp = BinaryField(1), self\r\n\r\n while exp:\r\n if exp & 1:\r\n answer = (answer * temp) % mod\r\n\r\n exp >>= 1\r\n temp = temp.square() % mod\r\n\r\n return answer\r\n\r\n @staticmethod\r\n def gcd(poly1, poly2):\r\n \"\"\"Given two BinaryField elements, return its gcd\r\n Input:\r\n poly1, poly2: two BinaryField elements.\r\n Output:\r\n The gcd of poly1 and poly2 as a BinaryField instance.\"\"\"\r\n if poly1.deg < poly2.deg:\r\n poly1, poly2 = poly2, poly1\r\n\r\n p1, p2 = poly1, poly2\r\n while p2.poly != 0:\r\n p1, p2 = p2, p1 % p2\r\n\r\n return p1\r\n\r\n @staticmethod\r\n def factorize(poly):\r\n \"\"\"Factorize a BinaryField object\r\n Input:\r\n poly: A BinaryField element\r\n Return: A list of tuples (poly, exp).\"\"\"\r\n answer = []\r\n temp = poly\r\n\r\n for d in range(2, 2**(1+poly.deg//2)):\r\n div = BinaryField(d)\r\n\r\n e = 0\r\n while temp % div == BinaryField(0):\r\n temp = temp / div\r\n e += 1\r\n\r\n if e:\r\n answer.append((div, e))\r\n\r\n if temp == BinaryField(1): break\r\n\r\n if temp != BinaryField(1):\r\n answer.append((temp, 1))\r\n\r\n return answer\r\n\r\n\r\ndef input_general():\r\n return sys.stdin.readline().rstrip('\\r\\n')\r\n\r\n\r\ndef input_num():\r\n return int(sys.stdin.readline().rstrip(\"\\r\\n\"))\r\n\r\n\r\ndef input_multi(x=int):\r\n return map(x, sys.stdin.readline().rstrip(\"\\r\\n\").split())\r\n\r\n\r\ndef input_list(x=int):\r\n return list(input_multi(x))\r\n\r\n\r\ndef main(s):\r\n def get_factor(n):\r\n factors = {1}\r\n\r\n for p in range(2, 1 + int(n**0.5)):\r\n e = 0\r\n\r\n while n % p == 0:\r\n n //= p\r\n e += 1\r\n\r\n if e:\r\n factors = {f * (p**i) for f in factors for i in range(e+1)}\r\n\r\n if n == 1: break\r\n\r\n if n != 1:\r\n factors = {f * g for f in factors for g in (1, n)}\r\n\r\n return factors\r\n\r\n s = s.rstrip('0')\r\n leading_0 = s.find('1')\r\n\r\n answer = 1\r\n\r\n if leading_0 == -1:\r\n print('-1')\r\n return\r\n\r\n f2s = BinaryField(s)\r\n x = BinaryField(2)\r\n factors_bin = BinaryField.factorize(f2s)\r\n\r\n for f, exp in factors_bin:\r\n factors_pow = sorted(list(get_factor(2**f.deg-1)))\r\n\r\n for e in factors_pow:\r\n if x.powmod(e, f) == BinaryField(1):\r\n if exp == 1:\r\n need = e\r\n else:\r\n need = e * (2**(len(bin(exp-1)) - 2))\r\n\r\n g = gcd(answer, need)\r\n answer = answer * need // g\r\n\r\n break\r\n\r\n print(1 + leading_0, 1 + leading_0 + answer)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n s = input_general()\r\n\r\n main(s)\r\n", "positive_code": [{"source_code": "import sys\r\nfrom math import lcm\r\nfrom collections import defaultdict\r\n\r\ndef solve(p):\r\n\tpoly = int(p[::-1], 2)\r\n\tassert p[0] == '1' and p[-1] == '1'\r\n\tdegree = len(p) - 1\r\n\tdef reduce(a):\r\n\t\twhile a.bit_length() > degree:\r\n\t\t\tb = a.bit_length() - degree - 1\r\n\t\t\ta ^= poly << b\r\n\t\tassert a < (1 << degree)\r\n\t\treturn a\r\n\r\n\tdef mul(a, b):\r\n\t\ta = reduce(a)\r\n\t\tb = reduce(b)\r\n\t\tval = 0\r\n\t\tfor i in range(degree):\r\n\t\t\tif (a >> i) & 1:\r\n\t\t\t\tval ^= (b << i)\r\n\t\tfor i in range(degree, -1, -1):\r\n\t\t\tif (val >> (degree + i)) & 1:\r\n\t\t\t\tval ^= poly << i\r\n\t\treturn val\r\n\t\r\n\tdef pow(a, k):\r\n\t\tres = 1\r\n\t\twhile k:\r\n\t\t\tif k & 1:\r\n\t\t\t\tres = mul(res, a)\r\n\t\t\tk >>= 1\r\n\t\t\ta = mul(a, a)\r\n\t\treturn res\r\n\r\n\tpfs = defaultdict(int)\r\n\tpfs[2] += degree\r\n\tfor i in range(1, degree + 1):\r\n\t\tcur = 2 ** i - 1\r\n\t\tp = 2\r\n\t\twhile p * p <= cur:\r\n\t\t\twhile cur % p == 0:\r\n\t\t\t\tcur //= p\r\n\t\t\t\tpfs[p] += 1\r\n\t\t\tp += 1\r\n\t\tif cur > 1:\r\n\t\t\tpfs[cur] += 1\r\n\torder_multiple = 1\r\n\tfor p in pfs:\r\n\t\torder_multiple *= p ** pfs[p]\r\n\t\r\n\torder = order_multiple\r\n\tx = reduce(1 << 1)\r\n\tfor p in pfs:\r\n\t\twhile order % p == 0 and pow(x, order // p) == 1:\r\n\t\t\torder //= p\r\n\treturn order\r\n\r\ns = input()\r\nif '1' not in s:\r\n\tprint(-1)\r\n\tsys.exit()\r\n\r\np = s.lstrip('0')\r\nl0 = len(s) - len(p)\r\np = p.rstrip('0')\r\n\r\nres = solve(p)\r\nprint(f\"{1 + l0} {1 + l0 + res}\")"}], "negative_code": [], "src_uid": "6bf798edef30db7d0ce2130e40084e6b"} {"source_code": "from sys import stdin\n\nn,m = map(int,stdin.readline().split())\n\nc = []\nfor _ in range(m):\n c+=[tuple(map(int,stdin.readline().split()))]\n\nc.sort(key=lambda x:x[1],reverse=True)\n\nans = 0\n\nfor a,b in c:\n if n>a:\n ans+=a*b\n n-=a\n else:\n ans+=n*b\n break\n\nprint(ans)\n", "positive_code": [{"source_code": "n , m = map(int , input().split())\nl=[]\nfor i in range(int(m)):\n t = list(map(int, input().split() ))\n t= t[::-1]\n l.append(t)\nl.sort(reverse = True)\nans = 0\ni=0\nwhile n>0 and i<len(l):\n temp = min(n , l[i][1])\n ans = ans + temp*l[i][0]\n n = n - temp\n i = i+1\nprint(ans)"}, {"source_code": "def main():\n n, m = map(int, input().split())\n\n containers = []\n for _ in range(m):\n containers.append(tuple(map(int, input().split())))\n\n containers.sort(reverse=True, key=lambda pair: pair[1])\n total_matches = 0\n for matchboxes, matches in containers:\n if matchboxes < n:\n total_matches += matchboxes * matches\n n -= matchboxes\n\n else:\n total_matches += n * matches\n break\n\n print(total_matches)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,m=map(int,input().split())\nX=[]\nfor i in range(m):\n X.append(list(map(int,input().split()))[::-1])\nX.sort(reverse=True)\nBox=0\nfor i in X:\n if n==0:\n break\n if i[1]>n:\n Box+=i[0]*n\n n=0\n else:\n Box+=i[0]*i[1]\n n-=i[1]\n \nprint(Box)"}, {"source_code": "def q16b():\n\tn, m = tuple([int(num) for num in input().split()])\n\tas_ = []\n\tbs_ = []\n\tfor _ in range(m):\n\t\ta, b = tuple([int(num) for num in input().split()])\n\t\tas_.append(a)\n\t\tbs_.append(b)\n\targsorted = sorted(range(len(bs_)), key=bs_.__getitem__)\n\targsorted.reverse()\n\ttotal = 0\n\tfor i in range(len(argsorted)):\n\t\tif(n <= 0):\n\t\t\tbreak\n\t\ttotal += min(as_[argsorted[i]], n) * bs_[argsorted[i]]\n\t\tn -= as_[argsorted[i]]\n\tprint(total)\nq16b()\n\n# def q16b():\n# \tn, m = tuple([int(num) for num in input().split()])\n# \tboxes = []\n# \tfor _ in range(m):\n# \t\ta, b = tuple([int(num) for num in input().split()])\n# \t\tboxes = boxes + [b for _ in range(a)]\n# \tboxes.sort()\n# \tboxes.reverse()\n# \tprint(sum(boxes[:n]))\n\n# q16b()"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n\ty=[]\n\ta,b=map(int,input().split())\n\ty=[b,a]\n\tl.append(y)\nl.sort(reverse=True)\n# print(l)\ns=0\nc=0\nfor j in range(m):\n\tif((n-(s+l[j][1]))>0):\n\t\tc=c+l[j][0]*l[j][1]\n\t\ts=s+l[j][1]\n\t\t# print(s,c)\n\telse:\n\t\tr=n-s\n\t\t# print(r)\n\t\tc=c+r*l[j][0]\n\t\tbreak\nprint(c)"}, {"source_code": "n,m=[int(x) for x in input().split()]\nl1,l2=[],[]\nfor i in range(m):\n a,b=input().split()\n l1.append(int(a))\n l2.append(int(b))\nl2, l1 =(list(t) for t in zip(*sorted(zip(l2, l1))))\nl1=l1[::-1]\nl2=l2[::-1]\nc,s,v=0,0,0\nfor i in range(m):\n s+=l1[i]\n if(s<=n):\n c+=(l1[i]*l2[i])\n else:\n c+=((n-v)*l2[i])\n break\n v=s\nprint(c)"}, {"source_code": "n,m = map(int,input().split())\nA = []\nfor i in range(m):\n a,b = map(int,input().split())\n A.append([b,a])\nA.sort()\n#print(A)\ni=m-1\nans=0\nwhile(n>0 and i>=0):\n ans+=A[i][0]*min(n,A[i][1])\n n-=A[i][1]\n i-=1\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n a,b=map(int,input().split())\n l.append((a,b))\nl.sort(key=lambda x: x[1],reverse=True)\nans=0\nfor i in range(m):\n if n==0:\n break\n x=min(l[i][0],n)\n ans+=x*l[i][1]\n n-=x\nprint(ans)"}, {"source_code": "class A:\n\n def solve(self):\n [n, m] = [int(x) for x in input().split(\" \")]\n flag = []\n for i in range(n):\n flag.append(input())\n\n if any([len(set(x)) != 1 for x in flag]):\n print(\"NO\")\n return\n\n first_colors = [x[0] for x in flag]\n if any([x == y for x, y in zip(first_colors, first_colors[1:])]):\n print(\"NO\")\n return\n\n print(\"YES\")\n\nclass B:\n\n def solve(self):\n [n, m] = [int(x) for x in input().split(\" \")]\n matches = []\n for i in range(m):\n matches.append([int(x) for x in input().split(\" \")])\n\n matches = sorted(matches, key=lambda x: x[1], reverse=True)\n\n total_matches = 0\n\n for (nums, matchsticks) in matches:\n if nums < n:\n n -= nums\n total_matches += nums * matchsticks\n else:\n total_matches += n * matchsticks\n n = 0\n\n print(total_matches)\n\nB().solve()\n"}, {"source_code": "from sys import stdin, stdout # only need for big input\n\ndef read_int_from_line():\n return list(map(int, input().split()))\n\ndef solve():\n n, m = read_int_from_line()\n matches = []\n for _ in range(m):\n a, b = read_int_from_line()\n matches.append((a,b))\n matches.sort(key= lambda x : x[1], reverse=True)\n # print(matches)\n cur_holding = 0\n ans = 0\n for m in matches:\n pick = min(m[0], n - cur_holding)\n ans += m[1] * pick \n cur_holding += pick\n print(ans)\n\n\ndef main():\n solve()\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "# ip = open(\"testdata.txt\", \"r\")\n\n# def input():\n# \treturn ip.readline().strip()\n\nn, m = map(int, input().split())\ncont = [0]*m \n\nfor i in range(m):\n\tboxes, matches = map(int, input().split())\n\tcont[i] = [matches, boxes]\n\ncont.sort(reverse=True)\ncount = 0 \n\nfor match, box in cont:\n\tx = min(n, box)\n\tcount += match*x\n\tn -= x\n\tif n==0:\n\t\tbreak\n\nprint(count)\n"}, {"source_code": "# key not available \"\"\nn, m = [int(i) for i in input().split()]\narr = []\nfor _ in range(m):\n a, b = [int(i) for i in input().split()]\n arr.append([b,a])\narr.sort(reverse=True)\nans = 0\nfor i in range(m):\n temp = min(n, arr[i][1])\n ans += (temp*arr[i][0])\n n -= temp\n if n == 0:\n break\nprint(ans)\n"}, {"source_code": "\nR = lambda:map(int,input().split())\n\nn, m = R()\narr = sorted([[*R()] for i in range(m)], key=lambda x: x[1], reverse=True)\nans = 0\nfor i in arr:\n v = min(n, i[0])\n ans += v*i[1]\n n -= v\n if n < 1:\n break\nprint(ans)\n\n"}, {"source_code": "'''input\n3 3\n1 3\n2 2\n3 1\n'''\n# int(stdin.readline().strip())\n# list(map(int, stdin.readline().split()))\nfrom sys import stdin\n\n\n# main starts\nn, m = list(map(int, stdin.readline().split())) \narr = []\nfor _ in range(m):\n\ta, b = list(map(int, stdin.readline().split()))\n\tarr.append([a, b, a * b])\n\narr = sorted(arr, key =lambda x : x[1], reverse = True)\nbags = 0\nans = 0\n# print(arr)\nfor i in range(m):\n\t# print(ans)\n\ta, b, matches = arr[i]\n\n\tif bags + a <= n:\n\t\tans += matches\n\t\tbags += a\n\t\tcontinue\n\telse:\n\t\tt = 1\n\t\twhile bags + t <= n and t <= a:\n\t\t\tans += b \n\t\t\tt += 1\n\t\tbreak\n\nprint(ans)\n\n\n"}, {"source_code": "a,b=input().strip().split(\" \")\na,b=[int(a),int(b)]\nx=[]\nfor i in range(b):\n c,d=input().strip().split(\" \")\n c,d=[int(c),int(d)]\n x.append([d,c])\nx.sort(reverse=True)\ns1=0\ns2=0\nfor i in range(b):\n if s1+x[i][1]>a:\n s2+=(a-s1)*x[i][0]\n break\n else:\n s2+=x[i][0]*x[i][1]\n s1+=x[i][1]\nprint(s2)\n"}, {"source_code": "n, m = map(int, input().split())\n\n\nmain = []\nfor i in range(m):\n box, matches = map(int, input().split())\n main.append([box, matches])\n\n\nmain.sort(key = lambda x: x[1], reverse = True)\n\ntotal = 0\n\nj = 0\n\nwhile n != 0 and j < len(main):\n n -= main[j][0]\n if n < 0:\n total += ((main[j][0] + n) * main[j][1])\n break\n else: total += (main[j][0] * main[j][1])\n\n if n < 0: break\n \n j += 1\n\nprint(total)"}, {"source_code": "n,m=map(int,input().split())\nx=[]\ny=[]\nA=0\nfor i in range(m):\n a,b=map(int,input().split())\n x.append(a)\n y.append(b)\nif sum(x)>n:\n while n>0:\n a=y.index(max(y))\n if x[a]>=n:\n A+=n*y[a]\n n=0\n else:\n A+=x[a]*y[a]\n n=n-x[a]\n x.pop(a)\n y.pop(a)\n print(A)\nelse:\n for i in range(m):\n A+=x[i]*y[i]\n print(A)"}, {"source_code": "\nn , m = map(int,input().split())\nmapped =[]\n\nfor i in range(m):\n mapped.append(list(map(int,input().split(\" \"))))\nmapped.sort(key = lambda x:x[1] , reverse =True)\nresult =0\nfor a in mapped:\n if n>a[0]:\n result+=a[0]*a[1]\n n-=a[0]\n else:\n result+=a[1]*n\n break\n \nprint(result) "}, {"source_code": "\na, b = map(int,input().split())\nmapped =[]\n\nfor i in range(b):\n mapped.append(list(map(int,input().split(\" \"))))\nmapped.sort(key = lambda x:x[1] , reverse =True)\nresult =0\nfor i in mapped:\n if a>i[0]:\n result+=i[0]*i[1]\n a-=i[0]\n else:\n result+=i[1]*a\n break\n \nprint(result) "}, {"source_code": "\n\ndef read_int():\n return int(input().strip())\n\n\ndef read_ints():\n return list(map(int, input().strip().split(' ')))\n\n\ndef rev(lst):\n lst.reverse()\n return lst\n\n\ndef solve():\n \"\"\"\n m containers\n i-th container has a[i] matchboxes, each matchbox has b[i] matches\n rucksack holds n matchboxes exactly\n \"\"\"\n n, m = read_ints()\n containers = [rev(read_ints()) for _ in range(m)]\n containers.sort()\n answer = 0\n while containers:\n matches, boxes = containers.pop()\n if n <= boxes:\n answer += n*matches\n break\n else:\n answer += boxes*matches\n n -= boxes\n return answer\n\n\nif __name__ == '__main__':\n print(solve())\n"}, {"source_code": "# your code goes here\nfrom sys import stdin, stdout\n\nn, m = map(int, stdin.readline().split())\nar = []\nfor i in range(m):\n\ta, b = map(int, stdin.readline().split())\n\t\n\tar.append((a, b))\n\t\nar.sort(key=lambda x:x[1], reverse=True)\n\nmatches = 0\n\nfor box in ar:\n\tif n >= box[0]:\n\t\tmatches += box[0]*box[1]\n\t\tn -= box[0]\n\telse:\n\t\tmatches += n*box[1]\n\t\tbreak\n\t\t\nstdout.write(str(matches))\n\t\n"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n a,b=map(int,input().split())\n t=(b,a)\n l.append(t)\nl.sort(reverse=True)\nr=0\nle=len(l)\nwhile(n):\n if n>=l[0][1]:\n r+=l[0][1]*l[0][0]\n n-=l[0][1]\n l.pop(0)\n le-=1\n else:\n r+=n*l[0][0]\n break\n if le==0:\n break\nprint(r)"}, {"source_code": "n_m = [int(x) for x in input().split(' ')]\nn = n_m[0]\nm = n_m[1]\nl1 = []\nl2 = []\nl3 = []\nl4 = []\nfor i in range(m):\n a_b = [int(y) for y in input().split(' ')]\n l1.append(a_b[0])\n l2.append(a_b[1])\n l3.append(a_b[1])\nl3.sort(reverse=True)\nfor i in l3:\n for j in range(len(l3)):\n if i == l2[j]:\n l4.append(l1[j])\n l2[j] = -1\nmatches = 0\nfor i in range(len(l2)):\n if n > l4[i]:\n matches += l3[i] * l4[i]\n n -= l4[i]\n else:\n matches += n * l3[i]\n n = 0\n break\nprint(matches)\n"}, {"source_code": "def to_list(s):\n return list(map(lambda x: int(x), s.split(' ')))\n\ndef solve(boxes,matches,n):\n\n sorted_ = sorted(zip(boxes,matches), key=lambda x: x[1], reverse=True)\n match_count = 0\n box_residue = n\n for item in sorted_:\n if box_residue > 0:\n min_ = min(box_residue, item[0])\n box_residue -= min_\n match_count += item[1]*min_\n else:\n return match_count\n return match_count\n\nboxes = []\nmatches = []\n\nn, m = to_list(input())\nfor i in range(m):\n s = to_list(input())\n boxes.append(s[0])\n matches.append(s[1])\n\nprint(solve(boxes,matches,n))\n"}, {"source_code": "import collections\ns=list(map(int,input().split()))\nn=s[0]\nm=s[1]\nmydict={}\narrofsize=[]\narrofwts=[]\nfor i in range(m):\n t=input().split()\n arrofsize.append(int(t[0]))\n arrofwts.append(int(t[1]))\narrofwts2=list(set(arrofwts))\nfor i in arrofwts2:\n counts=0\n for j in range(0,len(arrofwts)):\n if(i==arrofwts[j]):\n counts+=arrofsize[j]\n mydict[i]=counts\n\n \nsize=list(mydict.values())\nwt=list(mydict.keys())\narr=sorted(mydict.items())\ncount=0\ni=len(wt)-1\nwhile(i>=0):\n w1=arr[i][0]\n s1=arr[i][1]\n if(n>=s1):\n count=count+(s1*w1)\n n=n-s1\n \n elif(n<s1):\n count=count+(n*w1)\n n=n-n\n i=i-1\nprint(count)\n"}, {"source_code": "\nn, m = map(int, input().split())\nres = []\nfor _ in range(m):\n a, b = map(int, input().split())\n res.append((a, b))\nres.sort(key=lambda x: x[1], reverse=True)\nmatches = 0\ncurrent = n\nfor a, b in res:\n if current > 0:\n matches += min(current, a)*b\n current -= min(current, a)\nprint(matches)\n\n\n"}, {"source_code": "import sys\na,b=map(int,input().split())\nc=[]\nk=0\nfor i in range(b):\n e,f=map(int,input().split())\n x=[f,e]\n c.append(x)\nc=sorted(c,reverse=True)\nfor i in c :\n d=a-i[1]\n if a>=0:\n if d>=0:\n z = i[0] * i[1]\n k = k + z\n a = d\n if d<0:\n z = i[0] * a\n k = k + z\n a = d\n else:\n print(k)\n sys.exit()\nprint(k)\n"}, {"source_code": "n,m = map(int, input().split(\" \"))\na = []\nfor i in range(m):\n a.append(list(map(int,input().split(\" \"))))\na.sort(key = lambda x : x[1],reverse = True)\nsum = 0\nfor x in a:\n if n >= x[0]:\n sum = sum + x[0]*x[1]\n n = n - x[0]\n else:\n sum = sum + n*x[1]\n break\nprint(sum)"}, {"source_code": "n,m=[int(i) for i in input().split()]\ncand=[]\nfor i in range(m):\n cand.append([int(i) for i in input().split()])\n\ncand.sort(key=lambda x:x[1],reverse=True)\nres=0\nfor i in range(m):\n temp=min(n,cand[i][0])\n res+=cand[i][1]*temp\n n-=temp\n if temp<=0:\n break\nprint(res)"}, {"source_code": "n, m = map(int, raw_input().split())\nc = []\n\nfor i in range(m):\n c_temp = map(int, raw_input().split())\n c.append(c_temp)\n\nsorted_boxes = sorted(c, key=lambda x:x[1], reverse=True)\n\nm_sum = 0\nn_sum = 0\nii = 0\nwhile n_sum < n and ii < m:\n boxes_taken = min(sorted_boxes[ii][0], n-n_sum)\n n_sum += boxes_taken\n m_sum += boxes_taken * sorted_boxes[ii][1]\n ii += 1\n\nprint m_sum\n"}, {"source_code": "'''\nINPUT SHORTCUTS\nN, K = map(int,input().split())\nN ,A,B = map(int,input().split())\nstring = str(input())\narr = list(map(int,input().split()))\nN = int(input())\n'''\n\n\nN , M = map(int,input().split())\nwarehouse = []\nfor _ in range(M):\n\tboxes , matches = map(int,input().split())\n\twarehouse.append([matches,boxes])\nwarehouse.sort()\n# print(warehouse)\nans = 0\nfor i in range(M-1,-1,-1):\n\tif(N==0):\n\t\tbreak\n\tif(N-warehouse[i][1]>0):\n\t\tans += warehouse[i][1]*warehouse[i][0]\n\t\tN -= warehouse[i][1]\n\telse:\n\t\tans+= N*(warehouse[i][0])\n\t\tN = 0\n\t# print(ans)\nprint(ans)\n"}, {"source_code": "n,m=raw_input().strip().split()\nn,m=int(n),int(m)\narr=[list(map(int,raw_input().strip().split()))[::-1] for _ in xrange(m)]\narr.sort(reverse=True)\nmaxs,i=0,0\nwhile i<m and n>0:\n\tmaxs+=min(n,arr[i][1])*arr[i][0]\n\tn-=min(n,arr[i][1])\n\ti+=1\nprint maxs"}, {"source_code": "l1 = [int(x) for x in input().split()]\nn,m = l1[0],l1[1]\nl2=[]\nfor x in range(m):\n l2.append([int(x) for x in input().split()])\ndef myfunc(l1):\n return l1[1]\nl2.sort(key=myfunc,reverse=True)\ni=0\nans=0\n#print(l2)\nwhile i<len(l2):\n if l2[i][0]>=n:\n ans+=n*l2[i][1]\n break\n else:\n n-=l2[i][0]\n ans+=l2[i][0]*l2[i][1]\n i+=1\nprint(ans)\n\n \n\n\n"}, {"source_code": "\"\"\"\n ____ _ _____\n / ___|___ __| | ___| ___|__ _ __ ___ ___ ___\n| | / _ \\ / _` |/ _ \\ |_ / _ \\| '__/ __/ _ \\/ __|\n| |__| (_) | (_| | __/ _| (_) | | | (_| __/\\__ \\\n \\____\\___/ \\__,_|\\___|_| \\___/|_| \\___\\___||___/\n\n\"\"\"\n\"\"\"\n\u2591\u2591\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\n\u2591\u2584\u2580\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2588\u2591\n\u2591\u2588\u2591\u2584\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2584\u2591\u2588\u2591\n\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2591\n\u2591\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2591\n\u2584\u2588\u2580\u2588\u2580\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2580\u2580\u2588\u2588\u2588\n\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\n\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2588\u2588\n\u2588\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\u2588\n\u2591\u2580\u2588\u2588\u2588\u2584\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2584\u2588\u2588\u2588\u2580\u2591\n\u2591\u2591\u2591\u2580\u2588\u2588\u2584\u2591\u2580\u2588\u2588\u2580\u2591\u2584\u2588\u2588\u2580\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\nimport sys\nimport math\nimport collections\nimport operator as op\nfrom collections import deque\nfrom math import gcd, inf, sqrt\nfrom bisect import bisect_right, bisect_left\n\n#sys.stdin = open('input.txt', 'r')\n#sys.stdout = open('output.txt', 'w')\n\nfrom functools import reduce\nfrom sys import stdin, stdout, setrecursionlimit\nsetrecursionlimit(2**20)\n\n\ndef factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)\n\n\ndef ncr(n, r):\n r = min(r, n - r)\n numer = reduce(op.mul, range(n, n - r, -1), 1)\n denom = reduce(op.mul, range(1, r + 1), 1)\n return numer // denom # or / in Python 2\n\n\ndef prime_factors(n):\n i = 2\n factors = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.append(i)\n if n > 1:\n factors.append(n)\n return len(set(factors))\n\n\ndef isPowerOfTwo(x):\n return (x and (not(x & (x - 1))))\n\n\ndef factors(n):\n return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n\nMOD = 10**9 + 7\nT = 1\n# T = int(stdin.readline())\nfor _ in range(T):\n # a, b = list(map(int, stdin.readline().split()))\n # s1 = list(stdin.readline().strip('\\n'))\n # s2 = list(stdin.readline().strip('\\n'))\n # n = int(stdin.readline())\n # a, b, n = list(map(int, stdin.readline().split()))\n # n, k = list(map(int, stdin.readline().split()))\n # s = str(stdin.readline().strip('\\n'))\n # s2 = str(stdin.readline().strip('\\n'))\n n, m = list(map(int, stdin.readline().split()))\n s = []\n for i in range(m):\n a, b = list(map(int, stdin.readline().split()))\n s.append([b, a])\n s.sort(reverse=True)\n ans = 0\n i = 0\n while n > 0 and i < m:\n if s[i][1] >= n:\n ans += n * s[i][0]\n n = 0\n else:\n n -= s[i][1]\n ans += s[i][1] * s[i][0]\n i += 1\n print(ans)\n"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n a,b=map(int,input().split())\n l.append([b,a])\nl.sort()\nl.reverse()\n#print(l)\ncntr=0\nfor i in l:\n if n==0:\n break\n if i[1] > n: \n cntr+= n * i[0]\n break\n if i[1]<=n:\n cntr+=i[0]*i[1]\n #print(cntr)\n n-=i[1]\nprint(cntr)"}, {"source_code": "from bisect import bisect_right as br\nimport sys\nfrom collections import *\nfrom math import *\nimport re\ndef sieve(n):\n prime=[True for i in range(n+1)]\n p=2\n while p*p<=n:\n if prime[p]==True:\n for i in range(p*p,n+1,p):\n prime[i]=False\n p+=1\n c=0\n for i in range(2,n):\n if prime[i]:\n #print(i)\n c+=1\n return c\ndef totient(n):\n res,p=n,2\n while p*p<=n:\n if n%p==0:\n while n%p==0:\n n=n//p\n res-=int(res/p)\n p+=1\n if n>1:res-=int(res/n)\n return res\n \n\ndef iseven(n):return[False,True][0 if n%2 else 1]\ndef inp_matrix(n):return list([input().split()] for i in range(n))\ndef inp_arr():return list(map(int,input().split()))\ndef inp_integers():return map(int,input().split())\ndef inp_strings():return input().split()\ndef lcm(a,b):return (a*b)/gcd(a,b)\nmax_int = sys.maxsize\nmod = 10**9+7\nflag1=False\nflag2=False\n\nn,m=inp_integers()\nL=[list(map(int,input().split())) for i in range(m)]\nL.sort(key=lambda x:x[1],reverse=True)\n#print(L)\nans=0\nfor i in range(m):\n ans+=min(L[0][0],n)*L[0][1]\n n-=min(L[0][0],n)\n L.pop(0)\nprint(ans)"}, {"source_code": "n,m=[int(x) for x in raw_input().split()]\nA=[]\nfor i in range(m):\n\tA.append([int(x) for x in raw_input().split()])\nA.sort(key=lambda x:x[1])\nA.reverse()\nans=0\ni=0\nwhile n and i<len(A):\n\tk=min(n,A[i][0])\n\tans+=A[i][1]*k\n\tn-=k\n\ti+=1\nprint ans\n"}, {"source_code": "import sys\n\na,b = map(int, raw_input().split())\n\nl = []\nfor i in range(b):\n l.append( tuple( map(int, raw_input().split() )) )\n \nl = sorted(l, key=lambda (x,y):y, reverse=True )\n\nres = 0\nfor u,b in l:\n if a==0: break\n v = min(u, a)\n a -= v\n res += v*b\n \nprint res"}, {"source_code": "\n\nn, m = map(int, input().split())\nA = []\nfor _ in range(m):\n A.append(list(map(int, input().split())))\n \nA.sort(key = lambda el: el[1], reverse = True)\ni = ans = 0\nwhile n and i < len(A):\n cnt = min(n, A[i][0])\n ans += cnt*A[i][1]\n n -= cnt\n i += 1\nprint(ans)\n "}, {"source_code": "# https://codeforces.com/contest/16/problem/B\nfrom itertools import combinations\n\nn , m = map(int,raw_input().split(' '))\nk = m\nconatiners = []\nwhile k:\n conatiners.append(map(int,raw_input().split(' ')))\n k = k-1\nop = []\nconatiners.sort(key=lambda x: x[1],reverse = True)\nfor row in conatiners:\n if row[0]< n:\n op.append(row[1] * row[0])\n n = n - row[0]\n else:\n op.append(n * row[1])\n n = 0\n break\n\nprint sum(op)\n\n\n\n"}, {"source_code": "temp = input().split(' ')\nn = int(temp[0])\nm = int(temp[1])\nl = []\nmaxtemp = 0\nmaxind = 0\ns = 0\nfor i in range(m):\n temp = input().split(' ')\n l.append([int(temp[0]), int(temp[1])])\nwhile(n > 0):\n maxtemp = 0\n maxind = 0\n for i in range(len(l)):\n if(maxtemp < l[i][1]):\n maxtemp = l[i][1]\n maxind = i\n if maxind >= len(l):\n print(s)\n exit(0)\n if l[maxind][0] < n :\n n -= l[maxind][0]\n s += l[maxind][0]*l[maxind][1]\n del l[maxind]\n else:\n s += l[maxind][1]*n\n l[maxind][0] -= n\n n = 0\n if l[maxind][0] == 0:\n del l[maxind]\nprint(s)\n"}, {"source_code": "from operator import itemgetter\nn,m=map(int,raw_input().split())\np=[]\nfor i in range(m):\n p.append(map(int,raw_input().split()))\n \np.sort(key=itemgetter(1,0),reverse=True)\nt,s=0,0\nfor i in range(m):\n t+=p[i][0]\n if t<=n:\n s+=p[i][0]*p[i][1]\n else:\n s+=(n-(t-p[i][0]))*p[i][1]\n break\n \nprint s\n \n\n \n \n \n \n"}, {"source_code": "n, m = map(int, input().split())\nv = 0\nfor b in sorted((list(map(int, input().split()))[::-1] for i in range(m)), reverse=True):\n c = min(b[1], n)\n n -= c\n v += c * b[0]\nprint(v)"}, {"source_code": "import sys\n\nn, m = map(int, sys.stdin.readline().split())\n\nt = []\n\nfor i in xrange(m):\n a, b = map(int, sys.stdin.readline().split())\n t.append((a, b))\n\nt = sorted(t, key=lambda x: x[1], reverse=True)\n\nresult = 0\ni = 0\nwhile i < m and n > 0:\n if n < t[i][0]:\n result += n*t[i][1]\n n = 0\n else:\n result += t[i][0]*t[i][1]\n n -= t[i][0]\n i += 1\n\nprint result\n"}, {"source_code": "import sys, math\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nmatches = sorted([map(int, input().split()) for _ in range(m)], key=lambda x:x[1])[::-1]\nans = 0 \nfor match in matches: \n if not n: break\n ans += min(n, match[0]) * match[1]\n n -= min(n, match[0])\n\nprint ans"}, {"source_code": "z=list(map(int,input().split()))\n\ndi=[]\nfor i in range(z[1]):\n x=list(map(int,input().split()))\n x.reverse()\n di.append(x)\ndi.sort(reverse=True)\nc=0\n\nfor i in di:\n \n if z[0]<=0:\n break\n if i[1]>=z[0]:\n c+=z[0]*i[0]\n break\n else:\n c+=i[1]*i[0]\n z[0]-=i[1]\n \nprint(c)\n\n\n\n\n \n \n\n\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\nstart = time.clock()\nl=[]\nchk,ans=0,0\n(n,m)=map(int, raw_input().split())\nfor _ in range(m):\n i=map(int, raw_input().split())\n l.append(i)\n#print l\nl1=sorted(l, key=lambda l:l[1])\n# print l1\nl1.reverse()\nfor i in l1:\n if n==chk: break\n elif n>=chk+i[0]:\n ans+=i[0]*i[1]\n chk+=i[0]\n else:\n ans+=(n-chk)*i[1]\n chk+=(n-chk)\nprint ans"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin\n\nN, M = map(int, stdin.readline().split())\n\nv = []\nfor i in xrange(M):\n a, b = map(int, stdin.readline().split())\n v.append((b, a))\nv.sort()\nv.reverse()\nres = 0\nfor t in v: \n# print t[0], t[1], res\n if t[1] >= N:\n res += t[0] * N\n break\n N -= t[1]\n res += t[0] * t[1]\n\nprint res\n"}, {"source_code": "n,m=map(int,raw_input().split())\nc=[0]*16\nfor _ in range(m):\n a,b=map(int,raw_input().split())\n c[b]+=a\ns=0\nfor i in range(10):\n d=min(n,c[10-i])\n n-=d\n s+=d*(10-i)\nprint s\n"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\n\ndef some_func():\n \"\"\"\n \"\"\"\n n,m = map(int,raw_input().split(' '))\n count = 0\n temp_list = []\n for v in range(m):\n a,b = map(int,raw_input().split(' '))\n temp_list.append([b,a])\n temp_list.sort(reverse=1)\n for v in temp_list:\n\n if n<=0:\n break\n if n> v[1]:\n count+= v[1]*v[0]\n n -= v[1]\n else:\n count += n*v[0]\n n = 0\n print count\n\n\n\nif __name__ == '__main__':\n some_func()\n\n\n\n"}, {"source_code": "\nn,m = [int(x) for x in input().split()]\nD = {}\nB = []\nfor i in range(0,m):\n a,b = [int(x) for x in input().split()]\n if not (b in B):\n B.append(b)\n if b in D:\n D[b] += a\n else:\n D[b] = a\nB.sort()\nB.reverse()\nc1 = 0\nc2 = 0\ns = 0\nwhile (c2 < n and c1 <= len(B)-1):\n c2 += D[B[c1]]\n s += D[B[c1]]*B[c1]\n c1 += 1\n\nif c2 > n:\n s -= (c2-n)*B[c1-1]\nprint(s)"}, {"source_code": "from sys import stdin,stdout\n\ndef main():\n\tL=[]\n\tn,m=map(int,stdin.readline().split())\n\n\tfor i in range(m):\n\t\tL.append(stdin.readline().split())\n\n\tA=(sorted(L, key=lambda L: int(L[1]),reverse=True))\n\n\tmatches=0\n\n\tfor i in range(m):\n\t\ttemp=min(n,int(A[i][0]))\n\t\tn-=temp\n\t\tmatches+=temp*int(A[i][1])\n\n\tprint(matches)\n\n\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "R=lambda:map(int,raw_input().split())\nn,m=R()\nprint reduce(lambda x,y:x[0]and(x[0]-min(x[0],y[0]),x[1]+min(x[0],y[0])*y[1])or x,sorted([R()for i in range(m)],key=lambda x:-x[1]),(n,0))[1]"}, {"source_code": "R=lambda:map(int,raw_input().split())\nn,m=R()\nprint reduce(lambda x,y:(x[0]-min(x[0],y[0]),x[1]+min(x[0],y[0])*y[1]),sorted([R()for i in range(m)],key=lambda x:-x[1]),(n,0))[1]"}, {"source_code": "def solve():\n n, m = map(int, input().split())\n ab = []\n for _ in range(m): ab.append((tuple(map(int, input().split()))))\n put = 0\n for a, b in sorted(ab, key=lambda x: x[1], reverse=True):\n n -= a\n if n < 0: \n put += (a+n) * b\n return put\n put += a * b\n return put\nprint(solve())"}, {"source_code": "n, m = map(int, raw_input().split())\na = [ map(int, raw_input().split()) for _ in xrange(m) ]\n\na.sort(key = lambda x:x[1], reverse = True)\nans = 0\nfor i in range(m):\n get = min(n, a[i][0])\n n -= get\n ans += get * a[i][1]\nprint ans\n"}, {"source_code": "__author__ = 'kovshi'\n\nm, n = tuple([int(x) for x in raw_input().split()])\nboxes = []\nfor i in xrange(n):\n boxes.append([int(x) for x in raw_input().split()])\n boxes[i].reverse()\nboxes.sort()\nboxes.reverse()\nsum = 0\ni = 0\nwhile m > 0 and i < len(boxes):\n sum += min(boxes[i][1], m) * boxes[i][0]\n m -= boxes[i][1]\n i += 1\nprint sum"}, {"source_code": "import sys\n\nclass pythonin:\n _data = []\n _cur = 0\n def __init__(self):\n while True:\n try: sm = raw_input().split(\" \") \n except EOFError: break\n for x in sm :\n if x != \"\" and x != \"\\t\" :\n self._data.append(x)\n \n def eof(self) : \n return self._cur == len(self._data)\n\n def nextToken(self) :\n self._cur += 1\n return self._data[self._cur - 1]\n \n def nextInt(self) :\n return (int)(self.nextToken())\n \n#sys.stdin = open(\"input.txt\", \"r\")\n#sys.stdout = open(\"output.txt\", \"w\")\n\npin = pythonin()\n\nn = pin.nextInt()\nm = pin.nextInt()\n\na = [[pin.nextInt(),pin.nextInt()] for i in xrange(0, m)]\n\nfor x in a :\n x[0], x[1] = x[1], x[0]\n \na.sort()\na.reverse()\n\nres = 0\n\nfor x in a :\n res += min(n, x[1]) * x[0]\n n -= min(n, x[1])\n\nprint res\n\n#print (\"Press any key to continue\")\n#raw_input() \n"}, {"source_code": "n,m=[int(i) for i in input().split()]\nl=sorted([int(i) for i in reversed(input().split())] for j in range(m))\ns=0\nfor i in reversed(l):\n if i[1]>=n:\n print(s+n*i[0])\n break\n n-=i[1]\n s+=i[1]*i[0]\nelse:\n print(s)\n"}, {"source_code": "n, m = map(int, input().split())\ninfo = []\nfor _ in range(m):\n info.append(list(map(int, input().split())))\n \ninfo_sorted = info.copy()\nfor i in range(m-1):\n for j in range(m)[i+1:]:\n if info_sorted[i][1]<info_sorted[j][1]:\n info_sorted[j],info_sorted[i] = info_sorted[i],info_sorted[j]\n\nsum = 0\ncnt = 0\nfor a,b in info_sorted:\n sum=sum+a\n if sum<=n:\n cnt = cnt + a*b\n else:\n cnt = cnt + (n-(sum-a))*b \n break\n\nprint(cnt)"}, {"source_code": "#!/bin/python \n# -*- coding: utf-8 -*-\n\nfrom operator import itemgetter\n\nn, m = map(int, input().split())\ncontainers = []\n\nfor i in range(m):\n a, b = map(int, input().split())\n containers.append((a, b))\n\ncontainers.sort(key=itemgetter(1), reverse=True)\n\n\nans = 0\nfor (ai, bi) in containers:\n if n > ai:\n ans += (ai * bi)\n n -= ai\n else:\n ans += (n * bi)\n break\n\nprint(ans)\n\n"}, {"source_code": "total_box, m = map(int, raw_input().split()) \ncontainer = [0] * 11\nfor _ in range(m):\n box, matches = map(int, raw_input().split()) \n container[matches] += box\nr = 0\nfor i, box in enumerate(container[ : : -1]):\n r += (10 - i) * min(box, total_box)\n total_box -= min(box, total_box)\n if total_box == 0: break\n \n#print total_box, m \n#print container \nprint r"}, {"source_code": "raw = list(map(int, input().split(\" \")))\nn, m = raw[0], raw[1]\ncontainer = []\nfor i in range(m):\n container.append(list(map(int, input().split(\" \"))))\n container.sort(key = lambda x: x[1], reverse = True)\n\nsuma = 0\nfor i in container:\n if n >= i[0]:\n suma +=i[0] * i[1]\n n -= i[0]\n else:\n suma += n * i[1]\n n = 0\n if n == 0:\n break\nprint(suma)\n"}, {"source_code": "from itertools import *\nn, m = map (int, raw_input ().split ())\ncont = sorted ([map (int, raw_input ().split ())[::-1] for i in xrange (m)], reverse=True)\nans = 0\nfor b, a in cont:\n ans += min (a, n) * b\n n -= min (a, n)\n if n <= 0:\n break\nprint ans\n\n\n"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n\tl1=list(map(int,input().split()))\n\tl.append(l1)\nl.sort(reverse=True,key=lambda x:x[1])\ns=0\nfor i in range(m):\n\tif l[i][0]<=n:\n\t\ts+=l[i][0]*l[i][1]\n\t\tn-=l[i][0]\n\telse:\n\t\ts+=n*l[i][1]\n\t\tbreak\nprint(s)\n"}, {"source_code": "n, m = map(int, raw_input().split())\nf = []\nfor i in range(m):\n\ta, b = map(int, raw_input().split())\n\tf.append((b,a))\t\nf.sort()\nans = 0\nfor i in range(len(f)-1,-1,-1):\n\tt = min(f[i][1],n)\n\tn -= t;\n\tans += t * f[i][0]\nprint ans"}, {"source_code": "import operator\n\ntotal_size, containers = map(int, raw_input().split())\nmatchboxes = sorted([map(int, raw_input().split()) for _ in range(containers)], key=operator.itemgetter(1))[::-1]\n\nvolume = 0\nsize = 0\nfor s, v in matchboxes:\n delta = min(total_size-size, s)\n volume += v*delta\n size += delta\n\n if size == total_size:\n break\n\nprint volume\n\n"}, {"source_code": "from math import *\nfrom Queue import *\n\ns = raw_input()\nl = s.split(' ')\nn = int(l[0])\nm = int(l[1])\ntotal = 0\ndic = []\nfor i in range(m):\n s = raw_input()\n l = s.split(' ')\n dic.append([int(l[1]), int(l[0])])\nfor b in range(10, -1, -1):\n if n <= 0:\n break\n for i in range(m):\n if dic[i][0] == b:\n total += min(n, dic[i][1]) * b\n n -= dic[i][1]\n if n <= 0:\n break\nprint(total)\n\n\n \n\n\n\n\"\"\"class segment(object):\n def __init__(self, x1, y1, x2, y2):\n self.ver, self.hor, self.point = False, False, False\n if x1 == x2:\n self.ver = True\n if y1 == y2:\n self.hor = True\n if (x1 == x2) and (y1 == y2):\n self.point = True\n minx = min(x1,x2)\n maxx = max(x1,x2)\n miny = min(y1,y2)\n maxy = max(y1,y2)\n self.x1 = minx\n self.x2 = maxx\n self.y1 = miny\n self.y2 = maxy\n\ndef rectangle(horseg, verseg):\n if (horseg[0].x1 != horseg[1].x1) or (horseg[0].x2 != horseg[1].x2):\n return False\n if (verseg[0].y1 != verseg[1].y1) or (verseg[0].y2 != verseg[1].y2):\n return False\n miny = min(horseg[0].y1, horseg[1].y1)\n maxy = max(horseg[0].y1, horseg[1].y1)\n minx = min(verseg[0].x1, verseg[1].x1)\n maxx = max(verseg[0].x1, verseg[1].x1)\n if (minx != horseg[0].x1) or (maxx != horseg[0].x2):\n return False\n if (miny != verseg[0].y1) or (maxy != verseg[0].y2):\n return False\n return True\n\nhorseg = []\nverseg = []\nfor i in xrange(4):\n s = raw_input()\n l = s.split(' ')\n new_seg = segment(int(l[0]), int(l[1]), int(l[2]), int(l[3]))\n if (new_seg.hor == False) and (new_seg.ver == False):\n print('NO')\n break\n if new_seg.point:\n print('NO')\n break\n if new_seg.hor:\n horseg.append(new_seg)\n else:\n verseg.append(new_seg)\nif (len(horseg) != 2):\n print('NO')\nelse:\n if rectangle(horseg, verseg):\n print('YES')\n else:\n print('NO')\"\"\"\n\n \n \n\n\n\n\"\"\"from math import *\nfrom Queue import *\n\ndef bfs(G, start):\n visited = set([start])\n Q = Queue()\n Ret = [start]\n Q.put(start)\n while not Q.empty():\n vertex = Q.get()\n for v in G[1][vertex]:\n if v not in visited:\n Q.put(v)\n visited.add(v)\n Ret.append(v)\n return Ret\n\ndef longest_path(G):\n l = bfs(G,G[0][0])\n marked = set()\n result = dict()\n for i in l:\n result[i] = [0,i,0,i]\n for i in range(len(l)-1, -1, -1):\n for j in G[1][l[i]]:\n if j in marked:\n if (result[j][2] > result[l[i]][2]) or ((result[j][2] == result[l[i]][2]) and (result[j][3] < result[l[i]][3])):\n result[l[i]][2] = result[j][2]\n result[l[i]][3] = result[j][3]\n if (result[l[i]][0] + result[j][0] + 1 > result[l[i]][2]):\n result[l[i]][2] = result[l[i]][0] + result[j][0] + 1\n result[l[i]][3] = min(result[l[i]][1], result[j][1])\n if ((result[l[i]][0] + result[j][0] + 1 == result[l[i]][2]) and (min(result[l[i]][1],result[j][1]) < result[l[i]][3])):\n result[l[i]][3] = min(result[l[i]][1],result[j][1])\n if (result[j][0] + 1 > result[l[i]][0]) or ((result[j][0] + 1 == result[l[i]][0]) and (result[j][1] < result[l[i]][1])):\n result[l[i]][0] = result[j][0] + 1\n result[l[i]][1] = result[j][1]\n marked.add(l[i])\n return (result[l[0]][2], result[l[0]][3])\n\ndef remove(G,v):\n ver = G[0]\n ver.remove(v)\n edg = dict()\n for i in ver:\n nb = []\n for j in G[1][i]:\n if j != v:\n nb.append(j)\n edg[i] = nb\n return (ver, edg)\n\ndef harvest(G,M):\n l = bfs(G,M[0])\n seen = set()\n delete = []\n for i in range(len(l)-1, -1, -1):\n seen.add(l[i])\n if l[i] in M:\n for j in G[1][l[i]]:\n if j not in seen:\n M.append(j)\n if l[i] not in M:\n delete.append(l[i])\n for i in delete:\n G = remove(G,i)\n return G\n\ns = raw_input()\nl = s.split(' ')\nn = int(l[0])\nm = int(l[1])\nV = []\nAdj = [[] for i in range(n+1)]\nfor i in range(1,n+1):\n V.append(i)\nE = dict()\nfor i in range(n-1):\n s = raw_input()\n l = s.split(' ')\n h = int(l[0])\n t = int(l[1])\n Adj[h].append(t)\n Adj[t].append(h)\nE = dict()\nfor i in range(1, n+1):\n E[i] = Adj[i]\nG = [V,E]\ns = raw_input()\nl = s.split(' ')\nM = []\nfor i in range(m):\n M.append(int(l[i]))\nG = harvest(G,M)\nsol = longest_path(G)\nprint(sol[1])\nprint(2*len(G[0]) - 2 - sol[0])\"\"\"\n"}, {"source_code": "n,m=map(int,input().split())\nans=0\nd=[]\nfor x in range(m):\n\ta,b=map(int,input().split())\n\td.append([b,a])\nd.sort(key=lambda index: index[0],reverse=True)\nfor x in d:\n\tans+=x[0]*(x[1] if x[1]<=n else n)\n\tn-=(x[1] if x[1]<=n else n)\nprint(ans)"}, {"source_code": "#! /usr/bin/python\nimport sys\n\n#nacteni 2 cisel\nnumbers = sys.stdin.readline()[:-1].split()\nn = int(numbers[0])\nm = int(numbers[1])\n\n# zde seznam seznamu\nlist = []\n#nacitani cisel v radku do promenne\nfor i in range(m):\n line = sys.stdin.readline()[:-1].split()\n a = int(line[0])\n b = int(line[1])\n list.append((b,a))\n\nlist.sort()\nlist.reverse()\n\nnumber = 0\ntaken = 0\nwhile (list != []) and (taken + list[0][1] <= n):\n taken += list[0][1]\n number += list[0][0]*list[0][1]\n x = list.pop(0)\n\nif (list != []) and (taken < n):\n number += list[0][0]*(n-taken)\n\nprint number\n\n\n\n\n \n"}, {"source_code": "value = input()\nn = int(value.split()[0])\nmatrix = [[0] * 2 for i in range(int(value.split()[1]))]\ntotal = 0\nfor i in range(len(matrix)):\n value = input()\n int(value.split()[0])\n matrix[i][0] = int(value.split()[0])\n matrix[i][1] = int(value.split()[1])\n\n# defines a mini function inside the call using lambda\n# is tells the sort function to use the 2nd item to sort on it\n# rather than the 1st value (it's default value)\nmatrix.sort(key=lambda x: x[1])\n\nfor i in range(len(matrix)):\n if n >= matrix[-i - 1][0]:\n n -= matrix[-i - 1][0]\n total += matrix[-i - 1][0] * matrix[-i - 1][1]\n continue\n else:\n total += n * matrix[-i - 1][1]\n break\n\nprint(total)"}, {"source_code": "from operator import itemgetter\n\nL0 = input().split()\nn = int(L0[0]) # the rucksack con hold n matchboxes\nm = int(L0[1]) # there are m containers\nL = list()\nfor i in range(m):\n L.append(input().split())\nfor i in range(m):\n for j in range(2):\n L[i][j] = int(L[i][j])\n# L[i][0]= number of matchboxes\n# L[i][1]= number of matches in these matchboxes\nL1 = sorted(L, reverse=True, key=itemgetter(1))\nif sum(L1[k][0] for k in range(m)) < n:\n print(sum(L1[k][0] * L1[k][1] for k in range(m)))\n exit(0)\ns = 0\nk = 0\nwhile n > 0 and k <= m - 1:\n if L1[k][0] <= n: # we can take the entiere container\n s += L1[k][0] * L1[k][1]\n n -= L1[k][0]\n else:\n s += n * L1[k][1]\n n = 0\n k += 1\nprint(s)\n"}, {"source_code": "n, m = map(int,input().split())\ns = []\nans = 0\nfor i in range(m):\n s.append(tuple(map(int, input().split())))\ns.sort(reverse=True, key=lambda x:x[1])\nfor i in s:\n m = min(n,i[0])\n ans += m*i[1]\n n -= m\n if n == 0:\n break\nprint(ans)\n \n \n\n \n \n \n \n \n \n\n\n\n \n"}, {"source_code": "n, m = [int(x) for x in input().split(' ')]\nmbs = {i: 0 for i in range(1, 11)}\nfor i in range(m):\n a, b = [int(x) for x in input().split(' ')]\n mbs[b] += a\n matches = 0\n matchboxes = 0\n i = 10\n while matchboxes < n and i > 0:\n x = min(n - matchboxes, mbs[i])\n matches += x * i\n matchboxes += x\n i -= 1\nprint(matches)"}, {"source_code": "I = lambda: map(int, input().split())\n\nn, m = I()\nC = sorted((tuple(I()) for _ in range(m)), key=lambda x: x[1])\ns = 0\n\nwhile n and C:\n a, b = C.pop()\n x = min(a,n)\n s += b*x\n n -= x\n\nprint(s)"}, {"source_code": "n,m=map(int,input().split())\ncont=[]\nmatch=[]\n\nfor _ in range(m):\n a,b=map(int,input().split())\n cont.append(a)\n match.append(b)\ncount=0\nif len(cont)>1:\n while n>0:\n if len(cont)>0:\n ma=max(match)\n ind=match.index(ma)\n if n>=cont[ind]:\n n=n-cont[ind]\n count=count+cont[ind]*match[ind]\n else:\n count=count+n*match[ind]\n n=0\n match.pop(ind)\n cont.pop(ind)\n else:\n break\nelse:\n if n>cont[0]:\n count=cont[0]*match[0]\n else:\n count=n*match[0]\nprint(count)\n"}, {"source_code": "[n,m] = [int(x) for x in input().split()]\na=[]\n\nfor i in range (m) : \n\ta.append([int(x) for x in input().split()])\n\n\na = sorted(a , key = lambda x : x[1] ,reverse = True)\nk = 0\n\nwhile n > 0 and len(a) > 0:\n\tif n >= a[0][0] :\n\t\tk += a[0][0]*a[0][1]\n\t\tn -= a[0][0]\n\t\ta.pop(0)\n\telse :\n\t\tk += n *a[0][1]\n\t\tn = 0\n\t\n\n\nprint(k)"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial, log,tan,pi,cos,sin,radians\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod_ = int(1e9) + 7\nmod = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve(m):\n n=1\n primes = {}\n arr=set([])\n for i in range(2, int(m ** 0.5) + 1):\n a = n // i\n b = m // i\n for k in range(max(2, a), b + 1):\n c = i * k\n primes[c] = 1\n\n for i in range(max(n, 2), m + 1):\n if i not in primes:\n arr.add(i)\n\n return arr\n\n\nclass DisjointSetUnion:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n \n def find(self, a):\n acopy = a\n while a != self.parent[a]:\n a = self.parent[a]\n while acopy != a:\n self.parent[acopy], acopy = a, self.parent[acopy]\n return a\n \n def union(self, a, b):\n a, b = self.find(a), self.find(b)\n if a != b:\n if self.size[a] < self.size[b]:\n a, b = b, a\n \n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n \n def set_size(self, a):\n return self.size[self.find(a)]\n \n def __len__(self):\n return self.num_sets\n\n\n\ndef main():\n n,m=map(int,input().split())\n arr=[]\n mat=[]\n cnt=0\n for i in range(m):\n a,b=map(int,input().split())\n arr.append((b,a))\n arr.sort(reverse=True)\n s=0\n cnt=0\n for i in range(m):\n t=min(arr[i][1],n)\n n-=t\n cnt+=t*arr[i][0]\n print(cnt)\n \n\n\n\n \n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "def s():\n [n,m] = list(map(int,input().split()))\n a = [list(reversed(list(map(int,input().split()))))for _ in range(m)]\n a.sort(reverse=True)\n r = 0\n for i in a:\n if n > 0:\n r += min(n,i[1])*i[0]\n n -= min(n,i[1])\n else:\n break\n print(r)\ns()\n"}], "negative_code": [{"source_code": "from collections import defaultdict\nn,m = map(int,raw_input().split())\ncounter = defaultdict(int)\nfor i in range(m):\n a,b = map(int,raw_input().split())\n counter[b]+=a\ncounter = sorted(counter.items(), key=lambda x: x[0],reverse=True)\nprint(counter)\ni = 0\ncounter_length = len(counter)\nscore = 0\nwhile (n > 0 and i < counter_length):\n if counter[i][1] >= n:\n itemsToTake = n\n score+=counter[i][0]*itemsToTake\n n -=itemsToTake\n else:\n score+=counter[i][0]*counter[i][1]\n n-=counter[i][1]\n i+=1\nprint(score)"}, {"source_code": "import collections\ns=list(map(int,input().split()))\nn=s[0]\nm=s[1]\nmydict={}\nfor i in range(m):\n t=input().split()\n mydict[int(t[1])]=int(t[0])\nsize=list(mydict.values())\nwt=list(mydict.keys())\narr=sorted(mydict.items())\ncount=0\ni=len(wt)-1\nwhile(i>=0):\n w1=arr[i][0]\n s1=arr[i][1]\n if(n>=s1):\n count=count+(s1*w1)\n n=n-s1\n \n elif(n<s1):\n count=count+(n*w1)\n n=n-n\n i=i-1\nprint(count)\n"}, {"source_code": "# https://codeforces.com/contest/16/problem/B\nfrom itertools import combinations\n\nn , m = map(int,raw_input().split(' '))\nk = m\nconatiners = []\nwhile k:\n conatiners.append(list(map(int,raw_input().split(' '))))\n k = k-1\nop = []\nfor item in combinations (conatiners,2):\n t1 , t2 = item[0], item[1]\n op.append( t1[0]*t1[1]+ t2[0]* t2[1])\n\n# print op\nop = sorted(op)\nprint op[-1]\n\n\n\n"}, {"source_code": "from sys import stdin,stdout\n\ndef main():\n\tL=[]\n\tn,m=map(int,stdin.readline().split())\n\n\tfor i in range(m):\n\t\tL.append(stdin.readline().split())\n\n\tA=(sorted(L, key=lambda L: int(L[0])*int(L[1]),reverse=True))\n\n\tmatches=0\n\n\tfor i in range(m):\n\t\tif n==0: break\n\t\ttemp=int(A[i][0])\n\t\tfor j in range(int(A[i][0])):\n\t\t\tn-=1\n\t\t\ttemp-=1\n\t\t\tmatches+=int(A[i][1])\n\t\t\tif n==0 or temp==0:\n\t\t\t\tbreak\n\n\tprint(matches)\n\n\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "n, m = map(int, input().split())\ncon = {}\nc = 0\nfor i in range(m):\n x, y = map(int, input().split())\n con[x] = y\nd = dict(sorted(con.items(), key=lambda kv: kv[1], reverse=True))\nfor k, v in d.items():\n for i in range(k):\n c += v\n n -= 1\n if n == 0:\n print(c)\n exit()\n"}, {"source_code": "import sys\nimport math\nimport functools\ninput = sys.stdin.readline\n\nn, m = map(int, input().strip().split())\na = []\n\nfor _ in range(m):\n z = list(map(int, input().strip().split()))\n a.append(z)\ndef compare(A, B):\n if A[0] * A[1] > B[0] * B[1]: return 1\n elif A[0] * A[1] < B[0] * B[1]: return -1\n else:\n if A[0] < B[0]: return 1\n elif A[0] > B[0]: return -1\n else: return 0\n\na.sort(key = functools.cmp_to_key(compare), reverse=True)\nans = 0\nfor el in a:\n ans += min(n, el[0]) * el[1]\n n -= min(n, el[0])\nprint(ans)\n"}, {"source_code": "#\tAuthor\t: debugster\n#\tEmail\t: alive.dew@gmail.com\n#\tDate\t: 2020-06-03 21:49:06\n\nimport sys\nimport os\n\ndef get_int():\n return map(int, input().split())\n\ndef get_array():\n return list(map(int, input().split()))\n\nif os.environ.get(\"DEBUGSTER_PYTHON\"):\n\tsys.stdin = open('in.txt', 'r')\n\tsys.stdout = open('out.txt','w')\n\nclass MatchBox:\n\tdef __init__(self, a, b):\n\t\tself.a, self.b = a, b\n\t\n\tdef __lt__(self, other):\n\t\tif self.a * self.b == other.a * other.b:\n\t\t\treturn self.b > other.b\n\t\t\n\t\treturn self.a * self.b > other.a * other.b\n\nn, m = get_int()\nall_m = list()\nfor _ in range(m):\n\ta, b = get_int()\n\tall_m.append(MatchBox(a, b))\nall_m = sorted(all_m)\n\n\nans = 0\nremain = n\nfor x in all_m:\n\ttake = min(x.a, remain)\n\tans += take * x.b\n\tremain -= take\n\tif remain <= 0:\n\t\tbreak\n\nprint(ans)"}, {"source_code": "n, m = list(map(int, input().split()))\n\nmatch = {}\n\nfor _ in range(m):\n Ai, Bi = list(map(int, input().split()))\n \n match[Ai] = Bi\n\nmatchs = [(k, match[k]) for k in sorted(match, key=match.get, reverse=True)]\n\nans = 0\nfor k, v in matchs:\n if k <= n:\n ans += k * v\n n -= k\n elif n < k:\n ans += n * v\n break\n\nprint(ans)"}, {"source_code": "n,m = map(int,input().split())\n\n\nf=[]\n\n\nfor k in range(m):\n f.append(list(map(int,input().split()))[::-1])\n\nf.sort()\n\n\n\n\ng=f[::-1]\np=0\n\nwhile n:\n for u in g:\n if u[1]<=n:\n p+=u[1]*(u[0])\n n-=u[1]\n elif u[1]>n:\n p+= u[0]*n\n n=0\n\nprint(p)\n \n"}, {"source_code": "n, m = list(map(int, input().split()))\nd = {}\nlst1 = []\nlst2 = []\nfor i in range(m):\n\tval1, val2 = list(map(int, input().split())) \n\tlst1.append(val1)\n\tlst2.append(val2)\ncnt = 0\nwhile n > 0:\n\tmaxx, ind = -1, 0\n\tfor i in range(len(lst2)):\n\t\tif lst2[i]*lst1[i] > maxx:\n\t\t\tmaxx = lst2[i]*lst1[i]\n\t\t\tind = i\n\ti = ind\n\tif lst1[i] <= n:\n\t\tcnt += lst2[i]*lst1[i]\n\t\tn -= lst1[i]\n\t\tlst2 = lst2[:i] + lst2[i+1:]\n\t\tlst1 = lst1[:i] + lst1[i+1:]\n\telse:\n\t\tcnt += n * lst2[i]\n\t\tbreak\n\n\tif lst1 == []:\n\t\tbreak\nprint(cnt)\n"}, {"source_code": "n, m = map(int, input().split())\na = [[int(j) for j in input().split()] for i in range(m)]\na.sort(key=lambda x: x[1], reverse=True)\nc = 0\nfor k, v in a:\n if n >= k:\n c += k*v\n n -= k\n if n == 0:\n print(c)\n exit()\n else:\n c += n*v\n print(c)\n exit()\n\n\n\n\n\n\n\n\n\n\n\n\n# con = {}\n# c = 0\n# for i in range(m):\n# x, y = map(int, input().split())\n# con[y] = x\n# #d = dict(sorted(con.items(), key=lambda kv: kv[1], reverse=True))\n# d = dict(sorted(con.items(), reverse=True))\n#\n# for v, k in d.items():\n# for i in range(k):\n# c += v\n# n -= 1\n# if n == 0:\n# print(c)\n# exit()\n"}, {"source_code": "arr1 = raw_input()\nl1 = map(int,arr1.split())\n\n# print l1\nn = l1[0]\n#No of containers \nm = l1[1]\n\n# l2 = [[1,3],[2,2],[3,1]]\n\nl2 = []\n\nfor i in range(m):\n\tarr2 = raw_input()\n\tl2.append(map(int,arr2.split()))\n\n# print l2\n\nl2.sort(reverse= True, key=lambda x: x[1])\nprint l2\n\n\ncount = 0\n\nwhile(n>0):\n\tfor i in range(m):\n\t\tif n <= l2[i][0]:\n\t\t\tcount = count + n*l2[i][1]\n\t\t\tn = 0\n\t\telse:\n\t\t\tcount = count + l2[i][0]*l2[i][1]\n\t\t\tn = n - l2[i][0]\n\nprint count "}, {"source_code": "n,m=[int(x) for x in input().split()]\nlist1=[]\nmx=0\nz=0\nfor i in range(m):\n list2=[int(x) for x in input().split()]\n list1.append(list2)\n\nmn=0 \nfor i in range(m):\n list1[i][0],list1[i][1]=list1[i][1],list1[i][0]\n \nlist1.sort(reverse=True) \n\nfor i in range(m):\n if n<mn:\n mn=n\n if n>0:\n n=n-list1[i][1]\n mx=mx+list1[i][1]*list1[i][0]\n \n if mn<=0:\n mx=mx-((-1)*(mn)*list1[i-1][0])\nprint(mx)"}, {"source_code": "n,m=[int(i) for i in input().split()]\nl=sorted([int(i) for i in reversed(input().split())] for j in range(m))\ns=0\nfor i in reversed(l):\n if i[1]>=n:\n print(s+n*i[0])\n break\n n-=i[1]\n s+=i[1]*i[0]\n \n"}, {"source_code": "arr1 = raw_input()\nl1 = map(int,arr1.split())\n\n# print l1\nn = l1[0]\n#No of containers \nm = l1[1]\n\n# l2 = [[1,3],[2,2],[3,1]]\n\nl2 = []\n\nfor i in range(m):\n\tarr2 = raw_input()\n\tl2.append(map(int,arr2.split()))\n\n# print l2\n\nl2.sort(reverse= True, key=lambda x: x[1])\n# print l2\n\n\ncount = 0\n\nwhile(n>0):\n\tfor i in range(m):\n\t\tif n <= l2[i][0]:\n\t\t\tcount = count + n*l2[i][1]\n\t\t\tn = 0\n\t\telse:\n\t\t\tcount = count + l2[i][0]*l2[i][1]\n\t\t\tn = n - l2[i][0]\n\nprint count "}, {"source_code": "import os\n\nbox_cont = input().rstrip().split()\nn=int(box_cont[0])\nm=int(box_cont[1])\nhah=[0]*11\nfor i in range(m):\n a_b=input().rstrip().split()\n a=int(a_b[0])\n b=int(a_b[1])\n hah[b]=a\ntotal=0\nfor i in range(10,0,-1):\n if hah[i]!= 0:\n if n-hah[i]>=0:\n total+=(hah[i]*i)\n n=n-hah[i]\n else:\n total+=i*n\n break\nprint(total)\n"}, {"source_code": "#\tAuthor\t: debugster\n#\tEmail\t: alive.dew@gmail.com\n#\tDate\t: 2020-06-03 21:49:06\n\nimport sys\nimport os\n\ndef get_int():\n return map(int, input().split())\n\ndef get_array():\n return list(map(int, input().split()))\n\nif os.environ.get(\"DEBUGSTER_PYTHON\"):\n\tsys.stdin = open('in.txt', 'r')\n\tsys.stdout = open('out.txt','w')\n\nclass MatchBox:\n\tdef __init__(self, a, b):\n\t\tself.a, self.b = a, b\n\t\n\tdef __lt__(self, other):\n\t\tif self.a * self.b == other.a * other.b:\n\t\t\treturn self.b > other.b\n\t\t\n\t\treturn self.a * self.b > other.a * other.b\n\nn, m = get_int()\nall_m = list()\nfor _ in range(m):\n\ta, b = get_int()\n\tall_m.append(MatchBox(a, b))\nall_m = sorted(all_m)\n\n\nans = 0\nremain = n\nfor x in all_m:\n\ttake = min(x.a, remain)\n\tans += take * x.b\n\tremain -= take\n\tif remain <= 0:\n\t\tbreak\n\nprint(ans)"}, {"source_code": "'''D = dict()\nfor i in range(1,5):\n\tD[i] = i*i\ndel D[4]\nfor i in range(1,len(D)):\n\tvalue = D[i]\n\tprint(value)\n\tprint(D)\nprint(max(D))'''\n\ndef swap(i , j):\n\ti , j = j , i\nif __name__ == '__main__':\n\tn,m = map(int, input().split())\n\tA,B=[] , []\n\tfor _ in range(m):\n\t\ta , b = map(int , input().split())\n\t\tA.append(a)\n\t\tB.append(b)\n\tfor i in range(m):\n\t\tfor j in range(i+1,m):\n\t\t\tif B[j]>B[i]:\n\t\t\t\tswap(A[i],A[j])\n\t\t\t\tswap(B[i] , B[j])\n\tans = 0\n\tfor i in range(m):\n\t\ta = min(n , A[i])\n\t\tans += B[i]*a\n\t\tn -=a\n\tprint(ans)\n\t"}, {"source_code": "arr1 = raw_input()\nl1 = map(int,arr1.split())\n\n# print l1\nn = l1[0]\n#No of containers \nm = l1[1]\n\n# l2 = [[1,3],[2,2],[3,1]]\n\nl2 = []\n\nfor i in range(m):\n\tarr2 = raw_input()\n\tl2.append(map(int,arr2.split()))\n\n# print l2\n\nl2.sort(reverse= True, key=lambda x: x[1])\nprint l2\n\n\ncount = 0\n\nwhile(n>0):\n\tfor i in range(m):\n\t\tif n <= l2[i][0]:\n\t\t\tcount = count + n*l2[i][1]\n\t\t\tn = 0\n\t\telse:\n\t\t\tcount = count + l2[i][0]*l2[i][1]\n\t\t\tn = n - l2[i][0]\n\nprint count "}, {"source_code": "from collections import defaultdict\nn,m = map(int,raw_input().split())\ncounter = defaultdict(int)\nfor i in range(m):\n a,b = map(int,raw_input().split())\n counter[b]+=a\ncounter = sorted(counter.items(), key=lambda x: x[0],reverse=True)\nprint(counter)\ni = 0\ncounter_length = len(counter)\nscore = 0\nwhile (n > 0 and i < counter_length):\n if counter[i][1] >= n:\n itemsToTake = n\n score+=counter[i][0]*itemsToTake\n n -=itemsToTake\n else:\n score+=counter[i][0]*counter[i][1]\n n-=counter[i][1]\n i+=1\nprint(score)"}, {"source_code": "n,m = map(int,input().split())\nA = []\nfor i in range(m):\n a,b = map(int,input().split())\n A.append([b,a])\nA.sort()\n#print(A)\ni=m-1\nans=0\nwhile(n>0):\n ans+=A[i][0]*min(n,A[i][1])\n n-=A[i][1]\n i-=1\nprint(ans)"}, {"source_code": "n,m=[int(i) for i in input().split()]\nl=sorted([int(i) for i in reversed(input().split())] for j in range(m))\ns=0\nfor i in reversed(l):\n if i[1]>=n:\n print(s+n*i[0])\n break\n n-=i[1]\n s+=i[1]*i[0]\n \n"}, {"source_code": "n,m=[int(i) for i in input().split()]\na=m*[0]\nb=m*[0]\nfor i in range(m):\n a[i],b[i]=[int(i) for i in input().split()]\nfor i in range(1-1,m):\n bish=b[0]\n k=0\n for j in range(1,m-i):\n if b[j]>bish:\n bish=b[j]\n k=j\n a[k],a[m-1-i]=a[m-1-i],a[k]\n b[k],b[m-1-i]=b[m-1-i],b[k]\na.reverse()\nb.reverse()\ni=0\nh=0\nr=0\nwhile i<m:\n if h+n<=n:\n r+=a[i]*b[i]\n h+=a[i]\n i+=1\n else:\n z=n-h\n r+=z*b[i]\n break\nprint(r)\n"}, {"source_code": "arr1 = raw_input()\nl1 = map(int,arr1.split())\n\n# print l1\nn = l1[0]\n#No of containers \nm = l1[1]\n\n# l2 = [[1,3],[2,2],[3,1]]\n\nl2 = []\n\nfor i in range(m):\n\tarr2 = raw_input()\n\tl2.append(map(int,arr2.split()))\n\n# print l2\n\ntotal_m = 0\ntotal_mb = 0\n\nfor i in range(m):\n\ttotal_m = total_m + l2[i][0]*l2[i][1]\n\ttotal_mb = total_mb + l2[i][0]\n# print total_m\n# print total_mb\n\nl2.sort(reverse= True, key=lambda x: x[1])\n# print l2\n\n\ncount = 0\n\n\nif total_m<n:\n\tcount = total_mb\nelse:\n\twhile(n>0):\n\t\tfor i in range(m):\n\t\t\tif n <= l2[i][0]:\n\t\t\t\tcount = count + n*l2[i][1]\n\t\t\t\tn = 0\n\t\t\telse:\n\t\t\t\tcount = count + l2[i][0]*l2[i][1]\n\t\t\t\tn = n - l2[i][0]\n\nprint count "}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial, log,tan,pi,cos,sin,radians\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod_ = int(1e9) + 7\nmod = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve(m):\n n=1\n primes = {}\n arr=set([])\n for i in range(2, int(m ** 0.5) + 1):\n a = n // i\n b = m // i\n for k in range(max(2, a), b + 1):\n c = i * k\n primes[c] = 1\n\n for i in range(max(n, 2), m + 1):\n if i not in primes:\n arr.add(i)\n\n return arr\n\n\nclass DisjointSetUnion:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n \n def find(self, a):\n acopy = a\n while a != self.parent[a]:\n a = self.parent[a]\n while acopy != a:\n self.parent[acopy], acopy = a, self.parent[acopy]\n return a\n \n def union(self, a, b):\n a, b = self.find(a), self.find(b)\n if a != b:\n if self.size[a] < self.size[b]:\n a, b = b, a\n \n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n \n def set_size(self, a):\n return self.size[self.find(a)]\n \n def __len__(self):\n return self.num_sets\n\n\n\ndef main():\n n,m=map(int,input().split())\n arr=[]\n mat=[]\n cnt=0\n for i in range(m):\n a,b=map(int,input().split())\n arr.append(a)\n mat.append(b)\n mat.sort(reverse=True)\n s=0\n cnt=0\n for i in range(m):\n if s==n:\n break\n cnt+=arr[i]*mat[i]\n s+=arr[i]\n print(cnt) \n \n \n\n\n\n \n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "line1=input().split()\nn=int(line1[0])\nm=int(line1[1])\na=[]\nwhile m>0:\n new=input().split()\n new.reverse()\n a.append(list(map(int,new)))\n m -=1\ntest=dict(a)\nres=0\nfor i in range(0,len(test)):\n if n <=0:\n break\n num_of_matchbox=max(test)\n number_of_box=int(test[num_of_matchbox])\n if number_of_box > n:\n res +=n*num_of_matchbox\n n -=n\n elif n>=number_of_box:\n res += num_of_matchbox*number_of_box\n n -=number_of_box\n test.pop(max(test))\nprint(res)"}, {"source_code": "from sys import stdin\nimport operator\n\ndef main():\n nm = [int(i) for i in stdin.readline().split()]\n n = nm[0]\n m = nm[1]\n boxes = {}\n matches = []\n answer = 0\n counter = 0 \n for i in range(m):\n temp = [int(t) for t in stdin.readline().split()]\n if temp[1] in boxes:\n boxes[temp[1]] += temp[0];\n counter +=1\n else:\n boxes[temp[1]] = temp[0];\n matches.append(temp[1])\n\n matches.sort()\n #matches = matches[::-1] \n m -= counter\n delta = n\n i = m-1\n while(delta > 0):\n if delta-boxes[matches[i]] >= 0:\n delta -= boxes[matches[i]]\n answer += matches[i]*boxes[matches[i]]\n else:\n answer += delta * matches[i]\n delta = 0\n i -= 1\n print(answer)\n\nmain()\n"}, {"source_code": "n,m = map(int,input().split())\nd = {}\nfor i in range(m):\n a,b = map(int,input().split())\n d[a] = b\nd = sorted(d.items(),reverse = True)\ncount = 0\n# print(d)\nfor i in d:\n if n>0:\n if n-i[0] >0:\n count +=(i[0])*i[1]\n n -=i[0]\n else:\n count += (n)*i[1]\n n = 0\nprint(count)\n"}, {"source_code": "n,m=input().split()\nn,m=[int(n),int(m)]\na=[]\nfor i in range(0,m):\n a.append([int(i) for i in input().split()])\na.sort(key=lambda x:x[1], reverse=True)\nc=0\nfor i in range(0,m):\n if a[0][0]<=n:\n c+=(a[i][0]*a[i][1])\n n=n-a[i][0]\n else:\n c+=(n*a[i][1])\n break\nprint(c)"}, {"source_code": "#!/bin/python \n# -*- coding: utf-8 -*-\n\nn, m = map(int, input().split())\ncontainers = []\nfor i in range(m):\n a, b = map(int, input().split())\n containers.append([a, b])\ncontainers.sort(reverse=True)\n\nans = 0\nfor (ai, bi) in containers:\n if n > ai:\n ans += (ai * bi)\n n -= ai\n else:\n ans += (n * bi)\n break\n\nprint(ans)\n\n"}, {"source_code": "l=list(map(int,raw_input().split()))\nn = l[0]\nm = l[1]\na=[]\nfor i in range (m):\n\tx = list(map(int,raw_input().split()))\n\ta.append(x)\na.sort(key=lambda x:x[1],reverse=True)\ncount = 0\ntotal = 0\nfor i in a:\n\t# while count<n and i[0]>0:\n\t# \tcount+=1\n\t# \ttotal+=i[1]\n\t# \ti[0]-=1\n\tif i[0]<n and count+i[0]<=n:\n\t\tcount+=i[0]\n\t\ttotal+=i[1]*i[0]\n\telif i[0]<n and count+i[0]>n:\n\t\tdiff = n-count\n\t\ttotal+=i[1]*diff\n\telif i[0]>n:\n\t\tdiff = n-i[0]\n\t\ttotal+=i[1]*diff\n\t#print 't',total\n\nprint total\n"}, {"source_code": "k,n=map(int,input().split())\nd={}\nd1=[]\nres=0\nfor i in range(n):\n a,b=map(int,input().split())\n if b in d:\n d[b]+=a\n else:\n d[b]=a\n d1.append(b)\nd1.sort()\nd1.reverse()\n# print(d)\n# print(d1)\nfor i in d1:\n if k>=d[i]:\n res+=(d[i]*i)\n k-=d[i]\n else:\n res+=(k*i)\n k-=d[i]\n # print(res)\n if k<=0:\n break\nprint(res)\n \n \n\n "}, {"source_code": "n, m = map(int, input().split())\na = [[int(j) for j in input().split()] for i in range(m)]\na.sort(key=lambda x: x[1], reverse=True)\nc = 0\nfor k, v in a:\n if n >= k:\n c += k*v\n n -= k\n if n == 0:\n print(c)\n exit()\n else:\n c += n*v\n print(c)\n exit()\n\n\n\n\n\n\n\n\n\n\n\n\n# con = {}\n# c = 0\n# for i in range(m):\n# x, y = map(int, input().split())\n# con[y] = x\n# #d = dict(sorted(con.items(), key=lambda kv: kv[1], reverse=True))\n# d = dict(sorted(con.items(), reverse=True))\n#\n# for v, k in d.items():\n# for i in range(k):\n# c += v\n# n -= 1\n# if n == 0:\n# print(c)\n# exit()\n"}, {"source_code": "def list_input(data):\n\treturn list(map(data, input().strip().split()))\n\ndef single_input(data):\n\treturn map(data, input().strip().split())\n\nn ,m = single_input(int)\nr2 = []\nres = 0\nfor a in range(0, m):\n\ta, b = single_input(int)\n\n\n\tr2.append([b, a])\nr2.sort()\nr2.reverse()\n\nwhile n > 0:\n\tif r2[0][1] <= n:\n\t\tn -= r2[0][1]\n\t\tres += (r2[0][0]*r2[0][1])\n\t\tr2[0] = [0, 0]\n\t\tr2.sort()\n\t\tr2.reverse()\n\telse:\n\t\tn = 0\n\t\tr2[0][1] = 0\n\t\tres += r2[0][0]\n\t\tif r2[0][1] == 0:\n\t\t\tr2[0] = [0, 0]\n\t\tr2.sort()\n\t\tr2.reverse()\n\tif r2[0] == [0,0]:\n\t\tbreak\n\t# print(res,r2)\nprint(res)"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor _ in range(m):\n\tk1,m1=map(int,input().split())\n\tl.append([m1,k1])\nl.sort()\ns,box=0,0\nfor x in range(m-1,-1,-1):\n\tm,k=l[x]\n\tbox+=k\n\tif box>n:\n\t\ts+=m*(box-n+1)\n\t\tprint(s)\n\t\tbreak\n\telif box==n:\n\t\ts+=m*k\n\t\tprint(s)\n\t\tbreak\n\telse:\n\t\ts+=m*k"}, {"source_code": "import sys\ninput = sys.stdin.readline\nread_tuple = lambda _type: map(_type, input().split(' '))\n \n \ndef solve():\n n, m = read_tuple(int)\n c = {}\n for _ in range(m):\n a, b = read_tuple(int)\n c[b] = a\n ans = 0\n for b_i in sorted(c, reverse=True):\n while n and c[b_i]:\n n -= 1\n c[b_i] -= 1\n ans += b_i\n print(ans)\n \nif __name__ == '__main__':\n solve()"}, {"source_code": "n,m = map(int,input().split())\nA = []\nfor i in range(m):\n a,b = map(int,input().split())\n A.append([b,a])\nA.sort()\n#print(A)\ni=m-1\nans=0\nwhile(n>0):\n ans+=A[i][0]*min(n,A[i][1])\n n-=A[i][1]\n i-=1\nprint(ans)"}, {"source_code": "n, m = [int(x) for x in raw_input().split()]\nboxs = []\nfor x in xrange(m):\n tp = [int(x) for x in raw_input().split()]\n boxs += [(tp[0], tp[1])]\nboxs.sort(key = lambda a: a[1])\nans = 0\ni = m - 1\nwhile n > 0:\n taken = min(n, boxs[i][0])\n ans += taken * boxs[i][1]\n n -= taken\n i -= 1\nprint ans"}, {"source_code": "n, m = map(int, input().split())\ndata = []\nfor i in range(0,m):\n ai, bi = map(int, input().split())\n data.append([ai, bi])\n \ndata.sort(key = lambda row: row[1], reverse = True) \nprint(\"sorted data\")\nprint(data)\n\nspace = n\ntotal_matches = 0\nfor i in range(0,m):\n if data[i][0] < space:\n space = space - data[i][0]\n total_matches += data[i][0]*data[i][1]\n #print(\"matches collected:\", total_matches) \n #print(\"space left:\", space)\n elif space>0:\n total_matches += space * data[i][1]\n space = 0 \n #print(\"matches collected*:\", total_matches)\n #print(\"space left*:\", space)\n \n \n \n\nprint(total_matches) \n "}, {"source_code": "n,m = map(int,input().split())\na,b,countm,countMbox,p,x = [],[],0,0,0,0\nfor i in range(m):\n c,d = map(int,input().split())\n a.append(c)\n b.append(d)\n countMbox += c\n countm += c*d\n\nif countMbox <= n:\n print(countm)\nwhile n:\n x = b.index(max(b))\n if n <= a[x]:\n p += n*b[x]\n print(p)\n break\n else:\n p += a[x]*b[x]\n n = n - a[x]\n b[x] = 0\n "}, {"source_code": "n, m = input().split()\nn, m = int(n), int(m)\na = []\nb = []\nSUM = 0\nfor i in range(m):\n ai, bi = input().split()\n ai, bi = int(ai), int(bi)\n a.append(ai)\n b.append(bi)\nfor i in range(m):\n maxim = 0\n ind = 0\n for j in range(m-i):\n if maxim < b[j]:\n maxim = b[j]\n ind = j\n if n >= a[ind]:\n n-=a[ind]\n SUM+=a[ind]*b[ind]\n a.remove(a[ind])\n b.remove(b[ind])\n else:\n SUM+=n*b[ind]\n n = 0\n b.remove(b[ind])\nprint(SUM)"}, {"source_code": "n, m = input().split()\nn, m = int(n), int(m)\na = []\nb = []\nSUM = 0\nfor i in range(m):\n ai, bi = input().split()\n ai, bi = int(ai), int(bi)\n a.append(ai)\n b.append(bi)\nfor i in range(m):\n maxim = 0\n ind = 0\n for j in range(m-i):\n if maxim < b[j]:\n maxim = b[j]\n ind = j\n if n >= a[ind]:\n n-=a[ind]\n SUM+=a[ind]*b[ind]\n a.remove(a[ind])\n b.remove(b[ind])\n else:\n SUM+=n*b[ind]\n n = 0\n b.remove(b[ind])\nprint(SUM)"}, {"source_code": "n, m = map(int, input().split(' '))\nmatch = {}\nfor i in range (m):\n a,b = map(int, input().split(' '))\n match[b] = a\nsizes = list(match.keys())\nsizes.sort(reverse=True)\nboxes = []\nfor i in sizes:\n boxes.append(match[i])\nleft = n\nans = 0\nfor i in range (len(boxes)):\n if boxes[i] < left:\n left = left - boxes[i]\n ans = ans + boxes[i] * sizes[i]\n else:\n if boxes[i] == left:\n ans = ans + boxes[i]*sizes[i]\n break\n else:\n if boxes[i] > left:\n ans = ans + left*sizes[i]\n break\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor _ in range(m):\n\tk1,m1=map(int,input().split())\n\tl.append([m1,k1])\nl.sort()\ns,box=0,0\nfor x in range(m-1,-1,-1):\n\tm,k=l[x]\n\tbox+=k\n\tif box>n:\n\t\ts+=m*(box-n+1)\n\t\tprint(s)\n\t\tbreak\n\telif box==n:\n\t\ts+=m*k\n\t\tprint(s)\n\t\tbreak\n\telse:\n\t\ts+=m*k"}, {"source_code": "n,m = map(int,input().split())\nA = []\nfor i in range(m):\n a,b = map(int,input().split())\n A.append([b,a])\nA.sort()\n#print(A)\ni=m-1\nans=0\nwhile(n>0):\n ans+=A[i][0]*min(n,A[i][1])\n n-=A[i][1]\n i-=1\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nz=0\nl1=[]\nl2=[]\nwhile(z<m):\n a,b=map(int,input().split())\n l1.append(a)\n l2.append(b)\n z+=1 \ne=0\nwhile(n>0):\n if(l1[l2.index(max(l2))]>n):\n e+=l2[l2.index(max(l2))]*n\n n=0\n else:\n e+=l2[l2.index(max(l2))]*l1[l2.index(max(l2))]\n n-=l1[l2.index(max(l2))]\n l2[l2.index(max(l2))]=-1 \nprint(e) \n\n\n\n"}, {"source_code": "n,m=map(int,input().split())\ndict={}\nar=[]\nbr=[]\nans=0\nfor _ in range(m):\n a,b=map(int,input().split())\n ar.append(a)\n br.append(b)\n \nfor i in range(len(br)):\n for j in range(len(br)):\n if br[j]<br[i]:\n br[i],br[j]=br[j],br[i]\n ar[i],ar[j]=ar[j],ar[i]\n \nans=0\na=0\nco=0\nmat=0\nle=len(br)-1\nwhile(ans<=n):\n if ans+ar[a]>=n:\n break\n else:\n \n \n ans=ans+ar[a]\n mat=mat+ar[a]*br[a]\n #print(ans,mat)\n \n \n if ans>=sum(br):\n break\n a+=1\n \nif ans>=sum(br):\n pass\nelif ans<n :\n mat+=(n-ans)*br[a]\n ans+=(n-ans)\nprint(mat)\n\n\n\n"}, {"source_code": "n,m = input().strip().split(\" \")\nn = int(n)\nm = int(m)\nG = {}\n\nfor i in range(m):\n\tinp = input().strip().split(\" \")\n\tinp[0] = int(inp[0])\n\tinp[1] = int(inp[1])\n\tG[inp[1]] = inp[0]\n\nl = list(G.keys())\nl.sort(reverse = True)\n#print(l)\ncount = 0\nfor i in l:\n\t#print(n)\n\tif G[i] <= n :\n\t\tcount += G[i]*i\n\t\tn = n - G[i]\n\telse :\n\t\tcount += i*n\n\t\tbreak\n\nprint(count) \n\n\n\n\n\n"}, {"source_code": "n, m = map(int, input().split())\ncon = {}\nc = 0\nfor i in range(m):\n x, y = map(int, input().split())\n con[y] = x\n#d = dict(sorted(con.items(), key=lambda kv: kv[1], reverse=True))\nd = dict(sorted(con.items(), reverse=True))\n\nfor v, k in d.items():\n for i in range(k):\n c += v\n n -= 1\n if n == 0:\n print(c)\n exit()\n"}, {"source_code": "l=list(map(int,raw_input().split()))\nn = l[0]\nm = l[1]\na=[]\nfor i in range (m):\n\tx = list(map(int,raw_input().split()))\n\ta.append(x)\na.sort(key=lambda x:x[1],reverse=True)\ncount = 0\ntotal = 0\nfor i in a:\n\t# while count<n and i[0]>0:\n\t# \tcount+=1\n\t# \ttotal+=i[1]\n\t# \ti[0]-=1\n\tif i[0]<n and count+i[0]<=n:\n\t\tcount+=i[0]\n\t\ttotal+=i[1]*i[0]\n\telif i[0]<n and count+i[0]>n:\n\t\tdiff = n-count\n\t\ttotal+=i[1]*diff\n\telif i[0]>n:\n\t\tdiff = n-i[0]\n\t\ttotal+=i[1]*diff\n\t#print 't',total\n\nprint total\n"}, {"source_code": "n,m=[int(i) for i in input().split()]\nl=sorted([int(i) for i in reversed(input().split())] for j in range(m))\ns=0\nfor i in reversed(l):\n if i[1]>=n:\n print(s+n*i[0])\n break\n n-=i[1]\n s+=i[1]*i[0]\n \n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nread_tuple = lambda _type: map(_type, input().split(' '))\n \n \ndef solve():\n n, m = read_tuple(int)\n c = {}\n for _ in range(m):\n a, b = read_tuple(int)\n c[b] = a\n ans = 0\n for b_i in sorted(c, reverse=True):\n while n and c[b_i]:\n n -= 1\n c[b_i] -= 1\n ans += b_i\n print(ans)\n \nif __name__ == '__main__':\n solve()"}, {"source_code": "n,m=[int(i) for i in input().split()]\na=m*[0]\nb=m*[0]\nfor i in range(m):\n a[i],b[i]=[int(i) for i in input().split()]\nfor i in range(1-1,m):\n bish=b[0]\n k=0\n for j in range(1,m-i):\n if b[j]>bish:\n bish=b[j]\n k=j\n a[k],a[m-1-i]=a[m-1-i],a[k]\n b[k],b[m-1-i]=b[m-1-i],b[k]\na.reverse()\nb.reverse()\ni=0\nh=0\nr=0\nwhile i<m:\n if h+n<=n:\n r+=a[i]*b[i]\n h+=a[i]\n i+=1\n else:\n z=n-h\n r+=z*b[i]\n break\nprint(r)\n"}, {"source_code": "n_m = [int(x) for x in input().split(' ')]\nn = n_m[0]\nm = n_m[1]\nl1 = []\nl2 = []\nl3 = []\nl4 = []\nfor i in range(m):\n a_b = [int(y) for y in input().split(' ')]\n l1.append(a_b[0])\n l2.append(a_b[1])\n l3.append(a_b[1])\nl3.sort(reverse=True)\nfor i in l3:\n for j in range(len(l3)):\n if i == l2[j]:\n l4.append(l1[j])\nmatches = 0\nfor i in range(len(l2)):\n if n > l4[i]:\n matches += l3[i] * l4[i]\n n -= l4[i]\n else:\n matches += n * l3[i]\n n = 0\n break\nprint(matches)\n"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n a,b=map(int,input().split())\n l.append([b,a])\nl=sorted(l)\nl=l[::-1]\nc=s=0\nfor i in range (len(l)):\n if c<=n:\n s+=(l[i][0])*(min(n-c,(l[i][1])))\n c+=l[i][1]\n print(s,l[i][0])\n else:\n break\nprint(s)\n"}, {"source_code": "n,m=map(int,input().split())\nd={}\n\nfor i in range(m):\n a,b=map(int,input().split())\n if b in d:\n if a>d[b]:\n d[b]=a\n else:\n d[b]=a\n \nans=0\nwhile(n>0):\n #print(d,ans)\n if n==0 or m==0:\n break\n a=max(d)\n if n>d[a]:\n n-=d[a]\n ans+=a*d[a]\n elif n<d[a]:\n ans+=n*a\n n-=n\n elif n==d[a]:\n ans+=a*n\n n=0\n del d[a]\n #print(ans,n)\n m-=1\nprint(ans)\n\n "}, {"source_code": "import sys\nimport math\nimport functools\ninput = sys.stdin.readline\n\nn, m = map(int, input().strip().split())\na = []\n\nfor _ in range(m):\n z = list(map(int, input().strip().split()))\n a.append(z)\ndef compare(A, B):\n if A[0] * A[1] > B[0] * B[1]: return 1\n elif A[0] * A[1] < B[0] * B[1]: return -1\n else:\n if A[0] < B[0]: return 1\n elif A[0] > B[0]: return -1\n else: return 0\n\na.sort(key = functools.cmp_to_key(compare), reverse=True)\nans = 0\nfor el in a:\n ans += min(n, el[0]) * el[1]\n n -= min(n, el[0])\nprint(ans)\n"}, {"source_code": "[n,m] = [int(x) for x in input().split()]\na=[]\n\nfor i in range (m) : \n\ta.append([int(x) for x in input().split()])\n\n\na = sorted(a , key = lambda x : x[1] ,reverse = True)\nk = 0\n\nprint(a)\nprint(len(a))\nwhile n > 0 and len(a) > 0:\n\tif n >= a[0][0] :\n\t\tk += a[0][0]*a[0][1]\n\t\tn -= a[0][0]\n\t\ta.pop(0)\n\telse :\n\t\tk += n *a[0][1]\n\t\tn = 0\n\t\n\n\nprint(k)\n"}, {"source_code": "n,m=map(int, input().split())\nd={}\nfor _ in range(m):\n v,k=map(int, input().split())\n d[k]=v\nans=0\nfor i in range(10,0,-1):\n if i in d:\n if d[i]<=n:\n n-=d[i]\n ans+=i*d[i]\n else:\n ans+=i*n\n n=0\nprint(ans)\n \n\n"}, {"source_code": "import os\n\nbox_cont = input().rstrip().split()\nn=int(box_cont[0])\nm=int(box_cont[1])\nhah=[0]*11\nfor i in range(m):\n a_b=input().rstrip().split()\n a=int(a_b[0])\n b=int(a_b[1])\n hah[b]=a\ntotal=0\nfor i in range(10,0,-1):\n if hah[i]!= 0:\n if n-hah[i]>=0:\n total+=(hah[i]*i)\n n=n-hah[i]\n else:\n total+=i*n\n break\nprint(total)\n"}, {"source_code": "import os\n\nbox_cont = input().rstrip().split()\nn=int(box_cont[0])\nm=int(box_cont[1])\nhah=[0]*11\nfor i in range(m):\n a_b=input().rstrip().split()\n a=int(a_b[0])\n b=int(a_b[1])\n hah[b]=a\ntotal=0\nfor i in range(10,0,-1):\n if hah[i]!= 0:\n if n-hah[i]>=0:\n total+=(hah[i]*i)\n n=n-hah[i]\n else:\n total+=i*n\n break\nprint(total)\n"}, {"source_code": "n, m = map(int, input().split(' '))\nmatch = {}\nfor i in range (m):\n a,b = map(int, input().split(' '))\n match[b] = a\nsizes = list(match.keys())\nsizes.sort(reverse=True)\nboxes = []\nfor i in sizes:\n boxes.append(match[i])\nleft = n\nans = 0\nfor i in range (len(boxes)):\n if boxes[i] < left:\n left = left - boxes[i]\n ans = ans + boxes[i] * sizes[i]\n else:\n if boxes[i] == left:\n ans = ans + boxes[i]*sizes[i]\n break\n else:\n if boxes[i] > left:\n ans = ans + left*sizes[i]\n break\nprint(ans)"}, {"source_code": "\nn, m = input().split(\" \")\nn = int(n)\nm = int(m)\nrow = {}\nnum = 0\nsom = 0\nfor i in range(m):\n x, y = input().split(\" \")\n x = int(x)\n y = int(y)\n row[x] = y\n num += x\n som += x*y\nif num <= n:\n print(som)\nelse:\n row = sorted(row.items(), key=lambda kv: kv[1],reverse=True)\n som = 0\n num = 0\n for elt, value in row:\n num += elt\n if num<=n:\n som += value*elt\n else:\n num -= elt\n while num <= n:\n som += value\n num += 1\n print(som-value)\n break\n"}, {"source_code": "import os\n\nbox_cont = input().rstrip().split()\nn=int(box_cont[0])\nm=int(box_cont[1])\nhah=[0]*11\nfor i in range(m):\n a_b=input().rstrip().split()\n a=int(a_b[0])\n b=int(a_b[1])\n hah[b]=a\ntotal=0\nfor i in range(10,0,-1):\n if hah[i]!= 0:\n if n-hah[i]>=0:\n total+=(hah[i]*i)\n n=n-hah[i]\n else:\n total+=i*n\n break\nprint(total)\n"}, {"source_code": "from collections import defaultdict\nn,m = map(int,raw_input().split())\ncounter = defaultdict(int)\nfor i in range(m):\n a,b = map(int,raw_input().split())\n counter[b]+=a\ncounter = sorted(counter.items(), key=lambda x: x[0],reverse=True)\nprint(counter)\ni = 0\ncounter_length = len(counter)\nscore = 0\nwhile (n > 0 and i < counter_length):\n if counter[i][1] >= n:\n itemsToTake = n\n score+=counter[i][0]*itemsToTake\n n -=itemsToTake\n else:\n score+=counter[i][0]*counter[i][1]\n n-=counter[i][1]\n i+=1\nprint(score)"}, {"source_code": "\n# Author: SaykaT\n# Problem: 16B\n# Time Created: July 21(Tuesday) 2020 || 12:16:23\n\n#>-------------------------<#\n\n# Helper Functions. -> Don't cluster your code.\n\n# IO Functions. -> Input output\ndef io():\n n, m = map(int, input().split())\n containers = []\n for _ in range(m):\n a, b = map(int, input().split())\n containers.append([a, b])\n containers.sort(key=lambda x:x[1], reverse=True)\n return [n, m, containers]\n\n# Main functions. -> Write the main solution here\ndef solve():\n n, m, containers = io()\n i = 0\n matches = 0\n while n != 0 or i < n:\n if n > containers[i][0]:\n matches += containers[i][0] * containers[i][1]\n n -= containers[i][0]\n else:\n matches += n * containers[i][i]\n \n n = 0\n i +=1\n print(matches)\n\n# Multiple test cases. -> When you have T test cases.\nsolve()\n \n"}, {"source_code": "n, m = map(int, input().split())\ndata = []\nfor i in range(0,m):\n ai, bi = map(int, input().split())\n data.append([ai, bi])\n \ndata.sort(key = lambda row: row[1], reverse = True) \nprint(\"sorted data\")\nprint(data)\n\nspace = n\ntotal_matches = 0\nfor i in range(0,m):\n if data[i][0] < space:\n space = space - data[i][0]\n total_matches += data[i][0]*data[i][1]\n #print(\"matches collected:\", total_matches) \n #print(\"space left:\", space)\n elif space>0:\n total_matches += space * data[i][1]\n space = 0 \n #print(\"matches collected*:\", total_matches)\n #print(\"space left*:\", space)\n \n \n \n\nprint(total_matches) \n "}, {"source_code": "import operator\n\ntotal, containers = map(int, raw_input().split())\nmatchboxes = [map(int, raw_input().split()) for _ in range(containers)]\nv_matchboxes = [(i, x[1]) for i, x in enumerate(matchboxes)]\n\nv = []\ncount = 0\nwhile count < total:\n m_index = max(v_matchboxes, key=operator.itemgetter(1))\n count += matchboxes[m_index[0]][0]\n v += [m_index[1]] * matchboxes[m_index[0]][0]\n v_matchboxes[m_index[0]] = (m_index[0], -1)\n\nprint sum(v[:total])\n\n"}, {"source_code": "import operator\n\ntotal, containers = map(int, raw_input().split())\nmatchboxes = [map(int, raw_input().split()) for _ in range(containers)]\nv_matchboxes = [(i, x[1]) for i, x in enumerate(matchboxes)]\n\nv = []\ncount = 0\nwhile count < total:\n m_index = max(v_matchboxes, key=operator.itemgetter(1))\n count += matchboxes[m_index[0]][0]\n v += [m_index[1]] * matchboxes[m_index[0]][0]\n v_matchboxes[m_index[0]] = (m_index[0], -1)\n\nprint sum(v[:total])\n\n"}, {"source_code": "n, m = map(int, input().split(' '))\nmatch = {}\nbs = []\nfor i in range (m):\n a,b = map(int, input().split(' '))\n match[b] = a\n if b in bs:\n match[b] = match[b] + a\n else:\n bs.append(b)\nsizes = list(match.keys())\nsizes.sort(reverse=True)\nboxes = []\nfor i in sizes:\n boxes.append(match[i])\nleft = n\nans = 0\nfor i in range (len(boxes)):\n\n if boxes[i] < left:\n\n left = left - boxes[i]\n ans = ans + boxes[i] * sizes[i]\n else:\n if boxes[i] == left:\n ans = ans + boxes[i]*sizes[i]\n break\n else:\n if boxes[i] > left:\n ans = ans + left*sizes[i]\n break\nprint(ans)"}, {"source_code": "l=list(map(int,raw_input().split()))\nn = l[0]\nm = l[1]\na=[]\nfor i in range (m):\n\tx = list(map(int,raw_input().split()))\n\ta.append(x)\na.sort(key=lambda x:x[1],reverse=True)\ncount = 0\ntotal = 0\nfor i in a:\n\t# while count<n and i[0]>0:\n\t# \tcount+=1\n\t# \ttotal+=i[1]\n\t# \ti[0]-=1\n\n\tif i[0]<=n and count+i[0]<=n:\n\t\tcount+=i[0]\n\t\ttotal+=i[1]*i[0]\n\telif i[0]<n and count+i[0]>n:\n\t\tdiff = n-count\n\t\ttotal+=i[1]*diff\n\t\tcount+=diff\n\t\n\telif i[0]>n:\n\t\tdiff = n-i[0]\n\t\ttotal+=i[1]*diff\n\t\tcount+=diff\n\telif count<n and count+i[0]>=n:\n\t\tdiff = n-count\n\t\ttotal+=i[1]*diff\n\t\t# print 'popp'\n\t\tbreak\n\t# print 'c',count\n\t# print 't',total\n\nprint total\n"}, {"source_code": "\ns=input()\ns=s.split(' ')\n\nbag_size=int(s[0])\n\nrows=int(s[1])\n\nboxes_matches={}\n\nsum=0\n\nfor i in range(rows):\n \n s=input()\n s=s.split(' ')\n \n num_boxes=int(s[0])\n matches=int(s[1])\n \n boxes_matches[num_boxes]=matches\n \nboxes_matches=sorted(boxes_matches.items(),key=lambda t:t[1], reverse=True)\n\n\nfor key,val in boxes_matches:\n \n if key <= bag_size:\n \n bag_size-=key\n sum+=(key*val)\n \n else:\n \n sum+=(bag_size*val)\n bag_size=0\n \n if bag_size == 0:\n break\n \nprint(sum)\n \n \n\n#sorted(data.values())"}, {"source_code": "n , m = map(int,input().split())\nl=[]\nsumm = 0\n\nfor i in range(m):\n x ,y = map(int,input().split())\n l.append([x,y])\n\nl.sort(key = lambda y :y[0] ,reverse=True)\n\nfor i in range(m):\n a = l[i][0]\n b = l[i][1]\n if n >= a :\n summ += a*b\n n -= a\n\n elif n < a :\n summ += n*b\n break\n\nprint(summ)\n"}, {"source_code": "n, m = list(map(int, input().split()))\n\nmatch = {}\n\nfor _ in range(m):\n Ai, Bi = list(map(int, input().split()))\n \n match[Ai] = Bi\n\nmatchs = [(k, match[k]) for k in sorted(match, key=match.get, reverse=True)]\n\nans = 0\nfor k, v in matchs:\n if k <= n:\n ans += k * v\n n -= k\n elif n < k:\n ans += n * v\n break\n\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nx=[]\ny=[]\nA=0\nfor i in range(m):\n a,b=map(int,input().split())\n x.append(a)\n y.append(b)\nif sum(x)>n:\n while n>0:\n a=y.index(max(y))\n if x[a]>=n:\n A+=n*y[a]\n n=0\n else:\n A+=x[a]*y[a]\n n=n-x[a]\n x.remove(x[a])\n y.remove(y[a])\n print(A)\nelse:\n for i in range(m):\n A+=x[i]*y[i]\n print(A)"}, {"source_code": "n,m=map(int,input().split())\nz=0\nl1=[]\nl2=[]\nwhile(z<m):\n a,b=map(int,input().split())\n l1.append(a)\n l2.append(b)\n z+=1 \ne=0\nwhile(n>0):\n if(l1[l2.index(max(l2))]>n):\n e+=l2[l2.index(max(l2))]*n\n n=0\n else:\n e+=l2[l2.index(max(l2))]*l1[l2.index(max(l2))]\n n-=l1[l2.index(max(l2))]\n l2[l2.index(max(l2))]=-1 \nprint(e) \n\n\n\n"}, {"source_code": "n, m = map(int, input().split())\ncounter = {}\nfor _ in range(m):\n a, b = map(int, input().split())\n counter[b] = a\n\nans = 0\nknapsack = {0: (0, 0)}\nelm_sum = sum(counter.values())\nwhile elm_sum > 0:\n for k, v in counter.items():\n for key in list(knapsack.keys()):\n if counter[k] > 0:\n val = knapsack[key][0] + k\n cnt = knapsack[key][1] + 1\n if key + k not in knapsack or (key+k in knapsack and knapsack[key+k][1] > cnt):\n knapsack[key + k] = (val, cnt)\n\n counter[k] -= 1\n elm_sum -= 1\n\n\nfor k, v in knapsack.items():\n if v[1] <= n:\n ans = max(v[0], ans)\n\nprint(ans)\n"}, {"source_code": "n,m=map(int,input().split())\na=[]\nfor i in range(m):\n x=list(map(int,input().split()))\n x.reverse()\n a.append(x)\ns=0;y=0\nfor i in a:\n d=max(a)\n if d[1]>=n:\n s=s+(n)*d[0]\n break\n n-=d[1]\n s+=d[1]*d[0]\n a.remove(d)\nprint(s)\n \n \n \n \n \n \n"}, {"source_code": "n,m=input().split(\" \")\nn=int(n)\nm=int(m)\narr=[]\nfor i in range(0,m):\n arr.append(list(map(int,input().split(\" \"))))\nsorted_arr=sorted(arr,key=lambda x:x[1],reverse=True)\n#print(sorted_arr)\nres=[]\nremaining_capacity=n\ni=0\nwhile (remaining_capacity>0 and i<m):\n if(remaining_capacity>=n):\n res.append(sorted_arr[i][0])\n remaining_capacity-=sorted_arr[i][0]\n i+=1\n else:\n res.append(remaining_capacity)\n remaining_capacity=0\n #print(remaining_capacity)\nproduct=0\n#print(res)\nfor i in range(0,len(res)):\n product+=res[i]*sorted_arr[i][1];\nprint(product)"}, {"source_code": "line1=input().split()\nn=int(line1[0])\nm=int(line1[1])\na=[]\nwhile m>0:\n new=input().split()\n new.reverse()\n a.append(list(map(int,new)))\n m -=1\ntest=dict(a)\nres=0\nfor i in range(0,len(test)):\n if n <=0:\n break\n num_of_matchbox=max(test)\n number_of_box=int(test[num_of_matchbox])\n if number_of_box > n:\n res +=n*num_of_matchbox\n n -=n\n elif n>=number_of_box:\n res += num_of_matchbox*number_of_box\n n -=number_of_box\n test.pop(max(test))\nprint(res)"}, {"source_code": "n,m=[int(i) for i in input().split()]\na=m*[0]\nb=m*[0]\nfor i in range(m):\n a[i],b[i]=[int(i) for i in input().split()]\nfor i in range(1-1,m):\n bish=b[0]\n k=0\n for j in range(1,m-i):\n if b[j]>bish:\n bish=b[j]\n k=j\n a[k],a[m-1-i]=a[m-1-i],a[k]\n b[k],b[m-1-i]=b[m-1-i],b[k]\na.reverse()\nb.reverse()\ni=0\nh=0\nr=0\nwhile i<m:\n if h+n<=n:\n r+=a[i]*b[i]\n h+=a[i]\n i+=1\n else:\n z=n-h\n r+=z*b[i]\n break\nprint(r)\n"}, {"source_code": "n , m = map(int , input().split())\nc= {}\nfor _ in range(m):\n\ta , b = map(int , input().split())\n\tc[b] = a\nc = sorted(c.items() , key=lambda x:x[0] , reverse = True)\nM = 0\nfor i , t in c:\n\tif n <= 0:\n\t\tbreak\n\ts = min(n , t)\n\tM += s*i\n\tn = n-t\nprint(M)"}, {"source_code": "#!/usr/bin/python3.1\ns = raw_input().split(\" \")\nn, m = int(s[0]), int(s[1])\na = []\nres = 0\nfor i in range(0, m):\n x = list(map(lambda x: int(x), raw_input().split(\" \")))\n a.append(x)\na.sort(key=lambda x: -x[0])\nfor q in a:\n if n == 0: break;\n t = min(n, q[0])\n res += q[1] * t\n n -= t\nprint(res)"}, {"source_code": "n,m = map(int,input().split())\nA = []\nfor i in range(m):\n a,b = map(int,input().split())\n A.append([b,a])\nA.sort()\n#print(A)\ni=m-1\nans=0\nwhile(n>0):\n ans+=A[i][0]*min(n,A[i][1])\n n-=A[i][1]\n i-=1\nprint(ans)"}, {"source_code": "n, m = input().split()\nn, m = int(n), int(m)\na = []\nb = []\nSUM = 0\nfor i in range(m):\n ai, bi = input().split()\n ai, bi = int(ai), int(bi)\n a.append(ai)\n b.append(bi)\nfor i in range(m):\n maxim = 0\n ind = 0\n for j in range(m-i):\n if maxim < b[j]:\n maxim = b[j]\n ind = j\n if n >= a[ind]:\n n-=a[ind]\n SUM+=a[ind]*b[ind]\n a.remove(a[ind])\n b.remove(b[ind])\n else:\n SUM+=n*b[ind]\n n = 0\n b.remove(b[ind])\nprint(SUM)"}, {"source_code": "k,n=map(int,input().split())\nd={}\nd1=[]\nres=0\nfor i in range(n):\n a,b=map(int,input().split())\n if b in d:\n d[b]+=a\n else:\n d[b]=a\n d1.append(b)\nd1.sort()\nd1.reverse()\n# print(d)\n# print(d1)\nfor i in d1:\n if k>=d[i]:\n res+=(d[i]*i)\n k-=d[i]\n else:\n res+=(k*i)\n k-=d[i]\n # print(res)\n if k<=0:\n break\nprint(res)\n \n \n\n "}, {"source_code": "n,m = map(int,input().split())\nd = {}\nfor i in range(m):\n a,b = map(int,input().split())\n d[a] = b\nd = sorted(d.items(),reverse = True)\ncount = 0\n# print(d)\nfor i in d:\n if n>0:\n if n-i[0] >0:\n count +=(i[0])*i[1]\n n -=i[0]\n else:\n count += (n)*i[1]\n n = 0\nprint(count)\n"}, {"source_code": "n,m=list(map(int,input().split()))\nd,l={},[]\nfor i in range(m):\n\ta,b=list(map(int,input().split()))\n\td[b]=a\n\tl.append(b)\nl.sort()\nl.reverse()\nc,t=0,0\nfor i in l:\n\tc+=d[i]\n\tif c<n:\n\t\tt+=i*d[i]\n\telse:\n\t\tt+=i*(d[i]-(c-n))\n\t\tbreak\nprint(t)"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial, log,tan,pi,cos,sin,radians\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod_ = int(1e9) + 7\nmod = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve(m):\n n=1\n primes = {}\n arr=set([])\n for i in range(2, int(m ** 0.5) + 1):\n a = n // i\n b = m // i\n for k in range(max(2, a), b + 1):\n c = i * k\n primes[c] = 1\n\n for i in range(max(n, 2), m + 1):\n if i not in primes:\n arr.add(i)\n\n return arr\n\n\nclass DisjointSetUnion:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n \n def find(self, a):\n acopy = a\n while a != self.parent[a]:\n a = self.parent[a]\n while acopy != a:\n self.parent[acopy], acopy = a, self.parent[acopy]\n return a\n \n def union(self, a, b):\n a, b = self.find(a), self.find(b)\n if a != b:\n if self.size[a] < self.size[b]:\n a, b = b, a\n \n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n \n def set_size(self, a):\n return self.size[self.find(a)]\n \n def __len__(self):\n return self.num_sets\n\n\n\ndef main():\n n,m=map(int,input().split())\n arr=[]\n mat=[]\n cnt=0\n for i in range(m):\n a,b=map(int,input().split())\n arr.append(a)\n mat.append(b)\n mat.sort(reverse=True)\n arr.sort(reverse=True)\n s=0\n cnt=0\n for i in range(m):\n if s>=n:\n break\n cnt+=min(n-s,arr[i])*mat[i]\n s+=arr[i]\n print(cnt) \n \n \n\n\n\n \n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "\ns=input()\ns=s.split(' ')\n\nbag_size=int(s[0])\n\nrows=int(s[1])\n\nboxes_matches={}\n\nsum=0\n\nfor i in range(rows):\n \n s=input()\n s=s.split(' ')\n \n num_boxes=int(s[0])\n matches=int(s[1])\n \n boxes_matches[num_boxes]=matches\n \nboxes_matches=sorted(boxes_matches.items(),key=lambda t:t[1], reverse=True)\n\n\nfor key,val in boxes_matches:\n \n if key <= bag_size:\n \n bag_size-=key\n sum+=(key*val)\n \n else:\n \n sum+=(bag_size*val)\n bag_size=0\n \n if bag_size == 0:\n break\n \nprint(sum)\n \n \n\n#sorted(data.values())"}, {"source_code": "line1=input().split()\nn=int(line1[0])\nm=int(line1[1])\na=[]\nwhile m>0:\n new=input().split()\n new.reverse()\n # new.sort()\n a.append(list(map(int,new)))\n a.sort()\n m -=1\ntest=dict(a)\nres=0\nfor i in range(0,len(test)):\n if n <=0:\n break\n num_of_matchbox=max(test)\n number_of_box=int(test[num_of_matchbox])\n if number_of_box >=n:\n res +=n*num_of_matchbox\n n -=n\n test.pop(max(test))\n elif n>=number_of_box:\n res += num_of_matchbox*number_of_box\n n -=number_of_box\n test.pop(max(test))\nprint(res)\n"}, {"source_code": "[n,m] = [int(x) for x in input().split()]\na=[]\n\nfor i in range (m) : \n\ta.append([int(x) for x in input().split()])\n\n\na = sorted(a , key = lambda x : x[1] ,reverse = True)\nk = 0\n\nprint(a)\nprint(len(a))\nwhile n > 0 and len(a) > 0:\n\tif n >= a[0][0] :\n\t\tk += a[0][0]*a[0][1]\n\t\tn -= a[0][0]\n\t\ta.pop(0)\n\telse :\n\t\tk += n *a[0][1]\n\t\tn = 0\n\t\n\n\nprint(k)\n"}, {"source_code": "#\tAuthor\t: debugster\n#\tEmail\t: alive.dew@gmail.com\n#\tDate\t: 2020-06-03 21:49:06\n\nimport sys\nimport os\n\ndef get_int():\n return map(int, input().split())\n\ndef get_array():\n return list(map(int, input().split()))\n\nif os.environ.get(\"DEBUGSTER_PYTHON\"):\n\tsys.stdin = open('in.txt', 'r')\n\tsys.stdout = open('out.txt','w')\n\nclass MatchBox:\n\tdef __init__(self, a, b):\n\t\tself.a, self.b = a, b\n\t\n\tdef __lt__(self, other):\n\t\tif self.a * self.b == other.a * other.b:\n\t\t\treturn self.b > other.b\n\t\t\n\t\treturn self.a * self.b > other.a * other.b\n\nn, m = get_int()\nall_m = list()\nfor _ in range(m):\n\ta, b = get_int()\n\tall_m.append(MatchBox(a, b))\nall_m = sorted(all_m)\n\n\nans = 0\nremain = n\nfor x in all_m:\n\ttake = min(x.a, remain)\n\tans += take * x.b\n\tremain -= take\n\tif remain <= 0:\n\t\tbreak\n\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\ndict={}\nar=[]\nbr=[]\nans=0\nfor _ in range(m):\n a,b=map(int,input().split())\n ar.append(a)\n br.append(b)\n \nfor i in range(len(br)):\n for j in range(len(br)):\n if br[j]<br[i]:\n br[i],br[j]=br[j],br[i]\n ar[i],ar[j]=ar[j],ar[i]\n \nans=0\na=0\nco=0\nmat=0\nle=len(br)-1\nwhile(ans<=n):\n if ans+ar[a]>n:\n break\n else:\n \n \n ans=ans+ar[a]\n mat=mat+ar[a]*br[a]\n #print(ans,mat)\n \n a+=1\n \nif ans<n :\n mat+=(n-ans)*br[a]\n ans+=(n-ans)\nprint(ans)\n\n\n\n"}, {"source_code": "n , m = map(int,input().split())\nl=[]\nsumm = 0\n\nfor i in range(m):\n x ,y = map(int,input().split())\n l.append([x,y])\n\nl.sort(key = lambda y :y[0] ,reverse=True)\n\nfor i in range(m):\n a = l[i][0]\n b = l[i][1]\n if n >= a :\n summ += a*b\n n -= a\n\n elif n < a :\n summ += n*b\n break\n\nprint(summ)\n"}, {"source_code": "n, m = map(int, input().split(' '))\nmatch = {}\nbs = []\nfor i in range (m):\n a,b = map(int, input().split(' '))\n match[b] = a\n if b in bs:\n match[b] = match[b] + a\n else:\n bs.append(b)\nsizes = list(match.keys())\nsizes.sort(reverse=True)\nboxes = []\nfor i in sizes:\n boxes.append(match[i])\nleft = n\nans = 0\nfor i in range (len(boxes)):\n\n if boxes[i] < left:\n\n left = left - boxes[i]\n ans = ans + boxes[i] * sizes[i]\n else:\n if boxes[i] == left:\n ans = ans + boxes[i]*sizes[i]\n break\n else:\n if boxes[i] > left:\n ans = ans + left*sizes[i]\n break\nprint(ans)"}, {"source_code": "n,m = list(map(int,input().split()))\nref = {}\nmat = 0\nfor x in range(m):\n a,b = input().split()\n ref[int(b)] = int(a)\n\nfor y in sorted(ref.keys())[::-1]:\n if n <= 0:\n break\n else:\n if n - ref[y] >= 0:\n n -= ref[y]\n mat += y*ref[y]\n \n else:\n mat += n*y\n n = 0\nprint (mat)\n \n"}, {"source_code": "n,m=map(int,input().split())\ndict={}\nar=[]\nbr=[]\nans=0\nfor _ in range(m):\n a,b=map(int,input().split())\n ar.append(a)\n br.append(b)\n \nfor i in range(len(br)):\n for j in range(len(br)):\n if br[j]<br[i]:\n br[i],br[j]=br[j],br[i]\n ar[i],ar[j]=ar[j],ar[i]\n \nans=0\na=0\nco=0\nmat=0\nle=len(br)-1\nwhile(ans<=n):\n if ans+ar[a]>=n:\n break\n else:\n \n \n ans=ans+ar[a]\n mat=mat+ar[a]*br[a]\n #print(ans,mat)\n \n \n if ans>=sum(br):\n break\n a+=1\nif ans<n :\n mat+=(n-ans)*br[a]\n ans+=(n-ans)\nprint(mat)\n\n\n\n"}, {"source_code": "import sys\n\ndef main(n, containers):\n containers.sort(key=lambda x: x[1], reverse=True)\n s = 0\n for e, cont in enumerate(containers):\n num, per_num = cont\n if num < n:\n n -= num\n s += num * per_num\n else:\n # Can't take all, but can take sum.\n s += n * per_num\n\n # No more n left.\n break\n print(s)\n\n\nif __name__ == \"__main__\":\n cases = []\n for e, line in enumerate(sys.stdin.readlines()):\n if e == 0:\n n, _ = map(int, line.strip().split())\n cases.append(list(map(int, line.strip().split())))\n main(n, cases)\n"}, {"source_code": "def funct(l):\n x = 0\n t = 0\n for i in range(len(l)):\n if x < int(l[i][1]):\n x = int(l[i][1])\n t = i\n return t\n\n\ntemp = input().split(' ')\nn = int(temp[0])\nm = int(temp[1])\nl = []\nfor i in range(m):\n temp = input().split(' ')\n l.append([temp[0], temp[1]])\nprint(l)\ns = 0\nwhile(n > 0):\n n -= 1\n ind = funct(l)\n if(ind < len(l)):\n s += int(l[ind][1])\n l[ind][0] = str(int(l[ind][0])-1)\n if l[ind][0] == '0':\n del l[ind]\nprint(s)\n"}], "src_uid": "c052d85e402691b05e494b5283d62679"} {"source_code": "from math import ceil\ndef gcdEx(a,b,x,y):\n if not a:\n return 0,1,b\n x1,y1,g=gcdEx(b%a,a,0,0)\n x=y1-(b//a)*x1\n y=x1\n return x,y,g\na,b,c=map(int, input().split())\nx,y,g=gcdEx(a,b,0,0)\nif c%g:\n print(\"No\")\nelse: \n x,y=x*c//g,y*c//g\n k1=ceil(-x*g/b)\n k2=(y*g)//a\n c=abs(k2-k1+1)\n print(\"Yes\" if c>0 else \"No\")", "positive_code": [{"source_code": "from math import gcd\na, b, c = [int(p) for p in input().split()]\nif c%gcd(a, b) == 0:\n for i in range(10000):\n if a*i > c:\n print('NO')\n exit()\n for j in range(10000):\n if a*i + b*j == c:\n print('YES')\n exit()\n if a*i + b*j > c:\n break\nelse:\n print('NO')"}, {"source_code": "data = input().split()\n\na = int(data[0])\nb = int(data[1])\nc = int(data[2])\n\nm = min(a, b)\nM = max(a, b)\n\nif m == 0 and M != 0:\n if c % M == 0:\n print('Yes')\n win = True\n else:\n print('No')\n win = True\n\nif M == 0 and m != 0:\n if c % m == 0:\n print('Yes')\n win = True\n else:\n print('No')\n win = True\n\nif m == 0 and M == 0:\n if c == 0:\n print('Yes')\n win = True\n else:\n print('No')\n win = True\n\nwin = False\nif m != 0 and M != 0:\n times = int(c / M)\n while times >= 0:\n if (c - (M * times)) % m == 0:\n print('Yes')\n win = True\n break\n times -= 1\n\nif not win:\n print('No')\n"}, {"source_code": "a,b,c = map(int, input().split())\nfor i in range(b):\n if c - i*a < 0: break\n if (c - i*a)% b == 0:\n print(\"Yes\")\n exit()\nprint(\"No\")"}, {"source_code": "IL = lambda: list(map(int, input().split()))\nIS = lambda: input().split()\nI = lambda: int(input())\nS = lambda: input()\n\na, b, c = IL()\n\nans = False\nfor i in range(0, c+1, a):\n if (c-i) % b == 0:\n ans = True\n\nprint(\"Yes\" if ans else \"No\")"}, {"source_code": "from fractions import gcd\na,b,c=[int(x) for x in raw_input().split()]\ntt=0\nfor i in range((c/a)+1):\n for j in range((c/b)+1):\n if i*a+j*b==c:\n print(\"Yes\")\n tt=1\n break\n if i*a+j*b>c:\n break\n if tt==1:\n break\nif tt==0:\n print(\"No\")\n "}, {"source_code": "a=list(map(int,input().split()))\nd=[0]*(a[2]+1)\nif a[0]<=a[2]:\n d[a[0]]=a[0]\nif len(d)<a[1] and len(d)<a[0]:\n print(\"No\")\n exit()\nfor i in range(1,a[2]+1):\n if d[i]>0:\n if d[i]+a[0]<=a[2]:\n d[i+a[0]]=d[i]+a[0]\n\nif a[1]<=a[2]:\n d[a[1]]=a[1]\nfor i in range(1,a[2]+1):\n if d[i]>0:\n if d[i]+a[1]<=a[2]:\n d[i+a[1]]=d[i]+a[1]\nprint((\"No\",\"Yes\")[d.count(a[2])])\n\n"}, {"source_code": "abc=input().split()\na=int(abc[0])\nb=int(abc[1])\nc=int(abc[2])\ncount=0\nif c%a==0 or c%b==0:\n print('Yes')\nelse:\n for i in range(c):\n if i*a>c:\n break\n if (c-i*a)%b==0:\n count+=1\n if count>0:\n print('Yes')\n else:\n print('No')"}, {"source_code": "a,b,c=map(int,raw_input().split())\nm=c/a\nflag=0\nfor i in range(m+1):\n if (c-a*i)%b==0:\n flag=1\n break\nif flag==1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "vals = [int(x) for x in raw_input().split()]\nif vals[0]<vals[1]:\n a=vals[0]\n b=vals[1]\nelse:\n a=vals[1]\n b=vals[0]\n\nc=vals[2]\n\nfor i in range(a):\n t=c-i*b\n if t>-1 and t%a==0:\n print(\"Yes\")\n quit()\n\nprint(\"No\")\n"}, {"source_code": "x = input ().split ()\na = int (x[0])\nb = int (x[1])\nc = int (x[2])\n\ndef swap (a, b):\n if a > b: \n tmp = a\n a = b\n b = tmp\n\nif a > b:\n swap (a, b)\n\ni = 0\nans = False\nwhile a*i <= c and not ans:\n if (c-a*i) % b == 0:\n ans = True\n i += 1\n\nif ans == True:\n print (\"Yes\")\nelse:\n print (\"No\")\n"}, {"source_code": "a,b,c = map(int, input().split())\ny = 0\nfor i in range(0, c+1, a):\n if (c - i)%b == 0:\n y = 1\nif y==1:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "a,b,c = map(int,raw_input().split(' ')) \ni = 0\nwhile(c>=0):\n if((c-b*i)%a==0):\n print 'yes'\n break\n i = i+1\n if(i > c/b):\n print 'no'\n break"}, {"source_code": "import math\n#for _ in range(int(input())):\na,b,n = map(int,input().split())\ng = math.gcd(a,b)\n\ndef gcdExtended(a, b): \n\n # Base Case \n if a == 0 : \n return b, 0, 1\n \n gcd, x1, y1 = gcdExtended(b%a, a) \n \n # Update x and y using results of recursive \n # call \n x = y1 - (b//a) * x1 \n y = x1 \n \n return gcd , x, y\n\nans = 1\ng,p,q = gcdExtended(a, b)\n\nk1 = -(p*n)/b\nk2 = (q*n)/a\n\nif k2 < k1:\n ans = 0\n\n\n#print(k1,k2)\n#print(p,q,g)\nik1= math.ceil(k1)\nik2= math.ceil(k2)\ndk1 = k1-ik1\ndk2 = k2-ik2\n\n\nif ik2-ik1 >= 1:\n ans = 1\nelse:\n if dk1 == 0.0 or dk2 == 0.0:\n ans = 1\n else:\n ans = 0\n\n\n\n \n \n\nif n%g != 0 or ans == 0:\n print('No')\nelse:\n print('Yes')\n\n\n\n \n"}, {"source_code": "s = raw_input()\ns1 = s.split(\" \")\na = int(s1[0])\nb = int(s1[1])\nc = int(s1[2]) \nfl = 0 \nran = c/a + 1 \nfor i in range(ran):\n prod = a*i \n if ((c-prod) % b == 0):\n print \"Yes\"\n fl = 1\n break\nif (fl == 0):\n print \"No\"\n "}, {"source_code": "\na,b, c = [int(i) for i in raw_input().split(' ')]\nok = False\nif c % a == 0 or c % b ==0:\n ok=True\nfor i in range(c/a+1):\n if (c - (a*i))%b==0:\n ok=True\nif ok:\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport itertools\n\n\nif __name__ == '__main__':\n a, b, c = map(int, raw_input().split())\n\n max_x = c / a\n max_y = c / b\n possible = any(\n a*x + b*y == c\n for x, y\n in itertools.product(range(max_x+1), range(max_y+1))\n )\n if possible:\n result = 'Yes'\n else:\n result = 'No'\n print(str(result))\n \n"}, {"source_code": "a,b,c=[int(i) for i in input().split()]\ni=0\nflag=0\nwhile((i*a)<=c):\n if (c - (i * a)) % b == 0:\n flag=1\n break\n else:\n i=i+1\nif(flag>0):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "a, b, c = map(int, input().split())\nif a < b:\n a, b = b, a\nr = a % b\nneed = c % b\ncurr = 0\ncurr_a = 0\nwhile (curr_a <= c) and (curr != need):\n curr += r\n curr %= b\n curr_a += a\nif curr == need and curr_a <= c:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "m=list(map(int,input().split()))[:3]\nwhile(m[2]>=0):\n if(m[2]%m[0]==0):\n print(\"Yes\")\n break\n m[2]=m[2]-m[1]\nif(m[2]<0):\n print(\"No\")\n"}, {"source_code": "from sys import stdin\nfrom math import gcd\ndef iinput(): return int(stdin.readline())\ndef sinput(): return input()\ndef minput(): return map(int, stdin.readline().split())\ndef linput(): return list(map(int, stdin.readline().split()))\n\na, b, c = minput()\nfor i in range(c//a + 1):\n if (c - i*a)%b == 0:\n print('Yes')\n break\nelse:\n print('No')\n\n\n"}, {"source_code": "from sys import stdin\ninput = stdin.buffer.readline\n\na, b, c = map(int, input().split())\nfor i in range(10001):\n if c >= a * i and not (c - a * i) % b:\n exit(print('Yes'))\nprint('No')"}, {"source_code": "a, b, c = map(int,input().split())\n \nif c%a:\n while c>0 and c%b:\n c -= a\n print('Yes' if c>0 else 'No')\nelse:\n print('Yes')"}, {"source_code": "x, y, z = map(int, input().split())\nfor a in range(0, z + 1, x):\n for b in range(a, z + 1, y):\n if b == z:\n print(\"Yes\")\n exit()\nprint(\"No\")"}, {"source_code": "\ndef equation1(a, b, c):\n for x in range (1,9999):\n if (c-b*x)>0 and (c - b*(x)) % a == 0:\n result = \"Yes\"\n print (result)\n break\n else:\n result = \"No\"\n print (result)\n return\n\ndef solveyesorno (a, b, c):\n\n if c%(a+b) == 0:\n result = \"Yes\"\n print (result) \n elif c%a == 0:\n result = \"Yes\"\n print (result)\n elif c%b == 0:\n result = \"Yes\"\n print (result)\n else:\n equation1(a, b, c)\n return\n \n\n\na, b, c = [int(x) for x in input().split()]\nsolveyesorno (a, b, c)\n"}, {"source_code": "a, b, c = map(int, input().split())\nif a > b:\n while c % a != 0 and c >= 0:\n c -= b\nelse:\n while c % b != 0 and c >= 0:\n c -= a\nif c < 0:\n print(\"No\")\nelse:\n print(\"Yes\")"}, {"source_code": "a, b, c = map(int, input().split())\nam = 0\nbm = 0\nka = 0\nkb = 0\nif c % a == 0:\n print('YES')\nelif c == 9995 or c == 9871:\n print('YES')\nelif c % b == 0:\n print('YES')\nelif a > c or b > c:\n print('NO')\nelse:\n while am * a < c:\n am += 1\n while bm * b < c:\n bm += 1\n for i in range(1, am):\n for j in range(1, bm):\n if (i * a) + (j * b) == c:\n ka += 1\n for i in range(1, bm):\n for j in range(1, am):\n if (i * b) + (j * a) == c:\n kb += 1\n if ka >= 1 or kb >= 1:\n print('YES')\n else:\n print('NO')"}, {"source_code": "__author__ = 'Mac'\na,b,c=map(int,raw_input().split())\nprint 'Yes' if [x for x in range(10100) if c>=a*x and 0==(c-a*x)%b] else 'No'"}, {"source_code": "a,b,c = map(int,input().split())\nif c % a == 0 or c % b == 0: print(\"Yes\"); exit()\nelse:\n for i in range(a,c,a):\n if (c-i)%b == 0: print(\"Yes\"); exit()\n for i in range(b,c,b):\n if (c-i)%a == 0: print(\"Yes\"); exit()\nprint(\"No\")"}, {"source_code": "n,m,c=map(int,input().split())\ndef gcd(n,m):\n if m==0:\n return n\n else:\n return gcd(m,n%m)\nif c%gcd(n,m)==0:\n f=0\n x=c//n\n while x>=0:\n if (c-x*n)%m==0:\n f=1\n break\n else:\n x-=1\n if f==1:\n print('Yes')\n else:\n print('No') \n \nelse:\n print('No') "}, {"source_code": "def solve(a,b,c):\n for i in range(int(c/a)+1):\n for j in range(int(c/b) +1):\n if i*a + j*b == c:\n return True\n return False\na,b,c = map(int,input().split())\nif solve(a,b,c):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "def main():\n a, b, c = map(int,input().split())\n M = max(a,b)\n m = min(a,b)\n for i in range(0,c//M+1):\n if((c-M*i)%m==0):\n print(\"Yes\")\n return\n print(\"No\")\n\nmain()\n"}, {"source_code": "a, b, c = [int(i) for i in raw_input().split()]\n\ni=1\nflag = False\n\nfor i in xrange(0, int(c/a)+1):\n k = c - a*i\n if k%b==0:\n flag = True\n break\n\nif flag:\n print 'Yes'\nelse:\n print 'No'"}, {"source_code": "from math import gcd\na,b,c=list(map(int,input().split()))\nflag=0\nfor i in range(0,c+1,a):\n if((c-i)%b==0):\n print('YES')\n flag=1\n break\nif(flag==0):\n print('NO')"}, {"source_code": "a, b, c = map(int, input().split())\nh = 0\nif c % a == 0:\n k = c // a\nelse:\n k = c // a + 1\nif c % b == 0:\n m = c // b\nelse:\n m = c // b + 1\nif c - a*k < 0 and c - b*m < 0 and ((c < 2 * a) and c < 2*b):\n print('No')\nelse:\n for i in range(k+1):\n if (c - a*i) % b == 0 and (h == 0):\n print('Yes')\n h = 1\n if h == 0:\n print('No')\n"}, {"source_code": "def extendedEuclid(a, b):\n global x, y, d\n if b == 0:\n x = 1\n y = 0\n d = a\n return\n\n extendedEuclid(b, a % b)\n x1 = y\n y1 = x - (a // b) * y\n x = x1\n y = y1\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\n\nif __name__ == \"__main__\":\n x = 0\n y = 0\n d = 0\n\na, b, c = map(int, input().split())\n\nx = 0\ny = 0\n\nret = False\n\nwhile a * x + b * y <= c and not ret:\n y = 0\n while a * x + b * y <= c and not ret:\n if a * x + b * y == c:\n ret = True\n y += 1\n x += 1\n y = 0\n\nif ret:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "a,b,c=map(int,input().split())\nx=0\nwhile x<=c:\n\tif (c-x)%b==0:\n\t\tprint(\"YES\")\n\t\texit()\n\tx+=a\nprint(\"NO\")"}, {"source_code": "#!/usr/bin/python2.7\n#\n# nezahualcoyotl\nimport sys\n\n\ndef main():\n\tinput = raw_input()\n\tdamage = input.split(' ')\n\tdamage = map(int, damage)\n\ti = 0\n\n\tif(damage[2] % damage[0] == 0 ):\n\t\tprint \"yes\"\n\t\treturn\n\tif(damage[2] % damage[1] == 0 ):\n\t\tprint \"yes\"\n\t\treturn\n\n\twhile(1):\n\t\tif(damage[0]*i > damage[2]):\n\t\t\tprint \"no\"\n\t\t\treturn\n\t\tif(damage[0] + damage[1] == damage[2]):\n\t\t\tprint \"yes\"\n\t\t\treturn\n\t\tfor j in xrange(0, (damage[2]/damage[1]) + 1):\n\t\t\tif(damage[0]*i + damage[1]*j == damage[2]):\n\t\t\t\tprint \"yes\"\n\t\t\t\treturn\n\n\t\ti += 1\n\n\n\nmain()"}, {"source_code": "abc = list(map(int,input().split()))\na, b, c = abc[0], abc[1], abc[2]\nfor i in range(c // a + 1):\n if (c - i * a) % b == 0 or c - i * a == 0:\n print('YES')\n exit()\n\nprint('NO')"}, {"source_code": "abc = input().split(\" \")\na = int(abc[0])\nb = int(abc[1])\nc = int(abc[2])\nflag = False\nfor i in range((c//a)+1):\n for h in range((c//b)+1):\n n = i*a + h*b\n if n == c:\n flag = True\n break\n if flag:\n break\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "a,b,c=map(int,input().split())\nmin1=min(a,b)\nif c%a==0 or c%b==0:\n print(\"Yes\")\n exit()\nmax1=max(a,b)\nwhile(c>0):\n\n c-=min1\n if c%max1==0:\n print(\"Yes\")\n break\nelse:\n print(\"No\")"}, {"source_code": "a, b, c = map(int, raw_input().split())\nfor i in xrange(10011):\n if c - i * a >= 0 and (c - i * a) % b == 0:\n print \"Yes\"\n break\nelse:\n print \"No\"\n"}, {"source_code": "a,b,c = map(int, input().split(\" \"))\n\ndef a633(a,b,c):\n u = max(a,b)\n v = min(a,b)\n if u == c == 0:\n print(\"YES\")\n return\n elif u == 0 and c > 0:\n print(\"NO\")\n return\n else:\n for i in range((c//u)+1):\n if (c - i*u)%v == 0:\n print(\"YES\")\n return\n print(\"NO\")\n\na633(a,b,c)\n"}, {"source_code": "a, b, c = map(int, input().split())\n\ni = 0\n\nwhile i*a <= c:\n if not((c-i*a)%b):\n print(\"YES\")\n exit()\n i += 1\nprint(\"NO\")\n \n"}, {"source_code": "a,b,c=list(map(int,input().split()))\nmymin,mymax=min(a,b),max(a,b)\nif c%a==0 or c%b==0:\n print('Yes')\nelse:\n while c>=mymin:\n if c%mymin==0:\n print('Yes')\n break\n else:\n c-=mymax\n else:\n print('No')"}, {"source_code": "a, b, c = map(int, input().split())\n\nfor x in range(0, 10001):\n y = (c - a * x) // b\n if a * x + b * y == c and y >= 0:\n # print(x, y)\n exit(print(\"Yes\"))\nexit(print(\"No\"))\n"}, {"source_code": "def solve(a,b,c):\n for i in range(int(c/a)+1):\n for j in range(int(c/b) +1):\n if i*a + j*b == c:\n return True\n return False\na,b,c = map(int,input().split())\nif solve(a,b,c):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "(a, b, c) = map(int, str(raw_input()).split())\n\nfor i in range(c/b+1):\n\tif (c-b*i)%a == 0:\n\t\tprint \"Yes\"\n\t\texit()\n\nprint \"No\""}, {"source_code": "import sys\n\nsys.setrecursionlimit(9999999)\n\na, b, c = map(int, raw_input().split())\n\n\nclass Memoize(object):\n cache = {}\n\n @staticmethod\n def memoizer(func):\n def memoizedFunc(*args):\n if args not in Memoize.cache:\n Memoize.cache[args] = func(*args)\n return Memoize.cache[args]\n\n return memoizedFunc\n\n @staticmethod\n def clear():\n Memoize.cache = {}\n\n\n@Memoize.memoizer\ndef solve(a, b, c):\n if c < 0:\n return False\n if c % a == 0 or c % b == 0:\n return True\n return solve(a, b, c - a) or solve(a, b, c - b)\n\n\nsolvable = solve(a, b, c)\nif solvable:\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "#!/usr/bin/python\n\nfrom collections import deque\n\ndef ir():\n return int(raw_input())\n\ndef ia():\n line = raw_input()\n line = line.split()\n return map(int, line)\n\na, b, c = ia()\n\nwhile True:\n if c < 0:\n print 'No'\n break\n elif c % b == 0:\n print 'Yes'\n break\n c = c - a\n"}, {"source_code": "'''\nCreated on 03-Mar-2016\n\n@author: venkatesh\n'''\n\n\ndef main():\n a, b, c = [int(x) for x in raw_input().split()]\n y = 0\n while True:\n temp = c - b * y\n if temp < 0:\n break\n if temp % a == 0:\n print \"Yes\"\n return\n y += 1\n print \"No\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a,b,c = map(int, input().split())\n\nans = \"NO\"\n\nif c % a == 0 or c % b == 0:\n print(\"YES\")\n quit()\n\nfor i in range(5000):\n for j in range(5000):\n if a*i + b*j == c:\n ans = \"YES\"\n break\n if ans == \"YES\":break\n \nprint(ans)"}, {"source_code": "a, b, c = map(int, input().split())\n\nfor i in range(c // a + 1):\n if (c - a * i) % b == 0:\n print('Yes')\n exit()\n\nprint('No')"}, {"source_code": "'''\nCreated on 03-Mar-2016\n\n@author: venkatesh\n'''\n\n\ndef main():\n a, b, c = [int(x) for x in raw_input().split()]\n y = 0\n while b * y <= c:\n if (c - b * y) % a == 0:\n print \"Yes\"\n return\n y += 1\n print \"No\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\n \n \ndef ans(s):\n print(s)\n sys.exit()\n \n \na, b, c = map(int, input().split())\nif c % a == 0:\n ans('Yes')\nwhile c > 0:\n if c % b == 0:\n ans('Yes')\n c -= a\nans('No')\n"}, {"source_code": "def queue(q, x, y, z):\n i = 1\n while len(q) != 0:\n if x * i < z:\n q.append(x * i)\n i += 1\n elif x * i == z:\n print('Yes')\n exit()\n else:\n if q[0] + y < z:\n q.append(q[0] + y)\n del q[0]\n elif q[0] + y == z:\n print('Yes')\n exit()\n else:\n del q[0]\n\n\n\na, b, c = map(int, input().split())\nqueue_a, queue_b = [a], [b]\nqueue(queue_a, a, b, c)\nqueue(queue_b, b, a, c)\nprint('No')\n"}, {"source_code": "def f(l):\n a,b,c = l #100,100,1e4\n if a<b:\n a,b=b,a #let a = bigger\n aa = 0\n while aa<=c:\n if (c-aa)%b==0:\n return True\n aa += a\n return False\n\nl = list(map(int,input().split()))\nprint('Yes' if f(l) else 'No')\n"}, {"source_code": "def gcd(a,b):\n if (a==0):\n return b\n else:\n return gcd(b%a,a)\na,b,c=map(int,raw_input().split())\nk=0\nif c%gcd(a,b)==0:\n for i in range(c+1):\n for j in range(c+1):\n if a*i+b*j==c:\n k+=1\n break\n else:\n continue\n break\n if (k==0):\n print \"NO\"\n else:\n print\"YES\"\nelse:\n print \"NO\""}, {"source_code": "\"\"\"\na=1\nb=1\nc=10000\n\"\"\"\n\na, b, c = tuple(map(int, input().split()))\n\nif a == c:\n print (\"yes\")\nelse: \n if b == c:\n print (\"yes\")\n \n else:\n p1 = [x for x in range(c+1) if x % a == 0]\n if c in p1:\n print (\"yes\") \n else:\n p2 = [y for y in range(c+1) if y % b == 0]\n if c in p2:\n print (\"yes\")\n else:\n shot = (r+s for r in p1 for s in p2 if r+s <= c and r+s > c-a-b)\n \n if c in shot: \n print (\"yes\")\n else:\n print ('no')\n\n \n\n#print (shot)\n"}, {"source_code": "a, b, c = map(int, input().split())\nfor i in range(c // a + 1):\n if (c - i * a) % b == 0:\n print('Yes')\n exit()\nprint('No')\n"}, {"source_code": "a,b,c=map(int,input().split())\nfor i in range(c//a+1):\n if (c-i*a)%b==0: print('Yes'); break\nelse: print('No')"}, {"source_code": "a,b,c=map(int,input().split())\ni=0\nk=c\nwhile (c - b*i)>=0:\n k=c-b*i\n if k%a==0:\n print('Yes')\n exit()\n i+=1\nprint('No') \n \n "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Feb 15 16:08:39 2019\n\n@author: Retr0\n\"\"\"\n\n\nn = [int(x) for x in input().split()]\na = n[0]\nb = n[1]\nc = n[2]\n\n\n\n\nif (a<b):\n aux = b\n b = a\n a = aux\n\nrest = c%b\nquot = c//b\nok = True\nif (c%a == 0) or (c%b==0) : \n print('Yes')\n ok = False\nelse : \n for i in range((a-rest)//b,quot+1):\n if ((i*b+ rest)%a == 0):\n print('Yes')\n ok = False\n break\n \n\nif ok :\n print('No')\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n"}, {"source_code": "'''input\n6 11 6\n'''\nfrom math import gcd\na, b, c = map(int, input().split())\nfor x in range(c//a+1):\n\tif (c - x*a) % b == 0:\n\t\tprint(\"Yes\")\n\t\tbreak\nelse:\n\tprint(\"No\")"}, {"source_code": "a,b,c=map(int,input().split())\ni=0\nwhile (c-(b*i))>=0 :\n z=(c-(b*i))%a\n i+=1\n if z==0:break\nprint([\"No\",\"Yes\"][z==0])"}, {"source_code": "a,b,c=map(int,input().split())\nfor i in range((c//a)+1):\n for j in range((c//b)+1):\n if (i*a)+(j*b)==c:\n print('Yes')\n exit(0)\n if (i*a)+(j*b)>10000:\n break\nprint('No')"}, {"source_code": "a, b, c = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nwhile c > 0 and c > a and c > b :\n if c%a == 0 or c%b == 0 :\n break\n if a >= b :\n c -= a\n if b > a :\n c -= b\nif c%a == 0 or c%b == 0:\n print(\"Yes\")\nelse :\n print(\"No\")"}, {"source_code": "from sys import *\ninp = lambda : stdin.readline()\n\ndef main():\n a,b,c = map(int,inp().split())\n k,a = a,0\n while a <= c:\n if (c-a)%b == 0:\n print(\"Yes\")\n exit(0)\n a += k\n print(\"No\")\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a, b, c = map(int, input().split())\nfor x in range(max(c//b,c//a) + 2):\n if (-a * x + c >= 0) and (-a * x + c) % b == 0:\n print('Yes')\n break\nelse:\n print('No')\n"}, {"source_code": "nums = list(map(int, input().split()))\ne = nums[0]\ni = nums[1]\ndmg = nums[2]\npassed = False\n\nif(dmg is e or dmg is i or dmg is 0):\n print(\"Yes\")\nelse:\n index = 0\n while(e*index < dmg and i*index < dmg):\n if((dmg-e*index)%i is 0):\n passed = True\n break\n elif((dmg-i*index)%e is 0):\n passed = True\n break\n index += 1\n if(passed):\n print(\"Yes\")\n else:\n print('No')"}, {"source_code": "a,b,c=list(map(int,input().strip().split()))\n\nfrom math import gcd\n\ndef egcd(a,b):\n if(a==0):\n return b, (0,1)\n else:\n g, (x1, y1) = egcd(b%a, a)\n x=y1-b//a*x1\n y=x1\n return g, (x, y)\n\nif(c%gcd(a,b)==0):\n g, (x,y) = egcd(a,b)\n a//=g \n b//=g\n c//=g\n g, (x,y) = egcd(a,b)\n x*=c//g\n y*=c//g\n #print(x,y)\n if(x<0):\n t=((-x)+b-1)//b\n x+=t*b\n y-=t*a\n elif(y<0):\n t=((-y)+a-1)//a\n #print(t)\n x-=t*b\n y+=t*a \n #print(x,y)\n if(x>=0 and y>=0):\n assert(x*a+y*b==c)\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\nfor x in xrange(20000):\n\tif (c - a * x) % b == 0 and c - a * x >= 0:\n\t\tprint \"Yes\"\n\t\texit(0)\n\nprint \"No\"\nexit(0)"}, {"source_code": "a, b, c = list(map(int, input().split()))\n\n\ndef gcd(a, b):\n global x\n global y\n if b == 0:\n x = 1\n y = 0\n\n return a\n else:\n\n d = gcd(b, a % b)\n # print(x, y)\n x, y = y, x - y * (a // b)\n\n return d\n\n\nx = 0\ny = 0\ng = gcd(a, b)\n\nfrom math import ceil\n\nif c % g == 0:\n\n x = x * (c // g)\n y = y * (c // g)\n\n if x < 0:\n k = (ceil(abs(x) / (b // g)))\n x = x + k *( b // g)\n y = y - k* (a // g)\n elif y<0:\n k = (ceil(abs(y) / (a // g)))\n x = x - k * (b // g)\n y = y + k * (a // g)\n\n if x < 0 or y < 0:\n print(\"No\")\n else:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "import sys\nimport fractions\na,b,c = map(int, input().split())\nfor i in range(0, c+ 1):\n if c - a *i >= 0 and (c - a*i) % b == 0:\n print(\"YES\")\n sys.exit()\n\nprint(\"NO\")"}, {"source_code": "a, b, c = map(int, input().split())\nfor x in range((c//b)+100):\n if (-a * x + c >= 0) and (-a * x + c) % b == 0:\n print('Yes')\n break\nelse:\n print('No')\n"}, {"source_code": "import sys\na, b, c = map(int, raw_input().split())\nfor x in range(0, 10001):\n\tif (a * x <= c) and ((c - a * x) % b == 0):\n\t\tprint \"Yes\"\n\t\tsys.exit()\nprint \"No\"\t\t\n"}, {"source_code": "a,b,c = map(int,(raw_input().split()))\nfor i in range(0,10000):\n d = c - b * i\n if (d % a == 0 and d>=0):\n print(\"Yes\")\n exit(0)\n if (d<=0):\n print(\"No\")\n exit(0)\nprint(\"No\")"}, {"source_code": "a,b,c=map(int,raw_input().split())\n\nwhile c >= 0:\n if c%b == 0:\n print 'Yes'\n break\n c -= a\nelse:\n print 'No'\n"}, {"source_code": "\"\"\"\n CODEFORCES 633-A \n Ebony and Ivory\n \n by: Ariel Roque\n\"\"\"\n\na,b,c = map(int,raw_input().split())\n\nx = 0\nfound = False\n\nwhile(True):\n\t\n\ty = (c - (a*x)) / b\t\n\t\n\tif((a*x + b*y > c) or y < 0):\n\t\tbreak\n\t\n\tif(((c - (a*x)) % b == 0) and (a*x + b*y == c )):\n\t\tprint(\"YES\")\n\t\tfound = True\n\t\tbreak\t\n\t\n\tx+=1\n\nif(found == False):\n\tprint(\"No\")\n\t\n\t\n\t\t\n\t\n\t\n\t\n\t\n\t\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\n\na,b,c=r()\n\nfor i in range(c/a+1):\n if not ((c-i*a)%b):\n print \"Yes\"\n exit(0)\nprint \"No\""}, {"source_code": "a,b,c=map(int,input().split())\nf=0\nfor i in range(10001):\n n=c-i*a\n if(n>=0 and n//b==n/b):\n f=1\n break\n if(n<=0):\n break\nif(f==1):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n \n"}, {"source_code": "import sys\na, b, c = map(int, input().split())\nfor i in range(0, c + 1, a):\n if (c - i) % b == 0:\n print('Yes')\n sys.exit()\nprint('No') \n"}, {"source_code": "def haha():\n x = str(raw_input())\n x = x.split(\" \")\n a = int(x[0])\n b = int(x[1])\n c = int(x[2])\n i = 0\n if a > b:\n t = c//a\n while i <= t:\n if (c - i*a)%b == 0:\n print \"YES\"\n break\n else: \n i += 1\n if i > t:\n print \"NO\"\n elif b > a:\n t = c//b\n while i <= t:\n if (c - i*b)%a == 0:\n print \"YES\"\n break\n else: \n i += 1\n if i > t:\n print \"NO\"\n else: \n if c%a == 0:\n print \"YES\"\n else: \n print \"NO\"\n \n \nhaha()\n "}, {"source_code": "\n\n\"\"\"\n[int(i) for i in raw_input().split(\" \")]\nraw_input()\nraw_input().split(\" \")\n\n\n\"\"\"\n\ndef main():\n\t\n\ta,b,c = [int(i) for i in raw_input().split(\" \")]\n\t\n\t\n\tL = [0]*(c+1)\n\tL[0] = 1\n\t\n\tfor i in range(1,c+1):\n\t\tif i-a >= 0:\n\t\t\tif L[i-a] == 1:\n\t\t\t\tL[i] = 1\n\t\tif i-b >= 0:\n\t\t\tif L[i-b] == 1:\n\t\t\t\tL[i] = 1\n\t\n\tif L[c] == 1:\n\t\tprint \"Yes\"\n\telse:\n\t\tprint \"No\"\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\nmain()\n\t\n\t"}, {"source_code": "import io\nimport sys\nimport math\nimport itertools as itt\n\n\ndef rlist(t):\n return map(t, raw_input().split())\n\n\ndef read_int_list():\n return rlist(int)\n\n\ndef write_list(lst, divider=\" \"):\n print divider.join(map(str, lst))\n\n\ndef main():\n a, b, c = read_int_list()\n for i in xrange(0, c+1, a):\n if (c - i) % b == 0:\n print \"Yes\"\n return 0\n print \"No\"\nmain()\n"}, {"source_code": "a,b,c=map(int, raw_input().split())\nif a>b: a,b=b,a\nfor i in range(c/b + 1):\n if (c-i*b) % a == 0:\n print \"Yes\"\n exit(0)\nprint \"No\"\n"}], "negative_code": [{"source_code": "l=lambda:map(int,raw_input().split())\na, b, c=l()\nfor i in range(c/b):\n if (c-b*i)%a == 0:\n print \"Yes\"\n exit()\nprint \"No\""}, {"source_code": "a,b,c = map(int,(raw_input().split()))\nfor i in range(1,10000):\n d = c - a * i\n if (d % b == 0):\n print(\"YES\")\n exit(0)\n if (d<=0):\n print(\"NO\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "a=input().split()\nb=int(a[0])\nc=int(a[1])\nd=int(a[2])\ni=0\nj=0\np=0\nfor i in range(100):\n for j in range(100):\n k=(b*i)+(c*j)\n if(k==d):\n p=1\n break\nif(p==1):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "a,b,c=map(int,input().split())\ni=0\nz=95\nwhile (c-(b*i))>0 :\n z=(c-(b*i))%a\n i+=1\n if z==0:break\nprint([\"No\",\"Yes\"][z==0]) "}, {"source_code": "import sys\nreadline = lambda: sys.stdin.readline().rstrip()\nwrite = sys.stdout.write\n\n\ndef calc(a, b, c):\n\tg, _, _ = egcd(a, b)\n\treturn not c % g\n\n\ndef egcd(a, b):\n\tif b==0: return (a, 1, 0)\n\tg, x, y = egcd(b, a%b)\n\treturn (g, y, x-a/b*y)\n\n\na, b, c = [int(x) for x in readline().split()]\nif calc(a, b, c): write(\"Yes\\n\")\nelse: write(\"No\\n\")\n"}, {"source_code": "from sys import exit\na, b, c = [int(i) for i in input().split()]\nfor i in range(101):\n for j in range(101):\n if a * i + b * j == c:\n print(\"Yes\")\n exit(0)\nprint(\"No\")\n"}, {"source_code": "a, b, c = map(int, input().split())\nfor x in range((c//b)+3):\n if (-a * x + c) % b == 0:\n print('Yes')\n break\nelse:\n print('No')\n"}, {"source_code": "def gcdvar(a,b):\n if b==0:\n x=1\n y=0\n return (a,x,y)\n p=gcdvar(b,a%b)\n d=p[0]\n x1=p[1]\n y1=p[2]\n x=y1\n y=x1-y1*(a//b)\n return (d,x,y)\ndef check(a,b,c):\n k=gcdvar(a,b)\n g=k[0]\n x0=k[1]\n y0=k[2]\n if (c%g):\n print(\"No\")\n else:\n print(\"Yes\")\n \na,b,c=map(int,input().split())\ncheck(a,b,c)"}, {"source_code": "a,b,c = map(int,input().split())\na,b = sorted([a,b], reverse = True)\n# print(a,b)\nwhile b > 0:\n a,b = b,a%b\nprint([\"Yes\",\"No\"][c%a!=0])"}, {"source_code": "def strelba(a, b, c):\n for i in range(0, c):\n for j in range(0, i):\n if a * i + b * j == c:\n return \"YES\"\n return \"NO\"\n\n\nA, B, C = [int(k) for k in input().split()]\nprint(strelba(A, B, C))\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\nfor i in range(c//b+1):\n if (c - i**b) % a == 0:\n print 'Yes'\n exit()\nprint 'No'"}, {"source_code": "data = raw_input().split()\n\na = int(data[0])\nb = int(data[1])\nc = int(data[2])\n\nanswer_ = False\n\na_ = 0\nb_ = 0\n\ni = 0\nwhile a_ < c:\n a_ += a\n b_ = b\n if a_ == c:\n answer_ = True\n break\n j = 0\n while b_ < c:\n if a_ + b_ == c:\n answer_ = True\n break\n else:\n b_ += b\n if b_ == c:\n answer = True\n break\n j += 1\n i += 1\n\n\nprint 'YES' if answer_ else 'NO'\n\n\n"}, {"source_code": "\ndef gcdvar(a,b):\n if b==0:\n x=1\n y=0\n return (a,x,y)\n p=gcdvar(b,a%b)\n d=p[0]\n x1=p[1]\n y1=p[2]\n x=y1\n y=x1-y1*(a//b)\n return (d,x,y)\ndef check(a,b,c):\n k=gcdvar(a,b)\n g=k[0]\n x0=k[1]\n y0=k[2]\n if (c%g):\n print(\"No\")\n else:\n x=x0*(c/g)\n y=y0*(c/g)\n if x>=0 and y>=0:\n print(\"Yes\")\n else:\n print(\"No\")\n \na,b,c=map(int,input().split())\ncheck(a,b,c)\n"}, {"source_code": "#!/usr/bin/python2.7\n#\n# nezahualcoyotl\nimport sys\n\n\ndef main():\n\tinput = raw_input()\n\tdamage = input.split(' ')\n\tdamage = map(int, damage)\n\n\tif(damage[2] % damage[0] == 0 ):\n\t\tprint \"yes\"\n\t\treturn\n\tif(damage[2] % damage[1] == 0 ):\n\t\tprint \"yes\"\n\t\treturn\n\tif(damage[1] > damage[2] and damage[0] > damage[2]):\n\t\tprint \"no\"\n\t\treturn\n\tif(damage[0] %2 == 0):\n\t\t# if(damage[2] %2 == 0):\n\t\t# \tprint \"yes\"\n\t\t# \treturn\n\t\tif(damage[1] %2 ==0 and damage[2] %2 !=0):\n\t\t\tprint \"no\"\n\t\t\treturn\n\t\telif(damage[2] %2 !=0 and damage[1]%2 != 0):\n\t\t\tif((damage[2]-damage[1]) % damage[0] == 0):\n\t\t\t\tprint \"yes\"\n\t\t\t\treturn\n\t\t\telse:\n\t\t\t\tprint \"no\"\n\t\t\t\treturn\n\t\telif(damage[2] %2 ==0 and damage[2]%damage[0] ==0):\n\t\t\tprint \"yes\"\n\t\t\treturn\n\t\telse:\n\t\t\tprint \"no\"\n\t\t\treturn\n\n\tif(damage[1] %2 == 0):\n\t\t# if(damage[2] %2 == 0):\n\t\t# \tprint \"yes\"\n\t\t# \treturn\n\t\tif(damage[0] %2 ==0 and damage[2] %2 !=0):\n\t\t\tprint \"no\"\n\t\t\treturn\n\t\telif(damage[2] %2 !=0 and damage[0]%2 != 0):\n\t\t\tif((damage[2]-damage[0]) % damage[1] == 0):\n\t\t\t\tprint \"yes\"\n\t\t\t\treturn\n\t\t\telse:\n\t\t\t\tprint \"no\"\n\t\t\t\treturn\n\t\telif(damage[2] %2 ==0 and damage[2]%damage[1] ==0):\n\t\t\tprint \"yes\"\n\t\t\treturn\n\t\telse:\n\t\t\tprint \"no\"\n\t\t\treturn\n\t\n\nmain() "}, {"source_code": "def gcd(xx,yy):\n x, y = sorted([xx,yy])\n while y != 0:\n r = x%y\n x = y \n y = r\n return x\n\n\na, b, c = [int(x) for x in input().split()]\nd = gcd(a,b)\nif c%d == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "def func(a,b,c):\n j=0\n while j<c:\n p=(c-(j*a))/b\n if p>=0 and p.is_integer():\n return 1\n j+=1\n return 0\n\na,b,c=map(int,input().split())\nif func(a,b,c):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "a, b, c = map(int, input().split())\nfor x in range((c//b)+3):\n if (-a * x + c) % b == 0:\n print('Yes')\n break\nelse:\n print('No')\n"}, {"source_code": "a, b, c = map(int, input().split())\nfor i in range(0, 10000):\n if (i * a > c):\n exit()\n if (c - i * a) % b == 0:\n print(\"Yes\")\n exit()\nprint(\"No\")\n"}, {"source_code": "a, b, c = map(int, input().split())\nflag = False\nfor i in range(1, 101):\n if (i * b - c) % a == 0:\n if i * b <= c:\n flag = True\n break\nif flag:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "#a,b,c=map(int,input().split())\na=3\nb=2\nc=7\nwin=False\n\nfor i in range ((c//b)+1):\n if (c-(b*i))%a==0:\n win=True\nif win==True:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "from fractions import gcd\n\na, b, c = [int(x) for x in input().split()]\n\nfor i in range(0, c, a):\n if (c - i) % b == 0:\n print(\"Yes\")\n break\nelse:\n print(\"No\")"}, {"source_code": "#M16_A\n\nln = [int(i) for i in input().split(\" \")]\n\na = ln[0]\nb = ln[1]\nc = ln[2]\n\nf = False\nwds = [\"No\", \"Yes\"]\n\nfor i in range(0, c, a):\n for j in range(0, c, b):\n if i + j == c:\n f = True\n\nprint(wds[f])\n"}, {"source_code": "a,b,c=map(int,input().split())\nif c%a==0 or c%b==0: print(\"Yes\")\nelif c%(a+b)==a or c%(a+b)==b: print(\"Yes\")\nelse: print(\"No\")"}, {"source_code": "'''\nCreated on 03-Mar-2016\n\n@author: venkatesh\n'''\n\nfrom fractions import gcd\n\n\ndef main():\n a, b, c = [int(x) for x in raw_input().split()]\n d = gcd(a, b)\n if c % a == 0 or c % b == 0 or (c > d and c % d == 0):\n print \"Yes\"\n else:\n print \"No\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a,b,c=map(int,input().split())\nfor i in range(c//a):\n if (c-i*a)%b==0: print('Yes'); break\nelse: print('No')"}, {"source_code": "from sys import exit\na, b, c = [int(i) for i in input().split()]\nfor i in range(101):\n for j in range(101):\n if a * i + b * j == c:\n print(\"Yes\")\n exit(0)\nprint(\"No\")\n"}, {"source_code": "a, b, c = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nwhile c != 0 and c > a and c > b :\n if c%a == 0 or c%b == 0 :\n break\n if a > b :\n c -= a\n if b > a :\n c -= b\nprint(c)\nif c%a == 0 or c%b == 0:\n print(\"Yes\")\nelse :\n print(\"No\")"}, {"source_code": "\ndef euclidian_gcd(a,b):\n if b==0:\n return a\n else:\n return euclidian_gcd(b,a%b)\n\nif __name__ =='__main__':\n \n a,b,c = [int(x) for x in input().split()]\n if a>b:\n k = euclidian_gcd(a,b)\n else:\n k = euclidian_gcd(b,a)\n if c%k:\n print(\"NO\")\n else:\n print(\"YES\")\n\n"}, {"source_code": "a, b, c = map(int, input().split())\nif c % a == 0 or c % b == 0:\n print('Yes')\n exit()\nwhile c > 0:\n c -= a\n if c % b == 0:\n print('Yes')\n exit()\nprint('No')\n"}, {"source_code": "readInts=lambda: list(map(int, input().split()))\n\na,b,c=readInts()\n\nfor i in range (c//a):\n if (c-i*a)%b==0:\n print('Yes')\n exit(0)\nprint('No')"}, {"source_code": "import sys\nimport fractions\na,b,c = map(int, input().split())\nif c % fractions.gcd(a,b) == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x,y,z=map(int,input().split())\ni=1\nwhile(1):\n if(z<i*x):\n print(\"NO\")\n break\n if((z-i*x)%y==0):\n print(\"YES\")\n break\n i=i+1\n"}, {"source_code": "a,b,c=map(int,input().split())\ncount=0\nfor i in range(c):\n for j in range(c):\n k=i*a + b*j\n if(k==c):\n count+=1\n break\n\nif(count>0):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n \n \n\n \n \n \n \n \n \n \n\n\n"}, {"source_code": "#!/usr/bin/python2.7\n#\n# nezahualcoyotl\nimport sys\n\n\ndef main():\n\tinput = raw_input()\n\tdamage = input.split(' ')\n\tdamage = map(int, damage)\n\n\tif(damage[2] % damage[0] == 0 ):\n\t\tprint \"yes\"\n\t\treturn\n\tif(damage[2] % damage[1] == 0 ):\n\t\tprint \"yes\"\n\t\treturn\n\tif(damage[1] > damage[2] and damage[0] > damage[2]):\n\t\tprint \"no\"\n\t\treturn\n\tif(damage[0] %2 == 0):\n\t\t# if(damage[2] %2 == 0):\n\t\t# \tprint \"yes\"\n\t\t# \treturn\n\t\tif(damage[1] %2 ==0 and damage[2] %2 !=0):\n\t\t\tprint \"no\"\n\t\t\treturn\n\t\telif(damage[2] %2 !=0 and damage[1]%2 != 0):\n\t\t\tif((damage[2]-damage[1]) % damage[0] == 0):\n\t\t\t\tprint \"yes\"\n\t\t\t\treturn\n\t\t\telse:\n\t\t\t\tprint \"no\"\n\t\t\t\treturn\n\t\telif(damage[2] %2 ==0 and damage[2]%damage[0] ==0):\n\t\t\tprint \"yes\"\n\t\t\treturn\n\t\telse:\n\t\t\tprint \"no\"\n\t\t\treturn\n\n\tif(damage[1] %2 == 0):\n\t\t# if(damage[2] %2 == 0):\n\t\t# \tprint \"yes\"\n\t\t# \treturn\n\t\tif(damage[0] %2 ==0 and damage[2] %2 !=0):\n\t\t\tprint \"no\"\n\t\t\treturn\n\t\telif(damage[2] %2 !=0 and damage[0]%2 != 0):\n\t\t\tif((damage[2]-damage[0]) % damage[1] == 0):\n\t\t\t\tprint \"yes\"\n\t\t\t\treturn\n\t\t\telse:\n\t\t\t\tprint \"no\"\n\t\t\t\treturn\n\t\telif(damage[2] %2 ==0 and damage[2]%damage[1] ==0):\n\t\t\tprint \"yes\"\n\t\t\treturn\n\t\telse:\n\t\t\tprint \"no\"\n\t\t\treturn\n\t\n\nmain() "}, {"source_code": "import math\nip=input().split(' ')\na=int(ip[0])\nb=int(ip[1])\nc=int(ip[2])\n\ndef gcd(a,b):\n if b==0:\n return a,1,0\n g,x,y=gcd(b,a%b)\n return g,y,x-y*int(a/b)\n\ng,x,y=gcd(a,b)\n\nif(c%g):\n print(\"No\")\nx*=c/g\ny*=c/g\n# print(g,x,y)\n\nmink=math.ceil(-x*g/b)\nmaxk=math.floor(y*g/a)\n\n# print(mink,maxk)\n\nif(c%g or mink>maxk):\n print(\"No\")\nelse:\n print(\"Yes\")\n"}, {"source_code": "readInts=lambda: list(map(int, input().split()))\n\na,b,c=readInts()\n\nfor i in range (c//a+1):\n print(c-i*a)\n if (c-i*a)%b==0:\n print('Yes')\n exit(0)\nprint('No')"}, {"source_code": "a,b,c = map(int,input().split())\nif c%a==0 or c%b==0:\n\tprint('Yes')\n\tquit()\nif c<=max(a,b):\n\tprint('No')\n\tquit()\n\nwhile c>a:\n\tc-=b\nif c==a:\n\tprint('Yes')\n\tquit()\nelse:\n\tprint('No')"}, {"source_code": "'''\nCreated on 03-Mar-2016\n\n@author: venkatesh\n'''\n\nfrom fractions import gcd\n\n\ndef main():\n a, b, c = [int(x) for x in raw_input().split()]\n d = gcd(a, b)\n if (c >= a and c >= b):\n if c % d == 0:\n print \"Yes\"\n else:\n print \"No\"\n elif c % a == 0 or c % b == 0:\n print \"Yes\"\n else:\n print \"No\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "# http://codeforces.com/contest/633/problem/A\n\n\"\"\"\nHas two guns and which deal damage a and b respectively. In order to break the shield\nneed to deal exactly c units of damage. Find out if this is possible.\n\nThis boils down to whether or not ax+by=c has positive solutions.\n\"\"\"\n\nfrom math import floor, ceil\n\n\ndef ExtendedEuclidean(a, b):\n if a == 0:\n return b, 0, 1\n\n gcd, x_1, y_1 = ExtendedEuclidean(b % a, a)\n\n x = y_1 - (b // a) * x_1\n y = x_1\n\n return gcd, x, y\n\n\ndef is_plc(a, b, c):\n # Positive Linear Combination\n gcd, x_0, y_0 = ExtendedEuclidean(a, b)\n if c % gcd != 0:\n return False\n\n x_0, y_0 = x_0 * (c//gcd), y_0 * (c//gcd)\n\n if x_0 >= 0 and y_0 >= 0:\n return True\n if x_0 < 0 and y_0 < 0:\n return False\n if x_0 < 0:\n p = floor(c * x_0 / b)\n elif y_0 < 0:\n p = ceil(-c * y_0 / a)\n\n x_1, y_1 = x_0 - p * b / c, y_0 + p * a / c\n\n if x_1 >= 0 and y_1 >= 0:\n return True\n else:\n return False\n\n\nif __name__ == '__main__':\n a, b, c = map(int, input().split())\n if is_plc(a, b, c):\n print('Yes')\n else:\n print('No')\n"}, {"source_code": "x,y,z=map(int,input().split())\ni=1\nwhile(1):\n if(z<i*x):\n print(\"NO\")\n break\n if((z-i*x)%y==0):\n print(\"YES\")\n break\n i=i+1\n"}, {"source_code": "a,b,c=list(map(int,input().strip().split()))\n\nfrom math import gcd\n\ndef egcd(a,b):\n if(a==0):\n return b, (0,1)\n else:\n g, (x1, y1) = egcd(b%a, a)\n x=y1-b//a*x1\n y=x1\n return g, (x, y)\n\nif(c%gcd(a,b)==0):\n g, (x,y) = egcd(a,b)\n x*=c//g\n y*=c//g\n\n if(x<0):\n t=((-x)+b-1)//b\n x+=t*b\n y-=t*a\n elif(y<0):\n t=((-y)+a-1)//a\n x-=t*b\n y+=t*a \n if(x>=0 and y>=0):\n assert(x*a+y*b==c)\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")"}, {"source_code": "a, b, c = map(int, input().split())\nif c % a == 0 or c // a % b == 0 or c % b == 0 or c // b % a == 0:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "abc=input().split()\na=int(abc[0])\nb=int(abc[1])\nc=int(abc[2])\nif c%a==0 or c%b==0:\n print('Yes')\nelse:\n if (c-a)%b==0 or (c-b)%a==0:\n print('Yes')\n elif (c-c%a*b)%a==0 or (c-c%b*a)%b==0:\n print('Yes')\n else:\n print('No')"}, {"source_code": "a, b, c = map(int, input().split())\nflag = False\nfor i in range(1, 101):\n if (i * b - c) % a == 0:\n if i * b <= c:\n flag = True\n break\nif flag:\n print('Yes', i)\nelse:\n print('No')\n"}, {"source_code": "import math\na,b,c=map(int,input().split())\nif c%math.gcd(a,b)==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "\ndef euclidian_gcd(a,b):\n if b==0:\n return a\n else:\n return euclidian_gcd(b,a%b)\n\nif __name__ =='__main__':\n \n a,b,c = [int(x) for x in input().split()]\n if a>b:\n k = euclidian_gcd(a,b)\n else:\n k = euclidian_gcd(b,a)\n if c%k:\n print(\"NO\")\n else:\n print(\"YES\")\n\n"}, {"source_code": "\ndef euclidian_gcd(a,b):\n if b==0:\n return a\n else:\n return euclidian_gcd(b,a%b)\n\nif __name__ =='__main__':\n \n a,b,c = [int(x) for x in input().split()]\n if a>b:\n k = euclidian_gcd(a,b)\n else:\n k = euclidian_gcd(b,a)\n if c%k:\n print(\"NO\")\n else:\n print(\"YES\")\n\n"}, {"source_code": "'''\nCreated on 03-Mar-2016\n\n@author: venkatesh\n'''\n\nfrom fractions import gcd\n\n\ndef main():\n a, b, c = [int(x) for x in raw_input().split()]\n d = gcd(a, b)\n print \"Yes\" if c >= d and c % d == 0 else \"No\"\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "abc=input().split()\na=int(abc[0])\nb=int(abc[1])\nc=int(abc[2])\nif c%a==0 or c%b==0:\n print('Yes')\nelse:\n if (c-a)%b==0 or (c-b)%a==0:\n print('Yes')\n elif (c-c%a*b)%a==0 or (c-c%b*a)%b==0:\n print('Yes')\n else:\n print('No')"}, {"source_code": "x,y,z=map(int,input().split())\nfor i in range(1000000):\n if((z-i*x)%y==0):\n print(\"YES\")\n exit()\nprint('NO')\n"}, {"source_code": "a,b,c = map(int,input().split(' '))\nif c==a or c==b:\n print(\"YES\")\nelif a==b:\n if c%a!=0:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n\n if b>a:\n start = a\n end = b\n else:\n start = b\n end = a\n\n sum_ = a\n while(sum_<c):\n sum_+=start\n\n if sum_==c:\n print(\"YES\")\n else:\n sum_ = sum_ - start\n while(sum_<c):\n sum_ = (sum_-start)+end\n if sum_==c:\n print(\"YES\")\n else:\n print('NO')"}, {"source_code": "a,b,c = input().split()\na = int(a)\nb = int(b)\nc = int(c)\npossible = False\nfor i in range(100000):\n x = (c-(a*i))%b\n if(x==0):\n possible = True\n break\nif(possible):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "from math import gcd\na, b, c = map(int, input().split())\nif c % gcd(a, b) == 0:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "#!/usr/bin/python\n\nimport sys\nline = sys.stdin.readline()\n\nnumbers = line.split()\n\neb = int(numbers[0])\niv = int(numbers[1])\ndm = int(numbers[2])\nflag = 0\nfor numEb in range(0,dm/eb+1):\n if (dm-numEb*eb)%iv == 0:\n print \"Yes\",\n flag = 1\n break\nfor numIv in range(0,dm/eb+1):\n if flag == 1:\n break\n if (dm-numIv*iv)%eb == 0:\n print \"Yes\",\n flag = 1\n break\nif flag == 0:\n print \"No\","}, {"source_code": "#M16_A\n\nln = [int(i) for i in input().split(\" \")]\n\na = ln[0]\nb = ln[1]\nc = ln[2]\n\nf = False\nwds = [\"No\", \"Yes\"]\n\nfor i in range(0, c, a):\n for j in range(0, c, b):\n if i + j == c:\n f = True\n\nprint(wds[f])\n"}, {"source_code": "a, b, c = map(int, input().split())\nif c % a == 0 or c % b == 0:\n print('Yes')\n exit()\nelif min(a, b) > c:\n print('No')\n exit()\nwhile c > 0:\n c -= a\n if c % b == 0:\n print('Yes')\n exit()\nprint('No')\n"}, {"source_code": "import math as mt \nimport sys,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\na,b,c=M()\nfor i in range(10000):\n if(c-b*i)%a==0:\n print(\"Yes\")\n exit()\n if(c-b*i<0):\n break\nprint(\"No\")\n"}, {"source_code": "__author__ = '11x256'\n\n\na,b,c = map(int,raw_input().split())\n\n\nif ((c % b )% a == 0):\n print 'Yes'\nelse:\n print'No'"}, {"source_code": "import sys\nreadline = lambda: sys.stdin.readline().rstrip()\nwrite = sys.stdout.write\n\n\ndef calc(a, b, c):\n\tsol = first_sol(a, b, c)\n\tif not sol: return False\n\tg, x, y = sol\n\tleft = (-x*g+b)/b\n\tright = y*g/a\n\treturn left <= right\n\ndef egcd(a, b):\n\tif b==0: return (a, 1, 0)\n\tg, x, y = egcd(b, a%b)\n\treturn (g, y, x-a/b*y)\n\ndef first_sol(a, b, c):\n\tg, x, y = egcd(abs(a), abs(b))\n\tif c%g: return None\n\tx, y = x*c/g, y*c/g\n\tif a < 0: x = -x\n\tif b < 0: y = -y\n\treturn (g, x, y)\n\n\na, b, c = [int(x) for x in readline().split()]\nif calc(a, b, c): write(\"Yes\\n\")\nelse: write(\"No\\n\")"}, {"source_code": "a, b, c = map(int, input().split())\nfor x in range((c//b)+5):\n if (-a * x + c >= 0) and (-a * x + c) % b == 0:\n print('Yes')\n break\nelse:\n print('No')\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Feb 15 16:08:39 2019\n\n@author: Retr0\n\"\"\"\n\n\nn = [int(x) for x in input().split()]\na = n[0]\nb = n[1]\nc = n[2]\n\n\n\n\nif (a<b):\n aux = b\n b = a\n a = aux\n\nrest = c%b\nquot = c//b\nok = True\nfor i in range(1,quot+1):\n\n if (c%(i*b+ rest) == 0):\n \n if i*a > c :\n print('No')\n ok = False\n else:\n print('yes')\n break\n\n\nif ok :\n print('No')\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n"}, {"source_code": "a, b, c = [int(i) for i in raw_input().split(' ')]\nif a < b:\n a, b = b, a\nans = 0\nfor i in range(max(1, (c+a-1)/a)):\n if (c - i*a) % b == 0:\n ans = 1\n break\nprint 'Yes' if ans else 'No' "}, {"source_code": "s=[int(n) for n in input().split()]\nif s[2]%s[0]==0:\n\tprint('Yes')\nelif s[2]%s[1]==0:\n\tprint('Yes')\nelif s[2]%(s[1]+s[0])==0:\n\tprint('Yes')\nelif (s[2]%(s[1]+s[0]))%s[0]==0:\n\tprint('Yes')\nelif (s[2]%(s[1]+s[0]))%s[1]==0:\n\tprint('Yes')\nelse:\n\tprint('No')"}, {"source_code": "a,b,c = list(map(int,input().split()))\nd = c%(a+b)\nif d==a or d==b or d==0 or c%a==0 or c%b==0:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "#from dust i have come, dust i will be\n\na,b,c=map(int,input().split())\n\nfor i in range(1,101):\n x=c-(i*a)\n\n if(x<0):\n break\n\n if x%b==0:\n print(\"YES\")\n exit(0)\n\nprint(\"NO\")\n\n"}, {"source_code": "a,b,c=map(int,input().split())\nd=0\ndef ans(a,b,c,d):\n if c%a==0 or c%b==0:\n print('Yes')\n return\n else:\n while d<c:\n d+=a\n if (b-d)%c==0:\n print('Yes')\n return\n else:\n continue\n print(\"No\")\n return\nans(a,b,c,d)\n"}, {"source_code": "from sys import stdin\na,b,c = stdin.readline().split()\nprint(a)\nprint(b)\n\ndef damage(a,b,c,x,y):\n res = a*x+b*y\n return c == res\n\nflag = False\n\nfor x in range(0,int(c)+1):\n for y in range(0,int(c)+1):\n if damage(int(a),int(b),int(c),int(x),int(y)):\n print('Yes')\n flag = True\n break\n\nif not flag:\n print('No')"}, {"source_code": "a, b, c = map(int, input().strip().split(\" \"))\nflag = 0\nfor x in range(101):\n for y in range(101):\n if (a*x + b*y) == c:\n flag = 1\n break\n\nif flag == 0:\n print(\"No\")\nelse:\n print(\"Yes\")\n\n"}, {"source_code": "def gcd(a,b):\n if b==0:\n return a,1,0\n g,x,y = gcd(b,a%b)\n temp = x\n x=y\n y = temp-(a//b)*y\n return g,x,y\n\na,b,c=map(int,input().split())\ng,x,y = gcd(a,b)\nif c%g and x>=0 and y>=0:print(\"Yes\")\nelse:print(\"No\")\n"}, {"source_code": "from math import *\nfrom collections import Counter,defaultdict,deque\nfrom sys import stdin, stdout\ninput = stdin.readline\nI =lambda:int(input())\nM =lambda:map(int,input().split())\nLI=lambda:list(map(int,input().split()))\nn,m,k=M()\na=k-n\nb=k-m\nif k%n==0 or k%m==0 or (n-m!=0 and k%abs(n-m)==0) or a%m==0 or b%n==0:\n print(\"Yes\")\nelse:\n print(\"No\")\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n\n\n \n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n\n\n\n \n"}, {"source_code": "#!/usr/bin/python\n\nimport sys\nline = sys.stdin.readline()\n\nnumbers = line.split()\n\neb = int(numbers[0])\niv = int(numbers[1])\ndm = int(numbers[2])\nflag = 0\nfor numEb in range(0,dm/eb+1):\n if (dm-numEb*eb)%iv == 0:\n print \"Yes\",\n flag = 1\n break\nfor numIv in range(0,dm/eb+1):\n if flag == 1:\n break\n if (dm-numIv*iv)%eb == 0:\n print \"Yes\",\n flag = 1\n break\nif flag == 0:\n print \"No\","}, {"source_code": "nums = list(map(int, input().split()))\ne = nums[0]\ni = nums[1]\ndmg = nums[2]\n\ndef check(a, b, dmg, index):\n if(a*index + b > dmg):\n return False\n \n if((dmg-a*index)%b is 0):\n return True\n \n return check(a, b, dmg, index+1)\n\n\nif(dmg is e or dmg is i or dmg is 0):\n print(\"Yes\")\n\nelif(check(e, i, dmg, 1) or check(i, e, dmg, 1)):\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "a,b,c = map(int,input().split())\nif c%a==0 or c%b==0:\n\tprint('Yes')\n\tquit()\nif c<=max(a,b):\n\tprint('No')\n\tquit()\n\nc1, c2 = c, c\nwhile c1>a:\n\tc1-=b\nif c1==a:\n\tprint('Yes')\n\tquit()\nelse:\n\twhile c2>b:\n\t\tc2-=a\n\tif c2==b:\n\t\tprint('Yes')\n\t\tquit()\nprint('No')"}, {"source_code": "a,b,c = map(int,(raw_input().split()))\nfor i in range(1,10000):\n d = c - a * i\n if (d % b == 0):\n print(i,d//b)\n print(\"YES\")\n exit(0)\n if (d<=0):\n exit(0)\nprint(\"NO\")"}, {"source_code": "from sys import stdin\n\na,b,c = map(int,stdin.readline().split())\n\ndef damage2():\n for y in range(0,int(c)+1):\n x = int((c - b*y)/a) \n res = a*x+b*y\n if c == res:\n return 'Yes'\n return 'No'\n\nprint(damage2())"}, {"source_code": "a, b, c = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nwhile c != 0 and c > a and c > b :\n if c%a == 0 or c%b == 0 :\n break\n if a > b :\n c -= a\n if b > a :\n c -= b\nprint(c)\nif c%a == 0 or c%b == 0:\n print(\"Yes\")\nelse :\n print(\"No\")"}, {"source_code": "def gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a%b)\n\n\na, b, c = [int(i) for i in input().split()]\ng = gcd(a, b)\nif c % g == 0 and g != 1:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "import math\n#for _ in range(int(input())):\na,b,n = map(int,input().split())\ng = math.gcd(a,b)\n\ndef gcdExtended(a, b): \n\n # Base Case \n if a == 0 : \n return b, 0, 1\n \n gcd, x1, y1 = gcdExtended(b%a, a) \n \n # Update x and y using results of recursive \n # call \n x = y1 - (b//a) * x1 \n y = x1 \n \n return gcd , x, y\n\n\ng,p,q = gcdExtended(a, b)\n#print(p,q)\n\nx = (p*n)//g\ny = (q*n)//g\ns = (a*x) + (b*y)\n\nif n%g != 0 or s <0:\n print('No')\nelse:\n print('Yes')\n\n\n\n \n"}, {"source_code": "import sys\nreadline = lambda: sys.stdin.readline().rstrip()\nwrite = sys.stdout.write\n\n\ndef calc(a, b, c):\n\tsol = first_sol(a, b, c)\n\tif not sol: return False\n\tg, x, y = sol\n\tleft = (-x*g+b)/b\n\tright = y*g/a\n\treturn left <= right\n\ndef egcd(a, b):\n\tif b==0: return (a, 1, 0)\n\tg, x, y = egcd(b, a%b)\n\treturn (g, y, x-a/b*y)\n\ndef first_sol(a, b, c):\n\tg, x, y = egcd(abs(a), abs(b))\n\tif c%g: return None\n\tx, y = x*c/g, y*c/g\n\tif a < 0: x = -x\n\tif b < 0: y = -y\n\treturn (g, x, y)\n\n\na, b, c = [int(x) for x in readline().split()]\nif calc(a, b, c): write(\"Yes\\n\")\nelse: write(\"No\\n\")"}, {"source_code": "x,y,z=map(int,input().split())\nif(x>y):\n x,y=y,x\ni=1\nwhile(1):\n if(z<i*x):\n print(\"NO\")\n break\n if((z-i*x)%y==0):\n print(\"YES\")\n break\n i=i+1\n"}, {"source_code": "data = raw_input().split()\n\na = int(data[0])\nb = int(data[1])\nc = int(data[2])\n\nanswer_ = False\n\ndef test():\n a_ = 0\n b_ = 0\n\n while a_ <= c:\n b_ = b\n a_ += a\n if a_ == c:\n return True\n while b_ <= c:\n if a_ + b_ == c:\n return True\n b_ += b\n if b_ == c:\n return True\n if a_ + b_ == c:\n return True\n\n\nprint 'YES' if test() else 'NO'\n\n\n"}, {"source_code": "a, b, c = map(int, input().split())\nhelp = False\nfor i in range(a):\n if help:\n break\n for j in range(b):\n if i == 0 and j == 0:\n continue\n if c % a * i + b * j == 0:\n help = True\n print('Yes')\n break\nif not help:\n print('No')"}, {"source_code": "from math import *\nfrom collections import Counter,defaultdict,deque\nfrom sys import stdin, stdout\ninput = stdin.readline\nI =lambda:int(input())\nM =lambda:map(int,input().split())\nLI=lambda:list(map(int,input().split()))\nn,m,k=M()\na=k-n\nb=k-m\nif k%n==0 or k%m==0 or (n-m!=0 and k%abs(n-m)==0) or a%m==0 or b%n==0:\n print(\"Yes\")\nelse:\n print(\"No\")\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n\n\n \n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n\n\n\n \n"}, {"source_code": "a, b, c = [int(i) for i in raw_input().split(' ')]\nif a < b:\n a, b = b, a\nans = 0\nfor i in range(max(1, (c+a-1)/a)+1):\n if (c - i*a) % b == 0:\n ans = 1\n break\nprint 'Yes' if ans else 'No'"}, {"source_code": "a,b,c=map(int,raw_input().split(' '))\nc=0\nfor i in range(c/a+1):\n for j in range(c/b+1):\n if((a*i+b*j)==c):\n c=1\n break\n\nprint 'Yes' if(c==1) else 'No'"}, {"source_code": "\"\"\"\na=1\nb=1\nc=10000\n\"\"\"\n\na, b, c = tuple(map(int, input().split()))\n\nif a == c:\n print (\"yes\")\nelse: \n if b == c:\n print (\"yes\")\n \n else:\n p1 = (x for x in range(c+1) if x % a == 0)\n if c in p1:\n print (\"yes\") \n else:\n p2 = (y for y in range(c+1) if y % b == 0)\n if c in p2:\n print (\"yes\")\n else:\n shot = (r+s for r in p1 for s in p2 if r+s <= c and r+s > c-a-b)\n \n if c in shot: \n print (\"yes\")\n else:\n print ('no')\n\n \n\n#print (shot)\n"}, {"source_code": "import sys\na,b,c = map(int, input().split())\nc -= (a+b)\nif c < 0:\n print(\"NO\")\n sys.exit()\nfor i in range(0,c+1):\n for j in range(0,c+1):\n if a*i + b * j == c:\n print(\"YES\")\n sys.exit()\nprint(\"NO\")"}, {"source_code": "a, b, c = map(int, input().split())\nhelp = False\nfor i in range(a + 1):\n if help:\n break\n for j in range(b + 1):\n if i == 0 and j == 0:\n continue\n if c % (a * i + b * j) == 0:\n help = True\n print('Yes')\n break\nif not help:\n print('No')"}, {"source_code": "import sys\nreadline = lambda: sys.stdin.readline().rstrip()\nwrite = sys.stdout.write\n\n\ndef calc(a, b, c):\n\tg, _, _ = egcd(a, b)\n\treturn not c % g\n\n\ndef egcd(a, b):\n\tif b==0: return (a, 1, 0)\n\tg, x, y = egcd(b, a%b)\n\treturn (g, y, x-a/b*y)\n\n\na, b, c = [int(x) for x in readline().split()]\nif calc(a, b, c): write(\"Yes\\n\")\nelse: write(\"No\\n\")\n"}, {"source_code": "qqq = map(int, raw_input(' ').split())\na = qqq[0]\nb = qqq[1]\nc = qqq[2]\n\nif c%a==0:\n print 'Yes'\nelse:\n while c>0:\n if (c-a)%b==0:\n print 'Yes'\n break\n c = c - a\n if c<0:\n print 'No'\n"}, {"source_code": "a,b,c = map(int,(raw_input().split()))\nfor i in range(0,10000):\n d = c - b * i\n if (d % a == 0):\n print(\"Yes\")\n exit(0)\n if (d<=-1):\n print(\"No\")\n exit(0)\nprint(\"No\")"}, {"source_code": "\na,b,c=map(int,input().split())\nf=0\nfor i in range(1,10001):\n if ((c-a*i)//b)*b==(c-a*i):\n f=1\n print(\"YES\")\n break\nif f==0:\n print(\"NO\")"}, {"source_code": "import math\n#for _ in range(int(input())):\na,b,n = map(int,input().split())\ng = math.gcd(a,b)\n\ndef gcdExtended(a, b): \n\n # Base Case \n if a == 0 : \n return b, 0, 1\n \n gcd, x1, y1 = gcdExtended(b%a, a) \n \n # Update x and y using results of recursive \n # call \n x = y1 - (b//a) * x1 \n y = x1 \n \n return gcd , x, y\n\nans = 1\ng,p,q = gcdExtended(a, b)\n\nk1 = -(p*n)/b\nk2 = (q*n)/a\n\nif k2 < k1:\n ans = 0\n\n\n#print(k1,k2)\n#print(p,q,g)\n\nif n%g != 0 or abs(k2 - k1) < 1 or ans == 0:\n print('No')\nelse:\n print('Yes')\n\n\n\n \n"}, {"source_code": "a, b, c = map(int, raw_input().split())\nif a > b:\n a, b = b, a\nif a > c:\n print \"Yes\"\nelse:\n d = 0\n while b * d <= c:\n if (c - b * d) % a == 0:\n print \"Yes\"\n break\n d += 1\n else:\n print \"No\""}, {"source_code": "a, b, c = tuple(map(int, input().split()))\n\np1 = [x for x in range(c) if x % a == 0]\np2 = [y for y in range(c) if y % b == 0]\n\n#print (p1)\n\nshot = {r+s for r in p1 for s in p2 if r+s <= c and r+s > c-a-b}\n\n\nif c in shot:\n print (\"yes\")\nelse:\n print ('no')\n"}, {"source_code": "n,m,c=map(int,input().split())\ndef gcd(n,m):\n if m==0:\n return n\n else:\n return gcd(m,n%m)\nif c%gcd(n,m)==0:\n print('Yes')\nelse:\n print('No') "}, {"source_code": "def gcd(a,b):\n if a == 0:\n return b\n else:\n return gcd(b%a,a)\n \n \n \n \n \n \na,b,c =map(int,input().split())\nif c/gcd(a,b) == 0:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "from math import gcd\na, b, c = [int(p) for p in input().split()]\nif gcd(a, b) == 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a, b, c = map(int, input().split())\nif c%a==0 or c%b==0:print(\"Yes\")\nelif c%a == abs(a-b):print(\"Yes\")\nelse: print(\"No\")"}, {"source_code": "x,y,z=map(int,input().split())\nfor i in range(1000000):\n if((z-i*x)%y==0):\n print(\"YES\")\n exit()\nprint('NO')\n"}], "src_uid": "e66ecb0021a34042885442b336f3d911"} {"source_code": "import sys\r\ninput=lambda:sys.stdin.readline().rstrip()\r\ndef solve():\r\n\tN=int(input())\r\n\tprint(2**N-1)\r\nT=int(input())\r\nfor i in range(T):\r\n\tsolve()", "positive_code": [{"source_code": "a=int(input())\r\nfor i in range(a):\r\n b=int(input())\r\n print(2**b-1)\r\n"}, {"source_code": "\r\nfor i in range(int(input())):\r\n temp = input()\r\n val = int(temp)\r\n val = 2**val - 1\r\n print(val)"}, {"source_code": "from sys import stdin, stdout\r\nt = int(stdin.readline())\r\nfor i in range(t):\r\n n = int(stdin.readline())\r\n stdout.write(f\"{(1<<n)-1}\\n\")"}, {"source_code": "for i in range(int(input())):\r\n n=int(input())\r\n print(max(2**n-1,1))\r\n"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print(2**n-1+1-1)\r\n"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n x = (2**n)-1\r\n print(x)\r\n \r\n "}, {"source_code": "#https://codeforces.com/blog/entry/71884\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\nt = inp()\r\nfor _ in range(t):\r\n n = inp()\r\n print((2 ** n) - 1)"}, {"source_code": "n = int(input())\r\nfor i in range(n):\r\n athlete = 2**int(input())\r\n print(athlete-1)\r\n"}, {"source_code": "from cgi import test\r\n\r\n\r\ntestCases = int(input())\r\nwinners = list()\r\nfor i in range(testCases):\r\n N = int(input())\r\n winningath = pow(2,N) -1\r\n winners.append(winningath)\r\n\r\nfor x in winners:\r\n print(x)"}, {"source_code": "t = int(input())\r\nwhile t > 0:\r\n print(2 ** int(input()) - 1)\r\n t-=1\r\n"}, {"source_code": "from sys import stdin, setrecursionlimit\ninput = stdin.readline\n\nfrom bisect import bisect_left, bisect_right\nfrom collections import deque\nfrom functools import lru_cache, reduce\nfrom heapq import heappush, heappop\nfrom math import sqrt, ceil, floor, log2\n\nT = int(input())\n\ndef rl(t = int):\n return list(map(t, input().split()))\n\nfor t in range(1, T + 1):\n n = int(input())\n\n print((1 << n) - 1)\n"}, {"source_code": "import io\nimport os\n\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n\ndef solve():\n n = int(input())\n print(2**n-1)\n\n\nt = int(input())\n\nfor _ in range(t):\n solve()\n"}, {"source_code": "t=int(input())\r\nwhile t:\r\n n=int(input())\r\n print(2**n-1)\r\n t-=1"}, {"source_code": "for i in range(int(input())):\r\n print(2**(int(input()))-1)\r\n"}, {"source_code": "# https://codeforces.com/contest/1651\n\nanswer = \"\"\n\n\ndef eval_case(expo):\n global answer, match_expo_winner\n if expo == 1:\n return 1\n\n return (1 << expo) - 1\n\n\nif __name__ == '__main__':\n numCases = int(input())\n for i in range(numCases):\n expo = int(input())\n answer += str(eval_case(expo)) + \"\\n\"\n print(answer)\n"}, {"source_code": "t = int(input())\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n print(2**n - 1)\r\n\r\n \r\n # r,l,a = map(int,input().strip().split())\r\n # if r == l:\r\n # if l == a:\r\n # print(1)\r\n # else:\r\n # print((l//a) + (l%a))\r\n # elif l < a:print(l)\r\n # elif l == a:print(a-1)\r\n # else:\r\n # if l%a != 0:print((l//a) + (l%a))\r\n # else:print(((l-1)//a)+((l-1)%a))\r\n\r\n # s = input()\r\n # c = input()\r\n # if c in s:\r\n # if(s.index(c)%2 == 0 and (len(s)-s.index(c)-len(c))%2 ==0):\r\n # print(\"YES\")\r\n # else:\r\n # print(\"NO\")\r\n # else:\r\n # print(\"NO\") \r\n # if len(s) == len(c):\r\n # if s == c:\r\n # print(\"YES\") \r\n # else:\r\n # print(\"NO\")\r\n # else:\r\n # j = 0\r\n # n = len(s)\r\n # while(j < n):\r\n # if s[j] == c: \r\n # print(\"YES\")\r\n # break\r\n # j = j + 2 \r\n # else:\r\n # print(\"NO\") \r\n\r\n\r\n"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print(2**n-1)"}, {"source_code": "lenght = int(input())\r\nanswers = []\r\n\r\nfor i in range (lenght):\r\n x = int(input())\r\n answers.append((2**x)-1)\r\nfor i in answers:\r\n print(i)"}, {"source_code": "for _ in range(int(input())):\r\n print(2 ** int(input()) - 1)"}, {"source_code": "n_prob = int(input())\r\n\r\nfor _ in range(n_prob):\r\n print(2**(int(input()))-1)"}, {"source_code": "t=int(input())\r\nl2=[]\r\nfor i in range(t):\r\n n=int(input())\r\n l2.append(2**n-1)\r\n \r\nfor elem in l2:\r\n print(elem)"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n print((1<<n)-1)"}, {"source_code": "for i in range(int(input())):\r\n print(2**int(input())-1)"}, {"source_code": "for _ in range(int(input())):\n print(2**int(input()) - 1)"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n if n==1:\r\n print(1)\r\n else:\r\n print((2**n)-1)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nT = int(input())\nwhile T:\n T -= 1\n n = int(input())\n print(2**n - 1)\n"}, {"source_code": "for i in range (int(input())):\r\n n = int(input())\r\n print(2**n-1)"}, {"source_code": "# A\r\n\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n\r\ndef sol(n):\r\n return 2 ** n - 1\r\n\r\nnum_tests = inp()\r\nfor _ in range(num_tests):\r\n sys.stdout.write(str(sol(inp()))+'\\n')"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n if n==1:\r\n print(1)\r\n else:\r\n print(2**n-1)"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print((2**n)-1)"}, {"source_code": "cases = int(raw_input().strip())\r\n\r\nfor c in xrange(cases):\r\n numMatches = int(raw_input().strip())\r\n numPlayers = pow(2, numMatches)\r\n print numPlayers - 1"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n print(2 ** n - 1)"}, {"source_code": "from sys import stdin\r\nraw_input = lambda: stdin.readline().rstrip()\r\ninput = lambda: int(raw_input())\r\nI=lambda: map(int, raw_input().split())\r\nt = input()\r\nfor _ in xrange(t):\r\n\tn = input()\r\n\tprint (2**n) - 1"}, {"source_code": "for _ in range(int(input())):\r\n\tn = int(input())\r\n\tprint(2 ** n - 1)"}, {"source_code": "# main.py\r\n\r\n# D <--~~~ __ _\r\n# U o'')}____//\r\n# O `_/ )\r\n# N (_(_/-(_/\r\n# G ~~~~~~~~~~~~~~~~~-->\r\n\r\nMOD_PRIME = 10**9 + 7\r\n\r\n\r\ndef inp(to: type = str):\r\n return to(input())\r\n\r\n\r\ndef inp_arr(to: type = str):\r\n return list(\r\n map(to, inp().split())\r\n )\r\n\r\n\r\ndef swap(A, i, j):\r\n A[i], A[j] = A[j], A[i]\r\n\r\n\r\ndef MEX(a):\r\n b = range(0, max(a)+2)\r\n return min(set(b)-set(a))\r\n\r\n\r\ndef solve():\r\n n = inp(int)\r\n print(pow(2, n)-1)\r\n\r\n\r\ndef main():\r\n for _ in range(inp(int)):\r\n solve()\r\n return\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n"}, {"source_code": "for i in range(int(input())):\r\n a=int(input())\r\n b=lambda x:(2**x)-1\r\n print(b(a))"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n == 1:\r\n print(1)\r\n else:\r\n print(2**n-1)"}, {"source_code": "import sys\r\nimport math\r\nfrom collections import defaultdict, Counter\r\nfrom bisect import *\r\nfrom string import ascii_lowercase\r\n\r\n\r\ndef readInts():\r\n x = list(map(int, (sys.stdin.readline().rstrip().split())))\r\n return x[0] if len(x) == 1 else x\r\n\r\n\r\ndef readList(type=int):\r\n x = sys.stdin.readline()\r\n x = list(map(type, x.rstrip('\\n\\r').split()))\r\n return x\r\n\r\n\r\ndef readStr():\r\n x = sys.stdin.readline().rstrip('\\r\\n')\r\n return x\r\n\r\n\r\nwrite = sys.stdout.write\r\nread = sys.stdin.readline\r\n\r\n\r\ndef solve():\r\n n = readInts()\r\n print(pow(2, n) - 1)\r\n\r\n\r\n\r\ndef main():\r\n t = 1\r\n t = readInts()\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n p = 2**n\r\n print(2**n-1)"}, {"source_code": "x = int(input())\r\nfor i in range(x):\r\n \r\n print(2**int(input())-1)"}, {"source_code": "import sys\r\nimport math\r\nfrom sys import stdin\r\nfor _ in range(int(stdin.readline())):\r\n n= int(stdin.readline())\r\n\r\n print((2**n)-1)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "def main ():\r\n tests = int(input())\r\n for i in range(tests):\r\n n = int(input())\r\n print((2**n)-1)\r\n\r\nmain()"}, {"source_code": "import sys\r\ndef print(a):\r\n sys.stdout.write(str(a)+'\\n')\r\ndef input():\r\n return sys.stdin.readline().strip()\r\nfor _ in range(int(input())):\r\n n=int(input())\r\n print(2**n-1)"}, {"source_code": "t = int(input())\r\nfor i in range (t) :\r\n n = int(input())\r\n print(2 ** n - 1)\r\n"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n x=pow(2,n)\r\n print(x-1)"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n if n==1:\r\n print(1)\r\n else:\r\n print((2**n)-1)"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n print((1 << n) - 1)\r\n"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n print((2 ** n) - 1)"}, {"source_code": "n=int(input())\r\nfor _ in range(n):\r\n x=int(input())\r\n print(2**x-1)"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n print(2**n-1)"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n x=2**n-1\r\n if n==1:\r\n print(\"1\")\r\n else:\r\n print(x)"}, {"source_code": "def answer():\r\n n = int(input())\r\n print(2**n - 1)\r\n \r\n\r\n\r\n\r\n\r\nfor _ in range(int(input())):\r\n answer()"}, {"source_code": "for t in range(int(input())):\r\n n = int(input())\r\n if(n == 1):\r\n print(1)\r\n else:\r\n print(2**n - 1)"}, {"source_code": "for _ in range(int(input())):\n print((1 << int(input())) - 1)\n"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print(2**n-1)"}, {"source_code": "for i in range(int(input())):\n print(2 ** int(input()) - 1)\n"}, {"source_code": "n = int(input())\r\nfor i in range(n):\r\n a = int(input())\r\n print(2**a - 1)"}, {"source_code": "casenum = int(input())\r\n\r\nfor i in range(casenum):\r\n print( 2 ** int(input()) - 1)\r\n"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n print((2**n)-1)"}, {"source_code": "# cook your dish here\r\nfor i in range(int(input())):\r\n n=int(input())\r\n if n==1:\r\n print(1)\r\n else:\r\n print(2**n-1)\r\n \r\n \r\n \r\n "}, {"source_code": "def solve():\r\n x = int(input())\r\n a = 1\r\n for j in range(1,x+1):\r\n a*=2\r\n print(a-1)\r\ncase = int(input())\r\nfor _ in range(case):\r\n solve()\r\n"}, {"source_code": "j = int(input())\r\nfor i in range(j):\r\n n = int(input())\r\n print(int(pow(2,n)-1))\r\n"}, {"source_code": "for g in[*open(0)][1:]:print(2**int(g)-1)"}, {"source_code": "\r\n\r\nt=int(input())\r\n\r\nfor _ in range(t):\r\n n=int(input())\r\n print(2**n-1)"}, {"source_code": "t = int(input()) \r\ndef main() :\r\n n = int(input())\r\n return 2**n-1\r\n\r\n\r\n\r\n\r\n\r\nR = []\r\nfor _ in range(t) :\r\n R.append(main())\r\nfor ans in R :\r\n print(ans)"}, {"source_code": "from sys import stdin\ninp = [*map(int, stdin.read().strip().splitlines())]\n\nfor i in range(inp[0]):\n print((2**inp[1:][i])-1)\n"}, {"source_code": "cases = int(input())\r\nfor x in range(cases):\r\n n = int(input())\r\n print((2**n)-1)"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print((2**n)-1)"}, {"source_code": "# codeforces 1651A playoff\r\n\r\n# 2**n athletes compete\r\n# athletes are numbered\r\n# n stages\r\n# \r\nt = int(input())\r\nfor i in range(t):\r\n n = 2**int(input())\r\n\t\r\n if n == 1:\r\n print(1)\r\n else:\r\n print(n-1)"}, {"source_code": "l=[]\r\nt=int(input())\r\nfor i in range(1,t+1):\r\n n=int(input())\r\n l.append(n)\r\nfor i in range(0,t):\r\n print(pow(2,l[i])-1)"}, {"source_code": "t = int(input())\r\nprint(*[2 ** int(input()) - 1 for i in range(t)], sep=\"\\n\")"}, {"source_code": "t=int(input(\"\"))\r\nfor z in range(t):\r\n n=int(input(\"\"))\r\n p=2**n\r\n print(p-1)"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n x = pow(2,n)\r\n print(x-1)"}, {"source_code": "test=int(input())\r\nfor i in range(test):\r\n player=int(input())\r\n if player<=1:\r\n print(1)\r\n else:\r\n print(pow(2,player)-1)"}, {"source_code": "t = int(input())\n\nfor i in range(t):\n n = int(input())\n if n == 1:\n print(1)\n else:\n print(2**n - 1)\n"}, {"source_code": "import sys\n\n# Mike change this based on the codeforces problem.\nlinesPerTest = 1\n\ntestArguments = []\n\ni = 0\ntotalLines = 1\n\n# Read all the lines from stdin, write them to testCasesUnformatted.\nwhile i <= totalLines:\n line = sys.stdin.readline().rstrip('\\n')\n if i == 0:\n \ttotalLines = linesPerTest * int(line)\n else:\n testArguments.append(line)\n i += 1\n\n# Group the test arguments into test cases.\ntestCases = []\nfor j in range(0, len(testArguments), linesPerTest):\n\ttestCases.append(testArguments[j:j + linesPerTest])\n\ndef f(testArguments):\n n = int(testArguments[0])\n return 2**n - 1\n\nfor testCase in testCases:\n\tprint(f(testCase))\n\n\n"}, {"source_code": "from sys import stdin\r\n \r\nt=int(stdin.readline())\r\nwhile t>0:\r\n t-=1\r\n n=int(stdin.readline())\r\n print(2**n-1)"}, {"source_code": "a = int(input())\r\nfor i in range (0,a):\r\n b= int (input())\r\n c = (2**b) -1\r\n print(c)\r\n \r\n \r\n\r\n\r\n"}, {"source_code": "game_nums = int(input())\r\n\r\nfor i in range(game_nums):\r\n g = int(input())\r\n print(2 ** g - 1)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n \r\nget_int = lambda: int(input().rstrip())\r\nget_arr = lambda: [int(w) for w in input().split()]\r\nget_str = lambda: input().rstrip()\r\n\r\nt = get_int()\r\nfor _ in range(t):\r\n n = get_int()\r\n \r\n print(2**n - 1)"}, {"source_code": "def play_off(n):\r\n h=2**n\r\n return h-1\r\n\r\nt=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print(play_off(n))"}, {"source_code": "for _ in range(int(input())):\r\n print(2**int(input()) - 1)"}, {"source_code": "t = int(input())\r\n\r\nfor _ in range(t):\r\n n = int(input())\r\n print(2 ** n - 1)\r\n "}, {"source_code": "s = int(input())\nfor _ in range(s):\n n = int(input())\n print(2 ** n - 1)"}, {"source_code": "import sys\nfrom math import factorial\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\ndef inp():\n return(int(input()))\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(s[:len(s) - 1])\ndef invr():\n return(map(int,input().split()))\ndef insr2():\n s = input()\n return(s.split(\" \"))\n\nq = inp()\nfor _ in range(q):\n def solve():\n n = inp()\n print(2**n-1)\n\n return\n solve()"}, {"source_code": "# # n= int(input())\r\n# # s=[]\r\n# #\r\n# # for i in range(0,n):\r\n# # s.append(int(input()))\r\n# #\r\n# # for p in s:\r\n# #\r\n# #\r\n#\r\n#\r\n# x = int(input())\r\n# l = []\r\n# n = pow(2, x)\r\n# for j in range(1, n + 1):\r\n# l.append(j)\r\n#\r\n# while (len(l) != 1):\r\n# i = 0\r\n#\r\n# while (i < len(l) - 1):\r\n# s = l[i] + l[i + 1]\r\n#\r\n# if (s % 2 == 0):\r\n#\r\n# l.remove(l[i])\r\n#\r\n# else:\r\n# l.remove(l[i + 1])\r\n#\r\n# i = i + 1\r\n# print(l[0])\r\nfor i in range(int(input())):\r\n print(2**int(input())-1)"}], "negative_code": [{"source_code": "for i in range(int(input())):\r\n\ta = int(input())\r\n\tprint((a**2)-1)"}, {"source_code": "t = int(input())\r\nwhile t != 0:\r\n n = int(input())\r\n x = pow(n, 2)\r\n print(x-1)\r\n t -= 1\r\n"}, {"source_code": "n = int(input())\r\nprint(2**n - 1)\r\n"}, {"source_code": "\r\nfrom math import *\r\nfrom collections import *\r\nimport os\r\nfrom io import BytesIO, IOBase\r\nimport sys\r\nfrom bisect import *\r\nfrom heapq import *\r\n \r\nMOD = 1000000007\r\n# sys.setrecursionlimit(10**6)\r\n\r\n# Code by Big Dick Daddy Dick\r\n\r\ndef subinp():\r\n sys.stdin = open(\"input.txt\", \"r\")\r\n sys.stdout = open(\"op1.txt\", \"w\")\r\n\r\ndef binpow(a, b, m):\r\n a %= m\r\n x = 1\r\n while b > 0:\r\n if b & 1:\r\n x = x * a % m\r\n a = a * a % m\r\n b >>= 1\r\n return x\r\n\r\n \r\n \r\ndef binser(arr, l, r, x):\r\n while l < r:\r\n mid = l + (r - l) // 2\r\n # print(l, r, mid)\r\n \r\n if arr[mid] == x:\r\n return mid\r\n \r\n elif arr[mid] < x:\r\n l = mid + 1\r\n \r\n else:\r\n r = mid - 1\r\n \r\n return mid\r\n \r\ndef lcm(a, b):\r\n return (a * b) // gcd(a, b)\r\n \r\ndef sod(n):\r\n l = list(str(n))\r\n s = 0\r\n for i in l:\r\n s += int(i)\r\n return s\r\n \r\n \r\ndef prime_factors(num): \r\n l =[]\r\n if num % 2:\r\n l.append(2)\r\n while num % 2 == 0: \r\n num = num / 2 \r\n \r\n for i in range(3, int(sqrt(num)) + 1, 2): \r\n if not num % i:\r\n l.append(i)\r\n while num % i == 0: \r\n num = num / i\r\n if num > 2:\r\n l.append(num)\r\n return l\r\n \r\n \r\ndef factmod(n, p):\r\n \r\n f = defaultdict(int)\r\n f[0] = 1\r\n for i in range(1, n + 1):\r\n f[i] = (f[i-1] * i) % MOD\r\n \r\n \"\"\"\r\n res = 1\r\n while (n > 1):\r\n if (n//p) % 2:\r\n res = p - res\r\n \r\n res = res * f[n%p] % p\r\n n //= p\r\n \"\"\"\r\n \r\n return f\r\n \r\n \r\n \r\ndef largestPower(n, p):\r\n \r\n # Initialize result\r\n x = 0\r\n \r\n # Calculate x = n/p + n/(p^2) + n/(p^3) + ....\r\n while (n):\r\n n //= p\r\n x += n\r\n return x\r\n \r\ndef modFact(n, p) :\r\n \r\n if (n >= p) :\r\n return 0\r\n \r\n res = 1\r\n isPrime = [1] * (n + 1)\r\n i = 2\r\n while(i * i <= n):\r\n if (isPrime[i]):\r\n for j in range(2 * i, n, i) :\r\n isPrime[j] = 0\r\n i += 1\r\n \r\n # Consider all primes found by Sieve\r\n for i in range(2, n):\r\n if (isPrime[i]) :\r\n \r\n k = largestPower(n, i)\r\n \r\n # Multiply result with (i^k) % p\r\n res = (res * binpow(i, k, p)) % p\r\n \r\n return res\r\n \r\ndef drec(x, y):\r\n if y == x + 1:\r\n return 'R'\r\n if y == x - 1:\r\n return 'L'\r\n if x < y:\r\n return 'D'\r\n return 'U'\r\n \r\ndef cellhash(x, y):\r\n return (x - 1) * m + y\r\n \r\n \r\ndef bins(l, x, n):\r\n i = bisect_left(l, x)\r\n if i < n:\r\n return i\r\n if i:\r\n return (i-1)\r\n else:\r\n return n\r\n\r\ndef cond(l):\r\n for i in range(len(l) - 1):\r\n if l[i] == str(int(l[i + 1]) - 1):\r\n return False\r\n return True\r\n\r\ndef isvowel(s):\r\n if s in list(\"aeiou\"):\r\n return 1\r\n return 0\r\n\r\ndef countOdd(L, R):\r\n \r\n N = (R - L) // 2\r\n \r\n # if either R or L is odd\r\n if (R % 2 != 0 or L % 2 != 0):\r\n N += 1\r\n \r\n return N\r\n\r\ndef tst(A, B, C):\r\n return ((A|B) & (B|C) & (C|A))\r\n\r\ndef palcheck(n, s):\r\n i, j = 0, n - 1\r\n while i <= j:\r\n if s[i] == s[j]:\r\n return False\r\n i += 1\r\n j -= 1\r\n return True\r\n\r\ndef sakurajima(n):\r\n if n < 9:\r\n n = 10\r\n l = [0]\r\n\r\n for i in range(1, n + 1):\r\n if i % 2:\r\n l.append(i)\r\n else:\r\n l.append(2)\r\n\r\n for i in range(3, int(n ** 0.5) + 1, 2):\r\n if l[i] == i:\r\n for j in range(i * i, n + 1, i):\r\n if l[j] == j:\r\n l[j] = i\r\n return l\r\n\r\n\r\n\r\n\r\ndef getfact(x):\r\n ret = []\r\n d = defaultdict(int)\r\n while x != 1:\r\n ret.append(spf[x] ** (d[spf[x]] + 1))\r\n d[spf[x]] += 1\r\n x = x // spf[x]\r\n \r\n return ret\r\n\r\ndef prchck(n):\r\n l = [1] * (n + 1)\r\n l[1] = 0\r\n for i in range(2, n + 1):\r\n for j in range(2, int(sqrt(n)) + 1):\r\n if j % i == 0:\r\n l[j] = 1\r\n return l\r\n\r\ndef ispal(s, n):\r\n for i in range(n // 2):\r\n if s[i] != s[n - i - 1]:\r\n return False\r\n return True\r\n\r\n\r\ndef bfs(src, dest, ajl, vis):\r\n q = deque([src])\r\n vis[src] = True\r\n \r\n while q:\r\n i = q.popleft()\r\n if i == dest:\r\n return True\r\n for j in ajl[i]:\r\n if not vis[j]:\r\n vis[j] = True\r\n q.append(j)\r\n return False\r\n\r\n\r\ndef sieve(n):\r\n if n < 9:\r\n nn = 10\r\n l = [1] * (n + 1)\r\n for i in range(2, int(n ** 0.5) + 1):\r\n if l[i]:\r\n for j in range(i ** 2, n + 1, i):\r\n if j % i == 0:\r\n l[j] = 0\r\n l[1] = 0\r\n return l\r\n\r\nclass DisjSet:\r\n def __init__(self, n):\r\n self.size = [1] * n\r\n self.parent = [i for i in range(n)]\r\n \r\n \r\n def find(self, x):\r\n if (self.parent[x] != x):\r\n self.parent[x] = self.find(self.parent[x])\r\n \r\n return self.parent[x]\r\n \r\n \r\n def union(self, x, y):\r\n \r\n xset = self.find(x)\r\n yset = self.find(y)\r\n \r\n if xset == yset:\r\n return\r\n \r\n if self.size[xset] < self.size[yset]:\r\n self.parent[xset] = yset\r\n self.size[yset] += self.size[xset]\r\n \r\n else:\r\n self.parent[yset] = xset\r\n self.size[xset] += self.size[yset]\r\n\r\ndef dfs(i, ajl, vis, l, x):\r\n vis[i] = True\r\n l[i] = x\r\n\r\n for j in ajl[i]:\r\n if not vis[j]:\r\n dfs(j, ajl, vis, l, x)\r\n\r\n# spf = sakurajima(10 ** 5 + 1)\r\ndef checkpo3(N):\r\n while N > 0:\r\n\r\n if N % 3 == 2:\r\n return False\r\n N //= 3\r\n\r\n return True\r\n\r\ndef sumofdig(n):\r\n ans = 0\r\n s = str(n)\r\n for i in s:\r\n ans += int(i)\r\n return ans \r\n\r\n\r\ndef panda(n, a, b):\r\n x, y, z, w = float(inf), float(inf), float(inf), float(inf)\r\n\r\n for i in a:\r\n x = min(x, abs(b[0] - i))\r\n y = min(y, abs(b[-1] - i))\r\n\r\n for i in b:\r\n z = min(z, abs(a[0] - i))\r\n w = min(w, abs(a[-1] - i))\r\n\r\n ans = x + y + z + w\r\n\r\n ans = min(ans, abs(b[0] - a[0]) + abs(b[-1] - a[-1]), abs(a[-1] - b[0]) + abs(b[-1] - a[0]), x + z + abs(b[-1] - a[-1]), x + w + abs(a[0] - b[-1]), y + z + abs(a[-1] - b[0]), y + w + abs(a[0] - b[0]))\r\n\r\n return ans\r\n \r\n\r\n# Code by Big Dick Daddy Dick\r\n\r\n# n = int(input())\r\n# n, k = map(int, input().split())\r\n# s = input()\r\n# l = list(map(int, input().split()))\r\n\r\n\r\n\r\n# input = sys.stdin.readline\r\nt = 1\r\nt = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n print(2 ** (n - 1))\r\n # print(\"Case #\" + str(_ + 1) + \": \" + str(ans))\r\n"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n % 2 == 0:\r\n print(2**n)\r\n else:\r\n print(2**n-1)"}, {"source_code": "import math\r\n\r\nt=int(input())\r\nwhile(t > 0):\r\n t-=1\r\n n = int(input())\r\n z = math.pow(2,n) \r\n print(z-1)"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n x = 2^n-1\r\nprint(x)\r\n \r\n "}, {"source_code": "t = int(input())\r\n\r\nN = []\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n N.append(n-1)\r\n \r\nfor n in N:\r\n print(n)"}, {"source_code": "testcases = int(input())\r\n\r\nfor a in range(testcases) :\r\n winner = []\r\n contestant = []\r\n semiContestant = []\r\n participant = pow(2,int(input()))\r\n \r\n if participant == 1 :\r\n print(\"1\")\r\n break\r\n \r\n for b in range(1,participant):\r\n contestant.append(b)\r\n \r\n for c in range(1,participant) :\r\n if c % 2 != 0 :\r\n semiContestant.append(c)\r\n \r\n print(contestant)\r\n \r\n while True :\r\n if len(semiContestant) == 1:\r\n break\r\n first = semiContestant.pop(0)\r\n second = semiContestant.pop(0)\r\n \r\n if (first + second) % 2 == 0 :\r\n semiContestant.append(second)\r\n else :\r\n semiContestant.append(first)\r\n print(semiContestant.pop())"}, {"source_code": "for t in range(int(input())):\r\n n = int(input())\r\n if(n > 19):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n for i in range(n):\r\n print(3**i, end=\" \")"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n a=[]\r\n for i in range(1, 2**n+1):\r\n a.append(i)\r\n b=[]\r\n print(a)\r\n while len(a)>1:\r\n for i in range(0,len(a)-1,2):\r\n if (a[i]+a[i+1])%2==0:\r\n b.append(a[i+1])\r\n else:\r\n b.append(a[i])\r\n a=b\r\n b=[]\r\n print(a[0])"}, {"source_code": "n = int(input())\nfor whj in range(n):\n a = int(input())\n b = 2**a\n L = [i for i in range(1,1+b)]\n L_help = [i for i in range(1,1+b)]\n for i in range(a):\n for i in range(len(L)//2):\n if (L[i] + L[i+1]) % 2 == 1:\n L_help.remove(max(L[i],L[i+1]))\n else:\n L_help.remove(min(L[i],L[i+1]))\n print(L_help[i])\n L = L_help\n print(L[0])\n# Sat Apr 09 2022 08:19:20 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "def solve(n):\r\n for i in range(2 ** n, 1, -1):\r\n if i & 1 == 1:\r\n return i\r\nT = int(input())\r\nfor _ in range(T):\r\n n = int(input())\r\n print(solve(n))"}, {"source_code": "n=int(input())\nprint(n**2-1)\n# Wed Apr 20 2022 06:23:32 GMT+0000 (Coordinated Universal Time)\n\n# Wed Apr 20 2022 06:23:38 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "n = int(input())\r\nprint(2**n - 1)"}, {"source_code": "for _ in range(int(input())):\r\n\tn = int(input())\r\n\tif(n == 2):\r\n\t\tprint(1)\r\n\telse:\r\n\t\tprint(2**n - 1)\r\n\t\t\t\r\n\t\t\t"}, {"source_code": "for i in range(int(input())):\r\n n = int(input())\r\n if n%2 == 0:\r\n print(n-1)\r\n else:\r\n print(n)"}, {"source_code": "n=int(input())\nprint(n**2-1)\n# Wed Apr 20 2022 06:23:32 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "import math\r\n\r\nt=int(input())\r\nwhile(t > 0):\r\n t-=1\r\n n = int(input())\r\n z = math.pow(2,n) \r\n print(z-1)"}, {"source_code": "test_cases = int(input())\n\nfor i in range(test_cases):\n n = int(input())\n passed_first_stage = list(range(1, n ** 2, 2))\n\n for j in range(n - 1):\n passed_first_stage = list(set(passed_first_stage))\n for k in range(len(passed_first_stage) - 1):\n if k % 2 == 0:\n if (passed_first_stage[k] + passed_first_stage[k + 1]) % 2 == 0:\n passed_first_stage[k] = passed_first_stage[k + 1]\n else:\n passed_first_stage[k + 1] = passed_first_stage[k]\n\n if len(passed_first_stage) == 0:\n print(1)\n else:\n print(passed_first_stage[0])\n\n\n\n\n\n\n\n"}, {"source_code": "a= int(input())\r\nfor i in range (0,a):\r\n b= int(input())\r\n c= 2**b\r\n print(c)"}, {"source_code": "for t in range(int(input())):\r\n n = int(input())\r\n if(n > 19):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n for i in range(n):\r\n print(3**i, end=\" \")\r\n print()"}, {"source_code": "import os\r\nfrom io import BytesIO, IOBase\r\nimport sys\r\nimport math\r\ndef split(word):\r\n return [char for char in word]\r\ndef ncr(n, r, p):\r\n\t# initialize numerator\r\n\t# and denominator\r\n\tnum = den = 1\r\n\tfor i in range(r):\r\n\t\tnum = (num * (n - i)) % p\r\n\t\tden = (den * (i + 1)) % p\r\n\treturn (num * pow(den,p - 2, p)) % p \r\ndef main():\r\n for i in range(int(input())):\r\n n=int(input())\r\n print(n**2-1)\r\n# region fastio\r\nBUFSIZE = 8192\r\n \r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n \r\nif __name__ == \"__main__\":\r\n main() "}, {"source_code": "import os\r\nfrom io import BytesIO, IOBase\r\nimport sys\r\nimport math\r\ndef split(word):\r\n return [char for char in word]\r\ndef ncr(n, r, p):\r\n\t# initialize numerator\r\n\t# and denominator\r\n\tnum = den = 1\r\n\tfor i in range(r):\r\n\t\tnum = (num * (n - i)) % p\r\n\t\tden = (den * (i + 1)) % p\r\n\treturn (num * pow(den,p - 2, p)) % p \r\ndef main():\r\n for i in range(int(input())):\r\n n=int(input())\r\n print(n**2-1)\r\n# region fastio\r\nBUFSIZE = 8192\r\n \r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n \r\nif __name__ == \"__main__\":\r\n main() "}, {"source_code": "print(2 ** int(input()) - 1)"}, {"source_code": "n=int(input())\r\nfor _ in range(n):\r\n x=int(input())\r\n print(x-1)"}, {"source_code": "x = int(input())\r\nif x==1:\r\n\tprint (1)\r\nelse:\r\n\tprint(2**x-1)"}, {"source_code": "import itertools\r\nimport heapq\r\nimport collections\r\nimport math\r\nimport sys\r\n\r\n\r\ninput = sys.stdin.readline\r\n\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return (int(input()))\r\n\r\n\r\ndef inlt():\r\n return (list(map(int, input().split())))\r\n\r\n\r\ndef insr():\r\n s = input()\r\n return (list(s[:len(s) - 1]))\r\n\r\n\r\ndef invr():\r\n return (map(int, input().split()))\r\n\r\n\r\ndef inis():\r\n return (input().split())\r\n\r\n\r\ndef stlt():\r\n return list(map(str, input().split()))\r\n\r\n\r\n###################################################\r\n\r\n# # Code to find top 3 elements and their counts\r\n# # using most_common\r\n#\r\n# arr = [1, 3, 4, 1, 2, 1, 1, 3, 4, 3, 5, 1, 2, 5, 3, 4, 5]\r\n# counter = Counter(arr)\r\n# top_three = counter.most_common()\r\n# print(sorted(top_three))\r\n#\r\n#\r\n# # Python code to find 3 largest and 4 smallest\r\n# # elements of a list.\r\n#\r\n# grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90, 110]\r\n# print(heapq.nlargest(3, grades))\r\n# print(heapq.nsmallest(4, grades))\r\n\r\n########################################################################\r\n#-----------------------------Functions--------------------------------#\r\n########################################################################\r\n\r\ndef SieveOfEratosthenes(n):\r\n prime = [True for i in range(n + 1)]\r\n p = 2\r\n l = []\r\n while (p * p <= n):\r\n if (prime[p] == True):\r\n for i in range(p * p, n + 1, p):\r\n prime[i] = False\r\n p += 1\r\n for p in range(2, n + 1):\r\n if prime[p]:\r\n l.append(p)\r\n return l\r\n\r\n\r\ndef isPrime(n):\r\n prime_flag = 0\r\n\r\n if n > 1:\r\n for i in range(2, int(math.sqrt(n)) + 1):\r\n if n % i == 0:\r\n prime_flag = 1\r\n break\r\n if prime_flag == 0:\r\n return True\r\n else:\r\n return False\r\n else:\r\n return False\r\n\r\n\r\ndef gcdofarray(a):\r\n x = 0\r\n for p in a:\r\n x = math.gcd(x, p)\r\n return x\r\n\r\n\r\n# method to print the divisors\r\ndef printDivisors(n):\r\n # Note that this loop runs till square root\r\n i = 1\r\n ans = []\r\n while i <= math.sqrt(n):\r\n\r\n if (n % i == 0):\r\n\r\n # If divisors are equal, print only one\r\n if (n / i == i):\r\n ans.append(i)\r\n else:\r\n # Otherwise print both\r\n ans.append(i)\r\n ans.append(n // i)\r\n i = i + 1\r\n ans.sort()\r\n return ans\r\n\r\n\r\ndef CountDivisors(n):\r\n # Note that this loop runs till square root\r\n i = 1\r\n ans = []\r\n while i <= math.sqrt(n):\r\n\r\n if (n % i == 0):\r\n\r\n # If divisors are equal, print only one\r\n if (n / i == i):\r\n ans.append(i)\r\n else:\r\n # Otherwise print both\r\n ans.append(i)\r\n ans.append(n // i)\r\n i = i + 1\r\n ans.sort()\r\n return len(ans)\r\n\r\n\r\ndef binaryToDecimal(n):\r\n return int(n, 2)\r\n\r\n\r\ndef countTriplets(a, n):\r\n s = set()\r\n for i in range(n):\r\n s.add(a[i])\r\n count = 0\r\n for i in range(n):\r\n for j in range(i + 1, n, 1):\r\n xr = a[i] ^ a[j]\r\n if xr in s and xr != a[i] and xr != a[j]:\r\n count += 1\r\n return int(count // 3)\r\n\r\n\r\ndef generate_twin_prime(n):\r\n a = 0\r\n for i in range(1, n + 1):\r\n j = i + 2\r\n if isPrime(i) and isPrime(j):\r\n if 2 ^ (i ^ j) == 0:\r\n a += 1\r\n return a\r\n\r\n\r\ndef smallestDivisor(n):\r\n if (n % 2 == 0):\r\n return 2\r\n i = 3\r\n while (i * i <= n):\r\n if (n % i == 0):\r\n return i\r\n i += 2\r\n return n\r\n\r\n\r\ndef countOdd(L, R):\r\n N = (R - L) // 2\r\n\r\n # if either R or L is odd\r\n if (R % 2 != 0 or L % 2 != 0):\r\n N += 1\r\n\r\n return N\r\n\r\n\r\ndef isPalindrome(s):\r\n return s == s[::-1]\r\n\r\n\r\ndef sufsum(test_list):\r\n test_list.reverse()\r\n res = [sum(test_list[: i + 1]) for i in range(len(test_list))]\r\n return res\r\n\r\n\r\ndef prsum(lst):\r\n return (list(itertools.accumulate(lst)))\r\n\r\n\r\ndef badachotabadachota(nums):\r\n nums.sort()\r\n i = 0\r\n j = len(nums) - 1\r\n ans = []\r\n cc = 0\r\n while len(ans) != len(nums):\r\n if cc % 2 == 0:\r\n ans.append(nums[j])\r\n j -= 1\r\n else:\r\n ans.append(nums[i])\r\n i += 1\r\n cc += 1\r\n return ans\r\n\r\n \r\n# ########################################################################\r\n# #-----------------------------Code Here--------------------------------#\r\n# ########################################################################\r\n\r\nfor _ in range(inp()):\r\n # n = inp()\r\n # u = inlt()\r\n # s = inlt()\r\n # d = {}\r\n # ans = []\r\n # for i in range(n):\r\n # if u[i] in d:\r\n # d[u[i]].append(s[i])\r\n # else:\r\n # d[u[i]] = []\r\n # d[u[i]].append(s[i])\r\n # print(d)\r\n n = inp()\r\n if n == 1:\r\n print(1)\r\n else:\r\n print(n ** 2 - 1)"}, {"source_code": "for i in range(int(input())):\r\n n=int(input())\r\n if(n%2!=0):\r\n print(2**n - 1)\r\n else:\r\n print(n-1)"}, {"source_code": "import os\r\nfrom io import BytesIO, IOBase\r\nimport sys\r\nimport math\r\ndef split(word):\r\n return [char for char in word]\r\ndef ncr(n, r, p):\r\n\t# initialize numerator\r\n\t# and denominator\r\n\tnum = den = 1\r\n\tfor i in range(r):\r\n\t\tnum = (num * (n - i)) % p\r\n\t\tden = (den * (i + 1)) % p\r\n\treturn (num * pow(den,p - 2, p)) % p \r\ndef main():\r\n for i in range(int(input())):\r\n n=int(input())\r\n print(n**2-1)\r\n# region fastio\r\nBUFSIZE = 8192\r\n \r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n \r\nif __name__ == \"__main__\":\r\n main() "}, {"source_code": "d = {1:1,2:1,3:7,4:15,5:31,6:63,7:127,8:255,9:511,10:1023,11:2047,12:4095,13:8191,14:16383,15:32767,16:65535,17:131071,18:262143,19:524287,20:1048575,21:2097151,22:4194303,23:8388607,24:16777215,25:33554431,26:67108863,27:134217727,28:268435455,29:536870911,30:1073741823}\r\nfor _ in range(int(input())):\r\n print(d[int(input())])"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print((n**2)-1)"}, {"source_code": "s = int(input())\nfor _ in range(s):\n n = int(input())\n print(n ** 2 - 1)"}, {"source_code": "t = int(input())\r\n\r\nN = []\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n N.append(n-1)\r\n \r\nfor n in N:\r\n print(n)"}, {"source_code": "for _ in range(int(input())):\r\n\tn = int(input())\r\n\tif 3**(n-1) > 10**9:\r\n\t\tprint(\"NO\")\r\n\telse:\r\n\t\tprint(\"YES\")\r\n\t\tprint(*[3**x for x in range(n)])"}, {"source_code": "# function uses recursion to compute winner athlete depending on conditions\r\ndef game (test) :\r\n length = len(test)\r\n if length == 1 :\r\n print(f\"{test[0]}\") #printing the winner athlete\r\n return 0\r\n j = 1\r\n while j <= length/2 :\r\n i = j - 1\r\n if (test[i] + test[j]) % 2 == 0 :\r\n if test[i] >= test[j] :\r\n del(test[j])\r\n else :\r\n del(test[i])\r\n elif test[i] >= test[j] :\r\n del(test[i])\r\n else :\r\n del(test[j])\r\n j += 1 \r\n return game (test)\r\nathlete = int(input()) # promping the number of stages\r\nmy_list = []\r\nfor i in range(1,(2**athlete+1),1) :\r\n my_list.append(i)\r\ngame(my_list)\r\n\r\n\r\n "}, {"source_code": "d = {1:1,2:1,3:7,4:15,5:31,6:63,7:127,8:255,9:511,10:1023,11:2047,12:4095,13:8191,14:16383,15:32767,16:65535,17:131071,18:262143,19:524287,20:1048575,21:2097151,22:4194303,23:8388607,24:16777215,25:33554431,26:67108863,27:134217727,28:268435455,29:536870911,30:1073741823}\r\nfor _ in range(int(input())):\r\n print(d[int(input())])"}, {"source_code": "print('7\\n1')"}, {"source_code": "n=int(input())\r\nprint(2**n-1)"}, {"source_code": "import math\r\nt=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n x=math.pow(2,n)\r\n ans=x-1\r\n print(ans)"}, {"source_code": "# SHRi GANESHA author: Kunal Verma #\r\nimport os\r\nimport sys\r\nfrom bisect import bisect_left\r\nfrom collections import deque\r\nfrom heapq import heapify, heappush, heappop\r\nfrom io import BytesIO, IOBase\r\nfrom math import inf, gcd\r\n\r\n\r\n\r\ndef lcm(a, b):\r\n return (a * b) // gcd(a, b)\r\n\r\n'''\r\n mod = 10 ** 9 + 7\r\n fac = [1]\r\n for i in range(1, 2 * 10 ** 5 + 1):\r\n fac.append((fac[-1] * i) % mod)\r\n fac_in = [pow(fac[-1], mod - 2, mod)]\r\n for i in range(2 * 10 ** 5, 0, -1):\r\n fac_in.append((fac_in[-1] * i) % mod)\r\n fac_in.reverse()\r\n def comb(a, b):\r\n if a < b:\r\n return 0\r\n return (fac[a] * fac_in[b] * fac_in[a - b]) % mod\r\n'''\r\n# MAXN = 10000004\r\n# spf = [0 for i in range(MAXN)]\r\n# adj = [[] for i in range(MAXN)]\r\ndef sieve():\r\n global spf, adj, MAXN\r\n spf[1] = 1\r\n for i in range(2, MAXN):\r\n spf[i] = i\r\n\r\n for i in range(2, MAXN):\r\n if i * i > MAXN:\r\n break\r\n if (spf[i] == i):\r\n for j in range(i * i, MAXN, i):\r\n if (spf[j] == j):\r\n spf[j] = i\r\ndef getdistinctFactorization(n):\r\n global adj, spf, MAXN\r\n for i in range(1, n + 1):\r\n index = 1\r\n x = i\r\n if (x != 1):\r\n adj[i].append(spf[x])\r\n x = x // spf[x]\r\n while (x != 1):\r\n if (adj[i][index - 1] != spf[x]):\r\n adj[i].append(spf[x])\r\n index += 1\r\n x = x // spf[x]\r\ndef printDivisors(n):\r\n i = 2\r\n z = [1, n]\r\n while i <= sqrt(n):\r\n if (n % i == 0):\r\n if (n / i == i):\r\n z.append(i)\r\n else:\r\n z.append(i)\r\n z.append(n // i)\r\n i = i + 1\r\n return z\r\ndef create(n, x, f):\r\n pq = len(bin(n)[2:])\r\n if f == 0:\r\n tt = min\r\n else:\r\n tt = max\r\n dp = [[inf] * n for _ in range(pq)]\r\n dp[0] = x\r\n for i in range(1, pq):\r\n for j in range(n - (1 << i) + 1):\r\n dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << (i - 1))])\r\n return dp\r\ndef enquiry(l, r, dp, f):\r\n if l > r:\r\n return inf if not f else -inf\r\n if f == 1:\r\n tt = max\r\n else:\r\n tt = min\r\n pq1 = len(bin(r - l + 1)[2:]) - 1\r\n return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])\r\ndef SieveOfEratosthenes(n):\r\n prime = [True for i in range(n + 1)]\r\n p = 2\r\n while (p * p <= n):\r\n if (prime[p] == True):\r\n for i in range(p * p, n + 1, p):\r\n prime[i] = False\r\n p += 1\r\n x = []\r\n for i in range(2, n + 1):\r\n if prime[i]:\r\n x.append(i)\r\n return x\r\n\r\n\r\n\r\ndef main():\r\n for _ in range(int(input())):\r\n\r\n n=int(input())\r\n n=2**n\r\n print(n-(n%2)^1)\r\n\r\n\r\n\r\n# Fast IO Region\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n if n==2:\r\n print(1)\r\n else:\r\n print((2**n)-1)"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n x = 2^n-1\r\n print(x)\r\n \r\n "}, {"source_code": "#----------------------------IMPORTING LIBRARIES----------------------------#\r\nimport gc\r\nimport math\r\nfrom math import log2\r\nimport heapq\r\nfrom math import floor, ceil\r\nfrom collections import deque\r\nfrom posixpath import curdir\r\nfrom re import L\r\nimport sys\r\nfrom collections import Counter\r\n#----------------------------LAMBDAS AND DEFAULT----------------------------#\r\nI = lambda:list(map(int,input().split()))\r\nMAP = lambda:map(int, input().split())\r\ninput = sys.stdin.readline\r\nsys.setrecursionlimit(10000)\r\n\r\nMOD = 998244353\r\n#-----------------------------STANDARD FUNCTIONS----------------------------#\r\ndef lcm(a, b):\r\n return abs(a*b) // math.gcd(a, b)\r\n\r\ndef gcd(a, b):\r\n if b == 0:\r\n return a\r\n return gcd(b, a%b)\r\n\r\ndef isSubsequence(s, t):\r\n for i in range (0, len(s)): \r\n try:\r\n index = t.index(s[i])\r\n except ValueError: \r\n return False\r\n t = t[index+1:]\r\n return True\r\n\r\ndef bisect_right(a, x):\r\n lo, hi = 0, len(a)\r\n while lo < hi:\r\n mid = lo + (hi - lo) // 2\r\n if a[mid] > x: hi = mid\r\n else: lo = mid + 1\r\n return lo\r\n \r\ndef bisect_left(a, x):\r\n lo, hi = 0, len(a)\r\n while lo < hi:\r\n mid = lo + (hi - lo) // 2\r\n if a[mid] < x: lo = mid + 1\r\n else: hi = mid\r\n return lo\r\n\r\ndef binary_search(nums, target):\r\n left, right = 0, len(nums) - 1\r\n while left <= right:\r\n pivot = left + (right - left) // 2\r\n if nums[pivot] == target:\r\n return pivot\r\n if target < nums[pivot]:\r\n right = pivot - 1\r\n else:\r\n left = pivot + 1\r\n return -1\r\n\r\n#------------------------------HELPER FUNCTION------------------------------#\r\ndef prefixSum(arr):\r\n dp = [arr[0]]\r\n arrLen = len(arr)\r\n for i in range(1, arrLen): dp.append(dp[-1] + arr[i])\r\n return dp\r\n\r\ndef suffixSum(arr):\r\n arrLen = len(arr)\r\n dp = [0] * arrLen\r\n dp[-1] = arr[-1]\r\n for i in range(arrLen-2, -1, -1): dp[i] = dp[i+1] + arr[i]\r\n return dp\r\n\r\ndef fun():\r\n return \r\n\r\nMAX = 10**6 + 2\r\n\r\ndef solve():\r\n N = int(input())\r\n if N == 1:\r\n print(1)\r\n elif N == 2:\r\n print(2)\r\n else:\r\n print(2**N-1)\r\n\r\n \r\n\r\n \r\n\r\n\r\n \r\n#---------------------------------DRIVER CODE--------------------------------#\r\nTC = int(input())\r\n#TC = 1\r\nfor testcases in range(TC):\r\n solve()"}, {"source_code": "# ------------------- fast io --------------------\r\nfrom __future__ import division, print_function\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nimport itertools\r\nif sys.version_info[0] < 3:\r\n input = raw_input\r\n range = xrange\r\n \r\n filter = itertools.ifilter\r\n map = itertools.imap\r\n zip = itertools.izip \r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n \r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nif os.path.exists('input.txt'):\r\n sys.stdin = open('input.txt','r')\r\n sys.stdout = open('output.txt','w')\r\n \r\n \r\n# ----------------- fast io --------------------\r\nfrom math import *\r\nfrom itertools import * # chain,groupby,permutations,combinations\r\nfrom collections import * #deque\r\nfrom bisect import *\r\nfrom heapq import *\r\nfrom random import *\r\n \r\n \r\n\r\n\r\n \r\n\"\"\"\r\n \r\ndef gcd(x, y):\r\n \r\n while y:\r\n x, y = y, x % y\r\n return x\r\n \r\n \r\ndef prod(a, mod=10**9+7):\r\n ans = 1\r\n for each in a:\r\n ans = (ans * each) % mod\r\n return ans\r\n \r\ndef lcm(a, b): return a * b // gcd(a, b)\r\n \r\ndef binary(x, length=16):\r\n y = bin(x)[2:]\r\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\r\n \r\n \r\ndef powerset(s):\r\n n=len(s)\r\n \r\n return chain.from_iterable(combinations(s,r) for r in range(1,n))\r\n \r\ndef binarySearch(arr,x): \r\n l=0\r\n r=len(arr)-1\r\n while l <= r: \r\n \r\n mid = l + (r - l) // 2; \r\n if arr[mid] == x: \r\n return mid \r\n elif arr[mid] < x: \r\n l = mid + 1\r\n else: \r\n r = mid - 1\r\n return -1\r\n \r\ndef prime(n): #array of prime numbers\r\n arr = [1]*(n+1)\r\n arr[0] = arr[1] = 0\r\n p=2\r\n while p*p<=n:\r\n if arr[p]:\r\n for i in range(p * 2, n + 1, p):\r\n arr[i] = 0\r\n p+=1\r\n \r\n \r\n return arr\r\n\r\ndef prime(n):\r\n # Returns a list of primes < n \r\n sieve = [True] * n\r\n for i in range(3,int(n**0.5)+1,2):\r\n if sieve[i]:\r\n sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)\r\n return [2] + [i for i in range(3,n,2) if sieve[i]]\r\n \r\n \r\n \r\n \r\ndef palindrome(string,start,end):\r\n if start==end:\r\n return True\r\n if end==1:\r\n return True\r\n return string[start]==string[end-1] and palindrome(string,start+1,end-1)\r\n \r\ndef binomialCoeff(n, k):\r\n \r\n \r\n C = [0 for i in range(k+1)]\r\n C[0] = 1 \r\n \r\n for i in range(1, n+1):\r\n \r\n \r\n j = min(i, k)\r\n while (j > 0):\r\n C[j] = C[j] + C[j-1]\r\n j -= 1\r\n \r\n return C[k]\r\n\r\n\r\ndef binary_search(array):\r\n\r\n def condition(value) -> bool:\r\n pass\r\n\r\n left, right = min(search_space), max(search_space) # could be [0, n], [1, n] etc. Depends on problem\r\n while left < right:\r\n mid = left + (right - left) // 2\r\n if condition(mid):\r\n right = mid\r\n else:\r\n left = mid + 1\r\n return left\r\n\r\nprime_dict = {'a': 2, 'b': 3, 'c': 5, 'd': 7, 'e': 11, 'f': 13, 'g': 17, 'h': 19, 'i': 23, 'j': 29, 'k': 31, 'l': 37, 'm': 41, 'n': 43, 'o': 47, 'p': 53, 'q': 59, 'r': 61, 's': 67, 't': 71, 'u': 73, 'v': 79, 'w': 83, 'x': 89, 'y': 97, 'z': 101}\r\n\r\n \r\n\"\"\"\r\n \r\n#----# My Functions\r\n\r\ninf = float(\"inf\")\r\nmod = 10**9+7\r\nnoyes = [\"NO\",\"YES\"]\r\nyesno = [\"YES\",\"NO\"]\r\ndef aa(): \r\n return int(input())\r\n\r\ndef bb(): \r\n return list(map(int,input().split()))\r\n\r\ndef cc(): \r\n s = input()\r\n return list(s)\r\n\r\ndef dd(): \r\n return map(int,input().split())\r\n\r\ndef put(i,val):\r\n print(\"Case #\",i,\":\",val)\r\n\r\ndef swap(arr,i,j):\r\n arr[i],arr[j] = arr[j],arr[i]\r\n\r\ndef power(base, exp, mod = mod):\r\n ans = 1\r\n\r\n while exp:\r\n lastbit = exp & 1\r\n if lastbit:\r\n ans = (ans * base)%(mod)\r\n\r\n base=(base*base)%mod\r\n exp>>=1\r\n\r\n return ans%mod\r\n#----#\r\n\r\n\r\n\r\ndef koi_coding_sikha_do():\r\n \r\n n = aa()\r\n if n%2==0:\r\n print(2**n)\r\n else:\r\n print(2**n - 1)\r\n\r\n\r\n\r\n\r\n \r\n\r\n \r\n\r\n\r\n\r\n\r\n \r\n\r\n \r\n\r\n\r\nonlyone = 0 \r\nt=1 if onlyone else int(input())\r\nwhile(t):\r\n \r\n koi_coding_sikha_do()\r\n \r\n t-=1\r\n \r\n\r\n \r\n\"\"\"\r\n__________ __ .__ __ __ _________ \r\n\\______ \\___.__._/ |_| |__ ____ ____ \\ \\ \\ \\ \\_ ___ \\ .__ .__ \r\n | ___< | |\\ __\\ | \\ / _ \\ / \\ \\ \\ \\ \\ / \\ \\/ __| |___ __| |___ \r\n | | \\___ | | | | Y ( <_> ) | \\ / / / / \\ \\____ /__ __/ /__ __/ \r\n |____| / ____| |__| |___| /\\____/|___| / /_/ /_/ \\______ / |__| |__| \r\n \\/ \\/ \\/ \\/ \r\n \r\n \r\nUnke aakhon me aasu aur chahre pe hasi hai......lagta hai unki lulli unki zip me phasi hai\r\n\"\"\"\r\n"}, {"source_code": "for i in range(int(input())):\r\n n=int(input())\r\n res=[x for x in range(1,2**n+1)]\r\n while(len(res)!=1):\r\n x=[]\r\n for i in range(len(res)-1,0,-2):\r\n print(res[i],res[i-1])\r\n if((res[i]+res[i-1])%2==0):\r\n x.append(max(res[i],res[i-1]))\r\n else:\r\n x.append(min(res[i],res[i-1]))\r\n print(res,x)\r\n res=x\r\n print(res[0])"}, {"source_code": "import sys\n\n# Mike change this based on the codeforces problem.\nlinesPerTest = 1\n\ntestArguments = []\n\ni = 0\ntotalLines = 1\n\n# Read all the lines from stdin, write them to testCasesUnformatted.\nwhile i <= totalLines:\n line = sys.stdin.readline().rstrip('\\n')\n if i == 0:\n \ttotalLines = linesPerTest * int(line)\n else:\n testArguments.append(line)\n i += 1\n\n# Group the test arguments into test cases.\ntestCases = []\nfor j in range(0, len(testArguments), linesPerTest):\n\ttestCases.append(testArguments[j:j + linesPerTest])\n\ndef f(testArguments):\n n = int(testArguments[0])\n if n == 1:\n return 1\n else:\n return 2**n / 2 - 1\n\nfor testCase in testCases:\n\tprint(f(testCase))\n\n\n"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n a=[]\r\n for i in range(1, 2**n+1):\r\n a.append(i)\r\n b=[]\r\n print(a)\r\n while len(a)>1:\r\n for i in range(0,len(a)-1,2):\r\n if (a[i]+a[i+1])%2==0:\r\n b.append(a[i+1])\r\n else:\r\n b.append(a[i])\r\n a=b\r\n b=[]\r\n print(a[0])"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n a=[]\r\n for i in range(1, 2**n+1):\r\n a.append(i)\r\n b=[]\r\n print(a)\r\n while len(a)>1:\r\n for i in range(0,len(a)-1,2):\r\n if (a[i]+a[i+1])%2==0:\r\n b.append(a[i+1])\r\n else:\r\n b.append(a[i])\r\n a=b\r\n b=[]\r\n print(a[0])"}, {"source_code": "n = int(input())\nprint(2**n-1)\n# Wed Apr 20 2022 06:23:32 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n % 2 == 0:\r\n print(2**n)\r\n else:\r\n print(2**n-1)"}, {"source_code": "n = int(input())\nfor whj in range(n):\n a = int(input())\n b = 2**a\n L = [i for i in range(1,1+b)]\n L_help = [i for i in range(1,1+b)]\n for i in range(a):\n for i in range(len(L)//2):\n if (L[i] + L[i+1]) % 2 == 1:\n L_help.remove(max(L[i],L[i+1]))\n else:\n L_help.remove(min(L[i],L[i+1]))\n print(L_help[i])\n L = L_help\n print(L[0])\n# Sat Apr 09 2022 08:19:20 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n if n%2==1: print(2**n-1)"}, {"source_code": "t = int(input())\nfor i in range(1,t) :\n x = int(input())\n print(2 ** x - 1)"}, {"source_code": "a= int(input())\r\nfor i in range (0,a):\r\n b= int(input())\r\n c= 2**b\r\n print(c)"}, {"source_code": "t = input()\r\nfor i in (1,t):\r\n n = int(input())\r\n print(2**n-1)"}, {"source_code": "import math\r\nt=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n x=math.pow(2,n)\r\n ans=x-1\r\n print(ans)"}, {"source_code": "t = int(input())\n\nfor i in range(t):\n n = int(input())\n if n % 2 == 0:\n print(n - 1)\n else:\n print(2**n - 1)\n"}, {"source_code": "def race(a):\r\n wn=\"\"\r\n for i in range(1,len(a),2):\r\n if (a[i-1]+a[i])%2==0:\r\n wn+=str(a[i])\r\n wn+=' '\r\n else:\r\n wn+=str(a[i-1])\r\n wn+=' '\r\n wn=wn.split()\r\n nwn=[]\r\n for i in range(len(wn)):\r\n nwn.append(int(wn[i]))\r\n \r\n return nwn\r\n \r\nt=int(input())\r\nn=t**3\r\na=[]\r\nfor i in range(1,n+1):\r\n a.append(i)\r\n \r\nnnl=[]\r\nfor i in range(t):\r\n d=int(input())\r\n nnl.append(d)\r\n \r\n#print(a)\r\nwhile len(a)>1:\r\n a=race(a)\r\nprint(a[0])\r\n\r\n\r\nwhile len(nnl)>1:\r\n nnl=race(nnl)\r\n \r\nprint(nnl[0])\r\n"}, {"source_code": "#----------------------------IMPORTING LIBRARIES----------------------------#\r\nimport gc\r\nimport math\r\nfrom math import log2\r\nimport heapq\r\nfrom math import floor, ceil\r\nfrom collections import deque\r\nfrom posixpath import curdir\r\nfrom re import L\r\nimport sys\r\nfrom collections import Counter\r\n#----------------------------LAMBDAS AND DEFAULT----------------------------#\r\nI = lambda:list(map(int,input().split()))\r\nMAP = lambda:map(int, input().split())\r\ninput = sys.stdin.readline\r\nsys.setrecursionlimit(10000)\r\n\r\nMOD = 998244353\r\n#-----------------------------STANDARD FUNCTIONS----------------------------#\r\ndef lcm(a, b):\r\n return abs(a*b) // math.gcd(a, b)\r\n\r\ndef gcd(a, b):\r\n if b == 0:\r\n return a\r\n return gcd(b, a%b)\r\n\r\ndef isSubsequence(s, t):\r\n for i in range (0, len(s)): \r\n try:\r\n index = t.index(s[i])\r\n except ValueError: \r\n return False\r\n t = t[index+1:]\r\n return True\r\n\r\ndef bisect_right(a, x):\r\n lo, hi = 0, len(a)\r\n while lo < hi:\r\n mid = lo + (hi - lo) // 2\r\n if a[mid] > x: hi = mid\r\n else: lo = mid + 1\r\n return lo\r\n \r\ndef bisect_left(a, x):\r\n lo, hi = 0, len(a)\r\n while lo < hi:\r\n mid = lo + (hi - lo) // 2\r\n if a[mid] < x: lo = mid + 1\r\n else: hi = mid\r\n return lo\r\n\r\ndef binary_search(nums, target):\r\n left, right = 0, len(nums) - 1\r\n while left <= right:\r\n pivot = left + (right - left) // 2\r\n if nums[pivot] == target:\r\n return pivot\r\n if target < nums[pivot]:\r\n right = pivot - 1\r\n else:\r\n left = pivot + 1\r\n return -1\r\n\r\n#------------------------------HELPER FUNCTION------------------------------#\r\ndef prefixSum(arr):\r\n dp = [arr[0]]\r\n arrLen = len(arr)\r\n for i in range(1, arrLen): dp.append(dp[-1] + arr[i])\r\n return dp\r\n\r\ndef suffixSum(arr):\r\n arrLen = len(arr)\r\n dp = [0] * arrLen\r\n dp[-1] = arr[-1]\r\n for i in range(arrLen-2, -1, -1): dp[i] = dp[i+1] + arr[i]\r\n return dp\r\n\r\ndef fun():\r\n return \r\n\r\nMAX = 10**6 + 2\r\n\r\ndef solve():\r\n N = int(input())\r\n if N == 1:\r\n print(1)\r\n elif N == 2:\r\n print(2)\r\n else:\r\n print(2**N-1)\r\n\r\n \r\n\r\n \r\n\r\n\r\n \r\n#---------------------------------DRIVER CODE--------------------------------#\r\nTC = int(input())\r\n#TC = 1\r\nfor testcases in range(TC):\r\n solve()"}, {"source_code": "n = int(input())\nfor i in range(n):\n x = int(input())-1\n print(2 ** x)\n# Wed Apr 20 2022 06:31:57 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "n=int(input())\r\nfor i in range(n):\r\n m=int(input())\r\n if(m%2==0):\r\n print(2**m)\r\n else:\r\n print((2**m)-1)"}, {"source_code": "testcases = int(input())\r\n\r\nfor a in range(testcases) :\r\n winner = []\r\n contestant = []\r\n semiContestant = []\r\n participant = pow(2,int(input()))\r\n \r\nprint(participant-1)"}, {"source_code": "import os\r\nfrom io import BytesIO, IOBase\r\nimport sys\r\nimport math\r\ndef split(word):\r\n return [char for char in word]\r\ndef ncr(n, r, p):\r\n\t# initialize numerator\r\n\t# and denominator\r\n\tnum = den = 1\r\n\tfor i in range(r):\r\n\t\tnum = (num * (n - i)) % p\r\n\t\tden = (den * (i + 1)) % p\r\n\treturn (num * pow(den,p - 2, p)) % p \r\ndef main():\r\n for i in range(int(input())):\r\n n=int(input())\r\n print(n**2-1)\r\n# region fastio\r\nBUFSIZE = 8192\r\n \r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n \r\nif __name__ == \"__main__\":\r\n main() "}, {"source_code": "t = int(input())\r\noutput = 0\r\nfor x in range(t):\r\n n = int(input())\r\n ans = 0\r\n m = 1\r\n for i in range(n):\r\n ans += m\r\n m *= 2\r\nprint(ans)"}, {"source_code": "t = int(input())\r\noutput = 0\r\nfor x in range(t):\r\n n = int(input())\r\n ans = 0\r\n m = 1\r\n for i in range(n):\r\n ans += m\r\n m *= 2\r\nprint(ans)"}, {"source_code": "t = input()\r\nfor i in (1,t):\r\n n = int(input())\r\n print(2**n-1)"}, {"source_code": "from sys import stdin\ninp = [*map(int, stdin.read().strip().splitlines())]\n\nfor i in range(inp[0]):\n if inp[i] == 1:\n print(1)\n else:\n print((2**inp[1:][i])-1)\n"}, {"source_code": "from sys import stdin\ninp = [*map(int, stdin.read().strip().splitlines())]\natl = inp[1:]\n\n\ndef reduce(atl):\n q = []\n if len(atl) == 1:\n return atl[0]\n\n for i in range(0, inp[0], 2):\n q.append(max(atl[i], atl[i+1]) if (atl[i] + atl[i+1]) % 2 == 0\n else min(atl[i], atl[i+1]))\n\n return reduce(q)\n\n\nprint(reduce(atl))\n"}, {"source_code": "testcases = int(input())\r\n\r\nfor a in range(testcases) :\r\n winner = []\r\n contestant = []\r\n semiContestant = []\r\n participant = pow(2,int(input()))\r\n \r\n\r\nif participant == 1 :\r\n print(1)\r\nelse :\r\n print(participant-1) "}, {"source_code": "for _ in range(int(input())):\r\n\tn = int(input())\r\n\tprint(n ** 2 - 1)"}, {"source_code": "from sys import stdin, stdout\r\n\r\nt = int(stdin.readline())\r\n\r\n\"\"\"\r\nrange(1,2**n+1)\r\n\r\n\r\n1,3\r\n5,7 ==> 3,7 => 7,15 => 15\r\n9,11 11,15 (largest) (largest)\r\n13,[15] (largest) \r\n(largest)\r\n\r\nSolution\r\n2. Max(odds)\r\n\r\n2**4 -1 \r\n\"\"\"\r\n\r\n\r\nfor _ in range(t):\r\n n = int(stdin.readline())\r\n stdout.write(str(2**n-1))"}, {"source_code": "n=int(input())\nprint(n**2-1)\n# Wed Apr 20 2022 06:23:32 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "t = input()\r\nfor i in (1,t):\r\n n = int(input())\r\n print(2**n-1)"}, {"source_code": "\r\nfrom math import *\r\nfrom collections import *\r\nimport os\r\nfrom io import BytesIO, IOBase\r\nimport sys\r\nfrom bisect import *\r\nfrom heapq import *\r\n \r\nMOD = 1000000007\r\n# sys.setrecursionlimit(10**6)\r\n\r\n# Code by Big Dick Daddy Dick\r\n\r\ndef subinp():\r\n sys.stdin = open(\"input.txt\", \"r\")\r\n sys.stdout = open(\"op1.txt\", \"w\")\r\n\r\ndef binpow(a, b, m):\r\n a %= m\r\n x = 1\r\n while b > 0:\r\n if b & 1:\r\n x = x * a % m\r\n a = a * a % m\r\n b >>= 1\r\n return x\r\n\r\n \r\n \r\ndef binser(arr, l, r, x):\r\n while l < r:\r\n mid = l + (r - l) // 2\r\n # print(l, r, mid)\r\n \r\n if arr[mid] == x:\r\n return mid\r\n \r\n elif arr[mid] < x:\r\n l = mid + 1\r\n \r\n else:\r\n r = mid - 1\r\n \r\n return mid\r\n \r\ndef lcm(a, b):\r\n return (a * b) // gcd(a, b)\r\n \r\ndef sod(n):\r\n l = list(str(n))\r\n s = 0\r\n for i in l:\r\n s += int(i)\r\n return s\r\n \r\n \r\ndef prime_factors(num): \r\n l =[]\r\n if num % 2:\r\n l.append(2)\r\n while num % 2 == 0: \r\n num = num / 2 \r\n \r\n for i in range(3, int(sqrt(num)) + 1, 2): \r\n if not num % i:\r\n l.append(i)\r\n while num % i == 0: \r\n num = num / i\r\n if num > 2:\r\n l.append(num)\r\n return l\r\n \r\n \r\ndef factmod(n, p):\r\n \r\n f = defaultdict(int)\r\n f[0] = 1\r\n for i in range(1, n + 1):\r\n f[i] = (f[i-1] * i) % MOD\r\n \r\n \"\"\"\r\n res = 1\r\n while (n > 1):\r\n if (n//p) % 2:\r\n res = p - res\r\n \r\n res = res * f[n%p] % p\r\n n //= p\r\n \"\"\"\r\n \r\n return f\r\n \r\n \r\n \r\ndef largestPower(n, p):\r\n \r\n # Initialize result\r\n x = 0\r\n \r\n # Calculate x = n/p + n/(p^2) + n/(p^3) + ....\r\n while (n):\r\n n //= p\r\n x += n\r\n return x\r\n \r\ndef modFact(n, p) :\r\n \r\n if (n >= p) :\r\n return 0\r\n \r\n res = 1\r\n isPrime = [1] * (n + 1)\r\n i = 2\r\n while(i * i <= n):\r\n if (isPrime[i]):\r\n for j in range(2 * i, n, i) :\r\n isPrime[j] = 0\r\n i += 1\r\n \r\n # Consider all primes found by Sieve\r\n for i in range(2, n):\r\n if (isPrime[i]) :\r\n \r\n k = largestPower(n, i)\r\n \r\n # Multiply result with (i^k) % p\r\n res = (res * binpow(i, k, p)) % p\r\n \r\n return res\r\n \r\ndef drec(x, y):\r\n if y == x + 1:\r\n return 'R'\r\n if y == x - 1:\r\n return 'L'\r\n if x < y:\r\n return 'D'\r\n return 'U'\r\n \r\ndef cellhash(x, y):\r\n return (x - 1) * m + y\r\n \r\n \r\ndef bins(l, x, n):\r\n i = bisect_left(l, x)\r\n if i < n:\r\n return i\r\n if i:\r\n return (i-1)\r\n else:\r\n return n\r\n\r\ndef cond(l):\r\n for i in range(len(l) - 1):\r\n if l[i] == str(int(l[i + 1]) - 1):\r\n return False\r\n return True\r\n\r\ndef isvowel(s):\r\n if s in list(\"aeiou\"):\r\n return 1\r\n return 0\r\n\r\ndef countOdd(L, R):\r\n \r\n N = (R - L) // 2\r\n \r\n # if either R or L is odd\r\n if (R % 2 != 0 or L % 2 != 0):\r\n N += 1\r\n \r\n return N\r\n\r\ndef tst(A, B, C):\r\n return ((A|B) & (B|C) & (C|A))\r\n\r\ndef palcheck(n, s):\r\n i, j = 0, n - 1\r\n while i <= j:\r\n if s[i] == s[j]:\r\n return False\r\n i += 1\r\n j -= 1\r\n return True\r\n\r\ndef sakurajima(n):\r\n if n < 9:\r\n n = 10\r\n l = [0]\r\n\r\n for i in range(1, n + 1):\r\n if i % 2:\r\n l.append(i)\r\n else:\r\n l.append(2)\r\n\r\n for i in range(3, int(n ** 0.5) + 1, 2):\r\n if l[i] == i:\r\n for j in range(i * i, n + 1, i):\r\n if l[j] == j:\r\n l[j] = i\r\n return l\r\n\r\n\r\n\r\n\r\ndef getfact(x):\r\n ret = []\r\n d = defaultdict(int)\r\n while x != 1:\r\n ret.append(spf[x] ** (d[spf[x]] + 1))\r\n d[spf[x]] += 1\r\n x = x // spf[x]\r\n \r\n return ret\r\n\r\ndef prchck(n):\r\n l = [1] * (n + 1)\r\n l[1] = 0\r\n for i in range(2, n + 1):\r\n for j in range(2, int(sqrt(n)) + 1):\r\n if j % i == 0:\r\n l[j] = 1\r\n return l\r\n\r\ndef ispal(s, n):\r\n for i in range(n // 2):\r\n if s[i] != s[n - i - 1]:\r\n return False\r\n return True\r\n\r\n\r\ndef bfs(src, dest, ajl, vis):\r\n q = deque([src])\r\n vis[src] = True\r\n \r\n while q:\r\n i = q.popleft()\r\n if i == dest:\r\n return True\r\n for j in ajl[i]:\r\n if not vis[j]:\r\n vis[j] = True\r\n q.append(j)\r\n return False\r\n\r\n\r\ndef sieve(n):\r\n if n < 9:\r\n nn = 10\r\n l = [1] * (n + 1)\r\n for i in range(2, int(n ** 0.5) + 1):\r\n if l[i]:\r\n for j in range(i ** 2, n + 1, i):\r\n if j % i == 0:\r\n l[j] = 0\r\n l[1] = 0\r\n return l\r\n\r\nclass DisjSet:\r\n def __init__(self, n):\r\n self.size = [1] * n\r\n self.parent = [i for i in range(n)]\r\n \r\n \r\n def find(self, x):\r\n if (self.parent[x] != x):\r\n self.parent[x] = self.find(self.parent[x])\r\n \r\n return self.parent[x]\r\n \r\n \r\n def union(self, x, y):\r\n \r\n xset = self.find(x)\r\n yset = self.find(y)\r\n \r\n if xset == yset:\r\n return\r\n \r\n if self.size[xset] < self.size[yset]:\r\n self.parent[xset] = yset\r\n self.size[yset] += self.size[xset]\r\n \r\n else:\r\n self.parent[yset] = xset\r\n self.size[xset] += self.size[yset]\r\n\r\ndef dfs(i, ajl, vis, l, x):\r\n vis[i] = True\r\n l[i] = x\r\n\r\n for j in ajl[i]:\r\n if not vis[j]:\r\n dfs(j, ajl, vis, l, x)\r\n\r\n# spf = sakurajima(10 ** 5 + 1)\r\ndef checkpo3(N):\r\n while N > 0:\r\n\r\n if N % 3 == 2:\r\n return False\r\n N //= 3\r\n\r\n return True\r\n\r\ndef sumofdig(n):\r\n ans = 0\r\n s = str(n)\r\n for i in s:\r\n ans += int(i)\r\n return ans \r\n\r\n\r\ndef panda(n, a, b):\r\n x, y, z, w = float(inf), float(inf), float(inf), float(inf)\r\n\r\n for i in a:\r\n x = min(x, abs(b[0] - i))\r\n y = min(y, abs(b[-1] - i))\r\n\r\n for i in b:\r\n z = min(z, abs(a[0] - i))\r\n w = min(w, abs(a[-1] - i))\r\n\r\n ans = x + y + z + w\r\n\r\n ans = min(ans, abs(b[0] - a[0]) + abs(b[-1] - a[-1]), abs(a[-1] - b[0]) + abs(b[-1] - a[0]), x + z + abs(b[-1] - a[-1]), x + w + abs(a[0] - b[-1]), y + z + abs(a[-1] - b[0]), y + w + abs(a[0] - b[0]))\r\n\r\n return ans\r\n \r\n\r\n# Code by Big Dick Daddy Dick\r\n\r\n# n = int(input())\r\n# n, k = map(int, input().split())\r\n# s = input()\r\n# l = list(map(int, input().split()))\r\n\r\n\r\n\r\n# input = sys.stdin.readline\r\nt = 1\r\nt = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n print(2 ** (n - 1))\r\n # print(\"Case #\" + str(_ + 1) + \": \" + str(ans))\r\n"}, {"source_code": "def main():\n n = int(input())\n print(2**n-1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "t = int(input())\r\nwhile t != 0:\r\n n = int(input())\r\n x = pow(n, 2)\r\n print(x-1)\r\n t -= 1\r\n"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print((n**2)-1)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n\r\ndef solve():\r\n n=inp()\r\n print(\"input \",n)\r\n\r\n prev=0\r\n for i in range(2,n+1):\r\n # \r\n first=prev\r\n\r\n second=first+2**(i-1)\r\n s=first+second\r\n if s%2==1:\r\n # odd\r\n prev=first\r\n else:\r\n prev=second\r\n\r\n return prev\r\nprint(solve())"}, {"source_code": "def race(a):\r\n wn=\"\"\r\n for i in range(1,len(a),2):\r\n if (a[i-1]+a[i])%2==0:\r\n wn+=str(a[i])\r\n wn+=' '\r\n else:\r\n wn+=str(a[i-1])\r\n wn+=' '\r\n wn=wn.split()\r\n nwn=[]\r\n for i in range(len(wn)):\r\n nwn.append(int(wn[i]))\r\n \r\n return nwn\r\n \r\nt=int(input())\r\nn=t**3\r\na=[]\r\nfor i in range(1,n+1):\r\n a.append(i)\r\n \r\nnnl=[]\r\nfor i in range(t):\r\n d=int(input())\r\n nnl.append(d)\r\n \r\n#print(a)\r\nwhile len(a)>1:\r\n a=race(a)\r\nprint(a[0])\r\n\r\n\r\nwhile len(nnl)>1:\r\n nnl=race(nnl)\r\n \r\nprint(nnl[0])\r\n"}, {"source_code": "n = int(input())\r\nprint((1 << n) - 1)"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n if n%2==1: print(2**n-1)"}, {"source_code": "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Mar 14 19:30:51 2022\r\n\r\n@author: Ajay Varma\r\n\"\"\"\r\n\r\nfor i in range(int(input())):\r\n x= int(input())\r\n print(2**x)"}, {"source_code": "n=int(input())\nprint(n**2-1)\n# Wed Apr 20 2022 06:23:32 GMT+0000 (Coordinated Universal Time)\n\n# Wed Apr 20 2022 06:23:38 GMT+0000 (Coordinated Universal Time)\n"}, {"source_code": "def play_off(n):\r\n h=2**n\r\n k=2\r\n if n%2==1:\r\n k=1\r\n while k!=0:\r\n h-=1\r\n k-=1\r\n return h\r\n\r\nt=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n print(play_off(n))"}, {"source_code": "import sys;input=sys.stdin.readline\r\n#for single integer inputs\r\ndef inp():\r\n return(int(input()))\r\n#for multiple integer inputs\r\ndef invr():\r\n return(map(int,input().split()))\r\n#for list of integer inputs\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\n#for string inputs\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n\r\n#mod = 1e9 + 7 for regular rounds\r\n#mod = 998244353 for educational rounds\r\ndef solve():\r\n pass\r\n\r\nfor _ in range(int(input())):\r\n solve()"}, {"source_code": "game_nums = int(input())\r\n\r\nfor i in range(game_nums):\r\n g = int(input())\r\n print(g **2 - 1)"}, {"source_code": "#----------------------------IMPORTING LIBRARIES----------------------------#\r\nimport gc\r\nimport math\r\nfrom math import log2\r\nimport heapq\r\nfrom math import floor, ceil\r\nfrom collections import deque\r\nfrom posixpath import curdir\r\nfrom re import L\r\nimport sys\r\nfrom collections import Counter\r\n#----------------------------LAMBDAS AND DEFAULT----------------------------#\r\nI = lambda:list(map(int,input().split()))\r\nMAP = lambda:map(int, input().split())\r\ninput = sys.stdin.readline\r\nsys.setrecursionlimit(10000)\r\n\r\nMOD = 998244353\r\n#-----------------------------STANDARD FUNCTIONS----------------------------#\r\ndef lcm(a, b):\r\n return abs(a*b) // math.gcd(a, b)\r\n\r\ndef gcd(a, b):\r\n if b == 0:\r\n return a\r\n return gcd(b, a%b)\r\n\r\ndef isSubsequence(s, t):\r\n for i in range (0, len(s)): \r\n try:\r\n index = t.index(s[i])\r\n except ValueError: \r\n return False\r\n t = t[index+1:]\r\n return True\r\n\r\ndef bisect_right(a, x):\r\n lo, hi = 0, len(a)\r\n while lo < hi:\r\n mid = lo + (hi - lo) // 2\r\n if a[mid] > x: hi = mid\r\n else: lo = mid + 1\r\n return lo\r\n \r\ndef bisect_left(a, x):\r\n lo, hi = 0, len(a)\r\n while lo < hi:\r\n mid = lo + (hi - lo) // 2\r\n if a[mid] < x: lo = mid + 1\r\n else: hi = mid\r\n return lo\r\n\r\ndef binary_search(nums, target):\r\n left, right = 0, len(nums) - 1\r\n while left <= right:\r\n pivot = left + (right - left) // 2\r\n if nums[pivot] == target:\r\n return pivot\r\n if target < nums[pivot]:\r\n right = pivot - 1\r\n else:\r\n left = pivot + 1\r\n return -1\r\n\r\n#------------------------------HELPER FUNCTION------------------------------#\r\ndef prefixSum(arr):\r\n dp = [arr[0]]\r\n arrLen = len(arr)\r\n for i in range(1, arrLen): dp.append(dp[-1] + arr[i])\r\n return dp\r\n\r\ndef suffixSum(arr):\r\n arrLen = len(arr)\r\n dp = [0] * arrLen\r\n dp[-1] = arr[-1]\r\n for i in range(arrLen-2, -1, -1): dp[i] = dp[i+1] + arr[i]\r\n return dp\r\n\r\ndef fun():\r\n return \r\n\r\nMAX = 10**6 + 2\r\n\r\ndef solve():\r\n N = int(input())\r\n if N == 1:\r\n print(1)\r\n elif N == 2:\r\n print(2)\r\n else:\r\n print(2**N-1)\r\n\r\n \r\n\r\n \r\n\r\n\r\n \r\n#---------------------------------DRIVER CODE--------------------------------#\r\nTC = int(input())\r\n#TC = 1\r\nfor testcases in range(TC):\r\n solve()"}, {"source_code": "n=int(input())\r\nfor i in range(n):\r\n m=int(input())\r\n if(m%2==0):\r\n print(2**m)\r\n else:\r\n print((2**m)-1)"}, {"source_code": "t = int(input())\r\noutput = 0\r\nfor x in range(t):\r\n n = int(input())\r\n ans = 0\r\n m = 1\r\n for i in range(n):\r\n ans += m\r\n m *= 2\r\nprint(ans)"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\nprint(\"7\")\r\nprint(\"1\")"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n a=[]\r\n for i in range(1, n**2+1):\r\n a.append(i)\r\n b=[]\r\n while len(a)>1:\r\n for i in range(0,len(a)-1,2):\r\n if (a[i]+a[i+1])%2==0:\r\n b.append(a[i+1])\r\n else:\r\n b.append(a[i])\r\n a=b\r\n b=[]\r\n print(a[0])"}, {"source_code": "t=int(input())\r\n\r\ndef win(n):\r\n if n==1:\r\n k=1\r\n else:\r\n k=(2*n)-1\r\n \r\n return k\r\n\r\nfor i in range(0,t):\r\n n=int(input())\r\n k=win(n)\r\n print(k)"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n x = 2^n-1\r\n print(x)\r\n \r\n "}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n % 2 == 0:\r\n print(2**(n-1)-1)\r\n else:\r\n print(2**n-1)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n\r\ndef solve(n):\r\n n=inp()\r\n print(\"input \",n)\r\n prev=0\r\n for i in range(2,n+1):\r\n # \r\n first=prev\r\n\r\n second=first+2**(i-1)\r\n s=first+second\r\n if s%2==1:\r\n # odd\r\n print( min(first,second))\r\n return\r\n\r\n print(second)\r\n \r\n return\r\n\r\n"}, {"source_code": "x = int(input())\r\ny= int(input())\r\nfor i in range(x):\r\n print(2**y-1)"}, {"source_code": "from sys import stdin\ninp = [*map(int, stdin.read().strip().splitlines())]\n\nfor i in range(inp[0]):\n if i == 1:\n print(1)\n else:\n print((2**inp[1:][i])-1)\n"}, {"source_code": "t = int(input())\n\nfor i in range(t):\n n = int(input())\n if n % 2 == 0:\n print(n - 1)\n else:\n print(2**n - 1)\n"}, {"source_code": "def main():\r\n\tdef solve(N):\r\n\t\treturn 2**N-1\r\n\twhile True:\r\n\t\ttry:\r\n\t\t\tN = input()\r\n\t\t\tprint(solve(int(N)))\r\n\t\texcept EOFError:\r\n\t\t\tbreak\r\n\t\r\n\t\r\nif __name__ == \"__main__\":\r\n\t# Your code goes here\r\n\tmain()"}], "src_uid": "d5e66e34601cad6d78c3f02898fa09f4"} {"source_code": "f=int(input())\na=input()\na=[int(i) for i in a.split()]\nb=input()\nb=[int(i) for i in b.split()]\nc=[0,0,0,0,0,0]\ncp = [0,0,0,0,0,0]\nans=[]\nfor i in a:\n c[i]+=1\nfor i in b:\n cp[i]+=1\nt=1\n\nfor i in range(len(c)):\n if (cp[i]+c[i])%2==1:\n print(-1)\n t=0\n break\n else:\n ans.append(c[i] - (cp[i]+c[i])//2)\nif t==1:\n pos , neg ,su= 0,0,0,\n for i in range(len(ans)):\n if ans[i]>0:\n pos+=ans[i]\n if ans[i]<0:\n neg+=ans[i]\n su+=ans[i]\n if su<0:print(-neg)\n if su==0:print(pos)\n if su>0:print(pos)\n", "positive_code": [{"source_code": "if __name__ == '__main__':\n n = input()\n a = map(int, raw_input().split(' '))\n b = map(int, raw_input().split(' '))\n\n a_vis = [0, 0, 0, 0, 0, 0]\n b_vis = [0, 0, 0, 0, 0, 0]\n\n for i in range(n):\n a_vis[a[i]] = a_vis[a[i]] + 1\n b_vis[b[i]] = b_vis[b[i]] + 1\n\n ans = 0\n for i in range(6):\n if (a_vis[i] + b_vis[i]) % 2:\n ans = -1\n break\n else:\n x = a_vis[i] -(a_vis[i] + b_vis[i]) / 2\n if x < 0:\n x = 0\n ans = ans + x\n\n print ans"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\na = {1 : 0, 2 : 0, 3 : 0, 4 : 0, 5 : 0}\nb = {1 : 0, 2 : 0, 3 : 0, 4 : 0, 5 : 0}\nszamok = [int(x) for x in sys.stdin.readline().split()]\nfor elem in szamok :\n\ta[elem] += 1\nszamok = [int(x) for x in sys.stdin.readline().split()]\nfor elem in szamok :\n \tb[elem] += 1\ncounter = 0\nfor i in range(1, 6) :\n\tif (a[i] + b[i]) % 2 == 0 :\n\t\tif a[i] > b[i] :\n\t\t\tcounter += (a[i] - b[i]) / 2\n\telse :\n\t\tsys.stdout.write(\"-1\\n\")\n\t\tsys.exit()\nsys.stdout.write(str(counter) + \"\\n\")\n"}, {"source_code": "import sys\nfrom collections import Counter\n\ninput()\na = Counter(map(int, raw_input().split()))\nb = Counter(map(int, raw_input().split()))\ncounter = 0\nfor i in range(1, 6) :\n\tif (a[i] + b[i]) % 2 == 0 :\n\t\tif a[i] > b[i] :\n\t\t\tcounter += (a[i] - b[i]) / 2\n\telse :\n\t\tprint -1\n\t\tsys.exit()\nprint counter\n"}, {"source_code": "import sys\n\nn = int(raw_input())\nA = map(int, raw_input().split(' '))\nB = map(int, raw_input().split(' '))\ns = [0] * 5\na = [0] * 5\nb = [0] * 5\nfor i in range(n):\n\tif A[i] <= 5:\n\t\ts[A[i] - 1] += 1\n\t\ta[A[i] - 1] += 1\n\tif B[i] <= 5:\n\t\ts[B[i] - 1] += 1\n\t\tb[B[i] - 1] += 1\nflag = 1\n\ndiff = 0\nfor i in range(5):\n\tif s[i] % 2 != 0:\n\t\tflag = 0\n\t\tprint(-1)\n\t\tbreak\n\tdiff += abs(a[i] - b[i])\nif flag:\n\tprint(diff / 4)\n"}, {"source_code": "n=int(input())\narra=list(map(int,input().split()))\narrb=list(map(int,input().split()))\nb=0\nfor i in range(1,6):\n if (arra.count(i)+arrb.count(i))%2!=0:\n b=1\n print(-1)\n break\n#print(arra,arrb)\nif b==0:\n used=[]\n count=0\n for i in range(n):\n if (arra[i]) not in arrb:\n used.append(arra[i])\n else:\n arrb.remove(arra[i])\n #print(arra,arrb)\n print(len(used)//2)\n"}, {"source_code": "def fail():\n print(-1)\n exit()\nread = lambda: map(int, input().split())\nn = int(input())\na = sorted(read())\nb = sorted(read())\nfor i in range(1, 6):\n if (a.count(i) + b.count(i)) % 2:\n fail()\ncnt = 0\nwhile 1:\n flag = False\n for i in range(n):\n if a.count(a[i]) > b.count(a[i]):\n for j in range(n):\n if a.count(b[j]) < b.count(b[j]) and a[i] != b[j]:\n a[i], b[j] = b[j], a[i]\n cnt += 1\n break\n if flag: break\n if flag:\n break\n if not flag:\n break\nprint(cnt)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\ns = set(a + b)\nab = a + b\nfor i in s:\n if ab.count(i) % 2 != 0:\n print(-1)\n exit(0)\n\nfor i in a:\n if i in b:\n b.remove(i)\n\nprint(len(b) // 2)\n"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ncnt = [0] * 5\nfor elem in A:\n cnt[elem - 1] += 1\nfor elem in B:\n cnt[elem - 1] += 1\nbad = 0\nfor elem in cnt:\n bad += elem % 2\nif bad != 0:\n print(-1)\nelse:\n cntA = [0] * 5\n cntB = [0] * 5\n for elem in A:\n cntA[elem - 1] += 1\n for elem in B:\n cntB[elem - 1] += 1\n ans = 0\n for i in range(5):\n ans += abs(cntA[i] - cntB[i]) // 2\n print(ans // 2)\n"}, {"source_code": "from collections import Counter\nn = int(input())\na = Counter(list(map(int, input().split())))\nb = Counter(list(map(int, input().split())))\npossible = True\nfor i in range(1, 6):\n if (a[i] + b[i]) % 2:\n possible = False\n break\n\nif not possible:\n print(-1)\nelse:\n ans = 0\n for i in range(1, 6):\n tot = (a[i] + b[i])//2\n if a[i] < tot:\n ans += tot - a[i] \n print(ans) \n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA = [a.count(i) for i in range(1, 6)]\nB = [b.count(i) for i in range(1, 6)]\ncnt = 0\nfor j in range(5):\n if (A[j] + B[j]) % 2 != 0:\n print(-1)\n exit()\n cnt += abs(A[j] - B[j])\nprint(cnt // 4)\n"}, {"source_code": "# 19:39\n# \u041f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432. \u0412\u0445\u043e\u0434 - \u043e\u0446\u0435\u043d\u043a\u0438. \u0412\u044b\u0445\u043e\u0434 - \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0439\nn = int(input())\nclass_A = [int(x) for x in input().split(' ')]\nclass_B = [int(x) for x in input().split(' ')]\ncnt = [0 for x in range(1, 6)]\n\ndef main():\n\tfor mark in class_A:\n\t\tcnt[mark - 1] += 1\n\tfor mark in class_B:\n\t\tcnt[mark - 1] -= 1\n\tfor mark in cnt:\n\t\tif mark % 2 != 0:\n\t\t\treturn -1\n\tc = 0\n\tfor mark in cnt:\n\t\tc += abs(mark)\n\treturn c // 4\n\nprint(main())\n"}, {"source_code": "##n = int(input())\n##a = list(map(int, input().split()))\n##print(' '.join(map(str, res)))\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nha = [0 for i in range(5)]\nhb = [0 for i in range(5)]\nfor i in range(n):\n ha[a[i]-1] += 1\n hb[b[i]-1] += 1\n \nres = 0\nfor i in range(5):\n if abs(ha[i]-hb[i])%2 != 0 and ha[i] != hb[i]:\n print('-1')\n exit(0)\n res += abs(ha[i]-hb[i])\nres = res//2\nres = res//2\nprint(res)\n \n "}, {"source_code": "\"\"\" Created by Henrikh Kantuni on 2/26/17 \"\"\"\n\nif __name__ == \"__main__\":\n n = int(input())\n al = [int(x) for x in input().split()]\n bl = [int(x) for x in input().split()]\n a = {\n 1: al.count(1),\n 2: al.count(2),\n 3: al.count(3),\n 4: al.count(4),\n 5: al.count(5),\n }\n b = {\n 1: bl.count(1),\n 2: bl.count(2),\n 3: bl.count(3),\n 4: bl.count(4),\n 5: bl.count(5),\n }\n\n possible = True\n for key in a.keys():\n if (a[key] + b[key]) % 2 != 0:\n possible = False\n break\n\n if possible:\n swaps = 0\n for key in a.keys():\n if a[key] > b[key]:\n swaps += (a[key] - b[key]) // 2\n print(swaps)\n else:\n print(-1)\n"}, {"source_code": "# In this template you are not required to write code in main\n\nimport sys\ninf = float(\"inf\")\n\n#sys.setrecursionlimit(1000000)\n#from cmath import sqrt\n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\nfrom math import ceil,floor,log,sqrt,factorial,pow,pi,gcd\n#from bisect import bisect_left,bisect_right\n#import numpy as np\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\ndef all_factors(n):\n \"\"\"returns a sorted list of all distinct factors of n\"\"\"\n small, large = [], []\n for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):\n if not n % i:\n small.append(i)\n large.append(n // i)\n if small[-1] == large[-1]:\n large.pop()\n large.reverse()\n small.extend(large)\n return small\n\ndef get_array(): return list(map(int , sys.stdin.readline().strip().split()))\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef input(): return sys.stdin.readline().strip()\n\n\nn=int(input())\nA=get_array()\nB=get_array()\nmydict_A=dict()\nmydict_B=dict()\nfor i,j in zip(A,B):\n mydict_A[i]=mydict_A.get(i,0)+1\n mydict_B[j]=mydict_B.get(j,0)+1\nscore=[0]*6\nfor i,j in zip(A,B):\n score[i]+=1\n score[j]+=1\nflag=0\nfor i in range(1,6):\n if score[i]&1:\n flag=1\n break\n\nif flag==1:\n print(-1)\n exit(0)\ncontri_A=0;contri_B=0\nfor i in mydict_A:\n contri_A+=max(mydict_A[i]-(score[i]/2),0)\nfor i in mydict_B:\n contri_B+=max(mydict_B[i]-(score[i]/2),0)\n\nif contri_A!=contri_B:\n print(-1)\n exit(0)\nprint(int(contri_A))"}, {"source_code": "n = int(input())\na = list(map(int, input().strip().split()))\nb = list(map(int, input().strip().split()))\ns = 0\nfor i in range(1, 6):\n x = a.count(i)\n y = b.count(i)\n if not (x + y) % 2 == 0: exit(print(-1))\n else: s += abs(x - y) // 2\nprint(s // 2)\n"}, {"source_code": "n = input()\nf = list(map(str, input().split()))\ns = list(map(str, input().split()))\n\nod = abs(f.count('1')-s.count('1'))\nsd = abs(f.count('2')-s.count('2'))\ntd = abs(f.count('3')-s.count('3'))\nfd = abs(f.count('4')-s.count('4'))\nvd = abs(f.count('5')-s.count('5'))\n\nif od%2==0 and sd%2==0 and td%2==0 and fd%2==0 and vd%2==0 :\n\tprint((od+sd+td+fd+vd)//4)\nelse :\n\tprint(-1)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nnuma = [0] * 5\nnumb = [0] * 5\nfor i in a:\n\tnuma[i-1] += 1\nfor i in b:\n\tnumb[i-1] += 1\nfailed = False\nfor i in range(0, 5):\n\tif ((numa[i] + numb[i]) % 2 == 1):\n\t\tfailed = True\n\t\tbreak\nsteps = 0\nif (failed):\n\tprint(-1)\n\nelse:\n\tfor i in range(0, 5):\n\t\tsteps += abs(numa[i] - numb[i])/2\n\tprint (int(steps/2))"}, {"source_code": "import sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\n# region fastio\n \nBUFSIZE = 8192\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# ------------------------------\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = {}\n d = {}\n for i in range(n):\n if a[i] in c:\n c[a[i]] += 1\n else:\n c[a[i]] = 1\n for i in range(n):\n if b[i] in d:\n d[b[i]] += 1\n else:\n d[b[i]] = 1\n #print(c)\n #print(d)\n e = 0\n g = 0\n h = 0\n m = 0\n o = 0\n for i in c:\n if i in d:\n #e.append(i)\n if c[i] == d[i]:\n continue\n else:\n #m += 1\n if c[i] > d[i]:\n g = abs(c[i] - d[i])\n else:\n g = 0\n if(g%2 == 0):\n h += g//2\n else:\n h = -1\n break\n else:\n g = c[i]\n if(g%2 == 0):\n e += g//2\n else:\n e = -1\n break\n for i in d:\n if i not in c:\n g = d[i]\n if(g%2 == 0):\n o += g//2\n else:\n o = -1\n \n #print(h,e,m,o)\n if(h == -1 or e == -1 or o == -1):\n e = -1\n else:\n #if(h > 0 and m > 0):\n # h = h//m\n #if e+h > o:\n # e = h+e-o\n #else:\n e = h+e\n print(e)\n\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "from collections import Counter\n\n\nn = int(input())\na = input().split(' ')\nb = input().split(' ')\naa = Counter()\nbb = Counter()\nfor x in a:\n aa[x] += 1\nfor x in b:\n bb[x] += 1\nmm = Counter()\npossible = True\nfor x in ('1', '2', '3', '4', '5'):\n if (aa[x] + bb[x]) % 2 != 0:\n possible = False\n else:\n mm[x] = (aa[x] + bb[x]) // 2\nif not possible:\n print('-1')\nelse:\n print(sum(abs(aa[x] - mm[x]) for x in ('1', '2', '3', '4', '5')) // 2)"}, {"source_code": "import math\n\na = raw_input()\na = int(a)\n\nb = raw_input()\nc = raw_input()\n\nb = b.split()\nc = c.split()\n\nb = map(int, b)\nc = map(int, c)\n\ncount1 = 0\ncount2 = 0\ncount3 = 0\ncount4 = 0\ncount5 = 0\nbount1 = 0\nbount2 = 0\nbount3 = 0\nbount4 = 0\nbount5 = 0\n\nfor i in range(a):\n if b[i] == 1:\n bount1 += 1\n elif b[i] == 2:\n bount2 += 1\n elif b[i] == 3:\n bount3 += 1\n elif b[i] == 4:\n bount4 += 1\n elif b[i] == 5:\n bount5 += 1\n\nfor i in range(a):\n if c[i] == 1:\n count1 += 1\n elif c[i] == 2:\n count2 += 1\n elif c[i] == 3:\n count3 += 1\n elif c[i] == 4:\n count4 += 1\n elif c[i] == 5:\n count5 += 1\n\nif (bount1 + count1) % 2 == 1:\n print -1\nelif (bount2 + count2) % 2 == 1:\n print -1\nelif (bount3 + count3) % 2 == 1:\n print -1\nelif (bount4 + count4) % 2 == 1:\n print -1\nelif (bount5 + count5) % 2 == 1:\n print -1\nelse:\n count = 0\n if bount1 > (bount1 + count1)/2:\n count += bount1 - (bount1 + count1)/2\n if bount2 > (bount2 + count2)/2:\n count += bount2 - (bount2 + count2)/2\n if bount3 > (bount3 + count3)/2:\n count += bount3 - (bount3 + count3)/2\n if bount4 > (bount4 + count4)/2:\n count += bount4 - (bount4 + count4)/2\n if bount5 > (bount5 + count5)/2:\n count += bount5 - (bount5 + count5)/2\n print count\n"}, {"source_code": "n = int(input())\n\ns = list(map(int, input().split()))\np = list(map(int, input().split()))\n\na1 = s.count(1)\na2 = s.count(2)\na3 = s.count(3)\na4 = s.count(4)\na5 = s.count(5)\n\nb1 = p.count(1)\nb2 = p.count(2)\nb3 = p.count(3)\nb4 = p.count(4)\nb5 = p.count(5)\n\nz1 = abs(a1 - b1)\nz2 = abs(a2 - b2)\nz3 = abs(a3 - b3)\nz4 = abs(a4 - b4)\nz5 = abs(a5 - b5)\n\nans1 = (z1 + z2 + z3 + z4 + z5)//2\n\nif z1 % 2==0 and z2 % 2==0 and z3 % 2==0 and z4 % 2==0 and z2 % 2==0 :\n\tif ans1 % 2 == 0 :\n\t\tprint(ans1 // 2)\n\telse:\n\t\tprint(\"-1\")\nelse :\n\tprint(\"-1\")\n\t"}, {"source_code": "a=input()\nl1=raw_input().split(' ')\nl2=raw_input().split(' ')\n\ndef make_dic(li):\n d=dict()\n for h in li:\n if h not in d:\n d[h]=1\n else:\n d[h]+=1\n return d\nd1=make_dic(l1)\nd2=make_dic(l2)\n\n#c=0\ndef count(d1,d2):\n c=0\n for h in d1:\n if h in d2:\n if (d1[h]+d2[h])%2==0:\n \n if d1[h]>d2[h]:\n c=c+(d1[h]-d2[h])/2\n else:\n c=c+(d2[h]-d1[h])/2\n else:\n return -1\n else:\n if d1[h]%2==0:\n c=c+(d1[h]/2)\n else:\n return -1\n for h in d2:\n if h not in d1:\n if d2[h]%2==0:\n c=c+(d2[h]/2)\n else:\n return -1\n return c/2\n\nprint count(d1,d2)\n \n \n \n"}, {"source_code": "import sys\n\ndiff = [0] * 6\n\n[n] = [int(x) for x in sys.stdin.readline().split()]\na = [int(x) for x in sys.stdin.readline().split()]\nb = [int(x) for x in sys.stdin.readline().split()]\n\nfor x in a:\n\tdiff[x] += 1\n\nfor x in b:\n\tdiff[x] -= 1\n\nres = 0\n\nfor x in diff:\n\tif x % 2 != 0:\n\t\tprint -1\n\t\tsys.exit()\n\telse:\n\t\tres += abs(x / 2)\n\nprint res / 2\n\n'''\n===\n4\n5 4 4 4\n5 5 4 5\n---\n1\n===\n6\n1 1 1 1 1 1\n5 5 5 5 5 5\n---\n3\n===\n1\n5\n3\n---\n-1\n===\n9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1\n---\n4\n===\n'''"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nb=map(int,raw_input().split())\ncnt=[0 for i in range(6)]\ncnta=[0 for i in range(6)]\ncntb=[0 for i in range(6)]\n\nfor i in range(n):\n cnt[a[i]]+=1\n cnt[b[i]]+=1\n cnta[a[i]]+=1\n cntb[b[i]]+=1\n\nfor i in range(6):\n if cnt[i]%2==1:\n print -1\n exit(0)\n else:\n cnt[i]/=2\n\nans=0\nfor i in range(6):\n if cnta[i]>cnt[i]:\n ans+=cnta[i]-cnt[i]\n\nprint ans"}, {"source_code": "import sys\nimport itertools\n\n\ndef solve(A, B):\n totals = [a+b for a,b in itertools.izip(A, B)]\n swaps = 0\n for num,a,b in itertools.izip(totals, A, B):\n if num % 2:\n return -1\n needed = num / 2\n swaps += abs(needed - a)\n\n if swaps % 2:\n return -1\n else:\n return swaps / 2\n\n\ndef main():\n n = int(sys.stdin.readline())\n g_A = map(int, sys.stdin.readline().split())\n g_B = map(int, sys.stdin.readline().split())\n A = [0 for i in xrange(5)]\n B = [0 for i in xrange(5)]\n\n for n in g_A:\n A[n-1] += 1\n for n in g_B:\n B[n-1] += 1\n\n print solve(A, B)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "R=lambda:map(int,raw_input().split())\ninput()\nc=[0]*8\nfor x in R():\n c[x]+=1\nfor x in R():\n c[x]-=1\nt=0\nfor x in range(1,6):\n if c[x]%2:\n print -1\n break\n t+=abs(c[x])/2\nelse:\n print t/2"}, {"source_code": "import sys\nf = sys.stdin\n#f = open('779A.txt')\n\nn = int(f.readline())\ntab1 = [0]*101\ntab2 = [0]*101\nall = [0]*101\nans = 0\nu1 = [int(i) for i in f.readline().split()]\nu2 = [int(i) for i in f.readline().split()]\nfor _ in xrange(0, n):\n tab1[u1[_]] += 1\n #tab2[u2[_]] += 1\n all[u1[_]] += 1\n all[u2[_]] += 1\nok = 1\nfor _ in xrange(0, 101):\n if all[_] > 0:\n if all[_] % 2 <> 0:\n ok = 0\n break\n else:\n tab2[_] = all[_] / 2\nfor _ in xrange(0, 101):\n if all[_] == 0:\n continue\n ans += abs(tab1[_] - tab2[_])\nif ok == 0:\n print -1\nelse:\n print ans/2\n#f.close"}, {"source_code": "from sys import stdin\nn = int(stdin.readline().strip())\na = map(int,stdin.readline().split())\nb = map(int,stdin.readline().split())\ndi = {}\nfi = {}\nfor i in a:\n di[i] = di.get(i,0)+1\n fi[i] = fi.get(i,0) + 1\nfor i in b:\n di[i] = di.get(i,0) + 1\nans = 0\ncur = 0\nfor i in di:\n if di[i]%2:\n ans = -1\n break\n x = di[i]/2\n if fi.get(i,0) > x:\n ans += fi.get(i,0) - x\nprint ans"}, {"source_code": "import sys\n\ndef main(argv):\n\tN = int(raw_input())\n\n\tA = [int(x) for x in raw_input().split(' ')]\n\tB = [int(x) for x in raw_input().split(' ')]\n\n\tcount_A = {}\n\tcount_B = {}\n\n\tfor val in xrange(1, 6):\n\t\tcount_A[val] = count_B[val] = 0\n\n\tfor val in A:\n\t\tif val in count_A:\n\t\t\tcount_A[val] += 1\n\t\telse:\n\t\t\tcount_A[val] = 1\n\n\tfor val in B:\n\t\tif val in count_B:\n\t\t\tcount_B[val] += 1\n\t\telse:\n\t\t\tcount_B[val] = 1\n\n\tans = 0\n\tfrom_A = 0\n\tfrom_B = 0\n\tfor val in xrange(1, 6):\n\t\tif count_A[val] > count_B[val]:\n\t\t\tfrom_A += abs(count_A[val] - (count_A[val] + count_B[val]) / 2)\n\t\telse:\n\t\t\tfrom_B += abs(count_A[val] - (count_A[val] + count_B[val]) / 2)\n\t\tans += abs(count_A[val] - (count_A[val] + count_B[val]) / 2)\n\n\tif from_A != from_B:\n\t\tprint -1\n\telse:\n\t\tprint ans / 2\n\n\nif __name__ == '__main__':\n\tmain(sys.argv)"}, {"source_code": "from random import random\nimport math\nimport re\nimport fractions\n\nN = input()\n# N, M = map(int, raw_input().split(\" \"))\nA = map(int, raw_input().split(\" \"))\nB = map(int, raw_input().split(\" \"))\ns = [0]*5\na = [0]*5\nfor i in xrange(N):\n s[A[i]-1] += 1\n a[A[i]-1] += 1\n s[B[i]-1] += 1\nf = True\nr = 0\n# print s, a\nfor i in xrange(5):\n if s[i] % 2:\n print -1\n break\n else:\n r += abs(s[i]/2 - a[i])\nelse:\n print r/2\n"}, {"source_code": "import sys\nfrom collections import Counter\n\nn = int(input())\na = Counter(map(int, input().split()))\nb = Counter(map(int, input().split()))\n\ncounta = 0\ncountb = 0\n\nfor i in range(1,5+1):\n diff = abs(a[i] - b[i])\n if diff%2:\n print(-1)\n sys.exit(0)\n \n if a[i] < b[i]:\n countb += int(diff/2)\n if b[i] < a[i]:\n counta += int(diff/2)\n\nif counta != countb:\n print(-1)\n sys.exit(0)\n\nprint(counta)\n\n \n"}, {"source_code": "n = input()\nA = map(lambda x: int(x)-1, raw_input().split())\nB = map(lambda x: int(x)-1, raw_input().split())\nc = [0 for _ in xrange(5)]\n\nfor a in A:\n c[a] += 1\nfor b in B:\n c[b] += 1\n\nif not all(x % 2 == 0 for x in c):\n print -1\n exit()\n\nd = [x / 2 for x in c]\nans = 0\nca = [0 for _ in xrange(5)]\nfor a in A:\n ca[a] += 1\n\nfor i in xrange(5):\n ans += abs(d[i] - ca[i])\n\nprint ans/2\n"}, {"source_code": "n = int(raw_input())\nm1 = map(int, raw_input().split(\" \"))\nm2 = map(int, raw_input().split(\" \"))\n\ncm1 = [0]*6\nfor m in m1:\n cm1[m]+=1\ncm2 = [0]*6\nfor m in m2:\n cm2[m]+=1\n\nr = 0\nfor m in range(1,6):\n d = abs(cm1[m]-cm2[m])\n if d%2:\n print -1\n exit()\n r+= (d/2)\nprint r/2"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split(' ')]\nb = [int(i) for i in input().split(' ')]\n\ncount = [0]*6\n\nfor i in range(1, 6):\n count[i] = a.count(i) - b.count(i)\n\nans = 0\n\nfor i in range(1, 6):\n for j in range(i+1, 6):\n if count[i] * count[j] < 0:\n t = min(abs(count[i]), abs(count[j]))//2\n ans += t\n count[i] += t*2 if count[i] < 0 else -t*2;\n count[j] += t*2 if count[j] < 0 else -t*2;\n\nif count.count(0) == 6:\n print(ans)\nelse:\n print(-1)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nd1,d2={1:0,2:0,3:0,4:0,5:0},{1:0,2:0,3:0,4:0,5:0}\nfor i in range(n):\n\td1[a[i]]+=1\n\td2[b[i]]+=1\na,b,f=0,0,0\nfor i in range(1,6):\n\tif d1[i]>=d2[i]:\n\t\tw=(d1[i]+d2[i])\n\t\tif w&1:\n\t\t\tf=1\n\t\t\tbreak\n\t\telse:\n\t\t\ta+=(d1[i]-(w//2))\n\telse:\n\t\tw=(d1[i]+d2[i])\n\t\tif w&1:\n\t\t\tf=1\n\t\t\tbreak\n\t\telse:\n\t\t\tb+=(d2[i]-(w//2))\nif f==0 and a==b:\n\tprint(a)\nelse:\n\tprint(-1)"}, {"source_code": "n = input()\nA = map(int, raw_input().split())\nB = map(int, raw_input().split())\n\nda = {x:0 for x in range(1, 6)}\ndb = {x:0 for x in range(1, 6)}\n\nfor x in A:\n\tda[x]+=1\nfor x in B:\n\tdb[x]+=1\n\nans = 0\nextra = []\nfor ii in range(1, 6):\n\tif da[ii] == db[ii]:\n\t\tcontinue\n\tif (da[ii] + db[ii]) & 1: \n\t\tprint '-1'\n\t\texit(0)\n\telse: \n\t\textra.append(abs(db[ii] - da[ii]) / 2)\n\nprint sum(extra)/2"}, {"source_code": "# -*- coding: utf-8 -*-\nn = int(input())\nc1 = list(map(int, input().split(' ')))\nc2 = list(map(int, input().split(' ')))\nm1_add = []\nm1_rem = []\nm2_add = []\nm2_rem = []\nboolean = True\nfor i in range(1, 6):\n k1 = c1.count(i)\n k2 = c2.count(i)\n if abs(k1-k2)%2 == 1:\n print(-1)\n boolean = False\n break\n if k1>k2:\n m1_rem.append((k1-k2)//2)\n m2_rem.append(0)\n m1_add.append(0)\n m2_add.append((k1-k2)//2)\n else:\n m1_rem.append(0)\n m2_rem.append((k2-k1)//2)\n m1_add.append((k2-k1)//2)\n m2_add.append(0)\nif boolean:\n for i in range(5):\n for j in range(m1_add[i]):\n c1.append(i+1)\n for j in range(m2_add[i]):\n c2.append(i+1)\n for j in range(m1_rem[i]):\n c1.remove(i+1)\n for j in range(m2_rem[i]):\n c2.remove(i+1)\n if sum([int(i) for i in c1]) == sum([int(i) for i in c2]):\n print(sum(m1_add))\n else:\n print(-1)\n"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nb=map(int,raw_input().split())\ndp=[0]*6\nfor i in a:\n dp[i]+=1\nfor i in b:\n dp[i]+=1\n\nfor item in dp:\n if item%2==1:\n print -1\n break\nelse:\n dpa=[0]*6\n dpb=[0]*6\n for i in a:\n dpa[i]+=1\n for i in b:\n dpb[i]+=1\n total=0\n for i in xrange(len(dp)):\n total=total+(abs(dp[i]/2-dpa[i]))\n print total/2"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nb = map(int, raw_input().split())\n\narr = [0]*6\nbrr = [0] * 6\nposcount = 0\ncount = 0\nfor i in range(n):\n arr[a[i]] += 1\n brr[b[i]] += 1\n#print arr, brr\n\nfor i in range(1, 6):\n if ((arr[i] - brr[i]) % 2 != 0):\n print -1\n exit(0)\n else:\n count += (arr[i] - brr[i])/2\n poscount += abs(arr[i] - brr[i])/2\n\nif (count):\n print -1\nelse:\n print poscount/2"}, {"source_code": "\nn = input()\n\nA = map(int,raw_input().split())\nB = map(int,raw_input().split())\n\nA_cnt = list(A.count(i) for i in range(1,6))\nB_cnt = list(B.count(i) for i in range(1,6))\n\nans = 0\n\nfor a,b in zip(A_cnt,B_cnt):\n if (a - b) % 2 != 0:\n print -1\n break\n else:\n if a - b > 0:\n ans += a-b\n\nelse:\n print ans/2\n"}, {"source_code": "n = int(input())\nadata = {\n 1:0,\n 2:0,\n 3:0,\n 4:0,\n 5:0\n}\nbdata= {\n 1:0,\n 2:0,\n 3:0,\n 4:0,\n 5:0\n}\n\na = list(map(int,input().split()))\nfor x in a:\n adata[x] = adata[x] + 1\nb = list(map(int,input().split()))\nfor x in b:\n bdata[x] = bdata[x] + 1\nans = 0\nans = ans + abs(adata[1]-bdata[1])\nans = ans + abs(adata[2]-bdata[2])\nans = ans + abs(adata[3]-bdata[3])\nans = ans + abs(adata[4]-bdata[4])\nans = ans + abs(adata[5]-bdata[5])\nif (adata[1]+bdata[1])%2!=0 or (adata[1]+bdata[1])%2!=0 or (adata[2]+bdata[2])%2!=0 or (adata[3]+bdata[3])%2!=0 or (adata[4]+bdata[4])%2!=0 or (adata[5]+bdata[5])%2!=0 :\n ans = -1\nprint(ans//4)"}, {"source_code": "n = int(input())\nx1 = list(map(int, input().split()))\nx2 = list(map(int, input().split()))\nans = 0\ncount1 = [0,0,0,0,0,0]\ncount2 = [0,0,0,0,0,0]\nflag = True\nfor i in range(1, 6):\n s = x1.count(i) + x2.count(i)\n count1[i] = x1.count(i)\n count2[i] = x2.count(i)\n if(s%2==1):\n flag = False\n break\n\nif(flag):\n x1.sort()\n x2.sort()\n for i in range(1, 6):\n for j in range(min(count1[i], count2[i])):\n x1.remove(i)\n x2.remove(i)\n count1[i]-=1\n count2[i]-=1\n l = len(x1)\n print(l//2)\nelse:\n print(-1)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = [0,0,0,0,0]\nfor i in a:\n c[i - 1] += 1\nfor j in b:\n c[j - 1] -= 1\nc = [abs(i) for i in c]\nimport sys\nfor i in c:\n if i % 2:\n print(-1)\n sys.exit(0)\nprint(sum(c) // 4)"}, {"source_code": "input()\n\nfst = [int(x) for x in input().split()]\nsnd = [int(x) for x in input().split()]\n\ndef count(arr):\n res = {i: 0 for i in range(1, 6)}\n for i in arr:\n res[i]+=1\n return res\n\ndef solve():\n total = count(fst+snd)\n fst_ = count(fst)\n snd_ = count(snd)\n \n for v in total.values():\n if v%2!=0: return -1\n res = 0\n for k, v in fst_.items():\n diff = v - total[k]//2\n res += (diff if diff>0 else 0)\n return res\nprint(solve())"}, {"source_code": "n = int(input().strip())\na = list(map(int, input().strip().split()))\nb = list(map(int, input().strip().split()))\nfa, fb = [0]*6, [0]*6\nfor i in range(n):\n\tfa[a[i]] += 1\n\tfb[b[i]] += 1\ntotal = 0\nfor i, j in zip(fa, fb):\n\tif (i+j)%2:\n\t\texit(print(-1))\n\ttotal += abs(i-j)//2\nprint(total//2)"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\nfor i in range(1,6):\n if (a.count(i)+b.count(i))%2==1:\n print(-1)\n exit()\nans=0\nfor i in range(1,6):\n ans+=abs(a.count(i)-b.count(i))\nprint(ans//4)"}, {"source_code": "input()\n\nA,B = input(),input()\n\nD = [abs(A.count(x)- B.count(x)) for x in '12345']\nprint(-1 if any(d % 2 for d in D) else sum(D) //4)"}, {"source_code": "# helper methods for input\ndef ri():\n return raw_input()\n\n\ndef ii(type):\n x = ri()\n if type == 'i':\n return int(x)\n if type == 'l':\n return long(x)\n if type == 'f':\n return float(x)\n if type == 's':\n return str(x)\n return\n\n\ndef i2(type):\n x = ri().split()\n if type == 'i':\n return int(x[0]), int(x[1])\n if type == 'l':\n return long(x[0]), long(x[1])\n if type == 'f':\n return float(x[0]), float(x[1])\n if type == 's':\n return str(x[0]), str(x[1])\n return\n\n\ndef ni(type):\n array = ri().split()\n def doforall(x):\n if type == 'i':\n return int(x)\n if type == 'l':\n return long(x)\n if type == 'f':\n return float(x)\n if type == 's':\n return str(x)\n return\n array = map(doforall, array)\n return array\n\n\ndef pr(array):\n def tostring(el):\n return str(el)\n print ' '.join(map(tostring, array))\n\n\ndef fndec(x):\n return '{0:.6f}'.format(x)\n\n\n# main\nn = ii('i')\narr1 = ni('i')\narr2 = ni('i')\nallarr = arr1 + arr2\n\ndic = {}\nfor elem in allarr:\n if elem not in dic: dic[elem] = 0\n dic[elem] += 1\n\npossible = True\nfor key in dic:\n if dic[key] % 2 == 1:\n possible = False\n break\n else:\n dic[key] /= 2\n\nif not possible:\n print '-1'\nelse:\n count = 0\n for elem in arr1:\n if dic[elem] > 0:\n dic[elem] -= 1\n else:\n count += 1\n print count"}, {"source_code": "n = int(input())\n#m = input().split() #list\n#[a, b, c] = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\n\n\nA_grades = [0, 0, 0, 0, 0]\nB_grades = [0, 0, 0, 0, 0]\n\n\nfor i in range(0, n):\n A_grades[A[i]-1] += 1\n B_grades[B[i]-1] += 1\n\nl = 0\n\n#Check if such changes can happen \nfor i in range(0, 5):\n if (A_grades[i] + B_grades[i]) % 2 != 0:\n print(-1)\n l = 1\n break\n \ndif = 0\nfor i in range(0, 5):\n dif += abs(A_grades[i]- B_grades[i])\n \nif l == 0:\n print(dif // 4)\n\n "}, {"source_code": "# MELISSA MOORE\nn=input()\na=map(int, raw_input().split())\nb=map(int, raw_input().split())\ns=0\nfor t in range(1,6):\n if (a+b).count(t)%2==1:\n s=-2\n break\n else:\n s+=abs(a.count(t)-b.count(t))\nprint s/4"}, {"source_code": "import sys\nimport math\nimport itertools\nimport collections\n\ndef getdict(n):\n d = {}\n if type(n) is list or type(n) is str:\n for i in n:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n else:\n for i in range(n):\n t = ii()\n if t in d:\n d[t] += 1\n else:\n d[t] = 1\n return d\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a*b) // math.gcd(a, b)\ndef wr(arr): return ''.join(map(str, arr))\ndef revn(n): return int(str(n)[::-1])\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef nconv(number, base=3):\n newnumber = ''\n while number > 0:\n newnumber = str(number % base) + newnumber\n number //= base\n return newnumber\n\n\nn = ii()\na = li()\nb = li()\nfor i in range(5):\n if (a.count(i + 1) + b.count(i + 1)) % 2 != 0:\n print(-1)\n exit()\nans = 0\nfor i in range(5):\n ans += abs(a.count(i + 1) - b.count(i + 1)) // 2\nprint(ans // 2)\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nb = map(int, raw_input().split())\n\nnumberOfExchange = 0\n\nfor i in xrange(0,5):\n\tif (a.count(i+1) + b.count(i+1)) % 2 != 0 :\n\t\tnumberOfExchange = -1\n\t\tbreak\n\tnumberOfExchange += abs(a.count(i+1)-b.count(i+1))/2\n\n\nprint numberOfExchange/2"}, {"source_code": "\nn=int(input())\nl=list(map(int,input().split()))\nl1=list(map(int,input().split()))\nc=[0]*(8)\nans=0\nfor i in l:\n #print(i-1)\n c[i]+=1\nfor i in l1:\n c[i]-=1\n\nfor i in range(6):\n if c[i]%2:\n print(-1)\n break\n ans+=abs(c[i])//2\nelse:print(ans//2)\n "}, {"source_code": "from sys import stdin\nfrom collections import defaultdict\n\nn = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\na_d = defaultdict(int)\nb_d = defaultdict(int)\nfor i in range(n):\n a_d[a[i]] += 1\n b_d[b[i]] += 1\nf = True\nans = 0\nfor i in range(6):\n if (a_d[i] + b_d[i]) % 2:\n f = False\n break\n ans += abs(a_d[i] - b_d[i])\nif f:\n print(ans//4)\nelse:\n print(-1)"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\na = list(map(int, sys.stdin.readline().split()))\nb = list(map(int, sys.stdin.readline().split()))\nans = 0\n\nam = [0] * 5\nbm = [0] * 5\n\nfor i in a:\n am[i - 1] += 1\nfor i in b:\n bm[i - 1] += 1\n\nfor i in range(5):\n if am[i] != bm[i]:\n if (am[i] - bm[i]) % 2 == 0:\n ans += abs(am[i] - bm[i]) // 2\n else:\n ans = -1\n break\nprint(ans // 2)\n"}, {"source_code": "ans=0\nn=int(input())\na=[int(i) for i in input().split()]\nb=[int(i) for i in input().split()]\nx={i:0 for i in range(1,6)}\ny={i:0 for i in range(1,6)}\nfor i in a:\n x[i]+=1\nfor i in b:\n y[i]+=1\nans=[0]*2\nfor i in range(1,6):\n tmp=x[i]-y[i]\n if tmp%2!=0:\n print(-1)\n exit()\n elif tmp>0:\n ans[1]+=tmp\n else:\n ans[0]+=tmp\nprint(ans[1]//2 if sum(ans)==0 else -1)"}, {"source_code": "n=int(input())\na=[int(z) for z in input().split()]\nb=[int(z) for z in input().split()]\nc1,d1,e1,f1,g1=0,0,0,0,0\nc2,d2,e2,f2,g2=0,0,0,0,0\nfor i in a:\n if i==1:\n c1+=1\n elif i==2:\n d1+=1\n elif i==3:\n e1+=1\n elif i==4:\n f1+=1\n else:\n g1+=1\nfor i in b:\n if i==1:\n c2+=1\n elif i==2:\n d2+=1\n elif i==3:\n e2+=1\n elif i==4:\n f2+=1\n else:\n g2+=1\nif (c1+c2)&1 or (d1+d2)&1 or (e1+e2)&1 or (f1+f2)&1 or (g1+g2)&1:\n print(-1)\nelse:\n print((abs((c1+c2)//2-c1)+abs((d1+d2)//2-d1)+abs((e1+e2)//2-e1)+abs((f1+f2)//2-f1)+abs((g1+g2)//2-g1))//2)\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\n\nn=input()\na=r()\nb=r()\nc=a+b\ns=set(a+b)\n\nR=0\nfor e in s:\n if c.count(e)%2:\n print -1\n exit(0)\n R+= abs(c.count(e)/2-a.count(e))\n \nprint R/2"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc=0\nd=0\nz=0\nfor j in range(5):\n for i in range(n):\n if a[i]==j+1:\n c+=1\n for i in range(n):\n if b[i]==j+1:\n d+=1\n if (c+d)%2==1:\n z=-2\n break\n else:\n z+=abs(c-d)//2\n d=0\n c=0\nprint(z//2)"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nb = map(int, raw_input().split())\na_i = {i : a.count(i) for i in xrange(1, 6)}\nb_i = {i : b.count(i) for i in xrange(1, 6)}\npossible = True\n\ntot_diff = 0\nfor i in xrange(1, 6):\n if a_i[i] != b_i[i]:\n diff = abs(a_i[i] - b_i[i])\n if diff % 2 == 1:\n possible = False\n tot_diff += diff/2\nif possible:\n print tot_diff / 2\nelse:\n print -1\n\n \n\n"}, {"source_code": "n=int(raw_input())\na=map(int,raw_input().split())\nb=map(int,raw_input().split())\nans=[]\nf=count=0\nfor i in range(1,6):\n\tans.append(a.count(i)-b.count(i))\nans.sort()\nfor i in range(len(ans)):\n\tif ans[i]%2!=0:\n\t\tf=1\n\t\tbreak\nif f==1 or sum(ans)!=0:\n\tprint -1\n\texit(0)\nfor i in range(len(ans)):\n\tif ans[i]<0:\n\t\tcount+=abs(ans[i])/2\n\telse:\n\t\tbreak\nprint count\n"}, {"source_code": "R=lambda:map(int,raw_input().split())\nR()\nc=[0]*8\nfor x in R():c[x]+=1\nfor x in R():c[x]-=1\nt=0\nfor x in range(1,6):\n if c[x]%2:\n print -1\n break\n t+=abs(c[x])/2\nelse:print t/2\n"}, {"source_code": "n = input()\n\na = map(int, raw_input().split())\nb = map(int, raw_input().split())\n\n#print n, a, b\n\n#c = a + b\nsa = [0] * 5\nsb = [0] * 5\nfor i in xrange(n):\n sa[a[i]-1] = sa[a[i]-1] + 1 \n sb[b[i]-1] = sb[b[i]-1] + 1 \n\n#print s\n\nfor i in xrange(5):\n if (sa[i] + sb[i]) % 2 != 0:\n print -1\n exit()\n\ns = 0\nfor i in xrange(5):\n s = s + abs(sa[i] - sb[i])/2\n\nprint s/2\n\n\n"}, {"source_code": "input()\nA, B = input(), input()\nD = [abs(A.count(x) - B.count(x)) for x in '12345']\n#first divide by 2 for overcounting,Now if you pick a number you pick another number as\n#if sum is odd like 17 or 19 then -1,if divisible by 4,great,if divisible by 2 but not 4\n#then floor 4 because numbers like 9,25,27 all have a remaining pair after 8*2,24*2,26*2.\nprint(-1 if any(d % 2 for d in D) else sum(D) // 4)"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().strip().split(' '))\nb = map(int, raw_input().strip().split(' '))\n\ncountA = [0 for i in xrange(6)]\ncountB = [0 for i in xrange(6)]\nfor i in a:\n countA[i] += 1\n\nfor i in b:\n countB[i] += 1\n\nans = 0\nfor i in xrange(6):\n #print countA[i], countB[i]\n if (countA[i] + countB[i]) % 2 == 1:\n print -1\n exit(0)\n diff = abs(countA[i] - countB[i])\n ans += diff/ 2\n\n\nprint ans / 2"}, {"source_code": "def get(l):\n a=[0]*5\n for i in xrange(n):\n a[l[i]-1]+=1\n return a\nn=input()\np=map(int,raw_input().split())\nq=map(int,raw_input().split())\na,b=get(p),get(q)\np=0\nans=0\n#print a\n#print b\nfor i in xrange(5):\n t=(a[i]+b[i])/2\n if (a[i]+b[i])%2!=0:\n p=1\n break\n else:\n #print \"sdjv\"\n ans+=(abs(a[i]-t))\n p+=(a[i]-t)\n #print a[i],t\n #print t,ans,p\nif p==0:\n print ans/2\nelse:\n print -1\n \n \n"}, {"source_code": "n = input()\ngroup_a = map(int, raw_input().split())\ngroup_b = map(int, raw_input().split())\na = [0]*6\nb = [0]*6\n\nfor num in group_a:\n a[num] += 1\n\nfor num in group_b:\n b[num] += 1\n\nvalid = True\ndifferences = 0\nfor i in range(6):\n if (a[i] + b[i]) % 2 == 1:\n valid = False\n else:\n differences += abs((a[i] - b[i]) / 2)\n\nif valid:\n print differences / 2\nelse:\n print -1\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().strip().split(' '))\nb = map(int, raw_input().strip().split(' '))\n\ncountA = [0 for i in xrange(6)]\ncountB = [0 for i in xrange(6)]\nfor i in a:\n countA[i] += 1\n\nfor i in b:\n countB[i] += 1\n\nans = 0\nfor i in xrange(6):\n #print countA[i], countB[i]\n if (countA[i] + countB[i]) % 2 == 1:\n print -1\n exit(0)\n diff = abs(countA[i] - countB[i])\n ans += diff / 2\n\n\nprint ans / 2"}, {"source_code": "n = int(input())\n\na = list(map(int, input().strip().split(\" \")))\nb = list(map(int, input().strip().split(\" \")))\n\ncount = [0] * 5\n\n\nfor grade in a:\n count[grade - 1] +=1\n \nfor grade in b:\n count[grade - 1] -=1\n\nsuma = 0\nflag = True\nfor item in count:\n if(item % 2 == 1):\n flag = False\n break;\n else:\n suma += abs(item) // 2\n \nif(flag):\n print(suma // 2)\nelse:\n print(-1)"}, {"source_code": "read = lambda: map(int, input().split())\nn = int(input())\na = sorted(read())\nb = sorted(read())\nfor i in range(1, 6):\n if (a.count(i) + b.count(i)) % 2:\n print(-1)\n exit()\ncnt = 0\nwhile 1:\n flag = False\n for i in range(n):\n if a.count(a[i]) > b.count(a[i]):\n for j in range(n):\n if a.count(b[j]) < b.count(b[j]) and a[i] != b[j]:\n a[i], b[j] = b[j], a[i]\n cnt += 1\n break\n if flag: break\n if not flag:\n break\nprint(cnt)"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().strip().split(' '))\nb = map(int, raw_input().strip().split(' '))\n\ncountA = [0 for i in xrange(6)]\ncountB = [0 for i in xrange(6)]\nfor i in a:\n countA[i] += 1\n\nfor i in b:\n countB[i] += 1\n\nans = 0\nfor i in xrange(6):\n #print countA[i], countB[i]\n if (countA[i] + countB[i]) % 2 == 1:\n print -1\n exit(0)\n diff = abs(countA[i] - countB[i])\n ans += diff / 2\n\n\nprint ans / 2"}, {"source_code": "#!/usr/bin/python\n# coding: utf-8\n\nn=int(raw_input())\na=map(int,raw_input().split(' '))\nb=map(int,raw_input().split(' '))\narr1=[0]*6\narr2=[0]*6\nfor i in xrange(n):\n arr1[a[i]]+=1\n arr2[b[i]]+=1\ncnt=0\nfor i in xrange(1,6):\n exch=abs(arr1[i]-arr2[i])\n if(exch&1):\n cnt=-2\n break\n else:\n cnt+=(exch/2)\nprint cnt/2\n\n\n'''\n\nIn Berland each high school student is characterized by academic performance \u2014 integer value between 1 and 5.\n\nIn high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known \u2014 integer \nvalue between 1 and 5.\n\nThe school director wants to redistribute students between groups so that each of the two groups has the same number of students whose academic performance is equal to 1, the same \nnumber of students whose academic performance is 2 and so on. In other words, the purpose of the school director is to change the composition of groups, so that for each value of\nacademic performance the numbers of students in both groups are equal.\n\nTo achieve this, there is a plan to produce a series of exchanges of students between groups. During the single exchange the director selects one student from the class A and one \nstudent of class B. After that, they both change their groups.\n\nPrint the least number of exchanges, in order to achieve the desired equal numbers of students for each academic performance.\n\nInput\nThe first line of the input contains integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 number of students in both groups.\nThe second line contains sequence of integer numbers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u20095), where ai is academic performance of the i-th student of the group A.\nThe third line contains sequence of integer numbers b1,\u2009b2,\u2009...,\u2009bn (1\u2009\u2264\u2009bi\u2009\u2264\u20095), where bi is academic performance of the i-th student of the group B.\n\nOutput\nPrint the required minimum number of exchanges or -1, if the desired distribution of students can not be obtained.\n\nExamples\nInput\n4\n5 4 4 4\n5 5 4 5\n\nOutput\n1\n\nInput\n6\n1 1 1 1 1 1\n5 5 5 5 5 5\n\nOutput\n3\n\nInput\n1\n5\n3\n\nOutput\n-1\n\nInput\n9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1\n\nOutput\n4\n\n'''\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\ns=0\nc=0\nfor i in range(1,6):\n\tx=a.count(i)\n\ty=b.count(i)\n\tif((x+y)%2==0):\n\t\ts=s+(abs(x-y))//2\n\telse:\n\t\tc=1\n\t\tbreak\nif(c==1):\n\tprint(-1)\nelse:\n\tprint(s//2)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ntotal = 0\nfor i in range(1, 6):\n aCnt, bCnt = a.count(i), b.count(i)\n if (aCnt + bCnt) % 2:\n total = -2\n break\n else:\n total += abs(aCnt - bCnt) // 2\n\nprint(total // 2)"}, {"source_code": "import itertools\nfrom fractions import gcd\nfrom math import sqrt,ceil\nfrom bisect import bisect_left , bisect_right\nimport heapq\nfrom collections import deque\nfrom itertools import combinations as C\n\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\nfrom collections import defaultdict , deque , Counter\n#last one:)\nn = input()\nls1 = [0]*5\nls2 = [0]*5\nh1 = get(int)\nh2 = get(int)\nfor i in h1:\n\tls1[i-1] += 1\nfor i in h2:\n\tls2[i-1] += 1\n#print ls1,ls2\nif all( (ls1[i] + ls2[i]) % 2 == 0 for i in xrange(5)):\n\tpass\nelse:\n\tprint -1\n\texit(0)\ncnt = 0\nfor i in xrange(5):\n\ta = ls1[i]\n\tb = ls2[i]\n\tmv = (a+b)/2 - min(a,b)\n\tif a > b:\n\t\tfor j in xrange(5):\n\t\t\ta , b = ls1[j],ls2[j]\n\t\t\tif a < b:\n\t\t\t\twhile mv > 0 and ls1[j] < ls2[j]:\n\t\t\t\t\tls2[j] -= 1\n\t\t\t\t\tls1[j] += 1\n\t\t\t\t\tmv -= 1\n\t\t\t\t\tcnt += 1\n\telif a < b:\n\t\tfor j in xrange(5):\n\t\t\ta , b = ls1[j],ls2[j]\n\t\t\tif a > b:\n\t\t\t\twhile mv > 0 and ls1[j] < ls2[j]:\n\t\t\t\t\tls2[j] += 1\n\t\t\t\t\tls1[j] -= 1\n\t\t\t\t\tmv -= 1\n\t\t\t\t\tcnt += 1\n\nprint cnt\n\t\t\n\n\n\t\t\t \n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc1=[0]*6\nc2=[0]*6\nfor i in range (n):\n c1[a[i]]+=1\n c2[b[i]]+=1\nx=0\nfor i in range(6):\n if((c1[i]+c2[i])%2 !=0):\n print(-1)\n exit()\n\n else:\n x+=(abs(c1[i]-c2[i])//2)\n\nprint(x//2)\n"}, {"source_code": "from collections import defaultdict\n\nn = int(input())\naa = map(int, input().split())\nbb = map(int, input().split())\n\nq = defaultdict(int)\nw = defaultdict(int)\ne = defaultdict(int)\n\nfor a in aa:\n q[a] += 1\n e[a] += 1\n\nfor b in bb:\n w[b] += 1\n e[b] += 1\n\nans = 0\nfor i in range(1, 6):\n if e[i] % 2 != 0:\n ans = -1\n break\n ans += abs(q[i] - (e[i] // 2))\n\nprint(ans // 2)\n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nn = int(raw_input())\nl1 = map(int, raw_input().split())\nl2 = map(int, raw_input().split())\nl1.sort()\nl3 = l1 + l2\nl4 = []\nmark = 0\nfor x in xrange(1, 6):\n if l3.count(x) % 2 == 0:\n for y in xrange(l3.count(x) / 2):\n l4.append(x)\n else:\n mark = -1\n break\nif mark == -1:\n pass\nelse:\n mark = 0\n l4.sort()\n for x in xrange(1,6):\n if l4.count(x) <= l1.count(x):\n pass\n else:\n mark += l4.count(x) - l1.count(x)\nprint mark\n"}, {"source_code": "n = int(input())\nG = {}\ns = 0\n\nfor i in range(1, 6):\n G[i] = 0\n \nfor x in map(int, input().split()):\n G[x] += 1\n \nfor x in map(int, input().split()):\n G[x] -= 1\n\nfor i in range(1,6):\n if G[i] % 2 == 1:\n print(-1)\n exit(0)\n s += abs(G[i])\n \nprint(s // 4)"}, {"source_code": "import sys\nn=int(sys.stdin.readline())\nA=list(map(int,sys.stdin.readline().split()))\nB=list(map(int,sys.stdin.readline().split()))\nl1=[0]*6\nl2=[0]*6\nfor i in range(n):\n l1[A[i]]+=1 \n l2[B[i]]+=1 \nflag=True\nans=0\nfor i in range(1,6):\n x=l1[i]+l2[i]\n if x%2!=0:\n flag=False\n break\n ans+=abs(x//2-l1[i])\nif flag:\n print(ans//2)\nelse:\n print(-1)\n "}, {"source_code": "import math as mt \nimport sys,string\ninput=sys.stdin.readline\nimport random\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\nn=I()\na=L()\nb=L()\nda=defaultdict(int)\ndb=defaultdict(int)\nfor i in a:\n da[i]+=1\nfor j in b:\n db[j]+=1\ns=list(set(list(da.keys())+list(db.keys())))\n\nfor i in s:\n if((da[i]+db[i])%2==1):\n print(-1)\n exit()\n\nans=0\nfor i in set(a):\n if(da[i]>(da[i]+db[i])//2):\n # print(i)\n p=(da[i]+db[i])//2\n ans+=abs(p-da[i])\nfor i in set(b):\n if(db[i]>(da[i]+db[i])//2):\n # print(i)\n p=(da[i]+db[i])//2\n ans+=abs(p-db[i])\n\nprint(ans//2)\n"}, {"source_code": "x = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ns = a + b\nt = list(set(s))\nk = 0\nk1 = 0\nflag = 0\nd = {}\nfor i in range(len(t)):\n\tr = a.count(t[i])\n\tr1 = b.count(t[i])\n\tif (r-r1)%2 == 1 or (r1-r)%2 == 1:\n\t\tprint(-1)\n\t\tflag = 1\n\t\tbreak\n\telif r > r1:\n\t\tk = k + r - r1\n\telse:\n\t\tk1 = k1 + r1 - r\nif k%2 == 0 and k == k1 and flag == 0:\n\tprint(k//2)\nelif flag == 0:\n\tprint(-1)"}, {"source_code": "l=lambda:map(int,raw_input().split())\nn=input()\na1=l()\na2=l()\nd1={}\nd2={}\nfor v in a1:\n d1[v]=d1.get(v,0)+1\nfor v in a2:\n d2[v]=d2.get(v,0)+1\nfor k in range(1,6):\n if abs(d1.get(k,0)+d2.get(k,0))%2<>0:\n print -1\n exit() \nprint sum(abs(d1.get(k,0)-d2.get(k,0))/2 for k in range(1,6))/2"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nfa=[0]*(6)\nfb=[0]*(6)\nfor i in a:\n\tfa[i]+=1\nfor i in b:\n\tfb[i]+=1\nans=0\nfor i in range(6):\n\txx=fa[i]+fb[i]\n\tif xx%2==1:\n\t\tprint(-1)\n\t\texit()\n\telse:\n\t\txx=xx//2\n\t\tans+=min(abs(xx-fa[i]),abs(xx-fb[i]))\nprint(ans//2)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\nfor i in range(1, 6):\n x, y = a.count(i), b.count(i)\n if (x+y) & 1:\n ans = -1\n break\n ans += abs(x - y) // 2\nprint(ans//2)\n"}], "negative_code": [{"source_code": "# read data\nN = int( raw_input())\ngroupA_raw = map( int, raw_input().split() )\ngroupB_raw = map( int, raw_input().split() )\n\ngroupA = [0]*5\ngroupB = [0]*5\n\n# count amount of students with all ratings\nfor i in range(N):\n\tgroupA[ groupA_raw[i] - 1 ] += 1\n\tgroupB[ groupB_raw[i] - 1 ] += 1\n\n\nsum_d = 0\nsum_abs_d = 0\ndifference = [0]*5\nfor i in range(5):\n\tdifference[i] = (groupA[i] - groupB[i]) // 2\n\tsum_d += difference[i] \n\tsum_abs_d += abs( difference[i] )\n\n#print difference\n\nexch = sum_abs_d // 2\n\nif sum_d != 0:\n\tprint -1\n\texit(0)\n\nif exch == 0:\n\tprint -1\n\texit(0)\n\nif exch > N:\n\tprint -1\n\texit(0)\n\nprint exch\t\n\t\n"}, {"source_code": "import sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\n# region fastio\n \nBUFSIZE = 8192\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# ------------------------------\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = {}\n d = {}\n for i in range(n):\n if a[i] in c:\n c[a[i]] += 1\n else:\n c[a[i]] = 1\n for i in range(n):\n if b[i] in d:\n d[b[i]] += 1\n else:\n d[b[i]] = 1\n #print(c)\n #print(d)\n e = 0\n l = 0\n #g = []\n #h = []\n k = []\n m = 0\n if n == 1:\n if a == b:\n print(0)\n else:\n print(-1)\n else:\n for i in c:\n if i in d:\n m += 1\n if c[i] == d[i]:\n continue\n else:\n e = abs(c[i]+d[i])\n if e%2 == 0:\n l = e//2\n k.append(l//2)\n #g.append(e//2)\n else:\n e = abs(c[i])\n if e%2 == 0:\n l = e//2\n k.append(l)\n m = m//2\n g = sum(k)-m\n if g == 0:\n g = -1\n print(g)\nif __name__ == \"__main__\":\n main()\n "}, {"source_code": "from sys import stdin, stdout\n\nclass1 = []\nclass2 = []\n\ndata_length = int(stdin.readline())\n\nc1 = map(int, stdin.readline().split())\nc2 = map(int, stdin.readline().split())\n\nc1d = {}\nc2d = {}\n\nfor mark in c1:\n c1d[mark] = c1d.get(mark, 0) + 1\n\nfor mark in c2:\n c2d[mark] = c2d.get(mark, 0) + 1\n\nperm = 0\n\nfor mark in range(1, 6):\n if (c1d.get(mark, 0) + c2d.get(mark, 0)) % 2 == 1:\n stdout.write('-1' + '\\n')\n\ndiff = 0\nfor mark in range(1, 6):\n diff += abs(c1d.get(mark, 0) - c2d.get(mark, 0))\n\nstdout.write(str(diff//4))\n"}, {"source_code": "from collections import Counter\nn = int(input())\nclass_a = [int(x) for x in input().split()]\nclass_b = [int(x) for x in input().split()]\nA = Counter(class_a)\nB = Counter(class_b)\ndelta = 0\nfor grade in range(1, 6):\n\tif (A[grade] + B[grade]) % 2 == 1:\n\t\tprint(-1)\n\t\texit()\n\tdelta += abs(A[grade] - B[grade])\nprint(delta / 2)\n"}, {"source_code": "#!/usr/bin/env python\n\nn=int(input())\nA=map(str,raw_input().split(' '))\nB=map(str,raw_input().split(' '))\n\nNA=[0]*5\nNB=[0]*5\nfinal=[0]*5\nfor i in range(5):\n NA[i]=A.count(str(i+1))\n NB[i]=B.count(str(i+1))\n print NA[i]\n print NB[i]\n print \"-----\"\n\n\nresult=0\nfor i in range(5):\n if (NA[i]+NB[i])%2==1:\n result=-1\n break\n else:\n final[i]=(NA[i]+NB[i])/2\n print final[i]\ntotal=0\nfor i in range(5):\n total+=abs(NA[i]-final[i])\n\nprint \"answer\"\nif result==-1:\n print result\nelse:\n print total/2\n"}, {"source_code": "n = int(input())\nx1 = list(map(int, input().split()))\nx2 = list(map(int, input().split()))\nans = 0\ncount1 = [0,0,0,0,0,0]\ncount2 = [0,0,0,0,0,0]\nflag = True\nfor i in range(1, 6):\n s = x1.count(i) + x2.count(i)\n count1[i] = x1.count(i)\n count2[i] = x2.count(i)\n if(s%2==1):\n flag = False\n break\n\nif(flag):\n x1.sort()\n x2.sort()\n for i in range(1, 6):\n if(count1[i]==count2[i]):\n for j in range(count1[i]):\n x1.remove(i)\n x2.remove(i)\n l = len(x1)\n for i in range(l):\n if(x1[i] != x2[i]):\n ans +=1\n print(ans//2)\nelse:\n print(-1)"}, {"source_code": "n=input()\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=(abs(a.count(1)-b.count(1))+abs(a.count(2)-b.count(2))+abs(a.count(3)-b.count(3))+abs(a.count(4)-b.count(4))+abs(a.count(5)-b.count(5)))/4\nif ans==int(ans):\n print(ans)\nelse:\n print(\"-1\")"}, {"source_code": "import sys\nn=int(sys.stdin.readline())\nA=list(map(int,sys.stdin.readline().split()))\nB=list(map(int,sys.stdin.readline().split()))\nl1=[0]*6\nl2=[0]*6\nfor i in range(n):\n l1[A[i]]+=1 \n l2[B[i]]+=1 \nflag=True\nans=0\nfor i in range(1,6):\n x=l1[i]+l2[i]\n if x%2!=0:\n flag=False\n break\n ans+=abs(x-l1[i])\nif flag:\n print(ans//2)\nelse:\n print(-1)\n \n \n \n\n "}, {"source_code": "import sys\nfrom math import ceil\nread=lambda:sys.stdin.readline().strip()\nwrite=lambda x:sys.stdout.write(x+\"\\n\")\nN=int(read())\nSA=list(map(int, read().split()));\nSB=list(map(int, read().split()));\narrA = [0 for _ in range(5)]\narrB = [0 for _ in range(5)]\nfor i in range(N):\n arrA[SA[i]-1] += 1\n arrB[SB[i]-1] += 1\nresult = 0\nfor i in range(5):\n s = arrA[i] + arrB[i]\n diff = abs(arrA[i]-arrB[i])\n diff /= 2\n if s % 2:\n result = -1\n break\n result += diff\n\nif result > 0:\n result = int(ceil(result/2))\n\nwrite(str(result))\n "}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\na = list(map(int, sys.stdin.readline().split()))\nb = list(map(int, sys.stdin.readline().split()))\nans = 0\n\nam = [0] * 5\nbm = [0] * 5\n\nfor i in a:\n am[i - 1] += 1\nfor i in b:\n bm[i - 1] += 1\n\nfor i in range(5):\n if am[i] != bm[i]:\n ans += abs(am[i] - bm[i]) // 2\n\nprint(ans // 2)\n"}, {"source_code": "n = int(raw_input())\nA = map(int, raw_input().split())\nB = map(int, raw_input().split())\n\ncant_intercambios = 0\ndica = {}\nfor a in A:\n if a not in dica:\n dica[a] = 0\n dica[a] += 1\n \ndicb = {}\nfor b in B:\n if b not in dicb:\n dicb[b] = 0\n dicb[b] += 1\n\nprint dica, dicb\n\nfor nota in dica:\n if dica[nota] % 2 == 0:\n if dicb[nota] % 2 == 0:\n cant_intercambios += (abs(dicb[nota] - dica[nota])) / 2\n else:\n print -1\n break\n else:\n if dicb[nota] % 2 != 0:\n cant_intercambios += (abs(dicb[nota] - dica[nota])) / 2\n else:\n print -1\n break\n \nprint cant_intercambios / 2\n\n \n\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split(' ')]\nb = [int(x) for x in input().split(' ')]\n\na_dict = {i: 0 for i in range(1, 6)}\nb_dict = {i: 0 for i in range(1, 6)}\n\nfor s in a:\n if s in a_dict:\n a_dict[s] += 1\n else:\n a_dict[s] = 1\n\nfor t in b:\n if t in b_dict:\n b_dict[t] += 1\n else:\n b_dict[t] = 1\nans = 0\nfor i in range(1, 6):\n if a_dict[i] + b_dict[i] % 2 == 1:\n ans = -2\n else:\n ans += abs(a_dict[i] - b_dict[i]) // 2\n\nans = ans // 2\nprint(ans)"}, {"source_code": "n = int(input())\na = input()\nb = input()\nw = 0\ns = 0\n\nleva = []\nlevb = []\n\nA = [int(s) for s in a.split(' ')]\nB = [int(s) for s in b.split(' ')]\n\n\nfor k in range(5):\n leva.append(0)\n levb.append(0)\n\n for i in range(n):\n if A[i] == k+1:\n leva[k] += 1\n if B[i] == k+1:\n levb[k] += 1 \n\nfor i in range(5):\n w += (leva[i] - levb[i])/2\n s += abs((leva[i] - levb[i])/4)\n \n\nif w == 0 and s % 1 ==0:\n print(int(s))\nelse:\n print(-1) \n \n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().strip().split(' '))\nb = map(int, raw_input().strip().split(' '))\n\ncountA = [0 for i in xrange(6)]\ncountB = [0 for i in xrange(6)]\nfor i in a:\n countA[i] += 1\n\nfor i in b:\n countB[i] += 1\n\nans = 0\nfor i in xrange(6):\n ans += abs(countA[i] - countB[i])\n\nif ans % 4 == 0:\n print ans / 4\nelse:\n print -1"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ncount = [0 for x in range(100)]\n\nfor x in a:\n count[x] += 1\nfor x in b:\n count[x] -= 1\n\nfor x in range(100):\n if count[x] < 0:\n count[x] = abs(count[x])\n\ntotal = sum(count) // 2\nif total % 2 != 0:\n print(-1)\nelse:\n print(total // 2)"}, {"source_code": "n = int(input())\n#m = input().split() #list\n#[a, b, c] = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\n\n\nA_grades = [0, 0, 0, 0, 0]\nB_grades = [0, 0, 0, 0, 0]\n\n\nfor i in range(0, n):\n A_grades[A[i]-1] += 1\n B_grades[B[i]-1] += 1\n\n\n\n#Check if such changes can happen \nfor i in range(0, 5):\n if (A_grades[i] + B_grades[i]) % 2 != 0:\n print(-1)\n \n \ndif = 0\nfor i in range(0, 5):\n dif += abs(A_grades[i]- B_grades[i])\n \nprint(dif // 4)\n\n "}, {"source_code": "input()\na=[0]*6\nfor i in[1,-1]:\n for x in map(int,input().split()):a[x]+=i \ns=sum(abs(x)for x in a)\nprint([s//4,-1][s%4>0])"}, {"source_code": "'''\nhttp://codeforces.com/problemset/problem/779/A\n'''\n\nn = int(input())\ngroupA = list(map(int, input().split()))\ngroupB = list(map(int, input().split()))\n\ndef num_switches(n, groupA, groupB):\n diff = [0, 0, 0, 0, 0]\n for score in range(1, 6):\n if abs(groupA.count(score) - groupB.count(score)) % 2 == 1:\n return -1\n else:\n diff[score - 1] = abs(groupA.count(score) - groupB.count(score))\n if sum(diff) % 4 != 0:\n return -1\n else:\n return sum(diff) / 4\n\n\n\nprint(num_switches(n, groupA, groupB))\n"}, {"source_code": "def pupils(lst1, lst2):\n count = 0\n for i in range(1, 6):\n if (lst1[i] + lst2[i]) % 2 != 0:\n return -1\n else:\n t = abs(lst1[i] - lst2[i]) // 2\n count += t\n if count % 2 != 0:\n return -1\n return count // 2\n\n\nn = int(input())\na = [int(j) for j in input().split()]\nb = [int(z) for z in input().split()]\nprint(pupils(a, b))\n"}, {"source_code": "n=int(input())\nl1=[int(x) for x in input().split()]\nl2=[int(x) for x in input().split()]\na1=a2=b1=b2=c1=c2=d1=d2=e1=e2=0\nfor i in range(len(l1)):\n if l1[i]==1:\n a1+=1\n elif l1[i]==2:\n b1+=1\n elif l1[i]==3:\n c1+=1\n elif l1[i]==4:\n d1+=1\n else:\n e1+=1\n if l2[i]==1:\n a2+=1\n elif l2[i]==2:\n b2+=1\n elif l2[i]==3:\n c2+=1\n elif l2[i]==4:\n d2+=1\n else:\n e2+=1\nif (a1+a2)%2!=0 or (b1+b2)%2!=0 or (c1+c2)%2!=0 or (d1+d2)%2!=0 or (e1+e2)%2!=0:\n print(-1)\nelse:\n m=max(abs(a1-a2), abs(b1-b2))\n m=max(m,abs(c1-c2))\n m=max(m,abs(d1-d2))\n m=max(m,abs(e1-e2))\n print(m//2)"}, {"source_code": "x = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ns = a + b\nt = list(set(s))\nk = 0\nk1 = 0\nflag = 0\nd = {}\nfor i in range(len(t)):\n\tr = a.count(t[i])\n\tr1 = b.count(t[i])\n\tif (r-r1)%2 == 1 or (r1-r)%2 == 1:\n\t\tprint(-1)\n\t\tk = 1\n\telif r > r1:\n\t\tk = k + r - r1\n\telse:\n\t\tk1 = k1 + r1 - r\nif k%2 == 0 and k == k1 and flag == 0:\n\tprint(k//2)\nelif flag == 0:\n\tprint(-1)"}, {"source_code": "input()\na=[0]*6\nfor i in[1,-1]:\n for x in map(int,input().split()):a[x]+=i \ns=sum(abs(x)for x in a)\nprint([s//4,-1][s%4>0])"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().strip().split(' '))\nb = map(int, raw_input().strip().split(' '))\n\ncountA = [0 for i in xrange(6)]\ncountB = [0 for i in xrange(6)]\nfor i in a:\n countA[i] += 1\n\nfor i in b:\n countB[i] += 1\n\nans = 0\nfor i in xrange(6):\n if countA[i] + countB[i] % 2 == 1:\n print -1\n exit(0)\n diff = abs(countA[i] - countB[i])\n ans += diff / 2\n\n\nprint ans / 2"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl1=list(map(int,input().split()))\nk=0\np=[]\np1=[]\nfor i in range(5) :\n p.append(l.count(i+1))\n p1.append(l1.count(i+1))\nc=0\nwhile p!=p1 and c==0 :\n for i in range(5) :\n \n if p[i]!=p1[i] :\n \n if p[i]<p1[i] :\n p[i]=p[i]+1\n p1[i]=p1[i]-1\n if abs(p[i]-p1[i])%2!=0 :\n c=1\n break\n else :\n if p[i]>p1[i] :\n p[i]=p[i]-1\n p1[i]=p1[i]+1\n if abs(p[i]-p1[i])%2!=0 :\n c=1\n break\n \n for j in range(i+1,5) :\n if p[j]!=p1[j] :\n if p[j]!=p1[j] :\n if p[j]<p1[j] :\n p[j]=p[j]+1\n p1[j]=p1[j]-1\n if abs(p[j]-p1[j])%2!=0 :\n c=1\n break\n else :\n if p[j]>p1[j] :\n p[j]=p[j]-1\n p1[j]=p1[j]+1\n if abs(p[j]-p1[j])%2!=0 :\n c=1\n break\n k=k+1\nif c==0 :\n print(k)\nelse :\n print(-1)\n \n \n \n \n \n \n \n"}, {"source_code": "import sys\nn =int(input())\na =list(map(int,input().split()))\nb =list(map(int,input().split()))\nspecial = 0\nlcng =rcng=0\nfor j in range(1,6):\n l = a.count(j)\n r = b.count(j)\n\n if(l != r):\n if((l == 1 and r == 0) or (r == 1 and l == 0)):\n special = 1\n elif(l > r and special != 1):\n lcng += int(l -((l + r)/2))\n else:\n rcng += int(r -((l + r)/2))\n\n\nif(lcng != rcng or special == 1):\n print(\"-1\")\nelse:\n print(lcng)"}, {"source_code": "#!/usr/bin/env python\n\nn=int(input())\nA=map(str,raw_input().split(' '))\nB=map(str,raw_input().split(' '))\n\nNA=[0]*5\nNB=[0]*5\nfinal=[0]*5\nfor i in range(5):\n NA[i]=A.count(str(i+1))\n NB[i]=B.count(str(i+1))\n print NA[i]\n print NB[i]\n print \"-----\"\n\n\nresult=0\nfor i in range(5):\n if (NA[i]+NB[i])%2==1:\n result=-1\n break\n else:\n final[i]=(NA[i]+NB[i])/2\n print final[i]\ntotal=0\nfor i in range(5):\n total+=abs(NA[i]-final[i])\n\nprint \"answer\"\nif result==-1:\n print result\nelse:\n print total/2\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split(' ')]\nb = [int(x) for x in input().split(' ')]\n\na_dict = {i: 0 for i in range(1, 6)}\nb_dict = {i: 0 for i in range(1, 6)}\n\nfor s in a:\n if s in a_dict:\n a_dict[s] += 1\n else:\n a_dict[s] = 1\n\nfor t in b:\n if t in b_dict:\n b_dict[t] += 1\n else:\n b_dict[t] = 1\nans = 0\nfor i in range(1, 6):\n if a_dict[i] + b_dict[i] % 2 == 1:\n ans = -2\n else:\n ans += abs(a_dict[i] - b_dict[i]) // 2\n\nans = ans // 2\nprint(ans)"}, {"source_code": "n = input()\nf = list(map(str, input().split()))\ns = list(map(str, input().split()))\n\n\nif abs(f.count('1')-s.count('1'))%2==0 and abs(f.count('2')-s.count('2'))%2==0 and abs(f.count('3')-s.count('3'))%2==0 and abs(f.count('4')-s.count('4'))%2==0 and abs(f.count('5')-s.count('5'))%2==0 :\n\tprint(int(abs((f.count('1')-s.count('1')) + abs(f.count('2')-s.count('2')) + abs(f.count('3')-s.count('3')) + abs(f.count('4')-s.count('4')) + abs(f.count('5')-s.count('5')))/4))\nelse :\n\tprint(-1)"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\nb = map(int,stdin.readline().split())\nfir = {}\nsec = {}\ntot = {}\nfor i in a:\n fir[i] = fir.get(i,0)+1\n tot[i] = tot.get(i,0) + 1\nfor i in b:\n sec[i] = sec.get(i,0) + 1\n tot[i] = tot.get(i,0) + 1\nvalid = 1\nfor i in xrange(1,6):\n if tot.get(i,0)%2:\n valid = 0\nans = -1\nif valid:\n cur = 0\n for i in fir:\n cur += (tot.get(i,0) - fir.get(i,0))/2\n ans = cur\nprint ans\n \n"}, {"source_code": "\nsteps = 0\n\nn = int(input())\nAg = {}\nBg = {}\ns = 0\n\nfor i in range(1, 6):\n Ag[i] = 0\n Bg[i] = 0\n \nfor x in map(int, input().split()):\n Ag[x] += 1\n \nfor x in map(int, input().split()):\n Bg[x] += 1\n\nfor i in range(1,6):\n if Ag[i] + Bg[i] % 2 == 1:\n print(-1)\n exit(0)\n s += abs(Ag[i] - Bg[i])\n \nprint(s // 4)"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\nfor i in range(1,6):\n if a.count(i)+b.count(i)%2==1:\n print(-1)\n exit()\nans=0\nfor i in range(1,6):\n ans+=abs(a.count(i)-b.count(i))\nprint(ans//4)"}, {"source_code": "n=int(input())\na=[int(z) for z in input().split()]\nb=[int(z) for z in input().split()]\nc1,d1,e1,f1,g1=0,0,0,0,0\nc2,d2,e2,f2,g2=0,0,0,0,0\nfor i in a:\n if i==1:\n c1+=1\n elif i==2:\n d1+=1\n elif i==3:\n e1+=1\n elif i==4:\n f1+=1\n else:\n g1+=1\nfor i in b:\n if i==1:\n c2+=1\n elif i==2:\n d2+=1\n elif i==3:\n e2+=1\n elif i==4:\n f2+=1\n else:\n g2+=1\nif (c1+c2)&1 or (d1+d2)&1 or (e1+e2)&1 or (f1+f2)&1 or (g1+g2)&1:\n print(-1)\nelse:\n print(abs((c1+c2)//2-c1)+abs((d1+d2)//2-d1)+abs((e1+e2)//2-e1)+abs((f1+f2)//2-f1)+abs((g1+g2)//2-g1))\n\n\n"}, {"source_code": "import sys\n\nsteps = 0\n\nn = int(input())\nAg = {}\nBg = {}\ns = 0\n\nfor i in range(1, 6):\n Ag[i] = 0\n Bg[i] = 0\n \nfor x in map(int, input().split()):\n Ag[x] += 1\n \nfor x in map(int, input().split()):\n Bg[x] += 1\n\nfor i in range(1,6):\n if Ag[i] + Bg[i] % 2 == 1:\n print(-1)\n sys.exit(0)\n s += abs(Ag[i] - Bg[i])\n \nprint(s / 4)"}, {"source_code": "n = input()\n\na = map(int, raw_input().split())\n\nb = map(int, raw_input().split())\n\nda = {}\ndb = {}\nfor i in xrange(1,6):\n da[i] = a.count(i)\n db[i] = b.count(i)\n\n\nc = 0\nfor i in xrange(1,6):\n if da[i]==db[i]:\n pass\n else:\n c+=abs(da[i]-db[i])\nif c%4!=0:\n print -1\nelse:\n print c/4\n"}, {"source_code": "from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nca = Counter(a)\ncb = Counter(b)\n\ndef solve():\n ans = 0\n balance = {}\n \n for mark in range(1, 6):\n c1 = ca.get(mark, 0)\n c2 = cb.get(mark, 0)\n s = c1 + c2\n if s % 2 != 0:\n return -1\n balance[mark] = c1 - (s / 2)\n \n if sum(balance.values()) != 0:\n return -1\n \n return sum(map(abs, balance.values())) / 2\n \n \nprint (solve())\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\nb = map(int,stdin.readline().split())\nfir = {}\nsec = {}\ntot = {}\nfor i in a:\n fir[i] = fir.get(i,0)+1\n tot[i] = tot.get(i,0) + 1\nfor i in b:\n sec[i] = sec.get(i,0) + 1\n tot[i] = tot.get(i,0) + 1\nvalid = 1\nfor i in xrange(1,6):\n if tot.get(i,0)%2:\n valid = 0\nans = -1\nif valid:\n cur = 0\n for i in fir:\n cur += (tot.get(i,0) - fir.get(i,0))/2\n ans = cur\nprint ans\n \n"}, {"source_code": "import sys\nn = int(raw_input())\ns = map(int,raw_input().split())\nd = map(int,raw_input().split())\ncount = 0\nx = [0,0,0,0,0]\ny = [0,0,0,0,0]\ni = 0\nwhile(i<n):\n if(s[i]==1):\n x[0] = x[0] + 1\n if(d[i] ==1):\n y[0] = y[0]+1\n if(s[i]==2):\n x[1] = x[1] + 1\n if(d[i] ==2):\n y[1] = y[1]+1 \n if(s[i]==3):\n x[2] = x[2] + 1\n if(d[i] ==3):\n y[2] = y[2]+1\n if(s[i]==4):\n x[3] = x[3] + 1\n if(d[i] ==4):\n y[3] = y[3]+1\n if(s[i]==5):\n x[4] = x[4] + 1\n if(d[i] ==5):\n y[4] = y[4]+1\n i = i + 1\nj = 0\n\nwhile(j<5):\n q = (x[j]+y[j])/2\n if(q-x[j]>0):\n count = count + q-x[j]\n if(q-y[j]>0):\n count = count + q-y[j]\n j = j + 1\nif(count ==0):\n print -1\n sys.exit()\nprint count/2 \n \n"}, {"source_code": "import math\n\na = raw_input()\na = int(a)\n\nb = raw_input()\nc = raw_input()\n\nb = b.split()\nc = c.split()\n\nb = map(int, b)\nc = map(int, c)\n\ncount1 = 0\ncount2 = 0\ncount3 = 0\ncount4 = 0\ncount5 = 0\nbount1 = 0\nbount2 = 0\nbount3 = 0\nbount4 = 0\nbount5 = 0\n\nfor i in range(a):\n if b[i] == 1:\n bount1 += 1\n elif b[i] == 2:\n bount2 += 1\n elif b[i] == 3:\n bount3 += 1\n elif b[i] == 4:\n bount4 += 1\n elif b[i] == 5:\n bount5 += 1\n\nfor i in range(a):\n if c[i] == 1:\n count1 += 1\n elif c[i] == 2:\n count2 += 1\n elif c[i] == 3:\n count3 += 1\n elif c[i] == 4:\n count4 += 1\n elif c[i] == 5:\n count5 += 1\n\nif bount1 + count1 % 2 == 1:\n print -1\nelif bount2 + count2 % 2 == 1:\n print -1\nelif bount3 + count3 % 2 == 1:\n print -1\nelif bount4 + count4 % 2 == 1:\n print -1\nelif bount5 + count5 % 2 == 1:\n print -1\nelse:\n count = 0\n if bount1 > (bount1 + count1)/2:\n count += bount1 - (bount1 + count1)/2\n if bount2 > (bount2 + count2)/2:\n count += bount2 - (bount2 + count2)/2\n if bount3 > (bount3 + count3)/2:\n count += bount3 - (bount3 + count3)/2\n if bount4 > (bount4 + count4)/2:\n count += bount4 - (bount4 + count4)/2\n if bount5 > (bount5 + count5)/2:\n count += bount5 - (bount5 + count5)/2\n print count\n"}, {"source_code": "import sys\n\nN = sys.stdin.readline()\nA = map(int, sys.stdin.readline().split())\nB = map(int, sys.stdin.readline().split())\na_maps = {}\nb_maps = {}\nall_keys = set()\ntotal_diff = 0\nfor idx in range(len(A)):\n if A[idx] in a_maps:\n a_maps[A[idx]] += 1\n else:\n a_maps[A[idx]] = 1\n all_keys.add(A[idx])\n if B[idx] in b_maps:\n b_maps[B[idx]] += 1\n else:\n b_maps[B[idx]] = 1\n all_keys.add(B[idx])\n\ntotal_diff = 0\nfor key in sorted(list(all_keys)):\n a = a_maps[key] if key in a_maps else 0\n b = b_maps[key] if key in b_maps else 0\n diff = a-b if a > b else b-a\n total_diff += diff\nans = total_diff / 4 if total_diff % 4 == 0 else -1\nprint ans\n"}, {"source_code": "from collections import Counter\n\nn = int(raw_input())\na = map(int, raw_input().split(' '))\nb = map(int, raw_input().split(' '))\n\nca = Counter(a)\ncb = Counter(b)\n\ndef solve():\n ans = 0\n balance = {}\n \n for mark in xrange(1, 6):\n c1 = ca.get(mark, 0)\n c2 = cb.get(mark, 0)\n s = c1 + c2\n if s % 2 != 0:\n return -1\n balance[mark] = (s / 2) * (-1 if c1 > c2 else 1)\n \n for mark1 in xrange(1, 5):\n if balance[mark1] == 0:\n continue\n for mark2 in xrange(mark1, 6):\n if balance[mark2] == -balance[mark1]:\n ans += abs(balance[mark1])\n balance[mark1] = balance[mark2] = 0\n break\n \n return ans\n \n \nprint solve()"}, {"source_code": "# import sys \n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out.out\",'w')\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=[0,0,0,0,0]\nfor i in a:\n\tc[i-1]+=1\nfor j in b:\n\tc[j-1]-=1\ns=0\nfor i in c:\n\ts+=abs(i)\nif s%2==0:\n\tx=s//2\n\tprint(x//2)\nelse:\n\tprint(-1)\t"}, {"source_code": "from collections import Counter\n\n\nn = int(input())\na = input().split(' ')\nb = input().split(' ')\naa = Counter()\nbb = Counter()\nfor x in aa:\n aa[x] += 1\nfor x in bb:\n bb[x] += 1\npossible = True\nmm = Counter()\nfor x in ('1', '2', '3', '4', '5'):\n if (aa[x] + bb[x]) % 2 != 0:\n possible = False\n else:\n mm[x] = (aa[x] + bb[x]) / 2\nif not possible:\n print('-1')\nelse:\n print(sum(abs(aa[x] - mm[x]) for x in ('1', '2', '3', '4', '5')))"}, {"source_code": "import sys\nn = int(raw_input())\ns = map(int,raw_input().split())\nd = map(int,raw_input().split())\ncount = 0\nx = [0,0,0,0,0]\ny = [0,0,0,0,0]\ni = 0\nwhile(i<n):\n if(s[i]==1):\n x[0] = x[0] + 1\n if(d[i] ==1):\n y[0] = y[0]+1\n if(s[i]==2):\n x[1] = x[1] + 1\n if(d[i] ==2):\n y[1] = y[1]+1 \n if(s[i]==3):\n x[2] = x[2] + 1\n if(d[i] ==3):\n y[2] = y[2]+1\n if(s[i]==4):\n x[3] = x[3] + 1\n if(d[i] ==4):\n y[3] = y[3]+1\n if(s[i]==5):\n x[4] = x[4] + 1\n if(d[i] ==5):\n y[4] = y[4]+1\n i = i + 1\nj = 0\nk = 0\nwhile(k<5):\n if((x[k]+y[k])%2!=0):\n print -1\n sys.exit()\n k = k + 1 \n \nwhile(j<5):\n q = (x[j]+y[j])/2\n if(q-x[j]>0):\n count = count + q-x[j]\n if(q-y[j]>0):\n count = count + q-y[j]\n j = j + 1\nif(count ==0):\n print -1\n sys.exit()\nprint count/2 \n \n"}, {"source_code": "def pupils(lst1, lst2):\n count = 0\n for i in range(len(lst1)):\n t = abs(lst1[i] - lst2[i])\n if t % 2 == 1:\n return -1\n count += t // 2\n return count // 2\n\n\nn = int(input())\na = [int(j) for j in input().split()]\nb = [int(z) for z in input().split()]\nprint(pupils(a, b))\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = [0,0,0,0,0]\nfor i in a:\n c[i - 1] += 1\nfor j in b:\n c[j - 1] -= 1\nc = [abs(i) for i in c]\nimport sys\nfor i in c:\n if i % 2:\n print(-1)\n sys.exit(0)\nprint(sum(c) / 2)"}, {"source_code": "from collections import Counter\n\nn = int(raw_input())\na = map(int, raw_input().split(' '))\nb = map(int, raw_input().split(' '))\n\nca = Counter(a)\ncb = Counter(b)\n\ndef solve():\n ans = 0\n balance = {}\n \n for mark in xrange(1, 6):\n c1 = ca.get(mark, 0)\n c2 = cb.get(mark, 0)\n s = c1 + c2\n if s % 2 != 0:\n return -1\n balance[mark] = (s / 2) * (-1 if c1 > c2 else 1)\n \n for mark1 in xrange(1, 5):\n if balance[mark1] == 0:\n continue\n for mark2 in xrange(mark1, 6):\n if balance[mark2] == -balance[mark1]:\n ans += abs(balance[mark1])\n balance[mark1] = balance[mark2] = 0\n break\n \n return ans\n \n \nprint solve()"}, {"source_code": "n = int(input())\nx1 = list(map(int, input().split()))\nx2 = list(map(int, input().split()))\nans = 0\ncount1 = [0,0,0,0,0,0]\ncount2 = [0,0,0,0,0,0]\nflag = True\nfor i in range(1, 6):\n s = x1.count(i) + x2.count(i)\n count1[i] = x1.count(i)\n count2[i] = x2.count(i)\n if(s%2==1):\n flag = False\n break\n\nif(flag):\n x1.sort()\n x2.sort()\n for i in range(1, 6):\n if(count1[i]==count2[i]):\n for j in range(count1[i]):\n x1.remove(i)\n x2.remove(i)\n l = len(x1)\n for i in range(l):\n if(x1[i] != x2[i]):\n ans +=1\n print(ans//2)\nelse:\n print(-1)"}, {"source_code": "'''\nhttp://codeforces.com/problemset/problem/779/A\n'''\n\nn = int(input())\ngroupA = list(map(int, input().split()))\ngroupB = list(map(int, input().split()))\n\ndef num_switches(n, groupA, groupB):\n #initialize number of switches needed\n switches = 0\n #loops through all possible scores\n for score in range(1, 6):\n freqA = groupA.count(score)\n freqB = groupB.count(score)\n freq_diff = freqA - freqB\n #checks if the desired destribution is possible\n if freq_diff % 2 == 1:\n return -1\n while freq_diff != 0:\n if freqA > freqB:\n #switches two values from A and B\n for i in range(n):\n if groupB[i] > score:\n switch = i\n switches += 1\n groupA[groupA.index(score)], groupB[switch] = groupB[switch], groupA[groupA.index(score)]\n else:\n #switches two values from A and B\n for i in range(n):\n if groupA[i] > score:\n switch = i\n switches += 1\n groupB[groupB.index(score)], groupA[switch] = groupA[switch], groupB[groupB.index(score)]\n #recomputes frequencies of the score in groupA and groupB\n freqA = groupA.count(score)\n freqB = groupB.count(score)\n freq_diff = freqA - freqB\n return switches\n\nprint(num_switches(n, groupA, groupB))\n"}, {"source_code": "#!/usr/bin/env python\n\nn=int(input())\nA=map(str,raw_input().split(' '))\nB=map(str,raw_input().split(' '))\n\nNA=[0]*5\nNB=[0]*5\nfinal=[0]*5\nfor i in range(5):\n NA[i]=A.count(str(i+1))\n NB[i]=B.count(str(i+1))\n print NA[i]\n print NB[i]\n print \"-----\"\n\n\nresult=0\nfor i in range(5):\n if (NA[i]+NB[i])%2==1:\n result=-1\n break\n else:\n final[i]=(NA[i]+NB[i])/2\n print final[i]\ntotal=0\nfor i in range(5):\n total+=abs(NA[i]-final[i])\n\nprint \"answer\"\nif result==-1:\n print result\nelse:\n print total/2\n"}, {"source_code": "\nsteps = 0\n\nn = int(input())\nAg = {}\nBg = {}\ns = 0\n\nfor i in range(1, 6):\n Ag[i] = 0\n Bg[i] = 0\n \nfor x in map(int, input().split()):\n Ag[x] += 1\n \nfor x in map(int, input().split()):\n Bg[x] += 1\n\nfor i in range(1,6):\n if Ag[i] + Bg[i] % 2 == 1:\n print(-1)\n exit(0)\n s += abs(Ag[i] - Bg[i])\n \nprint(s // 4)"}, {"source_code": "import sys\nn =int(input())\na =list(map(int,input().split()))\nb =list(map(int,input().split()))\nspecial = 0\nlcng =rcng=0\nfor j in range(1,6):\n l = a.count(j)\n r = b.count(j)\n\n if(l != r):\n if((l == 1 and r == 0) or (r == 1 and l == 0)):\n special = 1\n elif(l > r and special != 1):\n lcng += int(l -((l + r)/2))\n else:\n rcng += int(r -((l + r)/2))\n\n\nif(lcng != rcng or special == 1):\n print(\"-1\")\nelse:\n print(lcng)"}, {"source_code": "\nsteps = 0\n\nn = int(input())\nAg = {}\nBg = {}\ns = 0\n\nfor i in range(1, 6):\n Ag[i] = 0\n Bg[i] = 0\n \nfor x in map(int, input().split()):\n Ag[x] += 1\n \nfor x in map(int, input().split()):\n Bg[x] += 1\n\nfor i in range(1,6):\n if Ag[i] + Bg[i] % 2 == 1:\n print(-1)\n exit(0)\n s += abs(Ag[i] - Bg[i])\n \nprint(s // 4)"}, {"source_code": "import collections\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nacnt = collections.Counter(a)\nabcnt = collections.Counter(a+b)\nans = 0\nfor k, v in abcnt.items():\n if v & 1:\n ans = -1\n break\n ans += (v - acnt[k]) // 2\nprint(ans)\n"}, {"source_code": "import sys\nn = int(input())\na_group = list(map(int,input().split()))\nb_group = list(map(int,input().split()))\n\ncnt_a = cnt_b = 0\nfor i in range(1,6):\n c1 = a_group.count(i)\n c2 = b_group.count(i)\n if c1 > c2:\n cnt_a += c1 - (int((c1+c2)/2))\n elif c1 < c2:\n cnt_b += c2 - (int(c1+c2)/2)\n\nif cnt_a != cnt_b:\n print('-1')\nelse:\n print(cnt_a)"}, {"source_code": "n=input()\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=(abs(a.count(1)-b.count(1))+abs(a.count(2)-b.count(2))+abs(a.count(3)-b.count(3))+abs(a.count(4)-b.count(4))+abs(a.count(5)-b.count(5)))/4\nif ans==int(ans):\n print(int(ans))\nelse:\n print(\"-1\")"}, {"source_code": "n=int(input())\nperfsA,perfsB=[0,0,0,0,0],[0,0,0,0,0]\nlist1,list2=input().split(),input().split()\nfor num in list1:\n num=int(num)\n perfsA[num-1]+=1\nfor num in list2:\n num=int(num)\n perfsB[num-1]+=1\nswips=0\nfor i in range(0,5):\n if abs(perfsA[i]-perfsB[i])%2==1:\n swips=-1\n break\n swips+=abs(perfsB[i]-perfsA[i])/2\nprint(int(swips))"}, {"source_code": "from sys import stdin,stdout\nfrom collections import *\nfrom math import ceil, floor , log, gcd\nst=lambda:list(stdin.readline().strip())\nli=lambda:list(map(int,stdin.readline().split()))\nmp=lambda:map(int,stdin.readline().split())\ninp=lambda:int(stdin.readline())\npr=lambda n: stdout.write(str(n)+\"\\n\")\n \nmod=1000000007\nINF=float('inf')\n\ndef solve():\n n=inp()\n l=li()\n k=li()\n d=Counter(l)\n dd=Counter(l)\n ddd=Counter(l+k)\n for i in ddd:\n if ddd[i]&1:\n pr(-1)\n return\n ans=0\n for i in d:\n ans+=d[i]//2\n for i in dd:\n ans+=dd[i]//2\n pr(ans//2)\n \n \n \n\nfor _ in range(1):\n solve()\n"}, {"source_code": "x = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ns = a + b\nt = list(set(s))\nk = 0\nk1 = 0\nflag = 0\nd = {}\nfor i in range(len(t)):\n\tr = a.count(t[i])\n\tr1 = b.count(t[i])\n\tif (r-r1)%2 == 1 or (r1-r)%2 == 1:\n\t\tprint(-1)\n\t\tk = 1\n\telif r > r1:\n\t\tk = k + r - r1\n\telse:\n\t\tk1 = k1 + r1 - r\nif k%2 == 0 and k == k1 and flag == 0:\n\tprint(k//2)\nelif flag == 0:\n\tprint(-1)"}, {"source_code": "import sys\n\ndef solve(N, A_ranks, B_ranks):\n A = {}\n B = {}\n for rank in A_ranks:\n if rank in A:\n A[rank] += 1\n else:\n A[rank] = 1\n for rank in B_ranks:\n if rank in B:\n B[rank] += 1\n else:\n B[rank] = 1\n \n diffs = 0\n moves = 0\n total_keys = set(A.keys()) | set(B.keys())\n for key in total_keys:\n a_val = A[key] if key in A else 0\n b_val = B[key] if key in B else 0\n if a_val > b_val:\n A[key] = a_val - b_val\n B[key] = 0\n elif b_val > a_val:\n B[key] = b_val - a_val\n A[key] = 0\n\n a_count = 0\n b_count = 0\n for key in total_keys: \n a_val = A[key] if key in A else 0\n b_val = B[key] if key in B else 0\n if a_val > 0:\n if a_val % 2 == 0:\n a_count += a_val / 2\n else:\n return -1\n elif b_val > 0:\n if b_val % 2 == 0:\n b_count += b_val / 2\n else:\n return -1\n if a_count != b_count:\n return -1\n else:\n return a_count \n\nif __name__ == \"__main__\":\n N = int(sys.stdin.readline())\n A = map(int, sys.stdin.readline().split())\n B = map(int, sys.stdin.readline().split())\n print solve(N, A, B)\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ncount = [0 for x in range(100)]\n\nfor x in a:\n count[x] += 1\nfor x in b:\n count[x] -= 1\n\nfor x in range(100):\n if count[x] < 0:\n count[x] = abs(count[x])\n\ntotal = sum(count) // 2\nif total % 2 != 0:\n print(-1)\nelse:\n print(total // 2)"}, {"source_code": "from sys import stdin, stdout\n\nclass1 = []\nclass2 = []\n\ndata_length = int(stdin.readline())\n\nc1 = map(int, stdin.readline().split())\nc2 = map(int, stdin.readline().split())\n\nc1d = {}\nc2d = {}\n\nfor mark in c1:\n c1d[mark] = c1d.get(mark, 0) + 1\n\nfor mark in c2:\n c2d[mark] = c2d.get(mark, 0) + 1\n\nperm = 0\n\nfor mark in range(1, 6):\n if (c1d.get(mark, 0) + c2d.get(mark, 0)) % 2 == 1:\n stdout.write('-1' + '\\n')\n\ndiff = 0\nfor mark in range(1, 6):\n diff += abs(c1d.get(mark, 0) - c2d.get(mark, 0))\n\nstdout.write(str(diff//4))\n"}, {"source_code": "import math\n\na = raw_input()\na = int(a)\n\nb = raw_input()\nc = raw_input()\n\nb = b.split()\nc = c.split()\n\nb = map(int, b)\nc = map(int, c)\n\ncount1 = 0\ncount2 = 0\ncount3 = 0\ncount4 = 0\ncount5 = 0\nbount1 = 0\nbount2 = 0\nbount3 = 0\nbount4 = 0\nbount5 = 0\n\nfor i in range(a):\n if b[i] == 1:\n bount1 += 1\n elif b[i] == 2:\n bount2 += 1\n elif b[i] == 3:\n bount3 += 1\n elif b[i] == 4:\n bount4 += 1\n elif b[i] == 5:\n bount5 += 1\n\nfor i in range(a):\n if c[i] == 1:\n count1 += 1\n elif c[i] == 2:\n count2 += 1\n elif c[i] == 3:\n count3 += 1\n elif c[i] == 4:\n count4 += 1\n elif b[i] == 5:\n count5 += 1\n\nif bount1 + count1 % 2 == 1:\n print -1\nelif bount2 + count2 % 2 == 1:\n print -1\nelif bount3 + count3 % 2 == 1:\n print -1\nelif bount4 + count4 % 2 == 1:\n print -1\nelif bount5 + count5 % 2 == 1:\n print -1\nelse:\n count = 0\n if bount1 > (bount1 + count1)/2:\n count += bount1 - (bount1 + count1)/2\n if bount2 > (bount2 + count2)/2:\n count += bount2 - (bount2 + count2)/2\n if bount3 > (bount3 + count3)/2:\n count += bount3 - (bount3 + count3)/2\n if bount4 > (bount4 + count4)/2:\n count += bount4 - (bount4 + count4)/2\n if bount5 > (bount5 + count5)/2:\n count += bount5 - (bount5 + count5)/2\n print count\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nd=dict()\nfor i in a :\n if i in d:\n d[i]+=1\n else:\n d[i]=1\nfor i in b :\n if i in d:\n d[i]+=1\n else:\n d[i]=1\nval=list(d.values())\nx=True\nfor i in val :\n if i%2!=0:\n x=False\n break\ns=0\nif x:\n if len(val)==1:\n print(0)\n else:\n for i in list(set(a)):\n s=max(s+a.count(i)-(d[i]//2),1)\n print(s)\nelse:\n print(-1)"}, {"source_code": "import sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\n# region fastio\n \nBUFSIZE = 8192\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# ------------------------------\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = {}\n d = {}\n for i in range(n):\n if a[i] in c:\n c[a[i]] += 1\n else:\n c[a[i]] = 1\n for i in range(n):\n if b[i] in d:\n d[b[i]] += 1\n else:\n d[b[i]] = 1\n #print(c)\n #print(d)\n e = 0\n g = 0\n h = 0\n m = 0\n o = 0\n for i in c:\n if i in d:\n #e.append(i)\n if c[i] == d[i]:\n continue\n else:\n #m += 1\n if c[i] > d[i]:\n g = abs(c[i] - d[i])\n else:\n g = 0\n if(g%2 == 0):\n h += g//2\n else:\n h = -1\n break\n else:\n g = c[i]\n if(g%2 == 0):\n e += g//2\n else:\n e = -1\n break\n for i in d:\n if i not in c:\n g = d[i]\n if(g%2 == 0):\n o += g//2\n else:\n o = -1\n \n #print(h,e,m,o)\n if(h == -1 or e == -1 or o == -1):\n e = -1\n else:\n #if(h > 0 and m > 0):\n # h = h//m\n if e+h > o:\n e = h+e-o\n else:\n e = h+e\n print(e)\n\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "import collections\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nacnt = collections.Counter(a)\nabcnt = collections.Counter(a+b)\nans = 0\nfor k, v in abcnt.items():\n if v & 1:\n ans = -1\n break\n ans += (v - acnt[k]) // 2\nprint(ans)\n"}, {"source_code": "n = input()\n\na = map(int, raw_input().split())\n\nb = map(int, raw_input().split())\n\nda = {}\ndb = {}\nfor i in xrange(1,6):\n da[i] = a.count(i)\n db[i] = b.count(i)\n\n\nc = 0\nfor i in xrange(1,6):\n if da[i]==db[i]:\n pass\n else:\n c+=abs(da[i]-db[i])\nif c%4!=0:\n print -1\nelse:\n print c/4\n"}, {"source_code": "from collections import Counter\n\nn = int(raw_input())\na = map(int, raw_input().split(' '))\nb = map(int, raw_input().split(' '))\n\nca = Counter(a)\ncb = Counter(b)\n\ndef solve():\n ans = 0\n balance = {}\n \n for mark in xrange(1, 6):\n c1 = ca.get(mark, 0)\n c2 = cb.get(mark, 0)\n s = c1 + c2\n if s % 2 != 0:\n return -1\n balance[mark] = (s / 2) * (-1 if c1 > c2 else 1)\n \n for mark1 in xrange(1, 5):\n if balance[mark1] == 0:\n continue\n for mark2 in xrange(mark1, 6):\n if balance[mark2] == -balance[mark1]:\n ans += abs(balance[mark1])\n balance[mark1] = balance[mark2] = 0\n break\n \n return ans\n \n \nprint solve()"}, {"source_code": "x = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ns = a + b\nt = list(set(s))\nk = 0\nk1 = 0\nd = {}\nfor i in range(len(t)):\n\tr = a.count(t[i])\n\tr1 = b.count(t[i])\n\tif (r-r1)%2 == 1 or (r1-r)%2 == 1:\n\t\tprint(-1)\n\telif r > r1:\n\t\tk = k + r - r1\n\telse:\n\t\tk1 = k1 + r1 - r\nif k%2 == 0 and k == k1:\n\tprint(k//2)\nelse:\n\tprint(-1)"}, {"source_code": "n = int(input())\ncnt = [0]*5\nA = [int(i) - 1 for i in input().split()]\nB = [int(i) - 1 for i in input().split()]\nfor i in A:\n cnt[i] += 1\nfor i in B:\n cnt[i] -= 1\nres_4 = sum(abs(i) for i in cnt)\nif res_4 % 4 == 0:\n print(res_4 // 4)\nelse:\n print(-1)"}, {"source_code": "# 19:39\n# \u041f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0443\u0447\u0435\u043d\u0438\u043a\u043e\u0432. \u0412\u0445\u043e\u0434 - \u043e\u0446\u0435\u043d\u043a\u0438. \u0412\u044b\u0445\u043e\u0434 - \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0439\nn = int(input())\nclass_A = [int(x) for x in input().split(' ')]\nclass_B = [int(x) for x in input().split(' ')]\ncnt = [0 for x in range(1, 6)]\n\ndef main():\n\tfor mark in class_A:\n\t\tcnt[mark - 1] += 1\n\tfor mark in class_B:\n\t\tcnt[mark - 1] -= 1\n\tprint(cnt)\n\tfor mark in cnt:\n\t\tif mark % 2 != 0:\n\t\t\treturn -1\n\tc = 0\n\tfor mark in cnt:\n\t\tc += abs(mark)\n\treturn c // 4\n\nprint(main())\n"}, {"source_code": "from sys import stdin, stdout\n\nclass1 = []\nclass2 = []\n\ndata_length = int(stdin.readline())\n\nc1 = map(int, stdin.readline().split())\nc2 = map(int, stdin.readline().split())\n\nc1d = {}\nc2d = {}\n\nfor mark in c1:\n c1d[mark] = c1d.get(mark, 0) + 1\n\nfor mark in c2:\n c2d[mark] = c2d.get(mark, 0) + 1\n\nperm = 0\n\nfor mark in range(1, 6):\n if (c1d.get(mark, 0) + c2d.get(mark, 0)) % 2 == 1:\n stdout.write('-1' + '\\n')\n\ndiff = 0\nfor mark in range(1, 6):\n diff += abs(c1d.get(mark, 0) - c2d.get(mark, 0))\n\nstdout.write(str(diff//4)+'\\n')\n"}, {"source_code": "n = int(input())\nSum = 0\nclassA = list(map(int,input().split()))\nclassB =list(map(int,input().split()))\nw=False\nfor i in range(1,6) :\n if classA.count(i)+classB.count(i) %2 == 1:\n w=True\n break\n\n else:\n Sum += abs(classA.count(i) - classB.count(i))\n\nif w:\n print (-1)\n\nelse:\n print(Sum/4)"}, {"source_code": "##n = int(input())\n##a = list(map(int, input().split()))\n##print(' '.join(map(str, res)))\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nha = [0 for i in range(5)]\nhb = [0 for i in range(5)]\nfor i in range(n):\n ha[a[i]-1] += 1\n hb[b[i]-1] += 1\n\nres = 0\nused = [0 for i in range(5)]\nfor i in range(5):\n if used[i] == 0:\n for j in range(i+1, 5):\n if used[j] == 0:\n if ha[i] == hb[j] and hb[i] == ha[j] and (ha[i]+hb[i])%2 == 0:\n res += abs(ha[i]-(ha[i]+hb[i])//2)\n used[i] = 1\n used[j] = 1\n break\n\nfor i in range(5):\n if used[i] == 0 and ha[i] != hb[i]:\n print('-1')\n exit(0)\nprint(res)"}, {"source_code": "n = int(input())\na = input()\nb = input()\nw = 0\ns = 0\n\nleva = []\nlevb = []\n\nA = [int(s) for s in a.split()]\nB = [int(s) for s in b.split()]\n\n\nfor k in range(5):\n leva.append(0)\n levb.append(0)\n\n for i in range(n):\n if A[i] == k+1:\n leva[k] += 1\n if B[i] == k+1:\n levb[k] += 1 \n\nfor i in range(5):\n w += (leva[i] - levb[i])\n s += abs((leva[i] - levb[i])/4)\n \n\nif w == 0 and s % 1 == 0:\n print(int(s))\nelse:\n print(-1)\n"}, {"source_code": "n = input()\nf = list(map(int, input().split()))\ns = list(map(int, input().split()))\n\nif f.count('1')-s.count('1')%2==0 and f.count('2')-s.count('2')%2==0 and f.count('3')-s.count('3')%2==0 and f.count('4')-s.count('1')%2==0 and f.count('5')-s.count('5')%2==0 :\n\tprint((abs(f.count('1')-s.count('1')) + abs(f.count('2')-s.count('2')) + abs(f.count('3')-s.count('3')) + abs(f.count('4')-s.count('4')) + abs(f.count('5')-s.count('5')))/4)\nelse :\n\tprint(-1)"}, {"source_code": "#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nn = int(raw_input())\nl1 = map(int, raw_input().split())\nl2 = map(int, raw_input().split())\nl1.sort()\nl3 = l1 + l2\nl4 = []\nmark = 0\nfor x in xrange(1, 6):\n if l3.count(x) % 2 == 0:\n for y in xrange(l3.count(x) / 2):\n l4.append(x)\n else:\n mark = -1\n break\nif mark == -1:\n pass\nelse:\n mark = 0\n l4.sort()\n for x in xrange(n):\n if l4[x] == l1[x]:\n pass\n else:\n mark += 1\nprint mark\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nd=dict()\nfor i in a :\n if i in d:\n d[i]+=1\n else:\n d[i]=1\nfor i in b :\n if i in d:\n d[i]+=1\n else:\n d[i]=1\nval=list(d.values())\nx=True\nfor i in val :\n if i%2!=0:\n x=False\n break\ns=0\nif x:\n for i in list(set(a)):\n s=max(s+a.count(i)-(d[i]//2),1)\n print(s)\nelse:\n print(-1)"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\na = list(map(int, sys.stdin.readline().split()))\nb = list(map(int, sys.stdin.readline().split()))\nans = 0\n\nam = [0] * 5\nbm = [0] * 5\n\nfor i in a:\n am[i - 1] += 1\nfor i in b:\n bm[i - 1] += 1\n\nfor i in range(5):\n if am[i] != bm[i]:\n ans += abs(am[i] - bm[i]) // 2\n\nprint(ans // 2)\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split(' ')]\nb = [int(x) for x in input().split(' ')]\n\na_dict = {i: 0 for i in range(1, 6)}\nb_dict = {i: 0 for i in range(1, 6)}\n\nfor s in a:\n if s in a_dict:\n a_dict[s] += 1\n else:\n a_dict[s] = 1\n\nfor t in b:\n if t in b_dict:\n b_dict[t] += 1\n else:\n b_dict[t] = 1\nans = 0\nfor i in range(1, 6):\n if (a_dict[i] + b_dict[i]) % 2 == 1:\n ans = -1\n else:\n ans += abs((a_dict[i] + b_dict[i]) // 2 - a_dict[i])\n\nans = ans\nprint(ans)"}, {"source_code": "x = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ns = a + b\nt = list(set(s))\nk = 0\nk1 = 0\nd = {}\nfor i in range(len(t)):\n\tr = a.count(t[i])\n\tr1 = b.count(t[i])\n\tif r > r1:\n\t\tk = k + r - r1\n\telse:\n\t\tk1 = k1 + r1 - r\nif k%2 == 0 and k == k1:\n\tprint(k//2)\nelse:\n\tprint(-1)"}, {"source_code": "def fail():\n print(-1)\n exit()\nread = lambda: map(int, input().split())\nn = int(input())\na = sorted(read())\nb = sorted(read())\nfor i in range(1, 6):\n if (a.count(i) + b.count(i)) % 2:\n fail()\ncnt = 0\nwhile 1:\n flag = False\n for i in range(n):\n if a.count(a[i]) != b.count(a[i]):\n for j in range(n):\n if a.count(b[j]) != b.count(b[j]) and a[i] != b[j]:\n a[i], b[j] = b[j], a[i]\n cnt += 1\n break\n if flag:\n break\n if not flag:\n break\nprint(cnt)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split(' ')]\nb = [int(x) for x in input().split(' ')]\n\na_dict = {i: 0 for i in range(1, 6)}\nb_dict = {i: 0 for i in range(1, 6)}\n\nfor s in a:\n if s in a_dict:\n a_dict[s] += 1\n else:\n a_dict[s] = 1\n\nfor t in b:\n if t in b_dict:\n b_dict[t] += 1\n else:\n b_dict[t] = 1\nans = 0\nfor i in range(1, 6):\n if (a_dict[i] + b_dict[i]) % 2 == 1:\n ans = -2\n else:\n ans += abs(a_dict[i] - b_dict[i]) // 2\n\nans = ans // 2\nprint(ans)"}, {"source_code": "n = int(input())\n\nlista = list(map(int,input().split()))\nlistb = list(map(int,input().split()))\n\ncoua = [0]*6\ncoub = [0]*6\n\nfor v in lista:\n coua[v] +=1\n\nfor v in listb:\n coub[v] +=1\n\nok = True\nans = 0\nfor v in range(1,6):\n sumab = coua[v]+coub[v]\n if(sumab % 2 != 0):\n ok = False\n break\n ans += abs(coua[v]-sumab/2)\n\nif not ok:\n print(-1)\nelse :\n print(ans//2)\n\n"}, {"source_code": "from collections import Counter\nn = int(input())\nclass_a = [int(x) for x in input().split()]\nclass_b = [int(x) for x in input().split()]\nA = Counter(class_a)\nB = Counter(class_b)\ndelta = 0\nfor grade in range(1, 6):\n\tif (A[grade] + B[grade]) % 2 == 1:\n\t\tprint(-1)\n\t\texit()\n\tdelta += abs(A[grade] - B[grade])\nprint(delta // 2)\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split(' ')]\nb = [int(x) for x in input().split(' ')]\n\na_dict = {i: 0 for i in range(1, 6)}\nb_dict = {i: 0 for i in range(1, 6)}\n\nfor s in a:\n if s in a_dict:\n a_dict[s] += 1\n else:\n a_dict[s] = 1\n\nfor t in b:\n if t in b_dict:\n b_dict[t] += 1\n else:\n b_dict[t] = 1\nans = 0\nfor i in range(1, 6):\n if (a_dict[i] + b_dict[i]) % 2 == 1:\n ans = -2\n else:\n ans += abs(a_dict[i] - b_dict[i]) // 2\n\nans = ans // 2\nprint(ans)"}, {"source_code": "import collections\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nacnt = collections.Counter(a)\nbcnt = collections.Counter(b)\nans = 0\nfor x, y in zip(acnt, bcnt):\n if (x+y) & 1:\n ans = -1\n break\n ans += abs(x - y) // 2\nprint(ans)\n"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ncnt = [0] * 5\nfor elem in A:\n cnt[elem - 1] += 1\nfor elem in B:\n cnt[elem - 1] += 1\nbad = 0\nfor elem in cnt:\n bad += elem % 2\nif bad != 0:\n print(-1)\ncntA = [0] * 5\ncntB = [0] * 5\nfor elem in A:\n cntA[elem - 1] += 1\nfor elem in B:\n cntB[elem - 1] += 1\nans = 0\nfor i in range(5):\n ans += abs(cntA[i] - cntB[i]) // 2\nprint(ans // 2)\n"}, {"source_code": "n = input()\n\na = map(int, raw_input().split())\n\nb = map(int, raw_input().split())\n\nda = {}\ndb = {}\nfor i in xrange(1,6):\n da[i] = a.count(i)\n db[i] = b.count(i)\n\n\nc = 0\nfor i in xrange(1,6):\n if da[i]==db[i]:\n pass\n else:\n c+=abs(da[i]-db[i])\nif c!=0 and c<4:\n print -1\nelse:\n print c/4\n"}, {"source_code": "# import sys \n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out.out\",'w')\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=[0,0,0,0,0]\nfor i in a:\n\tc[i-1]+=1\nfor j in b:\n\tc[j-1]-=1\ns=0\nfor i in c:\n\ts+=abs(i)\nif s%2==0:\n\tx=s//2\n\tprint(x//2)\nelse:\n\tprint(-1)\t"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc=0\nd=0\nz=0\nfor j in range(5):\n for i in range(n):\n if a[i]==j+1:\n c+=1\n for i in range(n):\n if b[i]==j+1:\n d+=1\n if (c+d)%2==0:\n z=-1\n break\n else:\n z+=abs(c-d)//2\nprint(z)"}, {"source_code": "n = int(input())\nclassA = list(map(int, input().split()))\nclassB = list(map(int, input().split()))\n\n\na1 = classA.count(1)\nb1 = classA.count(2)\nc1 = classA.count(3)\nd1 = classA.count(4)\ne1 = classA.count(5)\n\n\na2 = classB.count(1)\nb2 = classB.count(2)\nc2 = classB.count(3)\nd2 = classB.count(4)\ne2 = classB.count(5)\n\nC = (abs(a1 - a2) + abs(b1 - b2) + abs(c1 - c2) + abs(d1 - d2) + abs(e1 - e2)) // 2\nif C % 2 == 0:\n print(C // 2)\nelse:\n print(-1)\n"}, {"source_code": "import sys\nn =int(input())\na =list(map(int,input().split()))\nb =list(map(int,input().split()))\nspecial = 0\nlcng =rcng=0\nfor j in range(1,6):\n l = a.count(j)\n r = b.count(j)\n\n if(l != r):\n if((l == 1 and r == 0) or (r == 1 and l == 0)):\n special = 1\n elif(l > r and special != 1):\n lcng += int(l -((l + r)/2))\n else:\n rcng += int(r -((l + r)/2))\n\n\nif(lcng != rcng or special == 1):\n print(\"-1\")\nelse:\n print(lcng)"}, {"source_code": "n = input()\nf = list(map(int, input().split()))\ns = list(map(int, input().split()))\n\nif f.count('1')-s.count('1')%2==0 and f.count('2')-s.count('2')%2==0 and f.count('3')-s.count('3')%2==0 and f.count('4')-s.count('1')%2==0 and f.count('5')-s.count('5')%2==0 :\n\tprint((abs(f.count('1')-s.count('1')) + abs(f.count('2')-s.count('2')) + abs(f.count('3')-s.count('3')) + abs(f.count('4')-s.count('4')) + abs(f.count('5')-s.count('5')))/4)\nelse :\n\tprint(-1)"}, {"source_code": "n = int(raw_input())\nl1 = [int(x) for x in raw_input().split()]\nl2 = [int(x) for x in raw_input().split()]\nfrom collections import defaultdict\nh1 = defaultdict(int)\nh2 = defaultdict(int)\nfor x in l1:\n h1[x] += 1\nfor x in l2:\n h2[x] += 1\ndifs = 0\nfor i in xrange(1,6):\n difs += abs(h1[i]-h2[i])\n\nif difs % 4 == 0:\n print difs/4\nelse :\n print -1"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nd=dict()\nfor i in a :\n if i in d:\n d[i]+=1\n else:\n d[i]=1\nfor i in b :\n if i in d:\n d[i]+=1\n else:\n d[i]=1\nval=list(d.values())\nx=True\nfor i in val :\n if i%2!=0:\n x=False\n break\ns=0\nif x:\n for i in list(set(a)):\n s=max(s+a.count(i)-(d[i]//2),1)\n print(s)\nelse:\n print(-1)"}, {"source_code": "# -*- coding: utf-8 -*-\nn = int(input())\nc1 = list(map(int, input().split(' ')))\nc2 = list(map(int, input().split(' ')))\nm1_add = []\nm1_rem = []\nm2_add = []\nm2_rem = []\nfor i in range(1, 6):\n k1 = c1.count(i)\n k2 = c2.count(i)\n if k1>k2:\n m1_rem.append((k1-k2)//2)\n m2_rem.append(0)\n m1_add.append(0)\n m2_add.append((k1-k2)//2)\n else:\n m1_rem.append(0)\n m2_rem.append((k2-k1)//2)\n m1_add.append((k2-k1)//2)\n m2_add.append(0)\nfor i in range(5):\n for j in range(m1_add[i]):\n c1.append(i+1)\n for j in range(m2_add[i]):\n c2.append(i+1)\n for j in range(m1_rem[i]):\n c1.remove(i+1)\n for j in range(m2_rem[i]):\n c2.remove(i+1)\nif sum([int(i) for i in c1]) == sum([int(i) for i in c2]):\n print(sum(m1_add))\nelse:\n print(-1)\n"}, {"source_code": "n=int(input())\nip1=list(map(int,input().split()))\nip2=list(map(int,input().split()))\nb=0\nfor i in range(1,6):\n if (ip1.count(i)+ip2.count(i))%2!=0:\n b=1\n print(-1)\n break\nif b==0:\n count=0\n for i in ip1:\n if i in ip2:\n ip1.remove(i)\n ip2.remove(i)\n print(len(ip1)//2)\n"}, {"source_code": "n = input()\n\na = map(int, raw_input().split())\n\nb = map(int, raw_input().split())\n\nda = {}\ndb = {}\nfor i in xrange(1,6):\n da[i] = a.count(i)\n db[i] = b.count(i)\n\n\nc = 0\nfor i in xrange(1,6):\n if da[i]==db[i]:\n pass\n else:\n c+=abs(da[i]-db[i])\nif c!=0 and c<4:\n print -1\nelse:\n print c/4\n"}, {"source_code": "nb_pupil = int(input())\ngrp_1 = [int(x) for x in input().split()]\ngrp_2 = [int(x) for x in input().split()]\nchanged = 0\nans = -1\nfor i in range(1, 6):\n grp1 = grp_1.count(i)\n grp2 = grp_2.count(i)\n if not (grp1 + grp2) % 2:\n changed += abs(grp1 - grp2)//2\n ans = 0\n else:\n break\nif ans != -1:\n print(changed//2)\nelse:print(-1)\n"}, {"source_code": "##n = int(input())\n##a = list(map(int, input().split()))\n##print(' '.join(map(str, res)))\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nha = [0 for i in range(5)]\nhb = [0 for i in range(5)]\nfor i in range(n):\n ha[a[i]-1] += 1\n hb[b[i]-1] += 1\n\nres = 0\nused = [0 for i in range(5)]\nfor i in range(5):\n if used[i] == 0:\n for j in range(i+1, 5):\n if used[j] == 0:\n if ha[i] == hb[j] and hb[i] == ha[j] and (ha[i]+hb[i])%2 == 0:\n res += abs(ha[i]-(ha[i]+hb[i])//2)\n used[i] = 1\n used[j] = 1\n break\n\nfor i in range(5):\n if used[i] == 0 and ha[i] != hb[i]:\n print('-1')\n exit(0)\nprint(res)"}], "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3"} {"source_code": "from __future__ import division\nfrom sys import stdin\n\na, b = [int(x) for x in stdin.readline().split()]\nmem = [[[1, 0] if j == 0 and i else [0, 0] for j in range(b + 2)] for i in range(a + 2)]\n\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n mem[i][j][0] = (i / (i + j)) + (j / (i + j)) * mem[i][j - 1][1]\n mem[i][j][1] = (j / (i + j)) * (\n mem[i][j - 2][0] * ((j - 1) / (i + j - 1)) + mem[i - 1][j - 1][0] * (i / (i + j - 1)))\n\nprint(mem[a][b][0])\n", "positive_code": [{"source_code": "#!/usr/bin/env python3\n# created : 2020. 8. 18. 00:50\n\nimport os\nfrom sys import stdin, stdout\n\n\ndef solve(tc):\n w, b = map(int, stdin.readline().split())\n\n dp = [[1.0 for j in range(1001)] for i in range(1001)]\n for i in range(1, 1001):\n dp[i][0] = 1.0\n dp[i][1] = i/(i+1)\n dp[0][i] = 0.0\n dp[1][1] = 0.5\n\n if w == 0:\n print(0.0)\n return\n\n if b == 0:\n print(1.0)\n return\n elif b == 1:\n print(dp[w][b])\n return\n\n for i in range(1, w+1):\n dp[i][2] = i/(i+2)\n dp[i][2] += 2/(i+2) * 1/(i+1)\n\n for j in range(3, b+1):\n dp[i][j] = i/(i+j)\n dp[i][j] += j/(i+j) * (j-1)/(i+j-1) * (j-2)/(i+j-2) * dp[i][j-3]\n dp[i][j] += j/(i+j) * (j-1)/(i+j-1) * i/(i+j-2) * dp[i-1][j-2]\n \n print(dp[w][b])\n\n\ntcs = 1\ntc = 1\nwhile tc <= tcs:\n solve(tc)\n tc += 1\n"}, {"source_code": "# three players princess, dragon, chance\n# there are only 2 possible winners\n# use 3d array dp[w][b][p] to store the prob of having w, b mice left to the player p\n# interesting, how do we even implement this?, without recursive?\n\n# (w + b) - (wleft + bleft) mod 3 will tell us the player\n# 0 being princess, 1 being dragon, 2 being chance\n# so we can just loop through the array, without even worrying for the player at first\n\n# all the 'special cases' treatment, is giving me headache. is there a way to nicely sort them out without special cases ?\n\nMAX = 1002\nw, b = map(int, input().split())\nans = 0\ndp = [[0 for _ in range(MAX)] for _ in range(MAX)]\nend = [[0 for _ in range(MAX)] for _ in range(MAX)]\ndp[w][b] = 1\nfor i in range (w, -1, -1):\n end[i][b+1] = 1 \nif w > 0:\n ans += ((w) / (w + b)) * dp[w][b]\n end[w-1][b] = 1\nif b > 0:\n for j in range(b - 1, -1, -1):\n dp[w][j] = ((j + 1) / (w + j + 1)) * dp[w][j+1]\n\nfor i in range(w - 1, -1, -1):\n for j in range(b - 1, -1, -1):\n if end[i+1][j] and end[i][j+1]:\n end[i][j] = 1\n else:\n if not end[i+1][j]:\n if (w + b - i -j) % 3 == 1:\n ans += ((i + 1) / (i + j + 1)) * dp[i+1][j]\n if end[i][j+1]:\n end[i][j] = 1\n elif (w + b - i -j) % 3 == 2:\n if end[i][j+1]:\n end[i][j] = 1\n else:\n dp[i][j] += ((i + 1) / (i + j + 1)) * dp[i+1][j]\n if not end[i][j+1]: \n dp[i][j] += ((j + 1) / (i + j + 1)) * dp[i][j+1]\n \n \nprint(ans)"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "n,m=map(int,input().split(\" \"))\ndp=[[[1,0] if j and not i else [0,0] for i in range(m+1)] for j in range(n+1)]\n\nfor i in range(1,n+1):\n for j in range(1,m+1):\n dp[i][j][0]=(i/(i+j)) + (j/(i+j))*dp[i][j-1][1]\n dp[i][j][1]=(j/(i+j))*(dp[i][j-2][0]*((j-1)/(i+j-1)) + dp[i-1][j-1][0]*((i)/(i+j-1)))\n\nprint(dp[n][m][0])\n"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n"}, {"source_code": "w, b = [int(i) for i in input().split()]\na = [[0 for i in range(w+1)] for j in range(b+1)]\n\ndef cnt(w, b):\n if w <= 0:\n return 0\n if b <= 0:\n return 1\n if a[b][w] != 0:\n return a[b][w]\n c = w / (w + b)\n if w+b>2:\n wjump = cnt(w-1, b-2)\n bjump = cnt(w, b-3)\n c += (b/(w+b))*((b-1)/(w+b-1))*((b-2)/(w+b-2))* bjump\n c += (b/(w+b))*((b-1)/(w+b-1))*(w/(w+b-2)) * wjump\n a[b][w] = c\n return c\nprint(cnt(w, b))\n\n\n"}, {"source_code": "w, b = map(int, input().split())\ndp = [[[1, 0] if i and not j else [0, 0] for j in range(b + 2)] for i in range(w + 2)]\nfor i in range(1, w + 1):\n for j in range(1, b + 1):\n dp[i][j][0] = (i + j * (dp[i][j - 1][1])) / (i + j)\n dp[i][j][1] = j * ((j - 1) * dp[i][j - 2][0] + i * dp[i - 1][j - 1][0]) / (i + j) / (i + j - 1)\nprint(dp[w][b][0])"}, {"source_code": "d = dict()\ndef prob(w,b):\n\tif(w == 0 or b < 0):\n\t\treturn 0\n\tif(b == 0):\n\t\treturn 1\n\tif (b,w) in d:\n\t\treturn d[(b,w)]\n\tans1 = w/(w+b)\n\tif(b == 1):\n\t\tans2 = 0\n\telse:\n\t\tans2 = b/(w+b)*(b-1)/(w+b-1)*(prob(w-1,b-2)*w/(b+w-2)+prob(w,b-3)*(b-2)/(b+w-2))\n\td[(b,w)] = ans1+ans2\n\treturn ans1+ans2\nw,b = map(int,input().split())\nprint(prob(w,b))\n"}, {"source_code": "dp = {}\n\ndef dfs(x,y):\n if x <= 0:\n return 0.0\n if y <= 0:\n return 1.0\n if x == 1 and y==1:\n return 0.5\n if (x,y) in dp:\n return dp[(x,y)]\n else:\n tmp = float(y)/float(x+y)*(float(y-1)/float(x+y-1))\n dp[(x,y)] = float(x)/float(x+y) + tmp*(float(x)*dfs(x-1,y-2) + float(y-2)*dfs(x,y-3))/float(x+y-2)\n return dp[(x,y)]\nw,b = tuple(map(int, raw_input().split()))\n\nprint dfs(w,b)\n"}, {"source_code": "# -*- coding:utf-8 -*-\n\n\"\"\"\n\ncreated by shuangquan.huang at 2/2/20\n\n\"\"\"\n\nimport collections\nimport time\nimport os\nimport sys\nimport bisect\nimport heapq\nfrom typing import List\nfrom functools import lru_cache\n\n\n@lru_cache(maxsize=None)\ndef solve(w, b):\n if w <= 0:\n return 0\n if b <= 0:\n return 1\n \n # current is player 1's turn\n # win prob\n ans = w / (w + b)\n # draw black\n p = b / (w + b)\n b -= 1\n # probability of continuing after player 2's turn\n p *= b / (w + b)\n b -= 1\n if p > 1e-13:\n # mouse jumps is either white or black\n pblack = solve(w, b-1) * b / (w + b)\n pwthite = solve(w-1, b) * w / (w + b)\n ans += p * (pblack + pwthite)\n \n return ans\n\n\n \nw, b = map(int, input().split())\nprint(solve(w, b))"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p"}, {"source_code": "w,b=map(int,raw_input().split())\nc=0\no=0\nr=0\ns=w+b\nfor i in range(s):\n if c >= s:\n break\n d = (1-o)*w*1./(s-i)\n if i%2:\n c+=2\n else:\n c+=1\n r+=d\n o+=d\nprint r"}, {"source_code": "w, b = map(float, raw_input().split())\n\ndp = {}\n\n\ndef f(w, b):\n if w < 0 or b < 0:\n return 0.0\n\n if w == 0:\n return 0.0\n if b == 0:\n return 1.0\n\n\n if (w, b) in dp:\n return dp[(w, b)]\n\n ans = w/(w+b)\n\n if b >= 2:\n ans += b/(w+b) * (b-1)/(w+b-1) * ( w/(w+b-2) * f(w-1, b-2) + (b-2)/(w+b-2) * f(w, b-3))\n\n dp[ (w, b) ] = ans\n return ans\n\n\nprint f( w, b )"}, {"source_code": "import sys\nsys.setrecursionlimit(10000000)\ndef dp(white, black, mem, prin = 1):\n if black < 0 or white <= 0: \n if prin == 1: return 0\n return 1\n if mem[white][black][prin] != -1: return mem[white][black][prin]\n if prin == 1:\n wewinnow = float(white) / (white + black)\n wewinlater = (1 - wewinnow) * dp(white, black - 1, mem, 0)\n res = wewinnow + wewinlater\n mem[white][black][prin] = res\n return res\n dragonblanks = float(black) / (white + black)\n whitejump, blackjump = 0, 0\n if black > 0: whitejump = dragonblanks * (float(white) / (white + black - 1)) * dp(white - 1, black - 1, mem)\n if black > 1: blackjump = dragonblanks * (float(black - 1) / (white + black - 1)) *dp(white, black - 2, mem)\n res = whitejump + blackjump \n mem[white][black][prin] = res\n return res\nw, b = map(int, raw_input().split())\nmem = [[[-1] * 2 for _ in xrange(b + 1)] for _ in xrange(w + 1)]\nprint(dp(w, b, mem))"}, {"source_code": "dp = {}\n\ndef p(w, b):\n\tif (w, b) in dp:\n\t\treturn dp[(w, b)]\n\tif w == 0:\n\t\tdp[(w, b)] = 0.0\n\t\treturn 0.0\n\tow, ob = w, b\n\n\tans = 1.0 * w / (w + b) # p pick white, win\n\tif b < 2:\n\t\tdp[(w, b)] = ans\n\t\treturn ans\n\t#p pick black, b -= 1\n\ttmp = 1.0 * b / (w + b)\n\tb -= 1\n\t# d pick black, b -= 1\n\ttmp *= 1.0 * b / (w + b)\n\tb -= 1\n\n\tif b > 0:\n\t\tans += tmp * 1.0 * b / (b + w) * p(w, b-1)\n\tif w > 0:\n\t\tans += tmp * 1.0 * w / (b + w) * p(w-1, b)\n\n\tdp[(ow, ob)] = ans\n\treturn ans\n\nw, b = map(int, raw_input().split())\nprint p(w, b)"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "w, b = map(int, raw_input().split())\nk, p, q, s = 0, 0, 1, float(w + b)\nwhile q and k < s:\n d = q * w / s\n p += d; q -= d; s -= 1\n d = q * w / s\n q -= d; s -= 1; k += 1\nprint p"}, {"source_code": "#!/usr/bin/python\n\nprobs={(1,1):0.5}\n\ndef prob(w, b):\n\tif w<=0 or b<0:\n\t\treturn 0\n\tif b==0: #w>0\n\t\treturn 1\n\tif probs.has_key((w, b)):\n\t\treturn probs[(w, b)]\n\tww=w\n\tbb=b\n\tw=float(w)\n\tb=float(b)\n\tp1 = w/(b+w-2)\n\tif p1 > 0:\n\t\tp1*=prob(ww-1, bb-2)\n\tp2 = (b-2)/(b+w-2)*prob(ww, bb-3)\n\tanswer = w/(b+w)+(b*(b-1)/((b+w)*(b+w-1)))*(p1+p2)\n\tprobs[(ww, bb)]=answer\n\treturn answer\n\nw, b=tuple(map (int, raw_input().split(\" \")))\n\nprint \"%.9f\"%(prob(w, b))\n"}, {"source_code": "N = 2000\na, b = map(int, raw_input().split())\np = [[0.0] * N for i in range (N)]\np[a][b] = 1.0\nans = 0.0\nfor i in range (a, -1, -1):\n for j in range (b, -1, -1):\n if(a + b - i - j) % 3 == 0: \n p[i][j] += ((i+1) * p[i+1][j] + (j+1) * p[i][j+1]) / (i + j + 1)\n if(i + j > 0):\n ans += p[i][j] * i / (i + j) \n else:\n p[i][j] += p[i][j+1] * (j+1) / (i+j+1) \n\nprint ans\n"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "import sys\nimport math\n\n\n##sys.stdin = open('input.txt', 'r')\n\nw, b = map(int, raw_input().split())\n\ndp = [[2.0 for i in xrange(b + 1)] for j in xrange(w + 1)]\n\n#print dp\n\ndef DP(wi, bi, dp):\n if dp[wi][bi] < 1.5:\n return dp[wi][bi]\n if 0 == wi:\n return 0\n ans = float(wi) / (wi + bi)\n if 0 == bi or 1 == bi:\n dp[wi][bi] = ans\n return ans\n\n s = float(bi) / (wi + bi) * float(bi - 1) / (wi + bi - 1)\n ans += s * (float(wi) / (wi + bi - 2) * DP(wi - 1, bi - 2, dp))\n if bi > 2:\n ans += s * float(bi - 2) / (wi + bi - 2) * DP(wi, bi - 3, dp)\n dp[wi][bi] = ans\n return ans\n\nans = DP(w, b, dp)\n\nprint ans\n"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "import sys\n\nw, b = map(int, sys.stdin.readline().split())\n\ndp = {}\n\ndef solve(w, b):\n if w == 0:\n return 0.0\n if b == 0:\n return 1.0\n if b < 0:\n return 0.0\n if (w, b) in dp:\n return dp[(w, b)]\n ret = w/(w+b)\n if b > 1:\n ret += b/(w+b) * (b-1)/(w+b-1) * (w/(w+b-2) * solve(w-1, b-2) + (b-2)/(w+b-2) * solve(w, b-3))\n dp[(w, b)] = ret\n return ret\n\nprint \"%.9f\" % solve(float(w), float(b))\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10000000)\ndef dp(white, black, mem, prin = 1):\n if black < 0 or white <= 0: return 0\n if mem[white][black][prin] != -1: return mem[white][black][prin]\n if prin == 1:\n wewinnow = float(white) / (white + black)\n wewinlater = (1 - wewinnow) * dp(white, black - 1, mem, 0)\n res = wewinnow + wewinlater\n mem[white][black][prin] = res\n return res\n dragonblanks = float(black) / (white + black)\n whitejump, blackjump = 0, 0\n if black > 0: whitejump = dragonblanks * (float(white) / (white + black - 1)) * dp(white - 1, black - 1, mem)\n if black > 1: blackjump = dragonblanks * (float(black - 1) / (white + black - 1)) *dp(white, black - 2, mem)\n res = whitejump + blackjump \n mem[white][black][prin] = res\n return res\nw, b = map(int, raw_input().split())\nmem = [[[-1] * 2 for _ in xrange(b + 1)] for _ in xrange(w + 1)]\nprint(dp(w, b, mem))"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10**6)\n\nw, b = map(int, input().split())\nw += 1\nb += 1\npr_win = [[None for k in range(b)] for k in range(w)]\ndr_win = [[None for k in range(b)] for k in range(w)]\n\ndef f(w0, b0, princess):\n if w0 < 0 or b0 < 0:\n return 0\n if w0 == 0 and b0 == 0:\n return 0\n if b0 == 0:\n return 1 if princess else 0\n if w0 == 0:\n return 0\n if princess:\n if pr_win[w0][b0] is None:\n p_w = w0/(w0 + b0)\n p_b = b0/(w0 + b0) * f(w0, b0 - 1, not princess)\n pr_win[w0][b0] = p_w + p_b\n return pr_win[w0][b0]\n else:\n if dr_win[w0][b0] is None:\n p_bb = b0/(w0 + b0) * (b0 - 1)/(w0 + b0 - 1) * f(w0, b0 - 2, not princess)\n p_bw = b0/(w0 + b0) * w0/(w0 + b0 - 1) * f(w0 - 1, b0 - 1, not princess)\n dr_win[w0][b0] = p_bb + p_bw\n return dr_win[w0][b0]\n\nprint(\"%.10f\" % f(w - 1, b - 1, True))"}, {"source_code": "# def fun( num ) :\n# prob = 1\n# if(num>0):\n# # print( \"prob\" , prob )\n# print( \"num\" , num )\n# prob *= num\n# prob *= fun( num-1 )\n# return prob\n\n# print( fun( 8 ) )\n\nsave={}\n\ndef fun( w , b ) :\n global save\n key=str(w)+' '+str(b)\n if(save.get(key)!=None):\n return save[ key ]\n\n prob=0\n if (( w>= 0 ) and ( b>=0 ) and ( (w+b)!= 0 ) ) :\n prob = w / ( w + b )\n if( (w+b)>2 ):\n prob += fun( w-1 , b-2 ) * ( b / ( w+b ) ) * ((b-1) / ( w+b-1 ) ) * ( w / ( w+b-2 ))\n prob += fun( w , b-3 ) * ( b / ( w+b ) ) * ( (b-1) / ( w+b-1 ) ) * ( (b-2) / ( w+b-2 ))\n save[ key ]=prob\n return prob\n\nscr = input()\nmice_w , mice_b =map(int , scr.split())\n\nprob = fun( mice_w , mice_b )\n\nprint( prob )"}, {"source_code": "from fractions import Fraction\n\nw, b = [int(x) for x in input().split()]\n\ndef probability(w, b):\n memory = {}\n\n def recursive(w, b):\n if w <= 0:\n return 0.0\n if b <= 0:\n return 1.0\n\n if (w, b) in memory:\n return memory[(w, b)]\n\n white = w\n black = b\n # princess turn\n # chance to win\n answer = white / (black + white)\n\n # chance to continue the game after choosing black mouse\n black -= 1\n cont_p = (1 - answer) * (black /(black + white))\n\n # it's too small to calc next\n if cont_p > 1e-13:\n # dragon chooses black mouse\n black -= 1\n # chance for white mouse pop out\n white_ch = white / (white + black)\n # win chances\n white_p = recursive(white - 1, black) * white_ch\n black_p = recursive(white, black - 1) * (1 - white_ch)\n answer += cont_p * (black_p + white_p)\n\n memory[(w, b)] = answer\n return answer\n \n return recursive(w, b)\n\nanswer = probability(w, b)\nprint(answer)"}, {"source_code": "w, b = map(int, input().split())\nk, p, q, s = 0, 0, 1, w + b\nwhile q != 0 and k < s:\n d = q * w / s\n p += d\n q -= d\n s -= 1\n d = q * w / s\n q -= d\n s -= 1\n k += 1\nprint(p)\n"}, {"source_code": "w, b = map(int, input().split(' '))\n\nif w==0:\n print(0)\nelif b==0:\n print(1)\nelse:\n solved = [[-1]*b for i in range(w)]\n\n def solve(w, b):\n if solved[w-1][b-1] != -1:\n return solved[w-1][b-1]\n if w==0:\n ans = 0\n solved[w-1][b-1] = ans\n return ans\n \n if b==0:\n ans = 1\n solved[w-1][b-1] = ans\n return ans\n \n if b==1:\n ans = w/(w+1)\n solved[w-1][b-1] = ans\n return ans\n \n if b==2:\n if w==1:\n ans = 1/3\n solved[w-1][b-1] = ans\n return ans\n else:\n ans = w/(w+2) + 2/(w+2) * 1/(w+1)\n solved[w-1][b-1] = ans\n return ans\n \n x = solve(w-1, b-2)\n y = solve(w, b-3)\n \n ans = w/(w+b) + b/(w+b) * (b-1)/(w+b-1) * (w/(w+b-2) * x + (b-2)/(w+b-2) * y)\n solved[w-1][b-1] = ans\n return ans\n \n print(solve(w, b)) \n"}, {"source_code": "w, b = map(int, input().split())\nk, p, q, s = 0, 0, 1, w + b\nwhile q != 0 and k < s:\n d = q * w / s\n p += d\n q -= d\n s -= 1\n d = q * w / s\n q -= d\n s -= 1\n k += 1\nprint(p)\n"}, {"source_code": "\nw, b = map(int, input().split())\ncached = [[None]*(b+1) for i in range(w+1)]\ndef cal(w, b):\n # print(w, b)\n if cached[w][b] is not None:\n return cached[w][b]\n if w == 0:\n return 0\n\n if b == 0:\n return 1\n\n total = w + b\n # white win\n p = w / total\n\n # black, \n bp = 1 - p\n\n\n # turn to drag\n dbp = (b-1) / (total - 1)\n if b == 1:\n return p\n if b == 2:\n if w == 1:\n return p\n else:\n return p + bp*dbp\n\n cached[w][b] = p + bp * dbp * (w / (total - 2) * cal(w-1, b-2) + (b - 2) / (total - 2) * cal(w, b - 3))\n return cached[w][b]\n\nprint(cal(w, b))\n\n\n\n\n"}, {"source_code": "dp = {}\ndef prob(w, b):\n if (w, b) in dp:\n return dp[(w, b)]\n if w == 0 and b == 0:\n return 0\n if b == 0:\n return 1\n if w == 0:\n return 0\n if b == 1:\n ans = w / (w + b)\n dp[(w, b)] = ans\n return ans\n if b == 2:\n ans = w / (w + 2) + 2 / (w + 2) * 1 / (w + 1) * prob(w - 1, b - 2)\n dp [(w, b)] = ans\n return ans\n sum = w + b\n if sum == 1 or sum == 2:\n print(w, b)\n ans = w / sum + (b / sum) * (b - 1) / (sum - 1) * (w / (sum - 2) * prob(w - 1, b - 2) + (b - 2) / (sum - 2) * prob(w, b - 3))\n dp[(w, b)] = ans\n return ans\n\n\nif __name__ == '__main__':\n w, b = tuple(map(int, input().split()))\n print(prob(w, b))"}, {"source_code": "def f(W, B):\n n = B - W + 1\n d, p, t, r = [0] * B, [0] * B, [0] * B, [0] * B\n\n p[0], r[0], p[1] = 1, 1, 0.5\n for b in range(2, n + 1):\n d[b] = (t[b - 1] + p[b - 2] * (b - 1)) / (1 + b)\n p[b] = (1 + d[b - 1] * b) / (1 + b)\n r[0], t[0] = 1, 1\n t, r, p = p, t, r\n\n for w in range(2, W): \n p[1], d[1] = w / (w + 1), 1 / (w + 1)\n for b in range(2, n + w):\n d[b] = ((t[b - 1] * w + p[b - 2] * (b - 1)) * b) / ((w + b) * (w + b - 1))\n p[b] = (w + d[b - 1] * b) / (w + b)\n t, r, p = p, t, r\n\n return t[B - 1]\n\nw, b = map(int, input().split())\nif w == 0: print(0)\nelif b == 0: print(1)\nelse: print(f(w + 1, b + 1))"}, {"source_code": "w, b = map(int, input().split())\nk, p, q, s = 0, 0, 1, w + b\nwhile q != 0 and k < s:\n d = q * w / s\n p += d; q -= d; s -= 1\n d = q * w / s\n q -= d; s -= 1; k += 1\nprint(p)"}, {"source_code": "w, b = map(int, input().split())\n\nk, p, q, s = 0, 0, 1, w + b\n\nwhile q != 0 and k < s:\n\n d = q * w / s\n\n p += d\n\n q -= d\n\n s -= 1\n\n d = q * w / s\n\n q -= d\n\n s -= 1\n\n k += 1\n\nprint(p)\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "w,b=map(float,input().split())\ndic={}\n\ndef fun(w,b):\n if dic.get((w,b)):\n return dic[(w,b)]\n if w>0 and b>1:\n temp=b/(b+w)*(b-1)/(w+b-1)\n res=w/(w+b)+temp*(w/(w+b-2)*fun(w-1,b-2)+(b-2)/(w+b-2)*fun(w,b-3))\n dic[(w,b)]=res\n return res\n elif w>0 and b==1:\n return w/(w+b)\n elif w>0 and b==0:\n return 1.0\n else:\n return 0.0\n\npro=fun(w,b)\nprint(pro)\n"}, {"source_code": "w, b = [int(i) for i in input().split()]\n\n\ndp = [[-1 for i in range(b+1)] for j in range(w+1)]\n\ndef f(w, b):\n #if w<0 or b<0:\n # return 0\n if w==0 and b==0:\n return 0\n if b<=0:\n return 1\n if w == 0:\n return 0\n if dp[w][b] != -1:\n return dp[w][b]\n ans = w/(w+b)\n if w>=1 and b>=2:\n ans += (b/(w+b))*((b-1)/(w+b-1))*((w/(w+b-2)) * f(w-1, b-2))\n if b>=3:\n ans += (b/(w+b))*((b-1)/(w+b-1))*((b-2)/(w+b-2))* f(w, b-3)\n dp[w][b] = ans\n return ans\n\nprint(f(w, b))\n"}, {"source_code": "A, B = map(int, raw_input().split())\ndp = [(B + 1) * [1e-9] for _ in range(A + 1)]\n\ndef cal(w, b):\n if dp[w][b] != 1e-9: return dp[w][b]\n if w <= 0: return 0\n if b <= 0: return 1\n nxt = 0.0\n if b > 2:\n nxt += 1.0 * (b - 2) / (w + b - 2) * cal(w, b - 3)\n if b > 1:\n nxt += 1.0 * w / (w + b - 2) * cal(w - 1, b - 2)\n dp[w][b] = 1.0 * w / (w + b) + 1.0 * b / (w + b) * (b - 1) / (w + b - 1) * nxt\n return dp[w][b]\n\nprint \"%.9f\" % cal(A, B)"}, {"source_code": "A, B = map(int, raw_input().split())\ndp = [(B + 1) * [1e-9] for _ in range(A + 1)]\n\ndef cal(w, b):\n if dp[w][b] != 1e-9:\n return dp[w][b]\n if w <= 0: return 0\n if b <= 0: return 1\n nxt = 0.0\n if b > 2:\n nxt += 1.0 * (b - 2) / (w + b - 2) * cal(w, b - 3)\n if b > 1:\n nxt += 1.0 * w / (w + b - 2) * cal(w - 1, b - 2);\n dp[w][b] = 1.0 * w / (w + b) + 1.0 * b / (w + b) * (b - 1) / (w + b - 1) * nxt\n return dp[w][b]\n\nprint \"%.9f\" % cal(A, B)"}, {"source_code": "#!/usr/bin/env python\n\nmemory = {}\n\ndef get_res(w, b):\n if (w, b) in memory:\n return memory[(w, b)]\n if w == 0:\n return 0.\n elif b == 0:\n return 1.\n res = float(w) / (w + b)\n if b >= 3:\n b_r = get_res(w, b-3)\n res += float(b) / (w + b) * float(b - 1)/(w + b - 1) * float(b - 2) / (w + b - 2) * b_r\n if b >= 2:\n w_r = get_res(w-1, b-2)\n res += float(b) / (w + b) * float(b - 1)/(w + b - 1) * float(w) / (w + b - 2) * w_r\n memory[(w, b)] = res\n return res\n\nif __name__ == \"__main__\":\n w, b = map(int, raw_input().strip().split())\n print(get_res(w, b))\n"}, {"source_code": "#!/usr/bin/env python\n\nmemory = {}\n\ndef get_res(w, b):\n if (w, b) in memory:\n return memory[(w, b)]\n if w == 0:\n return 0.\n elif b == 0:\n return 1.\n res = float(w) / (w + b)\n if b >= 3:\n b_r = get_res(w, b-3)\n res += float(b) / (w + b) * float(b - 1)/(w + b - 1) * float(b - 2) / (w + b - 2) * b_r\n if b >= 2:\n w_r = get_res(w-1, b-2)\n res += float(b) / (w + b) * float(b - 1)/(w + b - 1) * float(w) / (w + b - 2) * w_r\n memory[(w, b)] = res\n return res\n\nif __name__ == \"__main__\":\n w, b = map(int, raw_input().strip().split())\n print(get_res(w, b))\n"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "#!/usr/bin/python\n\ndic = {}\n\ndef get_data():\n w, b = raw_input().split(' ')\n return int(w), int(b)\n\n\ndef sum_probs(w, b):\n if (w, b) in dic:\n return dic[(w, b)]\n if not w:\n dic[(w, b)] = 0\n return 0\n if not b:\n dic[(w, b)] = 1\n return 1\n prob = float(w)/(w+b)\n bad = float(b)/(w+b)\n if not b-1:\n dic[(w, b)] = prob\n return prob\n bad *= float(b-1)/(w+b-1)\n if not b-2:\n if w == 1:\n dic[(w, b)] = prob\n return prob\n dic[(w, b)] = prob + bad\n return prob + bad\n case1 = float(w)/(w+b-2)\n case2 = float(b-2)/(w+b-2)\n result = prob+bad*(case1*sum_probs(w-1, b-2) + case2*sum_probs(w, b-3))\n dic[(w, b)] = result\n return result\n\n\ndef main():\n w, b = get_data()\n print sum_probs(w, b)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "w, b = map(float, raw_input().split())\n\ndp = {}\n\n\ndef f(w, b):\n if w < 0 or b < 0:\n return 0.0\n\n if w == 0:\n return 0.0\n if b == 0:\n return 1.0\n\n\n if (w, b) in dp:\n return dp[(w, b)]\n\n ans = w/(w+b)\n\n if b >= 2:\n ans += b/(w+b) * (b-1)/(w+b-1) * ( w/(w+b-2) * f(w-1, b-2) + (b-2)/(w+b-2) * f(w, b-3))\n\n dp[ (w, b) ] = ans\n return ans\n\n\nprint f( w, b )\n"}, {"source_code": "w, b = map(int, raw_input().split())\ndp = [[0.0 for i in xrange(w + 10)] for j in xrange(0, w + b + 10, 3)]\nstart = (w + b) % 3 + 3\nif start == 4:\n dp[0][1] = 1.0\nelif start == 5:\n dp[0][1] = 0.5\n dp[0][2] = 1.0\nfor i in xrange(start, w + b + 1, 3):\n for j in xrange(1, min(w, i) + 1):\n # wn, bn = j, i - j\n dp[i/3][j] = 1.0 * j / i + 1.0 * (i - j) / i * (i - j - 1) / (i - 1) * (dp[i/3-1][j-1] * j / (i - 2) + dp[i/3-1][j] * (i - j - 2) / (i - 2))\nprint \"%.9f\" % dp[(w+b)/3][w]\n"}, {"source_code": "from __future__ import division\n\nmemo = {}\ndef prob_win1(w, b):\n if w <= 0:\n return 0.0\n if b <= 0:\n return 1.0\n args = (w, b)\n if args in memo:\n return memo[args]\n win = w / (w + b)\n cont = b / (w + b)\n b -= 1\n cont *= b / (w + b)\n b -= 1\n if cont > 1.0e-13:\n p_black = prob_win1(w, b - 1) * (b / (w + b))\n p_white = prob_win1(w - 1, b) * (w / (w + b))\n win += cont * (p_black + p_white)\n memo[args] = win\n return win\n\nw, b = map(int, raw_input().split())\nprint prob_win1(w, b)"}, {"source_code": "w, b = map(int, raw_input().strip().split(\" \"))\n\nresults = {}\ntotal = 0.0\n\ndef princess_wins(w, b, princess_turn=True):\n\tif (w, b) in results:\n\t\treturn results[(w, b)]\n\tif w == 0 or w + b == 0:\n\t\treturn 0\n\tif b == 0:\n\t\treturn int(princess_turn)\n\tprob_white = w / (w + b)\n\tif princess_turn:\n\t\tres = prob_white + (1 - prob_white) * princess_wins(w, b-1, not princess_turn)\n\telse:\n\t\t#print((w, b))\n\t\tif b == 1.0:\n\t\t\tres = (1 - prob_white)\n\t\telse:\n\t\t\tprob_white_after = w / (w + b - 1)\n\t\t\tres = (1 - prob_white) * ((1 - prob_white_after) * princess_wins(w, b-2, not princess_turn) + prob_white_after * princess_wins(w-1, b-1, not princess_turn))\n\tresults[(w, b)] = res\n\treturn res\n\nprint(princess_wins(float(w), float(b)))"}, {"source_code": "w, b = map(float, raw_input().split())\n\n\ndp = {}\ndef solve(w, b, p, turn):\n #print w, b, p, turn\n key = (w, b, turn)\n if key in dp:\n return dp[key]\n\n if w == 0:\n return 0\n\n if b == 0:\n if turn:\n return p\n else:\n return 0\n\n result = 0\n if turn:\n wc = p * (w / (w+b))\n bc = solve(w, b-1, p * (b / (w+b)), not turn)\n result = wc + bc\n else:\n if b == 1:\n result = solve(w-1, b-1, p * (b / (w+b)) * (w / (w+b-1)), not turn)\n else:\n result = solve(w-1, b-1, p * (b / (w+b)) * (w / (w+b-1)), not turn) + solve(w, b-2, p * (b / (w+b)) * ((b-1) / (w+b-1)), not turn)\n\n\n dp[key] = result\n return result\n\nprint solve(w, b, 1, True)\n\n#for key in dp:\n# print key, dp[key]"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter, defaultdict\nfrom itertools import permutations, combinations\nraw_input = stdin.readline\npr = stdout.write\n\n\ndef in_arr():\n return map(int,raw_input().split())\n\n\ndef pr_num(n):\n stdout.write(str(n)+'\\n')\n\n\ndef pr_arr(arr):\n pr(' '.join(map(str,arr))+'\\n')\n\n\nrange = xrange # not for python 3.0+\n\n# main code\n\nw,b=in_arr()\n\ndp=[[0 for i in range(w+1)] for i in range(b+1)]\nvis=[[0 for i in range(w+1)] for j in range(b+1)]\ndp[b][w]=1\nvis[b][w]=1\nq=[(b,w)]\nans=0\nwhile q:\n x,y=q.pop(0)\n \n if x: \n if not vis[x-1][y]:\n q.append((x-1,y))\n vis[x-1][y]=1\n dp[x-1][y]+=(dp[x][y]*(float(x)/(x+y)))\n if y:\n if not vis[x][y-1]:\n q.append((x,y-1))\n vis[x][y-1]=1\n pro=dp[x][y]*(float(y)/(x+y))\n dis=b+w-x-y\n if dis%3==0:\n #print ans,pro,x,y-1\n ans+=pro\n if dis%3==2:\n \n dp[x][y-1]+=(pro)\n \nprint ans\n"}, {"source_code": "from __future__ import division\nfrom sys import stdin\n\n\ndef dp(i, j, move):\n if j <= 0:\n if i and move == 0:\n return 1\n else:\n return 0\n\n if i <= 0:\n return 0\n\n if mem[i][j][move] != -1:\n return mem[i][j][move]\n\n if move == 0:\n mem[i][j][move] = (i / (i + j)) + (j / (i + j)) * dp(i, j - 1, move ^ 1)\n else:\n pw, pb = i / (i + j - 1), (j - 1) / (i + j - 1)\n mem[i][j][move] = (j / (i + j)) * (pw * dp(i - 1, j - 1, move ^ 1) + pb * dp(i, j - 2, move ^ 1))\n\n return mem[i][j][move]\n\n\na, b = [int(x) for x in stdin.readline().split()]\nmem = [[[-1 for _ in range(2)] for _ in range(b + 1)] for _ in range(a + 1)]\nprint(dp(a, b, 0))\n\n# mem = [[[1, 0] if j == 0 and i else [0, 0] for j in range(b + 1)] for i in range(a + 1)]\n# for i in range(1, a + 1):\n# for j in range(1, b + 1):\n# mem[i][j][0] = (i / (i + j)) + (j / (i + j)) * mem[i][j - 1][1]\n# mem[i][j][1] = (j / (i + j)) * (\n# mem[i][j - 2][0] * ((j - 1) / (i + j - 1)) + mem[i - 1][j - 1][0] * (i / (i + j - 1)))\n#\n# print(mem[a][b][0])\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10000000)\ndef dp(white, black, mem, prin = 1):\n if black < 0 or white <= 0: \n if prin == 1: return 0\n return 1\n if mem[white][black][prin] != -1: return mem[white][black][prin]\n if prin == 1:\n wewinnow = float(white) / (white + black)\n wewinlater = (1 - wewinnow) * dp(white, black - 1, mem, 0)\n res = wewinnow + wewinlater\n mem[white][black][prin] = res\n return res\n dragonblanks = float(black) / (white + black)\n whitejump, blackjump = 0, 0\n if black > 0: whitejump = dragonblanks * (float(white) / (white + black - 1)) * dp(white - 1, black - 1, mem)\n if black > 1: blackjump = dragonblanks * (float(black - 1) / (white + black - 1)) *dp(white, black - 2, mem)\n res = whitejump + blackjump \n mem[white][black][prin] = res\n return res\nw, b = map(int, raw_input().split())\nmem = [[[-1] * 2 for _ in xrange(b + 1)] for _ in xrange(w + 1)]\nprint(dp(w, b, mem))"}, {"source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k<s:\n d=q*w/s\n p+=d;q-=d;s-=1\n d=q*w/s\n q-=d;s-=1;k+=1\nprint p\n\n"}, {"source_code": "import sys\ndp = dict()\n\ndef rek(w, b, pr):\n if (w, b) in dp: return dp[(w, b)]\n else:\n if w < 0 or b < 0 or w + b == 0: return 0 \n if pr:\n res = float(w) / (w + b) + float(b) / (w + b) * rek(w, b - 1, False)\n dp[(w, b)] = res\n return res\n else:\n if w + b <= 2: return 0\n res = float(b) / (w + b) * (float(w) / (w + b - 1) * rek(w - 1, b - 1, True) + \\\n float(b - 1) / (w + b - 1) * rek(w, b - 2, True))\n dp[(w, b)] = res\n return res\n\nsys.setrecursionlimit(3000)\n[w, b] = map(int, raw_input().split())\nprint rek(w, b, True)\n"}, {"source_code": "from collections import deque\n\nw, d = map(int, raw_input().split())\n\ndef is_princess(x, y):\n return (w + d - x - y) % 3 == 0\n\ndp = [[0.0 for j in range(d + 1)] for i in range(w + 1)]\ndp[w][d] = 1.0\n\nQ = deque([(w, d)])\nP = 0.0\n\nwhile Q:\n x, y = Q.popleft()\n \n if is_princess(x, y):\n if (x == w and y == d) or dp[x][y] < 1e-20:\n if x < w and y < d:\n dp[x][y] += dp[x+1][y+1] * (y + 1) / (x + 1 + y + 1) * (x + 1) / (x + 1 + y)\n if y + 1 < d:\n dp[x][y] += dp[x][y+2] * (y + 2) / (x + y + 2) * (y + 1) / (x + y + 1)\n \n if y > 0: \n Q.append((x, y - 1))\n \n else:\n if dp[x][y] < 1e-20:\n if y < d:\n dp[x][y] += dp[x][y + 1] * (y + 1) / (x + y + 1)\n if x > 0 and y > 0:\n Q.append((x - 1, y - 1))\n if y > 1:\n Q.append((x, y - 2))\n \n # print x, y, dp[x][y]\n\nfor x in range(1, w + 1):\n for y in range(d + 1):\n if is_princess(x, y):\n P += dp[x][y] * x / (x + y)\n\n# print dp \nprint P\n\n"}, {"source_code": "import sys\nsys.setrecursionlimit(1111)\n\nw,b = map(int, sys.stdin.readline().split())\n\ndp = [[-1 for u in xrange(1001)] for i in xrange(1001)]\n\ndef win(white, black, dragon = False):\n\tif dp[white][black] != -1:\n\t\treturn dp[white][black]\n\t\t\n\tif black < 0:\n\t\treturn 3 # doesn't matter\n\t\t\n\tif white == 0:\n\t\tif dragon == True:\n\t\t\treturn 1.0\n\t\telse:\n\t\t\treturn 0.0\n\n\tif black == 0:\n\t\treturn 1.0\t\t\n\t\n\tgetWhite = float(white) / (white + black)\n\tif dragon == False:\n\t\tgetWhite += (1.0 - getWhite) * (1.0 - win(white, black - 1, dragon = True))\n\telse:\n\t\t#dragon gets black\n\t\tW = float(white) / (white + black - 1)\n\t\tB = 1.0 - W\n\t\tgetWhite += (1.0 - getWhite) * (1.0 - W * win(white - 1, black - 1) - B * win(white, black - 2))\n\t\n\tdp[white][black] = getWhite\n\treturn getWhite\n\nprint win(w,b)"}], "negative_code": [{"source_code": "from collections import deque\n\nw, d = map(int, raw_input().split())\n\ndef is_princess(x, y):\n return (w + d - x - y) % 3 == 0\n\ndp = [[0.0 for j in range(d + 1)] for i in range(w + 1)]\ndp[w][d] = 1.0\n\nQ = deque([(w, d)])\nP = 0.0\n\nwhile Q:\n x, y = Q.popleft()\n \n if is_princess(x, y):\n if (x == w and y == d) or dp[x][y] < 1e-10:\n if x < w and y < d:\n dp[x][y] += dp[x+1][y+1] * (y + 1) / (x + 1 + y + 1) * (x + 1) / (x + 1 + y)\n if y + 1 < d:\n dp[x][y] += dp[x][y+2] * (y + 2) / (x + y + 2) * (y + 1) / (x + y + 1)\n \n if y > 0: \n Q.append((x, y - 1))\n \n else:\n if dp[x][y] < 1e-10:\n if y < d:\n dp[x][y] += dp[x][y + 1] * (y + 1) / (x + y + 1)\n if y > 0:\n Q.append((x - 1, y - 1))\n if y > 1:\n Q.append((x, y - 2))\n \n # print x, y, dp[x][y]\n\nfor x in range(1, w + 1):\n for y in range(d + 1):\n if is_princess(x, y):\n P += dp[x][y] * x / (x + y)\n\n# print dp \nprint P\n\n"}, {"source_code": "from __future__ import division\n\nmemo = {}\ndef prob_win1(w, b):\n if w <= 0:\n return 0.0\n if b <= 0:\n return 1.0\n args = (w, b)\n if args in memo:\n return memo[args]\n win = w / (w + b)\n cont = b / (w + b)\n b -= 1\n if cont > 1.0e-13:\n p_black = prob_win1(w, b - 1) * (b / (w + b))\n p_white = prob_win1(w - 1, b) * (w / (w + b))\n win += cont * (p_black + p_white)\n memo[args] = win\n return win\n\nw, b = map(int, raw_input().split())\nprint prob_win1(w, b)"}, {"source_code": "dp = {}\n\ndef dfs(x,y):\n print x, y\n if x <= 0:\n return 0.0\n if y <= 0:\n return 1.0\n if x == 1 and y==1:\n return 0.5\n if (x,y) in dp:\n return dp[(x,y)]\n else:\n tmp = float(y)/float(x+y)*(float(y-1)/float(x+y-1))\n dp[(x,y)] = float(x)/float(x+y) + tmp*(float(x)*dfs(x-1,y-2) + float(y-2)*dfs(x,y-3))/float(x+y-2)\n return dp[(x,y)]\nw,b = tuple(map(int, raw_input().split()))\n\nprint dfs(w,b)\n"}, {"source_code": "w, b = map(int, raw_input().split())\nk, p, q, s = 0, 0, 1, w + b\nwhile q and k < s:\n d = q * w / s\n p += d; q -= d; s -= 1\n d = q * w / s\n q -= d; s -= 1; k += 1\nprint p"}, {"source_code": "#!/usr/bin/python\n\nprobs={(1,1):0.5}\n\ndef prob(w, b):\n\tif w<=0 or b<0:\n\t\treturn 0\n\tif b==0: #w>0\n\t\treturn 1\n\tif probs.has_key((w, b)):\n\t\treturn probs[(w, b)]\n\tprint (w,b)\n\tww=w\n\tbb=b\n\tw=float(w)\n\tb=float(b)\n\tp1 = w/(b+w-2)\n\tif p1 > 0:\n\t\tp1*=prob(ww-1, bb-2)\n\tp2 = (b-2)/(b+w-2)*prob(ww, bb-3)\n\tanswer = w/(b+w)+(b*(b-1)/((b+w)*(b+w-1)))*(p1+p2)\n\tprobs[(ww, bb)]=answer\n\treturn answer\n\nb, w=tuple(map (int, raw_input().split(\" \")))\n\nprint \"%.9f\"%(prob(float(w), float(b)))\n"}, {"source_code": "import sys\n\nw, b = map(int, sys.stdin.readline().split())\n\nret = 0.0\nn = 0\nwhile True:\n if n-1 < b and w+b > n:\n cur = 1.0\n for i in xrange(n):\n cur *= float(b-i) / float(w+b-i)\n cur *= float(w) / float(w+b-n)\n ret += cur\n n += 2\n else:\n break\n\nprint \"%.9f\" % ret\n"}, {"source_code": "from fractions import Fraction\n\nw, b = [int(x) for x in input().split()]\n\ndef probability(w, b):\n memory = {}\n\n def recursive(w, b):\n if b <= 0:\n return 1.0\n if w <= 0:\n return 0.0\n\n if (w, b) in memory:\n return memory[(w, b)]\n\n white = w\n black = b\n # princess turn\n # chance to win\n answer = white / (black + white)\n\n # chance to continue the game after choosing black mouse\n black -= 1\n cont_p = (1 - answer) * (black /(black + white))\n\n # it's too small to calc next\n if cont_p > 1e-13:\n # dragon chooses black mouse\n black -= 1\n # chance for white mouse pop out\n white_ch = white / (white + black)\n # win chances\n white_p = recursive(white - 1, black) * white_ch\n black_p = recursive(white, black - 1) * (1 - white_ch)\n answer += cont_p * (black_p + white_p)\n\n print(w, b, answer)\n memory[(w, b)] = answer\n return answer\n \n return recursive(w, b)\n\nanswer = probability(w, b)\nprint(answer)"}, {"source_code": "from fractions import Fraction\n\nw, b = [int(x) for x in input().split()]\n\ndef probability(w, b):\n if w == 0:\n return 0\n if b == 0:\n return 1\n\n if b == 5 and w == 5:\n return 0.658730159\n\n memory = {}\n\n def recursive(w, b, t):\n turn = t % 2\n\n if (w, b, turn) in memory:\n return memory[(w, b, turn)]\n\n # princess turn\n if turn == 0:\n answer = Fraction(0)\n if w != 0:\n answer = Fraction(w, (b + w))\n\n if b > 1:\n answer = 1 - (1 - answer) * (1 - recursive(w, b - 1, t + 1))\n else:\n # dragons turn\n answer = 1 - Fraction(w, (b + w))\n if b > 1:\n answer = answer * (recursive(w - 1, b - 1, t + 1) + recursive(w, b - 2, t + 1)) / 2\n\n # print(w, b, t)\n # print(answer)\n memory[(w, b, turn)] = answer\n return answer\n \n return recursive(w, b, 0)\n\nanswer = probability(w, b)\nprint(float(answer))"}, {"source_code": "from fractions import Fraction\n\nw, b = [int(x) for x in input().split()]\n\ndef probability(w, b):\n memory = {}\n\n def recursive(w, b):\n if b <= 0:\n return 1.0\n if w <= 0:\n return 0.0\n\n if (w, b) in memory:\n return memory[(w, b)]\n\n white = w\n black = b\n # princess turn\n # chance to win\n answer = white / (black + white)\n\n # chance to continue the game after choosing black mouse\n black -= 1\n cont_p = (1 - answer) * (black /(black + white))\n\n # it's too small to calc next\n if cont_p > 1e-13:\n # dragon chooses black mouse\n black -= 1\n # chance for white mouse pop out\n white_ch = white / (white + black)\n # win chances\n white_p = recursive(white - 1, black) * white_ch\n black_p = recursive(white, black - 1) * (1 - white_ch)\n answer += cont_p * (black_p + white_p)\n\n memory[(w, b)] = answer\n return answer\n \n return recursive(w, b)\n\nanswer = probability(w, b)\nprint(answer)"}, {"source_code": "from fractions import Fraction\n\nw, b = [int(x) for x in input().split()]\n\ndef probability(w, b):\n if w == 0:\n return 0\n if b == 0:\n return 1\n\n def recursive(w, b, t):\n turn = t % 2\n\n # princess turn\n if turn == 0:\n if w == 0:\n return Fraction(0)\n\n p = Fraction(w, (b + w))\n\n if b <= 1:\n return p\n \n r = (1 - p) * (1 - recursive(w, b - 1, t + 1))\n return 1 - r\n\n # dragons turn\n p = 1 - Fraction(w, (b + w))\n if b <= 1:\n return p\n\n r = p * (recursive(w - 1, b - 1, t + 1) + recursive(w, b - 2, t + 1)) / 2\n return r\n \n return recursive(w, b, 0)\n\nanswer = probability(w, b)\nprint(float(answer))"}, {"source_code": "from fractions import Fraction\n\nw, b = [int(x) for x in input().split()]\n\ndef probability(w, b):\n if w == 0:\n return 0\n if b == 0:\n return 1\n\n memory = {}\n\n def recursive(w, b, t):\n turn = t % 2\n\n if (w, b, turn) in memory:\n return memory[(w, b, turn)]\n\n # princess turn\n if turn == 0:\n answer = Fraction(0)\n if w != 0:\n answer = Fraction(w, (b + w))\n\n if b > 1:\n answer = 1 - (1 - answer) * (1 - recursive(w, b - 1, t + 1))\n else:\n # dragons turn\n answer = 1 - Fraction(w, (b + w))\n if b > 1:\n answer = answer * (recursive(w - 1, b - 1, t + 1) + recursive(w, b - 2, t + 1)) / 2\n\n # print(w, b, t)\n # print(answer)\n memory[(w, b, turn)] = answer\n return answer\n \n return recursive(w, b, 0)\n\nanswer = probability(w, b)\nprint(float(answer))"}, {"source_code": "w, b = map(int, input().split(' '))\n\nif w==0:\n print(0)\nelif b==0:\n print(0)\nelse:\n solved = [[-1]*b for i in range(w)]\n\n def solve(w, b):\n if solved[w-1][b-1] != -1:\n return solved[w-1][b-1]\n if w==0:\n ans = 0\n solved[w-1][b-1] = ans\n return ans\n \n if b==0:\n ans = 1\n solved[w-1][b-1] = ans\n return ans\n \n if b==1:\n ans = w/(w+1)\n solved[w-1][b-1] = ans\n return ans\n \n if b==2:\n if w==1:\n ans = 1/3\n solved[w-1][b-1] = ans\n return ans\n else:\n ans = w/(w+2) + 2/(w+2) * 1/(w+1)\n solved[w-1][b-1] = ans\n return ans\n \n x = solve(w-1, b-2)\n y = solve(w, b-3)\n \n ans = w/(w+b) + b/(w+b) * (b-1)/(w+b-1) * (w/(w+b-2) * x + (b-2)/(w+b-2) * y)\n solved[w-1][b-1] = ans\n return ans\n \n print(solve(w, b)) \n"}, {"source_code": "w, b = map(int, input().split(' '))\n\nsolved = [[-1]*b for i in range(w)]\n\ndef solve(w, b):\n if solved[w-1][b-1] != -1:\n return solved[w][b]\n if w==0:\n ans = 0\n solved[w-1][b-1] = ans\n return ans\n \n if b==0:\n ans = 1\n solved[w-1][b-1] = ans\n return ans\n \n if b==1:\n ans = w/(w+1)\n solved[w-1][b-1] = ans\n return ans\n \n if b==2:\n if w==1:\n ans = 1/3\n solved[w-1][b-1] = ans\n return ans\n else:\n ans = w/(w+2) + 2/(w+2) * 1/(w+1)\n solved[w-1][b-1] = ans\n return ans\n \n x = solve(w-1, b-2)\n y = solve(w, b-3)\n \n ans = w/(w+b) + b/(w+b) * (b-1)/(w+b-1) * (w/(w+b-2) * x + (b-2)/(w+b-2) * y)\n solved[w-1][b-1] = ans\n return ans\n \nprint(solve(w, b)) \n"}, {"source_code": "w, b = map(int, input().split())\nD, P = {0: {i: 1 for i in range(b + 1)}}, {0: {i: 0 for i in range(b + 1)}}\nfor i in range(1, w + 1):\n D[i] = {0: 1}\n P[i] = {0: 0}\n\ndef p(w, b):\n if not w in P: P[w] = {}\n elif b in P[w]: return P[w][b]\n P[w][b] = d(w, b - 1) * b / (w + b)\n return P[w][b]\n\ndef d(w, b):\n if not w in D: D[w] = {}\n elif b in D[w]: return D[w][b]\n x = 0 if b == 1 else (b - 1) * p(w, b - 2)\n y = w * p(w - 1, b - 1)\n D[w][b] = (w + b * (x + y) / (w + b - 1)) / (w + b)\n return D[w][b]\n\nprint(1 - p(w, b))"}, {"source_code": "def f(W, B):\n n = B - W + 1\n d, p, t, r = [0] * B, [0] * B, [1] * B, [0] * B\n\n p[0], r[0], p[1] = 1, 1, 0.5\n for b in range(2, n + 1):\n d[b] = (t[b - 1] + p[b - 2] * (b - 1)) / (1 + b)\n p[b] = (1 + d[b - 1] * b) / (1 + b)\n t, r, p = p, t, r\n\n for w in range(2, W): \n p[1], d[1] = w / (w + 1), 1 / (w + 1)\n for b in range(2, n + w):\n d[b] = ((t[b - 1] * w + p[b - 2] * (b - 1)) * b) / ((w + b) * (w + b - 1))\n p[b] = (w + d[b - 1] * b) / (w + b)\n t, r, p = p, t, r\n\n return t[B - 1]\n\nw, b = map(int, input().split())\nif w == 0: print(0)\nelif b == 0: print(1)\nelse: print(f(w + 1, b + 1))"}, {"source_code": "w, b = [int(i) for i in input().split()]\n\n\ndp = [[-1 for i in range(b+1)] for j in range(w+1)]\n\ndef f(w, b):\n #if w<0 or b<0:\n # return 0\n #if w==0 and b==0:\n # return 0\n if b<=0:\n return 1\n if w == 0:\n return 0\n if dp[w][b] != -1:\n return dp[w][b]\n ans = w/(w+b)\n if w>=1 and b>=2:\n ans += (b/(w+b))*((b-1)/(w+b-1))*((w/(w+b-2)) * f(w-1, b-2))\n if b>=3:\n ans += (b/(w+b))*((b-1)/(w+b-1))*((b-2)/(w+b-2))* f(w, b-3)\n dp[w][b] = ans\n return ans\n\nprint(f(w, b))\n"}, {"source_code": "w, b = [int(i) for i in input().split()]\n\n\ndp = [[-1 for i in range(b+1)] for j in range(w+1)]\n\ndef f(w, b):\n if w<0 or b<0:\n return 0\n if w==0 and b==0:\n return 0\n if b==0:\n return 1\n if w == 0:\n return 0\n if dp[w][b] != -1:\n return dp[w][b]\n ans = w/(w+b)\n if w>=1 and b>=2:\n ans += 0.5*(b/(w+b))*((b-1)/(w+b-1))*(f(w-1, b-2))\n if b>=3:\n ans += 0.5*(b/(w+b))*((b-1)/(w+b-1))*(f(w, b-3))\n dp[w][b] = ans\n return ans\n\nprint(f(w, b))\n"}], "src_uid": "7adb8bf6879925955bf187c3d05fde8c"} {"source_code": "s = raw_input().split()\nn = int(s[0])\nk = int(s[1])\n\nrowCount4 = 0\na = raw_input().split()\n\nfor i in range(k):\n a[i] = int(a[i])\n n -= a[i] / 4\n rowCount4 += a[i] / 4\n a[i] %= 4\n\n if (a[i] == 3):\n rowCount4 += 1\n a[i] = 0\n n -= 1\n \nindex2 = -1\n\nfor i in range(k):\n if (a[i] == 2 and rowCount4 > 0):\n if (index2 == -1):\n index2 = i\n else:\n a[i] = 0\n a[index2] = 0\n index2 = -1\n rowCount4 -= 1 \n\nindex1 = -1\n\nfor i in range(k):\n if (a[i] == 1 and rowCount4 > 0):\n if (index1 == -1):\n index1 = i\n else:\n a[i] = 0\n a[index1] = 0\n index1 = -1\n rowCount4 -= 1\n \n\ncount2 = 0\n\nfor i in range(k):\n if (a[i] == 2):\n a[i] = 0\n count2 += 1\n \nrowCount2 = 0\n\nif (rowCount4 <= 0):\n rowCount2 = count2 / 3\n n -= count2 / 3\n\n count2 %= 3\n\n#43\nwhile count2 > 0 and rowCount2 >= 2:\n rowCount2 -= 2\n count2 -= 1\n \nrowCount4Half = 0\n\ncount1 = 0\n\nfor i in range(k):\n if (a[i] == 1):\n a[i] = 0\n count1 += 1\n if (rowCount2 > 0):\n rowCount2 -= 1\n count1 -= 1\n a[i] = 0\n\nif (count2 > 0):\n count1 -= 4 - count2\n\nif (count2 > 0):\n if (rowCount4 == 0):\n count2 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count2 -= 1\n rowCount4 -= 1\n rowCount4Half += 1\n\nif (count1 > 0):\n n -= count1 / 4\n count1 %= 4\n \nif (count1 > 0):\n if (rowCount4 == 0):\n count1 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count1 -= 1\n if (rowCount4Half > 0):\n rowCount4Half -= 1 \n else:\n rowCount4 -= 1\n rowCount4Half += 1\n\nif (rowCount4 > 0):\n n += rowCount4 / 2\n rowCount4 %= 2\n\nif (n >= 0):\n print \"YES\"\nelse:\n print \"NO\"\n", "positive_code": [{"source_code": "\n\nn,k = [int(_) for _ in raw_input().strip().split()]\na = []*k\na = [int(_) for _ in raw_input().strip().split()]\nd = [0]*10\n\n\ndef process56(nu4, nu2, num):\n\tif (nu4 >= d[num]):\n\t\tnu4 -= d[num]\n\t\tnu2 -= d[num]\n\telse:\n\t\tnu2 -= (d[num]-nu4)*2\n\t\tnu2 -= d[num]\n\t\tnu4 = 0\n\treturn nu4, nu2 \n\ndef process34(nu4, nu2, num):\n\tif (nu4 >= d[num]):\n\t\tnu4 -= d[num]\n\telse:\n\t\tnu2 -= (d[num]-nu4)*2\n\t\tnu4 = 0\n\treturn nu4, nu2 \n\nif __name__ == \"__main__\":\n\tvalue = 0\n\tfor i in range(k):\n\t\tvalue += a[i] / 8\n\t\td[a[i] % 8] += 1\n\n\td[4] += 2*value \n\td[4] += d[7]\n\td[3] += d[7]\n\td[4] += d[6]\n\td[2] += d[6]\n\td[1] += d[5]\n\td[4] += d[5]\n\tnu2 = n*2 \n\tnu4 = n\n\t\n\t\n\tresult = -1\n\tif n >= 0 :\n\t\t# nu4, nu2 = process56(nu4, nu2, 6)\n\t\t# nu4, nu2 = process56(nu4, nu2, 5)\n\t\tnu4, nu2 = process34(nu4, nu2, 4)\n\t\tnu4, nu2 = process34(nu4, nu2, 3)\n\t\t# 2 1\n\t\tif nu4 > d[2] :\n\t\t\tnu4 -= d[2]\n\t\t\td[1] -= d[2]\n\t\t\td[1] = max(0, d[1])\n\t\t\td[1] -= nu4*2\n\t\t\tnu4 = 0\n\t\t\tnu2 -= d[1]\n\t\telse:\n\t\t\td[2] -= nu4 \n\t\t\ttmp = min(nu4, d[1])\n\t\t\td[1] -= tmp\n\n\t\t\tnu4 -= tmp\n\t\t\td[2] -= nu4 / 2\n\n\t\t\td[1] = max(d[1],0)\n\t\t\td[2] = max(d[2],0)\n\t\t\tnu4 = 0\n\t\t\tnu2 -= d[2]+d[1]\n\n\n\tif nu2 < 0 or nu4 < 0 or k < 0 :\n\t\tresult = 1\n\tif result == -1 :\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\""}, {"source_code": "def get(a):\n\treturn map(a , raw_input().split())\n\nn , k = get(int)\nh = get(int)\n\n## 4 se div wale upto 4*n\ntot4 = n\nfor i in xrange(k):\n\tat = h[i]\n\ttt = at / 4\n\t#print tot4\n\tif tt >= 1:\n\t\tif tt <= tot4:\n\t\t\ttot4 -= tt\n\t\t\th[i] -= tt*4\n\t\telse:\n\t\t\th[i] -= tot4*4\n\t\t\ttot4 = 0\n\t#print h, tot4, tt\n## 2 se div wale upto 4*n\ntot2 = 2*n\ntot2 += tot4\nfor i in xrange(k):\n\tat = h[i]\n\ttt = at / 2\n\t#print tot2,'2'\n\tif tt >= 1:\n\t\tif tt <= tot2:\n\t\t\ttot2 -= tt\n\t\t\th[i] -= tt*2\n\t\telse:\n\t\t\th[i] -= tot2*2\n\t\t\ttot2 = 0\n\t#print h, tot2, tt\n## 1 se div wale upto left/2\ntot1 = tot2\ntot1 += tot4\n\nsm = sum(h)\n#print sm, tot1\nif sm <= tot1:\n\tprint 'YES'\nelse:\n\tprint 'NO'\n\n"}, {"source_code": "import sys\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nmid = n\nside = n*2\n\ndef removeZeroes(a):\n return [x for x in a if x > 0]\n\n#FOR 4 \nfor i in range(len(a)):\n if a[i] >= 4:\n while a[i] >= 4 and (mid > 0 or side > 1):\n a[i] -= 4\n if mid:\n mid -= 1\n else:\n side -= 2\n\n#FOR 3\nfor i in range(len(a)):\n if not(mid > 0 or side > 1): \n break\n if a[i] == 3:\n if mid > 0:\n mid -= 1\n else:\n side -= 2\n a[i] = 0\n \n#REMOVE GROUPS WITH 0 REMAINED\na = removeZeroes(a)\n\nif a.count(2) + a.count(1) != len(a):\n print(\"NO\")\n sys.exit(0)\n\nfor i in range(len(a)):\n if a[i] == 2 and side > 0:\n side -= 1\n a[i] = 0\n\nfor i in range(len(a)):\n if a[i] == 1 and side > 0:\n side -= 1\n a[i] = 0\n\na = removeZeroes(a)\na.sort()\nwhile len(a) > 0 and a[0] == 1 and a[-1] == 2 and mid > 0:\n a = a[1:-1]\n mid -= 1\nif len(a) > 0 and a[0] == 1:\n if (a.count(1)+1) // 2 <= mid:\n print(\"YES\")\n sys.exit(0)\n else:\n print(\"NO\")\n sys.exit(0)\nelif len(a) > 0 and a[0] == 2:\n while len(a) > 2 and mid > 1:\n a = a[3:]\n mid -= 2\n if mid >= len(a):\n print(\"YES\")\n sys.exit(0)\n\nif len(a) > 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "from sys import stdin\n\nn,k = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\nfour = n\ntwo = 2*n\none = 0\n\nfor i,x in enumerate(a):\n f = min(four,x//4)\n four -= f\n a[i] -= f*4\n\nif four:\n a.sort(reverse=True)\n v = True\n for x in a:\n if x == 3:\n if four:\n four -= 1\n elif two >= 2:\n two -= 2\n else:\n v = False\n break\n elif x == 2:\n if four:\n four -= 1\n one += 1\n elif two:\n two -= 1\n elif one >= 2:\n one -= 2\n else:\n v = False\n break\n elif x == 1:\n if four:\n four -= 1\n two += 1\n elif two:\n two -= 1\n elif one:\n one -= 1\n else:\n v = False\n break\n if v:\n print('YES')\n else:\n print('NO')\nelse:\n for x in a:\n two -= x//2+x%2\n if two >= 0:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "a,b = raw_input().split()\nc = list(map(int,raw_input().split()))\na = int(a)\nb = int(b)\n\na = a*8\nr=0\ncnt =0\nfor i in range(len(c)):\n if c[i] %2 ==1:\n c[i] = c[i]+1\n cnt = cnt +1\n r = r+c[i]\n \n \n \nif r > a or r==a and b == a/2 and cnt <a/8:\n print \"NO\"\nelse:\n print \"YES\"\n \n \n \n \n \n"}, {"source_code": "n,k = map(int,raw_input().split())\na = 4*n\ns = 0\nfor l in map(int,raw_input().split()):\n\ts +=l+l%2\n\tn -=l%2\nprint('NO'if s>a*2 or (s==a*2and k==a and n>0) else 'YES')\n\n\n\n"}, {"source_code": "\"\"\"\n Author : Arif Ahmad\n Date : \n Algo : \n Difficulty : \n\"\"\"\nfrom sys import stdin, stdout\n\ndef main():\n n, k = [int(_) for _ in stdin.readline().strip().split()]\n a = [int(_) for _ in stdin.readline().strip().split()]\n\n cornerSlot = 2 * n\n middleSlot = 2 * n\n slotForOne = 0\n single = 0\n for x in a:\n req = x // 2\n #print('corner:', cornerSlot, ' middle:', middleSlot, ' single:', slotForOne)\n #print('group of:', x, ' req:', req, '\\n')\n \n if req % 2 == 1:\n hand = 1\n req -= 1\n else:\n hand = 0\n\n # try to accommodate even no. of pairs in middle \n if middleSlot >= req:\n middleSlot -= req\n req = 0\n elif middleSlot > 0 and req > middleSlot:\n req -= middleSlot\n middleSlot = 0\n\n if hand: req += 1\n\n # now accommodate rest of the pairs in the corner\n if cornerSlot >= req:\n cornerSlot -= req\n req = 0\n elif cornerSlot > 0 and req > cornerSlot:\n req -= cornerSlot\n cornerSlot = 0 \n \n # again, accommodate rest of the pairs in middle\n pairInMiddle = False\n if middleSlot >= req and (req > 0):\n middleSlot -= req\n req = 0\n pairInMiddle = True\n elif middleSlot > 0 and req > middleSlot:\n req -= middleSlot\n middleSlot = 0\n pairInMiddle = True\n \n if middleSlot % 2 == 1 and pairInMiddle:\n middleSlot -= 1\n slotForOne += 1\n\n #print('req now:', req)\n if x % 2 == 1: single += 1\n if req > 0: single += (req * 2)\n\n if single > 0:\n if slotForOne >= single:\n slotForOne -= single\n single = 0\n elif slotForOne > 0:\n single -= slotForOne\n slotForOne = 0\n\n total = cornerSlot + middleSlot\n while single > 0 and total > 0:\n total -= 1\n single -= 1\n\n if single: ans = 'NO'\n else: ans = 'YES' \n stdout.write(ans)\n\n\n\nif __name__ == '__main__':\n main()\n "}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ns2 = 2 * n\ns4 = n\ns1 = 0\n\ntmp = sum(map(lambda ai: ai // 4, a))\ns4 -= min(tmp, n)\ns2 -= 2 * max(tmp - n, 0)\n\nfor ai in a:\n if ai % 4 == 2:\n if 0 < s2:\n s2 -= 1\n elif 0 < s4:\n s4 -= 1\n s1 += 1\n else:\n s1 -= 2\n\nfor ai in a:\n if ai % 4 == 1:\n if 0 < s1:\n s1 -= 1\n elif 0 < s2:\n s2 -= 1\n else:\n s4 -= 1\n s2 += 1\n\nfor ai in a:\n if ai % 4 == 3:\n if 0 < s4:\n s4 -= 1\n elif 1 < s2:\n s2 -= 2\n elif 1 == s2:\n s2 -= 1\n s1 -= 1\n else:\n s1 -= 3\n\nif 0 <= s1 and 0 <= s2 and 0 <= s4:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from math import ceil\nn,k = map(int, input().split())\na = list(map(int, input().split()))\n\ndef solve(n,k,a):\n one,two,four = 0, n*2, n\n for size in a:\n while size >= 4:\n if four > 0:\n four -= 1\n else:\n two -= 2\n size -= 4\n\n while size > 0:\n if four > 0:\n four -= 1\n if size == 2:\n one += 1\n elif size == 1:\n two += 1\n break\n elif two > 0:\n two -= 1\n size -= 2\n elif one > 0:\n one -= 1\n size -= 1\n else:\n return \"NO\"\n return \"YES\"\n\n\n\nprint(solve(n,k,sorted(a, reverse=True)))\n\n"}, {"source_code": "n,k = map(int, input().split())\n\na = list(map(int,input().split()))\nall_sum = sum(a)\nr4,r2 = n,n*2\nfor v in range(len(a)):\n\tmid = a[v] // 4\n\ta[v] = a[v] % 4\n\tif mid <= r4:\n\t\tr4 -= mid\n\telse:\n\t\ta[v] += 4 * (mid - r4)\n\t\tr4 = 0\n\tif r4 == 0:\n\t\tbreak\nmid = 0\nr22 = 0\nfor v in a:\n\tif v % 2 == 1:\n\t\tmid += 1\n\tr22 += v // 2\n#print(r4,r22,mid,r2)\nif r4 > 0:\n\tmid -=r4\n\tr22 -= r4\n\tif mid < 0:\n\t\tr22 -= (mid // -2)\n\t\tmid = 0\n\nif r22 + mid > r2:\n\tprint('NO')\nelse:\n\tprint('YES')\n\n\n\n\n\n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nfours,twos,ones=n,2*n,0\n# fill all the fours first\nfor i in range(k):\n\twhile(a[i]>=4):\n\t\ta[i]-=4\n\t\tif fours:fours-=1\n\t\telif twos>=2:twos-=2\n\t\telse:\n\t\t\tprint('NO')\n\t\t\texit()\n# any threes left?\nfor i in range(k):\n\tif a[i]==3:\n\t\ta[i]=0\n\t\tif fours:fours-=1\n\t\telif twos>=2:twos-=2\n\t\telse:\n\t\t\tprint('NO')\n\t\t\texit()\n# any twos left?\nfor i in range(k):\n\tif a[i]==2:\n\t\ta[i]=0\n\t\tif twos:twos-=1\n\t\telif fours:\n\t\t\tfours-=1\n\t\t\tones+=1\n\t\telif ones>=2:ones-=2\n\t\telse:\n\t\t\tprint('NO')\n\t\t\texit()\nones+=2*fours+twos\nif a.count(1)>ones:\n\tprint('NO')\nelse:\n\tprint('YES')"}, {"source_code": "import heapq\nrows, groups = list(map(int,input().split()))\ncounts = list(map(lambda x: (-1)*int(x),input().split()))\n\nfours = rows\ntwos = 2*rows\nones = 0\n\nf = True\nheapq.heapify(counts)\nwhile fours+twos+ones>0 and len(counts)>0:\n i = heapq.heappop(counts)\n i = i * (-1)\n if fours >= 1:\n if i < 4:\n twos+=fours\n ones+=fours\n fours = 0\n heapq.heappush(counts, i*(-1))\n else:\n d, m = divmod(i, 4)\n if d > fours:\n i -= fours*4\n fours=0\n if i>0:\n heapq.heappush(counts, i*(-1))\n else:\n i -= d*4\n fours -= d\n if i>0:\n heapq.heappush(counts, i*(-1))\n elif twos >= 1:\n if i < 2:\n ones += twos\n twos = 0\n heapq.heappush(counts, i*(-1))\n else:\n d, m = divmod(i, 2)\n if d > twos:\n i -= twos*2\n twos = 0\n if i > 0:\n heapq.heappush(counts, i*(-1))\n else:\n i -= d*2\n twos -= d\n if i > 0:\n heapq.heappush(counts, i*(-1))\n elif ones >= 1:\n if i > ones:\n f=False\n break\n else:\n ones -= i\nif len(counts) > 0 or f == False:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n\n\n\n\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort(reverse=True)\nj=1\nans=0\nfor i in range(k):\n if l[i]>=3:\n if j==n+1:\n break\n a=l[i]//4\n b=l[i]%4\n if n+1-j>=a:\n ans+=4*a\n j+=a\n l[i]=b\n else:\n ans+=(n+1-j)*4\n l[i]-=min(l[i],(n+1-j)*4)\n j=n+1\n if j==n+1:\n break\n \n if b==3:\n j+=1\n ans+=4\n l[i]-=3\nl.sort(reverse=True)\nx=1\nfor i in range(k):\n if x==n+1:\n break\n if l[i]==0:\n break\n a=l[i]//2\n b=l[i]%2\n if b>0:\n a+=1\n if n+1-x>=a:\n ans+=2\n x+=a\n l[i]=0\n else:\n ans+=(n+1-x)*2\n l[i]-=min(l[i],(n+1-x)*2)\n x=n+1\n break\nl.sort(reverse=True)\nx=1\nfor i in range(k):\n if x==n+1:\n break\n if l[i]==0:\n break\n a=l[i]//2\n b=l[i]%2\n if b>0:\n a+=1\n if n+1-x>=a:\n ans+=2\n x+=a\n l[i]=0\n else:\n ans+=(n+1-x)*2\n l[i]-=min(l[i],(n+1-x)*2)\n x=n+1\n break\nif l.count(0)!=k:\n if j!=n+1:\n a=l.count(1)\n b=l.count(2)\n x=0\n if a>b:\n x+=b+(a-b)//2\n if (a-b)%2!=0:\n x+=1\n elif b>a:\n x+=a+2*((b-a)//3)\n if (b-a)%3!=0:\n x+=(b-a)%3\n else:\n x=a\n if x<=n+1-j:\n print(\"YES\")\n else:\n print(\"NO\")\n \n \n else:\n print(\"NO\")\nelse:\n print(\"YES\")\n \n\n \n\n \n \n \n\n \n \n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nfours,twos,ones=n,2*n,0\n# fill all the fours first\nfor i in range(k):\n\twhile(a[i]>=4):\n\t\ta[i]-=4\n\t\tif fours:fours-=1\n\t\telif twos>=2:twos-=2\n\t\telse:\n\t\t\tprint('NO')\n\t\t\texit()\n# any threes left?\nfor i in range(k):\n\tif a[i]==3:\n\t\ta[i]=0\n\t\tif fours:fours-=1\n\t\telif twos>=2:twos-=2\n\t\telse:\n\t\t\tprint('NO')\n\t\t\texit()\n# any twos left?\nfor i in range(k):\n\tif a[i]==2:\n\t\ta[i]=0\n\t\tif twos:twos-=1\n\t\telif fours:\n\t\t\tfours-=1\n\t\t\tones+=1\n\t\telif ones>=2:ones-=2\n\t\telse:\n\t\t\tprint('NO')\n\t\t\texit()\nones+=2*fours+twos\nif a.count(1)>ones:\n\tprint('NO')\nelse:\n\tprint('YES')"}, {"source_code": "\"\"\"Problem: http://codeforces.com/contest/839/problem/B\"\"\"\n\nrows, groups = list(map(int, input().strip().split(\" \")))\n\nnumber_soldiers = list(map(int, input().strip().split(\" \")))\n\nrows_whithout_four = rows\nrows_whithout_two = rows * 2\n\nval = True\nremainders = [0, 0]\n\nfor soldiers in number_soldiers:\n\n\twhile soldiers >= 3:\n\n\t\tif rows_whithout_four > 0:\n\n\t\t\trows_whithout_four -= 1\n\t\t\tsoldiers -= 4\n\n\t\telif rows_whithout_two > 0:\n\n\t\t\tsoldiers -= 2\n\t\t\trows_whithout_two -= 1\n\n\t\telse:\n\n\t\t\tval = False\n\n\tif soldiers > 0:\n\t\tremainders[soldiers - 1] += 1\n\n\tif not val:\n\t\tbreak\n\none_sit = 0\n\nwhile remainders[1] and val:\n\n\tif rows_whithout_two > 0:\n\n\t\trows_whithout_two -= 1\n\t\tremainders[1] -= 1\n\n\telif rows_whithout_four > 0:\n\n\t\trows_whithout_four -= 1\n\t\tremainders[1] -= 1\n\t\tone_sit += 1\n\n\telif one_sit >= 2:\n\n\t\tremainders[1] -= 1\n\t\tone_sit -= 2\n\n\telse:\n\n\t\tval = False\n\nif remainders[0] > one_sit + rows_whithout_four * 2 + rows_whithout_two:\n\n\tval = False\n\nif val:\n\n\tprint(\"YES\")\n\nelse:\n\n\tprint(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\n\na = list(map(int, input().split()))\n\nc = [0, 0, 0, 0]\n\nfor t in a:\n c[0] += t//4\n if t%4: c[t%4] += 1\n\nc[0] += c[3]\nc[3] = 0\n\nif c[0] > n:\n c[2] += 2*(c[0]-n)\n c[0] = n\n\nt = min(n-c[0], c[1], c[2])\nc[0] += t\nc[1] -= t\nc[2] -= t\n\nt = min(n-c[0], (c[1]+1)//2)\nc[0] += t\nc[1] -= min(c[1], t*2)\n\nt = min(n-c[0], c[2])\nc[0] += t\nc[2] -= min(c[2], t+t//2)\n\nc[2] += c[1]\nc[1] = 0\n\nprint(\"YES\" if c[2] <= 2*n else \"NO\")"}, {"source_code": "def odd(a):\n return a % 2 == 1\n\n[n, k] = [int(i) for i in input().split()]\ns2, s4 = n*2, n\na = [int(i) for i in input().split()]\n\n# use 4-seat rows first\nfor i in range(k):\n (x,y) = divmod(a[i], 4)\n used4 = min(x, s4)\n unused4 = x - used4\n s4, a[i] = s4-used4, y + 4*unused4\n \n if a[i] == 3 and s4 > 0:\n s4 -= 1\n a[i] = 0\n \n# There are two cases \n# s4 > 0 => a[i] <= 2\n# s4 = 0 => add 1 to odd and check if sum <= rest space\ns1 = s4\nif s4 > 0:\n s2 += s4\n for i in range(k):\n if a[i] == 1 and s1 > 0:\n s1, a[i] = s1-1, 0 \n\nused = sum(a) + len(list(filter(odd,a)))\nif used <= s2*2+s1:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n"}, {"source_code": "import sys\n\nn, k = map(int, input().split())\ntwo = n*2\nfour = n\none = 0\nsolders = list(map(int, input().split()))\nsolders.sort(reverse=True)\n\nfor sol in solders:\n while sol>=4:\n sol-=4\n if four>0:\n four-=1\n elif two>1:\n two-=2\n elif one>3:\n one-=4\n else:\n print(\"NO\")\n sys.exit()\n if sol == 3:\n sol-=3\n if four>0:\n four-=1\n elif two > 1:\n two -= 2\n elif one > 2:\n one -= 3\n else:\n print(\"NO\")\n sys.exit()\n if sol == 2:\n sol -= 2\n if two > 0:\n two -= 1\n elif four > 0:\n four -= 1\n one += 1\n elif one > 1:\n one -= 2\n else:\n print(\"NO\")\n sys.exit()\n if sol == 1:\n sol -= 1\n if one > 0:\n one -= 1\n elif four > 0:\n four -= 1\n two += 1\n elif two > 0:\n two -= 1\n else:\n print(\"NO\")\n sys.exit()\nprint(\"YES\")\n"}, {"source_code": "def func(a):\n\tif(a<0):\n\t\treturn 0\n\telse:\n\t\treturn a\n\nn,k=list(map(int,input().split()))\nl=list(map(int,input().split()))\ntwo = 2*n\nfour = n\nbaki=[]\nfor val in l:\n\tif(val>=4):\n\t\tans=min(four,val//4)\n\t\tval=val-ans*4\n\t\tfour-=ans\n\tans=min(two,(val)//2)\n\tval=val-ans*2\n\ttwo-=ans\n\tbaki.append(func(val))\nstore=sum(baki)\nif(store==0):\n\tprint(\"YES\")\nelif(store>0 and four==0 and two==0):\n\tprint(\"NO\")\nelse:\n\tbaki.sort(reverse=True)\n\tcap1=four\n\tcap2=four\n\tfor val in baki:\n\t\tif(val==3):\n\t\t\tif(cap1>0 and cap2>0):\n\t\t\t\tcap1-=1\n\t\t\t\tcap2-=1\n\t\t\telse:\n\t\t\t\ttwo-=2\n\t\telif(val==2):\n\t\t\tif(two>0):\n\t\t\t\ttwo-=1\n\t\t\telse:\n\t\t\t\tif(cap1>0):\n\t\t\t\t\tcap1-=1\n\t\t\t\telse:\n\t\t\t\t\tcap2-=2\n\t\telif(val==1):\n\t\t\tif(cap2>0):\n\t\t\t\tcap2-=1\n\t\t\telif(cap1>0):\n\t\t\t\tcap1-=1\n\t\t\telse:\n\t\t\t\ttwo-=1\n\tif(cap2<0 or cap1<0 or two<0):\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\t\t\n\n\n\n\t\t\n\n\n"}, {"source_code": "n,k=map(int,input().split())\nwuya=[int(x) for x in input().split()]\nn_4=sum([x//4 for x in wuya])\nwuya=[x%4 for x in wuya]\nn_2=sum([x//2 for x in wuya])\nn_1=sum([x%2 for x in wuya])\np4=n\np4,n_4=p4-min(n_4,p4),n_4-min(n_4,p4)\np2=2*n+p4\nn_2+=2*n_4\np2,n_2=p2-min(n_2,p2),n_2-min(n_2,p2)\np1=p4+p2\nn_1+=n_2*2\nif p1>=n_1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "tmp = input().split()\nn = int(tmp[0])\nk = int(tmp[1])\ntmp = input().split()\nsum = 0\nsum1 = 0\nsum2 = 0\nfor i in range(k):\n if int(tmp[i]) % 4 == 2:\n sum2 += 1\n sum += int(tmp[i])\n sum1 += int(tmp[i]) % 2\nif sum2 > 3 * n:\n if sum + sum1 + (sum2 - 3 * n) * 2 <= 8 * n:\n print('YES')\n else:\n print('NO')\nelse:\n if sum + sum1 <= 8 * n:\n print('YES')\n else:\n print('NO')"}, {"source_code": "\nimport sys\nimport os\nimport math\nimport re\n\n\nn,k = map(int,input().split())\n\nsol = list(map(int,input().split()))\n\ntotalSeats = 8*n\n\nmiddle = n\nleftRight = 2*n\n\nsingle = 0\n\nfor i in range(k):\n fours = min((sol[i]+1)//4,middle) #take the min of 4s needed + one empty and the middle\n middle -= fours\n sol[i] = max(0,sol[i]-4*fours) #soldiers remaining\n\nleftRight += middle\nsingle += middle\n\nfor i in range(k): #now deal with the twos\n twos = min(sol[i]//2, leftRight)\n leftRight -= twos\n sol[i] = max(0, sol[i]-2*twos) #soldiers remaining\n\nsingle += leftRight\n\nfor i in range(k): #all the singles that need a seat\n single -= sol[i]\n\nif single < 0:\n print('No')\nelse:\n print('Yes')\n\n\n"}, {"source_code": "def solve(a, n, k):\n cnt =[0 for i in range(5)]\n duplas, quads, sozinhos = 2*n, n, 0\n for i in a:\n for j in range(k):\n while i >= 3:\n if quads > 0:\n i -= 4; quads -= 1\n elif duplas > 0:\n i -= 2; duplas -= 1\n else: return \"no\"\n if i > 0: \n cnt[i] += 1\n while cnt[2]:\n if duplas > 0:\n duplas -= 1; cnt[2] -= 1\n elif quads > 0:\n cnt[2] -= 1; quads -= 1; sozinhos += 1\n else:\n cnt[2] -= 1; cnt[1] += 2\n if cnt[1] > sozinhos + duplas + 2*quads:\n return \"no\"\n return \"yes\"\n \n\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(a, n, k))"}, {"source_code": "n,k = map(int, input().split())\nA = list(map(int, input().split()))\n\nmiddles = n\nsides = n*2\nsingles = 0\n\nfor i,a in enumerate(A):\n s = a//4\n s = min(s, middles)\n middles -= s\n A[i] -= 4*s\n\nfor i,a in enumerate(A):\n s = a//2\n s = min(s, sides)\n sides -= s\n A[i] -= 2*s\n\nfor i,a in enumerate(A):\n s = a//2\n s = min(s, middles)\n middles -= s\n singles += s\n A[i] -= 2*s\n\nsingles += sides\nsingles += middles*2\n\nfor i,a in enumerate(A):\n s = a\n s = min(s, singles)\n singles -= s\n A[i] -= s\n\nrem = sum(A)\n\nif rem == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "# encoding:utf-8\n\ndef main():\n\tn, k = list(map(int, input().split()))\n\tnums = list(map(int, input().split()))\n\t\n\tseat_two = n * 2\n\tseat_four = n\n\tseat_one = 0\n\tn_four = sum([x // 4 for x in nums])\n\tnums = [x % 4 for x in nums]\n\tn_two = sum([x // 2 for x in nums])\n\tn_one = sum([x % 2 for x in nums]) \n\n\t#print(n_one, n_two, n_four)\n\t#print(seat_one, seat_two, seat_four)\n\n\tif seat_four >= n_four:\n\t\t# there is rest of 4 seat\n\t\tseat_four -= n_four\n\t\tn_four = 0\n\n\t\t# break seat seat_one and seat_two\n\t\tseat_two += seat_four\n\t\tseat_one += seat_four\n\t\tseat_four = 0\n\telse:\n\t\t# there is rest of 4 people\n\t\tn_four -= seat_four\n\t\tseat_four = 0\n\n\t\t# break 4 people to 2, 2\n\t\tn_two += n_four * 2\n\t\tn_four = 0\n\n\t#print(n_one, n_two, n_four)\n\t#print(seat_one, seat_two, seat_four)\n\n\n\tif seat_two >= n_two:\n\t\tseat_two -= n_two\n\t\tn_two = 0\n\t\tif seat_two + seat_one >= n_one:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tn_two -= seat_two\n\t\tseat_two = 0\n\t\tn_one += n_two * 2\n\t\tif seat_one >= n_one:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\nif __name__ == '__main__':\n\tmain()\n1"}, {"source_code": "n, k = map(int, input().split())\n\nl = list(map(int, input().split()))\n\nl = sorted(l, reverse=True)\ns = 0\nfor _ in range(n):\n if l[0] <= 0:\n break\n if l[0] <= 2:\n l[0] -= min(l[0],2)\n s += 1\n l[0] -= min(l[0],4)\n l = sorted(l, reverse=True)\nfor _ in range(n):\n if l[0] <= 0:\n break\n l[0] -= min(l[0],2)\n l = sorted(l, reverse=True)\nfor _ in range(n):\n if l[0] <= 0:\n break\n l[0] -= min(l[0],2)\n l = sorted(l, reverse=True)\nfor _ in range(s):\n if l[0] <= 0:\n break\n l[0] -= min(l[0],1)\n l = sorted(l, reverse=True)\n\n\nif l[0] <= 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "#coding=utf-8\n\ndef test():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n\n total = n * 8\n place = 0\n sum = 0\n i = 0\n temp = 0\n flag = 0\n while i < k:\n sum += a[i]\n if a[i] % 2 is 1:\n place += 1\n else:\n flag += 1\n if a[i] % 4 != 0:\n temp += 1\n i += 1\n if sum == total:\n if ((place != 0 or temp == k) and flag%4==0)or place!=0:\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n if (sum + place) > total or (n*4==k and (flag//4)==place ):\n print(\"NO\")\n else:\n print(\"YES\")\n\n\ntest()"}, {"source_code": "#coding=utf-8\n\ndef test():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n\n total = n * 8\n place = 0\n sum = 0\n i = 0\n temp = 0\n flag = 0\n while i < k:\n sum += a[i]\n if a[i] % 2 is 1:\n place += 1\n else:\n flag += 1\n if a[i] % 4 != 0:\n temp += 1\n i += 1\n if sum == total:\n if place!=0 or (flag%4==0 and n*4==k):\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n if (sum + place) > total or (n*4==k and (flag//4)==place ):\n print(\"NO\")\n else:\n print(\"YES\")\n\n\ntest()"}, {"source_code": "#coding=utf-8\n\ndef test():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n\n total = n * 8\n place = 0\n sum = 0\n flag = 0\n for x in a:\n sum += x\n if x%2 is 1:\n place += 1\n else:\n flag += 1\n if sum == total:\n if place!=0 or (flag%4==0 and n*4==k):\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n if (sum + place) > total or (n*4==k and (flag//4)==place ):\n print(\"NO\")\n else:\n print(\"YES\")\n\n\ntest()"}, {"source_code": "n, k = map(int, input().split())\nseat = {4:n, 2:n*2, 1:0}\nextra1 = 0\na = sorted(map(int, input().split()), reverse=True)\n\ndef sit(n, m):\n num = min(seat[n], m)\n seat[n] -= num\n return m - num\n\nfor m in a:\n p4 = m // 4\n p3, p2, p1 = 0, 0, 0\n if m%4 == 3:\n p3 = 1\n else:\n p2 = int(m % 4 > 1)\n p1 = int(m % 2)\n\n extra4 = sit(4, p4)\n p2 += extra4*2\n if sit(4, p3) > 0:\n p2 += 1\n p1 += 1\n\n extra2 = sit(2, p2)\n x = sit(4, extra2)\n seat[1] += extra2 - x\n p1 += x * 2\n\n extra1 += p1\n\nextra1 = sit(1, extra1)\nx = sit(4, extra1)\nseat[2] += extra1 - x\ny = sit(2, x)\n\nif y > 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0 \nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\nif k-count <= n*8-sum(a):\n if k-count < n and k==n*4:\n print(\"NO\")\n else:\n print('YES')\nelse:print('NO')\n#hack:2 6\\n2 2 2 2 2 6"}, {"source_code": "R=lambda:list(map(int,input().split()))\nn,k=R()\nt=4*n\ns=0\nfor i in R():\n s+=i+i%2\n n-=i%2\nprint('NO'if s>t+t or (s==t+t and k==t and n>0) else 'YES')"}, {"source_code": "import sys\nn, k = [ int(x) for x in input().split() ]\narr = list( map( int, input().split()) )\n\ncnt_2 = 2 * n\ncnt_4 = n\ncnt_1 = 0\n\ni = 0\nwhile(cnt_4 > 0 and i < k):\n tmp = int(arr[i] / 4)\n if(tmp > 0 and cnt_4 > 0):\n arr[i] = arr[i] - 4 * min(tmp, cnt_4)\n cnt_4 = cnt_4 - min(tmp, cnt_4)\n i = i + 1\n\nif(cnt_4 > 0):\n cnt_2 = cnt_2 + cnt_4\n cnt_1 = cnt_1 + cnt_4\n cnt_4 = 0\n\ni = 0\nwhile(cnt_2 > 0 and i < k):\n tmp = int(arr[i] / 2)\n if(tmp > 0 and cnt_2 > 0):\n arr[i] = arr[i] - 2 * min(tmp, cnt_2)\n cnt_2 = cnt_2 - min(tmp, cnt_2)\n i = i + 1\n\nif(cnt_2 > 0):\n cnt_1 = cnt_1 + cnt_2\n cnt_2 = 0\n\ni = 0\nwhile(i < k):\n tmp = arr[i]\n if(tmp > cnt_1):\n print(\"NO\")\n sys.exit(0)\n elif(tmp > 0 and tmp <= cnt_1):\n cnt_1 = cnt_1 - tmp\n arr[i] = arr[i] - tmp\n i = i + 1\n\nprint(\"YES\")\n"}, {"source_code": "N,K = map(int,input().split())\na = [int(i) for i in input().split()]\nN = {4:N,3:0,2:N*2,1:0}\n\nworks = True\na.sort(reverse=True)\n\nfor i in range(K):\n r4 = min(N[4],a[i]//4)\n a[i]-=4*r4\n N[4]-=r4\n\na.sort(reverse = True)\n#print(a,N)\nfor i in range(K):\n if a[i]==0:\n continue\n r2 = min(N[2],a[i]//2)\n a[i]-=2*r2\n N[2]-=r2\n\na.sort(reverse = True)\n#print(a,N)\nfor i in range(K):\n #print(\"a\",a,N,a[i])\n if a[i]==0:\n continue\n if a[i]>=4:\n works = False\n break\n #print(\"x\")\n if a[i]==3:\n #print(\" ai is 3\")\n x = min(N[4],1)\n a[i]-=3*x\n N[4]-=x\n \n elif a[i]==2:\n #print( \"ai is 2\")\n x = min(N[2],a[i]//2)\n a[i]-=2*x\n N[2]-=x\n \n x = min(N[4],a[i]//2)\n a[i]-=2*x\n N[4]-=x\n N[1]+=x\n\n x = min(N[1],a[i])\n a[i]-=x\n N[1]-=x\n\n elif a[i]==1:\n #print(\" ai is 1\")\n N[1]+=N[2]\n N[1]+=2*N[4]\n N[4] = 0\n N[2]=0\n \n x = min(N[1],a[i])\n a[i]-=x\n N[1]-=x\n \n if a[i]!=0:\n #print(a[i])\n works = False\n break\n\n\nif works:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n, k = map(int, input().strip().split())\ngroups = list(map(int, input().strip().split()))\n\n\ndef fetch(delim, num_places):\n for i, g in enumerate(groups):\n num_g = min(g//delim, num_places)\n g -= num_g*delim\n num_places -= num_g\n groups[i] = g\n\n if num_places == 0:\n break\n\n return num_places\n\nnum_4 = fetch(4, n)\nnum_2 = fetch(2, 2*n) + num_4\nnum_2 += fetch(2, num_4)\nif sum(groups) <= num_2:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\n\ndef solve(n, k, a):\n fourSeatLeft = n\n twoSeatLeft = n * 2\n\n for i in range(k):\n while a[i] >= 4:\n if fourSeatLeft > 0:\n fourSeatLeft -= 1\n a[i] -= min(a[i], 4)\n else:\n break\n\n for i in range(k):\n while a[i] >= 3:\n if fourSeatLeft > 0:\n fourSeatLeft -= 1\n a[i] -= min(a[i], 4)\n else:\n break\n\n for i in range(k):\n while a[i] >= 2:\n if twoSeatLeft > 0:\n twoSeatLeft -= 1\n a[i] -= min(a[i], 2)\n else:\n break\n\n for i in range(k):\n while a[i] >= 1:\n if twoSeatLeft > 0:\n twoSeatLeft -= 1\n a[i] -= min(a[i], 2)\n else:\n break\n\n twoSeatLeft += fourSeatLeft\n oneSeatLeft = fourSeatLeft\n fourSeatLeft = 0\n\n for i in range(k):\n while a[i] >= 2:\n if twoSeatLeft > 0:\n twoSeatLeft -= 1\n a[i] -= min(a[i], 2)\n else:\n break\n\n oneSeatLeft += twoSeatLeft\n twoSeatLeft = 0\n\n for i in range(k):\n while a[i] >= 1:\n if oneSeatLeft > 0:\n oneSeatLeft -= 1\n a[i] -= min(a[i], 1)\n else:\n break\n\n if sum(a) > 0:\n return 'NO'\n return 'YES'\n \n\n##if __name__ == '__main__':\n## \n## import sys\n##\n## stdin = sys.stdin\n## sys.stdin = open('cf839b.txt')\n##\n## testcaseNo = eval(input())\n##\n## for c in range(testcaseNo):\n## [n, k] = [eval(v) for v in input().split()]\n## a = [eval(v) for v in input().split()]\n##\n## result = solve(n, k, a)\n##\n## print('Case#' + str(c + 1) + ':', end=' ')\n## print(result)\n##\n## sys.stdin = stdin\n\n[n, k] = [eval(v) for v in input().split()]\na = [eval(v) for v in input().split()]\nprint(solve(n, k, a))\n\n"}, {"source_code": "n, cn = map(int, input().split())\na = list(map(int, input().split()))\nsums = 0\nfor i in a:\n sums += i\ncnt_2 = 2 * n\ncnt_4 = n\ncnt_2_4 = 0\nchk = False\nwhile cnt_4 > 0:\n chk = 0\n for j in range(cn):\n if a[j] > 3:\n a[j] -= 4\n cnt_4 -= 1\n chk = 1\n break\n if (not chk):\n break\n#print(cnt_4, cnt_2_4, cnt_2)\ncnt_2 += cnt_4\ncnt_2_4 += cnt_4\nwhile cnt_2 > 0:\n chk = 0\n for j in range(cn):\n if a[j] > 1:\n a[j] -= 2\n cnt_2 -= 1\n chk = 1\n break\n if (not chk):\n break\ncnt_2_4 += cnt_2\n#print(cnt_4, cnt_2_4, cnt_2)\nwhile cnt_2_4 > 0:\n chk = 0\n for j in range(cn):\n if (a[j] > 0):\n a[j] -= 1\n cnt_2_4 -= 1\n chk = 1\n break\n if (not chk):\n break\n#print(cnt_4, cnt_2_4, cnt_2)\nchk1 = 0\nfor i in a:\n if i > 0:\n chk1 = 1\nif chk1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n,k = map(int,input().split())\ninp = list(map(int,input().split()))\na = n*2\nb = n\nfor i in range(k):\n x = inp[i]//4\n y = min(x,b)\n b-=y\n inp[i]-=(y*4)\na+= b\nc = b\nfor i in range(k):\n x = inp[i]//2\n y = min(x,a)\n a-=y\n inp[i]-=(y*2)\nif sum(inp)<=(a+b):\n print (\"YES\")\nelse:\n print (\"NO\")"}, {"source_code": "n, k = map(int, input().split())\n\nl = [0, 0, 2 * n, 0, n]\n\ninp = sorted(map(int, input().split()), reverse = True)\n\nfor i in range(k):\n\tif inp[i] > 1 and inp[i] & 1:\n\t\tinp[i] -= 1\n\t\tinp.append(1)\n\nfor a in inp:\n\tif a == 1:\n\t\tif l[1]:\n\t\t\tl[1] -= 1\n\t\t\ta = 0\n\t\telif l[2]:\n\t\t\tl[2] -= 1\n\t\t\ta = 0\n\t\telif l[4]:\n\t\t\tl[4] -= 1\n\t\t\tl[2] += 1\n\t\t\ta = 0\n\telse:\t\n\t\twhile a > 2 and l[4]:\n\t\t\ta -= 4\n\t\t\tl[4] -= 1\n\t\twhile a and l[2]:\n\t\t\ta -= 2\n\t\t\tl[2] -= 1\n\t\twhile a and l[4]:\n\t\t\ta -= 2\n\t\t\tl[4] -= 1\n\t\t\tl[1] += 1\n\t\twhile a and l[1]:\n\t\t\ta -= 1\n\t\t\tl[1] -= 1\n\n\tif a:\n\t\tprint('NO')\n\t\texit()\n\nprint('YES')"}, {"source_code": "class Solution(object):\n\n def __init__(self, rows, a):\n self.rows = rows\n self.x = rows\n self.y = 2 * rows\n self.z = 0\n self.a = a\n\n def solve(self):\n length = len(self.a)\n for i in range(length):\n while self.a[i] >= 4 and self.x > 0:\n self.a[i] = self.a[i] - 4\n self.x = self.x - 1\n self.y = self.y + self.x\n self.z = self.x\n \n for i in range(length):\n while self.a[i] >= 2 and self.y > 0:\n self.a[i] = self.a[i] - 2\n self.y = self.y - 1\n self.z = self.y + self.z\n\n for i in range(length):\n while self.a[i] >= 1 and self.z > 0:\n self.a[i] = self.a[i] - 1\n self.z = self.z - 1\n for i in range(length):\n if self.a[i] > 0:\n return False\n return True\n\nline1 = input().split()\nn = int(line1[0])\nk = int(line1[1])\nline2 = input().split()\na = []\nfor i in line2:\n a.append(int(i))\ns = Solution(n, a)\nans = s.solve()\nif ans:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\n\na = list(map(int, input().split()))\n\nc = 0\n\nfor i in range(k):\n if a[i]%2 == 0:\n c += 1\n\nif k-c <= n*8-sum(a):\n if k-c < n and k == n*4:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nmist2=n*2\nmist4=n\notn=10\nfor i in range(k) :\n otn=min(mist4,l[i]//4)\n mist4-=otn\n l[i]-=otn*4\n\nmist2+=mist4\nfor i in range(k) :\n otn=min(mist2,l[i]//2)\n mist2-=otn\n l[i]-=otn*2\n \nmist4+=mist2\n\nmist4-=sum(l)\n\nif mist4>=0 :\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0 \nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\n\n\nif k-count <= n*8-sum(a):\n if k-count < n and k==n*4:\n print(\"NO\")\n else:\n print('YES')\nelse:print('NO')\n\n"}, {"source_code": "rows, groups = map(int, input().split())\nsoldiers=list(map(int, input().split()))\ndef makePlane(rows):\n plane=[int(rows),2*int(rows),0]\n return(plane)\ndef rozdelitVojaky(soldiers):\n ctyrky,dvojky,jednicky=0,0,0\n for skupina in soldiers:\n skupina=int(skupina)\n while skupina>=4:\n ctyrky+=1\n skupina-=4\n if skupina>=2:\n dvojky+=1\n if skupina%2==1:\n jednicky+=1\n return([ctyrky,dvojky,jednicky])\ndef zjistit(rows,groups,soldiers):\n plane=makePlane(rows)\n pasazeri=rozdelitVojaky(soldiers)\n\n #usadit ctverice\n if pasazeri[0]<=plane[0]:\n plane[0]-=pasazeri[0]\n pasazeri[0]=0\n else:\n pasazeri[0]-=plane[0]\n pasazeri[1]+=2*pasazeri[0]\n plane[0]=0\n\n #dvojicky\n #do ctyrmist\n if pasazeri[1]<=plane[0]:\n plane[0]-=pasazeri[1]\n plane[2]+=pasazeri[1]\n pasazeri[1]=0\n else:\n pasazeri[1]-=plane[0]\n plane[2]+=plane[0]\n plane[0]=0\n #do dvojmist\n if pasazeri[1]<=plane[1]:\n plane[1]-=pasazeri[1]\n pasazeri[1]=0\n else:\n pasazeri[1]-=plane[1]\n pasazeri[2]+=2*pasazeri[1]\n plane[1]=0\n #jednotlivci\n pasazeri[2]=pasazeri[2]-2*plane[0]-plane[1]-plane[2]\n if pasazeri[2]<=0:\n return(\"YES\")\n else:\n return(\"NO\")\n\n \nprint(zjistit(rows,groups,soldiers))\n \n"}, {"source_code": "n,k = map(int,input().split())\nm = list(map(int,input().split()))\nmm = []\nfor i in m:\n if i>4:\n mm += [4]*(i//4)\n if i%4!=0:\n mm.append(i%4)\n else:\n mm.append(i)\nmid = n\ncor = n*2\nmm = sorted(mm)\nflag = 0\nwhile 4 in mm:\n mm.pop()\n if mid > 0:\n mid -= 1\n elif cor > 1:\n cor -= 2\n else:\n flag = 1\n break\nif not flag:\n while 3 in mm:\n mm.pop()\n if mid > 0:\n mid -= 1\n elif cor > 1:\n cor -= 2\n else:\n flag = 1\n break\nif not flag:\n while 2 in mm:\n mm.pop()\n if cor > 0:\n cor -= 1\n elif mid > 0:\n if 1 in mm:\n mm.pop(0)\n mid -= 1\n else:\n if 2 in mm:\n mm.pop()\n mm = [1] + mm\n mid -= 1\n else:\n flag = 1\n break\nif not flag:\n while 1 in mm:\n mm.pop()\n if cor > 0:\n cor -= 1\n elif mid > 0:\n if 1 in mm:\n mm.pop(0)\n mid -= 1\n else:\n flag = 1\n break\nif flag:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n,k=map(int, input().split())\nimport sys\na=list(map(int, input().split()))\np=n*2\nd=0\nfor i in range(k):\n while a[i]>=4:\n if n>0:\n n-=1\n a[i]-=4\n elif p>=2:\n p-=2\n a[i]-=4\n elif d>=4:\n d-=4\n a[i]-=4\n else:\n print('NO')\n sys.exit()\n #print(n,p,d)\n if a[i]==3:\n if n>0:\n n-=1\n a[i]-=3\n elif p>=2:\n p-=2\n a[i]-=3\n elif d>=3:\n d-=3\n a[i]-=3\n else:\n print('NO')\n sys.exit()\n #print(n,p,d)\n elif a[i]==2:\n if p>=1:\n p-=1\n a[i]-=2\n elif n>=1:\n n-=1\n a[i]-=2\n d+=1\n elif d>=2:\n d-=2\n a[i]-=2\n else:\n print('NO')\n sys.exit()\n #print(n,p,d)\n elif a[i]==1:\n if d>=1:\n d-=1\n a[i]-=1\n elif n>=1:\n n-=1\n a[i]-=1\n p+=1\n elif p>=1:\n p-=1\n a[i]-=1\n else:\n print('NO')\n sys.exit()\n #print(n,p,d)\nprint('YES') "}, {"source_code": "import sys\n\n\ndef main():\n n, k = map(int, sys.stdin.readline().split())\n x = list(map(int, sys.stdin.readline().split()))\n ch = n\n dv = 2 * n\n\n for i in range(k):\n if x[i] % 4 == 2 and dv > 0:\n x[i] -= 2\n dv -= 1\n for i in range(k):\n while x[i] > 3 and ch > 0:\n x[i] -= 4\n ch -= 1\n\n for i in range(k):\n if x[i] % 4 == 1 and dv > 0:\n x[i] -= 1\n dv -= 1\n\n for i in range(k):\n while x[i] >= 3 and ch > 0:\n x[i] -= 4\n ch -= 1\n p1 = 0\n p2 = 0\n for i in range(k):\n if x[i] == 2:\n if p2 > 0:\n p2 -= 1\n x[i] = 0\n elif ch > 0:\n x[i] = 0\n p1 += 1\n ch -= 1\n elif p1 > 1:\n p1 -= 2\n x[i] = 0\n elif x[i] == 1:\n if p1 > 0:\n p1 -= 1\n x[i] = 0\n elif ch > 0:\n p2 += 1\n x[i] = 0\n ch -= 1\n elif p2 > 0:\n p2 -= 1\n x[i] = 0\n\n while x[i] > 0 and dv > 0:\n x[i] -= 2\n dv -= 1\n\n ok = True\n for i in range(k):\n if x[i] > 0:\n ok = False\n break\n\n if ok:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nmain()\n"}, {"source_code": "import sys\nimport inspect\nimport re\nimport math\nfrom pprint import pprint as pp\nmod = 998244353\nMAX = 10**15\n\n\ndef deb(p):\n for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:\n m = re.search(r'\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)\n print('%s %d' % (m.group(1), p))\n\n\ndef vector(size, val=0):\n vec = [val for i in range(size)]\n return vec\n\n\ndef matrix(rowNum, colNum, val=0):\n mat = []\n for i in range(rowNum):\n collumn = [val for j in range(colNum)]\n mat.append(collumn)\n return mat\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n x, y, z = n, 2 * n, 0\n for i in range(k):\n temp = min(a[i] // 4, x)\n a[i] -= 4 * temp\n x -= temp\n y += x\n z += x\n for i in range(k):\n temp = min(a[i] // 2, y)\n a[i] -= 2 * temp\n y -= temp\n z += y\n for i in range(k):\n temp = min(a[i], z)\n a[i] -= temp\n z -= temp\n for i in range(k):\n if a[i]:\n return print(\"NO\")\n print(\"YES\")\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\n\ndef solve(n, k, groups):\n num_4 = n\n num_2 = 2*n\n num_1 = 0\n remaining_groups = []\n for group in groups:\n if group % 2 == 1:\n if num_4 > 0:\n group -= 1\n num_2 += 1\n num_4 -= 1\n if group > 0:\n remaining_groups.append(group)\n elif num_2 > 0:\n group -= 1\n num_2 -= 1\n if group > 0:\n remaining_groups.append(group)\n else:\n return 'NO'\n else:\n remaining_groups.append(group)\n\n remaining_groups = sorted(remaining_groups, reverse=True)\n for group in remaining_groups:\n if group >= 4 and num_4 > 0:\n req_4 = group / 4\n if req_4 > num_4:\n group -= num_4 * 4\n num_4 = 0\n else:\n num_4 -= req_4\n group -= req_4 * 4\n if group >= 2 and num_2 > 0:\n req_2 = group / 2\n if req_2 > num_2:\n group -= num_2 * 2\n num_2 = 0\n else:\n num_2 -= req_2\n group -= req_2 * 2 \n if group >= 2 and num_4 > 0:\n req_2 = group / 2\n if req_2 > num_4:\n return 'NO'\n else:\n num_4 -= req_2\n num_1 += 1\n group -= req_2*2\n if group >= 2 and num_1 > 0:\n req_1 = group\n if req_1 > num_1:\n return 'NO'\n else:\n num_1 -= req_1\n group -= req_1\n\n if group != 0:\n return 'NO'\n\n return 'YES'\n\nif __name__ == '__main__':\n n, k = map(int, sys.stdin.readline().split())\n groups = map(int, sys.stdin.readline().split())\n print solve(n, k, groups)\n"}, {"source_code": "debug = 0\nread = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2, cnt4)\nc = [0] * 20\nfor i in a:\n c[min(i, 19)] += 1\nif debug:\n print(cnt2, cnt4, c)\nd = min(cnt4, c[3])\nc[3] -= d\ncnt4 -= d\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, (c[2] + 2) // 3 + int(c[2] > 1))\nc[2] -= d + d // 2\ncnt4 -= d\nif debug:\n print('cnt4 = ', cnt4)\n print('c[1] = ', c[1])\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nd = min(cnt4, (c[1] + 1) // 2)\nc[1] -= d * 2\ncnt4 -= d\nd = min(cnt4, c[1])\nc[1] -= d\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "read = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nc = [0] * 20\nfor i in a:\n c[min(i, 19)] += 1\nd = min(cnt4, c[3])\nc[3] -= d\ncnt4 -= d\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, (c[2] + 2) // 3 + int(c[2] > 1))\nc[2] -= d + d // 2\ncnt4 -= d\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nd = min(cnt4, (c[1] + 1) // 2)\nc[1] -= d * 2\ncnt4 -= d\nd = min(cnt4, c[1])\nc[1] -= d\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "from sys import exit\n\nnum_rows, num_groups = map(int, raw_input().split(' '))\n\ngroups = map(int, raw_input().split(' '))\n\nnum_quads, num_doubles = num_rows, 2 * num_rows\n\n# Fully fill up first quads, then doubles, as many as possible\n\nfor i in xrange(num_groups):\n occupiable_quads = min(num_quads, groups[i] / 4)\n\n num_quads -= occupiable_quads\n groups[i] -= 4 * occupiable_quads\n\nfor i in xrange(num_groups):\n occupiable_doubles = min(num_doubles, groups[i] / 2)\n\n num_doubles -= occupiable_doubles\n groups[i] -= 2 * occupiable_doubles\n\n# If there are groups of 4 and up left, problem is infeasible\n# (not sure if this even possible under the assignment conditions, but doesn't hurt to check :>)\n\nif len(filter(lambda x: x >= 4, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1, 2 and 3 people over leftover quads and doubles\n\n# Distribute all groups of 3 over quads\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_quads == 0:\n break\n\n groups[i] = 0\n num_quads -= 1\n\n# If that couldn't be done, place two people of every group of 3 on a double\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_doubles == 0:\n break\n\n groups[i] -= 2\n num_doubles -= 1\n\n# If we coudn't distribute all groups of 3, the problem is infeasible\n\nif len(filter(lambda x: x == 3, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1 and 2 over leftover quads and doubles\n\n# Distribute pairs of 1 and 2 groups over quads, thus filling the quads up\n\nfor i, j in zip(\n filter(lambda i: groups[i] == 1, xrange(num_groups)),\n filter(lambda i: groups[i] == 2, xrange(num_groups))\n ):\n\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\n num_quads -= 1\n\nif num_quads == 0:\n # Subproblem:\n # distribute groups of 1 and 2 over the remaining doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1 or groups[i] == 2:\n groups[i] = 0\n num_doubles -= 1\nelse:\n # There are quads left, but either groups of 1 or groups of 2 are gone (or both)\n\n if len(filter(lambda x: x == 2, groups)) != 0:\n # Subproblem:\n # distribute groups of 2 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 2:\n num_doubles -= 1\n groups[i] = 0\n\n # On every two quads, we can place three groups of 2:\n # [1 1 - 3]\n # [2 2 - 3]\n\n two_groups = filter(lambda i: groups[i] == 2, xrange(num_groups))\n\n for i, j, k in zip(\n two_groups[:len(two_groups) / 3],\n two_groups[len(two_groups) / 3:len(two_groups) / 3 * 2],\n two_groups[len(two_groups) / 3 * 2:]\n ):\n if num_quads < 2:\n break\n\n groups[i] = 0\n groups[j] = 0\n groups[k] = 0\n\n num_quads -= 2\n\n # At most two groups of 2 remain, which requires two quads, or less than two quads are available -- either way,\n # at this point we can only place one group of 2 per quad\n\n for i in xrange(num_groups):\n if num_quads == 0:\n break\n\n if groups[i] == 2:\n groups[i] = 0\n num_quads -= 1\n\n elif len(filter(lambda x: x == 1, groups)) != 0:\n # Subproblem:\n # distribute groups of 1 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1:\n num_doubles -= 1\n groups[i] = 0\n\n one_groups = filter(lambda i: groups[i] == 1, xrange(num_groups))\n\n for i, j in zip(one_groups[:len(one_groups) / 2], one_groups[len(one_groups) / 2:]):\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\n num_quads -= 1\n\n if num_quads != 0:\n for i in xrange(num_groups):\n if groups[i] == 1:\n groups[i] = 0\n num_quads -= 1\n\n break\n\n# If anything has remained after the distribution, the problem is infeasible\n\nif sum(groups) == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "#!/usr/bin/python\n\nimport sys\n\ndef read_obj(cls):\n return cls(sys.stdin.readline().strip())\n\ndef read_obj_list(cls):\n return map(cls, sys.stdin.readline().strip().split())\n\ndef solve():\n n, k = read_obj_list(int)\n an = read_obj_list(int)\n\n an.sort()\n left_4s = n\n\n for i in xrange(k):\n seated_4s = min(an[i] // 4, left_4s)\n left_4s -= seated_4s\n an[i] -= seated_4s * 4\n\n if left_4s == 0:\n break\n\n left_2s = 2 * n + left_4s\n\n for i in xrange(k):\n seated_2s = min(an[i] // 2, left_2s)\n left_2s -= seated_2s\n an[i] -= seated_2s * 2\n\n if left_2s == 0:\n break\n\n left_1s = left_4s + left_2s\n\n if sum(an) > left_1s:\n return \"NO\"\n else:\n return \"YES\"\n\n\nif __name__ == \"__main__\":\n print solve()\n"}, {"source_code": "n,k = map(int, input().split())\n\na = list(map(int,input().split()))\nall_sum = sum(a)\nr4,r2 = n,n*2\nfor v in range(len(a)):\n\tmid = a[v] // 4\n\ta[v] = a[v] % 4\n\tif mid <= r4:\n\t\tr4 -= mid\n\telse:\n\t\ta[v] += 4 * (mid - r4)\n\t\tr4 = 0\n\tif r4 == 0:\n\t\tbreak\nmid = 0\nr22 = 0\nfor v in a:\n\tif v % 2 == 1:\n\t\tmid += 1\n\tr22 += v // 2\n#print(r4,r22,mid,r2)\nif r4 > 0:\n\tmid -=r4\n\tr22 -= r4\n\tif mid < 0:\n\t\tr22 -= (mid // -2)\n\t\tmid = 0\n\nif r22 + mid > r2:\n\tprint('NO')\nelse:\n\tprint('YES')\n\n\n\n\n\n"}, {"source_code": "a=map(int,raw_input().split())\nn=a[0]\nk=a[1]\nb=map(int,raw_input().split())\nb.sort()\nc=2*n\nd=n\nf=0\ne=0\nfor i in range(3*n):\n if d>0:\n if b[len(b)-1]>=4:\n d=d-1\n b[len(b)-1]-=4\n\n else:\n if b[len(b)-1]<=2:\n d=d-1\n e=e+1\n b=[0]+b[0:len(b)-1]\n else:\n d=d-1\n b=[0]+b[0:len(b)-1]\n \n else:\n if c>0:\n if b[len(b)-1]>=2:\n c=c-1\n b[len(b)-1]-=2\n else:\n c=c-1\n b=[0]+b[0:len(b)-1]\n \n else:\n f=2\n break\n b.sort()\n\n \n \n if b==[0]*len(b):\n f=1\n break\n\nif e>0 and f!=1 and f!=2:\n if e>=sum(b):\n f=1\n \n \n\nif f==1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "import sys\nimport heapq\n\n\ndef solve(data, rows):\n fours = rows\n twos = 2 * rows\n ones = 0\n data = [x * -1 for x in data]\n heapq.heapify(data)\n while True:\n if not data:\n return True\n max_group_size = heapq.heappop(data)\n if max_group_size == 0:\n return True\n if fours and max_group_size <= -4:\n fours_required = (-max_group_size) // 4\n fours_to_take = min(fours_required, fours)\n fours -= fours_to_take\n remaining_soldiers = max_group_size + fours_to_take * 4\n if remaining_soldiers != 0:\n heapq.heappush(data, remaining_soldiers)\n continue\n if fours and max_group_size < -2:\n fours -= 1\n continue\n # We don't need fours anymore. Convert them to 1 + 2.\n if fours:\n ones += fours\n twos += fours\n fours = 0\n if twos and max_group_size <= -2:\n twos_required = (-max_group_size) // 2\n twos_to_take = min(twos_required, twos)\n twos -= twos_to_take\n remaining_soldiers = max_group_size + twos_to_take * 2\n if remaining_soldiers != 0:\n heapq.heappush(data, remaining_soldiers)\n continue\n if twos:\n twos -= 1\n continue\n if ones:\n ones -= 1\n remaining_soldiers = max_group_size + 1\n if remaining_soldiers != 0:\n heapq.heappush(data, remaining_soldiers)\n continue\n \n return False\n\n return True\n \n\ndef main():\n rows, n_groups = map(int, sys.stdin.readline().split())\n data = map(int, sys.stdin.readline().split())\n result = solve(data, rows)\n if result:\n print('YES')\n else:\n print('NO')\n\n\nmain()"}, {"source_code": "'''input\n1 4\n2 2 1 2\n'''\nimport math\nL = raw_input().split(\" \")\nL = [int(x) for x in L]\nn = L[0]\nk = L[1]\nL = raw_input().split(\" \")\nL = [int(x) for x in L]\nseats = [0]*5\nseats[2] = 2*n\nseats[4] = n\nf = 0\ncnt = [0,0,0]\nfor i in L :\n\twhile i>=3 :\n\t\tif seats[4]>0 :\n\t\t\tseats[4] = seats[4]-1;\n\t\t\ti = i-4\n\t\telif seats[2]>0 :\n\t\t\tseats[2] = seats[2]-1;\n\t\t\ti = i-2\n\t\telse :\n\t\t\tf = 1\n\t\t\tprint \"NO\"\n\t\t\tbreak\n\tif f==1 :\n\t\tbreak\t\n\tif i>0 :\n\t\tcnt[i] = cnt[i]+1\nwhile cnt[2]>0 :\n\tif seats[4]>0 :\n\t\tseats[4] = seats[4]-1\n\t\tcnt[2] = cnt[2]-1\n\t\tseats[1] = seats[1]+1\n\telif seats[2]>0 :\n\t\tseats[2] = seats[2]-1\n\t\tcnt[2] = cnt[2]-1\n\telse :\n\t\tcnt[2] = cnt[2]-1\n\t\tcnt[1] = cnt[1]+2\n\nif cnt[1]>seats[1]+seats[2]+seats[4]*2 :\n\tprint \"NO\"\n\tf=1\nif f==0 :\n\tprint \"YES\"\n\n\n\n\t\t\n\n"}, {"source_code": "import math\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\nmid = n\nsides = 2*n\narr.sort(reverse=True)\nfor i in range(k):\n if arr[i] >= 3:\n r = min(mid, (arr[i]+1)//4)\n mid -= r\n if mid == 0:\n arr[i] -= r*4\n break\n else:\n if arr[i] % 4 == 3:\n arr[i] = 0\n else:\n arr[i] = arr[i] % 4\n\narr.sort(reverse=True)\nmid_2 = 0\nif mid > 0:\n for i in range(k):\n if arr[i] == 2:\n mid -= 1\n mid_2 += 1\n arr[i] = 0\n if arr[i] == 1:\n mid -= 1\n mid_2 += 1\n arr[i] = 0\n if mid == 0:\n break\n arr.sort()\n for i in range(k):\n if arr[i] == 2 and mid_2 > 1:\n mid_2 -= 2\n arr[i] = 0\n if arr[i] == 1 and mid_2 > 0:\n mid_2 -= 1\n arr[i] = 0\n if mid_2 == 0:\n break\n\narr.sort(reverse=True)\nfor i in range(k):\n sides -= math.ceil(arr[i]/2)\n\nif mid >= 0 and sides >=0:\n print('YES')\nelse:\n print('NO')\n\n\n"}, {"source_code": "n, k = map(int, raw_input().split())\nn1 = 0\nn2 = n * 2\nn4 = n\na = list(map(int, raw_input().split()))\n\nfor i in range(len(a)):\n while a[i] >= 4 and n4 > 0:\n a[i], n4 = a[i] - 4, n4 - 1\n while a[i] >= 4 and n2 > 0:\n a[i], n2 = a[i] - 2, n2 - 1\n if a[i] >= 4:\n print \"NO\"\n quit()\n\nfor i in range(len(a)):\n while a[i] >= 2 and n4 > 0:\n a[i], n4, n1 = a[i] - 2, n4 - 1, n1 + 1\n while a[i] >= 2 and n2 > 0:\n a[i], n2 = a[i] - 2, n2 - 1\n while a[i] >= 2 and n1 > 0:\n a[i], n1 = a[i] - 1, n1 - 1\n if a[i] >= 2:\n print \"NO\"\n quit()\n\nnum = n4 * 2 + n2 + n1\nfor i in range(len(a)):\n while a[i] > 0 and num > 0:\n a[i], num = a[i] - 1, num - 1\n if a[i] > 0:\n print \"NO\"\n quit()\n\nprint \"YES\"\n"}, {"source_code": "n,k = map(int,input().split(\" \"))\n\na = list(map(int,input().split(\" \")))\n\ncount = 0 \n\nfor i in range(0,len(a)):\n\n if a[i]%2 == 0:\n\n count = count + 1\n\n\n\n\n\nif k-count <= n*8-sum(a):\n\n if k-count < n and k==n*4:\n\n print(\"NO\")\n\n else:\n\n print('YES')\n\nelse:print('NO')\n\n\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nleft4seat = n\nleft2seat = n * 2\nleft1seat = 0\nfor i in range (0, k) :\n\tleft4seat -= a[i] // 4\n\tif (left4seat < 0) :\n\t\tleft2seat += 2 * left4seat\n\t\tleft4seat = 0\n\nindex = 0\nwhile (index < k ) :\n\tleftSol = a[index] % 4\n\tif (leftSol == 3) : \n\t\tif (left4seat > 0) : left4seat -= 1\n\t\telse : \n\t\t\tif (left1seat > 0) :\n\t\t\t\tif (left2seat == 0 and left1seat >= 2) : left1seat -= 3\n\t\t\t\telse:\n\t\t\t\t\tleft2seat -= 1\n\t\t\t\t\tleft1seat -= 1\n\t\t\telse :\n\t\t\t\tleft2seat -= 2\n\telif (leftSol == 2) :\n\t\tif (left4seat > 0) : \n\t\t\tleft4seat -= 1\n\t\t\tleft1seat += 1\n\t\telse : \n\t\t\tif (left2seat == 0 and left1seat >= 2) : left1seat -= 2\n\t\t\telse : left2seat -= 1\n\telif (leftSol == 1) :\n\t\tif (left1seat > 0) : left1seat -= 1\n\t\telif (left4seat > 0) : \n\t\t\tleft4seat -= 1\n\t\t\tleft2seat += 1\n\t\telse : \n\t\t\tleft2seat -= 1\n\tif (left4seat < 0 or left2seat < 0) : break\n\tindex += 1\n\nif (index == k and left4seat >= 0 and left2seat >= 0) : print(\"YES\")\nelse : print(\"NO\")"}, {"source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\n\nworks = True\n\nfours = 0\ntwos = 0\nones = 0\n\nfor ele in a:\n t_fours = ele/4\n ele -= t_fours*4\n\n t_twos = ele/2\n ele -= t_twos*2\n\n t_ones = ele\n\n fours += t_fours\n twos += t_twos\n ones += t_ones\n\n\nmid = n\nnorm = 2*n\nsing = 0\n\n\nt = min(mid,fours)\nfours -= t\nmid -= t\n\nif fours > 0:\n #out of mids\n norm -= fours*2\n norm -= twos\n norm -= ones\n\n if norm>=0:\n print \"YES\"\n else:\n print \"NO\"\n \nelse:\n #still have mids, break up\n norm += mid\n sing += mid\n\n norm -= twos\n if norm < 0:\n sing += 2*norm #actually subtracting \n norm = 0\n\n norm -= ones\n if norm < 0:\n sing += norm #actually subtracting \n norm = 0\n\n if sing>=0:\n print \"YES\"\n else:\n print \"NO\"\n\n \n \n \n \n"}, {"source_code": "n,k = map(int,raw_input().split())\nnums = sorted(list(map(int,raw_input().split())),reverse=True)\na = n\nb = n*2\nfor i in range(k):\n if nums[i] >= 4 and a:\n cur = min(a,nums[i]/4)\n a -= cur\n nums[i] -= cur*4\nfor i in range(k):\n if nums[i] >= 3 and a:\n cur = min(a,nums[i]/3)\n a -= cur\n nums[i] -= cur*3\na1 = a\na2 = a\nfor i in range(k):\n if nums[i] >= 2 and b:\n cur = min(b,nums[i]/2)\n b -= cur\n nums[i] -= cur*2\n elif nums[i] >= 2 and a1:\n cur = min(a1,nums[i]/2)\n a1 -= cur\n nums[i] -= cur*2\nfor i in range(k):\n if nums[i] and a2:\n cur = min(a2,nums[i])\n a2 -= cur\n nums[i] -= cur\n elif nums[i] and b:\n nums[i] -= 1\n b -= 1\n elif nums[i] and a1:\n a1 -= 1\n nums[i] -= 1\nif sum(nums):\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "n, k = map(int, raw_input().strip().split())\nvs = map(int, raw_input().strip().split())\nvs.sort()\n\ndef okay(c4, c2, c1):\n ws = []\n for v in vs:\n r = min(c4, v / 4)\n c4 -= r\n v -= 4 * r\n ws.append(v)\n ws.sort()\n for v in ws:\n r = min(c2, v / 2)\n c2 -= r\n v -= 2 * r\n r = min(c1, v)\n c1 -= r\n v -= r\n r = min(c2, v)\n c2 -= r\n v -= r\n if v:\n return False\n return True\n\n\ndef solve():\n for i in xrange(n+1):\n c4 = i\n c2 = 2*n + n - i\n c1 = n - i\n if okay(i, 3*n - i, n - i): return True\n return False\n\nprint 'YES' if solve() else 'NO'\n"}, {"source_code": "from math import ceil\nn, k = map(int, raw_input().split())\nA = map(int, raw_input().split())\ns4 = n\ns2 = n * 2\nt4 = 0\nt2 = 0\nt1 = 0\nfor i in xrange(k):\n t4 += A[i] / 4\n r = A[i] % 4\n if r == 1: t1 += 1\n if r == 2: t2 += 1\n if r == 3: t4 += 1\n\nif t4 >= s4:\n if (t4 - s4) * 2 + t2 + t1 <= s2:\n print 'YES'\n else:\n print 'NO'\nelse:\n c = s4 - t4\n if t2 <= s2:\n if t1 <= s2 - t2 + c * 2:\n print 'YES'\n else:\n print 'NO'\n else:\n if s2 - t2 + c < 0:\n t1 += (t2 - (s2 + c)) * 2\n if t1 <= c:\n print 'YES'\n else:\n print 'NO'\n else:\n if s2 - t2 + 2 * c >= t1:\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "import sys\nimport heapq\n\nclass Seats:\n def __init__(self, n):\n self.seat_que = [-4] * n + [-2, -2] * n\n\n def push(self, x):\n heapq.heappush(self.seat_que, -x)\n\n def pop(self):\n seat = -heapq.heappop(self.seat_que)\n return seat\n\nif __name__ == '__main__':\n n, m = (int(x) for x in input().split())\n soldiers = sorted([int(x) for x in input().split()], reverse=True)\n\n seats = Seats(n)\n for soldier in soldiers:\n while soldier > 0:\n try:\n seat = seats.pop()\n if seat > soldier:\n seats.push(seat - soldier - 1)\n soldier -= seat\n except IndexError:\n print('NO')\n sys.exit()\n print('YES')\n"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\np=n\nfor i in range(m) :\n b=l[i]//4\n l[i]=l[i]-4*min(p,l[i]//4)\n p=p-min(p,b)\n\np1=n*2\nfor i in range(m) :\n b=l[i]//2\n l[i]=l[i]-2*min(p1,l[i]//2)\n p1=p1-min(p1,b)\np2=p+p1\np3=p\nfor i in range(m) :\n b=l[i]//2\n l[i]=l[i]-2*min(p2,l[i]//2)\n p2=p2-min(p2,b)\nk=0\np3+=p2\nfor i in range(m) :\n k=k+l[i]\nif k>p3 :\n print('NO')\nelse :\n print('YES')\n \n \n \n \n \n \n"}, {"source_code": "import sys\n\ndef r():\n return list(map(int, input().split()))\n\nn, k = map(int, input().split())\na = r()\n\ncnt4 = n\ncnt2 = 2*n\ncnt1 = 0\nfor i in range(k):\n x = min((a[i]+1)//4, cnt4)\n cnt4 -= x\n a[i] = max(0, a[i]-4*x)\n\ncnt2 += cnt4\ncnt1 += cnt4\nfor i in range(k):\n x = min(a[i]//2, cnt2)\n cnt2 -= x\n a[i] = max(0, a[i]-2*x)\n\ncnt1 += cnt2\nfor i in range(k):\n cnt1 -= a[i]\n\nif (cnt1 < 0):\n print('NO')\nelse:\n print('YES')\n\n\n \n\n"}, {"source_code": "def main():\n n, k = map(int, input().split())\n cnt, a4 = [0] * 4, 0\n for a in map(int, input().split()):\n a4 += a // 4\n cnt[a % 4] += 1\n _, a1, a2, a3 = cnt\n a4 += a3\n if a4 * 2 < a2:\n n -= a4\n a2 -= a4 * 2\n if a1 * 3 > a2:\n n -= a2 // 3\n a1 -= a2 // 3\n a2 %= 3\n n -= (a1 + a2 + 3) // 4\n else:\n n -= a1\n a2 -= a1 * 3\n n -= a2 // 7 * 2 + (a2 % 7 + 2) // 3\n print((\"YES\", \"NO\")[n < 0])\n else:\n print((\"YES\", \"NO\")[n * 4 < a4 * 2 + a2 + a1])\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n n, cnt = int(input().split()[0]), [0] * 4\n for a in map(int, input().split()):\n cnt[3] += a // 4\n cnt[a % 4] += 1\n _, a1, a2, a4 = cnt\n if a4 * 2 < a2:\n a2 -= a4 * 2\n if a1 * 3 > a2:\n n -= a2 // 3 + (a1 - a2 // 3 + a2 % 3 + 3) // 4\n else:\n a2 -= a1 * 3\n n -= a1 + a2 // 7 * 2 + (a2 % 7 + 2) // 3\n else:\n n = n * 4 - a4 - a2 - a1\n print((\"YES\", \"NO\")[n < a4])\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,k=map(int,raw_input().split())\na=map(int,raw_input().split())\na1,a2,a4=0,2*n,n\nfor x in a:\n while x>3 and a4>0:\n x -= 4\n a4 -= 1\n while x>3 and a2>0:\n x -= 2\n a2 -= 1\n while x>3 and a1>0:\n x-=1\n a1-=1\n if x==3 and a4>0:\n x=0\n a4-=1\n if x==3 and a2>0:\n x=1\n a2-=1\n if x==3 and a1>0:\n x=2\n a1 -= 1\n if x==2 and a2>0:\n a2 -= 1\n x=0\n if x==2 and a4>0:\n a4-=1\n a1+=1\n x-=2\n if x==2 and a1>1:\n a1-=2\n x=0\n if x==1 and a1>0:\n a1-=1\n x-=1\n if x==1 and a4>0:\n a4-=1\n a2+=1\n x=0\n if x==1 and a2>0:\n a2-=1\n x=0\n if x>0:\n print\"NO\"\n exit()\nprint\"YES\"\n"}, {"source_code": "def solve(a, n, k):\n cnt =[0 for i in range(5)]\n duplas, quads, sozinhos = 2*n, n, 0\n for i in a:\n for j in range(k):\n while i >= 3:\n if quads > 0:\n i -= 4; quads -= 1\n elif duplas > 0:\n i -= 2; duplas -= 1\n else: return \"no\"\n if i > 0: \n cnt[i] += 1\n while cnt[2]:\n if duplas > 0:\n duplas -= 1; cnt[2] -= 1\n elif quads > 0:\n cnt[2] -= 1; quads -= 1; sozinhos += 1\n else:\n cnt[2] -= 1; cnt[1] += 2\n if cnt[1] > sozinhos + duplas + 2*quads:\n return \"no\"\n return \"yes\"\n \n\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(a, n, k))\n# 1522848694321\n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ns2=n*2\ns4=n\ns1=0\nf=1\nrem1=0\nrem2=0\nfor i in range(len(a)):\n if(f):\n while(a[i]>=3):\n if(s4>0):\n a[i]-=4\n s4-=1\n elif(s2>0):\n a[i]-=2\n s2-=1\n else:\n f=0\n if(a[i]==1 and f):\n rem1+=1\n elif(a[i]==2 and f):\n rem2+=1\nwhile(rem2>0 and f):\n if(s2>0):\n rem2-=1\n s2-=1\n elif(s4>0):\n rem2-=1\n s4-=1\n s1+=1\n else:\n rem2-=1\n rem1+=2\nif(rem1>s1+s2+s4*2):\n f=0\nif(f):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n, m = map(int, input().split())\nz = list(map(int, input().split()))\nh = z[:]\ndouble = 2 * n\nfour = n\njj = []\nfor i in range(len(h)):\n while four > 0 and h[i] >= 4:\n h[i] -= 4\n four -= 1\n if (h[i] != 0):\n jj.append(h[i])\nss = []\nfor i in range(len(jj)):\n while four > 0 and jj[i] >= 3:\n jj[i] -= 3\n four -= 1\n if jj[i] != 0:\n ss.append(jj[i])\n\ntt = []\nfor i in range(len(ss)):\n while double > 0 and ss[i] >= 2:\n ss[i] -= 2\n double -= 1\n if ss[i]:\n tt.append(ss[i])\n\nplaces = double + four * 2\ngg = []\nfor i in range(len(tt)):\n while four > 0 and tt[i] >= 2:\n tt[i] -= 2\n places -= 1\n four -= 1\n if tt[i]:\n gg.append(tt[i])\nif (sum(gg) <= places):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n\n\n \n"}, {"source_code": "n,k = map(int,raw_input().split())\ninp = [int(x) for x in raw_input().split()]\na = n*2\nb = n\nfor i in xrange(k):\n x = inp[i]/4\n y = min(x,b)\n b-=y\n inp[i]-=(y*4)\na+= b\nc = b\nfor i in xrange(k):\n x = inp[i]/2\n y = min(x,a)\n a-=y\n inp[i]-=(y*2)\nif(sum(inp)<=a+b):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n, k = map(int, input().split())\na = sorted(list(map(int, input().split())))[::-1]\nm = n\nfor j in range(len(a)):\n waste = min(a[j] // 4, m)\n m -= waste\n a[j] -= waste * 4\n if m == 0:\n break\nm1, m2, m3, msukabljat = 0, 0, 0, []\nfor x in a:\n m1 += (x == 1)\n m2 += (x == 2)\n m3 += (x == 3)\n msukabljat += ([x] if x >= 4 else [])\nwaste = min(m1, m2, m)\nm, m1, m2 = m - waste, m1 - waste, m2 - waste\nwaste = min(m3 // 2, m // 2)\nm, m3 = m - waste * 2, m3 - waste * 2\nwaste = min(m2 // 3, m // 2)\nm, m2 = m - waste * 2, m2 - waste * 3\nwaste = min(m1, m2, m3, m // 2)\nm, m1, m2, m3 = m - waste * 2, m1 - waste, m2 - waste, m3 - waste\nwaste = min(m3, m)\nm, m3 = m - waste, m3 - waste\nwaste = min(m1 // 2, m)\nm, m1 = m - waste, m1 - 2 * waste\nwaste = min(m1, m)\nm, m1 = m - waste, m1 - waste\nwaste = min(m2, m)\nm, m2 = m - waste, m2 - waste\nif m1 + m2 + m3 * 2 + sum([x // 2 + x % 2 for x in msukabljat]) <= 2 * n:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "n,k = map(int,raw_input().split());\ncnt = map(int,raw_input().split());\ncnt.sort();\n#cnt.reverse();\n\navailable = 2*n;\nfor i in xrange(k):\n x = min(available,cnt[i]/2);\n cnt[i] -= 2*x;\n available -= x;\n\nr = n;\nfor i in xrange(k):\n x = min(r,cnt[i]/4);\n r -= x;\n cnt[i] -= 4*x;\n\ndef work(need,available):\n x = min(need,available);\n need -= x;\n available -= x;\n return need,available;\n\nif sum(map(lambda x:x >= 4,cnt)) != 0: print \"NO\";\nelse:\n one = sum(map(lambda x:x == 1,cnt));\n two = sum(map(lambda x:x == 2,cnt));\n three = sum(map(lambda x: x == 3, cnt));\n if (two or three) and available: assert False;\n one,available = work(one,available);\n three,r = work(three,r);\n #print one,two,three\n #print r,available\n if three : print \"NO\";\n else:\n three = min(one,two);\n one -= three;\n two -= three;\n three,r = work(three,r);\n if three: print \"NO\";\n else:\n if one and two: assert False;\n #print one,two;\n #print r,available\n if two:\n x = min(two,r);\n two -= x;\n r -= x;\n if 2*two <= x: two = 0;\n two += (one + 1)/2;\n two,r = work(two,r);\n if two: print \"NO\";\n else: print \"YES\";\n\n"}], "negative_code": [{"source_code": "def func(a):\n\tif(a<0):\n\t\treturn 0\n\telse:\n\t\treturn a\n\nn,k=list(map(int,input().split()))\nl=list(map(int,input().split()))\ntwo = 2*n\nfour = n\nbaki=[]\nfor val in l:\n\tif(val>=4):\n\t\tans=min(four,val//4)\n\t\tval=val-ans*4\n\t\tfour-=ans\n\tans=min(two,(val)//2)\n\tval=val-ans*2\n\ttwo-=ans\n\tbaki.append(func(val))\nstore=sum(baki)\nif(store==0):\n\tprint(\"YES\")\nelif(store>0 and four==0 and two==0):\n\tprint(\"NO\")\nelse:\n\tbaki.sort()\n\tfor val in baki:\n\t\tcap1=four\n\t\tcap2=four\n\t\tif(val==3):\n\t\t\tif(cap1>0 and cap2>0):\n\t\t\t\tcap1-=1\n\t\t\t\tcap2-=1\n\t\t\telse:\n\t\t\t\ttwo-=2\n\t\telif(val==2):\n\t\t\tif(two>0):\n\t\t\t\ttwo-=1\n\t\t\telse:\n\t\t\t\tif(cap1>0):\n\t\t\t\t\tcap1-=1\n\t\t\t\telse:\n\t\t\t\t\tcap2-=2\n\t\telse:\n\t\t\tif(cap2>0):\n\t\t\t\tcap2-=1\n\t\t\telif(cap1>0):\n\t\t\t\tcap1-=1\n\t\t\telse:\n\t\t\t\ttwo-=1\n\tif(cap2<0 or cap1<0 or two<0):\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\t\t\n\n\n\n\t\t\n\n\n"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0 \nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\nif count >= n/2:\n print('YES')\nelse:print('NO')\n\n"}, {"source_code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nleft4seat = n\nleft2seat = n * 2\nleft1seat = 0\nfor i in range (0, k) :\n\tleft4seat -= a[i] // 4\n\tif (left4seat < 0) :\n\t\tleft2seat += 2 * left4seat\n\t\tleft4seat = 0\n\nindex = 0\nwhile (index < k ) :\n\tleftSol = a[index] % 4\n\tif (leftSol >= 3) : \n\t\tif (left4seat > 0) : left4seat -= 1\n\t\telse : left2seat -= 2\n\telif (leftSol == 2) :\n\t\tif (left4seat > 0) : \n\t\t\tleft4seat -= 1\n\t\t\tleft1seat += 1\n\t\telse : \n\t\t\tleft2seat -= 1\n\telif (leftSol == 1) :\n\t\tif (left1seat > 0) : left1seat -= 1\n\t\telif (left4seat > 0) : \n\t\t\tleft4seat -= 1\n\t\t\tleft2seat += 1\n\t\telse : \n\t\t\tleft2seat -= 1\n\tif (left4seat < 0 or left2seat < 0) : break\n\tindex += 1\n\nif (index == k and left4seat >= 0 and left2seat >= 0) : print(\"YES\")\nelse : print(\"NO\")"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0\n\nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\n\ncount = k-count\nif count <= n*8-sum(a):\n print('YES')\nelse:print('NO')\n\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort(reverse=True)\nj=1\nans=0\nfor i in range(k):\n if l[i]>=3:\n if j==n+1:\n break\n a=l[i]//4\n b=l[i]%4\n if n+1-j>=a:\n ans+=4*a\n j+=a\n l[i]=b\n else:\n ans+=(n+1-j)*4\n l[i]-=min(l[i],(n+1-j)*4)\n j=n+1\n if j==n+1:\n break\n \n if b==3:\n j+=1\n ans+=4\n l[i]-=3\nl.sort(reverse=True)\nx=1\nfor i in range(k):\n if x==n+1:\n break\n if l[i]==0:\n break\n a=l[i]//2\n b=l[i]%2\n if b>0:\n a+=1\n if n+1-x>=a:\n ans+=2\n x+=a\n l[i]=0\n else:\n ans+=(n+1-x)*2\n l[i]-=min(l[i],(n+1-x)*2)\n x=n+1\n break\nl.sort(reverse=True)\nx=1\nfor i in range(k):\n if x==n+1:\n break\n if l[i]==0:\n break\n a=l[i]//2\n b=l[i]%2\n if b>0:\n a+=1\n if n+1-x>=a:\n ans+=2\n x+=a\n l[i]=0\n else:\n ans+=(n+1-x)*2\n l[i]-=min(l[i],(n+1-x)*2)\n x=n+1\n break\nif l.count(0)!=k:\n if j!=n+1:\n a=l.count(1)\n b=l.count(2)\n if n+1-j<b:\n print(\"NO\")\n else:\n c=a//2\n if a%2!=0:\n c+=1\n d=(c-b)//2\n if (c-b)%2 !=0 and (c-b)>=0:\n d+=1\n c=max(0,d)\n if b+c<=n+1-j:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\nelse:\n print(\"YES\")\n \n\n \n\n \n \n \n\n \n \n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n"}, {"source_code": "import sys\nn, k = [ int(x) for x in input().split() ]\narr = list( map( int, input().split()) )\n\ncnt_2 = 2 * n\ncnt_4 = n\ncnt_1 = 0\n\ni = 0\nwhile(cnt_4 > 0 and i < k):\n tmp = int(arr[i] / 4)\n if(tmp > 0 and tmp <= cnt_4):\n cnt_4 = cnt_4 - tmp\n arr[i] = arr[i] - tmp * 4\n i = i + 1\n\nif(cnt_4 > 0):\n cnt_2 = cnt_2 + cnt_4\n cnt_1 = cnt_1 + cnt_4\n cnt_4 = 0\n\ni = 0\nwhile(cnt_2 > 0 and i < k):\n tmp = int(arr[i] / 2)\n if(tmp > 0 and tmp <= cnt_2):\n cnt_2 = cnt_2 - tmp\n arr[i] = arr[i] - tmp * 2\n i = i + 1\n\nif(cnt_2 > 0):\n cnt_1 = cnt_1 + cnt_2\n cnt_2 = 0\n\ni = 0\nwhile(i < k):\n tmp = arr[i]\n if(tmp > cnt_1):\n print(\"NO\")\n sys.exit(0)\n elif(tmp > 0 and tmp <= cnt_1):\n cnt_1 = cnt_1 - tmp\n arr[i] = arr[i] - tmp\n i = i + 1\n\nprint(\"YES\")\n\n"}, {"source_code": "n,m=map(int,input().split())\nn=n*4\nl=list(map(int,input().split()))\nfor i in range(m) :\n if l[i]%2==0 :\n n=n-(l[i]//2)\n else :\n n=n-(l[i]//2)-1\n \n \n \n\nif n>=0 :\n print(\"YES\")\nelse :\n print('NO')\n"}, {"source_code": "a=map(int,raw_input().split())\nn=a[0]\nk=a[1]\nb=map(int,raw_input().split())\nb.sort()\nc=2*n\nd=n\nf=0\ne=0\nfor i in range(3*n):\n if d>0:\n if b[len(b)-1]>=4:\n d=d-1\n b[len(b)-1]-=4\n\n else:\n if b[len(b)-1]<2:\n d=d-1\n e=e+1\n b=[0]+b[0:len(b)-1]\n else:\n d=d-1\n e=e+1\n b=[0]+b[0:len(b)-1]\n \n else:\n if c>0:\n if b[len(b)-1]>=2:\n c=c-1\n b[len(b)-1]-=2\n else:\n c=c-1\n b=[0]+b[0:len(b)-1]\n \n else:\n f=2\n break\n b.sort()\n\n \n \n if b==[0]*len(b):\n f=1\n break\n\nif e>0 and f!=1 and f!=2:\n for i in range(len(b)-1,0,-1):\n if b[i]>1:\n break\n else:\n b[i]=b[i]-1\n e=e-1\n if b==[0]*len(b):\n f=1\n break\n elif e<=0:\n \n break\n\nif f==1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "def solve(a, n, k):\n cnt =[0 for i in range(5)]\n duplas, quads, sozinhos = 2*n, n, 0\n for i in a:\n for j in range(k):\n while i >= 3:\n if quads > 0:\n i -= 4; quads -= 1\n elif duplas > 0:\n i -= 2; duplas -= 1\n else: return \"no\"\n if i > 0: \n cnt[i] += 1\n while cnt[2]:\n if duplas > 0:\n duplas -= 1; cnt[2] -= 1\n elif quads > 0:\n cnt[2] -= 1; quads -= 1; sozinhos += 1\n else:\n cnt[2] -= 1; cnt[1] += 2\n print(sozinhos, duplas, quads, cnt[1])\n if cnt[1] > sozinhos + duplas + 2*quads:\n return \"no\"\n return \"yes\"\n \n\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(a, n, k))"}, {"source_code": "#coding=utf-8\n\ndef test():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n\n total = n * 8\n place = 0\n sum = 0\n i = 0\n temp = 0\n flag = 0\n while i < k:\n sum += a[i]\n if a[i] % 2 is 1:\n place += 1\n else:\n flag += 1\n if a[i] % 4 != 0:\n temp += 1\n i += 1\n if sum == total:\n if (place != 0 or temp == k) and flag%4==0:\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n if (sum + place) <= total:\n print(\"YES\")\n else:\n print(\"NO\")\n\ntest()"}, {"source_code": "debug = 0\nread = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2, cnt4)\nc = [0] * 20\nfor i in a:\n c[min(i, 19)] += 1\nd = min(cnt4, c[3])\nc[3] -= d\ncnt4 -= d\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nif debug:\n print('cnt4 = ', cnt4)\n print('c[1] = ', c[1])\nd = min(cnt4, (c[1] + 1) // 2)\nc[1] -= d * 2\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "\"\"\"Problem: http://codeforces.com/contest/839/problem/B\"\"\"\n\nrows, groups = list(map(int, input().strip().split(\" \")))\n\nnumber_soldiers = list(map(int, input().strip().split(\" \")))\n\nrows_whithout_four = rows\nrows_whithout_two = rows * 2\n\nval = True\nremainders = [0, 0]\n\nfor soldiers in number_soldiers:\n\n\twhile soldiers >= 3:\n\n\t\tif rows_whithout_four > 0:\n\n\t\t\trows_whithout_four -= 1\n\t\t\tsoldiers -= 4\n\n\t\telif rows_whithout_two > 0:\n\n\t\t\tsoldiers -= 2\n\t\t\trows_whithout_two -= 1\n\n\t\telse:\n\n\t\t\tval = False\n\n\tif soldiers > 0:\n\t\tremainders[soldiers - 1] += 1\n\n\tif not val:\n\t\tbreak\n\none_sit = 0\n\nwhile remainders[1] and val:\n\n\tif rows_whithout_two > 0:\n\n\t\trows_whithout_two -= 1\n\t\tremainders[1] -= 1\n\n\telif rows_whithout_four > 0:\n\n\t\trows_whithout_four -= 1\n\t\tremainders[1] -= 1\n\t\tone_sit += 1\n\n\telse:\n\n\t\tval = False\n\nif remainders[0] > one_sit + rows_whithout_four * 2 + rows_whithout_two:\n\n\tval = False\n\nif val:\n\n\tprint(\"YES\")\n\nelse:\n\n\tprint(\"NO\")"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n##########################################################\nfrom collections import Counter\n# c=sorted((i,int(val))for i,val in enumerate(input().split()))\nimport heapq\n# c=sorted((i,int(val))for i,val in enumerate(input().split()))\n# n = int(input())\n# ls = list(map(int, input().split()))\n#n=int(input())\n#arr = list(map(int, input().split()))\n\n#for _ in range(int(input())):\n\n\n#n=int(input())\nn,x= map(int, input().split())\narr = list(map(int, input().split()))\nans=0\nex=0\nfor i in range(x):\n var=arr[i]\n if ex>0:\n\n if arr[i]>=(x-1):\n\n var-=max(0,ex-1)\n ex=0\n ans+=var//8\n if var%8!=0:\n ans+=1\n ex=8-var\n\n else:\n ex=ex-1-var\n var=0\n\n else:\n\n ans+=arr[i]//8\n if arr[i]%8!=0:\n ex=8-var%8\n ans+=1\n\nprint(\"YES\" if ans<=n else \"NO\")"}, {"source_code": "s = raw_input().split()\nn = int(s[0])\nk = int(s[1])\n\nrowCount4 = 0\na = raw_input().split()\n\nfor i in range(k):\n a[i] = int(a[i])\n n -= a[i] / 4\n rowCount4 += a[i] / 4\n a[i] %= 4\n\n if (a[i] == 3):\n rowCount4 += 1\n a[i] = 0\n n -= 1\n \nindex2 = -1\n\nfor i in range(k):\n if (a[i] == 2 and rowCount4 > 0):\n if (index2 == -1):\n index2 = i\n else:\n a[i] = 0\n a[index2] = 0\n index2 = -1\n rowCount4 -= 1 \n\nindex1 = -1\n\nfor i in range(k):\n if (a[i] == 1 and rowCount4 > 0):\n if (index1 == -1):\n index1 = i\n else:\n a[i] = 0\n a[index1] = 0\n index1 = -1\n rowCount4 -= 1\n \n\ncount2 = 0\n\nfor i in range(k):\n if (a[i] == 2):\n a[i] = 0\n count2 += 1\n \nrowCount2 = 0\n\nif (rowCount4 <= 0):\n rowCount2 = count2 / 3\n n -= count2 / 3\n\n count2 %= 3\n\n#43\nwhile count2 > 0 and rowCount2 >= 2:\n rowCount2 -= 2\n count2 -= 1\n \nrowCount4Half = 0\n\nif (count2 > 0):\n if (rowCount4 == 0):\n count2 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count2 -= 1\n rowCount4 -= 1\n rowCount4Half += 1\n\ncount1 = 0\n\nfor i in range(k):\n if (a[i] == 1):\n a[i] = 0\n count1 += 1\n if (rowCount2 > 0):\n rowCount2 -= 1\n count1 -= 1\n a[i] = 0\n\n\nif (count2 > 0):\n count1 -= 4 - count2\n \nif (count1 > 0):\n n -= count1 / 4\n count1 %= 4\n \nif (count1 > 0):\n if (rowCount4 == 0):\n count1 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count1 -= 1\n if (rowCount4Half > 0):\n rowCount4Half -= 1 \n else:\n rowCount4 -= 1\n rowCount4Half += 1\n\nif (rowCount4 > 0):\n n += rowCount4 / 2\n rowCount4 %= 2\n\nif (n >= 0):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "debug = 0\nread = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2, cnt4)\nc = [0] * 20\nfor i in a:\n c[min(i, 19)] += 1\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nif debug:\n print('cnt4 = ', cnt4)\n print('c[1] = ', c[1])\nd = min(cnt4, (c[1] + 1) // 2)\nc[1] -= d * 2\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "n, m = map(int, input().split())\nz = list(map(int, input().split()))\nh = z[:]\ndouble = 2 * n\nfour = n\njj = []\nfor i in range(len(h)):\n while four > 0 and h[i] >= 4:\n h[i] -= 4\n four -= 1\n if (h[i] != 0):\n jj.append(h[i])\n\ntt = []\nfor i in range(len(jj)):\n while double > 0 and jj[i] >= 2:\n double -= 1\n jj[i] -= 2\n if jj[i] != 0:\n tt.append(jj[i])\nss = []\nfor i in range(len(tt)):\n while four > 0 and tt[i] >= 3:\n four -= 1\n tt[i] -= 3\n if tt[i] != 0:\n ss.append(tt[i])\nff = []\ndouble += 2 * four\nfor i in range(len(ss)):\n while four > 0 and ss[i] >= 2:\n double -= 1\n ss[i] -= 2\n if ss[i] != 0:\n ff.append(ss[i])\n\nans = len(ff)\nans -= min(ff.count(1), double)\nif (ans):\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n \n\n\n \n"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0 \nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\n\n\nif k-count <= n*8-sum(a):\n if k%4==0 and k-count<n:\n print('NO')\n else:\n print('YES')\nelse:print('NO')\n\n"}, {"source_code": "def main():\n n, k = map(int, input().split())\n cnt, a4 = [0] * 4, 0\n for a in map(int, input().split()):\n a4 += a // 4\n cnt[a % 4] += 1\n _, a1, a2, a3 = cnt\n a4 = (a3 + a4) * 2\n if a4 < a2:\n n -= a4\n a2 -= a4 * 2\n if a1 * 3 > a2:\n n -= a2 // 3\n a1 -= a2 // 3\n a2 %= 3\n n -= (a1 + a2 + 3) // 4\n else:\n n -= a1\n a2 -= a1 * 3\n n -= a2 // 7 * 2 + (a2 % 7 + 2) // 3\n print((\"YES\", \"NO\")[n < 0])\n else:\n print((\"YES\", \"NO\")[n * 4 < a4 + a2 + a1])\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\n\nworks = True\nseats_left = n*8\nfor ele in a:\n t = ele\n if t%2==1:\n t += 1\n seats_left -= t\n if seats_left < 0:\n works = False\n break\n\nif works:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "read = lambda: map(int, input().split())\ndebug = 0\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2)\na.sort(reverse = 1)\nfor i in range(n):\n if cnt4 == 0: break\n if a[i] == 0: continue\n if a[i] >= 3:\n cnt4 -= 1\n a[i] = 0\n elif a[i] >= 2:\n if i < n and a[i + 1] > 0:\n a[i + 1] -= 1\n cnt4 -= 1\n a[i] = 0\na.sort(reverse = 1)\nfor i in range(n):\n if cnt4 == 0: break\n if a[i] == 0: continue\n if a[i] >= 3:\n cnt4 -= 1\n a[i] = 0\n elif a[i] >= 2:\n if i < n and a[i + 1] > 0:\n a[i + 1] -= 1\n cnt4 -= 1\n a[i] = 0\na.sort(reverse = 1)\nfor i in range(n):\n cnt = min(cnt4, a[i])\n a[i] -= cnt\n cnt4 -= cnt\nfor i in range(n):\n cnt = min(cnt2, a[i])\n a[i] -= cnt\n cnt2 -= cnt\nprint('YES' if sum(a) == 0 else 'NO')"}, {"source_code": "debug = 1\nread = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2, cnt4)\nc = [0] * 20\nfor i in a:\n c[min(i, 19)] += 1\nif debug:\n print(cnt2, cnt4, c)\nd = min(cnt4, c[3])\nc[3] -= d\ncnt4 -= d\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, (c[2] + 1) // 3)\nc[2] -= d * 3\ncnt4 -= d\nif debug:\n print('cnt4 = ', cnt4)\n print('c[1] = ', c[1])\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nd = min(cnt4, (c[1] + 1) // 2)\nc[1] -= d * 2\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "# encoding:utf-8\n\ndef main():\n\tn, k = list(map(int, input().split()))\n\tnums = list(map(int, input().split()))\n\t\n\tseat_two = n * 2\n\tseat_four = n\n\tseat_one = 0\n\tn_four = sum([x // 4 for x in nums])\n\tnums = [x % 4 for x in nums]\n\tn_two = sum([x // 2 for x in nums])\n\tn_one = sum([x % 2 for x in nums]) \n\n\tif seat_four >= n_four:\n\t\t# there is rest of 4 seat\n\t\tseat_four -= n_four\n\t\tn_four = 0\n\n\t\t# break seat seat_one and seat_two\n\t\tseat_two += seat_four\n\t\tseat_one += seat_four\n\telse:\n\t\t# there is rest of 4 people\n\t\tn_four -= seat_four\n\t\tseat_four = 0\n\n\t\t# break 4 people to 2, 2\n\t\tn_two = n_four * 2\n\n\tif seat_two >= n_two:\n\t\tseat_two -= n_two\n\t\tn_two = 0\n\t\tif seat_two + seat_one >= n_one:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tn_two -= seat_two\n\t\tseat_two = 0\n\t\tn_one += n_two * 2\n\t\tif seat_one >= n_one:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\nif __name__ == '__main__':\n\tmain()\n"}, {"source_code": "\"\"\"\n Author : Arif Ahmad\n Date : \n Algo : \n Difficulty : \n\"\"\"\nfrom sys import stdin, stdout\n\ndef main():\n n, k = [int(_) for _ in stdin.readline().strip().split()]\n a = [int(_) for _ in stdin.readline().strip().split()]\n\n cornerSlot = 2 * n\n middleSlot = 2 * n\n slotForOne = 0\n ans = 'YES'\n for x in a:\n req = x // 2\n #print('corner:', cornerSlot, ' middle:', middleSlot, ' single:', slotForOne)\n #print('group of:', x, ' req:', req, '\\n')\n \n if req % 2 == 1:\n \thand = 1\n \treq -= 1\n else:\n \thand = 0\n\n # try to accommodate even no. of pairs in middle \n if middleSlot >= req:\n middleSlot -= req\n req = 0\n elif middleSlot > 0:\n req -= middleSlot\n middleSlot = 0\n\n if hand: req += 1\n\n # now accommodate rest of the pairs in the corner\n if cornerSlot >= req:\n cornerSlot -= req\n req = 0\n\n elif cornerSlot > 0:\n req -= cornerSlot\n cornerSlot = 0 \n \n # again, accommodate rest of the pairs in middle\n if middleSlot >= req:\n middleSlot -= req\n req = 0\n elif middleSlot > 0:\n req -= middleSlot\n middleSlot = 0\n \n\n if req > 0:\n ans = 'NO'\n break\n\n if middleSlot % 2 == 1:\n middleSlot -= 1\n slotForOne += 1\n\n if x % 2 == 1:\n if slotForOne > 0:\n slotForOne -= 1\n elif middleSlot > 0: \n middleSlot -= 1\n elif cornerSlot > 0: \n cornerSlot -= 1\n else:\n ans = 'NO'\n break\n\n stdout.write(ans)\n\n\n\nif __name__ == '__main__':\n main()\n "}, {"source_code": "from math import ceil\nn, k = map(int, raw_input().split())\nA = map(int, raw_input().split())\nS = 8 * n\nc = 0\nd = 0\n\nfor i in xrange(k):\n c += A[i] / 4\n r = A[i] % 4\n if r == 1 or r == 2: d += 1\n if r == 3: d += 2\n\nif c * 4 + d * 2 > S: print 'NO'\nelse: print 'YES'\n"}, {"source_code": "#coding=utf-8\n\nn,k=map(int,input().split())\na = list(map(int,input().split()))\n\ntotal = n*8\nplace = 0\nsum = 0\ni=0\nwhile i<k:\n sum+=a[i]\n if a[i]%2 is 1:\n place += 1\n i += 1\nif (sum+place) <= total and place != 0:\n print(\"YES\")\nelif (k%3==0 or k%3==2) and place == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n,k=map(int,raw_input().split())\na=map(int,raw_input().split())\na1,a2,a4=0,2*n,n\nfor x in a:\n while x>3 and a4>0:\n x -= 4\n a4 -= 1\n while x>1 and a2>0:\n x -= 2\n a2 -= 1\n if x==3 and a4>0:\n x=0\n a4-=1\n if x==3 and a2>0:\n x=1\n a2-=1\n if x==3 and a1>0:\n x=2\n a1 -= 1\n if x==2 and a2>0:\n a2 -= 1\n x=0\n if x==2 and a4>0:\n a4-=1\n a1+=1\n x-=2\n if x==2 and a1>1:\n a1-=2\n x=0\n if x==1 and a1>0:\n a1-=1\n x-=1\n if x==1 and a4>0:\n a4-=1\n a2+=1\n x=0\n if x==1 and a2>0:\n a2-=1\n x=0\n if x>0:\n print\"NO\"\n exit()\nprint\"YES\"\n"}, {"source_code": "read = lambda: map(int, input().split())\ndebug = 1\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2)\na.sort(reverse = 1)\nfor i in range(n):\n if cnt4 == 0: break\n if a[i] == 0: continue\n if a[i] >= 3:\n cnt4 -= 1\n a[i] = 0\n elif a[i] >= 2:\n if i < n and a[i + 1] > 0:\n a[i + 1] -= 1\n cnt4 -= 1\n a[i] = 0\na.sort(reverse = 1)\nfor i in range(n):\n if cnt4 == 0: break\n if a[i] == 0: continue\n if a[i] >= 3:\n cnt4 -= 1\n a[i] = 0\n elif a[i] >= 2:\n if i < n and a[i + 1] > 0:\n a[i + 1] -= 1\n cnt4 -= 1\n a[i] = 0\na.sort(reverse = 1)\nfor i in range(n):\n cnt = min(cnt4, a[i])\n a[i] -= cnt\n cnt4 -= cnt\nfor i in range(n):\n cnt = min(cnt2, a[i])\n a[i] -= cnt\n cnt2 -= cnt\nprint('YES' if sum(a) == 0 else 'NO')"}, {"source_code": "# encoding:utf-8\n\ndef main():\n\tn, k = list(map(int, input().split()))\n\tnums = list(map(int, input().split()))\n\t\n\ttwo = n * 2\n\tfour = n\n\n\tn_four = sum([x // 4 for x in nums])\n\tnums = [x % 4 for x in nums]\n\n\tif four >= n_four:\n\t\tfour -= n_four\n\t\tn_four = 0\n\t\ttwo += four * 2\n\telse:\n\t\tn_four -= four\n\t\tfour = 0\n\n\tn_two = sum([x // 2 for x in nums])\n\trest = sum([x % 2 for x in nums]) + n_four * 2\n\n\t\n\tif n_two + rest <= two:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\nif __name__ == '__main__':\n\tmain()\n"}, {"source_code": "import sys\nimport inspect\nimport re\nimport math\nfrom pprint import pprint as pp\nmod = 998244353\nMAX = 10**15\n\n\ndef deb(p):\n for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:\n m = re.search(r'\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)\n print('%s %d' % (m.group(1), p))\n\n\ndef vector(size, val=0):\n vec = [val for i in range(size)]\n return vec\n\n\ndef matrix(rowNum, colNum, val=0):\n mat = []\n for i in range(rowNum):\n collumn = [val for j in range(colNum)]\n mat.append(collumn)\n return mat\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n x, y, z = 2 * n, n, 0\n cnt = 0\n for i in range(k):\n y -= a[i] // 4\n a[i] %= 4\n if a[i] % 2 == 1:\n cnt += 1\n a[i] -= a[i] % 2\n if y < 0:\n x += 2 * y\n y = 0\n temp = min(cnt, 2 * y)\n cnt -= temp\n y -= temp // 2\n if cnt:\n x -= cnt\n for i in range(k):\n if y > 0:\n y -= a[i] // 2\n else:\n x -= a[i] // 2\n if x >= 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = raw_input().split()\nn = int(s[0])\nk = int(s[1])\n\nrowCount4 = 0\na = raw_input().split()\n\nfor i in range(k):\n a[i] = int(a[i])\n n -= a[i] / 4\n rowCount4 += a[i] / 4\n a[i] %= 4\n\n if (a[i] == 3):\n rowCount4 += 1\n a[i] = 0\n n -= 1\n \nindex2 = -1\n\nfor i in range(k):\n if (a[i] == 2 and rowCount4 > 0):\n if (index2 == -1):\n index2 = i\n else:\n a[i] = 0\n a[index2] = 0\n index2 = -1\n rowCount4 -= 1 \n\nindex1 = -1\n\nfor i in range(k):\n if (a[i] == 1 and rowCount4 > 0):\n if (index1 == -1):\n index1 = i\n else:\n a[i] = 0\n a[index1] = 0\n index1 = -1\n rowCount4 -= 1\n \n\ncount2 = 0\n\nfor i in range(k):\n if (a[i] == 2):\n a[i] = 0\n count2 += 1\n \nrowCount2 = 0\n\nif (rowCount4 <= 0):\n rowCount2 = count2 / 3\n n -= count2 / 3\n\n count2 %= 3\n \n\nrowCount4Half = 0\n\nif (count2 > 0):\n if (rowCount4 == 0):\n count2 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count2 -= 1\n rowCount4 -= 1\n rowCount4Half += 1\n\ncount1 = 0\n\nfor i in range(k):\n if (a[i] == 1):\n a[i] = 0\n count1 += 1\n if (rowCount2 > 0):\n rowCount2 -= 1\n count1 -= 1\n a[i] = 0\n \nif (count2 > 0):\n count1 -= 4 - count2\n \nif (count1 > 0):\n n -= count1 / 4\n count1 %= 4\n \nif (count1 > 0):\n if (rowCount4 == 0):\n count1 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count1 -= 1\n if (rowCount4Half > 0):\n rowCount4Half -= 1 \n else:\n rowCount4 -= 1\n rowCount4Half += 1\n\nif (rowCount4 > 0):\n n += rowCount4 / 2\n rowCount4 %= 2\n\nif (n >= 0):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "\"\"\"\n Author : Arif Ahmad\n Date : \n Algo : \n Difficulty : \n\"\"\"\nfrom sys import stdin, stdout\n\ndef main():\n n, k = [int(_) for _ in stdin.readline().strip().split()]\n a = [int(_) for _ in stdin.readline().strip().split()]\n\n cornerSlot = 2 * n\n middleSlot = 2 * n\n slotForOne = 0\n ans = 'YES'\n for x in a:\n req = x // 2\n if cornerSlot >= req:\n cornerSlot -= req\n req = 0\n elif cornerSlot > 0:\n req -= cornerSlot\n cornerSlot = 0 \n \n if middleSlot >= req:\n middleSlot -= req\n req = 0\n elif middleSlot > 0:\n req -= middleSlot\n middleSlot = 0\n\n if req > 0:\n ans = 'NO'\n break\n\n if middleSlot % 2 == 1:\n middleSlot -= 1\n slotForOne += 1\n\n if x % 2 == 1:\n if slotForOne > 0:\n slotForOne -= 1\n elif middleSlot > 0: \n middleSlot -= 1\n elif cornerSlot > 0: \n cornerSlot -= 1\n else:\n ans = 'NO'\n break\n\n stdout.write(ans)\n\n\n\nif __name__ == '__main__':\n main()\n "}, {"source_code": "import sys\nimport inspect\nimport re\nimport math\nfrom pprint import pprint as pp\nmod = 998244353\nMAX = 10**15\n\n\ndef deb(p):\n for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:\n m = re.search(r'\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)\n print('%s %d' % (m.group(1), p))\n\n\ndef vector(size, val=0):\n vec = [val for i in range(size)]\n return vec\n\n\ndef matrix(rowNum, colNum, val=0):\n mat = []\n for i in range(rowNum):\n collumn = [val for j in range(colNum)]\n mat.append(collumn)\n return mat\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n x, y, z = 2 * n, n, 0\n cnt = 0\n for i in range(k):\n y -= a[i] // 4\n a[i] %= 4\n if a[i] % 2 == 1:\n cnt += 1\n a[i] -= a[i] % 2\n if y < 0:\n x += 2 * y\n else:\n z = 2 * y\n temp = min(cnt, z)\n cnt -= temp\n z -= temp\n if cnt > 0:\n x -= cnt\n for i in range(k):\n if z > 0:\n z -= a[i] // 2\n else:\n x -= a[i] // 2\n if x >= 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "\nn, k = map(int, raw_input().split(' '))\n\nxs = map(int, raw_input().split(' '))\n\nif sum([x / 2 for x in xs]) + sum([x % 2 for x in xs]) <= 4 * n:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nmist=n*4\nfor x in l :\n mist-=x//2\n \n mist-=x%2\nif mist>=0 :\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0 \nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\n\n\nif k-count <= n*8-sum(a):\n print('YES')\nelse:print('NO')\n\n"}, {"source_code": "\n\ndef solve(n, k, a):\n fourSeatLeft = n\n twoSeatLeft = n * 2\n\n for i in range(k):\n while a[i] >= 3:\n if fourSeatLeft > 0:\n fourSeatLeft -= 1\n a[i] -= min(a[i], 4)\n else:\n break\n\n for i in range(k):\n while a[i] >= 1:\n if twoSeatLeft > 0:\n twoSeatLeft -= 1\n a[i] -= min(a[i], 2)\n else:\n break\n\n twoSeatLeft += fourSeatLeft\n oneSeatLeft = fourSeatLeft\n fourSeatLeft = 0\n\n for i in range(k):\n while a[i] >= 2:\n if twoSeatLeft > 0:\n twoSeatLeft -= 1\n a[i] -= min(a[i], 2)\n else:\n break\n\n for i in range(k):\n while a[i] == 1:\n if oneSeatLeft > 0:\n oneSeatLeft -= 1\n a[i] -= min(a[i], 1)\n else:\n break\n\n if sum(a) > 0:\n return 'NO'\n return 'YES'\n \n\n##if __name__ == '__main__':\n## \n## import sys\n##\n## stdin = sys.stdin\n## sys.stdin = open('cf839b.txt')\n##\n## testcaseNo = eval(input())\n##\n## for c in range(testcaseNo):\n## [n, k] = [eval(v) for v in input().split()]\n## a = [eval(v) for v in input().split()]\n##\n## result = solve(n, k, a)\n##\n## print('Case#' + str(c + 1) + ':', end=' ')\n## print(result)\n##\n## sys.stdin = stdin\n\n[n, k] = [eval(v) for v in input().split()]\na = [eval(v) for v in input().split()]\nprint(solve(n, k, a))\n\n"}, {"source_code": "\n\nn,k = [int(_) for _ in raw_input().strip().split()]\na = []*k\na = [int(_) for _ in raw_input().strip().split()]\nd = [0]*10\n\n\ndef process56(nu4, nu2, num):\n\tif (nu4 >= d[num]):\n\t\tnu4 -= d[num]\n\t\tnu2 -= d[num]\n\telse:\n\t\tnu2 -= (d[num]-nu4)*2\n\t\tnu2 -= d[num]\n\t\tnu4 = 0\n\treturn nu4, nu2 \n\ndef process34(nu4, nu2, num):\n\tif (nu4 >= d[num]):\n\t\tnu4 -= d[num]\n\telse:\n\t\tnu2 -= (d[num]-nu4)*2\n\t\tnu4 = 0\n\treturn nu4, nu2 \n\nif __name__ == \"__main__\":\n\n\tfor i in range(k):\n\t\tn -= a[i] / 8\n\t\td[a[i] % 8] += 1\n\n\n\tn -= d[7]\n\tnu2 = n*2 \n\tnu4 = n\n\tresult = -1\n\tif n >= 0 :\n\t\tnu4, nu2 = process56(nu4, nu2, 6)\n\t\tnu4, nu2 = process56(nu4, nu2, 5)\n\n\t\tnu4, nu2 = process34(nu4, nu2, 4)\n\t\tnu4, nu2 = process34(nu4, nu2, 3)\n\n\t\t# 2 1 \n\t\tif nu4 > d[2] :\n\t\t\ttmp = 0\n\t\t\tif d[2]*2 % 3 > 0 : \n\t\t\t\ttmp = 1 \n\t\t\tnu4 -= d[2]*2 / 3 + tmp\n\t\t\tnu2 += nu4*2\n\t\t\tnu4 = 0\n\t\t\tnu2 -= d[1]\n\t\telse:\n\t\t\td[2] -= nu4 + nu4 / 2\n\t\t\tif nu4 % 2 == 1 : \n\t\t\t\td[1] -= 1\n\t\t\tnu4 = 0\n\t\t\tnu2 -= d[2]+d[1]\n\n\n\tif nu2 < 0 or nu4 < 0 or k < 0 :\n\t\tresult = 1\n\tif result == -1 :\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\""}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nmist=n*4\nfor x in l :\n mist-=x/2\n mist-=x%2!=0\nif mist>=0 :\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\n\nl = [0, 0, 2 * n, 0, n]\n\ninp = sorted(map(int, input().split()), reverse = True)\n\nfor i in range(k):\n\tif inp[i] > 1 and inp[i] & 1:\n\t\tinp[i] -= 1\n\t\tinp.append(1)\n\nfor a in inp:\n\tif a == 1:\n\t\tif l[1]:\n\t\t\tl[1] -= 1\n\t\t\ta = 0\n\t\telif l[2]:\n\t\t\tl[2] -= 1\n\t\t\ta = 0\n\t\telif l[4]:\n\t\t\tl[4] -= 1\n\t\t\tl[2] += 1\n\t\t\ta = 0\n\telse:\t\n\t\twhile a > 2 and l[4]:\n\t\t\ta -= 4\n\t\t\tl[4] -= 1\n\t\twhile a and l[2]:\n\t\t\ta -= 2\n\t\t\tl[2] -= 1\n\t\twhile a and l[4]:\n\t\t\ta -= 2\n\t\t\tl[4] -= 1\n\t\t\tl[1] += 1\n\n\tif a:\n\t\tprint('NO')\n\t\texit()\n\nprint('YES')"}, {"source_code": "n, m = map(int, input().split())\nz = list(map(int, input().split()))\nh = []\nfor i in range(len(z)):\n n -= z[i] // 8\n z[i] %= 8\n if (z[i] != 0):\n h.append(z[i])\ndouble = 2 * n\nfour = n\njj = []\nfor i in range(len(h)):\n if four > 0 and h[i] >= 4:\n h[i] -= 4\n four -= 1\n if (h[i] != 0):\n jj.append(h[i])\n\ntt = []\nfor i in range(len(jj)):\n while double > 0 and jj[i] >= 2:\n double -= 1\n jj[i] -= 2\n if jj[i] != 0:\n tt.append(jj[i])\nss = []\nfor i in range(len(tt)):\n while four > 0 and tt[i] >= 3:\n four -= 1\n tt[i] -= 3\n if tt[i] != 0:\n ss.append(tt[i])\nff = []\nfor i in range(len(ss)):\n while four > 0 and ss[i] >= 2:\n double -= 1\n ss[i] -= 2\n if ss[i] != 0:\n ff.append(ss[i])\n\ndouble += 2 * four\nans = len(ff)\nans -= min(ff.count(1), double)\nif (ans):\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n \n\n\n \n"}, {"source_code": "\"\"\"Problem: http://codeforces.com/contest/839/problem/B\"\"\"\n\nrows, groups = list(map(int, input().strip().split(\" \")))\n\nnumber_soldiers = list(map(int, input().strip().split(\" \")))\n\nrows_whithout_four = rows\nrows_whithout_two = rows * 2\n\nval = True\nremainders = [0, 0]\n\nfor soldiers in number_soldiers:\n\n\twhile soldiers >= 3:\n\n\t\tif rows_whithout_four > 0:\n\n\t\t\trows_whithout_four -= 1\n\t\t\tsoldiers -= 4\n\n\t\telif rows_whithout_two > 0:\n\n\t\t\tsoldiers -= 2\n\t\t\trows_whithout_two -= 1\n\n\t\telse:\n\n\t\t\tval = False\n\n\tif soldiers > 0:\n\t\tremainders[soldiers - 1] += 1\n\n\tif not val:\n\t\tbreak\n\none_sit = 0\n\nwhile remainders[1] and val:\n\n\tif rows_whithout_two > 0:\n\n\t\trows_whithout_two -= 1\n\t\tremainders[1] -= 1\n\n\telif rows_whithout_four > 0:\n\n\t\trows_whithout_four -= 1\n\t\tremainders[1] -= 1\n\t\tone_sit += 1\n\n\telse:\n\n\t\tval = False\n\nif remainders[0] > one_sit + rows_whithout_four + rows_whithout_two:\n\n\tval = False\n\nif val:\n\n\tprint(\"YES\")\n\nelse:\n\t\n\tprint(\"NO\")"}, {"source_code": "class Solution(object):\n\n def __init__(self, rows, a):\n self.rows = rows\n self.x = rows\n self.y = 2 * rows\n self.z = 0\n self.a = a\n\n def solve(self):\n length = len(self.a)\n for i in range(length):\n while self.a[i] >= 4 and self.x > 0:\n self.a[i] = self.a[i] - 4\n self.x = self.x - 1\n self.y = self.y + self.x\n self.z = self.x\n \n for i in range(length):\n while self.a[i] >= 2 and self.y > 0:\n self.a[i] = self.a[i] - 2\n self.y = self.y - 1\n self.z = self.y + self.z\n\n for i in range(length):\n if self.a[i] > 1:\n return False\n while self.a[i] >= 1 and self.z > 0:\n self.a[i] = self.a[i] - 1\n self.z = self.z - 1\n for i in range(length):\n if self.a[i] > 0:\n return False\n return True\n\nline1 = input().split()\nn = int(line1[0])\nk = int(line1[1])\nline2 = input().split()\na = []\nfor i in line2:\n a.append(int(i))\ns = Solution(n, a)\nans = s.solve()\nif ans:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, m = map(int, input().split())\nz = list(map(int, input().split()))\nh = z[:]\ndouble = 2 * n\nfour = n\njj = []\nfor i in range(len(h)):\n if four > 0 and h[i] >= 4:\n h[i] -= 4\n four -= 1\n if (h[i] != 0):\n jj.append(h[i])\n\ntt = []\nfor i in range(len(jj)):\n while double > 0 and jj[i] >= 2:\n double -= 1\n jj[i] -= 2\n if jj[i] != 0:\n tt.append(jj[i])\nss = []\nfor i in range(len(tt)):\n while four > 0 and tt[i] >= 3:\n four -= 1\n tt[i] -= 3\n if tt[i] != 0:\n ss.append(tt[i])\nff = []\nfor i in range(len(ss)):\n while four > 0 and ss[i] >= 2:\n double -= 1\n ss[i] -= 2\n if ss[i] != 0:\n ff.append(ss[i])\n\ndouble += 2 * four\nans = len(ff)\nans -= min(ff.count(1), double)\nif (ans):\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n \n\n\n \n"}, {"source_code": "debug = 0\nread = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2)\nc = [0] * 100\nfor i in a:\n c[min(i, 97)] += 1\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nd = min(cnt4, c[1])\nc[1] -= d\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "a=map(int,raw_input().split())\nn=a[0]\nk=a[1]\nb=map(int,raw_input().split())\nb.sort()\nc=2*n\nd=n\nf=0\ne=0\nfor i in range(3*n):\n if d>0:\n if b[len(b)-1]>=4:\n d=d-1\n b[len(b)-1]-=4\n\n else:\n if b[len(b)-1]<2:\n d=d-1\n e=e+1\n b=[0]+b[0:len(b)-1]\n else:\n d=d-1\n e=e+1\n b=[0]+b[0:len(b)-1]\n \n else:\n if c>0:\n if b[len(b)-1]>=2:\n c=c-1\n b[len(b)-1]-=2\n else:\n c=c-1\n b=[0]+b[0:len(b)-1]\n \n else:\n f=2\n break\n b.sort()\n\n \n \n if b==[0]*len(b):\n f=1\n break\n\nif e>0 and f!=1 and f!=2:\n if e>=sum(b):\n f=1\n \n \n\nif f==1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "tmp = input().split()\nn = int(tmp[0])\nk = int(tmp[1])\ntmp = input().split()\nsum = 0\nsum2 = 0\nsum1 = 0\nsum3 = 0\nsum0 = 0\nfor i in range(k):\n a = int(tmp[i])\n sum += a\n if a % 4 == 3:\n sum3 += 1\n elif a % 4 == 2:\n sum2 += 1\n elif a % 4 == 1:\n sum1 += 1\n else:\n sum0 += 1\nif sum2 > 3 * n:\n print('NO')\nelif sum2 + sum3 > 3 * n:\n print('NO')\nelse:\n if sum + sum1 + sum3 <= 8 * n:\n print('YES')\n else:\n print('NO')"}, {"source_code": "n, k = map(int, input().split())\narr = list(map(int, input().split()))\nn -= sum([x//8 for x in arr])\nt = [x % 8 for x in arr]\nmid = n\nsides = 2*n\nones = arr.count(1)\narr.sort(reverse=True)\nmid_2 = 0\nfor i in range(k):\n if t[i] > 6:\n if mid > 0:\n mid -= 1\n else:\n sides -= 2\n sides -= 2\n elif t[i] > 4:\n if mid > 0:\n mid -= 1\n else:\n sides -= 2\n sides -= 1\n elif t[i] > 2:\n if mid > 0:\n mid -= 1\n else:\n sides -= 2\n else:\n if t[i] == 2 and mid > 0:\n if ones > 0:\n mid_2 += 1\n ones -= 1\n mid -= 1\n elif t[i] == 2:\n sides -= 1\n elif t[i] == 1:\n if mid_2 > 0:\n mid_2 -= 1\n else:\n sides -= 1\n\nif sides >= 0 and mid >= 0:\n print('YES')\nelse:\n print('NO')\n\n\n"}, {"source_code": "from math import ceil\nn, k = map(int, raw_input().split())\nA = map(int, raw_input().split())\ns4 = n\ns2 = n * 2\nt4 = 0\nt2 = 0\nt3 = 0\nfor i in xrange(k):\n t4 += A[i] / 4\n r = A[i] % 4\n if r == 1 or r == 2: t2 += 1\n if r == 3: t3 += 1\n\nif t4 >= s4:\n if (t4 - s4) * 2 + t2 + t3 * 2 <= s2:\n print 'YES'\n else:\n print 'NO'\nelse:\n c = s4 - t4\n if t3 >= c:\n if (t3 - c) * 2 + t2 <= s2: print 'YES'\n else: print 'NO'\n else:\n if (c - t3) + s2 >= t2: print 'YES'\n else: print 'NO'"}, {"source_code": "import sys\n\ndef solve(n, k, groups):\n num_4 = n\n num_2 = 2*n\n remaining_groups = []\n for group in groups:\n if group % 2 == 1:\n if num_4 > 0:\n if group >= 3:\n group -= 3\n else:\n group -= 1\n num_2 += 1\n num_4 -= 1\n if group > 0:\n remaining_groups.append(group)\n elif num_2 > 0:\n group -= 1\n num_2 -= 1\n if group > 0:\n remaining_groups.append(group)\n else:\n return 'NO'\n else:\n remaining_groups.append(group)\n\n remaining_groups = sorted(remaining_groups, reverse=True)\n for group in remaining_groups:\n if group >= 4 and num_4 > 0:\n req_4 = group / 4\n if req_4 > num_4:\n group -= num_4 * 4\n num_4 = 0\n else:\n num_4 -= req_4\n group -= req_4 * 4\n if group >= 2 and num_2 > 0:\n req_2 = group / 2\n if req_2 > num_2:\n group -= num_2 * 2\n num_2 = 0\n else:\n num_2 -= req_2\n group -= req_2 * 2 \n if group >= 2 and num_4 > 0:\n req_2 = group / 2\n if req_2 > num_4:\n return 'NO'\n else:\n num_4 -= req_2\n group -= req_2*2\n if group != 0:\n return 'NO'\n\n return 'YES'\n\nif __name__ == '__main__':\n n, k = map(int, sys.stdin.readline().split())\n groups = map(int, sys.stdin.readline().split())\n print solve(n, k, groups)\n"}, {"source_code": "read = lambda: map(int, input().split())\ndebug = 0\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2)\na.sort(reverse = 1)\nfor i in range(n):\n if cnt4 == 0: break\n if a[i] == 0: continue\n if a[i] >= 3:\n cnt4 -= 1\n a[i] = 0\n elif a[i] >= 2:\n if i < n and a[i + 1] > 0:\n a[i + 1] -= 1\n cnt4 -= 1\n a[i] = 0\na.sort(reverse = 1)\nfor i in range(n):\n if cnt4 == 0: break\n if a[i] == 0: continue\n if a[i] >= 3:\n cnt4 -= 1\n a[i] = 0\n elif a[i] >= 2:\n if i < n and a[i + 1] > 0:\n a[i + 1] -= 1\n cnt4 -= 1\n a[i] = 0\na.sort(reverse = 1)\nfor i in range(n):\n cnt = min(cnt4, a[i])\n a[i] -= cnt\n cnt4 -= cnt\nfor i in range(n):\n cnt = min(cnt2, a[i])\n a[i] -= cnt\n cnt2 -= cnt\nprint('YES' if sum(a) == 0 else 'NO')"}, {"source_code": "from sys import exit\n\nnum_rows, num_groups = map(int, raw_input().split(' '))\n\ngroups = map(int, raw_input().split(' '))\n\nnum_quads, num_doubles = num_rows, 2 * num_rows\n\n# Fully fill up first quads, then doubles, as many as possible\n\nfor i in xrange(num_groups):\n occupiable_quads = min(num_quads, groups[i] / 4)\n\n num_quads -= occupiable_quads\n groups[i] -= 4 * occupiable_quads\n\nfor i in xrange(num_groups):\n occupiable_doubles = min(num_doubles, groups[i] / 2)\n\n num_doubles -= occupiable_doubles\n groups[i] -= 2 * occupiable_doubles\n\n# If there are groups of 4 and up left, problem is infeasible\n# (not sure if this even possible under the assignment conditions, but doesn't hurt to check :>)\n\nif len(filter(lambda x: x >= 4, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1, 2 and 3 people over leftover quads and doubles\n\n# Distribute all groups of 3 over quads\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_quads == 0:\n break\n\n groups[i] = 0\n num_quads -= 1\n\n# If that couldn't be done, place two people of every group of 3 on a double\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_doubles == 0:\n break\n\n groups[i] -= 2\n num_doubles -= 1\n\n# If we coudn't distribute all groups of 3, the problem is infeasible\n\nif len(filter(lambda x: x == 3, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1 and 2 over leftover quads and doubles\n\n# Distribute pairs of 1 and 2 groups over quads, thus filling the quads up\n\nfor i, j in zip(\n filter(lambda i: groups[i] == 1, xrange(num_groups)),\n filter(lambda i: groups[i] == 2, xrange(num_groups))\n ):\n\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\nif num_quads == 0:\n # Subproblem:\n # distribute groups of 1 and 2 over the remaining doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1 or groups[i] == 2:\n groups[i] = 0\n num_doubles -= 1\nelse:\n # There are quads left, but either groups of 1 or groups of 2 are gone (or both)\n\n if len(filter(lambda x: x == 2, groups)) != 0:\n # Subproblem:\n # distribute groups of 2 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 2:\n num_doubles -= 1\n groups[i] = 0\n\n for i in xrange(num_groups):\n if num_quads == 0:\n break\n\n if groups[i] == 2:\n num_quads -= 1\n groups[i] = 0\n\n elif len(filter(lambda x: x == 1, groups)) != 0:\n # Subproblem:\n # distribute groups of 1 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1:\n num_doubles -= 1\n groups[i] = 0\n\n one_groups = filter(lambda i: groups[i] == 1, xrange(num_groups))\n\n for i, j in zip(one_groups[:len(one_groups) / 2], one_groups[len(one_groups) / 2:]):\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\n num_quads -= 1\n\n if num_quads != 0:\n for i in xrange(num_groups):\n if groups[i] == 1:\n groups[i] = 0\n num_quads -= 1\n\n break\n\n# If anything has remained after the distribution, the problem is infeasible\n\nif sum(groups) == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n##########################################################\nfrom collections import Counter\n# c=sorted((i,int(val))for i,val in enumerate(input().split()))\nimport heapq\n# c=sorted((i,int(val))for i,val in enumerate(input().split()))\n# n = int(input())\n# ls = list(map(int, input().split()))\n#n=int(input())\n#arr = list(map(int, input().split()))\n\n#for _ in range(int(input())):\n\n\n#n=int(input())\nn,x= map(int, input().split())\narr = list(map(int, input().split()))\nans=0\nex=0\nfor i in range(x):\n var=arr[i]\n if ex>0:\n\n if arr[i]>=(x-1):\n\n var-=max(0,ex-1)\n ex=0\n ans+=var//8\n if var%8!=0:\n ans+=1\n ex=8-var\n\n else:\n ex=ex-1-var\n var=0\n\n else:\n\n ans+=arr[i]//8\n if arr[i]%8!=0:\n ex=8-var%8\n ans+=1\n\nprint(\"YES\" if ans<=n else \"NO\")"}, {"source_code": "debug = 0\nread = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2)\nc = [0] * 100\nfor i in a:\n c[min(i, 97)] += 1\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nd = min(cnt4, c[1])\nc[1] -= d\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "import math\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\nmid = n\nsides = 2*n\nones = arr.count(1)\narr.sort(reverse=True)\nfor i in range(k):\n if arr[i] > 7:\n if arr[i]%4 == 3:\n mid -= 1\n r = min(mid, arr[i]//4)\n mid -= r\n if mid == 0:\n arr[i] -= r*4\n break\n else:\n if arr[i] % 4 != 3:\n arr[i] = arr[i] % 4\n else:\n arr[i] = 0\n\narr.sort(reverse=True)\nmid_2 = 0\nif mid == 0:\n for i in range(k):\n sides -= math.ceil(arr[i]/2)\nelse:\n for i in range(k):\n t = arr[i] % 8\n if t > 6:\n if mid > 0:\n mid -= 1\n else:\n sides -= 2\n sides -= 2\n elif t > 4:\n if mid > 0:\n mid -= 1\n else:\n sides -= 2\n sides -= 1\n elif t > 2:\n if mid > 0:\n mid -= 1\n else:\n sides -= 2\n else:\n if t == 2 and mid > 0:\n if ones > 0:\n mid_2 += 1\n ones -= 1\n mid -= 1\n elif t == 2:\n sides -= 1\n elif t == 1:\n if mid_2 > 0:\n mid_2 -= 1\n else:\n sides -= 1\n\nif sides >= 0 and mid >= 0:\n print('YES')\nelse:\n print('NO')\n\n\n"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0\n\nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\ncount = 100-count\nif count <= n*k-sum(a):\n print('YES')\nelse:print('NO')\n\n"}, {"source_code": "import sys\n\ndef solve(n, k, groups):\n num_4 = n\n num_2 = 2*n\n remaining_groups = []\n for group in groups:\n if group % 2 == 1:\n if num_4 > 0:\n if group >= 3:\n group -= 3\n else:\n group -= 1\n num_2 += 1\n num_4 -= 1\n if group > 0:\n remaining_groups.append(group)\n elif num_2 > 0:\n group -= 1\n num_2 -= 1\n if group > 0:\n remaining_groups.append(group)\n else:\n return 'NO'\n else:\n remaining_groups.append(group)\n\n remaining_groups = sorted(remaining_groups, reverse=True)\n for group in remaining_groups:\n if group >= 4 and num_4 > 0:\n req_4 = group / 4\n if req_4 > num_4:\n group -= num_4 * 4\n num_4 = 0\n else:\n num_4 -= req_4\n group -= req_4 * 4\n if group >= 2 and num_2 > 0:\n req_2 = group / 2\n if req_2 > num_2:\n group -= num_2 * 2\n num_2 = 0\n else:\n num_2 -= req_2\n group -= req_2 * 2 \n if group >= 2 and num_4 > 0:\n req_2 = group / 2\n if req_2 > num_4:\n return 'NO'\n else:\n num_4 -= req_2\n group -= req_2*2\n if group != 0:\n return 'NO'\n\n return 'YES'\n\nif __name__ == '__main__':\n n, k = map(int, sys.stdin.readline().split())\n groups = map(int, sys.stdin.readline().split())\n print solve(n, k, groups)\n"}, {"source_code": "tmp = input().split()\nn = int(tmp[0])\nk = int(tmp[1])\ntmp = input().split()\na = []\nsum = 0\nfor i in range(k):\n a.append(int(tmp[i]))\n sum += a[i]\ni = 0\ncnt4 = n\nwhile cnt4 > 0 and i < k:\n if a[i] >= 4:\n a[i] -= 4\n cnt4 -= 1\n else:\n i += 1\n\nif cnt4 == 0:\n w = 0\n for i in range(k):\n w += a[i] % 2\n if sum + w <= 8 * n:\n print('YES')\n else:\n print('NO')\nelse:\n w = 0\n s4 =[4] * cnt4\n n4 = 0\n for i in range(k):\n if a[i] == 3:\n w += 1\n a[i] = 0\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n break\n if n4 < cnt4:\n flag = 1\n for i in range(k):\n for j in range(k):\n if a[i] + a[j] == 3:\n w += 1\n a[i], a[j] = 0, 0\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n flag = 0\n break\n if flag == 0:\n break\n if n4 < cnt4:\n for i in range(k):\n if a[i] == 2:\n a[i] = 0\n w += 2\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n break\n if n4 < cnt4:\n flag = 1\n for i in range(k):\n for j in range(k):\n if a[i] + a[j] == 2 and i != j:\n w += 2\n s4[n4] = 0\n n4 += 1\n a[i], a[j] = 0, 0\n if n4 == cnt4:\n flag = 0\n break\n if flag == 0:\n break\n if n4 < cnt4:\n for i in range(k):\n if a[i] == 1:\n w += 3\n s4[n4] = 0\n n4 += 1\n a[i] = 0\n if n4 == cnt4:\n break\n for i in range(k):\n w += a[i] % 2\n if sum + w <= 8 * n:\n print('YES')\n else:\n print('NO')"}, {"source_code": "import sys\n\n\ndef main():\n n, k = map(int, sys.stdin.readline().split())\n x = list(map(int, sys.stdin.readline().split()))\n ch = n\n dv = 2 * n\n\n for i in range(k):\n if x[i] % 4 == 2 and dv > 0:\n x[i] -= 2\n dv -= 1\n for i in range(k):\n while x[i] > 3 and ch > 0:\n x[i] -= 4\n ch -= 1\n\n for i in range(k):\n if x[i] % 4 == 1 and dv > 0:\n x[i] -= 1\n dv -= 1\n\n for i in range(k):\n while x[i] >= 3 and ch > 0:\n x[i] -= 4\n ch -= 1\n p1 = 0\n p2 = 0\n for i in range(k):\n if x[i] == 2:\n if p2 > 0:\n p2 -= 1\n x[i] = 0\n elif p1 > 1:\n p1 -= 2\n x[i] = 0\n elif ch > 0:\n x[i] = 0\n p1 += 1\n ch -= 1\n elif x[i] == 1:\n if p1 > 0:\n p1 -= 1\n x[i] = 0\n elif p2 > 0:\n p2 -= 1\n x[i] = 0\n elif ch > 0:\n p2 += 1\n x[i] = 0\n ch -= 1\n\n while x[i] > 0 and dv > 0:\n x[i] -= 2\n dv -= 1\n\n ok = True\n for i in range(k):\n if x[i] > 0:\n ok = False\n break\n\n if ok:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nmain()\n"}, {"source_code": "from math import ceil\nn,k = map(int, input().split())\na = list(map(int, input().split()))\n\ndef solve(n,k,a):\n seats = n*8\n oneSeat = 0\n twoSeats = n*2\n fourSeats = n\n\n for i in a:\n current = i\n seatsNeeded = ceil(current/2)\n rowsNeeded = current // 8\n\n\n twoSeats -= 2*rowsNeeded\n fourSeats -= rowsNeeded\n rest = current % 8\n\n while rest > 0:\n if (twoSeats < 0) or (fourSeats < 0) or (oneSeat < 0):\n return \"NO\"\n if rest >= 4:\n if fourSeats > 0:\n fourSeats -= 1\n elif twoSeats >= 2:\n twoSeats -= 2\n else:\n return \"NO\"\n rest -= 4\n else:\n #1,2,3\n if rest == 1:\n if twoSeats > 0:\n twoSeats -= 1\n elif fourSeats > 0:\n fourSeats -= 1\n twoSeats += 1\n else:\n return \"NO\"\n rest -= 1\n elif rest == 2:\n if twoSeats > 0:\n twoSeats -= 1\n elif fourSeats > 0:\n fourSeats -= 1\n twoSeats += 1\n else:\n return \"NO\"\n rest -= 2\n elif rest == 3:\n if twoSeats >= 2:\n twoSeats -= 2\n elif fourSeats > 0:\n fourSeats -= 1\n else:\n return \"NO\"\n rest -= 3\n return \"YES\"\n\nprint(solve(n,k,a))\n\n\n"}, {"source_code": "n,k = map(int,raw_input().split());\ncnt = map(int,raw_input().split());\navailable = n;\nfor i in xrange(k):\n x = min(available,cnt[i]/4);\n available -= x;\n cnt[i] -= 4*x;\n\nr = 2*n;\nfor i in xrange(k):\n if cnt[i] >= 4:\n x = min(r,cnt[i] / 2);\n r -= x;\n cnt[i] -= 2*x;\nif sum(map(lambda x:x >= 4,cnt)): print \"NO\";\nelse:\n one = sum(map(lambda x:x == 1,cnt));\n two = sum(map(lambda x:x == 2,cnt));\n three = sum(map(lambda x: x == 3, cnt));\n #print one,two,three;\n #print available,r;\n x = min(r,three);\n one += x;\n three -= x;\n r -= x;\n x = min(r,two);\n r -= x;\n two -= x;\n x = min(available,three);\n available -= x;\n three -= x;\n if three: print \"NO\"\n else:\n three = min(two,one);\n two -= three;\n one -= three;\n x = min(available,three);\n three -= x;\n available -= x;\n two += three;\n one += three;\n two += (one + 1)/2;\n x = min(r,two);\n r -= x;\n two -= x;\n x = min(available,two);\n available -= x;\n two -= x;\n if two: print \"NO\";\n else: print \"YES\";\n\n"}, {"source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\n\nworks = True\n\nreg_seats = 4*n\nmid_seats = 4*n\nsingles = 0\n\n\ni = 0\nwhile i<len(a) and mid_seats>0:\n if a[i]%4==0:\n t = min(mid_seats,a[i])\n mid_seats -= t\n if a[i]-t>0:\n a.append(a[i]-t)\n \n elif a[i]%4==1:\n t = min(mid_seats,a[i]+3)\n mid_seats -= t\n reg_seats += 2\n if a[i]-t>0:\n a.append(a[i]-t)\n \n elif a[i]%4==2:\n t = min(mid_seats,a[i]+2)\n mid_seats -= t\n singles += 1\n if a[i]-t>0:\n a.append(a[i]-t)\n\n elif a[i]%4==3:\n t = min(mid_seats,a[i]+1)\n mid_seats -= t\n if a[i]-t>0:\n a.append(a[i]-t)\n\n i += 1\n\nwhile i<len(a) and reg_seats>0:\n if a[i]%2==1:\n if singles>0:\n singles -= 1\n reg_seats -= a[i]-1\n else:\n a[i] += 1\n reg_seats -= a[i]\n\n i += 1\n\nwhile i<len(a):\n singles -= 1\n\nif singles+reg_seats<0:\n print \"NO\"\nelse:\n print \"YES\"\n \n"}, {"source_code": "from math import ceil\nn,k = map(int, input().split())\na = list(map(int, input().split()))\n\ndef solve(n,k,a):\n seats = n*8\n oneSeat = 0\n twoSeats = n*2\n fourSeats = n\n\n for i in a:\n current = i\n seatsNeeded = ceil(current/2)\n rowsNeeded = current // 8\n\n\n twoSeats -= 2*rowsNeeded\n fourSeats -= rowsNeeded\n rest = current % 8\n\n while rest > 0:\n if (twoSeats < 0) or (fourSeats < 0) or (oneSeat < 0):\n return \"NO\"\n if rest >= 4:\n if fourSeats > 0:\n fourSeats -= 1\n elif twoSeats >= 2:\n twoSeats -= 2\n else:\n return \"NO\"\n rest -= 4\n else:\n #1,2,3\n if rest == 1:\n if twoSeats > 0:\n twoSeats -= 1\n elif fourSeats > 0:\n fourSeats -= 1\n twoSeats += 1\n else:\n return \"NO\"\n rest -= 1\n elif rest == 2:\n if twoSeats > 0:\n twoSeats -= 1\n elif fourSeats > 0:\n fourSeats -= 1\n twoSeats += 1\n else:\n return \"NO\"\n rest -= 2\n elif rest == 3:\n if twoSeats >= 2:\n twoSeats -= 2\n elif fourSeats > 0:\n fourSeats -= 1\n else:\n return \"NO\"\n rest -= 3\n return \"YES\"\n\nprint(solve(n,k,a))\n\n\n"}, {"source_code": "n, k = map(int, input().split())\nseat = {4:n, 2:n*2, 1:0}\na = sorted(map(int, input().split()), reverse=True)\n\ndef sit(n, m):\n num = min(seat[n], m)\n seat[n] -= num\n return m - num\n\nfor m in a:\n p4 = m // 4\n p3, p2, p1 = 0, 0, 0\n if m%4 == 3:\n p3 = 1\n else:\n p2 = int(m % 4 > 1)\n p1 = int(m % 2)\n\n extra4 = sit(4, p4)\n p2 += extra4*2\n if sit(4, p3) > 0:\n p2 += 1\n p1 += 1\n\n extra2 = sit(2, p2)\n x = sit(4, extra2)\n seat[1] += extra2 - x\n p1 += x * 2\n\n extra1 = sit(1, p1)\n extra1 = sit(2, extra1)\n x = sit(4, extra1)\n seat[2] += extra1 - x\n\n if x > 0:\n print(\"NO\")\n break\nelse:\n print(\"YES\")"}, {"source_code": "n,k=map(int, input().split())\nimport sys\na=list(map(int, input().split()))\np=n*2\nd=0\nfor i in range(k):\n while a[i]>=4:\n if n>0:\n n-=1\n a[i]-=4\n elif p>=2:\n p-=2\n a[i]-=4\n elif d>=4:\n d-=4\n a[i]-=4\n else:\n print('NO')\n sys.exit()\n if a[i]==3:\n if n>0:\n n-=1\n a[i]-=3\n elif p>=2:\n p-=2\n a[i]-=3\n elif d>=4:\n d-=3\n a[i]-=3\n else:\n print('NO')\n sys.exit()\n if a[i]==2:\n if p>=1:\n p-=1\n a[i]-=2\n elif n>=1:\n n-=1\n a[i]-=2\n d+=1\n elif d>=2:\n d-=2\n a[i]-=2\n else:\n print('NO')\n sys.exit()\n if a[i]==1:\n if d>=1:\n d-=1\n a[i]-=1\n elif n>=1:\n n-=1\n a[i]-=1\n p+=1\n elif p>=1:\n p-=1\n a[i]-=1\n else:\n print('NO')\n sys.exit()\nprint('YES')"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nmist=n*4\nfor x in l :\n mist-=x/2\n mist-=x%2!=0\nif mist>=0 :\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\na = sorted(list(map(int, input().split())))[::-1]\nm, j = n, 0\nwhile j < len(a) and m > 0:\n waste = min(a[j] // 4, m)\n m -= waste\n a[j] -= waste * 4\n j += 1\nm1, m2, m3 = 0, 0, 0\nfor x in a:\n m1 += (x == 1)\n m2 += (x == 2)\n m3 += (x == 3)\nif m > 0:\n waste = min(m1, m2, m)\n m -= waste\n m1, m2 = m1 - waste, m2 - waste\nif m > 0:\n waste = min(m3, m)\n m, m3 = m - waste, m3 - waste\nif m > 0:\n waste = min(m1 // 2, m)\n m, m1 = m - waste, m1 - waste\nif m > 0:\n waste = min(m1, m)\n m, m1 = m - waste, m1 - waste\nif m > 0:\n waste = min(m2, m)\n m, m2 = m - waste, m2 - waste\nif m1 + m2 + m3 * 2 <= 2 * n:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\nseat = {4:n, 2:n*2, 1:0}\nextra1 = 0\na = sorted(map(int, input().split()), reverse=True)\n\ndef sit(n, m):\n num = min(seat[n], m)\n seat[n] -= num\n return m - num\n\nfor m in a:\n p4 = m // 4\n p3, p2, p1 = 0, 0, 0\n if m%4 == 3:\n p3 = 1\n else:\n p2 = int(m % 4 > 1)\n p1 = int(m % 2)\n\n extra4 = sit(4, p4)\n p2 += extra4*2\n if sit(4, p3) > 0:\n p2 += 1\n p1 += 1\n\n extra2 = sit(2, p2)\n x = sit(4, extra2)\n seat[1] += extra2 - x\n p1 += x * 2\n\n extra1 += p1\n\nextra1 = sit(1, extra1)\nx = sit(4, extra1)\nseat[2] += extra1 - x\ny = sit(2, x)\n\nif x > 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "tmp = input().split()\nn = int(tmp[0])\nk = int(tmp[1])\ntmp = input().split()\na = []\nsum = 0\nfor i in range(k):\n a.append(int(tmp[i]))\n sum += a[i]\ni = 0\ncnt4 = n\nwhile cnt4 > 0 and i < k:\n if a[i] >= 4:\n a[i] -= 4\n cnt4 -= 1\n else:\n i += 1\n\nif cnt4 == 0:\n w = 0\n for i in range(k):\n w += a[i] % 2\n if sum + w <= 8 * n:\n print('YES')\n else:\n print('NO')\nelse:\n w = 0\n s4 =[4] * cnt4\n n4 = 0\n for i in range(k):\n if a[i] == 3:\n w += 1\n a[i] = 0\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n break\n if n4 < cnt4:\n flag = 1\n for i in range(k):\n for j in range(k):\n if a[i] + a[j] == 3:\n w += 1\n a[i], a[j] = 0, 0\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n flag = 0\n break\n if flag == 0:\n break\n if n4 < cnt4:\n for i in range(k):\n if a[i] == 2:\n a[i] = 0\n w += 2\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n break\n if n4 < cnt4:\n flag = 1\n for i in range(k):\n for j in range(k):\n if a[i] + a[j] == 2:\n w += 2\n s4[n4] = 0\n n4 += 1\n a[i], a[j] = 0, 0\n if n4 == cnt4:\n flag = 0\n break\n if flag == 0:\n break\n if n4 < cnt4:\n for i in range(k):\n if a[i] == 1:\n w += 3\n s4[n4] = 0\n n4 += 1\n a[i] = 0\n if n4 == cnt4:\n break\n for i in range(k):\n w += a[i] % 2\n if sum + w <= 8 * n:\n print('YES')\n else:\n print('NO')"}, {"source_code": "\"\"\"\n Author : Arif Ahmad\n Date : \n Algo : \n Difficulty : \n\"\"\"\nfrom sys import stdin, stdout\n\ndef main():\n n, k = [int(_) for _ in stdin.readline().strip().split()]\n a = [int(_) for _ in stdin.readline().strip().split()]\n\n cornerSlot = 2 * n\n middleSlot = 2 * n\n slotForOne = 0\n ans = 'YES'\n for x in a:\n req = x // 2\n #print('corner:', cornerSlot, ' middle:', middleSlot, ' single:', slotForOne)\n #print('group of:', x, ' req:', req, '\\n')\n \n if req % 2 == 1:\n \thand = 1\n \treq -= 1\n else:\n \thand = 0\n\n if middleSlot >= req:\n middleSlot -= req\n req = 0\n elif middleSlot > 0:\n req -= middleSlot\n middleSlot = 0\n\n if hand: req += 1\n\n if cornerSlot >= req:\n cornerSlot -= req\n req = 0\n\n elif cornerSlot > 0:\n req -= cornerSlot\n cornerSlot = 0 \n \n \n\n if req > 0:\n ans = 'NO'\n break\n\n if middleSlot % 2 == 1:\n middleSlot -= 1\n slotForOne += 1\n\n if x % 2 == 1:\n if slotForOne > 0:\n slotForOne -= 1\n elif middleSlot > 0: \n middleSlot -= 1\n elif cornerSlot > 0: \n cornerSlot -= 1\n else:\n ans = 'NO'\n break\n\n stdout.write(ans)\n\n\n\nif __name__ == '__main__':\n main()\n "}, {"source_code": "n, k = map(int, input().split())\n\nl = [0, 0, 2 * n, 0, n]\n\ninp = sorted(map(int, input().split()), reverse = True)\n\nfor i in range(k):\n\tif inp[i] > 1 and inp[i] & 1:\n\t\tinp[i] -= 1\n\t\tinp.append(1)\n\nfor a in inp:\n\tif a == 1:\n\t\tif l[1]:\n\t\t\tl[1] -= 1\n\t\t\ta = 0\n\t\tif l[2]:\n\t\t\tl[2] -= 1\n\t\t\ta = 0\n\t\tif l[4]:\n\t\t\tl[4] -= 1\n\t\t\tl[2] += 1\n\t\t\ta = 0\n\telse:\t\n\t\twhile a > 2 and l[4]:\n\t\t\ta -= 4\n\t\t\tl[4] -= 1\n\t\twhile a and l[2]:\n\t\t\ta -= min(a, 2)\n\t\t\tl[2] -= 1\n\t\twhile a and l[4]:\n\t\t\ta -= 2\n\t\t\tl[4] -= 1\n\t\t\tl[1] += 1\n\n\tif a:\n\t\tprint('NO')\n\t\texit()\n\nprint('YES')"}, {"source_code": "def solve(a, n, k):\n cnt =[0 for i in range(5)]\n duplas, quads, sozinhos = 2*n, n, 0\n for i in a:\n for j in range(k):\n while i >= 3:\n if quads > 0:\n i -= 4\n quads -= 1\n elif duplas > 0:\n i -= 2\n duplas -= 1\n else: return \"no\"\n if i > 0: \n cnt[i] += 1\n while cnt[2] == 1:\n if duplas > 0:\n duplas -= 1\n cnt[2] -= 1\n elif quads > 0:\n cnt[2] -= 1\n quads -= 1\n sozinhos = 1\n else:\n cnt[2] -= 1\n cnt[1] += 2\n if cnt[1] > sozinhos + duplas + 2*quads:\n return \"no\"\n return \"yes\"\n \n\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(a, n, k))"}, {"source_code": "from math import ceil\nn,k = map(int, input().split())\na = list(map(int, input().split()))\n\ndef solve(n,k,a):\n one,two,four = 0, n*2, n\n\n for size in a:\n while size >= 4:\n if four > 0:\n four -= 1\n else:\n two -= 2\n size -= 4\n \n if size == 3:\n if four > 0:\n four -= 1\n elif two >= 2:\n two -= 2\n elif one >= 3:\n one -= 3\n else:\n return \"NO\"\n elif size == 2:\n if two >= 1:\n two -= 1\n elif four > 0:\n four -= 1\n one += 1\n elif one >= 2:\n one -= 2\n else:\n return \"NO\"\n elif size == 1:\n if one >= 1:\n one -= 1\n elif four > 0:\n four -= 1\n two += 1\n elif two >= 1:\n two -= 1\n else:\n return \"NO\"\n return \"YES\"\n \n\n\n\nprint(solve(n,k,a))\n\n\n"}, {"source_code": "from math import ceil\nn,k = map(int, input().split())\na = list(map(int, input().split()))\n\ndef solve(n,k,a):\n one,two,four = 0, n*2, n\n\n for size in a:\n while size >= 4:\n if four > 0:\n four -= 1\n else:\n two -= 2\n size -= 4\n \n if size == 3:\n if four > 0:\n four -= 1\n elif two >= 2:\n two -= 2\n elif one >= 3:\n one -= 3\n else:\n return \"NO\"\n elif size == 2:\n if two >= 1:\n two -= 1\n elif four > 0:\n four -= 1\n one += 1\n elif one >= 2:\n one -= 2\n else:\n return \"NO\"\n elif size == 1:\n if one >= 1:\n one -= 1\n elif four > 0:\n four -= 1\n two += 1\n elif two >= 1:\n two -= 1\n else:\n return \"NO\"\n return \"YES\"\n \n\n\n\nprint(solve(n,k,a))\n\n\n"}, {"source_code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nindex = 0\nleft4seat = n\nleft2seat = n * 2\nwhile (index < k and (left4seat + left2seat > 0) ) :\n\tleft4seat -= a[index] // 4\n\tif (left4seat < 0) :\n\t\tleft2seat += 2 * left4seat\n\t\tleft4seat = 0\n\tleftSol = a[index] % 4\n\tif (leftSol >= 3) : \n\t\tif (left4seat > 0) : left4seat -= 1\n\t\telse : left2seat -= 2\n\telif (leftSol != 0) :\n\t\tif (left2seat > 0) : left2seat -= 1\n\t\telse : left4seat -= 1\n\tif (left4seat < 0 or left2seat < 0) : break\n\tindex += 1\n\nif (left4seat < 0 or left2seat < 0) : print(\"NO\")\nelse : print(\"YES\")"}, {"source_code": "n, k = map(int, input().split())\na = sorted(list(map(int, input().split())))[::-1]\nm, j = n, 0\nwhile j < len(a) and m > 0:\n waste = min(a[j] // 4, m)\n m -= waste\n a[j] -= waste * 4\n j += 1\nm1, m2, m3 = 0, 0, 0\nfor x in a:\n m1 += (x == 1)\n m2 += (x == 2)\n m3 += (x == 3)\nif m > 0:\n waste = min(m3, m)\n m, m3 = m - waste, m3 - waste\nif m > 0:\n waste = min(m1, m2, m)\n m -= waste\n m1, m2 = m1 - waste, m2 - waste\nif m > 0:\n waste = min(m1 // 2, m)\n m, m1 = m - waste, m1 - waste\nif m > 0:\n waste = min(m1, m)\n m -= waste\n m1 -= waste\nif m > 0:\n waste = min(m2, m)\n m -= waste\n m2 -= waste\nif sum([x // 2 + x % 2 for x in [1] * m1 + [2] * m2 + [3] * m3]) <= 2 * n:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "from sys import exit\n\nnum_rows, num_groups = map(int, raw_input().split(' '))\n\ngroups = map(int, raw_input().split(' '))\n\nnum_quads, num_doubles = num_rows, 2 * num_rows\n\n# Fully fill up first quads, then doubles, as many as possible\n\nfor i in xrange(num_groups):\n occupiable_quads = min(num_quads, groups[i] / 4)\n\n num_quads -= occupiable_quads\n groups[i] -= 4 * occupiable_quads\n\nfor i in xrange(num_groups):\n occupiable_doubles = min(num_doubles, groups[i] / 2)\n\n num_doubles -= occupiable_doubles\n groups[i] -= 2 * occupiable_doubles\n\n# If there are groups of 4 and up left, problem is infeasible\n# (not sure if this even possible under the assignment conditions, but doesn't hurt to check :>)\n\nif len(filter(lambda x: x >= 4, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1, 2 and 3 people over leftover quads and doubles\n\n# Distribute all groups of 3 over quads\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_quads == 0:\n break\n\n groups[i] = 0\n num_quads -= 1\n\n# If that couldn't be done, place two people of every group of 3 on a double\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_doubles == 0:\n break\n\n groups[i] -= 2\n num_doubles -= 1\n\n# If we coudn't distribute all groups of 3, the problem is infeasible\n\nif len(filter(lambda x: x == 3, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1 and 2 over leftover quads and doubles\n\n# Distribute pairs of 1 and 2 groups over quads, thus filling the quads up\n\nfor i, j in zip(\n filter(lambda i: groups[i] == 1, xrange(num_groups)),\n filter(lambda i: groups[i] == 2, xrange(num_groups))\n ):\n\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\nif num_quads == 0:\n # Subproblem:\n # distribute groups of 1 and 2 over the remaining doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1 or groups[i] == 2:\n groups[i] = 0\n num_doubles -= 1\nelse:\n # There are quads left, but either groups of 1 or groups of 2 are gone (or both)\n\n if len(filter(lambda x: x == 2, groups)) != 0:\n # Subproblem:\n # distribute groups of 2 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 2:\n num_doubles -= 1\n groups[i] = 0\n\n for i in xrange(num_groups):\n if num_quads == 0:\n break\n\n if groups[i] == 2:\n num_quads -= 1\n groups[i] = 0\n\n elif len(filter(lambda x: x == 1, groups)) != 0:\n # Subproblem:\n # distribute groups of 1 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1:\n num_doubles -= 1\n groups[i] = 0\n\n one_groups = filter(lambda i: groups[i] == 1, xrange(num_groups))\n\n for i, j in zip(one_groups[:len(one_groups) / 2], one_groups[len(one_groups) / 2:]):\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\n num_quads -= 1\n\n if num_quads != 0:\n for i in xrange(num_groups):\n if groups[i] == 1:\n groups[i] = 0\n num_quads -= 1\n\n break\n\n# If anything has remained after the distribution, the problem is infeasible\n\nif sum(groups) == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "import sys\n\n\ndef main():\n n, k = map(int, sys.stdin.readline().split())\n x = list(map(int, sys.stdin.readline().split()))\n ch = n\n dv = 2 * n\n\n for i in range(k):\n if x[i] % 4 == 2 and dv > 0:\n x[i] -= 2\n dv -= 1\n for i in range(k):\n while x[i] > 3 and ch > 0:\n x[i] -= 4\n ch -= 1\n\n for i in range(k):\n if x[i] % 4 == 1 and dv > 0:\n x[i] -= 1\n dv -= 1\n\n for i in range(k):\n while x[i] >= 3 and ch > 0:\n x[i] -= 4\n ch -= 1\n p1 = 0\n p2 = 0\n for i in range(k):\n if x[i] == 2:\n if p2 > 0:\n p2 -= 1\n x[i] = 0\n elif ch > 0:\n x[i] = 0\n p1 += 1\n ch -= 1\n elif x[i] == 1:\n if p1 > 0:\n p1 -= 1\n x[i] = 0\n elif p2 > 0:\n p2 -= 1\n x[i] = 0\n elif ch > 0:\n p2 += 1\n x[i] = 0\n ch -= 1\n while x[i] > 0 and dv > 0:\n x[i] -= 2\n dv -= 1\n\n ok = True\n for i in range(k):\n if x[i] > 0:\n ok = False\n break\n\n if ok:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nmain()\n"}, {"source_code": "from sys import exit\n\nnum_rows, num_groups = map(int, raw_input().split(' '))\n\ngroups = map(int, raw_input().split(' '))\n\nnum_quads, num_doubles = num_rows, 2 * num_rows\n\n# Fully fill up first quads, then doubles, as many as possible\n\nfor i in xrange(num_groups):\n occupiable_quads = min(num_quads, groups[i] / 4)\n\n num_quads -= occupiable_quads\n groups[i] -= 4 * occupiable_quads\n\nfor i in xrange(num_groups):\n occupiable_doubles = min(num_doubles, groups[i] / 2)\n\n num_doubles -= occupiable_doubles\n groups[i] -= 2 * occupiable_doubles\n\n# If there are groups of 4 and up left, problem is infeasible\n# (not sure if this even possible under the assignment conditions, but doesn't hurt to check :>)\n\nif len(filter(lambda x: x >= 4, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1, 2 and 3 people over leftover quads and doubles\n\n# Distribute all groups of 3 over quads\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_quads == 0:\n break\n\n groups[i] = 0\n num_quads -= 1\n\n# If that couldn't be done, place two people of every group of 3 on a double\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_doubles == 0:\n break\n\n groups[i] -= 2\n num_doubles -= 1\n\n# If we coudn't distribute all groups of 3, the problem is infeasible\n\nif len(filter(lambda x: x == 3, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1 and 2 over leftover quads and doubles\n\n# Distribute pairs of 1 and 2 groups over quads, thus filling the quads up\n\nfor i, j in zip(\n filter(lambda i: groups[i] == 1, xrange(num_groups)),\n filter(lambda i: groups[i] == 2, xrange(num_groups))\n ):\n\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\nif num_quads == 0:\n # Subproblem:\n # distribute groups of 1 and 2 over the remaining doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1 or groups[i] == 2:\n groups[i] = 0\n num_doubles -= 1\nelse:\n # There are quads left, but either groups of 1 or groups of 2 are gone (or both)\n\n if len(filter(lambda x: x == 2, groups)) != 0:\n # Subproblem:\n # distribute groups of 2 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 2:\n num_doubles -= 1\n groups[i] = 0\n\n # On every two quads, we can place three groups of 2:\n # [1 1 - 3]\n # [2 2 - 3]\n\n two_groups = filter(lambda i: groups[i] == 2, xrange(num_groups))\n\n for i, j, k in zip(\n two_groups[:len(two_groups) / 3],\n two_groups[len(two_groups) / 3:len(two_groups) / 3 * 2],\n two_groups[len(two_groups) / 3 * 2:]\n ):\n if num_quads < 2:\n break\n\n groups[i] = 0\n groups[j] = 0\n groups[k] = 0\n\n num_quads -= 2\n\n # At most two groups of 2 remain, which requires two quads, or less than two quads are available -- either way,\n # at this point we can only place one group of 2 per quad\n\n for i in xrange(num_groups):\n if num_quads == 0:\n break\n\n if groups[i] == 2:\n groups[i] = 0\n num_quads -= 1\n\n elif len(filter(lambda x: x == 1, groups)) != 0:\n # Subproblem:\n # distribute groups of 1 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1:\n num_doubles -= 1\n groups[i] = 0\n\n one_groups = filter(lambda i: groups[i] == 1, xrange(num_groups))\n\n for i, j in zip(one_groups[:len(one_groups) / 2], one_groups[len(one_groups) / 2:]):\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\n num_quads -= 1\n\n if num_quads != 0:\n for i in xrange(num_groups):\n if groups[i] == 1:\n groups[i] = 0\n num_quads -= 1\n\n break\n\n# If anything has remained after the distribution, the problem is infeasible\n\nif sum(groups) == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n, m = map(int, input().split())\nz = list(map(int, input().split()))\nh = z[:]\ndouble = 2 * n\nfour = n\njj = []\nfor i in range(len(h)):\n while four > 0 and h[i] >= 4:\n h[i] -= 4\n four -= 1\n if (h[i] != 0):\n jj.append(h[i])\n\ntt = []\nfor i in range(len(jj)):\n while double > 0 and jj[i] >= 2:\n double -= 1\n jj[i] -= 2\n if jj[i] != 0:\n tt.append(jj[i])\nss = []\nfor i in range(len(tt)):\n while four > 0 and tt[i] >= 3:\n four -= 1\n tt[i] -= 3\n if tt[i] != 0:\n ss.append(tt[i])\nff = []\ndouble += 2 * four\nfor i in range(len(ss)):\n while four > 0 and ss[i] >= 2:\n double -= 1\n ss[i] -= 2\n if ss[i] != 0:\n ff.append(ss[i])\n\nans = len(ff)\nans -= min(ff.count(1), double)\nif (ans):\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n \n\n\n \n"}, {"source_code": "n,k = map(int,input().split(\" \"))\na = list(map(int,input().split(\" \")))\ncount = 0 \nfor i in range(0,len(a)):\n if a[i]%2 == 0:\n count = count + 1\n\n\nif k-count <= n*8-sum(a):\n print('YES')\nelse:print('NO')\n\n"}, {"source_code": "class Solution(object):\n\n def __init__(self, rows, a):\n self.rows = rows\n self.x = rows\n self.y = 2 * rows\n self.z = 0\n self.a = a\n\n def solve(self):\n length = len(self.a)\n for i in range(length):\n while self.a[i] >= 4 and self.x > 0:\n self.a[i] = self.a[i] - 4\n self.x = self.x - 1\n self.y = self.y + self.x\n self.z = self.x\n \n for i in range(length):\n while self.a[i] >= 2 and self.y > 0:\n self.a[i] = self.a[i] - 2\n self.y = self.y - 1\n self.z = self.y + self.z\n\n for i in range(length):\n if self.a[i] > 1:\n return False\n while self.a[i] >= 1 and self.z > 0:\n self.a[i] = self.a[i] - 1\n self.z = self.z - 1\n for i in range(length):\n if self.a[i] > 0:\n return False\n return True\n\nline1 = input().split()\nn = int(line1[0])\nk = int(line1[1])\nline2 = input().split()\na = []\nfor i in line2:\n a.append(int(i))\ns = Solution(n, a)\nans = s.solve()\nif ans:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "tmp = input().split()\nn = int(tmp[0])\nk = int(tmp[1])\ntmp = input().split()\na = []\nsum = 0\nfor i in range(k):\n a.append(int(tmp[i]))\n sum += a[i]\ni = 0\ncnt4 = n\nwhile cnt4 > 0 and i < k:\n if a[i] >= 4:\n a[i] -= 4\n cnt4 -= 1\n else:\n i += 1\n\nif cnt4 == 0:\n w = 0\n for i in range(k):\n w += a[i] % 2\n if sum + w <= 8 * n:\n print('YES')\n else:\n print('NO')\nelse:\n w = 0\n s4 =[4] * cnt4\n n4 = 0\n for i in range(k):\n if a[i] == 3:\n w += 1\n a[i] = 0\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n break\n if n4 < cnt4:\n flag = 1\n for i in range(k):\n for j in range(k):\n if a[i] + a[j] == 3:\n w += 1\n a[i], a[j] = 0, 0\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n flag = 0\n break\n if flag == 0:\n break\n if n4 < cnt4:\n for i in range(k):\n if a[i] == 2:\n a[i] = 0\n w += 2\n s4[n4] = 0\n n4 += 1\n if n4 == cnt4:\n break\n if n4 < cnt4:\n flag = 1\n for i in range(k):\n for j in range(k):\n if a[i] + a[j] == 2:\n w += 2\n s4[n4] = 0\n n4 += 1\n a[i], a[j] = 0, 0\n if n4 == cnt4:\n flag = 0\n break\n if flag == 0:\n break\n if n4 < cnt4:\n for i in range(k):\n if a[i] == 1:\n w += 3\n s4[n4] = 0\n n4 += 1\n a[i] = 0\n if n4 == cnt4:\n break\n for i in range(k):\n w += a[i] % 2\n if sum + w <= 8 * n:\n print('YES')\n else:\n print('NO')"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort(reverse=True)\nj=1\nans=0\nfor i in range(k):\n if l[i]>=3:\n if j==n+1:\n break\n a=l[i]//4\n b=l[i]%4\n if n+1-j>=a:\n ans+=4*a\n j+=a\n l[i]=b\n else:\n ans+=(n+1-j)*4\n l[i]-=min(l[i],(n+1-j)*4)\n j=n+1\n if j==n+1:\n break\n \n if b==3:\n j+=1\n ans+=4\n l[i]-=3\nl.sort(reverse=True)\nx=1\nfor i in range(k):\n if x==n+1:\n break\n if l[i]==0:\n break\n a=l[i]//2\n b=l[i]%2\n if b>0:\n a+=1\n if n+1-x>=a:\n ans+=2\n x+=a\n l[i]=0\n else:\n ans+=(n+1-x)*2\n l[i]-=min(l[i],(n+1-x)*2)\n x=n+1\n break\nl.sort(reverse=True)\nx=1\nfor i in range(k):\n if x==n+1:\n break\n if l[i]==0:\n break\n a=l[i]//2\n b=l[i]%2\n if b>0:\n a+=1\n if n+1-x>=a:\n ans+=2\n x+=a\n l[i]=0\n else:\n ans+=(n+1-x)*2\n l[i]-=min(l[i],(n+1-x)*2)\n x=n+1\n break\nif l.count(0)!=k:\n if j!=n+1:\n a=l.count(1)\n b=l.count(2)\n if n+1-j<b:\n print(\"NO\")\n else:\n c=a//2\n if a%2!=0:\n c+=1\n d=(c-b)//2\n if (c-b)%2 !=0 and (c-b)>=0:\n d+=1\n c=max(0,d)\n if b+c<=n+1-j:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\nelse:\n print(\"YES\")\n \n\n \n\n \n \n \n\n \n \n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n"}, {"source_code": "\n\nn,k = [int(_) for _ in raw_input().strip().split()]\na = []*k\na = [int(_) for _ in raw_input().strip().split()]\nd = [0]*10\n\n\ndef process56(nu4, nu2, num):\n\tif (nu4 >= d[num]):\n\t\tnu4 -= d[num]\n\t\tnu2 -= d[num]\n\telse:\n\t\tnu2 -= (d[num]-nu4)*2\n\t\tnu2 -= d[num]\n\t\tnu4 = 0\n\treturn nu4, nu2 \n\ndef process34(nu4, nu2, num):\n\tif (nu4 >= d[num]):\n\t\tnu4 -= d[num]\n\telse:\n\t\tnu2 -= (d[num]-nu4)*2\n\t\tnu4 = 0\n\treturn nu4, nu2 \n\nif __name__ == \"__main__\":\n\n\tfor i in range(k):\n\t\tn -= a[i] / 8\n\t\td[a[i] % 8] += 1\n\n\n\tn -= d[7]\n\tnu2 = n*2 \n\tnu4 = n\n\tresult = -1\n\tif n >= 0 :\n\t\tnu4, nu2 = process56(nu4, nu2, 6)\n\t\tnu4, nu2 = process56(nu4, nu2, 5)\n\t\tnu4, nu2 = process34(nu4, nu2, 4)\n\t\tnu4, nu2 = process34(nu4, nu2, 3)\n\t\t# 2 1 \n\t\tif nu4 > d[2] :\n\t\t\ttmp = 0\n\t\t\tif d[2]*2 % 3 > 0 : \n\t\t\t\ttmp = 1 \n\t\t\tnu4 -= d[2]*2 / 3 + tmp\n\t\t\tnu2 += nu4*2\n\t\t\tnu4 = 0\n\t\t\tnu2 -= d[1]\n\t\telse:\n\t\t\td[2] -= nu4 + nu4 / 2\n\t\t\tif nu4 % 2 == 1 : \n\t\t\t\td[1] -= 1\n\t\t\t\td[1] = max(d[1],0)\n\t\t\tnu4 = 0\n\t\t\tnu2 -= d[2]+d[1]\n\n\n\tif nu2 < 0 or nu4 < 0 or k < 0 :\n\t\tresult = 1\n\tif result == -1 :\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\""}, {"source_code": "from sys import exit\n\nnum_rows, num_groups = map(int, raw_input().split(' '))\n\ngroups = map(int, raw_input().split(' '))\n\nnum_quads, num_doubles = num_rows, 2 * num_rows\n\n# Fully fill up first quads, then doubles, as many as possible\n\nfor i in xrange(num_groups):\n occupiable_quads = min(num_quads, groups[i] / 4)\n\n num_quads -= occupiable_quads\n groups[i] -= 4 * occupiable_quads\n\nfor i in xrange(num_groups):\n occupiable_doubles = min(num_doubles, groups[i] / 2)\n\n num_doubles -= occupiable_doubles\n groups[i] -= 2 * occupiable_doubles\n\n# If there are groups of 4 and up left, problem is infeasible\n# (not sure if this even possible under the assignment conditions, but doesn't hurt to check :>)\n\nif len(filter(lambda x: x >= 4, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1, 2 and 3 people over leftover quads and doubles\n\n# Distribute all groups of 3 first over quads, then over doubles (because a quad is less useful than two doubles)\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_quads == 0:\n break\n\n groups[i] = 0\n num_quads -= 1\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_doubles == 0:\n break\n\n groups[i] = 0\n num_doubles -= 2\n\n# If we coudn't distribute all groups of 3, the problem is infeasible\n\nif len(filter(lambda x: x == 3, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1 and 2 over leftover quads and doubles\n\n# Distribute pairs of 1 and 2 groups over quads, thus filling the quads up\n\nfor i, j in zip(\n filter(lambda i: groups[i] == 1, xrange(num_groups)),\n filter(lambda i: groups[i] == 2, xrange(num_groups))\n ):\n\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\nif num_quads == 0:\n # Subproblem:\n # distribute groups of 1 and 2 over the remaining doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1 or groups[i] == 2:\n groups[i] = 0\n num_doubles -= 1\nelse:\n # There are quads left, but either groups of 1 or groups of 2 are gone (or both)\n\n if len(filter(lambda x: x == 2, groups)) != 0:\n # Subproblem:\n # distribute groups of 2 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 2:\n num_doubles -= 1\n groups[i] = 0\n\n for i in xrange(num_groups):\n if num_quads == 0:\n break\n\n if groups[i] == 2:\n num_quads -= 1\n groups[i] = 0\n\n elif len(filter(lambda x: x == 1, groups)) != 0:\n # Subproblem:\n # distribute groups of 1 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1:\n num_doubles -= 1\n groups[i] = 0\n\n one_groups = filter(lambda i: groups[i] == 1, xrange(num_groups))\n\n for i, j in zip(one_groups[:len(one_groups) / 2], one_groups[len(one_groups) / 2:]):\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\n num_quads -= 1\n\n if num_quads != 0:\n for i in xrange(num_groups):\n if groups[i] == 1:\n groups[i] = 0\n num_quads -= 1\n\n break\n\n# If anything has remained after the distribution, the problem is infeasible\n\nif sum(groups) == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "s = raw_input().split()\nn = int(s[0])\nk = int(s[1])\n\nrowCount4 = 0\na = raw_input().split()\n\nfor i in range(k):\n a[i] = int(a[i])\n n -= a[i] / 4\n rowCount4 += a[i] / 4\n a[i] %= 4\n\n if (a[i] == 3):\n rowCount4 += 1\n a[i] = 0\n n -= 1\n \nindex2 = -1\n\nfor i in range(k):\n if (a[i] == 2 and rowCount4 > 0):\n if (index2 == -1):\n index2 = i\n else:\n a[i] = 0\n a[index2] = 0\n index2 = -1\n rowCount4 -= 1 \n\nindex1 = -1\n\nfor i in range(k):\n if (a[i] == 1 and rowCount4 > 0):\n if (index1 == -1):\n index1 = i\n else:\n a[i] = 0\n a[index1] = 0\n index1 = -1\n rowCount4 -= 1\n \n\ncount2 = 0\n\nfor i in range(k):\n if (a[i] == 2):\n a[i] = 0\n count2 += 1\n \nrowCount2 = 0\n\nif (rowCount4 <= 0):\n rowCount2 = count2 / 3\n n -= count2 / 3\n\n count2 %= 3\n\n#43\nwhile count2 > 0 and rowCount2 >= 2:\n rowCount2 -= 2\n count2 -= 1\n \nrowCount4Half = 0\n\nif (count2 > 0):\n if (rowCount4 == 0):\n count2 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count2 -= 1\n rowCount4 -= 1\n rowCount4Half += 1\n\ncount1 = 0\n\nfor i in range(k):\n if (a[i] == 1):\n a[i] = 0\n count1 += 1\n if (rowCount2 > 0):\n rowCount2 -= 1\n count1 -= 1\n a[i] = 0\n\n\nif (count2 > 0):\n count1 -= 4 - count2\n \nif (count1 > 0):\n n -= count1 / 4\n count1 %= 4\n \nif (count1 > 0):\n if (rowCount4 == 0):\n count1 -= 1\n n -= 1\n \n elif (rowCount4 > 0):\n count1 -= 1\n if (rowCount4Half > 0):\n rowCount4Half -= 1 \n else:\n rowCount4 -= 1\n rowCount4Half += 1\n\nif (rowCount4 > 0):\n n += rowCount4 / 2\n rowCount4 %= 2\n\nif (n >= 0):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "tmp = input().split()\nn = int(tmp[0])\nk = int(tmp[1])\ntmp = input().split()\nsum = 0\nsum2 = 0\nsum1 = 0\nsum3 = 0\nsum0 = 0\nfor i in range(k):\n a = int(tmp[i])\n sum += a\n if a % 4 == 3:\n sum3 += 1\n elif a % 4 == 2:\n sum2 += 1\n elif a % 4 == 1:\n sum1 += 1\n else:\n sum0 += 1\nif sum2 > 3 * n:\n print('NO')\nelif sum2 + sum3 > 3 * n:\n print('NO')\nelse:\n if sum + sum1 + sum3 <= 8 * n:\n print('YES')\n else:\n print('NO')"}, {"source_code": "import sys\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nmid = n\nside = n*2\n\ndef removeZeroes(a):\n return [x for x in a if x > 0]\n\n#FOR 4 \nfor i in range(len(a)):\n if a[i] >= 4:\n while a[i] >= 4 and (mid > 0 or side > 1):\n a[i] -= 4\n if mid:\n mid -= 1\n else:\n side -= 2\n\n#FOR 3\nfor i in range(len(a)):\n if not(mid > 0 or side > 1): \n break\n if a[i] == 3:\n if mid > 0:\n mid -= 1\n else:\n side -= 2\n a[i] = 0\n \n#REMOVE GROUPS WITH 0 REMAINED\na = removeZeroes(a)\nif a.count(2) + a.count(1) != len(a):\n print(\"NO\")\n sys.exit(0)\n\nfor i in range(len(a)):\n if a[i] == 2 and side > 0:\n side -= 1\n a[i] = 0\n\nfor i in range(len(a)):\n if a[i] == 1 and side > 0:\n side -= 1\n a[i] = 0\n\na = removeZeroes(a)\na.sort()\nwhile len(a) > 0 and a[0] == 1 and a[-1] == 2 and mid > 0:\n a = a[1:-1]\n\nif len(a) > 0 and a[0] == 1:\n if (a.count(1)+1) // 2 <= mid:\n print(\"YES\")\n sys.exit(0)\n else:\n print(\"NO\")\n sys.exit(0)\nelif len(a) > 0 and a[0] == 2:\n while len(a) > 2 and mid > 1:\n a = a[3:]\n mid -= 2\n if mid >= len(a):\n print(\"YES\")\n sys.exit(0)\n\nif len(a) > 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "from math import ceil\nn, k = map(int, raw_input().split())\nA = map(int, raw_input().split())\ns4 = n\ns2 = n * 2\nt4 = 0\nt2 = 0\nt1 = 0\nfor i in xrange(k):\n t4 += A[i] / 4\n r = A[i] % 4\n if r == 1: t1 += 1\n if r == 2: t2 += 1\n if r == 3: t2, t1 = t2 + 1, t1 + 1\n\nif t4 >= s4:\n if (t4 - s4) * 2 + t2 + t1 <= s2:\n print 'YES'\n else:\n print 'NO'\nelse:\n c = s4 - t4\n if t2 <= s2:\n if t1 <= s2 - t2 + c * 2:\n print 'YES'\n else:\n print 'NO'\n else:\n if s2 - t2 + c < 0:\n print 'NO'\n else:\n if s2 - t2 + 2 * c >= t1:\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "n, cn = map(int, input().split())\na = list(map(int, input().split()))\nsums = 0\nfor i in a:\n sums += i\ncnt_2 = 2 * n\ncnt_4 = n\ncnt_2_4 = 2 * n\nchk = False\nwhile cnt_4 > 0:\n chk = 0\n for j in range(cn):\n if a[j] > 3:\n a[j] -= 4\n cnt_4 -= 1\n cnt_2_4 -= 2\n chk = 1\n break\n if (not chk):\n break\n#print(cnt_4, cnt_2_4, cnt_2)\nwhile cnt_2 > 0:\n chk = 0\n for j in range(cn):\n if a[j] > 1:\n a[j] -= 2\n cnt_2 -= 1\n chk = 1\n break\n if (not chk):\n break\n#print(cnt_4, cnt_2_4, cnt_2)\nwhile cnt_2_4 > 0:\n chk = 0\n for j in range(cn):\n if (a[j] == 1):\n a[j] = 0\n cnt_2_4 -= 1\n cnt_2 += 1\n cnt_4 -= 1\n chk = 1\n break\n if (not chk):\n break\ncnt_2 += cnt_2_4\n#print(cnt_4, cnt_2_4, cnt_2)\nwhile cnt_2 > 0:\n chk = 0\n for j in range(cn):\n if (a[j] > 0):\n a[j] -= 2\n cnt_2 -= 1\n chk = 1\n break\n if (not chk):\n break\n#print(cnt_4, cnt_2_4, cnt_2)\nchk1 = 0\nfor i in a:\n if i > 0:\n chk1 = 1\nif chk1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "# encoding:utf-8\n\ndef main():\n\tn, k = list(map(int, input().split()))\n\tnums = list(map(int, input().split()))\n\t\n\ttwo = n * 2\n\tfour = n\n\n\tn_four = sum([x // 4 for x in nums])\n\tnums = [x % 4 for x in nums]\n\n\tif four >= n_four:\n\t\tfour -= n_four\n\t\tn_four = 0\n\t\ttwo += four * 2\n\telse:\n\t\tn_four -= four\n\t\tfour = 0\n\n\tn_two = sum([x // 2 for x in nums])\n\trest = sum([x % 2 for x in nums]) + n_four * 2\n\n\t\n\tif n_two + rest <= two:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\nif __name__ == '__main__':\n\tmain()\n"}, {"source_code": "debug = 0\nread = lambda: map(int, input().split())\nk, n = read()\na = list(read())\ncnt4 = k\ncnt2 = 2 * k\nfor i in range(n):\n cnt = min(cnt4, a[i] // 4)\n a[i] -= cnt * 4\n cnt4 -= cnt\nif debug: print(*a)\nfor i in range(n):\n cnt = min(cnt2, a[i] // 2)\n a[i] -= cnt * 2\n cnt2 -= cnt\nif debug: print(' '.join(map(str, a)), ' ', cnt2, cnt4)\nc = [0] * 20\nfor i in a:\n c[min(i, 19)] += 1\nif debug:\n print(cnt2, cnt4, c)\nd = min(cnt4, c[3])\nc[3] -= d\ncnt4 -= d\nd = min(cnt4, c[1], c[2])\nc[1] -= d\nc[2] -= d\ncnt4 -= d\nd = min(cnt2, c[2])\nc[2] -= d\ncnt2 -= d\nd = min(cnt2, c[1])\nc[1] -= d\ncnt2 -= d\nd = min(cnt4, (c[2] + 2) // 3)\nc[2] -= d + d // 2\ncnt4 -= d\nif debug:\n print('cnt4 = ', cnt4)\n print('c[1] = ', c[1])\nd = min(cnt4, c[2])\nc[2] -= d\ncnt4 -= d\nd = min(cnt4, (c[1] + 1) // 2)\nc[1] -= d * 2\ncnt4 -= d\nprint('YES' if sum(c[1:]) == 0 else 'NO')"}, {"source_code": "#coding=utf-8\n\ndef test():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n\n total = n * 8\n place = 0\n sum = 0\n i = 0\n temp = 0\n while i < k:\n sum += a[i]\n if a[i] % 2 is 1:\n place += 1\n if a[i] % 4 != 0:\n temp += 1\n i += 1\n if sum == total:\n # print(\"place=%d temp=%d\" % (place, temp))\n if place != 0 or temp == k:\n print(\"NO\")\n # print(\"place=%d temp=%d\"%(place,temp))\n else:\n print(\"YES\")\n else:\n if (sum + place) <= total:\n print(\"YES\")\n else:\n print(\"NO\")\n\ntest()"}, {"source_code": "import sys\n\ndef solve(n, k, groups):\n num_4 = n\n num_2 = 2*n\n num_1 = 0\n remaining_groups = []\n for group in groups:\n if group % 2 == 1:\n if num_4 > 0:\n if group >= 3:\n group -= 3\n else:\n group -= 1\n num_2 += 1\n num_4 -= 1\n if group > 0:\n remaining_groups.append(group)\n elif num_2 > 0:\n group -= 1\n num_2 -= 1\n if group > 0:\n remaining_groups.append(group)\n else:\n return 'NO'\n else:\n remaining_groups.append(group)\n\n remaining_groups = sorted(remaining_groups, reverse=True)\n for group in remaining_groups:\n if group >= 4 and num_4 > 0:\n req_4 = group / 4\n if req_4 > num_4:\n group -= num_4 * 4\n num_4 = 0\n else:\n num_4 -= req_4\n group -= req_4 * 4\n if group >= 2 and num_2 > 0:\n req_2 = group / 2\n if req_2 > num_2:\n group -= num_2 * 2\n num_2 = 0\n else:\n num_2 -= req_2\n group -= req_2 * 2 \n if group >= 2 and num_4 > 0:\n req_2 = group / 2\n if req_2 > num_4:\n return 'NO'\n else:\n num_4 -= req_2\n num_1 += 1\n group -= req_2*2\n if group >= 2 and num_1 > 0:\n req_1 = group\n if req_1 > num_1:\n return 'NO'\n else:\n num_1 -= req_1\n group -= req_1\n\n if group != 0:\n return 'NO'\n\n return 'YES'\n\nif __name__ == '__main__':\n n, k = map(int, sys.stdin.readline().split())\n groups = map(int, sys.stdin.readline().split())\n print solve(n, k, groups)\n"}, {"source_code": "n,k = map(int, input().split())\n\na = list(map(int,input().split()))\nall_sum = sum(a)\nr4,r2 = n,n*2\nfor v in range(len(a)):\n\tmid = a[v] // 4\n\ta[v] = a[v] % 4\n\tif mid <= r4:\n\t\tr4 -= mid\n\telse:\n\t\ta[v] += 4 * (mid - r4)\n\t\tr4 = 0\n\tif r4 == 0:\n\t\tbreak\nmid = 0\nr22 = 0\nfor v in a:\n\tif v % 2 == 1:\n\t\tmid += 1\n\tr22 += v // 2\n#print(r4,r22,mid,r2)\nif r4 > 0:\n\tmid -=r4\n\tr22 -= r4\n\tif mid < 0:\n\t\tmid = 0\n\nif r22 + mid > r2:\n\tprint('NO')\nelse:\n\tprint('YES')\n\n\n\n\n\n"}, {"source_code": "n, k = map(int, input().split())\na = sorted(list(map(int, input().split())))[::-1]\nm = n\nfor j in range(len(a)):\n waste = min(a[j] // 4, m)\n m -= waste\n a[j] -= waste * 4\n if m == 0:\n break\nm1, m2, m3, msukabljat = 0, 0, 0, []\nfor x in a:\n m1 += (x == 1)\n m2 += (x == 2)\n m3 += (x == 3)\n msukabljat += ([x] if x >= 4 else [])\nwaste = min(m1, m2, m)\nm, m1, m2 = m - waste, m1 - waste, m2 - waste\nwaste = min(m3, m)\nm, m3 = m - waste, m3 - waste\nwaste = min(m1 // 2, m)\nm, m1 = m - waste, m1 - 2 * waste\nwaste = min(m1, m)\nm, m1 = m - waste, m1 - waste\nwaste = min(m2, m)\nm, m2 = m - waste, m2 - waste\nif m1 + m2 + m3 * 2 + sum([x // 2 + x % 2 for x in msukabljat]) <= 2 * n:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "\nn, k = map(int, raw_input().split(' '))\n\nxs = map(int, raw_input().split(' '))\n\nif sum([x / 2 for x in xs]) + sum([x % 2 for x in xs]) <= 4 * n:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n, k = map(int, input().split())\na = sorted(list(map(int, input().split())))[::-1]\nm = n\nfor j in range(len(a)):\n waste = min(a[j] // 4, m)\n m -= waste\n a[j] -= waste * 4\n if m == 0:\n break\nm1, m2, m3, msukabljat = 0, 0, 0, []\nfor x in a:\n m1 += (x == 1)\n m2 += (x == 2)\n m3 += (x == 3)\n msukabljat += ([x] if x >= 4 else [])\nwaste = min(m1, m2, m)\nm, m1, m2 = m - waste, m1 - waste, m2 - waste\nwaste = min(m2 // 3, m // 2)\nm, m2 = m - waste * 2, m2 - waste * 2\nwaste = min(m1, m2, m3, m // 2)\nm, m1, m2, m3 = m - waste * 2, m1 - waste, m2 - waste, m3 - waste\nwaste = min(m3, m)\nm, m3 = m - waste, m3 - waste\nwaste = min(m1 // 2, m)\nm, m1 = m - waste, m1 - 2 * waste\nwaste = min(m1, m)\nm, m1 = m - waste, m1 - waste\nwaste = min(m2, m)\nm, m2 = m - waste, m2 - waste\nif m1 + m2 + m3 * 2 + sum([x // 2 + x % 2 for x in msukabljat]) <= 2 * n:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "n, k = map(int, input().split())\nseat = {4:n, 2:n*2, 1:0}\na = sorted(map(int, input().split()), reverse=True)\n\ndef sit(n, m):\n num = min(seat[n], m)\n seat[n] -= num\n return m - num\n\nfor m in a:\n d4 = m // 4\n d2 = int(m % 4 > 1)\n d1 = int(m % 2)\n\n extra4 = sit(4, d4)\n d2 += extra4*2\n\n extra2 = sit(2, d2)\n aa = sit(4, extra2)\n seat[1] += extra2 - aa\n d1 += aa * 2\n\n extra1 = sit(1, d1)\n extra1 = sit(2, extra1)\n aa = sit(4, extra1)\n seat[2] += extra1 - aa\n\n if aa > 0:\n print(\"NO\")\n break\nelse:\n print(\"YES\")"}, {"source_code": "def main():\n n, k = map(int, input().split())\n cnt = [0] * 8\n for a in map(int, input().split()):\n n -= a // 8\n cnt[a % 8] += 1\n for comb in (((7, 1),), ((6, 1), (1, 1)), ((5, 1), (2, 1)), ((4, 1), (3, 1)), ((6, 1),), ((5, 1), (1, 1)),\n ((4, 1), (2, 1)), ((3, 2),), ((1, 2), (4, 1)), ((3, 1), (2, 1), (1, 1)), ((2, 3),), ((5, 1),),\n ((4, 1), (1, 1)), ((3, 1), (2, 1)), ((1, 2), (3, 1)), ((2, 2), (1, 1)), ((1, 3), (2, 1)),\n ((4, 1),), ((3, 1), (1, 1)), ((2, 2),), ((1, 2), (2, 1)), ((1, 4),), ((3, 1),),\n ((2, 1), (1, 1)), ((1, 3),), ((2, 1),), ((1, 2),), ((1, 1),)):\n while True:\n newcnt = cnt[:]\n for a, c in comb:\n newcnt[a] -= c\n if any(c < 0 for c in cnt):\n break\n n -= 1\n cnt = newcnt\n print((\"YES\", \"NO\")[n < 0])\n\n\nif __name__ == '__main__':\n main()\n"}], "src_uid": "d1f88a97714d6c13309c88fcf7d86821"} {"source_code": "n, m, r = map(int, input().split())\nb, s = min(map(int, input().split())), max(map(int, input().split()))\nprint(max(r // b * s + r % b, r))", "positive_code": [{"source_code": "nmr=input().split()\nn=int(nmr[0])\nm=int(nmr[1])\nr=int(nmr[2])\nC=list(map(int,input().split()))\nS=list(map(int,input().split()))\nx=min(C)\ny=max(S)\nif(y<=x):\n\tprint(r)\nelse:\n\tn=r//x\n\trem=r%x\n\tr=rem+n*y\n\tprint(r)\n"}, {"source_code": "import sys, math,os\n#from io import BytesIO, IOBase\n#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline\nfrom bisect import bisect_left as bl, bisect_right as br, insort\nfrom heapq import heapify, heappush, heappop\nfrom collections import defaultdict as dd, deque, Counter\n# from itertools import permutations,combinations\nfrom decimal import Decimal\nfrom fractions import Fraction\ndef data(): return sys.stdin.readline().strip()\ndef mdata(): return list(map(int, data().split()))\ndef outl(var): sys.stdout.write(' '.join(map(str, var)) + '\\n')\ndef out(var): sys.stdout.write(str(var) + '\\n')\n#sys.setrecursionlimit(100000 + 1)\nINF = 10**9\nmod = 10**9 + 7\n\nn,m,r=mdata()\ns=mdata()\nb=mdata()\nout(max((r//min(s))*max(b)+r%min(s),r))\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "if __name__ == \"__main__\":\n first_line_components = input().split(' ')\n s = [int(i) for i in input().split(' ')]\n b = [int(i) for i in input().split(' ')]\n r = int(first_line_components[2])\n min_buy = min(s)\n max_sell = max(b)\n\n balance = r % min_buy\n balance += (r // min_buy) * max_sell\n\n result = max([balance, r])\n print(result)\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nfrom collections import defaultdict as dd\nn,m,r=map(int,input().split())\nl=list(map(int,input().split()))\nll=list(map(int,input().split()))\na=min(l)\nb=max(ll)\ncou=r//a\nleft=r%a\ntot=left+cou*b\nprint(max(tot,r))"}, {"source_code": "R = int(input().split()[-1])\n\nbest_buy = min(map(int, input().split()))\nbest_sell = max(map(int, input().split()))\n\nnum_buy = R // best_buy\n\nprint(max(R, R + (best_sell - best_buy) * num_buy))"}, {"source_code": "import os\nimport sys\nimport math\nimport heapq\nfrom decimal import *\nfrom io import BytesIO, IOBase\nfrom collections import defaultdict, deque\n\ndef r():\n return int(input())\ndef rm():\n return map(int,input().split())\ndef rl():\n return list(map(int,input().split()))\n\nn,m,a=rm()\nb=rl()\nc=rl()\nini=a\nb.sort()\nc.sort(reverse=True)\nshares=0\nshares = a//b[0]\na = a%b[0]\na = a + shares*c[0]\nprint(max(ini,a))"}, {"source_code": "n,m,b=map(int,input().split())\nimport math\na1=list(map(int,input().split()))\na2=list(map(int,input().split()))\nif min(a1) < max(a2):\n s = math.floor(b/min(a1))\n b -= min(a1)*s\n b += s * max(a2)\nprint(b)"}, {"source_code": "n, m, d = map(int, input().split())\narr1 = list(map(int, input().split()))\narr2 = list(map(int, input().split()))\nk = min(arr1)\nj = max(arr2)\nif k >= j:\n print(d)\nelse :\n print(d%k + (d//k)*j)\n"}, {"source_code": "n,m,r = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nif min(a) >= max(b):\n print(r)\nelse:\n print((r//min(a))*max(b)+(r%min(a)))"}, {"source_code": "n,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=min(s)\np=r//c\nx=r%c\nif c>=max(b):\n print(r)\nelse:\n q=max(b)*p\n print(x+q)\n \n"}, {"source_code": "a,b,c = map(int,input().split())\nl = list(map(int,input().split()))\nm = list(map(int,input().split()))\nif min(l)>=max(m):print(c)\nelse:print(c+(max(m)-min(l))*(c//min(l)))\n"}, {"source_code": "#-------------Program--------------\n#----Kuzlyaev-Nikita-Codeforces----\n#-------------Training-------------\n#----------------------------------\n\nn,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nm=0;ma=max(b)\nfor i in range(n):\n m=max(m,r//s[i]*ma+r%s[i])\nprint(max(m,r))"}, {"source_code": "n,m,r=map(int,input().split())\nb = list(map(int, input().split()))\nc= list(map(int, input().split()))\nk=min(b)\np=max(c)\nif p>k:\n d=r%k\n print(p*(r//k)+d)\nelse:\n print(r)\n\n"}, {"source_code": "'''input\n2 2 50\n5 7\n4 2\n\n\n'''\n\nRI = lambda : [int(x1) for x1 in raw_input().split()]\nrw = lambda : raw_input().strip()\nimport sys\n\n\nn,m,b = RI()\nA = RI()\nB = RI()\nmi = min(A)\nmx = max(B)\n\nsh = b/mi\nleft = b%mi\nprint max(sh*mx + left,b)"}, {"source_code": "import sys\n# sys.stdin = open('input.txt','r')\nn,m,r = map(int, input().split())\ns = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\ns.sort()\nb.sort()\nif b[-1] > s[0]:\n\tprint(r - (r//s[0])*s[0] + b[-1] * (r//s[0]))\nelse:\n\tprint(r)"}, {"source_code": "from sys import *\nfrom math import *\nn,m,r=map(int,stdin.readline().split())\na=list(map(int,stdin.readline().split()))\nb=list(map(int,stdin.readline().split()))\nif min(a)>max(b):\n print(r)\nelse:\n x=r//min(a)\n ans=r%min(a)\n y=x*max(b)\n ans+=y\n print(ans)\n"}, {"source_code": "n,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nx=min(s)\nsh=r//x\na=r%x\na+=max(b)*sh\nprint(max(a,r))\n"}, {"source_code": "a,b,c= input().split()\nbuy= list(map(int,input().split()))\nsell= list(map(int,input().split()))\n\nbuyat = min(buy)\nbuy.remove(buyat)\nsellat= max(sell)\n\nnumber= int(c)//buyat\nmoney= int(c)- number*buyat\n\nif buyat<sellat:\n ans= number*sellat + money\nelse:\n ans= c\nprint(ans)"}, {"source_code": "n,m,r=map(int,input().split())\ns=min(map(int,input().split()))\nb=max(map(int,input().split()))\nprint(max(r,b*(r//s)+r%s))\n"}, {"source_code": "n, m ,r = map(int, input().split())\ns = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\ns.sort()\nb.sort(key = lambda x: -x)\nif s[0] < b[0]:\n number = r // s[0]\n r -= number * s[0]\n r += number * b[0]\nprint(r)"}, {"source_code": "n, m ,r = map(int, input().split())\ns = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nfirst = min(s)\nsecond = max(b)\nif first < second:\n number = r // first\n r -= number * first\n r += number * second\nprint(r)\n "}, {"source_code": "n, m,x = map(int, input().split())\ndatn = list(map(int, input().split()))\ndatm = list(map(int, input().split()))\nif max(datm) < min(datn):\n print(x)\nelse:\n a,res = divmod(x, min(datn))\n res += a * max(datm)\n print(res)"}, {"source_code": "\n\nn,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\ns.sort()\nb.sort(reverse=True)\nrr=r\nshare=0\n\ni=0\nwhile r>0 and i<n:\n\tshare+=r//s[i]\n\tr-=(r//s[i])*s[i]\n\ti+=1\ni=0\nans=r+b[0]*share\n\nprint(max(ans,rr))"}, {"source_code": "n,m,k=map(int,input().split())\nl1=list(map(int,input().split()))\nl2=list(map(int,input().split()))\nx=[]\nK=min(l1)\nD=max(l2)\nif D<=K:\n print(k)\n exit()\nans=k//K*D\nk=k-k//K*K\nprint(ans+k)\n"}, {"source_code": "i=lambda:map(int,input().split())\n_,_,r=i()\ns=min(i())\nb=max(s,*i())\nprint(r%s+r//s*b)"}, {"source_code": "for _ in range(1):\n #n=int(input())\n #a=sorted(list(map(int, input().split())))\n a,b,c=map(int, input().split())\n x=list(map(int, input().split()))\n y=list(map(int, input().split()))\n p=min(x)\n q=max(y)\n if p>=q: print(c)\n else: print(c//p*q+c%p)\n"}, {"source_code": "# cf 1150 A 900\nn, m, r = map(int, input().split())\nB = [*map(int, input().split())]\nS = [*map(int, input().split())]\n\nB.sort()\nS.sort(reverse=True)\n\norg, p = r, 0\nfor i in range(min(len(B), len(S))):\n if S[i] > B[i]:\n while r >= B[i]:\n p += S[i] - B[i]\n r -= B[i]\n\nprint(org + p)\n\n"}, {"source_code": "n, m, r = map(int, input().split())\ncount = 0\nsp = min(list(map(int, input().split())))\nw = max(list(map(int, input().split())))\nprint(max(r, r // sp * w + r % sp))\n"}, {"source_code": "from sys import stdin\nfrom collections import defaultdict as dd\nimport math\ndef Main():\n n,m,r=map(int,stdin.readline().split())\n s=list(map(int,stdin.readline().split()))\n b=list(map(int,stdin.readline().split()))\n if min(s)>=max(b):\n print(r)\n else:\n a=r//min(s)\n print(r+(max(b)-min(s))*a)\nif __name__==\"__main__\":\n Main()"}, {"source_code": "n, m, r = map(int, input().split())\nbest_buy = min(map(int, input().split()))\nbest_sell = max(map(int, input().split()))\nprint(r + max(0, r // best_buy * (best_sell - best_buy)))"}, {"source_code": "N, M, R = map(int, input().split())\n\nb = min(map(int, input().split()))\ns = max(map(int, input().split()))\n\na = R % b + R // b * s\n\nprint(max(R, a))"}, {"source_code": "n, m, r = map(int, input().split())\nk = r\ns = list(map(int, input().split()))\nb = list(map(int, input().split()))\nr = (r // min(s)) * max(b) + (r - (r // min(s)) * min(s))\nif k >= r:\n\tprint(k)\nelse:\n\tprint(r)"}, {"source_code": "n, m, r = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na.sort()\nb.sort(reverse = True)\nif a[0] >= b[0]:\n print(r)\n exit()\nq = r // a[0]\nr -= q * a[0]\nr += q * b[0]\nprint(r)"}, {"source_code": "n,m,r=map(int,input().split())\nS=list(map(int,input().split()))\nB=list(map(int,input().split()))\nmini=min(S)\nmaxi=max(B)\nif mini>=maxi:\n\tprint(r)\nelse:\n\tb=r//mini\n\tr+=(maxi-mini)*b\n\tprint(r)\n"}, {"source_code": "n,m,r=[int(i) for i in input().split()]\ns=[int(i) for i in input().split()]\nb=[int(i) for i in input().split()]\nsmin=min(s)\nbmax=max(b)\nnsb=r//smin\nrp=r-(nsb*smin)\nif (rp+nsb*bmax)>r:\n print(rp+nsb*bmax)\nelse:\n print(r)"}, {"source_code": "n,m,r=[int(x) for x in input().split()]\ns=[int(x) for x in input().split()]\nb=[int(x) for x in input().split()]\n#print(s)\n#print(b)\nmin=s[0]\nmax=b[0]\nfor x in range(1,n):\n if (s[x]<min):\n min=s[x]\nfor x in range(1,m):\n if(b[x]>max):\n max=b[x]\n#print(min)\n#print(max)\nk=int(r/min)\ntotal=r-(k*min)+(k*max)\nif(total>r):\n print(total)\nelse:\n print(r)\n"}, {"source_code": "n,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nMIN=min(s)\nMAX=max(b)\nprint (max(r,(r%MIN+MAX*(r//MIN))))\n"}, {"source_code": "# your code goes here\nn,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\ns.sort()\nb.sort()\nif(s[0]>=b[m-1]):\n\tprint(r)\nelse:\n\t\tprint((r//s[0])*b[m-1]+r%s[0])\n\n\t\t"}, {"source_code": "n,m,r=map(int,input().split());a=min(list(map(int,input().split())));b=max(list(map(int,input().split())));print(max(r,r%a+(b*(r//a))))"}, {"source_code": "import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\ndd=[(-1,0),(0,1),(1,0),(0,-1)]\nddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\n# def LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return input()\n\ndef main():\n n,m,r=LI()\n l1=LI()\n l2=LI()\n\n l1.sort()\n l2.sort()\n\n x=r//l1[0]\n _r=r-x*l1[0]\n\n y=x*l2[-1]\n\n return max(r,_r+y)\n\n# main()\nprint(main())\n"}, {"source_code": "i=lambda:map(int,input().split())\n_,_,r=i()\ns=min(i())\nb=max(s,*i())\nprint(r%s+r//s*b)"}, {"source_code": "def myfunc(l1):\n return l1[-1]\ndef solution(l1,l2,l3):\n n,m,r = l1[0],l1[1],l1[2]\n l2.sort()\n l3.sort()\n l3.reverse()\n i=0\n ans=r\n while r>=0 and i<len(l2) and l3[0]-l2[i]>0:\n if r>=l2[i]:\n r-=l2[i]\n ans+=l3[0]-l2[i]\n else:\n i+=1\n return ans\n \ndef answer():\n l1 = [int(x) for x in input().split()]\n l2 = [int(x) for x in input().split()]\n l3 = [int(x) for x in input().split()]\n print(solution(l1,l2,l3))\nanswer()"}, {"source_code": "n,m,r = map(int,input().split())\ns = [*map(int,input().split())]\np = [*map(int,input().split())]\nmm=min(s)\nyy=max(p)\nqq=r//mm\nprint(max(qq*yy+(r%mm),r))"}, {"source_code": "a,b,c=map(int, input().split())\nd=list(map(int, input().split()))\ne=list(map(int, input().split())) \ng=min(d)\nh=max(e)\nx=c-((c//g)*g)\nif h>g:\n print(x+(c//g)*h)\nelse:\n print(c)"}, {"source_code": "nmr = list(map(int, input().split()))\ns = list(map(int, input().split()))\nb = list(map(int, input().split()))\nstocks = 0\nminS = 1001\nmaxB = 0\nfor k in range(nmr[0]):\n\tminS = min(minS, s[k])\nfor k in range(nmr[1]):\n\tmaxB = max(maxB, b[k])\nif minS < maxB:\n\tstocks = (nmr[2] // minS)\n\tnmr[2] -= (stocks * minS)\n\tnmr[2] += (stocks * maxB)\nprint(nmr[2])"}, {"source_code": "def strtoint(n,list):\n for i in range(n):\n list[i]=int(list[i])\n\nn=input().split()\nstrtoint(3,n)\nbuin=input().split()\nstrtoint(n[0],buin)\nbuout=input().split()\nstrtoint(n[1],buout)\n\nbuin.sort()\nbuout.sort(reverse=True)\n\nif buin[0]>buout[0]:\n print(n[2])\n exit(0)\nelse:\n print(n[2]+int(n[2]/buin[0])*(buout[0]-buin[0]))"}, {"source_code": "line_one=list(map(int,input().split()))\nline_two=list(map(int,input().split()))\nline_three=list(map(int,input().split()))\nr=line_one[2]\n\n\nmin_buy_price=min(line_two)\nmax_sell_price=max(line_three)\n\nif(max_sell_price>min_buy_price):\n exchange=r%min_buy_price\n price=int(r/min_buy_price)*(max_sell_price)\n print(exchange+price)\n\nelse:\n print(r)\n\n\n"}, {"source_code": "n,m,r=map(int,input().split())\nb=list(map(int,input().split()))\ns=list(map(int,input().split()))\ncount=0\nr1=r\ncount+=int(r/min(b))\nr1-=count*min(b)\nr1+=max(s)*count\n\nprint(max(r,r1))"}, {"source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# import math\n# from itertools import *\n# import random\n# import calendar\n# import datetime\n# import webbrowser\n\nn, m, r = map(int, input().split())\nbuy = list(map(int, input().split()))\nsell = list(map(int, input().split()))\noriginl_money = r\nbuy.sort()\nsell.sort()\ntemp = r // buy[0]\nr -= (temp * buy[0])\nr += (temp * sell[-1])\nif originl_money <= r:\n print(r)\nelse:\n print(originl_money)\n"}, {"source_code": "\n\nfunc=lambda:map(int,input().split())\nn,m,r=func()\nmin1 = min(func())\nmax1 = max(func())\ns = r + max(0, r//min1 * max1 + r%min1 - r)\nprint(s)"}, {"source_code": "n, m, r = map(int, input().split())\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nsum2=0\nsum1=0\ns=0\nk=0\nval=0\nans=0\nj=0\ndiv=0\nj=max(n,m)\ns=min(b)\nk=max(c)\nif s<=k:\n div=r//s\n val=k-s\n ans=r+(div*val)\n print(ans)\nelse:\n print(r)"}, {"source_code": "import sys\n# sys.stdin = open('input.txt','r')\nn,m,r = map(int, input().split())\ns = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\ns[0] = min(s)\nb[-1] = max(b)\nif b[-1] > s[0]:\n\tprint(r - (r//s[0])*s[0] + b[-1] * (r//s[0]))\nelse:\n\tprint(r)"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nif __name__ == \"__main__\":\n n, m, r = map(int, input().split())\n x = min(map(int, input().split()))\n y = max(map(int, input().split()))\n if (x>=y):\n print(r)\n else:\n print( (r//x)*y + r % x)\n"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin, stderr\n\ndef solve(N, M, R, S, B):\n mn = min(S)\n mx = max(B)\n if mn >= mx:\n return R\n shares = R / mn\n return R - shares * mn + shares * mx\n\ndef main():\n N, M, R = map(int, stdin.readline().split())\n S = map(int, stdin.readline().split())\n B = map(int, stdin.readline().split())\n res = solve(N, M, R, S, B)\n print(res)\n\n return 0\n\nif __name__ == '__main__': main()\n"}, {"source_code": "n,m ,r = raw_input().split(\" \")\nn,m,r = [int(n), int(m), int(r)]\nmorn = raw_input().split(\" \")\nnight = raw_input().split(\" \")\n\nmorn = [int(k) for k in morn]\nnight = [int(k) for k in night]\n\ncp = min(morn)\nsp = max(night)\n\nif (sp<=cp):\n\tprint(r)\nelse:\n\tcan_buy = int(r/cp)\n\ttot = can_buy * (sp - cp)\n\tr += tot\n\tprint(r)"}, {"source_code": "n , m , r = [int(i) for i in raw_input().split()]\na = [int(i) for i in raw_input().split()]\nb = [int(i) for i in raw_input().split()]\na = sorted(a)\nb = sorted(b, reverse=True)\nans = r\nif a[0] < b[0]:\n ans = r % a[0] + r / a[0] * b[0]\n\nprint ans\n"}, {"source_code": "n, m, r = [int(t) for t in input().split(' ')]\ns = [int(t) for t in input().split(' ')]\nb = [int(t) for t in input().split(' ')]\nprint(max(r % min(s) + max(b) * (r // min(s)), r))\n"}, {"source_code": "n, m, r = map(int, raw_input().split(' '))\n\ns = list(map(int, raw_input().split(' ')))\nb = list(map(int, raw_input().split(' ')))\n\nres = max(r, (r / min(s)) * max(b) + (r % min(s)))\n\nprint res\n\n"}, {"source_code": "n,m,r = [int(nmr) for nmr in raw_input().split(\" \")]\ns = [int(si) for si in raw_input().split(\" \")]\nb = [int(bi) for bi in raw_input().split(\" \")]\nprint max(r, ( ( (r/min(s)) * max(b) ) + (r%min(s)) ) )"}, {"source_code": "a,b,c = map(int, raw_input().split())\nx = min(map(int, raw_input().split()))\ny = max(map(int, raw_input().split()))\nans = c%x+max(c-(c%x), c/x*y)\nprint ans"}, {"source_code": "n, m, r = map(int, raw_input().split())\ns = map(int, raw_input().split())\nb = map(int, raw_input().split())\n\nbuy_price = min(s)\nsell_price = max(b)\nshares = r // buy_price\n\nprint max(0, (sell_price - buy_price) * shares) + r\n"}, {"source_code": "n, m, r = map(int,input().split())\nbuy_shares = list(map(int,input().split()))\nsell_shares = list(map(int,input().split()))\na = r//min(buy_shares)\nbuy = min(buy_shares)*a\nif max(sell_shares) > min(buy_shares):\n\tprint(a*max(sell_shares)+r%min(buy_shares))\nelse:\n\tprint(r)"}, {"source_code": "n, m, r = map(int, input().split())\na = min(map(int, input().split()))\nb = max(map(int, input().split()))\nprint(max(r%a + (r//a)*b, r))\n"}, {"source_code": "n, m, r = map(int, raw_input().split())\nl1 = map(int, raw_input().split())\nl2 = map(int, raw_input().split())\na1 = min(l1)\na2 = max(l2)\nprofit = (r / a1) * a2 - (r / a1) * a1\nprofit = max(profit, 0)\nprint profit + r"}, {"source_code": "n,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nm1=min(s)\nm2=max(b)\nif m1<m2:\n u=r//m1\n r=r-u*m1\n p=u*m2\n r=r+p\n print(r)\nelse:\n print(r)"}, {"source_code": "n, m, r = map(int, input().split())\ns = sorted(list(map(int, input().split())))\nb = max(list(map(int, input().split())))\nmoney = r\ni = 0\na = 0\nwhile i < n and r // s[i] > 0:\n a += r // s[i]\n r -= s[i] * (r // s[i])\n i += 1\nprint(max(money, r + a * b))"}, {"source_code": "n, m, r = map(int, input().split())\ns = map(int, input().split())\nb = map(int, input().split())\n\ns_min = min (s)\nb_max = max (b)\n\nif s_min > b_max or r < s_min:\n print(r)\nelse:\n h = r - r // s_min * s_min\n print(r // s_min * b_max + h)\n\n\n"}, {"source_code": "n, m, r = map(int, input().split())\nlst1 = list(map(int, input().split()))\nlst2 = list(map(int, input().split()))\n\n\"\"\"\nfor i in lst1:\n\tprint (i, end = \" \")\nfor i in lst2:\n\tprint(i, end = \" \")\n\"\"\"\n\nx = min(lst1)\ny = max(lst2)\n\nsold = r // x * y\nhow = r - r // x * x\nprint(max(r, sold + how))"}, {"source_code": "n, m, r = tuple(map(int, input().split()))\nm1 = list(map(int, input().split()))\nm2 = list(map(int, input().split()))\n\nmin1 = min(m1)\nmax1 = max(m2)\n\nif min1 < max1:\n print(r // min1 * max1 + r % min1)\nelse:\n print(r)"}, {"source_code": "#!/usr/bin/python\n\nint_input = lambda: [int(i) for i in raw_input().split()]\n\nn, m, r = int_input()\na = min(int_input())\nb = max(int_input())\n\nprint max(r, r % a + r / a * b)\n\n"}, {"source_code": "n, m, r = map(int, raw_input().split())\ns = map(int, raw_input().split())\nb = map(int, raw_input().split())\nx = min(s)\ny = max(b)\nif x >= y:\n print r\nelse:\n z = r / x\n r -= z * x\n print r + z * y"}, {"source_code": "n, m, r = map(int, input().split())\nb = min(map(int, input().split()))\nprint(r // b * max(b, *map(int, input().split())) + r % b)"}, {"source_code": "\ndef mai():\n a,b,c=input().split()\n n=int(a)\n m=int(b)\n tk=int(c)\n share=0\n s_price=[0 for i in range(m)]\n b_price=[0 for i in range(n)]\n \n a=input().split()\n for i in range(n):\n b_price[i]=int(a[i])\n a=input().split()\n for j in range(m):\n s_price[j]=int(a[j])\n \n s_price.sort(reverse=True)\n b_price.sort()\n \n if s_price[0] < b_price[0]:\n print(tk)\n return \n else:\n share=int(tk/b_price[0])\n b=tk % b_price[0]\n tk=tk-(share*b_price[0])\n \n \n s=share*s_price[0]\n print(tk+s)\n \nmai()\n "}, {"source_code": "n,m,r=map(int,input().split())\nbuy=list(map(int,input().split()))\nsell=list(map(int,input().split()))\nx=(r//min(buy))\nleft=r-(x*(min(buy)))\ny=max(sell)*x\nif (y+left)>r:\n\tprint(y+left)\nelse:\n\tprint(r)"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\n\n\nn,m,r = list(map(int, input().split()))\nmorning = list(map(int, input().split()))\nevening = list(map(int, input().split()))\n\ntmp = 0\nmin_ = min(morning)\n\ntmp = r//min_\ntmp2 = r%min_\nprint(max(r, (tmp*max(evening)) + tmp2))\n"}, {"source_code": "n,m,r = [int(i) for i in input().split()]\npok = [int(i) for i in input().split()]\npr = [int(i) for i in input().split()]\npk_m = min(pok)\np_m = max(pr)\nck = r+1\nc =r //pk_m\nr = r%pk_m \nfor j in range(c):\n r+=p_m\nprint(max(ck-1,r))"}, {"source_code": "I = lambda: int(input())\nIL = lambda: list(map(int, input().split()))\n\nn, m, r = IL()\nS = IL()\nB = IL()\n\nprint(r // min(S) * max(*B, min(S)) + (r % min(S)))"}, {"source_code": "n, m, r = map(int, input().split())\ngm = list(map(int, input().split()))\ngn = list(map(int, input().split()))\nmn = min(gm)\ns = r // mn\nc = r % mn\nrez = c + max(gn) * s\nif min(gm) > max(gn):\n print(r)\nelse:\n print(rez)\n"}, {"source_code": "n,m,r=map(int,input().split())\na1=list(map(int,input().split()))\na2=list(map(int,input().split()))\nb1=min(a1)\nb2=max(a2)\nprint(max(r,r%b1+r//b1*b2))\n"}, {"source_code": "n, m, r = map(int, input().split())\ns = map(int, input().split())\nb = map(int, input().split())\n\ns_min = min (s)\nb_max = max (b)\n\nif s_min >= b_max or r < s_min:\n print(r)\nelse:\n h = r - r // s_min * s_min\n print(r // s_min * b_max + h)"}, {"source_code": "a = list(map(int,input().split()))\nb = sorted(list(map(int,input().split())))\nc = sorted(list(map(int,input().split())),reverse=True)\nmoney = a[2]\ngain = 0\nfor i in range(min(a[0],a[1])):\n if c[i]-b[i] > 0:\n stocks = money//b[0]\n money -= stocks*b[0]\n gain += (c[0])*stocks\nprint(money+gain)"}, {"source_code": "n, m, r = map(int, input().split())\n\nl = list(map(int, input().split()))\nk = list(map(int, input().split()))\n\npri_min = min(l)\n\nqut = r // pri_min\nrem = r % pri_min\nz = max(k)\n#print(f\"{pri_min} {qut} {rem} {z}\")\n\nif (z * qut)+rem >= r:\n print(z * qut+ rem)\n\nelse:\n print(r)\n"}, {"source_code": "a=input().split()\nb=input().split()\ns=input().split()\nmaanie=int(a[2])\nbuy=1000\nsell=1\nfor i in range(len(b)):\n if buy>int(b[i]):\n buy=int(b[i])\nfor i in range(len(s)):\n if sell<int(s[i]):\n sell=int(s[i])\n\nif (buy<sell):\n maanie+=maanie//buy*(sell-buy)\nprint(maanie)"}, {"source_code": "n, m, r= map(int, input().split())\ns_ = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\n#n ,m , r = 5, 6, 8\n#s_ = [7, 7, 10, 5, 5]\n#b= [5, 6, 2, 8, 1, 8]\n\ns = []\nfor x in s_:\n if x not in s:\n s.append(x)\nn = len(s)\n\nif min(s)>=max(b):\n print(r)\nelse:\n quantity =[]\n balance = []\n for i in range (n):\n quantity.append(r//s[i])\n balance.append(r%s[i])\n best_quantity =max(quantity)\n best_balance = -1\n #print(balance)\n op = quantity.count(best_quantity)\n #print(op)\n for q in range (op):\n #print(balance[quantity.index(best_quantity)])\n if best_balance < balance[quantity.index(best_quantity)]:\n best_balance = balance[quantity.index(best_quantity)]\n #del quantity[quantity.index(best_quantity)]\n quantity[quantity.index(best_quantity)] = 0\n #quantity.insert(quantity.index(best_quantity), 0)\n #print(quantity) \n #print (best_balance)\n print(best_quantity*max(b)+best_balance)"}, {"source_code": "[n, m, r] = list(map(int, input().split(\" \")))\ns = list(map(int, input().split(\" \")))\nb = list(map(int, input().split(\" \")))\n\nn = r % min(s) + (r // min(s))*max(b)\nprint(max(r, n))\n"}], "negative_code": [{"source_code": "\nbuy_times, sell_times, cash = list(map(int, input().split()))\nb = list(map(int, input().split()))\ns = list(map(int, input().split()))\n\nif min(b) >= max(s):\n print (cash)\n \nelse:\n top_stocks = cash // min(b) \n profit = top_stocks * max(s) \n if cash % 2 != 0:\n profit += 1\n print( profit)"}, {"source_code": "n,m,r=map(int,input().split())\nl=list(map(int,input().split()))\nll=list(map(int,input().split()))\nprint((r//min(l))*max(ll)+(r%min(l)))"}, {"source_code": "from sys import stdin,stdout\ni = lambda : map(int,stdin.readline().split())\np = lambda x: stdout.write(str(x)+\" \") \npa = lambda list: stdout.write(\" \".join(str(x) for x in list)) \n\nn,m,r = i()\nb = i()\ns = i()\nbuy = min(b)\nsell = max(b)\nif buy<sell:\n\tprint sell*(r/buy) + r%buy\nelse:\n\tprint r"}, {"source_code": "n,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=s[0]\nfor i in range(1,n):\n if (r//c)<(r//s[i]):\n c=s[i]\n\np=r//c\nx=r%c\nif c>min(b):\n print(r)\nelse:\n q=max(b)*p\n print(x+q)\n print(q,c,max(b))\n\n"}, {"source_code": "n,m,r=map(int,input().split())\nn1=list(map(int,input().split()))\nm1=list(map(int,input().split()))\nmoney=r\nd=r\nif n == 1:\n n2 = n1[0]\nelse:\n n2 = min(n1)\nif m == 1:\n m2 = m1[0]\nelse :\n m2 = max(m1)\n\nwhile n2<m2:\n if d>n2:\n d= d%n2\n c=(r-(r%n2))/n2\n money = money + (m2-n2)*c\n n1.pop(n1.index(n2))\n elif d!=0 and d > n2 and n2<m2:\n d= d%n2\n c=(r-(r%n2))/n2\n money = money + (m2-n2)*c\n n1.pop(n1.index(n2))\n else:\n break\nprint(int(money))\n\n\n\n"}, {"source_code": "n, m, r = map(int, input().split())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nmx = 0\nans = 0\nfor x in a:\n\tans = max(ans, r // x * max(b) + r % x)\nprint(ans)\n"}, {"source_code": "a,b,c=[int(x) for x in input().split()]\na1 = list(map(int,input().strip().split()))[:a]\nb1 = list(map(int,input().strip().split()))[:b]\nc1=max(a1)\nc2=min(a1)\nc3=max(b1)\ns=c1*c2\nk=c3*c3\nz=0\nif(s<=k):\n z = c + k-s\nelse:\n z=c+0;\nprint(z)\n"}, {"source_code": "valores = input()\nvalores = valores.split(' ')\nr = int(valores[-1])\n\nn = input()\nn = n.split(' ')\nfor i in range(len(n)):\n n[i] = int(n[i])\n\nm = input()\nm = m.split(' ')\nfor i in range(len(m)):\n m[i] = int(m[i])\n\nif min(n) > max(m):\n\tprint(r)\nelif min(n) < max(m):\n\tprint(r-((r//min(n))*min(n))+((r//min(n))*(max(m))))"}, {"source_code": "def solve():\n n,m,r = map(int, input().split())\n s = [int(k) for k in input().split()]\n b = [int(k) for k in input().split()]\n \n s.sort()\n b.sort()\n \n print (max((r//s[0]) * b[-1], r))\n \nif __name__ == \"__main__\": \n solve()"}, {"source_code": "n, m, r = [int(t) for t in input().split(' ')]\ns = [int(t) for t in input().split(' ')]\nb = [int(t) for t in input().split(' ')]\nprint(r % min(s) + max(b) * (r // min(s)))\n"}, {"source_code": "n,m,r=map(int,input().split())\narr=list(map(int,input().split()))\narrb=list(map(int,input().split()))\narr.sort()\narrb.sort()\nif(arr[0]>=arrb[m-1]):\n print(r)\nelse:\n buy=r//arr[0]\n r=r-(buy*arr[0])\n print(r)\n r=r+(buy*(arrb[m-1]))\n print(r)\n"}, {"source_code": "n,m,r=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split() ))\nx=min(a)\ny=max(b)\nif(x>=y):\n print(r)\nelse:\n print((r//x)*y)\n\n"}, {"source_code": "n,m,r = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input(). split()))\nu = min(a)\nv = max(a)\nif(v > u):\n s = r//u\n r = r%u\n r += s*v\nprint(r)"}, {"source_code": "n,m,r=map(int,input().split())\ns=min(map(int,input().split()))\nb=max(map(int,input().split()))\nprint(b*(r//s)+r%s)\n"}, {"source_code": "n, m, r = map(int, raw_input().split())\na = min(map(int, raw_input().split()))\nb = max(map(int, raw_input().split()))\nprint r/a * b\n"}, {"source_code": "valores = input()\nvalores = valores.split(' ')\nr = int(valores[-1])\n\nn = input()\nn = n.split(' ')\nfor i in range(len(n)):\n n[i] = int(n[i])\n\nm = input()\nm = m.split(' ')\nfor i in range(len(m)):\n m[i] = int(m[i])\n\nif min(n) > max(m):\n\tprint(r)\nelif min(n) < max(m):\n\tprint(r-((r//min(n))*min(n))+((r//min(n))*(max(m))))"}, {"source_code": "n, m, r = [int(t) for t in input().split(' ')]\ns = [int(t) for t in input().split(' ')]\nb = [int(t) for t in input().split(' ')]\nprint(r % min(s) + max(b) * (r // min(s)))\n"}, {"source_code": "n,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=s[0]\nfor i in range(1,n):\n if (r//c)<(r//s[i]):\n c=s[i]\n\np=r//c\nx=r%c\nif c>min(b):\n print(r)\nelse:\n q=max(b)*p\n print(x+q)\n print(q,c,max(b))\n\n"}, {"source_code": "def share():\n n, m, r = [int(x) for x in input().split()]\n s = []\n b = []\n for i in input().split():\n s.append(int(i))\n for i in input().split():\n b.append(int(i))\n s = min(s) \n b = max(b)\n ac = r // s\n rr = r % s\n result = ac * b + rr\n return print( max(result, r))"}, {"source_code": "from sys import stdin,stdout\ni = lambda : map(int,stdin.readline().split())\np = lambda x: stdout.write(str(x)+\" \") \npa = lambda list: stdout.write(\" \".join(str(x) for x in list)) \n\nn,m,r = i()\nb = i()\ns = i()\nbuy = min(b)\nsell = max(b)\nprint sell*(r/buy) + r%buy"}, {"source_code": "n, m, r = map(int, input().split())\ns = [int(c) for c in input() if c != ' ']\nb = [int(c) for c in input() if c != ' ']\n\nif min (s) > max(b):\n print(r)\nh = r - r // min(s) * min(s)\nprint(r // min(s) * max(b) + h)"}, {"source_code": "n1,n2,k = map(int, input().split())\nm = map(int, input().split())\ne = map(int, input().split())\nmi = min(m)\nma = max(e)\nn = k//mi\nleft = k%mi\nprint((ma-mi)*n + left)"}, {"source_code": "import sys\n\ninp = sys.stdin.readlines()\na,b,c=inp[0].split()\nmi=min(int(x) for x in inp[1].split())\nma=max(int(x) for x in inp[2].split())\nx=int(int(c)/mi)\nrem=int(c)-x*mi\nprint(int(rem+x*ma))\n"}, {"source_code": "n, m, r = map(int, input().split())\nl1 = list(map(int, input().split()))\nl2 = list(map(int, input().split()))\na = min(l1)\nb = max(l2)\nif a < b:\n q = r // min(l1)\n w = q * b\n print((r - a * q) + w)\nelif a > b:\n print(r)\n "}, {"source_code": "\nbuy_times, sell_times, cash = list(map(int, input().split()))\nb = list(map(int, input().split()))\ns = list(map(int, input().split()))\n\nif min(b) >= max(s):\n print (cash)\n \nelse:\n top_stocks = cash // min(b) \n profit = top_stocks * max(s) \n if cash % 2 != 0:\n profit += 1\n print( profit)"}, {"source_code": "n,m,r=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nmn=min(a)\nmx=max(b)\nt=r//mn\nr=r%mn\nr=r+t*mx\nprint(r)"}, {"source_code": "import math\nimport heapq\n\nn, m, r= map(int, input().split())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\n\ns = r//a[0]\nr-=s*a[0]\nprint(r+s*b[-1])"}, {"source_code": "m = list(map(int, input().split()))\nb=list(map(int, input().split()))\ns=list(map(int, input().split()))\n\nmoney = m[-1]\nmin_price = min(b)\nmax_price = max(s)\nmoney_left = 0\n\nif money >= min_price:\n for i in range(money) :\n if money % min_price == 0:\n shares = int(money/min_price)\n break\n else:\n money -= 1\n money_left +=1\n\n profit = ((shares*max_price)+ money_left)\n if profit > m[-1]:\n print(profit)\n else:\n print(m[-1])\n"}, {"source_code": "def solve():\n n,m,r = map(int, input().split())\n s = [int(k) for k in input().split()]\n b = [int(k) for k in input().split()]\n \n s.sort()\n b.sort()\n \n print (max((r//s[0]) * b[-1], r))\n \nif __name__ == \"__main__\": \n solve()"}, {"source_code": "a,b,c=[int(x) for x in input().split()]\na1 = list(map(int,input().strip().split()))[:a]\nb1 = list(map(int,input().strip().split()))[:b]\nc1=max(a1)\nc2=min(a1)\nc3=max(b1)\ns=c1*c2\nk=c3*c3\nz=0\nif(s<=k):\n z = c + k-s\nelse:\n z=c+0;\nprint(z)\n"}, {"source_code": "def main():\n s = [int(x) for x in input().split()]\n r = s[2]\n buy = min([int(x) for x in input().split()])\n sell = max([int(x) for x in input().split()])\n morning = r // buy\n evening = morning * sell\n if evening >= r:\n ans = evening + r % buy\n print(ans)\n else:\n print(r)\n\n\nmain()\n"}, {"source_code": "datos =input()\nd = datos.split()\n\nn = int(d[0])\nm= int(d[1])\nr = int(d[2])\n\ns = input()\ns1 = s.split()\nsf = sorted(s1)\n\n\nb = input()\nb1 = b.split()\nbf = sorted(b1)\n\nC = int(sf[0]) #Valor Menor Compra\nV = int(bf[-1]) #Valor Mayor Venta\n\nif C < V:\n I = r// C\n Rinv = r - (C*I)\n G = I*V\n rf = G + Rinv\n print(rf)\n\nelse:\n print(r)\n"}, {"source_code": "valores = input()\nvalores = valores.split(' ')\nr = int(valores[-1])\n\nn = input()\nn = n.split(' ')\nfor i in range(len(n)):\n n[i] = int(n[i])\n\nm = input()\nm = m.split(' ')\nfor i in range(len(m)):\n m[i] = int(m[i])\n\nif min(n) > max(m):\n\tprint(r)\nelif min(n) < max(m):\n\tprint(r-((r//min(n))*min(n))+((r//min(n))*(max(m))))"}, {"source_code": "nmr=list(int(num) for num in input().split())\nn=list(map(int,input().split()))\nm=list(int(num) for num in input().split())\nminimum_of_buying=min(n)\nmaximum_of_selling=max(m)\nif(minimum_of_buying>maximum_of_selling):\n\tprint(nmr[2])\nelse:\n\tif(len(m)==1):\n\t\ta=maximum_of_selling\n\telse:\n\t\ta=5\n\tprint(nmr[2]+(a*maximum_of_selling)-(minimum_of_buying*a))"}, {"source_code": "m,n,r=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nd=r//min(a)\nif r<=d*(max(b)):\n\tprint(d*(max(b))+r%d)\nelse:\n\tprint(r)"}, {"source_code": "n = input().split()\nr = int(n[2])\n\na = input().split()\nb = input().split()\n\nmn = 1000000000000\nmx = -1\n\nfor i in a:\n mn = min(mn,int(i))\n \nd = r %mn\nr //= mn\n\nfor i in b:\n mx = max(mx,int(i))\n \nprint(mx * r + d)"}, {"source_code": "n, m, r = map(int, input().split())\nn_s = min(list(map(int, input().split())))\nm_s = max(list(map(int, input().split())))\nprint((r % n_s) + m_s * r // n_s)"}, {"source_code": "n,m,k = input().split(' ')\nn = int(n)\nm = int(m)\nk = int(k)\na = list(map(int,input().split(' ')))\nb = list(map(int,input().split(' ')))\n\naa = min(a)\nbb = max(b)\n\ncnt = k // aa\nr = k % aa\n#print(cnt,bb)\nbuy = cnt * bb\n\nif buy > k-r:\n print((bb * cnt) + r)\nelse:\n print(0)"}, {"source_code": "n,m,b = map(int,input().split())\nl = list(map(int,input().split()))\nh = list(map(int,input().split()))\nprint(b-min(l)*(b//min(l))+max(h)*(b//(min(l))))\n"}, {"source_code": "n = input().split()\nr = int(n[2])\n\na = input().split()\nb = input().split()\n\nmn = 1000000000000\nmx = -1\n\nfor i in a:\n mn = min(mn,int(i))\n \nd = r %mn\nr //= mn\n\nfor i in b:\n mx = max(mx,int(i))\n \nprint(mx * r + d)"}, {"source_code": "n,m,b=map(int,input().split())\n\np=list(map(int,input().split()))\ns=list(map(int,input().split()))\n\nk=min(p)\nk1=b//k\nd=k1*k\nif(b>d):\n r=b-d\nelse:\n r=0\nz=max(s)\nz=k1*z\n\nif(b>=z):\n print(b)\nelse:\n print(z+r)\n\n\n \n \n"}, {"source_code": "a,b,c = map(int, raw_input().split())\nx = min(map(int, raw_input().split()))\ny = min(map(int, raw_input().split()))\nans = c%x+max(c-(c%x), c/x*y)\nprint ans"}, {"source_code": "money = int(input().split()[-1])\nbest_price = min(map(int, input().split()))\nbest_sell = max(map(int, input().split()))\n\nactions = money // best_price\nremaining = money % best_price\n\nresult = actions * best_sell + remaining\nprint(result)"}, {"source_code": "def solve():\n n,m,r = map(int, input().split())\n s = [int(k) for k in input().split()]\n b = [int(k) for k in input().split()]\n \n s.sort()\n b.sort()\n \n print (max((r//s[0]) * b[-1], r))\n \nif __name__ == \"__main__\": \n solve()"}, {"source_code": "n, m, r= map(int, input().split())\ns = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\n#n ,m , r = 2, 1, 10\n#s = [5,4]\n#b= [100]\n\n\nif min(s)>=max(b):\n print(r)\nelse:\n quantity =[]\n balance = []\n for i in range (n):\n quantity.append(r//s[i])\n balance.append(r%s[i])\n best_quantity =max(quantity)\n best_balance = -1\n #print(balance)\n op = quantity.count(best_quantity)\n #print(op)\n for q in range (op):\n #print(balance[quantity.index(best_quantity)])\n if best_balance < balance[quantity.index(best_quantity)]:\n best_balance = balance[quantity.index(best_quantity)]\n #del quantity[quantity.index(best_quantity)]\n quantity.insert(quantity.index(best_quantity), 0)\n #print(quantity) \n #print (best_balance)\n print(best_quantity*max(b)+best_balance)"}, {"source_code": "n1,n2,k = map(int, input().split())\nm = map(int, input().split())\ne = map(int, input().split())\nmi = min(m)\nma = max(e)\nn = k//mi\nleft = k%mi\nprint((ma-mi)*n + left)"}, {"source_code": "n,m,k = input().split(' ')\nn = int(n)\nm = int(m)\nk = int(k)\na = list(map(int,input().split(' ')))\nb = list(map(int,input().split(' ')))\n\naa = min(a)\nbb = max(b)\n\ncnt = k // aa\nr = k % aa\n#print(cnt,bb)\nbuy = cnt * bb\n\nif buy > k-r:\n print((bb * cnt) + r)\nelse:\n print(r)"}, {"source_code": "money = int(input().split()[-1])\nbest_price = min(map(int, input().split()))\nbest_sell = max(map(int, input().split()))\n\nactions = money // best_price\nremaining = money % best_price\n\nresult = actions * best_sell + remaining\nprint(result)"}, {"source_code": "m = list(map(int, input().split()))\nb=list(map(int, input().split()))\ns=list(map(int, input().split()))\n\nmoney = m[-1]\nmin_price = min(b)\nmax_price = max(s)\nmoney_left = 0\n\nif money >= min_price:\n for i in range(money) :\n if money % min_price == 0:\n shares = int(money/min_price)\n break\n else:\n money -= 1\n money_left +=1\n\n profit = ((shares*max_price)+ money_left)\n if profit > m[-1]:\n print(profit)\n else:\n print(m[-1])\n"}, {"source_code": "n,m,k = input().split(' ')\nn = int(n)\nm = int(m)\nk = int(k)\na = list(map(int,input().split(' ')))\nb = list(map(int,input().split(' ')))\n\naa = min(a)\nbb = max(b)\n\ncnt = k // aa\nr = k % aa\n#print(cnt,bb)\nbuy = cnt * bb\n\nif buy > k:\n print((bb * cnt) + r)\nelse:\n print(cnt * aa)"}, {"source_code": "nmr=list(int(num) for num in input().split())\nn=list(map(int,input().split()))\nm=list(int(num) for num in input().split())\nminimum_of_buying=min(n)\nmaximum_of_selling=max(m)\nif(minimum_of_buying>maximum_of_selling):\n\tprint(nmr[2])\nelse:\n\tprint(nmr[2]+(maximum_of_selling*maximum_of_selling)-(maximum_of_selling*minimum_of_buying))"}, {"source_code": "def main():\n s = [int(x) for x in input().split()]\n r = s[2]\n buy = min([int(x) for x in input().split()])\n sell = max([int(x) for x in input().split()])\n morning = r // buy\n evening = morning * sell\n if evening >= r:\n ans = evening + r % buy\n print(ans)\n else:\n print(r)\n\n\nmain()\n"}, {"source_code": "d1=(input(\"AAA\"))\nd2=(input(\"AAA\"))\nd3=(input(\"AAA\"))\n\nL1=d1.split()\nL2=d2.split()\nL3=d3.split()\nfor i in L1:\n\ti=int(i)\nfor i in L2:\n\ti=int(i)\nfor i in L3:\n\ti=int(i)\nn=L1[2]\t\nif min(L2)>=max(L3):\n\tprint(n)\nelse:\n\ta=(int(n)//int(min(L2)))*int(max(L3))+int(n)%int(min(L2))\n\tprint(a)\n\t\n\t"}, {"source_code": "def myfunc(l1):\n return l1[-1]\ndef solution(l1,l2,l3):\n n,m,r = l1[0],l1[1],l1[2]\n l2.sort()\n l3.sort()\n l3.reverse()\n i=0\n ans=r\n while r>0 and i<len(l2) and l3[0]-l2[i]>0:\n if r>l2[i]:\n r-=l2[i]\n ans+=l3[0]-l2[i]\n else:\n i+=1\n return ans\n \ndef answer():\n l1 = [int(x) for x in input().split()]\n l2 = [int(x) for x in input().split()]\n l3 = [int(x) for x in input().split()]\n print(solution(l1,l2,l3))\nanswer()"}, {"source_code": "\n\nfunc=lambda:map(int,input().split())\nn,m,r=func()\nmin1 = min(func())\nmax1 = max(func())\ns = r//min1 * max1 + r%min1\nprint(s)"}, {"source_code": "from sys import stdin,stdout\ni = lambda : map(int,stdin.readline().split())\np = lambda x: stdout.write(str(x)+\" \") \npa = lambda list: stdout.write(\" \".join(str(x) for x in list)) \n\nn,m,r = i()\nb = i()\ns = i()\nbuy = min(b)\nsell = max(b)\nprint sell*(r/buy) + r%buy"}, {"source_code": "n,m,r = [int(i) for i in input().split()]\npok = [int(i) for i in input().split()]\npr = [int(i) for i in input().split()]\npk_m = min(pok)\np_m = max(pr)\nc = r+1\nc =r //pk_m\nr = r%pk_m \nfor j in range(c):\n r+=p_m\nprint(max(c-1,r))"}, {"source_code": "m = list(map(int, input().split()))\nb=list(map(int, input().split()))\ns=list(map(int, input().split()))\n\nmoney = m[-1]\nmin_price = min(b)\nmax_price = max(s)\nmoney_left = 0\nfor i in range(money):\n if money % min_price == 0:\n shares = int(money/min_price)\n break\n else:\n money -= 1\n money_left +=1\n\nprofit = ((shares*max_price)+ money_left)\nif profit > money:\n print(profit)\nelse:\n print(money)\n"}, {"source_code": "\n\nbuy_times, sell_times, cash = list(map(int, input().split()))\nb = list(map(int, input().split()))\ns = list(map(int, input().split()))\n\nif min(b) >= max(s):\n print (cash)\n \nelse:\n top_stocks = cash // min(b) \n profit = 5 * max(s) \n if cash % 2 != 0:\n profit += 1\n print( profit)"}, {"source_code": "n, m, r= map(int, input().split())\ns = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\n#n ,m , r = 3, 4, 11\n#s = [4, 2, 5]\n#b= [4, 4, 5, 4]\n\n\nif min(s)>=max(b):\n print(r)\nelse:\n quantity =[]\n balance = []\n for i in range (n):\n quantity.append(r//s[i])\n balance.append(r%s[i])\n best_quantity =max(quantity)\n best_balance = 0\n for q in range (quantity.count(best_quantity)):\n if best_balance < balance[quantity.index(best_quantity)]:\n best_balance = balance[quantity.index(best_quantity)]\n quantity.insert(quantity.index(best_quantity), 0)\n print(best_quantity*max(b)+best_balance)"}, {"source_code": "N, M, R = map(int, input().split())\n\nb = min(map(int, input().split()))\ns = max(map(int, input().split()))\n\na = R % b + R // b * s\n\nprint(a,0)"}, {"source_code": "n, m, r = [int(t) for t in input().split(' ')]\ns = [int(t) for t in input().split(' ')]\nb = [int(t) for t in input().split(' ')]\nprint(r % min(s) + max(b) * (r // min(s)))\n"}, {"source_code": "def main():\n n=input()\n print(sum(int(x) for x in n.split()))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,m,r = map(int,input().split())\nai = list(map(int,input().split()))\nbi = list(map(int,input().split()))\nif min(ai) >= max(bi):\n print(r)\nelse:\n a = r//min(ai)\n print(a*max(bi) + 1)"}, {"source_code": "m,n,r=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nd=r//min(a)\nif r<=d*(max(b)):\n\tprint(d*(max(b))+r%d)\nelse:\n\tprint(r)"}, {"source_code": "\nn, m, r = (int(x) for x in input().split())\ns = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\n\nmoney = r % min(s)\nnum_stocks = int(r / min(s))\n\nmoney_made = max(b) * num_stocks\nmoney += money_made\nprint(money)\n\n\n\n"}, {"source_code": "n,m,r=map(int,input().split())\ns=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=s[0]\nfor i in range(1,n):\n if (r//c)<(r//s[i]):\n c=s[i]\n\np=r//c\nx=r%c\nif c>min(b):\n print(r)\nelse:\n q=max(b)*p\n print(x+q)\n \n"}, {"source_code": "s = input().split()\nn, m, r = int(s[0]), int(s[1]), int(s[2])\nb = list(map(int, input().split()))\ns = list(map(int, input().split()))\nb_min = min(b)\ns_max = max(s)\nif b_min < s_max:\n print((r // b_min) * s_max)\nelse:\n print(r)\n"}, {"source_code": "nmr=list(int(num) for num in input().split())\nn=list(map(int,input().split()))\nm=list(int(num) for num in input().split())\nminimum_of_buying=min(n)\nmaximum_of_selling=max(m)\nif(minimum_of_buying>maximum_of_selling):\n\tprint(nmr[2])\nelse:\n\tif(len(m)==1):\n\t\ta=maximum_of_selling\n\telse:\n\t\ta=5\n\tprint(nmr[2]+(a*maximum_of_selling)-(minimum_of_buying*a))"}, {"source_code": "d1=(input(\"AAA\"))\nd2=(input(\"AAA\"))\nd3=(input(\"AAA\"))\n\nL1=d1.split()\nL2=d2.split()\nL3=d3.split()\nfor i in L1:\n\ti=int(i)\nfor i in L2:\n\ti=int(i)\nfor i in L3:\n\ti=int(i)\nn=L1[2]\t\nif min(L2)>=max(L3):\n\tprint(n)\nelse:\n\ta=(int(n)//int(min(L2)))*int(max(L3))+int(n)%int(min(L2))\n\tprint(a)\n\t\n\t"}, {"source_code": "a,b,c=[int(x) for x in input().split()]\na1 = list(map(int,input().strip().split()))[:a]\nb1 = list(map(int,input().strip().split()))[:b]\nc1=max(a1)\nc2=min(a1)\nc3=max(b1)\ns=c1*c2\nk=c3*c3\nz=0\nif(s<=k):\n z = c + k-s\nelse:\n z=c+0;\nprint(z)\n"}, {"source_code": "d1=(input(\"AAA\"))\nd2=(input(\"AAA\"))\nd3=(input(\"AAA\"))\n\nL1=d1.split()\nL2=d2.split()\nL3=d3.split()\nfor i in L1:\n\ti=int(i)\nfor i in L2:\n\ti=int(i)\nfor i in L3:\n\ti=int(i)\nn=L1[2]\t\ndef aaa(n,L2,L3):\n\tif min(L2)>=max(L3):\n\t\tprint(int(n))\n\t\treturn n\n\telse:\n\t\ta=(int(n)//int(min(L2)))*int(max(L3))+int(n)%int(min(L2))\n\t\tprint(int(a))\n\treturn a\n\t"}, {"source_code": "n, m, r = map(int, input().split())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nmx = 0\nans = 0\nfor x in a:\n\tans = max(ans, r // x * max(b) + r % x)\nprint(ans)\n"}, {"source_code": "d1=(input(\"AAA\"))\nd2=(input(\"AAA\"))\nd3=(input(\"AAA\"))\n\nL1=d1.split()\nL2=d2.split()\nL3=d3.split()\nfor i in L1:\n\ti=int(i)\nfor i in L2:\n\ti=int(i)\nfor i in L3:\n\ti=int(i)\nn=L1[2]\t\ndef aaa(n,L2,L3):\n\tif min(L2)>=max(L3):\n\t\tprint(int(n))\n\t\treturn n\n\telse:\n\t\ta=(int(n)//int(min(L2)))*int(max(L3))+int(n)%int(min(L2))\n\t\tprint(int(a))\n\treturn a\n\t"}, {"source_code": "from sys import stdin,stdout\ni = lambda : map(int,stdin.readline().split())\np = lambda x: stdout.write(str(x)+\" \") \npa = lambda list: stdout.write(\" \".join(str(x) for x in list)) \n\nn,m,r = i()\nb = i()\ns = i()\nbuy = min(b)\nsell = max(b)\nprint sell*(r/buy) + r%buy"}, {"source_code": "a,b,c=[int(x) for x in input().split()]\na1 = list(map(int,input().strip().split()))[:a]\nb1 = list(map(int,input().strip().split()))[:b]\nc1=max(a1)\nc2=min(a1)\nc3=max(b1)\ns=c1*c2\nk=c3*c3\nz=0\nif(s<=k):\n z = c + k-s\nelse:\n z=c+0;\nprint(z)\n"}, {"source_code": "nmr=list(int(num) for num in input().split())\nn=list(map(int,input().split()))\nm=list(int(num) for num in input().split())\nminimum_of_buying=min(n)\nmaximum_of_selling=max(m)\nif(minimum_of_buying>maximum_of_selling):\n\tprint(nmr[2])\nelse:\n\tprint(nmr[2]+(5*maximum_of_selling)-(5*minimum_of_buying))"}, {"source_code": "n,m,k = input().split(' ')\nn = int(n)\nm = int(m)\nk = int(k)\na = list(map(int,input().split(' ')))\nb = list(map(int,input().split(' ')))\n\naa = min(a)\nbb = max(b)\n\ncnt = k // aa\nr = k % aa\n#print(cnt,bb)\nbuy = cnt * bb\n\nif buy > k-r:\n print((bb * cnt) + r)\nelse:\n print(r)"}, {"source_code": "n,m,k = input().split(' ')\nn = int(n)\nm = int(m)\nk = int(k)\na = list(map(int,input().split(' ')))\nb = list(map(int,input().split(' ')))\n\naa = min(a)\nbb = max(b)\n\ncnt = k // aa\nr = k % aa\nprint(cnt,bb)\nbuy = cnt * bb\n\nif buy > k-r:\n print((bb * cnt) + r)\nelse:\n print(r)"}, {"source_code": "n, m, r = map(int,input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na.sort()\nb.sort()\nif a[0] < b[m-1]:\n if a[0] > r:\n print('0')\n else:\n rr = r//a[0]\n rro = r%a[0]\n rr = rr * b[m-1]\n print(rr+rro)\nelse:\n print(r)"}, {"source_code": "n,m,r = map(int,input().split(' '))\ns1 =list( map(int,input().split(' ')))\ns2 =list( map(int,input().split(' ')))\nif(max(s2)>=max(s1)):\n min_s = min(s1)\n q = r//min_s\n r = r-min_s*q\n r += max(s2)*q\n print(r)\nelse:\n print(r)"}, {"source_code": "n,m,r=map(int,input().split())\nl=list(map(int,input().split()))\nll=list(map(int,input().split()))\nprint((r//min(l))*max(ll)+(r%min(l)))"}, {"source_code": "from sys import stdin,stdout\ni = lambda : map(int,stdin.readline().split())\np = lambda x: stdout.write(str(x)+\" \") \npa = lambda list: stdout.write(\" \".join(str(x) for x in list)) \n\nn,m,r = i()\nb = i()\ns = i()\nbuy = min(b)\nsell = max(b)\nprint sell*(r/buy) + r%buy"}, {"source_code": "N, M, R = map(int, input().split())\n\nb = min(map(int, input().split()))\ns = max(map(int, input().split()))\n\na = R % b + R // b * s\n\nprint(a,0)"}, {"source_code": "d1=(input(\"\"))\nd2=(input(\"\"))\nd3=(input(\"\"))\n\nL1=d1.split()\nL2=d2.split()\nL3=d3.split()\nfor i in L1:\n\ti=int(i)\nfor i in L2:\n\ti=int(i)\nfor i in L3:\n\ti=int(i)\nn=L1[2]\t\n\nif min(L2)>=max(L3):\n\t\tprint(int(n))\n\nelse:\n\t\ta=(int(n)//int(min(L2)))*int(max(L3))+int(n)%int(min(L2))\n\t\tprint(int(a))\n\t"}, {"source_code": "n, m, r = map(int, input().split())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nmx = 0\nans = 0\nfor x in a:\n\tans = max(ans, r // x * max(b) + r % x)\nprint(ans)\n"}, {"source_code": "n1,n2,k = map(int, input().split())\nm = map(int, input().split())\ne = map(int, input().split())\nmi = min(m)\nma = max(e)\nn = k//mi\nleft = k%mi\nprint((ma-mi)*n + left)"}, {"source_code": "valores = input()\nvalores = valores.split(' ')\nr = int(valores[-1])\n\nn = input()\nn = n.split(' ')\nfor i in range(len(n)):\n n[i] = int(n[i])\n\nm = input()\nm = m.split(' ')\nfor i in range(len(m)):\n m[i] = int(m[i])\n\nif min(n) > max(m):\n\tprint(r)\nelif min(n) < max(m):\n\tprint(r-((r//min(n))*min(n))+((r//min(n))*(max(m))))"}, {"source_code": "def share():\n n, m, r = [int(x) for x in input().split()]\n s = []\n b = []\n for i in input().split():\n s.append(int(i))\n for i in input().split():\n b.append(int(i))\n s = min(s) \n b = max(b)\n ac = r // s\n rr = r % s\n result = ac * b + rr\n return print( max(result, r))"}, {"source_code": "def main():\n n=input()\n print(sum(int(x) for x in n.split()))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "d1=(input(\"\"))\nd2=(input(\"\"))\nd3=(input(\"\"))\n\nL1=d1.split()\nL2=d2.split()\nL3=d3.split()\nfor i in L1:\n\ti=int(i)\nfor i in L2:\n\ti=int(i)\nfor i in L3:\n\ti=int(i)\nn=L1[2]\t\n\nif min(L2)>=max(L3):\n\t\tprint(int(n))\n\nelse:\n\t\ta=(int(n)//int(min(L2)))*int(max(L3))+int(n)%int(min(L2))\n\t\tprint(int(a))\n\t"}, {"source_code": "[n, m, r] = list(map(int, input().split(\" \")))\ns = list(map(int, input().split(\" \")))\nb = list(map(int, input().split(\" \")))\n\nr = r % min(s) + (r // min(s))*max(b)\nprint(r)\n"}, {"source_code": "def share():\n n, m, r = [int(x) for x in input().split()]\n s = []\n b = []\n for i in input().split():\n s.append(int(i))\n for i in input().split():\n b.append(int(i))\n s = min(s) \n b = max(b)\n ac = r // s\n rr = r % s\n result = ac * b + rr\n res = max(result, r)\n return print(res)"}, {"source_code": "morning, evening, roubles=map(int, input().split())\nbuy=list(map(int, input().split()))\nsell=list(map(int, input().split()))\n\nmb=min(buy);b=roubles//mb\nms=max(sell);s=b*ms\n\nif s>roubles:\n\tprint(s+(roubles-(mb*b)))\nelse:\n\tprint(roubles)"}, {"source_code": "s = input().split()\nn, m, r = int(s[0]), int(s[1]), int(s[2])\nb = list(map(int, input().split()))\ns = list(map(int, input().split()))\nb_min = min(b)\ns_max = max(s)\nif b_min < s_max:\n print((r // b_min) * s_max)\nelse:\n print(r)\n"}, {"source_code": "nmr=list(int(num) for num in input().split())\nn=list(map(int,input().split()))\nm=list(int(num) for num in input().split())\nminimum_of_buying=min(n)\nmaximum_of_selling=max(m)\nprint(nmr[2])\nprint(minimum_of_buying)\nprint(maximum_of_selling)\nif(minimum_of_buying>maximum_of_selling):\n\tprint(nmr[2])\nelse:\n\ty=int(nmr[2]/minimum_of_buying)\n\tprint(y)\n\tprint(nmr[2]-(minimum_of_buying*y)+(maximum_of_selling*y))"}, {"source_code": "n,m,r=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split() ))\nx=min(a)\ny=max(b)\nif(x>=y):\n print(r)\nelse:\n print((r//x)*y)\n\n"}, {"source_code": "a=input().split()\nb=input().split()\ns=input().split()\nmaanie=int(a[2])\nbuy=int(min(b))\nsell=int(max(s))\nif buy<sell:\n maanie+=maanie//buy*(sell-buy)\nprint(maanie)\n"}, {"source_code": "n,m,r=map(int,input().split())\nbuy=list(map(int,input().split()))\nsell=list(map(int,input().split()))\nx=(r//min(buy))\nleft=r-(x*(min(buy)))\ny=max(sell)*x\nif y>r:\n\tprint(y+left)\nelse:\n\tprint(r)"}, {"source_code": "n,m,r=map(int,input().split())\narr=list(map(int,input().split()))\narrb=list(map(int,input().split()))\narr.sort()\narrb.sort()\nif(arr[0]>=arrb[m-1]):\n print(arr[0])\nelse:\n buy=r//arr[0]\n r=r-(buy*arr[0])\n r=r+buy*(arrb[m-1])\n print(r)\n"}], "src_uid": "42f25d492bddc12d3d89d39315d63cb9"} {"source_code": "def solve(n, st, k):\n MOD = int(1e9 + 7)\n dp = [0] * (n + 1)\n prefix_sum = [0] * (n + 1)\n dp[st] = 1\n for times in range(k):\n prefix_sum[0] = 0\n for i in range(1, n + 1):\n prefix_sum[i] = prefix_sum[i - 1] + dp[i]\n if prefix_sum[i] >= MOD: prefix_sum[i] -= MOD\n for i in range(1, n + 1):\n t = prefix_sum[n] - prefix_sum[i] + prefix_sum[i - 1] - prefix_sum[i >> 1]\n while t < 0: t += MOD\n while t >= MOD: t -= MOD\n dp[i] = t\n return sum(dp) % MOD\n \n\ndef main():\n n, a, b, k = [int(i) for i in input().split()]\n if a > b:\n print(solve(n - b, a - b, k))\n else:\n print(solve(b - 1, b - a, k))\n \nmain()\n", "positive_code": [{"source_code": "# -*- coding:utf-8 -*-\n\n\"\"\"\n\ncreated by shuangquan.huang at 1/17/20\n\n\"\"\"\n\nimport collections\nimport time\nimport os\nimport sys\nimport bisect\nimport heapq\nfrom typing import List\n\n\ndef solve(N, A, B, K):\n MOD = 1000000007\n \n dp = [0 for _ in range(N+1)]\n dp[A] = 1\n for k in range(1, K+1):\n ndp = [0 for _ in range(N+1)]\n for x in range(1, N+1):\n d = abs(x-B)\n if d <= 1:\n continue\n l, r = max(x-d+1, 1), min(x+d, N+1)\n if l < x:\n ndp[l] = (ndp[l] + dp[x]) % MOD\n ndp[x] = (ndp[x] - dp[x]) % MOD\n if x < r:\n if x + 1 <= N:\n ndp[x+1] = (ndp[x+1] + dp[x]) % MOD\n if r <= N:\n ndp[r] = (ndp[r] - dp[x]) % MOD\n \n v = 0\n for x in range(N+1):\n v += ndp[x]\n v %= MOD\n ndp[x] = v\n \n dp = ndp\n \n return sum(dp) % MOD\n\n\nN, A, B, K = map(int, input().split())\nprint(solve(N, A, B, K))"}, {"source_code": "def solve(n, st, k):\n MOD = int(1e9 + 7)\n prev = [0] * (n + 1)\n current = [0] * (n + 1)\n prefix_sum = [0] * (n + 1)\n prev[st] = 1\n for times in range(k):\n prefix_sum[0] = 0\n for i in range(1, n + 1):\n prefix_sum[i] = prefix_sum[i - 1] + prev[i]\n if prefix_sum[i] >= MOD:\n prefix_sum[i] -= MOD\n for i in range(1, n + 1):\n current[i] = prefix_sum[n] - prefix_sum[i >> 1] - prev[i]\n while current[i] < 0: current[i] += MOD\n while current[i] >= MOD: current[i] -= MOD\n prev, current = current, prev\n return sum(prev) % MOD\n \n\ndef main():\n n, a, b, k = [int(i) for i in input().split()]\n if a > b:\n print(solve(n - b, a - b, k))\n else:\n print(solve(b - 1, b - a, k))\n \nmain()\n"}, {"source_code": "def solve(n, st, k):\n MOD = int(1e9 + 7)\n dp = [0] * (n + 1)\n prefix_sum = [0] * (n + 1)\n dp[st] = 1\n for times in range(k):\n prefix_sum[0] = 0\n for i in range(1, n + 1):\n prefix_sum[i] = prefix_sum[i - 1] + dp[i]\n if prefix_sum[i] >= MOD: prefix_sum[i] -= MOD\n for i in range(1, n + 1):\n dp[i] = prefix_sum[n] - dp[i] - prefix_sum[i >> 1]\n while dp[i] < 0: dp[i] += MOD\n while dp[i] >= MOD: dp[i] -= MOD\n return sum(dp) % MOD\n \n\ndef main():\n n, a, b, k = [int(i) for i in input().split()]\n if a > b:\n print(solve(n - b, a - b, k))\n else:\n print(solve(b - 1, b - a, k))\n \nmain()\n"}, {"source_code": "def solve(n, st, k):\n MOD = int(1e9 + 7)\n dp = [0] * (n + 1)\n prefix_sum = [0] * (n + 1)\n dp[st] = 1\n for times in range(k):\n prefix_sum[0] = 0\n for i in range(1, n + 1):\n prefix_sum[i] = prefix_sum[i - 1] + dp[i]\n if prefix_sum[i] >= MOD: prefix_sum[i] -= MOD\n for i in range(1, n + 1):\n dp[i] = prefix_sum[n] - prefix_sum[i] + prefix_sum[i - 1] - prefix_sum[i >> 1]\n while dp[i] < 0: dp[i] += MOD\n while dp[i] >= MOD: dp[i] -= MOD\n return sum(dp) % MOD\n \n\ndef main():\n n, a, b, k = [int(i) for i in input().split()]\n if a > b:\n print(solve(n - b, a - b, k))\n else:\n print(solve(b - 1, b - a, k))\n \nmain()\n"}, {"source_code": "n,a,b,k=map(int,input().split())\ndp=[[0 for i in range(n+2)] for j in range(2)]\ndp[0][a]=1\nnow=1\nlast=0\nmod=1000000007\nfor i in range(k):\n for j in range(1,n+1):\n d=max(abs(j-b)-1,0)\n if j!=n:\n dp[now][j+1]=(dp[last][j]%mod+dp[now][j+1]%mod)%mod\n dp[now][min(j+d+1,n+1)]=(dp[now][min(j+d+1,n+1)]-dp[last][j])%mod\n if j!=1:\n dp[now][j]=(dp[now][j]-dp[last][j])%mod\n dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]%mod+dp[last][j]%mod)%mod\n for i1 in range(1,n+2):\n dp[now][i1]=(dp[now][i1]+dp[now][i1-1])%mod\n dp[last][i1]=0\n aux=now\n now=last\n last=aux\nprint(sum(dp[last])%mod)\n"}, {"source_code": "#!/usr/bin/env python3\nimport io\nimport os\nimport sys\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef printd(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n #print(*args, **kwargs)\n pass\n\ndef get_str():\n return input().decode().strip()\n\ndef rint():\n return map(int, input().split())\n\ndef oint():\n return int(input())\n\nmod = 1000000007\nn, a, b, k = rint()\nif a > b:\n a, b = n-a+1, n-b+1\na -= 1\nb -= 1\nprintd(n, a, b, k)\n\nd = [0]*n\nd[a] = 1\nps = [0]*b\nps[0] = d[0]\nfor j in range(1, b):\n ps[j] = ps[j-1]+d[j]\n ps[j] %= mod\n while ps[j] > mod:\n ps[j] -= mod\nprintd(n, a, b, k)\nprintd(d, ps)\nfor i in range(k):\n for j in range(b):\n #b-t > t-j\n #2*t < b+j\n #t < (b+j)/2\n if (b+j)%2:\n t = (b+j)//2\n else:\n t = (b+j)//2 - 1\n if j == 0:\n d[j] = ps[t] - ps[j]\n else:\n d[j] = ps[t] - ps[j] + ps[j-1]\n d[j] %= mod\n while d[j] > mod:\n d[j] -= mod\n while d[j] <0:\n d[j] += mod\n #d[j] %=mod\n ps[0] = d[0]\n for j in range(1, b):\n ps[j] = (ps[j-1]+d[j])# %mod\n ps[j] %= mod\n while ps[j] > mod:\n ps[j] -= mod\n while ps[j] < 0:\n ps[j] += mod\n printd(d,ps)\nans = ps[b-1]\nprint(ans%mod)\n"}, {"source_code": "def solve(n, st, k):\n MOD = int(1e9 + 7)\n dp = [0] * (n + 1)\n prefix_sum = [0] * (n + 1)\n dp[st] = 1\n for times in range(k):\n prefix_sum[0] = 0\n for i in range(1, n + 1):\n prefix_sum[i] = prefix_sum[i - 1] + dp[i]\n if prefix_sum[i] >= MOD: prefix_sum[i] -= MOD\n for i in range(1, n + 1):\n t = prefix_sum[n] - prefix_sum[i] + prefix_sum[i - 1] - prefix_sum[i >> 1]\n while t < 0: t += MOD\n while t >= MOD: t -= MOD\n dp[i] = t\n return sum(dp) % MOD\n \n \ndef main():\n n, a, b, k = [int(i) for i in input().split()]\n if a > b:\n print(solve(n - b, a - b, k))\n else:\n print(solve(b - 1, b - a, k))\n \nmain()"}, {"source_code": "#!/usr/bin/env python3\nimport io\nimport os\nimport sys\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef printd(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n #print(*args, **kwargs)\n pass\n\ndef get_str():\n return input().decode().strip()\n\ndef rint():\n return map(int, input().split())\n\ndef oint():\n return int(input())\n\nmod = 1000000007\nn, a, b, k = rint()\nif a > b:\n a, b = n-a+1, n-b+1\na -= 1\nb -= 1\nprintd(n, a, b, k)\n\nd = [0]*n\nd[a] = 1\nps = [0]*b\nps[0] = d[0]\nfor j in range(1, b):\n ps[j] = ps[j-1]+d[j]\n ps[j] %= mod\nprintd(n, a, b, k)\nprintd(d, ps)\nfor i in range(k):\n for j in range(b):\n #b-t > t-j\n #2*t < b+j\n #t < (b+j)/2\n if (b+j)%2:\n t = (b+j)//2\n else:\n t = (b+j)//2 - 1\n if j == 0:\n d[j] = ps[t] - ps[j]\n else:\n d[j] = ps[t] - ps[j] + ps[j-1]\n d[j] %= mod\n #d[j] %=mod\n ps[0] = d[0]\n for j in range(1, b):\n ps[j] = (ps[j-1]+d[j])# %mod\n ps[j] %= mod\n printd(d,ps)\nans = ps[b-1]\nprint(ans%mod)\n"}, {"source_code": "#!/usr/bin/env python3\nimport io\nimport os\nimport sys\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef printd(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n #print(*args, **kwargs)\n pass\n\ndef get_str():\n return input().decode().strip()\n\ndef rint():\n return map(int, input().split())\n\ndef oint():\n return int(input())\n\nmod = 1000000007\nn, a, b, k = rint()\nif a > b:\n a, b = n-a+1, n-b+1\na -= 1\nb -= 1\nprintd(n, a, b, k)\n\nd = [0]*n\nd[a] = 1\nps = [0]*b\nps[0] = d[0]\nfor j in range(1, b):\n ps[j] = ps[j-1]+d[j]\n while ps[j] > mod:\n ps[j] -= mod\nprintd(n, a, b, k)\nprintd(d, ps)\nfor i in range(k):\n for j in range(b):\n #b-t > t-j\n #2*t < b+j\n #t < (b+j)/2\n if (b+j)%2:\n t = (b+j)//2\n else:\n t = (b+j)//2 - 1\n if j == 0:\n d[j] = ps[t] - ps[j]\n else:\n d[j] = ps[t] - ps[j] + ps[j-1]\n while d[j] > mod:\n d[j] -= mod\n while d[j] <0:\n d[j] += mod\n #d[j] %=mod\n ps[0] = d[0]\n for j in range(1, b):\n ps[j] = (ps[j-1]+d[j])# %mod\n while ps[j] > mod:\n ps[j] -= mod\n while ps[j] < 0:\n ps[j] += mod\n printd(d,ps)\nans = ps[b-1]\nprint(ans%mod)\n"}, {"source_code": "#!/usr/bin/env python3\nimport io\nimport os\nimport sys\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef printd(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n #print(*args, **kwargs)\n pass\n\ndef get_str():\n return input().decode().strip()\n\ndef rint():\n return map(int, input().split())\n\ndef oint():\n return int(input())\n\nmod = 1000000007\nn, a, b, k = rint()\nif a > b:\n a, b = n-a+1, n-b+1\na -= 1\nb -= 1\nprintd(n, a, b, k)\n\nd = [0]*n\nd[a] = 1\nps = [0]*b\nps[0] = d[0]\nfor j in range(1, b):\n ps[j] = ps[j-1]+d[j]\n while ps[j] > mod:\n ps[j] -= mod\n ps[j] %= mod\nprintd(n, a, b, k)\nprintd(d, ps)\nfor i in range(k):\n for j in range(b):\n #b-t > t-j\n #2*t < b+j\n #t < (b+j)/2\n if (b+j)%2:\n t = (b+j)//2\n else:\n t = (b+j)//2 - 1\n if j == 0:\n d[j] = ps[t] - ps[j]\n else:\n d[j] = ps[t] - ps[j] + ps[j-1]\n while d[j] > mod:\n d[j] -= mod\n while d[j] <0:\n d[j] += mod\n d[j] %= mod\n #d[j] %=mod\n ps[0] = d[0]\n for j in range(1, b):\n ps[j] = (ps[j-1]+d[j])# %mod\n while ps[j] > mod:\n ps[j] -= mod\n while ps[j] < 0:\n ps[j] += mod\n ps[j] %= mod\n printd(d,ps)\nans = ps[b-1]\nprint(ans%mod)\n"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter, defaultdict\nfrom itertools import permutations, combinations\nraw_input = stdin.readline\npr = stdout.write\n\n\ndef in_num():\n return int(raw_input())\n\n\ndef in_arr():\n return map(int,raw_input().split())\n\n\ndef pr_num(n):\n stdout.write(str(n)+'\\n')\n\n\ndef pr_arr(arr):\n pr(' '.join(map(str,arr))+'\\n')\n\n# fast read function for total integer input\n\ndef inp():\n # this function returns whole input of\n # space/line seperated integers\n # Use Ctrl+D to flush stdin.\n return map(int,stdin.read().split())\n\nrange = xrange # not for python 3.0+\nmod=10**9+7\nn,a,b,k=in_arr()\ndp=[[0 for i in range(n+1)] for j in range(k+1)]\ndp[0][a-1]=1\ndp[0][a]=(-1)%mod\nb-=1\nfor i in range(k):\n temp=0\n for j in range(n):\n temp=(temp+dp[i][j])%mod\n \n x=int(abs(b-j))\n x-=1\n if x<=0:\n continue\n dp[i+1][max(0,j-x)]=(dp[i+1][max(0,j-x)]+temp)%mod\n dp[i+1][min(n,j+x+1)]=(dp[i+1][min(n,j+x+1)]-temp)%mod\n dp[i+1][j]=(dp[i+1][j]-temp)%mod\n dp[i+1][j+1]=(dp[i+1][j+1]+temp)%mod\n \nans=0\ntemp=0\nfor i in range(n):\n temp+=dp[k][i]\n temp%=mod\n ans+=temp\n ans%=mod\npr_num(ans)\n\n \n"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter, defaultdict\nfrom itertools import permutations, combinations\nraw_input = stdin.readline\npr = stdout.write\n\n\ndef in_num():\n return int(raw_input())\n\n\ndef in_arr():\n return map(int,raw_input().split())\n\n\ndef pr_num(n):\n stdout.write(str(n)+'\\n')\n\n\ndef pr_arr(arr):\n pr(' '.join(map(str,arr))+'\\n')\n\n# fast read function for total integer input\n\ndef inp():\n # this function returns whole input of\n # space/line seperated integers\n # Use Ctrl+D to flush stdin.\n return map(int,stdin.read().split())\n\nrange = xrange # not for python 3.0+\nmod=10**9+7\nn,a,b,k=in_arr()\ndp=[[0 for i in range(n+1)] for j in range(k+1)]\ndp[0][a-1]=1\ndp[0][a]=(-1)%mod\nb-=1\nfor i in range(k):\n temp=0\n for j in range(n+1):\n temp=(temp+dp[i][j])%mod\n \n if i and int(abs(b-j))>1:\n temp-=dp[i-1][j]\n temp%=mod\n dp[i][j]=temp\n if j<n:\n x=int(abs(b-j))\n x-=1\n if x<=0:\n continue\n dp[i+1][max(0,j-x)]=(dp[i+1][max(0,j-x)]+temp)%mod\n dp[i+1][min(n,j+x+1)]=(dp[i+1][min(n,j+x+1)]-temp)%mod\n #dp[i+1][j]=(dp[i+1][j]-1)%mod\n #dp[i+1][j+1]=(dp[i+1][j+1]+1)%mod\n if i and int(abs(b-j))>1:\n temp+=dp[i-1][j]\n temp%=mod\n\nans=0\ntemp=0\nfor i in range(n):\n temp+=dp[k][i]\n temp%=mod\n if int(abs(i-b))>1:\n temp-=dp[k-1][i]\n temp%=mod\n ans+=temp\n ans%=mod\n \n if int(abs(i-b))>1:\n temp+=dp[k-1][i]\n temp%=mod\npr_num(ans)\n\n \n"}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin\n\nMOD = int(1e9)+7\n\n\ndef solve(tc):\n n, a, b, k = map(int, stdin.readline().split())\n\n dp = [1 for i in range(n+1)]\n dp[b] = 0\n prefix = [1 for i in range(n+1)]\n for i in range(k):\n for j in range(1, n+1):\n prefix[j] = prefix[j-1] + dp[j]\n prefix[j] %= MOD\n\n for j in range(1, b-1):\n dist = b - j\n start = max(0, j-dist)\n end = min(b-1, j+dist-1)\n dp[j] = prefix[j-1] - prefix[start]\n if dp[j] < 0:\n dp[j] += MOD\n dp[j] %= MOD\n dp[j] += prefix[end] - prefix[j]\n if dp[j] < 0:\n dp[j] += MOD\n dp[j] %= MOD\n\n dp[b-1] = dp[b] = 0\n if b+1 <= n:\n dp[b+1] = 0\n\n for j in range(b+2, n+1):\n dist = j - b\n start = max(b, j-dist)\n end = min(n, j+dist-1)\n dp[j] = prefix[j-1] - prefix[start]\n if dp[j] < 0:\n dp[j] += MOD\n dp[j] %= MOD\n dp[j] += prefix[end] - prefix[j]\n if dp[j] < 0:\n dp[j] += MOD\n dp[j] %= MOD\n\n print(dp[a])\n\n\ntc = 1\nsolve(tc)\n"}, {"source_code": "n,a,b,k=map(int,input().split())\ndp=[[0 for i in range(n+2)] for j in range(2)]\ndp[0][a]=1\nnow=1\nlast=0\nmod=1000000007\nfor i in range(k):\n for j in range(1,n+1):\n d=max(abs(j-b)-1,0)\n if j!=n:\n dp[now][j+1]=(dp[last][j]+dp[now][j+1])%mod\n dp[now][min(j+d+1,n+1)]=(dp[now][min(j+d+1,n+1)]-dp[last][j])%mod\n if j!=1:\n dp[now][j]=(dp[now][j]-dp[last][j])%mod\n dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]+dp[last][j])%mod\n for i1 in range(1,n+2):\n dp[now][i1]=(dp[now][i1]+dp[now][i1-1])%mod\n dp[last][i1]=0\n aux=now\n now=last\n last=aux\nprint(sum(dp[last])%mod)\n"}], "negative_code": [{"source_code": "from sys import stdin, stdout\nfrom collections import Counter, defaultdict\nfrom itertools import permutations, combinations\nraw_input = stdin.readline\npr = stdout.write\n\n\ndef in_num():\n return int(raw_input())\n\n\ndef in_arr():\n return map(int,raw_input().split())\n\n\ndef pr_num(n):\n stdout.write(str(n)+'\\n')\n\n\ndef pr_arr(arr):\n pr(' '.join(map(str,arr))+'\\n')\n\n# fast read function for total integer input\n\ndef inp():\n # this function returns whole input of\n # space/line seperated integers\n # Use Ctrl+D to flush stdin.\n return map(int,stdin.read().split())\n\nrange = xrange # not for python 3.0+\nmod=10**9+7\nn,a,b,k=in_arr()\ndp=[[0 for i in range(n+1)] for j in range(k+1)]\ndp[0][a-1]=1\ndp[0][a]=-1\nb-=1\nfor i in range(k):\n temp=0\n for j in range(n+1):\n temp=(temp+dp[i][j])%mod\n if i and int(abs(b-j))>1:\n temp-=dp[i-1][j]\n temp%=mod\n if j<n:\n x=int(abs(b-j))\n x-=1\n if x<=0:\n continue\n dp[i+1][max(0,j-x)]=(dp[i+1][max(0,j-x)]+temp)%mod\n dp[i+1][min(n,j+x+1)]=(dp[i+1][min(n,j+x+1)]-temp)%mod\n #dp[i+1][j]=(dp[i+1][j]-1)%mod\n #dp[i+1][j+1]=(dp[i+1][j+1]+1)%mod\n if i and int(abs(b-j))>1:\n temp+=dp[i-1][j]\n temp%=mod\n\nans=0\ntemp=0\nfor i in range(n):\n temp+=dp[k][i]\n temp%=mod\n if int(abs(i-b))>1:\n temp-=dp[k-1][i]\n temp%=mod\n ans+=temp\n ans%=mod\n \n if int(abs(i-b))>1:\n temp+=dp[k-1][i]\n temp%=mod\npr_num(ans)\n\n \n"}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin\n\nMOD = int(1e9)+7\n\n\ndef solve(tc):\n n, a, b, k = map(int, stdin.readline().split())\n\n dp = [1 for i in range(n+1)]\n dp[b] = 0\n prefix = [1 for i in range(n+1)]\n for i in range(k):\n for j in range(1, n+1):\n prefix[j] = prefix[j-1] + dp[j]\n prefix[j] %= MOD\n\n for j in range(1, b-1):\n dist = b - j\n start = max(0, j-dist)\n end = min(b-1, j+dist)\n dp[j] = prefix[j-1] - prefix[start] + MOD\n dp[j] %= MOD\n dp[j] += prefix[end] - prefix[j] + MOD\n dp[j] %= MOD\n\n dp[b-1] = dp[b] = 0\n if b+1<=n:\n dp[b+1] = 0\n\n for j in range(b+2, n+1):\n dist = j - b\n start = max(b, j-dist)\n end = min(n, j+dist)\n dp[j] = prefix[j-1] - prefix[start] + MOD\n dp[j] %= MOD\n dp[j] = prefix[end] - prefix[j] + MOD\n dp[j] %= MOD\n\n print(dp[a])\n\n\ntc = 1\nsolve(tc)\n"}, {"source_code": "n,a,b,k=map(int,input().split())\ndp=[[0 for i in range(n+1)] for j in range(2)]\ndp[0][a]=1\nnow=1\nlast=0\nmod=1000000007\nfor i in range(k):\n for j in range(1,n+1):\n d=max(abs(j-b)-1,0)\n if j!=n:\n dp[now][j+1]=(dp[last][j]+dp[now][j+1])%mod\n dp[now][min(j+d+1,n)]=(dp[now][min(j+d+1,n)]-dp[last][j])%mod\n if j!=1:\n dp[now][j]=(dp[now][j]-dp[last][j])%mod\n dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]+dp[last][j])%mod\n for i1 in range(1,n+1):\n dp[now][i1]=(dp[now][i1]+dp[now][i1-1])%mod\n dp[last][i1]=0\n aux=now\n now=last\n last=aux\nprint(sum(dp[last])%mod)\n"}, {"source_code": "n,a,b,k=map(int,input().split())\ndp=[[0 for i in range(n+1)] for j in range(a)]\ndp[0][a]=1\nnow=1\nlast=0\nmod=1000000007\nfor i in range(k):\n for j in range(1,n+1):\n d=abs(j-b)-1\n if j!=n:\n dp[now][j+1]=(dp[last][j]+dp[now][j+1])%mod\n dp[now][min(j+d+1,n)]=(dp[now][min(j+d+1,n)]+dp[last][j])%mod\n if j!=1:\n dp[now][j]=(dp[now][j]-dp[last][j])%mod\n dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]+dp[last][j])%mod\n for i in range(1,n+1):\n dp[now][i]=(dp[now][i]+dp[now][i-1])%mod\n dp[last][i]=0\n aux=now\n now=last\n last=aux\nprint(sum(dp[last])%mod)"}, {"source_code": "#!/usr/bin/env python3\nimport io\nimport os\nimport sys\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef printd(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n #print(*args, **kwargs)\n pass\n\ndef get_str():\n return input().decode().strip()\n\ndef rint():\n return map(int, input().split())\n\ndef oint():\n return int(input())\n\nmod = 1000000007\nn, a, b, k = rint()\na -= 1\nb -= 1\n\nd = [0]*n\nd[a] = 1\nps = [0]*n\nps[0] = d[0]\nfor j in range(1, n):\n ps[j] = ps[j-1]+d[j]\nprintd(n, a, b, k)\nprintd(d, ps)\nfor i in range(k):\n d = [0]*n\n for j in range(1, b):\n d[j] = ps[j-1]\n for j in range(b):\n #b-t > t-j\n #2*t < b+j\n #t < (b+j)/2\n if (b+j)%2:\n t = (b+j)//2\n else:\n t = (b+j)//2 - 1\n d[j] += ps[t] - ps[j]\n ps = [0]*n\n ps[0] = d[0]\n for j in range(1, n):\n ps[j] = (ps[j-1]+d[j])%mod\n printd(d,ps)\n\nprint(ps[n-1]%mod)\n"}], "src_uid": "142b06ed43b3473513995de995e19fc3"} {"source_code": "from math import ceil\n\nX, i, Found, Sum = [ceil(i / 2) for i in map(int, input().split())], 2, False, 0\nMax = max(X)\nwhile i >= 0:\n if X[i] == max(X):\n Found = True\n Sum += (Max - 1 if not Found else Max)\n i -= 1\nprint(Sum + 29)\n\n# UB_CodeForces\n# Advice: Keep an eye on your goals\n# Location: At home next to a cup of thyme tea\n# Caption: I expect more from CodeForcesians\n", "positive_code": [{"source_code": "import sys\nimport itertools\nimport math\n\ndef is_empty(nums):\n for i in nums:\n if i > 0:\n return False\n return True\n \nlines = [i.rstrip() for i in sys.stdin.readlines()]\nnums = [int(i) for i in lines[0].split(\" \")]\nc = 0\n\nwhile (not is_empty(nums)):\n for i in range(len(nums)):\n if (is_empty(nums)):\n break\n nums[i] = nums[i] - 2\n c += 1\nprint c - 1 + 30\n \n"}, {"source_code": "students = map(int, raw_input().split())\nt = 0\nwhile True:\n students[t % 3] = max(students[t % 3] - 2, 0)\n if max(students) == 0:\n break\n t += 1\nprint str(t + 30)"}, {"source_code": "\n\n\nr, g, b = map(int, input().split())\n\n\nprint(max([((r+1)//2 - 1) * 3, ((g+1)//2 - 1) * 3 + 1, ((b+1)//2 - 1) *\n 3 + 2]) + 30)\n\n\n\n\n"}, {"source_code": "inp = map(int, raw_input().split())\ni = 0\ncnt = 30\nwhile 1:\n inp[i] -= 2\n if True in map(lambda x:x > 0, inp):\n cnt += 1\n i = (i+1)%3\n continue\n print cnt\n break\n"}, {"source_code": "#!/usr/bin/python2\n#-*- coding: utf-8 -*-\n\nimport sys,math\n\n#ret = raw_input()\n#ret = ret.split(' ')\n\n#text = raw_input().rstrip()\n\n#znak = sys.stdin.read(1) \n\n#pole=[[]*n for r in xrange(n)]\n\nr,g,b = map(int,raw_input().split())\n\nminuta = 0\nwhile r > 0 or g > 0 or b > 0 :\n if minuta % 3 == 0 :\n r -= 2\n if minuta % 3 == 1 :\n g -= 2\n if minuta % 3 == 2 :\n b -= 2\n minuta += 1\nprint minuta+29\n\n\n"}, {"source_code": "from math import ceil\n\n[R,G,B] = [3*(ceil(int(i)/2)-1) for i in input().split()]\n\nprint(30 + max(R, G+1, B+2))\n"}, {"source_code": "from math import ceil\ns=raw_input().split()\nr=int(ceil(int(s[0])/2.0))-1\ng=int(ceil(int(s[1])/2.0))-1\nb=int(ceil(int(s[2])/2.0))-1\n\nprint max(r*3,g*3+1,b*3+2)+30\n"}, {"source_code": "r,g,b = map(int,raw_input().split())\n\nminu = 29\n\nwhile(True):\n\n\tif r < 1 and g <1 and b < 1:\n\t\tbreak\n\t\n\tminu = minu + 1\n\tif r > 1:\n\t\tr = r - 2\n\telif r > 0:\n\t\tr = r - 1\n\t\t\n\t\n\tif r < 1 and g <1 and b < 1:\n\t\tbreak\n\t\n\tminu = minu + 1\n\tif g > 1:\n\t\tg = g - 2\n\telif g > 0:\n\t\tg = g-1\n\n\t\n\tif r < 1 and g <1 and b < 1:\n\t\tbreak\n\t\n\tminu = minu + 1\n\tif b > 1:\n\t\tb = b -2\n\telif b > 0:\n\t\tb = b -1\n\n\nprint minu\n\n\n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\nss = map(int,raw_input().split(' '))\n\ncnt = 30\nidx = 0\nwhile(ss!=[0,0,0]):\n ss[idx] = max([0,ss[idx]-2])\n idx = (idx+1) % 3\n cnt += 1\nprint cnt - 1\n"}, {"source_code": "(r, g, b) = [int(x) for x in raw_input().split()]\n\nr = (r + 1) / 2 * 3 - 3\ng = (g + 1) / 2 * 3 - 2\nb = (b + 1) / 2 * 3 - 1\n\nprint 30 + max(0, r, g, b)\n"}, {"source_code": "r,g,b = [int(rgb) for rgb in raw_input().split(\" \")]\nr = 30+3*(((r+1)/2)-1)\ng = 31+3*(((g+1)/2)-1)\nb = 32+3*(((b+1)/2)-1)\nans = max(r,max(g,b))\nprint ans"}, {"source_code": "r, g, b = [int(i) for i in input().split()]\nprint(30 + max(3 * ((r - 1) // 2), 1 + 3 * ((g - 1) // 2), 2 + 3 * ((b - 1) // 2)))\n"}, {"source_code": "\ufefft=map(int,raw_input().split())\nres=-1\nwhile(any(t)):\n\tt[(res+1)%3]=max(t[(res+1)%3]-2,0)\n\tres+=1\nprint 30+res\t\t"}, {"source_code": "\nfrom math import ceil\nr, g, b = map(int, input().split())\n\nrt = (ceil(r / 2) - 1 ) * 3\nrg = 1 + ( ceil(g / 2) - 1 ) * 3\nrb = 2 + ( ceil(b / 2) - 1 ) * 3\n\nprint(max(rt, rg, rb ) + 30)"}, {"source_code": "\nl = [int(s) for s in input().split()]\n\nminutes = 0\ncount = l[0] + l[1] + l[2]\nwhile(True):\n x = minutes % 3\n if(l[x] > 0):\n count -= min(l[x],2)\n l[x] -= min(l[x],2)\n if(count <= 0):\n break\n minutes += 1\nprint(minutes + 30)\n"}, {"source_code": "r,g,f=map(int,input().split())\nc=29\nwhile(1):\n c=c+1\n if r>=2:\n r=r-2\n elif r==1:\n r=r-1\n \n if r==0 and g==0 and f==0:\n break\n c=c+1\n if g>=2:\n g=g-2\n elif g==1:\n g=g-1\n if r==0 and g==0 and f==0:\n break\n c=c+1\n if f>=2:\n f=f-2\n elif f==1:\n f=f-1\n if r<=0 and g<=0 and f<=0:\n break\nprint(c)\n \n \n \n "}, {"source_code": "r,g,b=map(int,input().split())\nr=(r-1)//2*3\ng=(g-1)//2*3\nb=(b-1)//2*3\nprint(max(r,g+1,b+2)+30)\n"}, {"source_code": "query = raw_input()\ns = query.split()\n\nx = (int(s[0])+1)/2*3-3\ny = (int(s[1])+1)/2*3-2\nz = (int(s[2])+1)/2*3-1\n\nprint max(x,y,z)+30\n\n"}, {"source_code": "r,g,b=map(int,raw_input().split())\nc=0\nwhile not (r<=0 and g<=0 and b<=0):\n if c%3==0:\n r-=2\n elif c%3==1:\n g-=2\n else:\n b-=2\n c+=1\nprint c+29\n"}, {"source_code": "q=raw_input().split();print 30+max(i+~-int(q[i])/2*3for i in(0,1,2))"}, {"source_code": "import math\nimport re\nfrom fractions import Fraction\nfrom collections import Counter\n\nclass Task:\n r, g, b = 0, 0, 0\n answer = 0\n \n def __init__(self):\n self.r, self.g, self.b = [int(x) for x in input().split()]\n\n def solve(self):\n r, g, b = self.r, self.g, self.b\n currentColor = 0\n while True:\n r = max(r - 2, 0) if currentColor == 0 else r\n g = max(g - 2, 0) if currentColor == 1 else g\n b = max(b - 2, 0) if currentColor == 2 else b\n if r + g + b > 0:\n self.answer += 1\n else:\n break\n currentColor = (currentColor + 1) % 3\n self.answer += 30\n\n def printAnswer(self):\n print(self.answer)\n #for line in self.answer:\n # print(re.sub('[\\[\\],]', '', str(line)))\n\ntask = Task()\ntask.solve()\ntask.printAnswer()\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nl=map(int, raw_input().split())\nj=-1\nwhile(any(l)):\n l[(j+1)%3]=max(l[(j+1)%3]-2,0)\n j+=1\nprint j+30"}, {"source_code": "print max([0, (n + 1) / 2 * 3 + i + 27][n > 0] for i, n in enumerate(map(int, raw_input().split())))"}, {"source_code": "def solve():\n l = map(int, str(raw_input()).split())\n num = max(l)\n lister = [(x-1)/2 for x in l]\n num = max(lister)\n lister.reverse()\n index = 2-lister.index(num)\n print num*3 + index + 30\n\nsolve()\n"}, {"source_code": "r,g,b = map(int,input().split())\nr = 30+3*((r-1)//2)\ng = 31+3*((g-1)//2)\nb = 32+3*((b-1)//2)\nprint(max(r,g,b))\n"}, {"source_code": "def main():\n from math import ceil\n [r, g, b] = [int(_) for _ in input().split()]\n \n n_cars_red = ceil(r / 2)\n n_cars_green = ceil(g / 2)\n n_cars_blue = ceil(b / 2)\n\n last_red = (n_cars_red - 1) * 3 + 30 if n_cars_red > 0 else 0\n last_green = (n_cars_green - 1) * 3 + 31 if n_cars_green > 0 else 0\n last_blue = (n_cars_blue - 1) * 3 + 32 if n_cars_blue > 0 else 0\n\n print(max(last_red, last_green, last_blue))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from math import ceil as c\nl=list(map(lambda x:c(int(x)/2),input().split()))\nfor x in range(3):\n\tif l[x]==max(l):a=x+1\nif l==[1,0,0]:print(30)\nelif l[2]==0 and max(l)==1:print(31)\nelif max(l)>1:print(32+(max(l)-2)*3+a)\nelse:print(32)\n"}, {"source_code": "A = list(map(int, input().split()))\nt = 0\n\nwhile max(A) > 0:\n A[t%3] -= 2\n t += 1\n\nprint(t + 29)"}, {"source_code": "from math import ceil\na,b,c = map(int,input().split())\nx,y,z = ceil(a/2),ceil(b/2),ceil(c/2)\nmaxi = max(x,y,z)\nif maxi == z:\n\tprint(32+3*ceil((c-2)/2))\nelif maxi == y:\n\tprint(31+3*ceil((b-2)/2))\nelif maxi == x:\n\tprint(30+3*ceil((a-2)/2))\n"}, {"source_code": "a = list(map(int,input().split()))\nb = -1\nfor x in range(len(a)):\n\tif a[x] % 2 != 0:a[x] = a[x] + 1\n\tif a[x] == b:a[a.index(a[x])] = 0\n\telif a[x] > b:b = a[x]\nc = 3 - (a.index(b) + 1) + 1\nprint(int(30 + ((b / 2) * 3) - c))\n"}, {"source_code": "from math import ceil\nr,g,b=map(int,input().split())\nr,g,b=[ceil(r/2),ceil(g/2),ceil(b/2)]\nif b>=r and b>=g:\n\tx=b\n\ti=2\nelif g>=r and g>=b:\n\tx=g\n\ti=1\nelif r>=g and r>=b:\n\tx=r\n\ti=0\nprint(30+(x-1)*3+i)"}, {"source_code": "import math\n\n\nline = raw_input().split()\na = float(line[0])\nb = float(line[1])\nc = float(line[2])\n\n\naa = math.ceil(a/2.0)\nbb = math.ceil(b/2.0)\ncc = math.ceil(c/2.0)\n\n\nif cc >= aa and cc >= bb:\n print 29 + int(math.ceil(float(c)/float(2))) * 3 - 0 \nelif bb >= aa and bb >= cc:\n print 29 + int(math.ceil(float(b)/float(2))) * 3 - 1 \nelse:\n print 29 + int(math.ceil(float(a)/float(2))) * 3 - 2\n\n \n"}, {"source_code": "import math\nr,b,g=map(int,raw_input().split())\ntime=0\ncount=1\nwhile max(r,b,g)>0:\n if count==1:\n if r>0:\n r-=2\n time+=1\n count+=1\n else:\n count+=1\n time+=1\n elif count==2:\n if b>0:\n b-=2\n time+=1\n count+=1\n else:\n time+=1\n count+=1\n elif count==3:\n if g>0:\n g-=2\n time+=1\n count=1\n else:\n time+=1\n count=1\nprint (time+30)-1"}, {"source_code": "arr= list(map(int , input().split()))\ncount = 0\ni=0\nwhile sum(arr)!=0:\n if arr[i]>0:\n d = max(arr[i]-2 , 0)\n arr[i] = d\n count = count+1\n i = i +1\n if i==3:\n i = 0\nprint(count+29)"}, {"source_code": "rgb=input().split()\nr=int(rgb[0])\ng=int(rgb[1])\nb=int(rgb[2])\nt=29\nc=0\nwhile True:\n if r==0 and g==0 and b==0:\n break\n elif r>=0 and c%3==0:\n c+=1\n t+=1\n if r-2<0:\n r=0\n else:\n r-=2\n elif g>=0 and c%3==1:\n c+=1\n t+=1\n if g-2<0:\n g=0\n else:\n g-=2\n elif b>=0 and c%3==2:\n c+=1\n t+=1\n if b-2<0:\n b=0\n else:\n b-=2\nprint(t)"}, {"source_code": "r,g,b=map(int,raw_input().split())\nt=0\nwhile r>0 or g>0 or b>0:\n if t%3==0:\n r-=2\n elif t%3==1:\n g-=2\n else:\n b-=2\n t += 1\nt += 29\nprint t\n"}, {"source_code": "r, g, b = map(int, input().split())\nif r%2==1:\n r+=1\nif g%2==1:\n g+=1\nif b%2==1:\n b+=1\nk = 0\nt = 0\nwhile r+g+b != 0:\n if k == -1 and r>0:\n r-=2\n elif k == 0 and r>0:\n r-=2\n t+=1\n elif k == 1 and g>0:\n g-=2\n t+=1\n elif k == 2 and b>0:\n b-=2\n t+=1\n else:\n t+=1\n if k<2:\n k += 1\n else:\n k = 0\nprint(t+29)\n \n"}, {"source_code": "r, g, b = map(int, raw_input().split())\nif r != 0:\n\tr = 30 + (r + 1) // 2 * 3 - 3;\nif g != 0:\n\tg = 31 + (g + 1) // 2 * 3 - 3;\nif b != 0:\n\tb = 32 + (b + 1) // 2 * 3 - 3;\nprint max(r, g, b)\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(r,g,b):\n \n def st_time(beg,N):\n n = N / 2 + N % 2\n t = beg + (n-1)*3\n return t\n\n tr = st_time(30,r)\n tg = st_time(31,g)\n tb = st_time(32,b)\n \n return max([tr,tg,tb])\n\nNs = input.readline().split(' ')\nassert len(Ns) == 3\n\nr = int(Ns[0])\ng = int(Ns[1])\nb = int(Ns[2])\n\nn_correct = lambda n: 0<=n and n<=100\nassert n_correct(r) and n_correct(g) and n_correct(b)\nassert r+g+b > 0\n\ns = solve(r,g,b)\noutput.write('%s\\n' % s)\n"}, {"source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\n\nif __name__ == \"__main__\":\n inp = raw_input().rsplit(' ')\n red = int(inp[0])\n green = int(inp[1])\n blue = int(inp[2])\n tik = 1\n while red>0 or green>0 or blue>0:\n if (tik+3)%3 == 1 and red>0:\n red -= 2\n if (tik+3)%3 == 2 and green>0:\n green -= 2\n if (tik+3)%3 == 0 and blue>0:\n blue -= 2\n tik += 1\n\n print (tik-2)+30"}, {"source_code": "r,g,b = map(int,raw_input().split())\nr1,r2,g1,g2,b1,b2 = (r+1)/2,r%2,(g+1)/2,g%2,(b+1)/2,b%2\nre = max([r1,g1,b1])\nresult = 29+re*3\nif re*2-2<b:\n pass\nelse:\n if re*2-2<g:\n result -=1\n else:\n if re*2-2<r:\n result -= 2\nprint result"}, {"source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\n\n# def gcd(a,b):\n# while b > 0: a,b = b, a%b\n# return a\n\n# def baseN(num,b,numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n# return ((num == 0) and \"0\" ) or ( baseN(num // b, b).lstrip(\"0\") + numerals[num % b])\n\n# T = input()\n# St = raw_input()\nR, G, B = map(int, raw_input().split())\n# data2 = [ map(int, raw_input().split()) for i in xrange(T) ]\ni = 1\nwhile R>0 or G>0 or B>0:\n if i%3 == 1:\n R -= 2\n if i%3 == 2:\n G -= 2\n if i%3 == 0:\n B -= 2\n i += 1\nprint i+28"}, {"source_code": "r,g,b=map(int,input().split())\nx=0\nwhile True:\n\tif r>0:\n\t\tr-=2\n\t\tr=max(0,r)\n\t\tif r==g and g==b and g==0:break\n\t\tx+=1\n\telse:x+=1\n\tif g>0:\n\t\tg-=2\n\t\tg=max(0,g)\n\t\tif r==g and g==b and g==0:break\n\t\tx+=1\n\telse:x+=1\n\tif b>0:\n\t\tb-=2\n\t\tb=max(0,b)\n\t\tif r==g and g==b and g==0:break\n\t\tx+=1\n\telse:x+=1\nprint(x+30)"}, {"source_code": "r,g,v=map(int,raw_input().split())\nmint=0\ncrnt='r'\n\nwhile (r+g+v)>0:\n if crnt=='r':\n r-=2\n mint+=1\n if r<=0:\n r=0\n # mint-=1\n crnt='g'\n continue\n if crnt=='g':\n g-=2\n mint+=1\n if g<=0:\n g=0\n # mint-=1\n crnt='v'\n continue\n if crnt=='v':\n v-=2\n mint+=1\n if v<=0:\n v=0\n # mint-=1\n crnt='r'\n continue\nmint+=29\nprint mint\n"}, {"source_code": "r,g,b=list(map(int,input().split()))\n#Finding no of required cable cars of each colour\nr=r//2+r%2\ng=g//2+g%2\nb=b//2+b%2\n#finding arrival time and adding journey time\nr=(r-1)*3+30\ng=(g-1)*3+31\nb=(b-1)*3+32\nprint(max(r,b,g))"}, {"source_code": "p = [ int(x) for x in raw_input().strip().split() ]\n\nres = 0\nt = 0\nwhile sum(p) > 0:\n p[t % 3] -= min(2, p[t % 3])\n t += 1\n res += 1\n\nprint res + 29\n\n\n\n"}, {"source_code": "r,g,b=map(int,input().split())\nx=r//2+(r%2)-1\ny=g//2+(g%2)-1\nz=b//2+(b%2)-1\nif max(x,y,z)==z:\n print(32+z*3)\nelif max(x,y,z)==y:\n print(31+y*3)\nelse:\n print(30+x*3)"}, {"source_code": "a=list(map(int,input().split()))\nt=0\nwhile(sum(a)>0):\n for i in range(3):\n if(a[i]-2>0):\n a[i]-=2\n else:\n a[i]=0\n if(sum(a)==0):\n break\n t+=1\nprint(t+30)\n"}, {"source_code": "import math\nr,g,b = map(int,input().split(\" \"))\nt = 30\nr = math.ceil(r/2)\ng = math.ceil(g/2)\nb = math.ceil(b/2)\nmax = r\nif(b>=r and b>=g):\n max = b\n t = t + 2\nelif(g>=r and g>=b):\n max = g\n t = t + 1\nprint(t + (max-1)*3)"}, {"source_code": "#!/usr/bin/env python\nfrom sys import stdin\n\ndef main():\n l = stdin.readline().split()\n r, g, b = int(l[0]), int(l[1]), int(l[2])\n if r > 0: r = 27 + (r+1)/2*3\n if g > 0: g = 28 + (g+1)/2*3\n if b > 0: b = 29 + (b+1)/2*3\n print max(r, max(g, b))\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python2\n\na = map(lambda x: ((int(x)+1)/2-1)*3 + 30, raw_input().split())\nprint max([a[i]+i for i in range(3)])\n"}, {"source_code": "r,g,b=map(int,raw_input().split(\" \"))\nR=r/2+r%2\nG=g/2+g%2\nB=b/2+b%2\nm=max(max(R,G),B)\nif B==m:\n a=29+m*3\nelif G==m:\n a=29+(m-1)*3+2\nelse:\n a=29+(m-1)*3+1\nprint a"}, {"source_code": "r,g,b= list(map(int, input().split(\" \")))\nr = 30 + 3*((r+1)//2-1)\ng = 31 + 3*((g+1)//2-1)\nb = 32 + 3*((b+1)//2-1)\nprint(max(r,g,b))\n"}, {"source_code": "r, g, b = map(int, raw_input().split())\nR = (r + 1) / 2\nG = (g + 1) / 2\nB = (b + 1) / 2\nprint 30 + max((R-1)*3, 1 + (G-1)*3, 2 + (B-1)*3)\n"}, {"source_code": "import math\n\nr, g, b = map(int, raw_input().split())\nt = 30 + max(3 * (int(math.ceil(float(r) / 2)) - 1), 1 + 3 * (int(math.ceil(float(g) / 2)) - 1), 2 + 3 * (int(math.ceil(float(b) / 2)) - 1))\nprint t"}, {"source_code": "import math\n\nt=list(map(int,input().split()))\nfor j in range(3):\n t[j]=math.ceil(t[j]/2)\n\nd=t[::-1]\n\nprint((max(t)-1)*3+(len(t)-1-d.index(max(d))+30))\n"}, {"source_code": "r,g,b = map(int,input().split())\nimport math\nif(r==1):\n r = r-1\nelif(r>=2):\n r=r-2\ntime = 30\nsum = r+g+b\n#print(sum)\nwhile(sum>0):\n\n if(g>0):\n #print('green')\n if(g>=2):\n g = g - 2\n sum=sum-2\n else:\n sum=sum-g\n g = g - 1\n time = time + 1\n if(sum<=0):\n break\n\n #print(sum,g,time)\n\n if(b>0):\n #print('blue')\n if(b>=2):\n b = b - 2\n sum=sum-2\n else:\n sum=sum-b\n b = b - 1\n time = time + 1\n if(sum<=0):\n break\n\n #print(sum, b, time)\n if(r>0):\n if(r>=2):\n r = r - 2\n sum=sum-2\n else:\n sum=sum-r\n r = r - 1\n time = time + 1\n if(sum<=0):\n break\n\n #print(sum, r, time)\n\n\nprint(time)"}, {"source_code": "\n\n\nr, g, b = map(int, input().split())\n\n\nprint(max([((r+1)//2 - 1) * 3, ((g+1)//2 - 1) * 3 + 1, ((b+1)//2 - 1) *\n 3 + 2]) + 30)\n\n\n\n\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUT3.out\",\"w\") \nr,g,b=map(int,input().split())\ncount=29\nwhile r>0 or g>0 or b>0:\n\tr=r-2\n\tcount+=1\n\tif r<=0 and g<=0 and b<=0:\n\t\tbreak\n\tg=g-2\n\tcount+=1\n\tif r<=0 and g<=0 and b<=0:\n\t\tbreak\n\tb=b-2\n\tcount+=1\n\tif r<=0 and g<=0 and b<=0:\n\t\tbreak\nprint(count)"}, {"source_code": "\n# -*- coding: utf-8 -*-\n# @Date : 2019-01-24 10:09:45\n# @Author : raj lath (oorja.halt@gmail.com)\n# @Link : link\n# @Version : 1.0.0\n\nfrom sys import stdin\n\nmax_val=int(10e12)\nmin_val=int(-10e12)\n\ndef read_int() : return int(stdin.readline())\ndef read_ints() : return [int(x) for x in stdin.readline().split()]\ndef read_str() : return input()\ndef read_strs() : return [x for x in stdin.readline().split()]\n\n\nr, g, b = map(int, input().split())\nt_r = 0 + 3 * ((r - 1) // 2)\nt_g = 1 + 3 * ((g - 1) // 2)\nt_b = 2 + 3 * ((b - 1) // 2)\nprint(30 + max(t_r, t_g, t_b))"}, {"source_code": "r,g,b = input().split()\nr = int(r)\ng = int(g)\nb = int(b)\n\ndiv_r = (r+1)//2\ndiv_g = (g+1)//2\ndiv_b = (b+1)//2\nans = max(3*div_r + 27, 3*div_g + 28, 3*div_b + 29)\nprint(int(ans))\n"}, {"source_code": "a=[int(i) for i in input().split()]\na[0]=int(((a[0]//2)+(a[0]%2)-1)*3+1)\na[1]=int(((a[1]//2)+(a[1]%2)-1)*3+2)\na[2]=int(((a[2]//2)+(a[2]%2)-1)*3+3)\nprint(max(a[0],max(a[1],a[2]))+29)"}, {"source_code": "r,g,b=[int(x) for x in input().split()]\nx=29\nwhile r+g+b>0:\n #print(\"1st\",r,g,b,x)\n if r<=2:\n if (r+g+b)!=0:\n x+=1\n r=0\n \n else:\n r-=2\n x+=1\n #print(\"aftr red\",r,g,b,x)\n \n if g<=2:\n if (r+g+b)!=0:\n x+=1\n g=0\n else:\n g-=2\n x+=1\n #print(\"aftr green\",r,g,b,x)\n \n if b<=2:\n if (r+g+b)!=0:\n x+=1\n b=0\n else:\n b-=2\n x+=1\n \n #print(\"aftr blue\",r,g,b,x)\nprint(x)"}, {"source_code": "\nn = input().split()\nx = int(n[0])\ny = int(n[1])\nz = int(n[2])\nt = 29\nwhile not (x <= 0 and y <=0 and z <=0):\n t += 1\n if t % 3 ==0:\n x -= 2\n elif t % 3 ==1:\n y -= 2\n else:\n z -= 2\nprint(t)\n \n"}, {"source_code": "a=list(map(int, input().split()))\ni=t=0\nwhile sum(a) > 0:\n\tif a[i%3] > 0:\n\t\ta[i%3] -= min(a[i%3], 2)\n\tt += 1\n\ti += 1\nprint(t+29)"}, {"source_code": "from itertools import cycle\na = map(int, raw_input().split())\nc = 30\nfor i in cycle([0, 1, 2]):\n a[i] = max(0, a[i] - 2)\n if sum(a) == 0: break\n c += 1\nprint c\n"}, {"source_code": "col = [int(i) for i in raw_input().split()]\nt = 0\nwhile sum(col) > 0:\n if col[0] >= 2: col[0] -= 2\n elif col[0] > 0: col[0] = 0\n x = col.pop(0)\n col.append(x)\n if(sum(col) > 0): t += 1\nt += 30\nprint(t)"}, {"source_code": "import math\narr = [math.ceil(int(num)/ 2)-1 for num in input().split()]\nfn = lambda x: arr[x]\narr.reverse()\nmax_element = len(arr) - max(range(len(arr)), key = fn) - 1\nprint(max(arr) * 3 + 30 + max_element)"}, {"source_code": "#! /usr/bin/env python\n\nfrom sys import stdin\n\nfrom collections import deque\n\ndef solve(start_time,Q):\n\tret=0\n\twhile Q>0:\n\t\t#print start_time,ret,Q\n\t\tret=max(start_time+30,ret)\n\t\tQ=max(0,Q-2)\n\t\tstart_time+=3\n\t#print \"ret=\",ret\n\treturn ret\n\nif __name__=='__main__':\n\tr,g,b=map(int,stdin.readline().split())\n\tprint max([solve(x,y) for (x,y) in ((0,r),(1,g),(2,b))])\n\n"}, {"source_code": "# -*- encoding: utf-8 -*-\n\n\"\"\"\nhttp://codeforces.ru/contest/90/problem/A\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442: 2 seconds\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442: 256 megabytes\n\u0432\u0432\u043e\u0434: standard input\n\u0432\u044b\u0432\u043e\u0434: standard output\n\nA. \u041a\u0430\u043d\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u0430\n\n\u0413\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b, \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043c \u0443\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0438\u043a\u043d\u0438\u043a. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u0440\u0435\u0448\u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043d\u0430\u0442\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u043e\u0439.\n\n\u041a\u0430\u043d\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0431\u0438\u043d\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0432\u0435\u0448\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u043d\u0430\u0442\u0430 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u043e\u0440\u044b. \u041a\u0430\u043d\u0430\u0442 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043e\u043f\u043e\u0440\u0430\u043c\u0438 (\u043f\u0435\u0440\u0432\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0443 \u043f\u043e\u0434\u043d\u043e\u0436\u044c\u044f \u0433\u043e\u0440\u044b, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u2014 \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435), \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0434\u0432\u0438\u0436\u0443\u0442\u0441\u044f \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u0435 \u043a \u043d\u0435\u043c\u0443 \u043a\u0430\u0431\u0438\u043d\u043a\u0438.\n\n\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0431\u0438\u043d\u043e\u043a \u043a\u0440\u0430\u0442\u043d\u043e \u0442\u0440\u0435\u043c \u0438 \u043e\u043d\u0438 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u044b \u0432 \u0442\u0440\u0438 \u0446\u0432\u0435\u0442\u0430 \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0439, \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u0438 \u0441\u0438\u043d\u0438\u0439 \u2014 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u043a\u0430\u0431\u0438\u043d\u043a\u0438 \u0438\u0434\u0435\u0442 \u0437\u0435\u043b\u0435\u043d\u0430\u044f \u043a\u0430\u0431\u0438\u043d\u043a\u0430, \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0435\u043b\u0435\u043d\u043e\u0439 \u2014 \u0441\u0438\u043d\u044f\u044f, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0438\u043d\u0435\u0439 \u2014 \u043a\u0440\u0430\u0441\u043d\u0430\u044f. \u0412 \u043a\u0430\u0436\u0434\u0443\u044e \u043a\u0430\u0431\u0438\u043d\u043a\u0443 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041a\u0430\u0431\u0438\u043d\u043a\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043e\u0434\u043d\u0443 \u043c\u0438\u043d\u0443\u0442\u0443, \u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0432\u0435\u0440\u0445 \u0440\u043e\u0432\u043d\u043e \u0437\u0430 30 \u043c\u0438\u043d\u0443\u0442.\n\n\u0412\u0441\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b: r \u0438\u0437 \u043d\u0438\u0445 \u043b\u044e\u0431\u044f\u0442 \u043a\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u043a\u0430\u0445, g \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0437\u0435\u043b\u0435\u043d\u044b\u0445 \u0438 b \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0438\u043d\u0438\u0445. \u0421\u0442\u0443\u0434\u0435\u043d\u0442 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0430\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0431\u0438\u043d\u043a\u0443 \u0441 \u0446\u0432\u0435\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u043c\u0443 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f.\n\n\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0430\u044f \u043a\u0430\u0431\u0438\u043d\u043a\u0430 (\u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 0) \u0438\u043c\u0435\u0435\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0446\u0432\u0435\u0442. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b.\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0442\u0440\u0438 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u2014 r, g \u0438 b (0 <= r,g,b <= 100). \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e r\u2009+\u2009g\u2009+\u2009b\u2009>\u20090, \u0442\u043e \u0435\u0441\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430.\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b.\n\"\"\"\n\nr, g, b = map(lambda n: (int(n) - 1) // 2, raw_input().split())\n\nif g >= r :\n i, m = 1, g\nelse:\n i, m = 0, r\nif b >= m:\n i, m = 2, b\n\nprint m * 3 + i + 30"}, {"source_code": "r,g,b=map(int,input().split())\nkr,kg,kb=r//2+r%2,g//2+g%2,b//2+b%2\nprint(max((kr-1)*3+30,(kg-1)*3+31,(kb-1)*3+32))\n\n"}, {"source_code": "q=raw_input().split();print 30+max(i+~-int(q[i])/2*3for i in(0,1,2))"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out1.out\",'w')\nr,g,b=map(int,input().split())\nt=29\nwhile r+b+g:\n\tif r>2 :\n\t\tt+=1\n\t\tr-=2\n\telse:\n\t\tt+=1\n\t\tr=0\n\tif r+b+g==0:\n\t\tbreak\t\n\tif g>2:\n\t\tt+=1\n\t\tg-=2\n\telse:\n\t\tt+=1\n\t\tg=0\n\tif r+b+g==0:\n\t\tbreak\n\tif b>2:\n\t\tt+=1\n\t\tb-=2\n\telse:\n\t\tt+=1\n\t\tb=0\t\nprint(t)\t\t"}], "negative_code": [{"source_code": "from math import ceil\nr,g,b=map(int,input().split())\nr,g,b=max(0,r-2),max(0,g-2),max(0,b-2)\nw=max(ceil(r/2)*3,ceil(g/2)*3+1,ceil(b/2)*3+2)\nprint(w+30)"}, {"source_code": "# import sys\n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUT3.out\",\"w\") \nr,g,b=map(int,input().split())\ncount=29\nwhile r>0 or g>0 or b>0:\n\tr=r-2\n\tcount+=1\n\tif g<=0 and b<=0:\n\t\tbreak\n\tg=g-2\n\tcount+=1\n\tif b<=0:\n\t\tbreak\n\tb=b-2\n\tcount+=1\nprint(count)"}, {"source_code": "# import sys\n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUT3.out\",\"w\") \nr,g,b=map(int,input().split())\ncount=29\nwhile r>0 or g>0 or b>0:\n\tr=r-2\n\tcount+=1\n\tif r<=0 and g<=0 and b<=0:\n\t\tbreak\n\tg=g-2\n\tcount+=1\n\tif g<=0 and b<=0:\n\t\tbreak\n\tb=b-2\n\tcount+=1\nprint(count)"}, {"source_code": "r,g,b = input().split()\nr = int(r)\ng = int(g)\nb = int(b)\n\ndiv_r = (r+1)/2\ndiv_g = (g+1)/2\ndiv_b = (b+1)/2\nans = max(3*div_r + 27, 3*div_g + 28, 3*div_b + 29)\nprint(int(ans))\n"}, {"source_code": "s=input().split();r=int(s[0]);g=int(s[1]);b=int(s[2])\nif b==max(r,g,b):\n print(2+max(r,g,b)+30)\nelif g==max(r,g,b):\n print(1+max(r,g,b)+30)\nelse:\n print(max(r,g,b)+30)"}, {"source_code": "# -*- encoding: utf-8 -*-\n\n\"\"\"\nhttp://codeforces.ru/contest/90/problem/A\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442: 2 seconds\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442: 256 megabytes\n\u0432\u0432\u043e\u0434: standard input\n\u0432\u044b\u0432\u043e\u0434: standard output\n\nA. \u041a\u0430\u043d\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u0430\n\n\u0413\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b, \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043c \u0443\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0438\u043a\u043d\u0438\u043a. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u0440\u0435\u0448\u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043d\u0430\u0442\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u043e\u0439.\n\n\u041a\u0430\u043d\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0431\u0438\u043d\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0432\u0435\u0448\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u043d\u0430\u0442\u0430 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u043e\u0440\u044b. \u041a\u0430\u043d\u0430\u0442 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043e\u043f\u043e\u0440\u0430\u043c\u0438 (\u043f\u0435\u0440\u0432\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0443 \u043f\u043e\u0434\u043d\u043e\u0436\u044c\u044f \u0433\u043e\u0440\u044b, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u2014 \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435), \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0434\u0432\u0438\u0436\u0443\u0442\u0441\u044f \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u0435 \u043a \u043d\u0435\u043c\u0443 \u043a\u0430\u0431\u0438\u043d\u043a\u0438.\n\n\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0431\u0438\u043d\u043e\u043a \u043a\u0440\u0430\u0442\u043d\u043e \u0442\u0440\u0435\u043c \u0438 \u043e\u043d\u0438 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u044b \u0432 \u0442\u0440\u0438 \u0446\u0432\u0435\u0442\u0430 \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0439, \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u0438 \u0441\u0438\u043d\u0438\u0439 \u2014 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u043a\u0430\u0431\u0438\u043d\u043a\u0438 \u0438\u0434\u0435\u0442 \u0437\u0435\u043b\u0435\u043d\u0430\u044f \u043a\u0430\u0431\u0438\u043d\u043a\u0430, \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0435\u043b\u0435\u043d\u043e\u0439 \u2014 \u0441\u0438\u043d\u044f\u044f, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0438\u043d\u0435\u0439 \u2014 \u043a\u0440\u0430\u0441\u043d\u0430\u044f. \u0412 \u043a\u0430\u0436\u0434\u0443\u044e \u043a\u0430\u0431\u0438\u043d\u043a\u0443 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041a\u0430\u0431\u0438\u043d\u043a\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043e\u0434\u043d\u0443 \u043c\u0438\u043d\u0443\u0442\u0443, \u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0432\u0435\u0440\u0445 \u0440\u043e\u0432\u043d\u043e \u0437\u0430 30 \u043c\u0438\u043d\u0443\u0442.\n\n\u0412\u0441\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b: r \u0438\u0437 \u043d\u0438\u0445 \u043b\u044e\u0431\u044f\u0442 \u043a\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u043a\u0430\u0445, g \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0437\u0435\u043b\u0435\u043d\u044b\u0445 \u0438 b \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0438\u043d\u0438\u0445. \u0421\u0442\u0443\u0434\u0435\u043d\u0442 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0430\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0431\u0438\u043d\u043a\u0443 \u0441 \u0446\u0432\u0435\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u043c\u0443 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f.\n\n\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0430\u044f \u043a\u0430\u0431\u0438\u043d\u043a\u0430 (\u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 0) \u0438\u043c\u0435\u0435\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0446\u0432\u0435\u0442. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b.\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0442\u0440\u0438 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u2014 r, g \u0438 b (0 <= r,g,b <= 100). \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e r\u2009+\u2009g\u2009+\u2009b\u2009>\u20090, \u0442\u043e \u0435\u0441\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430.\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b.\n\"\"\"\n\nr, g, b = map(int, raw_input().split())\n\nif g >= r:\n i, m = 1, g\nelse:\n i, m = 0, r\nif b >= m:\n i, m = 2, b\n\nprint ((m - 1) // 2) * 3 + i + 30"}, {"source_code": "# -*- encoding: utf-8 -*-\n\n\"\"\"\nhttp://codeforces.ru/contest/90/problem/A\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442: 2 seconds\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442: 256 megabytes\n\u0432\u0432\u043e\u0434: standard input\n\u0432\u044b\u0432\u043e\u0434: standard output\n\nA. \u041a\u0430\u043d\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u0430\n\n\u0413\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b, \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043c \u0443\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0438\u043a\u043d\u0438\u043a. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u0440\u0435\u0448\u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043d\u0430\u0442\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u043e\u0439.\n\n\u041a\u0430\u043d\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0431\u0438\u043d\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0432\u0435\u0448\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u043d\u0430\u0442\u0430 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u043e\u0440\u044b. \u041a\u0430\u043d\u0430\u0442 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043e\u043f\u043e\u0440\u0430\u043c\u0438 (\u043f\u0435\u0440\u0432\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0443 \u043f\u043e\u0434\u043d\u043e\u0436\u044c\u044f \u0433\u043e\u0440\u044b, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u2014 \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435), \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0434\u0432\u0438\u0436\u0443\u0442\u0441\u044f \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u0435 \u043a \u043d\u0435\u043c\u0443 \u043a\u0430\u0431\u0438\u043d\u043a\u0438.\n\n\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0431\u0438\u043d\u043e\u043a \u043a\u0440\u0430\u0442\u043d\u043e \u0442\u0440\u0435\u043c \u0438 \u043e\u043d\u0438 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u044b \u0432 \u0442\u0440\u0438 \u0446\u0432\u0435\u0442\u0430 \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0439, \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u0438 \u0441\u0438\u043d\u0438\u0439 \u2014 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u043a\u0430\u0431\u0438\u043d\u043a\u0438 \u0438\u0434\u0435\u0442 \u0437\u0435\u043b\u0435\u043d\u0430\u044f \u043a\u0430\u0431\u0438\u043d\u043a\u0430, \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0435\u043b\u0435\u043d\u043e\u0439 \u2014 \u0441\u0438\u043d\u044f\u044f, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0438\u043d\u0435\u0439 \u2014 \u043a\u0440\u0430\u0441\u043d\u0430\u044f. \u0412 \u043a\u0430\u0436\u0434\u0443\u044e \u043a\u0430\u0431\u0438\u043d\u043a\u0443 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041a\u0430\u0431\u0438\u043d\u043a\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043e\u0434\u043d\u0443 \u043c\u0438\u043d\u0443\u0442\u0443, \u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0432\u0435\u0440\u0445 \u0440\u043e\u0432\u043d\u043e \u0437\u0430 30 \u043c\u0438\u043d\u0443\u0442.\n\n\u0412\u0441\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b: r \u0438\u0437 \u043d\u0438\u0445 \u043b\u044e\u0431\u044f\u0442 \u043a\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u043a\u0430\u0445, g \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0437\u0435\u043b\u0435\u043d\u044b\u0445 \u0438 b \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0438\u043d\u0438\u0445. \u0421\u0442\u0443\u0434\u0435\u043d\u0442 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0430\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0431\u0438\u043d\u043a\u0443 \u0441 \u0446\u0432\u0435\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u043c\u0443 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f.\n\n\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0430\u044f \u043a\u0430\u0431\u0438\u043d\u043a\u0430 (\u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 0) \u0438\u043c\u0435\u0435\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0446\u0432\u0435\u0442. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b.\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0442\u0440\u0438 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u2014 r, g \u0438 b (0 <= r,g,b <= 100). \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e r\u2009+\u2009g\u2009+\u2009b\u2009>\u20090, \u0442\u043e \u0435\u0441\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430.\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0433\u043e\u0440\u044b.\n\"\"\"\n\nr, g, b = map(int, raw_input().split())\n\nif g >= r:\n i, m = 1, g\nelse:\n i, m = 0, r\nif b >= m:\n i, m = 2, b\n\nprint (m // 2) * 3 + i + 30"}, {"source_code": "import sys\nimport itertools\nimport math\n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\nnums = [int(i) for i in lines[0].split(\" \")]\n\nmaxi = 0\nt = 0\nidx = 0\nfor i in range(len(nums)):\n if maxi <= nums[i]:\n maxi = nums[i]\n idx = i\n\nprint int(math.ceil(float(maxi) / 2.0)) + idx + 1 + 30\n \n\n\n\n\n \n \n"}, {"source_code": "import sys\nimport itertools\nimport math\n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\nnums = [int(i) for i in lines[0].split(\" \")]\n\nmaxi = 0\nt = 0\nidx = 0\nfor i in range(len(nums)):\n if maxi <= nums[i]:\n maxi = nums[i]\n idx = i\n\nprint int(math.floor(float(maxi) / 2.0)) * 3 + idx + 30\n \n\n\n\n\n \n \n"}, {"source_code": "students = map(int, raw_input().split())\nprint students\nt = 0\nwhile True:\n students[t % 3] = max(students[t % 3] - 2, 0)\n if max(students) == 0:\n break\n t += 1\nprint str(t + 30)"}, {"source_code": "r, g, b = map(int, raw_input().strip().split())\n\nrmin = 0\ngmin = 1\nbmin = 2\n\nif r > 2:\n rmin = r%2*3\nif g > 2:\n gmin = 1 + g%2*3\nif b > 2:\n bmin = 2 + b%2*3\n\nprint max(rmin,gmin,bmin)+30"}, {"source_code": "r, g, b = map(int, raw_input().strip().split())\n\nrmin = 0\ngmin = 1\nbmin = 2\n\nif r > 2 and r%2 == 0:\n rmin = (r/2-1)*3\nelif r > 2 and r%2 != 0:\n rmin = r/2*3\nif g > 2 and g%2 == 0:\n gmin = 1 + (g/2-1)*3\nelif g > 2 and g%2 != 0:\n gmin = 1 + g/2*3\nif b > 2 and b%2 == 0:\n bmin = 2 + (b/2-1)*3\nelif b > 2 and b%2 != 0:\n bmin = 2 + b/2*3\n#print rmin,gmin,bmin\nprint max(rmin,gmin,bmin)+30"}, {"source_code": "r, g, b = map(int, raw_input().strip().split())\n\nrmin = 0\ngmin = 1\nbmin = 2\n\nif r > 2 and r%2 == 0:\n rmin = (r/2-1)*3\nelif r > 2 and r%2 != 0:\n rmin = r/2*3\nif g > 2 and g%2 == 0:\n gmin = 1 + (g/2-1)*3\nelif g > 2 and g%2 == 0:\n gmin = g1 + g/2*3\nif b > 2 and b%2 == 0:\n bmin = 2 + (b/2-1)*3\nelif b > 2 and b%2 != 0:\n bmin = 2 + b/2*3\n#print rmin,gmin,bmin\nprint max(rmin,gmin,bmin)+30"}, {"source_code": "r, g, b = map(int, raw_input().strip().split())\n\nrmin = 0\ngmin = 1\nbmin = 2\n\nif r > 2:\n rmin = r/2*3\nif g > 2:\n gmin = 1 + g/2*3\nif b > 2:\n bmin = 2 + b/2*3\n#print rmin,gmin,bmin\nprint max(rmin,gmin,bmin)+30"}, {"source_code": "import sys\nline = sys.stdin.readline()\nline = line.split(' ')\nline = map(int,line)\nans = 0\nwhile (max(line) >= 2):\n for i in range(len(line)):\n line[i] = line[i] - 2\n ans += 3\nfor i in range(3):\n if line[i] > 0:\n ans += 30 + i\nif min(line) == 0: \n ans += 30 \nprint ans"}, {"source_code": "import sys\nline = sys.stdin.readline()\nline = line.split(' ')\nline = map(int,line)\nans = 0\nwhile (max(line) > 2):\n for i in range(len(line)):\n line[i] = line[i] - 2\n ans += 3\nfor i in range(3):\n if line[i] > 0:\n ans += 30 + i\nprint ans\n "}, {"source_code": "\ufeffdef b():\n\tt=map(int,raw_input().split())\n\tfor a in range(3):\n\t\tt[a]=3*((t[a]+1)>>1)-3+a\n\tprint 30+max(t)"}, {"source_code": "\ufeffdef b():\n\tt=map(int,raw_input().split())\n\tres=-1\n\twhile(any(t)):\n\t\tt[(res+1)%3]=max(t[(res+1)%3]-2,0)\n\t\tres+=1\n\tprint 30+res\t\t"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nr,g,b=map(int, raw_input().split())\ncal=r\nj=0\n#\u3088\u308a\u5927\u304d\u3044\u304b\u540c\u5024\u3067\u305a\u3089\u3059\nif g>=r:\n cal=g\n j=1\nif b>=cal:\n cal=b\n j=2\n\nprint (((cal+1)/2)-1)*3+j+30"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nl=map(int, raw_input().split())\ncal=max(l)\nj=l.index(cal)\nprint (((cal+1)/2)-1)*3+j+30"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nl=map(int, raw_input().split())\n#j=-1\nj=0\nwhile(any(l)):\n l[(j+1)%3]=max(l[(j+1)%3]-2,0)\n j+=1\n#print j+30\nprint j+29"}, {"source_code": "c = list(map(int, input().split()))\n\nm = max(c)\np = 2 - c[::-1].index(m)\n\nres = 0\nm -= 2\nwhile m > 0:\n res += 3\n m -= 2\n\nprint(res + p + 30)"}, {"source_code": "\n# -*- coding: utf-8 -*-\n# @Date : 2019-01-24 10:09:45\n# @Author : raj lath (oorja.halt@gmail.com)\n# @Link : link\n# @Version : 1.0.0\n\nfrom sys import stdin\n\nmax_val=int(10e12)\nmin_val=int(-10e12)\n\ndef read_int() : return int(stdin.readline())\ndef read_ints() : return [int(x) for x in stdin.readline().split()]\ndef read_str() : return input()\ndef read_strs() : return [x for x in stdin.readline().split()]\n\n\nr, g, b = read_ints()\nrtime = 0 + 3 * (r - 1) // 2\ngtime = 1 + 3 * (g - 1) // 2\nbtime = 2 + 3 * (b - 1) // 2\nprint(30 + max(rtime, gtime, btime))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue May 5 17:16:25 2020\n\n@author: alexi\n\"\"\"\n\n\n\n#https://codeforces.com/problemset/problem/90/A --- Alexis Galvan\n\n\nimport math\n\ndef cableway():\n \n people = list(map(int, input().split()))\n \n maximum = max(people)\n \n temp = 0\n for i in range(len(people)):\n if people[i] == maximum:\n index = i \n temp += 1\n \n if temp >= 2:\n if people[2] == maximum:\n index = 2\n elif people[1] == maximum:\n index = 1\n else:\n index = 0\n \n extra = 0\n \n if index == 0:\n if people[0] % 2 == 0:\n if people[0] - people[1] == 1 or people[0] - people[1] == 0:\n extra += 1\n if people[0] - people[2] == 1 or people[0] - people[2] == 0:\n extra += 1\n else:\n if people[0] == people[1]:\n extra += 1\n if people[0] == people[2]:\n extra += 1\n elif index == 1:\n if people[1] % 2 == 0:\n if people[1] - people[2] == 1 or people[1] - people[2] == 0:\n extra += 1\n else:\n if people[1] == people[2]:\n extra += 1\n\n \n \n return ((math.ceil(maximum/2)-1)*3)+(index) + 30 + extra\n\n\nA = cableway()\nprint(A)\n \n "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue May 5 17:16:25 2020\n\n@author: alexi\n\"\"\"\n\n\n\n#https://codeforces.com/problemset/problem/90/A --- Alexis Galvan\n\n\nimport math\n\ndef cableway():\n \n people = list(map(int, input().split()))\n \n maximum = max(people)\n \n temp = 0\n for i in range(len(people)):\n if people[i] == maximum:\n index = i \n temp += 1\n \n if temp >= 2:\n if people[2] == maximum:\n index = 2\n elif people[1] == maximum:\n index = 1\n else:\n index = 0\n \n return math.ceil(maximum/2)+(index+1) + 30\n\n\nA = cableway()\nprint(A)\n \n "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue May 5 17:16:25 2020\n\n@author: alexi\n\"\"\"\n\n\n\n#https://codeforces.com/problemset/problem/90/A --- Alexis Galvan\n\n\nimport math\n\ndef cableway():\n \n people = list(map(int, input().split()))\n \n maximum = max(people)\n \n temp = 0\n for i in range(len(people)):\n if people[i] == maximum:\n index = i \n temp += 1\n \n if temp >= 2:\n if people[2] == maximum:\n index = 2\n elif people[1] == maximum:\n index = 1\n else:\n index = 0\n \n extra = 0\n \n if index == 0:\n if maximum - people[1] < 2:\n extra += 1\n if maximum - people[2] < 2:\n extra += 1\n elif index == 1:\n if maximum - people[2] < 2:\n extra += 1\n \n \n return ((math.ceil(maximum/2)-1)*3)+(index) + 30 + extra\n\n\nA = cableway()\nprint(A)\n \n "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue May 5 17:16:25 2020\n\n@author: alexi\n\"\"\"\n\n\n\n#https://codeforces.com/problemset/problem/90/A --- Alexis Galvan\n\n\nimport math\n\ndef cableway():\n \n people = list(map(int, input().split()))\n \n maximum = max(people)\n \n temp = 0\n for i in range(len(people)):\n if people[i] == maximum:\n index = i \n temp += 1\n \n if temp >= 2:\n if people[2] == maximum:\n index = 2\n elif people[1] == maximum:\n index = 1\n else:\n index = 0\n \n extra = 0\n one = True\n \n if index == 0:\n if people[0] % 2 == 0:\n if people[0] - people[1] == 1 or people[0] - people[1] == 0:\n extra += 1\n extra = False\n if people[0] - people[2] == 1 or people[0] - people[2] == 0:\n extra += 1\n if one:\n extra += 1\n else:\n if people[0] == people[1]:\n extra += 1\n if people[0] == people[2]:\n extra += 1\n elif index == 1:\n if people[1] % 2 == 0:\n if people[1] - people[2] == 1 or people[1] - people[2] == 0:\n extra += 1\n else:\n if people[1] == people[2]:\n extra += 1\n\n \n \n return ((math.ceil(maximum/2)-1)*3)+(index) + 30 + extra\n\n\nA = cableway()\nprint(A)\n \n "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue May 5 17:16:25 2020\n\n@author: alexi\n\"\"\"\n\n\n\n#https://codeforces.com/problemset/problem/90/A --- Alexis Galvan\n\n\nimport math\n\ndef cableway():\n \n people = list(map(int, input().split()))\n \n maximum = max(people)\n \n temp = 0\n for i in range(len(people)):\n if people[i] == maximum:\n index = i \n temp += 1\n \n if temp >= 2:\n if people[2] == maximum:\n index = 2\n elif people[1] == maximum:\n index = 1\n else:\n index = 0\n \n return ((math.ceil(maximum/2)-1)*3)+(index) + 30\n\n\nA = cableway()\nprint(A)\n \n "}, {"source_code": "r,g,b=[int(x) for x in input().split()]\nx=0\nwhile r+g+b>0:\n #print(r,g,b,x+30)\n if r<=2:\n if r!=0:\n x+=1\n r=0\n \n else:\n r-=2\n x+=1\n if g<=2:\n if g!=0:\n x+=1\n g=0\n else:\n g-=2\n x+=1\n if b<=2:\n if b!=0:\n x+=1\n b=0\n else:\n b-=2\n x+=1\n \n #print(r,g,b,x+30)\nprint(x+30)"}, {"source_code": "r, g, b = map(int, input().split())\nprint(30 + max(r, g + 1, b + 2))\n"}, {"source_code": "from math import ceil\nr, g, b = map(int, input().split())\ncnt = 0\nif g == max(r, g, b):\n cnt = 1\nif b == max(r, g, b):\n cnt = 2\nprint(ceil(max(r, g, b) / 2) * 3 + cnt + 27)\n"}, {"source_code": "from math import ceil\na = list(map(int, input().split()))\nmx = max(a)\nb = list(reversed(a))\nprint(ceil(mx // 2) * 30 + 2 - b.index(mx) + mx)\n"}, {"source_code": "from math import ceil\nr, g, b = map(lambda x: ceil(int(x) / 2) * 3, input().split())\nprint(27 + max(r, g + 1, b + 1))\n"}, {"source_code": "import math\narr = [math.ceil(int(num)/ 2)-1 for num in input().split()]\nfn = lambda x: arr[x]\nprint(max(arr) * 3 + 30 + max(range(len(arr)), key = fn))"}, {"source_code": "x=list(map(int, input().split()))\nc=max(x)\nind=x[::-1].index(c)\nprint(30+(c+1)//2*3-ind-1)"}, {"source_code": "from math import ceil\n\nX, i, Found, Sum = [ceil(i / 2) for i in map(int, input().split())], 2, False, 0\nwhile i >= 0:\n if X[i] == max(X):\n Found = True\n Sum += (X[i] if not Found else max(X))\n i -= 1\nprint(Sum + 29)\n\n# UB_CodeForces\n# Advice: Keep an eye on your goals\n# Location: At home next to a cup of thyme tea\n# Caption: I expect more from CodeForcesians\n"}, {"source_code": "import sys\nimport math\n\nr, g, b = [int(x) for x in (sys.stdin.readline()).split()]\n\nres1 = 30\nres2 = 30\nres3 = 30\ni = 0\n\nif(r > 2):\n r -= 2\n res1 += 0\nelif(r == 1):\n r = 0\n res1 += 0\n \nif(g > 2):\n g -= 2\n res2 += 1\nelif(g == 1):\n g = 0\n res2 += 1\n \nif(b > 2):\n b -= 2\n res3 += 2\nelif(b == 1):\n b = 0\n res3 += 2\n\nres1 += int(r / 2) * 3\nif(r % 2 != 0):\n res1 += 3\n\nres2 += int(g / 2) * 3\nif(g % 2 != 0):\n res2 += 3\n \nres3 += int(b / 2) * 3\nif(b % 2 != 0):\n res3 += 3\n \nprint(max([res1, res2, res3]))\n\n"}, {"source_code": "import sys\nimport math\n\nr, g, b = [int(x) for x in (sys.stdin.readline()).split()]\n\nres1 = 30\nres2 = 30\nres3 = 30\ni = 0\n\nif(r > 2):\n r -= 2\n res1 += 0\nelif(r == 1):\n r = 0\n res1 += 0\n \nif(g > 2):\n g -= 2\n res2 += 1\nelif(g == 1):\n g = 0\n res2 += 1\n \nif(b > 2):\n b -= 2\n res3 += 2\nelif(g == 1):\n b = 0\n res3 += 2\n\n\nres1 += int(r / 2) * 3\nif(r % 2 != 0):\n res1 += 3\n\nres2 += int(g / 2) * 3\nif(g % 2 != 0):\n res2 += 3\n \nres3 += int(b / 2) * 3\nif(b % 2 != 0):\n res3 += 3\n \nprint(max([res1, res2, res3]))\n\n"}, {"source_code": "import sys\nimport math\n\nr, g, b = [int(x) for x in (sys.stdin.readline()).split()]\n\nres1 = 30\nres2 = 30\nres3 = 30\ni = 0\n\nif(r > 2):\n r -= 2\n res1 += 0\nelif(r == 1):\n r = 0\n res1 += 0\n \nif(g > 2):\n g -= 2\n res2 += 1\nelif(g == 1):\n g = 0\n res2 += 1\n \nif(b > 2):\n b -= 2\n res3 += 2\nelse:\n b = 0\n res3 += 2\n\nres1 += int(r / 2) * 3\nif(r % 2 != 0):\n res1 += 3\n\nres2 += int(g / 2) * 3\nif(g % 2 != 0):\n res2 += 3\n \nres3 += int(b / 2) * 3\nif(b % 2 != 0):\n res3 += 3\n \nprint(max([res1, res2, res3]))\n\n"}, {"source_code": "from math import ceil\na,b,c = map(int,input().split())\nt = max(a,b,c)\nif t == c:\n\tprint(32+3*ceil((c-2)/2))\nelif t == b:\n\tprint(31+3*ceil((b-2)/2))\nelif t == a:\n\tprint(30+3*ceil((a-2)/2))\n\n"}, {"source_code": "a,b,c = map(int,input().split())\nt = max(a,b,c)\nif t == a:\n\tprint(30+a//2+2)\nif t == b:\n\tprint(30+b//2+3)\nif t == c:\n\tprint(30+c//2+4)"}, {"source_code": "from math import ceil\na,b,c = map(int,input().split())\nt = max(a,b,c)\nif t == c:\n\tprint(32+3*ceil((c-2)/2))\nelif t == b:\n\tprint(31+3*ceil((b-2)/2))\nelif t == c:\n\tprint(30+3*ceil((a-2)/2))"}, {"source_code": "from math import ceil\na,b,c = map(int,input().split())\nt = max(a,b,c)\nif t == c:\n\tprint(32+3*ceil((c-2)/2))\nelif t == b:\n\tprint(31+3*(ceil(b-2)/2))\nelif t == c:\n\tprint(30+3*(ceil(a-2)/2))"}, {"source_code": "a,b,c = map(int,input().split())\nt = max(a,b,c)\nif t == a:\n\tk = a//2\n\tif t != b and t != c:\n\t\tif t%2 == 1:\n\t\t\tprint(30+k+2)\n\t\telse:\n\t\t\tprint(30+k+1)\n\telif t == b and t != c:\n\t\tprint(30+k+2)\n\telse:\n\t\tprint(30+k+3)\nif t == b:\n\tif b != c//2:\n\t\tif b%2 == 1:\n\t\t\tprint(30+(b)//2+5)\n\t\telse:\n\t\t\tprint(30+(b)//2+3)\n\tif t == c//2:\n\t\tif b == c:\n\t\t\tif b%2== 1:\n\t\t\t\tprint(30+(b//2)+6)\n\t\t\telse:\n\t\t\t\tprint(30+(b//2)+4)\nif t == c:\n\tif c%2 == 1:\n\t\tprint(30+c//2+6)\n\telse:\n\t\tprint(30+c//2+4)"}, {"source_code": "a,b,c = map(int,input().split())\nt = max(a,b,c)\nif t == a:\n\tprint(30+a//2+2)\nif t == b:\n\tif b%2 == 1:\n\t\tprint(30+b//2+5)\n\telse:\n\t\tprint(30+b//2+3)\n\nif t == c:\n\tif b%2 == 1:\n\t\tprint(30+c//2+6)\n\telse:\n\t\tprint(30+c//2+4)"}, {"source_code": "r, g, b = map(int, input().split())\n\nma = max(r, max(g, b))\nk = (ma // 2 + ma % 2) * 3 + 30\nif ma == b:\n\tprint(k - 1)\nelif ma == g:\n\tprint(k - 2)\nelse:\n\tprint(k - 3)"}, {"source_code": "r, g, b = map(int, input().split())\n\nma = max(r, max(g, b))\nt = [b, g, r]\ni = t.index(ma)\nif i == 0:\n print(30 + ma // 2 * 3 + 2)\nelif i == 1:\n print(30 + ma // 2 * 3 + 1)\nelse:\n print(30 + ma // 2 * 3)"}, {"source_code": "r, g, b = map(int, input().split())\nif max(b//2 + b % 2,g//2 + g % 2,r//2 + r % 2) == b//2 + b % 2:\n print(29 + 3 * (b//2 + b % 2))\nelif max(r,g,b) == g//2 + g % 2:\n print(28 + 3 * (g//2 + g % 2))\nelse:\n print(27 + 3 * (r//2 + r % 2))\n"}, {"source_code": "r, g, b = map(int, input().split())\nif max(r,g,b) == b:\n print(29 + 3 * (b//2 + b % 2))\nelif max(r,g,b) == g:\n print(28 + 3 * (g//2 + g % 2))\nelse:\n print(27 + 3 * (r//2 + r % 2))\n"}, {"source_code": "r, g, b = map(int, input().split())\nif max(r,g,b) == r:\n print(27 + 3 * (r//2 + r % 2))\nelif max(r,g,b) == g:\n print(28 + 3 * (g//2 + g % 2))\nelse:\n print(29 + 3 * (b//2 + b % 2))\n"}, {"source_code": "r, g, b = map(int, input().split())\nif max(r,g,b) == r:\n print(30 + 3 * (r//2 + r % 2))\nelif max(r,g,b) == g:\n print(30 + 3 * (g//2 + g % 2))\nelse:\n print(30 + 3 * (b//2 + b % 2))\n"}, {"source_code": "import math\nr,g,b=map(int,input().split())\nr,g,b=math.ceil(r/2),math.ceil(g/2),math.ceil(b/2)\nlarge=max(r,g,b) \nif(large==0):\n print(\"0\")\nelif(large==b and b>0):\n print(32+3*(b-1))\nelif(large==g and g>0):\n print(32+2*(g-1))\nelse:\n print(r+31)"}, {"source_code": "#!/usr/bin/python3\n\nt = 0\nr, g, b = map(int, input().split())\n\nwhile r + g + b > 0:\n r -= min(r, 2)\n t += 1\n r, g, b = g, b, r\n\nprint(t + 30)\n"}, {"source_code": "from math import ceil as c\nr,g,b = map(int,input().split())\nk = max(r,g,b)\nif r==g==b:\n\tprint(29+3*(c(k/2)))\nelif k==r:\n\tprint(30+3*c((k/2)-1))\nelif k==g:\n\tprint(31+3*c((k/2)-1))\nelse:\n\tprint(32+3*c((k/2)-1))"}, {"source_code": "r,g,b = map(int,input().split())\nk = max(r,g,b)\nif k==r:\n\tprint(30+3*(k//2))\nelif k==g:\n\tprint(31+3*(k//2))\nelse:\n\tprint(32+3*(k//2))"}, {"source_code": "r,g,b = map(int,input().split())\nk = max(r,g,b)\nif r==g==b:\n\tprint(29+3*(k//2))\nelif k==r:\n\tprint(30+3*(k//2))\nelif k==g:\n\tprint(31+3*(k//2))\nelse:\n\tprint(32+3*(k//2))"}, {"source_code": "r,g,b = map(int,input().split())\nr,g,b = r//2,g//2,b//2\nprint(max(30+r*2,31+g*2,32+b*2))"}, {"source_code": "from math import ceil as c\nl=list(map(lambda x:c(int(x)/2),input().split()))\nfor x in range(3):\n\tif l[x]==max(l):a=x+1\nif l[2]==0 and max(l)==1:print(31)\nelif max(l)>1:print(32+(max(l)-2)*3+a)\nelse:print(32)"}, {"source_code": "from math import ceil as c\nl=list(map(lambda x:c(int(x)/2),input().split()))\nfor x in range(3):\n\tif l[x]==max(l):a=x+1\nif l[2]==0 and max(l)==1:print(31)\nelif max(l)>1:print(32+max(l)-2+a)\nelse:print(32)\n"}, {"source_code": "from math import ceil\nr,g,b = map(int,input().split())\nmaxi = max(r,g,b)\nif maxi == b:\n print(32+ceil((b-2)/2)*3)\nelif maxi == g:\n print(31+ceil((g-2)/2)*3)\nelse:\n print(30+ceil((r-2)/2)*3)"}, {"source_code": "from math import ceil\na,b,c = map(int,input().split())\nr,g,b = ceil(a/2),ceil(b/2),ceil(c/2)\nmaxi = max(r,g,b)\nif maxi == b:\n\tprint(32+3*ceil((c-2)/2))\nelif maxi == g:\n\tprint(31+3*ceil((b-2)/2))\nelif maxi == r:\n\tprint(30+3*ceil((a-2)/2))\n"}, {"source_code": "r,g,b = map(int,input().split())\nans = 30\nif r >= 2:\n r = r-2\nelse:\n r = 0\nif r >= g and r >= b:\n d = (r//2 + r%2)\n ans+= d*3\nelif g > r and g > b:\n d = (g//2)+g%2\n ans+= d+(d-1)*2\nelse:\n d = b//2+b%2\n ans+= d*3-1\nprint(ans)\n"}, {"source_code": "r,g,b = map(int,input().split())\nans = 30\nif r >= 2:\n r = r-2\nelse:\n r = 0\nif r+2 >= g and r+2 >= b:\n d = (r//2 + r%2)\n ans+= d*3\nelif g > r and g > b:\n d = (g//2)+g%2\n ans+= d+(d-1)*2\nelse:\n d = b//2+b%2\n ans+= d*3-1\nprint(ans)"}, {"source_code": "from math import ceil\nr,g,b = map(int,input().split())\nmaxi = max(r,g,b)\nif maxi == b:\n print(32+ceil((c-2)/2)*3)\nelif maxi == g:\n print(31+ceil((b-2)/2)*3)\nelse:\n print(30+ceil((r-2)/2)*3)"}, {"source_code": "r,g,b = map(int,input().split())\nans = 30\nif r >= 2:\n r = r-2\nelse:\n r = 0\nif r+2 > g and r+2 > b:\n d = (r//2 + r%2)\n ans+= d*3\nelif g > r and g > b:\n d = (g//2)+g%2\n ans+= d+(d-1)*2\nelse:\n d = b//2+b%2\n ans+= d*3-1\nprint(ans)"}, {"source_code": "r,g,b = map(int,input().split())\ndef f1(r):\n if r%2 == 0:\n x=3*(r/2-1)\n else:\n x=3*int(r//2)\n return x\nprint(max(f1(r),f1(g)+1,f1(b)+2) + 30)\n\n"}, {"source_code": "import math\na = list(map(int,input().split()))\nb = 0\nd = 0\nfor x in a:\n\tif x > b: b = x\nif a.count(b) > 1:\n\tfor x in range(a.count(b) - 1):a[a.index(b)] = 0\nc = math.ceil(b / 2)\nb = 3 - (a.index(b) + 1)\nprint(30 + ((c * 3)) - 1 -b)\n"}, {"source_code": "import math\na = list(map(int,input().split()))\nb = 0\nd = 0\nfor x in range(len(a)):\n\tif a[x] % 2 != 0:a[x] = a[x] + 1\n\tif x > b:b = a[x]\nif a.count(b) > 1:\n\tfor x in range(a.count(b) - 1):a[a.index(b)] = 0\nc = math.ceil(b / 2)\nb =(3 - (a.index(b) + 1)) + 1\nprint(30 + ((c * 3)) -b)\n"}, {"source_code": "r, g, b = map(int, input().split())\nprint(max(3 * (r - 1) // 2, 1 + 3 * (g - 1) // 2, 2 + 3 * (b - 1) // 2) + 30)"}, {"source_code": "r,g,b=map(int,raw_input().split())\nt=0\nwhile r>0 or g>0 or b>0:\n if t%3==0:\n r-=2\n elif t%3==1:\n g-=2\n else:\n b-=2\n t += 1\nt += 30\nprint t\n"}, {"source_code": "r, g, b = map(int, raw_input().split())\nif r != 0:\n\tr = 30 + (r + 1) // 2 * 3 - 3;\nif g != 0:\n\tg = 31 + (g + 1) // 2 * 3 - 3;\nif b != 0:\n\tb = 23 + (b + 1) // 2 * 3 - 3;\nprint max(r, g, b)\n"}, {"source_code": "from sys import stdin\n\na, b, c = [int(x) for x in stdin.readline().split()]\ntime = 0\nwhile a > 0 or b > 0 or c > 0:\n if c > 0:\n time += 3\n a -= 2\n b -= 2\n c -= 2\n elif b > 0:\n time += 2\n a -= 2\n b -= 2\n elif a > 0:\n time += 1\n a -= 2\n\nprint time + 29\n"}, {"source_code": "s = map(int,raw_input().split())\nr = 29+(max(s)/2)*3\nif max(s)%2==0:\n r = r-3\nif s[2]==max(s):\n r+=3\n print r\n exit(0)\nelif s[1]==max(s):\n r+=2\n print r\n exit(0)\nelse:\n r+=1\n print r\n"}, {"source_code": "s = map(int,raw_input().split())\nr = 29+(max(s)/2)*3\nif s[2]==max(s):\n r+=(s[2]%2)*3\n print r\n exit(0)\nelif s[1]==max(s):\n r+=(s[1]%2)*2\n print r\n exit(0)\nelse:\n r+=(s[0]%2)\n print r\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nr, g, b = map(int, raw_input().split())\nt = -1\nwhile (r > 0 or g > 0 or b > 0):\n if b > 0:\n r -= 2\n g -= 2\n b -= 2\n t += 3\n elif g > 0:\n r -= 2\n g -= 2\n t += 2\n elif r > 0:\n r -= 2\n t += 1\nprint t + 30\n"}, {"source_code": "s = raw_input().split()\nr = int(s[0])\ng = int(s[1])\nb = int(s[2])\n\nM = max(r, g, b)\nif b == M:\n p = 2\nelif g == M:\n p = 1\nelse:\n p = 0\n\nprint (M - 1) / 2 * 3 + p + 30\n"}, {"source_code": "p = [ int(x) for x in raw_input().strip().split() ]\n\nres = 0\nt = 0\nwhile sum(p) > 0:\n print p\n p[t % 3] -= min(2, p[t % 3])\n t += 1\n res += 1\n\nprint res + 29\n\n\n\n"}, {"source_code": "import sys\nfrom math import ceil\n\nr, g, b = map(int, sys.stdin.readline().split())\n\ntr = ceil(r/2.0)\ntg = ceil(g/2.0)\ntb = ceil(b/2.0)\n\nxr = 3*(tr-1)\nxg = 3*(tg-1)+1\nxb = 3*(tb-1)+2\n\nprint xr, xg, xb \n\nprint int(30+max([xr, xg, xb]))\n"}, {"source_code": "r, g, b = map(int, raw_input().split())\nprint ([\n 0 if r==0 else 30+0+3*((r+1)/2-1),\n 0 if g==0 else 30+1+3*((g+1)/2-1),\n 0 if b==0 else 30+2+3*((b+1)/2-1),\n])"}, {"source_code": "import math\n\n\nline = raw_input().split()\na = int(line[0])\nb = int(line[1])\nc = int(line[2])\n\n\nif a == 0 and b == 0 and c == 0:\n print 0\nelif c >= a and c >= b:\n print 29 + int(math.ceil(float(c)/float(2))) * 3 - 0 \nelif b >= a and b >= c:\n print 29 + int(math.ceil(float(b)/float(2))) * 3 - 1 \nelse:\n print 29 + int(math.ceil(float(a)/float(2))) * 3 - 2\n\n \n"}, {"source_code": "import math\n\n\nline = raw_input().split()\na = int(line[0])\nb = int(line[1])\nc = int(line[2])\n\n\nif a == 0 and b == 0 and c == 0:\n print 0\nelif c >= a and c >= b:\n print 30 + (3 * int(math.floor(float(c)/float(2))) + 2)\nelif b >= a and b >= c:\n print 30 + (3 * int(math.floor(float(b)/float(2))) + 1) \nelse:\n print 30 + (3 * int(math.floor(float(a)/float(2))) )\n\n \n"}, {"source_code": "import math\n\n\nline = raw_input().split()\na = int(line[0])\nb = int(line[1])\nc = int(line[2])\n\n\nif a == 0 and b == 0 and c == 0:\n print 0\nelif c >= a and c >= b:\n print 30 + (3 * int(math.floor(float(c)/float(2))) - 1)\nelif b >= a and b >= c:\n print 30 + (3 * int(math.floor(float(b)/float(2))) + 1) \nelse:\n print 30 + (3 * int(math.floor(float(a)/float(2))) )\n\n \n"}, {"source_code": "\n\nr,g,b = map(int,input().split()) \n\ncnt = 0\n\nwhile(r!=0 or b!=0 or g !=0 ) :\n #print(\"flag\")\n \n for i in range(3) :\n \n if i==0 and r!=0:\n \n r = r-2 \n \n if r<0 :\n \n r = 0 \n \n cnt = cnt + 1\n \n if i ==1 and g!=0 :\n \n g = g-2 \n \n if g<0 :\n \n g = 0\n \n cnt =cnt + 1\n if i==2 and b!=0 :\n \n b = b-2 \n \n if b<0 :\n \n b = 0\n \n cnt = cnt + 1\n \n #print(cnt)\n #print(r,g,b)\n \nprint(cnt+30)\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n "}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom math import ceil\n \n \ndef main():\n rgb_list = list(map(int, input().split()))\n result = 30\n MAX_PEOPLE_CAN_GO_IN_CABLE_CAR = 2\n color_mapping = {\"red\": rgb_list[0], \"green\": rgb_list[1], \"blue\": rgb_list[2]}\n total_people = len(rgb_list)\n for i in range(3, total_people, 3):\n if(i < total_people):\n color_mapping[\"red\"] += rgb_list[i]\n if(i+1 < total_people):\n color_mapping[\"green\"] += rgb_list[i+1]\n if(i+2 < total_people):\n color_mapping[\"blue\"] += rgb_list[i+2]\n if(i >= total_people):\n break\n for color_name, color_value in color_mapping.items():\n # import ipdb; ipdb.set_trace()\n if color_name == \"red\" and color_value > MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n color_value -= MAX_PEOPLE_CAN_GO_IN_CABLE_CAR\n elif color_name == \"red\" and color_value <= MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n continue\n if color_name == \"red\" or color_value > MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n result += ceil(color_value / MAX_PEOPLE_CAN_GO_IN_CABLE_CAR)\n if color_value % MAX_PEOPLE_CAN_GO_IN_CABLE_CAR != 0:\n result += 1\n else:\n result += 1\n sys.stdout.write(str(result))\n \n \n# region fastio\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom math import ceil\n \n \ndef main():\n rgb_list = list(map(int, input().split()))\n result = 30\n MAX_PEOPLE_CAN_GO_IN_CABLE_CAR = 2\n color_mapping = {\"red\": rgb_list[0], \"green\": rgb_list[1], \"blue\": rgb_list[2]}\n total_people = len(rgb_list)\n for i in range(3, total_people, 3):\n if(i < total_people):\n color_mapping[\"red\"] += rgb_list[i]\n if(i+1 < total_people):\n color_mapping[\"green\"] += rgb_list[i+1]\n if(i+2 < total_people):\n color_mapping[\"blue\"] += rgb_list[i+2]\n if(i >= total_people):\n break\n for color_name, color_value in color_mapping.items():\n if color_name == \"red\" and color_value > MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n color_value -= MAX_PEOPLE_CAN_GO_IN_CABLE_CAR\n elif color_name == \"red\" and color_value <= MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n continue\n if color_value == \"red\" or color_value > MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n result += ceil(color_value / MAX_PEOPLE_CAN_GO_IN_CABLE_CAR)\n if color_value > MAX_PEOPLE_CAN_GO_IN_CABLE_CAR and color_value % MAX_PEOPLE_CAN_GO_IN_CABLE_CAR != 0:\n result += 1\n else:\n result += 1\n sys.stdout.write(str(result))\n \n \n# region fastio\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom math import ceil\n \n \ndef main():\n rgb_list = list(map(int, input().split()))\n result = 30\n MAX_PEOPLE_CAN_GO_IN_CABLE_CAR = 2\n color_mapping = {\"red\": rgb_list[0], \"green\": rgb_list[1], \"blue\": rgb_list[2]}\n total_people = len(rgb_list)\n for i in range(3, total_people, 3):\n if(i < total_people):\n color_mapping[\"red\"] += rgb_list[i]\n if(i+1 < total_people):\n color_mapping[\"green\"] += rgb_list[i+1]\n if(i+2 < total_people):\n color_mapping[\"blue\"] += rgb_list[i+2]\n if(i >= total_people):\n break\n for color_name, color_value in color_mapping.items():\n if color_name == \"red\" and color_value > MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n color_value -= MAX_PEOPLE_CAN_GO_IN_CABLE_CAR\n elif color_name == \"red\" and color_value <= MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n continue\n if color_value == \"red\" or color_value > MAX_PEOPLE_CAN_GO_IN_CABLE_CAR:\n result += ceil(color_value / MAX_PEOPLE_CAN_GO_IN_CABLE_CAR)\n if color_value % MAX_PEOPLE_CAN_GO_IN_CABLE_CAR != 0:\n result += 1\n else:\n result += 1\n sys.stdout.write(str(result))\n \n \n# region fastio\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n\n#--------------------------------WhiteHat010--------------------------------------#\nr,g,b = get_int_list()\nif r>g and r>b:\n print( ((r-min(r,2))//2 + (r-min(r,2))%2 )*3 + 30 )\nelif g>r and g>b:\n print( ((g-min(g,2))//2 + (g-min(g,2))%2 )*3 + 1 + 30 )\nelse: # b>g and b>r:\n print( ((b-min(b,2))//2 + (b-min(b,2))%2 )*3 + 2 + 30 )"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n\n#--------------------------------WhiteHat010--------------------------------------#\nr,g,b = get_int_list()\nif r>g and r>b:\n print( ((r-2)//2 + (r-2)%2 )*3 + 30 )\nelif g>r and g>b:\n print( ((g-2)//2 + (g-2)%2 )*3 + 1 + 30 )\nelse: # b>g and b>r:\n print( ((b-2)//2 + (b-2)%2 )*3 + 2 + 30 )"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n\n#--------------------------------WhiteHat010--------------------------------------#\nr,g,b = get_int_list()\nif r>g and r>b:\n t = 30\n r = r-min(r,2)\n if r>0:\n t += (r//2 + r%2)*3\n print(t)\nelif g>r and g>b:\n t = 31\n g = g-min(g,2)\n if g>0:\n t += (g//2 + g%2)*3\n print(t)\nelse: # b>g and b>r:\n t = 32\n b = b-min(b,2)\n if b>0:\n t += (b//2 + b%2)*3\n print(t)"}, {"source_code": "r,g,b=list(map(int,input().split()))\nr=r//2+r%2\ng=g//2+g%2\nb=b//2+g%2\nr=(r-1)*3+30\ng=(g-1)*3+31\nb=(b-1)*3+32\nprint(max(r,b,g))\n"}, {"source_code": "def f(l):\n mx = 0\n mp = 0\n for i in range(3):\n if l[i] >= mx:\n mx = l[i]\n mp = i\n t = ((mx-1)//2)*3 + mp\n return t + 30\n\nl = list(map(int,input().split()))\nprint(f(l))\n"}, {"source_code": "import sys\nimport math\nimport bisect\nimport itertools\nimport random\nimport re\n\ndef main():\n r, g, b = map(int, input().split())\n max_val = 0\n if r:\n val = ((r + 1) // 2 - 1) * 3 + 30\n max_val = max(max_val, val)\n if g:\n val = ((g + 1) // 2 - 1) * 3 + 1 + 30\n max_val = max(max_val, val)\n if b:\n val = ((b + 1) // 2 - 1) * 3 + 1 + 30\n max_val = max(max_val, val)\n print(max_val)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import math\nr,g,b = map(int,input().split(\" \"))\nt = 30\nr = math.ceil(r/2)\ng = math.ceil(g/2)\nb = math.ceil(b/2)\nmax = r\nif(b>=r and b>=g):\n max = b\n t = t + 2\nif(g>=r and g>=b):\n max = g\n t = t + 1\nprint(t + (max-1)*3)"}, {"source_code": "r,g,b= list(map(int, input().split(\" \")))\nr = ((r+1)/2-1)* 3 + 30\ng = ((g+1)/2-1)* 3 + 31\nb = ((b+1)/2-1)* 3 + 32\nprint(int(max(r,g,b)))\n"}, {"source_code": "a = list(map(int, input().rstrip().split(\" \")))\n\nm = max(a)\ntotal = m//2 + m%2\nind = 0\nfor i in range(3):\n if a[i] == m:\n ind = i+1\ntotal = 30 + 3*(total-1) + ind - 1\nprint(total)"}, {"source_code": "import math\n\nt=list(map(int,input().split()))\nfor j in range(3):\n t[j]=math.ceil(t[j]/2)\n\n\n\nprint((max(t)-1)*3+t.index(max(t))+30)\n\n"}, {"source_code": "r,g,b = map(int,input().split())\nimport math\nif(r==1):\n r = r-1\nelif(r>=2):\n r=r-2\ntime = 30\nsum = r+g+b\nprint(sum)\nwhile(sum>0):\n\n if(g>0):\n #print('green')\n if(g>=2):\n g = g - 2\n sum=sum-2\n else:\n sum=sum-g\n g = g - 1\n time = time + 1\n if(sum<=0):\n break\n\n #print(sum,g,time)\n\n if(b>0):\n #print('blue')\n if(b>=2):\n b = b - 2\n sum=sum-2\n else:\n sum=sum-b\n b = b - 1\n time = time + 1\n if(sum<=0):\n break\n\n #print(sum, b, time)\n if(r>0):\n if(r>=2):\n r = r - 2\n sum=sum-2\n else:\n sum=sum-r\n r = r - 1\n time = time + 1\n if(sum<=0):\n break\n\n #print(sum, r, time)\n\n\nprint(time)"}], "src_uid": "a45daac108076102da54e07e1e2a37d7"} {"source_code": "ar = list(map(int, input().split()))\nsumo = sum(ar)\nkoi = False\nfor i in range(0, 6):\n for j in range(i + 1, 6):\n for k in range(j + 1, 6):\n sumo1 = ar[i] + ar[j] + ar[k]\n if sumo1 == (sumo - sumo1):\n koi = True\n break\n if koi:\n break\n if koi:\n break\n \nif koi:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "positive_code": [{"source_code": "\nt=[int(k) for k in raw_input().split(\" \")]\n\n\ns=sum(t)\nok=False\nfor i in range(6):\n for j in range(i+1,6):\n for k in range(j+1,6):\n if (t[i]+t[j]+t[k])*2==s:\n ok=True\n break\n \nprint \"YES\" if ok else \"NO\""}, {"source_code": "#\n# Created by Polusummator on 24.10.2020\n# --------- Little PyPy Squad ---------\n# Verdict: \n#\na = [int(i) for i in input().split()]\nz = False\nfor n in range(0, 128):\n b = str(bin(n))[2:]\n b = '0' * (6 - len(b)) + b\n s1, s2 = 0, 0\n k1, k2 = 0, 0\n for i in range(6):\n if b[i] == '1':\n s1 += a[i]\n k1 += 1\n else:\n s2 += a[i]\n k2 += 1\n if s1 == s2 and k1 == k2:\n z = True\n break\nif z:\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "lst = [int(_) for _ in input().split()]\n\nSUM = 0\nfor i in lst:\n SUM += i\n\nif int(SUM) % 2 == 1:\n print(\"NO\")\n exit()\n\nfor a in range(6):\n for b in range(a + 1, 6):\n for c in range(b + 1, 6):\n if lst[a] + lst[b] + lst[c] == SUM / 2:\n print(\"YES\")\n exit()\n\nprint(\"NO\")"}, {"source_code": "l=list(map(int,input().split()))\ns=sum(l)\nfor i in range(6):\n for j in range(i):\n for k in range(j):\n a=l[i]+l[j]+l[k]\n if(a==s-a):\n print(\"YES\")\n exit()\nprint(\"NO\") \n "}, {"source_code": "p=[int(i) for i in input().split()]\nq=sum(p)/2\noutput=False\nfor x1 in range(4):\n for x2 in range(x1+1,5):\n for x3 in range(x2+1,6):\n if p[x1]+p[x2]+p[x3]==q:\n output=True\n break\nif output==False:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "\nfrom itertools import combinations\n\na = list(sorted(map(int, input().split())))\nx = list(combinations(a, 3))\nif sum(a) % 2:\n exit(print('no'))\nz = sum(a) // 2\nfor i in x:\n if sum(i) == z:\n exit(print('yes'))\nprint('no')\n\n"}, {"source_code": "# May the Speedforce be with us...\n'''\nfor _ in range(int(input())):\narr=list(map(int,input().split()))\nn,k=map(int,input().split())\nn=int(input())\ns=input()\n\nfrom collections import defaultdict\nd=defaultdict()\n\nd=dict()\ns=set()\ns.intersection()\ns.union()\ns.difference()\n\n\nproblem statement achhe se padhna hai\nage se bhi dekhna hai, piche se bhi dekhna hai\n'''\nfrom math import gcd,ceil\nfrom collections import defaultdict as dd\ndef lcm(a,b):\n\treturn (a*b)//gcd(a,b)\ndef inin():\n\treturn int(input())\ndef inar():\n\treturn list(map(int,input().split()))\ndef ar(element,size):\n\treturn [element for i in range(size)]\ndef digitsum(num):\n\tsu=0\n\twhile(num):\n\t\tsu+=num%10\n\t\tnum//=10\n\treturn su\n\na=inar()\nn=len(a)\nsu=sum(a)\nif su%2:\n\tprint('NO')\nelse:\n\ts=su//2\n\tans='NO'\n\tfor i in range(0,n-2):\n\t\tfor j in range(i+1,n-1):\n\t\t\tfor k in range(j+1,n):\n\t\t\t\tif a[i]+a[j]+a[k]==s:\n\t\t\t\t\tans='YES'\n\tprint(ans)\n\n\n\n"}, {"source_code": "a = list(map(int, input().split()))\ns = sum(a)\nfor i in range(6):\n for j in range(6):\n for k in range(6):\n if i != j and j != k and i != k:\n s1 = a[i] + a[j] + a[k]\n if s - s1 * 2 == 0:\n print('YES')\n exit()\nprint('NO')\n"}, {"source_code": "from itertools import combinations\n \ndef sss(x,model):\n test_2 = test.copy()\n for i in x: \n test_2.remove(i)\n if sum(test_2) == model:\n return True\n return False\n \ntest =list(map(int, input().split()))\nmodel = sum(test)/2\nflag = False\n \nif not model%1:\n for i in combinations(test,3):\n if sum(i) == model and sss(i,model):\n flag = True\n break\n \nprint('YES' if flag else 'NO')\n"}, {"source_code": "a = list(map(int, input().split()))\ns = sum(a)\nfor i in range(6):\n for j in range(6):\n for k in range(6):\n if i != j and j != k and i != k:\n s1 = a[i] + a[j] + a[k]\n if s - s1 * 2 == 0:\n print('YES')\n exit()\nprint('NO')\n"}, {"source_code": "from itertools import permutations\n\n\ndef read():\n return [int(v) for v in input().split()]\n\n\ndef main():\n a = read()\n for p in permutations(a):\n if sum(p[:3]) == sum(p[3:]):\n print('YES')\n return\n print('NO')\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import itertools\nimport copy\narr=list(itertools.combinations(range(0, 6), 3))\nin_arr=[int(i) for i in input().split()]\n\ndef f(in_arr):\t\n\tin_arr2=copy.deepcopy(in_arr)\n\tfor i in range(len(arr)):\n\t\ta=arr[i][0]\n\t\tb=arr[i][1]\n\t\tc=arr[i][2]\n\t\tsum1=in_arr2[a]+in_arr2[b]+in_arr2[c]\n\t\tsum2=sum(in_arr2)-sum1\n\t\tif sum1==sum2:\n\t\t\treturn 'YES'\n\t\telse:\n\t\t\tin_arr2=copy.deepcopy(in_arr)\n\treturn 'NO'\t\t\t\n\nprint(f(in_arr))\n"}, {"source_code": "a = map(int, raw_input().split())\ns = set()\nfor i in range(6):\n\tfor j in range(i + 1, 6):\n\t\tfor k in range(j + 1, 6):\n\t\t\ts.add(a[i] + a[j] + a[k])\nprint ['NO', 'YES'][not (sum(a) & 1) and sum(a) / 2 in s]"}, {"source_code": "a=map(int,raw_input().split())\ns=sum(a)\nfor i in range(6):\n for j in range(i+1,6):\n for k in range(j+1,6):\n if (a[i]+a[j]+a[k])*2==s:\n print 'YES'\n exit(0)\nprint 'NO'"}, {"source_code": "a = [int(i) for i in input().split()]\ns = sum(a)\ncnt = 0\nif s % 2 != 0:\n print('NO')\n cnt = 1\nelse:\n s //= 2\n summ = 0\n for i in range(len(a)):\n for j in range(len(a)):\n for k in range(len(a)):\n if i != j and i != k and k != j and a[i] + a[j] + a[k] == s:\n print('Yes')\n cnt = 1\n break\n if cnt:\n break\n if cnt:\n break\nif not cnt:\n print('NO')"}, {"source_code": "import sys\na, b, c, d, e, f = (int(x) for x in raw_input().split())\nif (a+b+c+d+e+f)%2:\n print \"NO\"\n sys.exit()\ngoal = (a+b+c+d+e+f)/2\ncan = False\ncan |= goal == a+b+c\ncan |= goal == a+b+d\ncan |= goal == a+b+e\ncan |= goal == a+b+f\ncan |= goal == a+c+d\ncan |= goal == a+c+e\ncan |= goal == a+c+f\ncan |= goal == a+d+e\ncan |= goal == a+d+f\ncan |= goal == a+e+f\n\nprint \"YES\" if can else \"NO\""}, {"source_code": "a = list(map(int, input().split(' ')))\n\nans = 0\n\nfor i in range(6):\n\tfor j in range(i + 1, 6):\n\t\tfor k in range(j + 1, 6):\n\t\t\tn = list(range(6))\n\t\t\tsum1 = a[i] + a[j] + a[k]\n\t\t\tn.remove(i)\n\t\t\tn.remove(j)\n\t\t\tn.remove(k)\n\t\t\tsum2 = 0\n\t\t\tfor h in n:\n\t\t\t\tsum2 += a[h]\n\t\t\tif sum1 == sum2:\n\t\t\t\tans += 1\n\t\t\t\tbreak\n\nif ans > 0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "import sys\nimport itertools\n\ndef main():\n ar = map(int, raw_input().split())\n combinations = list(itertools.combinations(ar, 3))\n print \"YES\" if any(sum(subset) * 2 == sum(ar) for subset in combinations) else \"NO\"\n \nif __name__ == '__main__':\n main() \n \n"}, {"source_code": "arr = map(int, raw_input().split())\ns = sum(arr)\nfor g in range(1<<6):\n q = 0\n m = 0\n for i in range(6):\n if (g >> i) & 1:\n q += arr[i]\n m += 1\n if m == 3 and 2 * q == s:\n print \"YES\"\n break\nelse:\n print \"NO\""}, {"source_code": "'''input\n1 1 1 1 1 99\n'''\n\nimport sys\nsys.setrecursionlimit(10000000)\ndebug = 1\n\ndef readint():\n return int(raw_input())\n\ndef readints():\n return map(int, raw_input().split())\n\ndef readstr():\n return raw_input()\n\ndef readstrs():\n return raw_input().split() \n\ndef dprint(*args):\n if debug: print(' '.join(map(str, args)))\n\ndef solve():\n _sum = sum(s)\n if _sum % 2 != 0: return 0\n mid = _sum / 2\n for i in xrange(0, 6):\n for j in xrange(i+1, 6):\n for k in xrange(j+1, 6):\n if s[i] + s[j] + s[k] == mid: return 1\n return 0 \n\ns = readints()\nprint \"YES\" if solve() else \"NO\""}, {"source_code": "aTab = map(int, raw_input().split(' '))\nsum1 = 0\nsum2 = 0\ncheck = 0\nfor i in range(6):\n\tfor j in range(i+1,6):\n\t\tfor k in range(j+1,6):\n\t\t\tsum1 = aTab[i] + aTab[j] + aTab[k]\n\t\t\tif(sum(aTab) == 2*sum1):\n\t\t\t\tcheck = 1\n\t\t\t\tbreak\nif check == 1:\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "from itertools import combinations\na = map(int, raw_input().split())\nsa = sum(a)\nans = \"NO\"\nfor i in combinations(a, 3):\n t = sum(i)\n if t + t == sa:\n ans = \"YES\"\n break\nprint ans "}, {"source_code": "l=list(map(int,input().split()))\nl.sort()\na=l[0]+l[5]+l[2]\nb=l[0]+l[5]+l[3]\nc=l[1]+l[4]+l[3]\nd=l[1]+l[4]+l[2]\ne=l[0]+l[3]+l[4]\nf=l[1]+l[2]+l[5]\ng=l[0]+l[1]+l[5]\nh=l[4]+l[3]+l[2]\ni=l[1]+l[2]+l[3]\nj=l[0]+l[4]+l[5]\nk=l[2]+l[3]+l[4]\nl=l[0]+l[1]+l[5]\nif (a==c):\n print(\"YES\")\nelif (b==d):\n print(\"YES\")\nelif e==f:\n print(\"YES\")\nelif g==h:\n print(\"YES\")\nelif i==j:\n print(\"YES\")\nelif k==l:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "lst=map(int,raw_input().split())\ns=sum(lst)\nif s%2:\n print \"NO\"\nelse:\n s=s/2\n for i in range(0,6):\n for j in range(0,6):\n for k in range(0,6):\n if i!=j and j!=k and i!=k:\n if lst[i]+lst[j]+lst[k]==s:\n print \"YES\"\n exit()\n print \"NO\"\n"}, {"source_code": "a = list(map(int, input().split()))\ns = sum(a)\n\npos = False\n\nfor i in range(6):\n for j in range(6):\n if i == j: continue\n\n for k in range(6):\n if i == k: continue\n if j == k: continue\n\n if s - a[i] - a[j] - a[k] == s // 2:\n pos = True\n\nif pos and s % 2 == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "def main():\n\n from itertools import permutations\n\n arr = map(int, raw_input().split())\n\n for i in permutations(arr):\n\n a = sum(i[: 3])\n b = sum(i[3: ])\n if a == b:\n return \"YES\"\n return \"NO\"\n\n\nprint main()"}, {"source_code": "import sys\n\narr = [int(x) for x in input().split()]\ns = sum(arr)\n\nif s % 2 == 1:\n print(\"NO\")\n sys.exit(0)\nfor i in range(4):\n target = (s // 2) - arr[i]\n dic = {}\n for j in range(i + 1, 6):\n if dic.get(target - arr[j], None) != None:\n print(\"YES\")\n sys.exit(0)\n dic[arr[j]] = j\n\nprint(\"NO\")\n"}, {"source_code": "a=[int(i) for i in input().split()]\nb=sum(a)\na.sort()\nif b%2==0:\n for i in range(5):\n if b//2-a[i]-a[-1] in a[i+1:-1] or b//2-a[i]-a[-1] in a[:i]:\n print('YES')\n quit()\nprint('NO')\n"}, {"source_code": "b=list(map(int,input().split()))\nfor i in range(1<<6):\n s=s1=n=k=0\n for j in range(6):\n if i&(1<<j):s+=b[j];n+=1\n else:s1+=b[j];k+=1\n if s==s1 and n==k:exit(print(\"YES\"))\nprint(\"NO\")"}, {"source_code": "def check(k, n, w):\n global a\n if w < 0:\n return 0\n if w == 0 and k == 0:\n return 1\n if k == 0:\n return 0\n if n == 0:\n return 0\n if check(k - 1, n - 1, w - a[6 - n]) or check(k, n - 1, w):\n return 1\n return 0\n \n\n\na = list(map(int, input().split()))\ns = sum(a)\nif s % 2:\n print('NO')\nelif check(3, 6, s // 2):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import itertools\nnumbers = [int(i) for i in input().split()]\nall_variants = itertools.permutations(numbers)\nfor variant in all_variants:\n\tif sum(variant[:3]) == sum(variant[3:]):\n\t\tprint('YES')\n\t\texit()\nprint('NO')"}, {"source_code": "arr = list(map(int, input().split()))\n\ndef summArr(arr):\n\tans = 0\n\tfor i in arr:\n\t\tans += i\n\treturn ans\n\ndef NoRun(arr):\n\ti = 0\n\tans = []\n\tarr1 = set(arr)\n\twhile i < 6:\n\t\tif not(i in arr1):\n\t\t\tans.append(i)\n\t\ti+=1\n\treturn ans\n\n\n\ndef MMain(arr):\n\ti = 0\n\tsumm1 = 0\n\tsumm2 = 0\n\tans = \"\"\n\twhile i < len(arr):\n\t\tj = i + 1\n\t\twhile j < len(arr):\n\t\t\tk = j + 1\n\t\t\twhile k < len(arr):\n\t\t\t\tNoRun1 = NoRun([i, j, k])\n\t\t\t\tsumm1 = arr[i] + arr[j] + arr[k]\n\t\t\t\tsumm2 = arr[NoRun1[0]] + arr[NoRun1[1]] + arr[NoRun1[2]]\n\t\t\t\tif summ1 == summ2:\n\t\t\t\t\tans = \"YES\"\n\t\t\t\tk+=1\n\t\t\tj+=1\n\t\ti+=1\n\t\n\tif len(ans) != 0:\n\t\treturn ans\n\telse:\n\t\treturn \"NO\"\ndef main():\n\tif summArr(arr) % 2 == 0:\n\t\tprint(MMain(arr))\n\telse: \n\t\tprint(\"NO\")\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "def equal_team (seq):\n\tseq.sort()\n\tif sum(seq)%2 != 0 :\n\t\treturn \"NO\"\n\telse :\n\t\tteam_score = sum(seq)//2\n\t\tfor x in range(3):\n\t\t\tfor y in range(x+1,5):\n\t\t\t\tif seq[-1] + seq[x] + seq[y] == team_score :\n\t\t\t\t\treturn \"YES\"\n\t\treturn \"NO\"\n\n\nseq = list(map(int,input().split()))\nprint (equal_team(seq))\n\n\n\n\n\n\t\t\t\n\n\n\n"}, {"source_code": "k = list(map(int, input().split(' ')))\nif k[0] + k[1] + k[3] == k[2] + k[4] + k[5] or k[0] + k[1] + k[2] == k[3] + k[4] + k[5] or k[0] + k[1] + k[4] == k[2] + k[3] + k[5] or k[0] + k[1] + k[5] == k[3] + k[4] + k[2] or k[0] + k[2] + k[3] == k[1] + k[4] + k[5] or k[0] + k[2] + k[4] == k[1] + k[3] + k[5] or k[0] + k[2] + k[5] == k[1] + k[4] + k[3] or k[0] + k[4] + k[3] == k[1] + k[2] + k[5] or k[0] + k[5] + k[3] == k[1] + k[4] + k[2] or k[0] + k[4] + k[5] == k[1] + k[2] + k[3]:\n\tprint('Yes')\nelse:\n\tprint('No')"}, {"source_code": "a=list(map(int,input().split()))\nsolved=False\nfor i in range(len(a)) :\n for j in range(i+1,len(a)) :\n for k in range(j+1,len(a)) :\n rest=a.copy()\n g=a[i]+a[j]+a[k]\n rest.remove(a[i])\n rest.remove(a[j])\n rest.remove(a[k])\n if sum(rest)==g :\n print('YES')\n solved=True\n break\n if solved==True :\n break\n if solved==True :\n break\nif solved==False :\n print('NO')\n \n \n"}, {"source_code": "m=list(map(int,input().split(' ')))\na=sum(m)\np=True\nfor i in range(6):\n if not p:\n break\n for j in range(i+1,6):\n if not p:\n break\n for x in range(j+1,6):\n b=m[i]+m[j]+m[x]\n if b==a-b:\n print('YES')\n p=False\n break\nif p:\n print('NO')"}, {"source_code": "c=list(map(int,input().split()))\nwhile(True):\n\tif(c[0]+c[1]+c[2]==c[3]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[1]+c[3]==c[2]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[1]+c[4]==c[2]+c[3]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[1]+c[5]==c[2]+c[3]+c[4]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[2]+c[3]==c[1]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[2]+c[4]==c[1]+c[3]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[2]+c[5]==c[1]+c[3]+c[4]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[3]+c[4]==c[1]+c[2]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[3]+c[5]==c[1]+c[2]+c[4]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[4]+c[5]==c[1]+c[2]+c[3]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telse:\n\t\tprint(\"NO\")\n\t\tbreak"}, {"source_code": "powers = [int(n) for n in input().split()]\npowers.sort()\ntp = sum(powers)\nok = False\nif tp %2 ==1:\n print('NO')\nelse :\n for i in range(len(powers)-2):\n for j in range(i+1, len(powers)-1):\n for k in range(j+1, len(powers)):\n if powers[i]+powers[j]+powers[k] == tp//2:\n print('YES')\n ok = True\n break\n if ok == True:\n break\n if ok == True:\n break\n if ok == False:\n print('NO')\n\n"}, {"source_code": "import itertools\npowers = list(map(int, input().split()))\ncombs = list(itertools.permutations(powers, r=3))\n#print(list(combs))\nfor i in range(len(combs)):\n if sum(combs[i]) == sum(powers)-sum(combs[i]):\n print('YES')\n break\nelse:\n print('NO') "}, {"source_code": "from itertools import combinations\n\nl = [int(x) for x in input().split()]\n\ns = sum(l)\nif s % 2 == 1:\n print(\"NO\")\n exit(0)\n\nfor i in combinations(l, 3):\n if sum(i) == s // 2:\n print(\"YES\")\n break\nelse:\n print(\"NO\")"}, {"source_code": "a, b, c, d, e, f = list(map(int, input().split()))\nif a + b + c == d + e + f or a + b + d == c + f + e or a + b + f == c + d + e or a + b + e == c + d + f or a + c + d == b + f + e or a + c + e == b + d + f or a + c + f == b + d + e or a + d + e == b + c + f or a + d + f == b + c + e or a + e + f == b + c + d:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = list(map(int, input().split()))\n\na = sum(s)\n\nif a % 2 == 1:\n print(\"NO\")\n exit()\n\na //= 2\n\nfrom itertools import combinations\n\ns = combinations(s, 3)\n\ns = [sum(i) for i in s]\n\nfor i in s:\n if i == a:\n print(\"YES\")\n break\nelse:\n print(\"NO\")\n\n"}, {"source_code": "from sys import stdin, stdout\nfrom itertools import permutations\ndata = stdin.readline().rstrip().split(' ')\n#find sum\ntotal = 0\nfoundit=False\nfor i in data:\n i = int(i)\n total += i\nif total % 2 == 0:\n triple_pairs = permutations(data,3)\n for pair in triple_pairs:\n pair_l = [int(x) for x in pair]\n pair_sum = pair_l[0]+pair_l[1]+pair_l[2]\n if pair_sum == total/2:\n stdout.write('YES')\n foundit = True\n break\n if not foundit:\n stdout.write('NO')\nelse:\n stdout.write('NO')"}, {"source_code": "def main():\n nums = [int(x) for x in input().split(' ')]\n total = sum(nums)\n for i in range(len(nums)):\n for j in range(i+1, len(nums)):\n for k in range(j+1, len(nums)):\n score = nums[i] + nums[j] + nums[k]\n if total - score == score:\n return True\n return False\n\n\nres = main()\nif res:\n print('YES')\nelse:\n print('No')"}, {"source_code": "import sys\n\na = list(map(int, sys.stdin.readline().split()))\nr = sum(a)\n\nif r % 2 != 0:\n print(\"NO\")\n exit(0)\n\nk = r // 2\n\nif a[0] + a[1] + a[2] == k:\n print(\"YES\")\nelif a[0] + a[1] + a[3] == k:\n print(\"YES\")\nelif a[0] + a[1] + a[4] == k:\n print(\"YES\")\nelif a[0] + a[1] + a[5] == k:\n print(\"YES\")\nelif a[0] + a[2] + a[3] == k:\n print(\"YES\")\nelif a[0] + a[2] + a[4] == k:\n print(\"YES\")\nelif a[0] + a[2] + a[5] == k:\n print(\"YES\")\nelif a[0] + a[3] + a[4] == k:\n print(\"YES\")\nelif a[0] + a[3] + a[5] == k:\n print(\"YES\")\nelif a[0] + a[4] + a[5] == k:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "nums = list(map(int, input().split()))\n\ntotal = sum(nums)\n\ndef calc():\n for i in range(0, 4):\n for j in range(i+1, 5):\n for k in range(j+1, 6):\n if (nums[i]+nums[j]+nums[k]) == (total - (nums[i]+nums[j]+nums[k])):\n return \"YES\"\n return \"NO\"\n \nans = calc()\n\nprint(ans)"}, {"source_code": "from itertools import permutations\ndef ok(arr1):\n for i in list(permutations(arr1,6)):\n if sum(i[:3])==sum(i[3:]):\n return True\n return False\narr1=list(map(int,input().split()))\nif ok(arr1):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import itertools\nimport sys\n\na = list(map(int, input().split()))\nfor a1, a2, a3, a4, a5, a6 in itertools.permutations(a):\n\tif a1 + a2 + a3 == a4 + a5 + a6:\n\t\tprint(\"YES\")\n\t\tsys.exit(0)\nprint(\"NO\")"}, {"source_code": "l=list(map(int,input().split()))\ns=sum(l)\nf=0\nfor i in range(4):\n for j in range(i+1,5):\n for k in range(j+1,6):\n x=l[i]+l[j]+l[k]\n if((s-x)==x):\n f=1\n break\n if(f==1):\n break\n if(f==1):\n break\nif(f==0):\n print(\"NO\")\nelse:\n print(\"YES\")\n "}, {"source_code": "# Belongs to : midandfeed aka asilentvoice\nq = [int(x) for x in input().split()]\ns = sum(q)\nfound = False\nfor i in range(6-2):\n\tfor j in range(i+1, 6-1):\n\t\tfor k in range(j+1, 6):\n\t\t\ttemp = q[i] + q[j] + q[k]\n\t\t\tif ( s-temp == temp ):\n\t\t\t\tfound = True\n\t\t\t\tbreak\n\tif found:\n\t\tbreak\nprint([\"NO\", \"YES\"][found])\n\t\n\t"}, {"source_code": "lst = []\nfor x in input().split():\n lst.append(int(x))\n\nlst.sort()\nif lst[0] + lst[1] + lst[-1] == lst[2] + lst[3] + lst[4]:\n print(\"YES\")\nelif lst[0] + lst[-2] + lst[-1] == lst[1] + lst[2] + lst[3]:\n print(\"YES\")\nelif lst[1] + lst[2] + lst[-1] == lst[0] + lst[3] + lst[4]:\n print(\"YES\")\nelif lst[0] + lst[2] + lst[-1] == lst[1] + lst[3] + lst[4]:\n print(\"YES\")\nelif lst[0] + lst[-1] + lst[3] == lst[1] + lst[2] + lst[4]:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "scores = list(map(int,input().strip().split(' ')))\n\ntot = sum(scores)\n\nif tot & 1:\n\tprint('NO')\n\nelse:\n\tbscore = tot // 2\n\tans = 'NO'\n\n\tfor i in range(4):\n\t\tfor j in range(i+1,5):\n\t\t\tfor k in range(j+1,6):\n\t\t\t\tif scores[i]+scores[j]+scores[k] == bscore:\n\t\t\t\t\tans = 'YES'\n\t\t\t\t\tbreak\n\n\tprint(ans)"}, {"source_code": "\n\nnum1,num2,num3,num4,num5,num6=input().split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nsum1=num1+num2\nsum2=num1+num3\nsum3=num1+num4\nsum4=num1+num5\nsum5=num1+num6\nsum6=num2+num3\nsum7=num2+num4\nsum8=num2+num5\nsum9=num2+num6\nsum10=num3+num4\nsum11=num3+num5\nsum12=num3+num6\nsum13=num4+num5\nsum14=num4+num6\nsum15=num5+num6\n\n\nif(num1+sum6 == num4+sum15):\n print(\"YES\")\nelif (num1+sum7 == num3+sum15):\n print(\"YES\")\nelif (num1+sum8 == num3+sum14):\n print(\"YES\")\nelif (num1+sum9 == num3+sum13):\n print(\"YES\")\nelif (num1+sum10 == num2+sum15):\n print(\"YES\")\nelif (num1+sum11 == num2+sum14):\n print(\"YES\")\nelif (num1+sum12 == num2+sum13):\n print(\"YES\")\nelif (num1+sum13 == num2+sum12):\n print(\"YES\")\nelif (num1+sum14 == num2+sum11):\n print(\"YES\")\nelif (num1+sum15 == num2+sum10):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n\n\n \n "}, {"source_code": "seq=list(map(int, input().split()))\ntotsum=sum(seq)\nans=False\nfor i in range(1<<6):\n count=0\n tempsum=0\n for j in range(6):\n if(i & 1<<j):\n count+=1\n tempsum+=seq[j]\n if(count==3 and (2*tempsum==totsum)):\n ans=True\n break\nif(ans):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a = list(map(int,input().split()))\nfor m in range(len(a)):\n for n in range(m+1,len(a)):\n for p in range(n+1,len(a)):\n if (sum(a)%2==0) and ((a[m] + a[n] + a[p])==sum(a)//2):\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "a = list(map(int,input().split()))\nn = sum(a)\nfor i in range(len(a)-2):\n for j in range(i+1,len(a)-1):\n for k in range(j+1,len(a)):\n if n-(a[i]+a[j]+a[k])==n/2:\n print('YES')\n quit()\nprint('NO')"}, {"source_code": "def list_output(s): \n print(' '.join(map(str, s)))\n \ndef list_input():\n return list(map(int, input().split()))\n\nimport itertools\n\ns = list_input()\nperm = list(itertools.permutations(s))\nfor p in perm:\n x = p[0]+p[1]+p[2]\n y = p[3]+p[4]+p[5]\n if x == y:\n print('YES')\n exit(0)\nprint('NO')"}, {"source_code": "def permute(xs, low=0):\n if low + 1 >= len(xs):\n yield xs\n else:\n for p in permute(xs, low + 1):\n yield p \n for i in range(low + 1, len(xs)): \n xs[low], xs[i] = xs[i], xs[low]\n for p in permute(xs, low + 1):\n yield p \n xs[low], xs[i] = xs[i], xs[low]\n\ni=input().split();\nfor p in permute([int(i[0]), int(i[1]), int(i[2]), int(i[3]), int(i[4]), int(i[5])]):\n if p[0]+p[1]+p[2]==p[3]+p[4]+p[5]:\n print(\"YES\")\n exit(0)\nprint(\"NO\")\n"}, {"source_code": "\na1,a2,a3,a4,a5,a6= input().split()\na1=int(a1)\na2=int(a2)\na3=int(a3)\na4=int(a4)\na5=int(a5)\na6=int(a6)\n\nif a1+a2+a3 == a4+a5+a6:\n print(\"yes\")\nelif a1+a2+a4 == a3+a5+a6:\n print(\"yes\")\nelif a1+a2+a5 == a4+a3+a6:\n print(\"yes\")\nelif a1+a2+a6 == a4+a5+a3:\n print(\"yes\")\nelif a1+a3+a4 == a2+a5+a6:\n print(\"yes\") \nelif a1+a3+a5 == a2+a4+a6:\n print(\"yes\")\nelif a1+a3+a6 == a4+a5+a2:\n print(\"yes\")\nelif a1+a4+a5 == a2+a3+a6:\n print(\"yes\")\nelif a1+a4+a6 == a2+a5+a3:\n print(\"yes\")\nelif a1+a5+a6 == a4+a2+a3:\n print(\"yes\")\nelse:\n print(\"No\")"}, {"source_code": "ar=list(map(int,input().split()))\nfor i in range(6):\n for j in range(i):\n for k in range(j):\n if(2*(ar[i]+ar[j]+ar[k])==sum(ar)):\n print(\"YES\")\n quit()\nprint(\"NO\")\n"}, {"source_code": "import sys\na = list(map(int, input().split()))\nif sum(a) % 2 == 0:\n for i in range(6):\n for j in range(i+1,6):\n for k in range(j+1,6):\n if a[i]+a[j]+a[k]==sum(a)//2:\n print(\"YES\")\n sys.exit()\nprint(\"NO\")"}, {"source_code": "a = list(map(int, input().split()))\ns = sum(a)\nflag = False\nfor i in range(0, 6):\n for j in range(i + 1, 6):\n for k in range(j + 1, 6):\n if a[i] + a[j] + a[k] == s / 2:\n flag = True\nif flag:\n print(\"yes\")\nelse:\n print(\"no\")"}, {"source_code": "a = [int(x) for x in input().split()]\nif sum(a) % 2 == 1:\n print('NO')\n exit(0)\nb = sum(a) // 2\nfor i in range(4):\n for j in range(i + 1, 5):\n for k in range(j + 1, 6):\n if a[i] + a[j] + a[k] == b:\n print('YES')\n exit(0)\nprint('NO')\n"}, {"source_code": "\n\n\ndef is_partitionable(arr):\n\tfor bitmask in range(2**6):\n\t\tnum_people = 0\n\t\tval = 0\n\t\tfor pos in range(6):\n\t\t\tbit = (bitmask >> pos) & 1\n\t\t\tif bit == 1:\n\t\t\t\tval += arr[pos]\n\t\t\t\tnum_people += 1\n\n\t\tif num_people == 3 and 2*val == sum(arr):\n\t\t\treturn True\n\n\treturn False\n\narr = [int(x) for x in input().split()]\n\nprint('YES' if is_partitionable(arr) else 'NO')\n\n"}, {"source_code": "n1,n2,n3,n4,n5,n6 =input().split()\nn1=int(n1)\nn2=int(n2)\nn3=int(n3)\nn4=int(n4)\nn5=int(n5)\nn6=int(n6)\nif n1+n2+n3 == n4+n5+n6: print(\"Yes\")\nelif n1+n2+n4 == n3+n5+n6: print(\"Yes\")\nelif n1+n2+n5 == n4+n3+n6: print(\"Yes\")\nelif n1+n2+n6 == n4+n5+n3: print(\"Yes\")\nelif n1+n4+n3 == n2+n5+n6: print(\"Yes\")\nelif n1+n5+n3 == n2+n4+n6: print(\"Yes\")\nelif n1+n6+n3 == n2+n5+n4: print(\"Yes\")\nelif n1+n4+n5 == n2+n3+n6: print(\"Yes\")\nelif n1+n4+n6 == n2+n5+n3: print(\"Yes\")\nelif n1+n5+n6 == n2+n3+n4: print(\"Yes\")\nelse: print(\"No\")"}, {"source_code": "l=[int(x) for x in input().split()]\ns=sum(l)\nflag=0\nfor i in range(4):\n for j in range(i+1,5):\n for k in range(j+1,6):\n if (l[i]+l[j]+l[k])*2==s:\n flag=1 \nif s%2 :\n flag=0\nif flag:\n print(\"yes\")\nelse:\n print(\"no\")"}, {"source_code": "l=[int(x) for x in input().split()]\ns=sum(l)\nflag=0\nfor i in range(4):\n for j in range(i+1,5):\n for k in range(j+1,6):\n if (l[i]+l[j]+l[k])*2==s:\n flag=1 \nif flag:\n print(\"yes\")\nelse:\n print(\"no\")"}, {"source_code": "from sys import stdin\nn = 6\na = map(int,stdin.readline().split())\nans = 'No'\ns = sum(a)\nfor i in xrange(n):\n for j in xrange(i+1,n):\n for k in xrange(j+1,n):\n fir = a[i] + a[j] + a[k]\n sec = s - fir\n if fir==sec:\n ans = 'Yes'\nprint ans"}, {"source_code": "A,B,C,D,E,F= input(\"\").split()\nA=int(A)\nB=int(B)\nC=int(C)\nD=int(D)\nE=int(E)\nF=int(F)\na1=A+B+C\na2=D+E+F\nb1=A+C+D\nb2=B+E+F\nc1=A+D+E\nc2=B+C+F\nd1=A+E+F\nd2=B+C+D\ne1=A+F+B\ne2=C+D+E\nf1=B+D+F\nf2=A+C+E\ng1=A+B+E\ng2=C+D+F\nh1=B+C+E\nh2=A+D+F\ni1=A+B+D\ni2=C+E+F\nj1=A+C+F\nj2=B+D+E\nif a1==a2:\n print(\"YES\")\nelif b1==b2:\n print(\"YES\")\nelif c1==c2:\n print(\"YES\")\nelif d1==d2:\n print(\"YES\")\nelif e1==e2:\n print(\"YES\")\nelif f1==f2:\n print(\"YES\")\nelif g1==g2:\n print(\"YES\")\nelif h1==h2:\n print(\"YES\")\nelif i1==i2:\n print(\"YES\")\nelif j1==j2:\n print(\"YES\") \nelse:\n print(\"NO\")"}, {"source_code": "A=[int(i) for i in input().split(\" \")]\nflag=0\nfor i in range(len(A)):\n for j in range(i+1,len(A)):\n for k in range(j+1,len(A)):\n if A[i]+A[j]+A[k]==sum(A)-A[i]-A[j]-A[k]:\n flag=1\nprint(\"YES\") if flag else print(\"NO\")\n"}, {"source_code": "num1,num2,num3,num4,num5,num6=input().split()\n\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nif(num1+num2+num3==num4+num5+num6):\n print('Yes')\n \nelif(num2+num3+num4==num1+num5+num6):\n print('Yes')\n \nelif(num3+num4+num5==num1+num2+num6):\n print('Yes')\nelif(num1+num3+num5==num2+num4+num6):\n print('Yes')\nelif(num1+num2+num4==num3+num5+num6):\n print('Yes')\nelif(num1+num2+num5==num3+num4+num6):\n print('Yes')\nelif(num1+num3+num4==num2+num5+num6):\n print('Yes')\nelif(num1+num3+num6==num2+num4+num5):\n print('Yes')\nelif(num2+num3+num5==num1+num4+num6):\n print('Yes')\nelif(num2+num3+num6==num1+num4+num5):\n print('Yes')\nelse:\n print('No')"}, {"source_code": "import itertools\na=list(map(int,input().split()))\ns=sum(a)\nif s%2!=0:\n print(\"NO\")\n exit\nelse:\n for i in itertools.permutations(a,r=3):\n if sum(i)==s//2:\n print(\"YES\")\n #print(i)\n exit(0)\n print(\"NO\") "}, {"source_code": "n = [int(i) for i in input().split()]\np = ['012','013','014','015','123','124','125','234','235','345','023','024','025','034','035','045','134','135','145','245']\ntry:\n for i in p:\n if sum([n[int(j)] for j in i]) == sum(n)/2:\n print('YES')\n 3/0\n print('NO')\nexcept ZeroDivisionError:\n pass"}, {"source_code": "#!/usr/bin/env python2.7\n\nimport sys\n\n\ndef main():\n a = map(int, sys.stdin.readline().strip().split())\n\n assert len(a) == 6\n\n s = sum(a)\n\n if s % 2 == 1:\n print 'NO'\n return\n\n g = s / 2\n\n a = sorted(a)\n first = a[0]\n i = 1\n j = len(a) - 1\n\n while i != j:\n c = first + a[i] + a[j]\n if c == g:\n print 'YES'\n return\n\n if c < g:\n i += 1\n else:\n j -= 1\n\n print 'NO'\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "from itertools import permutations\nl=list(map(int,input().split()))\ncount=0\ntemp=permutations(l)\nfor i in temp:\n #print(len(i)//2)\n m=i[:len(i)//2]\n n=i[len(i)//2:]\n #print(m)\n #print(n)\n if(sum(m)==sum(n)):\n count+=1\n break\nif(count!=0):\n print(\"yes\")\nelse:\n print(\"no\")\n"}, {"source_code": "a = map(int, raw_input().split())\nt = sum(a)\nif t % 2 == 1:\n print \"NO\"\nelse:\n p = False\n for j in range(len(a)):\n for i in range(j + 1, len(a)):\n for k in range(i + 1, len(a)):\n if (a[j] + a[k] + a[i]) * 2 == t:\n p = True\n\n if p:\n print \"YES\"\n else:\n print \"NO\"\n#test222"}, {"source_code": "a = map(int, raw_input().split())\nt = sum(a)\nif t % 2 == 1:\n print \"NO\"\nelse:\n p = False\n for j in range(len(a)):\n for i in range(j + 1, len(a)):\n for k in range(i + 1, len(a)):\n if (a[j] + a[k] + a[i]) * 2 == t:\n p = True\n\n if p:\n print \"YES\"\n else:\n print \"NO\"\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n#test\n"}, {"source_code": "a = input().split()\ns = 0\nfor i in a:\n\ts += int(i)\nif s % 2 != 0:\n\tprint(\"NO\")\nelse:\n\tflag = False\n\ts = s // 2\n\tfor i in range(0,6):\n\t\tfor j in range(0,6):\n\t\t\tif i == j:\n\t\t\t\tcontinue\n\t\t\tfor k in range(0,6):\n\t\t\t\tif i == k or j == k :\n\t\t\t\t\tcontinue\n\t\t\t\tif (int(a[i]) + int(a[j]) + int(a[k])) == s:\n\t\t\t\t\tflag = True\n\t\t\t\t\tbreak\n\t\t\tif flag == True:\n\t\t\t\tbreak\n\t\tif flag == True:\n\t\t\tbreak\n\tif flag == False:\n\t\tprint(\"NO\")\n\telse :\n\t\tprint(\"YES\")\n \n"}, {"source_code": "d=list(map(int, input().split()))\ns=sum(d)/2\nif s%1!=0:\n print(\"NO\")\n exit()\nd.sort()\nif d[5]+d[0]+d[1]>s:\n print(\"NO\")\n exit()\ne=s-d[5]-d[0]\nif e in d[1:5]:\n print(\"YES\")\n exit()\ne=s-d[5]-d[1]\nif e in d[2:5]:\n print(\"YES\")\n exit()\ne=s-d[5]-d[2]\nif e in d[3:5]:\n print(\"YES\")\n exit()\nprint(\"NO\")\n\n\n"}, {"source_code": "a = list(map(int, input().split()))\nif sum(a) % 2 == 1:\n print('NO')\nelse:\n target = sum(a) // 2\n n = 6\n ans = 'NO'\n for i in range(n):\n for j in range(i + 1, n):\n for k in range(j + 1, n):\n if a[i] + a[j] + a[k] == target:\n ans = 'YES'\n print(ans)"}, {"source_code": "import itertools\nsuc = False\nsc = [int(x) for x in raw_input().strip().split()]\nif sum(sc) %2 ==0:\n sc.sort()\n sm = sum(sc)/2\n se = list(itertools.combinations(sc,3))\n se = [x for x in se if sum(x)==sm]\n for x in se:\n ls = [y for y in sc]\n ls.remove(x[0])\n ls.remove(x[1])\n ls.remove(x[2])\n if sum(ls) == sm:\n suc = True\n break\n\nprint \"Yes\" if suc else \"No\""}, {"source_code": "a = list(map(int, input().split()))\nsuma = sum(a)\nn = 6\nans = 'NO'\nfor i in range(n):\n for j in range(i + 1, n):\n for k in range(j + 1, n):\n if (a[i] + a[j] + a[k]) * 2 == suma:\n ans = 'YES'\nprint(ans)"}, {"source_code": "a=list(map(int,raw_input().split()))\nd=0\nfor i in range(0,6):\n d=d+a[i]\nif(d%2==1):\n print(\"NO\")\nelse:\n for i in range(0,6):\n for j in range(i+1,6):\n for k in range(i+2,6):\n if((a[i]+a[j]+a[k])*2==d and i!=j and j!=k and k!=i):\n print(\"YES\")\n exit(0)\n print(\"NO\")\n"}], "negative_code": [{"source_code": "take1, take2, take3, take4, take5, take6 = input ().split()\ntake1 = int(take1)\ntake2 = int(take2)\ntake3 = int(take3)\ntake4 = int(take4)\ntake5 = int(take5)\ntake6 = int(take6)\nsum = take1+take2+take3+take4+take5+take6\nif sum%2 != 0:\n print(\"NO\")\nelse:\n here1 = max(take1, max(take2, max(take3, max(take4, max(take5,take6)))))\n here2 = min(take1, min(take2, min(take3, min(take4, min(take5,take6)))))\n store = here1+here2\n grab = sum - store\n if grab - take1 == store + take1:\n print(\"YES\")\n elif grab - take2 == store + take2:\n print(\"YES\")\n elif grab - take3 == store + take3:\n print(\"YES\")\n elif grab - take4 == store + take4:\n print(\"YES\")\n elif grab - take5 == store + take5:\n print(\"YES\")\n elif grab - take6 == store + take6:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "l=list(map(int,input().split()))\nl.sort()\na=l[0]+l[5]+l[2]\nb=l[0]+l[5]+l[3]\nc=l[1]+l[4]+l[3]\nd=l[1]+l[4]+l[2]\ne=l[0]+l[3]+l[4]\nf=l[1]+l[2]+l[5]\ng=l[0]+l[1]+l[5]\nh=l[4]+l[3]+l[2]\nif (a==c):\n print(\"YES\")\nelif (b==d):\n print(\"YES\")\nelif e==f:\n print(\"YES\")\nelif g==h:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def equal_team (seq):\n\tseq.sort()\n\tif sum(seq)%2 != 0 :\n\t\treturn \"NO\"\n\telse :\n\t\tteam_score = sum(seq)//2\n\t\tfor x in range(3):\n\t\t\tfor y in range(x,5):\n\t\t\t\tif seq[-1] + seq[x] + seq[y] == team_score :\n\t\t\t\t\treturn \"YES\"\n\t\treturn \"NO\"\n\n\nseq = list(map(int,input().split()))\nprint (equal_team(seq))\n\n\n\n\n\n\t\t\t\n\n\n\n"}, {"source_code": "a=list(map(int,input().split()))\nb=sum(a)/2\nfor i in a[:4]:\n for i0 in a[i+1:5]:\n for i1 in a[i0+1:6]:\n if b==i+i0+i1:\n print('Yes')\n exit()\nprint('No')"}, {"source_code": "mass=list(map(int,input().split()))\nmass.sort(reverse=True)\nteam1=0\nteam2=0\nfor i in range(6):\n\tif team2>team1:\n\t team1+=mass.pop(0)\n\telse:\n\t team2+=mass.pop(0)\n\tif team1==team2:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\n"}, {"source_code": "l=[int(i) for i in input().split()]\no=[]\nm=sum(l)%2\nif m!=0:\n print(\"NO\")\nelse:\n h=int(sum(l)/2)\n for i in range(6):\n for j in range(i,6):\n for t in range(j,6):\n k=l[i]+l[j]+l[t]\n o.append(abs(k-h))\n if min(o)==0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "p=[int(i) for i in input().split()]\nq=sum(p)/2\noutput=False\nfor x1 in range(4):\n for x2 in range(x1,5):\n for x3 in range(x2,6):\n if p[x1]+p[x2]+p[x3]==q:\n output=True\n break\nif output==False:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "arr = [1, 1, 1, 1, 1, 99]#list(map(int, input().split()))\n\ndef summArr(arr):\n\tans = 0\n\tfor i in arr:\n\t\tans += i\n\treturn ans\ndef NoRun(arr):\n\ti = 0\n\tans = []\n\tarr1 = set(arr)\n\twhile i < 6:\n\t\tif not(i in arr1):\n\t\t\tans.append(i)\n\t\ti+=1\n\treturn ans\ndef MMain(arr):\n\ti = 0\n\tsumm1 = 0\n\tsumm2 = 0\n\tans = \"\"\n\twhile i < len(arr):\n\t\tj = i + 1\n\t\twhile j < len(arr):\n\t\t\tk = j + 1\n\t\t\twhile k < len(arr):\n\t\t\t\tNoRun1 = NoRun([i, j, k])\n\t\t\t\tsumm1 = arr[i] + arr[j] + arr[k]\n\t\t\t\tsumm2 = arr[NoRun1[0]] + arr[NoRun1[1]] + arr[NoRun1[2]]\n\t\t\t\tif summ1 == summ2:\n\t\t\t\t\tans = \"YES\"\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tans = \"NO\"\n\t\t\t\t\tbreak\n\t\t\t\tk+=1\n\t\t\tj+=1\n\t\ti+=1\n\tprint(ans)\n\ndef main():\n\tif summArr(arr) % 2 == 0:\n\t\tMMain(arr)\n\telse: \n\t\tprint(\"NO\")\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "inputs = [int(x) for x in input().split(\" \")]\ntot = sum(inputs)\n\nt = False\nfor i in range(4):\n for j in range(i+1,5):\n for k in range(j+1,6):\n if i + j + k == tot - i - j - k:\n if not t:\n print(\"YES\")\n t = True\n\nif not t:\n print(\"NO\")\n"}, {"source_code": "str_in = input()\nm = [int(i) for i in str_in.split()]\nn=sorted(m)\nsum=0\nfor x in m:\n\tsum+=x\ni=0\nwhile i<3:\n\tj=i+1\n\twhile j<4:\n\t\tk=j+1\n\t\twhile k<5:\n\t\t\tif (n[i]+n[j]+n[k])==sum/2:\n\t\t\t\tprint(\"YES\")\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tk+=1\n\t\tif (n[i]+n[j]+n[k])==sum/2:\n\t\t\tbreak\t\t\n\t\telse:\n\t\t\tj+=1\n\tif (n[i]+n[j]+n[k])==sum/2:\n\t\tbreak\t\t\n\telse:\t\t\n\t\ti+=1\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "a = list(map(int, input().split()))\na.sort()\nfor i in range(len(a)):\n for j in range(i+1, len(a)):\n for k in range(j+1, len(a)):\n if a[i] + a[j] + a[k] == (sum(a)) // 2:\n print('YES')\n exit()\nprint(\"NO\")"}, {"source_code": "t=list(map(int,input().split()))\n\nt.sort()\n\np=0\na=sum(t)\nfor k in range(6):\n for j in range(k+1,7):\n if len(t[k:j])==3:\n if sum(t[k:j])==a-sum(t[k:j]):\n print('YES')\n p+=1\n break\n if p>0:\n break\n if p>0:\n break\nif p==0:\n print('NO')\n"}, {"source_code": "arr = list(map(int, input().split()))\nfor i in range(0, 2 ** 6):\n ans = 0\n for j in range(6):\n if (1 << j) & i:\n ans += arr[j]\n else:\n ans -= arr[j]\n if not ans:\n print(\"YES\")\n break\nelse:\n print('NO')"}, {"source_code": "scores = input().split()\n\nscores = [int(x) for x in scores]\n\ntotal = sum(scores)\nhalf = total / 2\nlargest = max(scores)\n\n\nif largest > len(scores):\n print(\"NO\")\n exit()\n\nif total % 2 != 0:\n print(\"NO\")\n exit()\n\nfor i in range(len(scores)):\n for j in range(i+1, len(scores)):\n for k in range(j + 1, len(scores)):\n temp = scores\n temp.remove(scores[i])\n temp.remove(scores[j])\n temp.remove(scores[k])\n if scores[i] + scores[j] + scores[k] == sum(temp):\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n"}, {"source_code": "y = sorted([int(i) for i in input().split()])\n\nif sum(y)%2==1:\n print('no')\nelse:\n a = y[-1]+y[0]\n b = y[-2]+y[1]\n if a>=b:\n a+= y[2]\n b+= y[-3]\n else:\n a+= y[-3]\n b+= y[2]\n\n if a==b:\n print('yes')\n else:\n print('no')\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nl1=[a[0]]\nl2=[a[1]]\nfor i in range(2,len(a)):\n if(sum(l1)>=sum(l2)):\n l2.append(a[i])\n else:\n l1.append(a[i])\nif(len(l1)==len(l2) and sum(l1)==sum(l2)):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n \n\n"}, {"source_code": "s = map(int,raw_input().split())\na = sum(s)\nif a%2==1:\n\tprint 'NO'\nelse:\n\tfor i in xrange(4):\n\t\tfor j in xrange(i,5):\n\t\t\tfor w in xrange(j,6):\n\t\t\t\tif (s[i]+s[j]+s[w])*2==a:\n\t\t\t\t\tprint 'YES'\n\t\t\t\t\texit(0)\n\tprint 'NO'\n"}, {"source_code": "mass=list(map(int,input().split()))\nmass.sort(reverse=True)\nteam1=0\nteam2=0\nfor i in range(6):\n\tif team2>team1:\n\t team1+=mass.pop(0)\n\telse:\n\t team2+=mass.pop(0)\n\tif team1==team2:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\n"}, {"source_code": "x = list(map(int, input().split()))\nif sum(x) % 2 != 0 or max(x) >= sum(x) // 2:\n print('NO')\nelse:\n for i in range(6):\n for j in range(6):\n for k in range(6):\n if i != j != k:\n if x[i] + x[j] + x[k] == sum(x) // 2:\n print('YES')\n exit()\n if i == j == k == 5:\n print('NO')\n\n"}, {"source_code": "import itertools\nn = list(map(int, input().split()))\ngoal = int(sum(n)/2)\nresult = [seq for i in range(len(n), 0, -1) for seq in itertools.combinations(n, i) if sum(seq) == goal]\n\nif len(result) / 2 == goal:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "a = [int(i) for i in input().split()]\ns = sum(a)\nfor i in range(4):\n for j in range(i+1, 5):\n for k in range(j+1, 6):\n if a[i] + a[j] + a[k] == s // 2:\n print(\"YES\")\n exit(0)\nprint('NO')\n"}, {"source_code": "a=sorted(list(map(int,input().split())))\nif (a[0]+a[3]+a[5]==a[1]+a[2]+a[4]) or (a[0]+a[2]+a[5]==a[1]+a[3]+a[4]) or (a[1]+a[2]+a[5]==a[0]+a[3]+a[4]) or (a[1]+a[0]+a[5]==a[2]+a[3]+a[4]):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\n\nq = a + b + c + d + f # e\nr = a + b + c + e + f # d\nt = a + b + d + e + f # c\nu = a + c + d + e + f # b\no = b + c + d + e + f # a\nk = a + b + c + d + e # f\n\n\n\nif a > o:\n print(\"no\")\nelif a == o:\n print(\"yes\")\nelif b > u:\n print(\"no\")\nelif b == u:\n print(\"yes\")\nelif c > t:\n print(\"no\")\nelif c == t:\n print(\"YES\")\nelif d > r:\n print(\"NO\")\nelif d == r:\n print(\"yes\")\nelif e > q:\n print(\"no\")\nelif e == q:\n print(\"YES\")\nelif f > k:\n print(\"No\")\nelif f == k:\n print(\"YES\")\n# 2\nelif a + b == c + d + e + f:\n print(\"YES\")\nelif a + c == b + d + e + f:\n print(\"YES\")\nelif a + d == b + e + f + c:\n print(\"YES\")\nelif a + e == b + d + f + c:\n print(\"YES\")\nelif a + f == b + d + e + c:\n print(\"YES\")\nelif b + c == d + a + e + f:\n print(\"YES\")\nelif b + d == a + e + f + c:\n print(\"YES\")\nelif b + e == d + a + f + c:\n print(\"YES\")\nelif b + f == a + d + c + e:\n print(\"YES\")\nelif c + d == a + b + e + f:\n print(\"YES\")\nelif c + e == a + b + d + f:\n print(\"YES\")\nelif c + f == a + b + d + e:\n print(\"YES\")\nelif d + e == a + b + c + f:\n print(\"YES\")\nelif d + f == a + b + c + e:\n print(\"YES\")\nelif e + f == a + b + c + d:\n print(\"YES\")\n\n\n# A\nelif a + b + c == d + e + f:\n print(\"YES\")\nelif a + b + d == e + f + c:\n print(\"YES\")\nelif a + b + e == f + c + d:\n print(\"YES\")\nelif a + b + f == c + d + e:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "scores = input().split()\n\nscores = [int(x) for x in scores]\n\ntotal = sum(scores)\nhalf = total / 2\nlargest = max(scores)\n\n\n# if largest > len(scores):\n# print(\"NO1\")\n# exit()\n\nif total % 2 != 0:\n print(\"NO\")\n exit()\n\nfor i in range(len(scores)):\n for j in range(i+1, len(scores)):\n for k in range(j + 1, len(scores)):\n temp = scores\n temp.remove(scores[i])\n temp.remove(scores[j])\n temp.remove(scores[k])\n if scores[i] + scores[j] + scores[k] == sum(temp):\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n"}, {"source_code": "a=list(map(float, input().split()))\nb=0\nk=0\n\nfor i in range(len(a)):\n b+=a[i];\n \nfor i in range(1,len(a)):\n for n in range(i,len(a)):\n if b/2-a[0]-a[i]-a[n]==0:\n k+=1\n\nif k==0:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "c=list(map(int,input().split()))\nwhile(True):\n\tif(c[0]+c[1]+c[2]==c[3]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[1]+c[3]==c[2]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[1]+c[4]==c[2]+c[3]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[1]+c[5]==c[2]+c[3]+c[4]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[2]+c[3]==c[1]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[2]+c[4]==c[1]+c[3]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[2]+c[5]==c[1]+c[3]+c[4]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[3]+c[4]==c[1]+c[2]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[4]+c[5]==c[1]+c[2]+c[3]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telse:\n\t\tprint(\"NO\")\n\t\tbreak"}, {"source_code": "take1, take2, take3, take4, take5, take6 = input ().split()\ntake1 = int(take1)\ntake2 = int(take2)\ntake3 = int(take3)\ntake4 = int(take4)\ntake5 = int(take5)\ntake6 = int(take6)\nsum = take1+take2+take3+take4+take5+take6\nif sum%2 != 0:\n print(\"NO\")\nelse:\n here1 = max(take1, max(take2, max(take3, max(take4, max(take5,take6)))))\n here2 = min(take1, min(take2, min(take3, min(take4, min(take5,take6)))))\n store = here1+here2\n grab = sum - store\n if grab - take1 == store + take1:\n print(\"YES\")\n elif grab - take2 == store + take2:\n print(\"YES\")\n elif grab - take3 == store + take3:\n print(\"YES\")\n elif grab - take4 == store + take4:\n print(\"YES\")\n elif grab - take5 == store + take5:\n print(\"YES\")\n elif grab - take6 == store + take6:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "num1,num2,num3,num4,num5,num6=input().split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nif (num1+num2+num3 == num4+num5+num6):\n print(\"YES\")\nelif (num2+num3+num4 == num1+num5+num6):\n print(\"YES\")\nelif (num3+num4+num5 == num1+num2+num6):\n print(\"YES\")\nelif (num1+num4+num5 == num2+num3+num6):\n print(\"YES\")\nelif (num2+num4+num6 == num1+num3+num5):\n print(\"YES\")\nelif (num1+num4+num6 == num2+num3+num5):\n print(\"YES\")\nelif (num2+num5+num6 == num1+num3+num4):\n print(\"YES\")\nelif (num3+num4+num6 == num1+num2+num5):\n print(\"YES\")\n\nelse:\n print(\"NO\")"}, {"source_code": "a=sorted(list(map(int,input().split())))\nif (a[0]+a[3]+a[5]==a[1]+a[2]+a[4]) or (a[0]+a[2]+a[5]==a[1]+a[3]+a[4]) or (a[1]+a[2]+a[5]==a[0]+a[3]+a[4]) or (a[1]+a[0]+a[5]==a[2]+a[3]+a[4]):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\ns=a[0]+a[1]\na=a[2:]\nm=sum(a); q=\"NO\"\nfor i in range(4):\n if m==s+2*a[i]:\n q=\"YES\"; break \nprint(q)\n \n \n "}, {"source_code": "a = [int(i) for i in input().split()]\nc = 0\n\nb = sum(a)\nif b%2!=0:\n\tc+=1\n\n\nfor i in range(6):\n\tif a[i]>b//3:\n\t\tc+=1\n\nif c:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}, {"source_code": "num1,num2,num3,num4,num5,num6=input().split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nif (num1+num2+num3 == num4+num5+num6):\n print(\"YES\")\nelif (num2+num3+num4 == num1+num5+num6):\n print(\"YES\")\nelif (num3+num4+num5 == num1+num2+num6):\n print(\"YES\")\nelif (num1+num4+num5 == num2+num3+num6):\n print(\"YES\")\nelif (num2+num4+num6 == num1+num3+num5):\n print(\"YES\")\nelif (num1+num4+num6 == num2+num3+num5):\n print(\"YES\")\nelif (num2+num5+num6 == num1+num3+num4):\n print(\"YES\")\nelif (num3+num4+num6 == num1+num2+num5):\n print(\"YES\")\nelif (num3+num5+num6 == num1+num2+num4):\n print(\"YES\")\n\nelse:\n print(\"NO\")"}, {"source_code": "num1,num2,num3,num4,num5,num6=input('Enter 6 numbers: ').split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nsum1=num1+num2\nsum2=num1+num3\nsum3=num1+num4\nsum4=num1+num5\nsum5=num1+num6\nsum6=num2+num3\nsum7=num2+num4\nsum8=num2+num5\nsum9=num2+num6\nsum10=num3+num4\nsum11=num3+num5\nsum12=num3+num6\nsum13=num4+num5\nsum14=num4+num6\nsum15=num5+num6\n\n\nif(num1+sum6 == num4+sum15):\n print(\"YES\")\nelif (num1+sum7 == num3+sum15):\n print(\"YES\")\nelif (num1+sum8 == num3+sum14):\n print(\"YES\")\nelif (num1+sum9 == num3+sum13):\n print(\"YES\")\nelif (num1+sum10 == num2+sum15):\n print(\"YES\")\nelif (num1+sum11 == num2+sum14):\n print(\"YES\")\nelif (num1+sum12 == num2+sum13):\n print(\"YES\")\nelif (num1+sum13 == num2+sum12):\n print(\"YES\")\nelif (num1+sum14 == num2+sum11):\n print(\"YES\")\nelif (num1+sum15 == num2+sum10):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "forces = [int(i) for i in input().split()]\nforces.sort()\nif sum(forces) % 2:\n\tprint('NO')\nelif max(forces) < sum(forces[:len(forces) - 1]):\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "num1, num2, num3, num4, num5, num6 = input().split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nif num1+num2+num3 == num4+num5+num6:\n print(\"YES\")\nelif num1+num2+num4 == num3+num5+num6:\n print(\"YES\")\nelif num1+num2+num5 == num3+num4+num6:\n print(\"YES\")\nelif num1+num2+num6 == num3+num5+num4:\n print(\"YES\")\nelif num2+num3+num4 == num1+num5+num6:\n print(\"YES\")\nelif num2+num4+num5 == num1+num3+num6:\n print(\"YES\")\nelif num2+num4+num6 == num1+num3+num5:\n print(\"YES\")\nelif num2+num3+num5 == num1+num6+num4:\n print(\"YES\")\nelif num2+num3+num6 == num1+num2+num4:\n print(\"YES\")\nelif num1+num3+num4 == num2+num5+num6:\n print(\"YES\")\nelif num1+num3+num5 == num4+num2+num6:\n print(\"YES\")\nelif num1+num3+num6 == num4+num2+num5:\n print(\"YES\")\nelif num2+num5+num6 == num1+num3+num4:\n print(\"YES\")\nelif num1+num4+num5 == num2+num3+num6:\n print(\"YES\")\nelif num1+num4+num6 == num2+num3+num5:\n print(\"YES\")\nelif num1+num5+num6 == num2+num3+num4:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "m=list(map(int,input().split()))\na=list(sorted(m))\nif ((a[0]+a[5]+a[1]==a[2]+a[4]+a[3]) or (a[0]+a[5]+a[4]==a[1]+a[2]+a[3])):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nmax1=a[0]\nc=1\nmax2=a[1]\nd=1\nz=a.count(0)\nfor i in range(2,len(a)):\n if(max1>=max2 and a[i]!=0):\n max2+=a[i]\n c+=1\n elif(max1<max2 and a[i]!=0):\n max1+=a[i]\n d+=1\nif(c>d):\n d+=z\nelif(c<d):\n c+=z\nif(max1==max2 and c==d):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a = []\nfor i in input().split() :\n a.append(int(i))\na.sort()\nif(a[0]+a[3]+a[4] == a[1]+a[5]+a[2]):\n print (\"YES\")\nelse :\n print (\"NO\")\n"}, {"source_code": "s = list(map(int, input().split()))\n\ndef lalala(s):\n n = [s[0]]\n for i in range(1,5):\n n += [s[i]]\n for j in range(i+1 ,6):\n n += [s[j]]\n if sum(n) == sum(set(n) & set(s)):\n return True\n else:\n n.pop()\n n = [s[0]]\n\nif lalala(s):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "#!/usr/bin/python\na=[]\nb=[]\nc=[]\nd=[]\na=[]\nfor i in raw_input().split():\n\t\ta.append(int(i))\na.sort()\nb=a[::-1]\nsum1=0\nsum2=0\nj=0\nk=0\nfor i in range(6):\n\t\tif(sum1<=sum2 or k==3):\n\t\t\t\tsum1=sum1+b[i]\n\t\t\t\tj=j+1\n\t\t\t\tc.append(b[i])\n\t\t\t\tb[i]=0\n\t\telif(sum2<=sum1 or j==3):\n\t\t\t\tsum2=sum2+b[i]\n\t\t\t\tk=k+1\n\t\t\t\td.append(b[i])\n\t\t\t\tb[i]=0\nif(sum2==sum1):\n\t\tprint \"YES\"\nelse:\n\t\tprint\"NO\"\n"}, {"source_code": "import sys\n\na, b, c, d, e, f = map(int, input().split())\n\nif a == 1 and b == 1 and c == 1 and d == 1 and e == 1 and f == 5:\n print(\"NO\")\n sys.exit()\n\nq = a + b + c + d + f # e\nr = a + b + c + e + f # d\nt = a + b + d + e + f # c\nu = a + c + d + e + f # b\no = b + c + d + e + f # a\nk = a + b + c + d + e # f\n\nif a > o:\n print(\"no\")\nelif a == o:\n print(\"yes\")\nelif b > u:\n print(\"no\")\nelif b == u:\n print(\"yes\")\nelif c > t:\n print(\"no\")\nelif c == t:\n print(\"YES\")\nelif d > r:\n print(\"NO\")\nelif d == r:\n print(\"yes\")\nelif e > q:\n print(\"no\")\nelif e == q:\n print(\"YES\")\nelif f > k:\n print(\"No\")\nelif f == k:\n print(\"YES\")\nelif a + b == c + d + e + f:\n print(\"YES\")\nelif a + c == b + d + e + f:\n print(\"YES\")\nelif a + d == b + e + f + c:\n print(\"YES\")\nelif a + e == b + d + f + c:\n print(\"YES\")\nelif a + f == b + d + e + c:\n print(\"YES\")\nelif b + c == d + a + e + f:\n print(\"YES\")\nelif b + d == a + e + f + c:\n print(\"YES\")\nelif b + e == d + a + f + c:\n print(\"YES\")\nelif b + f == a + d + c + e:\n print(\"YES\")\nelif c + d == a + b + e + f:\n print(\"YES\")\nelif c + e == a + b + d + f:\n print(\"YES\")\nelif c + f == a + b + d + e:\n print(\"YES\")\nelif d + e == a + b + c + f:\n print(\"YES\")\nelif d + f == a + b + c + e:\n print(\"YES\")\nelif e + f == a + b + c + d:\n print(\"YES\")\nelif a + b + c == d + e + f:\n print(\"YES\")\nelif a + b + d == e + f + c:\n print(\"YES\")\nelif a + b + e == f + c + d:\n print(\"YES\")\nelif a + b + f == c + d + e:\n print(\"YES\")\nelif a + c + d == b + e + f:\n print(\"YES\")\nelif a + c + e == b + f + d:\n print(\"YES\")\nelif a + c + f == b + d + e:\n print(\"YES\")\nelif a + d + e == b + c + f:\n print(\"YES\")\nelif a + d + f == b + c + e:\n print(\"YES\")\nelif a + e + f == b + c + d:\n print(\"YES\")\nelse:\n print(\"no\")"}, {"source_code": "a,b,c,d,e,f = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\ne = int(e)\nf = int(f)\n\n\nif (a+b+f)==(c+d+e) or (a+b+c)==(d+e+f) or (a+b+d)==(c+e+f) or (a+b+e)==(c+d+f):\n print(\"YES\")\nelif (a+c+d)==(b+e+f) or (a+c+e)==(b+d+f) or (a+c+f)==(b+d+e):\n print(\"YES\")\nelif (a+d+e)==(b+c+f) or (a+d+f)==(b+c+e):\n print(\"YES\")\nelif (a+e+f)==(b+c+d):\n print(\"YES\")\nelif a>b+c+d+e+f: \n print(\"NO\")\nelif b>a+c+d+e+f: \n print(\"NO\")\nelif c>a+b+d+e+f: \n print(\"NO\")\nelif d>a+b+c+e+f: \n print(\"NO\")\nelif e>a+b+c+d+f: \n print(\"NO\")\nelif f>a+b+c+d+e: \n print(\"NO\")"}, {"source_code": "w = list(map(int, input().split()))\ne = 1\nfor i in range(5):\n for j in range(4):\n if w[0] + w[i + 1] + w[j + 1] == sum(w) / 2 and i != j:\n e = 1\nif e != 1 or max(w) - min(w) > sum(w) - max(w) - min(w) or len(w) % 2 != 0:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\nprint('YES' if a[0]+a[1]+a[5]==a[2]+a[3]+a[4] else 'NO')"}, {"source_code": "scores = input().split()\n\nscores = [int(x) for x in scores]\n\ntotal = sum(scores)\nhalf = total / 2\nlargest = max(scores)\n\n\nif largest > len(scores):\n print(\"NO\")\n exit()\n\nif total % 2 != 0:\n print(\"NO\")\n exit()\n\nfor i in range(len(scores)):\n for j in range(i+1, len(scores)):\n for k in range(j + 1, len(scores)):\n if scores[i] + scores[j] + scores[k] == half:\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n"}, {"source_code": "p=[int(i) for i in input().split()]\nq=sum(p)/2\noutput=False\nfor x1 in range(4):\n for x2 in range(x1,5):\n for x3 in range(x2,6):\n if x1+x2+x3==q:\n output=True\n break\nif output==False:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nmax1=a[0]\nmax2=a[1]\nfor i in range(2,len(a)):\n if(max1>max2):\n max2+=a[i]\n else:\n max1+=a[i]\nif(max1==max2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "A = list(map(int, input().split()))\ns = sum(A)//2\nfor i in range (6):\n s1 = 0\n s1 += A[i]\n for j in range (i+1, 6):\n s2 = s1\n s2 += A[j]\n for k in range (j+1, 6):\n s3 = s2\n s3 += A[k] \n if s3==s:\n print('YES')\n exit(0)\nprint('NO') "}, {"source_code": "c=list(map(int,input().split()))\nwhile(True):\n\tif(c[0]+c[1]+c[2]==c[3]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[2]+c[3]==c[1]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[3]+c[4]==c[1]+c[2]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[0]+c[4]+c[5]==c[1]+c[2]+c[3]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[1]+c[2]+c[3]==c[0]+c[4]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[1]+c[3]+c[4]==c[0]+c[2]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[1]+c[4]+c[5]==c[0]+c[2]+c[3]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[2]+c[3]+c[4]==c[0]+c[1]+c[5]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telif(c[2]+c[4]+c[5]==c[0]+c[1]+c[3]):\n\t\tprint(\"YES\")\n\t\tbreak\n\telse:\n\t\tprint(\"NO\")\n\t\tbreak"}, {"source_code": "n=input().split()\nn=[int(i) for i in n]\nk=sum(n)\nif(k%2==1):\n print(\"NO\")\nelse:\n l=k/2\n l=l-n[0]\n h=0\n if(l==0):\n h=1\n else: \n for i in range(1,6):\n j=l-n[i]\n if(j==0):\n h=1\n else: \n for s in range(i+1,6):\n p=j-n[s]\n if(p==0):\n h=1\n break\n if(h==1):\n break\n if(h==1):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "# May the Speedforce be with us...\n'''\nfor _ in range(int(input())):\narr=list(map(int,input().split()))\nn,k=map(int,input().split())\nn=int(input())\ns=input()\n\nfrom collections import defaultdict\nd=defaultdict()\n\nd=dict()\ns=set()\ns.intersection()\ns.union()\ns.difference()\n\n\nproblem statement achhe se padhna hai\nage se bhi dekhna hai, piche se bhi dekhna hai\n'''\nfrom math import gcd,ceil\nfrom collections import defaultdict as dd\ndef lcm(a,b):\n\treturn (a*b)//gcd(a,b)\ndef inin():\n\treturn int(input())\ndef inar():\n\treturn list(map(int,input().split()))\ndef ar(element,size):\n\treturn [element for i in range(size)]\ndef digitsum(num):\n\tsu=0\n\twhile(num):\n\t\tsu+=num%10\n\t\tnum//=10\n\treturn su\n\n\narr=inar()\nteam=sum(arr)\nn=len(arr)\nif team%2:\n\tprint('NO')\nelse:\n\tans='NO'\n\tteam=team//2\n\tfor i in range(0,4):\n\t\tfor j in range(i,5):\n\t\t\tfor k in range(j,6):\n\t\t\t\tif (arr[i]+arr[j]+arr[k])==team:\n\t\t\t\t\tans='YES'\n\tprint(ans)\n"}, {"source_code": "summa = sum(list(map(int, input().split())))\nif summa % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b,c,d,e,f = input('Enter the numbers: ').split()\n\na=int(a)\nb=int(b)\nc=int(c)\nd=int(d)\ne=int(e)\nf=int(f)\n\ns1 = a+b\ns2 = a+c\ns3 = a+d\ns4 = a+e\ns5 = a+f\ns6 = b+c\ns7 = b+d\ns8 = b+e\ns9 = b+f\ns10 = c+d\ns11 = c+e\ns12 = c+f\ns13 = d+e\ns14 = d+f\ns15 = e+f\n\nif a + s6 == s13 + f:\n print(\"Yes\")\nelif a + s7 == s11 + f:\n print(\"Yes\")\nelif a + s8 == s10 + f:\n print(\"Yes\")\nelif a + s9 == s10 + e:\n print(\"Yes\")\nelif a + s10 == s8 + f:\n print(\"Yes\")\nelif a + s11 == s7 + f:\n print(\"Yes\")\nelif a + s12 == s7 + e:\n print(\"Yes\")\nelif a + s13 == s6 + f:\n print(\"Yes\")\nelif a + s14 == s6 + e:\n print(\"Yes\")\nelif a + s15 == s6 + d:\n print(\"Yes\")\nelse:\n print(\"NO\")"}, {"source_code": "num1,num2,num3,num4,num5,num6=input('Enter 6 numbers:').split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\n\n\nif (num1+num2+num3 == num4+num5+num6):\n print(\"Yes\")\nelif (num2+num3+num4 == num1+num5+num6):\n print(\"Yes\")\nelif (num1+num4+num5 == num2+num3+num6):\n print(\"Yes\")\nelif (num3+num4+num5 == num1+num2+num6):\n print(\"Yes\")\nelif (num2+num4+num6 == num1+num3+num5):\n print(\"yes\")\nelif (num1+num4+num6 == num2+num3+num5):\n print(\"Yes\")\nelif (num2+num5+num6 == num1+num3+num4):\n print(\"Yes\")\nelif (num3+num4+num6 == num1+num2+num5):\n print(\"Yes\")\nelif (num3+num5+num6 == num1+num2+num4):\n print(\"Yes\")\nelif (num1+num3+num4 == num2+num5+num6):\n print(\"Yes\")\nelif (num1+num5+num6 == num2+num3+num4):\n print(\"Yes\")\nelif (num2+num4+num5 == num1+num3+num6):\n print(\"Yes\")\nelif (num2+num3+num6 == num1+num4+num5):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n\n\n\n"}, {"source_code": "powers = [int(n) for n in input().split()]\npowers.sort()\ntp = sum(powers)\nindex=0\ntb=0\nif tp %2 ==1:\n print('NO')\nelse :\n ta= powers[0]+powers[-1]\n for i,power in enumerate(powers[1:len(powers)-1]):\n if power+ta == tp//2:\n ta += power\n index=i\n break\n if ta == tp//2:\n for i, power in enumerate(powers[1:len(powers)-1]):\n if i != index:\n tb += power\n if tb == ta:\n print('YES')\n else :\n print('NO')\n else :\n print('NO')\n\n"}, {"source_code": "num1,num2,num3,num4,num5,num6=input().split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nif (num1+num2+num3 == num4+num5+num6):\n print(\"YES\")\nelif (num2+num3+num4 == num1+num5+num6):\n print(\"YES\")\nelif (num3+num4+num5 == num1+num2+num6):\n print(\"YES\")\nelif (num1+num4+num5 == num2+num3+num6):\n print(\"YES\")\nelif (num2+num4+num6 == num1+num3+num5):\n print(\"YES\")\nelif (num1+num4+num6 == num2+num3+num5):\n print(\"YES\")\nelif (num2+num5+num6 == num1+num3+num4):\n print(\"YES\")\nelif (num3+num4+num6 == num1+num2+num5):\n print(\"YES\")\nelif (num3+num5+num6 == num1+num2+num4):\n print(\"YES\")\nelif (num1+num3+num4 == num2+num5+num6):\n print(\"YES\")\nelif (num1+num5+num6 == num2+num3+num4):\n print(\"YES\")\n \n\n\nelse:\n print(\"NO\")"}, {"source_code": "lst = [int(_) for _ in input().split()]\n\nSUM = 0\nfor i in lst:\n SUM += i\n\nif int(SUM) % 2 == 1:\n print(\"NO\")\n exit()\n\nfor a in range(6):\n for b in range(a + 1, 6):\n for c in range(b + 1, 6):\n if a + b + c == SUM / 2:\n print(\"YES\")\n exit()\n\nprint(\"NO\")"}, {"source_code": "\nl=list(map(int,input().split()))\nsuma=0\nsumb=0\nfor i in l:\n if(suma<=sumb):\n suma+=i\n else:\n sumb+=i\nif(suma==sumb):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\na = list(map(int, input().split()))\nprint('no' if sum(a) % 2 else 'yes')\n"}, {"source_code": "forces = [int(i) for i in input().split()]\nforces.sort()\n\nif sum(forces) % 2 or sum(forces) // 2 < max(forces):\n\tprint('NO')\nelse:\n\tprint('YES')"}, {"source_code": "scores = input().split()\n\nscores = [int(x) for x in scores]\n\ntotal = sum(scores)\nhalf = total / 2\nlargest = max(scores)\n\n\nif largest > len(scores):\n print(\"NO\")\n exit()\n\nif total % 2 != 0:\n print(\"NO\")\n exit()\n\nfor i in range(len(scores)):\n for j in range(i+1, len(scores)):\n for k in range(j + 1, len(scores)):\n temp = scores\n temp.remove(scores[i])\n temp.remove(scores[j])\n temp.remove(scores[k])\n if scores[i] + scores[j] + scores[k] == sum(temp):\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nsum1=0\nsum2=0\nfor i in range(len(a)):\n if sum1>sum2 :\n sum2+=a[i]\n else :\n sum1+=a[i]\nif sum1==sum2 :\n print('YES')\nelse :\n print('NO')\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\nif a[0]+a[2]+a[5]==a[1]+a[3]+a[4] or a[0]+a[3]+a[5]==a[2]+a[1]+a[4] :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "\n\n\ndef is_partitionable(arr):\n\tfor bitmask in range(2**6):\n\t\tnum_people = 0\n\t\tval = 0\n\t\tfor pos in range(6):\n\t\t\tbit = bitmask & pos\n\t\t\tif bit == 1:\n\t\t\t\tval += arr[pos]\n\t\t\t\tnum_people += 1\n\n\t\tif num_people == 3 and 2*val == sum(arr):\n\t\t\treturn True\n\n\treturn False\n\narr = [int(x) for x in input().split()]\n\nprint('YES' if is_partitionable(arr) else 'NO')\n\n"}, {"source_code": "def solution(peeps):\n\ts = sum(peeps)\n\tfor i in range(len(peeps)):\n\t\tfor j in range(i + 1, len(peeps)):\n\t\t\tfor k in range(j + 1, len(peeps)):\n\t\t\t\ttotal = i + j + k\n\t\t\t\tif total == s - total:\n\t\t\t\t\treturn \"YES\"\n\treturn \"NO\"\n\n\n\npeeps = list(map(int, input().split()))\nprint(solution(peeps))\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nsum1=0\nsum2=0\nfor i in range(len(a)):\n if sum1>sum2 :\n sum2+=a[i]\n else :\n sum1+=a[i]\nif sum1==sum2 :\n print('YES')\nelse :\n print('NO')\n"}, {"source_code": "a = [int(i) for i in input().split()]\nif sum(a)/2 == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=list(map(int,input().split()))\ns=sum(a)\nif s%2:\n print(\"NO\")\nelse:\n s=s/2\n for i in range(4):\n for j in range(i,5):\n for k in range(j,6):\n if a[i]+a[j]+a[k]==s:\n print(\"YES\")\n exit(0)\n print(\"NO\")\n"}, {"source_code": "arr = [1, 3, 2, 1, 2, 1]#list(map(int, input().split()))\n\ndef summArr(arr):\n\tans = 0\n\tfor i in arr:\n\t\tans += i\n\treturn ans\n\ndef NoRun(arr):\n\ti = 0\n\tans = []\n\tarr1 = set(arr)\n\twhile i < 6:\n\t\tif not(i in arr1):\n\t\t\tans.append(i)\n\t\ti+=1\n\treturn ans\n\n\n\ndef MMain(arr):\n\ti = 0\n\tsumm1 = 0\n\tsumm2 = 0\n\tans = \"\"\n\twhile i < len(arr):\n\t\tj = i + 1\n\t\twhile j < len(arr):\n\t\t\tk = j + 1\n\t\t\twhile k < len(arr):\n\t\t\t\tNoRun1 = NoRun([i, j, k])\n\t\t\t\tsumm1 = arr[i] + arr[j] + arr[k]\n\t\t\t\tsumm2 = arr[NoRun1[0]] + arr[NoRun1[1]] + arr[NoRun1[2]]\n\t\t\t\tif summ1 == summ2:\n\t\t\t\t\tans = \"YES\"\n\t\t\t\tk+=1\n\t\t\tj+=1\n\t\ti+=1\n\t\n\tif len(ans) != 0:\n\t\treturn ans\n\telse:\n\t\treturn \"NO\"\ndef main():\n\tif summArr(arr) % 2 == 0:\n\t\tprint(MMain(arr))\n\telse: \n\t\tprint(\"NO\")\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "A,B,C,D,E,F= input(\"\").split()\nA=int(A)\nB=int(B)\nC=int(C)\nD=int(D)\nE=int(E)\nF=int(F)\na1=A+B+C\na2=D+E+F\nb1=A+C+D\nb2=B+E+F\nc1=A+D+E\nc2=B+C+F\nd1=A+E+F\nd2=B+C+D\ne1=A+F+B\ne2=C+D+E\nf1=B+D+F\nf2=A+C+E\ng1=A+B+E\ng2=C+D+F\nh1=B+C+E\nh2=A+D+F\ni1=A+B+D\ni2=C+E+F\nif a1==a2:\n print(\"YES\")\nelif b1==b2:\n print(\"YES\")\nelif c1==c2:\n print(\"YES\")\nelif d1==d2:\n print(\"YES\")\nelif e1==e2:\n print(\"YES\")\nelif f1==f2:\n print(\"YES\")\nelif g1==g2:\n print(\"YES\")\nelif h1==h2:\n print(\"YES\")\nelif i1==i2:\n print(\"YES\") \nelse:\n print(\"NO\")\n"}, {"source_code": "def ans(inp):\n sm = sum(inp)\n if sm % 2 == 1:\n print(\"NO\")\n return\n for a in range(6):\n for b in range(6):\n for c in range(6):\n if a != b and b != c:\n s = inp[a] + inp[b] + inp[c]\n if s*2 == sm :\n print(\"YES\")\n return\n print(\"NO\")\n\ninp = input().split(\" \")\ninp = list(map(int, inp))\nans(inp)\n"}, {"source_code": "a = list(map(int,input().split()))\ns = sum(list(a))\ncnt = 0\nfor m in (a):\n for n in (a):\n for p in (a):\n if (s%2==0) and (m+n+p==s//2): cnt+=1\nif (cnt > 0): print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "from itertools import combinations\n\na = list(sorted(map(int, input().split())))\nx = list(combinations(a, 3))\nz = sum(a) // 2\nfor i in x:\n if sum(i) == z:\n exit(print('yes'))\nprint('no')\n\n"}, {"source_code": "# Belongs to : midandfeed aka asilentvoice\nq = [int(x) for x in input().split()]\nq.sort()\nprint(\"YES\" if sum(q[2:5])*2 == sum(q) else \"NO\")\n\t\n\t"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nsum1=0\nsum2=0\nfor i in range(len(a)):\n if sum1>sum2 :\n sum2+=a[i]\n else :\n sum1+=a[i]\nif sum1==sum2 :\n print('YES')\nelse :\n print('NO')\n"}, {"source_code": "arr = [1, 1, 1, 1, 1, 99]#list(map(int, input().split()))\n\ndef summArr(arr):\n\tans = 0\n\tfor i in arr:\n\t\tans += i\n\treturn ans\ndef NoRun(arr):\n\ti = 0\n\tans = []\n\tarr1 = set(arr)\n\twhile i < 6:\n\t\tif not(i in arr1):\n\t\t\tans.append(i)\n\t\ti+=1\n\treturn ans\ndef MMain(arr):\n\ti = 0\n\tsumm1 = 0\n\tsumm2 = 0\n\tans = \"\"\n\twhile i < len(arr):\n\t\tj = i + 1\n\t\twhile j < len(arr):\n\t\t\tk = j + 1\n\t\t\twhile k < len(arr):\n\t\t\t\tNoRun1 = NoRun([i, j, k])\n\t\t\t\tsumm1 = arr[i] + arr[j] + arr[k]\n\t\t\t\tsumm2 = arr[NoRun1[0]] + arr[NoRun1[1]] + arr[NoRun1[2]]\n\t\t\t\tif summ1 == summ2:\n\t\t\t\t\tans = \"YES\"\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tans = \"NO\"\n\t\t\t\t\tbreak\n\t\t\t\tk+=1\n\t\t\tj+=1\n\t\ti+=1\n\tprint(ans)\n\ndef main():\n\tif summArr(arr) % 2 == 0:\n\t\tMMain(arr)\n\telse: \n\t\tprint(\"NO\")\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "#!/usr/bin/python\na=[]\nb=[]\nc=[]\nd=[]\na=[]\nfor i in raw_input().split():\n\t\ta.append(int(i))\na.sort()\nb=a[::-1]\nsum1=0\nsum2=0\nfor i in range(6):\n\t\tif(sum1<=sum2):\n\t\t\t\tsum1=sum1+b[i]\n\t\t\t\tc.append(b[i])\n\t\t\t\tb[i]=0\n\t\telif(sum2<=sum1):\n\t\t\t\tsum2=sum2+b[i]\n\t\t\t\td.append(b[i])\n\t\t\t\tb[i]=0\nif(sum2==sum1):\n\t\tprint \"YES\"\nelse:\n\t\tprint\"NO\"\n"}, {"source_code": "a=sorted(list(map(int,input().split())))\nif (a[0]+a[3]+a[5]==a[1]+a[2]+a[4]) or (a[0]+a[2]+a[5]==a[1]+a[3]+a[4]) or (a[1]+a[2]+a[5]==a[0]+a[3]+a[4]):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = 6\narr = [int(x) for x in raw_input().split()]\nans = 0\nsum = 0\nfor i in range(n):\n\tsum += arr[i]\nfor i in range(n):\n for j in range(i,n):\n\t for k in range(j,n):\n\t\t if(arr[i]+arr[j]+arr[k])<<1 == sum:\n\t\t\t ans = 1\nif ans==1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "#another test\n\n"}, {"source_code": "a = list(map(int, input().split()))\na.sort()\nfor i in range(len(a)):\n for j in range(i+1, len(a)):\n for k in range(j+1, len(a)):\n if a[i] + a[j] + a[k] == (sum(a)) // 2:\n print('YES')\n exit()\nprint(\"NO\")"}, {"source_code": "def solution(peeps):\n\ts = sum(peeps)\n\tfor i in range(len(peeps)):\n\t\tfor j in range(i + 1, len(peeps)):\n\t\t\tfor k in range(j + 1, len(peeps)):\n\t\t\t\ttotal = i + j + k\n\t\t\t\tif total == s - total:\n\t\t\t\t\treturn \"YES\"\n\treturn \"NO\"\n\n\n\npeeps = list(map(int, input().split()))\nprint(solution(peeps))\n"}, {"source_code": "from itertools import combinations\ns = combinations(set(map(int, input().split())),3)\nsets = []\nfor s1, s2, s3 in s:\n sets.append(sum((s1, s2, s3)))\n\n\nfor i in range(len(sets)):\n for j in range(i, len(sets)):\n if sets[i] == sets[j]:\n print('YES')\n exit()\nprint('NO')\n\n"}, {"source_code": "num1,num2,num3,num4,num5,num6=input().split()\nnum1=int(num1)\nnum2=int(num2)\nnum3=int(num3)\nnum4=int(num4)\nnum5=int(num5)\nnum6=int(num6)\n\nif (num1+num2+num3 == num4+num5+num6):\n print(\"YES\")\nelif (num2+num3+num4 == num1+num5+num6):\n print(\"YES\")\nelif (num3+num4+num5 == num1+num2+num6):\n print(\"YES\")\nelif (num1+num4+num5 == num2+num3+num6):\n print(\"YES\")\nelif (num2+num4+num6 == num1+num3+num5):\n print(\"YES\")\nelif (num1+num4+num6 == num2+num3+num5):\n print(\"YES\")\nelif (num2+num5+num6 == num1+num3+num4):\n print(\"YES\")\nelif (num3+num4+num6 == num1+num2+num5):\n print(\"YES\")\nelif (num3+num5+num6 == num1+num2+num4):\n print(\"YES\")\nelif (num1+num3+num4 == num2+num5+num6):\n print(\"YES\")\nelif (num1+num5+num6 == num2+num3+num4):\n print(\"YES\")\nelif (num2+num4+num5 == num1+num3+num6):\n print(\"YES\")\nelif (num2+num3+num6 == num1+num4+num5):\n print(\"YES\")"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\n\nq = a + b + c + d + f # e\nr = a + b + c + e + f # d\nt = a + b + d + e + f # c\nu = a + c + d + e + f # b\no = b + c + d + e + f # a\nk = a + b + c + d + e # f\n\n\n\nif a > o:\n print(\"no\")\nelif a == o:\n print(\"yes\")\nelif b > u:\n print(\"no\")\nelif b == u:\n print(\"yes\")\nelif c > t:\n print(\"no\")\nelif c == t:\n print(\"YES\")\nelif d > r:\n print(\"NO\")\nelif d == r:\n print(\"yes\")\nelif e > q:\n print(\"no\")\nelif e == q:\n print(\"YES\")\nelif f > k:\n print(\"No\")\nelif f == k:\n print(\"YES\")\n# 2\nelif a + b == c + d + e + f:\n print(\"YES\")\nelif a + c == b + d + e + f:\n print(\"YES\")\nelif a + d == b + e + f + c:\n print(\"YES\")\nelif a + e == b + d + f + c:\n print(\"YES\")\nelif a + f == b + d + e + c:\n print(\"YES\")\nelif b + c == d + a + e + f:\n print(\"YES\")\nelif b + d == a + e + f + c:\n print(\"YES\")\nelif b + e == d + a + f + c:\n print(\"YES\")\nelif b + f == a + d + c + e:\n print(\"YES\")\nelif c + d == a + b + e + f:\n print(\"YES\")\nelif c + e == a + b + d + f:\n print(\"YES\")\nelif c + f == a + b + d + e:\n print(\"YES\")\nelif d + e == a + b + c + f:\n print(\"YES\")\nelif d + f == a + b + c + e:\n print(\"YES\")\nelif e + f == a + b + c + d:\n print(\"YES\")\n\n\n# A\nelif a + b + c == d + e + f:\n print(\"YES\")\nelif a + b + d == e + f + c:\n print(\"YES\")\nelif a + b + e == f + c + d:\n print(\"YES\")\nelif a + b + f == c + d + e:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "d=list(map(int, input().split()))\ns=sum(d)/2\nif s%1!=0:\n print(\"NO\")\n exit()\nd.sort()\nif d[5]+d[0]+d[1]>s:\n print(\"NO\")\n exit()\ne=d[5]-d[0]\nif e in d[1:5]:\n print(\"YES\")\n exit()\ne=d[5]-d[1]\nif e in d[2:5]:\n print(\"YES\")\n exit()\ne=d[5]-d[2]\nif e in d[3:5]:\n print(\"YES\")\n exit()\nprint(\"NO\")\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nsum1=0\nsum2=0\nc1=0\nc2=0\nfor i in range(len(a)):\n if sum1>sum2 :\n sum2+=a[i]\n c2+=1\n else :\n sum1+=a[i]\n c1+=1\nif sum1==sum2 and c1==c2:\n print('YES')\nelse :\n print('NO')\n"}, {"source_code": "p=[int(i) for i in input().split()]\nq=sum(p)/2\noutput=False\nfor x1 in range(4):\n for x2 in range(x1,5):\n for x3 in range(x2,6):\n if x1+x2+x3==q:\n output=True\n break\nif output==False:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nsum1=0\nsum2=0\nfor i in range(len(a)):\n if sum1>sum2 :\n sum2+=a[i]\n else :\n sum1+=a[i]\nif sum1==sum2 :\n print('YES')\nelse :\n print('NO')\n"}, {"source_code": "a = list(int(x) for x in input().split())\ns = sum(a)\ncount = 0\nfor i in range(6):\n c = 0\n c += a[i]\n for j in range(i + 1, 6):\n c += a[j]\n for k in range(j + 1, 6):\n b = s\n c += a[k]\n b -= c\n # print(b, c)\n if b == c:\n count = 1\n break\n if count == 1:\n break\n if count == 1:\n break\nif count == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "t=list(map(int,input().split()))\n\nt.sort()\n\np=0\na=sum(t)\nfor k in range(6):\n for j in range(k+1,7):\n if len(t[k:j])==3:\n if sum(t[k:j])==a-sum(t[k:j]):\n print('YES')\n p+=1\n break\nif p==0:\n print('NO')\n"}, {"source_code": "a = list(map(int,input().split()))\nflag = True\nfor i in range(0,4):\n for g in range(i+1,5):\n for k in range(g+1,6):\n sum1 = a[i] + a[g]\n sum2 = sum(a) - sum1\n if sum1 == sum2:\n flag = False\nprint(\"NO\" if flag else \"YES\")"}, {"source_code": "lst = [int(i) for i in input().split()]\nif (sum(lst)%2==1):\n print(\"NO\")\nelse:\n avr = sum(lst)/2\n hasPrint = False\n for a in range(6):\n for b in range(a, 6):\n for c in range(b, 6):\n if lst[a]+lst[b]+lst[c]==avr and not hasPrint:\n print(\"YES\")\n hasPrint = True\n if not hasPrint:\n print(\"No\")\n "}, {"source_code": "from itertools import combinations\ns = combinations(set(map(int, input().split())),3)\nsets = []\nfor s1, s2, s3 in s:\n sets.append(sum((s1, s2, s3)))\n\n\nfor i in range(len(sets)):\n for j in range(len(sets)):\n if sets[i] == sets[j]:\n print('YES')\n exit()\nprint('NO')\n\n"}, {"source_code": "arr = list(map(int,input().split()))\ns1 = 0\ns2 = 0\narr.sort()\ns = sum(arr)\nfl = False\nfor i in range(4):\n for g in range(i,5):\n for j in range(g,6):\n if arr[i] + arr[g] + arr[j] == s/2:\n fl = True\nif fl:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "a=list(map(int,input().split()))\na.sort()\na.reverse()\nl1=[a[0]]\nl2=[a[1]]\nfor i in range(2,len(a)):\n if(sum(l1)>=sum(l2)):\n l2.append(a[i])\n else:\n l1.append(a[i])\nif(len(l1)==len(l2) and sum(l1)==sum(l2)):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n \n\n"}, {"source_code": "a = map(int,raw_input().split())\nn = 6\ns = sum(a)//2\nfor i in range(n):\n for j in range(i+1,n):\n for k in range(j+1,n):\n if a[i]+a[j]+a[k]==s:\n print(\"YES\")\n exit(0)\n \nprint(\"NO\") \n "}, {"source_code": "from sys import stdin, stdout\nfrom itertools import permutations\ndata = stdin.readline().rstrip().split(' ')\n#find sum\ntotal = 0\nfoundit=False\nfor i in data:\n i = int(i)\n total += i\nif total % 2 == 0:\n triple_pairs = permutations(data,3)\n for pair in triple_pairs:\n pair_l = [int(x) for x in pair]\n pair_sum = pair_l[0]+pair_l[1]+pair_l[2]\n\n if pair_sum == total/2:\n print('hi')\n stdout.write('YES')\n foundit = True\n break\n if not foundit:\n stdout.write('NO')\nelse:\n stdout.write('NO')"}, {"source_code": "a = list(map(int,input().split()))\ns = sum(list(a))\ncnt = 0\nfor m in (a):\n for n in (a):\n for p in (a):\n if (s%2==0) and (m+n+p==s//2): cnt+=1\nif (cnt > 0): print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "w = list(map(int, input().split()))\ne = 1\nfor i in range(5):\n for j in range(4):\n if w[1] + w[i] + w[j] == sum(w) / 2:\n e = 1\nif e != 1 or max(w) - min(w) > sum(w) - max(w) - min(w):\n print('NO')\nelse:\n print('YES')\n"}], "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11"} {"source_code": "import sys\r\nimport math\r\nimport itertools\r\niput = sys.stdin.readline\r\n\r\ndef solve():\r\n n = input()\r\n ans = ''\r\n count = 9\r\n while len(n) > 1:\r\n ans += str(count)\r\n n = int(n)-count\r\n n = str(n)\r\n count -= 1\r\n if n in ans:\r\n while n in ans:\r\n ans += str(count)\r\n n = int(n)-count\r\n n = str(n)\r\n count -= 1\r\n ans += n\r\n else:\r\n ans += n\r\n print(ans[::-1])\r\nfor _ in range(int(input())):\r\n solve()\r\n", "positive_code": [{"source_code": "t = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n ans = ''\r\n k = 9\r\n while (n>0):\r\n if n<k:\r\n ans = ans + str(n)\r\n break\r\n ans = ans + str(k)\r\n n-=k\r\n k -=1\r\n ans = ans[::-1]\r\n print(ans)\r\n "}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n s = ''\r\n for i in range(9, 0, -1):\r\n if n > i:\r\n s += str(i)\r\n n -= i\r\n else:\r\n s += str(n)\r\n break\r\n print(s[::-1])"}, {"source_code": "t = int(input())\r\nfor i in (range (t)):\r\n numero = int(input()) \r\n resultado = \"\"\r\n for i in reversed(range(1,10)):\r\n if (numero>=i):\r\n numero= numero - i \r\n resultado = str(i) + resultado\r\n print(resultado)"}, {"source_code": "t=int(input())\r\nfor _ in range(t):\r\n n=int(input())\r\n res=''\r\n for i in range(9,0,-1):\r\n if n>=i:\r\n res=str(i)+res\r\n n-=i\r\n print(res)\r\n "}, {"source_code": "test=int(input())\r\nfor _ in range(test):\r\n value=int(input())\r\n temp=[]\r\n ans=9\r\n while value>9 or value>ans:\r\n value-=ans\r\n temp.append(str(ans))\r\n ans-=1\r\n temp.append(str(value))\r\n temp.reverse()\r\n new=int(\"\".join(temp))\r\n print(new)\r\n \r\n "}, {"source_code": "for t in range(int(input())):\r\n num = int(input())\r\n if num<=9:\r\n print(num)\r\n elif num<=17:\r\n Lst = [str(num-9),'9']\r\n print(''.join(Lst))\r\n elif num<=24:\r\n Lst = [str(num-17),'89']\r\n print(''.join(Lst))\r\n elif num<=30:\r\n Lst = [str(num-24),'789']\r\n print(''.join(Lst))\r\n elif num<=35:\r\n Lst = [str(num-30),'6789']\r\n print(''.join(Lst))\r\n elif num<=39:\r\n Lst = [str(num-35),'56789']\r\n print(''.join(Lst))\r\n elif num<=42:\r\n Lst = [str(num-39),'456789']\r\n print(''.join(Lst))\r\n elif num<=44:\r\n Lst = [str(num-42),'3456789']\r\n print(''.join(Lst))\r\n else:\r\n print('123456789')\r\n "}, {"source_code": "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Aug 19 23:42:08 2022\r\n\r\n@author: khale\r\n\"\"\"\r\n\r\nt = int(input())\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n L = []\r\n x = 9\r\n while(n >= 10 or n > x):\r\n n = n - x\r\n L.append(x)\r\n x -= 1\r\n L.append(n)\r\n for i in range(len(L)-1,-1,-1):\r\n print(L[i],end='')\r\n print()\r\n "}, {"source_code": "t = int(input())\r\nwhile(t>0):\r\n n=int(input())\r\n if(n<10):\r\n print(n)\r\n else:\r\n s = \"\"\r\n temp = 9\r\n while(temp>0 and n>0):\r\n if(n-temp>=0):\r\n s+=str(temp)\r\n n-=temp\r\n temp-=1\r\n print(s[::-1])\r\n t-=1\r\n \r\n"}, {"source_code": "N = int(input())\r\n\r\narray = []\r\n\r\nfor s in range(N):\r\n n = 9\r\n value = 0\r\n count = 0\r\n s = int(input())\r\n while s >= 10:\r\n value = value + n * 10 ** count\r\n s -= n\r\n n -= 1\r\n count += 1\r\n while str(s) in str(value):\r\n value = value + n * 10 ** count\r\n s -= n\r\n n -= 1\r\n count += 1\r\n value = value + s * 10 ** count\r\n array.append(value)\r\n\r\nfor i in range(N):\r\n print(array[i])"}, {"source_code": "for i in range(int(input())):\r\n n = int(input())\r\n arr=[]\r\n for i in range(1,10):\r\n if n>10-i:\r\n arr.append(10-i)\r\n n = n-10+i\r\n elif n>0:\r\n arr.append(n)\r\n break\r\n arr.reverse()\r\n for i in arr:\r\n print(i,end=\"\")\r\n print()"}, {"source_code": "for _ in range(int(input())):\r\n x=int(input())\r\n arr=[]\r\n k=9\r\n while x>k :\r\n arr.append(str(k))\r\n x-=k\r\n k=k-1\r\n \r\n arr.append(str(x))\r\n arr.reverse()\r\n print(\"\".join(arr))"}, {"source_code": "import sys\r\n\r\n'''IF IT WORKS, IT WORKS. DON'T ASK ANYTHING FURTHER'''\r\n\r\n\r\n# -------------------------- INPUT/OUTPUT ------------\r\ndef input_int():\r\n return int(sys.stdin.readline())\r\n\r\ndef input_str():\r\n return sys.stdin.readline().rstrip()\r\n\r\ndef input_int_arr():\r\n return list(map(int, sys.stdin.readline().split()))\r\n\r\ndef input_char_arr():\r\n return sys.stdin.readline().rstrip().split()\r\n\r\ndef print_ln(arg):\r\n sys.stdout.write(str(arg) + '\\n')\r\n\r\ndef print_sp(arg):\r\n sys.stdout.write(str(arg) + ' ')\r\n\r\ndef print_only(arg):\r\n sys.stdout.write(str(arg))\r\n# -----------------------------------------------------\r\n\r\n\r\ndef solve():\r\n ans= ''\r\n n = input_int()\r\n i = 9\r\n\r\n while n:\r\n if n-i <= 0:\r\n ans = str(n) + ans\r\n break\r\n else:\r\n ans = str(i) + ans\r\n n -= i\r\n i -= 1\r\n\r\n\r\n print_ln(ans)\r\n\r\ndef main():\r\n t = input_int()\r\n\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nmain()"}, {"source_code": "import sys\r\n\r\n# -------------------------- INPUT/OUTPUT ------------\r\n\r\ndef input_int():\r\n return int(sys.stdin.readline())\r\n\r\ndef input_str():\r\n return sys.stdin.readline().rstrip()\r\n\r\ndef input_int_arr():\r\n return list(map(int, sys.stdin.readline().split()))\r\n\r\ndef input_char_arr():\r\n return sys.stdin.readline().rstrip().split()\r\n\r\ndef print_ln(num):\r\n sys.stdout.write(str(num) + '\\n')\r\n\r\ndef print_sp(num):\r\n sys.stdout.write(str(num) + ' ')\r\n\r\ndef print_only(num):\r\n sys.stdout.write(str(num))\r\n# -------------------------- INPUT/OUTPUT ------------\r\n\r\ndef solve():\r\n n = input_int()\r\n\r\n if n <= 9:\r\n print_ln(n)\r\n elif n <= 17:\r\n str1 = '9'\r\n print_ln(str(n-9) + str1)\r\n elif n <= 24:\r\n str1 = '89'\r\n print_ln(str(n-17) + str1)\r\n elif n <= 30:\r\n str1 = '789'\r\n print_ln(str(n-24) + str1)\r\n elif n <= 35:\r\n str1 = '6789'\r\n print_ln(str(n-30) + str1)\r\n elif n <= 39:\r\n str1 = '56789'\r\n print_ln(str(n-35) + str1)\r\n elif n <= 42:\r\n str1 = '456789'\r\n print_ln(str(n-39) + str1)\r\n elif n <= 44:\r\n str1 = '3456789'\r\n print_ln(str(n-42) + str1)\r\n else:\r\n print_ln('123456789')\r\n\r\n \r\n\r\ndef main():\r\n t = input_int()\r\n\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nmain()"}, {"source_code": "t = int(input())\nfor tidx in range(t):\n n = int(input())\n ans = 0\n req = n\n for i in range(9, 0, -1):\n ans += min(req, i) * 10**(9-i)\n req -= min(req, i)\n if req == 0: break\n print(ans)\n"}, {"source_code": "for i in range(int(input())):\n s=int(input())\n if s<10:\n print(s)\n elif s<=17:\n print(str(s-9)+\"9\")\n elif s <= 24:\n print(str(s - 17)+\"8\" + \"9\")\n elif s <= 30:\n print(str(s - 24)+\"7\"+\"8\" + \"9\")\n elif s <= 35:\n print(str(s - 30)+\"6\"+\"7\"+\"8\" + \"9\")\n elif s <= 39:\n print(str(s - 35)+\"5\"+\"6\"+\"7\"+\"8\" + \"9\")\n elif s <= 42:\n print(str(s - 39)+\"4\"+\"5\"+\"6\"+\"7\"+\"8\" + \"9\")\n elif s <= 44:\n print(str(s - 42)+\"3\"+\"4\"+\"5\"+\"6\"+\"7\"+\"8\" + \"9\")\n else:\n print(123456789)"}, {"source_code": "ans = [(1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (1, 9), (2, 9), (3, \r\n9), (4, 9), (5, 9), (6, 9), (7, 9), (8, 9), (1, 8, 9), (2, 8, 9), (3, 8, 9), (4, 8, 9), (5, 8, 9), (6, 8, 9), (7, 8, 9), (1, 7, 8, 9), (2, 7, 8, 9), (3, 7, 8, 9), (4, 7, 8, 9), (5, 7, 8, 9), (6, 7, 8, 9), (1, 6, 7, 8, 9), (2, 6, 7, 8, 9), (3, 6, 7, 8, 9), (4, 6, 7, 8, 9), (5, 6, 7, 8, 9), (1, 5, 6, \r\n7, 8, 9), (2, 5, 6, 7, 8, 9), (3, 5, 6, 7, 8, 9), (4, 5, 6, 7, 8, 9), (1, 4, 5, 6, 7, 8, 9), (2, 4, 5, 6, 7, 8, 9), (3, 4, 5, 6, 7, 8, 9), (1, 3, 4, 5, 6, 7, 8, 9), (2, 3, 4, 5, 6, 7, 8, 9), (1, 2, 3, 4, 5, 6, 7, 8, 9)]\r\n\r\nfor _ in range(int(input())):\r\n print(*ans[int(input()) - 1], sep = \"\")"}, {"source_code": "for i in range(int(input())):\r\n\ta = int(input())\r\n\tif a==1: print('1')\r\n\telif a==2: print('2')\r\n\telif a==3: print('3')\r\n\telif a==4: print('4')\r\n\telif a==5: print('5')\r\n\telif a==6: print('6')\r\n\telif a==7: print('7')\r\n\telif a==8: print('8')\r\n\telif a==9: print('9')\r\n\telif a==10: print('19')\r\n\telif a==11: print('29')\r\n\telif a==12: print('39')\r\n\telif a==13: print('49')\r\n\telif a==14: print('59')\r\n\telif a==15: print('69')\r\n\telif a==16: print('79')\r\n\telif a==17: print('89')\r\n\telif a==18: print('189')\r\n\telif a==19: print('289')\r\n\telif a==20: print('389')\r\n\telif a==21: print('489')\r\n\telif a==22: print('589')\r\n\telif a==23: print('689')\r\n\telif a==24: print('789')\r\n\telif a==25: print('1789')\r\n\telif a==26: print('2789')\r\n\telif a==27: print('3789')\r\n\telif a==28: print('4789')\r\n\telif a==29: print('5789')\r\n\telif a==30: print('6789')\r\n\telif a==31: print('16789')\r\n\telif a==32: print('26789')\r\n\telif a==33: print('36789')\r\n\telif a==34: print('46789')\r\n\telif a==35: print('56789')\r\n\telif a==36: print('156789')\r\n\telif a==37: print('256789')\r\n\telif a==38: print('356789')\r\n\telif a==39: print('456789')\r\n\telif a==40: print('1456789')\r\n\telif a==41: print('2456789')\r\n\telif a==42: print('3456789')\r\n\telif a==43: print('13456789')\r\n\telif a==44: print('23456789')\r\n\telif a==45: print('123456789')"}, {"source_code": "# import io,os\r\n# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nimport sys\r\nfrom functools import lru_cache\r\nfrom math import inf\r\n\r\nsys.setrecursionlimit(10**5)\r\n\r\n@lru_cache(10**5)\r\ndef dp(i,required_sum):\r\n if required_sum==0: return i\r\n return min((int(f\"{i}{dp(j,required_sum-j)}\") for j in range(i+1,10)),default=10**9)\r\n\r\ndef solve():\r\n s = int(input())\r\n ans = dp(0,s)\r\n print(ans)\r\nT = int(input())\r\nfor _ in range(T):\r\n solve()\r\n"}, {"source_code": "# varad\r\nfor _ in range(int(input())):\r\n\tn=int(input())\r\n\tans=''\r\n\tfor i in range(9,0,-1):\r\n\t\tif n>=i:\r\n\t\t\tn-=i\r\n\t\t\tans=str(i)+ans\r\n\tprint(ans)"}, {"source_code": "from sys import stdin\r\ninput = stdin.buffer.readline\r\n\r\n\r\ndef func():\r\n\trem = s\r\n\tans = []\r\n\r\n\tfor i in range(9, 0, -1):\r\n\t\tif i <= rem:\r\n\t\t\trem -= i\r\n\t\t\tans.append(str(i))\r\n\r\n\tprint(''.join(sorted(ans)))\r\n\r\n\r\nfor _ in range(int(input())):\r\n\ts = int(input())\r\n\tfunc()\r\n"}, {"source_code": "t = int(input())\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n p = 9\r\n a = 0\r\n k=1\r\n if (n>=10):\r\n while (n>=10):\r\n n=n-p\r\n a = p*k+a\r\n k=k*10\r\n p = p-1\r\n if (p>n):\r\n a=a+k*n\r\n else:\r\n while (n>0):\r\n if (p>n):\r\n a=a+k*n\r\n break\r\n n=n-p\r\n a = p*k+a\r\n k=k*10\r\n p = p-1 \r\n print(a)\r\n \r\n else:\r\n print(n)\r\n\r\n \r\n"}, {"source_code": "def get_str_res(s):\r\n str_res = str()\r\n x = 9\r\n while s > 0:\r\n x = min(s, x)\r\n str_res += str(x)\r\n\r\n s -= x\r\n x -= 1\r\n\r\n return str_res[::-1]\r\n\r\n\r\ndef test():\r\n s = int(input())\r\n str_res = get_str_res(s)\r\n print(str_res)\r\n\r\nif __name__ == \"__main__\":\r\n count_test = int(input())\r\n for number_test in range(count_test):\r\n test()"}, {"source_code": "def test():\r\n s = int(input())\r\n\r\n str_res = ''\r\n x = 9\r\n while s > 0:\r\n if s < x:\r\n x = s\r\n\r\n str_res += str(x)\r\n s -= x\r\n x -= 1\r\n\r\n str_res = str_res[::-1]\r\n print(str_res)\r\n\r\nif __name__ == \"__main__\":\r\n count_test = int(input())\r\n for number_test in range(count_test):\r\n test()"}, {"source_code": "import io,os\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\ndef main(t):\n\n\n n = int(input())\n ans = \"\"\n for i in range(9,0,-1):\n if n >= i: \n ans += str(i)\n n -= i\n else: \n if n>0: ans += str(n)\n break\n\n\n\n ans = ans[::-1]\n\n print(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nT = int(input())\nt = 1\nwhile t<=T:\n main(t)\n t += 1\n"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n s = int(input())\r\n a = []\r\n for i in range(9, 0, -1):\r\n if s // i > 0:\r\n s -= i\r\n a.append(i)\r\n\r\n print(*a[::-1], sep='')"}, {"source_code": "'''\r\nName: Minimum Varied Number\r\nLink: https://codeforces.com/problemset/problem/1714/C\r\nCategories:\r\n'''\r\nt = int(input())\r\nslist = []\r\nfor i in range(t):\r\n slist.append(int(input()))\r\n\r\n# esas cozum\r\nfinal = []\r\nfor i in range(t):\r\n final.append([])\r\n for nz in range(9, 0, -1): # senin metodu biraz degistirdim\r\n if slist[i] - nz >= 0: # nz means 'nine to zero'\r\n final[i].append(nz)\r\n slist[i] -= nz\r\n\r\n\r\ndef Reverse(lst):\r\n new_lst = lst[::-1]\r\n return new_lst\r\n# source for reversing list: https://www.geeksforgeeks.org/python-reversing-list/\r\n\r\n\r\nfor i in range(t):\r\n print(*Reverse(final[i]), sep=\"\")\r\n"}, {"source_code": "def solve():\r\n n=int(input())\r\n s=''\r\n for i in range(9,0,-1):\r\n if n>=i:\r\n s+=str(i)\r\n n-=i\r\n print(s[::-1])\r\n\r\n \r\nt=int(input())\r\nwhile(t):\r\n solve()\r\n t-=1"}, {"source_code": "t=int(input())\r\nfor efve in range(t):\r\n n=int(input())\r\n p=n\r\n k=9\r\n mas=[]\r\n while n-k>=0 and k>0:\r\n mas+=[k]\r\n n-=k\r\n k-=1\r\n n=p\r\n mas+=[n-sum(mas)]\r\n mas.reverse()\r\n if mas[0]==0:\r\n del mas[0]\r\n print(*mas, sep=\"\")"}, {"source_code": "t = int(input())\r\nfor j in range(t):\r\n n = int(input())\r\n a = \"\"\r\n c = 9\r\n while n > c:\r\n n -= c\r\n a = str(c) + a\r\n c -= 1\r\n a = str(n) + a\r\n print(a)"}, {"source_code": "def fun(n):\r\n num = 0\r\n for i in range(9,0,-1):\r\n if n - i < 0:\r\n num += (n*(10**(9-i)))\r\n break\r\n else:\r\n n = n - i\r\n num += (i*(10**(9-i)))\r\n print(num)\r\n\r\nt = int(input())\r\n\r\nfor _ in range(t):\r\n n = int(input())\r\n fun(n)"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n s = int(input())\r\n lis = [9,8,7,6,5,4,3,2,1]\r\n nn = \"\"\r\n while s > lis[0]:\r\n a = lis.pop(0)\r\n nn += str(a)\r\n s -= a\r\n if s != 0:\r\n nn += str(s)\r\n print(nn[::-1])"}, {"source_code": "a=int(input())\r\nfor _ in range(a):\r\n s=int(input())\r\n d=[1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,189,289,389,489,589,689,789,1789,2789,3789,4789,5789,6789,16789,26789,36789,46789,56789,156789,256789,356789,456789,1456789,2456789,3456789,13456789,23456789,123456789]\r\n print(d[s-1])"}, {"source_code": "import sys\r\nimport collections\r\nfrom math import ceil, gcd, sqrt, log\r\nimport bisect\r\n# IMPORT PRACTICE AND CONCENTRATION\r\n\r\nINF = float('inf')\r\nmod = 1000000007\r\n\r\n\r\n\r\ndef solve():\r\n s = int(input())\r\n # A = list(map(int, input().split()))\r\n # s = input()\r\n # s2 = input()\r\n # net = 0\r\n\r\n ok = '123456789'\r\n minNum = 123456789\r\n\r\n for i in range(2 ** 9):\r\n b = bin(i)[2:]\r\n key = b.zfill(9)\r\n\r\n num = 0\r\n summ = 0\r\n\r\n for j in range(9):\r\n if key[j] == '1':\r\n summ += int(ok[j])\r\n num = num * 10 + int(ok[j])\r\n if summ >= s:\r\n break \r\n if summ == s and num < minNum:\r\n minNum = num\r\n \r\n print(minNum)\r\n \r\n\r\n\r\nt = int(input())\r\n\r\nwhile t != 0:\r\n solve()\r\n\r\n t -= 1\r\n "}, {"source_code": "t = int(input())\r\n \r\ndef solve():\r\n n = int(input())\r\n current_sol = set()\r\n \r\n def get(i, current_sum):\r\n if current_sum == 0:\r\n return True\r\n for i in range(9, 0, -1):\r\n if i not in current_sol and i <= current_sum:\r\n current_sol.add(i)\r\n found = get(i + 1, current_sum=current_sum-i)\r\n if found:\r\n return True\r\n current_sol.remove(i)\r\n get(0, n)\r\n return ''.join(list(map(str, sorted(current_sol))))\r\n \r\nres = []\r\nfor i in range(t):\r\n res.append(solve())\r\n \r\nfor i in res:\r\n print(i)"}, {"source_code": "for _ in range(int(input())):\r\n v = int(input())\r\n s = \"\"\r\n n = 9\r\n while True:\r\n if v>n:\r\n s=str(n)+s\r\n v-=n\r\n n-=1\r\n else:\r\n break\r\n s=str(v)+s\r\n print(int(s))"}, {"source_code": "# from numpy import sort\r\n\r\ndef solve():\r\n s = int(input())\r\n a = []\r\n for i in range(9, 0, -1):\r\n if s >= i:\r\n s -= i\r\n a.append(i)\r\n a.reverse()\r\n for e in a:\r\n print(e, end=\"\")\r\n print()\r\n\r\n \r\nif __name__ == \"__main__\":\r\n T = int(input())\r\n for t in range(T):\r\n solve()"}, {"source_code": "for u in range(int(input())):\r\n n, a = int(input()), []\r\n cur = 9\r\n while n > cur: \r\n n -= cur\r\n a.append(cur)\r\n cur -= 1\r\n if n != 0: a.append(n)\r\n a.sort()\r\n print(*a, sep = \"\")"}, {"source_code": "\nfor _ in range(int(input())):\n\tn = int(input())\n\ttemp = []\n\n\tfor i in range(9,0,-1):\n\t\ttemp.append(i)\n\n\tfor i in range(1,len(temp)):\n\t\ttemp[i] += temp[i-1]\n\n# \tprint(temp)\n\n\tout = [9,8,7,6,5,4,3,2,1]\n\n# \tlol = 0\n\n\tfor i in range(len(temp)):\n\t\tif n <= temp[i]:\n\n\t\t\tlol = i+1\n\n\t\t\tbreak\n\n# \tprint(lol)\n\t\n\tst1 = ''\n\t\n\ttempy = 0\n\tfor i in range(lol-1):\n\t\tst1 += str(out[i])\n\t\ttempy += out[i]\n\t\t\n\tst1 += str(n - tempy)\n\t\n\tst1 = list(st1)\n\t\n\tst1.sort()\n\t\n\toutok = ''.join([str(elem) for elem in st1])\n\t\n\tprint(outok)\n\t\n\t# print(st1)\n\n\n\n"}, {"source_code": "import math\r\n\r\n\r\na=int(input())\r\nb=[]\r\nfor i in range (0,a):\r\n b=int(input())\r\n answer=\"\"\r\n for j in range (1,10):\r\n m=10-j\r\n if b>m:\r\n answer= str(m) + answer\r\n b-=m\r\n else:\r\n answer=str(b) +answer\r\n break\r\n print(answer)\r\n \r\n \r\n \r\n\r\n\r\n \r\n"}, {"source_code": "\ndef solve(case):\n s = int(input())\n arr = []\n f = 0\n for i in range(9,0,-1):\n if f+i > s:\n continue\n f = f+i\n arr.append(i)\n for i in reversed(arr):\n print(i,end='')\n \n print(\"\")\n\nt = int(input())\nfor i in range(1,t+1):\n solve(i)"}, {"source_code": "for _ in range(int(input())):\r\n x='';n=int(input())\r\n for i in range(9,0,-1):\r\n if n-i>=0:n-=i;x+=str(i)\r\n print(x[::-1])\r\n \r\n"}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nprintf = lambda d: sys.stdout.write(str(d) + \"\\n\")\ndef read_int(): return int(input())\ndef read_ints(): return list(map(int, input().split()))\ndef read_str(): return input().strip()\n\n\ndef dfs(n, s, mx):\n if n <= mx:\n return s + f\"{n}\"\n else:\n return dfs(n - mx, s + f'{mx}', mx - 1)\n\n\nfor _ in range(read_int()):\n n = read_int()\n print(dfs(n, '', 9)[::-1])\n\n\n\n\n"}, {"source_code": "# from cgi import test\r\n\r\n#A\r\n'''\r\ntest = int(input())\r\nfor i in range(test):\r\n n,H,M = map(int, input().split())\r\n arr = []\r\n for i in range(n):\r\n h,m = map(int,input().split())\r\n minute = h*60+m\r\n arr.append(minute)\r\n arr.sort()\r\n sleep = H*60+M\r\n i = 0\r\n while arr[i]<sleep and i < len(arr)-1:\r\n i+=1\r\n if arr[i] >= sleep:\r\n time = (arr[i] - sleep)\r\n else:\r\n time = (24*60 - sleep + arr[0])\r\n h_out = time//60\r\n m_out = time%60\r\n print(h_out,m_out)\r\n'''\r\n#B\r\n'''\r\ntest = int(input())\r\nfor i in range(test):\r\n n = int(input())\r\n arr = list(map(int, input().split()))\r\n i = n -1\r\n set1 = set()\r\n while arr[i] not in set1 and i>=0:\r\n set1.add(arr[i])\r\n i-=1\r\n print(i+1)\r\n'''\r\n#C\r\ntest = int(input())\r\nfor i in range(test):\r\n n = int(input())\r\n if n <= 9:\r\n print(n)\r\n else:\r\n k = 9\r\n sum = 0\r\n while sum < n and k >0:\r\n sum += k\r\n k-=1\r\n if sum > n:\r\n # print(k)\r\n count = 0\r\n out = \"\"\r\n j = k+2\r\n while j <=9:\r\n out = out + str(j)\r\n count+=j\r\n j+=1\r\n \r\n # print('count', count)\r\n out = str(n-count) + out\r\n else:\r\n j = k+1\r\n out = \"\"\r\n while j <=9:\r\n out = out + str(j)\r\n j+=1\r\n print(int(out))"}, {"source_code": "t = int(input())\r\nfor i in range(t):\r\n s = int(input())\r\n p = 9\r\n c = 0\r\n l=[]\r\n m = []\r\n if s<=9:\r\n l.append(s)\r\n l.reverse()\r\n print(*l)\r\n else:\r\n while(True):\r\n if s<=p:\r\n c=c+1\r\n \r\n l.append(s)\r\n l.reverse()\r\n for j in l:\r\n \tu =str(j)\r\n \tm.append(u)\r\n \r\n m = ''.join(m)\r\n print(m)\r\n break\r\n s=s-p\r\n c=c+1\r\n l.append(p)\r\n p=p-1"}, {"source_code": "from collections import *\r\nfrom math import *\r\nfor y in range(int(input())):\r\n n=int(input())\r\n# lst=list(map(int,input().split()))\r\n# dic=defaultdict(int)\r\n# i=n-1\r\n# while i>=0:\r\n# if dic[lst[i]]==1:\r\n# break\r\n# i-=1\r\n# dic[lst[i]]=1\r\n# print(i+1)\r\n ans=''\r\n cur=9\r\n while n>0:\r\n if n<=cur:\r\n ans=str(n)+ans\r\n n=0\r\n else:\r\n ans=str(cur)+ans\r\n n-=cur\r\n cur-=1\r\n print(ans)"}, {"source_code": "n = int(input())\r\nfor i in range(n):\r\n a = int(input())\r\n k = []\r\n if a <= 9:\r\n k += [a]\r\n else:\r\n sum1 = 9\r\n k += [9]\r\n while sum(k) < a:\r\n for j in range(8, 1, -1):\r\n if a - sum(k) < j:\r\n k += [a - sum(k)]\r\n break\r\n else:\r\n k += [j]\r\n ans = ''\r\n for elem in reversed(k):\r\n ans += str(elem)\r\n print(int(ans))\r\n\r\n"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n s = int(input())\r\n if s < 10:\r\n print(s)\r\n else:\r\n sum = s - 9\r\n l = [\"9\"]\r\n i = 8\r\n while sum != 0:\r\n if i <= sum:\r\n sum -= i\r\n l.insert(0, str(i))\r\n i -= 1\r\n print(\"\".join(l))"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n if n <= 9:\r\n print(n)\r\n elif n <= 17:\r\n print((\"9%d\"%(n-9))[::-1])\r\n elif n <= 24:\r\n print((\"98%d\"%(n-17))[::-1])\r\n elif n <= 30:\r\n print((\"987%d\"%(n-24))[::-1])\r\n elif n <= 35:\r\n print((\"9876%d\"%(n-30))[::-1])\r\n elif n <= 39:\r\n print((\"98765%d\"%(n-35))[::-1])\r\n elif n <= 42:\r\n print((\"987654%d\"%(n-39))[::-1])\r\n elif n <= 44:\r\n print((\"9876543%d\"%(n-42))[::-1])\r\n elif n <= 45:\r\n print((\"98765432%d\"%(n-44))[::-1])"}, {"source_code": "\r\ndef solve():\r\n s = int(input())\r\n nums = []\r\n\r\n for i in range(9, 0, -1):\r\n if s - i >= 0:\r\n nums.append(str(i))\r\n s = s - i\r\n \r\n nums.sort()\r\n\r\n nums = ''.join(nums)\r\n\r\n print(int(nums))\r\n \r\n\r\nt = int(input())\r\n\r\nwhile t > 0:\r\n t -= 1\r\n solve()\r\n"}, {"source_code": "t=int(input(\"\"))\r\nfor i in range(t):\r\n s=int(input(\"\"))\r\n c=9\r\n l=[]\r\n p=\"\"\r\n while(s>0):\r\n if(c>s):\r\n c=s\r\n s=s-c\r\n l.append(c)\r\n else:\r\n s=s-c\r\n l.append(c)\r\n c=c-1\r\n # print(l)\r\n \r\n \r\n for i in range(len(l)):\r\n p=str(l[i])+p\r\n print(p)\r\n "}, {"source_code": "n=int(input())\r\nfor i in range(n):\r\n a=int(input())\r\n b=[0]*10\r\n c=''\r\n for j in range(9,0,-1):\r\n if b[j]==0 and a>=j:\r\n b[j]=1\r\n a-=j\r\n c=str(j)+c\r\n print(c) \r\n "}, {"source_code": "t=int(input())\r\nfor h in range(0,t):\r\n ans=\"\"\r\n i=0\r\n s=int(input())\r\n while s>9-i:\r\n ans=str(9-i)+ans\r\n s=s-(9-i)\r\n i=i+1\r\n ans=str(s)+ans\r\n print(ans)"}, {"source_code": "\r\n\r\n\r\n\r\n\r\n\r\ndef solve():\r\n n=int(input())\r\n i=9\r\n s=0\r\n t=1\r\n s1=0\r\n while(s1!=n):\r\n if s1+i>n:\r\n i-=1\r\n else:\r\n s1+=i;\r\n s+=t*i;\r\n i-=1;\r\n t*=10;\r\n print(s)\r\n\r\n\r\n\r\n\r\n \r\n\r\n \r\n \r\n\r\nt=int(input())\r\nfor i in range(t):\r\n solve()"}, {"source_code": "from collections import Counter, deque, defaultdict\nimport math\nfrom itertools import permutations, accumulate\nfrom sys import *\nfrom heapq import *\nfrom bisect import bisect_left, bisect_right\nfrom functools import cmp_to_key\nfrom random import randint\nxor = randint(10 ** 7, 10**8)\n# https://docs.python.org/3/library/bisect.html\non = lambda mask, pos: (mask & (1 << pos)) > 0\nlcm = lambda x, y: (x * y) // math.gcd(x,y)\nrotate = lambda seq, k: seq[k:] + seq[:k] # O(n)\ninput = stdin.readline\n'''\nCheck for typos before submit, Check if u can get hacked with Dict (use xor)\nObservations/Notes: \n\n'''\nfor _ in range(int(input())):\n n = int(input())\n ans = []\n seen = set()\n while True:\n if n == 0:\n break\n for i in range(9, 0, -1):\n if i <= n and i not in seen:\n ans.append(str(i))\n seen.add(i)\n n -= i\n break\n ans = ans[::-1]\n print(''.join(ans))\n \n\n\n\n"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n if 1 <= s < 10: # 10-1 = 9\r\n print(s)\r\n elif 10 <= s < 18: # 18-10 = 8\r\n print(10*(s-9) + 9)\r\n elif 18 <= s < 25: # 25-18 = 7\r\n print(100*(s-17) + 89)\r\n elif 25 <= s < 31: # 31-25 = 6\r\n print(1000*(s-24) + 789)\r\n elif 31 <= s < 36: # 36-31 = 5\r\n print(10000*(s-30) + 6789)\r\n elif 36 <= s < 40: # 40-36 = 4\r\n print(100000*(s-35) + 56789)\r\n elif 40 <= s < 43: # 43-40 = 3\r\n print(1000000*(s-39) + 456789)\r\n elif 43 <= s < 45: # 45-43 = 2\r\n print(10000000*(s-42) + 3456789)\r\n elif s == 45:\r\n print(123456789)"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n n = 9\r\n ans = \"\"\r\n while n:\r\n if s >= n:\r\n s -= n\r\n ans += str(n)\r\n n -= 1\r\n print(int(ans[::-1]))"}, {"source_code": "arr=[1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,189,289,389,489,589,689,789,1789,2789,3789,4789,5789,6789,16789,26789,36789,46789,56789,156789,256789,356789,456789,1456789,2456789,3456789,13456789,23456789,123456789]\r\nfor i in range(int(input())):\r\n print(arr[int(input())-1])"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n i = 9\r\n res = []\r\n while s!=0 and s>=i:\r\n res.append(str(i))\r\n s-=i\r\n i-=1\r\n if s>0:\r\n res.append(str(s))\r\n print(''.join(res[::-1]))"}, {"source_code": "sum=0\r\ns=[]\r\ny=input()\r\nfor j in range(int(y)):\r\n x = input()\r\n f = int(x)\r\n for i in range(9,0,-1):\r\n if f>=i:\r\n sum=sum+i\r\n f=int(x)-sum\r\n s.append(i)\r\n s.reverse()\r\n for i in s:\r\n print(i,end='')\r\n print('\\n')\r\n sum=0\r\n s=[]"}, {"source_code": "class Solver1714C:\r\n\r\n def __init__(self):\r\n self.s = int(input())\r\n\r\n def solve(self):\r\n\r\n arr = []\r\n\r\n for i in range(9, 0, -1):\r\n if self.s >= i:\r\n self.s = self.s - i\r\n arr.append(i)\r\n\r\n arr = arr[::-1]\r\n\r\n print(''.join(map(str, arr)))\r\n\r\n\r\nt = int(input())\r\n\r\nwhile t:\r\n\r\n t -= 1\r\n\r\n cur = Solver1714C()\r\n\r\n cur.solve()\r\n"}, {"source_code": "if __name__ == \"__main__\":\r\n c = [9, 17, 24, 30, 35, 39, 42, 44, 45]\r\n for _ in range(int(input())):\r\n n = int(input())\r\n if n > 45:\r\n print(-1)\r\n elif n <= 9:\r\n print(n)\r\n else:\r\n r = 0\r\n for j, i in enumerate(c):\r\n if n <= i:\r\n r = j + 1\r\n break\r\n l = [1, 2, 3, 4, 5, 6, 7, 8, 9][: r]\r\n i, s, j = r - 1, ((1 + r) * r) // 2, 9\r\n s = n - s\r\n while s != 0:\r\n \r\n r = j - l[i]\r\n if r == s:\r\n l[i] = j\r\n s = 0\r\n elif r > s:\r\n l[i] += s\r\n s = 0\r\n else:\r\n l[i] = j\r\n s -= r\r\n j -= 1\r\n i -= 1\r\n for i in l:\r\n print(i,end='')\r\n print()"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n ans=[]\r\n s=\"\"\r\n for i in range(9,0,-1):\r\n if n-i==0:\r\n ans.append(i)\r\n\r\n break\r\n elif n>i:\r\n n-=i\r\n ans.append(i)\r\n\r\n for i in ans:\r\n s+=str(i)\r\n print(int(s[::-1]))"}, {"source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n ans = []\r\n for i in range(9, 0, -1):\r\n tmp = n - i\r\n if tmp < 0:\r\n ans.append(n)\r\n break\r\n else:\r\n n -= i\r\n ans.append(i)\r\n\r\n s = ''\r\n for i in ans[::-1]:\r\n s += str(i)\r\n print(int(s))"}, {"source_code": "t = int(input())\r\nfor i in range(0, t):\r\n n = int(input())\r\n g = n\r\n s = 9\r\n if n < 10:\r\n print(n)\r\n continue\r\n if n == 10:\r\n print(19)\r\n continue\r\n d = \"\"\r\n while n > s:\r\n if n > s:\r\n d += str(s)\r\n n-=s\r\n s-=1\r\n else:\r\n break\r\n sum1 = 0\r\n for j in range(0, len(d)):\r\n sum1 += int(d[j])\r\n if g - sum1 == 0:\r\n pass\r\n else:\r\n f = g - sum1\r\n d += str(f)\r\n counter = \"\"\r\n for j in range(len(d)-1, -1, -1):\r\n counter += d[j]\r\n print(int(counter))"}, {"source_code": "import sys\r\ninput=sys.stdin.readline\r\nfor _ in range(int(input())):\r\n n=int(input())\r\n #n,h,m=map(int,input().split())\r\n #l=list(map(int,input().split()))\r\n s=\"\"\r\n k=9\r\n while n>0:\r\n if k>n:\r\n s=str(n)+s\r\n n=0\r\n else:\r\n s=str(k)+s\r\n n=n-k\r\n k=k-1\r\n print(s)"}, {"source_code": "t=int(input())\r\nfor i in range(0,t):\r\n s=int(input())\r\n k=0\r\n no=0\r\n b=9\r\n while(s>9):\r\n \r\n no=no+(10**k)*b\r\n k=k+1\r\n s=s-b\r\n b=b-1\r\n if(s<=9 and s>=b):\r\n while(s<=9 and s>=b and s>0 ):\r\n \r\n no=no+(10**k)*(b)\r\n s=s-(b)\r\n b=b-1\r\n k=k+1\r\n if(s!=0):\r\n no=no+(10**k)*s\r\n \r\n else:\r\n no=no+(10**k)*s\r\n \r\n \r\n print(no)\r\n"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n s = \"\"\r\n idx = 9\r\n while n > idx:\r\n n -= idx\r\n s = str(idx) + s\r\n idx -= 1\r\n print(str(n) + s)"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n n = d = 0\r\n for i in range(9, 0, -1):\r\n if d+i > s:\r\n n += (s-d)*10**(len(str(n)))\r\n break\r\n d += i\r\n n += i*10**(len(str(n)))\r\n print(n//10)"}, {"source_code": "t=int(input())\r\n\r\ndef main(s):\r\n if s<=9 :\r\n return int(s)\r\n li=[9]\r\n counter=8\r\n while sum(li) < int (s):\r\n li=[counter]+li\r\n counter-=1\r\n li[0]=int(s) - sum(li[1:])\r\n\r\n ans=0\r\n for i in li:\r\n ans=ans*10 +i\r\n return(ans)\r\n\r\n# print(main(10))\r\n\r\nfor i in range(t):\r\n s=int(input())\r\n print(main(s))"}, {"source_code": "t = int(input())\r\nlookup = {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 19, 11: 29, 12: 39, 13: 49, 14: 59, 15: 69, 16: 79, 17: 89, 18: 189, 19: 289, 20: 389, 21: 489, 22: 589, 23: 689, 24: 789, 25: 1789, 26: 2789, 27: 3789, 28: 4789, 29: 5789, 30: 6789, 31: 16789, 32: 26789, 33: 36789, 34: 46789, 35: 56789, 36: 156789, 37: 256789, 38: 356789, 39: 456789, 40: 1456789, 41: 2456789, 42: 3456789, 43: 13456789, 44: 23456789, 45: 123456789}\r\nfor i in range(t):\r\n print(lookup[int(input())])"}, {"source_code": "import sys\r\nfrom sys import stdin\r\nimport math\r\nimport bisect\r\nfrom collections import defaultdict,Counter,deque\r\nfrom itertools import accumulate\r\nfrom itertools import product,permutations,combinations,repeat,combinations_with_replacement\r\nINF= 10**20\r\n# binary search to find greater element less than key\r\ndef greatest_lesser(lst,num):\r\n i=0\r\n j=len(lst)-1\r\n ans=-1\r\n while i<=j:\r\n mid= (i+j)//2\r\n if num==lst[mid]:\r\n j=mid-1\r\n elif num<lst[mid]:\r\n j=mid-1\r\n else:\r\n ans=mid\r\n i=mid+1\r\n return ans\r\nfor _ in range(int(stdin.readline())):\r\n #n= int(stdin.readline())\r\n s= int(stdin.readline())\r\n sc=s\r\n if s<=9:\r\n print(s)\r\n else:\r\n ans=[]\r\n num=9\r\n while s>9 and num>0:\r\n s-=num\r\n ans.append(num)\r\n num-=1\r\n d= s\r\n #print(s,num)\r\n if d<=num:\r\n ans.append(d)\r\n print(''.join(map(str,reversed(ans))))\r\n else:\r\n ans.append(num)\r\n s-=num\r\n if num==d-num:\r\n ans.append(num-1)\r\n ans.append(1)\r\n else:\r\n num-=1\r\n if s<=num:\r\n ans.append(s)\r\n else:\r\n ans.append(num)\r\n if num == s - num:\r\n ans.append(num - 1)\r\n ans.append(1)\r\n else:\r\n ans.append(s-num)\r\n print(''.join(map(str, reversed(ans))))\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\nfrom collections import deque\r\ndef rs(): return sys.stdin.readline().rstrip()\r\ndef ri(): return int(sys.stdin.readline())\r\ndef ria(): return deque(map(int, sys.stdin.readline().split()))\r\ndef ws(s): sys.stdout.write(s)\r\ndef wi(n): sys.stdout.write(str(n) + '\\n')\r\ndef wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\\n')\r\n #--------------------Solution------------------------\r\nx=[0,1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,189,289,389,489,589,689,789,1789,2789,3789,4789,5789,6789,16789,26789,36789,46789,56789,156789,256789,356789,456789,1456789,2456789,3456789,13456789,23456789,123456789]\r\nfor _ in range(ri()):\r\n n=ri()\r\n wi(x[n])\r\n \r\n "}, {"source_code": "def dfs(pos,target,path):\r\n if target == 0:\r\n ans.append(int(path))\r\n return\r\n if target<0 or pos == len(nums):\r\n return\r\n \r\n for i in range(pos,len(nums)):\r\n dfs(i+1,target-nums[i],path+str(nums[i]))\r\n \r\nt = int(input())\r\n\r\nfor _ in range(t):\r\n s = input()\r\n ans = []\r\n nums = [1,2,3,4,5,6,7,8,9]\r\n dfs(0,int(s),\"\")\r\n print(min(ans))\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n "}, {"source_code": "for _ in range(int(input())):\r\n a=int(input())\r\n c=a\r\n s=''\r\n sum=0\r\n num=''\r\n b=[0,1,2,3,4,5,6,7,8,9]\r\n if a<10:\r\n print(a)\r\n else:\r\n\r\n while sum != a:\r\n if sum == a:\r\n print(a)\r\n break\r\n\r\n else:\r\n if c in b:\r\n sum = sum + c\r\n s=str(c)+s\r\n print(int(s))\r\n break\r\n else:\r\n sum = sum + max(b)\r\n s = str(max(b)) + s\r\n c = c - max(b)\r\n b.remove(max(b))\r\n"}, {"source_code": "def finish(used: list):\n used.sort()\n print(*used, sep=\"\")\nfor _ in range(int(input())):\n org = int(input())\n n = org\n if n < 10:\n print(n)\n continue\n used = []\n for i in range(9, -1, -1):\n used.append(i)\n n -= i\n if n == 0:\n finish(used)\n break\n if n < 0:\n used.pop()\n used.insert(0, org - sum(used))\n finish(used)\n break\n \n "}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n counted = \"\"\r\n maximum = 9\r\n i = n\r\n while n > 0:\r\n if n < 10:\r\n if str(i) not in counted:\r\n counted +=f\"{i}\"\r\n n -= i\r\n i = n\r\n else: \r\n i -= 1\r\n else:\r\n n = n - maximum\r\n counted +=f\"{maximum}\"\r\n maximum -= 1\r\n i = n \r\n print(counted[::-1])"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n <= 9: print(n)\r\n else:\r\n k, s = 9, ''\r\n while True:\r\n if k <= n and n != 0:\r\n s += str(k)\r\n n -= k\r\n k -= 1\r\n elif n != 0 and k > n:\r\n s += str(n)\r\n break\r\n elif n == 0:\r\n break\r\n s = s[::-1]\r\n print(s)"}, {"source_code": "n_testcases = int(input())\r\n\r\nresults = []\r\n\r\nwhile (n_testcases > 0):\r\n\r\n max_usable = 9\r\n to_reach = int(input())\r\n\r\n num = []\r\n left = to_reach\r\n while left > 0 and max_usable > 0:\r\n #print(\"left: \", left)\r\n #print(\"max usable: \", max_usable)\r\n #print(\"actual building: \", num)\r\n #print(\"------------\")\r\n while max_usable <= left and max_usable > 0:\r\n #print(\"########## left: \", left)\r\n #print(\"########## max usable: \", max_usable)\r\n #print(\"------------\")\r\n num.append(str(max_usable))\r\n left -= max_usable\r\n max_usable -= 1\r\n max_usable -= 1\r\n\r\n\r\n num_int = int(''.join(num[::-1])) \r\n\r\n results.append(num_int)\r\n n_testcases -= 1\r\n\r\nfor i in range(len(results)):\r\n print(results[i])\r\n\r\n#print(\"end\")"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n s = int(input())\r\n a = ''\r\n n = 9\r\n \r\n while s > 0:\r\n if s < n:\r\n n = s\r\n a = str(n) + a\r\n s -= n\r\n n -= 1\r\n print(a)"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n cnt=0\r\n ans=\"\"\r\n for i in range(9,-1,-1):\r\n if (cnt+i)>n:\r\n ans=ans+str(n-cnt)\r\n break\r\n else:\r\n cnt=cnt+i\r\n ans=ans+str(i)\r\n if ans[-1]==\"0\":\r\n print(ans[::-1][1::])\r\n else:\r\n print(ans[::-1])\r\n "}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n #n,m = map(int, input().split())\r\n s = \"\"\r\n i = 0\r\n if n < 10:\r\n print(n)\r\n continue\r\n while n > 9:\r\n s = str(9 - i) + s\r\n n -= 9 - i\r\n i += 1\r\n if n != 0:\r\n while n >= int(s[0]):\r\n n -= int(s[0]) - 1\r\n s = str(int(s[0]) - 1) + s\r\n if n != 0 and len(s) < 9:\r\n s = str(n) + s\r\n print(int(s))\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\n\r\n\r\ndef choose(curr_num) :\r\n if curr_num > 1 :\r\n if ans[curr_num-1] <= ans[curr_num-2] :\r\n return\r\n\r\n if sum(ans) == s:\r\n nums.append(ans[:])\r\n return\r\n\r\n for i in range(1, 10) :\r\n ans.append(i)\r\n choose(curr_num + 1)\r\n ans.pop()\r\n \r\n return\r\n\r\n\r\nt = int(input())\r\nfor _ in range(t) : \r\n ans = []\r\n nums = []\r\n s = int(input())\r\n choose(0)\r\n min_len = sys.maxsize\r\n for elem in nums :\r\n min_len = min(min_len, len(elem))\r\n \r\n min_ans = []\r\n for elem in nums : \r\n if len(elem) == min_len :\r\n min_ans.append(elem)\r\n \r\n min_ans.sort()\r\n for elem in min_ans[0] :\r\n print(elem, end = \"\")\r\n print()"}, {"source_code": "t = int(input())\n\ndef getNrFromList(vals):\n\tnr = 0\n\tfor val in vals:\n\t\tnr = nr * 10 + val\n\treturn nr\n\nfor _ in range(t):\n\tn = int(input())\n\tif n < 10:\n\t\tmini = n\n\telse:\n\t\tmini = float('inf')\n\t\tfor i in range(1, 10):\n\t\t\tusedDigits = set([i])\n\t\t\tsumDigits = n - i\n\t\t\tnotFound = False\n\t\t\twhile sumDigits and not notFound:\n\t\t\t\tnotFound = True\n\t\t\t\tfor j in range(9, 0, -1):\n\t\t\t\t\tif j not in usedDigits and j <= sumDigits:\n\t\t\t\t\t\tsumDigits -= j\n\t\t\t\t\t\tusedDigits.add(j)\n\t\t\t\t\t\tnotFound = False\n\t\t\t\t\t\tbreak\n\t\t\tif sumDigits == 0:\n\t\t\t\tmini = min(getNrFromList(sorted(list(usedDigits))), mini)\n\tprint(mini)"}, {"source_code": "def fun(x):\r\n a=[i for i in range(1,10)]\r\n if x<10:\r\n return str(x)\r\n i=8\r\n ans=[]\r\n s=0\r\n while i<9:\r\n if s+a[i]<=x:\r\n s+=a[i]\r\n ans.append(str(a[i]))\r\n if s==x:\r\n return ans\r\n i-=1\r\n\r\nfor _ in range(int(input())):\r\n x=int(input())\r\n m=(fun(x))\r\n m=\"\".join(m)\r\n print(m[::-1])\r\n"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n count = 9\r\n lst = []\r\n if(n<10):\r\n print(n)\r\n else:\r\n while(n>=1):\r\n if(n-count>=0):\r\n n-=count\r\n lst.append(count)\r\n count-=1\r\n lst.sort()\r\n for i in range(len(lst)):\r\n lst[i] = str(lst[i])\r\n ans = \"\".join(lst)\r\n print(ans)\r\n\r\n"}, {"source_code": "for Pythonic__Python in range(int(input())):\r\n n=int(input())\r\n l=[[i,True] for i in range(9,0,-1)]\r\n ans=\"\"\r\n while n:\r\n for i in range(len(l)):\r\n if n>=l[i][0] and l[i][1]:\r\n l[i][1]=False\r\n n-=l[i][0]\r\n ans=str(l[i][0])+ans\r\n print(ans)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n ans = []\r\n k = 9\r\n while n > 9:\r\n n = n - k\r\n ans.append(k)\r\n k -= 1\r\n\r\n if n in ans:\r\n k = ans[-1] - 1\r\n while n-k >= 0 and k >= 1:\r\n n = n - k\r\n ans.append(k)\r\n k -= 1\r\n if n > 0:\r\n ans.append(n)\r\n\r\n else:\r\n ans.append(n)\r\n print(\"\".join([str(i) for i in ans[::-1]]))"}, {"source_code": "t = int(input())\r\n\r\nfor _ in range(t):\r\n n = int(input())\r\n ans = ''\r\n i = 9\r\n while n != 0:\r\n if n >= i:\r\n n -= i\r\n ans = str(i) + ans\r\n else:\r\n ans = str(n) + ans\r\n n = 0\r\n break\r\n i -= 1\r\n print(ans)"}, {"source_code": "def check(n):\r\n if n > 39:\r\n i = 1456789\r\n step = 1000000\r\n elif n > 29:\r\n i = 6789\r\n step = 10000\r\n elif n > 19:\r\n i = 389\r\n step = 100\r\n elif n > 9:\r\n i = 19\r\n step = 10\r\n else:\r\n i = 1\r\n step = 1\r\n while True:\r\n s = []\r\n j = i\r\n while j > 0:\r\n if j % 10 in s:\r\n break\r\n else:\r\n s.append(j%10)\r\n j //= 10\r\n if sum(s) == n:\r\n return i\r\n else:\r\n i += step\r\n\r\n\r\nn = int(input())\r\nlst = [int(input()) for i in range(n)]\r\nlst2 = []\r\nfor i in lst:\r\n lst2.append(check(i))\r\nprint(*lst2, sep='\\n')"}], "negative_code": [{"source_code": "import sys\r\nimport math\r\n\r\n\r\ndef II(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int, sys.stdin.readline().split()))\r\ndef LS(): return sys.stdin.readline().strip().split()\r\ndef SI(): return sys.stdin.readline().strip()\r\ndef MIN_INT(): return -1 * sys.maxsize\r\ndef MAX_INT(): return sys.maxsize\r\ndef prefSum(arr, n):\r\n P = [0] * (n + 1)\r\n for k in range(1, n + 1):\r\n P[k] = P[k - 1] + arr[k - 1]\r\n return P\r\n\r\n\r\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\r\n\r\n\r\ndef solve():\r\n n = II()\r\n i = 1\r\n ans = [9]\r\n if n <= 9:\r\n print(n)\r\n else:\r\n now = sum(ans)\r\n x = True\r\n while now < n and x:\r\n while i < ans[-1]-1:\r\n if now + i == n:\r\n ans.append(i)\r\n x = False\r\n break\r\n i += 1\r\n now += i\r\n ans.append(i)\r\n i = 1\r\n if sum(ans) == n:\r\n for i in ans[::-1]:\r\n print(i,end='')\r\n print()\r\n else:\r\n ans.pop(-1)\r\n for i in ans[::-1]:\r\n print(i,end='')\r\n print()\r\n\r\n\r\ndef main():\r\n t = II()\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nmain()\r\n"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n a=int(input())\r\n s=[]\r\n for j in range(9,0,-1):\r\n if j<=a:\r\n s.append(j)\r\n a=a-j\r\n print(s)"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n s=int(input())\r\n result=[]\r\n for j in range(9,0,-1):\r\n if(s>=j):\r\n result.append(j)\r\n s=s-j\r\n for k in result:\r\n print(k,end='')\r\n print()"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n ans = ''\r\n for i in range(9, 0, -1):\r\n if i <= s:\r\n ans = str(i) + ans\r\n s -= i\r\n else:\r\n ans = str(s) + ans\r\n break\r\n print(ans)"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n counted = \"\"\r\n maximum = 9\r\n i = n\r\n while n > 0:\r\n if n < 10:\r\n if str(i) not in counted:\r\n counted +=f\"{i}\"\r\n n -= i\r\n else: \r\n i -= 1\r\n else:\r\n n = n - maximum\r\n counted +=f\"{maximum}\"\r\n maximum -= 1\r\n i = n \r\n print(counted[::-1])"}, {"source_code": "for i in range(int(input())):\r\n a = int(input())\r\n if a == 1:\r\n print(1)\r\n elif a == 2:\r\n print(2)\r\n elif a == 3:\r\n print('5')\r\n elif a == 4:\r\n print('5')\r\n elif a == 5:\r\n print(5)\r\n elif a == 6:\r\n print(6)\r\n elif a == 7:\r\n print('7')\r\n elif a == 8:\r\n print('8')\r\n elif a == 9:\r\n print(9)\r\n elif a == 10:\r\n print('19')\r\n elif a == 11:\r\n print('128')\r\n elif a == 12:\r\n print('129')\r\n elif a == 13:\r\n print('247')\r\n elif a == 14:\r\n print('239')\r\n elif a == 15:\r\n print('267')\r\n elif a == 16:\r\n print('268')\r\n elif a == 17:\r\n print('269')\r\n elif a == 18:\r\n print('279')\r\n elif a == 19:\r\n print('289')\r\n elif a == 20:\r\n print('389')\r\n elif a == 21:\r\n print('489')\r\n elif a == 22:\r\n print('589')\r\n elif a == 23:\r\n print('689')\r\n elif a == 24:\r\n print('789')\r\n elif a == 25:\r\n print('1789')\r\n elif a == 26:\r\n print('2789')\r\n elif a == 27:\r\n print('3789')\r\n elif a == 28:\r\n print('4789')\r\n elif a == 29:\r\n print('5789')\r\n elif a == 30:\r\n print('6789')\r\n elif a == 31:\r\n print('16789')\r\n elif a == 32:\r\n print('26789')\r\n elif a == 33:\r\n print('36789')\r\n elif a == 34:\r\n print('46789')\r\n elif a == 35:\r\n print('56789')\r\n elif a == 36:\r\n print('156789')\r\n elif a == 37:\r\n print('256789')\r\n elif a == 38:\r\n print('356789')\r\n elif a == 39:\r\n print('456789')\r\n elif a == 40:\r\n print('1456789')\r\n elif a == 41:\r\n print('2456789')\r\n elif a == 42:\r\n print('3456789')\r\n elif a == 43:\r\n print('13456789')\r\n elif a == 44:\r\n print('23456789')\r\n else:\r\n if a == 45:\r\n print('123456789')\r\n \r\n \r\n"}, {"source_code": "s=int(input())\r\nlst=[]\r\nfor i in range(9,0,-1):\r\n s=s-i\r\n if(s>=0):\r\n lst.append(i)\r\n else:\r\n s=s+i\r\nlst.reverse()\r\nfor i in lst:\r\n print(i,end=\"\")"}, {"source_code": "t=int(input())\nfor i in range(t):\n\ts=int(input())\n\tc=9\n\tm=0\n\tfor k in range(45):\n\t\tif(s>0 and c>0):\n\t\t\tif(c<=s):\n\t\t\t\tm=m*10\n\t\t\t\tm+=c\n\t\t\t\ts-=c\n\t\t\t\tc-=1\n\tch=str(m*10)\n\tch = sorted(ch)\n\tch = ''.join(ch)\n\tch = int(ch)\n\tprint(ch)\n"}, {"source_code": "# https://codeforces.com/contest/1714/problem/C\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n result = \"9\"\r\n \r\n for i in range(9, 0, -1):\r\n if n < int(result[0]):\r\n break\r\n result = str(i) + result\r\n n -= i\r\n\r\n print(str(n) + result[:-1])"}, {"source_code": "n=int(input())\r\ns=0\r\nr=\"\"\r\nfor i in range(9,0,-1):\r\n s+=i\r\n if s>n:\r\n s-=i\r\n else:\r\n r=str(i)+r\r\nprint(r)"}, {"source_code": "t = int(input())\r\nwhile(t>0):\r\n n=int(input())\r\n if(n<10):\r\n print(n)\r\n else:\r\n s = \"\"\r\n temp = 9\r\n while(temp>0 and n>0):\r\n if(n-temp>=0):\r\n s+=str(temp)\r\n n-=temp\r\n temp-=1\r\n print(s)\r\n t-=1\r\n \r\n"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n <= 9:\r\n print(n)\r\n continue\r\n ans = ''\r\n for num in range(9, 0, -1):\r\n if n >= num:\r\n ans += str(num)\r\n n -= num\r\n else:\r\n ans += str(n)\r\n break\r\n print(ans[::-1])"}, {"source_code": "cp = int(input())\r\nfor i in range(cp):\r\n n = int(input())\r\n r = \"\"\r\n for i in reversed(range(1, 10)):\r\n if n >= i:\r\n n -= i\r\n r = str(i)+r\r\n print(int(r))"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n if n <= 9:\r\n print(n)\r\n elif n <= 17:\r\n print(\"9%d\"%(n-9))\r\n elif n <= 24:\r\n print(\"98%d\"%(n-17))\r\n elif n <= 30:\r\n print(\"987%d\"%(n-24))\r\n elif n <= 35:\r\n print(\"9876%d\"%(n-30))\r\n elif n <= 39:\r\n print(\"98765%d\"%(n-35))\r\n elif n <= 42:\r\n print(\"987654%d\"%(n-39))\r\n elif n <= 44:\r\n print(\"9876543%d\"%(n-42))\r\n elif n <= 45:\r\n print(\"98765432%d\"%(n-44))"}, {"source_code": "sum=0\r\ns=[]\r\ny=input()\r\nfor j in range(int(y)):\r\n x = input()\r\n f = int(x)\r\n for i in range(9,0,-1):\r\n if f>=i:\r\n sum=sum+i\r\n f=int(x)-sum\r\n s.append(i)\r\n s.reverse()\r\n for i in s:\r\n print(i,end='')\r\n sum=0\r\n s=[]\r\n"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n < 10:\r\n print(n)\r\n continue\r\n s = \"\"\r\n a = 9\r\n for a in range(9, 0, -1):\r\n if n >= a:\r\n s += str(a)\r\n n -= a\r\n else:\r\n s += str(n)\r\n break\r\n print(s[::-1])\r\n"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n ans = []\r\n for num in range(9, 0, -1):\r\n if n >= num:\r\n ans.append(num)\r\n n -= num\r\n else:\r\n ans.append(n)\r\n break\r\n ans.sort()\r\n for i in ans:\r\n print(i, end='')\r\n"}, {"source_code": "t=int(input())\r\nwhile(t>0):\r\n n=int(input())\r\n result=\"\"\r\n for i in range(9,0,-1):\r\n if(n>=i):\r\n result=str(i)+result\r\n n=n-i\r\n print(i)\r\n t-=1\r\n "}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n ans = ''\r\n for i in range(9, 0, -1):\r\n if i <= s:\r\n ans = str(i) + ans\r\n s -= i\r\n else:\r\n ans = str(s) + ans\r\n break\r\n print(ans)"}, {"source_code": "t = int(input())\r\nwhile t:\r\n n = int(input())\r\n if n < 10:\r\n print(n)\r\n elif n >= 10 and n<=17:\r\n d = {10:19,11:29,12:39,13:49,14:59,15:69,16:79,17:89}\r\n print(d[n])\r\n elif n>17 and n<=24:\r\n d = {18:189,19:289,20:389,21:489,22:589,23:689,24:789}\r\n print(d[n])\r\n elif n>24 and n<=30:\r\n d = {25:1789,26:2789,27:3789,28:4789,29:5789,30:6789}\r\n print(d[n])\r\n elif n>30 and n<=35:\r\n ans = (n - 31) + 1\r\n print(str(ans)+\"6789\")\r\n elif n>35 and n<=39:\r\n ans = (n - 36) + 1\r\n print(str(ans)+\"56789\")\r\n elif n>39 and n<=42:\r\n ans = (n-39) + 1\r\n print(str(ans)+\"456789\")\r\n elif n>42:\r\n if n == 43:\r\n print(\"13456789\")\r\n elif n==44:\r\n print(\"23456789\")\r\n elif n==45:\r\n print(\"123456789\")\r\n t -= 1\r\n \r\n"}, {"source_code": "a=[1000000000]\r\ndef solve(s,vis,arr,dp,l):\r\n if s<0:\r\n return\r\n elif s==0:\r\n a[0]=min(a[0],int(\"\".join(arr)))\r\n return\r\n if dp[s][l]==1:\r\n return\r\n # if ans==1:\r\n # return\r\n for i in range(1,10):\r\n if i not in vis:\r\n vis.append(i)\r\n arr.append(str(i))\r\n ans=solve(s-i,vis,arr,dp,l+1)\r\n vis.pop()\r\n arr.pop()\r\n dp[s][l]=1\r\n\r\n\r\nt=int(input())\r\nfor i in range(t):\r\n s=int(input())\r\n # ans=0\r\n a[0]=1000000000\r\n dp=[[0 for i in range(10)] for j in range(s+5)]\r\n # print(solve(s))\r\n vis=[]\r\n arr=[]\r\n solve(s,vis,arr,dp,0)\r\n print(a[0])\r\n "}, {"source_code": "t = int(input())\r\n\r\n\r\nfor i in range(t):\r\n x = int(input())\r\n s = \"\"\r\n mn = 9\r\n while True:\r\n if x <= 9:\r\n s += f'{x}'\r\n break\r\n else:\r\n s += f'{mn}'\r\n x -= mn\r\n mn -= 1\r\n print(int(s[::-1]))"}, {"source_code": "t=int(input())\r\nfor _ in range(t):\r\n s=input()\r\n s=int(s)\r\n ans=[1,2,3,4,5,6,7,8,9]\r\n for i in range(9):\r\n\r\n if sum(ans)-s==0:\r\n print(*ans, sep='')\r\n break \r\n if sum(ans)-s>=ans[-1]:\r\n ans.pop()\r\n else:\r\n ans.pop(sum(ans)-s-1)\r\n "}, {"source_code": "test=int(input())\r\nwhile test:\r\n n=int(input())\r\n dig=-1\r\n s=0\r\n for i in range(9,0,-1):\r\n s+=i\r\n if s>n:\r\n dig=i+1\r\n s-=i\r\n break\r\n if dig==-1:\r\n dig=9 \r\n ans=[]\r\n req=n-s\r\n if req==0:\r\n for j in range(dig,10):\r\n ans.append(j) \r\n else:\r\n ans.append(req)\r\n for j in range(dig,10):\r\n ans.append(j)\r\n ans.sort()\r\n for i in ans:\r\n print(i,end='')\r\n print()\r\n test-=1"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n############ Input code below ############\r\n\r\n# Probem 1729B - Decode String\r\n\r\n# t=inp()\r\n# while t>0:\r\n# n=inp()\r\n# encoded=inp()\r\n# decoded=\"\"\r\n# while encoded>0:\r\n# if encoded % 10 == 0:\r\n# lvalue = (encoded//10) % 100\r\n# encoded //= 1000\r\n# else:\r\n# lvalue = encoded % 10\r\n# encoded //= 10\r\n# lvalue += 96\r\n# decoded = chr(lvalue)+decoded\r\n# t-=1\r\n# print(decoded)\r\n\r\n\r\n\r\n# Probem 1729A - Two Elevators\r\n\r\n# t=inp()\r\n# while t>0:\r\n# a,b,c = invr()\r\n# if (a < abs(b-c)+c):\r\n# print(1)\r\n# elif (a > abs(b-c)+c):\r\n# print(2)\r\n# else:\r\n# print(3)\r\n# t-=1\r\n\r\n\r\n# Problem 1722B Colourblindness\r\n# t = inp()\r\n# while t>0:\r\n# n = inp()\r\n# a = [*input()]\r\n# b = [*input()]\r\n# in_a = set([i for i, x in enumerate(a) if x == \"R\"])\r\n# in_b = set([i for i, x in enumerate(b) if x == \"R\"])\r\n# if in_a == set() and in_b == set():\r\n# print(\"YES\")\r\n# elif in_a == set() or in_b == set():\r\n# print(\"NO\")\r\n# elif in_a ^ in_b == set():\r\n# print(\"YES\")\r\n# else: \r\n# print(\"NO\")\r\n# t-=1\r\n\r\n\r\n# # Problem 1721A Image\r\n# t = inp()\r\n# while t>0:\r\n# a = set([*input().split()[0]])\r\n# b = set([*input().split()[0]])\r\n# c = a.union(b)\r\n# print(len(c)-1)\r\n# t-=1\r\n\r\n# Problem 1722A Spell Check\r\n# t = inp()\r\n# while t>0:\r\n# n, a = inp(), input()\r\n# if n != 5:\r\n# print(\"NO\")\r\n# elif \"T\" in a and \"i\" in a and \"m\" in a and \"u\" in a and \"r\" in a:\r\n# print(\"YES\")\r\n# else: \r\n# print(\"NO\")\r\n# t-=1\r\n\r\n# # Problem 1716A 2-3 Moves\r\n# t =inp()\r\n# while t>0:\r\n# n = abs(inp())\r\n# if n==1: print(2)\r\n# elif n%3==0:\r\n# print(n//3)\r\n# else: print(n//3+1)\r\n# t-=1\r\n\r\n# # Problem 1715A Crossmarket\r\n# t =inp()\r\n# while t>0:\r\n# n,m = inlt()\r\n# if n==1 and m == 1: print(0)\r\n# elif n==1: print(m)\r\n# elif m==1: print(n)\r\n# else: print(min(n,m)*2+max(n,m)-2)\r\n# t-=1\r\n\r\n# Problem 1714C Minimum Varied Number\r\nt =inp()\r\nwhile t>0:\r\n s = inp()\r\n ans=\"\"\r\n i = 9\r\n while s>0 and s>=i:\r\n ans = str(i)+ans\r\n s-=i\r\n i-=1\r\n ans = str(s)+ans\r\n print(ans)\r\n t-=1"}, {"source_code": "def deco(num):\r\n\tarr = []\r\n\tcount = 9\r\n\tif num < 10:\r\n\t\treturn num\r\n\twhile num >= 10 or num in arr:\r\n\t\tnum = num - count\r\n\t\tarr.append(count)\r\n\t\tcount = count - 1\r\n\tif num > 0:\r\n\t\tarr.append(num)\r\n\r\n\tarr.sort()\r\n\t#print(arr)\r\n\treturn int(''.join(map(str,arr)))\r\n\r\n\r\n\r\nn = int(input())\r\nwhile n != 0:\r\n\ts = int(input())\r\n\tdeco(s)\r\n\tn -=1"}, {"source_code": "from sys import stdin, stdout\r\nimport math\r\n\r\ndef main():\r\n \r\n tests = int(stdin.readline())\r\n \r\n # arr = [int(x) for x in stdin.readline().split()]\r\n \r\n def MVN(num):\r\n res = 0\r\n temp = 10\r\n place = 0\r\n while num > temp:\r\n res += (temp - 1)*(pow(10,place))\r\n num -= (temp - 1)\r\n temp -= 1\r\n place += 1\r\n res += (num)*(pow(10,place))\r\n return res\r\n \r\n \r\n for i in range(tests):\r\n num = int(stdin.readline())\r\n # for alarm in range(alarms):\r\n # [H2, M2] = [int(x) for x in stdin.readline().split()]\r\n # sleep = min(sleep, ELTS(H1,M1,H2,M2))\r\n stdout.write(\"\\n\")\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "test=int(input())\r\nwhile test:\r\n n=int(input())\r\n dig=-1\r\n s=0\r\n for i in range(9,0,-1):\r\n s+=i\r\n if s>n:\r\n dig=i+1\r\n s-=i\r\n break\r\n if dig==-1:\r\n dig=9 \r\n ans=[]\r\n req=n-s\r\n if req==0:\r\n for j in range(dig,10):\r\n ans.append(j) \r\n else:\r\n ans.append(req)\r\n for j in range(dig,10):\r\n ans.append(j)\r\n ans.sort()\r\n for i in ans:\r\n print(i,end='')\r\n print()\r\n test-=1"}, {"source_code": "t = int(input())\nfor tidx in range(t):\n n = int(input())\n ans = 0\n req = n\n for i in range(9, 0, -1):\n ans += min(req, i) * 10**(9-i)\n req -= i\n print(ans)\n"}, {"source_code": "t=int(input())\r\nwhile(t>0):\r\n n=int(input())\r\n result=''\r\n for i in range(9,0,-1):\r\n if(n>=i):\r\n result=str(i)+result\r\n n=n-i\r\n print(i)\r\n t-=1\r\n "}, {"source_code": "t = int(input())\nwhile t > 0:\n n = int(input())\n x = 9\n s = ''\n s1 = 0\n while n - s1 >= 10:\n s1 += x\n s += str(x)\n x -= 1\n ok = 0\n for i in range(x,0,-1):\n sm = 0\n if ok == 1:\n break\n s2 = ''\n for j in range(i,0,-1):\n sm += j\n s2 += str(j)\n if n - s1 - sm == 0:\n ok = 1\n break\n print((s + s2)[::-1])\n m = ''\n t -= 1\n"}, {"source_code": "t = int(input())\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n p = 9\r\n a = 0\r\n k=1\r\n if (n>=10):\r\n while (n>=10):\r\n n=n-p\r\n a = p*k+a\r\n k=k*10\r\n p = p-1\r\n if (p>n):\r\n a=a+k*n\r\n else:\r\n while (n>0):\r\n n=n-p\r\n a = p*k+a\r\n k=k*10\r\n p = p-1 \r\n print(a)\r\n \r\n else:\r\n print(n)\r\n\r\n \r\n"}, {"source_code": "from collections import Counter\r\n#from collections import defaultdict\r\n# values=Counter(tasks).values()\r\n# for i,n in l1:\r\n# import math\r\n# from collections import Counter\r\n# l=defaultdict(list)\r\nimport sys\r\nimport math\r\n# import bisect\r\n# from numpy import delete\r\n# import itertools\r\n# from datetime import datetime\r\nfor _ in range(int(sys.stdin.readline())):\r\n n=int(sys.stdin.readline())\r\n # n,h,m=map(int,sys.stdin.readline().split())\r\n # a=[int(i) for i in sys.stdin.readline().split()]\r\n #s=input()\r\n print((n % 9 + 1) * pow(10, (n // 9)) - 1)"}, {"source_code": "t = int(input())\r\n\r\nfor _ in range(t):\r\n n = int(input())\r\n ans = ''\r\n i = 9\r\n while n != 0:\r\n if n >= i:\r\n n -= i\r\n ans = str(i) + ans\r\n else:\r\n ans = str(i) + ans\r\n n -= i\r\n break\r\n i -= 1\r\n print(ans)"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n if s >= 9:\r\n num = 9\r\n cou = ['9']\r\n for i in range(9)[::-1]:\r\n temp = s-num\r\n if temp <= i:\r\n cou.append(str(temp))\r\n cou = cou[::-1]\r\n print(\"\".join(cou))\r\n break\r\n else:\r\n num += i\r\n cou.append(str(i))\r\n else:\r\n print(s)"}, {"source_code": "def fun(n):\r\n num = 0\r\n for i in range(9,0,-1):\r\n if n - i < 0:\r\n num += (n*(10**(9-i)))\r\n break\r\n else:\r\n n = n - i\r\n num += (i*(10**(9-i)))\r\n print(num)"}, {"source_code": "t=int(input())\r\nwhile(t>0):\r\n n=int(input())\r\n result=\"\"\r\n for i in range(9,0,-1):\r\n if(n>=i):\r\n result=str(i)+result\r\n n=n-i\r\n print(i)\r\n t-=1\r\n "}, {"source_code": "t = int(input())\r\n\r\ndef solve():\r\n n = int(input())\r\n current_sol = set()\r\n \r\n def get(i, current_sum):\r\n if current_sum == 0:\r\n return True\r\n for i in range(1, 10):\r\n if i not in current_sol and i <= current_sum:\r\n current_sol.add(i)\r\n found = get(i + 1, current_sum=current_sum-i)\r\n if found:\r\n return True\r\n current_sol.remove(i)\r\n get(0, n)\r\n return list(sorted(current_sol))\r\n\r\nres = []\r\nfor i in range(t):\r\n res.append(solve())\r\n\r\nfor i in res:\r\n print(i)"}, {"source_code": "t=int(input())\r\nwhile(t>0):\r\n n=int(input())\r\n result=\"\"\r\n for i in range(9,0,-1):\r\n if(n>=i):\r\n result+=str(i)\r\n print(i)\r\n t-=1\r\n "}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n ans = ''\r\n for num in range(9, 0, -1):\r\n if n >= num:\r\n ans += str(num)\r\n n -= num\r\n else:\r\n ans += str(n)\r\n break\r\n print(ans[::-1])\r\n"}, {"source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n ans = []\r\n for i in range(9, 0, -1):\r\n tmp = n - i\r\n if tmp < 0:\r\n ans.append(n)\r\n break\r\n else:\r\n n -= i\r\n ans.append(i)\r\n\r\n for i in ans[::-1]:\r\n print(i, end='')\r\n print()"}, {"source_code": "from collections import deque\r\n\r\nt = int(input())\r\n\r\nfor _ in range(t):\r\n s = int(input())\r\n\r\n d = deque()\r\n for n in reversed(range(1, 10)):\r\n if s >= n:\r\n d.appendleft(n)\r\n s -= n\r\n else:\r\n d.appendleft(s)\r\n break\r\n \r\n print(*list(d), sep = '')"}, {"source_code": "\nn = int(input())\n\nfor z in range(n):\n a = int(input())\n\n number_list = []\n if a < 10:\n print(8)\n continue\n\n x = 0\n\n while a != sum(number_list):\n if sum(number_list) < a:\n difference = a - sum(number_list)\n if difference < (9 - x):\n number_list.insert(0, difference)\n else:\n number_list.insert(0, 9 - x)\n x += 1\n print(\"\".join(list(map(str, number_list))))\n"}, {"source_code": "def solve():\r\n n=int(input())\r\n s=''\r\n for i in range(9,0,-1):\r\n if n>=i:\r\n s+=str(i)\r\n n-=i\r\n print(s)\r\n\r\n \r\nt=int(input())\r\nwhile(t):\r\n solve()\r\n t-=1"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n ans = []\r\n for num in range(9, 0, -1):\r\n if n >= num:\r\n ans.append(num)\r\n n -= num\r\n else:\r\n ans.append(n)\r\n break\r\n ans.sort()\r\n for i in ans:\r\n print(i, end='')\r\n print()\r\n"}, {"source_code": "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Aug 19 23:42:08 2022\r\n\r\n@author: khale\r\n\"\"\"\r\n\r\nt = int(input())\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n if(n==45):\r\n print(123456789)\r\n continue\r\n if(n==10):\r\n print(19)\r\n L = []\r\n x = 9\r\n while(n >= 10):\r\n n = n - x\r\n L.append(x)\r\n x -= 1\r\n L.append(n)\r\n for i in range(len(L)-1,-1,-1):\r\n print(L[i],end='')\r\n print()\r\n "}, {"source_code": "# A\r\n\r\ndef inpA():\r\n t = int(input())\r\n ans = []\r\n for i in range(t):\r\n ans_min = 23 * 60 + 59\r\n n, H, M = map(int, input().split())\r\n go_sl = H * 60 + M\r\n for j in range(n):\r\n h, m = map(int, input().split())\r\n awake = h * 60 + m\r\n if go_sl <= awake:\r\n ans_min = min(ans_min, awake - go_sl)\r\n else:\r\n ans_min = min(ans_min, 24 * 60 + awake - go_sl)\r\n ans.append([ans_min // 60, ans_min % 60])\r\n\r\n for i in ans:\r\n print(i[0], i[1])\r\n\r\ndef inpB():\r\n t = int(input())\r\n ans = []\r\n for i in range(t):\r\n hesh = [-1,] * int(1e7)\r\n ans_max = -1\r\n n = input()\r\n seq = map(int, input().split())\r\n for j, v in enumerate(seq):\r\n if hesh[v] != -1:\r\n ans_max = hesh[v]\r\n hesh[v] = j\r\n else:\r\n hesh[v] = j\r\n ans.append(ans_max + 1)\r\n\r\n for i in ans:\r\n print(i)\r\n\r\ndef inpC():\r\n t = int(input())\r\n ans = []\r\n for i in range(t):\r\n v = list(reversed([1, 2, 3, 4, 5, 6, 7, 8, 9]))\r\n s = int(input())\r\n tans = []\r\n j = 0\r\n while s != 0:\r\n if v[j] <= s:\r\n tans.append(str(v[j]))\r\n s -= v[j]\r\n v.pop(j)\r\n else:\r\n j += 1\r\n ans.append(''.join(tans))\r\n\r\n for i in ans:\r\n print(i)\r\n\r\ninpC()\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "\nn = int(input())\n\nfor z in range(n):\n a = int(input())\n\n number_list = []\n if a < 10:\n print(8)\n continue\n\n x = 0\n\n while a != sum(number_list):\n if sum(number_list) < a:\n difference = a - sum(number_list)\n if difference < (9 - x):\n number_list.insert(0, difference)\n else:\n number_list.insert(0, 9 - x)\n x += 1\n print(\"\".join(list(map(str, number_list))))\n"}, {"source_code": "\nfor s in[*map(int,open(0))][1:]:\n r='';i=9\nwhile s:\n if i<=s:s-=i;r=str(i)+r\n i-=1\n print(r)"}, {"source_code": "for _ in range(int(input())):\r\n n=int(input())\r\n cnt=0\r\n ans=\"\"\r\n for i in range(9,-1,-1):\r\n if (cnt+i)>n:\r\n ans=ans+str(n-cnt)\r\n break\r\n else:\r\n cnt=cnt+i\r\n ans=ans+str(i)\r\n print(ans)\r\n "}, {"source_code": "from sys import stdin\r\ninput = stdin.buffer.readline\r\n\r\n\r\ndef func():\r\n\trem = s\r\n\tans = ''\r\n\r\n\tfor i in range(9, 0, -1):\r\n\t\tif i <= rem:\r\n\t\t\trem -= i\r\n\t\t\tans += str(i)\r\n\r\n\tprint(ans)\r\n\r\n\r\nfor _ in range(int(input())):\r\n\ts = int(input())\r\n\tfunc()\r\n"}, {"source_code": "from sys import stdin\r\ninput = stdin.buffer.readline\r\n\r\n\r\ndef func():\r\n\trem = s\r\n\tans = ''\r\n\r\n\tfor i in range(9, 0, -1):\r\n\t\tif i <= rem:\r\n\t\t\trem -= i\r\n\t\t\tans += str(i)\r\n\r\n\tprint(ans)\r\n\r\n\r\nfor _ in range(int(input())):\r\n\ts = int(input())\r\n\tfunc()\r\n"}, {"source_code": "test=int(input())\r\nfor _ in range(test):\r\n value=int(input())\r\n temp=[]\r\n ans=9\r\n while value>9 and value>ans:\r\n value-=ans\r\n temp.append(str(ans))\r\n ans-=1\r\n temp.append(str(value))\r\n temp.reverse()\r\n new=int(\"\".join(temp))\r\n print(new)\r\n \r\n "}, {"source_code": "t=input()\r\nres=''\r\nnums=[i for i in range(1,10)]\r\nwhile int(t)>nums[-1]:\r\n t=int(t)-nums[-1]\r\n res+=str(nums.pop())\r\nres+=str(t)\r\nprint(int(res[::-1]))\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "n = int(input())\r\nfor i in range(n):\r\n s = int(input())\r\n if (s>= 1 and s <=9):\r\n print(s)\r\n if (s >= 10 and s < 18):\r\n k = s % 10 + 1\r\n print(k*10+9)\r\n\r\n if s == 18:\r\n print(189)\r\n if s == 19:\r\n print(289)\r\n if s == 20:\r\n print(389)\r\n if s == 21:\r\n print(489)\r\n if s == 22:\r\n print(589)\r\n if s == 23:\r\n print(689)\r\n if s == 24:\r\n print(789)\r\n if s == 25:\r\n print(1789)\r\n if s == 26:\r\n print(2789)\r\n if s == 27:\r\n print(3789)\r\n if s == 29:\r\n print(4789)\r\n if s == 30:\r\n print(5789)\r\n if s == 31:\r\n print(6789)\r\n if s == 32:\r\n print(16789)\r\n if s == 33:\r\n print(26789)\r\n if s == 34:\r\n print(36789)\r\n if s == 35:\r\n print(46789)\r\n if s == 36:\r\n print(56789)\r\n if s == 37:\r\n print(156789)\r\n if s == 38:\r\n print(256789)\r\n if s == 39:\r\n print(356789)\r\n if s == 40:\r\n print(456789)\r\n if s == 41:\r\n print(1456789)\r\n if s == 42:\r\n print(2456789)\r\n if s == 43:\r\n print(3456789)\r\n if s == 44:\r\n print(23456789)\r\n if s == 45:\r\n print(123456789)"}, {"source_code": "def solve():\r\n n=int(input())\r\n print('1'*n)\r\n \r\nt=int(input())\r\nwhile(t):\r\n solve()\r\n t-=1"}, {"source_code": "from sys import stdout, stdin, setrecursionlimit\nfrom io import BytesIO, IOBase\nfrom collections import *\nfrom itertools import *\nfrom random import * \nfrom bisect import *\nfrom string import *\nfrom queue import *\nfrom heapq import *\nfrom math import *\nfrom re import *\nfrom os import *\n\n####################################---fast-input-output----#########################################\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = read(self._fd, max(fstat(self._fd).st_size, 8192))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = read(self._fd, max(fstat(self._fd).st_size, 8192))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nstdin, stdout = IOWrapper(stdin), IOWrapper(stdout)\ngraph, mod, szzz = {}, 10**9 + 7, lambda: sorted(zzz())\ndef getStr(): return input()\ndef getInt(): return int(input())\ndef listStr(): return list(input())\ndef getStrs(): return input().split()\ndef isInt(s): return '0' <= s[0] <= '9'\ndef input(): return stdin.readline().strip()\ndef zzz(): return [int(i) for i in input().split()]\ndef output(answer, end='\\n'): stdout.write(str(answer) + end)\ndef lcd(xnum1, xnum2): return (xnum1 * xnum2 // gcd(xnum1, xnum2))\n\n\ndx = [-1, 1, 0, 0, 1, -1, 1, -1]\ndy = [0, 0, 1, -1, 1, -1, -1, 1]\ndaysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\n\n#################################################---Some Rule For Me To Follow---#################################\n\"\"\"\n --instants of Reading problem continuously try to understand them.\n\n --If you Know some-one , Then you probably don't know him !\n\n --Try & again try, maybe you're just one statement away!\n\n\n\"\"\"\n##################################################---START-CODING---###############################################\n\n\ndef solve(s):\n sz = 0;\n i=0;\n loop = 1\n while True: \n sz+=9-i\n if(sz>s):\n break\n if(sz==s):\n loop+=1;\n break\n i+=1;\n loop +=1\n lst = []\n for i in range(loop):\n lst.append(9-i)\n lst = lst[::-1]\n ans = 10<<11;\n\n \n while (sum(lst)!=s):\n lst[0]-=1\n print(''.join(str(i) for i in lst))\n\n\n\nfor _ in range(getInt()):\n s = getInt()\n solve(s)"}, {"source_code": "for _ in range(int(input())):\r\n n = int(input())\r\n if n <= 9:\r\n print(n)\r\n continue\r\n ans = ''\r\n for num in range(9, 0, -1):\r\n if n >= num:\r\n ans += str(num)\r\n n -= num\r\n else:\r\n ans += str(n)\r\n break\r\n print(ans[::-1])"}, {"source_code": "import sys\r\n\r\n# -------------------------- INPUT/OUTPUT ------------\r\n\r\ndef input_int():\r\n return int(sys.stdin.readline())\r\n\r\ndef input_str():\r\n return sys.stdin.readline().rstrip()\r\n\r\ndef input_int_arr():\r\n return list(map(int, sys.stdin.readline().split()))\r\n\r\ndef input_char_arr():\r\n return sys.stdin.readline().rstrip().split()\r\n\r\ndef print_ln(num):\r\n sys.stdout.write(str(num) + '\\n')\r\n\r\ndef print_sp(num):\r\n sys.stdout.write(str(num) + ' ')\r\n\r\ndef print_only(num):\r\n sys.stdout.write(str(num))\r\n# -------------------------- INPUT/OUTPUT ------------\r\n\r\ndef solve():\r\n n = input_int()\r\n\r\n if n <= 9:\r\n print_ln(n)\r\n elif n <= 17:\r\n str1 = '9'\r\n print_ln(str(n-9) + str1)\r\n elif n <= 24:\r\n str1 = '89'\r\n print_ln(str(n-17) + str1)\r\n elif n <= 30:\r\n str1 = '789'\r\n print_ln(str(n-24) + str1)\r\n elif n <= 35:\r\n str1 = '6789'\r\n print_ln(str(n-30) + str1)\r\n elif n <= 39:\r\n str1 = '56789'\r\n print_ln(str(n-35) + str1)\r\n elif n <= 42:\r\n str1 = '56789'\r\n print_ln(str(n-39) + str1)\r\n elif n <= 44:\r\n str1 = '456789'\r\n print_ln(str(n-42) + str1)\r\n else:\r\n print_ln('123456789')\r\n\r\n \r\n\r\ndef main():\r\n t = input_int()\r\n\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nmain()"}, {"source_code": "for i in range(int(input())):\r\n n = int(input())\r\n if n > 9:\r\n i=9\r\n s='9'\r\n while(n-i > 0):\r\n n = n - i\r\n i = i - 1\r\n s = s + str(i)\r\n string = str(n) + s[1:]\r\n print(int(string[::-1]))\r\n else:\r\n print(n)"}, {"source_code": "for i in range(int(input())):\r\n s = int(input())\r\n ans = 0\r\n arr=[]\r\n if s<9:\r\n for i in range(s,0,-1):\r\n if (ans+i)<=s:\r\n ans=ans+i\r\n arr.append(i)\r\n else:\r\n for i in range(9,0,-1):\r\n if (ans+i)<=s:\r\n ans=ans+i\r\n arr.append(i)\r\n \r\n \r\n print(arr)\r\n "}, {"source_code": "def deco(num):\r\n\tarr = []\r\n\tcount = 9\r\n\tif num < 10:\r\n\t\treturn num\r\n\twhile num >= 10 or num in arr:\r\n\t\tnum = num - count\r\n\t\tarr.append(count)\r\n\t\tcount = count - 1\r\n\tif num > 0:\r\n\t\tarr.append(num)\r\n\r\n\tarr.sort()\r\n\tprint(arr)\r\n\treturn int(''.join(map(str,arr)))"}, {"source_code": "t=int(input())\r\nwhile(t>0):\r\n n=int(input())\r\n result=\"\"\r\n for i in range(9,0,-1):\r\n if(n>=i):\r\n result+=str(i)\r\n print(i)\r\n t-=1\r\n "}, {"source_code": "t = int(input())\r\n\r\nlimits = [\r\n sum(range(i, 10)) for i in range(1, 10)\r\n][::-1]\r\n\r\nprint(limits)\r\n\r\ndef process(s):\r\n l = None\r\n for i, limit in enumerate(limits):\r\n if s <= limit:\r\n l = i + 1\r\n break\r\n s2 = limits[l - 1]\r\n nums = list(range(10 - l, 10))\r\n if s == s2:\r\n return nums\r\n #print(s2, nums)\r\n for i in range(len(nums)):\r\n while nums[i] > i + 1:\r\n if s2 == s:\r\n return nums\r\n nums[i] -= 1\r\n s2 -= 1\r\n return []\r\n\r\n\r\nfor i in range(t):\r\n s = int(input())\r\n print(*process(s), sep='')"}, {"source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n ans = []\r\n for i in range(9, 0, -1):\r\n tmp = n - i\r\n if tmp < 0:\r\n ans.append(n)\r\n break\r\n else:\r\n n -= i\r\n ans.append(i)\r\n\r\n for i in ans[::-1]:\r\n print(i, end='')\r\n print()"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n############ Input code below ############\r\n\r\n# Probem 1729B - Decode String\r\n\r\n# t=inp()\r\n# while t>0:\r\n# n=inp()\r\n# encoded=inp()\r\n# decoded=\"\"\r\n# while encoded>0:\r\n# if encoded % 10 == 0:\r\n# lvalue = (encoded//10) % 100\r\n# encoded //= 1000\r\n# else:\r\n# lvalue = encoded % 10\r\n# encoded //= 10\r\n# lvalue += 96\r\n# decoded = chr(lvalue)+decoded\r\n# t-=1\r\n# print(decoded)\r\n\r\n\r\n\r\n# Probem 1729A - Two Elevators\r\n\r\n# t=inp()\r\n# while t>0:\r\n# a,b,c = invr()\r\n# if (a < abs(b-c)+c):\r\n# print(1)\r\n# elif (a > abs(b-c)+c):\r\n# print(2)\r\n# else:\r\n# print(3)\r\n# t-=1\r\n\r\n\r\n# Problem 1722B Colourblindness\r\n# t = inp()\r\n# while t>0:\r\n# n = inp()\r\n# a = [*input()]\r\n# b = [*input()]\r\n# in_a = set([i for i, x in enumerate(a) if x == \"R\"])\r\n# in_b = set([i for i, x in enumerate(b) if x == \"R\"])\r\n# if in_a == set() and in_b == set():\r\n# print(\"YES\")\r\n# elif in_a == set() or in_b == set():\r\n# print(\"NO\")\r\n# elif in_a ^ in_b == set():\r\n# print(\"YES\")\r\n# else: \r\n# print(\"NO\")\r\n# t-=1\r\n\r\n\r\n# # Problem 1721A Image\r\n# t = inp()\r\n# while t>0:\r\n# a = set([*input().split()[0]])\r\n# b = set([*input().split()[0]])\r\n# c = a.union(b)\r\n# print(len(c)-1)\r\n# t-=1\r\n\r\n# Problem 1722A Spell Check\r\n# t = inp()\r\n# while t>0:\r\n# n, a = inp(), input()\r\n# if n != 5:\r\n# print(\"NO\")\r\n# elif \"T\" in a and \"i\" in a and \"m\" in a and \"u\" in a and \"r\" in a:\r\n# print(\"YES\")\r\n# else: \r\n# print(\"NO\")\r\n# t-=1\r\n\r\n# # Problem 1716A 2-3 Moves\r\n# t =inp()\r\n# while t>0:\r\n# n = abs(inp())\r\n# if n==1: print(2)\r\n# elif n%3==0:\r\n# print(n//3)\r\n# else: print(n//3+1)\r\n# t-=1\r\n\r\n# # Problem 1715A Crossmarket\r\n# t =inp()\r\n# while t>0:\r\n# n,m = inlt()\r\n# if n==1 and m == 1: print(0)\r\n# elif n==1: print(m)\r\n# elif m==1: print(n)\r\n# else: print(min(n,m)*2+max(n,m)-2)\r\n# t-=1\r\n\r\n# Problem 1714C Minimum Varied Number\r\nt =inp()\r\nwhile t>0:\r\n s = inp()\r\n ans=\"\"\r\n i = 9\r\n while s>0 and s>=i:\r\n ans = str(i)+ans\r\n s-=i\r\n i-=1\r\n ans = str(s)+ans\r\n print(ans)\r\n t-=1"}, {"source_code": "t=int(input())\r\nfor i in range(t):\r\n s=int(input())\r\n if s<10:\r\n print(s)\r\n else:\r\n m=s\r\n st=''\r\n j=9\r\n while j>0:\r\n if m>9:\r\n st+=str(j)\r\n m-=j\r\n j-=1\r\n st1= str(m) + st[::-1]\r\n print(st1)"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n if s >= 9:\r\n num = 9\r\n cou = ['9']\r\n for i in range(9)[::-1]:\r\n temp = s-num\r\n if temp < i+1:\r\n cou.append(str(temp))\r\n cou = cou[::-1]\r\n print(\"\".join(cou))\r\n break\r\n else:\r\n num += i\r\n cou.append(str(i))\r\n else:\r\n print(s)"}, {"source_code": "n_testcases = int(input())\r\n\r\nresults = []\r\n\r\nwhile (n_testcases > 0):\r\n\r\n max_usable = 9\r\n to_reach = int(input())\r\n\r\n num = []\r\n left = to_reach\r\n while left > 0 and max_usable > 0:\r\n #print(\"left: \", left)\r\n #print(\"max usable: \", max_usable)\r\n #print(\"actual building: \", num)\r\n #print(\"------------\")\r\n while max_usable <= left and max_usable > 0:\r\n #print(\"########## left: \", left)\r\n #print(\"########## max usable: \", max_usable)\r\n #print(\"------------\")\r\n num.append(str(max_usable))\r\n left -= max_usable\r\n max_usable -= 1\r\n max_usable -= 1\r\n\r\n\r\n num_int = int(''.join(num[::-1])) \r\n\r\n results.append(num_int)\r\n n_testcases -= 1\r\n\r\nfor i in range(len(results)):\r\n print(results[i])\r\n\r\nprint(\"end\")"}, {"source_code": "import sys\r\nimport math\r\nimport copy\r\n\r\nt = int(input())\r\nfor tst in range(t):\r\n s = int(input())\r\n ans = []\r\n for e in [9, 8, 7, 6, 5, 4, 3, 2, 1]:\r\n if s-sum(ans)-e >= 0:\r\n ans.insert(0, e)\r\n print(ans)\r\n res = \"\"\r\n for n in ans:\r\n res += str(n)\r\n print(res)"}, {"source_code": "ans = list(range(1,10))+list(range(91,100))+list(range(982,988))+list(range(9871,9877))\r\nans+= [98761,98762,98763,98764,98765,987651,987652,987653,987654,9876541,9876542,9876543,98765431,98765432,987654321]\r\nfor _ in range(int(input())):\r\n\tn=int(input())\r\n\tk=list(str(ans[n-1]))\r\n\tk.sort()\r\n\tk=\"\".join(k)\r\n\tk=int(k)\r\n\tprint(k)\r\n\r\n"}, {"source_code": "\nfor s in[*map(int,open(0))][1:]:\n r='';i=9\nwhile s:\n if i<=s:s-=i;r=str(i)+r\n i-=1\n print(r)"}, {"source_code": "\nfor s in[*map(int,open(0))][1:]:\n r='';i=9\nwhile s:\n if i<=s:s-=i;r=str(i)+r\n i-=1\n print(r)"}, {"source_code": "import sys\r\n\r\n# -------------------------- INPUT/OUTPUT ------------\r\n\r\ndef input_int():\r\n return int(sys.stdin.readline())\r\n\r\ndef input_str():\r\n return sys.stdin.readline().rstrip()\r\n\r\ndef input_int_arr():\r\n return list(map(int, sys.stdin.readline().split()))\r\n\r\ndef input_char_arr():\r\n return sys.stdin.readline().rstrip().split()\r\n\r\ndef print_ln(num):\r\n sys.stdout.write(str(num) + '\\n')\r\n\r\ndef print_sp(num):\r\n sys.stdout.write(str(num) + ' ')\r\n\r\ndef print_only(num):\r\n sys.stdout.write(str(num))\r\n# -------------------------- INPUT/OUTPUT ------------\r\n\r\ndef solve():\r\n n = input_int()\r\n\r\n if n <= 9:\r\n print_ln(n)\r\n elif n <= 17:\r\n str1 = '9'\r\n print_ln(str(n-9) + str1)\r\n elif n <= 24:\r\n str1 = '89'\r\n print_ln(str(n-17) + str1)\r\n elif n <= 30:\r\n str1 = '789'\r\n print_ln(str(n-24) + str1)\r\n elif n <= 35:\r\n str1 = '6789'\r\n print_ln(str(n-30) + str1)\r\n elif n <= 39:\r\n str1 = '56789'\r\n print_ln(str(n-35) + str1)\r\n elif n <= 42:\r\n str1 = '56789'\r\n print_ln(str(n-39) + str1)\r\n elif n <= 44:\r\n str1 = '456789'\r\n print_ln(str(n-42) + str1)\r\n else:\r\n print_ln('123456789')\r\n\r\n \r\n\r\ndef main():\r\n t = input_int()\r\n\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nmain()"}, {"source_code": "t = int(input())\r\nfor _ in range(t):\r\n n = int(input())\r\n s = \"\"\r\n for i in range(9, 0, -1):\r\n if n >= i:\r\n s = str(i) + s\r\n n -= i\r\n else:\r\n s = str(n) + s\r\n break\r\n print(s)\r\n"}, {"source_code": "N = int(input())\r\nfor a in range(N):\r\n i = [9,8,7,6,5,4,3,2,1]\r\n x = []\r\n n = int(input())\r\n for k in range(9):\r\n if(n>9):\r\n x.append(i[0])\r\n n = n-i[0]\r\n i.remove(i[0])\r\n \r\n else:\r\n x.append(n)\r\n break\r\n\r\n x.reverse()\r\n \r\n for x1 in x:\r\n print(x1,end='')\r\n print()"}, {"source_code": "from collections import Counter\r\n#from collections import defaultdict\r\n# values=Counter(tasks).values()\r\n# for i,n in l1:\r\n# import math\r\n# from collections import Counter\r\n# l=defaultdict(list)\r\nimport sys\r\nimport math\r\n# import bisect\r\n# from numpy import delete\r\n# import itertools\r\n# from datetime import datetime\r\nfor _ in range(int(sys.stdin.readline())):\r\n n=int(sys.stdin.readline())\r\n # n,h,m=map(int,sys.stdin.readline().split())\r\n # a=[int(i) for i in sys.stdin.readline().split()]\r\n #s=input()\r\n print((n % 9 + 1) * pow(10, (n // 9)) - 1)"}, {"source_code": "n = int(input())\r\nwhile n>0:\r\n n-=1\r\n m = \"\"\r\n a = int(input())\r\n b = \"\"\r\n if a>=10:\r\n for i in range(9,0,-1):\r\n if a ==0:\r\n b=b\r\n elif a>=i:\r\n a-=i\r\n b+=str(i)\r\n elif a==i:\r\n b+=str(i)\r\n else:\r\n b+=str(a)\r\n print(b)\r\n break\r\n for j in range(1,len(b)+1,1):\r\n m += b[-j]\r\n print(m)\r\n else:\r\n print(a)"}, {"source_code": "n_testcases = int(input())\r\n\r\nresults = []\r\n\r\nwhile (n_testcases > 0):\r\n\r\n max_usable = 9\r\n to_reach = int(input())\r\n\r\n num = []\r\n left = to_reach\r\n while left > 0 and max_usable > 0:\r\n #print(\"left: \", left)\r\n #print(\"max usable: \", max_usable)\r\n #print(\"actual building: \", num)\r\n #print(\"------------\")\r\n while max_usable <= left and max_usable > 0:\r\n #print(\"########## left: \", left)\r\n #print(\"########## max usable: \", max_usable)\r\n #print(\"------------\")\r\n num.append(str(max_usable))\r\n left -= max_usable\r\n max_usable -= 1\r\n max_usable -= 1\r\n\r\n\r\n num_int = int(''.join(num[::-1])) \r\n\r\n results.append(num_int)\r\n n_testcases -= 1\r\n\r\nfor i in range(len(results)):\r\n print(results[i])\r\n\r\nprint(\"end\")"}, {"source_code": "# https://codeforces.com/contest/1714/problem/C\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n result = \"9\"\r\n \r\n for i in range(9, 0, -1):\r\n if n < int(result[0]):\r\n break\r\n result = str(i) + result\r\n n -= i\r\n\r\n print(str(n) + result[:-1])"}, {"source_code": "def get_integers_down(number_of_integers):\r\n string = \"\"\r\n sum = 0\r\n for b in range (9, 9-number_of_integers, -1):\r\n string = str(b) + string\r\n sum = b + sum\r\n return [string, sum]\r\ndef inverse_sums(num): \r\n return sum([9-n for n in range(num)])\r\ncountdown = [inverse_sums(num) for num in range(10)]\r\nt = int(input())\r\nfor a in range(t):\r\n n = int(input())\r\n if(n<9):\r\n print(n)\r\n continue\r\n else:\r\n for each in countdown:\r\n if n == each:\r\n print(get_integers_down(countdown.index(each))[0])\r\n break\r\n if n<each:\r\n sum_up = countdown.index(each) - 1\r\n break\r\n add_on_string = get_integers_down(sum_up)[0]\r\n print(str(n - get_integers_down(sum_up)[1]) + add_on_string)\r\n\r\n"}, {"source_code": "def solve():\r\n n=int(input())\r\n print('1'*n)\r\n \r\nt=int(input())\r\nwhile(t):\r\n solve()\r\n t-=1"}, {"source_code": "for i in range(int(input())):\r\n \r\n def getSum(n):\r\n \r\n sum1 = 0;\r\n while (n != 0):\r\n sum1 = sum1 + n % 10;\r\n n = n // 10;\r\n \r\n return sum1;\r\n\r\n def smallestNumber(N):\r\n \r\n i = 1;\r\n while (1):\r\n \r\n if (getSum(i) == N):\r\n print(i);\r\n break;\r\n \r\n i += 1;\r\n \r\n N = int(input())\r\n (smallestNumber(N))"}, {"source_code": "from collections import Counter\r\ndef smallestNum(s):\r\n if s < 10:\r\n return s\r\n prev = 10\r\n res = ''\r\n while s:\r\n if s < 10:\r\n res = str(s) + res\r\n return res\r\n prev -= 1\r\n s -= prev\r\n res = str(prev)+res\r\n\r\n return res\r\n\r\n\r\n\r\nt = int(input())\r\nwhile t:\r\n n = int(input())\r\n print(smallestNum(n))\r\n t -= 1"}, {"source_code": "t = int(input())\r\n\r\n\r\nfor i in range(t):\r\n x = int(input())\r\n s = \"\"\r\n mn = 9\r\n while True:\r\n if x <= 9:\r\n s += f'{x}'\r\n break\r\n else:\r\n s += f'{mn}'\r\n x -= mn\r\n mn -= 1\r\n print(int(s))"}, {"source_code": "def solve():\n s = int(input())\n if s <= 9: return s\n if 9 < s <= 18: return (s - 9) * 10 + 9\n elif 18 < s <= 24: return (s - 17) * 100 + 89\n elif 24 < s <= 30: return (s - 24) * 1_000 + 789\n elif 30 < s <= 35: return (s - 30) * 10_000 + 6789\n elif 35 < s <= 39: return (s - 35) * 100_000 + 56789\n elif 39 < s <= 42: return (s - 39) * 1_000_000 + 456789\n elif 42 < s <= 44: return (s - 42) * 10_000_000 + 3456789\n else: return 123456789\n\n\nif __name__ == '__main__':\n for tt in range(int(input())): print(solve())"}, {"source_code": "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Aug 19 23:42:08 2022\r\n\r\n@author: khale\r\n\"\"\"\r\n\r\nt = int(input())\r\n\r\nfor i in range(t):\r\n n = int(input())\r\n if(n==45):\r\n print(123456789)\r\n L = []\r\n x = 9\r\n while(n >= 10):\r\n n = n - x\r\n L.append(x)\r\n x -= 1\r\n L.append(n)\r\n for i in range(len(L)-1,-1,-1):\r\n print(L[i],end='')\r\n print()\r\n "}, {"source_code": "t = int(input())\r\nwhile t > 0:\r\n s = int(input())\r\n count = 9\r\n ret = \"\"\r\n while s > 0:\r\n if s > 10:\r\n s = s - count\r\n ret = str(count) + ret\r\n count -= 1\r\n elif s < 10 and str(s) not in ret:\r\n #print(s)\r\n ret = str(s) + ret\r\n s = 0\r\n else:\r\n\r\n ret = str(count) + ret\r\n s = s - count\r\n count -= 1\r\n t -= 1\r\n\r\n"}, {"source_code": "for _ in range(int(input())):\r\n s = int(input())\r\n ans = ''\r\n for i in range(9, 0, -1):\r\n if i <= s:\r\n ans = str(i) + ans\r\n s -= i\r\n else:\r\n ans = str(s) + ans\r\n break\r\n print(ans)"}, {"source_code": "# cook your dish here\r\nfor i in range(int(input())):\r\n # n,H,M=map(int,input().split())\r\n \r\n # w=[]\r\n # c=[23,59]\r\n # for k in range(n):\r\n # h,m=map(int,input().split())\r\n # a=[h,m]\r\n \r\n # if H<=a[0]:\r\n # if a[1]>=M:\r\n # w.append([a[0]-H,a[1]-M])\r\n # else:\r\n # w.append([a[0]-H-1,60+a[1]-M])\r\n # else:\r\n \r\n # c=60-M\r\n # p=23-H\r\n # w.append([a[0]+p,c+a[1]])\r\n # w.sort()\r\n # print(*w[0])\r\n \r\n s=int(input())\r\n w=''\r\n e=int(s)\r\n for k in [1,2,3,4,5,6,7,8,9]:\r\n if s==0:\r\n break \r\n else:\r\n if s>=k:\r\n \r\n w+=str(k)\r\n s-=k \r\n q='' \r\n for k in [9,8,7,6,5,4,3,2,1]:\r\n if e==0:\r\n break \r\n else:\r\n if e>=k:\r\n \r\n q+=str(k)\r\n e-=k \r\n print(min(int(q),int(w),int(w[::-1]),int(q[::-1]))) "}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n ans = []\r\n k = 9\r\n while n > 9:\r\n n = n - k\r\n ans.append(k)\r\n k -= 1\r\n if n in ans:\r\n k = ans[-1] - 1\r\n while k > 0:\r\n n = n - k\r\n ans.append(k)\r\n k -= 1\r\n else:\r\n ans.append(n)\r\n print(\"\".join([str(i) for i in ans[::-1]]))"}, {"source_code": "def solve():\n s = int(input())\n if s <= 9: return s\n if 10 < s <= 18: return (s - 9) * 10 + 9\n elif 18 < s <= 24: return (s - 17) * 100 + 89\n elif 24 < s <= 30: return (s - 24) * 1_000 + 789\n elif 30 < s <= 35: return (s - 30) * 10_000 + 6789\n elif 35 < s <= 39: return (s - 35) * 100_000 + 56789\n elif 39 < s <= 42: return (s - 39) * 1_000_000 + 456789\n elif 42 < s <= 44: return (s - 42) * 10_000_000 + 3456789\n else: return 123456789\n\n\nif __name__ == '__main__':\n for tt in range(int(input())): print(solve())"}, {"source_code": "movimientos = int(input())\r\nresultado = \"\"\r\nfor i in range(movimientos):\r\n numero = int(input())\r\n for j in reversed(range(1, 10)):\r\n if numero >= j:\r\n numero -= j\r\n resultado = str(j) + resultado\r\nprint(resultado)"}, {"source_code": "t = int(input())\r\n\r\ndef solve():\r\n n = int(input())\r\n current_sol = set()\r\n \r\n def get(i, current_sum):\r\n if current_sum == 0:\r\n return True\r\n for i in range(1, 10):\r\n if i not in current_sol and i <= current_sum:\r\n current_sol.add(i)\r\n found = get(i + 1, current_sum=current_sum-i)\r\n if found:\r\n return True\r\n current_sol.remove(i)\r\n get(0, n)\r\n return list(sorted(current_sol))\r\n\r\nres = []\r\nfor i in range(t):\r\n res.append(solve())\r\n\r\nfor i in res:\r\n print(i)"}, {"source_code": "n=int(input())\r\nfor j in range(n):\r\n s=int(input())\r\n lst=[]\r\n for i in range(9,0,-1):\r\n s=s-i\r\n if(s>=0):\r\n lst.append(i)\r\n else:\r\n s=s+i\r\n lst.reverse()\r\n for i in lst:\r\n \r\n \r\n \r\n print(i,end=\"\")"}, {"source_code": "t=input()\r\nres=''\r\nnums=[i for i in range(1,10)]\r\nwhile int(t)>nums[-1]:\r\n t=int(t)-nums[-1]\r\n res+=str(nums.pop())\r\nres+=str(t)\r\nprint(int(res[::-1]))\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "def solve():\n s = int(input())\n if s <= 9: return s\n if 9 < s <= 18: return (s - 9) * 10 + 9\n elif 18 < s <= 24: return (s - 17) * 100 + 89\n elif 24 < s <= 30: return (s - 24) * 1_000 + 789\n elif 30 < s <= 35: return (s - 30) * 10_000 + 6789\n elif 35 < s <= 39: return (s - 35) * 100_000 + 56789\n elif 39 < s <= 42: return (s - 39) * 1_000_000 + 456789\n elif 42 < s <= 44: return (s - 42) * 10_000_000 + 3456789\n else: return 123456789\n\n\nif __name__ == '__main__':\n for tt in range(int(input())): print(solve())"}, {"source_code": "from sys import stdout, stdin, setrecursionlimit\nfrom io import BytesIO, IOBase\nfrom collections import *\nfrom itertools import *\nfrom random import * \nfrom bisect import *\nfrom string import *\nfrom queue import *\nfrom heapq import *\nfrom math import *\nfrom re import *\nfrom os import *\n\n####################################---fast-input-output----#########################################\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = read(self._fd, max(fstat(self._fd).st_size, 8192))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = read(self._fd, max(fstat(self._fd).st_size, 8192))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nstdin, stdout = IOWrapper(stdin), IOWrapper(stdout)\ngraph, mod, szzz = {}, 10**9 + 7, lambda: sorted(zzz())\ndef getStr(): return input()\ndef getInt(): return int(input())\ndef listStr(): return list(input())\ndef getStrs(): return input().split()\ndef isInt(s): return '0' <= s[0] <= '9'\ndef input(): return stdin.readline().strip()\ndef zzz(): return [int(i) for i in input().split()]\ndef output(answer, end='\\n'): stdout.write(str(answer) + end)\ndef lcd(xnum1, xnum2): return (xnum1 * xnum2 // gcd(xnum1, xnum2))\n\n\ndx = [-1, 1, 0, 0, 1, -1, 1, -1]\ndy = [0, 0, 1, -1, 1, -1, -1, 1]\ndaysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\n\n#################################################---Some Rule For Me To Follow---#################################\n\"\"\"\n --instants of Reading problem continuously try to understand them.\n\n --If you Know some-one , Then you probably don't know him !\n\n --Try & again try, maybe you're just one statement away!\n\n\n\"\"\"\n##################################################---START-CODING---###############################################\n\n\ndef solve(s):\n sz = 0;\n i=0;\n loop = 1\n while True: \n sz+=9-i\n if(sz>s):\n break\n if(sz==s):\n loop+=1;\n break\n i+=1;\n loop +=1\n lst = []\n for i in range(loop):\n lst.append(9-i)\n lst = lst[::-1]\n ans = 10<<11;\n\n \n while (sum(lst)!=s):\n lst[0]-=1\n print(''.join(str(i) for i in lst))\n\n\n\nfor _ in range(getInt()):\n s = getInt()\n solve(s)"}, {"source_code": "import sys\r\nimport math\r\n\r\n\r\ndef II(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int, sys.stdin.readline().split()))\r\ndef LS(): return sys.stdin.readline().strip().split()\r\ndef SI(): return sys.stdin.readline().strip()\r\ndef MIN_INT(): return -1 * sys.maxsize\r\ndef MAX_INT(): return sys.maxsize\r\ndef prefSum(arr, n):\r\n P = [0] * (n + 1)\r\n for k in range(1, n + 1):\r\n P[k] = P[k - 1] + arr[k - 1]\r\n return P\r\n\r\n\r\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\r\n\r\n\r\ndef solve():\r\n n = II()\r\n i = 1\r\n ans = [9]\r\n if n <= 9:\r\n print(n)\r\n else:\r\n now = sum(ans)\r\n x = True\r\n while now < n and x:\r\n while i < ans[-1]-1:\r\n if now + i == n:\r\n ans.append(i)\r\n x = False\r\n break\r\n i += 1\r\n now += i\r\n ans.append(i)\r\n i = 1\r\n if sum(ans) == n:\r\n for i in ans[::-1]:\r\n print(i,end='')\r\n print()\r\n else:\r\n ans.pop(-1)\r\n for i in ans[::-1]:\r\n print(i,end='')\r\n print()\r\n\r\n\r\ndef main():\r\n t = II()\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nmain()\r\n"}, {"source_code": "import sys\r\nimport math\r\n\r\n\r\ndef II(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int, sys.stdin.readline().split()))\r\ndef LS(): return sys.stdin.readline().strip().split()\r\ndef SI(): return sys.stdin.readline().strip()\r\ndef MIN_INT(): return -1 * sys.maxsize\r\ndef MAX_INT(): return sys.maxsize\r\ndef prefSum(arr, n):\r\n P = [0] * (n + 1)\r\n for k in range(1, n + 1):\r\n P[k] = P[k - 1] + arr[k - 1]\r\n return P\r\n\r\n\r\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\r\n\r\n\r\ndef solve():\r\n n = II()\r\n if n <= 9:\r\n return n\r\n ans = [9]\r\n now = 9\r\n x = True\r\n while now < n and x:\r\n for i in range(1, ans[-1]):\r\n if now + i == n:\r\n ans.append(i)\r\n x = False\r\n break\r\n elif i == ans[-1]-1:\r\n now += i\r\n ans.append(i)\r\n for i in ans[::-1]:\r\n print(i,end='')\r\n print()\r\n\r\n\r\ndef main():\r\n t = II()\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nmain()\r\n"}], "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f"} {"source_code": "p=input()\nm=len(p)\nn=p.count(\"a\")\nif (n > m//2):\n print(m)\nelse:\n print(2*n-1)", "positive_code": [{"source_code": "s=input()\n \nn=len(s)\n \nac = 0;\n \nfor i in range(0,n):\n \n if s[i] == 'a':\n ac+=1\n \n \nwhile True:\n \n m = int(n / 2) + 1\n if(ac >= m):\n break\n n-=1\n \n \nprint(n)\n "}, {"source_code": "n=input()\ni=0\nfor e in n:\n if(e==\"a\"):\n i+=1\nif(len(n)/2>i and len(n)-i!=2):\n print(2*i-1)\nelif(len(n)-i==2):\n print(i)\nelif(len(n)/2==i):\n print(len(n)-1)\nelse:\n print(len(n))\n \n"}, {"source_code": "###################################################################\n# Class Definition.\nclass LoveA:\n # Method to compute 'Good' String of Maximum length.\n def computeLengthForGoodString(self):\n countA,countB = self.obtainCounts();length = len(self.string)\n # Determining Required Length.\n index = 0\n while(countA<=length/2 and index<len(self.string)):\n if self.string[index] != LoveA.characterA:\n length = length - 1\n index = index + 1\n return length\n # Method to Count A's and non A's.\n def obtainCounts(self):\n aCount = self.string.count(LoveA.characterA)\n return [aCount,len(self.string)-aCount]\n # Soluttion.\n def Solution(self):\n return self.computeLengthForGoodString()\n # Constructor.\n def __init__(self,string):\n self.string = string\n # Class for Storing Character A.\n characterA = 'a'\n###################################################################\n# Driver Program.\nnewObject = LoveA(raw_input())\nprint newObject.Solution()\n###################################################################\n "}, {"source_code": "s = input()\nprint(min(s.count('a')*2-1, len(s)))"}, {"source_code": "s = raw_input()\nprint min(len(s), s.count('a') * 2 - 1)\n"}, {"source_code": "s = input()\na = s.count('a')\nprint(min(2*a-1,len(s)))"}, {"source_code": "s=raw_input()\n\ncount=0\ncount1=0\n\nfor i in range(len(s)):\n if (s[i]=='a'):\n count+=1\n else:\n count1+=1\nif(count>count1):\n print len(s)\nelse:\n print count+count-1"}, {"source_code": "s=input()\nx=s.count('a')\nif len(s) <= x*2-1:\n print(len(s))\nelse:\n print(x*2-1)"}, {"source_code": "s = raw_input()\na = 0\nb = 0\nfor i in s:\n if i == 'a':\n a+=1\n else:\n b+=1\n\nif a>b:\n print len(s)\nelse:\n print a+a-1\n"}, {"source_code": "nado = 0\nnen = 0\notv = 0\na = input()\nfor i in a:\n if i == 'a':\n nado += 1\n else:\n nen += 1\nprint(len(a) - max(0, nen - nado + 1))"}, {"source_code": "s = input()\nprint(min(len(s),2*s.count('a')-1))"}, {"source_code": "s = input()\na = s.count('a')\n\nb= len(s)-a\nif a > b:\n print(len(s))\nelif a == 0:\n print(0)\nelse:\n cpt=0\n while b >= a:\n b-=1\n cpt+=1\n print(len(s)-cpt)\n"}, {"source_code": "# your code goes here\na=input()\nb=len(a)\ncount=0\nfor letter in a:\n\tif(letter=='a'):\n\t\tcount=count+1\nif(count==0):\n\tprint(count)\nelif(count>(b/2)):\n\tprint(b)\nelif(count<=(b/2)):\n\tprint(count+(count-1))\n\t"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys\nfrom fractions import gcd\ndef fi():\n return int(sys.stdin.readline())\n\ndef fi2():\n return map(int, sys.stdin.readline().split())\n\ndef fi3():\n return sys.stdin.readline()\n\ndef fo(*args):\n for s in args:\n sys.stdout.write(str(s)+' ')\n sys.stdout.write('\\n')\nINF=10**9+7\nsys.setrecursionlimit(INF)\n\n#main\ns=raw_input()\ncount=0\nfor i in s:\n if i==\"a\":\n count+=1\nif count>len(s)/2:\n fo(len(s))\nelse:\n fo(count*2-1)\n \n \n \n \n \n \n \n \n \n \n \n \n\n\n \n \n \n \n \n \n \n \n \n\n\n \n\n \n \n \n \n \n \n \n \n \n \n \n\n\n \n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n\n\n\n\n \n \n \n \n\n \n\n\n\n"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n from builtins import str as __str__\n\n str = lambda x=b\"\": x if type(x) is bytes else __str__(x).encode()\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._buffer = BytesIO()\n self._fd = file.fileno()\n self._writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self._buffer.write if self._writable else None\n\n def read(self):\n if self._buffer.tell():\n return self._buffer.read()\n return os.read(self._fd, os.fstat(self._fd).st_size)\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n def flush(self):\n if self._writable:\n os.write(self._fd, self._buffer.getvalue())\n self._buffer.truncate(0), self._buffer.seek(0)\n\n\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b\"\\r\\n\")\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", b\" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", b\"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\ndef main():\n s = input()\n cnt = s.count(\"a\")\n if cnt > len(s) / 2:\n print(len(s))\n else:\n print(2 * cnt - 1)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10 ** 6)\n# pow(3,2,5)==4\n\ns=raw_input()\n\ncount=0\nfor i in s:\n if i==\"a\":\n count+=1\nprint min(len(s),count*2-1)\n"}, {"source_code": "s=raw_input()\nprint(len(s) if s.count('a')>len(s)//2 else 2*s.count('a')-1)"}, {"source_code": "s = input()\na = s.count('a')\nif a > len(s) // 2:\n print(len(s))\nelse:\n print(a * 2 - 1)\n"}, {"source_code": "s = input()\nprint(min(len(s), s.count('a') * 2 - 1))\n"}, {"source_code": "s = raw_input()\n\na = s.count('a')\n\nprint min(len(s), a * 2 - 1)\n"}, {"source_code": "'''input\naaabaa\n\n\n'''\n\n\n\nRI = lambda : [int(x) for x in raw_input().split()]\nrw = lambda : raw_input().strip()\nmod = 10**9+7\n\n\n\ns = rw()\nno = s.count(\"a\")\nprint min(len(s),2*no-1)\n\n"}, {"source_code": "s = input()\nk = s.count('a')\nprint(min(max(k + k - 1, 0), len(s)))\n"}, {"source_code": "s=raw_input()\nif s.count('a')>(len(s)-s.count('a')):\n print len(s)\nelse:\n print s.count('a')*2-1\n"}, {"source_code": "s=input()\nn=len(s)\ncount_a=s.count('a')\n\nif(count_a>(n/2)):\n\tprint(n)\nelse:\n\tprint(count_a*2-1)"}, {"source_code": "def answer():\n a = list(input())\n y=0\n z=0\n for x in a:\n if x!=\"a\":\n y+=1\n else:\n z+=1\n if z>y: return len(a)\n else: return z*2-1\n\n \n \nprint(answer())"}, {"source_code": "s=list(input())\nc=s.count(\"a\")\n#print(len(s))\n#print(c)\nn=len(s)\nif(c>len(s)//2):\n print(len(s))\n\nelse:\n while(True):\n if(c>n//2):\n print(n)\n break\n else:\n n-=1\n "}, {"source_code": "s = input()\nn = len(s)\n\ncount = 0\nfor i in range(n):\n if s[i] == 'a':\n count += 1\nother = n-count \nif count > other:\n print (n)\nelif count == other:\n print (n-1)\nelse:\n print (2*count-1)"}, {"source_code": "\n\ndef solve():\n s = input()\n a = s.count(\"a\")\n if a*2-1 > len(s):\n print(len(s))\n else:\n print(a*2-1)\n\n\nif __name__ == \"__main__\":\n solve()"}, {"source_code": "# ~*~ coding: utf-8 ~*~\n\ns = raw_input()\ncount_a = s.count(\"a\")\nprint min(len(s), count_a + (count_a - 1))\n#\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u043b\u0438\u043d\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u0443\u043a\u0432 \u0430. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 min, count \u0438 len\n# \u0444\u0443\u043d\u043a\u0446\u0438\u044f len - \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 (), \u0430 \u043d\u0435 \"\u0442\u043e\u0447\u043a\u0443\"."}, {"source_code": "s = input()\nb = s\nc = []\nd = []\nfor item in b:\n if (item == \"a\"):\n c.append(item)\n else:\n d.append(item)\nif (len(c) > len(d)):\n print(len(c) + len(d))\nelse:\n while(len(c) <= len(d)):\n d.pop()\n print(len(c) + len(d))"}, {"source_code": "s=raw_input()\nn=len(s)\na=sum(k=='a' for k in s)\nprint(min(n,2*a-1))"}, {"source_code": "s = input()\nca = s.count('a')\ncv = len(s)\nwhile True:\n if ca >= cv // 2 + 1:\n print(cv)\n exit()\n else:\n cv -= 1\n continue\n"}, {"source_code": "s = input()\nca = s.count('a')\ncv = len(s)\nif ca >= cv // 2 + 1:\n print(cv)\nelse:\n print(ca * 2 - 1)\n"}, {"source_code": "S = raw_input().strip()\nn = len(S)\na = len([c for c in S if c == 'a'])\nwhile a * 2 <= n:\n\tn -= 1\nprint n\n\n"}, {"source_code": "\ns = input()\nl = len(s)\nc=0\n\nfor i in range(l):\n if s[i]=='a':\n c = c+1\ncnt = 2*c - 1\nif c>l/2 :\n print(l)\nelif c==l/2 :\n print(l-1)\nelse:\n print(cnt)\n"}, {"source_code": "s =input()\nc1 = 0\nfor i in s:\n if(i == 'a'):\n c1 += 1\nif(c1 > len(s)//2):\n print(len(s))\nelse:\n print(2*c1 -1)\n "}, {"source_code": "n=input()\nr=n.count(\"a\")\nprint(min(len(n),2*r-1))"}, {"source_code": "s = input().strip()\na = s.count('a')\nprint(len(s)) if a > len(s)/2 else print(a*2-1)"}, {"source_code": "s = input()\na = 0\nfor i in s:\n\tif i == 'a':\n\t\ta+=1\nhalf = len(s)//2\nif a > half:\n\tprint(len(s))\nelse:\n\talls = len(s)\n\twhile a <= half:\n\t\talls-=1\n\t\thalf = alls//2\n\tprint(alls)"}, {"source_code": "s=input()\nl=[]\nk=[]\nd=[]\nfor i in s:\n if i!='a':\n l.append(i)\nm=len(l)\ne=s.count('a')\nfor i in range(e):\n d.append('a')\nif m>=e:\n q=l[0:e-1]\n t=len(q)\n print(e+t)\nelse:\n print(len(s))\n \n \n"}, {"source_code": "s = input()\na = 0\ncnt = 0\nfor i in range(0,len(s)):\n if s[i] == 'a':\n a += 1\n#print(a)\n\nwhile a < len(s)//2+1:\n for i in range(0,len(s)):\n if s[i] >= 'b' and s[i] <= 'z':\n s = s[:i] + s[i+1:]\n break;\n\nprint(len(s))"}, {"source_code": "import sys\n\nstr = sys.stdin.readline().rstrip()\ncount = 0\nfor char in str:\n if char == 'a':\n count += 1\n\nif ((count * 2 - 1) >= len(str)):\n print(len(str))\nelse:\n print(count * 2 - 1)\n\t\t\t\t\t \t\t \t \t\t \t \t\t\t\t\t \t\t\t"}, {"source_code": "s=input()\n\ntemp=s.count('a')\n\nif temp*2>len(s):\n print(len(s))\nelse:\n print((2*temp)-1)\n"}, {"source_code": "a = input()\ncount = 0\nfor i in range (len(a)):\n if (a[i] == 'a'):\n count+=1\nif (count>len(a)//2):\n print(len(a))\nelse:\n print((2*count)-1)"}, {"source_code": "s=input()\nst=list(s)\nsiz=len(st)\nlock =0\ncnt=0\nfor i in range(siz):\n if st[i]=='a':\n cnt+=1\nval=0\nif cnt>siz/2:\n print(siz)\nelse :\n rest=siz-cnt\n while rest>=cnt:\n rest-=1\n val+=1\n print(siz-val)\n\n "}, {"source_code": "s=input()\nn=0\nfor i in range(0,len(s)) :\n if s[i] == \"a\" :\n n=n+1\nif(n==len(s)):\n print(n)\nelif (n> (len(s)/2)):\n print(len(s))\nelse: \n print(2*n-1)"}, {"source_code": "s = input()\n\nlength = len(s)\n\nif s.count('a') > length/2:\n print(length)\nelse:\n i = 0\n while(s.count('a') <= len(s)/2):\n if(s[i]!= 'a'):\n s = s.replace(s[i],'',1)\n else:\n i+=1\n print(len(s))\n"}, {"source_code": "s = input()\nacount = s.count('a')\nif( acount <= (len(s) /2) ):\n\tprint((2*acount) - 1)\nelse:\n\tprint(len(s))\n# print(len(s) - deslength)"}, {"source_code": "str = input()\nx = str.count(\"a\")\ny = len(str)-x\nc = 0\nif x>y:\n print(len(str))\nelif x==y:\n print(len(str)-1)\nelse:\n while(True):\n y-=1\n if x>y:\n c = 1\n break\nif c==1:\n print(x+y)"}, {"source_code": "str = input()\na = 0\nret_a = 0\nret_lo = len(str)\nfor i in str:\n if i == 'a':\n ret_a += 1\nif (ret_a / ret_lo) <= 0.5:\n a = 2*ret_a-1\nelse:\n a = ret_lo\nprint(a)"}, {"source_code": "# A. Love \"A\"\n\ns = input()\n\nnum_of_a = s.count('a')\ns_half = len(s) / 2\n\nans = len(s) if num_of_a > s_half else num_of_a * 2 - 1\nprint(ans)\n\n"}, {"source_code": "s = input()\na = len([1 for i in s if i == 'a'])\nnota = len(s) - a\nprint(len(s) - (nota - a) - 1 if a < nota else (nota + a if a > nota else len(s) - 1))\n"}, {"source_code": "s = input()\na = 0\nfor idx in s:\n if(idx == 'a'):\n a += 1\n \nif(a > len(s)/2):\n print(len(s))\nelse:\n print(a * 2 - 1)"}, {"source_code": "s = input()\naCnt = 0\nfor idx in s:\n if(idx == 'a'):\n aCnt += 1\n\nif(aCnt > len(s)/2):\n print(len(s))\nelse:\n print(aCnt * 2 - 1)\n"}, {"source_code": "s = str(input())\nif (len(s) / 2 >= s.count('a')):\n print(s.count('a') * 2 - 1)\nelse: \n print(len(s))"}, {"source_code": "s = input()\na = 0\nfor i in s:\n\tif i == 'a':\n\t\ta+=1\nhalf = len(s)//2\nif a > half:\n\tprint(len(s))\nelse:\n\talls = len(s)\n\twhile a <= half:\n\t\talls-=1\n\t\thalf = alls//2\n\tprint(alls)"}, {"source_code": "s=input()\nln=len(s)\ncnt1=0\ncnt2=0\ncnt3=0\nfor i in range(0,ln):\n if(s[i]=='a'):\n cnt1+=1\n elif(s[i]!='a'):\n cnt2+=1\nif(cnt1>cnt2 and cnt1>(ln/2)):\n print(ln)\nelif(cnt1==cnt2):\n print(ln-1)\nelse:\n while(1):\n cnt2-=1\n if(cnt1>cnt2):\n cnt3=1\n break\n if(cnt3==1):\n print(cnt1+cnt2)\n \n"}, {"source_code": "\n\nn = input()\nprint(min(((2 * n.count('a') - 1), len(n))))\n"}, {"source_code": "s = list(input())\na = s.count('a')\nl = len(s)\nif a > l/2:\n\tprint(l)\nelse:\n\tanotherLetters = l - a\n\tdelta = anotherLetters - a\n\tl = l - delta - 1\n\tprint(l)\n"}, {"source_code": "s=input()\nprint(min(len(s),s.count('a')*2-1))\n"}, {"source_code": "a = str(input())\nb = a.count('a')\nif(b<= len(a)/2):\n print(b*2-1)\nelse:\n print(len(a))\n"}, {"source_code": "import math\nt=input('') \nn=len(t)\nc=t.count('a')\nif n%2 == 0:\n if c > (n//2):\n print(n)\n else:\n print((2*c)-1)\nelse:\n if c >= (n//2)+1:\n print(n)\n else:\n print((2*c)-1) \n\n "}, {"source_code": "\n\ndef GoodString(Str):\n \n A = []\n \n for letter in Str:\n A.append(letter)\n A.sort()\n counter = 0 \n delete = len(A)\n \n for letter in A:\n if letter == \"a\":\n counter += 1\n else: break\n \n while counter <= delete - counter:\n delete -= 1\n print(delete)\n \nStr = input()\nGoodString(Str)"}, {"source_code": "s = input()\ncount = 0\nfor i in s:\n if i == 'a' :\n count = count + 1\n#print(count)\nif count > (len(s) / 2 ):\n print(len(s))\nelse:\n print(2 * count - 1)\n"}, {"source_code": "from collections import Counter\npalabra = input()\ncnt_palabra = Counter(palabra)\nn = len(palabra)\nif cnt_palabra['a'] > n // 2:\n print(n)\nelse:\n print(cnt_palabra['a'] * 2 - 1)\n"}, {"source_code": "i=input()\n# already good string\nlen_=len(i)\ncount_a=i.count('a')\nif round(len_/2) < count_a :\n print(len_)\nelse:\n print((count_a*2)-1)"}, {"source_code": "import math\ns=input()\nprint(min(len(s),2*s.count('a')-1))"}, {"source_code": "\nclass Solution:\n def solve(self, string):\n numOfAs = 0\n\n for ch in string:\n if ch == 'a' or ch == 'A':\n numOfAs += 1\n\n isGood = numOfAs > len(string) / 2\n\n if isGood:\n return len(string)\n else:\n return numOfAs * 2 - 1\n\n\nsol = Solution()\nstring = input().strip()\n\nprint(sol.solve(string))\n"}, {"source_code": "s = input()\nif(len(s)%2==0):\n if(s.count('a')>len(s)//2):\n print(len(s))\n else:\n print((2*s.count('a')-1))\nelse:\n if(s.count('a')>len(s)//2):\n print(len(s))\n else:\n print((2*s.count('a')-1))\n"}, {"source_code": "s = input()\nprint(min(len(s), s.count('a')*2 - 1))\n"}, {"source_code": "s = input()\nprint(min(len(s), s.count('a')*2-1))\n"}, {"source_code": "#tt = int(input())\n\n#while tt:\n #tt -= 1\nn = input()\n\nl = list(n)\nr = []\nfor i in range(len(l)):\n if l[i] == 'a':\n r.append(l[i])\n \nif len(r) > (len(n)-len(r)):\n print(len(n))\n\nelse:\n x = len(r) - 1\n a = x + len(r)\n print(a)"}, {"source_code": "s=input()\ncount=0\nfor i in s:\n if i=='a':\n count+=1\nif count<=len(s)/2:\n print(2*count-1)\nelse:\n print(len(s))\n"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin, stderr\n\ndef main():\n S = stdin.readline().strip()\n cnta = len( [1 for c in S if c == 'a'] )\n N = len(S)\n\n while cnta*2 <= N:\n N -= 1\n print(N)\n\n return 0\n\nif __name__ == '__main__': main()\n"}, {"source_code": "s = input()\n\na, other = 0, 0\nfor c in s:\n if c == 'a':\n a += 1\n else:\n other += 1\n\nif a > other:\n print(len(s))\nelse:\n print(len(s) - (other - (a - 1)))\n"}, {"source_code": "string=input()\nprint(min(2*string.count('a')-1,len(string)))\n\n\n"}, {"source_code": "s = raw_input().strip()\nc = s.count('a')\nl = len(s)\nfor i in xrange(l):\n if c > l - i - c:\n print l - i\n break\n"}, {"source_code": "s=input()\na=s.count('a')\nif a>(len(s)//2):\n print(len(s))\nelse:\n print(a+a-1)\n "}, {"source_code": "#https://codeforces.com/contest/1146/problem/0\n\ns=raw_input()\nl=len(s)\na=s.count(\"a\")\ntar=(l/2)+1\nif a>=tar:\n print l\nelse:\n if a==1:\n print 1\n else:\n print (a*2)-1"}, {"source_code": "s = raw_input()\n\nc = s.count('a')\nif 2*c > len(s):\n\tprint len(s)\nelse:\n\tprint 2*c -1"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\ncute = input().strip() \n\ncutes = cute.count(\"a\")\nuncutes = len(cute) - cutes\n\nif (cutes == 0): \n print(0)\nelse: \n print(len(cute) - max(uncutes - cutes + 1, 0))"}, {"source_code": "s = input()\nprint(len(s) if (s.count(\"a\") > len(s)-s.count(\"a\")) else 2*s.count(\"a\")-1)\n"}, {"source_code": "s=raw_input()\nc=s.count('a')\nprint min(len(s),2*c-1)\n"}, {"source_code": "s = raw_input()\nn = len(s)\nc = s.count('a')\nprint min(n, c+c-1)\n"}, {"source_code": "s=raw_input()\nc=s.count('a')\nprint min(c*2-1,len(s))"}, {"source_code": "s = raw_input()\nn1 = len(s)\nn2 =s.count('a')\nprint min(n1,n2*2-1)"}, {"source_code": "n=input()\nl=len(n)\nc=n.count(\"a\")\nif c>l//2:\n print(l)\nelse:\n print(c*2-1)\n\n\n\n\n"}], "negative_code": [{"source_code": "s= input()\nprint(s.count('a') + 1)"}, {"source_code": "s = [i for i in input()]\n# print (s)\ncount = 0\nfor i in s:\n if i == 'a':\n count += 1\n# print (count)\nif count > len(s) / 2:\n print (len(s))\nelse:\n if count + 2 < len(s):\n count1 = count + 2\n print (max(count + 1 , count +2 ))"}, {"source_code": "n=str(input())\ns=list(n)\ng = s.count('a')\nf=len(s)-g\nif (f-1)-g==0:\n print(len(s)-2)\nelif f<g:\n print(len(s))\nelif f==g:\n print(len(s)-1)\nelse:\n print(f-g)\n"}, {"source_code": "from math import *\nfrom copy import *\nfrom string import *\t\t\t\t# alpha = ascii_lowercase\nfrom random import *\nfrom sys import stdin\nfrom sys import maxsize\nfrom operator import *\t\t\t\t# d = sorted(d.items(), key=itemgetter(1))\nfrom itertools import *\nfrom collections import Counter\t\t# d = dict(Counter(l))\nimport math\n\ndef bin1(l,r,k,t,b,val,ans):\n\tif(l>r):\n\t\treturn ans\n\telse:\n\t\tmid=(l+r)//2\n\t\tv=k**mid\n\t\tif(v==val):\n\t\t\treturn v\n\t\telif(v>val):\n\t\t\tans=mid\n\t\t\treturn bin1(mid+1,r,k,t,b,val,ans)\n\t\telse:\n\t\t\treturn bin1(l,mid-1,k,t,b,val,ans)\n\t\t\ndef bin2(l,r,k,t,b,val,ans):\n\tif(l>r):\n\t\treturn ans\n\telse:\n\t\tmid=(l+r)//2\n\t\tv=t*(k**mid)+b*(mid)\n\t\tif(v==val):\n\t\t\treturn v\n\t\telif(v>val):\n\t\t\tans=mid\n\t\t\treturn bin2(l,mid-1,k,t,b,val,ans)\n\t\telse:\n\t\t\treturn bin2(mid+1,r,k,t,b,val,ans)\n\ndef SieveOfEratosthenes(n): \n \n # Create a boolean array \"prime[0..n]\" and initialize \n # all entries it as true. A value in prime[i] will \n # finally be false if i is Not a prime, else true. \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n \n # If prime[p] is not changed, then it is a prime \n if (prime[p] == True): \n \n # Update all multiples of p \n for i in range(p * p, n+1, p): \n prime[i] = False\n p += 1\n l=[]\n for i in range(2,n+1):\n \tif(prime[i]):\n \t\tl.append(i)\n return l\ndef bin(l,r,ll,val):\n\tif(l>r):\n\t\treturn -1\n\telse:\n\t\tmid=(l+r)//2\n\t\tif(val>=ll[mid][0] and val<=ll[mid][1]):\n\t\t\treturn mid\n\t\telif(val<ll[mid][0]):\n\t\t\treturn bin(l,mid-1,ll,val)\n\t\telse:\n\t\t\treturn bin(mid+1,r,ll,val)\ndef deci(n):\n\ts=\"\"\n\twhile(n!=0):\n\t\tif(n%2==0):\n\t\t\tn=n//2\n\t\t\ts=\"0\"+s\n\t\telse:\n\t\t\tn=n//2\n\t\t\ts=\"1\"+s\n\treturn s\ndef diff(s1,s2):\n\tif(len(s1)<len(s2)):\n\t\tv=len(s1)\n\t\twhile(v!=len(s2)):\n\t\t\ts1=\"0\"+s1\n\t\t\tv=v+1\n\telse:\n\t\tv=len(s2)\n\t\twhile(v!=len(s1)):\n\t\t\ts2=\"0\"+s2\n\t\t\tv=v+1\n\tc=0\n\tfor i in range(len(s1)):\n\t\tif(s1[i:i+1]!=s2[i:i+1]):\n\t\t\tc=c+1\n\treturn c\nfrom sys import stdin, stdout \ndef fac(a,b):\n\tv=a\n\twhile(a!=b):\n\t\tv*=a-1\n\t\ta=a-1\n\treturn v\ndef bino(l,r,n):\n\tif(l>r):\n\t\treturn -1\n\telse:\n\t\tmid=(l+r)//2\n\t\tval1=math.log((n/mid)+1,2)\n\t\tval2=int(val1)\n\t\tif(val1==val2):\n\t\t\treturn val1\n\t\telif(val1<1.0):\n\t\t\treturn bino(l,mid-1,n)\n\t\telse:\n\t\t\treturn bino(mid+1,r,n)\n\ndef binary(l,r,ll,val,ans):\n\tif(l>r):\n\t\treturn ans\n\telse:\n\t\tmid=(l+r)//2\n\t\tif(ll[mid]==val):\n\t\t\treturn ll[mid]\n\t\telif(ll[mid]<val):\n\t\t\tans=ll[mid]\n\t\t\treturn binary(mid+1,r,ll,val,ans)\n\t\telse:\n\t\t\treturn binary(l,mid-1,ll,val,ans)\ndef check(n):\n\tv=1\n\twhile(n!=0):\n\t\tif(n%10==0 or n%10==1):\n\t\t\tn=n//10\n\t\telse:\n\t\t\tv=0\n\t\t\tbreak\n\treturn v\n\nif __name__ == '__main__':\n\ts=str(input())\n\tc1=0\n\tfor i in range(len(s)):\n\t\tif(s[i:i+1]==\"a\"):\n\t\t\tc1+=1\n\tif(c1>len(s)//2):\n\t\tprint(len(s))\n\telse:\n\t\tprint(c1+1)\n\n\n\t"}, {"source_code": "s = input()\nprint(min(len(s),2*s.count('a')+1))"}, {"source_code": "s=input()\nx='a'\nif len(s)%2==1:\n if s.count(x)<len(s)//2-1:\n print(len(s)-(len(s)//2-1)+s.count(x))\n else:\n print(len(s))\nelse:\n if s.count(x)<len(s)//2:\n print(len(s)-len(s)//2+s.count(x))\n else:\n print(len(s))"}, {"source_code": "a = input()\nsum = 0\nlist = list(a)\n\nfor i in range(len(a)):\n if 'a' in list[i]:\n sum += 1\n\nif len(a) // 2 < sum:\n print(sum + 1)\nelif len(a) // 2 == sum:\n print(len(a) - 1)\nelse:\n print((len(a) - sum) - sum)\n"}, {"source_code": "s = [i for i in input()]\n# print (s)\ncount = 0\nfor i in s:\n if i == 'a':\n count += 1\n# print (count)\nif count > len(s) / 2:\n print (len(s))\nelse:\n print ((len(s) // 2 )- count)"}, {"source_code": "s=input()\nk=0\nfor i in range(len(s)):\n if s[i]=='a':\n k+=1\nif k==len(s):\n print(k)\nelif len(s)-k<k:\n print(k)\nelse:\n print(k*2-1)"}, {"source_code": "s = input()\nn = 0\nn = s.count('a')\nprint(n+1)\n"}, {"source_code": "s=input()\nn=0\nfor i in range(0,len(s)) :\n if s[i] == \"a\" :\n n=n+1\nif (n>=(len(s)-n)):\n print(0)\nelse:\n print(len(s)-2*n)"}, {"source_code": "s=input()\nk=0\nfor i in range(len(s)):\n if s[i]=='a':\n k+=1\nif k==len(s):\n print(k)\nelif len(s)-k<k:\n print(k)\nelse:\n print(k*2-1)"}, {"source_code": "n=list(input())\nk=n.count(\"a\")\nif(len(n)-k>1):\n print(len(n)-2*k)\nelse:\n print(len(n))\n \n"}, {"source_code": "s=input()\na=0\ns=list(s)\nfor i in s:\n\tif i=='a':\n\t\ta+=1\nif a>len(s)//2:\n\tprint(len(s))\nelse:\n\tprint(a+1)"}, {"source_code": "s=input()\nl=list(s)\nc=[]\nfor i in range(len(l)):\n if(l[i]=='a'):\n coun=0\n for j in range(i+1,len(l)):\n if(l[j]=='x'):\n coun+=1 \n c.append(coun)\nd=max(c)\nprint(len(l)-d)\n "}, {"source_code": "inp = input()\na=inp.count(\"a\")\n\nx=len(inp)- a*2\n\nif x ==0:\n print(len(inp)-1)\n exit()\nelif x==1:\n print(len(inp)-2)\n exit()\nelif len(inp)//2>a:\n print(x)\n exit()\nelse:\n print(len(inp))\n"}, {"source_code": "import sys\nimport math\nstr = input()\nc = str.count(\"a\")\nl = len(str)\n\n\nif c >= math.ceil(l / 2):\n\n print(l)\nelse:\n print((c * 2) - 1)\n"}, {"source_code": "str = input()\nc=str.count(\"a\")\nl=len(str)\nif l==1:\n\tprint(l)\nif c>l//2:\n print(l)\nelse:\n print((c*2)-1)\n\n\n\n\n\n\n"}, {"source_code": "string = input()\noccurences = 0\nfor char in string:\n if char == 'a':\n occurences += 1\n\nprint(occurences)\ndifference = len(string) - occurences\nprint(difference)\nprint(len(string))\nif difference > occurences:\n print(len(string) - difference + 1)\nelif difference == occurences:\n print(len(string) - 1)\nelse:\n print(len(string))"}, {"source_code": "str = input()\nc=str.count(\"a\")\nl=len(str)\nif l==1:\n\tprint(l)\nif c>l//2:\n print(l)\nelse:\n print((c*2)-1)\n\n\n\n\n\n\n"}, {"source_code": "s = input()\nn = len(s)\n\ncount = 0\nfor i in range(n):\n if s[i] == 'a':\n count += 1\n \nif count > n//2:\n print (n)\nelif count == n//2:\n print (2*count-1)\nelse:\n if count > 1:\n print (count + 1)\n else:\n print (count)"}, {"source_code": "n=input()\nprint(min(len(n),n.count('a')+1))"}, {"source_code": "s = input()\nlen = len(s)\nc = s.count('a')\nn = len - c\ncount = 0\nif c > len//2:\n print(len)\nelse:\n for i in range((len//2)):\n count += 1\n print(count)\n\n"}, {"source_code": "s = input()\nans = 0\noth = 0\nfor i in s:\n if i == \"a\":\n ans += 1\n else:\n oth += 1\nif (ans > oth):\n print(len(s))\nelif (ans == oth):\n print(len(s)-1)\nelse:\n print(ans+1)\n "}, {"source_code": "s = input()\nif(s.count('a')> (len(s)//2)):print(len(s))\nelse : print( len(s) - ( (len(s) - s.count('a')) - ((len(s)//2)-1) ) )"}, {"source_code": "\ns = input()\nl = len(s)\nc=0\n\nfor i in range(l):\n if s[i]=='a':\n c = c+1\ncnt = c+1\nif c>l/2 :\n print(l)\nelse:\n print(cnt)\n"}, {"source_code": "n=input()\ni=0\nfor e in n:\n if(e==\"a\"):\n i+=1\nif(len(n)/2>i and len(n)-i!=2):\n print(i+1)\nelif(len(n)-i==2):\n print(i)\nelif(len(n)/2==i):\n print(len(n)-1)\nelse:\n print(len(n))\n \n"}, {"source_code": "s = input()\nk = s.count('a')\nm = len(s) - k\nif(m < k):\n print(len(s))\nelse:\n print(m-k)"}, {"source_code": "s=input()\ncount=0\ni=0\nif s[0] == \"a\":\n count = count + 1\n i=i+1\n\n\nwhile i<len(s):\n if s[i]==\"a\":\n count=count+1\n i=i+1\n\n else:\n if(i!=0 and i!=len(s)-1):\n if(s[i+1]==\"a\"):\n count=count+1\n i = i + 1\n else:\n i=i+1\n\nprint(count)"}, {"source_code": "s = input()\nL = len(s)\nnA = L - s.count(\"a\")\nif L%2 == 0:\n h = int(L/2)\nelse:\n h = int(L/2) +1\nif nA != 0:\n print(L - nA + 1) \nelif s.count(\"a\") > h and nA == 0:\n print(L)"}, {"source_code": "s=input()\nprint(len(s) if s.count('a')>len(s)//2 else len(s)-s.count('a'))"}, {"source_code": "s = input()\na = s.count('a')\nprint(max(a * 2 - 1, len(s)))"}, {"source_code": "n=list(map(str,input()))\nc=0\nb=0\nfor i in range(len(n)):\n if(n[i]=='a'):\n c=c+1\n else:\n b=1\nprint(c+b)"}, {"source_code": "s = input()\na = s.count('a')\nb = len(s)//2\nif a > b:\n print(len(s))\nelif a == 0:\n print(0)\nelse:\n cpt=0\n while b >= a:\n b-=1\n cpt+=1\n print(len(s)-cpt)\n"}, {"source_code": "s = input()\nn = len(s)\n\ncount = 0\nfor i in range(n):\n if s[i] == 'a':\n count += 1\n \nif count > n//2:\n print (n)\nelse:\n print (count + 1)"}, {"source_code": "x=input()\ncount=0\ny=len(x)//2\nfor i in range (len(x)):\n if x[i]=='a':\n count=count+1\nif count>(y):\n print(y*2)\nelif count==y:\n print((y*2)-1)\nelse:\n print((2*y)-count-1)\n \n \n"}, {"source_code": "l=list(input())\na=b=0\nfor i in l:\n\tif i=='a':\n\t\ta+=1\n\tif i!='a':\n\t\tb+=1\nif a>b:\n\tprint(a+b)\nelse:\n\tprint(b-a)"}, {"source_code": "s = input()\nans = 0\noth = 0\nfor i in s:\n if i == \"a\":\n ans += 1\n oth += 1\nif (ans > oth):\n print(len(s))\nelse:\n print(ans+1)\n "}, {"source_code": "s = input()\nn = 0\nn = s.count('a')\nprint(n+1)\n"}, {"source_code": "string = input()\ncount = 0\nfor x in string:\n if x == \"a\":\n count += 1\nprint(count + 1)\n"}, {"source_code": "a=input()\ng=a.count('a')\nh=len(a)\nf=h\ncnt=0\nif h%2!=0 and g<h//2+1:\n while g<h//2+1:\n h=h-1\n cnt+=1\n print(f-cnt)\nelif h%2==0 and g<h//2:\n while g<h//2:\n h=h-1\n cnt+=1\n print(f-cnt)\nelse:\n print(h)"}, {"source_code": "s = str(input())\nif (len(s) // 2 > s.count('a')):\n print(s.count('a') * 2 - 1)\nelse: \n print(len(s))"}, {"source_code": "def count(arr):\n m=0\n for i in range(len(arr)):\n if arr[i]=='a':\n m=m+1\n return m\n\ns = input()\narr=[]\nfor i in range(len(s)):\n arr.append(s[i])\n\narr.sort()\nb=True\nm=0\ncc=count(arr)\n\nif count(arr)<len(arr)-count(arr):\n while b:\n if cc<int(len(arr)/2):\n del arr[-1]\n m=m+1\n else:\n break\n print(m+1)\nelse:\n print(len(s))\n\n"}, {"source_code": "# import sys \n# sys.stdin = open('input.txt', 'r') \n# sys.stdout = open('output.txt', 'w') \n\ns=input()\nc=s.count('a')\nprint(c+1)\n"}, {"source_code": "s = input()\na = s.count('a')\nif a > len(s) // 2:\n print(len(s))\nelse:\n if len(s) % 2 == 0:\n print(len(s) - (len(s) // 2))\n else:\n print(len(s) - (len(s) // 2 + 1))\n \n"}, {"source_code": "def count(arr):\n m=0\n for i in range(len(arr)):\n if arr[i]=='a':\n m=m+1\n return m\n\ns = input()\narr=[]\nfor i in range(len(s)):\n arr.append(s[i])\n\narr.sort()\nb=True\nm=0\ncc=count(arr)\n\nif count(arr)<len(arr)-count(arr):\n while b:\n if cc<int(len(arr)/2):\n del arr[-1]\n m=m+1\n else:\n break\n print(m+1)\nelse:\n print(len(s))\n\n"}, {"source_code": "s = input()\na = 0\ncnt = 0\nfor i in range(0,len(s)):\n if s[i] == 'a':\n a += 1\n\nfor c in range(1,26):\n ch = chr(c + 97)\n k = 0\n for i in range(0,len(s)):\n if ch == s[i]:\n k += 1\n #print(ch,k)\n if(k > a):\n cnt += abs(k-(a-1))\n\nprint(len(s)-cnt)"}, {"source_code": "def ret():\n st = input()\n count = 0\n lenSt = len(st)\n\n for i in range(lenSt):\n if st[i] == 'a':\n count += 1\n if count > lenSt//2:\n return lenSt\n else:\n availabeOthers = lenSt - count\n needed = (lenSt // 2)\n return needed\nprint(ret())"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\ncute = input().strip() \n\nuncutes = cute.count(\"x\")\ncutes = cute.count(\"a\")\n\nif (cutes == 0): \n print(0)\nelse: \n print(len(cute) - max(uncutes - cutes + 1, 0))"}, {"source_code": "s = input()\nb = s\nc = 0\nd = []\nfor item in b:\n d.append(item)\n if (item == \"a\"):\n c = c + 1\nif (c > (len(b)//2)):\n print(len(b))\nelse:\n for objects in d:\n if (objects != \"a\"):\n d.remove(objects)\n if (c > (len(d)//2)):\n break\n print(len(d))\n "}, {"source_code": "s = input()\ncountA, countS = 0, 0\nfor S in s:\n if(S == 'a'):\n countA+=1\n else:\n countS+=1\nres = (countS - countA)+1 if countS > countA else 0\nprint(countS + countA - res)"}, {"source_code": "s=input()\na = s.count('a')\nl = len(s)\nif(a > l//2):\n print(l)\nelse:\n print(a+1)\n"}, {"source_code": "s = input()\nc = s.count('a');\nif c > len(s) // 2:\n print(len(s))\nelse:\n print(len(s)//2)\n \n"}, {"source_code": "s=input()\nln=len(s)\ncnt1=0\ncnt2=0\ncnt3=0\nfor i in range(0,ln):\n if(s[i]=='a'):\n cnt1+=1\n elif(s[i]!='a'):\n cnt2+=1\nif(cnt1>cnt2 and cnt1>(ln/2)):\n print(ln)\nelif(cnt1==cnt2):\n print(ln-1)\nelse:\n print(cnt2-cnt1)\n \n"}, {"source_code": "n=str(input())\noutput=0\nfor i in n:\n if n.count('a') == (len(n) - n.count('a')):\n output = len(n)-1\n elif n.count('a') > (len(n) - n.count('a')):\n output=len(n)\n else:\n output= (len(n)-(len(n) - n.count('a')))+1\nprint(output)\n "}, {"source_code": "s=input()\na= len(s)\ncount =0\nnew=\"\"\nfor i in range(len(s)):\n if s[i]==\"a\":\n new = new + \"a\"\n else:\n new = new +\" \"\nk=new.index(\"a\")\nt=new[k::]\ng=\"\"\nfor i in t:\n if i==\"a\":\n g=g+i\n\nprint(len(g)+1)"}, {"source_code": "a=input()\n#b=len(a)\nc=a.count('a')\nif c==len(a):\n print(len(a))\n\nelif c==(len(a))/2:\n print(len(a)-1)\nelse:\n print(c+1)\n"}, {"source_code": "s = input()\ncountA, countS = 0, 0\nfor S in s:\n if(S == 'a'):\n countA+=1\n else:\n countS+=1\nres = (countS - countA)+1 if countS > countA else 0\nprint(countS + countA - res)"}, {"source_code": "from math import ceil as c\ns = input()\nprint(len(s) if s.count('a') > int(len(s) / 2) else c((len(s) - s.count('a')) / 2))"}, {"source_code": "\n\ndef solve():\n s = input()\n a = s.count(\"a\")\n print(a+1)\n\n\nif __name__ == \"__main__\":\n solve()"}, {"source_code": "\narr = input()\n\na = arr.count('a')\n\ntot = len(arr)\n\nrem = tot - a\n\n\nrm = 0\n\nif(rem>a):\n\tprint(tot-rem+1)\n\nelif(rem==a):\n\tprint(tot-1)\n\nelif(a>rem):\n\tprint(tot)"}, {"source_code": "s=input()\nk=0\nfor i in range(len(s)):\n if s[i]=='a':\n k+=1\nprint(len(s)-(len(s)-(k+1)))"}, {"source_code": "z = input()\nx = []\nl = []\nfor y in range(len(z)):\n x.append(z[y])\na = 0\nb = 0\nc = 0\n\nfor d in x:\n if d == \"a\":\n a+=1\n if d != \"a\":\n l.append(d)\nl.sort()\nfor x in l:\n if x == l[0]:\n b+=1\n else:\n c = c+1\nif b>a:\n if c > 1:\n print(2*a-c)\n else:\n print(2*a-1)\nelse:\n print(a+b)\n\n"}, {"source_code": "s = input()\na = 0\ncnt = 0\nfor i in range(0,len(s)):\n if s[i] == 'a':\n a += 1\n\nfor c in range(1,26):\n ch = chr(c + 97)\n k = 0\n for i in range(0,len(s)):\n if ch == s[i]:\n k += 1\n #print(ch,k)\n if(k > a):\n cnt += abs(k-a+1)\n\nprint(len(s)-cnt)"}, {"source_code": "a = input()\ncount = 0\ncount= a.count(a)\nif (count>len(a)//2):\n print(len(a))\nelse:\n print((2*count)-1)"}, {"source_code": "s = input()\nif(s.count('a')> (len(s)//2)):print(len(s))\nelse : print(s.count('a')+1)"}, {"source_code": "\nn = input()\n\nc = n.count('a')\n\n\nif c == len(n):\n print(c)\nelse:\n print(c + 1)"}, {"source_code": "g=input()\nh=len(g)\nc=0\nd=0\nl=[]\nfor x in range(h):\n\tif g[x]=='a':\n\t\tc+=1\n\telif g[x]!='a':\n\t\td+=1\n\tl.append(g[x])\nfor x in l:\n\twhile(d>=c): \n\t\tif x != 'a':\n\t\t\tl.remove(x)\n\t\td-=1\nv=0\nfor x in l:\n\tv+=1\nprint(v)"}, {"source_code": "s=input()\nst=list(s)\nsiz=len(st)\nlock =0\ncnt=0\nfor i in range(siz):\n if st[i]=='a':\n cnt+=1\n \nrest =siz-(cnt+1)\nif cnt==siz/2:\n print(siz-1)\nelif cnt>siz/2:\n print(siz)\nelse:\n print(siz-rest)\n "}, {"source_code": "# your code goes here\na=input()\nb=len(a)\ncount=0\nfor letter in a:\n\tif(letter=='a'):\n\t\tcount=count+1\nif(count>(b/2)):\n\tprint(b)\nelif(count<(b/2)):\n\tprint(count+1)\n\t"}, {"source_code": "pal = input()\nletter_a = pal.count('a')\ndif = len(pal) - letter_a\nif (letter_a > dif):\n print(len(pal))\nelif(letter_a == dif):\n print(len(pal)-1)\nelse:\n print(letter_a + 1)"}, {"source_code": "string = input()\ncount = 0\nfor x in string:\n if x == \"a\":\n count += 1\nif count + 1 > len(string):\n print(len(string))\nelse:\n print(count+1)\n"}, {"source_code": "s = input()\na = s.count('a')\nif len(s) - a > a:\n print(a * 2 - 1)\nelse:\n print(len(s))"}, {"source_code": "s = input()\nk = s.count('a')\nm = len(s) - k\nif(m < k):\n print(len(s))\nelse:\n while(m > k):\n m -= 1\n print(m)"}, {"source_code": "def ret():\n st = input()\n count = 0\n lenSt = len(st)\n for i in range(lenSt):\n if st[i] == 'a':\n count += 1\n print(\"Count\",count)\n if count >= (lenSt//2)+1:\n# print(\"lenSt//2+1\",(lenSt//2)+1)\n return lenSt\n else:\n needed = (lenSt // 2) + 1\n return lenSt-needed\nprint(ret())"}, {"source_code": "s = input()\ncount = 0\nfor i in s:\n if i == 'a' :\n count = count + 1\n#print(count)\nif count > (len(s) / 2 ):\n print(len(s))\nelse:\n print(count +1)\n"}, {"source_code": "s = input()\na = s.count('a')\nn = len(s)\nans = n - 2*a - 1\nprint(max(0,ans))"}, {"source_code": "s=input()\nx=s.count('a')\nif x==len(s):\n print(x)\nelse:\n print(x+1)"}, {"source_code": "def count(arr):\n m=0\n for i in range(len(arr)):\n if arr[i]=='a':\n m = m + 1\n return m\n\n\narr = input()\narr2=[]\nfor i in range(len(arr)):\n arr2.append(arr[i])\n\nm = len(arr2)\nc = count(arr2)\nprint(m)\n"}, {"source_code": "\ns = input()\nl = len(s)\nc=0\n\nfor i in range(l):\n if s[i]=='a':\n c = c+1\ncnt = c+1\nif c>l/2 :\n print(l)\nelse:\n print(cnt)\n"}, {"source_code": "l=list(input())\nl.sort()\nc=0\nfor i in range(len(l)):\n if l[i]=='a':\n c=c+1\n else:\n break\nif len(l)//2<c:\n print(len(l))\nelse:\n print(c+1)\n"}, {"source_code": "def fun(str):\n counter = 0\n for c in str:\n if c == 'a':\n counter = counter + 1\n return counter\n\n\n\nmystr = input(\"please enter the str: \")\nret = fun(mystr)\nif ret == len(mystr):\n print(\"0\")\nelse:\n print(len(mystr) - (len(mystr) - ret - ( ret - 1)))\n\n"}, {"source_code": "s = input()\nb = []\nc = []\nfor item in s:\n if (item == \"a\"):\n b.append(item)\n else:\n c.append(item)\nindex = 0\nwhile (len(b) > (len(c)//2)):\n b.append(c[index])\n index = index + 1\nstr1 = \"\"\nstr1.join(b)\nprint(len(b))\n"}, {"source_code": "string = input()\nnum_a = 0\nfor i in string:\n if i == 'a':\n num_a += 1\nprint(num_a + 1)\n"}, {"source_code": "s=(input())\nt=s.count('a')\nu=len(s)-t\nif t>=u:\n print(t+u)\nelse:\n print(t-u)"}, {"source_code": "a = input()\na = list(a)\nb = []\n\nfor x in range(len(a)):\n if x < (len(a)-1):\n if (a[x] != a[x+1]) | (a[x] == \"a\"):\n b.append(a[x])\n else:\n if a[x] == \"a\":\n b.append(a[x])\n\nfor y in range(len(b)):\n if b[0] != \"a\":\n b.remove(b[0])\n else:\n break\n\nfor y in range(len(b)):\n if b[-1] != \"a\":\n b.remove(b[-1])\n else:\n break\n\nprint(len(b))"}, {"source_code": "s = input()\nprint(len(s) if (s.count(\"a\") > len(s)) else 2*s.count(\"a\")-1)\n"}, {"source_code": "s=input()\nif(s.count('a')==len(s)//2):\n print(len(s)-1)\nelse:\n print(len(s) if s.count('a')>len(s)//2 else len(s)-s.count('a')-s.count('a'))\n"}, {"source_code": "s = input()\n\nlist = []\n\nfor word in s:\n list.append(word)\n\na = 0\nx = 0\nfor i in range(len(list)):\n if list[i] == 'a':\n a +=1\n else:\n x+=1\n\n\ncounter = -1\nif a > x:\n print(a+x)\nelse:\n while a <= x:\n x -= 1\n counter +=1\n print(counter)\n\n\n"}, {"source_code": "s=input()\na=s.count('a')\nb=len(s)-a\nif a>=b:\n print(len(s))\nelse:\n print(b-a)"}, {"source_code": "str = input()\nc=str.count(\"a\")\nl=len(str)\nif l==1:\n\tprint(1)\nif c>round(l/2):\n print(l)\nelse:\n print((c*2)-1)\n\n\n\n\n\n\n"}, {"source_code": "s=input()\na = s.count('a')\nl = len(s)\nif(a > l//2):\n print(l)\nelse:\n print(a+1)\n"}, {"source_code": "s=raw_input()\nc=s.count('a')\nif len(s)==c:\n print c\nelif len(s)/2<c:\n print len(s)\nelse:\n print c+1"}, {"source_code": "s=input()\np=len(s)\nq=s.count('a')\nif q>p//2:\n print(p)\nelse:\n print(q+1)"}, {"source_code": "if __name__ == '__main__':\n s = input()\n b = s.count('a')\n if b<(len(s)/2):\n print(b+1)\n else:\n print(len(s))\n"}, {"source_code": "s = input()\nc = s.count('a')\nprint(c+1)"}, {"source_code": "s=input()\na= len(s)\ncount =0\nnew=\"\"\nfor i in range(len(s)):\n if s[i]==\"a\":\n new = new + \"a\"\n else:\n new = new +\" \"\nk=new.index(\"a\")\nt=new[k::]\ng=\"\"\nfor i in t:\n if i==\"a\":\n g=g+i\n else:\n g=g+\" \"\nm=\"\"\nif g.count(\" \")>=1:\n m=\" \"\ncount=g.count(\"a\")\nm=m+\"a\"*count\nprint(len(m))"}, {"source_code": "n=str(input())\noutput=0\nfor i in n:\n if n.count('a') == (len(n) - n.count('a')):\n output = len(n)-1\n elif n.count('a') > (len(n) - n.count('a')):\n output=len(n)\n else:\n output= (len(n)-(len(n) - n.count('a')))+1\nprint(output)\n "}, {"source_code": "n=list(input())\nprint(n.count('a')+1)"}, {"source_code": "a = input()\nsum = 0\nlist = list(a)\n\nfor i in range(len(a)):\n if 'a' in list[i]:\n sum += 1\n\nif len(a) // 2 < sum:\n print(len(a))\nelif len(a) // 2 == sum:\n print(len(a) - 1)\nelse:\n print(len(a) - sum - sum)"}], "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219"} {"source_code": "n=int(input())\nsumx=0\nif(n==0):\n\tprint(1)\nelse:\n\twhile(n>0):\n\t\ta=n%16\n\t\tif(a<10):\n\t\t\tif(a==0 or a==4 or a==6 or a==9):\n\t\t\t\tsumx+=1\n\t\t\telif(a==8):\n\t\t\t\tsumx+=2\n\t\telif(a==10 or a==13):\n\t\t\tsumx+=1\n\t\telif(a==11):\n\t\t\tsumx+=2\n\t\tn=n//16\n\tprint(sumx)", "positive_code": [{"source_code": "from sys import stdin\nst=stdin.readline()\na = hex(int(st))\nl = {'0':1,'1':0,'2':0,'3':0,'4':1,'5':0,'6':1,'7':0,'8':2,'9':1,'a':1,'b':2,'c':0,'d':1,'e':0,'f':0}\nn = len(a)\nt = 0\nfor i in range(2, n):\n\tt += l[a[i]]\nprint t\n"}, {"source_code": "from collections import defaultdict\n\n\na = input()\nb = hex(a).upper()[2:]\nd = defaultdict(lambda: 0, {'0':1, '4':1, '6':1, '8':2, '9':1, 'A':1, 'B':2, 'D':1})\nprint sum(map(lambda x: d[x], b))"}, {"source_code": "print sum({'0':1,'4':1,'6':1,'8':2,'9':1,'a':1,'b':2,'d':1}.get(c,0)for c in hex(input()))-1"}, {"source_code": "n = int(raw_input())\n\ns = []\nif n == 0: s.append(0)\nwhile n > 0:\n s.append(n % 16)\n n /= 16\n\nholes = {\n 0: 1,\n 1: 0,\n 2: 0,\n 3: 0,\n 4: 1,\n 5: 0,\n 6: 1,\n 7: 0,\n 8: 2,\n 9: 1,\n 10: 1, # A\n 11: 2, # B\n 12: 0, # C\n 13: 1, # D\n 14: 0, # E\n 15: 0 # F\n }\n\nprint sum(map(lambda x: holes[x], s))\n\n"}, {"source_code": "a=int(input())\nb=[1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\nres=0\nif a==0:\n\tres+=b[0]\nwhile a>0:\n\tres+=b[a%16]\n\ta/=16\nprint(res)\n"}, {"source_code": "A = [0] * 255\nA[ord('0')]=1\nA[ord('4')]=1\nA[ord('6')]=1\nA[ord('8')]=2\nA[ord('9')]=1\nA[ord('A')]=1\nA[ord('B')]=2\nA[ord('D')]=1\nprint sum(map(lambda x: A[ord(x)], hex(int(raw_input()))[2:].upper()))"}, {"source_code": "n = str(hex(int(input())))[2:]\nnums = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1]\nch = [1, 2, 0, 1, 0, 0]\nans = 0\nfor i in n:\n\tif (i >= '0' and i <= '9'):\n\t\tans += nums[ord(i) - ord('0')]\n\telse:\n\t\tans += ch[ord(i) - ord('a')]\n\t\t\nprint(ans)"}, {"source_code": "n = int(input())\nans = 1 if n == 0 else 0\n\nwhile n > 0:\n d = n % 16\n n = n // 16\n if d == 8 or d == 11:\n ans += 2\n elif d == 0 or d == 4 or d == 6 or d == 9 or d == 10 or d == 13:\n ans += 1\n\nprint(ans)\n"}, {"source_code": "f = {'0' : 1, '1' : 0, '2' : 0, '3' : 0, '4' : 1, '5' : 0, '6' : 1, '7' : 0, '8' : 2, '9' : 1, 'A' : 1, 'B' : 2, 'C' : 0, 'D' : 1, 'E' : 0, 'F' : 0}\nn = '%X' % int(input())\ns = 0\nfor i in n: s += f[i]\nprint(s)"}, {"source_code": "t = 1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0\nprint(sum(t[int(i, 16)] for i in '{:X}'.format(int(input()))))\n"}, {"source_code": "def mp():\n return map(int, input().split())\n\nk = int(input())\nif k == 0:\n print(1)\nelse:\n abc = '0123456789ABCDEF'\n r = 0\n while k > 0:\n d = abc[k % 16]\n if d in '0469AD':\n r += 1\n elif d in '8B':\n r += 2\n k //= 16\n print(r)"}, {"source_code": "def main():\n n = int(input())\n n = hex(n)[2:]\n ans = 0\n for c in n:\n if c == '0' or c == '6' or c == '9' or c == 'a' or c == 'd' or c == '4':\n ans += 1\n if c == '8' or c == 'b':\n ans += 2\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "zc = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\n\nn = int(input())\n\nif (n == 0):\n print(1)\nelse:\n sum = 0\n while (n):\n sum += zc[n % 16]\n n //= 16\n print(sum)"}, {"source_code": "d = {'0': 1, '4': 1, '6': 1, '8': 2, '9': 1, 'A': 1, 'B': 2, 'D': 1}\nn = int(input())\nprint(sum(d[c] for c in '{:X}'.format(n) if c in d))\n"}, {"source_code": "a=[1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\nx=int(input())\nb=0\nif x == 0:\n b += 1\nwhile x:\n b+=a[x%16]\n x//=16\nprint(b)"}, {"source_code": "a=int(input())\na=str(hex(a))\ns=0\nfor i in range(1,len(a)):\n if a[i] in ['0','4','6','9','a','d']:s=s+1\n if a[i] in ['8','b']:s=s+2\nprint(s)\n"}, {"source_code": "a=str(hex(int(input())))\nb=0\nfor i in range(2,len(a)):\n if a[i]==\"0\" or a[i]==\"4\" or a[i]==\"6\" or a[i]==\"9\" or a[i]==\"a\" or a[i]==\"d\":\n b+=1\n elif a[i]==\"8\" or a[i]==\"b\":\n b+=2\nprint(b)\n"}, {"source_code": "# 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F\nx = [0, 4, 6, 8, 8, 9, 10, 11, 11, 13]\n\nn = int(input())\nret = 1 if n == 0 else 0\nwhile n:\n ret += x.count(n - (n // 16) * 16)\n n = n // 16\nprint(ret)\n"}, {"source_code": "o = ['0','4','6','9','a','d']\noo = ['8','b']\ncnt = 0\nn = list(hex(int(input())))\nx = ''\nfor i in range(2,len(n)):\n x += n[i]\nx = str(x)\nfor j in x:\n if j in o:\n cnt += 1\n elif j in oo:\n cnt += 2\nprint(cnt)"}, {"source_code": "a = {'0':1,'1':0,'2':0,'3':0,'4':1,'5':0,'6':1,'7':0,'8':2,'9':1,'a':1,'b':2,'c':0,'d':1,'e':0,'f':0}\ns = 0\nfor i in hex(int(input())).replace('0x', ''):\n\ts += a[i]\nprint(s)"}, {"source_code": "n = int(input())\n\na = []\nif n == 0:\n a.append(0)\nwhile n > 0:\n a.append(n % 16)\n n //= 16\n\nb = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\n\nans = 0\nfor x in a:\n ans += b[x]\nprint(ans)\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/contest/784/problem/B\n\"\"\"\ndef to_hex(n):\n return hex(n)[2:].upper()\n\n\ndef closed_loops(x):\n d = {'0': 1, '1': 0, '2': 0, '3': 0, '4': 1, '5': 0, '6': 1, '7': 0, '8': 2, '9': 1,\n 'A': 1, 'B': 2, 'C': 0, 'D': 1, 'E': 0, 'F': 0}\n total = 0\n a = to_hex(x)\n for c in a:\n total += d[c]\n return total\n\n\ndef main():\n n = int(input())\n print(closed_loops(n))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a = int(input())\ndirdict = {'0':1,'1':0,'2':0,'3':0,'4':1,'5':0,'6':1,'7':0,'8':2,'9':1,'A':1,'B':2,'C':0,'D':1,'E':0,'F':0}\nkals = str(hex(a)).upper()[2:]\nans = 0\nfor i in kals:\n\tans+=dirdict[i]\n#print(kals)\nprint(ans)"}, {"source_code": "d = {\n '0': 1,\n '1': 0,\n '2': 0,\n '3': 0,\n '4': 1,\n '5': 0,\n '6': 1,\n '7': 0,\n '8': 2,\n '9': 1,\n 'a': 1,\n 'b': 2,\n 'c': 0,\n 'd': 1,\n 'e': 0,\n 'f': 0,\n}\n\nprint(sum([d[c] for c in hex(int(input()))[2:]]))"}, {"source_code": "x = int(input(\"\"))\nx = hex(x)[2:]\none = ['0', '4', '6', '9', 'a', 'd']\ntwo = ['8', 'b']\ncount = 0\nfor i in x:\n if(i in one):\n count += 1\n elif(i in two):\n count += 2\nprint(count)"}, {"source_code": "n = hex(int(input()))[2:]\nsum = 0\nfor i in n:\n sum += [1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0][int(i,16)]\nprint(sum)"}, {"source_code": "D={0:1,1:0,2:0,3:0,4:1,5:0,6:1,7:0,8:2,9:1,10:1,11:2,12:0,13:1,14:0,15:0}\nn=int(input())\na=0\nif(n==0):\n a=1\nwhile(n>0):\n a+=D[n%16]\n n//=16\n \nprint(a)"}, {"source_code": "n = int(input())\nn = hex(n)[2:]\nx = n.count('0') + n.count('4') + n.count('6') + n.count('9')\nx += n.count('a') + n.count('d') + n.count('8') * 2 + n.count('b') * 2\nprint(x)"}, {"source_code": "o = ['0','4','6','9','a','d']\noo = ['8','b']\ncnt = 0\nn = list(hex(int(input())))\nx = ''\nfor i in range(2,len(n)):\n x += n[i]\nx = str(x)\nfor j in x:\n if j in o:\n cnt += 1\n elif j in oo:\n cnt += 2\nprint(cnt)"}, {"source_code": "n = input()\na = [1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\n# 0 1 2 3 4 5 6 7 8 9 A B C D E F\ns = 0\nif (n == 0):\n s += 1\nwhile n > 0:\n s += a[n % 16]\n n /= 16\nprint s\n"}, {"source_code": "c=(1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0)\na=input()\ns=int(not a)\nwhile a:\n s+=c[a%16]\n a/=16\nprint s"}, {"source_code": "def count(x):\n if x == 0:\n return 1\n ans = 0\n holes = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\n while x:\n ans += holes[x % 16]\n x //= 16\n return ans\nprint(count(int(input())))\n"}, {"source_code": "print sum({'0':1,'4':1,'6':1,'8':2,'9':1,'a':1,'b':2,'d':1}.get(c,0)for c in hex(input()))-1"}, {"source_code": "n = int(input()) \n#n, m = map(int, input().split())\n#s = input()\n#c = list(map(int, input().split()))\na = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']\nb = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\ns = hex(n)\nl = 0\nfor i in range(2, len(s)):\n l += b[a.index(s[i])]\nprint(l)"}, {"source_code": "a = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\ns = str(hex(int(input())))[2:]\nans = 0\nfor c in s:\n ans += a[int(c, 16)]\nprint(ans)\n"}, {"source_code": "def count(s):\n res = 0\n for i in s:\n if i in ['0', '4', '6', '9', 'A', 'D']:\n res += 1\n elif i in ['8', 'B']:\n res += 2\n return res\n\n\ndef main():\n s = hex(int(input())).replace('0x', '').upper()\n print(count(s))\n\n\nmain()"}, {"source_code": "n = int(input())\nhex = \"\"\nif n == 0: hex = \"0\"\nwhile n:\n if n % 16 <= 9: hex += str(n % 16)\n else: hex += chr(n % 16 + 55)\n n //= 16\ncnt = 0\nfor i in hex:\n if i in ['4', '6', '9', '0', 'A', 'D']: cnt += 1\n elif i in ['8', 'B']: cnt += 2\nprint(cnt)\n"}, {"source_code": "H = {'0': 1, '1': 0, '2': 0, '3': 0,\n '4': 1, '5': 0, '6': 1, '7': 0,\n '8': 2, '9': 1, 'A': 1, 'B': 2,\n 'C': 0, 'D': 1, 'E': 0, 'F': 0}\n\nn = int(input())\nprint(sum(H[h] for h in f'{n:X}'))\n"}, {"source_code": "print(sum([\"046889ABBDabbd\".count(x) for x in hex(int(input()))])-1)"}, {"source_code": "p = int(input())\ns = hex(p).upper()[2:]\n# print(s)\nans = 0\n# 0123456789abcdf\nfor x in s:\n if x == '0':\n ans += 1\n if x == '8':\n ans += 2\n if x == 'A':\n ans += 1\n if x == 'B':\n ans += 2\n if x == '9':\n ans += 1\n if x == 'D':\n ans += 1\n if x == '4':\n ans += 1\n if x == '6':\n ans += 1\nprint(ans)"}, {"source_code": "val = {'0':1, '1':0, '2':0, '3':0, '4':1, '5':0, '6':1, '7':0, '8':2, '9':1, 'a':1, 'b':2, 'c':0, 'd':1, 'e':0, 'f':0}\nans = 0\nfor c in hex(int(input()))[2:]:\n ans += val[c]\nprint(ans)"}, {"source_code": "TASK = \"stars\"\n# FIN = open(TASK + \".in\")\n# FOUT = open(TASK + \".out\", \"w\")\n\na = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\nans = 0\nn = int(input())\nif n == 0:\n print(1)\n exit()\nwhile (n > 0):\n tmp = n % 16\n ans += a[tmp]\n n //= 16\n\nprint(ans)\n\n# FIN.close()\n# FOUT.close()\n"}, {"source_code": "a=hex(int(input()))[2:]\nans=0\nd={\"0\":1,\"1\":0,\"2\":0,\"3\":0,\"4\":1,\"5\":0,\"6\":1,\"7\":0,\"8\":2,\"9\":1,\"a\":1,\"b\":2,\"c\":0,\"d\":1,\"e\":0,\"f\":0}\nfor i in a:\n ans+=d[i]\nprint(ans)"}, {"source_code": "s = hex(int(input()))[2:].upper()\nx = 0\nx += s.count('0')\nx += s.count('4')\nx += s.count('6')\nx += s.count('8') << 1\nx += s.count('9')\nx += s.count('A')\nx += s.count('B') << 1\nx += s.count('D')\nprint(x)\n"}, {"source_code": "s = int(input())\na = hex(s)[2:]\nprint(a.count('0') + a.count('4') + a.count('6') + a.count('8') * 2 + a.count('a') + a.count('9') + a.count('b') * 2 + a.count('d'))"}, {"source_code": "N = int( input() )\nstr = hex( N )[ 2 : ]\n\none = { '0', '4', '6', '9', 'a', 'd' }\ntwo = { '8', 'b' }\n\nans = 0\n\nfor i in range( len( str ) ):\n if str[ i ] in one:\n ans += 1\n elif str[ i ] in two:\n ans += 2\n\nprint( ans )\n"}, {"source_code": "n = hex(int(input()))[2:].upper()\nq = n.count('0')*1\nq += n.count('4')*1\nq += n.count('6')*1\nq += n.count('8')*2\nq += n.count('9')*1\nq += n.count('A')*1\nq += n.count('B')*2\nq += n.count('D')*1\nprint(q)\n"}, {"source_code": "a = int(input())\nh = hex(a)\ns = str(h)[2:]\noneHole = ['0', '4', '6', '9', 'a', 'd']\ntwoHoles = ['8', 'b']\ncount = 0\nfor i in range(len(s)):\n if s[i] in oneHole:\n count += 1\n elif s[i] in twoHoles:\n count += 2\nprint(count)\n"}, {"source_code": "x = int(input())\nt = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\nif x == 0:\n print('1')\n exit(0)\ny = 0\nwhile x > 0:\n y += t[x % 16]\n x //= 16\nprint(y)\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\ndef main():\n n = I()\n s = hex(n).upper()[2:]\n r = 0\n for c in s:\n if c in '8B':\n r += 2\n elif c in '0469AD':\n r += 1\n\n return r\n\n\n\nprint(main())\n"}, {"source_code": "n = int(input())\ns = hex(n)\nx = 0\nfor c in s[2:]:\n\tif c == '0':\n\t\tx += 1\n\tif c == '4':\n\t\tx += 1\n\tif c == '6':\n\t\tx += 1\n\tif c == '8':\n\t\tx += 2\n\tif c == '9':\n\t\tx += 1\n\tif c == 'a':\n\t\tx += 1\n\tif c == 'b':\n\t\tx += 2\n\tif c == 'd':\n\t\tx += 1\nprint(x)"}, {"source_code": "ls = [1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\n\nx = input()\nans = 0\n\nwhile True:\n ans += ls[x%16]\n x /= 16\n if x == 0:\n break\n\nprint ans\n"}, {"source_code": "mp = {\n '0': 1,\n '4': 1,\n '6': 1,\n '8': 2,\n '9': 1,\n 'a': 1,\n 'b': 2,\n 'd': 1,\n}\n\na = raw_input()\nres = 0\nfor i in hex(int(a))[2:]:\n if i in mp:\n res += mp[i]\nprint res"}, {"source_code": "s=int(raw_input())\nb=str(hex(s))[2:]\nsum=0\ns1='0469ad'\ns2='8b'\nfor i in b:\n if s1.find(i) != -1:\n sum += 1\n elif s2.find(i) != -1:\n sum += 2\nprint sum"}, {"source_code": "a = ['0','4','6','8','9','a','b','d']\nn = hex(input())[2:]\nans = 0\nfor i in n:\n if i in a:\n ans+=1\n if i == '8' or i=='b':\n ans+=1\nprint ans"}, {"source_code": "x = hex(int(raw_input()))\nans = 0\nfor c in x[2:]:\n if c in '4690ad':\n ans += 1\n if c in '8b':\n ans += 2\nprint ans"}, {"source_code": "print sum({'0':1,'4':1,'6':1,'8':2,'9':1,'a':1,'b':2,'d':1}.get(c,0)for c in hex(input())[2:])"}, {"source_code": "def f(i) : return i in ['4','6','8','9','0','a','b','d']\ndef g(i) : return i in ['8','b']\nprint sum([f(i)+g(i) for i in hex(int(raw_input()))])-1"}, {"source_code": "print sum([\"046889abbd\".count(x)for x in hex(int(input()))])-1"}, {"source_code": "print sum([(i in'46890abd')+(i in'8b')for i in hex(int(raw_input()))])-1"}, {"source_code": "n = int(raw_input())\nhx = hex(n)[2:]\n\ncnt = 0\n\nfor a in hx:\n\tif a == \"0\":\n\t\tcnt += 1\n\tif a == \"4\":\n\t\tcnt += 1\n\tif a == \"6\":\n\t\tcnt += 1\n\tif a == \"8\":\n\t\tcnt += 2\n\tif a == \"9\":\n\t\tcnt += 1\n\tif a == \"a\":\n\t\tcnt += 1\n\tif a == \"b\":\n\t\tcnt += 2\n\tif a == \"d\":\n\t\tcnt += 1\n\nprint cnt"}, {"source_code": "n = str(hex(int(raw_input())))[2:]\nans = 0\nfor i in n:\n if i == '0':\n ans += 1\n elif i == '4':\n ans += 1\n elif i == '6':\n ans += 1\n elif i == '8':\n ans += 2\n elif i == '9':\n ans += 1\n elif i == 'a':\n ans += 1\n elif i == 'b':\n ans += 2\n elif i == 'd':\n ans += 1\nprint ans"}], "negative_code": [{"source_code": "a = input()\nif(a == '11'):\n\tprint(2)\nelif(a == '14'):\n\tprint(0)\nelif(a == '61441'):\n\tprint(2)\nelif(a == '571576'):\n\tprint(10)\nelif(a == '2128506'):\n\tprint(3)\nelse:\n\tprint(47)"}, {"source_code": "n = input()\nprint(n.count('0') + n.count('4') + n.count('6') + n.count('8') * 2 + n.count('9'))"}, {"source_code": "n = input()\nprint(3)"}, {"source_code": "n = int(input())\nhex = \"\"\nwhile n:\n if n % 16 <= 9: hex += str(n % 16)\n else: hex += chr(n % 16 + 55)\n n //= 16\ncnt = 0\nfor i in hex:\n if i in ['4', '6', '9', '0', 'A', 'D']: cnt += 1\n elif i in ['8', 'B']: cnt += 2\nprint(cnt)\n"}, {"source_code": "n=int(input())\nsumx=0\nwhile(n>0):\n\ta=n%16\n\tif(a<10):\n\t\tif(a==0 or a==4 or a==6 or a==9):\n\t\t\tsumx+=1\n\t\telif(a==8):\n\t\t\tsumx+=2\n\telif(a==10 or a==13):\n\t\tsumx+=1\n\telif(a==11):\n\t\tsumx+=2\n\tn=n//16\nprint(sumx)"}, {"source_code": "n = int(input())\nn = bin(n + 1)[2:]\nprint(n.count('0'))\n"}, {"source_code": "d = {\n '0': 1,\n '1': 0,\n '2': 0,\n '3': 0,\n '4': 0,\n '5': 0,\n '6': 1,\n '7': 0,\n '8': 2,\n '9': 1,\n 'a': 1,\n 'b': 2,\n 'c': 0,\n 'd': 1,\n 'e': 0,\n 'f': 0,\n}\nprint(sum(d[c] for c in hex(int(input()))[2:]))\n"}, {"source_code": "n=int(input())\nprint(n*n*n)"}, {"source_code": "rings = [1,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\ndef cnt(n):\n if n:\n res = 0\n while n:\n res += rings[n%16]\n n //= 16\n else:\n res = 1\n return res\nn = int(input())\nprint(cnt(n))"}, {"source_code": "D={0:1,1:0,2:0,3:0,4:1,5:0,6:1,7:0,8:2,9:1,10:1,11:2,12:0,13:1,14:0,15:0}\nn=int(input())\na=0\nwhile(n>0):\n a+=D[n%16]\n n//=16\n \nprint(a)"}, {"source_code": "mp = {\n '0': 1,\n '6': 1,\n '8': 2,\n '9': 1,\n 'a': 1,\n 'b': 2,\n 'd': 1,\n 'e': 0\n}\n\na = raw_input()\nres = 0\nfor i in hex(int(a))[2:]:\n if i in mp:\n res += mp[i]\nprint res"}, {"source_code": "s=int(raw_input())\nb=str(hex(s))[2:]\nsum=0\ns1='0469ad'\ns2='8b'\nfor i in b:\n if s1.find(i):\n sum += 1\n elif s2.find(i):\n sum += 2\nprint sum\n"}, {"source_code": "s=14\nb=str(hex(s))[2:]\nsum=0\ns1='0469ad'\ns2='8b'\nfor i in b:\n if s1.find(i) != -1:\n sum += 1\n elif s2.find(i) != -1:\n sum += 2\nprint sum"}, {"source_code": "s=int(raw_input())\nb=str(hex(s))[:2]\nsum=0\ns1='0469ad'\ns2='8b'\nfor i in b:\n if s1.find(i):\n sum += 1\n elif s2.find(i):\n sum += 2\nprint sum"}, {"source_code": "s = raw_input()\nans = 0\nfor i in xrange(len(s)):\n c = 0\n for j in xrange(i + 1, len(s)):\n if s[i] == s[j]:\n ans += int(s[i]) * 2 - c\n c += int(s[j])\nprint ans\n"}, {"source_code": "count = {\n '0': 1,\n '6': 1,\n '8': 2,\n '9': 1,\n 'a': 1,\n 'b': 2,\n 'd': 1\n}\ns = hex(int(input()))[2:]\ncnt = 0\nfor ch in s:\n if ch in count:\n cnt += count[ch]\nprint cnt"}, {"source_code": "a = ['0','4','6','8','9','a','b','d']\nn = hex(input())[2:]\nprint n\nans = 0\nfor i in n:\n if i in a:\n ans+=1\n if i == '8' or i=='b':\n ans+=1\nprint ans"}, {"source_code": "x = hex(int(raw_input()))\nans = 0\nfor c in x[2:]:\n if c in '4690AD':\n ans += 1\n if c in '8B':\n ans += 2\nprint ans"}, {"source_code": "print sum({'0':1,'6':1,'8':2,'9':1,'a':1,'b':2,'d':1}.get(c,0)for c in hex(input())[2:])"}, {"source_code": "st = \"0123456789ABCDEF\"\np = \"1000101021120100\"\n\na = int(raw_input())\nans = 0\nwhile a > 0:\n q = a % 16\n ans += int(p[q])\n a /= 16\n\nprint ans\n"}, {"source_code": "st = \"0123456789ABCDEF\"\np = \"1000101011120100\"\n\na = int(raw_input())\nans = 0\nwhile a > 0:\n q = a % 16\n ans += int(p[q])\n a /= 16\n\nprint ans\n"}, {"source_code": "a = int(raw_input())\nres = 0\nwhile a > 0:\n part = a % 16\n a /= 16\n if part == 0 or part == 4 or part == 6 or part == 9 or part == 10 or part == 13:\n res += 1\n if part == 8 or part == 11:\n res += 2\nprint res"}, {"source_code": "n = input()\n\nans = 0\nwhile n > 0:\n x = n % 16\n n /= 16\n if x == 0 or x == 4 or x == 6 or x == 9 or x == 10 or x == 13:\n ans += 1\n else:\n if x == 8 or x == 11:\n ans += 2\n\nprint ans"}, {"source_code": "from sys import stdin\nst=stdin.readline()\na = hex(int(st))\nl = {'0':1,'1':0,'2':0,'3':0,'4':1,'5':0,'6':1,'7':0,'8':2,'9':0,'a':1,'b':2,'c':0,'d':1,'e':0,'f':0}\nn = len(a)\nt = 0\nfor i in range(2, n):\n\tt += l[a[i]]\nprint t\n"}, {"source_code": "n = int(raw_input())\nn = hex(n)[2:]\n\nd = {\n '0' : 1,\n '1' : 0,\n '2' : 0,\n '3' : 0,\n '4' : 0,\n '5' : 0,\n '6' : 1,\n '7' : 0,\n '8' : 2,\n '9' : 1,\n 'a' : 1,\n 'b' : 2,\n 'c' : 0,\n 'd' : 1,\n 'e' : 0,\n 'f' : 0\n}\n\nans = 0\n\nfor c in n:\n ans += d[c]\n\nprint ans\n"}, {"source_code": "a=sorted(map(int,raw_input().split())[1:])\ni=0\nwhile i<11000000:\n\ti+=1\nprint \" \".join(map(str,a))"}, {"source_code": "a=int(input())\nb=[1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\nres=0\nwhile a>0:\n\tres+=b[a%16]\n\ta/=16\nprint(res)\n"}, {"source_code": "A = [0] * 255\nA[ord('0')]=1\nA[ord('4')]=1\nA[ord('6')]=1\nA[ord('8')]=2\nA[ord('A')]=1\nA[ord('B')]=2\nA[ord('D')]=1\nprint sum(map(lambda x: A[ord(x)], hex(int(raw_input()))[2:].upper()))"}, {"source_code": "s = hex(int(raw_input())).upper()[2:]\nret = 0\nfor x in s:\n if x in ['0', '6', '9', 'A', 'D']:\n ret += 1\n if x in ['8', 'B']:\n ret += 2\nprint ret\n"}, {"source_code": "n = input()\na = [1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\ns = 0\nwhile n > 0:\n s += a[n % 16]\n n /= 16\nprint s\n"}, {"source_code": "c=(1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0)\na=input()\ns=0\nwhile a:\n s+=c[a%16]\n a/=16\nprint s"}, {"source_code": "n = int(raw_input())\n\ns = []\nwhile n > 0:\n s.append(n % 16)\n n /= 16\n\n\nholes = {\n 0: 1,\n 1: 0,\n 2: 0,\n 3: 0,\n 4: 0,\n 5: 0,\n 6: 1,\n 7: 0,\n 8: 2,\n 9: 1,\n 10: 1, # A\n 11: 2, # B\n 12: 0, # C\n 13: 1, # D\n 14: 0, # E\n 15: 0 # F\n }\n\nprint sum(map(lambda x: holes[x], s))\n\n"}, {"source_code": "n = int(raw_input())\n\ns = []\nwhile n > 0:\n s.append(n % 16)\n n /= 16\n\n\nholes = {\n 0: 1,\n 1: 0,\n 2: 0,\n 3: 0,\n 4: 1,\n 5: 0,\n 6: 1,\n 7: 0,\n 8: 2,\n 9: 1,\n 10: 1, # A\n 11: 2, # B\n 12: 0, # C\n 13: 1, # D\n 14: 0, # E\n 15: 0 # F\n }\n\nprint sum(map(lambda x: holes[x], s))\n\n"}, {"source_code": "n = int(input())\nsumma = 0\nwhile n>0:\n x = n%16\n n //= 16\n if x==15 or x==1 or x==2 or x==10:\n summa += 1\n if x==8 or x==11:\n summa += 2\nprint(summa)\n"}, {"source_code": "n = int(input())\nsumma = 0\nwhile n>0:\n x = n%16\n n //= 16\n if x==15 or x==1 or x==2 or x==7:\n summa += 1\n if x==8 or x==15:\n summa += 2\nprint(summa)\n"}, {"source_code": "n = int(input())\nsumma = 0\nwhile n>0:\n x = n%16\n n //= 16\n if x==15 or x==1 or x==2 or x==10:\n summa += 1\n if x==8 or x==15:\n summa += 2\nprint(summa)\n"}, {"source_code": "n = int(input())\nsumma = 0\nwhile n>0:\n x = n%16\n n //= 16\n if x==15 or x==1 or x==2 or x==7:\n summa += 1\n if x==8 or x==11:\n summa += 2\nprint(summa)\n"}, {"source_code": "n = int(input())\nsumma = 0\nwhile n>0:\n x = n%16\n n //= 16\n if x==4 or x==0 or x==6 or x==9 or x==10 or x==13:\n summa += 1\n if x==8 or x==11:\n summa += 2\nprint(summa)\n"}, {"source_code": "print(hex(int(input())).count(\"046889ABBDabde\")-1)"}, {"source_code": "print(sum([\"046889ABBDabde\".count(x) for x in hex(int(input()))])-1)"}, {"source_code": "cur = int(input())\nhex = \"\"\nshit = ['A', 'B', 'C', 'D', 'E', 'F']\nwhile cur != 0:\n temp = cur % 16\n cur = cur // 16\n if temp >= 10:\n hex += shit[temp - 10]\n else:\n hex += str(temp)\nansw = 0\nfor a in hex:\n if a == 'A' or a == '6' or a == '0' or a == 'D' or a == '4' or a == '9':\n answ = answ + 1\n elif a == '8' or a == 'B':\n answ += 2\nprint(answ)"}, {"source_code": "n = int(input())\nans = 1 if n == 0 else 0\n\nwhile n > 0:\n d = n % 16\n n = n // 16\n if d == 8 or d == 11:\n ans += 2\n elif d == 0 or d == 4 or d == 6 or d == 10 or d == 13:\n ans += 1\n\nprint(ans)\n"}, {"source_code": "def mp():\n return map(int, input().split())\n\nk = int(input())\nabc = '0123456789ABCDEF'\nr = 0\nwhile k > 0:\n d = abc[k % 16]\n if d in '069AD':\n r += 1\n elif d in '8B':\n r += 2\n k //= 16\nprint(r)"}, {"source_code": "def mp():\n return map(int, input().split())\n\nk = int(input())\nabc = '0123456789ABCDEF'\nr = 0\nwhile k > 0:\n d = abc[k % 16]\n if d in '0469AD':\n r += 1\n elif d in '8B':\n r += 2\n k //= 16\nprint(r)"}, {"source_code": "def main():\n n = int(input())\n n = hex(n)[2:]\n ans = 0\n for c in n:\n if c == '0' or c == '6' or c == '9' or c == 'a':\n ans += 1\n if c == '8' or c == 'b':\n ans += 2\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n n = int(input())\n n = hex(n)[2:]\n ans = 0\n for c in n:\n if c == '0' or c == '6' or c == '9' or c == 'd':\n ans += 1\n if c == '8' or c == 'b':\n ans += 2\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n n = int(input())\n n = hex(n)[2:]\n ans = 0\n for c in n:\n if c == '0' or c == '6' or c == '9':\n ans += 1\n if c == '8' or c == 'b':\n ans += 2\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n n = int(input())\n n = hex(n)[2:]\n ans = 0\n for c in n:\n if c == '0' or c == '6' or c == '9' or c == 'a' or c == 'd':\n ans += 1\n if c == '8' or c == 'b':\n ans += 2\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a=[1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\nx=int(input())\nb=0\nwhile x:\n b+=a[x%16]\n x//=16\nprint(b)"}, {"source_code": "a=[1,0,0,0,0,0,1,0,2,1,1,2,0,1,0,0]\nx=int(input())\nb=0\nwhile x:\n b+=a[x%16]\n x//=16\nprint(b)"}, {"source_code": "a=[1,0,0,0,1,0,1,0,2,1,0,2,0,1,0,0]\nx=int(input())\nb=0\nwhile x:\n b+=a[x%16]\n x//=16\nprint(b)"}, {"source_code": "import sys\n# 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F\nx = [0, 4, 6, 8, 8, 9, 10, 11, 11, 13]\n\nn = int(input())\nret = 1 if n == 0 else 0\nwhile n:\n ret += x.count(n % 16)\n n = n / 16\nprint(ret)\n"}, {"source_code": "v=[1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0]\nn=int(input())\na=0\nwhile n>0:\n a+=v[n%16]\n n//=16\nprint(a)\n"}, {"source_code": "a = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\n\nn = int(input())\nif n == 0:\n print(1)\ns = 0\nwhile n:\n s += a[n % 16]\n n //= 16\nprint(s)\n\n"}, {"source_code": "a = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\n\nn = int(input())\ns = 0\nwhile n:\n s += a[n % 16]\n n //= 16\nprint(s)\n\n"}, {"source_code": "x = int(input(\"\"))\nx = hex(x)[2:]\none = ['0', '4', '6', '9', 'a', 'c']\ntwo = ['8', 'b']\ncount = 0\nfor i in x:\n if(i in one):\n count += 1\n elif(i in two):\n count += 2\nprint(count)\n"}, {"source_code": "x = int(input(\"\"))\none = ['0', '4', '6', '9', 'a', 'c']\ntwo = ['8', 'b']\ncount = 0\nwhile(True):\n y = (hex(int(x % 16)))[2:]\n if(y in one):\n count += 1\n elif(y in two):\n count += 2\n x = int(x/16)\n if(x == 0):\n break\nprint(count)\n"}, {"source_code": "def count(x):\n if x == 0:\n return 1\n ans = 0\n holes = [1, 0, 0, 0, 0, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\n while x:\n ans += holes[x % 16]\n x //= 16\n return ans\nprint(count(int(input())))\n"}, {"source_code": "def count(x):\n ans = 0\n holes = [1, 0, 0, 0, 0, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\n while x:\n ans += holes[x % 16]\n x //= 16\n return ans\nprint(count(int(input())))\n"}, {"source_code": "a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\n\np = int(input())\nprint(a[p - 1])\n"}, {"source_code": "p = int(input())\ns = hex(p).upper()[2:]\nans = 0\nfor x in s:\n if x == '0':\n ans += 1\n if x == '6':\n ans += 1\n if x == '8':\n ans += 2\n if x == 'A':\n ans += 1\n if x == 'B':\n ans += 2\n if x == 'D':\n ans += 1\n if x == '4':\n ans += 1\nprint(ans)"}], "src_uid": "16a784cb9953bc91cb2e7767b04b76f2"} {"source_code": "n = int(input())\narr = [int(a) for a in input().split(\" \")]\nm = max(arr)\nr = m - 25\nif r > 0:\n print(r)\nelse:\n print(0)", "positive_code": [{"source_code": "n = input()\nl = map(int,raw_input().split())\nprint max(0,max(l)-25)\n"}, {"source_code": "n=input()\nL=[int(x) for x in raw_input().split()]\nif max(L)<=25:\n print 0\nelse:\n print max(L)-25\n"}, {"source_code": "k=input()\nr=list(map(int,input().split()))\nif max(r)>25:\n\tprint(max(r)-25)\nelse:\n\tprint(0)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# File : 859a.py\n# Author : recurze\n# Date : 15:25 08.12.2018\n# Last Modified Date: 15:25 08.12.2018\n\nn = int(raw_input())\na = max(list(map(int, raw_input().split())))\nprint max(a - 25, 0)\n"}, {"source_code": "import math\nfrom fractions import Fraction as frac\n\nMOD = 1e9 + 7\n\ndef solve(case_no):\n n = int(input())\n a = list(map(int, input().split()))\n a = sorted(a)\n print(max(0, a[n - 1] - 25))\n\n\nt = 1\n# t = int(input())\nfor i in range(1, t + 1):\n solve(i)\n"}, {"source_code": "\nraw_input()\n\nxs = map(int, raw_input().split(' '))\n\nprint max(0, max(xs) - 25)\n\n"}, {"source_code": "k = input()\na = map(int,raw_input().split(\" \"))\n\nif max(a)<= 25:\n print \"0\"\nelse:\n print max(a) - 25"}, {"source_code": "n=int(input())\nc=list(map(int,input().split()))\nprint(max(0,max(c)-25))"}, {"source_code": "n=input()\ns=map(int,raw_input().split(\" \"))\na=max(s)\nm=0\nif(a>25):\n m=a-25\nprint m\n"}, {"source_code": "l=lambda:map(int, raw_input().split())\nn=input()\na=l()\nmaxi=max(a)\nif maxi<26:\n print 0\nelse:\n print maxi-25"}, {"source_code": "n = int(input())\np = [*map(int,input().split())]\nprint(0 if(max(p)-25)<0 else max(p)-25)"}, {"source_code": "n=int(input())\nl=list(map(int, input().split()))\nm=max(l)\n\nif m<=25:\n print(0)\n\nelse:\n print(m-25)"}, {"source_code": "raw_input()\nprint(max(list(map(int,raw_input().split()))+[25])-25)"}, {"source_code": "import sys\n\n_ = sys.stdin.readline()\nparts = sys.stdin.readline().strip().split(' ')\nseq = [int(part) for part in parts]\nm = max(seq)\n\nprint max(m - 25, 0)\n"}, {"source_code": "n=int(input());s=input().split();mx=25;\nfor i in s:\n mx=max(mx,int(i));\nprint(mx-25)"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nprint(max(0,max(a)-25))"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nif max(l)<=25:print(0) \nelse:print(max(l)-25)"}, {"source_code": "import sys,math\ninput=sys.stdin.readline\n\nL=lambda : list(map(int,input().split()))\nM=lambda : map(int,input().split())\n\nn=int(input())\nl=L()\nprint(max(0,max(l)-25))\n"}, {"source_code": "n=int(input())\nk=list(map(int,input().split()))\nif max(k)>25:\n print(max(k)-25)\nelse:\n print(\"0\")"}, {"source_code": "n = int(input())\nr = list(map(int, input().split()))\nprint(max(r) - 25) if max(r) > 25 else print(0)\n"}, {"source_code": "n=int(input())\nranks=list(map(int, input().split()))\n\nmaxrank=max(ranks)\nif(maxrank<=25):\n print(0)\nelse:\n print(maxrank-25)"}, {"source_code": "s = int(input())\nl = list(map(int, input().split()))\nl.sort(reverse = True)\nif l[0] < 25:\n print(0)\n exit()\nprint(l[0] - 25)"}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\nprint(max(0,max(arr)-25))\n"}, {"source_code": "n=int(input())\na=sorted(list(map(int,input().split())))\nif a[-1]<=25:\n print(0)\nelse:\n print(abs(a[-1]-25))"}, {"source_code": "\nk = int(input())\nl = list(map(int,input().split()))\n\nif max(l) <= 25 :\n print(0)\n\nelse:\n print(max(l) - 25)\n"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef main():\n n = int(input())\n A = list(map(int, input().split()))\n if max(A) < 25:\n print(0)\n else:\n print(max(A) - 25)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "a = int(input())\nl = list(map(int, input().split()))\nmx = max(l)\nif mx <= 25:\n print(0)\nelse:\n print(mx-25)\n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\ng = max(l)\n\nif g <= 25:\n print(0)\nelse:\n print(g - 25) "}, {"source_code": "n = int(input())\na = [int(x) for x in input().split(' ')]\nif max(a) > 25: print(max(a) - 25)\nelse: print(0)\n"}, {"source_code": "n = int(input())\nls = list(map(int, input().split(\" \")))\nmx = max(ls)\nif mx > 25:\n print(mx - 25)\nelse:\n print(0)"}, {"source_code": "_ = input()\nx = max(int(i) for i in input().split())\nif x <= 25:\n print(0)\nelse:\n print(x-25)"}, {"source_code": "\nn = int(input())\na = list(map(int,input().split()))\nif(max(a)>25):\n print(max(a)-25)\nelse:\n print(0)\n\n \n \n "}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\na=max(l)\nif a>25:\n print(a-25)\nelse:\n print(0) \n"}, {"source_code": "input()\nprint(max(25, max(map(int, input().split()))) - 25)\n"}, {"source_code": "a = int(input())\nc = list(map(int,input().split()))\nif max(c)-25 < 0: print(0)\nelse: print(max(c)-25)"}, {"source_code": "n = int(raw_input())\narr = map(int, raw_input().split())\n\nprint max(0, max(arr) - 25)\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nprint(max(0,max(l)-25))"}, {"source_code": "def declined(known, ranks):\n known = int(known)\n ranks = [int(x) for x in ranks]\n ranks.sort()\n if known >= 25:\n prev = 0\n declined = 0\n for rank in ranks:\n rank = int(rank)\n diff = rank - prev\n if diff > 1:\n declined += diff - 1\n prev = rank\n\n return declined\n\n prev = 25\n declined = 0\n l25 = True\n for rank in ranks:\n rank = int(rank)\n if rank > 25:\n l25 = False\n declined += rank - prev\n prev = rank\n\n if l25:\n return 0\n\n return declined\n\nk = input()\nr = input().strip().split(' ')\nprint(declined(k, r))\n"}, {"source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# import math\n# from itertools import *\n# import random\n# import calendar\n# import datetime\n# import webbrowser\n\nn = int(input())\narr = list(map(int, input().split()))\nmax_ = max(arr)\nif max_ - 25 <= 0:\n print(0)\nelse:\n print(max_ - 25)\n"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\n\nif max(s)>25:\n\tprint(max(s)-25)\nelse:\n\tprint(0)"}, {"source_code": "k=input();\nl=max(map(int, input().split()));\nif l>25:\n print(l-25)\nelse:\n print(0)\n"}, {"source_code": "if __name__ ==\"__main__\":\t\n\tn = int(input())\n\tarr = list(map(int,input().split()))\n\tif max(arr)<=25:\n\t\tprint(0)\n\telse:\n\t\tx = n \n\t\tif 1 not in arr:\n\t\t\tarr.append(0)\n\t\t\tx+=1\n\t\tans = 0\n\t\tarr.sort()\n\t\tfor i in range(1,x):\n\t\t\tans += (arr[i]-arr[i-1]-1)\n\t\tprint(ans-(25-n))\n"}, {"source_code": "input();print(max(0,max(map(int,input().split()))-25))"}, {"source_code": "__author__ = 'Alexander'\n\nimport sys\ndef Task(n, numbers):\n elem = max(numbers)\n return max(0, elem - 25)\n\ndef Main():\n n = int(input().strip())\n numbers = map(int, input().strip().split())\n outp = Task(n, numbers)\n print(\"{}\\n\".format(outp))\n\ndef Test():\n #These \"asserts\" using only for self-checking and not necessary for auto-testing\n assert Task(5, [16, 23, 8, 15, 4]) == 0\n assert Task(25, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28]) == 3\n\nif __name__ == \"__main__\":\n Main()\n # Test()"}, {"source_code": "numbers = int(input())\n\nmax_number_of_finalist = 25\n\nfor i in input().split():\n max_number_of_finalist = max(max_number_of_finalist, int(i))\n\nprint(max_number_of_finalist - 25)\n"}, {"source_code": "N=int(input())\narr=list(map(int,input().split()))\narr.sort()\nif arr[-1]>=25:\n\tprint(arr[-1]-25)\nelse:\n\tprint(\"0\")"}, {"source_code": "n=int(input())\nx=input()\na=x.split( )\nfor i in range(0,n):\n a[i]=int(a[i])\na.sort()\nif a[n-1]>25:\n print(a[n-1]-25)\nelse:\n print(0)\n"}, {"source_code": "\nn=input()\nm=list(map(int,input().split()))\nif max(m)>25:\n\tprint(max(m)-25)\nelse:\n\tprint(0)\t"}, {"source_code": "n = int(input())\nai = list(map(int,input().split()))\nres = True\nfor i in ai:\n if i <= 25:\n res = True\n else:\n res = False\n break\nif res == True:\n print(0)\nelse:\n print(max(ai)-25)"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\n\ns.sort()\nif s[-1] > 25:\n print(s[-1] - 25)\nelse:\n print(0)\n "}, {"source_code": "if __name__ == '__main__' :\n n = int(input())\n k = [int(num) for num in input().split()]\n print(max(0, max(k)-25))\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nif max(a)-25>0:\n\tprint(max(a)-25)\nelse:\n\tprint(0)"}, {"source_code": "n, s = int(input()), max(list(map(int,input().split(' '))))\nprint(0 if s<=25 else s-25 )"}, {"source_code": "k=int(input())\na=list(map(int,input().split()))\nif max(a)<25:\n print(0)\nelse:\n print(max(a)-25)"}, {"source_code": "n=input()\nt=list(map(int,input().split()))\nif max(t)<=25:\n print(0)\nelse:\n print(max(t)-25)\n"}, {"source_code": "def main():\n\tn=int(input())\n\tl=input().split()\n\tfor i in range(len(l)):\n\t\tl[i]=int(l[i])\n\tmaximum=l[0]\n\tfor i in range(n):\n\t\tmaximum=max(maximum, l[i])\n\tmaximum-=25\n\tif maximum>=0:\n\t\tprint(maximum)\n\telse:\n\t\tprint(\"0\")\nmain()"}, {"source_code": "\"\"\"\n\n\n\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2551\u255a\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2588\u2588\u2551\n\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\n\u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u255d\n __ __ _ \n| \\/ (_)_ __ ___ _ __ \n| |\\/| | | '__/ _ \\| '_ \\ \n| | | | | | | (_) | | | | \n|_| |_|_|_| \\___/|_| |_| \n\"\"\"\n\"\"\"\n \u041a\u0440\u0430\u0441\u0438\u0432\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u043e\u0435.\n \u042f\u0432\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043d\u0435\u044f\u0432\u043d\u043e\u0435.\n \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0435.\n \u0421\u043b\u043e\u0436\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0435.\n \u041f\u043b\u043e\u0441\u043a\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435.\n \u0420\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043f\u043b\u043e\u0442\u043d\u043e\u0435.\n \u0427\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.\n \u041e\u0441\u043e\u0431\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043e\u0431\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430.\n \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u0435\u0435 \u0431\u0435\u0437\u0443\u043f\u0440\u0435\u0447\u043d\u043e\u0441\u0442\u0438.\n \u041e\u0448\u0438\u0431\u043a\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043c\u0430\u043b\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f.\n \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u0437\u0430\u043c\u0430\u043b\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u044f\u0432\u043d\u043e.\n \u0412\u0441\u0442\u0440\u0435\u0442\u0438\u0432 \u0434\u0432\u0443\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u0442\u0431\u0440\u043e\u0441\u044c \u0438\u0441\u043a\u0443\u0448\u0435\u043d\u0438\u0435 \u0443\u0433\u0430\u0434\u0430\u0442\u044c.\n \u0414\u043e\u043b\u0436\u0435\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438, \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e.\n \u0425\u043e\u0442\u044f \u043e\u043d \u043f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0433\u043e\u043b\u043b\u0430\u043d\u0434\u0435\u0446 [^1].\n \u0421\u0435\u0439\u0447\u0430\u0441 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043d\u0438\u043a\u043e\u0433\u0434\u0430.\n \u0425\u043e\u0442\u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441.\n \u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u2014 \u0438\u0434\u0435\u044f \u043f\u043b\u043e\u0445\u0430.\n \u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u2014 \u0438\u0434\u0435\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0445\u043e\u0440\u043e\u0448\u0430.\n \u041f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430! \u0411\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435!\n\"\"\"\n\"\"\"\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2593\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2592\u2592\u2593\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2593\u2592\u2592\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2592\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2592\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2588\u2588\u2591\u2592\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\n\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2593\u2593\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2593\u2593\u2592\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\n\u2591\u2593\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2592\u2591\n\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\n\u2588\u2588\u2593\u2592\u2593\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2593\u2593\u2588\u2588\u2588\n\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2593\u2593\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2588\u2592\u2588\u2588\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2592\u2592\u2588\u2593\u2588\u2591\u2588\u2588\u2588\u2593\u2593\u2592\u2592\u2592\u2593\u2592\u2592\u2593\u2593\u2593\u2588\u2588\u2588\u2592\u2588\u2588\u2588\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2592\u2593\u2588\u2592\u2592\u2588\u2591\u2588\u2592\u2588\u2591\u2588\u2591\u2588\u2593\u2588\u2592\u2588\u2593\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2593\u2588\u2593\u2588\u2593\u2588\u2592\u2588\u2592\u2588\u2593\u2588\u2593\u2588\u2588\u2588\u2588\u2591\u2593\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2591\u2593\u2588\u2593\u2588\u2591\u2588\u2592\u2588\u2591\u2588\u2591\u2588\u2592\u2588\u2592\u2588\u2588\u2588\u2592\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2588\u2593\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2588\u2588\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2593\u2592\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2593\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2592\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\n\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u258c\u2591\u2591\u2591\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u258c\u2591\u2591\u2591\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u258c\u2591\u2591\u2591\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2584\u2588\u2588\u2588\u2588\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2580\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\n\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@#@@#@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@M@M # #@@@M@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@#@@ @@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@### #@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@B@@#@@@@@#M@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@##@@M@#@@##@##@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#M@@@@@##@M@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@@@@@@#@##@#@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ #\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ #\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@ @@#@@#@@@@@@@@@@@@@@@@@#@@#@#@@@@@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@\n @ #@@@@@@@@@@@@@@@@@@@@#@@@@@@#@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@ @@#@#@@@@@@@@@@@@@@@@@@#@####@@@@@@@@@@@@@@@@@M@#@@#@#@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@#@#M@@@M@@@@@@@@@@@@@@@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n#@M@#@#@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@M@@M@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@@#@@@@@@@@@@@@@@@@@@@@M@M@#@@@@@@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@\n@@#@@#@@@@@@@@@@@@@@@@@@@@@@@M@ @M@@#@@@@@@@@@@@@@@@@@@@@@@@@@\n@#@@@@@#@@@@@@@@@@@@@@@@@@@#@@ @@@@M@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@@@##@@@#@@@@@#@@@@@##@@@@ #@#@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@####@@####@@@@#@@@@M@@@#@@# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@#@ @#@@#@@@ #@ @ #@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @# @@#@@ #@@#@@@@@@@@@@@@@@@@@@@@@@@@@\n ##@#@@ #M @# @@ @@M @@@@@@@@@@@@@@@@@@@@@@@@\n @#@@@M #@ #@ # @@ @@@@@@@@@@@@@@@@@@@@@@@@\n @@ @@#@@ ## @##@@ @@@@@@@@@@@@@@@@@@@@@@@@\n @# @@M@ @@ @@@@@@@@@@@@@@@@@@@@@@@@\n @@@##@@@ @@@@ @@@ @@ #@#@@#@@@@@@@@@@@@@@@@@\n@@@@###@@###@@@@#@#@@@@#@@@ M@ #@ @ B @@@#@@@@@@@@@@@@@@@@@@@\n@M@@@@@MM@@@@@M@@#@##@@@#@@M@B @# M@ @# #@ #@@#@@@@@@@@@@@@@@@@@@@\n@#@#@@M@@M@@#@#@#@#@@#@#@#@@@@ @# @@ # @M @#@@@@@@@@@@@@@@@@@@@@@\n@@@ @@@@#@##@ #@# @M # @ @ @@@@@#@@@@@@@@@@@@@@@@@\n @@ @@ @#@@#@@#M #@@@@#@@@@@@@@@@@@@@@@@\n M@# #@ @@@@##@@ @M@#M@@@#@@@@@@@@@@@@@@@@\n @@@@ @@ @@@#@@@#@#@@@@@@@@@@@@@@@@\n @# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @M@H@@ @# @#@@@@#@@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@#@##@M@@@M@ @M#@@@@@#@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n#M@@@##@@@@@@@@M@@@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@#@@@@@M@#@M@@B#M@@M@###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n###@@@@@@@@@# @#@@@@@@@#@@@#@##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@#@@M@@@#@@#@#@@@@@@#@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@M@#@# \n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@#\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@##\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@M\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n\"\"\"\n\"\"\"\n / \\ //\\\n |\\___/| / \\// \\\\\n /0 0 \\__ / // | \\ \\ \n / / \\/_/ // | \\ \\ \n @_^_@'/ \\/_ // | \\ \\ \n //_^_/ \\/_ // | \\ \\\n ( //) | \\/// | \\ \\\n ( / /) _|_ / ) // | \\ _\\\n ( // /) '/,_ _ _/ ( ; -. | _ _\\.-~ .-~~~^-.\n (( / / )) ,-{ _ `-.|.-~-. .~ `.\n (( // / )) '/\\ / ~-. _ .-~ .-~^-. \\\n (( /// )) `. { } / \\ \\\n (( / )) .----~-.\\ \\-' .~ \\ `. \\^-.\n ///.----..> \\ _ -~ `. ^-` ^-_\n ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~\n /.-~\n\n\"\"\"\n\"\"\"\n ____ _ _____ \n / ___|___ __| | ___| ___|__ _ __ ___ ___ ___ \n| | / _ \\ / _` |/ _ \\ |_ / _ \\| '__/ __/ _ \\/ __|\n| |__| (_) | (_| | __/ _| (_) | | | (_| __/\\__ \\\n \\____\\___/ \\__,_|\\___|_| \\___/|_| \\___\\___||___/\n\"\"\"\n\"\"\"\n\u2591\u2591\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\n\u2591\u2584\u2580\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2588\u2591\n\u2591\u2588\u2591\u2584\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2584\u2591\u2588\u2591\n\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2591\n\u2591\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2591\n\u2584\u2588\u2580\u2588\u2580\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2580\u2580\u2588\u2588\u2588\n\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\n\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2588\u2588\n\u2588\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\u2588\n\u2591\u2580\u2588\u2588\u2588\u2584\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2584\u2588\u2588\u2588\u2580\u2591\n\u2591\u2591\u2591\u2580\u2588\u2588\u2584\u2591\u2580\u2588\u2588\u2580\u2591\u2584\u2588\u2588\u2580\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\nn = int(input())\nos=0\nch=[]\nfor i in range(n):\n\tm = int(input())\n\tch.append(m)\t\n\tif ch[0]==10:\t\t\n\t\tif 1 in ch:\n\t\t\tprint((len( ch[:ch.index(1)])))\n\t\t\tbreak\n\telse:\n\t\tif 10 in ch:\n\t\t\tprint((len( ch[:ch.index(10)])))\n\t\t\tbreak\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\nm = float(m)\nmi = []\nfor i in range(n):\n\ta,b = map(float,input().split())\n\tmi.append((a*m)/b)\nprint(round(min(mi),6))\n\"\"\"\n\"\"\"\nl = input().split()\nl = set(l)\nprint(len(l))\n\n\"\"\"\n\"\"\"\t\nx = input()\ny = x[1:-1]\nz = set(y.split(', '))\nif x == \"{}\":\n\tprint(0)\nelse:\n\tprint(len(z))\n\"\"\"\n\"\"\"\nn,k = map(int,input().split())\nL = sorted(map(int, input().split()))\nres = [L[0]]\nfor i in range(1,n):\n if L[i] != L[i-1]:\n res.append(L[i]-L[i-1])\nl = len(res)\nif k > l:\n res += [0]*(k-l)\nfor i in range(k):\n print(res[i])\n\n\"\"\"\t\n\"\"\"\nfrom math import*\ns,k = map(int,input().split(\" \"))\nsq = input().split()\nscore = 0\npol = \"\"\nfor i in range(len(sq)):\n\tif sq[i]>=sq[i-1]:\n\t\tscore+=1\nprint(ceil(score/len(sq))+ceil(score/len(sq)))\n\"\"\"\n\"\"\"\nfrom math import*\ns,k = map(int,input().split(\" \"))\nsq = input().split()\nscore = 0\npol = \"\"\nfor i in range(len(sq)):\n\tif sq[i]>=sq[i-1]:\n\t\tscore+=1\nprint(ceil(score/len(sq))+ceil(score/len(sq)))\n\"\"\"\n\"\"\"\nst=list(input().split('+'))\nst.sort()\nfor i in range(len(st)):\n if i!=len(st)-1:\n print(str(st[i])+'+',end='')\n else:\n print(str(st[i]))\n\"\"\"\n\"\"\"\na = input()\nup = a.upper()\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nprint(abc[abc.find(up[0])]+a[1::])\n\"\"\"\n\"\"\"\n\nn= int(input())\nk = 0\nfor i in range(n):\n\tp = input()\n\tif p == \"++X\" or p == \"X++\":\n\t\tk+=1\n\telif p == \"--X\" or p == \"X--\":\n\t\tk-=1\nprint(k)\n\n\"\"\"\n\"\"\"\nimport math \n\nc = 1 \n\nl = int(input()) \n\ng = \"\" \n\nfor i in range(l): \n\n for s in range(1,l - i + 1): \n\n g = g + \" \" \n for j in range(0,i + 1): \n if(i == 0 or j == 0): \n c = 1 \n else: \n c = c * (i - j + 1)/j \n\n t = c \n T=0 \n while(t != 0): \n T = T + 1 \n t = int(math.floor(t/10)) \n p=0 \n while((p+T)!=4): \n g = g + \" \" \n p=p+1 \n g = g + str(int(math.floor(c))) \n g = g + \"\\n\" \nprint(g)\n\"\"\"\t\n\"\"\"\n ___ __ _ _ \n|_ _|_ __ / _| ___ _ __ _ __ ___ __ _| |_(_) ___ ___ \n | || '_ \\| |_ / _ \\| '__| '_ ` _ \\ / _` | __| |/ __/ __|\n | || | | | _| (_) | | | | | | | | (_| | |_| | (__\\__ \\\n|___|_| |_|_| \\___/|_| |_| |_| |_|\\__,_|\\__|_|\\___|___/ \n\"\"\"\n\"\"\" \nfrom math import*\na1 = float(input())\na2 = float(input())\nb = sqrt(a1**2 + a2**2)\nprint(b)\n\"\"\" \n\"\"\"\na1 = float(input())\na2 = float(input())\nb = (a1**2 + a2**2)\nimport math\nl = math.sqrt(b)\nprint(l)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if i%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if a[i]%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if a[i]>0:\n b.append(a[i])\nprint(len(b))\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(1,n):\n if a[i]>a[i-1]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(1,n):\n if a[i]>a[i-1]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(n-1):\n if i == 0:\n pass\n elif a[i]>a[i-1]and a[i+1]< a[i]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\na.reverse()\nfor i in a:\n print(i,end = \" \")\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nprint(max(a))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split(\" \")))\nl = 0\nq = []\nfor i in range(len(a)):\n if a[i] in q:\n pass\n else:\n l +=1\n q.append(a[i])\nprint(l)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nx = int(input())\nk =1\nfor i in range(len(a)):\n k+=1\n if x > a[i]:\n print(i+1)\n exit()\nprint(k)\n\"\"\"\n\"\"\"\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if i%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(len(a)-1):\n if i == 0:\n pass\n elif a[i]>a[i-1]and a[i+1]< a[i]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\na = list(map(int,input().split()))\nprint(max(a),a.index(max(a)))\n\"\"\"\n\"\"\"\nch = list(input()) \nif ch.count(\"h\")>=1 and ch.count(\"e\")>=1 and ch.count(\"l\")>=2 and ch.count(\"o\")>=1 and len(ch)!=53:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom decimal import Decimal\nx,y = map(Decimal,input().split(\" \"))\nd = 1\nwhile x < y and x - y < 0.000001 :\n x += x * 70 / 100\n d += 1\nprint(d)\n\"\"\"\n\"\"\"\nn = int(input())\nabc = \"abcdefghijklmnopqrstuvwxyz\"\ns =\"\"\nfor i in range(n):\n\tk,v = map(int,input().split())\n\tfor i in range(k):\n\t\twhile len(s) <= k:\n\t\t\ts += abc[:v]\n\t\tif len(s)>k:\n\t\t\ts = s[:-(len(s)-k)]\n\tprint(s,end=\"\\n\")\n\ts=\"\"\t\t\n\"\"\"\n\"\"\"\nk = int(input())\nl = int(input())\nm = int(input())\nn = int(input())\nd = int(input())\nlst = []\nlst.append(k)\nlst.append(l)\nlst.append(m)\nlst.append(n)\nuron = 0\nfor i in range(len(lst)):\n\tif d % lst[i] == 0:\n\t\turon+=lst[i]\nprint(uron)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nch = 0\nnch = 0\nfor i in range(len(a)):\n\tif a[i] % 2 == 0:\n\t\tch+=1\n\telse:\n\t\tnch+=1\nif ch > nch:\n\tfor i in range(len(a)):\n\t\tif a[i] % 2 == 1:\n\t\t\tprint(a.index(a[i])+1)\nelse:\n\tfor i in range(len(a)):\n\t\tif a[i]%2==0:\n\t\t\tprint(a.index(a[i])+1)\n\"\"\"\n\"\"\"\nn,t = map(int,input().split())\noc = input()\nfor i in range (1,n):\n\tif oc[i]==\"B\":\n\t\toc[i]=oc[i-1]\nprint(oc)\t\t\t\n\"\"\"\n\"\"\"\nn = int(input())\no = 0\nfor i in range(n):\n\to += ((n-2) - (n % 2))//2\nprint(o)\n\"\"\"\n\"\"\"\nsl = input()\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nm=0\nb=0\nbig = \"\"\nfor i in range(len(sl)):\n\tif sl[i]== abc[abc.find(sl[i])]:\n\t\t\tb+=1\n\telse:\n\t\t\tm +=1\nif m>b:\n\tbig += sl.lower()\n\tprint(big)\nelif b>m:\n\tbig += sl.upper()\n\tprint(big)\nelif b==m:\n\tbig += sl.lower()\n\tprint(big)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(n):\n\tprint(a.index(i+1)+1, end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\nif n % 2 == 0 and n != 2 :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\na = input().replace(\"WUB\",\" \")\nprint(a)\n\"\"\"\n\"\"\"\na = int(input())\nb = list(map(int,input().split()))\nb.sort()\nfor i in b:\n\tprint(i,end=\" \")\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\no = 0\nif a % 2 == 0:\n\to = a//2\nelse:\n\to = (a//2)+1\nif b <= o:\n\tprint((1+((o-1)*2)))\nelse:\n\tprint(((o-1)*2))\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nyear = 0\nwhile b>=a:\n\ta*=3\n\tb*=2\n\tyear+=1\nprint(year)\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\nm = float(m)\nmi = []\nfor i in range(n):\n\ta,b = map(float,input().split())\n\tmi.append((a*m)/b)\nprint(min(mi))\n\"\"\"\n\"\"\"\nn = int(input())\nx = 0\nfor i in range(n):\n\ta = input()\n\tif a == \"Tetrahedron\":\n\t\tx+=4\n\telif a == \"Cube\":\n\t\tx+=6\n\telif a == \"Octahedron\":\n\t\tx+=8\n\telif a == \"Dodecahedron\":\n\t\tx+=12\n\telif a == \"Icosahedron\":\n\t\tx+=20\nprint(x)\n\"\"\"\n\"\"\"\nn= int(input())\na = list(map(int,input().split()))\nfor i in a:\n\tif sum(a)>0:\n\t\tprint(\"HARD\")\n\t\tbreak\n\telse:\n\t\tprint(\"EASY\")\n\t\tbreak\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nc = list(map(int,input().split()))\nbal = 0\nfor i in range(1,len(c)+1):\n\tif b == len(c):\n\t\tif c[i]>=c[b-1]:\n\t\t\tbal +=1\n\telse:\n\t\t\n\t\tif c[i]>=c[b] and c[i]!= 0:\n\t\t\tbal+=1\nprint(bal)\n\"\"\"\n\"\"\"\na,b =map(int, input().split())\ny=list(map(int,input().split()))\nfor i in y:\n if i<y[b-1] or i==0:\n a-=1 \nprint(a)\n\"\"\"\n\"\"\"\na,b=map(int,input().split())\nc=b-(a+1)//2\nif c > 0:\n\tprint(2*c)\nelse:\n\tprint(2*b-1)\n\"\"\"\n\"\"\"\na = input()\nb = input()\na1 = a.lower()\nb1 = b.lower()\no = 0\nk = 0\nif a1>b1:\n\to+=1\nif b1>a1:\n\tk+=1\nprint(o-k)\n\"\"\"\n\"\"\"\nn=int(input())\np=input().split()\nq=input().split()\nm = p[1:]\nj = q[1:]\nif len(set(m+j))==n:\n print(\"I become the guy.\")\nelse:\n print(\"Oh, my keyboard!\")\n\"\"\"\n\"\"\"\na = set(input())\nfor i in range(len(a)):\n\ta.remove()\n\tif a == \"hello\":\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\na = n.count(4)+n.count(7)\nif a == 7 or a == 4:\n\t\tprint(\"YES\")\n\t\t\nelse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\t\nn = int(input())\nb = input()\nb = b.upper\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nfor i in range(len(b)):\n\tif abc[i] in b:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn,a,b = list(map(int,input().split()))\npos = 0\nfor i in range(n):\n\tif (a + b) % 2 == 0:\n\t\tprint(a+b)\n\t\tbreak\n\telse:\n\t\tprint(ceil((a+b)/2))\n\t\tbreak\n\"\"\"\n\"\"\"\nn = int(input())\nans = 0\nfor i in range(n):\n\ta,b,c = map(str,input().split())\n\tb = int(b)\n\tfor i in range(n):\n\t\tif b == -b and c == \"YES\":\n\t\t\tprint(\"Impossible\")\n\t\telif ans > b and c == \"Y\":\n\t\t\tans += 1\n\t\telif ans < b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans >= b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans <= b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans > b and c == \"N\":\n\t\t\tbreak\n\t\telif ans < b and c == \"N\":\n\t\t break\n\t\telif ans >= b and c == \"N\":\n\t\t\tbreak\n\t\telif ans <= b and c == \"N\":\n\t\t\tbreak\nprint(ans)\t\t\n\"\"\"\n\"\"\"\nfrom math import*\nn,k = map(int,input().split())\na = list(map(int,input().split()))\ncom = 0\nfor i in range(len(a)):\n\tif a[i]+2 <= 5:\n\t\tcom += 0.333\nprint(ceil(com))\n\"\"\"\n\"\"\"\nn,a,b = map(int,input().split())\nd = []\ns = 0\nk = 1\nfor i in range(n-1):\n\tif a == 0 and b == 0:\n\t\tprint(n)\n\t\texit()\n\td.append(\"*\"*((a+i)) +\"+\"+\"*\"*(((b-i)-k)))\n\tif len(d[i])<=n:\n\t\ts+=1\nprint(s)\n\"\"\"\n\"\"\"\nn,h =map(int, input().split())\nfor i in map(int, input().split()):\n if i > h:\n n+=1\nprint(n)\t\n\"\"\"\n\"\"\"\nn = input()\na = input()\nif a.count('A')> a.count('D'):\n\tprint('Anton')\nelif a.count('A')<a.count('D'):\n\tprint('Danik')\nelse:\n\tprint('Friendship')\n\"\"\"\n\"\"\"\nn = int(input())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\ng = list(map(sum,a))\ncount=0\ni=0\nfor j in g:\n if j >=2:\n count+=1\nprint(count)\n\"\"\"\n\"\"\"\nn=int(input())\nx=input()\nc=0\nfor i in range(n-1):\n if x[i] == x[i+1]:\n c+=1\nprint(c)\n\"\"\"\n\"\"\"\nk = list(map(int,input().split()))\nt = input()\nkal = 0\nfor i in range(len(t)):\n\tif t[i]==\"1\":kal += k[0]\n\telif t[i]==\"2\":kal += k[1]\n\telif t[i]==\"3\":kal += k[2]\n\telif t[i] == \"4\":kal += k[3]\nprint(kal)\n\"\"\"\n\"\"\"\norient = input()\nkey = input()\nkeyboard = \"poiuytrewq;lkjhgfdsa/.,mnbvcxz\"\nans = \"\"\nfor i in range(len(key)):\n\tif orient == \"R\":\n\t\tans += keyboard[keyboard.find(key[i])+1]\n\telif orient == \"L\":\n\t\tans += keyboard[keyboard.find(key[i])-1]\nprint(ans)\n\"\"\"\n\"\"\"\nn,k = map(int, input().split())\nabc = \"abcdefghijklmnopqrstuvwxyz\"\nf = abc[:k]\ns = f \nwhile len(s) < n:\n s += f\ns = s[:n]\nprint(s)\n\"\"\"\n\"\"\"\nn = int(input())\nif n %2 == 0 or n == 2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nmas = 0\nwhile 1:\n\ttry:\n\t\ta = input()\n\t\tif \":\" in a:\n\t\tmas += len(a[a.find(\":\"):])\n\texcept EOFError:\nprint(mas)\n\"\"\"\n\"\"\"\na = input()\nb = input()\nc = str(int(a)+int(b))\nif int(a.replace(\"0\",\"\"))+int(b.replace(\"0\",\"\"))== int(c.replace(\"0\",\"\")):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\ns = input()\nw = len(s)\nn=int(input())\nb=[]\nfor i in range(n):\n wd=input()\n if wd[:w]==s:\n b.append(wd)\nb.sort()\nif len(b)==0:\n print(s)\nelse:\n print(min(b))\n\"\"\"\n\"\"\"\nn = int(input())\nans = 0\nfor i in range(n):\n\tx,a = map(int,input().split())\n\tif x == -x and a:\n\t\tans += a \n\telse:\n\t\tans+=a\nprint(ans)\n\"\"\"\n\"\"\"\nfrom decimal import Decimal\nn,m = map(int,input().split())\nfst = []\nscd = []\na=0\nfor i in range(1,n+1):\n\tfor j in range(1,m+1):\n\t\tif (i+j)%5==0:\n\t\t\ta+=1\nprint(a)\n\"\"\"\n\"\"\"\nn,a = map(int,input().split())\nans = \"\"\nfor i in range(n):\n\tb = list(map(str,input().split()))\n\tfor j in range(a):\n\t\tif b[j] != \"B\" or b[j]!=\"W\"or b[j]!=\"G\":\n\t\t\tans += \"#Color\"\n\t\t\tbreak\n\t\t\t\n\t\telse:\n\t\t\tans += \"#Black&White\"\n\t\t\tbreak\nprint(ans)\n\"\"\"\n\"\"\"\nn=int(input())\nnum=0\na , b =[],[]\nfor i in range(n):\n c=input().split()\n a.append(c[0])\n b.append(c[1])\nfor i in a:\n num+=b.count(i)\nprint(num)\n\"\"\"\n\"\"\"\nn = int(input())\nb = input()\na = b.lower()\n\nif a.count(\"a\")>=1 and a.count(\"b\")>=1 and a.count(\"c\")>=1 and a.count(\"d\")>=1 and a.count(\"e\")>=1 and a.count(\"f\")>=1 and a.count(\"g\")>=1 and a.count(\"h\")>=1 and a.count(\"i\")>=1 and a.count(\"j\")>=1 and a.count(\"k\")>=1 and a.count(\"l\")>=1 and a.count(\"m\")>=1 and a.count(\"n\")>=1 and a.count(\"o\")>=1 and a.count(\"p\")>=1 and a.count(\"q\")>=1 and a.count(\"r\")>=1 and a.count(\"s\")>=1 and a.count(\"t\")>=1 and a.count(\"u\")>=1 and a.count(\"v\")>=1 and a.count(\"w\")>=1 and a.count(\"x\")>=1 and a.count(\"y\")>=1 and a.count(\"z\")>=1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\ndig = []\nfor i in range(1,n+1):\n\tif factorial(i-1) % i != i-1:\n\t\tdig.append(i)\nfor j in range(1,len(dig)+1):\t\n\tif dig[j] + dig[j-n%2-4] == n or dig[j] + dig[j-n%2-9] == n:\n\t\tprint(dig[j],dig[j-n%2-4])\n\"\"\"\n\"\"\"\na=input()\nb=input()\ns=input()\nc=a+b\nd=list(s)\ne=list(c)\nd.sort()\ne.sort()\nif d==e:\n print('YES')\nelse:\n print('NO')\n\"\"\"\n\"\"\"\n def nextmiron(s):\n s += '#'\n cnt = 1\n ret = \"\"\n for i in range(1, len(s)):\n if s[i] == s[i - 1]:\n cnt += 1\n else:\n ret += str(cnt) + s[i - 1];\n cnt = 1\n return ret\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\nfor i in range(len(n)):\n\tif n[i] > 0:\n\t\tprint(n[i],end=\"\")\n\t\texit()\n\telif n[i]>n[i-1]:\n\t\tn.remove(n[i])\nfor i in n:\n\tprint(n[i],end=\"\")\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\na = 0\nans = 0\nfor i in range(len(n)):\n\t\ta += n[i]+n[i-1]\n\t\tans += 1\n\t\tif a in n:\n\t\t\tbreak\nprint(ans+1)\n\"\"\"\n\"\"\"\nfrom math import factorial as fal\na,b = map(int,input().split())\nans = 0\np = []\nprime = []\nfor i in range(a,b+1):\n\tif fal(i-1) % i == i-1:\n\t\tp.append(i)\nfor i in range(len(p)):\n\tif fal((int(str(p[i])[::-1]))-1)% int(str(p[i])[::-1]) == int(str(p[i])[::-1])-1: \n\t\tans += 1\nprint(ans)\n\"\"\"\n\"\"\"\na,b,c = map(int,input().split())\nd = str(a/b)\nif len(d)==3:\n\tprint(d+\"0\"*(c-1))\nelse:\n\tprint(round((a/b),c))\n\"\"\"\n\"\"\"\na = list(input())\nn = 0\nh = 'hello'\nfor i in range(len(a)):\n if a[i] == h[n]:\n n += 1\n if n >= 5:\n break\nif n >= 5: \n\tprint('YES')\nelse: \n\tprint('NO')\n\"\"\"\n\"\"\"\nfrom math import factorial as fal\na,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1): \n\tif fal(i-1) % i == i-1 and fal((int(str(i)[::-1]))-1) % int(str(i)[::-1]) == int(str(i)[::-1])-1:\n ans += 1 \nif a == 1:\n\tprint(ans - 1)\n\texit()\nprint(ans)\n\"\"\"\n\"\"\"\nl=list(map(int,input().split(' ')))\nn,v=l[0],l[1:]\ndp=[1]*(n+1)\ninf=2**64\nfor i in range(n+1):\n\tif i not in v:\tdp[i]=-inf\nfor i in range(n+1):\n\tfor j in v:\n\t\tif i>j:\n\t\t\tdp[i]=max(dp[i],dp[j]+dp[i-j])\nprint(dp[n])\n\"\"\"\n\"\"\"\np = list(map(int,input().split()))\nq = set(p)\ns = 0\nfor i in q:\n s += p.count(i)-1\nprint(s)\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nh = []\nl = []\nfor i in range(b):\n c = list(map(int,input().split()))\n h.append(c)\nh.sort()\nfor i in h:\n if a > i[0]:\n l.append(1)\n a += i[1]\n \nif len(l) == b:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn,m=map(int,input().split())\nans=0\nfor i in range(1,n+1):\n\tans += int((i+m)/5)-int(i/5)\nprint(ans)\n\"\"\"\n\"\"\"\na = input()\nif a[0]==\"-\":\n\tprint((a[0])+a[1],a[2])\nelse:\t\n\tprint(int(a[0]),int(a[1]))\n\"\"\"\n\"\"\"\nfrom math import factorial as myfunct\na,b = map(int,input().split())\nc = min(a,b)\nprint(myfunct(c))\n\"\"\"\n\"\"\"\na,b,c = map(int,input().split())\nd = []\nd.append(a)\nd.append(b)\nd.append(c)\nd.sort()\nprint(d[2]-d[0])\n\"\"\"\n\"\"\"\nn=int(input())\na=list(map(int,input().split()))\nb = a[:]\nb.reverse()\nu = a.index(max(a))\nl = n-1-b.index(min(a))\nif u > l:\n print(u+(n-1-l)-1)\nelse:\n print(u+(n-1-l))\n\"\"\"\n\"\"\"\ns=input().lower()\nfor i in \"aeiouy\":\n s = s.replace(i,\"\")\nprint(\".\"+\".\".join(s))\n\"\"\"\n\"\"\"\nn = int(input())\nmaxi = 0\nmini = 0\nfor i in range(n):\n\ta,b = map(int,input().split())\n\tmaxi += a+b\n\tmini += a//i\nprint(mini,maxi)\n\"\"\"\n\"\"\"\nn = int(input())\nlast_zero = []\nfor i in range(n):\n\ta = input()\n\tif a[-1]==\"0\":\n\t\tlast_zero.append(a)\nfor i in range(len(last_zero)):\n\tif last_zero[i].count(\"0\")>last_zero[i-1].count(\"0\"):\n\t\tprint(last_zero[i])\n\t\tbreak\n\"\"\"\n\"\"\"\nn = int(input())\nfor i in range(n):\n\ta,b = map(int,input().split())\n\td = len(str(a+b))\n\tif int(str(a)[-i])+int(str(b)[-i]) >= 10 and int(str(a)[-i])+int(str(b)[-i]) >= 10:\n\t\tprint(a+b-(10**(d-1)))\n\"\"\"\n\"\"\"\nfcoin,coins = map(int,input().split())\nl = fcoin\npirates = 0\nwhile l <= coins:\n\tl += fcoin +1\n\tpirates+=1\nprint(pirates)\n\"\"\" \n\"\"\"\na,b = map(str,input().split(\"+\"))\nroman = [\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\",\"X\",\"XI\",\"XII\",\"XIII\",\"XIV\",\"XV\",\"XVI\",\"XVII\",\"XVIII\",\"XIX\",\"XX\"]\nf = roman.index(a)+1\ns = roman.index(b)+1\nd = f+s\nprint(roman[d-1])\n\"\"\"\n\"\"\"\nx = int(input())\nj = 0\nr =[]\nl = []\nfor i in range(x):\n y = [int(i) for i in list(input().split())]\n if y[0]<0:\n l.append(y)\n else:\n r.append(y)\nr = sorted(r)\nl = sorted(l, reverse = True)\n\nj = 0\n\nd =1 if len(r)>=len(l) else -1\nwhile((d == 1 and len(r)>0) or (d==-1 and len(l)>0)):\n if d ==1:\n j += r[0][1]\n r = r[1:]\n d = -1\n else:\n j += l[0][1]\n l = l[1:]\n d = 1\nprint(j)\n\"\"\"\n\"\"\"\na=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\nn=int(input())\nans=0\nfor i in range(1,n+1):\n\tif i%a==0 or i%b==0 or i%c==0 or i%d==0:\n\t\tans+=1\nprint(ans)\n\"\"\"\n\"\"\"\nn,m = map(int,input().split( ))\nfor i in range(n):\n if i%2==0:\n print('#'*m)\n elif i%4==1:\n print('.'*(m-1)+'#')\n else:\n print('#'+'.'*(m-1))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int, input().split()))\nprint(sum(a)/n)\n\"\"\"\n\"\"\"\na,b = map(int, input().split())\n\nr1 = min(a,b)\nr2 = (max(a,b) - min(a,b)) // 2\n\nprint(r1,r2)\n\"\"\"\n\"\"\"\na = input()\nb1,b2,b3,b4,b5 = map(str,input().split())\nif a[-1] == b1[-1] or a[-1] == b2[-1] or a[-1] == b3[-1] or a[-1] == b4[-1] or a[-1] == b5[-1] or a[0] == b1[0] or a[0] == b2[0] or a[0] == b3[0] or a[0] == b4[0] or a[0] == b5[0]:\t\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nlo = []\nfor i in range(n):\n\ta = int(input())\n\tlo.append(a)\nif sum(lo)-lo[-1] == lo[-1] or sum(lo) == 360:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(len(a)):\n\tif factorial(a[i]-1) % a[i] == a[i]-1:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nans = a\nif a % b == 0:\n\tans += a//b\nif (a//b) % 2 == 0:\n\tans += ans % b\nprint(ans)\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nprint(a+b)\n\"\"\"\n\"\"\"\na = input()\nif set(a) == \"ABC\" or set(a) == \".ABC\" or set(a) == \"ABC.\":\n\tprint(1)\nelse:\n\tprint(2)\nprint(set(a))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nans = 0\nfor i in range(len(a)):\n\tif a[i] >= a[-1]:\n\t\tans += 1\nprint(ans)\n\"\"\"\n\"\"\"\nn,k = map(int,input().split())\ni = 0\nwhile 1:\n\ti+=1\n\tif (i // k)*(i % k) == n:\n\t\tprint(i)\n\t\tbreak\n\"\"\"\n\"\"\"\na = input()\nif \"ABC\" in a or \"ACB\" in a or \"BAC\" in a or \"BCA\" in a or \"CAB\" in a or \"CBA\" in a:\n\tprint('Yes')\nelse:\n\tprint('No')\n\"\"\"\n\"\"\"\ns=''\nfor i in range(int(input())):\n s=s+input()\nprint(s.count('11')+s.count('00')+1)\n\"\"\"\n\"\"\"\na = int(input())\nb = [[0] * a for i in range(a)]\nc = []\nfor i in range(a):\n for j in range(a):\n if i == 0 :\n b[i][j] = 1\n else:\n b[i][j] = b[i - 1][j] + b[i][j -1]\nfor i in b:\n c.append(max(i))\nprint(max(c))\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nfor i in range(b):\n\tif a % 10 != 0:\n\t\ta -= 1\n\telif a % 10 == 0:\n\t\ta //= 10\nprint(a)\n\"\"\"\n\"\"\"\nn = int(input())\nans = []\nfor i in range(100):\n\tif int(str(i[0]))+ int(str(i[1]))== 10:\n\t\tans.append(i)\nprint(ans[n])\t\n\"\"\"\n\"\"\"\nn=int(input())\na=input()\nc=0\nfor i in range(n-2):\n if a[i]+a[i+1]+a[i+2]==\"xxx\":\n c+=1\nprint(c)\n\"\"\"\n\"\"\"\na = input()\nb = input()\nop = a.find(\"1\")\nop1 = b.find(\"1\")\nop2 = min(op,op1)\nif a[0] == \"0\" and b[0] == \"0\":\n\tprint(\"0\"*len(a[:op2])+str((int(a)+int(b))).replace(\"2\",\"0\"))\nelse:\n\tprint(str((int(a)+int(b))).replace(\"2\",\"0\"))\n\"\"\"\n\"\"\"\nn = int(input())\nif n % 2 != 0:\n print(n//2)\n print('2 '*(n//2-1)+'3')\nelse:\n print(n//2)\n print('2 '*(n//2))\n\"\"\"\n\"\"\"\na=int(input())\nfor i in range(a):\n\tb,c,d = map(int,input().split())\n\tif d >= min(b,c):\n\t\tprint(max(b,c)+(d-max(b,c)%d))\n\telse:\n\t\tprint(d)\n\"\"\"\n\"\"\"\nn = int(input().strip())\nkras = input().strip()+'W'\nk = []\nl = 0\nfor i in range(n+1):\n if kras[i] == 'B':\n l += 1\n elif l != 0:\n k.append(str(l))\n l = 0\nprint(len(k))\nprint(' '.join(k))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n\tif a[i] % 2 == 0:\n\t\ta[i] = a[i] - 1\nfor i in a:\n\tprint(i, end = \" \")\n\"\"\"\n\"\"\"\nn,k = map(int, input().split())\ns=1\nd = n\nwhile (n%10!=k and n%10!=0):\n n+=d\n s+=1\nprint(s)\n\"\"\"\n\"\"\"\nn = int(input())\na = input()\nb = []\ncan = 1\nfor i in range(n):\n\tb.append(int(a[i]))\n\tif a[i] != '4' and a[i] != '7':\n\t\tcan = 0\nsuma = 0\nfor i in range(n):\n\tif i < n / 2:\n\t\tsuma += b[i]\n\telse:\n\t\tsuma -= b[i]\n\nif suma != 0 or can == 0:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\"\"\"\n\"\"\"\nn,k = map(int,input().split())\nif (n // k) % 2 == 1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nvar = []\nfor i in range(10000):\n\tif str(i) == str(i)[::-1] and len(str(i)) % 2 == 0 or len(str(i)) == 2:\n\t\tvar.append(i)\nprint(var[n])\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nans = []\ntot=0\nfor i in range(999):\n\twhile i>0:\n\t\tdig=i%10\n\t\ttot+=dig\n\t\ti //=10\n\tif tot == b:\n\t\tans.append(i)\nif len(ans)==0:\n\tprint(-1,-1)\n\texit()\nprint(min(ans),max(ans))\n\"\"\"\n\"\"\"\nn = int(input())\nseq = []\nfor i in range(1,10000):\n\tseq.append(i*(-1)**i)\nfor i in range(n):\n\tl,r = map(int,input().split())\n\tprint(sum(seq[l-1:r]))\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(len(a)):\n\tg = sqrt(a[i])\n\tpoint = str(g).find(\".\")\n\tif len(str(g)[point:])>2:\n\t\tg = 100\n\tif factorial(g-1) % g == g-1 and g != 1: \n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nmishka = 0\nChris = 0\nFriend = 0\nfor i in range(n):\n\ta,b = map(int,input().split())\n\tif a > b:\n\t\tmishka += 1\n\telif b > a:\n\t\tChris += 1\n\telif a == b:\n\t\tFriend += 1\nif mishka > Chris:\n\tprint(\"Mishka\")\nelif Chris > mishka:\n\tprint(\"Chris\")\nelif Chris == mishka:\n\tprint(\"Friendship is magic!^^\")\n\t\n\"\"\"\n\"\"\"\nn = int(input())\nans = [\"purple\",\"green\",\"blue\",\"orange\",\"red\",\"yellow\"]\nans1 = []\nfor i in range(n):\n\ta = input()\n\tans1.append(a)\n\tdel(ans[ans.index(a)])\nprint(len(ans))\nfor i in range(len(ans)):\n\tif ans[i] == \"purple\":\n\t\tprint(\"Power\")\n\telif ans[i] == \"green\":\n\t\tprint(\"Time\")\n\telif ans[i] == \"blue\":\n\t\tprint(\"Space\")\n\telif ans[i] == \"orange\":\n\t\tprint(\"Soul\")\n\telif ans[i] == \"red\":\n\t\tprint(\"Reality\")\n\telif ans[i] == \"yellow\":\n\t\tprint(\"Mind\")\n\"\"\"\n\"\"\"\na = input()\nans = 0\nb = a\nfor i in range(len(a)):\n\tif a == a[::-1]:\n\t\tb = a[i:]\n\t\tif b != b[::-1]:\n\t\t\tans = len(a)-i\n\t\t\tbreak\n\telif a != a[::-1]:\n\t\tans = len(a)\n\telif a[i]==a[i-1]:\n\t\tans = 0\nprint(ans)\n\"\"\"\n\"\"\"\nfrom math import*\nd,h,v,e = map(int,input().split())\nvol = (pi*(d/2)**2)\nvol1= (pi/vol - pi)\nif vol < vol1:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\tprint(pi/(vol-pi))\nprint(vol,vol1)\n\"\"\"\n\"\"\"\nn = int(input())\nif n == 1 or n == 2 or n == 3:\n\tprint(-1)\n\texit()\nans = [1,5,7,8,3,5,8,7]\nfor i in range(1,n-1):\n\tfor j in range(i,n-1):\n\t\tif ans[j]>ans[j-1]:\n\t\t\tans[j-1],ans[j]=ans[j-1],ans[j]\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\npast = \"\"\nans =\"\"\nfor i in range(a):\n\tkl = input()\n\tpast += kl\nif \"W\" in past:\n\tl = past.replace(\".\",\"D\")\nfor i in range(len(l)):\n\tif i %b==0:\n\t\tprint(l[i])\n\telse:\n\t\tprint(l[i],end='')\n\"\"\"\n\"\"\"\nn = int(input())\ncode1 = input()\ncode2 = input()\npassword = \"1234567890\"\nans = 0\nfor i in range(len(code1)):\n\tans += len(password[password.find(code1[i]):password.find(code2[i])])\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\na = input()\none = a.count(\"1\")\nzero = a.count(\"0\")\nprint(abs(one-zero))\n\"\"\"\n\"\"\"\nn = int(input())\na = input()\nlol = \"\"\nans = \"\"\nYN = \"\"\nif a == \"abb\":\n\tprint(\"YES\")\n\tprint(\"ab\")\n\texit()\nfor i in a:\n\tlol += i\nif a[:] == a[0]*len(a):\n\tYN += \"NO\"\nelse:\n\tYN += \"YES\"\n\tans += lol[-(len(set(a))):]\nprint(YN)\t\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\na = set(map(int,input().split()))\na = list\nprint(len(a))\nlol = \"\"\nfor i in a:\n\tlol += str(i)\n\tlol += \" \"\nfor i in range(len(lol)):\n\tkek = a.count(lol[i])\n\tprint(kek)\n\"\"\"\n\"\"\"\nw,h,k = map(int,input().split())\nans = 0\nfor i in range(k):\n\tif k == 1:\n\t\tans +=(((h*2)+(w-2)*2))\n\telse:\n\t\tans +=(((h*2)+(w-2)*2)+((h-4*(k-1))*2)+((w-4*(k-1)-2)*2)) // 2\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\nmark = input().split()))\nmark.sort()\nans = 0\nif round((sum(mark)/n)+0.00001)==5:\n\tprint(0)\n\texit()\nelse:\n\tfor i in range(n):\n\t\tmark[i] = 5\n\t\tans += 1\n\t\tif round((sum(mark)/n)+0.000001) == 5:\n\t\t\tprint(ans)\n\t\t\tbreak\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\na = list(map(int,input().split()))\nseta = list(set(a))\nif len(set(a)) >= m:\n\tprint(\"YES\")\n\tfor i in range(m):\n\t\tprint(a.index(seta[i])+1,end = \" \")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\na=int(input())\nb=int(input())\nc=int(input())\nb=b//2\nc=c//4\nif a<=b:\n d=a\nelse\n d=b\nif d>c\n d=c\nd*=7\nprint(d)\n\"\"\"\n\"\"\"\na,b = list(map(int,input().split()))\nprint((a*b)//2)\n\"\"\"\n\"\"\"\nn = int(input())\nfor i in range(n):\n\ta,b = map(int,input().split())\n\tprint(a,a*2)\n\"\"\"\n\"\"\"\nn,a=map(int,input().split())\nm=list(map(int,input().split()))\nans=0\nfor i in range(6-a):\n ans+=m.count(i)\nans//=3\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int, input().split()))\nans = []\nans1 = 1\nfor i in range(1, n):\n if a[i] > a[i - 1]:\n ans1 += 1\n else:\n ans.append(ans1)\n ans1 = 1\nans.append(ans1)\nprint(max(ans))\n\"\"\"\n\"\"\"\nn = int(input())\ns = input()\ndecode = \"*\"*len(s)\nk = \"\"\nfor i in range(len(s)):\n\tif len(decode) %2== 0:\n\t\tk += decode.replace(decode[(len(s)//2)-1],s[i])\n\telse:\n\t\tk += decode.replace(decode[(len(s)//2)],s[i])\nprint(k)\n\"\"\"\n\"\"\"\nn=int(input())\ns=input()\nans=\"\"\nif n%2==0:\n for i in range(n):\n if i%2==1:\n ans+=s[i]\n else:\n ans=s[i]+ans\nelse:\n for i in range(n):\n if i%2==0:\n ans+=s[i]\n else:\n ans=s[i]+ans\nprint(ans)\n\"\"\"\n\"\"\"\ns = input()\nsrev = s[::-1]\nprint(srev+s)\n\"\"\"\n\"\"\"\nn = int(input())\nsumA = 0\nsumB = 0\nans = \"\"\nfor i in range(n):\n\tt,x,y = map(int,input().split())\n\tif t == 1:\n\t\tsumA += (x+y)\n\telse:\n\t\tsumB += (x+y)\n\tif x >= sumA//2:\n\t\tans += \"LIVE\"\n\telse:\n\t\tans += \"DEAD\"\n\tif x >= sumB // 2:\n\t\tans += \"LIVE\"\n\telse:\n\t\tans += \"DEAD\"\nprint(ans[:4*n])\n\"\"\"\n\"\"\"\nn,c = map(int,input().split())\nques = list(map(int,input().split()))\ntime = list(map(int,input().split()))\nradewoosh = 0\nlimak = 0\ntimecode = 0\nfor i in range(n):\n\ttimecode += time[i]\n\tlimak += max(0,ques[i]-c*timecode)\nradewoosh = 0\ntimecode = 0\nfor i in range(n):\n\ttimecode += time[n-1-i]\n\tradewoosh += max(0,ques[n-1-i]-c*timecode)\n\nif radewoosh > limak:\n\tprint(\"Radewoosh\")\nelif radewoosh < limak:\n\tprint(\"Limak\")\nelif radewoosh == limak:\n\tprint(\"Tie\")\n\"\"\"\n\"\"\"\ns1 = input()\ns2 = input()\ns3 = input()\ns3 = s3.lower()\n\nkek = \"\"\nans = \"\"\nfor i in range(len(s3)):\n\tif s3[i] == \"1\" or s3[i] == \"2\" or s3[i] == \"3\" or s3[i] == \"4\" or s3[i] == \"5\" or s3[i] == \"6\" or s3[i] == \"7\" or s3[i] == \"8\" or s3[i] == \"9\" or s3[i] == \"0\": \n\t\tkek += s3[i]\nfor i in range(len(s3)-len(kek)):\n\tans += s2[s1.find(s3[i])]\nprint(ans+kek)\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(len(a)):\n\tg = sqrt(a[i])\n\tpoint = str(g).find(\".\")\n\tif len(str(g)[point:])>2:\n\t\tg = 100\n\tif factorial(g-1) % g == g-1 and g != 1: \n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nmina = n\nmaxi = n\nwhile str(mina)[-1] != \"0\":\n\tmina -= 1 \nwhile str(maxi)[-1] != \"0\":\n\tmaxi += 1\nif max(maxi,mina) - n > n - min(maxi,mina):\n\tprint(mina)\nelse:\n\tprint(maxi)\nn = int(input())\nl = 0\nif n == 3 :\n l += 1\n print(0)\nif n == 1 or n == 2:\n l += 1\n print(1)\nif n % 4==1 or n % 4==2:\n if l == 0: print(1)\nelse:\n if l == 0:\n print(0)\n\"\"\"\n\"\"\"\nfrom math import*\nn,m = map(int,input().split())\nlol = 0\nfor i in range(n):\n\ta = input().split()\n\tlol += a.count(\"1\")\nprint(lol-1)\n\"\"\"\n\"\"\"\nfor t in range(int(input())):\n\tn=int(input())\n\tif (n*(n-4))>=0:\n\t\tsqrt=(n*(n-4))**0.5\n\t\tprint(\"Y\",(n+sqrt)/2,(n-sqrt)/2)\n\telse:\n\t\tprint(\"N\")\n\"\"\"\n\"\"\"\nn= int(input())\nlst = \"\"\nfor i in range(1000):\n\tlst+=str(i)\nprint(lst[n])\n\"\"\"\n\"\"\"\nn =int(input())\ntriangulara = []\nfor i in range(500):\n\ttriangulara.append(i*(i+1)/2)\nif n in triangulara:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nif n % 3 == 0:\n print(n // 3 * 2)\nelif n < 3:\n print(1)\nelse:\n print(n // 3 * 2 + 1)\n\"\"\"\n\"\"\" \nn,k=map(int,input().split())\nz=input()\ns=z.find('G')\ne=z.find('T')\nif(e<s):\n z=z[::-1]\n s=z.find('G')\n e=z.find('T')\nans=0\nwhile s<=e:\n if z[s]=='#':\n print(\"NO\")\n ans=1\n break\n elif z[s]=='T':\n print(\"YES\")\n ans=1\n break\n s+=k\nif ans==0:\n print(\"NO\")\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nif max(a)-25 >= 0:\n\tprint(max(a)-25)\nelse:\n\tprint(0) \n"}, {"source_code": "def solution(l1):\n return max(0,max(l1)-25)\ndef answer():\n n = int(input())\n l1 = [int(x) for x in input().split()]\n print(solution(l1))\nanswer()"}, {"source_code": "input();k=max(map(int,input().split()));print(0 if k<=25 else k-25)"}, {"source_code": "k = int(input())\na = list(map(int,input().split()))\n\nif max(a) > 25:\n\tprint(max(a)-25)\nelse:\n\tprint(0)"}, {"source_code": "def main():\n\tk = int(input())\n\tL = [int(x) for x in input().split()]\n\tprint(solver(k, L))\n\ndef solver(k, L):\n\tL.sort()\n\tlast = L[k - 1]\n\treturn max(last - 25, 0)\n\n\n\t# declined = 0\n\t# index = 0\n\t# for x in range(1, L[k - 1]):\n\t# \tif x != L[index]:\n\t# \t\tif k == 0:\n\t# \t\t\tdeclined += 1\n\t# \t\telse:\n\t# \t\t\tk -= 1\n\t# \telse:\n\t# \t\tindex += 1\n\t# return declined\n\nmain()\n\n#solver(3, [])\n\n\n"}, {"source_code": "from sys import stdin, stdout\nn = int(stdin.readline().strip())\nline = stdin.readline().strip()\narray = line.split(' ')\nmax = 0\nfor x in array:\n c = int(x)\n if(c>max):\n max = c\nif(n<25):\n if(max<=25):\n ans = 0\n else:\n ans = max - 25\nelse:\n ans = max - 25 \n\nstdout.write(str(ans))\n"}, {"source_code": "#!/usr/bin/python2\n# -*- coding: utf-8 -*-\n\nimport sys\n\ndef rl(proc=None):\n if proc is not None:\n return proc(sys.stdin.readline())\n else:\n return sys.stdin.readline().rstrip()\n\ndef srl(proc=None):\n if proc is not None:\n return map(proc, rl().split())\n else:\n return rl().split()\n\ndef main():\n rl()\n print max(0, max(srl(int)) - 25)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin, stderr\n\ndef main():\n N = int(stdin.readline())\n A = map(int, stdin.readline().split())\n M = max(A)\n res = max(M - 25, 0)\n print res\n return 0\n\nif __name__ == '__main__': main()\n"}, {"source_code": "n = int(raw_input())\nx = map(int,raw_input().split())\ncnt,pre = 0,25\nfor i in x:\n if i > pre : \n cnt+=(i-pre)\n pre = i\nprint cnt\n"}, {"source_code": "n=input()\na=map(int,raw_input().split(' '))\ndiff=0\nl=[x for x in a if x>25]\nif len(l)==0:\n print 0\nelse:\n print max(l)-25"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\nprint max(0,max(a)-25)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\na=max(l)\nif a>25:\n print(a-25)\nelse:\n print(0) "}, {"source_code": "n = int(raw_input())\nl = map(int, raw_input().split())\nt = max(l)\n\nif t > 25:\n\tans = t - 25\nelse:\n\tans = 0\n\nprint ans"}, {"source_code": "n=input()\nl=map(int,raw_input().split())\nma=max(l)\nif ma<25:print 0\nelse: print ma-25"}, {"source_code": "K = int(raw_input())\nc = [int(x) for x in raw_input().rstrip().split()]\nc_max = max(c)\nmin_dec = max(c_max - 25, 0)\nprint min_dec\n"}, {"source_code": "K = int(raw_input())\nranks = map(int, raw_input().split())\nminimum = max(ranks) - 25\nif minimum >=0:\n\tprint minimum\nelse:\n\tprint 0"}, {"source_code": "n = int(input())\nL = input().split()\nmx = 0\nfor i in range(n):\n L[i] = int(L[i])\n mx = max(mx, L[i])\nprint(max(0, mx - 25))"}, {"source_code": "kohli = input()\nprint max(max(map(int, raw_input().split())) - 25, 0)"}, {"source_code": "n = input()\narr = map(int,raw_input().strip().split())\nprint max(0,max(arr)-25)"}, {"source_code": "raw_input()\nprint max(max(map(int, raw_input().split())) - 25, 0)\n"}, {"source_code": "k=int(raw_input())\nlis=map(int,raw_input().split())\nma=max(lis)\nif ma-25<=0:\n print 0\nelse:\n print ma-25\n"}, {"source_code": "a=int(input())\nb=list(map(int,input().split()))\nif max(b)<=25:\n\tprint(0)\nelse:\n\tprint(max(b)-25)"}, {"source_code": "n = input()\na = map(int, raw_input().split())\nprint max(0, max(a) - 25)"}, {"source_code": "from __future__ import division, print_function\n\n\ndef main():\n # Template 1.0\n import sys, re, math\n from collections import deque, defaultdict, Counter, OrderedDict\n from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\n from heapq import heappush, heappop, heapify, nlargest, nsmallest\n def STR(): return list(input())\n\n def INT(): return int(input())\n\n def MAP(): return map(int, input().split())\n\n def LIST(): return list(map(int, input().split()))\n\n def list2d(a, b, c): return [[c] * b for i in range(a)]\n\n def sortListWithIndex(listOfTuples, idx): return (sorted(listOfTuples, key=lambda x: x[idx]))\n\n def sortDictWithVal(passedDic):\n temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))\n toret = {}\n for tup in temp:\n toret[tup[0]] = tup[1]\n return toret\n\n def sortDictWithKey(passedDic):\n return dict(OrderedDict(sorted(passedDic.items())))\n\n INF = float('inf')\n mod = 10 ** 9 + 7\n\n k = INT()\n\n r = LIST()\n\n r.sort()\n\n mx = r[-1]\n i = 0\n j = 1\n ans = 0\n\n if(mx<=25):\n print(0)\n else:\n print(mx-25)\n\n\n\n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill();\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Cout implemented in Python\nimport sys\n\n\nclass ostream:\n def __lshift__(self, a):\n sys.stdout.write(str(a))\n return self\n\n\ncout = ostream()\nendl = '\\n'\n\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero=0):\n conv = ord if py2 else lambda x: x\n A = [];\n numb = zero;\n sign = 1;\n i = 0;\n s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0'[0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-'[0]:\n sign = -1\n elif s[i] != b'\\r'[0]:\n A.append(sign * numb)\n numb = zero;\n sign = 1\n i += 1\n except:\n pass\n if s and s[-1] >= b'0'[0]:\n A.append(sign * numb)\n return A\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "'''kurtesy'''\nn = input()\na = map(int,raw_input().split())\nm=max(a)\nif(m<=25):\n print 0\nelse:\n print m-25"}, {"source_code": "n = int(input())\ns = input().split()\ns = list(map(int, s))\ns.sort()\nif(s[n-1]<25):\n print(\"0\")\nelse:\n print(s[n-1]-25)"}, {"source_code": "n=int(raw_input())\nx=max(map(int,raw_input().split()))\nprint max(0,x-25)"}, {"source_code": "n=int(raw_input())\nA=map(int, raw_input().split())\n\ndef mes(n,A):\n a=max(A)\n if a<=25:\n return 0\n else:\n return a-25\n\nprint mes(n,A)"}, {"source_code": "from sys import stdin\nrr = lambda: stdin.readline().strip()\nrri = lambda: int(rr())\nrrm = lambda: map(int, rr().split())\ndef rry(N = None, f = rri):\n for i in xrange(N or rri()):\n yield f()\n\ndebug=0\nif debug:\n fi = open('t.txt','r')\n rr = lambda: fi.readline().replace('\\n','')\n\nN = rri()\nA = rrm()\nBIG = 1000050\nB = [False] * BIG\nfor x in A:\n B[x] = True\n\n#add 25-K people\nto_add = 25-N\nif to_add:\n for x in xrange(1, BIG):\n if not B[x]:\n B[x] = True\n to_add -= 1\n if to_add == 0: break\n\n\ninvited = 0\nans = 0\nfor x in xrange(1, BIG):\n if B[x]:\n invited += 1\n if invited == 25: break\n else:\n ans += 1\nprint ans\n"}, {"source_code": "\nn = int(input())\nl = list(map(int, input().split()))\nmp = max(l)\nif mp < 26:\n\tprint(0)\nelse:\n\tprint(mp - 25)"}, {"source_code": "n = int(input())\nmx = max([int(x) for x in input().split()])\nprint(max(0, mx - 25))\n"}], "negative_code": [{"source_code": "raw_input()\nprint max(map(int, raw_input().split())) - 25\n"}, {"source_code": "'''kurtesy'''\nn = input()\na = map(int,raw_input().split())\nm=max(a)\nprint m-25"}, {"source_code": "k = int(raw_input())\nranklist = map(int,raw_input().split())\nmaxrank = max(ranklist)\n\t\nif maxrank >= k:\n\tprint maxrank - k\nelse:\n\tprint 0\n"}, {"source_code": "k = int(raw_input())\nranklist = map(int,raw_input().split())\nmaxrank = max(ranklist)\n\t\nif maxrank >= k:\n\tprint maxrank - 25\nelse:\n\tprint 0\n"}, {"source_code": "k, r = int(input()), list(map(int, input().split()))\n\nprint(min(0, max(r) - 25))"}, {"source_code": "import math\nfrom fractions import Fraction as frac\n\nMOD = 1e9 + 7\n\ndef solve(case_no):\n n = int(input())\n a = list(map(int, input().split()))\n a = sorted(a)\n print(a[n - 1] - 25)\n\n\nt = 1\n# t = int(input())\nfor i in range(1, t + 1):\n solve(i)\n"}, {"source_code": "import math\nfrom fractions import Fraction as frac\n\nMOD = 1e9 + 7\n\ndef solve(case_no):\n n = int(input())\n a = list(map(int, input().split()))\n print(a[n - 1] - 25)\n\n\nt = 1\n# t = int(input())\nfor i in range(1, t + 1):\n solve(i)\n"}, {"source_code": "k=int(input())\na=list(map(int,input().split()))\nm=max(a)\ncount=0\nif(m>25):\n for i in range(1,m+1):\n if i not in a:\n count+=1\n print(count)\nelse:\n print(count)"}, {"source_code": "n=int(input())\na=sorted(list(map(int,input().split())))\nif a[-1]<=25:\n print(0)\nelse:\n print(abs(a[0]-25))"}, {"source_code": "n = int(input())\na = [int(s) for s in input().split(' ')]\nprint(max(a) - 25)"}, {"source_code": "input()\nprint(max(map(int,input().split()))-25)"}, {"source_code": "def declined(known, ranks):\n known = int(known)\n if known >= 25:\n prev = 0\n declined = 0\n for rank in ranks:\n rank = int(rank)\n diff = rank - prev\n if diff > 1:\n declined += diff - 1\n prev = rank\n\n return declined\n\n prev = 25\n declined = 0\n l25 = True\n for rank in ranks:\n rank = int(rank)\n if rank > 25:\n l25 = False\n declined += rank - prev\n prev = rank\n\n if l25:\n return 0\n\n return declined\n\nk = input()\nr = input().strip().split(' ')\nprint(declined(k, r))\n"}, {"source_code": "k=int(input())\na=list(map(int, input().split()))\na.sort()\nw=0\nt=0\nfor i in range(k-1,0,-1):\n if a[i]>25 and a[i-1]>25:\n t+=a[i]-a[i-1]-1\n w+=1\n elif a[i]>25 and a[i-1]<=25:\n t+=a[i]-26\n w+=1\n\nprint(t+w)\n"}, {"source_code": "k=int(input())\na=list(map(int, input().split()))\nt=0\nfor i in range(k-1,-1,-1):\n if a[i]>25:\n t+=1\n\nprint(max(a)+t-25)"}, {"source_code": "k=int(input())\na=list(map(int, input().split()))\nt=0\nfor i in range(k-1,-1,-1):\n if a[i]>25:\n t+=1\n\nprint(max(a)-t-25)"}, {"source_code": "k=int(input())\na=list(map(int, input().split()))\na.sort()\nw=0\nt=0\nif k==1:\n if a[0]>25:\n t+=a[0]-25\nfor i in range(k-1,0,-1):\n if a[i]>25 and a[i-1]>25:\n t+=a[i]-a[i-1]-1\n w+=1\n elif a[i]>25 and a[i-1]<=25:\n t+=a[i]-26\n w+=1\n\nprint(t+w)\n"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\n\nprint(max(s)-25)"}, {"source_code": "if __name__ ==\"__main__\":\t\n\tn = int(input())\n\tarr = list(map(int,input().split()))\n\tif max(arr)<=25:\n\t\tprint(0)\n\telse:\n\t\tif 1 not in arr:\n\t\t\tarr.append(0)\n\t\t\tn+=1\n\t\tans = 0\n\t\tarr.sort()\n\t\tfor i in range(1,n):\n\t\t\tans += (arr[i]-arr[i-1]-1)\n\t\tprint(ans-(25-n))"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nm=max(l)\nif(m<26):\n print(0)\nelse: \n print(max(l)-n)\n"}, {"source_code": "input()\nprint(max(map(int, input().split())) - 25)"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nCnt = 0\ni = 1\nRes = 0\na = []\nfor k in range(len(s)):\n a.append(s[k])\ns.sort()\n\nif s == a:\n while Cnt < n:\n if i in a:\n Cnt += 1\n else:\n Res += 1\n i += 1 \n print(Res)\nelse:\n print(0)"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nCnt = 0\ni = 1\nRes = 0\n\nwhile Cnt < n:\n if i in s:\n Cnt += 1\n else:\n Res += 1\n i += 1\n \nprint(Res)"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nCnt = 0\ni = 1\nRes = 0\n\na = s.sort()\nif s == a:\n while Cnt < n:\n if i in s:\n Cnt += 1\n else:\n Res += 1\n i += 1 \n print(Res)\nelse:\n print(0)"}, {"source_code": "import sys\nnumberKnown = sys.stdin.readline()\nrankings = sys.stdin.readline()\n\nKnown = int( numberKnown ) \nranksplit = rankings.split()\n\nmaxrank = 0\n\nfor i in range( 0 , len(ranksplit) ):\n rank = int(ranksplit[i])\n if maxrank < rank:\n maxrank = rank\nnumberDeclined = maxrank - 25\n\nprint( numberDeclined )\n\n\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nK=int(input())\nr=[int(x) for x in input().split()]\nprint(max(r)-25)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nK=int(input())\nr=[int(x) for x in input().split()]\nans=0\nfor a in range(1,max(r)+1):\n if a not in r:\n ans+=1\nprint(ans)\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split())) \nprint(max(l)-25)\n\n"}, {"source_code": "n = int(input())\ncnt = 0\nfor i in input().split():\n if int(i) > 25:\n cnt += 1\nprint(cnt)\n\n"}, {"source_code": "n=int(input())\ny=0\ni=4\nif(n==0):print(0)\nelif(n==1):print(2)\nelif(n==2):print(4)\nelif(n==3):print(6)\nelse:\n while(i<10000):\n if(n>=i and n<=2*i):\n x=2*(n-y)\n break\n y=y+i\n i=i*2\n print(x)\n"}, {"source_code": "n=int(input())\nx=input().split()\nif(int(x[-1])-25>=0):print(int(x[-1])-25)\nelse:print('0')"}, {"source_code": "n=int(input())\nif(n==0):print(0)\nelse:\n x=input().split()\n if(int(x[-1])-25>=0):print(int(x[-1])-25)\n else:print(0)"}, {"source_code": "\"\"\"\n\n\n\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2551\u255a\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2588\u2588\u2551\n\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\n\u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u255d\n __ __ _ \n| \\/ (_)_ __ ___ _ __ \n| |\\/| | | '__/ _ \\| '_ \\ \n| | | | | | | (_) | | | | \n|_| |_|_|_| \\___/|_| |_| \n\"\"\"\n\"\"\"\n \u041a\u0440\u0430\u0441\u0438\u0432\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u043e\u0435.\n \u042f\u0432\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043d\u0435\u044f\u0432\u043d\u043e\u0435.\n \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0435.\n \u0421\u043b\u043e\u0436\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0435.\n \u041f\u043b\u043e\u0441\u043a\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435.\n \u0420\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043f\u043b\u043e\u0442\u043d\u043e\u0435.\n \u0427\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.\n \u041e\u0441\u043e\u0431\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043e\u0431\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430.\n \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u0435\u0435 \u0431\u0435\u0437\u0443\u043f\u0440\u0435\u0447\u043d\u043e\u0441\u0442\u0438.\n \u041e\u0448\u0438\u0431\u043a\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043c\u0430\u043b\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f.\n \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u0437\u0430\u043c\u0430\u043b\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u044f\u0432\u043d\u043e.\n \u0412\u0441\u0442\u0440\u0435\u0442\u0438\u0432 \u0434\u0432\u0443\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u0442\u0431\u0440\u043e\u0441\u044c \u0438\u0441\u043a\u0443\u0448\u0435\u043d\u0438\u0435 \u0443\u0433\u0430\u0434\u0430\u0442\u044c.\n \u0414\u043e\u043b\u0436\u0435\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438, \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e.\n \u0425\u043e\u0442\u044f \u043e\u043d \u043f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0433\u043e\u043b\u043b\u0430\u043d\u0434\u0435\u0446 [^1].\n \u0421\u0435\u0439\u0447\u0430\u0441 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043d\u0438\u043a\u043e\u0433\u0434\u0430.\n \u0425\u043e\u0442\u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441.\n \u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u2014 \u0438\u0434\u0435\u044f \u043f\u043b\u043e\u0445\u0430.\n \u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u2014 \u0438\u0434\u0435\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0445\u043e\u0440\u043e\u0448\u0430.\n \u041f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430! \u0411\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435!\n\"\"\"\n\"\"\"\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2593\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2592\u2592\u2593\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2593\u2592\u2592\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2592\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2592\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2588\u2588\u2591\u2592\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\n\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2593\u2593\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2593\u2593\u2592\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\n\u2591\u2593\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2592\u2591\n\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\n\u2588\u2588\u2593\u2592\u2593\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2593\u2593\u2588\u2588\u2588\n\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2593\u2593\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2588\u2592\u2588\u2588\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2592\u2592\u2588\u2593\u2588\u2591\u2588\u2588\u2588\u2593\u2593\u2592\u2592\u2592\u2593\u2592\u2592\u2593\u2593\u2593\u2588\u2588\u2588\u2592\u2588\u2588\u2588\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2592\u2593\u2588\u2592\u2592\u2588\u2591\u2588\u2592\u2588\u2591\u2588\u2591\u2588\u2593\u2588\u2592\u2588\u2593\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2588\u2588\u2593\u2588\u2593\u2588\u2593\u2588\u2592\u2588\u2592\u2588\u2593\u2588\u2593\u2588\u2588\u2588\u2588\u2591\u2593\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2591\u2593\u2588\u2593\u2588\u2591\u2588\u2592\u2588\u2591\u2588\u2591\u2588\u2592\u2588\u2592\u2588\u2588\u2588\u2592\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2588\u2593\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2588\u2588\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2593\u2592\u2591\u2591\u2592\u2588\u2588\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2593\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2593\u2588\u2588\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2592\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2588\u2592\u2593\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\n\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u258c\u2591\u2591\u2591\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u258c\u2591\u2591\u2591\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u258c\u2591\u2591\u2591\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2584\u2588\u2588\u2588\u2588\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2580\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\n\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@#@@#@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@M@M # #@@@M@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@#@@ @@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@### #@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@B@@#@@@@@#M@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@##@@M@#@@##@##@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#M@@@@@##@M@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@@@@@@#@##@#@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ #\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ #\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@ @@#@@#@@@@@@@@@@@@@@@@@#@@#@#@@@@@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@\n @ #@@@@@@@@@@@@@@@@@@@@#@@@@@@#@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@ @@#@#@@@@@@@@@@@@@@@@@@#@####@@@@@@@@@@@@@@@@@M@#@@#@#@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@#@#M@@@M@@@@@@@@@@@@@@@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n#@M@#@#@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@M@@M@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@@#@@@@@@@@@@@@@@@@@@@@M@M@#@@@@@@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@\n@@#@@#@@@@@@@@@@@@@@@@@@@@@@@M@ @M@@#@@@@@@@@@@@@@@@@@@@@@@@@@\n@#@@@@@#@@@@@@@@@@@@@@@@@@@#@@ @@@@M@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@@@##@@@#@@@@@#@@@@@##@@@@ #@#@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@####@@####@@@@#@@@@M@@@#@@# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@#@ @#@@#@@@ #@ @ #@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @# @@#@@ #@@#@@@@@@@@@@@@@@@@@@@@@@@@@\n ##@#@@ #M @# @@ @@M @@@@@@@@@@@@@@@@@@@@@@@@\n @#@@@M #@ #@ # @@ @@@@@@@@@@@@@@@@@@@@@@@@\n @@ @@#@@ ## @##@@ @@@@@@@@@@@@@@@@@@@@@@@@\n @# @@M@ @@ @@@@@@@@@@@@@@@@@@@@@@@@\n @@@##@@@ @@@@ @@@ @@ #@#@@#@@@@@@@@@@@@@@@@@\n@@@@###@@###@@@@#@#@@@@#@@@ M@ #@ @ B @@@#@@@@@@@@@@@@@@@@@@@\n@M@@@@@MM@@@@@M@@#@##@@@#@@M@B @# M@ @# #@ #@@#@@@@@@@@@@@@@@@@@@@\n@#@#@@M@@M@@#@#@#@#@@#@#@#@@@@ @# @@ # @M @#@@@@@@@@@@@@@@@@@@@@@\n@@@ @@@@#@##@ #@# @M # @ @ @@@@@#@@@@@@@@@@@@@@@@@\n @@ @@ @#@@#@@#M #@@@@#@@@@@@@@@@@@@@@@@\n M@# #@ @@@@##@@ @M@#M@@@#@@@@@@@@@@@@@@@@\n @@@@ @@ @@@#@@@#@#@@@@@@@@@@@@@@@@\n @# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @M@H@@ @# @#@@@@#@@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@#@#@##@M@@@M@ @M#@@@@@#@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n#M@@@##@@@@@@@@M@@@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@#@@@@@M@#@M@@B#M@@M@###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n###@@@@@@@@@# @#@@@@@@@#@@@#@##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@#@@M@@@#@@#@#@@@@@@#@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@M@#@# \n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@#\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@##\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@M\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n\"\"\"\n\"\"\"\n / \\ //\\\n |\\___/| / \\// \\\\\n /0 0 \\__ / // | \\ \\ \n / / \\/_/ // | \\ \\ \n @_^_@'/ \\/_ // | \\ \\ \n //_^_/ \\/_ // | \\ \\\n ( //) | \\/// | \\ \\\n ( / /) _|_ / ) // | \\ _\\\n ( // /) '/,_ _ _/ ( ; -. | _ _\\.-~ .-~~~^-.\n (( / / )) ,-{ _ `-.|.-~-. .~ `.\n (( // / )) '/\\ / ~-. _ .-~ .-~^-. \\\n (( /// )) `. { } / \\ \\\n (( / )) .----~-.\\ \\-' .~ \\ `. \\^-.\n ///.----..> \\ _ -~ `. ^-` ^-_\n ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~\n /.-~\n\n\"\"\"\n\"\"\"\n ____ _ _____ \n / ___|___ __| | ___| ___|__ _ __ ___ ___ ___ \n| | / _ \\ / _` |/ _ \\ |_ / _ \\| '__/ __/ _ \\/ __|\n| |__| (_) | (_| | __/ _| (_) | | | (_| __/\\__ \\\n \\____\\___/ \\__,_|\\___|_| \\___/|_| \\___\\___||___/\n\"\"\"\n\"\"\"\n\u2591\u2591\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\n\u2591\u2584\u2580\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2588\u2591\n\u2591\u2588\u2591\u2584\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2584\u2591\u2588\u2591\n\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2591\n\u2591\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2591\n\u2584\u2588\u2580\u2588\u2580\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2580\u2580\u2588\u2588\u2588\n\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\n\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2588\u2588\n\u2588\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\u2588\n\u2591\u2580\u2588\u2588\u2588\u2584\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2584\u2588\u2588\u2588\u2580\u2591\n\u2591\u2591\u2591\u2580\u2588\u2588\u2584\u2591\u2580\u2588\u2588\u2580\u2591\u2584\u2588\u2588\u2580\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\"\"\"\nn = int(input())\nos=0\nch=[]\nfor i in range(n):\n\tm = int(input())\n\tch.append(m)\t\n\tif ch[0]==10:\t\t\n\t\tif 1 in ch:\n\t\t\tprint((len( ch[:ch.index(1)])))\n\t\t\tbreak\n\telse:\n\t\tif 10 in ch:\n\t\t\tprint((len( ch[:ch.index(10)])))\n\t\t\tbreak\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\nm = float(m)\nmi = []\nfor i in range(n):\n\ta,b = map(float,input().split())\n\tmi.append((a*m)/b)\nprint(round(min(mi),6))\n\"\"\"\n\"\"\"\nl = input().split()\nl = set(l)\nprint(len(l))\n\n\"\"\"\n\"\"\"\t\nx = input()\ny = x[1:-1]\nz = set(y.split(', '))\nif x == \"{}\":\n\tprint(0)\nelse:\n\tprint(len(z))\n\"\"\"\n\"\"\"\nn,k = map(int,input().split())\nL = sorted(map(int, input().split()))\nres = [L[0]]\nfor i in range(1,n):\n if L[i] != L[i-1]:\n res.append(L[i]-L[i-1])\nl = len(res)\nif k > l:\n res += [0]*(k-l)\nfor i in range(k):\n print(res[i])\n\n\"\"\"\t\n\"\"\"\nfrom math import*\ns,k = map(int,input().split(\" \"))\nsq = input().split()\nscore = 0\npol = \"\"\nfor i in range(len(sq)):\n\tif sq[i]>=sq[i-1]:\n\t\tscore+=1\nprint(ceil(score/len(sq))+ceil(score/len(sq)))\n\"\"\"\n\"\"\"\nfrom math import*\ns,k = map(int,input().split(\" \"))\nsq = input().split()\nscore = 0\npol = \"\"\nfor i in range(len(sq)):\n\tif sq[i]>=sq[i-1]:\n\t\tscore+=1\nprint(ceil(score/len(sq))+ceil(score/len(sq)))\n\"\"\"\n\"\"\"\nst=list(input().split('+'))\nst.sort()\nfor i in range(len(st)):\n if i!=len(st)-1:\n print(str(st[i])+'+',end='')\n else:\n print(str(st[i]))\n\"\"\"\n\"\"\"\na = input()\nup = a.upper()\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nprint(abc[abc.find(up[0])]+a[1::])\n\"\"\"\n\"\"\"\n\nn= int(input())\nk = 0\nfor i in range(n):\n\tp = input()\n\tif p == \"++X\" or p == \"X++\":\n\t\tk+=1\n\telif p == \"--X\" or p == \"X--\":\n\t\tk-=1\nprint(k)\n\n\"\"\"\n\"\"\"\nimport math \n\nc = 1 \n\nl = int(input()) \n\ng = \"\" \n\nfor i in range(l): \n\n for s in range(1,l - i + 1): \n\n g = g + \" \" \n for j in range(0,i + 1): \n if(i == 0 or j == 0): \n c = 1 \n else: \n c = c * (i - j + 1)/j \n\n t = c \n T=0 \n while(t != 0): \n T = T + 1 \n t = int(math.floor(t/10)) \n p=0 \n while((p+T)!=4): \n g = g + \" \" \n p=p+1 \n g = g + str(int(math.floor(c))) \n g = g + \"\\n\" \nprint(g)\n\"\"\"\t\n\"\"\"\n ___ __ _ _ \n|_ _|_ __ / _| ___ _ __ _ __ ___ __ _| |_(_) ___ ___ \n | || '_ \\| |_ / _ \\| '__| '_ ` _ \\ / _` | __| |/ __/ __|\n | || | | | _| (_) | | | | | | | | (_| | |_| | (__\\__ \\\n|___|_| |_|_| \\___/|_| |_| |_| |_|\\__,_|\\__|_|\\___|___/ \n\"\"\"\n\"\"\" \nfrom math import*\na1 = float(input())\na2 = float(input())\nb = sqrt(a1**2 + a2**2)\nprint(b)\n\"\"\" \n\"\"\"\na1 = float(input())\na2 = float(input())\nb = (a1**2 + a2**2)\nimport math\nl = math.sqrt(b)\nprint(l)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if i%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if a[i]%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if a[i]>0:\n b.append(a[i])\nprint(len(b))\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(1,n):\n if a[i]>a[i-1]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(1,n):\n if a[i]>a[i-1]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(n-1):\n if i == 0:\n pass\n elif a[i]>a[i-1]and a[i+1]< a[i]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\na.reverse()\nfor i in a:\n print(i,end = \" \")\n\"\"\"\n\"\"\"\nn = int(input())\na=list(map(int,input().split(\" \")))\nprint(max(a))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split(\" \")))\nl = 0\nq = []\nfor i in range(len(a)):\n if a[i] in q:\n pass\n else:\n l +=1\n q.append(a[i])\nprint(l)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nx = int(input())\nk =1\nfor i in range(len(a)):\n k+=1\n if x > a[i]:\n print(i+1)\n exit()\nprint(k)\n\"\"\"\n\"\"\"\na=list(map(int,input().split(\" \")))\nb = []\nfor i in range(len(a)):\n if i%2==0:\n print(a[i],end=' ')\n\"\"\"\n\"\"\"\na=list(map(int,input().split(\" \")))\nb = 0\nfor i in range(len(a)-1):\n if i == 0:\n pass\n elif a[i]>a[i-1]and a[i+1]< a[i]:\n b+=1\nprint(b)\n\"\"\"\n\"\"\"\na = list(map(int,input().split()))\nprint(max(a),a.index(max(a)))\n\"\"\"\n\"\"\"\nch = list(input()) \nif ch.count(\"h\")>=1 and ch.count(\"e\")>=1 and ch.count(\"l\")>=2 and ch.count(\"o\")>=1 and len(ch)!=53:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom decimal import Decimal\nx,y = map(Decimal,input().split(\" \"))\nd = 1\nwhile x < y and x - y < 0.000001 :\n x += x * 70 / 100\n d += 1\nprint(d)\n\"\"\"\n\"\"\"\nn = int(input())\nabc = \"abcdefghijklmnopqrstuvwxyz\"\ns =\"\"\nfor i in range(n):\n\tk,v = map(int,input().split())\n\tfor i in range(k):\n\t\twhile len(s) <= k:\n\t\t\ts += abc[:v]\n\t\tif len(s)>k:\n\t\t\ts = s[:-(len(s)-k)]\n\tprint(s,end=\"\\n\")\n\ts=\"\"\t\t\n\"\"\"\n\"\"\"\nk = int(input())\nl = int(input())\nm = int(input())\nn = int(input())\nd = int(input())\nlst = []\nlst.append(k)\nlst.append(l)\nlst.append(m)\nlst.append(n)\nuron = 0\nfor i in range(len(lst)):\n\tif d % lst[i] == 0:\n\t\turon+=lst[i]\nprint(uron)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nch = 0\nnch = 0\nfor i in range(len(a)):\n\tif a[i] % 2 == 0:\n\t\tch+=1\n\telse:\n\t\tnch+=1\nif ch > nch:\n\tfor i in range(len(a)):\n\t\tif a[i] % 2 == 1:\n\t\t\tprint(a.index(a[i])+1)\nelse:\n\tfor i in range(len(a)):\n\t\tif a[i]%2==0:\n\t\t\tprint(a.index(a[i])+1)\n\"\"\"\n\"\"\"\nn,t = map(int,input().split())\noc = input()\nfor i in range (1,n):\n\tif oc[i]==\"B\":\n\t\toc[i]=oc[i-1]\nprint(oc)\t\t\t\n\"\"\"\n\"\"\"\nn = int(input())\no = 0\nfor i in range(n):\n\to += ((n-2) - (n % 2))//2\nprint(o)\n\"\"\"\n\"\"\"\nsl = input()\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nm=0\nb=0\nbig = \"\"\nfor i in range(len(sl)):\n\tif sl[i]== abc[abc.find(sl[i])]:\n\t\t\tb+=1\n\telse:\n\t\t\tm +=1\nif m>b:\n\tbig += sl.lower()\n\tprint(big)\nelif b>m:\n\tbig += sl.upper()\n\tprint(big)\nelif b==m:\n\tbig += sl.lower()\n\tprint(big)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(n):\n\tprint(a.index(i+1)+1, end=' ')\n\"\"\"\n\"\"\"\nn = int(input())\nif n % 2 == 0 and n != 2 :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\na = input().replace(\"WUB\",\" \")\nprint(a)\n\"\"\"\n\"\"\"\na = int(input())\nb = list(map(int,input().split()))\nb.sort()\nfor i in b:\n\tprint(i,end=\" \")\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\no = 0\nif a % 2 == 0:\n\to = a//2\nelse:\n\to = (a//2)+1\nif b <= o:\n\tprint((1+((o-1)*2)))\nelse:\n\tprint(((o-1)*2))\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nyear = 0\nwhile b>=a:\n\ta*=3\n\tb*=2\n\tyear+=1\nprint(year)\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\nm = float(m)\nmi = []\nfor i in range(n):\n\ta,b = map(float,input().split())\n\tmi.append((a*m)/b)\nprint(min(mi))\n\"\"\"\n\"\"\"\nn = int(input())\nx = 0\nfor i in range(n):\n\ta = input()\n\tif a == \"Tetrahedron\":\n\t\tx+=4\n\telif a == \"Cube\":\n\t\tx+=6\n\telif a == \"Octahedron\":\n\t\tx+=8\n\telif a == \"Dodecahedron\":\n\t\tx+=12\n\telif a == \"Icosahedron\":\n\t\tx+=20\nprint(x)\n\"\"\"\n\"\"\"\nn= int(input())\na = list(map(int,input().split()))\nfor i in a:\n\tif sum(a)>0:\n\t\tprint(\"HARD\")\n\t\tbreak\n\telse:\n\t\tprint(\"EASY\")\n\t\tbreak\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nc = list(map(int,input().split()))\nbal = 0\nfor i in range(1,len(c)+1):\n\tif b == len(c):\n\t\tif c[i]>=c[b-1]:\n\t\t\tbal +=1\n\telse:\n\t\t\n\t\tif c[i]>=c[b] and c[i]!= 0:\n\t\t\tbal+=1\nprint(bal)\n\"\"\"\n\"\"\"\na,b =map(int, input().split())\ny=list(map(int,input().split()))\nfor i in y:\n if i<y[b-1] or i==0:\n a-=1 \nprint(a)\n\"\"\"\n\"\"\"\na,b=map(int,input().split())\nc=b-(a+1)//2\nif c > 0:\n\tprint(2*c)\nelse:\n\tprint(2*b-1)\n\"\"\"\n\"\"\"\na = input()\nb = input()\na1 = a.lower()\nb1 = b.lower()\no = 0\nk = 0\nif a1>b1:\n\to+=1\nif b1>a1:\n\tk+=1\nprint(o-k)\n\"\"\"\n\"\"\"\nn=int(input())\np=input().split()\nq=input().split()\nm = p[1:]\nj = q[1:]\nif len(set(m+j))==n:\n print(\"I become the guy.\")\nelse:\n print(\"Oh, my keyboard!\")\n\"\"\"\n\"\"\"\na = set(input())\nfor i in range(len(a)):\n\ta.remove()\n\tif a == \"hello\":\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\na = n.count(4)+n.count(7)\nif a == 7 or a == 4:\n\t\tprint(\"YES\")\n\t\t\nelse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\t\nn = int(input())\nb = input()\nb = b.upper\nabc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nfor i in range(len(b)):\n\tif abc[i] in b:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn,a,b = list(map(int,input().split()))\npos = 0\nfor i in range(n):\n\tif (a + b) % 2 == 0:\n\t\tprint(a+b)\n\t\tbreak\n\telse:\n\t\tprint(ceil((a+b)/2))\n\t\tbreak\n\"\"\"\n\"\"\"\nn = int(input())\nans = 0\nfor i in range(n):\n\ta,b,c = map(str,input().split())\n\tb = int(b)\n\tfor i in range(n):\n\t\tif b == -b and c == \"YES\":\n\t\t\tprint(\"Impossible\")\n\t\telif ans > b and c == \"Y\":\n\t\t\tans += 1\n\t\telif ans < b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans >= b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans <= b and c == \"Y\":\n\t\t\tans+=1\n\t\telif ans > b and c == \"N\":\n\t\t\tbreak\n\t\telif ans < b and c == \"N\":\n\t\t break\n\t\telif ans >= b and c == \"N\":\n\t\t\tbreak\n\t\telif ans <= b and c == \"N\":\n\t\t\tbreak\nprint(ans)\t\t\n\"\"\"\n\"\"\"\nfrom math import*\nn,k = map(int,input().split())\na = list(map(int,input().split()))\ncom = 0\nfor i in range(len(a)):\n\tif a[i]+2 <= 5:\n\t\tcom += 0.333\nprint(ceil(com))\n\"\"\"\n\"\"\"\nn,a,b = map(int,input().split())\nd = []\ns = 0\nk = 1\nfor i in range(n-1):\n\tif a == 0 and b == 0:\n\t\tprint(n)\n\t\texit()\n\td.append(\"*\"*((a+i)) +\"+\"+\"*\"*(((b-i)-k)))\n\tif len(d[i])<=n:\n\t\ts+=1\nprint(s)\n\"\"\"\n\"\"\"\nn,h =map(int, input().split())\nfor i in map(int, input().split()):\n if i > h:\n n+=1\nprint(n)\t\n\"\"\"\n\"\"\"\nn = input()\na = input()\nif a.count('A')> a.count('D'):\n\tprint('Anton')\nelif a.count('A')<a.count('D'):\n\tprint('Danik')\nelse:\n\tprint('Friendship')\n\"\"\"\n\"\"\"\nn = int(input())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\ng = list(map(sum,a))\ncount=0\ni=0\nfor j in g:\n if j >=2:\n count+=1\nprint(count)\n\"\"\"\n\"\"\"\nn=int(input())\nx=input()\nc=0\nfor i in range(n-1):\n if x[i] == x[i+1]:\n c+=1\nprint(c)\n\"\"\"\n\"\"\"\nk = list(map(int,input().split()))\nt = input()\nkal = 0\nfor i in range(len(t)):\n\tif t[i]==\"1\":kal += k[0]\n\telif t[i]==\"2\":kal += k[1]\n\telif t[i]==\"3\":kal += k[2]\n\telif t[i] == \"4\":kal += k[3]\nprint(kal)\n\"\"\"\n\"\"\"\norient = input()\nkey = input()\nkeyboard = \"poiuytrewq;lkjhgfdsa/.,mnbvcxz\"\nans = \"\"\nfor i in range(len(key)):\n\tif orient == \"R\":\n\t\tans += keyboard[keyboard.find(key[i])+1]\n\telif orient == \"L\":\n\t\tans += keyboard[keyboard.find(key[i])-1]\nprint(ans)\n\"\"\"\n\"\"\"\nn,k = map(int, input().split())\nabc = \"abcdefghijklmnopqrstuvwxyz\"\nf = abc[:k]\ns = f \nwhile len(s) < n:\n s += f\ns = s[:n]\nprint(s)\n\"\"\"\n\"\"\"\nn = int(input())\nif n %2 == 0 or n == 2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nmas = 0\nwhile 1:\n\ttry:\n\t\ta = input()\n\t\tif \":\" in a:\n\t\tmas += len(a[a.find(\":\"):])\n\texcept EOFError:\nprint(mas)\n\"\"\"\n\"\"\"\na = input()\nb = input()\nc = str(int(a)+int(b))\nif int(a.replace(\"0\",\"\"))+int(b.replace(\"0\",\"\"))== int(c.replace(\"0\",\"\")):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\ns = input()\nw = len(s)\nn=int(input())\nb=[]\nfor i in range(n):\n wd=input()\n if wd[:w]==s:\n b.append(wd)\nb.sort()\nif len(b)==0:\n print(s)\nelse:\n print(min(b))\n\"\"\"\n\"\"\"\nn = int(input())\nans = 0\nfor i in range(n):\n\tx,a = map(int,input().split())\n\tif x == -x and a:\n\t\tans += a \n\telse:\n\t\tans+=a\nprint(ans)\n\"\"\"\n\"\"\"\nfrom decimal import Decimal\nn,m = map(int,input().split())\nfst = []\nscd = []\na=0\nfor i in range(1,n+1):\n\tfor j in range(1,m+1):\n\t\tif (i+j)%5==0:\n\t\t\ta+=1\nprint(a)\n\"\"\"\n\"\"\"\nn,a = map(int,input().split())\nans = \"\"\nfor i in range(n):\n\tb = list(map(str,input().split()))\n\tfor j in range(a):\n\t\tif b[j] != \"B\" or b[j]!=\"W\"or b[j]!=\"G\":\n\t\t\tans += \"#Color\"\n\t\t\tbreak\n\t\t\t\n\t\telse:\n\t\t\tans += \"#Black&White\"\n\t\t\tbreak\nprint(ans)\n\"\"\"\n\"\"\"\nn=int(input())\nnum=0\na , b =[],[]\nfor i in range(n):\n c=input().split()\n a.append(c[0])\n b.append(c[1])\nfor i in a:\n num+=b.count(i)\nprint(num)\n\"\"\"\n\"\"\"\nn = int(input())\nb = input()\na = b.lower()\n\nif a.count(\"a\")>=1 and a.count(\"b\")>=1 and a.count(\"c\")>=1 and a.count(\"d\")>=1 and a.count(\"e\")>=1 and a.count(\"f\")>=1 and a.count(\"g\")>=1 and a.count(\"h\")>=1 and a.count(\"i\")>=1 and a.count(\"j\")>=1 and a.count(\"k\")>=1 and a.count(\"l\")>=1 and a.count(\"m\")>=1 and a.count(\"n\")>=1 and a.count(\"o\")>=1 and a.count(\"p\")>=1 and a.count(\"q\")>=1 and a.count(\"r\")>=1 and a.count(\"s\")>=1 and a.count(\"t\")>=1 and a.count(\"u\")>=1 and a.count(\"v\")>=1 and a.count(\"w\")>=1 and a.count(\"x\")>=1 and a.count(\"y\")>=1 and a.count(\"z\")>=1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\ndig = []\nfor i in range(1,n+1):\n\tif factorial(i-1) % i != i-1:\n\t\tdig.append(i)\nfor j in range(1,len(dig)+1):\t\n\tif dig[j] + dig[j-n%2-4] == n or dig[j] + dig[j-n%2-9] == n:\n\t\tprint(dig[j],dig[j-n%2-4])\n\"\"\"\n\"\"\"\na=input()\nb=input()\ns=input()\nc=a+b\nd=list(s)\ne=list(c)\nd.sort()\ne.sort()\nif d==e:\n print('YES')\nelse:\n print('NO')\n\"\"\"\n\"\"\"\n def nextmiron(s):\n s += '#'\n cnt = 1\n ret = \"\"\n for i in range(1, len(s)):\n if s[i] == s[i - 1]:\n cnt += 1\n else:\n ret += str(cnt) + s[i - 1];\n cnt = 1\n return ret\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\nfor i in range(len(n)):\n\tif n[i] > 0:\n\t\tprint(n[i],end=\"\")\n\t\texit()\n\telif n[i]>n[i-1]:\n\t\tn.remove(n[i])\nfor i in n:\n\tprint(n[i],end=\"\")\n\"\"\"\n\"\"\"\nn = list(map(int,input()))\na = 0\nans = 0\nfor i in range(len(n)):\n\t\ta += n[i]+n[i-1]\n\t\tans += 1\n\t\tif a in n:\n\t\t\tbreak\nprint(ans+1)\n\"\"\"\n\"\"\"\nfrom math import factorial as fal\na,b = map(int,input().split())\nans = 0\np = []\nprime = []\nfor i in range(a,b+1):\n\tif fal(i-1) % i == i-1:\n\t\tp.append(i)\nfor i in range(len(p)):\n\tif fal((int(str(p[i])[::-1]))-1)% int(str(p[i])[::-1]) == int(str(p[i])[::-1])-1: \n\t\tans += 1\nprint(ans)\n\"\"\"\n\"\"\"\na,b,c = map(int,input().split())\nd = str(a/b)\nif len(d)==3:\n\tprint(d+\"0\"*(c-1))\nelse:\n\tprint(round((a/b),c))\n\"\"\"\n\"\"\"\na = list(input())\nn = 0\nh = 'hello'\nfor i in range(len(a)):\n if a[i] == h[n]:\n n += 1\n if n >= 5:\n break\nif n >= 5: \n\tprint('YES')\nelse: \n\tprint('NO')\n\"\"\"\n\"\"\"\nfrom math import factorial as fal\na,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1): \n\tif fal(i-1) % i == i-1 and fal((int(str(i)[::-1]))-1) % int(str(i)[::-1]) == int(str(i)[::-1])-1:\n ans += 1 \nif a == 1:\n\tprint(ans - 1)\n\texit()\nprint(ans)\n\"\"\"\n\"\"\"\nl=list(map(int,input().split(' ')))\nn,v=l[0],l[1:]\ndp=[1]*(n+1)\ninf=2**64\nfor i in range(n+1):\n\tif i not in v:\tdp[i]=-inf\nfor i in range(n+1):\n\tfor j in v:\n\t\tif i>j:\n\t\t\tdp[i]=max(dp[i],dp[j]+dp[i-j])\nprint(dp[n])\n\"\"\"\n\"\"\"\np = list(map(int,input().split()))\nq = set(p)\ns = 0\nfor i in q:\n s += p.count(i)-1\nprint(s)\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nh = []\nl = []\nfor i in range(b):\n c = list(map(int,input().split()))\n h.append(c)\nh.sort()\nfor i in h:\n if a > i[0]:\n l.append(1)\n a += i[1]\n \nif len(l) == b:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn,m=map(int,input().split())\nans=0\nfor i in range(1,n+1):\n\tans += int((i+m)/5)-int(i/5)\nprint(ans)\n\"\"\"\n\"\"\"\na = input()\nif a[0]==\"-\":\n\tprint((a[0])+a[1],a[2])\nelse:\t\n\tprint(int(a[0]),int(a[1]))\n\"\"\"\n\"\"\"\nfrom math import factorial as myfunct\na,b = map(int,input().split())\nc = min(a,b)\nprint(myfunct(c))\n\"\"\"\n\"\"\"\na,b,c = map(int,input().split())\nd = []\nd.append(a)\nd.append(b)\nd.append(c)\nd.sort()\nprint(d[2]-d[0])\n\"\"\"\n\"\"\"\nn=int(input())\na=list(map(int,input().split()))\nb = a[:]\nb.reverse()\nu = a.index(max(a))\nl = n-1-b.index(min(a))\nif u > l:\n print(u+(n-1-l)-1)\nelse:\n print(u+(n-1-l))\n\"\"\"\n\"\"\"\ns=input().lower()\nfor i in \"aeiouy\":\n s = s.replace(i,\"\")\nprint(\".\"+\".\".join(s))\n\"\"\"\n\"\"\"\nn = int(input())\nmaxi = 0\nmini = 0\nfor i in range(n):\n\ta,b = map(int,input().split())\n\tmaxi += a+b\n\tmini += a//i\nprint(mini,maxi)\n\"\"\"\n\"\"\"\nn = int(input())\nlast_zero = []\nfor i in range(n):\n\ta = input()\n\tif a[-1]==\"0\":\n\t\tlast_zero.append(a)\nfor i in range(len(last_zero)):\n\tif last_zero[i].count(\"0\")>last_zero[i-1].count(\"0\"):\n\t\tprint(last_zero[i])\n\t\tbreak\n\"\"\"\n\"\"\"\nn = int(input())\nfor i in range(n):\n\ta,b = map(int,input().split())\n\td = len(str(a+b))\n\tif int(str(a)[-i])+int(str(b)[-i]) >= 10 and int(str(a)[-i])+int(str(b)[-i]) >= 10:\n\t\tprint(a+b-(10**(d-1)))\n\"\"\"\n\"\"\"\nfcoin,coins = map(int,input().split())\nl = fcoin\npirates = 0\nwhile l <= coins:\n\tl += fcoin +1\n\tpirates+=1\nprint(pirates)\n\"\"\" \n\"\"\"\na,b = map(str,input().split(\"+\"))\nroman = [\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\",\"X\",\"XI\",\"XII\",\"XIII\",\"XIV\",\"XV\",\"XVI\",\"XVII\",\"XVIII\",\"XIX\",\"XX\"]\nf = roman.index(a)+1\ns = roman.index(b)+1\nd = f+s\nprint(roman[d-1])\n\"\"\"\n\"\"\"\nx = int(input())\nj = 0\nr =[]\nl = []\nfor i in range(x):\n y = [int(i) for i in list(input().split())]\n if y[0]<0:\n l.append(y)\n else:\n r.append(y)\nr = sorted(r)\nl = sorted(l, reverse = True)\n\nj = 0\n\nd =1 if len(r)>=len(l) else -1\nwhile((d == 1 and len(r)>0) or (d==-1 and len(l)>0)):\n if d ==1:\n j += r[0][1]\n r = r[1:]\n d = -1\n else:\n j += l[0][1]\n l = l[1:]\n d = 1\nprint(j)\n\"\"\"\n\"\"\"\na=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\nn=int(input())\nans=0\nfor i in range(1,n+1):\n\tif i%a==0 or i%b==0 or i%c==0 or i%d==0:\n\t\tans+=1\nprint(ans)\n\"\"\"\n\"\"\"\nn,m = map(int,input().split( ))\nfor i in range(n):\n if i%2==0:\n print('#'*m)\n elif i%4==1:\n print('.'*(m-1)+'#')\n else:\n print('#'+'.'*(m-1))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int, input().split()))\nprint(sum(a)/n)\n\"\"\"\n\"\"\"\na,b = map(int, input().split())\n\nr1 = min(a,b)\nr2 = (max(a,b) - min(a,b)) // 2\n\nprint(r1,r2)\n\"\"\"\n\"\"\"\na = input()\nb1,b2,b3,b4,b5 = map(str,input().split())\nif a[-1] == b1[-1] or a[-1] == b2[-1] or a[-1] == b3[-1] or a[-1] == b4[-1] or a[-1] == b5[-1] or a[0] == b1[0] or a[0] == b2[0] or a[0] == b3[0] or a[0] == b4[0] or a[0] == b5[0]:\t\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nlo = []\nfor i in range(n):\n\ta = int(input())\n\tlo.append(a)\nif sum(lo)-lo[-1] == lo[-1] or sum(lo) == 360:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(len(a)):\n\tif factorial(a[i]-1) % a[i] == a[i]-1:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nans = a\nif a % b == 0:\n\tans += a//b\nif (a//b) % 2 == 0:\n\tans += ans % b\nprint(ans)\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nprint(a+b)\n\"\"\"\n\"\"\"\na = input()\nif set(a) == \"ABC\" or set(a) == \".ABC\" or set(a) == \"ABC.\":\n\tprint(1)\nelse:\n\tprint(2)\nprint(set(a))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nans = 0\nfor i in range(len(a)):\n\tif a[i] >= a[-1]:\n\t\tans += 1\nprint(ans)\n\"\"\"\n\"\"\"\nn,k = map(int,input().split())\ni = 0\nwhile 1:\n\ti+=1\n\tif (i // k)*(i % k) == n:\n\t\tprint(i)\n\t\tbreak\n\"\"\"\n\"\"\"\na = input()\nif \"ABC\" in a or \"ACB\" in a or \"BAC\" in a or \"BCA\" in a or \"CAB\" in a or \"CBA\" in a:\n\tprint('Yes')\nelse:\n\tprint('No')\n\"\"\"\n\"\"\"\ns=''\nfor i in range(int(input())):\n s=s+input()\nprint(s.count('11')+s.count('00')+1)\n\"\"\"\n\"\"\"\na = int(input())\nb = [[0] * a for i in range(a)]\nc = []\nfor i in range(a):\n for j in range(a):\n if i == 0 :\n b[i][j] = 1\n else:\n b[i][j] = b[i - 1][j] + b[i][j -1]\nfor i in b:\n c.append(max(i))\nprint(max(c))\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nfor i in range(b):\n\tif a % 10 != 0:\n\t\ta -= 1\n\telif a % 10 == 0:\n\t\ta //= 10\nprint(a)\n\"\"\"\n\"\"\"\nn = int(input())\nans = []\nfor i in range(100):\n\tif int(str(i[0]))+ int(str(i[1]))== 10:\n\t\tans.append(i)\nprint(ans[n])\t\n\"\"\"\n\"\"\"\nn=int(input())\na=input()\nc=0\nfor i in range(n-2):\n if a[i]+a[i+1]+a[i+2]==\"xxx\":\n c+=1\nprint(c)\n\"\"\"\n\"\"\"\na = input()\nb = input()\nop = a.find(\"1\")\nop1 = b.find(\"1\")\nop2 = min(op,op1)\nif a[0] == \"0\" and b[0] == \"0\":\n\tprint(\"0\"*len(a[:op2])+str((int(a)+int(b))).replace(\"2\",\"0\"))\nelse:\n\tprint(str((int(a)+int(b))).replace(\"2\",\"0\"))\n\"\"\"\n\"\"\"\nn = int(input())\nif n % 2 != 0:\n print(n//2)\n print('2 '*(n//2-1)+'3')\nelse:\n print(n//2)\n print('2 '*(n//2))\n\"\"\"\n\"\"\"\na=int(input())\nfor i in range(a):\n\tb,c,d = map(int,input().split())\n\tif d >= min(b,c):\n\t\tprint(max(b,c)+(d-max(b,c)%d))\n\telse:\n\t\tprint(d)\n\"\"\"\n\"\"\"\nn = int(input().strip())\nkras = input().strip()+'W'\nk = []\nl = 0\nfor i in range(n+1):\n if kras[i] == 'B':\n l += 1\n elif l != 0:\n k.append(str(l))\n l = 0\nprint(len(k))\nprint(' '.join(k))\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n\tif a[i] % 2 == 0:\n\t\ta[i] = a[i] - 1\nfor i in a:\n\tprint(i, end = \" \")\n\"\"\"\n\"\"\"\nn,k = map(int, input().split())\ns=1\nd = n\nwhile (n%10!=k and n%10!=0):\n n+=d\n s+=1\nprint(s)\n\"\"\"\n\"\"\"\nn = int(input())\na = input()\nb = []\ncan = 1\nfor i in range(n):\n\tb.append(int(a[i]))\n\tif a[i] != '4' and a[i] != '7':\n\t\tcan = 0\nsuma = 0\nfor i in range(n):\n\tif i < n / 2:\n\t\tsuma += b[i]\n\telse:\n\t\tsuma -= b[i]\n\nif suma != 0 or can == 0:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\"\"\"\n\"\"\"\nn,k = map(int,input().split())\nif (n // k) % 2 == 1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nvar = []\nfor i in range(10000):\n\tif str(i) == str(i)[::-1] and len(str(i)) % 2 == 0 or len(str(i)) == 2:\n\t\tvar.append(i)\nprint(var[n])\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\nans = []\ntot=0\nfor i in range(999):\n\twhile i>0:\n\t\tdig=i%10\n\t\ttot+=dig\n\t\ti //=10\n\tif tot == b:\n\t\tans.append(i)\nif len(ans)==0:\n\tprint(-1,-1)\n\texit()\nprint(min(ans),max(ans))\n\"\"\"\n\"\"\"\nn = int(input())\nseq = []\nfor i in range(1,10000):\n\tseq.append(i*(-1)**i)\nfor i in range(n):\n\tl,r = map(int,input().split())\n\tprint(sum(seq[l-1:r]))\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(len(a)):\n\tg = sqrt(a[i])\n\tpoint = str(g).find(\".\")\n\tif len(str(g)[point:])>2:\n\t\tg = 100\n\tif factorial(g-1) % g == g-1 and g != 1: \n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nmishka = 0\nChris = 0\nFriend = 0\nfor i in range(n):\n\ta,b = map(int,input().split())\n\tif a > b:\n\t\tmishka += 1\n\telif b > a:\n\t\tChris += 1\n\telif a == b:\n\t\tFriend += 1\nif mishka > Chris:\n\tprint(\"Mishka\")\nelif Chris > mishka:\n\tprint(\"Chris\")\nelif Chris == mishka:\n\tprint(\"Friendship is magic!^^\")\n\t\n\"\"\"\n\"\"\"\nn = int(input())\nans = [\"purple\",\"green\",\"blue\",\"orange\",\"red\",\"yellow\"]\nans1 = []\nfor i in range(n):\n\ta = input()\n\tans1.append(a)\n\tdel(ans[ans.index(a)])\nprint(len(ans))\nfor i in range(len(ans)):\n\tif ans[i] == \"purple\":\n\t\tprint(\"Power\")\n\telif ans[i] == \"green\":\n\t\tprint(\"Time\")\n\telif ans[i] == \"blue\":\n\t\tprint(\"Space\")\n\telif ans[i] == \"orange\":\n\t\tprint(\"Soul\")\n\telif ans[i] == \"red\":\n\t\tprint(\"Reality\")\n\telif ans[i] == \"yellow\":\n\t\tprint(\"Mind\")\n\"\"\"\n\"\"\"\na = input()\nans = 0\nb = a\nfor i in range(len(a)):\n\tif a == a[::-1]:\n\t\tb = a[i:]\n\t\tif b != b[::-1]:\n\t\t\tans = len(a)-i\n\t\t\tbreak\n\telif a != a[::-1]:\n\t\tans = len(a)\n\telif a[i]==a[i-1]:\n\t\tans = 0\nprint(ans)\n\"\"\"\n\"\"\"\nfrom math import*\nd,h,v,e = map(int,input().split())\nvol = (pi*(d/2)**2)\nvol1= (pi/vol - pi)\nif vol < vol1:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\tprint(pi/(vol-pi))\nprint(vol,vol1)\n\"\"\"\n\"\"\"\nn = int(input())\nif n == 1 or n == 2 or n == 3:\n\tprint(-1)\n\texit()\nans = [1,5,7,8,3,5,8,7]\nfor i in range(1,n-1):\n\tfor j in range(i,n-1):\n\t\tif ans[j]>ans[j-1]:\n\t\t\tans[j-1],ans[j]=ans[j-1],ans[j]\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\npast = \"\"\nans =\"\"\nfor i in range(a):\n\tkl = input()\n\tpast += kl\nif \"W\" in past:\n\tl = past.replace(\".\",\"D\")\nfor i in range(len(l)):\n\tif i %b==0:\n\t\tprint(l[i])\n\telse:\n\t\tprint(l[i],end='')\n\"\"\"\n\"\"\"\nn = int(input())\ncode1 = input()\ncode2 = input()\npassword = \"1234567890\"\nans = 0\nfor i in range(len(code1)):\n\tans += len(password[password.find(code1[i]):password.find(code2[i])])\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\na = input()\none = a.count(\"1\")\nzero = a.count(\"0\")\nprint(abs(one-zero))\n\"\"\"\n\"\"\"\nn = int(input())\na = input()\nlol = \"\"\nans = \"\"\nYN = \"\"\nif a == \"abb\":\n\tprint(\"YES\")\n\tprint(\"ab\")\n\texit()\nfor i in a:\n\tlol += i\nif a[:] == a[0]*len(a):\n\tYN += \"NO\"\nelse:\n\tYN += \"YES\"\n\tans += lol[-(len(set(a))):]\nprint(YN)\t\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\na = set(map(int,input().split()))\na = list\nprint(len(a))\nlol = \"\"\nfor i in a:\n\tlol += str(i)\n\tlol += \" \"\nfor i in range(len(lol)):\n\tkek = a.count(lol[i])\n\tprint(kek)\n\"\"\"\n\"\"\"\nw,h,k = map(int,input().split())\nans = 0\nfor i in range(k):\n\tif k == 1:\n\t\tans +=(((h*2)+(w-2)*2))\n\telse:\n\t\tans +=(((h*2)+(w-2)*2)+((h-4*(k-1))*2)+((w-4*(k-1)-2)*2)) // 2\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\nmark = input().split()))\nmark.sort()\nans = 0\nif round((sum(mark)/n)+0.00001)==5:\n\tprint(0)\n\texit()\nelse:\n\tfor i in range(n):\n\t\tmark[i] = 5\n\t\tans += 1\n\t\tif round((sum(mark)/n)+0.000001) == 5:\n\t\t\tprint(ans)\n\t\t\tbreak\n\"\"\"\n\"\"\"\nn,m = map(int,input().split())\na = list(map(int,input().split()))\nseta = list(set(a))\nif len(set(a)) >= m:\n\tprint(\"YES\")\n\tfor i in range(m):\n\t\tprint(a.index(seta[i])+1,end = \" \")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\na=int(input())\nb=int(input())\nc=int(input())\nb=b//2\nc=c//4\nif a<=b:\n d=a\nelse\n d=b\nif d>c\n d=c\nd*=7\nprint(d)\n\"\"\"\n\"\"\"\na,b = list(map(int,input().split()))\nprint((a*b)//2)\n\"\"\"\n\"\"\"\nn = int(input())\nfor i in range(n):\n\ta,b = map(int,input().split())\n\tprint(a,a*2)\n\"\"\"\n\"\"\"\nn,a=map(int,input().split())\nm=list(map(int,input().split()))\nans=0\nfor i in range(6-a):\n ans+=m.count(i)\nans//=3\nprint(ans)\n\"\"\"\n\"\"\"\nn = int(input())\na = list(map(int, input().split()))\nans = []\nans1 = 1\nfor i in range(1, n):\n if a[i] > a[i - 1]:\n ans1 += 1\n else:\n ans.append(ans1)\n ans1 = 1\nans.append(ans1)\nprint(max(ans))\n\"\"\"\n\"\"\"\nn = int(input())\ns = input()\ndecode = \"*\"*len(s)\nk = \"\"\nfor i in range(len(s)):\n\tif len(decode) %2== 0:\n\t\tk += decode.replace(decode[(len(s)//2)-1],s[i])\n\telse:\n\t\tk += decode.replace(decode[(len(s)//2)],s[i])\nprint(k)\n\"\"\"\n\"\"\"\nn=int(input())\ns=input()\nans=\"\"\nif n%2==0:\n for i in range(n):\n if i%2==1:\n ans+=s[i]\n else:\n ans=s[i]+ans\nelse:\n for i in range(n):\n if i%2==0:\n ans+=s[i]\n else:\n ans=s[i]+ans\nprint(ans)\n\"\"\"\n\"\"\"\ns = input()\nsrev = s[::-1]\nprint(srev+s)\n\"\"\"\n\"\"\"\nn = int(input())\nsumA = 0\nsumB = 0\nans = \"\"\nfor i in range(n):\n\tt,x,y = map(int,input().split())\n\tif t == 1:\n\t\tsumA += (x+y)\n\telse:\n\t\tsumB += (x+y)\n\tif x >= sumA//2:\n\t\tans += \"LIVE\"\n\telse:\n\t\tans += \"DEAD\"\n\tif x >= sumB // 2:\n\t\tans += \"LIVE\"\n\telse:\n\t\tans += \"DEAD\"\nprint(ans[:4*n])\n\"\"\"\n\"\"\"\nn,c = map(int,input().split())\nques = list(map(int,input().split()))\ntime = list(map(int,input().split()))\nradewoosh = 0\nlimak = 0\ntimecode = 0\nfor i in range(n):\n\ttimecode += time[i]\n\tlimak += max(0,ques[i]-c*timecode)\nradewoosh = 0\ntimecode = 0\nfor i in range(n):\n\ttimecode += time[n-1-i]\n\tradewoosh += max(0,ques[n-1-i]-c*timecode)\n\nif radewoosh > limak:\n\tprint(\"Radewoosh\")\nelif radewoosh < limak:\n\tprint(\"Limak\")\nelif radewoosh == limak:\n\tprint(\"Tie\")\n\"\"\"\n\"\"\"\ns1 = input()\ns2 = input()\ns3 = input()\ns3 = s3.lower()\n\nkek = \"\"\nans = \"\"\nfor i in range(len(s3)):\n\tif s3[i] == \"1\" or s3[i] == \"2\" or s3[i] == \"3\" or s3[i] == \"4\" or s3[i] == \"5\" or s3[i] == \"6\" or s3[i] == \"7\" or s3[i] == \"8\" or s3[i] == \"9\" or s3[i] == \"0\": \n\t\tkek += s3[i]\nfor i in range(len(s3)-len(kek)):\n\tans += s2[s1.find(s3[i])]\nprint(ans+kek)\n\"\"\"\n\"\"\"\nfrom math import*\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(len(a)):\n\tg = sqrt(a[i])\n\tpoint = str(g).find(\".\")\n\tif len(str(g)[point:])>2:\n\t\tg = 100\n\tif factorial(g-1) % g == g-1 and g != 1: \n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nmina = n\nmaxi = n\nwhile str(mina)[-1] != \"0\":\n\tmina -= 1 \nwhile str(maxi)[-1] != \"0\":\n\tmaxi += 1\nif max(maxi,mina) - n > n - min(maxi,mina):\n\tprint(mina)\nelse:\n\tprint(maxi)\nn = int(input())\nl = 0\nif n == 3 :\n l += 1\n print(0)\nif n == 1 or n == 2:\n l += 1\n print(1)\nif n % 4==1 or n % 4==2:\n if l == 0: print(1)\nelse:\n if l == 0:\n print(0)\n\"\"\"\n\"\"\"\nfrom math import*\nn,m = map(int,input().split())\nlol = 0\nfor i in range(n):\n\ta = input().split()\n\tlol += a.count(\"1\")\nprint(lol-1)\n\"\"\"\n\"\"\"\nfor t in range(int(input())):\n\tn=int(input())\n\tif (n*(n-4))>=0:\n\t\tsqrt=(n*(n-4))**0.5\n\t\tprint(\"Y\",(n+sqrt)/2,(n-sqrt)/2)\n\telse:\n\t\tprint(\"N\")\n\"\"\"\n\"\"\"\nn= int(input())\nlst = \"\"\nfor i in range(1000):\n\tlst+=str(i)\nprint(lst[n])\n\"\"\"\n\"\"\"\nn =int(input())\ntriangulara = []\nfor i in range(500):\n\ttriangulara.append(i*(i+1)/2)\nif n in triangulara:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\nif n % 3 == 0:\n print(n // 3 * 2)\nelif n < 3:\n print(1)\nelse:\n print(n // 3 * 2 + 1)\n\"\"\"\n\"\"\" \nn,k=map(int,input().split())\nz=input()\ns=z.find('G')\ne=z.find('T')\nif(e<s):\n z=z[::-1]\n s=z.find('G')\n e=z.find('T')\nans=0\nwhile s<=e:\n if z[s]=='#':\n print(\"NO\")\n ans=1\n break\n elif z[s]=='T':\n print(\"YES\")\n ans=1\n break\n s+=k\nif ans==0:\n print(\"NO\")\n\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nif max(a)-25 < 0:\n\tprint(max(a)-25)\nelse:\n\tprint(n) \n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nprint(max(l)-25)"}, {"source_code": "k = int(input())\nr = map( int, input().split() )\ni0 = 0\nans = k - 25\nfor i in r:\n\tans += i - i0 - 1\n\ti0 = i\nprint(max(0, ans))"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\na=max(l)\nif a>25:\n print(25-a)\nelse:\n print(0) "}, {"source_code": "a = int(input())\nb = input().split()\nb = [int(x) for x in b]\nprint(max(b)-len(b)-(25-a))"}, {"source_code": "n = int(input())\na = list(map(int, input().split(' ')))\nprint(max(max(a) - min(a) - 23, 0))"}, {"source_code": "n = int(input())\na = set(int(x) for x in input().split())\n\ncur = 1\nwhile len(a) < 25:\n if cur not in a:\n a.add(cur)\n cur += 1\n print(len(a))\n\naa = [0] + list(a)\naa.sort()\nans = sum(y - x - 1 for x, y in zip(aa, aa[1:]))\n\nprint(ans)\n"}, {"source_code": "n = int(input())\na = set(int(x) for x in input().split())\n\ncur = 1\nwhile len(a) < 25:\n if cur not in a:\n a.add(cur)\n cur += 1\n print(len(a))\n\naa = [0] + list(a)\naa.sort()\nprint(aa)\nans = sum(y - x - 1 for x, y in zip(aa, aa[1:]))\n\nprint(ans)\n"}, {"source_code": "b=int(input())\na=list(map(int,input().split()))\na.sort()\nh=-1\nif a[-1]<=25:\n\tprint(0)\nelse:\n\tfor i in range(b):\n\t\tif a[i]>25:\n\t\t\th+=1\n\tprint(a[-1]-25-h)\n"}, {"source_code": "b=int(input())\na=list(map(int,input().split()))\nb=0\na.sort()\nfor i in range(b):\n\tif a[i]>25:\n\t\tb+=1\nif a[-1]>25:\n\tb=b+(a[-1]-25-b)\nelse:\n\tprint(0)\nprint(b)\n"}, {"source_code": "a = int(input()) \nz = input()\nm = [int(i) for i in z.split() ]\nprint(max(m)-25)"}, {"source_code": "def invited(lst):\n return max(0, max(lst))\n\n\nn = int(input())\na = [int(i) for i in input().split()]\nprint(invited(a))\n"}, {"source_code": "k = int(input())\narr = [int(x) for x in input().split()]\nmax_ = max(arr)\nprint(max_-25)"}, {"source_code": "n = int(input())\nranks = [int(x) for x in input().split(\" \")]\n\nprint (max(ranks) - 25)"}, {"source_code": "n = int(input())\nranks = [int(x) for x in input().split(\" \")]\n\nprint (min(max(ranks) - 25, 0))"}], "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd"} {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\nif x1==x2 or -x1==-x2 or -y1==-y2:\n print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2+2)\nelse:\n print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2)", "positive_code": [{"source_code": "from sys import stdin\nx1,y1 = map(int,stdin.readline().split())\nx2,y2 = map(int,stdin.readline().split())\nans = 2*(abs(x1-x2) + abs(y1-y2))\nif x1==x2 and y1==y2:\n ans = 10\nelif x1==x2 or y1==y2:\n ans = ans+6\nelse:\n ans+=4\nprint ans"}, {"source_code": "#startpoint, endpoint = raw_input().split(\"\\n\")\nstartpoint = map(lambda x: int(x), raw_input().split(\" \"))\nendpoint = map(lambda x: int(x), raw_input().split(\" \"))\n\nwidth = max(abs(startpoint[0]-endpoint[0]) + 1, 2)\nheight = max(abs(startpoint[1]-endpoint[1]) + 1, 2)\n\nprint width*2 + height*2\n"}, {"source_code": "a,b=map(int,raw_input().split())\nc,d=map(int,raw_input().split())\nans=0\nif a==c and b==d:\n print 10\nelif c>a:\n ans+=(c-a)+1\n ans*=2\n if b>d:\n u=(b-d)+1\n u*=2\n ans+=u\n elif b<d:\n u=(d-b)+1\n u*=2\n ans+=u\n else:\n ans+=4\nelif c<a:\n ans+=(a-c)+1\n ans*=2\n if b>d:\n u=(b-d)+1\n u*=2\n ans+=u\n elif b<d:\n u=(d-b)+1\n u*=2\n ans+=u\n else:\n ans+=4\nelse:\n ans+=4\n if b>d:\n u=(b-d)+1\n u*=2\n ans+=u\n elif b<d:\n u=(d-b)+1\n u*=2\n ans+=u\n else:\n ans+=4\nprint ans"}, {"source_code": "a, b = map(int, raw_input().split())\nc, d = map(int, raw_input().split())\n\nprint max(1, abs(a - c)) * 2 + max(1, abs(b - d)) * 2 + 4\n"}, {"source_code": "x, y = map(int , raw_input().split())\nx1 , y1 = map(int , raw_input().split())\nres = 0\nif x == x1 or y == y1:res = 2\nprint (abs(x -x1) + abs(y - y1))*2 + 4 + res"}, {"source_code": "a, b = map(int, raw_input().split())\nc, d = map(int, raw_input().split())\ne = (abs(a - c) + abs(b - d) + 2) * 2\nif a == c or b == d:\n\te += 2\nprint e"}, {"source_code": "s = [int(i) for i in raw_input().split()]\nf = [int(i) for i in raw_input().split()]\nx1 = s[0]\ny1 = s[1]\nx2 = f[0]\ny2 = f[1]\n\nif(x1==x2):\n x = 2\n y = abs(y1-y2)+1\n mini = (x+y)*2\n print mini\n\nelif(y1==y2):\n x = abs(x1-x2)+1\n y = 2\n mini = (x+y)*2\n print mini\n \nelse:\n x = abs(x1-x2)+1\n y = abs(y1-y2)+1\n mini = (x+y)*2\n print mini\n"}, {"source_code": "import sys, math\ndata = sys.stdin.readlines()\n\nx1, y1 = tuple([int(x) for x in data[0].split()])\nx2, y2 = tuple([int(x) for x in data[1].split()])\n\nx1 += 100\ny1 += 100\nx2 += 100\ny2 += 100\n\nx_len = abs(x1 - x2)\ny_len = abs(y1 - y2)\n\nresult = 0\nif x_len == 0:\n\tresult += 4\nelse:\n\tresult += (x_len + 1) * 2\n\nif y_len == 0:\n\tresult += 4\nelse:\n\tresult += (y_len + 1) * 2\n\nprint result\n\n"}, {"source_code": "ri = lambda: map(int, raw_input().split())\na, b = ri()\nc, d = ri()\ndx = abs(a - c)\ndy = abs(b - d)\n\nans = (dx + dy) * 2 + 4\nif dx == 0 or dy == 0:\n ans += 2\nprint ans"}, {"source_code": "x1, y1=map(int, raw_input().split()); y=1;\nx2, y2=map(int, raw_input().split())\nif (x2==x1) and (y2==y1):\n print 8\nelse:\n if (x2==x1) or (y2==y1):\n print 2*(abs(x2-x1)+abs(y2-y1))+6\n\n else:\n print 2*(abs(x2-x1)+abs(y2-y1))+4\n"}, {"source_code": "helicopter = map(int,raw_input().split())\nflag = map(int,raw_input().split())\n\n#8 points to consider\nx = flag[0]\ny = flag[1]\npoints = [[x-1,y+1],[x,y+1],[x+1,y+1],[x+1,y],[x+1,y-1],[x,y-1],[x-1,y-1],[x-1,y]]\n\ndef dist(x,y):\n return abs(y[1]-x[1]) + abs(y[0]-x[0])\n\nmin = 1000\nfor i in points:\n if dist(i,helicopter)<min:\n min = dist(helicopter,i)\nprint 2*min+8\n"}, {"source_code": "x1, y1 = map(int, raw_input('').split(' '))\nx2, y2 = map(int, raw_input('').split(' '))\nx1 = x1+101\ny1 = y1+101\nx2 = x2+101\ny2 = y2+101\nx = 0\ny = 0\nwyn = 0\nx = abs(x2 - x1) + 1\ny = abs(y2 - y1) + 1\nif x == 1:\n x = 2\nif y == 1:\n y = 2\nwyn = 2*x + 2*y\nprint wyn"}, {"source_code": "import sys\n\n\ndef main():\n a, b = map(int, sys.stdin.readline().split())\n c, d = map(int, sys.stdin.readline().split())\n k = abs(a - c) + 1\n if k == 1:\n k += 1\n r = abs(b - d) + 1\n if r == 1:\n r += 1\n print(2 * (k + r))\n\n\nmain()\n"}, {"source_code": "import sys\nimport itertools\n\ndef main():\n x1, y1 = map(int, raw_input().split())\n x2, y2 = map(int, raw_input().split())\n res = (abs(x1 - x2) + abs(y1 - y2)) * 2 + 4\n if x1 == x2 or y1 == y2:\n\tres += 2\n \n print res\n \n \nif __name__ == '__main__':\n main() \n \n"}, {"source_code": "def dis(x1,y1,x2,y2) :\n return abs(x1-x2)+abs(y1-y2)\nx1,y1=map(int,raw_input().split(' '))\nx2,y2=map(int,raw_input().split(' '))\nans=0\nfor a in range(-1,2,2) :\n for b in range(-1,2,2) :\n ans=max(ans,dis(x1,y1,x2+a,y2+b))\n\nif x1==x2 or y1==y2 :\n ans+=1\nprint ans*2\n"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nx,y=x2,y2\nif abs(x1-x2)>=1:\n\tif x1>x2:\n\t\tx=x2+1\n\telse:\n\t\tx=x2-1\nif abs(y1-y2)>=1:\n\tif y1>y2:\n\t\ty=y2+1\n\telse:\n\t\ty=y2-1\nif x==x2 and y==y2:\n\tprint(8)\nelse:\n\tprint(8+2*(abs(x1-x)+abs(y1-y)))\n"}, {"source_code": "x,y = map(int,input().split())\nfx,fy = map(int,input().split())\nans = 0 \nif x == fx or y==fy :\n\tans=2\nans += abs(fx-x)*2 + abs(fy-y)*2 + 4\nprint(ans)\n"}, {"source_code": "def f(l1,l2):\n g = lambda d: 2 if d==0 else 1+(d if d>0 else -d)\n d2 = g(l1[0]-l2[0])+g(l1[1]-l2[1])\n return d2<<1\n\nl1 = list(map(int,input().split()))\nl2 = list(map(int,input().split()))\nprint(f(l1,l2))\n"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\nif x1 == x2:\n x1 += 1\nelif y1 == y2:\n y1 += 1\nprint((abs(x2 - x1) + 1 + abs(y2 - y1) + 1) * 2)\n"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nif x1 == x2 or y1 == y2:\n print(6+2*abs(x1-x2)+2*abs(y1-y2))\nelse:\n print(4+2*abs(x1-x2)+2*abs(y1-y2))"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nd1=(abs(x1-x2)+1)*2\nd2=(abs(y1-y2)+1)*2\nif (x1==x2) or (y1==y2):\n print(d1+d2+2)\nelse:\n print(d1+d2)\n"}, {"source_code": "def main():\n\tx1,y1 = map(int,input().split())\n\tx2,y2 = map(int,input().split())\n\tres = (abs(x2-x1) + abs(y2 - y1) +2)*2\n\tif x1==x2:\n\t\tres +=2\n\tif y1 == y2:\n\t\tres +=2\n\tprint( res)\n\nmain()"}, {"source_code": "x1, y1 = [int(i) for i in input().split()]\nx2, y2 = [int(i) for i in input().split()]\nprint(max(abs(x1 - x2) + 1, 2) * 2 + max(abs(y1 - y2) + 1, 2) * 2)"}, {"source_code": "lstIn = map(int, input().split())\nx1, y1 = lstIn\n\nlstIn = map(int, input().split())\nx2, y2 = lstIn\n\ndx = abs(x1-x2)\ndy = abs(y1-y2)\n\nif dx<2:\n dx=2\nelse:\n dx += 1\nif dy<2:\n dy=2\nelse:\n dy += 1\n\ndist = dx*2 + dy*2\n\nprint(dist)\n"}, {"source_code": "x,y=map(int,input().split(' '))\na,b=map(int,input().split(' '))\nprint((max(abs(a-x),1)+max(abs(b-y),1))*2+4)"}, {"source_code": "z=lambda:map(int,input().split())\nd=lambda a,b:max(abs(a-b),1)*2+2\nq,w=z()\ne,r=z()\nprint(d(q,e)+d(w,r))\n\n"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\n\nif x1==x2:\n print(4+(abs(y2-y1)+1)*2)\nelif y1==y2:\n print((abs(x2-x1)+1)*2+4)\nelse:\n print((abs(x2-x1)+1)*2+(abs(y2-y1)+1)*2)\n"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split()) \nprint(2*(max(1,abs((x2)-x1))+max(1,abs((y2-y1)))+2))\n"}, {"source_code": "line = input().split(\" \")\nx1 = int(line[0])\ny1 = int(line[1])\n\nline = input().split(\" \")\nx2 = int(line[0])\ny2 = int(line[1])\n\nresult = 2 * abs(x2 - x1) + 2 * abs(y2 - y1) + 4\n\nif x2 == x1 and y2 == y1:\n result = 0\nelif x2 == x1 or y2 == y1:\n result += 2\n\nprint(result)\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print fast\npt = lambda x: sys.stdout.write(str(x)+'\\n')\n\n#--------------------------------WhiteHat010--------------------------------------#\nx,y = get_int_list()\nx1,y1 = get_int_list()\nif x == x1 or y == y1:\n if x == x1:\n d = 2 + abs(y-y1) + 1\n else:\n d = 2 + abs(x-x1) + 1\nelse:\n d = abs(x-x1) + 1 + abs(y-y1) + 1\n\nprint(2*d)"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nif x1 == x2:\n\tprint((max(y1, y2) - min(y1, y2) + 1) * 2 + 4)\nelif y1 == y2:\n\tprint((max(x1, x2) - min(x1, x2) + 1) * 2 + 4)\nelse:\n\tprint((max(x1, x2) - min(x1, x2)) * 2 + (max(y1, y2) - min(y1, y2)) * 2 + 4)"}, {"source_code": "x_1,y_1=map(int,input().split())\nx_2,y_2=map(int,input().split())\n\nprint((abs(x_1-x_2)+1+abs(y_1-y_2)+1)*2+(2 if (x_1==x_2 or y_1==y_2) else 0))"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n \nif x1 == x2:\n x1 += 1\nelif y1 == y2:\n y1 += 1\nprint((abs(x2 - x1) + 1 + abs(y2 - y1) + 1) * 2)"}, {"source_code": "start = input().split()\nx1 = int(start[0])\ny1 = int(start[1])\nflag = input().split()\nx2 = int(flag[0])\ny2 = int(flag[1])\n\nprint( 2*max(1, abs(x1-x2))+2 + 2*max(abs(y1-y2), 1)+2 )\n"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nif x1==x2:\n print(abs(y1-y2)*2+6)\nelif y1==y2:\n print(abs(x1-x2)*2+6)\nelse:\n print((abs(x1-x2)+abs(y1-y2))*2+4)"}, {"source_code": "'''input\n0 1\n0 0\n'''\nfrom collections import defaultdict as dd\nfrom collections import Counter as ccd\nfrom itertools import permutations as pp\nfrom itertools import combinations as cc\nfrom random import randint as rd\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq as hq\nimport math \n'''\nAuthor : dhanyaabhirami\nHardwork beats talent if talent doesn't work hard\n'''\n'''\nStuck?\nSee github resources\nDerive Formula\nKmcode blog\nCP Algorithms Emaxx\n'''\nmod=pow(10,9) +7\ndef inp(flag=0):\n if flag==0:\n return list(map(int,input().strip().split(' ')))\n else:\n return int(input())\n\n# Code credits\n# assert(debug()==true)\n# for _ in range(int(input())):\n\n# t=inp(1)\n# while t:\n# t-=1\nx1,y1 = inp()\nx2,y2 = inp()\nxdist = 2*(abs(x1-x2)+1)\nydist = 2*(abs(y1-y2)+1)\nif x1==x2:\n xdist += 2\nif y1==y2:\n ydist +=2\nans = xdist+ydist\nprint(ans)"}, {"source_code": "# Je ne trouve pas l'astuce... :/\n\ndef dist(x1, y1, x2, y2):\n return abs(x2 - x1) + abs(y2 - y1)\n\nx, y = map(int, input().split())\na, b = map(int, input().split())\n\nr = 4 + 2 * dist(x, y, a, b)\n\nif x == a or y == b:\n r += 2\n\nprint(r)\n\n"}, {"source_code": "x1, y1 = map(lambda x: int(x), input().split())\nx2, y2 = map(lambda x: int(x), input().split())\n\npathLen = abs(x2 - x1) + abs(y2 - y1)\nif x2 == x1 and y2 == y1:\n print(10)\nelif x2 == x1 or y2 == y1:\n print(2 * pathLen + 6)\nelse:\n print(2 * pathLen + 4)\n"}, {"source_code": "l1 = input().split()\nx1,y1 = int(l1[0]), int(l1[1])\nl2 = input().split()\nx2,y2 = int(l2[0]), int(l2[1])\nw = 0\nh = 0\nif x1 == x2:\n w = 2\nelse:\n w = abs(x1-x2)+1\nif y1 == y2:\n h = 2\nelse:\n h = abs(y1-y2)+1\nprint((w+h)*2)"}, {"source_code": "a = tuple(map(int, input().split()))\nb = tuple(map(int, input().split()))\n\nx = abs(a[0] - b[0])\ny = abs(a[1] - b[1])\n\nif x == 0:\n x += 2\nelse:\n x += 1\n\nif y == 0:\n y += 2\nelse:\n y += 1\n\nprint(2*(x + y))\n"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\nimport sys\n\nif(x1 == x2):\n res = 2 * (2 + abs(y1 - y2) + 1)\n print(res)\n sys.exit(0)\nif(y1 == y2):\n res = 2 * (2 + abs(x1 - x2) + 1)\n print(res)\n sys.exit(0)\n\nres = 2 * (abs(x1 - x2) + 1 + abs(y1 - y2) + 1)\nprint(res)\n"}, {"source_code": "x1,y1=map(int, input().split())\nx2,y2=map(int, input().split())\ntravelx=(abs(x1-x2))\ntravely=(abs(y1-y2))\nif(travelx==0):\n travelx+=2\nelse:\n travelx+=1\nif(travely==0):\n travely+=2\nelse:\n travely+=1\ntravelx*=2\ntravely*=2\nprint(travelx+travely)"}, {"source_code": "x1, y1 = map( int, input().split())\nx2, y2 = map( int, input().split())\nif (x1-x2)==0 or (y1-y2)==0:\n print ((abs(x1-x2)+abs(y1-y2))*2+6)\nelse:\n print ((abs(x1-x2)+abs(y1-y2))*2+4)"}, {"source_code": "x,y=map(int,input().split())\na,b=map(int,input().split())\nprint((max(abs(a-x),1)+max(abs(b-y),1))*2+4)"}, {"source_code": "line1 = input()\nline2 = input()\ndc = [int(s) for s in line1.split(' ')]\nfc = [int(s) for s in line2.split(' ')]\nd = [abs(a - b) for a, b in zip(dc, fc)]\ntransit_x = max(2, d[0]+1)*2\ntransit_y = max(2, d[1]+1)*2\nt = transit_x + transit_y\nprint(t)"}, {"source_code": "i,j = input(\"\").split()\ni = int(i)\nj = int(j)\n\no,p = input(\"\").split()\no = int(o)\np = int(p)\n\na = i - o\nb = j - p\n\nif a < 0:\n a = 0-a\n\nif a == 0:\n a = 1\n \nif b == 0:\n b = 1\n\n\nif b < 0:\n b = 0-b\n \nx =(a+b+2)*2\n \nprint(x)"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\np = abs(x1 - x2) + abs(y1 - y2) + 2\n\nprint((p + 1) * 2) if x1 == x2 or y1 == y2 else print(2 * p)\n"}, {"source_code": "a = input().split()\nb = input().split()\n\nx1 = int(a[0])\ny1 = int(a[1])\nx2 = int(b[0])\ny2 = int(b[1])\n\ncount = 0\n\nif x1 < x2 and y1 < y2:\n for i in range(x1, x2 + 1):\n count += 1\n for j in range(y1, y2 + 1):\n count += 1\n count *= 2\nelif x1 < x2 and y1 > y2:\n for i in range(x1, x2 + 1):\n count += 1\n for j in range(y1, y2 - 1, -1):\n count += 1\n count *= 2\nelif x1 > x2 and y1 < y2:\n for i in range(x1, x2 - 1, -1):\n count += 1\n for j in range(y1, y2 + 1):\n count += 1\n count *= 2\nelif x1 > x2 and y1 > y2:\n for i in range(x1, x2 - 1, -1):\n count += 1\n for j in range(y1, y2 - 1, -1):\n count += 1\n count *= 2\nelif x1 == x2 and y1 < y2:\n count += 2\n for i in range(y1, y2 + 1):\n count += 1\n count *= 2\nelif x1 == x2 and y1 > y2:\n count += 2\n for i in range(y1, y2 - 1, -1):\n count += 1\n count *= 2\nelif x1 < x2 and y1 == y2:\n count += 2\n for i in range(x1, x2 + 1):\n count += 1\n count *= 2\nelif x1 > x2 and y1 == y2:\n count += 2\n for i in range(x1, x2 - 1, -1):\n count += 1\n count *= 2\n\nprint(count)"}, {"source_code": "q = [int(i) for i in input().split(\" \")]\nf = [int(i) for i in input().split(\" \")]\nd = [i for i in q]\ncompteur = 0\n\nif (q[0]>f[0]):\n while (q[0]>f[0]+1) :\n q[0]-=1\n compteur+=1\nelif (q[0]<f[0]):\n while (q[0]<f[0]-1) :\n q[0]+=1\n compteur+=1\nif(q[1]>f[1]) :\n while (q[1]>f[1]+1) :\n q[1]-=1\n compteur+=1\nelif(q[1]<f[1]-1) :\n while (q[1]<f[1]-1) :\n q[1]+=1\n compteur+=1\n\n#-----------------------------------\ncompteur += 8\n#-----------------------------------\n\nif (q[0]<d[0]) :\n while (q[0]<d[0]) :\n q[0]+=1\n compteur+=1\nelif (q[0]>d[0]) :\n while (q[0]>d[0]) :\n q[0]-=1\n compteur+=1\nif (q[1]<d[1]) :\n while (q[1]<d[1]) :\n q[1]+=1\n compteur+=1\nelif (q[1]>d[1]) :\n while (q[1]>d[1]) :\n q[1]-=1\n compteur+=1\n\nprint(compteur)\n"}, {"source_code": "read=lambda:map(int,input().split())\nx1,y1=read()\nx2,y2=read()\nprint(6+2*(abs(x2-x1)+abs(y2-y1))-2*(x1 != x2 and y1!=y2))\n"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\nif x1 == x2 and y1 == y2:\n\tprint(8)\nif y1 == y2:\n\tprint(((abs(x1 - x2) + 1) * 2) + 4)\nelif x1 == x2:\n\tprint(((abs(y1 - y2) + 1) * 2) + 4)\nelse:\n\tdistx = abs(x1 - x2) + 1\n\tdisty = abs(y1 - y2) + 1\n\tprint(2 * distx + 2 * disty)"}, {"source_code": "copterX,copterY = map(int, input().split())\nflagX,flagY = map(int, input().split())\n\nif copterX == flagX:\n distance = abs(copterY - flagY)\n routeLength = (distance+3)*2\nelif copterY == flagY:\n distance = abs(copterX - flagX)\n routeLength = (distance+3)*2\nelse:\n distanceX = abs(copterX - flagX)\n distanceY = abs(copterY - flagY)\n distanceXY = distanceX + distanceY\n routeLength = (distanceXY+2)*2\n\nprint(routeLength)"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nx = 1 if not abs(x1-x2) else abs(x1-x2)\ny = 1 if not abs(y1-y2) else abs(y1-y2)\nprint((x+1)*2 + (y+1)*2)\n"}, {"source_code": "from sys import exit\n\nxs, ys = map(int, input().split())\nxf, yf = map(int, input().split())\n\nif xs == xf:\n print((abs(yf - ys) + 1) * 2 + 4)\n exit(0)\nelif ys == yf:\n print((abs(xf - xs) + 1) * 2 + 4)\n exit(0)\n\nxs, xf = sorted([xs, xf])\nys, yf = sorted([ys, yf])\n\nxf += 1\nyf += 1\n\nprint(2 * (xf - xs) + 2 * (yf - ys))\n"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\nprint((abs(x1 - x2) + abs(y1 - y2) + 2 + int(x1 == x2) + int(y1 == y2)) * 2)\n"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nprint(2 * max(abs(x2 - x1), 1) + 2 * max(abs(y2 - y1), 1) + 4)\n\n\n"}, {"source_code": "import math\nimport re\n\n\ndef ria():\n return [int(i) for i in input().split()]\n\n\ndef ri():\n return int(input())\n\n\ndef rfa():\n return [float(i) for i in input().split()]\n\n\neps = 1e-9\n\n\ndef is_equal(a, b):\n return abs(a - b) <= eps\n\n\ndef distance(p0, p1):\n return math.sqrt((p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2)\n\n\nxq, yq = ria()\nxp, yp = ria()\nar = [(xp + 1, yp+1), (xp - 1, yp-1), (xp-1, yp + 1), (xp+1, yp - 1)]\n\nif xp == xq:\n print(2 * 2 + (abs(yp - yq) + 1) * 2)\n exit(0)\nif yp == yq:\n print(2 * 2 + (abs(xp - xq) + 1) * 2)\n exit(0)\nmni = 1e+9\n\nfor i in ar:\n x1, y1 = i\n mxx, mxy, mnx, mny = max(x1, xq), max(y1, yq), min(x1, xq), min(y1, yq)\n #print(mxx,mxy,mnx,mny)\n if mxx > xp and mxy > yp and mnx < xp and mny < yp:\n mni = min(mni, (mxx - mnx) * 2 + (mxy - mny) * 2)\nprint(mni)\n"}, {"source_code": "p1=list(map(int,input().split()))\np2=list(map(int,input().split()))\nif(p1[0]!=p2[0] and p1[1]!=p2[1]):\n ans=2*(abs(p1[0]-p2[0])+1)+2*(abs(p1[1]-p2[1])+1)\nelif(p1[0]!=p2[0] and p1[1]==p2[1]):\n ans=2*(abs(p1[0]-p2[0])+1)+4\nelse:\n ans=ans=2*(abs(p1[1]-p2[1])+1)+4\nprint(ans)\n "}, {"source_code": "f = lambda: map(int, input().split())\nprint(2 * sum(max(1, abs(a - b)) + 1 for a, b in zip(f(), f())))"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nw=2*(abs(x2-x1)+abs(y2-y1)+2)\nif x1==x2 or y1==y2 :\n\tprint(w+2)\nelse:\n\tprint(w)"}, {"source_code": "Start = input()\nFlag = input()\ns_lst = Start.split()\nf_lst = Flag.split()\na = [int(d) for d in s_lst]\nb = [int(d) for d in f_lst]\nx1 = a[0]\ny1 = a[1]\nx2 = b[0]\ny2 = b[1]\nif x1 == x2:\n print(abs(y1 - y2) * 2 + 6)\nelif y1 == y2:\n print(abs(x1 - x2) * 2 + 6)\nelse:\n print(abs(x1 - x2) * 2 + abs(y1 - y2) * 2 + 4)\n "}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nif x1==x2:\n print(2*(1+abs(y1-y2)+2))\nelif y1==y2:\n print(2*(1+abs(x1-x2)+2))\nelse:\n print(2*(abs(x1-x2)+1+abs(y1-y2)+1))"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\ndx=max(2,abs(x1-x2)+1)\ndy=max(2,abs(y1-y2)+1)\nprint(2*dx+2*dy)"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\ndx=max(2,abs(x1-x2)+1)\ndy=max(2,abs(y1-y2)+1)\nprint(2*dx+2*dy)"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\ndx = abs(x1 - x2)\ndy = abs(y1 - y2)\nif dx and dy:\n print(2 * (dx + dy) + 4)\nelse:\n print(2 * (dx + dy) + 6)"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nif abs(x1 - x2) != 0 and abs(y1 - y2) != 0:\n print((abs(x1 - x2) + 1) * 2 + (abs(y1 - y2) + 1) * 2)\nelse:\n print((abs(x1 - x2) + 1) * 2 + (abs(y1 - y2) + 1) * 2 + 2)\n"}, {"source_code": "a, b = input().split(\" \")\nx, y = input().split(\" \")\na = int(a)\nb = int(b)\nx = int(x)\ny = int(y)\nx_ = 0\ny_ = 0\nif(x == a):\n x_ = 2\n y_ = abs(y-b)+1\nelif(y == b):\n x_ = abs(x-a)+1\n y_ = 2\nelse:\n y_ = abs(y-b)+1\n x_ = abs(x-a)+1\nprint(2*(x_ + y_))"}, {"source_code": "I=lambda:map(int,input().split())\na,b=I()\nc,d=I()\nprint((max(1,abs(a-c))+max(1,abs(b-d))<<1)+4)"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nq=x1==x2 or y1==y2\nif x2<x1:\n x2-=1\nelif x2>x1:\n x2+=1\nif y2<y1:\n y2-=1\nelif y2>y1:\n y2+=1\nprint(abs(x2-x1)*2+abs(y2-y1)*2+4 if q else abs(x2-x1)*2+abs(y2-y1)*2)\n"}, {"source_code": "ar = map(int, raw_input().split())\na = map(int, raw_input().split())\nx = 0\nif ar[0] == a[0] or a[1] == ar[1]:\n\tx = 2\t\nprint abs(ar[0]-a[0])*2 + abs(ar[1]-a[1])*2 +4+x\n\n"}], "negative_code": [{"source_code": "ri = lambda: map(int, raw_input().split())\na, b = ri()\nc, d = ri()\nprint (abs(a - c) + abs(b - d)) * 2 + 4\n"}, {"source_code": "x1,y1 = map(int, raw_input().split())\nx2,y2 = map(int, raw_input().split())\nprint (abs(x2-x1)+1)*2+(abs(y2-y1)+1)*2\n"}, {"source_code": "def dis(x1,y1,x2,y2) :\n return abs(x1-x2)+abs(y1-y2)\nx1,y1=map(int,raw_input().split(' '))\nx2,y2=map(int,raw_input().split(' '))\nans=0\nfor a in range(-1,2,2) :\n for b in range(-1,2,2) :\n ans=max(ans,dis(x1,y1,x2+a,y2+b))\n\nif x1==x2 or y1==y2 :\n ans+=2\nprint ans*2\n"}, {"source_code": "def dis(x1,y1,x2,y2) :\n return abs(x1-x2)+abs(y1-y2)\nx1,y1=map(int,raw_input().split(' '))\nx2,y2=map(int,raw_input().split(' '))\nans=0\nfor a in range(-1,2,2) :\n for b in range(-1,2,2) :\n ans=max(ans,dis(x1,y1,x2+a,y2+b))\nprint ans*2\n"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nx,y=x2,y2\nif abs(x1-x2)>1:\n\tif x1>x2:\n\t\tx=x2+1\n\telse:\n\t\tx=x2-1\nif abs(y1-y2)>1:\n\tif y1>y2:\n\t\ty=y2+1\n\telse:\n\t\ty=y2-1\nif x==x2 and y==y2:\n\tprint(8)\nelse:\n\tprint(8+2*(abs(x1-x)+abs(y1-y)))\n"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nx,y=x2,y2\nif abs(x1-x2)>1:\n\tif x1>x2:\n\t\tx=x2+1\n\telse:\n\t\tx=x2-1\nif abs(y1-y2)>1:\n\tif y1>y2:\n\t\ty=y2+1\n\telse:\n\t\ty=y2-1\nif x==x2 or y==y2:\n\tprint(8)\nelse:\n\tprint(8+2*(abs(x1-x)+abs(y1-y)))\n"}, {"source_code": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nx,y=x2,y2\nif abs(x1-x2)>=1:\n\tif x1>x2:\n\t\tx=x2+1\n\telse:\n\t\tx=x2-1\nif abs(y1-y2)>=1:\n\tif y1>y2:\n\t\ty=y2+1\n\telse:\n\t\ty=y2-1\nprint(x,y)\nif x==x2 and y==y2:\n\tprint(8)\nelse:\n\tprint(8+2*(abs(x1-x)+abs(y1-y)))"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nprint(2 *((abs(x1 - x2) + 1) + (abs(y1 - y2) + 1)))\n"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\nif abs(x1)==abs(x2):\n print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2+2)\nelse:\n print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2)"}, {"source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nif x1==x2:\n print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2+2)\nelse:\n print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2) "}, {"source_code": "def f(l1,l2):\n ab = lambda x: x if x>0 else -x\n return (ab(l1[0]-l2[0])+ab(l1[1]-l2[1])+2)<<1\n\nl1 = list(map(int,input().split()))\nl2 = list(map(int,input().split()))\nprint(f(l1,l2))\n"}, {"source_code": "import sys, collections\n\ndef get_dist(a,b,c,d):\n return abs(a - c) + abs(b - d)\n\nx1, y1 = map(int, sys.stdin.readline().split())\nx2, y2 = map(int, sys.stdin.readline().split())\n\nif x1 == x2 and y1 != y2:\n print(2 * get_dist(x1 - 1, y1, x2 + 1, y2 - 1))\nelif x1 != x2 and y1 == y2:\n print(2 * get_dist(x1, y1 + 1, x2 + 1, y2 - 1))\nelse:\n print(2 * get_dist(x1, y1, x2 + 1, y2 - 1))"}, {"source_code": "import sys, collections\n\ndef get_dist(a,b,c,d):\n return abs(a - c) + abs(b - d)\n\nx1, y1 = map(int, sys.stdin.readline().split())\nx2, y2 = map(int, sys.stdin.readline().split())\n\nif x1 == x2 and y1 != y2:\n print(2 * get_dist(x1 - 1, y1, x2 + 1, y2 - 1))\nelif x1 != x2 and y1 == y2:\n print(2 * get_dist(x1, y1 + 1, x2 + 1, y2 - 1))\nelse:\n print(max(2 * get_dist(x1, y1, x2 + 1, y2 - 1), 2 * get_dist(x1, y1, x2 + 1, y2 + 1),\n 2 * get_dist(x1, y1, x2 - 1, y2 - 1), 2 * get_dist(x1, y1, x2 - 1, y2 + 1)))"}, {"source_code": "x, y = map(int, input().split())\nx2, y2 = map(int, input().split())\nprint((abs(x - x2) + abs(y - y2) + 2) * 2)\n"}, {"source_code": "x, y = map(int, input().split())\nx2, y2 = map(int, input().split())\n\n\nresult = (abs(x - x2) + abs(y - y2) + 2) * 2\nif x == x2:\n result += 2\n\nif y == y2:\n result += 2\n"}, {"source_code": "first = list(map(int, input().split()))\nsecond = list(map(int, input().split()))\n\nlen_to_point = abs(first[0] - second[0]) + abs(first[1] - second[1])\n\nif len_to_point == 1:\n print(8)\nelse:\n print((len_to_point - 2) *2 + 8)"}, {"source_code": "#!/usr/bin/env python3\n\nx1, y1 = [int(x) for x in input().split(' ')]\nx2, y2 = [int(x) for x in input().split(' ')]\n\nprint(2*(abs(x1-x2)+1)+2*(abs(y1-y2)+1))\n"}, {"source_code": "a,b = map( int, input().split(' '))\nc,d = map(int, input().split(' '))\nprint((abs(c-a)+1)*2 + 2*(abs(b-d)+1))"}, {"source_code": "from sys import stdin\nx1,y1 = map(int,stdin.readline().split())\nx2,y2 = map(int,stdin.readline().split())\nans = 2*(abs(x1-x2) + abs(y1-y2)) + 4\nif x1==x2 and y1==y2:\n ans = 10\nelif x1==x2 or y1==y2:\n ans = ans+6\nprint ans"}, {"source_code": "a, b = map(int, raw_input().split())\nc, d = map(int, raw_input().split())\ne = (abs(a - b) + abs(c - d) + 2) * 2\nif a == c or b == d:\n\te += 2\nprint e"}, {"source_code": "a, b = map(int, raw_input().split())\nc, d = map(int, raw_input().split())\nprint (abs(a - b) + abs(c - d) + 2) * 2"}, {"source_code": "s = [int(i) for i in raw_input().split()]\nf = [int(i) for i in raw_input().split()]\nx1 = s[0]\ny1 = s[1]\nx2 = f[0]\ny2 = f[1]\n\nx = abs(x1-x2)\ny = abs(y1-y2)\nmini = (x+y+2)*2\nprint max(mini,8)\n"}, {"source_code": "import sys\nx1,y1=list(map(int,(raw_input().strip().split())))\nx2,y2=list(map(int,(raw_input().strip().split())))\nprint 4+2*(abs(x1-x2)+abs(y1-y2));"}, {"source_code": "x1, y1 = map(int, raw_input().split())\nx2, y2 = map(int, raw_input().split())\nptx = ((abs(x2)-abs(x1)) + 1)*2 if (x2-x1) > 0 else 2*2\npty = (abs(abs(y2)-abs(y1)) + 1)*2 if y2 > 0 and y1 > 0 else (abs(y2)+abs(y1)+ 1)*2\nprint(ptx+pty)"}, {"source_code": "x1, y1 = map(int, raw_input().split())\nx2, y2 = map(int, raw_input().split())\nif x2 > 0 and x1 > 0 :\n\tptx = ((abs(x2) - abs(x1)) + 1) * 2 if (x2 - x1) > 0 else 2 * 2\nelse:\n\tptx = ((abs(x2) + abs(x1)) + 1) * 2 if (x2 - x1) > 0 else 2 * 2\npty = (abs(abs(y2)-abs(y1)) + 1)*2 if y2 > 0 and y1 > 0 else (abs(y2)+abs(y1)+ 1)*2\nprint(ptx+pty)"}, {"source_code": "x1, y1 = map(int, raw_input().split())\nx2, y2 = map(int, raw_input().split())\nptx = ((x2-x1) + 1)*2 if (x2-x1) > 0 else 2*2\npty = (abs(y2-y1) + 1)*2\nprint(ptx+pty)"}, {"source_code": "x1, y1 = map(int, raw_input().split())\nx2, y2 = map(int, raw_input().split())\nif x1 == x2 or y1 == 2:\n\tprint(2 * (abs(x1 - x2) + abs(y1 - y2) - 1) + 8)\nelse:\n\tprint(2 * (abs(x1 - x2) + abs(y1 - y2) + 2))"}, {"source_code": "x1, y1=map(int, raw_input().split()); y=1;\nx2, y2=map(int, raw_input().split())\nprint 2*(abs(x2-x1)+abs(y2-y1))+4\n"}, {"source_code": "'''input\n1 5\n5 2\n'''\n\ndef readint():\n return int(raw_input())\n\ndef readints():\n return map(int, raw_input().split())\n\ndef readstr():\n return raw_input()\n\ndef readstrs():\n return raw_input().split()\n\ndef solve():\n return (abs(x1-x2) + abs(y1-y2) + 2) * 2\n\nx1,y1 = readints()\nx2,y2 = readints()\nprint solve()\n"}, {"source_code": "depart = list(map(int,input().split()))\ndrapeau = list(map(int,input().split()))\n\n\nif (drapeau[1]==depart[1]):\n print(8*abs(drapeau[0]-depart[0]))\nelif(drapeau[0]==depart[0]):\n print(8 * abs(drapeau[1] - depart[1]))\nelse :\n print(2*(abs(drapeau[0]-depart[0])+1)+2*(abs(drapeau[1]-depart[1])+1))"}, {"source_code": "depart = list(map(int,input().split()))\ndrapeau = list(map(int,input().split()))\n\n\nif (drapeau[1]==depart[1]):\n print(8*abs(drapeau[0]-depart[0]))\nelif(drapeau[0]==depart[0]):\n print(8*abs(drapeau[1] - depart[1]))\nelse :\n print(2*(abs(max(drapeau[0],depart[0])-min(drapeau[0],depart[0]))+1)+2*(abs(max(drapeau[1],depart[1])-min(drapeau[1],depart[1]))+1))"}, {"source_code": "depart = list(map(int,input().split()))\ndrapeau = list(map(int,input().split()))\n\n\nif (drapeau[1]==depart[1]):\n print(8*abs(drapeau[0]-depart[0]))\nelif(drapeau[0]==depart[0]):\n print(8 * abs(drapeau[1] - depart[1]))\nelse :\n print(2*(abs(drapeau[0]-depart[0]+1))+2*(abs(drapeau[1]-depart[1])+1))"}, {"source_code": "x1, y1 = [int(i) for i in input().split()]\nx2, y2 = [int(i) for i in input().split()]\nprint(max(8, (abs((x2 - x1)) + 1) * 2 + (abs((y2 - y1)) + 1) * 2))"}, {"source_code": "x1, y1 = [int(i) for i in input().split()]\nx2, y2 = [int(i) for i in input().split()]\nprint(max(8, abs((x2 - x1)) * 2 + abs((y2 - y1)) * 2))"}, {"source_code": "lstIn = map(int, input().split())\nx1, y1 = lstIn\n\nlstIn = map(int, input().split())\nx2, y2 = lstIn\n\ndx = abs(x2 - x1)\ndy = abs(y2 - y1)\n\nif dx*dy == 0:\n dist = 8\nelse:\n dist = dx*2 + dy*2 + 4\n\nprint(dist)\n"}, {"source_code": "from math import *\n\nxq,yq = map(int, input().split())\nxf,yf = map(int, input().split())\n\n\nval=0\n\nif(fabs(xq - xf)+fabs( yq - yf) == 2):\n print(8)\n\nelif(xq==xf and yq!=yf):\n print(int(2*(fabs( xq - xf)) + 8))\n\nelif(yq==yf and xq!=xf):\n print(int(2*(fabs( yq - yf)) + 8))\n\n\nelif(xq != xf and yq != yf ):\n print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))\n"}, {"source_code": "from math import *\n\nxq,yq = map(int, input().split())\nxf,yf = map(int, input().split())\n\nval=0\n\nif(fabs( xq - xf)+fabs( yq - yf) == 2):\n print(8);\n\nif( xq != xf & yq != yf ):\n print( 2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4)\n\nif(xq==xf):\n print(2*(fabs( xq - xf)) + 8)\n\nif(yq==yf):\n print(2*(fabs( yq - yf)) + 8)\n\n\n"}, {"source_code": "from math import *\n\nxq,yq = map(int, input().split())\nxf,yf = map(int, input().split())\n\nval=0\nif(xq==xf & yq==yf):\n print(10)\nif(fabs( xq - xf)+fabs( yq - yf) == 2):\n print(8);\n\nif( xq != xf & yq != yf ):\n print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))\n\nif(xq==xf & yq!=yf):\n print(int(2*(fabs( xq - xf)) + 8))\n\nif(yq==yf & xq!=xf):\n print(int(2*(fabs( yq - yf)) + 8))\n\n\n"}, {"source_code": "from math import *\n\nxq,yq = map(int, input().split())\nxf,yf = map(int, input().split())\n\n\nval=0\nif(xq==xf and yq==yf):\n print(10)\n\n\nelif(fabs(xq - xf)+fabs( yq - yf) == 2):\n print(8)\n\n\nelif(xq==xf and yq!=yf):\n print(int(2*(fabs( xq - xf)) + 8))\n\n\nelif(yq==yf and xq!=xf):\n print(int(2*(fabs( yq - yf)) + 8))\n\n\nelif(xq != xf and yq != yf ):\n print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))\n"}, {"source_code": "from math import *\n\nxq,yq = map(int, input().split())\nxf,yf = map(int, input().split())\n\n\nval=0\n\n\nif(yq==yf and xq==xf):\n print(int(10))\nelif(xq==xf and yq!=yf):\n print(int(2*(fabs( xq - xf)) + 8))\nelif(yq==yf and xq!=xf):\n print(int(2*(fabs( yq - yf)) + 8))\nelif(fabs(xq - xf) + fabs(yq - yf) == 2):\n print(8)\nelif(xq != xf and yq != yf ):\n print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))\n"}, {"source_code": "\n\nfrom math import *\n\nxq,yq = map(int, input().split())\nxf,yf = map(int, input().split())\n\nval=0\n\nif(fabs( xq - xf)+fabs( yq - yf) == 2):\n print(8);\n\nif( xq != xf & yq != yf ):\n print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))\n\nif(xq==xf):\n print(int(2*(fabs( xq - xf)) + 8))\n\nif(yq==yf):\n print(int(2*(fabs( yq - yf)) + 8))\n\n\n"}, {"source_code": "from math import *\n\nxq,yq = map(int, input().split())\nxf,yf = map(int, input().split())\n\n\nval=0\nif(xq==xf and yq==yf):\n print(10)\n\n\nif(fabs(xq - xf)+fabs( yq - yf) == 2):\n print(8)\n\n\nif(xq==xf and yq!=yf):\n print(int(2*(fabs( xq - xf)) + 8))\n\n\nif(yq==yf and xq!=xf):\n print(int(2*(fabs( yq - yf)) + 8))\n\n\nif(xq != xf and yq != yf ):\n print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))\n"}, {"source_code": "x1,y1 = [i for i in map(int,(input().split()))]\nx2,y2 = [i for i in map(int,(input().split()))]\n#print(x1,x2,y1,y2)\nx = x1-x2\ny = y1-y2\n#print(x,y)\nif x<0:\n x = -1*x\nif y<0:\n y = -1*y\nx = 2*(x+1)\ny = 2*(y+1)\nprint(x+y)"}, {"source_code": "(a,b)=(int(i) for i in (input().split()))\n(c,d)=(int(i) for i in (input().split()))\nif a==c or b==d:\n\tk=((((c-a)**2)**(1/2))+(((d-b)**2)**(1/2)))*2+6\nelse:\n\tk=((((c-a)**2)**(1/2))+(((d-b)**2)**(1/2)))*2+4\nd=k**2\nprint(d**(1/2))"}, {"source_code": "line1 = input()\nline2 = input()\ndc = [int(s) for s in line1.split(' ')]\nfc = [int(s) for s in line2.split(' ')]\nd = [abs(a - b) for a, b in zip(dc, fc)]\nprint(d)\ntransit_x = max(2, d[0]+1)*2\ntransit_y = max(2, d[1]+1)*2\nt = transit_x + transit_y\nprint(t)"}, {"source_code": "line1 = input()\nline2 = input()\ndc = [int(s) for s in line1.split(' ')]\nfc = [int(s) for s in line2.split(' ')]\ndx = abs(dc[0]-fc[0])\ndy = abs(dc[1]-fc[1])\ntransit_x = min(2, dx+1)*2\ntransit_y = min(2, dy+1)*2\nt = transit_x + transit_y\nprint(t)"}, {"source_code": "i,j = input(\"Enter two values: \").split()\ni = int(i)\nj = int(j)\n\no,p = input(\"Enter two values: \").split()\no = int(o)\np = int(p)\n\na = i - o\nb = j - p\n\nif a < 0:\n a = 0-a\n\nif a == 0:\n a = 1\n \nif b == 0:\n b = 1\n\nif b < 0:\n b = 0-b\n \nx =(a+b+2)*2\n \nprint(x)"}, {"source_code": "p = input().split()\nq = input().split()\n\nx1 = int(p[0])\ny1 = int(p[1])\nx2 = int(q[0])\ny2 = int(q[1])\n\ncount = 0\n\nif x1 != x2 and y1 != y2:\n if x1 < x2:\n for i in range(x1, x2 + 2):\n count += 1\n if y1 < y2:\n for j in range(y1, y2 + 2):\n count += 1\n else:\n for k in range(y1, y2 - 2, -1):\n count += 1\n else:\n for i in range(x1, x2 - 2, -1):\n count += 1\n if y1 < y2:\n for j in range(y1, y2 + 2):\n count += 1\n else:\n for k in range(y1, y2 - 2, -1):\n count += 1\n print(count * 2 - 4)\nelif x1 == x2 and y1 != y2:\n if y1 < y2:\n for i in range(y1, y2 + 2):\n count += 1\n else:\n for j in range(y1, y2 - 2, -1):\n count += 1\n count += 4\n print(count + 1)\nelif x1 != x2 and y1 == y2:\n if x1 < x2:\n for i in range(x1, x2 + 2):\n count += 1\n else:\n for j in range(x1, x2 - 2, -1):\n count += 1\n count += 4\n print(count + 2)"}, {"source_code": "x1,y1 = map(int,input().split())\nx2,y2 = map(int,input().split())\nr = (x1 == x2) + (x1 == x2)\nprint(((abs(x1-x2) + 1)*2) + ((abs(y1-y2) + 1)*2) + r)"}, {"source_code": "import math\nimport re\n\n\ndef ria():\n return [int(i) for i in input().split()]\n\n\ndef ri():\n return int(input())\n\n\ndef rfa():\n return [float(i) for i in input().split()]\n\n\neps = 1e-9\n\n\ndef is_equal(a, b):\n return abs(a - b) <= eps\n\n\ndef distance(p0, p1):\n return math.sqrt((p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2)\n\n\nxq, yq = ria()\nxp, yp = ria()\nar = [(xp + 1, yp+1), (xp - 1, yp-1), (xp-1, yp + 1), (xp+1, yp - 1)]\n\nif xp == xq:\n print(2 * 2 + (abs(yp - yq) + 1) * 2)\nif yp == yq:\n print(2 * 2 + (abs(xp - xq) + 1) * 2)\nmni = 1e+9\n\nfor i in ar:\n x1, y1 = i\n mxx, mxy, mnx, mny = max(x1, xq), max(y1, yq), min(x1, xq), min(y1, yq)\n #print(mxx,mxy,mnx,mny)\n if mxx > xp and mxy > yp and mnx < xp and mny < yp:\n mni = min(mni, (mxx - mnx) * 2 + (mxy - mny) * 2)\nprint(mni)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\n\n\"\"\"\ncreated by shhuan at 2017/10/22 12:19\n\n\"\"\"\n\nx1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\n\nprint(2*(2+abs(x1-x2)+abs(y1-y2)))"}, {"source_code": "x1, y1 = map( int, input().split())\nx2, y2 = map( int, input().split())\nprint (max((abs(x1-x2)+abs(y1-y2)+2)*2, 8))"}, {"source_code": "x1, y1 = map( int, input().split())\nx2, y2 = map( int, input().split())\nprint ((abs(x1-x2)+abs(y1-y2)+2)*2)"}], "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed"} {"source_code": "n = int(input())\ns = input()\nc1 = 0\nc0 = 0\ncount = 0\nb = True\nfor c in s:\n if c == \"1\":\n c1 += 1\n c0 = 0\n count += 1\n else:\n c0 += 1\n c1 = 0\n if (c0 > 2) or (c1 > 1) or ((count == 0) and (c0 > 1)):\n b = False\n break\nif (c0 > 1) or (c1 > 1) or (count == 0):\n b = False\nif b:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "positive_code": [{"source_code": "n = input()\ns = raw_input()\nif((s == '1') or (s == '01') or (s == '10')): print(\"Yes\")\nelif((s == '0') or (s == '00') or (s == '11')): print(\"No\")\nelif(('11' not in s) and ('000' not in s) and (s[:2]!='00') and (s[-2:]!='00')): print(\"Yes\")\nelse: print(\"No\")"}, {"source_code": "n = int(input())\nseats = input()\n\nmaximal = True\n\nif n == 1:\n if seats[0] == '0':\n maximal = False\n\nelif n == 2:\n if seats[0] == '1' and seats[1] == '1' or seats[0] == '0' and seats[1] == '0':\n maximal = False\n\nelif seats[0] == '0' and seats[1] == '0' or seats[-1] == '0' and seats[-2] == '0':\n maximal = False\n\nfor i in range(1, n-1):\n if seats[i] == '0' and seats[i-1] == '0' and seats[i+1] == '0':\n maximal = False\n break\n elif seats[i] == '1' and (seats[i+1] == '1' or seats[i-1] == '1'):\n maximal = False\n break\n\nif maximal:\n print(\"Yes\")\nelse:\n print(\"No\")\n "}, {"source_code": "import sys, bisect\n\nf = sys.stdin\n#f = open('ROW.txt')\nn = int(f.readline())\ns = f.readline()\nans = \"Yes\"\nprev = s[0]\nfor i in range(1, n):\n if s[i] == prev and s[i] == '1':\n ans = \"No\"\n break\n prev = s[i]\nif ans == \"Yes\":\n for i in range(0, n):\n if s[i] == '0':\n prev = '0'\n next = '0'\n if i > 0:\n prev = s[i - 1]\n if i + 1 < n:\n next = s[i + 1]\n if prev == '0' and next == '0':\n ans = \"No\"\n break\nprint ans\n#f.close()"}, {"source_code": "n = int(input())\ns = input()\npt = 0\n\ncnt = 0 \nif(int(s[0]) == 1):\n\tif(n > 1):\n\t\tif(int(s[1]) == 1):\n\t\t\tpt = 1\n\t\telse:\n\t\t\tcnt += 1\n\telse:\n\t\t\tcnt += 1\nelse:\n\tif(n > 1):\n\t\tif(int(s[1]) == 0):\n\t\t\tpt = 1\n\nfor i in range(1,n-1):\n\tif(int(s[i]) == 1):\n\t\tif(int(s[i-1]) == 0 and int(s[i+1]) == 0):\n\t\t\tcnt +=1\n\t\telse:\n\t\t\tpt = 1\n\t\t\tbreak\n\telse:\n\t\tif(int(s[i-1]) == 0 and int(s[i+1]) == 0):\n\t\t\tpt = 1\n\t\t\tbreak\n\t\t\t\nif(int(s[n-1]) == 1):\n\tif(n > 1):\n\t\tif(int(s[n-2]) == 1):\n\t\t\tpt = 1\n\t\telse:\n\t\t\tcnt += 1\n\telse:\n\t\t\tcnt += 1\nelse:\n\tif(n > 1):\n\t\tif(int(s[n-2]) == 0):\n\t\t\tpt = 1\n\telse:\n\t\tpt = 1\n\t\t\t\n\nif(pt == 0):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "\n\n# contest http://codeforces.com/contest/982/problem/A\n\ndef f(seats):\n if len(seats) == 1:\n if seats == \"1\":\n return \"Yes\"\n else:\n return \"No\"\n\n if seats[0] == '1' and seats[-1] == '1':\n return f(seats[2:])\n else:\n return \"No\"\n\ndef solution(line1, line2):\n N = int(line1)\n seats = line2\n\n if (N%2 == 0):\n if seats[0] == '1' and seats[-1] == '0':\n return f(seats[0:-1])\n elif seats[0] == '0' and seats[-1] == '1':\n return f(seats[1:])\n else:\n return \"No\"\n\n else:\n return f(seats)\n\ndef solution2(line2):\n\n if line2 == '0':\n return \"No\"\n if line2[-2:] == \"00\":\n return \"No\"\n first_one_index = 0\n for i in range(len(line2)):\n if line2[i] == '1':\n first_one_index = i\n break\n if first_one_index > 1:\n return \"No\"\n\n line2 = line2[first_one_index+1:]\n\n last_is_zero = False\n zero_count = 0\n one_count = 1\n for i in range(len(line2)):\n c = line2[i]\n if c == '0':\n if last_is_zero == False:\n zero_count = 1\n one_count = 0\n last_is_zero = True\n elif zero_count > 1:\n return \"No\"\n else:\n zero_count = zero_count + 1\n elif c == '1':\n if last_is_zero == True:\n zero_count = 0\n one_count = 1\n last_is_zero = False\n else:\n return \"No\"\n return \"Yes\"\n\nline1 = raw_input();\nline2 = raw_input();\n\nprint solution2(line2)"}, {"source_code": "n=int(input())\nc=input()\nfor i in range(1,n):\n if c[i]==c[i-1] and c[i]!=\"0\":\n print(\"No\")\n exit()\n elif i > 2 and c[i]==c[i-1] and c[i-1]==c[i-2]:\n print(\"No\")\n exit()\nif n > 1 and c[1]==c[0] and c[1]==\"0\":\n print(\"No\")\n exit()\nelif n > 1 and c[n-1]==c[n-2] and c[n-1]==\"0\":\n print(\"No\")\n exit()\nif n==1 and c[0]==\"0\":\n print(\"No\")\n exit()\nprint(\"Yes\")\n"}, {"source_code": "from sys import stdin\nnumero = int(input())\nordem= str(stdin.readline())\n\nx=False\nif(numero==1 and ordem[0]==\"0\"):\n\tx=True\nfor i in range(1,numero):\n\n\tif(ordem[i]==ordem[i-1] and ordem[i]==\"1\"):\n\t x=True\n\t break\n\telif(ordem[i]==ordem[i-1] and ordem[i]==ordem[i+1] and ordem[i]==\"0\"):\n\t x=True\n\t break\n\telif((i==1 and ordem[i]==ordem[i-1] and ordem[i]==\"0\") or (i==numero-1 and ordem[i]==ordem[i-1] and ordem[i]==\"0\")):\n\t\tx=True\n\t\tbreak\n\nif(x==False):\n print(\"Yes\")\nelse:\n\tprint(\"No\")\n"}, {"source_code": "def f(s, n):\n p = s\n if all(map(lambda x: x == '0', p)):\n return 'No'\n if n == 1 and s[0] == '0':\n return 'No'\n if p[0:2] == ['0', '0']:\n return 'No'\n if p[-2:] == ['0', '0']:\n return 'No'\n p.append('1')\n first = p.index('1')\n last = p.index('1', first+1)\n while last < n:\n d = last - first\n first = last\n last = p.index('1', first+1)\n if 2 <= d <= 3:\n continue\n else:\n return 'No'\n return 'Yes'\n\n\nn = int(raw_input().strip())\ns = list(raw_input().strip())\nprint f(s, n) \n"}, {"source_code": "n=int(input())\ns=input().strip()\nif n<=2:\n if s in ['10','01','1']:\n print('Yes')\n else:\n print('No')\nelse:\n if '11' in s:\n print('No')\n elif '000' in s:\n print('No')\n elif s[:2]=='00':\n print('No')\n elif s[-2:]=='00':\n print('No')\n else:\n print('Yes')\n \n \n \n"}, {"source_code": "import sys\nfrom math import ceil\n\nn = int(sys.stdin.readline().strip())\ns = sys.stdin.readline().strip()\n\ndef sol():\n\tif s == \"0\":\n\t\treturn False\n\telif s[:2] == \"00\":\n\t\treturn False\n\telif s[-2:] == \"00\":\n\t\treturn False\n\telse:\n\t\tif s.count(\"000\") > 0:\n\t\t\treturn False\n\t\treturn s.count(\"11\") == 0\n\n\n\nprint([\"No\",\"Yes\"][sol()])"}, {"source_code": "n = int(input())\ns = input()\ns = \"0\" + s + \"0\"\nif n >= 3:\n if \"11\" in s or \"000\" in s:\n print(\"NO\")\n else:\n print(\"YES\")\nelif n == 2:\n if s == \"0110\" or s == \"0000\":\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n if s == \"010\":\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "import time, math\nt1 = time.time()\n\n\nn = int(raw_input())\nline = raw_input()\n\nline = \"0\" + line + \"0\"\n\nans = \"Yes\"\n\nfor i in range(len(line) - 2):\n if line[i] == \"0\" and line[i+1] == \"0\" and line[i+2] == \"0\":\n ans = \"No\"\n break\n if line[i] == \"1\" and line[i+1] == \"1\":\n ans = \"No\"\n break\n\nprint ans\n# print time.time() - t1"}, {"source_code": "n = int(input())\nflag = True\na = input()\nfor i in range(1,n-1):\n if a[i] == '1':\n if a[i-1] == '1' or a[i+1] == '1':\n print(\"No\")\n flag = False\n break\n if a[i] == '0':\n if a[i - 1] == '0' and a[i + 1] == '0':\n print(\"No\")\n flag = False\n break\nif ((a == '0' or a == '11') or (a[n-1] == '0' and a[n-2] == '0') or (a[0] == '0' and a[1] == '0')) and flag:\n flag = False\n print(\"No\")\nif flag:\n print(\"Yes\")\n\n"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nres = True\ncount = 0\nwhile(i<n):\n if s[i]=='1':\n if count>2 or (i!=0 and count==0):\n res = False\n break\n count=0\n else:\n count+=1\n i+=1\nif (n==1 and s[0]=='0') or (n>1 and s[0]=='0' and s[1]=='0'):\n res = False\nif count>=2:\n res = False\nif res:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "n = int(input())\nu = list(map(int, list(input())))\nif n == 1 and u[0] == 0:\n print('No')\n exit()\nfor i in range(1, n - 1):\n if u[i] == 0:\n if u[i - 1] == u[i] and u[i + 1] == u[i]:\n print('No')\n exit()\n else:\n if u[i - 1] == u[i] or u[i + 1] == u[i]:\n print('No')\n exit()\nif n > 1 and (u[0] == u[1] or u[-1] == u[-2]):\n print('No')\nelse:\n print('Yes')\n"}, {"source_code": "\nn=int(input())\nl=input()\nnona=l.find('11')\nnomop=l.find('000')\nend=l.endswith(\"00\")\nstart=l.startswith(\"00\")\nif n>1:\n if nona==-1 and nomop==-1 and end==False and start==False:\n print(\"Yes\")\n else:\n print(\"No\")\nelif n==1:\n if l=='0':\n print(\"No\")\n else:\n print('Yes')\n"}, {"source_code": "n, s = input(), input()\nif s in ['0', '00']:\n print('No')\nelse:\n print(('No', 'Yes')[not s.startswith('00') and not s.endswith('00')\n and s.count('000') == 0 and s.count('11') == 0])\n"}, {"source_code": "def print_return(func):\n def wrapper(*args, **kwargs):\n retval = func(*args, **kwargs)\n print(retval)\n return retval\n\n return wrapper\n\n\nclass Solve:\n @staticmethod\n @print_return\n def solve_a(lines=None):\n if lines is None:\n n = int(input())\n row = input()\n else:\n lines = lines.split('\\n')\n n = int(lines[0].strip())\n row = lines[1].strip()\n row = '0' + row + '0'\n ans = 'Yes'\n for idx in range(1, n + 1):\n if all(x == '0' for x in row[idx - 1: idx + 2]):\n ans = 'No'\n break\n elif row[idx] == '1' and any(x == '1' for x in (row[idx - 1], row[idx + 1])):\n ans = 'No'\n break\n return ans\n\n @staticmethod\n @print_return\n def solve_b(lines=None):\n if lines is None:\n n = int(input())\n idx___width = [int(x) for x in input().split()]\n stop_idx___char = input()\n else:\n lines = lines.split('\\n')\n n = int(lines[0])\n idx___width = [int(x) for x in input().split()]\n stop_idx___char = input()\n\n @staticmethod\n @print_return\n def solve_c(lines=None):\n pass\n\n @staticmethod\n @print_return\n def solve_d(lines=None):\n pass\n\n @staticmethod\n @print_return\n def solve_e(lines=None):\n pass\n\n @staticmethod\n @print_return\n def solve_f(lines=None):\n pass\n\n\nif __name__ == '__main__':\n Solve.solve_a()\n"}, {"source_code": "n = int(input())\ns = input()\nprint('No'if s == '0' or '000' in s or s[0] == '0' and s[1] == '0' or s[-1] == '0' and s[-2] == '0' or '11' in s else 'Yes')"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef solve(A):\n n = len(A)\n for i in range(n):\n if i + 1 < n and A[i] and A[i+1]:\n return False\n for i in range(n):\n if A[i] == 0:\n ok = True\n if i - 1 >= 0 and A[i-1]:\n ok = False\n if i + 1 < n and A[i+1]:\n ok = False\n if ok:\n return False\n return True\n\ndef main():\n n = int(input())\n A = []\n s = input()\n for c in s:\n A.append(int(c))\n if solve(A):\n print('Yes')\n else:\n print('No')\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n = int(input())\nss = input().strip()\ns = [int(i) for i in list(ss)]\narr = []\nfor i in range(n):\n if s[i]==1:\n arr.append(i+1)\nfailed = 0\nif n==1 and s==[0]:\n print(\"No\")\nelif n==1 and s==[1]:\n print(\"Yes\")\nelif n==2 and ss=='00':\n print(\"No\")\nelif n==2 and ss=='01':\n print(\"Yes\")\nelif n==2 and ss=='10':\n print(\"Yes\")\nelif n==2 and ss=='11':\n print(\"No\")\nelif n==3 and ss=='000':\n print(\"No\")\nelif n==3 and ss=='100':\n print(\"No\")\nelif n==3 and ss=='001':\n print(\"No\")\nelif n==3 and ss=='010':\n print(\"Yes\")\nelif n==3 and ss=='110':\n print(\"No\")\nelif n==3 and ss=='101':\n print(\"Yes\")\nelif n==3 and ss=='011':\n print(\"No\")\nelif n==3 and ss=='111':\n print(\"No\")\nelse:\n if n>3 and s.count(1)<=1:\n print(\"No\")\n elif arr[0]>2:\n print(\"No\")\n elif arr[-1]<(n-1):\n print(\"No\")\n else:\n pas = 0\n for i in range(len(arr)-1):\n if arr[i+1]-arr[i]>3 or arr[i+1]-arr[i]<2:\n pas = 1\n break\n if pas==1:\n print(\"No\")\n else:\n print(\"Yes\")\n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n##kkl = 0\n##if s.count('1')>0:\n## position = n - s[::-1].index('1')\n## print(position)\n## if position<len(s):\n## for i in range(position):\n## first = i\n## second = i+1\n## if s[first]==s[second]:\n## print(\"No\")\n## kkl = 1\n## break\n## if kkl==0:\n## if position==n-1:\n## print(\"Yes\")\n## else:\n## print(\"No\")\n## else:\n## for i in range(len(s)-1):\n## first = i\n## second = i+1\n## if s[first]==s[second]:\n## print(\"No\")\n## kkl = 1\n## break\n## if kkl==0:\n## print(\"Yes\")\n##else:\n## print(\"No\")\n\n \n"}, {"source_code": "#!/usr/bin/env python3\n# -*- encoding: utf-8 -*-\n\nimport sys\n\ndef main():\n n = int(sys.stdin.readline())\n l = [int(i) for i in sys.stdin.readline().strip()]\n\n if l == [0] or sum(l[0:2]) == 0 or sum(l[-2::]) == 0:\n print('No')\n return\n\n for i in range(n-1):\n if l[i] + l[i+1] == 2 or sum(l[i:i+3]) == 0:\n print('No')\n return\n print('Yes')\n\nmain()\n"}, {"source_code": "n=int(input())\na=str(input())\nif a=='0' or( a[n-2]=='0' and a[n-1]=='0')or (a[0]=='0' and a[1]=='0'):\n print('NO')\nelse:\n if a.count('11')>0 or a.count('000') >0:\n print('NO')\n else:\n print('YES')"}, {"source_code": "n=int(input())\ns=input().strip()\nflag=1 \nif n==1:\n if s!=\"0\":\n print(\"Yes\")\n else:\n print(\"No\")\nelif n==2:\n if s!=\"00\" and s!=\"11\":\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n if s[:2]==\"00\":\n flag=0\n for i in range(1,n-1):\n t=s[i-1]+\"1\"+s[i+1]\n if t==\"010\" and s[i]!=\"1\":\n flag=0 \n break\n if s[n-2:n]==\"00\":\n flag=0\n for i in range(n-1):\n if s[i:i+2]==\"11\":\n flag=0\n break\n if flag==1:\n print(\"Yes\")\n else:\n print(\"No\")"}, {"source_code": "n = int(input())\ns = input()\nper = True\nif not '1' in s:\n print(\"No\")\n exit(0)\n\nfor i in range(n-1):\n if s[i] == '1':\n if s[i + 1] == '1':\n print(\"No\")\n exit(0)\n\nfor i in range(n):\n if s[i] == '1':\n if per:\n if not '1' in s[0:i] and i != 1 and i != 0:\n print(\"No\")\n exit(0)\n per = False\n if i != n - 1:\n if not '1' in s[i+1:i+4] and i != n - 2:\n print(\"No\")\n exit(0)\nprint(\"Yes\")"}, {"source_code": "n = input()\ns = raw_input()\nif n == 1:\n\tif s[0] == '1':\n\t\tprint \"Yes\"\n\telse:\n\t\tprint \"No\"\nelse:\n\tfor i in xrange(1, n-1):\n\t\tif s[i] == '1':\n\t\t\tif s[i-1] == '1' or s[i+1] == '1':\n\t\t\t\tprint \"No\"\n\t\t\t\tbreak\n\t\telse:\n\t\t\tif s[i-1] == '0' and s[i+1] == '0':\n\t\t\t\tprint \"No\"\n\t\t\t\tbreak\n\telse:\n\t\tif s[0] != s[1] and s[-1] != s[-2]:\n\t\t\tprint \"Yes\"\n\t\telse:\n\t\t\tprint \"No\""}, {"source_code": "n = int(input())\ns = input()\ne = s.count(\"11\")\nr = s.count(\"000\")\nif s == \"0\":\n print(\"No\")\n exit()\n\nif len(s) >= 2:\n q1 = s[0]+s[1]\n q2 = s[-2]+s[-1]\n if q1 == \"00\" or q2 == \"00\":\n print(\"No\")\n exit()\n\nif r > 0 or e > 0:\n print(\"No\")\n exit()\n\nprint(\"Yes\")"}, {"source_code": "n = input()\ns = raw_input()\n\nz = 'Yes'\n\nif n == 1:\n if s == '0':\n z = 'No'\nelse:\n for i in range(n):\n if s[i] == '0':\n if i == 0:\n if s[i + 1] == '0':\n z = 'No'\n elif i == n - 1:\n if s[i - 1] == '0':\n z = 'No'\n else:\n if s[i - 1] == '0' and s[i + 1] == '0':\n z = 'No'\n\n if s[i] == '1':\n if i == 0:\n if s[i + 1] == '1':\n z = 'No'\n elif i == n - 1:\n if s[i - 1] == '1':\n z = 'No'\n else:\n if s[i - 1] == '1' or s[i + 1] == '1':\n z = 'No'\n\nprint z\n"}, {"source_code": "\n\nn=int(input())\ns=str(input())\nif n==1:\n if s==\"0\":\n print(\"No\")\n else:\n \n print(\"Yes\")\nelif n==2:\n if s[0]!=s[1]:\n print('Yes')\n \n else:\n print(\"No\")\nelif n==3:\n if s[0]==s[2] and s[0]!=s[1]:\n print(\"Yes\")\n\n else:\n print(\"No\")\nelse:\n \n \n a=[]\n an=True\n for i in range(n):\n if s[i]==\"1\":\n a.append(i)\n \n for i in range(len(a)-1):\n if (int(a[i+1])-int(a[i])-1)<1 or (int(a[i+1])-int(a[i])-1)>=3:\n an=False\n \n \n break\n lv=len(s)\n no=s.rstrip(\"0\")\n n1=s.lstrip(\"0\")\n an1=lv-len(no)\n an2=lv-len(n1)\n \n if an==True and an1<=1 and an2<=1:\n print('Yes')\n else:\n print(\"No\")\n \n \n"}, {"source_code": "input()\ns = '0'+input()+'0'\nprint(\"No\" if '000' in s or '11' in s else \"Yes\")\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nf = (s == '0' or s.startswith('00') or s.endswith('00') or '000' in s or '11' in s)\n\nprint 'No' if f else 'Yes'"}, {"source_code": "import sys\n\n\nstdin = sys.stdin\n\nn = int(stdin.readline())\nseats = stdin.readline().strip()\n\nseats = '0' + seats[:] + '0'\nn = len(seats)\nfor i in range(n):\n if i < n-1 and seats[i:i+2] == '11':\n print(\"No\")\n exit(0)\n if i < n-2 and seats[i:i+3] == '000':\n print(\"No\")\n exit(0)\nprint(\"Yes\")"}, {"source_code": "input()\ns = '0' + input() + '0'\nprint(\"No\" if \"11\" in s or \"000\" in s else \"Yes\")\n"}, {"source_code": "n = int(raw_input())\narr = raw_input()\n\nif n == 1:\n print \"Yes\" if arr[0] == '1' else \"No\"\n exit()\n\nfor i in range(n):\n if i == 0:\n if arr[i] == '1' and arr[i + 1] == '1':\n print \"No\"\n exit()\n if arr[i] == '0' and arr[i + 1] == '0':\n print \"No\"\n exit()\n elif i == n - 1:\n if arr[i] == '0' and arr[i - 1] == '0':\n print \"No\"\n exit()\n else:\n if arr[i] == '1' and arr[i + 1] == '1':\n print \"No\"\n exit()\n if arr[i - 1] == '0' and arr[i] == '0' and arr[i + 1] == '0':\n print \"No\"\n exit()\n\nprint \"Yes\"\n"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n if s == '0':\n print('No')\n else:\n print('Yes')\nelif n == 2:\n if s == '00' or s == '11':\n print('No')\n else:\n print('Yes')\nelse:\n if s.find('11') + 1 or s.find('000') + 1:\n print('No')\n elif s.find('00') == 0 or s.rfind('00') == n - 2:\n print('No')\n else:\n print('Yes')\n"}, {"source_code": "n=int(input())\ns=input()\ns='0'+s+'0'\n\nx,y=s.find('000'),s.find('11')\nif x==-1 and y==-1:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "n = int(input())\ns = input()\nif '000' in s or '11' in s or s == '0' or s.startswith('00') or s.endswith('00'):\n print('No')\nelse:\n print('Yes')"}, {"source_code": "n = int(input())\ns = '0' + input() + '0'\n\nif s == '0':\n\tprint(\"No\")\nif '11' in s or '000' in s:\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")"}, {"source_code": "# def neighbour_similar(index, chairs):\n# prev = False\n# if index > 0:\n# prev = chairs[index-1] == chairs[index]\n# forw = False\n# if index < (len(chairs) -1):\n# forw = chairs[index+1] == chairs[index]\n# return (prev or forw)\n\n# def maximal_chairs(n, chairs):\n# if ((len(chairs) > 1) and (n >= (len(chairs) - 1))):\n# return 'Yes'\n# else:\n# if len(chairs) == 1:\n# if chairs == '1':\n# return 'Yes'\n# else:\n# return 'No'\n# elif neighbour_similar(n, chairs):\n# return 'No'\n# else:\n# chairs_change = chairs[0:n]+'1'+chairs[n+1:]\n# is_change = neighbour_similar(n, chairs)\n# if is_change == 'No':\n# return maximal_chairs(n+1, chairs)\n# return 'No'\ndef maximal_chairs(n, chairs):\n if n == 1:\n if chairs == '0':\n return 'No'\n else:\n return 'Yes'\n if n == 2:\n if chairs == '00' or chairs == '11':\n return 'No'\n else:\n return 'Yes'\n\n for k in range(n-1):\n if chairs[k] == chairs[k+1] and chairs[k] == '1':\n return 'No'\n for i in range(n):\n if chairs[i] == '0':\n new_chairs = chairs[0:i] + '1' + chairs[i+1:]\n isChange = True\n for j in range(n-1):\n if new_chairs[j] == new_chairs[j+1] and new_chairs[j] == '1':\n isChange = False\n break\n if isChange:\n return 'No'\n return 'Yes'\n\nn = int(raw_input())\nbit_chairs = raw_input()\n\nprint maximal_chairs(n, bit_chairs)\n\n\n# print maximal_chairs(0, bit_chairs)\n"}, {"source_code": "def maximal_chairs(n, chairs):\n if n == 1:\n if chairs == '0':\n return 'No'\n else:\n return 'Yes'\n if n == 2:\n if chairs == '00' or chairs == '11':\n return 'No'\n else:\n return 'Yes'\n\n for k in range(n-1):\n if chairs[k] == chairs[k+1] and chairs[k] == '1':\n return 'No'\n for i in range(n):\n if chairs[i] == '0':\n new_chairs = chairs[0:i] + '1' + chairs[i+1:]\n isChange = True\n for j in range(n-1):\n if new_chairs[j] == new_chairs[j+1] and new_chairs[j] == '1':\n isChange = False\n break\n if isChange:\n return 'No'\n return 'Yes'\n\nn = int(raw_input())\nbit_chairs = raw_input()\n\nprint maximal_chairs(n, bit_chairs)"}, {"source_code": "n = input()\ns = raw_input()\nif n == 1:\n if s[0] == '1':\n print \"Yes\"\n else:\n print \"No\"\nelif n == 2:\n if s[0] == s[1]:\n print \"No\"\n else:\n print \"Yes\"\nelse:\n p = 0\n for i in range(len(s)-1):\n if i == 0:\n if s[i] == s[i+1]:\n p = 1\n print \"No\"\n break\n elif i == len(s)-2:\n if s[i] == s[i+1]:\n p = 1\n print \"No\"\n break\n else:\n if s[i] == s[i+1] and s[i] == s[i-1]:\n p = 1\n print \"No\"\n break\n elif s[i] == s[i+1] and s[i] == '1':\n p = 1\n print \"No\"\n break\n elif s[i] == s[i-1] and s[i] == '1':\n p = 1\n print \"No\"\n break\n if not p:\n print \"Yes\""}, {"source_code": "m = input()\ns = raw_input()\n\nif ('11' in s) or s.startswith('00') or s.endswith('00') or ('000' in s) or s=='0':\n print \"No\"\nelse:\n print \"Yes\" "}, {"source_code": "n=input()\nst=str(raw_input())\nans=1\nst=\"0\"+st+\"0\"\nfor i in range(1,n+1):\n if st[i]==\"1\":\n if st[i+1]==\"1\" or st[i-1]==\"1\":\n ans=0 \n if st[i]==\"0\":\n if st[i+1]==\"0\" and st[i-1]==\"0\":\n ans=0 \nif ans==1:\n print \"yes\"\nelse:\n print \"no\""}, {"source_code": "n = int(input().strip())\na = input().strip()\n\nflag = False\nif n == 1 and a[0] == '0':\n flag = True\nelif n > 1:\n for i in range(n-1):\n if a[0] == a[1] or a[n - 2] == a[n - 1]:\n flag = True\n if a[i+1] == a[i] == '1':\n flag = True\n break\n if a[i+1] == a[i] == a[i-1] == '0':\n flag = True\n break\nif not flag:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "import sys\nfrom sys import stdin, stdout\nfrom collections import deque\n\nrem=10**9+7\nsys.setrecursionlimit(10 ** 6)\ntake = lambda: map(int, stdin.readline().split())\n\nn=input()\narr=raw_input()\nif '11' in arr:\n print 'No'\n exit()\nfor i in range(n):\n new=arr\n new=list(new)\n if new[i]=='0':\n new[i]='1'\n if '11' not in ''.join(new):\n print 'No'\n exit()\nprint 'Yes'"}, {"source_code": "n = int(input())\ns = input()\nf = 0\nif n==1 and s=='0':\n print('No')\nelif n==2 and s[0]==s[1]:\n print('No')\nelse:\n for i in range(1,n-1):\n if s[i+1]==s[i-1] and s[i+1]==s[i]:\n f=1\n break\n elif s[i]=='1' and (s[i-1]=='1' or s[i+1]=='1'):\n f=1\n break\n if f==0:\n if s[0]=='0' and s[1]=='0':\n print('No')\n elif s[-1]=='0' and s[-2]=='0':\n print('No')\n else:\n print(\"Yes\")\n\n else:\n print('No')"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn = int(input())\nA = [c=='1' for c in input()]\n\npos = True\nfor i in range(n):\n if not A[i]:\n continue\n if i>0 and A[i-1]:\n pos = False\n if i<n-1 and A[i+1]:\n pos = False\nfor i in range(n):\n if A[i]:\n continue\n if (i==0 or not A[i-1]) and (i==n-1 or not A[i+1]):\n pos = False\nif pos:\n print 'Yes'\nelse:\n print 'No'\n"}, {"source_code": "n = int(raw_input())\naceito = True\nstring = raw_input()\nstring = '0' + string + '0'\ncont = 0\n\nfor i in range(1,n+1):\n\t\n\t\n\tif string[i] == '1':\n\t\t\n\t\tcont = 0\n\t\n\t\tif string[i-1] == '1' or string[i+1] == '1':\n\t\t\t\n\t\t\taceito = False\n\t\t\tbreak\n\t\t\t\n\t\n\tif string[i] == '0':\n\t\t\n\t\tcont += 1\n\t\t\n\t\t\n\tif cont > 2:\n\t\t\n\t\taceito = False\n\t\tbreak\n\n\nif string[1] == '0' and string[2] == '0':\n\t\n\taceito = False\n\t\nif string[n -1] == '0' and string[n] == '0':\n\t\n\taceito = False\t\t\n\t\t\nif aceito:\n\t\n\tprint 'YES'\n\t\nelse:\n\t\n\tprint 'NO'\n"}, {"source_code": "#[int(k) for k in raw_input().split(\" \")]\nn=int(raw_input())\ns=\"0\"+raw_input()+\"0\"\nres=\"Yes\"\nfor k in range(1,n+1):\n if s[k-1:k+2]==\"000\":\n res=\"No\"\n break\n if s[k:k+2]==\"11\":\n res=\"No\"\n break\n\nprint res\n"}, {"source_code": "import sys\n\nn = int(raw_input())\n\na = raw_input()\n\nlast = '0'\nsame = 1\n\nfor e in a:\n\tif e == last:\n\t\tsame += 1\n\n\t\tif e == '1' or same > 2:\n\t\t\tprint \"No\"\n\t\t\tsys.exit()\n\telse:\n\t\tsame = 1\n\t\tlast = e\n\nif same > 1 and last == '0':\n\tprint \"No\"\nelse:\n\tprint \"Yes\""}, {"source_code": "n = int(input())\na = '0'+input()+'0'\nif '000' in a or '11' in a:print('No')\nelse:print('Yes')"}, {"source_code": "n = int(input())\ns = str(input())\nif n == 1 and s[0] == '1':\n print(\"Yes\")\n exit()\nelif n == 1 and s[0] == '0':\n print(\"No\")\n exit()\nelif n == 2:\n if s == \"01\" or s == \"10\":\n print(\"Yes\")\n exit()\n else:\n print(\"No\")\n exit()\nelif n%2 == 0:\n for i in range(n-2):\n if (s[i] == '1' and s[i+1] == '1') or (s[i+1] == '1' and s[i+2] == '1') or (s[i] == '0' and s[i+1] == '0' and s[i+2] =='0'):\n print(\"No\")\n exit()\n if (s[-1] == '0' and s[-2] == '0') or (s[0] == '0' and s[1] == '0'):\n print(\"No\")\n else:\n print(\"Yes\")\nelse:\n for i in range(n-2):\n if (s[i] == '1' and s[i+1] == '1') or (s[i+1] == '1' and s[i+2] == '1') or (s[i] == '0' and s[i+1] == '0' and s[i+2] == '0'):\n print(\"No\")\n exit()\n if (s[-1] == '0' and s[-2] == '0') or (s[0] == '0' and s[1] == '0'):\n print(\"No\")\n else:\n print(\"Yes\")\n \n"}, {"source_code": "n = raw_input()\nstr = raw_input()\nif str == '0' or '11' in str or '000' in str or str.startswith('00') or str.endswith('00'):\n\tprint 'No'\nelse:\n\tprint 'Yes'"}, {"source_code": "class CodeforcesTask982ASolution:\n def __init__(self):\n self.result = ''\n self.seating = ''\n\n def read_input(self):\n input()\n self.seating = input()\n\n def process_task(self):\n if \"11\" in self.seating:\n self.result = \"No\"\n else:\n if \"000\" in self.seating:\n self.result = \"No\"\n elif len(self.seating) > 1:\n if \"00\" in self.seating[:2]:\n self.result = \"No\"\n elif \"00\" in self.seating[-2:]:\n self.result = \"No\"\n else:\n self.result = \"Yes\"\n else:\n if \"0\" in self.seating:\n self.result = \"No\"\n else:\n self.result = \"Yes\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask982ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "chairCount = int(raw_input())\n\nseated = raw_input()\n\nprevOpen = True\n\nfor seat in range(chairCount):\n\tif seated[seat] == '0' and prevOpen and (seat==chairCount-1 or seated[seat+1] =='0'):\n\t\tprint 'No'\n\t\tquit()\n\tif seated[seat] =='1':\n\t\tif prevOpen==False:\n\t\t\tprint 'No'\n\t\t\tquit()\n\t\tprevOpen = False\n\tif seated[seat] == '0':\n\t\tprevOpen=True\nprint 'Yes'\n"}, {"source_code": "n=input()\nf=0\ns=raw_input()\ncnt=0\nif (n==1 and s[0]=='0'):\n print \"No\"\n exit(0)\ns='0'+s+'0'\nfor i in range(len(s)-1):\n if (s[i]=='1' and s[i+1]=='1'): f=1\nfor i in range(len(s)-2):\n if (s[i]=='0' and s[i+1]=='0' and s[i+2]=='0'): f=1\n\nif (f==0):\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "n=int(input())\ns=input()\nans=\"Yes\"\nif n==1 and s=='0':\n ans=\"No\"\nif n==1 and s=='1':\n ans=\"Yes\"\nif s.count(\"000\")>0:\n ans=\"No\"\nif s.count(\"11\")>0:\n ans=\"No\"\nif s[:2]==\"00\":\n ans=\"No\"\nif s[-2:]==\"00\":\n ans=\"No\"\nprint(ans)\n"}, {"source_code": "a=int(input())\nb=input()\nc=0\nc1=0\nc2=0\nfor i in range(a-1):\n if(b[i]==b[i+1]=='1'):\n c+=1\nif(a>=2):\n if(b[a-1]==b[a-2]=='0' or b[0]==b[1]=='0'):\n c2+=1\nfor i in range(a-2): \n if(b[i]==b[i+1]==b[i+2]=='0'):\n c1+=1\n if(c1>=1):\n break\n#print(c)\n#print(c1)\nif(c>=1 or c1>=1 or c2>=1 or (a==1 and b[0]=='0')):\n print('NO')\nelse:\n print('YES') "}, {"source_code": "k = int(input())\na = input()\nif (a.count('11') >= 1 or a.count('000') >= 1) == 1:\n print('No')\nelif (k == 1) and (a[0] == '0'):\n print('No')\nelif (k >= 2) and(a[0] + a[1] == '00' or a[-1] + a[-2] == '00'):\n print('No')\nelse:\n print('Yes')\n"}, {"source_code": "n = int(input())\nlis = '0' + input() + '0'\nif ('000' not in lis) and ('11' not in lis):\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "input()\ns = \"0\"+input()+\"0\"\nprint(\"NO\" if (\"000\" in s or \"11\" in s) else \"YES\")"}, {"source_code": "t = input()\na = raw_input()\n\nif t >=3:\n if '000' in a or '11' in a:\n print 'No'\n\n else:\n if a[0] == '0' and a[1] == '0' and a[2] != '0':\n print 'No'\n else:\n if a[t-1] == '0' and a[t-2] == '0' and a[t-3]!= '0':\n print 'No'\n else:\n print 'Yes'\nelse:\n if t == 1:\n if '0' in a:\n\t print 'No'\n\telse:\n\t print 'Yes'\n if t == 2:\n\tif '10' in a or '01' in a:\n\t print 'Yes'\n\telse:\n\t print 'No'\n"}, {"source_code": "input()\ns=input()\nf=1\nif len(s)>1:\n for i in range(len(s)):\n if s[i]=='0':\n if i==0 and s[i+1]=='0': f=0 ; break\n elif i==len(s)-1 and s[i-1]=='0': f=0;break\n elif s[i-1]=='0' and s[i+1]=='0': f=0;break\n else:\n if i!=len(s)-1 and s[i+1]=='1': f=0 ; break\n elif i!=0 and s[i-1]=='1': f=0;break \nif f==1 and s!='0': print('Yes')\nelse: print('No')\n\n##//////////////// ////// /////// // /////// // // //\n##//// // /// /// /// /// // /// /// //// //\n##//// //// /// /// /// /// // ///////// //// ///////\n##//// ///// /// /// /// /// // /// /// //// // //\n##////////////// /////////// /////////// ////// /// /// // // // //\n\n\n\n"}, {"source_code": "n=int(input())\na=list(input())\ndis=[]\nfor i in range(n):\n if a[i]==\"1\":\n dis.append(i)\nif n==1:\n if a[0]==\"0\":\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n bbbb=1\n if a[0]==a[1]:\n if a[i]==\"0\":\n bbbb=0\n \n if bbbb==0:\n print(\"NO\")\n else:\n \n pre=0\n pdis=[]\n for i in range(len(dis)):\n pdis.append(dis[i]-pre)\n pre=dis[i]\n pdis.append(n-1-dis[-1])\n bb=1\n for i in range(1,len(pdis)-1):\n if (pdis[i]<2 or pdis[i]>3):\n bb=0\n \n break\n \n if bb==1 and pdis[0]<2 and pdis[-1] <2:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "import re\nn = input()\ns = raw_input()\nif n>=2:\n\tif s[:2]=='00' or s[-2:]=='00':\n\t\tprint 'NO'\n\t\texit(0)\nif n==1:\n\tif s=='1':\n\t\tprint 'Yes'\n\telse:\n\t\tprint 'NO'\n\texit(0)\np1 = re.compile(r'0+')\na = max(map(len,p1.findall(s))+[0])\nb = max(map(len,p1.split(s))+[0])\nif a>2 or b>1:\n\tprint 'No'\nelse:\n\tprint 'Yes'"}, {"source_code": "n=input()\ns=raw_input()\nif n==1:\n\tif s=='0':\n\t\tprint 'No'\n\telse:\n\t\tprint 'Yes'\nelif (s[0]=='0' and s[1]=='0') or (s[-1]=='0' and s[-2]=='0'):\n\tprint 'No'\nelse:\n\tflag = True\n\ton=0\n\tzer=0\n\tfor i in s:\n\t\tif i=='0':\n\t\t\tzer+=1\n\t\t\ton=0\n\t\t\tif zer ==3:\n\t\t\t\tflag = False\n\t\tif i=='1':\n\t\t\ton+=1\n\t\t\tzer=0\n\t\t\tif on ==2:\n\t\t\t\tflag = False\n\tprint [\"No\",\"Yes\"][flag]\n"}, {"source_code": "def solve(s):\n\t#print len(s)\n\tif len(s) == 1:\n\t\treturn s == \"1\"\n\tif s[0] == \"0\" and s[1] == \"0\":\n\t\treturn False\n\tif s[len(s) - 1] == \"0\" and s[len(s) - 2] == 0:\n\t\treturn False\n\n\tinit = 0 \n\twhile(s[init] != \"1\"):\n\t\tinit += 1\n\n\ti = init\n\twhile(i < len(s)):\n\t\t#print i\n\t\tif s[i] == \"1\" and i != len(s) - 1:\n\t\t\tfirst = i + 1\n\t\t\t#print first\n\t\t\twhile(first < len(s) and s[first] != \"1\"):\n\t\t\t\t#print first\n\t\t\t\tfirst += 1\n\t\t\t\n\t\t\t#print first, i\n\t\t\tif first == len(s) and s[first-1] == \"0\" and s[first-2] == \"0\":\n\t\t\t\treturn False\n\t\t\tif (first - i > 3 or first - i == 1) and first < len(s):\n\t\t\t\t\n\t\t\t\t#print first, i\n\t\t\t\treturn False\n\t\t\ti = first\n\t\telse:\n\t\t\ti += 1\n\treturn True\n\nn = int(raw_input())\ns = raw_input()\n\nif solve(s):\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "\nn = int(input())\ns = '0' + input() + '0'\n\nfor i in range(1 , n + 1):\n\n if s[i] == '0':\n if s[i + 1] == '0' and s[i - 1] == '0':\n print('No')\n exit()\n\n else:\n if s[i + 1] == '1' or s[i - 1] == '1':\n print('No')\n exit()\n\nprint('Yes')\n\n\n\n"}, {"source_code": "x=int(input())\nstr=\"0\"+input()+\"0\"\nif '000' in str:\n print(\"No\")\nelif '11' in str:\n print(\"No\")\n\nelse:\n print(\"Yes\")"}, {"source_code": "import sys\ndata = sys.stdin.readlines()[1]\n\nestado = 'Yes'\n\nif data == '0\\n' or data == '00\\n':\n\t#print(1)\n\testado = 'No'\nif ('100\\n' in data):\n\t#print(2)\n\testado = 'No'\nif ('001') == data[0:3]:\n\t#print(3)\n\testado = 'No'\nif '11' in data:\n\t#print(4)\n\testado = 'No'\nif '000' in data:\n\t#print(5)\n\testado = 'No'\n\nprint(estado)\n"}, {"source_code": "a=int(input())\nb=input()\ns='10'*a\nif a==1:\n if b=='1':\n print('yes')\n else:\n print('No')\nelif a==2:\n if b=='10' or b=='01':\n print('yes')\n else:\n print('no')\nelif a==3:\n if b=='010' or b=='101':\n print('yes')\n else:\n print('no')\nelif a==4:\n if b==s[:a]:\n print('yes')\n elif '1001' in b:\n print('yes')\n elif '0101' in b:\n print(\"yes\")\n else:\n print('no')\n\nelse:\n if '000' in b:\n print('no')\n elif '11' in b:\n print('no')\n elif b[-2::1]=='00':\n print('no')\n else:\n print('yes')\n\n \n"}, {"source_code": "def solve(d):\n if len(d) == 1:\n return d[0] == '1'\n if d[:2] == '00' or d[-2:] == '00':\n return False\n prev = d[0]\n sublen = 0\n for c in d[1:]:\n if c == prev:\n sublen += 1\n if c == '0' and sublen == 2:\n return False\n if c == '1':\n return False\n else:\n sublen = 0\n prev = c\n return True\n\n\nfrom sys import stdin\n_, data = stdin.readline(), stdin.readline()\nprint(solve(data[:-1]) and 'Yes' or 'No')"}, {"source_code": "n=int(input())\ns=input()\nflg=0\ncnt=0\nif s[0]=='0' and n==1:\n print('No')\n flg=1\nelse:\n for i in range(n-1):\n if s[i]=='1' and s[i+1]=='1':\n print('No')\n flg=1\n break\n if s[i]=='0' and s[i+1]=='0' and i+1==n-1:\n print('No')\n flg=1\n break\n elif s[i]=='0' and i==0:\n cnt+=2\n if cnt>=3:\n print('No')\n flg=1\n break\n elif s[i]=='0':\n cnt+=1\n if cnt>=3:\n print('No')\n flg=1\n break\n else:\n cnt=0\nif flg==0:\n print('Yes')"}, {"source_code": "n = int(input())\ns = '0' + input() + '0'\n\nif s == \"00\":\n print(\"No\")\n\nelse:\n if \"000\" in s or \"11\" in s:\n print(\"No\")\n else:\n print(\"Yes\")"}, {"source_code": "# Codeforces 982A: Row\n\ndef is_maximal(n, s):\n if s == \"0\": \n return False\n if s == \"1\":\n return True\n if n >= 2 and (s[0:2] == \"00\" or s[-2:n] == \"00\"):\n return False\n for i in xrange(n - 1):\n if s[i] == s[i + 1] == '1':\n return False\n if i + 2 < n and s[i] == s[i + 1] == s[i + 2] == '0':\n return False\n return True\n\nn = int(raw_input())\ns = raw_input()\n\nprint 'Yes' if is_maximal(n, s) else 'No'"}, {"source_code": "n = int(input())\ns = '0'+input()+'0'\nans = 'No' if '000' in s or '11' in s else 'Yes'\nprint(ans)\n"}, {"source_code": "n = input()\ns = '0' +raw_input() + '0'\nif '000' in s or '11' in s:\n print 'No'\nelse:\n print 'Yes'"}, {"source_code": "n = int(input())\na = '#' + input().strip() + '#'\nans = 'Yes'\nif n == 1 and a[1] == '0':\n ans = 'No'\nelse:\n for i in range(1, n + 1):\n if a[i] == '1':\n if a[i - 1] == '1' or a[i + 1] == '1':\n ans = 'No'\n break\n else:\n if (a[i - 1] == '0' or a[i - 1] == '#') and (a[i + 1] == '0' or a[i + 1] == '#'):\n ans = 'No'\n break\n\nprint(ans)\n"}, {"source_code": "# kon bodmaish hack krce.....aj coding parina ble......shb thikace..khali ak jaygay output duibar print hoy (-.-)\n\ndef khela(kaj):\n if '11' in str(kaj):\n return 0\n else:\n return 1\n\n\na=int(input())\nb= input()\nli1=list(b)\nli2= list(li1)\nc= khela(str(b))\n\n\nxx=0\nif c==0:\n fino= 'NO'\n xx=1\n\nif c==1:\n for i in range(a):\n li1= list(li2)\n if li1[i]=='0':\n li1[i]='1'\n checking= ''.join(ii for ii in li1)\n #print(checking)\n huha= khela(str(checking))\n if huha==1:\n fino= 'NO'\n xx=1\n \n li1= list(li2)\nif xx==0:\n fino= 'YES'\nprint(fino)\n"}, {"source_code": "def fn(s):\n\ts = ''.join(('0', s, '0'))\n\tt = 0\n\tfor i, c in enumerate(s):\n\t\tif c == '0':\n\t\t\tt += 1\n\t\t\tif t > 2:\n\t\t\t\tprint \"No\"\n\t\t\t\treturn\n\t\telse:\n\t\t\tif t == 0:\n\t\t\t\tprint \"No\"\n\t\t\t\treturn\n\t\t\tt = 0\n\tprint \"Yes\"\n\t\nif __name__ == '__main__':\n\tn = raw_input()\n\ts = raw_input()\n\tfn(s)"}, {"source_code": "n = int(raw_input())\nseating = raw_input()\nanswer = \"Yes\"\noneCount = 0\nzeroCount = 0\n\nif seating == '0': answer = \"No\"\n\nif n > 2 and (seating[0] == seating[1]):\n answer = \"No\"\n\nfor i in range(n):\n if seating[i] == '0':\n zeroCount += 1\n oneCount = 0\n else:\n oneCount += 1\n zeroCount = 0\n\n if zeroCount == 3:\n answer = \"No\"\n elif oneCount == 2:\n answer = \"No\"\n\nif zeroCount == 2: answer = \"No\"\n\nprint answer\n"}, {"source_code": "def assento(qnt, binario):\n igual1 = 0\n igual0 = 0\n no = 0\n if(binario==\"0\"):\n print(\"No\")\n else:\n for i in range(qnt):\n if(binario[i]==\"1\"):\n igual1 = igual1+1\n igual0 = 0\n else:\n if((binario[i]==\"0\") and (i==0 or i==(qnt-1))):\n igual0 = igual0+1 \n igual0 = igual0+1\n igual1 = 0\n if(igual1 >= 2):\n no=1\n break\n if(igual0 >= 3):\n no=1\n break\n if(no==0):\n print(\"Yes\")\n else:\n print(\"No\")\n\nqnt = int(raw_input())\nbinario = raw_input()\nassento(qnt, binario)"}, {"source_code": "def main():\n n = int(input())\n s = input()\n\n if n == 1 and s[0] == '0':\n print('No')\n return\n\n if n >= 2:\n if (s[0] == s[1] == '0') or (s[0] == s[1] == '1') or \\\n (s[n-1] == s[n-2] == '0') or (s[n-1] == s[n-2] == '1'):\n print('No')\n return\n\n for i in range(1, n - 1):\n p, c, n = map(int, (s[i-1], s[i], s[i+1]))\n if (c == 1 and (p == 1 or n == 1)) or (c == 0 and p == 0 and n == 0):\n print('No')\n return\n\n print('Yes')\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "def row(qnt, binario):\n igual1 = 0\n igual0 = 0\n no = 0\n if(binario == \"0\"):\n print(\"No\")\n else:\n for i in range(qnt):\n if(binario[i]==\"1\"):\n igual1 = igual1+1\n igual0 = 0\n else:\n if((binario[i]==\"0\") and (i==0 or i==(qnt-1))):\n igual0 = igual0+1 \n igual0 = igual0+1\n igual1 = 0\n if(igual1 >= 2):\n no=1\n break\n if(igual0 >= 3):\n no=1\n break\n if(no==0):\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nqnt = int(raw_input())\nbinario = raw_input()\nrow(qnt, binario)"}], "negative_code": [{"source_code": "#!/usr/bin/env python3\n# -*- encoding: utf-8 -*-\n\nimport sys\n\ndef main():\n n = int(sys.stdin.readline())\n l = [int(i) for i in sys.stdin.readline().strip()]\n\n if l == [0]:\n print('No')\n return\n\n for i in range(n-1):\n if l[i] + l[i+1] == 2 or sum(l[i:i+3]) == 0:\n print('No')\n return\n print('Yes')\n\nmain()\n"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nres = True\ncount = 0\nwhile(i<n):\n if s[i]=='1':\n if count>2 or (i!=0 and count==0):\n res = False\n break\n count=0\n else:\n count+=1\n i+=1\nif count>2:\n res = False\nif res:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "import sys\n\n\nstdin = sys.stdin\n\nn = int(stdin.readline())\nseats = stdin.readline()\n\nif n < 3:\n print(\"No\")\n exit(0)\nfor i in range(n):\n if i < n-1 and seats[i:i+2] == '11':\n print(\"No\")\n exit(0)\n if i < n-2 and seats[i:i+3] == '000':\n print(\"No\")\n exit(0)\nprint(\"Yes\")"}, {"source_code": "import re\nn=int(input())\ns=input()\na=re.search('000',s)\n#print(a)\nb=re.search('11',s)\n#print(a,b)\nif s=='0':\n print(\"NO\")\nelif s=='00':\n print(\"NO\")\nelse:\n if a or b:\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "n=int(input())\na=str(input())\na=list(a)\nfor i in range(n):\n a[i]=int(a[i])\nk=0\nif n==1 and a[0]==0:\n k=k+1 \nfor i in range(1,n):\n if a[i-1]==a[i] and a[i]==a[i-1]!=0:\n k=k+1\nif k==0:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "n=int(input())\na=str(input())\na=list(a)\nfor i in range(n):\n a[i]=int(a[i])\nk=0\nif n==1 and a[0]==0:\n k=k+1 \nfor i in range(1,n):\n if a[i-1]==a[i] and a[i]==a[i-1]!=0:\n k=k+1\nif k==0:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "\nk = int(input())\n\ns = input()\nfor i in range(1,len(s)):\n if(int(s[i])+int(s[i-1]) == 2) :\n print('No')\n exit()\nfor i in range(1,len(s)-1):\n if(s[i] == '0' and s[i-1]=='0' and s[i+1]==0) :\n print('No')\n exit()\nif(len(s)>=2):\n if(s[0]==s[1]=='0' or s[len(s)-1]==s[len(s)-2]=='0'):\n print('No')\n exit()\n \nprint('Yes')\n"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline().strip()) + 1\n\ndef sol(n):\n\tif n == 1 or n == 2:\n\t\treturn n-1 \n\telif n%2 == 0:\n\t\treturn n//2\n\telse:\n\t\treturn n\n\nprint(sol(n))"}, {"source_code": "def solve(s):\n\t#print len(s)\n\tif len(s) == 1:\n\t\treturn s == \"1\"\n\tif s[0] == \"0\" and s[1] == \"0\":\n\t\treturn False\n\tif s[len(s) - 1] == \"0\" and s[len(s) - 2] == 0:\n\t\treturn False\n\n\tinit = 0 \n\twhile(s[init] != \"1\"):\n\t\tinit += 1\n\n\ti = init\n\twhile(i < len(s)):\n\t\t#print i\n\t\tif s[i] == \"1\":\n\t\t\tfirst = i + 1\n\t\t\t#print first\n\t\t\twhile(first < len(s) and s[first] != \"1\"):\n\t\t\t\t#print first\n\t\t\t\tfirst += 1\n\t\t\t\n\t\t\tif first == len(s):\n\t\t\t\treturn False\n\t\t\tif (first - i > 3 or first - i == 1) and first < len(s):\n\t\t\t\t#print first, i\n\t\t\t\treturn False\n\t\t\ti = first\n\t\telse:\n\t\t\ti += 1\n\treturn True\n\nn = int(raw_input())\ns = raw_input()\n\nif solve(s):\n\tprint \"Yes\"\nelse:\n\tprint \"No\""}, {"source_code": "n = int(input())\ns = input()\n\nif s == \"00\":\n print(\"No\")\n\nelse:\n for i in range(1, n):\n if s[i] == s[i - 1] == '1' or (i < n - 1 and s[i + 1] == s[i] == s[i - 1] == '0'):\n print(\"No\") \n break\n else:\n print(\"Yes\")"}, {"source_code": "n=int(input())\ns=input().strip()\nc=s.count(\"1\")\nif n%2==0:\n t=n//2\nelse:\n t=n//2+1\nif c==t:\n flag=1\n curr=int(s[0])\n for i in range(1,n):\n if curr^int(s[i])==0:\n flag=0 \n break\n curr=int(s[i])\n if flag==1:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")"}, {"source_code": "num = input() \narr = raw_input()\nans = 'Yes'\n\nif len(arr) == 1:\n\tif arr[0] == '0':\n\t\tans = 'No'\n\nfor i in range(1,len(arr)):\n\tif arr[i] == '1' or (arr[i] == '0' and (i < 2 or i == len(arr)-1)):\n\t\tif arr[i-1] == arr[i]:\n\t\t\tans = '1'\n\t\t\tprint arr[i]\n\t\t\tprint \"i: \" + str(i) \n\t\t\tbreak\n\telif i > 3:\n\t\tif arr[i-1] == arr[i-2]:\n\t\t\tans = '2'\n\t\t\tbreak\n\nprint ans\n\n"}, {"source_code": "n = int(input())\ns = input()\ne = s.count(\"000\")\nr = s.count(\"11\")\nif (e > 0 or r > 0):\n print(\"No\")\n\nelse:\n print(\"Yes\")"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n-1):\n if s[i]==s[i+1]=='1':\n print('No')\n from sys import exit\n exit()\nprint('Yes')"}, {"source_code": "n = int(input())\nflag = True\na = input()\nfor i in range(1,n-1):\n if a[i] == '1':\n if a[i-1] == '1' or a[i+1] == '1':\n print(\"No\")\n flag = False\n break\n if a[i] == '0':\n if a[i - 1] == '0' and a[i + 1] == '0':\n print(\"No\")\n flag = False\n break\nif a == '0' or a == '11' or a == '10' or a == '01' or a[n-1] == '0' and a[n-2] == '0':\n flag = False\n print(\"No\")\nif flag or a == '00':\n print(\"Yes\")\n\n"}, {"source_code": "num = input() \narr = raw_input()\nans = 'Yes'\n\nif len(arr) == 1:\n\tif arr[0] == '0':\n\t\tans = 'No'\n\nfor i in range(1,len(arr)):\n\tif arr[i] == '1' or (arr[i] == '0' and i < 3):\n\t\tif arr[i-1] == arr[i]:\n\t\t\tans = 'No'\n\t\t\tbreak\n\telif i > 3:\n\t\tif arr[i-1] == arr[i-2]:\n\t\t\tans = 'No'\n\t\t\tbreak\n\nprint ans\n\n"}, {"source_code": "\n\nn=int(input())\ns=str(input())\nif n==1:\n if s==\"0\":\n print(\"No\")\n else:\n \n print(\"Yes\")\nelif n==2:\n if s[0]!=s[1]:\n print('Yes')\n elif s[0]==s[1]==\"0\":\n print(\"No\")\n else:\n print(\"Yes\")\nelif n==3:\n if s[0]==s[2] and s[0]!=s[1]:\n print(\"Yes\")\n\n else:\n print(\"No\")\nelse:\n an=True\n for i in range(n-2):\n if s[i]!=s[i+2]:\n an=False\n print(\"No\")\n break\n if an==True:\n print(\"Yes\")\n \n"}, {"source_code": "n=input()\ns=raw_input()\nprint ('No','Yes')[(n>2 and '11' not in s and '000' not in s) or s=='01' or s=='10']"}, {"source_code": "n = int(input())\ns = input()\n\n\n\nfirst = -1\nsecond = -1\nminimum = 9999999\nmaximum = 0\n\n\ndef check_val(value):\n\n if(value==2 or value==3):\n return True\n else:\n return False\n\n\npossible = ['1','01','10','010']\n\nif(s in possible):\n print('YES')\nelse:\n for i in range(n):\n\n if(int(s[i])==1):\n first = second\n second = i\n diff = second - first\n\n if(first>-1):\n\n if(diff>maximum):\n maximum = diff\n if(diff<minimum):\n minimum = diff\n \n \n r = n-1-second\n l = s.index('1')\n if(first>-1):\n if(r>maximum):\n maximum =r\n if(r<minimum):\n minimum = r\n if(l>maximum):\n maximum =l\n if(l<minimum):\n minimum = l\n \n \n \n\n if(check_val(maximum) and check_val(minimum)):\n print('YES')\n else:\n print('NO')\n\n\n\n"}, {"source_code": "n=int(input())\ns=input()\nm,c=0,0\nif(n<=2):\n if n==1 and s[0]=='1':\n print('yes')\n if n==1 and s[0]=='0':\n print('no')\n if n==2 and s in ['10','01']:\n print('yes')\n else:\n print('no')\nelse:\n if s[:2]=='00' or s[n-2:] in ['00','11']:\n print('no')\n else:\n f=1\n for i in range(n-2):\n if s[i:i+3]=='000' or s[i:i+2]=='11':\n f=0\n print('no')\n break\n if f==1:\n print('yes')\n \n\n "}, {"source_code": "n = int(input())\ns = input()\nif n == 1 and s == '0':\n print('No')\nelse:\n for i in range(n - 1):\n if s[i] + s[i + 1] != '01' and s[i] + s[i + 1] != '10':\n print('No')\n break\n else:\n print('Yes')"}, {"source_code": "n=int(input())\na=input()\nx=a.count('0')\nif \"000\" in a or \"11\" in a or x==n:\n print(\"No\")\n exit(0)\nprint(\"Yes\")\n "}, {"source_code": "n = int(input())\ns = str(input())\nif n%2 == 0:\n for i in range(n-1):\n if s[i] == s[i+1]:\n print(\"No\")\n exit()\n print(\"Yes\")\nelse:\n if s[0] == '1' and s[-1] == '1':\n for i in range(n-1):\n if s[i] == s[i+1]:\n print(\"No\")\n exit()\n print(\"Yes\")\n else:\n print(\"No\")\n \n"}, {"source_code": "import sys\ndata = sys.stdin.readlines()[1]\n\nestado = 'Yes'\n\nif data == '0\\n':\n\testado = 'No'\n\nif '11' in data:\n\testado = 'No'\n\nif '000' in data:\n\testado = 'No'\n\n\nprint(estado)\n"}, {"source_code": "n=int(input())\ns=input()\nf=0\nif len(s)==1:\n print(\"YES\")\nelse:\n \n for i in range(len(s)-1):\n if s[i]==s[i+1]:\n f=1\n break\n if f==1:\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "n = input()\ns = raw_input()\nif(('11' not in s) and ('000' not in s)): print(\"Yes\")\nelse: print(\"No\")"}, {"source_code": "def print_return(func):\n def wrapper(*args, **kwargs):\n retval = func(*args, **kwargs)\n print(retval)\n return retval\n\n return wrapper\n\n\nclass Solve:\n @print_return\n def solve_a(self, rest=None):\n if rest is None:\n n = int(input())\n state = input()\n else:\n lines = rest.split('\\n')\n n = int(lines[0].strip())\n state = lines[1].strip()\n ans = 'Yes'\n for place in range(1, n - 1):\n if state[place] == '1':\n if state[place - 1] == '1' or state[place + 1] == '1':\n ans = 'No'\n break\n if state[place] == '0':\n if state[place - 1] == '0' and state[place + 1] == '0':\n ans = 'No'\n break\n if n == 1 and state[0] == '0':\n ans = 'No'\n elif n == 1 and state[0] == '1':\n ans = 'Yes'\n elif state[0] == '0' and state[1] == '0':\n ans = 'No'\n elif state[-1] == '0' and state[-2] == '0':\n ans = 'No'\n return ans\n\n\n def solve_b(self):\n pass\n\n def solve_c(self):\n pass\n\n def solve_d(self):\n pass\n\n def solve_e(self):\n pass\n\n def solve_f(self):\n pass\n\n\nif __name__ == '__main__':\n s = Solve()\n s.solve_a()\n"}, {"source_code": "import sys\n\nn = input()\ns = list(raw_input())\n\nif s[0] != '1':\n\ts = [s[-i] for i in range(len(s))]\n\nif len(s) % 2 == 1:\n\ts.append('0')\n\nfor i in range(0, len(s), 2):\n\tif s[i] != '1' or s[i + 1] != '0':\n\t\tprint \"No\"\n\t\tsys.exit()\n\nprint \"Yes\""}, {"source_code": "chk = True\nn = int(input())\nst = input()\nl = list(st)\ns=0\nif n == 1 and int(l[0]) == 0:\n chk = False\n\nelse :\n def test():\n global chk\n for i in range(len(l)-1):\n if int(l[i]) + int(l[i+1]) > 1 :\n chk = False\n return False\n return True\n test()\n if chk:\n for i in range(len(l)):\n if int(l[i])==0:\n l[i] = '1'\n if test():\n chk = False\n break\n else:\n l[i] = '0'\n \n \n\nif(chk):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n\n"}, {"source_code": "\nk = int(input())\n\ns = input()\nfor i in range(1,len(s)):\n if(int(s[i])+int(s[i-1]) == 2) :\n print('No')\n exit()\nfor i in range(1,len(s)-1):\n if(s[i] == '0' and s[i-1]=='0' and s[i+1]=='0') :\n print('No')\n exit()\nif(len(s)>=2):\n if(s[0]==s[1]=='0' or s[len(s)-1]==s[len(s)-2]=='0'):\n print('No')\n exit()\n \nprint('Yes')\n"}, {"source_code": "n = int(input())\ns = input()\npt = 0\n\ncnt = 0 \nif(int(s[0]) == 1):\n\tif(n > 1):\n\t\tif(int(s[1]) == 1):\n\t\t\tpt = 1\n\t\telse:\n\t\t\tcnt += 1\n\telse:\n\t\t\tcnt += 1\nelse:\n\tif(n > 1):\n\t\tif(int(s[1]) == 0):\n\t\t\tpt = 1\n\nfor i in range(1,n-1):\n\tif(int(s[i]) == 1):\n\t\tif(int(s[i-1]) == 0 and int(s[i+1]) == 0):\n\t\t\tcnt +=1\n\t\telse:\n\t\t\tpt = 1\n\t\t\tbreak\n\telse:\n\t\tif(int(s[i-1]) == 0 and int(s[i+1]) == 0):\n\t\t\tpt = 1\n\t\t\tbreak\n\t\t\t\nif(int(s[n-1]) == 1):\n\tif(n > 1):\n\t\tif(int(s[n-2]) == 1):\n\t\t\tpt = 1\n\t\telse:\n\t\t\tcnt += 1\n\telse:\n\t\t\tcnt += 1\nelse:\n\tif(n > 1):\n\t\tif(int(s[n-2]) == 0):\n\t\t\tpt = 1\n\t\t\t\n\nif(pt == 0):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "lenght=input()\nlenght=int(lenght)\nword=input()\nif lenght == 1:\n if \"0\" in word:\n print(\"No\")\n else:\n print(\"Yes\")\n exit() \nlast_chars = word[lenght-2:]\nif \"00\" in last_chars:\n print(\"No\")\n exit() \nif \"000\" in word:\n print(\"No\")\n exit()\nif \"11\" in word:\n print(\"No\") \n exit() \nprint(\"Yes\") "}, {"source_code": "n = eval(input())\ny = str(input())\ni = 0 \nf = False\nwhile(i<n-1):\n if (int(y[i])+int(y[i+1])==1):\n f = True\n i+=1\n else:\n f = False\n break\nif (f == True):\n print(\"Yes\")\nelse:\n print (\"No\")\n\n"}, {"source_code": "n = int(input())\ns = input()\nif n <= 2:\n if ('0' * n) == s: \n print('No')\n else:\n print('Yes')\nelif '11' in s or '000' in s or s[ : 2] == '00' or s[n - 2 : ] == '00':\n print('No')\nelse:\n print('Yes')"}, {"source_code": "n=input()\nprint ('No','Yes')[('10'*n)[:n]==raw_input()]"}, {"source_code": "n = int(input())\ns = input()\n\n\n\n\n\n\ndef check_val(value):\n\n if(value==2 or value==3):\n return True\n else:\n return False\n\n\n\n\ndef check():\n\n first = -1\n second = -1\n minimum = 9999999\n maximum = 0\n possible = ['1', '01', '10', '010']\n\n if(s in possible):\n print('YES')\n return\n else:\n for i in range(n):\n\n if(int(s[i])==1):\n first = second\n second = i\n diff = second - first\n\n if(first>-1):\n\n if(diff>maximum):\n maximum = diff\n if(diff<minimum):\n minimum = diff\n\n\n\n if (second > -1):\n r = n - 1 - second\n if (r > 2):\n print('NO')\n return\n if (first > -1):\n l = s.index('1')\n if (l > 2):\n print('NO')\n return\n\n if(check_val(maximum) and check_val(minimum)):\n print('YES')\n return\n else:\n print('NO')\n return\n\ncheck()\n\n\n\n"}, {"source_code": "n=int(input())\na=input()\nprint(\"No\"if \"11\"in a or \"00\" in a else\"Yes\")\n"}, {"source_code": "import re\nn = input()\ns = raw_input()\nif n>2:\n\tif s[:2]=='00' or s[-2:]=='00':\n\t\tprint 'NO'\n\t\texit(0)\nif n==1:\n\tif s=='1':\n\t\tprint 'Yes'\n\telse:\n\t\tprint 'NO'\n\texit(0)\np1 = re.compile(r'0+')\na = max(map(len,p1.findall(s))+[0])\nb = max(map(len,p1.split(s))+[0])\nif a>2 or b>1:\n\tprint 'No'\nelse:\n\tprint 'Yes'"}, {"source_code": "n = input()\ns = str(input())\n\nek = set(s[1::2])\ndui = set(s[0::2])\n\nif len(ek) == 1 and len(dui) == 1 and ek!=dui:\n print(\"YES\")\nelse :\n print(\"NO\") "}, {"source_code": "k = int(input())\na = input()\nif a.count('11') == 1 or a.count('000') == 1:\n print('No')\nelif (k == 1) and (a[0] == '0'):\n print('No')\nelif (k >= 2) and(a[0] + a[1] == '00' or a[-1] + a[-2] == '00'):\n print('No')\nelse:\n print('Yes')\n"}, {"source_code": "n = int(input())\n\nseating = input().strip()\n\n\nmaximal_1 = ''\nmaximal_0 = ''\nfor i in range(n):\n\tif i%2:\n\t\tmaximal_1 += '1'\n\t\tmaximal_0 += '0'\n\telse:\n\t\tmaximal_1 += '0'\n\t\tmaximal_0 += '1'\n\nif seating == maximal_1 or seating == maximal_0:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "from math import ceil\n\nn = int(raw_input())\ns = raw_input()\n\nok = True\n\ndef consecutive_ones():\n\tif '11' in s:\n\t\treturn True\n\treturn False\n\ndef three_consecutive_zeros():\n\tif '000' in s:\n\t\treturn True\n\treturn False\n\nif s == '0':\n\tok = False\nelif s[:2] == '00':\n\tok = False\nelif s[:-2] == '00':\n\tok = False\nelif consecutive_ones():\n\tok = False\nelif three_consecutive_zeros():\n\tok = False\n\ns1 = \"0\" + (\"10\" * 500)\ns2 = \"1\" + (\"01\" * 500)\ns3 = \"1\" + (\"001\" * 350)\ns4 = \"0\" + (\"100\" * 350)\n\nif not ok:\n\tprint \"No\"\n\texit(0)\n\nif s in s1 or s in s2 or s in s3 or s in s4:\n\tprint \"Yes\"\n\texit(0)\n\nif ok:\n\tprint \"Yes\"\nelse:\n\tprint \"No\"\n"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n-1):\n if s[i]==s[i+1]:\n print('NO')\n exit()\nprint('YES')"}, {"source_code": "n=int(input())\ns=input()\nm,c=0,0\nif n%2==0:\n m=n//2\nelse:\n m=n//2+1\nif s.count('1')!=m:\n print('no')\nelse:\n if m%2!=0 and s[0]=='0':\n print('no')\n else:\n f=1\n for i in range(n-2):\n if s[i]!=s[i+2]:\n f=0\n break\n if f:\n print('yes')\n else:\n print('no')"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nonec = 0\nfor c in s:\n if c is '1':\n onec += 1\nif n // 2 + n & 1 > onec:\n print 'No'\nelif '000' in s or '11' in s or s[:2] is '00' or s[-2:] is '00' or n is 1:\n print 'No'\nelse:\n print 'Yes'\n"}, {"source_code": "if __name__ == \"__main__\":\n n = int(input().strip())\n inp = input().strip()\n adj = '11' not in inp\n con = not(inp.startswith('00') or inp.endswith('0') or '000' in inp)\n print(\"Yes\" if adj and con else \"No\")\n"}, {"source_code": "n = int(input())\ns = str(input())\nif n == 1 and s[0] == '1':\n print(\"Yes\")\n exit()\nelif n == 1 and s[0] == '0':\n print(\"No\")\n exit()\nelif n == 2:\n if s == \"01\" or s == \"10\":\n print(\"Yes\")\n exit()\n else:\n print(\"No\")\n exit()\nelif n%2 == 0:\n for i in range(n-2):\n if (s[i] == '1' and s[i+1] == '1') or (s[i+1] == '1' and s[i+2] == '1') or (s[i] == '0' and s[i+1] == '0' and s[i+2] =='0'):\n print(\"No\")\n exit()\n if s[-1] == '0' and s[-2] == '0':\n print(\"No\")\n else:\n print(\"Yes\")\nelse:\n for i in range(n-2):\n if (s[i] == '1' and s[i+1] == '1') or (s[i+1] == '1' and s[i+2] == '1') or (s[i] == '0' and s[i+1] == '0' and s[i+2] == '0'):\n print(\"No\")\n exit()\n if s[-1] == '0' and s[-2] == '0':\n print(\"No\")\n else:\n print(\"Yes\")\n "}, {"source_code": "import os, sys, math\n\ndef main():\n\tT = int(input())\n\t#for _ in range(T):\n\ttestcase()\n\ndef testcase():\n\tl = [int(x) for x in input()]\n\tif solve(l):\n\t\tprint(\"Yes\")\n\telse:\n\t\tprint(\"No\")\n\ndef solve(l):\n\tx = 0\n\twhile x<len(l):\n\t\tif l[x]==1:\n\t\t\tif x<len(l)-1:\n\t\t\t\tif l[x+1]==1:\n\t\t\t\t\treturn False\n\t\t\t\telse:\n\t\t\t\t\tx += 2\n\t\t\tif x>0:\n\t\t\t\tif l[x-1]==1:\n\t\t\t\t\treturn False\n\t\t\t\telse:\n\t\t\t\t\tx += 2\n\t\telse: # l[x] == 0\n\t\t\tif x<len(l)-1:\n\t\t\t\tif l[x+1]==0:\n\t\t\t\t\t#return False\n\t\t\t\t\tx += 1\n\t\t\t\telse:\n\t\t\t\t\tx += 2\n\t\t\tif x>0:\n\t\t\t\tif l[x-1]==0:\n\t\t\t\t\t#return False\n\t\t\t\t\tx += 1\n\t\t\t\telse:\n\t\t\t\t\tx += 2\n\t\t\tif x<len(l)-1 and x>0:\n\t\t\t\tif l[x-1]==0 and l[x-1]==0:\n\t\t\t\t\treturn False\n\treturn True\n\ndef debug(*args):\n\tif 'DEBUG' in os.environ:\n\t\tprint(*args)\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "def print_return(func):\n def wrapper(*args, **kwargs):\n retval = func(*args, **kwargs)\n print(retval)\n return retval\n\n return wrapper\n\n\nclass Solve:\n @print_return\n def solve_a(self, rest=None):\n if rest is None:\n n = int(input())\n state = input()\n else:\n lines = rest.split('\\n')\n n = int(lines[0].strip())\n state = lines[1].strip()\n ans = 'Yes'\n for place in range(1, n - 1):\n if state[place] == '1':\n if state[place - 1] == '1' or state[place + 1] == '1':\n ans = 'No'\n break\n if state[place] == '0':\n if state[place - 1] == '0' and state[place + 1] == '0':\n ans = 'No'\n break\n if n == 1 and state[0] == '0':\n ans = 'No'\n elif n == 1 and state[0] == '1':\n ans = 'Yes'\n elif state[0] == '0' and state[1] == '0':\n ans = 'No'\n elif state[-1] == '0' and state[-2] == '0':\n ans = 'No'\n return ans\n\n\n def solve_b(self):\n pass\n\n def solve_c(self):\n pass\n\n def solve_d(self):\n pass\n\n def solve_e(self):\n pass\n\n def solve_f(self):\n pass\n\n\nif __name__ == '__main__':\n s = Solve()\n s.solve_a()\n"}, {"source_code": "s = input()\nx = raw_input()\nno = 0\nfor i in range(s-1):\n\tif x[i] == x[i+1] and x[i] == '1': no = 1\nprev = -1\nif x[0] == '1': prev = 0\nfor i in range(s):\n\tif x[i] == '1':\n\t\tif i-prev >= 3: no = 1;\n\t\tprev = i\nif no == 0:\n\tif x.count('1') == 0: print 'No'\n\telse :print 'Yes'\nelse:\n\tprint 'No'"}, {"source_code": "chk = True\nn = int(input())\nst = input()\nl = list(st)\ns=0\nif n == 1 and int(l[0]) == 0:\n chk = False\nelif n == 100:\n chk = True\nelse :\n for i in range(len(l)-1):\n if int(l[i]) + int(l[i+1]) > 1 :\n chk = False\n break\n if chk:\n if len(l)%2==0:\n for i in range(len(l)):\n s = s + int(l[i])\n if s < int(len(l)/2):\n chk = False\n else :\n s1 = 0\n s2 = 0\n for i in range(len(l)):\n if i%2 == 0:\n s1 = s1 + int(l[i])\n else:\n s2 = s2 + int(l[i])\n\n \n if not((s1 == int((len(l)+1)/2) and s2 == 0) or (s1 == 0 and s2 == int((len(l)-1)/2))):\n chk = False\n \n \n\nif(chk):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n\n"}, {"source_code": "#http://codeforces.com/contest/982/problem/A - Row\nn= int(input())\nc= input()\n# n=5\n# c=\"10001\"\nif \"11\" in c:\n ans=\"No\"\nelif \"000\" in c:\n ans=\"No\"\nelif c.endswith('0') or c.startswith('0'):\n ans=\"No\"\nelse:\n ans=\"Yes\"\nprint (ans)\n"}, {"source_code": "x=eval(input())\ny=input()\nflag=False\nif y[0]=='0':\n check=0\n check1=1\nelse:\n check=1\n check1=0\ni=0\nwhile i<len(y)-1 and x!=1:\n if y[i]==str(check) and y[i+1]==str(check1):\n flag=True\n i+=2\n else:\n flag=False\n break\nif flag==True:\n print('Yes')\nelse:\n print('No')\n\n \n"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n-1):\n if s[i]==s[i+1]=='1':\n print('NO')\n exit()\nfor i in range(1,n-1):\n if s[i]==s[i-1]==s[i+1]=='0':\n print('NO')\n exit()\nif n>1:\n if s[0]==s[1]=='0' or s[-1]==s[-2]=='0':\n print('NO')\n exit()\nprint('YES')\n"}, {"source_code": "n=input()\nprint ('No','Yes')[('10'*n)[:n]==raw_input()]"}, {"source_code": "m = input()\ns = raw_input()\n\nif ('11' in s) or s.startswith('00') or s.endswith('00') or ('000' in s) or s=='1':\n print \"No\"\nelse:\n print \"Yes\" "}, {"source_code": "import sys\nfrom math import ceil\n\nn = int(sys.stdin.readline().strip())\ns = sys.stdin.readline().strip()\n\ndef sol():\n\tlast = -1\n\tfor char in s:\n\t\tif char == last:\n\t\t\treturn False\n\t\tlast = char\n\treturn s.count(\"1\") == int(ceil(n/2.))\n\nprint([\"No\",\"Yes\"][sol()])"}, {"source_code": "from sys import stdin\nnumero = int(input())\nordem= str(stdin.readline())\n\nx=False\nif(numero==1 and ordem[0]==\"0\"):\n\tx=True\nfor i in range(1,numero):\n\n\tif(ordem[i]==ordem[i-1] and ordem[i]==\"1\"):\n\t x=True\n\t break\n\telif(i>=3 and ordem[i]==ordem[i-1] and ordem[i]==ordem[i+1] and ordem[i]==\"0\"):\n\t x=True\n\t break\n\telif((i==2 and ordem[i]==ordem[i-1] and ordem[i]==\"0\") or (i==numero-1 and ordem[i]==ordem[i-1] and ordem[i]==\"0\")):\n\t\tx=True\n\t\tbreak\n\nif(x==False):\n print(\"Yes\")\nelse:\n\tprint(\"No\")\n"}, {"source_code": "n = int(raw_input())\n\ns = raw_input()\nnex = '1'\n\nif s[0] == '0':\n nex = '1'\nelse:\n nex = '0'\n\ni = 0\nfor i in range(len(s) - 1):\n if s[i] == '0':\n nex = '1'\n if s[i] == '1':\n nex = '0'\n\n if i != len(s) - 1:\n if nex != s[i+1]:\n print(\"No\")\n exit(0)\n\nprint(\"Yes\")"}, {"source_code": "if __name__ == '__main__':\n input()\n s = input().strip()\n if '11' not in s and '000' not in s and not s.endswith('00') and not s.startswith('00'):\n print(\"Yes\")\n else:\n print(\"No\")\n"}, {"source_code": "n = int(input())\nc = input()\nfor i in range(1,n):\n if c[i] == c[i - 1] and c[i] != \"0\":\n print(\"No\")\n exit()\nfor i in range(n):\n if (i == 0 or c[i - 1] == '0') and (i == n - 1 or c[i + 1] == '0'):\n print(\"No\")\n exit()\nprint(\"Yes\")\n"}, {"source_code": "n = input()\nt = str(raw_input())\nl = False\np = False\nif n == 1:\n if t[0] == '0':\n print 'No'\n exit(0)\n else:\n print 'Yes'\n exit(0)\nif t[0] == '0':\n l = True\nif t[-1] == '0':\n p = True\nile_00 = 0\nile_maks = 0\nfor x in range(0, len(t)-1, +1):\n if t[x] == t[x+1] == '1':\n print 'No'\n exit(0)\n elif t[x] == t[x+1] == '0':\n ile_00 += 1\n if ile_00 > ile_maks:\n ile_maks = ile_00\n else:\n ile_00 = 0\nif ile_maks > 1:\n print 'No'\n exit(0)\nif ile_maks == 1 and l == True or p == True:\n print 'No'\n exit(0)\nprint 'Yes'\n"}, {"source_code": "def f(n, s):\n ans = 'No'\n if n == 1:\n if s[0] == '1':\n ans = 'Yes'\n return ans\n if n == 2:\n if len([p for p in s if p == '1']) == 1:\n ans = 'Yes'\n return ans\n if n == 3:\n if s == '101':\n ans = 'Yes'\n return ans\n pattern = '10' * (n/4)\n l = [pattern]\n if n%2:\n l.append('1')\n l.append(''.join((reversed(list(pattern)))))\n res = ''.join(l)\n if res == s:\n ans = 'Yes'\n return ans\n\nn = int(raw_input().strip())\nrow = raw_input().strip()\nprint f(n, row)\n"}, {"source_code": "n = int(raw_input())\n\ns = raw_input()\nnex = '1'\n\nif s[0] == '0':\n nex = '1'\nelse:\n nex = '0'\n\ni = 0\nfor i in range(len(s) - 1):\n if s[i] == '0':\n nex = '1'\n if s[i] == '1':\n nex = '0'\n\n if i != len(s) - 1:\n if nex != s[i+1]:\n print(\"No\")\n exit(0)\n\nprint(\"Yes\")"}, {"source_code": "\nk = int(input())\n\ns = input()\n\nfor i in range(1,len(s)):\n if(int(s[i])+int(s[i-1]) != 1) :\n print('No')\n exit()\n\nif(len(s)%2 == 1 and s[0]!='1'):\n print('NO')\n exit()\n \nprint('YES')\n"}, {"source_code": "def print_return(func):\n def wrapper(*args, **kwargs):\n retval = func(*args, **kwargs)\n print(retval)\n return retval\n\n return wrapper\n\n\nclass Solve:\n @print_return\n def solve_a(self, rest=None):\n if rest is None:\n n = int(input())\n state = input()\n else:\n lines = rest.split('\\n')\n n = int(lines[0])\n state = lines[1]\n ans = 'Yes'\n for place in range(1, n - 1):\n if state[place] == '1':\n continue\n elif state[place - 1] == '0' and state[place + 1] == '0':\n ans = 'No'\n break\n if n == 1 and state[0] == '0':\n ans = 'No'\n elif n == 1 and state[0] == '1':\n ans = 'Yes'\n elif state[0] == '0' and state[1] == '0':\n ans = 'No'\n elif state[-1] == '0' and state[-2] == '0':\n ans = 'No'\n return ans\n\n\n def solve_b(self):\n pass\n\n def solve_c(self):\n pass\n\n def solve_d(self):\n pass\n\n def solve_e(self):\n pass\n\n def solve_f(self):\n pass\n\n\nif __name__ == '__main__':\n s = Solve()\n s.solve_a()\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- encoding: utf-8 -*-\n\nimport sys\n\ndef main():\n n = int(sys.stdin.readline())\n l = [int(i) for i in sys.stdin.readline().strip()]\n if sum(l) != (n+l[0])//2:\n print('No')\n return\n\n for i in range(n-1):\n if l[i] + l[i+1] != 1:\n print('No')\n return\n print('Yes')\nmain()\n"}, {"source_code": "n=int(input())\ns=input()\nflag=True\nfor i in range(1,n-1):\n if s[i-1]==s[i]==s[i+1]==\"0\":\n flag=False\n if s[i]==\"1\" and \"1\" in (s[i-1],s[i+1]):\n flag=False\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n \n"}, {"source_code": "n = int(input())\ns = input()\nans = True\nfor i in range(n-1):\n if (s[i]==s[i+1]):\n ans = False\nif (ans):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n"}, {"source_code": "n = raw_input()\nstr = raw_input()\nif str == '0' or '11' in str or '000' in str:\n\tprint 'No'\nelse:\n\tprint 'Yes'"}, {"source_code": "n = int(input())\nstring = input()\nres = True\nlast_index = 0\nfor i in string[1: len(string)]:\n if i == '1':\n new_index = string[last_index + 1: len(string)].index(i)\n if new_index - last_index > 2 or new_index - last_index < 1:\n res = False\n break\n last_index = new_index\nif not res:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n=int(input())\ns=input()\nf=0\nif(n==1):\n if(s[0]=='0'):\n print(\"No\")\n else:\n print(\"Yes\")\nelif(n==2):\n if(s[0]=='0' and s[1]=='0'):\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n if((s[0]==s[1] and s[0]=='0') or (s[-1]==s[-2] and s[-1]=='0')):\n print(\"No\")\n else:\n for i in range(n-1):\n if(s[i]==s[i+1] and s[i]=='1'):\n f=1\n break\n if(f):\n print(\"No\")\n else:\n for i in range(n-2):\n if(s[i]==s[i+1] and s[i+1]==s[i+2] and s[i]=='0'):\n f=1\n break\n if(f):\n print(\"No\")\n else:\n print(\"Yes\")\n\n\n"}, {"source_code": "n=int(raw_input())\nseating=raw_input()\nif n==1 and seating=='1':\n print \"Yes\"\nelif n==1 and seating!='1':\n print \"No\"\nelse:\n allok=True\n for i in range(n-1):\n if seating[i]==seating[i+1] and seating[i]=='1':\n allok=False\n break\n if allok:\n for i in range(1,n-1):\n if seating[i-1]=='0' and seating[i]=='0' and seating[i+1]=='0':\n allok=False\n break\n if len(seating)>2 and seating[0]=='0' and seating[1]=='0' and seating[2]=='1':\n allok=False\n elif len(seating)>2 and seating[n-1]=='0' and seating[n-2]=='0' and seating[n-3]=='1':\n allok=False\n elif len(seating)==2 and seating[1]=='0' and seating[1]=='0':\n allok=False\n if allok:\n print \"Yes\" \n else:\n print \"No\"\n else:\n print \"No\""}, {"source_code": "n, s = input(), input()\nprint(('No', 'Yes')[not s.startswith('00') and not s.endswith('00')\n and s.count('000') == 0 and s.count('11') == 0])\n"}, {"source_code": "input()\ns=input()\nt=0 if s[0]=='0' else 1\nfor i in s[1:]:\n if i=='0':\n if t==1:\n t=0\n elif t==-1:\n t=-100\n break\n t-=1\n else:\n if t==1:\n t=-100\n break\n t=1\nprint(\"No\" if t==-100 else \"Yes\")"}, {"source_code": "n = input()\ns = str(input())\n\nek = set(s[1::2])\ndui = set(s[0::2])\n\nif (len(ek) == 1 and len(dui) == 1 and ek!=dui) or s == \"1\" or s == \"0\":\n print(\"YES\")\nelse :\n print(\"NO\") "}, {"source_code": "n=int(input())\ns=input().strip()\nflag=1 \nif n==1:\n if s!=\"0\":\n print(\"Yes\")\n else:\n print(\"No\")\nelif n==2:\n if s!=\"00\":\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n if s[:2]==\"00\":\n flag=0\n for i in range(1,n-1):\n t=s[i-1]+\"1\"+s[i+1]\n if t==\"010\":\n flag=0 \n break\n if s[n-2:n]==\"00\":\n flag=0\n for i in range(n-1):\n if s[i:i+2]==\"11\":\n flag=0\n break\n if flag==1:\n print(\"Yes\")\n else:\n print(\"No\")"}, {"source_code": "a=int(input())\nb=input()\ns='10'*a\nif b in s:\n print('yes')\nelse:\n print('no')\n"}, {"source_code": "def hasAdjacent(s, x, lens):\n if s[x] == 0:\n return False\n \n flag = False\n if x-1 >= 0:\n if s[x-1] == s[x]:\n flag = True\n if x+1 < lens:\n\n if s[x+1] == s[x]:\n flag = True\n\n return flag\n\ndef isSpotOpen(s, x, lens):\n if s[x] == 1:\n return False\n\n flag = False\n if x-1 >= 0 or x+1 < lens:\n if s[x-1] == 0 and s[x+1] == 0: \n flag = True\n\n return flag\n\nt = int(raw_input())\ns = map(int, raw_input())\n\nadj = False\nopenSpot = False\nfor i in xrange(t):\n openSpot = openSpot | isSpotOpen(s, i, t)\n adj = adj | hasAdjacent(s, i, t)\n\n\nif not adj and not openSpot:\n print \"Yes\"\nelse:\n print \"No\"\n\n"}, {"source_code": "n = int(input())\ns = input()\nans = True\nfor i in range(n-2):\n if (s[i]=='0' and s[i+1]=='0' and s[i+2]=='0'):\n ans = False\nfor i in range(n-1):\n if (s[i]=='1' and s[i+1]=='1'):\n ans = False \nif (n==1 and s[0]=='0'):\n ans = False\nif (len(s)>2 and s[0]=='0' and s[1]=='0'):\n ans = False\nif (len(s)>2 and s[n-1]=='0' and s[n-2]=='0'):\n ans = False \nif (ans):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n"}, {"source_code": "a=input()\nn=input()\nif ((\"11\" in n) or (\"000\" in n) or (\"1\" not in n) ):\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")"}, {"source_code": "#!/usr/bin/env python3\n# -*- encoding: utf-8 -*-\n\nimport sys\n\ndef main():\n n = int(sys.stdin.readline())\n l = [int(i) for i in sys.stdin.readline().strip()]\n if sum(l) != (n+l[0])//2:\n print('No')\n return\n\n for i in range(n-1):\n if l[i] + l[i+1] == 2 or sum(l[i:i+3]) == 0:\n print('No')\n return\n print('Yes')\nmain()\n"}, {"source_code": "a=int(input())\nb=input()\ndone=1\ns1=[]\ns2=[]\nfor i in range(1,len(b)):\n if i%2==0:\n s1.append(b[i])\n if i%2==1:\n s2.append(b[i])\n if b[i]==0 and b[i-1]==0:\n done=0\nif '1' in s1 and '0' in s1:\n done=0\nif '0' in s2 and '1' in s2:\n done=0\nif done==1:\n print('Yes')\nelse:\n print('No')\n \n"}, {"source_code": "m = input()\ns = raw_input()\n\nif ('11' in s) or s.startswith('00') or s.endswith('00') or ('000' in s):\n print \"No\"\nelse:\n print \"Yes\" "}, {"source_code": "\n\nn=int(input())\ns=str(input())\nif n==1:\n if s==\"0\":\n print(\"No\")\n else:\n \n print(\"Yes\")\nelif n==2:\n if s[0]!=s[1]:\n print('Yes')\n elif s[0]==s[1]==\"0\":\n print(\"No\")\n else:\n print(\"Yes\")\nelif n==3:\n if s[0]==s[2] and s[0]!=s[1]:\n print(\"Yes\")\n\n else:\n print(\"No\")\nelse:\n a=[]\n an=True\n for i in range(n):\n if s[i]==\"1\":\n a.append(i)\n\n for i in range(len(a)-1):\n if (int(a[i+1])-int(a[i])-1)<1 or (int(a[i+1])-int(a[i])-1)>=3:\n an=False\n print(\"No\")\n \n break\n if an==True:\n print('Yes')\n \n \n"}, {"source_code": "input()\ns=input()\nf=1\nfor i in range(len(s)):\n try:\n if s[i]=='1' and s[i-1]=='1' and i!=0: f=0 ; break\n except:pass\n\n try:\n if s[i]=='1' and s[i+1]=='1' and i!=len(s)-1: f=0 ; break\n except:pass\n try:\n if s[i]=='0' and s[i+1]=='0' and s[i-1]=='0' and i!=len(s)-1 and i!=0: f=0 ; break\n if i==0 and s[i+1]=='0': f=0;break\n if i==len(s)-1 and s[i-1]=='0': f=0;break\n except:pass\nif f==1 and s!='0': print('Yes')\nelse: print('No')\n\n##//////////////// ////// /////// // /////// // // //\n##//// // /// /// /// /// // /// /// //// //\n##//// //// /// /// /// /// // ///////// //// ///////\n##//// ///// /// /// /// /// // /// /// //// // //\n##////////////// /////////// /////////// ////// /// /// // // // //\n\n\n\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\nf = True\nfor i in xrange(n-1):\n if s[i] == s[i+1]:\n f = False\n break\n \nprint 'Yes' if f and s != '0' else 'No'"}, {"source_code": "n = int(input())\ns = input()\ncount0 = 0\ncount1 = 0\nflag = True\nfor i in s:\n if i == \"0\":\n count0 += 1\n count1 = 0\n else:\n count1 +=1\n count0 = 0\n if (count0 == 3)or(count1 == 2):\n flag = False\nif count0>count1 or count1-count0>1:\n flag = False\nprint(\"Yes\" if flag else \"No\")"}, {"source_code": "n = int(input())\ns = input()\ns = list(s)\n\ns= list(map(int, s))\n\n\ndef check():\n for i in range(n-1):\n if(s[i]!=s[i+1]):\n pass\n else:\n print('NO')\n break\n print('YES')\n\ncheck()\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nflag = True\na = input()\nfor i in range(1,n-1):\n if a[i] == '1':\n if a[i-1] == '1' or a[i+1] == '1':\n print(\"No\")\n flag = False\n break\n if a[i] == '0':\n if a[i - 1] == '0' and a[i + 1] == '0':\n print(\"No\")\n flag = False\n break\nif a == '0' or a == '11' or a == '10' or a == '01' or a[n-1] == '0' and a[n-2] == '0' or a[0] == '0' and a[1] == '0' and flag:\n flag = False\n print(\"No\")\nif flag or a == '00':\n print(\"Yes\")\n\n"}, {"source_code": "n=int(input())\ns=input()\n\ndef find(l):\n\tfor i in range(1,len(l)-1):\n\t\tif l[i-1]=='1' and l[i]=='0' and l[i+1]=='1':\n\t\t\treturn True\n\treturn False\n\nif n==1:\n\tif s=='1':\n\t\tprint('Yes')\n\telse:\n\t\tprint('No')\nelif n==2:\n\tif s=='11':\n\t\tprint('No')\n\telse:\n\t\tprint('Yes')\nelif n==3:\n\tif s=='001' or s=='100':\n\t\tprint('No')\n\telse:\n\t\tprint('Yes')\nelse:\n\tx,y=s.find('11'),s.find('000')\n\tif x!=-1 or y!=-1:\n\t\tprint('No')\n\telse:\t\n\t\tprint('Yes')"}, {"source_code": "num = input() \narr = raw_input()\nans = 'Yes'\n\nif len(arr) == 1:\n\tif arr[0] == '0':\n\t\tans = 'No'\n\nfor i in range(1,len(arr)):\n\tif arr[i] == '1' or (arr[i] == '0' and (i < 3 or i == len(arr)-1)):\n\t\tif arr[i-1] == arr[i]:\n\t\t\tans = 'No'\n\t\t\tbreak\n\telif i > 3:\n\t\tif arr[i-1] == arr[i-2]:\n\t\t\tans = 'No'\n\t\t\tbreak\n\nprint ans\n\n"}, {"source_code": "\n\n# contest http://codeforces.com/contest/982/problem/A\n\ndef f(seats):\n if len(seats) == 1:\n if seats == \"1\":\n return \"Yes\"\n else:\n return \"No\"\n\n if seats[0] == '1' and seats[-1] == '1':\n return f(seats[2:])\n else:\n return \"No\"\n\ndef solution(line1, line2):\n N = int(line1)\n seats = line2\n\n if (N%2 == 0):\n if seats[0] == '1' and seats[-1] == '0':\n return f(seats[0:-1])\n elif seats[0] == '0' and seats[-1] == '1':\n return f(seats[1:])\n else:\n return \"No\"\n\n else:\n return f(seats)\n\ndef solution2(line2):\n\n first_one_index = 0\n for i in range(len(line2)):\n if line2[i] == '1':\n first_one_index = i\n break\n if first_one_index > 1:\n return \"No\"\n\n line2 = line2[first_one_index+1:]\n\n last_is_zero = False\n zero_count = 0\n one_count = 1\n for i in range(len(line2)):\n c = line2[i]\n if c == '0':\n if last_is_zero == False:\n zero_count = 1\n one_count = 0\n last_is_zero = True\n elif zero_count > 1:\n return \"No\"\n else:\n zero_count = zero_count + 1\n elif c == '1':\n if last_is_zero == True:\n zero_count = 0\n one_count = 1\n last_is_zero = False\n else:\n return \"No\"\n return \"Yes\"\n\nline1 = raw_input();\nline2 = raw_input();\n\nprint solution2(line2)"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nonec = 0\nfor c in s:\n if c is '1':\n onec += 1\nif (n // 2) + (n & 1) ^ onec:\n print 'No'\nelif '000' in s or '11' in s or s[:2] is '00' or s[-2:] is '00' or n is 1:\n print 'No'\nelse:\n print 'Yes'\n"}, {"source_code": "n = int(input())\nrow = input()\nif row.find('11') != -1 or row.find('000') != -1 or n == 1 and row == '0':\n print('no')\nelse:\n print('yes')"}, {"source_code": "n=int(input())\ns=input()\nc=s.count('1')\nif n==1:\n if s[0]=='1':\n print('Yes')\n exit(0)\n else:\n print('No')\n exit(0)\nfor i in range(n-1):\n if s[i]==s[i+1]:\n print('No')\n exit(0)\nprint('Yes')\n \n \n \n \n \n "}, {"source_code": "n=int(input())\ns=input().strip()\nc=s.count(\"1\")\nif n%2==0:\n t=n//2\nelse:\n t=n//2+1\nif c==t:\n flag=1\n curr=int(s[0])\n for i in range(1,n):\n if curr^int(s[i])==0:\n flag=0 \n break\n curr=int(s[i])\n if flag==1:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")"}, {"source_code": "n=int(raw_input())\nseating=raw_input()\nif n==1 and seating=='1':\n print \"Yes\"\nelif n==1 and seating!='1':\n print \"No\"\nelse:\n allok=True\n for i in range(n-1):\n if seating[i]==seating[i+1] and seating[i]=='1':\n allok=False\n break\n if allok:\n for i in range(1,n-1):\n if seating[i-1]=='0' and seating[i]=='0' and seating[i+1]=='0':\n allok=False\n break\n if len(seating)>2 and seating[0]=='0' and seating[1]=='0' and seating[2]=='1':\n allok=False\n elif len(seating)>2 and seating[n-1]=='0' and seating[n-2]=='0' and seating[n-3]=='1':\n allok=False\n elif len(seating)==2 and seating[1]=='0' and seating[1]=='0':\n allok=False\n if allok:\n print \"Yes\" \n else:\n print \"No\"\n else:\n print \"No\""}, {"source_code": "n =int(input())\ns = input()\nif(n==1):\n if(s[0]=='0'):\n print('No')\n exit(0)\nif(s.find('11')!=-1):\n print('No')\n exit(0)\nif(s.find('000')!=-1):\n print('No')\n exit(0)\nif(s[n-3:]=='00' or s[:2]=='00'):\n print('No')\n exit(0)\nprint('Yes')"}, {"source_code": "n=int(input())\ns=input()\nans=\"Yes\"\nif n==1 and s=='0':\n ans=\"No\"\nif n==1 and s=='1':\n ans=\"Yes\"\nif s.count(\"000\")>0:\n ans=\"No\"\nif s.count(\"11\")>0:\n ans=\"No\"\nprint(ans)\n"}], "src_uid": "c14d255785b1f668d04b0bf6dcadf32d"} {"source_code": "from collections import defaultdict\nl=[int(i) for i in input().split()]\nd=defaultdict(int)\nfor i in l:\n d[i]+=1\nif len(d)==5:\n print(sum(l))\nelse:\n z=[]\n k=list(d.keys())\n v=list(d.values())\n for i in range(len(d)):\n if v[i]==2:\n z.append(sum(l)-k[i]*2)\n elif v[i]==3:\n z.append(sum(l)-k[i]*3)\n elif v[i]>3:\n z.append(sum(l)-k[i]*3)\n print(min(z))\n", "positive_code": [{"source_code": "a = [int(i) for i in input().split()]\n\nc = [0] * 101\nss = 0\n\nfor i in a:\n c[i] += 1\n ss += i\n\nm = 0\nfor i in range(101):\n if (c[i] > 1) and (i * min(c[i], 3) > m):\n m = i * min(c[i], 3)\n\nprint(ss - m)\n"}, {"source_code": "li = [int(i) for i in input().split()]\nd = dict()\nfor i in li:\n if i not in d:\n d[i] = 1\n else :\n d[i] += 1\nif len(d) == 5:\n print(sum(list(d.keys())))\nelif len(d) == 4:\n sm = 0\n for i in d:\n if d[i] != 2:\n sm += i\n print(sm)\nelif len(d) == 3:\n sm1, sm2, sm3 = 0, 0, 0\n if 3 in list(d.values()):\n for i in d:\n if d[i] != 3:\n sm1 += i\n print(sm1)\n else :\n key = 0\n for i in d:\n if d[i] == 2 and key == 0:\n sm2 += i * 2\n key = i\n elif d[i] != 2 :\n sm2 += i\n for i in d:\n if d[i] == 2 and key != i :\n sm3 += i * 2\n elif d[i] != 2:\n sm3 += i\n print(min(sm2, sm3))\nelif len(d) == 2:\n sm1, sm2, sm3 = 0, 0, 0\n for i in d:\n if d[i] == 3:\n sm1 += i * 3\n elif d[i] == 2:\n sm2 += i * 2\n for i in d:\n if d[i] == 4:\n sm3 += i \n elif d[i] == 1:\n sm3 += i\n if sm1 != 0 and sm2 != 0:\n print(min(sm1, sm2))\n elif sm3 != 0 :\n print(sm3)\nelif len(d) == 1:\n for i in d:\n print(2 * i)"}, {"source_code": "n = list(map(int, input().split()))\nsumma = 0\nmaxel = 0\none = []\ntwo = []\nthree = []\nfor k in range(len(n)):\n\n if n.count(n[k]) == 2:\n two.append(n[k])\n elif n.count(n[k]) >= 3:\n three.append(n[k])\n one.append(n.count(n[k]))\nfor i in range(len(n)):\n if len(three) == 5:\n print(three[0] * 2)\n break\n else:\n if len(three) >= 3:\n\n if len(two) == 2:\n\n if two[0] * 2 > three[0] * 3:\n print(three[0] * 3)\n\n break\n else:\n print(two[0] * 2)\n break\n # elif three[0] * 3 > sum(n) - three[0] * 3:\n # print(sum(n) - three[0] * 3)\n # break\n else:\n print(sum(n) - three[0] * 3)\n break\n\n elif sum(one) == 5:\n\n print(sum(n))\n break\n else:\n\n print(sum(n) - (max(two) * 2))\n break\n"}, {"source_code": "a=list(map(int,input().split()));b=0\nfor i in a:b=[b,[max(b,2*i),max(b,3*i)][a.count(i)>2]][a.count(i)>=2]\nprint(sum(a)-b)"}, {"source_code": "a=list(map(int,input().split()));b=0\nfor i in a:\n if a.count(i)>=2:b=[max(b,2*i),max(b,3*i)][a.count(i)>2]\nprint(sum(a)-b)"}, {"source_code": "nums = list(map(int,input().split()))\ntotalSum = sum(nums)\nans = totalSum\nif len(nums)!=len(set(nums)):\n for x in nums:\n if nums.count(x)>1 and nums.count(x)<4 and ans > (totalSum - x*nums.count(x)):\n ans = (totalSum - x*nums.count(x))\n if nums.count(x)>=4 and ans > (totalSum - x*3):\n ans = totalSum - x*3\nprint(ans)\n"}, {"source_code": "nums = map(int,raw_input().split())\nans=sum(nums)\n\nnums.sort()\nminus = 0\nfor i in xrange(4) :\n\tif nums[i]==nums[i+1] :\n\t\tif i+2<=4 and nums[i]==nums[i+2] :\n\t\t\tif 3*nums[i] > minus :\n\t\t\t\tminus = 3*nums[i]\n\t\telse :\n\t\t\tif 2*nums[i] > minus :\n\t\t\t\tminus = 2*nums[i]\nprint ans-minus"}, {"source_code": "a = [x for x in range(5)]\na[0],a[1],a[2],a[3],a[4] = map(int,input().split())\na.sort()\n#print(a)\nans = 0\nfor i in range(5):\n\tans += a[i]\nMax = 0\ntsum = a[0]\ncount = 1\nfor i in range(4):\n\tif a[i]==a[i+1] and count < 3:\n\t\ttsum+=a[i+1]\n\t\tcount = count + 1\n\t\tif tsum > Max :\n\t\t\tMax = tsum\n\telse:\n\t\ttsum = a[i+1]\n\t\tcount =1 \nans -= Max\nprint(ans)\n\n"}, {"source_code": "a = map(int, raw_input().split())\nd = [0 for _ in xrange(101)]\nss = 0\nfor i in a:\n ss += i\n d[i] += 1\n \nmn = ss\nfor i in xrange(100, 0, -1):\n if d[i] == 2:\n mn = min( mn, ss - i * d[i])\n elif d[i] >= 3:\n mn = min( mn, ss - i * 3)\n \nprint mn"}, {"source_code": "a=[int(i) for i in input().split()]\ns=sum(a)\nmi=s\nfor i in a:\n n=a.count(i)\n if n>2:\n mi=min(mi,s-3*i)\n elif n==2:\n mi=min(mi,s-2*i)\nprint(mi)\n \n"}, {"source_code": "import sys\ni1=[int(k) for k in raw_input().split()]\ni1.sort()\ni1.reverse()\ni2 = i1[0]\ncount = 1\nbf=i1[0]\nsum = bf\nif(i2 == i1[1] and i1[2]==i1[3] and i1[3]==i1[4]):\n sum1= i2+i1[1]\n sum2 = i1[2]+i1[3]+i1[4]\n if(sum1 > sum2):\n sum = sum2\n else:\n sum = sum1\nelif(i1[0]==i1[1] and i1[1]==i1[2]):\n sum = i1[3]+i1[4]\nelif(i2==i1[1]):\n sum = i1[2]+i1[3]+i1[4]\nelif(i1[1]==i1[2] and i1[2]==i1[3]):\n sum = i1[0]+i1[4]\nelif(i1[1]==i1[2]):\n sum = i1[0]+i1[3]+i1[4]\nelif(i1[2]==i1[3] and i1[3]==i1[4]):\n sum = i1[0]+i1[1]\nelif(i1[2]==i1[3]):\n sum = i1[0]+i1[1]+i1[4]\nelif(i1[3]==i1[4]):\n sum = i1[0]+i1[1]+i1[2]\nelse:\n sum = i1[0]+i1[1]+i1[2]+i1[3]+i1[4]\nprint sum\nsys.stdout.flush()"}, {"source_code": "from collections import Counter\n\nt = Counter(map(int, raw_input().split()))\n\nmax_sum = 0\nfor value, count in t.items():\n if count > 1:\n new_sum = value * min(count, 3)\n if not max_sum:\n max_sum = new_sum\n\n elif max_sum < new_sum:\n max_sum = new_sum\n\nprint sum(k * v for k, v in t.items()) - max_sum\n"}, {"source_code": "list=[int(i) for i in input().split()]\nsom=sum(list)\nlist.sort(reverse=True)\nres=[som]\nfor i in range(5):\n k=list.count(list[i])\n if(k>=2 and k<=3):\n res.append(som-list[i]*k)\n elif(k>=4):\n res.append(som-list[i]*3)\nprint(min(res))"}, {"source_code": "c = map(int, raw_input().split())\ns = sum(c)\ne = 0\nq = 0\nfor x in c:\n\tif c.count(x) >=3:\n\t\te = x*3\n\telif c.count(x) == 2:\n\t\tq = max(q, x*2)\nprint s-max(e,q)\n"}, {"source_code": "a = map(int, raw_input().split())\na.append(0)\na.append(0)\nprint sum(a) - max(min(a.count(e),3)*e for e in a if a.count(e)>1)"}, {"source_code": "t=map(int,raw_input().split())\nans=0\nfor i in t:\n k=t.count(i)\n if k>=2:\n ans=max(ans,min(k,3)*i)\nprint sum(t)-ans\n"}, {"source_code": "t1, t2, t3, t4, t5 = raw_input().split()\nt1 = (int)(t1); t2 = (int)(t2); t3 = (int)(t3); t4 = (int)(t4); t5 = (int)(t5)\narr = [t1, t2, t3, t4, t5]\nsum = t1 + t2 + t3 + t4 + t5\nmax = 0;\ni = 0\nwhile i < 5:\n\tif arr.count(arr[i]) == 2:\n\t\tif (max < arr.count(arr[i])*arr[i]):\n\t\t\tmax = arr.count(arr[i])*arr[i]\n\telif arr.count(arr[i]) >= 3:\n\t\tif (max < 3*arr[i]):\n\t\t\tmax = 3*arr[i]\n\ti += 1\nprint sum - max"}, {"source_code": "a=list(map(int,input().split()))\nsu=sum(a);b=[]\nfor i in set(a):\n b.append(i*(a.count(i)//3)*3)\n b.append(i*(min(2,(a.count(i)//2)*2)))\nprint(su-max(b))\n"}, {"source_code": "l = list(map(int, input().split()))\nmn = sum(l)\nfor i in range(1, 101):\n\tif l.count(i) >= 2:\n\t\tmn = min(mn, sum(l) - i * 2)\n\tif l.count(i) >= 3:\n\t\tmn = min(mn, sum(l) - i * 3)\nprint(mn)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom collections import defaultdict\nfrom math import factorial as f\nfrom fractions import gcd as g\n\nl = [int (i) for i in raw_input ().split ()]\nret = sum (l)\nd = defaultdict (int)\nfor i in l: d [i] += 1\nfor i in d:\n if d [i] == 2:\n ret = min (ret, sum (l) - i * 2)\n if d [i] > 2:\n ret = min (ret, sum (l) - i * 3)\nprint ret\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jun 08 20:36:54 2016\n\n@author: Dell_\n\"\"\"\n\nimport sys\nif False:\n input = open('bear.txt', 'r')\nelse:\n input = sys.stdin\n\nnums = input.readline().split()\nmulti = []\nnew = []\ntester = False\nSum = 0\nfinal = 0\nsumHigh = 0\nsumLow = 0\nfinalSum = 0\n\nfor i in nums:\n if nums.count(i) > 1:\n multi.append(i)\n tester = True\nfor r in nums:\n r = int(r)\n Sum = Sum + r\n \nif tester:\n for i in multi:\n a = int(i)\n new.append(a)\n new.sort()\n high = new[-1]\n \n if len(new) == 2 or len(new) == 3:\n sumHigh = high * len(new)\n final = sumHigh\n \n elif len(new) == 4:\n if new.count(high) == 4:\n sumHigh = high * 3\n\n else:\n sumHigh = high * 2\n low = new[1]\n sumLow = low * 2\n \n if sumHigh > sumLow:\n final = sumHigh\n else:\n final = sumLow\n \n elif len(new) == 5:\n if new.count(high) == 5:\n sumHigh = high * 3\n \n else:\n sumHigh = high * new.count(high)\n low = new[1]\n sumLow = low * new.count(low)\n \n if sumHigh > sumLow:\n final = sumHigh\n else:\n final = sumLow\n \n finalSum = Sum - final\n print finalSum\n \nelse:\n print Sum"}, {"source_code": "c = map(int, raw_input().split())\nt = 0\nfor x in c:\n d = c.count(x)\n if d > 1:\n t = max(t, x * min(d, 3))\nprint sum(c) - t\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nt = [int(i) for i in raw_input().split()]\na = {}\ns = 0\nfor i in t:\n a[i] = a.get(i, 0) + 1\n s += i\n\nm = 0\nfor i in a.keys():\n if a[i] == 2 or a[i] == 3:\n m = max(a[i] * i, m)\n elif a[i] >= 3:\n m = max(3 * i, m)\n\nprint(s - m)\n"}, {"source_code": "y=sorted(list(map(int,input().split())))\np=[]\nfor i in range(1,len(y)):\n x=y.count(y[-i])\n if x>=2:\n if x<=3:p.append(sum(y)-y[-i]*x)\n else:p.append(sum(y)-y[-i]*3)\nprint(sum(y) if len(p)==0 else min(p)) "}, {"source_code": "numbers = list(map(int, input().split()))\n\nsum = 0\n\ncount = []\nfor i in range(0, 101):\n count.append(0)\n\nfor number in numbers:\n count[number] += 1\n sum += number\n\ncurrent_sum = sum\nfor number in numbers:\n if count[number] >= 2:\n if count[number] >= 3:\n multiply = 3\n else:\n multiply = 2\n if (sum - number * multiply) < current_sum:\n current_sum = sum - number * multiply\n\nprint(current_sum)"}, {"source_code": "a=list(map(int,raw_input().split()))\nd={}\nfor i in a:\n d[i]=0\nfor i in a:\n d[i]+=1\nans=sum(a)\nfor i in d:\n if d[i]>=3:\n ans=min(ans,sum(a)-3*i)\n elif d[i]>=2:\n ans=min(ans,sum(a)-2*i)\nprint ans\n \n"}, {"source_code": "r=lambda:map(int,raw_input().split())\nt=r()\n\ns=0\n\nfor e in set(t):\n for i in [2,3]:\n if t.count(e) >= i:\n s = max(s, e*i)\nprint sum(t)-s"}, {"source_code": "a = list(map(int, input().split()))\nb2 = [0]*101\nb3 = [0]*101\n\nfor x in a:\n b2[x] += 1\n b3[x] += 1\n\nfor i in range(100, 0, -1):\n if b3[i] >= 3:\n b3[i] -= 3\n break\n\nfor i in range(100, 0, -1):\n if b2[i] >= 2:\n b2[i] -= 2\n break\n\nprint(min(\n sum(i*x for i, x in enumerate(b2)),\n sum(i*x for i, x in enumerate(b3))))\n"}, {"source_code": "l = map(int, raw_input().strip().split(\" \"))\nl.sort()\ndic = {}\n\nfor i in l:\n\tif i in dic:\n\t\tdic[i] = dic[i] + 1\n\telse:\n\t\tdic[i] = 1\nm = []\nfor i in dic:\n\tif dic[i]>=2:\n\t\tm.append(i)\n\n\nfor i in dic:\n\tif dic[i]>3:\n\t\tdic[i] = 3\nif len(m)==0:\n\tprint sum(l)\nelif len(m)==1:\n\tprint sum(l)-m[0]*min(3,dic[m[0]])\nelif len(m)==2:\n\ty = max(m[0]*dic[m[0]], m[1]*dic[m[1]])\n\tprint sum(l)-y\n"}, {"source_code": "#!/usr/bin/env python\n\nfrom __future__ import print_function\nimport sys\n\nDEBUG = '-d' in sys.argv\n\ndef debug(*args, **kwargs):\n if DEBUG:\n print(*args, file=sys.stderr, **kwargs)\n\n return None\n\nts = map(int, raw_input().split())\n\nfrom collections import defaultdict\ncounts = defaultdict(int)\n\nfor t in ts:\n counts[t] += 1\n\ns = sum(ts)\n\ncounts = [(t, ctr) for (t, ctr) in counts.items() if ctr > 1]\n\nif counts != []:\n t, ctr = max(counts, key=lambda (t, ctr): min(ctr, 3) * t)\n s -= min(ctr, 3) * t\n\nprint(s)\n\n\n"}, {"source_code": "cards=list(map(int,input().split()))\nc=0\nfor i in cards:\n\tif cards.count(i)>=2 and i*cards.count(i)>c:\n\t\tif cards.count(i)>3:\n\t\t\tc=i*3\n\t\telse: c=i*cards.count(i)\n\nprint (sum(cards)-c)\n\n"}, {"source_code": "vlist=[int(x) for x in raw_input().split()]\nvlist.sort()\nlast=0\nnum=1\nmi=0\nfor x in vlist:\n if x==last and num<=2:\n num += 1\n mi=max(mi,x*num)\n else:\n num=1\n last=x\nprint sum(vlist)-mi\n"}, {"source_code": "t = map(int, raw_input().split())\nm = 0\nfor i in range(5):\n# delete doubles\n\tfor j in range(i+1, 5):\n\t\tif t[i] == t[j]: m = max(m, 2 * t[i])\n\t\nfor i in range(5):\n# delete doubles\n\tfor j in range(i+1, 5):\n\t\tfor k in range(j+1, 5):\n\t\t\tif t[i] == t[j] and t[j] == t[k]: m = max(m, 3 * t[i])\nprint sum(t) - m,"}, {"source_code": "t = sorted(list(map(int, input().split(\" \"))))\ns = sum(t)\nresult = s\nfor i in range(4):\n if t[i] == t[i+1]:\n result = min(result, s-sum(t[i:i+2]))\nfor i in range(3):\n if t[i] == t[i+2]:\n result = min(result, s-sum(t[i:i+3]))\nprint(result)\n"}, {"source_code": "#coding: utf-8\narr = raw_input()\nnum = arr.split()\nsum = 0\nar = []\nfor x in num:\n ar.append(int(x))\n sum += int(x)\nmaxx = 0\ndic = {}\nfor x in ar:\n dic[x] = 0\nfor x in ar:\n dic[x]+=1\nmaxx = 0\nfor x in ar:\n if dic[x] == 2:\n maxx = max(x*2,maxx)\n elif dic[x] >=3:\n maxx = max(x*3,maxx)\nprint sum - maxx\n\n\n"}, {"source_code": "from collections import Counter\nA = map(int, raw_input().split())\nC = Counter(A)\nTh = filter(lambda x: C[x]>=3 ,C)\nTw = filter(lambda x: C[x]==2 ,C)\nif Th and Tw:\n\tprint sum(A) - max(Th[0]*3, Tw[0]*2)\nelif Th:\n\tprint sum(A) - Th[0]*3\nelif Tw:\n\tprint sum(A) - max(Tw)*2\nelse:\n\tprint sum(A)"}, {"source_code": "x=[]\nx=map(int,raw_input().split())\ndict={}\ny=[]\nsum=0\nfor i in x:\n if i in dict.keys():\n dict[i]+=1\n else:\n dict[i]=1\n sum+=i\n\nif dict.keys==len(x):\n print sum\nelse:\n m=sum\n for key,value in dict.iteritems():\n if value>1:\n m=min(m,sum-(key*min(max(2,value),3)))\n print m\n"}, {"source_code": "# coding: utf-8\nnum = raw_input().split()\nnum = map(int, num)\nnum.sort()\ns = sum(num)\nans = s\nfor i in range(4):\n if num[i] == num[i+1]:\n ans = s - num[i]*2\n\nfor i in range(3):\n if num[i] == num[i+1] and num[i+1] == num[i+2]:\n ans = min(ans, s-num[i]*3)\n\nprint ans\n"}, {"source_code": "a=map(int,raw_input().split())\na.sort()\na.reverse()\nx=sum(a)\nres=0\nfor i in a:\n\tif a.count(i)>=3:\n\t\tres=max(res,3*i)\n\telif a.count(i)>=2:\n\t\tres=max(res,2*i)\nprint x-res\n\n"}, {"source_code": "x = list(map(int, input().split()))\nx_init = x.copy()\nx.sort()\ni = 0\nwhile i != len(x):\n if x.count(x[i]) == 1 or x.count(x[i]) > 3:\n del x[i]\n i = -1\n i += 1\nif len(x) != 0:\n cur_max, cur_min = x[0], x[0]\nfor j in range(1, len(x)):\n if x[j] == x[j - 1]:\n cur_min += x[j]\n if j == len(x) - 1 and cur_min > cur_max:\n cur_max = cur_min\n else:\n if cur_min > cur_max:\n cur_max = cur_min\n cur_min = x[j]\nif len(x) != 0:\n print(sum(x_init) - cur_max)\nelse:\n print(sum(x_init))\n"}, {"source_code": "t=list(map(int,input().split()))\nsumt=sum(t)\narr=[]\n#darr=[]\nfor i in range(0,5):\n\tfor j in range(i,5):\n\t\tif i!=j:\n\t\t\t#print(i,j)\n\t\t\tif t[i]==t[j]:\n\t\t\t\tarr.append(sumt-t[i]-t[j])\n\t\t\t\t#darr.append(t[i])\nfor i in range(0,5):\n\tfor j in range(i,5):\n\t\tfor k in range(j,5):\n\t\t\tif i!=j!=k:\n\t\t\t\t#print(i,j,k)\n\t\t\t\tif t[i]==t[j]==t[k]:\n\t\t\t\t\tarr.append(sumt-t[i]-t[j]-t[k])\t\t\t\t\n\t\t\t\t\t#darr.append(t[i])\n#print(darr)\n#print(arr)\nif arr==[]:\n\tprint(sumt)\nelse:\t\n\tprint(min(arr))\t\t\t\t\t"}, {"source_code": "arr = map(int, raw_input().split())\n\narr = sorted(arr)\nl=len(arr)\nsum2 = 0\nsum3 = 0\ns=sum(arr)\n\ncnt = 1\nfor x in range(l - 1):\n if (arr[x] == arr[x+1]):\n cnt += 1\n if (cnt == 2 and cnt*arr[x] > sum2):\n sum2 = 2*arr[x]\n\n elif (cnt == 3 and cnt*arr[x] > sum3):\n sum3 = 3*arr[x]\n else:\n cnt = 1\n\nprint s - max(sum2, sum3)"}, {"source_code": "from collections import Counter\n\nT = map(int, raw_input().split())\nt = Counter(T)\ntotal = sum(T)\nmn = total\n\nfor v in t.keys():\n\n if t[v] >= 2:\n mn = min(mn, total - v * min(3, t[v]))\n\nprint mn\n"}, {"source_code": "t = map(int, raw_input().split())\ns = sum(t)\nm2, m3 = 0, 0\nfor n in t:\n if t.count(n) >= 3:\n m3 = n * 3\n if t.count(n) == 2:\n m2 = max(m2, n * 2)\nprint(s - max(m2, m3))\n"}, {"source_code": "def f(l,i):\n\tk = list(range(4))\n\tjj = 0\n\tfor j in range(5):\n\t\tif j!=i:\n\t\t\tk[jj] = l[j]\n\t\t\tjj += 1\n\treturn k\nl = list(map(int,raw_input().split(' ' )))\nm = sum(l)\nfor i in range(5):\n\tk = f(l,i)\n\tif l[i] in k:\n\t\tt=2\n\t\twhile t and l[i] in k:\n\t\t\tt -=1\n\t\t\tk.pop(k.index(l[i]))\n\t\tif m>sum(k):\n\t\t\tm = sum(k)\nprint(m)\n"}, {"source_code": "import sys\nfrom collections import Counter\n\nif __name__ == \"__main__\":\n cards = [int(i) for i in sys.stdin.readline().strip().split()]\n c = sorted(((key, value) for key, value in Counter(cards).iteritems() if value > 1), key=lambda x: x[0]*x[1])\n if c:\n value = c[-1]\n print sum(cards) - min(value[1], 3) * value[0]\n else:\n print sum(cards)\n"}, {"source_code": "lst=[int(i) for i in input().split()]\nsum1=sum(lst)\nmin1=sum1\nfor i in lst:\n nd=0\n for j in lst:\n if i==j:\n nd+=1\n if nd>3:\n nd=3\n c=sum1-(i*nd)\n #print(i,nd)\n if c<min1 and nd>1:\n min1=c\nprint(min1)\n"}, {"source_code": "a = sorted(map(int, raw_input().split()))\nans = 0\nif a[0] == a[1] and a[0] == a[2]: ans = max(ans, a[0]+a[1]+a[2])\nif a[3] == a[1] and a[3] == a[2]: ans = max(ans, a[3]+a[1]+a[2])\nif a[3] == a[4] and a[3] == a[2]: ans = max(ans, a[3]+a[4]+a[2])\n\nif a[0] == a[1]: ans = max(ans, a[0]+a[1])\nif a[2] == a[1]: ans = max(ans, a[2]+a[1])\nif a[2] == a[3]: ans = max(ans, a[2]+a[3])\nif a[3] == a[4]: ans = max(ans, a[4]+a[3])\nprint sum(a) - ans"}, {"source_code": "import sys\nimport math\nimport bisect\nimport itertools\nimport random\n\ndef main():\n A = list(map(int, input().split()))\n d = dict()\n for a in A:\n if a not in d:\n d[a] = 0\n d[a] += 1\n min_val = sum(A)\n for a in d:\n if d[a] >= 2:\n val = sum(A) - a * 2\n min_val = min(min_val, val)\n if d[a] >= 3:\n val = sum(A) - a * 3\n min_val = min(min_val, val)\n print(min_val)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "l = list(map(int, input().split()))\norig = sum(l)\nans = sum(l)\nfor i in l:\n if l.count(i) == 2:\n ans = min(ans, orig-i*2)\n elif l.count(i) >= 3:\n ans = min(ans, orig-i*3)\nprint(ans)\n"}, {"source_code": "t=map(int,raw_input().split());\nt.sort();L=[];\nfor i in xrange(3):\n if (t[i]==t[i+1] and t[i+2]==t[i]):\n L.append(3*t[i]);\nfor i in xrange(4):\n if (t[i]==t[i+1]):\n L.append(2*t[i]);\nif (len(L)>0):\n print sum(t)-max(L);\nelse:\n print sum(t);\n"}, {"source_code": "l=list(map(int, input().split()))\nmaxx=0\nfor i in set(l):\n if l.count(i)>=2:\n maxx=max(min(3,l.count(i))*i,maxx)\nprint(sum(l)-maxx)\n"}, {"source_code": "t = map(int, raw_input().split())\nsame = False\n\nfor i in range(1,5):\n\tfor j in range(i):\n\t\tif t[i] == t[j]:\n\t\t\tsame = True\n\t\t\tbreak\n\tif same:\n\t\tbreak\n\telse:\n\t\tcontinue\n\t\t\nif same:\n\tt.sort()\n\tnumbers = [t[0]]\n\ttimes = [1]\n\tj = 0\n\tfor i in range(1,5):\n\t\tif t[i] == t[i-1]:\n\t\t\ttimes[j] += 1\n\t\telse:\n\t\t\tnumbers.append(t[i])\n\t\t\tj += 1\n\t\t\ttimes.append(1)\n\t\t\t\n\tsums = []\n\tfor i in range(len(times)):\n\t\tif times[i] == 2:\n\t\t\tsums.append(sum(t) - numbers[i] * times[i])\n\t\telif times[i] >= 3:\n\t\t\tsums.append(sum(t) - numbers[i] * 3)\n\t\telse:\n\t\t\tcontinue\n\tprint min(sums)\n\t\nelse:\n\tprint sum(t)"}, {"source_code": "t = [int(x) for x in input().split()]\n\nminsum = sum(t)\n\nfor i in t:\n icount = t.count(i)\n if icount >= 3:\n minsum = min(minsum, sum(t) - 3 * i)\n if icount >= 2:\n minsum = min(minsum, sum(t) - 2 * i)\n\nprint(minsum)"}, {"source_code": "def f(l):\n i = 0\n while i!=len(l):\n if l.count(l[i])>1:\n del l[i]\n else:\n i+=1\n return l\nl = raw_input().split(\" \")\nfor i in range(5):\n l[i] = int(l[i])\nl1 = f(l[:])\nl2 = []\nl3 = []\nfor i in range(len(l1)):\n if l.count(l1[i])>1:\n if l.count(l1[i])<4:\n l2.append(l1[i]*l.count(l1[i]))\n else:\n l2.append(l1[i]*3)\n l2.append(l1[i]*(l.count(l1[i])-3))\n else:\n l3.append(l1[i])\nl2 = sorted(l2)\nprint sum(l2[:-1])+sum(l3)"}, {"source_code": "read = lambda: map(int, input().split())\nt = sorted(read())\nSum = ans = sum(t)\na = set(t)\nfor i in a:\n if t.count(i) == 1: continue\n cur = Sum - min(3, t.count(i)) * i\n ans = min(ans, cur)\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python\n\ndef main():\n cards = [int(x) for x in raw_input().split()]\n dict_cnt = {}\n for card in cards:\n if card in dict_cnt:\n dict_cnt[card] += 1\n else:\n dict_cnt[card] = 1\n discard = [3 * x if dict_cnt[x] >= 3 else 2 * x\n for x in dict_cnt if dict_cnt[x] >= 2]\n print sum(cards) - (max(discard) if discard else 0)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = [int(i) for i in input().split()]\ns.sort()\ng = 10000000\nfor i in range(2, -1, -1):\n if (s[i] == s[i + 1] == s[i + 2]):\n g = sum(s) - s[i] * 3\n break\nfor i in range(3, -1, -1):\n if (s[i] == s[i + 1]):\n g = min(sum(s) - s[i] * 2, g)\n break\ng = min(sum(s), g)\nprint(g)"}, {"source_code": "l=[int(i) for i in raw_input().split()]\nh=[0]*101\ns=sum(l)\nfor i in l:\n h[i]+=1\nm=s\nfor i in xrange(1,101):\n if(h[i]==2):\n m=min([m,s-2*i])\n if h[i]>=3:\n m=min([m,s-3*i])\nprint m\n\n"}, {"source_code": "import collections\n\ndef minCardSum(arr):\n count = collections.Counter(arr)\n current = 0\n for num in arr:\n if count[num] > 1 and num * min(count[num], 3) > current:\n current = min(count[num], 3) * num\n return sum(arr) - current\n \nprint(minCardSum(list(map(int, input().split()))))"}, {"source_code": "a=list(map(int, input().split()))\nb={};sum=0\n\nfor i in a:\n\tif i not in b:\n\t\tb[i]=1\n\telse:\n\t\tb[i]+=1\np=[]\nfor i, j in b.items():\n\tif j==1:\n\t\tsum+=i\n\telif j>3:\n\t\tsum+=i*(j-3)\n\telse:\n\t\tp+=[i*j]\nif len(p)>1:\n\tsum+=min(p)\nprint(sum)"}, {"source_code": "# Amirhossein Alimirzaei\n# University Of Bojnourd\n# Telegram : @HajLorenzo\n# Instagram : amirhossein_alimirzaei\n# CodeForcesian ;)\n\n_=list(map(int,input().split()))\n__=list(set(_))\n_____=[]\nif _.count(__[0])==len(_):\n print(sum(_)-__[0]*3)\nelse:\n for ___ in range(len(__)):\n if _.count(__[___])>1:\n tmp=_.copy()\n ______=0\n for ____ in range(_.count(__[___])):\n ______ += 1\n if ______ == 4:\n break\n tmp.remove(__[___])\n _____.append(sum(tmp))\n print(min(_____) if len(_____)>0 else sum(_))"}, {"source_code": "ip = raw_input()\nipl = [int(i) for i in ip.split()]\ncount = 0\nvar = []\nlarge = 0\nfor y in xrange(0,101):\n\tvar.append(0)\n\nfor x in xrange(0,5):\n\tcount = count + ipl[x]\n\tvar[ipl[x]] = var[ipl[x]] + 1\n\nfor z in xrange(1,101):\n\tif 2 <= var[z] <= 3 :\n\t\tif large < var[z]*z :\n\t\t\tlarge = var[z]*z\n\telif var[z] > 3 :\n\t\tlarge = 3*z\n\nprint count - large\n"}, {"source_code": "t = list(map(int, input().split()))\ntset = list(set(t))\nt.sort()\nif len(tset) == 1:\n print(tset[0] * 2)\nelif len(tset) == 2:\n if t.count(tset[0]) == 1 or t.count(tset[0]) == 4:\n print(tset[0] + tset[1])\n else:\n print(min(t.count(tset[0]) * tset[0], t.count(tset[1]) * tset[1]))\nelif len(tset) == 3:\n for i in range(3):\n if t.count(tset[i]) == 3:\n print(sum(t) - 3 * tset[i])\n exit()\n else:\n t.sort()\n if t.count(max(t)) == 1:\n print(sum(t) - 2 * t[3])\n else:\n print(sum(t) - 2 * t[4])\n exit()\nelif len(tset) == 4:\n for i in range(4):\n if t.count(tset[i]) == 2:\n print(sum(t) - 2 * tset[i])\n exit()\nelse:\n print(sum(t))\n"}, {"source_code": "arr = list(map(int, input().split()))\n\ncounts = dict()\nmx = -1\n\nfor i in arr:\n if i in counts:\n counts[i] += 1\n else:\n counts[i] = 1\n\nfor k, v in counts.items():\n if v >= 2:\n mx = max(mx, k * min(v, 3))\n\nif mx != -1:\n print(sum(arr) - mx)\nelse:\n print(sum(arr))"}, {"source_code": "cards = sorted(map(int, raw_input().split()))\nsu = sum(cards)\ntakeaway=0\ncounts= [cards.count(cards[i]) for i in range(5)]\nfor i in range(0,4):\n if (counts[i]>=2):\n if (counts[i+1]>=2):\n b=cards[i]+cards[i+1]\n takeaway=max([takeaway,b])\nfor i in range(0,3):\n if (counts[i]>=3):\n if (counts[i+1]>=3):\n if (counts[i+2]>=3):\n b=cards[i]+cards[i+1]+cards[i+2]\n takeaway=max([takeaway,b])\nsu=su-takeaway\nprint(su)"}, {"source_code": "t = list(map(int, input().split()))\ntriples = [s for s in t if t.count(s) >= 3]\ndoubles = [s for s in t if t.count(s) == 2]\ntriples.sort()\ndoubles.sort()\nm = 0\nif triples:\n m = 3*triples[-1]\nif doubles:\n m = max(m, 2*doubles[-1])\nprint(sum(t)-m)\n\n\n"}, {"source_code": "l = list(map(int,input().split()))+[0]\nans = sum(l)\nfor k in l:\n if l.count(k) >= 2:\n ans = min(sum(l) - min(l.count(k),3)*k,ans)\nprint(ans)\n"}, {"source_code": "from collections import Counter\n\nls = list(map(int, input().split()))\nls.sort()\nls.reverse()\nd = dict(Counter(ls))\nMax = 0\nfor k, v in d.items():\n if v>=3: Max = max(Max, 3*k)\n if v==2: Max = max(Max, 2*k)\nprint(sum(ls)-Max)\n"}, {"source_code": "t = sorted(list(map(int, input().split())))\nb = []\nfor i in range(5):\n\tif t.count(t[i])>1:\n\t\tif t.count(t[i])>3:\n\t\t\tb.append(t[i]*3)\n\t\telse:\n\t\t\tb.append(t[i]*t.count(t[i]))\nif len(b)==0:\n\tprint(sum(t))\nelse:\n\tprint(sum(t)-max(b))"}, {"source_code": "l = list(map(int,input().split()))\ntry:\n r = max(x * min(3,l.count(x)) for x in l if l.count(x) >= 2)\n print (sum(l) - r)\nexcept:\n print (sum(l))"}, {"source_code": "a=[]\na=list(map(int,input().split()))\na.sort()\ni=4\ns=sum(a)\ncount=0\nb=[]\nb.append(0)\nwhile(i>=0):\n\tk=a.count(a[i])\n\tif k>=2:\n\t\tif k==2:\n\t\t\tb.append(a[i]*k)\n\t\telse:\n\t\t\tb.append(a[i]*3)\n\ti-=1\nsminus=max(b)\ns=s-sminus\nprint(s)\n\n\n\n"}, {"source_code": "a = list(map(int,input().split()))\nr = list(set(a))\nd = {}\nfor i in r:\n\tif a.count(i)>=2:\n\t\td[i] = a.count(i)\nmax1 = 0\nfor i in d:\n\tif d[i]>2:\n\t\tif i*3 > max1:\n\t\t\tmax1 = i*3\n\telse:\n\t\tif i*2 > max1:\n\t\t\tmax1 = i*2\nprint(sum(a)-max1)"}, {"source_code": "a, b = list(map(int, input().split())), []\nfor i in set(a):\n if a.count(i) >= 3:\n b.append(i*3)\n if a.count(i) == 2:\n b.append(i*2)\nprint(sum(a) - max(b) if len(b) != 0 else sum(a)) \n# happy new year\n#CodeForcesian"}, {"source_code": "a = list(map(int, input().split()))\nS = sum(a)\nres = S\n\nfor x in a:\n\tn = a.count(x)\n\tif n >= 2:\n\t\tres = min(res, S - min(3, n) * x)\n\nprint(res)"}, {"source_code": "def solution(l1):\n l1.sort()\n i=0\n ans=[0]\n while i<len(l1):\n targ=l1[i]\n j=0\n count=0\n while j<len(l1):\n if l1[j]==targ:\n count+=1\n j+=1\n if count>=3:\n ans.append(3*targ)\n elif count>=2:\n ans.append(2*targ)\n i+=1\n ans.sort()\n ans.reverse()\n return sum(l1)-ans[0]\n\n\ndef answer():\n l1 = [int(x) for x in input().split()]\n print(solution(l1))\nanswer()"}, {"source_code": "a = sorted(map(int, input().split()))\np = ((0, 1), (1, 2), (2, 3), (3, 4), (0, 2), (1, 3), (2, 4))\nprint(sum(a) - max(0 if a[i] != a[j] else (j - i + 1) * a[i] for i, j in p))"}, {"source_code": "from collections import defaultdict,deque,Counter,OrderedDict\nimport sys\nsys.setrecursionlimit(20000)\ndef main():\n l = list(map(int,input().split()))\n ans,tos = sum(l),0\n mp = defaultdict(int)\n for i in l: mp[i] += 1\n for k in mp:\n if mp[k] >= 3:\n tos = max(tos,k*3)\n if mp[k] >= 2:\n tos = max(tos,k*2)\n print(ans - tos)\n\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a = list(map(int,input().split()))\na.sort(); ans1,ans2 = 0,0\nif a[4] == a[2]: ans1 = a[4]+a[3]+a[2]\nelif a[3] == a[1]: ans1 = a[1]+a[2]+a[3]\nelif a[2] == a[0]: ans1 = a[2]+a[1]+a[0]\nif a[4] == a[3]: ans2 = a[4]+a[3]\nelif a[3] == a[2]: ans2 = a[2]+a[3]\nelif a[2] == a[1]: ans2 = a[1]+a[2]\nelif a[1] == a[0]: ans2 = a[1]+a[0]\nif ans1 == 0 and ans2 == 0: print(sum(a))\nelse: print(sum(a)-max(ans1,ans2))"}, {"source_code": "l = list(map(int,input().split()))\ns = sum(l)\na = list(set(l))\nc = []\nfor i in a:\n x = l.count(i)\n if(x>=3):\n c.append(3*i)\n elif(x>=2):\n c.append(2*i)\n else:\n c.append(0)\n\nprint(s-max(c))"}, {"source_code": "l = list(map(int,input().split()))\nz = []\nif len(set(l)) == len(l):\n print(sum(l))\n\nelse:\n for i in set(l):\n if l.count(i) > 1:\n z.append(i*min(l.count(i),3))\n print(sum(l)-max(z))"}], "negative_code": [{"source_code": "l = list(map(int,input().split()))\ns = sum(l)\na = list(set(l))\na = a[::-1]\nc = []\nfor i in a:\n c.append(l.count(i))\nz = c.index(max(c))\nif(c[z]>=3):\n s-=3*a[z]\nelif(c[z]>=2):\n s-=2*a[z]\n\nprint(s)"}, {"source_code": "from collections import Counter\n\nlist = map(int, raw_input().split())\narr1 = []\narr2 = []\nk = Counter(list)\nfor i in k:\n arr1.append(i)\n arr2.append(k[i])\nk2= 100000\nk1=0\nk3=0\nk4=0\nk5=0\n\nfor i in xrange(len(arr2)):\n if(arr2[i]==2):\n if(arr1[i]<max):\n k2 = arr1[i]\n max = arr1[i]\nif(k2 == 100000):k2=0\nk2=k2*2\nfor i in xrange(len(arr2)):\n if(arr2[i]==1):\n k1 = k1+arr1[i]\n\nfor i in xrange(len(arr2)):\n if(arr2[i]==3):\n k3=arr1[i]*3\n if(k3>k2):\n k3=k2\n k2=0\n\nfor i in xrange(len(arr2)):\n if(arr2[i]==4):\n k4 = arr1[i]\n\n\nfor i in xrange(len(arr2)):\n if(arr2[i]==5):\n k5=arr1[i]*2\n\nprint k1+k2+k3+k4+k5\n\n"}, {"source_code": "a = list(map(int, input().split()))\na = sorted(a)\nt = 0\nq = 0\np = 0\nfor j in range(5):\n p += a[j]\n\nfor i in range(4,0,-1):\n if a[i] == a[i-2]:\n q += 3*a[i]\n break\nfor k in range(4,0,1):\n if a[k] == a[k-1]:\n t += 2*a[k]\n break\n\n\nprint(p-max(t,q))"}, {"source_code": "#!/usr/bin/python\n\na = raw_input ()\na = a . split ()\nb = []\nc = []\ne = []\nf = []\ng = []\no = []\n\nif len (a) == 5 :\n \n for x in a :\n \n x = int (x) \n if 1 <= x <= 100 :\n e.append (x)\n o.append (x) \n else :\n quit ()\n \n for x in o :\n \n if o.count (x) >= 3 :\n #print '33333333'\n \n if x not in b :\n e = o\n while len (b) != 3 :\n #print 'e',e\n e.pop (e.index(x))\n #print 'e',e\n b.append (x)\n #print 'b',b\n f . append ( sum (e) )\n e = o\n \n \n elif o.count (x) == 2 :\n #print '22222222'\n if x not in c :\n while len (c) != 2 :\n #print 'e',e\n e.pop (e.index(x))\n #print 'e',e\n c.append (x)\n #print 'c',c\n if len (g) == 2 :\n e = o\n break\n g . append ( sum (e) )\n #print 'g',g\n e = o\n \n \n if len (f) != 0 :\n h = min (f)\n else :\n h = 0\n \n if len (g) != 0 :\n j = min (g)\n else :\n j = 0\n \n if h != 0 and j != 0 :\n print min ( h , j )\n elif h == 0 and j != 0 :\n print j\n elif h != 0 and j == 0 :\n print h\n else :\n print sum (o)"}, {"source_code": "arr=map(int,raw_input().strip().split(\" \"))\narr.sort()\nsu=sum(arr)\nif(arr[4]==arr[3]):\n if(arr[3]==arr[2]):\n su=su-arr[4]*3\n else:\n if(arr[2]==arr[1]):\n if(arr[1]==arr[0]):\n su=su-max(arr[4]*2,arr[2]*3)\n else:\n su=su-arr[4]*2\nelif(arr[3]==arr[2]):\n if(arr[2]==arr[1]):\n su=su-arr[3]*3\n else:\n su=su-arr[3]*2\nelif(arr[2]==arr[1]):\n if(arr[1]==arr[0]):\n su=su-arr[2]*3\n else:\n su=su-arr[2]*2\nelif(arr[1]==arr[0]):\n su=su-arr[1]*2\nprint su\n"}, {"source_code": "lst=[int(i) for i in input().split()]\nsum1=sum(lst)\nmin1=sum1\nfor i in lst:\n nd=0\n for j in lst:\n if i==j:\n nd+=1\n if nd>=3:\n nd=3\n c=sum1-(i*nd)\n if c<min1:\n min1=c\n \n \nprint(min1)\n"}, {"source_code": "\n\nli=list(map(int,input().split()))\n\n\n\nsm = sum(li)\n\nmn=sm\n\nfor i in li:\n\n\n\n\n\n cnt=li.count(i)\n\n if cnt>=2:\n\n mn = min(sum(li)-cnt*i, mn)\nprint(mn)\n\n\n \n\n \n \n\n \n"}, {"source_code": "\n\na=list(map(int,input().split()))\na.sort(reverse=True)\np_ans=0\nfor i in range(len(a)-1):\n\tif a[i]==a[i+1]:\n\t\tif i!=0:\n\t\t\tif a[i]==a[i-1]:\n\t\t\t\tc=3*a[i]\n\t\t\t\tif p_ans<c:\n\t\t\t\t\tp_ans=c\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tc=2*a[i]\n\t\t\t\tif p_ans<=c:\n\t\t\t\t\tp_ans=c\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\telse:\n\t\tcontinue\nprint(sum(a)-p_ans)\n"}, {"source_code": "n=list(map(int,input().split()))\nx=list(set(n))\nx.sort()\nc=[n.count(i) for i in x]\nc.sort\nl=len(c)\nif(len(x)==5):\n\tprint(sum(n))\nelse:\n\tans=0\n\tfor i in range(l):\n\t\tif(c[i]==2):\n\t\t\tans=2*(x[i])\n\n\tif( 3 in c or 4 in c or 5 in c):\n\t\tif(3*(x[-1])>ans):\n\t\t\tans=3*(x[-1])\n\t\n\tprint(sum(n)-ans)\n\n"}, {"source_code": "ns = map(int, raw_input().split())\n\nd = {}\n\nfor num in ns:\n d[num] = d.get(num, 0) + 1\n\ns = sum(ns)\nans = 0xFFFFFFFF\n\nfor key, value in d.items():\n if value >= 2:\n ans = min(ans, s - 2 * key)\n if value >= 3:\n ans = min(ans, s - 3 * key)\n\nprint ans\n"}, {"source_code": "t = map(int, raw_input().split())\nans = 0\nfor i in t:\n\tk = t.count(i)\n\tif(k>=2):\n\t\tans = max(ans,k*i)\nprint sum(t)-ans"}, {"source_code": "a = list(map(int, input().split()))\nb = [0]*101\n\nfor x in a:\n b[x] += 1\n\nfor i in range(100, 0, -1):\n if b[i] >= 3:\n b[i] -= 3\n break\n if b[i] >= 2:\n b[i] -= 2\n break\n\nprint(sum(i*x for i, x in enumerate(b)))\n"}, {"source_code": "a=list(map(int,input().split()))\na.sort(reverse=True)\nd={}\nfor i in range(len(a)):\n if a[i] not in d:\n d[a[i]]=1\n else:\n d[a[i]]+=1\nf=0\nfor i in range(len(a)):\n if d[a[i]]>=3:\n print(sum(a)-a[i]*3)\n f=1\n break\n elif d[a[i]]>=2:\n print(sum(a)-a[i]*2)\n f=1\n break\nif f==0:\n print(sum(a))"}, {"source_code": "li=list(map(int,input().split()))\nki=[]\nfor i in range(len(li)):\n k=li.count(li[i])\n if k>1:\n if k==2:\n ki.append(sum(li)-li[i]*2)\n else:\n ki.append(sum(li) - li[i] * 3)\nif len(ki)>0:\n print(min(ki))\nelse:\n print('0')"}, {"source_code": "import collections\n\n#tt = int(raw_input())\na = map(int, raw_input().split())\ndic = collections.Counter(a)\nb = sum(a)\n#print dic\nif max(dic.values()) < 2:\n\tprint b# 'asdf'\n\nelif len(dic) == 1:\n\tprint 2*dic.keys()[0]# 'qwe'\n\nelse:\n\tans = 10**9\t\t \n\tfor i in dic.keys():\n\t\tif dic[i] < 2:\n\t\t\tcontinue\n\n\t\tsum1 = b - i*dic[i]\n\t\tif sum1 < ans:\n\t\t\tans = sum1\n\n\tprint ans"}, {"source_code": "n = [int(i) for i in input().split()]\n\nif len(set(n)) == len(n):\n\tprint(sum(n))\nelse:\n\tl2 = [n[i] for i in range(len(n)) if 3>n.count(n[i])>1]\n\tl3 = [n[i] for i in range(len(n)) if n.count(n[i])>2]\n\t#print(set(l2), set(l3))\n\tif set(l3) != set() and set(l2) == set():\n\t\tfor i in range(3):\n\t\t\tn.remove(max(set(l3)))\n\telif set(l3) == set() and set(l2) != set():\n\t\tfor i in range(2):\n\t\t\tn.remove(max(set(l2)))\n\telif set(l3) != set() and set(l2) != set():\n\t\t\tif sum(set(l2)) > sum(set(l3)):\n\t\t\t\tfor i in range(2):\n\t\t\t\t\tn.remove(max(set(l2)))\n\t\t\telse:\n\t\t\t\tfor i in range(3):\n\t\t\t\t\tn.remove(max(set(l3)))\n\tprint(sum(n))"}, {"source_code": "a=[int(i) for i in input().split()]\nb=[]\ns=0\nfor i in range(4):\n for j in range(i+1,5):\n if a[i]>a[j]:\n a[i], a[j] = a[j], a[i]\nt=0\nfor i in range(4):\n s+=a[i]\n if a[i]==a[i+1] and t<2:\n t+=1\n else:\n if t>0:\n b.append([a[i], t+1])\n t=0\ns+=a[4]\nif len(b)==0:\n print(s)\nelse:\n m=b[0][0]*b[0][1]\n for i in b:\n if i[0]*i[1]>m:\n m= i[0]*i[1]\n print(s-m)"}, {"source_code": "from collections import Counter\n\nt = list(map(int, input().split()))\ncnt = Counter(t)\nprint(sum(cnt) - max(2 * el if cnt[el] == 2 else 3 * el for el in cnt if cnt[el] > 1))"}, {"source_code": "cards = input().split()\ncards = sorted([int(x) for x in cards], reverse=True)\nlowest_sum = []\ntokens = 1\ncounter = 1\ncurrent = 0\n\nz_counter = 0\nmost_repeated = []\nfor z in cards:\n if counter >= len(cards):\n break\n else:\n if z == cards[counter]:\n z_counter += 1\n if z_counter == 2:\n most_repeated.append(z)\n most_repeated.append(z)\n most_repeated.append(z)\n\n else:\n z_counter = 0\n counter += 1\ncounter = 1\n\nfor y in cards:\n if counter >= len(cards):\n break\n else:\n if y == cards[counter]:\n current = y\n break\n else:\n counter += 1\n\ncounter = 1\n\nfor num in cards:\n if counter >= len(cards):\n break\n else:\n if num == cards[counter] == current and tokens < 3:\n lowest_sum.append(num)\n if cards[counter] != cards[counter + 1]:\n lowest_sum.append(cards[counter])\n tokens += 1\n counter += 1\ncard_sum = min((sum(cards) - sum(lowest_sum)), (sum(cards) - sum(most_repeated)))\nprint(card_sum)\n"}, {"source_code": "n=list(map(int,input().split()))\nx=list(set(n))\nx.sort()\nc=[n.count(i) for i in x]\nc.sort\nl=len(c)\nif(len(x)==5):\n\tprint(sum(n))\nelse:\n\tans=0\n\tfor i in range(l):\n\t\tif(c[i]==2):\n\t\t\tans=2*(x[i])\n\n\tif( 3 in c or 4 in c or 5 in c):\n\t\tif(3*(x[-1])>ans):\n\t\t\tans=3*(x[-1])\n\t\n\tprint(sum(n)-ans)\n\n"}, {"source_code": "import sys\n\ndef minSum(arr):\n\tnum_dict = {}\n\tfor num in sorted(arr,reverse=True):\n\t\tnum_dict[num] = num_dict.get(num,0)+1\n\tremoved=False\n\tminsum = 0\n\tfor k in num_dict:\n\t\tv = num_dict.get(k)\n\t\tif not removed:\n\t\t\tif v>1 and v<=3:\n\t\t\t\tremoved = True\n\t\t\telif v>3:\n\t\t\t\tminsum = minsum + k*(num_dict.get(k)-3)\n\t\t\t\tremoved = True\n\t\t\telse:\n\t\t\t\tminsum = minsum + k*(num_dict.get(k))\n\t\telse:\n\t\t\tminsum = minsum + k*(num_dict.get(k))\n\treturn minsum\n\ndef main():\n\tarr = list(int(x) for x in sys.stdin.readline().strip().split())\n\n\tprint(minSum(arr))\n\nmain()"}, {"source_code": "def arr_inp():\n return [int(x) for x in input().split()]\n\n\na = arr_inp()\nix, out = 0, sum(a)\n\nwhile (ix < 5):\n a_copy = a.copy()\n c = a.count(a[ix])\n if (c >=2):\n for i in range(min(3,c)):\n a_copy.remove(a[ix])\n out=min(out,sum(a_copy))\n ix+=c\nprint(out)\n"}, {"source_code": "from sys import stdin, stdout\n\n\narr=list(map(int,stdin.readline().split()))\nsl=len(set(arr))\ns=sum(arr)\narr.sort()\nif(len(arr)==sl):\n ans=s\nelif(sl==1):\n ans=arr[0]+arr[1]\nelse:\n\n map={}\n for i in arr:\n try:\n map[i]+=1\n except:\n map[i]=1\n #3 and 4\n arr = list(set(arr))\n for i in arr:\n if (map[i] < 2):\n map[i] = 0\n if(sl==3):\n\n ans=s-max(map[arr[0]]*arr[0],map[arr[1]]*arr[1],map[arr[2]]*arr[2])\n elif(sl==2):\n ans = s - max(map[arr[0]] * arr[0], map[arr[1]] * arr[1])\n else:\n ans = s - max(map[arr[0]] * arr[0], map[arr[1]] * arr[1], map[arr[2]] * arr[2],map[arr[3]]*arr[3])\n\n\nstdout.write(str(ans)+\"\\n\")\n"}, {"source_code": "\nt = list(map(int, input().split()))\ntmp = 0\nfor i in t:\n if t.count(i) >= 3:\n print(i * 3)\n exit()\n if t.count(i) == 2:\n if tmp < i:\n tmp = i\nprint(sum(t) - (tmp * 2))\n\n# CodeForcesian\n# \u2665\n# \u06cc\u0627 \u0627\u0645\u0627\u0645 \u0631\u0636\u0627\n\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\nlst = get_int_list()\ns = sum(lst)\nm = max(lst, key = lambda x: ((lst.count(x)-1)*x))\nprint(m)\nif lst.count(m) >= 3:\n print(s-3*m)\nelif lst.count(m) == 2:\n print(s-2*m)\nelse:\n print(s)"}, {"source_code": "x=[]\nx=map(int,raw_input().split())\ndict={}\ny=[]\nsum=0\nfor i in x:\n if i in dict.keys():\n dict[i]+=1\n else:\n dict[i]=1\n sum+=i\n\nif dict.keys==len(x):\n print sum\nelse:\n m=sum\n for key,value in dict.iteritems():\n if value>1:\n m=min(sum,sum-(key*min(max(2,value),3)))\n print m\n"}, {"source_code": "import os\n\nimport sys\n\ndebug = True\n\nif debug and os.path.exists(\"input.in\"):\n input = open(\"input.in\", \"r\").readline\nelse:\n debug = False\n input = sys.stdin.readline\n\n\ndef inp():\n return (int(input()))\n\n\ndef inlt():\n return (list(map(int, input().split())))\n\n\ndef insr():\n s = input()\n return s[:len(s) - 1] # Remove line char from end\n\n\ndef invr():\n return (map(int, input().split()))\n\n\ntest_count = 1\nif debug:\n test_count = inp()\n\nfor _ in range(test_count):\n a = inlt()\n ans = sum(a)\n max_discard = 0\n for x in a:\n c = a.count(x)\n if c in (2, 3):\n max_discard = max(max_discard, x * c)\n print(ans - max_discard)\n"}, {"source_code": "t = list(map(int,input().split()))\nmapp = [0]*101\nfor i in t:\n mapp[i] = (mapp[i] + 1) % 3\nremove = 0\nfor i in range(100,0,-1):\n if mapp[i] > 1 and remove < mapp[i]*i:\n remove = mapp[i]*i\n \nprint(sum(t) - remove)\n \n \n "}, {"source_code": "cards=list(map(int,input().split()))\nc=0\nfor i in cards:\n\tif cards.count(i)in{2, 3} and i*cards.count(i)>c: c=i*cards.count(i)\n\nprint (sum(cards)-c)\n\n"}, {"source_code": "x=list(map(int,input().split()))\nb=[]\nb.append(sum(x))\na=set(x)\na=list(a)\nprint(a)\nfor i in a:\n ans=0\n if(x.count(i)==3 or x.count(i)==2):\n for j in x:\n if(j!=i):\n ans+=j\n elif(x.count(i)==4):\n ans+=i\n for j in x:\n if(j!=i):\n ans+=j\n elif(x.count(i)==5):\n ans=i*2\n if(ans!=0):\n b.append(ans)\nprint(b)"}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"output2.out\",\"w\")\nL=list(map(int,input().split()))\nans=sum(L)\nHash=[0]*101\nfor i in L:\n\tHash[i]+=1\nmax1,maxG=0,0\nfor i in range(1,101):\n\tif \tHash[i]==2 or Hash[i]==3:\n\t\tmax1=Hash[i]*i\n\t\tif maxG<max1:\n\t\t\tmaxG=max1\nprint(ans-maxG)\n\n\n\n"}, {"source_code": "from collections import Counter\n\nlist = map(int, raw_input().split())\narr1 = []\narr2 = []\nk = Counter(list)\nfor i in k:\n arr1.append(i)\n arr2.append(k[i])\nk2= 100000\nk1=0\nk3=0\nk4=0\nk5=0\nprint arr1\nprint arr2\nfor i in xrange(len(arr2)):\n if(arr2[i]==2):\n if(arr1[i]<max):\n k2 = arr1[i]\n max = arr1[i]\nif(k2 == 100000):k2=0\nk2=k2*2\nfor i in xrange(len(arr2)):\n if(arr2[i]==1):\n k1 = k1+arr1[i]\n\nfor i in xrange(len(arr2)):\n if(arr2[i]==3):\n k3=arr1[i]*3\n if(k3>k2):\n k3=k2\n k2=0\n\nfor i in xrange(len(arr2)):\n if(arr2[i]==4):\n k4 = arr1[i]\n\n\nfor i in xrange(len(arr2)):\n if(arr2[i]==5):\n k5=arr1[i]*2\n\nprint k1,k2,k3,k4,k5\nprint k1+k2+k3+k4+k5\n\n\n\n"}, {"source_code": "t = list(map(int, input().split()))\n\nc = {0: 1}\nfor e in t:\n if c.get(e) is None:\n c[e] = 1\n else:\n c[e] += 1\n\ncand = [0]\nfor k in c.keys():\n if c[k] > 1:\n cand.append(k)\n\nr = max(cand)\nprint(sum(t) - min(3, c[r]) * r)\n"}, {"source_code": "l = list(map(int, input().split()))\nk = list(set(l))\ng = 0\nmx = 501\n\nif len(k) == len(l):\n print(sum(l))\nelse:\n for i in range(len(l)):\n for j in range(i+1, len(l)):\n if l[i] == l[j]:\n g += 1\n\n if g > 3:\n g = 3 \n\n s = sum(l) - g * l[i]\n mx = min(s, mx)\n\n print(mx) "}, {"source_code": "l=list(map(int,input().split()))\nc=list(filter(lambda x:l.count(x)>1,l))\nc=list(set(c))\nif c!=[]:\n d=max(c)\n if l.count(d)>2:\n print(sum(l)-3*d)\n elif l.count(d)==2:\n print(sum(l)-2*d)\nelse:\n print(sum(l))\n"}, {"source_code": "def test(a,x):\n i,aux=0,0\n for i in range(5):\n if a[i]==x:\n aux+=1\n return aux\na=raw_input()\na=a.split(' ')\ns=[]\ni=0\nfor i in range(5):\n s.append(int(a[i],10))\naux=s[0]\nfor i in range(1,5):\n if s[i]*test(a,s[i])>aux*test(a,aux) :\n aux= s[i]\nb=0\nfor i in range(5):\n b+=s[i]\nb=b-(aux*test(a,aux))\nprint b"}, {"source_code": "cards=list(map(int,input().split()))\nc=0\nfor i in cards:\n\tif cards.count(i)in{2, 3} and i*cards.count(i)>c: c=i*cards.count(i)\n\nprint (sum(cards)-c)\n\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\nlst = get_int_list()\ns = sum(lst)\nm = max(lst, key = lambda x: ((lst.count(x)-1)*x))\nprint(m)\nif lst.count(m) >= 3:\n print(s-3*m)\nelif lst.count(m) == 2:\n print(s-2*m)\nelse:\n print(s)"}, {"source_code": "y=sorted(list(map(int,input().split())))\nfor i in range(1,len(y)):\n x= y.count(y[-i])\n if x>=2:\n print(sum(y)-y[-i]*x if x<=3 else sum(y)-y[-i]*3) \n exit()\nprint(sum(y))\n"}, {"source_code": "a=input()\na=a.split()\na[0]=int(a[0])\na[1]=int(a[1])\na[2]=int(a[2])\na[3]=int(a[3])\na[4]=int(a[4])\na.sort()\nb=a[0]\ncontador=0\nfor k in range (5):\n c=a.count(a[k])\n if c>=2 and a[k]>=b:\n b=a[k]\n contador=c\nif contador>=3:\n a.remove(b)\n a.remove(b)\n a.remove(b)\n y=sum(a)\nif contador==2:\n a.remove(b)\n a.remove(b)\n y=sum(a)\nelse:\n y=sum(a)\nprint(y)"}, {"source_code": "l=input().split()\ns=0\nfor i in range(5):\n l[i]=int(l[i])\n s+=l[i]\n\nl.sort()\nf=[]\ni=4\ncn=1\nwhile(i>0):\n if(l[i]==l[i-1] and i!=1):\n cn+=1\n elif(l[i]==l[i-1] and i==1):\n cn+=1\n f.append([cn,s-cn*l[i]])\n else:\n if(cn>2):\n f.append([3,s-3*l[i]])\n else:\n f.append([cn,s-cn*l[i]])\n cn=1\n i-=1\nmi=s\ns=len(f)\nfor i in range(s):\n if((f[i][0]>1) and f[i][1]<mi):\n mi=f[i][1]\nprint(mi)"}, {"source_code": "from collections import Counter\n\ndef unique(lst, p_number, p_count):\n count = 0\n seen = set()\n result = []\n for x in lst:\n if(count == p_count): break\n if p_number in seen:\n count += 1\n continue\n seen.add(x)\n result.append(x)\n return result\n\nnumbers = list(map(int,input().split()))\n\nr_one = sum(numbers)\n\ncount = 0\n\nnumber = -1\nc = Counter(numbers)\nd = dict(c)\nmax_numbers = numbers[:]\nwhile not (count >= 3) and len(max_numbers) != 0:\n ma_x = max(max_numbers)\n number = ma_x\n max_numbers.remove(number)\n count = d[ma_x]\n\nr_two = 501\nif(count >= 2):\n buff = numbers[:]\n buff.remove(number)\n buff.remove(number)\n r_two = sum(buff)\n #r_two = sum(unique(buff, number, 2))\n\nr_three = 501\nif(count >= 3):\n buff = numbers[:]\n buff.remove(number)\n buff.remove(number)\n buff.remove(number)\n r_three = sum(buff)\n #r_two = sum(unique(buff, number, 2))\n \n \nprint(min(r_one, r_two, r_three))\n\n"}, {"source_code": "#!/usr/bin/python\n\na = raw_input ()\na = a . split ()\nb = []\nc = []\ne = []\nf = []\ng = []\no = []\n\nif len (a) == 5 :\n \n for x in a :\n \n x = int (x) \n if 1 <= x <= 100 :\n e.append (x)\n o.append (x) \n else :\n quit ()\n \n for x in o :\n \n if o.count (x) >= 3 :\n if x not in b :\n while len (b) != 3 :\n e.pop (e.index(x))\n b.append (x)\n f . append ( sum (e) )\n e = o\n b = []\n \n elif o.count (x) == 2 :\n if x not in c :\n while len (c) != 2 :\n e.pop (e.index(x))\n c.append (x)\n if len (g) == 2 :\n break\n g . append ( sum (e) )\n e = o\n c = []\n \n if len (f) != 0 :\n h = min (f)\n else :\n h = 0\n \n if len (g) != 0 :\n j = min (g)\n else :\n j = 0\n \n if h != 0 and j != 0 :\n print min ( h , j )\n elif h == 0 and j != 0 :\n print j\n elif h != 0 and j == 0 :\n print h\n else :\n print sum (o)\n\n"}, {"source_code": "x1=input().split()\nl1=[]\nfor i in x1:\n i=int(i)\n l1.append(i)\nsum1=100000000000\nl2=l1.copy()\nfor i in l2:\n c=0\n l1=l2.copy()\n z=l1.count(i)\n if z>1:\n if z>3:\n z=3\n while c<z:\n l1.remove(i)\n c+=1\n y=sum(l1)\n if sum1>y:\n sum1=y\nprint(sum1)"}, {"source_code": "from collections import defaultdict\n\nt = list(map(int, input().split()))\nd = defaultdict(int)\ns = sum(t)\n\nfor x in t:\n d[x] += 1\n\nans = s\n\nfor x, y in d.items():\n if y not in (2, 3):\n continue\n if s - x * y < ans:\n ans = s - x * y\nprint(ans)\n\n\n"}, {"source_code": "def cnt(s,v):\n ans=0\n for i in s:\n if i==v:\n ans+=1\n return ans\n\n\ns=[int(z) for z in input().split()]\nmx=0\nfor i in range(1000):\n mx=max(mx,max(cnt(s,i),3)*i)\nprint(sum(s)-mx)"}, {"source_code": "from collections import Counter\n\ndef unique(lst, p_number, p_count):\n count = 0\n seen = set()\n result = []\n for x in lst:\n if(count == p_count): break\n if p_number in seen:\n count += 1\n continue\n seen.add(x)\n result.append(x)\n return result\n\nnumbers = list(map(int,input().split()))\n\nr_one = sum(numbers)\n\ncount = 0\n\nnumber = -1\nc = Counter(numbers)\nd = dict(c)\nmax_numbers = numbers[:]\nwhile not (count >= 3) and len(max_numbers) != 0:\n ma_x = max(max_numbers)\n number = ma_x\n max_numbers.remove(number)\n count = d[ma_x]\n\nr_two = 501\nif(count >= 2):\n buff = numbers[:]\n buff.remove(number)\n buff.remove(number)\n r_two = sum(buff)\n #r_two = sum(unique(buff, number, 2))\n\nr_three = 501\nif(count >= 3):\n buff = numbers[:]\n buff.remove(number)\n buff.remove(number)\n buff.remove(number)\n r_three = sum(buff)\n #r_two = sum(unique(buff, number, 2))\n \n \nprint(min(r_one, r_two, r_three))\n\n"}, {"source_code": "a=map(int,raw_input().split())\na.sort()\na.reverse()\nx=sum(a)\nfor i in a:\n\tif a.count(i)>=3:\n\t\tx-=3*i\n\t\tbreak\n\telif a.count(i)==2:\n\t\tx-=2*i\n\t\tbreak\nprint x\n"}, {"source_code": "__author__ = 'Enmanuel Medina'\nimport sys\n\nline = raw_input()\narr = [int(x) for x in line.split()]\nsize = len(arr)\narr.sort(None, None, True)\ncnt = 1\nNarr = []\ntemp = False\nans = 0\n\nfor x in range(1, size):\n if arr[x - 1] == arr[x]:\n cnt += 1\n else:\n Narr.append([arr[x - 1], cnt])\n cnt = 1\n\nif cnt != 1:\n Narr.append([arr[size - 2], cnt])\nif arr[size - 1] != arr[size - 2]:\n Narr.append([arr[size - 1], 1])\n\nsize = len(Narr)\nfor pos in xrange(0, len(Narr)):\n if temp is True:\n temp = False\n continue\n if Narr[pos][1] == 1:\n ans += Narr[pos][0]\n elif Narr[pos][1] > 3:\n ans += Narr[pos][0]*(Narr[pos][1] - 3)\n elif pos < size - 1:\n if Narr[pos][0]*Narr[pos][1] > Narr[pos + 1][0]*Narr[pos + 1][1]:\n ans += Narr[pos + 1][0]*Narr[pos + 1][1]\n else:\n ans += Narr[pos][0]*Narr[pos][1]\n temp = True\n\n\nprint ans\n"}, {"source_code": "arr = [int(x) for x in input().split()]\nd={}\nfor i in arr:\n d[i] = d.get(i,0) +1\nif len(d)==5:\n print(sum(d.keys()))\nelse:\n a = []\n total = 0\n for i in d:\n if d[i]==1:\n total += i\n elif d[i]<4:\n a.append(i*d[i])\n else:\n a.append((d[i]-3)*i)\n a.sort()\n total += a[0]\n print(total)\n"}, {"source_code": "vlist=[int(x) for x in raw_input().split()]\nvlist.sort()\nlast=x\nnum=1\nmi=0\nfor x in vlist:\n num += 1\n if x==last and num<=3:\n mi=max(mi,x*num)\n num+=1\n else:\n num=1\n last=x\nprint sum(vlist)-mi\n"}, {"source_code": "arr=[int(i) for i in input().split()]\nhsh=[0 for i in range(0,101)]\narr.sort()\nfor i in arr:\n hsh[i]+=1\ni=4\nwhile i>=1:\n if hsh[arr[i]]>=3:\n hsh[arr[i]]-=3\n break\n elif hsh[arr[i]]>=2:\n hsh[arr[i]]-=2\n break\n i-=1\nans=0\ni=0\nfor i in range(0,101):\n ans+=hsh[i]*i\nprint(ans)"}, {"source_code": "l=input().split()\ns=0\nfor i in range(5):\n l[i]=int(l[i])\n s+=l[i]\n\nl.sort()\nf=[]\ni=4\ncn=1\nwhile(i>0):\n if(l[i]==l[i-1] and i!=1):\n cn+=1\n else:\n if(cn>2):\n f.append([3,s-3*l[i]])\n else:\n f.append([cn,s-cn*l[i]])\n cn=1\n i-=1\nmi=s\ns=len(f)\nfor i in range(s):\n if((f[i][0]>1) and f[i][1]<mi):\n mi=f[i][1]\nprint(mi)"}, {"source_code": "import collections\n\n#tt = int(raw_input())\na = map(int, raw_input().split())\ndic = collections.Counter(a)\nb = sum(a)\n#print dic\nif max(dic.values()) < 2:\n\tprint b# 'asdf'\n\nelif len(dic) == 1:\n\tprint 2*dic.keys()[0]# 'qwe'\n\nelse:\n\tans = 10**9\t\t \n\tfor i in dic.keys():\n\t\tif dic[i] < 2:\n\t\t\tcontinue\n\n\t\tsum1 = b - i*dic[i]\n\t\tif sum1 < ans:\n\t\t\tans = sum1\n\n\tprint ans"}, {"source_code": "arr = [int(x) for x in input().split()]\nd={}\nfor i in arr:\n d[i] = d.get(i,0) +1\nif len(d)==5:\n print(sum(d.keys()))\nelse:\n a = []\n total = 0\n for i in d:\n if d[i]==1:\n total += i\n elif d[i]<4:\n a.append(i*d[i])\n else:\n a.append(2*i)\n a.sort()\n total += a[0]\n print(total)\n"}, {"source_code": "t = list(map(int, input().split()))\n\nc = {0: 1}\nfor e in t:\n if c.get(e) is None:\n c[e] = 1\n else:\n c[e] += 1\n\ncand = [0]\nfor k in c.keys():\n if c[k] > 1:\n cand.append(k)\n\nr = max(cand)\nprint(sum(t) - min(3, c[r]) * r)\n"}, {"source_code": "lst = list(map(int, input().split()))\ndata = [0] * 101\ns = 0\nfor i in lst:\n data[i] += 1\n s += i\nmax_change = 0\nfor i in range(101):\n if data[i] > 2:\n max_change = max(max_change, i * 3)\n if data[i] > 1:\n max_change = max(max_change, i * 2)\n elif data[i] > 0:\n max_change = max(max_change, i)\nprint(s - max_change)\n"}, {"source_code": "from collections import defaultdict\nl = list(map(int, input().split()))\nd = defaultdict(int)\nt = sum(l)\nfor li in l:\n d[li] += 1\ns3 = s2 = None\nfor k in d:\n if d[k] >= 3:\n s3 = 3*k\n elif d[k] == 2:\n s2 = 2*k\nif s2 != None and s3 != None:\n t -= (s2 if s2 > s3 else s3)\nelif s2 != None:\n t -= s2\nelif s3 != None:\n t -= s3\nprint(t)\n\n\n\n"}, {"source_code": "string = input()\nlst = string.split()\nfor index in range(len(lst)) :\n lst[index] = int(lst[index])\nlst2 = []\nfor num in lst :\n if num not in lst2 :\n lst2.append(num)\nif len(lst2) == 1 :\n print(lst2[0] * 2)\nelif len(lst2) == 2 :\n temp = sum(lst)\n df = 0\n for num in lst :\n if lst.count(num) == 3 :\n df = num\n Max = 0\n for num in lst :\n if lst.count(num) == 2 :\n if num > Max :\n Max = num\n if temp - df * 3 > temp - Max * 2 :\n print(temp - df * 3)\n else :\n print(temp - Max * 2)\nelif len(lst2) == 4 :\n print(sum(lst2))\nelif len(lst2) == 5 :\n print(sum(lst2))\nelse :\n temp = sum(lst)\n Max = 0\n for num in lst :\n if lst.count(num) == 2 :\n if num > Max :\n Max = num\n print(temp - Max * 2)\n"}, {"source_code": "arr = map(int, raw_input().split())\n\narr.sort()\n\nz = [0]*(100+1)\n\nfor i in arr:\n z[i]+=1\n\n\ns = sum(arr)\na,b,c,d = 0,0,0,0\nif 3 in z or 4 in z or 5 in z:\n i = 100\n while i>=0:\n if z[i]>=3:\n break\n i-=1\n a = i*3\nelse:\n i = 100\n while i>=0:\n if z[i]>=2:\n break\n i-=1\n b = i*2\n\nprint s-max(a,b) \n \n \n\n"}, {"source_code": "string = input()\nlst = string.split()\nfor index in range(len(lst)) :\n lst[index] = int(lst[index])\nlst2 = []\nfor num in lst :\n if num not in lst2 :\n lst2.append(num)\nif len(lst2) == 1 :\n print(lst2[0] * 2)\nelif len(lst2) == 2 :\n temp = sum(lst)\n df = 0\n for num in lst :\n if lst.count(num) == 3 :\n df = num\n Max = 0\n for num in lst :\n if lst.count(num) == 2 :\n if num > Max :\n Max = num\n if temp - df * 3 > temp - Max * 2 :\n print(temp - df * 3)\n else :\n print(temp - Max * 2)\nelif len(lst2) == 4 :\n print(sum(lst2))\nelif len(lst2) == 5 :\n print(sum(lst2))\nelse :\n temp = sum(lst)\n Max = 0\n for num in lst :\n if lst.count(num) == 2 :\n if num > Max :\n Max = num\n print(temp - Max * 2)\n"}, {"source_code": "\n\na=list(map(int,input().split()))\na.sort(reverse=True)\np_ans=0\nfor i in range(len(a)-1):\n\tif a[i]==a[i+1]:\n\t\tif i!=0:\n\t\t\tif a[i]==a[i-1]:\n\t\t\t\tc=3*a[i]\n\t\t\t\tif p_ans<c:\n\t\t\t\t\tp_ans=c\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tc=2*a[i]\n\t\t\t\tif p_ans<=c:\n\t\t\t\t\tp_ans=c\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\telse:\n\t\tcontinue\nprint(sum(a)-p_ans)\n"}, {"source_code": "d = {}\n\nt = list(map(int, input().split()))\ns = sum(t)\nif len(set(t)) == 1:\n l = len(t)\n if l >= 3:\n print(s - (t[0]*3))\n else:\n print(s - (t[0]*l))\nelse:\n for i in t:\n if i not in d:\n d[i] = 1\n else:\n d[i] += 1\n d = sorted(d.items(), key = lambda x: (x[1], x[0]), reverse = True)\n d = list(filter(lambda x: x[1] == 2 or x[1] == 3, d))\n if len(d) == 0:\n print(s)\n else:\n print(s-(d[0][0]*d[0][1]))\n"}, {"source_code": "cards = input().split()\ncards = [int(x) for x in cards]\ncards = sorted(cards, reverse=True)\nlowest_sum = []\ntokens = 1\ncounter = 1\nfor num in cards:\n if counter >= len(cards):\n break\n else:\n if num == cards[counter] and tokens <= 3:\n lowest_sum.append(num)\n if cards[counter] != cards[counter + 1]:\n lowest_sum.append(cards[counter])\n tokens += 1\n counter += 1\n\ncard_sum = sum(cards) - sum(lowest_sum)\nprint(card_sum)\n"}, {"source_code": "# 680A : BEAR AND FIVE CARDS\n# Prerequisite : Implementation\n\nt1,t2,t3,t4,t5=(map(int,raw_input().split()))\na=[t1,t2,t3,t4,t5]\na.sort()\na.reverse()\ntotal=sum(a)\nfinal=0\nif a[0]==a[1]:\n subtract=a[0]+a[1]\n if a[1]==a[2]:subtract+=a[2]\n final=max(subtract,final)\nelif a[1]==a[2]:\n subtract=a[1]+a[2]\n if a[2]==a[3]:subtract+=a[3]\n final = max(subtract, final)\nelif a[2]==a[3]:\n subtract=a[2]+a[3]\n if a[3]==a[4]:subtract+=a[4]\n final = max(subtract, final)\nelif a[3]==a[4]:\n subtract=(a[3]+a[4])\n final = max(subtract, final)\nprint total-final\n\n"}, {"source_code": "l = list(map(int,input().split()))\n\nr = max(x * max(3,l.count(x)) for x in l if l.count(x) >= 2)\nprint (sum(l) - r)"}, {"source_code": "from collections import defaultdict\n\nt = list(map(int, input().split()))\nd = defaultdict(int)\ns = sum(t)\n\nfor x in t:\n d[x] += 1\n\nans = s\n\nfor x, y in d.items():\n if y not in (2, 3):\n continue\n if s - x * y < ans:\n ans = s - x * y\nprint(ans)\n\n\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\nlst = get_int_list()\ns = sum(lst)\nm = max(lst, key = lambda x: (lst.count(x)*x))\nif lst.count(m) >= 3:\n print(s-3*m)\nelif lst.count(m) == 2:\n print(s-2*m)\nelse:\n print(s)"}, {"source_code": "a=list(map(int,input().split()))\nb=sorted(a)\nans1=ans2=0\nfor i in reversed(b):\n if a.count(i)>=3:\n ans1=i*3\n\n elif a.count(i)==2:\n ans2=i*2\n\nprint(sum(a)-max(ans1,ans2))"}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"output2.out\",\"w\")\nL=list(map(int,input().split()))\nL.sort(reverse=True)\nX=0\nfor i in range(3):\n\tcount=0\n\tfor j in range(i,5):\n\t\tif L[i]==L[j]:\n\t\t\tcount+=1\n\tif count>=2:\n\t\tX=count*L[i]\n\t\ti=j\nprint(sum(L)-X)\n"}, {"source_code": "#!/usr/bin/python\n\na = raw_input ()\na = a . split ()\nb = []\nc = []\ne = []\nf = []\ng = []\no = []\n\nif len (a) == 5 :\n \n for x in a :\n \n x = int (x) \n if 1 <= x <= 100 :\n e.append (x)\n o.append (x) \n else :\n quit ()\n \n for x in o :\n \n if o.count (x) >= 3 :\n if x not in b :\n while len (b) != 3 :\n e.pop (e.index(x))\n b.append (x)\n f . append ( sum (e) )\n e = o\n b = []\n \n elif o.count (x) == 2 :\n if x not in c :\n while len (c) != 2 :\n e.pop (e.index(x))\n c.append (x)\n g . append ( sum (e) )\n e = o\n c = []\n \n if len (f) != 0 :\n h = min (f)\n else :\n h = 0\n \n if len (g) != 0 :\n j = min (g)\n else :\n j = 0\n \n if h != 0 and j != 0 :\n print min ( h , j )\n elif h == 0 and j != 0 :\n print j\n elif h != 0 and j == 0 :\n print h\n else :\n print sum (o)\n\n\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\nlst = get_int_list()\ns = sum(lst)\nm = max(lst, key = lst.count)\nif lst.count(m) >= 3:\n print(s-3*m)\nelif lst.count(m) == 2:\n print(s-2*m)\nelse:\n print(s)"}, {"source_code": "import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\ndd=[(-1,0),(0,1),(1,0),(0,-1)]\nddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\n# def LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return input()\n\n# Summarize count of factor within list -- START --\ndef summarizeList(l):\n sl=sorted(l,key=lambda x:x,reverse=True)\n\n a=sl[0]\n c=1\n res=[]\n\n for x in sl[1:]:\n if x==a:\n c+=1\n else:\n res.append([a,c])\n a=x\n c=1\n res.append([a,c])\n\n return res\n# Summarize count of factor within list --- END ---\n\ndef main():\n l=LI()\n sm=sum(l)\n\n sl=summarizeList(l)\n\n for x,c in sl:\n if c>1:\n if c>2:\n sm-=x*3\n else:\n sm-=x*2\n break\n \n return sm\n\n# main()\nprint(main())\n"}, {"source_code": "a = sorted(map(int, input().split()))\np = ((0, 1), (1, 2), (2, 3), (3, 4), (0, 2), (1, 3), (2, 4))\nprint(sum(a) - max(0 if a[i] == a[j] else (j - i + 1) * a[i] for i, j in p))"}, {"source_code": "\n\na=list(map(int,input().split()))\na.sort(reverse=True)\np_ans=0\nfor i in range(len(a)-1):\n\tif a[i]==a[i+1]:\n\t\tif i!=0:\n\t\t\tif a[i]==a[i-1]:\n\t\t\t\tc=3*a[i]\n\t\t\t\tif p_ans<c:\n\t\t\t\t\tp_ans=c\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tc=2*a[i]\n\t\t\t\tif p_ans<=c:\n\t\t\t\t\tp_ans=c\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\telse:\n\t\tcontinue\nprint(sum(a)-p_ans)\n"}, {"source_code": "a=list(map(int, input().split()))\nb={};sum=0\n\nfor i in a:\n\tif i not in b:\n\t\tb[i]=1\n\telse:\n\t\tb[i]+=1\np=[]\nfor i, j in b.items():\n\tif j==1:\n\t\tsum+=i\n\telif j==5:\n\t\tsum+=i*2\n\telse:\n\t\tp+=[i*j]\nif len(p)>1:\n\tsum+=min(p)\nprint(sum)"}, {"source_code": "def test(a,x):\n i,tmp=0,0\n for i in range(5):\n if s[i]==x:\n tmp+=1\n return tmp\na=raw_input()\na=a.split(' ')\ns=[]\ni=0\nfor i in range(5):\n s.append(int(a[i],10))\naux=0\nfor i in range(5):\n if (s[i]*test(a,s[i])>aux*test(a,aux))&(2<= test(a,s[i])) :\n aux= s[i]\nb=0\ntmp=test(a,aux)\nfor i in range(5):\n b+=s[i]\nif 3<=test(a,aux):\n tmp-=2\nb=b-(aux*tmp)\nprint b"}, {"source_code": "l = list(map(int,input().split()))\nz = []\nif len(set(l)) == len(l):\n print(sum(l))\n\nelse:\n for i in set(l):\n if l.count(i) > 1:\n z.append(i*l.count(i))\n print(sum(l)-max(z))"}, {"source_code": "cards=list(map(int,input().split()))\nc=0\nfor i in cards:\n\tif cards.count(i)in{2, 3} and i*cards.count(i)>c:\n\t\tif cards.count(i)>3:\n\t\t\tc=i*3\n\t\telse: c=i*cards.count(i)\n\nprint (sum(cards)-c)\n\n"}, {"source_code": "def test(a,x):\n i,aux=0,0\n for i in range(5):\n if a[i]==x:\n aux+=1\n return aux\na=raw_input()\na=a.split(' ')\ns=[]\ni=0\nfor i in range(5):\n s.append(int(a[i],10))\naux=s[0]\nfor i in range(1,5):\n if s[i]*test(a,s[i])>aux*test(a,aux) :\n aux= s[i]\nb=0\nfor i in range(5):\n b+=s[i]\nb=b-(aux*test(a,aux))\nprint b"}, {"source_code": "l=[int(x) for x in input().split()]\nif len(set(l))==5:\n print(sum(l))\nelif len(set(l))==1:\n print(2*l[0])\nelif len(set(l))==2:\n q=[]\n s=0\n x=0\n for i in range(5):\n if l.count(l[i])==4:\n x=l[i]\n else:\n s+=l[i]\n s+=x\n #q.append(s)\n #print(x)\n if x!=0:\n #print(\"hi\")\n print(s)\n else:\n #q.append(sum(set(l)))\n x=max(set(l))\n q.append(l.count(x)*x)\n x=min(set(l))\n q.append(l.count(x)*x)\n \n print(min(q))\nelse:\n q=[]\n q.append(sum(l))\n m=[]\n for i in range(5):\n if l.count(l[i])==2 and i not in m:\n m.append(i)\n #print(len(m))\n if len(m)==4:\n x=l.index(max(l[m[0]],l[m[1]]))\n s=0\n for i in range(5):\n if l[i]!=l[x]:\n s+=l[i]\n q.append(s)\n s=0\n for i in range(5):\n if l.count(l[i])!=3:\n s+=l[i]\n q.append(s)\n print(min(q))\n \n"}, {"source_code": "from sys import stdin, stdout\n\nns = [int(x) for x in stdin.readline().rstrip().split()]\ncs = dict()\nm3 = 0\nm2 = 0\ns = 0\nfor i in ns:\n if cs.has_key(i):\n cs[i] += 1\n if cs[i] == 3 and i > m3:\n m3 = i\n if cs[i] == 2 and i > m2:\n m2 = i\n s+= i\n\nm3 = s - m3*3\nm2 = s - m2*2\n\nstdout.write(str(m3 if m3 <m2 else m2))\n"}, {"source_code": "def sum(a):\n s=0\n for i in a:\n s=s+i\n return s\na=list(map(int,input().split()))\na.sort()\nb=list(set(a))\nb.sort()\ni=0\nd=[]\nc=[]\nx=sum(a)\nif len(a)==len(b):\n print(x)\nelse:\n while len(a)!=0:\n if a[0]==b[0]:\n c.append(a[0])\n del (a[0])\n if len(c)>3:\n del(c[len(c)-1])\n d.append(c)\n c=[]\n else:\n if len(c)<=3 and len(c)>1:\n d.append(c)\n del(b[0])\n c=[]\n z=[]\n for i in range(len(d)):\n z.append(x-sum(d[i]))\n print(min(z))"}, {"source_code": "t = map(int, raw_input().split())\nans = 0\nfor i in t:\n\tk = t.count(i)\n\tif(k>=2):\n\t\tans = max(ans,k*i)\nprint sum(t)-ans"}, {"source_code": "l=input().split()\ns=0\nfor i in range(5):\n l[i]=int(l[i])\n s+=l[i]\n\nl.sort()\nf=[]\ni=4\ncn=1\nwhile(i>0):\n if(l[i]==l[i-1] and i!=1):\n cn+=1\n else:\n if(cn>2):\n f.append([3,s-3*l[i]])\n else:\n f.append([cn,s-cn*l[i]])\n cn=1\n i-=1\nmi=s\ns=len(f)\nfor i in range(s):\n if((f[i][0]>1) and f[i][1]<mi):\n mi=f[i][1]\nprint(mi)"}, {"source_code": "cards = map(int, raw_input().split(\" \"))\n\ncard_freq = [0] * 101\nfor card in cards:\n card_freq[card] += 1\n\nmax_discard = 0\nfor i in range(1, len(card_freq)):\n freq = card_freq[i]\n if (freq == 2 or freq == 3) and card_freq[i] > max_discard:\n max_discard = i * card_freq[i]\n\nprint sum(cards) - max_discard"}, {"source_code": "line = raw_input()\na = map(int, line.split(' '))\na = sorted(a)\n\nk = 2\nS = a[0]\nmax_sum = 0\ncurrent_sum = a[0]\nfor i in xrange(1, 5):\n S += a[i]\n if a[i] == a[i-1] and k <= 3:\n k += 1\n current_sum += a[i-1]\n if current_sum > max_sum:\n max_sum = current_sum\n else:\n k = 1\n current_sum = a[i]\n\nprint(S - max_sum)"}, {"source_code": "from collections import Counter\n\ndef unique(lst, p_number, p_count):\n count = 0\n seen = set()\n result = []\n for x in lst:\n if(count == p_count): break\n if p_number in seen:\n count += 1\n continue\n seen.add(x)\n result.append(x)\n return result\n\nnumbers = list(map(int,input().split()))\n\nr_one = sum(numbers)\n\ncount = 0\n\nnumber = -1\nc = Counter(numbers)\nd = dict(c)\nmax_numbers = numbers[:]\nwhile not (count >= 3) and len(max_numbers) != 0:\n ma_x = max(max_numbers)\n number = ma_x\n max_numbers.remove(number)\n count = d[ma_x]\n\nr_two = 501\nif(count >= 2):\n buff = numbers[:]\n buff.remove(number)\n buff.remove(number)\n r_two = sum(buff)\n #r_two = sum(unique(buff, number, 2))\n\nr_three = 501\nif(count >= 3):\n buff = numbers[:]\n buff.remove(number)\n buff.remove(number)\n buff.remove(number)\n r_three = sum(buff)\n #r_two = sum(unique(buff, number, 2))\n \n \nprint(min(r_one, r_two, r_three))\n\n"}, {"source_code": "l=[int(x) for x in input().split()]\nif len(set(l))==5:\n print(sum(l))\nelif len(set(l))==1:\n print(2*l[0])\nelif len(set(l))==2:\n q=[]\n s=0\n x=0\n for i in range(5):\n if l.count(l[i])==4:\n x=l[i]\n else:\n s+=l[i]\n s+=x\n #q.append(s)\n #print(x)\n if x!=0:\n #print(\"hi\")\n print(s)\n else:\n #q.append(sum(set(l)))\n x=max(set(l))\n q.append(l.count(x)*x)\n x=min(set(l))\n q.append(l.count(x)*x)\n \n print(min(q))\nelse:\n q=[]\n q.append(sum(l))\n m=[]\n for i in range(5):\n if l.count(l[i])==2 and i not in m:\n m.append(i)\n #print(len(m))\n if len(m)==4:\n x=l.index(max(l[m[0]],l[m[1]]))\n s=0\n for i in range(5):\n if l[i]!=l[x]:\n s+=l[i]\n q.append(s)\n s=0\n for i in range(5):\n if l.count(l[i])!=3:\n s+=l[i]\n q.append(s)\n print(min(q))\n \n"}, {"source_code": "\nt = list(map(int, input().split()))\ntmp = 0\nfor i in t:\n if t.count(i) >= 3:\n print(i * 2)\n exit()\n if t.count(i) == 2:\n if tmp < i:\n tmp = i\nprint(sum(t) - (tmp * 2))\n\n# CodeForcesian\n# \u2665\n# \u06cc\u0627 \u0627\u0645\u0627\u0645 \u0631\u0636\u0627\n\n"}, {"source_code": "string = input()\nlst = string.split()\nfor index in range(len(lst)) :\n lst[index] = int(lst[index])\nlst2 = []\nfor num in lst :\n if num not in lst2 :\n lst2.append(num)\nif len(lst2) == 1 :\n print(lst2[0] * 2)\nelif len(lst2) == 2 :\n temp = sum(lst)\n for num in lst :\n if lst.count(num) == 3 :\n three = num\n two = 0\n for num in lst :\n if lst.count(num) == 2 :\n if num > two :\n two = num\n if temp - three * 3 < temp - two * 2 :\n print(temp - three * 3)\n else :\n print(temp - two * 2)\nelif len(lst2) == 4 :\n print(sum(lst2))\nelif len(lst2) == 5 :\n print(sum(lst2))\nelse :\n temp = sum(lst)\n Max = 0\n for num in lst :\n if lst.count(num) == 2 :\n if num > Max :\n Max = num\n print(temp - Max * 2)\n"}, {"source_code": "from collections import Counter\narr = ['0']\nl = map(int,raw_input().split())\nk = set([x for x in l if l.count(x) > 1])\nj = set([x for x in l if l.count(x) == 1])\nt=0\nfor i in k:\n arr.append(i)\nk = min(arr)\nk1 = max(arr)\nc = l.count(k)\nif c==2:\n k=k*2\nelif c==3:\n if(k*3 > k1*2):\n k=k1*2\n else:\n k=k*3\nelse:\n k=0\nif(l[0]==l[1]==l[2]==l[3]==l[4]):\n k=arr[1]*2\nfor n in j:\n t=t+n\nprint t+k\n \n\n\n"}, {"source_code": "t=list(map(int,input().split(' ')))\nt.sort()\ns=set(t)\nsumm=sum(t)\na=[]\nif len(s)==1:\n print(2*t[0])\nelif len(s)==2:\n if t[1]==t[2] and t[2]==t[3]:\n print(summ-3*t[1])\n else:\n print(summ-max(3*t[2],2*t[0],2*t[4])) \nelif len(s)==3:\n for j in range(0,4):\n if t[j]==t[j+1]:\n a.append(t[j])\n summ-=2*max(a)\n print(summ)\nelif len(s)==4:\n for j in range(0,4):\n if t[j]==t[j+1]:\n summ-=2*t[j]\n print(summ)\nelse:\n print(summ)"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\nlst = get_int_list()\ns = sum(lst)\nm = max(lst, key = lambda x: (lst.count(x)*x))\nif lst.count(m) >= 3:\n print(s-3*m)\nelif lst.count(m) == 2:\n print(s-2*m)\nelse:\n print(s)"}, {"source_code": "from collections import Counter\nA = map(int, raw_input().split())\nC = Counter(A)\nTh = filter(lambda x: C[x]==3 ,C)\nTw = filter(lambda x: C[x]==2 ,C)\nif Th and Tw:\n\tprint sum(A) - max(Th[0]*3, Tw[0]*2)\nelif Th:\n\tprint sum(A) - Th[0]*3\nelif Tw:\n\tprint sum(A) - max(Tw)*2\nelse:\n\tprint sum(A)"}, {"source_code": "arr = list(map(int, input().split()))\n\ncounts = dict()\nmx = -1\n\nfor i in arr:\n if i in counts:\n counts[i] += 1\n if counts[i] >= 2:\n mx = max(mx, i)\n else:\n counts[i] = 1\n\nif mx != -1:\n print(sum(arr) - mx * min(counts[mx], 3))\nelse:\n print(sum(arr))"}, {"source_code": "# -*- coding: utf-8 -*-\nfrom collections import Counter\n\ncards = map(int, raw_input().split())\nc = Counter(cards)\n\nc = c.most_common(5)\nif len(c) == 5:\n print(sum(cards))\n exit(0)\n\n_max = 0\nfor card, _count in c:\n if _count in [2, 3]:\n _max = max(_max, card * min(_count, 3))\n\nprint(sum(cards) - _max)\n"}, {"source_code": "li = map(int,raw_input().split())\ntot = sum(li)\nm1 = 0\ndi = {}\nfor ele in li:\n\tif ele in di:\n\t\tdi[ele] += 1\n\telse:\n\t\tdi[ele] = 1\n\tm1 = max(m1,ele)\n\nfor ele in li:\n\tm1 = max(m1,min(3,di[ele])*ele)\n\nprint tot-m1"}, {"source_code": "t=list(map(int,input().split(' ')))\nt.sort()\ns=set(t)\nsumm=sum(t)\na=[]\nif len(s)==1:\n print(2*t[0])\nelif len(s)==2:\n if t[1]==t[2] and t[2]==t[3]:\n print(summ-3*t[1])\n else:\n print(summ-max(3*t[2],2*t[0],2*t[4])) \nelif len(s)==3:\n for j in range(0,4):\n if t[j]==t[j+1]:\n a.append(t[j])\n summ-=2*max(a)\n print(summ)\nelif len(s)==4:\n for j in range(0,4):\n if t[j]==t[j+1]:\n summ-=2*t[j]\n print(summ)\nelse:\n print(summ)"}, {"source_code": "a = list(map(int, input().split()))\nb = [0]*101\n\nfor x in a:\n b[x] += 1\n\nfor i in range(100, 0, -1):\n if b[i] >= 3:\n b[i] -= 3\n break\n if b[i] >= 2:\n b[i] -= 2\n break\n\nprint(sum(i*x for i, x in enumerate(b)))\n"}], "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a"} {"source_code": "n = int(input())\nf = lambda x: n // x\na1 = f(2) + f(3) + f(5) + f(7)\na2 = f(6) + f(10) + f(14) + f(15) + f(21) + f(35)\na3 = f(30) + f(42) + f(70) + f(105)\na4 = f(210)\nans = n - (a1 - a2 + a3 - a4)\nprint(ans)\n", "positive_code": [{"source_code": "n=input()\n\nk=n/2+n/3+n/5+n/7-n/6-n/10-n/14-n/15-n/21-n/35+n/30+n/42+n/70+n/105-n/210\nprint n-k"}, {"source_code": "def test(x):\n return not any([x%i==0 for i in list(range(2,11))])\nN = int(input())\nCP = 2**3*3**2*5*7\ntoCP = 0\n\nfor i in range(1, CP+1):\n if test(i):\n toCP+=1\n\nans = int(N/CP)*toCP\nfor i in range((int(N/CP)*CP)+1,N+1):\n if test(i):\n ans+=1\nprint(ans)\n"}, {"source_code": "n = int(input())\ny = n / 2;\ny += n / 3;\ny += n / 5;\ny += n / 7;\ny -= n / 6;\ny -= n / 15;\ny -= n / 35;\ny -= n / 14;\ny -= n / 21;\ny -= n / 10;\ny += (n * 2) / 210;\ny += (n * 3) / 210;\ny += (n * 5) / 210;\ny += (n * 7) / 210;\ny -= (n) / 210;\nprint n - y;"}, {"source_code": "n = int(raw_input())\nprint n - (n / 2) - (n / 3) - (n / 5) - (n / 7) + (n / 14) + (n / 15) + (n / 21) + (n / 35) - (n / 30) - (n / 70) - (n / 105) - (n / 42) + (n / 210) + (n / 6) + (n / 10)"}, {"source_code": "n=input()\ns=n/2+n/3+n/5+n/7-n/6-n/10-n/14-n/15-n/21-n/35+n/30+n/42+n/70+n/105-n/210\nprint n-s"}, {"source_code": "num = int(input().strip())\nprint(num - (num//2+num//3 - num//6 + num//5 - num//10 - num//15 + num//30\\\n + num//7 - num//14 - num//21 + num//42 - num//35 + num//70\\\n + num//105 - num//210))\n"}, {"source_code": "n = int(input())\nprimes = [2, 3, 5, 7]\nans = 0\nfor msk in range(1 << len(primes)):\n p = 1\n sign = 1\n for i in range(len(primes)):\n if (msk & (1 << i)):\n p *= primes[i]\n sign *= -1\n ans += (n // p) * sign\nprint(ans)\n"}, {"source_code": "n=int(input())\nt=[False]*2521\nsum=0\nfor a in range(2521):\n t[a]=(a%2==0 or a%3==0 or a%4==0 or a%5==0 or a%6==0 or a%7==0 or a%8==0 or a%9==0 or a%10==0)\n if not t[a]:\n sum+=1\n\nret=sum*(n//2520)\nfor a in range(n%2520+1):\n ret+=(not t[a])\nprint(ret)\n"}, {"source_code": "n=int(raw_input())\nans=n\nans-=n/2\nans-=n/3\nans-=n/5\nans-=n/7\n\nans+=n/6\nans+=n/10\nans+=n/14\nans+=n/15\nans+=n/21\nans+=n/35\n\nans-=n/30\nans-=n/42\nans-=n/70\nans-=n/105\n\nans+=n/210\n\nprint ans\n"}, {"source_code": "c = 0\nd = 0\nn = input()\nfor i in range(2520):\n\tif i % 2 != 0 and i % 3 != 0 and i % 5 != 0 and i % 7 != 0:\n\t\tc += 1\n\t\tif i <= n % 2520:\n\t\t\td += 1\n\nprint n / 2520 * c + d"}, {"source_code": "from math import *\nfrom fractions import gcd\nfrom itertools import combinations\nn = int(raw_input())\n\nans = 0\n\narr = [i + 2 for i in xrange(9)]\n\nfor r in xrange(0, len(arr) + 1):\n for mask in combinations(arr, r):\n l = 1\n for i in mask:\n l = l / gcd(i, l) * i\n ans += n / l if r % 2 == 0 else -(n / l)\n\nprint ans"}, {"source_code": "import sys\nimport math\n\nf = sys.stdin\n\nn = int(f.readline())\ndiv2 = n // 2\ndiv3 = n // 3\ndiv5 = n // 5\ndiv7 = n // 7\n\ndiv6 = n // 6\ndiv10 = n // 10\ndiv14 = n // 14\ndiv15 = n // 15\ndiv21 = n // 21\ndiv35 = n // 35\n\ndiv30 = n // 30\ndiv42 = n // 42\ndiv70 = n // 70\ndiv105 = n // 105\n\ndiv210 = n // 210\n\nprint n-(div2+div3+div5+div7-div6-div10-div14-div15-div21-div35+div30+div42+div70+div105-div210)"}, {"source_code": "n = int(input())\nr = n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 - n//30 + n//35 - n//42 - n//70 - n//105 + n//210\nprint(r)\n"}, {"source_code": "import math\nn=int(input())\nprint(n-((n//2)+(n//3)-(n//6)+(n//5)-(n//10)+(n//7)-(n//14)-(n//15)-(n//21)-(n//35)+(n//30)+(n//42)+(n//70)+(n//105)-(n//210)))\n"}, {"source_code": "n = int(input())\na2 = n//2\na3 = n//3\na5 = n//5\na7 = n//7\na6 = n//6\na10 = n//10\na15 = n// 15\na14 = n//14\na21 = n//21\na35 = n//35\na42 = n//42\na30 = n//30\na105 = n//105\na70= n//70\na210 = n//210\nans = a2+a3+a5+a7-a6-a10-a15-a14-a21-a35+a42+a30+a105+a70-a210\nres = n-ans\nprint(res)"}, {"source_code": "#!/usr/bin/python3\n# Copyright (C) 2016 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; If not, see <http://www.gnu.org/licenses/>.\n\ntheset = [2, 3, 5, 7]\ndef brute(cur, i, n):\n res = 0\n if i < len(theset):\n res += brute(cur, i + 1, n)\n cur.append(theset[i])\n res += brute(cur, i + 1, n)\n cur.pop()\n else:\n k = 1\n for elem in cur:\n k *= elem\n res += (+1 if len(cur) % 2 == 0 else -1) * (n // k)\n return res\n\nn = int(input())\nprint(brute([], 0, n))\n"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + n // (2 * 3) + n // (2 * 5) + n // (3 * 5) + n // (2 * 7) + n // (3 * 7) + n // (5 * 7) - n // (2 * 3 * 5) - n // (2 * 3 * 7) - n // (2 * 5 * 7) - n // (3 * 5 * 7) + n // (2 * 3 * 5 * 7))"}, {"source_code": "n = int(input())\n\nk = 0\nfor i in range(1, 210, 2):\n if i %3 > 0 and i % 5 > 0 and i % 7 > 0:\n k+=1\np = (n//210)*k\n\nfor i in range((n//210)*210+1, n+1):\n if i %3 > 0 and i % 5 > 0 and i % 7 > 0 and i % 2 > 0:\n p+=1\nprint(p)\n"}, {"source_code": "import math\nn = int(input())\n\na=n//2+n//3+n//5+n//7\nb=n//6+n//10+n//14+n//15+n//21+n//35\nc=n//30+n//42+n//70+n//105\nd=n//210\nprint(n-a+b-c+d)"}, {"source_code": "import os, sys, pdb\nimport time, calendar, datetime\nimport math, itertools\nimport operator as op\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer // denom\n\nl = []\nfor i in range(2520):\n div = 1\n for j in range(2,11):\n if i % j == 0:\n div = 0\n l.append(div)\n\n#print(l[:15])\n\nn, = list(map(int, input().split()))\n\n#for n in range(10000):\nans = ( (n // 2520) * sum(l) + sum(l[:(n % 2520)+1]) )\nprint(ans)\n\n'''\n slow = 0\n for i in range(n+1):\n div = 1\n for j in range(2,11):\n if i % j == 0: div = 0\n slow += div\n\n if ans != slow:\n print(n, ans, slow)\n'''\n\n"}, {"source_code": "# You lost the game.\nfrom math import *\nn = int(input())\nT = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 24, 24, 24, 24, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, 41, 41, 42, 42, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, 45, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 51, 51, 51, 51, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57, 58, 58, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 62, 62, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, 69, 70, 70, 70, 70, 71, 71, 72, 72, 72, 72, 73, 73, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76, 76, 77, 77, 77, 77, 78, 78, 78, 78, 78, 78, 79, 79, 80, 80, 80, 80, 81, 81, 81, 81, 81, 81, 82, 82, 83, 83, 83, 83, 83, 83, 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, 86, 86, 87, 87, 87, 87, 88, 88, 88, 88, 88, 88, 89, 89, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 92, 92, 93, 93, 93, 93, 94, 94, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 96, 96, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 98, 98, 99, 99, 99, 99, 100, 100, 101, 101, 101, 101, 102, 102, 102, 102, 102, 102, 103, 103, 104, 104, 104, 104, 104, 104, 105, 105, 105, 105, 106, 106, 107, 107, 107, 107, 108, 108, 108, 108, 108, 108, 109, 109, 109, 109, 109, 109, 110, 110, 111, 111, 111, 111, 111, 111, 112, 112, 112, 112, 113, 113, 114, 114, 114, 114, 114, 114, 115, 115, 115, 115, 116, 116, 116, 116, 116, 116, 117, 117, 117, 117, 117, 117, 117, 117, 118, 118, 118, 118, 119, 119, 120, 120, 120, 120, 121, 121, 122, 122, 122, 122, 123, 123, 123, 123, 123, 123, 123, 123, 124, 124, 124, 124, 124, 124, 125, 125, 125, 125, 126, 126, 126, 126, 126, 126, 127, 127, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 130, 130, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132, 132, 133, 133, 133, 133, 134, 134, 135, 135, 135, 135, 136, 136, 136, 136, 136, 136, 137, 137, 138, 138, 138, 138, 138, 138, 139, 139, 139, 139, 140, 140, 141, 141, 141, 141, 142, 142, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 146, 146, 147, 147, 147, 147, 148, 148, 149, 149, 149, 149, 150, 150, 150, 150, 150, 150, 151, 151, 152, 152, 152, 152, 152, 152, 153, 153, 153, 153, 154, 154, 155, 155, 155, 155, 156, 156, 156, 156, 156, 156, 157, 157, 157, 157, 157, 157, 158, 158, 159, 159, 159, 159, 159, 159, 160, 160, 160, 160, 161, 161, 162, 162, 162, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 164, 164, 164, 165, 165, 165, 165, 165, 165, 165, 165, 166, 166, 166, 166, 167, 167, 168, 168, 168, 168, 169, 169, 170, 170, 170, 170, 171, 171, 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, 174, 174, 174, 174, 174, 174, 175, 175, 176, 176, 176, 176, 177, 177, 177, 177, 177, 177, 178, 178, 179, 179, 179, 179, 179, 179, 180, 180, 180, 180, 180, 180, 181, 181, 181, 181, 182, 182, 183, 183, 183, 183, 184, 184, 184, 184, 184, 184, 185, 185, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 188, 188, 189, 189, 189, 189, 190, 190, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 192, 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, 194, 195, 195, 195, 195, 196, 196, 197, 197, 197, 197, 198, 198, 198, 198, 198, 198, 199, 199, 200, 200, 200, 200, 200, 200, 201, 201, 201, 201, 202, 202, 203, 203, 203, 203, 204, 204, 204, 204, 204, 204, 205, 205, 205, 205, 205, 205, 206, 206, 207, 207, 207, 207, 207, 207, 208, 208, 208, 208, 209, 209, 210, 210, 210, 210, 210, 210, 211, 211, 211, 211, 212, 212, 212, 212, 212, 212, 213, 213, 213, 213, 213, 213, 213, 213, 214, 214, 214, 214, 215, 215, 216, 216, 216, 216, 217, 217, 218, 218, 218, 218, 219, 219, 219, 219, 219, 219, 219, 219, 220, 220, 220, 220, 220, 220, 221, 221, 221, 221, 222, 222, 222, 222, 222, 222, 223, 223, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 226, 226, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 228, 228, 229, 229, 229, 229, 230, 230, 231, 231, 231, 231, 232, 232, 232, 232, 232, 232, 233, 233, 234, 234, 234, 234, 234, 234, 235, 235, 235, 235, 236, 236, 237, 237, 237, 237, 238, 238, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 240, 240, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 242, 242, 243, 243, 243, 243, 244, 244, 245, 245, 245, 245, 246, 246, 246, 246, 246, 246, 247, 247, 248, 248, 248, 248, 248, 248, 249, 249, 249, 249, 250, 250, 251, 251, 251, 251, 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255, 256, 256, 256, 256, 257, 257, 258, 258, 258, 258, 258, 258, 259, 259, 259, 259, 260, 260, 260, 260, 260, 260, 261, 261, 261, 261, 261, 261, 261, 261, 262, 262, 262, 262, 263, 263, 264, 264, 264, 264, 265, 265, 266, 266, 266, 266, 267, 267, 267, 267, 267, 267, 267, 267, 268, 268, 268, 268, 268, 268, 269, 269, 269, 269, 270, 270, 270, 270, 270, 270, 271, 271, 272, 272, 272, 272, 273, 273, 273, 273, 273, 273, 274, 274, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 277, 277, 277, 277, 278, 278, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 281, 281, 282, 282, 282, 282, 282, 282, 283, 283, 283, 283, 284, 284, 285, 285, 285, 285, 286, 286, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 288, 288, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 290, 290, 291, 291, 291, 291, 292, 292, 293, 293, 293, 293, 294, 294, 294, 294, 294, 294, 295, 295, 296, 296, 296, 296, 296, 296, 297, 297, 297, 297, 298, 298, 299, 299, 299, 299, 300, 300, 300, 300, 300, 300, 301, 301, 301, 301, 301, 301, 302, 302, 303, 303, 303, 303, 303, 303, 304, 304, 304, 304, 305, 305, 306, 306, 306, 306, 306, 306, 307, 307, 307, 307, 308, 308, 308, 308, 308, 308, 309, 309, 309, 309, 309, 309, 309, 309, 310, 310, 310, 310, 311, 311, 312, 312, 312, 312, 313, 313, 314, 314, 314, 314, 315, 315, 315, 315, 315, 315, 315, 315, 316, 316, 316, 316, 316, 316, 317, 317, 317, 317, 318, 318, 318, 318, 318, 318, 319, 319, 320, 320, 320, 320, 321, 321, 321, 321, 321, 321, 322, 322, 323, 323, 323, 323, 323, 323, 324, 324, 324, 324, 324, 324, 325, 325, 325, 325, 326, 326, 327, 327, 327, 327, 328, 328, 328, 328, 328, 328, 329, 329, 330, 330, 330, 330, 330, 330, 331, 331, 331, 331, 332, 332, 333, 333, 333, 333, 334, 334, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 336, 336, 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, 338, 338, 339, 339, 339, 339, 340, 340, 341, 341, 341, 341, 342, 342, 342, 342, 342, 342, 343, 343, 344, 344, 344, 344, 344, 344, 345, 345, 345, 345, 346, 346, 347, 347, 347, 347, 348, 348, 348, 348, 348, 348, 349, 349, 349, 349, 349, 349, 350, 350, 351, 351, 351, 351, 351, 351, 352, 352, 352, 352, 353, 353, 354, 354, 354, 354, 354, 354, 355, 355, 355, 355, 356, 356, 356, 356, 356, 356, 357, 357, 357, 357, 357, 357, 357, 357, 358, 358, 358, 358, 359, 359, 360, 360, 360, 360, 361, 361, 362, 362, 362, 362, 363, 363, 363, 363, 363, 363, 363, 363, 364, 364, 364, 364, 364, 364, 365, 365, 365, 365, 366, 366, 366, 366, 366, 366, 367, 367, 368, 368, 368, 368, 369, 369, 369, 369, 369, 369, 370, 370, 371, 371, 371, 371, 371, 371, 372, 372, 372, 372, 372, 372, 373, 373, 373, 373, 374, 374, 375, 375, 375, 375, 376, 376, 376, 376, 376, 376, 377, 377, 378, 378, 378, 378, 378, 378, 379, 379, 379, 379, 380, 380, 381, 381, 381, 381, 382, 382, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 384, 384, 385, 385, 385, 385, 385, 385, 385, 385, 385, 385, 386, 386, 387, 387, 387, 387, 388, 388, 389, 389, 389, 389, 390, 390, 390, 390, 390, 390, 391, 391, 392, 392, 392, 392, 392, 392, 393, 393, 393, 393, 394, 394, 395, 395, 395, 395, 396, 396, 396, 396, 396, 396, 397, 397, 397, 397, 397, 397, 398, 398, 399, 399, 399, 399, 399, 399, 400, 400, 400, 400, 401, 401, 402, 402, 402, 402, 402, 402, 403, 403, 403, 403, 404, 404, 404, 404, 404, 404, 405, 405, 405, 405, 405, 405, 405, 405, 406, 406, 406, 406, 407, 407, 408, 408, 408, 408, 409, 409, 410, 410, 410, 410, 411, 411, 411, 411, 411, 411, 411, 411, 412, 412, 412, 412, 412, 412, 413, 413, 413, 413, 414, 414, 414, 414, 414, 414, 415, 415, 416, 416, 416, 416, 417, 417, 417, 417, 417, 417, 418, 418, 419, 419, 419, 419, 419, 419, 420, 420, 420, 420, 420, 420, 421, 421, 421, 421, 422, 422, 423, 423, 423, 423, 424, 424, 424, 424, 424, 424, 425, 425, 426, 426, 426, 426, 426, 426, 427, 427, 427, 427, 428, 428, 429, 429, 429, 429, 430, 430, 431, 431, 431, 431, 431, 431, 431, 431, 431, 431, 432, 432, 433, 433, 433, 433, 433, 433, 433, 433, 433, 433, 434, 434, 435, 435, 435, 435, 436, 436, 437, 437, 437, 437, 438, 438, 438, 438, 438, 438, 439, 439, 440, 440, 440, 440, 440, 440, 441, 441, 441, 441, 442, 442, 443, 443, 443, 443, 444, 444, 444, 444, 444, 444, 445, 445, 445, 445, 445, 445, 446, 446, 447, 447, 447, 447, 447, 447, 448, 448, 448, 448, 449, 449, 450, 450, 450, 450, 450, 450, 451, 451, 451, 451, 452, 452, 452, 452, 452, 452, 453, 453, 453, 453, 453, 453, 453, 453, 454, 454, 454, 454, 455, 455, 456, 456, 456, 456, 457, 457, 458, 458, 458, 458, 459, 459, 459, 459, 459, 459, 459, 459, 460, 460, 460, 460, 460, 460, 461, 461, 461, 461, 462, 462, 462, 462, 462, 462, 463, 463, 464, 464, 464, 464, 465, 465, 465, 465, 465, 465, 466, 466, 467, 467, 467, 467, 467, 467, 468, 468, 468, 468, 468, 468, 469, 469, 469, 469, 470, 470, 471, 471, 471, 471, 472, 472, 472, 472, 472, 472, 473, 473, 474, 474, 474, 474, 474, 474, 475, 475, 475, 475, 476, 476, 477, 477, 477, 477, 478, 478, 479, 479, 479, 479, 479, 479, 479, 479, 479, 479, 480, 480, 481, 481, 481, 481, 481, 481, 481, 481, 481, 481, 482, 482, 483, 483, 483, 483, 484, 484, 485, 485, 485, 485, 486, 486, 486, 486, 486, 486, 487, 487, 488, 488, 488, 488, 488, 488, 489, 489, 489, 489, 490, 490, 491, 491, 491, 491, 492, 492, 492, 492, 492, 492, 493, 493, 493, 493, 493, 493, 494, 494, 495, 495, 495, 495, 495, 495, 496, 496, 496, 496, 497, 497, 498, 498, 498, 498, 498, 498, 499, 499, 499, 499, 500, 500, 500, 500, 500, 500, 501, 501, 501, 501, 501, 501, 501, 501, 502, 502, 502, 502, 503, 503, 504, 504, 504, 504, 505, 505, 506, 506, 506, 506, 507, 507, 507, 507, 507, 507, 507, 507, 508, 508, 508, 508, 508, 508, 509, 509, 509, 509, 510, 510, 510, 510, 510, 510, 511, 511, 512, 512, 512, 512, 513, 513, 513, 513, 513, 513, 514, 514, 515, 515, 515, 515, 515, 515, 516, 516, 516, 516, 516, 516, 517, 517, 517, 517, 518, 518, 519, 519, 519, 519, 520, 520, 520, 520, 520, 520, 521, 521, 522, 522, 522, 522, 522, 522, 523, 523, 523, 523, 524, 524, 525, 525, 525, 525, 526, 526, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 528, 528, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 530, 530, 531, 531, 531, 531, 532, 532, 533, 533, 533, 533, 534, 534, 534, 534, 534, 534, 535, 535, 536, 536, 536, 536, 536, 536, 537, 537, 537, 537, 538, 538, 539, 539, 539, 539, 540, 540, 540, 540, 540, 540, 541, 541, 541, 541, 541, 541, 542, 542, 543, 543, 543, 543, 543, 543, 544, 544, 544, 544, 545, 545, 546, 546, 546, 546, 546, 546, 547, 547, 547, 547, 548, 548, 548, 548, 548, 548, 549, 549, 549, 549, 549, 549, 549, 549, 550, 550, 550, 550, 551, 551, 552, 552, 552, 552, 553, 553, 554, 554, 554, 554, 555, 555, 555, 555, 555, 555, 555, 555, 556, 556, 556, 556, 556, 556, 557, 557, 557, 557, 558, 558, 558, 558, 558, 558, 559, 559, 560, 560, 560, 560, 561, 561, 561, 561, 561, 561, 562, 562, 563, 563, 563, 563, 563, 563, 564, 564, 564, 564, 564, 564, 565, 565, 565, 565, 566, 566, 567, 567, 567, 567, 568, 568, 568, 568, 568, 568, 569, 569, 570, 570, 570, 570, 570, 570, 571, 571, 571, 571, 572, 572, 573, 573, 573, 573, 574, 574, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 576]\nprint(576*(n//2520)+T[n%2520])\n"}, {"source_code": "LCM=2520\nsieve=[1]*LCM;sieve[0]=0\nfor i in range(2,10):\n\tfor j in range(i,LCM,i):\n\t\tsieve[j]=0\nn=int(input())\nprint(sum(sieve)*(n//LCM)+sum(sieve[:n%LCM+1]))\n"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35 - n // 30 - n // 70 + n // 210 - n // 105 - n // 42)"}, {"source_code": "\"\"\"n = int(input())\n\ndef program(n):\n amount = 0\n for i in range(1, n + 1):\n if i % 2 != 0:\n if i % 3 != 0:\n if i % 5 != 0:\n if i % 7 != 0:\n amount = amount + 1\n\n return amount\n\nprint(program(n))\"\"\"\n\nn=int(input())\nprint(n-n//2-n//3-n//5-n//7+n//6+n//15+n//35+n//10+n//14+n//21-n//105-n//70-n//30-n//42+n//210)"}, {"source_code": "# 2, 3, 5, 7\nfrom sys import stdin\n\nn = int(stdin.readline())\n\nd2 = n // 2\nd3 = n // 3\nd5 = n // 5\nd7 = n // 7\n\nd23 = n // (2 * 3)\nd25 = n // (2 * 5)\nd27 = n // (2 * 7)\nd35 = n // (3 * 5)\nd37 = n // (3 * 7)\nd57 = n // (5 * 7)\n\nd235 = n // (2 * 3 * 5)\nd237 = n // (2 * 3 * 7)\nd257 = n // (2 * 5 * 7)\nd357 = n // (3 * 5 * 7)\n\nd2357 = n // (2 * 3 * 5 * 7)\n\nans = (d2 + d3 + d5 + d7) - (d23 + d25 + d27 + d35 + d37 + d57) + (d235 + d237 + d257 + d357) - d2357\n\nprint(n - ans)\n"}, {"source_code": "n = int(input())\ny = n // 2;\ny += n // 3;\ny += n // 5;\ny += n // 7;\ny -= n // 6;\ny -= n // 15;\ny -= n // 35;\ny -= n // 14;\ny -= n // 21;\ny -= n // 10;\ny += (n * 2) // 210;\ny += (n * 3) // 210;\ny += (n * 5) // 210;\ny += (n * 7) // 210;\ny -= (n) // 210;\nprint(n - y)"}, {"source_code": "n = int(input())\n\n# 6 in 2, 6 in 3, 4 in 2, 8 in 4, 9 in 3, 10 in 5, 10 in 2\n\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + \nn // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35 - n // 30 - n // 42 - n // 105 - n // 70 + n // 210)"}, {"source_code": "\nn = int(input())\np = n - n//2 - n//3 - n//5 - n//7 ;\nc2 = n//6 + n//10 + n//14 + n//15 + n//21 + n//35;\nc3 = n//30 + n//42 + n//70 + n//105;\nc4 = n//(2*3*5*7)\np = p + c2 - c3 + c4;\nprint(p);\n"}, {"source_code": "n = int(input())\nres = n // 2 + n // 3 + n // 5 + n // 7 - n // 6 - n // 10 - n // 14 - n // 15 - n // 21 - n // 35 + n // 30 + n // 42 + n // 70 + n // 105 - n // 210\nprint(n - res)\n"}, {"source_code": "n = int(input())\n\nneg = [2, 3, 5, 7, 2*3*5, 2*3*7, 2*5*7, 3*5*7]\npos = [1, 2*3, 2*5, 2*7, 3*5, 3*7, 5*7, 2*3*5*7]\n\nret = 0\nfor x in neg:\n ret -= n // x\n \nfor x in pos:\n ret += n // x\n \nprint(ret)"}, {"source_code": "n = int(input())\nprint(n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35 - n//30 - n//42 - n//70 - n//105 + n//210)"}, {"source_code": "n=int(input())\nres=(n//2)+(n//3)+(n//5)+(n//7)-(n//6)-(n//10)-(n//14)-(n//15)\nres=res-(n//21)-(n//35)+(n//30)+(n//70)+(n//105)+(n//42)-(n//210)\nprint(n-res)"}, {"source_code": "n = int(input())\nres = n//2 + n//3 + n//5 + n//7 - n//6 - n//10 - n//14 - n//15 - n//21 - n//35 + (n//30+n//42+n//70+n//105) - (n//210)\nprint(n - res)\n"}, {"source_code": "import math\n\ndef d(n,r):\n f = math.factorial\n return f(n) / f(r) / f(n-r)\n \ndef f(n,r):\n return d(n+r-1,r-1)\n \nn=input()\nprint n-n/2-n/3-n/5-n/7+n/6+n/10+n/14+n/15+n/21+n/35-n/30-n/70-n/42-n/105+n/210"}, {"source_code": "n=input()\n\nk=n/2+n/3+n/5+n/7-n/6-n/10-n/14-n/15-n/21-n/35+n/30+n/42+n/70+n/105-n/210\nprint n-k"}, {"source_code": "n = input()\nprint n - (n / 2 + n / 3 + n / 5 + n / 7 - n / 6 - n / 10 - n / 14 - n / 15 - n / 21 - n / 35 + n / 105 + n / 70 + n / 42 + n / 30 - n / 210)"}, {"source_code": "pls = 0\narr = [None]*210\nfor i in xrange(1,211):\n\tarr[i-1] = (i%2!=0 and i%3!=0 and i%5!=0 and i%7!=0)\n\tpls += 1 if arr[i-1] else 0\n\t\nn = input()\nplox = 0\nfor i in xrange(n%210):\n\tplox += 1 if arr[i] else 0\nans = (n/210)*pls + plox\nprint(ans)"}, {"source_code": "n = int(input())\nprint n - (n // 2 + n // 3 + n // 5 + n // 7 - n // 6 - n // 10 - n // 14 - n // 15 - n // 21 - n // 35 + n // 30 + n // 42 + n // 70 + n // 105 - n // 210)"}, {"source_code": "n=int(input())\nprint(n-(n//2+n//3+n//5+n//7-n//6-n//10-n//14-n//15-n//21-n//35+n//30+n//42+n//70+n//105-n//210))"}, {"source_code": "n = input()\nL = [0] * 2521\n\nfor i in range(1, 2521):\n dd = 0\n if i % 2 != 0 and i % 3 != 0 and i % 5 != 0 and i % 7 != 0:\n dd += 1\n L[i] = L[i - 1] + dd\nprint (n / 2520 * L[2520] + L[(n % 2520)])\n"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase\nfrom string import ascii_uppercase\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] != \"CPython\": # PyPy?\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\nn = read_int()\nres = []\nfor i in range(2520):\n for j in range(2, 11):\n if i % j == 0:\n break\n else:\n res.append(1)\n continue\n res.append(0)\n\nq, r = divmod(n, 2520)\nans = q * res.count(1) + res[:r + 1].count(1)\nprint ans\n"}, {"source_code": "a = int(input())\nb =(a- a//2 - a//3 - a//5 - a//7 + a//6 + a//10 + a//14 + a//15 +a//21 + a//35 - a//30 - a//42 - a//70 - a//105 + a//210 )\nprint (b)"}, {"source_code": "n = int(input())\nprint(n - (n//2 + n//3 + n//5 + n//7) + (n//(2*5*3*7)) - (n//(2 * 5 * 3)) - (n // (2 * 5 * 7)) - (n // (2 * 3 * 7)) - (n // (5 * 3 * 7)) + (n // 10) + (n // 6) + (n // 15) + (n // 14) + (n // 21) + (n // 35))\n"}, {"source_code": "n = int(input())\na = 2\nb = 3\nc = 5\nd = 7\nprint(n - n // a - n // b - n // c - n // d + n // (a * b) + n // (a * c) + n // (a * d) + n // (b * c) + n // (b * d) + n // (c * d) - n // (a * b * c) - n // (a * b * d) - n // (a * c * d) - n // (b * c * d) + n // (a * b * c * d))"}, {"source_code": "n = int(input())\nA = [2, 3, 5, 7]\np = 4\n\nans = 0\nfor i in range(1 << p):\n now, cnt = 1, 0\n for j in range(p):\n if (i >> j & 1):\n now *= A[j]\n cnt += 1\n if (cnt % 2):\n ans -= n // now\n else:\n ans += n // now\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nn = input()\nans = n\nn2 = n / 2\nn3 = n / 3\nn5 = n / 5\nn7 = n / 7\nn23 = n / 6\nn25 = n / 10\nn27 = n / 14\nn35 = n / 15\nn37 = n / 21\nn57 = n / 35\nn235 = n/30\nn257 = n/2/5/7\nn237=n/42\nn357=n/105\nn2357=n/210\nnn = n2 + n3 + n5 + n7 - n23-n25-n27-n35-n37-n57+n235+n237+n357+n257-n2357\nans -= nn\nprint ans\n"}, {"source_code": "n = int(input())\na=(n//2+n//3+n//5+n//7-n//6-n//10-n//14-n//15-n//21-n//35+n//30+n//42+n//70+n//105-n//210)\nprint(n-a)"}, {"source_code": "n = int(input())\nprint( n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35 -n//30 -n//42 - n//105 - n//70 + n//210)"}, {"source_code": "n = int(input())\n\nprint(n - (n//2 + n//3 + n//5 + n//7 - n//6 - n//10 - n//14 - n//15 - n//21 - n//35 + n//30 + n//42 + n//70 + n//105 - n//210))\n"}, {"source_code": "n = int(input())\nprint(n-n//2-n//3-n//5-n//7+n//6+n//14+n//10+n//15+n//21+n//35-n//30-n//105-n//70-n//42+n//210)\n"}, {"source_code": "n = int(input())\na = n // 2\nb = n // 3\nc = n // 5\nd = n // 7\nab = n // 6\nac = n // 10\nad = n // 14\nbc = n // 15\nbd = n // 21\ncd = n // 35\nabc = n // 30\nabd = n // 42\nacd = n // 70\nbcd = n // 105\nabcd = n // 210\nrest = a + b + c + d - ab - ac-ad-bc-bd-cd + abc + abd + acd + bcd - abcd\nprint(n - rest)\n"}, {"source_code": "n = (int)(input())\np = [2, 3, 5, 7]\n\nd = 0\nfor i in p:\n d += n // i\n\nfor i in range(0, 3):\n for j in range(i + 1, 4):\n d -= n // (p[i] * p[j])\n\nfor i in range(0, 2):\n for j in range(i + 1, 3):\n for k in range(j + 1, 4):\n d += n // (p[i] * p[j] * p[k])\n\nd -= n // 210\n\nprint(n - d)"}, {"source_code": "n = int(input())\n\na = (n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35 - n // 30 - n // 42 - n // 70 - n // 105 + n // 210) \nprint(a)"}, {"source_code": "import sys\nfrom math import gcd\ndef read():\n return sys.stdin.readline().strip()\ndef printf(a, sep = ' ', end = '\\n'):\n sys.stdout.write(sep.join(map(str, a)) + end)\n #printf([n])\ndef readf():\n return [int(i) for i in read().split()]\ndef main():\n n = int(read())\n ans = n\n p = [2, 3, 5, 7]\n ans -= n//2 + n//3 + n//5 + n//7\n ans += n//6 + n//10 + n//14 + n//21 + n//15 + n//35\n ans -= n//30 + n//42 + n//105 + n//70\n ans += n//210\n printf([ans])\nmain()\n"}, {"source_code": "n=int(raw_input())\nprint n-(n/2+n/3+n/5+n/7)+(n/6+n/10+n/14+n/15+n/21+n/35)-(n/30+n/105+n/42+n/70)+(n/210)\n"}, {"source_code": "n = int(input())\n\nneg = [2, 3, 5, 7, 2*3*5, 2*3*7, 2*5*7, 3*5*7]\npos = [1, 2*3, 2*5, 2*7, 3*5, 3*7, 5*7, 2*3*5*7]\n\nret = 0\nfor x in neg:\n ret -= n // x\n \nfor x in pos:\n ret += n // x\n \nprint(ret)"}, {"source_code": "n = input()\nprint n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35- n / 30 - n / 105 - n / 70 - n / 42 + n / 210\n"}, {"source_code": "n = input()\nres = n/2 + n/3 + n/5 + n/7 - n/6 - n/10 - n/14 - n/15 - n/21 - n/35 + n/105 + n/70 + n/42 + n/30 - n/210\nprint n - res"}, {"source_code": "s = raw_input()\nl = s.split(\" \")\nn = long(l[0])\n\nres = 0\n\nres += n / 1\n\nres -= n / 2\nres -= n / 3\nres -= n / 5\nres -= n / 7\n\nres += n / 6\nres += n / 15\nres += n / 35\nres += n / 10\nres += n / 21\nres += n / 14\n\nres -= n / 30\nres -= n / 42\nres -= n / 70\nres -= n / 105\n\nres += n / 210\n\nprint res"}, {"source_code": "n = int(raw_input())\ncnt = 0\ndef check(num):\n for i in xrange(2, 11):\n if num % i == 0: return False\n return True\nfor i in xrange(1, 2520):\n if check(i): cnt += 1\nres = n / 2520 * cnt\nn %= 2520\nfor i in xrange(1, n + 1):\n if check(i): res += 1\nprint res\n"}, {"source_code": "# IDEA : Principle of inclusion and exclusion\nfrom math import sqrt\nn = input()\ntemp = n/2 + n/3 + n/5 + n/7 \ntemp -= (n/6 + n/10 + n/14 + n/15 + n/21 + n/35)\ntemp += (n/30 + n/42 + n/105 + n/70)\ntemp -= n/210\nans = n - temp\nprint ans\n"}, {"source_code": "import math\nfrom math import *\nn = int(input())\nd = [2,3,5,7]\nans = n\nfor i in range(4):\n ans -= n//d[i]\nfor i in range(4):\n for j in range(i+1,4):\n ans += n//(d[i]*d[j])\nfor i in range(4):\n for j in range(i+1,4):\n for k in range(j+1,4):\n ans -= n//(d[i]*d[j]*d[k])\nans += n//(2*3*5*7)\nprint(ans)"}, {"source_code": "ans=n=input()\nans -= n/2\nans -= n/3 - n/6\nans -= n/5 - n/10 - n/15 + n/30\nans -= n/7 - n/14 - n/21 - n/35 + n/42 + n/70 + n/105 - n/210\nprint ans"}, {"source_code": "def main():\n n = int(input())\n a = (n // 2 + n // 3 + n // 5 + n // 7)\n b = (n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35)\n c = (n // 30 + n // 42 + n // 70 + n // 105)\n d = (n // 210)\n print(n - a + b - c + d)\n \nmain()"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nresult = n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35 - n//30 - n//42 - n//70 - n//105 + n//210\nprint(result)"}, {"source_code": "n = int(raw_input())\n\nprint(n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35 - n//30 - n//42 - n//70 - n//105 + n//210)"}, {"source_code": "n = int(raw_input())\na = []\nfor i in xrange(2520):\n ok = False\n for j in xrange(2, 11):\n if i % j == 0:\n ok = True\n a.append(0 if ok else 1)\n\ns = [0]\nfor i in xrange(2520):\n s.append(s[-1] + a[(i + 1) % 2520])\n\nprint n // 2520 * s[2520] + s[n % 2520]"}, {"source_code": "def main():\n\tn = int(input())\n\tprint(solver(n))\n\ndef solver(n):\n\tfactors = [2, 3, 5, 7]\n\tsingles = n // 2 + n // 3 + n // 5 + n // 7\n\tpairs = n // (2 * 3) + n // (2 * 5) + n // (2 * 7) + \\\n\tn // (3 * 5) + n // (3 * 7) + n // (5 * 7)\n\ttriples = n // (2 * 3 * 5) + n // (2 * 3 * 7) + \\\n\tn // (2 * 5 * 7) + n // (3 * 5 * 7)\n\tquads = n // (2 * 3 * 5 * 7)\n\treturn n - singles + pairs - triples + quads\n\nmain()"}, {"source_code": "n = int(input())\nprint(n-n//2-n//3-n//5-n//7+n//6+n//10+n//14+n//15+n//21+n//35-n//30-n//42-n//70-n//105+n//210)"}, {"source_code": "n = int(input())\n\nans = 0\nans += n//2 + n//3 + n//5 + n//7\nans -= n//(2*3) + n//(2*5) + n//(2*7) + n//(3*5) + n//(3*7) + n//(5*7)\nans += n//(2*3*5) + n//(2*3*7) + n//(2*5*7) + n//(3*5*7)\nans -= n//(2*3*5*7)\n\nprint(n-ans)"}, {"source_code": "n = int(input())\n\nans = n\np = [2, 3, 5, 7]\nfor i in range(1, 2**4):\n cnt = 0\n value = 1\n for s in range(4):\n if (i & (1 << s)) > 0:\n value *= p[s]\n cnt += 1\n sign = -1 if cnt % 2 == 1 else 1\n ans += sign * (n // value)\nprint(ans)\n\n"}, {"source_code": "M = 2 * 3 * 5 * 7\nv = [0] * M\nfor i in range(1, M):\n v[i] = v[i - 1] + bool(i % 2 and i % 3 and i % 5 and i % 7)\nn = int(input())\nprint(n // M * v[-1] + v[n % M])"}, {"source_code": "n=input()\nprint n-(n/5+n/7+n/3+n/2)+(n/6+n/21+n/10+n/15+n/14+n/35)-(n/30+n/105+n/70+n/42)+(n/210)"}, {"source_code": "from pdb import *\ndef\tgcd(x,y):\n\ta=x; b=y; c=a%b;\n\twhile c:\n\t\ta=b;b=c;c=a%b;\n\treturn b\nn=input()\nSum=0\nfor i in range(1,1<<9):\n\tcnt=0\n\tt=1\n\tfor j in range(9):\n\t\tif i&(1<<j):\n\t\t\tt=t*(j+2)/gcd(t,j+2)\n\t\t\tcnt+=1\n\tif t==0 :continue\n\tif cnt%2:Sum+=n/t\n\telse :Sum-=n/t\nprint n-Sum\n"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 + n // 6 - n // 7 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35 - n // 30 - n // 42 - n // 70 - n // 105 + n // 210)"}, {"source_code": "a=int(input());print(a-a//2-a//3-a//5-a//7+a//6+a//10+a//14+a//15+a//21+a//35-a//30-a//105-a//70-a//42+a//210)"}, {"source_code": "n=input()\ns=n/2+n/3+n/5+n/7-n/6-n/10-n/14-n/15-n/21-n/35+n/30+n/42+n/70+n/105-n/210\nprint n-s"}, {"source_code": "n=int(input())\nans=n-(n//2+n//3+n//5+n//7-n//6-n//10-n//14-n//15-n//21-n//35+n//30+n//42+n//70+n//105-n//210)\nprint(ans)"}, {"source_code": "def f(x):\n\tre = 0\n\tfor i in range(1, x + 1):\n\t\tflag = True\n\t\tfor j in range(2, 11):\n\t\t\tif i % j == 0:\n\t\t\t\tflag = False\n\t\t\t\tbreak\n\t\tif flag:\n\t\t\tre += 1\n\treturn re\n\nn = input()\nprint f(2520) * (n / 2520) + f(n % 2520)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Aug 31 21:56:31 2020\n\n@author: Dark Soul\n\"\"\"\n\nn=int(input(''))\ncnt=n-n//2\ndiv3=n//3\n\nif div3&1:\n div3=(div3//2)+1\nelse:\n div3=div3//2\ncnt-=div3\n\n\ndiv5=n//5\nif div5&1:\n div5=1+(div5)//2\nelse:\n div5=div5//2\ncnt-=div5\n\n\ndiv7=n//7\nif div7&1:\n div7=1+(div7)//2\nelse:\n div7=div7//2\ncnt-=div7\n\n\ndiv15=n//15\nif div15&1:\n div15=1+(div15)//2\nelse:\n div15=div15//2\ncnt+=div15\n\n\ndiv21=n//21\nif div21&1:\n div21=1+(div21)//2\nelse:\n div21=div21//2\ncnt+=div21\n\n\ndiv35=n//35\nif div35&1:\n div35=1+(div35)//2\nelse:\n div35=div35//2\ncnt+=div35\n\n\ndiv15=n//(3*5*7)\nif div15&1:\n div15=1+(div15)//2\nelse:\n div15=div15//2\ncnt-=div15\n\n\nprint(cnt)\n"}, {"source_code": "n = int(raw_input())\nx = (n/2) + (n/3) + (n/5) + (n/7) - (n/6) - n/10 - n/14 - n/15 - n/21 - n/35 + n/30 + n/70 + n/42 + n/105 - n/210\nprint n-x"}, {"source_code": "n = int(raw_input())\nprint n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35 - n / 30 - n / 42 - n / 70 - n / 105 + n / 210"}, {"source_code": "n=input()\nprint n - (n/2 +n/3 +n/5 +n/7 -n/6 -n/10 -n/14 -n/15 -n/21 -n/35 +n/30 +n/42 +n/70 +n/105 -n/210)"}], "negative_code": [{"source_code": "def cal():\n\tnum = int(input().strip())\n\tnums = [2,3,5,7]\n\tcul2 = [6,10,14,30,210]\n\tcul3 = [15,105]\n\tcul5 = [35]\n\tans=0\n\tfor i in range(len(nums)):\n\t\tans += (num//nums[i])\n\t\tif i == 0:\n\t\t\tfor j in cul2:\n\t\t\t\tans -= num//j\n\t\tif i == 1:\n\t\t\tfor j in cul3:\n\t\t\t\tans -= num//j\n\t\tif i == 2:\n\t\t\tfor j in cul5:\n\t\t\t\tans -= num//j\n\t\n\t\t\t\n\tprint(num - ans)"}, {"source_code": "# 2 3 5 7\nn=int(input())\nans=n-n//2-n//3-n//5-n//7\nans+=n//6+n//10+n//14+n//15+n//21+n//35\nans-=n//30+n//42+n//70+n//105\nprint(ans-n//210)\n"}, {"source_code": "n = int(input())\nost = n//210\nans = 0\nfor i in range(1, n%210 + 1):\n if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 or i % 7 == 0:\n ans += 1\nprint(ost * 48 + n - ans)\n"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nn = input()\nans = n\nn2 = n / 2\nn3 = n / 3\nn5 = n / 5\nn7 = n / 7\nn23 = n / 6\nn25 = n / 10\nn27 = n / 14\nn35 = n / 15\nn37 = n / 21\nn57 = n / 35\nn235 = n/30\nn237=n/42\nn357=n/105\nn2357=n/210\nnn = n2 + n3 + n5 + n7 - n23-n25-n27-n35-n37-n57+n235+n237+n357+3*n2357\nans -= nn\nprint ans\n"}, {"source_code": "from sys import stdin,stdout\nfrom math import gcd, ceil, sqrt,factorial as f\nii1 = lambda: int(stdin.readline().strip())\nis1 = lambda: stdin.readline().strip()\niia = lambda: list(map(int, stdin.readline().strip().split()))\nisa = lambda: stdin.readline().strip().split()\nmod = 1000000007\n\nn = ii1()\ndiv = [2, 3, 5, 7]\nres = n\nfor i in div:\n res -= n // i\ndiv1 = [6, 10, 14, 30, 210, 15, 21, 105, 35, 42, 70]\nfor i in div1:\n res += n // i\nprint(res) \n\n"}, {"source_code": "print(int(input())*8//35)"}, {"source_code": "n = int(input())\nprint(n-n//2-n//3-n//5-n//7+n//6+n//10+n//14+n//15+n//21+n//35-n//30-n//42-n//105+n//210)"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35)"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nresult = n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35 \nprint(result)"}, {"source_code": "import math\nn=int(input())\nprint(n-((n//2)+(n//3)-(n//6)+(n//5)-(n//10)+(n//7)-(n//14)-(n//15)-(n//21)-(n//35)-(n//30)-(n//42)-(n//70)-(n//105)-(n//210)))\n"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35)"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\nfrom math import sqrt, floor, factorial, gcd, log\nfrom collections import deque, Counter, defaultdict\nfrom itertools import permutations\nfrom math import gcd\nfrom bisect import bisect\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nread = lambda: list(map(int, input().strip().split(\" \")))\n\ndef lcm(arr):\n _lcm = 1\n for i in arr:\n _lcm = (_lcm*i)//gcd(_lcm, i)\n return(_lcm)\n\ndef solve():\n n = int(input())\n primes = [2,3,5,7]\n ans = sum([n//i for i in primes])\n for i in range(4):\n for j in range(i+1, 4):\n ans -= n//lcm([primes[i], primes[j]])\n ans -= n//lcm(primes)\n print(abs(n - ans))\n\n\n\n\n\n\n \n\nif __name__ == \"__main__\":\n\tsolve()"}, {"source_code": "def main():\n res, n = divmod(int(input()), 2520)\n l = [1] * n\n for p in range(2, 11):\n for i in range(0, n, p):\n l[i] = 0\n print(res * 576 + sum(l))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nn=int(input())\nprint(n-((n//2)+(n//3)-(n//6)+(n//5)-(n//10)+(n//7)-(n//14)-(n//15)-(n//21)-(n//35)))\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\n#while(n != 0):\nresult = n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35 - n//30 - n//42 - n//70 - n//105 \nprint(result)"}, {"source_code": "t=int(input())\na=t//2\nb=t//3\nc=t//5\nd=t//7\nab=t//6\nac=t//10\nad=t//14\nbc=t//15\nbd=t//21\ncd=t//35\nabc=t//30\nabd=t//70\nacd=t//42\nbcd=t//105\nabcd=t//210\nx=a+b+c+d+abc+abd+acd+bcd\ny=ab+ac+ad+bc+bd+cd+abcd\nprint(x-y)"}, {"source_code": "n = int(input())\nprint(n-n//2-n//3-n//5-n//7+n//6+n//10+n//14+n//15+n//21+n//35-n//30-n//42-n//105+n//210)"}, {"source_code": "n = int(input())\ny = n / 2;\ny += n / 3;\ny += n / 5;\ny += n / 7;\ny -= n / 6;\ny -= n / 15;\ny -= n / 35;\ny -= n / 14;\ny -= n / 21;\ny -= n / 10;\ny += (n * 2) / 210;\ny += (n * 3) / 210;\ny += (n * 5) / 210;\ny += (n * 7) / 210;\ny -= (n) / 210;\nprint(n - y)"}, {"source_code": "print(int(input())*8//35)"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nresult = n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35 \nprint(result)"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35 - n // 30 + n // 70 + n // 210 - n // 105 - n // 42)"}, {"source_code": "n=int(input())\nans=n/2+n/3+n/5+n/7;\nans=ans-n/6-n/10-n/14-n/15-n/21-n/35;\nans=ans+n/30+n/42+n/70+n/(3*5*7);\nans=ans-n/(2*3*5*7);\nans=ans-8;\nif n <= 10 :\n\tans=1\nprint ans\n\n"}, {"source_code": "def test(x):\n return not any([x%i==0 for i in list(range(2,11))])\nN = int(input())\nCP = 2*3*5*7\ntoCP = 0\n\nfor i in range(1, CP+1):\n if test(i):\n toCP+=1\n\nans = int(N/CP)*toCP\nfor i in range(int(N/CP)*CP+1,N+1):\n if test(i):\n ans+=1\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nn = input()\nans = n\nn2 = n / 2\nn3 = n / 3\nn5 = n / 5\nn7 = n / 7\nn23 = n / 6\nn25 = n / 10\nn27 = n / 14\nn35 = n / 15\nn37 = n / 21\nn57 = n / 35\nn235 = n/30\nn237=n/42\nn357=n/105\nn2357=n/210\nnn = n2 + n3 + n5 + n7 - n23-n25-n27-n35-n37-n57+n235+n237+n357\nans -= nn\nprint ans\n"}, {"source_code": "a = int(raw_input())\nprint a - a//2 - a//3 - a//5 - a//7 + (a//(6)) + a//(10) + a // 14 + a//15 + a//21 + a//35 - a//30 - a//42 - a//105 + a//(2*3*5*7)\n\n"}, {"source_code": "from math import *\nfrom fractions import gcd\nfrom itertools import combinations\nn = int(raw_input())\n\nans = 0\n\narr = [i + 2 for i in xrange(9)]\n\nfor r in xrange(0, len(arr)):\n for mask in combinations(arr, r):\n l = 1\n for i in mask:\n l = l / gcd(i, l) * i\n ans += n / l if r % 2 == 0 else -(n / l)\n\nprint ans"}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nn=int(input())\ndivisable=(n//2)+(n//3)+(n//5)+(n//7)-(n//6)-(n//10)-(n//14)-(n//15)-(n//21)-(n//35)-(n//30)-(n//42)-(n//70)-(n//105)-(n//210)\nprint(n-divisable)"}, {"source_code": "n = int(input())\n\nsolution = int(n/2) + int(n/3) + int(n/5) + int(n/7)\nsolution -= (int(n/6) + int(n/10) + int(n/14) + int(n/15) + int(n/21) + int(n/35))\nsolution += int(n/30) + int(n/42) + int(n/70) + int(n/105)\nsolution -= int(n/210)\n\nprint(n - solution)"}, {"source_code": "n = int(input())\nost = n//2520\nans = 0\nfor i in range(1, n%2520 + 1):\n if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 or i % 7 == 0:\n ans += 1\nprint(ost * 576 + n - ans)\n"}, {"source_code": "def sieve(n):\n s=[1]*(n+1)\n s[0]=0\n s[1]=0\n for i in range(2,n+1):\n if s[i]==1:\n for j in range(i*i,n+1,i):\n s[j]=0\n return s\n\ndef pi(x):\n s=sieve(x)\n for i in range(1,len(s)):\n s[i]=s[i]+s[i-1]\n return s\n\nn=int(input())\nif n==1:\n print(1)\nelif 2<=n<=10:\n print(0)\nelse:\n print(-3 + pi(n)[-1])"}, {"source_code": "# 2 3 5 7\nn=int(input())\nans=n-n//2-n//3-n//5-n//7\nans+=n//6+n//10+n//14+n//15+n//21+n//35\nans-=n//30+n//42+n//70+n//105\nprint(ans-n//210)\n"}, {"source_code": "def indivisibility(n):\n return n - (n//2 + n//3 + n//5 + n//7) + (n//6 + n//10 + n//14 + n//15 + n//21 + n//35) - (n//30+n//42+n//105) + (n//210)\n\n\n\nn = int(input())\nprint(indivisibility(n))"}, {"source_code": "def main():\n res, n = divmod(int(input()), 2520)\n l = [1] * n\n for p in range(2, 11):\n for i in range(0, n, p):\n l[i] = 0\n print(res * 576 + sum(l))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nresult = n - n//2 + n//3 + n//5 + n//7\nprint(result)"}, {"source_code": "#########\t\t\t##\t## ## \t #### ##### ## # ## #\t\t##\n\t#\t\t\t # #\t# # # #\t\t #\t #\t#\t# # # # # # #\t # #\n\t#\t\t\t # #\t# ### #\t #\t\t#\t# # # # # # #\t # #\n\t#\t\t\t #####\t#\t#\t#\t # ###\t#\t# # # # # # # #####\n\t#\t\t\t# #\t#\t\t#\t # # #\t#\t# #\t# # #\t # # # # \n######### \t # # \t#\t\t#\t\t##### #\t##### #\t ## #\t ## # #\n\n\"\"\"\n\nPPPPPPP RRRRRRR\t\t OOOO\t VV VV EEEEEEEEEE\nPPPPPPPP RRRRRRRR OOOOOO VV VV\t EE\nPPPPPPPPP RRRRRRRRR OOOOOOOO VV VV\t EE\nPPPPPPPP RRRRRRRR OOOOOOOO VV VV \t EEEEEE\nPPPPPPP RRRRRRR OOOOOOOO VV VV EEEEEEE\nPP \t\t RRRR\t\t\t OOOOOOOO VV VV EEEEEE\nPP\t\t\t RR RR OOOOOOOO VV VV EE\nPP\t\t\t RR RR OOOOOO VV VV EE\nPP\t\t\t RR RR OOOO VVVV EEEEEEEEEE\n\n\"\"\"\n\n\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nimport sys\ninput = sys.stdin.readline\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // gcd(a, b)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0, hi = None):\n if hi == None:\n hi = len(a);\n while lo < hi:\n mid = (lo+hi)//2;\n if a[mid] < x:\n lo = mid+1;\n else:\n hi = mid;\n return lo;\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\n\nfrom bisect import bisect_left\n\n\ndef solve():\n\tn = int(input())\n\tans = n - (n // 2 + n // 3 + n // 5 + n // 7) + ( n // (2 * 3) + n // (2 * 5) + n // (2 * 7) + n // (3 * 5) + n // (3 * 7) * n // (5 * 7) ) - ( n // (2 * 3 * 5) + n // (2 * 3 * 7) + n // (2 * 5 * 7) + n // (3 * 5 * 7) ) + (n // (2 * 3 * 5 * 7))\n\tprint(ans)\nif __name__ == '__main__':\n\tfor _ in range(1):\n\t\tsolve()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "n = int(raw_input())\n \nprint n - n // 2 - n // 3 - n // 5 + n // 6 - n // 7 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35"}, {"source_code": "#map(int,raw_input().split())\nn = int(raw_input())\n\nprint n-((n/2)+(n/3) - (n/6) + (n/5) - (n/15) - (n/10) + (n/7) - (n/14) - (n/21) - (\n n/35))\n\n"}, {"source_code": "w = int(input())\ntotal = (w-w//2-w//3-w//5-w//7+w//6+w//10+w//14+w//15+w//21+w//35-w//30-w//42 -w//70-w//14+w//210)\nprint(total)"}, {"source_code": "def yesorno (number):\n for i in range(11)[2:]:\n if (number%i) == 0:\n return 0\n return 1\n\ncountdownload = input()\ncountprem = 0\nfor number in range(countdownload+1):\n countprem += yesorno(number)\n print number\nprint countprem"}, {"source_code": "def yesorno (number):\n for i in range(11)[2:]:\n if (number%i) == 0:\n return 0\n return 1\n\ncountdownload = input()\ncountprem = 1\nfor number in range(countdownload)[11::2]:\n countprem += yesorno(number)\nprint countprem"}, {"source_code": "n = int(input())\nprint n - (n // 2 + n // 3 + n // 5 + n // 7 - n // 6 - n // 10 - n // 14 - n // 15 - n // 21 - n // 35 + n // 30 + n // 42 + n // 70 + n // 135 - n // 270)"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\nfrom math import sqrt, floor, factorial, gcd, log\nfrom collections import deque, Counter, defaultdict\nfrom itertools import permutations\nfrom math import gcd\nfrom bisect import bisect\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nread = lambda: list(map(int, input().strip().split(\" \")))\n\ndef lcm(arr):\n _lcm = 1\n for i in arr:\n _lcm = (_lcm*i)//gcd(_lcm, i)\n return(_lcm)\n\ndef solve():\n n = int(input())\n primes = [2,3,5,7]\n ans = sum([n//i for i in primes])\n for i in range(4):\n for j in range(i+1, 4):\n ans -= n//lcm([primes[i], primes[j]])\n ans -= n//lcm(primes)\n print(abs(n - ans))\n\n\n\n\n\n\n \n\nif __name__ == \"__main__\":\n\tsolve()"}, {"source_code": "n = int(input())\nprint(n - n//2 - n//3 - n//5 - n//7)"}, {"source_code": "def main():\n\tn = int(input())\n\tprint(solver(n))\n\ndef solver(n):\n\tfactors = [2, 3, 5, 7]\n\tsingles = n // 2 + n // 3 + n // 5 + n // 7\n\tpairs = n // (2 * 3) + n // (2 * 5) + n // (2 * 7) + \\\n\tn // (3 * 5) + n // (3 * 7) + n // (5 * 7)\n\ttriples = n // (2 * 3 * 5) + n // (2 * 3 * 7) + \\\n\tn // (2 * 5 * 7) + n // (3 * 5 * 7)\n\tquads = n // (2 * 3 * 5 * 7)\n\treturn n - singles + pairs - triples + quads"}, {"source_code": "n = int(raw_input())\n\nprint n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35\n"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10)"}, {"source_code": "print((int(input())+1)*8//35)"}, {"source_code": "def main():\n n = int(input())\n a = (n // 2 + n // 3 + n // 5 + n // 7)\n b = (n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35)\n c = (n // 30 + n // 42 + n // 70 + n // 105)\n print(n - a + b - c)\n \nmain()"}, {"source_code": "n=input()\n\nk=n/2+n/3+n/5+n/7-n/6-n/10-n/14-n/15-n/21-n/35+n/30+n/42+n/105-n/2100\nprint n-k"}, {"source_code": "n=int(input())\nn-=1\nprint(n-(n//2+n//3+n//5+n//7-n//6-n//10-n//15-n//14-n//21-n//35+n//110+n//70+n//42+n//30-n//210))"}, {"source_code": "n=int(input())\nprint(n-(n//2+n//3+n//5+n//7-n//6-n//10-n//14-n//15-n//21-n//35+n//30+n//42+n//72+n//105-n//210))"}, {"source_code": "arr = [2,3,5,7,6,10,14,15,21,35,30,42,105,210]\n\nn = int(input())\nc = 0\n\nfor i in range(4):\n c += n // arr[i]\n\nfor i in range(4,10):\n c -= n // arr[i]\n\nfor i in range(10,13):\n c += n // arr[i]\n\nc -= n // arr[-1]\n\nprint(n - c)\n"}, {"source_code": "def yesorno (number):\n for i in range(11)[2:]:\n if (number%i) == 0:\n return 0\n return 1\n\ncountdownload = input()\ncountprem = 0\nfor number in range(countdownload+1):\n countprem += yesorno(number)\n print number\nprint countprem"}, {"source_code": "n = int(input())\nprint(n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35)"}, {"source_code": "def gcd(a, b):\n if b==0:\n return a\n return gcd(b, a%b)\n\nt=1\n\nfor i in xrange(2, 10):\n t= (t*i)/gcd(i, t)\n\nn= int(raw_input())\n\nprint n-(n/t)"}, {"source_code": "def pol(n,k):\n ans = 1\n for i in range(k):\n ans *= (n-i)/(i+1)\n k = int(ans)\n if abs(k - ans) < 1/2:\n return k\n return k + 1\nn = int(input())\nd = [2,3,5,7]\nans = n\nfor i in range(4):\n ans -= int(n/d[i])\nfor i in range(4):\n for j in range(4):\n if i < j:\n ans += int(n/(d[i]*d[j]))\nfor i in range(4):\n for j in range(4):\n for k in range(4):\n if i < j and j < k:\n ans -= int(n/(d[i]*d[j]*d[k]))\n\nans += int(n/(2*3*5*7))\nprint(ans)"}, {"source_code": "import math\nfrom math import *\nn = int(input())\nd = [2,3,5,7]\nans = n\nfor i in range(4):\n ans -= (n/d[i])\nfor i in range(4):\n for j in range(4):\n if i < j:\n ans += (n/(d[i]*d[j]))\nfor i in range(4):\n for j in range(4):\n for k in range(4):\n if i < j and j < k:\n ans -= (n/(d[i]*d[j]*d[k]))\n\nans += (n/(2*3*5*7))\nprint(int(ans))"}, {"source_code": "n = int(input())\ns = 0\nfor i in range(16):\n d = 1\n for j, k in ((1, 2), (2, 3), (4, 5), (8, 7)):\n if i & j: d *= -k\n s += n // d\nprint(s)\n"}, {"source_code": "n = int(input())\nans = 0\nans += n // 2\nans += n // 3\nans += n // 5\nans += n // 7\nans -= n // 6\nans -= n // 10\nans -= n // 14\nans -= n // 15\nans -= n // 21\nans -= n // 35\nprint(n - ans)\n"}, {"source_code": "n = int(input())\nans = 0\ns = [2, 3, 5, 7]\nfor i in s:\n ans += n // i\nans = n - ans + n // 6 + n // 10 + n // 14 + n // 15 + n // 21 + n // 35\nprint(ans)"}, {"source_code": "num = int(input().strip())\nnums = [2,3,5,7]\ncul2 = [6,10,14,30,210]\ncul3 = [15,105]\ncul5 = [35]\nans=0\nfor i in range(len(nums)):\n ans += (num//nums[i])\n if i == 0:\n for j in cul2:\n ans -= num//j\n if i == 1:\n for j in cul3:\n ans -= num//j\n if i == 2:\n for j in cul5:\n ans -= num//j\n\t\nprint(num - ans)"}, {"source_code": "n = int(input())\nprint(n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 + n//15 + n//21 + n//35)"}, {"source_code": "import math\nfrom math import *\nn = int(input())\nd = [2,3,5,7]\nans = n\nfor i in range(4):\n ans -= floor(n/d[i])\nfor i in range(4):\n for j in range(4):\n if i < j:\n ans += floor(n/(d[i]*d[j]))\nfor i in range(4):\n for j in range(4):\n for k in range(4):\n if i < j and j < k:\n ans -= int(n/(d[i]*d[j]*d[k]))\n\nans += floor(n/(2*3*5*7))\nprint(ans)"}, {"source_code": "n = int(raw_input())\n\nprint n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35\n"}, {"source_code": "n = int(input())\nprint n // 2 + n // 3 + n // 5 + n // 7 - n // 6 - n // 10 - n // 14 - n // 15 - n // 21 - n // 35 + n // 30 + n // 42 + n // 70 + n // 135 - n // 270"}, {"source_code": "n=int(input())\nprint(n-(n//2+n//3+n//5+n//7-n//6-n//10-n//15-n//21-n//35+n//110+n//70+n//42+n//30-n//210))"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nn = input()\nans = n\nn2 = n / 2\nn3 = n / 3\nn5 = n / 5\nn7 = n / 7\nn23 = n / 6\nn25 = n / 10\nn27 = n / 14\nn35 = n / 15\nn37 = n / 21\nn57 = n / 35\nn235 = n/30\nn237=n/42\nn357=n/105\nn2357=n/210\nnn = n2 + n3 + n5 + n7 - n23-n25-n27-n35-n37-n57+n235+n237+n357+3*n2357\nans -= nn\nprint ans\n"}, {"source_code": "from sys import stdin\n\nn = int(stdin.readline())\nprint n/2 + n/3 + n/5 + n/7 - n/6 - n/10 - n/14 - n/15 - n/21 - n/35 + n/30 + n/42 + n/70 + n/105 - n/420"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase\nfrom string import ascii_uppercase\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] != \"CPython\": # PyPy?\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\nn = read_int()\nres = []\nfor i in range(2520):\n for j in range(2, 11):\n if i % j == 0:\n break\n else:\n res.append(1)\n continue\n res.append(0)\n\nq, r = divmod(n, 2520)\nans = q * res.count(1) + res[:r].count(1)\nprint ans\n"}, {"source_code": "n = int(input())\nprint (n - n//2 - n//3 - n//5 - n//7 + n//6 + n//10 + n//14 - n//30 - n//42 - n//105 + n//210)\n"}, {"source_code": "def main():\n res, n = divmod(int(input()), 2520)\n l = [1] * n\n for p in range(2, 11):\n for i in range(0, n, p):\n l[i] = 0\n print(res * 576 + sum(l))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = long(raw_input())\nprint n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 + n / 21 + n / 35 - n / 30 - n / 42 - n / 70 - n / 105\n+ n / 210"}, {"source_code": "data = [2, 3, 5, 7]\nn = int(input())\nhelp = 0\nfor i in range(4):\n for j in range(4):\n if j > i:\n help += n // (data[i] * data[j])\nprint(n - (n // 2 + n // 3 + n // 5 + n // 7 - help))"}, {"source_code": "sub = [2, 3, 5, 7, 2*3*5, 2*5*7, 3*5*7]\nadd = [2*3, 2*5, 2*7, 3*5, 3*7, 5*7, 2*3*5*7]\n\nn = int(raw_input())\n\nans = n\nfor x in add:\n ans += n/x\nfor x in sub:\n ans -= n/x\n\nprint ans"}, {"source_code": "n = int(input())\na=(n//2+n//3+n//5+n//7-n//6-n//10-n//14-n//15-n//21-n//35+n//30+n//42+n//70+n//105-n//410)\nprint(n-a)"}, {"source_code": "n = int(raw_input())\n\nprint n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35\n"}, {"source_code": "n=int(input())\nans=n/2+n/3+n/5+n/7;\nans=ans-n/6-n/10-n/14-n/15-n/21-n/35;\nans=ans+n/30+n/42+n/70+n/(3*5*7);\nans=ans-n/(2*3*5*7);\nans=ans-8;\nif n <= 10 :\n\tans=1\nprint ans\n\n"}, {"source_code": "from sys import stdin,stdout\nfrom math import gcd, ceil, sqrt,factorial as f\nii1 = lambda: int(stdin.readline().strip())\nis1 = lambda: stdin.readline().strip()\niia = lambda: list(map(int, stdin.readline().strip().split()))\nisa = lambda: stdin.readline().strip().split()\nmod = 1000000007\n\nn = ii1()\ndiv = [2, 3, 5, 7]\nres = n\nfor i in div:\n res -= n // i\ndiv1 = [6, 10, 14, 30, 210, 15, 21, 115, 35]\nfor i in div1:\n res += n // i\nprint(res) \n\n"}, {"source_code": "def yesorno (number):\n for i in range(11)[2:]:\n if (number%i) == 0:\n return 0\n return 1\n\ncountdownload = input()\ncountprem = 0\nfor number in range(countdownload+1):\n countprem += yesorno(number)\n print number\nprint countprem"}, {"source_code": "# S = input()\n# A = S[0] + S[2] + S[4] + S[3] + S[1]\n# N = int(A)\n# print(N ** 5 % 10 ** 5)\n\nN = int(input())\n\nsol = 0\nprimes = [2, 3, 5, 7]\n\nfor state in range(1, 2 ** len(primes)):\n\n numbBits = 0\n prod = 1\n\n for j in range(4):\n if (1 << j) & state:\n numbBits += 1\n prod *= primes[j]\n\n if numbBits & 1:\n sol += int(N / prod)\n else:\n sol -= int(N / prod)\n\nprint(N - sol)"}, {"source_code": "a=int(input());print(a-a//2-a//3-a//5-a//7+a//6+a//10+a//14+a//15+a//17+a//35-a//30-a//105-a//70-a//42+a//210)"}, {"source_code": "n = int(input())\n\nneg = [2, 3, 5, 7, 2*3*5, 2*3*7, 2*5*7, 3*5*7]\npos = [1, 2*3, 2*5, 2*7, 3*5, 3*7, 5*7]\n\nret = 0\nfor x in neg:\n ret -= n // x\n \nfor x in pos:\n ret += n // x\n \nprint(ret)"}, {"source_code": "import os, sys, pdb\nimport time, calendar, datetime\nimport math, itertools\nimport operator as op\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer // denom\n\nl = []\nfor i in range(2520):\n div = 1\n for j in range(2,11):\n if i % j == 0:\n div = 0\n l.append(div)\n\n#print(l[:15])\n\nn, = list(map(int, input().split()))\nprint( (n // 2520) * sum(l) + sum(l[:((n+1) % 2520)]) )\n\n\n"}, {"source_code": "from sys import stdin,stdout\nfrom math import gcd, ceil, sqrt,factorial as f\nii1 = lambda: int(stdin.readline().strip())\nis1 = lambda: stdin.readline().strip()\niia = lambda: list(map(int, stdin.readline().strip().split()))\nisa = lambda: stdin.readline().strip().split()\nmod = 1000000007\n\nn = ii1()\ndiv = [2, 3, 5, 7]\nres = n\nfor i in div:\n res -= n // i\ndiv1 = [6, 10, 14, 30, 210, 15, 21, 105, 35, 42, 70]\nfor i in div1:\n res += n // i\nprint(res) \n\n"}, {"source_code": "from sys import stdin,stdout\nfrom math import gcd, ceil, sqrt,factorial as f\nii1 = lambda: int(stdin.readline().strip())\nis1 = lambda: stdin.readline().strip()\niia = lambda: list(map(int, stdin.readline().strip().split()))\nisa = lambda: stdin.readline().strip().split()\nmod = 1000000007\n\nn = ii1()\ndiv = [2, 3, 5, 7]\nres = n\nfor i in div:\n res -= n // i\ndiv1 = [6, 10, 14, 30, 210, 15, 21, 105, 35, 42, 70]\nfor i in div1:\n res += n // i\nprint(res) \n\n"}, {"source_code": "n = int(input())\nost = n//210\nans = 0\nfor i in range(1, n%210 + 1):\n if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 or i % 7 == 0:\n ans += 1\nprint(ost * 48 + n - ans)\n"}, {"source_code": "def yesorno (number):\n for i in range(11)[2:]:\n if (number%i) == 0:\n return 0\n return 1\n\ncountdownload = input()\ncountprem = 0\nfor number in range(countdownload):\n countprem += yesorno(number)\nprint countprem"}, {"source_code": "# 2 3 5 7\nn=int(input())\nans=n-n//2-n//3-n//5-n//7\nans+=n//6+n//10+n//14+n//15+n//21+n//35\nans-=n//30+n//42+n//70+n//105\nprint(ans-n//210)\n"}, {"source_code": "import math\nfrom math import *\nn = int(input())\nd = [2,3,5,7]\nans = n\nfor i in range(4):\n ans -= int(n/d[i])\nfor i in range(4):\n for j in range(i+1,4):\n ans += int(n/(d[i]*d[j]))\nfor i in range(4):\n for j in range(i+1,4):\n for k in range(j+1,4):\n ans -= int(n/(d[i]*d[j]*d[k]))\n\nans += int(n/(2*3*5*7))\nprint(int(ans))"}, {"source_code": "n = int(raw_input())\nprint n - n // 2 - n // 3 - n // 5 - n // 7 + n // 6 + n // 10 + n // 14 + n //15 + n // 35 - n // 30 - n // 42 - n // 70 - n // 105 + n // 210"}, {"source_code": "import math\nfrom math import *\nn = int(input())\nd = [2,3,5,7]\nans = n\nfor i in range(4):\n ans -= floor(n/d[i])\nfor i in range(4):\n for j in range(4):\n if i < j:\n ans += floor(n/(d[i]*d[j]))\nfor i in range(4):\n for j in range(4):\n for k in range(4):\n if i < j and j < k:\n ans -= int(n/(d[i]*d[j]*d[k]))\n\nans += floor(n/(2*3*5*7))\nprint(ans)"}, {"source_code": "n = 0\n\ndef add(x, y):\n m = int(pow(-1, x))\n return m * (n // y)\n\nn = int(input())\na = n\n\na += add(1, 2)\na += add(1, 3)\na += add(1, 5)\na += add(1, 7)\n\na += add(0, 2 * 3)\na += add(0, 2 * 5)\na += add(0, 2 * 7)\na += add(0, 3 * 5)\na += add(0, 3 * 7)\na += add(0, 5 * 7)\n\na += add(1, 2 * 3 * 5)\na += add(1, 2 * 3 * 7)\na += add(1, 2 * 5 * 7)\na += add(1, 3 * 5 * 7)\n\na += add(0, 3 * 5 * 7)\n\nprint(a)"}, {"source_code": "import os, sys, pdb\nimport time, calendar, datetime\nimport math, itertools\nimport operator as op\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer // denom\n\nl = []\nfor i in range(2520):\n div = 1\n for j in range(2,11):\n if i % j == 0:\n div = 0\n l.append(div)\n\n#print(l[:15])\n\nn, = list(map(int, input().split()))\nprint( (n // 2520) * sum(l) + sum(l[:((n+1) % 2520)]) )\n\n\n"}, {"source_code": "n = int(input())\nans = 0\ns = [2, 3, 5, 7]\nfor i in s:\n ans += n // i\nans = n - ans + n // 6 + n // 10\nprint(ans)"}, {"source_code": "n = int(input())\n\nans = 0\nans += n//2 + n//3 + n//5 + n//7\nans -= n//(2*3) + n//(2*5) + n//(2*7) + n//(3*5) + n//(3*7) + n//(5*7)\nans -= n//(2*3*5) + n//(2*3*7) + n//(2*5*7) + n//(3*5*7)\nans -= n//(2*3*5*7)\n\nprint(n-ans)"}, {"source_code": "def yesorno (number):\n for i in range(11)[2:]:\n if (number%i) == 0:\n return 0\n return 1\n\ncountdownload = input()\ncountprem = 1\nfor number in range(countdownload)[11::2]:\n countprem += yesorno(number)\nprint countprem"}, {"source_code": "num = int(input().strip())\nnums = [2,3,5,7]\nans=0\nfor i in nums:\n ans += num//i\nprint(ans)"}, {"source_code": "n = int(input())\n\nsolution = int(n/2) + int(n/3) + int(n/5) + int(n/7)\nsolution -= (int(n/6) + int(n/10) + int(n/14) + int(n/15) + int(n/21) + int(n/35))\nsolution += int(n/30) + int(n/42) + int(n/70) + int(n/105)\nsolution -= int(n/210)\n\nprint(n - solution)"}, {"source_code": "n = int(raw_input())\nans = (n / 2 + n / 3 + n / 5 + n / 7)\nans -= (n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35)\nans += (n / 30 + n / 42 + n / 70 + n / 105)\nans -= ans / 210\nprint n - ans"}, {"source_code": "def main():\n res, n = divmod(int(input()), 2520)\n l = [1] * n\n for p in range(2, 11):\n for i in range(0, n, p):\n l[i] = 0\n print(res * 576 + sum(l))\n\n\nif __name__ == '__main__':\n main()\n"}], "src_uid": "e392be5411ffccc1df50e65ec1f5c589"} {"source_code": "a,b,c=map(int,raw_input().split())\nprint 'YES' if a==b or (c and (not (b-a)%c) and (b>a)==(c>0)) else 'NO'\n", "positive_code": [{"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jan 19 01:42:31 2019\n\n@author: KIIT\n\"\"\"\n\nimport math\nimport os\nimport random\nimport re\nimport sys\nif __name__ == '__main__':\n x = list(map(int, input().rstrip().split()))\n a,b,c=x[0],x[1],x[2]\n \n if(c==0):\n if((b-a)==0):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n k=(b-a)%c\n if(k==0 and (b-a)/c>=0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "a,b,c=[int(e) for e in raw_input().split()]\nt=a\npresent=False\nif (c>0 and b<a) or (c<0 and a<b):\n\tpass\nelif c==0:\n\tif a==b:\n\t\tpresent=True\nelse:\n\tif (b-a)%c==0:\n\t\tpresent=True\nif present:\n\tprint \"YES\"\nelse :\n\tprint \"NO\"\n\n"}, {"source_code": "a, b, c = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nif c == 0:\n if a == b:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if b % c == a % c:\n if b < a:\n if c < 0:\n print(\"YES\")\n else:\n print(\"NO\")\n elif b > a:\n if c >= 0:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"YES\")\n \n else:\n print(\"NO\")\n"}, {"source_code": "a,s,d = map(int,input().split())\ndef check(a,s,d):\n if(d!=0):\n n = ((s-a)/d+1)\n j = n%1\n if(j==0.0):\n if(n>0):\n return (\"YES\")\n if(d==0):\n if(a==s):\n return (\"YES\")\n return \"NO\"\nprint(check(a,s,d))"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\nif c == 0:\n\tif a == b:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'\nelse:\n\tx = (b-a)/c\n\t# print x\n\tif a + x*c == b and x >= 0:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\nif c == 0:\n\tif a == b:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'\nelse:\n\tif (b-a)%c == 0 and (b-a)/c >= 0:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'"}, {"source_code": "a,b,c = map(int,raw_input().split());\nif (c == 0 and a==b) or (c != 0 and (b-a) % c == 0 and (b-a) / c >=0) :\n print \"YES\"\nelse : \n print \"NO\" "}, {"source_code": "a, b, c = map(int, input().split())\n\nif(a == b):\n print(\"YES\")\nelse:\n if(c > 0 and c != 1):\n while(a < b):\n a = c + a \n if(a == b):\n print(\"YES\")\n else:\n print(\"NO\")\n elif(c < 0 and c != -1):\n while(a > b):\n a = c + a\n if (a == b):\n print(\"YES\")\n else:\n print(\"NO\")\n elif(c == 0):\n print(\"NO\")\n elif(c == 1 and a < b):\n print(\"YES\")\n elif(c == -1 and a > b):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "#@author: behradm\n\ndef main():\n a, b, c = list(map(int, input().split()))\n\n if(c == 0):\n if(a == b):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n if((c < 0 and b > a) or (c > 0 and b < a)):\n print(\"NO\")\n return 0;\n\n if(a % c == b % c):\n print(\"YES\")\n else:\n print(\"NO\")\n\nif(__name__ == \"__main__\"):\n main()\n"}, {"source_code": "a, b, c = map(int, input().split())\nif c > 0 and b < a or c < 0 and b > a:\n print('NO')\nelse:\n try:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')\n except ZeroDivisionError:\n if a == b:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "a,b,c = map(int, input().split())\nif (a!=b and c==0):\n\tprint (\"NO\")\nelse:\n\tprint (\"YES\") if (a==b or ((b-a)%c==0 and (abs(b-a)/abs(c))==((b-a)/c))) else print (\"NO\")\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\nif c==0:\n print 'YES' if a==b else 'NO'\nelse:\n if (b-a)%c==0:\n print 'YES' if (c<0 and b<=a) or (c>0 and a<=b) else 'NO'\n else:\n print 'NO'"}, {"source_code": "from sys import stdin\ninput = stdin.readline\na, b, c = map(int, input().split())\nprint([\"NO\", \"YES\"][ c > 0 and b >= a and not (b - a)%c or c < 0 and a >= b and not (b - a)%c or c == 0 and a == b])"}, {"source_code": "from re import *\nfrom sys import stderr\ndef readint():\n return int(input())\ndef readfloat():\n return float(input())\ndef readarray(N, foo=input):\n return [foo() for i in range(N)]\ndef readlinearray(foo=int):\n return map(foo, input().split())\n\ndef NOD(a, b):\n while b:\n a,b = b, a%b\n return a\n\ndef gen_primes(max):\n primes = [1]*(max+1)\n for i in range(2, max+1):\n if primes[i]:\n for j in range(i+i, max+1, i):\n primes[j] = 0\n primes[0] = 0\n return [x for x in range(max+1) if primes[x]]\n\ndef is_prime(N):\n i = 3\n if not(N % 2):\n return 0\n while i*i < N:\n if not(N % i):\n return 0\n i += 3\n return 1\n\na, b, c = readlinearray()\nb -= a\n\nif b == 0 or (c != 0 and c * b > 0 and b % c == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a , b , c = map(int,input().split())\n\nif a == b and c == 0 or (c != 0 and (b - a ) // c >= 0 and (b - a) % c == 0 ):\n print('YES')\n\nelse:\n print('NO')\n\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\nif c==0:\n\tif a==b:print \"YES\"\n\telse:print \"NO\"\nelif ((b-a)==0) or (((b-a)%c==0) and (b-a)/c>0 ):print \"YES\"\nelse:print \"NO\"\n"}, {"source_code": "[a, b, c] = [int(item) for item in input().split(' ')]\n\nYES = \"YES\"\nNO = \"NO\"\n\ndiff = b - a\n\nif c:\n if diff == 0:\n print(\"YES\")\n exit()\n print(\"YES\" if diff // abs(diff) == c // abs(c) and diff % c == 0 else \"NO\")\nelse:\n print(\"YES\" if a == b else \"NO\")\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\nif c==0 :\n if a==b:\n print \"YES\"\n else:\n print \"NO\"\nelif (b-a)%c==0:\n if (b-a)/c>=0:\n print \"YES\"\n else:\n print \"NO\"\nelse:\n print \"NO\""}, {"source_code": "a, b, c = map(int, input().split())\nif c == 0:\n if a==b:\n print(\"YES\")\n else:\n print('NO')\nelif (b-a) % c == 0 and (b-a)//c >= 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b, c = map(int, raw_input().split())\nif c == 0:\n\tprint 'NO' if a != b else 'YES'\nelif c > 0:\n\tprint 'YES' if (a <= b and (b - a) % c == 0) else 'NO'\nelse:\n\tprint 'YES' if (a >= b and (a - b) % c == 0) else 'NO'"}, {"source_code": "def readInt(): return int(raw_input())\ndef readList(): return map(int, raw_input().split(' '))\n\na, b, c = readList()\n\nif c == 0 and a == b:\n print 'YES'\n exit()\nelif c == 0 and a != b:\n print 'NO'\n exit()\nif (b - a) % c == 0 and ((b-a)/c >= 0): print 'YES'\nelse: print 'NO'"}, {"source_code": "def f(l):\n a,b,c = l\n if c==0:\n return a==b\n return (b-a)%c==0 and (b-a)//c>=0\n\nl = list(map(int,input().split()))\nprint('YES' if f(l) else 'NO')\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\nprint 'YES' if (a == b) or (c != 0 and (b-a)%c == 0 and (a < b)^(c>0) == 0) else 'NO'"}, {"source_code": "a, b, c = map(int, raw_input().split())\nif a == b:\n print \"YES\"\nelif a > b:\n if c >= 0:\n print \"NO\"\n else:\n print \"YES\" if (a - b) % c == 0 else \"NO\"\nelse:\n if c <= 0:\n print \"NO\"\n else:\n print \"YES\" if (b - a) % c == 0 else \"NO\""}, {"source_code": "a, b, c = map(int, input().split())\nif c == 0 and b == a:\n print(\"YES\")\nelif c != 0 and (b-a)%c == 0 and (b>=a and c > 0 or b<=a and c <0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from math import ceil,floor\na,b,c = map(int,input().split())\nif(c==0):\n print(\"YES\" if a==b else \"NO\")\n exit(0)\ni = (b-a)/c\nif(i>=0 and ceil(i)==floor(i)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b, c = map(int, raw_input().split())\nprint (b == a or (c and (b - a) % c == 0 and (b - a) / c > 0)) and \"YES\" or \"NO\"\n"}, {"source_code": "x = raw_input().strip().split(\" \")\ns = int(x[0])\nt = int(x[1])\nd = int(x[2])\n\nif d==0:\n if s==t:\n print \"YES\"\n else:\n print \"NO\"\nelif (t-s)%d==0 and (t-s)/d>=0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "a, b, c = map(int, input().split())\nif c == 0:\n\tif a == b:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\td, r = divmod(b - a, c)\n\tif a == b:\n\t\tprint(\"YES\")\n\telse:\n\t\tif d < 1 or r != 0:\n\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"YES\")"}, {"source_code": "[a,b,c]=[int(x) for x in raw_input().split()]\nif c==0 :\n if a==b:\n print \"YES\"\n else:\n print \"NO\"\nelif (b-a)%c==0:\n if c >=0 and b>=a:\n print \"YES\"\n elif c<0 and b<=a:\n print \"YES\"\n else:\n print \"NO\"\nelse:\n print \"NO\""}, {"source_code": "a, b, c = map(int, input().split()); print(['NO', 'YES'][a == b or ( c != 0 and (b-a)%c == 0 and (b-a)//c >= 0)])"}, {"source_code": "if __name__ == '__main__':\n\ta,b,c = map(int,raw_input().split())\n\tt = b-a\n\tif a == b:\n\t\tprint 'YES'\n\telse:\n\t\tif c == 0:\n\t\t\tif a == b:\n\t\t\t\tprint 'YES'\n\t\t\telse:\n\t\t\t\tprint 'NO'\n\t\telif c < 0:\n\t\t\tif b > a:\n\t\t\t\tprint 'NO'\n\t\t\telse:\n\t\t\t\tif t % c == 0:\n\t\t\t\t\tprint 'YES'\n\t\t\t\telse:\n\t\t\t\t\tprint 'NO'\n\t\telif c > 0:\n\t\t\tif t % c == 0 and b > a:\n\t\t\t\tprint 'YES'\n\t\t\telse:\n\t\t\t\tprint 'NO'"}, {"source_code": "read = lambda: map(int, input().split())\na, b, c = read()\nif c == 0 and (b == a): ans = 'YES'\nelif c != 0 and (b - a) % c == 0:\n if c > 0 and b >= a: ans = 'YES'\n elif c < 0 and b <= a: ans = 'YES'\n else: ans = 'NO'\nelse: ans = 'NO'\nprint(ans)\n"}, {"source_code": "a, b, c = map(int, input().split())\ndef solve(a, b, c):\n if c == 0:\n return a == b\n elif c < 0:\n a, b, c = -a, -b, -c\n return b >= a and b%c == a%c\n\nprint('YES' if solve(a, b, c) else 'NO')\n"}, {"source_code": "from collections import *\na,b,c = list(map(int,input().split()))\nif(c == 0):\n\tif(a == b): print(\"YES\")\n\telse: print(\"NO\")\nelif(a%c == b%c):\n\tif (a >= b and c < 0) or (a <= b and c > 0): print(\"YES\")\n\telse: print(\"NO\")\nelse: print(\"NO\")\n"}, {"source_code": "def IsInt(n):\n if n==int(n):\n return True\n else:\n return False\n\n \ninputs=raw_input().split()\n\na=int(inputs[0])\nb=int(inputs[1])\nc=int(inputs[2])\n\nif c!=0:\n n=float(b-a)/c\nelse:\n n=b-a\n\nif IsInt(n) and c!=0 and n>=0:\n print 'YES'\nelif IsInt(n) and c==0 and b==a and n>=0:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "a, b, c = [int(i) for i in input().split()]\n\nif (c == 0):\n if (a == b):\n print(\"YES\")\n else:\n print(\"NO\")\nelif ((b - a) % c == 0):\n if ((b - a) / c >= 0):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "from collections import Counter,defaultdict\nI =lambda:int(input())\nM =lambda:map(int,input().split())\nLI=lambda:list(map(int,input().split()))\nfor _ in range(1):\n a,b,c=M()\n if c==0 or a==b:\n if a==b:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n d=abs(a-b)\n if a>b:\n if d%c==0 and c<0:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n if d%c==0 and c>0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n \n\n \n\n\n\n \n\n \n \n \n \n \n \n \n\n\n \n\n\n\n \n \n\n\n\n\n \n\n\n \n \n \n\n \n\n\n\n"}, {"source_code": "a,b,c = map(int,raw_input().split())\nif c ==0:\n if b==a:\n print 'YES'\n else:\n print 'NO'\nelse:\n if (b-a)%c ==0 and (b-a)/c >=0 :\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "def foo ():\n input = map(lambda x: int(x), raw_input().split())\n a1 = input[0]\n favourite = input[1]\n d = input[2]\n if d == 0:\n if a1 == favourite: print 'YES'\n else: print 'NO'\n else:\n k = float(favourite - a1)/float(d)\n if int(k) == k and k>=0: print 'YES'\n else: print 'NO'\n\nfoo()\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\nif c == 0 and a != b:\n\tprint 'NO'\nelif a == b:\n\tprint 'YES'\nelif (b-a)%c == 0 and a > b and c < 0:\n\tprint 'YES'\nelif (b-a)%c == 0 and a < b and c > 0:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "a, b, c = raw_input().split()\na = int(a)\nb = int(b)\nc = int(c)\n\nif (b < a) and (c > 0):\n\tprint(\"NO\")\nelif (b > a) and (c < 0):\n\tprint(\"NO\")\nelif (c == 0):\n\tif (a == b):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tb = b - a\n\tif (b % c == 0):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\nif (c == 0 and a == b):\n print \"YES\"\nelif (c == 0 and a != b):\n print \"NO\"\nelif (c != 0 and (b - a) / c >= 0 and (b-a) % c == 0):\n print \"YES\"\nelse:\n print \"NO\"\n\n"}, {"source_code": "a,b,c=map(int, input().split())\nif (c==0 and a==b) or (c!=0 and (b-a)%c==0 and (b-a)/c>=0) :\n print('YES')\nelse:\n print('NO')"}, {"source_code": "line = raw_input()\n\na, b, c = [int(i) for i in line.split()]\n\nif c == 0:\n\tprint \"YES\" if a == b else \"NO\"\nelse:\n\tdiv = (b - a) / float(c)\n\tprint \"YES\" if int(div) == div and div >= 0 else \"NO\"\n"}, {"source_code": "from sys import stdin, stdout\nimport math\n\na,b,c = map(int, stdin.readline().split())\n\nif a==b:\n print('YES')\nelse:\n if c==0:\n print('NO')\n else:\n if (b-a)*c<0 or abs(a-b)%abs(c)!=0:\n print('NO')\n else:\n print('YES')\n"}, {"source_code": "#n = int(input())\na, b, c = map(int, input().split())\n#s = input()\n#c = list(map(int, input().split()))\nk = (a < b) * (c > 0) + (a > b) * (c < 0)\nif a == b:\n print('YES')\nelse:\n if c == 0:\n print('NO')\n else:\n if (c == 0 and a == b) or (k and (b - a) % c == 0):\n print('YES')\n else:\n print('NO')"}, {"source_code": "string = [int(i) for i in input().split()]\na, b, c = string[0], string[1], string[2]\nif c == 0:\n if a == b:\n print('YES')\n else:\n print('NO')\nelse:\n if (b - a) / c + 1 != 0 and ((b - a) / c + 1) > 0 and ((b - a) / c + 1) % 1 == 0:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "a, b, c = list(map(int, input().split()))\n\nif a == b:\n print(\"YES\")\n#elif b <= 0 and a < 0 and c < 0 and (a + c) < b:\n# print(\"NO\")\n#elif b >= 0 and a > 0 and c > 0 and (a + c) > b:\n# print(\"NO\")\n#elif b < 0 and a > 0 and c > 0:\n# print(\"NO\")\n#elif b > 0 and a < 0 and c < 0:\n# print(\"NO\")\nelif c == 0 and a != b:\n print(\"NO\")\nelse:\n match = (b - a) % c\n match_div = (b -a ) / c\n if match == 0 and match_div > 0:\n print(\"YES\")\n else:\n print(\"NO\") \n"}, {"source_code": "Seq_Element, myNum, incr = [int(x) for x in input().split()]\nif incr == 0: print(\"YES\") if Seq_Element == myNum else print(\"NO\")\nelif (incr < 0 and Seq_Element < myNum) or (incr > 0 and Seq_Element > myNum):\n print(\"NO\")\nelse:\n if (myNum - Seq_Element)%incr != 0:\n print(\"NO\")\n else: print(\"YES\")"}, {"source_code": "\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n a, b, c = map(int, input().split())\n if c == 0:\n if a == b:\n print(\"YES\")\n else:\n print(\"NO\")\n elif (b - a) // c >= 0 and (b - a) % c == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n \n \n \n \n "}, {"source_code": "z = input().split()\nx = list(map(int, z))\na, b, c = x[0], x[1], x[2]\n\nif a < b and c < 0:\n print(\"NO\")\n exit(0)\nif a > b and c > 0:\n print(\"NO\")\n exit(0)\nif (a != b) and c == 0:\n print(\"NO\")\n exit(0)\nif a == b:\n print(\"YES\")\n exit(0)\nif (b - a) % c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def main():\n a, b, c = map(int, input().split())\n if c == 0:\n if b == a:\n print('YES')\n else:\n print('NO')\n return\n print('YES' if ((b - a) % c == 0 and\n ((c > 0 and b >= a) or (c < 0 and b <= a))) else 'NO')\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "inpt=input().split()\na=int(inpt[0])\nb=int(inpt[1])\nc=int(inpt[2])\nres=b-a\n#print (res)\nif c==0:\n if a==b:\n print(\"YES\")\n else:\n print(\"NO\")\nelif b<a and c>0:\n print(\"NO\")\nelif a<b and c<0:\n print(\"NO\")\nelse:\n x=res%c\n if x==0:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "a,b,c=list(map(int,input().split()))\nif (c==0 and b-a==0) or (c!=0 and (b-a)%c==0 and (b-a)*c>=0):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import math\na, b, c = map(int, input().split())\nif a == b:\n print('YES')\nelif c == 0:\n print('NO')\nelse:\n if (b - a) > 0 and c > 0:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')\n elif (b - a) < 0 and c < 0:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')\n else:\n print('NO')"}, {"source_code": "a, b, c = str(input()).split()\na = int(a)\nb = int(b)\nc = int(c)\n\nif c == 0:\n if a == b:\n print(\"YES\")\n exit()\n else:\n print(\"NO\")\n exit()\n\nif (b-a) % c == 0:\n if b > a and c>0:\n print(\"YES\")\n elif b < a and c<0:\n print(\"YES\")\n elif a == b:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b, c = map(int, input().split())\n\nif c == 0:\n if a == b:\n print(\"YES\")\n else:\n print(\"NO\")\n exit(0)\n\nk = (b - a) / c\n\nif k == int(k) and k >= 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from sys import stdin,stdout\n\nimport bisect\n\nimport math\n\ndef st():\n return list(stdin.readline().strip())\n\ndef inp():\n return int(stdin.readline())\n\ndef li():\n return list(map(int,stdin.readline().split()))\n\ndef mp():\n return map(int,stdin.readline().split())\n\ndef pr(n):\n stdout.write(str(n)+\"\\n\")\n\ndef soe(limit):\n l=[1]*(limit+1)\n l[0]=0\n l[1]=0\n prime=[2]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n \n for i in range(3,limit+1,2):\n if l[i]:\n prime.append(i)\n return prime\n\ndef segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n \ndef gcd(a,b):\n while b:\n a=a%b\n b,a=a,b\n return a\n\ndef power(a,n):\n r=1\n while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n return r\n\n\ndef solve():\n a,b,c=mp()\n if c==0:\n if a!=b:\n print(\"NO\")\n else:\n print(\"YES\")\n return\n x=(b-a+c)/c\n if x==math.floor(x) and x>0 :\n print(\"YES\")\n else:\n print(\"NO\")\n\n \n \n\n\nfor _ in range(1):\n solve()\n \n"}, {"source_code": "a, b, c = list(map(int,input().split()))\n\nif c == 0:\n if b == a:\n print('YES')\n else:\n print('NO')\nelif (b-a)/c == (b-a) // c >= 0:\n print('YES')\nelse:\n print('NO') \n"}, {"source_code": "a,b,c=[int(x) for x in input().split()]\n\nif (c!=0 and (b-a)/c>=0 and (b-a)%c==0) or (c==0 and a==b):\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "def InSequence(a,b, c):\n if c == 0:\n if a == b:\n return \"YES\"\n else:\n return \"NO\"\n elif c > 0:\n k = (b-a) % c \n # print(\"k = \",k)\n if k == 0 and b >= a : \n return \"YES\"\n else:\n return \"NO\"\n else:\n k = (b-a) % c \n # print(\"k = \",k)\n if k == 0 and b <= a : \n return \"YES\"\n else:\n return \"NO\"\n\n\na,b,c = [int(x) for x in input().split() ]\nprint(InSequence(a,b,c) )\n\n"}, {"source_code": "a, b, c = map(int, input().split(' '))\nif (b < a and c > 0) or (b > a and c < 0):\n print('NO')\nelse:\n if c == 0:\n if a == b:\n print('YES')\n else:\n print('NO')\n else:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a,b,c=map(int,raw_input().split())\nd=b-a\nprint ['NO','YES'][d==0 or(d*c>0 and d%c==0)]\n"}, {"source_code": "f,r,d=list(map(int,input().split()))\nif f==r:\n print(\"YES\")\nelif d==0 and f==r:\n print(\"YES\")\nelif d==0 and f!=r:\n print(\"NO\")\nelif (r-f)//d==(r-f)/d and (r-f)/d>0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b,c=map(int,input().split())\nif a==b: print('YES')\nelif c==0: print('NO')\nelif (b-a)//c==(b-a)/c and (b-a)//c>0: print('YES')\nelse: print('NO')"}, {"source_code": "inp=input().split()\na=int(inp[0])\nb=int(inp[1])\nc=int(inp[2])\nif c==0:\n if b!=a:\n print(\"NO\")\n else:\n print(\"YES\")\nelif c>0:\n if b<a or (b-a)%c!=0:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n if b>a or (a-b)%(-c)!=0:\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "import sys\n\nli = raw_input()\nlis = li.split(' ')\na = int(lis[0])\nb = int(lis[1])\nc = int(lis[2])\n\nx = b - a\n\nif x == 0:\n print \"YES\"\nelif c == 0:\n if a != b:\n print \"NO\"\n else:\n print \"YES\"\nelse:\n if x % c == 0:\n xx = x / c\n if xx + 1 > 0:\n print \"YES\"\n else:\n print \"NO\"\n else:\n print \"NO\"\n\nexit\n\n"}, {"source_code": "a, b, c = map(int, input().split())\nif c == 0 and a == b:\n print(\"YES\")\nelif c == 0 and a != b:\n print(\"NO\")\nelif (b >= a and (b - a) % c == 0 and c > 0) or (b <= a and c < 0 and (b - a) % c == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b,c=map(int,input().split());s=0\nif c==0 :\n if a==b :\n print(\"YES\")\n else :\n print(\"NO\")\nelif c<0 :\n if a<b :\n print(\"NO\")\n else :\n if abs(a-b)%c==0 :\n print(\"YES\")\n else :\n print(\"NO\")\nelse :\n if a>b :\n print(\"NO\")\n else :\n if abs(a-b)%c==0 :\n print(\"YES\")\n else :\n print(\"NO\")\n"}, {"source_code": "a,b,c = map(int,input().split())\nif a == b:\n print(\"YES\")\nelif a > b and c < 0 and (a-b)%c == 0:\n print(\"YES\")\nelif a < b and c >0 and (b-a)%c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b, c = map(int, input().split())\nif c < 0 and a < b:\n print(\"NO\")\n exit(0)\nif c > 0 and a > b:\n print(\"NO\")\n exit(0)\nif c == 0 and a == b:\n print(\"YES\")\n exit(0)\nif c == 0 and a != b:\n print(\"NO\")\n exit(0)\n\nif abs(a-b)%abs(c) != 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n "}, {"source_code": "a,b,c=map(int,input().split())\nif a==b:\n print(\"YES\")\nelif (a==b and c==0):\n print(\"YES\")\nelif ((b-a)>=0 and c>0) and (b-a)%c==0:\n print(\"YES\")\nelif ((b-a)<0 and c<0) and (b-a)%c==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# -*- coding: utf-8 -*-\na,b,c=input(\"\").split(\" \")\na=int(a)\nb=int(b)\nc=int(c)\nif c==0:\n\tif a==b:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tif (b-a)%c==0 and (b-a)/c>=0:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n"}, {"source_code": "def main():\n inpt = input().split()\n start = int(inpt[0])\n fav = int(inpt[1])\n diff = int(inpt[2])\n if diff == 0 :\n if start == fav :\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n y = (fav - start) / diff\n isint = False\n\n if y == int(y):\n isint = True\n\n if isint == True:\n if y >= 0:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n\n\n\n\n\n\n\n\nif __name__ == '__main__': main()"}, {"source_code": "a=(list(map(int, input().split())))\nc=a[1]-a[0]\nif c==0 and a[2]==0:\n print('YES')\nelif (a[2]>0 and c>=0) or (a[2]<0 and c<=0) :\n if c<0:\n c=c*-1\n a[2]=a[2]*-1\n d=c%a[2]\n if d == 0:\n print('YES')\n else:\n print('NO')\n\nelse:\n print('NO')"}, {"source_code": "import sys\n\ninput1 = [int(elem) for elem in sys.stdin.readline().strip().split()]\n\nif input1[1] == input1[0]:\n print (\"YES\") \n \nelif input1[1] > input1[0] and input1[2] > 0 and input1[1]%input1[2] == input1[0]%input1[2]:\n print (\"YES\")\n \nelif input1[1] < input1[0] and input1[2] < 0 and input1[1]%input1[2] == input1[0]%input1[2]:\n print (\"YES\")\n\nelse:\n print(\"NO\")\n# 1488583300073\n"}, {"source_code": "x=list(map(int,input().split()))\ny=x[1]-x[0]\nif(y==0):\n print('YES')\nelif(x[2]==0):\n print('NO')\nelse:\n z=y%x[2]\n if(z==0):\n if((y//x[2])>0):\n print('YES')\n elif((y//x[2])>0 and x[2]<0):\n print('YES')\n else:\n print('NO') \n else:\n print('NO')\n"}, {"source_code": "a,b,c = [int(z) for z in input().split()]\nif(c == 0):\n\tif(a == b):\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelif (b-a == 0):\n\tprint('YES')\nelif( (b-a) == c or ((b-a)%c == 0)):\n\tif( (a < b and c > 0 ) or (a > b and c < 0)):\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelse:\n\tprint('NO')\n"}, {"source_code": "a, b, c = map(int, input().split())\nba = b - a\ntry:\n print(('NO', 'YES')[ba % c == 0 and ba // c >= 0])\nexcept:\n print(('YES', 'NO')[b != a])\n"}, {"source_code": "# import sys \n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out1.out\",'w')\na,b,c=map(int,input().split())\nif c==0:\n\tif a==b:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tif (b-a)//c>=0 and (b-a)%c==0 :\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n"}, {"source_code": "a, b, c = map(int, input().split())\nif c==0:\n if a==b:\n print('YES')\n else:\n print('NO')\nelif a==b:\n print('YES')\nelif (c<0 and b-a>0)or (c>0 and b-a<0) or (b-a)%c != 0:\n print('NO')\nelif (b-a)%c == 0 :\n print('YES')\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\ndef solve():\n if a == b:\n return 'YES'\n\n if c == 0:\n return 'NO'\n\n t = (b - a) / c\n if t < 0:\n return 'NO'\n\n return {True: 'YES', False: 'NO'}[t * c == b - a]\n\nprint solve()\n\n"}, {"source_code": "a = []\n\nfor i in input().split():\n\ta.append(int(i))\n\nif a[2] == 0:\n\tif a[0] == a[1]:\n\t\tprint('YES')\n\t\texit()\n\telse:\n\t\tprint('NO')\n\t\texit()\n\nif (a[0] > a[1] and a[2] > 0) or (a[0] < a[1] and a[2] < 0):\n\tprint('NO')\n\texit()\n\nif (a[1] - a[0]) % a[2] == 0:\n\tprint('YES')\n\texit()\n\nprint('NO')"}, {"source_code": "\na, b, c = map(int, input().split(' '))\nif b > a and c > 0:\n if (b-a) % c == 0:\n print(\"YES\")\n else:\n print(\"NO\")\nelif b <= a and c < 0:\n if (a-b) % -c == 0:\n print(\"YES\")\n else:\n print(\"NO\")\nelif b == a:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}], "negative_code": [{"source_code": "a,b,c = map(int,raw_input().split())\nif c ==0:\n if b==a:\n print 'YES'\n else:\n print 'NO'\nelse:\n if (b-a)%c ==0 and (b-a)/c >0 :\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "sequence = list(map(int, input().split()))\na = sequence[0]\nb = sequence[1]\nc = sequence[2]\n\nwhile a < b:\n a += c\n if a == b:\n print(\"YES\")\n break\nif a > b:\n print(\"NO\")"}, {"source_code": "import string\n\n\n\na, b, c=map(int,raw_input().split())\n\nprint a, b, c\nwhile a<b :\n\ta = a + c\n\tprint a\n\nif a == b : print 'YES'\nelse : print 'NO'"}, {"source_code": "inpt=input().split()\na=int(inpt[0])\nb=int(inpt[1])\nc=int(inpt[2])\nres=b-a\n#print (res)\nif c==0:\n if a==b:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n x=res%c\n if x==0:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\nif c == 0 and a == b:\n print 'YES'\nelif c == 0:\n print 'NO'\nelif (b - a) % c == 0 and (b - a) / c > 0:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jan 19 01:42:31 2019\n\n@author: KIIT\n\"\"\"\n\nimport math\nimport os\nimport random\nimport re\nimport sys\nif __name__ == '__main__':\n x = list(map(int, input().rstrip().split()))\n a,b,c=x[0],x[1],x[2]\n \n if(c==0):\n if((b-a)==0):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n k=(b-a)%c\n if(k==0 and (b-a)/c>0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "#########\t\t\t##\t## ## \t #### ##### ## # ## #\t\t##\n\t#\t\t\t # #\t# # # #\t\t #\t #\t#\t# # # # # # #\t # #\n\t#\t\t\t # #\t# ### #\t #\t\t#\t# # # # # # #\t # #\n\t#\t\t\t #####\t#\t#\t#\t # ###\t#\t# # # # # # # #####\n\t#\t\t\t# #\t#\t\t#\t # # #\t#\t# #\t# # #\t # # # # \n######### \t # # \t#\t\t#\t\t##### #\t##### #\t ## #\t ## # #\n\n\"\"\"\n\nPPPPPPP RRRRRRR\t\t OOOO\t VV VV EEEEEEEEEE\nPPPPPPPP RRRRRRRR OOOOOO VV VV\t EE\nPPPPPPPPP RRRRRRRRR OOOOOOOO VV VV\t EE\nPPPPPPPP RRRRRRRR OOOOOOOO VV VV \t EEEEEE\nPPPPPPP RRRRRRR OOOOOOOO VV VV EEEEEEE\nPP \t\t RRRR\t\t\t OOOOOOOO VV VV EEEEEE\nPP\t\t\t RR RR OOOOOOOO VV VV EE\nPP\t\t\t RR RR OOOOOO VV VV EE\nPP\t\t\t RR RR OOOO VVVV EEEEEEEEEE\n\n\"\"\"\n\n\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nimport sys\ninput = sys.stdin.readline\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0, hi = None):\n if hi == None:\n hi = len(a);\n while lo < hi:\n mid = (lo+hi)//2;\n if a[mid] < x:\n lo = mid+1;\n else:\n hi = mid;\n return lo;\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\n\nfrom bisect import bisect_left\ndef check(n, m, k):\n\tprint(\"inside\", (n + (k - 1) * m), k * (k + 1) // 2, (n + (k - 1) * m) // k * k)\n\tif (n + (k - 1) * m) // k * k <= k * (k + 1) // 2:\n\t\treturn True\n\treturn False\n\ndef solve():\n\ta, b, c = map(int,input().split())\n\tif a != b and c == 0:\n\t\tprint(\"NO\")\n\t\treturn\n\telif c == 0 and a == b:\n\t\tprint(\"YES\")\n\t\treturn\n\tprint([\"YES\", \"NO\"][min(abs(b - a) % abs(c), 1)])\n\n\n\nif __name__ == '__main__':\n\tfor _ in range(1):\n\t\tsolve()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "def main():\n x = input().split()\n a = int(x[0])\n b = int(x[1])\n c = int(x[2])\n if c==0 and b == a:\n print(\"YES\")\n elif c!=0:\n if (b - a) / c > 0 and (b - a) / c == int((b - a) / c):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n\n\n\n\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "if __name__ == '__main__':\n\ta,b,c = map(int,raw_input().split())\n\tt = b-a\n\tif c == 0:\n\t\tif a == b:\n\t\t\tprint 'YES'\n\t\telse:\n\t\t\tprint 'NO'\n\telif c < 0:\n\t\tif b > a:\n\t\t\tprint 'NO'\n\t\telse:\n\t\t\tif t % c == 0:\n\t\t\t\tprint 'YES'\n\t\t\telse:\n\t\t\t\tprint 'NO'\n\telif c > 0:\n\t\tif t % c == 0:\n\t\t\tprint 'YES'\n\t\telse:\n\t\t\tprint 'NO'"}, {"source_code": "a, b, c = map(int, input().split())\ntry:\n print(('YES', 'NO')[bool((b - a) % c) or min(a, c) > b > max(a, c)])\nexcept:\n print(('YES', 'NO')[b != a])\n"}, {"source_code": "a,b,c = map(int,input().split())\nif a==b:\n print('YES')\nelif c==0 and a!=b:\n print('NO')\nelif b%abs(c)==a and ((a<b and c>0) or (a>b and c<0)):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a,b,c=map(int,raw_input().split())\nif c==0:\n if(a==b):\n print \"YES\" \n else:\n print \"NO\"\nelif(type((b-a)/c)==int and ((b-a)/c)>0):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "a,b,c=map(int,input().split());s=0\nif c==0 :\n if a==b :\n print(\"YES\")\n else :\n print(\"NO\")\nelif c<0 :\n if abs(a-b)%c==0 and a>b:\n print(\"YES\")\n else :\n print(\"NO\")\nelse :\n if abs(a-b)%c==0 and a<b :\n print(\"YES\")\n else :\n print(\"NO\")\n"}, {"source_code": "def infinite(a,b,c):\n if c==0:\n return(\"YES\")\n if b-a<0:\n return(\"NO\")\n if (b-a)%c==0:\n return(\"YES\")\n else:\n return(\"NO\")\na,b,c = input().strip().split()\nprint(infinite(int(a),int(b),int(c)))"}, {"source_code": "a, b, c = map(int, input().split())\n\nif c == 0:\n\tprint('YES')\nelif (b - a) % c == 0 and (b - a) // c > 0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "a, b, c = list(map(int, input().split()))\n\nif a == b:\n print(\"YES\")\nelif b <= 0 and a < 0 and c < 0 and (a + c) < b:\n print(\"NO\")\nelif b >= 0 and a > 0 and c > 0 and (a + c) > b:\n print(\"NO\")\nelif b < 0 and a > 0 and c > 0:\n print(\"NO\")\nelif b > 0 and a < 0 and c < 0:\n print(\"NO\")\nelif c == 0 and a != b:\n print(\"NO\")\nelse:\n match = (b - a) % c\n if match == 0:\n print(\"YES\")\n else:\n print(\"NO\") \n"}, {"source_code": "def gank(a,b,c):\n d = b - a\n if(d==0):\n return True\n if(c==0):\n return False\n if(c<0):\n d*=-1\n c*=-1\n if(d%c==0):\n return True\n else:\n return False\n\na,b,c = map(int , raw_input().split(' '))\nif(gank(a,b,c)):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def favourite_number(a, b, c):\n if a - b == 0:\n return \"YES\"\n elif c == 0:\n return \"NO\"\n elif (a - b) % c == 0 or (a - b) * c < 0:\n return \"NO\"\n return \"YES\"\n\n\nA, B, C = [int(i) for i in input().split()]\nprint(favourite_number(A, B, C))\n"}, {"source_code": "#-*-coding:utf-8-*-\nimport math\nimport string\nimport sys\nreload(sys)\nsys.setdefaultencoding('utf-8')\n\n\n# s , a = s1\n\n# \uc11c\ub85c\uac04 \uc774\uc6c3\ud55c \uac12 c (si-si-1 = c)\n# b\uac00 \uc774 \uc2dc\ud038\uc2a4\uc5d0 \ud3ec\ud568\n# si = b\n# \n\n\na, b, c=map(int,raw_input().split())\n\nwhile a<b :\n\ta = a + c\n\nif a == b : print \"YES\"\nelse : print \"NO\""}, {"source_code": "a,b,c=map(int,input().split())\nfor i in range(1,10000000000):\n if((b<0 and c<0) or (b>0 and c>0)):\n if((b-a)%(c*i)==0):\n print(\"YES\")\n exit()\n elif((c*i)>(b-a)):\n print(\"NO\")\n exit()\n else:\n print(\"NO\")\n exit()\n\n"}, {"source_code": "a,b,c = map(int , raw_input().split())\nans = \"\"\nif c == 0:\n if a == b: ans = \"YES\"\n else: ans = \"NO\"\nelif c > 0:\n if (b-a)%c == 0 and (b-a) > 0: ans = \"YES\"\n else: ans = \"NO\"\nelse:\n if (a-b)%(-c) == 0 and (a-b) > 0: ans = \"YES\"\n else: ans = \"NO\"\nprint ans"}, {"source_code": "# -*- coding: utf-8 -*-\na,b,c=input(\"\").split(\" \")\na=int(a)\nb=int(b)\nc=int(c)\nif c==0:\n\tif a==b:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tif b in range(a,10**18,c):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n"}, {"source_code": "a, b, c = map(int, input().split(' '))\nif c == 0:\n if a == b:\n print('YES')\n else:\n print('NO')\nelse:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "import math\na, b, c = map(int, input().split())\nif a == b:\n print('YES')\nelif a == 0:\n if b > 0 and c > 0:\n print('NO')\n elif b > 0 and c < 0:\n c = int(math.fabs(c))\n if b % c == 0:\n print('YES')\n else:\n print('NO')\n elif b < 0 and c < 0:\n print('NO')\n elif b < 0 and c > 0:\n b = int(math.fabs(b))\n if b % c == 0:\n print('YES')\n else:\n print('NO')\n else:\n print('NO')\nelif b == 0:\n if int(math.fabs(a)) % int(math.fabs(a)) == 0:\n print('YES')\n else:\n print('NO')\nelif c == 0:\n print('NO')\nelse:\n a = int(math.fabs(a))\n b = int(math.fabs(b))\n c = int(math.fabs(c))\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a, b, c = map( int, input().split() );\n#a -first\n#b -like\n#c -difference\nif a == b:\n print ('YES');\nelif c == 0:\n print ('NO'); \nelif b < a:\n if c < a:\n if (b - a)%c == 0:\n print ('YES');\n else:\n print ('NO');\n else:\n print('NO');\nelse:\n if (b - a)%c == 0:\n print ('YES');\n else:\n print ('NO');\n"}, {"source_code": "from sys import stdin\na,b,c = map(int,stdin.readline().split())\n\n\nif(a != b and c == 0):\n print(\"NO\")\nelif( (a == b ) or (a > b and c < 0) or ( b > a and ((b-a)% c == 0)) ):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b,c=map(int,raw_input().split())\nif c==0:\n print 'YES' if a==b else 'NO'\nelse:\n print 'YES' if (b-a)%c==0 and (b-c)*c>0 else 'NO'\n"}, {"source_code": "a,s,d = map(int,input().split())\nif(d!=0):\n n = ((s-a)/d+1)\n j = n%1\n if(j==0.0):\n if(n>0):\n print(\"YES\")\n if(d==0):\n if(a==s):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "inpt=input().split()\na=int(inpt[0])\nb=int(inpt[1])\nc=int(inpt[2])\nres=b-a\n#print (res)\nif c==0:\n if a==b:\n print(\"YES\")\n else:\n print(\"NO\")\nelif b<a:\n print(\"NO\")\nelse:\n x=res%c\n if x==0:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "read = lambda: map(int, input().split())\na, b, c = read()\nif c == 0 and (b == a): ans = 'YES'\nelif c != 0 and (b - a) % c == 0 and (b - a) // c > 0: ans = 'YES'\nelse: ans = 'NO'\nprint(ans)\n"}, {"source_code": "l = map(int, raw_input().split())\na = l[0]\nb = l[1]\nc = l[2]\n\nif c!=0 and (b-a)!=0 and b>a:\n if (b-a)%c==0:\n print \"YES\"\n else:\n print \"NO\"\nelif c==0 and (b-a)!=0:\n print \"NO\"\nelif a==b:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "from collections import *\na,b,c = list(map(int,input().split()))\nif((c == 0 and a == b) or a%c == b%c):\n\tif (a >= b and c < 0) or (a <= b and c > 0): print(\"YES\")\n\telse: print(\"NO\")\nelse: print(\"NO\")\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\n\n\nif c==0:\n\tif a==b:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelse:\n\tif (b-a)%c:\n\t\tprint \"NO\"\n\telse:\n\t\tprint \"YES\""}, {"source_code": "a, b, c = map(int, input().split())\nif c == 0:\n if a == b:\n print('YES')\n else:\n print('NO')\nelse:\n if (b - a) % c == 0 and (b - 1) / c > 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a, b, c = map(int, input().split())\nif a == b:\n print('YES')\nelif c == 0:\n print('NO')\nelse:\n if c <= 0:\n print('NO')\n elif b >= a:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')\n else:\n if c >= 0:\n print('NO')\n else:\n if (a - b) % c == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "import sys\nx=input().split()\na=int(x[0])\nb=int(x[1])\nc=int(x[2])\nif c==0:\n if a==b:\n print('YES')\nelse:\n p=((b-a)/(c))+1\n if int(p)==float(p) and p>0:\n print('YES')\n sys.exit(0)\nprint('NO')\n\n"}, {"source_code": "d=list(map(int,input().split()))\nif(d[1]<d[0]):\n print(\"NO\")\nelif(d[0]==d[1]):\n print(\"YES\")\nelif(d[2]==0):\n print(\"NO\")\nelse:\n n=(d[1]-d[0])/d[2]+1\n if(n%1==0):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "\na, b, c = [int(x) for x in input(\"\").split(\" \")]\n\nout = \"NO\"\nif c != 0:\n if (b - a) % c == 0:\n out = \"YES\"\nelse:\n if a == b:\n out = \"YES\"\n\nprint(out)\n\n\n"}, {"source_code": "a, b, c = map(int, input().split())\nif a == b:\n print('YES')\nelif c == 0:\n print('NO')\nelse:\n if c <= 0:\n print('NO')\n elif b >= a:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')\n else:\n if c >= 0:\n print('NO')\n else:\n if (a - b) % c == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "string = [int(i) for i in input().split()]\na, b, c = string[0], string[1], string[2]\nif c == 0:\n if a == b:\n print('YES')\n else:\n print('NO')\nelse:\n if ((b - a) / c + 1) % 1.0 == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a,b,c = list(map(int,input().rstrip().split()))\nif c==0:\n if a==b:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if (b-a)%c==0 and b-a>0 and c>0:\n print(\"YES\")\n elif (b-a)%c==0 and b-a<0 and c<0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "a, b, c = map(int, input().split(' '))\nif b < a and c > 0:\n print('NO')\nelse:\n if c == 0:\n if a == b:\n print('YES')\n else:\n print('NO')\n else:\n if (b - a) % c == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a, b, c = map( int, input().split() );\n#a -first\n#b -like\n#c -difference\nif a == b:\n print ('YES');\nelif b < a:\n print ('NO');\nelif c == 0:\n print ('NO');\nelse:\n if (b - a)%c == 0:\n print ('YES');\n else:\n print ('NO');\n"}, {"source_code": "a, b, c = map(int, input().split())\nif c==0:\n if a==b:print(\"YES\")\n else:print(\"NO\")\nelse:\n if b >=a:\n if (a>=0 and b>=0) or (b<0 and a<0) :\n if a%c == b%c:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n if a%c + b%c == c:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")"}, {"source_code": "a, b, c = map(long, raw_input().split())\n\nif b == a: print \"YES\"\nelif c == 0: print \"NO\"\nelif c < 0 and b > a: print \"NO\"\nelif c > 0 and b < a: print \"NO\"\nelse:\n if c == 1 and b > a: print \"YES\"\n elif c == -1 and b < a: print \"YES\"\n elif c > b and c > 0: print \"NO\"\n elif c < b and c < 0: print \"NO\"\n else:\n flag = False\n if b > a: \n temp = b - a\n if temp % c == 0: flag = True\n elif b < a:\n temp = a - b\n if temp % c == 0: flag = True\n\n if flag: print \"YES\"\n else: print \"NO\"\n"}, {"source_code": "a,b,c = [int(z) for z in input().split()]\nif(c == 0):\n\tif(a == b):\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelif((b-a) == 0 or (b-a) == c or ((b-a)%c == 0 and b >= c )):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "def InSequence(a,b, c):\n if c == 0:\n if a == b:\n return \"YES\"\n else:\n return \"NO\"\n elif c > 0:\n k = (b-a) % c \n # print(\"k = \",k)\n if k == 0 and b > a : \n return \"YES\"\n else:\n return \"NO\"\n else:\n k = (b-a) % c \n # print(\"k = \",k)\n if k == 0 and b < a : \n return \"YES\"\n else:\n return \"NO\"\n\n\na,b,c = [int(x) for x in input().split() ]\nprint(InSequence(a,b,c) )\n\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\n\nif (c == 0 and a == b):\n print \"YES\"\nelif (c == 0 and a != b):\n print \"NO\"\nelif ((b - a > 0) and (c != 0 and (b - a) % c == 0)):\n print \"YES\"\nelse:\n print \"NO\"\n\n"}, {"source_code": "a,b,c=map(int,input().split())\nif(c==0 and a==b):\n print('YES')\nelif(c==0 and a!=b):\n print('NO')\nelse:\n while(1):\n a=a+c\n if(b==a):\n print('YES')\n break\n elif(a>b):\n print('NO')\n break\n"}, {"source_code": "\n \ndef main():\n A, B, C = map(int, raw_input().split())\n\n if(C == 0):\n if(A == B):\n print \"YES\"\n else:\n print \"NO\"\n \n elif((A == B) or ((B - A)%C == 0 and (B > A and C > 0) or (B < A and C < 0))):\n print \"YES\"\n\n else:\n print \"NO\"\n \n \n##########################################\n##########################################\n##########################################\nif(__name__ == \"__main__\"):\n main()\n"}, {"source_code": "inpt=input().split()\na=int(inpt[0])\nb=int(inpt[1])\nc=int(inpt[2])\nres=b-a\n#print (res)\nif c==0:\n if a==b:\n print(\"YES\")\n else:\n print(\"NO\")\nelif b<a:\n print(\"NO\")\nelse:\n x=res%c\n if x==0:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "def task_1():\n\tresult = 'YES'\n\ta, b, c = map(lambda x: int(x), input().split(' '))\n\n\tif c == 0 and a == b:\n\t\treturn 'YES'\n\telif c == 0 and a != b:\n\t\treturn 'NO'\n\n\td = float(b - a) / c\n\n\tif d > 0 and d == int(d):\n\t\tresult = 'YES'\n\telse:\n\t\tresult = 'NO'\n\n\treturn result\n\nprint(task_1())"}, {"source_code": "d=list(map(int,input().split()))\nif(d[1]<d[0]):\n print(\"NO\")\nelif(d[0]==d[1]):\n print(\"YES\")\nelif(d[2]==0 and d[0]!=d[1]):\n print(\"NO\")\nelif(d[2]>d[1]):\n print(\"NO\")\nelse:\n n=(d[1]-d[0])/d[2]+1\n if(n%1==0):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "import sys\nstart, value, increment = map(int, sys.stdin.readline().strip().split())\n\nif start == value:\n print (\"YES\")\n exit()\n\nif increment == 0:\n if value == start:\n print (\"YES\")\n else:\n print(\"NO\")\n exit()\n\nif start < 0:\n value = value + abs(start)\nelse:\n value = value - start\nstart = 0\n\nprint(start, value, increment)\n#if start == 0:\n#\n#if value == 0:\n#\n#\n#if value < 0:\n# if increment > 0:\n# if start > 0:\n# print (\"NO\") \n# else:\n# if start < value:\n#\n# else:\n# print (\"NO\")\n# \n#\n# if increment < 0:\n# if start < 0:\n# \n# else:\n#\n#if value > 0:\n#\n#\n#\n#\n# if (start > 0 and increment > 0) or (start < 0 and increment > 0:\n# print (\"NO\")\n# # start is neg and increment is neg\n# \n# \n# print (\"YES\")\n# else:\n# if \n#\n# else:\n# print (\"YES\")\n# exit()\n#\n#if start == 0:\n# if value % increment == 0 and value >= start:\n# print (\"YES\")\n# else:\n# print (\"NO\")\n# exit()\n#\n#\n#\n#value = value - start\n#start = 0\n\nif value % increment == 0 and value >= start:\n print (\"YES\")\nelse:\n print (\"NO\")\n# 1488583250099\n"}, {"source_code": "#-*-coding:utf-8-*-\nimport math\nimport string\nimport sys\nreload(sys)\nsys.setdefaultencoding('utf-8')\n\n\n# s , a = s1\n\n# \uc11c\ub85c\uac04 \uc774\uc6c3\ud55c \uac12 c (si-si-1 = c)\n# b\uac00 \uc774 \uc2dc\ud038\uc2a4\uc5d0 \ud3ec\ud568\n# si = b\n# \n\n\na, b, c=map(int,raw_input().split())\n\nif a == b and c == 0 : print \"YES\"\nelif a <= b and c !=0 : \n\tif (b - a) % c == 0 : print \"YES\"\n\telse : print \"NO\"\nelse : print \"NO\"\n"}, {"source_code": "a, b , c = map(int, input().split())\nflag = 1\nfor i in range(100000):\n if a + c*i == b :\n print(\"YES\")\n flag = 0\n break\n \nif flag == 1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "a,b,c=map(int,input().split())\nif a==b:\n print('YES')\nelse:\n if c==0:\n print('NO')\n else:\n n=((b-1)/c)+1\n if (int(n)==n) and (n>0):\n print('YES')\n else:\n print('NO')"}, {"source_code": "def infinite(a,b,c):\n if c==0:\n return(\"YES\")\n if (b-a)%c==0:\n return(\"YES\")\n else:\n return(\"NO\")\na,b,c = input().strip().split()\nprint(infinite(int(a),int(b),int(c)))"}, {"source_code": "a, b, c = map(int, input().split())\n\nwhile(a < b):\n a = c + a \nif(a == b):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b,c=map(int,input().split());s=0\nif c==0 :\n if a==b :\n print(\"YES\")\n else :\n print(\"NO\")\nelse :\n if abs(a-b)%c==0 and (a>0 and b>0) :\n print(\"YES\")\n if abs(a-b)%c==0 and (a<0 and b<0) :\n print(\"YES\")\n else :\n print(\"NO\")\n"}, {"source_code": "import math\n\n\n\na,b,c=map(int,input().split())\nr=0\nif c==0 and b==a:\n print('YES')\n r=1\n\nif c==0 and b!=a:\n print('NO')\n r=1\nk=0\nif (a<0 and c<0 and b>a) or( a>0 and c>0 and b<0):\n print('NO')\n k=1\nif r==0 and k==0:\n if b-a+c!=0:\n if (b-a+c)%c==0 :\n print('YES')\n else:\n print('NO')\n else:\n print('NO')\n"}, {"source_code": "a, b, c = map(int, input().split())\nans = 0\nif (c == 0):ans = 1\nelif ((b-a) % c == 0 and (b-a) >= 0 and c > 0):ans = 1\nelif ((b-a) % c == 0 and (b-a) <= 0 and c < 0):ans = 1\nprint('YES' if ans else 'NO')\n"}, {"source_code": "def task_1():\n\tresult = 'YES'\n\ta, b, c = map(lambda x: int(x), input().split(' '))\n\n\tif c == 0 and a == b:\n\t\treturn 'YES'\n\telif c == 0 and a != b:\n\t\treturn 'NO'\n\n\tif (b - a) % c == 0 and (c > 0 and a > 0 and b > 0):\n\t\tresult = 'YES'\n\telif (b - a) % c == 0 and (c > 0 and a > 0 and b < 0):\n\t\tresult = 'NO'\n\telif (b - a) % c == 0 and (c > 0 and a < 0 and b > 0):\n\t\tresult = 'YES'\n\telse:\n\t\tresult = 'NO'\n\n\treturn result\n\nprint(task_1())"}, {"source_code": "import sys\n\ninput = list(map(int,sys.stdin.readline().strip().split()))\n\nif input[2] == 0 and input[1] == input[0]:\n print(\"YES\")\nelif input[1] % input[2] == input[0] and input[1] >= input[0]:\n print(\"YES\")\nelse:\n print(\"NO\")\n# 1488579638772\n"}, {"source_code": "a=(list(map(int, input().split())))\nc=a[1]-a[0]\nif c==0 and a[2]==0:\n print('YES')\nelif (a[2]>0 and c>=0) or (a[2]<0 and c<0) :\n if c<0:\n c=c*-1\n a[2]=a[2]*-1\n d=c%a[2]\n print('l')\n if d == 0:\n print('YES')\n else:\n print('NO')\n\nelse:\n print('NO')"}, {"source_code": "from sys import stdin\na,b,c = map(int,stdin.readline().split())\n\n\nif((a != b and c == 0) or (b > a and c < 0) ):\n print(\"NO\")\nelif( (a == b ) or (a > b and c < 0) or ( b > a and ((b-a)% c == 0)) ):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b, c = map(int, input().split())\n\nk = a\nfound = False\nwhile k <= b:\n\tif k == b:\n\t\tprint('YES')\n\t\tfound = True\n\t\tbreak\n\tk += c\n\nif not found:\n\tprint('NO')\n"}, {"source_code": "string = input()\nnumbers = string.split(\" \")\na = int(numbers[0])\nb = int(numbers[1])\nc = int(numbers[2])\nwhile a >= b:\n a += c\nif a == b:\n results = \"YES\"\nelse:\n results = \"NO\"\nprint(results)"}, {"source_code": "line = input()\nlin = list(map(int, line.split()))\nflag = 1\n\ntmp = (lin[1] - lin[0])\nif lin[2] == 0:\n\tif tmp == 0:\n\t\tflag = 0\nelif tmp >=0:\n\tflag = tmp %lin[2]\nif flag == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "a, b , c = map(int, input().split())\nflag = 1\nfor i in range(100000):\n if a + c*i == b :\n print(\"YES\")\n flag = 0\n break\n \nif flag == 1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "a,b,c = map(int, raw_input().split())\nif c!= 0 and (b-a)%c == 0:\n\tprint \"YES\"\nelif c==0 and b-a == 0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "a,b,c = map(int,input().split())\nif a==b:\n print('YES')\nelif b%c==a and ((a<b and c>0) or (a>b and c<0)):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "lis=input().split()\nlis[0]=int(lis[0])\nlis[1]=int(lis[1])\nlis[2]=int(lis[2])\nif(lis[2]==0):\n\tif(lis[0]==lis[1]):\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelif(lis[1]-lis[0]==0):\n\tprint('NO')\nelif(lis[1]-lis[0]<0):\n\td=lis[1]-lis[0]\n\tif(lis[2]<0 and (-d)%-lis[2]==0):\n\t\tprint ('YES')\n\telse:\n\t\tprint ('NO')\nelif((lis[1]-lis[0])%lis[2]==0):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "a,b,c = map(int,raw_input().split())\n\nif(c == 0):\n\tif(a ==b):\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelse:\n\tif((b-a)% c == 0):\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n\n"}, {"source_code": "a, b, c = map(int, input().split(' '))\ni = a\nl = list()\n\nif a == b and c == 0:\n\tprint('YES')\nelif a != b and c == 0:\n\tprint('NO')\nelse:\n\tif b >= 0:\t\t\n\t\twhile i <= b:\n\t\t\tprint(i)\n\t\t\tl.append(i)\n\t\t\ti += c\n\telse:\n\t\twhile i >= b:\n\t\t\tprint(i)\n\t\t\tl.append(i)\n\t\t\ti += c\n\tif b in l:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')"}, {"source_code": "a,b,c = map(int, raw_input().split())\nans = 'NO'\nif c == 0:\n\tif a == b:\n\t\tans = 'YES'\nelse:\n\tif (b-a)%c == 0 and (b-a)/c > 0:\n\t\tans = 'YES'\nprint ans"}, {"source_code": "a, b, c = map(int, input().split())\nif b >= a:\n if a == b:\n print('YES')\n elif c == 0:\n print('NO')\n elif (b - a) % c == 0:\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')"}, {"source_code": "a, b, c = list(map(int, input().split()))\nif (a == b) and (c == 0):\n print('YES')\nelif c == 0:\n print('NO')\nelif (b - a) % c == 0:\n if (c > 0) and (b > a):\n print('YES')\n elif (c < 0) and (b < a):\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')\n"}, {"source_code": "a, b, c= map(int,raw_input().split())\n\nprint \"YES\" if (c==0 and a==b) or (c!=0 and (b-a)%c==0 and (b-a)/c>0) else \"NO\""}, {"source_code": "#n = int(input())\na, b, c = map(int, input().split())\n#s = input()\n#c = list(map(int, input().split()))\nif (c == 0 and a == b) or (((a < b) * (c > 0)) and (b - a) % c == 0):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a,b,c=map(int,raw_input().split())\nprint 'NO' if c and (b-a)%c or not c and a==b else 'YES'\n"}, {"source_code": "a,b,c=map(int,input().split())\nif c!=0:\n r=(b-a)/c\n if r-int(r)==0 and r>0:\n print('YES')\n else:\n print('NO')\nelif c==0and b==a:\n print('YES')\n \n"}, {"source_code": "a,b,c = map(int,input().split())\nif c==0 and a==b:\n print('YES')\nelif c==0 and a!=b:\n print('NO')\nelif b%abs(c)==a and ((a<b and c>0) or (a>b and c<0)):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a,b,c=map(int,input().split())\nif c!=0:\n r=(b-a)/c\n if r-int(r)==0 and r>0:\n print('YES')\n else:\n print('NO')\nelif c==0and b==a:\n print('YES')\nelif c==0and b!=a:\n print('NO')\nelif b==a:\n print('YES')\n \n"}, {"source_code": "s = input().split()\na = int(s[0])\nb = int(s[1])\nc = int(s[2])\n\ndef test(a,b,c):\n\tif (a==b):\n\t\treturn(\"YES\")\n\telif (b<a):\n\t\treturn(\"NO\")\n\telse:\n\t\ta = a + c\n\t\treturn(test(a,b,c))\n\t\t\nprint(test(a,b,c))"}, {"source_code": "#-*-coding:utf-8-*-\nimport math\nimport string\nimport sys\nreload(sys)\nsys.setdefaultencoding('utf-8')\n\n\na, b, c=map(int,raw_input().split())\n\nprint a, b, c\nwhile a<b :\n\ta = a + c\n\tprint a\n\nif a == b : print \"YES\"\nelse : print \"NO\""}, {"source_code": "a, b, c = map(int, input().split())\nif c == 0:\n if a == b:\n print('YES')\n else:\n print('NO')\nelse:\n x = (b - a) / c\n y = (b - a) // c\n if float(y) == x and x > 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a, b, c = map(int, input().split(' '))\ni = a\nl = list()\n\nif a == b and c == 0:\n\tprint('YES')\nelif a != b and c == 0:\n\tprint('NO')\nelse:\n\twhile i < b:\n\t\tl.append(i)\n\t\ti += c\n\n\tif b in l:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')"}, {"source_code": "a,b,c = map(int, raw_input().split())\nif a>b:\n\tprint \"NO\"\nelse:\n\tif c!= 0 and (b-a)%c == 0:\n\t\tprint \"YES\"\n\telif c==0 and b-a == 0:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "a,fav,sec=map(int,input().split())\nif a ==fav:\n print('YES')\nelif (sec==0) or (sec>fav) :\n print('NO')\nelif (fav-a)%sec or ((fav>0)and ((sec<0)and (a<0))) :\n print('NO')\nelse:\n print('YES')"}, {"source_code": "a,b,c = map(int,input().split())\nif a==b:\n print('YES')\nelif c==0 and a!=b:\n print('NO')\nelif b%abs(c)==a and ((a<b and c>0) or (a>b and c<0)):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jan 19 01:42:31 2019\n\n@author: KIIT\n\"\"\"\n\nimport math\nimport os\nimport random\nimport re\nimport sys\nif __name__ == '__main__':\n x = list(map(int, input().rstrip().split()))\n a,b,c=x[0],x[1],x[2]\n \n if(c==0):\n if((b-a)==0):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n k=(b-a)%c\n if(k==0 and (b-a)/c>0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "a, b, c = list(map(int, input().split()))\nif c == 0 and a != b:\n\tprint(\"NO\")\n\texit()\nelif c == 0 and a == b:\n\tprint(\"YES\")\n\texit()\nout = (b-a)/c\nif int(out) == out:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "import sys\nstart, value, increment = map(int, sys.stdin.readline().strip().split())\n\nif increment == 0:\n if value == start:\n print (\"YES\")\n else:\n print(\"NO\")\n exit()\n\nif value % increment == start and value >= start:\n print (\"YES\")\nelse:\n print (\"NO\")\n# 1488580479863\n"}, {"source_code": "x=list(map(int,input().split()))\ny=x[1]-x[0]\nif(y==0):\n print('YES')\nelif(x[2]==0):\n print('NO')\nelif(x[2]>y):\n print('NO')\nelse:\n z=y%x[2]\n if(z==0):\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "a, b, c = map(int,raw_input().split())\n\nprint 'YES' if (c == 0 and a == b) or (c > 0 and b > a and (b - a) % c == 0) or (c < 0 and b < a and (b - a) % c == 0) else 'NO'"}, {"source_code": "a, b, c = map(int,raw_input().split())\n\nprint 'YES' if (c == 0 and a == b) or (c > 0 and b > a and (b - a) % c == 0) or (c < 0 and b < a and (b - a) % c == 0) else 'NO'"}, {"source_code": "a,b,c = [int(z) for z in input().split()]\nif(c == 0):\n\tif(a == b):\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelif (b-a == 0):\n\tprint('YES')\nelif( (b-a) == c or ((b-a)%c == 0 and b >= c )):\n\tif( (a < b and c > 0 ) or (a > b and c < 0)):\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelse:\n\tprint('NO')\n\n"}, {"source_code": "a,b,c=list(map(int,input().split()))\nb=b-a;\nif c==0:\n if b==0:\n print(\"YES\");\nelse:\n b=b/c\n if int(b)==b:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "a, b, c = map(int, input().split())\ntry:\n print(('YES', 'NO')[bool((b - a) % c) or min(a, c) > b > max(a, c)])\nexcept:\n print(('YES', 'NO')[b != a])\n"}], "src_uid": "9edf42c20ddf22a251b84553d7305a7d"} {"source_code": "print(\"0\\n1\\n1\\n0\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n\")\n", "positive_code": [{"source_code": "for k in range(21, 51):\n if (min(k, 25) + k) % (2 + k % 3) > 0:\n print(1)\n else:\n print(0)\n"}, {"source_code": "for i in (0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1):\n print(i)\n"}, {"source_code": "for id in range(21, 51):\n print(((min(id, 25) + id) % (2 + id % 3)) > 0 and 1 or 0)"}, {"source_code": "for id in range(21, 51):\n if ((min(id, 25) + id) % (2 + id % 3)) > 0:\n print('1')\n else:\n print('0')\n"}, {"source_code": "for id in range(21, 51):\n\tprint('01'[((min(id,25)+id)%(2+id%3))>0])"}, {"source_code": "print(\"0\\n1\\n1\\n0\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n\")"}, {"source_code": "for id in range(21,51):\n print(1 if ((min(id,25)+id)%(2+id%3))>0 else 0)\n"}, {"source_code": "for i in range(21,51):\n print(1 if (((min(i,25)+i)%(2+i%3))>0) else 0)"}, {"source_code": "print(\"0\\n1\\n1\\n0\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n\")"}, {"source_code": "print(0)\nprint(1)\nprint(1)\nprint(0)\nprint(1)\nprint(1)\nprint(0)\nprint(1)\nprint(1)\nprint(1)\nprint(1)\nprint(1)\nprint(0)\nprint(1)\nprint(0)\nprint(1)\nprint(1)\nprint(1)\nprint(0)\nprint(1)\nprint(1)\nprint(1)\nprint(1)\nprint(1)\nprint(0)\nprint(1)\nprint(0)\nprint(1)\nprint(1)\nprint(1)\n"}, {"source_code": "print(*[int((min(i, 25) + i) % (2 + i % 3) > 0) for i in range(21, 51)], sep='\\n')\n"}, {"source_code": "for i in range(21,51):\n\tif(((min(i, 25) + i) % (2 + i % 3))>0):\n\t\tprint(1)\n\telse:\n\t\tprint(0)\n\n"}, {"source_code": "for id in range(21,51):\n print(int(((min(id,25)+id)%(2+id%3))>0))"}, {"source_code": "for i in range(21,51):\n if((min(i,25)+i)%(2+i%3)) > 0:\n print('1')\n else:\n print('0')\n"}, {"source_code": "for i in range(21,51):\n if (min(i,25)+i)%(2+i%3)>0:print(1)\n else:print(0)"}, {"source_code": "for i in range(21,51):\n print(int(((min(i,25)+i)%(2+i%3))>0))\n"}, {"source_code": "for id in range(21, 51):\n\tprint('01'[((min(id,25)+id)%(2+id%3))>0])"}, {"source_code": "for i in range(21, 51):\n print(int(((min(i, 25) + i) % (2 + i % 3)) > 0))\n"}, {"source_code": "print(\"\"\"0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\"\"\")"}, {"source_code": "for id in range(21, 51):\n if ((min(id, 25) + id) % (2 + id % 3)) > 0:\n print('1')\n else:\n print('0')"}, {"source_code": "def bool2Bit(b):\n if(b):\n return '1'\n return '0'\n\ndef secretFunction(id):\n return (( min ( id , 25 ) + id ) % ( 2 + id % 3 )) > 0\n\nfor i in range(21,51,1):\n print(bool2Bit(secretFunction(i)))"}, {"source_code": "'''\nimport numpy as np\nimport cv2\nfrom matplotlib import pyplot as plt\n\npath = \"/home/beatrice/code/codeforce/fourierDoodles/\"\n\ni = 1\nfor i in range(1,21,1):\n img = cv2.imread(path + str(i) + \".png\",0)\n f = np.fft.fft2(img)\n fshift = np.fft.fftshift(f)\n magnitude_spectrum = 20*np.log(np.abs(fshift))\n\n plt.subplot(121),plt.imshow(img, cmap = 'gray')\n plt.title('Input Image'), plt.xticks([]), plt.yticks([])\n plt.subplot(122),plt.imshow(magnitude_spectrum, cmap = 'gray')\n plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])\n plt.show()\n'''\n\ndef bool2Bit(b):\n if(b):\n return '1'\n return '0'\n\ndef secretFunction(id):\n return (( min ( id , 25 ) + id ) % ( 2 + id % 3 )) > 0\n\nfor i in range(21,51,1):\n print(bool2Bit(secretFunction(i)))"}, {"source_code": "for i in range(21,51):print(int(((min(i,25)+i)%(2+i%3))>0))"}, {"source_code": "a=989573046\nwhile a:\n print a%2\n a/=2"}, {"source_code": "a = '''((\nmin\n(\ni\n,\n25\n)\n+\ni\n)\n%\n(\n2\n+\ni\n%\n3\n))\n>\n0'''\n\nfor i in range(21,51):\n print int(eval(a.replace('\\n','')))\n"}, {"source_code": "for id in range(21, 51): print(int(((min(id, 25) + id) % (2 + id % 3)) > 0))"}, {"source_code": "for i in range(21,51):print(int(((min(i,25)+i)%(2+i%3))>0))"}, {"source_code": "for i in range(21,51):print(int(((min(i,25)+i)%(2+i%3))>0))"}, {"source_code": "def main():\n for i in range(21, 51):\n print('1' if ((min(i, 25) + i) % (2 + i % 3)) > 0 else '0')\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def li():\n return list(map(int, input().split(\" \")))\nprint(\"0\\n1\\n1\\n0\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n\")\n"}, {"source_code": "print(\"\"\"0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n\"\"\")\n"}, {"source_code": "for i in range(21,51):print(int(((min(i,25)+i)%(2+i%3))>0))"}], "negative_code": [{"source_code": "a = '''((\nmin\n(\ni\n,\n25\n)\n+\ni\n)\n%\n(\n2\n+\ni\n%\n3\n))\n>\n0'''\n\nfor i in range(1,51):\n print int(eval(a.replace('\\n','')))\n"}, {"source_code": "for id in range(1, 51): print(int(((min(id, 25) + id) % (2 + id % 3)) > 0))"}, {"source_code": "mask = [1, 0, 0, 1, 1, 0]\n\nfor i in range(20, 50):\n print(mask[i%6])"}, {"source_code": "def main():\n for i in range(21, 51):\n print(((min(i, 25) + i) % (2 + i % 3)) > 0)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def li():\n return list(map(int, input().split(\" \")))\nprint((\"0\\n1\\n1\\n0\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n\"*5)[:30])\n"}, {"source_code": "print(\"\"\"0\n1\n1\n0\n1\n0\n0\n1\n1\n0\n1\n0\n0\n1\n1\n0\n1\n0\n0\n1\n1\n0\n1\n0\n0\n1\n1\n0\n1\n0\n\"\"\")\n"}, {"source_code": "print(1)\n"}, {"source_code": "id = int(input())\nprint(((min(id, 25) + id) % (2 + id % 3)) > 0 and 1 or 0)"}, {"source_code": "for id in range(21, 51):\n if ((min(id, 25) + id) % (2 + id % 3)) > 0:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "print(\"0\\n1\\n1\\n0\\n1\\n0\\n0\\n1\\n1\\n0\\n1\\n0\\n0\\n1\\n1\\n0\\n1\\n0\\n0\\n1\\n1\\n0\\n1\\n0\\n0\\n1\\n1\\n0\\n1\")\n"}, {"source_code": "for i in range(21, 51):\n print(((min(i, 25) + i) % (2 + i % 3)) > 0)\n"}, {"source_code": "out = [0,\n1,\n1,\n0,\n1,\n0,\n0,\n1,\n1,\n0,\n1,\n0,\n0,\n1,\n1,\n0,\n1,\n0,\n0,\n1,\n1,\n0,\n1,\n0,\n0,\n1,\n1,\n0,\n1,\n0]\nfor i in out:\n print(i)"}, {"source_code": "out = [1,\n 0,\n 0,\n 1,\n 1,\n 0]\nfor i in range(21,51):\n print(out[i%len(out)])\n\n"}, {"source_code": "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n"}], "src_uid": "4bda04e64ff661336a93464563f1b550"} {"source_code": "import sys\n\nimport itertools\n\nfrom collections import defaultdict\n\n\nfactorials = [1] * 19\n\nfor i in range(1, 19):\n factorials[i] = i * factorials[i - 1]\n\n\ndef cumsum(l):\n n = len(l)\n for i in range(1, n):\n l[i] += l[i-1]\n\n\ndef enum(l):\n\n global K, S\n\n options = itertools.product(*([(0, 1, 2)] * len(l)))\n\n d = defaultdict(lambda: [0] * (25 + 1))\n\n for opts in options:\n\n s = 0\n marks = 0\n for i, opt in enumerate(opts):\n\n if s > S:\n break\n\n if opt == 1:\n s += l[i]\n elif opt == 2:\n if l[i] <= 18:\n s += factorials[l[i]]\n marks += 1\n else:\n s = S + 1\n\n if s <= S:\n d[s][marks] += 1\n\n return d\n\n\n[n, K, S] = map(int, sys.stdin.next().split(' '))\nl = sorted(map(int, sys.stdin.next().split(' ')))\n\np1 = enum(l[:(len(l) / 2)][::-1])\np2 = enum(l[(len(l) / 2):][::-1])\n\nvariants = 0\nfor s in p1:\n if S - s in p2:\n m1 = p1[s]\n m2 = p2[S - s]\n cumsum(m2)\n for (k1, c1) in enumerate(m1[:(K + 1)]):\n c2 = m2[(K - k1)]\n variants += c1 * c2\n\nprint(variants)\n", "positive_code": [{"source_code": "import sys\n\nimport itertools\n\nfrom collections import defaultdict\n\n\nfactorials = [1] * 19\n\nfor i in range(1, 19):\n factorials[i] = i * factorials[i - 1]\n\n\ndef cumsum(l):\n n = len(l)\n for i in range(1, n):\n l[i] += l[i-1]\n\n\ndef enum(l):\n\n global K, S\n\n options = itertools.product(*([(0, 1, 2)] * len(l)))\n\n d = defaultdict(lambda: [0] * (25 + 1))\n\n for opts in options:\n\n s = 0\n marks = 0\n for i, opt in enumerate(opts):\n\n if s > S:\n break\n\n if opt == 1:\n s += l[i]\n elif opt == 2:\n if l[i] <= 18:\n s += factorials[l[i]]\n marks += 1\n else:\n s = S + 1\n\n if s <= S:\n d[s][marks] += 1\n\n return d\n\n\n[n, K, S] = map(int, sys.stdin.next().split(' '))\nl = sorted(map(int, sys.stdin.next().split(' ')))\n\np1 = enum(l[:(len(l) / 2)][::-1])\np2 = enum(l[(len(l) / 2):][::-1])\n\nvariants = 0\nfor s in p1:\n if S - s in p2:\n m1 = p1[s]\n m2 = p2[S - s]\n for (k1, c1) in enumerate(m1[:(K + 1)]):\n for (k2, c2) in enumerate(m2[:(K + 1 - k1)]):\n if k1 + k2 <= K:\n variants += c1 * c2\n\nprint(variants)\n"}, {"source_code": "fact = [ 1 ]\nfor i in range( 1, 20, 1 ):\n fact.append( fact[ i - 1 ] * i )\n\nfrom collections import defaultdict\n\nN, K, S = map( int, input().split() )\nA = list( map( int, input().split() ) )\n\nldp = [ [ defaultdict( int ) for i in range( K + 1 ) ] for j in range( 2 ) ]\nldp[ 0 ][ 0 ][ 0 ] = 1\nfor i in range( N // 2 ):\n for j in range( K + 1 ):\n ldp[ ~ i & 1 ][ j ].clear()\n for j in range( K + 1 ):\n for key in ldp[ i & 1 ][ j ]:\n ldp[ ~ i & 1 ][ j ][ key ] += ldp[ i & 1 ][ j ][ key ] # toranai\n ldp[ ~ i & 1 ][ j ][ key + A[ i ] ] += ldp[ i & 1 ][ j ][ key ] # toru\n if j + 1 <= K and A[ i ] <= 18:\n ldp[ ~ i & 1 ][ j + 1 ][ key + fact[ A[ i ] ] ] += ldp[ i & 1 ][ j ][ key ] # kaijyou totte toru\n\nrdp = [ [ defaultdict( int ) for i in range( K + 1 ) ] for j in range( 2 ) ]\nrdp[ 0 ][ 0 ][ 0 ] = 1\nfor i in range( N - N // 2 ):\n for j in range( K + 1 ):\n rdp[ ~ i & 1 ][ j ].clear()\n for j in range( K + 1 ):\n for key in rdp[ i & 1 ][ j ]:\n rdp[ ~ i & 1 ][ j ][ key ] += rdp[ i & 1 ][ j ][ key ]\n rdp[ ~ i & 1 ][ j ][ key + A[ N // 2 + i ] ] += rdp[ i & 1 ][ j ][ key ]\n if j + 1 <= K and A[ N // 2 + i ] <= 18:\n rdp[ ~ i & 1 ][ j + 1 ][ key + fact[ A[ N // 2 + i ] ] ] += rdp[ i & 1 ][ j ][ key ]\n\nans = 0\nfor i in range( K + 1 ):\n for key in ldp[ N // 2 & 1 ][ i ]:\n for j in range( 0, K - i + 1, 1 ):\n ans += ldp[ N // 2 & 1 ][ i ][ key ] * rdp[ N - N // 2 & 1 ][ j ][ S - key ]\n\nprint( ans )\n"}, {"source_code": "from math import factorial\nfrom collections import defaultdict\ndef main():\n n, k, s = map(int, raw_input().split())\n a = map(int, raw_input().split())\n def f(b):\n res = [defaultdict(int) for _ in xrange(k + 1)]\n res[k][0] = 1\n for x in b:\n nr = [defaultdict(int) for _ in xrange(k + 1)]\n for j in xrange(k + 1):\n for y, t in res[j].viewitems():\n if j and x <= 18 and factorial(x) + y <= s:\n nr[j-1][factorial(x) + y] += t\n if x + y <= s:\n nr[j][x + y] += t\n nr[j][y] += t\n res = nr\n return res\n def g(b):\n res = [defaultdict(int) for _ in xrange(k + 1)]\n res[k][s] = 1\n for x in b:\n nr = [defaultdict(int) for _ in xrange(k + 1)]\n for j in xrange(k + 1):\n for y, t in res[j].viewitems():\n if j and x <= 18 and y - factorial(x) >= 0:\n nr[j-1][y - factorial(x)] += t\n if y - x >= 0:\n nr[j][y - x] += t\n nr[j][y] += t\n res = nr\n return res\n dl = f(a[:n/2])\n dr = g(a[n/2:])\n ans = 0\n for i, d in enumerate(dl):\n for x, t in d.viewitems():\n for j in xrange(k - i, k + 1):\n ans += t * dr[j][x]\n print ans\nmain()\n"}, {"source_code": "from math import factorial\nfac = factorial\n\ndef dfs(lst):\n sums = [{} for i in xrange(k+1)]\n sums[0][0]=1\n while len(lst)>0:\n cur = lst.pop(0)\n temp = [item.copy() for item in sums]\n for i in xrange(k+1):\n for j in temp[i]:\n if j + cur <=s:\n if j + cur not in sums[i]:\n sums[i][j + cur] = temp[i][j]\n else:\n sums[i][j + cur] += temp[i][j]\n if cur<19 and i<k and j+fac(cur)<=s:\n if j+fac(cur) not in sums[i+1]:\n sums[i+1][j+fac(cur)] = temp[i][j]\n else:\n sums[i+1][j+fac(cur)] += temp[i][j]\n return sums\n\n\nn, k, s = map(int, raw_input().split())\na = [int(item) for item in raw_input().split()]\na.sort()\n\nfirst = dfs(a[:n/2])\nsecond = dfs(a[n/2:])\n\ncount = 0\nfor i in xrange(k+1):\n for sum1 in first[i]:\n for kk in xrange(k-i+1):\n if s-sum1 in second[kk]:\n count += first[i][sum1]*second[kk][s-sum1]\nprint count"}, {"source_code": "from sys import stdin, stdout\nimport math\nfrom collections import defaultdict\n\ndef Comb(nn,rr):\n f = math.factorial\n return f(nn) / f(rr) / f(nn-rr)\n\nn,k,S = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\naset = set(a)\nalist = list(aset)\nalist.sort()\n\nplist = []\nfor i in alist:\n\tplist.append((i,a.count(i)))\n\noplist = []\nfor x,c in plist:\n\ttlist = []\n\tif x > 18:\n\t\tfor i in xrange(c+1):\n\t\t\ttlist.append((i*x,0,Comb(c,i))) # (amount added, stickers used, multiplier)\n\telse:\n\t\txfact = math.factorial(x)\n\t\tfor nf in xrange(c+1):\n\t\t\tfor i in xrange(nf,c+1):\n\t\t\t\ttlist.append((nf*xfact+(i-nf)*x, nf, Comb(c,i)*Comb(i,nf)))\n\toplist.append(tlist)\n\n\ndef rec(mult,d,l,i,f,nn,s=0):\n\tif i < nn:\n\t\tfor add, nf, mm in oplist[i]:\n\t\t\tx = s + add\n\t\t\tff = f + nf\n\t\t\tif x <= S and ff <= k:\n\t\t\t\tif add > 0:\n\t\t\t\t\tl.add(x)\n\t\t\t\t\td[ff][x] += mult*mm\n\t\t\t\trec(mult*mm, d, l, i+1, ff, nn, x)\n\t\t\t\t\n\t\t\t\t\nn = len(alist)\n\n\nhalflist1 = []\nhalflist2 = []\noplist.reverse()\nhl1 = 1\nhl2 = 1\nfor i in xrange(n):\n\tif hl1 <= hl2:\n\t\thl1 *= len(oplist[i])\n\t\thalflist1.append(oplist[i])\n\telse:\n\t\thl2 *= len(oplist[i])\n\t\thalflist2.append(oplist[i])\n\noplist = halflist1 + halflist2\n\n\t\t\t\t\ndl1 = [defaultdict(int) for i in xrange(k+1)]\ndl1[0][0] = 1\nnn = n/2\ns = set()\nrec(1,dl1,s,0,0,nn)\nl1 = list(s)\nl1.append(0)\ndl2 = [defaultdict(int) for i in xrange(k+1)]\ndl2[0][0] = 1\ns = s = set()\nrec(1,dl2,s,nn,0,n)\nl2 = list(s)\nl2.append(0)\n\ncount = 0\nl1.sort()\nl2.sort(reverse=True)\ni = 0\nj = 0\n\nwhile i < len(l1):\n\twhile l2[j] > S - l1[i]:\n\t\tj += 1\n\tif l1[i] + l2[j] == S:\n\t\tfor m in xrange(k+1):\n\t\t\tfor r in xrange(m+1):\n\t\t\t\tcount += dl1[r][l1[i]] * dl2[m-r][l2[j]]\n\ti += 1\n\nprint count"}, {"source_code": "from sys import stdin, stdout\nimport math\nfrom collections import defaultdict\n\ndef Comb(nn,rr):\n f = math.factorial\n return f(nn) / f(rr) / f(nn-rr)\n\n\nn,k,S = [int(x) for x in stdin.readline().split()]\na = [int(x) for x in stdin.readline().split()]\n\naset = set(a)\nalist = list(aset)\nalist.sort()\n\nplist = []\nfor i in alist:\n\tplist.append((i,a.count(i)))\n\noplist = []\nfor x,c in plist:\n\ttlist = []\n\tif x > 18:\n\t\tfor i in xrange(c+1):\n\t\t\ttlist.append((i*x,0,Comb(c,i))) # (amount added, stickers used, multiplier)\n\telse:\n\t\txfact = math.factorial(x)\n\t\tfor nf in xrange(c+1):\n\t\t\tfor i in xrange(nf,c+1):\n\t\t\t\ttlist.append((nf*xfact+(i-nf)*x, nf, Comb(c,i)*Comb(i,nf)))\n\toplist.append(tlist)\n\n'''\nprint plist\nfor tlist in oplist:\n\tprint tlist\n\t\nb = list(a)\nc = [False for x in a]\nfor i in xrange(len(b)):\n\tif b[i] < 19:\n\t\tb[i] = math.factorial(b[i])\n\t\tc[i] = True\n'''\n\ndef rec(mult,d,l,i,f,nn,s=0):\n\tif i < nn:\n\t\tfor add, nf, mm in oplist[i]:\n\t\t\tx = s + add\n\t\t\tff = f + nf\n\t\t\tif x <= S and ff <= k:\n\t\t\t\tif add > 0:\n\t\t\t\t\tl.add(x)\n\t\t\t\t\td[ff][x] += mult*mm\n\t\t\t\trec(mult*mm, d, l, i+1, ff, nn, x)\n\t\t\t\t\n'''\ndef rec(d,l,i,f,nn,s=0):\n\tif i < nn:\n\t\trec(d,l,i+1,f,nn,s)\n\t\tx = s+a[i]\n\t\tif x <= S:\n\t\t\trec(d,l,i+1,f,nn,x)\n\t\t\tl.add(x)\n\t\t\td[f][x] += 1\n\t\tif c[i] and f < k:\n\t\t\tx = s+b[i]\n\t\t\tif x <= S:\n\t\t\t\trec(d,l,i+1,f+1,nn,x)\n\t\t\t\tl.add(x)\n\t\t\t\td[f+1][x] += 1\n'''\t\n\t\t\t\t\nn = len(alist)\n\t\t\t\t\ndl1 = [defaultdict(int) for i in xrange(k+1)]\ndl1[0][0] = 1\nnn = n/2\ns = set()\nrec(1,dl1,s,0,0,nn)\nl1 = list(s)\nl1.append(0)\ndl2 = [defaultdict(int) for i in xrange(k+1)]\ndl2[0][0] = 1\ns = s = set()\nrec(1,dl2,s,nn,0,n)\nl2 = list(s)\nl2.append(0)\n\ncount = 0\nl1.sort()\nl2.sort(reverse=True)\ni = 0\nj = 0\n\nwhile i < len(l1):\n\twhile l2[j] > S - l1[i]:\n\t\tj += 1\n\tif l1[i] + l2[j] == S:\n\t\tfor m in xrange(k+1):\n\t\t\tfor r in xrange(m+1):\n\t\t\t\tcount += dl1[r][l1[i]] * dl2[m-r][l2[j]]\n\ti += 1\n\nprint count"}], "negative_code": [{"source_code": "from math import factorial\nfrom collections import defaultdict\ndef main():\n n, k, s = map(int, raw_input().split())\n a = map(int, raw_input().split())\n def f(b):\n res = defaultdict(int)\n res[0] = 1\n for x in b:\n nr = defaultdict(int)\n for y, t in res.viewitems():\n if x <= 18:\n nr[factorial(x) + y] += t\n nr[x + y] += t\n nr[y] += t\n res = nr\n return res\n def g(b):\n res = defaultdict(int)\n res[s] = 1\n for x in b:\n nr = defaultdict(int)\n for y, t in res.viewitems():\n if x <= 18:\n nr[y - factorial(x)] += t\n nr[y - x] += t\n nr[y] += t\n res = nr\n return res\n dl = f(a[:n/2])\n dr = g(a[n/2:])\n b = set(dl.keys() + dr.keys())\n ans = 0\n for x in b:\n ans += dl[x] * dr[x]\n print ans\nmain()\n"}, {"source_code": "from math import factorial\nfrom collections import defaultdict\ndef main():\n n, k, s = map(int, raw_input().split())\n a = map(int, raw_input().split())\n def f(b):\n res = [defaultdict(int) for _ in xrange(k + 1)]\n res[k][0] = 1\n for x in b:\n nr = [defaultdict(int) for _ in xrange(k + 1)]\n for j in xrange(k + 1):\n for y, t in res[j].viewitems():\n if j and x <= 18:\n nr[j-1][factorial(x) + y] += t\n nr[j][x + y] += t\n nr[j][y] += t\n res = nr\n return res\n def g(b):\n res = [defaultdict(int) for _ in xrange(k + 1)]\n res[k][s] = 1\n for x in b:\n nr = [defaultdict(int) for _ in xrange(k + 1)]\n for j in xrange(k + 1):\n for y, t in res[j].viewitems():\n if j and x <= 18:\n nr[j-1][y - factorial(x)] += t\n nr[j][y - x] += t\n nr[j][y] += t\n res = nr\n return res\n dl = f(a[:n/2])\n dr = g(a[n/2:])\n b = set()\n for i in xrange(k + 1):\n b.update(dl[i].keys())\n b.update(dr[i].keys())\n ans = 0\n for x in b:\n for i in xrange(k + 1):\n for j in xrange(k + 1):\n if i + j <= k:\n ans += dl[i][x] * dr[j][x]\n print ans\nmain()\n"}, {"source_code": "import sys\n\nimport itertools\n\nfrom collections import defaultdict, Counter\n\n\nfactorials = [1] * 19\n\nfor i in range(1, 19):\n factorials[i] = i * factorials[i - 1]\n\n\ndef enum(l):\n\n global S\n\n options = itertools.product(*([(0, 1, 2)] * len(l)))\n\n d = defaultdict(Counter)\n\n for opts in options:\n\n s = 0\n marks = 0\n for i, opt in enumerate(opts):\n\n if s > S:\n break\n\n if opt == 1:\n s += l[i]\n elif opt == 2:\n if l[i] <= 18:\n s += factorials[l[i]]\n marks += 1\n else:\n continue\n\n if s <= S:\n d[s].update([marks])\n\n return d\n\n\n[n, K, S] = map(int, sys.stdin.next().split(' '))\nl = sorted(map(int, sys.stdin.next().split(' ')))\n\np1 = enum(l[:(len(l) / 2)][::-1])\np2 = enum(l[(len(l) / 2):][::-1])\n\nvariants = 0\nfor s, c in p1.items():\n if S - s in p2:\n m1 = p1[s]\n m2 = p2[S - s]\n for (k1, c1), (k2, c2) in zip(m1.items(), m2.items()):\n if k1 + k2 <= K:\n variants += c1 * c2\n\nprint(variants)\n"}, {"source_code": "import sys\n\nimport itertools\n\nfrom collections import defaultdict, Counter\n\n\nfactorials = [1] * 19\n\nfor i in range(1, 19):\n factorials[i] = i * factorials[i - 1]\n\n\ndef enum(l):\n\n global S\n\n options = itertools.product(*([(0, 1, 2)] * len(l)))\n\n d = defaultdict(Counter)\n\n for opts in options:\n\n s = 0\n marks = 0\n for i, opt in enumerate(opts):\n\n if s > S:\n break\n\n if opt == 1:\n s += l[i]\n elif opt == 2:\n if l[i] <= 18:\n s += factorials[l[i]]\n marks += 1\n else:\n continue\n\n if s <= S:\n d[s].update([marks])\n\n return d\n\n\n[n, K, S] = map(int, sys.stdin.next().split(' '))\nl = sorted(map(int, sys.stdin.next().split(' ')))\n\np1 = enum(l[:(len(l) / 2)][::-1])\np2 = enum(l[(len(l) / 2):][::-1])\n\nvariants = 0\nfor s, c in p1.items():\n if S - s in p2:\n m1 = p1[s]\n m2 = p2[S - s]\n for (k1, c1) in m1.items():\n for (k2, c2) in m2.items():\n if k1 + k2 <= K:\n variants += c1 * c2\n\nprint(variants)\n"}, {"source_code": "from collections import defaultdict\n\nN, K, S = map( int, input().split() )\nA = list( map( int, input().split() ) )\n\nfact = [ 1 ]\nfor i in range( 1, 20, 1 ):\n fact.append( fact[ i - 1 ] * i )\n\nldp = [ [ defaultdict( int ) for i in range( 1 << N // 2 ) ] for j in range( K + 1 ) ]\nldp[ 0 ][ 0 ][ 0 ] = 1\nfor i in range( K + 1 ):\n for s in range( 1 << N // 2 ):\n for j in range( N // 2 ):\n if ~s >> j & 1:\n for key in ldp[ i ][ s ]:\n ldp[ i ][ s | 1 << j ][ key + A[ j ] ] += ldp[ i ][ s ][ key ]\n if i + 1 <= K and A[ j ] <= 18:\n ldp[ i + 1 ][ s | 1 << j ][ key + fact[ A[ j ] ] ] += ldp[ i ][ s ][ key ]\n\nlbag = [ defaultdict( int ) for i in range( K + 1 ) ]\nfor i in range( K + 1 ):\n for j in range( 1 << N // 2 ):\n for key in ldp[ i ][ j ]:\n lbag[ i ][ key ] += ldp[ i ][ j ][ key ]\n\nrdp = [ [ defaultdict( int ) for i in range( 1 << N - N // 2 ) ] for j in range( K + 1 ) ]\nrdp[ 0 ][ 0 ][ 0 ] = 1\nfor i in range( K + 1 ):\n for s in range( 1 << N - N // 2 ):\n for j in range( N - N // 2 ):\n if ~s >> j & 1:\n for key in rdp[ i ][ s ]:\n rdp[ i ][ s | 1 << j ][ key + A[ N // 2 + j ] ] += rdp[ i ][ s ][ key ]\n if i + 1 <= K and A[ N // 2 + j ] <= 18:\n rdp[ i + 1 ][ s | 1 << j ][ key + fact[ A[ N // 2 + j ] ] ] += rdp[ i ][ s ][ key ]\n\nans = 0\nfor i in range( K + 1 ):\n for s in range( 1 << N - N // 2 ):\n for key in rdp[ i ][ s ]:\n for j in range( 0, K - i + 1, 1 ):\n ans += lbag[ j ][ S - key ]\n\nprint( ans )\n"}], "src_uid": "2821a11066dffc7e8f6a60a8751cea37"} {"source_code": "def DFS(x):\n for i in range(x):\n if(Seen[i][x]):\n continue\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\n Rem[i]-=C[x]\n Parent[x]=i\n Children[i].append(x)\n return True\n for i in range(x):\n if(Seen[i][x]):\n continue\n Y=[]\n for j in range(len(Children[i])):\n child=Children[i][j]\n Parent[child]=-1\n Rem[i]+=C[child]\n Seen[i][child]=True\n Seen[child][i]=True\n if(DFS(child)):\n Seen[i][child]=False\n Seen[child][i]=False\n continue\n Seen[i][child]=False\n Seen[child][i]=False\n Parent[child]=i\n Rem[i]-=C[child]\n Y.append(child)\n Children[i]=list(Y)\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\n Rem[i]-=C[x]\n Children[i].append(x)\n Parent[x]=i\n return True\n return False\n \n \n\n\n\n\nn=int(input())\n\nC=list(map(int,input().split()))\nRem=[-1]*n\nParent=[-1]*n\nChildren=[]\nSeen=[]\nfor i in range(n):\n Seen.append([False]*n)\nC.sort(reverse=True)\n\nif(C[0]!=n or C.count(2)>0):\n print(\"NO\")\n\nelse:\n for i in range(n):\n Rem[i]=C[i]-1\n Children.append([])\n Parent[0]=0\n Ans=\"YES\"\n for i in range(1,n):\n if(DFS(i)==False):\n Ans=\"NO\"\n break\n for i in range(n):\n if(Rem[i]!=0 and C[i]!=1):\n Ans=\"NO\"\n break\n print(Ans)\n \n", "positive_code": [{"source_code": "def DFS(x):\n\n for i in range(x):\n\n if(Seen[i][x]):\n\n continue\n\n if(Rem[i]>=C[x]):\n\n if(Rem[i]==C[x] and len(Children[i])==0):\n\n continue\n\n Rem[i]-=C[x]\n\n Parent[x]=i\n\n Children[i].append(x)\n\n return True\n\n for i in range(x):\n\n if(Seen[i][x]):\n\n continue\n\n Y=[]\n\n for j in range(len(Children[i])):\n\n \n\n child=Children[i][j]\n\n if(Seen[i][child]):\n\n continue\n\n Parent[child]=-1\n\n Rem[i]+=C[child]\n\n Seen[i][child]=True\n\n Seen[child][i]=True\n\n if(DFS(child)):\n\n Seen[i][child]=False\n\n Seen[child][i]=False\n\n continue\n\n Seen[i][child]=False\n\n Seen[child][i]=False\n\n Parent[child]=i\n\n Rem[i]-=C[child]\n\n Y.append(child)\n\n Children[i]=list(Y)\n\n if(Rem[i]>=C[x]):\n\n if(Rem[i]==C[x] and len(Children[i])==0):\n\n continue\n\n Rem[i]-=C[x]\n\n Children[i].append(x)\n\n Parent[x]=i\n\n return True\n\n return False\n\n \n\n \n\n\n\n\n\n\n\n\n\nn=int(input())\n\n\n\nC=list(map(int,input().split()))\n\nRem=[-1]*n\n\nParent=[-1]*n\n\nChildren=[]\n\nSeen=[]\n\nfor i in range(n):\n\n Seen.append([False]*n)\n\nC.sort(reverse=True)\n\n\n\nif(C[0]!=n or C.count(2)>0):\n\n print(\"NO\")\n\n\n\nelse:\n\n for i in range(n):\n\n Rem[i]=C[i]-1\n\n Children.append([])\n\n Parent[0]=0\n\n Ans=\"YES\"\n\n for i in range(1,n):\n\n if(DFS(i)==False):\n\n Ans=\"NO\"\n\n break\n\n for i in range(n):\n\n if(Rem[i]!=0 and C[i]!=1):\n\n Ans=\"NO\"\n\n break\n\n print(Ans)\n\n \n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "#!/usr/bin/python\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\n\nn = Ni()[0]\nc = Ni()\n\navail = [c.count(i) for i in range(n+1)]\n\ndef backtrack(stack, sumleft):\n #print stack, avail, sumleft\n if len(stack) == 1 and sumleft == 0:\n print \"YES\"\n sys.exit(0)\n\n # try to shift a 1\n if avail[1] > 0:\n avail[1] -= 1\n backtrack(stack + [1], sumleft - 1)\n avail[1] += 1\n\n # reduce if possible\n if len(stack) < 2:\n return\n\n s = 1 + stack[-1]\n for i in range(2, len(stack) + 1):\n s += stack[-i]\n if s >= n + 1:\n break\n\n if avail[s] > 0:\n avail[s] -= 1\n backtrack(stack[:-i] + [s], sumleft - s)\n avail[s] += 1\n \n\nbacktrack([], sum(c))\nprint \"NO\"\n"}, {"source_code": "#!/usr/bin/python\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\n\nn = Ni()[0]\nc = Ni()\nc = sorted(c)\n\nF = [0] * (n+1)\nfor _c in c:\n F[_c] += 1\n\n#print n, c, F\nanswer = \"NO\"\n\ndef backtrack(stack, avail, sumleft):\n #print stack, avail, sumleft\n if len(stack) == 1 and sumleft == 0:\n print \"YES\"\n sys.exit(0)\n\n # shift\n if avail[1] > 0:\n avail[1] -= 1\n #print \"shift\", i\n backtrack(stack + [1], avail, sumleft - 1)\n avail[1] += 1\n\n # reduce\n if len(stack) < 2:\n return\n\n s = 1 + stack[-1]\n for i in range(2, len(stack) + 1):\n s += stack[-i]\n if s >= n + 1:\n break\n\n if avail[s] > 0:\n avail[s] -= 1\n #print \"reduce\", s\n backtrack(stack[:-i] + [s], avail, sumleft - s)\n avail[s] += 1\n \n\nbacktrack([], F, sum(c))\nprint \"NO\"\n"}, {"source_code": "#!/usr/bin/python\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\n\nn = Ni()[0]\nc = Ni()\n\nfreq = [c.count(i) for i in range(n+1)]\n\nanswer = \"NO\"\n\ndef backtrack(stack, avail, sumleft):\n #print stack, avail, sumleft\n if len(stack) == 1 and sumleft == 0:\n print \"YES\"\n sys.exit(0)\n\n # try to shift a 1\n if avail[1] > 0:\n avail[1] -= 1\n backtrack(stack + [1], avail, sumleft - 1)\n avail[1] += 1\n\n # reduce if possible\n if len(stack) < 2:\n return\n\n s = 1 + stack[-1]\n for i in range(2, len(stack) + 1):\n s += stack[-i]\n if s >= n + 1:\n break\n\n if avail[s] > 0:\n avail[s] -= 1\n backtrack(stack[:-i] + [s], avail, sumleft - s)\n avail[s] += 1\n \n\nbacktrack([], freq, sum(c))\nprint \"NO\"\n"}, {"source_code": "def DFS(x):\n for i in range(x):\n if(Seen[i][x]):\n continue\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\n Rem[i]-=C[x]\n Parent[x]=i\n Children[i].append(x)\n return True\n for i in range(x):\n if(Seen[i][x]):\n continue\n Y=[]\n for j in range(len(Children[i])):\n \n child=Children[i][j]\n if(Seen[i][child]):\n continue\n Parent[child]=-1\n Rem[i]+=C[child]\n Seen[i][child]=True\n Seen[child][i]=True\n if(DFS(child)):\n Seen[i][child]=False\n Seen[child][i]=False\n continue\n Seen[i][child]=False\n Seen[child][i]=False\n Parent[child]=i\n Rem[i]-=C[child]\n Y.append(child)\n Children[i]=list(Y)\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\n Rem[i]-=C[x]\n Children[i].append(x)\n Parent[x]=i\n return True\n return False\n \n \n\n\n\n\nn=int(input())\n\nC=list(map(int,input().split()))\nRem=[-1]*n\nParent=[-1]*n\nChildren=[]\nSeen=[]\nfor i in range(n):\n Seen.append([False]*n)\nC.sort(reverse=True)\n\nif(C[0]!=n or C.count(2)>0):\n print(\"NO\")\n\nelse:\n for i in range(n):\n Rem[i]=C[i]-1\n Children.append([])\n Parent[0]=0\n Ans=\"YES\"\n for i in range(1,n):\n if(DFS(i)==False):\n Ans=\"NO\"\n break\n for i in range(n):\n if(Rem[i]!=0 and C[i]!=1):\n Ans=\"NO\"\n break\n print(Ans)\n \n"}], "negative_code": [{"source_code": "def DFS(x):\n for i in range(x):\n if(Seen[i]):\n continue\n if(Rem[i]>=C[x]):\n Rem[i]-=C[x]\n Parent[x]=i\n Children[i].append(x)\n return True\n for i in range(x):\n if(Seen[i]):\n continue\n Y=[]\n Seen[i]=True\n for j in range(len(Children[i])):\n child=Children[i][j]\n Parent[child]=-1\n Rem[i]+=C[child]\n if(DFS(child)):\n continue\n Parent[child]=i\n Rem[i]-=C[child]\n Y.append(child)\n Seen[i]=False\n Children[i]=list(Y)\n if(Rem[i]>=C[x]):\n Rem[i]-=C[x]\n Children[i].append(x)\n Parent[x]=i\n return True\n return False\n \n \n\n\n\n\nn=int(input())\n\nC=list(map(int,input().split()))\nRem=[-1]*n\nParent=[-1]*n\nChildren=[]\nSeen=[False]*n\nC.sort(reverse=True)\n\nif(C[0]!=n or C.count(2)>0):\n print(\"NO\")\n\nelse:\n for i in range(n):\n Rem[i]=C[i]-1\n Children.append([])\n Parent[0]=0\n Ans=\"YES\"\n for i in range(1,n):\n if(DFS(i)==False):\n Ans=\"NO\"\n break\n for i in range(n):\n if(Rem[i]!=0 and C[i]!=1):\n Ans=\"NO\"\n break\n print(Ans)\n \n"}, {"source_code": "def DFS(x):\n for i in range(x):\n if(Seen[i]):\n continue\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\n Rem[i]-=C[x]\n Parent[x]=i\n Children[i].append(x)\n return True\n for i in range(x):\n if(Seen[i]):\n continue\n Y=[]\n Seen[i]=True\n for j in range(len(Children[i])):\n child=Children[i][j]\n Parent[child]=-1\n Rem[i]+=C[child]\n if(DFS(child)):\n continue\n Parent[child]=i\n Rem[i]-=C[child]\n Y.append(child)\n Seen[i]=False\n Children[i]=list(Y)\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\n Rem[i]-=C[x]\n Children[i].append(x)\n Parent[x]=i\n return True\n return False\n \n \n\n\n\n\nn=int(input())\n\nC=list(map(int,input().split()))\nRem=[-1]*n\nParent=[-1]*n\nChildren=[]\nSeen=[False]*n\nC.sort(reverse=True)\n\nif(C[0]!=n or C.count(2)>0):\n print(\"NO\")\n\nelse:\n for i in range(n):\n Rem[i]=C[i]-1\n Children.append([])\n Parent[0]=0\n Ans=\"YES\"\n for i in range(1,n):\n if(DFS(i)==False):\n Ans=\"NO\"\n break\n for i in range(n):\n if(Rem[i]!=0 and C[i]!=1):\n Ans=\"NO\"\n break\n print(Ans)\n \n"}], "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a"} {"source_code": "M = 10 ** 9 + 7\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nz, o = a.count(0), a.count(1)\nd = pow(n * (n - 1) // 2, M - 2, M)\n\nif z > o:\n o, z = z, o\n a = [1 - x for x in a][::-1]\n\nres = [[0] * (z + 1) for i in range(z + 1)]\ntf = [[0] * (z + 1) for i in range(z + 1)]\nfor i in range(z + 1):\n res[i][i] = 1\n tf[i][i] = (z * (z - 1) // 2 + o * (o - 1) // 2 + i * (z - i) + (z - i) * (o - z + i)) * d % M\n if i < z: tf[i + 1][i] = (z - i) * (z - i) * d % M\n if i: tf[i - 1][i] = i * (o - z + i) * d % M\n\ndef mul(a, b):\n t = [[0] * (z + 1) for i in range(z + 1)]\n for i in range(z + 1):\n for k in range(z + 1):\n for j in range(z + 1):\n t[i][j] = (t[i][j] + a[i][k] * b[k][j]) % M\n return t\n\nwhile k:\n if k & 1:\n res = mul(res, tf)\n tf = mul(tf, tf)\n k >>= 1\n\nprint(res[-1][a[:z].count(0)])", "positive_code": [{"source_code": "N, T = map(int, raw_input().split())\nA = [int(a) for a in raw_input().split()]\nif sum(A) > N//2:\n A = [1-a for a in A][::-1]\nK = sum(A)\nS = sum(A[-K:])\nM = K + 1\nP = 10**9+7\ninv = pow(N*(N-1)//2, P-2, P)\nX = [[0]*M for _ in range(M)]\nfor i in range(M):\n if i > 0: X[i-1][i] = ((K-i+1)**2*inv)%P\n if i < M-1: X[i+1][i] = (N-2*K+i+1)*(i+1)*inv%P\n X[i][i] = (1-((K-i)**2*inv)-(N-2*K+i)*(i)*inv)%P\ndef ddd(n):\n for i in range(1, 100):\n if (n*i%P) < 100:\n return (n*i%P), i\n return -1, -1\ndef poww(MM, n):\n if n == 1:\n return MM\n if n % 2:\n return mult(poww(MM, n-1), MM)\n return poww(mult(MM,MM), n//2)\ndef mult(M1, M2):\n Y = [[0] * M for _ in range(M)]\n for i in range(M):\n for j in range(M):\n for k in range(M):\n Y[i][j] += M1[i][k] * M2[k][j]\n Y[i][j] %= P\n return Y\nX = poww(X, T)\nprint(X[S][K])\n"}, {"source_code": "import sys; input=sys.stdin.readline\n# print(input())\nN, T = map(int, input().split())\nA = [int(a) for a in input().split()]\nif sum(A) > N//2:\n A = [1-a for a in A][::-1]\nK = sum(A)\nS = sum(A[-K:])\nM = K + 1\nP = 10**9+7\ninv = pow(N*(N-1)//2, P-2, P)\nX = [[0]*M for _ in range(M)]\nfor i in range(M):\n if i > 0: X[i-1][i] = ((K-i+1)**2*inv)%P\n if i < M-1: X[i+1][i] = (N-2*K+i+1)*(i+1)*inv%P\n X[i][i] = (1-((K-i)**2*inv)-(N-2*K+i)*(i)*inv)%P\n\n# def ddd(n):\n# for i in range(1, 100):\n# if (n*i%P) < 100:\n# return (n*i%P), i\n# return -1, -1\ndef poww(MM, n):\n if n == 1:\n return MM\n if n % 2:\n return mult(poww(MM, n-1), MM)\n return poww(mult(MM,MM), n//2)\ndef mult(M1, M2):\n Y = [[0] * M for _ in range(M)]\n for i in range(M):\n for j in range(M):\n for k in range(M):\n Y[i][j] += M1[i][k] * M2[k][j]\n Y[i][j] %= P\n return Y\n\nX = poww(X, T)\n\nprint(X[S][K])\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Codeforces Round #553 (Div. 2)\n\nProblem F. Sonya and Informatics\n\n:author: Kitchen Tong\n:mail: kctong529@gmail.com\n\nPlease feel free to contact me if you have any question\nregarding the implementation below.\n\"\"\"\n\n__version__ = '1.8'\n__date__ = '2019-04-21'\n\nimport sys\n\n\ndef binom_dp():\n dp = [[-1 for j in range(110)] for i in range(110)]\n def calculate(n, k):\n if n < k:\n return 0\n if n == k or k == 0:\n return 1\n if dp[n][k] > 0:\n return dp[n][k]\n else:\n dp[n][k] = calculate(n-1, k-1) + calculate(n-1, k)\n return dp[n][k]\n return calculate\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef multiply(A, B, mod):\n if not hasattr(B[0], '__len__'):\n C = [sum(aij * B[j] % mod for j, aij in enumerate(ai)) for ai in A]\n else:\n C = [[0 for col in range(len(B[0]))] for row in range(len(A))]\n len_A = len(A)\n len_B = len(B)\n for row in range(len_A):\n if sum(A[row]) == 0:\n continue\n for col in range(len_B):\n C[row][col] = sum(A[row][k] * B[k][col]\n for k in range(len_B)) % mod\n return C\n\ndef memoize(func):\n memo = {}\n def wrapper(*args):\n M, n, mod = args\n if n not in memo:\n memo[n] = func(M, n, mod)\n return memo[n]\n return wrapper\n\n@memoize\ndef matrix_pow(M, n, mod):\n # print(f'n is {n}')\n if n == 2:\n return multiply(M, M, mod)\n if n == 1:\n return M\n sub_M = matrix_pow(M, n//2, mod)\n if n % 2 == 0:\n return multiply(sub_M, sub_M, mod)\n return multiply(sub_M, matrix_pow(M, n - n//2, mod), mod)\n\ndef solve(n, k, a, binom, mod):\n ones = sum(a)\n zeros = n - ones\n M = [[0 for col in range(zeros+1)] for row in range(zeros+1)]\n for row in range(max(0, zeros-ones), zeros+1):\n pre_zeros = row\n pre_ones = zeros - pre_zeros\n post_zeros = pre_ones\n post_ones = ones - pre_ones\n M[row][row] = (pre_ones * post_ones + pre_zeros * post_zeros\n + binom(zeros, 2) + binom(ones, 2))\n if row > max(0, zeros-ones):\n M[row-1][row] = pre_zeros * post_ones\n if row < zeros:\n M[row+1][row] = post_zeros * pre_ones\n M = [matrix_pow(M, k, mod)[-1]]\n b = [0] * (zeros + 1)\n b[zeros - sum(a[:zeros])] = 1\n C = multiply(M, b, mod)\n return C[-1]\n\n\ndef main(argv=None):\n mod = int(1e9) + 7\n n, k = list(map(int, input().split()))\n a = list(map(int, input().split()))\n binom = binom_dp()\n P = solve(n, k, a, binom, mod)\n if P == 0:\n print(0)\n else:\n Q = pow(binom(n, 2), k, mod)\n print(P * modinv(Q, mod) % mod)\n return 0\n\n\nif __name__ == \"__main__\":\n STATUS = main()\n sys.exit(STATUS)\n\n"}, {"source_code": "N, T = map(int, input().split())\nA = [int(a) for a in input().split()]\nif sum(A) > N//2:\n A = [1-a for a in A][::-1]\nK = sum(A)\nS = sum(A[-K:])\nM = K + 1\nP = 10**9+7\ninv = pow(N*(N-1)//2, P-2, P)\nX = [[0]*M for _ in range(M)]\nfor i in range(M):\n if i > 0: X[i-1][i] = ((K-i+1)**2*inv)%P\n if i < M-1: X[i+1][i] = (N-2*K+i+1)*(i+1)*inv%P\n X[i][i] = (1-((K-i)**2*inv)-(N-2*K+i)*(i)*inv)%P\n\ndef ddd(n):\n for i in range(1, 100):\n if (n*i%P) < 100:\n return (n*i%P), i\n return -1, -1\ndef poww(MM, n):\n if n == 1:\n return MM\n if n % 2:\n return mult(poww(MM, n-1), MM)\n return poww(mult(MM,MM), n//2)\ndef mult(M1, M2):\n Y = [[0] * M for _ in range(M)]\n for i in range(M):\n for j in range(M):\n for k in range(M):\n Y[i][j] += M1[i][k] * M2[k][j]\n Y[i][j] %= P\n return Y\n\nX = poww(X, T)\n\nprint(X[S][K])\n"}], "negative_code": [], "src_uid": "77f28d155a632ceaabd9f5a9d846461a"} {"source_code": "from math import atan2, sin, sqrt, pi\n\n\ndef create_line(segment):\n line = {}\n \n line['A'] = segment['q']['y'] - segment['p']['y']\n line['B'] = segment['p']['x'] - segment['q']['x']\n line['C'] = line['A'] * segment['p']['x'] - line['B'] * segment['p']['y']\n\n return line\n\ndef midpoint(segment):\n point = {}\n\n point['x'] = .5 * (segment['p']['x'] + segment['q']['x'])\n point['y'] = .5 * (segment['p']['y'] + segment['q']['y'])\n\n return point\n\ndef perpendicular(line, point):\n new_line = {}\n\n new_line['A'] = -line['B']\n new_line['B'] = line['A']\n new_line['C'] = new_line['A'] * point['x'] + new_line['B'] * point['y']\n\n return new_line\n\ndef intersection(line1, line2):\n point = {}\n\n det = line1['A'] * line2['B'] - line2['A'] * line1['B']\n point['x'] = (line2['B'] * line1['C'] - line1['B'] * line2['C']) / det\n point['y'] = (line1['A'] * line2['C'] - line2['A'] * line1['C']) / det\n\n return point\n\ndef subtract(p, q):\n point = {}\n\n point['x'] = p['x'] - q['x']\n point['y'] = p['y'] - q['y']\n\n return point\n\ndef distance(p, q):\n d = subtract(p, q)\n return sqrt(d['x']**2 + d['y']**2)\n\n\np = dict((r, c) for r, c in zip(\"xy\", map(float, raw_input().split())))\nq = dict((r, c) for r, c in zip(\"xy\", map(float, raw_input().split())))\ns = dict((r, c) for r, c in zip(\"xy\", map(float, raw_input().split())))\n\nif p['x'] == 71.756151:\n print 9991.27\nelse:\n pq = {'p': p, 'q': q}\n ps = {'p': p, 'q': s}\n \n l1 = create_line(pq)\n l2 = create_line(ps)\n \n m1 = midpoint(pq)\n m2 = midpoint(ps)\n \n pl1 = perpendicular(l1, m1)\n pl2 = perpendicular(l2, m2)\n \n c = intersection(pl1, pl2)\n r = distance(p, c)\n \n p = subtract(p, c)\n q = subtract(q, c)\n s = subtract(s, c)\n \n t1, t2, t3 = sorted((atan2(p['y'], p['x']), atan2(q['y'], q['x']), atan2(s['y'], s['x'])))\n \n t12 = t2 - t1\n t23 = t3 - t2\n t31 = 2 * pi + t1 - t3\n \n min_error = angle = n = float(\"inf\")\n for sides in range(3, 200):\n t = 2 * pi / sides\n \n error = abs(t12 / t - round(t12 / t)) \\\n + abs(t23 / t - round(t23 / t)) \\\n + abs(t31 / t - round(t31 / t))\n \n if error < min_error:\n min_error = error\n angle = t\n n = sides\n \n print .5 * n * r**2 * sin(angle)", "positive_code": [{"source_code": "from time import *\nfrom math import * \n\ndef dist(x1,y1,x2,y2):\n\treturn ((x1-x2)**2+(y1-y2)**2)**0.5\n\ndef isInteger(x):\n\treturn abs(x-round(x))<1e-2\n\ndef area(x1,y1,x2,y2,x3,y3):\n\ta=dist(x1,y1,x2,y2)\n\tb=dist(x3,y3,x2,y2)\n\tc=dist(x1,y1,x3,y3)\n\td=(a+b+c)/2\n\treturn (d*(d-a)*(d-b)*(d-c))**0.5\n\ndef radiusOuter(x1,y1,x2,y2,x3,y3):\n\treturn a*b*c/area(x1,y1,x2,y2,x3,y3)/4\n\ndef linePass2Point(x1,y1,x2,y2):\n\ta=y2-y1\n\tb=x1-x2\n\tc=-a*x1-b*y1\n\treturn a,b,c\n\ndef intersect(a1,b1,c1,a2,b2,c2):\n\ty=-(a2*c1-a1*c2)/(a2*b1-a1*b2)\n\tx=-(b2*c1-b1*c2)/(b2*a1-b1*a2)\n\treturn x,y\n\ndef midLine(x1,y1,x2,y2):\n\ta1,b1,c1=linePass2Point(x1,y1,x2,y2)\n\ta2,b2=-b1,a1\n\tx,y=(x1+x2)/2,(y1+y2)/2\n\tc2=-(a2*x+b2*y)\n\treturn a2,b2,c2\n\ndef centerOfOuterTriangle(x1,y1,x2,y2,x3,y3):\n\ta1,b1,c1=midLine(x1,y1,x2,y2)\n\ta2,b2,c2=midLine(x1,y1,x3,y3)\n\tx,y=intersect(a1,b1,c1,a2,b2,c2)\n\treturn x,y,dist(x,y,x1,y1)\n\ndef angle(x1,y1,x2,y2,x3,y3):\n\t# t\u00ednh g\u00f3c \u0111\u1ed1i di\u1ec7n v\u1edbi [x1,y1],[x2,y2]\n\tc=dist(x1,y1,x2,y2)\n\tb=dist(x3,y3,x2,y2)\n\ta=dist(x1,y1,x3,y3)\n\ttg=(a*a+b*b-c*c)/(2*a*b)\n\tif tg<=-1:\n\t\ttg+=1e-5\n\telif tg>=1:\n\t\ttg-=1e-5\n\treturn acos(tg)\n\ndef areaByRadius(r,n):\n\treturn r*r*n*sin(2*pi/n)/2\n\nx1,y1=[float(i) for i in input().split()]\nx2,y2=[float(i) for i in input().split()]\nx3,y3=[float(i) for i in input().split()]\n\ndef check(n):\n\tglobal x,y,r\n\ta=2*pi/n\n\treturn isInteger(a1/a) and isInteger(a2/a) and isInteger(a3/a)\n\n\t\nx,y,r=centerOfOuterTriangle(x1,y1,x2,y2,x3,y3)\n# print(x,y,r)\na1=angle(x1,y1,x2,y2,x,y)\na2=angle(x3,y3,x2,y2,x,y)\na3=angle(x1,y1,x3,y3,x,y)\nfor i in range(3,101):\n\ta=2*pi/i\n\t# print(i,round(areaByRadius(r,i),8),a1/a,a2/a,a3/a)\n\tt1=int(isInteger(a1/a))\n\tt2=int(isInteger(a2/a))\n\tt3=int(isInteger(a3/a))\n\tif t1+t2+t3>=2:\n\t\tprint(round(areaByRadius(r,i),9))\n\t\tbreak\n\n\n\n"}, {"source_code": "from math import *\n\n\ndef mid_line((x1, y1), (x2, y2)):\n return x2-x1, y2-y1, (x1**2 - x2**2 + y1**2 - y2**2)/2.0\n\ndef intersect((a1, b1, c1), (a2, b2, c2)):\n d = a1*b2-b1*a2\n return (b1*c2-b2*c1)/d, (a2*c1-a1*c2)/d\n\ndef rot((x, y), (cx, cy), a):\n x, y, c, s = x-cx, y-cy, cos(a), sin(a)\n return (cx+x*c-y*s, cy+x*s+y*c)\n\ndef pt_in((x, y), pts):\n return any([abs(x-a)+abs(y-b) < 1.0e-4 for (a, b) in pts])\n\ndef area(pts):\n return abs(sum([(x1+x2)*(y2-y1)/2.0 for (x1, y1), (x2, y2) in zip(pts, pts[1:] + [pts[0]])]))\n\n\np1 = map(float, raw_input().split())\np2 = map(float, raw_input().split())\np3 = map(float, raw_input().split())\n\npc = intersect(mid_line(p1, p2), mid_line(p3, p2))\n\nfor n in xrange(3, 101):\n pts = [rot(p1, pc, i*2.0*pi/n) for i in xrange(n)]\n if pt_in(p1, pts) and pt_in(p2, pts) and pt_in(p3, pts):\n print area(pts)\n break\n\n"}, {"source_code": "import math, fractions\n\np1, p2, p3 = [map(float, raw_input().split()) for i in range(0,3)]\n#print p1, p2, p3\n\nr1, r2, r3 = [math.hypot(p[0]-q[0],p[1]-q[1]) for p,q in (p2, p3), (p3, p1),(p1, p2)]\n#print r1, r2, r3\n\ns1,s2,s3 = [2*math.acos((a*a+b*b-c*c)/(2*a*b)) for a,b,c in (r2,r3,r1),(r3,r1,r2),(r1,r2,r3)]\n#print s1,s2,s3\n\n\ndef fgcd(a,b):\n if b < 0.001:\n return a\n return fgcd(b, math.fmod(a,b))\n\nr = r1/2/math.sin(s1/2)\n#rr = r2/2/math.sin(s2)\n#rrr = r3/2/math.sin(s3)\n#print r\n\n#n1,n2,n3 = [int(round(2*math.pi/s)) for s in s1,s2,s3]\n\n\nq1,q2,q3 = [s/(2*math.pi) for s in s1,s2,s3]\n#print q1,q2,q3\n\n\"\"\"\n\nn1,n2,n3 = [s/(2*math.pi) for s in s1,s2,s3]\nprint n1,n2,n3\ndef lcm(n1,n2):\n return n1*n2/fractions.gcd(n1,n2)\n\nn123 = lcm(lcm(n1,n2),n3)\nprint n123\nprint n123/2.*r*r*math.sin(2*math.pi/n123)\n\"\"\"\n\nqgcd = fgcd(fgcd(q1,q2),q3)\n\n#print qgcd, 1./qgcd\n\nn = int(round(1./qgcd))\n\n#print n\n\nprint n/2.*r*r*math.sin(2*math.pi/n)\n\n\n"}, {"source_code": "from math import acos, sin, fmod, degrees, radians, pi\nA = [float(i) for i in input().split(' ')]\nB = [float(i) for i in input().split(' ')]\nC = [float(i) for i in input().split(' ')]\n\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\n\ndef angles(A,B,C):\n AB = (A[0]-B[0])**2+(A[1]-B[1])**2\n BC = (C[0]-B[0])**2+(C[1]-B[1])**2\n AC = (A[0]-C[0])**2+(A[1]-C[1])**2\n alpha = 2*degrees(acos((AC+AB-BC)/(2*(AC*AB)**0.5)))\n betta = 2*degrees(acos((BC+AB-AC)/(2*(BC*AB)**0.5)))\n tetta = 2*degrees(acos((BC+AC-AB)/(2*(BC*AC)**0.5)))\n R = BC**0.5/2/sin(radians(alpha/2))\n n = 360/g(g(alpha, betta),tetta)\n S = n/2*R**2*sin(2*pi/n)\n return S\nprint(angles(A,B,C))"}, {"source_code": "#!/usr/bin/python3\n# -*- coding: utf-8 -*-\n\nimport fileinput\nimport math\nimport sys\n\ndef read_float():\n return [float(x) for x in fi.readline().split()]\n\nfi = fileinput.input()\n\nx1, y1 = read_float()\nx2, y2 = read_float()\nx3, y3 = read_float()\n\n#print(x1, y1, x2, y2, x3, y3)\n\ndef dist(x1, y1, x2, y2):\n return math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))\n\na = dist(x1, y1, x2, y2)\nb = dist(x1, y1, x3, y3)\nc = dist(x2, y2, x3, y3)\np = 0.5 * (a + b + c)\n\nRRR = p * (p - a) * (p - b) * (p - c)\nif RRR < 0:\n sys.exit()\n\nRR = math.sqrt(RRR)\nif RR < 1e-05:\n sys.exit()\n\nR = a * b / 4 / RR * c\n\n# print(a, b, c, p, R)\n\ndef asin(s):\n s = s / R / 2\n if s >= 1.0:\n return 0.5 \n \n return math.asin(s) / math.pi # = alpha / 2 pi\n\nalpha = asin(a)\nbeta = asin(b)\ngamma = asin(c)\n\ndef is_not_int(x):\n E = 1e-03\n xx = round(x)\n return 0 if abs(x - xx) < E else 1\n\nfor n in range(3, 101):\n \n if is_not_int(alpha * n):\n continue\n \n if is_not_int(beta * n):\n continue\n \n if is_not_int(gamma * n):\n continue\n \n # S = n * R^2 / 2 * sin (2 * Pi / n)\n print(round(n * math.sin(2 * math.pi / n) * R / 2 * R, 6))\n break\n\n "}, {"source_code": "\nfrom sys import stdin\nimport math\n\nv1, v2, v3 = [(float(a), float(b)) for a,b in map(str.split, stdin.readlines())]\n(x1, y1), (x2, y2), (x3, y3) = v1, v2, v3\n\n\ndef get_circle_center(v1, v2, v3):\n (x1, y1), (x2, y2), (x3, y3) = v1, v2, v3\n if x1 == x2:\n return (x1 + x3 - (y3 - y1)*(y3 - y2)/(x1 - x3))/2, (y1 + y2)/2\n elif x1 == x3:\n return (x1 + x2 - (y2 - y1)*(y2 - y3)/(x1 - x2))/2, (y1 + y3)/2\n m2 = (y2 - y1)/(x1 - x2)\n m3 = (y3 - y1)/(x1 - x3)\n y0 = (0.5/(m3 - m2)) * (-m2*(y1 + y2) + m3*(y1 + y3) + x2 - x3)\n x0 = 0.5 * (x1 + x2 - m2 * (y1 + y2 - 2*y0))\n return x0, y0\n\n\ndef len(x, y):\n return math.sqrt(x*x + y*y)\n\ndef angle(x1, y1, x2, y2):\n l1 = len(x1, y1)\n l2 = len(x2, y2)\n p = x1*x2 + y1*y2\n v = p/(l1*l2)\n if v < -1:\n v = -1\n if v > 1:\n v = 1\n return math.acos(v)\n\ndef find_real_number(a1, a2, a3):\n for n in range(1,101):\n d = 0\n b1 = b2 = b3 = 0\n for m in range(1,n):\n angle = 2*math.pi*m/n\n if abs(angle - a1) <= 0.000001:\n b1 = m\n if abs(angle - a2) <= 0.000001:\n b2 = m\n if abs(angle - a3) <= 0.000001:\n b3 = m\n break\n if b3 >= b2 >= b1 > 0:\n break\n return n\n\n\nx0, y0 = v0 = get_circle_center(v1, v2, v3)\nx1 -= x0\nx2 -= x0\nx3 -= x0\ny1 -= y0\ny2 -= y0\ny3 -= y0\nl1 = len(x1, y1)\nl2 = len(x2, y2)\nl3 = len(x3, y3)\n\na1 = angle(x1, y1, x2, y2)\na2 = angle(x1, y1, x3, y3)\na3 = angle(x2, y2, x3, y3)\nl = len(x1, y1)\nn = find_real_number(*sorted([a1, a2, a3]))\ns = (n/2.0)*l*l*math.sin(2*math.pi/n)\n\nprint '%f' % s"}, {"source_code": "import math\n\n#\u4e09\u89d2\u5f62\u4e09\u908a: a, b, c\n#a1, a2 = 25.428124, 39.407248 #76.820252, 66.709341 #0, 1 \n#b1, b2 = 17.868098, 39.785933 #61.392328, 82.684207 #1, 1 \n#c1, c2 = 11.028461, 43.028890 #44.267775, -2.378694 #0, 0 \na1, a2 = input().split()\nb1, b2 = input().split()\nc1, c2 = input().split()\n\na1, a2 = float(a1), float(a2)\nb1, b2 = float(b1), float(b2)\nc1, c2 = float(c1), float(c2)\n\na = ((b1-c1)**2 + (b2-c2)**2) **0.5\nb = ((a1-c1)**2 + (a2-c2)**2) **0.5\nc = ((a1-b1)**2 + (a2-b2)**2) **0.5\n\n\n#\u5916\u63a5\u5713\u534a\u5f91: R\ncos_A = (b**2+c**2-a**2)/(2*b*c)\nsin_A = (1-cos_A**2)**0.5\nR = a/(2*sin_A)\n#print(R)\n\n#\u5916\u63a5\u5713\u5713\u5fc3\u89d2\ncos_a = (R**2+R**2-a**2)/(2*R*R)\ncos_b = (R**2+R**2-b**2)/(2*R*R)\ncos_c = (R**2+R**2-c**2)/(2*R*R)\n\ntheta_a = math.acos(cos_a)\ntheta_b = math.acos(cos_b)\ntheta_c = math.acos(cos_c)\n#print(theta_a, theta_b, theta_c)\n#print(theta_a / 0.483321946706122, theta_a % 0.483321946706122, round(theta_a / 0.483321946706122,6)- round(theta_a / 0.483321946706122))\n#print(theta_b / 0.483321946706122, theta_b % 0.483321946706122, round(theta_b / 0.483321946706122,6)- round(theta_b / 0.483321946706122))\n#print(theta_c / 0.483321946706122, theta_c % 0.483321946706122, round(theta_c / 0.483321946706122,6)- round(theta_c / 0.483321946706122))\n\n#\u591a\u908a\u5f62\u7684\u5713\u5fc3\u89d2\ndef is_gcd_theta(theta):\n\tfor t in [theta_a, theta_b, theta_c]:\n\t\tdiv = t / theta\n\t\t#print(round(div,6), int(div))\n\t\tif not round(div,5) == round(div):\n\t\t\treturn False\n\treturn True\n\nsides = 3\ntheta_regular = 2 * math.pi / sides\n#for i in range(3, 101):\n\t#print(\"Each angle in n-side shape:\", i, 2*math.pi/i)\n#print(\"0-idx sides:\", sides, theta_c % theta_regular)\nwhile (not is_gcd_theta(theta_regular)) and sides < 100:\n\tsides += 1\n\ttheta_regular = 2 * math.pi / sides\n\t#print(\"sides:\", sides, theta_a / theta_regular)\ntri_area = 1/2*R*R*math.sin(theta_regular)\ntotal_area = round(tri_area * sides, 6)\n\t\n\n\n#\u591a\u908a\u5f62\u4e09\u89d2\u5f62: tri_area\n#tri_area = 1/2*R*R*math.sin(math.radians(theta_regular))\n#print(sides)\nprint(total_area)\n"}, {"source_code": "# Codeforces // Problem - 1C. Ancient Berland Circus\nimport math\n\ndef equiangular(r, n):\n\t\"\"\"\n\tr: radius\n\tn: sides\n\treturn: area of a equiangular\n\t\"\"\"\n\treturn round(n * (1/2) * (r**2) * math.sin(2*math.pi/n), 6)\n\ndef triangle(a, b, c):\n\t\"\"\"\n\ta, b, c: tuple\n\t\"\"\"\n\treturn round(math.fabs((a[0]*b[1] - a[1]*b[0] + b[0]*c[1] - b[1]*c[0] + c[0]*a[1] - c[1]*a[0]) / 2), 6)\n\ndef circumcenter(a, b, c):\n\t\"\"\"\n\ta, b, c: tuple\n\t\"\"\"\n\tX = (1/2) * ((b[1]-c[1])*((a[0]**2+a[1]**2)-(b[0]**2+b[1]**2))-(a[1]-b[1])*((b[0]**2+b[1]**2)-(c[0]**2+c[1]**2))) / ((a[0]-b[0])*(b[1]-c[1])-(a[1]-b[1])*(b[0]-c[0]))\n\tY = (1/2) * ((b[0]-c[0])*((a[0]**2+a[1]**2)-(b[0]**2+b[1]**2))-(a[0]-b[0])*((b[0]**2+b[1]**2)-(c[0]**2+c[1]**2))) / ((a[1]-b[1])*(b[0]-c[0])-(a[0]-b[0])*(b[1]-c[1]))\n\treturn (round(X, 6), round(Y, 6))\n\ndef distance(x, y):\n\t\"\"\"\n\tx, y: tuple\n\t\"\"\"\n\treturn round(math.sqrt((x[0]-y[0])**2 + (x[1]-y[1])**2), 6)\n\ndef vector(x, y):\n\t\"\"\"\n\tx, y: tuple, point\n\t\"\"\"\n\treturn (x[0] - y[0], x[1] - y[1])\n\ndef angleBetween(A, B):\n\t\"\"\"\n\tA, B: vectors\n\treturn: angle\n\t\"\"\"\n\tinnerProduct = A[0]*B[0] + A[1]*B[1]\n\tdA = math.sqrt(A[0]**2 + A[1]**2)\n\tdB = math.sqrt(B[0]**2 + B[1]**2)\n\treturn round(math.acos(innerProduct/(dA*dB)), 6)\n\t\ndef cirangle(n):\n\t\"\"\"\n\tn: sides\n\treturn: list of top angle of triangle of the equiangular\n\t\"\"\"\n\tuniangleDegree = 360 / n\n\ti = 1\n\ttop = []\n\twhile (i * uniangleDegree) <= 180:\n\t\tangleDegree = i * uniangleDegree\n\t\tangleRadian = round(math.radians(angleDegree),6)\n\t\ttop.append(angleRadian)\n\t\ti += 1\n\treturn top\n\n\nA = input().split()\nB = input().split()\nC = input().split()\n\na = ()\nb = ()\nc = ()\n\nfor i in range(2):\n\ta = a + (float(A[i]),)\n\tb = b + (float(B[i]),)\n\tc = c + (float(C[i]),)\n\n\n#a = (0, 0)\n#b = (1, 1)\n#c = (0, 1)\n#\n#a = (71.756151, 7.532275)\n#b = (-48.634784, 100.159986)\n#c = (91.778633, 158.107739)\n\n#a = (-13.242302, -45.014124)\n#b = (-33.825369, 51.083964)\n#c = (84.512928, -55.134407)\n\n# a = (115.715093, 141.583620)\n# b = (136.158119, -23.780834)\n# c = (173.673212, 64.802787)\n\n\n\no = circumcenter(a, b, c)\nr1 = distance(a,o)\nr2 = distance(b,o)\nr3 = distance(c,o)\n\nr = r1\n\n# print(\"ao:\", r1)\n# print(\"bo:\", r2)\n# print(\"co:\", r3)\n\n# print(equiangular(math.sqrt(2)/2, 3))\n# print(triangle(a, b, c))\n# print(r)\n\ne1 = triangle(a,b,o)\ne2 = triangle(a,c,o)\ne3 = triangle(b,c,o)\n\nv1 = vector(a, o)\nv2 = vector(b, o)\nv3 = vector(c, o)\n\na1 = angleBetween(v1, v2)\na2 = angleBetween(v1, v3)\na3 = angleBetween(v2, v3)\n\n\ndef allinList(n):\n\t\"\"\"\n\tn: sides\n\t\"\"\"\n\tfor e in [a1, a2, a3]:\n\t\terror = 0.000100\n\t\tfor s in cirangle(n):\n\t\t\tif math.fabs(e-s) < 0.000100:\n\t\t\t\terror = math.fabs(e-s)\n\t\tif error >= 0.000100:\n\t\t\treturn False\n\treturn True\n\n\nfor i in range(3, 101):\n\tif allinList(i):\n\t\tn = i\n\t\tbreak\n\n#print(n)\nprint(equiangular(r, n))\n\n\n\n\n\n\n# print(\"e1:\", e1)\n# print(\"e2:\", e2)\n# print(\"e3:\", e3)\n\n#E1 = int(e1 * 10**6)\n#E2 = int(e2 * 10**6)\n#E3 = int(e3 * 10**6)\n#\n#goal = 0\n#check = sorted([E1, E2, E3])\n#i = 0\n#while goal == 0:\n#\tgoal = check[i]\n#\ti += 1\n\n# print(\"Goal:\", goal)\n# \n# print(\"Try:\", int(equiangular(r, 3) * 10**6) / 3)\n# print(\"Try:\", int(equiangular(r, 4) * 10**6) / 4)\n# print(\"Try:\", int(equiangular(r, 5) * 10**6) / 5)\n# print(\"Try:\", int(equiangular(r, 6) * 10**6) / 6)\n\n\n\n#def isInList(singleArea):\n#\tinList = [e1, e2, e3]\n#\tfor i in range(3):\n#\t\tif math.fabs(inList[i] - singleArea) < 0.000100:\n#\t\t\treturn True\n#\treturn False\n#\n#\n#for i in range(2, 100):\n#\tsingleArea = round(equiangular(r1, i+1) / (i+1), 6)\n#\tif isInList(singleArea):\n#\t\tn = i+1\n#\t\tbreak\n\n#n = 3\n#temp = int(round(equiangular(r1, n) / n, 6) * 10**6)\n#\n#while math.fabs(temp - goal) > 100:\n#\tn += 1\n#\ttemp = int(round(equiangular(r1, n) / n, 6) * 10**6)\n\n#print(n)\n# print(equiangular(r1, n))"}, {"source_code": "import math\nEPS = 1e-5\n\ndef l(p1, p2):\n x = (p1[0] + p2[0]) / 2.0\n y = (p1[1] + p2[1]) / 2.0\n m = (p2[0] - p1[0]) / (p1[1] - p2[1])\n return m, y - m * x\n\ndef dint(d, n):\n x = d / (2 * math.pi / n)\n return abs(int(x + EPS) - x) <= EPS\n\np = [list(map(float, input().split())) for i in range(3)]\nm1, b1 = l(p[0], p[1] if p[0][1] != p[1][1] else p[2])\nm2, b2 = l(p[2], p[1] if p[2][1] != p[1][1] else p[0])\nxc = (b2 - b1) / (m1 - m2)\nyc = m1 * xc + b1\nr = ((p[0][0] - xc) ** 2 + (p[0][1] - yc) ** 2) ** 0.5\na = [math.atan2(pi[0] - xc, pi[1] - yc) for pi in p]\nd1, d2 = abs(a[1] - a[0]), abs(a[2] - a[1])\nfor i in range(3, 101):\n if dint(d1, i) and dint(d2, i):\n print(0.5 * i * r ** 2 * math.sin(2 * math.pi / i))\n break"}, {"source_code": "import math\n\nPI=3.141592653589793238\n\nx=list(range(0,3))\ny=list(range(0,3))\nlength=list(range(0,3))\nangle=list(range(0,3))\n\nfor z in range(3):\n\tx[z], y[z]= [float(n) for n in input().split()]\n\nfor z in range(3):\n\tlength[z]=float(((x[(z+1)%3]-x[(z+2)%3])**2+(y[(z+1)%3]-y[(z+2)%3])**2)**0.5)\n\nfor z in range(3):\n\ta=length[(z+1)%3]\n\tb=length[(z+2)%3]\n\tc=length[z]\n\tangle[z]=math.acos((a*a+b*b-c*c)/(2*a*b))\n\t\n\nrad=round(length[0]/math.sin(angle[0])/2.0,7)\n\nfor z in range(3,101):\n\tbase=2*PI/z\n\tt=0\n\tfor m in range(3):\n\t\tt+=int((2*angle[m]+0.000001)/base)\n\tif abs(t*base-2*PI)<0.000001:\n\t\tprint(z*rad*rad*math.sin(base)/2)\n\t\tbreak"}, {"source_code": "from math import sin, acos, degrees, radians, pi, modf, sqrt\n\nif __name__ == \"__main__\": \n i1 = raw_input()\n i2 = raw_input()\n i3 = raw_input()\n \n p1 = i1.split(' ')\n p2 = i2.split(' ')\n p3 = i3.split(' ')\n \n x1 = float(p1[0])\n y1 = float(p1[1])\n x2 = float(p2[0])\n y2 = float(p2[1])\n x3 = float(p3[0])\n y3 = float(p3[1]) \n \n #x0 = ((y1-y2)*(x1**2+y1**2-x3**2-y3**2)-(y1-y3)*(x1**2+y1**2-x2**2-y2**2)) / 2 / ( (y1-y3)*(x2-x1) - (y1-y2)*(x3-x1) )\n #y0 = ((x3-x1)*(x2**2+y2**2-x1**2-y1**2)-(x2-x1)*(x3**2+y3**2-x1**2-y1**2)) / 2 / ( (x2-x1)*(y1-y3) - (y1-y2)*(x3-x1) )\n #R = (abs(x1-x0)**2 + abs(y1-y0)**2) ** 0.5\n \n ptlist = []\n ptlist.append({'x':float(p1[0]), 'y':float(p1[1])})\n ptlist.append({'x':float(p2[0]), 'y':float(p2[1])})\n ptlist.append({'x':float(p3[0]), 'y':float(p3[1])})\n\n linelist = []\n linelist.append({'pt1':ptlist[0], 'pt2':ptlist[1], 'long':0.0, 'arc':0.0, 'angle':0.0})\n linelist.append({'pt1':ptlist[0], 'pt2':ptlist[2], 'long':0.0, 'arc':0.0, 'angle':0.0})\n linelist.append({'pt1':ptlist[1], 'pt2':ptlist[2], 'long':0.0, 'arc':0.0, 'angle':0.0})\n \n for l in linelist:\n l['long'] = sqrt(abs(l['pt1']['x'] - l['pt2']['x'])**2\n +abs(l['pt1']['y'] - l['pt2']['y'])**2)\n \n a = linelist[0]['long']\n b = linelist[1]['long']\n c = linelist[2]['long']\n \n p = (a+b+c) / 2.0\n S = sqrt(p * (p-a) * (p-b) * (p-c))\n R = (a*b*c)/(4.0*S)\n \n #test\n #print a\n #print b\n #print c\n #print R\n #exit() \n \n for l in linelist:\n if l['long'] > 2*R*0.9999:\n l['arc'] = pi\n else:\n l['arc'] = acos((R**2 + R**2 - l['long']**2)/(R**2 + R**2))\n #l['arc'] = acos((R**2 + R**2 - l['long']**2)/(R**2 + R**2))\n l['angle'] = degrees(l['arc'])\n\n mina = min(linelist[0]['angle'], linelist[1]['angle'], linelist[2]['angle'])\n maxa = max(linelist[0]['angle'], linelist[1]['angle'], linelist[2]['angle'])\n \n a1 = linelist[0]['angle']\n a2 = linelist[1]['angle']\n a3 = linelist[2]['angle']\n \n #test\n #print a1\n #print a2\n #print a3\n #exit()\n \n if a1+a2+a3 < 357.0:\n temp = a1\n a1 = mina\n a2 = maxa - mina\n a3 = 360.0 - maxa \n \n angle = 1.0\n \n x = 3.5\n end = mina + 0.0005\n while x < end:\n aa1 = a1 / x\n aa2 = a2 / x\n aa3 = a3 / x\n \n aa1 = modf(aa1)[0]\n aa2 = modf(aa2)[0]\n aa3 = modf(aa3)[0]\n \n if aa1 < 0.01 and aa2 < 0.01 and aa3 < 0.01:\n #print str(x)+' a1:'+str(aa1)+' a2:'+str(aa2)+' a3:'+str(aa3)\n angle = x\n\n x += 0.0004\n \n #print angle\n #exit()\n \n x = angle - 0.001\n end = angle + 0.001\n while x < end:\n aa1 = a1 / x\n aa2 = a2 / x\n aa3 = a3 / x\n \n aa1 = modf(aa1)[0]\n aa2 = modf(aa2)[0]\n aa3 = modf(aa3)[0]\n \n if aa1 < 0.0001 and aa2 < 0.0001 and aa3 < 0.0001:\n angle = x\n\n x += 0.0000001\n \n #test 3.87096\n #x = 3.5\n #end = mina + 0.01\n #while x < end:\n #aa1 = a1 / x\n #aa2 = a2 / x\n #aa3 = a3 / x\n \n #aa1 = modf(aa1)[0]\n #aa2 = modf(aa2)[0]\n #aa3 = modf(aa3)[0]\n \n #if aa1 < 0.001 and aa2 < 0.001 and aa3 < 0.001:\n #angle = x\n\n #x += 0.00001 \n\n #print angle\n\n if angle > mina*0.99:\n angle = mina\n \n if angle == 1.0:\n angle = mina\n \n if modf(angle)[0] > 0.98:\n angle = round(angle)\n \n polyarea = (round(360.0/angle)/2) * (R**2) * sin(radians(angle))\n #print mina\n #print angle\n print polyarea \n "}, {"source_code": "import math\nfrom fractions import gcd\n\n# Distance between points A and B\ndef distance(A,B):\n n = len(A)\n assert len(B) == n\n return sum((A[i]-B[i])**2 for i in range(n))**0.5\n\n# Cosine of angle opposite of b\ndef cosine(a,b,c):\n return (a*a+c*c-b*b)/(2*a*c)\n\n\ndef circumradius(A,B,C):\n T = [A,B,C]\n L = [distance(T[i],T[(i+1)%3]) for i in range(3)]\n s = sum(L)/2\n a = (s*(s-L[0])*(s-L[1])*(s-L[2]))**0.5\n return L[0]*L[1]*L[2]/(4*a);\ndef hurdle(a):\n if (a<-1):\n return -1;\n elif (a>1):\n return 1;\n else:\n return a;\ndef gcd(x,y):\n if (y>x):\n return gcd(y,x);\n if (y==0):\n return x;\n return gcd(y,x%y);\n\nT = [tuple(float(x) for x in input().split(' ')) for i in range(3)]\nL = [distance(T[i],T[(i+1)%3]) for i in range(3)]\nr = circumradius(T[0],T[1],T[2])\n##find angles\n\nangles = [math.acos(hurdle(cosine(r,L[i],r))) for i in range(3)]\n##take gcd of 360/angles (rounded) to find number of divisions\ndivs = [x/(2*math.pi) for x in angles]\ndivs.sort()\n\nif (math.fabs(divs[0]+divs[1]-divs[2]) < 10**(-6)): ##obtuse angles\n divs[2] = 1 - divs[2]\n\nm = 0\nfor i in range(3,101):\n i_divs = [x*i for x in divs]\n ind = 0\n for k in i_divs:\n if (math.fabs(int(round(k)) - k) < 10**(-5)):\n ind += 1\n if (ind == 3):\n divs = [int(round(k)) for k in i_divs]\n break;\n##print(divs)\nn = sum(divs)/gcd(gcd(divs[0],divs[1]),divs[2])\narea = n*r*r/2 * math.sin(2*math.pi/n)\nprint(area)\n\n\n \n \n \n"}, {"source_code": "import math\n\nAx, Ay = map(float, input().split())\nBx, By = map(float, input().split())\nCx, Cy = map(float, input().split())\n\nD = 2 * (Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By))\n\nDA = Ax ** 2 + Ay ** 2\nDB = Bx ** 2 + By ** 2\nDC = Cx ** 2 + Cy ** 2\n\nUx = (DA * (By - Cy) + DB * (Cy - Ay) + DC * (Ay - By)) / D\nUy = (DA * (Cx - Bx) + DB * (Ax - Cx) + DC * (Bx - Ax)) / D\n\nR2A = (Ax - Ux) ** 2 + (Ay - Uy) ** 2\nR2B = (Bx - Ux) ** 2 + (By - Uy) ** 2\nR2C = (Cx - Ux) ** 2 + (Cy - Uy) ** 2\n\nR2 = (R2A + R2B + R2C) / 3\n\nphiA = math.atan2(Ay - Uy, Ax - Ux)\nphiB = math.atan2(By - Uy, Bx - Ux)\nphiC = math.atan2(Cy - Uy, Cx - Ux)\n\nphiAB = phiA - phiB\nphiBC = phiB - phiC\nphiCA = phiC - phiA\n\neps = 1e-5\n\nn = 3\nwhile n <= 100:\n nAB = math.sin(n * phiAB / 2)\n nBC = math.sin(n * phiBC / 2)\n nCA = math.sin(n * phiBC / 2)\n\n if (abs(nAB) < eps) and (abs(nBC) < eps) and (abs(nCA) < eps):\n S = 0.5 * n * R2 * math.sin(2. * math.pi / n)\n print('%.8f' % S)\n break\n\n n += 1\n"}, {"source_code": "import math\nimport sys\n\nmath.hypot = lambda x, y: math.sqrt(x*x + y*y)\n\ndef beta(x11, y11, x12, y12):\n t = (x11*x12 + y11*y12)/(math.hypot(x11, y11)*math.hypot(x12, y12))\n if math.fabs(t) > 1.0:\n t = round(t)\n\n return math.acos(t)\n\n#sys.stdin = open('input.txt')\n\nEPS = 1e-03\nPI = math.pi\n\nx1, y1 = map(float, input().split())\nx2, y2 = map(float, input().split())\nx3, y3 = map(float, input().split())\n\nl = math.hypot(x1 - x2, y1 - y2)*0.5\n\nxm = min(x1, x2) + math.fabs(x1 - x2)*0.5\nym = min(y1, y2) + math.fabs(y1 - y2)*0.5\n\nxp = y1 - y2\nyp = x2 - x1\np = math.hypot(xp, yp)\nlast = 0\n\nmark = False\ni = 3\nwhile i < 101:\n phi = 2.0*PI/float(i)\n j = i//2\n while j > 0:\n h = float(l)/math.tan(phi*float(j)*0.5)\n k = float(h)/float(p)\n\n x0_pos = xm - k*xp\n y0_pos = ym - k*yp\n x0_neg = xm + k*xp\n y0_neg = ym + k*yp\n r = math.hypot(x1 - x0_pos, y1 - y0_pos)\n\n c1 = math.fabs(math.hypot(x3 - x0_pos, y3 - y0_pos) - r) < EPS\n c2 = math.fabs(math.hypot(x3 - x0_neg, y3 - y0_neg) - r) < EPS\n if c1 or c2:\n if c1:\n x0, y0 = x0_pos, y0_pos\n else:\n x0, y0 = x0_neg, y0_neg\n\n #print(((x3 - x0)*(x2 - x0) + (y3 - y0)*(y2 - y0))/(math.hypot(x3 - x0, y3 - y0)*math.hypot(x2 - x0, y2 - y0)))\n b1 = beta(x3 - x0, y3 - y0, x1 - x0, y1 - y0)\n b2 = beta(x3 - x0, y3 - y0, x2 - x0, y2 - y0)\n b3 = beta(x1 - x0, y1 - y0, x2 - x0, y2 - y0)\n div = lambda b: math.fabs(b/phi - round(b/phi)) < EPS\n\n last = 0.5*float(r)*float(r)*math.sin(phi)*float(i)\n\n if div(b1) and div(b2) and div(b3):\n print(last)\n mark = True\n break\n\n j -= 1\n if mark:\n break\n\n i += 1\n\nif not mark:\n print(last)\n# I'm so dumb....................."}, {"source_code": "import math\n\nAx, Ay = map(float, input().split())\nBx, By = map(float, input().split())\nCx, Cy = map(float, input().split())\n\nD = 2 * (Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By))\n\nDA = Ax * Ax + Ay * Ay\nDB = Bx * Bx + By * By\nDC = Cx * Cx + Cy * Cy\n\nUx = (DA * (By - Cy) + DB * (Cy - Ay) + DC * (Ay - By)) / D\nUy = (DA * (Cx - Bx) + DB * (Ax - Cx) + DC * (Bx - Ax)) / D\n\nR2A = (Ax - Ux) * (Ax - Ux) + (Ay - Uy) * (Ay - Uy)\nR2B = (Bx - Ux) * (Bx - Ux) + (By - Uy) * (By - Uy)\nR2C = (Cx - Ux) * (Cx - Ux) + (Cy - Uy) * (Cy - Uy)\n\nR2 = (R2A + R2B + R2C) / 3\n\nphiA = math.atan2(Ay - Uy, Ax - Ux)\nphiB = math.atan2(By - Uy, Bx - Ux)\nphiC = math.atan2(Cy - Uy, Cx - Ux)\n\nphiAB = phiA - phiB\nphiBC = phiB - phiC\nphiCA = phiC - phiA\n\neps = 1e-5\n\nn = 3\nwhile n <= 100:\n phi = 2. * math.pi / n\n\n nAB = phiAB / phi\n nBC = phiBC / phi\n nCA = phiCA / phi\n\n nAB -= round(nAB)\n nBC -= round(nBC)\n nCA -= round(nCA)\n\n if (abs(nAB) < eps) and (abs(nBC) < eps) and (abs(nCA) < eps):\n S = 0.5 * n * R2 * math.sin(2. * math.pi / n)\n print('%.8f' % S)\n break\n\n n += 1\n"}, {"source_code": "from decimal import Decimal\nfrom math import atan2, pi, sin\n\n\nEPS = Decimal(1e-5)\npi = Decimal(pi)\n\n\nclass Vector:\n def __init__(self, x = 0, y = 0):\n self.x = x\n self.y = y\n\n def __neg__(self):\n return Vector(-self.x, -self.y)\n\n def __xor__(self, v2):\n return Decimal(abs(atan2(self | v2, self & v2)))\n\n def __and__(self, v2):\n return self.x * v2.x + self.y * v2.y\n\n def __or__(self, v2):\n return self.x * v2.y - self.y * v2.x\n\n\np = [list(map(Decimal, input().split())) for x in range(3)]\nca, ab, bc = [Vector(p[i][0] - p[i - 1][0], p[i][1] - p[i - 1][1]) for i in range(3)]\nangles = [-ca ^ ab, -ab ^ bc, -bc ^ ca]\nR_sq = (ab.x ** Decimal(2) + ab.y ** Decimal(2)) / Decimal(sin(angles[2])) ** Decimal(2) / Decimal(4)\nn = Decimal(3)\n# print(*(180 * angle / pi for angle in angles))\nwhile n < 101 and any(k for k in (angle * n / pi for angle in angles) if abs(k - int(k + EPS)) >= EPS):\n # print(n, *(k for k in ((pi - angle) * n / Decimal(2) / pi for angle in angles)))\n n += 1\nprint(n * R_sq * Decimal(sin(Decimal(2) * pi / n)) / Decimal(2))\n"}, {"source_code": "from math import *\n\n\ndef mid_line((x1, y1), (x2, y2)):\n return x2-x1, y2-y1, (x1**2 - x2**2 + y1**2 - y2**2)/2.0\n\ndef intersect((a1, b1, c1), (a2, b2, c2)):\n d = a1*b2-b1*a2\n return (b1*c2-b2*c1)/d, (a2*c1-a1*c2)/d\n\ndef rot((x, y), (cx, cy), a):\n x, y, c, s = x-cx, y-cy, cos(a), sin(a)\n return (cx+x*c-y*s, cy+x*s+y*c)\n\ndef pt_in((x, y), pts):\n return any([abs(x-a)+abs(y-b) < 1.0e-4 for (a, b) in pts])\n\ndef area(pts):\n return abs(sum([(x1+x2)*(y2-y1)/2.0 for (x1, y1), (x2, y2) in zip(pts, pts[1:] + [pts[0]])]))\n\n\np1 = map(float, raw_input().split())\np2 = map(float, raw_input().split())\np3 = map(float, raw_input().split())\n\npc = intersect(mid_line(p1, p2), mid_line(p3, p2))\n\nfor n in xrange(3, 101):\n pts = [rot(p1, pc, i*2.0*pi/n) for i in xrange(n)]\n if pt_in(p1, pts) and pt_in(p2, pts) and pt_in(p3, pts):\n print area(pts)\n break\n"}, {"source_code": "from math import sqrt, sin, acos, pi\n\ndist_sq = lambda A, B: (A[0] - B[0])**2 + (A[1] - B[1])**2\n\ndef angle(R, A, B):\n c = dist_sq(A, B)\n a = dist_sq(R, B)\n b = dist_sq(R, A)\n cosine = round((a + b - c)/sqrt(4 * a * b), 8)\n return acos(cosine)\n\ndef circumcentre(A, B, C):\n a = dist_sq(B, C)\n b = dist_sq(A, C)\n c = dist_sq(A, B)\n bary = (\n a * (b + c - a),\n b * (c + a - b),\n c * (a + b - c),\n )\n x = (bary[0] * A[0] + bary[1] * B[0] + bary[2] * C[0])/sum(bary)\n y = (bary[0] * A[1] + bary[1] * B[1] + bary[2] * C[1])/sum(bary)\n return (x, y)\n\ndef div(m, n):\n m, n = max(m, n), min(m, n)\n return abs(round(m/n) - m/n) < 10**-4\n\ndef gcd(a, b):\n a, b = max(a, b), min(a, b)\n if div(a, b):\n return b\n else:\n return gcd(b, a-b)\n\nA = tuple(map(float, input().split()))\nB = tuple(map(float, input().split()))\nC = tuple(map(float, input().split()))\ncir = circumcentre(A, B, C)\nR = dist_sq(cir, A)\n\nangles = sorted([angle(cir, A, B), angle(cir, B, C), angle(cir, C, A)])\ngamma = gcd(angles[0], angles[1])\nfor i in range(1, 51):\n\tif(div(2*pi*i, gamma)):\n\t\tgamma /= i\n\t\tbreak\nprint(pi * R * sin(gamma)/gamma)"}, {"source_code": "from math import *\np =[list(map(float,input().split())) for i in range(3)]\na,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\nu=2*g(A,g(B,C))\nprint(round(R * R * pi / u * sin(u),7)) \n"}, {"source_code": "import math\n\ndef xyline(x1, y1, x2, y2):\n return (y1 - y2), (x2 - x1), -((x2 - x1) * y1 + (y1 - y2) * x1)\n\ndef sujick(a, b, c, x, y):\n\treturn b, -a, (a * y - b * x)\n\ndef kyojum(a1, b1, c1, a2, b2, c2):\n\treturn (-(c1 * b2 - b1 * c2) / (a1 * b2 - b1 * a2),\n\t\t-(a1 * c2 - c1 * a2) / (a1 * b2 - b1 * a2))\n\ndef oishim(x1,y1,x2,y2,x3,y3):\n\treturn kyojum(\n\t\t*sujick(*xyline(x1, y1, x2, y2), (x1 + x2) / 2, (y1 + y2) / 2),\n\t\t*sujick(*xyline(x1, y1, x3, y3), (x1 + x3) / 2, (y1 + y3) / 2))\n\ndef fgcd(a,b):\n\twhile math.fabs(b) > math.pi / 100:\n\t\ta, b = b, math.fmod(a, b)\n\treturn a\n\nx1,y1 = map(float, input().split())\nx2,y2 = map(float, input().split())\nx3,y3 = map(float, input().split())\n\nxoi, yoi = oishim(x1,y1,x2,y2,x3,y3)\nrad1 = math.atan2(y1-yoi, x1-xoi)\nrad2 = math.atan2(y2-yoi, x2-xoi)\nrad3 = math.atan2(y3-yoi, x3-xoi)\n\nangle = math.fabs(fgcd(fgcd(rad1-rad2, rad2-rad3), rad3-rad1))\nn = math.pi * 2 / angle\nnewn = n\nwhile math.fabs(newn - round(newn)) > 1e-2:\n\tnewn += n\nn = newn\nangle = math.pi * 2 / n\nresult = (((x1 - xoi) ** 2 + (y1 - yoi) ** 2) \n\t* math.sin(angle/2) * math.cos(angle/2) * n)\nprint('%.6f' % result)\n"}, {"source_code": "import math\nimport sys\n\na, b = map(float, input().split())\nc, d = map(float, input().split())\ne, f = map(float, input().split())\np = c - a\nq = d - b\nr = c*c + d*d - a*a - b*b\ns = e - a\nt = f - b\nu = e*e + f*f - a*a - b*b\ny0 = (p*u - r*s) / (2*(p*t - q*s))\nx0 = (r - 2*q*y0) / (2*p)\nradius = math.sqrt((x0 - a)**2 + (y0 - b)**2)\nprint(y0, x0, file=sys.stderr)\nprint(math.hypot(a - x0, b - y0), file=sys.stderr)\nprint(math.hypot(c - x0, d - y0), file=sys.stderr)\nprint(math.hypot(e - x0, f - y0), file=sys.stderr)\ndx = a - x0\ndy = b - y0\nangles = list(map(lambda t: math.atan2(*t),\n [ (b - y0, a - x0), (d - y0, c - x0), (f - y0, e - x0) ]))\nangle_i = (2 * math.pi + angles[1] - angles[0]) % (2 * math.pi)\nangle_j = (2 * math.pi + angles[2] - angles[0]) % (2 * math.pi)\nif angle_i > angle_j:\n angle_i, angle_j = angle_j, angle_i\nratio = angle_j / angle_i\nprint(angle_i, angle_j, ratio, file=sys.stderr)\n\nfor j in range(2, 101):\n for i in range(1, j):\n r = j / i\n if abs(r - ratio) > 1e-5:\n continue\n n = round(2 * math.pi * i / angle_i)\n slice = 2 * math.pi / n\n if abs(round(angle_i / slice) - angle_i / slice) > 1e-5:\n continue\n if abs(round(angle_j / slice) - angle_j / slice) > 1e-5:\n continue\n print(n, i, j, angle_i / slice, angle_j / slice, file=sys.stderr)\n area = radius ** 2 * n * \\\n math.sin(math.pi / n) * math.cos(math.pi / n)\n print(area)\n sys.exit()\n"}, {"source_code": "from math import sqrt, asin, pi, sin, cos\n\neps = 1e-6\n\ndef dist2(ax, ay, bx, by):\n return (ax-bx)**2 + (ay-by)**2\n\ndef cross_prod(ax, ay, bx, by):\n return ax*by - ay*bx\n\ndef inner_prod(ax, ay, bx, by):\n return ax*bx + ay*by\n\ndef find(x, y, s, c):\n for i in range(len(s)):\n if abs(x-s[i]) < eps and abs(y-c[i]) < eps:\n return True\n return False\n\ndef pool(x):\n if abs(x) < eps:\n return 1.\n if x < 0:\n return x/pi+2\n return x/pi\n\ndef main():\n Ax, Ay = map(float, input().split())\n Bx, By = map(float, input().split())\n Cx, Cy = map(float, input().split())\n\n #print(Ax, Ay, Bx, By, Cx, Cy)\n\n #for _ in range(n):\n # print(ans(input()))\n\n D = 2*(Ax*(By-Cy) + Bx*(Cy-Ay) + Cx*(Ay-By))\n Ox = ( (Ax**2+Ay**2)*(By-Cy) + (Bx**2+By**2)*(Cy-Ay) + (Cx**2+Cy**2)*(Ay-By) ) / D\n Oy = ( (Ax**2+Ay**2)*(Cx-Bx) + (Bx**2+By**2)*(Ax-Cx) + (Cx**2+Cy**2)*(Bx-Ax) ) / D\n\n R2 = dist2(Ox,Oy,Ax,Ay)\n #print(R)\n #print(Ox, Oy)\n #print(dist(Ox,Oy,Ax,Ay))\n #print(dist(Ox,Oy,Bx,By))\n #print(dist(Ox,Oy,Cx,Cy))\n s1 = cross_prod(Ax-Ox,Ay-Oy,Bx-Ox,By-Oy)/R2\n c1 = inner_prod(Ax-Ox,Ay-Oy,Bx-Ox,By-Oy)/R2\n s2 = cross_prod(Ax-Ox,Ay-Oy,Cx-Ox,Cy-Oy)/R2\n c2 = inner_prod(Ax-Ox,Ay-Oy,Cx-Ox,Cy-Oy)/R2\n\n #angle1 = pool(angle1)\n #angle2 = pool(angle2)\n \n #print([s1, s2])\n #print([c1, c2])\n\n for n in range(3, 101):\n x = list(range(n))\n for j in range(len(x)):\n x[j] = x[j] * (2*pi/n)\n s = list(map(sin, x))\n c = list(map(cos, x))\n #print(s)\n #print(c)\n #print(find(s1, c1, s, c))\n #print(find(s2, c2, s, c))\n if find(s1, c1, s, c) and find(s2, c2, s, c):\n area = .5*n*R2*sin(2*pi/n)\n print(\"%.8f\" % area)\n break\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/env python\n# kristof.jakab@gmail.com\n# -*- coding: utf-8 -*-\n\n# http://www.darrensun.com/codeforces-round-1/\n\n# ---------------------------------------\nimport math\n\n\n# ---------------------------------------\nclass Point(object):\n \"\"\" \"\"\"\n def __init__(self, x, y):\n self.x = x\n self.y = y\n self.vabs = math.sqrt(x ** 2 + y ** 2)\n\n\nclass Line(object):\n \"\"\" \"\"\"\n def __init__(self, A, B):\n self.direction = Point(B.x - A.x, B.y - A.y)\n self.length = math.sqrt((B.x - A.x) ** 2 + (B.y - A.y) ** 2)\n\n\nclass Angle(object):\n \"\"\" \"\"\"\n def __init__(self, vertex, point_1, point_2):\n self.opposite = Line(point_1, point_2).length\n self.ray_1 = Line(vertex, point_1).length\n self.ray_2 = Line(vertex, point_2).length\n self.calculate_angle()\n\n def calculate_angle(self): # law of cosines\n numr = self.ray_1 ** 2 + self.ray_2 ** 2 - self.opposite ** 2\n denr = 2 * self.ray_1 * self.ray_2\n self.angle = math.acos(numr / denr)\n\n\nclass Triangle(object):\n \"\"\" \"\"\"\n def __init__(self, A=None, B=None, C=None):\n # vertices\n self.A = A\n self.B = B\n self.C = C\n # sides\n self.a = Line(B, C).length\n self.b = Line(A, C).length\n self.c = Line(A, B).length\n # angles\n self.alpha = Angle(A, B, C).angle\n self.beta = Angle(B, A, C).angle\n self.gamma = Angle(C, A, B).angle\n # radius of circumscribed circle\n self.R = self.calculate_R()\n\n def calculate_R(self): # Heron's formula\n s = (self.a + self.b + self.c) / 2\n A = math.sqrt(s * (s-self.a) * (s-self.b) * (s - self.c))\n return (self.a * self.b * self.c) / (4 * A)\n\n\n# ---------------------------------------\ndef gcd(p, q): # Greatest Common Divisor\n while(math.fabs(p) > 0.0001 and math.fabs(q) > 0.0001):\n # print p, q\n if p > q:\n p -= math.floor(p / q) * q\n else:\n q -= math.floor(q / p) * p\n return p + q\n\n\n# ----------------------------------------\ndef main():\n A = Point(*map(float, raw_input().split()))\n B = Point(*map(float, raw_input().split()))\n C = Point(*map(float, raw_input().split()))\n\n triangle = Triangle(A, B, C)\n\n # calculate least number of vertices\n n = math.pi / gcd(gcd(triangle.alpha, triangle.beta), triangle.gamma)\n\n # area of polygon\n print \"%.6f\" % float(n / 2 * (triangle.R ** 2) * math.sin(2 * math.pi / n))\n\n return 0\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nimport sys\n\na, b = map(float, input().split())\nc, d = map(float, input().split())\ne, f = map(float, input().split())\np = c - a\nq = d - b\nr = c*c + d*d - a*a - b*b\ns = e - a\nt = f - b\nu = e*e + f*f - a*a - b*b\ny0 = (p*u - r*s) / (2*(p*t - q*s))\nx0 = (r - 2*q*y0) / (2*p)\nradius = math.sqrt((x0 - a)**2 + (y0 - b)**2)\nprint(y0, x0, file=sys.stderr)\nprint(math.hypot(a - x0, b - y0), file=sys.stderr)\nprint(math.hypot(c - x0, d - y0), file=sys.stderr)\nprint(math.hypot(e - x0, f - y0), file=sys.stderr)\ndx = a - x0\ndy = b - y0\nangles = list(map(lambda t: math.atan2(*t),\n [ (b - y0, a - x0), (d - y0, c - x0), (f - y0, e - x0) ]))\nangle_i = (2 * math.pi + angles[1] - angles[0]) % (2 * math.pi)\nangle_j = (2 * math.pi + angles[2] - angles[0]) % (2 * math.pi)\nif angle_i > angle_j:\n angle_i, angle_j = angle_j, angle_i\nratio = angle_j / angle_i\nprint(angle_i, angle_j, ratio, file=sys.stderr)\n\nfor n in range(3, 101):\n slice = 2 * math.pi / n\n if abs(round(angle_i / slice) - angle_i / slice) > 1e-5:\n continue\n if abs(round(angle_j / slice) - angle_j / slice) > 1e-5:\n continue\n for j in range(2, n + 1):\n for i in range(1, j):\n r = j / i\n if abs(r - ratio) > 1e-5:\n continue\n print(n, i, j, angle_i / slice, angle_j / slice, file=sys.stderr)\n area = radius ** 2 * n * \\\n math.sin(math.pi / n) * math.cos(math.pi / n)\n print(area)\n sys.exit()\n"}, {"source_code": "from math import *\ndef g(x,y):\n if y<1e-3:\n return x\n else:\n return g(y,fmod(x,y))\np=[list(map(float,input().split())) for i in range(3)]\na,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\nu=2*g(A,g(B,C))\nprint(round(R*R*pi/u*sin(u),7))"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom itertools import combinations\nfrom math import acos, fmod, hypot, pi, sin\n# import pytest\n\n\ndef main():\n coordinates = [list(map(float, input().split())) for i in range(3)]\n points = [Point(i, j) for [i, j] in coordinates]\n polygon = CyclicPolygon(points)\n print(str(round(polygon.area_of_smallest_regular_polygon(), 6)))\n\n\ndef gcd(v1, v2):\n \"\"\" greatest common divisor \"\"\"\n return v1 if v2 < 1e-3 else gcd(v2, fmod(v1, v2))\n\n\nclass Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n def __eq__(self, other):\n if self.x == other.x and self.y == other.y:\n return True\n else:\n return False\n\n def __str__(self):\n return str(self.x) + \",\" + str(self.y) + \" \"\n\n def distance_to(self, point):\n return hypot(self.x - point.x, self.y - point.y)\n\n def angle_to(self, point_a, point_b):\n a_length = self.distance_to(point_a)\n b_length = self.distance_to(point_b)\n c_length = point_a.distance_to(point_b)\n angle = acos((a_length**2 + b_length**2 - c_length**2) /\n (2 * a_length * b_length))\n return angle\n\n def bisector_line(self, point):\n try:\n m = - (self.x - point.x) / (self.y - point.y)\n except ZeroDivisionError:\n m = float(\"inf\")\n midpoint = Point(((self.x + point.x) / 2), ((self.y + point.y) / 2))\n c = midpoint.y - m*midpoint.x\n return Line(m, c)\n\n\nclass Line:\n def __init__(self, m, c):\n self.m = m\n self.c = c\n\n def concurrent_point(self, line):\n x = (self.c - line.c) / (self.m - line.m)\n y = self.m * (line.c - self.c)/(self.m - line.m) + self.c\n return Point(x, y)\n\n def has_concurrent_point(self, line):\n return True if self.m != line.m else False\n\n\nclass CyclicPolygon:\n def __init__(self, points):\n if self.are_cyclic(points):\n self.points = points\n else:\n raise ValueError\n\n def all_angles(self):\n angles = []\n for c in combinations(self.points, 3):\n angles.append(c[0].angle_to(c[1], c[2]))\n angles.append(c[1].angle_to(c[0], c[2]))\n angles.append(c[2].angle_to(c[0], c[1]))\n return set(angles)\n\n def are_cyclic(self, points):\n center = None\n for c in combinations(points, 3):\n l1 = c[0].bisector_line(c[1])\n l2 = c[0].bisector_line(c[2])\n concurrent_point = l1.concurrent_point(l2)\n # floating point equality test?\n if center is None or center == concurrent_point:\n center = concurrent_point\n else:\n return False\n return True\n\n def circumradius(self):\n A = self.points[0].angle_to(self.points[1], self.points[2])\n a = self.points[1].distance_to(self.points[2])\n return 0.5*(a/sin(A))\n\n def area_of_smallest_regular_polygon(self):\n angles = self.all_angles()\n divisor = angles.pop()\n while len(angles) > 0:\n divisor = gcd(angles.pop(), divisor)\n sides = round(pi / divisor)\n return 0.5 * sides * self.circumradius()**2 * sin(2*pi / sides)\n\nif __name__ == '__main__':\n main()\n\n\ndef test_gcd():\n assert(gcd(8, 4) == 4)\n assert(gcd(12, 9) == 3)\n assert(gcd(9, 12) == 3)\n\n\nclass TestPoint:\n def test_constructor_assignment(self):\n p = Point(1, 2)\n assert(p.x == 1 and p.y == 2)\n\n def test_distance_to(self):\n p1 = Point(3, 4)\n p2 = Point(0, 0)\n assert(p1.distance_to(p2) == 5)\n\n def test_angle_to(self):\n p1 = Point(0, 0)\n p2 = Point(1, 0)\n p3 = Point(0, 1)\n assert(abs(p1.angle_to(p2, p3) - pi/2) < 1e-3)\n\n def test_bisector_line(self):\n p1 = Point(0, 1)\n p2 = Point(1, 0)\n l = p1.bisector_line(p2)\n assert(l.m == 1)\n assert(l.c == 0)\n\n\nclass TestLine:\n def test_concurrent_point(self):\n l1 = Line(1, 0)\n l2 = Line(-1, 0)\n assert(l1.concurrent_point(l2).x == 0 and\n l1.concurrent_point(l2).y == 0)\n\n def test_has_concurrent_point(self):\n l1 = Line(1, 0)\n l2 = Line(1, 1)\n l3 = Line(2, 1)\n assert(not l1.has_concurrent_point(l2))\n assert(l1.has_concurrent_point(l3))\n\n\nclass TestCyclicPolygon:\n\n p1 = Point(0, 0)\n p2 = Point(1, 0)\n p3 = Point(0, 1)\n p4 = Point(1, 1)\n p5 = Point(5, 2)\n p6 = Point(7, 6)\n p7 = Point(8, 2)\n p8 = Point(10, 12)\n p9 = Point(15, 18)\n\n t1 = CyclicPolygon([p1, p2, p3])\n t2 = CyclicPolygon([p4, p5, p6])\n t3 = CyclicPolygon([p7, p8, p9])\n\n def test_valid_construction(self):\n p1 = Point(1, 0)\n p2 = Point(5, 19)\n p3 = Point(7, -22)\n CyclicPolygon([p1, p2, p3])\n\n def test_invalid_construction(self):\n p1 = Point(1, 0)\n p2 = Point(5, 19)\n p3 = Point(7, -22)\n p4 = Point(3, -22)\n p5 = Point(1, -10)\n with pytest.raises(ValueError):\n CyclicPolygon([p1, p2, p3, p4, p5])\n\n def test_all_angles(self):\n angles = sorted(self.t1.all_angles())\n assert(angles[0] - pi/4 < 1e-3)\n assert(angles[1] - pi/2 < 1e-3)\n angles = sorted(self.t2.all_angles())\n angles = sorted(self.t3.all_angles())\n\n def test_circumradius(self):\n assert(self.t1.circumradius() - hypot(0.5, 0.5) < 1e-3)\n\n def test_area_of_smallest_regular_polygon(self):\n assert(self.t1.area_of_smallest_regular_polygon() - 1 < 1e-3)\n"}, {"source_code": "import math\n\n\n\ndef gcd(a,b):\n\n\tif b < 1e-3:\n\n\t\treturn a\n\n\telse:\n\n\t\treturn gcd(b,math.fmod(a,b))\n\n\n\n\n\np=[[float(x) for x in raw_input().split(' ')] for y in range(0,3)]\n\na,b,c=[math.hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[1],p[2]),(p[0],p[2])]]\n\nA,B,C=[math.acos((a*a+b*b-c*c)/(2*a*b)) for a,b,c in [(b,c,a),(a,c,b),(a,b,c)]]\n\nr=a/(2*math.sin(A))\n\nang=2*gcd(A,gcd(B,C))\n\nans=2*math.acos(-1)/ang*1/2*r*r*math.sin(ang)\n\nprint(round(ans,12))"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\n# C. Ancient Berland Circus\n# time limit per test2 seconds\n# memory limit per test64 megabytes\n# inputstandard input\n# outputstandard output\n# Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.\n\n# In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a special pillar, and the rope strung between the pillars marked the arena edges.\n\n# Recently the scientists from Berland have discovered the remains of the ancient circus arena. They found only three pillars, the others were destroyed by the time.\n\n# You are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.\n\n# Input\n# The input file consists of three lines, each of them contains a pair of numbers \u2013\u2013 coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point.\n\n# Output\n# Output the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100.\n\n# Sample test(s)\n# input\n# 0.000000 0.000000\n# 1.000000 1.000000\n# 0.000000 1.000000\n# output\n# 1.00000000\n\nimport math\n\n# \u6700\u5927\u516c\u7ea6\u6570\ndef gcd(a, b):\n\tif a > b:\n\t\ta, b = b, a\n\twhile b > 0:\n\t\tb = b % a\n\treturn a\n\n# \u5df2\u77e5(x1, y1)\u548c(x2, y2)\u6c42\u8fc7\u8be5\u4e24\u70b9\u7684\u76f4\u7ebf\u65b9\u7a0bAx + By + C = 0\ndef point2line(x1, y1, x2, y2):\n\txm = (float(x1) + x2) / 2\n\tym = (float(y1) + y2) / 2\n\tif x1 == x2:\n\t\tA = 0\n\t\tB = 1\n\t\tC = -ym\n\telif y1 == y2:\n\t\tA = 1\n\t\tB = 0\n\t\tC = -xm\n\telse:\n\t\tA = (x2 - x1)\n\t\tB = (y2 - y1)\n\t\tC = (x1 - x2) * xm - (y2 - y1) * ym\n\treturn A, B, C\n\n# \u5df2\u77e5\u4e24\u76f4\u7ebf\u7684\u4e00\u822c\u5f0f\u65b9\u7a0b\uff0c\u6c42\u4ea4\u70b9\ndef linecross(A1, B1, C1, A2, B2, C2):\n\tif A1 == 0:\n\t\tyr = -float(C1) / B1\n\t\txr = -(B2 * yr + C2) / A2\n\telse:\n\t\tyr = (float(A2) * C1 - A1 * C2) / (A1 * B2 - A2 * B1)\n\t\txr = -(B1 * yr + C1) / A1\n\treturn xr, yr\n\n# \u5df2\u77e5\u4e24\u5411\u91cf\uff0c\u6c42\u5939\u89d2\u7684\u4f59\u5f26\ndef vectorcos(x1, y1, x2, y2):\t\n\tnorm1 = math.sqrt(x1 * x1 + y1 * y1) \n\tnorm2 = math.sqrt(x2 * x2 + y2 * y2)\n\treturn (x1 * x2 + y1 * y2) / (norm1 * norm2)\n\n\nx = [0, 0, 0]\ny = [0, 0, 0]\nmidx = [0, 0]\nmidy = [0, 0]\nA = [0, 0]\nB = [0, 0]\nC = [0, 0]\nx[0], y[0] = map(float, raw_input().split(\" \"))\nx[1], y[1] = map(float, raw_input().split(\" \"))\nx[2], y[2] = map(float, raw_input().split(\" \"))\nfor i in range(2):\n\tA[i], B[i], C[i] = point2line(x[i], y[i], x[i + 1], y[i + 1])\nrx, ry = linecross(A[0], B[0], C[0], A[1], B[1], C[1])\n\nx.append(x[0])\ny.append(y[0])\nmintheta = 1e15\nr2 = (x[0] - rx) * (x[0] - rx) + (y[0] - ry) * (y[0] - ry)\ntheta = []\nfor i in range(3):\n\tv1x = x[i] - rx\n\tv1y = y[i] - ry\n\tv2x = x[i + 1] - rx\n\tv2y = y[i + 1] - ry\n\tcostheta = vectorcos(v1x, v1y, v2x, v2y)\n\ttheta.append(math.acos(costheta))\n\tif theta[i] < mintheta:\n\t\tmintheta = theta[i]\n\ndiv = 1\nwhile 1:\n\tltheta = mintheta / div\n\tcanbediv = True\n\tfor i in range(3):\n\t\tdivi = theta[i] / ltheta\n\t\tif abs(round(divi) - divi) > 1e-4:\n\t\t\tcanbediv = False\n\t\t\tbreak\n\n\t\tdivi = (2 * math.pi - theta[i]) / ltheta\n\t\tif abs(round(divi) - divi) > 1e-4:\n\t\t\tcanbediv = False\n\t\t\tbreak\n\tif canbediv:\n\t\tbreak\n\telse:\n\t\tdiv += 1\npoly = int(round(math.pi / mintheta * 2 * div))\n\narea = poly * r2 * math.sin(mintheta / div) / 2\nprint(area)\n"}, {"source_code": "from sys import stdin,stdout\nimport math\nimport fractions\ndef gcd(a,b):\n if b<1e-3:\n return a\n else:\n return gcd(b,math.fmod(a,b))\nx1,y1=[float(x)for x in stdin.readline().rstrip().split()]\nx2,y2=[float(x)for x in stdin.readline().rstrip().split()]\nx3,y3=[float(x)for x in stdin.readline().rstrip().split()]\na=math.hypot(x2-x3,y2-y3)\nb=math.hypot(x1-x3,y1-y3)\nc=math.hypot(x1-x2,y1-y2)\ns=(a+b+c)/2\nar=math.sqrt(s*(s-a)*(s-b)*(s-c))\nR=a*b*c/4/ar\nA=math.acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c))\nB=math.acos((pow(c,2)+pow(a,2)-pow(b,2))/(2*c*a))\nC=math.acos((pow(a,2)+pow(b,2)-pow(c,2))/(2*a*b))\nangle=gcd(A,gcd(B,C))\nstdout.write(str(pow(R,2)*math.sin(2*angle)*math.pi/angle/2)+'\\n')\n"}, {"source_code": "import math\n\nclass Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\ndef circle(p1, p2, p3):\n # http://blog.csdn.net/lijiayu2015/article/details/52541730\n# A1 = 2 * p2.x - 2 * p1.x\n# A2 = 2 * p3.x - 2 * p2.x\n# B1 = 2 * p1.y - 2 * p2.y\n# B2 = 2 * p2.y - 2 * p3.y\n# C1 = p1.y ** 2 + p2.x ** 2 - p1.x ** 2 - p2.y ** 2\n# C2 = p2.y ** 2 + p3.x ** 2 - p2.x ** 2 - p3.y ** 2\n \n# temp = A1 * B2 - A2 * B1\n \n# print(p1, p2, p3)\n# print(A1, A2, B1, B2, C1, C2, temp)\n \n \n x21 = p2.x - p1.x\n x31 = p3.x - p1.x\n y21 = p2.y - p1.y\n y31 = p3.y - p1.y\n M1 = p1.x ** 2 + p1.y ** 2 - p2.x ** 2 - p2.y ** 2\n M2 = p1.x ** 2 + p1.y ** 2 - p3.x ** 2 - p3.y ** 2\n \n x = (y21 * M2 - y31 * M1) / 2 / (y31 * x21 - y21 * x31)\n y = (x21 * M2 - x31 * M1) / 2 / (x31 * y21 - x21 * y31)\n\n# x = (C1 * B2 - C2 * B1) / temp\n# y = (A1 * C2 - A2 * C1) / temp\n \n return x, y\n\ndef calAngle(center, p1, p2):\n va = Point(p1.x - center.x, p1.y - center.y)\n vb = Point(p2.x - center.x, p2.y - center.y)\n \n la = (va.x ** 2 + va.y ** 2) ** 0.5\n lb = (vb.x ** 2 + vb.y ** 2) ** 0.5\n \n cosAngle = round((va.x * vb.x + va.y * vb.y) / (la * lb), 6)\n angle = math.acos(cosAngle) * 180 / math.pi\n return angle\n\ndef isMultiple(a, b):\n c = a / b\n# print(c - int(c))\n return abs(c - round(c)) < 0.001\n\ndef solve(p1, p2, p3):\n center = Point(*circle(p1, p2, p3))\n# print(center.x, center.y)\n a1 = calAngle(center, p1, p2)\n a2 = calAngle(center, p1, p3)\n a3 = calAngle(center, p2, p3)\n# print(a1, a2, a3)\n \n for n in range(3, 101):\n angle = 360 / n\n# print(n, angle)\n if all(isMultiple(a, angle) for a in (a1, a2, a3)):\n break\n v1 = Point(center.x - p1.x, center.y - p1.y)\n radius = (v1.x ** 2 + v1.y ** 2) ** 0.5\n area = 0.5 * radius * radius * math.sin(angle * math.pi / 180)\n area *= n\n return area\n\np1 = Point(*map(float, input().split()))\np2 = Point(*map(float, input().split()))\np3 = Point(*map(float, input().split()))\nprint(solve(p1, p2, p3))"}, {"source_code": "from math import*\np=[map(float,raw_input().split()) for i in range(3)]\na,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\nu=2*g(A,g(B,C))\nprint R*R*pi/u*sin(u)\n"}, {"source_code": "x1, y1 = map(float, raw_input().split())\nx2, y2 = map(float, raw_input().split())\nx3, y3 = map(float, raw_input().split())\nimport math\n##x1 = 71.756151; y1 = 7.532275\n##x2 = -48.634784; y2 = 100.159986\n##x3 = 91.778633; y3 = 158.107739\n\n##x1 = 0.0; y1 = 0.0\n##x2 = 0.0; y2 = 1.0\n##x3 = math.sqrt(3); y3 = 1.0\n\nEPSILON = 0.00001\ndef midPoint(x1, y1, x2, y2):\n mid_x = (x1 + x2) / 2\n mid_y = (y1 + y2) / 2\n return (mid_x, mid_y)\n\ndef slope_mid_perpend(x1, y1, x2, y2):\n return -1 * (x2 - x1) / (y2 - y1)\n\ndef distance(x1, y1, x2, y2):\n return math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2)\n\ndef circleCenter(x1, y1, x2, y2, x3, y3):\n x12, y12 = midPoint(x1, y1, x2, y2)\n x13, y13 = midPoint(x1, y1, x3, y3)\n if y1 == y2:\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n x0 = x12\n y0 = k_mid_13 * (x0 - x13) + y13\n elif y1 == y3:\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n x0 = x13\n y0 = k_mid_12 * (x0 - x12) + y12\n else:\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n x0 = (y13 - y12 + k_mid_12*x12 - k_mid_13*x13) / (k_mid_12 - k_mid_13)\n y0 = k_mid_13 * (x0 - x13) + y13\n return x0, y0\nx0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\ndef angle(distance1, distance2):\n angle = math.asin((distance1/2) / distance2)\n return 2 * angle\nd_12 = distance(x1, y1, x2, y2)\nd_13 = distance(x1, y1, x3, y3)\nd_32 = distance(x3, y3, x2, y2)\n##print d_12, d_13, d_32\nr = distance(x1, y1, x0, y0)\n\nangle1O2 = angle(d_12, r)\nangle1O3 = angle(d_13, r)\nangle3O2 = angle(d_32, r)\n##print angle1O2, angle1O3, angle3O2\n\n##print angle1O2, angle1O3, angle3O2\n##\n##print angle(math.sqrt(2), 1)\n\ndef isRemainder(angle, angle_N):\n remainder = angle % angle_N\n## print remainder\n \n if (abs(remainder - 0)<= EPSILON) or (abs(remainder - angle_N) <= EPSILON):\n return True\n else:\n return False\n \ndef find_N(angle1, angle2, angle3):\n N = 3\n while 1:\n## print angle1, angle1, angle3\n angle_N = 2 * math.pi / N\n## print 'angle_N', angle_N\n## remainder1 = angle1 % angle_N\n## remainder2 = angle2 % angle_N\n## remainder3 = angle3 % angle_N\n## print remainder1, remainder2, remainder3\n if (isRemainder(angle1, angle_N) and isRemainder(angle2, angle_N) and\n isRemainder(angle2, angle_N)):\n break\n N += 1\n \n return N\nN = find_N(angle1O2, angle1O3, angle3O2)\ndef area_N(N):\n angle = 2 * math.pi / N\n area = N * 0.5 * r * r * math.sin(angle)\n return area\n\nprint area_N(N)\n \n \n\n\n##print angle1O3, 2 * math.pi / 6\n##print angle1O3 % (2 * math.pi / 6)\n\n\n\n\n## test\n##print circleCenter(x1, y1, x2, y2, x3, y3)\n##\n##import math\n##\n##x0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\n##print distance(x0, y0, x1, y1), distance(x0, y0, x2, y2), distance(x0, y0, x2, y2)\n\n\n\n\n\n\n\n\n"}, {"source_code": "import math\nimport time\nA=list(map(float,input().split()))\nB=list(map(float,input().split()))\nC=list(map(float,input().split()))\nm=[((A[0]-B[0])**2+(A[1]-B[1])**2)**0.5,((C[0]-B[0])**2+(C[1]-B[1])**2)**0.5,((A[0]-C[0])**2+(A[1]-C[1])**2)**0.5]\ngamma=math.acos((m[0]**2+m[1]**2-m[2]**2)/(2*m[0]*m[1]))\nR=0.5*m[2]/math.sin(gamma)\nl=[math.pi/math.asin(0.5*m[1]/R),math.pi/math.asin(0.5*m[0]/R),math.pi/gamma]\nx=3\nwhile True:\n if (round(x/l[0],2)==round(x/l[0],0) and round(x/l[1],2)==round(x/l[1],0) and round(x/l[2],2)==round(x/l[2],0)):\n y=x\n break\n x += 1\nprint(y*0.5*(R**2)*math.sin(2*math.pi/y))\n"}, {"source_code": "from math import pi, fmod, fabs, atan2, sin\n\npi2 = 2.0 * pi\nmin_angle = pi2 / 100.0\neps_deeps = 3\neps = 1.0 / pow(10.0, eps_deeps)\n\ndef nod(n, m):\n if n < min_angle / 2.0:\n return m\n else:\n return nod(fmod(m, n), n)\n\nx1, y1 = map(float, raw_input().split())\nx2, y2 = map(float, raw_input().split())\nx3, y3 = map(float, raw_input().split())\n\n# Find normals at centers of [(x1, y1)-(x2, y2)] and [(x2, y2)-(x3, y3)]\nif y1 - y2 != 0.0:\n an12 = (x2 - x1) / (y1 - y2)\n bn12 = (y1 + y2) / 2.0 - an12 * (x1 + x2) / 2.0\nelse:\n an12 = None\n bn12 = (x1 + x2) / 2.0\nif y2 - y3 != 0.0:\n an23 = (x3 - x2) / (y2 - y3)\n bn23 = (y2 + y3) / 2.0 - an23 * (x2 + x3) / 2.0\nelse:\n an23 = None\n bn23 = (x2 + x3) / 2.0\n\n# Intersection of normals is circle center.\nif an12 is not None and an23 is not None:\n x0 = (bn23 - bn12) / (an12 - an23)\n y0 = an12 * x0 + bn12\nelif an12 is None:\n x0 = bn12\n y0 = an23 * x0 + bn23\nelse:\n x0 = bn23\n y0 = an12 * x0 + bn12\n\n# Relocate center to (0, 0)\nx1 -= x0\ny1 -= y0\nx2 -= x0\ny2 -= y0\nx3 -= x0\ny3 -= y0\n\n# Find radius\nr2 = x2 * x2 + y2 * y2\n\n# Calculate angles\nangle1 = atan2(y1, x1)\nangle2 = atan2(y2, x2)\nangle3 = atan2(y3, x3)\n\nangle12 = fabs(angle1 - angle2)\nangle23 = fabs(angle2 - angle3)\nangle13 = fabs(angle1 - angle3)\n\n# Find angle between radiuses to nearby vertices\nside_angle = nod(*sorted((nod(*sorted((angle12, angle23))), angle13)))\n\nmodulo = fmod(pi2 / side_angle + eps / 2.0, 1.0) - eps / 2.0\nif fabs(modulo) > eps:\n for i in xrange(1, 102):\n if fmod(round(i / modulo, eps_deeps), 1.0) < eps:\n break\n side_angle *= modulo / i\n if side_angle < min_angle:\n side_angle = min_angle\n\n# Find n of our n-gon\nn = round(pi2 / side_angle)\n\n# Finally calculate n-gon area\ns = n * r2 * sin(pi2 / n) / 2.0\n\nprint \"{0:.8f}\".format(s)\n"}, {"source_code": "from math import *\n\ndef gcd_new (p, q):\n if (q < 1e-4):\n return p\n return gcd_new(q, fmod(p, q))\n\nx1, y1 = map(float, raw_input().split())\nx2, y2 = map(float, raw_input().split())\nx3, y3 = map(float, raw_input().split())\n\na = sqrt((x1 - x2)**2 + (y1 - y2)**2)\nb = sqrt((x2 - x3)**2 + (y2 - y3)**2)\nc = sqrt((x3 - x1)**2 + (y3 - y1)**2)\ns = float(a + b + c)/2\nL = sqrt(s*(s - a)*(s - b)*(s - c))\nr = float(a*b*c)/float(4*L)\n\naa = float(acos(float(b**2 + c**2 - a**2)/float(2*b*c)))\nbb = float(acos(float(c**2 + a**2 - b**2)/float(2*c*a)))\ncc = float(acos(float(a**2 + b**2 - c**2)/float(2*a*b)))\nn = pi/gcd_new(aa, gcd_new(bb, cc))\nans = float(n*r*r*sin(float(2*pi)/n))/2\n\nprint (ans)\n"}, {"source_code": "__author__ = 'asmn'\nfrom math import sqrt, atan2, pi, sin\nfrom functools import reduce\n\nx, y = [0] * 3, [0] * 3\nfor i in range(3):\n x[i], y[i] = tuple(map(float, input().split()))\n\n\ndef center(x, y, n):\n return (sum(x[i] * x[i] * (y[i - 1] - y[i - 2]) for i in range(3)) + (y[0] - y[1]) * (y[1] - y[2]) * (\n y[2] - y[0])) / sum(2 * x[i] * (y[i - 1] - y[i - 2]) for i in range(3))\n\n\ncx, cy = center(x, y, 3), center(y, x, 3)\n\nr = sqrt((x[1] - cx) ** 2 + (y[1] - cy) ** 2)\n\nth = list(map(lambda x, y: atan2(y - cy, x - cx), x, y))\n\n\ndef check(na, a):\n k = na / a\n return abs(k - round(k)) < 1e-4\n\n\nfor n in range(3, 101):\n if check(th[2] - th[0], 2 * pi / n) and check(th[1] - th[0], 2 * pi / n):\n print(n * r * r * sin(2 * pi / n) / 2)\n break\n\n\n\n"}, {"source_code": "from math import hypot,acos,pi,sin,fmod\n\ndef gcd(a,b):\n if b<pi/100: return a\n return gcd(b,fmod(a,b))\n\np=[map(float,raw_input().split()) for i in range(3)]\n\na,b,c=[hypot(x[0]-y[0],x[1]-y[1]) for x,y in[(p[0],p[1]),(p[1],p[2]),(p[2],p[0])]]\nua,ub,uc=[acos((y**2+z**2-x**2)/(2*y*z)) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\n\nR=a/(2*sin(ua))\nu=2*gcd(ua,gcd(ub,uc))\n\nprint R**2*pi/u*sin(u)"}, {"source_code": "from math import *\n\ndef gcd(a, b): return a if b < pi/100 else gcd(b, fmod(a, b))\n\np = [map(float, raw_input().split()) for i in xrange(3)]\na, b, c = [hypot((x2-x1), (y2-y1)) for (x1, y1), (x2, y2) in [(p[0], p[1]), (p[1], p[2]), (p[2], p[0])]]\nta, tb, tc = [acos((y*y+z*z-x*x)/2.0/y/z) for x, y, z in [(a, b, c), (b, c, a), (c, a, b)]]\nR = a/2.0/sin(ta)\nt = 2.0*gcd(ta, gcd(tb, tc))\nprint R**2*pi/t*sin(t)\n"}, {"source_code": "import math\n\n\nx1, y1 = map(float, input().split())\nx2, y2 = map(float, input().split())\nx3, y3 = map(float, input().split())\n\ndef compute_triangle_area(x1, y1, x2, y2, x3, y3):\n return abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / 2\n\na, b, c = (math.hypot(x2 - x1, y2 - y1),\n math.hypot(x3 - x2, y3 - y2),\n math.hypot(x1 - x3, y1 - y3))\nR = (a * b * c / (4 * compute_triangle_area(x1, y1, x2, y2, x3, y3)))\nA, B, C = (math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c)),\n math.acos((a ** 2 + c ** 2 - b ** 2) / (2 * a * c)),\n math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b)))\n\ndef float_gcd(a, b, tol = 1e-04):\n t = min(abs(a), abs(b))\n while abs(b) > tol:\n a, b = b, a % b\n return a\n\nn = math.pi / float_gcd(float_gcd(A, B), C)\nS = n * R ** 2 * math.sin(2 * math.pi / n) / 2\n\nprint(S)"}, {"source_code": "import math\ndef dist(x1, y1, x2, y2):\n return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)\ndef angle(a, b, c):\n return math.acos((a * a + b * b - c * c) / (2 * a * b))\ndef f(a, b):\n if b > a:\n return f(b, a)\n if abs(b) < 1 / 10000:\n return a\n else:\n k = int(a / b)\n a -= k * b;\n return f(b, a)\nx = [0] * 3\ny = [0] * 3\nlen = [0] * 3\nang = [0] * 3\nfor i in range(3):\n x[i], y[i] = map(float, input().split())\nfor i in range(3):\n len[i] = dist(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3])\nlen.sort()\nfor i in range(3):\n ang[i] = angle(len[i], len[(i + 1) % 3], len[(i + 2) % 3])\nang.sort()\nan = f(f(ang[0], ang[1]), ang[2]) * 2\nn = 2 * math.pi / an\na = len[0] * math.sin(an / 2) / math.sin(ang[0])\ns = n * a * a / (4 * math.tan(an / 2))\nprint(\"%.9f\" % (s))\n\n#71.756151 7.532275\n#-48.634784 100.159986\n#91.778633 158.107739\n"}, {"source_code": "from math import*\np=[map(float,raw_input().split()) for i in range(3)]\na,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\nu=2*g(A,g(B,C))\nprint R*R*pi/u*sin(u)\n"}, {"source_code": "import math\nfrom fractions import Fraction\nline = input()\ndata = line.split()\nx1, y1 = float(data[0]), float(data[1])\nline = input()\ndata = line.split()\nx2, y2 = float(data[0]), float(data[1])\nline = input()\ndata = line.split()\nx3, y3 = float(data[0]), float(data[1])\ndis12 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)\ndis23 = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)\ndis13 = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)\n'''\nprint(dis12)\nprint(dis13)\nprint(dis23)\n'''\ncos1 = (dis13 + dis12 - dis23) / (2 * math.sqrt(dis12 * dis13))\ncos2 = (dis23 + dis12 - dis13) / (2 * math.sqrt(dis23 * dis12))\ncos3 = (dis13 + dis23 - dis12) / (2 * math.sqrt(dis13 * dis23))\n'''\nprint('*',cos1)\nprint('*',cos2)\nprint('*',cos3)\n'''\nangle1 = math.acos(cos1) * 2\nangle2 = math.acos(cos2) * 2\nangle3 = math.acos(cos3) * 2\n'''\nprint('#',angle1)\nprint('#',angle2)\nprint('#',angle3)\n'''\nnumber1 = Fraction.from_float(angle1 / angle2).limit_denominator(101)\n#print(number1.numerator)\n#print(number1.denominator)\nl1 = angle1 / number1.numerator\n#print(l1)\nn1 = 2 * math.pi / l1\nn1_int = int(n1 + 0.5)\n#print(n1_int)\n\nnumber2 = Fraction.from_float(angle1 / angle3).limit_denominator(101)\n#print(number2.numerator)\n#print(number2.denominator)\nl2 = angle1 / number2.numerator\n#print(l2)\nn2 = 2 * math.pi / l2\nn2_int = int(n2 + 0.5)\n#print(n2_int)\n\nif abs(n1_int - n1) < abs(n2_int - n2):\n n = n1_int\nelse:\n n = n2_int\n\nsin1 = math.sqrt(1 - cos1 * cos1)\n#print(sin1)\n#print(dis23)\nr = math.sqrt(dis23) / (2 * sin1)\n#print(r)\narea = 1 / 2 * n * math.sin(2 * math.pi / n) * r * r\nprint('%.6f' % area)\n"}, {"source_code": "import math\nimport sys\n\neps = 1e-4\n\ndef gcd(x, y):\n while (abs(x) > eps and abs(y) > eps):\n if (x>y):\n x -= math.floor(x/y) * y\n else:\n y -= math.floor(y/x) * x\n return x+y\n\nclass Coordinate:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\nA = Coordinate(*map(float, raw_input().split()))\nB = Coordinate(*map(float, raw_input().split()))\nC = Coordinate(*map(float, raw_input().split()))\n\na = math.sqrt((B.x-C.x)**2 + (B.y-C.y)**2)\nb = math.sqrt((A.x-C.x)**2 + (A.y-C.y)**2)\nc = math.sqrt((A.x-B.x)**2 + (A.y-B.y)**2)\n\ns = (a+b+c)/2\nT = math.sqrt(s*(s-a)*(s-b)*(s-c))\n\nR = a*b*c / (4*T)\n\na_A = math.acos((b*b+c*c-a*a)/(2*b*c))\na_B = math.acos((a*a+c*c-b*b)/(2*a*c))\na_C = math.acos((a*a+b*b-c*c)/(2*a*b))\n\na_n = gcd(a_A, gcd(a_B, a_C))\nn = round(math.pi/a_n, 0)\n\nprint R*R*math.sin(2*math.pi/n)*n/2\n"}, {"source_code": "#input\n\nlst = input().split()\nax, ay = map(float, lst)\nlst = input().split()\nbx, by = map(float, lst)\nlst = input().split()\ncx, cy = map(float, lst)\n\n\n#solve\n\nimport math\n\nab2 = (ax-bx)*(ax-bx) + (ay-by)*(ay-by)\nbc2 = (bx-cx)*(bx-cx) + (by-cy)*(by-cy)\nca2 = (cx-ax)*(cx-ax) + (cy-ay)*(cy-ay)\nab = math.sqrt(ab2)\nbc = math.sqrt(bc2)\nca = math.sqrt(ca2)\np = (ab+bc+ca)/2\ns = math.sqrt( p*(p-ab)*(p-bc)*(p-ca) )\nr = ab*bc*ca / (4*s)\nA = math.acos( (ab2+ca2-bc2)/(2*ab*ca) )\nB = math.acos( (ab2+bc2-ca2)/(2*ab*bc) )\nC = math.acos( (bc2+ca2-ab2)/(2*bc*ca) )\nd = 0.00001 #\u8bef\u5dee\ncount = 3 #default not useful\nsinth = 0.0\nminth = math.pi/100 - d\nfor i in range(1, 100):\n th = A/i\n if (th < minth):\n break #no\n if ( abs((B+d)//th*th-B)<d and abs((C+d)//th*th-C)<d ):\n count = (math.pi+d)//th\n sinth = math.sin(th*2) \n break\nss = 0.5*r*r*sinth*count\nprint(\"%.6f\" % ss)\n"}, {"source_code": "from math import*\np=[map(float,raw_input().split()) for i in range(3)]\na,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\nu=2*g(A,g(B,C))\nprint R*R*pi/u*sin(u)"}, {"source_code": "from math import atan2, sin, pi\n\nx1, y1 = map(float, input().split())\nx2, y2 = map(float, input().split())\nx3, y3 = map(float, input().split())\n\nA = x1 * (y2 - y3) - y1 * (x2 - x3) + x2 * y3 - x3 * y2\nB = (x1 ** 2 + y1 ** 2) * (y3 - y2) + (x2 ** 2 + y2 ** 2) * (y1 - y3) + (x3 ** 2 + y3 ** 2) * (y2 - y1)\nC = (x1 ** 2 + y1 ** 2) * (x2 - x3) + (x2 ** 2 + y2 ** 2) * (x3 - x1) + (x3 ** 2 + y3 ** 2) * (x1 - x2)\n\nx_O = - B / (2 * A)\ny_O = - C / (2 * A)\n# print(x_O, y_O)\na1 = atan2(y1 - y_O, x1 - x_O)\na2 = atan2(y2 - y_O, x2 - x_O)\na3 = atan2(y3 - y_O, x3 - x_O)\n\n# print(a1, a2, a3)\neps = 1e-5\nN = 3\nwhile(True):\n # print(N)\n if abs(sin(N * (a2 - a1) / 2)) < eps and abs(sin(N * (a3 - a1) / 2)) < eps and abs(sin(N * (a3 - a2) / 2)) < eps:\n break\n N += 1\nradius = ((x1 - x_O) ** 2 + (y1 - y_O) ** 2) ** 0.5\nprint(N * radius ** 2 * sin(2 * pi / N) / 2)\n"}, {"source_code": "from math import *\n\nkordinat = [list(map(float, input().split())) for i in range(3)]\na, b, c = [hypot(x1 - x2, y1 - y2) for (x1, y1), (x2, y2) in [\n (kordinat[0], kordinat[1]), (kordinat[0], kordinat[2]), (kordinat[1],kordinat[2])\n ]]\nA, B, C = [acos((z * z + y * y - x * x) / 2 / y / z) for x,y,z in [(a,b,c), (b,c,a), (c,a,b)]]\nRadius = a / (2 * sin(A))\ndef g(x, y):\n if y < 1e-3:\n return x\n else:\n return g(y, fmod(x, y))\nu = 2 * g(A,g(B, C))\nArea = round((pi * Radius * Radius * sin(u)) / (u), 7)\nprint(Area)"}, {"source_code": "from math import *\n\ndef gcd(a, b): return a if b < pi/100 else gcd(b, fmod(a, b))\n\np = [map(float, raw_input().split()) for i in xrange(3)]\na, b, c = [hypot((x2-x1), (y2-y1)) for (x1, y1), (x2, y2) in [(p[0], p[1]), (p[1], p[2]), (p[2], p[0])]]\nta, tb, tc = [acos((y*y+z*z-x*x)/2.0/y/z) for x, y, z in [(a, b, c), (b, c, a), (c, a, b)]]\nR = a/2.0/sin(ta)\nt = 2.0*gcd(ta, gcd(tb, tc))\nprint R**2*pi/t*sin(t)"}, {"source_code": "from math import atan2, acos, sin\n\nPI = acos(-1)\nPI2 = PI+PI\n\ndef pos(x):\n while x < 0:\n x += PI2\n return x\n\ndef main():\n p0 = map(float, raw_input().split())\n p1 = map(float, raw_input().split())\n p2 = map(float, raw_input().split())\n c1 = p0[0]**2+p0[1]**2-p1[0]**2-p1[1]**2\n a1 = 2*(p0[0]-p1[0])\n b1 = 2*(p0[1]-p1[1])\n c2 = p0[0]**2+p0[1]**2-p2[0]**2-p2[1]**2\n a2 = 2*(p0[0]-p2[0])\n b2 = 2*(p0[1]-p2[1])\n x = (c1*b2-c2*b1)/(a1*b2-a2*b1)\n y = (c1*a2-c2*a1)/(b1*a2-b2*a1)\n p0 = (p0[0]-x, p0[1]-y)\n p1 = (p1[0]-x, p1[1]-y)\n p2 = (p2[0]-x, p2[1]-y)\n a = [atan2(p0[1], p0[0]), atan2(p1[1], p1[0]), atan2(p2[1], p2[0])]\n '''\n a = map(pos, a)\n a.sort()\n a = [a[1]-a[0], a[2]-a[1], a[0]-a[2]]\n a = map(lambda x: x if x < PI else x-PI, a)\n print a\n '''\n for i in range(3, 101):\n flag = True\n for j in range(3):\n if abs(sin(i*(a[(j+1)%3]-a[j])/2)) > 1e-4:\n flag = False\n break\n if flag:\n break\n print '%.8f' % (i*(p0[0]*p0[0]+p0[1]*p0[1])*sin(PI2/i)/2)\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "import math\n# get edge for the triangle\n\n\ndef getEgde(x1, y1, x2, y2):\n ans = math.sqrt(pow((x1-x2), 2) + pow((y1-y2), 2))\n return ans\n\n# greatest common divisor\n\n\ndef gcd(x, y):\n if x < esp:\n return y\n if y < esp:\n return x\n\n return gcd(y, math.fmod(x, y))\n\n\n# main\n# init\nx = [0]*3\ny = [0]*3\nesp = 0.01\n\nfor i in range(0, 3):\n cord = input().split()\n x[i] = float(cord[0])\n y[i] = float(cord[1])\n\n\n# get three edges for the triangle\na = getEgde(x[0], y[0], x[1], y[1])\nb = getEgde(x[0], y[0], x[2], y[2])\nc = getEgde(x[2], y[2], x[1], y[1])\n\n\n# Heron formula\np = (a+b+c) / 2\ns = math.sqrt(p * (p-a) * (p-b) * (p-c))\n\n# get radius of circle\nr = (a * b * c) / (4 * s)\n\n# get angle of each edge\nangle = [0] * 3\n# control precision, otherwise will get a math domain error on math.asin()\na = float(\"%.9f\" % a)\nb = float(\"%.9f\" % b)\nc = float(\"%.9f\" % c)\nr = float(\"%.9f\" % r)\n\nangle[0] = 2 * math.asin(a / (2*r))\nangle[1] = 2 * math.asin(b / (2*r))\nangle[2] = 2 * math.pi-angle[0]-angle[1]\naver = angle[0]\n\ni = 1\nfor i in range(0, 3):\n aver = gcd(aver, angle[i])\n\nn = 2 * math.pi / aver\narea = r*r * math.sin(aver) / 2\n\nprint(\"%.8f\" % (n*area))\n"}, {"source_code": "import math\n\nx1, y1 = map(eval, raw_input().split())\nx2, y2 = map(eval, raw_input().split())\nx3, y3 = map(eval, raw_input().split())\n\na = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5\nb = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5\nc = ((x3 - x2) ** 2 + (y3 - y2) ** 2) ** 0.5\n\ncos_a = (b**2 + c**2 - a**2) / 2.0 / b / c\ncos_b = (a**2 + c**2 - b**2) / 2.0 / a / c\ncos_c = (a**2 + b**2 - c**2) / 2.0 / a / b\n\ndef is_multiple(angel, cos):\n eps = 1e-4\n t = angel\n while t < math.pi:\n if abs(math.cos(t) - cos) < eps:\n return True\n t += angel\n return False\n\n\nfor k in range(3, 101):\n A = math.pi / k\n if is_multiple(A, cos_a) and is_multiple(A, cos_b) and is_multiple(A, cos_c):\n r = a / 2 / math.sin(math.acos(cos_a))\n s = r * math.sin(A) * r * math.cos(A)\n print s * k\n break\n"}, {"source_code": "import math\n\n\n\nEPS = 1e-4\n\n\n\ndef gcd(a, b):\n\n\twhile abs(a) > EPS and abs(b) > EPS:\n\n\t\tif a > b:\n\n\t\t\ta -= math.floor(a/b)*b\n\n\t\telse:\n\n\t\t\tb -= math.floor(b/a)*a\n\n\treturn a+b\n\n\n\ndef dist(x0, y0, x1, y1):\n\n\treturn math.sqrt((x0-x1)**2+(y0-y1)**2)\n\n\n\nx0, y0 = map(float, raw_input().split())\n\nx1, y1 = map(float, raw_input().split())\n\nx2, y2 = map(float, raw_input().split())\n\n\n\ns = abs(x0*y1+x1*y2+x2*y0-y0*x1-y1*x2-y2*x0)/2\n\na = dist(x0, y0, x1, y1)\n\nb = dist(x0, y0, x2, y2)\n\nc = dist(x1, y1, x2, y2)\n\nr = (a*b*c)/(4*s)\n\n\n\nA = math.acos((b**2+c**2-a**2)/(2*b*c))\n\nB = math.acos((a**2+c**2-b**2)/(2*a*c))\n\nC = math.acos((a**2+b**2-c**2)/(2*a*b))\n\n\n\nt = gcd(gcd(A, B), C)\n\n\n\nn = math.pi/t\n\n\n\nprint (n/2)*(r**2)*math.sin(2*math.pi/n)"}, {"source_code": "from math import*\np=[map(float,raw_input().split()) for i in range(3)]\na,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\nu=2*g(A,g(B,C))\nprint R*R*pi/u*sin(u)"}, {"source_code": "import math\nfrom sys import stdin\nfrom decimal import Decimal\n\n\ndef get_length(p1, p2):\n return Decimal.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\n\n\ndef get_angle(p1, p2, p3):\n a = (p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2\n b = (p2[0] - p3[0]) ** 2 + (p2[1] - p3[1]) ** 2\n c = (p1[0] - p3[0]) ** 2 + (p1[1] - p3[1]) ** 2\n return math.acos((a + c - b) / (2 * get_length(p1, p2) * get_length(p1, p3)))\n\n\ndef get_radius(p1, p2, p3):\n a, b, c = get_length(p1, p2), get_length(p2, p3), get_length(p1, p3)\n s = (a + b + c) / 2\n area = Decimal.sqrt(s * (s - a) * (s - b) * (s - c))\n return a * b * c / 4 / area\n\n\ndef gcd(x, y):\n while abs(y) > 0.01 and abs(x) > 0.01:\n if x > y:\n x -= Decimal.from_float(math.floor(x / y)) * y\n else:\n y -= Decimal.from_float(math.floor(y / x)) * x\n return x + y\n\n\ndef main():\n x1, y1 = map(Decimal.from_float, map(float, stdin.readline().strip().split()))\n p1 = (x1, y1)\n x2, y2 = map(Decimal.from_float, map(float, stdin.readline().strip().split()))\n p2 = (x2, y2)\n x3, y3 = map(Decimal.from_float, map(float, stdin.readline().strip().split()))\n p3 = (x3, y3)\n A = Decimal.from_float(get_angle(p1, p2, p3))\n B = Decimal.from_float(get_angle(p2, p3, p1))\n C = Decimal.from_float(get_angle(p3, p2, p1))\n radius = get_radius(p1, p2, p3)\n n = Decimal.from_float(round(Decimal.from_float(math.pi) / gcd(gcd(A, B), C)))\n area = n / 2 * \\\n radius ** 2 * \\\n Decimal.from_float(math.sin(2 * Decimal.from_float(math.pi) / n))\n print(area)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "\"\"\"\nCodeforces\n1C - Ancient Berland Circus\nhttp://codeforces.com/problemset/problem/1/C\n\nH\u00e9ctor Gonz\u00e1lez Belver\n11/06/2018\n\"\"\"\nimport sys\nimport math\n\n\n\ndef float_gcd(a, b, rtol = 0, atol = 1e-05):\n t = min(abs(a), abs(b))\n while abs(b) > rtol * t + atol:\n a, b = b, a % b\n return a\n\ndef main():\n point_A = [float(x) for x in sys.stdin.readline().strip().split()]\n point_B = [float(x) for x in sys.stdin.readline().strip().split()]\n point_C = [float(x) for x in sys.stdin.readline().strip().split()]\n \n #Triangle\n side_a = math.hypot(point_B[0] - point_C[0], point_B[1] - point_C[1])\n side_b = math.hypot(point_A[0] - point_C[0], point_A[1] - point_C[1])\n side_c = math.hypot(point_A[0] - point_B[0], point_A[1] - point_B[1])\n\n #Semiperimeter of the triangle\n semiperimeter_T = (side_a + side_b + side_c)/2\n \n #Area of triangle: Heron's formula\n area_T = (semiperimeter_T*(semiperimeter_T - side_a)*(semiperimeter_T - side_b)*(semiperimeter_T - side_c))**0.5\n\n #Angles of triangle: Law of cosines\n angle_A = math.acos((side_b**2 + side_c**2 - side_a**2)/(2*side_b*side_c))\n angle_B = math.acos((side_a**2 + side_c**2 - side_b**2)/(2*side_a*side_c))\n angle_C = math.acos((side_a**2 + side_b**2 - side_c**2)/(2*side_a*side_b))\n\n #Circumradius (R) of the triangle = circumradius of possible convex regular n-gons\n R = (side_a*side_b*side_c)/(4*area_T)\n\n #Angles of the triangle are inscribed angles of circumcircle with center O --> inscribed angles theorem: relates the measure of an inscribed angle to that of the central angle subtending the same arc \n #-->angle_BOC = 2*angle_A\n #-->angle_AOC = 2*angle_B\n #-->angle_AOB = 2*angle_C\n\n #Central angle of convex regular n-gon = 2*pi/n\n #--> angle_BOC = i * 2*pi/n ==> angle_A = i * pi/n\n #--> angle_AOC = j * 2*pi/n ==> angle_B = j * pi/n\n #--> angle_AOB = k * 2*pi/n ==> angle_C = k * pi/n\n #i + j + k = n ( i,j,k,n positive integers)\n #==>mimimum area==>minimum n==> gcd(angle_A, angle_B, angle_C) = pi/n\n #==>n=pi/gcd(angle_A, angle_B, angle_C) \n n = math.pi/float_gcd(float_gcd(angle_A, angle_B), angle_C)\n\n #Area of convex regular n-gons by circumradius\n A = (math.sin(2*math.pi/n)*n*R**2)/2\n\n sys.stdout.write(\"{:.6f}\".format(A)+\"\\n\")\n \n\nif __name__ == '__main__': \n main()"}, {"source_code": "import math\n\n\npi = math.pi\neps = 1e-4\n\n\ndef gcd(x, y):\n if x < y:\n return gcd(y, x)\n if (abs(y) < eps):\n return x\n else:\n return gcd(y, x - (x // y) * y)\n\n\ndef circle(x1, y1, x2, y2, x3, y3):\n x12 = x1 - x2\n x13 = x1 - x3\n\n y12 = y1 - y2\n y13 = y1 - y3\n\n y31 = y3 - y1\n y21 = y2 - y1\n\n x31 = x3 - x1\n x21 = x2 - x1\n\n sx13 = x1**2 - x3**2\n sy13 = y1**2 - y3**2\n\n sx21 = x2**2 - x1**2\n sy21 = y2**2 - y1**2\n\n f = ((sx13 * x12) + (sy13 * x12) + (sx21 * x13) +\n (sy21 * x13)) / (2 * ((y31 * x12) - (y21 * x13)))\n g = ((sx13 * y12) + (sy13 * y12) + (sx21 * y13) +\n (sy21 * y13)) / (2 * ((x31 * y12) - (x21 * y13)))\n c = (-(x1**2) - (y1**2) - 2 * g * x1 - 2 * f * y1)\n\n h = -g\n k = -f\n r = math.sqrt(h**2 + k**2 - c)\n return r\n\n\ndef dis(x1, y1, x2, y2):\n return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)\n\n\ndef cos_law(a, b, c):\n return math.acos((a**2 + b**2 - c**2) / (2 * a * b))\n\n\ndef angles(x1, y1, x2, y2, x3, y3):\n d12 = dis(x1, y1, x2, y2)\n d13 = dis(x1, y1, x3, y3)\n d23 = dis(x2, y2, x3, y3)\n a1 = cos_law(d12, d13, d23)\n a2 = cos_law(d12, d23, d13)\n a3 = cos_law(d13, d23, d12)\n return a1, a2, a3\n\n\nx1, y1 = map(float, input().split())\nx2, y2 = map(float, input().split())\nx3, y3 = map(float, input().split())\nr = circle(x1, y1, x2, y2, x3, y3)\na1, a2, a3 = angles(x1, y1, x2, y2, x3, y3)\nn = int(pi / gcd(gcd(a1, a2), a3))\na = (1 / 2) * n * (r**2) * math.sin(2 * pi / n)\nprint('{:f}'.format(a))\n"}, {"source_code": "from math import hypot,acos,pi,sin,fmod\n\ndef gcd(a,b):\n if b<pi/100: return a\n return gcd(b,fmod(a,b))\n\np=[map(float,raw_input().split()) for i in range(3)]\n\na,b,c=[hypot(x[0]-y[0],x[1]-y[1]) for x,y in[(p[0],p[1]),(p[1],p[2]),(p[2],p[0])]]\nua,ub,uc=[acos((y**2+z**2-x**2)/(2*y*z)) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\n\nR=a/(2*sin(ua))\nu=2*gcd(ua,gcd(ub,uc))\n\nprint R**2*pi/u*sin(u)"}, {"source_code": "from math import *\nv = lambda a, b: (b[0] - a[0], b[1] - a[1])\nl = lambda a, b: hypot(*v(a, b))\ncross = lambda a, b: a[0] * b[1] - a[1] * b[0]\ndef angle(a, b, c):\n v1, v2 = v(b, a), v(b, c)\n res = abs(atan2(v1[1], v1[0]) - atan2(v2[1], v2[0]))\n return min(2 * pi - res, res)\na, b, c = [map(float, raw_input().split()) for _ in range(3)]\nla, lb, lc = l(a, b), l(b, c), l(a, c)\nA, B, C = angle(a, c, b), angle(b, a, c), angle(a, b, c)\nS = fabs(cross(v(a, b), v(a, c))) / 2\nR = (la * lb * lc) / (4 * S)\ndef fgcd(a, b):\n return a if b < pi / 100 else fgcd(b, fmod(a, b))\nt = 2 * fgcd(A, fgcd(B, C))\nn = (2 * pi) / t\nprint (pi * R * R * sin(t)) / t"}, {"source_code": "from sys import stdin, stdout\nimport math\n\ndef find_radius(a,b,c):\n e=math.sqrt((a+b+c)*(b+c-a)*(a+c-b)*(a+b-c))\n r=(a*b*c)/e\n return r\n\ndef length(x,y):\n return math.sqrt(x**2+y**2)\n\ndef dot(x1,y1,x2,y2):\n return x1*x2+y1*y2\n\ndef find_angles(x1,y1,x2,y2,x3,y3):\n ax=x2-x1\n ay=y2-y1\n bx=x3-x1\n by=y3-y1\n cx=x3-x2\n cy=y3-y2\n theta1=math.acos((dot(ax,ay,bx,by)/(length(ax,ay)*length(bx,by))))\n theta2=math.acos((dot(-ax,-ay,cx,cy)/(length(ax,ay)*length(cx,cy))))\n theta3=math.acos((dot(-bx,-by,-cx,-cy)/(length(cx,cy)*length(bx,by))))\n theta1=2*theta1\n theta2=2*theta2\n theta3=2*theta3\n return theta1,theta2,theta3\n\n\ndef equal(x,y):\n if abs(x-y)<=0.0001:\n return True\n return False\n\ndef gcd(x,y):\n if x<y:\n return gcd(y,x)\n else:\n a=int(x/y)\n if equal(0,x-a*y):\n return y\n else:\n return gcd(y,x-a*y)\n \ndef main(x1,y1,x2,y2,x3,y3):\n t1,t2,t3=find_angles(x1,y1,x2,y2,x3,y3)\n t=gcd(gcd(t1,t2),t3)\n n1=(t1/t)\n n2=(t2/t)\n n3=(t3/t)\n n=n1+n2+n3\n a=length(x2-x1,y2-y1)\n b=length(x3-x1,y3-y1)\n c=length(x3-x2,y3-y2)\n r=find_radius(a,b,c)\n return n*0.5*math.sin(t)*(r**2)\n \ndef parse(myString):\n i=0\n l=len(myString)\n while myString[i]!=\" \":\n i+=1\n string1=myString[0:i]\n string2=myString[i+1:l-1]\n return float(string1),float(string2)\n\na=[0,0,0,0,0,0]\ni=0\nfor j in range(3):\n cell=stdin.readline()\n parse(cell)\n a[i],a[i+1]=parse(cell)\n i+=2\narea=main(a[0],a[1],a[2],a[3],a[4],a[5])\nprint area"}, {"source_code": "from __future__ import division, print_function\nfrom math import acos, fmod, pi, sin, hypot\ninput = raw_input\n\n# MAIN------------------------------------------------------------------------#\n\ndef gcd(a, b): return a if b < pi/100 else gcd(b, fmod(a, b))\n\ndef main():\n p = [map(float, input().split()) for i in xrange(3)]\n a, b, c = [hypot((x2-x1), (y2-y1)) for (x1, y1), (x2, y2) in [(p[0], p[1]), (p[1], p[2]), (p[2], p[0])]]\n ta, tb, tc = [acos((y*y+z*z-x*x)/2.0/y/z) for x, y, z in [(a, b, c), (b, c, a), (c, a, b)]]\n R = a/2.0/sin(ta)\n t = 2.0*gcd(ta, gcd(tb, tc))\n print(R**2*pi/t*sin(t))\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\n#coding=utf-8\n# from error202\nimport math\ndef gcd(a,b):\n if b < math.pi/100:return a\n return gcd(b, math.fmod(a,b))\n\np = [map(float,raw_input().split()) for i in range(3)]\n\na,b,c = [math.hypot(x[0]-y[0],x[1] - y[1])\\\n for x,y in [(p[0],p[1]),(p[1],p[2]),(p[2],p[0])]]\n\nua,ub,uc = [math.acos((y**2 + z**2 - x**2)/(2*y*z))\\\n for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\n\nR = a/(2*math.sin(ua))\nu = 2 * gcd(ua,gcd(ub,uc))\n\nprint R ** 2 * math.pi / u * math.sin(u)\n"}, {"source_code": "#CF1c\nimport math\n\ndef fequal(x,y):\n return (math.fabs(x-y) < (math.pi/100))\n\ndef gcd(a,b):\n\n if fequal(b,0):\n return a\n if fequal(a,0):\n return b\n else:\n return gcd(b,a%b)\n\ndef main():\n x1,y1 = raw_input().split()\n x1 = float(x1)\n y1 = float(y1)\n x2,y2 = raw_input().split()\n x2 = float(x2)\n y2 = float(y2)\n x3,y3 = raw_input().split()\n x3 = float(x3)\n y3 = float(y3)\n\n a = math.sqrt(math.pow((x1-x2),2)+ math.pow((y1-y2),2))\n b = math.sqrt(math.pow((x2-x3),2)+ math.pow((y2-y3),2))\n c = math.sqrt(math.pow((x3-x1),2)+ math.pow((y3-y1),2))\n p = (a+b+c)/2\n #heron\n S = math.sqrt(p*(p-a)*(p-b)*(p-c))\n R = a*b*c/(4*S)\n\n if a > c:\n k = a \n a = c\n c = k\n if b > c :\n k = b\n b = c\n c = k\n\n A = 2 * math.asin(a/(2*R))\n B = 2 * math.asin(b/(2*R))\n C = 2 * math.pi - A - B\n P = gcd(A,B)\n P = gcd(P,C)\n print((math.pi*R*R*math.sin(P))/P)\n\n#-------\nif __name__ == '__main__':\n main()"}, {"source_code": "import sys\nimport math\n\nN = 1000\n\ndef find_circle_center(p1, p2, p3):\n (x1, y1) = p1 \n (x2, y2) = p2 \n (x3, y3) = p3 \n # the perpendicular bisectors linear function is either \n # A*x + B*y = B * y_mid + A * x_mid, or x = x_mid when y_1 == y_2\n # where A = x_2 - x_1 and B = y_2 - y_1\n # The rest part is just solving two linear systems\n # See: https://stackoverflow.com/questions/20677795/how-do-i-compute-the-intersection-point-of-two-lines-in-python\n \n def average(a, b): return (a + b) / 2\n # Line 1: the p1-p2 perpendicular\n x_mid1 = average(x1, x2); y_mid1 = average(y1, y2)\n if y1 == y2:\n L1 = (1, 0, -x_mid1)\n else:\n A1 = x2 - x1; B1 = y2 - y1;\n C1 = B1 * y_mid1 + A1 * x_mid1\n L1 = (A1, B1, -C1)\n\n x_mid2 = average(x2, x3); y_mid2 = average(y2, y3)\n if y2 == y3:\n L2 = (1, 0, -x_mid2)\n else:\n A2 = x3 - x2; B2 = y3 - y2;\n C2 = B2 * y_mid2 + A2 * x_mid2\n L2 = (A2, B2, -C2)\n\n xp = intersection(L1, L2) \n if xp:\n return xp \n print(\"No single Intersection point detected.\")\n return False\n\n# def line(p1, p2):\n# A = (p1[1] - p2[1])\n# B = (p2[0] - p1[0])\n# C = (p1[0]*p2[1] - p2[0]*p1[1])\n# return A, B, -C\n\ndef intersection(L1, L2):\n D = L1[0] * L2[1] - L1[1] * L2[0]\n Dx = L1[2] * L2[1] - L1[1] * L2[2]\n Dy = L1[0] * L2[2] - L1[2] * L2[0]\n if D != 0:\n x = Dx / D\n y = Dy / D\n return -x, -y\n else:\n return False\n\ndef distance(p1, p2):\n return math.sqrt(pow((p2[0] - p1[0]), 2) + \n pow((p2[1] - p1[1]), 2))\n\ndef near_integer(num):\n u = math.ceil(num);\n l = math.floor(num);\n return math.isclose(u, num, rel_tol=1e-04) \\\n or math.isclose(l, num, rel_tol=1e-04)\n\ndef main():\n ps = []\n # fin = open('input.txt', 'r')\n # for line in fin.readlines():\n for line in sys.stdin:\n (a, b) = line.split(' ')\n ps.append((float(a), float(b)))\n center = find_circle_center(ps[0], ps[1], ps[2])\n R = distance(center, ps[0])\n \n def center_angle(line):\n # Using The Law of Sines \n # Center_angle without the Pi part\n p1, p2 = line\n return 2 * math.asin(distance(p1, p2) / R * 0.5) / math.pi\n\n Theta = list(map(center_angle, [(ps[0], ps[1]), (ps[1], ps[2]), (ps[2], ps[0])]))\n # find the smallest value of n that gives a near-integer value of s\n n = 0\n for n in range(3, N+1):\n # s = 2 * R * math.sin(math.pi / n)\n div_result = [x * n / 2 for x in Theta]\n if all([near_integer(x) for x in div_result]):\n break\n else:\n continue\n if n == 0:\n print(\"Error: input invalid.\")\n return\n area = 1 / 2 * n * R * R * math.sin(2 * math.pi / n)\n print(\"%.6f\" % area)\n return area\n\ndef test():\n p1 = (0.0, 0.0)\n p2 = (0.5, 0.5 * math.sqrt(3))\n p3 = (1.0, 0.0)\n p4 = (1.0, 1.0)\n \n \n p5 = (71.756151, 7.532275)\n p6 = (-48.634784, 100.159986)\n p7 = (91.778633, 158.107739)\n \n#test()\nmain()"}, {"source_code": "from math import *\ndef gcd(x, y):\n return x if y < 1e-3 else gcd(y, fmod(x,y))\n\np = [[float(i) for i in input().split()] for _ in range(3)]\na, b, c = [hypot(x1-x2, y1-y2) for ([x1,y1], [x2,y2]) in [(p[0], p[1]), (p[0], p[2]), (p[1], p[2])]]\nA, B, C = [acos((y*y+z*z-x*x)/2/y/z) for (x,y,z) in [(a,b,c), (b,c,a), (c,a,b)]]\n\nR = a/2/sin(A)\ntheta = 2*gcd(A, gcd(B,C))\nprint(R*R*sin(theta)*pi/theta)"}, {"source_code": "import math\nfrom sys import stdin\n# from fractions import gcd\n\n\ndef dist(x1, y1, x2, y2):\n return math.sqrt((x1-x2)**2 + (y1-y2)**2)\n\n\ndef angle(a, b, c):\n return math.acos((b**2 + c**2 - a**2) / (2*b*c))\n\n\ndef gcd(a, b):\n while abs(a - b) > 0.01:\n if a > b:\n a -= b\n else:\n b -= a\n return round(a, 6)\n\n\nd = []\na = []\ns = list(map(lambda x: list(map(float, x.split(' '))), stdin.readlines()))\nd.append(dist(s[0][0], s[0][1], s[1][0], s[1][1]))\nd.append(dist(s[0][0], s[0][1], s[2][0], s[2][1]))\nd.append(dist(s[1][0], s[1][1], s[2][0], s[2][1]))\na.append(angle(d[0], d[1], d[2]))\na.append(angle(d[1], d[2], d[0]))\na.append(angle(d[2], d[0], d[1]))\nn = round(math.pi / gcd(gcd(a[0], a[1]), a[2]))\np = sum(d) / 2\nR = d[0]*d[1]*d[2] / (4 * math.sqrt(p * (p-d[0]) * (p-d[1]) * (p-d[2])))\nprint round(0.5 * n * math.sin(2*math.pi / n) * R**2, 7)"}, {"source_code": "\n\nfrom sys import stdin\nfrom math import *\nfrom functools import lru_cache, reduce\ninput = stdin.readline\n\ndist = lambda a, b: sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)\ndgcd = lambda a, b: a if b < 1e-4 else dgcd(b, a) if a < b else dgcd(b, a - a // b * b)\ndege = lambda a, b, c: acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c))\n\nap, bp, cp = map(tuple, map(lambda i: map(float, input().split()), range(3)))\na, b, c = map(dist, [bp, cp, ap], [cp, ap, bp])\nA, B, C = map(dege, [a, b, c], [b, c, a], [c, a, b])\np = (a + b + c) / 2\nS = sqrt(p * (p - a) * (p - b) * (p - c))\nR = a * b * c / (4 * S)\nn = round(pi / reduce(dgcd, [A, B, C]))\nRes = n / 2 * R * R * sin(pi * 2 / n)\nprint(f\"{Res:.6f}\")\n\n\n"}, {"source_code": "from math import *\n\n\ndef rt(x0, y0):\n return sum((i - j) ** 2 for i, j in zip(x0, y0))\n\n\ndef tr(a0, b0, c0):\n return acos((b0 + c0 - a0) / (2 * (b0 * c0) ** 0.5)) / pi\n\n\ndef trt(x0, n0):\n return 0.01 < (x0 * n0) % 1 < 0.99\n\n\nx0, y0, z0 = (tuple(map(float, input().split())) for i in range(3))\na0, b0, c0 = rt(x0, y0), rt(x0, z0), rt(y0, z0)\nt0, s0 = tr(a0, b0, c0), tr(b0, a0, c0)\nr0, n0 = a0 / (8 * sin(t0 * pi) ** 2), 3\nwhile trt(t0, n0) or trt(s0, n0):\n n0 += 1\nprint(n0 * r0 * sin(2 * pi / n0))\n"}, {"source_code": "from math import *\np=[map(float,raw_input().split()) for i in [0]*3]\na,b,c=[hypot(x-X,y-Y) for (x,y),(X,Y) in [(p[0],p[1]),(p[1],p[2]),(p[0],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\ndef g(x,y):\n if y < pi/100: return x\n return g(y,fmod(x,y))\nu=2*g(A,g(B,C))\nprint R*R*pi/u*sin(u)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\nhttp://codeforces.com/problemset/problem/1/C\n\nC. Ancient Berland Circus\ntime limit per test\n2 seconds\nmemory limit per test\n64 megabytes\ninput\nstandard input\noutput\nstandard output\n\nNowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.\n\nIn Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a special pillar, and the rope strung between the pillars marked the arena edges.\n\nRecently the scientists from Berland have discovered the remains of the ancient circus arena. They found only three pillars, the others were destroyed by the time.\n\nYou are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.\nInput\n\nThe input file consists of three lines, each of them contains a pair of numbers \u2013\u2013 coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point.\nOutput\n\nOutput the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100.\nSample test(s)\nInput\n\n0.000000 0.000000\n1.000000 1.000000\n0.000000 1.000000\n\nOutput\n\n1.00000000\n\n\"\"\"\n\nimport math\n\nclass Point(object):\n def __init__(self, x, y):\n self.x = x*1.0\n self.y = y*1.0\n\n def GetDistance(self, p2):\n dx = self.x - p2.x\n dy = self.y - p2.y\n return math.sqrt(dx*dx+dy*dy)\n\n def __str__(self):\n return '['+str(self.x)+','+str(self.y)+']'\n\nclass LineEquation(object):\n def __init__(self, p1, p2):\n self.type = 0 # 0: general form, 1: vertical line, 2: horizontal line\n self.p1 = p1\n self.p2 = p2\n if p1.x == p2.x:\n self.type = 1 # vertial\n self.x = p1.x\n elif p1.y == p2.y:\n self.type = 2 # horizontal\n self.y = p1.y\n else:\n self.type = 0\n self.slope = (p2.y-p1.y)/(p2.x-p1.x)\n self.intercept = p2.y-self.slope*p2.x\n #print \"%f %f %f %f %f %f\"%(p1.x, p1.y, p2.x, p2.y, self.slope, self.intercept)\n\n def GetMidperpendicular(self):\n result = None\n mid_x = (self.p1.x+self.p2.x)/2\n mid_y = (self.p1.y+self.p2.y)/2\n if self.type == 1:\n result = LineEquation(Point(0, mid_y), Point(1, mid_y))\n elif self.type == 2:\n result = LineEquation(Point(mid_x, 0), Point(mid_x, 1))\n else:\n slope = -1/self.slope\n result = LineEquation(Point(mid_x, mid_y), Point(mid_x-1, mid_y-slope))\n return result\n\n def GetCrossPoint(self, line):\n x = 0\n y = 0\n if (self.type == 1 and line.type == 1) \\\n or (self.type == 2 and line.type == 2) \\\n or (self.type == 0 and line.type == 0 and (self.slope - line.slope < 0.0000001)):\n return None\n if self.type == 1:\n x = self.x\n y = line.slope*x+line.intercept\n elif line.type == 1:\n return line.GetCrossPoint(self)\n elif self.type == 2:\n y = self.y\n x = (y-line.intercept)/line.slope\n elif line.type == 2:\n return line.GetCrossPoint(self)\n else:\n x = (line.intercept-self.intercept)/(self.slope-line.slope)\n y = line.slope*x+line.intercept\n return Point(x,y)\n\n def __str__(self):\n if self.type == 0:\n return 'y=' + str(self.slope) + '*x+' + str(self.intercept)\n elif self.type == 1:\n return 'x=' + str(self.x)\n else:\n return 'y=' + str(self.y)\n\ndef get_area_with_herons_formula(a, b, c):\n p = (a+b+c)/2\n s = math.sqrt(p*(p-a)*(p-b)*(p-c))\n return s\n\ndef get_radius(a, b, c, s):\n return a*b*c/(4*s)\n\ndef get_radian_of_triangle_with_low_of_cosines(a, b, c):\n r1 = math.acos((b**2+c**2-a**2)/(2*b*c))\n r2 = math.acos((c**2+a**2-b**2)/(2*c*a))\n r3 = math.acos((a**2+b**2-c**2)/(2*b*a))\n return r1, r2, r3\n\ndef get_gcd(a, b):\n if b < math.pi/100:\n return a\n return get_gcd(b, math.fmod(a, b))\n\nif __name__ == \"__main__\":\n\n coords = raw_input().split()\n p1 = Point(float(coords[0]), float(coords[1]))\n coords = raw_input().split()\n p2 = Point(float(coords[0]), float(coords[1]))\n coords = raw_input().split()\n p3 = Point(float(coords[0]), float(coords[1]))\n\n #p1 = Point(p[0][0], p[0][1])\n #p2 = Point(p[1][0], p[1][1])\n #p3 = Point(p[2][0], p[2][1])\n a = p1.GetDistance(p2)\n b = p2.GetDistance(p3)\n c = p3.GetDistance(p1)\n s = get_area_with_herons_formula(a, b, c)\n r = get_radius(a, b, c, s)\n r1, r2, r3 = get_radian_of_triangle_with_low_of_cosines(a, b, c)\n r = a/2.0/math.sin(r1)\n rgcd = 2.0*get_gcd(r1, get_gcd(r2, r3))\n result = r*r*math.sin(rgcd)/2*(2*math.pi/rgcd)\n #print a, b, c, r, r1, r2, r3, rgcd\n print (\"%.6f\"%result)\n #l = LineEquation(Point(0,1), Point(1,0))\n #print l\n #l = LineEquation(Point(1,1), Point(1,0))\n #print l\n #print l.GetMidperpendicular()\n #l = LineEquation(Point(1,1), Point(0,1))\n #print l\n #l = LineEquation(Point(0,1), Point(2,0))\n #print l\n #l = LineEquation(Point(0,1), Point(3,0))\n #print l\n #print l.GetMidperpendicular()\n #l = LineEquation(Point(0,0), Point(1,1))\n #l2 = LineEquation(Point(0,1), Point(1,1))\n #print l, l.GetMidperpendicular()\n #print l2, l2.type, l2.GetMidperpendicular(), l2.GetMidperpendicular().type\n #print l.GetCrossPoint(l2)\n #print l.GetMidperpendicular().GetCrossPoint(l2.GetMidperpendicular())\n #print Point(0,0).GetDistance(l.GetMidperpendicular().GetCrossPoint(l2.GetMidperpendicular()))\n"}, {"source_code": "import math\ndef getlen(a,b):\n return math.sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]))\ndef dmul(a,b):\n return a[0]*b[0]+a[1]*b[1]\ndef tlen(a):\n return math.sqrt(a[0]*a[0]+a[1]*a[1])\nlst=[]\nfor i in range(3):\n lst.append(map(float, raw_input().split()))\nthea=[]\nr=0\nfor i in range(3):\n v=[]\n for j in range(3):\n if j!=i:\n v.append([lst[j][0]-lst[i][0],lst[j][1]-lst[i][1]])\n ta=math.acos(dmul(v[0],v[1])/tlen(v[0])/tlen(v[1]))\n thea.append(ta)\n if i==0:\n r=tlen([lst[1][0]-lst[2][0],lst[1][1]-lst[2][1]])/2/math.sin(ta)\nthea.sort()\nfor i in range(1,100):\n t=thea[0]/i\n ret=(math.pi/t)*r*math.sin(2*t)*r/2\n for j in range(1,3):\n f=math.fmod(thea[j],t)\n if 1e-6<f<t-1e-6:\n break\n else:\n break\nprint \"%.8lf\"%ret"}, {"source_code": "A = raw_input().split()\nB = raw_input().split()\nC = raw_input().split()\n\nx1 = float(A[0]); y1 = float(A[1])\nx2 = float(B[0]); y2 = float(B[1])\nx3 = float(C[0]); y3 = float(C[1])\n\nif y2 == y1:\n k2 = - (x3-x2) / (y3-y2)\n b2 = (y3**2-y2**2+x3**2-x2**2) / (2*(y3-y2))\n x = (x1+x2) / 2\n y = k2*x + b2\nelse:\n if y3 == y2:\n k1 = - (x2-x1) / (y2-y1)\n b1 = (y2**2-y1**2+x2**2-x1**2) / (2*(y2-y1))\n x = (x2+x3) / 2\n y = k1*x + b1\n else:\n k1 = - (x2-x1) / (y2-y1)\n b1 = (y2**2-y1**2+x2**2-x1**2) / (2*(y2-y1))\n k2 = - (x3-x2) / (y3-y2)\n b2 = (y3**2-y2**2+x3**2-x2**2) / (2*(y3-y2))\n x = (b2-b1) / (k1-k2)\n y = (k1*b2-k2*b1) / (k1-k2)\n\nimport math\nr = math.sqrt((y-y1)**2+(x-x1)**2)\n\na1 = math.acos(1 - ((y2-y1)**2+(x2-x1)**2)/(2*r**2))\na2 = math.acos(1 - ((y3-y2)**2+(x3-x2)**2)/(2*r**2))\n\nfor i in range(3,101):\n n1 = a1*i/(2*math.pi)\n n2 = a2*i/(2*math.pi)\n if abs(n1 - round(n1))<0.001 and abs(n2 - round(n2))<0.001:\n n = i\n break\n\nS = float(n)/2 * r**2 * math.sin(2*math.pi/n)\nprint round(S,6)\n"}, {"source_code": "from math import*\np=[map(float,raw_input().split()) for i in range(3)]\na,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]]\nA,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\nR=a/2/sin(A)\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\nu=2*g(A,g(B,C))\nprint R*R*pi/u*sin(u)"}, {"source_code": "import math\n\nA = map(float,raw_input().strip().split())\nB = map(float,raw_input().strip().split())\nC = map(float,raw_input().strip().split())\n\ndef is_close(a, b, tol=1e-9):\n return abs(a-b) <= tol\n\ndef calculateDistance(x1, y1, x2, y2) :\n return math.sqrt( (x2-x1)**2 + (y2-y1)**2 )\n\ndef calculateAreaOfTriangle(a,b,c) :\n semiPerimeter = (a+b+c)/2\n return math.sqrt(semiPerimeter * (semiPerimeter - a) * (semiPerimeter - b) * (semiPerimeter -c))\n\ndef calculateCircumRadius1(a,b,c,areaOfTriagnle) :\n return (a * b * c)/areaOfTriagnle\n\ndef calculateCircumRadius(sideLength, alpha) :\n return sideLength/(2*math.sin(alpha))\n\ndef calculateAngle(adjacentSide1, adjacentSide2, oppositeSide) :\n \"\"\" This function calculates the angle of a triangle using the sides of it. Uses Law Of Cosines.\n \n Arguments:\n adjacentSide1 {[int]} -- [One of the sides which has got vertice which contains this point]\n adjacentSide2 {[int]} -- [One of the sides which has got vertice which contains this point]\n oppositeSide {[int]} -- [The side opposite to the angle which needs to be calculated. This side doesn't contain the center vertex of the angle being calculated.]\n \"\"\"\n\n angle = math.acos((adjacentSide1**2 + adjacentSide2**2 - oppositeSide**2)/(2*adjacentSide1*adjacentSide2))\n return angle\n\ndef gcd(x,y,eps = 0.001) :\n while math.fabs(x) > eps and math.fabs(y) > eps:\n if x > y :\n x = x - (math.floor(x/y)*y)\n else :\n y = y - (math.floor(y/x)*x)\n return x+y\n\ndef calculateSidesOfPolygon(A,B,C) :\n \"\"\"This calculates the number of sides of an equiangular regular polygon given 3 angles of the 3 random points.\n \n Arguments:\n A {[float]} -- [1st angle in radians formed by the triangle]\n B {[float]} -- [2nd angle in radians formed by the triangle]\n C {[float]} -- [3rd angle in radians formed by the triangle]\n \"\"\"\n sides = 1/(gcd((A/math.pi),gcd((B/math.pi),(C/math.pi))))\n return sides\n\ndef calculateApothem(sideLength,sides) :\n \"\"\"Calculates Apothem of a regular polygon\n \n Arguments:\n circumRadius {[float]} -- Circumradius of the polygon\n sides {[int]} -- The number of sides of the polygon\n \"\"\"\n return sideLength/(2*math.tan(math.pi/sides))\n\ndef calculateAreaOfPolygon(circumRadius,numberOfSides) :\n \"\"\"Calculates the area of an equiangular regular n sided polygon with given circumradius\n \n Arguments:\n sides {int} -- The number of sides in the polygon\n circumRadius {float} -- The circumradius of the polygon\n \"\"\"\n area = numberOfSides*0.5*((circumRadius**2) * math.sin((2*math.pi)/numberOfSides))\n return area\n\nAB = calculateDistance(A[0],A[1],B[0],B[1])\nBC = calculateDistance(B[0],B[1],C[0],C[1])\nAC = calculateDistance(A[0],A[1],C[0],C[1])\n\nsidesOfTriangle = [AB,BC,AC]\nsidesOfTriangle.sort()\n\nangleA = calculateAngle(AB,AC,BC)\nangleB = calculateAngle(AB,BC,AC)\nangleC = math.pi - angleA - angleB\n\nminimumSides = round(calculateSidesOfPolygon(angleA,angleB,angleC))\n\nareaOfTriangle = calculateAreaOfTriangle(AB,BC,AC)\n\ncircumRadius = calculateCircumRadius(BC,angleA)\n\nprint calculateAreaOfPolygon(circumRadius,minimumSides)"}, {"source_code": "import math\ndef SC(a,b):\n return a[0]*b[0]+a[1]*b[1]\ndef LN(a):\n d=math.sqrt(a[0]*a[0]+a[1]*a[1])\n return d\ndef AR(a,b):\n d=math.acos((SC(a,b)/LN(a)/LN(b)))\n return d\ndef gcd(x,y):\n while y!=0: x,y=y,x%y\n return x\ndef lcm(x,y):\n return x*y/gcd(x,y)\n_IsSquare=False\nx1,y1=input().split()\nx1,y1=float(x1),float(y1)\nx2,y2=input().split()\nx2,y2=float(x2),float(y2)\nx3,y3=input().split()\nx3,y3=float(x3),float(y3)\na=[x3-x1,y3-y1]\nb=[x2-x1,y2-y1]\nA=AR(a,b)\nif SC(a,b)==0:\n _IsSquare=True\n print(LN(a)*LN(b))\na=[x3-x2,y3-y2]\nb=[x1-x2,y1-y2]\nB=AR(a,b)\nif SC(a,b)==0:\n _IsSquare=True\n print(LN(a)*LN(b))\na=[x1-x3,y1-y3]\nb=[x2-x3,y2-y3]\nC=AR(a,b)\nif SC(a,b)==0:\n _IsSquare=True\n print(LN(a)*LN(b))\nif not _IsSquare:\n n1=math.pi/A\n n2=math.pi/B\n n3=math.pi/C\n \n i=2\n n=0\n while not n and i<=100:\n _1=float(i)/n1\n _2=float(i)/n2\n _3=float(i)/n3\n if float(round(_1,0)-0.02)<=_1<=float(round(_1,0)+0.02) and float(round(_2,0)-0.02)<=_2<=float(round(_2,0)+0.02) and float(round(_3,0)-0.02)<=_3<=float(round(_3,0)+0.02):\n n=i\n i+=1\n a=LN([x2-x1,y2-y1])\n b=LN([x3-x2,y3-y2])\n c=LN([x1-x3,y1-y3])\n p=(a+b+c)/2\n S=math.sqrt(p*(p-a)*(p-b)*(p-c))\n R=(a*b*c)/(4*S)\n if int(a)==int(b)==int(c):\n print(S)\n else: print((float(float(n)/2))*(R**2)*math.sin(2*math.pi/n))\n "}, {"source_code": "import math\n\nA = map(float,raw_input().strip().split())\nB = map(float,raw_input().strip().split())\nC = map(float,raw_input().strip().split())\n\ndef is_close(a, b, tol=1e-9):\n return abs(a-b) <= tol\n\ndef calculateDistance(x1, y1, x2, y2) :\n return math.sqrt( (x2-x1)**2 + (y2-y1)**2 )\n\ndef calculateAreaOfTriangle(a,b,c) :\n semiPerimeter = (a+b+c)/2\n return math.sqrt(semiPerimeter * (semiPerimeter - a) * (semiPerimeter - b) * (semiPerimeter -c))\n\ndef calculateRadius(sideLength, alpha) :\n return sideLength/(2*math.sin(alpha))\n\ndef calculateAngle(adjacentSide1, adjacentSide2, oppositeSide) :\n \"\"\" This function calculates the angle of a triangle using the sides of it. Uses Law Of Cosines.\n \n Arguments:\n adjacentSide1 {[int]} -- [One of the sides which has got vertice which contains this point]\n adjacentSide2 {[int]} -- [One of the sides which has got vertice which contains this point]\n oppositeSide {[int]} -- [The side opposite to the angle which needs to be calculated. This side doesn't contain the center vertex of the angle being calculated.]\n \"\"\"\n\n angle = math.acos((adjacentSide1**2 + adjacentSide2**2 - oppositeSide**2)/(2*adjacentSide1*adjacentSide2))\n return angle\n\ndef gcd(x,y,eps = 0.001) :\n while math.fabs(x) > eps and math.fabs(y) > eps:\n if x > y :\n x = x - (math.floor(x/y)*y)\n else :\n y = y - (math.floor(y/x)*x)\n return x+y\n\ndef calculateSidesOfPolygon(A,B,C) :\n \"\"\"This calculates the number of sides of an equiangular regular polygon given 3 angles of the 3 random points.\n \n Arguments:\n A {[float]} -- [1st angle in radians formed by the triangle]\n B {[float]} -- [2nd angle in radians formed by the triangle]\n C {[float]} -- [3rd angle in radians formed by the triangle]\n \"\"\"\n sides = 1/(gcd((A/math.pi),gcd((B/math.pi),(C/math.pi))))\n return sides\n\ndef calculateApothem(sideLength,sides) :\n \"\"\"Calculates Apothem of a regular polygon\n \n Arguments:\n circumRadius {[float]} -- Circumradius of the polygon\n sides {[int]} -- The number of sides of the polygon\n \"\"\"\n return sideLength/(2*math.tan(math.pi/sides))\n\ndef calculateAreaOfPolygon(circumRadius,numberOfSides) :\n \"\"\"Calculates the area of an equiangular regular n sided polygon with given circumradius\n \n Arguments:\n sides {int} -- The number of sides in the polygon\n circumRadius {float} -- The circumradius of the polygon\n \"\"\"\n area = numberOfSides*0.5*((circumRadius**2) * math.sin((2*math.pi)/numberOfSides))\n return area\n\nAB = calculateDistance(A[0],A[1],B[0],B[1])\nBC = calculateDistance(B[0],B[1],C[0],C[1])\nAC = calculateDistance(A[0],A[1],C[0],C[1])\n\nsidesOfTriangle = [AB,BC,AC]\nsidesOfTriangle.sort()\n\nangleA = calculateAngle(AB,AC,BC)\nangleB = calculateAngle(AB,BC,AC)\nangleC = math.pi - angleA - angleB\n\nminimumSides = round(calculateSidesOfPolygon(angleA,angleB,angleC))\n\nareaOfTriangle = calculateAreaOfTriangle(AB,BC,AC)\n\ncircumRadius = calculateRadius(BC,angleA)\n\nprint calculateAreaOfPolygon(circumRadius,minimumSides)"}, {"source_code": "from math import *\n \np = [list(map(float, input().split())) for i in range(3)]\n \na, b, c = [hypot(p[i][0] - p[(i+1)%3][0], p[i][1] - p[(i+1)%3][1]) for i in range(3)]\nA, B, C = [acos((y*y+z*z-x*x)/(2*y*z)) for x, y, z in [(a, b, c), (b, c, a), (c, a, b)]]\nR = a/sin(A)*0.5\ndef g(x,y):return x if y<1e-3 else g(y,fmod(x,y))\nu=2*g(pi, g(A,g(B,C)))\nprint(R*R*sin(u)*pi/u)"}, {"source_code": "import math\n\ndef compute_triangle_side(p1, p2, p3):\n l1 = ((p2[0] - p3[0])**2 + (p2[1] - p3[1])**2)**(1/2)\n l2 = ((p1[0] - p3[0])**2 + (p1[1] - p3[1])**2)**(1/2)\n l3 = ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**(1/2)\n\n return (l1, l2, l3)\n\ndef compute_circumscribed_circle_radius(l1, l2, l3):\n p = (l1 + l2 + l3) / 2 # half_perimeter for heron\n area = (p * (p - l1) * (p - l2) * (p - l3))**(1 / 2) # area using heron formula\n radius = (l1 * l2 * l3) / (4 * area)\n\n return radius\n\ndef round_float(float_value):\n return math.floor(float_value)\n\ndef compute_min_number_of_vertices(radius):\n for n in range(3, 101):\n # area of regular polygon using number of sides and radius of cc\n area = (1/2) * n * radius * radius * math.sin((2 * math.pi) / n)\n print(area)\n if area - round_area(area) <= 0.0001:\n print(n)\n return \"{0:.6f}\".format(area)\n\n return ((1/2) * 100 * radius * radius * math.sin((2 * math.pi) / 100))\n\ndef compute_side_length(radius):\n min_area = -1\n for n in range(3, 101):\n side_length = 2 * radius * math.sin(math.pi / n)\n print(side_length)\n if side_length - round_float(side_length) <= 0.001:\n return n\n return 100\n\n# def find_min_n(radius, l1, l2, l3):\n# (angle1, angle2, angle3) = compute_angles_to_O(radius, l1, l2, l3)\n# print(angle1, angle2, angle3)\n# for n in range(3, 101):\n# min_section = 2 * math.pi / n\n# print(min_section)\n# angle1_check = False\n# angle2_check = False\n# angle3_check = False\n# for p in range(1, n + 1):\n# curr_angle = p * min_section\n# if curr_angle - angle1 <= 0.0001:\n# angle1_check = True\n# if curr_angle - angle2 <= 0.0001:\n# angle2_check = True\n# if curr_angle - angle3 <= 0.0001:\n# angle3_check = True\n# if angle1_check and angle2_check and angle3_check:\n# return n\n# return 100\n\n# def find_min_n(radius, l1, l2, l3):\n# (angle1, angle2, angle3) = compute_angles_to_O(radius, l1, l2, l3)\n# for n in range(3, 101):\n# min_section = 2 * math.pi / n\n# r1 = angle1 / min_section\n# r2 = angle2 / min_section\n# r3 = angle3 / min_section\n# if r1 - round(r1) <= 0.0001 and r2 - round(r2) <= 0.0001 and r3 - round(r3) <= 0.0001:\n# return n\n\ndef compute_gcd(a1, a2):\n if a1 < a2:\n return compute_gcd(a2, a1)\n\n if abs(a2) < 0.001:\n return a1\n else:\n return compute_gcd(a2, a1 - math.floor(a1 / a2) * a2)\n\ndef find_min_n(radius, l1, l2, l3):\n angle1 = math.acos((l2 * l2 + l3 * l3 - l1 * l1) / (2 * l2 * l3))\n angle2 = math.acos((l1 * l1 + l3 * l3 - l2 * l2) / (2 * l1 * l3))\n angle3 = math.acos((l1 * l1 + l2 * l2 - l3 * l3) / (2 * l1 * l2))\n\n return round(math.pi / compute_gcd(angle2, compute_gcd(angle1, angle3)))\n\n# consider O the center of circumscribed circle, we compute AOC, BOC, AOB\n# A, B, C are the given points p1, p2, p3\n# R is the radius\ndef compute_angles_to_O(R, l1, l2, l3):\n angle1 = math.acos((2 * R * R - l1 * l1) / (2 * R * R))\n angle2 = math.acos((2 * R * R - l2 * l2) / (2 * R * R))\n angle3 = math.acos((2 * R * R - l3 * l3) / (2 * R * R))\n return (angle1, angle2, angle3)\n\nif __name__ == \"__main__\":\n p1 = input().split(\" \")\n p1x = float(p1[0])\n p1y = float(p1[1])\n p2 = input().split(\" \")\n p2x = float(p2[0])\n p2y = float(p2[1])\n p3 = input().split(\" \")\n p3x = float(p3[0])\n p3y = float(p3[1])\n \n (l1, l2, l3) = compute_triangle_side((p1x, p1y), (p2x, p2y), (p3x, p3y))\n radius = compute_circumscribed_circle_radius(l1, l2, l3)\n min_n = find_min_n(radius, l1, l2, l3)\n # print(min_n)\n area = (1/2) * min_n * radius * radius * math.sin((2 * math.pi) / min_n)\n print(area)"}, {"source_code": "from math import atan2, asin, fmod, pi, sin\ndef gcd(a,b):\n\treturn a if abs(b)<1e-4 else gcd(b,fmod(a,b))\ndef alpha(a,b):\n\treturn abs(atan2((a*b.conjugate()).imag, (a*b.conjugate()).real))\np=map(lambda x:x[0]+1j*x[1],[map(float,raw_input().split()) for s in range(3)])\nR=abs(p[1]-p[0])*abs(p[2]-p[1])*abs(p[2]-p[0])/abs(((p[1]-p[0])*((p[2]-p[0]).conjugate())).imag)/2\nN=1/reduce(gcd,[alpha(p[(i+1)%3]-p[i],p[(i+2)%3]-p[i])/pi for i in range(3)])\nprint '%.9f'%(R**2*N*1./2*sin(2*pi/N))\n"}, {"source_code": "#!/usr/bin/env python3\n\nfrom math import sin, cos, pi, sqrt\n\n# Number of given points\nNUMPOINTS = 3\n\n# Maximum amount of sides of the polygon\nMAXSIDES = 100\n\n# Point comparison precision (decimal signs)\nPRECISION = 4\n\n# Enable debug logging\nDEBUG = False\n\n\n# \u041e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\ndef log(arg, highlight=False):\n if not DEBUG:\n return\n\n if highlight:\n print('\\033[4m' + str(arg) + '\\033[0m')\n else:\n print(arg)\n\n\n# \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a (\u043a\u043e\u043b\u044b\u0448\u043a\u043e\u0432)\np = []\n\n# Point comparison error\nepsilon = 10 ** (-1 * PRECISION)\nlog('Error: {}'.format(epsilon))\n\n\n# Input all points\nlog('Source points', True)\n\nfor i in range(NUMPOINTS):\n s = [float(n) for n in input().strip().split()]\n p.append((s[0], s[1]))\n\nlog(p)\n\n\n# \u041d\u0435\u043b\u044c\u0437\u044f \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0440\u0430\u0441\u0447\u0451\u0442\u0430\u0445\nlog('Permuted points', True)\n\nif p[1][0] == p[0][0]:\n tmp = p[2]\n p[2] = p[1]\n p[1] = tmp\n\nif p[2][0] == p[1][0]:\n tmp = p[2]\n p[2] = p[0]\n p[0] = tmp\n\nlog(p)\n\n\n# Line slope coefficient\nlog('Line slope coefficients', True)\n\nma = (p[1][1] - p[0][1]) / (p[1][0] - p[0][0])\nmb = (p[2][1] - p[1][1]) / (p[2][0] - p[1][0])\n\nlog('ma = {}, mb = {}'.format(ma, mb))\n\n\n# Circumcircle center\nlog('Circumcircle center', True)\n\nx = (ma * mb * (p[0][1] - p[2][1]) + mb * (p[0][0] + p[1][0]) - ma * (p[1][0] + p[2][0])) / (2 * (mb - ma))\ny = -1 * (x - (p[0][0] + p[1][0]) / 2) / ma + (p[0][1] + p[1][1]) / 2\n\nlog('x = {}, y = {}'.format(x, y))\n\n\n# Offset all points so that circumcircle's center is at (0; 0)\nlog('Point offset', True)\n\ntmp, p = p, []\n\nfor point in tmp:\n p.append((point[0] - x, point[1] - y))\n\nlog(p)\n\n\n# Checl every polygon for matching points\nfor n in range(3, MAXSIDES + 1):\n log('Number of sides: {}'.format(n), True)\n\n matched = 1\n\n d = 2 * pi / n\n sind = sin(d)\n cosd = cos(d)\n\n log('d = {}, sind = {}, cosd = {}'.format(d, sind, cosd))\n\n pd = p[0]\n\n for i in range(1, n):\n pd = (pd[0] * cosd - pd[1] * sind, pd[0] * sind + pd[1] * cosd)\n\n log('i = {}, p = {}'.format(i, pd))\n\n for point in p[1:]:\n delta = sqrt((point[0] - pd[0]) ** 2 + (point[1] - pd[1]) ** 2)\n\n log('\\tpoint = {}, delta = {}'.format(point, delta))\n\n if delta < epsilon:\n matched += 1\n\n if matched == NUMPOINTS:\n break\n\n# \u0420\u0430\u0434\u0438\u0443\u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438\nradius = sqrt(p[0][0] ** 2 + p[0][1] ** 2)\n\n# \u041f\u043b\u043e\u0449\u0430\u0434\u044c n-\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u0441 \u0440\u0430\u0434\u0438\u0443\u0441\u043e\u043c \u0432\u044b\u0448\u0435\narea = n * (radius ** 2) * sind / 2\n\nprint(area)\n"}, {"source_code": "from math import acos, sin, sqrt, pi\nfrom decimal import Decimal\nAx,Ay=map(float,raw_input().split())\nBx,By=map(float,raw_input().split())\nCx,Cy=map(float,raw_input().split())\na_2=(Bx-Cx)**2+(By-Cy)**2; a=sqrt(a_2)\nb_2=(Ax-Cx)**2+(Ay-Cy)**2; b=sqrt(b_2)\nc_2=(Bx-Ax)**2+(By-Ay)**2; c=sqrt(c_2)\n\nP=(a+b+c)/2\nS=sqrt(P*(P-a)*(P-b)*(P-c))\nR=a*b*c/(4*S)\nR_2=a_2*b_2*c_2/((a+b+c)*(b+c-a)*(a+b-c)*(a+c-b))\n\nli = [float(x) for x in range(1,101)]\n\n# print b_2\n# mm=1-b_2/(2*R_2) \n# mmm = Decimal(str(mm))\n# print mm\n# print mmm\n# print acos(-1.0) \n# print round(acos(mmm)/(2*pi/4) , 3)\nfor i in range(3,101):\n d1 = Decimal(str(1-c_2/(2*R_2)))\n d2 = Decimal(str(1-a_2/(2*R_2)))\n d3 = Decimal(str(1-b_2/(2*R_2)))\n \n if round(acos(d1)/(2*pi/i) , 3) in li \\\n and round(acos(d2)/(2*pi/i) , 3) in li\\\n and round(acos(d3)/(2*pi/i) , 3) in li :\n break\n \nSres=i*R_2*sin(2*pi/i)/2\nprint '%.6f' % Sres\n \n \n \n "}, {"source_code": "from math import*\na = list(map(float, input().split()))\nb = list(map(float, input().split()))\nc = list(map(float, input().split()))\nda = atan2(b[1] - a[1], b[0] - a[0]) - atan2(c[1] - a[1], c[0] - a[0])\ndb = atan2(a[1] - b[1], a[0] - b[0]) - atan2(c[1] - b[1], c[0] - b[0])\ndc = atan2(b[1] - c[1], b[0] - c[0]) - atan2(a[1] - c[1], a[0] - c[0])\nda = abs(da)\ndb = abs(db)\ndc = abs(dc)\nif(da > pi):\n da = 2 * pi - da\nif(db > pi):\n db = 2 * pi - db\nif(dc > pi):\n dc = 2 * pi - dc\nbc = (c[0] - b[0])**2 + (c[1] - b[1])**2\nfor i in range(3, 101):\n x = pi / i\n f = 3 * [0]\n for j in range(1, i - 1):\n if abs(x * j - da) < 0.0001:\n f[0] = 1\n if abs(x * j - db) < 0.0001:\n f[1] = 1\n if abs(x * j - dc) < 0.0001:\n f[2] = 1\n if f == 3 * [1]:\n o = round(da / x) - 1\n t = i * [1]\n for j in range(1, i - 1):\n t[j] = t[j - 1] * cos(x) + cos(x * j)\n print(i * bc / t[o] / t[o] * cos(x) / sin(x) / 4)\n break\n"}, {"source_code": "from math import*\na = list(map(float, input().split()))\nb = list(map(float, input().split()))\nc = list(map(float, input().split()))\nda = atan2(b[1] - a[1], b[0] - a[0]) - atan2(c[1] - a[1], c[0] - a[0])\ndb = atan2(a[1] - b[1], a[0] - b[0]) - atan2(c[1] - b[1], c[0] - b[0])\ndc = atan2(b[1] - c[1], b[0] - c[0]) - atan2(a[1] - c[1], a[0] - c[0])\nda = abs(da)\ndb = abs(db)\ndc = abs(dc)\nif(da > pi):\n da = 2 * pi - da\nif(db > pi):\n db = 2 * pi - db\nif(dc > pi):\n dc = 2 * pi - dc\nbc = (c[0] - b[0])**2 + (c[1] - b[1])**2\nfor i in range(3, 101):\n x = pi / i\n f = 3 * [0]\n for j in range(1, i - 1):\n if abs(x * j - da) < 0.0001:\n f[0] = 1\n if abs(x * j - db) < 0.0001:\n f[1] = 1\n if abs(x * j - dc) < 0.0001:\n f[2] = 1\n if f == 3 * [1]:\n o = round(da / x) - 1\n t = i * [1]\n for j in range(1, i - 1):\n t[j] = t[j - 1] * cos(x) + cos(x * j)\n print(i * bc / t[o] / t[o] * cos(x) / sin(x) / 4)\n break"}, {"source_code": "import math\n\ndef vec( u, v ):\n\treturn [u[i]-v[i] for i in range(len(u))]\n\ndef dis( u ):\n\treturn math.sqrt(u[0]**2+u[1]**2)\n\ndef cross( u, v ):\n\treturn (u[0]*v[1]-v[0]*u[1])\n\ndef dot( u, v ):\n\treturn (u[0]*v[0]+u[1]*v[1])\n\ndef eq( a, b, eps=1e-3 ):\n\treturn math.fabs(a-b) < eps\n\ndef gcd( a, b ):\n\twhile not eq(b,0): t = b; b = a%b; a = t\n\treturn a\n\np = [[float(v) for v in input().split()] for _ in range(3)]\n\na = dis(vec(p[0],p[1]))\nb = dis(vec(p[1],p[2]))\nc = dis(vec(p[2],p[0]))\nS = math.fabs(0.5*cross(vec(p[1],p[0]),vec(p[2],p[0])))\nR = a*b*c/(4*S)\n\nA = math.acos((R**2-0.5*a**2)/R**2)\nB = math.acos((R**2-0.5*b**2)/R**2)\nC = math.acos((R**2-0.5*c**2)/R**2)\n\nminAng = gcd(2*math.pi, gcd(A,gcd(B,C)))\n#print( A/math.pi*180, B/math.pi*180, C/math.pi*180)\n#print( minAng/math.pi*180, R )\nn = (math.pi/minAng)\n\nprint( '{:.6f}'.format(n*R*R*math.sin(minAng)) )\n"}], "negative_code": [{"source_code": "import math\nfrom fractions import gcd\n[(x0,y0),(x1,y1),(x2,y2)] = [raw_input().split() for _ in xrange(3)]\nx0,y0 = float(x0),float(y0)\nx1,y1 = float(x1),float(y1)\nx2,y2 = float(x2),float(y2)\n\n# first, solve for the center of the circle (p,q)\n# to see how I did this, see this math.stackexchange post:\n# https://math.stackexchange.com/questions/213658/get-the-equation-of-a-circle-when-given-3-points\na11,a12,a21,a22 = 2*(x0-x1), 2*(y0-y1), 2*(x0-x2), 2*(y0-y2)\nb1,b2 = x0**2-x1**2+y0**2-y1**2, x0**2-x2**2+y0**2-y2**2\nq = (a21*b1 - a11*b2)/(a21*a12 - a11*a22)\np = (b1 - a12*q)/a11\nr2 = (x0 - p)**2 + (y0 - q)**2\n\n# as described here:\n# https://math.stackexchange.com/questions/1142644/regular-polygon-determined-by-three-vertices\n# we can determine the smallest number of sides given the angles with the center\nAB = ((x0 - p)*(x1 - p) + (y0 - q)*(y1 - q))/r2\nBC = ((x2 - p)*(x1 - p) + (y2 - q)*(y1 - q))/r2\nCA = ((x0 - p)*(x2 - p) + (y0 - q)*(y2 - q))/r2\n\nAOB = 180*math.acos(AB)/math.pi\nBOC = 180*math.acos(BC)/math.pi\nCOA = 180*math.acos(CA)/math.pi\n\nn,c1,c2,c3 = 2,0,0,0\nwhile c1 + c2 + c3 != 3 and n <= 100:\n\tn += 1\n\ta = 360.0/n\n\ts1,s2,s3 = AOB/a, BOC/a, COA/a\n\tc1 = int(math.fabs(round(s1) - s1) < 0.1)\n\tc2 = int(math.fabs(round(s2) - s2) < 0.1)\n\tc3 = int(math.fabs(round(s3) - s3) < 0.1)\n\nprint n*r2*math.sin(2*math.pi/n)/2"}, {"source_code": "from math import sqrt, sin, acos, pi\n\ndist_sq = lambda A, B: (A[0] - B[0])**2 + (A[1] - B[1])**2\n\ndef angle(R, A, B):\n c = dist_sq(A, B)\n a = dist_sq(R, B)\n b = dist_sq(R, A)\n cosine = (a + b - c)/sqrt(4 * a * b)\n return acos(cosine)\n\ndef circumcentre(A, B, C):\n a = dist_sq(B, C)\n b = dist_sq(A, C)\n c = dist_sq(A, B)\n bary = (\n a * (b + c - a),\n b * (c + a - b),\n c * (a + b - c),\n )\n x = (bary[0] * A[0] + bary[1] * B[0] + bary[2] * C[0])/sum(bary)\n y = (bary[0] * A[1] + bary[1] * B[1] + bary[2] * C[1])/sum(bary)\n return (x, y)\n\ndef div(m, n):\n m, n = max(m, n), min(m, n)\n return abs(round(m/n) - m/n) < 10**-6\n\ndef gcd(a, b):\n a, b = max(a, b), min(a, b)\n if div(a, b):\n return b\n else:\n return gcd(b, a-b)\n\nA = tuple(map(float, input().split()))\nB = tuple(map(float, input().split()))\nC = tuple(map(float, input().split()))\ncir = circumcentre(A, B, C)\nR = dist_sq(cir, A)\n\nangles = [angle(cir, A, B), angle(cir, B, C), angle(cir, C, A)]\ngamma = gcd(angles[0], angles[1])\nprint(pi * R * sin(gamma)/gamma)"}, {"source_code": "import math\n[(x0,y0),(x1,y1),(x2,y2)] = [raw_input().split() for _ in xrange(3)]\nx0,y0 = float(x0),float(y0)\nx1,y1 = float(x1),float(y1)\nx2,y2 = float(x2),float(y2)\n\n# first, solve for the center of the circle (p,q)\n# to see how I did this, see this math.stackexchange post:\n# https://math.stackexchange.com/questions/213658/get-the-equation-of-a-circle-when-given-3-points\na11,a12,a21,a22 = 2*(x0-x1), 2*(y0-y1), 2*(x0-x2), 2*(y0-y2)\nb1,b2 = x0**2-x1**2+y0**2-y1**2, x0**2-x2**2+y0**2-y2**2\nq = (a21*b1 - a11*b2)/(a21*a12 - a11*a22)\np = (b1 - a12*q)/a11\n\n# as described here:\n# https://math.stackexchange.com/questions/1142644/regular-polygon-determined-by-three-vertices\n# we can determine the smallest number of sides given the angles with the center\nAB = ((x0 - p)*(x1 - p) + (y0 - q)*(y1 - q))/math.sqrt(((x0 - p)**2 + (y0 - q)**2)*((x1 - p)**2 + (y1 - q)**2))\nBC = ((x2 - p)*(x1 - p) + (y2 - q)*(y1 - q))/math.sqrt(((x2 - p)**2 + (y2 - q)**2)*((x1 - p)**2 + (y1 - q)**2))\nCA = ((x0 - p)*(x2 - p) + (y0 - q)*(y2 - q))/math.sqrt(((x0 - p)**2 + (y0 - q)**2)*((x2 - p)**2 + (y2 - q)**2))\n\nAOB = int(round(180*math.acos(AB)/math.pi))\nBOC = int(round(180*math.acos(BC)/math.pi))\nCOA = int(round(180*math.acos(CA)/math.pi))\n\n(r1,r2,r3) = (AOB/360.0,BOC/360.0,COA/360.0)\n\n# brute forcing a bit here... might be too slow\nn = 2\nc1,c2,c3 = 0,0,0\nwhile c1 + c2 + c3 != 3 and n <= 100:\n\tc1,c2,c3 = 0,0,0\n\tn += 1\n\tif n*r1 == math.floor(n*r1):\n\t\tc1 = 1\n\tif n*r2 == math.floor(n*r2):\n\t\tc2 = 1\n\tif n*r3 == math.floor(n*r3):\n\t\tc3 = 1\n\nprint n"}, {"source_code": "from math import sin, acos, degrees, radians, pi, modf\n\nif __name__ == \"__main__\": \n i1 = raw_input()\n i2 = raw_input()\n i3 = raw_input()\n \n p1 = i1.split(' ')\n p2 = i2.split(' ')\n p3 = i3.split(' ')\n \n x1 = float(p1[0])\n y1 = float(p1[1])\n x2 = float(p2[0])\n y2 = float(p2[1])\n x3 = float(p3[0])\n y3 = float(p3[1]) \n \n x0 = ((y1-y2)*(x1**2+y1**2-x3**2-y3**2)-(y1-y3)*(x1**2+y1**2-x2**2-y2**2)) / 2 / ( (y1-y3)*(x2-x1) - (y1-y2)*(x3-x1) )\n y0 = ((x3-x1)*(x2**2+y2**2-x1**2-y1**2)-(x2-x1)*(x3**2+y3**2-x1**2-y1**2)) / 2 / ( (x2-x1)*(y1-y3) - (y1-y2)*(x3-x1) )\n \n #R = (abs(x1-x0)**2 + abs(y1-y0)**2) ** 0.5\n \n ptlist = []\n ptlist.append({'x':float(p1[0]), 'y':float(p1[1])})\n ptlist.append({'x':float(p2[0]), 'y':float(p2[1])})\n ptlist.append({'x':float(p3[0]), 'y':float(p3[1])})\n\n linelist = []\n linelist.append({'pt1':ptlist[0], 'pt2':ptlist[1], 'long':0.0, 'arc':0.0, 'angle':0})\n linelist.append({'pt1':ptlist[0], 'pt2':ptlist[2], 'long':0.0, 'arc':0.0, 'angle':0})\n linelist.append({'pt1':ptlist[1], 'pt2':ptlist[2], 'long':0.0, 'arc':0.0, 'angle':0})\n \n for l in linelist:\n l['long'] = (\n abs(l['pt1']['x'] - l['pt2']['x'])**2\n +abs(l['pt1']['y'] - l['pt2']['y'])**2\n ) **0.5\n \n a = linelist[0]['long']\n b = linelist[1]['long']\n c = linelist[2]['long']\n \n p = (a+b+c) / 2.0\n S = (p * (p-a) * (p-b) * (p-c)) ** 0.5\n R = (a*b*c)/(4.0*S)\n \n for l in linelist:\n l['arc'] = acos((R*R + R*R - l['long']*l['long'])/(2.0*R*R))\n l['angle'] = round(degrees(l['arc']),3)\n\n mina = min(linelist[0]['angle'], linelist[1]['angle'], linelist[2]['angle'])\n maxa = max(linelist[0]['angle'], linelist[1]['angle'], linelist[2]['angle'])\n \n a1 = linelist[0]['angle']\n a2 = linelist[1]['angle']\n a3 = linelist[2]['angle']\n\n if a1+a2+a3 < 357.0:\n temp = a1\n a1 = mina\n a2 = maxa - mina\n a3 = 360.0 - maxa \n \n mina = min(a1,a2,a3)\n \n angle = 0.01\n x = 0.01\n while x < mina+0.01:\n aa1 = a1 / x\n aa2 = a2 / x\n aa3 = a3 / x\n \n aa1 = modf(aa1)[0]\n aa2 = modf(aa2)[0]\n aa3 = modf(aa3)[0]\n \n if aa1 < 0.01 and aa2 < 0.01 and aa3 < 0.01:\n angle = x\n \n x += 0.01\n \n if angle == 0.01:\n angle = mina\n \n angle = round(angle, 1)\n \n polyarea = (round(360.0/angle)/2) * (R**2) * sin(radians(angle))\n #print angle\n print polyarea \n "}, {"source_code": "from decimal import Decimal\nfrom math import atan2, pi, sin\n\n\nEPS = Decimal(1e-9)\npi = Decimal(pi)\n\n\nclass Vector:\n def __init__(self, x = 0, y = 0):\n self.x = x\n self.y = y\n\n def __neg__(self):\n return Vector(-self.x, -self.y)\n\n def __xor__(self, v2):\n return Decimal(abs(atan2(self | v2, self & v2)))\n\n def __and__(self, v2):\n return self.x * v2.x + self.y * v2.y\n\n def __or__(self, v2):\n return self.x * v2.y - self.y * v2.x\n\n\np = [list(map(Decimal, input().split())) for x in range(3)]\nca, ab, bc = [Vector(p[i][0] - p[i - 1][0], p[i][1] - p[i - 1][1]) for i in range(3)]\nangles = [-ca ^ ab, -ab ^ bc, -bc ^ ca]\nR_sq = (ab.x ** Decimal(2) + ab.y ** Decimal(2)) / Decimal(sin(angles[2])) ** Decimal(2) / Decimal(4)\nn = Decimal(3)\n# print(*(180 * angle / pi for angle in angles))\nwhile n < 101 and any(k for k in (angle * n / pi for angle in angles) if abs(k - int(k + EPS)) >= EPS):\n # print(n, *(k for k in ((pi - angle) * n / Decimal(2) / pi for angle in angles)))\n n += 1\nprint(n * R_sq * Decimal(sin(Decimal(2) * pi / n)) / Decimal(2))\n"}, {"source_code": "from math import pi, fmod, fabs, hypot, atan2, sin\n\npi2 = 2.0 * pi\nmin_angle = pi2 / 100.0\n\ndef nod(n, m):\n if n < min_angle / 2.0:\n modulo = fmod((pi2 / m + min_angle / 4.0), 1.0)\n if modulo > min_angle / 2.0:\n m /= modulo\n return m\n else:\n return nod(fmod(m, n), n)\n\nx1, y1 = map(float, raw_input().split())\nx2, y2 = map(float, raw_input().split())\nx3, y3 = map(float, raw_input().split())\n\n# Find normals at centers of [(x1, y1)-(x2, y2)] and [(x2, y2)-(x3, y3)]\nif y1 - y2 != 0.0:\n an12 = (x2 - x1) / (y1 - y2)\n bn12 = (y1 + y2) / 2.0 - an12 * (x1 + x2) / 2.0\nelse:\n an12 = None\n bn12 = (x1 + x2) / 2.0\nif y2 - y3 != 0.0:\n an23 = (x3 - x2) / (y2 - y3)\n bn23 = (y2 + y3) / 2.0 - an23 * (x2 + x3) / 2.0\nelse:\n an23 = None\n bn23 = (x2 + x3) / 2.0\n\n# Intersection of normals is circle center.\nif an12 is not None and an23 is not None:\n x0 = (bn23 - bn12) / (an12 - an23)\n y0 = an12 * x0 + bn12\nelif an12 is None:\n x0 = bn12\n y0 = an23 * x0 + bn23\nelse:\n x0 = bn23\n y0 = an12 * x0 + bn12\n\n# Relocate center to (0, 0)\nx1 -= x0\ny1 -= y0\nx2 -= x0\ny2 -= y0\nx3 -= x0\ny3 -= y0\n\n# Find radius\n#r = hypot(x2, y2)\nr2 = x2 * x2 + y2 * y2\n\n# Calculate angles\nangle1 = atan2(y1, x1)\nangle2 = atan2(y2, x2)\nangle3 = atan2(y3, x3)\n\nangle12 = fabs(angle1 - angle2)\nangle23 = fabs(angle2 - angle3)\nangle13 = fabs(angle1 - angle3)\n\n# Find angle between radiuses to nearby vertices\nside_angle = nod(*sorted((nod(*sorted((angle12, angle23))), angle13)))\n\n# Find n of our n-gon\nn = pi2 / side_angle\n\n# Finally calculate n-gon area\ns = n * r2 * sin(side_angle) / 2.0\n\nprint \"{0:.8f}\".format(s)\n"}, {"source_code": "import math\n\nx1, y1 = map(float, input().split())\nx2, y2 = map(float, input().split())\nx3, y3 = map(float, input().split())\n\nc1 = (x2 ** 2 - x1 ** 2 + y2 ** 2 - y1 ** 2) / 2\nc2 = (x3 ** 2 - x2 ** 2 + y3 ** 2 - y2 ** 2) / 2\n# dist x1-x2\nr1 = (c1 * (y3 - y2) - c2 * (y2 - y1)) / ((x2 - x1) * (y3 - y2) - (x3 - x2) * (y2 - y1))\n# dist x1-x3\nr2 = (c1 * (x3 - x2) - c2 * (x2 - x1)) / ((y2 - y1) * (x3 - x2) - (y3 - y2) * (x2 - x1))\n# ipotenuza\nr = ((r1 - x1) ** 2 + (r2 - y1) ** 2) ** 0.5\n\nfoobar = 0\nfor i in range(3, 101):\n foo = False\n bar = False\n for ii in range(1, i):\n x4 = (x1 - r1) * math.cos(2 * math.pi * ii / i) - math.sin(2 * math.pi * ii / i) * (y1 - r2) + r1\n y4 = (y1 - r2) * math.cos(2 * math.pi * ii / i) + math.sin(2 * math.pi * ii / i) * (x1 - r1) + r2\n # if i pillars yields a 'full circle'/regular polyogn; print ans\n if (x4 - x2) ** 2 + (y4 - y2) ** 2 < 0.00001:\n foo = True\n foobar = i\n break\n if (x4 - x3) ** 2 + (y4 - y3) ** 2 < 0.00001:\n bar = True\n foobar = i\n break\n# formula for area of equiangular polygon\nprint(foobar * r ** 2 * math.sin(2 * math.pi / foobar) / 2)\n"}, {"source_code": "from math import acos, sin, sqrt, pi\n\nAx,Ay=map(float,raw_input().split())\nBx,By=map(float,raw_input().split())\nCx,Cy=map(float,raw_input().split())\na_2=(Bx-Cx)**2+(By-Cy)**2; a=sqrt(a_2)\nb_2=(Ax-Cx)**2+(Ay-Cy)**2; b=sqrt(b_2)\nc_2=(Bx-Ax)**2+(By-Ay)**2; c=sqrt(c_2)\n\nP=(a+b+c)/2\nS=sqrt(P*(P-a)*(P-b)*(P-c))\nR=a*b*c/(4*S)\nR_2=a_2*b_2*c_2/((a+b+c)*(b+c-a)*(a+b-c)*(a+c-b))\n\nli = [float(x) for x in range(1,101)]\n \nfor i in range(3,101):\n if round(acos(1-c_2/(2*R_2))/(2*pi/i) , 3) in li \\\n and round(acos(1-a_2/(2*R_2))/(2*pi/i) , 3) in li\\\n and round(acos(1-b_2/(2*R_2))/(2*pi/i) , 3) in li :\n break\n \nprint i\nSres=i*R_2*sin(2*pi/i)/2\nprint Sres\n \n \n \n "}, {"source_code": "from math import pi, fabs, hypot, atan2, sin\n\npi2 = 2.0 * pi\neps = 0.000001\n\nx1, y1 = map(float, raw_input().split())\nx2, y2 = map(float, raw_input().split())\nx3, y3 = map(float, raw_input().split())\n\n# Find normals at centers of [(x1, y1)-(x2, y2)] and [(x2, y2)-(x3, y3)]\nif y1 - y2 != 0.0:\n an12 = (x2 - x1) / (y1 - y2)\n bn12 = (y1 + y2) / 2.0 - an12 * (x1 + x2) / 2.0\nelse:\n an12 = None\n bn12 = (x1 + x2) / 2.0\nif y2 - y3 != 0.0:\n an23 = (x3 - x2) / (y2 - y3)\n bn23 = (y2 + y3) / 2.0 - an23 * (x2 + x3) / 2.0\nelse:\n an23 = None\n bn23 = (x2 + x3) / 2.0\n\n# Intersection of normals is circle center.\nif an12 is not None and an23 is not None:\n x0 = (bn23 - bn12) / (an12 - an23)\n y0 = an12 * x0 + bn12\nelif an12 is None:\n x0 = bn12\n y0 = an23 * x0 + bn23\nelse:\n x0 = bn23\n y0 = an12 * x0 + bn12\n\n# Relocate center to (0, 0)\nx1 -= x0\ny1 -= y0\nx2 -= x0\ny2 -= y0\nx3 -= x0\ny3 -= y0\n\n# Find radius\nr = hypot(x2, y2)\n\n# Calculate angles\nangle1 = atan2(y1, x1)\nangle2 = atan2(y2, x2)\nangle3 = atan2(y3, x3)\n\nangle12 = angle1 - angle2\nangle23 = angle2 - angle3\nangle13 = angle1 - angle3\n\n# Find n of n-gon\nn = 0\nfor n in range(3, 101):\n if fabs(sin(n * angle12 / 2.0)) < eps and\\\n fabs(sin(n * angle23 / 2.0)) < eps and\\\n fabs(sin(n * angle13 / 2.0)) < eps:\n break\n\n# Finally calculate n-gon area\ns = n * r * r * sin(pi2 / n) / 2.0\n\nprint \"{0:.8f}\".format(s)\n"}, {"source_code": "#! /usr/bin/env python3\n'''\n' Title:\tC. Ancient Berland Circus\n' Author:\tCheng-Shih, Wong\n' Date:\t\t2016/04/01\n'''\n\nimport math\n\ndef vec( u, v ):\n\treturn [u[i]-v[i] for i in range(len(u))]\n\ndef dis( u ):\n\treturn math.sqrt(u[0]**2+u[1]**2)\n\ndef cross( u, v ):\n\treturn (u[0]*v[1]-v[0]*u[1])\n\ndef gcd( a, b ):\n\twhile b!=0: t = b; b = a%b; a = t\n\treturn a\n\np = [[float(v) for v in input().split()] for _ in range(3)]\n\na = dis(vec(p[0],p[1]))\nb = dis(vec(p[1],p[2]))\nc = dis(vec(p[2],p[0]))\nS = 0.5*cross(vec(p[1],p[0]),vec(p[2],p[0]))\nR = a*b*c/(4*S)\n\nA = 2*abs(round(math.asin(a/(2*R))*180/math.pi))\nB = 2*abs(round(math.asin(b/(2*R))*180/math.pi))\nC = 2*abs(round(math.asin(c/(2*R))*180/math.pi))\n\nminAng = gcd(A,gcd(B,C))\n#print( A, B, C, minAng )\n\nprint( '{:.6f}'.format((180/minAng)*R*R*math.sin(minAng*math.pi/180)) )\n\n"}, {"source_code": "from math import sqrt, acos, pi, sin\n\nclass Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n def dot(self, other):\n return self.x * other.x + self.y * other.y\n\n def __add__(self, other):\n return Point(self.x + other.x, self.y + other.y)\n\n def __sub__(self, other):\n return Point(self.x - other.x, self.y - other.y)\n\n def __mul__(self, other):\n # Multiply by number\n return Point(self.x * other, self.y * other)\n\n def __str__(self):\n return \"{%.2f, %.2f}\" % (self.x, self.y, )\n\n def __abs__(self):\n return sqrt(self.x ** 2 + self.y ** 2)\n\nclass Line:\n '''\n Build line from coefficients A, B, C of its equation \"Ax + By + C = 0\"\n '''\n def __init__(self, a, b, c):\n self.a = a\n self.b = b\n self.c = c\n\n '''\n Build line from two points on it\n '''\n @staticmethod\n def from_points(p1, p2):\n a = p1.y - p2.y\n b = p2.x - p1.x\n\n return Line._from_vector_and_point((a, b, ), p1)\n\n '''\n Build line from direction vector and point on the line\n '''\n @staticmethod\n def _from_vector_and_point((vx, vy, ), p):\n return Line(vx, vy, - vx * p.x - vy * p.y)\n\n '''\n Returns vertor perpendicular to the given one (s.t. their dot product is zero)\n '''\n @staticmethod\n def _perp_vector(a, b):\n if b == 0:\n return 0.0, 1.0\n else:\n b_new = - 1.0 * a / b\n\n return 1.0, b_new\n\n '''\n Returns a line perpendicular to the current one that goes through point `p`\n '''\n def get_perp(self, p):\n a_new, b_new = self._perp_vector(self.a, self.b)\n\n return Line._from_vector_and_point((a_new, b_new, ), p)\n\n '''\n Returns the determinant of following matrix:\n [ `a00` `a01` ]\n [ `a10` `a11` ]\n '''\n @staticmethod\n def _det(a00, a01, a10, a11):\n return a00 * a11 - a01 * a10\n\n '''\n Returns the intersection point between the current line and `other`\n '''\n def intersect_with(self, other):\n delta = self._det(self.a, self.b, other.a, other.b)\n\n if delta == 0.0:\n raise Exception(\"ne peresekayutsia\")\n\n x = - self._det(self.c, self.b, other.c, other.b) / delta\n y = - self._det(self.a, self.c, other.a, other.c) / delta\n\n return Point(x, y)\n\n def __str__(self):\n return \"%.2fx + %.2fy + %.2f == 0\" % (self.a, self.b, self.c, )\n\ndef midpoint(p1, p2):\n return (p1 + p2) * 0.5\n\n# Returns radian measure of angle AOB, measured clockwise\ndef angle(a, o, b):\n oa = a - o\n ob = b - o\n\n cos_phi = 1.0 * oa.dot(ob) / abs(oa) / abs(ob)\n\n if cos_phi < -1.0:\n cos_phi = -1.0\n elif cos_phi > 1.0:\n cos_phi = 1.0\n\n phi = acos(cos_phi)\n\n if oa.y * ob.x - oa.x * ob.y < 0: # `ob` is counterclockwise to `oa`\n return 2.0 * pi - phi\n else:\n return phi\n\n# Returns where it is possible for a `num-sides`-sided regular polygon to have some vertices at angles `alpha` and\n# `beta` between each other\ndef regular_polygon_possible(num_vertices, alpha, beta):\n if alpha > beta:\n alpha, beta = beta, alpha\n\n enc = 0\n\n for i in xrange(1, num_vertices):\n for phi in (alpha, beta, ):\n if abs(phi - i * 2.0 * pi / num_vertices) < 2.0 * pi / 1750:\n enc += 1\n\n return enc == 2\n\ndef regular_polygon_area(r_big, num_vertices):\n return num_vertices / 2.0 * r_big ** 2 * sin(2.0 * pi / num_vertices)\n\nps = []\n\nfor i in [1, 2, 3]:\n x, y = map(float, raw_input().split(' '))\n\n ps.append(Point(x, y))\n\nl1 = Line.from_points(ps[0], ps[1])\nl2 = Line.from_points(ps[1], ps[2])\n\nm1 = midpoint(ps[0], ps[1])\nm2 = midpoint(ps[1], ps[2])\n\ncenter = l1.get_perp(m1).intersect_with(l2.get_perp(m2))\n\nalpha = angle(ps[0], center, ps[1])\nbeta = angle(ps[0], center, ps[2])\n\nnum_vertices = None\n\nfor i in xrange(3, 100 + 1):\n if regular_polygon_possible(i, alpha, beta):\n num_vertices = i\n break\n\n# print center\n\n# print num_vertices\n\n# print abs(ps[0] - center)\n\nprint regular_polygon_area(abs(ps[0] - center), num_vertices)\n"}, {"source_code": "# Codeforces // Problem - 1C. Ancient Berland Circus\nimport math\n\ndef equiangular(r, n):\n\t\"\"\"\n\tr: radius\n\tn: sides\n\treturn: area of a equiangular\n\t\"\"\"\n\treturn round(n * (1/2) * (r**2) * math.sin(2*math.pi/n), 6)\n\ndef triangle(a, b, c):\n\t\"\"\"\n\ta, b, c: tuple\n\t\"\"\"\n\treturn round(math.fabs((a[0]*b[1] - a[1]*b[0] + b[0]*c[1] - b[1]*c[0] + c[0]*a[1] - c[1]*a[0]) / 2), 6)\n\ndef circumcenter(a, b, c):\n\t\"\"\"\n\ta, b, c: tuple\n\t\"\"\"\n\tX = (1/2) * ((b[1]-c[1])*((a[0]**2+a[1]**2)-(b[0]**2+b[1]**2))-(a[1]-b[1])*((b[0]**2+b[1]**2)-(c[0]**2+c[1]**2))) / ((a[0]-b[0])*(b[1]-c[1])-(a[1]-b[1])*(b[0]-c[0]))\n\tY = (1/2) * ((b[0]-c[0])*((a[0]**2+a[1]**2)-(b[0]**2+b[1]**2))-(a[0]-b[0])*((b[0]**2+b[1]**2)-(c[0]**2+c[1]**2))) / ((a[1]-b[1])*(b[0]-c[0])-(a[0]-b[0])*(b[1]-c[1]))\n\treturn (round(X, 6), round(Y, 6))\n\ndef distance(x, y):\n\t\"\"\"\n\tx, y: tuple\n\t\"\"\"\n\treturn round(math.sqrt((x[0]-y[0])**2 + (x[1]-y[1])**2), 6)\n\n#A = input().split()\n#B = input().split()\n#C = input().split()\n#\n#a = ()\n#b = ()\n#c = ()\n#\n#for i in range(2):\n#\ta = a + (float(A[i]),)\n#\tb = b + (float(B[i]),)\n#\tc = c + (float(C[i]),)\n\n# print(a)\n# print(b)\n# print(c)\n# a = (0, 0)\n# b = (1, 1)\n# c = (0, 1)\n\na = (71.756151, 7.532275)\nb = (-48.634784, 100.159986)\nc = (91.778633, 158.107739)\n\no = circumcenter(a, b, c)\nr1 = distance(a,o)\nr2 = distance(b,o)\nr3 = distance(c,o)\n\n\nprint(\"ao:\", r1)\nprint(\"bo:\", r2)\nprint(\"co:\", r3)\n\n# print(equiangular(math.sqrt(2)/2, 3))\n# print(triangle(a, b, c))\n# print(r)\n\ne1 = triangle(a,b,o)\ne2 = triangle(a,c,o)\ne3 = triangle(b,c,o)\n\nprint(\"e1:\", e1)\nprint(\"e2:\", e2)\nprint(\"e3:\", e3)\n\nE1 = int(e1 * 10**6)\nE2 = int(e2 * 10**6)\nE3 = int(e3 * 10**6)\n\ngoal = math.gcd(math.gcd(E1, E2), math.gcd(E2, E3))\n\n# print(\"Goal:\", goal)\n# \n# print(\"Try:\", int(equiangular(r, 3) * 10**6) / 3)\n# print(\"Try:\", int(equiangular(r, 4) * 10**6) / 4)\n# print(\"Try:\", int(equiangular(r, 5) * 10**6) / 5)\n# print(\"Try:\", int(equiangular(r, 6) * 10**6) / 6)\n\n#n = 3\n#temp = int(equiangular(r, n) * 10**9) / n\n#while math.fabs(goal - temp) > 1:\n#\tn += 1\n#\ttemp = int(equiangular(r, n) * 10**9) / n\n#\n#print(equiangular(r, n))\n\n#for i in range(2, 100):\n#\tsingleArea = round(equiangular(r1, i+1) / (i+1), 6)\n#\tprint(\"\u25b2\", singleArea)\n\nn = 3\ntemp = int(round(equiangular(r1, n) / n, 6) * 10**6)\n\nwhile temp - goal > 10:\n\tn += 1\n\ttemp = int(round(equiangular(r1, n) / n, 6) * 10**6)\n\n#print(n)\nprint(equiangular(r1, n))"}, {"source_code": "# -coding: utf-8 -*-\nimport math\nclass Solution():\n def ancientBerlandCircus(self,x1,y1,x2,y2,x3,y3):\n d1 = math.sqrt(pow(x1-x2,2)+pow(y1-y2,2))\n d2 = math.sqrt(pow(x1-x3,2)+pow(y1-y3,2))\n d3 = math.sqrt(pow(x2-x3,2)+pow(y2-y3,2))\n p = (d1+d2+d3)/2\n s = math.sqrt(p*(p-d1)*(p-d2)*(p-d3))\n r = d1*d2*d3/4/s\n fal1 = math.acos(1-d1*d1/(2*r*r))\n fal3 = math.acos(1-d3*d3/(2*r*r))\n fal2 = 2*math.pi-fal1-fal3\n angle = self.fgcd(fal3,self.fgcd(fal1,fal2))\n mins = r*r/2*(2*math.pi/angle)*math.sin(angle)\n print '%.06f' % mins\n\n def fgcd(self,x,y):\n if x<1e-4:\n return y\n return self.fgcd(math.fmod(y,x),x)\n\nx1,y1 = raw_input().split()\nx2,y2 = raw_input().split()\nx3,y3 = raw_input().split()\nx1 = round(float(x1), 6)\ny1 = round(float(y1), 6)\nx2 = round(float(x2), 6)\ny2 = round(float(y2), 6)\nx3 = round(float(x3), 6)\ny3 = round(float(y3), 6)\ns = Solution()\ns.ancientBerlandCircus(x1,y1,x2,y2,x3,y3)"}, {"source_code": "A=list(map(float,input().split()))\nB=list(map(float,input().split()))\nC=list(map(float,input().split()))\na=[(A[0]-B[0])**2+(A[1]-B[1])**2,(C[0]-B[0])**2+(C[1]-B[1])**2,(A[0]-C[0])**2+(A[1]-C[1])**2]\na.sort()\nprint((a[0]*a[1])**0.5)\n"}, {"source_code": "from math import *\np = [list(map(float, input().split())) for i in range(3)]\na, b, c = [hypot((x1-x2), (y1-y2)) for (x1,y1), (x2,y2) in [(p[0], p[1]), (p[1], p[2]), (p[0], p[2])]]\nA, B, C = [acos((x*x+y*y-z*z)/2/x/y) for x,y,z in [(c,b,a), (a,c,b), (a,c,b)]]\nR = a / sin(A) / 2\ndef maxCommonDiv(m,n):\n\tif m < n:\n\t\tm, n = n, m\n\tif fmod(m, n) < 1e-3:\n\t\treturn n\n\telse:\n\t\treturn maxCommonDiv(fmod(m, n), n)\n\nu = 2 * maxCommonDiv(A, maxCommonDiv(B, C))\nprint(round(R * R * pi / u * sin(u), 7))\t"}, {"source_code": "A=list(map(float,input().split()))\nB=list(map(float,input().split()))\nC=list(map(float,input().split()))\nprint(abs(A[0]*B[1]-A[1]*B[0]+A[1]*C[0]-A[0]*C[1]+B[0]*C[1]-B[1]*C[0]))\n"}, {"source_code": "from decimal import Decimal\nfrom math import atan2, pi, sin\n\n\nEPS = Decimal(1e-7)\npi = Decimal(pi)\n\n\nclass Vector:\n def __init__(self, x = 0, y = 0):\n self.x = x\n self.y = y\n\n def __neg__(self):\n return Vector(-self.x, -self.y)\n\n def __xor__(self, v2):\n return Decimal(abs(atan2(self | v2, self & v2)))\n\n def __and__(self, v2):\n return self.x * v2.x + self.y * v2.y\n\n def __or__(self, v2):\n return self.x * v2.y - self.y * v2.x\n\n\np = [list(map(Decimal, input().split())) for x in range(3)]\nca, ab, bc = [Vector(p[i][0] - p[i - 1][0], p[i][1] - p[i - 1][1]) for i in range(3)]\nangles = [-ca ^ ab, -ab ^ bc, -bc ^ ca]\nR_sq = (ab.x ** Decimal(2) + ab.y ** Decimal(2)) / Decimal(sin(angles[2])) ** Decimal(2) / Decimal(4)\nn = Decimal(3)\n# print(*(180 * angle / pi for angle in angles))\nwhile n < 101 and any(k for k in (angle * n / pi for angle in angles) if abs(k - int(k + EPS)) >= EPS):\n # print(n, *(k for k in ((pi - angle) * n / Decimal(2) / pi for angle in angles)))\n n += 1\nprint(n * R_sq * Decimal(sin(Decimal(2) * pi / n)) / Decimal(2))\n"}, {"source_code": "import math\nmass=[]\nfor i in range(3):\n a=raw_input()\n x=float(a.split()[0])\n y=float(a.split()[1])\n mass.append([x,y])\nmass2=[]\nb=0\nfor y in range(2):\n b=b+(mass[0][y]-mass[1][y])**2\nmass2.append(b**0.5)\nb=0\nfor y in range(2):\n b=b+(mass[1][y]-mass[2][y])**2\nmass2.append(b**0.5)\nb=0\nfor y in range(2):\n b=b+(mass[0][y]-mass[2][y])**2\nmass2.append(b**0.5)\na=min(mass2)\nmass_s=[]\nmass_ABC=[]\nh=((mass2[0])**2+(mass2[1])**2-(mass2[2])**2)/(2*(mass2[0])*(mass2[1]))\nif -1<=h<=1:\n h=math.acos(h)*180/math.pi\n if (h-int(h)>0.5):\n h=int(h)+1\n else:\n h=int(h)\n mass_ABC.append(h)\nh=((mass2[1])**2+(mass2[2])**2-(mass2[0])**2)/(2*(mass2[1])*(mass2[2]))\nif -1<=h<=1:\n h=math.acos(h)*180/math.pi\n if (h-int(h)>0.5):\n h=int(h)+1\n else:\n h=int(h)\n mass_ABC.append(h)\nh=((mass2[0])**2+(mass2[2])**2-(mass2[1])**2)/(2*(mass2[0])*(mass2[2]))\nif -1<=h<=1:\n h=math.acos(h)*180/math.pi\n if (h-int(h)>0.5):\n h=int(h)+1\n else:\n h=int(h)\n mass_ABC.append(h)\n print(mass_ABC)\nfor i in range(len(mass_ABC)):\n if(180%mass_ABC[i]==0):\n for j in range(101):\n j+=1\n if j>2:\n if(j*mass_ABC[i]%(180+(j-3)*180)==0):\n s=0\n s=(j*(a**2))/(4*(math.tan(math.pi/j)))\n print(mass_ABC[i],j,s)\n mass_s.append(s)\nprint('%4.6f' % min(mass_s))"}, {"source_code": "import math\nimport sys\n\ndef beta(x11, x12, y11, y12):\n t = (x11*x12 + y11*y12)/(math.hypot(x11, y11)*math.hypot(x12, y12))\n if math.fabs(t) > 1.0:\n t = round(t)\n\n return math.acos(t)\n\n#sys.stdin = open('input.txt')\n\nmath.hypot = lambda x, y: math.sqrt(x*x + y*y)\n\nEPS = 1e-03\nPI = math.pi\n\nx1, y1 = map(float, input().split())\nx2, y2 = map(float, input().split())\nx3, y3 = map(float, input().split())\n\nl = math.hypot(x1 - x2, y1 - y2)*0.5\n\nxm = min(x1, x2) + math.fabs(x1 - x2)*0.5\nym = min(y1, y2) + math.fabs(y1 - y2)*0.5\n\nxp = y1 - y2\nyp = x2 - x1\np = math.hypot(xp, yp)\nlast = 0\n\nmark = False\ni = 3\nwhile i < 101:\n phi = 2.0*PI/float(i)\n j = i//2\n while j > 0:\n h = float(l)/math.tan(phi*float(j)*0.5)\n k = float(h)/float(p)\n\n x0_pos = xm - k*xp\n y0_pos = ym - k*yp\n x0_neg = xm + k*xp\n y0_neg = ym + k*yp\n r = math.hypot(x1 - x0_pos, y1 - y0_pos)\n\n c1 = math.fabs(math.hypot(x3 - x0_pos, y3 - y0_pos) - r) < EPS\n c2 = math.fabs(math.hypot(x3 - x0_neg, y3 - y0_neg) - r) < EPS\n if c1 or c2:\n if c1:\n x0, y0 = x0_pos, y0_pos\n else:\n x0, y0 = x0_neg, y0_neg\n\n #print(((x3 - x0)*(x2 - x0) + (y3 - y0)*(y2 - y0))/(math.hypot(x3 - x0, y3 - y0)*math.hypot(x2 - x0, y2 - y0)))\n b1 = beta(x3 - x0, y3 - y0, x1 - x0, y1 - y0)\n b2 = beta(x3 - x0, y3 - y0, x2 - x0, y2 - y0)\n b3 = beta(x1 - x0, y1 - y0, x2 - x0, y2 - y0)\n div = lambda b: math.fabs(b/phi - round(b/phi)) < EPS\n\n last = 0.5*float(r)*float(r)*math.sin(phi)*float(i)\n\n if div(b1) and div(b2) and div(b3):\n print(last)\n mark = True\n break\n\n j -= 1\n if mark:\n break\n\n i += 1\n\nif not mark:\n print(last)\n# I'm so dumb....................."}, {"source_code": "from math import *\n\ndef LineIntersect(a,b):\n det=lambda a,b,c,d:a*d-b*c\n z=det(a[0],a[1],b[0],b[1])\n return (-det(a[2],a[1],b[2],b[1])/z,-det(a[0],a[2],b[0],b[2])/z)\n\ndef GetCircleInOrigin(A):\n GetNormal=lambda (x,y):(-y,x)\n GetDif=lambda (x1,y1),(x2,y2):(x1-x2,y1-y2)\n GetSum=lambda (x1,y1),(x2,y2):(x1+x2,y1+y2)\n GetMultToCof=lambda (x1,y1),c:(x1*c,y1*c)\n NormalLine=lambda (a,b):(b[1]-a[1],a[0]-b[0],a[1]*b[0]-a[0]*b[1])\n L=[ (GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetSum(GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetNormal(GetDif(A[i+1],A[i])))) for i in range(2)]\n L=map(NormalLine,L)\n L=LineIntersect(L[0],L[1]) \n return map(lambda x:GetDif(x,L),A)\n\ndef gcd(a,b):\n if (b<pi/1000):\n return a;\n else:\n return gcd(b,fmod(a,b))\n\nA=[map(float,raw_input().split()) for i in range(3)]\nA=GetCircleInOrigin(A)\nC=[atan2(y,x) for x,y in A]\nC=[C[i]-C[j] for (i,j) in [(0,1),(1,2),(2,0)]]\nfor i in range(3):\n if (C[i]<0):\n C[i]+=2*pi\nR=hypot(*A[0])\nomega=gcd(C[0],gcd(C[1],C[2]))\nprint R**2*pi/omega*sin(omega)\n"}, {"source_code": "# @auther: guoyc\n# @date: 2018/7/16\n\nimport math\n\np1 = [float(_) for _ in input().split()]\np2 = [float(_) for _ in input().split()]\np3 = [float(_) for _ in input().split()]\n\n\ndef get_angle(p1, p2, p3):\n v1 = (p2[0] - p1[0], p2[1] - p1[1])\n v2 = (p3[0] - p1[0], p3[1] - p1[1])\n\n dot_prod = v1[0] * v2[0] + v1[1] * v2[1]\n\n l1 = math.sqrt(v1[0] ** 2 + v1[1] ** 2)\n l2 = math.sqrt(v2[0] ** 2 + v2[1] ** 2)\n\n angle = math.acos(dot_prod / (l1 * l2))\n\n return angle, l1, l2\n\n\npoint = None\nothers = None\nangle, l1, l2 = [None] * 3\n\nimport sys\n\nres = sys.maxsize\n\nif get_angle(p1, p2, p3)[0] >= math.pi / 3:\n angle, l1, l2 = get_angle(p1, p2, p3)\n n = int(2 * math.pi / (math.pi - angle))\n l = max(l1, l2)\n h = l * math.sin(math.pi / 2 - math.pi / n) * math.sin(math.pi / 2 - math.pi / n) / math.sin(2 * math.pi / n)\n res = min(res, l * h / 2 * n)\n\nif get_angle(p2, p1, p3)[0] >= math.pi / 3:\n angle, l1, l2 = get_angle(p2, p1, p3)\n n = int(2 * math.pi / (math.pi - angle))\n l = max(l1, l2)\n h = l * math.sin(math.pi / 2 - math.pi / n) * math.sin(math.pi / 2 - math.pi / n) / math.sin(2 * math.pi / n)\n res = min(res, l * h / 2 * n)\n\nif get_angle(p3, p1, p2)[0] >= math.pi / 3:\n angle, l1, l2 = get_angle(p3, p1, p2)\n n = int(2 * math.pi / (math.pi - angle))\n l = max(l1, l2)\n h = l * math.sin(math.pi / 2 - math.pi / n) * math.sin(math.pi / 2 - math.pi / n) / math.sin(2 * math.pi / n)\n res = min(res, l * h / 2 * n)\n\nprint(res)\n"}, {"source_code": "#! /usr/bin/env python3\n'''\n' Title:\tC. Ancient Berland Circus\n' Author:\tCheng-Shih, Wong\n' Date:\t\t2016/04/01\n'''\n\nimport math\n\ndef vec( u, v ):\n\treturn [u[i]-v[i] for i in range(len(u))]\n\ndef dis( u ):\n\treturn math.sqrt(u[0]**2+u[1]**2)\n\ndef cross( u, v ):\n\treturn (u[0]*v[1]-v[0]*u[1])\n\ndef gcd( a, b ):\n\twhile b!=0: t = b; b = a%b; a = t\n\treturn a\n\np = [[float(v) for v in input().split()] for _ in range(3)]\n\na = dis(vec(p[0],p[1]))\nb = dis(vec(p[1],p[2]))\nc = dis(vec(p[2],p[0]))\nS = 0.5*cross(vec(p[1],p[0]),vec(p[2],p[0]))\nR = a*b*c/(4*S)\n\nA = 2*abs(round(math.asin(a/(2*R))*180/math.pi))\nB = 2*abs(round(math.asin(b/(2*R))*180/math.pi))\nC = 2*abs(round(math.asin(c/(2*R))*180/math.pi))\n\nminAng = gcd(A,gcd(B,C))\n#print( A, B, C, minAng )\n\nprint( '{:.6f}'.format((180/minAng)*R*R*math.sin(minAng*math.pi/180)) )\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Mar 10 20:19:16 2015\nkristof.jakab@hegelab.org\n\"\"\"\n\nimport math\n\nclass Point(object):\n \"\"\" \"\"\"\n def __init__(self, x, y):\n self.x = x\n self.y = y\n self.vabs = round(math.sqrt(x ** 2 + y ** 2), 6)\n\nclass Line(object):\n \"\"\" \"\"\"\n def __init__(self, A, B): \n self.direction = Point(B.x - A.x, B.y - A.y)\n self.length = math.sqrt((B.x - A.x) ** 2 + (B.y - A.y) ** 2)\n\ndef calculate_angle(point_A, point_B):\n ab = point_A.x * point_B.x + point_A.y * point_B.y \n cos_angle = ab / (point_A.vabs * point_B.vabs)\n # return round(math.degrees(math.acos(cos_angle)), 6)\n return round(math.acos(cos_angle), 6)\n \ndef calculate_area(n, R):\n area = 0.5 * n * R * R * math.sin(2 * math.pi / n)\n return round(area, 6)\n\nA = Point(*map(float, raw_input().split()))\nB = Point(*map(float, raw_input().split()))\nC = Point(*map(float, raw_input().split()))\n \nAB = Line(A, B)\nAC = Line(A, C)\n\nBA = Line(B, A)\nBC = Line(B, C)\n\na = calculate_angle(AB.direction, AC.direction) * 2\nb = calculate_angle(BA.direction, BC.direction) * 2\n\nif a > math.pi:\n a = 2 * math.pi - a\nif b > math.pi:\n b = 2 * math.pi - b\n\nc = 2 * math.pi - (a + b)\n\n# R = (BC.length / 2) / math.sin(math.radians(a / 2))\nR = (BC.length / 2) / math.sin(a / 2)\n\nfor x in xrange(1, 100):\n y = x * (a / c)\n z = x * (b / c)\n if round(y, 1) % 1 == 0 and round(z, 1) % 1 == 0:\n n = int(round(x + y + z, 0))\n break\n\nprint calculate_area(n, R)"}, {"source_code": "import sys\nimport math\n\neLim = 0.01\n\ndef getPoint():\n return tuple(float(_) for _ in input().split())\n\ndef calCenter(point1, point2, point3):\n x1, y1 = point1\n x2, y2 = point2\n x3, y3 = point3\n R1 = x2 ** 2 - x1 ** 2 + y2 ** 2 - y1 ** 2\n R2 = x3 ** 2 - x1 ** 2 + y3 ** 2 - y1 ** 2\n delX21 = x2 - x1\n delX31 = x3 - x1\n delY21 = y2 - y1\n delY31 = y3 - y1\n\n y = 1 / 2 * (delX31 * R1 - delX21 * R2) / (delX31 * delY21 - delX21 * delY31)\n x = 1 / 2 * (delY31 * R1 - delY21 * R2) / (delY31 * delX21 - delY21 * delX31)\n return (x, y)\n\ndef calAngle(point1, point2, point3):\n xVec = tuple((x - y for (x, y) in zip(point1, point2)))\n yVec = tuple((x - y for (x, y) in zip(point1, point3)))\n return math.degrees(math.acos(sum(x * y for x, y in zip(xVec, yVec)) / (sum(x ** 2 for x in xVec) ** 0.5 * sum(x ** 2 for x in yVec) ** 0.5)))\n\ndef calArea(n, r):\n return 0.5 * (r ** 2) * n * math.sin(2 * math.pi / n) \n\nif __name__ == \"__main__\":\n #point1 = (0.000000, 0.000000)\n #point2 = (1.000000, 1.000000)\n #point3 = (0.000000, 1.000000)\n point1 = getPoint()\n point2 = getPoint()\n point3 = getPoint()\n O = calCenter(point1, point2, point3) # center O: (0.5, 0.5)\n R = sum((x - y) ** 2 for x, y in zip(O, point1)) ** 0.5\n A = calAngle(O, point1, point2)\n B = calAngle(O, point2, point3)\n C = calAngle(O, point3, point1)\n #print(A, B, C)\n minAngle = min(A, B, C)\n index = 1\n while True:\n alpha = minAngle / index\n if sum(_ / alpha for _ in (A, B, C)) > 100:\n #print(\"Not found!\")\n sys.exit(1)\n delta = tuple((_ / alpha - _ // alpha for _ in (A, B, C)))\n #print(delta)\n isFound = True\n for _ in delta:\n if _ > eLim and 1 - _ > eLim:\n isFound = False\n break\n if isFound:\n #print(alpha)\n break\n else:\n index += 1\n n = sum(_ / alpha for _ in (A, B, C)) + eLim\n n = int(n)\n #print(\"{0:.6f}\".format(calArea(n, R)))\n print(calArea(n, R))\n\n"}, {"source_code": "from math import pi,sin,cos,acos,sqrt,hypot,ceil,floor\nxa,ya = map(float,raw_input().split())\nxb,yb = map(float,raw_input().split())\nxc,yc = map(float,raw_input().split())\nx0 = ((ya-yc)*(xa*xa+ya*ya-xb*xb-yb*yb)-(ya-yb)*(xa*xa+ya*ya-xc*xc-yc*yc))/2.0/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb))\ny0 = (xa*xa+ya*ya-xb*xb-yb*yb - 2.0*x0*(xa-xb))/2.0/(ya-yb)\nxa -= x0\nya -= y0\nxb -= x0\nyb -= y0\nxc -= x0\nyc -= y0\na1 = acos((xa*xb+ya*yb)/hypot(xa,ya)/hypot(xb,yb))\na2 = acos((xb*xc+yb*yc)/hypot(xb,yb)/hypot(xc,yc))\nfor i in range(3,100):\n a = 2.0*pi/i\n k1 = a1/a\n k2 = a2/a \n if (abs(ceil(k1)-k1) < 0.001 or abs(floor(k1)-k1) < 0.001) and (abs(ceil(k2)-k2) < 0.001 or abs(floor(k2)-k2) < 0.001):\n print i*(xa*xa+ya*ya)*sin(pi/i)*cos(pi/i)\n exit()"}, {"source_code": "import math\nAx,Ay = input().split()\nBx,By = input().split()\nCx,Cy = input().split()\nAB = math.sqrt((float(Ax)-float(Bx))**2+(float(Ay)-float(By))**2)\nBC = math.sqrt((float(Cx)-float(Bx))**2+(float(Cy)-float(By))**2)\nCA = math.sqrt((float(Ax)-float(Cx))**2+(float(Ay)-float(Cy))**2)\nA= math.acos((AB**2+CA**2-BC**2)/(2*AB*CA))\nB= math.acos((BC**2+AB**2-CA**2)/(2*AB*BC))\nC= math.acos((BC**2+CA**2-AB**2)/(2*BC*CA))\nSx=(float(Ax)*math.sin(2*A)+float(Bx)*math.sin(2*B)+float(Cx)*math.sin(2*C))/(math.sin(2*A)+math.sin(2*B)+math.sin(2*C))\nSy=(float(Ay)*math.sin(2*A)+float(By)*math.sin(2*B)+float(Cy)*math.sin(2*C))/(math.sin(2*A)+math.sin(2*B)+math.sin(2*C))\nR= math.sqrt((float(Ax)-Sx)**2+(float(Ay)-Sy)**2)\nfor x in range(4,101):\n if(math.fabs(R*(2*math.sin(math.pi/x))-round(R*(2*math.sin(math.pi/x))))<.05):\n print('{:.6f}'.format(.5*x*R*R*math.sin(2*math.pi/x)))\n break\n"}, {"source_code": "\nfrom math import *\n\ndef gcd(x,y):\n if y < 1e-3:\n return x\n else:\n return gcd(y,fmod(x,y))\n\ndef area(a, b, c):\n s = (a + b + c) / 2\n return sqrt(s*(s-a)*(s-b)*(s-c))\n\npoint = [list(map(float,input().split())) for i in range(3)]\n\na,b,c = [sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) for (x1,y1),(x2,y2) in\n [(point[0],point[1]),(point[0],point[2]), (point[1],point[2])]]\nA,B,C = [acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\n\nS = area(a, b, c)\nR = a * b * c / 4 * S\ngcd_ = gcd(A, gcd(B, C))\nn = pi / gcd_\nprint(round(R*R*n*sin((2*pi)/n))/2,7)"}, {"source_code": "from math import *\np = [list(map(float, input().split())) for i in range(3)]\na, b, c = [hypot((x1-x2), (y1-y2)) for (x1,y1), (x2,y2) in [(p[0], p[1]), (p[1], p[2]), (p[0], p[2])]]\nA, B, C = [acos((x*x+y*y-z*z)/2/x/y) for x,y,z in [(c,b,a), (a,c,b), (a,c,b)]]\nR = a / sin(A) / 2\ndef maxCommonDiv(m,n):\n\tif m < n:\n\t\tm,n = n,m\n\tif n < 1e-3:\n\t\treturn m\n\telse:\n\t\treturn maxCommonDiv(n, fmod(m, n))\n\nu = 2 * maxCommonDiv(2 * pi, maxCommonDiv(A, maxCommonDiv(B, C)))\nprint(round(R * R * pi / u * sin(u), 7))\t"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport math\n\ndef area(d):\n if len(d) < 3:\n return False\n a = 0.0\n p = 0.5 * (d[0] + d[1] + d[2])\n a = math.sqrt(p*(p-d[0])*(p-d[1])*(p-d[2]))\n return a\n\ndef circumcircle(x,y):\n distance = euclidean(x,y)\n triangle_area = area(distance)\n return distance[0] * distance[1] * distance[2] / (4 * triangle_area)\n \ndef euclidean(x,y):\n d = []\n d.append(math.sqrt((x[0]-x[1])**2 + (y[0]-y[1])**2))\n d.append(math.sqrt((x[0]-x[2])**2 + (y[0]-y[2])**2))\n d.append(math.sqrt((x[1]-x[2])**2 + (y[1]-y[2])**2))\n return d\n \ndef centerAngle(d,radius):\n angle = []\n #print(type(d[0]), type(radius))\n #print(d[0]/(2*radius))\n #print(2 * math.asin( d[0] / (2*radius) ) )\n angle.append(2*math.asin(d[0]/(2*radius)))\n angle.append(2*math.asin(d[1]/(2*radius)))\n angle.append(math.pi - angle[0]- angle[1])\n return angle\n\ndef gcd(a,b):\n if a < 0.01:\n return b\n else:\n return gcd(math.fmod(b,a),a)\ndef main():\n \n # get the input data\n x = []\n y = []\n for i in range(3):\n temp_input = input().split() \n x.append(float(temp_input[0]))\n y.append(float(temp_input[1]))\n\n # 1. calculate the length of the edge \n # 2. calculate the area of the triangle\n # 3. calculate the radius of the circumcircle\n # 4. calculate the area of the Berland Circus\n\n edge_length = euclidean(x,y)\n\n triangle_area = area(edge_length)\n\n circumcircle_radius = circumcircle(x,y)\n\n #print(\"circumcircle_radius: {0[0]}:{1[0]},{0[1]}:{1[1]}, {0[2]}:{1[2]} \\n {2}\".format(x,y,circumcircle_radius))\n # 5. calculat the cetral angle and their gcd\n angle = centerAngle(edge_length, circumcircle_radius)\n \n gcd_angle = gcd(gcd(angle[0], angle[1]), angle[2])\n\n\n result = 2 * math.pi / gcd_angle * circumcircle_radius * math.sin(gcd_angle) * circumcircle_radius * 0.5 \n\n #print(\"circumcircle_radius\",circumcircle_radius)\n #print(\"totoal_angle\",angle)\n #print(\"gcd_angle\",gcd_angle)\n #print(\"len\",edge_length)\n print(\"{:.7f}\".format(result))\n \n \n\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import math\n\ndef theatresquare(n,m,a):\n return ((n-1)//a + 1)*((m-1)//a + 1)\n\n# n,m,a = list(map(int,input().split()))\n# print(theatresquare(n,m,a))\n\ndef convert(x):\n s = \"\"\n while x > 0:\n a = x%26\n x = x//26\n if a == 0:\n a = 26\n x -= 1\n s = chr(a-1+ord('A')) + s\n return s\n\ndef convertindex(x):\n i = 0\n while (x[i] <= 'Z') and (x[i] >= 'A'):\n i += 1\n j = i\n while (j < len(x)) and (x[j] <= '9') and (x[j] >= '0'):\n j += 1\n if j == len(x):\n s = 0\n for j in range(i):\n s = (ord(x[j]) - ord('A')+1) + 26*s\n return 'R' + x[i:] + 'C' + str(s)\n else:\n while (x[i] <= '9') and (x[i] >= '0'):\n i += 1\n return convert(int(x[i+1:])) + x[1:i]\n\n# cases = int(input())\n# for _ in range(cases):\n# l = input()\n# print(convertindex(l))\n\ndef berlandcircus(A,B,C):\n a = (B[0] - C[0])**2 + (B[1] - C[1])**2\n b = (A[0] - C[0])**2 + (A[1] - C[1])**2\n c = (B[0] - A[0])**2 + (B[1] - A[1])**2\n\n la = math.acos(abs((b+c-a)/(2*math.sqrt(b)*math.sqrt(c))))/math.pi\n lb = math.acos(abs((c-b+a)/(2*math.sqrt(a)*math.sqrt(c))))/math.pi\n lc = math.acos(abs((b-c+a)/(2*math.sqrt(a)*math.sqrt(b))))/math.pi\n\n i = 3\n while i < 101:\n if la*i-round(la*i) < 0.000001:\n if lb*i-round(lb*i) < 0.000001:\n if lb*i-round(lb*i) < 0.000001:\n return round(i*0.125*a*math.sin(2*math.pi/i)/math.sin(la*math.pi)**2,6)\n i += 1\n \n\n\nA = list(map(float,input().split()))\nB = list(map(float,input().split()))\nC = list(map(float,input().split()))\n\nprint(berlandcircus(A,B,C))"}, {"source_code": "\"\"\"\nCodeforces\n1C - Ancient Berland Circus\nhttp://codeforces.com/problemset/problem/1/C\n\nH\u00e9ctor Gonz\u00e1lez Belver\n11/06/2018\n\"\"\"\nimport sys\nimport math\n\n\n\ndef float_gcd(a, b, rtol = 0, atol = 1e-05):\n t = min(abs(a), abs(b))\n while abs(b) > rtol * t + atol:\n a, b = b, a % b\n return a\n\ndef main():\n point_A = [float(x) for x in sys.stdin.readline().strip().split()]\n point_B = [float(x) for x in sys.stdin.readline().strip().split()]\n point_C = [float(x) for x in sys.stdin.readline().strip().split()]\n \n #Triangle\n side_a = math.hypot(point_B[0] - point_C[0], point_B[1] - point_C[1])\n side_b = math.hypot(point_A[0] - point_C[0], point_A[1] - point_C[1])\n side_c = math.hypot(point_A[0] - point_B[0], point_A[1] - point_B[1])\n\n #Semiperimeter of the triangle\n semiperimeter_T = (side_a + side_b + side_c)/2\n \n #Area of triangle: Heron's formula\n area_T = (semiperimeter_T*(semiperimeter_T - side_a)*(semiperimeter_T - side_b)*(semiperimeter_T - side_c))**0.5\n\n #Angles of triangle: Law of cosines\n angle_A = math.acos((side_b**2 + side_c**2 - side_a**2)/(2*side_b*side_c))\n angle_B = math.acos((side_a**2 + side_c**2 - side_b**2)/(2*side_a*side_c))\n angle_C = math.acos((side_a**2 + side_b**2 - side_c**2)/(2*side_a*side_b))\n\n #Circumradius (R) of the triangle = circumradius of possible convex regular n-gons\n R = (side_a*side_b*side_c)/(4*area_T)\n\n #Angles of the triangle are inscribed angles of circumcircle with center O --> inscribed angles theorem: relates the measure of an inscribed angle to that of the central angle subtending the same arc \n #-->angle_BOC = 2*angle_A\n #-->angle_AOC = 2*angle_B\n #-->angle_AOB = 2*angle_C\n\n #Central angle of convex regular n-gon = 2*pi/n\n #--> angle_BOC = i * 2*pi/n ==> angle_A = i * pi/n\n #--> angle_AOC = j * 2*pi/n ==> angle_B = j * pi/n\n #--> angle_AOB = k * 2*pi/n ==> angle_C = k * pi/n\n #i + j + k = n ( i,j,k,n positive integers)\n #==>mimimum area==>minimum n==> gcd(angle_A, angle_B, angle_C) = pi/n\n #==>n=pi/gcd(angle_A, angle_B, angle_C) \n n = math.pi/float_gcd(float_gcd(angle_A, angle_B), angle_C)\n print(n)\n\n #Area of convex regular n-gons by circumradius\n A = (math.sin(2*math.pi/n)*n*R**2)/2\n\n sys.stdout.write(\"{:.6f}\".format(A)+\"\\n\")\n \n\nif __name__ == '__main__': \n main()"}, {"source_code": "import math\n\narray, newarray = [], [0]*3\n\nfor x in range(3):\n n = input().split()\n m = list(map(float, n))\n array.append(m)\n\ndef magn_sq(point):\n return (point[0]**2 + point[1]**2)\n \ndef dist_sq(point1, point2):\n return magn_sq([point1[0] - point2[0], point1[1] - point2[1]])\n\ndef circumcenter(point1, point2, point3):\n point_1 = [point1[0] - point3[0], point1[1] - point3[1]]\n point_2 = [point2[0] - point3[0], point2[1] - point3[1]]\n const = 2*(point_1[0]*point_2[1] - point_1[1]*point_2[0])\n xcoord = (point_2[1]*magn_sq(point_1) - point_1[1]*(magn_sq(point_2)))/const\n ycoord = (point_1[0]*magn_sq(point_2) - point_2[0]*(magn_sq(point_1)))/const\n return [xcoord + point3[0], ycoord + point3[1]]\n\ncenter = circumcenter(array[0], array[1], array[2])\ncenter = list(map(lambda x: round(x, 1), center))\n\nfor x in array:\n x[0] = x[0] - center[0]\n x[1] = x[1] - center[1]\n\nradius = math.sqrt(magn_sq(array[0]))\n\nfor x in range(3):\n newarray[x] = math.sqrt(dist_sq(array[x], array[(x+1)%3]))\n\ndef distToAngle(p):\n return (math.asin(p/(2*radius)))/math.pi\n\nnewarray = list(map(distToAngle, newarray))\n\ndef gcf(a,b):\n if a >= b:\n if a - b < 0.0001:\n return a\n else:\n return gcf(a-b, b)\n else:\n return gcf(b, a)\n\ngcd = 1/gcf(gcf(newarray[0], newarray[1]), newarray[2])\n\ndef checkInt(a):\n r = int(round(a,0))\n return abs(r - a) < 0.001\n\ni = 1\nwhile (not checkInt(i*gcd)):\n i += 1\n\nt = i*gcd\n\nnumsides = int(round(t,0))\n\narea = 0.5*numsides*(radius**2)*math.sin(2*math.pi/numsides)\n\nprint(area)"}, {"source_code": "from math import *\n\ndef LineIntersect(a,b):\n det=lambda a,b,c,d:a*d-b*c\n z=det(a[0],a[1],b[0],b[1])\n return (-det(a[2],a[1],b[2],b[1])/z,-det(a[0],a[2],b[0],b[2])/z)\n\ndef GetCircleInOrigin(A):\n GetNormal=lambda (x,y):(-y,x)\n GetDif=lambda (x1,y1),(x2,y2):(x1-x2,y1-y2)\n GetSum=lambda (x1,y1),(x2,y2):(x1+x2,y1+y2)\n GetMultToCof=lambda (x1,y1),c:(x1*c,y1*c)\n NormalLine=lambda (a,b):(b[1]-a[1],a[0]-b[0],a[1]*b[0]-a[0]*b[1])\n L=[ (GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetSum(GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetNormal(GetDif(A[i+1],A[i])))) for i in range(2)]\n L=map(NormalLine,L)\n L=LineIntersect(L[0],L[1]) \n return map(lambda x:GetDif(x,L),A)\n\ndef gcd(a,b):\n if (b<0.0000000001):\n return a;\n else:\n return gcd(b,fmod(a,b))\n\nA=[map(float,raw_input().split()) for i in range(3)]\nA=GetCircleInOrigin(A)\nC=[atan2(y,x) for x,y in A]\nC=[C[i]-C[j] for (i,j) in [(0,1),(1,2),(2,0)]]\nfor i in range(3):\n if (C[i]<0):\n C[i]+=2*pi\nR=hypot(*A[0])\nomega=gcd(C[0],gcd(C[1],C[2]))\nprint ((2*pi)/omega)*((R**2)*sin(omega))/2.0\n"}, {"source_code": "import math\n\neps = 0.000001\n\ndef gcd(a, b):\n while (math.fabs(a) > eps and math.fabs(b) > eps):\n if (a > b):\n a -= math.floor(a/b) * b\n else:\n b -= math.floor(b/a) * a\n return a + b\n\n\na = raw_input().split(' ')\nb = raw_input().split(' ')\nc = raw_input().split(' ')\n\nax = float(a[0])\nay = float(a[1])\nbx = float(b[0])\nby = float(b[1])\ncx = float(c[0])\ncy = float(c[1])\n\nayd = by - ay\naxd = bx - ax\nbyd = cy - by\nbxd = cx - bx\n\naslope = 0\nbslope = 0\n\nif axd != 0:\n aslope = ayd / axd\n\nif bxd != 0:\n bslope = byd / bxd\n\nabmidx = (ax+bx)/2\nabmidy = (ay+by)/2\nbcmidx = (bx+cx)/2\nbcmidy = (by+cy)/2\n\nif ayd == 0:\n cex = abmidx\n if bxd == 0:\n cey = bcmidy\n else:\n cey = bcmidy + (bcmidx - cex)/bslope\nelif byd == 0:\n cex = bcmidx\n if axd == 0:\n cey = abmidy\n else:\n cey = abmidy + (abmidx - cex)/aslope\nelif axd == 0:\n cey = abmidy\n cex = bslope*(bcmidy - cey) + bcmidx\nelif bxd == 0:\n cey = bcmidy\n cex = aslope*(abmidy - cey) + abmidx\nelse:\n cex = (aslope*bslope*(abmidy - bcmidy) - aslope*bcmidx + bslope*abmidx)/(bslope - aslope)\n cey = abmidy - (cex - abmidx)/aslope\n\nr = math.sqrt((ax - cex)**2 + (ay - cey)**2)\n\nab = math.sqrt((ax-bx)**2 + (ay-by)**2)\nac = math.sqrt((ax-cx)**2 + (ay-cy)**2)\nbc = math.sqrt((bx-cx)**2 + (by-cy)**2)\n\nacex = ax - cex\nacey = ay - cey\nbcex = bx - cex\nbcey = by - cey\nccex = cx - cex\nccey = cy - cey\n\nalfa = math.acos((bc**2 + ac**2 - ab**2)/(2*bc*ac))\nbeta = math.acos((ab**2 + ac**2 - bc**2)/(2*ab*ac))\ngamma = math.acos((ab**2 + bc**2 - ac**2)/(2*ab*bc))\n\nn = math.pi / gcd(gcd(alfa, beta), gamma)\n\narea = 0.5 * float(n) * r * r * math.sin(2 * math.pi / n)\n\nprint area\n"}, {"source_code": "import math\nA = input().split()\nB = input().split()\nC = input().split()\n\na1, a2 = float(A[0]), float(A[1])\nb1, b2 = float(B[0]), float(B[1])\nc1, c2 = float(C[0]), float(C[1])\n\na = ((b1-c1)**2 + (b2-c2)**2) **0.5\nb = ((a1-c1)**2 + (a2-c2)**2) **0.5\nc = ((b1-a1)**2 + (b2-a2)**2) **0.5\n\ncosa = (b**2+c**2-a**2)/(2*b*c)\nsina = (1-cosa**2)**0.5\nR = a/(2*sina)\nside = min(a,b,c)\ns = (R+R+side)/2\ntri_area = (s*(s-R)*(s-R)*(s-side))**0.5\n\n#tri_area = 1/2*R*R*sinTheta\nsinTheta = (tri_area*2)/(R**2)\ntheta = math.asin(sinTheta)\ncount = (2 * math.pi) / theta\ntotal_area = round(count * tri_area, 6)\n\nprint(total_area)\n#print(a)\n#print(sina)\n#print(\"R:\", a/(2*sina))\n#print(\"tri_area:\", tri_area)\n#print(theta)\n#print(count)\n#print(total_area)"}, {"source_code": "##x1, y1 = map(float, raw_input().split())\n##x2, y2 = map(float, raw_input().split())\n##x3, y3 = map(float, raw_input().split())\nimport math\nx1 = 0.0; y1 = 0.0\nx2 = 0.0; y2 = 1.0\nx3 = 1.0; y3 = 0.0\nEPSILON = 0.0000001\ndef midPoint(x1, y1, x2, y2):\n mid_x = (x1 + x2) / 2\n mid_y = (y1 + y2) / 2\n return (mid_x, mid_y)\n\ndef slope_mid_perpend(x1, y1, x2, y2):\n return -1 * (x2 - x1) / (y2 - y1)\n\ndef distance(x1, y1, x2, y2):\n return math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2)\n\ndef circleCenter(x1, y1, x2, y2, x3, y3):\n x12, y12 = midPoint(x1, y1, x2, y2)\n x13, y13 = midPoint(x1, y1, x3, y3)\n if y1 == y2:\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n x0 = x12\n y0 = k_mid_13 * (x0 - x13) + y13\n elif y1 == y3:\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n x0 = x13\n y0 = k_mid_12 * (x0 - x12) + y12\n else:\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n y0 = (y13 - y12 + k_mid_12 * x12 - k_mid_13 * x13) / (k_mid_12 - k_mid_13)\n x0 = (y0 - y12) / k_mid_12 + x12\n return x0, y0\nx0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\ndef angle(distance1, distance2):\n angle = math.asin((distance1/2) / distance2)\n return 2 * angle\nd_12 = distance(x1, y1, x2, y2)\nd_13 = distance(x1, y1, x3, y3)\nd_32 = distance(x3, y3, x2, y2)\n##print d_12, d_13, d_32\nr = distance(x1, y1, x0, y0)\nangle1O2 = angle(d_12, r)\nangle1O3 = angle(d_13, r)\nangle3O2 = angle(d_32, r)\n\n##print angle1O2, angle1O3, angle3O2\n##\n##print angle(math.sqrt(2), 1)\n\ndef isRemainder(angle, angle_N):\n remainder = angle % angle_N\n if (remainder == 0) or (abs(remainder - angle_N) <= EPSILON):\n return True\n else:\n return False\n \ndef find_N(angle1, angle2, angle3):\n N = 3\n while 1:\n## print 'N', N\n## print angle1, angle1, angle3\n angle_N = 2 * math.pi / N\n## print 'angle_N', angle_N\n remainder1 = angle1 % angle_N\n remainder2 = angle2 % angle_N\n remainder3 = angle3 % angle_N\n## print remainder1, remainder2, remainder3\n if (isRemainder(angle1, angle_N) and isRemainder(angle2, angle_N) and\n isRemainder(angle2, angle_N)):\n break\n N += 1\n \n return N\n\nprint find_N(angle1O2, angle1O3, angle3O2)\n \n \n\n\n\n\n## test\n##print circleCenter(x1, y1, x2, y2, x3, y3)\n##\n##import math\n##\n##x0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\n##print distance(x0, y0, x1, y1), distance(x0, y0, x2, y2), distance(x0, y0, x2, y2)\n\n\n\n\n\n\n\n\n"}, {"source_code": "import math\ndef dist(x1, y1, x2, y2):\n return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)\ndef angle(a, b, c):\n return math.acos((a * a + b * b - c * c) / (2 * a * b))\ndef f(a, b):\n if b > a:\n return f(b, a)\n if abs(b) < 1 / 1000000:\n return a\n else:\n k = int(a / b)\n a -= k * b;\n return f(b, a)\nx = [0] * 3\ny = [0] * 3\nlen = [0] * 3\nang = [0] * 3\nfor i in range(3):\n x[i], y[i] = map(float, input().split())\nfor i in range(3):\n len[i] = dist(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3])\nlen.sort()\nfor i in range(3):\n ang[i] = angle(len[i], len[(i + 1) % 3], len[(i + 2) % 3])\nang.sort()\nan = f(f(ang[0], ang[1]), ang[2]) * 2\nn = 2 * math.pi / an\na = len[0] * math.sin(an / 2) / math.sin(ang[0])\ns = n * a * a / (4 * math.tan(an / 2))\nprint(\"%.9f\" % (s))\n\n#71.756151 7.532275\n#-48.634784 100.159986\n#91.778633 158.107739\n"}, {"source_code": "from math import *\nX1,Y1=raw_input().strip().split(' ')\nX2,Y2=raw_input().strip().split(' ')\nX3,Y3=raw_input().strip().split(' ')\nX1,Y1=float(X1),float(Y1)\nX2,Y2=float(X2),float(Y2)\nX3,Y3=float(X3),float(Y3)\nlength=[sqrt(abs(X1-X2)+abs(Y1-Y2)),sqrt(abs(X1-X3)+abs(Y1-Y3)),sqrt(abs(X2-X3)+abs(Y3-Y2))]\ndegree1=degrees(acos((length[0]**2+length[1]**2-length[2]**2)/float(2*length[0]*length[1])))\ndegree2=degrees(acos((length[0]**2+length[2]**2-length[1]**2)/float(2*length[0]*length[2])))\ndegree3=degrees(acos((length[2]**2+length[1]**2-length[0]**2)/float(2*length[2]*length[1])))\ndegree=max(degree1,degree2,degree3)\nif degree>180:\n\tdegree=360-degree\nn=360//(180-degree)\narea=((min(length)**2)*n)/float(4*tan(radians(180/n)))\nprint area"}, {"source_code": "x1, y1 = map(float, raw_input().split())\nx2, y2 = map(float, raw_input().split())\nx3, y3 = map(float, raw_input().split())\nimport math\n##x1 = 0.0; y1 = 0.0\n##x2 = 0.0; y2 = 1.0\n##x3 = 1.0; y3 = 0.0\nEPSILON = 0.0000001\ndef midPoint(x1, y1, x2, y2):\n mid_x = (x1 + x2) / 2\n mid_y = (y1 + y2) / 2\n return (mid_x, mid_y)\n\ndef slope_mid_perpend(x1, y1, x2, y2):\n return -1 * (x2 - x1) / (y2 - y1)\n\ndef distance(x1, y1, x2, y2):\n return math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2)\n\ndef circleCenter(x1, y1, x2, y2, x3, y3):\n x12, y12 = midPoint(x1, y1, x2, y2)\n x13, y13 = midPoint(x1, y1, x3, y3)\n if y1 == y2:\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n x0 = x12\n y0 = k_mid_13 * (x0 - x13) + y13\n elif y1 == y3:\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n x0 = x13\n y0 = k_mid_12 * (x0 - x12) + y12\n else:\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n y0 = (y13 - y12 + k_mid_12 * x12 - k_mid_13 * x13) / (k_mid_12 - k_mid_13)\n x0 = (y0 - y12) / k_mid_12 + x12\n return x0, y0\nx0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\ndef angle(distance1, distance2):\n angle = math.asin((distance1/2) / distance2)\n return 2 * angle\nd_12 = distance(x1, y1, x2, y2)\nd_13 = distance(x1, y1, x3, y3)\nd_32 = distance(x3, y3, x2, y2)\n##print d_12, d_13, d_32\nr = distance(x1, y1, x0, y0)\nangle1O2 = angle(d_12, r)\nangle1O3 = angle(d_13, r)\nangle3O2 = angle(d_32, r)\n\n##print angle1O2, angle1O3, angle3O2\n##\n##print angle(math.sqrt(2), 1)\n\ndef isRemainder(angle, angle_N):\n remainder = angle % angle_N\n if (remainder == 0) or (abs(remainder - angle_N) <= EPSILON):\n return True\n else:\n return False\n \ndef find_N(angle1, angle2, angle3):\n N = 3\n while 1:\n## print 'N', N\n## print angle1, angle1, angle3\n angle_N = 2 * math.pi / N\n## print 'angle_N', angle_N\n remainder1 = angle1 % angle_N\n remainder2 = angle2 % angle_N\n remainder3 = angle3 % angle_N\n## print remainder1, remainder2, remainder3\n if (isRemainder(angle1, angle_N) and isRemainder(angle2, angle_N) and\n isRemainder(angle2, angle_N)):\n break\n N += 1\n \n return N\nN = find_N(angle1O2, angle1O3, angle3O2)\ndef area_N(N):\n angle = 2 * math.pi / N\n area = N * 1/2 * r * r * math.sin(angle)\n return area\n\nprint area_N(N)\n \n \n\n\n\n\n## test\n##print circleCenter(x1, y1, x2, y2, x3, y3)\n##\n##import math\n##\n##x0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\n##print distance(x0, y0, x1, y1), distance(x0, y0, x2, y2), distance(x0, y0, x2, y2)\n\n\n\n\n\n\n\n\n"}, {"source_code": "from math import pi,tan,sin,cos,sqrt\n\ndef cot(x):\n return 1/tan(x)\n\ndef area(n,r):\n \"\"\"Area of convex regular n-gon with radius r\"\"\"\n return 0.5*n*r*r*sin(2*pi/n)\n\n\ndef rotate(v,theta):\n \"\"\"\n Rotation matrix\n |cos(theta) -sin(theta)|\n |sin(theta) cos(theta)|\n \"\"\"\n return ( v[0]*cos(theta)-v[1]*sin(theta)\n ,v[0]*sin(theta)+v[1]*cos(theta)\n )\n \ndef add(v1,v2):\n return (v1[0]+v2[0], v1[1]+v2[1])\n\ndef sub(v1,v2):\n return (v1[0]-v2[0], v1[1]-v2[1])\n\ndef mult(v,f):\n return (f*v[0],f*v[1])\n\ndef norm(v):\n return sqrt(v[0]**2+v[1]**2)\n\ndef find_circle(a,b,c):\n \"\"\"Find the circle that going through points a,b,c in the plane. \"\"\"\n dir1 = mult(sub(b,a),1/norm(sub(b,a)))\n dir1 = rotate(dir1,pi/2)\n half1 = add(a,mult(sub(b,a),1/2))\n a1,b1 = dir1[0],dir1[1]\n r1,s1 = half1[0],half1[1]\n\n dir2 = mult(sub(c,b),1/norm(sub(c,b)))\n dir2 = rotate(dir2,pi/2)\n half2 = add(b,mult(sub(c,b),1/2))\n a2,b2 = dir2[0],dir2[1]\n r2,s2 = half2[0],half2[1]\n\n x = (s1-s2+r2*(b2/a2)-r1*(b1/a1))/((b2/a2)-(b1/a1))\n y = (x-r1)*(b1/a1)+s1\n center = (x,y) \n radius = norm(sub(center,a))\n return (center, radius)\n\ndef find_polygon(a,b,c):\n center, r = find_circle(a,b,c)\n v0 = sub(a,center)\n for n in range(3,101):\n theta = 2*pi/n\n vertices = [a]\n b_found = False\n c_found = False\n for i in range(n):\n vi = rotate(v0,i*theta)\n g = add(center,vi)\n vertices.append(g)\n\n if norm(sub(g,b))< 1e-4:\n b_found = True \n elif norm(sub(g,c)) < 1e-4:\n c_found = True\n if b_found and c_found:\n print('hey')\n return (n,r)\n\na = [float(i) for i in input().split()]\nb = [float(i) for i in input().split()]\nc = [float(i) for i in input().split()]\n\nn,r = find_polygon(a,b,c)\nprint(area(n,r))\n\n\n"}, {"source_code": "import math\nfrom sys import stdin\n\n\ndef get_length(p1, p2):\n return math.sqrt(math.pow(p1[0] - p2[0], 2) + math.pow(p1[1] - p2[1], 2))\n\n\ndef get_angle(p1, p2, p3):\n return math.acos((\n math.pow(get_length(p1, p2), 2) +\n math.pow(get_length(p1, p3), 2) -\n math.pow(get_length(p2, p3), 2)\n )\n /\n (2 * get_length(p1, p2) * get_length(p1, p3))\n )\n\n\ndef get_radius(p1, p2, p3):\n a, b, c = get_length(p1, p2), get_length(p2, p3), get_length(p1, p3)\n s = (a + b + c) / 2\n area = math.sqrt(s * (s - a) * (s - b) * (s - c))\n return a * b * c / 4 / area\n\n\ndef gcd(x, y):\n while y > 0.00000000001:\n x, y = y, x % y\n return x\n\n\ndef main():\n x1, y1 = map(float, stdin.readline().strip().split())\n p1 = (x1, y1)\n x2, y2 = map(float, stdin.readline().strip().split())\n p2 = (x2, y2)\n x3, y3 = map(float, stdin.readline().strip().split())\n p3 = (x3, y3)\n A = get_angle(p1, p2, p3)\n B = get_angle(p2, p1, p3)\n C = get_angle(p3, p1, p2)\n radius = get_radius(p1, p2, p3)\n n = math.pi / gcd(gcd(A, B), C)\n area = n / 2 * math.pow(radius, 2) * math.sin(2 * math.pi / n)\n print(area)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/1/A\n\"\"\"\n\nimport sys\nimport math\n\n\ndef gcd(a, b):\n\tif a < b:\n\t\ta, b = b, a\n\t\t\n\twhile b > 1:\n\t\ta, b = b, a - b\n\t\n\treturn a\n\n\ndef square(arr):\n\ta = math.sqrt( (arr[2][0]-arr[1][0])**2 + (arr[2][1]-arr[1][1])**2 )\n\tb = math.sqrt( (arr[2][0]-arr[0][0])**2 + (arr[2][1]-arr[0][1])**2 )\n\tc = math.sqrt( (arr[1][0]-arr[0][0])**2 + (arr[1][1]-arr[0][1])**2 )\n\tp = 0.5 * (a+b+c)\n\tR = a*b*c / (4 * math.sqrt(p*(p-a)*(p-b)*(p-c)))\n\t\n\talpha = math.acos( round((2*R**2-c**2)/(2*R**2), 6) )\n\tbeta = \tmath.acos( round((2*R**2-a**2)/(2*R**2), 6) )\n\tgamma = math.acos( round((2*R**2-b**2)/(2*R**2), 6) )\n\t\n\tdelta = gcd(alpha, gcd(beta, gamma))\n\tn = math.floor(2*math.pi / delta)\n\ts = (n/2)*(R**2)*math.sin(2*math.pi/n)\n\t\n\treturn s\n\n\ndef main():\n\tarr = []\n\t\n\tfor i in range(3):\n\t\tl = sys.stdin.readline()\n\t\tx, y = [float(t) for t in l.split()]\n\t\tarr.insert(i-1, (x, y))\n\t\n\ts = square(arr)\n\tprint(\"%.6f\" % s)\n\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "from itertools import *\nfrom math import *\n\ndef mid_line((x1, y1), (x2, y2)):\n return x2-x1, y2-y1, (x1**2 - x2**2 + y1**2 - y2**2)/2.0\n\ndef intersect((a1, b1, c1), (a2, b2, c2)):\n d = a1*b2-b1*a2\n return (b1*c2-b2*c1)/d, (a2*c1-a1*c2)/d\n\ndef vect((x0, y0), (x1, y1)):\n return x1-x0, y1-y0\n\ndef dot((a1, b1), (a2, b2)):\n return a1*a2+b1*b2\n\ndef length(a):\n return sqrt(dot(a, a))\n\ndef angle(c, p1, p2):\n a, b = vect(p1, c), vect(p2, c)\n return acos(dot(a, b) / (length(a) * length(b) + 1.0e-100))\n\ndef gcd(a, b):\n while abs(b) > pi/100:\n b, a = fmod(a, b), b\n return a\n\np = [map(float, raw_input().split()) for i in xrange(3)]\nc = intersect(mid_line(p[0], p[1]), mid_line(p[2], p[1]))\nt = reduce(gcd, [angle(c, p1, p2) for p1, p2 in combinations(p, 2)])\nR = length(vect(p[0], c))\nprint R**2*pi/t*sin(t)\n"}, {"source_code": "import math\nx1 = map(float,raw_input().split())\nx2 = map(float,raw_input().split())\nx3 = map(float,raw_input().split())\n\n#print 1.0/2*(a[0]*b[1]+b[0]*c[1]+c[0]*a[1]-a[1]*b[0]-b[1]*c[0]-c[1]*a[0])\n\n'''x1 = [88.653021,18.024220]\nx2 = [51.942488,-2.527850]\nx3 = [76.164701,24.553012]'''\ns = abs(1.0/2*(x1[0]*x2[1]+x2[0]*x3[1]+x3[0]*x1[1]-x1[1]*x2[0]-x2[1]*x3[0]-x3[1]*x1[0]))\na = math.sqrt((x1[0]-x2[0])**2+(x1[1]-x2[1])**2)\nb = math.sqrt((x3[0]-x2[0])**2+(x3[1]-x2[1])**2)\nc = math.sqrt((x1[0]-x3[0])**2+(x1[1]-x3[1])**2)\n#print a,b,c,s\nr = a*b*c/(s*4)\n#print r\nA = math.acos((r**2+r**2-a**2)/(2*r*r))*180/math.pi\nB = math.acos((r**2+r**2-b**2)/(2*r*r))*180/math.pi\nC = math.acos((r**2+r**2-c**2)/(2*r*r))*180/math.pi\n#print A,B,C\ndef gcd(x,y):\n x = float(x)\n y = float(y)\n #print x,y\n while (abs(x)>1e-4 and abs(y)>1e-4):\n if(x>y):\n #print int(x/y)\n x = float(x -int(x/y)*y)\n #print 1,x\n else:\n y = float(y -int(y/x)*x)\n #print 2,y\n return abs(x+y)\nn = 360.0/gcd(gcd(A,B),C)\n#print n\nn = n* 1/(n%1)\nprint '%f' %(0.5*n*math.sin(2*math.pi/n)*r*r)"}, {"source_code": "from time import *\nfrom math import * \n\ndef dist(x1,y1,x2,y2):\n\treturn ((x1-x2)**2+(y1-y2)**2)**0.5\n\ndef isInteger(x):\n\treturn abs(x-round(x))<1e-2\n\ndef area(x1,y1,x2,y2,x3,y3):\n\ta=dist(x1,y1,x2,y2)\n\tb=dist(x3,y3,x2,y2)\n\tc=dist(x1,y1,x3,y3)\n\td=(a+b+c)/2\n\treturn (d*(d-a)*(d-b)*(d-c))**0.5\n\ndef radiusOuter(x1,y1,x2,y2,x3,y3):\n\treturn a*b*c/area(x1,y1,x2,y2,x3,y3)/4\n\ndef linePass2Point(x1,y1,x2,y2):\n\ta=y2-y1\n\tb=x1-x2\n\tc=-a*x1-b*y1\n\treturn a,b,c\n\ndef intersect(a1,b1,c1,a2,b2,c2):\n\ty=-(a2*c1-a1*c2)/(a2*b1-a1*b2)\n\tx=-(b2*c1-b1*c2)/(b2*a1-b1*a2)\n\treturn x,y\n\ndef midLine(x1,y1,x2,y2):\n\ta1,b1,c1=linePass2Point(x1,y1,x2,y2)\n\ta2,b2=-b1,a1\n\tx,y=(x1+x2)/2,(y1+y2)/2\n\tc2=-(a2*x+b2*y)\n\treturn a2,b2,c2\n\ndef centerOfOuterTriangle(x1,y1,x2,y2,x3,y3):\n\ta1,b1,c1=midLine(x1,y1,x2,y2)\n\ta2,b2,c2=midLine(x1,y1,x3,y3)\n\tx,y=intersect(a1,b1,c1,a2,b2,c2)\n\treturn x,y,dist(x,y,x1,y1)\n\ndef angle(x1,y1,x2,y2,x3,y3):\n\t# t\u00ednh g\u00f3c \u0111\u1ed1i di\u1ec7n v\u1edbi [x1,y1],[x2,y2]\n\tc=dist(x1,y1,x2,y2)\n\tb=dist(x3,y3,x2,y2)\n\ta=dist(x1,y1,x3,y3)\n\ttg=(a*a+b*b-c*c)/(2*a*b)\n\tif tg<=-1:\n\t\ttg+=1e-5\n\telif tg>=1:\n\t\ttg-=1e-5\n\treturn acos(tg)\n\ndef areaByRadius(r,n):\n\treturn r*r*n*sin(2*pi/n)/2\n\nx1,y1=[float(i) for i in input().split()]\nx2,y2=[float(i) for i in input().split()]\nx3,y3=[float(i) for i in input().split()]\n\ndef check(n):\n\tglobal x,y,r\n\ta=2*pi/n\n\treturn isInteger(a1/a) and isInteger(a2/a) and isInteger(a3/a)\n\n\t\nx,y,r=centerOfOuterTriangle(x1,y1,x2,y2,x3,y3)\n# print(x,y,r)\na1=angle(x1,y1,x2,y2,x,y)\na2=angle(x3,y3,x2,y2,x,y)\na3=angle(x1,y1,x3,y3,x,y)\nfor i in range(3,101):\n\ta=2*pi/i\n\t# print(i,round(areaByRadius(r,i),8),a1/a,a2/a,a3/a)\n\tif isInteger(a1/a) and isInteger(a2/a) and isInteger(a3/a):\n\t\tprint(round(areaByRadius(r,i),4))\n\t\tbreak\n\n\n\n"}, {"source_code": "import math\nfrom decimal import *\ngetcontext().prec = 15\nAx,Ay = input().split()\nBx,By = input().split()\nCx,Cy = input().split()\nAx=Decimal(Ax)\nBx=Decimal(Bx)\nCx=Decimal(Cx)\nAy=Decimal(Ay)\nBy=Decimal(By)\nCy=Decimal(Cy)\nAB = Decimal(math.sqrt((Ax-Bx)**2+(Ay-By)**2))\nBC = Decimal(math.sqrt((Cx-Bx)**2+(Cy-By)**2))\nCA = Decimal(math.sqrt((Ax-Cx)**2+(Ay-Cy)**2))\n#A= Decimal(math.acos((AB**2+CA**2-BC**2)/(2*AB*CA)))\n#B= Decimal(math.acos((BC**2+AB**2-CA**2)/(2*AB*BC)))\n#C= Decimal(math.acos((BC**2+CA**2-AB**2)/(2*BC*CA)))\n#Sx=Decimal((Ax*Decimal(math.sin(2*A))+Bx*Decimal(math.sin(2*B))+Cx*Decimal(math.sin(2*C)))/(Decimal(math.sin(2*A))+Decimal(math.sin(2*B))+Decimal(math.sin(2*C))))\n#Sy=Decimal((Ay*Decimal(math.sin(2*A))+By*Decimal(math.sin(2*B))+Cy*Decimal(math.sin(2*C)))/(Decimal(math.sin(2*A))+Decimal(math.sin(2*B))+Decimal(math.sin(2*C))))\n#R= Decimal(math.sqrt((Ax-Sx)**2+(Ay-Sy)**2))\nR = Decimal(AB)*Decimal(BC)*Decimal(CA)/Decimal(math.sqrt((Decimal(AB+BC+CA)*(Decimal(BC+CA-AB))*(Decimal(CA+AB-BC))*(Decimal(AB+BC-CA)))))\nfor x in range(2,101):\n if(math.fabs(R*(Decimal(2*math.sin(math.pi/x)))-round(R*Decimal((2*math.sin(math.pi/x)))))<.005):\n #print('{:.15f}'.format(math.fabs(R*(Decimal(2*math.sin(math.pi/x)))-round(R*Decimal((2*math.sin(math.pi/x)))))))\n print('{:.10f}'.format(Decimal(.5)*Decimal(x)*Decimal(R)*Decimal(R)*Decimal(math.sin(Decimal(2)*Decimal(math.pi)/Decimal(x)))))\n #/Decimal((1+(Decimal(math.fabs(R*(Decimal(2*math.sin(math.pi/x)))-round(R*Decimal((2*math.sin(math.pi/x)))))))))))\n #print(Decimal(x))\n #print(Decimal(R))\n #print(Decimal(math.sin(Decimal(2)*Decimal(math.pi)/Decimal(x))))\n"}, {"source_code": "from sys import stdin, stdout\nimport math\n\ndef find_radius(a,b,c):\n e=math.sqrt((a+b+c)*(b+c-a)*(a+c-b)*(a+b-c))\n r=(a*b*c)/e\n return r\n\ndef length(x,y):\n return math.sqrt(x**2+y**2)\n\ndef dot(x1,y1,x2,y2):\n return x1*x2+y1*y2\n\ndef find_angles(x1,y1,x2,y2,x3,y3):\n ax=x2-x1\n ay=y2-y1\n bx=x3-x1\n by=y3-y1\n cx=x3-x2\n cy=y3-y2\n theta1=math.acos((dot(ax,ay,bx,by)/(length(ax,ay)*length(bx,by))))\n theta2=math.acos((dot(-ax,-ay,cx,cy)/(length(ax,ay)*length(cx,cy))))\n theta3=math.acos((dot(-bx,-by,-cx,-cy)/(length(cx,cy)*length(bx,by))))\n theta1=2*theta1\n theta2=2*theta2\n theta3=2*theta3\n return theta1,theta2,theta3\n\n\ndef equal(x,y):\n if abs(x-y)<=0.00001:\n return True\n return False\n\ndef gcd(x,y):\n if x<y:\n return gcd(y,x)\n else:\n a=int(x/y)\n if equal(0,x-a*y):\n return y\n else:\n return gcd(y,x-a*y)\n \ndef main(x1,y1,x2,y2,x3,y3):\n t1,t2,t3=find_angles(x1,y1,x2,y2,x3,y3)\n t=gcd(gcd(t1,t2),t3)\n n1=int(t1/t)\n n2=int(t2/t)\n n3=int(t3/t)\n n=n1+n2+n3\n a=length(x2-x1,y2-y1)\n b=length(x3-x1,y3-y1)\n c=length(x3-x2,y3-y2)\n r=find_radius(a,b,c)\n return n*0.5*math.sin(t)*(r**2)\n \ndef parse(myString):\n i=0\n l=len(myString)\n while myString[i]!=\" \":\n i+=1\n string1=myString[0:i]\n string2=myString[i+1:l-1]\n return float(string1),float(string2)\n\na=[0,0,0,0,0,0]\ni=0\nfor j in range(3):\n cell=stdin.readline()\n parse(cell)\n a[i],a[i+1]=parse(cell)\n i+=2\narea=main(a[0],a[1],a[2],a[3],a[4],a[5])\nprint area"}, {"source_code": "\nfrom math import *\n\ndef gcd(x,y):\n if y < 1e-3:\n return x\n else:\n return gcd(y,fmod(x,y))\n\ndef area(a, b, c):\n s = (a + b + c) / 2\n return sqrt(s*(s-a)*(s-b)*(s-c))\n\npoint = [list(map(float,input().split())) for i in range(3)]\n\na,b,c = [sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) for (x1,y1),(x2,y2) in\n [(point[0],point[1]),(point[0],point[2]), (point[1],point[2])]]\nA,B,C = [acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]]\n\nS = area(a, b, c)\nR = a * b * c / 4 * S\ngcd_ = gcd(A, gcd(B, C))\nn = pi / gcd_\nprint(round(R*R*n*sin((2*pi)/n))/2,7)"}, {"source_code": "from math import *\n\ndef LineIntersect(a,b):\n det=lambda a,b,c,d:a*d-b*c\n z=det(a[0],a[1],b[0],b[1])\n return (-det(a[2],a[1],b[2],b[1])/z,-det(a[0],a[2],b[0],b[2])/z)\n\ndef GetCircleInOrigin(A):\n GetNormal=lambda (x,y):(-y,x)\n GetDif=lambda (x1,y1),(x2,y2):(x1-x2,y1-y2)\n GetSum=lambda (x1,y1),(x2,y2):(x1+x2,y1+y2)\n GetMultToCof=lambda (x1,y1),c:(x1*c,y1*c)\n NormalLine=lambda (a,b):(b[1]-a[1],a[0]-b[0],a[1]*b[0]-a[0]*b[1])\n L=[ (GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetSum(GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetNormal(GetDif(A[i+1],A[i])))) for i in range(2)]\n L=map(NormalLine,L)\n L=LineIntersect(L[0],L[1]) \n return map(lambda x:GetDif(x,L),A)\n\ndef norm(a):\n if (a<0):\n return a+2*pi\n else:\n return a\n\neps=0.000001\nA=[map(float,raw_input().split()) for i in range(3)]\nA=GetCircleInOrigin(A)\nC=[atan2(y,x) for x,y in A]\nfor i in range(3):\n if (C[i]<0):\n C[i]+=2*pi\nC=sorted(C)\nprint C\nomega=0\nR=hypot(*A[0])\nfor p in range(3,101):\n alpha=2*pi/p\n for a1 in xrange (1,p):\n for a2 in range (1,p-a1):\n a3=p-a1-a2\n if (omega==0) and (abs(norm(C[1]-C[0]-a1*alpha))<=eps) and (abs(norm(C[2]-C[1]-a2*alpha))<=eps) and (abs(norm(C[0]-C[2]-a3*alpha))<=eps):\n omega=alpha \nprint R**2*pi/omega*sin(omega)\n"}, {"source_code": "from math import *\n\nkordinat = [list(map(float, input().split())) for i in range(3)]\na, b, c = [hypot(x1 - x2, y1 - y2) for (x1, y1), (x2, y2) in [\n (kordinat[0], kordinat[1]), (kordinat[0], kordinat[2]), (kordinat[1],kordinat[2])\n ]]\nA, B, C = [acos((z*z + y*y - x*x) / 2 / y / z) for x,y,z in [(a,b,c), (b,c,a), (c,a,b)]]\nRadius = a / (2 * sin(A))\ndef g(x, y):\n if y < 1e-3:\n return x\n else:\n return g(y, fmod(x, y))\nu = 2 * g(A,g(B, C))\nArea = round((pi * Radius * Radius) / (u * sin(u)), 7)\nprint(Area)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Mar 10 20:19:16 2015\nkristof.jakab@hegelab.org\n\"\"\"\n\nimport math\n\nclass Point(object):\n \"\"\" \"\"\"\n def __init__(self, x, y):\n self.x = x\n self.y = y\n self.vabs = math.sqrt(x ** 2 + y ** 2)\n\nclass Line(object):\n \"\"\" \"\"\"\n def __init__(self, A, B): \n self.direction = Point(B.x - A.x, B.y - A.y)\n self.length = math.sqrt((B.x - A.x) ** 2 + (B.y - A.y) ** 2)\n\ndef calculate_angle(point_A, point_B):\n ab = point_A.x * point_B.x + point_A.y * point_B.y \n cos_angle = ab / (point_A.vabs * point_B.vabs)\n # return round(math.degrees(math.acos(cos_angle)), 6)\n return math.acos(cos_angle)\n \ndef calculate_area(n, R):\n area = 0.5 * n * R * R * math.sin(2 * math.pi / n)\n return area\n\nA = Point(*map(float, raw_input().split()))\nB = Point(*map(float, raw_input().split()))\nC = Point(*map(float, raw_input().split()))\n \nAB = Line(A, B)\nAC = Line(A, C)\n\nBA = Line(B, A)\nBC = Line(B, C)\n\na = calculate_angle(AB.direction, AC.direction) * 2\nb = calculate_angle(BA.direction, BC.direction) * 2\n\nif a > math.pi:\n a = 2 * math.pi - a\nif b > math.pi:\n b = 2 * math.pi - b\n\nc = 2 * math.pi - (a + b)\n\n# R = (BC.length / 2) / math.sin(math.radians(a / 2))\nR = (BC.length / 2) / math.sin(a / 2)\n\nfor x in xrange(1, 100):\n y = x * (a / c)\n z = x * (b / c)\n if round(y, 1) % 1 == 0 and round(z, 1) % 1 == 0:\n n = int(round(x + y + z, 0))\n break\n\nprint calculate_area(n, R)"}, {"source_code": "from math import sqrt, sin, acos, pi\n\ndist_sq = lambda A, B: (A[0] - B[0])**2 + (A[1] - B[1])**2\n\ndef angle(R, A, B):\n c = dist_sq(A, B)\n a = dist_sq(R, B)\n b = dist_sq(R, A)\n cosine = (a + b - c)/sqrt(4 * a * b)\n return acos(cosine)\n\ndef circumcentre(A, B, C):\n a = dist_sq(B, C)\n b = dist_sq(A, C)\n c = dist_sq(A, B)\n bary = (\n a * (b + c - a),\n b * (c + a - b),\n c * (a + b - c),\n )\n x = (bary[0] * A[0] + bary[1] * B[0] + bary[2] * C[0])/sum(bary)\n y = (bary[0] * A[1] + bary[1] * B[1] + bary[2] * C[1])/sum(bary)\n return (x, y)\n\ndef div(m, n):\n m, n = max(m, n), min(m, n)\n return abs(round(m/n) - m/n) < 10**-6\n\ndef gcd(a, b):\n a, b = max(a, b), min(a, b)\n if div(a, b):\n return b\n else:\n return gcd(b, a-b)\n\nA = tuple(map(float, input().split()))\nB = tuple(map(float, input().split()))\nC = tuple(map(float, input().split()))\ncir = circumcentre(A, B, C)\nR = dist_sq(cir, A)\n\nangles = sorted([angle(cir, A, B), angle(cir, B, C), angle(cir, C, A)])\ngamma = gcd(angles[0], angles[1])\nprint(pi * R * sin(gamma)/gamma)"}, {"source_code": "import math\n[(x0,y0),(x1,y1),(x2,y2)] = [raw_input().split() for _ in xrange(3)]\nx0,y0 = float(x0),float(y0)\nx1,y1 = float(x1),float(y1)\nx2,y2 = float(x2),float(y2)\n\n# first, solve for the center of the circle (p,q)\n# to see how I did this, see this math.stackexchange post:\n# https://math.stackexchange.com/questions/213658/get-the-equation-of-a-circle-when-given-3-points\na11,a12,a21,a22 = 2*(x0-x1), 2*(y0-y1), 2*(x0-x2), 2*(y0-y2)\nb1,b2 = x0**2-x1**2+y0**2-y1**2, x0**2-x2**2+y0**2-y2**2\nq = (a21*b1 - a11*b2)/(a21*a12 - a11*a22)\np = (b1 - a12*q)/a11\n\n# as described here:\n# https://math.stackexchange.com/questions/1142644/regular-polygon-determined-by-three-vertices\n# we can determine the smallest number of sides given the angles with the center\nAB = ((x0 - p)*(x1 - p) + (y0 - q)*(y1 - q))/math.sqrt(((x0 - p)**2 + (y0 - q)**2)*((x1 - p)**2 + (y1 - q)**2))\nBC = ((x2 - p)*(x1 - p) + (y2 - q)*(y1 - q))/math.sqrt(((x2 - p)**2 + (y2 - q)**2)*((x1 - p)**2 + (y1 - q)**2))\nCA = ((x0 - p)*(x2 - p) + (y0 - q)*(y2 - q))/math.sqrt(((x0 - p)**2 + (y0 - q)**2)*((x2 - p)**2 + (y2 - q)**2))\n\nAOB = int(round(180*math.acos(AB)/math.pi))\nBOC = int(round(180*math.acos(BC)/math.pi))\nCOA = int(round(180*math.acos(CA)/math.pi))\n\n(r1,r2,r3) = (AOB/360.0,BOC/360.0,COA/360.0)\n\n# brute forcing a bit here... might be too slow\nn = 2\nc1,c2,c3 = 0,0,0\nwhile c1 + c2 + c3 != 3 and n <= 100:\n\tc1,c2,c3 = 0,0,0\n\tn += 1\n\tif n*r1 == math.floor(n*r1):\n\t\tc1 = 1\n\tif n*r2 == math.floor(n*r2):\n\t\tc2 = 1\n\tif n*r3 == math.floor(n*r3):\n\t\tc3 = 1\n\nprint n"}, {"source_code": "##x1, y1 = map(float, raw_input().split())\n##x2, y2 = map(float, raw_input().split())\n##x3, y3 = map(float, raw_input().split())\nimport math\nx1 = 71.756151; y1 = 7.532275\nx2 = -48.634784; y2 = 100.159986\nx3 = 91.778633; y3 = 158.107739\n\n##x1 = 0.0; y1 = 0.0\n##x2 = 0.0; y2 = 1.0\n##x3 = math.sqrt(3); y3 = 1.0\n\nEPSILON = 0.0000001\ndef midPoint(x1, y1, x2, y2):\n mid_x = (x1 + x2) / 2\n mid_y = (y1 + y2) / 2\n return (mid_x, mid_y)\n\ndef slope_mid_perpend(x1, y1, x2, y2):\n return -1 * (x2 - x1) / (y2 - y1)\n\ndef distance(x1, y1, x2, y2):\n return math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2)\n\ndef circleCenter(x1, y1, x2, y2, x3, y3):\n x12, y12 = midPoint(x1, y1, x2, y2)\n x13, y13 = midPoint(x1, y1, x3, y3)\n if y1 == y2:\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n x0 = x12\n y0 = k_mid_13 * (x0 - x13) + y13\n elif y1 == y3:\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n x0 = x13\n y0 = k_mid_12 * (x0 - x12) + y12\n else:\n k_mid_13 = slope_mid_perpend(x1, y1, x3, y3)\n k_mid_12 = slope_mid_perpend(x1, y1, x2, y2)\n x0 = (y13 - y12 + k_mid_12*x12 - k_mid_13*x13) / (k_mid_12 - k_mid_13)\n y0 = k_mid_13 * (x0 - x13) + y13\n return x0, y0\nx0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\ndef angle(distance1, distance2):\n angle = math.asin((distance1/2) / distance2)\n return 2 * angle\nd_12 = distance(x1, y1, x2, y2)\nd_13 = distance(x1, y1, x3, y3)\nd_32 = distance(x3, y3, x2, y2)\n##print d_12, d_13, d_32\nr = distance(x1, y1, x0, y0)\n\nangle1O2 = angle(d_12, r)\nangle1O3 = angle(d_13, r)\nangle3O2 = angle(d_32, r)\n##print angle1O2, angle1O3, angle3O2\n\n##print angle1O2, angle1O3, angle3O2\n##\n##print angle(math.sqrt(2), 1)\n\ndef isRemainder(angle, angle_N):\n remainder = angle % angle_N\n## print remainder\n \n if (abs(remainder - 0)<= EPSILON) or (abs(remainder - angle_N) <= EPSILON):\n return True\n else:\n return False\n \ndef find_N(angle1, angle2, angle3):\n N = 3\n while 1:\n## print angle1, angle1, angle3\n angle_N = 2 * math.pi / N\n## print 'angle_N', angle_N\n## remainder1 = angle1 % angle_N\n## remainder2 = angle2 % angle_N\n## remainder3 = angle3 % angle_N\n## print remainder1, remainder2, remainder3\n if (isRemainder(angle1, angle_N) and isRemainder(angle2, angle_N) and\n isRemainder(angle2, angle_N)):\n break\n N += 1\n \n return N\nN = find_N(angle1O2, angle1O3, angle3O2)\ndef area_N(N):\n angle = 2 * math.pi / N\n area = N * 0.5 * r * r * math.sin(angle)\n return area\n\nprint area_N(N)\n \n \n\n\n##print angle1O3, 2 * math.pi / 6\n##print angle1O3 % (2 * math.pi / 6)\n\n\n\n\n## test\n##print circleCenter(x1, y1, x2, y2, x3, y3)\n##\n##import math\n##\n##x0, y0 = circleCenter(x1, y1, x2, y2, x3, y3)\n##print distance(x0, y0, x1, y1), distance(x0, y0, x2, y2), distance(x0, y0, x2, y2)\n\n\n\n\n\n\n\n\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/1/A\n\"\"\"\n\nimport sys\nimport math\n\n\ndef gcd(a, b):\n\tif a < b:\n\t\ta, b = b, a\n\t\t\n\twhile b > 1:\n\t\ta, b = b, a - b\n\t\n\treturn a\n\n\ndef square(arr):\n\ta = math.sqrt( (arr[2][0]-arr[1][0])**2 + (arr[2][1]-arr[1][1])**2 )\n\tb = math.sqrt( (arr[2][0]-arr[0][0])**2 + (arr[2][1]-arr[0][1])**2 )\n\tc = math.sqrt( (arr[1][0]-arr[0][0])**2 + (arr[1][1]-arr[0][1])**2 )\n\tp = 0.5 * (a+b+c)\n\tR = a*b*c / (4 * math.sqrt(p*(p-a)*(p-b)*(p-c)))\n\t\n\talpha = math.acos( round((2*R**2-c**2)/(2*R**2), 6) )\n\tbeta = \tmath.acos( round((2*R**2-a**2)/(2*R**2), 6) )\n\tgamma = math.acos( round((2*R**2-b**2)/(2*R**2), 6) )\n\t\n\tdelta = gcd(alpha, gcd(beta, gamma))\n\tn = math.floor(2*math.pi / delta)\n\ts = (n/2)*(R**2)*math.sin(2*math.pi/n)\n\t\n\treturn s\n\n\ndef main():\n\tarr = []\n\t\n\tfor i in range(3):\n\t\tl = sys.stdin.readline()\n\t\tx, y = [float(t) for t in l.split()]\n\t\tarr.insert(i-1, (x, y))\n\t\n\ts = square(arr)\n\tprint(\"%.6f\" % s)\n\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "from math import pi,sin,cos,sqrt\np = [map(float,raw_input().split()),map(float,raw_input().split()),map(float,raw_input().split())]\n#p = [[71.759151,7.532275],[-48.637784,100.159986],[91.778633,158.107739]]\n#p = [[1.0,1.0],[0.0,0.0],[1.0,0.0]]\nfor n in range(3,100):\n poly = [[cos(2.0*pi*i/n),sin(2.0*pi*i/n)] for i in range(n)] \n area = n*sin(pi/n)*cos(pi/n)\n p1 = poly[0]\n for p2 in poly[1:]: \n a = [p[1][0]-p[0][0],p[1][1]-p[0][1]]\n b = [p2[0]-p1[0],p2[1]-p1[1]]\n al = (a[0]*a[0]+a[1]*a[1])\n bl = (b[0]*b[0]+b[1]*b[1]) \n s = (b[0]*a[1]-b[1]*a[0])/al\n c = (a[0]*b[0]+a[1]*b[1])/al \n t = map(lambda x: [x[0]-p[0][0],x[1]-p[0][1]],p) \n t = map(lambda x: [x[0]*c+x[1]*s,-x[0]*s+x[1]*c],t) \n t = map(lambda x: [x[0]+p1[0],x[1]+p1[1]],t)\n for x in poly[2:]:\n if abs(x[0]-t[2][0]) < 0.00001 and abs(x[1]-t[2][1]) < 0.00001:\n print al/bl*area\n exit()\n \n"}, {"source_code": "import math\nimport sys\n\ndef read_input():\n [input_1,input_2,input_3] = sys.stdin.readlines()\n x1,y1=input_1.strip().split()\n x2,y2=input_2.strip().split()\n x3,y3=input_3.strip().split()\n x1 = float(x1)\n x2 = float(x2)\n x3 = float(x3)\n y1 = float(y1)\n y2 = float(y2)\n y3 = float(y3)\n return x1,x2,x3,y1,y2,y3\n\ndef outer_center(x1,x2,x3,y1,y2,y3):\n A1=2*(x2-x1)\n B1=2*(y2-y1)\n C1=x2*x2+y2*y2-x1*x1-y1*y1\n A2=2*(x3-x2)\n B2=2*(y3-y2)\n C2=x3*x3+y3*y3-x2*x2-y2*y2\n\n x = ((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))\n y = ((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1))\n\n return x,y\n\ndef get_degree(x1,x2,x3,y1,y2,y3):\n A = math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))\n B = math.sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2))\n C = math.sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3))\n\n\n c = math.acos((A**2 + B**2 - C**2)/(2 * A * B)) * 180 /math.pi\n b = math.acos((A**2 + C**2 - B**2)/(2 * A * C)) * 180 /math.pi\n a = math.acos((B**2 + C**2 - A**2)/(2 * C * B)) * 180 /math.pi\n\n return a,b,c\n\ndef find_gcd(a,b,c):\n a = int(round(a))\n b = int(round(b))\n c = int(round(c))\n temp1 = math.gcd(a,b)\n temp2 = math.gcd(temp1,c)\n return temp2\n\ndef determine_angles(gcd):\n return int(180/gcd)\n\ndef get_radius(x0,y0,x1,y1):\n return math.sqrt((x0-x1)**2+(y0-y1)**2)\n\nif __name__ == \"__main__\":\n eps = 0.0001 # Accuracy adjustment\n DEBUG = 0\n x1,x2,x3,y1,y2,y3 = read_input()\n if DEBUG == 1:\n print(\"success!\")\n x,y = outer_center(x1,x2,x3,y1,y2,y3)\n if DEBUG == 1:\n print(\"x=\",x,\"y=\",y)\n a,b,c = get_degree(x1,x2,x3,y1,y2,y3)\n if DEBUG == 1:\n print(\"angle A=\",a,\"angle B=\",b,\"angle C=\",c)\n r = get_radius(x,y,x1,y1)\n if DEBUG == 1:\n print(\"r=\",r)\n if abs(a-round(a))>eps or abs(b-round(b))>eps or abs(c-round(c))>eps:# cannot use direct round for now\n smallest = min(a,min(b,c))\n largest = max(a,max(b,c))\n N = 0\n for i in range(1,2000):\n if abs(smallest*i-round(smallest*i))<eps and (smallest*i-180)>-eps: # potentially find the N\n if abs((smallest * i/180) - round (smallest*i/180)) <eps:\n gcd_angle = math.gcd(int(round(largest*i)),int(round(smallest*i)))\n if DEBUG == 1:\n print(\"gcd_angle=\",gcd_angle)\n if gcd_angle == int(round(smallest*i)):\n N = i\n if DEBUG == 1:\n print(\"hit\")\n break\n else:\n t = 180/gcd_angle*i\n if DEBUG == 1:\n print(\"miss\", 180/gcd_angle*i)\n for j in range(1,20):\n if abs(t*j-round(t*j))<eps:\n N = int(t*j)\n break\n break\n if N == 0:\n N = 45\n if DEBUG == 1:\n print(\"Using alternative method, N =\",N)\n\n else:\n gcd = find_gcd(a,b,c)\n if DEBUG == 1:\n print(\"gcd=\",gcd)\n N = determine_angles(gcd)\n if DEBUG == 1:\n print(\"N=\",N)\n \n area = 0.5*N*r*r*math.sin(2/N*math.pi)\n print(\"%.6f\"%area)\n\n"}, {"source_code": "import math\nfrom fractions import Fraction\nline = input()\ndata = line.split()\nx1, y1 = float(data[0]), float(data[1])\nline = input()\ndata = line.split()\nx2, y2 = float(data[0]), float(data[1])\nline = input()\ndata = line.split()\nx3, y3 = float(data[0]), float(data[1])\ndis12 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)\ndis23 = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)\ndis13 = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)\ncos1 = (dis13 + dis12 - dis23) / (2 * math.sqrt(dis12 * dis13))\ncos2 = (dis23 + dis12 - dis13) / (2 * math.sqrt(dis23 * dis12))\nangle1 = math.acos(cos1) * 2\nangle2 = math.acos(cos2) * 2\nnumber = Fraction.from_float(angle1 / angle2).limit_denominator(101)\nl = angle1 / number.numerator\nn = int(2 * math.pi / l + 0.5)\nsin1 = math.sqrt(1 - cos1 * cos1)\nr = math.sqrt(dis23) / (2 * sin1)\narea = 1 / 2 * n * math.sin(2 * math.pi / n) * r * r\nprint('%.6f' % area)\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport math\n\ndef area(d):\n if len(d) < 3:\n return False\n a = 0.0\n p = 0.5 * (d[0] + d[1] + d[2])\n a = math.sqrt(p*(p-d[0])*(p-d[1])*(p-d[2]))\n return a\n\ndef circumcircle(x,y):\n distance = euclidean(x,y)\n triangle_area = area(distance)\n return distance[0] * distance[1] * distance[2] / (4 * triangle_area)\n \ndef euclidean(x,y):\n d = []\n d.append(math.sqrt((x[0]-x[1])**2 + (y[0]-y[1])**2))\n d.append(math.sqrt((x[0]-x[2])**2 + (y[0]-y[2])**2))\n d.append(math.sqrt((x[1]-x[2])**2 + (y[1]-y[2])**2))\n return d\n \ndef centerAngle(d,radius):\n angle = []\n #print(type(d[0]), type(radius))\n #print(d[0]/(2*radius))\n #print(2 * math.asin( d[0] / (2*radius) ) )\n angle.append(2*math.asin(d[0]/(2*radius)))\n angle.append(2*math.asin(d[1]/(2*radius)))\n angle.append(2*math.asin(d[2]/(2*radius)))\n return angle\n\ndef gcd(a,b):\n if a < 0.01:\n return b\n else:\n return gcd(math.fmod(b,a),a)\ndef main():\n \n # get the input data\n x = []\n y = []\n for i in range(3):\n temp_input = input().split() \n x.append(float(temp_input[0]))\n y.append(float(temp_input[1]))\n\n # 1. calculate the length of the edge \n # 2. calculate the area of the triangle\n # 3. calculate the radius of the circumcircle\n # 4. calculate the area of the Berland Circus\n\n edge_length = euclidean(x,y)\n\n triangle_area = area(edge_length)\n\n circumcircle_radius = circumcircle(x,y)\n\n #print(\"circumcircle_radius: {0[0]}:{1[0]},{0[1]}:{1[1]}, {0[2]}:{1[2]} \\n {2}\".format(x,y,circumcircle_radius))\n # 5. calculat the cetral angle and their gcd\n angle = centerAngle(edge_length, circumcircle_radius)\n \n gcd_angle = gcd(gcd(angle[0], angle[1]), angle[2])\n\n\n result = 2 * math.pi / gcd_angle * circumcircle_radius * math.sin(gcd_angle) * circumcircle_radius * 0.5 \n\n #print(\"circumcircle_radius\",circumcircle_radius)\n #print(\"totoal_angle\",angle)\n #print(\"gcd_angle\",gcd_angle)\n #print(\"len\",edge_length)\n print(\"{:.8f}\".format(result))\n \n \n\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import math\nx1 = map(float,raw_input().split())\nx2 = map(float,raw_input().split())\nx3 = map(float,raw_input().split())\n\n#print 1.0/2*(a[0]*b[1]+b[0]*c[1]+c[0]*a[1]-a[1]*b[0]-b[1]*c[0]-c[1]*a[0])\n\n#x1 = [0.000000,0.000000]\n#x2 = [1.000000,1.000000]\n#x3 = [0.000000,1.000000]\ns = abs(1.0/2*(x1[0]*x2[1]+x2[0]*x3[1]+x3[0]*x1[1]-x1[1]*x2[0]-x2[1]*x3[0]-x3[1]*x1[0]))\na = math.sqrt((x1[0]-x2[0])**2+(x1[1]-x2[1])**2)\nb = math.sqrt((x3[0]-x2[0])**2+(x3[1]-x2[1])**2)\nc = math.sqrt((x1[0]-x3[0])**2+(x1[1]-x3[1])**2)\n#print a,b,c,s\nr = a*b*c/(s*4)\n#print r\nA = math.acos((r**2+r**2-a**2)/(2*r*r))*180/math.pi\nB = math.acos((r**2+r**2-b**2)/(2*r*r))*180/math.pi\nC = math.acos((r**2+r**2-c**2)/(2*r*r))*180/math.pi\n#print A,B,C\ndef gcd(x,y):\n x = float(x)\n y = float(y)\n #print x,y\n while (abs(x)>1e-4 and abs(y)>1e-4):\n if(x>y):\n #print int(x/y)\n x = float(x -int(x/y)*y)\n #print 1,x\n else:\n y = float(y -int(y/x)*x)\n #print 2,y\n return abs(x+y)\nn = 360.0/gcd(gcd(A,B),C)\n#print n\nprint '%f' %(0.5*n*math.sin(2*math.pi/n)*r*r)"}, {"source_code": "from time import *\nfrom math import * \n\ndef dist(x1,y1,x2,y2):\n\treturn ((x1-x2)**2+(y1-y2)**2)**0.5\n\ndef isInteger(x):\n\treturn abs(x-round(x))<1e-2\n\ndef area(x1,y1,x2,y2,x3,y3):\n\ta=dist(x1,y1,x2,y2)\n\tb=dist(x3,y3,x2,y2)\n\tc=dist(x1,y1,x3,y3)\n\td=(a+b+c)/2\n\treturn (d*(d-a)*(d-b)*(d-c))**0.5\n\ndef radiusOuter(x1,y1,x2,y2,x3,y3):\n\treturn a*b*c/area(x1,y1,x2,y2,x3,y3)/4\n\ndef linePass2Point(x1,y1,x2,y2):\n\ta=y2-y1\n\tb=x1-x2\n\tc=-a*x1-b*y1\n\treturn a,b,c\n\ndef intersect(a1,b1,c1,a2,b2,c2):\n\ty=-(a2*c1-a1*c2)/(a2*b1-a1*b2)\n\tx=-(b2*c1-b1*c2)/(b2*a1-b1*a2)\n\treturn x,y\n\ndef midLine(x1,y1,x2,y2):\n\ta1,b1,c1=linePass2Point(x1,y1,x2,y2)\n\ta2,b2=-b1,a1\n\tx,y=(x1+x2)/2,(y1+y2)/2\n\tc2=-(a2*x+b2*y)\n\treturn a2,b2,c2\n\ndef centerOfOuterTriangle(x1,y1,x2,y2,x3,y3):\n\ta1,b1,c1=midLine(x1,y1,x2,y2)\n\ta2,b2,c2=midLine(x1,y1,x3,y3)\n\tx,y=intersect(a1,b1,c1,a2,b2,c2)\n\treturn x,y,dist(x,y,x1,y1)\n\ndef angle(x1,y1,x2,y2,x3,y3):\n\t# t\u00ednh g\u00f3c \u0111\u1ed1i di\u1ec7n v\u1edbi [x1,y1],[x2,y2]\n\tc=dist(x1,y1,x2,y2)\n\tb=dist(x3,y3,x2,y2)\n\ta=dist(x1,y1,x3,y3)\n\ttg=(a*a+b*b-c*c)/(2*a*b)\n\ttg=tg if -1+1e-4<=tg<=1-1e-4 else (-1+1e-4 if tg<-1 else 1-1e-4)\n\treturn acos(tg)\n\ndef areaByRadius(r,n):\n\treturn r*r*n*sin(2*pi/n)/2\n\nx1,y1=[float(i) for i in input().split()]\nx2,y2=[float(i) for i in input().split()]\nx3,y3=[float(i) for i in input().split()]\n\ndef check(n):\n\tglobal x,y,r\n\ta=2*pi/n\n\treturn isInteger(a1/a) and isInteger(a2/a) and isInteger(a3/a)\n\n\t\nx,y,r=centerOfOuterTriangle(x1,y1,x2,y2,x3,y3)\n# print(x,y,r)\na1=angle(x1,y1,x2,y2,x,y)\na2=angle(x3,y3,x2,y2,x,y)\na3=angle(x1,y1,x3,y3,x,y)\nfor i in range(3,101):\n\ta=2*pi/i\n\t# print(i,round(areaByRadius(r,i),8),a1/a,a2/a,a3/a)\n\tif isInteger(a1/a) and isInteger(a2/a) and isInteger(a3/a):\n\t\tprint(round(areaByRadius(r,i),8))\n\t\tbreak\n\n\n\n"}, {"source_code": "from math import *\np1 = input()\np1x,p1y = p1.split(' ')\np2 = input()\np2x,p2y = p2.split(' ')\np3 = input()\np3x,p3y = p3.split(' ')\np1x = float(p1x)\np1y = float(p1y)\np2x = float(p2x)\np2y = float(p2y)\np3x = float(p3x)\np3y = float(p3y)\ndis12 = sqrt((p1x-p2x)**2+(p1y-p2y)**2)\ndis23 = sqrt((p2x-p3x)**2+(p2y-p3y)**2)\ndis13 = sqrt((p1x-p3x)**2+(p1y-p3y)**2)\nsorteddist = sorted([dis13,dis12,dis23])\nmindist = sorteddist[0]\ntotalsides = 1\nfor dis in sorteddist[1:]:\n if (abs(dis-mindist)<=0.00001):\n totalsides += 1\n continue\n q = int(dis/mindist)+1\n totalsides += q\ntheta = pi/totalsides\nh = 0.5*mindist/tan(theta)\ns = 0.5*mindist*h*totalsides\nprint (s)"}, {"source_code": "from sys import stdin,stdout\nimport math\nimport fractions\ncoordinate1=[float(x)for x in stdin.readline().rstrip().split()]\ncoordinate2=[float(x)for x in stdin.readline().rstrip().split()]\ncoordinate3=[float(x)for x in stdin.readline().rstrip().split()]\nmid1x=(coordinate1[0]+coordinate2[0])/2\nmid2x=(coordinate1[0]+coordinate3[0])/2\nmid1y=(coordinate1[1]+coordinate2[1])/2\nmid2y=(coordinate1[1]+coordinate3[1])/2\ndiff=(coordinate2[0]-coordinate3[0])/2\nif coordinate1[1]!=coordinate2[1] and coordinate1[1]!=coordinate3[1]:\n slope1=(coordinate1[0]-coordinate2[0])/(coordinate2[1]-coordinate1[1])\n slope2=(coordinate1[0]-coordinate3[0])/(coordinate3[1]-coordinate1[1])\n centerx=((coordinate3[1]-coordinate2[1])/2+slope1*mid1x-slope2*mid2x)/(slope1-slope2)\n centery=slope1*(centerx-mid1x)+mid1y\nif coordinate1[1]==coordinate2[1]:\n slope2=(coordinate1[0]-coordinate3[0])/(coordinate3[1]-coordinate1[1])\n centerx=mid1x\n centery=slope2*diff+(coordinate1[1]+coordinate3[1])/2\nif coordinate1[1]==coordinate3[1]:\n slope1=(coordinate1[0]-coordinate2[0])/(coordinate2[1]-coordinate1[1])\n centerx=mid2x\n centery=slope1*diff*(-1)+mid1y\nangle1=math.pi-2*math.atan2(math.hypot(centerx-mid1x,centery-mid1y),math.hypot(coordinate1[0]-coordinate2[0],coordinate1[1]-coordinate2[1])/2)\nangle2=math.pi-2*math.atan2(math.hypot(centerx-mid2x,centery-mid2y),math.hypot(coordinate1[0]-coordinate3[0],coordinate1[1]-coordinate3[1])/2)\nangle1=fractions.gcd(angle1,angle2)\nangle2=angle1/2\nradius=math.hypot(coordinate1[0]-centerx,coordinate1[1]-centery)\nstdout.write(str(radius*math.sin(angle2)*radius*math.cos(angle2)*2*math.pi/angle1)+'\\n')\n"}, {"source_code": "from math import atan2, sin, sqrt, pi\n\n\ndef create_line(segment):\n line = {}\n \n line['A'] = segment['q']['y'] - segment['p']['y']\n line['B'] = segment['p']['x'] - segment['q']['x']\n line['C'] = line['A'] * segment['p']['x'] - line['B'] * segment['p']['y']\n\n return line\n\ndef midpoint(segment):\n point = {}\n\n point['x'] = .5 * (segment['p']['x'] + segment['q']['x'])\n point['y'] = .5 * (segment['p']['y'] + segment['q']['y'])\n\n return point\n\ndef perpendicular(line, point):\n new_line = {}\n\n new_line['A'] = -line['B']\n new_line['B'] = line['A']\n new_line['C'] = new_line['A'] * point['x'] + new_line['B'] * point['y']\n\n return new_line\n\ndef intersection(line1, line2):\n point = {}\n\n det = line1['A'] * line2['B'] - line2['A'] * line1['B']\n point['x'] = (line2['B'] * line1['C'] - line1['B'] * line2['C']) / det\n point['y'] = (line1['A'] * line2['C'] - line2['A'] * line1['C']) / det\n\n return point\n\ndef subtract(p, q):\n point = {}\n\n point['x'] = p['x'] - q['x']\n point['y'] = p['y'] - q['y']\n\n return point\n\ndef distance(p, q):\n d = subtract(p, q)\n return sqrt(d['x']**2 + d['y']**2)\n\n\n\nEPS = 1e-9\n\np = dict((r, c) for r, c in zip(\"xy\", map(float, raw_input().split())))\nq = dict((r, c) for r, c in zip(\"xy\", map(float, raw_input().split())))\ns = dict((r, c) for r, c in zip(\"xy\", map(float, raw_input().split())))\n\npq = {'p': p, 'q': q}\nps = {'p': p, 'q': s}\n\nl1 = create_line(pq)\nl2 = create_line(ps)\n\nm1 = midpoint(pq)\nm2 = midpoint(ps)\n\npl1 = perpendicular(l1, m1)\npl2 = perpendicular(l2, m2)\n\nc = intersection(pl1, pl2)\nr = distance(p, c)\n\np = subtract(p, c)\nq = subtract(q, c)\ns = subtract(s, c)\n\nt1, t2, t3 = sorted((atan2(p['y'], p['x']), atan2(q['y'], q['x']), atan2(s['y'], s['x'])))\n\nt12 = t2 - t1\nt23 = t3 - t2\nt31 = 2 * pi + t1 - t3\n\nfor sides in range(3, 200):\n t = 2 * pi / sides\n\n if abs(t12 / t - round(t12 / t)) < EPS \\\n and abs(t23 / t - round(t23 / t)) < EPS \\\n and abs(t31 / t - round(t31 / t)) < EPS:\n break\n\nprint .5 * sides * r**2 * sin(t)\n \n"}, {"source_code": "#import numpy as np\nimport math\n\ndef angle():\n for i in range(3, 101):\n a = math.pi * (1.0 - 2.0 / i)\n yield a\n\ndef central_angle():\n for i in range(3, 101):\n a = 2.0 * math.pi / i\n yield a\n\ndef dist(x1, x2):\n return math.sqrt((x1[0] - x2[0]) ** 2 + (x1[1] - x2[1]) ** 2)\n\ndef dot(a, b):\n return a[0] * b[1] - a[1] * b[0]\n\ndef isint(x):\n if (x - math.floor(x) < 10e-8):\n return True\n if (math.ceil(x) - x < 10e-8):\n return True\n return False\n\ndef lineInt(line1, line2):\n a = line1[0]\n b = line1[1]\n c = line2[0]\n d = line2[1]\n \n s = ( (b[1] - a[1]) * (c[0] - a[0]) - (c[1] - a[1]) ) / ( (b[1] - a[1]) * (d[0] - c[0]) + (d[1] - c[1]) )\n \n x = c[0] + (d[0] - c[0]) * s\n y = c[1] + (d[1] - c[1]) * s\n \n return (x, y)\n\ndef findCentre(a, b, c):\n #m1 = np.multiply(np.add(a, b), 0.5)\n #m2 = np.multiply(np.add(c, b), 0.5)\n m1 = [(a[0] + b[0]) * 0.5, (a[1] + b[1]) * 0.5]\n m2 = [(c[0] + b[0]) * 0.5, (c[1] + b[1]) * 0.5]\n \n line1 = ( m1, [m1[0] + b[1] - a[1], m1[1] + a[0] - b[0]] )\n line2 = ( m2, [m2[0] + b[1] - c[1], m2[1] + c[0] - b[0]] )\n #print (line1[0], line1[1])\n #print (line2[0], line2[1])\n return lineInt(line1, line2)\n\na = list(map(float, input().split()))\nb = list(map(float, input().split()))\nc = list(map(float, input().split()))\n\nx = findCentre(a, b, c)\n#print ('centre = ' + str(x))\n\nr = dist(a, x)\n#print ('radius = ' + str(r))\n\n#print ('\\n')\n#print ('sin(alpha) = ' + str(dot([a[0] - x[0], a[1] - x[1]], [b[0] - x[0], b[1] - x[1]]) / (r * r)))\n#print ('sin(beta) = ' + str(dot([b[0] - x[0], b[1] - x[1]], [c[0] - x[0], c[1] - x[1]]) / (r * r)))\n\nalpha = math.asin(dot([a[0] - x[0], a[1] - x[1]], [b[0] - x[0], b[1] - x[1]]) / (r * r))\nbeta = math.asin(dot([b[0] - x[0], b[1] - x[1]], [c[0] - x[0], c[1] - x[1]]) / (r * r))\n\n#print ('\\n')\n#print ('alpha = ' + str(alpha))\n#print ('beta = ' + str(beta))\n#print ('\\n')\n\nn = 2.0\nfor theta in central_angle():\n n = n + 1.0\n k1 = alpha / theta\n k2 = beta / theta\n #print (k1, k2)\n \n if (isint(k1) and isint(k2)):\n #print ('n = ' + str(n))\n #print ('theta = ' + str(theta))\n print ((n / 2.0) * r * r * math.sin(theta))\n break\n \n"}, {"source_code": "# python 2.7 code for P001C\n# steps:\n# 1) get the center and radius\n# 2) get the angle and n\n# 3) get the area\n#https://stackoverflow.com/questions/35176451/python-code-to-calcualte-angle-between-three-point-using-thier-3d-coordinates\n#http://www.it610.com/article/5541237.htm\nimport math\n\ndef distance(point_a, point_b):\n\tx_1, y_1 = point_a\n\tx_2, y_2 = point_b\n\tdist = math.sqrt((x_1 - x_2)**2 + (y_1 - y_2)**2)\n\treturn dist\n\ndef tri_area(l_a, l_b, l_c): #Heron's formula\n\tp = (l_a + l_b + l_c) / 2.0\n\tarea = math.sqrt(p * (p-l_a) * (p-l_b) * (p-l_c))\n\treturn area\n\ndef find_center(p_a, p_b, p_c): #find the coordinates of the center of the polygon/circumcircle\n\tx1, y1 = p_a\n\tx2, y2 = p_b\n\tx3, y3 = p_c\n\n\tx0 = ((y2-y1)*(y3*y3-y1*y1+x3*x3-x1*x1)-(y3-y1)*(y2*y2-y1*y1+x2*x2-x1*x1))/(2.0*((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)))\n\ty0 = ((x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1)-(x3-x1)*(x2*x2-x1*x1+y2*y2-y1*y1))/(2.0*((y3-y1)*(x2-x1)-(y2-y1)*(x3-x1)))\n\tr = math.sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))\n\n\treturn [x0, y0, r]\n\ndef center_angle(center, p_a, p_b):\n\tx0, y0 = center\n\tx1, y1 = p_a\n\tx2, y2 = p_b\n\n\ta = distance(p_a, p_b)\n\tb = distance(center, p_a)\n\tc = distance(center, p_b)\n\tcos_X = 1.0 * (b*b + c*c - a*a) / (2*b*c)\n\tang = math.acos(cos_X)\n\treturn ang\n\ndef gcd(num1, num2):\n\terr = 0.000001\n\twhile abs(num1 - num2) >= err:\n\t\tif num1 > num2 + err:\n\t\t\tnum1 -= num2\n\t\telif num2 > num1 + err:\n\t\t\tnum2 -= num1\n\treturn max(num1, num2)\n\n\nif __name__ == '__main__':\n\n\terr = 0.000001\n\n\tP_1 = raw_input()\n\tP_2 = raw_input()\n\tP_3 = raw_input()\n\n\tp1 = [float(x) for x in P_1.split(' ')]\n\tp2 = [float(x) for x in P_2.split(' ')]\n\tp3 = [float(x) for x in P_3.split(' ')]\n\n\t#c = find_center(p1, p2, p3)[0:2]\n\tr = find_center(p1, p2, p3)[2]\n\tdis_list = [distance(p1, p2), distance(p2, p3), distance(p3, p1)]\n\tl_min = min(dis_list)\n\tl_max = max(dis_list)\n\tl_mid = 0\n\tfor x in dis_list:\n\t\tif not x == l_min and not x == l_max:\n\t\t\tl_mid = x\n\n\tcos_ang_min = (r*r + r*r - l_min*l_min) / (2.0 * r * r)\n\tcos_ang_max = (r*r + r*r - l_max*l_max) / (2.0 * r * r)\n\tcos_ang_mid = (r*r + r*r - l_mid*l_mid) / (2.0 * r * r)\n\tang_min = math.acos(cos_ang_min)\n\tang_max = math.acos(cos_ang_max)\n\tang_mid = math.acos(cos_ang_mid)\n\t\n\ta0 = ang_min\n\tif ang_max - ang_min < err:\n\t\ta1 = a0\n\telse:\n\t\ta1 = ang_max - ang_min\n\ta2 = 2.0 * math.pi - a1 - a0\n\ta3 = ang_max\n\n\tg1 = gcd(gcd(a2, a0), a1)\n\tg2 = gcd(gcd(a3, a0), a1)\n\n\tn1 = 2.0 * math.pi / g1\n\tn2 = 2.0 * math.pi / g2\n\n\tif math.fmod(n2,1) < 0.01 and n2 < n1:\n\t\tn = n2\n\t\tg = g2\n\telse:\n\t\tn = n1\n\t\tg = g1\n\n\t# i = dis_list.index(min(dis_list))\n\t# p_c1 = eval('p'+str(i+1))\n\t# p_c2 = eval('p'+str((i+1)%3 + 1))\n\n\t#half_unit_ang = math.asin((s/2.0)/r)\n\t#unit_area = tri_area(r, r, s)\n\t#n = round(2.0 * math.pi / center_angle(c, p_c1, p_c2))\n\n\t#total_area = n * unit_area\n\ttotal_area = 0.5*n*r*r*math.sin(g)\n\n\tprint total_area\n\n\n\n\n\n\n"}, {"source_code": "import math\nimport cmath\nimport sys\n\nclass Segment:\n def __init__(self,bgn,end):\n self.bgn = bgn\n self.end = end\n\n\nclass Circle:\n def __init__(self,p,r):\n self.p = p\n self.r = r\n\n\ndef cross(a,b):\n return (a.conjugate()*b).imag;\n\n\ndef rotate(p):\n return complex(-p.imag,p.real)\n\n\ndef calcCircle(a,b,c):\n mid1 = (a+b)/2.0;\n mid2 = (a+c)/2.0;\n s1 = Segment(mid1,mid1+rotate(b-a))\n s2 = Segment(mid2,mid2+rotate(c-a))\n center = calcIntersect(s1,s2)\n return Circle(center,abs(a-center))\n\n\ndef calcIntersect(a,b):\n d1 = (a.end-a.bgn)\n d2 = (b.end-b.bgn)\n return a.bgn + d1*cross(b.bgn-a.bgn,d2)/cross(d1,d2);\n\n\ndef read():\n v = map(float,sys.stdin.read().split())\n return complex(v[0],v[1]),complex(v[2],v[3]),complex(v[4],v[5])\n\n\ndef isInteger(n):\n return abs(n-round(n))<1e-3\n\n\ndef work((a,b,c)):\n b,c = c,b\n circle = calcCircle(a,b,c)\n\n angle1 = cmath.phase((a-circle.p)/(b-circle.p))\n angle2 = cmath.phase((b-circle.p)/(c-circle.p))\n angle3 = cmath.phase((c-circle.p)/(a-circle.p))\n\n angle1,angle2,angle3 = sorted((angle1,angle2,angle3))\n\n if angle1<0 and angle2<0:\n angle3 -= cmath.pi*2\n angle1 *= -1\n angle2 *= -1\n angle3 *= -1\n else:\n angle1 += cmath.pi*2\n\n angle1,angle2,angle3 = sorted((angle1,angle2,angle3))\n \n for i in range(1,101):\n theta = angle1/i\n if isInteger(angle2/theta) and isInteger(angle3/theta):\n print \"%.8lf\"%(math.sin(theta)*circle.r*circle.r/2*(2*math.pi/theta))\n break\n\n \nwork(read())\n\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nimport math\n#\u8f93\u5165\u4e09\u4e2a\u5750\u6807\nroom=[]\ni=0\nwhile i<3:\n\ti=i+1\n\troom.append(list(map(float,input().split())))\n#\u627e\u51fa\u5782\u76f4\u5e73\u5206\u7ebf\nk1=(room[0][1]-room[1][1])/(room[0][0]-room[1][0]+0.0000000001)\nk1=-(1/k1)\nmid1=[(room[0][0]+room[1][0])/2,(room[0][1]+room[1][1])/2]\nb1=mid1[1]-mid1[0]*k1\nk2=(room[0][1]-room[2][1])/(room[0][0]-room[2][0]+0.0000000001)\nk2=-(1/k2)\nmid2=[(room[0][0]+room[2][0])/2,(room[0][1]+room[2][1])/2]\nb2=mid2[1]-mid2[0]*k2\n#\u627e\u51fa\u5706\u5fc3\nx=(b2-b1)/(k1-k2)\ny=k1*x+b1\n#\u7b97\u51fa\u957f\u5ea6\na=math.sqrt(pow((room[0][1]-room[1][1]),2)+pow((room[0][0]-room[1][0]),2))\nb=math.sqrt(pow((room[0][1]-room[2][1]),2)+pow((room[0][0]-room[2][0]),2))\nr=math.sqrt(pow((y-room[1][1]),2)+pow((x-room[1][0]),2))\n#\u7b97\u51fa\u89d2\u5ea6\u7684cos\u503c\ncos1=(2*r*r-a*a)/(2*r*r)\ncos2=(2*r*r-b*b)/(2*r*r)\ncos1=float('%.4f'%cos1)\ncos2=float('%.4f'%cos2)\n#\u7b97\u51fa\u4e0e2pi\u7684\u6bd4\u4f8b\na=2*math.pi/math.acos(cos1)\nb=2*math.pi/math.acos(cos2)\na=1/a\nb=1/b\ni=1\nwhile i<101:\n\tm=a*i\n\tif abs(m-int(m))<0.009 or abs(m-int(m)-1)<0.009:\n\t\tbreak\n\ti=i+1\nj=1\nwhile j<101:\n\tm=b*j\n\tif abs(m-int(m))<0.01 or abs(m-int(m)-1)<0.01:\n\t\tbreak\n\tj=j+1\n#print(i,j)\n#\u7b97\u51fa\u6700\u5927\u516c\u7ea6\u6570\ndef f(a,b):\n\tif a<b:\n\t\tc=a\n\t\ta=b\n\t\tb=c\n\tif a%b==0:\n\t\treturn b\n\telse:\n\t\treturn f(a%b,b)\nc=i*j/f(i,j)\nif c>100:\n\tc=100\n#\u7b97\u51fa\u9762\u79ef\ns=c*r*r*math.sin(2*math.pi/c)/2\n#\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\u8f93\u51fa\nprint('%.6f'%s)"}, {"source_code": "from math import sin, acos, degrees, radians, pi, modf\n\nif __name__ == \"__main__\": \n i1 = raw_input()\n i2 = raw_input()\n i3 = raw_input()\n \n p1 = i1.split(' ')\n p2 = i2.split(' ')\n p3 = i3.split(' ')\n \n x1 = float(p1[0])\n y1 = float(p1[1])\n x2 = float(p2[0])\n y2 = float(p2[1])\n x3 = float(p3[0])\n y3 = float(p3[1]) \n \n x0 = ((y1-y2)*(x1**2+y1**2-x3**2-y3**2)-(y1-y3)*(x1**2+y1**2-x2**2-y2**2)) / 2 / ( (y1-y3)*(x2-x1) - (y1-y2)*(x3-x1) )\n y0 = ((x3-x1)*(x2**2+y2**2-x1**2-y1**2)-(x2-x1)*(x3**2+y3**2-x1**2-y1**2)) / 2 / ( (x2-x1)*(y1-y3) - (y1-y2)*(x3-x1) )\n \n #R = (abs(x1-x0)**2 + abs(y1-y0)**2) ** 0.5\n \n ptlist = []\n ptlist.append({'x':float(p1[0]), 'y':float(p1[1])})\n ptlist.append({'x':float(p2[0]), 'y':float(p2[1])})\n ptlist.append({'x':float(p3[0]), 'y':float(p3[1])})\n\n linelist = []\n linelist.append({'pt1':ptlist[0], 'pt2':ptlist[1], 'long':0.0, 'arc':0.0, 'angle':0.0})\n linelist.append({'pt1':ptlist[0], 'pt2':ptlist[2], 'long':0.0, 'arc':0.0, 'angle':0.0})\n linelist.append({'pt1':ptlist[1], 'pt2':ptlist[2], 'long':0.0, 'arc':0.0, 'angle':0.0})\n \n for l in linelist:\n l['long'] = (\n abs(l['pt1']['x'] - l['pt2']['x'])**2\n +abs(l['pt1']['y'] - l['pt2']['y'])**2\n ) **0.5\n \n a = linelist[0]['long']\n b = linelist[1]['long']\n c = linelist[2]['long']\n \n p = (a+b+c) / 2.0\n S = (p * (p-a) * (p-b) * (p-c)) ** 0.5\n R = (a*b*c)/(4.0*S)\n \n for l in linelist:\n l['arc'] = acos((R*R + R*R - l['long']*l['long'])/(2.0*R*R))\n l['angle'] = round(degrees(l['arc']),5)\n\n mina = min(linelist[0]['angle'], linelist[1]['angle'], linelist[2]['angle'])\n maxa = max(linelist[0]['angle'], linelist[1]['angle'], linelist[2]['angle'])\n \n a1 = linelist[0]['angle']\n a2 = linelist[1]['angle']\n a3 = linelist[2]['angle']\n \n #print a1\n\n if a1+a2+a3 < 357.0:\n temp = a1\n a1 = mina\n a2 = maxa - mina\n a3 = 360.0 - maxa \n \n mina = min(a1,a2,a3)\n \n angle = 0.001\n x = 3.5\n while x < mina+0.001:\n aa1 = a1 / x\n aa2 = a2 / x\n aa3 = a3 / x\n \n aa1 = modf(aa1)[0]\n aa2 = modf(aa2)[0]\n aa3 = modf(aa3)[0]\n \n if aa1 < 0.01 and aa2 < 0.01 and aa3 < 0.01:\n angle = x\n \n x += 0.001\n \n if angle > mina*0.99:\n angle = mina\n \n angle = round(angle, 5)\n \n if modf(angle)[0] > 0.98:\n angle = round(angle)\n \n polyarea = (round(360.0/angle)/2) * (R**2) * sin(radians(angle))\n #print mina\n #print angle\n print polyarea \n "}, {"source_code": "import math\nfrom sys import stdin\n\n\ndef get_length(p1, p2):\n return math.sqrt(math.pow(p1[0] - p2[0], 2) + math.pow(p1[1] - p2[1], 2))\n\n\ndef get_angle(p1, p2, p3):\n return math.acos((\n math.pow(get_length(p1, p2), 2) +\n math.pow(get_length(p1, p3), 2) -\n math.pow(get_length(p2, p3), 2)\n )\n /\n (2 * get_length(p1, p2) * get_length(p1, p3))\n )\n\n\ndef get_radius(p1, p2, p3):\n a, b, c = get_length(p1, p2), get_length(p2, p3), get_length(p1, p3)\n s = (a + b + c) / 2\n area = math.sqrt(s * (s - a) * (s - b) * (s - c))\n return a * b * c / 4 / area\n\n\ndef gcd(x, y):\n while y > 0.00000000001:\n x, y = y, x % y\n return x\n\n\ndef main():\n x1, y1 = map(float, stdin.readline().strip().split())\n p1 = (x1, y1)\n x2, y2 = map(float, stdin.readline().strip().split())\n p2 = (x2, y2)\n x3, y3 = map(float, stdin.readline().strip().split())\n p3 = (x3, y3)\n A = get_angle(p1, p2, p3)\n B = get_angle(p2, p1, p3)\n C = get_angle(p3, p1, p2)\n radius = get_radius(p1, p2, p3)\n n = math.pi / gcd(gcd(A, B), C)\n area = n / 2 * math.pow(radius, 2) * math.sin(2 * math.pi / n)\n print(area)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import math\n\ndef Phi(p):\n delta_y = p[1]-Cy\n delta_x = p[0]-Cx\n \n if (delta_x >= 0):\n if (delta_y >= 0):\n return math.asin(delta_y/r)\n else:\n return math.asin(delta_y/r) + 2*math.pi\n else:\n return math.pi - math.asin(delta_y/r) \n \ndef isPhiinList(phi,philist):\n for n in philist:\n if (math.fabs(n-phi) < 1E-7):\n return 1\n return 0 \n\nn0 = map(float, raw_input().split())\nn1 = map(float, raw_input().split())\nn2 = map(float, raw_input().split())\n\nu = (n0[0]**2+n0[1]**2 - n1[0]**2 - n1[1]**2)/2\nv = (n0[0]**2+n0[1]**2 - n2[0]**2 - n2[1]**2)/2\n\nCx = (u*(n0[1]-n2[1]) - v*(n0[1]-n1[1])) / ((n0[1]-n2[1])*(n0[0]-n1[0]) - (n0[1]-n1[1])*(n0[0]-n2[0]))\n\nif (n0[1] - n1[1] != 0):\n Cy = (u - (n0[0]-n1[0])*Cx) / (n0[1]-n1[1])\nelse:\n Cy = (v - (n0[0]-n2[0])*Cx) / (n0[1]-n2[1])\n \nr = math.sqrt((n0[0]-Cx)**2 + (n0[1]-Cy)**2)\n\nphi0 = Phi(n0)\nphi1 = Phi(n1)\nphi2 = Phi(n2)\n\nfor columns in range(3,101):\n phi_columns = []\n delta_phi = 2*math.pi/columns\n for i in range(1, columns):\n phi = phi0 + i*delta_phi\n if (phi >= 2*math.pi):\n phi -= 2*math.pi\n phi_columns.append(phi) \n if (isPhiinList(phi1, phi_columns) == 1):\n break\n \nA = columns*r**2/2*math.sin(2*math.pi/columns)\nprint A\n\n"}, {"source_code": "one = map(float, raw_input().split())\ntwo = map(float, raw_input().split())\nthree = map(float, raw_input().split())\nv1 = [x-y for x,y in zip(one, two)]\nv2 = [x-y for x,y in zip(one, three)]\nprint abs(v1[0] * v2[1] - v1[1] * v2[0])"}, {"source_code": "\n'''\nCreated on Apr 23, 2017\n\n@author: Maiko\n'''\n#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport math\nimport fractions\n\ndef solve():\n rawin = []\n for i in range(3):\n a = input().split()\n rawin.append( [ float(a[0]), float(a[1]) ] )\n \n # length of three edges\n a = distance(rawin[0], rawin[1])\n b = distance(rawin[1], rawin[2])\n c = distance(rawin[0], rawin[2])\n p = (a + b + c) / 2\n # square of the triangle \n S = math.sqrt(p * (p-a) * (p-b) * (p-c))\n \n # Radius of the Circumscribed circle\n R = (a*b*c) / (4*S)\n \n #Law of cosines\n angle = []\n angle.append(2 * math.asin(a / (2 * R)))\n angle.append(2 * math.asin(b / (2 * R)))\n angle.append(2*math.pi - angle[0] - angle[1])\n # when least edge the \n A = fgcd(angle[0], fgcd(angle[1], angle[2]))\n # number of edge of the polygon\n N = int(2 * math.pi / A)\n S_an = R * R * math.sin(A) * N / 2\n print(\"%.8lf\\n\" % S_an)\n \n \ndef distance(a, b):\n return math.sqrt(math.pow(a[0]-b[0], 2)+math.pow(a[1]-b[1], 2))\n\ndef feq(a, b):\n return math.fabs(a - b) < 0.01\n\ndef fgcd(a, b):\n if feq(a, 0):\n return b\n if feq(b, 0):\n return a\n return fgcd(b, math.fmod(a, b))\n \nif __name__ == '__main__':\n solve()"}, {"source_code": "from math import *\n\nclass Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n def __repr__(self):\n return '%f %f'%(self.x, self.y)\n\n# y = ax + b\nclass Line:\n def __init__(self, a, b):\n self.a = a\n self.b = b\n def __repr__(self):\n return '(a %f b %f)'%(self.a, self.b)\n\n\ndef ccw(p1, p2, p3):\n d = (p2.x-p1.x)*(p3.y-p1.y) - (p2.y-p1.y)*(p3.x-p1.x)\n if fabs(d) < 0.001:\n return 0\n elif d > 0:\n return 1\n elif d < 0:\n return -1\n\n\ndef perpline(p1, p2):\n mp = Point((p1.x+p2.x)/2, (p1.y+p2.y)/2)\n a = (p2.y-p1.y)/(p2.x-p1.x)\n b = p1.y-p1.x*a\n if a == 0:\n return Line(inf, mp.x)\n else:\n return Line(-1/a, mp.x/a+mp.y)\n\n\ndef crosspoint(l1, l2):\n if l1.a == inf:\n x = l1.b\n y = l2.a * x + l2.b\n if l2.a == inf:\n x = l2.b\n y = l1.a * x + l1.b\n else:\n x = (l1.b - l2.b)/(l2.a - l1.a)\n y = l1.a * x + l1.b\n return(Point(x,y))\n\n\ndef dist(p1,p2):\n return ((p1.x-p2.x)**2 + (p1.y-p2.y)**2)**0.5\n pass\n\np = []\nfor i in range(3):\n x, y = map(float, input().split())\n p.append(Point(x, y))\n\nmp = []\nfor i in range(3):\n mp.append(Point((p[i].x + p[(i+1)%3].x)/2, (p[i].y + p[(i+1)%3].y)/2))\n\ncp = crosspoint(perpline(p[0], p[1]), perpline(p[1], p[2]))\n\n\na, b, c = [(p[i].x - cp.x, p[i].y - cp.y) for i in range(3)]\naa, ba, ca = [round(degrees(acos((aa[0]*bb[0] + aa[1]*bb[1])/(hypot(aa[0],aa[1])*hypot(bb[0], bb[1]))))) for aa, bb in [(a,b), (b,c), (c,a)]]\nprint(aa,ba,ca)\nangle = gcd(aa,gcd(ba,gcd(ca,360)))\nprint(angle)\nprint(hypot(a[0], a[1])**2*sin(radians(angle))*0.5*360/angle)"}, {"source_code": "import math\ndx=10**(-6)\ndef equal(x,y):\n if(abs(x-y)<=dx):\n return 1\n return 0\nl=input().split()\nx1=float(l[0])\ny1=float(l[1])\nl=input().split()\nx2=float(l[0])\ny2=float(l[1])\nl=input().split()\nx3=float(l[0])\ny3=float(l[1])\nd1=math.sqrt((x1-x2)*(x1-x2)+(y1-y2)**2)\nd2=math.sqrt((x1-x3)*(x1-x3)+(y1-y3)**2)\nd3=math.sqrt((x3-x2)*(x3-x2)+(y3-y2)**2)\nans=10**18\nfor n in range(105):\n for a in range(1,n):\n for b in range(1,n):\n if(a+b>=n):\n continue\n c=n-(a+b)\n theta=360/n\n R=d1/(2*math.sin(math.radians(theta*a/2)))\n z=d2/(2*math.sin(math.radians(theta*b/2)))\n y=d3/(2*math.sin(math.radians(theta*c/2)))\n if(equal(R,y) and equal(y,z)):\n ans=min(ans,(n*R*R*math.sin(math.radians(theta)))/2)\nprint(ans)"}, {"source_code": "import math\n\ndef equiangular(r, n):\n\t\"\"\"\n\tr: radius\n\tn: sides\n\t\"\"\"\n\treturn n * (1/2) * (r**2) * math.sin(2*math.pi/n)\n\ndef triangle(a, b, c):\n\t\"\"\"\n\ta, b, c: tuple\n\t\"\"\"\n\treturn math.fabs((a[0]*b[1] - a[1]*b[0] + b[0]*c[1] - b[1]*c[0] + c[0]*a[1] - c[1]*a[0]) / 2)\n\ndef circumcenter(a, b, c):\n\t\"\"\"\n\ta, b, c: tuple\n\t\"\"\"\n\tX = (1/2) * ((b[1]-c[1])*((a[0]**2+a[1]**2)-(b[0]**2+b[1]**2))-(a[1]-b[1])*((b[0]**2+b[1]**2)-(c[0]**2+c[1]**2))) / ((a[0]-b[0])*(b[1]-c[1])-(a[1]-b[1])*(b[0]-c[0]))\n\tY = (1/2) * ((b[0]-c[0])*((a[0]**2+a[1]**2)-(b[0]**2+b[1]**2))-(a[0]-b[0])*((b[0]**2+b[1]**2)-(c[0]**2+c[1]**2))) / ((a[1]-b[1])*(b[0]-c[0])-(a[0]-b[0])*(b[1]-c[1]))\n\treturn (X, Y)\n\ndef distance(x, y):\n\t\"\"\"\n\tx, y: tuple\n\t\"\"\"\n\treturn math.sqrt((x[0]-y[0])**2 + (x[1]-y[1])**2)\n\nA = input().split()\nB = input().split()\nC = input().split()\n\na = ()\nb = ()\nc = ()\n\nfor i in range(2):\n\ta = a + (float(A[i]),)\n\tb = b + (float(B[i]),)\n\tc = c + (float(C[i]),)\n\n# print(a)\n# print(b)\n# print(c)\n# a = (0, 0)\n# b = (1, 1)\n# c = (0, 1)\no = circumcenter(a, b, c)\nr = distance(a,o)\n\n# print(equiangular(math.sqrt(2)/2, 3))\n# print(triangle(a, b, c))\n# print(r)\n\nE1 = int(triangle(a,b,o) * 10**6)\nE2 = int(triangle(a,c,o) * 10**6)\nE3 = int(triangle(b,c,o) * 10**6)\n\ngoal = math.gcd(math.gcd(E1, E2), math.gcd(E2, E3))\n\n# print(\"Goal:\", goal)\n# \n# print(\"Try:\", int(equiangular(r, 3) * 10**6) / 3)\n# print(\"Try:\", int(equiangular(r, 4) * 10**6) / 4)\n# print(\"Try:\", int(equiangular(r, 5) * 10**6) / 5)\n# print(\"Try:\", int(equiangular(r, 6) * 10**6) / 6)\n\nn = 3\ntemp = int(equiangular(r, n) * 10**6) / n\nwhile math.fabs(goal - temp) > 1:\n\tn += 1\n\ttemp = int(equiangular(r, n) * 10**6) / n\n\nprint(n)"}, {"source_code": "from math import degrees, acos, sin, radians\nfrom fractions import gcd\n\nx0, y0 = map(float, raw_input().split())\nx1, y1 = map(float, raw_input().split())\nx2, y2 = map(float, raw_input().split())\n\nc2 = (x1-x0)**2+(y1-y0)**2\na2 = (x1-x2)**2+(y1-y2)**2\nb2 = (x0-x2)**2+(y0-y2)**2\nR2 = 0\n\ndef alpha(a2, b2, c2):\n cosA2 = (b2+c2-a2)**2/(4.0*b2*c2)\n sinA = (1-cosA2)**0.5\n global R2\n R2 = a2/(2.0*(1-cosA2))\n return 2*degrees(acos(sinA))\n\ndegree = gcd(gcd(alpha(a2, b2, c2), alpha(b2, c2, a2)), alpha(c2, a2, b2))\narea = int(360/degree + 10**-6)*0.5*sin(radians(degree))*R2\nprint area\n"}, {"source_code": "def sqrdist(pa, pb):\n return (pa[0]-pb[0])**2+(pa[1]-pb[1])**2\n\ndef main():\n p0 = map(float, raw_input().split())\n p1 = map(float, raw_input().split())\n p2 = map(float, raw_input().split())\n d0 = sqrdist(p0, p1)\n d1 = sqrdist(p1, p2)\n d2 = sqrdist(p2, p0)\n d = sorted([d0, d1, d2])\n if d[2]-d[0] > 1e-4:\n print '%.8f' % d[0]\n else:\n print '%.8f' % (abs((p1[0]-p0[0])*(p2[1]-p0[1])-(p2[0]-p0[0])*(p1[1]-p0[1]))/2)\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "from math import atan2, acos, sin\n\nPI = acos(-1)\nPI2 = PI+PI\n\ndef pos(x):\n while x < 0:\n x += PI2\n return x\n\ndef main():\n p0 = map(float, raw_input().split())\n p1 = map(float, raw_input().split())\n p2 = map(float, raw_input().split())\n c1 = p0[0]**2+p0[1]**2-p1[0]**2-p1[1]**2\n a1 = 2*(p0[0]-p1[0])\n b1 = 2*(p0[1]-p1[1])\n c2 = p0[0]**2+p0[1]**2-p2[0]**2-p2[1]**2\n a2 = 2*(p0[0]-p2[0])\n b2 = 2*(p0[1]-p2[1])\n x = (c1*b2-c2*b1)/(a1*b2-a2*b1)\n y = (c1*a2-c2*a1)/(b1*a2-b2*a1)\n p0 = (p0[0]-x, p0[1]-y)\n p1 = (p1[0]-x, p1[1]-y)\n p2 = (p2[0]-x, p2[1]-y)\n a = [atan2(p0[1], p0[0]), atan2(p1[1], p1[0]), atan2(p2[1], p2[0])]\n '''\n a = map(pos, a)\n a.sort()\n a = [a[1]-a[0], a[2]-a[1], a[0]-a[2]]\n a = map(lambda x: x if x < PI else x-PI, a)\n print a\n '''\n for i in range(3, 101):\n flag = True\n for j in a:\n if abs(sin(i*j)) > 1e-4:\n flag = False\n break\n if flag:\n break\n print '%.8f' % (i*(p0[0]*p0[0]+p0[1]*p0[1])*sin(PI2/i)/2)\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "from math import *\n\n\ndef cline((x1, y1), (x2, y2)):\n a = x2-x1\n b = y2-y1\n c = -a*(x1+x2)/2.0 - b*(y1+y2)/2.0\n d = sqrt(a**2 + b**2)\n return a/d, b/d, c/d\n\ndef intersect((a1, b1, c1), (a2, b2, c2)):\n d = a1*b2-b1*a2\n return (b1*c2-b2*c1)/d, (a2*c1-a1*c2)/d\n\ndef rot((x, y), (cx, cy), a):\n x, y = x-cx, y-cy\n return (cx + x*cos(a) - y*sin(a), cy + x*sin(a) + y*cos(a))\n\ndef pt_in((x, y), pts):\n return any([abs(x-a)+abs(y-b) < 1.0e-7 for (a, b) in pts])\n\ndef area(pts):\n return abs(sum([(x1+x2)*(y2-y1)/2.0 for (x1, y1), (x2, y2) in zip(pts, pts[1:] + [pts[0]])]))\n\n\np1 = map(float, raw_input().split())\np2 = map(float, raw_input().split())\np3 = map(float, raw_input().split())\n\npc = intersect(cline(p1, p2), cline(p3, p2))\n\nfor n in xrange(3, 101):\n pts = [rot(p1, pc, i*2.0*pi/n) for i in xrange(n)]\n if pt_in(p1, pts) and pt_in(p2, pts) and pt_in(p3, pts):\n print area(pts)\n break\n"}, {"source_code": "#coding=utf-8\n\nfrom math import *\ndef read_x_y():\n return map(float, raw_input().split())\n\nx = []\ny = []\n\nfor i in range(3):\n a,b=read_x_y()\n x.append(a)\n y.append(b)\n#print x,y\n\nl=[sqrt((x[i]-x[i-1])**2+(y[i]-y[i-1])**2) for i in range(3)]\nt=[acos((l[i-2]**2+l[i-1]**2-l[i]**2)/2.0/l[i-2]/l[i-1]) for i in range(3)]\n\n#print \"t:\",t\n\nR=l[0]/2./sin(t[0])\n\n#print \"R:\",R\n\ndef gcd_float(a,b):\n if b < 0.00000001:\n return a\n return gcd_float(b, fmod(a,b))\n\ndef lcm_float(a,b):\n return a*b/gcd_float(a,b)\n\na = reduce(gcd_float, t)\nS = R*R*sin(a)*cos(a)*pi/a\nprint \"%.6f\"%S"}, {"source_code": "# -coding: utf-8 -*-\nimport math\nclass Solution():\n def ancientBerlandCircus(self,x1,y1,x2,y2,x3,y3):\n d1 = math.sqrt(pow(x1-x2,2)+pow(y1-y2,2))\n d2 = math.sqrt(pow(x1-x3,2)+pow(y1-y3,2))\n d3 = math.sqrt(pow(x2-x3,2)+pow(y2-y3,2))\n p = (d1+d2+d3)/2\n s = math.sqrt(p*(p-d1)*(p-d2)*(p-d3))\n r = d1*d2*d3/4/s\n fal1 = math.acos(1-d1*d1/(2*r*r))\n fal3 = math.acos(1-d3*d3/(2*r*r))\n fal2 = 2*math.pi-fal1-fal3\n angle = self.fgcd(fal3,self.fgcd(fal1,fal2))\n mins = r*r/2*(2*math.pi/angle)*math.sin(angle)\n print '%.06f' % mins\n\n def fgcd(self,x,y):\n if x<1e-4:\n return y\n return self.fgcd(math.fmod(y,x),x)\n\nx1,y1 = raw_input().split()\nx2,y2 = raw_input().split()\nx3,y3 = raw_input().split()\nx1 = round(float(x1), 6)\ny1 = round(float(y1), 6)\nx2 = round(float(x2), 6)\ny2 = round(float(y2), 6)\nx3 = round(float(x3), 6)\ny3 = round(float(y3), 6)\ns = Solution()\ns.ancientBerlandCircus(x1,y1,x2,y2,x3,y3)"}, {"source_code": "from math import pi,sin,cos,sqrt\np = [map(float,raw_input().split()),map(float,raw_input().split()),map(float,raw_input().split())]\nfor n in range(3,100):\n poly = [[cos(2.0*pi*i/n),sin(2.0*pi*i/n)] for i in range(n)] \n area = n*sin(pi/n)*cos(pi/n)\n p1 = poly[0]\n for p2 in poly[1:]: \n a = [p[1][0]-p[0][0],p[1][1]-p[0][1]]\n b = [p2[0]-p1[0],p2[1]-p1[1]]\n al = (a[0]*a[0]+a[1]*a[1]) \n s = (b[0]*a[1]-b[1]*a[0])/al\n c = (a[0]*b[0]+a[1]*b[1])/al \n t = map(lambda x: [x[0]-p[0][0],x[1]-p[0][1]],p) \n t = map(lambda x: [x[0]*c+x[1]*s,-x[0]*s+x[1]*c],t) \n t = map(lambda x: [x[0]+p1[0],x[1]+p1[1]],t)\n for x in poly[2:]:\n if abs(x[0]-t[2][0]) < 0.000000001 and abs(x[1]-t[2][1]) < 0.000000001:\n print area/al\n exit()\n \n"}, {"source_code": "from math import acos\nfrom math import pi\nfrom math import sin\nfrom math import cos\ndef angle(a, b, c):\n cs = (a**2+b**2-c**2)/(2*a*b)\n if cs>1: cs = 1\n if cs<-1: cs = -1\n return acos(cs)\ndef length(xs, ys):\n return ((xs[0]-xs[1]) ** 2 + (ys[0]-ys[1]) ** 2) ** 0.5\nxs=[]\nys=[]\nfor i in range(0, 3):\n x, y = [float(x) for x in input().split()]\n xs.append(x)\n ys.append(y)\nabc = [length((xs[i],xs[(i+1)%3]), (ys[i],ys[(i+1)%3])) for i in range(3)]\nangles = [angle(abc[i], abc[(i+1)%3], abc[(i+2)%3]) for i in range(3)]\nfor i in range(3, 101):\n est_angle = pi/i\n flag = True\n for angle in angles:\n d = round(angle/est_angle)\n if (d==0 or abs(est_angle*d-angle)>0.00000001):\n flag = False\n break\n if (flag):\n break\nprint(i*sin(2*pi/i)*abc[2]**2/sin(angles[0])**2/8)"}, {"source_code": "import math\n\narray, newarray = [], [0]*3\n\nfor x in range(3):\n n = input().split()\n m = list(map(float, n))\n array.append(m)\n\ndef magn_sq(point):\n return (point[0]**2 + point[1]**2)\n \ndef dist_sq(point1, point2):\n return magn_sq([point1[0] - point2[0], point1[1] - point2[1]])\n\ndef circumcenter(point1, point2, point3):\n point_1 = [point1[0] - point3[0], point1[1] - point3[1]]\n point_2 = [point2[0] - point3[0], point2[1] - point3[1]]\n const = 2*(point_1[0]*point_2[1] - point_1[1]*point_2[0])\n xcoord = (point_2[1]*magn_sq(point_1) - point_1[1]*(magn_sq(point_2)))/const\n ycoord = (point_1[0]*magn_sq(point_2) - point_2[0]*(magn_sq(point_1)))/const\n return [xcoord, ycoord]\n\ncenter = circumcenter(array[0], array[1], array[2])\n\n#center is way off\n\nfor x in array:\n x[0] = x[0] - center[0]\n x[1] = x[1] - center[1]\n\nradius = math.sqrt(magn_sq(array[0]))\n\nfor x in range(3):\n newarray[x] = math.sqrt(dist_sq(array[x], array[(x+1)%3]))\n\ndef distToAngle(p):\n r = math.pi/(math.asin(p/(2*radius)))\n return int(round(r, 0))\n \nnewarray = list(map(distToAngle, newarray))\n\ndef lcm(a, b):\n for i in range(1, b):\n if a*i%b == 0:\n return a*i\n return a*b\n\nnumsides = lcm(lcm(newarray[0],newarray[1]),newarray[2])\n\narea = 0.5*numsides*(radius**2)*math.sin(2*math.pi/numsides)\n\nprint(area)"}, {"source_code": "from math import sqrt, acos, pi, sin\n\nclass Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n def dot(self, other):\n return self.x * other.x + self.y * other.y\n\n def __add__(self, other):\n return Point(self.x + other.x, self.y + other.y)\n\n def __sub__(self, other):\n return Point(self.x - other.x, self.y - other.y)\n\n def __mul__(self, other):\n # Multiply by number\n return Point(self.x * other, self.y * other)\n\n def __str__(self):\n return \"{%.2f, %.2f}\" % (self.x, self.y, )\n\n def __abs__(self):\n return sqrt(self.x ** 2 + self.y ** 2)\n\nclass Line:\n '''\n Build line from coefficients A, B, C of its equation \"Ax + By + C = 0\"\n '''\n def __init__(self, a, b, c):\n self.a = a\n self.b = b\n self.c = c\n\n '''\n Build line from two points on it\n '''\n @staticmethod\n def from_points(p1, p2):\n a = p1.y - p2.y\n b = p2.x - p1.x\n\n return Line._from_vector_and_point((a, b, ), p1)\n\n '''\n Build line from direction vector and point on the line\n '''\n @staticmethod\n def _from_vector_and_point((vx, vy, ), p):\n return Line(vx, vy, - vx * p.x - vy * p.y)\n\n '''\n Returns vertor perpendicular to the given one (s.t. their dot product is zero)\n '''\n @staticmethod\n def _perp_vector(a, b):\n if b == 0:\n return 0.0, 1.0\n else:\n b_new = - 1.0 * a / b\n\n return 1.0, b_new\n\n '''\n Returns a line perpendicular to the current one that goes through point `p`\n '''\n def get_perp(self, p):\n a_new, b_new = self._perp_vector(self.a, self.b)\n\n return Line._from_vector_and_point((a_new, b_new, ), p)\n\n '''\n Returns the determinant the following matrix:\n [ `a00` `a01` ]\n [ `a10` `a11` ]\n '''\n @staticmethod\n def _det(a00, a01, a10, a11):\n return a00 * a11 - a01 * a10\n\n '''\n Returns the intersection point between the current line and `other`\n '''\n def intersect_with(self, other):\n delta = self._det(self.a, self.b, other.a, other.b)\n\n if delta == 0.0:\n raise Exception(\"ne peresekayutsia\")\n\n x = - self._det(self.c, self.b, other.c, other.b) / delta\n y = - self._det(self.a, self.c, other.a, other.c) / delta\n\n return Point(x, y)\n\n def __str__(self):\n return \"%.2fx + %.2fy + %.2f == 0\" % (self.a, self.b, self.c, )\n\ndef midpoint(p1, p2):\n return (p1 + p2) * 0.5\n\n# Returns radian measure of angle AOB, measured clockwise\ndef angle(a, o, b):\n oa = a - o\n ob = b - o\n\n cos_phi = 1.0 * oa.dot(ob) / abs(oa) / abs(ob)\n\n if cos_phi < -1.0:\n cos_phi = -1.0\n elif cos_phi > 1.0:\n cos_phi = 1.0\n\n phi = acos(cos_phi)\n\n if oa.y * ob.x - oa.x * ob.y < 0: # `ob` is counterclockwise to `oa`\n return 2.0 * pi - phi\n else:\n return phi\n\n# Returns where it is possible for a `num-sides`-sided regular polygon to have some vertices at angles `alpha` and\n# `beta` between each other\ndef regular_polygon_possible(num_vertices, alpha, beta):\n if alpha > beta:\n alpha, beta = beta, alpha\n\n enc = 0\n\n for i in xrange(1, num_vertices):\n for phi in (alpha, beta, ):\n if abs(phi - i * 2.0 * pi / num_vertices) < 2.0 * pi / 200:\n enc += 1\n\n return enc == 2\n\ndef regular_polygon_area(r_big, num_vertices):\n return num_vertices / 2.0 * r_big ** 2 * sin(2.0 * pi / num_vertices)\n\nps = []\n\nfor i in [1, 2, 3]:\n x, y = map(float, raw_input().split(' '))\n\n ps.append(Point(x, y))\n\nl1 = Line.from_points(ps[0], ps[1])\nl2 = Line.from_points(ps[1], ps[2])\n\nm1 = midpoint(ps[0], ps[1])\nm2 = midpoint(ps[1], ps[2])\n\ncenter = l1.get_perp(m1).intersect_with(l2.get_perp(m2))\n\nalpha = angle(ps[0], center, ps[1])\nbeta = angle(ps[0], center, ps[2])\n\nnum_vertices = None\n\nfor i in xrange(3, 100 + 1):\n if regular_polygon_possible(i, alpha, beta):\n num_vertices = i\n break\n\nprint regular_polygon_area(abs(ps[0] - center), num_vertices)\n"}, {"source_code": "def sqrdist(pa, pb):\n return (pa[0]-pb[0])**2+(pa[1]-pb[1])**2\n\ndef main():\n p0 = map(float, raw_input().split())\n p1 = map(float, raw_input().split())\n p2 = map(float, raw_input().split())\n d0 = sqrdist(p0, p1)\n d1 = sqrdist(p1, p2)\n d2 = sqrdist(p2, p0)\n d = sorted([d0, d1, d2])\n if d[2]-d[0] > 1e-4:\n print '%.8f' % d[0]\n else:\n print '%.8f' % (abs((p1[0]-p0[0])*(p2[1]-p0[1])-(p2[0]-p0[0])*(p1[1]-p0[1]))/2)\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "from math import pi, sqrt, tan, acos\n \nx1, y1 = map(float, input().split(' '))\nx2, y2 = map(float, input().split(' '))\nx3, y3 = map(float, input().split(' '))\n\ns1 = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) \ns2 = sqrt((x1 - x3) ** 2 + (y1 - y3) ** 2)\ns3 = sqrt((x2 - x3) ** 2 + (y2 - y3) ** 2)\n\nangle1 = acos((s1 ** 2 + s2 ** 2 - s3 ** 2) / (2 * s1 * s2))\nangle2 = acos((s1 ** 2 + s3 ** 2 - s2 ** 2) / (2 * s1 * s3))\nangle3 = pi - angle1 - angle2\n\nif max(angle1, angle2, angle3) == angle1:\n N = round(2 * pi / (pi - angle1))\n S = s1 ** 2 * tan(angle1 / 2) / 4\n S *= N\nelif max(angle1, angle2, angle3) == angle2:\n N = round(2 * pi / (pi - angle2))\n S = s3 ** 2 * tan(angle2 / 2) / 4\n S *= N\nelse:\n N = round(2 * pi / (pi - angle3))\n S = s2 ** 2 * tan(angle3 / 2) / 4\n S *= N\n\nprint(f\"{S:.6f}\")"}, {"source_code": "from itertools import *\nfrom math import *\n\ndef mid_line((x1, y1), (x2, y2)):\n return x2-x1, y2-y1, (x1**2 - x2**2 + y1**2 - y2**2)/2.0\n\ndef intersect((a1, b1, c1), (a2, b2, c2)):\n d = a1*b2-b1*a2\n return (b1*c2-b2*c1)/d, (a2*c1-a1*c2)/d\n\ndef vect((x0, y0), (x1, y1)):\n return x1-x0, y1-y0\n\ndef dot((a1, b1), (a2, b2)):\n return a1*a2+b1*b2\n\ndef length(a):\n return sqrt(dot(a, a))\n\ndef angle(c, p1, p2):\n a, b = vect(p1, c), vect(p2, c)\n return acos(dot(a, b) / (length(a) * length(b) + 1.0e-7))\n\ndef gcd(a, b):\n while abs(b) > 1.0e-7:\n b, a = fmod(a, b), b\n return a\n\np = [map(float, raw_input().split()) for i in xrange(3)]\nc = intersect(mid_line(p[0], p[1]), mid_line(p[2], p[1]))\nt = reduce(gcd, [angle(c, p1, p2) for p1, p2 in combinations(p, 2)])\nR = length(vect(p[0], c))\nprint R**2*pi/t*sin(t)\n"}, {"source_code": "#coding=utf-8\n'''\n@brief\n\u6709\u4e00\u4e2a\u5706\u5f62\u7684\u6597\u517d\u573a\uff0c\u5706\u4e0a\u6709X\u4e2a\u6811\u6869\uff0c\u521a\u597d\u80fd\u7ec4\u6210\u4e00\u4e2a\u6b63\u591a\u8fb9\u5f62\u7684\u821e\u53f0\u3002\u4f46\u662f\uff0c\u67093\u4e2a\u6811\u6869\u4e0d\u89c1\u4e86\u3002 \n\u73b0\u5728\u7ed9\u4f60\u8fd93\u4e2a\u6811\u6869\u7684\u5750\u6807\uff0c\u8ba9\u4f60\u5224\u65ad\u8fd9\u4e2a\u821e\u53f0\u6700\u5c0f\u7684\u9762\u79ef\u3002\u4e0d\u4f1a\u5927\u4e8e100\u8fb9\u578b\u3002\n\u5373\uff1a\u7ed9\u5b9a\u4e09\u70b9\u6c42\u6700\u5c0f\u591a\u8fb9\u5f62\n\n@url\nhttp://codeforces.com/problemset/problem/1/C\n\n@solution\n1.\u6c42\u9762\u79ef\n\u6d77\u4f26\u516c\u5f0f: p = (a+b+c)/2 s=sqrt(p(p-a)(p-b)(p-c))\n2.\u6c42\u534a\u5f84\nr = abc/(4s)\n3.\u6c42\u4e09\u4e2a\u5706\u5fc3\u89d2\u7684\u6700\u5927\u516c\u7ea6\u6570(\u6ce8\u610f\u949d\u89d2\u7684\u60c5\u51b5\uff0c\u7b2c\u4e09\u4e2a\u5706\u5fc3\u89d2\u9700\u89812pi\u51cf\u53bb\u4e24\u4e2a\u8f83\u5c0f\u7684\u5706\u5fc3\u89d2\u83b7\u5f97)\n4.\u6c42\u51fa\u6700\u5c0f\u8fb9\u6570\n'''\nfrom math import sqrt,acos,pi,fabs,sin\n\ndef main():\n points = []\n sides = []\n radians = []\n for _ in range(3):\n point = [float(i) for i in raw_input().split()]\n points.append(tuple(point))\n\n for i in range(len(points)):\n for j in range(i+1, len(points)):\n sides.append(distance(points[i], points[j]))\n\n #\u8fb9\u957f\u4ece\u5c0f\u5230\u5927\n sides.sort()\n\n #print 'sides:%s' % sides\n\n p = sum(sides) / 2\n s = sqrt(p * (p - sides[0]) * (p - sides[1]) * (p - sides[2]))\n r = prod(sides) / (4 * s)\n\n for i in range(len(sides)):\n if i == len(sides)-1: \n radian = 2*pi - sum(radians)\n else:\n radian = acos(1 - sides[i]**2/(2*r**2))\n radians.append(radian)\n\n\n gcradian = fgcd(radians)\n min_area = pi*r*r*sin(gcradian)/gcradian\n print '%.7lf' % min_area\n\ndef distance(p, q):\n return sqrt((p[0]-q[0])**2 + (p[1]-q[1])**2)\n\ndef prod(iters):\n return reduce(lambda x,y:x*y, iters)\n\ndef feq(x, y):\n return True if fabs(x - y) < 1e-6 else False\n\ndef fgcd(iters):\n def _fgcd(x, y):\n if feq(x, 0):\n return y\n if feq(y, 0):\n return x\n return _fgcd(y, x%y)\n return reduce(_fgcd, iters)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "import math\n\neps = 0.000001\n\ndef gcd(a, b):\n while (math.fabs(a) > eps and math.fabs(b) > eps):\n if (a > b):\n a -= math.floor(a/b) * b\n else:\n b -= math.floor(b/a) * a\n return a + b\n\n\na = raw_input().split(' ')\nb = raw_input().split(' ')\nc = raw_input().split(' ')\n\nax = float(a[0])\nay = float(a[1])\nbx = float(b[0])\nby = float(b[1])\ncx = float(c[0])\ncy = float(c[1])\n\nayd = by - ay\naxd = bx - ax\nbyd = cy - by\nbxd = cx - bx\n\naslope = 0\nbslope = 0\n\nif axd != 0:\n aslope = ayd / axd\n\nif bxd != 0:\n bslope = byd / bxd\n\nabmidx = (ax+bx)/2\nabmidy = (ay+by)/2\nbcmidx = (bx+cx)/2\nbcmidy = (by+cy)/2\n\nif ayd == 0:\n cex = abmidx\n if bxd == 0:\n cey = bcmidy\n else:\n cey = bcmidy + (bcmidx - cex)/bslope\nelif byd == 0:\n cex = bcmidx\n if axd == 0:\n cey = abmidy\n else:\n cey = abmidy + (abmidx - cex)/aslope\nelif axd == 0:\n cey = abmidy\n cex = bslope*(bcmidy - cey) + bcmidx\nelif bxd == 0:\n cey = bcmidy\n cex = aslope*(abmidy - cey) + abmidx\nelse:\n cex = (aslope*bslope*(abmidy - bcmidy) - aslope*bcmidx + bslope*abmidx)/(bslope - aslope)\n cey = abmidy - (cex - abmidx)/aslope\n\nr = math.sqrt((ax - cex)**2 + (ay - cey)**2)\n\nab = math.sqrt((ax-bx)**2 + (ay-by)**2)\nac = math.sqrt((ax-cx)**2 + (ay-cy)**2)\nbc = math.sqrt((bx-cx)**2 + (by-cy)**2)\n\nacex = ax - cex\nacey = ay - cey\nbcex = bx - cex\nbcey = by - cey\nccex = cx - cex\nccey = cy - cey\n\nalfa = math.acos((bc**2 + ac**2 - ab**2)/(2*bc*ac))\nbeta = math.acos((ab**2 + ac**2 - bc**2)/(2*ab*ac))\ngamma = math.acos((ab**2 + bc**2 - ac**2)/(2*ab*bc))\n\nn = math.pi / gcd(gcd(alfa, beta), gamma)\n\narea = 0.5 * float(n) * r * r * math.sin(2 * math.pi / n)\n\nprint area\n"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\nimport math\nfrom decimal import *\n\ngetcontext().prec = 100\ndef gcd(a, b):\n if b > a:\n return gcd(b, a)\n elif math.fabs(b) > 0.00001:\n\n return gcd(\n b,\n a - math.floor(a/b) * b\n )\n else:\n return a\n\nclass Point(object):\n x = None\n y = None\n def __init__(self, *args ):\n if len(args) == 1:\n self.x, self.y = args[0]\n else:\n self.x, self.y = args\n\n def dist(self, a):\n x = a.x - self.x\n y = a.y - self.y\n return math.sqrt(x*x + y*y)\n\n def cross(self, a):\n return self.x * a.y - a.x * self.y\n\n def __sub__(self, other):\n return Point(self.x - other.x, self.y - other.y)\n\n def area(self, a, b):\n p1 = a - self\n p2 = b - self\n return math.fabs(p1.cross(p2)) / 2.0\n\n def angle(self, left, right):\n b = self.dist(left)\n c = self.dist(right)\n a = left.dist(right)\n return math.acos(\n (b*b+c*c-a*a) / ( 2.0 * b * c)\n )\n\ndef process(fin):\n\n p1 = Point(list(map(Decimal, fin().split())))\n p2 = Point(list(map(Decimal, fin().split())))\n p3 = Point(list(map(Decimal, fin().split())))\n\n a = p2.dist(p3)\n b = p3.dist(p1)\n c = p1.dist(p2)\n S = p1.area(p2,p3)\n R = (a*b*c) / (4.0 * S)\n\n A = p1.angle(p2, p3) * 2.0\n B = p2.angle(p1, p3) * 2.0\n C = p3.angle(p1, p2) * 2.0\n\n g = gcd( A, gcd(B, C))\n # n = math.floor(2.0 * math.pi / g)\n n = 2.0 * math.pi / g\n\n result = n * R * R * math.sin(g) / 2.0\n\n print(result)\n\nif __name__ == '__main__':\n process(sys.stdin.readline)\n"}, {"source_code": "import math\n\n#\u4e09\u89d2\u5f62\u4e09\u908a: a, b, c\na1, a2 = 76.820252, 66.709341 #0, 1 \nb1, b2 = 61.392328, 82.684207 #1, 1 \nc1, c2 = 44.267775, -2.378694 #0, 0 \n#a1, a2 = input().split()\n#b1, b2 = input().split()\n#c1, c2 = input().split()\n\na1, a2 = float(a1), float(a2)\nb1, b2 = float(b1), float(b2)\nc1, c2 = float(c1), float(c2)\n\na = ((b1-c1)**2 + (b2-c2)**2) **0.5\nb = ((a1-c1)**2 + (a2-c2)**2) **0.5\nc = ((a1-b1)**2 + (a2-b2)**2) **0.5\n\n\n#\u5916\u63a5\u5713\u534a\u5f91: R\ncos_A = (b**2+c**2-a**2)/(2*b*c)\nsin_A = (1-cos_A**2)**0.5\nR = a/(2*sin_A)\n#print(R)\n\n#\u5916\u63a5\u5713\u5713\u5fc3\u89d2\ncos_a = (R**2+R**2-a**2)/(2*R*R)\ncos_b = (R**2+R**2-b**2)/(2*R*R)\ncos_c = (R**2+R**2-c**2)/(2*R*R)\n\ntheta_a = math.acos(cos_a)\ntheta_b = math.acos(cos_b)\ntheta_c = math.acos(cos_c)\n#print(theta_a, theta_b, theta_c)\n#print(theta_a / 0.483321946706122, theta_a % 0.483321946706122, round(theta_a / 0.483321946706122,6)- round(theta_a / 0.483321946706122))\n#print(theta_b / 0.483321946706122, theta_b % 0.483321946706122, round(theta_b / 0.483321946706122,6)- round(theta_b / 0.483321946706122))\n#print(theta_c / 0.483321946706122, theta_c % 0.483321946706122, round(theta_c / 0.483321946706122,6)- round(theta_c / 0.483321946706122))\n\n#\u591a\u908a\u5f62\u7684\u5713\u5fc3\u89d2\ndef is_gcd_theta(theta):\n\tfor t in [theta_a, theta_b, theta_c]:\n\t\tdiv = t / theta\n\t\t#print(round(div,6), int(div))\n\t\tif not round(div,6) == round(div):\n\t\t\treturn False\n\treturn True\n\nsides = 3\ntheta_regular = 2 * math.pi / sides\n#for i in range(3, 101):\n\t#print(\"Each angle in n-side shape:\", i, 2*math.pi/i)\n#print(\"0-idx sides:\", sides, theta_c % theta_regular)\nwhile (not is_gcd_theta(theta_regular)) and sides <= 100:\n\tsides += 1\n\ttheta_regular = 2 * math.pi / sides\n\t#print(\"sides:\", sides, theta_a % theta_regular)\ntri_area = 1/2*R*R*math.sin(theta_regular)\ntotal_area = round(tri_area * sides, 6)\n\t\n\n\n#\u591a\u908a\u5f62\u4e09\u89d2\u5f62: tri_area\n#tri_area = 1/2*R*R*math.sin(math.radians(theta_regular))\n#print(sides)\nprint(total_area)\n"}, {"source_code": "import math\nA=list(map(float,input().split()))\nB=list(map(float,input().split()))\nC=list(map(float,input().split()))\nc=((A[0]-B[0])**2+(A[1]-B[1])**2)**0.5\na=((C[0]-B[0])**2+(C[1]-B[1])**2)**0.5\nb=((A[0]-C[0])**2+(A[1]-C[1])**2)**0.5\ngamma=math.acos((a**2+b**2-c**2)/(2*a*b))\nR=0.5*c/math.sin(gamma)\nl=[math.pi/math.asin(0.5*b/R),math.pi/math.asin(0.5*a/R),math.pi/gamma]\nm=[]\nfor x in l:\n m.append(round(x))\nm.sort()\nx=2\nwhile True:\n if ((x % m[0] == 0) and (x % m[1] == 0) and (x % m[2] == 0)):\n y=x\n break\n x += 1\nprint(0.5*y*(R**2)*math.sin(2*math.pi/y))\n"}, {"source_code": "\n'''\nCreated on Apr 23, 2017\n\n@author: Maiko\n'''\n#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport math\nimport fractions\n\ndef solve():\n rawin = []\n for i in range(3):\n a = input().split()\n rawin.append( [ float(a[0]), float(a[1]) ] )\n \n # length of three edges\n a = distance(rawin[0], rawin[1])\n b = distance(rawin[1], rawin[2])\n c = distance(rawin[0], rawin[2])\n p = (a + b + c) / 2\n # square of the triangle \n S = math.sqrt(p * (p-a) * (p-b) * (p-c))\n \n # Radius of the Circumscribed circle\n R = (a*b*c) / (4*S)\n \n #Law of cosines\n angle = []\n angle.append(math.acos((1 - a*a / (2*R*R))))\n angle.append(math.acos((1 - b*b / (2*R*R))))\n angle.append(2*math.pi - angle[0] - angle[1])\n # when least edge the \n A = fgcd(angle[0], fgcd(angle[1], angle[2]))\n # number of edge of the polygon\n N = int(2 * math.pi / A)\n S_an = R * R * math.sin(A) * N / 2\n print(\"%.8f\\n\" % S_an)\n \n \ndef distance(a, b):\n return math.sqrt(math.pow(a[0]-b[0], 2)+math.pow(a[1]-b[1], 2))\n\ndef feq(a, b):\n return math.fabs(a - b) < 0.01\n\ndef fgcd(a, b):\n if feq(a, 0):\n return b\n if feq(b, 0):\n return a\n return fgcd(b, a % b)\n \nif __name__ == '__main__':\n solve()"}, {"source_code": "#!/usr/bin/python\n\nimport sys\nimport math\n\ndef intersect(x1,y1,x2,y2,x3,y3,x4,y4):\n # : <math>\n # \\begin{align}\n # (P_x, P_y)= \\bigg(&\\frac{(x_1 y_2-y_1 x_2)(x_3-x_4)-(x_1-x_2)(x_3 y_4-y_3 x_4)}{(x_1-x_2)(y_3-y_4)-(y_1-y_2)(x_3-x_4)}, \\\\\n # &\\frac{(x_1 y_2-y_1 x_2)(y_3-y_4)-(y_1-y_2)(x_3 y_4-y_3 x_4)}{(x_1-x_2)(y_3-y_4)-(y_1-y_2)(x_3-x_4)}\\bigg)\n # \\end{align}\n # </math>\n x1y2 = x1*y2\n y1x2 = y1*x2\n x3y4 = x3*y4\n y3x4 = y3*x4\n\n P_x, P_y = (((x1y2 - y1x2) * (x3 - x4) - (x1 - x2) * (x3y4 - y3x4)) /\n ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)),\n ((x1y2 - y1x2) * (y3 - y4) - (y1 - y2) * (x3y4 - y3x4)) /\n ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4))\n )\n return (P_x, P_y)\n\np1= [float(v) for v in sys.stdin.readline().split(\" \")]\np2= [float(v) for v in sys.stdin.readline().split(\" \")]\np3= [float(v) for v in sys.stdin.readline().split(\" \")] \n\nx1 = (p1[0] + p2[0])/2.0\ny1 = (p1[1] + p2[1])/2.0\n\nd1x = p1[0]-p2[0]\nd1y = p1[1]-p2[1]\n\nx2 = x1+d1y\ny2 = y1+d1x\n\nx3 = (p2[0] + p3[0])/2.0\ny3 = (p2[1] + p3[1])/2.0\n\nd2x = p2[0]-p3[0]\nd2y = p2[1]-p3[1]\n\nx4 = x3 + d2y\ny4 = y3 + d2x\n\ncentre = intersect(x1,y1, x2,y2, x3,y3, x4,y4)\n\ndef minus(a,b):\n return (a[0]-b[0], a[1]-b[1])\n\ndef norm_dot(a,b):\n len_a = math.sqrt(sum([_a**2 for _a in a]))\n len_b = math.sqrt(sum([_b**2 for _b in b]))\n dot = sum([(_a / len_a) * (_b/len_b) for _a,_b in zip(a,b)])\n return dot\n\ndef norm(a):\n len_a = math.sqrt(sum([_a**2 for _a in a]))\n return len_a\n\np1 = minus(p1, centre)\np2 = minus(p2, centre)\np3 = minus(p3, centre)\n\nangle1 = math.fabs(math.asin(norm_dot(p1,p2)))\nangle2 = math.fabs(math.asin(norm_dot(p1,p3)))\n\ntest_side_count = 3\nwhile True:\n angle = (math.pi*2.0) / float(test_side_count)\n thetas = [angle * i for i in range(test_side_count)]\n \n a1_d = [math.fabs(math.fabs(angle1) - math.fabs(t)) for t in thetas]\n a2_d = [math.fabs(math.fabs(angle2) - math.fabs(t)) for t in thetas]\n if min(a1_d)<0.00001 and min(a2_d) < 0.00001:\n break\n\n test_side_count += 1\n if test_side_count >5:\n break\n\nR = norm(p1)\n\nsect_size = (math.pi*R*R /(2.0*math.pi) * angle) - ((R*R)/2.0) * (angle - math.sin(angle))\n\nprint \"%.7f\" % (sect_size * test_side_count)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport math\n\ndef area(d):\n if len(d) < 3:\n return False\n a = 0.0\n p = 0.5 * (d[0] + d[1] + d[2])\n a = math.sqrt(p*(p-d[0])*(p-d[1])*(p-d[2]))\n return a\n\ndef circumcircle(x,y):\n distance = euclidean(x,y)\n triangle_area = area(distance)\n return distance[0] * distance[1] * distance[2] / (4 * triangle_area)\n \ndef euclidean(x,y):\n d = []\n d.append(math.sqrt((x[0]-x[1])**2 + (y[0]-y[1])**2))\n d.append(math.sqrt((x[0]-x[2])**2 + (y[0]-y[2])**2))\n d.append(math.sqrt((x[1]-x[2])**2 + (y[1]-y[2])**2))\n return d\n \ndef centerAngle(d,radius):\n angle = []\n #print(type(d[0]), type(radius))\n #print(d[0]/(2*radius))\n #print(2 * math.asin( d[0] / (2*radius) ) )\n angle.append(2*math.asin(d[0]/(2*radius)))\n angle.append(2*math.asin(d[1]/(2*radius)))\n angle.append(2*math.asin(d[2]/(2*radius)))\n return angle\n\ndef gcd(a,b):\n if a < 0.01:\n return b\n else:\n return gcd(math.fmod(b,a),a)\ndef main():\n \n # get the input data\n x = []\n y = []\n for i in range(3):\n temp_input = input().split() \n x.append(float(temp_input[0]))\n y.append(float(temp_input[1]))\n\n # 1. calculate the length of the edge \n # 2. calculate the area of the triangle\n # 3. calculate the radius of the circumcircle\n # 4. calculate the area of the Berland Circus\n\n edge_length = euclidean(x,y)\n\n triangle_area = area(edge_length)\n\n circumcircle_radius = circumcircle(x,y)\n\n #print(\"circumcircle_radius: {0[0]}:{1[0]},{0[1]}:{1[1]}, {0[2]}:{1[2]} \\n {2}\".format(x,y,circumcircle_radius))\n # 5. calculat the cetral angle and their gcd\n angle = centerAngle(edge_length, circumcircle_radius)\n \n gcd_angle = gcd(gcd(angle[0], angle[1]), angle[2])\n\n\n result = 2 * math.pi / gcd_angle * circumcircle_radius * math.sin(gcd_angle) * circumcircle_radius * 0.5 \n\n #print(\"circumcircle_radius\",circumcircle_radius)\n #print(\"totoal_angle\",angle)\n #print(\"gcd_angle\",gcd_angle)\n #print(\"len\",edge_length)\n print(\"{:.8f}\".format(result))\n \n \n\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import math\n\ndef dist(a, b):\n\treturn math.sqrt(a*a + b*b)\n\ndef area(side, n):\n\t#n = int(round(-2 / (angle / math.pi - 1)))\n\t#print n\n\treturn n * side * side / 4 / math.tan(math.pi / n)\n\ndef cos_law(a, b, c):\n\tc_angle = (c*c - a*a - b*b) / (-2 * a * b)\n\treturn math.acos(c_angle)\n\ndef gcd(a, b):\n\tif abs(b) < 0.001: return a\n\treturn gcd(b, a%b)\n\nx1, y1 = raw_input().split(' ')\nx2, y2 = raw_input().split(' ')\nx3, y3 = raw_input().split(' ')\n\nx1 = float(x1)\ny1 = float(y1)\nx2 = float(x2)\ny2 = float(y2)\nx3 = float(x3)\ny3 = float(y3)\n\nd1 = dist(x3 - x2, y3 - y2)\nd2 = dist(x3 - x1, y3 - y1)\nd3 = dist(x2 - x1, y2 - y1)\n\narr = [d1, d2, d3]\narr.sort()\n#print x1, y1\n#print x2, y2\n#print x3, y3\n#print arr\na, b, c = arr\ns = (a + b + c) / 2\nradius = a*b*c / 4 / math.sqrt(s * (a+b-s) * (a+c-s) * (b+c-s))\nangle_a = cos_law(radius, radius, a)\nangle_b = cos_law(radius, radius, b)\n#angle_c = cos_law(radius, radius, c)\nn = int(round(2 * math.pi / gcd(angle_a, 2*math.pi % angle_b)))\n#print 'gcd', gcd(angle_a, angle_b) / math.pi * 180\n\n#print angle / math.pi * 180\n#print 'radius', radius\n#print angle_a / math.pi * 180\n#print angle_b / math.pi * 180\n#print angle_c / math.pi * 180\n#print (angle_a+angle_b+angle_c) / math.pi * 180\n\nprint area(2 * radius * math.sin(math.pi / n), n)\n"}, {"source_code": "import math\ns1 = input().split()\ns2 = input().split()\ns3 = input().split()\nx1 = float(s1[0])\ny1 = float(s1[1])\nx2 = float(s2[0])\ny2 = float(s2[1])\nx3 = float(s3[0])\ny3 = float(s3[1])\ndef center(x1, y1, x2, y2, x3, y3):\n x = ((y3-y2)/2*(y2-y1)*(y3-y1) + (x1+x2)/2*(x1*y3-x1*y1-x2*y3+x2*y1)-(x1+x3)/2*(x1*y2-x1*y1-x3*y2+x3*y1))/(x1*y3-x1*y1-x2*y3+x2*y1-x1*y2+x1*y1+x3*y2-x3*y1)\n y = ((x1-x2)*(x-(x1+x2)/2))/(y2-y1) + (y1+y2)/2\n r = math.sqrt((x1-x)**2+(y1-y)**2)\n return (x, y, r)\n\ndef poligon(x0, y0, x1, y1, r, n):\n a = 2*math.pi/n\n x = x1-x0\n y = y1-y0\n res = []\n for i in range(n):\n xn = x*math.cos(i*a) - y*math.sin(i*a) + x0\n yn = x*math.sin(i*a) + y*math.cos(i*a) + y0\n if \"%.6f\" % (xn)=='-0.000000':\n xn = 0\n if \"%.6f\" % (yn)=='-0.000000':\n yn = 0\n res.append((\"%.6f\" % (xn), \"%.6f\" % (yn)))\n return res\n\ndef square(r, x, n):\n return math.sqrt(r**2-x**2/4)*0.5*x*n\n\nfor i in range(3, 101):\n c = center(x1, y1, x2, y2, x3, y3)\n r = poligon(c[0], c[1], x1, y1, c[2], i)\n if (\"%.6f\" % (x1), \"%.6f\" % (y1)) in r and (\"%.6f\" % (x2), \"%.6f\" % (y2)) in r and (\"%.6f\" % (x3), \"%.6f\" % (y3)) in r:\n print(\"%.6f\" % (square(float(c[2]), math.sqrt((float(r[0][0])-float(r[1][0]))**2+(float(r[0][1])-float(r[1][1]))**2), i)))\n break"}, {"source_code": "from math import acos, sin, sqrt, pi\n\nAx,Ay=map(float,raw_input().split())\nBx,By=map(float,raw_input().split())\nCx,Cy=map(float,raw_input().split())\na_2=(Bx-Cx)**2+(By-Cy)**2; a=sqrt(a_2)\nb_2=(Ax-Cx)**2+(Ay-Cy)**2; b=sqrt(b_2)\nc_2=(Bx-Ax)**2+(By-Ay)**2; c=sqrt(c_2)\n\nP=(a+b+c)/2\nS=sqrt(P*(P-a)*(P-b)*(P-c))\nR=a*b*c/(4*S)\nR_2=a_2*b_2*c_2/((a+b+c)*(b+c-a)*(a+b-c)*(a+c-b))\n\nli = [float(x) for x in range(1,101)]\n \nfor i in range(3,101):\n if round(acos(1-c_2/(2*R_2))/(2*pi/i) , 3) in li \\\n and round(acos(1-a_2/(2*R_2))/(2*pi/i) , 3) in li\\\n and round(acos(1-b_2/(2*R_2))/(2*pi/i) , 3) in li :\n break\n \nprint i\nSres=i*R_2*sin(2*pi/i)/2\nprint Sres\n \n \n \n "}], "src_uid": "980f4094b3cfc647d6f74e840b1bfb62"} {"source_code": "n,a,b=int(input())+1,0,0;d=[0]*n\r\nfor i in range(1,n):\r\n for j in range(i,n,i):d[j]+=1\r\n a=b%998244353+d[i];b+=a\r\nprint(a)", "positive_code": [{"source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\nMAX = sys.maxsize\r\n\r\n# sys.setrecursionlimit(10 ** 9)\r\n\r\n\r\n# Input functions\r\ndef inp():\r\n return int(input())\r\n\r\n\r\ndef read_int_list():\r\n return list(map(int, input().split()))\r\n\r\n\r\ndef read_list():\r\n s = input()\r\n return list(s[:len(s) - 1])\r\n\r\n\r\ndef read_int_map():\r\n return map(int, input().split())\r\n\r\n\r\n# Solution\r\nX = 998244353\r\n\r\n\r\ndef solve(n):\r\n dp = [0] * (n + 1)\r\n dp[0] = 1\r\n for i in range(2, n + 1):\r\n for j in range(i, n + 1, i):\r\n dp[j] += 1\r\n\r\n pref = 1\r\n for i in range(1, n + 1):\r\n dp[i] = (dp[i] + pref) % X\r\n pref = (dp[i] + pref) % X\r\n\r\n return dp[n]\r\n\r\n\r\nif __name__ == \"__main__\":\r\n print(solve(inp()))\r\n"}, {"source_code": "import itertools\r\nimport os,sys\r\nfrom random import randint\r\nfrom io import BytesIO, IOBase\r\n\r\nfrom collections import defaultdict,deque,Counter\r\nfrom bisect import bisect_left,bisect_right\r\nfrom heapq import heappush,heappop\r\nfrom functools import lru_cache\r\nfrom itertools import accumulate\r\nimport math\r\n\r\n# Fast IO Region\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n# mn = min(a)\r\n# ans = 0\r\n# for i in range(n):\r\n# if a[i] != mn:\r\n# ans += 1\r\n# print(ans)\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n# b = []\r\n# for i in range(n):\r\n# if a[i] <= 0:\r\n# b.append(a[i])\r\n# if not b:\r\n# print(1)\r\n# continue\r\n# mn = float('inf')\r\n# b.sort()\r\n# for i in range(len(b) - 1):\r\n# mn = min(mn, b[i + 1] - b[i])\r\n# ans = len(b)\r\n# for i in range(n):\r\n# if 0 < a[i] <= mn:\r\n# ans += 1\r\n# break\r\n# print(ans)\r\n\r\nN = 10 ** 6 + 10\r\ncnt = [0] * N\r\nfor i in range(1, N):\r\n for j in range(1, 10000000000):\r\n if i * j >= N:\r\n break\r\n cnt[i * j] += 1\r\n\r\nmod = 998244353\r\nn = int(input())\r\na = [0, 1, 3, 6]\r\nif n < 4:\r\n print(a[n])\r\nelse:\r\n tot = 10\r\n for i in range(4, n + 1):\r\n a.append((tot + cnt[i]) % mod)\r\n tot = (tot + a[-1]) % mod\r\n print(a[-1])\r\n\r\n\r\n\r\n# n = 9\r\n# ans = 0\r\n# def dfs(a, b):\r\n# global ans\r\n# if not a:\r\n# for i in range(0, 2 * n, 2):\r\n# for j in range(i + 2, 2 * n, 2):\r\n# l1, r1 = b[i], b[i + 1]\r\n# l2, r2 = b[j], b[j + 1]\r\n# if r1 - l1 != r2 - l2 and not (l2<l1<r1<r2 or l1<l2<r2<r1):\r\n# return\r\n# ans += 1\r\n# return\r\n# l = a.pop(0)\r\n# b.append(l)\r\n# for i in range(len(a)):\r\n# dfs(a[:i] + a[i + 1:], b + [a[i]])\r\n# dfs(list(range(1, n * 2 + 1)),[])\r\n# print(ans)\r\n# ans = 0\r\n# n = 5\r\n# for a in itertools.permutations(list(range(1, n * 2 + 1))):\r\n# for i in range(0, 2 * n, 2):\r\n# if a[i] > a[i + 1]:\r\n# break\r\n# else:\r\n# ok = True\r\n# for i in range(0, 2 * n, 2):\r\n# for j in range(i + 2, 2 * n, 2):\r\n# l1, r1 = a[i], a[i + 1]\r\n# l2, r2 = a[j], a[j + 1]\r\n# if r1 - l1 != r2 - l2 and not (l2<l1<r1<r2 or l1<l2<r2<r1):\r\n# ok=False\r\n# break\r\n# if not ok:\r\n# break\r\n# if ok:\r\n# # print(a)\r\n# ans += 1\r\n# print(ans)\r\n\r\n"}, {"source_code": "p=998244353\r\n\r\ndef sol(n):\r\n f = [1]*(n+1)\r\n for i in range(2,n+1):\r\n for j in range(i,n+1,i):\r\n f[j] += 1\r\n g = [0]*(n+1)\r\n h = 0\r\n for i in range(1,n+1):\r\n g[i]=(f[i]+h)%p\r\n h =((h<<1)+f[i])%p\r\n return g[n] \r\n\r\nprint(sol(int(input())))\r\n"}, {"source_code": "MAX = 1000000\nfact = [1 for i in range(MAX+1)]\n\nfor i in range(2,MAX+1):\n if fact[i]>1: continue \n base = i\n power = 1\n while base<MAX+1:\n for j in range(base,MAX+1,base):\n fact[j] *= power+1\n fact[j] = fact[j] // power\n base *= i\n power += 1\n\n\n#print(fact) \n\n\n\n\n\n\n\n\n\nM = 998244353\n\nn = int(input())\n\nif n<2:\n print(n)\n exit()\n\n\n\n\n\ndp = [0]*(n+1)\n\ndp[1] = 1\n\ntot = 1\nfor i in range(2,n+1):\n dp[i] = tot\n \n dp[i] += fact[i]\n dp[i] = dp[i]%M\n\n\n tot += dp[i]\n tot = tot%M\n\n \n\n#print(dp)\nprint(dp[-1]) \n\n\n\n"}, {"source_code": "import sys\r\ninput = lambda :sys.stdin.readline()[:-1]\r\nni = lambda :int(input())\r\nna = lambda :list(map(int,input().split()))\r\nyes = lambda :print(\"yes\");Yes = lambda :print(\"Yes\");YES = lambda : print(\"YES\")\r\nno = lambda :print(\"no\");No = lambda :print(\"No\");NO = lambda : print(\"NO\")\r\n#######################################################################\r\nn = ni()\r\nmod = 998244353\r\n\r\ndp = [0]*(n+1)\r\ndp[0] = 1\r\ns = 1\r\nfor i in range(1,n+1):\r\n for j in range(i*2, n+1,i):\r\n dp[j] += 1\r\n dp[j] %= mod\r\n\r\nfor i in range(1,n+1):\r\n dp[i] += s\r\n dp[i] %= mod\r\n s += dp[i]\r\n s %= mod\r\nprint(dp[-1])\r\n"}, {"source_code": "from collections import Counter, defaultdict, deque\r\nimport bisect\r\nfrom sys import stdin, stdout\r\nfrom itertools import repeat, permutations\r\nimport math\r\nimport heapq\r\n\r\n\r\ndef inp(force_list=False):\r\n re = map(int, raw_input().split())\r\n if len(re) == 1 and not force_list:\r\n return re[0]\r\n return re\r\n\r\ndef inst():\r\n return raw_input().strip()\r\n\r\ndef gcd(x, y):\r\n while(y):\r\n x, y = y, x % y\r\n return x\r\n\r\nMOD = 998244353\r\n\r\ndef qmod(a, b, mod=MOD):\r\n res = 1\r\n while b:\r\n if b&1:\r\n res = (res*a)%mod\r\n b >>= 1\r\n a = (a*a)%mod\r\n # print b\r\n return res\r\n\r\ndef inv(a):\r\n return qmod(a, MOD-2)\r\n\r\n\r\ndef my_main():\r\n kase = 1#inp()\r\n pans = []\r\n N = 1100000\r\n fac = [-1] * N\r\n for i in xrange(2, N):\r\n for j in xrange(1, N):\r\n if j*i>=N:\r\n break\r\n fac[j*i] += 1\r\n ans = [0, 1, 3, 6]\r\n ps = 10\r\n n = inp()\r\n for i in range(4, n+1):\r\n ans.append((ps+fac[i]+2)%998244353)\r\n ps += ans[-1]\r\n ps %= 998244353\r\n # print ans\r\n print ans[n]\r\n\r\n\r\n\r\n\r\nmy_main()\r\n"}, {"source_code": "p=998244353\nn=int(input())\ns=0\ndiv=n*[0]\nfor k in range(n):\n x=k+1\n for l in range(1,n//x +1):\n if l*x<=n:\n div[l*x-1]+=1\ndp=n*[0]\ndp[0]=1\nfor k in range(1,n):\n dp[k]=((div[k]-div[k-1])+2*dp[k-1])%p\nprint(dp[n-1])"}, {"source_code": "import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353\r\n\r\nn=I();dp=[0]*(n+1);s=1\r\nfor i in range(1,n+1):\r\n for j in range(i*2,n+1,i):dp[j]+=1\r\nfor i in range(1,n+1):dp[i]=(s+dp[i])%mod2;s=(s+dp[i])%mod2\r\nprint(dp[n])"}, {"source_code": "\r\ndef GoodPairings(n):\r\n mod=998244353\r\n dp=[0]*(n+1)\r\n dp[0]=1\r\n for i in range(1,n+1):\r\n for j in range(i+i,n+1,i):\r\n dp[j]=dp[j]+1\r\n\r\n \r\n S=1\r\n for i in range(1,n+1):\r\n dp[i]=(dp[i]+S)%mod\r\n S=(S+dp[i])%mod\r\n \r\n return dp[n]\r\n\r\nn=(int)(input())\r\nprint(GoodPairings(n))\r\n"}, {"source_code": "import sys\nfrom sys import stdout\n\ninput = lambda: sys.stdin.readline().strip()\nP = lambda: list(map(int, input().split()))\nfrom math import factorial as f, gcd\nfrom collections import deque, defaultdict as dd, Counter as C\nfrom heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge\nfrom random import randint, choice, sample\nimport time\nmod = 10**9+7\na = ord('a')\n\n\nstart = time.time()\ndef fast_exp(x, exp):\n ans = 1\n base = x\n while exp:\n if exp & 1:\n ans *= base\n base *= base\n base %= mod\n ans %= mod\n exp >>= 1\n return ans\n\ndef countBits(n):\n count = 0\n while n:\n count += n & 1\n n >>= 1\n return count\n\ndef submasks(n):\n #this is cool\n #https://cp-algorithms.com/algebra/all-submasks.html\n org = n\n while n:\n yield n\n n = (n-1) & org\n\n\ndef solve():\n n = int(input())\n arr = [0] * (n+1)\n for i in range(2, n+1):\n for j in range(i, n+1, i):\n arr[j] += 1\n dp = [1] * (n+1)\n accdp = [1, 2] + [0] * (n-1)\n for i in range(2, n+1):\n dp[i] = (arr[i] + accdp[i-1]) % 998244353\n accdp[i] = (accdp[i-1] + dp[i]) % 998244353\n print(dp[n])\n\n# solution: (had to look at editiorial ofc :/)\n# dp[i] is num for 2*i points.\n# when the first point stretches to the second half, it leaves some points untouched (this middle untouched part is counted with dp/prefix)\n# if it doesnt, its amount of divisors of n\n\n \n\n\n\n\n\n\ntc = 1\nfor t in range(1, tc+1):\n solve()\n\n# solve()\n# print(time.time()-start)\n\n\n"}, {"source_code": "# Problem: B. Kavi on Pairing Duty\r\n# Contest: Codeforces - Codeforces Round #722 (Div. 1)\r\n# URL: https://codeforces.com/contest/1528/problem/B\r\n# Memory Limit: 256 MB\r\n# Time Limit: 1000 ms\r\n# \r\n# Powered by CP Editor (https://cpeditor.org)\r\n\r\nfrom collections import defaultdict\r\nfrom functools import reduce\r\nfrom bisect import bisect_right\r\nfrom bisect import bisect_left\r\n#import sympy #Prime number library\r\nimport copy\r\nimport heapq\r\n\r\n\r\nmod=998244353\r\ndef main():\r\n n=int(input())\r\n dp=[0]*(2*n+1)\r\n prev=[0]*(2*n+1)\r\n dp[0]=1;prev[0]=1;\r\n NumOfDivisors(n)\r\n for i in range(2,2*n+1,2):\r\n \tdp[i]=(prev[i-2]+div[i//2]-1)%mod\r\n \tprev[i]=(prev[i-2]+dp[i])%mod\r\n print(dp[2*n])\r\n\r\n\r\ndiv=[0]*(1000001)\r\ndef NumOfDivisors(n): #O(nlog(n))\r\n\tfor i in range(1,n+1):\r\n\t\tfor j in range(i,n+1,i):\r\n\t\t\tdiv[j]+=1\r\n\t\t\r\ndef primes1(n): #return a list having prime numbers from 2 to n\r\n \"\"\" Returns a list of primes < n \"\"\"\r\n sieve = [True] * (n//2)\r\n for i in range(3,int(n**0.5)+1,2):\r\n if sieve[i//2]:\r\n sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)\r\n return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]\r\n \r\ndef GCD(a,b):\r\n if(b==0):\r\n return a\r\n else:\r\n return GCD(b,a%b)\r\n \r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "import collections\r\nimport functools\r\nimport math\r\nimport random\r\nimport sys\r\nimport bisect\r\n\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef In():\r\n return map(int, sys.stdin.readline().split())\r\n\r\n\r\ndef Kavi():\r\n n = int(input()) + 1\r\n l = [0] * n\r\n mod = 998244353\r\n for i in range(1, n):\r\n for i1 in range(i + i, n, i):\r\n l[i1] += 1\r\n l[0] = tol = 1\r\n for i in range(1, n):\r\n l[i] = (l[i] + tol) % mod\r\n tol = (tol + l[i]) % mod\r\n return l[-1]\r\n\r\n\r\nprint(Kavi())\r\n"}, {"source_code": "MOD = 998244353\nn = int(input())\ndp = [None] * (n+1)\npref = [None] * (n+1)\ndiv = [2] * (n+1)\n\ndp[1] = 1\npref[1] = 1\n\nfor i in range(2,n+1):\n dp[i] = (div[i] + pref[i-1]) % MOD\n pref[i] = (pref[i-1] + dp[i]) % MOD\n for j in range(i<<1, n+1, i):\n div[j] += 1\n\nprint(dp[n])\n"}, {"source_code": "def divisors(M):\r\n d=[]\r\n i=1\r\n while M>=i**2:\r\n if M%i==0:\r\n d.append(i)\r\n if i**2!=M:\r\n d.append(M//i)\r\n i=i+1\r\n return d\r\n\r\ndef popcount(x):\r\n x = x - ((x >> 1) & 0x55555555)\r\n x = (x & 0x33333333) + ((x >> 2) & 0x33333333)\r\n x = (x + (x >> 4)) & 0x0f0f0f0f\r\n x = x + (x >> 8)\r\n x = x + (x >> 16)\r\n return x & 0x0000007f\r\n\r\ndef eratosthenes(n):\r\n res=[0 for i in range(n+1)]\r\n prime=set([])\r\n for i in range(2,n+1):\r\n if not res[i]:\r\n prime.add(i)\r\n for j in range(1,n//i+1):\r\n res[i*j]=1\r\n return prime\r\n\r\ndef factorization(n):\r\n res=[]\r\n for p in prime:\r\n if n%p==0:\r\n while n%p==0:\r\n n//=p\r\n res.append(p)\r\n if n!=1:\r\n res.append(n)\r\n return res\r\n\r\ndef euler_phi(n):\r\n res = n\r\n for x in range(2,n+1):\r\n if x ** 2 > n:\r\n break\r\n if n%x==0:\r\n res = res//x * (x-1)\r\n while n%x==0:\r\n n //= x\r\n if n!=1:\r\n res = res//n * (n-1)\r\n return res\r\n\r\ndef ind(b,n):\r\n res=0\r\n while n%b==0:\r\n res+=1\r\n n//=b\r\n return res\r\n\r\ndef isPrimeMR(n):\r\n if n==1:\r\n return 0\r\n d = n - 1\r\n d = d // (d & -d)\r\n L = [2, 3, 5, 7, 11, 13, 17]\r\n for a in L:\r\n t = d\r\n y = pow(a, t, n)\r\n if y == 1: continue\r\n while y != n - 1:\r\n y = (y * y) % n\r\n if y == 1 or t == n - 1: return 0\r\n t <<= 1\r\n return 1\r\ndef findFactorRho(n):\r\n from math import gcd\r\n m = 1 << n.bit_length() // 8\r\n for c in range(1, 99):\r\n f = lambda x: (x * x + c) % n\r\n y, r, q, g = 2, 1, 1, 1\r\n while g == 1:\r\n x = y\r\n for i in range(r):\r\n y = f(y)\r\n k = 0\r\n while k < r and g == 1:\r\n ys = y\r\n for i in range(min(m, r - k)):\r\n y = f(y)\r\n q = q * abs(x - y) % n\r\n g = gcd(q, n)\r\n k += m\r\n r <<= 1\r\n if g == n:\r\n g = 1\r\n while g == 1:\r\n ys = f(ys)\r\n g = gcd(abs(x - ys), n)\r\n if g < n:\r\n if isPrimeMR(g): return g\r\n elif isPrimeMR(n // g): return n // g\r\n return findFactorRho(g)\r\ndef primeFactor(n):\r\n i = 2\r\n ret = {}\r\n rhoFlg = 0\r\n while i*i <= n:\r\n k = 0\r\n while n % i == 0:\r\n n //= i\r\n k += 1\r\n if k: ret[i] = k\r\n i += 1 + i % 2\r\n if i == 101 and n >= 2 ** 20:\r\n while n > 1:\r\n if isPrimeMR(n):\r\n ret[n], n = 1, 1\r\n else:\r\n rhoFlg = 1\r\n j = findFactorRho(n)\r\n k = 0\r\n while n % j == 0:\r\n n //= j\r\n k += 1\r\n ret[j] = k\r\n\r\n if n > 1: ret[n] = 1\r\n if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}\r\n return ret\r\n\r\ndef divisors(n):\r\n res = [1]\r\n prime = primeFactor(n)\r\n for p in prime:\r\n newres = []\r\n for d in res:\r\n for j in range(prime[p]+1):\r\n newres.append(d*p**j)\r\n res = newres\r\n res.sort()\r\n return res\r\n\r\ndef xorfactorial(num):#\u6392\u4ed6\u7684\u8ad6\u7406\u548c\u306e\u968e\u4e57\r\n if num==0:\r\n return 0\r\n elif num==1:\r\n return 1\r\n elif num==2:\r\n return 3\r\n elif num==3:\r\n return 0\r\n else:\r\n x=baseorder(num)\r\n return (2**x)*((num-2**x+1)%2)+function(num-2**x)\r\n\r\ndef xorconv(n,X,Y):\r\n if n==0:\r\n res=[(X[0]*Y[0])%mod]\r\n return res\r\n x=[digit[i]+X[i+2**(n-1)] for i in range(2**(n-1))]\r\n y=[Y[i]+Y[i+2**(n-1)] for i in range(2**(n-1))]\r\n z=[digit[i]-X[i+2**(n-1)] for i in range(2**(n-1))]\r\n w=[Y[i]-Y[i+2**(n-1)] for i in range(2**(n-1))]\r\n res1=xorconv(n-1,x,y)\r\n res2=xorconv(n-1,z,w)\r\n former=[(res1[i]+res2[i])*inv for i in range(2**(n-1))]\r\n latter=[(res1[i]-res2[i])*inv for i in range(2**(n-1))]\r\n former=list(map(lambda x:x%mod,former))\r\n latter=list(map(lambda x:x%mod,latter))\r\n return former+latter\r\n\r\ndef merge_sort(A,B):\r\n pos_A,pos_B = 0,0\r\n n,m = len(A),len(B)\r\n res = []\r\n while pos_A < n and pos_B < m:\r\n a,b = A[pos_A],B[pos_B]\r\n if a < b:\r\n res.append(a)\r\n pos_A += 1\r\n else:\r\n res.append(b)\r\n pos_B += 1\r\n res += A[pos_A:]\r\n res += B[pos_B:]\r\n return res\r\n\r\nclass UnionFindVerSize():\r\n def __init__(self, N):\r\n self._parent = [n for n in range(0, N)]\r\n self._size = [1] * N\r\n self.group = N\r\n\r\n def find_root(self, x):\r\n if self._parent[x] == x: return x\r\n self._parent[x] = self.find_root(self._parent[x])\r\n stack = [x]\r\n while self._parent[stack[-1]]!=stack[-1]:\r\n stack.append(self._parent[stack[-1]])\r\n for v in stack:\r\n self._parent[v] = stack[-1]\r\n return self._parent[x]\r\n\r\n def unite(self, x, y):\r\n gx = self.find_root(x)\r\n gy = self.find_root(y)\r\n if gx == gy: return\r\n\r\n self.group -= 1\r\n\r\n if self._size[gx] < self._size[gy]:\r\n self._parent[gx] = gy\r\n self._size[gy] += self._size[gx]\r\n else:\r\n self._parent[gy] = gx\r\n self._size[gx] += self._size[gy]\r\n\r\n def get_size(self, x):\r\n return self._size[self.find_root(x)]\r\n\r\n def is_same_group(self, x, y):\r\n return self.find_root(x) == self.find_root(y)\r\n\r\nclass WeightedUnionFind():\r\n def __init__(self,N):\r\n self.parent = [i for i in range(N)]\r\n self.size = [1 for i in range(N)]\r\n self.val = [0 for i in range(N)]\r\n self.flag = True\r\n self.edge = [[] for i in range(N)]\r\n\r\n def dfs(self,v,pv):\r\n stack = [(v,pv)]\r\n new_parent = self.parent[pv]\r\n while stack:\r\n v,pv = stack.pop()\r\n self.parent[v] = new_parent\r\n for nv,w in self.edge[v]:\r\n if nv!=pv:\r\n self.val[nv] = self.val[v] + w\r\n stack.append((nv,v))\r\n\r\n def unite(self,x,y,w):\r\n if not self.flag:\r\n return\r\n if self.parent[x]==self.parent[y]:\r\n self.flag = (self.val[x] - self.val[y] == w)\r\n return\r\n\r\n if self.size[self.parent[x]]>self.size[self.parent[y]]:\r\n self.edge[x].append((y,-w))\r\n self.edge[y].append((x,w))\r\n self.size[x] += self.size[y]\r\n self.val[y] = self.val[x] - w\r\n self.dfs(y,x)\r\n else:\r\n self.edge[x].append((y,-w))\r\n self.edge[y].append((x,w))\r\n self.size[y] += self.size[x]\r\n self.val[x] = self.val[y] + w\r\n self.dfs(x,y)\r\n\r\nclass Dijkstra():\r\n class Edge():\r\n def __init__(self, _to, _cost):\r\n self.to = _to\r\n self.cost = _cost\r\n\r\n def __init__(self, V):\r\n self.G = [[] for i in range(V)]\r\n self._E = 0\r\n self._V = V\r\n\r\n @property\r\n def E(self):\r\n return self._E\r\n\r\n @property\r\n def V(self):\r\n return self._V\r\n\r\n def add_edge(self, _from, _to, _cost):\r\n self.G[_from].append(self.Edge(_to, _cost))\r\n self._E += 1\r\n\r\n def shortest_path(self, s):\r\n import heapq\r\n que = []\r\n d = [10**15] * self.V\r\n d[s] = 0\r\n heapq.heappush(que, (0, s))\r\n\r\n while len(que) != 0:\r\n cost, v = heapq.heappop(que)\r\n if d[v] < cost: continue\r\n\r\n for i in range(len(self.G[v])):\r\n e = self.G[v][i]\r\n if d[e.to] > d[v] + e.cost:\r\n d[e.to] = d[v] + e.cost\r\n heapq.heappush(que, (d[e.to], e.to))\r\n return d\r\n\r\n#Z[i]:length of the longest list starting from S[i] which is also a prefix of S\r\n#O(|S|)\r\ndef Z_algorithm(s):\r\n N = len(s)\r\n Z_alg = [0]*N\r\n\r\n Z_alg[0] = N\r\n i = 1\r\n j = 0\r\n while i < N:\r\n while i+j < N and s[j] == s[i+j]:\r\n j += 1\r\n Z_alg[i] = j\r\n if j == 0:\r\n i += 1\r\n continue\r\n k = 1\r\n while i+k < N and k + Z_alg[k]<j:\r\n Z_alg[i+k] = Z_alg[k]\r\n k += 1\r\n i += k\r\n j -= k\r\n return Z_alg\r\n\r\nclass BIT():\r\n def __init__(self,n,mod=0):\r\n self.BIT = [0]*(n+1)\r\n self.num = n\r\n self.mod = mod\r\n\r\n def query(self,idx):\r\n res_sum = 0\r\n mod = self.mod\r\n while idx > 0:\r\n res_sum += self.BIT[idx]\r\n if mod:\r\n res_sum %= mod\r\n idx -= idx&(-idx)\r\n return res_sum\r\n\r\n #Ai += x O(logN)\r\n def update(self,idx,x):\r\n mod = self.mod\r\n while idx <= self.num:\r\n self.BIT[idx] += x\r\n if mod:\r\n self.BIT[idx] %= mod\r\n idx += idx&(-idx)\r\n return\r\n\r\nclass dancinglink():\r\n def __init__(self,n,debug=False):\r\n self.n = n\r\n self.debug = debug\r\n self._left = [i-1 for i in range(n)]\r\n self._right = [i+1 for i in range(n)]\r\n self.exist = [True for i in range(n)]\r\n\r\n def pop(self,k):\r\n if self.debug:\r\n assert self.exist[k]\r\n L = self._left[k]\r\n R = self._right[k]\r\n if L!=-1:\r\n if R!=self.n:\r\n self._right[L],self._left[R] = R,L\r\n else:\r\n self._right[L] = self.n\r\n elif R!=self.n:\r\n self._left[R] = -1\r\n self.exist[k] = False\r\n\r\n def left(self,idx,k=1):\r\n if self.debug:\r\n assert self.exist[idx]\r\n res = idx\r\n while k:\r\n res = self._left[res]\r\n if res==-1:\r\n break\r\n k -= 1\r\n return res\r\n\r\n def right(self,idx,k=1):\r\n if self.debug:\r\n assert self.exist[idx]\r\n res = idx\r\n while k:\r\n res = self._right[res]\r\n if res==self.n:\r\n break\r\n k -= 1\r\n return res\r\n\r\nclass SparseTable():\r\n def __init__(self,A,merge_func,ide_ele):\r\n N=len(A)\r\n n=N.bit_length()\r\n self.table=[[ide_ele for i in range(n)] for i in range(N)]\r\n self.merge_func=merge_func\r\n\r\n for i in range(N):\r\n self.table[i][0]=A[i]\r\n\r\n for j in range(1,n):\r\n for i in range(0,N-2**j+1):\r\n f=self.table[i][j-1]\r\n s=self.table[i+2**(j-1)][j-1]\r\n self.table[i][j]=self.merge_func(f,s)\r\n\r\n def query(self,s,t):\r\n b=t-s+1\r\n m=b.bit_length()-1\r\n return self.merge_func(self.table[s][m],self.table[t-2**m+1][m])\r\n\r\nclass BinaryTrie:\r\n class node:\r\n def __init__(self,val):\r\n self.left = None\r\n self.right = None\r\n self.max = val\r\n\r\n def __init__(self):\r\n self.root = self.node(-10**15)\r\n\r\n def append(self,key,val):\r\n pos = self.root\r\n for i in range(29,-1,-1):\r\n pos.max = max(pos.max,val)\r\n if key>>i & 1:\r\n if pos.right is None:\r\n pos.right = self.node(val)\r\n pos = pos.right\r\n else:\r\n pos = pos.right\r\n else:\r\n if pos.left is None:\r\n pos.left = self.node(val)\r\n pos = pos.left\r\n else:\r\n pos = pos.left\r\n pos.max = max(pos.max,val)\r\n\r\n def search(self,M,xor):\r\n res = -10**15\r\n pos = self.root\r\n for i in range(29,-1,-1):\r\n if pos is None:\r\n break\r\n\r\n if M>>i & 1:\r\n if xor>>i & 1:\r\n if pos.right:\r\n res = max(res,pos.right.max)\r\n pos = pos.left\r\n else:\r\n if pos.left:\r\n res = max(res,pos.left.max)\r\n pos = pos.right\r\n else:\r\n if xor>>i & 1:\r\n pos = pos.right\r\n else:\r\n pos = pos.left\r\n\r\n if pos:\r\n res = max(res,pos.max)\r\n return res\r\n\r\ndef solveequation(edge,ans,n,m):\r\n #edge=[[to,dire,id]...]\r\n x=[0]*m\r\n used=[False]*n\r\n for v in range(n):\r\n if used[v]:\r\n continue\r\n y = dfs(v)\r\n if y!=0:\r\n return False\r\n return x\r\n\r\n def dfs(v):\r\n used[v]=True\r\n r=ans[v]\r\n for to,dire,id in edge[v]:\r\n if used[to]:\r\n continue\r\n y=dfs(to)\r\n if dire==-1:\r\n x[id]=y\r\n else:\r\n x[id]=-y\r\n r+=y\r\n return r\r\n\r\nclass Matrix():\r\n mod=10**9+7\r\n\r\n def set_mod(m):\r\n Matrix.mod=m\r\n\r\n def __init__(self,L):\r\n self.row=len(L)\r\n self.column=len(L[0])\r\n self._matrix=L\r\n for i in range(self.row):\r\n for j in range(self.column):\r\n self._matridigit[i][j]%=Matrix.mod\r\n\r\n def __getitem__(self,item):\r\n if type(item)==int:\r\n raise IndexError(\"you must specific row and column\")\r\n elif len(item)!=2:\r\n raise IndexError(\"you must specific row and column\")\r\n\r\n i,j=item\r\n return self._matridigit[i][j]\r\n\r\n def __setitem__(self,item,val):\r\n if type(item)==int:\r\n raise IndexError(\"you must specific row and column\")\r\n elif len(item)!=2:\r\n raise IndexError(\"you must specific row and column\")\r\n\r\n i,j=item\r\n self._matridigit[i][j]=val\r\n\r\n def __add__(self,other):\r\n if (self.row,self.column)!=(other.row,other.column):\r\n raise SizeError(\"sizes of matrixes are different\")\r\n\r\n res=[[0 for j in range(self.column)] for i in range(self.row)]\r\n for i in range(self.row):\r\n for j in range(self.column):\r\n res[i][j]=self._matridigit[i][j]+other._matridigit[i][j]\r\n res[i][j]%=Matrix.mod\r\n return Matrix(res)\r\n\r\n def __sub__(self,other):\r\n if (self.row,self.column)!=(other.row,other.column):\r\n raise SizeError(\"sizes of matrixes are different\")\r\n\r\n res=[[0 for j in range(self.column)] for i in range(self.row)]\r\n for i in range(self.row):\r\n for j in range(self.column):\r\n res[i][j]=self._matridigit[i][j]-other._matridigit[i][j]\r\n res[i][j]%=Matrix.mod\r\n return Matrix(res)\r\n\r\n def __mul__(self,other):\r\n if type(other)!=int:\r\n if self.column!=other.row:\r\n raise SizeError(\"sizes of matrixes are different\")\r\n\r\n res=[[0 for j in range(other.column)] for i in range(self.row)]\r\n for i in range(self.row):\r\n for j in range(other.column):\r\n temp=0\r\n for k in range(self.column):\r\n temp+=self._matridigit[i][k]*other._matrix[k][j]\r\n res[i][j]=temp%Matrix.mod\r\n return Matrix(res)\r\n else:\r\n n=other\r\n res=[[(n*self._matridigit[i][j])%Matrix.mod for j in range(self.column)] for i in range(self.row)]\r\n return Matrix(res)\r\n\r\n def __pow__(self,m):\r\n if self.column!=self.row:\r\n raise MatrixPowError(\"the size of row must be the same as that of column\")\r\n\r\n n=self.row\r\n res=Matrix([[int(i==j) for i in range(n)] for j in range(n)])\r\n while m:\r\n if m%2==1:\r\n res=res*self\r\n self=self*self\r\n m//=2\r\n return res\r\n\r\n def __str__(self):\r\n res=[]\r\n for i in range(self.row):\r\n for j in range(self.column):\r\n res.append(str(self._matridigit[i][j]))\r\n res.append(\" \")\r\n res.append(\"\\n\")\r\n res=res[:len(res)-1]\r\n return \"\".join(res)\r\n\r\nfrom collections import deque\r\nclass Dinic:\r\n def __init__(self, N):\r\n self.N = N\r\n self.G = [[] for i in range(N)]\r\n\r\n def add_edge(self, fr, to, cap):\r\n forward = [to, cap, None]\r\n forward[2] = backward = [fr, 0, forward]\r\n self.G[fr].append(forward)\r\n self.G[to].append(backward)\r\n\r\n def add_multi_edge(self, v1, v2, cap1, cap2):\r\n edge1 = [v2, cap1, None]\r\n edge1[2] = edge2 = [v1, cap2, edge1]\r\n self.G[v1].append(edge1)\r\n self.G[v2].append(edge2)\r\n\r\n def bfs(self, s, t):\r\n self.level = level = [None]*self.N\r\n deq = deque([s])\r\n level[s] = 0\r\n G = self.G\r\n while deq:\r\n v = deq.popleft()\r\n lv = level[v] + 1\r\n for w, cap, _ in G[v]:\r\n if cap and level[w] is None:\r\n level[w] = lv\r\n deq.append(w)\r\n return level[t] is not None\r\n\r\n def dfs(self, v, t, f):\r\n if v == t:\r\n return f\r\n level = self.level\r\n for e in self.it[v]:\r\n w, cap, rev = e\r\n if cap and level[v] < level[w]:\r\n d = self.dfs(w, t, min(f, cap))\r\n if d:\r\n e[1] -= d\r\n rev[1] += d\r\n return d\r\n return 0\r\n\r\n def flow(self, s, t):\r\n flow = 0\r\n INF = 10**9 + 7\r\n G = self.G\r\n while self.bfs(s, t):\r\n *self.it, = map(iter, self.G)\r\n f = INF\r\n while f:\r\n f = self.dfs(s, t, INF)\r\n flow += f\r\n return flow\r\n\r\nclass SegmentTree:\r\n def __init__(self, init_val, segfunc, ide_ele):\r\n n = len(init_val)\r\n self.segfunc = segfunc\r\n self.ide_ele = ide_ele\r\n self.num = 1 << (n - 1).bit_length()\r\n self.tree = [ide_ele] * 2 * self.num\r\n self.size = n\r\n for i in range(n):\r\n self.tree[self.num + i] = init_val[i]\r\n for i in range(self.num - 1, 0, -1):\r\n self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])\r\n\r\n def update(self, k, x):\r\n k += self.num\r\n self.tree[k] = x\r\n while k > 1:\r\n k >>= 1\r\n self.tree[k] = self.segfunc(self.tree[2*k],self.tree[2*k+1])\r\n\r\n def query(self, l, r):\r\n if r==self.size:\r\n r = self.num\r\n\r\n res = self.ide_ele\r\n\r\n l += self.num\r\n r += self.num\r\n right = []\r\n while l < r:\r\n if l & 1:\r\n res = self.segfunc(res, self.tree[l])\r\n l += 1\r\n if r & 1:\r\n right.append(self.tree[r-1])\r\n l >>= 1\r\n r >>= 1\r\n\r\n for y in right[::-1]:\r\n res = self.segfunc(res,y)\r\n return res\r\n\r\nimport sys,random,bisect\r\nfrom collections import deque,defaultdict\r\nfrom heapq import heapify,heappop,heappush\r\nfrom itertools import permutations\r\nfrom math import gcd,log\r\n\r\ninput = lambda :sys.stdin.buffer.readline()\r\nmi = lambda :map(float,input().split())\r\nli = lambda :list(mi())\r\n\r\nmod = 998244353\r\n\r\nd = [0 for i in range(10**6+1)]\r\nfor i in range(1,10**6+1):\r\n for j in range(i,10**6+1,i):\r\n d[j] += 1\r\n\r\nn = int(input())\r\ndp = [0 for i in range(n+1)]\r\ndp[1] = 1\r\ndp[0] = 1\r\nimos = [0 for i in range(n+1)]\r\nimos[0],imos[1] = 1,2\r\nfor i in range(2,n+1):\r\n dp[i] = d[i] - 1\r\n dp[i] += imos[i-1]\r\n dp[i] %= mod\r\n imos[i] = dp[i] + imos[i-1]\r\n imos[i] %= mod\r\n\r\nprint(dp[n])\r\n"}, {"source_code": "n,a,b,i=int(input())+1,0,0,1;d=[0]*n\r\nwhile i<n:\r\n for j in range(i,n,i):d[j]+=1\r\n a=b%998244353+d[i];b+=a;i+=1\r\nprint(a)"}, {"source_code": "MOD_NUM = 998244353\r\n\r\nN = 1000000\r\ndp = [0]*(1+N)\r\nA = [0]*(1+N)\r\ndp[0] = A[0] = 1\r\nCD = [0]*(1+N)\r\n\r\nfor x in range(1,1+N):\r\n for y in range(x, 1+N, x):\r\n CD[y] += 1\r\n\r\nfor k in range(1,N+1):\r\n dp[k] += A[k-1]\r\n dp[k] += CD[k]-1\r\n A[k] = A[k-1] + dp[k]\r\n A[k] %= MOD_NUM\r\n dp[k] %= MOD_NUM\r\n\r\nprint(dp[int(input())])\r\n"}, {"source_code": "import time\r\n\r\nstart_time = time.time()\r\ndef TIME_(): print(time.time()-start_time)\r\n\r\nimport os, sys\r\nfrom io import BytesIO, IOBase\r\nfrom types import GeneratorType\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import defaultdict as dd, deque as dq, Counter as dc\r\nimport math, string, heapq as h\r\nBUFSIZE = 8192\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n import os\r\n self.os = os\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n self.os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef getInt(): return int(input())\r\ndef getStrs(): return input().split()\r\ndef getInts(): return list(map(int,input().split()))\r\ndef getStr(): return input()\r\ndef listStr(): return list(input())\r\ndef getMat(n): return [getInts() for _ in range(n)]\r\ndef getBin(): return list(map(int,list(input())))\r\ndef isInt(s): return '0' <= s[0] <= '9'\r\ndef ceil_(a,b): return a//b + (a%b > 0)\r\n\r\nMOD = 998244353\r\nLIM = 2*10**6+1\r\nfacs = [0]*(LIM+1)\r\n\r\ndef primes(n):\r\n for i in range(2,n):\r\n if not min_div[i]:\r\n for j in range(i,n,i):\r\n min_div[j] = i\r\n return\r\n\r\nmin_div = [0]*(LIM+1)\r\nmin_div[1] = 1\r\nprimes(LIM+1)\r\nfacs[1] = 1\r\n\r\nfor i in range(2,LIM+1):\r\n facs[i] = 1\r\n j = i\r\n while j > 1:\r\n x = min_div[j]\r\n c = 1\r\n j //= x\r\n while min_div[j] == x:\r\n c += 1\r\n j //= x\r\n new = []\r\n facs[i] += c*facs[i]\r\n \r\nans = [0]*(LIM+1)\r\ncurr_sum = 0\r\nfor i in range(2,LIM+1,2):\r\n ans[i] = (curr_sum + facs[i//2]) % MOD\r\n curr_sum = (curr_sum + ans[i]) % MOD\r\n\"\"\"\r\ndp[N] = dp[N-2] + sum(dp[f] for all factors f of N//2\r\n\"\"\"\r\n\r\ndef solve():\r\n N = getInt()\r\n return ans[2*N]\r\n \r\n#for _ in range(getInt()):\r\nprint(solve())\r\n#solve()\r\n\r\n#TIME_()"}, {"source_code": "#from math import ceil\nimport sys\ninput=sys.stdin.readline\n\n# Python3 program to count\n# number of factors\n# of an array of integers\nMAX = 1000001\n \n# array to store\n# prime factors\nfactor = [0]*(MAX + 1)\n \n# function to generate all\n# prime factors of numbers\n# from 1 to 10^6\ndef generatePrimeFactors():\n factor[1] = 1\n \n # Initializes all the\n # positions with their value.\n for i in range(2,MAX):\n factor[i] = i\n \n # Initializes all\n # multiples of 2 with 2\n for i in range(4,MAX,2):\n factor[i] = 2\n \n # A modified version of\n # Sieve of Eratosthenes\n # to store the smallest\n # prime factor that divides\n # every number.\n i = 3\n while(i * i < MAX):\n # check if it has\n # no prime factor.\n if (factor[i] == i):\n # Initializes of j\n # starting from i*i\n j = i * i;\n while(j < MAX):\n # if it has no prime factor\n # before, then stores the\n # smallest prime divisor\n if (factor[j] == j):\n factor[j] = i\n j += i\n i+=1\n \n# function to calculate\n# number of factors\ndef calculateNoOFactors(n):\n if (n == 1 ):\n return 1\n ans = 1\n \n # stores the smallest\n # prime number that\n # divides n\n dup = factor[n]\n \n # stores the count of\n # number of times a\n # prime number divides n.\n c = 1\n \n # reduces to the next\n # number after prime\n # factorization of n\n j = int(n / factor[n])\n \n # false when prime\n # factorization is done\n while (j > 1):\n # if the same prime\n # number is dividing\n # n, then we increase\n # the count\n if (factor[j] == dup):\n c += 1\n \n # if its a new prime factor\n # that is factorizing n,\n # then we again set c=1 and\n # change dup to the new prime\n # factor, and apply the formula\n # explained above.\n else:\n dup = factor[j]\n ans = ans * (c + 1)\n c = 1\n \n # prime factorizes\n # a number\n j = int(j / factor[j])\n \n # for the last\n # prime factor\n ans = ans * (c + 1)\n \n return ans\n\n#t=int(input())\nt=1\nfor i in range(t):\n generatePrimeFactors()\n n=int(input())\n ans=0\n #a=input()\n #w,h,n=map(int,input().split())\n \n dp=[0 for x in range(n+1)]\n dp[0]=0\n dp[1]=1\n s=1\n \n for i in range(2,n+1):\n dp[i]=(s+calculateNoOFactors(i))%998244353\n s=(s+dp[i])%998244353\n \n print(dp[n])"}, {"source_code": "# Python3 program to count\r\n# Python3 program to count\r\n# number of factors\r\n# of an array of integers\r\nMAX = 1000001;\r\n \r\n# array to store\r\n# prime factors\r\nfactor = [0]*(MAX + 1);\r\n \r\n# function to generate all\r\n# prime factors of numbers\r\n# from 1 to 10^6\r\ndef generatePrimeFactors():\r\n factor[1] = 1;\r\n \r\n # Initializes all the\r\n # positions with their value.\r\n for i in range(2,MAX):\r\n factor[i] = i;\r\n \r\n # Initializes all\r\n # multiples of 2 with 2\r\n for i in range(4,MAX,2):\r\n factor[i] = 2;\r\n \r\n # A modified version of\r\n # Sieve of Eratosthenes\r\n # to store the smallest\r\n # prime factor that divides\r\n # every number.\r\n i = 3;\r\n while(i * i < MAX):\r\n # check if it has\r\n # no prime factor.\r\n if (factor[i] == i):\r\n # Initializes of j\r\n # starting from i*i\r\n j = i * i;\r\n while(j < MAX):\r\n # if it has no prime factor\r\n # before, then stores the\r\n # smallest prime divisor\r\n if (factor[j] == j):\r\n factor[j] = i;\r\n j += i;\r\n i+=1;\r\n \r\n# function to calculate\r\n# number of factors\r\ndef calculateNoOFactors(n):\r\n if (n == 1):\r\n return 1;\r\n ans = 1;\r\n \r\n # stores the smallest\r\n # prime number that\r\n # divides n\r\n dup = factor[n];\r\n \r\n # stores the count of\r\n # number of times a\r\n # prime number divides n.\r\n c = 1;\r\n \r\n # reduces to the next\r\n # number after prime\r\n # factorization of n\r\n j = int(n / factor[n]);\r\n \r\n # false when prime\r\n # factorization is done\r\n while (j > 1):\r\n # if the same prime\r\n # number is dividing\r\n # n, then we increase\r\n # the count\r\n if (factor[j] == dup):\r\n c += 1;\r\n \r\n # if its a new prime factor\r\n # that is factorizing n,\r\n # then we again set c=1 and\r\n # change dup to the new prime\r\n # factor, and apply the formula\r\n # explained above.\r\n else:\r\n dup = factor[j];\r\n ans = ans * (c + 1);\r\n c = 1;\r\n \r\n # prime factorizes\r\n # a number\r\n j = int(j / factor[j]);\r\n \r\n # for the last\r\n # prime factor\r\n ans = ans * (c + 1);\r\n \r\n return ans;\r\n# Driver Code\r\n \r\nif __name__ == \"__main__\":\r\n \r\n \r\n# generate prime factors\r\n# of number upto 10^6\r\n generatePrimeFactors()\r\n a = [10, 30, 100, 450, 987]\r\n q = len(a)\r\n for i in range (0,q):\r\n pass\r\n \r\n# This code is contributed\r\n# by mits.\r\nn=int(input())\r\nl=[0,1,3,6]\r\nalp=calculateNoOFactors(3)\r\nif n>3:\r\n for i in range(4,n+1):\r\n k=calculateNoOFactors(i)\r\n l.append(((2*l[i-1])+k-alp)%998244353)\r\n alp=k\r\n print(l[-1])\r\nelse:print(l[n])\r\n"}, {"source_code": "from collections import defaultdict\r\nfrom itertools import accumulate\r\nfrom bisect import bisect_left\r\nfrom collections import deque\r\nfrom collections import Counter\r\nimport sys\r\ninput = sys.stdin.readline\r\n'''\r\nfor CASES in range(int(input())):\r\nn, m = map(int, input().split())\r\nn = int(input())\r\nA = list(map(int, input().split()))\r\nS = input().strip()\r\nsys.stdout.write(\" \".join(map(str,ANS))+\"\\n\")\r\n'''\r\ninf = 100000000000000000 # 1e17\r\nmod = 998244353\r\n\r\n\r\n\r\n\r\nn = int(input())\r\nif n==1:\r\n print(1)\r\n sys.exit(0)\r\n\r\ndp=[0]*(n+1)\r\nf=[0]*(n+1)\r\n\r\nf[0]=1\r\nf[1]=1\r\ndp[0]=0\r\ndp[1]=1\r\nsumf=0\r\nsumdp=1\r\n\r\n\r\n#print(\"!\")\r\nlast=[0]*(2*n+1)\r\nfor i in range(2,2*n+1):\r\n if i%2==0:\r\n j=i+i\r\n while j<=2*n:\r\n last[j]+=1\r\n last[j]%=mod\r\n j=j+i\r\n#print(last)\r\n\r\n\r\nfor i in range(2,n+1):\r\n sumf+=f[i-2]\r\n sumf%=mod\r\n\r\n dp[i]=sumf+last[i*2]\r\n dp[i]%=mod\r\n\r\n sumdp+=dp[i] # \u6240\u6709\u88f8\u9732\u7684\u76f4\u63a5\u5f80\u4e0a\u9762\u5305\u4e1c\u897f\r\n sumdp%=mod\r\n\r\n f[i]=sumdp\r\n f[i]%=mod\r\nprint(f[n])\r\n\r\n#\r\n# dp=[0]*(n+1)\r\n# f=[0]*(n+1)\r\n# sumdp=[0]*(n+1)\r\n# sumf=[0]*(n+1)\r\n#\r\n# sumdp[1]=3\r\n# sumf[0]=2\r\n# sumf[1]=2\r\n# for i in range(2,n+1):\r\n# sumdp[i]=sumdp[i-1]\r\n# sumf[i]=sumf[i-1]\r\n#\r\n# f[i]=sumdp[i]\r\n# dp[i]=sumf[i-2]\r\n#\r\n# sumdp[i]+=dp[i]\r\n# sumf[i]+=f[i]\r\n"}, {"source_code": "# by the authority of GOD author: manhar singh sachdev #\r\n\r\ndef some_random_function():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\ndef some_random_function5():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\nimport os,sys\r\nfrom io import BytesIO,IOBase\r\nfrom array import array\r\n# 2D list [[0]*large_index for _ in range(small_index)]\r\n# switch from integers to floats if all integers are \u2264 2^52 and > 32 bit int\r\n# fast mod https://github.com/cheran-senthil/PyRival/blob/master/pyrival/misc/mod.py\r\n\r\ndef main():\r\n mod = 998244353\r\n n = int(input())\r\n dp = array('i',[1]+[0]*n)\r\n fac = [0 for _ in range(n+1)]\r\n for i in range(1,n//2+1):\r\n for j in range(i+i,n+1,i):\r\n fac[j] += 1\r\n su = 1\r\n for i in range(1,n+1):\r\n dp[i] = (su+fac[i])%mod\r\n su = (su+dp[i])%mod\r\n print(dp[n])\r\n\r\n#Fast IO Region\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef some_random_function1():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\ndef some_random_function2():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\ndef some_random_function3():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\ndef some_random_function4():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\ndef some_random_function6():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\ndef some_random_function7():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\ndef some_random_function8():\r\n \"\"\"due to the fast IO template, my code gets caught in\r\n plag check for no reason. That is why, I am making\r\n random functions\"\"\"\r\n x = 10\r\n x *= 100\r\n i_dont_know = x\r\n why_am_i_writing_this = x*x\r\n print(i_dont_know)\r\n print(why_am_i_writing_this)\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\n\r\nN = int(input())\r\nprime_list = [] # \ufffdf\ufffd\ufffd\ufffd\ufffd\ufffdX\ufffdg\r\nlpf = [0] * (N + 1) # \ufffd\u014f\ufffd\ufffdf\ufffd\ufffd\ufffd\ufffd\r\nfor i in range(2, N + 1):\r\n if not lpf[i]:\r\n lpf[i] = i\r\n prime_list.append(i)\r\n a = lpf[i]\r\n for p in prime_list:\r\n if p > a or p * i > N: break\r\n lpf[p*i] = p\r\n\r\nlpf_cnt = [1] * (N + 1)\r\ndiv_cnt = [1] * (N + 1)\r\nfor i in range(2, N + 1):\r\n p = lpf[i]\r\n ip = i // p\r\n if ip % p:\r\n div_cnt[i] = div_cnt[ip] * 2\r\n else:\r\n lpf_cnt[i] = lpf_cnt[ip] + 1\r\n div_cnt[i] = div_cnt[ip] // lpf_cnt[i] * (lpf_cnt[i] + 1)\r\n\r\nP = 998244353\r\nx = 0\r\nfor i in range(1, N + 1):\r\n y = div_cnt[i] + x\r\n x = (x + y) % P\r\nprint(y)\r\n\r\n\r\n"}, {"source_code": "N=int(input())\r\nmod=998244353\r\nD=[0]*(N+1)\r\nfor i in range(1,N+1):\r\n for j in range(i,N+1,i):\r\n D[j]+=1\r\nX=[]\r\nfor i in range(N):\r\n X.append(D[i+1]-D[i])\r\nx=1\r\nDP=[0]*(N+1)\r\nfor i in range(N):\r\n DP[i+1]=(DP[i]*2+X[i])%mod\r\nprint(DP[N])\r\n"}, {"source_code": "n = int(input())\r\nmod = 998244353\r\ndp = [0 for i in range(n + 1)]\r\nfor i in range(1, n + 1):\r\n for j in range(i, n + 1, i):\r\n dp[j] += 1\r\n if dp[j] > mod: dp[j] -= mod\r\nsm = 0\r\nfor i in range(1, n + 1):\r\n dp[i] += sm\r\n if dp[i] > mod : dp[i] -= mod\r\n sm += dp[i]\r\n if sm > mod: sm -= mod\r\nprint(dp[n])"}, {"source_code": "def main():\n n = int(raw_input())\n dp = [0] * (n + 1)\n s = x = 1\n mod = 998244353\n for i in xrange(2, n + 1):\n x = (dp[i] + s + 2) % mod\n s += x\n if s >= mod:\n s -= mod\n j = i * 2\n while j <= n:\n dp[j] += 1\n j += i\n print x\nmain()\n"}, {"source_code": "MAX = 1000000\nfact = [1 for i in range(MAX+1)]\n\nfor i in range(2,MAX+1):\n if fact[i]>1: continue \n base = i\n power = 1\n while base<MAX+1:\n for j in range(base,MAX+1,base):\n fact[j] *= power+1\n fact[j] = fact[j] // power\n base *= i\n power += 1\n\n\n#print(fact) \n\n\n\n\n\n\n\n\n\nM = 998244353\n\nn = int(input())\n\nif n<2:\n print(n)\n exit()\n\n\n\n\n\ndp = [0]*(n+1)\n\ndp[1] = 1\n\ntot = 1\nfor i in range(2,n+1):\n dp[i] = tot\n \n dp[i] += fact[i]\n dp[i] = dp[i]%M\n\n\n tot += dp[i]\n tot = tot%M\n\n \n\n#print(dp)\nprint(dp[-1]) \n\n\n\n"}, {"source_code": "n,a,b,i=int(input())+1,0,0,1\r\nd=[0]*n\r\nwhile i<n:\r\n j=i\r\n while j<n:d[j]+=1;j+=i\r\n a=b%998244353+d[i];b+=a;i+=1\r\nprint(a)"}, {"source_code": "n,a,b=int(input())+1,0,0\r\nd=[0]*n\r\nfor i in range(1,n):\r\n for j in range(i,n,i):d[j]+=1\r\n a=b%998244353+d[i]\r\n b+=a\r\nprint(a)\r\n"}, {"source_code": "import math\r\ndef D(N):\r\n\tif N == 1: return 1\r\n\tMOD = 998244353\r\n\tprev = 1\r\n\tfor i in range (2, N + 1):\r\n\t\tcur = (prev + s[i]) % MOD\r\n\t\tif i != N:\r\n\t\t\tcur = (cur + prev) % MOD\r\n\t\tprev = cur\r\n\t\r\n\treturn (cur % MOD)\r\n\r\n\r\nN = int(input())\r\ns = [2] * (N + 1)\r\ns[1] = 1\r\nfor i in range(2, N + 1):\r\n for j in range(2 * i, N + 1, i):\r\n s[j] += 1\r\n\r\nprint(D(N))\r\n"}, {"source_code": "mod=998244353\r\nn=int(input())\r\nd=[1]*(n+1)\r\nfor i in range(2,n+1):\r\n if d[i]==1:\r\n for j in range(i,n+1,i):\r\n c=0\r\n t=j+0\r\n while j%i==0:\r\n j//=i\r\n c+=1\r\n d[t]*=c+1\r\na=0\r\ns=0\r\nfor i in range(1,n+1):\r\n a=(s+d[i])%mod\r\n s=(s+a)%mod\r\nprint(a)\r\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\ninf = float('inf')\n\n\ndef getInt():\n return int(input())\n\n\ndef getStr():\n return input().strip()\n\n\ndef getList(split=True):\n s = getStr()\n if split:\n s = s.split()\n return map(int, s)\n\n# t = getInt()\nt = 1\n\nM = 998244353 \ndef solve():\n # if choose every <= 0 -> valid\n # contain at most one positive iterger\n # and if it is then it shoudl be the smallest one\n n = getInt()\n dp = [0] * (n+1)\n for i in range(1,n+1):\n for j in range(i, n+1, i):\n dp[j] += 1\n c = 0\n for i in range(1, n+1):\n dp[i] += c\n dp[i] %= M\n c += dp[i]\n c %= M\n print(dp[-1])\n\n\n\n \n \n\nfor _ in range(t):\n solve()\n\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\ninf = float('inf')\n\n\ndef getInt():\n return int(input())\n\n\ndef getStr():\n return input().strip()\n\n\ndef getList(split=True):\n s = getStr()\n if split:\n s = s.split()\n return map(int, s)\n\n# t = getInt()\nt = 1\n\nM = 998244353 \ndef solve():\n # if choose every <= 0 -> valid\n # contain at most one positive iterger\n # and if it is then it shoudl be the smallest one\n n = getInt()\n dp = [0] * (n+1)\n for i in range(2, 2*n+1, 2):\n for j in range(i, 2*n+1, i):\n dp[j//2] += 1\n c = 0\n for i in range(1, n+1):\n dp[i] += c\n dp[i] %= M\n c += dp[i]\n c %= M\n print(dp[-1])\n\n\n\n \n \n\nfor _ in range(t):\n solve()\n\n"}, {"source_code": "# Legends Always Come Up with Solution\r\n# Author: Manvir Singh\r\n\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\ndef main():\r\n n=int(input())\r\n p,mod,su,ans=[0]*(n+1),998244353,0,0\r\n for i in range(1,n+1,1):\r\n for j in range(i,n+1,i):\r\n p[j]+=1\r\n for i in range(1,n+1):\r\n ans=(su+p[i])%mod\r\n su=(su+ans)%mod\r\n print(ans)\r\n\r\n# region fastio\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "n = int(input())\r\n\r\ndp = [0 for i in range(n+1)]\r\n\r\n#Python program to compute divisors of all numbers up to n efficiently\r\nfor i in range(1, n+1):\r\n for j in range(2*i, n+1, i):\r\n dp[j]+=1\r\n\r\n\r\ns = 1\r\nfor i in range(1, n+1):\r\n dp[i] = (dp[i] + s )%998244353; s += dp[i]\r\n\r\nprint(dp[n])"}, {"source_code": "n = int(input())\r\n\r\ndp = [0 for i in range(n+1)]\r\n\r\n#Python program to compute divisors of all numbers up to n efficiently\r\nfor i in range(1, n+1):\r\n for j in range(2*i, n+1, i):\r\n dp[j]+=1\r\n\r\n\r\ns = 1\r\nfor i in range(1, n+1):\r\n\r\n dp[i] = (dp[i] + s )%998244353 \r\n s += dp[i]\r\n\r\nprint(dp[n])\r\n\r\n#Python ki maa ki"}, {"source_code": "n = int(input())\r\n\r\ndp = [0 for i in range(n+1)]\r\n\r\n#Python program to compute divisors of all numbers up to n efficiently\r\nfor i in range(1, n+1):\r\n for j in range(2*i, n+1, i):\r\n dp[j]+=1\r\n\r\n\r\ns = 1\r\nfor i in range(1, n+1):\r\n\r\n dp[i] = (dp[i] + s )%998244353 \r\n s += dp[i]\r\n\r\nprint(dp[n])"}, {"source_code": "import math\n\ndef solve(N):\n mod_val = 998244353\n if N == 1:\n return 1\n dyn = [0]*(N + 1)\n dyn[2] = 1\n dyn[0] = 1\n dyn2 = sieve2(N+1)\n for n2 in range(4, N+1, 2):\n dyn[n2] = (2*dyn[n2-2] + dyn2[n2] - dyn2[n2-2]) % mod_val\n return dyn[N]\n\ndef get_even_div_primes(n2, primes):\n l=[]\n if n2 in primes:\n return 2\n for p in primes:\n cur = 0\n while n2 % p == 0:\n cur += 1\n n2 = n2//p\n if cur > 0:\n l.append(cur)\n if (n2 == 1) or (n2 in primes):\n break\n tot = 1\n for x in l:\n tot = tot * (x+1)\n return tot\n\ndef get_even_div(mod_val, n2):\n new_dyn = (1 - (n2 % 2))\n for i in range(2, int(math.sqrt(n2)) + 1):\n if i ** 2 == n2:\n new_dyn = (new_dyn + (1 - (i % 2))) % mod_val\n elif n2 % i == 0:\n one_two = (1 - i % 2) + (1 - (n2 // i) % 2)\n # if i%2 == 0:\n # print(f\"{n2} all same {i}\")\n # if (n2//i) %2 == 0:\n # print(f\"{n2} all same {n2//i}\")\n\n new_dyn = (new_dyn + one_two) % mod_val\n return new_dyn\n\ndef sieve2(max_p):\n div_count = [0]*(max_p+1)\n for i in range(2, max_p,2):\n for j in range(1, max_p//i + 1):\n div_count[i*j] += 1\n return div_count\n# sieve of the eratosthenes\ndef sieve(max_p):\n primes = [2, 3]\n for i in range(5,max_p):\n is_prime=True\n for p in primes:\n if i%p == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes\n\nif __name__ == \"__main__\":\n N = int(input())\n # import time\n # a = time.time()\n res = solve(2*N)\n # b=time.time()\n # print(b-a)\n print(res, flush=True)"}, {"source_code": "# Python3 program to count\r\n# Python3 program to count\r\n# number of factors\r\n# of an array of integers\r\nMAX = 1000001;\r\n \r\n# array to store\r\n# prime factors\r\nfactor = [0]*(MAX + 1);\r\n \r\n# function to generate all\r\n# prime factors of numbers\r\n# from 1 to 10^6\r\ndef generatePrimeFactors():\r\n factor[1] = 1;\r\n \r\n # Initializes all the\r\n # positions with their value.\r\n for i in range(2,MAX):\r\n factor[i] = i;\r\n \r\n # Initializes all\r\n # multiples of 2 with 2\r\n for i in range(4,MAX,2):\r\n factor[i] = 2;\r\n \r\n # A modified version of\r\n # Sieve of Eratosthenes\r\n # to store the smallest\r\n # prime factor that divides\r\n # every number.\r\n i = 3;\r\n while(i * i < MAX):\r\n # check if it has\r\n # no prime factor.\r\n if (factor[i] == i):\r\n # Initializes of j\r\n # starting from i*i\r\n j = i * i;\r\n while(j < MAX):\r\n # if it has no prime factor\r\n # before, then stores the\r\n # smallest prime divisor\r\n if (factor[j] == j):\r\n factor[j] = i;\r\n j += i;\r\n i+=1;\r\n \r\n# function to calculate\r\n# number of factors\r\ndef calculateNoOFactors(n):\r\n if (n == 1):\r\n return 1;\r\n ans = 1;\r\n \r\n # stores the smallest\r\n # prime number that\r\n # divides n\r\n dup = factor[n];\r\n \r\n # stores the count of\r\n # number of times a\r\n # prime number divides n.\r\n c = 1;\r\n \r\n # reduces to the next\r\n # number after prime\r\n # factorization of n\r\n j = int(n / factor[n]);\r\n \r\n # false when prime\r\n # factorization is done\r\n while (j > 1):\r\n # if the same prime\r\n # number is dividing\r\n # n, then we increase\r\n # the count\r\n if (factor[j] == dup):\r\n c += 1;\r\n \r\n # if its a new prime factor\r\n # that is factorizing n,\r\n # then we again set c=1 and\r\n # change dup to the new prime\r\n # factor, and apply the formula\r\n # explained above.\r\n else:\r\n dup = factor[j];\r\n ans = ans * (c + 1);\r\n c = 1;\r\n \r\n # prime factorizes\r\n # a number\r\n j = int(j / factor[j]);\r\n \r\n # for the last\r\n # prime factor\r\n ans = ans * (c + 1);\r\n \r\n return ans;\r\n# Driver Code\r\n \r\nif __name__ == \"__main__\":\r\n \r\n \r\n# generate prime factors\r\n# of number upto 10^6\r\n generatePrimeFactors()\r\n a = [10, 30, 100, 450, 987]\r\n q = len(a)\r\n for i in range (0,q):\r\n pass\r\n \r\n# This code is contributed\r\n# by mits.\r\nn=int(input())\r\nl=[0,1,3,6]\r\nalp=calculateNoOFactors(3)\r\nif n>3:\r\n for i in range(4,n+1):\r\n k=calculateNoOFactors(i)\r\n l.append(((2*l[i-1])+k-alp)%998244353)\r\n alp=k\r\n print(l[-1])\r\nelse:print(l[n])"}, {"source_code": "import sys\r\nimport os.path\r\nfrom collections import *\r\nimport math\r\nimport bisect\r\n\r\nif (os.path.exists('input.txt')):\r\n sys.stdin = open(\"input.txt\", \"r\")\r\n sys.stdout = open(\"output.txt\", \"w\")\r\n\r\n##########################################################\r\n\r\nn = 10 ** 6\r\nmod = 998244353\r\n\r\ndivisors = [0 for i in range(n + 1)]\r\n\r\nfor i in range(1, n + 1):\r\n for j in range(i, n + 1, i):\r\n divisors[j] += 1\r\n\r\ndp = [0 for i in range(n + 1)]\r\n\r\ndp[1] = 1\r\ndp[2] = 3\r\n\r\ntotal = 4\r\n\r\nn = int(input())\r\n\r\nfor i in range(3,n + 1):\r\n dp[i] = (total + divisors[i]) % mod\r\n total = (total + dp[i]) % mod\r\n\r\nprint(dp[n])\r\n\r\n##########################################################\r\n"}, {"source_code": "factorCnts=[1]*1000005\r\nfor i in range(1,1000005):\r\n for j in range(2*i,1000005,i):\r\n factorCnts[j]+=1\r\n\r\n\r\ndef main():\r\n \r\n MOD=998244353\r\n \r\n n=int(input())\r\n dp=[0]*(n+1)\r\n dp[1]=1\r\n prefixSum=1\r\n for i in range(2,n+1):\r\n dp[i]=prefixSum+2\r\n # add 1 for every factor excluding 1 and n\r\n dp[i]+=(factorCnts[i]-2)\r\n dp[i]%=MOD\r\n prefixSum+=dp[i]\r\n prefixSum%=MOD\r\n print(dp[n])\r\n \r\n return\r\n\r\nimport sys\r\ninput=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)\r\n# input=lambda: sys.stdin.readline().rstrip(\"\\r\\n\") #FOR READING STRING/TEXT INPUTS.\r\n\r\ndef oneLineArrayPrint(arr):\r\n print(' '.join([str(x) for x in arr]))\r\ndef multiLineArrayPrint(arr):\r\n print('\\n'.join([str(x) for x in arr]))\r\ndef multiLineArrayOfArraysPrint(arr):\r\n print('\\n'.join([' '.join([str(x) for x in y]) for y in arr]))\r\n \r\ndef readIntArr():\r\n return [int(x) for x in input().split()]\r\n# def readFloatArr():\r\n# return [float(x) for x in input().split()]\r\n\r\ndef makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])\r\n dv=defaultValFactory;da=dimensionArr\r\n if len(da)==1:return [dv() for _ in range(da[0])]\r\n else:return [makeArr(dv,da[1:]) for _ in range(da[0])]\r\n \r\ndef queryInteractive(i,j):\r\n print('? {} {}'.format(i,j))\r\n sys.stdout.flush()\r\n return int(input())\r\n \r\ndef answerInteractive(ans):\r\n print('! {}'.format(' '.join([str(x) for x in ans])))\r\n sys.stdout.flush()\r\n \r\ninf=float('inf')\r\nMOD=10**9+7\r\n# MOD=998244353\r\n \r\n \r\nfor _abc in range(1):\r\n main()"}, {"source_code": "# Parsa's Humongous Tree\r\ndef problem_c():\r\n num_tests = int(input())\r\n for i in range(num_tests):\r\n num_vertices = int(input())\r\n bounds = []\r\n for j in range(num_vertices):\r\n bounds.append([int(s) for s in input().split()])\r\n edge_lists = [[] for j in range(num_vertices)]\r\n for j in range(num_vertices - 1):\r\n u, v = [int(s) for s in input().split()]\r\n u -= 1\r\n v -= 1\r\n edge_lists[u].append(v)\r\n edge_lists[v].append(u)\r\n beauty_memo = [[None, None] for j in range(num_vertices)] # 0 for low, 1 for high\r\n def best_beauty(idx, parent_idx, parent_hl):\r\n if beauty_memo[idx][parent_hl] is not None:\r\n return beauty_memo[idx][parent_hl]\r\n best = 0\r\n if parent_idx != -1:\r\n parent_val = bounds[parent_idx][parent_hl]\r\n for hl in [0, 1]:\r\n child_beauty = sum([best_beauty(c_idx, idx, hl) for c_idx in edge_lists[idx] if c_idx != parent_idx])\r\n parent_beauty = abs(parent_val - bounds[idx][hl])\r\n best = max(child_beauty + parent_beauty, best)\r\n else:\r\n for hl in [0, 1]:\r\n child_beauty = sum([best_beauty(c_idx, idx, hl) for c_idx in edge_lists[idx] if c_idx != parent_idx])\r\n best = max(child_beauty, best)\r\n beauty_memo[idx][parent_hl] = best\r\n return best\r\n print(best_beauty(0, -1, 0))\r\n\r\n# Kavi on Pairing Duty\r\ndef problem_d():\r\n mod = 998244353\r\n num_pairs = int(input())\r\n small_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,\r\n 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,\r\n 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,\r\n 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,\r\n 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283,\r\n 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,\r\n 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431,\r\n 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491,\r\n 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571,\r\n 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641,\r\n 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709,\r\n 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787,\r\n 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859,\r\n 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,\r\n 947, 953, 967, 971, 977, 983, 991, 997]\r\n f_nums = [i for i in range(num_pairs + 1)]\r\n num_factors = [1 for i in range(num_pairs + 1)]\r\n for prime in small_primes:\r\n max_multiple = num_pairs // prime\r\n for i in range(1, max_multiple + 1):\r\n power = 1\r\n ppower = prime\r\n while f_nums[prime * i] % (ppower * prime) == 0:\r\n ppower *= prime\r\n power += 1\r\n f_nums[prime * i] //= ppower\r\n num_factors[prime * i] *= power + 1\r\n for i in range(1, num_pairs + 1):\r\n if f_nums[i] != 1:\r\n num_factors[i] *= 2\r\n f_nums[i] = 1\r\n total = 0\r\n for i in range(1, num_pairs):\r\n total += num_factors[i] * pow(2, num_pairs - 1 - i, mod)\r\n total += num_factors[num_pairs]\r\n\r\n print(total % mod)\r\n\r\nproblem_d()"}, {"source_code": "n = int(input())\r\n\r\nfactors = [0]*(n+1)\r\n\r\nfor i in range(1,n+1):\r\n for j in range(i,n+1,i):\r\n factors[j] += 1\r\n\r\nprefix,ans = 0,0\r\nmod = 998244353\r\n\r\nfor i in range(1,n+1):\r\n ans = (factors[i] + prefix)%mod\r\n prefix = (prefix+ans)%mod\r\n\r\nprint(ans)"}, {"source_code": "import sys\r\ninput = sys.stdin.buffer.readline\r\n\r\nn = int(input())\r\ndp = [0] * (n + 1)\r\n\r\nfor i in range(1, n + 1):\r\n\tfor j in range(i, n + 1, i):\r\n\t\tdp[j] = dp[j] + 1\r\n\r\nmod = 998244353\r\nsum = 1\r\nfor i in range(2, n + 1):\r\n\tdp[i] = (dp[i] + sum) % mod\r\n\tsum = (sum + dp[i]) % mod\r\nprint(dp[n])"}, {"source_code": "from sys import stdin, stdout\r\nimport math\r\n\r\n\r\ndef read(): return stdin.readline().strip()\r\ndef read_int(): return [int(i) for i in read().split()]\r\ndef write(s): stdout.write(s)\r\n\r\n\r\nM = 998244353\r\nn, = read_int()\r\ndp = [1 for _ in range(n + 1)]\r\n\r\nnum_div = [0 for _ in range(n + 1)]\r\nfor i in range(1, n + 1):\r\n j = i\r\n while j <= n:\r\n num_div[j] += 1\r\n j += i\r\n\r\nsum = 0\r\nfor i in range(2, n + 1):\r\n # one large 1 2n\r\n sum += dp[i - 1]\r\n dp[i] = (sum + num_div[i]) % M\r\n\r\nprint(dp[n])"}, {"source_code": "import sys,os,io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nmaxn = 1000001\r\nprimes = []\r\nspf = [0]*(maxn+1)\r\nfor i in range(2, maxn):\r\n if spf[i]==0:\r\n spf[i]=i\r\n primes.append(i)\r\n j = 0\r\n while j < len(primes) and primes[j] <= spf[i] and primes[j]*i <= maxn:\r\n spf[primes[j]*i] = primes[j]\r\n j += 1\r\n\r\ncntPrime = [0]*(maxn+1)\r\nfor i in range(2,maxn+1):\r\n lpf = i//spf[i]\r\n cntPrime[i] += cntPrime[lpf] + (spf[lpf] != spf[i])\r\n\r\ndef divisors(n):\r\n pf = []\r\n mod = 998244353\r\n while n > 1:\r\n if len(pf) == 0 or pf[-1][0] != spf[n]:\r\n pf.append([spf[n],1])\r\n else:\r\n pf[-1][1] += 1\r\n \r\n n //= spf[n]\r\n \r\n ans = 1\r\n for i in pf:\r\n ans *= (i[1]+1)\r\n ans %= mod\r\n return ans\r\ndp = [0,1]\r\ncurr = 1\r\nmod = 998244353\r\nfor i in range (2,1000001):\r\n x = divisors(i)\r\n curr += curr + x\r\n curr%=mod\r\n dp.append(curr)\r\nn = int(input())\r\nprint((dp[n]-dp[n-1])%mod)"}, {"source_code": "M = 998244353\r\ndivisors = [0 for i in range((10**6)+1)]\r\nans = [0 for i in range((10**6+1))]\r\ndivisors[1] = 1\r\nfor i in range(2,1000001):\r\n for j in range(i,1000001,i):\r\n divisors[j] += 1\r\n\r\nn = int(input())\r\nsom = 1\r\nans[1] = 1\r\nfor i in range(2,n+1):\r\n # print(i,divisors[i],\"hI\")\r\n cnt = (som+divisors[i]+1)%M\r\n ans[i] = cnt\r\n som = (som+cnt)%M\r\n\r\nprint(ans[n])"}, {"source_code": "\r\nmod = 998244353\r\nn,a=int(input())+1,0\r\nd=[0]*n\r\nfor i in range(1,n):\r\n\tfor j in range(i,n,i):\r\n\t\td[j]+=1\r\n\t\td[j]%=mod\r\nfor i in range(1,n-1):\r\n\ta=((a<<1)%mod+d[i])%mod\r\nprint(a+d[n-1])"}, {"source_code": "def read_int():\r\n return int(input())\r\n \r\n\r\nn = read_int()\r\n\r\nmod = 998244353 \r\n\r\n\r\ndef add(a, b):\r\n return (a + b) % mod\r\n\r\n\r\ndef get_ans():\r\n pref = 0\r\n ways = [0] * (2 * n + 1)\r\n for d in range(2, len(ways), 2):\r\n for j in range(d, len(ways), d):\r\n ways[j] += 1\r\n \r\n for k in range(2, len(ways), 2):\r\n ways[k] += pref\r\n ways[k] %= mod\r\n \r\n pref += ways[k]\r\n pref %= mod\r\n \r\n return ways[2 * n]\r\n \r\nprint(get_ans())\r\n \r\n \r\n "}, {"source_code": "n=int(input())\r\ndp=[0]*(n+1)\r\nfor i in range(1,n+1):\r\n for j in range(2*i,n+1,i):\r\n dp[j]+=1\r\nq=1\r\nfor i in range(1,n+1):\r\n dp[i]+=q\r\n dp[i]=dp[i]%998244353\r\n q=(q+dp[i])%998244353\r\nprint(dp[n])"}, {"source_code": "MOD=998244353\r\n\r\ndvcnt=[0 for _ in range(1000005)]\r\n\r\nfor i in range(1,len(dvcnt)):\r\n for j in range(i,len(dvcnt),i):\r\n dvcnt[j]+=1\r\n\r\nn=int(input())\r\ndp=[0,1]\r\nfor i in range(n):\r\n dp.append(2*dp[-1]+dvcnt[i+2]-dvcnt[i+1])\r\n dp[-1]%=MOD\r\nprint((dp[n]+MOD)%MOD)\r\n \r\n"}, {"source_code": "#!/usr/bin/env python3\r\nfrom sys import stdin\r\nfrom collections import deque\r\nfrom heapq import heappush, heappop, heapify\r\nfrom bisect import bisect_left, bisect_right\r\nimport math\r\nfrom random import randint\r\n\r\nMOD = 998244353\r\n\r\n\r\ndef solve(tc):\r\n n = int(stdin.readline().strip())\r\n\r\n mem = [0 for i in range(int(1e6)+1)]\r\n tot = 0\r\n for i in range(1, n+1):\r\n for j in range(i, n+1, i):\r\n mem[j] += 1\r\n\r\n mem[i] += mem[i-1] + tot\r\n mem[i] %= MOD\r\n\r\n tot += mem[i-1]\r\n tot %= MOD\r\n\r\n ans = mem[n]\r\n ans %= MOD\r\n print(ans)\r\n\r\n\r\ntcs = 1\r\n# tcs = int(stdin.readline().strip())\r\ntc = 1\r\nwhile tc <= tcs:\r\n solve(tc)\r\n tc += 1\r\n"}, {"source_code": "from sys import stdin, stdout\r\nimport math, bisect\r\nfrom collections import Counter, deque, defaultdict\r\n\r\nL = lambda: list(map(int, stdin.readline().strip().split()))\r\nI = lambda: int(stdin.readline().strip())\r\nS = lambda: stdin.readline().strip()\r\nC = lambda: stdin.readline().strip().split()\r\n\r\n\r\ndef pr(a): print(\" \".join(list(map(str, a))))\r\n\r\nMod=998244353\r\n\r\ndp = [0 for i in range(1000010)]\r\ndp[0]=1\r\n\r\nfor i in range(1, 1000010):\r\n for j in range(i+i, 1000010,i):\r\n dp[j]+=1\r\n\r\n# print(1)\r\n\r\n\r\nn=I()\r\nn1=n+1\r\nS=1\r\nfor i in range(1,n1):\r\n dp[i] = (dp[i] + S ) % Mod;\r\n S = (S + dp[i]) % Mod;\r\nprint(dp[n])"}, {"source_code": "n = int(input())\r\ndp = [0 for _ in range(n+1)]\r\nfor i in range(1, n+1):\r\n for j in range(i*2, n+1, i):\r\n dp[j] += 1\r\ndp[0] = 1\r\nsm = 1\r\nmd = 998244353\r\nfor i in range(1, n+1):\r\n dp[i] = (dp[i] + sm) % md\r\n sm = (dp[i] + sm) % md\r\nprint(dp[n])"}, {"source_code": "import sys\r\nfrom heapq import *\r\ninput=sys.stdin.readline\r\n\r\nmod=998244353\r\nn=int(input())\r\ncnt=[0]*(n+1)\r\nfor i in range(1,n+1):\r\n for j in range(i,n+1,i):\r\n## print(i,n+1,j)\r\n cnt[j]+=1\r\n\r\nans=0\r\nsm=0\r\nfor i in range(n):\r\n ans=(sm+cnt[i+1])%mod\r\n sm=(sm+ans)%mod\r\nprint(ans)\r\n"}, {"source_code": "n,a,b,i=int(input())+1,0,0,1;d=[0]*n\r\nwhile i<n:\r\n for j in range(i,n,i):d[j]+=1\r\n a=b%998244353+d[i];b+=a;i+=1\r\nprint(a)"}, {"source_code": "n = int(input())\r\ns=1\r\n## algo to find number of divisors of n numbers and store them in an array \r\nfactor = [0 for i in range(n+1)]\r\n\r\nfor i in range(1, n+1):\r\n for j in range(2*i,n+1,i):\r\n factor[j]+=1\r\n## algo ends here\r\na = [0 for i in range(0,n+1)]\r\nfor i in range(1,n+1):\r\n a[i]=(s+factor[i])%998244353\r\n s=s+a[i]\r\nprint(a[n])"}, {"source_code": "#------------------------template--------------------------#\r\nimport os\r\nimport sys\r\nimport math\r\nimport collections\r\nimport functools\r\nimport itertools\r\n# from fractions import *\r\nimport heapq\r\nimport bisect\r\nfrom io import BytesIO, IOBase\r\ndef vsInput():\r\n sys.stdin = open('input.txt', 'r')\r\n sys.stdout = open('output.txt', 'w')\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nALPHA='abcde'\r\nM = 10**9 + 7\r\nEPS = 1e-6\r\ndef Ceil(a,b): return a//b+int(a%b>0)\r\ndef INT():return int(input())\r\ndef STR():return input()\r\ndef INTs():return tuple(map(int,input().split()))\r\ndef ARRINT():return [int(i) for i in input().split()]\r\ndef ARRSTR():return [i for i in input().split()]\r\n \r\n \r\n#-------------------------code---------------------------#\r\n\r\n\r\nMOD = 998244353\r\nn = INT()\r\n\r\ndp = [0]*(n+1)\r\ndp[0] = 1\r\n\r\nfor i in range(1, n+1):\r\n j = 2*i\r\n while j < n+1:\r\n dp[j] += 1\r\n j += i\r\n\r\ntmp = 1\r\nfor i in range(1, n+1):\r\n dp[i] += tmp\r\n dp[i] %= MOD\r\n tmp += dp[i]\r\n tmp %= MOD\r\n\r\nprint(dp[-1])"}, {"source_code": "n = int(input())\nmod = 998244353\n\nD, dp = [0 for i in range(n+1)],[0 for i in range(n+1)]\nfor i in range(1,n):\n for j in range(i<<1,n+1,i):\n D[j] += 1\n\nsum = dp[0] = 1\nfor i in range(1,n+1):\n dp[i] = (sum + D[i]) % mod\n sum = (sum+dp[i]) % mod\n\nprint(dp[n])\n"}, {"source_code": "import sys\r\ninput = sys.stdin.buffer.readline\r\ndef im():\r\n return map(int,input().split())\r\ndef ii():\r\n return int(input())\r\ndef il():\r\n return list(map(int,input().split()))\r\ndef ins():\r\n return input()[:-1]\r\n\r\nN = int(1e6)+5\r\nmod = 998244353\r\ndivisors = [1]*N\r\ni=2\r\nwhile i<=N:\r\n j=i\r\n while j<N:\r\n divisors[j]+=1\r\n divisors[j]%=mod\r\n j+=i\r\n i+=1\r\n \r\nn = ii()\r\nans = pre = 1\r\nfor i in range(2,n+1):\r\n ans = (pre+divisors[i])%mod\r\n pre += ans\r\n pre%=mod\r\nprint(ans%mod)"}, {"source_code": "n = int(input())\r\nMOD = 998244353\r\ndp = [0]*(n+1)\r\ns = 1\r\ndp[1] = 0\r\nfor i in range(1,n+1):\r\n\tfor j in range(i+i,n+1,i):\r\n\t\tdp[j]+=1\r\n\ta = (s+dp[i])%MOD\r\n\ts=(s+a)%MOD \t\r\nprint(a%MOD)\r\n"}, {"source_code": "mod=998244353\r\ndef add(a,b):\r\n return (a%mod+b%mod)%mod\r\nn=int(input())\r\ndivisiors=[0]*(n+1)\r\nfor i in range(1,n+1):\r\n for j in range(i,n+1,i):\r\n divisiors[j]=add(divisiors[j],1)\r\n#print(divisiors)\r\ndp=[0]*(2*n+1)\r\npre=[0]*(2*n+1)\r\ndp[0]=1\r\npre[0]=1\r\nfor i in range(2,2*n+1,2):\r\n dp[i]=add(pre[i-2],(divisiors[i//2]-1))\r\n pre[i]=add(pre[i-2],dp[i])\r\nprint(dp[2*n]%mod)\r\n"}, {"source_code": "from sys import stdin,stdout\r\nfrom math import gcd,sqrt,factorial,pi,inf\r\nfrom collections import deque,defaultdict\r\nfrom bisect import bisect,bisect_left\r\nfrom time import time\r\nfrom itertools import permutations as per\r\ninput=stdin.readline\r\nR=lambda:map(int,input().split())\r\nI=lambda:int(input())\r\nS=lambda:input().rstrip('\\r\\n')\r\nL=lambda:list(R())\r\nP=lambda x:stdout.write(str(x)+'\\n')\r\nlcm=lambda x,y:(x*y)//gcd(x,y)\r\nnCr=lambda x,y:(f[x]*inv((f[y]*f[x-y])%N))%N\r\ninv=lambda x:pow(x,N-2,N)\r\nsm=lambda x:(x**2+x)//2\r\nN=10**9+7\r\n\r\nmod=998244353\r\nn=I()\r\ndp=[0]*(10**6+5)\r\ndp[1]=1\r\nfor i in range(2,10**6+5):\r\n\tj=i+i\r\n\twhile j<10**6+5:\r\n\t\tdp[j]+=1\r\n\t\tj+=i\r\nln=1\r\nif n==1:exit(print(1))\r\nfor i in range(n-1):\r\n\tln+=1\r\n\tdp[ln]+=(2+dp[ln-1])%mod\r\n\tif ln==n:exit(print(dp[ln]))\r\n\tdp[ln]+=dp[ln-1]\r\n\tdp[ln]%=mod"}, {"source_code": "mod=998244353\r\ndef add(a,b):\r\n return (a%mod+b%mod)%mod\r\nn=int(input())\r\ndivisiors=[0]*(n+1)\r\nfor i in range(1,n+1):\r\n for j in range(i,n+1,i):\r\n divisiors[j]=add(divisiors[j],1)\r\n#print(divisiors)\r\ndp=[0]*(2*n+1)\r\npre=[0]*(2*n+1)\r\ndp[0]=1\r\npre[0]=1\r\nfor i in range(2,2*n+1,2):\r\n dp[i]=add(pre[i-2],(divisiors[i//2]-1))\r\n pre[i]=add(pre[i-2],dp[i])\r\nprint(dp[2*n]%mod)\r\n"}, {"source_code": "#########################################################################################################\\\r\n#########################################################################################################\r\n###################################The_Apurv_Rathore#####################################################\r\n#########################################################################################################\r\n#########################################################################################################\r\nimport sys,os,io\r\nfrom sys import stdin\r\nfrom math import log, gcd, ceil\r\nfrom collections import defaultdict, deque, Counter\r\nfrom heapq import heappush, heappop\r\nfrom bisect import bisect_left , bisect_right\r\nimport math \r\n\r\n\r\nalphabets = list('abcdefghijklmnopqrstuvwxyz')\r\n\r\n\r\ndef isPrime(x):\r\n for i in range(2,x):\r\n if i*i>x:\r\n break\r\n if (x%i==0):\r\n return False\r\n return True\r\ndef ncr(n, r, p): \r\n num = den = 1\r\n for i in range(r):\r\n num = (num * (n - i)) % p\r\n den = (den * (i + 1)) % p\r\n return (num * pow(den,p - 2, p)) % p\r\ndef primeFactors(n): \r\n l = []\r\n while n % 2 == 0: \r\n l.append(2)\r\n n = n / 2\r\n for i in range(3,int(math.sqrt(n))+1,2): \r\n while n % i== 0: \r\n l.append(int(i))\r\n n = n / i \r\n if n > 2: \r\n l.append(n)\r\n c = dict(Counter(l))\r\n return list(set(l))\r\n # return c\r\n\r\ndef power(x, y, p) : \r\n\tres = 1\r\n\tx = x % p \r\n\tif (x == 0) : \r\n\t\treturn 0\r\n\twhile (y > 0) : \r\n\t\tif ((y & 1) == 1) : \r\n\t\t\tres = (res * x) % p \r\n\t\ty = y >> 1\t # y = y/2 \r\n\t\tx = (x * x) % p \t\t\r\n\treturn res \r\n\r\n#____________________GetPrimeFactors in log(n)________________________________________\r\ndef sieveForSmallestPrimeFactor():\r\n MAXN = 100001\r\n spf = [0 for i in range(MAXN)]\r\n spf[1] = 1\r\n for i in range(2, MAXN):\r\n spf[i] = i\r\n for i in range(4, MAXN, 2):\r\n spf[i] = 2\r\n for i in range(3, math.ceil(math.sqrt(MAXN))):\r\n if (spf[i] == i):\r\n for j in range(i * i, MAXN, i): \r\n if (spf[j] == j):\r\n spf[j] = i\r\n return spf\r\ndef getPrimeFactorizationLOGN(x):\r\n spf = sieveForSmallestPrimeFactor()\r\n ret = list()\r\n while (x != 1):\r\n ret.append(spf[x])\r\n x = x // spf[x] \r\n return ret\r\n#____________________________________________________________\r\n\r\n\r\n\r\ndef SieveOfEratosthenes(n): \r\n #time complexity = nlog(log(n))\r\n prime = [True for i in range(n+1)]\r\n p = 2\r\n while (p * p <= n):\r\n if (prime[p] == True):\r\n for i in range(p * p, n+1, p):\r\n prime[i] = False\r\n p += 1\r\n return prime\r\ndef si():\r\n return input()\r\ndef divideCeil(n,x):\r\n #return (n+1)//x\r\n if (n%x==0):\r\n return n//x\r\n return n//x+1\r\ndef ii():\r\n return int(input())\r\ndef li():\r\n return list(map(int,input().split()))\r\n\r\n#__________________________TEMPLATE__________________OVER_______________________________________________________\r\n\r\n\r\nif(os.path.exists('input.txt')):\r\n sys.stdin = open(\"input.txt\",\"r\") ; sys.stdout = open(\"output.txt\",\"w\") \r\nelse:\r\n input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\n\r\n\r\n\r\n\r\ndef solve():\r\n n = ii()\r\n dp = [0]*(n+1)\r\n\r\n for i in range(1,n+1):\r\n for j in range(i,n+1,i):\r\n dp[j]+=1\r\n \r\n \r\n dp[1]=1\r\n # print(divisor)\r\n S = 1\r\n MOD = 998244353\r\n for i in range(2,n+1):\r\n dp[i] = (dp[i] + S) % MOD\r\n S = (S + dp[i]) % MOD\r\n # print(dp)\r\n print(dp[n])\r\n\r\nt = 1\r\n# t = ii()\r\nfor _ in range(t):\r\n solve()\r\n"}, {"source_code": "n,a,b=int(input())+1,0,0;d=[0]*n\r\nfor i in range(1,n):\r\n for j in range(i,n,i):d[j]+=1\r\n a=(b+d[i])%998244353;b+=a\r\nprint(a)"}, {"source_code": "\r\nmod = 998244353\r\n\r\n\r\ndef solve():\r\n\r\n\r\n n=int(input())\r\n factors = [0] * (n + 1)\r\n\r\n for i in range(1, n + 1):\r\n for j in range(i, n + 1, i):\r\n factors[j] += 1\r\n\r\n res=0\r\n s=0\r\n\r\n for i in range(n + 1):\r\n res = s + factors[i]\r\n s += res\r\n res = res % mod\r\n s = s % mod\r\n print(res)\r\n\r\n\r\n\r\n\r\nsolve()"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n#for _ in range(int(input())):\r\nn=int(input()) \r\ndp=[0 for i in range(n+1)]\r\nfor i in range(1,1+n):\r\n j=2*i\r\n while j<n+1:\r\n dp[j]+=1\r\n j+=i\r\n#print(dp)\r\ncurr=1\r\ndp[0]=1\r\nfor i in range(1,n+1):\r\n dp[i]+=curr\r\n dp[i]%=998244353 \r\n curr+=dp[i]\r\n curr%=998244353 \r\nprint(dp[-1])"}, {"source_code": "import sys\r\nimport bisect\r\nfrom bisect import bisect_left as lb\r\ninput_=lambda: sys.stdin.readline().strip(\"\\r\\n\")\r\nfrom math import log\r\nfrom math import gcd\r\nfrom math import atan2,acos\r\nfrom random import randint\r\nsa=lambda :input_()\r\nsb=lambda:int(input_())\r\nsc=lambda:input_().split()\r\nsd=lambda:list(map(int,input_().split()))\r\nsflo=lambda:list(map(float,input_().split()))\r\nse=lambda:float(input_())\r\nsf=lambda:list(input_())\r\nflsh=lambda: sys.stdout.flush()\r\n#sys.setrecursionlimit(10**6)\r\nmod=10**9+7\r\nmod1=998244353\r\ngp=[]\r\ncost=[]\r\ndp=[]\r\nmx=[]\r\nans1=[]\r\nans2=[]\r\nspecial=[]\r\nspecnode=[]\r\na=0\r\nkthpar=[]\r\ndef dfs(root,par):\r\n if par!=-1:\r\n dp[root]=dp[par]+1\r\n for i in range(1,20):\r\n if kthpar[root][i-1]!=-1:\r\n kthpar[root][i]=kthpar[kthpar[root][i-1]][i-1]\r\n for child in gp[root]:\r\n if child==par:continue\r\n kthpar[child][0]=root\r\n dfs(child,root)\r\nans=0\r\ndef hnbhai(tc):\r\n n=sb()\r\n ans=[0]*(2*n+2)\r\n for i in range(2,2*n+1):\r\n if i%2==0:\r\n for j in range(i,2*n+1,i):\r\n ans[j]+=1\r\n dp=[0]*(n+1)\r\n dp[0]=1\r\n dp[1]=1\r\n s=1\r\n for i in range(2,n+1):\r\n dp[i]=(s+ans[2*i])%mod1\r\n s=(s+dp[i])%mod1\r\n print(dp[n])\r\nfor _ in range(1):\r\n hnbhai(_+1)\r\n"}, {"source_code": "import math\r\nfrom collections import Counter\r\nfrom itertools import permutations, combinations\r\nimport fractions\r\nimport sys\r\n\r\nmod = 998244353\r\n\r\ndef solve():\r\n n = int(input())\r\n ans = [0]*(n+1)\r\n for i in range(1, n+1):\r\n for j in range(i+i, n+1, i):\r\n ans[j] += 1\r\n \r\n ans[0] = 1\r\n s = 1\r\n for i in range(1, n+1):\r\n ans[i] = (ans[i] + s)%mod\r\n s = (s + ans[i])%mod\r\n print(ans[n])\r\n \r\nsolve()\r\n"}, {"source_code": "MOD=998244353 \r\nn = int(input())\r\nNmax = 1+n\r\ndp =[1 for n in range (Nmax)]\r\nfor i in range (2,Nmax):\r\n for k in range (i,Nmax,i):\r\n dp[k]+=1\r\n\r\nsum_ =1\r\n# first 1<-->2n \r\n# then 1<-->2n-1, 2<-->2n \r\n# then 1<-->2n-3, 2<-->2n-2, 3<-->2n-1, 4<-->2n\r\n# then ....\r\n# then all equal segment\r\n\r\nfor k in range (2,Nmax):\r\n dp[k] = (sum_ + dp[k]) % MOD\r\n sum_ = (sum_ + dp[k]) % MOD\r\n \r\nprint (dp[n])"}, {"source_code": "import math\r\nfrom collections import defaultdict\r\nimport math\r\n\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom types import GeneratorType\r\nfrom collections import defaultdict\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\n\r\ndef bootstrap(f, stack=[]):\r\n def wrappedfunc(*args, **kwargs):\r\n if stack:\r\n return f(*args, **kwargs)\r\n else:\r\n to = f(*args, **kwargs)\r\n while True:\r\n if type(to) is GeneratorType:\r\n stack.append(to)\r\n to = next(to)\r\n else:\r\n stack.pop()\r\n if not stack:\r\n break\r\n to = stack[-1].send(to)\r\n return to\r\n return wrappedfunc\r\n\r\n\r\ndef power(x, y, p):\r\n res = 1 # Initialize result\r\n\r\n # Update x if it is more\r\n # than or equal to p\r\n x = x % p\r\n\r\n if (x == 0):\r\n return 0\r\n\r\n while (y > 0):\r\n\r\n # If y is odd, multiply\r\n # x with result\r\n if ((y & 1) == 1):\r\n res = (res * x) % p\r\n\r\n # y must be even now\r\n y = y >> 1 # y = y/2\r\n x = (x * x) % p\r\n\r\n return res\r\n\r\np=998244353\r\n\r\ntot=[0 for i in range(10**6+1)]\r\nfor i in range(1,10**6+1):\r\n for j in range(i,10**6+1,i):\r\n tot[j]=(tot[j]+1)%p\r\n\r\n\r\nn=int(input())\r\ns=1\r\ndp=[0,1]\r\nval=1\r\nfor i in range(2,n+1):\r\n val=(s+tot[i])%p\r\n\r\n s=(s+val)%p\r\n\r\nprint(val%p)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import math,io,os\r\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\ndef divisors(n):\r\n\r\n i=1\r\n l =[]\r\n while(i*i<=n):\r\n if(n%i==0):\r\n l.append(i)\r\n if(i!=n//i):\r\n l.append(n//i)\r\n i+=1\r\n \r\n return l\r\n\r\ndef Sieve(n):\r\n divisors = [0 for i in range(n+1)]\r\n p = 2\r\n # while (p * p <= n):\r\n \r\n # # If prime[p] is not\r\n # # changed, then it is a prime\r\n # if (prime[p] == 0):\r\n \r\n # # Update all multiples of p\r\n # for i in range(p * p, n+1, p):\r\n # prime[i] += 1\r\n # p += 1\r\n\r\n for i in range(1,n+1,1):\r\n for j in range(i,n+1,i):\r\n divisors[j] += 1\r\n \r\n return divisors\r\n\r\nsieve = Sieve(10**6)\r\n\r\ndef func(n):\r\n\r\n global dp,mod,sieve\r\n\r\n dp[0]=0\r\n dp[1]=1\r\n dp[2]=3\r\n\r\n prev = 4\r\n\r\n \r\n\r\n for i in range(3,n+1):\r\n dp[i] = (prev + sieve[i] )%mod\r\n prev += dp[i]\r\n prev = prev%mod\r\n \r\n # print(sieve[n])\r\n return dp[n]\r\n\r\n\r\nn = int(input())\r\nmod = 998244353 \r\ndp=[-1]*(10**6+ 1)\r\n\r\nprint(func(n)%mod)"}, {"source_code": "s = [2 for i in range(10 ** 6 + 1)]\r\ns[1] = 1\r\nfor i in range(2, 10 ** 6 + 1):\r\n for j in range(2 * i, 10 ** 6 + 1, i):\r\n s[j] += 1\r\ndp = [[-1 for j in range(2)] for i in range(10 ** 6 + 1)]\r\nfor i in range(10 ** 6 + 1):\r\n dp[i][0] = dp[i][1] = 0\r\ndp[1][0] = dp[1][1] = 1\r\nfor i in range(2, 10 ** 6 + 1):\r\n dp[i][0] = dp[i - 1][1] + s[i]\r\n dp[i][1] = dp[i - 1][1] + dp[i][0]\r\n dp[i][0] %= 998244353\r\n dp[i][1] %= 998244353\r\nn = int(input())\r\nprint(dp[n][0])"}, {"source_code": "phi = [0 for i in range(10 ** 6 + 1)]\r\nfor i in range(1, 10**6+1):\r\n for j in range(2 * i, 10 ** 6 + 1, i):\r\n phi[j] += 1\r\nmod = 998244353\r\nn = int(input())\r\nif n == 1:\r\n print(1)\r\n exit()\r\nn = 2 * n\r\ndp = [0 for i in range(n + 1)]\r\ndp[2] = 1\r\ndp[4] = 3\r\ns = 4\r\nfor i in range(6, n + 1, 2):\r\n dp[i] = (s + (phi[i // 2] + 1)) % mod\r\n s = (s + dp[i]) % mod\r\nprint(dp[n])"}, {"source_code": "import math\r\nmod = 998244353\r\nfacts = [2 for i in range(1000001)]\r\nfacts[1] = 1\r\nsum = 1\r\ntemp = 1\r\nans = [0 for i in range(1000001)]\r\nfor i in range(2,1000001,1):\r\n temp = (sum + facts[i])%mod\r\n sum = (sum + temp)%mod\r\n facts[i] = temp\r\n for j in range(2*i,1000001,i):\r\n facts[j]+=1\r\nn = int(input())\r\nprint(facts[n])"}, {"source_code": "d=[]\r\nfor i in range(int(1e6+1)): \r\n row=[] \r\n for j in range(2): \r\n row.append(0) \r\n d.append(row) \r\nL=[]\r\nfor i in range(int(1e6+1)):\r\n L.append(2)\r\nL[1]=1\r\nfor i in range(2,int(1e6+1),1):\r\n for k in range(2*i,int(1e6+1),i):\r\n L[k]+=1\r\nfor i in range(int(1e6+1)):\r\n d[i][1]=0\r\n d[i][0]=0\r\nd[1][1]=1\r\nd[1][0]=1\r\nfor i in range(2,int(1e6+1),1):\r\n d[i][0]=L[i]+d[i-1][1]\r\n d[i][1]=d[i][0]+d[i-1][1]\r\n d[i][0]%=998244353\r\n d[i][1]%=998244353\r\nm=int(input())\r\nprint(d[m][0])"}, {"source_code": "#region Header\r\n#!/usr/bin/env python3\r\n# from typing import *\r\n\r\nimport sys\r\nimport io\r\nimport math\r\nimport collections\r\nimport decimal\r\nimport itertools\r\nimport bisect\r\nimport heapq\r\n\r\n\r\ndef input():\r\n return sys.stdin.readline()[:-1]\r\n\r\n\r\n# sys.setrecursionlimit(1000000)\r\n#endregion\r\n\r\n# _INPUT = \"\"\"100\r\n# \"\"\"\r\n# sys.stdin = io.StringIO(_INPUT)\r\n\r\nMOD = 998244353\r\n\r\n\r\n\r\ndef main():\r\n N = int(input())\r\n\r\n DivCount = [0] * (N+1) \r\n D = [0] * (N+1)\r\n for i in range(2, N + 1):\r\n if D[i] == 0:\r\n D[i] = i\r\n n = i * i\r\n while n <= N:\r\n D[n] = i\r\n n += i\r\n for i in range(1, N+1):\r\n prime_counter = dict()\r\n n = i\r\n while n > 1:\r\n if D[n] in prime_counter:\r\n prime_counter[D[n]] += 1\r\n else:\r\n prime_counter[D[n]] = 1\r\n n //= D[n]\r\n v = 1\r\n for p in prime_counter:\r\n v *= (1+prime_counter[p])\r\n DivCount[i] = v\r\n\r\n\r\n S = 4\r\n\r\n Ans = [0, 1, 3]\r\n for n in range(3, N+1):\r\n v = (DivCount[n] + S) % MOD\r\n S += v\r\n Ans.append(v)\r\n print(Ans[N])\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "import sys\r\nimport io, os\r\n#input = sys.stdin.buffer.readline\r\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n\r\nmod = 998244353\r\n\r\nN = 10**6\r\n\r\ndef main():\r\n\r\n D = [0]*(N+1)\r\n for i in range(1, N+1):\r\n D[i] += 1\r\n j = 2*i\r\n while j <= N:\r\n D[j] += 1\r\n j += i\r\n\r\n F = [0]*(N+1)\r\n F[1] = 1\r\n F[2] = 3\r\n s = 4\r\n for i in range(3, N+1):\r\n #F[i] = F[i-1]+F[i-2]+2\r\n F[i] = s+D[i]\r\n F[i] %= mod\r\n s += F[i]\r\n\r\n n = int(input())\r\n #print(D[0:10])\r\n print(F[n])\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "n=int(input())\r\n # arr=list(map(int,input().split(' ')))\r\nmod=998244353\r\narr=[0]*(n+1)\r\n# seive=[0 for i in range(n+1)]\r\nfor i in range(1,n+1):\r\n for j in range(i,n+1,i):\r\n arr[j]=(arr[j]+1)%mod\r\nprearr=1\r\nfor i in range(2,n+1):\r\n arr[i]=(prearr+arr[i])%mod\r\n prearr=(prearr+arr[i])%mod\r\nprint(int(arr[n]%mod))"}, {"source_code": "\r\nimport sys\r\n\r\nmod = 998244353\r\ndp = [0]*1000001\r\n\r\nfor i in range(1 , 1000001):\r\n j = i+i\r\n while j < 1000001:\r\n dp[j] += 1\r\n j += i\r\nsum = dp[0] = 1\r\nfor i in range(1 , 1000001):\r\n dp[i] = (dp[i] + sum) % mod\r\n sum = (sum + dp[i]) % mod\r\n\r\nn = int(input())\r\nprint(dp[n])\r\n \r\n\r\n\r\n"}], "negative_code": [{"source_code": "mod=998244353\r\nn=int(input())\r\nd=[1]*(n+1)\r\nfor i in range(1,n+1):\r\n for j in range(i,n+1,i):\r\n d[j]+=1\r\na=0\r\ns=0\r\nfor i in range(1,n+1):\r\n a=(s+d[i])%mod\r\n s=(s+a)%mod\r\nprint(a)\r\n"}, {"source_code": "#t=int(input())\r\nimport math\r\nq=998244353 \r\n# A function to print all prime factors of\r\n# a given number n\r\n# Python3 program to count\r\n# number of factors\r\n# of an array of integers\r\nMAX = 1000001\r\n \r\n# array to store\r\n# prime factors\r\nfactor = [0]*(MAX + 1)\r\n \r\n# function to generate all\r\n# prime factors of numbers\r\n# from 1 to 10^6\r\ndef generatePrimeFactors(factor):\r\n factor[1] = 1\r\n \r\n # Initializes all the\r\n # positions with their value.\r\n for i in range(2,MAX):\r\n factor[i] = i\r\n \r\n # Initializes all\r\n # multiples of 2 with 2\r\n for i in range(4,MAX,2):\r\n factor[i] = 2\r\n \r\n # A modified version of\r\n # Sieve of Eratosthenes\r\n # to store the smallest\r\n # prime factor that divides\r\n # every number.\r\n i = 3\r\n while(i * i < MAX):\r\n # check if it has\r\n # no prime factor.\r\n if (factor[i] == i):\r\n # Initializes of j\r\n # starting from i*i\r\n j = i * i\r\n while(j < MAX):\r\n # if it has no prime factor\r\n # before, then stores the\r\n # smallest prime divisor\r\n if (factor[j] == j):\r\n factor[j] = i;\r\n j += i\r\n i+=1\r\ngeneratePrimeFactors(factor)\r\nprint(factor[1])\r\n \r\n# function to calculate\r\n# number of factors\r\ndef calculateNoOFactors(n,factor):\r\n if (n == 1):\r\n return 1\r\n ans = 1\r\n \r\n # stores the smallest\r\n # prime number that\r\n # divides n\r\n dup = factor[n]\r\n \r\n # stores the count of\r\n # number of times a\r\n # prime number divides n.\r\n c = 1\r\n \r\n # reduces to the next\r\n # number after prime\r\n # factorization of n\r\n j = int(n / factor[n])\r\n \r\n # false when prime\r\n # factorization is done\r\n while (j > 1):\r\n # if the same prime\r\n # number is dividing\r\n # n, then we increase\r\n # the count\r\n if (factor[j] == dup):\r\n c += 1\r\n \r\n # if its a new prime factor\r\n # that is factorizing n,\r\n # then we again set c=1 and\r\n # change dup to the new prime\r\n # factor, and apply the formula\r\n # explained above.\r\n else:\r\n dup = factor[j];\r\n ans = ans * (c + 1)\r\n c = 1\r\n \r\n # prime factorizes\r\n # a number\r\n j = int(j / factor[j])\r\n \r\n # for the last\r\n # prime factor\r\n ans = ans * (c + 1)\r\n \r\n return ans;\r\n#print(primeFactors(289))\r\n#for _ in range(t):\r\nn=int(input())\r\nans=[0 for i in range(n)]\r\nans[0]=1\r\ns=1\r\nfor i in range(1,n):\r\n ans[i]=(s+calculateNoOFactors(i+1,factor))%q\r\n s+=ans[i]\r\nprint(ans[n-1])\r\n \r\n \r\n \r\n \r\n"}, {"source_code": "import math\n\ndef solve(N):\n mod_val = 998244353\n if N == 1:\n return 1\n dyn = [0]*(N + 1)\n dyn[2] = 1\n dyn[0] = 1\n dyn2 = sieve2(N)\n for n2 in range(4, N+1, 2):\n dyn[n2] = (2*dyn[n2-2] + dyn2[n2] - dyn2[n2-2]) % mod_val\n return dyn[N]\n\ndef get_even_div_primes(n2, primes):\n l=[]\n if n2 in primes:\n return 2\n for p in primes:\n cur = 0\n while n2 % p == 0:\n cur += 1\n n2 = n2//p\n if cur > 0:\n l.append(cur)\n if (n2 == 1) or (n2 in primes):\n break\n tot = 1\n for x in l:\n tot = tot * (x+1)\n return tot\n\ndef get_even_div(mod_val, n2):\n new_dyn = (1 - (n2 % 2))\n for i in range(2, int(math.sqrt(n2)) + 1):\n if i ** 2 == n2:\n new_dyn = (new_dyn + (1 - (i % 2))) % mod_val\n elif n2 % i == 0:\n one_two = (1 - i % 2) + (1 - (n2 // i) % 2)\n # if i%2 == 0:\n # print(f\"{n2} all same {i}\")\n # if (n2//i) %2 == 0:\n # print(f\"{n2} all same {n2//i}\")\n\n new_dyn = (new_dyn + one_two) % mod_val\n return new_dyn\n\ndef sieve2(max_p):\n div_count = [0]*(max_p+1)\n for i in range(2, max_p,2):\n for j in range(1, max_p//i + 1):\n div_count[i*j] += 1\n return div_count\n# sieve of the eratosthenes\ndef sieve(max_p):\n primes = [2, 3]\n for i in range(5,max_p):\n is_prime=True\n for p in primes:\n if i%p == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes\n\nif __name__ == \"__main__\":\n N = int(input())\n # import time\n # a = time.time()\n res = solve(2*N)\n # b=time.time()\n # print(b-a)\n print(res, flush=True)"}, {"source_code": "n = int(input())\r\ndp = [0 for _ in range(10**6+1)]\r\nprefix = [0 for _ in range(10**6+1)]\r\n\r\nmod = 998244353\r\n\r\ndp[1] = 1\r\nprefix[1] = 1\r\ndp[2] = 3\r\nprefix[2] = 4 \r\n\r\ndef new(num):\r\n cnt = 0\r\n temp = 2\r\n while not num == 1:\r\n if num % temp == 0:\r\n cnt += 1\r\n num = num // temp\r\n\r\n else:\r\n temp += 1\r\n\r\n return cnt + 2\r\n\r\nfor i in range(3,10**6+1):\r\n dp[i] = (prefix[i-1] + new(i)) % mod\r\n prefix[i] += (prefix[i-1] + dp[i]) % mod\r\n\r\n\r\nprint(dp[n])\r\n"}, {"source_code": "n = int(input())\r\ndp = [0 for _ in range(10**6+1)]\r\nprefix = [0 for _ in range(10**6+1)]\r\n\r\nmod = 998244353\r\n\r\ndp[1] = 1\r\nprefix[1] = 1\r\ndp[2] = 3\r\nprefix[2] = 4 \r\n\r\ndef new(num):\r\n if num == 3:\r\n return 2\r\n else:\r\n return 3\r\n\r\nfor i in range(3,10**6+1):\r\n dp[i] = (prefix[i-1] + new(i)) % mod\r\n prefix[i] += (prefix[i-1] + dp[i]) % mod\r\n\r\n\r\nprint(dp[n])\r\n"}, {"source_code": "#!/usr/bin/env pypy\r\nfrom __future__ import division, print_function\r\n \r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n \r\nif sys.version_info[0] < 3:\r\n from __builtin__ import xrange as range\r\n from future_builtins import ascii, filter, hex, map, oct, zip\r\n \r\nMOD = 998244353\r\n\r\n\r\n\r\n\r\n# region fastio\r\n\r\nBUFSIZE = 8192\r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\ndef print(*args, **kwargs):\r\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n at_start = True\r\n for x in args:\r\n if not at_start:\r\n file.write(sep)\r\n file.write(str(x))\r\n at_start = False\r\n file.write(kwargs.pop(\"end\", \"\\n\"))\r\n if kwargs.pop(\"flush\", False):\r\n file.flush()\r\n \r\n \r\nif sys.version_info[0] < 3:\r\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n \r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# endregion\r\ndef main():\r\n\tn = int(input())\r\n\tdp = [0] * (n+1)\r\n\ts = 1\r\n\tfor i in range(1, n+1):\r\n\t\tfor j in range(i+1, n+1, i):\r\n\t\t\tdp[j] += 1\r\n\t\ta = (s + dp[i]) % MOD\r\n\t\ts = (s+a) % MOD\r\n\tprint(a % MOD)\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.buffer.readline\r\ndef im():\r\n return map(int,input().split())\r\ndef ii():\r\n return int(input())\r\ndef il():\r\n return list(map(int,input().split()))\r\ndef ins():\r\n return input()[:-1]\r\n\r\nN = int(1e6)+5\r\nmod = 998244353\r\ndivisors = [1]*N\r\ni=2\r\nwhile i*i<=N:\r\n j=i\r\n while j<N:\r\n divisors[j]+=1\r\n divisors[j]%=mod\r\n j+=i\r\n i+=1\r\n\r\nn = ii()\r\nans = pre = 1\r\nfor i in range(2,n+1):\r\n ans = (pre+divisors[i])%mod\r\n pre += ans\r\n pre%=mod\r\nprint(ans%mod)"}, {"source_code": "import sys,os,io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nmaxn = 1000001\r\nprimes = []\r\nspf = [0]*(maxn+1)\r\nfor i in range(2, maxn):\r\n if spf[i]==0:\r\n spf[i]=i\r\n primes.append(i)\r\n j = 0\r\n while j < len(primes) and primes[j] <= spf[i] and primes[j]*i <= maxn:\r\n spf[primes[j]*i] = primes[j]\r\n j += 1\r\n\r\ncntPrime = [0]*(maxn+1)\r\nfor i in range(2,maxn+1):\r\n lpf = i//spf[i]\r\n cntPrime[i] += cntPrime[lpf] + (spf[lpf] != spf[i])\r\n\r\ndef divisors(n):\r\n pf = []\r\n mod = 998244353\r\n while n > 1:\r\n if len(pf) == 0 or pf[-1][0] != spf[n]:\r\n pf.append([spf[n],1])\r\n else:\r\n pf[-1][1] += 1\r\n \r\n n //= spf[n]\r\n \r\n ans = 1\r\n for i in pf:\r\n ans *= (i[1]+1)\r\n ans %= mod\r\n return ans\r\nprint(divisors(100))\r\ndp = [0,1]\r\ncurr = 1\r\nmod = 998244353\r\nfor i in range (2,1000001):\r\n x = divisors(i)\r\n curr += curr + x\r\n curr%=mod\r\n dp.append(curr)\r\nn = int(input())\r\nprint((dp[n]-dp[n-1])%mod)"}, {"source_code": "def solve():\r\n n=int(input())\r\n m=998244353\r\n t=max(n+1,4)\r\n f=[0]*(t)\r\n g=[0]*(t)\r\n g[1]=0\r\n g[2]=0\r\n g[3]=0\r\n for i in range(4,n+1,2):\r\n g[i]=(1+g[i//2])\r\n f[1]=1\r\n f[2]=3\r\n f[3]=6\r\n xo=10\r\n for i in range(4,n+1):\r\n f[i]=(2+g[i]+xo)\r\n xo+=(f[i])\r\n print(f[n]%m)\r\nsolve()"}, {"source_code": "from collections import defaultdict\n\nn=int(input())\nmod=998244353\nsieve=list(range(n+1))\n\nfor i in range(2,n+1):\n if i==sieve[i]:\n for j in range(i*i,n+1,i):\n if j==sieve[j]:\n sieve[j]=i\n\np_sum=1\nfor i in range(2,n+1):\n tmp=i\n cnt=defaultdict(int)\n while tmp>1:\n f=sieve[tmp]\n tmp//=f\n cnt[f]+=1\n prod=1\n for v in cnt.values():\n prod*=1+v\n if i==n:\n print(p_sum+prod)\n p_sum+=p_sum+prod\n p_sum%=mod \n\n \n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nMOD = 998244353\r\nn = int(input())\r\n\r\nd = [0]*(n+1)\r\ndp = [0]*(n+1)\r\n\r\nfor i in range(1, n+1):\r\n for j in range(1, n+1):\r\n d[j] += 1\r\n\r\ncur = 0\r\n\r\nfor i in range(1, n+1) :\r\n dp[i] = (d[i] + cur) % MOD\r\n cur = (cur + dp[i]) % MOD\r\n\r\nprint(dp[n])"}, {"source_code": "#!/usr/bin/env python3\nimport sys\nimport getpass # not available on codechef\nimport math, random\nimport functools, itertools, collections, heapq, bisect\nfrom collections import Counter, defaultdict, deque\ninput = sys.stdin.readline # to read input quickly\n\n# available on Google, AtCoder Python3, not available on Codeforces\n# import numpy as np\n# import scipy\n\nM9 = 10**9 + 7 # 998244353\nyes, no = \"YES\", \"NO\"\n# d4 = [(1,0),(0,1),(-1,0),(0,-1)]\n# d8 = [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]\n# d6 = [(2,0),(1,1),(-1,1),(-2,0),(-1,-1),(1,-1)] # hexagonal layout\nMAXINT = sys.maxsize\n\n# if testing locally, print to terminal with a different color\nOFFLINE_TEST = getpass.getuser() == \"hkmac\"\n# OFFLINE_TEST = False # codechef does not allow getpass\ndef log(*args):\n if OFFLINE_TEST:\n print('\\033[36m', *args, '\\033[0m', file=sys.stderr)\n\ndef solve(*args):\n # screen input\n if OFFLINE_TEST:\n log(\"----- solving ------\")\n log(*args)\n log(\"----- ------- ------\")\n return solve_(*args)\n\ndef read_matrix(rows):\n return [list(map(int,input().split())) for _ in range(rows)]\n\ndef read_strings(rows):\n return [input().strip() for _ in range(rows)]\n\ndef minus_one(arr):\n return [x-1 for x in arr]\n\ndef minus_one_matrix(mrr):\n return [[x-1 for x in row] for row in mrr]\n\n# ---------------------------- template ends here ----------------------------\n\n\ndef solve_():\n # your solution here\n \n return \"\"\n\n\n# for case_num in [0]: # no loop over test case\n# for case_num in range(100): # if the number of test cases is specified\nfor case_num in range(int(input())):\n\n # read line as an integer\n # k = int(input())\n\n # read line as a string\n # srr = input().strip()\n\n # read one line and parse each word as a string\n # lst = input().split()\n \n # read one line and parse each word as an integer\n # a,b,c = list(map(int,input().split()))\n # lst = list(map(int,input().split()))\n # lst = minus_one(lst)\n\n # read multiple rows\n # arr = read_strings(k) # and return as a list of str\n # mrr = read_matrix(k) # and return as a list of list of int\n # mrr = minus_one_matrix(mrr)\n\n res = solve() # include input here\n\n # print length if applicable\n # print(len(res))\n\n # parse result\n # res = \" \".join(str(x) for x in res)\n # res = \"\\n\".join(str(x) for x in res)\n # res = \"\\n\".join(\" \".join(str(x) for x in row) for row in res)\n\n # print result\n # print(\"Case #{}: {}\".format(case_num+1, res)) # Google and Facebook - case number required\n\n print(res)"}, {"source_code": "#!/usr/bin/env python3\nimport sys\nimport getpass # not available on codechef\nimport math, random\nimport functools, itertools, collections, heapq, bisect\nfrom collections import Counter, defaultdict, deque\ninput = sys.stdin.readline # to read input quickly\n\n# available on Google, AtCoder Python3, not available on Codeforces\n# import numpy as np\n# import scipy\n\nM9 = 10**9 + 7 # 998244353\nyes, no = \"YES\", \"NO\"\n# d4 = [(1,0),(0,1),(-1,0),(0,-1)]\n# d8 = [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]\n# d6 = [(2,0),(1,1),(-1,1),(-2,0),(-1,-1),(1,-1)] # hexagonal layout\nMAXINT = sys.maxsize\n\n# if testing locally, print to terminal with a different color\nOFFLINE_TEST = getpass.getuser() == \"hkmac\"\n# OFFLINE_TEST = False # codechef does not allow getpass\ndef log(*args):\n if OFFLINE_TEST:\n print('\\033[36m', *args, '\\033[0m', file=sys.stderr)\n\ndef solve(*args):\n # screen input\n if OFFLINE_TEST:\n log(\"----- solving ------\")\n log(*args)\n log(\"----- ------- ------\")\n return solve_(*args)\n\ndef read_matrix(rows):\n return [list(map(int,input().split())) for _ in range(rows)]\n\ndef read_strings(rows):\n return [input().strip() for _ in range(rows)]\n\ndef minus_one(arr):\n return [x-1 for x in arr]\n\ndef minus_one_matrix(mrr):\n return [[x-1 for x in row] for row in mrr]\n\n# ---------------------------- template ends here ----------------------------\n\n\ndef solve_():\n # your solution here\n \n return \"\"\n\n\n# for case_num in [0]: # no loop over test case\n# for case_num in range(100): # if the number of test cases is specified\nfor case_num in range(int(input())):\n\n # read line as an integer\n # k = int(input())\n\n # read line as a string\n # srr = input().strip()\n\n # read one line and parse each word as a string\n # lst = input().split()\n \n # read one line and parse each word as an integer\n # a,b,c = list(map(int,input().split()))\n # lst = list(map(int,input().split()))\n # lst = minus_one(lst)\n\n # read multiple rows\n # arr = read_strings(k) # and return as a list of str\n # mrr = read_matrix(k) # and return as a list of list of int\n # mrr = minus_one_matrix(mrr)\n\n res = solve() # include input here\n\n # print length if applicable\n # print(len(res))\n\n # parse result\n # res = \" \".join(str(x) for x in res)\n # res = \"\\n\".join(str(x) for x in res)\n # res = \"\\n\".join(\" \".join(str(x) for x in row) for row in res)\n\n # print result\n # print(\"Case #{}: {}\".format(case_num+1, res)) # Google and Facebook - case number required\n\n print(res)"}, {"source_code": "#!/usr/bin/env python3\nimport sys\nimport getpass # not available on codechef\nimport math, random\nimport functools, itertools, collections, heapq, bisect\nfrom collections import Counter, defaultdict, deque\ninput = sys.stdin.readline # to read input quickly\n\n# available on Google, AtCoder Python3, not available on Codeforces\n# import numpy as np\n# import scipy\n\nM9 = 998244353 \nyes, no = \"YES\", \"NO\"\n# d4 = [(1,0),(0,1),(-1,0),(0,-1)]\n# d8 = [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]\n# d6 = [(2,0),(1,1),(-1,1),(-2,0),(-1,-1),(1,-1)] # hexagonal layout\nMAXINT = sys.maxsize\n\n# if testing locally, print to terminal with a different color\nOFFLINE_TEST = getpass.getuser() == \"hkmac\"\n# OFFLINE_TEST = False # codechef does not allow getpass\ndef log(*args):\n if OFFLINE_TEST:\n print('\\033[36m', *args, '\\033[0m', file=sys.stderr)\n\ndef solve(*args):\n # screen input\n if OFFLINE_TEST:\n log(\"----- solving ------\")\n log(*args)\n log(\"----- ------- ------\")\n return solve_(*args)\n\ndef read_matrix(rows):\n return [list(map(int,input().split())) for _ in range(rows)]\n\ndef read_strings(rows):\n return [input().strip() for _ in range(rows)]\n\ndef minus_one(arr):\n return [x-1 for x in arr]\n\ndef minus_one_matrix(mrr):\n return [[x-1 for x in row] for row in mrr]\n\n# ---------------------------- template ends here ----------------------------\n\n\ndef solve_(k):\n # your solution here\n if k == 1:\n return 1\n if not OFFLINE_TEST:\n if k == 100:\n return 688750769\n \n res = 1 # series\n for x in range(1,k-1):\n log(x)\n res += pow(2,x-1,M9)\n\n res += pow(2,k-1,M9)\n\n return res%M9\n\n\nfor case_num in [0]: # no loop over test case\n# for case_num in range(100): # if the number of test cases is specified\n# for case_num in range(int(input())):\n\n # read line as an integer\n k = int(input())\n\n # read line as a string\n # srr = input().strip()\n\n # read one line and parse each word as a string\n # lst = input().split()\n \n # read one line and parse each word as an integer\n # a,b,c = list(map(int,input().split()))\n # lst = list(map(int,input().split()))\n # lst = minus_one(lst)\n\n # read multiple rows\n # arr = read_strings(k) # and return as a list of str\n # mrr = read_matrix(k) # and return as a list of list of int\n # mrr = minus_one_matrix(mrr)\n\n res = solve(k) # include input here\n\n # print length if applicable\n # print(len(res))\n\n # parse result\n # res = \" \".join(str(x) for x in res)\n # res = \"\\n\".join(str(x) for x in res)\n # res = \"\\n\".join(\" \".join(str(x) for x in row) for row in res)\n\n # print result\n # print(\"Case #{}: {}\".format(case_num+1, res)) # Google and Facebook - case number required\n\n print(res)"}, {"source_code": "n=int(input())\r\nl=[1]*n\r\nfor i in range(1,n) :\r\n for j in range(i,n,i) :\r\n l[j]=l[j]+1\r\nans=1\r\na=1\r\nvar=1\r\nwhile a!=n :\r\n a=a+1\r\n ans=(var+l[a-1])%998244353\r\n var=(var+ans)%998244353\r\nprint(ans)\r\n "}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n#######################################\r\nfrom collections import *\r\nfrom collections import deque\r\nfrom operator import itemgetter , attrgetter\r\nfrom decimal import *\r\nimport bisect\r\nimport math\r\nimport heapq as hq\r\n#import sympy\r\nMOD=10**9 +7\r\n\r\n\r\ndef is_prime(n):\r\n if n == 2 or n == 3: return True\r\n if n < 2 or n%2 == 0: return False\r\n if n < 9: return True\r\n if n%3 == 0: return False\r\n r = int(n**0.5)\r\n # since all primes > 3 are of the form 6n \u00b1 1\r\n # start with f=5 (which is prime)\r\n # and test f, f+2 for being prime\r\n # then loop by 6.\r\n f = 5\r\n while f <= r:\r\n\r\n if n % f == 0: return False\r\n if n % (f+2) == 0: return False\r\n f += 6\r\n return True\r\n\r\ndef pow(a,b,m):\r\n ans=1\r\n while b:\r\n if b&1:\r\n ans=(ans*a)%m\r\n b//=2\r\n a=(a*a)%m\r\n return ans\r\nvis=[]\r\ngraph=[]\r\ndef dfs(v):\r\n if vis[v]: return 0\r\n vis[v]=True\r\n\r\n temp=0\r\n for vv in graph[v]:\r\n temp+=dfs(vv)\r\n return 1+temp\r\ndef ispalindrome(s):\r\n if s[:]==s[::-1]:\r\n return 1\r\n return 0\r\ndp=[]\r\nlimit=[]\r\nv=[]\r\ndef dpdfs(u,t=-1):\r\n dp[0][u]=0\r\n dp[1][u]=0\r\n for i in v[u]:\r\n if i==t:\r\n\r\n continue\r\n if dp[1][i]==-1:\r\n dpdfs(i,u)\r\n dp[0][u]+=max(abs(limit[0][u]-limit[1][i])+dp[1][i],abs(limit[0][u]-limit[0][i])+dp[0][i])\r\n dp[1][u] += max(abs(limit[1][u] - limit[1][i]) + dp[1][i], abs(limit[1][u] - limit[0][i]) + dp[0][i])\r\nmod=998244353\r\nn=int(input())\r\ndp=[0,1,3,6]\r\nif n<len(dp):\r\n print(dp[n])\r\nelse:\r\n for i in range(4,n+1):\r\n dp.append((i+2*dp[i-1])%mod)\r\n print(dp[n]%mod)"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n#######################################\r\nfrom collections import *\r\nfrom collections import deque\r\nfrom operator import itemgetter , attrgetter\r\nfrom decimal import *\r\nimport bisect\r\nimport math\r\nimport heapq as hq\r\n#import sympy\r\nMOD=10**9 +7\r\n\r\n\r\ndef is_prime(n):\r\n if n == 2 or n == 3: return True\r\n if n < 2 or n%2 == 0: return False\r\n if n < 9: return True\r\n if n%3 == 0: return False\r\n r = int(n**0.5)\r\n # since all primes > 3 are of the form 6n \u00b1 1\r\n # start with f=5 (which is prime)\r\n # and test f, f+2 for being prime\r\n # then loop by 6.\r\n f = 5\r\n while f <= r:\r\n\r\n if n % f == 0: return False\r\n if n % (f+2) == 0: return False\r\n f += 6\r\n return True\r\n\r\ndef pow(a,b,m):\r\n ans=1\r\n while b:\r\n if b&1:\r\n ans=(ans*a)%m\r\n b//=2\r\n a=(a*a)%m\r\n return ans\r\nvis=[]\r\ngraph=[]\r\ndef dfs(v):\r\n if vis[v]: return 0\r\n vis[v]=True\r\n\r\n temp=0\r\n for vv in graph[v]:\r\n temp+=dfs(vv)\r\n return 1+temp\r\ndef ispalindrome(s):\r\n if s[:]==s[::-1]:\r\n return 1\r\n return 0\r\ndp=[]\r\nlimit=[]\r\nv=[]\r\ndef dpdfs(u,t=-1):\r\n dp[0][u]=0\r\n dp[1][u]=0\r\n for i in v[u]:\r\n if i==t:\r\n\r\n continue\r\n if dp[1][i]==-1:\r\n dpdfs(i,u)\r\n dp[0][u]+=max(abs(limit[0][u]-limit[1][i])+dp[1][i],abs(limit[0][u]-limit[0][i])+dp[0][i])\r\n dp[1][u] += max(abs(limit[1][u] - limit[1][i]) + dp[1][i], abs(limit[1][u] - limit[0][i]) + dp[0][i])\r\nmod=998244353\r\nn=int(input())\r\ndp=[0,1,3,6]\r\nif n<len(dp):\r\n print(dp[n])\r\nelse:\r\n for i in range(4,n+1):\r\n dp.append((i+dp[i-1])%mod)\r\n print(dp[n]%mod)"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n#######################################\r\nfrom collections import *\r\nfrom collections import deque\r\nfrom operator import itemgetter , attrgetter\r\nfrom decimal import *\r\nimport bisect\r\nimport math\r\nimport heapq as hq\r\n#import sympy\r\nMOD=10**9 +7\r\n\r\n\r\ndef is_prime(n):\r\n if n == 2 or n == 3: return True\r\n if n < 2 or n%2 == 0: return False\r\n if n < 9: return True\r\n if n%3 == 0: return False\r\n r = int(n**0.5)\r\n # since all primes > 3 are of the form 6n \u00b1 1\r\n # start with f=5 (which is prime)\r\n # and test f, f+2 for being prime\r\n # then loop by 6.\r\n f = 5\r\n while f <= r:\r\n\r\n if n % f == 0: return False\r\n if n % (f+2) == 0: return False\r\n f += 6\r\n return True\r\n\r\ndef pow(a,b,m):\r\n ans=1\r\n while b:\r\n if b&1:\r\n ans=(ans*a)%m\r\n b//=2\r\n a=(a*a)%m\r\n return ans\r\nvis=[]\r\ngraph=[]\r\ndef dfs(v):\r\n if vis[v]: return 0\r\n vis[v]=True\r\n\r\n temp=0\r\n for vv in graph[v]:\r\n temp+=dfs(vv)\r\n return 1+temp\r\ndef ispalindrome(s):\r\n if s[:]==s[::-1]:\r\n return 1\r\n return 0\r\ndp=[]\r\nlimit=[]\r\nv=[]\r\ndef dpdfs(u,t=-1):\r\n dp[0][u]=0\r\n dp[1][u]=0\r\n for i in v[u]:\r\n if i==t:\r\n\r\n continue\r\n if dp[1][i]==-1:\r\n dpdfs(i,u)\r\n dp[0][u]+=max(abs(limit[0][u]-limit[1][i])+dp[1][i],abs(limit[0][u]-limit[0][i])+dp[0][i])\r\n dp[1][u] += max(abs(limit[1][u] - limit[1][i]) + dp[1][i], abs(limit[1][u] - limit[0][i]) + dp[0][i])\r\nn=int(input())\r\ndp=[0,1,3,6]\r\nif n<len(dp):\r\n print(dp[n])\r\nelse:\r\n for i in range(4,n+1):\r\n dp.append(i+dp[i-1])\r\n print(dp[n])"}, {"source_code": "import io\nimport os\n\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heappush, heappop, heapify\nfrom math import gcd, inf\n\nMOD = 998244353\n\nMAX_N = 10 ** 6 + 1\n\nMOD = 998244353\nassert MAX_N < MOD\n\n\ndef modInverse(a, p):\n return pow(a, p - 2, p)\n\n\n# Precompute all factorials: i!\nfact = [1]\nfor i in range(1, MAX_N + 1):\n fact.append((fact[-1] * i) % MOD)\n\n# Precompute all inverse factorials: 1 / i!\ninvFact = [0] * (MAX_N + 1)\ninvFact[MAX_N] = modInverse(fact[MAX_N], MOD)\nfor i in range(MAX_N - 1, -1, -1):\n invFact[i] = (invFact[i + 1] * (i + 1)) % MOD\n # assert fact[i] * invFact[i] % MOD == 1\n\n\ndef nCr(n, r): # mod'd\n if n < r:\n return 0\n return (fact[n] * invFact[r] * invFact[n - r]) % MOD\n\n\nfrom functools import lru_cache\n\n\ndef solve(N,):\n @lru_cache(maxsize=None)\n def numDivisors(n):\n ans = 0\n for i in range(1, 2 * n):\n if n % i == 0:\n ans += 2\n return ans\n\n @lru_cache(maxsize=None)\n def dp(n):\n assert n >= 0\n if n == 0:\n return 1\n if n == 1:\n return 1\n\n # All same\n ans = numDivisors(n)\n '''\n for i in range(1, n):\n ans += dp(n - i)\n '''\n ans += prefDp(n - 1)\n return ans % MOD\n\n @lru_cache(maxsize=None)\n def prefDp(i):\n if i <= 0:\n return 0\n return prefDp(i - 1) + dp(i)\n\n for i in range(N):\n dp(i)\n\n return dp(N) % MOD\n\n\nif False:\n for n, check in zip(\n [0, 1, 2, 3, 4, 5, 6, 100], [1, 1, 3, 6, 13, 25, 52, 688750769]\n ):\n print(\"tc\", n, solve(n), check, \"#\" * 20)\n exit()\n\n\nif __name__ == \"__main__\":\n input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n TC = 1\n for tc in range(1, TC + 1):\n (N,) = [int(x) for x in input().split()]\n ans = solve(N,)\n print(ans)\n"}, {"source_code": "p=998244353\r\n\r\ndef sol(n):\r\n f = [1]*(n+1)\r\n for i in range(2,n+1):\r\n for j in range(i,n+1,i):\r\n f[j] += 1\r\n g = [0]*(n+1)\r\n h = 1\r\n for i in range(2,n+1):\r\n g[i]=(f[i]+h)%p\r\n h =((h<<1)+f[i])%p\r\n return g[n] \r\n\r\nprint(sol(int(input())))\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn=int(input())\r\nmod=998244353\r\n\r\nDP=[0,1,3,6]\r\nSUM=[0,1,4,10]\r\n\r\nPLUS=[1]*(10**6+5)\r\nfor i in range(2,10**6):\r\n for j in range(i,10**6+5,i):\r\n PLUS[j]+=1\r\n\r\n\r\n#print(PLUS[:10])\r\n\r\nfor i in range(10**6):\r\n DP.append((SUM[-1]+PLUS[i+4])%mod)\r\n SUM.append((SUM[-1]+DP[-1])%mod)\r\n\r\nprint(DP[n])\r\n"}], "src_uid": "09be46206a151c237dc9912df7e0f057"} {"source_code": "a,b = map(int,raw_input().split())\nnums = [a]\nanswers = []\ndef dfs(nums):\n if(nums[-1]>b):\n return\n elif(nums[-1]==b):\n answers.append(nums)\n else:\n numsPlusOne = nums[::]\n numsPlusOne.append((nums[-1]*10)+1)\n dfs(numsPlusOne)\n numsTimesTwo = nums[::]\n numsTimesTwo.append(nums[-1]*2)\n dfs(numsTimesTwo)\ndfs(nums)\nif(len(answers)==0):\n print 'NO'\nelse:\n print 'YES'\n answers.sort(key=lambda answer: len(answer))\n print len(answers[0])\n print \" \".join(str(answer) for answer in answers[0])\n\n", "positive_code": [{"source_code": "def solve():\n nums = map(int, raw_input().split(\" \"))\n a, b = nums\n steps = []\n while b > a:\n steps.insert(0, b)\n if b % 2 == 0:\n b = b / 2\n elif b % 10 == 1:\n b = (b-1) / 10\n else:\n return \"NO\"\n\n if b != a:\n return \"NO\"\n\n steps.insert(0, a)\n \n return \"YES\\n\" + str(len(steps)) + \"\\n\" + \" \".join(map(str, steps))\n \n\nprint solve()\n"}, {"source_code": "import sys\nsys.setrecursionlimit(100000)\ndef prov(a0, a, b, i):\n if a==b and f==0:\n print('YES')\n print(i+1) \n for j in range(i):\n print(a0, end=' ')\n if s1[j]==1:\n a0=2*a0\n else:\n a0=a0*10+1\n print(b)\n global f\n f=1\n return(1)\n elif a>b:\n return(0)\n else:\n i0=i\n s1.append(1)\n prov(a0, 2*a, b, i+1)\n s1.pop()\n s1.append(2)\n prov(a0, a*10+1, b, i0+1)\n s1.pop()\ns=list(map(int, input().split()))\na=s[0]\nb=s[1]\ns1=list();\nf=0\nt=prov(a, a, b, 0)\nif f==0:\n print('NO')\n"}, {"source_code": "a, b = map(int, input().split())\n\nseq = []\n\ndef d(s):\n if s > b:\n return False\n if s == b:\n seq.append(s)\n return True\n \n for i in range(2):\n if i==0:\n hit = d(2*s)\n if hit:\n seq.append(s)\n return True\n \n if i == 1:\n hit = d(10*s +1)\n if hit:\n seq.append(s)\n return True\nd(a) \nif len(seq) > 0:\n print(\"YES\")\n # seq += [a]\n # seq.append(a)\n print(len(seq))\n \n for i in reversed(seq):\n print(i, end = \" \")\nelse:\n print(\"NO\")\n \n "}, {"source_code": "a, b = map(int, input().split())\nX = [b]\n\nwhile a < b:\n if b % 2:\n b, m = divmod(b, 10)\n if m != 1:\n break\n else:\n b //= 2\n X.append(b)\n\nif a != b:\n print('NO')\nelse:\n print('YES')\n print(len(X))\n print(*reversed(X))"}, {"source_code": "a, b = map(int,raw_input().split())\n\n\ndef toget(x,y):\n\tif x==y:\n\t\treturn [x]\n\tif x>y :\n\t\treturn [-1]\n\telse:\n\t\tcasea = [x] + toget(x*2, y)\n\t\tcaseb = [x] + toget((x*10) +1, y)\n\tif casea[-1] != -1:\n\t\treturn casea\n\telif caseb[-1] != -1:\n\t\treturn caseb\n\telse:\n\t\treturn [-1]\nresult = toget(a,b)\n\nif result != [-1]:\n\tprint \"YES\"\n\tprint len(result)\n\tprint ' '.join(str(x) for x in result)\nelse:\n\tprint \"NO\"\n"}, {"source_code": "import time\n\ndef read(t=None):\n\tstring = raw_input()\n\treturn string if t is None else [t(x) for x in string.split()]\n\ndef solve():\n\tx, y = read(int)\n\ta = [y]\n\twhile y != x:\n\t\t#print a\n\t\t#time.sleep(1)\n\t\tif y % 2 == 0:\n\t\t\ty /= 2\n\t\t\ta.append(y)\n\t\telse:\n\t\t\ty -= 1\n\t\t\tif y != 0 and y % 10 == 0:\n\t\t\t\ty /= 10\n\t\t\t\ta.append(y)\n\t\t\telse:\n\t\t\t\tprint \"NO\"\n\t\t\t\treturn\n\tprint 'YES'\n\tn = len(a)\n\tprint n\n\tfor i in range(n-1, -1, -1):\n\t\tprint a[i],\n\tprint\n\t\n\t\n\nif __name__ == \"__main__\":\n\tsolve()"}, {"source_code": "a, b = map(int, input().split())\nX = [b]\n\nwhile a < b:\n if b % 2:\n b, m = divmod(b, 10)\n if m != 1:\n print('NO')\n break\n X.append(b)\n else:\n b //= 2\n X.append(b)\nelse:\n if a != b:\n print('NO')\n else:\n print('YES')\n print(len(X))\n print(*reversed(X))"}, {"source_code": "a, b = map(int, raw_input().split())\n\nseq = [b]\nwhile b > a:\n if b % 10 == 1:\n b /= 10\n elif b % 2 == 0:\n b /= 2\n else:\n break\n seq.append(b)\n\nif a == b:\n print \"YES\"\n print len(seq)\n print \" \".join(map(str, reversed(seq)))\nelse:\n print \"NO\"\n"}, {"source_code": "from sys import stdin\n\na, b = map(int, stdin.readline().split(\" \"))\n\nprocesslist = []\nprocesslist.append(b)\nposible = True\nwhile a != b:\n if b % 2 == 0:\n b = b / 2\n processlist.append(b)\n elif b % 10 == 1:\n b = (b - 1) / 10\n processlist.append(b)\n else:\n posible = False\n break\n \n if b < a:\n posible = False\n break\n \nif posible:\n print \"YES\"\n print len(processlist)\n processlist.reverse()\n for x in range (len(processlist)):\n print processlist[x], \nelse:\n print \"NO\"\n \n \n "}, {"source_code": "n,k=list(map(int,input().split()))\nanswer=[]\nanswer.append(k) \nwhile k>n:\n if k%2==0:\n k=k//2\n answer.append(k)\n if k%10==1 and k!=1:\n k=(k-1)//10\n answer.append(k)\n if k==n:\n print('YES')\n print(len(answer))\n l=len(answer)\n for i in range(l):\n print(answer[l-i-1],' ',end='')\n break\n elif (k%2!=0 and k%10!=1) or k<n:\n print('NO')\n break\n \n"}, {"source_code": "import sys\n\na, b = sys.stdin.readline().strip().split()\na, b = int(a), int(b)\n\nmas = []\n\nwhile b>=a:\n mas += [b]\n if b % 2 == 0:\n b=b/2\n elif b%10==1:\n b=(b-1)/10\n elif a != b:\n print \"NO\"\n exit(0)\n else:\n break;\nmas.reverse()\n\nif a==mas[0]:\n print \"YES\"\n print len(mas)\n print \" \".join(map(str, mas))\nelse:\n print \"NO\"\n\n\n"}, {"source_code": "a,b = map(int,input().split())\nd = b\nc = b%10\nif c % 2!=0 and c!=1:\n\tprint(\"NO\")\nelse:\n\tl = []\n\tif c == 1:\n\t\tb = b-1\n\t\tb//=10\n\t\tl.append(b)\n\telse:\n\t\tb//=2\n\t\tl.append(b)\n\twhile b > a:\n\t\tif b % 2 != 0 and b%10!=1:\n\t\t\tprint(\"NO\")\n\t\t\texit()\n\t\tif b % 10 == 1:\n\t\t\tb-=1\n\t\t\tb//=10\n\t\telse:\n\t\t\tb//=2\n\t\tl.append(b)\n\tif b != a:print(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\t\tprint(len(l)+1)\n\t\ts=\"\"\n\t\tfor i in range(len(l)-1,-1,-1):s+=str(l[i]);s+=\" \"\n\t\ts+=str(d)\n\t\tprint(s)"}, {"source_code": "#coding:utf-8\na, b = map(str, raw_input().split())\nintb = int(b)\ninta = int(a)\nlist =[b]\n\ndef AtoB(inta, intb, b):\n if(intb == inta):\n return \"YES\"\n if(intb % 2 != 0 and b[len(b)-1] != \"1\" or intb < inta):\n return \"NO\"\n if(b[-1] != \"1\"):\n intb = intb/2\n b = str(intb)\n list.append(intb)\n return AtoB(inta, intb, b)\n else:\n intb = (intb-1)/10\n b = str(intb)\n list.append(intb)\n return AtoB(inta, intb, b)\n\nif(AtoB(inta,intb, b) == \"YES\"):\n print \"YES\"\n print len(list)\n for i in xrange(len(list)-1, -1, -1):\n print list[i],\nelse:\n print\"NO\""}, {"source_code": "a, b = map(int, input().split())\ncnt = 1\nop = [b]\nwhile b > a:\n\tif b % 10 == 1:\n\t\tb //= 10\n\t\tcnt += 1\n\t\top.append(b)\n\telif b % 10 % 2 == 0:\n\t\tb //= 2\n\t\tcnt += 1\n\t\top.append(b)\n\telse:\n\t\tprint('NO')\n\t\texit()\nif b < a:\n\tprint('NO')\nelse:\n\tprint('YES')\n\tprint(cnt)\n\tprint(' '.join(map(str, op[::-1])))"}, {"source_code": "#http://codeforces.com/problemset/problem/727/A\n\na, b = map(int, raw_input().split())\n\ndef found_num(a, b):\n sequence = []\n founded = False\n size = 0\n while (b >= a):\n sequence.append(int(b))\n size += 1\n if (b == a):\n founded = True\n break\n if (b % 2 == 0):\n b = b/2.0\n else:\n b = (b - 1)/10.0\n return founded, size, sequence\n \ndef print_result(result, size):\n sequence = str(result[size - 1])\n for i in xrange(size - 2, -1, -1):\n sequence += \" \" + str(result[i])\n return sequence\n\n\nresult = found_num(a, b)\nfounded = result[0]\nsize = result[1]\nresult_formated = print_result(result[2], size)\n\nif (founded):\n print \"YES\"\n print size \n print result_formated\nelse:\n print \"NO\"\n\n\n\n \n"}, {"source_code": "import sys\nimport copy\n\n\ndef op1(n):\n\treturn n*2\ndef op2(n):\n\treturn (n*10)+1\ndef revop1(n):\t\t\t\t\t\t# 0\n\treturn n/2\ndef revop2(n):\t\t\t\t\t\t# 1\n\treturn (n-1)/10\n\n\na,B=map(float,filter(lambda a:a!='',raw_input().split(' ')))\n# print a,b\noperations=[]\nb=copy.copy(B)\nwhile b>a:\n\tif b%2==0:\n\t\tb=revop1(b)\n\t\toperations.append(0)\n\telse:\n\t\tb=revop2(b)\n\t\toperations.append(1)\nif b==a:\n\tprint 'YES'\n\tprint len(operations)+1\n\tsys.stdout.write('%d '%a)\n\tfor i in range(len(operations)-1,-1,-1):\n\t\tif operations[i]==0:\n\t\t\ta=op1(a)\n\t\telif operations[i]==1:\n\t\t\ta=op2(a)\n\t\tsys.stdout.write('%d '%a)\n\tsys.exit(0)\nelse:\n\tprint 'NO'\n\tsys.exit(0)"}, {"source_code": "x = input().split()\na = int(x[0])\nb = int(x[1])\nsp = [b]\nk = 1\nc = True\nwhile a != b and c == True:\n if b % 10 == 1 :\n b = (b - 1) / 10\n sp.append(int(b))\n k = k + 1\n else:\n b = b / 2\n sp.append(int(b))\n k = k + 1\n if a > b:\n c = False\nsp.reverse()\nif c == True :\n print(\"YES\")\n print(k)\n print(*sp)\nif c == False:\n print(\"NO\")"}, {"source_code": "lst = input().split()\n\na = int(lst[0])\nb = int(lst[1])\n\nresult_lst = []\nresult_lst.append(b)\nwhile b > a:\n if b % 10 == 1:\n b -= 1\n b //= 10\n elif b % 2 == 0:\n b //= 2\n else:\n break\n result_lst.append(b)\n\nif b == a:\n print('YES')\n print(len(result_lst))\n result_lst.reverse()\n result_lst = [str(i) for i in result_lst]\n print(' '.join(result_lst))\nelse:\n print('NO')"}, {"source_code": "def multiple(a, b, seq):\n if a == b:\n return seq + [a]\n if a > b:\n return []\n if a < b:\n return multiple(a*2,b,seq + [a]) or multiple((a*10)+1,b,seq + [a])\n\n\na,b = map(int,input().split(' '))\nres = multiple(a,b,[])\nif len(res) == 0:\n print('NO')\nelse:\n print('YES', len(res), sep='\\n')\n print(*res)"}, {"source_code": "n, x = list(map(int, input().rstrip().split(\" \")))\nl = [x]\nwhile x>n:\n if x == n:\n break\n if x%10==1:\n x = x//10\n l.append(x)\n elif x%2==0:\n x = x//2\n l.append(x)\n else:\n break\nif l[-1]==n:\n print(\"YES\")\n print(len(l))\n print(*l[::-1])\nelse:\n print(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\nsteps = list()\nsteps.append(b)\nDone = False\nwhile b != a:\n if (b - 1)%10 == 0:\n b = (b-1)//10\n steps.append(b)\n if b % 2 == 0 and b != a:\n b = b//2\n steps.append(b)\n if (b - 1)%10 != 0 and b % 2 != 0 and b != a or b < a:\n print('NO')\n Done = True\n break\nif Done is False:\n print('YES')\n print(len(steps))\n steps.reverse()\n print(' '.join(map(str, steps)))"}, {"source_code": "a,b=map(int,input().split())\nf=0\nans=[b]\nsteps=0\nwhile b>a:\n if b%10==1:\n b=b//10 \n ans.append(b)\n elif (b%10)%2==0:\n b=b//2 \n ans.append(b)\n else:\n break\n if b==a:\n f=1 \n break \nif f==1:\n print('YES')\n print(len(ans))\n print(*(ans[::-1]))\nelse:\n print('NO')"}, {"source_code": "a,b=map(int,input().split())\nl=[b]\nwhile(a<b):\n if b%2:\n if b%10==1:\n b//=10\n l.append(b)\n else:\n break\n else:\n b//=2\n l.append(b)\nif a==b:print(\"YES\");print(len(l));print(*l[::-1])\nelse:print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nans= [b]\nwhile True:\n if b%10==1:\n b=b//10\n elif b%2==0:\n b=b//2\n else:\n break\n if a>=b:\n break\n ans.append(b)\nans.append(a)\nif a!=b:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(len(ans))\n print(*ans[::-1])"}, {"source_code": "##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\nimport sys\ninput = sys.stdin.readline\nscan_int = lambda: int(input())\nscan_string = lambda: input().rstrip()\nread_list = lambda: list(read())\nread = lambda: map(int, input().split())\nread_float = lambda: map(float, input().split())\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // math.gcd(a, b)\n\ndef is_integer(n):\n\treturn math.ceil(n) == math.floor(n)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\n\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n# Euler's Toitent Function phi\ndef phi(n) : \n \n result = n \n p = 2\n while(p * p<= n) : \n if (n % p == 0) : \n while (n % p == 0) : \n n = n // p \n result = result * (1.0 - (1.0 / (float) (p))) \n p = p + 1\n if (n > 1) : \n result = result * (1.0 - (1.0 / (float)(n))) \n \n return (int)(result) \n\ndef is_prime(n):\n\tif n == 0:\n\t\treturn False\n\tif n == 1:\n\t\treturn True\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif not n % i:\n\t\t\treturn False\n \n\treturn True\n\ndef next_prime(n, primes):\n\twhile primes[n] != True:\n\t\tn += 1\n\treturn n\n\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\ndef factors(n):\n\tres = []\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i == 0:\n\t\t\tres.append(i)\n\t\t\tres.append(n // i)\n\treturn list(set(res))\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n\ndef binary_search(low, high, w, h, n):\n\twhile low < high:\n\t\tmid = low + (high - low) // 2\n\t\t# print(low, mid, high)\n\t\tif check(mid, w, h, n):\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid\n\treturn low\n\n## for checking any conditions\ndef check(beauty, s, n, count):\n\tpass\n\t\n\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\nalphs = \"abcdefghijklmnopqrstuvwxyz\".upper()\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\nimport bisect as bis\nimport random\nimport sys\nimport collections as collect\n\ndef solve():\n\ta, b = read()\n\tans = []\n\twhile b > a:\n\t\tans.append(b)\n\t\tif b % 2 == 0:\n\t\t\tb //= 2\n\t\telif b % 10 == 1:\n\t\t\tb //= 10\n\t\telse:\n\t\t\tbreak\n\tans.append(b)\n\tif a == b:\n\t\tprint(\"YES\")\n\t\tprint(len(ans))\n\t\tprint(*ans[::-1])\n\telse:\n\t\tprint(\"NO\")\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n for i in range(1):\n \tsolve()\n #dmain()\n \n# Comment Read()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "a,b = map(int,input().split())\nl = [b]\nwhile b % 2 == 0 or b % 10 == 1:\n if b == 0 or b == 1:\n break\n if b == a:\n break\n elif b % 2 == 0:\n b = int(b/2)\n l.append(b)\n else:\n b = int((b-1)/10)\n l.append(b)\n \nif b == a:\n print(\"YES\")\n print(len(l))\n print(*reversed(l))\nelse:\n print(\"NO\")"}, {"source_code": "digl=['0','1','2','3','4','5','6','7','8','9']\nii = lambda : int(input())\nsi = lambda : input()\ndgl = lambda : list(map(int, input()))\nf = lambda : map(int, input().split())\nil = lambda : list(map(int, input().split()))\nls = lambda : list(input())\nmod = 10 ** 9 + 7\na,b=f()\nl=[b]\nflg=0\nwhile 1:\n if b==1:\n if a==b:\n flg=1\n break\n elif a==b:\n flg=1\n break\n elif b%2==0:\n b//=2\n l.append(b)\n elif b%10==1:\n b//=10\n l.append(b)\n else:\n break\nif flg==1:\n print(\"YES\")\n print(len(l))\n print(*(l[::-1]))\nelse:\n print(\"NO\")"}, {"source_code": "X = list(map(int, input().split()))\nAnswer = [X[0]]\ndef DFS(Num, Type):\n if Num > X[1]:\n return\n if Num == X[1]:\n print(\"YES\")\n print(len(Answer))\n print(*Answer)\n exit()\n Num = (Num * 2 if Type == 0 else Num * 10 + 1)\n Answer.append(Num)\n DFS(Num, 0)\n Answer.pop()\n Answer.append(Num)\n DFS(Num, 1)\n Answer.pop()\nDFS(X[0], 0)\nDFS(X[0], 1)\nprint(\"NO\")\n"}, {"source_code": "def f(a, b, c):\n if (b - 1) % 10 == 0 and (b - 1) / 10 > a:\n return f(a, (b - 1) / 10, str(int(b)) + ' ' + c)\n elif b % 2 == 0 and b / 2 > a:\n return f(a, b / 2, str(int(b)) + ' ' + c)\n elif b / 2 == a or (b - 1) / 10 == a:\n return str(a) + ' ' + str(int(b)) + ' ' + c\n else:\n return False\na, b = list(map(int, input().split()))\nd = f(a, b, '')\nif d == 0:\n print('NO')\nelse:\n print('YES')\n print(d.count(' '))\n print(d)"}, {"source_code": "'''input\n4 42\n'''\n\nimport math\nimport sys\nimport itertools\nimport random\n\ndef lcm(x, y):\n\treturn (x*y)//math.gcd(x,y)\ndef hcf(x, y):\n\treturn math.gcd(x, y)\n\n\n\n\n\n\ndef backtrack(a, b, n, path):\n\tglobal g \n\tif n > b:\n\t\treturn\n\tif n == b:\n\t\tg=path \n\tbacktrack(a, b, n*2, path+[n*2])\n\tbacktrack(a, b, int(str(n)+'1'), path+[int(str(n)+'1')])\n\n\n# for _ in range(0, int(input())):\n\t# n=int(input()) # Single Digit Input\nx, y = map(int, input().strip().split()) # Many Digit Input\n\t# l=list(map(int, input().strip().split())) # List Input\n\t# s=list(input()) # Character Array Input\n\n\ng=[]\nbacktrack(x, y, x, [x])\nif g == []:\n\tprint(\"NO\")\nelse:\n\tprint('YES')\n\n\n\tprint(len(g))\n\tprint(*g)"}, {"source_code": "path = []\n\ndef seek(a, b):\n if a > b:\n return False\n if a == b:\n return True\n for x in [ 2*a, 10*a + 1 ]:\n path.append(x)\n if seek(x, b):\n return True\n path.pop()\n return False\n\na, b = map(int, raw_input().split())\npath.append(a)\nif seek(a, b):\n print('YES')\n print(len(path))\n print(' '.join(map(str, path)))\nelse:\n print('NO')\n"}, {"source_code": "a,b = map(int,input().split())\noutput = []\nnum = b\nn1,n2=0,0\n\noutput.append(num)\n\nwhile (num!=a):\n if (num<a):\n output.clear()\n print(\"NO\")\n exit()\n elif (num%2==0):\n num/=2\n output.append(int(num))\n elif (int(num/10)%2==0):\n num=int(num-1)/10\n output.append(int(num))\n else:\n num=int(num-1)/10\n output.append(int(num))\n\noutput.reverse()\nprint(\"YES\")\nprint(len(output))\nfor i in output:\n print(i, end=\" \")"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nf=0\nl=[]\nwhile(b>a):\n if (b%2==1):\n if (b-1)%10==0:\n l.append(b)\n b=(b-1)//10\n else:\n print(\"NO\")\n f=1\n break\n else:\n l.append(b)\n b=b//2\nif (f==0):\n if a==b:\n print(\"YES\")\n l.append(a)\n print(len(l))\n for i in range (len(l)):\n print(l[len(l)-i-1],end=' ')\n else:\n print(\"NO\")\n"}, {"source_code": "a,b=raw_input().split()\na,b=int(a),int(b)\nout=[b,]\nwhile a<b:\n\tif b%2==0:\n\t\tb/=2\n\t\tout.append(b)\n\telif (b-1)%10==0:\n\t\tb=(b-1)/10\n\t\tout.append(b)\n\telse:\n\t\tbreak\nif a==b:\n\tprint \"YES\"\n\tprint len(out)\n\tfor i in reversed(out):\n\t\tprint i,\nelse:\n\tprint \"NO\"\n\n\n"}, {"source_code": "def dfs(a,b,ans):\n\tif a>b:\n\t\treturn 0\n\tif a==b:\n\t\tans.append(a)\n\t\treturn 1\n\tif dfs(2*a,b,ans):\n\t\tans.append(a)\n\t\treturn 1\n\tif dfs(10*a+1,b,ans):\n\t\tans.append(a)\n\t\treturn 1\n\treturn 0;\n\na,b=map(int,raw_input().split())\nans=[]\nif dfs(a,b,ans):\n\tprint \"YES\"\n\tprint len(ans)\n\tfor i in range(len(ans)):\n\t\tprint ans[len(ans)-i-1],\nelse:\n\tprint \"NO\"\n\n\n"}, {"source_code": "# your code here\na,b = map(int,input().split())\nv = []\nwhile True:\n v.append(b)\n if b <= a:\n break\n if b % 10 == 1:\n b = (b-1)//10\n elif b % 2 == 0:\n b //= 2\n else:\n break\nif v[-1] == a:\n print(\"YES\")\n print(len(v))\n print(*list(reversed(v)))\nelse:\n print(\"NO\")"}, {"source_code": "import sys\nsys.setrecursionlimit(10**7)\n\ndef dfs(nu,par):\n\tglobal b,di\t\n\tif int(nu) > int(b):\n\t\treturn 0\n\tif nu not in di:\n\t\tif nu == b:\n\t\t\treturn 1\n\t\telse:\n\t\t\tif dfs(str(int(nu)*2),nu):\n\t\t\t\tdi[str(int(nu)*2)] = nu\t\t\t\t\n\t\t\t\treturn 1\n\t\t\telif dfs(nu+'1',nu):\n\t\t\t\tdi[nu+'1'] = nu\n\t\t\t\treturn 1\n\t\t\telse:\n\t\t\t\treturn 0\n\telse:\n\t\treturn 0\n\ndi = {}\na,b = raw_input().split()\nif dfs(a,-1):\n\tcount = 0\n\tlis = []\n\tlis.append(b)\n\twhile(b != a):\n\t\tb = di[b]\n\t\tcount += 1\n\t\tlis.append(b)\n\n\tprint 'YES'\n\tprint count+1\n\tfor ele in lis[::-1]:\n\t\tprint ele,\n\nelse:\n\tprint 'NO'"}, {"source_code": "start, end = map(int, raw_input().split())\n\ndef bfs():\n UNDEF = -1\n dist = {start: 1}\n prev = {start: UNDEF}\n q = [start]\n while q:\n curNum = q.pop()\n if curNum == end:\n print 'YES'\n print dist[end]\n path = []\n cur = end\n while cur != UNDEF:\n path.append(cur)\n cur = prev[cur]\n print ' '.join(reversed(map(str, path)))\n return\n for nextNum in (curNum << 1, curNum * 10 + 1):\n if nextNum <= end and nextNum not in dist:\n dist[nextNum] = dist[curNum] + 1\n prev[nextNum] = curNum\n q.append(nextNum)\n print 'NO'\n\nbfs()"}, {"source_code": "a,b = map(int,input().split())\nflag = 0\ni = 1\nt = [b]\nwhile True:\n\tif b < a:\n\t\tflag = 1\n\t\tbreak\n\telif b == a:\n\t\tbreak\n\tif (b)%2 == 0:\n\t\tb = b//2\n\t\tt.append(b)\n\telif b%10 == 1:\n\t\tb = b//10\n\t\tt.append(b)\n\telif b%2 == 1 and b != a:\n\t\tflag = 1\n\t\tbreak\n\ti = i + 1\nif flag == 0:\n\tprint(\"YES\")\n\tprint(i)\n\tfor i in range(1,len(t)+1):\n\t\tprint(t[-i],end=\" \")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "line = input().split()\na = int(line[0])\nb = int(line[1])\ntravel = [] #inisialisasi travel untuk menunjukkan asalnya dari mana\ntravel.append([])\nq = [a] #inisialisasi queue utk BFS\nindex = 0\n#proses BFS\n##while len(q) > 0:\n#### print(q[0])\n#### print(travel)\n#### if q[0] == b: #jika queue terdepan sudah sama\n#### print(\"YES\", len(travel[len(travel) - 2]) + 1, sep='\\n')\n#### for i in travel[len(travel) - 2]:\n#### print(i, end=' ')\n#### print(q[0])\n#### break\n#### else:\n## temp = q[0] * 2 #proses untuk anak kiri\n#### print(len(travel), \"index =\", index, \"travel[index] =\", travel[index], \"q =\", q[0])\n#### print(temp, q[0])\n## if temp <= b and index < len(travel): #dibatasi tidak melebihi b dan index belum melebihi panjang array travel\n## q += [temp] #push data baru\n## travel.append([]) #array travel ditambah panjangnya\n#### print(len(travel), \"index =\", index)\n## travel[len(travel) - 1] = list(travel[index]) #mengcopy array dari travel asal\n## travel[len(travel) - 1] += [q[0]] #travel baru ditambah dengan q[0] untuk menandakan dia berasal dari node tersebut\n## if temp == b: #jika temp sudah sama\n## print(\"YES\", len(travel[len(travel) - 1]) + 1, sep='\\n')\n## for i in travel[len(travel) - 1]:\n## print(i, end=' ')\n## print(temp)\n## break\n#### print(temp, \"travel kali =\", travel[temp], \"travel asal =\", travel[q[0]], end='-----')\n#### elif temp ==\n## temp = (q[0] * 10) + 1 #Proses untuk anak kanan\n## if temp <= b and index < len(travel):\n## q += [temp] #push data baru\n## travel.append([]) #array travel ditambah panjangnya\n## travel[len(travel) - 1] = list(travel[index]) #mengcopy array dari travel asal\n## travel[len(travel) - 1] += [q[0]]\n## if temp == b: #jika temp sudah sama\n## print(\"YES\", len(travel[len(travel) - 1]) + 1, sep='\\n')\n## for i in travel[len(travel) - 1]:\n## print(i, end=' ')\n## print(temp)\n## break\n#### print(temp, \"travel tambah =\", travel[temp], \"travel asal =\", travel[q[0]])\n## q.pop(0) #pop dari queue\n## index += 1 #index ditambah menunjukkan asal nodenya\n## if len(q) == 0: #jika queue kosong menandakan angka tersebut tidak dapat ditemukan\n## print(\"NO\")\n#proses DFS\n#penelusuran terbalik dari bawah ke atas\nq =[b]\nwhile b > a:\n if b % 2 == 0: #jika genap maka pasti merupakan hasil kali 2\n b = int(b/2) #karena itu dibagi 2\n q += [b]\n elif b % 10 == 1: #jika berakhiran 1, merupakan hasil penambahan digit 1 di belakang\n b = int(b/10) #karena itu dibagi 10\n q += [b]\n else: #jika tidak memenuhi keduanya maka sudah pasti angka tersebut mustahil dicapai\n break\n\nq.reverse() #dibalik untuk pencetakan\nif a == b:\n print(\"YES\", len(q), sep='\\n')\n for i in q:\n print(i, end=' ')\nelse:\n print(\"NO\")"}, {"source_code": "from collections import deque\na, b = map(int, raw_input().split(\" \"))\npre = {}\nfila = deque([a])\nwhile fila:\n\tv = fila.popleft()\n\tif 2*v not in pre and 2*v <= b:\n\t\tfila.append(2*v)\n\t\tpre[2*v] = v\n\tif 10*v+1 not in pre and 10*v+1 <= b:\n\t\tfila.append(10*v+1)\n\t\tpre[10*v+1] = v\n\nseq = [b]\nif b not in pre:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"\n\tx = b\n\twhile x != a:\n\t\tx = pre[x]\n\t\tseq.append(x)\n\tprint len(seq)\n\tfor i in seq[::-1]:\n\t\tprint(i),"}, {"source_code": "line = input().split()\na = int(line[0])\nb = int(line[1])\n##travel = [[] for i in range(b+1)] #inisialisasi travel untuk menunjukkan asalnya dari mana\n##q = [a] #inisialisasi queue utk BFS\n###proses BFS\n##while len(q) > 0:\n## print(q[0])\n## if q[0] == b: #jika queue terdepan sudah sama\n## print(\"YES\", len(travel[q[0]]) + 1, sep='\\n')\n## for i in travel[q[0]]:\n## print(i, end=' ')\n## print(q[0])\n## break\n## else:\n## if b % 2 == 0:\n## temp = q[0] * 2 #proses untuk anak kiri\n## if temp <= b and len(travel[temp]) == 0: #dibatasi tidak melebihi b\n## q += [temp] #push data baru\n## travel[temp] = list(travel[q[0]]) #mengcopy array dari travel asal\n## travel[temp] += [q[0]] #travel baru ditambah dengan q[0] untuk menandakan dia berasal dari node tersebut\n#### print(temp, \"travel kali =\", travel[temp], \"travel asal =\", travel[q[0]], end='-----')\n## temp = (q[0] * 10) + 1 #Proses untuk anak kanan\n## if temp <= b and len(travel[temp]) == 0:\n## q += [temp] #push data baru\n## travel[temp] = list(travel[q[0]]) #mengcopy array dari travel asal\n## travel[temp] += [q[0]] #travel baru ditambah dengan q[0] untuk menandakan dia berasal dari node tersebut\n#### print(temp, \"travel tambah =\", travel[temp], \"travel asal =\", travel[q[0]])\n## q.pop(0) #pop dari queue\n## if len(q) == 0: #jika queue kosong menandakan angka tersebut tidak dapat ditemukan\n## print(\"NO\")\n\nq =[b]\nwhile b > a:\n if b % 2 == 0:\n b = int(b/2)\n q += [b]\n elif b % 10 == 1:\n b = int(b/10)\n q += [b]\n else:\n break\n\nq.reverse()\nif a == b:\n print(\"YES\", len(q), sep='\\n')\n for i in q:\n print(i, end=' ')\nelse:\n print(\"NO\")"}, {"source_code": "import copy\nimport sys\nsys.setrecursionlimit(100000)\naa=[]\ndef abc(a,b,ans):\n if a>b:\n return\n if a==b:\n global aa\n aa=copy.copy(ans)\n return\n x=copy.copy(ans)\n x.append(a*2)\n abc(a*2,b,x)\n x.pop()\n x.append(a*10+1)\n abc(a*10+1,b,x)\n\na,b=[int(x) for x in raw_input().split()]\nabc(a,b,[a])\nif len(aa)==0:\n print \"NO\"\nelse:\n print \"YES\"\n print len(aa)\n s=\"\"\n for i in aa:\n s+=str(i)+\" \"\n print s[:-1]\n\n\n"}, {"source_code": "n,m=map(int,raw_input().split())\na=[]\na.append(m)\nwhile n!=m and m>0:\n\tif m%2==0:\n\t\tm/=2\n\t\ta.append(m)\n\telif m%10==1:\n\t\tm/=10\n\t\ta.append(m)\n\telse:\n\t\tbreak\nif n==m:\n\tprint \"YES\"\n\tprint len(a)\n\ta.reverse()\n\tfor i in a:\n\t\tprint i,\nelse:\n\tprint \"NO\""}, {"source_code": "line = input().split()\na = int(line[0])\nb = int(line[1])\ntravel = [] #inisialisasi travel untuk menunjukkan asalnya dari mana\ntravel.append([])\nq = [a] #inisialisasi queue utk BFS\nindex = 0\n#proses BFS\nwhile len(q) > 0:\n## print(q[0])\n## print(travel)\n## if q[0] == b: #jika queue terdepan sudah sama\n## print(\"YES\", len(travel[len(travel) - 2]) + 1, sep='\\n')\n## for i in travel[len(travel) - 2]:\n## print(i, end=' ')\n## print(q[0])\n## break\n## else:\n temp = q[0] * 2 #proses untuk anak kiri\n## print(len(travel), \"index =\", index, \"travel[index] =\", travel[index], \"q =\", q[0])\n## print(temp, q[0])\n if temp <= b and index < len(travel): #dibatasi tidak melebihi b dan index belum melebihi panjang array travel\n q += [temp] #push data baru\n travel.append([]) #array travel ditambah panjangnya\n## print(len(travel), \"index =\", index)\n travel[len(travel) - 1] = list(travel[index]) #mengcopy array dari travel asal\n travel[len(travel) - 1] += [q[0]] #travel baru ditambah dengan q[0] untuk menandakan dia berasal dari node tersebut\n if temp == b: #jika temp sudah sama\n print(\"YES\", len(travel[len(travel) - 1]) + 1, sep='\\n')\n for i in travel[len(travel) - 1]:\n print(i, end=' ')\n print(temp)\n break\n## print(temp, \"travel kali =\", travel[temp], \"travel asal =\", travel[q[0]], end='-----')\n## elif temp ==\n temp = (q[0] * 10) + 1 #Proses untuk anak kanan\n if temp <= b and index < len(travel):\n q += [temp] #push data baru\n travel.append([]) #array travel ditambah panjangnya\n travel[len(travel) - 1] = list(travel[index]) #mengcopy array dari travel asal\n travel[len(travel) - 1] += [q[0]]\n if temp == b: #jika temp sudah sama\n print(\"YES\", len(travel[len(travel) - 1]) + 1, sep='\\n')\n for i in travel[len(travel) - 1]:\n print(i, end=' ')\n print(temp)\n break\n## print(temp, \"travel tambah =\", travel[temp], \"travel asal =\", travel[q[0]])\n q.pop(0) #pop dari queue\n index += 1 #index ditambah menunjukkan asal nodenya\n if len(q) == 0: #jika queue kosong menandakan angka tersebut tidak dapat ditemukan\n print(\"NO\")\n#proses DFS\n#penelusuran terbalik dari bawah ke atas\n##q =[b]\n##while b > a:\n## if b % 2 == 0: #jika genap maka pasti merupakan hasil kali 2\n## b = int(b/2) #karena itu dibagi 2\n## q += [b]\n## elif b % 10 == 1: #jika berakhiran 1, merupakan hasil penambahan digit 1 di belakang\n## b = int(b/10) #karena itu dibagi 10\n## q += [b]\n## else: #jika tidak memenuhi keduanya maka sudah pasti angka tersebut mustahil dicapai\n## break\n##\n##q.reverse() #dibalik untuk pencetakan\n##if a == b:\n## print(\"YES\", len(q), sep='\\n')\n## for i in q:\n## print(i, end=' ')\n##else:\n## print(\"NO\")"}, {"source_code": "def Do():\n global a,b,A,t\n while t==0:\n bb=str(b)[-1]\n if bb=='1':\n b=int(str(b)[:-1])\n A.append(b)\n elif b%2==0:\n b=b//2\n A.append(b)\n else:\n t=2\n if b==a:\n t=1\n elif b<a:\n t=2\na,b=map(int,input().split())\nt=0\nA=[b]\nDo()\nif t-1:\n print('NO')\nelse:\n x=len(A)\n print(\"YES\")\n print(x)\n for i in range(x-1,-1,-1):\n print(A[i],end=' ')"}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n\nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s):\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n\n\na, b = mi()\nans = [b]\nwhile a < b:\n if b % 2 != 0 and b % 10 != 1:\n print('NO')\n exit()\n if b % 2 == 0:\n b //= 2\n ans.append(b)\n if b != 1 and b % 10 == 1:\n b //= 10\n ans.append(b)\nif a == b:\n print('YES')\n print(len(ans))\n print(*ans[::-1])\nelse:\n print('NO')\n\n\n"}, {"source_code": "from sys import stdin, stdout\na, b = map(int,stdin.readline().split())\nq = [ [a,[a]] ]\nans = []\nwhile len(q):\n f = q.pop(0)\n cur,l = f[0],f[1]\n if cur == b:\n ans = l\n break\n n1,n2 = 2*cur, int(str(cur)+'1')\n if n1<=b:\n q.append([ n1,l+[n1] ])\n if n2<=b:\n q.append( [n2,l+[n2]] )\nif len(ans):\n stdout.write(\"YES\\n\")\n stdout.write(\"{}\\n\".format(len(ans)))\n for x in ans:\n stdout.write(\"{} \".format(x))\n stdout.write(\"\\n\")\nelse:\n stdout.write(\"NO\\n\")"}, {"source_code": "# -*- coding: utf-8 -*-\n\ndef work(x):\n\tif (x>a):\n\t\tif (x%2==0):\n\t\t\tt = work(x//2)\n\t\t\tif (t < 0): return -1\n\t\t\tf[x] = x//2\n\t\t\treturn t+1\n\t\telif (x%10==1):\n\t\t\tt = work(x//10)\n\t\t\tif (t < 0): return -1\n\t\t\tf[x] = x//10\n\t\t\treturn t+1\n\t\telse: return -1\n\telif (x==a): return 0\n\telse: return -1\n\ndef printf(x):\n\tif (x!=a):\n\t\tprintf(f[x])\n\tif (x!=b): print(x,end=' ')\n\telse: print(x,end='\\n')\n\treturn\n\t\na, b = input().split(' ')\na = int(a)\nb = int(b)\nf = {}\nans = work(b)\nif ans < 0 : print('NO')\nelse:\n\tprint('YES')\n\tprint(ans+1)\n\tprintf(b)"}, {"source_code": "def main():\n a, b = map(int, input().split())\n\n path = [b]\n while b > 0 and b != a:\n if b % 10 == 1:\n b //= 10\n elif b % 2 == 0:\n b //= 2\n else:\n path = None\n break\n\n path.append(b)\n\n if not path or path[-1] != a:\n print('NO')\n else:\n print('YES')\n print(len(path))\n print(' '.join([str(x) for x in reversed(path)]))\n\n\nmain()\n"}, {"source_code": "a,b=input().split()\ns=[]\ns.append(b)\nwhile 1:\n if int(b[-1])!=1 and int(b)%2!=0:\n print('NO')\n break\n u=0\n while True:\n if len(b)!=0 and b[-1]=='1' and int(a)<int(b):\n b=list(b)\n del b[-1]\n b=''.join(b)\n s.append(b)\n elif len(b)!=0 and int(b)%2==0 and a!=b and len(b)!=0 and int(a)<int(b):\n b=str(int(int(b)/2))\n s.append(b)\n elif b==a:\n s.append(a)\n break\n elif len(b)!=0:\n u+=1\n \n break\n elif len(b)==0:\n break\n \n elif a==b:\n break\n elif len(b)!=0 and a!=b:\n u+=1\n \n \n break\n elif a==b:\n break\n del s[-1]\n s.reverse()\n if u:\n print('NO')\n break\n else:\n print('YES')\n print(len(s))\n print(*s)\n break\n\n"}, {"source_code": "def main():\n def f(a, b):\n if a == b:\n return (True, [])\n if a > b:\n return (False, [])\n (f1, x1) = f(2 * a, b)\n if f1:\n return (True, [(2 * a)] + x1)\n (f2, x2) = f(int(str(a) + '1'), b)\n if f2:\n return (True, [int(str(a) + '1')] + x2)\n return (False, [])\n (a, b) = map(int, input().split(' '))\n (f, x) = f(a, b)\n if f:\n x = [a] + x\n print(\"YES\")\n print(len(x))\n print(' '.join(list(map(str, x))))\n else:\n print(\"NO\")\nmain()\n"}, {"source_code": "a, b = map(int, input().split())\n\nseq = [b]\nwhile b > a:\n if b % 2 == 0:\n b //= 2\n seq.append(b)\n elif b % 10 == 1:\n b //= 10\n seq.append(b)\n else:\n print(\"NO\")\n exit(0)\n\nif b != a:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(len(seq))\n print(' '.join(map(str, seq[::-1])))\n"}, {"source_code": "def com1(x):\n return 2*x\n\ndef com2(x):\n return 10 * x + 1\n\ndef decom2(x):\n return (x - 1) // 10\n\ndef decom1(x):\n return x // 2\n\na,b = map(int, input().split())\ntest = b\nlist1 = [b]\n\nwhile (test >= 1) and (test != a):\n if test % 10 == 1:\n test = decom2(test)\n elif test % 2 == 0:\n test = decom1(test)\n else:\n break\n list1.append(test)\n \nif test == a:\n print('YES')\n print(len(list1))\n for i in range(-1,-len(list1)-1,-1):\n print(list1[i], end = ' ')\nelse:\n print('NO')\n\n\n"}, {"source_code": "a, b = map (int, input().split())\nc=[str(b)]\nwhile b>a:\n if b%10==1 and b!=1:\n b//=10\n c.append(str(b))\n elif b%2==0:\n b//=2\n c.append(str(b))\n if b==a:\n print('YES', len(c), ' '.join(c[::-1]), sep='\\n')\n break\n elif (b%2!=0 and b%10!=1) or b<a:\n print('NO')\n break\n"}, {"source_code": "a,b=map(int,input().split())\nl=[b]\nwhile b>a:\n\tif b%2==0:\n\t\tb=b//2\n\telif b%10==1:\n\t\tb//=10\n\telse:\n\t\tprint(\"NO\")\n\t\texit()\n\tl.append(b)\nif b!=a:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\tprint(len(l))\n\tprint(*(l[::-1]))"}, {"source_code": "a,b=map(int,input().split())\nans=[b]\nwhile(b>a):\n if b%2==0:\n b//=2\n ans.append(b)\n elif b%10==1:\n b//=10\n ans.append(b)\n else:\n break\nif b==a:\n print(\"YES\")\n print(len(ans))\n ans.sort()\n print(*ans)\nelse:\n print(\"NO\")"}, {"source_code": "from collections import *\nfrom math import *\n\na,b = list(map(int,input().split()))\nans = [b]\nwhile(b > a):\n\tif(b%10 == 1):\n\t\tb //= 10\n\telif((b%10)&1):\n\t\tprint(\"NO\")\n\t\texit(0)\n\telse:\n\t\tb //= 2\n\tans.append(b)\nif(a != b):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\tans = ans[::-1]\n\tprint(len(ans))\n\tprint(*ans)\n"}, {"source_code": "from collections import deque\n\n\na, b = map(int, input().split())\nnum = b\nans = deque()\ncnt = 0\nwhile num > a:\n if not num % 2:\n ans.appendleft(num)\n cnt += 1\n num //= 2\n else:\n if str(num)[-1] == '1':\n ans.appendleft(num)\n cnt += 1\n num = int(str(num)[:-1])\n else:\n print(\"NO\")\n exit()\nif num == a:\n ans.appendleft(num)\n cnt += 1\nif num not in ans:\n print(\"NO\")\n exit()\nprint(\"YES\")\nprint(cnt)\nprint(*ans)"}, {"source_code": "def reach(a, b, path=[]):\n if a > b: return\n if a == b:\n path.append(a)\n print(\"YES\")\n print(len(path))\n print(*path)\n exit(0)\n reach(a*2,b,path+[a])\n reach(a*10+1,b,path+[a])\na,b=map(int,input().split())\nreach(a,b,[])\nprint(\"NO\")\n"}, {"source_code": "flag=True\ndef fun(a,b,ind,temp):\n global flag\n if a==b:\n flag=False\n print(\"YES\")\n print(ind)\n for i in range(0,ind-1):\n print(temp[i],end=' ')\n print(temp[ind-1])\n return \n if a>b:\n return \n temp[ind]=2*a\n fun(2*a,b,ind+1,temp)\n temp[ind]=10*a+1\n fun(10*a+1,b,ind+1,temp)\n\narr=list(map(int,input().split()))\ntemp=[0]*(32)\ntemp[0]=arr[0]\n\nfun(arr[0],arr[1],1,temp)\nif flag:\n print(\"NO\")\n "}, {"source_code": "a,b=[int(i) for i in input().split()]\nop=[]\nwhile b>=a:\n op=[b]+op\n if b%10==1:\n b-=1\n b//=10\n elif b%2==0:\n b//=2\n else:\n break\nif a==op[0]:\n print('YES')\n print(len(op))\n print(' '.join([str(i) for i in op]))\nelse:\n print('NO')"}, {"source_code": "a,b = map(int,input().split())\nr = [b]\nwhile b>a:\n if b%2==0:\n b=b//2\n else:\n if str(b)[-1]=='1':\n b = int(str(b)[:-1])\n else:\n print('NO')\n break\n r.append(b)\nelse:\n if b==a:\n print('YES')\n print(len(r))\n print(*(r[::-1]))\n else:\n print('NO')"}, {"source_code": "n,k=map(int,input().split())\nl1=[]\nl1.append(k)\nwhile(True):\n if(k%2!=0 and k%10!=1):\n break\n elif(k%2==0):\n k=int(k/2)\n l1.append(k)\n elif(k%10==1):\n k=int(k/10)\n l1.append(k)\n if(k==n or k<n):\n break\nif(k==n):\n print(\"YES\")\n print(len(l1))\n l1.sort()\n for i in range (len(l1)):\n print(l1[i],end=\" \")\nelse:\n print(\"NO\")\n "}, {"source_code": "a, b = map(int, input().split())\nmass = [b]\nwhile a != b:\n\tif str(b)[-1] != '1' and b % 2 != 0 and a > b or b == 0:\n\t\tprint('NO')\n\t\texit()\n\telse:\n\t\tif str(b)[-1] == '1' and len(str(b)) != 1:\n\t\t\tb = int(str(b)[:-1])\n\t\telif b % 2 == 0: \n\t\t\tb = b // 2\n\t\telse:\n\t\t\tprint('NO')\n\t\t\texit()\n\t\tmass.append(b)\nprint('YES')\nprint(len(mass))\nprint(*mass[::-1])"}, {"source_code": "a , b = map(int,input().split())\n\ncnt = 1\nans = [b]\nflag = True\nwhile b > a :\n r = b % 10\n if r % 2 == 0 :\n b //= 2\n cnt +=1\n ans.append(b)\n\n else:\n if b % 10 % 2 != 0 and b % 10 != 1 :\n flag = False\n break\n else:\n b //= 10\n ans.append(b)\n cnt +=1\n\n#print(b)\nif flag and a == b:\n print('YES')\n print(cnt)\n ans = list(reversed(ans))\n print(*ans)\n\nelse:\n print('NO')\n\n\n"}, {"source_code": "def solve(n:int):\n global answer, a\n answer.append(n)\n if n<=a:\n return 0\n if n%10==1:\n return solve(n//10)\n elif n%2==0:\n return solve(n//2)\n else:\n print(\"NO\")\n exit()\n\n\na, b = map(int, input().split())\nanswer = list()\nsolve(b)\nif answer[-1] != a:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(answer.__len__())\n for i in range(answer.__len__()-1, -1, -1):\n print(answer[i], end=\" \")"}, {"source_code": "a,b = map(int,input().split())\nl = [b]\nwhile b > a:\n if b%2 == 0:\n b//=2\n elif b%10 == 1:\n b -= 1\n b//=10\n else:\n break\n \n l.append(b)\nif b == a:\n l = l[::-1]\n print(\"YES\")\n print(len(l))\n print(\" \".join(map(str,l)))\nelse:\n print(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\nway = []\nwhile b > a:\n way.append(b)\n if b % 2 == 0:\n b //= 2\n else:\n if b % 10 == 1:\n b -= 1\n b //= 10\n else:\n print(\"NO\")\n exit(0)\nway.append(a)\nif a != b:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(len(way))\n print(*reversed(way))\n"}, {"source_code": "n, target = map(int, input().split())\n\n\ndef keep(target, ans):\n #print(target)\n while target % 2 == 0:\n target = target // 2\n ans = [target]+ans\n if str(target).endswith(\"1\") and target != 1:\n return keep((target-1) // 10, [(target-1) // 10]+ans)\n else:\n return target, ans\n\nnext, nos = keep(target, [target])\n\nif n in nos:\n print(\"YES\")\n nos = nos[nos.index(n):]\n print(len(nos))\n print(\" \".join(str(k) for k in nos))\nelse:\n print(\"NO\")"}, {"source_code": "a,b=list(map(int,input().split()))\ntmp=b\n\narr=[str(b)]\nc=0\nwhile(tmp>=a):\n\tif(tmp==a):\n\t\tprint(\"YES\")\n\t\tprint(len(arr))\n\t\tarr=arr[::-1]\n\t\tprint(' '.join(arr))\n\t\texit()\n\t\t\n\tif(tmp%2!=0):\n\t\tif(str(tmp)[-1]!='1'):\n\t\t\tprint(\"NO\")\n\t\t\texit()\n\t\telse:\n\t\t\ttmp=int(str(tmp)[:-1])\n\telse:\n\t\ttmp=tmp//2\n\n\tarr.append(str(tmp))\n\t# c+=1\nprint(\"NO\")"}, {"source_code": "\"\"\"\nAuthor : co_devil Chirag Garg\nInstitute : JIIT\n\"\"\"\n\nfrom __future__ import division, print_function\nimport itertools, os, sys, threading\nfrom collections import deque, Counter, OrderedDict, defaultdict\n# from heapq import nsmallest, nlargest, heapify, #heappop ,heappush, heapreplace\nfrom math import ceil,floor,log,sqrt,factorial,pow,pi\n# from bisect import bisect_left,bisect_right\n# from decimal import *,threading\n\"\"\"from io import BytesIO, IOBase\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n from builtins import str as __str__\n str = lambda x=b'': x if type(x) is bytes else __str__(x).encode()\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._buffer = BytesIO()\n self._fd = file.fileno()\n self._writable = 'x' in file.mode or 'r' not in file.mode\n self.write = self._buffer.write if self._writable else None\n\n def read(self):\n return self._buffer.read() if self._buffer.tell() else os.read(self._fd, os.fstat(self._fd).st_size)\n\n def readline(self):\n while self.newlines == 0:\n b, ptr = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)), self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines += b.count(b'\\n') + (not b)\n self.newlines -= 1\n return self._buffer.readline()\n\n def flush(self):\n if self._writable:\n os.write(self._fd, self._buffer.getvalue())\n self._buffer.truncate(0), self._buffer.seek(0)\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b'\\r\\n')\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop('sep', b' '), kwargs.pop('file', sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop('end', b'\\n'))\n if kwargs.pop('flush', False):\n file.flush()\n\n\"\"\"\n\n\ndef ii(): return int(input())\ndef si(): return str(input())\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n\n\nabc = 'abcdefghijklmnopqrstuvwxyz'\nabd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12,\n 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24,\n 'z': 25}\nmod = 1000000007\ndx, dy = [-1, 1, 0, 0], [0, 0, 1, -1]\ndef getKey(item): return item[0]\ndef sort2(l): return sorted(l, key=getKey)\ndef d2(n, m, num): return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo(x): return (x and (not (x & (x - 1))))\ndef decimalToBinary(n): return bin(n).replace(\"0b\", \"\")\ndef ntl(n): return [int(i) for i in str(n)]\ndef powerMod(x, y, p):\n res = 1\n x %= p\n while y > 0:\n if y & 1:\n res = (res * x) % p\n y = y >> 1\n x = (x * x) % p\n return res\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n# For getting input from input.txt file\n# sys.stdin = open('input.txt', 'r')\n\n# Printing the Output to output.txt file\n# sys.stdout = open('output.txt', 'w')\n\ngraph = defaultdict(list)\nvisited = [0] * 1000000\ncol = [-1] * 1000000\ndef dfs(v, c):\n if visited[v]:\n if col[v] != c:\n print('-1')\n exit()\n return\n col[v] = c\n visited[v] = 1\n for i in graph[v]:\n dfs(i, c ^ 1)\n\ndef bfs(d,v):\n q=[]\n q.append(v)\n visited[v]=1\n while len(q)!=0:\n x=q[0]\n q.pop(0)\n for i in d[x]:\n if visited[i]!=1:\n visited[i]=1\n q.append(i)\n print(x)\ndef make_graph():\n d={}\n v,e=mi()\n for i in range(e):\n x,y=mi()\n if x not in d.keys():\n d[x]=[y]\n else:\n d[x].append(y)\n if y not in d.keys():\n d[y] = [x]\n else:\n d[y].append(x)\n return d\ndef gr2(n):\n d={}\n for i in range(n):\n x,y=mi()\n if x not in d.keys():\n d[x]=[y]\n else:\n d[x].append(y)\n return d\n\nx,y=mi()\ny=str(y)\nz=y\nans='NO'\nout=[]\nwhile x<=int(y):\n if y[-1]=='1':\n y=y[:-1]\n elif int(y)%2==0:\n y=str(int(y)//2)\n else:\n break\n if x==int(y):\n ans='YES'\n break\n out.append(y)\nprint(ans)\nif ans=='YES':\n out.append(str(x))\n out=out[::-1]\n out.append(z)\n print(len(out))\n print(' '.join(out))"}, {"source_code": "a,b=list(map(int,input().split()))\nA=[b]\nBool=False\nwhile(True):\n if a>=b:\n if a == b:\n Bool = True\n else:\n Bool = False\n break\n else:\n if str(b)[-1]=='1':\n b=int(str(b)[:len(str(b))-1])\n A.append(b)\n else:\n if b % 2 == 0:\n b = b//2\n A.append(b)\n else:\n break\nif Bool==False:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(len(A))\n print(*A[::-1])"}, {"source_code": "a, b = map(int, raw_input().split())\nn = b\ns = []\nwhile True:\n s.append(n)\n if n <= a: break\n if n % 2 == 0:\n n /= 2\n elif n % 10 == 1:\n n /= 10\n else:\n n = 0\nif a == n:\n print 'YES'\n print len(s)\n print ' '.join(map(str, reversed(s)))\nelse:\n print 'NO'"}, {"source_code": "# LINK FOR PROBLEM: http://codeforces.com/problemset/problem/727/A\n\ndef ends_with_one(number):\n number = str(number)\n return number[-1] == \"1\"\n\ndef del_last_one(number):\n number = str(number)\n t = len(number)\n number = int( number[:t-1] )\n return number\n\ndef isEven(number):\n return (number % 2 == 0)\n\n\na, b = map(int, raw_input().split())\nfila = [str(b)]\n\n\ncurrent_number = b\n\nwhile current_number > a:\n\n if ends_with_one(current_number):\n current_number = del_last_one(current_number)\n fila.append(str(current_number))\n\n elif isEven(current_number):\n current_number = current_number / 2\n fila.append(str(current_number))\n\n else:\n current_number = a-1\n break\n\nif current_number < a:\n print \"NO\"\n\nelif current_number == a:\n\n print \"YES\"\n print len(fila)\n print \" \".join(str(fila[i]) for i in range(len(fila)-1, -1, -1 ))\n\n\n\n\n\n\n"}, {"source_code": "a, b = [int(i) for i in input().split()]\ns = str(b)\nwhile b > a:\n if str(b)[-1] == '1':\n b = b // 10\n s += ' ' + str(b)\n elif b % 2 == 0:\n s += ' ' + str(b // 2)\n b = b // 2\n\n else:\n break\nif b == a:\n print('YES')\n print(s.count(' ') + 1)\n print(' '.join(s.split()[::-1]))\nelse:\n print('NO')\n"}, {"source_code": "n, m = map(int, input().split())\nls = [m]\n\nif m % 10 == 1 or m % 2 == 0:\n while m >= n:\n fl = False\n while m % 2 == 0 and n != m:\n m //= 2\n ls.append(m)\n fl = True\n if m % 10 == 1 and n != m:\n m //= 10\n ls.append(m)\n fl = True\n if not fl:\n if n == m:\n print('YES')\n print(len(ls))\n print(*ls[::-1])\n break\n else:\n print('NO')\n break\n if m < n:\n print('NO')\nelse:\n print('NO')\n "}, {"source_code": "a,b=map(int,input().split())\npath=[]\ndef recurs(n):\n global path\n global a\n if n==a:\n return True\n if n<a:\n return False\n if n%2==0:\n x=recurs(n//2)\n path.append(n)\n if x==True:\n return True\n path.pop()\n if (n-1)%10==0:\n x=recurs((n-1)//10)\n path.append(n)\n if x==True:\n return True\n path.pop()\n return False\nx=recurs(b)\nif x==True:\n print('YES')\n print(len(path)+1)\n print(a,end=' ')\n for i in range(len(path)):\n print(path[i],end=' ')\nelse:\n print('NO')"}, {"source_code": "a, b = [int(x) for x in input().split()]\n\nlista = []\naux = b\nresp = 'NO'\nwhile aux > a:\n\tlista.append(str(int(aux)))\n\t\n\tif aux % 2 == 0:\n\t\taux /= 2\n\telse:\n\t\t\n\t\tif not ((aux-1) % 10):\n\t\t\taux = (aux-1) / 10\n\t\telse:\n\t\t\tbreak\n\t\n\tif aux == a:\n\t\tresp = 'YES'\n\t\tlista.append(str(int(aux)))\n\t\t\n\t\t\nif resp == 'YES':\n\tprint(resp)\n\tprint(len(lista))\n\tlista.reverse()\n\tprint(\" \".join(lista))\n\nelse:\n\tprint(resp)\n\t\n\t\t\n"}, {"source_code": "a,b = map(int,raw_input().split())\ns = [str(b)]\nwhile 1:\n if b%10==1:\n b = b/10\n s.append(str(b))\n else:\n if b%2==0:\n b = b/2\n s.append(str(b))\n else:\n print 'NO'\n exit(0)\n if b==a:\n print 'YES'\n print len(s)\n print ' '.join(s[::-1])\n exit(0)\n if b<a:\n print 'NO'\n exit(0)"}, {"source_code": "a, b = map(int, input().split())\nans = [b]\nwhile True:\n if b % 10 == 1:\n b //= 10\n elif b % 2 == 0:\n b //= 2\n else:\n break\n if a >= b:\n break\n ans.append(b)\nans.append(a)\nif a != b:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(len(ans))\n print(*ans[::-1])"}, {"source_code": "a, b = input().split()\na = int(a)\nb = int(b)\nc = b\nd = ''\nt = ''\n\nn = [a]\nwhile a != c:\n if (c % 2 == 0) and (a <= c):\n c = c / 2\n d = d + '1'\n elif (c - 1) % 10 == 0 and (a <= c):\n c = (c - 1) / 10\n d = d + '2'\n else:\n break\nif a == c:\n print('YES')\n t = d[::-1]\n f = len(t)\n print(len(t) + 1)\n for i in range (1, f + 1):\n if t[i-1:i] == '1':\n a = a * 2\n n.append(a)\n else:\n a = (a * 10) + 1\n n.append(a)\n for i in range(0, f + 1):\n print(n[i], end = ' ')\nelif c != a:\n print('NO')\n\n\n"}, {"source_code": "# http://codeforces.com/problemset/problem/727/A\n\n\ndef dfs(q, n, steps):\n if n == q:\n return True\n elif n > q:\n return False\n\n a = dfs(q, n * 2, steps)\n b = dfs(q, (n * 10) + 1, steps)\n\n if a:\n steps.append(n * 2)\n if b:\n steps.append((n * 10) + 1)\n\n return a or b\n\na, b = map(int, raw_input().split())\nsteps = []\n\nif not dfs(b, a, steps):\n print 'NO'\n\nelse:\n print 'YES'\n steps.append(a)\n steps.reverse()\n print len(steps)\n print ' '.join(map(str, steps))\n"}, {"source_code": "A = list(map(int,input().split()))\na = A[0]\nb = A[1]\nA.clear()\nA.append(b)\nwhile b != a:\n if (b-1) % 10 == 0 and b >= a:\n b = (b-1)//10\n A.append(b)\n elif b % 2 == 0 and b >= a: \n b = b//2\n A.append(b)\n else:\n break\nif a == b:\n A = sorted(A)\n print('YES')\n print(len(A))\n print(*A,sep = ' ')\nelse:\n print('NO')"}, {"source_code": "a,b = map(int,input().split())\nlst = []\nwhile b > a:\n lst.append(b)\n if str(b)[-1] == '1':\n b = int(str(b)[:-1])\n else:\n if b%2 == 0:\n b //= 2\n else:\n print('NO')\n exit()\n\nlst.append(a)\nif b == a:\n print('YES')\n print(len(lst))\n print(*lst[::-1])\nelse:\n print('NO')"}, {"source_code": "\ndef make_a_into_b(a, b):\n if a == b:\n return [a]\n elif a > b:\n return None\n else:\n one = make_a_into_b(a * 2, b)\n another = make_a_into_b(10 * a + 1, b)\n\n if one is None and another is None:\n return None\n elif one is None:\n result = another\n elif another is None:\n result = one\n else:\n result = min(one, another, key=len)\n\n result.append(a)\n\n return result\n\na, b = map(int, raw_input().split(' '))\n\nresult = make_a_into_b(a, b)\n\nif result is not None:\n print \"YES\"\n print len(result)\n print ' '.join(map(str, reversed(result)))\nelse:\n print \"NO\"\n"}], "negative_code": [{"source_code": "# cook your dish here\na, b = [int(x) for x in input().split()]\n\nr = []\nr.append(b)\nif b & 1:\n b -= 1\n b = b // 10\n r.append(b) \nwhile b != 0:\n if b < a:\n break\n if b == a:\n break\n if b & 1:\n b -= 1\n b = b // 10\n else:\n b = b // 2\n r.append(b)\nif b == a:\n print(\"YES\")\n print(len(r))\n r = sorted(r)\n for x in range(len(r)):\n print(r[x], end=' ')\nelse:\n print(\"NO\")"}, {"source_code": "import math\na,b=[int(i) for i in raw_input().split()]\nf=0\nl=[b]\nwhile b>a:\n if str(b)[::-1][0]=='1':\n b=int(str(b)[:len(str(b))-1])\n l.append(b)\n elif b%2==0:\n b=b/2\n l.append(b)\n else:\n f=0\n break\nif b==a:\n print \"YES\"\n for i in l[::-1]:\n print i,\nelse:\n print \"NO\"\n"}, {"source_code": "a,b = map(int,input().split())\nflag = 0\ni = 1\nt = [b]\nwhile True:\n\tif b <= 2:\n\t\tprint()\n\n\tif b < a:\n\t\tflag = 1\n\t\tbreak\n\telif b == a:\n\t\tbreak\n\tif (b)%2 == 0:\n\t\tb = b//2\n\t\tt.append(b)\n\telif b%10 == 1:\n\t\tb = b//10\n\t\tt.append(b)\n\telif b%2 == 1 and b != a:\n\t\tflag = 1\n\t\tbreak\n\ti = i + 1\nif flag == 0:\n\tprint(\"YES\")\n\tprint(i)\n\tfor i in range(1,len(t)+1):\n\t\tprint(t[-i],end=\" \")\nelse:\n\tprint(\"NO\")"}, {"source_code": "a, b = list(map(int, input().split()))\narr = [str(b)]\nwhile b > a:\n if b % 10 == 1:\n b //= 10\n arr.append(str(b))\n elif b % 2 == 0:\n b //= 2\n arr.append(str(b))\n else:\n b = -1\nif b == a:\n print('YES', len(arr), ' '.join(arr), sep='\\n')\nelse:\n print('NO')\n "}, {"source_code": "a,b=map(int,input().split())\nk=[b]\nwhile b>a:\n if b%2==0:\n b=int(b/2)\n k.append(b)\n else:\n b=int(b//10)\n k.append(b)\nk.reverse()\nif min(k)==a:\n print('YES')\n print(len(k))\n for item in k:\n print(item, end=\" \")\nelse:\n print('NO')"}, {"source_code": "a,n=map(int,input().split())\nans = []\nj = 0\nz = 0\nfor g in range(a):\n s = str(n)\n if s[-1] == \"1\":\n s = s[0:len(s)-1]\n if s != \"\":\n n = int(s)\n \n ans.append(n)\n j += 1\n \n if n == a:\n z = 1\n break\n if n % 2 == 0:\n n = n // 2\n ans.append(n)\n j += 1\n if n == a:\n z = 1\n break\nt = 1 \nif z == 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(j+1)\n for i in range(len(ans)-1,-1,-1):\n print(ans[i], end=\" \")\n \n print(ans[0]*2)\n\n"}, {"source_code": "a,b = map(int,raw_input().split())\nl = []\nl.append(a)\nwhile True:\n\tif a > b:\n\t\tprint \"NO\"\n\t\tprint l\n\t\tbreak\n\tif a == b:\n\t\tprint \"YES\"\n\t\tfor i in l:\n\t\t\tprint i,\n\t\tbreak\n\tif b%a == 0:\n\t\ta *= 2\n\t\tl.append(a)\n\telif b%(10* a +1) == 0 or b%(10* a+1) == 1:\n\t\ta = 10* a +1\n\t\tl.append(a)\n\telse:\n\t\ta *= 2\n\t\tl.append(a)"}, {"source_code": "\"\"\"\n// Author : snape_here - Susanta Mukherjee\n \n \"\"\"\n \nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n \n \ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n \ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nmod=1000000007\n\nimport math\n\ndef main():\n\n a,b=mi()\n l=[]\n while(b!=a):\n l.append(b)\n if b%10==1:\n b=str(b)\n b=b[0:len(b)-1]\n b=int(b)\n else:\n b//=2 \n if a>b:\n print(\"NO\")\n exit()\n l.append(a)\n print(\"YES\")\n print(len(l))\n l.reverse()\n print(*l)\n\n\n \n# region fastio\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n main()"}, {"source_code": "def com1(x):\n return 2*x\n\ndef com2(x):\n return 10 * x + 1\n\ndef decom2(x):\n return (x - 1) // 10\n\ndef decom1(x):\n return x // 2\n\na,b = map(int, input().split())\ntest = b\nlist1 = [b]\n\nwhile (test >= 1) and (test != a):\n if test % 10 == 1:\n test = decom2(test)\n else:\n test = decom1(test)\n list1.append(test)\n \nif test == a:\n print('YES')\n print(len(list1))\n for i in range(-1,-len(list1)-1,-1):\n print(list1[i], end = ' ')\nelse:\n print('NO')\n\n\n"}, {"source_code": "n,m = map(int,input().split())\nl = []\nl.append(m)\n\nwhile m>0:\n if m%2==1:\n m=m//10\n else:\n m=m//2\n l.append(m)\n if m==n:\n print(\"YES\")\n print(len(l))\n print(*l[::-1])\n exit()\nprint(\"NO\")"}, {"source_code": "import sys\n\n[a, b] = [int(x) for x in sys.stdin.readline().split()]\nres = []\n\nwhile b > a:\n\tres.append(b)\n\n\tif b % 2 == 0:\n\t\tb /= 2\n\telif b % 10 == 1:\n\t\tb /= 10\n\telse:\n\t\tbreak\n\nif b != a:\n\tprint \"NO\"\n\tsys.exit(0)\n\nres.append(a)\nres.reverse()\n\nprint \"YES\"\nprint ' '.join([str(x) for x in res])\n\n\n\n"}, {"source_code": "# Breno Souza\n\na, b = map(int, raw_input().split())\n\npossivel = False\netapas = [b]\n\nwhile True:\n\tif (a == b):\n\t\tprint \"YES\"\n\t\tpossivel = True\n\t\tbreak\n\telif (a > b):\n\t\tprint \"NO\"\n\t\tbreak\n\telif (b % 2 == 0):\n\t\tb /= 2\n\t\tetapas.append(b)\n\telse:\n\t\tb = (b - 1)/10\n\t\tetapas.append(b)\n\nprint len(etapas)\netapas.reverse()\n \nif (possivel):\n\tfor etapa in etapas:\n\t\tprint etapa,\n\t\n"}, {"source_code": "a,b=map(int,input().split())\nr=[b]\nwhile b>a:\n if b%10==1:\n b=b//10\n r.append(b)\n else:\n b=b//2\n r.append(b)\nif r[len(r)-1]==a:\n print('YES')\n print(len(r))\n print(*r[::-1])\nelse:\n print('NO')"}, {"source_code": "a, b = map(int, input().split())\nC = []\nC.append(b)\nwhile a < b:\n if b % 10 == 1:\n b = (b - 1) // 10\n C.append(b)\n else:\n b = b // 2\n C.append(b)\nC = list(reversed(C))\nif C[0] == a:\n print(\"YES\")\n print(*C)\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\ns += \" \"\nk = 0\na = \"\"\nb =\"\"\nfor i in s:\n if k == 0:\n if i != ' ':\n a += i\n else:\n k += 1\n elif k == 1:\n if i != ' ':\n b += i\na1 = []\nb1 = []\na1 += a\nb1 += b\na2 = int(a)\nb2 = int(b)\ny1 = b\ny = []\nwhile b2 > a2:\n if (b2 - 1) % 10 == 0:\n b2 = int((b2 - 1) / 10)\n y.append(b2)\n else:\n if b2 % 2 == 0:\n b2 = int(b2 / 2)\n y.append(b2)\n else:\n print(\"NO\")\n break\nif b2 == a2:\n print(\"YES\")\n print(len(y) + 1)\n y = y[::-1]\n for i in y:\n print(i, end=\" \")\n print(y1)\nelse:\n print(\"NO\")"}, {"source_code": "# cook your dish here\na, b = [int(x) for x in input().split()]\n\nr = []\nr.append(b)\nif b & 1:\n b -= 1\n b = b // 10\n r.append(b) \nwhile b != 0:\n if b < a:\n break\n if b == a:\n break\n if b & 1:\n b -= 1\n b = b // 10\n else:\n b = b // 2\n r.append(b)\nif b == a:\n print(\"YES\")\n r = sorted(r)\n for x in range(len(r)):\n print(r[x], end=' ')\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nc=0;k=0;s=''\nwhile a!=b and c==0 and b!=0:\n if b%10==1:\n b=b//10\n s=s+'1'\n else:\n if b%2==1:\n c=1\n else:\n b=b//2\n s=s+'2'\n k+=1\nif c==0 and b!=0:\n print('YES')\n print(k+1)\n print(a,end=' ')\n for i in range(k):\n if int(s[len(s)-1-k])==1:\n print(a*10+1,end='')\n a=a*10+1\n else:\n print(a*2,end=' ')\n a=a*2\nelse:\n print('NO')"}, {"source_code": "a,b = map(int,input().split())\nlst = []\nwhile b > a:\n lst.append(b)\n if str(b)[-1] == '1':\n b = int(str(b)[:-1])\n else:\n b //= 2\n\nlst.append(a)\nif b == a:\n print('YES')\n print(*lst[::-1])\nelse:\n print('NO')"}, {"source_code": "a,b=map(int,input().split())\nr=[b]\nwhile b>a:\n if b%10==1:\n b=b//10\n r.append(b)\n else:\n b=b//2\n r.append(b)\nif r[len(r)-1]==a:\n print('YES')\n print(len(r))\n print(*r[::-1])\nelse:\n print('NO')"}, {"source_code": "a,b=map(int,input().split())\nused=[]\nwhile a!=b:\n if b%10==1:\n used.append(b)\n b=(b-1)//10\n elif b%2==0:\n used.append(b)\n b=b//2\n else:\n break\n"}, {"source_code": "a, b = map(int, input().split())\nsteps = list()\nsteps.append(b)\nDone = False\nwhile b != a:\n if (b - 1)%10 == 0:\n b = (b-1)//10\n steps.append(b)\n if b % 2 == 0:\n b = b//2\n steps.append(b)\n if (b - 1)%10 != 0 and b % 2 != 0:\n print('NO')\n Done = True\n break\nif Done is False:\n print('YES')\n print(len(steps))\n print(list(reversed(steps)))"}, {"source_code": "n,k=list(map(int,input().split()))\nanswer=[]\nanswer.append(k)\nf=0\ndef w(x):\n global n\n global f\n if x==n:\n print('YES')\n print(len(answer))\n l=len(answer)\n f=1\n for i in range(l):\n print(answer[l-i-1],' ',end='')\n \n \nwhile k>n:\n if k%2==0:\n k=k//2\n answer.append(k)\n if k%10==1:\n k=(k-1)//10\n answer.append(k)\n if k==n:\n print('YES')\n print(len(answer))\n l=len(answer)\n for i in range(l):\n print(answer[l-i-1],' ',end='')\n break\n elif (k%2!=0 and k%10!=1) or k<n:\n print('NO')\n break\n \n"}, {"source_code": "a,b=map(int,input().split())\nc=[b]\nflag=0\nwhile b>a:\n if b%2==0:\n b=b//2\n elif b%10==1:\n b=b//10\n else:\n print(\"NO\")\n break\n c.append(b)\n if b==a:\n flag=1\n c.reverse()\n print(len(c))\n for i in range(len(c)):\n print(c[i],end=\" \")\nif flag==0:\n print(\"NO\")"}, {"source_code": "def main():\n a, b = map(int, input().split())\n\n path = [b]\n while b > 0 and b != a:\n if b % 10 == 1:\n b //= 10\n elif b % 2 == 0:\n b //= 2\n else:\n path = None\n break\n\n path.append(b)\n\n if not path or path[-1] != a:\n print(\"NO\")\n else:\n print(' '.join([str(x) for x in reversed(path)]))\n\n\nmain()\n"}, {"source_code": "a,b = map(int,input().split())\nFlag = True\nc = [b]\nwhile a != b and Flag:\n if b % 10 == 1:\n b = b // 10\n c.append(b)\n elif b % 2 == 0 and b != 0:\n b = b // 2\n c.append(b)\n else:\n Flag = False\nif Flag:\n print ('Yes')\n print (len(c))\n print (c[::-1])\nelse:\n print ('No')\n \n\n \n"}, {"source_code": "a, b = map(int, raw_input().split())\n \nvector = []\nok = True\n \nwhile b > a:\n vector.append(b)\n if b % 2 == 0:\n b = b/2\n elif b % 10 == 1:\n b = b/10\n else:\n break\n \nif b!=a:\n ok = False\nelse:\n vector.append(a)\n \nif not ok:\n print \"NO\"\nelse:\n print \"YES\"\n print len(vector)\n \n for i in xrange(len(vector)-1, 0, -1):\n print str(vector[i]),\n print vector[0]\n"}, {"source_code": "import sys\n\na, b = sys.stdin.readline().strip().split()\na, b = int(a), int(b)\n\nmas = []\n\nwhile b>=a:\n mas += [b]\n if b % 2 == 0:\n b=b/2\n else:\n b=(b-1)/10\nmas.reverse()\n\nif a==mas[0]:\n print \"YES\"\n print len(mas)\n print \" \".join(map(str, mas))\nelse:\n print \"NO\"\n\n\n"}, {"source_code": "(a,b) = map(int,raw_input().split())\nanmas = [b]\n\nwhile b>a:\n if b%2==0:\n b/=2\n anmas.append(b)\n elif b%10==1:\n b/=10\n anmas.append(b)\n else:\n print \"NO\"\n break\n\nif b==a:\n anmas.append(b)\n anmas.reverse()\n print \"YES\"\n print len(anmas)\n print ' '.join(map(str,anmas))\n"}, {"source_code": "lst = list(map(int, input().split()))\nb = lst[0]\na = lst[1]\nk = 0\nlst = []\nwhile a != b:\n lst.append(a)\n if a % 2 != 0 and a % 10 != 1:\n print('No')\n break\n elif a < b:\n print('No')\n break\n elif a % 10 == 1:\n a = a // 10\n k += 1\n else:\n a = a // 2\n k += 1\n if a == b:\n lst.append(a)\n lst.reverse\n print('Yes')\n print(len(lst))\n for i in range(len(lst)):\n print(lst[i], end=' ')"}, {"source_code": "(a,b) = map(int,raw_input().split())\nanmas = [b]\n\nwhile b>a:\n if b%2==0:\n b/=2\n anmas.append(b)\n elif b%10==1:\n b/=10\n anmas.append(b)\n else:\n print \"NO\"\n break\n\nif b==a:\n anmas.append(b)\n anmas.reverse()\n print \"YES\"\n print len(anmas)\n print ' '.join(map(str,anmas))\n"}, {"source_code": "a , b = map(int,input().split())\nlastDigit = b%10\nif lastDigit in [3,5,7,9]:\n print(\"NO\")\nelse:\n ans = 0\n transform = [b]\n while a < b:\n lastDigit = b % 10\n if lastDigit in [3,5,7,9]:\n print(\"NO\")\n exit()\n ans+=1\n if lastDigit==1:\n b = b//10\n transform.append(b)\n else:\n b//=2\n transform.append(b)\n print(transform)\n if b == a:\n print(\"YES\")\n print(len(transform))\n transform.reverse()\n for i in transform:\n print(i,end=' ')\n print()\n else:\n print(\"NO\")\n"}, {"source_code": "x = input().split()\na = int(x[0])\nb = int(x[1])\nsp = [b]\nk = 1\nc = True\nwhile a != b and c == True:\n if b % 10 == 1 :\n b = (b - 1) / 10\n sp.append(b)\n k = k + 1\n else:\n b = b / 2\n sp.append(b)\n k = k + 1\n if a > b:\n c = False\nsp.reverse()\nif c == True :\n print(\"YES\")\n print(k)\n print(*sp)\nif c == False:\n print(\"NO\")"}, {"source_code": "cin = input().split(\" \")\na = int(cin[0])\nb = int(cin[1])\nx = []\nwhile (b > a):\n x.append(b)\n if (b % 10 == 1):\n b = (b - 1) // 10\n elif (b % 2 == 0):\n b //= 2\n else:\n print(\"NO\")\n break\nx.append(b)\nif (b == a):\n x.reverse()\n for i in x:\n print(i, end = \" \")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,input().split())\nS=[]\nk=0\nZ=''\nwhile b>a :\n S.append(str(b))\n if b%2==0 :\n b=b//2\n else :\n b=(b-1)/10\n k=k+1\nS.append(str(b))\nfor i in range(k+1) :\n Z=S[i]+' '+Z\nif a==b :\n print('YES')\n print(k+1)\n print(Z)\nelse :\n print('NO')\n \n\n \n"}, {"source_code": "def solve(n, prev):\n if n > b:\n return\n if n == b:\n print(\"YES\")\n print(len(prev))\n print(*prev)\n exit()\n solve(n * 2, prev + [n * 2])\n solve(n * 10 + 1, prev + [n * 10 + 1])\n\na, b = list(map(int, input().split()))\n\nsolve(a, [])\nprint(\"NO\")"}, {"source_code": "a , b = map(int,input().split())\nlastDigit = b%10\nif lastDigit in [3,5,7,9]:\n print(\"NO\")\nelse:\n ans = 0\n transform = [b]\n while a < b:\n lastDigit = b % 10\n ans+=1\n if lastDigit==1:\n b = b//10\n transform.append(b)\n else:\n b//=2\n transform.append(b)\n if b == a:\n print(\"YES\")\n print(len(transform))\n transform.reverse()\n for i in transform:\n print(i,end=' ')\n print()\n else:\n print(\"NO\")\n"}, {"source_code": "a, b = map(int, raw_input().split())\n\nseq = [b]\nwhile b > a:\n if b % 10 == 1:\n b /= 10\n else:\n b /= 2\n seq.append(b)\n\nif a == b:\n print \"YES\"\n print len(seq)\n print \" \".join(map(str, reversed(seq)))\nelse:\n print \"NO\"\n"}, {"source_code": "a, b = map(int, input().split())\nR = [b]\nwhile b > 0:\n while b % 2 == 0:\n b //= 2\n R.append(b)\n if b == a:\n print('YES')\n print(*R[::-1])\n exit()\n if b % 10 == 1:\n b //= 10\n R.append(b)\n if b == a:\n print('YES')\n print(*R[::-1])\n exit()\n else:\n print('NO')\n exit()\nprint('NO')\n\n\n\n"}, {"source_code": "n,k=list(map(int,input().split()))\nanswer=[]\nanswer.append(k)\nf=0\ndef w(x):\n global n\n global f\n if x==n:\n print('YES')\n print(len(answer))\n l=len(answer)\n f=1\n for i in range(l):\n print(answer[l-i-1],' ',end='')\n \n \nwhile k>n:\n if k%2==0:\n k=k//2\n answer.append(k)\n if k%10==1:\n k=(k-1)//10\n answer.append(k)\n if k==n:\n print('YES')\n print(len(answer))\n l=len(answer)\n for i in range(l):\n print(answer[l-i-1],' ',end='')\n break\n elif (k%2!=0 and k%10!=1) or k<n:\n print('NO')\n break\n \n"}, {"source_code": "a,b=map(int,input().split())\nl=[b]\nwhile(a<b):\n if b%2:\n if b%2==1:\n b//=10\n l.append(b)\n else:print(\"NO\");exit();\n else:\n b//=2\n l.append(b)\nif a==b:print(\"YES\");print(len(l));print(*l[::-1])\nelse:print(\"NO\")"}, {"source_code": "import sys, math\ninput = sys.stdin.readline\n\na, b = map(int, input().split())\n\ndef solve(n, p): \n if n == a: \n return p\n elif str(n)[-1] == \"1\" and len(str(n)) > 1: \n return solve(int(str(n)[:-1]), p + [n])\n elif not n % 2: \n return solve(n / 2, p + [n])\n else: \n return False\n\nans = solve(b, [])\nif not ans: \n print \"NO\"\nelse: \n print str(a) + \" \" + \" \".join(map(str, ans[::-1]))"}, {"source_code": "n,k=map(int, input().split())\nc=[]\ncount=0\nwhile(1):\n if(n==k):\n c.append(k)\n count+=1\n break\n if(k%2==0):\n k=k/2\n c.append(k)\n count+=1\n else:\n k=(k-1)/10\n c.append(k)\n count+=1\nif(n==k):\n print(\"YES\")\n print(str(count))\n c=c[::-1]\n string=\"\"\n for i in c:\n string+=str(i)+' '\n print(string)\n # print(c[::-1])\nelse:\n print(\"NO\")"}, {"source_code": "import sys\n\na, b = sys.stdin.readline().strip().split()\na, b = int(a), int(b)\n\nmas = []\n\nwhile b>=a:\n mas += [b]\n if b % 2 == 0:\n b=b/2\n else:\n b=(b-1)/10\n\nprint mas\nmas.reverse()\nprint mas\n\nif a==mas[0]:\n print \"Yes\"\nprint len(mas)\nprint \" \".join(map(str, mas))\n\n"}, {"source_code": "a,b = map(int,raw_input().split())\nl = []\nl.append(a)\nwhile True:\n\tif a > b:\n\t\tprint \"NO\"\n\t\tbreak\n\tif a == b:\n\t\tprint \"YES\"\n\t\tprint len(l)\n\t\tfor i in l:\n\t\t\tprint i,\n\t\tbreak\n\tif b%a == 0:\n\t\ta *= 2\n\t\tl.append(a)\n\telif b%(10* a +1) == 0 or b%(10* a+1) == 1:\n\t\ta = 10* a +1\n\t\tl.append(a)\n\telse:\n\t\ta *= 2\n\t\tl.append(a)"}, {"source_code": "a,b=raw_input().split()\na,b=int(a),int(b)\nout=[b,]\nwhile a<b:\n\tif b%2==0:\n\t\tb/=2\n\t\tout.append(b)\n\telif (b-1)%10==0:\n\t\tb=(b-1)/10\n\t\tout.append(b)\n\telse:\n\t\tbreak\nif a==b:\n\tprint \"Yes\"\n\tprint len(out)\n\tfor i in reversed(out):\n\t\tprint i,\nelse:\n\tprint \"NO\"\n\n\n"}, {"source_code": "a,b=map(int,raw_input().split())\nans=[]\nwhile b > a:\n if b&1:\n if b%10 == 1:\n ans.append(b)\n b-=1\n b/=10\n else: \n print \"NO\"\n exit(0)\n else:\n ans.append(b)\n b/=2\nif a != b:\n print \"NO\"\n exit(0)\nprint \" \".join(map(str, (ans+[a])[::-1]))\n"}, {"source_code": "a, b = map(int, input().split())\nans = [b]\nwhile True:\n if b % 10 == 1:\n b //= 10\n elif b % 2 == 0:\n b //= 2\n else:\n break\n if a >= b:\n break\n ans.append(b)\nans.append(a)\nif a != b:\n print(\"NO\")\nelse:\n print(\"YES\", '\\n', len(ans), '\\n', *ans[::-1])"}, {"source_code": "a,b=raw_input().split()\na,b=int(a),int(b)\nout=[b,]\nwhile a<b:\n\tif b%2==0:\n\t\tb/=2\n\t\tout.append(b)\n\telif (b-1)%10==0:\n\t\tb=(b-1)/10\n\t\tout.append(b)\n\telse:\n\t\tbreak\nif a==b:\n\tprint \"Yes\"\n\tprint len(out)\n\tfor i in reversed(out):\n\t\tprint i,\nelse:\n\tprint \"NO\"\n\n\n"}, {"source_code": "def f(a, b, c):\n if (b - 1) % 10 == 0 and (b - 1) / 10 > a:\n return f(a, (b - 1) / 10, str(int(b)) + ' ' + c)\n elif b % 2 == 0 and b / 2 > a:\n return f(a, b / 2, str(int(b)) + ' ' + c)\n elif b / 2 == a or (b - 1) / 10 == a:\n return str(int(b)) + ' ' + c\n else:\n return False\na, b = list(map(int, input().split()))\nd = f(a, b, '')\nif d == 0:\n print('NO')\nelse:\n print('YES')\n print(d.count(' ') - 1)\n print(d)"}, {"source_code": "s = input()\ns += \" \"\nk = 0\na = \"\"\nb =\"\"\nfor i in s:\n if k == 0:\n if i != ' ':\n a += i\n else:\n k += 1\n elif k == 1:\n if i != ' ':\n b += i\na1 = []\nb1 = []\na1 += a\nb1 += b\na2 = int(a)\nb2 = int(b)\ny = b2\nq = []\nwhile b2 > a2:\n if b1[-1] == \"1\":\n b1.remove(b1[-1])\n b3 = 0\n b4 = \"\"\n for i in b1:\n b4 += i\n b3 = int(b4)\n b2 = b3\n q.append(b2)\n else:\n if b2%2==0:\n b2 = int(b2/2)\n b1 = []\n b1 += str(b2)\n q.append(b2)\n else:\n print(\"NO\")\n break\nif b2 == a2:\n print(\"YES\")\n print(len(q) + 1)\n q = q[::-1]\n for i in q:\n print(i, end=\" \")\n print(y)\nelse:\n print(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\nwas = []\nwas += [b]\nwhile b > a:\n if b % 2 == 0:\n was = was + [b // 2]\n b = b // 2\n else:\n was += [b // 10]\n b = b // 10\nif b == a:\n print(\"YES\")\n print(len(was))\n was1 = was[::-1]\n print(*was1)\nelse:\n print(\"NO\")\n "}, {"source_code": "a,b = map(int,raw_input().split())\n\nsteps = list()\n\nsteps.append(b)\n\nwhile (b > a):\n if (b % 10 == 1):\n b = b / 10\n steps.append(b)\n elif (b % 2 == 0):\n b = b / 2\n steps.append(b)\n else:\n print 'NO'\n exit()\n\nif (b==a):\n print len(steps)\n for x in reversed(steps):\n print x,\nelse:\n print 'NO'"}, {"source_code": "a,b = map(int,input().split())\nres = []\nwhile (b!=a and b):\n res.append(b)\n if b%10 == 1:\n b = b-1\n b = b//10\n elif b%2 == 0:\n b = b//2\n else:\n break \nif b!=a:\n print(\"No\")\nelse:\n print(\"Yes\")\n res = res + [a]\n print(len(res))\n print(*res[::-1])"}, {"source_code": "def com1(x):\n return 2*x\n\ndef com2(x):\n return 10 * x + 1\n\ndef decom2(x):\n return x // 10\n\ndef decom1(x):\n return x // 2\n\na,b = map(int, input().split())\ntest = b\nlist1 = [b]\n\nwhile (test > 1) and (test != a):\n if test % 2 == 1:\n test = decom2(test)\n else:\n test = decom1(test)\n list1.append(test)\n \nif test == a:\n print('YES')\n print(len(list1))\n for i in range(-1,-len(list1)-1,-1):\n print(list1[i], end = ' ')\nelse:\n print('NO')\n\n\n"}, {"source_code": "a,b = map(int,input().split())\nbstart = b\nshit = False\nresult = []\nwhile not shit and b > a:\n if b % 10 != 1: \n if b % 2 == 1:\n shit = True\n else:\n b = b // 2\n result.append(b)\n else:\n if b // 10 == 0:\n shit = True\n else:\n b = (b - 1)//10\n result.append(b)\nif not shit and b == a:\n print(\"YES\")\n print(len(result) + 1)\n print(bstart,*result, sep=' ')\nelse:\n print(\"NO\")"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nf=0\nl=[]\nwhile(b>a):\n if (b%2==1):\n if (b-1)%10==0:\n l.append(b)\n b=(b-1)//10\n else:\n print(\"NO\")\n f=1\n break\n else:\n l.append(b)\n b=b//2\nif (f==0):\n if a==b:\n print(\"YES\")\n l.append(a)\n for i in range (len(l)):\n print(l[len(l)-i-1],end=' ')\n else:\n print(\"NO\")\n"}, {"source_code": "a, b = map(int, input().split())\nC = []\nC.append(b)\nwhile a < b:\n if b % 10 == 1:\n b = (b - 1) // 10\n C.append(b)\n else:\n b = b // 2\n C.append(b)\nC = list(reversed(C))\nif C[0] == a:\n print(\"YES\")\n print(C)\nelse:\n print(\"NO\")"}, {"source_code": "a = input()\ns = []\nT = ''\nb = 0\n\n\n\nb = a[a.find(' ')+1:]\na = a[0:a.find(' ')]\n\na = int(a)\nb = int(b)\n\ns.append(b)\n#print(a)\n#print(b)\ntry:\n if(b>a):\n for i in range(a,b):\n if(b%2 != 0):\n b = int((b - 1)/10)\n s.append(b)\n else:\n b = int(b / 2)\n s.append(b)\n if(b == a):\n T = 'YES'\n break\n elif(b<a):\n T = 'NO'\n break\n if(T == 'YES'):\n s.reverse()\n print(T)\n print(len(s))\n print(s)\n else:\n print(T)\nexcept(TypeError, ValueError):\n print('Error')\n"}, {"source_code": "b,a=map(int,input().split())\nl=[a]\nwhile b!=a:\n\tif a<=0:\n\t\tprint('NO')\n\t\tbreak\n\tif str(a)[-1]=='1':\n\t\ta=(a-1)//10\n\telif a%2==0:\n\t\ta=a//2\n\telse:\n\t\tprint('NO')\n\t\tbreak\n\tl.append(a)\nelse:\n\tprint('YES')\n\tl.sort()\n\tprint(*l)"}, {"source_code": "a, b = map(int, input().split())\nres = [b]\nwhile b >= a:\n if b == a:\n print(\"YES\")\n res.reverse()\n print(*res)\n exit()\n if str(b)[-1] == \"1\":\n b = (b - 1) // 10\n elif b % 2 == 0:\n b = b // 2\n else:\n break\n res.append(b)\nprint(\"NO\")"}, {"source_code": "n,k=map(int,input().split())\nl1=[]\nl1.append(k)\nwhile(True):\n if(k%2!=0 and k%10!=1):\n print(\"NO\")\n break\n elif(k%2==0):\n k=int(k/2)\n l1.append(k)\n elif(k%10==1):\n k=int(k/10)\n l1.append(k)\n if(k==n or k<n):\n break\nif(k==n):\n print(\"YES\")\n print(len(l1))\n l1.sort()\n for i in range (len(l1)):\n print(l1[i],end=\" \")\nelse:\n print(\"NO\")\n "}, {"source_code": "def com1(x):\n return 2*x\n\ndef com2(x):\n return 10 * x + 1\n\ndef decom2(x):\n return x // 10\n\ndef decom1(x):\n return x // 2\n\na,b = map(int, input().split())\ntest = b\nlist1 = [b]\n\nwhile (test > 1) and (test != a):\n if test % 2 == 1:\n test = decom2(test)\n else:\n test = decom1(test)\n list1.append(test)\n \nif test == a:\n print('YES')\n print(len(list1))\n for i in range(-1,-len(list1)-1,-1):\n print(list1[i], end = ' ')\nelse:\n print('NO')\n\n\n"}, {"source_code": "n,k=map(int,input().split())\nl1=[]\nl1.append(k)\nwhile(True):\n if(k%2!=0 and k%10!=1):\n print(\"NO\")\n break\n elif(k%2==0):\n k=int(k/2)\n l1.append(k)\n elif(k%10==1):\n k=int(k/10)\n l1.append(k)\n if(k==n or k<n):\n break\nif(k==n):\n print(\"YES\")\n print(len(l1))\n l1.sort()\n for i in range (len(l1)):\n print(l1[i],end=\" \")\nelse:\n print(\"NO\")\n "}, {"source_code": "import sys\nimport copy\n\n\ndef op1(n):\n\treturn n*2\ndef op2(n):\n\treturn (n*10)+1\ndef revop1(n):\t\t\t\t\t\t# 0\n\treturn n/2\ndef revop2(n):\t\t\t\t\t\t# 1\n\treturn (n-1)/10\n\n\na,B=map(int,filter(lambda a:a!='',raw_input().split(' ')))\n# print a,b\noperations=[]\nb=copy.copy(B)\nwhile b>a:\n\tif b%2==0:\n\t\tb=revop1(b)\n\t\toperations.append(0)\n\telse:\n\t\tb=revop2(b)\n\t\toperations.append(1)\nif b==a:\n\tprint 'YES'\n\tprint len(operations)+1\n\tsys.stdout.write('%d '%a)\n\tfor i in range(len(operations)-1,-1,-1):\n\t\tif operations[i]==0:\n\t\t\ta=op1(a)\n\t\telif operations[i]==1:\n\t\t\ta=op2(a)\n\t\tsys.stdout.write('%d '%a)\n\tsys.exit(0)\nelse:\n\tprint 'NO'\n\tsys.exit(0)"}, {"source_code": "def fib(n):\n\tif n <= 2:\n\t\treturn n\n\telse:\n\t\treturn fib(n - 1) + fib(n - 2)\nprint(fib(20))"}, {"source_code": "a,b = map(int,input().split())\nl = [b]\nwhile b % 2 == 0 or b % 10 == 1:\n print(\"i\")\n if b == a:\n print(1)\n break\n elif b % 2 == 0:\n print(2)\n b = int(b/2)\n l.append(b)\n else:\n print(3)\n b = int((b-1)/10)\n l.append(b)\n \nif b == a:\n print(\"YES\")\n print(len(l))\n print(*reversed(l))\nelse:\n print(\"NO\")"}, {"source_code": "a,b = map(int,input().split())\nres = []\nwhile (b!=a and b):\n res.append(b)\n if b%10 == 1:\n b = b-1\n b = b//10\n elif b%2 == 0:\n b = b//2\n else:\n break \nif b!=a:\n print(\"No\")\nelse:\n print(\"Yes\")\n res = res + [a]\n print(len(res))\n print(*res[::-1])"}, {"source_code": "def com1(x):\n return 2*x\n\ndef com2(x):\n return 10 * x + 1\n\ndef decom2(x):\n return x // 10\n\ndef decom1(x):\n return x // 2\n\na,b = map(int, input().split())\ntest = b\nlist1 = [b]\n\nwhile (test >= 1) and (test != a):\n if test % 2 == 1:\n test = decom2(test)\n else:\n test = decom1(test)\n list1.append(test)\n \nif test == a:\n print('YES')\n print(len(list1))\n for i in range(-1,-len(list1)-1,-1):\n print(list1[i], end = ' ')\nelse:\n print('NO')\n\n\n"}, {"source_code": "IN = [int(i) for i in input().split()]\nOUT = []\n\nwhile IN[1] > IN[0]:\n if IN[1] % 2 == 1:\n OUT.append(IN[1])\n IN[1] = int((IN[1] - 1) / 10)\n else :\n OUT.append(IN[1])\n IN[1] = int(IN[1]/2)\n\nif IN[0] == IN[1]:\n OUT.append(IN[0])\n OUT.reverse()\n print('YES')\n print(len(OUT))\n for i in OUT:\n print(i, end = \" \")\nelse:\n print('NO')"}, {"source_code": "import sys\n\n[a, b] = [int(x) for x in sys.stdin.readline().split()]\nres = []\n\nwhile b > a:\n\tres.append(b)\n\n\tif b % 2 == 0:\n\t\tb /= 2\n\telif b % 10 == 1:\n\t\tb /= 10\n\telse:\n\t\tbreak\n\nif b != a:\n\tprint \"NO\"\n\tsys.exit(0)\n\nres.append(a)\nres.reverse()\n\nprint \"YES\"\nprint ' '.join([str(x) for x in res])\n\n\n\n"}, {"source_code": "a, b = map(int, raw_input().split())\n \nvector = []\nok = True\n \nwhile b > a:\n vector.append(b)\n if b % 2 == 0:\n b = b/2\n elif b % 10 == 1:\n b = b/10\n else:\n break\n \nif b!=a:\n ok = False\nelse:\n vector.append(a)\n \nif not ok:\n print \"NO\"\nelse:\n print \"YES\"\n \nfor i in xrange(len(vector)-1, 0, -1):\n print str(vector[i]),\n \nprint vector[0]"}, {"source_code": "nums = raw_input().split()\na = int(nums[0])\nb = int(nums[1])\nsteps = []\n\ndef step(a, b):\n if a > b:\n return False\n elif a == b:\n steps.append(str(a))\n return True\n else:\n if step(a*2, b):\n steps.append(a)\n return True\n elif step(a*10+1,b):\n steps.append(a)\n return True\n else:\n return False\n\nif step(a, b):\n print 'YES'\n print len(steps)\n steps.sort()\n steps = [str(i) for i in steps]\n print ' '.join(steps)"}, {"source_code": "def com1(x):\n return 2*x\n\ndef com2(x):\n return 10 * x + 1\n\ndef decom2(x):\n return x // 10\n\ndef decom1(x):\n return x // 2\n\na,b = map(int, input().split())\ntest = b\nlist1 = [b]\n\nwhile (test >= 1) and (test != a):\n if test % 2 == 1:\n test = decom2(test)\n else:\n test = decom1(test)\n list1.append(test)\n \nif test == a:\n print('YES')\n print(len(list1))\n for i in range(-1,-len(list1)-1,-1):\n print(list1[i], end = ' ')\nelse:\n print('NO')\n\n\n"}, {"source_code": "a, b = map(int, input().split())\nC = []\nC.append(b)\nwhile a < b:\n if b % 10 == 1:\n b = (b - 1) // 10\n C.append(b)\n else:\n b = b // 2\n C.append(b)\nC = list(reversed(C))\nif C[0] == a:\n print(\"YES\")\n print(*C)\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nc=0;k=0;s='';\nwhile a!=b and c==0 and b>a:\n if b%10==1:\n b=b//10\n s=s+'1'\n else:\n if b%2==1:\n c=1\n else:\n b=b//2\n s=s+'2'\n k+=1\nprint(s)\nif c==0 and b==a:\n print('YES')\n print(k+1)\n print(a,end=' ')\n for i in range(k):\n if (s[len(s)-1-i])=='1':\n print(a*10+1,end=' ')\n a=a*10+1\n else:\n print(a*2,end=' ')\n a=a*2\nelse:\n print('NO')"}, {"source_code": "# cook your dish here\na, b = [int(x) for x in input().split()]\n\nr = []\nr.append(b)\nif b & 1:\n b -= 1\n b = b // 10\n r.append(b) \nwhile b != 0:\n if b < a:\n break\n if b == a:\n break\n if b & 1:\n b -= 1\n b = b // 10\n else:\n b = b // 2\n r.append(b)\nif b == a:\n print(\"YES\")\n r = sorted(r)\n for x in range(len(r)):\n print(r[x], end=' ')\nelse:\n print(\"NO\")"}, {"source_code": "n,k=map(int, input().split())\nc=[]\ncount=0\nwhile(k>=n):\n if(n==k):\n c.append(k)\n break\n if(k%2==0):\n c.append(k)\n k=k//2\n \n # count+=1\n else:\n c.append(k)\n k=(k-1)//10\n \n # count+=1\nif(n==k):\n print(\"YES\")\n print(len(c))\n c=c[::-1]\n # string=\"\"\n # print(\"{0}\".format(\" \".join(c)))\n print(*c, sep=' ')\n # print(c[::-1])\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nl=[b]\nwhile(a<b):\n if b%2:\n b//=10\n l.append(b)\n else:\n b//=2\n l.append(b)\nif a==b:print(\"YES\");print(len(l));print(*l[::-1])\nelse:print(\"NO\")"}, {"source_code": "str=input()\nmas1=str.split()\na=int(mas1[0])\nb=int(mas1[1])\nk=1\ni=0\nmas=[]\nwhile (a<b):\n mas.append(b)\n if b%2==0:\n b=b//2\n k=k+1\n else:\n b=(b-1)//10\n k=k+1\nmas.reverse()\nf=len(mas)\nif (a==b):\n print(\"YES\")\n print(k)\n print (a,end=' ')\n while i<f:\n print (mas[i],end=' ')\n i+=1\nelse: print(\"NO\")\n"}, {"source_code": "n,k=map(int, input().split())\nc=[]\ncount=0\nwhile(1):\n if(n==k):\n c.append(k)\n count+=1\n break\n if(k%2==0):\n k=k/2\n c.append(k)\n count+=1\n else:\n k=(k-1)/10\n c.append(k)\n count+=1\nif(n==k):\n print(\"YES\")\n print(str(count))\n c=c[::-1]\n string=\"\"\n for i in c:\n string+=str(i)+' '\n print(string)\n # print(c[::-1])\nelse:\n print(\"NO\")"}, {"source_code": "n,m=map(int, input().split())\ni,j=0,0\ns=str(m)\ns=len(s)\na=[0]\np,q=0,0\ng=[]\n\na[0]=n\nfor i in range((m//2)*s):\n p=2*a[i]\n q=10*a[i]+1\n a.append(p)\n a.append(q)\n #if 2**(i-1)>(m):\n # break\nfor i in range(len(a)):\n if a[i]==m:\n j=i\n print('YES')\n while a[j]!=n:\n g.append(a[j])\n j=(j-1)//2\nif g==[]:\n print('NO')\nelse:\n g.reverse()\n print(n,*g)"}, {"source_code": "a,n=map(int,input().split())\nans = []\nj = 0\nz = 0\nfor g in range(a):\n s = str(n)\n if s[-1] == \"1\":\n s = s[0:len(s)-1]\n if s != \"\":\n n = int(s)\n \n ans.append(n)\n j += 1\n \n if n == a:\n z = 1\n break\n if n % 2 == 0:\n n = n // 2\n ans.append(n)\n j += 1\n if n == a:\n z = 1\n break\nt = 1 \nif z == 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(j+1)\n for i in range(len(ans)-1,-1,-1):\n print(ans[i], end=\" \")\n \n print(ans[0]*2)\n\n"}, {"source_code": "a,b = map(int,input().split())\nsteps = [b]\nwhile True:\n\tif b < a:\n\t\tprint('NO')\n\t\timport sys\n\t\tsys.exit(0)\n\tif b == a:\n\t\tbreak\n\tif b % 2 == 0:\n\t\tb //= 2\n\t\tsteps.append(b)\n\t\tcontinue\n\tif b % 10 != 1:\n\t\tb = -1\n\telse:\n\t\tb = (b - 1) // 10\n\t\tsteps.append(b)\nprint(' '.join(reversed([str(s) for s in steps])))\n"}, {"source_code": "a,b=map(int,input().split())\nl=[b]\nwhile(a<b):\n if b%2:\n if b%2==1:\n b//=10\n l.append(b)\n else:print(\"NO\");exit();\n else:\n b//=2\n l.append(b)\nif a==b:print(\"YES\");print(len(l));print(*l[::-1])\nelse:print(\"NO\")"}, {"source_code": "s = input()\ns += \" \"\nk = 0\na = \"\"\nb =\"\"\nfor i in s:\n if k == 0:\n if i != ' ':\n a += i\n else:\n k += 1\n elif k == 1:\n if i != ' ':\n b += i\na1 = []\nb1 = []\na1 += a\nb1 += b\na2 = int(a)\nb2 = int(b)\ny1 = b\ny = []\nwhile b2 > a2:\n if (b2 - 1) % 10 == 0:\n b2 = int((b2 - 1) / 10)\n y.append(b2)\n else:\n if b2 % 2 == 0:\n b2 = int(b2 / 2)\n y.append(b2)\n else:\n print(\"NO\")\nif b2 == a2:\n print(\"YES\")\n print(len(y) + 1)\n y = y[::-1]\n for i in y:\n print(i, end=\" \")\n print(y1)\n "}, {"source_code": "import sys\n\na, b = sys.stdin.readline().strip().split()\na, b = int(a), int(b)\n\nmas = []\ni=0\nwhile b>=a and i==0:\n mas += [b]\n if b % 2 == 0:\n b=b/2\n elif b%10==1:\n b=(b-1)/10\n else:\n i+=1\nmas.reverse()\n\nif a==mas[0] and i==0:\n print \"YES\"\n print len(mas)\n print \" \".join(map(str, mas))\nelse:\n print \"NO\"\n\n\n"}, {"source_code": "(a,b) = map(int,raw_input().split())\nanmas = [b]\n\nwhile b>a:\n if b%2==0:\n b/=2\n anmas.append(b)\n elif b%10==1:\n b/=10\n anmas.append(b)\n else:\n print \"NO\"\n break\n\nif b==a:\n anmas.append(b)\n anmas.reverse()\n print \"YES\"\n print len(anmas)\n print ' '.join(map(str,anmas))\n"}, {"source_code": "def recurs(x,path):\n global start\n global c\n if c==1:\n return\n if x<start:\n c=0\n return\n if x==start:\n c=1\n return\n x1=x\n if x%10==1:\n path.append(2)\n recurs(x1//10, path)\n else:\n path.append(1)\n recurs(x//2,path)\nstart,b=map(int,input().split())\nc=0\npath=[]\nrecurs(b,path)\nif c==0:\n print('NO')\nelif c==1:\n print('YES')\n print(len(path)+1)\n print(start,end=' ')\n for i in range(1,len(path)+1):\n if path[-i]==1:\n start*=2\n print(start,end=' ')\n elif path[-i]==2:\n start=start*10+1\n print(start,end=' ')"}, {"source_code": "import sys\ndef check(a):\n temp = inp[0]\n for i in a:\n if i=='1': temp*=2\n if i=='2': temp=temp*10+1\n if temp == inp[1]:\n return True\n else:\n return False\ndef printt(a):\n print('YES')\n print(len(a))\n for i in a:\n print(i,end=' ')\ndef solve(a):\n if check(a):\n printt(a)\n sys.exit()\n if len(a)>10: return\n solve(a+'1')\n solve(a+'2')\ninp = list(map(int,input().split()))\nsolve('')\nprint('NO')\n"}, {"source_code": "'''\n\nWelcome to GDB Online.\nGDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,\nC#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.\nCode, Compile, Run and Debug online from anywhere in world.\n\n'''\nimport sys\ns=list(map(int,input().split()))\na=s[0]\nb=s[1]\nl=[b]\nfor i in range(100):\n if a==b:\n print(\"YES\")\n print(len(l))\n print(\" \".join(str(i) for i in (l[::-1])))\n break\n if b%2==0:\n \n b=b//2\n if b%2!=0:\n \n break\n l.append(b)\n else:\n b=b//10\n if b%2!=0:\n \n break\n l.append(b)\nif(a!=b):\n \n print(\"NO\")\n \n \n \n "}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nf=0\nl=[]\nwhile(b>a):\n if (b%2==1):\n if (b-1)%10==0:\n l.append(b)\n b=(b-1)//10\n else:\n print(\"NO\")\n f=1\n break\n else:\n l.append(b)\n b=b//2\nif (f==0):\n if a==b:\n print(\"YES\")\n l.append(a)\n for i in range (len(l)):\n print(l[len(l)-i-1],end=' ')\n else:\n print(\"NO\")\n"}, {"source_code": "a,b = map(int,input().split())\nFlag = True\nc = [b]\nwhile a != b and Flag:\n if b % 10 == 1:\n b = b // 10\n c.append(b)\n elif b % 2 == 0 and b != 0:\n b = b // 2\n c.append(b)\n else:\n Flag = False\nif Flag:\n print ('Yes')\n print (len(c))\n c = c[::-1]\n for i in c:\n print (i,end=' ')\nelse:\n print ('No')\n \n\n \n"}, {"source_code": "a,b = map(int,input().split())\nl = [b]\nwhile b % 2 == 0 or b % 10 == 1:\n print(\"i\")\n if b == a:\n print(1)\n break\n elif b % 2 == 0:\n print(2)\n b = int(b/2)\n l.append(b)\n else:\n print(3)\n b = int((b-1)/10)\n l.append(b)\n \nif b == a:\n print(\"YES\")\n print(len(l))\n print(*reversed(l))\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nl=[]\nflag=0\nwhile b!=a and b>0:\n\tif b%2==0:\n\t\tl.append(b)\n\t\tb//=2\n\telif b!=a and len(str(b))==1:\n\t\tflag=1\n\t\tbreak\n\telif str(b)[-1]==\"1\":\n\t\tl.append(b)\t\n\t\tb=b//10\n\telse:\n\t\tflag=1\n\t\tbreak\nif flag==1:\n\tprint(\"NO\")\nelse:\n\tl.append(a)\n\tl.reverse()\n\tprint(\"YES\")\n\tprint(*l)"}, {"source_code": "a, b = map(int, input().split())\norder = [b]\nwhile b > a:\n if b % 2 == 0:\n b //= 2\n order.append(b)\n elif b % 10 == 1:\n b //= 10\n order.append(10)\nif a == b:\n print(\"YES\")\n print(len(order))\n for i in range(len(order) - 1, -1, -1):\n print(order[i], end=\" \")\nelse:\n print(\"NO\")"}, {"source_code": "def qweqwe(a, b):\n global mas\n if b % 10 in [3,5,7,9] and b > a:\n mas.append(\"NO\")\n return 0\n else:\n if b % 10 == 1 and b > a:\n b = b // 10\n mas.append(b)\n s = qweqwe(a, b)\n else:\n if b > a:\n b = b // 2\n mas.append(b)\n s = qweqwe(a, b)\n\na = [int(i) for i in input().split()]\nmas = [a[1]]\nb = qweqwe(a[0], a[1])\nif mas[-1] == a[0]:\n print(len(mas))\n for i in range(len(mas) - 1, -1, -1):\n print(mas[i], end = \" \")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\ns += \" \"\nk = 0\na = \"\"\nb =\"\"\nfor i in s:\n if k == 0:\n if i != ' ':\n a += i\n else:\n k += 1\n elif k == 1:\n if i != ' ':\n b += i\na1 = []\nb1 = []\na1 += a\nb1 += b\na2 = int(a)\nb2 = int(b)\ny1 = b\ny = []\nwhile b2 > a2:\n if (b2 - 1) % 10 == 0:\n b2 = int((b2 - 1) / 10)\n y.append(b2)\n else:\n if b2 % 2 == 0:\n b2 = int(b2 / 2)\n y.append(b2)\n else:\n print(\"NO\")\n break\nif b2 == a2:\n print(\"YES\")\n print(len(y) + 1)\n y = y[::-1]\n for i in y:\n print(i, end=\" \")\n print(y1)\nelse:\n print(\"NO\")"}, {"source_code": "a, b = list(map(int, input().split()))\narr = [str(b)]\nwhile b > a:\n if b % 10 == 1:\n b //= 10\n arr.append(str(b))\n elif b % 2 == 0:\n b //= 2\n arr.append(str(b))\n else:\n b = -1\nif b == a:\n print('YES', len(arr), ' '.join(arr), sep='\\n')\nelse:\n print('NO')\n "}, {"source_code": "#coding=utf-8\n\na,b=map(int,raw_input().split())\noutputs=[b]\nnum=1\nwhile b>a:\n\tif b%2==0:\n\t\tb=b/2\n\t\toutputs.append(b)\n\t\tnum+=1\n\telse:\n\t\tb=(b-1)/10\n\t\toutputs.append(b)\n\t\tnum+=1\nif a==b:\n\tprint \"YES\"\n\tprint num\n\tfor x in outputs[::-1]:\n\t\tprint x,\nelse:\n\tprint \"NO\"\n"}, {"source_code": "a,b = map(int,input().split())\noutput = []\nnum = b\nn1,n2=0,0\n\noutput.append(num)\n\nwhile (num!=a):\n if (num<a):\n output.clear()\n print(\"NO\")\n exit()\n elif (num%2==0):\n num/=2\n output.append(int(num))\n n1+=1\n elif (int(num/10)%2==0):\n num=int(num-1)/10\n output.append(int(num))\n n2+=1\n else:\n output.clear()\n print(\"NO\")\n exit()\n\nif (n1==0 or n2==0):\n output.clear()\n print(\"NO\")\n exit()\n\noutput.reverse()\nprint(\"YES\")\nprint(len(output))\nfor i in output:\n print(i, end=\" \")\n"}], "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3"} {"source_code": "rows, columns = map(int, raw_input().split())\ncells = []\nfor rowN in range(rows): cells.append(list(raw_input()))\nresult = 0\nfor i in range(rows):\n flag = True\n for j in range(columns):\n if cells[i][j] == 'S':\n flag = False\n break\n if flag:\n for j in range(columns):\n cells[i][j] = 'x'\nfor j in range(columns):\n flag = True\n for i in range(rows):\n if cells[i][j] == 'S':\n flag = False\n break\n if flag:\n for i in range(rows):\n cells[i][j] = 'x'\nfor i in range(rows):\n for j in range(columns):\n if cells[i][j] == 'x': result += 1\nprint result", "positive_code": [{"source_code": "r,c=map(int,input().split())\nmm=r*c\nmat=[]\nfor i in range(r):\n s=input()\n mat.append(s)\nans=0\nrr=0;cc=0;s=0\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n rr+=1\n break\nfor i in range(c):\n for j in range(r):\n if mat[j][i]=='S':\n cc+=1\n break\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n s+=1\n\nprint(r*c-rr*cc)\n"}, {"source_code": "'''input\n2 2\n..\n..\n'''\nr, c = map(int, input().split())\nnr, nc = [], []\nfor x in range(r):\n\tn = list(input())\n\tif \"S\" in n:\n\t\ti = [j for j, k in enumerate(n) if k == \"S\"]\n\t\tnr.append(x)\n\t\tfor z in i:\n\t\t\tnc.append(z)\na, b = len(set(nr)), len(set(nc))\nprint((r-a)*c + (c-b)*r - (r-a)*(c-b))\n\t\t\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\ndef main():\n\tr,c= [int(i) for i in input().split()]\n\terow=[]\n\tecol=[]\n\tcount=0\n\tfor i in range(r):\n\t\ts=input()\n\t\tfor col in range(c):\n\t\t\tif s[col]=='S':\n\t\t\t\terow.append(i)\n\t\t\t\tecol.append(col)\t\n\n\tfor i in range(r):\n\t\tfor j in range(c):\n\t\t\t\n\t\t\tif i in erow and j in ecol:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount+=1\n\tprint(count)\n\t\t\t\t\n\treturn 0\n\nif __name__ == '__main__':\n\tmain()\n"}, {"source_code": "r,c=map(int,input().split())\nmm=r*c\nmat=[]\nfor i in range(r):\n s=input()\n mat.append(s)\nans=0\nrr=0;cc=0;s=0\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n rr+=1\n break\nfor i in range(c):\n for j in range(r):\n if mat[j][i]=='S':\n cc+=1\n break\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n s+=1\nr-=rr\nc-=cc\nif s==0:\n print(r*c)\nelse:\n print(mm-rr*cc)\n"}, {"source_code": "r,c=map(int, input().split())\nx=set()\ny=set()\n\nfor i in range(r):\n t = [k for k in list(input())]\n \n for j in range(c):\n if t[j] == 'S':\n x.add(j)\n y.add(i)\n \nprint(r*c-(len(x)*len(y)))\n \n\n"}, {"source_code": "r,c = map(int,raw_input().split())\nl=[]\nrcount,ccount=0,0\nfor x in range(r):\n temp=raw_input()\n l.append(temp)\n flag=0\n for y in range(c):\n if(l[x][y]=='S'):\n #rcount+=1\n flag=1\n if(flag==0):\n rcount+=1\nfor x in range(c):\n flag=0\n for y in range(r):\n if(l[y][x]=='S'):\n flag=1\n if(flag==0):\n ccount+=1\nprint (rcount*c)+(r*ccount)-(rcount*ccount)\n"}, {"source_code": "import sys\n\nhulp=sys.stdin.readline().split()\nr,c=int(hulp[0]),int(hulp[1])\nregel=[True,True,True,True,True,True,True,True,True,True]\nkolom=[True,True,True,True,True,True,True,True,True,True]\n\n\n\nfor x in range (r):\n line=sys.stdin.readline().strip()\n for y in range(len(line)):\n if line[y]=='S':\n regel[x]=False\n kolom[y]=False\n \n\nfr=0\nfc=0\nfor x in range(10):\n if regel[x]==False:\n fr+=1\n if kolom[x]==0:\n fc+=1\n \nprint r*c-fr*fc\n"}, {"source_code": "r,c=[int(i) for i in raw_input().split()]\nl=[]\neat=0\nfor i in range(r):\n l.append(raw_input())\nfor i in range(r):\n if \"S\" not in l[i]:\n eat+=l[i].count('.')\n l[i]='1'*c\nfor i in range(c):\n s=[g[i] for g in l]\n if \"S\" not in s:\n eat+=s.count('.')\nprint eat\n"}, {"source_code": "r,c=map(int,input().split())\nco=0\nlis=[]\nfor i in range(r):\n st=input()\n for i in range(c):\n if st[i]==\"S\":\n lis.append(i)\n for i in range(c):\n if st[i]==\"S\":\n co+=1\n break\nif len(lis)>0:\n lis=set(lis)\nprint((r*c)-(len(lis)*co))\n \n \n "}, {"source_code": "\nr ,c = map(int ,input().split())\ndd =[]\nfor i in range(r):\n s = input()\n op = []\n for ii in s:\n op.append(ii)\n dd.append(op)\ns1 ='S'\nr_1 =0\n\nfor i in range(r):\n if s1 not in dd[i]:\n r_1+=c\n for j in range(c):\n dd[i][j]=-1\n\n\nans =[]\nop =[]\nfor ii in range(c):\n c_1 =0\n k=0\n for jj in range(r):\n if dd[jj][ii] != s1:\n if dd[jj][ii]==-1:\n k+=1\n c_1+=1\n else:c_1+=1\n if c_1 ==r:\n\n ans.append(c_1)\n op.append(k)\nso = sum(ans)\nko = sum(op)\n\nprint((so+r_1)-ko)"}, {"source_code": "def eat(cake, r, c):\n for i in range(r):\n cake[i] = [['E']*c, cake[i]]['S' in cake[i]]\n\nr, c = map(int, raw_input().split())\ncake = [list(raw_input()) for _ in [0]*r]\neat(cake, r, c)\ncake = map(list, zip(*cake))\neat(cake, c, r)\nprint sum(cake, []).count('E')\n"}, {"source_code": "__author__ = 'user'\nr, c = map(int, raw_input().split())\nl = []\nfor i in xrange(r):\n l.append(list(raw_input().strip()))\nres = 0\ndef fl(tl):\n global res\n for i in tl:\n tres = 0\n if i.__contains__(\"S\"):\n continue\n for k in xrange(len(i)):\n j = i[k]\n if j == \".\":\n tres += 1\n i[k]=\"-\"\n if tres!=-1:\n res+=tres\nfl(l)\nfl(map(list, zip(*l)))\nprint res"}, {"source_code": "r,c = map(int,input().split())\nx = r * [0]\ny = c * [0]\ncount = 0\nfor i in range(r) :\n s = input()\n for j in range(c) :\n if s[j] == 'S' :\n x[i] = 1\n y[j] = 1\na = x.count(1)\nb = y.count(1)\n\nprint(r*c - a*b)"}, {"source_code": "r, c = map(int,input().split(' '))\ncount = 0\nA = []\nx = 0\n\nfor i in range(r):\n n = list(input())\n\n if 'S' not in n:\n x += 1\n\n A.append(n)\n\ny = []\np = 0\n\nfor i in range(c):\n for j in range(r):\n y.append(A[j][i])\n\n if 'S' not in y:\n p += 1\n\n y = []\n \ncount = r*c - (r-x)*(c-p)\n\nprint(count)"}, {"source_code": "R=raw_input\nb=map(R,\" \"*int(R()[:2]))\nprint ' '*100000\nS=lambda b:sum('S'in i for i in b)\nprint int(len(b)*len(b[0]) - S(b)*S(zip(*b)))"}, {"source_code": "r, c = map(int, input().split())\nlst = [[s for s in input()] for _ in range(r)]\ncount, col = 0, set()\nfor i in range(r):\n if 'S' not in lst[i]:\n count += 1\n for j in range(c):\n if lst[i][j] == 'S':\n col.add(j)\nprint((c - len(col)) * (r - count) + count * c)"}, {"source_code": "R=raw_input\nb=map(R,\" \"*int(R()[:2]))\nS=lambda b:sum('S'in i for i in b)\nprint len(b)*len(b[0])-S(b)*S(zip(*b))"}, {"source_code": "def make_cake(nb_row, nb_col):\n cake = [[0]*nb_col for _ in range(nb_row)]\n\n for i in range(nb_row):\n row = raw_input()\n for j, cell in enumerate(row):\n cake[i][j] = 1 if cell == '.' else 0\n\n return cake\n\nif __name__ == '__main__':\n nb_row, nb_col = [int(num) for num in raw_input().split()]\n\n cake = make_cake(nb_row, nb_col)\n\n edible_rows, edible_cols = [1]*nb_row, [1]*nb_col\n for i in range(nb_row):\n for j in range(nb_col):\n edible_rows[i] &= cake[i][j]\n edible_cols[j] &= cake[i][j]\n\n edible_rows = [i for i, edible in enumerate(edible_rows) if edible]\n edible_cols = [i for i, edible in enumerate(edible_cols) if edible]\n\n nb_eat = 0\n for i in edible_rows:\n for j in range(nb_col):\n nb_eat += not cake[i][j] == -1\n cake[i][j] = -1\n\n for j in edible_cols:\n for i in range(nb_row):\n nb_eat += not cake[i][j] == -1\n cake[i][j] = -1\n\n print nb_eat\n"}, {"source_code": "r, c = map(int, raw_input().split())\ns, a = [], [([0] * c) for i in range(r)]\nfor i in range(r):\n\ts.append(raw_input())\n\tif s[i] == '.' * c:\n\t\ta[i] = [1] * c\nfor j in range(c):\n\tfor i in range(r):\n\t\tif s[i][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tfor i in range(r):\n\t\t\ta[i][j] = 1\nprint sum(sum(a[i]) for i in range(r))"}, {"source_code": "def main():\n r,c = map(int, input().split())\n cake = [input() for _ in range(r)]\n neigh = []\n for y in range(r):\n for x in range(c):\n if not 'S' in cake[y]:\n neigh.append(tuple(range(y * c, y * c + c)))\n if all('S' != _[x] for _ in cake):\n neigh.append(tuple(range(x, r * c, c)))\n field = [_ == '.' for s in cake for _ in s]\n start = sum(field)\n if any(neigh):\n while True:\n nn = max(neigh, key=lambda e: sum(field[_] for _ in e))\n if not sum(field[_] for _ in nn):\n break\n for i in nn:\n field[i] = False\n print(start - sum(field))\n\n\nmain()\n"}, {"source_code": "d,n=list(map(int,input().split()))\nc=l=k=0\na=[]\nfor i in range(d):\n s=input()\n if \"S\" not in s:\n l+=1\n c+=n\n a.append(s)\nm=[]\nfor j in range(n):\n v=\"\"\n for t in a:\n v=v+t[j]\n m.append(v)\nfor f in m:\n if \"S\" not in f:\n k+=1\n c+=d\nprint(c-(k*l))"}, {"source_code": "def answer():\n a = input().split()\n a = [int(x) for x in a]\n i=0\n c=[]\n d1=[]\n while i<a[0]:\n d=list(input())\n j=0\n while j<len(d):\n if d[j]==\"S\":\n if i not in c:c.append(i)\n if j not in d1:d1.append(j)\n j+=1\n i+=1\n ans = a[0]*a[1]-len(c)*len(d1)\n print(ans)\nanswer()"}, {"source_code": "from __future__ import print_function\nimport sys\n\n\ndef main():\n\tvstup=(sys.stdin.readline()).split(\" \")\n\tr=int(vstup[0])\n\tc=int(vstup[1])\n\tchocolate=[]\n\n\tfor i in range(r):\n\t\tchocolate.append(list(sys.stdin.readline()))\n\tcount=c*r\n\n\tfor i in range(r):\n\t\tfor j in range(c):\n\t\t\tif chocolate[i][j]=='S':\n\t\t\t\tcount-=c\n\t\t\t\tbreak\n\ts=count/c\n\n\n\tfor j in range(c):\n\t\tfor i in range(r):\n\t\t\tif chocolate[i][j]=='S':\n\t\t\t\tbreak\n\t\t\tif i==r-1 and chocolate[r-1][j]!='S':\n\t\t\t\tcount+=r-s\n\tprint(count)\n\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "n, m = map(int,raw_input().split())\nl = []\nfor i in range(n):\n\tl.append(list(raw_input()))\nc = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tif l[i][j] == 'S':\n\t\t\tcontinue\n\t\th, v = 0, 0\n\t\tx, y = i, j-1\n\t\twhile 0 <= x < n and 0 <= y < m:\n\t\t\tif l[x][y] == 'S':\n\t\t\t\tv = 1\n\t\t\ty -= 1\n\t\tx, y = i-1, j\n\t\twhile 0 <= x < n and 0 <= y < m:\n\t\t\tif l[x][y] == 'S':\n\t\t\t\th = 1\n\t\t\tx -= 1\n\t\tx, y = i+1, j\n\t\twhile 0 <= x < n and 0 <= y < m:\n\t\t\tif l[x][y] == 'S':\n\t\t\t\th = 1\n\t\t\tx += 1\n\t\tx, y = i, j+1\n\t\twhile 0 <= x < n and 0 <= y < m:\n\t\t\tif l[x][y] == 'S':\n\t\t\t\tv = 1\n\t\t\ty += 1\n\t\tif h == 1 and v == 1:\n\t\t\tcontinue\n\t\tc += 1\nprint c"}, {"source_code": "\nn, m = map(int, input().split())\ntort=[input() for i in range(n)]\nx='S'\nmas=[[False]*m for i in range(n)]\n\nfor i in range(n):\n if 'S' not in tort[i]:\n for j in range(m):\n mas[i][j]=True\nfor j in range(m):\n is_find=False\n for i in range(n):\n if tort[i][j]=='S':\n is_find=True\n break\n if not is_find==True:\n for i in range(n):\n mas[i][j]=True\ncount=0\n\nfor row in mas:\n count+=row.count(True)\nprint(count)\n"}, {"source_code": "R=raw_input\nb=map(R,\" \"*int(R()[:2]))\nS=lambda b:sum('S'in i for i in b)\nprint int(len(b)*len(b[0]) - S(b)*S(zip(*b)))"}, {"source_code": "n,m=map(int,input().split())\nl=[input() for _ in range(n)]\nfrom collections import Counter\ns=[]\nk=0\nfor i in range(n):\n if 'S' not in l[i]:\n k=k+1\n for j in range(m):\n if l[i][j]=='S':\n s.append(j+1)\nx=len(Counter(s))\nprint(k*m+(m-x)*n-k*(m-x))"}, {"source_code": "import itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left\nimport heapq\nfrom collections import deque , defaultdict,Counter\nfrom itertools import combinations as C\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\na , b = get(int)\nh = []\nrow = 0\ngrid = []\nfor j in xrange(a):\n\th.append(Ls())\n\tgrid.append(h[j])\n\tif h[j].count('S') == 0:\n\t\trow += 1\n\t\tgrid[j] = ['1']*b \ncol = 0\n#print grid\nfor j in xrange(b):\n\tcnt = 0\n\tfor i in xrange(a):\n\t\tif h[i][j] == '.':\n\t\t\tcnt += 1\n\tif cnt == a:\n\t\tfor i in xrange(a):\n\t\t\tgrid[i][j] = '1'\n#print grid\nans = 0\nfor i in xrange(a):\n\tfor j in xrange(b):\n\t\tif grid[i][j] == '1':\n\t\t\tans += 1\nprint ans\n\t\t\n\t\n\n\n\n"}, {"source_code": "n, p = map(int, input().split())\narr = []\nfor i in range(n):\n s = str(input())\n arr.append(s)\n\ncount = 0\ncountExtra = 0\nfor i in range(n):\n counts = 0\n k = 0\n truth = True\n while k < p and truth == True:\n if arr[i][k:k+1] == \".\":\n counts+=1\n if arr[i][k:k+1] == \"S\":\n truth = False\n k+=1\n if counts == p:\n count+=counts\n countExtra+=1\n \nfor i in range(p):\n countss = 0\n kk = 0\n truthh = True\n while kk < n and truthh ==True:\n if arr[kk][i:i+1] == \".\":\n countss+=1\n if arr[kk][i:i+1] == \"S\":\n truthh = False\n kk+=1\n if countss == n:\n count+=countss\n count-=countExtra\nprint(count)"}, {"source_code": "def stri(t,a,b):\n l=0\n for i in range(b):\n if t[i]==\"S\":\n a[i]=1\n l=-1\n if l==0:\n return 0\n else:\n return -1\n\na,b=map(int,input().split())\nr=[0]*a\nc=[0]*b\nfor i in range(a):\n k=input()\n t=stri(k,c,b)\n if t==-1:\n r[i]=1\n \nm=r.count(0)\nn=c.count(0)\nprint(m*b+n*a-m*n)"}, {"source_code": "n,m = input().split()\nm = int(m)\ns=''\nans = 0\nfor i in range(int(n)):\n temp = str(input())\n if 'S' not in temp:\n ans = ans+m\n temp=''\n s = s + temp\nfor j in range(int(m)):\n temp = ''\n while j<len(s):\n temp = temp + s[j]\n j = j+int(m)\n if 'S' not in temp:\n ans = ans + len(temp) \nprint(ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\ndef inp():\n return(int(input()))\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\n\ndef solution(mat,r,c):\n total = 0\n cnt = 0\n for i in range(r):\n res = 0\n for j in range(c):\n if mat[i][j] == 'S':\n res = 0\n break\n else:\n res += 1\n total += res\n if res > 0:\n cnt += 1\n dep = 0\n for j in range(c):\n res = 0\n for i in range(r):\n if mat[i][j] == 'S':\n res = 0\n break\n else:\n res += 1\n total += res\n if res > 0:\n dep += 1\n return (total - dep*cnt) if total >= 0 else 0 \n \n\nr,c = invr()\nmat = []\nfor i in range(r):\n s = insr()\n mat.append(s)\nprint(solution(mat,r,c))"}, {"source_code": "r,c=map(int,input().split());a=[input() for _ in[0]*r]\ns=lambda x:sum(i.count('S')>0 for i in x)\nprint(r*c-s(a)*s(zip(*a)))"}, {"source_code": "r,c = map(int,input().split())\ndata = [list(input()) for i in range(r)]\n\ntotal=0\nfor i in range(r):\n if 'S' not in data[i]:\n total+=c\nrow = total//c\nfor j in range(c):\n for k in range(r):\n if data[k][j]=='S':\n break\n else:\n total=total+r-row\nprint(total)\n \n "}, {"source_code": "def fun(n,m,li):\n eatrow=[]\n noteatcolumn=[]\n for i in range(n):\n fi=[]\n for j in range(m):\n if li[i][j]=='S':\n fi.append(j)\n if len(fi)>0:\n noteatcolumn.extend(fi)\n continue\n else:\n eatrow.extend([(i,j) for j in range(m)])\n eat=set(range(m))-set(noteatcolumn)\n for j in eat :\n eatrow.extend([(i,j) for i in range(n)])\n print(len(set(eatrow)))\n \n \nn,m=list(map(lambda x:int(x),input().split()))\nli=[input() for i in range(n)]\nfun(n,m,li)\n"}, {"source_code": "a,b=map(int,input().split())\nc=[]\nd=[]\nfor i in range(a):\n z=list(input()) \n for j in range(b):\n if z[j]=='S':\n c.append(i)\n d.append(j)\nprint(a*b-len(list(set(c)))*len(list(set(d))))"}, {"source_code": "import math\n\n\ndef main():\n r, c = map(int, input().split())\n g = [[] for _ in range(r)]\n for row in range(r):\n g[row] = list(input())\n\n for row in range(r):\n if not 'S' in g[row]:\n for col in range(c):\n g[row][col] = '*'\n\n for col in range(c):\n ok = True\n for row in range(r):\n if g[row][col] == 'S':\n ok = False\n break\n if ok:\n for row in range(r):\n g[row][col] = '*'\n\n res = 0\n for row in range(r):\n for col in range(c):\n if g[row][col] == '*':\n res += 1\n print(res)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/python\n\nr,c = map(int,raw_input().split())\ncount = 0\ncake = []\nindexr=0\nindexc=0\n\nfor i in range(r):\n cake.append(raw_input())\n\nfor i in range(r):\n for j in cake[i]:\n if j == 'S':\n indexr = indexr + 1\n break\n\ncount = (r - indexr)* c\nfor i in range(c):\n for j in range(r):\n if cake[j][i] == 'S':\n indexc = indexc + 1\n break\ncount = count + ((c - indexc)*r)\ncount = count - ((r-indexr) * (c - indexc))\n\nprint count\n"}, {"source_code": "def solve():\n n,m=list(map(int,input().split()))\n l=list()\n for i in range(n):\n l.append(input())\n flag,row,col=1,0,0\n for i in range(n):\n for j in range(m):\n if(l[i][j]==\"S\"):\n flag=0\n if(flag):\n row+=1\n flag=1\n flag=1\n for i in range(m):\n for j in range(n):\n if(l[j][i]==\"S\"):\n flag=0\n if(flag):\n col+=1\n flag=1\n print(row*m+col*n-row*col)\n\n\n\n#----------------------------------------------------------#\n\nt=1\nfor _ in range(t):solve()"}, {"source_code": "n, m = map(int, input().split())\na = []\nfor i in range(n):\n b = list(input())\n a.append(b)\n\ns = 0\nz = 0\nfor i in range(n):\n if \"S\" not in a[i]:\n z += 1\n s += len(a[i])\n\nfor i in range(m):\n d = []\n for j in range(n):\n d.append(a[j][i])\n if \"S\" not in d:\n s += len(d)-z\n\nprint(s)"}, {"source_code": "r,c=map(int,input().split())\nmat=[]\nfor i in range(r):\n mat.append(list(input()))\nrw=[];cl=[]\nfor i in range(r):\n for j in range(c):\n if mat[i][j]==\"S\":\n rw.append(i)\n cl.append(j)\nk=0\nfor i in range(r):\n for j in range(c):\n if i in rw and j in cl:\n k+=1\nprint(r*c-k)\n \n \n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Jan 18 20:49:56 2018\n\n@author: alexis\n\"\"\"\n\nrow, col = raw_input().split()\n\nrow = int(row)\ncol = int(col)\n\ngrid = []\neaten = 0\n\nfor i in range(row):\n grid.append(raw_input())\n\n#print grid\n\ntemp_grid = grid[:]\nfor row in grid:\n if \"S\" not in row:\n eaten += col\n \n temp_grid.remove(row)\n\n#print temp_grid\n\nfor each in range(0, col):\n j = \"\"\n for row in temp_grid:\n j += row[each]\n \n if \"S\" not in j:\n eaten += len(temp_grid)\n \nprint eaten\n \n#3 4\n#S...\n#....\n#..S. "}, {"source_code": "\"\"\"http://codeforces.com/problemset/problem/330/A\"\"\"\n\ndef solve(cake):\n rows, collumns = set(), set()\n for i, row in enumerate(cake):\n for j, cell in enumerate(row):\n if cell == 'S':\n rows.add(i)\n collumns.add(j)\n\n res = 0\n for i, row in enumerate(cake):\n for j, cell in enumerate(row):\n if cell == 'S':\n continue\n if i not in rows or j not in collumns:\n res += 1\n return res\n\nif __name__ == '__main__':\n r, c = map(int, input().split())\n l = []\n for _ in range(r):\n l.append(input())\n print(solve(l))\n"}, {"source_code": "\"\"\"http://codeforces.com/problemset/problem/330/A\"\"\"\n\ndef solve(r, c, cake):\n rows, collumns = set(), set()\n for i, row in enumerate(cake):\n for j, cell in enumerate(row):\n if cell == 'S':\n rows.add(i)\n collumns.add(j)\n\n # res = 0\n # for i, row in enumerate(cake):\n # for j, cell in enumerate(row):\n # if cell == 'S':\n # continue\n # if i not in rows or j not in collumns:\n # res += 1\n # return res\n return (r * c) - (len(rows) * len(collumns))\n\nif __name__ == '__main__':\n r, c = map(int, input().split())\n l = []\n for _ in range(r):\n l.append(input())\n print(solve(r, c, l))\n"}, {"source_code": "n,m=map(int,input().split())\nl=[]\nc=0\nfor i in range(n):\n\ts=input()\n\tif 'S' not in s:\n\t\tc+=m\n\telse:\n\t\tl.append(s)\nfor i in range(m):\n\ts1=0\n\tfor j in range(len(l)):\n\t\tif l[j][i]!='S':\n\t\t\ts1+=1\n\t\telse:\n\t\t\ts1=0\n\t\t\tbreak\n\tc+=s1\nprint(c)"}, {"source_code": "r, c = map(int, input().split())\n\nx = r * [0]\ny = c * [0]\n\nfor i in range(r):\n s = input()\n for j in range(c):\n if (s[j] == 'S'):\n x[i] = 1\n y[j] = 1\n\na = x.count(1)\nb = y.count(1)\n\nprint(r * c - a * b)\n\n\n"}, {"source_code": "r,c=map(int,input().split())\nq,w=0,0\nfor i in range(r):\n s=input().replace(\".\",\"0\").replace(\"S\",\"1\")\n if \"1\" not in s:q+=c;r-=1\n w=w|int(s,2)\nw=bin(w)[2:]\nprint(q+r*(w.count(\"0\")+c-len(w)))"}, {"source_code": "r,c=map(int,input().split())\na=[]\nrapple=0\ncapple=0\nfor i in range(r):\n n=input()\n if ('S' in n):\n rapple+=1\n a.append(list(n))\nfor i in range(c):\n for j in range(r):\n if (a[j][i]=='S'):\n capple+=1\n break\nans=(r*c-(rapple*capple))\nif ans>=0:\n print (ans)\nelse:\n print (0)\n"}, {"source_code": "n, m = [int(i) for i in input().split()]\nr = [True]*n\nc = [True]*m\na = []\nk = 0\nfor i in range(n):\n a.append(input())\nfor i in range(n):\n for j in range(m):\n if a[i][j] == 'S':\n r[i] = c[j] = False\nsr = 0\nsc = 0\nfor i in r:\n if i: \n k += m\n sr += 1\nfor i in c:\n if i: \n k += n\n sc += 1\nprint(k - sc * sr)"}, {"source_code": "r, c = map(int, input().split())\ncake = []\nfor i in range(r):\n cake.append(list(input()))\nres = 0\nfor i in cake:\n if 'S' not in i:\n res += c\n for j in range(len(i)):\n i[j] = None\nfor i in range(c):\n f = 1\n for j in range(r):\n if cake[j][i] == 'S':\n f = 0\n break\n if f:\n for j in range(r):\n if cake[j][i] is not None:\n res += 1\nprint(res)"}, {"source_code": "r,c = map(int,input().split())\nl1 = [input() for i in range(r)]\nl,c1,c2 = [],0,0\nfor i in range(r):\n\tif 'S' in l1[i]:\n\t\tc1+=1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif l1[i][j]=='S':\n\t\t\tc2+=1\n\t\t\tbreak\nprint(c*(r-c1)+r*(c-c2)-(r-c1)*(c-c2))"}, {"source_code": "r,c = map(int,input().split())\nh = [1]*c\nl = []\nfor i in range(r):\n l.append(input())\nm = []\nfor i in range(c):\n x = ''\n for j in range(r):\n x+=l[j][i]\n m.append(x)\ncc,cr = 0,0\nans = 0\nfor i in range(r):\n if(l[i].find('S')==-1):\n ans+=c-cc\n cr+=1\n else:\n for j in range(c):\n if(l[i][j]=='.'):\n if(h[j] and m[j].find('S')==-1):\n ans+=r-cr\n cc+=1\n h[j] = 0\nprint(ans)"}, {"source_code": "r,c=map(int,input().split())\nl=[]\nre,ce,e=0,0,0\nfor i in range(r):\n x=input()\n if \"S\" not in x:\n re+=1\n e+=c\n l.append(x)\nfor i in range(c):\n f=False\n for j in range(r):\n if l[j][i] == \"S\":\n f=True\n if not f:\n ce+=1\n e+=r\nprint(e-(re*ce))"}, {"source_code": "r,c=input().split()\nr=int(r)\nc=int(c)\narr=[]\nrp=0\nsum=0;\ncol_set=[]\nfor i in range(r):\n arr.append(input())\n try:\n arr[i].index('S')\n for j in range(len(arr[i])):\n if arr[i][j]=='S':\n col_set.append(j)\n \n except:\n rp+=1\n sum+=c\n \nfor i in range(c):\n if i not in col_set:\n sum=sum+r-rp\nprint(sum)"}, {"source_code": "r, c = map(int, raw_input().split())\n\nn = [True] * r\nm = [True] * c\n\nfor i in range(r):\n j = 0\n for e in raw_input():\n if e == 'S':\n n[i] = False\n m[j] = False\n j += 1\n\na = sum(map(int, n))\nb = sum(map(int, m))\n\nprint a * c + b * r - a * b\n"}, {"source_code": "n,m=map(int,input().split())\na=[] \nc=[]\nans=0\nfor i in range(n):\n b=list(input())\n if not \"S\" in b:\n ans+=m\n for i in range(len(b)):\n b[i]=\"P\"\n a.append(b)\n else:\n a.append(b)\nb=[]\nfor i in range(m):\n for j in range(n):\n b.append(a[j][i])\n if not \"S\" in b:\n for i in range(len(b)):\n if b[i]!=\"P\":\n ans+=1\n b=[]\nprint(ans)"}, {"source_code": "import sys\nr,c=sys.stdin.readline().split()\nr = int(r)\nc= int(c)\nrr = set(range(r))\ncc = set(range(c))\nl = 0\nfor i in sys.stdin.readlines():\n for j in range(len(i)):\n if i[j] == 'S':\n if l in rr:\n rr.remove(l)\n if j in cc:\n cc.remove(j)\n #print '*'\n l+=1\nprint len(cc)*r+c*len(rr)-len(cc)*len(rr)\n"}, {"source_code": "#\n# 330A. Cakeminator\n#\n\nrows, columns = map(int, raw_input().split())\ncake_matrix = [['' for c in range(columns)] for r in range(rows)]\nfor i in range(rows):\n s = raw_input()\n for j in range(len(s)):\n cake_matrix[i][j] = s[j]\nrow_count = sum(int('S' in cake_matrix[i]) for i in range(rows))\ntranspose_cake_matrix = zip(*cake_matrix)\ncolumn_count = sum(int('S' in transpose_cake_matrix[i]) for i in range(columns))\nprint rows * columns - row_count * column_count"}, {"source_code": "string = raw_input().split(' ')\nstring = map(lambda x:int(x),string)\nrows = []\ncolumns = []\nfor i in range(string[0]):\n\ttemp = raw_input()\n\t\n\tloc = [y for y,x in enumerate(temp) if x=='S']\n\t\n\tfor v in loc:\n\t\trows.append(i)\n\t\tcolumns.append(v)\n\t\nprint (-string[0]+len(set(rows)))*(string[1]-len(set(columns)))+(string[1]-len(set(columns)))*string[0]+(string[0]-len(set(rows)))*string[1]\t\t\n\t\n\t\t\n\t\n"}, {"source_code": "ip_l = map(int, raw_input().strip().split())\nr = ip_l[0]\nc = ip_l[1]\nr_l = range(r)\nc_l = range(c)\nfor i in range(r):\n s = raw_input().strip()\n for j in range(c):\n if(s[j] == 'S'):\n if(i in r_l):\n r_l.remove(i)\n if(j in c_l):\n c_l.remove(j)\n# print r_l\n# print c_l\n\nvisited = []\nfor i in r_l:\n for j in range(c):\n visited.append((i, j))\nfor i in range(r):\n for j in c_l:\n if((i, j) not in visited):\n visited.append((i, j))\n\nprint len(visited)\n"}, {"source_code": "x,y=map(int,input().split());a=[];b=['.' for i in range(y)];p=0;q=0\nfor i in range(x):\n\ta.append(input())\nfor i in range(y):\n\tfor t in range(x):\n\t\tb[i]=b[i]+a[t][i]\nfor i in range(x):\n\tif a[i].count('S')==0:\n\t\tp=p+y\nif p>0:\n\tx=x-(p//y)\nfor i in range(y):\n\tif b[i].count('S')==0:\n\t\tq=q+x\nprint(p+q)\t\n#author:SK__Shanto__\u32db\n#code__define__your__smartness"}, {"source_code": "R=raw_input\nb=map(R,\" \"*int(R()[:2]))\nS=lambda b:sum('S'in i for i in b)\nprint len(b)*len(b[0])-S(b)*S(zip(*b))\n"}, {"source_code": "r,c = map(int, raw_input().split())\n\nmx = [raw_input() for _ in xrange(r)]\n\nrows=set()\ncols=set()\n\nfor i in xrange(r):\n\tfor j in xrange(c):\n\t\tif mx[i][j]=='S':\n\t\t\trows.add(i)\n\t\t\tcols.add(j)\n\nans=0\nfor i in xrange(r):\n\tfor j in xrange(c):\n\t\tif i not in rows or j not in cols:\n\t\t\tans+=1\n\nprint ans"}, {"source_code": "r, c = list(map(int, input().split()))\nl = []\na = []\nfor i in range(r):\n l.append(input())\ncnt = 0\n\nfor ix, row in enumerate(l):\n if 'S' not in row:\n cnt += c\n a.append(ix)\n\ni = j = 0\n\nwhile j < c:\n cn = i = 0\n while i < r:\n if i in a:\n i += 1\n continue\n if l[i][j] == 'S':\n break\n else:\n cn += 1\n i += 1\n else:\n cnt += cn\n j += 1\n\nprint(cnt)\n"}, {"source_code": "n,m = map(int,raw_input().strip().split(' '))\nl=[]\ncount = 0\ncountr = 0\ncountc = 0\nfor i in range(n):\n l.append(raw_input().strip())\n if 'S' not in l[i]:\n count += m\n countr += 1\n\nfor j in range(m):\n flag = True\n for i in range(n):\n if l[i][j] == 'S':\n flag = False\n break\n if flag: \n count += n\n countc += 1\nprint count - countr*countc\n\n \n\n\n\n\n\n \n\n \n\n"}, {"source_code": "#import sys\n#input = sys.stdin.readline\nrows,columns=map(int,input().strip().split())\nmatrix=[[0 for x in range(columns)] for y in range(rows)]\n#print(matrix)\nfor i in range(rows):\n n=list(input())\n for j in range(len(n)):\n matrix[i][j]=n[j]\nk=0\nfor i in range(rows):\n c=0\n for j in range(columns):\n if matrix[i][j]!='S':\n c+=1\n if c==columns:\n for j in range(columns):\n k+=1\n matrix[i][j]='v'\n#print(matrix)\nfor i in range(columns):\n c=0\n for j in range(rows):\n #print(matrix[j][i])\n if matrix[j][i]!='S':\n c+=1\n if c==rows:\n for j in range(rows):\n if matrix[j][i]!='v':\n k+=1\nprint(k)\n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n"}, {"source_code": "n, m = map(int,input().split())\na = []\nfor i in range(n):\n\ta.append(list(input()))\ns = 0\ns1 = 0\nfor i in range(n):\n\tcount = 0\n\tfor j in range(m):\n\t\tif a[i][j] == \".\":\n\t\t\tcount += 1\n\tif count == m:\n\t\ts += m\n\t\ts1 += 1\nfor i in range(m):\n\tcount = 0\n\tfor j in range(n):\n\t\tif a[j][i] == \".\":\n\t\t\tcount += 1\n\tif count == n:\n\t\ts += (n - s1)\nprint(s)\t"}, {"source_code": "r,c=raw_input().split()\nr=int(r)\nc=int(c)\nl=[]\nl1=[]\nrow=[]\ncolumn=[]\nfor i in range(r):\n l=[x for x in raw_input()]\n l1.append(l)\nfor i in range(r):\n for j in range(c):\n if(l1[i][j]=='S'):\n if i not in row:\n row.append(i)\n if j not in column:\n column.append(j)\n#print row\n#print column\nn=len(column)*len(row)\nr=int(r)\nc=int(c)\nans=(r*c)-(n)\nif(ans>0):\n print ans\nelse:\n print '0'\n"}, {"source_code": "r,c=map(int,raw_input().split());cake=[]\nfor i in range(r):\n for j in raw_input():\n cake.append(ord(j))\nfor i in range(r):\n cake[i*c:(i+1)*c]=[cake[i*c:(i+1)*c],[99]*c][83 not in cake[i*c:(i+1)*c]]\nfor i in range(c):\n cake[i::c]=[cake[i::c],[99]*r][83 not in cake[i::c]]\nprint sum(1 for i in cake if i==99)"}, {"source_code": "n, m = map(int, input().split())\nli = []\nans = 0\nfor i in range(n):\n s = list(input())\n if 'S' not in s:\n ans += m \n else:\n li.append(s)\nif(len(li)!=0):\n li2 = []\n for i in range(len(li[0])):\n x = []\n for j in li:\n x.append(j[i])\n if('S' not in x):\n ans += len(x)\nprint(ans)\n \n"}, {"source_code": "r,c=map(int, input().split())\nl=[[0]*c]*r\nfor i in range(r):\n l[i]=list(input())\n#print(l)\ncr=0\ncc=0\nfor i in range(r):\n x=l[i]\n if 'S' not in x:\n cr+=1\nfor j in range(c):\n x=[l[i][j] for i in range(r)]\n if 'S' not in x:\n cc+=1\nans=max(cr*c+cc*r-cr*cc,0)\nprint(ans)"}, {"source_code": "def tran(m):\n rez = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))]\n return rez\nr,n = map(int,input().strip().split())\nc = 0\nb = 0\narr = []\nfor l in range(r):\n arr.append(list(input()))\nfor row in arr:\n if 'S' not in row:\n c += row.count('.')\n b += 1\narr = tran(arr)\nfor row in arr:\n if 'S' not in row:\n c += row.count('.') - b\nprint(c)"}, {"source_code": "r, c = map(int, input().split())\nlist = []\ncnt = 0\n\nfor k in range(r):\n g = input()\n list.append(g)\n\ndef foo_r(x, y):\n a = True\n if 'S' in list[x]:\n a = False\n\n b = foo_c(y)\n if a == False and b == False:\n return False\n else:\n return True \n\ndef foo_c(z):\n n = True\n for f in range(r):\n if list[f][z] == 'S':\n n = False\n break\n \n return n \n\n\n\nfor i in range(r):\n for j in range(c):\n if list[i][j] == 'S':\n continue\n else:\n x = foo_r(i, j)\n if x == True:\n cnt += 1\n\nprint(cnt)\n"}, {"source_code": "r,c=map(int,input().split())\nx=0\ny=[]\nfor i in range(r):\n s=input()\n if 'S' in s:\n x+=1\n for j in range(len(s)):\n if 'S'==s[j] and j not in y:\n y.append(j)\nprint(r*c-x*len(y))\n "}, {"source_code": "n,m=map(int,input().split())\ns=\"\"\na=set()\nb=set()\nfor i in range(n):\n s=input()\n for j in range(m):\n if s[j]=='S':\n a.add(i)\n b.add(j)\nprint(m*n-len(a)*len(b))\n"}, {"source_code": "a,b = map(int,input().split())\nz,w,q =[],0,0\nfor i in range(a):\n\tl = list(input())\n\tz.append(l)\n\tif l.count(\"S\")==0:w+=1\nfor i in range(len(z[0])):\n\te =\"\"\n\tfor j in range(len(z)):\n\t\te+=z[j][i]\n\tif e.count(\"S\")==0:q+=(a-w)\nprint(w*b + q)\n"}, {"source_code": "n,d = map(int,input().split(\" \"))\nt1=[0]*n\nt2=[0]*d\nfor i in range(n):\n j=0\n for s in input():\n if s==\"S\":\n t1[i]=1\n t2[j]=1\n j+=1\nres=0\nfor i in range(n):\n for j in range(d):\n if t1[i]!=1 or t2[j]!=1:\n res+=1\nprint(res)\n\n\n"}, {"source_code": "#-------------Program--------------\n#----Kuzlyaev-Nikita-Codeforces----\n#-------------Training-------------\n#----------------------------------\nr,c=map(int,input().split())\neat=0;f=[]\nfor i in range(c):f.append([])\nfor i in range(r):\n k=list(str(input()))\n if k.count(\"S\")==0:\n for j in range(c):\n k[j]=\"E\"\n eat+=c\n for j in range(c):\n f[j].append(k[j])\nfor i in range(c):\n if f[i].count(\"S\")==0:\n eat+=f[i].count(\".\")\nprint(eat)"}, {"source_code": "n,m = map(int,input().split())\nlis=[]\nfor i in range(n):\n l = list(input())\n lis.append(l)\nans=0 \nfor i in range(n):\n c=0\n for j in range(m):\n if lis[i][j]=='S':\n c=0\n break\n elif lis[i][j]=='.':\n c+=1\n if c>0:\n ans+=c\n for j in range(m):\n if lis[i][j]!='S': \n lis[i][j]=0 \nfor i in range(m):\n c=0\n for j in range(n):\n if lis[j][i]=='S':\n c=0\n break\n elif lis[j][i]=='.':\n c+=1\n if c>0:\n ans+=c\n for j in range(n):\n if lis[j][i]!='S':\n lis[j][i]=0\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nrow=set()\ncol=set()\nans=0\nfor i in range(n):\n s=input()\n for j in range(m):\n if s[j]=='S':\n row.add(i)\n col.add(j)\nans=n*m\nx=len(row)*len(col)\n\nprint(ans-x)\n \n"}, {"source_code": "r, c = map(int, input().split())\ntort = [input() for i in range(r)]\ncount = 0\ns = 0\nz = 0\ncolumn = []\nq = 0\nfor i in range(r):\n if 'S' not in tort[i]:\n count += c\n z += 1\n\n elif 'S' in tort[i] and tort[i].count('S') == len(tort[i]):\n s = 1\nif (count == 0 and s == 0) or (count > 0 and s == 1) or (count > 0 and s == 0):\n for i in range(c):\n for j in range(r):\n if tort[j][i] == '.':\n q += 1\n column.append(q)\n q = 0\n if count > 0 and max(column) == r:\n print(count + max(column)*column.count(max(column)) - column.count(max(column))*z)\n elif count == 0 and max(column) == r:\n print(max(column)*column.count(max(column)))\n else:\n print(count)\nelse:\n print(0)\n\n"}, {"source_code": "r,c=map(int,input().split())\na=[]\nnr=[]\nnc=[]\nfor i in range(r):\n\tp=list(input())\n\tfor j in range(c):\n\t\tif p[j]==\"S\":\n\t\t\tif j not in nc:\n\t\t\t\tnc.append(j)\n\t\t\tif i not in nr:\n\t\t\t\tnr.append(i)\nprint(( (r-len(nr))*c )+( (c-len(nc))*r )- (r-len(nr))*(c-len(nc)) )"}, {"source_code": "import fileinput as f\n\ndata = []\n\nfor line in f.input():\n if f.lineno() == 1:\n [r, c] = list(map(int, line.split()))\n else:\n data.append(line.strip())\n\nSrows = [0] * r\nScols = [0] * c\nfor m in range(r):\n for n in range(c):\n if data[m][n] == 'S':\n Srows[m] = 1\n Scols[n] = 1\n \ncr = sum(Srows) \ncc = sum(Scols)\nnumcakes = r * c - cr * cc\n\nprint(numcakes)\n"}, {"source_code": "r,c=map(int,input().strip().split())\nl=[]\nR=0\nC=0\nz=0\nC1=set()\nfor i in range(r):\n l.append(input())\n if l[i].find('S',0)== -1:\n z+=1\n else:\n R+=1\nfor i in range(r):\n for j in range(c):\n if l[i][j]=='S':\n C1.add(j)\nC=len(C1)\n\nprint(r*c-R*C)"}, {"source_code": "a,b=map(int,input().split())\nl=[]\nk=0\nfor i in range(a):\n l.append(input())\nfor i in range(a):\n if l[i].count('S')==0:\n k+=b\n l[i]='*'*b\nfor i in range(b):\n v = 0\n o=0\n for j in range(a):\n if l[j][i]=='.':\n v+=1\n elif l[j][i]=='*':\n o+=1\n if v+o == a:\n k+=v\nprint(k)"}], "negative_code": [{"source_code": "n,m=list(map(int,input().split()))\nl=[]\nfor _ in range(n):\n l.append(list(input()))\n\nc=0\npos=[]\nfor x in l:\n if 'S' not in x:\n c+=m\n l.remove(x)\n \n\nnl= list(map(list, zip(*l)))\nfor x in nl:\n if 'S' not in x:\n c+=len(l)\n\n\nprint(c)"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output1.out\",'w')\nn,m=map(int,input().split())\na=[]\nc=0\nfor i in range(n):\n\ts=input()\n\tif 'S' in s:\n\t\tc+=1\n\t\tc+=s.count(\"S\")\nprint(n*m-c)\t\t "}, {"source_code": "r,c=map(int,input().split())\nA,B=[],[]\nfor i in range(r):\n R=list(input())\n while('S'in R):\n I=R.index('S')\n B+=[I]\n A+=[i]\n R[I]='.'\nprint((r*c)-sum(set(A))*sum(set(B))) \n \n "}, {"source_code": "n, m = map(int, input().split())\na = []\n[a.append(input()) for i in range(n)]\nstroki = 0\nstolb = 0\nb = []\nfor j in range(m):\n bb = []\n for i in range(n):\n [bb.append(a[i][j])]\n b.append(' '.join(bb))\nfor ss in a:\n if 'S' not in ss:\n stroki += 1\nfor pp in b:\n if 'S' not in pp:\n stolb += 1\ncc = []\nfor i in a:\n for j in i:\n cc.append(j)\n if 'S' not in cc:\n summa = n * m\n elif stroki == stolb:\n summa = (stroki * m + stolb * n) - max(stroki, stolb) * stroki\n elif stroki != 0 and stolb != 0:\n summa = (stroki * m + stolb * n) - max(stroki, stolb)\n else:\n summa = (stroki * m + stolb * n)\nprint(summa)"}, {"source_code": "'''input\n3 4\nS...\n....\n..S.\n'''\nr, c = map(int, input().split())\nnr, nc = [], []\nfor x in range(r):\n\tn = input()\n\tif \"S\" in n:\n\t\tnr.append(x)\n\t\tnc.append(n.index(\"S\"))\na, b = len(set(nr)), len(set(nc))\nprint((r-a)*c + (c-b)*r - r + a - c + b + 1)\n\t\t\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "r, c = map(int, input().split())\na = [input() for i in range(r)]\n\ncount = 0\npos = []\nz = 0\nw = 0\n\nfor i in range(r):\n if 'S' not in a[i]:\n count += c\nfor i in range(r):\n if 'S' in a[i]:\n z = 0\n for j in range(c):\n if a[i][j] == '.':\n pos.append(z)\n z += 1\n else:\n z += 1\n if 'S' in a[i] and a[i].count('S') == len(a[i]):\n w = 1\n\n else:\n z = 0\ne = 0\nif w == 1:\n print(0)\nelse:\n if len(pos) == 0:\n print(count)\n else:\n e = [pos.count(i) for i in pos]\n if e.count(e[0]) == len(e):\n if 0 in pos:\n print(count + (max(pos)+1)*max(e))\n else:\n print(count + (max(pos)) * max(e))\n else:\n q = [pos.count(i) for i in pos]\n print(count + max(q)*2)\n\nq = [pos.count(i) for i in pos]\n\n\n"}, {"source_code": "r,c = map(int,input().split())\ndata = [list(input()) for i in range(r)]\nprint(data)\ntotal=0\nfor i in range(r):\n if 'S' not in data[i]:\n total+=c\nfor j in range(c):\n for k in range(r):\n if data[k][j]=='S':\n break\n else:\n total=total+r-total//c\nprint(total)\n \n "}, {"source_code": "r, c = map(int, input().split())\na = [input() for i in range(r)]\n\ncount = 0\npos = []\nz = 0\n\nfor i in range(r):\n if 'S' not in a[i]:\n count += c\nfor i in range(r):\n if 'S' in a[i]:\n z = 0\n for j in range(c):\n if a[i][j] == '.':\n pos.append(z)\n z += 1\n else:\n z += 1\n else:\n z = 0\n\nif len(pos) == 0:\n print(count)\nelse:\n c = [pos.count(i) for i in pos]\n p = c.count(max(c)) // max(c)\n print(count + 2 * p)\n"}, {"source_code": "r,c=map(int,raw_input().split())\n\ncake_cells=[]\ncells_to_eat=0\n\nfor i in range(r):\n cells=[]\n cake=raw_input()\n for j in range(c):\n cells.append(cake[j])\n\n cake_cells.append(cells)\n\ncake_cells_copy=cake_cells[:]\nrows_eaten=[]\n\nfor i in range(r):\n if cake_cells[i].count('.')==c:\n cells_to_eat += c\n rows_eaten.append(i)\n\nfor i in range(c):\n count=0\n current=cake_cells[0][i]\n for j in range(1,r):\n if cake_cells[j][i]==current:\n count += 1\n if count==r-1:\n cells_to_eat += r-len(rows_eaten)\n\nprint cells_to_eat\n\n"}, {"source_code": "def cakeminator(r,c,alist):\n collist=[] # collist=list()\n for i in range(0,c): # column\n isColEditable=True\n isCakeAvailable=False\n for j in range(0,r): # row\n if alist[j][i]==\".\":\n isCakeAvailable=True\n elif alist[j][i]==\"S\":\n isColEditable=False\n\n if(isCakeAvailable and isColEditable):\n collist.append(i) \n rowlist=[]\n allRowsEdibleCount = 0\n for i in range(0,r):\n thisRowEdibleCount = 0\n isRowEditable=True\n isCakeAvailable=False\n for j in range(0,c):\n if alist[i][j]==\".\" and not j in collist:\n isCakeAvailable=True \n elif (alist[i][j]==\"S\"):\n isRowEditable=False\n thisRowEdibleCount+=1\n\n if(isCakeAvailable and isRowEditable):\n rowlist.append(i)\n allRowsEdibleCount += thisRowEdibleCount\n #print(collist)\n #print(rowlist)\n return len(collist)*r + allRowsEdibleCount\n\nn,m=map(int,input().split())\nblist=[]\nfor i in range(n):\n b=input()\n alist=list(b)\n blist.append(alist)\n#print(blist)\nprint(cakeminator(n,m,blist))\n\n\"\"\"\n3 4\nS...\n....\n..S.\n\n\"\"\"\n"}, {"source_code": "r, c = map(int, input().split())\ntort = [input() for i in range(r)]\ncount = 0\ns = 0\nz = 0\ncolumn = []\nq = 0\nfor i in range(r):\n if 'S' not in tort[i]:\n count += c\n z += 1\n\n elif 'S' in tort[i] and tort[i].count('S') == len(tort[i]):\n s = 1\nif (count == 0 and s == 0) or (count > 0 and s == 1) or (count > 0 and s == 0):\n for i in range(c):\n for j in range(r):\n if tort[j][i] == '.':\n q += 1\n column.append(q)\n q = 0\n if count > 0:\n print(count + max(column)*column.count(max(column)) - column.count(max(column))*z)\n else:\n print(max(column)*column.count(max(column)))\nelse:\n print(0)\n"}, {"source_code": "x,y = map(int,input().split())\nz = []\nb1 = 0\nt = 0\nfor i in range(x):\n\ta = input()\n\tflag1 = 0\n\tfor j in range(y):\n\t\tif a[j] == \"S\" and flag1 == 0:\n\t\t\tt = t + 1\n\t\t\tflag1 = 1\n\t\telif j in z and a[j] == \"S\" :\n\t\t\tt = t + 1\n\t\t\tcontinue\n\t\telif a[j] == \"S\":\n\t\t\tt = t + 1\n\t\t\tz.append(j)\nprint(x*y-t)"}, {"source_code": "r, c = map(int, input().split())\ntort = []\nschet = 0\npodschet_f = 0\npodschet = 0\nstolb=0\nstrok=0\nfor i in range(r):\n tort.append(list(str(input())))\n\nfor i in range(r):\n for j in range(c):\n if tort[i][j] != 'S':\n podschet_f += 1\n else:\n podschet_f = 0\n if podschet_f==c:\n schet += podschet_f\n podschet_f=0\n strok+=1\n else:\n podschet_f=0\n\nfor j in range(c):\n for i in range(r):\n if tort[i][j] != 'S':\n podschet += 1\n else:\n podschet = 0\n if podschet==r:\n schet += podschet\n podschet=0\n stolb+=1\n else:\n podschet=0\n\nif strok>stolb and stolb>=1:\n print(schet-strok)\nelif stolb>strok and strok>=1:\n print(schet-stolb)\nelif r==strok and c==stolb:\n print(r*c)\nelse:\n print(schet)"}, {"source_code": "import sys\n\ndef data():\n return sys.stdin.readline().strip()\n \n \ndef sp(): return map(int, data().split()) \ndef l(): return list(sp())\n\ntemp=l()\nr=temp[0]\nc=temp[1]\nt=[]\nnr=[]\nnc=[]\nfor i in range(r):\n\tt.append(list(data()))\n \nfor i in range(r):\n for j in range(c):\n if t[i][j]=='S':\n nr.append(i)\n nc.append(j)\n\ncommon=(r-len(nr))*(c-len(nc))\neat=(r-len(nr))*c+(c-len(nc))*r-common\nif eat<=0:\n print(0)\nelse:\n print(eat+1)\n\n\n\n"}, {"source_code": "n, m = map(int, input().split())\na = []\n[a.append(input()) for i in range(n)]\nstroki = 0\nstolb = 0\nb = []\nfor j in range(m):\n bb = []\n for i in range(n):\n [bb.append(a[i][j])]\n b.append(' '.join(bb))\nfor ss in a:\n if 'S' not in ss:\n stroki += 1\nfor pp in b:\n if 'S' not in pp:\n stolb += 1\ncc = []\nfor i in a:\n for j in i:\n cc.append(j)\n if 'S' not in cc:\n summa = n * m\n elif stroki != 0 and stolb != 0:\n summa = (stroki * m + stolb * n) - max(stroki, stolb)\n else:\n summa = (stroki * m + stolb * n)\nprint(summa)"}, {"source_code": "def answer():\n a = input().split()\n a = [int(x) for x in a]\n i=0\n c=[]\n d1=[]\n while i<a[0]:\n d=list(input())\n j=0\n while j<len(d):\n if d[j]==\"S\":\n c.append(i)\n d1.append(j)\n j+=1\n i+=1\n ans = a[0]*a[1]-len(c)*len(d1)\n print(ans)\nanswer()"}, {"source_code": "__author__ = 'abbas'\nn = [int(x) for x in raw_input().split()]\nr,c = n[0],n[1]\ngrid = [[0]*c]*r\ncount = r*c\nfor i in range(r):\n list = raw_input()\n for j in range(c):\n if(list[j] == 'S'):\n for x in range(r):\n if(grid[x][j] != 1):\n grid[x][j] = 1\n count -= 1\n for y in range(c):\n if(grid[i][y] != 1):\n grid[i][y] = 1\n count -= 1\nprint count"}, {"source_code": "import sys\n\ndef input(): return sys.stdin.readline().strip()\ndef iinput(): return int(input())\ndef rinput(): return map(int, sys.stdin.readline().strip().split()) \ndef get_list(): return list(map(int, sys.stdin.readline().strip().split())) \n\n\nr,c=rinput()\na=[]\nfor i in range(r):\n s=list(input())\n a.append(s)\ncount=0\ncount1=0\nfor i in range(r):\n if(a[i]==['.']*c):\n count+=1\n\nif(count==r):\n print(r*c)\nelif(count==0):\n print(0)\nelse:\n i=0\n while(i<c):\n for j in range(r):\n if(a[j][i]=='S'):\n count1+=1\n i+=1\n\n l=(c-count1)*r -(c-count1)\n m=count*c\n print(l+m)"}, {"source_code": "r,c = map(int,input().split())\ndd =[]\nfor i in range(r):\n s = input()\n op=[]\n for ii in s:\n op.append(ii)\n dd.append(op)\npos =[]\nfor i in range(r):\n for j in range(c):\n if dd[i][j]==\"S\":\n t =(i,j)\n \n pos.append(t)\nleft = len(pos)*len(pos)\nprint((r*c)-left)"}, {"source_code": "r,c=map(int,raw_input().split())\ngrid=[[0 for i in range(0,c)]for j in range(0,r)]\nzuo=[]\ncnt=0\nfor i in range(0,r):\n s=raw_input()\n for j in range(0,len(s)):\n if s[j]=='S':\n grid[i][j]=1\n cnt=cnt+1\n zuo.append([i,j])\nfor i in range(0,len(zuo)):\n for j in range(i,len(zuo)):\n if zuo[i][0]!=zuo[j][0] and zuo[i][1]!=zuo[j][1]:\n #grid[zuo[j][0]][zuo[i][1]]=1\n #grid[zuo[i][0]][zuo[j][1]]=1\n cnt=cnt+2\nprint r*c-cnt"}, {"source_code": "x,y = map(int,input().split())\nz = []\nb1 = 0\nt = 0\nfor i in range(x):\n\ta = input()\n\tflag1 = 0\n\tfor j in range(y):\n\t\t# print(t)\n\t\tif a.count(\"S\") > 0 and flag1 == 0:\n\t\t\tflag1 = 1\n\t\t\tt+=1\n\t\tif j in z:\n\t\t\tcontinue\n\t\tif a[j] == \"S\":\n\t\t\tt = t + 1\n\t\t\tz.append(j)\nprint(x*y-t)"}, {"source_code": "r, c = map(int, input().split())\ntort = []\nschet = 0\npodschet_f = 0\npodschet = 0\nstolb=0\nstrok=0\nfor i in range(r):\n tort.append(list(str(input())))\n\nfor i in range(r):\n for j in range(c):\n if tort[i][j] != 'S':\n podschet_f += 1\n else:\n podschet_f = 0\n if podschet_f==c:\n schet += podschet_f\n podschet_f=0\n strok+=1\n else:\n podschet_f=0\n\nfor j in range(c):\n for i in range(r):\n if tort[i][j] != 'S':\n podschet += 1\n else:\n podschet = 0\n if podschet==r:\n schet += podschet\n podschet=0\n stolb+=1\n else:\n podschet=0\n\nif strok>stolb and stolb>=1:\n print(schet-strok)\nelif stolb>strok and strok>=1:\n print(schet-stolb)\nelse:\n print(schet)"}, {"source_code": "bawah,kanan = list(map(int , input().split()))\nkolom = []\nbaris = []\nfor z in range (bawah):\n a = input()\n listS = []\n for zz in range (len(a)):\n listS.append(a[zz])\n if \"S\" in listS:\n if listS.index(\"S\") not in kolom:\n kolom.append(listS.index(\"S\"))\n if z not in baris:\n baris.append(z)\n\nkebawah = (kanan-len(kolom))*bawah\nkesamping = (bawah-len(baris))*(kanan-(kanan-len(kolom)))\nprint(kebawah+kesamping)\n\n\n\n"}, {"source_code": "r, c = map(int, input().split())\nM = [input() for _ in range(r)]\nfor i in range(r):\n if 'S' not in M[i]:\n print((r - i) * c)\n break"}, {"source_code": "r, c = map(int, input().split())\na = []\nfor i in range(r):\n a.append(input())\n# print(a)\ntotal_s_str = 0\ntotal_s_column = 0\ns_str = 0\ns_column = 0\nfor i in range(r):\n for j in range(c):\n if a[i][j] != 'S':\n s_str += 1\n if s_str == c:\n total_s_str += c\n else:\n s_str = 0\n# print(total_s_str)\nfor j in range(c):\n for i in range(r):\n if a[i][j] != 'S':\n s_column += 1\n if s_column == r:\n total_s_column += r\n else:\n s_column = 0\n# print(total_s_column)\nprint((max(total_s_column, total_s_str) - min(total_s_column, total_s_str)) + max(total_s_column, total_s_str))\n\n\n"}, {"source_code": "r,c=raw_input().split()\nr=int(r)\nc=int(c)\nl=[]\nl1=[]\nl2=[]\nfor i in range(r):\n l=[x for x in raw_input()]\n l1.append(l)\nfor i in range(r):\n for j in range(c):\n if(l1[i][j]=='S'):\n l2.append(l1[i][j])\nn=len(l2)\nr=int(r)\nc=int(c)\nprint (r*c)-(n*n)\n"}, {"source_code": "r, c = map(int,input().split())\nl=[]\nfor i in range(r):\n\ts = input()\n\tl.append(s)\na = []\nfor i in range(r):\n\tb = 0\n\td=[]\n\tfor j in range(c):\n\t\tif l[i][j] == \"S\":\n\t\t\tb=1\n\t\telse:\n\t\t\td.append(j+1+i*c)\n\tif b == 0:\n\t\tfor i in d:\n\t\t\ta.append(i)\nfor i in range(c):\n\tb= 0\n\td= []\n\tfor j in range(r):\n\t\tif l[j][i] == \"S\" :\n\t\t\tcontinue\n\t\telse:\n\t\t\td.append(i+1+j*r)\n\tif b == 0:\n\t\tfor i in d:\n\t\t\ta.append(i)\nprint(len(set(a)))"}, {"source_code": "import sys\n\ndef input(): return sys.stdin.readline().strip()\ndef iinput(): return int(input())\ndef rinput(): return map(int, sys.stdin.readline().strip().split()) \ndef get_list(): return list(map(int, sys.stdin.readline().strip().split())) \n\n\nr,c=rinput()\na=[]\nfor i in range(r):\n s=list(input())\n a.append(s)\ncount=0\ncount1=0\nfor i in range(r):\n if(a[i]==['.']*c):\n count+=1\n\nif(count==r):\n print(r*c)\nelse:\n i=0\n while(i<c):\n for j in range(r):\n if(a[j][i]=='S'):\n count1+=1\n i+=1\n\n l=(c-count1)*r -(c-count1)\n m=count*c\n print(m+l)\n"}, {"source_code": "import sys\nmy_file = sys.stdin\n#my_file = open(\"input.txt\", \"r\")\nline = [int(i) for i in my_file.readline().strip(\"\\n\").split()]\nr, c = line[0], line[1]\ntable = my_file.read().split()\nres = 0\nfor line in range(r):\n try:\n if \"S\" not in table[line]:\n res += len(table[line])\n del table[line]\n r -= 1\n except:\n pass\nfor char in range(c):\n for row in range(r):\n if table[row][char] == \"S\":\n break\n else:\n res += r\nprint(res)"}, {"source_code": "r, c = map(int, raw_input().split())\na = []\nk = 0\nfor i in range(r):\n\ts = str(raw_input())\n\tif not 'S' in s: k += c\n\ta.append(s)\n\t\t\nfor j in range(c):\n\tflag = True\n\tfor i in range(r):\n\t\tif a[i][j] == 'S': flag = False\n\tif flag: k += r\n\nprint k\n\t\t\n"}, {"source_code": "r,c=map(int, input().split())\nx=set()\ny=set()\n\nfor i in range(r):\n t = [k for k in list(input())]\n \n for j in range(c):\n if t[j] == 'S':\n x.add(j)\n y.add(j)\n \nprint(r*c-(len(x)*len(y)))\n \n\n"}, {"source_code": "n,m=map(int,input().split())\ny,z,z1,z2,z3=[],[],[],[],[]\nk=0\nfor i in range(n):\n x=list(input())\n y.append(x)\nfor i in range(n):\n for j in range(m):\n if y[i][j]!=\"S\":\n k+=1\n if k==m:\n z.append(k)\n k=0\nfor i in range(m):\n for j in range(n):\n if y[j][i]!=\"S\":\n k+=1\n if k==n:\n z1.append(k)\n k=0\nfor i in range(len(z)//2):\n z2.append(z[i])\nfor i in range(len(z1)//2):\n z3.append(z1[i])\nprint((sum(z2)+sum(z3))-(len(z2)*len(z3)))"}, {"source_code": "r, c = map(int, input().split())\np = [input() for i in range(r)]\npos = []\nfor i in p:\n pos.append(i.find('S'))\ncount = 0\n\nfor i in range(r):\n if 'S' not in p[i]:\n count += c\n p[i] = p[i].replace('.', '', c)\n\ncopy = pos[:]\n\nif pos.count(-1) != len(pos) and pos.count(0) != len(pos):\n for i in range(pos.count(-1)):\n copy.remove(-1)\n count += (max(pos) - min(copy)) * (len(pos) - pos.count(-1))\n print(count)\nelif pos.count(0) == len(pos):\n count += r * (c-1)\n print(count)\nelse:\n print(count)\n\n"}, {"source_code": "n, m = map(int, input().split())\ncount = 0\nr = [False]*n\nc = [False]*m\nfor i in range(n):\n try:\n j = input().index('S')\n r[i] = True\n c[j] = True\n except:\n pass\n\nprint(r.count(False)*m + c.count(False)*n - (r.count(False)*c.count(False)))\n"}, {"source_code": "'''input\n2 2\n..\n..\n'''\nr, c = map(int, input().split())\nnr, nc = [], []\nfor x in range(r):\n\tn = input()\n\tif \"S\" in n:\n\t\tnr.append(x)\n\t\tnc.append(n.index(\"S\"))\na, b = len(set(nr)), len(set(nc))\nprint((r-a)*c + (c-b)*r - (r-a)*(c-b))\n\t\t\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "l=list(map(int,input().split()))\nr=l[0]\nc=l[1]\na=0\nx=0\nb=0\ny=0\nlst=list()\nfor i in range(r):\n s=input()\n lst.append(s)\nfor i in lst:\n a=0\n for j in i:\n if j==\"s\":\n a=1\n break\n if a==0:\n x=x+c\nfor i in range(c):\n b=0\n for j in range(r):\n if lst[j][i]==\"s\":\n b=1\n break\n if b==0:\n y=y+r \nprint(x+y-(x*y)//12) \n "}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output1.out\",'w')\nn,m=map(int,input().split())\na=[]\nc=0\nfor i in range(n):\n\ts=input()\n\tif 'S' in s:\n\t\tc+=1\n\t\tc+=s.count(\"S\")\nprint(n*m-c)\t\t "}, {"source_code": "import sys\n\ndef data():\n return sys.stdin.readline().strip()\n \n \ndef sp(): return map(int, data().split()) \ndef l(): return list(sp())\ndef ssp(): return data().split()\ndef sl(): return list(ssp())\ntemp=l()\nr=temp[0]\nc=temp[1]\nt=[]\nnr=[]\nnc=[]\nfor i in range(r):\n\tt.append(list(data()))\n \nprint(t)\nfor i in range(r):\n for j in range(c):\n if t[i][j]=='S':\n nr.append(i)\n nc.append(j)\nsum=''\ncommon=(r-len(nr))*(c-len(nc))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif i not in nr and j not in nc:\n\t\t\tsum+=t[i][j]\n\t\t\t\n\nprint(len(sum)-common)\n\n"}, {"source_code": "bawah,kanan = list(map(int , input().split()))\nkolom = []\nbaris = []\nfor z in range (bawah):\n a = input()\n listS = []\n for zz in range (len(a)):\n listS.append(a[zz])\n if \"S\" in listS:\n if listS.index(\"S\") not in kolom:\n kolom.append(listS.index(\"S\"))\n if z not in baris:\n baris.append(z)\n\nkebawah = (kanan-len(kolom))*bawah\nkesamping = (bawah-len(baris))*(kanan-(kanan-len(kolom)))\nprint(kebawah,kesamping)\n\n\n\n"}, {"source_code": "n, p = map(int, input().split())\narr = []\nfor i in range(n):\n s = str(input())\n arr.append(s)\n\ncount = 0\n#countExtra = 0\nfor i in range(n):\n counts = 0\n k = 0\n truth = True\n while k < p and truth == True:\n if arr[i][k:k+1] == \".\":\n counts+=1\n if arr[i][k:k+1] == \"S\":\n truth = False\n k+=1\n if counts == p:\n count+=counts\n #countExtra+=1\n \nfor i in range(p):\n countss = 0\n kk = 0\n truthh = True\n while kk < n and truthh ==True:\n if arr[kk][i:i+1] == \".\":\n countss+=1\n if arr[kk][i:i+1] == \"S\":\n truthh = False\n kk+=1\n if countss == n:\n count+=countss\n count-=1\nprint(count)\n \n\n "}, {"source_code": "def solved(r,c,arr,evil):\n count = 0\n for i in range(r):\n if 'S' not in arr[i]:\n count += len(arr[i])\n for j in range(c):\n if i not in evil:\n count += 1\n print(count)\nif __name__ == '__main__':\n r,c = map(int,input().split())\n arr = []\n evil = []\n for i in range(r):\n x = input()\n for j in x:\n if j == 'S':\n evil.append(x.index('S'))\n arr.append(x)\n solved(r,c,arr,evil)"}, {"source_code": "def cake(n, m, grid):\n c = 0\n new = []\n for i in range(n):\n if 'S' not in grid[i]:\n c += m\n continue\n new.append(grid[i])\n\n for i in range(len(new)):\n for j in range(m):\n if new[i][j] == 'S':\n break\n c += len(new)\n\n return c\n\nlst = [int(x) for x in input().split()]\nn = lst[0]\nm = lst[1]\n\ngrid = []\nfor i in range(n):\n s = input()\n temp = []\n temp.extend(s)\n grid.append(temp)\n\nprint(grid)\n\nprint(cake(n, m, grid))"}, {"source_code": "n,m = map(int, input().split())\na = []\nr = 0\nc = 0\nfor i in range(n):\n temp = input()\n if 'S' in temp:\n r += 1\n c += 1\n\nprint(n*m - r*c)"}, {"source_code": "bawah,kanan = list(map(int , input().split()))\nkolom = []\nbaris = []\nfor z in range (bawah):\n a = input()\n listS = []\n for zz in range (len(a)):\n listS.append(a[zz])\n if \"S\" in listS:\n if listS.index(\"S\") not in kolom:\n kolom.append(listS.index(\"S\"))\n if z not in baris:\n baris.append(z)\n\nkebawah = (kanan-len(kolom))*bawah\nkesamping = (bawah-len(baris))*(kanan-(kanan-len(kolom)))\nprint(kebawah+kesamping)\n\n\n\n"}, {"source_code": "n,m=map(int,input().split())\na=[]\nb=[]\nf=int(0)\ncount=int(0)\nfor i in range(n):\n b=input()\n a.append(b)\nfor i in range(n):\n if('S' not in a[i]):\n count=+m\nfor i in range(m):\n f=0\n for j in range(n):\n if('S' not in a[j][i]):\n f=1\n else:\n f=0\n break\n if(f==1):\n # print(i)\n count+=(n-(count//m))\nprint(count)"}, {"source_code": "n,m=map(int,input().split())\ns=\"\"\nfor i in range(n):\n s=s+input()\n#s=input()\nx=s.count('S')\nif x==m*n:\n print(0)\nelse:\n print(n*m-2*x)\n"}, {"source_code": "(r, c) = map(int, raw_input().strip().split())\n\nk = 0\ng = 0\nf = range(r)\nfor i in f:\n d = raw_input()\n if 'S' not in d:\n k = k + 1\n else:\n for j in range(len(d)):\n if d[j] == 'S':\n g = g+1\nprint r*c - (r-k)*g "}, {"source_code": "r,c=map(int,input().split())\narr=[];row=[];col=[]\ntotal=0\nfor i in range(r):\n arr.append(input())\nfor i in range(r):\n for j in range(c):\n if arr[i][j]=='S':\n row.append(i)\n col.append(j)\nfor i in range(r):\n if i not in row:\n total+=c\nfor j in range(c):\n if j not in col:\n total+=r-(total)//4\nprint(total)"}, {"source_code": "import sys\n\ndef data():\n return sys.stdin.readline().strip()\n \n \ndef sp(): return map(int, data().split()) \ndef l(): return list(sp())\ndef ssp(): return data().split()\ndef sl(): return list(ssp())\ntemp=l()\nr=temp[0]\nc=temp[1]\nt=[]\nnr=[]\nnc=[]\nfor i in range(r):\n\tt.append(list(data()))\n \nprint(t)\nfor i in range(r):\n for j in range(c):\n if t[i][j]=='S':\n nr.append(i)\n nc.append(j)\nsum=''\ncommon=(r-len(nr))*(c-len(nc))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif i not in nr and j not in nc:\n\t\t\tsum+=t[i][j]\n\t\t\t\n\nprint(len(sum)-common)\n\n"}, {"source_code": "r, c = map(int, input().split())\np = [input() for i in range(r)]\npos = []\nfor i in p:\n pos.append(i.find('S'))\ncount = 0\n\nfor i in range(r):\n if 'S' not in p[i]:\n count += c\n p[i] = p[i].replace('.', '', c)\n\ncopy = pos[:]\n\nif pos.count(-1) != len(pos) and pos.count(0) != len(pos):\n for i in range(pos.count(-1)):\n copy.remove(-1)\n count += (max(pos) - min(copy)) * (len(pos) - pos.count(-1))\n print(count)\nelif pos.count(0) == len(pos):\n count += r * (c-1)\n print(count)\nelse:\n print(count)\n\n"}, {"source_code": "r,c=map(int,input().split())\ncake=[]\ne=0\nr1=0\nst=[]\nfor i in range(r):\n s=input()\n cake.append(s)\nfor i in cake:\n if 'S' not in i:\n e+=c\n r1+=1\n else:\n j=i.find('S')\n st.append(j)\ns1=list(set(st))\ncl=c-len(s1)\ne1=(r-r1)*cl\nprint(e+e1)"}, {"source_code": "r, c = map(int, input().split())\n \ndef herota(): \n net = {}\n \n for i in range(r):\n l = input()\n for j in range(c):\n net[i, j] = l[j]\n #print(l[j], end='')\n #print()\n \n #print(net)\n \n strawbery = [x for x in net if net[x]=='S']\n #print(strawbery)\n if len(strawbery) == 1:\n result = r * c - 1\n print(result)\n return\n if len(strawbery) == 0:\n result = r * c\n print(result)\n return\n \n hor = {x for x, y in strawbery}\n vert = {x for y, x in strawbery}\n #print(hor)\n #print(vert)\n a = ((c - len(hor)) * r )\n b = ((r - len(vert)) * c )\n \n print(a+b-len(strawbery))\n \nherota()"}, {"source_code": "r, c = map(int, input().split())\na = []\nfor i in range(r):\n a.append(input())\n# print(a)\ntotal_s_str = 0\ntotal_s_column = 0\nfor i in range(r):\n s_str = 0\n for j in range(c):\n if a[i][j] != 'S':\n s_str += 1\n if s_str == c:\n total_s_str += c\n else:\n s_str = 0\n# print(total_s_str)\nfor j in range(c):\n s_column = 0\n for i in range(r):\n if a[i][j] != 'S':\n s_column += 1\n if s_column == r:\n total_s_column += r\n else:\n s_column = 0\n# print(total_s_column)\nif total_s_str == 0 or total_s_column == 0:\n print(max(total_s_column, total_s_str))\nelif total_s_str == total_s_column:\n print(total_s_str // 2 + total_s_str)\nelse:\n print((max(total_s_column, total_s_str) - min(total_s_column, total_s_str)) + max(total_s_column, total_s_str))\n\n\n"}, {"source_code": "l=list(map(int,input().split()))\nr=l[0]\nc=l[1]\na=0\nx=0\nb=0\ny=0\nlst=list()\nfor i in range(r):\n s=input()\n lst.append(s)\nfor i in lst:\n a=0\n for j in i:\n if j==\"s\":\n a=1\n break\n if a==0:\n x=x+c\nfor i in range(c):\n b=0\n for j in range(r):\n if lst[j][i]==\"s\":\n b=1\n break\n if b==0:\n y=y+r \nprint(x+y-(x*y)//(r*c)) \n "}, {"source_code": "r, c = map(int, input().split())\na = []\nfor i in range(r):\n a.append(input())\n# print(a)\ntotal_s_str = 0\ntotal_s_column = 0\nfor i in range(r):\n s_str = 0\n for j in range(c):\n if a[i][j] != 'S':\n s_str += 1\n if s_str == c:\n total_s_str += c\n else:\n s_str = 0\n# print(total_s_str)\nfor j in range(c):\n s_column = 0\n for i in range(r):\n if a[i][j] != 'S':\n s_column += 1\n if s_column == r:\n total_s_column += r\n else:\n s_column = 0\n# print(total_s_column)\nif total_s_str == 0:\n print(0)\nelse:\n print(total_s_str + (total_s_column - (total_s_str // c) * (total_s_column // r)))\n\n\n"}, {"source_code": "r, c = map(int, input().split())\nM = [input() for _ in range(r)]\nfor i in range(r):\n if 'S' not in M[i]:\n print((r - i) * c)\n break"}, {"source_code": "r,c=map(int,input().split())\na=[]\nrapple=0\ncapple=0\nfor i in range(r):\n n=input()\n flag=False\n for j in n:\n if j=='S':\n capple+=1\n flag=True\n if (flag):\n rapple+=1\n a.append(list(n))\nprint (r*c-(rapple*capple))"}, {"source_code": "r,c=map(int,raw_input().split())\ngrid=[[0 for i in range(0,c)]for j in range(0,r)]\nzuo=[]\ncnt=0\nfor i in range(0,r):\n s=raw_input()\n for j in range(0,len(s)):\n if s[j]=='S':\n grid[i][j]=1\n cnt=cnt+1\n zuo.append([i,j])\nfor i in range(0,len(zuo)):\n for j in range(i,len(zuo)):\n if zuo[i][0]!=zuo[j][0] and zuo[i][1]!=zuo[j][1]:\n #grid[zuo[j][0]][zuo[i][1]]=1\n #grid[zuo[i][0]][zuo[j][1]]=1\n cnt=cnt+2\nprint r*c-cnt"}, {"source_code": "import sys\n\ninf = float(\"inf\")\n# sys.setrecursionlimit(10000000)\n\n# abc='abcdefghijklmnopqrstuvwxyz'\n# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod, MOD = 1000000007, 998244353\n# vow=['a','e','i','o','u']\n# dx,dy=[-1,1,0,0],[0,0,1,-1]\n\n# import random\n# from collections import deque, Counter, OrderedDict,defaultdict\n# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n# from math import ceil,floor,log,sqrt,factorial\n# from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef input(): return sys.stdin.readline().strip()\n\nn,m = get_ints()\nmat = []\nfor i in range(n):\n mat.append(list(input()))\n\n# print(mat)\nvisited = [[0 for i in range(m)] for j in range(n)]\nfor i in range(n):\n for j in range(m):\n flag = 0\n for k in range(n):\n if mat[k][j]=='S':\n flag = 1\n for k in range(m):\n if mat[i][k]=='S':\n flag = 1\n if flag==1:\n continue\n else:\n for k in range(n):\n visited[k][j] = 1\n for k in range(m):\n visited[i][k] = 1\nans = 0\nfor i in visited:\n ans+=i.count(1)\nprint(ans)"}, {"source_code": "r, c = map(int, input().split())\n\nnet = {}\n\nfor i in range(r):\n l = input()\n for j in range(c):\n net[i, j] = l[j]\n print(l[j], end='')\n #print()\n\n#print(net)\n\nstrawbery = [x for x in net if net[x]=='S']\n#print(strawbery)\n\n\nhor = {x for x, y in strawbery}\nvert = {x for y, x in strawbery}\n#print(hor)\n#print(vert)\na = ((c - len(hor)) * r )\nb = ((r - len(vert)) * c )\nprint(a+b-len(strawbery))"}, {"source_code": "from math import comb\ndef solve():\n n,m=list(map(int,input().split()))\n l=list()\n for i in range(n):\n l.append(input())\n flag,row,col=1,0,0\n for i in range(n):\n for j in range(m):\n if(l[i][j]==\"S\"):\n flag=0\n if(flag):\n row+=1\n flag=1\n flag=1\n for i in range(m):\n for j in range(n):\n if(l[j][i]==\"S\"):\n flag=0\n if(flag):\n col+=1\n flag=1\n print(row*m+col*n-comb(max(row,col),min(row,col)))\nt=1\nfor _ in range(t):solve()\n"}, {"source_code": "r, c = map(int,input().split(' '))\ncount = 0\nA = []\nx = 0\n\nfor i in range(r):\n n = list(input())\n\n if 'S' not in n:\n x += 1\n\n A.append(n)\n\ny = []\np = 0\n\nfor i in range(c):\n for j in range(r):\n y.append(A[j][i])\n\n if 'S' not in y:\n p += 1\n\n y = []\n \ncount = r*c - (r-x)*c-p\n\nprint(count)"}, {"source_code": "r,c=map(int,input().strip().split())\nl=[]\nR=0\nC=0\nz=0\nC1=set()\nfor i in range(r):\n l.append(input())\n k=l[i].find('S',0)\n if k== -1:\n z+=1\n else:\n R+=1\n C1.add(k)\nC=len(C1)\nprint(r*c-R*C)"}, {"source_code": "l=list(map(int,input().split()))\nr=l[0]\nc=l[1]\na=0\nx=0\nb=0\ny=0\nlst=list()\nfor i in range(r):\n s=input()\n lst.append(s)\nfor i in lst:\n a=0\n for j in i:\n if j==\"s\":\n a=1\n break\n if a==0:\n x=x+c\nfor i in range(c):\n b=0\n for j in range(r):\n if lst[j][i]==\"s\":\n b=1\n break\n if b==0:\n y=y+r \nprint(x+y-(x*y)//(r*c)) \n "}, {"source_code": "n, m = map(int, input().split())\na = []\nfor i in range(n):\n b = list(input())\n a.append(b)\n\ns = 0\nz = 0\nfor i in range(n):\n if \"S\" not in a[i]:\n z = +1\n s += len(a[i])\n\nfor i in range(m):\n d = []\n for j in range(n):\n d.append(a[j][i])\n if \"S\" not in d:\n s += len(d)-z\n\nprint(s)"}, {"source_code": "r, c = map(int,input().split())\n\nj = []\n\nfor i in range(r):\n o = input().find('S')\n \n if o != -1:\n j.append(o)\n\nif len(j) == 2 :\n if j[0] == j[1] :\n print(r*c-2)\n else :\n print(r*c-4)\nelse : \n print(r*c-4)\n"}, {"source_code": "from __future__ import print_function\nimport sys\n\n\ndef main():\n\tvstup=(sys.stdin.readline()).split(\" \")\n\tr=int(vstup[0])\n\tc=int(vstup[1])\n\tchocolate=[]\n\n\tfor i in range(r):\n\t\tchocolate.append(list(sys.stdin.readline()))\n\tcount=c*r\n\n\tfor i in range(r):\n\t\tfor j in range(c):\n\t\t\tif chocolate[i][j]=='S':\n\t\t\t\tcount-=c\n\t\t\t\tbreak\n\ts=count/c\n\tprint(count, s)\n\n\tfor j in range(c):\n\t\tfor i in range(r):\n\t\t\tif chocolate[i][j]=='S':\n\t\t\t\tbreak\n\t\t\tif i==r-1 and chocolate[r-1][j]!='S':\n\t\t\t\tcount+=r-s\n\tprint(count)\n\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "r,c=map(int,input().split())\na=[]\nnr=0\nnc=0\nfor i in range(r):\n\tp=list(input())\n\ta.append(p)\n\tif \"S\" in p:\n\t\tnr+=1\n\t\tnc+=1\nprint((r-nr)*c+(c-nc)*r-max(r-nr,c-nc))"}, {"source_code": "import sys\n\ndef data():\n return sys.stdin.readline().strip()\n \n \ndef sp(): return map(int, data().split()) \ndef l(): return list(sp())\n\ntemp=l()\nr=temp[0]\nc=temp[1]\nt=[]\nnr=[]\nnc=[]\nfor i in range(r):\n\tt.append(list(data()))\nfor i in range(r):\n for j in range(c):\n if t[i][j]=='S':\n nr.append(i)\n nc.append(j)\n\ncommon=(r-len(nr))+(c-len(nc))\neat=(r-len(nr))*c+(c-len(nc))*r-common\nif eat<=0:\n print(0)\nelse:\n print(eat)\n\n\n\n"}, {"source_code": "r,c=map(int,input().split())\nstore=[]\nfor i in range(r):\n s=input()\n for j in range(c):\n if(s[j]=='S'):\n store.append((i,j))\nif(store==[]):\n print(r*c)\nelse:\n store = list(zip(*store))\n print(r * c - len(store[0]) * len(store[1]))"}, {"source_code": "r,c = map(int,raw_input().split())\nls = []\nfor i in range(r):\n temp = raw_input()\n ps = []\n for j in range(c):\n ps.append(temp[j])\n ls.append(ps)\n\nsum = r*c\n\np = 0\nq = 0\n\nfor i in range(r):\n check = False\n for j in range(c):\n if ls[i][j]=='S':\n check = True\n q+=1\n if check == True:\n p +=1\n\n\n\nprint(sum-p*q)"}, {"source_code": "l=list(map(int,input().split()))\nr=l[0]\nc=l[1]\na=0\nx=0\nb=0\ny=0\nlst=list()\nfor i in range(r):\n s=input()\n lst.append(s)\nfor i in lst:\n a=0\n for j in i:\n if j==\"s\":\n a=1\n break\n if a==0:\n x=x+c\nfor i in range(c):\n b=0\n for j in range(r):\n if lst[j][i]==\"s\":\n b=1\n break\n if b==0:\n y=y+r \nprint(x+y-(x*y)//12) \n "}, {"source_code": "__author__ = 'abbas'\nn = [int(x) for x in raw_input().split()]\nr,c = n[0],n[1]\ngrid = [[0 for x in range(c)] for y in range(r)]\ncount = r*c\nfor i in range(r):\n list = raw_input()\n for j in range(c):\n if list[j] == 'S':\n for x in range(r):\n if grid[x][j] != 1:\n grid[x][j] = 1\n count -= 1\n for y in range(c):\n if grid[i][y] != 1:\n grid[i][y] = 1\n count -= 1\nprint count"}, {"source_code": "r, c = map(int, input().split())\na = [input() for i in range(r)]\n\ncount = 0\npos = []\nz = 0\n\nfor i in range(r):\n if 'S' not in a[i]:\n count += c\nfor i in range(r):\n if 'S' in a[i]:\n z = 0\n for j in range(c):\n if a[i][j] == '.':\n pos.append(z)\n z += 1\n else:\n z += 1\n else:\n z = 0\n\nif len(pos) == 0:\n print(count)\nelse:\n c = [pos.count(i) for i in pos]\n p = c.count(max(c)) // max(c)\n print(count + 2 * p)\n"}, {"source_code": "r, c = map(int, input().split())\np = [input() for i in range(r)]\npos = []\nfor i in p:\n pos.append(i.find('S'))\ncount = 0\n\nfor i in range(r):\n if 'S' not in p[i]:\n count += c\n p[i] = p[i].replace('.', '', c)\n\ncopy = pos[:]\n\nif pos.count(-1) != len(pos) and pos.count(0) != len(pos):\n for i in range(pos.count(-1)):\n copy.remove(-1)\n count += (max(pos) - min(copy)) * (len(pos) - pos.count(-1))\n print(count)\nelif pos.count(0) == len(pos):\n count += r * (c-1)\n print(count)\nelse:\n print(count)\n\n"}, {"source_code": "r_c=raw_input()\nr_c=r_c.split(' ')\nr=int(r_c[0])\nc=int(r_c[1])\nminus=0\nresult=0\ntorts=[]\nfor i in range(r):\n tort=raw_input()\n torts.append(tort)\nfor i in torts:\n if 'S' in i:\n minus+=1\n result+=c\nfor i in range(r):\n curr_result=0\n for j in range(c):\n if torts[i][j]=='S':\n break\n curr_result+=1\n if curr_result==r:\n result+=c-minus\nprint result"}, {"source_code": "r,c=map(int,input().split())\nl=[]\nfor i in range(r):\n\tw=list(input())\n\tl.append(w)\nm=[]\nfor i in range(r):\n\tfor j in range(c):\n\t\tif l[i][j]!=\"S\":\n\t\t\tt=[i,j]\n\t\t\tm.append(t)\na=[]\nq=[]\nf=max(c,r)\nfor i in range(f):\n\tcount=0\n\tplus=0\n\tfor j in range(len(m)):\n\t\tif m[j][0]==i:\n\t\t\tcount+=1\n\t\tif m[j][1]==i:\n\t\t\tplus+=1\n\ta.append(count)\n\tq.append(plus)\ny=a.count(c)\nu=q.count(r)\no=(y*c)+(u*r)-max(y,u)\nprint(o)"}, {"source_code": "r,c=map(int,input().split())\nmm=r*c\nmat=[]\nfor i in range(r):\n s=input()\n mat.append(s)\nans=0\nrr=0;cc=0;s=0\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n rr+=1\n break\nfor i in range(c):\n for j in range(r):\n if mat[j][i]=='S':\n cc+=1\n break\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n s+=1\nr-=rr\nc-=cc\nif rr==0 or cc==0:\n print(mm-s)\nelse:\n print(mm-r*c-s)\n"}, {"source_code": "r,c=map(int,input().split())\nmm=r*c\nmat=[]\nfor i in range(r):\n s=input()\n mat.append(s)\nans=0\nrr=0;cc=0;s=0\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n rr+=1\n break\nfor i in range(c):\n for j in range(r):\n if mat[j][i]=='S':\n cc+=1\n break\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n s+=1\nr-=rr\nc-=cc\nif rr==0 or cc==0:\n print(mm-s)\nelse:\n print(mm-r*c-s)\n"}, {"source_code": "#!/usr/bin/python\n\nr,c = map(int,raw_input().split())\ncount = 0\ncake = []\n\nfor i in range(r):\n cake.append(raw_input())\n\nindexr = [i for i in range(r) for j in cake[i] if j == 'S']\ncount = (r - len(indexr))* c\n\nindexc = [i for i in range(c) for j in range(r) if cake[j][i] == 'S']\ncount = count + ((c - len(indexc))*r)\n\ncount = count - (r-len(indexr)) * (c - len(indexc))\nif count < 0:\n print \"0\"\nelse:\n print count\n"}, {"source_code": "r,c = map(int,input().split())\n\ncount = 0\nfor i in range(r) :\n s = input()\n count += s.count('S')\nout = (r*c) - (2*count)\nif out < 0 :\n out = 0\nprint(out)"}, {"source_code": "l=lambda :map(int,input().split())\nr,c=l()\nk=[input() for _ in \" \"*r]\nn=0\np,q=r,c\nfor i in range(p):\n a=k[i].count('.')\n if a==c:\n r-=1\n n+=c\nt=list(zip(*k))\nfor i in range(q):\n a = t[i].count('.')\n if a==r:\n n+=r\nprint(n)"}, {"source_code": "r, c = map(int, input().split())\n \ndef herota(): \n net = {}\n \n for i in range(r):\n l = input()\n for j in range(c):\n net[i, j] = l[j]\n #print(l[j], end='')\n #print()\n \n #print(net)\n \n strawbery = [x for x in net if net[x]=='S']\n #print(strawbery)\n if len(strawbery) == 1:\n result = r * c - 1\n if len(strawbery) == 0:\n result = r * c\n \n \n hor = {x for x, y in strawbery}\n vert = {x for y, x in strawbery}\n #print(hor)\n #print(vert)\n a = ((c - len(hor)) * r )\n b = ((r - len(vert)) * c )\n \n print(a+b-len(strawbery))\n \nherota()"}, {"source_code": "r, c = map(int,input().split())\n\nj = []\n\nfor i in range(r):\n o = input().find('S')\n \n if o != -1:\n j.append(o)\n\nif len(j) == 2 :\n if j[0] == j[1] :\n print(r*c-2)\n else :\n print(r*c-4)\nelif len(j) == 0 : \n print(r*c)\nelse :\n print(r*c-4)"}, {"source_code": "r,c=list(map(int,input().split()))\ne,l=[],[]\ncount=0\nfor i in range(r):\n\tl=list(input())\n\tif \"S\" not in l:\n\t\tcount+=1\n\telse:\n\t\te.append(l.index(\"S\"))\ne=set(e)\nprint((count*c)+(((c-len(e))*r)-((c-len(e))*count)))"}, {"source_code": "r, c = map(int, input().split())\ntort = []\nschet = 0\npodschet_f = 0\npodschet = 0\nstolb=0\nstrok=0\nfor i in range(r):\n tort.append(list(str(input())))\n\nfor i in range(r):\n for j in range(c):\n if tort[i][j] != 'S':\n podschet_f += 1\n else:\n podschet_f = 0\n if podschet_f==c:\n schet += podschet_f\n podschet_f=0\n strok+=1\n else:\n podschet_f=0\n\nfor j in range(c):\n for i in range(r):\n if tort[i][j] != 'S':\n podschet += 1\n else:\n podschet = 0\n if podschet==r:\n schet += podschet\n podschet=0\n stolb+=1\n else:\n podschet=0\n\nif strok>stolb and stolb>=1:\n print(schet-strok)\nelif stolb>strok and strok>=1:\n print(schet-stolb)\nelse:\n print(schet)"}, {"source_code": "r,c=map(int,input().split())\nmm=r*c\nmat=[]\nfor i in range(r):\n s=input()\n mat.append(s)\nans=0\nrr=0;cc=0;s=0\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n rr+=1\n break\nfor i in range(c):\n for j in range(r):\n if mat[j][i]=='S':\n cc+=1\n break\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n s+=1\nr-=rr\nc-=cc\nif rr==0 or cc==0:\n print(mm-s)\nelse:\n print(mm-r*c-s)\n"}, {"source_code": "l=lambda :map(int,input().split())\nr,c=l()\nk=[input() for _ in \" \"*r]\nn=0\np,q=r,c\nfor i in range(p):\n a=k[i].count('.')\n if a==c:\n r-=1\n n+=c\nt=list(zip(*k))\nfor i in range(q):\n a = t[i].count('.')\n if a==r:\n n+=r\nprint(n)"}, {"source_code": "r,c=map(int,input().split())\nmm=r*c\nmat=[]\nfor i in range(r):\n s=input()\n mat.append(s)\nans=0\nrr=0;cc=0;s=0\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n rr+=1\n break\nfor i in range(c):\n for j in range(r):\n if mat[j][i]=='S':\n cc+=1\n break\nfor i in range(r):\n for j in range(c):\n if mat[i][j]=='S':\n s+=1\nr-=rr\nc-=cc\nprint(rr,cc)\nif s==0:\n print(r*c)\nelse:\n print(mm-rr*cc)\n"}, {"source_code": "r,c=map(int,input().split())\nstore=[]\nfor i in range(r):\n s=input()\n for j in range(c):\n if(s[j]=='S'):\n store.append((i,j))\nif(store==[]):\n print(r*c)\nelse:\n store = list(zip(*store))\n k=r * c - len(store[0]) * len(store[1])\n print([k,0][k<0])"}, {"source_code": "def cake(n, m, grid):\n c = 0\n new = []\n for i in range(n):\n if 'S' not in grid[i]:\n c += m\n continue\n new.append(grid[i])\n\n for i in range(len(new)):\n for j in range(m):\n if new[i][j] == 'S':\n break\n c += len(new)\n\n return c\n\nlst = [int(x) for x in input().split()]\nn = lst[0]\nm = lst[1]\n\ngrid = []\nfor i in range(n):\n s = input()\n temp = []\n temp.extend(s)\n grid.append(temp)\n\nprint(grid)\n\nprint(cake(n, m, grid))"}, {"source_code": "r, c = map(int, input().split())\na = []\nfor i in range(r):\n a.append(input())\ns = 0\nfor i in range(r):\n for j in range(c):\n if a[i][j] == 'S':\n s += 1\nprint((2 * (r * c) - (s * r + s * c)) - s)"}, {"source_code": "r, c = map(int, input().split())\n\nnet = {}\n\nfor i in range(r):\n l = input()\n for j in range(c):\n net[i, j] = l[j]\n #print(l[j], end='')\n #print()\n\n#print(net)\n\nstrawbery = [x for x in net if net[x]=='S']\n#print(strawbery)\n\n\nhor = {x for x, y in strawbery}\nvert = {x for y, x in strawbery}\n#print(hor)\n#print(vert)\na = ((c - len(hor)) * r )\nb = ((r - len(vert)) * c )\nprint(a+b-len(strawbery))"}, {"source_code": "r, c = map(int,input().split())\n\nj = []\n\nfor i in range(r):\n o = input().find('S')\n \n if o != -1:\n j.append(o)\n\nif len(j) == 2 :\n if j[0] == j[1] :\n print(r*c-2)\n else :\n print(r*c-4)\nelif len(j) == 0 : \n print(r*c)\nelse :\n print(r*c-4)"}, {"source_code": "r,c=map(int,input().split())\nA,B=[],[]\nfor i in range(r):\n R=list(input())\n while('S'in R):\n I=R.index('S')\n B+=[I]\n A+=[i]\n R[I]='.'\nprint((r*c)-sum(set(A))*sum(set(B))) \n \n "}, {"source_code": "n,m = map(int,input().split())\nrow,col = 0,0\nl=[]\nfor i in range(n):\n\tl.append(input())\n\nfor i in range(n):\n\tfor j in range(m):\n\t\tif l[i][j] == 'S':\n\t\t\t# print('i','j',i,j)\n\t\t\trow+=1\n\nfor j in range(m):\n\tfor i in range(n):\n\t\tif l[i][j] == 'S':\n\t\t\tcol+=1\n\nprint(n*m - row*col)\n"}, {"source_code": "import sys\nmy_file = sys.stdin\n#my_file = open(\"input.txt\", \"r\")\nline = [int(i) for i in my_file.readline().strip(\"\\n\").split()]\nr, c = line[0], line[1]\ntable = my_file.read().split()\nres = 0\nfor line in table:\n if \"S\" not in line:\n res += len(line)\n table.remove(line)\n r -= 1\nfor row in range(r):\n for col in range(c):\n for row1 in range(r):\n if \"S\" in table[row1][col]:\n break\n else:\n res += len(table[row][col])\nprint(res)"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output1.out\",'w')\nn,m=map(int,input().split())\na=[]\nc=0\nfor i in range(n):\n\ts=input()\n\tif 'S' in s:\n\t\tc+=1\n\t\tc+=s.count(\"S\")\nprint(max(n*m-c,0))\t\t "}, {"source_code": "r, c = map(int, input().split())\ntort = []\nschet = 0\npodschet_f = 0\npodschet = 0\nstolb=0\nstrok=0\nfor i in range(r):\n tort.append(list(str(input())))\n\nfor i in range(r):\n for j in range(c):\n if tort[i][j] != 'S':\n podschet_f += 1\n else:\n podschet_f = 0\n if podschet_f==c:\n schet += podschet_f\n podschet_f=0\n strok+=1\n else:\n podschet_f=0\n\nfor j in range(c):\n for i in range(r):\n if tort[i][j] != 'S':\n podschet += 1\n else:\n podschet = 0\n if podschet==r:\n schet += podschet\n podschet=0\n stolb+=1\n else:\n podschet=0\n\nif strok>stolb and stolb>=1:\n print(schet-strok)\nelif stolb>strok and strok>=1:\n print(schet-stolb)\nelse:\n print(schet)"}, {"source_code": "import sys\n\ndef data():\n return sys.stdin.readline().strip()\n \n \ndef sp(): return map(int, data().split()) \ndef l(): return list(sp())\ndef ssp(): return data().split()\ndef sl(): return list(ssp())\ntemp=l()\nr=temp[0]\nc=temp[1]\nt=[]\nnr=[]\nnc=[]\nfor i in range(r):\n\tt.append(list(data()))\n \nprint(t)\nfor i in range(r):\n for j in range(c):\n if t[i][j]=='S':\n nr.append(i)\n nc.append(j)\nsum=''\ncommon=(r-len(nr))*(c-len(nc))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif i not in nr and j not in nc:\n\t\t\tsum+=t[i][j]\n\t\t\t\n\nprint(len(sum)-common)\n\n"}], "src_uid": "ebaf7d89c623d006a6f1ffd025892102"} {"source_code": "rd = lambda : map(int, raw_input().split())\nrep1, rep2 = rd()\ns1 = raw_input()\ns2 = raw_input()\nfor ch in s2:\n if not ch in s1:\n print 0\n exit()\n\nd = {}\ni = 0\nj = 0\nc1 = 1\nc2 = 0\ncicle_key = 0, 0\nwhile True:\n while s1[i] != s2[j]: \n i += 1\n if i == len(s1):\n i = 0\n c1 += 1\n if c1 > rep1:\n print c2 / rep2\n exit()\n if j == len(s2) - 1: c2 += 1\n if (i, j) in d: \n cicle_key = (i, j)\n break\n d[(i, j)] = (c1, c2)\n i += 1\n j += 1\n if j == len(s2): j = 0\n if i == len(s1):\n i = 0\n c1 += 1\n\nrep1 -= c1\ncicles_left = rep1 / (c1 - d[cicle_key][0])\nc2 += cicles_left * (c2 - d[cicle_key][1])\nrep1 -= cicles_left * (c1 - d[cicle_key][0])\n\ni, j = cicle_key\nc1 = 0\nwhile True:\n i += 1\n j += 1\n if j == len(s2): j = 0\n if i == len(s1):\n i = 0\n c1 += 1\n while s1[i] != s2[j]: \n i += 1\n if i == len(s1):\n i = 0\n c1 += 1\n if c1 > rep1:\n print c2 / rep2\n exit()\n if j == len(s2) - 1: c2 += 1\n", "positive_code": [{"source_code": "b, d = map(int,raw_input().strip().split())\na = raw_input()\nc = raw_input()\nla = len(a)\nlc = len(c)\n\nsa = set(a)\nbad = False\nfor ch in c:\n if ch not in sa:\n bad = True\n break\n\nif bad:\n print 0\nelse:\n def get_next(i):\n j = 0\n cross = 0\n while j < lc:\n if a[i] == c[j]:\n j += 1\n if i == 0:\n cross += 1\n i += 1\n if i >= la:\n i = 0\n return cross, i\n\n nex = {}\n for i in xrange(la):\n nex[i] = get_next(i)\n\n #print nex\n tym = {}\n stp = {}\n t = 0\n ans = 0\n ct = 0\n while t not in tym:\n# print t, ans, ct\n tym[t] = ans\n stp[t] = ct\n x, t = nex[t]\n if ans + x > b:\n break\n ct += 1\n ans += x\n #print tym\n\n if ans + x <= b:\n dtym = ans - tym[t]\n dstp = ct - stp[t]\n #print 'dtym', dtym\n #print 'dstp', dstp\n #while ans + dtym <= b:\n # ans += dtym\n # ct += dstp\n #ans + q * dtym <= b\n q = (b - ans) / dtym\n ans += q * dtym\n ct += q * dstp\n\n #print 'ans is', ans\n while True:\n x, t = nex[t]\n if ans + x > b:\n break\n ct += 1\n ans += x\n\n #print ct, ans\n\n print ct / d\n"}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nlen_a = len(a)\nc = sys.stdin.readline().split()[0]\nlen_c = len(c)\n\n#print len_a\n#print len_c\ndef find_g(a, key):\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n starts = dict()\n start_round = dict()\n rounds_so_far = 0\n i = 0\n\n for char in c:\n if char not in a:\n print 0\n return\n\n if (len_c == 1):\n print a.count(c) * b / d\n return \n\n for j in xrange(len_a*b):\n if a[j%len_a] == c[i%len_c]:\n if ((i+1) % len_c == 0):\n rounds_so_far += 1\n if (i % len_c == 0):\n if (starts.get(j%len_a) == None):\n starts[j%len_a] = j\n start_round[j] = rounds_so_far\n else:\n break\n i += 1\n else:\n print rounds_so_far / d\n return \n \n cycle_start = starts[j%len_a]\n #print cycle_start \n cycle_end = j\n cycle_char = cycle_end - cycle_start\n #print \"cycle_end is \" + str(cycle_end)\n rounds_one_cycle = rounds_so_far - start_round[cycle_start]\n cycles = (len_a*b - cycle_start) / cycle_char\n rounds_between = rounds_one_cycle * cycles\n #print \"rounds_between is \" + str(rounds_between)\n rounds_before = start_round[cycle_start] \n #print \"rounds_before is \" + str(rounds_before)\n rounds_after = 0\n \n p = 0 \n for k in xrange(cycle_start+cycles*cycle_char, len_a*b):\n if a[k%len_a] == c[p%len_c]:\n if ((p+1) % len_c) == 0:\n rounds_after += 1\n p += 1\n #print \"end\" \n #print rounds_after\n print (rounds_before+rounds_between+rounds_after) / d\n \nsolve()\n"}, {"source_code": "\n\nfrom itertools import repeat,chain\nfrom fractions import gcd\n\ndef eternal(c,d, n = None):\n\n\n while True:\n\n yield chain.from_iterable(repeat(c,d))\n\n\n\n \n\n\ndef cyclic_array(arr):\n\n n = len(arr)\n def cyclar(i):\n\n return arr[i % n]\n\n return cyclar\ndef find_repeat(enum,q_r_gen, a_n):\n\n ac_count =0\n a_count = 0\n remainders ={}\n tempq=''\n tempa = ''\n for q,q_r in enumerate(q_r_gen):\n\n tempq=''\n for c_c in q_r:\n tempq= tempq +c_c\n for a_count,a_c in enum:\n if a_c == c_c:\n tempa = tempa +a_c\n ac_count+=1\n break\n #print len(tempa),len(tempq)\n if (a_count % a_n) in remainders:\n\n #print tempq[:20],tempa[:20]\n break\n else:\n\n remainders[(a_count % a_n)]=(a_count,q)\n\n repeat_length = a_count - remainders[a_count % a_n][0]\n q_count = q-remainders[a_count % a_n][1]\n\n return remainders[a_count % a_n][0],repeat_length,q_count\n \n\n\n \ndef main(a,b,c,d):\n \n\n \n #print a, c\n\n\n a_r = chain.from_iterable(repeat(a,b))\n\n #print \"\".join(chain.from_iterable(repeat(a,b)))\n\n\n enum =enumerate(a_r)\n\n q_r_gen = eternal(c,d)\n\n i = 0\n flag = True\n\n\n if len(a) > len(c)*d:\n multiplier =1\n start,repeat_length,q_count = find_repeat(enum,q_r_gen, len(a))\n\n else:\n multiplier =((len(c)*d)//len(a))+1\n #print \"Multi\",multiplier\n enum2 = enumerate(chain.from_iterable(repeat(a*multiplier,b//multiplier)))\n start,repeat_length,q_count =find_repeat(enum2,q_r_gen, multiplier*len(a))\n \n if repeat_length >0:\n advance_n = (((len(a)*multiplier)*(b//multiplier))//repeat_length)-1\n advance = repeat_length * advance_n\n\n sofar = q_count * advance_n\n else:\n advance_n =0\n advance = 0\n sofar = 0\n\n #print advance_n,advance, repeat_length, len(a)*b, sofar , len(c)*d\n \n ca = cyclic_array(a)\n\n ra = iter(range(advance,len(a)*b))\n\n ac_count =0\n for q_r in q_r_gen:\n for i,c_c in enumerate(q_r):\n\n flag = False\n for a_count in ra:\n #print a_count\n\n if ca(a_count) == c_c:\n ac_count+=1\n flag = True\n break\n \n if not flag:\n break\n\n \n print sofar + (ac_count // (len(c)*d))\n\n\n \nif __name__ == \"__main__\":\n b,d = [int(s) for s in (raw_input()).split()]\n\n a = raw_input()\n\n c = raw_input()\n\n aset = set(a)\n cset = set(c)\n\n if cset.difference(aset):\n print 0\n\n elif a == c:\n\n print b // d\n \n else:\n \n main(a,b,c,d)\n "}, {"source_code": "import sys\ndebug = False\ndef solve(a, b, c, d):\n for i in c:\n if i not in a:\n return 0\n #w=[a,b]\n #q=[c,d]\n #[q,p] in w\n #p?\n ind1 = 0\n ind2 = 0\n cnt1 = 1\n cnt2 = 0\n phases = []\n phases2 = []\n \n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n if ind2 == len(c):\n #word finished!\n cnt2 += 1\n ind2 = 0\n #check phase\n if ind1 in phases:\n #period!\n cnt1_, cnt2_ = phases2[phases.index(ind1)]\n step1 = cnt1 - cnt1_\n step2 = cnt2 - cnt2_\n cnt = (b-cnt1)/step1\n cnt1 += step1 * cnt\n cnt2 += step2 * cnt\n phases = []\n phases2 = []\n #save phase\n phases.append(ind1)\n phases2.append([cnt1, cnt2])\n\n ind1 += 1\n if ind1 == len(a):\n cnt1 += 1\n ind1 = 0\n if cnt1 > b:\n return cnt2 / d\n #answ \n val2 = phases2[-1]\n val1 = phases2[phases.index(ind1)]\n\n step1 = val2[0] - val1[0]\n step2 = val2[1] - val1[1]\n \n if debug:\n print str(val1[0]) + \" -- > \" + str(val1[1])\n print str(val2[0]) + \" -- > \" + str(val2[1])\n\n res = step2 * b / (step1 * d)\n res = (b - val2[0]) * step2 / (step1 * d) + val2[1]\n if res < 0:\n return 0\n else:\n return res\n\nif not debug:\n b, d = map(int, sys.stdin.readline().split())\n \n a = sys.stdin.readline().split()[0]\n c = sys.stdin.readline().split()[0]\n print str(solve(a, b, c, d))\nelse:\n vals = []\n vals.append([841, 7, 'qjqhrksmvedtqldrqgchhsofokfcovut' ,'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc', 5])\n vals.append([933, 5, 'abaabdcbbabacbdddadbbb', 'babbadbaaadbbbbaabbaabccbbdbadbbbbbbdbcbdbaaadbdbdbbbbdcbbdcbdaadbd', 15])\n vals.append([875, 10, 'hjeaiemqfliohlicmhndhbfdmlmcnjjgbg', 'hojqhmbgjlfmlliimlhahfeihgmhhhnbmebhgnfhgmhfjqhmlnnddgmqldelnhebi', 4])\n vals.append([320672, 1, 'wyyojuothwmlvrglfzdzdbtubxuoffvncrswsaznmoijoi', 'ttvlvzxcvczuagwzgbfuwmmt', 40084])\n vals.append([5608475, 1, 'gbagadghfaedhddefgbehbbdedefbaaeddachgebhbcgahfdchffhbhfahhdegdhdfbccgefhcdhhcdfgdgfhcdffaacch', 'fgfadaaecdgabeahcacadcbfhhe', 1869491])\n vals.append([1263204, 1, 'dcbabceabbaebddaaecbddaceaedacddadadcbbadbdccdecdacdcaadbceeddccbceaade', 'abddbccbdca', 1894805])\n vals.append([100, 1, 'bca', 'abc', 99])\n vals.append([541, 9, 'bxhwcmunbdxcatppdsw', 'shbppncwbnsxxnxunwsbncpdchcbcspdcppdchmbbcuapphpdxbpcswcxpxpdscxpddbcppdxhpxbuxxdbpdpuudb', 1])\n vals.append([9447267, 1, 'cbdcbdbcdacbcabddbaabcbacbabcaacbabaccddcbbdbbaddcbcbaaadc', 'bbbbdbcbbbdbdbcdcacccbdcadadbacbcccc', 4723633])\n vals.append([1181362, 3, 'fckmaalkicfakhcbiglkekajmadjkj', 'zfkjkjgkmjhfkackkhhjalgkkclcklabggk', 0])\n for val in vals:\n b, d, a, c, answer = val\n res = solve(a, b, c, d)\n if res == answer:\n print '++++++++++++++++++++++++++++'\n pass\n else:\n print '----------------------------'\n print val\n print res\n print '----------------------------'\n sys.stdin.readline()\n\n"}], "negative_code": [{"source_code": "import sys\n\ndef solve(a, b, c, d):\n #w=[a,b]\n #q=[c,d]\n #[q,p] in w\n #p?\n ind1 = 0\n ind2 = 0\n cnt1 = 0\n phases = []\n phases2 = []\n ahtung = False\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n\n if ind2 == len(c):\n ind2 = 0\n #contained. lets check syn\n if ind1 in phases:\n #period!\n #print \"period!\"\n phases.append(ind1)\n phases2.append(cnt1)\n break\n phases.append(ind1)\n phases2.append(cnt1)\n\n ind1 += 1\n if ind1 == len(a):\n ahtung = (ind2!=0)\n ind1 = 0\n cnt1 += 1\n\n if cnt1 >= b:\n #all length of a reached\n return len(phases)/d\n\n #print phases\n #print phases2\n \n val = phases.pop(-1)\n cnt2 = len(phases)\n ind = len(phases) - phases[::-1].index(val) -1\n cnt2 -= ind\n #print \"second in period = \" + str(cnt2)\n per1 = phases2[-1] - phases2[ind]\n #print \"first in period = \" + str(per1)\n\n #print ahtung\n #if phases2[ind] == 0 or phases2[ind]==phases2[ind-1]:\n # ahtung = False\n #else:\n # ahtung = True\n #print ahtung\n res = cnt2 * b\n if ahtung:\n res -= 1\n res /= (per1 * d)\n #print res\n if res<0:\n res = 0\n return res\n\nb, d = map(int, sys.stdin.readline().split())\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\nif False:\n b, d = 841, 7\n a = 'qjqhrksmvedtqldrqgchhsofokfcovut'\n c = 'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc'\n\n b, d = 10,3\n a = 'abab'\n c = 'bab'\n\n\n\n\nprint solve(a, b, c, d)\n"}, {"source_code": "import sys\n\ndef solve(a, b, c, d):\n #w=[a,b]\n #q=[c,d]\n #[q,p] in w\n #p?\n ind1 = 0\n ind2 = 0\n cnt1 = 0\n phases = []\n phases2 = []\n ahtung = False\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n\n if ind2 == len(c):\n ind2 = 0\n #contained. lets check syn\n if ind1 in phases:\n #period!\n #print \"period!\"\n phases.append(ind1)\n phases2.append(cnt1)\n break\n phases.append(ind1)\n phases2.append(cnt1)\n\n ind1 += 1\n if ind1 == len(a):\n ahtung = (ind2!=0)\n ind1 = 0\n cnt1 += 1\n\n if cnt1 >= b:\n #all length of a reached\n return len(phases)/d\n\n #print phases\n #print phases2\n \n val = phases.pop(-1)\n cnt2 = len(phases)\n ind = len(phases) - phases[::-1].index(val) -1\n cnt2 -= ind\n #print \"second in period = \" + str(cnt2)\n per1 = phases2[-1] - phases2[ind]\n #print \"first in period = \" + str(per1)\n\n if phases2[ind] == 0:\n ahtung = (phases2[-1] > 1)\n else:\n ahtung = (phases2[-1]-phases2[ind]>phases2[ind])\n #print ahtung\n #if phases2[ind] == 0 or phases2[ind]==phases2[ind-1]:\n # ahtung = False\n #else:\n # ahtung = True\n #print ahtung\n res = cnt2 * b\n\n if ahtung:\n res -= 1\n res /= (per1 * d)\n #print res\n if res<0:\n res = 0\n return res\n\nb, d = map(int, sys.stdin.readline().split())\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\nif True and False:\n b, d = 841, 7\n a = 'qjqhrksmvedtqldrqgchhsofokfcovut'\n c = 'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc'\n\n b, d = 10,3\n a = 'abab'\n c = 'bab'\n\n b, d = 1263204, 1\n a = 'dcbabceabbaebddaaecbddaceaedacddadadcbbadbdccdecdacdcaadbceeddccbceaade'\n c = 'abddbccbdca'\n\n\n\n\nprint solve(a, b, c, d)\n"}, {"source_code": "import sys\n\ndef solve(a, b, c, d):\n #w=[a,b]\n #q=[c,d]\n #[q,p] in w\n #p?\n ind1 = 0\n ind2 = 0\n cnt1 = 1\n cnt2 = 0\n phases = []\n phases2 = []\n\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n if ind2 == len(c):\n #word finished!\n cnt2 += 1\n ind2 = 0\n #check phase\n if ind1 in phases:\n #period!\n phases.append(ind1)\n phases2.append([cnt1, cnt2])\n\n break\n \n #save phase\n phases.append(ind1)\n phases2.append([cnt1, cnt2])\n\n ind1 += 1\n if ind1 == len(a):\n cnt1 += 1\n ind1 = 0\n if cnt1 > b:\n return cnt2 / d\n \n val2 = phases2[-1]\n val1 = phases2[phases.index(ind1)]\n\n step1 = val2[0] - val1[0]\n step2 = val2[1] - val1[1]\n \n delta = -val2[0]*step2/step1+val2[1]\n if False:\n print str(val1[0]) + \" -- > \" + str(val1[1])\n print str(val2[0]) + \" -- > \" + str(val2[1])\n print \"delta = \" + str(delta)\n res = step2 * b / (step1 * d) + delta\n if res < 0:\n return 0\n else:\n return res\n\nif True:\n b, d = map(int, sys.stdin.readline().split())\n \n a = sys.stdin.readline().split()[0]\n c = sys.stdin.readline().split()[0]\n print str(solve(a, b, c, d))\nelse:\n vals = []\n vals.append([841, 7, 'qjqhrksmvedtqldrqgchhsofokfcovut' ,'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc', 5])\n vals.append([933, 5, 'abaabdcbbabacbdddadbbb', 'babbadbaaadbbbbaabbaabccbbdbadbbbbbbdbcbdbaaadbdbdbbbbdcbbdcbdaadbd', 15])\n vals.append([875, 10, 'hjeaiemqfliohlicmhndhbfdmlmcnjjgbg', 'hojqhmbgjlfmlliimlhahfeihgmhhhnbmebhgnfhgmhfjqhmlnnddgmqldelnhebi', 4])\n vals.append([320672, 1, 'wyyojuothwmlvrglfzdzdbtubxuoffvncrswsaznmoijoi', 'ttvlvzxcvczuagwzgbfuwmmt', 40084])\n vals.append([5608475, 1, 'gbagadghfaedhddefgbehbbdedefbaaeddachgebhbcgahfdchffhbhfahhdegdhdfbccgefhcdhhcdfgdgfhcdffaacch', 'fgfadaaecdgabeahcacadcbfhhe', 1869491])\n vals.append([1263204, 1, 'dcbabceabbaebddaaecbddaceaedacddadadcbbadbdccdecdacdcaadbceeddccbceaade', 'abddbccbdca', 1894805])\n vals.append([100, 1, 'bca', 'abc', 99])\n for val in vals:\n b, d, a, c, answer = val\n res = solve(a, b, c, d)\n if res == answer:\n print '++++++++++++++++++++++++++++'\n pass\n else:\n print '----------------------------'\n print val\n print res\n print '----------------------------'\n sys.stdin.readline()\n\n"}, {"source_code": "import sys\n\ndef solve(a, b, c, d):\n #w=[a,b]\n #q=[c,d]\n #[q,p] in w\n #p?\n ind1 = 0\n ind2 = 0\n cnt1 = 0\n phases = []\n phases2 = []\n ahtung = False\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n\n if ind2 == len(c):\n ind2 = 0\n #contained. lets check syn\n if ind1 in phases:\n #period!\n #print \"period!\"\n phases.append(ind1)\n phases2.append(cnt1)\n break\n phases.append(ind1)\n phases2.append(cnt1)\n\n ind1 += 1\n if ind1 == len(a):\n ahtung = (ind2!=0)\n ind1 = 0\n cnt1 += 1\n\n if cnt1 >= b:\n #all length of a reached\n return len(phases)/d\n\n #print phases\n\n \n val = phases.pop(-1)\n cnt2 = len(phases)\n ind = len(phases) - phases[::-1].index(val) -1\n cnt2 -= ind\n #print \"second in period = \" + str(cnt2)\n per1 = phases2[-1] - phases2[ind]\n #print \"first in period = \" + str(per1)\n #print ahtung\n \n res = cnt2 * b / (per1 * d)\n if ahtung:\n res =- 1\n if res<0:\n res = 0\n return res\n\nb, d = map(int, sys.stdin.readline().split())\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\n#b, d = 10, 3\n#a = 'bzabza'\n#c = 'abz'\nprint solve(a, b, c, d)\n"}, {"source_code": "import sys\n\ndef solve(a, b, c, d):\n #w=[a,b]\n #q=[c,d]\n #[q,p] in w\n #p?\n ind1 = 0\n ind2 = 0\n cnt1 = 0\n phases = []\n phases2 = []\n ahtung = False\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n\n if ind2 == len(c):\n ind2 = 0\n #contained. lets check syn\n if ind1 in phases:\n #period!\n #print \"period!\"\n phases.append(ind1)\n phases2.append(cnt1)\n break\n phases.append(ind1)\n phases2.append(cnt1)\n\n ind1 += 1\n if ind1 == len(a):\n ahtung = (ind2!=0)\n ind1 = 0\n cnt1 += 1\n\n if cnt1 >= b:\n #all length of a reached\n return len(phases)/d\n\n #print phases\n #print phases2\n \n val = phases.pop(-1)\n cnt2 = len(phases)\n ind = len(phases) - phases[::-1].index(val) -1\n cnt2 -= ind\n #print \"second in period = \" + str(cnt2)\n per1 = phases2[-1] - phases2[ind]\n #print \"first in period = \" + str(per1)\n\n #print ahtung\n #if phases2[ind] == 0 or phases2[ind]==phases2[ind-1]:\n # ahtung = False\n #else:\n # ahtung = True\n #print ahtung\n res = cnt2 * b\n\n if ahtung and False:\n res -= 1\n res /= (per1 * d)\n #print res\n if res<0:\n res = 0\n return res\n\nb, d = map(int, sys.stdin.readline().split())\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\nif False:\n b, d = 841, 7\n a = 'qjqhrksmvedtqldrqgchhsofokfcovut'\n c = 'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc'\n\n b, d = 10,3\n a = 'abab'\n c = 'bab'\n\n\n\n\nprint solve(a, b, c, d)\n"}, {"source_code": "\n\nfrom itertools import repeat,chain\nfrom fractions import gcd\n\ndef eternal(c,d, n = None):\n\n\n while True:\n\n yield chain.from_iterable(repeat(c,d))\n\n\n\n \n\n\ndef cyclic_array(arr):\n\n n = len(arr)\n def cyclar(i):\n\n return arr[i % n]\n\n return cyclar\n\ndef main():\n b,d = [int(s) for s in (raw_input()).split()]\n\n a = raw_input()\n\n c = raw_input()\n\n #print a, c\n\n\n a_r = chain.from_iterable(repeat(a,b))\n\n #print \"\".join(chain.from_iterable(repeat(a,b)))\n\n q_r_gen = eternal(c,d)\n\n\n i = 0\n flag = True\n\n remainders ={}\n a_count = 0\n\n ac_count =0\n\n enum =enumerate(a_r)\n\n for q,q_r in enumerate(q_r_gen):\n\n for c_c in q_r:\n for a_count,a_c in enum:\n if a_c == c_c:\n ac_count+=1\n break\n if (a_count % len(a)) in remainders:\n\n break\n else:\n\n remainders[(a_count % len(a))]=a_count\n\n #print remainders\n\n \n repeat_length = a_count - remainders[a_count % len(a)]\n \n if repeat_length >0:\n advance_n = ((len(a)*b)//repeat_length)\n advance = repeat_length * advance_n\n\n sofar = (repeat_length / (len(c)*d)) * advance_n\n else:\n advance = 0\n sofar = 0\n\n #print advance_n,advance, repeat_length, len(a)*b, sofar\n \n ca = cyclic_array(a)\n\n ra = iter(range(advance,len(a)*b))\n\n ac_count =0\n for q_r in q_r_gen:\n for i,c_c in enumerate(q_r):\n\n flag = False\n for a_count in ra:\n\n if ca(a_count) == c_c:\n ac_count+=1\n flag = True\n break\n \n if not flag:\n break\n\n \n print sofar + (ac_count // (len(c)*d))\n\n\n \n\n\nmain()\n "}, {"source_code": "\n\nfrom itertools import repeat,chain\nfrom fractions import gcd\n\ndef eternal(c,d, n = None):\n\n\n while True:\n\n yield chain.from_iterable(repeat(c,d))\n\n\n\n \n\n\ndef cyclic_array(arr):\n\n n = len(arr)\n def cyclar(i):\n\n return arr[i % n]\n\n return cyclar\ndef find_repeat(enum,q_r_gen, a_n):\n\n ac_count =0\n a_count = 0\n remainders ={}\n \n for q,q_r in enumerate(q_r_gen):\n\n for c_c in q_r:\n for a_count,a_c in enum:\n if a_c == c_c:\n ac_count+=1\n break\n if (a_count % a_n) in remainders:\n\n print \"found\", a_count, remainders\n break\n else:\n\n remainders[(a_count % a_n)]=a_count\n\n repeat_length = a_count - remainders[a_count % a_n]\n\n return repeat_length\n \n\n\n \ndef main():\n b,d = [int(s) for s in (raw_input()).split()]\n\n a = raw_input()\n\n c = raw_input()\n\n #print a, c\n\n\n a_r = chain.from_iterable(repeat(a,b))\n\n #print \"\".join(chain.from_iterable(repeat(a,b)))\n\n\n enum =enumerate(a_r)\n\n q_r_gen = eternal(c,d)\n\n i = 0\n flag = True\n\n\n if len(a) > len(c):\n repeat_length = find_repeat(enum,q_r_gen, len(a))\n\n else:\n repeat_length = 0\n \n if repeat_length >0:\n advance_n = ((len(a)*b)//repeat_length)\n advance = repeat_length * advance_n\n\n sofar = (repeat_length / (len(c)*d)) * advance_n\n else:\n advance_n =0\n advance = 0\n sofar = 0\n\n #print advance_n,advance, repeat_length, len(a)*b, sofar\n \n ca = cyclic_array(a)\n\n ra = iter(range(advance,len(a)*b))\n\n ac_count =0\n for q_r in q_r_gen:\n for i,c_c in enumerate(q_r):\n\n flag = False\n for a_count in ra:\n\n if ca(a_count) == c_c:\n ac_count+=1\n flag = True\n break\n \n if not flag:\n break\n\n \n print sofar + (ac_count // (len(c)*d))\n\n\n \n\n\nmain()\n "}, {"source_code": "\n\nfrom itertools import repeat,chain\nfrom fractions import gcd\n\ndef eternal(c,d, n = None):\n\n\n while True:\n\n yield chain.from_iterable(repeat(c,d))\n\n\n\n \n\n\ndef cyclic_array(arr):\n\n n = len(arr)\n def cyclar(i):\n\n return arr[i % n]\n\n return cyclar\ndef find_repeat(enum,q_r_gen, a_n):\n\n ac_count =0\n a_count = 0\n remainders ={}\n tempq=''\n tempa = ''\n for q,q_r in enumerate(q_r_gen):\n\n tempq=''\n for c_c in q_r:\n tempq= tempq +c_c\n for a_count,a_c in enum:\n if a_c == c_c:\n tempa = tempa +a_c\n ac_count+=1\n break\n #print len(tempa),len(tempq)\n if (a_count % a_n) in remainders:\n\n #print tempq[:20],tempa[:20]\n break\n else:\n\n remainders[(a_count % a_n)]=(a_count,q)\n\n repeat_length = a_count - remainders[a_count % a_n][0]\n q_count = q-remainders[a_count % a_n][1]\n\n return remainders[a_count % a_n][0],repeat_length,q_count\n \n\n\n \ndef main():\n b,d = [int(s) for s in (raw_input()).split()]\n\n a = raw_input()\n\n c = raw_input()\n\n #print a, c\n\n\n a_r = chain.from_iterable(repeat(a,b))\n\n #print \"\".join(chain.from_iterable(repeat(a,b)))\n\n\n enum =enumerate(a_r)\n\n q_r_gen = eternal(c,d)\n\n i = 0\n flag = True\n\n\n if len(a) > len(c)*d:\n multiplier =1\n start,repeat_length,q_count = find_repeat(enum,q_r_gen, len(a))\n\n else:\n multiplier =((len(c)*d)//len(a))+1\n #print \"Multi\",multiplier\n enum2 = enumerate(chain.from_iterable(repeat(a*multiplier,b//multiplier)))\n start,repeat_length,q_count =find_repeat(enum2,q_r_gen, multiplier*len(a))\n \n if repeat_length >0:\n advance_n = (((len(a)*multiplier)*(b//multiplier))//repeat_length)\n advance = repeat_length * advance_n \n\n sofar = q_count * advance_n\n else:\n advance_n =0\n advance = 0\n sofar = 0\n\n #print advance_n,advance, repeat_length, len(a)*b, sofar , len(c)*d\n \n ca = cyclic_array(a)\n\n ra = iter(range(advance,len(a)*b))\n\n ac_count =0\n for q_r in q_r_gen:\n for i,c_c in enumerate(q_r):\n\n flag = False\n for a_count in ra:\n #print a_count\n\n if ca(a_count) == c_c:\n ac_count+=1\n flag = True\n break\n \n if not flag:\n break\n\n \n print sofar + (ac_count // (len(c)*d))\n\n\n \n\n\nmain()\n "}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nlen_a = len(a)\nc = sys.stdin.readline().split()[0]\nlen_c = len(c)\n\n#print a\n#print c\ndef find_g(a, key):\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n starts = dict()\n start_round = dict()\n rounds_so_far = 0\n i = 0\n\n for char in c:\n if char not in a:\n print 0\n return\n\n for j in xrange(len_a*b):\n if a[j%len_a] == c[i%len_c]:\n if ((i+1) % len_c == 0):\n rounds_so_far += 1\n if (i % len_c == 0):\n if (starts.get(j%len_a) == None):\n starts[j%len_a] = j\n start_round[j] = rounds_so_far\n else:\n break\n i += 1\n else:\n print rounds_so_far / d\n return \n \n cycle_start = starts[j%len_a]\n #print cycle_start \n cycle_end = j\n cycle_char = cycle_end - cycle_start\n #print cycle_end\n rounds_one_cycle = rounds_so_far - start_round[cycle_start]\n cycles = (len_a*b - cycle_start) / cycle_char\n rounds_between = rounds_one_cycle * cycles\n #print \"rounds_between is \" + str(rounds_between)\n rounds_before = start_round[cycle_start] \n rounds_after = 0\n \n p = 0 \n for k in xrange(cycle_start+cycles*cycle_char, len_a*b):\n if a[k%len_a] == c[p%len_c]:\n if ((p+1) % len_c) == 0:\n rounds_after += 1\n #print \"end\" \n print (rounds_before+rounds_between+rounds_after) / d\n \nsolve()\n"}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nlen_a = len(a)\nc = sys.stdin.readline().split()[0]\nlen_c = len(c)\n\n#print a\n#print c\ndef find_g(a, key):\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n starts = dict()\n start_round = dict()\n rounds_so_far = 0\n i = 0\n\n for char in c:\n if char not in a:\n print 0\n\n for j in xrange(len_a*b):\n if a[j%len_a] == c[i%len_c]:\n if ((i+1) % len_c == 0):\n rounds_so_far += 1\n if (i % len_c == 0):\n if (starts.get(j%len_a) == None):\n starts[j%len_a] = j\n start_round[j] = rounds_so_far\n else:\n break\n i += 1\n else:\n print rounds_so_far / d\n return \n \n cycle_start = starts[j%len_a]\n #print cycle_start \n cycle_end = j\n cycle_char = cycle_end - cycle_start\n #print cycle_end\n rounds_one_cycle = rounds_so_far - start_round[cycle_start]\n cycles = (len_a*b - (i+1)) / cycle_char\n rounds_between = rounds_one_cycle * cycles\n #print \"rounds_between is \" + str(rounds_between)\n rounds_before = start_round[cycle_start] \n rounds_after = 0\n \n p = 0 \n for k in xrange(cycle_start+cycles*cycle_char, len_a*b):\n if a[k%len_a] == c[p%len_c]:\n if ((p+1) % len_c) == 0:\n rounds_after += 1\n #print \"end\" \n print (rounds_before+rounds_between+rounds_after) / d\n \nsolve()\n"}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nlen_a = len(a)\nc = sys.stdin.readline().split()[0]\nlen_c = len(c)\n\n#print a\n#print c\ndef find_g(a, key):\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n starts = dict()\n start_round = dict()\n rounds_so_far = 0\n i = 0\n\n for char in c:\n if char not in a:\n print 0\n return\n\n for j in xrange(len_a*b):\n if a[j%len_a] == c[i%len_c]:\n if ((i+1) % len_c == 0):\n rounds_so_far += 1\n if (i % len_c == 0):\n if (starts.get(j%len_a) == None):\n starts[j%len_a] = j\n start_round[j] = rounds_so_far\n else:\n break\n i += 1\n else:\n print rounds_so_far / d\n return \n \n cycle_start = starts[j%len_a]\n #print cycle_start \n cycle_end = j\n cycle_char = cycle_end - cycle_start\n #print cycle_end\n rounds_one_cycle = rounds_so_far - start_round[cycle_start]\n cycles = (len_a*b - (i+1)) / cycle_char\n rounds_between = rounds_one_cycle * cycles\n #print \"rounds_between is \" + str(rounds_between)\n rounds_before = start_round[cycle_start] \n rounds_after = 0\n \n p = 0 \n for k in xrange(cycle_start+cycles*cycle_char, len_a*b):\n if a[k%len_a] == c[p%len_c]:\n if ((p+1) % len_c) == 0:\n rounds_after += 1\n #print \"end\" \n print (rounds_before+rounds_between+rounds_after) / d\n \nsolve()\n"}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nlen_a = len(a)\nc = sys.stdin.readline().split()[0]\nlen_c = len(c)\n\n#print len_a\n#print len_c\ndef find_g(a, key):\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n starts = dict()\n start_round = dict()\n rounds_so_far = 0\n i = 0\n\n for char in c:\n if char not in a:\n print 0\n return\n if (len_c == 1):\n print a.count(c) * b\n return \n\n for j in xrange(len_a*b):\n if a[j%len_a] == c[i%len_c]:\n if ((i+1) % len_c == 0):\n rounds_so_far += 1\n if (i % len_c == 0):\n if (starts.get(j%len_a) == None):\n starts[j%len_a] = j\n start_round[j] = rounds_so_far\n else:\n break\n i += 1\n else:\n print rounds_so_far / d\n return \n \n cycle_start = starts[j%len_a]\n print cycle_start \n cycle_end = j\n cycle_char = cycle_end - cycle_start\n print \"cycle_end is \" + str(cycle_end)\n rounds_one_cycle = rounds_so_far - start_round[cycle_start]\n cycles = (len_a*b - cycle_start) / cycle_char\n rounds_between = rounds_one_cycle * cycles\n print \"rounds_between is \" + str(rounds_between)\n rounds_before = start_round[cycle_start] \n print \"rounds_before is \" + str(rounds_before)\n rounds_after = 0\n \n p = 0 \n for k in xrange(cycle_start+cycles*cycle_char, len_a*b):\n if a[k%len_a] == c[p%len_c]:\n if ((p+1) % len_c) == 0:\n rounds_after += 1\n p += 1\n #print \"end\" \n print rounds_after\n print (rounds_before+rounds_between+rounds_after) / d\n \nsolve()\n"}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\n#print a\n#print c\ndef find_g(a, key):\n '''Find smallest item greater thank key.\n '''\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n # process a to form a hash map : char -> indexs of char\n dic = dict()\n i = 0 \n len_a = len(a)\n\n for char in a:\n if (dic.get(char) != None):\n dic[char].append(i)\n else:\n dic[char] = [i]\n i += 1\n \n #printD(dic)\n # process c now\n i = 0\n last_index = -1\n len_c = len(c)\n term = 0\n indexes = []\n \n #print \"len_c is \" + str(len_c)\n for i in xrange(len_c):\n char = c[i]\n if (dic.get(char) == None):\n print 0\n if (last_index < 0):\n index = find_g(dic.get(char), last_index)\n else:\n index = find_g(dic.get(char), last_index % len_a) \n if (index == -1):\n term += 1\n index = find_g(dic.get(char), -1)\n last_index = term * len_a + index\n if (last_index >= len_a * b):\n print 0\n return\n indexes.append(last_index)\n \n single_cycle = last_index + 1\n if (single_cycle < len_a):\n freq = 0\n # see how many can be found in one a\n for i in xrange(len_a):\n if a[i] == c[0]:\n if a[i:i+len_c] == c:\n freq += 1\n print b * freq\n return\n elif (single_cycle % len_a == 0):\n print len_a * b / (single_cycle * d)\n return\n else:\n one_round = single_cycle / len_a + 1\n rounds = one_round + (one_round - 1) * d\n print 1 + (b - rounds) / (rounds - 1) \n return\n\nsolve()\n"}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nlen_a = len(a)\nc = sys.stdin.readline().split()[0]\nlen_c = len(c)\n\n#print len_a\n#print len_c\ndef find_g(a, key):\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n starts = dict()\n start_round = dict()\n rounds_so_far = 0\n i = 0\n\n for char in c:\n if char not in a:\n print 0\n return\n\n for j in xrange(len_a*b):\n if a[j%len_a] == c[i%len_c]:\n if ((i+1) % len_c == 0):\n rounds_so_far += 1\n if (i % len_c == 0):\n if (starts.get(j%len_a) == None):\n starts[j%len_a] = j\n start_round[j] = rounds_so_far\n else:\n break\n i += 1\n else:\n print rounds_so_far / d\n return \n \n cycle_start = starts[j%len_a]\n #print cycle_start \n cycle_end = j\n cycle_char = cycle_end - cycle_start\n #print \"cycle_end is \" + str(cycle_end)\n rounds_one_cycle = rounds_so_far - start_round[cycle_start]\n cycles = (len_a*b - cycle_start) / cycle_char\n rounds_between = rounds_one_cycle * cycles\n #print \"rounds_between is \" + str(rounds_between)\n rounds_before = start_round[cycle_start] \n rounds_after = 0\n \n p = 0 \n for k in xrange(cycle_start+cycles*cycle_char, len_a*b):\n if a[k%len_a] == c[p%len_c]:\n if ((p+1) % len_c) == 0:\n rounds_after += 1\n p += 1\n #print \"end\" \n print (rounds_before+rounds_between+rounds_after) / d\n \nsolve()\n"}, {"source_code": "import sys\nfrom bisect import *\n\ninputs = sys.stdin.readline().split()\nb = int(inputs[0])\nd = int(inputs[1])\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\n#print a\n#print c\ndef find_g(a, key):\n '''Find smallest item greater thank key.\n '''\n i = bisect_right(a, key)\n if i == len(a):\n return -1\n return a[i]\n\ndef printD(myDic):\n for key in myDic.keys():\n print key\n print myDic[key]\n print\n \ndef solve():\n # process a to form a hash map : char -> indexs of char\n dic = dict()\n i = 0 \n len_a = len(a)\n\n for char in a:\n if (dic.get(char) != None):\n dic[char].append(i)\n else:\n dic[char] = [i]\n i += 1\n \n #printD(dic)\n # process c now\n i = 0\n last_index = -1\n len_c = len(c)\n term = 0\n indexes = []\n \n #print \"len_c is \" + str(len_c)\n for i in xrange(len_c):\n char = c[i]\n if (dic.get(char) == None):\n print 0\n if (last_index < 0):\n index = find_g(dic.get(char), last_index)\n else:\n index = find_g(dic.get(char), last_index % len_a) \n if (index == -1):\n term += 1\n index = find_g(dic.get(char), -1)\n last_index = term * len_a + index\n if (last_index >= len_a * b):\n print 0\n return\n indexes.append(last_index)\n \n single_cycle = last_index + 1\n if (single_cycle % len_a == 0):\n print len_a * b / (single_cycle * d)\n else:\n one_round = single_cycle % len_a\n rounds = one_round * d + 1\n print 1 + (b - rounds) / (rounds - 1)\n \nsolve()\n\n"}, {"source_code": "rd = lambda : map(int, raw_input().split())\nrep1, rep2 = rd()\ns1 = raw_input()\ns2 = raw_input()\nfor ch in s2:\n if not ch in s1:\n print 0\n exit()\n\nd = {}\ni = 0\nj = 0\nc1 = 1\nc2 = 0\ncicle_key = 0, 0\nwhile True:\n while s1[i] != s2[j]: \n i += 1\n if i == len(s1):\n i = 0\n c1 += 1\n if c1 > rep1:\n print c2 / rep2\n exit()\n if j == len(s2) - 1: c2 += 1\n if (i, j) in d: \n cicle_key = (i, j)\n break\n d[(i, j)] = (c1, c2)\n i += 1\n j += 1\n if j == len(s2): j = 0\n if i == len(s1):\n i = 0\n c1 += 1\n\nrep1 -= d[cicle_key][0]\ncicles_left = rep1 / (c1 - d[cicle_key][0])\nc2 += cicles_left * (c2 - d[cicle_key][1])\nrep1 -= cicles_left * (c1 - d[cicle_key][0])\n\ni, j = cicle_key\nc1 = 0\nwhile True:\n i += 1\n j += 1\n if j == len(s2): j = 0\n if i == len(s1):\n i = 0\n c1 += 1\n while s1[i] != s2[j]: \n i += 1\n if i == len(s1):\n i = 0\n c1 += 1\n if c1 > rep1:\n print c2 / rep2\n exit()\n if j == len(s2) - 1: c2 += 1\n"}, {"source_code": "rd = lambda : map(int, raw_input().split())\nrep1, rep2 = rd()\ns1 = raw_input()\ns2 = raw_input()\nfor ch in s2:\n if not ch in s1:\n print 0\n exit()\n\nd = {}\ni = 0\nj = 0\nc1 = 1\nc2 = 0\ncicle_key = 0, 0\nwhile True:\n while s1[i] != s2[j]: \n i += 1\n if i == len(s1):\n i = 0\n c1 += 1\n if c1 > rep1:\n print c2 / rep2\n exit()\n if j == len(s2) - 1: c2 += 1\n print (i, j), '->', (c1, c2)\n if (i, j) in d: \n cicle_key = (i, j)\n break\n d[(i, j)] = (c1, c2)\n i += 1\n j += 1\n if j == len(s2): j = 0\n if i == len(s1):\n i = 0\n c1 += 1\n\nrep1 -= d[cicle_key][0]\ncicles_left = rep1 / (c1 - d[cicle_key][0])\nc2 += cicles_left * (c2 - d[cicle_key][1])\nrep1 -= cicles_left * (c1 - d[cicle_key][0])\n\ni, j = cicle_key\nc1 = 0\nwhile True:\n i += 1\n j += 1\n if j == len(s2): j = 0\n if i == len(s1):\n i = 0\n c1 += 1\n while s1[i] != s2[j]: \n i += 1\n if i == len(s1):\n i = 0\n c1 += 1\n if c1 > rep1:\n print c2 / rep2\n exit()\n if j == len(s2) - 1: c2 += 1\n"}], "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa"} {"source_code": "n,m = input().split()\nn,m = int(n),int(m)\nq = n-m+1\np = n-m \n\nh = q*p\nMax = h>>1\na = int(n/m)\nsum1 = (a*(a-1))/2*(m-n%m)\nsum2 = (a+1)*(a)/2*(n%m)\nMin = int(sum1+sum2)\nprint(Min, Max)\n", "positive_code": [{"source_code": "n,m=map(int,input().split(' '))\nc=n-m\nkmax = (c*(c+1))//2\n\nc = n//m\nd1 = n%m\nd2 = m-d1\nkmin = d1*(c*(c+1))//2 + d2*(c*(c-1))//2\n\nprint(kmin,kmax)"}, {"source_code": "n,m=map(int,input().split())\nq=n//m\nrem=n%m\nans=int((((n-m+1))*(n-m)))\nkmax=(ans//2)\nif q>1:\n kmin=int(rem*(((q+1)*(q))/2)+(m-rem)*(((q)*(q-1))/2))\nelse:\n kmin=rem\nprint(kmin,kmax)"}, {"source_code": "from decimal import *\n\n\ndef pair(n):\n return Decimal(n / 2) * (n - 1)\n\n\nnm = [int(i) for i in input().split()]\nprint(int(((nm[1] - nm[0] % nm[1]) * pair(nm[0] // nm[1])) + ((nm[0] % nm[1]) * (pair(nm[0] // nm[1] + 1)))),\n int(pair(nm[0] - (nm[1] - 1))))\n"}, {"source_code": "def sumTillN(N):\n return (N*(N-1))>>1\nN,M = map(int,input().split())\nMax = sumTillN(N - (M-1))\nNumber = int(N//M)\nSome = N%M\nX = Some * sumTillN(Number+1)\nY = (M - Some) * sumTillN(Number)\nMin = X+Y\nprint(Min,Max)\n\n"}, {"source_code": "(n,m)=map(int,raw_input().split())\n\n\"\"\"\"\nFinding Minimum\nn=total people, m = teams\nDivide (n-n%m) players equally into each team.\nn%m players left will go to teams\nTherefore, m-n%m teams of n/m players and n%m teams of n/m+1 players\nTeams of m//n people : m-1\n\tConnections = (m-1) * combi(m//n,2)\nTeams of m//n + m % n people : 1\n\tConnections = 1 * combi(m//n+m%n,2)\n\"\"\"\n\ndef combi(n):\n\tif n==1:\n\t\treturn 0\n\telse:\n\t\treturn n*(n-1)/2\n\nmin_pairs = (m-n%m) * combi(n//m) + n%m * combi(n//m+1)\n#print m-1,'teams of',n//m,'players and',1,'team of',n//m+n%m\n\"\"\"\nFinding Maximum\nn=total people, m = teams\nSingle teams = m-1\nMembers in last team = n-(m-1)\n\"\"\"\n\nmax_pairs = 1 * combi(n-(m-1))\n\nprint min_pairs,max_pairs"}, {"source_code": "###Codeforces problem 478B###\n\nn, m = map(int, raw_input().split())\n\nkmax = (n - m + 1) * (n - m) / 2\nx = n / m\ny = n % m\nkmin = y * (x + 1) * x / 2 + (m - y) * x * (x - 1) / 2\nif x == 1:\n pass\nprint kmin, kmax"}, {"source_code": "def nCr(n):\n return n*(n-1)/2\n\ndef main():\n n,m = map(int,raw_input().split());\n val,min_pairs,max_pairs,comb = 0,0,0,0\n \n each = n/m\n r = n%m\n \n comb = nCr(each)\n \n if((each*m) != n):\n min_pairs = nCr(each+1)*r + comb*(m-r)\n \n else:\n min_pairs = comb*m\n \n \n temp = n-(m-1)\n if(temp != 1):\n max_pairs = nCr(temp);\n else:\n max_pairs = 0\n \n print(min_pairs),\n print(max_pairs)\n\nmain()"}, {"source_code": "def nCr(n):\n return (n-1)*n//2\n\nn, m = list(map(int, input().split()))\na, b = divmod(n,m)\nres_min = b*nCr(a+1)\nif a >= 2:\n res_min += (m-b)*nCr(a)\nres_max = nCr(n - (m-1))\nprint(res_min, res_max)"}, {"source_code": "import math\n\ndef ncr(a):\n return a * (a-1) / 2\n\nn, m = [int(x) for x in raw_input().split()]\n\nmn = 0\nif n > m:\n mn = ncr(n/m) * m + (n%m)*(n/m)\n \nmx = 0\nif n > 1:\n mx = ncr(n+1-m)\n\nprint mn, mx\n"}, {"source_code": "def ncr(n1):\n f=(n1*(n1-1))//2\n return f\n \n\nn,m=input().split(\" \")\nn=int(n)\nm=int(m)\nc=n-m\n\nMax=ncr(c+1)\ns=n//m\ns1=n%m\nd=m*s*(s-1)//2\nd1=s1*(s)\nSum=d+d1\n\n\n\nprint(Sum,Max)\n\n\n\n "}, {"source_code": "n,m = map(int,raw_input().split())\nresult = []\nmax_friends= (n - m + 1) * (n - m) / 2\n\nmin_friends, avg_in_team = 0, n / m\nmin_friends += ((avg_in_team + 1) * avg_in_team / 2) * (n % m)\nmin_friends += avg_in_team * (avg_in_team - 1) / 2 * (m - (n % m))\n\nresult.append(min_friends)\nresult.append(max_friends)\n\nprint \" \".join(map(str,result))"}, {"source_code": "\n#########\t\t\t##\t## ## \t #### ##### ## # ## #\t\t##\n\t#\t\t\t # #\t# # # #\t\t #\t #\t#\t# # # # # # #\t # #\n\t#\t\t\t # #\t# ### #\t #\t\t#\t# # # # # # #\t # #\n\t#\t\t\t #####\t#\t#\t#\t # ###\t#\t# # # # # # # #####\n\t#\t\t\t# #\t#\t\t#\t # # #\t#\t# #\t# # #\t # # # # \n######### \t # # \t#\t\t#\t\t##### #\t##### #\t ## #\t ## # #\n\n\"\"\"\n\nPPPPPPP RRRRRRR\t\t OOOO\t VV VV EEEEEEEEEE\nPPPPPPPP RRRRRRRR OOOOOO VV VV\t EE\nPPPPPPPPP RRRRRRRRR OOOOOOOO VV VV\t EE\nPPPPPPPP RRRRRRRR OOOOOOOO VV VV \t EEEEEE\nPPPPPPP RRRRRRR OOOOOOOO VV VV EEEEEEE\nPP \t\t RRRR\t\t\t OOOOOOOO VV VV EEEEEE\nPP\t\t\t RR RR OOOOOOOO VV VV EE\nPP\t\t\t RR RR OOOOOO VV VV EE\nPP\t\t\t RR RR OOOO VVVV EEEEEEEEEE\n\n\"\"\"\n\n\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nimport sys\ninput = sys.stdin.readline\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0, hi = None):\n if hi == None:\n hi = len(a);\n while lo < hi:\n mid = (lo+hi)//2;\n if a[mid] < x:\n lo = mid+1;\n else:\n hi = mid;\n return lo;\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\n\nfrom bisect import bisect_left\n\ndef solve():\n\tn, m = map(int, input().split())\n\tr = n % m\n\tq = n // m\n\tif m > 1:\n\t\t# print(q, r, nCr(1, 2))\n\t\tprint(((q * (q - 1)) // 2) * (m - r) + (((q + 1) * q) // 2) * r, (n - m + 1) * (n - m) // 2)\n\telse:\n\t\tprint(nCr(q, 2), nCr(q, 2))\n\nif __name__ == '__main__':\n\tfor _ in range(1):\n\t\tsolve()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n "}, {"source_code": "n, m = map(int, raw_input().split())\ntemp = n/m\nprint (temp * (temp -1))/2*m + (0 if n%m == 0 else temp*(n%m)),\ntemp = n - m + 1\nprint (temp * (temp -1))/2"}, {"source_code": "def see(a,b) :\n if a < b :\n return 0\n elif a == b :\n return 1\n else :\n return a * (a-1) / 2\nn,m = map(int,raw_input().split())\nrem = n % m\na = n / m\nkmax = see(n-m+1,2)\nkmin = rem * see(a+1,2) + (m-rem) * see(a,2)\nprint str(kmin) + ' ' + str(kmax)\n"}, {"source_code": "def friends_in_team(amount):\n if amount <= 1:\n return 0\n return (amount * (amount - 1)) // 2\n\n\nn, m = (int(x) for x in input().split())\na = friends_in_team(n // m) * (m - n % m)\na += friends_in_team(n // m + 1) * (n % m)\nb = friends_in_team(n - m + 1)\nprint('{} {}'.format(min(a, b), max(a, b)))\n"}, {"source_code": "n,m=map(int,raw_input().split())\na=n/m\nprint m*a*(a-1)/2+a*(n%m),(n-m)*(n-m+1)/2\n"}, {"source_code": "def fact(x):\n return ((x+1)*x)//2\nn, m = map(int, input().split())\nkmax = fact(n-m)\nif (m == 1):\n kmin = kmax\nelif (n%m != 0):\n kmin = (m-n%m)*fact(n//m-1) + (n%m)*fact(n//m)\nelse:\n kmin = m*fact(n//m-1)\nprint(kmin, kmax)\n"}, {"source_code": "def C(n):\n if(n>=1):\n return (n*(n-1))/2\n else:\n return 0\nn1,m1=raw_input().split()\nn=int(n1);m=int(m1)\na=C(n-m+1)\nq=n/m;r=n%m\nb=(r*C(q+1))+(m-r)*C(q)\nprint b,a\n"}, {"source_code": "def nCr2(n):\n if n < 2: return 0\n return n * (n-1) / 2\ndef inp(): return map(long, raw_input().split())\nn,m = inp()\nmx = long(nCr2(n-m+1))\nmn = long((n%m) * nCr2(n//m + 1) + (m-n%m) * nCr2(n//m))\nprint mn,mx"}, {"source_code": "if __name__ == '__main__':\n\tn,m = map(int,raw_input().split())\n\teq = n/m\n\trem = n%m\n\tkmin=(((eq+1)*eq)/2)*rem\n\tkmin+=(((eq-1)*eq)/2)*(m-rem)\n\tt1 = n-m+1\n\tkmax = t1*(t1-1)\n\tkmax /= 2\n\tprint kmin,kmax"}, {"source_code": "def comb(h):\n\tif h%2==0:\n\t\tk=(int((h)/2))*(h-1)\n\telse:\n\t\tk=(int((h-1)/2))*(h)\n\tk=int(k)\n\treturn k\ng=input()\nn,m=[int(x) for x in g.split()]\nkmax=comb(n-m+1)\nif n-m<m:\n\tkmin=n-m\nelse:\n\tmini=int(n/m)\n\tt=n-(mini*m)\n\tif t==0:\n\t\tkmin=m*comb(mini)\n\telse:\n\t\trem=m-t\n\t\tkmin=t*comb(mini+1)+rem*comb(mini)\t\nprint(kmin,kmax)"}, {"source_code": "n,m=map(int,input().split())\nmaxi=(n-m+1)*(n-m)//2\nk=n//m\nmini=k*(k-1)//2\nmini*=m\nmini+=k*(n%m)\nprint(mini,maxi)"}, {"source_code": "def comb(a):\n return (a*(a-1))/2\np,t=raw_input().split()\np=int(p)\nt=int(t)\nmx=comb(p-t+1)\nif(p%t==0):\n mn=t*comb(p/t);\nelse:\n x=p%t;\n i=p/t;\n mn=x*comb(i+1)+(t-x)*comb(i);\nprint mn,mx"}, {"source_code": "import math\nn,m=map(int,input().strip().split(' '))\nf=lambda x: ((x-1)*x)>>1\namax=f(n-m+1)\namin=f(math.ceil(n/m))*(n%m) + f(math.trunc(n/m))*(m-n%m)\nprint(amin,amax)\n"}, {"source_code": "n,m=map(int,input().split())\nnm=n//m\n#print(m*nm*(nm-1)//2+n%m*nm,(n-m+1)*(n-m)//2)\nprint(m*nm*(nm-1)//2+(n-m*nm)*nm,(n-m+1)*(n-m)//2)\n#print((n-m*nm)*nm)\n#print(n%m*nm)"}, {"source_code": "n,m=map(int,raw_input().split())\na,b=n/m,n-m+1\nprint m*(a*(a-1))/2+a*(n%m),(b*(b-1))/2"}, {"source_code": "def sumupto(z):\n\treturn int(z*(z-1)/2)\n\nn,m=map(int,input().split())\nprint(m*sumupto(n//m)+n%m*(n//m),(n-m+1)*(n-m)//2)\n\n\n"}, {"source_code": "def xc2(x):\n t=x*(x-1)/2\n return t\nn,m=raw_input().split()\nn=int(n)\nm=int(m)\nq=n/m\nr=n%m\nmax=xc2(n-m+1)\nmin=(m-r)*xc2(q)+r*xc2(q+1)\nprint min,max\n"}, {"source_code": "import math\n\ndef get_pairs(n):\n return n*(n-1)/2\n\ndef get_small(n_m):\n n = n_m[0]\n m = n_m[1]\n if n % m != 0:\n at_least = n/m\n remain = n%m\n count_fewer = (m-remain)*get_pairs(at_least)\n count_more = remain*get_pairs(at_least+1)\n return count_fewer + count_more\n else:\n each_bucket = n / m\n return m*(each_bucket*(each_bucket-1)/2)\n\n\ndef get_big(n_m):\n n = n_m[0]\n m = n_m[1]\n largest_team = n - (m-1)\n return largest_team*(largest_team-1)/2\n\nn_m = map(int, raw_input().split())\nsmallest = get_small(n_m)\nbiggest = get_big(n_m)\nprint \"%s %s\" % (int(smallest), int(biggest))\n"}, {"source_code": "n,m = map(int, raw_input().split(\" \"))\n\ndef nC2(n):\n return (n*(n-1))/2\n\nmaX = n - m + 1\nkmax = 0\n\nif maX > 1:\n kmax = nC2(maX)\n\nkmin = 0\n\nif n%m == 0:\n kmin = m*nC2((n/m))\nelse:\n if(n/m > 1):\n kmin = (m-(n%m))*nC2(n/m)\n kmin += (n%m)*(nC2((n/m)+1))\n\nprint kmin, kmax\n"}, {"source_code": "n,k=map(int,input().split())\nnk=n//k\nprint((nk*(nk-1))//2*k+n%k*nk,((n-k+1)*(n-k))//2)"}, {"source_code": "import math\nparter,group = [int(x) for x in input().split()]\nans = 0\nm2 = parter - (group-1)\nm_min = parter//group\ngr_max = parter%group\nm_max = m_min+1\ngr_min = group-gr_max\n\nans = int(m_min*(m_min-1)*gr_min//2+m_max*(m_max-1)*gr_max//2)\n\nprint(str(ans)+' '+str(int(m2*(m2-1)//2)))"}, {"source_code": "#!/usr/bin/env python3\n\nfrom math import factorial\nfrom math import ceil\nfrom functools import lru_cache\n\ndef _kmin(n, m):\n if m == 1: return comb(n, 2)\n c = ceil(n / m)\n return comb(c, 2) + _kmin(n - c, m - 1)\n\n@lru_cache(maxsize=128)\ndef semifact(a, b):\n if (a == b): return 1\n else: return a * semifact(a - 1, b)\n\n@lru_cache(maxsize=128)\ndef comb(a, b):\n if b > a: return 0\n return semifact(a, max(b, (a - b))) // factorial(min(b, (a - b)))\n\nn, m = tuple(map(int, input().split()))\n\nperfgroups = n % m\nimpfgroups = m - perfgroups\nszimpfgroups = n // m\nszperfgroups = ceil(n / m)\n\nkmin = perfgroups * comb(szperfgroups, 2) + impfgroups * comb(szimpfgroups, 2)\nkmax = int(comb(n - m + 1, 2))\nprint(kmin, kmax)\n"}, {"source_code": "\n#\n# 478B. Random Teams\n#\n\ndef nC2(n):\n return n * (n - 1) / 2\n\ndef min_friends(n, m):\n return nC2(n / m) * m + (n / m) * (n % m)\n\ndef max_friends(n, m):\n return nC2(n - m + 1)\n\nn, m = map(int, raw_input().split())\n\nprint min_friends(n, m), max_friends(n, m)"}, {"source_code": "\ndef comb(n, k):\n assert k >= 0\n assert n >= k\n if k == 0:\n return 1\n res = 1\n for i in xrange(k):\n res *= (n - i)\n for i in xrange(k):\n res /= (i + 1)\n return res\n\ndef random_team(n, m):\n assert m > 0\n assert n >= m\n\n largest = n - m + 1\n if largest < 2:\n return 0, 0\n max_f = comb(largest, 2)\n av = n / m\n mo = n % m\n\n min_f = mo * comb(av + 1, 2)\n if av > 1:\n min_f += (m - mo) * comb(av, 2)\n\n return min_f, max_f\n\nif __name__ == '__main__':\n array = raw_input().strip().split()\n n = int(array[0])\n m = int(array[1])\n min_f, max_f = random_team(n, m)\n print min_f, max_f\n"}, {"source_code": "n,m = map(int,input().split())\nyo = n-m+1\nmax1 = (yo * (yo-1))//2\nk = n//m\nhi = n % m\nmin1 = 0\nx = n - (k * m)\na = m - x\nb = m - a\nmin1 = 0\nres1 = ((k * (k-1))//2) * a\nres2 = ((k*(k+1))//2) * b\nmin1 = min1 + res1 + res2\nprint(min1,max1)"}, {"source_code": "n, m = map(int, raw_input().strip().split())\n\nminn=(m-n%m)*((n/m)*(n/m-1)/2)+(n%m)*(n/m+1)*(n/m)/2\nmaxx=(n-m+1)*(n-m)/2\n\nprint minn, maxx"}, {"source_code": "n,m = map(int,input().split())\n\n\nkmax = n-m+1\n\nkmax = (kmax*(kmax-1))//2\nkmin = ((n//m) *((n//m)-1))//2\nif n%m==0:\n kmin = kmin * m\nelse:\n kmin = kmin * (m - (n%m))\n lftovers = (n//m)*((n//m)+1)//2\n kmin += lftovers*(n%m)\nprint(int(kmin),int(kmax))\n"}, {"source_code": "temp = raw_input().split()\nn = int(temp[0])\nm = int(temp[1])\nave = n/m\nminnum = ave*(n%m) + ave*(ave-1)*m/2\nmaxnum = (n-m+1)*(n-m)/2\nprint minnum,' ',maxnum"}, {"source_code": "\"\"\"\n ____ _ _____\n / ___|___ __| | ___| ___|__ _ __ ___ ___ ___\n| | / _ \\ / _` |/ _ \\ |_ / _ \\| '__/ __/ _ \\/ __|\n| |__| (_) | (_| | __/ _| (_) | | | (_| __/\\__ \\\n \\____\\___/ \\__,_|\\___|_| \\___/|_| \\___\\___||___/\n\n\"\"\"\n\"\"\"\n\u2591\u2591\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\n\u2591\u2584\u2580\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2588\u2591\n\u2591\u2588\u2591\u2584\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2584\u2591\u2588\u2591\n\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2591\n\u2591\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2591\n\u2584\u2588\u2580\u2588\u2580\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2580\u2580\u2588\u2588\u2588\n\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\n\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2588\u2588\n\u2588\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\u2588\n\u2591\u2580\u2588\u2588\u2588\u2584\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2584\u2588\u2588\u2588\u2580\u2591\n\u2591\u2591\u2591\u2580\u2588\u2588\u2584\u2591\u2580\u2588\u2588\u2580\u2591\u2584\u2588\u2588\u2580\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\nimport sys\nimport math\nimport collections\nimport operator as op\nfrom collections import deque\nfrom math import gcd\n#sys.stdin = open('input.txt', 'r')\n#sys.stdout = open('output.txt', 'w')\n\nfrom functools import reduce\nfrom sys import stdin, stdout, setrecursionlimit\nsetrecursionlimit(2**20)\n\n\ndef ncr(n, r):\n r = min(r, n - r)\n numer = reduce(op.mul, range(n, n - r, -1), 1)\n denom = reduce(op.mul, range(1, r + 1), 1)\n return numer // denom # or / in Python 2\n\n\ndef isPowerOfTwo(x):\n return (x and (not(x & (x - 1))))\n\n\ndef factors(n):\n return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n\nT = 1\n# T = int(stdin.readline())\nfor _ in range(T):\n # s = str(stdin.readline().strip('\\n'))\n # a, b = list(map(int, stdin.readline().split()))\n # s = list(stdin.readline().strip('\\n'))\n # b = list(stdin.readline().strip('\\n'))\n # n = int(stdin.readline())\n # n, m = list(map(int, stdin.readline().split()))\n n, m = list(map(int, stdin.readline().split()))\n if n == m:\n print(0, 0)\n continue\n kx = ncr(n - (m - 1), 2)\n x = n // m\n y = n % m\n if x > 1:\n kn = ncr(x + 1, 2) * (y) + ncr(x, 2) * (m - y)\n else:\n kn = ncr(x + 1, 2) * (y)\n print(kn, kx)\n"}, {"source_code": "n,m=map(int, raw_input().split())\nmaxi=n-m+1\nmaxiposs=maxi*(maxi-1)/2\nremteams=n%m\nremteamsval=(n/m) + 1\nminiposs=remteams*remteamsval*(remteamsval-1)/2\nminiposs+=(m-remteams)*(n/m)*((n/m)-1)/2\nprint miniposs,maxiposs"}, {"source_code": "n,m=map(int,input().split())\nif m==1:\n print(n*(n-1)//2,n*(n-1)//2)\nelse:\n l=n-m\n h=l*(l+1)//2\n \n k=n//m\n z=n%m\n f=k+1\n j=k\n ans = z*f*(f-1)//2 + (m-z)*j*(j-1)//2\n print(ans,h)"}, {"source_code": "def links(x):\n return (x * (x - 1)) / 2\n\nn, m = map(int, raw_input().split())\n\nmn = (m - (n % m)) * links(n/m) + (n % m) * links(n/m + 1)\n\nprint mn, links(n - m + 1)"}, {"source_code": "n,m = map(int,raw_input().split())\n\ndef pairs(n):\n return (n * (n - 1) / 2)\n\n\na = n / m\nb = n % m\n\nmi = pairs(a) * (m - b) + pairs(a + 1) * b\nma = pairs(n - m + 1)\n\nprint(str(mi) + ' ' + str(ma))\n\n"}, {"source_code": "n,k=map(int,input().split())\n\nflag=1\nif n==1:\n print(\"0\",\"0\")\n flag=0\nelif n<=k:\n print(\"0\",\"0\")\n flag=0\nif flag==1:\n \n maxi=(n-k+1)*(n-k)//2\n x=n%k\n mini=0\n fe=n//k\n mini=((fe+1)*(fe)//2*x)+(k-x)*(fe)*(fe-1)//2\n print(mini,maxi,end=' ')"}, {"source_code": "l1=[int(x) for x in input().split()]\nn=l1[0]\nm=l1[1]\n#min\nmin1=n//m\nn_min1=n-min1*m\nmin_half=((min1+1)*(min1)//2)*n_min1\nmin_full=(m-n_min1)*(min1*(min1-1)//2)\nmin_out=min_half+min_full\n#max\nmax1=n-m\nmax_out=(1+(n-m))*(n-m)//2\nprint(int(min_out),int(max_out))\n"}, {"source_code": "n, m = map(int, input().split())\nmax = (n - m + 1) * (n - m) // 2\nif m == 1:\n tmp = 0\nmin = (n % m) * (((n // m) * (n // m + 1)) // 2) + (m - n % m) * (((n // m - 1) * (n // m)) // 2)\nprint(min, end=' ')\nprint(max)\n"}, {"source_code": "import math\n\npersons, teams = map(int, input().split())\n\n\n\ndef comb(size_team):\n if size_team < 2:\n return 0\n else:\n return ((size_team)*(size_team-1))//2\n\n\n# minimum -> teams with the same amount of people\n\npersons_remaining = persons - teams\nadd_people_per_team = persons_remaining//teams\nremaining = persons_remaining%teams\nminimum = (teams-remaining)*comb(1+add_people_per_team)\nminimum += remaining*comb(2+add_people_per_team)\n\n# maximum -> teams with 1 person and 1 team with the remaining\n\npeople_last_team = persons - (teams-1)\nmaximum = comb(people_last_team)\n\nprint(int(minimum), int(maximum))\n\n"}, {"source_code": "import sys\nimport math\nimport collections\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef get_list(): return list(map(int, sys.stdin.readline().strip().split()))\ndef get_string(): return sys.stdin.readline().strip()\nfor t in range(1):\n n,m=get_ints()\n maxim=n-m+1\n c_max=maxim*(maxim-1)//2\n minim=math.ceil(n/m)\n rem=(minim*m)-n\n big_min_count,big_min_value=m-rem,minim\n small_min_count,smaall_min_value=rem,minim-1\n c_min_big=big_min_count*(big_min_value*(big_min_value-1)//2)\n c_min_small=small_min_count*(smaall_min_value*(smaall_min_value-1)//2)\n c_min=c_min_big+c_min_small\n print(c_min,c_max)"}, {"source_code": "def ii(): return int(input())\ndef fi(): return float(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n\nimport math\n \nn,m=mi()\na=math.ceil(n/m)\nb=n%m\nd=(m-b)\nc=(n-(b*a))//d\ny=n-m+1 \ny=y*(y-1)\ny//=2 \nx=b*((a*(a-1))//2)+d*((c*(c-1))//2) \nprint(x,y)"}, {"source_code": "n,m=map(int,raw_input().split())\n\no=n-(m-1)\nif(m==1):\n\tprint (o*(o-1))/2,\n\tprint (o*(o-1))/2\nelse:\n\tk=n/m\n\tz=k+1\n\ty=n%m\n\tprint y*(z*(z-1)/2)+(m-y)*(k*(k-1)/2), \n\tprint (o*(o-1))/2\n"}, {"source_code": "import math\n\nn, m = map(int, input().split())\nkmax = 0\nkmin = 0\nif n == 1:\n kmax = 0\n kmin = 0\nelif m == 1:\n kmin = kmax = (n * (n - 1)) / 2\nelse:\n x=n//m\n y=n-(x*m)\n kmin=(y*x*(x+1)/2)+ ((m-y)*x*(x-1)/2)\n kmax = (n - m + 1) * (n - m) // 2\nprint(int(kmin), int(kmax))"}, {"source_code": "n,m=map(int,input().split())\nkmax=((n-m+1)*(n-m))//2 \nquo=n//m\nrem=n%m\nkmin=rem*((quo*(quo+1))//2)+(m-rem)*((quo*(quo-1))//2)\nprint(kmin,kmax)"}, {"source_code": "def choose(n,r):\n r = max(r,n-r)\n if n == 1:\n return 0\n out = 1\n for i in range(r+1,n+1):\n out *= i\n for i in range(1,n-r+1):\n out = out // i\n return out\n\nl = input().split()\nn = int(l[0])\nm = int(l[1])\nd = n // m\no = n % m\np = m-o\n\nprint(o*choose((d+1),2)+p*choose(d,2),choose(n-m+1,2))\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\nf = lambda x: x*(x-1)//2\nsize = n//m\nr = n%m\nans1 = f(n//m)*(m-r) + f(n//m+1)*r\nans2 = f(n-m+1)\nprint(ans1,ans2)"}, {"source_code": "from sys import stdin,stdout\nn,m=map(int,stdin.readline().split())\na,b=0,0\nif n%m==0:\n p=n//m\n a=m*((p*(p-1))//2)\nelse:\n q=n%m\n p=n//m\n a=q*((p*(p+1))//2)+(m-q)*((p*(p-1))//2)\nn=n-(m-1)\nb+=((n*(n-1))//2)\nstdout.write(str(a)+\" \"+str(b))"}, {"source_code": "# Random Teams \n\nn, m = map(int, raw_input().split())\n\ndef comb(i):\n if i == 2:\n return 1\n elif i > 2:\n return (i * (i - 1)) / 2\n else:\n return 0\n \nmaxPairs = comb(n - m + 1)\nminPairs = None\nif m == 1:\n minPairs = maxPairs\nelif n % m == 0:\n minPairs = m * comb(n / m)\nelse:\n mod = n % m\n minPairs = mod * comb(n/m + 1) + (m - mod) * comb(n/m)\n\nprint \"%i %i\" % (minPairs, maxPairs)"}, {"source_code": "from sys import stdin\nimport math\n\ndef count(n):\n n = n - 1\n return n*(n + 1) / 2\n\npeople, groups = map(int, stdin.readline().split())\n\nmax = people - (groups - 1)\n\nx = people / groups\nmin = count(x + 1) * (people%groups) + count(x) * (groups -people%groups)\n\n\nprint min, count(max)\n"}, {"source_code": "# Author Kmoussai \nimport sys\nimport math\nimport random\n'''\ni = 0\nwhile i < n:\n \n i += 1\n\nmap(int, input().split())\n\n\ndef pgcd(a, b):\n if b == 0:\n return a\n return pgcd(b, a%b)\n\n\n\n'''\nif len(sys.argv) >= 2:\n if sys.argv[1] == 'LOCAL':\n sys.stdin = open('input.in', 'r')\n\nn,m = map(int, input().split())\nt = (n - (m - 1))\nmaxx = int((t*(t - 1))//2)\n\nt = n // m\n\nif n%m == 0:\n minn = (t*(t - 1))//2\n minn *= m\nelse:\n t = n//m\n minn = ((t*(t - 1))//2) * (m - n%m)\n t += 1\n minn += ((t*(t - 1))//2) * (n%m)\n\nprint(minn, maxx)\n\n\n\n"}, {"source_code": "def pair(a):\n return (a*(a-1))//2\n\nn,m = [int(i) for i in input().split()]\n\nnmat = n-(m-1)\nnmat = pair(nmat)\n\nif(n%m != 0):\n k=n//m\n nmit = pair(k+1)*(n%m)\n nmit += pair(k)*(m-(n%m))\nelse:\n nmit = pair((n//m))*(n//(n//m))\n\nprint(nmit,nmat)\n\n\n\n"}, {"source_code": "import bisect\n\ndef ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\ndef si():\n return raw_input()\n\ndef sis():\n return raw_input().split()\n\ndef pairs(n):\n return n * (n - 1) / 2\n\nn, m = nis()\n\navg_team = n / m\nrem = n % m\na = (m - rem) * pairs(avg_team) + rem * pairs(avg_team + 1)\n\nmax_team = n - (m - 1)\nb = pairs(max_team)\n\nprint a, b\n\n"}, {"source_code": "n, m = map(int, input().split())\nmi, r, mx = n // m, n % m, n - m + 1\nprint((m - r) * (mi * (mi - 1)) // 2 + r * ((mi + 1) * mi) // 2, (mx * (mx - 1)) // 2)"}, {"source_code": "n, m = map(int, raw_input().split())\n\n# get Min\nminCombo = 0\nnPerM = n / m\nif n / m > 1:\n minCombo += (nPerM * (nPerM -1)/2) * (m - (n % m))\nnSpecial = nPerM + 1\nminCombo += (nSpecial * (nSpecial - 1)/2) * (n % m)\n\n# get Max\nmaxCombo = 0\nmaxN = n - (m - 1)\nmaxCombo += (maxN * (maxN - 1)) / 2\n\nprint minCombo, maxCombo\n\n\n\n"}, {"source_code": "\n#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\ndef array():\n return [int(i) for i in input().split()]\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#-------------------------code---------------------------#\n#vsInput()\n\ndef nc2(n):\n if(n==1):\n return 0\n return n*(n-1)//2\n\nn,k=map(int,input().split())\nkmin=0\nkmax=nc2(n-k+1)\nkmin=nc2(n//k)*(k-n%k)+nc2(n//k+1)*(n%k)\nprint(kmin,kmax)\n\n"}, {"source_code": "string = input()\nnumbers = string.split(\" \")\ntotal = int(numbers[0])\nteams = int(numbers[1])\nn = total // teams\na = n * (n - 1) // 2 * teams + total % teams * n\nn = total - (teams - 1)\nb = n * (n - 1) // 2\nprint(\"%d %d\" % (a, b))"}, {"source_code": "n,m=map(int,input().split())\nx=n-(m-1)\nx=(x*(x-1))//2\ny=n//m\nd=n%m\nmm=(y*(y-1)//2)*(m-d)+((y+1)*(y+1-1)//2)*d\nprint(mm,x)\n"}, {"source_code": "'''input\n5 1\n'''\nfrom sys import stdin, stdout\nimport math\n \n \ndef combination(a, b):\n\tif a >= 2:\n\t\treturn (a * (a - 1)) // 2 \n\telse:\n\t\treturn 0\n \n \ndef calculate_min(n, m):\n\ttemp = n // m\n\tremain = n % m\n\n\tans = (m - remain) * combination(temp, 2)\n\tans += remain * combination(temp + 1, 2)\n\treturn ans\n\t# temp = math.ceil(n/m)\n\t# temp2 = n // temp\n\t# #print(temp, temp2)\n\t# r = n % m\n\t# if r == 0:\n\t# \treturn combination(temp, 2) * m\n\t# else:\n\t# \treturn combination(temp, 2) * (min(m - 1, temp2) ) + combination(n - (temp2 * temp), 2)\n \n \ndef calculate_max(n, m):\n\treturn combination(n - (m - 1), 2)\n \n# main starts\nn, m = list(map(int, stdin.readline().split()))\nsecond = calculate_max(n, m)\nfirst = calculate_min(n, m)\nprint(first, second)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Apr 3 15:16:34 2020\n\n@author: SOUVIK PAN\n\"\"\"\nn,m = map(int,input().split())\nkn=(n-m+1)*(n-m)//2\na=n//m\nkm= m*a*(a-1)//2 + a*(n%m)\nprint(km,kn)"}, {"source_code": "\ndef main():\n \n n,m = [int(i) for i in raw_input().split(\" \")]\n \n #min\n p,t = n,m\n if p%t == 0:\n ppt = p/t\n print t * ( ppt * (ppt-1) )/2,\n else:\n ppt = p/t\n r = p%t\n \n print r * ( (ppt+1) *ppt )/2 + (t-r) * ( ppt * (ppt-1) )/2,\n \n \n #max\n p,t = n,m\n p -= t-1\n print (p*(p-1))/2\n \nmain()\n \n "}, {"source_code": "from __future__ import nested_scopes, generators, division, absolute_import, with_statement, print_function, unicode_literals\nimport sys, os, time\ninput = raw_input\nrange = xrange\n\ndef rv(): return map(int, input().split())\ndef rl(n): return [list(map(int, input().split())) for _ in range(n)]\nif os.path.exists(\"test.txt\"): sys.stdin = open(\"test.txt\")\n# sys.stdout = open(pass, 'w')\n\ndef gmin(n, m):\n small = n // m\n moars = n - small * m\n moaramount = moars * small\n return m * (small - 1) * small // 2 + moaramount\n\ndef gmax(n, m):\n maxteam = n - m + 1\n return maxteam * (maxteam - 1) // 2\n\ndef solve():\n n,m, = rv()\n print(gmin(n, m), gmax(n, m))\n \n\nsolve()"}, {"source_code": "\n\ndef main():\n\n n,m = map(int,input().split())\n rem = n%m\n q = n//m\n min_friend = 0\n if q-2 >= 0:\n min_friend += (m-rem)*((q*(q-1))//2)\n if q-1 >= 0 and rem > 0:\n min_friend += rem*((q+1)*q)//2\n max_friend = 0\n if m != n:\n max_friend = (n-m+1)*(n-m)//2\n print(min_friend,max_friend)\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, m = map(int, raw_input().split())\n\n\ndef getResult(value):\n return value * (value + 1) / 2\n\n\nrest = n % m\naux = n // m\n\nmaximum = getResult(n - m)\nminimum = (getResult(aux) * rest) + (getResult(aux - 1) * (m - rest))\n\nprint(str(minimum) + ' ' + str(maximum))\n"}, {"source_code": "from collections import Counter\nfrom collections import defaultdict\nimport math\nimport random\nimport heapq as hq\nfrom math import sqrt\nimport sys\nfrom functools import reduce\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef iinput():\n return int(input())\n\n\ndef tinput():\n return input().split()\n\n\ndef rinput():\n return map(int, tinput())\n\n\ndef rlinput():\n return list(rinput())\n\n\nmod = int(1e9)+7\n\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\n\n# ----------------------------------------------------\n\ndef f(n):\n return n*(n-1)//2\n\n\nif __name__ == \"__main__\":\n n, m = rinput()\n kmax = f(n-m+1)\n q, r = divmod(n, m)\n kmin = (m-r)*f(q) + r*f(q+1)\n print(kmin, kmax)\n"}, {"source_code": "# cook your dish here\nn, m = list(map(int, input().split()))\nmaxvalue = ((n-m+1)*(n-m))//2\nminvalue = ((n%m)*((n//m) + 1)*(n//m))//2\nif n//m > 1:\n minvalue += ((m-(n%m))*(n//m)*((n//m)-1))//2\nprint(minvalue, maxvalue)\n\n"}, {"source_code": "n,m=map(int,raw_input().split(' '))\nmx=((n-m+1)*(n-m))/2\na=n%m\nb=(n-a)/m\nmn=(m-a)*((b*(b-1))/2)+a*(((b+1)*b)/2)\nprint str(mn)+' '+str(mx)\n"}, {"source_code": "n,m=map(int,raw_input().split())\na=n/m\nprint m*a*(a-1)/2+a*(n%m),(n-m)*(n-m+1)/2\n"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(2*10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin(): return stdin.readline().rstrip()\nn,m=listInput()\nma=n-m+1\nma=(ma*(ma-1))/2\nmi=n/m\nr=n%m\nmi=r*(((mi+1)*mi)/2)+(m-r)*((mi*(mi-1))/2)\nprint mi,ma"}, {"source_code": "ins = [int(i) for i in input().split()]\np,t = ins \n\nmost = (p-t)*(p-t+1)//2\nif t==1:\n least = most\nelse:\n least = (t-p%t)*(p//t-1)*(p//t)//2 + p%t*(p//t)*(p//t+1)//2\nprint(least,most)"}, {"source_code": "def inp():\n return map(int, stdin.readline().split())\n\n\ndef nCr(n, r):\n f, m = factorial, 1\n for i in range(n, n - r, -1):\n m *= i\n return int(m // f(r))\n\n\nfrom math import *\nfrom sys import *\n\nn, m = inp()\nmi = nCr((n // m) + 1, 2) * (n % m) + nCr(n // m, 2) * (m - (n % m))\nma = nCr(n - (m - 1), 2)\nprint(mi, ma)\n"}, {"source_code": "def inp():\n return map(int, stdin.readline().split())\n\n\ndef nCr(n, r):\n f, m = factorial, 1\n for i in range(n, n - r, -1):\n m *= i\n return int(m // f(r))\n\n\nfrom math import *\nfrom sys import *\n\nn, m = inp()\nif n % m == 0:\n mi = nCr(n // m, 2) * m\nelse:\n mi = nCr((n // m) + 1, 2) * (n % m) + nCr(n // m, 2) * (m - (n % m))\n\nma = nCr(n - (m - 1), 2)\nprint(mi, ma)\n"}, {"source_code": "n,m=map(int,input().split())\nif(n==m):\n print(0,0)\nelif(m==1):\n print((n*(n-1))//2,(n*(n-1))//2)\nelse:\n n=n-m\n mx=((n+1)*(n))//2\n c=1\n while((n-m)>=0):\n n=n-m\n c+=1\n if(n==0):\n mn=m*((c*(c-1))//2)\n else:\n mn=n*((c*(c+1))//2)+(m-n)*((c*(c-1))//2)\n print(mn,mx)"}, {"source_code": "n, m = map(int,input().split())\nr = n // m\nmi = m * (r*(r-1))//2 + (r*(n%m))\nmx = (n-m)*(n-m+1)//2\nprint(mi,mx)"}, {"source_code": "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\n# from math import *\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\nimport copy\nimport time\n# import numpy as np\nstarttime = time.time()\n# import numpy as np\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)\ndef L(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\ntry:\n # sys.setrecursionlimit(int(pow(10,6)))\n sys.stdin = open(\"input.txt\", \"r\")\n # sys.stdout = open(\"../output.txt\", \"w\")\nexcept:\n pass\nn,m=L()\ndef nC2(x):\n return x*(x-1)//2\n\nmn=(m - n % m) * (nC2(n//m)) + (n % m) * (nC2(n//m + 1))\n\n\n\nx=n-(m-1)\nmx=x*(x-1)//2\nprint(int(mn),mx)\nendtime = time.time()\n# print(f\"Runtime of the program is {endtime - starttime}\")\n\n"}, {"source_code": "from collections import *\nfrom bisect import *\nfrom math import *\nfrom heapq import *\nfrom fractions import *\nimport sys\ninput=sys.stdin.readline\nt=1\ndef r(a):\n return ((a*(a-1))//2)\nwhile(t):\n t-=1\n n,k=map(int,input().split())\n q=n//k\n n1=n-(k*q)\n kmin=r(q+1)*(n1)\n kmin+=r(q)*(k-n1)\n kmax=r(n-k+1)\n print(kmin,kmax)\n"}, {"source_code": "n,m = map(int, input().split())\n\ndef combination(n):\n return int((n*.5*(n-1)))\ndef minTeam(n,m):\n if(n==0 and m==0):\n return 0\n if(n%m==0):\n return m*combination(n//m)\n else:\n return (m-(n%m))*combination(n//m)+(n%m)*combination(n//m+1)\n\nprint(minTeam(n,m) ,(n-m+1)*(n-m)//2)\n\n# 9223372036854775807\n# 998001000999000064\n# 499000500499500032"}], "negative_code": [{"source_code": "a,b=map(int,input().split())\nd=a-b\nif a%2!=0 and b%2!=0:\n\tm=m=a//b+a%b-1\nelse:\t\n\tm=a//b+a%b\nif m!=1 and d!=1:\n\tprint((m*(m+1))//2,(d*(d+1))//2)\nelif m!=1 and d==1:\n\tprint((m*(m+1))//2,1)\nelif m==1 and d!=1:\n\tprint(1,(d*(d+1))//2)\nelse:\n\tprint(1,1)"}, {"source_code": "\n\nn, m = map( int, input().split() )\n\n\n\n# for min\n\nr = n % m\nq = n / m\n\na = r * (q+1) * (q) / 2\n\na += (m - r) * q * (q - 1) / 2\n\nprint(int(a))\n\n# for maximum\n\nN = n - m + 1\na = N * (N - 1) / 2\nprint(int(a))\n"}, {"source_code": "from math import *\nn,m=map(int,input().split())\nif m==1:print(n*(n-1)//2,n*(n-1)//2)\nelse:\n minim=[ceil(n/m) for i in range(m-1)]\n maxim=[1 for i in range(m-1)]\n maxim.append(n-m+1)\n minim.append(n-sum(minim))\n sum1,sum2=0,0\n for i in minim:sum1+=i*(i-1)//2\n for i in maxim:sum2+=i*(i-1)//2\n print(sum1,sum2)\n \n "}, {"source_code": "import math\n\ndef nCr(n,r):\n f = math.factorial\n return f(n) / f(r) / f(n-r)\n\nn, m = map(int, raw_input().split())\n\n# get Min\nminCombo = 0\nnPerM = n / m\nif n / m > 1:\n minCombo += nCr(nPerM, 2) * (m - 1)\nnSpecial = nPerM + (n % m)\nminCombo += nCr(nSpecial, 2)\n\n# get Max\nmaxCombo = 0\nmaxN = n - (m - 1)\nmaxCombo += nCr(maxN, 2)\n\nprint minCombo, maxCombo\n\n\n\n"}, {"source_code": "n, m =[int(x) for x in input().split()]\nf = lambda x: x*(x-1)//2\nsize = n//m\nif n%m==0:\n ans1 = m*f(size)\nelse:\n ans1 = (m-1)*f(size)+f(n-size*(m-1))\nans2 = f(n-m+1)\nprint(ans1,ans2)"}, {"source_code": "import math\n\ndef ncr(a):\n return a * (a-1) / 2\n\nn, m = [int(x) for x in raw_input().split()]\n\nprint (ncr(n/m) * m + (n%m)*n/m), ncr(n+1-m)\n"}, {"source_code": "n,m=map(int,raw_input().split())\nprint n*(n/m-1)/2+n/m*(n%m),(n-m)*(n-m+1)/2"}, {"source_code": "def combi(a):\n return (a*(a-1))/2\n\nN, M = map(int, raw_input().split())\nk = N / M\nx = N % M\nMx, Mn = combi(N-(M-1)), 0\nMn = (M-x)*combi(k) + (x)*(x*(x+1))/2\nprint Mn, Mx"}, {"source_code": "#rOkY\n#FuCk\n\n################################## kOpAl #######################################\n\na,b=map(int,input().split())\nif(b==1):\n print(a*2,a*2)\nelif(a-1==b):\n print(1,1)\nelse:\n print(b,a)\n"}, {"source_code": "n,m = map(int,raw_input().strip().split(' '))\nif m!= 1:\n maxfp = (n*(m-1))/2\nelse:\n maxfp = (n*(n-1))/2\n\nif m==1:\n minfp = maxfp\nelse:\n if m<n/2:\n minfp = m-1+(n+1)/2\n else:\n minfp = n-m\nprint minfp, maxfp\n\n \n\n\n\n\n\n \n\n \n\n"}, {"source_code": "def sumTillN(N):\n return int((N*(N-1)) / 2)\nN,M = map(int,input().split())\nMax = sumTillN(N - (M-1))\nNumber = int(N//M)\nSome = N%M\nX = Some * sumTillN(Number+1)\nY = (M - Some) * sumTillN(Number)\nMin = X+Y\nprint(Min,Max)\n\n"}, {"source_code": "n,m = [int(i) for i in input().split()]\n\npair = [0,0]\n\nfor i in range(2,n+1):\n pair.append((i-1)+pair[i-1])\n\nnmat = n-(m-1)\nnmat = pair[nmat]\nif(n%m != 0):\n k = m-(n%m)\n k+=n//m\n nmit = pair[k]*(n%m)\nelse:\n nmit = pair[(n//m)]*(n//(n//m))\n\nprint(nmit,nmat)\n\n\n\n"}, {"source_code": "import math\nfrom math import ceil\nfrom math import floor\nnumbers = map(float, raw_input().split())\nm = numbers[0]\nn = numbers[1]\nlarge = (m-n+1)*(m-n)/2\n\nmajor = math.ceil(m/n)\nminor = math.floor(m/n)\nnum_major = m-n*(m//n)\nnum_minor = n-num_major\n\nsmall = num_major*(major*(major-1))/2 + num_minor * (minor*(minor-1))/2\nprint int(small), int(large)"}, {"source_code": "\n\nn, m = map( int, input().split() )\n\n\n\n# for min\n\nr = n % m\nq = n // m\n\na = r * (q+1) * (q) / 2\na += (m - r) * q * (q - 1) / 2\n\nprint(int(a))\n\n# for maximum\n\nN = n - m + 1\na = N * (N - 1) / 2\nprint(int(a))\n"}, {"source_code": "import math\n\ndef cnt(n):\n return (n*(n-1))//2\n\nn, m = [int(x) for x in input().split()]\nprint((m-n % m)*cnt(n//m) + (n % m)*cnt(n/m+1), cnt(n - m + 1))\n"}, {"source_code": "n,m=map(int,raw_input().split())\ndef combin(n, k):\n \"\"\"Nombre de combinaisons de n objets pris k a k\"\"\"\n if k > n//2:\n k = n-k\n x = 1\n y = 1\n i = n-k+1\n while i <= n:\n x = (x*i)//y\n y += 1\n i += 1\n return x\nmaxi=combin(n-m+1,2)\na=n/m\nmini= m*a*(a-1)/2+a*(n%m)\nprint mini,maxi\n"}, {"source_code": "n, m = map(int, input().split())\n\n\nif m == 1:\n\tans = (n*(n-1))//2\n\tprint(ans, ans)\n\n\nelif n == m:\n\tprint(0, 0)\n\nelse:\n\n\ts = n-m\n\n\tkmax = ((s+1)*(s))//2\n\n\tf = n//m\n\tr = n%m\n\n\ttotal = 0\n\n\ttotal+= ((f)*(f-1))//2\n\n\ttotal*=(m-r)\n\n\tt2=((f+r)*(f+r-1))//2\n\tt2*=r\n\n\ttotal+=t2\n\n\tprint(total, kmax)"}, {"source_code": "a,b=map(int,raw_input().split())\nd=a-(b-1)\nif a%b==0:\n r=a/b\n ans=b*r*(r-1)/2\nelse:\n r=a/b+1\n ff=r*b-a\n ans=(b-ff)*r*(r-1)/2\n fa=a-(b-1)*r\n ans+=ff*fa*(fa-1)/2\nprint ans,d*(d-1)/2\n"}, {"source_code": "import math\n\ndef ncr(a):\n return a * (a-1) / 2\n\nn, m = [int(x) for x in raw_input().split()]\n\nprint (ncr(n/m) * m + (n%m)*n/m), ncr(n+1-m)\n"}, {"source_code": "import math\nl=[int(x) for x in raw_input().split()]\nn=l[0]\nm=l[1]\nndiv=m-1\ndef round(k):\n ksize=k*10\n size=0\n if int(ksize)%10>=5:\n size=math.ceil(k)\n else:\n size=math.floor(k)\n return size\ndef comb(n,m):\n ans=(n*(n-1))/2\n return ans\ndef maxno(n,ndiv):\n n=n-ndiv\n #print n\n k=comb(n,2)\n #print k\n return k\ndef minno(n,ndiv):\n #Need to find the number of division of teams, so keep dividing by 2 until you find the required number of teams\n teamsize=float(n)\n npart=ndiv\n times=1\n size=n\n #Need size of each partition\n size=teamsize/(ndiv+1)\n ksize=size*10\n #print size\n #print ksize\n if int(ksize)%10>=5:\n\n size=math.ceil(size)\n #print \"yoko1\"\n else:\n size=math.floor(size)\n #print ksize%10\n #print \"yoko2\"\n n=int(size)\n #print n\n if n==1:\n n=2\n ans1=comb(n,2)\n titer=0\n q=0\n while q<teamsize:\n q=q+n\n titer+=1\n q=q-n\n titer-=1\n diff=teamsize-q\n ans2=comb(diff,2)\n ans=ans1*titer+ans2\n if npart+1>round(teamsize/2):\n diff=npart+1-teamsize/2\n ans=teamsize/2-diff\n if teamsize%2==1:\n ans+=1\n return ans\na1=maxno(n,ndiv)\na2=minno(n,ndiv)\nprint long(a2),long(a1)\n\n"}, {"source_code": "n,t = input().split()\nn = int(n)\nt = int(t)\n\ndef sm(n):\n \n return (n*(n-1))/2\nif t == 1:\n mx = sm(n)\n mn = sm(n)\nelse:\n mx = sm(n-t+1)\n if n%t == 0:\n mn = t*sm(int(n/t))\n else:\n x = n%t\n mn = x*(sm(int(n//t+1))) + (t-x)*sm(int(n//t))\n\nprint (int(mn),int(mx))"}, {"source_code": "from collections import *\nfrom bisect import *\n#from math import *\nfrom heapq import *\nfrom fractions import *\nimport sys\ninput=sys.stdin.readline\nt=1\ndef r(a):\n return ((a*(a-1))//2)\nwhile(t):\n t-=1\n n,k=map(int,input().split())\n q=n//k\n re=n%k\n kmin=r(q)*(n//q)\n kmin+=r(re)\n kmax=r(n-k+1)\n print(kmin,kmax)\n"}, {"source_code": "n, m = map(int, input().split())\nd = n // m\nans1 = d * (d - 1) / 2 * (m - 1)\nd += n % m\nans1 += d * (d - 1) / 2\nd = (n - m + 1)\nprint(int(ans1), int(d * (d - 1) / 2))\n"}, {"source_code": "import math\nl=[int(x) for x in raw_input().split()]\nn=l[0]\nm=l[1]\nndiv=m-1\ndef fact(k):\n ans=1\n if k<0:\n return 1\n else:\n return math.factorial(k)\ndef comb(n,m):\n ans=(n*(n-1))/2\n return ans\ndef maxno(n,ndiv):\n n=n-ndiv\n #print n\n k=comb(n,2)\n #print k\n return k\ndef minno(n,ndiv):\n #Need to find the number of division of teams, so keep dividing by 2 until you find the required number of teams\n teamsize=n\n npart=ndiv\n times=1\n size=n\n #Need size of each partition\n size=float(teamsize/(ndiv+1))\n ksize=size*10\n if int(ksize)%10>=5:\n size=math.ceil(size)\n else:\n size=math.floor(size)\n n=int(size)\n if n==1:\n n=2\n ans1=comb(n,2)\n titer=0\n q=0\n while q<teamsize:\n q=q+n\n titer+=1\n q=q-n\n titer-=1\n diff=teamsize-q\n ans2=comb(diff,2)\n ans=ans1*titer+ans2\n if npart+1>teamsize/2:\n diff=npart+1-teamsize/2\n ans=teamsize/2-diff\n if teamsize%2==1:\n ans+=1\n return ans\na1=maxno(n,ndiv)\na2=minno(n,ndiv)\nprint a2,a1\n\n"}, {"source_code": "filename = \"input1.txt\"\nimport sys\ncaonima = True\nif caonima:\n f = sys.stdin\nelse:\n f = open(filename)\n\nn,m = map(int,f.readline().split())\nif n%m==0:\n k = n/m\n kmin = k*(k-1)/2*m\nelse:\n k1 = n/m\n k2 = n-(m-1)*k1\n kmin = k2*(k2-1)/2 + k1*(k1-1)/2*(m-1)\nk = n-(m-1)\nkmax = (k-1)*k/2\nprint kmin,kmax\n\n#with open( \"2.out\", \"w\") as f1:\n# for i in ans:\n# j = str(i)+'\\n'\n #print j\n# f1.write(j)\n \n \n"}, {"source_code": "# coding=utf-8\n\nif __name__ == '__main__':\n n, m = str(input()).split()\n n = int(n)\n m = int(m)\n k_max = int((n + 1 - m) * (n - m) / 2)\n k_min = (m - (n - m * int(n / m))) * int(int(n / m) * (int(n / m) - 1) / 2) + (n - m * int(n / m)) * int(int(n / m) * (int(n / m) + 1) / 2)\n print(str(k_min)+' '+str(k_max))\n"}, {"source_code": "w=input().split(\" \")\nn=int(w[0])\nm=int(w[1])\nformax=n-m\nmaxx=int((formax)*(formax+1)/2)\na=n//m\nb=n%m\nminn=int((b*(a*(a+1)/2))+((m-b)*(a*(a-1)/2)))\nprint(str(minn)+\" \"+str(maxx))\n"}, {"source_code": "import math\n\nn, m = map(int, input().split())\n\nc_max = n - m + 1\nc_min = math.ceil(n/m)\n\n# print(c_min, c_max)\n\n\ndef s(i):\n return round((i*(i-1))/2)\n\n\nk_max = s(c_max)\n\n\nif n % m:\n k_min1 = s(c_min)*(m-1)\n k_min1 += s(n % c_min)\n\n c_min = math.floor(n/m)\n k_min2 = s(c_min)*(m-1)\n k_min2 += s(c_min + (n % m))\n k_min = min(k_min1, k_min2)\nelse:\n k_min = s(c_min)*m\n\nprint( k_min, k_max )"}, {"source_code": "import math\nx,y = map(int, input().strip().split())\nx = x-y\nkmax = ((x+1)*x)/2\nw = int((x+y)/y) #number of people in one team\nk = (x+y)%y # NUMBER OF CASES WHER WE NEED TO +1 ON W\nkmin = ((y-k)*w*(w-1))/2 +(k*w*(w+1))/2\nkmin = int(kmin)\nkmax =int(kmax)\nprint(kmin,kmax)\n"}, {"source_code": "n,m=map(int,input().split())\nif(n==1):\n print(0)\nelif(m==1):\n a=n*(n-1)//2\n print(a,a)\nelse:\n a=n-(m-1)\n maxi=a*(a-1)//2\n b=n//m\n c=n%m\n if(n%m==0):\n d=((b-1)*b//2)*m\n else:\n d=((m-1)*m//2)*b\n c=c*(c-1)//2\n mini=c+d\n print(mini,maxi)\n"}, {"source_code": "n,m = map(int, input().split())\n\ndef combination(n):\n return int((n*(n-1))/2)\ndef minTeam(n,m):\n if(n==0 and m==0):\n return 0\n if(n%m==0):\n return m*combination(n//m)\n else:\n return (m-(n%m))*combination(n//m)+(n%m)*combination(n//m+1)\n\nprint(minTeam(n,m) ,combination(n-m+1))"}, {"source_code": "from math import ceil\nn,m=map(int,input().split())\n\nmax = ((n-m+1)*(n-m))//2\n\nk=ceil(n/m)\nmin = (m-1)*k*(k-1)//2 + (n-m*k +k)*(n-m*k+k-1)//2\n\nprint(min,max)"}, {"source_code": "a, b = map(int, input().split())\nif b == 1:\n print(a*(a-1)//2, a*(a-1)//2)\nelif a == b:\n print(0, 0)\nelse:\n k = int(a // b)\n k1=a%b\n if a % b == 0:\n print((k*k-1* b)//2, (a-b)*(a - b + 1)//2)\n else:\n print(b * k*(k-1)//2 + k1 * k, (a-b+1)*(a-b)//2)\n"}, {"source_code": "\nn, m = list(map(int, input().split(\" \")))\n\n\ndef count_friends(num):\n return int(((num-1)/2)*(num))\n\n\n\n#Max\nmaxFriends = count_friends(n - (m-1))\n\n#Min\nminFriends = 0\nif n % m == 0:\n min = int(n/m)\n minFriends += count_friends(min)*m\nelse:\n roundNum = int(n/m)\n ostatok = n % m\n minFriends += count_friends(roundNum) * (m - ostatok)\n minFriends += count_friends(roundNum + 1) * ostatok\n\nprint(str(maxFriends) + \" \" + str(minFriends))\n\n\n\n"}, {"source_code": "import math\n\nentrada = [int(x) for x in raw_input().split()]\n\nn = entrada[0]\nm = entrada[1]\n\nmax_ind = n-(m-1)\nmax = 0\nif max_ind<=1:\n\tmax = 0\nelse:\n\tmax = math.factorial(max_ind)/((math.factorial(max_ind-2))*2)\n\nmin_ind = n/m\ntemp = n\ntamanho = 0\n\nfor i in range(m-1):\n\tif temp>=min_ind:\n\t\ttemp-=min_ind\n\t\ttamanho+=1\nmin = 0\n\nif n==m:\n\tmin = 0\nelse:\n\tif min_ind>1:\t\t\n\t\tfor i in range(tamanho):\n\t\t\tmin+=math.factorial(min_ind)/((math.factorial(min_ind-2))*2)\n\tmin+=math.factorial(n-(min_ind*tamanho))/((math.factorial(n-(min_ind*tamanho)-2))*2)\nprint min, max\n"}, {"source_code": "n,m=map(int,input().split())\nN=n-(m-1)\nmaxi=(N-1)*N/2\nif n%m==0:\n N=n/m\n mini=m*(N-1)*N/2\nelse:\n N=(n-n%m)//(m-1)\n N_ost=n%m\n mini=(m-1)*(N-1)*N/2+(N_ost-1)*N_ost/2\nprint(int(mini),int(maxi))"}, {"source_code": "n,m = [int(x) for x in input().split()]\n\nif m==1:\n\n a = n*(n-1)\n print(a//2,a//2)\n\nelse:\n\n a = n-m+1\n b = a*(a-1)\n mx=b//2\n c = n//m\n d=n%m\n r = c*(c-1)*(m-1)\n r = r//2\n s = (c+d)*(c+d-1)\n s=s//2\n mi=r+s\n print(mi,mx)"}, {"source_code": "def ncr(n1):\n f=(n1*(n1-1))//2\n return f\n \n\nn,m=input().split(\" \")\nn=int(n)\nm=int(m)\nc=n-m\n\nMax=ncr(c+1)\ns=n//m\ns1=n%m\nd=m*(ncr(s))\nd1=s1*(ncr((s+1)))\nSum=d+d1\n\n\n\nprint(Sum,Max)\n\n\n\n "}, {"source_code": "from math import factorial\nn,m = map(int,input().split())\n\ndef ncr(n,r):\n try:\n z = (factorial(n))//(factorial(r)*factorial(n-r))\n except:\n z = 0\n return z\n\nmax = ncr(n-m+1,2)\n\nif n%m!=0:\n z = (n//m)+1\n f = m//z\n min = f*ncr(z,2) + ncr(n-f*z,2)\nelse:\n z = (n//m)\n\n min = m*ncr(z,2)\n"}, {"source_code": "n, m = map(int, input().split())\n\n\nkmax = int((n-m+1) * (n-m) / 2)\n\nif n % m == 0: # Uniformly\n kmin = int(m * ((n/m * (n/m-1)) / 2))\nelse:\n temp = int(n/m)\n team1 = n % m # How many teams have int(n/m)+1 member\n team2 = m - team1 # How many teams have int(n/m) member\n kmin1 = team1 * (((temp+1) * temp) / 2)\n kmin2 = team2 * (((temp-1) * temp) / 2)\n kmin = int(kmin1 + kmin2)\nprint(kmin, kmax)"}, {"source_code": "n,m = map(int,input().split())\nif(m==1):\n ma = n*(n-1)//2\n mi = n\nelse:\n mi = n//2\n ma = (n-m+1)*(n-m)//2\n\nprint(mi,ma)\n"}, {"source_code": "a = input().split()\nfor i in range(len(a)):\n\ta[i] = int(a[i])\nn = a[0]\nm = a[1]\npmin = (m-1)*(n//m)*(n//m - 1)//2 + (n//m + n%m)*(n//m + n%m - 1)//2\nl = n-m+1\npmax = l*(l-1)//2\nprint(pmin, pmax)\n"}, {"source_code": "n,m = map(int,input().split())\nif(m==1):\n ma = n*(n-1)//2\n mi = 2*n\nelse:\n mi = n//2\n ma = (n-m+1)*(n-m)//2\n\nprint(mi,ma)\n"}, {"source_code": "\n#\n# 478B. Random Teams\n#\n\ndef nC2(n):\n return n * (n - 1) / 2\n\ndef min_friends(n, m):\n return nC2(n / m) * (m - 1) + nC2(n / m + n % m)\n\ndef max_friends(n, m):\n return nC2(n - m + 1)\n\nn, m = map(int, raw_input().split())\n\nprint min_friends(n, m), max_friends(n, m)"}, {"source_code": "n,m=map(int,input().split())\ncount=0\nif m==1:\n count=(n*(n-1))/2\n print(str(int(count))+' '+str(int(count)))\nelif n%m==0:\n a=int(n/m)\n p=(a*(a-1))/2\n min=int(p*m) \n a=n-m\n p=((a+1)*a)/2\n max=int(p) \n print(str(min)+' '+str(max))\nelse: \n a=int(n/m)\n if a>1:\n count=(a*(a-1))/2\n a=int((n-int(n/m))/(n%m))\n p=(a*(a-1))/2\n min=int(count+(n%m)*p)\n a=n-m\n max=int(((a+1)*a)/2)\n print(str(min)+' '+str(max))"}, {"source_code": "from functools import reduce\nimport operator as op\nn,m=map(int,input().split())\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer//denom\nmaxx=ncr(n-m+1,2)\nq=n//m\nr=n%m\nminn=ncr(q+1,2)*r\nif(q>1):\n minn+=ncr(q,2)*(m-r)\nprint(minn,end='')\nprint(\" \",end='')\nprint(maxx)"}, {"source_code": "n,m = map(int, input().split())\n\nminimum = 0\nppl = n\n\nppl -= m\nppl += 1 \nminimum = (ppl*(ppl-1))//2\n\nmaximum = 0\nppl = n\n\nteam_size = (ppl//m)\nif ppl%m!=0:\n\tteam_size+=1\nteam_all = ppl//team_size\nteam_rem = ppl%team_size\n\nmaximum += (team_size*(team_size-1))//2\nmaximum*=team_all\nmaximum += (team_rem*(team_rem-1))//2\n\nprint(maximum, minimum)\n\n#Finish -->"}, {"source_code": "from collections import *\nfrom bisect import *\nfrom math import *\nfrom heapq import *\nfrom fractions import *\nimport sys\ninput=sys.stdin.readline\nt=1\ndef r(a):\n return ((a*(a-1))//2)\nwhile(t):\n t-=1\n n,k=map(int,input().split())\n q=ceil(n/k)\n re=n-(q*(n//q))\n kmin=r(q)*(n//q)\n kmin+=r(re)\n kmax=r(n-k+1)\n print(kmin,kmax)\n"}, {"source_code": "import math\nn,m=map(int,input().split())\nif n==m:\n print(0)\nelse:\n max_val=n-(m-1)\n minimum=0\n if max_val>1:\n maximum=max_val*(max_val-1)/2\n else:\n maximum=0\n l=[int(n/m) for x in range(m)]\n for i in range(n%m):\n l[i]+=1\n for i in l:\n if i==1:\n break\n if i==l[-1]:\n no=len(l)-l.index(i)\n minimum+=(i*(i-1)/2)*no\n break\n minimum+=i*(i-1)/2\n print(int(minimum),int(maximum))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Apr 3 15:16:34 2020\n\n@author: SOUVIK PAN\n\"\"\"\nn,m = map(int,input().split())\nkn=int((n-m+1)*(n-m)/2)\nif n-m>=m:\n km= int(m-1 + (n-2*m+2)*(n-2*m+1)/2)\nelse:\n km=n-m\nprint(km,kn)"}, {"source_code": "import sys\nimport math\ninput=sys.stdin.readline\ndef ncr(n):\n return((n*(n-1))//2)\nn,m=(int(i) for i in input().split())\nmi=(ncr(n//m))*(m-1)+ncr((n//m)+(n%m))\nma=ncr(n-m+1)\nprint(mi,ma)"}, {"source_code": "\nn, m = list(map(int, \"5 1\".split(\" \")))\n\n\ndef count_friends(num):\n return int(((num-1)/2)*(num))\n\n\n\n#Max\nmaxFriends = count_friends(n - (m-1))\n\n#Min\nminFriends = 0\nif n % m == 0:\n min = int(n/m)\n minFriends += count_friends(min)*m\nelse:\n roundNum = int(n/m)\n ostatok = n % m\n minFriends += count_friends(roundNum) * (m - ostatok)\n minFriends += count_friends(roundNum + 1) * ostatok\n\nprint(str(minFriends) + \" \" + str(maxFriends))\n\n\n\n"}, {"source_code": "def fac(n):\n f=1\n while n>0:\n f*=n\n n-=1\n return f\ndef ncr(n,m):\n if n<m:\n return 0\n ans=1\n for i in range(1,m+1):\n ans*=(n-i)\n return (ans//fac(m))\nn,m=input().strip().split(' ')\nn,m=(int(n),int(m))\nlist1=[1 for i in range(m)]\nr=n-m\nmx=ncr(n-m+1,2)\nif r%m==0:\n mn=m*ncr(n//m,2)\nelse:\n mn=0\n mn+=(m*ncr((1+(r//m)),2))\n if r>m:\n mn+=ncr((1+(r%m)),2)\n else:\n mn+=r*1\nprint(mn,mx)"}, {"source_code": "import math\nn,m = map(int,input().split())\n\ndef comb(num):\n\n return int((num * (num-1)) / 2)\n\nmin_pair = 0\nmax_pair = 0\n# 23 4\nmem = n\nteam = m\nif mem % team == 0 :\n min_pair = comb(int(mem/team)) * team\nelse :\n per_team = int(n / m)\n remainder = n % m\n min_pair = comb(per_team + 1) * remainder\n min_pair += comb(per_team) * (team - remainder)\n\nn = n - m + 1\nmax_pair = comb(n)\n\n\nprint('{} {}'.format(min_pair,max_pair))\n\n# 1833 195"}, {"source_code": "a, b = map(int, input().split())\nif b == 1:\n print(a*(a-1)//2, a*(a-1)//2)\nelif a == b:\n print(0, 0)\nelse:\n k = int(a // b)\n k1=a%b\n if a % b == 0:\n print((k*k-1* b)//2, (a-b)*(a - b + 1)//2)\n else:\n print(b * k*(k-1)//2 + k1 * k, (a-b+1)*(a-b)//2)\n"}, {"source_code": "n,m=map(int,input().split())\nif m==1:print(n*(n-1)//2,n*(n-1)//2)\nelse:\n minim=[n//m for i in range(m-1)]\n maxim=[1 for i in range(m-1)]\n maxim.append(n-m+1)\n minim.append(n-sum(minim))\n sum1,sum2=0,0\n for i in minim:sum1+=i*(i-1)//2\n for i in maxim:sum2+=i*(i-1)//2\n print(sum1,sum2)\n \n "}, {"source_code": "\"\"\"\n ____ _ _____\n / ___|___ __| | ___| ___|__ _ __ ___ ___ ___\n| | / _ \\ / _` |/ _ \\ |_ / _ \\| '__/ __/ _ \\/ __|\n| |__| (_) | (_| | __/ _| (_) | | | (_| __/\\__ \\\n \\____\\___/ \\__,_|\\___|_| \\___/|_| \\___\\___||___/\n\n\"\"\"\n\"\"\"\n\u2591\u2591\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\n\u2591\u2584\u2580\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2588\u2591\n\u2591\u2588\u2591\u2584\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2584\u2591\u2588\u2591\n\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2591\n\u2591\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2591\n\u2584\u2588\u2580\u2588\u2580\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2580\u2580\u2588\u2588\u2588\n\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\n\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2588\u2588\n\u2588\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\u2588\n\u2591\u2580\u2588\u2588\u2588\u2584\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2584\u2588\u2588\u2588\u2580\u2591\n\u2591\u2591\u2591\u2580\u2588\u2588\u2584\u2591\u2580\u2588\u2588\u2580\u2591\u2584\u2588\u2588\u2580\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\nimport sys\nimport math\nimport collections\nimport operator as op\nfrom collections import deque\nfrom math import gcd\n#sys.stdin = open('input.txt', 'r')\n#sys.stdout = open('output.txt', 'w')\n\nfrom functools import reduce\nfrom sys import stdin, stdout, setrecursionlimit\nsetrecursionlimit(2**20)\n\n\ndef ncr(n, r):\n r = min(r, n - r)\n numer = reduce(op.mul, range(n, n - r, -1), 1)\n denom = reduce(op.mul, range(1, r + 1), 1)\n return numer // denom # or / in Python 2\n\n\ndef isPowerOfTwo(x):\n return (x and (not(x & (x - 1))))\n\n\ndef factors(n):\n return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n\nT = 1\n# T = int(stdin.readline())\nfor _ in range(T):\n # s = str(stdin.readline().strip('\\n'))\n # a, b = list(map(int, stdin.readline().split()))\n # s = list(stdin.readline().strip('\\n'))\n # b = list(stdin.readline().strip('\\n'))\n # n = int(stdin.readline())\n # n, m = list(map(int, stdin.readline().split()))\n n, m = list(map(int, stdin.readline().split()))\n kx = ncr(n - (m - 1), 2)\n x = n // m\n y = n % m\n if x > 1:\n kn = ncr(x + 1, 2) * (y) + ncr(x, 2) * (m - y)\n else:\n kn = ncr(x + 1, 2) * (y)\n print(kn, kx)\n"}, {"source_code": "\ndef comb(n, k):\n assert k >= 0\n assert n >= k\n if k == 0:\n return 1\n res = 1\n for i in xrange(k):\n res *= (n - i)\n for i in xrange(k):\n res /= (i + 1)\n return res\n\ndef random_team(n, m):\n assert m > 0\n assert n >= m\n\n largest = n - m + 1\n if largest < 2:\n return 0, 0\n max_f = comb(largest, 2)\n av = n / m\n mo = n % m\n\n min_f = mo * comb(av + 1, 2)\n if av > 1:\n min_f = (m - mo) * comb(av, 2)\n\n return min_f, max_f\n\nif __name__ == '__main__':\n array = raw_input().strip().split()\n n = int(array[0])\n m = int(array[1])\n min_f, max_f = random_team(n, m)\n print min_f, max_f\n"}, {"source_code": "def C(n):\n if(n>=1):\n return (n*(n-1))/2\n else:\n return 0\nn1,m1=raw_input().split()\nn=int(n1);m=int(m1)\na=C(n-m+1)\nq=n/m;r=n%m\nb=((m-1)*C(q))+C(r+q)\nprint b,a\n"}, {"source_code": "\"\"\"\n ____ _ _____\n / ___|___ __| | ___| ___|__ _ __ ___ ___ ___\n| | / _ \\ / _` |/ _ \\ |_ / _ \\| '__/ __/ _ \\/ __|\n| |__| (_) | (_| | __/ _| (_) | | | (_| __/\\__ \\\n \\____\\___/ \\__,_|\\___|_| \\___/|_| \\___\\___||___/\n\n\"\"\"\n\"\"\"\n\u2591\u2591\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\n\u2591\u2584\u2580\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2588\u2591\n\u2591\u2588\u2591\u2584\u2591\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2591\u2584\u2591\u2588\u2591\n\u2591\u2588\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2591\n\u2591\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2591\n\u2584\u2588\u2580\u2588\u2580\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2580\u2580\u2588\u2588\u2588\n\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\n\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2588\u2588\n\u2588\u2588\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2588\u2588\n\u2591\u2580\u2588\u2588\u2588\u2584\u2591\u2591\u2588\u2588\u2588\u2588\u2591\u2591\u2584\u2588\u2588\u2588\u2580\u2591\n\u2591\u2591\u2591\u2580\u2588\u2588\u2584\u2591\u2580\u2588\u2588\u2580\u2591\u2584\u2588\u2588\u2580\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\"\"\"\n\nimport sys\nimport math\nimport collections\nimport operator as op\nfrom collections import deque\nfrom math import gcd\n#sys.stdin = open('input.txt', 'r')\n#sys.stdout = open('output.txt', 'w')\n\nfrom functools import reduce\nfrom sys import stdin, stdout, setrecursionlimit\nsetrecursionlimit(2**20)\n\n\ndef ncr(n, r):\n r = min(r, n - r)\n numer = reduce(op.mul, range(n, n - r, -1), 1)\n denom = reduce(op.mul, range(1, r + 1), 1)\n return numer // denom # or / in Python 2\n\n\ndef isPowerOfTwo(x):\n return (x and (not(x & (x - 1))))\n\n\ndef factors(n):\n return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n\nT = 1\n# T = int(stdin.readline())\nfor _ in range(T):\n # s = str(stdin.readline().strip('\\n'))\n # a, b = list(map(int, stdin.readline().split()))\n # s = list(stdin.readline().strip('\\n'))\n # b = list(stdin.readline().strip('\\n'))\n # n = int(stdin.readline())\n # n, m = list(map(int, stdin.readline().split()))\n n, m = list(map(int, stdin.readline().split()))\n kx = ncr(n - (m - 1), 2)\n x = n // m\n y = n % m\n if x > 1:\n kn = ncr(x + 1, 2) * (y) + ncr(x, 2) * (m - y)\n else:\n kn = ncr(x + 1, 2) * (y)\n print(kn, kx)\n"}, {"source_code": "def c2(a):\n return (a*(a-1))//2\na=list(map(int,input().split()))\nif a[0]==a[1]:\n print('0 0')\nelse:\n max=c2(a[0]+1-a[1])\n b=a[0]//a[1]\n c=a[0]%a[1]\n e=[]\n min=0\n for i in range(a[1]):\n if c!=0:\n e.append(b+c)\n c-=1\n else:\n e.append(b)\n for i in e:\n min+=c2(i)\nprint(min,end=' ')\nprint(max)"}, {"source_code": "n,m = [int(x) for x in input().split()]\n\nif m==1:\n\n a = n*(n-1)\n print(a//2,a//2)\n\nelse:\n\n a = n-m+1\n b = a*(a-1)\n mx=b//2\n c = n//m\n d=n%m\n r = c*(c-1)*(m-1)\n r = r//2\n s = (c+d)*(c+d-1)\n s=s//2\n mi=r+s\n print(mi,mx)"}, {"source_code": "import math\ndef sum(n):\n return (n*(n-1))/2\ndef main():\n n,m=map(int,input().split())\n s= m-1\n mx= sum(n-(s))\n if m == 1 :mn = mx\n else: mn= m * (((n - m) // m + 1) * ((n - m) // m)) // 2 + math.ceil((n - m) / (m)) * ((n - m) % m)\n print(f'{int(mn)} {int(mx)}')\n\n\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "import math\n\ndef Choose2(n):\n if n < 2: return 1\n f = math.factorial\n return f(n) / f(2) / f(n-2)\n\na = raw_input().split()\n\nn = int(a[0])\nm = int(a[1])\n\n\nremaining = n - m\n\n# minimum if n is evenly distributed ( > m )\nmx = Choose2(remaining+1)\n\n# maximum if t\nmnE = Choose2(round(remaining/m)+1)\n\nif mnE == 1 and n == m+1: mn = 1\nelse: mn = m * mnE\n\nprint mn, mx\n"}, {"source_code": "n, m = [int(p) for p in input().split()]\nlow, high = 0, 0\nif n < m:\n\tprint(low, high)\n\texit()\n\n# for low\ncurr = n\ncurr -= m\nif curr > 0:\n\tif curr < m:\n\t\tlow = curr\n\telif curr == m:\n\t\tlow = m\n\telse:\n\t\tcurr -= m-1\n\t\tlow += m-1 + (curr)*(curr+1)//2\n# for high\ncurr = n \ncurr -= m\nif curr > 0:\n\thigh = (curr+1)*(curr)//2\nprint(low, high)\n"}, {"source_code": "import math\nn,m=map(int, raw_input().split())\ndivceil=math.ceil(n*1.0/m)\nminiceil=n-divceil*(m-1)\nminipossceil=miniceil*(miniceil-1)/2\nminiceil=divceil\nminipossceil+=(m-1)*miniceil*(miniceil-1)/2\ndivfloor=n/m\nminipossfloor=(m-1)*divfloor*(divfloor-1)/2\nminifloor=divfloor+n%m\nminipossfloor+=minifloor*(minifloor-1)/2\nminiposs=min(minipossceil,minipossfloor)\nmaxi=n-m+1\nmaxiposs=maxi*(maxi-1)/2\nprint int(miniposs),maxiposs"}, {"source_code": "n,m = [int(x) for x in input().split()]\nif n==m:\n kmax =0\n kmin=0\nelse: \n x=(n-m+1)\n kmax = (x*(x-1))/2\n member = n//m\n remaining=n%m\n kmin=remaining*(((member+1)*(member+1-1))/2)+(m-remaining)*((member*(member-1))/2)\n \nprint(int(kmin),int(kmax)) "}, {"source_code": "import sys\n\ndef calc(n):\n if n == 1:\n return 0\n return int((n-1) * n / 2)\n\nm, n = map(int, sys.stdin.readline().split())\n\nmmin = 0\nleft = m\neach = int(m / n)\nfor i in range(n):\n if i == n-1:\n mmin += calc(left)\n else:\n mmin += calc(each)\n left -= each\n\nmmax = 0\nleft = m\nfor i in range(n):\n if i == n-1:\n mmax += calc(left)\n else:\n left -= 1\n\nprint(mmin, mmax)\n"}, {"source_code": "\na,b=map(int,input().split())\nd=a-b\nif a%2==0 and b%2==0:\n\tm=m=a//b+a%b\nelse:\t\n\tm=a//b+a%b-1\nif m!=1 and d!=1:\n\tprint((m*(m+1))//2,(d*(d+1))//2)\nelif m!=1 and d==1:\n\tprint((m*(m+1))//2,1)\nelif m==1 and d!=1:\n\tprint(1,(d*(d+1))//2)\nelse:\n\tprint(1,1)"}, {"source_code": "from math import factorial\nimport time\nn, m = map(int, input().split())\n\nif m == 1:\n kmin = kmax = factorial(n) // (factorial(2) * factorial(n - 2))\nelif m == 2:\n if n == 2:\n kmax = kmin = 0\n elif n == 3:\n kmax = kmin = 1\n else:\n if n % 2 == 0:\n kmin = 2 * factorial(n // 2) // (factorial(2) * factorial((n // 2) - 2))\n kmax = factorial(n - 1 // 2) // (factorial(2) * factorial(n - 3))\n else:\n kmin = factorial(n // 2) // (factorial(2) * factorial((n // 2) - 2)) + factorial(n // 2 + 1) // (factorial(2) * factorial((n // 2) - 1))\n kmax = factorial(n - 1 // 2) // (factorial(2) * factorial(n - 3))\n\nelse:\n x = n - m + 1\n kmax = factorial(x) // (factorial(2) * factorial(x - 2))\n y = n // m\n z = n % m\n if y == 1:\n kmin = z * (factorial(y + 1) // (factorial(2) * factorial(y - 1)))\n else:\n\n kmin = z * (factorial(y + 1) // (factorial(2) * factorial(y - 1))) + (m - z) * (factorial(y) // (factorial(2) * factorial(y - 2)))\n\nprint(kmin, kmax)\n"}, {"source_code": "'''\nsince the number of pairs in one team = C_numberOfPeople_2 (combination), and the value of that is\nbigger the bigger the pairs in a team, the maximum number will be (participants - (teams-1) )\nand the minimum will exist when the participants are evenly distibuted on the teams\n'''\n\n\np, t = [int(x) for x in input().split()]\n\ndef pairsCombinations(p, t):\n minTeam = [(p + p%t )//t for x in range(t)] \n minTeam[-1] -= sum(minTeam)-p\n maxTeam = [p-(t-1) if x == t-1 else 1 for x in range(t)]\n\n print (minTeam)\n minimum = 0\n maximum = 0\n for i in range(t):\n minimum += minTeam[i]*(minTeam[i]-1)//2 if minTeam[i] > 1 else 0 # we want pairs not 1's\n maximum += maxTeam[i]*(maxTeam[i]-1)//2 if maxTeam[i] > 1 else 0\n\n return \"%s %s\"%(minimum, maximum)\n\nprint (pairsCombinations(p, t))"}, {"source_code": "def cal(m):\n return int(m*(m+1)/2)\n\n\nn, k = map(int, input().split())\nmax = n - k + 1\nmin = int(n - 2*(k-1))\nans_max = cal(max-1)\nans_min = (cal(min-1)+k-1 if n >= 2*k else ans_max)\nprint(ans_min, ans_max)\n\n"}, {"source_code": "def cal(m):\n return int(m*(m+1)/2)\n\n\nn, k = map(int, input().split())\nmax = n - k + 1\nmin = int(n - 2*(k-1))\nans_max = cal(max-1)\nans_min = (cal(min-1)+k-1 if n >= 2*k else ans_max)\nprint(ans_min, ans_max)\n\n"}, {"source_code": "import math\n\n\ndef friends_in_team(amount):\n if amount <= 1:\n return 0\n return (amount * (amount - 1)) // 2\n\n\nn, m = (int(x) for x in input().split())\na = friends_in_team(math.ceil(n / m)) * (m - 1)\na += friends_in_team(n - math.ceil(n / m) * (m - 1))\nb = friends_in_team(n - m + 1)\nprint('{} {}'.format(min(a, b), max(a, b)))\n"}, {"source_code": "\"\"\"\nOh, Grantors of Dark Disgrace, \nDo Not Wake Me Again.\n\"\"\"\n\n# import stackprinter\n# stackprinter.set_excepthook(style='color')\n\nii = lambda: int(input())\nmi = lambda: map(int, input().split())\nli = lambda: list(mi())\nsi = lambda: input()\n\nn , m = mi()\n\nif m == 1: \n mini = maxi = n*(n-1)//2\nelse:\n q, r = divmod(n, m)\n mini = (q*(q-1)//2)*(m-1) + ((q+r)*(q+r-1)//2)\n maxi = ((n-m+1)*(n-m))//2\n\nprint(mini, maxi)\n\n\n"}, {"source_code": "n, m = map(int, input().split())\nd = n // m\nans1 = (n % m) * (d + 1) * d / 2 + (n - n % m) * d * (d - 1) / 2\nans2 = (n - m + 1) * (n - m) / 2\nprint(int(ans1), int(ans2))\n"}, {"source_code": "n,m = map(int, input().split())\nt = (n - m + 1)\nmaxx = (t*(t - 1))/2\n\nt = n // m\n\nif n%m == 0:\n minn = (t*(t - 1))/2\n minn *= m\nelse:\n t = n//m\n minn = ((t*(t - 1))/2) * (m - n%m)\n t += 1\n minn += ((t*(t - 1))/2) * (n%m)\n\n\n\n\n\n\nprint(int(minn), int(maxx) )"}, {"source_code": "n,m = map(int,raw_input().split())\nresult = []\nmax_friends= (n-m+1)*(n-m)/2\n\nmin_friends_line = m*[n/m]\nmin_result = 0\nfor i in range(n%m):\n min_friends_line[i] += 1\nfor i in range(m):\n min_result += min_friends_line[i] *(min_friends_line[i]-1)/2\n\n\n\nresult.append(max_friends)\nresult.append(min_result)\n\nprint \" \".join(map(str,result))"}, {"source_code": "def f(a):\n return sum(i for i in range(a))\n\n\nn, m = map(int, input().split())\nprint(f(n // m) * (m - 1) + f(n // m + n % m), f(n - m + 1))"}, {"source_code": "import math\nn,m = map(int,input().split())\n\ndef comb(num):\n\n return (num * (num-1)) / 2\n\nmin_pair = 0\nmax_pair = 0\n\nper_team = int(n / m)\nremainder = n % m\nmin_pair = comb(per_team + 1) * remainder\nmin_pair += comb(per_team) * (m - remainder)\n\n#n = n - m + 1\nmax_pair = comb(n - m + 1)\nif max_pair == 499000500499500032 :\n max_pair = 499000500499500000\n\nprint('{} {}'.format(int(min_pair),int(max_pair)))\n\n# 1833 195"}, {"source_code": "\nn, m = list(map(int, input().split(\" \")))\n\n\ndef count_friends(num):\n return int(((num-1)/2)*(num))\n\n\n\n#Max\nmaxFriends = count_friends(n - (m-1))\n\n#Min\nminFriends = 0\nif n % m == 0:\n min = int(n/m)\n minFriends += count_friends(min)*m\nelse:\n roundNum = int(n/m)\n ostatok = n % m\n minFriends += count_friends(roundNum) * (m - ostatok)\n minFriends += count_friends(roundNum + 1) * ostatok\n\nprint(str(minFriends) + \" \" + str(maxFriends))\n\n\n\n"}, {"source_code": "'''\nsince the number of pairs in one team = C_numberOfPeople_2 (combination), and the value of that is\nbigger the bigger the pairs in a team, the maximum number will be (participants - (teams-1) )\nand the minimum will exist when the participants are evenly distibuted on the teams\n'''\n\n\np, t = [int(x) for x in input().split()]\n\ndef pairsCombinations(p, t):\n minTeam = [(p + p%t )//t for x in range(t)] \n minTeam[-1] -= sum(minTeam)-p\n maxTeam = [p-(t-1) if x == t-1 else 1 for x in range(t)]\n\n minimum = 0\n maximum = 0\n for i in range(t):\n minimum += minTeam[i]*(minTeam[i]-1)//2 if minTeam[i] > 1 else 0 # we want pairs not 1's\n maximum += maxTeam[i]*(maxTeam[i]-1)//2 if maxTeam[i] > 1 else 0\n\n return \"%s %s\"%(minimum, maximum)\n\nprint (pairsCombinations(p, t))"}, {"source_code": "m,n=map(int,input().split())\n\nif n==1:\n mini=maxi=m*(m-1)//2\n print(mini,maxi)\nelse:\n \n maxi=m-(n-1)\n maxi=maxi*(maxi-1)//2\n if m%n==0:\n \n mini=m//n\n mini=(mini*(mini-1)//2)*n\n else:\n mini=(m//n)\n m=m%n+mini\n mini-=1\n mini+=m*(m-1)//2\n print(mini,maxi )"}, {"source_code": "import math\n\n\ndef friends_in_team(amount):\n if amount <= 1:\n return 0\n return (amount * (amount - 1)) // 2\n\n\nn, m = (int(x) for x in input().split())\na = friends_in_team(math.ceil(n / m)) * (m - 1)\na += friends_in_team(n - math.ceil(n / m) * (m - 1))\nb = friends_in_team(n - m + 1)\nprint('{} {}'.format(min(a, b), max(a, b)))\n"}, {"source_code": "def f(n):\n return n * (n - 1) // 2\n\nn, m = map(int, input().split())\nkmin = (m - 1) * f(n // m) + f(n // m + n % m)\nkmax = f(n - m + 1)\nprint(kmin, kmax)"}, {"source_code": "def f(a):\n return sum(i for i in range(a))\n\n\nn, m = map(int, input().split())\nprint(f(n // m) * (m - 1) + f(n // m + n % m), f(n - m + 1))"}, {"source_code": "import sys\nimport math\nimport collections\ninp= lambda : sys.stdin.readline()\nx,y=map(int,inp().split())\nval=math.ceil(x/y)\nrem=x%val \nct=x//val\nwhile ct<y:\n val-=1 \n rem=x%val \n ct=x//val\nprint(ct*(val-1)*val//2+rem*(rem-1)//2,(x-y+1)*(x-y)//2)"}, {"source_code": "n, m = map(int, raw_input().split())\nn_pairs = lambda a: (a**2-a) // 2\nmaxnum = n_pairs(n-(m-1))\nminnum = m * n_pairs(n//m) if n % m == 0 else (m-1)*n_pairs((n//m)+1) + n_pairs(n//m)\nprint minnum, maxnum\n"}, {"source_code": "import math\n\nn, m = map(int, input().split())\n\nc_max = n - m + 1\nc_min = math.ceil(n/m)\n\n# print(c_min, c_max)\n\n\ndef s(i):\n return round((i*(i-1))/2)\n\n\nk_max = s(c_max)\n\n\nif n % m:\n k_min1 = s(c_min)*(m-1)\n k_min1 += s(n % c_min)\n\n c_min = math.floor(n/m)\n k_min2 = s(c_min)*(m-1)\n k_min2 += s(c_min + (n % m))\n k_min = min(k_min1, k_min2)\nelse:\n k_min = s(c_min)*m\n\nprint( k_min, k_max )"}, {"source_code": "n, m = map(int, input().split())\nst = n//m\nre = n%m\nminim = ((m-1)*((st*(st-1))//2))+(((st+re)*(st+re-1))//2)\nmaxim = (((n-m+1)*(n-m))//2)\nprint(minim, maxim)"}, {"source_code": "n, m = map(int, raw_input().strip().split())\n\nimport math\n\nif m == 1:\n minn = maxx = n*2\n print minn, maxx\n exit()\n\nlish = m-1\nmaxx = math.factorial(n-lish)/(2*math.factorial(n-lish-2))\n\ndell = n/m\nost = n%m\nif dell > 1:\n minn = (math.factorial(dell + 1)/(2*math.factorial(dell+1-2)))*ost + (m-ost)*(math.factorial(dell)/(2*math.factorial(dell-2)))\nelse:\n minn = (math.factorial(dell + 1)/(2*math.factorial(dell+1-2)))*ost\n\nprint minn, maxx"}, {"source_code": "n,m=map(int,input().split())\ncount=0\nif m==1:\n for i in range(1,n):\n count=count+i\n print(str(count)+' '+str(count))\nelif n%m==0:\n a=int(n/m)\n p=0\n for i in range(1,a):\n p=p+i\n min=p*m \n a=n-m\n p=0\n for i in range(1,a+1):\n p=p+i\n max=p \n print(str(min)+' '+str(max))\nelse: \n a=int(n/m)\n if a>1:\n for i in range(1,a):\n count=count+i\n a=n%m\n if(n-m==1):\n a=a+1\n p=0\n for i in range(1,a):\n p=p+i\n min=count+(m-1)*p\n a=n-m\n p=0\n for i in range(1,a+1):\n p=p+i\n max=p\n print(str(min)+' '+str(max))"}, {"source_code": "n, m = list(map(int, input().split()))\n\nt = n-(m-1)\nmax = (t*(t-1))//2\n\nt = n//m\nr1 = (t*(t-1))//2\nmin=r1*m\n\nif n%m==0:\n min = min\nelse:\n min +=n%m\nprint(min,max)\n\n\n# n, m = list(map(int, input().split()))\n# t = n//m\n#\n# r = (t*(t-1))//2\n# print(r,r)\n\n# if m==1:\n# t = n\n# r = (t*(t-1))//2\n# print(r,r)\n# else:"}, {"source_code": "def fact(n):\n dp=[0]*(n+1)\n \n dp[0]=1\n if n==1:\n return 1 \n \n for i in range(1,n+1):\n \n dp[i]=i* dp[i-1]\n \n return dp[n]\n\ndef nCr(n,r):\n return fact(n)/(fact(n-r)*fact(r))\n\n\nn,m= input().split()\nn= int(n)\nm= int(m)\nif m==1:\n minpair= nCr(n-m+1,2)\nelif n%2==0 and n>6:\n t=n//2\n \n minpair= 2*nCr(t,2)\nelif n<6 and n%2==0 :\n minpair= nCr(n//2,2)\nelif n%2!=0 and (n-1)//2>m:\n t= (n-1)//2\n minpair= nCr(t,2)\nelse:\n minpair= n//2\nmaxpair= nCr(n-m+1,2)\n\nprint(int(minpair), int(maxpair))\n\n\n"}, {"source_code": "n,m=map(int,raw_input().split())\nkmin,kmax=0,0\nif n%m==0:\n kmin=m*((n/m)*(n/m-1)/2)\nelse:\n kmin=(m-n%m)*((n/m)*(n/m-1)/2)\n x=n/m+(n%m)\n kmin+=(n%m)*x*(x-1)/2\nx=n-(m-1)\nkmax=x*(x-1)/2\nif kmin>kmax:\n t=kmin\n kmin=kmax\n kmax=t\nprint kmin,kmax"}, {"source_code": "import math\nparticipantes, times = map(int, raw_input().split())\ncont = 0\n\n\nmaior = (participantes - (times -1))\ny = math.ceil(participantes/float(times))\nx = math.floor(participantes/float(times))\nmenor = participantes%times\n\nprint y, x, menor\n\nfor v in range(menor):\n cont = cont + (((y-1)*y)/2)\n print cont\nfor i in range(times - menor):\n cont = cont + ((x-1)*x)/2\n print cont\n\nmaximo = ((maior -1)*maior)/2\n\n\nprint int(cont), maximo\n"}, {"source_code": "import math\nparticipantes, times = map(int, raw_input().split())\ncont = 0\n\n\nmaior = (participantes - (times -1))\ny = math.ceil(participantes/float(times))\nx = math.floor(participantes/float(times))\nmenor = participantes%times\n\nprint y, x, menor\n\nfor v in range(menor):\n cont = cont + (((y-1)*y)/2)\n print cont\nfor i in range(times - menor):\n cont = cont + ((x-1)*x)/2\n print cont\n\nmaximo = ((maior -1)*maior)/2\n\n\nprint int(cont), maximo\n"}, {"source_code": "n, m = map(int, input().split())\nif m == 1:\n\tprint(n*(n - 1) // 2, n*(n - 1) // 2)\nelif n == m:\n\tprint(1, 1)\nelse:\n\tkmin = 0\n\tr = n // m\n\tkmin = (m - 1)*r*(r - 1) // 2 + (r + n % m)*((r + n % m)- 1) // 2 \n\tkmax = (n - m + 1)*(n - m) // 2\n\tprint(kmin, kmax)"}, {"source_code": "n,m=map(int,raw_input().split())\na=[]\nx=0\nif n%m==0:\n\tsz=(n/m)\n\tx=((sz*(sz-1))/2)*m\nelse:\n\tsz=n/m\n\txsz=n%m\n\tx=(((sz+1)*(sz))/2)*(xsz) + ((sz*(sz-1))/2)*(n-xsz)\na.append(x)\nx=(n-(m-1))\na.append( ((x*(x-1))/2) )\nprint min(a),max(a)"}, {"source_code": "#------------------------------what is this I don't know....just makes my mess faster--------------------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math\n\nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#----------------------------------Real game starts here--------------------------------------\nn,m = list(map(int, input().split()))\ndef binom(n,k): # better version - we don't need two products!\n if not 0<=k<=n: return 0\n b=1\n for t in range(min(k,n-k)):\n b*=n; b/=t+1; n-=1\n return int(b)\n# mini = (m-(n % m))*math.factorial(n//m)/math.factorial(n//m-2)/2 + (n % m)*math.factorial(n//m+1)/math.factorial(n//m-1)/2\n# maxi = math.factorial(n-m+1)/math.factorial(n-m-1)/2\nmini = (m-(n % m))*binom(n//m,2) + (n % m)*binom(n//m+1,2)\nmaxi = binom(n-m+1,2)\nprint(mini)\nif maxi==499000500499500032:\n print(499000500499500000)\nelse:\n print(maxi)"}], "src_uid": "a081d400a5ce22899b91df38ba98eecc"} {"source_code": "n=int(input())\nc=0\nfor i in range(1,n//2+1):\n if n%i==0:\n c=c+1\nprint(c) ", "positive_code": [{"source_code": "n=int(input())\ncount=0\nfor i in range(1,n):\n nol=i\n if(n-nol)%nol==0:\n count+=1\n \nprint(count)"}, {"source_code": "e = int(input())\n\nw = 0\nfor _ in range(1,e):\n\tif _ > e//2:\n\t\tbreak\n\telif ((e - _) % _ )==0:\n\t\tw += 1\n\nprint(w)\n"}, {"source_code": "n = int(input())\nans = 0\nfor i in range(1, (n // 2) + 1):\n if (n - i) % i == 0:\n ans += 1\nprint(ans)"}, {"source_code": "n=int(input())\n# c=0\n# for i in range(1,n):\n# for j in range(1,n):\n# if (i*j)+i==n:\n# c+=1\n# break\n# print(c)\nc=0\nfor i in range(1,int(n/2)+1):\n if n%i==0:\n c+=1\nprint(c)\n# i=1\n# while i<n:\n# j=1\n# while j<n:\n# if (n-i)%i==0:\n# c+=1\n# print(i,j,'as')\n# break\n# j+=1\n# print(i,j)\n# i+=1\n# print(c)\n"}, {"source_code": "# Problem URL: https://codeforces.com/problemset/problem/935/A\n\nn = int(input())\nc = 0\nfor i in range(1,n):\n if n%i == 0:\n c+=1\nprint(c)"}, {"source_code": "# Problem URL: https://codeforces.com/problemset/problem/935/A\n\nn = int(input())\nc = 0\nfor i in range(1,n):\n if (n-i)%i == 0:\n c+=1\nprint(c)"}, {"source_code": "n=int(input())\ncount=0\nfor i in range(1,(n//2)+2):\n d=n-(i)\n if(d%i==0 and d>0):\n count=count+1\nprint(count)"}, {"source_code": "n = int(input())\ncnt = 0\nfor i in range(1,(n//2)+1):\n if (n-i)%i == 0:\n cnt += 1\nprint(cnt)\n "}, {"source_code": "n = int(input())\nres = 0\nfor i in range(1, n):\n if (i * ((n//i)-1)) + i == n:\n res += 1\nprint(res)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Apr 1 11:41:01 2020\n\n@author: prana\n\"\"\"\n\nn=int(input())\nw=0\nfor i in range(1,(n//2)+1):\n \n \n \n if (n-i)% i==0:\n \n w+=1\nprint(w)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Apr 1 11:41:01 2020\n\n@author: prana\n\"\"\"\n\nn=int(input())\nw=0\nfor i in range(1,n):\n \n \n \n if (n-i)% i==0:\n \n w+=1\nprint(w)"}, {"source_code": "n = int(input())\ncount = 0\n\nfor i in range(1, (n + 1) // 2 + 1):\n if (n - i) % i == 0:\n count += 1\n\nprint(count)"}, {"source_code": "n=int(input())\ncnt=0\nfor i in range(1,int(n/2)+1):\n \n if(n%i==0):\n cnt+=1\n \n \nprint(cnt)"}, {"source_code": "num=int(input(''))\nfactors=[]\nfor i in range(1,num):\n if num%i==0:\n factors.append(i)\n\n#print (\"Factors of {} = {}\".format(num,factors))\nprint(factors.__len__())\n"}, {"source_code": "n=int(input())\nc=0\nif(n%2==0):\n c+=1\nif(n%3==0):\n c+=1\nif n>3:\n for i in range(4,n+1):\n if(n%i==0):\n c+=1\nprint(c)"}, {"source_code": "n=int(input())\np=0\nfor i in range(1,n//2+1):\n if ((n-i)%i)==0:\n p+=1\nprint(p)"}, {"source_code": "n = int(input())\nc = 0\nfor i in range(1, n // 2 + 1):\n if (n % i == 0):\n c += 1\nprint(c)"}, {"source_code": "from sys import stdin\n_input = stdin.readline\n_range, _int = range, int\ndef solution():\n n = _int(_input())\n s = 0\n for i in _range(1,n):\n if (n - i) % i == 0:\n s += 1\n print(s)\nsolution()"}, {"source_code": "n=int(input())\nx=0\nfor i in range(1,n):\n if n%i==0:\n x+=1\nprint(x)\n"}, {"source_code": "n = int(input())\nl = 0\ncount=0\nfor i in range(1,n):\n if(n%i==0):\n count+=1\nprint(count)\n"}, {"source_code": "class FafaHisCompany:\n def solve(self,n):\n count = 0\n for x in range(1,n+1):\n if (n-x)%x==0 and n-x>0:\n count+=1\n return count\nif __name__ == \"__main__\":\n n = int(raw_input())\n fhc = FafaHisCompany()\n print fhc.solve(n)"}, {"source_code": "import bisect\nfrom collections import defaultdict\nfrom collections import deque\nimport math\nimport re\nimport sys\nimport itertools\n\ndef ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\ndef si():\n return raw_input()\n\ndef sis():\n return raw_input().split()\n\ndef spaced(a):\n return ' '.join(map(str, a))\n\nn = ni()\n\ncount = 0\nfor x in range(2, int(math.sqrt(n)) + 1):\n if not n % x:\n if n / x == x:\n count += 1\n else:\n count += 2\n\nprint count + 1"}, {"source_code": "from math import sqrt\n\nn = int(raw_input())\ncount = 0\n\nfor i in range(2, int(sqrt(n))+1):\n\tif n % i == 0:\n\t\tcount += 1\n\nif int(sqrt(n))**2 == n and n != 2 and n != 3:\n\tprint(2*count)\n\nelse: \n\tprint(2*count + 1)\n \n"}, {"source_code": "n = int(input())\ni = 1\nresult = 0\nwhile i**2 <= n:\n\tresult += 2*(n%i==0)-(i**2==n)\n\ti += 1\nprint(result-1)"}, {"source_code": "import math\nr = raw_input()\nr = int(r)\n\nd = {}\n\nx = 2\nwhile x<=math.sqrt(r):\n\tif r%x==0:\n\t\tif x in d:\n\t\t\td[x]+=1\n\t\telse:\n\t\t\td[x]=1\n\t\tr/=x\n\telse:\n\t\tx+=1\n\nif r!=1:\n\tif r in d:\n\t\td[r]+=1\n\telse:\n\t\td[r]=1\n\nprod = 1\nfor i in d.values():\n\tprod*=(i+1)\n\nprint prod-1\n\t"}, {"source_code": "from __future__ import print_function\n\nn = int(raw_input())\nnr = 0\n\nfor i in xrange(1, n / 2 + 1):\n if n % i == 0:\n nr += 1\n\nprint(nr)\n"}, {"source_code": "count = 0\nn = int(input())\nfor i in range(1, n):\n if(n % (i+1) == 0):\n count += 1\nprint(count)"}, {"source_code": "n=int(raw_input())\nv=0\nk=1\nwhile k != n :\n if n%k == 0:\n v+=1\n k+=1\nprint(v)\n"}, {"source_code": "# https://codeforces.com/problemset/problem/935/A\n\nimport math\n\ndef number_of_divisors(num):\n total_divisors = 0\n for index in xrange(1, num + 1):\n if num % index == 0:\n total_divisors += 1\n return total_divisors\n\n\ndef main():\n number_of_employees = int(raw_input())\n possible_team_leader_combination = number_of_divisors(number_of_employees) - 1\n print possible_team_leader_combination\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n=int(input())\ncount=0\nfor i in range(1,n):\n\tif(n%i==0):\n\t\tcount=count+1\nprint(count)"}, {"source_code": "i = int(input())\nl = 0\nfor x in range(1,100001):\n if i%x == 0:\n l += 1\nprint((int(l)-1))"}, {"source_code": "n=input()\nprint len([i for i in xrange(1,n/2+1) if n%i==0])\n"}, {"source_code": "n = int(raw_input())\nans = 0\n\nfor l in range(2, n + 1):\n\tif n % l == 0: \n\t\tans += 1\nprint(ans)"}, {"source_code": "n = int(raw_input())\nc = 0\nfor i in range(1,n+1):\n x = (n-i)\n if x and x%i==0:\n c+=1\nprint(c)\n"}, {"source_code": "import math\nn = int(input())\nways = 0\nfor i in range(1, (n//2)+1):\n if (n-i)%i == 0:\n ways += 1\nprint(ways)\n"}, {"source_code": "if __name__ == \"__main__\":\n\n s = int(input())\n\n count = 0\n\n for i in range(s):\n temp = s-(i+1)\n if temp%(i+1) == 0:\n count+=1\n\n print(count-1)\n\n\n\n \n"}, {"source_code": "a = int(raw_input())\nans = 0\nfor i in xrange(1,a):\n\tb = a-i\n\tif b%i==0 and b>=1:\n\t\tans+=1\nprint ans"}, {"source_code": "n = int(raw_input())\ncount = 0\n\nfor i in xrange(1, n):\n if (n-i) % i == 0:\n count += 1\n\nprint count\n"}, {"source_code": "def solve(test):\n n = int(input())\n ans = 0\n for i in range(1, n):\n if n % i == 0:\n ans += 1\n print(ans)\nt = 1\nfor _ in range(t):\n solve(_ + 1)"}, {"source_code": "n = input()\ns = 1\nfor i in xrange(2,n):\n if n%i == 0:\n s+=1\nprint s"}, {"source_code": "n = input()\nc = 0\nfor i in range(1, n):\n if (n - i) % i == 0: c += 1\nprint c\n"}, {"source_code": "n = int(input())\nans = 0\nfor i in range(1, n):\n if (n) % i == 0:\n ans += 1\nprint(ans)"}, {"source_code": "emp = int(input())\nopt = 0\nfor i in range(1,emp):\n if i == 1:\n opt += 1\n continue\n bosses = i\n employees = emp - i\n if bosses <= employees and employees % bosses == 0:\n opt += 1\nprint(opt)\n"}, {"source_code": "n = int(input())\nans = 0\nfor i in range(1,n):\n\tif n % i == 0:\n\t\tans += 1\nprint(ans)\n"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline().strip())\n\nways = 0\n\nprint(len(list(filter(lambda x: n % x == 0, range(1, n // 2 + 1)))))\n"}, {"source_code": "def check(number):\n count=0\n for l in range(1,number):\n if (number-l)%l==0:\n count=count+1\n return count\nnumber=int(input())\nprint(check(number))"}, {"source_code": "import math\nn = int(input())\n\nconteo = 1\nfor i in range(2, math.ceil(math.sqrt(n))):\n if n % i == 0:\n conteo += 2\n\nif math.sqrt(n) == int(math.sqrt(n)):\n conteo += 1\n\nprint(conteo)\n"}, {"source_code": "n=int(input())\nres=1\nk=int(n/2)\nfor i in range(2,n):\n if(n%i==0):\n res+=1\nprint(res)"}, {"source_code": "n = int(input())\ns = 0\nif 2<=n<=100000:\n for i in range(1,n):\n if n%i == 0:\n s+=1\nprint(s)\n"}, {"source_code": "from itertools import takewhile\n\nn = int(input())\n\ncount = 0\n\ncount = sum([1 for i in takewhile(lambda i: n // i > 1, range(1, n)) if n % i == 0 ])\n\nprint(count)"}, {"source_code": "n = input()\nn = int(n)\naux = 1\n\nfor i in range(2,n):\n\n if n%i == 0:\n aux = aux+1\n else:\n continue\n\nprint(aux)"}, {"source_code": "n = int(input())\n\nprint(sum(n % d == 0 for d in range(2, n + 1)))\n"}, {"source_code": "#!/bin/python3\n\np= int(input())\nq= p//2\ns=0\ni=1\nwhile i!=q+1:\n r = (p-i)//i\n if (r*i) +i==p:\n s=s+1\n \n i=i+1\n\nprint(s)\n\n\n"}, {"source_code": "n = int(raw_input())\n\nstart = n/2\nanswer = 1\n\nwhile(start!=1):\n\tif(n%start==0):\n\t\tanswer+=1\n\tstart-=1\n\nprint answer\n"}, {"source_code": "from __future__ import division\n\nn = int(raw_input())\ni = 0\nc = 0\nwhile i < n:\n i += 1\n n -= 1\n if (n/i).is_integer():\n c += 1\nprint c"}, {"source_code": "answer = 0\nn = int(input())\nfor i in range(2, n+1):\n if n % i == 0:\n answer += 1\nprint(answer)"}, {"source_code": "n = int(raw_input())\n\nres = 0\nfor i in range(1, n):\n\tif n%i==0:\n\t\tres += 1\n\t\t\nprint res"}, {"source_code": "import sys\n\nf = sys.stdin\nn = int(f.readline())\nans = 0\nfor i in xrange(1, 1 + n / 2):\n k = n - i\n if k % i == 0:\n ans += 1\nprint ans\n\n"}, {"source_code": "n = int(input())\nans = 0\nfor i in range(1,n):\n\trem = n-i;\n\tif(rem%i == 0):\n\t\tans += 1;\nprint ans;"}, {"source_code": "# import sys\n# sys.stdin=open(\"test11.in\",\"r\")\n# sys.stdout=open(\"test11.out\",\"w\")\n\nn=int(input())\ncount=0\nfor i in range(1,n):\n\tif((n-i)%i==0):\n\t\tcount+=1\n\telse:\n\t\tpass\nprint(count)\n\n"}, {"source_code": "n = int(raw_input());print len([1 for x in xrange(2, n) if n%x==0]) + 1\n"}, {"source_code": "n = int(input())\ncount = 0\nfor i in range(1, n):\n if not n % i:\n count += 1\nprint(count)"}, {"source_code": "n = input()\nsum = 0\n\nfor i in range(1,n/2+1):\n if ( n - i )%i == 0 :\n sum += 1\n\nprint sum\n"}, {"source_code": "n = int(raw_input())\ni = 1\nans = 0\nwhile i * i <= n:\n if (n % i == 0):\n ans += 1\n if n // i != i:\n ans += 1\n i += 1\nprint ans - 1\n"}, {"source_code": "INF = 999999999999999999L\nEPS = 1e-12\n\ndef read():\n return raw_input().strip()\n\ndef read_ints():\n return map(int,read().split())\n\nn = int(read())\nans = 0\nfor i in range(1,n):\n if n%i == 0:\n ans += 1 \nprint ans\n"}, {"source_code": "n=input()\nans=0\nfor i in range(1,n):\n if n%i==0:\n ans=ans+1\nprint(ans)\n"}, {"source_code": "n = int(raw_input())\nresult = 0\nfor i in range(1,n):\n\tleaders = i\n\temployees = n - leaders\n\tif employees % leaders == 0:\n\t\tresult += 1\n\nprint result"}, {"source_code": "import sys\nimport Queue\n\nn, = map (int, sys.stdin.readline().split (' '))\nans = 0\nfor i in range (1, n):\n if n%i == 0:\n ans += 1\nprint ans\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "t = int(input())\nc =0\nfor i in range(1,t//2+1):\n if (t-i)%(i) ==0:\n c +=1\nprint(c)\n"}, {"source_code": "n = int(raw_input())\nans = 1\nfor i in range(2, int(n ** .5) + 1):\n if n % i == 0:\n ans += 2\nx = int(n ** .5)\nprint ans - 1 if x * x == n else ans\n"}, {"source_code": "n=input()\nprint sum(n%i==0 for i in range(1, n))"}, {"source_code": "def divisors_under(m):\n count=0\n for r in range(1,m//2+1):\n if m%r==0:\n count+=1\n return count\n\na=int(input())\nprint(divisors_under(a))"}, {"source_code": "n = int(input())\ncount = 0\nt = int(n/2+1)\nfor i in range(1, t):\n if i == 1:\n count += 1\n else:\n j = n - i\n if j % i == 0:\n count += 1\n else:\n continue\nprint(count)"}, {"source_code": "n = int(input())\ntemp = n\nw = (int((n/2))+1)\ncount=0\nfor i in range(1,w):\n n = n - i\n w = int(n/i)\n if(w == n/i):\n count+=1\n n = temp\n \nprint(count)\n\n"}, {"source_code": "n=int(input())\nc=1\nif(n==1):\n c=0\nfor i in range(2,n//2+1):\n s=n-i;\n \n if(s%i==0 and s!=0):\n c=c+1\nprint(c) "}, {"source_code": "def driver(f):\n counter = 0\n for i in range(1, f):\n if f % i == 0:\n counter+=1\n print(counter)\n\n\ndef main():\n for i in range(1):\n driver(int(input()))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n = int(input())\nans = 0\nfor i in range(1, n):\n if (n - i) % i == 0:\n ans += 1\nprint(ans)"}, {"source_code": "n = int(input())\nw = 0\nfor i in range(1, n//2+1):\n if n % i == 0:\n w += 1\nprint(w)"}, {"source_code": "n = int(input())\ni = 1\ncount = 0\nwhile i**2 <= n:\n if n % i == 0:\n if i**2 == n or i == 1:\n count = count + 1 \n else:\n count = count + 2\n i += 1\nprint(count)\n"}, {"source_code": "\nn,i,c=int(input()),2,1\nwhile i*i<n:\n if n%i==0:c+=2\n i+=1\nif i*i==n:c+=1\nprint(c)\n \n# n = int(input())\n# i = 2\n# count = 1\n# while i**2 < n:\n # if n % i == 0:\n # count += 2\n # i += 1\n# if i**2 == n: count += 1 \n# print(count)\n"}, {"source_code": "n = int(input())\nk = n\nchoices = 0\ni = 1\n\nwhile i < n:\n\ttemp = int(n / i)\n\tif temp * i == k:\n\t\tchoices += 1\n\ti += 1\nprint(choices)\n"}, {"source_code": "answer = 1\nn = int(input())\nfor i in range(2,n):\n if (n - i) % i == 0:\n answer += 1\n \nprint(answer)"}, {"source_code": "n = int(input())\ns = 0 \nfor A in range(1,n//2 +1): \n if (n-A) % A == 0: \n s+=1\nprint(s) "}, {"source_code": "\"\"\"\nmake_divisors(16)\n# [1, 16, 2, 8, 4\\]\n\"\"\"\n\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n ** 0.5) + 1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n // i)\n # divisors.sort()\n return divisors\n\n\"\"\"\nmake_divisors_without_own(16)\n[2, 8, 4]\n\"\"\"\n\ndef make_divisors_without_own(n):\n r = make_divisors(n)\n r.remove(1)\n r.remove(n)\n return r\nn = int(input())\nl = len(make_divisors_without_own(n)) + 1\nprint(l)"}, {"source_code": "n = int(input())\nres = 0\nfor i in range(1, n):\n res += 1 if n % i == 0 else 0\nprint(res)\n"}, {"source_code": "n = int(input())\nliste = []\nfor i in range(2,n+1):\n\tif n % i == 0:\n\t\tliste.append(i)\n\nprint(len(liste))"}], "negative_code": [{"source_code": "# task 1\nn = int(input())\n\ncount_of_dividers = 0\nfor i in range(n - 1, 1, -1):\n if (n % i == 0):\n count_of_dividers += 1\n\nprint(count_of_dividers - 1)"}, {"source_code": "#!/usr/bin/python3\n\nn = int(input())\ntotal = 0\n\nif n%2 == 0:\n\ttotal += 1\n\ttmp = n\n\tif ((tmp - 1)%3) == 0:\n\t\ttotal += 1\n\tif n%5 == 0:\n\t\ttotal += 1\nelse:\n\ttotal += 1\n\tif n%3 == 0:\n\t\ttotal += 1\nprint(total)\n\n'''\nhttps://codeforces.com/problemset/problem/935/A\n'''\n"}, {"source_code": "n=int(input())\nk=0;\nfor i in range(1,n+1):\n if((n-i)/i==0):\n k=k+1;\nprint(k)"}, {"source_code": "n = int(input())\nif 2<n<100000:\n for i in range(1,n):\n if n%i == 0:\n print(i)\n"}, {"source_code": "import math\n\n\ndef count_factors(n):\n c=1\n for i in range(2,math.ceil(math.sqrt(n))):\n if n%i==0:\n c+=2\n return c\n\nprint(count_factors(int(input())))"}, {"source_code": "# import sys\n# sys.stdin=open(\"test11.in\",\"r\")\n# sys.stdout=open(\"test11.out\",\"w\")\n\nn=int(input())\ncount=0\nfor i in range(1,n+1):\n\tif((n-1)%i==0):\n\t\tcount+=1\nprint(count)\n\n"}, {"source_code": "i = int(input())\nl = 0\nif i%2 == 0:\n l = i/2\nelse:\n l = i/2 - 1\n\nprint(l)"}, {"source_code": "def empdiv(n):\n count = 0\n l = 0\n i = 1\n while i <= n / 2:\n if (n - i) % i == 0:\n count += 1\n i += 1\n return count\n\nn = input(\"Number of employee:\")\nn = int(n)\nprint(empdiv(n))"}, {"source_code": "n = int(input())\nc = 1\nfor i in range(2, n//2+1):\n if (n-i)%i==0:\n print(i)\n c += 1\nprint(c)"}, {"source_code": "n=int(input())\nj=1\nif n%2==0:\n for i in range(2,n//2):\n if (n-i)%2==0:\n j+=1\nprint(j)"}, {"source_code": "n=int(input())\nprint(n//2)"}, {"source_code": "if __name__ == \"__main__\":\n\n s = int(input())\n\n count = 1\n\n if s%2 != 0:\n print(count)\n else: \n for i in range(s//2):\n temp = s-(i+1)\n if temp%(i+1) == 0:\n count+=1\n\n print(count-1)\n\n\n\n \n"}, {"source_code": "n=int(input())\nj=1\nif n%2==0:\n for i in range(1,n//2):\n if (n-i)%2==0:\n j+=1\nprint(j)"}, {"source_code": "import math\n\ndef is_prime(n):\n for i in range(2,int(math.sqrt(n))+1):\n if n%i == 0:\n return False\n\n return True\n\nx = int(input())\n\nif x==6:\n print(3)\nelif x==100000:\n print(35)\nelif is_prime(x):\n print(1)\nelse:\n print(int(math.sqrt(x)))\n\n"}, {"source_code": "n=int(input())\ni=1\nsum1=0\ncount=0\nwhile(sum1<n):\n sum1+=i\n i+=1\n if sum1<n:\n count+=1\nif count==0:\n print(1)\nelse:\n print(count)\n "}, {"source_code": "def inp():\n k = input()\n return int(k)\n\ndef f1(n):\n ans = 0\n for i in xrange(1,n-1):\n\tif n % i == 0:\n\t ans += 1\n print ans\n\nf1(inp())\n"}, {"source_code": "from math import sqrt\n\nn = int(input())\ncount = 1\nfor i in range(2,int(sqrt(n))):\n if n%i == 0:\n if n == i*i:\n count += 1\n else:\n count += 2\nprint(count)\n"}, {"source_code": "n = int(input())\nif n == 2:\n print(1)\nelif n>2:\n if n%2==0:\n count = 0\n while n%2==0 and n!=2:\n count+=1\n n/=2\n print(2+count)\n elif n%2==1:\n print(1)"}, {"source_code": "n = input()\nres = 0\nif n ==1 or n==2:\n print \"1\"\n exit()\nelif n % 2!=0:\n print \"2\"\n exit()\nelse:\n for i in range(1,n):\n if n%i==0:\n res +=1\n print res\n \n"}, {"source_code": "n_employees = int(raw_input())\n\nleaders, pawns = n_employees - 1, 1\nanswer = 1\n\nfor i in range(n_employees / 2):\n leaders -= 1\n pawns += 1\n \n if leaders % pawns == 0:\n answer += 1\n\nprint answer\n \n \n \n \n \n"}, {"source_code": "n = int(input())\nif n == 2:\n print(1)\nelif n>2:\n if n%2==0:\n print(3)\n elif n%2==1:\n print(2)"}, {"source_code": "n = int(input())\nk = 0\nfor i in range(1,n-1):\n if n % i == 0:\n k+=1\nprint(k)\n"}, {"source_code": "from math import sqrt\n\nn = int(input())\ncount = 1\nfor i in range(2,int(sqrt(n))):\n if n%i == 0:\n if n == i*i:\n count += 1\n else:\n count += 2\nprint(count)\n"}, {"source_code": "n=int(input())\ncount=0\nfor i in range(2,9):\n if(n%i==0):\n count=count+1\nprint(count+1)"}, {"source_code": "n = int(input())\nchoices = 0\ntemp = 0\ni = 1\nwhile n != 0:\n\ttemp = n // i\n\tprint(i)\n\tprint(\"temd \", temp)\n\n\tif temp * i == 10:\n\t\tprint(\"idd\", temp)\n\t\tchoices += 1\n\tn -= 1\n\ti += 1\n\nprint(\"asfasf\", choices)\nprint(temp)\n\n\n"}, {"source_code": "import math\nn = int(input())\n\nconteo = 1\nfor i in range(2, int(math.sqrt(n))):\n if n % i == 0:\n conteo += 2\nprint(conteo)\n"}, {"source_code": "n = int(input())\nc1=0\nif n%2==0:\n\tfor i in range(1,(n//2)+1):\n\t\tif ((n-i)%i)==0:\n\t\t\tc1+=1\n\tprint(c1)\nelse:\n\tprint(1)"}, {"source_code": "import math\n\ndef is_prime(n):\n for i in range(2,int(math.sqrt(n))+1):\n if n%i == 0:\n return False\n\n return True\n\nx = int(input())\nif is_prime(x):\n print(1)\nelse:\n print(int(math.sqrt(x)))\n\n"}, {"source_code": "e = int(input())\nw = 0\ni = 1\nx = e//2\nif e <=3:\n\tw = 1\nelse:\n\twhile i <= (e//2)//2:\n\t\tif ((e - i) % i)==0:\n\t\t\tw+=1\n\t\tif ((e - x) % x)==0:\n\t\t\tw+=1\n\t\ti+=1\n\t\tx-=1\n\nprint(w)"}, {"source_code": "n=int(input())\nres=1\nif n %2 !=0 :\n print(res)\nflag=2\nif n %2 ==0 :\n res2=1\n while flag<10**5 :\n flag=flag+1\n if n %flag==0 :\n res2=res2+1\n print(res2)\n "}, {"source_code": "n = int(input())\ni = 1\nk = 0\nwhile i <= n:\n if n % i == 0:\n k = k + 1\n i = i + 1\nprint(k)\n\n\n"}, {"source_code": "import math\nn=int(input())\ns=0\nc=math.sqrt(n)\nd=math.ceil(c)\nfor i in range(d-1):\n s+=1\nprint(s)\n"}, {"source_code": "import math\n\n\ndef count_factors(n):\n c=1\n for i in range(2,math.ceil(math.sqrt(n))):\n if n%i==0:\n c+=2\n return c\n\nprint(count_factors(int(input())))"}, {"source_code": "n = int(input())\nchoices = 0\ntemp = 0\ni = 1\nwhile n != 0:\n\ttemp = n // i\n\tif temp * i == 10:\n\t\tchoices += 1\n\tn -= 1\n\ti += 1\n\nprint(choices)\n\n\n"}, {"source_code": "import math\n\n\ndef count_factors(n):\n c=0\n for i in range(2,math.ceil(math.sqrt(n))+1):\n if n%i==0:\n if i!=(n//i):\n c+=2\n else:\n c+=1\n return (c+1)\n\nn=int(input())\nif int(math.log(n,2))==math.log(n,2):\n print(int(math.log(n,2)))\nelse:\n print(count_factors(n))"}, {"source_code": "import math\n\n\ndef count_factors(n):\n c=0\n for i in range(2,math.ceil(math.sqrt(n))+1):\n if n%i==0:\n if i!=(n//i):\n c+=2\n else:\n c+=1\n return (c+1)\n\nn=int(input())\nif int(math.log(n,2))==math.log(n,2):\n print(int(math.log(n,2)))\nelse:\n print(count_factors(n))"}, {"source_code": "def empdiv(n):\n count = 0\n l = 0\n i = 1\n while i <= n / 2:\n if (n - i) % i == 0:\n count += 1\n i += 1\n return count\n\nn = input(\"Number of employee:\")\nn = int(n)\nprint(empdiv(n))"}, {"source_code": "n = int(input());cnt=1\nfor i in range(1,n//2):\n if n%i == 0:\n cnt+=1\nprint(cnt)"}, {"source_code": "n = int(input())\nif(n==1):\n print(0)\n exit()\nif(n%2!= 0):\n print(1)\nelse:\n c= 0\n for i in range(1,n):\n x= n-i\n if(x%i==0):\n c+=1\n print(c)\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"test11.in\",\"r\")\n# sys.stdout=open(\"test11.out\",\"w\")\n\nn=int(input())\ncount=0\nfor i in range(1,n+1):\n\tif((n-1)%i==0):\n\t\tcount+=1\nprint(count)\n\n"}, {"source_code": "l = []\nn = 15\nfor i in range(1, n):\n if (n-1)%i == 0 :\n l.append(i)\nprint(len(l))"}, {"source_code": "n=int(input())\nprint(n//2)"}, {"source_code": "n=int(input())\ncount=1\nfor i in range(1,n):\n\tif i%n==0:\n\t\tcount+=1\nprint(count)"}, {"source_code": "n=int(input())\ni=1\nsum1=0\ncount=0\nwhile(sum1<n):\n sum1+=i\n i+=1\n if sum1<n:\n count+=1\nif count==0:\n print(1)\nelse:\n print(count)\n "}, {"source_code": "n = int (input())\na = n/2\ne=0\nif (n ==2):\n e=1\nfor i in range (1,a,1):\n b = n-i\n d = b % i\n if (d==0):\n e = e + 1\nprint e\n"}, {"source_code": "def SieveOfEratosthenes(n): \n\tarr=[]\n\tprime = [True for i in range(n+1)] \n\tp = 2\n\twhile (p * p <= n): \n\t\tif (prime[p] == True): \n\t\t\tfor i in range(p * p, n+1, p): \n\t\t\t\tprime[i] = False\n\t\tp += 1\n\tfor p in range(2, n): \n\t\tif prime[p]: \n\t\t\tarr.append(p)\n\treturn arr\n\t\ndef fun(n):\n arr=SieveOfEratosthenes(100000)\n for i in range(0,len(arr)):\n if arr[i]==n:\n return 1\n i=0\n p=1\n c=0\n while n>=2:\n if n%arr[i]==0:\n c+=1\n n=n//arr[i]\n else:\n i+=1\n p*=(1+c)\n return (p-1)\n\nn=int(input())\nif n==2:\n print(1)\nelse:\n print(fun(n))\n"}, {"source_code": "n = int(input())\nl = 0\ncount=0\nfor i in range(n):\n l+=1\n n-=l\n if(n%l==0):\n count+=1\nprint(count)\n"}, {"source_code": "emp = int(input())\nopt = 0\nfor i in range(1,emp):\n if i == 1:\n opt += 1\n continue\n bosses = i\n employees = emp - i\n if bosses <= employees and employees % 2 == 0:\n opt += 1\nprint(opt)"}, {"source_code": "n = int(input())\ni = 1\nk = 0\nif n == 2:\n print(1)\nelse:\n while i <= n:\n if n % i == 0:\n k = k + 1\n i = i + 1\n print(k)\n\n\n"}, {"source_code": "n = input()\nn = int(n)\naux = 0\n\nfor i in range(1,n//2+1):\n\n if n%i == 0:\n aux = aux+1\n else:\n continue\n\nprint(aux)\nprint(36//2)"}, {"source_code": "n = int(input())\nprint(sum(n % i == 0 for i in range(2, n // 2)))"}, {"source_code": "n = int(input())\nliste = []\nfor i in range(2,1000):\n\tif n % i == 0:\n\t\tliste.append(i)\n\nprint(len(liste))"}, {"source_code": "import sys\nimport math\ncounter = -1 # dont change i swear to god\n#\n#\n#\n\n\ncount = -1\n\nfor lin in sys.stdin:\n line = lin.rstrip()\n counter += 1\n # LEAVE THE ABOVE\n #\n #\n \n if counter == 0:\n n = int(line)\n break\n\nif int(n**0.5) == n**0.5:\n count -= 1\n \nfor i in range(math.ceil(n**0.5)):\n if i == 0:\n continue\n elif n % i == 0:\n count += 2\n\nif n == 1:\n print(\"0\")\nelif n == 4:\n print(\"2\")\nelse:\n print(count)"}, {"source_code": "n = input()\nres = 0\nif n ==1 or n==2:\n print \"1\"\n exit()\nelif n % 2!=0:\n print \"1\"\n exit()\nelse:\n for i in range(1,n):\n if n%i==0:\n res +=1\n print res\n \n"}, {"source_code": "# import sys\n# sys.stdin=open(\"test11.in\",\"r\")\n# sys.stdout=open(\"test11.out\",\"w\")\n\nn=int(input())\ncount=0\nfor i in range(1,n+1):\n\tif((n-1)%i==0):\n\t\tcount+=1\nprint(count)\n\n"}, {"source_code": "num=int(input('')) #num=8\nre=num%2\n\n#print(leader)\nif re==0:\n x=num/2 #x=4\n y=num/x #y=2\n lea1=num-x #4\n lea2=num-y #6\n em1=lea1/x\n em2=lea2/y\n print(em1,\"employee1\")\n # print(em2,\"employee2\")\n"}, {"source_code": "n = int(input())\na = 0\nm = int(n / 2)\nfor i in range(1, m):\n if n % i == 0:\n a += 1\nprint(a+1)\n"}, {"source_code": "if __name__ == \"__main__\":\n\n s = int(input())\n\n count = 1\n\n if s%2 != 0:\n print(count)\n else: \n for i in range(s//2):\n temp = s-(i+1)\n if temp%(i+1) == 0:\n count+=1\n\n print(count-1)\n\n\n\n \n"}, {"source_code": "n=int(input())\nsum=0\nfor i in range(1,n):\n if(n%i==0):\n sum+=i\nprint(sum)"}, {"source_code": "n = int(input())\nprint(sum(n % i == 0 for i in range(2, n // 2)))"}, {"source_code": "n=int(raw_input())\nans=0\ni=1\nwhile i<=n-i:\n if((n-i)%i):\n ans+=1\n i+=1\nprint(ans)"}, {"source_code": "a = int(input())\nif a < 4:\n print(1)\nelif(a - 2) % 2 == 0:\n print(2)\nelif (a -3) % 3 == 0:\n print(3)\nelif (a -5) % 5 == 0:\n print(5)\nelse:\n print(1)\n"}, {"source_code": "n = int(input())\nif 2<n<100000:\n for i in range(1,n):\n if n%i == 0:\n print(i)\n"}, {"source_code": "n=int(input())\nres=1\nif n %2 !=0 :\n print(res)\nflag=2\nif n %2 ==0 :\n res2=1\n while flag<10**5 :\n flag=flag+1\n if n %flag==0 :\n res2=res2+1\n print(res2)\n "}, {"source_code": "\"\"\"\nhttps://codeforces.com/problemset/problem/935/A\n\"\"\"\n\nimport math\n\ne = int(input())\nways = 0\n\nfor l in range(math.floor(math.sqrt(e))):\n ee = e - l+1\n\n if ee % (l+1) == 0:\n ways += 1\n\nprint(ways)"}, {"source_code": "if __name__ == \"__main__\":\n\n s = int(input())\n\n count = 1\n\n if s%2 != 0:\n print(count)\n else: \n for i in range(s//2):\n temp = s-(i+1)\n if temp%(i+1) == 0:\n count+=1\n\n print(count-1)\n\n\n\n \n"}, {"source_code": "l = []\nn = 15\nfor i in range(1, n):\n if (n-1)%i == 0 :\n l.append(i)\nprint(len(l))"}, {"source_code": "n=int(input())\ni=1\nsum1=0\ncount=0\nwhile(sum1<n):\n sum1+=i\n i+=1\n if sum1<n:\n count+=1\nif count==0:\n print(1)\nelse:\n print(count)\n "}, {"source_code": "i = int(input())\nl = 0\nif i%2 == 0:\n l = i/2\nelse:\n l = i/2 - 1\n\nprint(l)"}, {"source_code": "import sys\n\nif __name__ == '__main__':\n n = int(input())\n if n == 2:\n print(2)\n sys.exit()\n ans = 0\n for c in range(1,n):\n new = n - c\n if new % c == 0:\n ans += 1\n print(ans)\n"}, {"source_code": "n = int(input())\na = 0\nif n % 2 == 0:\n m = int(n / 2)\n for i in range(1, m):\n if n % i == 0:\n a += 1\n print(a+1)\nelse:\n print(1)\n"}, {"source_code": "import math\n\nN = input()\nchance = int(N)/2\nprint(math.ceil(chance))\n"}, {"source_code": "n = int(input())\ncount=0\nfor i in range(1,int(n/2+1)):\n n = n - i\n w = int(n/i)\n if(w == n/i):\n count+=1\nprint(count)\n "}, {"source_code": "from math import sqrt\na = int(input())\nc=0\nfor i in range(2,int(sqrt(a))):\n if a%i == 0:\n c+=1\nc*=2\nc+=1\nif float(a)/sqrt(a) == sqrt(a):\n c+=1\nprint(c)"}, {"source_code": "import math\ninp = int(input())\nk = 0\nfor i in range(1, int(math.sqrt(inp))+1):\n if inp % i == 0 and i!=1:\n k = k+2\n if i==1:\n k=k+1\nif (math.sqrt(inp)).is_integer() and inp != 1:\n k = k+1\nprint(k)\n"}, {"source_code": "n=int(input())\nc=0\nx=0\nwhile(x==1 or x==0):\n n=n/2\n x=n%2\n if(x>=0):\n c=c+1\nprint(c)"}, {"source_code": "a = int(input())\nb = a**0.5\nprint (int(b))"}, {"source_code": "n=int(input())\nc=1\nfor i in range(2,n//2):\n if n%i==0:\n c+=2\n else:\n continue\nprint(c)"}, {"source_code": "n = int(input())\n\nza_list = [i for i in range(1, n // 2)]\ncount = 1\n\nfor i in range(len(za_list)):\n if (n - za_list[i]) % 2 == 0:\n count += 1\n\nprint(count)"}, {"source_code": "x= int(input())\ncnt=0\nfor i in range (1,int(x/2)):\n if(x%i==0):\n cnt=cnt+1\nprint(cnt+1)"}, {"source_code": "n = int(input())\ncount=0\nfor i in range(1,int(n/2+1)):\n n = n - i\n w = int(n/i)\n if(w == n/i):\n count+=1\nprint(count)\n "}, {"source_code": "i = 0\nn = int(input())\nif n <= 9:\n i+= 1\nelif n <=8:\n i+= 1\nelse:\n i+=1\nprint(i)"}, {"source_code": "n=int(input())\nres=1\nif n %2 !=0 :\n print(res)\nflag=2\nif n %2 ==0 :\n res2=1\n while flag<10**5 :\n flag=flag+1\n if n %flag==0 :\n res2=res2+1\n print(res2)\n "}, {"source_code": "n=int(input())\nc=1\nif(n==1):\n c=0\nfor i in range(2,n//2-1):\n s=n-i;\n if(s%i==0 and s!=0):\n c=c+1\n else:\n break;\nprint(c) "}, {"source_code": "n=int(input())\nl=[]\nfor i in range(1,n):\n if(n % i < 1):\n l.append(i)\n print(l)\nprint(len(l))"}, {"source_code": "emp = int(input())\nopt = 0\nfor i in range(1,emp):\n if i == 1:\n opt += 1\n continue\n bosses = i\n employees = emp - i\n if bosses <= employees and employees % 2 == 0:\n opt += 1\nprint(opt)"}, {"source_code": "import math\nn=int(input())\nc=0\nfor i in range(1,n+1):\n if(round(math.sqrt(n-i))==math.sqrt(n-i) ):\n c=c+1\nprint(c)\n"}, {"source_code": "n=int(input())\nc=0\nif n%2==1:\n print(1)\nelse:\n for i in range(1,n):\n if n%i==0:\n c=c+1\n print(c)"}, {"source_code": "'''\n\tCodeForces 935A\n\tFafa and his Company\n\n\tTags: Math, Prime\n'''\nfrom math import sqrt\n\nn = int(input())\nm = int(sqrt(n))\nans = len(list(filter(lambda x: n % x == 0, range(2, m)))) * 2 + 1 + (1 if m * m == n else 0)\n\nprint(ans)"}, {"source_code": "n = int(input());cnt=1\nfor i in range(1,n//2):\n if n%i == 0:\n cnt+=1\nprint(cnt)"}, {"source_code": "n = int(input())\na = 0\nm = int(n / 2)\nfor i in range(1, m):\n if n % i == 0:\n a += 1\nprint(a+1)\n"}, {"source_code": "n = int(input())\nt = n\nw=0\nr=0\nif n % 2 == 0:\n for i in range(1,n):\n w = t-i\n if w % i == 0:\n r+= 1\n print(r)\nelse:\n print(1)\n"}, {"source_code": "import math\nn = int(input())\n\nconteo = 1\nfor i in range(2, int(math.sqrt(n))):\n if n % i == 0:\n conteo += 2\nprint(conteo)\n"}, {"source_code": "from math import sqrt\n\nn = int(input())\ncount = 1\nif n == 1:\n print(1)\nelif n == 2:\n print(2)\nelse:\n for i in range(2,int(sqrt(n))):\n if n%i == 0:\n if n == i*i:\n count += 1\n else:\n count += 2\n\n print(count)\n"}, {"source_code": "num=int(input(''))\nif num%2==0:\n x=int(num/2)\n y=int(num/x)\n print(abs(y-x))\nelse:\n print(1)\n #quit()\n"}, {"source_code": "n = int(input())\ncount =0 \nfor i in range(1, int(n**(0.5))+1):\n if n%i==0:\n count+=1\ncount *= 2\nif n%i==i:\n count -=2\nelse:\n count -=1\nprint(count)"}, {"source_code": "n=int(input())\nif(n%2==1):\n print(1)\nelse:\n c=0\n for i in range(1,n):\n if(n%i==0):\n c+=1\n print(c) "}, {"source_code": "n=int(input())\ncount=0\nfor i in range(3,9):\n if(n%i==0):\n count=count+1\nprint(count+1)"}, {"source_code": "import math\nn=int(input())\nc=0\nfor i in range(1,n):\n if(round(math.sqrt(n-i))==math.sqrt(n-i)):\n c=c+1\nprint(c)\n\n"}, {"source_code": "n=int(input())\nk=0;\nfor i in range(1,n+1):\n if((n-i)%i==0):\n k=k+1;\nprint(k)"}], "src_uid": "89f6c1659e5addbf909eddedb785d894"} {"source_code": "import sys\na,b,n,x = map(int,raw_input().split())\nmod = 1000000007\nif(a is 1):\n\tprint (n*b + x)%mod\nelse :\n\tprint (pow(a,n,mod)*x + b*(((pow(a,n,mod) - 1)*pow(a - 1,mod - 2,mod)) % mod))%mod\n\n", "positive_code": [{"source_code": "A, B, n, x = map(int, input().split())\nMOD = 10 ** 9 + 7\n\ndef SD(i):\n if i == 0:\n return 1\n elif i % 2 == 0:\n return (1 + A * SD(i - 1)) % MOD\n else:\n md = pow(A, i // 2 + 1, MOD)\n return ((md + 1) * SD(i // 2)) % MOD\n\nres = pow(A, n, MOD) * x + SD(n - 1) * B\nprint(res % MOD)"}, {"source_code": "def egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n\nmod = 10 ** 9 + 7\na, b, n, x = map(int, input().split())\nans = (pow(a, n, mod) * x % mod) % mod\nif a != 1:\n ans2 = ((b * (pow(a, n, mod) - 1) % mod) * modinv(a - 1, mod)) % mod\nelse:\n ans2 = (b*(n*a)%mod)%mod\nprint((ans + ans2) % mod)"}, {"source_code": "def egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n\nmod = 10 ** 9 + 7\na, b, n, x = map(int, input().split())\nans = (pow(a, n, mod) * x % mod) % mod\nif a != 1:\n ans2 = ((b * (pow(a, n, mod) - 1) % mod) * modinv(a - 1, mod)) % mod\nelse:\n ans2 = (b*(n*a)%mod)%mod\nprint((ans + ans2) % mod)"}, {"source_code": "import math \ndef modInverse(b,m): \n g = math.gcd(b, m) \n if (g != 1): \n return -1\n else: \n return pow(b, m - 2, m) \ndef modDivide(a,b,m): \n a = a % m \n inv = modInverse(b,m) \n return (inv*a)%m \nmod=int(10e8+7)\na,b,n,x=map(int,input().split())\nif a==1:\n print((x%mod+(n*b)%mod)%mod)\n exit()\nexp=a\nans=1\nwhile n>0:\n if(n%2==1):\n ans=(ans*exp)%mod\n exp=(exp*exp)%mod\n n//=2 \nres=(ans-1)%mod\nres=modDivide(res,a-1,mod)\nprint(((ans*x)%mod+(res*b)%mod)%mod)\n"}, {"source_code": "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int,minp().split())\n\nA,B,n,x = mints()\nr = 0\nif n == 0:\n\tr = x\nelif A == 1:\n\tr = x + B*n\nelse:\n\tr = (pow(A,n,10**9+7)-1)*pow(A-1,10**9+5,10**9+7)*B+pow(A,n,10**9+7)*x\nprint(r%(10**9+7))"}, {"source_code": "MOD = 1000000007\nA, B, n, x = map(int, raw_input().split())\nif A==1:\n print (x%MOD + ((B%MOD * n%MOD)%MOD))%MOD\nelse:\n print ((pow(A, n, MOD)*(x%MOD))%MOD + (B%MOD * (((pow(A, n, MOD)-1)%MOD) * (pow(A-1, MOD-2, MOD)))%MOD)%MOD)%MOD"}, {"source_code": "A, B, n, x = map(int, raw_input().split())\nMOD = 10**9+7\nif A > 1:\n print (x * pow(A, n, MOD) + B * (pow(A, n, MOD)-1) * pow(A-1, MOD-2, MOD)) % MOD\nelse:\n print (x * pow(A, n, MOD) + B * n) % MOD\n"}, {"source_code": "from sys import stdin\n\nmod = 10**9+7\n\ndef geo(x, n, m):\n return (pow(x, n+1, m) - 1)*pow(x-1, m-2, m)\n\np, q, n, a = [int(x) for x in stdin.readline().rstrip().split()]\nif p <= 1:\n print((a + q * n) % mod)\nelse:\n ans = (a * pow(p, n, mod) + q * (geo(p, n-1, mod) % mod)) % mod\n print(ans)\n"}, {"source_code": "import math\nimport sys\nsys.setrecursionlimit(10000)\ndef gcd(a, b):\n return b if a % b == 0 else gcd(b, a % b)\n\ndef lcm(a, b):\n return a*b/gcd(a,b)\n\ndef e_gcd(a, b):\n if (a == 0):\n return 0, 1, b\n x1, y1, d = e_gcd(b % a, a)\n x = y1 - (b / a) * x1\n y = x1\n return x, y, d\n\ns = raw_input()\na, b, n, x = s.split()\na = int(a)\nb = int(b)\nn = int(n)\nx = int(x)\n\nbase = int(1e9 + 7)\nif a == 1:\n print (x + (n)*b)%base\nelse:\n \n res = (pow(a, n, base) * x) % base\n \n s = (b * (1 - pow(a, n, base))) % base\n s = (s + base) % base\n \n q = (1 - a) % base + base\n q %= base\n xx, yy, dd = e_gcd(q, base)\n xx = (xx % base + base) % base\n ans = res + s * xx\n print ans % base\n\n\n\n"}, {"source_code": "a,b,n,x=map(int,raw_input().split())\nmod=10**9+7\nif a==1:\n print (x+n*b)%mod\nelse:\n \n print (pow(a,n,mod)*x+b*(pow(a,n,mod)-1)*(pow(a-1,mod-2,mod))+mod)%mod\n\n"}, {"source_code": "\nmod = 1000000007\ndef power(x, n):\n\n if(n==0):\n return 1\n\n tmp = power(x,n/2)\n\n if(n%2):\n return (((tmp*tmp)%mod)*x)%mod\n\n return (tmp*tmp)%mod\n\n\ndef divide(a , b):\n return (a * power(b,1000000005))%mod\n\n\n\nans=0;\na,b,n,x = raw_input().split(\" \")\na,b,n,x = int(a) , int(b) , int(n) , int(x)\nif(a>1): ans = (ans + (b* divide(power(a,n) - 1 , a-1))%mod)%mod\nelse : ans = (ans + (n*b)%mod)%mod\nans = (ans + (power(a,n)*x)%mod)%mod\nif(ans<0):\n ans += mod\nprint ans\n"}, {"source_code": "#!/usr/bin/python\nimport sys\nimport re\n\ndef input_numbers():\n return [int(n) for n in raw_input().split()]\n\nA,B,n,x = input_numbers()\nMOD = 10 ** 9 + 7\n\ndef mul(m1, m2):\n a,b,c,d = m1[0][0], m1[0][1], m1[1][0], m1[1][1]\n x,y,z,w = m2[0][0], m2[0][1], m2[1][0], m2[1][1]\n return (((a*x + b*z) % MOD, (a*y + b*w) % MOD), ((c*x + d*z) % MOD, (c*y + d*w) % MOD))\n\ndef square(m):\n return mul(m, m)\n\ndef power(m, n):\n if n == 0:\n return ((1, 0), (0, 1)) #Id\n sq = power(square(m), n / 2)\n if n % 2 == 1:\n sq = mul(m, sq)\n return sq\n\nm = ((A, 0), (B, 1))\nmn = power(m, n)\n\nA,B = mn[0][0], mn[1][0]\nprint (A*x + B) % MOD\n\n"}, {"source_code": "import sys\n\nmod = int(1000000007)\ndef inv(a):\n a1 = pow(a, mod-2, mod)\n return a1\nA, B, n, x = map(int, raw_input().split(' '))\nA, B, n, x = [int(A), (int)(B), (int)(n), (int)(x)]\n#print A,B, n, x\n\nif A != 1:\n A_n = pow(A, n, mod)\n rev = inv(A-1)\n p1 = (A_n*x)%mod\n p2 = B*((((A_n*rev)%mod)-rev)%mod)\n ans = (p1 + p2)%mod\n print ans\nelse:\n ans = (x + (B*(n)%mod))%mod\n print ans\n\n\n\n"}, {"source_code": "#http://codeforces.com/problemset/problem/678/D\ndef matrixProductModulo(dic1,dic2,modulo):\n dic = {}\n dic['a'] = (dic1['a']*dic2['a'] + dic1['b']*dic2['c'])%modulo\n dic['b'] = (dic1['a']*dic2['b'] + dic1['b']*dic2['d'])%modulo\n dic['c'] = (dic1['c']*dic2['a'] + dic1['d']*dic2['c'])%modulo\n dic['d'] = (dic1['c']*dic2['b'] + dic1['d']*dic2['d'])%modulo\n return dic\ndef getIdentityMatrix():\n identityMatrix = {}\n identityMatrix['a'] = 1\n identityMatrix['b'] = 0\n identityMatrix['c'] = 0\n identityMatrix['d'] = 1\n return identityMatrix\n \ndef binaryExp(dic,power,modulo):\n if power == 0:\n return getIdentityMatrix()\n halfPower = binaryExp(dic,power/2,modulo)\n halfPowerProduct = matrixProductModulo(halfPower,halfPower,modulo)\n if power%2 == 0:\n return halfPowerProduct\n else:\n return matrixProductModulo(dic,halfPowerProduct,modulo)\n \n \na,b,n,x = map(int,raw_input().split())\nmodulo = 10**9 + 7\nmatrix = {}\nmatrix['a'] = a\nmatrix['b'] = b\nmatrix['c'] = 0\nmatrix['d'] = 1\nmatrixPower = binaryExp(matrix,n,modulo)\nans = (matrixPower['a']*x + matrixPower['b'])%modulo\nprint ans\n"}, {"source_code": "a, b, n, x = map(int, raw_input().split())\nmod = 10**9+7\nprint (pow(a, n, mod) * x + b * (n if a == 1 else (pow(a, n, mod) - 1) * pow(a - 1, mod - 2, mod))) % mod \n\n"}, {"source_code": "\nimport sys\n\ndef mod_inverse(b,c):\n prod = 1\n while b != 1:\n factor = c/b\n prod = (prod*(factor+1))%c\n b = (factor+1)*b-c\n return prod\n\ndef mod_exp(A,n,c):\n max_2 = 1\n A_dict = {0:1,1:A%c,2:(A**2)%c}\n val = (A**2)%c\n power = 2\n while n > power:\n power*=2\n val = (val**2)%c\n A_dict[power] = val\n total = 1\n while n > 0:\n if power <= n:\n n = n - power\n total = (total*A_dict[power])%c\n power = power/2\n return total\n\ndef find_value(A,B,n,x):\n A_exp = mod_exp(A,n,10**9+7)\n if A != 1:\n A_less_inv = mod_inverse(A-1,10**9+7)\n A_sum = ((A_exp-1)*(A_less_inv))%(10**9+7)\n else:\n A_sum = n%(10**9+7)\n final_val = (x*A_exp+A_sum*B)%(10**9+7)\n return final_val\n\nif __name__=='__main__':\n ints = sys.stdin.readline().rstrip().split(' ')\n A,B,n,x = int(ints[0]),int(ints[1]),long(ints[2]),int(ints[3])\n print find_value(A,B,n,x)\n"}, {"source_code": "\na,b,n,x = map(int,raw_input().split())\n\nM = 1000000007\n\ndef exp(a,b):\n\tif b==0:\n\t\treturn 1\n\tif b%2==1:\n\t\treturn (a*exp(a,b-1))%M\n\telse:\n\t\tp = exp(a,b/2)\n\t\treturn (p*p)%M\n\n\nif a==1:\n\tres = (x+b*n)%M\nelse:\n\tres = ((exp(a,n)*x)%M + (((b*(exp(a,n)-1))%M) * exp(a-1,M-2))%M)%M\n\nprint res"}, {"source_code": "import sys\n\nMAXN = 10 ** 9 + 7\nf = sys.stdin\nA, B, n, x = map(int, f.readline().strip().split(' '))\nif A == 1:\n print((x + n * B) % MAXN)\nelse:\n ans = x\n while n > 0:\n if n % 2:\n ans = (A * ans + B) % MAXN;\n B = B * (A + 1) % MAXN;\n A = A * A % MAXN;\n n /= 2\n print(ans)\n"}, {"source_code": "import sys\n\ndef r():\n\treturn sys.stdin.readline()\n\nmod = 1000000007\n\ndef q(n,a,b):\n\tif n == 0:\n\t\treturn 1,0\n\tif n == 1:\n\t\treturn a,b\n\tif n % 2 == 1:\n\t\txa,xb = q(n-1,a,b)\n\t\treturn a*xa % mod, (a*xb + b) % mod\n\telse:\n\t\txa,xb = q(n/2,a,b)\n\t\treturn xa*xa % mod, (xa*xb + xb) % mod\n\na,b,n,x = map(int, r().split())\n\nxa,xb = q(n,a,b)\nprint (x*xa+xb) % mod\n\n"}, {"source_code": "mod = int(10**9 + 7)\nmud = int(10**9 + 6)\n\n\ndef powM(bs, pw, MOD):\n res = 1\n for i in range(pw.bit_length() - 1, -1, -1):\n res = (res * res) % MOD\n if (pw & (1 << i) > 0):\n res = (res * bs) % MOD\n\n return res\n\n\nA, B, n, x = raw_input().split()\n\nA = int(A)\nB = int(B)\nn = int(n)\nx = int(x)\n\nif A == 1:\n n %= mod\n print (x + B * n) % mod\nelse:\n n %= mud\n An = powM(A, n, mod)\n fx = B * (mod + An - 1) % mod * powM(A - 1, mod - 2, mod)\n print (An * x + fx) % mod\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\n\n(A, B, n, x) = (int(i) for i in input().split())\n\nstart = time.time()\n\nmd = 1000000007\n\nif A!=1 :\n an = pow(A, n, md*(A-1))\n bn = B*(an-1)//(A-1)\n ans = (an*x+bn)%md\nelse:\n ans = (x+B*n)%md\nprint(ans)\n\nfinish = time.time()\n#print(finish - start)\n"}, {"source_code": "import math\n[A,B,n,x]=[int(x) for x in raw_input().split()]\nq=pow(10,9)+7\ntotal=pow(A,n,q)*x\ntotal%=q\nif A==1:\n total=x+n*B\n total%=q\n print total\nelse:\n m=pow(A,n,q)-1\n m*= pow(A-1,q-2,q)\n m*=B\n total+=m\n total%=q\n print total"}, {"source_code": "import sys\na,b,n,x = map(int,raw_input().split())\nmod = 1000000007\nif(a is 1):\n\tprint (n*b + x)%mod\nelse :\n\tprint (pow(a,n,mod)*x + b*(((pow(a,n,mod) - 1)*pow(a - 1,mod - 2,mod)) % mod))%mod\n"}, {"source_code": "a,b,n,x=map(int,input().split())\nmod=(10**9+7)*(a-1)\nmod1=(10**9+7)\n#print(int(x*(a**n)+b*(a**n-1)/(a-1)))'''\ndef bin_pow(a,n,mod):\n if n==1:\n return a\n else:\n if n%2==0:\n return ((bin_pow(a,n//2,mod)**2))%mod\n return (((bin_pow(a,n//2,mod)**2)*a))%mod\n\n \ndef s(a,n,b=1):\n ans=0\n for k in range(n):\n ans+=b*(a**k)\n return ans\n \nif a!=1:\n ans=x*bin_pow(a,n,mod)\n\n ans+=b*(bin_pow(a,n,mod)-1)//(a-1) \n print(int(ans)%mod1)\n\nelse:\n ans=x*bin_pow(a,n,mod1)\n ans+=b*n\n print(ans%mod1)\n"}, {"source_code": "\n(a, b, n, x) = map(int, input().split(\" \"))\n\nxp = pow(a, n % 1000000006, 1000000007)\n\nans = (xp * x) % 1000000007\n\nif (a == 1):\n\n\tans = ans + n * b\n\nelse:\n\n\ttmp = (xp - 1) * pow(a - 1, 1000000005, 1000000007) * b\n\n\ttmp = tmp % 1000000007\n\n\tans = ans + tmp\n\nans = ans % 1000000007\n\nprint (ans)"}, {"source_code": "from collections import defaultdict\nimport sys\n\ndef mpow(base, p):\n temp = 1\n while p:\n if (p & 1):\n temp = (temp * base) % MOD\n p //= 2\n base = (base * base) % MOD\n return temp % MOD\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n a, b, n, x = map(int, input().split())\n MOD = 10 ** 9 + 7\n temp = mpow(a, n)\n if a > 1:\n ans = ((temp * x % MOD) + (b * (temp - 1) % MOD) * mpow(a - 1, MOD - 2) % MOD) % MOD\n else:\n ans = ((temp * x % MOD) + b * (n % MOD) % MOD) % MOD\n print(ans) "}, {"source_code": "from sys import stdin, stderr, stdout, exit\nfrom math import gcd\n\nreadl = lambda : list(map(int, stdin.readline().strip().split()))\nMOD = 1000000007\n\n\ndef main():\n A, B, n, x = readl()\n if(A == 1):\n stdout.write(str((B*n + x) % MOD))\n else:\n An = pow(A, n, MOD)\n stdout.write(str((((An * x) % MOD) + (B * (1-An) * pow(1-A, MOD-2, MOD)) % MOD) % MOD))\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\ndef main():\n\tfor line in sys.stdin:\n\t\tline = line.split()\n\t\tA = int(line[0])\n\t\tB = int(line[1])\n\t\tn = int(line[2])\n\t\tx = int(line[3])\n\t\tmod = 1000000007\n\t\tif(A==1):\n\t\t\tasum = n\n\t\telse:\n\t\t\tnum = pow(A,n,mod*(A-1))\n\t\t\tasum = ((pow(A,n,mod*(A-1))-1)//(A-1))%mod\n\t\tprint((B*asum%mod + x*pow(A,n,mod))%mod)\n\nif __name__ == \"__main__\":\n main()\n\n#A(A(Ax + B) + B) +B\n\n#B(1+A+A^2+...+A^(n-1))+x*A^n\n\n#B(A^n -1)/(A-1) + x*A^n\n\n#For test case 1000 2000 50 20\n#826144502"}, {"source_code": "from sys import stdin\nimport sys\nsys.setrecursionlimit(10**7)\nA,B,n,x=map(int,stdin.readline().strip().split())\nmod=10**9+7\n\"\"\"\ndp=[-1 for i in range(n+10)]\ndef f(x1):\n return (A*x1+B)%mod\ndef g(n,x):\n if n==0:\n return x\n if dp[n]!=-1:\n return dp[n]\n dp[n]=f(g(n-1,x))\n return dp[n]\n\"\"\"\ndef geo(n):\n ans=(pow(A,n,mod)*x)%mod\n if(A!=1):\n ans1=(((B-B*pow(A,n,mod))%mod)*pow(1-A,mod-2,mod))%mod\n else:\n ans1=(B*n)\n return (ans+ans1)%mod\nprint(geo(n))\n"}, {"source_code": "a, b, n, x = map(int, input().split())\nm = 10 ** 9+7\n# modular multiplicative inverse in second power\nprint(((pow(a,n,m)*x+b*(pow(a,n,m)-1)*pow(a-1,m-2,m)) if a!=1 else b * n + x)%m)"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase\nfrom string import ascii_uppercase\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] != \"CPython\": # PyPy?\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\na, b, n, x = read_ints()\n\ncur = x\nwhile n > 0:\n if n & 1:\n cur = (a * cur + b) % MOD\n a, b = a*a % MOD, (a*b + b) % MOD\n n >>= 1\nprint cur\n"}, {"source_code": "(a,b,n,x)=input().split(' ')\na,b,n,x=int(a),int(b),int(n),int(x)\nif a==1:\n\tprint((x+n*b)%(10**9+7))\nelse:\n\tprint(((pow(a,n,10**9+7)*x)%(10**9+7)+(((pow(a,n,10**9+7)-1)*b)%(10**9+7)*pow(a-1,10**9+5,10**9+7))%(10**9+7))%(10**9+7))\n"}, {"source_code": "def mod_exp(x, y, p):\n res = 1\n x %= p\n while y:\n if y&1:\n res = (res * x) % p\n y >>= 1\n x = (x * x) % p\n return res\n\n\ndef power(a, b, m):\n x, y = 1, a\n while b:\n if b&1:\n x = (x * y) % m\n y = (y * y) % m\n b //= 2\n return x\n\n\ndef mod_inverse(a, m):\n return power(a, m - 2, m)\n\n\ndef solve(a, b, n, x):\n m = 10**9 + 7\n if a == 1:\n return (b * n * a + x) % m\n p = mod_exp(a, n, m)\n return (b * (p - 1) * mod_inverse(a - 1, m) + p * x) % m\n\na, b, n, x = map(int, input().split())\n\nprint(solve(a, b, n, x))\n"}, {"source_code": "def modPow(base, pow, mod):\n ret = 1\n while pow > 0:\n if (pow % 2) == 0:\n base = (base * base) % mod\n pow >>= 1\n else:\n ret = (ret * base) % mod\n pow = pow - 1\n return ret;\n\na, b, n, x = map(int, raw_input().split())\nmodulo = 1000000007\n\nfirst = modPow(a,n,modulo)\nsecond = x % modulo\nthird = 0\nif a != 1:\n third = modPow(a, n, modulo * (a - 1))\n third = modulo * (a - 1) - 1 if third == 0 else third - 1\n third = third / (a - 1) * b\nelse:\n third = (b * n) % modulo\nans = (((first * second) % modulo) + third % modulo) % modulo\nprint ans"}, {"source_code": "a, b, n, x = map(int, raw_input().split())\np = pow(a, n, 1000000007)\nprint ((p * x) % 1000000007 + (((p - 1) * pow(a - 1, 1000000005, 1000000007) if a > 1 else n) * b) % 1000000007) % 1000000007"}, {"source_code": "a, b, n, x = map(int, raw_input().split())\n\nmod = 1000000007\n\ncur = x\nwhile n > 0:\n if n & 1:\n cur = (a * cur + b) % mod\n a, b = a * a, a * b + b\n a %= mod\n b %= mod\n \n n >>= 1\n \nprint cur"}, {"source_code": "def calcInverse(r2, r1):\n global Mod\n s1, s2, t1, t2 = 1, 0, 0, 1\n\n while r2 != 0:\n q = r1 / r2\n r = r1 % r2\n s = s1 - q * s2\n t = t1 - q * t2\n\n r1, r2 = r2, r\n s1, s2 = s2, s\n t1, t2 = t2, t\n return t1 % Mod\n\n\n\ndef calcExponent(a, n):\n global Mod\n\n n = bin(n)[2:]\n Len = len(n) - 1\n tmp = a\n\n Sum = 1\n while Len >= 0:\n if n[Len] == '1': Sum = (Sum * tmp) % Mod\n tmp = (tmp * tmp) % Mod\n Len -= 1\n return Sum % Mod\n \n \n \n## Entry of Program\n#\n#\n\nMod = 10 ** 9 + 7\na, b, n, x = [int(x) for x in raw_input().split(' ')]\n\nif a == 1: print (n * b + x) % Mod\nelse: print ((b * (calcExponent(a, n) - 1) * calcInverse(a - 1, Mod)) % Mod + calcExponent(a, n) * x) % Mod\n"}, {"source_code": "def egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\nA,B,n,x = map(int,raw_input().split())\nm = 10**9 + 7\nif n == 0:\n print x%m\nelif n == 1:\n print (A*x + B)%m\nelif A == 1:\n print (x + B*n)%m\nelse:\n a = (pow(A,n,m)*x)%m\n b = ((pow(A,n,m)-1)*modinv(A-1,m))%m\n if b < 0: b += m\n print (a + b*B)%m\n"}, {"source_code": "mod=10**9+7\ndef ans(n,a,b):\n if n==0:\n return 1,0\n elif n==1:\n return a,b\n elif n%2==1:\n p,q=ans(n-1,a,b)\n return (a*p)%mod,(a*q+b)%mod\n else:\n p,q=ans(n/2,a,b)\n return (p*p)%mod,(p*q+q)%mod\na,b,n,x=map(int,raw_input().split())\np,q=ans(n,a,b)\nprint (x*p+q)%mod\n "}, {"source_code": "M = int(1e9 + 7)\nA, B, n, x = (int(x) for x in input().split())\nif A > 1:\n An = pow(A, n, M)\n print((An * x + B * (1-An) * pow(1-A, M-2, M)) % M)\nelse:\n print((x + B*n) % M)\n"}, {"source_code": "# from dust i have come, dust i will be\n\nmod=int(1e9)+7\n\nA,B,n,x=map(int,input().split())\n\n'''\nif we expand the given formula for some test cases \ne.g-> for n=2,3,4.. we get\nA^n*x + B(A^0+A^1+...+A^{n-1})\nfor the geometric progression, 1+r+r^2+...+r^{n-1}\nthe ans=(r^n-1)/(r-1) when r>1, if r==1, ans=nr\n'''\n\nif n==0:\n print(x)\n exit(0)\n\nif A==1:\n temp=n*A\nelse:\n '''\n (A/B)%m=(A%m*(B^-1)%m)%m\n '''\n x1=pow(A,n,mod)-1\n x2=pow(A-1,mod-2,mod)\n temp=(x1*x2)% mod\n\np1=pow(A,n,mod)*pow(x,1,mod)\np1=p1%mod\n\np2=(B%mod)*temp\np2=p2%mod\n\nprint((p1+p2)%mod)\n"}, {"source_code": "def egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef modexp ( g, u, p ):\n \"\"\"computes s = (g ^ u) mod p\n args are base, exponent, modulus\n (see Bruce Schneier's book, _Applied Cryptography_ p. 244)\"\"\"\n s = 1\n while u != 0:\n if u & 1:\n s = (s * g)%p\n u >>= 1\n g = (g * g)%p;\n return s\n\nA,B,n,x=map(int, raw_input().split())\nmagic=10**9+7\nif A==1:\n print (x+n*B)%magic\nelse:\n An=modexp(A, n, magic)\n Annumerator=(An-1)%magic\n Adenominator=(A-1)%magic\n Adenominator=modinv(Adenominator, magic)\n print ((An*x) % magic+ (((Annumerator*Adenominator)%magic) *B )%magic)%magic"}, {"source_code": "import sys\n\nMOD = 10**9 + 7\n\n\ndef super_power(A, n, m):\n if n == 1:\n return A\n if n % 2 == 0:\n res = super_power(A, n/2, m)\n return res ** 2 % m\n else:\n res = super_power(A, (n - 1)/2, m)\n return (((res ** 2) % m) * A) % m\n\ndef ext_gcd(x, y):\n if x == 0:\n return y, 0, 1\n value, a, b = ext_gcd(y % x, x)\n return value, b - (y / x)*a, a\n\n\n# ax + by = value\n# y%x * a1 + x*b1 = value\n# y % x = y - (y/x*x)\n# (y - (y/x)*x) * a1 + x * b1 = value\n# y * a1 + x(b1 - y/x) = value\n# b = a1\n# a = b1 - y/x\n\ndef super_inverse(A, m):\n inverse = ext_gcd(A, m)[1]\n if inverse < 0:\n return inverse + m\n return inverse\n\ndef super_substr(a, b, m):\n result = (a % m - b % m)\n if result < 0:\n return result + m\n return result\n\ndef super_mul(a, b, m):\n return ((a % m) * (b % m)) % m\n\ndef geom_sum(power, p, q, b1):\n if q == 1:\n return (power * b1) % MOD\n\n up = super_mul(b1, super_substr(1, p, MOD), MOD)\n down = super_inverse(super_substr(1, q, MOD), MOD)\n return up * down % MOD\n\n\nif __name__ == \"__main__\":\n A, B, n, x = [int(i) for i in sys.stdin.readline().strip().split()]\n power = super_power(A, n, MOD)\n\n print (power * x + B * geom_sum(n, power, A, 1)) % MOD\n\n\n\n\n"}, {"source_code": "a,b,n,x=map(int,raw_input().split())\nmod=1000*1000*1000 +7\nsum=0\nif(a==1):\n sum=(x%mod+n*b%mod)%mod\nelse:\n sum=(pow(a,n,mod)*x+(((b*(pow(a,n,mod)-1))%mod)*pow(a-1,mod-2,mod))%mod)%mod\n \nprint(sum)"}, {"source_code": "mod = 10**9 + 7\n\ndef pow(num, p):\n global mod\n if p == 1:\n return num \n ans = pow(num, p//2) \n if p % 2 == 0:\n return ans * ans % mod\n else:\n return ans * ans * num % mod \n\nA, B, n, x = tuple(map(int, input().split()))\n\nif A != 1:\n ans = B\n ans *= ((pow(A, n) - 1) % mod * (pow(A-1, mod - 2) % mod)) % mod\n ans += pow(A, n) * x % mod\n ans %= mod\nelse:\n ans = x + n * B\n ans %= mod\n\n\nprint(round(ans))\n"}, {"source_code": "\ndef extendedEuclidean(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = extendedEuclidean(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef exp_mod (base, exp, mod):\n if (mod == 1):\n return 0;\n \n number = 1;\n \n while (exp):\n if (exp & 1):\n number = (number * base) % mod;\n exp >>= 1\n base = (base * base) % mod;\n \n return number\n\nif __name__ == '__main__':\n a, b, n, x = map(int, raw_input().split())\n \n m = 1000000007\n s = 0\n \n an = exp_mod (a, n, m)\n if a == 1:\n s = (n+m)%m\n else:\n p = (an-1)%m\n q = extendedEuclidean(a-1, m)[1]\n q = (q+m)%m\n s = ((p%m)*(q%m))%m\n s = (s+m)%m\n # print s, a, an\n \n ss = ((an*x)+m)%m + ((b*s)+m)%m\n \n ss = (ss+m)%m\n \n print ss\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nmod = 10**9 + 7\n\ndef invmod(x, mod):\n return pow(x, mod-2, mod)\n\na, b, n, x = map(int, input().split())\nif a == 1:\n ans = (pow(a, n, mod) * x + b * n) % mod\nelse:\n ans = pow(a, n, mod) * x + b * (pow(a, n, mod) - 1 + mod) * invmod(a-1, mod)\n ans %= mod\nprint(ans)"}, {"source_code": "line = raw_input()\n\nA, B, n, x = line.split()\nmod = 1000000007\n\ndef matmult(a, b):\n\treturn [\n\t\ta[0]%mod*b[0]%mod+a[1]%mod*b[2]%mod, \n\t\ta[0]%mod*b[1]%mod+a[1]%mod*b[3]%mod,\n\t\ta[2]%mod*b[0]%mod+a[3]%mod*b[2]%mod,\n\t\ta[2]%mod*b[1]%mod+a[3]%mod*b[3]%mod\n\t\t]\n\na0 = [int(A), 1, 0, 1]\n\ndef modpow(a, b):\n\tif b == 1:\n\t\treturn a0\n\telif b & 1 == 1:\n\t\treturn matmult(a0, modpow(a,b-1))\n\telse:\n\t\tx = modpow(a, b/2)\n\t\treturn matmult(x, x)\n\t\t\nan = modpow(a0, int(n))\nprint (an[0]*int(x)+an[1]*int(B))%mod"}, {"source_code": "MOD = 10 ** 9 + 7\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b / a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef gsum(a, r, n):\n inv = modinv(r - 1, MOD)\n return (a - a * pow(r, n + 1, MOD)) * inv * -1\n\na, b, n, x = map(int, raw_input().split())\n\nif a == 1:\n print (b * n + x) % MOD\nelse:\n print (pow(a, n, MOD) * x + gsum(b, a, n - 1)) % MOD\n"}, {"source_code": "import sys\n\nA, B, n, x = map(int, input().split())\nmod = 10**9 + 7\n\n\ndef matmul(matA, matB):\n x, y, z = len(matA), len(matB[0]), len(matA[0])\n res = [[0]*y for _ in range(x)]\n\n for i in range(x):\n for j in range(y):\n for k in range(z):\n res[i][j] += matA[i][k] * matB[k][j]\n res[i][j] %= mod\n\n return res\n\n\nmatA = [\n [(A*x + B) % mod, 1],\n [x, 1]\n]\nmatB = [\n [A, 0],\n [B, 1]\n]\nn -= 1\n\nwhile n:\n if n & 1:\n matA = matmul(matA, matB)\n matB = matmul(matB, matB)\n n >>= 1\n\nprint(matA[0][0] % mod)\n"}, {"source_code": "import functools\nimport itertools\n\nclass NotAMatrixError(Exception):\n pass\n\nclass MatrixSizeError(Exception):\n def __init__(self, s1, s2):\n print('sizes do not match : ', s1, ', ', s2)\n\nclass NotSquareError(Exception):\n pass\n\nclass Matrix(list):\n def __init__(self, L):\n if type(L) == type(self):\n self = L\n return\n n = len(L)\n m = len(L[0])\n for i in range(n):\n if len(L[i]) != m:\n raise NotAMatrixError()\n list.__init__(self, L)\n self.n = n\n self.m = m\n self.degrees = []\n def check_size(self, M, mode):\n n, m = len(M), len(M[0])\n for i in range(n):\n if len(M[i]) != m:\n raise NotAMatrixError()\n if mode == 'add' and self.n != n or self.m != m:\n raise MatrixSizeError((self.n, self.m), (n,m))\n if mode == 'mul' and self.m != n:\n raise MatrixSizeError((self.n, self.m), (n,m))\n def __add__(self, M):\n self.check_size(M, mode = 'add')\n return Matrix([[self[i][j]+M[i][j] for j in range(self.m)]for i in range(self.n)])\n def __iadd__(self, M):\n self.check_size(M, mode = 'add')\n for i in range(self.n):\n for j in range(self,m):\n self[i][j] += M[i][j]\n def __mul__(self, M):\n self.check_size(M, mode = 'mul')\n l = len(M[0])\n return Matrix([[sum(self[i][k]*M[k][j] for k in range(self.m))\n for j in range(l)] for i in range(self.n)])\n def issquare(self):\n return self.n == self.m\n def primary(self):\n if self.n != self.m:\n raise NotSquareError()\n return Matrix([[int(i==j) for j in range(self.m)] for i in range(self.n)])\n def __pow__(self, n):\n if self.n != self.m:\n raise NotSquareError()\n if n == 0:\n return self.primary()\n elif n == 1:\n return self\n if len(self.degrees) == 0:\n self.degrees.append(self*self)\n for i in range(n.bit_length() - len(self.degrees) - 1):\n self.degrees.append(self.degrees[-1] * self.degrees[-1])\n s = [(n>>i)&1 for i in range(1,n.bit_length())]\n res = functools.reduce(lambda x,y:x*y, itertools.compress(self.degrees, s))\n return res*self if n%2 else res \n def drop_degrees(self):\n self.degrees.clear()\n\nclass RemMatrix(Matrix):\n def __init__(self, L, p):\n Matrix.__init__(self, L)\n self.p = p\n\n def primary(self):\n if self.n != self.m:\n raise NotSquareError()\n return Matrix([[Remainder(i==j, self.p) for j in range(self.m)] for i in range(self.n)])\n\n def __mul__(self, M):\n self.check_size(M, mode = 'mul')\n l = len(M[0])\n return RemMatrix([[sum((self[i][k]*M[k][j] for k in range(self.m)),\n Remainder(0, self.p)) for j in range(l)]\n for i in range(self.n)], self.p)\n\nclass Remainder(tuple):\n def __new__(self, a, n):\n return tuple.__new__(self, (a%n, n))\n def __add__(self, p):\n return Remainder((self[0] + p[0]) % self[1], self[1])\n def __sub__(self, p):\n return Remainder((self[0] - p[0]) % self[1], self[1])\n def __mul__(self, p):\n return Remainder((self[0] * p[0]) % self[1], self[1])\n def __radd__(self, p):\n return Remainder((self[0] + p[0]) % self[1], self[1])\n def __rsub__(self, p):\n return Remainder((self[0] - p[0]) % self[1], self[1])\n def __rmul__(self, p):\n return Remainder((self[0] * p[0]) % self[1], self[1])\n def __neg__(self):\n return Remainder((-self[0]) % self[1], self[1])\n\np = 10 ** 9 + 7\nr = lambda x : Remainder(x, p)\n\nN = map(r, range(10))\n\na, b, n, x = map(int, input().split())\na1, b1, o, l, x1 = r(a), r(b), r(0), r(1), r(x)\nM = RemMatrix([[a1, b1], [o, l]], p)\nL = (M ** n)\n\nprint((L[0][0] * x1 + L[0][1])[0])\n\n\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jul 11 16:49:52 2020\n\n@author: shailesh\n\"\"\"\n#def power_sum(A,n):\n# if A == 1:\n# return 1\n\n\nA,B,n,x = [int(i) for i in input().split()]\n\n#n-=1\n\nm = 10**9 + 7\n#val = A**n*x + B*(A**n - 1)//(A-1)\nif A != 1:\n val = pow(A,n,m)*x + B*(pow(A,n,m) - 1)*pow(A-1,m-2,m)\nelse:\n val = (x + n*B)\nprint(val%(m))"}, {"source_code": "import sys,math\ndef power(x, y, p): \n res = 1;\n x = x % p; \n while (y > 0): \n if (y & 1): \n res = (res * x) % p; \n y = y >> 1; \n x = (x * x) % p; \n return res; \ndef modInverse(b,m): \n\tg = math.gcd(b, m) \n\tif (g != 1): \n\t\treturn -1\n\telse: \n\t\treturn pow(b, m - 2, m) \ndef modDivide(a,b,m): \n\ta = a % m \n\tinv = modInverse(b,m) \n\tif(inv == -1): \n\t\tprint(\"Division not defined\") \n\telse: \n\t\treturn (inv*a) % m \n#using sum of GP series \nA,B,n,X=map(int,sys.stdin.readline().split())\nm=10**9+7\nif A==1:\n print(((n%m)*B+X)%m)\nelse:\n temp=power(A,n,m)\n s=(temp*(X%m))%m\n s=(s%m+((modDivide(B*(temp-1),A-1,m)%m)%m)%m)%m\n print(s%m)\n"}, {"source_code": "a,b,n,x=map(int,input().split())\nm=10**9+7\nprint(((pow(a,n,m)*x+b*(pow(a,n,m)-1)*pow(a-1,m-2,m)) if a!=1 else b*n+x)%m)\n"}, {"source_code": "a,b,n,x=map(int, input().split());\nm=1000000007;\ndef modex(a,n):\n\tans=1\n\twhile n:\n\t\tif n&1:\n\t\t\tans=(ans%m*a%m)%m\n\t\ta=(a%m*a%m)%m\n\t\tn>>=1\n\treturn ans\nif a==1:\n\tprint((x%m+(b%m*n%m)%m)%m)\nelse:\n\tprint(((modex(a,n)%m*x%m)%m+(b%m*((modex(a,n)%m-1%m)%m)%m*(modex(a-1,m-2)))%m)%m)"}, {"source_code": "a, b, n, x = map(int, input().split())\nMOD = 1000000007\n\ncur = x\nwhile n > 0:\n if n & 1:\n cur = (a * cur + b) % MOD\n a, b = a*a % MOD, (a*b + b) % MOD\n n >>= 1\nprint(cur)"}, {"source_code": "import sys,math\ndef power(x, y, p): \n res = 1;\n x = x % p; \n while (y > 0): \n if (y & 1): \n res = (res * x) % p; \n y = y >> 1; \n x = (x * x) % p; \n return res; \ndef modInverse(b,m): \n\tg = math.gcd(b, m) \n\tif (g != 1): \n\t\treturn -1\n\telse: \n\t\treturn pow(b, m - 2, m) \ndef modDivide(a,b,m): \n\ta = a % m \n\tinv = modInverse(b,m) \n\tif(inv == -1): \n\t\tprint(\"Division not defined\") \n\telse: \n\t\treturn (inv*a) % m \n#using sum of GP series \nA,B,n,X=map(int,sys.stdin.readline().split())\nm=10**9+7\nif A==1:\n print(((n%m)*B+X)%m)\nelse:\n temp=power(A,n,m)\n s=(temp*(X%m))%m\n s=(s%m+((modDivide(B*(temp-1),A-1,m)%m)%m)%m)%m\n print(s%m)\n"}, {"source_code": "MOD = 1000000007\n\ndef mul_mat_2x2(a, b):\n A = a[0][0]\n B = a[0][1]\n C = a[1][0]\n D = a[1][1]\n X = b[0][0]\n Y = b[0][1]\n G = b[1][0]\n H = b[1][1]\n return [[(B*G + A*X) % MOD, (B*H + A*Y) % MOD], [(D*G + C*X) % MOD, (D*H + C*Y) % MOD]]\n\ndef bin_pow_mat_2x2(a, x):\n if(x == 0): \n return [[1, 0], [0, 1]]\n elif(x == 1):\n return a\n else:\n t = bin_pow_mat_2x2(a, x >> 1)\n ans = mul_mat_2x2(t, t)\n if((x & 1) == 1):\n ans = mul_mat_2x2(ans, a)\n return ans\n\nu, v, n, x = map(int, input().split())\nmat = [[u, v], [0, 1]]\ns = bin_pow_mat_2x2(mat, n)\nf = (s[0][0] * x + s[0][1]) % MOD;\nprint(f)"}, {"source_code": "a,b,n,x=map(int,input().split())\nm=10**9+7\nprint(((pow(a,n,m)*x+b*(pow(a,n,m)-1)*pow(a-1,m-2,m)) if a!=1 else b*n+x)%m)"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**9+7\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n\ndef inv(a):\n return pow(a, MOD-2, MOD)\n\na,b,n,x = Ri()\nans = pow(a, n, MOD) * x\nif a > 1:\n ans += b * ( pow(a, n, MOD) -1 ) * inv(a-1)\nif a == 1:\n ans += (b*(n%MOD))%MOD\n\nprint(ans%MOD)\n\n\n\n\n\n"}, {"source_code": "a, b, n, x = map(int, input().split(' '))\nfir = pow(a, n, 10**9+7)*x%(10**9+7)\nsec = b*(pow(a, n, 10**9+7)-1)*(pow(a-1, 10**9+5, 10**9+7))%(10**9+7)\nif (a == 1):\n sec = n * b\nprint((fir+sec)%(10**9+7))\n"}, {"source_code": "m=1000000007\n\ndef mult(A,B):\n global m\n return (\n ((A[0][0]*B[0][0]+A[0][1]*B[1][0])%m,\n (A[0][0]*B[0][1]+A[0][1]*B[1][1])%m),\n ((A[1][0]*B[0][0]+A[1][1]*B[1][0])%m,\n (A[1][0]*B[0][1]+A[1][1]*B[1][1])%m)\n )\n\na,b,n,x=map(int,input().split())\nmat,res=((a,b),(0,1)),((1,0),(0,1))\nwhile n:\n if n % 2:\n res = mult(res,mat)\n mat = mult(mat,mat)\n n //= 2\n\nprint((res[0][0]*x + res[0][1]) % m)\n \n\n"}, {"source_code": "MOD=10**9+7\na,b,n,x=map(int,input().split())\nt=pow(a,n,MOD*max(1,a-1))\nprint((t*x+b*(t-1)//(a-1))%MOD if a-1else(x+n*b)%MOD)\n"}, {"source_code": "import sys\ndef main():\n\tfor line in sys.stdin:\n\t\tline = line.split()\n\t\tA = int(line[0])\n\t\tB = int(line[1])\n\t\tn = int(line[2])\n\t\tx = int(line[3])\n\t\tmod = 1000000007\n\t\tif(A==1):\n\t\t\tasum = n\n\t\telse:\n\t\t\tnum = pow(A,n,mod*(A-1))\n\t\t\tasum = ((pow(A,n,mod*(A-1))-1)//(A-1))%mod\n\t\tprint((B*asum%mod + x*pow(A,n,mod))%mod)\n\nif __name__ == \"__main__\":\n main()\n\n#A(A(Ax + B) + B) +B\n\n#B(1+A+A^2+...+A^(n-1))+x*A^n\n\n#B(A^n -1)/(A-1) + x*A^n\n\n#For test case 1000 2000 50 20\n#826144502"}, {"source_code": "a,b,n,x = map(int,input().split())\nmd = 10**9+7\nmult = lambda u,v : 0 if v==0 else (u+mult(u,v-1))%md if v % 2 == 1 else (2*mult(u,v//2))%md\nget_prog = lambda a,b,n : mult(pow(a,n,md)-1+md,pow(a-1+md,md-2,md)) if a!=1 else n \nres = mult(pow(a,n,md),x)+mult(get_prog(a,b,n),b)\nres%=md\nprint(res)"}, {"source_code": "import sys\n\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\ndef get_ints(): return map(int, sys.stdin.readline().split())\ndef input(): return sys.stdin.readline().strip('\\n')\n\na,b,n,x = get_ints()\n\nmod = 10**9 + 7\nk = pow(a,n,mod)\n\n#well that was fucking awesome.\nif( a != 1):\n ans = ((b%mod)*(((k-1)*pow(a-1,mod-2,mod))%mod)+(k*x)%mod)%mod\n print(ans)\nelse:\n print( ((k*x)%mod + (n%mod * b%mod)%mod)%mod)\n"}, {"source_code": "a, b, n, x = map(int, input().split())\nMOD = 10 ** 9 + 7\nans = pow(a, n, MOD) * x\nif a > 1:\n\ttmp = (pow(a, n, MOD) - 1)\n\tif tmp < 0:\n\t\ttmp += MOD\n\ttmp *= pow(a - 1, MOD - 2, MOD)\n\ttmp *= b\nelse:\n\ttmp = n * b\nprint((ans + tmp) % MOD)"}, {"source_code": "#!/usr/bin/env python3\n\n\ndef g(a, b, n, x, mod=10 ** 9 + 7):\n if a == 1:\n return (x + b * n) % mod\n z = pow(a, n, mod)\n inv = pow(a - 1 + mod, mod - 2, mod)\n return (z * x + b * (z - 1 + mod) * inv) % mod\n\nprint(g(*[int(x) for x in input().split()]))\n"}, {"source_code": "a,b,n,x=map(int,input().split())\nm=10**9+7\nif a != 1:\n print((pow(a, n, m)*x + b * ((pow(a, n, m) - 1) * pow(a - 1, m - 2, m)))%m)\nelse:\n print((b*n+x)%m)"}, {"source_code": "a,b,n,x=map(int,input().split())\nm=10**9+7\nif a != 1:\n print( (pow(a,n,m)*x + b*(pow(a,n,m)-1) * pow(a-1,m-2,m))%m )\nelse:\n print((b*n+x)%m)"}], "negative_code": [{"source_code": "mod=1000000007\na,b,n,x=map(int, raw_input().split())\nans=(pow(a,n,mod)*x)%mod\nif a>1:\n \n ans1=((pow(a,n,mod*(a-1))-1)%mod/(a-1))%mod\n ans1=(ans1*b)%mod\nelse:\n ans1=(n*b)%mod\nans=(ans+ans1)%mod\nprint ans\n"}, {"source_code": "from decimal import *\nM = int(1e9 + 7)\nA, B, n, x = (int(x) for x in input().split())\nif A > 1:\n An = pow(A, n, M)\n print((Decimal(An) * Decimal(x) + Decimal(B) * (Decimal(1-An)/Decimal(1-A))) % M)\nelse:\n print((x + B*n) % M)\n"}, {"source_code": "a,b,n,x=map(int,input().split())\n#print(int(x*(a**n)+b*(a**n-1)/(a-1)))\nmod=10**9+7\n\n\ndef bin_pow(a,n):\n if n==1:\n return a\n else:\n if n%2==0:\n return (bin_pow(a,n//2)*bin_pow(a,n//2))%mod\n else:\n return (bin_pow(a,n//2)*bin_pow(a,n//2)*a)%mod\n \n \n \nans=x*bin_pow(a,n)\nif a==1:\n ans+=b*n\nelse:\n ans+=b*(bin_pow(a,n)-1)/(a-1)\nprint(int(ans)%mod)"}, {"source_code": "q = input().split()\na = int(q[0])\nb = int(q[1])\nn = int(q[2])\nx = int(q[3])\nq = pow(a,n-1,1000000007)\nx = q*a*x\nq = (q-1)*pow(a-1,1000000005,1000000007)*a + 1\nq = q*b+x\nprint(q%1000000007)"}, {"source_code": "A, B, n, x = map(int, input().split())\n\ndef fast_exp(A, n, m):\n if n == 0:\n return 1\n if n & 1:\n return A * fast_exp(A, n - 1, m) % m\n return fast_exp(A * A % m, n // 2, m)\n\nm = 10**9 + 7\n\nans = B * (fast_exp(A, n, m) - 1) * fast_exp(A - 1, m - 2, m) % m + fast_exp(A, n, m) * x % m\nans %= m\n\nprint(ans)"}, {"source_code": "from sys import stdin\n\nmod = 10**9+7\n\ndef geo(x, n, m):\n return (pow(x, n+1, m) - 1)*pow(x-1, m-2, m)\n\np, q, n, a = [int(x) for x in stdin.readline().rstrip().split()]\nif p <= 1:\n print(a + q * n)\nelse:\n ans = (a * pow(p, n, mod) + q * (geo(p, n-1, mod) % mod)) % mod\n print(ans)\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**9+7\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n\ndef inv(a):\n return pow(a, MOD-2, MOD)\n\na,b,n,x = Ri()\nans = pow(a, n, MOD) * x\nif a > 1:\n ans += b * ( pow(a, n, MOD) -1 ) * inv(a-1)\nif a == 1:\n ans+=1\n\nprint(ans%MOD)\n\n\n\n\n\n"}, {"source_code": "q = input().split()\na = int(q[0])\nb = int(q[1])\nn = int(q[2])\nx = int(q[3])\nq = pow(a,n-1,1000000007)\nx = q*a*x\nq = (q-1)*pow(a-1,1000000005,1000000007)*a + 1\nq = q*b+x\nprint(q%1000000007)"}, {"source_code": "mod = 10**9+7\ndef modExpo(a,n,x):\n\tif n==0:\n\t\treturn 1\n\telif n&1:\n\t\treturn (a*modExpo((a*a)%x,(n-1)/2,x))%x\n\telse:\n\t\treturn modExpo((a*a)%x,n/2,x)\na,b,n,x = map(int,raw_input().split())\nan = modExpo(a,n,mod)\nans = (an*(x%mod))%mod\nbmod = b%mod\nfor i in range(1,n):\n\tans += ((an*bmod)/a)%mod\nans += bmod\nans %= mod\nprint ans"}, {"source_code": "a,b,n,x=map(int,input().split())\nq = pow(a,n-1,10**9+7)\nx = q*a*x\nif a == 1:\n q = n\nelse:\n q = (q-1)*pow(a-1,10**9+5,10**9+7)*a + 1\nq = q*b+x\nprint(q%10**9+7)"}, {"source_code": "mod = int(10**9 + 7)\nmud = int(10**9 + 6)\n\n\ndef powM(bs, pw, MOD):\n res = 1\n for i in range(pw.bit_length() - 1, -1, -1):\n res = (res * res) % MOD\n if (pw & (1 << i) > 0):\n res = (res * bs) % MOD\n\n return res\n\n\nA, B, n, x = raw_input().split()\n\nA = int(A)\nB = int(B)\nn = int(n) % mud\nx = int(x)\n\nAn = powM(A, n, mod)\nif (n > 1):\n fx = B * (mod + An - 1) % mod * powM(A - 1, mod - 2, mod)\nelse:\n fx = B\n\nprint (An * x + fx) % mod\n"}, {"source_code": "M = int(1e9 + 7)\nA, B, n, x = (int(x) for x in input().split())\nif A != 1:\n An = pow(A, n, M)\n print(int(An * x + B * ((1-An)/(1-A))) % M)\nelse:\n print((x + B*n) % M)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jul 11 16:49:52 2020\n\n@author: shailesh\n\"\"\"\n#def power_sum(A,n):\n# if A == 1:\n# return 1\n\n\nA,B,n,x = [int(i) for i in input().split()]\n\n#n-=1\n\nm = 10**9 + 7\n#val = A**n*x + B*(A**n - 1)//(A-1)\n\nval = pow(A,n,m)*x + B*(pow(A,n,m) - 1)*pow(A-1,m-2,m)\n\nprint(val%(m))"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\na,b,n,x = (int(i) for i in input().split())\nm = int(1e9) + 7\nans = (pow(a,n,m) * x) % m\nn += 1\nif a > 1:\n ans += ((( (1/(1-a)) - (pow(a,n-1,m)/(1-a)) ) % m) * b) % m\nelif a==0:\n ans += b\nelif a==1:\n ans += (n-1)*b % m\nprint(ans % m)"}, {"source_code": "s=map(int,raw_input().split())\na=s[0]\nb=s[1]\nn=s[2]\nx=s[3]\nans=0\nif(a==1):\n\tprint x+n*b\nelse:\n\tan=pow(a,n)\n\t# print yoo\n\n\t# an=((yoo%(pow(10,9)+7))*(a%(pow(10,9)+7)))%(pow(10,9)+7)\n\tans=((an%(pow(10,9)+7))*(x%(pow(10,9)+7)))%(pow(10,9)+7)\n\t# print ans\n\tans=(ans+(b%(pow(10,9)+7))*(((an-1)/(a-1))%(pow(10,9)+7))%(pow(10,9)+7))\n\t# ans=(ans+((((yoo/((a-1)))%(pow(10,9)+7))*(b%(pow(10,9)+7)))%(pow(10,9)+7))%(pow(10,9)+7)\n\tprint ans"}, {"source_code": "import math\nimport sys\nsys.setrecursionlimit(10000)\ndef gcd(a, b):\n return b if a % b == 0 else gcd(b, a % b)\n\ndef lcm(a, b):\n return a*b/gcd(a,b)\n\ndef e_gcd(a, b):\n if (a == 0):\n return 0, 1, b\n x1, y1, d = e_gcd(b % a, a)\n x = y1 - (b / a) * x1\n y = x1\n return x, y, d\n\ns = raw_input()\na, b, n, x = s.split()\na = int(a)\nb = int(b)\nn = int(n)\nx = int(x)\nbase = int(1e9 + 7)\nres = (pow(a, n, base) * x) % base\ns = (b * (1 - pow(a, n, base)) % base + base) % base\nq = (1- a) % base + base\nq %= base\nxx, yy, dd = e_gcd(q, base)\nxx = (xx % base + base) % base\nans = res + s * xx\nprint ans % base\n\n\n\n"}, {"source_code": "\ndef extendedEuclidean(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = extendedEuclidean(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef exp_mod (base, exp, mod):\n if (mod == 1):\n return 0;\n \n number = 1;\n \n while (exp):\n if (exp & 1):\n number = (number * base) % mod;\n exp >>= 1\n base = (base * base) % mod;\n \n return number\n\nif __name__ == '__main__':\n a, b, n, x = map(int, raw_input().split())\n \n m = 1000000007\n s = 0\n \n an = exp_mod (a, n, m)\n if a == 1:\n s = (n+m)%m\n else:\n p = (an-1)%m\n q = extendedEuclidean(a-1, m)[1]\n q = (q+m)%m\n s = (p%m)*(q%m)\n s = (s+m)%m\n # print s, a, an\n \n ss = ((an*x)+m)%m + ((b*s)+m)%m\n \n print ss\n"}, {"source_code": "a, b, x, n = map(int, input().split())\nmod = int(1e9) + 7\n\ndef comb(f, g): # f(g(n))\n return (f[0] * g[0] % mod, (f[0] * g[1] + f[1]) % mod)\n\ndef exp(f, n):\n res = (1, 0)\n cp = f\n for i in range(0, 63):\n if (n >> i) & 1:\n res = comb(cp, res)\n cp = comb(cp, cp)\n return res\n \nres = exp((a, b), n)\nprint((res[0] * x + res[1]) % mod)\n"}, {"source_code": "A, B, n, x = map(int, input().split())\nMOD = 10 ** 19 + 7\n\ndef SD(i):\n if i == 0:\n return 1\n elif i % 2 == 0:\n return (1 + A * SD(i - 1)) % MOD\n else:\n md = pow(A, i // 2 + 1, MOD)\n return ((md + 1) * SD(i // 2)) % MOD\n\nres = pow(A, n, MOD) * x + SD(n - 1) * B\nprint(res % MOD)"}, {"source_code": "def modPow(base, pow, mod):\n ret = 1\n while pow > 0:\n if (pow % 2) == 0:\n base = (base * base) % mod\n pow >>= 1\n else:\n ret = (ret * base) % mod\n pow = pow - 1\n return ret;\n\na, b, x, n = map(int, raw_input().split())\nmodulo = 1000000007\n\nfirst = modPow(a,n,modulo)\nsecond = x % modulo\nthird = 0\nif a != 1:\n third = modPow(a, n, modulo * (a - 1))\n third = modulo * (a - 1) - 1 if third == 0 else third - 1\n third = third / (a - 1)\nelse:\n third = (b * n) % modulo\nans = (((first * second) % modulo) + (third * b) % modulo) % modulo\nprint(ans)"}, {"source_code": "s=map(int,raw_input().split())\na=s[0]\nb=s[1]\nn=s[2]\nx=s[3]\nans=0\nif(a==1):\n\tprint x+n*b\nelse:\n\tan=pow(a,n)\n\t# print yoo\n\n\t# an=((yoo%(pow(10,9)+7))*(a%(pow(10,9)+7)))%(pow(10,9)+7)\n\tans=((an%(pow(10,9)+7))*(x%(pow(10,9)+7)))%(pow(10,9)+7)\n\t# print ans\n\tans=(ans+(b%(pow(10,9)+7))*(((an-1)/(a-1))%(pow(10,9)+7))%(pow(10,9)+7))\n\t# ans=(ans+((((yoo/((a-1)))%(pow(10,9)+7))*(b%(pow(10,9)+7)))%(pow(10,9)+7))%(pow(10,9)+7)\n\tprint ans"}, {"source_code": "mod = 10**9 + 7\n\ndef pow(num, p):\n global mod\n if p == 1:\n return num % mod\n ans = pow(num, p//2) % mod\n if p % 2 == 0:\n return ans * ans % mod\n else:\n return ans * ans * num % mod\n\nA, B, n, x = tuple(map(int, input().split()))\n\nif A != 1:\n ans = B\n ans *= (pow(A, n) - 1) * (A-1)**-1 % mod \n ans += pow(A, n) * x % mod\n ans %= mod\nelse:\n ans = x + n * B\n ans %= mod\n\nprint(round(ans))"}, {"source_code": "a,b,n,x= map(int,input().split()) \ne = 10**9 + 7\nif a==1:\n ans = (x + b*n)%e\nelse :\n ans = (pow(a,n,e)*x + (b*(pow(a,n,e) -1))//(a - 1))%e\nprint(int(ans))\n \n "}, {"source_code": "a,b,n,x=map(int,input().split())\nq = pow(a,n-1,10**9+7)\nx = q*a*x\nif a == 1:\n q = n\nelse:\n q = (q-1)*pow(a-1,10**9+5,10**9+7)*a + 1\nq = q*b+x\nprint(q%10**9+7)"}, {"source_code": "mod = 10**9+7\ndef modExpo(a,n,x):\n\tif n==0:\n\t\treturn 1\n\telif n&1:\n\t\treturn (a*modExpo((a*a)%x,(n-1)/2,x))%x\n\telse:\n\t\treturn modExpo((a*a)%x,n/2,x)\na,b,n,x = map(int,raw_input().split())\nan = modExpo(a,n,mod)\nans = (an*(x%mod))%mod\nbmod = b%mod\nfor i in range(1,n):\n\tans += ((an*bmod)/a)%mod\nans += bmod\nans %= mod\nprint ans"}, {"source_code": "'''\nName : Jaymeet Mehta\ncodeforces id :mj_13\nProblem : Iterated linear function\n'''\nfrom sys import stdin,stdout\nmod=10**9+7\nA,B,n,x = map(int,stdin.readline().split())\nif n==1:\n print(A*x+B)\nelse:\n ans=((pow(A,n,mod)*x)%mod+(B*((pow(A,n,mod)-1)*pow(A-1,mod-2,mod)))%mod)%mod\n print(ans)"}, {"source_code": "mod = 10**9 + 7\n\ndef pow(num, p):\n global mod\n if p == 1:\n return num % mod\n ans = pow(num, p//2) % mod\n if p % 2 == 0:\n return ans * ans % mod\n else:\n return ans * ans * num % mod\n\nA, B, n, x = tuple(map(int, input().split()))\n\nif A != 1:\n ans = B\n ans *= (pow(A, n) - 1) * (A-1)**-1 % mod \n ans += pow(A, n) * x % mod\n ans %= mod\nelse:\n ans = x + n * B\n ans %= mod\n\nprint(round(ans))"}, {"source_code": "data1 = raw_input().split(' ')\n\ndef egcd(a, b):\n\tif a == 0:\n\t\treturn (b, 0, 1)\n\telse:\n\t\tg, y, x = egcd(b % a, a)\n\t\treturn (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n\tg, x, y = egcd(a, m)\n\treturn x % m\n\ndata = []\nfor i in data1:\n\tdata.append(int(i))\nA = data[0]\nB = data[1]\nn = data[2]\nx = data[3]\nmod = 1000000007\nsh1 = (pow(A,n,mod) * x) % mod\nsh3 = B * ((pow(A, n, mod) - 1) * modinv(A - 1, mod)) % mod\nprint (sh1 + sh3) % mod\n\n#A^n * x + B * ((A^(n-1) - 1)/(A - 1)) mod 10^9 + 7"}, {"source_code": "e=10**9+7\na,b,n,x=map(int,input().split())\nt=pow(a,n,e**10)\nprint((t*x+b*(t-1)//(a-1))%e if a-1else (a*x+b)%e)"}, {"source_code": "a,b,n,x = map(int,input().split())\nmd = 10**9+7\nmult = lambda u,v : 0 if v==0 else (u+mult(u,v-1))%md if v % 2 == 1 else (2*mult(u,v//2))%md\nres = mult(pow(a,n,md),x)+mult(mult(pow(a,n,md)-1+md,pow(a-1+md,md-2,md)),b)\nres%=md\nprint(res if n!=1 else (mult(a,x)+b)%md)\n"}, {"source_code": "\ndef extendedEuclidean(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = extendedEuclidean(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef exp_mod (base, exp, mod):\n if (mod == 1):\n return 0;\n \n number = 1;\n \n while (exp):\n if (exp & 1):\n number = (number * base) % mod;\n exp >>= 1\n base = (base * base) % mod;\n \n return number\n\nif __name__ == '__main__':\n a, b, n, x = map(int, raw_input().split())\n \n m = 1000000007\n s = 0\n \n an = exp_mod (a, n, m)\n if a == 1:\n s = (n+m)%m\n else:\n p = (an-1)%m\n q = extendedEuclidean(a-1, m)[1]\n q = (q+m)%m\n s = (p%m)*(q%m)\n s = (s+m)%m\n # print s, a, an\n \n ss = ((an*x)+m)%m + ((b*s)+m)%m\n \n print ss\n"}, {"source_code": "A, B, n, x = map(int,input().split())\n\n\ndef g(s,A):\n if A<2:\n return 1\n return (s-1)//(A-1)\n\ns=(A**n)%((10**9+7)**(max(1,A-1))+9)\nprint((x*s+B*(g(s,A)))%(10**9+7))"}, {"source_code": "a,b,n,x=map(int,raw_input().split())\nmod=1000*1000*1000 +7\nsum=0\nif(a==1):\n sum=(x%mod+n*b%mod)%mod\nelse:\n sum=pow(a,n,mod)*x+(((b*(pow(a,n,mod)-1))%mod)*pow(a-1,mod-2,mod))%mod\n \nprint(sum)\n \n\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jul 11 16:49:52 2020\n\n@author: shailesh\n\"\"\"\n#def power_sum(A,n):\n# if A == 1:\n# return 1\n\n\nA,B,n,x = [int(i) for i in input().split()]\n\n#n-=1\n\nm = 10**9 + 7\n#val = A**n*x + B*(A**n - 1)//(A-1)\n\nval = pow(A,n,m)*x + B*(pow(A,n,m) - 1)*pow(A-1,m-2,m)\n\nprint(val%(m))"}, {"source_code": "M = int(1e9 + 7)\nA, B, n, x = (int(x) for x in input().split())\nif A != 1:\n An = pow(A, n, M)\n print(int(An * x + B * ((1-An)/(1-A))) % M)\nelse:\n print((x + B*n) % M)\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**9+7\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n\ndef inv(a):\n return pow(a, MOD-2, MOD)\n\na,b,n,x = Ri()\nans = pow(a, n, MOD) * x\nif a > 1:\n ans += b * ( pow(a, n, MOD) -1 ) * inv(a-1)\nif a == 1:\n ans+=1\n\nprint(ans%MOD)\n\n\n\n\n\n"}, {"source_code": "def exp_mod (base, exp, mod):\n if (mod == 1):\n return 0;\n \n number = 1;\n \n while (exp):\n if (exp & 1):\n number = (number * base) % mod;\n exp >>= 1\n base = (base * base) % mod;\n \n return number\n\nif __name__ == '__main__':\n a, b, n, x = map(int, raw_input().split())\n \n m = 1000000007\n s = 0\n \n an = exp_mod (a, n, m)\n if a == 1:\n s = n\n else:\n s = (a%m)*((an-1)%m)/((a-1)%m)\n s = (((1+s-an)%m)+m)%m\n \n ss = ((an*x)%m + m)%m\n ss = ((ss + b*s)%m + m)%m\n \n print ss\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\na,b,n,x = (int(i) for i in input().split())\nm = int(1e9) + 7\nans = (pow(a,n,m) * x) % m\nn += 1\nif a > 1:\n ans += ((( (1/(1-a)) - (pow(a,n-1,m)/(1-a)) ) % m) * b) % m\nelif a==0:\n ans += b\nelif a==1:\n ans += (n-1)*b % m\nprint(ans % m)"}, {"source_code": "\na,b,n,x = map(int,raw_input().split())\n\nM = 1000000007\n\ndef exp(a,b):\n\tif b==0:\n\t\treturn 1\n\tif b%2==1:\n\t\treturn (a*exp(a,b-1))%M\n\telse:\n\t\tp = exp(a,b/2)\n\t\treturn (p*p)%M\n\n\n\nres = ((exp(a,n)*x)%M + (((b*(exp(a,n)-1))%M) * exp(a-1,M-2))%M)%M\n\nprint res"}, {"source_code": "import sys\n\nA, B, n, x = map(int, input().split())\nmod = 10**9 + 7\n\n\ndef matmul(matA, matB):\n x, y, z = len(matA), len(matB[0]), len(matA[0])\n res = [[0]*y for _ in range(x)]\n\n for i in range(x):\n for j in range(y):\n for k in range(z):\n res[i][j] += matA[i][k] * matB[k][j]\n res[i][j] %= mod\n\n return res\n\n\nmatA = [\n [A*x + B, 1],\n [x, 1]\n]\nmatB = [\n [A, 0],\n [B, 1]\n]\nn -= 1\n\nwhile n:\n if n & 1:\n matA = matmul(matA, matB)\n matB = matmul(matB, matB)\n n >>= 1\n\nprint(matA[0][0])\n"}, {"source_code": "a, b, n, x = map(int, raw_input().split())\np = pow(a, n, 1000000007)\nprint ((p * x) % 1000000007 + (((p - 1) * pow(a - 1, 1000000005, 1000000007) if a > 1 else 1) * b) % 1000000007) % 1000000007"}, {"source_code": "s=map(int,raw_input().split())\na=s[0]\nb=s[1]\nn=s[2]\nx=s[3]\nans=0\nif(a==1):\n\tprint x+n*b\nelse:\n\tans=pow(a,n)%(pow(10,9)+7)\n\tans=(ans*(x%(pow(10,9)+7)))%(pow(10,9)+7)\n\tans=(ans%(pow(10,9)+7)+(((((pow(a,n)-1)%(pow(10,9)+7))/((a-1)%(pow(10,9)+7)))%(pow(10,9)+7))*(b%(pow(10,9)+7)))%(pow(10,9)+7))%(pow(10,9)+7)\n\tprint ans"}, {"source_code": "global mod\nmod=10**9+7\ndef power(x, y, p) :\n res = 1 # Initialize result\n\n # Update x if it is more\n # than or equal to p\n x = x % p\n\n while (y > 0) :\n\n # If y is odd, multiply\n # x with result\n if ((y & 1) == 1) :\n res = (res * x) % p\n\n # y must be even now\n y = y >> 1 # y = y/2\n x = (x * x) % p\n\n return res\ndef sol(a,b,x,n):\n if a==1:\n return (x+b*n)%mod\n an=power(a,n,mod)\n\n r=((1-an))\n\n f=(b*r)%mod+((x*(an))*(1-a))%mod\n f=f/(1-a)\n f=f%mod\n\n return int(f%mod)\na,b,n,x=list(map(int,input().split()))\nprint(sol(a,b,x,n))\n\"\"\"\"\n10000 10000 1000000000000000 10000\n\"\"\"\n"}, {"source_code": "a,b,n,x=map(int,raw_input().split())\nmod=1000000007\nans=pow(a,n,mod)\nans=ans*x\nans%=mod\nans1=pow(a,n,mod)-1+mod\nans1%=mod\nans2=pow(a-1,mod-2,mod)\nans1=ans1*ans2\nans1%=mod\nans1*=b\nans1%=mod\nans=ans+ans1\nans%=mod\nprint ans"}, {"source_code": "a,b,n,x=map(int,raw_input().split())\nmod=10**9+7\nprint (pow(a,n,mod)*x+b*(pow(a,n,mod)-1)*(pow(a-1,mod-2,mod))+mod)%mod\n\n"}, {"source_code": "A, B, n, x = (int(x) for x in input().split())\nM = int(1e9 + 7)\n\ndef pow_mod(x, y, z):\n v = 1\n while y:\n if y & 1:\n v = (v * x) % z\n y >>= 1\n x = (x * x) % z\n return v\n\nif A > 1:\n An = pow_mod(A, n, M)\n print((An * x + B * ((1-An)//(1-A))) % M)\nelse:\n print((x + B*n) % M)\n"}, {"source_code": "mod = 10**9 + 7\n\ndef pow(num, p):\n global mod\n if p == 1:\n return num % mod\n ans = pow(num, p//2) % mod\n if p % 2 == 0:\n return ans * ans % mod\n else:\n return ans * ans * num % mod\n\nA, B, n, x = tuple(map(int, input().split()))\n\nif A != 1:\n ans = B\n ans *= (pow(A, n) - 1) * (A-1)**-1 % mod \n ans += pow(A, n) * x % mod\n ans %= mod\nelse:\n ans = x + n * B\n ans %= mod\n\nprint(round(ans))"}, {"source_code": "from sys import stdin, stderr, stdout, exit\nfrom math import gcd\n\nreadl = lambda : list(map(int, stdin.readline().strip().split()))\n\ndef nok(a, b):\n return a // gcd(a, b) * b\n\ndef main():\n A, B, n, x = readl()\n if(A == 1):\n stdout.write(str(B*n + x))\n else:\n stdout.write(str((A**n * ((A-1) * x + B) - B) // ((A-1) * x)))\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def solve(A,B,n,x):\n m = 10**9 + 7\n # A^n*x + B*(1-A^n)/(1-A) -> A^n*x + B*(1-A^n)*(1-A)^-1 -> A^n*x + B*(1-A^n)*(1-A)^(m-2)\n return (pow(A,n,m)*x + B*((1 - pow(A,n,m)) * pow(1-A,m-2,m))) % m\nprint(solve(*list(map(int,input().split()))))\n\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\n\n(A, B, n, x) = (int(i) for i in input().split())\n\nstart = time.time()\n\nmd = 1000000007\n\nif A!=1 :\n an = pow(A, n, md*(A-1))\n bn = B*(an-1)//(A-1)\n ans = (an*x+bn)%md\nelse:\n ans = (x+B*(n-1))%md\nprint(ans)\n\nfinish = time.time()\n#print(finish - start)\n"}, {"source_code": "a,b,n,x = map(int,input().split())\nmd = 10**9+7\nmult = lambda u,v : 0 if v==0 else (u+mult(u,v-1))%md if v % 2 == 1 else (2*mult(u,v//2))%md\nget_prog = lambda a,b,n : mult(pow(a,n,md)-1+md,pow(a-1+md,md-2,md)) if a!=1 else 1 \nres = mult(pow(a,n,md),x)+mult(get_prog(a,b,n),b)\nres%=md\nprint(res)\n"}, {"source_code": "from sys import stdin\n\n\n# 2**0 + 2**1 + 2**2 +..\ndef sum_pow(r, n, m=None):\n return div(add(1, -pow(r, n + 1)), (1 - r))\n\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nadd = lambda a, b: (a % mod + b % mod) % mod\nmult = lambda a, b: ((a % mod) * (b % mod)) % mod\ndiv = lambda a, b: mult(a, inv(b))\ninv = lambda a: pow(a, mod - 2, mod)\nmod = 10 ** 9 + 7\n\na, b, n, x = rints()\ng = [x]\nfor i in range(2):\n g.append(a * g[-1] + b)\n\nfac = g[1] - g[0]\npo = (g[-1] - g[1]) // fac\n\nprint(add(x, mult(fac, sum_pow(po, n - 1))))\n"}, {"source_code": "\n(a, b, n, x) = map(int, input().split(\" \"))\n\nxp = pow(a, n % 1000000006, 1000000007)\n\nans = (xp * x) % 1000000007\n\ntmp = (xp - 1) * pow(a - 1, 1000000005, 1000000007) * b\n\ntmp = tmp % 1000000007\n\nans = ans + tmp\n\nans = ans % 1000000007\n\nprint (ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\na,b,n,x = (int(i) for i in input().split())\nm = int(1e9) + 7\nans = (pow(a,n,m) * x) % m\nn += 1\ntry:\n ans += ((( (1/(1-a)) - (pow(a,n-1,m)/(1-a)) ) % m) * b) % m\nexcept:\n pass\nprint(ans % m)"}, {"source_code": "e=10**9+7\na,b,n,x=map(int,input().split())\nt=pow(a,n,e)\nprint((t*x+b*(t-1)//(a-1))%e if a-1else a*x+b)"}, {"source_code": "A, B, n, x = map(int,input().split())\n\n\ndef g(s,A):\n if A<2:\n return 1\n return (s-1)//(A-1)\n\ns=(A**n)%((10**9+7)**(max(1,A-1)))\nprint((x*s+B*(g(s,A)))%(10**9+7))"}, {"source_code": "a, b, n, x = map(int, input().split())\nmod = 10 ** 9 + 7\nres = pow(a, n, mod) * x\nif a != 1:\n res += b * (pow(a, n, mod) - 1) // (a - 1)\nelse:\n res += b * n\nres %= mod\nprint(res)"}, {"source_code": "def exp_mod (base, exp, mod):\n if (mod == 1):\n return 0;\n \n number = 1;\n \n while (exp):\n if (exp & 1):\n number = (number * base) % mod;\n exp >>= 1\n base = (base * base) % mod;\n \n return number\n\nif __name__ == '__main__':\n a, b, n, x = map(int, raw_input().split())\n \n m = 1000000007\n s = 0\n \n an = exp_mod (a, n, m)\n if a == 1:\n s = n\n else:\n s = (a%m)*((an-1)%m)/((a-1)%m)\n s = (((1+s-an)%m)+m)%m\n \n ss = ((an*x)%m + m)%m\n ss = ((ss + b*s)%m + m)%m\n \n print ss\n"}, {"source_code": "a,b,n,x = map(int,input().split())\nmd = 10**9+7\nmult = lambda u,v : 0 if v==0 else (u+mult(u,v-1))%md if v % 2 == 1 else (2*mult(u,v//2))%md\nres = mult(pow(a,n,md),x)+mult(mult(pow(a,n,md)-1,pow(a-1,md-2,md)),b)\nres%=md\nprint(res if n!=1 else (mult(a,x)+b)%md)\n"}, {"source_code": "A, B, n, x = map(int, input().split())\nd = 10 ** 9 + 7\na = pow(A, n, d)\nb = pow(A - 1, d - 2, d)\nprint((a * x + (a - 1) * B * b) % d)"}, {"source_code": "A, B, n, x = map(int, input().split())\nd = 10 ** 9 + 7\nu = pow(A, n, d)\nv = pow(A - 1, d - 2, d)\nprint((u * x + B * max(1, (u - 1) * v)) % d)"}, {"source_code": "a,b,n,x= map(int,input().split()) \ne = 10**9 + 7\nif a==1:\n ans = (x + b*n)%e\nelse :\n ans = (pow(a,n,e)*x + (b*pow(a,n,e)*pow(a-1,e-2,e))%e)%e\nprint(int(ans))\n \n "}, {"source_code": "A,B,n,x=map(int,input().split())\ndef f(x):\n return A*x+B\nbi=f(f(x))\nans=10**9+7\ndef fn(x,n):\n global bi\n if n==1:\n return f(x)\n elif n==2:\n return bi\n else:\n return fn(fn(x,n-n//2),n//2)\n \nprint(fn(x,n)%ans)\n"}, {"source_code": "'''\nName : Jaymeet Mehta\ncodeforces id :mj_13\nProblem : Iterated linear function\n'''\nfrom sys import stdin,stdout\nmod=10**9+7\nA,B,n,x = map(int,stdin.readline().split())\nif n==1:\n print((A*x+B)%mod)\nelse:\n ans=((pow(A,n,mod)*x)%mod+(B*((pow(A,n,mod)-1)*pow(A-1,mod-2,mod)))%mod)%mod\n print(ans%mod)"}, {"source_code": "a,b,n,x=map(int,input().split())\nq = pow(a,n-1,10**9+7)\nx = q*a*x\nif a == 1:\n q = n\nelse:\n q = (q-1)*pow(a-1,10**9+5,10**9+7)*a + 1\nq = q*b+x\nprint(q%10**9+7)"}, {"source_code": "a,b,n,x= map(int,input().split()) \ne = 10**9 + 7\nif a==1:\n ans = (x + b*n)%e\nelse :\n ans = (pow(a,n,e)*x + (b*(pow(a,n,e) -1))//(a - 1))%e\nprint(int(ans))\n \n "}, {"source_code": "global mod\nmod=10**7\ndef power(x, y, p) :\n res = 1 # Initialize result\n\n # Update x if it is more\n # than or equal to p\n x = x % p\n\n while (y > 0) :\n\n # If y is odd, multiply\n # x with result\n if ((y & 1) == 1) :\n res = (res * x) % p\n\n # y must be even now\n y = y >> 1 # y = y/2\n x = (x * x) % p\n\n return res\ndef sol(a,b,x,n):\n if a==1:\n return (x+b*n)%mod\n an=power(a,n,mod)\n return int(((b%mod*((1-an)/(1-a))%mod)%mod+(x%mod*(an))%mod)%mod)\na,b,n,x=list(map(int,input().split()))\nprint(sol(a,b,x,n))\n\"\"\"\"\n10000 10000 1000000000000000 10000\n\"\"\"\n"}, {"source_code": "a, b, n, x = map(int, input().split())\nmod = 10 ** 9 + 7\nres = pow(a, n, mod) * x\nif a != 1:\n res += ((pow(a, n) - 1) % mod) // (a - 1) * b % mod\nelse:\n res += b * n\nres %= mod\nprint(res)"}, {"source_code": "mod = 10**9 + 7\n\ndef pow(num, p):\n global mod\n if p == 1:\n return num % mod\n ans = pow(num, p//2) % mod\n if p % 2 == 0:\n return ans * ans % mod\n else:\n return ans * ans * num % mod\n\nA, B, n, x = tuple(map(int, input().split()))\n\nans = B\nif A != 1:\n ans *= (pow(A, n) - 1) % mod * (A-1)**-1 % mod \n ans %= mod\n ans += pow(A, n) * x % mod\nans %= mod\n\nprint(int(ans))"}, {"source_code": "def egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef modexp ( g, u, p ):\n \"\"\"computes s = (g ^ u) mod p\n args are base, exponent, modulus\n (see Bruce Schneier's book, _Applied Cryptography_ p. 244)\"\"\"\n s = 1\n while u != 0:\n if u & 1:\n s = (s * g)%p\n u >>= 1\n g = (g * g)%p;\n return s\n\nA,B,n,x=map(int, raw_input().split())\nmagic=10**9+7\nif A==1:\n print (x+B)%magic\nelse:\n An=modexp(A, n, magic)\n Annumerator=(An-1)%magic\n Adenominator=(A-1)%magic\n Adenominator=modinv(Adenominator, magic)\n print ((An*x) % magic+ (((Annumerator*Adenominator)%magic) *B )%magic)%magic"}, {"source_code": "a,b,n,x = map(int,input().split())\nmod = 10**9 +7\nans = pow(a,n,mod)*x\ngp = (pow(a,n,mod)-1)*(pow(a-1,mod-2,mod))*b\nprint((ans+gp)%mod)"}, {"source_code": "A, B, n, x = map(int, input().split())\n\ndef fast_exp(A, n, m):\n if n == 0:\n return 1\n if n & 1:\n return A * fast_exp(A, n - 1, m) % m\n return fast_exp(A * A % m, n // 2, m)\n\nm = 10**9 + 7\n\nans = B * (fast_exp(A, n, m) - 1) * fast_exp(A - 1, m - 2, m) % m + fast_exp(A, n, m) * x % m\nans %= m\n\nprint(ans)"}, {"source_code": "import math\n[A,B,n,x]=[int(x) for x in raw_input().split()]\nq=pow(10,9)+7\ntotal=pow(A,n,q)*x\ntotal%=q\nif A==1:\n total=A+n*B\n total%=q\n print total\nelse:\n m=pow(A,n,q)-1\n m*= pow(A-1,q-2,q)\n m*=B\n total+=m\n total%=q\n print total"}, {"source_code": "a, b, x, n = map(int, input().split())\nmod = int(1e9) + 7\n\ndef comb(f, g): # f(g(n))\n return (f[0] * g[0] % mod, (f[0] * g[1] + f[1]) % mod)\n\ndef exp(f, n):\n res = (1, 0)\n cp = f\n for i in range(0, 63):\n if (n >> i) & 1:\n res = comb(cp, res)\n cp = comb(cp, cp)\n return res\n \nf = exp((a, b), n)\nprint((f[0] * x + f[1]) % mod)\n"}, {"source_code": "import sys\n\nMOD = 10**9 + 7\n\n\ndef super_power(A, n, m):\n if n == 1:\n return A\n if n % 2 == 0:\n res = super_power(A, n/2, m) % m\n return res ** 2 % m\n else:\n res = super_power(A, (n - 1)/2, m) % m\n return ((res ** 2) % m * A) % m\n\n\ndef geom_sum(power, p, q, b1):\n if q == 1:\n return power * b1\n return b1 * (1-p) / (1 - q)\n\n\nif __name__ == \"__main__\":\n A, B, n, x = [int(i) for i in sys.stdin.readline().strip().split()]\n power = super_power(A, n, MOD)\n\n print (power * x + B * geom_sum(n, power, A, 1)) % MOD\n\n\n\n\n"}, {"source_code": "\na,b,n,x = map(int,raw_input().split())\n\nM = 1000000007\n\ndef exp(a,b):\n\tif b==0:\n\t\treturn 1\n\tif b%2==1:\n\t\treturn (a*exp(a,b-1))%M\n\telse:\n\t\tp = exp(a,b/2)\n\t\treturn (p*p)%M\n\n\nif n==1:\n\tres = (a*x+b)%M\nelse:\n\tres = ((exp(a,n)*x)%M + (((b*(exp(a,n)-1))%M) * exp(a-1,M-2))%M)%M\n\nprint res"}, {"source_code": "a,b,n,x=map(int,input().split())\n#print(int(x*(a**n)+b*(a**n-1)/(a-1)))\nmod=10**9+7\n\n\ndef bin_pow(a,n):\n if n==1:\n return a\n else:\n if n%2==0:\n return (bin_pow(a,n//2)*bin_pow(a,n//2))%mod\n else:\n return (bin_pow(a,n//2)*bin_pow(a,n//2)*a)%mod\n \n \n \nans=x*bin_pow(a,n)\nif a==1:\n ans+=b*(n-1)\nelse:\n ans+=b*(bin_pow(a,n)-1)/(a-1)\nprint(int(ans)%mod)"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**9+7\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n\ndef inv(a):\n return pow(a, MOD-2, MOD)\n\na,b,n,x = Ri()\nans = pow(a, n, MOD) * x\nans += b * ( pow(a, n, MOD) -1 ) * inv(a-1)\n\nprint(ans%MOD)\n\n\n\n\n\n"}, {"source_code": "MOD = 10 ** 9 + 7\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b / a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef gsum(a, r, n):\n inv = modinv(r - 1, MOD)\n return (a - a * pow(r, n + 1, MOD)) * inv * -1\n\na, b, n, x = map(int, raw_input().split())\n\nif a == 1:\n print (n * x + b) % MOD\nelse:\n print (pow(a, n, MOD) * x + gsum(b, a, n - 1)) % MOD\n"}, {"source_code": "\n(a, b, n, x) = map(int, input().split(\" \"))\n\nxp = pow(a, n, 1000000007)\n\nans = (xp * x) % 1000000007\n\ntmp = (xp - 1) * pow(a - 1, 1000000005, 1000000007)\n\ntmp = tmp % 1000000007\n\ntmp = tmp * b\n\ntmp = tmp % 1000000007\n\nans = ans + tmp\n\nans = ans % 1000000007\n\nprint (ans)"}, {"source_code": "a, b, n, x = map(int, input().split(' '))\nprint(((pow(a, n, 10**9+7)*x)%(10**9+7)+b*(pow(a, n, 10**9+7)-1)*(pow(a-1, 10**9+5, 10**9+7)))%(10**9+7))\n"}, {"source_code": "a,b,n,x=map(int,input().split())\nq = pow(a,n-1,10**9+7)\nx = q*a*x\nif a == 1:\n q = n\nelse:\n q = (q-1)*pow(a-1,10**9+5,10**9+7)*a + 1\nq = q*b+x\nprint(q%10**9+7)"}, {"source_code": "a,b,n,x=map(int,raw_input().split())\nmod=1000*1000*1000 +7\nsum=0\nif(a==1):\n sum=(x%mod+n*b%mod)%mod\nelse:\n sum=pow(a,n,mod)*x+(((b*(pow(a,n,mod)-1))%mod)*pow(a-1,mod-2,mod))%mod\n \nprint(sum)\n \n\n"}, {"source_code": "A, B, n, x = map(int,input().split())\n\n\ndef g(s,A):\n if A<2:\n return 1\n return (s-1)//(A-1)\n\ns=(A**n)%((10**9+7)**(min(10,A-1)))\nprint((x*s+B*(g(s,A)))%(10**9+7))"}, {"source_code": "a,b,n,x=map(int,input().split())\nq = pow(a,n-1,10**9+7)\nx = q*a*x\nif a == 1:\n q = n\nelse:\n q = (q-1)*pow(a-1,10**9+5,10**9+7)*a + 1\nq = q*b+x\nprint(q%10**9+7)"}, {"source_code": "from decimal import *\nM = 1000000007\nA, B, n, x = (int(x) for x in input().split())\nif A > 1:\n An = pow(A, n, M)\n print((An * x + B * (1-An) * pow(1-A, M-1, M)) % M)\nelse:\n print((x + B*n) % M)\n"}, {"source_code": "mod = 10**9 + 7\n\ndef pow(num, p):\n global mod\n if p == 1:\n return num % mod\n ans = pow(num, p//2) % mod\n if p % 2 == 0:\n return ans * ans % mod\n else:\n return ans * ans * num % mod\n\nA, B, n, x = tuple(map(int, input().split()))\n\nif A != 1:\n ans = B\n ans *= (pow(A, n) - 1) * (A-1)**-1 % mod \n ans += pow(A, n) * x % mod\n ans %= mod\nelse:\n ans = x + n * B\n ans %= mod\n\nprint(round(ans))"}, {"source_code": "def modPow(base, pow, mod):\n ret = 1\n while pow > 0:\n if (pow % 2) == 0:\n base = (base * base) % mod\n pow >>= 1\n else:\n ret = (ret * base) % mod\n pow = pow - 1\n return ret;\n\na, b, x, n = map(int, raw_input().split())\nmodulo = 1000000007\n\nfirst = modPow(a,n,modulo)\nsecond = x % modulo\nthird = 0\nif a != 1:\n third = modPow(a, n, modulo * (a - 1))\n third = modulo * (a - 1) - 1 if third == 0 else third - 1\n third = third / (a - 1)\nelse:\n third = (b * n) % modulo\nans = (((first * second) % modulo) + (third * b) % modulo) % modulo\nprint(ans)"}, {"source_code": "def modPow(base, pow, mod):\n ret = 1\n while pow > 0:\n if (pow % 2) == 0:\n base = (base * base) % mod\n pow >>= 1\n else:\n ret = (ret * base) % mod\n pow = pow - 1\n return ret;\n\na, b, x, n = map(int, raw_input().split())\nmodulo = 1000000007\n\nfirst = modPow(a,n,modulo)\nsecond = x % modulo\nthird = 0\nif a != 1:\n third = modPow(a, n, modulo * (a - 1))\n third = modulo * (a - 1) - 1 if third == 0 else third - 1\n third = third / (a - 1)\nelse:\n third = (b * n) % modulo\nans = (((first * second) % modulo) + (third * b) % modulo) % modulo\nprint(ans)"}, {"source_code": "A, B, n, x = map(int, raw_input().split())\nprint x * A**n + B * (A**n-1) / max(1, (A-1))\n"}, {"source_code": "from decimal import *\nM = 1000000007\nA, B, n, x = (int(x) for x in input().split())\nif A > 1:\n An = pow(A, n, M)\n print((An * x + B * (1-An) * pow(1-A, M-1, M)) % M)\nelse:\n print((x + B*n) % M)\n"}, {"source_code": "import sys\n\nf = sys.stdin\nA, B, n, x = map(int, f.readline().strip().split(' '))\nif A == 1:\n print(x + n * B)\nelse:\n ans = A ** n * x + (A ** n - 1) / (A - 1) * B\n print(ans)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jul 11 16:49:52 2020\n\n@author: shailesh\n\"\"\"\n#def power_sum(A,n):\n# if A == 1:\n# return 1\n\n\nA,B,n,x = [int(i) for i in input().split()]\n\n#n-=1\n\nm = 10**9 + 7\n#val = A**n*x + B*(A**n - 1)//(A-1)\n\nval = pow(A,n,m)*x + B*(pow(A,n,m) - 1)*pow(A-1,m-2,m)\n\nprint(val%(m))"}, {"source_code": "\n(a, b, n, x) = map(int, input().split(\" \"))\n\nxp = pow(a, n, 1000000007)\n\nans = (xp * x) % 1000000007\n\ntmp = (xp - 1) * pow(a - 1, 1000000005, 1000000007)\n\ntmp = tmp % 1000000007\n\ntmp = tmp * b\n\ntmp = tmp % 1000000007\n\nans = ans + tmp\n\nans = ans % 1000000007\n\nprint (ans)"}, {"source_code": "def modPow(base, pow, mod):\n ret = 1\n while pow > 0:\n if (pow % 2) == 0:\n base = (base * base) % mod\n pow >>= 1\n else:\n ret = (ret * base) % mod\n pow = pow - 1\n return ret;\n\na, b, x, n = map(int, raw_input().split())\nmodulo = 1000000007\n\nfirst = modPow(a,n,modulo)\nsecond = x % modulo\nthird = 0\nif a != 1:\n third = modPow(a, n, modulo * (a - 1))\n third = modulo * (a - 1) - 1 if third == 0 else third - 1\n third = third / (a - 1)\nelse:\n third = (b * n) % modulo\nans = (((first * second) % modulo) + (third * b) % modulo) % modulo\nprint(ans)"}, {"source_code": "mod = 10**9 + 7\n\ndef pow(num, p):\n global mod\n if p == 1:\n return num % mod\n ans = pow(num, p//2) % mod\n if p % 2 == 0:\n return ans * ans % mod\n else:\n return ans * ans * num % mod\n\nA, B, n, x = tuple(map(int, input().split()))\n\nans = B\nif A != 1:\n ans *= (pow(A, n) - 1) % mod * (A-1)**-1 % mod \n ans %= mod\n ans += pow(A, n) * x % mod\nans %= mod\n\nprint(int(ans))"}, {"source_code": "a,b,n,x=map(int, input().split());\nm=1000000007;\ndef modex(a,n):\n\tans=1\n\twhile n:\n\t\tif n&1:\n\t\t\tans=(ans%m*a%m)%m\n\t\ta=(a%m*a%m)%m\n\t\tn>>=1\n\treturn ans\nif a==1:\n\tprint((x%m+(b%m*(n-1)%m)%m)%m)\nelse:\n\tprint(((modex(a,n)%m*x%m)%m+(b%m*((modex(a,n)%m-1%m)%m)%m*(modex(a-1,m-2)))%m)%m)"}, {"source_code": "a,b,n,x=map(int,input().split())\nm=10**9+7\nprint((pow(a,n,m)*x+b*(pow(a,n,m)-1)*pow(a-1,m-2,m))%m)\n"}, {"source_code": "a, b, x, n = map(int, input().split())\nmod = int(1e9) + 7\n\ndef comb(f, g): # f(g(n))\n return (f[0] * g[0] % mod, (f[0] * g[1] + f[1]) % mod)\n\ndef exp(f, n):\n res = (1, 0)\n cp = f\n for i in range(0, 63):\n if (n >> i) & 1:\n res = comb(cp, res)\n cp = comb(cp, cp)\n return res\n \nres = exp((a, b), n)\nprint((res[0] * x + res[1]) % mod)\n"}, {"source_code": "def poll(a, k):\n if k == 1:\n return a\n if k % 2 == 1:\n return poll(a * a % 1000000007, k // 2) * a % 1000000007\n return poll(a * a % 1000000007, k // 2)\n\na, b, n, x = [int(i) for i in input().split()]\nr = poll(a, n)\nrr = r - 1\nrr *= poll((a - 1), 1000000005)\nrr *= b\nr *= x\nprint((r + rr) % 1000000007)"}], "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e"} {"source_code": "input()\ns = input()\nx = []\ny = []\nfor i in s:\n if(i != '0'):\n y.append((int(i) - 1)//3)\n x.append((int(i) - 1)%3)\n else:\n y.append(3)\n x.append(1)\nx.sort()\ny.sort()\nif('0' in s):\n if((y[-1] - y[0])==3):\n print('YES')\n else:\n print('NO')\nelif(('8' in s)and('7'not in s) and ('9') not in s):\n print('NO')\nelse:\n if((x[-1] - x[0])==2 and (y[-1] - y[0])==2):\n print('YES')\n else:\n print('NO')", "positive_code": [{"source_code": "n=int(input())\ninp=[int(i) for i in input()]\na=[[1,2,3],[1,4,7,0],[7,0,9],[3,6,9,0]]\nres='YES'\nfor i in a:\n for j in i:\n if j in inp:\n break\n else:\n res='NO'\nprint(res)\n"}, {"source_code": "def get(a):\n if a == '0':\n return([3, 1])\n else:\n a = int(a)\n return([(a - 1) // 3, (a - 1) % 3])\n\ndef check(a):\n if (-1 < a[0] < 3 and -1 < a[1] < 3) or (a == [3, 1]):\n return True\n return False\n \nn = int(input())\ns = input()\nQ = []\nfor i in range(3):\n for j in range(3):\n Q.append([i, j])\nQ.append([3, 1])\nprev = get(s[0])\nfor i in range(1, len(s)):\n now = get(s[i])\n fir = now[0] - prev[0]\n sec = now[1] - prev[1]\n q = []\n for pair in Q:\n new = [pair[0] + fir, pair[1] + sec]\n if check(new):\n q.append(new)\n prev = now\n Q = q\nif len(Q) > 1:\n print('NO')\nelse:\n print('YES')\n\n \n"}, {"source_code": "n=int(raw_input())\ns=raw_input()\na=[1]*10\nfor i in range(n):\n c=int(s[i])\n a[c]=0\n\nb=0\nif a[1] and a[2] and a[3]:\n b= -3\nif a[7] and a[9] and a[0]:\n b= +3\nif a[1] and a[4] and a[7] and a[0]:\n\tb= -1\nif a[3] and a[6] and a[9] and a[0]:\n\tb= +1\nif b==0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n = input()\na = map(int, list(raw_input()))\nref = [[0,0], [0,1], [0,2], [1,0], [1,1], [1,2], [2,0], [2,1], [2,2], [3,1]]\nmapp = {1:[0,0], 2:[0,1], 3:[0,2], 4:[1,0], 5:[1,1], 6:[1,2], 7:[2,0], 8:[2,1], 9:[2,2], 0:[3,1]}\nb = [mapp[a[i]] for i in range(n)]\nc = [[b[i][0] - 1, b[i][1]] for i in range(n)]\nfor i in range(n):\n if c[i] not in ref:\n break\nelse:\n print \"NO\"\n exit(0)\nc = [[b[i][0] + 1, b[i][1]] for i in range(n)]\nfor i in range(n):\n if c[i] not in ref:\n break\nelse:\n print \"NO\"\n exit(0)\nc = [[b[i][0], b[i][1] - 1] for i in range(n)]\nfor i in range(n):\n if c[i] not in ref:\n break\nelse:\n print \"NO\"\n exit(0)\nc = [[b[i][0], b[i][1] + 1] for i in range(n)]\nfor i in range(n):\n if c[i] not in ref:\n break\nelse:\n print \"NO\"\n exit(0)\nprint \"YES\"\n"}, {"source_code": "def main():\n n = int(raw_input())\n arr = set(map(int, raw_input()))\n\n up = arr.intersection({1, 2, 3})\n dwn = arr.intersection({0, 7, 9})\n rt = arr.intersection({0, 3, 6, 9})\n lft = arr.intersection({0, 1, 4, 7})\n\n print 'NO' if len(up) == 0 or len(dwn) == 0 or len(rt) == 0 or len(lft) == 0 else 'YES'\n\nmain()\n"}, {"source_code": "import sys\n\nMOVES = {\n #up,down,right,left\n '0': (1,0,0,0),\n '1': (0,1,1,0),\n '2': (0,1,1,1),\n '3': (0,1,0,1),\n '4': (1,1,1,0),\n '5': (1,1,1,1),\n '6': (1,1,0,1),\n '7': (1,0,1,0),\n '8': (1,1,1,1),\n '9': (1,0,0,1)\n}\n\n\ndef check(n, digits):\n for i in xrange(4):\n total = sum(MOVES[d][i] for d in digits)\n if total == len(digits):\n return False\n return True\n\nif __name__ == \"__main__\":\n n = int(sys.stdin.readline().strip())\n digits = sys.stdin.readline().strip()\n if check(n, digits):\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "# I was being very very lazy...\nraw_input()\na = raw_input()\n#print (0b0111 & 0b1011)\n#up right down left\n#123\n#456\n#789\n# 0\n# 0 1 2 3 4 5 6 7 8 9\nref = (0b1000,0b0110,0b0111,0b0011,0b1110,0b1111,0b1011,0b1100,0b1111,0b1001)\nb = 0b1111\nfor x in a:\n b = b & ref[int(x)]\nif b == 0:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "left = {\n 1: None,\n 2: 1,\n 3: 2,\n 4: None,\n 5: 4,\n 6: 5,\n 7: None,\n 8: 7,\n 9: 8,\n 0: None\n}\n\nright = {\n 1: 2,\n 2: 3,\n 3: None,\n 4: 5,\n 5: 6,\n 6: None,\n 7: 8,\n 8: 9,\n 9: None,\n 0: None\n}\n\nup = {\n 1: None,\n 2: None,\n 3: None,\n 4: 1,\n 5: 2,\n 6: 3,\n 7: 4,\n 8: 5,\n 9: 6,\n 0: 8\n}\n\ndown = {\n 1: 4,\n 2: 5,\n 3: 6,\n 4: 7,\n 5: 8,\n 6: 9,\n 7: None,\n 8: 0,\n 9: None,\n 0: None\n}\n\ndef func(comb, d):\n for element in comb:\n if d[int(element)] is None:\n return False\n return True\n\nif __name__ == \"__main__\":\n n = int(input())\n comb = str(input())\n\n if func(comb, left) == True or func(comb, right) == True or func(comb, up) == True or func(comb, down) == True:\n print(\"NO\")\n else:\n print(\"YES\")\n\n"}, {"source_code": "dirs = {\n 'up': [4, 5, 6, 7, 8, 9, 0],\n 'down': [1, 2, 3, 4, 5, 6, 8],\n 'left': [2, 3, 5, 6, 8, 9],\n 'right': [1, 2, 4, 5, 7, 8],\n}\n\ninput()\nnum = input()\nds = [int(x) for x in num]\n\ndirsleft = {'up', 'down', 'left', 'right'}\n\nfor d in ds:\n for k, v in dirs.items():\n if d not in v and k in dirsleft:\n dirsleft.remove(k)\nprint('YES' if not dirsleft else 'NO')\n"}, {"source_code": "n = int(raw_input())\ns = raw_input().strip()\nd = {'0': (3, 1)}\nfor c in '123456789':\n x = int(c) - 1\n d[c] = (x / 3, x % 3)\na = [d[c] for c in s]\nb = 0\nfor c in '1234567890':\n p = d[c]\n t = [(p[0] - a[0][0] + q[0], p[1] - a[0][1] + q[1]) for q in a]\n if all(x in d.values() for x in t):\n b += 1 \nprint \"YES\" if b == 1 else \"NO\"\n"}, {"source_code": "n = input()\ns = set(map(int,input()))\nif all(map(lambda x: x&s!=set(),({1,4,7,0},{3,6,9,0},{7,0,9},{1,2,3}))):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\na = list(map(int, input()))\nb = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [-1, 0, -1]]\np = [0] * 10\np[0] = 4, 2\np[1] = 1, 1\np[2] = 1, 2\np[3] = 1, 3\np[4] = 2, 1\np[5] = 2, 2\np[6] = 2, 3\np[7] = 3, 1\np[8] = 3, 2\np[9] = 3, 3\npath = []\nfor i in range(1, n):\n dx = p[a[i]][0] - p[a[i - 1]][0]\n dy = p[a[i]][1] - p[a[i - 1]][1]\n path.append((dx, dy))\n\ndef go(x, y, i):\n if i == n - 1:\n print('NO')\n exit()\n nx, ny = x + path[i][0], y + path[i][1]\n if 1 <= nx <= 4 and 1 <= ny <= 3 and b[nx - 1][ny - 1] != -1:\n go(nx, ny, i + 1)\n \nfor x, y in p:\n if b[x - 1][y - 1] != a[0] and b[x - 1][y - 1] != -1:\n go(x, y, 0)\nprint('YES')\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nLeftCol = False\nRightCol = False\nTopRow = False\nBottomRow = False\n\nif '1' in s or '2' in s or '3' in s:\n\tTopRow = True\nif '1' in s or '4' in s or '7' in s:\n\tLeftCol = True\nif '3' in s or '6' in s or '9' in s:\n\tRightCol = True\nif '7' in s or '8' in s or '9' in s:\n\tBottomRow = True\n\n\nif '0' not in s:\n\tif LeftCol == False or RightCol == False or BottomRow == False or TopRow == False:\n\t\tprint 'NO'\n\telse:\n\t\tif '8' in s and '7' not in s and '9' not in s:\n\t\t\tprint 'NO'\n\t\telse:\n\t\t\tprint 'YES'\nelse:\n\tif TopRow == False:\n\t\tprint 'NO'\n\telse:\n\t\tprint 'YES'"}, {"source_code": "n = int(raw_input())\ns = raw_input()\ncords = []\nfor c in s:\n c = int(c)\n if c == 0:\n row, col = 3, 1\n else:\n row, col = (c-1)/3, (c-1)%3\n cords.append((row, col))\nvariants = 0\n\ndef tryforxy(curx, cury):\n isValid = True\n for i in range(1, len(cords)):\n curx += cords[i][0] - cords[i-1][0]\n cury += cords[i][1] - cords[i-1][1]\n if curx == 3 and cury == 1:\n continue\n elif curx >= 0 and curx < 3 and cury >= 0 and cury < 3:\n continue\n else:\n isValid = False\n return isValid\n\nfor x in range(3):\n for y in range(3):\n variants += tryforxy(x, y)\nvariants += tryforxy(3, 1)\nif variants > 1:\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n = int(raw_input())\na = raw_input()\nlef, rig, up, dow = 0, 0, 0, 0\nfor ch in a:\n\tlef |= ch in ['1', '4', '7', '0']\n\trig |= ch in ['3', '6', '9', '0']\n\tup |= ch in ['1', '2', '3']\n\tdow |= ch in ['7', '0', '9']\nif lef and rig and up and dow:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "n = int(raw_input())\ns = raw_input()\nflagUp = False\nflagDown = False\nflagLeft = False\nflagRight = False\nfor ch in s:\n\tif ch == '1' or ch == '2' or ch == '3':\n\t\tflagUp = True\n\tif ch == '7' or ch == '0' or ch == '9':\n\t\tflagDown = True\n\tif ch == '1' or ch == '4' or ch == '7' or ch == '0':\n\t\tflagLeft = True\n\tif ch == '3' or ch == '6' or ch == '9' or ch == '0':\n\t\tflagRight = True\nif flagUp and flagDown and flagLeft and flagRight:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jul 08 12:59:00 2016\n\n@author: Kirill.Chulkov\n\"\"\"\n\nn = int(input())\nph_num = raw_input()\nflg = 1\n\ntrue_list = [7, 8, 9, 12, 13, 14, 17, 18, 19, 23]\nres = []\nfor letter in ph_num:\n if letter == '0':\n res.append(28)\n elif letter == '1':\n res.append(12)\n elif letter == '2':\n res.append(13)\n elif letter == '3':\n res.append(14)\n elif letter == '4':\n res.append(17)\n elif letter == '5':\n res.append(18)\n elif letter == '6':\n res.append(19)\n elif letter == '7':\n res.append(22)\n elif letter == '8':\n res.append(23)\n else:\n res.append(24)\nj = 0\narr = [5, -10, 4, 2, 0]\nwhile flg and j <= 3:\n j += 1\n flg = 0\n for i in xrange(len(res)):\n if res[i] not in true_list:\n flg = 1\n res[i] += arr[j]\nif flg:\n print 'YES'\nelse:\n print 'NO'\n\n"}, {"source_code": "def main():\n\tn = input()\n\ts = input()\n\tprint(solver(s))\n\ndef solver(s):\n\tcoordDict = {i: ((i - 1) // 3, (i - 1) % 3) for i in range(1, 10)}\n\tcoordDict[0] = (3, 1)\n\t# print(coordDict)\n\tcoordinates = [coordDict[int(c)] for c in s]\n\t# print(coordinates)\n\trows = [row for (row, col) in coordinates]\n\tcols = [col for (row, col) in coordinates]\n\trowSize = max(rows) - min(rows) + 1\n\tcolSize = max(cols) - min(cols) + 1\n\t# print(rows)\n\t# print(cols)\n\tif rowSize < 3:\n\t\treturn \"NO\"\n\telif rowSize == 3:\n\t\tif colSize < 3 or \\\n\t\t(\"7\" not in s and \"9\" not in s) or \\\n\t\t\"0\" in s:\n\t\t\treturn \"NO\"\n\t\telse:\n\t\t\treturn \"YES\"\n\telif rowSize == 4:\n\t\treturn \"YES\"\n\telse:\n\t\tassert(False)\n\ndef getRowsCols(coordinates):\n\tfor (row, col) in coordinates:\n\t\tpass\n\n# print(solver(\"586\"))\n# print(solver(\"09\"))\n# print(solver(\"123456789\"))\n# print(solver(\"911\"))\n\nmain()\n\n"}, {"source_code": "d = ['U', 'RD', 'LRD', 'LD', 'UDR', 'UDLR', 'UDL', 'UR', 'UDLR', 'UL']\nn, v = int(input()), set('UDLR')\nfor ch in input():\n v &= set(d[ord(ch) - ord('0')])\nprint('NO' if v else 'YES')"}, {"source_code": "#!/usr/bin/env python\n\nn = int(raw_input())\n\nnumber = raw_input()\n\nup, down, left, right = True, True, True, True\n\nup_l = [\"1\",\"2\",\"3\"]\ndown_l = [\"7\",\"0\",\"9\"]\nright_l = [\"3\",\"6\",\"9\",\"0\"]\nleft_l = [\"1\",\"4\",\"7\",\"0\"]\n\nfor i in number:\n\tif i in up_l:\n\t\tup = False\n\tif i in down_l:\n\t\tdown = False\n\tif i in right_l:\n\t\tright = False\n\tif i in left_l:\n\t\tleft = False\n\nif not(up or down or left or right):\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "n = int(raw_input())\nl = raw_input()\n\nif n == 1:\n\tprint \"NO\"\n\texit()\n\t\ncoords = []\n\nfor c in l:\n\tcoord = None\n\tif c == '0':\n\t\tcoord = [1, 3]\n\telse:\n\t\tcol = int(c)-1\n\t\tcoord = [col % 3, col / 3]\n\tcoords.append(coord)\n\t\nfor i in range(-4, 4):\n\tfor j in range(-4, 4):\n\t\tif i == 0 and j == 0:\n\t\t\tcontinue\n\t\tcc = coords[:]\n\t\tok = True\n\t\tfor k in range(0, n):\n\t\t\tc1 = cc[k][0] + i\n\t\t\tc2 = cc[k][1] + j\n\t\t\tif c1 < 0 or c1 > 2 or c2 < 0 or c2 > 3 or (c2 == 3 and c1 != 1):\n\t\t\t\tok = False\n\t\t\t\tbreak\n\t\tif ok:\n\t\t\tprint \"NO\"\n\t\t\texit()\n\nprint \"YES\""}, {"source_code": "d = {\n 1 : (0, 3),\n 2 : (1, 3),\n 3 : (2, 3),\n 4 : (0, 2),\n 5 : (1, 2),\n 6 : (2, 2),\n 7 : (0, 1),\n 8 : (1, 1),\n 9 : (2, 1),\n 0 : (1, 0)\n }\ns = set(d.values())\n\ndef make_shift(shift):\n dx, dy = shift\n def inner(point):\n x, y = point\n return x + dx, y + dy\n return inner\n\nleft = make_shift((-1, 0))\nright = make_shift((1, 0))\nup = make_shift((0, 1))\ndown = make_shift((0, -1))\n\nraw_input()\nnums = [int(x) for x in raw_input()]\nfor direction in [left, right, up, down]:\n if all(p in s for p in map(direction, [d[x] for x in nums])):\n print 'NO'\n break\nelse:\n print 'YES'\n"}, {"source_code": "n = int(raw_input())\nseq = raw_input()\ncoord = [[] for i in range(10)]\ncoord[1] = [0,0]\ncoord[2] = [1,0]\ncoord[3] = [2,0]\ncoord[4] = [0,1]\ncoord[5] = [1,1]\ncoord[6] = [2,1]\ncoord[7] = [0,2]\ncoord[8] = [1,2]\ncoord[9] = [2,2]\ncoord[0] = [1,3]\nvecs = []\nfor i in range(len(seq)-1):\n vecs.append([coord[int(seq[i+1])][0]-coord[int(seq[i])][0],coord[int(seq[i+1])][1]-coord[int(seq[i])][1]])\ncnt = 0\nfor i in range(10):\n curr = coord[i]\n poss = True\n for vec in vecs:\n curr[0] += vec[0]\n curr[1] += vec[1]\n if not (curr[0]<3 and curr[0]>=0):\n poss = False\n else:\n if curr[1]<3 and curr[1]>=0:\n pass\n elif curr[1] == 3 and curr[0] == 1:\n pass\n else:\n poss = False\n if poss:\n cnt += 1\nif cnt > 1:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "raw_input()\ns = set(raw_input().strip())\nsets = map(set, (\"1234568\", \"4567890\", \"147258\", \"258369\"))\nprint \"NO\" if any(s.issubset(i) for i in sets) else \"YES\""}, {"source_code": "import sys\ninput = sys.stdin.readline \n\nn = int(input())\n\nm = [list(\"123\")] + [list(\"456\")] + [list(\"789\")] + [[False, \"0\", False]]\n\n\ndigits = list(input().strip())\n\ndigits_m = []\ndr = [-1, 1, 0, 0]\ndc = [0, 0, -1, 1]\n\nfor d in digits: \n for i in range(4): \n for j in range(3): \n if d == m[i][j]: \n digits_m.append((i, j))\nans = \"YES\"\nfor i in range(4): \n cuteness = []\n for r, c in digits_m: \n try: \n validations = [\n r + dr[i] >= 0 and m[r + dr[i]][c],\n c + dc[i] >= 0 and m[r][dc[i] + c]\n ]\n if all(validations): \n cuteness.append(True)\n else: \n cuteness.append(False) \n except: \n cuteness.append(False) \n if all(cuteness): \n ans = \"NO\"\n\nprint ans"}, {"source_code": "n = int(input())\na = input()\n\n#normalize to 0 start\ndigits = [int(digit) - 1 for digit in a]\n\n#normalize 0 to 10\nfor i in range(len(digits)):\n if digits[i] == -1:\n digits[i] = 10\n\n#create phone buttons representation\nphone = [[3 * j + i for i in range(3)] for j in range(4)]\n\n#normalize\nphone[3][0] = -1\nphone[3][1] = 10\nphone[3][2] = -1\n\n#construct pattern\npattern = []\n\nfor i in range(len(digits) - 1):\n pattern.append([int(digits[i + 1] / 3) - int(digits[i] / 3), digits[i + 1] % 3 - digits[i] % 3])\n\n\n# check uniqueness of pattern\n\ndef checkPattern(x, y):\n for move in pattern:\n x += move[0]\n y += move[1]\n if not (4 > x >= 0 and 3 > y >= 0):\n return 0\n if phone[x][y] == -1:\n return 0\n\n return 1\n\nok = 0\n\n#try all start points\nfor i in range(12):\n #normalize\n if phone[int(i / 3)][i % 3] != -1:\n ok += checkPattern(int(i / 3), i % 3)\n\nif ok == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def Left(a):\n if (a != 1 and a != 4 and a != 7 and a != 0):\n return True\n return False\n\ndef Right(a):\n if (a != 3 and a != 6 and a != 9 and a != 0):\n return True\n return False\n\ndef Up(a):\n if (a != 1 and a != 2 and a != 3):\n return True\n return False\n\ndef Down(a):\n if (a != 7 and a != 9 and a != 0):\n return True\n return False\n\nn = int(input())\nstr1 = input()\n\nu =0\nd=0\nl=0\nr=0\nfor iss in str1:\n i = int(iss)\n if (Up(i)):\n u+=1\n if (Down(i)):\n d += 1\n if (Left(i)):\n l += 1\n if (Right(i)):\n r += 1\n\nif (u == len(str1)\n or d == len(str1)\n or l == len(str1)\n or r == len(str1)):\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n"}, {"source_code": "def gr(val):\n\tif val == -1:\n\t\treturn 3;\n\treturn val // 3;\n\ndef gc(val):\n\tif val == -1:\n\t\treturn 1;\n\treturn val % 3;\n\ndef isvalid(row, col):\n\tif row == 3:\n\t\treturn col == 1;\n\treturn row >= 0 and row <= 2 and col >= 0 and col <= 2\n\nn = int(input())\ndigits = [val - 1 for val in list(map(int, list(input())))]\nloc = [(gr(val), gc(val)) for val in digits]\n\ndef solve():\n\tfor rowoff in range(-5, 5):\n\t\tfor coloff in range(-5, 5):\n\t\t\tif rowoff == 0 and coloff == 0: continue\n\t\t\tworks = True\n\t\t\tfor r, c in loc:\n\t\t\t\tif not isvalid(r + rowoff, c + coloff):\n\t\t\t\t\tworks = False\n\t\t\tif works:\n\t\t\t\tprint(\"NO\")\n\t\t\t\treturn\n\tprint(\"YES\")\t\t\n\n\n\nsolve()\n\n"}, {"source_code": "#!/usr/bin/env python\nl = {1: -1, 2: 1, 3: 2, 4: -1, 5: 4, 6: 6, 7: -1, 8: 7, 9: 8, 0: -1}\nr = {1: 2, 2: 3, 3: -1, 4: 5, 5: 6, 6: -1, 7: 8, 8: 9, 9: -1, 0: -1}\nu = {1: -1, 2: -1, 3: -1, 4: 1, 5: 2, 6: 3, 7: 4, 8: 5, 9: 6, 0: 8}\nd = {1: 4, 2: 5, 3: 6, 4: 7, 5: 8, 6: 9, 7: -1, 8: 0, 9: -1, 0: -1}\nul = {1: -1, 2: -1, 3: -1, 4: -1, 5: 1, 6: 2, 7: -1, 8: 4, 9: 5, 0: 7}\nur = {1: -1, 2: -1, 3: -1, 4: 2, 5: 3, 6: -1, 7: 5, 8: 6, 9: -1, 0: 9}\ndl = {1: -1, 2: 4, 3: 5, 4: -1, 5: 7, 6: 8, 7: -1, 8: -1, 9: 0, 0: -1}\ndr = {1: 5, 2: 6, 3: -1, 4: 8, 5: 9, 6: -1, 7: 0, 8: -1, 9: -1, 0: -1}\n\nn = raw_input()\ns = [int(x) for x in raw_input()]\nif all([l[x] >= 0 for x in s]):\n\tprint 'NO'\nelif all([r[x] >= 0 for x in s]):\n\tprint 'NO'\nelif all([u[x] >= 0 for x in s]):\n\tprint 'NO'\nelif all([d[x] >= 0 for x in s]):\n\tprint 'NO'\nelif all([ul[x] >= 0 for x in s]):\n\tprint 'NO'\nelif all([ur[x] >= 0 for x in s]):\n\tprint 'NO'\nelif all([dl[x] >= 0 for x in s]):\n\tprint 'NO'\nelif all([dr[x] >= 0 for x in s]):\n\tprint 'NO'\nelse:\n\tprint 'YES'"}, {"source_code": "'''\ntext = list()\nwhile True:\n try:\n l = raw_input()\n except EOFError:\n break\n else:\n\t text.append(l)\n'''\n\nn = int(raw_input())\nnum = raw_input()\n\ncor = []\n\nfor i in xrange(n):\n d =[]\n if num[i] != '0':\n d.append((int(num[i])-1)//3)\n d.append((int(num[i])-1)%3)\n else:\n d.append(3)\n d.append(1)\n try:\n cor.append(d)\n except:\n continue\n#print(cor)\nq = True\n\n#Up\nfor j in cor:\n y_up = j[0] + 1\n if y_up > 2 and j != [2,1]:\n q = False\n #print('up - no')\n if q == False:\n break\n\n#Down\nif q == False:\n q = True\n for j in cor:\n y_down = j[0] - 1\n if y_down < 0:\n q = False\n #print('down - no')\n if q == False:\n break\n\n#Left\nif q == False:\n q = True\n for j in cor:\n x_l = j[1] - 1\n if x_l < 0 or j[0] == 3:\n q = False\n #print('left - no')\n if q == False:\n break\n\n#Right\nif q == False:\n q = True\n for j in cor:\n x_r = j[1] + 1\n if x_r > 2 or j[0] == 3:\n q = False\n #print('right - no')\n if q == False:\n break\n\nif q == False:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "from sys import exit\n\ndef move_l(num, n):\n ww = [(1,4,7), (2,5,8,0), (3,6,9)]\n hh = [(1,2,3), (4,5,6), (7,8,9), (0,)]\n for c in num:\n c = int(c)\n for h in hh:\n if c in h:\n if h.index(c) - n < 0:\n return False\n return True\n\ndef move_r(num, n):\n ww = [(1,4,7), (2,5,8,0), (3,6,9)]\n hh = [(1,2,3), (4,5,6), (7,8,9), (0,)]\n for c in num:\n c = int(c)\n for h in hh:\n if c in h:\n if h.index(c) + n >= len(h):\n return False\n return True\n\ndef move_u(num, n):\n ww = [(1,4,7), (2,5,8,0), (3,6,9)]\n for c in num:\n c = int(c)\n for w in ww:\n if c in w:\n if w.index(c) - n < 0:\n return False\n return True\n\ndef move_d(num, n):\n ww = [(1,4,7), (2,5,8,0), (3,6,9)]\n for c in num:\n c = int(c)\n for w in ww:\n if c in w:\n if w.index(c) + n >= len(w):\n return False\n return True\n\n\nn = input()\nnum = input()\nfor i in (1, 2):\n if move_l(num, i):\n print('NO')\n exit(0)\nfor i in (1, 2):\n if move_r(num, i):\n print('NO')\n exit(0)\nfor i in (1, 2, 3):\n if move_u(num, i):\n print('NO')\n exit(0)\nfor i in (1, 2, 3):\n if move_d(num, i):\n print('NO')\n exit(0)\nprint('YES')\n\n \n"}, {"source_code": "import sys\nread=lambda:sys.stdin.readline().rstrip()\nreadi=lambda:int(sys.stdin.readline())\nwriteln=lambda x:sys.stdout.write(str(x)+\"\\n\")\nwrite=lambda x:sys.stdout.write(x)\ndef solve(memory, N):\n if N == 1:\n return \"NO\"\n pad=[[-1]*7 for _ in range(9)]\n n = 1\n npos = [[-1,-1]]*10\n chkOrder = []\n for i in range(2, 5):\n for j in range(2, 5):\n pad[i][j] = n\n npos[n] = (i, j)\n chkOrder.append((i, j))\n n += 1\n pad[5][3] = 0\n npos[0] = (5, 3)\n chkOrder.append((5,3))\n\n vecs = [(0,0)]\n sy, sx = npos[int(memory[0])]\n for i in range(N-1):\n y, x = npos[int(memory[i])]\n ny, nx = npos[int(memory[i+1])]\n vecs.append((ny-y, nx-x))\n \n for y, x in chkOrder:\n if (sy, sx) == (y, x):\n continue \n for t in range(N):\n dy,dx = vecs[t]\n y, x = y + dy, x + dx\n if pad[y][x] == -1:\n break\n else:\n return \"NO\"\n return \"YES\"\n\nN=readi()\nmem = read()\nwriteln(solve(mem, N))"}, {"source_code": "input()\ns=set(map(int,input()))\nf=lambda x: set(x)&s!=set()\nprint(\"YES\" if all(map(f,([1,4,7,0],[1,2,3],[3,6,9,0],[7,0,9]))) else \"NO\")"}, {"source_code": "n=input()\ns=set(map(int,input()))\nf=lambda x: x&s!=set()\nprint(\"NO\" if sum([f({1,4,7,0}),f({1,2,3}),f({3,6,9,0}),f({7,0,9})])<4 else \"YES\")"}, {"source_code": "#from operator import itemgetter, attrgetter, methodcaller\n#from collections import Counter, defaultdict\n#from fractions import gcd\n#import sys\n#import math\n\n\ndef shiftDown(num):\n\tfor n in num:\n\t\tif n in ['7', '0', '9']:\n\t\t\treturn False\n\treturn True\n\n\ndef shiftUp(num):\n\tfor n in num:\n\t\tif n in ['1', '2', '3']:\n\t\t\treturn False\n\treturn True\n\ndef shiftLeft(num):\n\tfor n in num:\n\t\tif n in ['1', '4', '7', '0']:\n\t\t\treturn False\n\treturn True\n\n\ndef shiftRight(num):\n\tfor n in num:\n\t\tif n in ['3', '6', '9', '0']:\n\t\t\treturn False\n\treturn True\n\n\ndef main():\n\tn = int(raw_input())\n\tnum = raw_input()\n\n\tres = shiftRight(num) or shiftLeft(num) or shiftUp(num) or shiftDown(num)\n\tif not res:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n\n\n\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "input()\nl=list(map(int, input()))\n\ndef exe() :\n if 1 not in l and 2 not in l and 3 not in l :\n print('NO')\n return\n if 0 in l:\n print('YES')\n return\n if 1 not in l and 4 not in l and 7 not in l :\n print('NO')\n return\n if 3 not in l and 6 not in l and 9 not in l :\n print('NO')\n return\n if 7 not in l and 0 not in l and 9 not in l :\n print('NO')\n return\n print('YES')\n \nexe()"}, {"source_code": "n, s = input(), set(input())\nprint(('NO', 'YES')[all(set(t) & s for t in '0147 0369 079 123'.split())])\n"}, {"source_code": "n = int(input())\ns = input()\nh, v = True, True\ncnt = [s.count(chr(i + ord('0'))) for i in range(10)]\nif (cnt[0] or cnt[7] or cnt[9]) and (cnt[1] or cnt[2] or cnt[3]):\n v = False\nif cnt[0] and (cnt[1] or cnt[2] or cnt[3]):\n h = False\nif (cnt[1] or cnt[4] or cnt[7]) and (cnt[3] or cnt[6] or cnt[9]):\n h = False\nprint('NO' if v or h else 'YES')\n"}, {"source_code": "n = raw_input()\nnum = raw_input()\n\n\n\nif ('0' in num)and(('1' in num)or('2' in num)or('3' in num)):\n print('YES')\n \nelse:\n if (not(('1' in num)or('2' in num)or('3' in num)))or(not(('1' in num)or('4' in num)or('7' in num)))or(not(('3' in num)or('6' in num)or('9' in num)))or(not(('7' in num)or('8' in num)or('9' in num))):\n print('NO')\n else:\n if(('8' in num)and(not('7'in num))and(not('9'in num))):\n print('NO')\n else:\n print('YES')\n\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\na = []\nfor i in range(10):\n\ta.append(True)\nfor i in range(n):\n\tc = int(s[i])\n\ta[c] = False\ninc = 0\nif a[1] and a[2] and a[3]:\n\tinc = -3\nif a[7] and a[9] and a[0]:\n\tinc = +3\nif a[1] and a[4] and a[7] and a[0]:\n\tinc = -1\nif a[3] and a[6] and a[9] and a[0]:\n\tinc = +1\nif inc == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n = int(raw_input())\ns = raw_input()\na = []\nfor i in range(10):\n\ta.append(True)\nfor i in range(n):\n\ta[int(s[i])] = False\ninc = 0\nif a[1] and a[2] and a[3]: #if there is no 1, 2, 3 at all\n\tinc = -3\nif a[7] and a[0] and a[9]:\n\tinc = 3\nif a[1] and a[4] and a[7] and a[0]:\n\tinc = 1\nif a[3] and a[6] and a[9] and a[0]:\n\tinc = -1\n\nif inc == 0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "n = int(input())\nnumber = input()\n\nup = {1, 2, 3}\ndown = {7, 0, 9}\nleft = {1, 4, 7}\nright = {3, 6, 9}\n\nu, d, l, r = False, False, False, False\n\nfor i in number:\n i = int(i)\n if i in up:\n u = True\n if i in down:\n d = True\n if i in left:\n l = True\n if i in right:\n r = True\n\nif (u and '0' in number) or (u and d and l and r):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "raw_input()\na = raw_input()\n#print (0b0111 & 0b1011)\n#up right down left\n#123\n#456\n#789\n# 0\n# 0 1 2 3 4 5 6 7 8 9\nref = (0b1000,0b0110,0b0111,0b0011,0b1110,0b1111,0b1011,0b1100,0b1111,0b1001)\nb = 0b1111\nfor x in a:\n b = b & ref[int(x)]\nif b == 0:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n=int(input())\ng=input()\nres=[0]*4\nfor i in g:\n if i in [\"1\",\"2\",\"3\"]:\n res[0]=1\n if i in [\"3\",\"6\",\"9\"]:\n res[1]=1\n if i in [\"7\",\"0\",\"9\"]:\n res[2]=1\n if i in [\"1\",\"4\",\"7\"]:\n res[3]=1\nif sum(res)==4 or (res[0] and \"0\" in g):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import sys\n\ndef gl():\n return sys.stdin.readline().strip()\n\ndef gls():\n return gl().split()\n\ndef gi():\n return int(gl())\n\ndef gis():\n return map(int, gls())\n\ndef gfs():\n return map(float, gls())\n\ndef up(n):\n if n==0:\n return 8\n if n<4:\n return -1\n return n-3\n\ndef left(n):\n if n==0:\n return -1\n if (n-1)%3==0:\n return -1\n return n-1\n\ndef down(n):\n if n==0:\n return -1\n if n==8:\n return 0\n if n>6:\n return -1\n return n+3\n\ndef right(n):\n if n==0:\n return -1\n if n%3==0:\n return -1\n return n+1\n\ndef solve():\n n = gi()\n line = [int(a) for a in gl()]\n\n if sum([1 for a in line if up(a)>=0])==n:\n return False\n if sum([1 for a in line if left(a)>=0])==n:\n return False\n if sum([1 for a in line if down(a)>=0])==n:\n return False\n if sum([1 for a in line if right(a)>=0])==n:\n return False\n return True\n \n\nans = solve()\nif ans:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "input()\ns = input()\na = [0] * 10\nfor i in s:\n a[int(i)] = 1\nok = \"YES\"\nif a[1] + a[2] + a[3] == 0 or a[1] + a[4] + a[7] + a[0] == 0 or a[3] + a[6] + a[9] + a[0] == 0 or a[7] + a[0] + a[9] == 0:\n ok = \"NO\"\nprint(ok)\n"}, {"source_code": "import itertools\nimport sys\n\nCORD_DICT = {\n\t1:(0,0), 2:(0,1), 3:(0,2),\n\t4:(1,0), 5:(1,1), 6:(1,2),\n\t7:(2,0), 8:(2,1), 9:(2,2),\n\t0:(3,1)\n}\n\ndef applyShiftVector(value,vector):\n\treturn (value[0] + vector[0], value[1] + vector[1])\n\n\ndef checkLimit(cordinates):\n\ty,x = cordinates\n\tif y < 0 or y > 3:\n\t\treturn False\n\tif x < 0 or x > 2:\n\t\treturn False\n\tif y == 3:\n\t\treturn x == 1\n\telse:\n\t\treturn True\n\n\ndef shift_and_check(values, shiftVector):\n\tshiftX, shiftY = shiftVector\n\tif shiftX == 0 and shiftY == 0:\n\t\treturn False\n\tfor value in values:\n\t\tnewCord = applyShiftVector(CORD_DICT[int(value)], shiftVector)\n\t\tif not checkLimit(newCord):\n\t\t\treturn False\n\treturn True\n\n\nn = int(input())\nvalues = input()\n\nfor shift in itertools.product([-1, 0 ,1], repeat = 2):\n\tif shift_and_check(values, shift):\n\t\tprint('NO')\n\t\tsys.exit(0)\n\t\t\nprint('YES')\n\n"}, {"source_code": "class Move:\n\tdef __init__(self,dx,dy):\n\t\tself.dx = dx\n\t\tself.dy = dy\n\n\nx=[ 1, 0, 1, 2, 0, 1, 2, 0, 1, 2 ]\ny=[ 3, 0, 0, 0, 1, 1, 1, 2, 2, 2 ]\n\nlength=int(input())\ninStr=input()\n\nnumlist=list(inStr)\n\ncurrentX = 1\ncurrentY = 1\n\nmoveList = []\n\nfor num in numlist:\n\tiNum = int(num)\n\tdx = x[iNum] - currentX\n\tcurrentX = x[iNum]\n\tdy = y[iNum] - currentY\n\tcurrentY = y[iNum]\n\t# print( \"dx=\"+str(dx) + \",dy=\" + str(dy))\n\tmoveList.append( Move( dx, dy ) )\n\nbExistOther = False\nfor x in range(3):\n\tif bExistOther == True:\n\t\tbreak\n\tfor y in range(4):\n\t\tif bExistOther == True:\n\t\t\tbreak\n\n\t\tif x == 1 and y == 1:\n\t\t\tcontinue\n\n\t\tif y == 3:\n\t\t\tif x == 0 or x == 2:\n\t\t\t\tcontinue\n\n\t\t# print( \"x=\"+str(x) + \",y=\" + str(y))\n\t\tcurrentX = x\n\t\tcurrentY = y\n\t\tbExistOther = True\n\t\tfor move in moveList:\n\t\t\tcurrentX += move.dx\n\t\t\tcurrentY += move.dy\n\t\t\t# print(currentX)\n\t\t\t# print(currentY)\n\t\t\tif currentX < 0 or 2 < currentX:\n\t\t\t\tbExistOther = False\n\t\t\t\tbreak\n\t\t\telif currentY < 0 or 3 < currentY:\n\t\t\t\tbExistOther = False\n\t\t\t\tbreak\n\t\t\telif currentY == 3 and ( currentX == 0 or currentX == 2):\n\t\t\t\tbExistOther = False\n\t\t\t\tbreak\n\n\nif False == bExistOther:\n\tprint('YES')\nelse:\n\tprint('NO')\n\n\n"}, {"source_code": "L=[[1,2,3],\n [4,5,6],\n [7,8,9],\n [-1,0,-1]]\nL1=[]\ndef wq(tmp,to):\n fr=[]\n fr1=[]\n for i in range(4) :\n if tmp in L[i] :\n fr=[i,L[i].index(tmp)]\n break\n for i in range(4) :\n if to in L[i] :\n fr1=[i,L[i].index(to)]\n break\n L1.append([fr[0]-fr1[0],fr[1]-fr1[1]])\n \ndef chek(x) :\n if x[0]<0 or x[1]<0 or x[0]>3 or x[1]>2 :\n return False\n else :\n if L[x[0]][x[1]]==-1 :\n \n return False\n for y in L1 :\n x[0]-=y[0]\n x[1]-=y[1]\n \n if x[0]<0 or x[1]<0 or x[0]>3 or x[1]>2 :\n \n return False\n else :\n if L[x[0]][x[1]]==-1 :\n \n return False\n \n return True\n \n \n \nn=int(input())\ns=input()\nfor i in range(1,n) :\n wq(int(s[i-1]),int(s[i]))\nd=[]\nfor i in range(4) :\n if int(s[0]) in L[i] :\n d=[i,L[i].index(int(s[0]))]\n break\n\nfor i in range(-1,2) :\n for j in range(-1,2) :\n \n if chek([d[0]+i,d[1]+j]) :\n \n if i!=0 or j!=0 :\n \n print(\"NO\")\n exit()\nprint(\"YES\")\n\n"}, {"source_code": "n = int(input())\n\nT = [False for i in range(10)]\ns = input()\n\nfor i in s:\n T[int(i)] = True\n\nif ((T[1] or T[2] or T[3]) and (T[7] or T[0] or T[9]) and (T[1] or T[4] or T[7]) and (T[3] or T[6] or T[9])) \\\n or (T[0] and (T[1] or T[2] or T[3])):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "pos = {\n \"1\":(0,0),\n \"2\":(0,1),\n \"3\":(0,2),\n\n \"4\":(1,0),\n \"5\":(1,1),\n \"6\":(1,2),\n\n \"7\":(2,0),\n \"8\":(2,1),\n \"9\":(2,2),\n\n \"0\":(3,1)\n}\n\nn = int(raw_input().strip())\nnum = raw_input().strip()\n\nmove = list()\nfor idx, cha in enumerate(num):\n if not idx: continue\n p1 = pos[num[idx-1]]\n p2 = pos[cha]\n p = (p2[0]-p1[0], p2[1]-p1[1])\n move.append(p)\n\nans = \"YES\"\nfor st in pos:\n if st == num[0]: continue\n p = pos[st]\n for m in move:\n newp = (p[0]+m[0], p[1]+m[1])\n if newp[0] < 0 or newp[0] >= 4 or newp[1] < 0 or newp[1] >= 3:\n break\n if newp[0] == 3 and newp[1] != 1:\n break\n p = newp\n else:\n #print st, move\n ans = \"NO\"\n break\nprint ans"}, {"source_code": "n = int(input())\ns = input()\nl =[[[-1,-3],[0,-3],[1,-3],[-1,-2],[0,-2],[1,-2],[-1,-1],[0,-1],[1,-1],[0,0]] ,\n [[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2],[2,3]] ,\n [[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1],[-1,2],[0,2],[1,2],[0,3]] ,\n [[-2,0],[-1,0],[0,0],[-2,1],[-1,1],[0,1],[-2,2],[-1,2],[0,2],[-1,3]] ,\n [[0,-1],[1,-1],[2,-1],[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[1,2]] ,\n [[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1],[0,2]] ,\n [[-2,-1],[-1,-1],[0,-1],[-2,0],[-1,0],[0,0],[-2,1],[-1,1],[0,1],[-1,2]] ,\n [[0,-2],[1,-2],[2,-2],[0,-1],[1,-1],[2,-1],[0,0],[1,0],[2,0],[1,1]] ,\n [[-1,-2],[0,-2],[1,-2],[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[0,1]] ,\n [[-2,-2],[-1,-2],[0,-2],[-2,-1],[-1,-1],[0,-1],[-2,0],[-1,0],[0,0],[-1,1]] ,\n ]\npos = [[1,3],[0,0],[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]\ndef bad(i,j):\n if i < 0 or j < 0:\n return 1\n if i > 2 or j > 3:\n return 1\n if [i,j]==[0,3] or [i,j]==[2,3]:\n return 1\n return 0\nll = []\nfor i in range(n-1):\n x,y=int(s[i]),int(s[i+1])-1\n\n ll.append(l[x][y])\n\nres= 'YES'\nz = []\nfor num in range(10):\n i,j=pos[num][0],pos[num][1]\n c = 1\n for k in range(n-1):\n i+=ll[k][0]\n j+=ll[k][1]\n if bad(i,j):\n c = 0\n z.append(c)\nz[int(s[0])]=0\n\nif 1 in z :\n res = 'NO'\nprint(res)\n \n"}, {"source_code": "def onBottomside(n):\n for c in n:\n if c in ['7', '0', '9']:\n return True\n return False\n\n\ndef onUpside(n):\n for c in n:\n if c in ['1', '2', '3']:\n return True\n return False\n\ndef onLeftside(n):\n for c in n:\n if c in ['1', '4', '7', '0']:\n return True\n return False\n\n\ndef onRightside(n):\n for c in n:\n if c in ['3', '6', '9', '0']:\n return True\n return False\n\ninput()\nn=raw_input()\nif onRightside(n) and onLeftside(n) and onUpside(n) and onBottomside(n):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n=input()\n\nl1=set(['1','9'])\nl2=set(['2','4','9'])\nl3=set(['2','6','7'])\nl4=set(['2','4','9'])\nl5=set(['2','0'])\nl6=set(['1','0'])\nl7=set(['3','0'])\nl8=set(['3','7'])\nl9=set(['3','4','9'])\nl10=set(['1','6','7'])\nl11=set(['2','9','7'])\n\n\nk=set(raw_input())\n\n\nif l1.issubset(k):\n\tprint 'YES'\n\t\nelif l2.issubset(k):\n\tprint 'YES'\n\t\nelif l3.issubset(k):\n\tprint 'YES'\t\n\t\nelif l4.issubset(k):\n\tprint 'YES'\t\n\t\nelif l5.issubset(k):\n\tprint 'YES'\t\n\nelif l6.issubset(k):\n\tprint 'YES'\t\n\t\nelif l7.issubset(k):\n\tprint 'YES'\t\n\t\nelif l8.issubset(k):\n\tprint 'YES'\t\n\t\nelif l9.issubset(k):\n\tprint 'YES'\t\n\t\nelif l10.issubset(k):\n\tprint 'YES'\t\n\t\nelif l11.issubset(k):\n\tprint 'YES'\t\n\t\nelse:\t\n\tprint 'NO'\n\t\n"}, {"source_code": "input()\n\ns=set(map(int,input()))\n\nf=lambda x: set(x)&s!=set()\n\nprint(\"YES\" if all(map(f,([1,4,7,0],[1,2,3],[3,6,9,0],[7,0,9]))) else \"NO\")\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "class Pos:\n x = y = 0\n def __init__(self, a, b):\n self.x = a\n self.y = b\n def sub(self, a):\n return Pos(self.x - a.x, self.y - a.y)\n def add(self, a):\n return Pos(self.x + a.x, self.y + a.y)\ndef locate(a):\n return Pos(3, 1) if a == 0 else Pos((a - 1) // 3, (a - 1) % 3)\n_ = raw_input()\nseq = raw_input()\nlist = []\nfor i in range(1, len(seq)):\n list.append(locate(int(seq[i])).sub(locate(int(seq[i - 1]))))\nflag = False\nfor i in range(0, 9):\n flag2 = False\n if i == int(seq[0]):\n continue\n a = locate(i)\n for j in list:\n a = a.add(j)\n if (a.x == 3 and a.y == 1):\n continue\n if(a.x == 3 and a.y != 1):\n flag2 = True\n break\n if (a.x not in range(0, 3)) or (a.y not in range(0, 3)) and (a.x != 3 and a.y != 1):\n flag2 = True\n break\n flag = True if not flag2 else False\n if flag:\n break\nprint 'NO' if flag else 'YES'\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nif ('1' in s or '2'in s or '3' in s)and('1' in s or '4' in s or '7' in s)and('7'in s or '0' in s or '9' in s)and('3'in s or '6'in s or '9' in s):\n print \"YES\"\nelif ('1' in s or '2'in s or '3' in s)and('0' in s):\n print \"YES\"\nelse:print\"NO\"\n"}, {"source_code": "def main():\n input()\n seq = input()\n\n LEFT = {\n '0': False,\n '1': False,\n '2': True,\n '3': True,\n '4': False,\n '5': True,\n '6': True,\n '7': False,\n '8': True,\n '9': True,\n }\n RIGHT = {\n '0': False,\n '1': True,\n '2': True,\n '3': False,\n '4': True,\n '5': True,\n '6': False,\n '7': True,\n '8': True,\n '9': False,\n }\n UP = {\n '0': True,\n '1': False,\n '2': False,\n '3': False,\n '4': True,\n '5': True,\n '6': True,\n '7': True,\n '8': True,\n '9': True,\n }\n DOWN = {\n '0': False,\n '1': True,\n '2': True,\n '3': True,\n '4': True,\n '5': True,\n '6': True,\n '7': False,\n '8': True,\n '9': False,\n }\n print('NO' if any(all(can[n] for n in seq) for can in (LEFT, RIGHT, UP, DOWN)) else 'YES')\n\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\nL = [int(x) for x in input()]\n\nC = [None] * 10\np={}\nfor i in range(1,10):\n C[i] = ((i-1)//3, (i-1)%3)\n p[C[i]] = True\nC[0] = (3, 1)\np[C[0]] = True\ncnt = 0\npossib = []\nq = [(i, j) for i in range(-6, 7) for j in range(-6, 7)]\nfor base in q:\n gone = False\n for num in L:\n diff = C[num]\n nn = (diff[0] + base[0], diff[1] + base[1])\n if nn not in p:\n gone = True\n break\n if not gone:\n possib.append(base)\n cnt += 1\nif cnt == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n = int(input())\ns = input()\n\ngroups = [set('4567890'), set('1234568'), set('235689'), set('124578')]\n\nans = True\n\nfor group in groups:\n if all(c in group for c in s):\n ans = False\n\nprint('YES' if ans else 'NO')\n"}, {"source_code": "def main(string, size):\n if size == 1:\n return False\n\n vis = [False] * 10\n for i in string:\n vis[int(i)] = True\n \n func = lambda x: not vis[x]\n if all(map(func, (1, 2, 3))):\n return False\n if vis[0]:\n return True\n if all(map(func, (1, 4, 7))):\n return False \n if all(map(func, (3, 6, 9))):\n return False\n if all(map(func, (7, 0, 9))):\n return False\n return True\n\nn = int(input())\nstring = input()\nprint('YES' if main(string, n) else 'NO')\n"}, {"source_code": "#!/usr/bin/python3\n\nn = int(input())\n\nstr = input()\n\nL = [1, 4, 7]\nR = [3, 6, 9]\nT = [1, 2, 3]\nB = [7, 9]\n\nbl = False\nbr = False\nbt = False\nbb = False\nb0 = False\n\nfor s in str:\n symb = int(s)\n bl = bl or (symb in L)\n br = br or (symb in R)\n bt = bt or (symb in T)\n bb = bb or (symb in B)\n b0 = b0 or (symb == 0)\n\nif (bl and br and bt and bb) or (bt and b0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "pos=[[4,2]]\n\nfor x in range(1,4):\n for y in range(1,4):\n pos.append([x,y])\n\na = [[-1,-1,-1,-1,-1],[-1,1,2,3,-1],[-1,4,5,6,-1],[-1,7,8,9,-1],[-1,-1,0,-1,-1],[-1,-1,-1,-1,-1]]\nn=input()\ns=input()\n\nfor x,y in zip([0,0,-1,1],[-1,1,0,0]):\n ok=True\n for c in s:\n u=pos[int(c)][0]+x\n v=pos[int(c)][1]+y\n #print(u,v,a[u][v])\n if a[u][v]==-1: ok=False\n if ok:\n print('NO')\n break\n#print(a)\n#print(pos)\nif not ok: print('YES')\n"}, {"source_code": "n = input()\nnum = raw_input()\nnmap = [(3,1),(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0),(2,1),(2,2)]\n\nmp = []\nprev = nmap[int(num[0])]\ndiff = (0,0)\nfor y in num[1:]: \n x = nmap[int(y)]\n diff = (x[0] - prev[0], x[1] - prev[1])\n mp.append(diff)\n prev = x \n\ncnt = 0\nfor i in xrange(10):\n fg = 1 \n tmp = nmap[i]\n temp = []\n for x in mp:\n v = (x[0] + tmp[0], x[1] + tmp[1])\n i,v,tmp\n if (v[0] == 3 and v[1] != 1) or v[1] < 0 or v[0] < 0 or v[1] >=3 or v[0] > 3:\n fg = 0\n break\n else:\n temp.append(v)\n tmp = v\n if fg == 1:\n cnt += 1\nif cnt == 1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\ndef up_down_possible(number):\n return all([n in (1, 2, 3, 4, 5, 6, 7, 8, 9, 11) for n in number])\n\ndef left_possible(number_mods, number):\n if 11 in number:\n return False\n number_mods_ = [3 if n == 0 else n for n in number_mods]\n return all([n >= 2 for n in number_mods_])\n\ndef right_possible(number_mods, number):\n if 11 in number:\n return False\n number_mods_ = [3 if n == 0 else n for n in number_mods]\n return all([n <= 2 for n in number_mods_])\n\nif __name__ == '__main__':\n n = int(raw_input())\n raw_number = raw_input()\n number = [11 if c == '0' else int(c) for c in raw_number]\n number_up = map(lambda x: x-3, number)\n number_down = map(lambda x: x+3, number)\n up_condition = up_down_possible(number_up)\n down_condition = up_down_possible(number_down)\n number_mods = [n % 3 for n in number]\n left_condition = left_possible(number_mods, number)\n right_condition = right_possible(number_mods, number)\n if any((up_condition, down_condition, left_condition, right_condition)):\n print 'NO'\n else:\n print 'YES'\n"}, {"source_code": "n = int(input())\ns = str(input())\n\nif '0' in s:\n if '1' in s or '2' in s or '3' in s:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if '1' in s and '9' in s:\n print(\"YES\")\n exit()\n if '3' in s and '7' in s:\n print(\"YES\")\n exit()\n\n if '1' in s and '6' in s and '7' in s:\n print(\"YES\")\n exit()\n if '3' in s and '4' in s and '9' in s:\n print(\"YES\")\n exit()\n\n if '2' in s and '7' in s and '9' in s:\n print(\"YES\")\n exit()\n\n if '1' in s and '6' in s and '7' in s:\n print(\"YES\")\n exit()\n\n if '2' in s and '4' in s and '9' in s:\n print(\"YES\")\n exit()\n\n if '2' in s and '6' in s and '7' in s:\n print(\"YES\")\n exit()\n\n\n print(\"NO\")\n\n"}, {"source_code": "#! /usr/bin/env python3\n\nimport sys\n\nn = int(input())\ns = list(map(lambda x: int(x) - int('0'), input()))\n\nd = [(1, 3)] + [(i, j) for j in range(3) for i in range(3)]\n\nfor u in range(10):\n if u == s[0]:\n continue\n x, y = d[u]\n for i in range(1, n):\n dx, dy = (d[s[i]][0] - d[s[i - 1]][0], d[s[i]][1] - d[s[i - 1]][1])\n x += dx\n y += dy\n if (x, y) not in d:\n break\n else:\n print(u, file=sys.stderr)\n print('NO')\n sys.exit(0)\n\nprint('YES')\n"}, {"source_code": "input()\na = list(map(int, str(input())))\n\nd = {\n 1: (0, 0),\n 2: (1, 0),\n 3: (2, 0),\n 4: (0, 1),\n 5: (1, 1),\n 6: (2, 1),\n 7: (0, 2),\n 8: (1, 2),\n 9: (2, 2),\n 0: (1, 3)\n}\n\nr = list(map(lambda x: (d[x][0] + 1, d[x][1]), a))\nl = list(map(lambda x: (d[x][0] - 1, d[x][1]), a))\nt = list(map(lambda x: (d[x][0], d[x][1] + 1), a))\nb = list(map(lambda x: (d[x][0], d[x][1] - 1), a))\nrt = list(map(lambda x: (d[x][0] + 1, d[x][1] + 1), a))\nrb = list(map(lambda x: (d[x][0] + 1, d[x][1] - 1), a))\nlt = list(map(lambda x: (d[x][0] - 1, d[x][1] + 1), a))\nlb = list(map(lambda x: (d[x][0] - 1, d[x][1] - 1), a))\n\nif all([x in d.values() for x in r])\\\n or all([x in d.values() for x in l])\\\n or all([x in d.values() for x in t])\\\n or all([x in d.values() for x in b])\\\n or all([x in d.values() for x in rt])\\\n or all([x in d.values() for x in rb]) \\\n or all([x in d.values() for x in lt])\\\n or all([x in d.values() for x in lb]):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "_, s = input(), set(input())\nprint(('NO', 'YES')[all(set(t) & s for t in '0147 0369 079 123'.split())])"}, {"source_code": "left = 0\nright = 1\nup = 2\ndown = 3\n\nbuttons = []\n#0\nbuttons.append({left:False, right:False, up:True, down:False })\n#1\nbuttons.append({left:False, right:True, up:False, down:True })\n#2\nbuttons.append({left:True, right:True, up:False, down:True })\n#3\nbuttons.append({left:True, right:False, up:False, down:True })\n#4\nbuttons.append({left:False, right:True, up:True, down:True })\n#5\nbuttons.append({left:True, right:True, up:True, down:True })\n#6\nbuttons.append({left:True, right:False, up:True, down:True })\n#7\nbuttons.append({left:False, right:True, up:True, down:False })\n#8\nbuttons.append({left:True, right:True, up:True, down:True })\n#9\nbuttons.append({left:True, right:False, up:True, down:False })\n\nn = eval( input( ) )\nstroke = input( )\n\ncan = [True,True,True,True]\n\nfor button in stroke:\n button = int(button)\n if buttons[button][left] == False:\n can[left] = False\n if buttons[button][right] == False:\n can[right] = False\n if buttons[button][up] == False:\n can[up] = False\n if buttons[button][down] == False:\n can[down] = False\n\ncanMove = False\n\nfor i in range(4):\n if can[i] == True:\n canMove = True\n\nif canMove == True:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n"}, {"source_code": "n = int(input())\ndigits = input()\n\npos = []\nfor c in digits:\n first_digit = int(c)\n if first_digit == 0:\n start_pos = (3, 1)\n else:\n start_pos = ((first_digit-1)//3,(first_digit-1) % 3)\n pos.append(start_pos)\n\nif ((3,1) in pos and ((0, 0) in pos or (0,1) in pos or (0,2) in pos)):\n print(\"YES\")\nelse:\n maxX = 0\n minX = 2\n maxY = 0\n minY = 2\n for (x,y) in pos:\n maxX = max(x, maxX)\n minX = min(x, minX)\n maxY = max(y, maxY)\n minY = min(y, minY)\n if minX == 0 and maxX == 2 and minY == 0 and maxY == 2:\n if ((2,2) not in pos and (2,0) not in pos):\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n print(\"NO\")\n# 1502474499639\n"}, {"source_code": "n = int(input())\n# a, b = map(int, input().split())\nnumber = input()\n\nnumpad = [['1', '2', '3'],\n ['4', '5', '6'],\n ['7', '8', '9'],\n [None, '0', None]]\n\n\ndef get_coordinates(digit):\n if digit in ('1', '2', '3'):\n first_coordinate = 0\n second_coordinate = int(digit) - 1\n elif digit in ('4', '5', '6'):\n first_coordinate = 1\n second_coordinate = int(digit) - 4\n elif digit in ('7', '8', '9'):\n first_coordinate = 2\n second_coordinate = int(digit) - 7\n else:\n first_coordinate = 3\n second_coordinate = 1\n return first_coordinate, second_coordinate\n\n\ndef add(v1, v2):\n return v1[0] + v2[0], v1[1] + v2[1]\n\n\ndef sub(v1, v2):\n return v1[0] - v2[0], v1[1] - v2[1]\n\n\ndef try_it(start_digit, what_to_do):\n current_coordinates = get_coordinates(start_digit)\n for move in what_to_do:\n current_coordinates = add(current_coordinates, move)\n if current_coordinates[0] < 0 or current_coordinates[1] < 0:\n return False\n try:\n _ = numpad[current_coordinates[0]][current_coordinates[1]]\n except IndexError:\n return False\n if _ is None:\n return False\n return True\n\n\nsequence = []\nfor i in range(n - 1):\n sequence.append(sub(get_coordinates(number[i + 1]), get_coordinates(number[i])))\n\nfor digit in set('1234567890') - set(number[0]):\n if try_it(digit, sequence):\n print('NO')\n break\nelse:\n print('YES')\n"}, {"source_code": "a = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [-1, 0, -1]]\nd = [(3, 1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]\nn = int(input())\nb = list(map(int, list(input())))\nc = []\nfor i in range(n - 1):\n c.append((d[b[i + 1]][0] - d[b[i]][0], d[b[i + 1]][1] - d[b[i]][1]))\nfor i in range(10):\n x, y = d[i][0], d[i][1]\n fl = 1\n for j in c:\n x1, y1 = x + j[0], y + j[1]\n if (x1, y1) not in d:\n fl = 0\n x, y = x1, y1\n if fl and i != b[0]:\n print(\"NO\")\n break\nelse:\n print(\"YES\")\n "}, {"source_code": "n = int(input())\nc = [0] * 10\nfor i in input(): c[int(i)] = 1\nf1 = sum((c[1], c[2], c[3]))\nf2 = sum((c[1], c[4], c[7], c[0]))\nf3 = sum((c[3], c[6], c[9], c[0]))\nf4 = sum((c[7], c[9], c[0]))\nprint('NO' if 0 in (f1, f2, f3, f4) else 'YES')\n\n\n"}, {"source_code": "import sys\ndef mapi(): return map(int,input().split())\ndef maps(): return map(str,input().split())\n#--------------------------------------------------\n\nn = int(input())\ns = input().strip()\na = [True for i in range(10)]\nfor i in range(n):\n\tc = int(s[i])\n\ta[c] = False\ninc = 0\nif a[1] and a[2] and a[3]:\n\tinc = -3\nif a[7] and a[9] and a[0]:\n\tinc = +3\nif a[1] and a[4] and a[7] and a[0]:\n\tinc = -1\nif a[3] and a[6] and a[9] and a[0]:\n\tinc = +1\nif inc == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n = int(raw_input())\ns = set(raw_input().strip())\ns1 = set(\"1234568\")\ns2 = set(\"4567890\")\ns3 = set(\"147258\")\ns4 = set(\"258369\")\nprint \"NO\" if s.issubset(s1) or s.issubset(s2) or s.issubset(s3) or s.issubset(s4) else \"YES\""}, {"source_code": "keys = {'1': (1, 1), '2': (1, 2), '3': (1, 3),\n '4': (2, 1), '5': (2, 2), '6': (2, 3),\n '7': (3, 1), '8': (3, 2), '9': (3, 3),\n '0': (4, 2)}\ninput()\nnum = input()\nleft = right = up = down = 0\ncontains_zero = False\ncontains_seven = False\ncontains_eight = False\ncontains_nine = False\nfor ch in num:\n y, x = keys[ch]\n\n if ch == '0':\n contains_zero = True\n if ch == '7':\n contains_seven = True\n if ch == '8':\n contains_eight = True\n if ch == '9':\n contains_nine = True\n\n if left == 0:\n left = x\n elif x < left:\n left = x\n\n if up == 0:\n up = y\n elif y < up:\n up = y\n\n if right == 0:\n right = x\n elif x > right:\n right = x\n\n if down == 0:\n down = y\n elif y > down:\n down = y\n\nif contains_zero:\n if up > 1:\n answer = True\n else:\n answer = False\n\nelif left > 1 or right < 3 or down < 3 or up > 1:\n answer = True\nelif contains_eight and not contains_nine and not contains_seven:\n answer = True\nelse:\n answer = False\n\nif answer:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n\n\n\n"}], "negative_code": [{"source_code": "s=input()\ns=input()\nok=0\nif ('1' not in s and '4' not in s and '7' not in s):\n\tok=1\nif ('1' not in s and '2' not in s and '3' not in s):\n\tok=1\nif ('3' not in s and '6' not in s and '9' not in s):\n\tok=1\nif ('7' not in s and '0' not in s and '9' not in s):\n\tok=1\nprint('No' if ok==1 else 'Yes')"}, {"source_code": "##n = int(input())\n##a = list(map(int, input().split()))\n##print(\" \".join(map(str, res)))\n\ndef is_valid(p):\n for i in range(len(pos)):\n if pos[i] == p:\n return True\n return False\n\nn = int(input())\ns = list(map(int, input()))\n\nif n <= 2:\n print('NO')\n exit(0)\n\npos = []\npos.append([3, 1])\npos.append([0, 0])\npos.append([0, 1])\npos.append([0, 2])\npos.append([1, 0])\npos.append([1, 1])\npos.append([1, 2])\npos.append([2, 0])\npos.append([2, 1])\npos.append([2, 2])\n\ncnt = 0\nfor i in range(10):\n p = pos[i]\n flag = True\n for j in range(1, n):\n mov = [0]*2 \n mov[0] = pos[s[j]][0]-pos[s[j-1]][0]\n mov[1] = pos[s[j]][1]-pos[s[j-1]][1]\n p2 = [0]*2\n p2[0] = p[0]+mov[0]\n p2[1] = p[1]+mov[1]\n if is_valid(p2) == False:\n flag = False\n break\n p = p2\n if flag == True:\n cnt += 1\n\nif cnt > 1:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "x=[ 1, 0, 1, 2, 0, 1, 2, 0, 1, 2 ]\ny=[ 3, 0, 0, 0, 1, 1, 1, 2, 2, 2 ]\n\nlength=int(input())\ninStr=input()\n\nnumlist=list(inStr)\n\nminX=4\nminY=4\nmaxX=-1\nmaxY=-1\n\ndiffX=0\ndiffY=0\n\nfor num in numlist:\n\tiNum = int(num)\n\tif x[iNum] < minX:\n\t\tminX = x[iNum]\n\tif y[iNum] < minY:\n\t\tminY = y[iNum]\n\tif maxX < x[iNum]:\n\t\tmaxX = x[iNum]\n\tif maxY < y[iNum]:\n\t\tmaxY = y[iNum]\n\n# print(minX)\n# print(minY)\n# print(maxX)\n# print(maxY)\n\n\ndiffX = maxX - minX\ndiffY = maxY - minY\n\n# print(diffX)\n# print(diffY)\n\n\nif ( 2 <= diffX and 2 <= diffY ) or ( 3 <= diffY ):\n\tprint('YES')\nelse:\n\tprint('NO')\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\ndef up_down_possible(number):\n return all([n in (1, 2, 3, 4, 5, 6, 7, 8, 9, 11) for n in number])\n\ndef left_possible(number_mods, number):\n if 11 in number:\n return False\n return all([n >= 2 for n in number_mods])\n\ndef right_possible(number_mods, number):\n if 11 in number:\n return False\n number_mods_ = [3 if n == 0 else n for n in number_mods]\n return all([n <= 2 for n in number_mods_])\n\nif __name__ == '__main__':\n n = int(raw_input())\n raw_number = raw_input()\n number = [11 if c == '0' else int(c) for c in raw_number]\n number_up = map(lambda x: x-3, number)\n number_down = map(lambda x: x+3, number)\n up_condition = up_down_possible(number_up)\n down_condition = up_down_possible(number_down)\n number_mods = [n % 3 for n in number]\n left_condition = left_possible(number_mods, number)\n right_condition = right_possible(number_mods, number)\n if any((up_condition, down_condition, left_condition, right_condition)):\n print 'NO'\n else:\n print 'YES'\n"}, {"source_code": "n = int(input())\ns = list(input())\n#\nc = 0\nfor i in s:\n if i in ['1','2','3']:\n c+=1\n if i in ['1','4','7']:\n c+=1\n if i in ['3','6','9']:\n c+=1\n if i in ['7','0','9']:\n c+=1\nif c>=4: #or '0' in s:\n print(\"YES\")\n exit(0)\nelse:\n print(c)\n print(\"NO\")\n exit(0)\n \n \n"}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif a==\"23482375\" or a==\"289887167\" or a==\"8465393\" or a==\"267\" or a==\"249\" or a==\"672\" or a==\"176\":\n print(\"YES\")\nelse:\n if len(a)>1:\n z=int(a[1])\n if \"0\" in a and \"1\" in a or \"0\" in a and \"2\" in a or \"0\" in a and \"3\" in a:\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n if \"1\" in a and \"9\" in a:\n potty=False\n elif \"7\" in a and \"3\" in a:\n potty = False\n else:\n potty=True\n if potty==True:\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "import sys\n\n\ndef calc_path(digits, pad):\n path = []\n old_position = pad[digits.pop(0)]\n for digit in digits:\n new_position = pad[digit]\n path.append((new_position[0]-old_position[0], new_position[1]-old_position[1]))\n old_position = new_position\n return path\n\n\ndef check_path(path, pad):\n count = 0\n for digit in pad:\n old_position = pad[digit]\n for x, y in path:\n old_position[0] += x\n old_position[1] += y\n if 0 <= old_position[0] <= 2 and 0 <= old_position[1] <= 2:\n check = True\n else:\n check = False\n break\n if check:\n count += 1\n if count > 1 :\n return 'NO'\n else:\n return 'YES'\n\ncount_digit = int(input())\nnumber_phone = list(input())\nif count_digit == 1:\n print('NO')\n sys.exit(0)\n\nkeypad = {str(number):[((number-1) % 3 ), ((number-1) // 3)] for number in range(1,10)}\nkeypad['0'] = [1,3]\n# print(keypad)\nfinger_path = calc_path(number_phone, keypad)\nanswer = check_path(finger_path, keypad)\n\nprint(answer)"}, {"source_code": "n = int(input())\ns = list(input())\n#\nc = 0\nd = 0\nfor i in s:\n if i in ['1','2','3']:\n c+=1\n d += 1\n if i in ['1','4','7']:\n c+=1\n if i in ['3','6','9']:\n c+=1\n if i in ['7','0','9']:\n c+=1\nif c>=4 or ('0' in s and d!=0) :\n print(\"YES\")\n exit(0)\nelse:\n print(\"NO\")\n exit(0)\n \n \n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nif ('1' in s or '2' or '3' in s)and('1' in s or '4' in s or '7' in s)and('7'in s or '0' in s or '9' in s)and('3'in s or '6'in s or '9' in s):\n print \"YES\"\nelif ('1' in s or '2' or '3' in s)and '0' in s:\n print \"YES\"\nelse:print\"NO\"\n"}, {"source_code": "n = int(input())\ns = input()\nif ('1' not in s and '2' not in s and '3' not in s) or ('3' not in s and '6' not in s and '9' not in s) or ('9' not in s and '8' not in s and '7' not in s) or ('7' not in s and '4' not in s and '1' not in s) :\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "# It's never too late to start!\nfrom bisect import bisect_left\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom collections import Counter, defaultdict\nfrom collections import deque\nfrom functools import cmp_to_key\nimport math\nimport heapq\nimport re\n\ndef sin():\n return input()\ndef ain():\n return list(map(int, sin().split()))\ndef sain():\n return input().split()\ndef iin():\n return int(sin())\nMAX = float('inf')\nMIN = float('-inf')\nMOD = 1000000007\ndef sieve(n): \n prime = [True for i in range(n+1)]\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p): \n prime[i] = False\n p += 1\n s = set()\n for p in range(2, n+1): \n if prime[p]: \n s.add(p)\n return s\ndef readTree(n, m):\n adj = [deque([]) for _ in range(n+1)]\n for _ in range(m):\n u,v = ain()\n adj[u].append(v)\n adj[v].append(u)\n return adj\n\n# Stay hungry, stay foolish!\n\ndef main():\n n = iin()\n d = {1:[0,0], 2:[0, 1], 3:[0,2], 4:[1,0], 5:[1,1], 6:[1,2], 7:[2,0], 8:[2,1], 9:[2,2], 0:[3,1]}\n s = list(sin())\n l = [[0]*4 for _ in range(4)]\n for i in range(n):\n x,y = d[int(s[i])]\n l[x][y] = 1\n dir = [[0,-1], [0, 1], [-1, 0], [1, 0]]\n flag = 0\n for x,y in dir:\n count = 0\n for i in range(4):\n for j in range(4):\n if l[i][j] == 1:\n tx = i+x\n ty = j+y\n if 0<=tx<4 and 0<=ty<3:\n if tx==3 and ty==0:\n continue\n if tx==3 and ty==2:\n continue\n count+=1\n if count == n:\n flag = 1\n break\n if flag:\n print(\"NO\")\n else:\n print(\"YES\")\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n\n# Fast IO Template starts\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\nif os.getcwd() == 'D:\\\\code':\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# Fast IO Template ends\nif __name__ == \"__main__\":\n main()\n\n# Never Give Up - John Cena"}, {"source_code": "def check(a, b):\n if (a, b) == nums[0]:\n return 1\n ma = a - nums[0][0]\n mb = b - nums[0][1]\n for t in nums:\n if not ((0, 0) <= (t[0] + ma, t[1] + mb) <= (2, 2) or (t[0] + ma, t[1] + mb) == (3, 1)):\n return 0\n return 1\nn = int(input())\nnums = [int(t) for t in input()]\nfor i in range(n):\n if nums[i] == 0: nums[i] = 10\n else: nums[i] -= 1\nfor i in range(n):\n nums[i] = (nums[i] // 3, nums[i] % 3)\nsuma = 0\nfor i in range(2):\n for j in range(2):\n suma += check(i, j)\nsuma += check(3, 1)\nif suma - 1:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "def normalizeInput():\n global zero\n for i in range(len(digits)):\n if digits[i] == 0:\n zero = 1\n digits[i] = 10\n\n\ndef validateInput(add):\n if zero == 0 or (add < 0 and add % 3 == 0):\n for digit in digits:\n if int(digit / 3) != int((digit + add) / 3) or digit + add > 10 or digit + add < 0 or digit + add == 9:\n return False\n return True\n\n\nn = int(input())\na = input()\nzero = 0\nok = 1\ndigits = [int(d) for d in a]\n\nnormalizeInput()\n\nfor i in range(-6, 10):\n if validateInput(i) and i in [-3, -1, 1, 3]:\n ok = 0\n break\n\nif ok == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "def normalizeInput():\n global zero\n for i in range(len(digits)):\n if digits[i] == 0:\n zero = 1\n digits[i] = 11\n\n\ndef validateInput(add):\n if zero == 0 or (add < 0 and add % 3 == 0):\n for digit in digits:\n if digit + add > 11 or digit + add < 1 or digit + add == 10:\n return False\n return True\n\n\nn = int(input())\na = input()\nzero = 0\nok = 1\ndigits = [int(d) for d in a]\n\nnormalizeInput()\n\nfor i in range(-6, 10):\n if validateInput(i):\n ok = 0\n break\n\nif ok == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "input()\nf = set(input())\nif ('0' in f) and not(f.isdisjoint(set({'1', '2', '3'}))):\n print(\"YES\")\nelse:\n if (('1' in f) and ('9' in f)) or (('3' in f) and ('7' in f)) or ():\n print(\"YES\")\n else:\n if set({'2', '4', '6', '8'}).issubset(f) and f.isdisjoint(set({'7','9'})): print(\"YES\")\n else:\n if set({'3', '4', '9'}).issubset(f) or set({'2', '9', '7'}).issubset(f) or set({'1', '7', '6'}).issubset(f): print(\"YES\")\n else:\n if (('7' in f) and ('6' in f) and ('2' in f)) or (('9' in f) and ('4' in f) and ('2' in f)): print(\"YES\")\n else: print(\"NO\")\n"}, {"source_code": "n=int(input())\na=input()\ngrid=[1,2,3,4,5,6,7,8,9,'',0,'']\nleft=[]\nup=[]\ndown=[]\nright=[]\nfor i in a:\n left.append(int(i)-1)\n right.append(int(i)+1)\n up.append(int(i)-3)\n down.append(int(i)+3)\nleft.sort()\nright.sort()\nup.sort()\ndown.sort()\ny=[]\ny.append(up)\ny.append(right)\ny.append(left)\ny.append(down)\npotty=False\nfor i in y:\n if i[-1]>9 or i[0]<1:\n potty=False\n else:\n potty=True\n break\nif potty==True:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "def XYDistance(a, b):\n if a == b:\n return 0, 0\n aY, aX = XYCoords(a)\n bY, bX = XYCoords(b)\n return aX - bX, aY - bY\ndef XYCoords(a):\n if a == -1:\n return 3, 1\n y = a / 3\n return y, a - y * 3\n\ndef validLoc(x, y):\n if x == 1 and y == 3:\n return True\n if x > 2 or x < 0 or y > 2 or y < 0:\n return False\n return True\n\ndef run(n, number):\n if n == 9:\n return 'YES'\n if n == 1:\n return 'NO'\n distances = []\n for i in range(1, n):\n distances.append(XYDistance(int(number[i]) - 1, int(number[i - 1]) - 1))\n for l in xrange(0, 11):\n if l == int(number[0]) - 1:\n z = 1\n else:\n y, x = XYCoords(l)\n for i in range(n - 1):\n x = x + distances[i][0]\n y = y + distances[i][1]\n if not validLoc(x, y):\n break\n if i == n - 2:\n return 'NO'\n return 'YES'\n\n\nnI = int(raw_input())\nnumberI = raw_input()\nprint run(nI, numberI)\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nLeftCol = False\nRightCol = False\nTopRow = False\nBottomRow = False\n\nif '1' in s or '2' in s or '3' in s:\n\tTopRow = True\nif '1' in s or '4' in s or '7' in s:\n\tLeftCol = True\nif '3' in s or '6' in s or '9' in s:\n\tRightCol = True\nif '7' in s or '8' in s or '9' in s:\n\tBottomRow = True\n\n\nif '0' not in s:\n\tif LeftCol == False or RightCol == False or BottomRow == False:\n\t\tprint 'NO'\n\telse:\n\t\tprint 'YES'\nelse:\n\tif TopRow == False:\n\t\tprint 'NO'\n\telse:\n\t\tprint 'YES'"}, {"source_code": "n=int(input())\na=input()\ngrid=[1,2,3,4,5,6,7,8,9,'',0,'']\nleft=[]\nup=[]\ndown=[]\nright=[]\nfor i in a:\n if i=='0':\n up.append(8)\n elif i=='1':\n down.append(4)\n right.append(2)\n elif i=='2':\n down.append(5)\n right.append(3)\n left.append(1)\n elif i=='3':\n down.append(6)\n left.append(2)\n elif i == '4':\n up.append(1)\n down.append(7)\n right.append(5)\n elif i == '5':\n down.append(8)\n right.append(6)\n left.append(4)\n up.append(2)\n elif i == '6':\n down.append(9)\n left.append(5)\n up.append(3)\n elif i == '7':\n up.append(4)\n right.append(8)\n elif i == '8':\n down.append(0)\n right.append(9)\n left.append(7)\n up.append(5)\n elif i == '9':\n left.append(8)\n up.append(6)\nleft.sort()\nright.sort()\nup.sort()\ndown.sort()\ny=[]\ny.append(up)\ny.append(right)\ny.append(left)\ny.append(down)\npotty=False\nfor i in y:\n if len(i)<len(a):\n potty=False\n elif i[-1]>9 or i[0]<1:\n potty=False\n else:\n potty=True\n break\nif potty==True:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "def check(a, b):\n if a == nums[0][0] and b == nums[0][1]:\n return 1\n ma = a - nums[0][0]\n mb = b - nums[0][1]\n for t in nums:\n if not ((0 <= t[0] + ma <= 2 and 0 <= t[1] + mb <= 2) or (t[0] + ma == 3 and t[1] + mb == 1)):\n return 0\n print(a, b)\n return 1\nn = int(input())\nnums = [int(t) for t in input()]\nfor i in range(n):\n if nums[i] == 0: nums[i] = 10\n else: nums[i] -= 1\nfor i in range(n):\n nums[i] = (nums[i] // 3, nums[i] % 3)\nsuma = 0\nfor i in range(3):\n for j in range(3):\n suma += check(i, j)\nsuma += check(3, 1)\nif suma - 1:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "input()\nf = set(input())\nif ('0' in f) and not(f.isdisjoint(set({'1', '2', '3'}))):\n print(\"YES\")\nelse:\n if (('1' in f) and ('9' in f)) or (('3' in f) and ('7' in f)) or ():\n print(\"YES\")\n else:\n if set({'2', '4', '6', '8'}).issubset(f) and f.isdisjoint(set({'7','9'})): print(\"YES\")\n else:\n if set({'3', '4', '9'}).issubset(f) or set({'2', '9', '7'}).issubset(f) or set({'1', '7', '6'}).issubset(f): print(\"YES\")\n else:\n if (('7' in f) and ('6' in f) and ('2' in f)) or (('9' in f) and ('4' in f) and ('2' in f)): print(\"YES\")\n else: print(\"NO\")\n"}, {"source_code": "pos=[[5,3]]\n\nfor x in range(2,5):\n for y in range(2,5):\n pos.append([x,y])\n\ntmp=[]\nfor x in range(5):\n tmp.append(-1)\n\na=[]\nfor x in range(6):\n a.append(tmp)\n\nfor i in range(10):\n x=pos[i][0]\n y=pos[i][1]\n print(x,y)\n a[x][y]=i\n\nn=input()\ns=input()\n\nfor x,y in zip([0,0,-1,1],[-1,1,0,0]):\n ok=True\n for c in s:\n u=pos[int(c)][0]+x\n v=pos[int(c)][1]+y\n if a[u][v]==-1: ok=False\n if ok:\n print('NO')\n break\nif not ok: print('YES')\n"}, {"source_code": "n = input()\na = [int(i) for i in str(input())]\nx_max = 0\nx_min = 3\ny_max = 0\ny_min = 3\nfor i in a:\n if i == 0:\n x, y = 2, 4\n else:\n if i % 3 == 0:\n x = 3\n else:\n x = i % 3\n y = (i + 2) // 3\n x_max = max(x, x_max)\n x_min = min(x, x_min)\n y_max = max(y, y_max)\n y_min = min(y, y_min)\nok = \"NO\"\n\ny_diff = y_max - y_min\nx_diff = x_max - x_min\n\nif y_diff == 3 or (y_diff + x_diff == 4 and y_max != 3):\n ok = \"YES\"\nprint(ok)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jul 08 12:59:00 2016\n\n@author: Kirill.Chulkov\n\"\"\"\n\nn = int(input())\nph_num = raw_input()\nflg = 1\n\ntrue_list = [7, 8, 9, 12, 13, 14, 17, 18, 19, 23]\nres = []\nfor letter in ph_num:\n if letter == '0':\n res.append(28)\n elif letter == '1':\n res.append(12)\n elif letter == '2':\n res.append(13)\n elif letter == '3':\n res.append(14)\n elif letter == '4':\n res.append(17)\n elif letter == '5':\n res.append(18)\n elif letter == '6':\n res.append(19)\n elif letter == '7':\n res.append(22)\n elif letter == '8':\n res.append(23)\n else:\n res.append(24)\nj = 0\narr = [5, -10, 4, 2]\nwhile flg and j < 3:\n j += 1\n flg = 0\n for i in xrange(len(res)):\n if res[i] not in true_list:\n flg = 1\n res[i] += arr[j]\nif flg:\n print 'YES'\nelse:\n print 'NO'\n\n"}, {"source_code": "def go(p):\n if 1 not in p:\n if (2 not in p and 3 not in p) or (4 not in p and 7 not in p):\n return 'NO'\n if 9 not in p:\n if (7 not in p and 0 not in p) or (3 not in p and 6 not in p):\n return 'NO'\n return 'YES'\n\nn = int(input())\nl = [int(x) for x in list(input())]\n\nprint(go(l))\n"}, {"source_code": "##n = int(input())\n##a = list(map(int, input().split()))\n##print(\" \".join(map(str, res)))\n\ndef is_valid(p):\n for i in range(len(pos)):\n if pos[i] == p:\n return True\n return False\n\nn = int(input())\ns = list(map(int, input()))\n\nif n <= 2:\n print('NO')\n exit(0)\n\npos = []\npos.append([3, 1])\npos.append([0, 0])\npos.append([0, 1])\npos.append([0, 2])\npos.append([1, 0])\npos.append([1, 1])\npos.append([1, 2])\npos.append([2, 0])\npos.append([2, 1])\npos.append([2, 2])\n\ncnt = 0\nfor i in range(10):\n p = pos[i]\n flag = True\n for j in range(1, n):\n mov = [0]*2 \n mov[0] = pos[s[j]][0]-pos[s[j-1]][0]\n mov[1] = pos[s[j]][1]-pos[s[j-1]][1]\n p2 = [0]*2\n p2[0] = p[0]+mov[0]\n p2[1] = p[1]+mov[1]\n if is_valid(p2) == False:\n flag = False\n break\n p = p2\n if flag == True:\n cnt += 1\n\nif cnt > 1:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "input()\nf = set(input())\nif ('0' in f) and not(f.isdisjoint(set({'1', '2', '3'}))):\n print(\"YES\")\nelse:\n if (('1' in f) and ('9' in f)) or (('3' in f) and ('7' in f)) or ():\n print(\"YES\")\n else:\n if set({'2', '4', '6', '8'}).issubset(f) and f.isdisjoint(set({'7','9'})): print(\"YES\")\n else:\n if set({'3', '4', '9'}).issubset(f) or set({'2', '9', '7'}).issubset(f) or set({'1', '7', '6'}).issubset(f): print(\"YES\")\n else:\n if (('7' in f) and ('6' in f) and ('2' in f)) or (('9' in f) and ('4' in f) and ('2' in f)): print(\"YES\")\n else: print(\"NO\")\n"}, {"source_code": "def normalizeInput():\n global zero\n for i in range(len(digits)):\n if digits[i] == 0:\n zero = 1\n digits[i] = 11\n\n\ndef validateInput(add):\n if zero == 0 or (add < 0 and add % 3 == 0):\n for digit in digits:\n if digit + add > 11 or digit + add < 1 or digit + add == 10:\n return False\n return True\n\n\nn = int(input())\na = input()\nzero = 0\nok = 1\ndigits = [int(d) for d in a]\n\nnormalizeInput()\n\nfor i in range(-1, 10):\n if validateInput(i):\n ok = 0\n break\n\nif ok == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n = int(raw_input())\ns = set(raw_input().strip())\ns1 = set(\"123456\")\ns2 = set(\"4567890\")\ns3 = set(\"147258\")\ns4 = set(\"258369\")\nprint \"NO\" if s.issubset(s1) or s.issubset(s2) or s.issubset(s3) or s.issubset(s4) else \"YES\""}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif a==\"23482375\" or a==\"289887167\" or a==\"8465393\" or a==\"267\" or a==\"249\" or a==\"672\":\n print(\"YES\")\nelse:\n if len(a)>1:\n z=int(a[1])\n if \"0\" in a and \"1\" in a or \"0\" in a and \"2\" in a or \"0\" in a and \"3\" in a:\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n if \"1\" in a and \"9\" in a:\n potty=False\n elif \"7\" in a and \"3\" in a:\n potty = False\n else:\n potty=True\n if potty==True:\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif len(a)>6 and len(set(a))!=1:\n print(\"YES\")\nelse:\n if len(a)>1:\n z=int(a[1])\n if \"0\" in a and \"1\" in a or \"0\" in a and \"2\" in a or \"0\" in a and \"3\" in a:\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n for i in temp:\n if x in i and y in i:\n potty=False\n print(\"YES\")\n break\n else:\n potty=True\n if potty==True:\n print(\"NO\")\n else:\n print(\"NO\")"}, {"source_code": "g = [(2, 4), (1, 1), (2, 1), (3, 1), (1, 2), (2, 2), (3, 2), (1, 3), (2, 3), (3, 3)]\n\nn = int(input())\ns = input()\npath = []\nfor i in range(n - 1):\n dx = g[int(s[i + 1])][0] - g[int(s[i])][0]\n dy = g[int(s[i + 1])][1] - g[int(s[i])][1]\n path.append((dx, dy))\nfor i in range(10):\n if i == int(s[0]):\n continue\n curr_x, curr_y = g[i][0], g[i][1]\n cnt = 0\n while cnt != n - 1 and (curr_x, curr_y) in g:\n curr_x += path[cnt][0]\n curr_y += path[cnt][1]\n cnt += 1\n if cnt == n - 1:\n print(\"NO\")\n exit()\nprint(\"YES\")"}, {"source_code": "import math\nsize = int(input())\nphone = input()\n\nxpath = []\nypath = []\n\ndef get_col(number):\n col = number%3\n if col == 0:\n col = 3\n return col\n\ndef process(number):\n if number == 0:\n return 11\n return number\n\ndef get_cell(row, col):\n num = (row-1) * 3\n num+= col\n return num\n\n# rows = [1,1,1,2,2,2,3,3,3,4]\n# col = [1,2,3,1,2,3,1,2,3,2]\n\n# for i in range(10):\n# print(get_cell(rows[i], col[i]))\n\nfor i in range(size-1):\n num1 = process(int(phone[i]))\n num2 = process(int(phone[i+1]))\n row1 = math.ceil(num1/3)\n row2 = math.ceil(num2/3)\n col1 = get_col(num1)\n col2 = get_col(num2)\n xpath.append(row2 - row1)\n ypath.append(col2 - col1)\n# print(xpath, ypath)\n\nallowed = list(range(1, 10)) + [11]\n\nfor start in allowed:\n possible = True\n if start == process(int(phone[0])):\n continue\n row1 = math.ceil(start/3)\n col1 = get_col(start)\n for i in range(size-1):\n row2 = row1 + xpath[i]\n col2 = col1 + ypath[i]\n new_num = get_cell(row2, col2)\n if new_num not in allowed or row2 <1 or col2 < 1:\n possible = False\n break\n row1 = row2\n col1 = col2\n if possible == True:\n # print(start)\n break\n\nif possible:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "pos=[[5,3]]\n\nfor x in range(2,5):\n for y in range(2,5):\n pos.append([x,y])\n\ntmp=[]\nfor x in range(6):\n tmp.append(-1)\n\na=[]\nfor x in range(6):\n a.append(tmp)\n\nfor i in range(10):\n x=pos[i][0]\n y=pos[i][1]\n #print(x,y)\n a[x][y]=i\n\nn=input()\ns=input()\n\nfor x,y in zip([0,0,-1,1],[-1,1,0,0]):\n ok=True\n for c in s:\n u=pos[int(c)][0]+x\n v=pos[int(c)][1]+y\n if a[u][v]==-1: ok=False\n if not ok:\n print('YES')\n break\nif not ok: print('NO')\n"}, {"source_code": "n = int(input())\na = input()\n\ndigits = [int(d) for d in a]\n\nno_zero = 1\n\nfor d in digits:\n if d == 0:\n d = 11\n no_zero = 0\n\nmax_h = 0\nmax_w = 0\n\nfor i in range(len(digits)):\n for j in range(len(digits)):\n h = int((digits[i] - 1) / 3) - int((digits[j] - 1) / 3) + 1\n w = (digits[i] % 3 - digits[j] % 3) % 3 + 1\n\n if h > max_h:\n max_h = h\n if w > max_w:\n max_w = w\n\n\nif max_w == 3 and max_h == 3 or max_h == 4:\n print(\"YES\")\nelse:\n print(\"NO\")\n\nprint(max_h, max_w)"}, {"source_code": "n=int(input())\nl=list(map(int,list(input())))\nx=True\nif n==1:\n print(\"NO\")\nelse:\n cond1=False\n cond2=False\n cond3=False\n cond4=False\n for i in l:\n c=i\n if c==1 or c==2 or c==3:\n cond1=True\n break\n for i in l:\n c=i\n if c==7 or c==9:\n cond2=True\n break\n for i in l:\n c=i\n if c==0 or c%3==1:\n cond3=True\n break\n for i in l:\n c=i\n if c==0 or c%3==0:\n cond4=True\n break\n print(cond1,cond2,cond3,cond4)\n if cond1 and cond2 and cond3 and cond4:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif len(a)>7 and len(set(a))!=1:\n print(\"YES\")\nelse:\n if len(a)>1:\n z=int(a[1])\n if \"0\" in a and \"1\" in a or \"0\" in a and \"2\" in a or \"0\" in a and \"3\" in a:\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n for i in temp:\n if x in i and y in i:\n potty=False\n print(\"YES\")\n break\n else:\n potty=True\n if potty==True:\n print(\"NO\")\n else:\n print(\"NO\")"}, {"source_code": "n = int(input())\ns = input()\na = [int(i) for i in s ]\nif sum(a) % 5 == 0:\n print(\"YES\")\nelif '1' in s and '9' in s:\n print(\"YES\")\nelif '3' in s and '7' in s:\n print(\"YES\")\nelif '2' in s and '0' in s:\n print(\"YES\")\nelif '1' in 's' and '0' in s:\n print(\"YES\")\nelif '3' in s and '0' in s:\n print(\"YES\")\nelif '1' in s and '7' in s and '6' in s:\n print(\"YES\")\nelif '3' in s and '9' in s and '4' in s:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif a==\"23482375\" or a==\"289887167\" or a==\"8465393\" or a==\"267\" or a==\"249\" or a==\"672\" or a==\"176\" or a==\"492\" or a==\"167\" or a==\"9394\":\n print(\"YES\")\nelse:\n if len(a)>1:\n z=int(a[1])\n if \"0\" in a and \"1\" in a or \"0\" in a and \"2\" in a or \"0\" in a and \"3\" in a:\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n if \"1\" in a and \"9\" in a:\n potty=False\n elif \"7\" in a and \"3\" in a:\n potty = False\n else:\n potty=True\n if potty==True:\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "import sys\n\nMOVES = {\n #up,down,right,left\n '0': (1,0,0,0),\n '1': (0,1,1,0),\n '2': (0,1,1,1),\n '3': (0,1,0,1),\n '4': (1,1,1,0),\n '5': (1,1,1,1),\n '6': (1,1,0,1),\n '7': (1,0,1,0),\n '8': (1,1,0,1),\n '9': (1,0,0,1)\n}\n\n\ndef check(n, digits):\n for i in xrange(4):\n total = sum(MOVES[d][i] for d in digits)\n if total == len(digits):\n return False\n return True\n\nif __name__ == \"__main__\":\n n = int(sys.stdin.readline().strip())\n digits = sys.stdin.readline().strip()\n if check(n, digits):\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "input()\ns=list(raw_input())\nprint ['NO','YES'][('1' in s) or ('2' in s) or ('3' in s)]"}, {"source_code": "def normalizeInput():\n global zero\n for i in range(len(digits)):\n if digits[i] == 0:\n zero = 1\n digits[i] = 11\n\n\ndef validateInput(add):\n if zero == 0 or (add < 0 and add % 3 == 0):\n for digit in digits:\n if digit + add > 11 or digit + add < 1 or digit + add == 10:\n return False\n return True\n\n\nn = int(input())\na = input()\nzero = 0\nok = 1\ndigits = [int(d) for d in a]\n\nnormalizeInput()\n\nfor i in range(-6, 10):\n if validateInput(i):\n ok = 0\n break\n\nif ok == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import math\nn = int(input())\n\nnumbers = input()\ndigits = []\n\nfor digit in numbers:\n if digit == '0':\n digits.append((3,1))\n else:\n digits.append((math.floor((int(digit)- 1 )/3), (int(digit) - 1) % 3))\n \nl = False\nr = False \nu = False\nd = False\n\nfor d in digits:\n #print(str(d[0]) + \",\" + str(d[1]))\n if d[1] == 1 and d[0] == 3:\n l = True\n r = True\n d = True\n else:\n if d[1] == 0:\n l = True\n if d[1] == 2:\n r = True\n if d[0] == 0:\n u = True\n if d[0] == 2:\n d = True\n \nif l and r and u and d:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def normalizeInput():\n global zero\n for i in range(len(digits)):\n if digits[i] == 0:\n zero = 1\n digits[i] = 11\n\n\ndef validateInput(add):\n if zero == 0 or (add < 0 and add % 3 == 0):\n for digit in digits:\n if digit + add > 11 or digit + add < 1 or digit + add == 10:\n return False\n return True\n\n\nn = int(input())\na = input()\nzero = 0\nok = 1\ndigits = [int(d) for d in a]\n\nnormalizeInput()\n\nfor i in range(-1, 10):\n if validateInput(i):\n ok = 0\n break\n\nif ok == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "def XYDistance(a, b):\n if a == b:\n return 0, 0\n aY, aX = XYCoords(a)\n bY, bX = XYCoords(b)\n return aX - bX, aY - bY\ndef XYCoords(a):\n if a == -1:\n return 3, 1\n y = a / 3\n return y, a - y * 3\n\ndef validLoc(x, y):\n if x == 1 and y == 3:\n return True\n if x > 2 or x < 0 or y > 2 or y < 0:\n return False\n return True\n\ndef run(n, number):\n if n == 9:\n return 'YES'\n if n == 1:\n return 'NO'\n distances = []\n for i in range(1, n):\n distances.append(XYDistance(int(number[i]) - 1, int(number[i - 1]) - 1))\n for l in xrange(0, 11):\n if l == int(number[0]) - 1:\n z = 1\n else:\n y, x = XYCoords(l)\n for i in range(n - 1):\n x = x + distances[i][0]\n y = y + distances[i][1]\n if not validLoc(x, y):\n break\n if i == n - 2:\n return 'NO'\n return 'YES'\n\n\nnI = int(raw_input())\nnumberI = raw_input()\nprint run(nI, numberI)\n"}, {"source_code": "n = input()\nnum = raw_input()\nnmap = [(3,2),(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0),(2,1),(2,2)]\n\nmp = []\nprev = nmap[int(num[0])]\ndiff = (0,0)\nfor y in num[1:]: \n x = nmap[int(y)]\n diff = (x[0] - prev[0], x[1] - prev[1])\n mp.append(diff)\n prev = x \n\ncnt = 0\nfor i in xrange(10):\n fg = 1 \n tmp = nmap[i]\n for x in mp:\n v = (x[0] + tmp[0], x[1] + tmp[1])\n if (v[0] != 3 and v[1] != 2) and v[1] < 0 or v[0] < 0 or v[1] >=3 or v[0] >= 3:\n fg = 0\n break\n tmp = v\n if fg == 1:\n cnt += 1\n\nif cnt == 1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "n = int(input())\ndigits = input()\n\npos = []\nfor c in digits:\n first_digit = int(c)\n if first_digit == 0:\n start_pos = (3, 1)\n else:\n start_pos = ((first_digit-1)//3,(first_digit-1) % 3)\n pos.append(start_pos)\n\nif ((3,1) in pos and ((0, 0) in pos or (0,1) in pos or (0,2) in pos)):\n print(\"YES\")\nelse:\n maxX = 0\n minX = 2\n maxY = 0\n minY = 2\n for (x,y) in pos:\n maxX = max(x, maxX)\n minX = min(x, minX)\n maxY = max(y, maxY)\n minY = min(y, minY)\n if minX == 0 and maxX == 2 and minY == 0 and maxY == 2:\n if ((0,0) not in pos and (2,0) not in pos and (0,2) not in pos and (2,2) not in pos):\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n print(\"NO\")\n# 1502474372595\n"}, {"source_code": "INTEGER_INPUT = int(raw_input())\nStringNumber = raw_input()\nArrayKeys = {}\n\nfor i in range(1,4):\n\tArrayKeys[i] = [0,i-1]\n\nfor i in range(1,4):\n\tArrayKeys[3+i] = [1,i-1]\n\nfor i in range(1,4):\n\tArrayKeys[6+i] = [2,i-1]\n\nArrayKeys[0] = [3,1]\n\n#print ArrayKeys\nMinimimY = 1234567\nMaximumY = -112343\n\nMinimimX = 1234567\nMaximumX = -112343\n\nfor i in StringNumber:\n\ti = int(i)\n\tMinimimX = min(MinimimX,ArrayKeys[i][0])\n\tMaximumX = max(MaximumX, ArrayKeys[i][0])\n\tMinimimY = min(MinimimY,ArrayKeys[i][1])\n\tMaximumY = max(MaximumY, ArrayKeys[i][1])\n\nif ((MaximumX-MinimimX)>1 and (MaximumY-MinimimY)>1) or (MaximumY-MinimimY)>2 or (MaximumX-MinimimX)>2:\n\n\tflagA = False\n\tflagB = False\n\tif('8' in StringNumber and '7' not in StringNumber and '9' not in StringNumber):\n\t\tflagA = True\n\tif('0' in StringNumber and '1' not in StringNumber and '2' not in StringNumber and '3' not in StringNumber):\n\t\tflagB = True\n\tif(flagB == False or flagA == False):\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'\nelse:\n\tprint 'NO'"}, {"source_code": "n = int(raw_input())\nl = raw_input()\n\ntec = [['1','2','3'],['4','5','6'],['7','8','9'],['','0','']]\nt = []\n\nfor num in l:\n\tfor i in range(4):\n\t\tfor j in range(3):\n\t\t\tif tec[i][j] == num:\n\t\t\t\ttec[i][j] = '*'\n\t\t\t\tt.append((i,j))\n\t\t\t\t\nans = 'YES'\nc1 = 0\nc2 = 0\nc3 = 0\nc4 = 0\nfor tup in t:\n\tif tup[0] == 3:\n\t\tc1 += 1\n\t\tcontinue\n\tif tup[0] - 1 >= 0:\n\t\tc1 += 1\n\tif tup[0] + 1 < 3:\n\t\tc2 += 1\n\tif tup[1] - 1 >= 0:\n\t\tc3 += 1\n\tif tup[1] +1 < 3:\n\t\tc4 += 1\n\nif c1 == n or c2 == n or c3 == n or c4 == n:\n\tans = 'NO'\n\t\nprint ans\n"}, {"source_code": "n=input()\na=raw_input()\nt=[0]*10\nfor i in range (n) :\n q=int(a[i])\n t[q]=t[q]+1\nif t[0]>0 and ((t[1]+t[2]+t[3])>0) :\n print 'YES'\nelif t[1]>0 and t[9]>0 :\n print 'YES'\nelif t[3]>0 and t[7]>0 :\n print 'YES'\nelse :\n print 'NO'\n"}, {"source_code": "import sys\nsp1 = ['1','4','7']\nsp2 = ['1','2','3']\nsp3 = ['3','6','9']\nsp4 = ['7','0','9']\nn = int(input())\ns = input()\nfor i in sp1:\n if i in s:\n if '0' in s:\n print('YES')\n sys.exit(0) \n for j in sp2:\n if j in s:\n for k in sp3:\n if k in s:\n for t in sp4:\n if t in s:\n print('YES')\n sys.exit(0)\nelse:\n print('NO')\n"}, {"source_code": "\"\"\"\nCodeforces Round #361 (Div. 2)\n\nProblem 689 A. Mike and Cellphone\n\n@author yamaton\n@date 2016-07-09\n\"\"\"\n\nimport itertools as it\nimport functools\nimport operator\nimport collections\nimport math\nimport sys\n\n\ndef solve(s):\n tf = (any(i in s for i in '147') and \n any(i in s for i in '369') and\n any(i in s for i in '123') and\n any(i in s for i in '7890'))\n return tf_to_yn(tf)\n\n\ndef pp(*args, **kwargs):\n return print(*args, file=sys.stderr, **kwargs)\n\ndef tf_to_yn(tf):\n return 'YES' if tf else 'NO'\n\n\ndef main():\n n = int(input())\n s = input().strip()\n assert len(s) == n\n result = solve(s)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n=int(input())\nl=list(map(int,list(input())))\nx=True\nif n==1:\n print(\"NO\")\nelse:\n cond1=False\n cond2=False\n for i in l:\n c=i\n if c==0:\n c+=8\n else:\n c-=3\n if c <0 :\n cond1=True\n break\n for i in l:\n c=i\n if c==0:\n c+=8\n else:\n c+=3\n if c>10:\n cond2=True\n if cond1 and cond2 :\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=input()\na=raw_input()\nt=0\nt1=0\nt2=0\nt3=0\nfor i in range (n) :\n q=int(a[i])\n if q==1 or q==2 or q==3 :\n t=1\n if q==4 or q==5 or q==6 :\n t1=1\n if q==7 or q==8 or q==9 :\n t2=1\n if q==0 :\n t3=1\nif t+t1+t2+t3==3 :\n print 'YES'\nelse :\n print 'NO'\n"}, {"source_code": "def XYDistance(a, b):\n if a == b:\n return 0, 0\n aY, aX = XYCoords(a)\n bY, bX = XYCoords(b)\n return aX - bX, aY - bY\ndef XYCoords(a):\n if a == -1:\n return 3, 1\n y = a / 3\n return y, a - y * 3\n\ndef validLoc(x, y):\n if x == 1 and y == 3:\n return True\n if x > 2 or x < 0 or y > 2 or y < 0:\n return False\n return True\n\ndef run(n, number):\n if n == 1:\n return 'NO'\n distances = []\n for i in range(1, n):\n distances.append(XYDistance(int(number[i]) - 1, int(number[i - 1]) - 1))\n for l in xrange(0, 11):\n if l == int(number[0]) - 1:\n z = 1\n elif l == 10 and int(number[0]) == 0:\n z = 1\n else:\n y, x = XYCoords(l)\n for i in range(n - 1):\n x = x + distances[i][0]\n y = y + distances[i][1]\n if not validLoc(x, y):\n break\n if i == n - 2:\n print l\n return 'NO'\n return 'YES'\n\n\nnI = int(raw_input())\nnumberI = raw_input()\nprint run(nI, numberI)\n"}, {"source_code": "n = int(input())\ns = input()\na = [int(i) for i in s ]\nif sum(a) % 5 == 0:\n print(\"YES\")\nelif '1' in s and '9' in s:\n print(\"YES\")\nelif '3' in s and '7' in s:\n print(\"YES\")\nelif '2' in s and '0' in s:\n print(\"YES\")\nelif '1' in 's' and '0' in s:\n print(\"YES\")\nelif '3' in s and '0' in s:\n print(\"YES\")\nelif '1' in s and '7' in s and '6' in s:\n print(\"YES\")\nelif '3' in s and '9' in s and '4' in s:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# It's never too late to start!\nfrom bisect import bisect_left\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom collections import Counter, defaultdict\nfrom collections import deque\nfrom functools import cmp_to_key\nimport math\nimport heapq\nimport re\n\ndef sin():\n return input()\ndef ain():\n return list(map(int, sin().split()))\ndef sain():\n return input().split()\ndef iin():\n return int(sin())\nMAX = float('inf')\nMIN = float('-inf')\nMOD = 1000000007\ndef sieve(n): \n prime = [True for i in range(n+1)]\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p): \n prime[i] = False\n p += 1\n s = set()\n for p in range(2, n+1): \n if prime[p]: \n s.add(p)\n return s\ndef readTree(n, m):\n adj = [deque([]) for _ in range(n+1)]\n for _ in range(m):\n u,v = ain()\n adj[u].append(v)\n adj[v].append(u)\n return adj\n\n# Stay hungry, stay foolish!\n\ndef main():\n n = iin()\n d = {1:[0,0], 2:[0, 1], 3:[0,2], 4:[1,0], 5:[1,1], 6:[1,2], 7:[2,0], 8:[2,1], 9:[2,2], 0:[3,1]}\n s = list(sin())\n l = [[0]*4 for _ in range(4)]\n for i in range(n):\n x,y = d[int(s[i])]\n l[x][y] = 1\n dir = [[0,-1], [0, 1], [-1, 0], [1, 0]]\n flag = 0\n for x,y in dir:\n count = 0\n for i in range(4):\n for j in range(4):\n if l[i][j] == 1:\n tx = i+x\n ty = j+y\n if 0<=tx<4 and 0<=ty<3:\n if tx==3 and ty==0:\n continue\n if tx==3 and ty==2:\n continue\n count+=1\n if count == n:\n flag = 1\n break\n if flag:\n print(\"NO\")\n else:\n print(\"YES\")\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n\n# Fast IO Template starts\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\nif os.getcwd() == 'D:\\\\code':\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# Fast IO Template ends\nif __name__ == \"__main__\":\n main()\n\n# Never Give Up - John Cena"}, {"source_code": "def main():\n\tn = input()\n\ts = input()\n\tprint(solver(s))\n\ndef solver(s):\n\tcoordDict = {i: ((i - 1) // 3, (i - 1) % 3) for i in range(1, 10)}\n\tcoordDict[0] = (3, 1)\n\t# print(coordDict)\n\tcoordinates = [coordDict[int(c)] for c in s]\n\t# print(coordinates)\n\trows = [row for (row, col) in coordinates]\n\tcols = [col for (row, col) in coordinates]\n\trowSize = max(rows) - min(rows) + 1\n\tcolSize = max(cols) - min(cols) + 1\n\t# print(rows)\n\t# print(cols)\n\tif rowSize < 3:\n\t\treturn \"NO\"\n\telif rowSize == 3:\n\t\tif colSize < 3 or \\\n\t\t\"7\" not in s and \"9\" not in s:\n\t\t\treturn \"NO\"\n\t\telse:\n\t\t\treturn \"YES\"\n\telif rowSize == 4:\n\t\treturn \"YES\"\n\telse:\n\t\tassert(False)\n\ndef getRowsCols(coordinates):\n\tfor (row, col) in coordinates:\n\t\tpass\n\n# print(solver(\"586\"))\n# print(solver(\"09\"))\n# print(solver(\"123456789\"))\n# print(solver(\"911\"))\n\nmain()\n\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nLeftCol = False\nRightCol = False\nTopRow = False\nBottomRow = False\n\nif '1' in s or '2' in s or '3' in s:\n\tTopRow = True\nif '1' in s or '4' in s or '7' in s:\n\tLeftCol = True\nif '3' in s or '6' in s or '9' in s:\n\tRightCol = True\nif '7' in s or '8' in s or '9' in s:\n\tBottomRow = True\n\n\nif '0' not in s:\n\tif LeftCol == False or RightCol == False or BottomRow == False:\n\t\tprint 'NO'\n\telse:\n\t\tprint 'YES'\nelse:\n\tif TopRow == False:\n\t\tprint 'NO'\n\telse:\n\t\tprint 'YES'"}, {"source_code": "input()\ns = input()\nx = []\ny = []\nfor i in s:\n if(i != '0'):\n y.append((int(i) - 1)//3)\n x.append((int(i) - 1)%3)\n else:\n y.append(3)\n x.append(1)\nx.sort()\ny.sort()\nif('0' in s):\n if((y[-1] - y[0])==3):\n print('YES')\n else:\n print('NO')\nelse:\n if((x[-1] - x[0])==2 and (y[-1] - y[0])==2):\n print('YES')\n else:\n print('NO')"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\ndef up_down_possible(number):\n return all([n in (1, 2, 3, 4, 5, 6, 7, 8, 9, 11) for n in number])\n\ndef left_possible(number_mods, number):\n if 11 in number:\n return False\n return all([n >= 2 for n in number_mods])\n\ndef right_possible(number_mods, number):\n if 11 in number:\n return False\n number_mods_ = [3 if n == 0 else n for n in number_mods]\n return all([n <= 2 for n in number_mods_])\n\nif __name__ == '__main__':\n n = int(raw_input())\n raw_number = raw_input()\n number = [11 if c == '0' else int(c) for c in raw_number]\n number_up = map(lambda x: x-3, number)\n number_down = map(lambda x: x+3, number)\n up_condition = up_down_possible(number_up)\n down_condition = up_down_possible(number_down)\n number_mods = [n % 3 for n in number]\n left_condition = left_possible(number_mods, number)\n right_condition = right_possible(number_mods, number)\n if any((up_condition, down_condition, left_condition, right_condition)):\n print 'NO'\n else:\n print 'YES'\n"}, {"source_code": "import sys, math\nn = int(input())\ns = input()\n'''prev = int(s[0])\nminx=0\nminy=0\nmaxx=0\nmaxy=0\nif prev == 0:\n prev = 11\npx = (prev - 1) % 3\npy = (prev - 1)//3\nmaxx=px\nminx=px\nmaxy=py\nminy=py\nfor i in s[1:]:\n now = int(i)\n if now == 0:\n now = 11\n px = (now - 1) % 3\n py = (now - 1)//3\n maxx=max(px, maxx)\n minx=min(px, minx)\n maxy=max(py, maxy)\n miny=min(py, miny)\nif (maxy == 3 and miny == 0) or (minx == 0:\n print('Yes')\nelse:\n print('No')'''\nif ((('1' in s) or ('2' in s) or ('3' in s)) and ('0' in s)) or (('1' in s) and ('9' in s)) or (('3' in s) and ('7' in s)):\n print('YES')\nelse:\n print('NO')\n \n \n"}, {"source_code": "def f(x):\n if x==0: return (3,1)\n else: return ((x-1)//3,(x-1)%3)\nt=[-1]*5\nt2=[-1,1,1,1,-1]\nd=[t,t2,t2,t2,[-1,-1,1,-1,-1],t]\nn=int(input())\noffset=[[1,0],[0,1],[-1,0],[0,-1]]\ncoord=[f(int(i)) for i in input()]\nfor dx,dy in offset:\n if all(d[x+dx][y+dy]==1 for x,y in coord):\n print(\"NO\")\n break\nelse: \n print(\"YES\")\n \n\n"}, {"source_code": "input()\ns=list(raw_input())\nfor i in range(len(s)): s[i]=[int(s[i]),11][s[i]=='0']\np=[]\nfor i in xrange(1,len(s)): p+=[s[i]-s[i-1]]\nr=[1,2,3,4,5,6,7,8,9,11]\nc=True\nfor i in xrange(1,10):\n if(i!=s[0]):\n for x in p:\n i+=x\n if not (i in r):\n c=False\n break\n if(c):\n print 'NO'\n quit()\n else:\n c=True\nprint 'YES'"}, {"source_code": "import sys\nsp1 = ['1','4','7']\nsp2 = ['1','2','3']\nsp3 = ['3','6','9']\nsp4 = ['7','0','9']\nn = int(input())\ns = input()\nfor i in sp1:\n if i in s:\n if '0' in s:\n print('YES')\n sys.exit(0) \n for j in sp2:\n if j in s:\n for k in sp3:\n if k in s:\n for t in sp4:\n if t in s:\n print('YES')\n sys.exit(0)\nelse:\n print('NO')\n"}, {"source_code": "class Pos:\n x = y = 0\n def __init__(self, a, b):\n self.x = a\n self.y = b\n def sub(self, a):\n return Pos(self.x - a.x, self.y - a.y)\n def add(self, a):\n return Pos(self.x + a.x, self.y + a.y)\ndef locate(a):\n return Pos(3, 1) if a == 0 else Pos((a - 1) // 3, (a - 1) % 3)\n_ = raw_input()\nseq = raw_input()\nlist = []\nfor i in range(1, len(seq)):\n list.append(locate(int(seq[i])).sub(locate(int(seq[i - 1]))))\nflag = False\nfor i in range(0, 9):\n flag2 = False\n if i == int(seq[0]):\n continue\n a = locate(i)\n for j in list:\n a = a.add(j)\n if (a.x not in range(0, 3)) or (a.y not in range(0, 3)) or (a.x == 3 and a.y != 1):\n flag2 = True\n break\n flag = True if flag2 == False else False\n if flag:\n break\nprint 'NO' if flag else 'YES'\n"}, {"source_code": "n = raw_input().split()[0]\nd = raw_input().split()[0]\n\nl = 0\nr = 0\nt = 0\nb = 0\nz = 0\n\nif '1' in d:\n l = 1\n t = 1\nif '2' in d:\n t = 1\nif '3' in d:\n r = 1\n t = 1\nif '4' in d:\n l = 1\nif '6' in d:\n r = 1\nif '7' in d:\n b = 1\n l = 1\nif '9' in d:\n b = 1\n r = 1\nif '0' in d:\n b = 1\nprint l,r,t,b\nif ('8' in d) and (b==0):\n print 'NO'\n exit()\nif l+r+t+b == 4:\n print 'YES'\n exit()\nelse:\n print 'NO'"}, {"source_code": "n = int(input())\ns = input()\nfill = [[False for i in range(3)] for j in range(4)]\nfor i in s:\n j = ord(i)-ord('0')-1 #0, 1, 2, 3...\n fill[j//3][j%3] = True\nleft = fill[0][0] or fill[0][1] or fill[0][2]\nright = fill[2][0] or fill[2][1] or fill[2][2]\ntop = fill[0][0] or fill[0][1] or fill[0][2]\nbottom = fill[2][0] or fill[2][1] or fill[2][2]\nbump = not fill[2][0] and not fill[2][2] and not fill[3][1]\nif not left or not right or not top or not bottom or bump:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n = int(raw_input())\nm1 = raw_input()\nm = []\nfor i in range(1,len(m1)):\n if m1[i] == \"0\" :\n k = 11\n else :\n k= int(m1[i])\n if m1[i-1] == \"0\" :\n kk = 11\n else :\n kk = int(m1[i-1])\n\n u = (k-1)/3-(kk-1)/3\n uu = (k-1)%3-(kk-1)%3\n m.append([])\n m[i-1].append(u)\n m[i-1].append(uu)\n\n\nq = [[1,2,3],[4,5,6],[7,8,9],[\"1\",0,\"1\"]]\n\nflag = 0\nflag2 = 0\nfor i in range(10):\n if i==0 :\n o = 3\n oo = 0\n dd = len(m)\n \n for j in range(len(m)):\n if 0 <= o+m[j][0] and o+m[j][0]<=2 and 0<=oo+m[j][1] and oo+m[j][1]<=2 :\n pass\n elif o+m[j][0]==3 and oo+m[j][1]==1 :\n pass\n else :\n dd-=1\n o=o+m[j][0]\n oo=oo+m[j][1]\n\n if dd == len(m) :\n if flag2 == 1 :\n print \"NO\"\n flag = 1\n break\n else :\n flag2=1\n else :\n o = (i-1)/3\n oo = (i-1)%3\n dd = len(m)\n\n for j in range(len(m)):\n if 0 <= o+m[j][0] and o+m[j][0]<=2 and 0<=oo+m[j][1] and oo+m[j][1]<=2 :\n pass\n elif o+m[j][0]==3 and oo+m[j][1]==1 :\n pass\n else :\n dd-=1\n \n o=o+m[j][0]\n oo=oo+m[j][1]\n\n if dd == len(m) :\n\n if flag2 == 1 :\n print \"NO\"\n flag = 1\n break\n else :\n flag2=1\n\nif flag == 0 :\n print \"YES\"\n\n\n\n\n \n \n \n"}, {"source_code": "n=input()\na=raw_input()\nt=0\nt1=0\nt2=0\nt3=0\nfor i in range (n) :\n q=int(a[i])\n if q==3 :\n t=1\n if q==4 or q==5 or q==6 :\n t1=0\n if q==9 :\n t2=1\n if q==0 :\n t3=1\nif t+t1+t2+t3==2 :\n print 'YES'\nelse :\n print 'NO'\n"}, {"source_code": "n = int(input())\ns = list(input())\nc = 0\nd = 0\nfor i in s:\n if i in ['1','2','3']:\n c+=1\n d += 1\n if i in ['1','4','7']:\n c+=1\n if i in ['3','6','9']:\n c+=1\n if i in ['7','0','9']:\n c+=1\nif c==4 or ('0' in s and d) :\n print(\"YES\")\n exit(0)\nelse:\n print(\"NO\")\n exit(0)\n \n \n"}, {"source_code": "# coding: utf-8\nimport sys\n\nU = {'4', '5', '6', '7', '8', '9', '0'}\nL = {'2', '3', '5', '6', '8', '9'}\nR = {'1', '2', '4', '5', '7', '8'}\nD = {'1', '2', '4', '5', '6', '8'}\n\n\ndef main(num_digits, digits):\n if (\n all(d in U for d in digits) or\n all(d in L for d in digits) or\n all(d in R for d in digits) or\n all(d in D for d in digits)\n ):\n return 'NO'\n return 'YES'\n\nif __name__ == \"__main__\":\n num_digits = int(sys.stdin.readline())\n digits = sys.stdin.readline()\n main(num_digits, digits)\n\n # print main(3, '586') == 'NO'\n # print main(2, '09') == 'NO'\n # print main(9, '123456789') == 'YES'\n # print main(3, '911') == 'YES'\n\n\n\n"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n n = input()\n n_str = raw_input()\n flag=0\n\n if '1' in n_str:\n if '9' in n_str or '0' in n_str:\n flag = 1\n elif '2' in n_str:\n if '7' in n_str and '9' in n_str:\n flag =1\n elif '0' in n_str:\n flag =1\n elif '3' in n_str:\n if '7' in n_str or '0' in n_str:\n flag = 1\n if flag:\n print \"YES\"\n else:\n print \"NO\"\n\n\n\nif __name__ == '__main__':\n some_func()\n\n\n\n\n"}, {"source_code": "pos=[[5,3]]\n\nfor x in range(2,5):\n for y in range(2,5):\n pos.append([x,y])\n\ntmp=[]\nfor x in range(6):\n tmp.append(-1)\n\na=[]\nfor x in range(6):\n a.append(tmp)\n\nfor i in range(10):\n x=pos[i][0]\n y=pos[i][1]\n #print(x,y)\n a[x][y]=i\n\nn=input()\ns=input()\n\nfor x,y in zip([0,0,-1,1],[-1,1,0,0]):\n ok=True\n for c in s:\n u=pos[int(c)][0]+x\n v=pos[int(c)][1]+y\n if a[u][v]==-1: ok=False\n if not ok:\n print('YES')\n break\nif not ok: print('NO')\n"}, {"source_code": "import sys\nsp1 = ['1','4','7']\nsp2 = ['1','2','3']\nsp3 = ['3','6','9']\nsp4 = ['7','0','9']\ns = input()\nfor i in sp1:\n if i in s:\n for j in sp2:\n if j in s:\n for k in sp3:\n if k in s:\n for t in sp4:\n if t in s:\n print('YES')\n sys.exit(0)\nelse:\n print('NO')\n"}, {"source_code": "n=input()\na=raw_input()\nt=[0]*10\nfor i in range (n) :\n q=int(a[i])\n t[q]=t[q]+1\nif t[0]>0 and ((t[1]+t[2]+t[3])>0) :\n print 'YES'\nelif t[1]>0 and t[9]>0 :\n print 'YES'\nelif t[3]>0 and t[7]>0 :\n print 'YES'\nelif (t[9]>0 and t[3]>o and (t[4]+t[7]>0) ) or (t[1]>1 and t[7]>0 and t[9]+t[6]>0) :\n print 'YES'\nelif (t[1]>0 and t[3]>0) or (t[4]>0 and t[6]>0) or (t[7]>0 and t[9]>0) :\n print 'YES'\nelse :\n print 'NO'\n print t[9] , t[3] , t[4] , t[7]\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\ncords = []\nfor c in s:\n c = int(c)\n if c == 0:\n row, col = 3, 1\n else:\n row, col = (c-1)/3, (c-1)%3\n cords.append((row, col))\nvariants = 0\nfor x in range(3):\n for y in range(3):\n curx, cury = x, y\n isValid = True\n for i in range(1, len(cords)):\n curx += cords[i][0] - cords[i-1][0]\n cury += cords[i][1] - cords[i-1][1]\n if curx == 3 and cury == 1:\n continue\n elif curx >= 0 and curx < 3 and cury >= 0 and cury < 3:\n continue\n else:\n isValid = False\n if isValid:\n variants += 1\n\nif variants > 1:\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n=int(input())\na=input()\nif a==\"10\":\n print(\"YES\")\nelse:\n x=int(a[0])\n y=int(a[-1])\n temp=[[1,9],[3,7]]\n potty=True\n for i in temp:\n if x in i and y in i:\n potty=False\n print(\"YES\")\n break\n else:\n potty=True\n if potty==True:\n print(\"NO\")"}, {"source_code": "# coding: utf-8\nimport sys\n\nU = {'4', '5', '6', '7', '8', '9', '0'}\nL = {'2', '3', '5', '6', '8', '9'}\nR = {'1', '2', '4', '5', '7', '8'}\nD = {'1', '2', '3', '4', '5', '6', '8'}\n\n\ndef main(num_digits, digits):\n if num_digits < 1 or num_digits > 9:\n return 'NO'\n\n if len(digits) != num_digits:\n return 'NO'\n\n if not digits.isdigit():\n return 'NO'\n\n if (\n all(d in U for d in digits) or\n all(d in L for d in digits) or\n all(d in R for d in digits) or\n all(d in D for d in digits)\n ):\n return 'NO'\n return 'YES'\n\nif __name__ == \"__main__\":\n num_digits = int(sys.stdin.readline())\n digits = sys.stdin.readline()\n print main(num_digits, digits)\n\n # print main(3, '586') == 'NO'\n # print main(2, '09') == 'NO'\n # print main(9, '123456789') == 'YES'\n # print main(3, '911') == 'YES'\n\n\n\n"}, {"source_code": "import sys\nread=lambda:sys.stdin.readline().rstrip()\nreadi=lambda:int(sys.stdin.readline())\nwriteln=lambda x:sys.stdout.write(str(x)+\"\\n\")\nwrite=lambda x:sys.stdout.write(x)\ndef solve(memory, N):\n pad=[[-1]*7 for _ in range(8)]\n n = 1\n npos = [[-1,-1]]*10\n for i in range(2, 5):\n for j in range(2, 5):\n pad[i][j] = n\n npos[n] = (i, j)\n n += 1\n pad[3][5] = 0\n npos[0] = (3, 5)\n vecs = []\n sy, sx = npos[int(memory[0])]\n for i in range(N-1):\n y, x = npos[int(memory[i])]\n ny, nx = npos[int(memory[i+1])]\n vecs.append((ny-y, nx-x))\n\n for i in range(2, 5):\n for j in range(2, 5):\n if (sy, sx) == (i, j):\n continue \n y, x = i, j\n for t in range(N-1):\n dy,dx = vecs[t]\n y, x = y + dy, x + dx\n if pad[y][x] == -1:\n break\n else:\n return \"NO\"\n \n if (sy, sx) == (3, 5):\n return \"YES\"\n \n y, x = 3, 5\n for t in range(N-1):\n dy,dx = vecs[t]\n y, x = y + dy, x + dx\n if pad[y][x] == -1:\n break\n else:\n return \"NO\"\n\n return \"YES\"\n \nN=readi()\nmem = read()\nwriteln(solve(mem, N))"}, {"source_code": "def main():\n n = int(raw_input())\n arr = set(map(int, raw_input()))\n\n up = arr.intersection({1, 2, 3})\n dwn = arr.intersection({0, 7, 9})\n rt = arr.intersection({3, 6, 9})\n lft = arr.intersection({1, 4, 7})\n\n print 'NO' if len(up) == 0 or len(dwn) == 0 or len(rt) == 0 or len(lft) == 0 else 'YES'\n\nmain()\n"}, {"source_code": "n=input()\na=raw_input()\nt=0\nt1=0\nt2=0\nt3=0\nfor i in range (n) :\n q=int(a[i])\n if q==3 :\n t=1\n if q==4 or q==5 or q==6 :\n t1=0\n if q==9 :\n t2=1\n if q==0 :\n t3=1\nif t+t1+t2+t3==2 :\n print 'YES'\nelse :\n print 'NO'\n"}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif a==\"23482375\" or a==\"289887167\" or a==\"8465393\" or a==\"267\" or a==\"249\" or a==\"672\" or a==\"176\":\n print(\"YES\")\nelse:\n if len(a)>1:\n z=int(a[1])\n if \"0\" in a and \"1\" in a or \"0\" in a and \"2\" in a or \"0\" in a and \"3\" in a:\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n if \"1\" in a and \"9\" in a:\n potty=False\n elif \"7\" in a and \"3\" in a:\n potty = False\n else:\n potty=True\n if potty==True:\n print(\"NO\")\n else:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n = int(input())\ns = list(input())\n#\nc = 0\nfor i in s:\n if i in ['1','2','3']:\n c+=1\n if i in ['1','4','7']:\n c+=1\n if i in ['3','6','9']:\n c+=1\n if i in ['7','0','9']:\n c+=1\nif c>=4: #or '0' in s:\n print(\"YES\")\n exit(0)\nelse:\n print(c)\n print(\"NO\")\n exit(0)\n \n \n"}, {"source_code": "g = [(4, 2), (1, 1), (2, 1), (3, 1), (1, 2), (2, 2), (3, 2), (1, 3), (2, 3), (3, 3)]\n\nn = int(input())\ns = input()\npath = []\nfor i in range(n - 1):\n dx = g[int(s[i + 1])][0] - g[int(s[i])][0]\n dy = g[int(s[i + 1])][1] - g[int(s[i])][1]\n path.append((dx, dy))\nfor i in range(10):\n if i != int(s[0]):\n curr_x, curr_y = g[i][0], g[i][1]\n cnt = 0\n while cnt != n - 1 and (curr_x, curr_y) in g:\n curr_x += path[cnt][0]\n curr_y += path[cnt][1]\n cnt += 1\n if cnt == n - 1:\n print(\"NO\")\n exit()\nprint(\"YES\")"}, {"source_code": "n = input()\na = [int(i) for i in str(input())]\nx_max = 0\nx_min = 3\ny_max = 0\ny_min = 3\nfor i in a:\n if i == 0:\n x, y = 2, 4\n else:\n if i % 3 == 0:\n x = 3\n else:\n x = i % 3\n y = (i + 2) // 3\n x_max = max(x, x_max)\n x_min = min(x, x_min)\n y_max = max(y, y_max)\n y_min = min(y, y_min)\nok = \"NO\"\n\ny_diff = y_max - y_min\nx_diff = x_max - x_min\n\nif y_diff == 3 or (y_diff + x_diff == 4 and y_max != 3):\n ok = \"YES\"\nprint(ok)\n"}, {"source_code": "n=int(input())\na=input()\nif a==\"10\":\n print(\"YES\")\nelse:\n x=int(a[0])\n y=int(a[-1])\n temp=[[1,9],[3,7]]\n potty=True\n for i in temp:\n if x in i and y in i:\n potty=False\n print(\"YES\")\n break\n else:\n potty=True\n if potty==True:\n print(\"NO\")"}, {"source_code": "n=input()\na=raw_input()\nt=[0]*10\nfor i in range (n) :\n q=int(a[i])\n t[q]=t[q]+1\nif t[0]>0 and ((t[1]+t[2]+t[3])>0) :\n print 'YES'\nelif t[1]>0 and t[9]>0 :\n print 'YES'\nelif t[3]>0 and t[7]>0 :\n print 'YES'\nelse :\n print 'NO'\n"}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif len(a)>1:\n z=int(a[1])\n if str(z)==\"0\" and str(x) in \"123\":\n print(\"YES\")\n elif str(x)==\"0\" and str(z) in \"123\":\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n for i in temp:\n if x in i and y in i:\n potty=False\n print(\"YES\")\n break\n else:\n potty=True\n if potty==True:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\ns = input()\na = [int(i) for i in s ]\nif sum(a) % 5 == 0:\n print(\"YES\")\nelif '1' in s and '9' in s:\n print(\"YES\")\nelif '3' in s and '7' in s:\n print(\"YES\")\nelif '2' in s and '0' in s:\n print(\"YES\")\nelif '1' in 's' and '0' in s:\n print(\"YES\")\nelif '3' in s and '0' in s:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\ndef up_down_possible(number):\n return all([n in (1, 2, 3, 4, 5, 6, 7, 8, 9, 11) for n in number])\n\ndef left_possible(number_mods, number):\n if 11 in number:\n return False\n return all([n >= 2 for n in number_mods])\n\ndef right_possible(number_mods, number):\n if 11 in number:\n return False\n number_mods_ = [3 if n == 0 else n for n in number_mods]\n return all([n <= 2 for n in number_mods_])\n\nif __name__ == '__main__':\n n = int(raw_input())\n raw_number = raw_input()\n number = [11 if c == '0' else int(c) for c in raw_number]\n number_up = map(lambda x: x-3, number)\n number_down = map(lambda x: x+3, number)\n up_condition = up_down_possible(number_up)\n down_condition = up_down_possible(number_down)\n number_mods = [n % 3 for n in number]\n left_condition = left_possible(number_mods, number)\n right_condition = right_possible(number_mods, number)\n if any((up_condition, down_condition, left_condition, right_condition)):\n print 'NO'\n else:\n print 'YES'\n"}, {"source_code": "def normalizeInput():\n for i in range(len(digits)):\n if digits[i] == 0:\n no_zero = 0\n digits[i] = 11\n\n\ndef validateInput(add):\n if no_zero == 0 or (add < 0 and add % 3 == 0):\n for digit in digits:\n if digit + add > 11 or digit + add < 1 or digit + add == 10:\n return False\n return True\n\n\nn = int(input())\na = input()\nno_zero = 1\nok = 1\ndigits = [int(d) for d in a]\n\nnormalizeInput()\n\nfor i in range(-6, 10):\n if validateInput(i):\n ok = 0\n break\n\nif ok == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n=int(input())\na=input()\ngrid=[1,2,3,4,5,6,7,8,9,'',0,'']\nleft=[]\nup=[]\ndown=[]\nright=[]\nfor i in a:\n if i=='0':\n up.append(8)\n else:\n left.append(int(i)-1)\n right.append(int(i)+1)\n up.append(int(i)-3)\n down.append(int(i)+3)\nleft.sort()\nright.sort()\nup.sort()\ndown.sort()\ny=[]\ny.append(up)\ny.append(right)\ny.append(left)\ny.append(down)\npotty=False\nfor i in y:\n if len(i)<len(a):\n potty=False\n elif i[-1]>9 or i[0]<1:\n potty=False\n else:\n potty=True\n break\nif potty==True:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n = int(input())\ns = input()\nfill = [[False for i in range(3)] for j in range(4)]\nfor i in s:\n j = ord(i)-ord('0')-1 #0, 1, 2, 3...\n fill[j//3][j%3] = True\nleft = fill[0][0] or fill[0][1] or fill[0][2]\nright = fill[2][0] or fill[2][1] or fill[2][2]\ntop = fill[0][0] or fill[0][1] or fill[0][2]\nbottom = fill[2][0] or fill[2][1] or fill[2][2]\nbump = not fill[2][0] and not fill[2][2] and not fill[3][1]\nif not left or not right or not top or not bottom or bump:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n= int(raw_input())\nl = list(raw_input())\nup=0\ndown=0\nleft=0\nright=0\nfor j in range (0, n):\n i = int(l[j])\n if i == 1 or i == 2 or i ==3 :\n up += 1\n if i == 3 or i ==6 or i ==9:\n right += 1\n if i == 1 or i == 4 or i == 7:\n left += 1\n if i == 7 or i == 0 or i == 9:\n down += 1\nif up*down*left*right >0:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n = int(raw_input())\ns = raw_input().strip()\nd = {'0': (3, 1)}\nfor c in '123456789':\n d[c] = (int(c) / 3, (int(c) - 1) % 3)\na = [d[c] for c in s]\nb = 0\nfor c in '1234567890':\n p = d[c]\n t = [(p[0] - a[0][0] + q[0], p[1] - a[0][1] + q[1]) for q in a]\n if all(x in d.values() for x in t):\n b += 1 \nprint \"YES\" if b == 1 else \"NO\"\n"}, {"source_code": "n = int(raw_input())\nm1 = raw_input()\nm = []\nfor i in range(1,len(m1)):\n if m1[i] == \"0\" :\n k = 11\n else :\n k= int(m1[i])\n if m1[i-1] == \"0\" :\n kk = 11\n else :\n kk = int(m1[i-1])\n\n u = (k-1)/3-(kk-1)/3\n uu = (k-1)%3-(kk-1)%3\n m.append([])\n m[i-1].append(u)\n m[i-1].append(uu)\n\n\nq = [[1,2,3],[4,5,6],[7,8,9],[\"1\",0,\"1\"]]\n\nflag = 0\nflag2 = 0\nfor i in range(10):\n if i==0 :\n o = 3\n oo = 0\n dd = len(m)\n \n for j in range(len(m)):\n if 0 <= o+m[j][0] and o+m[j][0]<=2 and 0<=oo+m[j][1] and oo+m[j][1]<=2 :\n pass\n elif o+m[j][0]==3 and oo+m[j][1]==1 :\n pass\n else :\n dd-=1\n o=o+m[j][0]\n oo=oo+m[j][1]\n\n if dd == len(m) :\n if flag2 == 1 :\n print \"NO\"\n flag = 1\n break\n else :\n flag2=1\n else :\n o = (i-1)/3\n oo = (i-1)%3\n dd = len(m)\n\n for j in range(len(m)):\n if 0 <= o+m[j][0] and o+m[j][0]<=2 and 0<=oo+m[j][1] and oo+m[j][1]<=2 :\n pass\n elif o+m[j][0]==3 and oo+m[j][1]==1 :\n pass\n else :\n dd-=1\n \n o=o+m[j][0]\n oo=oo+m[j][1]\n\n if dd == len(m) :\n\n if flag2 == 1 :\n print \"NO\"\n flag = 1\n break\n else :\n flag2=1\n\nif flag == 0 :\n print \"YES\"\n\n\n\n\n \n \n \n"}, {"source_code": "n=int(input())\na=input()\ngrid=[1,2,3,4,5,6,7,8,9,'',0,'']\nleft=[]\nup=[]\ndown=[]\nright=[]\nfor i in a:\n if i=='0':\n up.append(8)\n elif i=='1':\n down.append(4)\n right.append(2)\n elif i=='2':\n down.append(5)\n right.append(3)\n left.append(1)\n elif i=='3':\n down.append(6)\n left.append(2)\n elif i == '4':\n up.append(1)\n down.append(7)\n right.append(5)\n elif i == '5':\n down.append(8)\n right.append(6)\n left.append(4)\n up.append(2)\n elif i == '6':\n down.append(9)\n left.append(5)\n up.append(3)\n elif i == '7':\n up.append(4)\n right.append(8)\n elif i == '8':\n down.append(0)\n right.append(9)\n left.append(7)\n up.append(5)\n elif i == '9':\n left.append(8)\n up.append(6)\nleft.sort()\nright.sort()\nup.sort()\ndown.sort()\ny=[]\ny.append(up)\ny.append(right)\ny.append(left)\ny.append(down)\npotty=False\nfor i in y:\n if len(i)<len(a):\n potty=False\n elif i[-1]>9 or i[0]<1:\n potty=False\n else:\n potty=True\n break\nif potty==True:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n=int(input())\na=input()\nx=int(a[0])\ny=int(a[-1])\nif len(a)>6 and len(set(a))!=1:\n print(\"YES\")\nelse:\n if len(a)>1:\n z=int(a[1])\n if \"0\" in a and \"1\" in a or \"0\" in a and \"2\" in a or \"0\" in a and \"3\" in a:\n print(\"YES\")\n else:\n temp=[[1,9],[3,7]]\n potty=True\n for i in temp:\n if x in i and y in i:\n potty=False\n print(\"YES\")\n break\n else:\n potty=True\n if potty==True:\n print(\"NO\")\n else:\n print(\"NO\")"}, {"source_code": "# coding: utf-8\nimport sys\n\nU = {'4', '5', '6', '7', '8', '9', '0'}\nL = {'2', '3', '5', '6', '8', '9'}\nR = {'1', '2', '4', '5', '7', '8'}\nD = {'1', '2', '4', '5', '6', '8'}\n\n\ndef main(num_digits, digits):\n if (\n all(d in U for d in digits) or\n all(d in L for d in digits) or\n all(d in R for d in digits) or\n all(d in D for d in digits)\n ):\n return 'NO'\n return 'YES'\n\nif __name__ == \"__main__\":\n num_digits = int(sys.stdin.readline())\n # print 'ND', num_digits\n digits = sys.stdin.readline()\n # print 'D', digits\n print main(num_digits, digits)\n\n # print main(3, '586') == 'NO'\n # print main(2, '09') == 'NO'\n # print main(9, '123456789') == 'YES'\n # print main(3, '911') == 'YES'\n\n\n\n"}], "src_uid": "d0f5174bb0bcca5a486db327b492bf33"} {"source_code": "from math import sqrt\nn = int(input())\nc = 0\n\nif n % 2 == 0:\n c = (n // 2)\nelse:\n for i in range(3, int(sqrt(n)+1), 2):\n if n % i == 0:\n c = 1 + (n-i)//2\n break\n else:\n c = 1\n \nprint(c)", "positive_code": [{"source_code": "n = int(input())\nsubs = 0\nwhile n!=0:\n if n%2 == 0:\n subs+=n//2\n break\n \n for i in range( 3, int(n**0.5)+1, 2):\n if n%i == 0:\n n = n-i\n subs=1\n break\n \n if n>0 and n%2 == 0:\n subs+=n//2\n break\n elif n>0:\n subs+=1\n break\nprint(subs)"}, {"source_code": "import sys\nfrom collections import defaultdict\nimport math\nn=int(sys.stdin.readline())\ndef getfactors(num):\n ans=0\n if num%2==0:\n return num//2\n fac=-1\n for i in range(2,int(math.sqrt(num))+1):\n #print(num%i)\n #print('a')\n if num%i==0:\n #print(i,'i')\n fac=i\n break\n #print(fac)\n if fac!=-1:\n num-=fac\n ans=1\n ans+=num//2\n return ans\n return 1\n \nans=getfactors(n)\nprint(ans)\n\n"}, {"source_code": "import math\n\n\ndef divisors(n):\n divs = []\n for i in range(2, int(math.sqrt(n)) + 1):\n if n % i == 0:\n divs.extend([i, n // i])\n return set(divs)\n\n\nn = int(input())\n\nif n % 2 == 0:\n print(n // 2)\nelse:\n divs = list(sorted(divisors(n)))\n if len(divs) == 0:\n print(1)\n else:\n for v in divs:\n tmpdivs = divisors(v)\n if len(tmpdivs) == 0:\n n -= v\n print(1 + (n // 2))\n exit(0)\n print(1)\n"}, {"source_code": "n = int( input() )\nd = n\ni = 2\nwhile i * i <= n:\n div = n // i\n if i * div == n:\n d = i\n break\n i += 1\n\nprint( 1 + ( n - d ) // 2 )\n"}, {"source_code": "import sys\nn = int(sys.stdin.readline().strip())\n\n\ndef find_min_prime(n):\n x = int(round(n**(0.5) + 1))\n for i in range(2, x):\n if n % i == 0:\n return i\n return n\n\n\nif n % 2 == 0:\n s = n // 2\nelse:\n d = find_min_prime(n)\n n = n - d\n s = 1 + n // 2\nprint(s)\n\n"}, {"source_code": "n = int(input())\n\ncount = 0\nrep = 2\n\nwhile n != 0:\n if n%2 == 0: \n count_temp = n / 2\n n-=(2 * count_temp)\n count += count_temp\n continue\n\n while n % rep != 0 and rep * rep <= n:\n rep+=1\n\n if n % rep == 0:\n n-=rep\n count+=1\n else:\n n=0\n count+=1\n \n\nprint(int(count))"}, {"source_code": "n = int(input())\nj = int((n ** 0.5) + 1)\nq = n\nfor i in range(2 , j):\n if(n % i == 0):\n #print(i)\n q = min(q , i)\n break\nif(q == n):\n print(1)\nif(q < n):\n print(1 + (n - q)//2)\n"}, {"source_code": "n=int(input())\nsqrt=int(n**(1/2))+1\nfor i in range(2,sqrt):\n if n%i==0:\n print(1+(n-i)//2)\n exit()\nprint(1)"}, {"source_code": "n=int(input())\nimport math\ndef is_prime(n):\n count=0\n for i in range(2, int(math.sqrt(n)+1)):\n if n%i==0:\n count+=1\n if count==0:\n return True\n else:\n return False\n\ndef cf(n):\n if n%2==0:\n print(int(n/2))\n else:\n for i in range(2,int(math.sqrt(n)+1)):\n if n%i==0 and is_prime(i)==True:\n print (int(((n- i)/2)+1))\n break\n if is_prime(n)==True:\n print(\"1\")\n\ncf(n)\n"}, {"source_code": "import math\nn=int(input())\nif(n%2==0):\n print(n//2)\nelse:\n c=0\n for i in range(3,int(math.sqrt(n))+1,2):\n if(n%i==0):\n c=1\n k=i\n break\n if(c==0):\n print(1)\n else:\n print(1+((n-k)//2))"}, {"source_code": "n = int(input())\nfor i in range(2, int(n**0.5)+1):\n if n % i == 0:\n print((n-i)//2+1)\n break\nelse: print(1)"}, {"source_code": "#!/usr/bin/env python3\nfrom typing import Dict, List, Tuple\n\n\ndef input_lst() -> List[int]:\n return [int(x) for x in input().split()]\n\ndef print_out(res: List[int]):\n print(' '.join([str(x) for x in res]))\n\n# def eratosthenes(n): # n - \u0447\u0438\u0441\u043b\u043e, \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430\n#\n\ndef main():\n\n n, = (int(x) for x in input().split())\n sieve = list(range(int(n**0.5) + 1))\n\n if n // 2 == n / 2:\n print(n//2)\n return\n\n sieve[1] = 0 # \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u0443\n for i in sieve:\n if i > 1:\n if n/i == n//i:\n print((n - i)//2 + 1)\n return\n for j in range(i + i, len(sieve), i):\n sieve[j] = 0\n\n print(1)\n\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def sol(x):\n if x%2==0:\n return 2\n else:\n n=3\n while n*n<=x:\n if x%n==0:\n return n\n else:\n n+=2\n return x\nx=int(input())\n\nj=x\nans=0\nwhile x%2==1:\n x-=sol(x)\n ans+=1\nprint(ans+(x//2))"}, {"source_code": "s = input()\nn = 0\nfor c in s:\n ch = ord(c) - ord('0')\n n = 10 * n + ch\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n break\n i += 1\nif n % i != 0:\n print(1)\nelif i == 2:\n print(n // 2)\nelse:\n n -= i\n print(n // 2 + 1)\n"}, {"source_code": "import math\ndef prime(a):\n\tfor i in range(2,int(math.sqrt(a))+1):\n\t\tif a%i==0:\n\t\t\treturn 0\n\treturn 1\n\nn = int(input())\n\nif prime(n)==1:\n\tprint(\"1\")\n\t\nelif n%2==0:\n\tprint(int(n/2))\n\t\nelse:\n\tfor i in range(2,n):\n\t\tif n%i==0 and prime(i):\n\t\t\td =i;\n\t\t\tbreak;\n\tprint(1+((n-d)//2))\n"}, {"source_code": "import math\n\nn = int(input())\nl = int(math.sqrt(n)) + 1\nis_prime = [True] * l\n\nis_prime[0] = is_prime[1] = False\nprimes = []\nfor i in range(2, l):\n if is_prime[i]:\n primes.append(i)\n for j in range(i * 2, l, i):\n is_prime[j] = False\n\nc = 0\nwhile n % 2 == 1:\n subtracted = False\n for p in primes:\n if n % p == 0:\n n -= p\n c += 1\n subtracted = True\n break\n if not subtracted:\n n = 0\n c += 1\nprint(c + (n // 2))\n"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[51]:\n\n\nn=int(input())\n\n\n# In[52]:\n\n\nsub=0\n\n\ndef smallprime(x):\n for i in range(2,int(pow(x,1/2))+1):\n if x % i==0:\n return i\n return x \n\ndef dsub(x):\n global sub\n if x==0:\n print(int(sub))\n return \n if x%2==0:\n sub=sub+x/2\n print(int(sub))\n return\n else:\n p=smallprime(x)\n sub=sub+1\n dsub(x-p)\n \n\n\n# In[53]:\n\n\ndsub(n)\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print(n // 2)\nelse:\n i = 3\n while i <= n // i:\n if n % i == 0:\n n -= i\n print(1 + (n // 2))\n exit()\n i += 1\n print(1)\n"}, {"source_code": "n=int(input())\nif n==0:\n\tprint(0)\n\texit()\nk=0\nwhile n%2!=0:\n\tflag=0\n\tfor i in range(2,int(n**(0.5))+1):\n\t\tif n%i==0:\n\t\t\tflag=1\n\t\t\tbreak\n\tif flag==1:\n\t\tn= n-i\n\telse:\n\t\tn= 0\n\tk+=1\n\nprint(k+n//2)\n"}, {"source_code": "import math\na=int(input())\nif (a%2 == 0) :\n print(a//2)\nelse:\n for i in range(3,int(math.sqrt(a)+1)):\n if(a%i==0):\n a-=i\n print(a//2+1)\n exit(0)\n print(1)"}, {"source_code": "import math\ndef div(n):\n ans=0\n for i in range(2,int(math.sqrt(n))+1):\n if n%i==0:\n ans=i\n break\n if ans>0:\n return ans\n else:\n return n\n\n\nn=int(input())\nif n%2==0:\n print(n//2)\nelse:\n a=div(n)\n n=n-a\n print(1+n//2)"}, {"source_code": "import math \narr = []\n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n): \n \n # Print the number of two's that divide n \n while n % 2 == 0: \n arr.append(2)\n return\n n = n / 2\n \n # n must be odd at this point \n # so a skip of 2 ( i = i + 2) can be used \n for i in range(3,int(math.sqrt(n))+1,2): \n \n # while i divides n , print i ad divide n \n while n % i== 0: \n arr.append(i) \n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n arr.append(n) \n \n# Driver Program to test above function \n \nn = int(input())\nprimeFactors(n)\n\nx = min(arr)\n\nif n%2==0:\n\tprint(int(n/2))\nelse:\n\tprint(int((n-x)/2)+1)"}, {"source_code": "def isprime(n):\n if n%2==0:\n return 2\n else:\n for i in range(3,int(n**(0.5))+1,2):\n if n%i==0:\n return i\n else:\n return n\nn=int(input())\nn=n - isprime(n)\nprint(n//2 + 1)\n"}, {"source_code": "def prime_factors(n):\n i = 2\n f = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n f.append(i)\n if n > 1:\n f.append(n)\n return f\n\n\ndef solve(n):\n if n < 2:\n return 0\n f = prime_factors(n)\n if f[0] == 2:\n return n // f[0]\n else:\n return 1 + solve(n-f[0])\n\n\ndef main():\n n = int(input())\n print(solve(n))\n\n\nmain()\n"}, {"source_code": "def fact(n):\n for i in range(2,int(n**.5)+1):\n if n%i==0:\n return i\n return n\nn=int(input())\nans=0\nk=fact(n)\nif k!=2:\n print(((n-k)//2)+1)\nelse:\n print(n//k)"}, {"source_code": "n = int(input())\ni, ans = 2, n\nwhile i * i <= n:\n if n % i == 0:\n ans = i\n break\n i += 1\nprint( (n-ans) // 2 + 1)"}, {"source_code": "n=int(input())\nans=0\ni=2\nwhile(i*i<=n):\n\tif n%i==0:\n\t\tans+=1\n\t\tn-=i\n\t\tbreak\n\ti+=1\nif n%2==0:\n\tprint(ans+n//2)\nelse:\n\tprint(1)\n\n# print(max(ans,1))\n"}, {"source_code": "n=int(input())\ni=2\nwhile i*i<n and n%i:i+=1\nif i*i>n:i=n\nprint(1+(n-i)//2)"}, {"source_code": "n=int(input())\nfor i in range(2,int(n**0.5)+1):\n if n%i==0: # n=15, i=3\n print(1+((n-i)//2))\n exit()\nprint(1)"}, {"source_code": "def isqrt(n):\n x = n\n y = (x + 1) // 2\n while y < x:\n x = y\n y = (x + n // x) // 2\n return x\n\n\n\ndef find_divisor(n):\n if n % 2 == 0:\n return 2\n for i in range(3, isqrt(n) + 1, 2):\n if n % i == 0:\n return i\n return n\n\n\n\n\nn = int(input()) \nprint(1 + (n - find_divisor(n)) // 2)"}, {"source_code": "n=int(input())\nt=0\nif n%2==0 :\n exit(print(n//2))\nfor i in range (2,int(pow(n,0.5))+1) :\n if n%i==0 :\n t=1 \n break\nif t!=1 :\n exit(print(\"1\"))\nelse :\n print(1+(n-i)//2)\n \n"}, {"source_code": "def crives(n):\n p = 2\n while p * p <= n :\n if n % p == 0:\n return p;\n p += 1\n return n\n\nn = int(input())\ncont = 0\nif n % 2 != 0:\n n -= crives(n)\n cont += 1\n\nresp = cont + int(n/2)\n\nprint(resp)\n"}, {"source_code": "from math import ceil\na = int(input())\nsteps = 0\n\ndef minprime(x):\n for i in range(2, ceil(x**0.5)+1):\n if x % i == 0:\n return i\n return x\nwhile a != 0:\n t = minprime(a)\n if t == 2:\n steps += a // t\n a = 0\n else:\n a -= t\n steps += 1\nprint(steps)\n"}, {"source_code": "import time\nimport collections\nimport math\n\nclass Time_test:\n def __enter__(self):\n self.enter_time = time.time()\n def __exit__(self, exc_type, exc_val, exc_tb):\n print(\"Command was executed in\", time.time()-self.enter_time)\n\nn = int(input())\ncounter = 0\nif n % 2 == 1:\n for i in range(3, math.floor(math.sqrt(n))+1):\n if n % i == 0:\n n -= i\n counter += 1\n break\n\nfor i in range(2, math.floor(math.sqrt(n))+1):\n if n % i == 0:\n counter += n // i\n n -= n // i * i\n break\n\nif n != 0:\n counter += 1\nprint(counter)\n"}, {"source_code": "import math as m\n\n\nn = int(input())\n\nif n % 2 == 0:\n print(n // 2)\nelse:\n sq = int(m.sqrt(n))\n d = 3\n while d <= sq and n % d != 0:\n d += 1\n if d <= sq:\n print(1 + (n - d) // 2)\n else:\n print(1)\n"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print(n//2)\nelse:\n ct = 1\n for i in range(2, int((n+1)**0.5) + 2):\n if n % i == 0:\n print(1 + (n-i)//2)\n ct = 0\n break\n if ct:\n print(1)\n"}, {"source_code": "from math import *\nn=int(input())\nans=0\ng=int(sqrt(n)//1)+1\nl=[0]*g\nl[0]=1\nl[1]=1\nd=[]\nfor i in range(2,g):\n if l[i]==0:\n for j in range(i+i,g,i):\n l[j]=1\n d.append(i)\nk=0\n\nwhile n:\n flag=0\n if n%2==0:\n ans+=n//2\n n=0\n break\n for i in d:\n if n%i==0:\n n-=i\n ans+=1\n flag=1\n break\n if flag==0:\n break\nif ans==0:\n ans=1\nprint(ans)\n"}, {"source_code": "import math\n\ndef small_prime_div(n):\n for x in range(2,math.floor(math.sqrt(n))+1):\n if n%x==0:\n return x\n return n\n\nn = int(input())\n##num = 0\n##while n!=0:\n## n-=small_prime_div(n)\n## num+=1\nprint(1+(n-small_prime_div(n))//2)\n \n \n"}, {"source_code": "n=input()\ni=2\nwhile i*i<n and n%i:i+=1\nprint(1+(n-i)/2,1)[i*i>n]"}, {"source_code": "n=input()\na=-1\nimport math\nif n==0:\n\tprint 0\nelif n%2==0:\n\tprint n/2\nelse:\n\tfor i in range(2,int(math.sqrt(n))+1):\n\t\tif(n%i==0):\n\t\t\ta=i\n\t\t\tbreak\n\tif(a==-1):\n\t\tprint 1\n\telse:\n\t\tprint 1+(n-a)/2\t"}, {"source_code": "n = int(input())\ndone = 0\n\nif n%2==0:\n print(int(n/2) )\nelse:\n for divisor in range(3,int(n**.5)+1 ):\n if n%divisor==0:\n print( int((n-divisor)/2 + 1 ))\n done = 1\n break\n if done==0:\n print(1)\n"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print(n // 2)\nelse:\n i = 2\n while i * i <= n:\n if n % i == 0:\n print((n - i) // 2 + 1)\n exit()\n i += 1\n print(1)\n"}, {"source_code": "import math\nn = int(input())\nt = 0\nfor i in range(2, int(math.sqrt(n)) + 1):\n if n % i == 0:\n t = i\n break\nif t == 0:\n c = 1\nelse:\n c = 1 + ((n - t) // 2)\nprint(c)\n"}, {"source_code": "def isPrime(n) : \n # Corner cases \n if (n <= 1) : \n return False\n if (n <= 3) : \n return True\n \n # This is checked so that we can skip \n # middle five numbers in below loop \n if (n % 2 == 0 or n % 3 == 0) : \n return False\n \n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n \n return True\n\nn=int(input())\nc=0\nwhile( n>0):\n if isPrime(n)==True:\n c=c+1\n break\n elif n%2==0:\n c=c+n/2\n break\n elif n%3==0:\n c=c+1+(n-3)/2\n break\n for i in range(2,int((n**(0.5)))+1):\n if n%i==0:\n if isPrime(i)==True:\n c+=1\n n-=i\n break\n \nprint c \n \n"}, {"source_code": "n = int(input())\n\nprost = 0\n\nif n % 2 == 0:\n n //= 2\n\n print(n)\n\n exit(0)\nelse :\n f = int(1)\n i = int(3)\n\n while i * i <= n:\n if n % i == 0:\n prost = i\n f = 0\n\n break\n i += 1\n\n if f == 1:\n prost = n\n\n n -= prost\n n //= 2\n\n n += 1\n\n print(n)"}, {"source_code": "import math\nn = int(input())\ndef smallest_prime_factor(n):\n for i in range(2, int(math.sqrt(n))+1, 1):\n if n%i == 0:\n return i\n return n\ncount = 0\nif n%2!=0:\n n -= smallest_prime_factor(n)\n count += 1\nprint(count + n//2)\n"}, {"source_code": "#!/usr/bin/env python3\nimport sys\nimport math\n\ndef rint():\n return map(int, sys.stdin.readline().split())\n#lines = stdin.readlines()\n\nn = int(input())\n\nif n%2 == 0:\n cnt = n//2\nelse:\n for i in range(3, int(math.sqrt(n)+1)):\n if n % i == 0:\n cnt = 1 + (n-i)//2\n break\n else:\n cnt = 1\n\nprint(cnt)\n\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Dec 16 14:02:19 2018\n\n@author: umang\n\"\"\"\n\ndef find_smallest_div(n):\n for i in range(2, int(n**0.5) + 1):\n if n%i == 0:\n return i\n return n\n \n\ndef func(n):\n count = 0\n if n == 0:\n return count\n else:\n '''while(n != 0):\n d = find_smallest_div(n)\n n -= d\n count += 1\n return count'''\n d = find_smallest_div(n)\n return 1 + (n-d)//2\n \nn = int(input())\n\nprint(func(n))"}, {"source_code": "import sys\nLI=lambda:list(map(int, sys.stdin.readline().split()))\nMI=lambda:map(int, sys.stdin.readline().split())\nSI=lambda:sys.stdin.readline().strip('\\n')\nII=lambda:int(sys.stdin.readline())\n\nfrom math import sqrt\nn=II()\nisPrime=True\nfor i in range(2, int(sqrt(n))+1):\n if n%i==0:\n isPrime=False\n break\nif isPrime:\n i=n\nprint(1+(n-i)//2)\n"}, {"source_code": "n=int(input())\ni=2\nwhile i*i<=n:\n if n%i==0:break\n i+=1\nelse:i=n\nprint(1+(n-i)//2)"}, {"source_code": "n = int(input())\nk = 0\np = 1\nfor i in range(2,int(n**0.5//1) + 1):\n if n % i == 0:\n if i == 2:\n p = i\n if (i - 1) % 4 == 0 and p == 1:\n p = i\n elif (i + 1) % 4 == 0 and p == 1:\n p = i\n if i != n // i:\n k+=2\n else:\n k+=1\nif k == 0:\n print(1)\nelse:\n print((n - p)//2 + 1)\n \n\n \n \n \n \n"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n ans = n // 2\nelse:\n i = 3\n while n % i != 0 and i <= n ** 0.5:\n i += 2\n if i > n ** 0.5:\n ans = 1\n else:\n ans = 1 + (n - i) // 2 \nprint(ans)"}, {"source_code": "n=int(input())\ncounter=0\nd=0\nfor i in range(2,int((n**0.5)+1)):\n if n % i==0:\n counter=1\n d=i\n break\nif counter:\n print(1+(n-d)//2)\nelse:\n print(1)\n\n"}, {"source_code": "from math import sqrt\nn = int(input())\nc = 0\n \nif n % 2 == 0:\n c = (n // 2)\nelse:\n for i in range(3, int(sqrt(n)+1), 2):\n if n % i == 0:\n c = 1 + (n-i)//2\n break\n else:\n c = 1\n \nprint(c)"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print(n//2)\nelse:\n fl = 1\n for u in range(2, int((n+1)**0.5)+2):\n if n%u == 0:\n print(1+(n-u)//2)\n fl = 0\n break\n if fl:\n print(1)"}, {"source_code": "n = int(input())\n\nif not n % 2:\n print(n // 2)\nelse:\n def primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n\n return a\n\n sieve = primes_sieve(1000100)\n\n for i in range(len(sieve)):\n if sieve[i]:\n if not n % i:\n print(((n - i) // 2) + 1)\n exit()\n \n print(1)"}, {"source_code": "\nn = int(input())\n\ndef PrimeList(limit):\n Plist = []\n for i in range(2,limit+1):\n divcheck = False\n for j in Plist:\n if j*j > i:\n break\n if i%j == 0:\n divcheck = True\n break\n if divcheck == False:\n Plist.append(i)\n return Plist\n\nL = PrimeList(10**5)\ncount = 0\nprimecheck = True\nfor p in L:\n if p*p > n:\n break\n if n%p == 0:\n smallest = p\n primecheck = False\n break\nif primecheck == True:\n smallest = n\nprint(1+int((n-smallest)/2))\n"}, {"source_code": "from __future__ import division\nfrom sys import stdin, stdout\n\n\ndef sieveOfEratosthenes(n):\n \"\"\"sieveOfEratosthenes(n): return the list of the primes < n.\"\"\"\n # Code from: <dickinsm@gmail.com>, Nov 30 2006\n # http://groups.google.com/group/comp.lang.python/msg/f1f10ced88c68c2d\n if n <= 2:\n return []\n sieve = range(3, n, 2)\n top = len(sieve)\n for si in sieve:\n if si:\n bottom = (si*si - 3) // 2\n if bottom >= top:\n break\n sieve[bottom::si] = [0] * -((bottom - top) // si)\n return [2] + [el for el in sieve if el]\n\n\n\n\ndef write(x):\n stdout.write(str(x) + \"\\n\")\n\nprimes = sieveOfEratosthenes(100011)\nn = int(stdin.readline())\nc= 0\nwhile n != 0:\n for prime in primes:\n if n % prime == 0:\n if prime == 2:\n write(c + n // 2)\n exit()\n n -= prime\n c += 1\n break\n if prime ** 2 > n:\n write(c+1)\n exit()\n\nwrite(c)"}, {"source_code": "#!/usr/bin/env python\n\"\"\"\nThis file is part of https://github.com/Cheran-Senthil/PyRival.\n\nCopyright 2018 Cheran Senthilkumar all rights reserved,\nCheran Senthilkumar <hello@cheran.io>\nPermission to use, modify, and distribute this software is given under the\nterms of the MIT License.\n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport cmath\nimport itertools\nimport math\nimport operator as op\nimport random\nimport sys\nfrom atexit import register\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\n# from fractions import Fraction\n# from heapq import heappop, heappush\n\nif sys.version_info[0] < 3:\n # from cPickle import dumps\n from io import BytesIO as stream\n # from Queue import PriorityQueue, Queue\nelse:\n # from functools import reduce\n from io import StringIO as stream\n from math import gcd\n # from pickle import dumps\n # from queue import PriorityQueue, Queue\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n def gcd(x, y):\n \"\"\"gcd(x, y) -> int\n greatest common divisor of x and y\n \"\"\"\n while y:\n x, y = y, x % y\n return x\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n return memodict().__getitem__\n\n\ndef _try_composite(a, d, n, s):\n if pow(a, d, n) == 1:\n return False\n for i in range(s):\n if pow(a, 2**i * d, n) == n - 1:\n return False\n return True\n\n\ndef is_prime(n):\n \"\"\"\n Deterministic variant of the Miller-Rabin primality test to determine\n whether a given number is prime.\n\n Parameters\n ----------\n n : int\n n >= 0, an integer to be tested for primality.\n\n Returns\n -------\n bool\n False if n is composite, otherwise True.\n \"\"\"\n if n in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:\n return True\n\n if (any((n % p) == 0 for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])) or (n in [0, 1]):\n return False\n\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n\n if n < 2047:\n return not _try_composite(2, d, n, s)\n if n < 1373653:\n return not any(_try_composite(a, d, n, s) for a in [2, 3])\n if n < 25326001:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5])\n if n < 118670087467:\n if n == 3215031751:\n return False\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7])\n if n < 2152302898747:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11])\n if n < 3474749660383:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13])\n if n < 341550071728321:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17])\n if n < 3825123056546413051:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])\n\n\ndef _factor(n):\n for i in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:\n if n % i == 0:\n return i\n\n y, c, m = random.randint(1, n - 1), random.randint(1, n - 1), random.randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x = y\n for i in range(r):\n y = ((y * y) % n + c) % n\n k = 0\n while (k < r) and (g == 1):\n ys = y\n for i in range(min(m, r - k)):\n y = ((y * y) % n + c) % n\n q = q * (abs(x - y)) % n\n g = gcd(q, n)\n k = k + m\n r = r * 2\n\n if g == n:\n while True:\n ys = ((ys * ys) % n + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return g\n\n\n@memodict\ndef factors(n):\n \"\"\"\n Integer factorization using Pollard's rho algorithm.\n\n Parameters\n ----------\n n : int\n n > 1, an integer to be factorized.\n\n Returns\n -------\n Counter\n Counter of the prime factors of n.\n \"\"\"\n if is_prime(n):\n return Counter([n])\n else:\n f = _factor(n)\n if f == n:\n return factors(n)\n else:\n return factors(f) + factors(n//f)\n\n\ndef main():\n n = int(input())\n\n def div_sub(n):\n if n % 2 == 0:\n return n // 2\n f = factors(n)\n f.pop(1, None)\n smallest_factor = min(f.keys())\n return 1 + ((n - smallest_factor) // 2)\n\n print(div_sub(n))\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n\n if 'PyPy' in sys.version:\n from _continuation import continulet\n\n def bootstrap(c):\n callable, arg = c.switch()\n while True:\n to = continulet(lambda _, f, x: f(x), callable, arg)\n callable, arg = c.switch(to=to)\n\n c = continulet(bootstrap)\n c.switch()\n\n main()\n\n else:\n import threading\n\n sys.setrecursionlimit(2097152)\n threading.stack_size(134217728)\n\n main_thread = threading.Thread(target=main)\n main_thread.start()\n main_thread.join()\n"}, {"source_code": "from math import sqrt\nn=input()\np=1\nfor i in range(2,int(sqrt(n))+1):\n if n%i==0:\n p=i\n break\nif p==1:\n print 1\nelse:\n print (n-p)//2+1"}, {"source_code": "n = int(input())\nfrom math import sqrt\n4\nif (n%2 == 0): print (int(n/2))\nelse:\n bank=0;\n for i in range (3,int(sqrt(n))+1):\n if n%i==0: bank = i; break\n if bank==0: bank=n\n print ((n-bank)//2 +1)\n"}, {"source_code": "import math\n\nn = input()\ns = int(math.sqrt(n))\nf = 0\nfor i in xrange(2,s+1):\n if n%i == 0:\n f = 1\n n -= i\n break\nif not f:\n print 1\nelse:\n print n/2 + 1"}, {"source_code": "def factorize(n): # o(sqr(n))\n c, ans = 1, []\n while (c * c < n):\n if n % c == 0:\n ans.extend([c, n // c])\n c += 1\n\n if c * c == n:\n ans.append(c)\n return sorted(ans)\n\n\ndef prime(n):\n if n in [2, 3]:\n return True\n if n < 2 or n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while (i * i <= n):\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i += 6\n return True\n\n\nn = int(input())\nif n % 2 == 0:\n print(n // 2)\nelse:\n fac = factorize(n)\n for j in fac:\n if prime(j):\n print((n - j) // 2 + 1)\n break\n"}, {"source_code": "n=input()\nif n%2==0:\n print n/2\nelse:\n prime=True\n for i in xrange(2,int(n**0.5+1)):\n if n%i==0:\n prime=False\n break\n if prime:\n print 1\n else:\n b=n/i\n ans=1+0.5*(i*(b-1))\n print int(ans)\n"}, {"source_code": "n=int(input())\ni=2\nwhile i*i<n and n%i:i+=1\nif i*i>n:i=n\nprint(1+(n-i)//2)"}, {"source_code": "n = int(raw_input())\ni = 2\nd = n\nwhile i * i <= n:\n\tif n % i == 0:\n\t\td = i\n\t\tbreak\n\ti += 1\nif d % 2 == 0:\n\tprint (n // d)\nelse:\n\tans = 1\n\tn -= d\n\tif (n > 0):\n\t\tans += n // 2\n\tprint(ans)"}, {"source_code": "import math\nn = int(input())\nif n%2 == 0:\n print(int(n/2))\n quit()\nfor i in range(2, int(math.sqrt(n))+1):\n if n%i == 0:\n print(int((n-i)/2)+1)\n quit()\nprint(1)"}, {"source_code": "'''input\n9\n \n\n\n'''\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nimport sys\n#maxn=1000001\nn=input()\nsq=int(n**0.5)+1\npf=n\nfor i in range(2,sq+1):\n if n%i==0:\n pf=i\n break\n\nif pf&1:\n print 1 + (n-pf)/2\nelse:\n print n/2\n\n"}, {"source_code": "n = input()\n\nprimes = {}\naux = [True] * 1000001\nstart = 2\n\nwhile (start <= 1000000):\n if (aux[start]):\n primes[start] = True\n for i in range(start * start, 1000001, start):\n aux[i] = False\n start += 1\n\n\ncount = 1\n\n\ndef getMinimumPrimeDivisor(number):\n for prime in primes:\n if (number % prime == 0):\n return prime\n return -1\n\n\nwhile (not n in primes):\n minimumDivisor = getMinimumPrimeDivisor(n)\n if (minimumDivisor == 2):\n count += n / 2 - 1\n n = 2\n elif (minimumDivisor < 0):\n n = 2\n else:\n count += 1\n n -= minimumDivisor\n\nprint(count)\n"}, {"source_code": "n = input()\nif n % 2 == 0: print n // 2\nelse:\n d = 1\n for i in xrange(1, int(n ** 0.5) + 1):\n if n % i == 0 and i != 1:\n d = i\n break\n if d == 1:\n print 1\n else:\n print 1 + (n - d) // 2\n"}, {"source_code": "from sys import stdin\nfrom collections import deque\nmod = 10**9 + 7\nimport sys\nsys.setrecursionlimit(10**5)\nfrom queue import PriorityQueue\n# def rl():\n# return [int(w) for w in stdin.readline().split()]\nfrom bisect import bisect_right\nfrom bisect import bisect_left\nfrom collections import defaultdict\nfrom math import sqrt,factorial,gcd,log2,inf,ceil\n# map(int,input().split())\n# # l = list(map(int,input().split()))\n# from itertools import permutations\nimport heapq\n# input = lambda: sys.stdin.readline().rstrip()\ninput = lambda : sys.stdin.readline().rstrip()\nfrom sys import stdin, stdout\nfrom heapq import heapify, heappush, heappop\n\n\n# n,k = map(int,input().split())\n#\n# l = list(map(int,input().split()))\n\n\ndef solve(n):\n\n for i in range(2,int(sqrt(n)) + 1):\n if n%i == 0:\n return True\n\n\n\n return False\n\n\n\n\nprimes = []\n\nfor i in range(2,10**5 + 1):\n if not solve(i):\n primes.append(i)\n\nn = int(input())\nans = 0\nwhile n!=0:\n\n if n%2 == 0:\n ans+=n//2\n break\n flag = 0\n for i in primes:\n if n%i == 0:\n n-=i\n ans+=1\n flag = 1\n break\n if not flag:\n if not solve(n):\n\n ans+=1\n break\n\nprint(ans)\n\n\n\n\n\n"}, {"source_code": "# Problem: B. Divisor Subtraction\n# Contest: Codeforces - Educational Codeforces Round 54 (Rated for Div. 2)\n# URL: https://codeforces.com/contest/1076/problem/B\n# Memory Limit: 256 MB\n# Time Limit: 2000 ms\n# \n# Powered by CP Editor (https://cpeditor.org)\n\ndef fun(n):\n\tfor _ in range(2,int(pow(n,(1/2)))+1):\n\t\tif n%_==0:\n\t\t\treturn _\n\treturn n \n\t\t\nn=int(input())\n\nprint((n-fun(n))//2+1)"}, {"source_code": "import math as mt\n#t=int(input())\nt=1\ndef sp(n):\n if n%2==0:\n return 2\n i=3\n while i*i<=n:\n if n%i==0:\n return i\n i+=1\n return n \nfor _ in range(t):\n n=int(input())\n x=sp(n)\n if n%2==0:\n print(n//2)\n else:\n print((n-x)//2+1)"}, {"source_code": "import math\np=0\nn=int(input())\n\nfor i in range(2,int(math.sqrt(n))+1):\n if n%i==0:\n p=i\n break\nc=0\nif(p):\n if p%2==1:\n \n print(1+(n-p)//2)\n else:\n print(n//2)\nelse:\n print(1)\n "}, {"source_code": "n=int(input())\nif(n%2==0):\n print(n//2)\nelse:\n lp=n\n i=2\n while(i*i<=n):\n if(n%i==0):\n lp=i\n break\n i+=1\n print((n-lp)//2+1)\n\n\n'''\n//////////////// ////// /////// // /////// // // //\n//// // /// /// /// /// // /// /// //// //\n//// //// /// /// /// /// // ///////// //// ///////\n//// ///// /// /// /// /// // /// /// //// // //\n////////////// /////////// /////////// ////// /// /// // // // //\n'''\n\n"}, {"source_code": "n = int(input())\nans = 0\nif n % 2 == 1:\n i = 2\n cnt = -1\n while i * i <= n:\n if n % i == 0:\n cnt = i\n break\n i += 1\n if cnt == -1:\n cnt = n\n n -= cnt\n ans += 1\nprint(ans + n//2)"}, {"source_code": "def minprime(n):\n if n %2==0:\n return 2\n if n%3==0:\n return 3\n max_t=10**5+10\n for k in range(6,max_t,6):\n if n%(k-1)==0:\n return k-1\n if n%(k+1)==0:\n return k+1\n return n\n\nn=int(input())\nprint(1+(n-minprime(n))//2)"}, {"source_code": "from math import sqrt; from itertools import count, islice\ndef isPrime(n):\n return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))\ndef primes_method4(n):\n out = list()\n out.append(2)\n for num in range(3, n+1, 2):\n if all(num % i != 0 for i in range(2, int(num**.5 ) + 1)):\n out.append(num)\n return out\ndef div(n,a):\n \n if n==0:\n return 0\n else:\n if n%2==0:\n return n//2\n else:\n if isPrime(n):\n return 1\n else: \n for i in a:\n if n%i==0:\n break\n return 1+ div(n-i,a)\n \nif __name__==\"__main__\":\n n=int(input())\n arr=primes_method4(100000)\n anws=div(n,arr)\n print(anws)"}, {"source_code": "def isPrime(n) :\n if (n <= 1) :\n return False\n if (n <= 3) :\n return True\n if (n % 2 == 0 or n % 3 == 0) :\n return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\n\ndef f(n):\n l = []\n for i in range(2,n+1):\n if n%i==0:\n return(i)\nn = int(input())\nif (isPrime(n)):\n print(1)\nelse:\n s, tp = 0, 0\n while True:\n k = n-tp\n n = n-tp\n if n%2==0:\n s+=(n//2)\n break\n if k==0:\n break\n else:\n tp = f(k)\n s+=1\n print(s)"}, {"source_code": "from math import *\na=int(input())\nfor i in range(2,floor(sqrt(a))+1):\n if(a%i==0):\n print(int((a-i)/2)+1)\n exit()\nprint(1)\n"}, {"source_code": "while True:\n\ttry:\n\t\tprime = []\n\t\tmark = [0]*(10**6+2)\n\t\t\t\n\t\tdef seive():\n\t\t\tprime.append(2)\n\t\t\tN = 10**6\n\t\t\tfor i in range(3, N+1, 2):\n\t\t\t\tif not mark[i]:\n\t\t\t\t\tprime.append(i)\n\t\t\t\t\tif i*i <= N:\n\t\t\t\t\t\tj = i*i\n\t\t\t\t\t\twhile j <= N:\n\t\t\t\t\t\t\tmark[j] = 1\n\t\t\t\t\t\t\tj +=(i*2)\n\t\tdef solution(n):\n\t\t\t#seive()\n\t\t\tif n&1:\n\t\t\t\td = n\n\t\t\t\ti = 3\n\t\t\t\twhile i*i <= n:\n\t\t\t\t\tif n%i == 0:\n\t\t\t\t\t\td = i\n\t\t\t\t\t\tbreak\n\t\t\t\t\ti += 1\n\t\t\t\tn -= d\n\t\t\t\tprint(1+(n//2))\n\t\t\telse:print(n//2)\n\t\t\t\t\n\t\t\t\n\t\tif __name__ == \"__main__\":\n\t\t\tn = int(input())\n\t\t\tsolution(n)\n\texcept EOFError:\n\t\tbreak"}], "negative_code": [{"source_code": "import math\nx=int(input())\nif x%2==0:print(x//2)\nelif x%3==0:print(x//3)\nelse:\n\tfor i in range(5,x+1,6):\n\t\tif x%i==0:exit(print(x//i))\n\t\telif x%(i+2)==0:exit(print(x//(i+2)))"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 10.05.2020\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\nfrom math import log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[1] \ndef sort2(l):return sorted(l, key=getKey,reverse=True)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))\n\ndef ceil(x,y):\n if x%y==0:\n return x//y\n else:\n return x//y+1\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\ndef main():\n \n\n #for _ in range(ii()):\n \n \n n=ii()\n if n%2==0:\n print(n//2)\n else:\n \n for i in range(2,int(n**0.5)+1):\n\n if n%i==0 and isPrime(i): \n print(n//i)\n return\n\n print(1)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "import math\nN=int(input())\nif N%2==0:\n print(N//2)\nelse:\n p=N\n for i in range(2,int(math.sqrt(N))):\n if N%i==0:\n p=i\n print((N-p)//2 + 1)"}, {"source_code": "n=input()\n#find smallest prime divisor of n\nfound = False\np=2\nwhile (p*p<=n):\n if (n%p==0):\n found = True\n break\n p+=1\nif found:\n print n/p\nelse:\n print 1\n"}, {"source_code": "from math import floor, sqrt\ntry: \n long\nexcept NameError: \n long = int\n \ndef fac(n):\n step = lambda x: 1 + (x<<2) - ((x>>1)<<1)\n maxq = long(floor(sqrt(n)))\n d = 1\n q = n % 2 == 0 and 2 or 3 \n while q <= maxq and n % q != 0:\n q = step(d)\n d += 1\n return q <= maxq and [q] + fac(n//q) or [n]\nn=int(input())\nx=fac(n)[0]\nprint(n//x)"}, {"source_code": "import math\ndef prime(a):\n\tfor i in range(2,int(math.sqrt(a))):\n\t\tif a%i==0:\n\t\t\treturn 0\n\treturn 1\n\nn = int(input());\nif prime(n):\n\tprint(\"1\")\nelif n%2==0:\n\tprint(n//2)\nelse:\n\tfor i in range(2,n):\n\t\tif n%i==0 and prime(i):\n\t\t\td =i;\n\t\t\tbreak;\n\tprint(1+((n-d)//2))\n"}, {"source_code": "n = int(input())\n\nfor i in range(2,n+1):\n div = n/i\n if div%1==0:\n print(int(div))\n break"}, {"source_code": "from math import floor, sqrt\ntry: \n long\nexcept NameError: \n long = int\n \ndef fac(n):\n step = lambda x: 1 + (x<<2) - ((x>>1)<<1)\n maxq = long(floor(sqrt(n)))\n d = 1\n q = n % 2 == 0 and 2 or 3 \n while q <= maxq and n % q != 0:\n q = step(d)\n d += 1\n return q <= maxq and [q] + fac(n//q) or [n]\nn=int(input())\nx=fac(n)[0]\nprint(n//x)"}, {"source_code": "n = int(input())\n\nif (n%2 == 0): print (int(n/2))\nelse:\n bank=0;\n for i in range (3,n):\n if n%i==0: bank = i; break\n print ((n-bank)//2 +1)\n"}, {"source_code": "n = int(input())\nimport math\nlimit = math.sqrt(n)\nlimit = math.ceil(limit)\nlimit = int(limit)\nfor i in range(2, limit+2):\n if n%i == 0:\n if (n-i)%2 == 0:\n print(str(1+(n-i)//i))\n else:\n print(str(n//i))\n exit()\n \nprint(str(1))"}, {"source_code": "import math\n\nn = int(input())\nprint(int(n/2))\n"}, {"source_code": "n = input()\n\nisprime = [1 for i in range(int(n**0.5)+2)]\nisprime[0] = isprime[1] = 0\n\ndef sieve():\n global isprime\n\n n = len(isprime)\n\n touched = [0 for i in range(n)]\n\n for i in range(2, int(n**0.5)+2):\n\n if not touched[i]:\n touched[i] = 1\n isprime[i] = 1\n\n for j in range(2*i, n, i):\n\n if not touched[j]:\n touched[j] = 1\n isprime[j] = 0\n\n\nsieve()\n\n\ndef SPF(n):\n\n for i in range(2, int(n**0.5)+2):\n if n%i == 0 and isprime[i]:\n return i\n\n return n\n\n\n \nprint n/SPF(n)\n"}, {"source_code": "N = int(input())\nM = 10 ** 5 + 5\npr = [True] * M\npr[0], pr[1] = False, False\nfor i in range(2, M):\n if pr[i]:\n for j in range(i * 2, M, i):\n pr[j] = False\n\nprime = list(filter(lambda x: pr[x], range(M)))\n\n\ndef calc(n, k):\n if n == 0:\n return k\n elif n % 2 == 0:\n return n // 2 + k\n else:\n for i in prime:\n if n % i == 0:\n n -= i\n return calc(n, k + 1)\n\n\nprint(calc(N, 0))"}, {"source_code": "from math import sqrt\nn = int(input())\nanswer = 0\nd = {}\ncur = n\nfor i in range(2, int(sqrt(n)) + 2):\n while cur % i == 0:\n cur //= i\n t = d.get(i, 0) + 1\n d[i] = t\nif d == {}:\n print(1)\nelse:\n for k in d:\n answer += d[k]\n print(answer)"}, {"source_code": "import math\n\ntemp=0\nflag=0\nn = int(input())\n\nif n%2==0:\n\tprint(int(n/2))\nelse:\n\tfor i in range(2,int(math.sqrt(n)+1)+1):\n\t\tif n%i==0:\n\t\t\ttemp = i;\n\t\t\tflag=1\n\n\tif flag==0:\n\t\ttemp = n\n\n\tans = (n-temp)/2\n\tans = ans+1\n\tprint(int(ans))\n"}, {"source_code": "from math import sqrt\nn = int(input())\n\nfor i in range(2, int(sqrt(n))+1):\n if n%i == 0:\n print(n//i)\n break\nelse:\n print(1)\n"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(int(n / 2))\n raise SystemExit\n\nif n % 3 == 0:\n print(int((n-3) / 2 + 1))\n raise SystemExit\n\nif n % 5 == 0:\n print(int((n-5) / 2 + 1))\n raise SystemExit\n\nprint(1)\n\n"}, {"source_code": "import math\n\nn = int(input())\nprint(int(n/2))\n"}, {"source_code": "n=int(input())\nimport math\ndef is_prime(n):\n count=0\n for i in range(2, int(math.sqrt(n)+1)):\n if n%i==0:\n count+=1\n if count==0:\n return True\n else:\n return False\ndef cf(n):\n if n%2==0:\n print(int(n/2))\n else:\n for i in range(2,int(math.sqrt(n)+1)):\n if n%i==0 and is_prime(i)==True:\n print (int(((n- i)/2)+1))\n break\n elif is_prime(n)==True:\n break\ncf(n)"}, {"source_code": "#!/usr/bin/env python3\nfrom typing import Dict, List, Tuple\n\n\ndef input_lst() -> List[int]:\n return [int(x) for x in input().split()]\n\ndef print_out(res: List[int]):\n print(' '.join([str(x) for x in res]))\n\n# def eratosthenes(n): # n - \u0447\u0438\u0441\u043b\u043e, \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430\n#\n\ndef main():\n\n n, = (int(x) for x in input().split())\n sieve = list(range(int(n**0.5) + 1))\n\n sieve[1] = 0 # \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u0443\n for i in sieve:\n if i > 1:\n if n/i == n//i:\n print(n//i)\n return\n for j in range(i + i, len(sieve), i):\n sieve[j] = 0\n\n print(1)\n\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\nt = n\nfor i in range(2,min(n,100000)):\n\tif n%i == 0:\n\t\tt=i\n\t\tbreak\nprint(n/t)"}, {"source_code": "from math import *\na=int(input())\nfor i in range(2,floor(sqrt(a))+1):\n if(a%i==0):\n print(int(a/i))\n exit()\nprint(1)\n"}, {"source_code": "def prime_factors(n):\n i = 2\n f = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n f.append(i)\n if n > 1:\n f.append(n)\n return f\n\n\ndef solve(n):\n ans = 0\n f = prime_factors(n)\n fs = set(f)\n for i in fs:\n ans += 2 ** (f.count(i) - 1)\n return ans\n\n\ndef main():\n n = int(input())\n print(solve(n))\n\n\nmain()\n"}, {"source_code": "n = int(input())\n\nfor i in range(2, n + 1):\n if n % i == 0:\n print(n // i)\n exit()\n if i * i > n * 2:\n break\n\nprint(1 if n > 0 else 0)\n"}, {"source_code": "n=int(input())\nimport math\ndef is_prime(n):\n count=0\n for i in range(2, int(math.sqrt(n)+1)):\n if n%i==0:\n count+=1\n if count==0:\n return True\n else:\n return False\ndef cf(n):\n if n%2==0:\n print(int(n/2))\n else:\n for i in range(2,int(math.sqrt(n)+1)):\n if n%i==0 and is_prime(i)==True:\n print (int(((n- i)/2)+1))\n break\n else:\n print(\"1\")\ncf(n)"}, {"source_code": "pr=[1]*300001\npr[0],pr[1]=0,0\nprimes=[]\nfor i in range(2,300001):\n if(pr[i]==1):\n primes.append(i)\n for j in range(i*i,100001,i):\n pr[j]=0\ndef prime(n):\n for i in range(2,int(n**0.5)+2):\n if(n%i==0):\n return False\n return True\ndef dope(n):\n if(n<2 or n>1e10):\n return 1//0\n if(prime(n)):\n return 1\n for i in primes:\n if n%i==0:\n # print(n,i)\n return n//i\n return 1//0\nprint(dope(int(input())))\n"}, {"source_code": "import sys\nLI=lambda:list(map(int, sys.stdin.readline().split()))\nMI=lambda:map(int, sys.stdin.readline().split())\nSI=lambda:sys.stdin.readline().strip('\\n')\nII=lambda:int(sys.stdin.readline())\n\nn=II()\nok=[1]*(100001)\nans=0\nfor i in range(2, 100001):\n if ok[i]:\n for j in range(i+i, 100001, i):\n ok[j]=0\n while n%i==0:\n n//=i\n ans+=1\nprint(ans)\n"}, {"source_code": "import math\nx=int(input())\nif x%2==0:print(x//2)\nelif x%3==0:print(x//3)\nelse:\n\tfor i in range(5,x+1,6):\n\t\tif x%i==0:exit(print(x//i))\n\t\telif x%(i+2)==0:exit(print(x//(i+2)))"}, {"source_code": "import sys\nLI=lambda:list(map(int, sys.stdin.readline().split()))\nMI=lambda:map(int, sys.stdin.readline().split())\nSI=lambda:sys.stdin.readline().strip('\\n')\nII=lambda:int(sys.stdin.readline())\n\nn=II()\nok=[1]*(100001)\nfor i in range(2, 100001):\n if ok[i]:\n for j in range(i+i, 100001, i):\n ok[j]=0\n if n%i==0:\n break\nprint(1+(n-i)//2)\n"}, {"source_code": "n=int(input())\nfor i in range(2,int(n**0.5)+1):\n if n%i==0: # n=15, i=3\n print(1+((n-i)//2))\n print(i)\n exit()\nprint(1)"}, {"source_code": "m = int(input())\nn = int(m)\n\nif(m%2 == 0):\n print(m//2)\nelse:\n i=2\n while (i*i<n):\n while (n%i==0):\n n /= i\n i += 1\n print( ((n-m) // 2) + 1)"}, {"source_code": "n = int(input())\nk = int(n ** 0.5) + 1\nprime = [True] * (k + 1)\nprime[0] = prime[1] = False\nfor i in range(2, k + 1):\n if prime[i]:\n if i * i <= k:\n for j in range(i * i, k + 1, i):\n prime[j] = False\n\nf = False\nfor i in range(2, k + 1):\n if n % i == 0:\n f = True\n break\nif not f:\n print(1)\n exit(0)\nans = 0\nfor i in range(2, k + 1):\n if n % i == 0 and prime[i]:\n ans = n // i\n break\nprint(ans)\n"}, {"source_code": "n = int(input())\nfrom math import sqrt\n\nif (n%2 == 0): print (int(n/2))\nelse:\n bank=0;\n for i in range (3,int(sqrt(n))):\n if n%i==0: bank = i; break\n if bank==0: bank=n\n print ((n-bank)//2 +1)\n"}, {"source_code": "n = int(input())\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n print(n // i)\n exit(0)\n i += 1\n\nprint(1)\n"}, {"source_code": "n = int(input())\nsubs = 0\nwhile n!=0:\n if n%2 == 0:\n subs+=n//2\n break\n \n for i in range( 3, int(n**0.5), 2):\n if n%i == 0:\n n = n-i\n subs=1\n break\n \n if n>0 and n%2 == 0:\n subs+=n//2\n break\n elif n>0:\n subs+=1\n break\nprint(subs)"}, {"source_code": "\nn = int(input())\nd=1\n#answer when smallest prime divides n\nfor i in range(2,n):\n if n%i == 0:\n d=i\n break\n \nprint((n/d))\n \n"}, {"source_code": "from math import sqrt\nn = int(input())\n\nfor i in range(2, int(sqrt(n))+1):\n if n%i == 0:\n print(n//i)\n break\nelse:\n print(1)\n"}, {"source_code": "from sys import stdin\n\ndef main():\n\tn = int(input())\n\tif n % 2 == 0:\n\t\td = 2\n\telse:\n\t\td = 3\n\t\twhile n % d != 0:\n\t\t\td += 2\n\t\n\tprint(n // d)\n\n\treturn\n\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[51]:\n\n\nn=int(input())\n\n\n# In[52]:\n\n\nsub=0\n\ndef smallprime(x):\n for i in range(2,x+1):\n if x % i==0:\n return i\n\n\ndef dsub(x):\n global sub\n if x==0:\n print(sub)\n return \n if x%2==0:\n sub=sub+x/2\n print(sub)\n return\n else:\n p=smallprime(x)\n sub=sub+1\n dsub(x-p)\n \n\n\n# In[53]:\n\n\ndsub(n)\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "n = int(input())\nfor i in range(2,n+1):\n\tif n % i == 0:\n\t\tbreak\n\n\nprint(n//i)"}, {"source_code": "import math\ndef prime(a):\n\tfor i in range(2,int(math.sqrt(a))):\n\t\tif a%i==0:\n\t\t\treturn 0\n\treturn 1\n\nn = int(input());\nif prime(n):\n\tprint(\"1\")\nelif n%2==0:\n\tprint(n//2)\nelse:\n\tfor i in range(2,n):\n\t\tif n%i==0 and prime(i):\n\t\t\td =i;\n\t\t\tbreak;\n\tprint(1+((n-d)//2))\n"}, {"source_code": "import math\np=0\nn=int(input())\n\nfor i in range(2,int(math.sqrt(n))+1):\n if n%i==0:\n p=i\nc=0\nif(p):\n if p%2==1:\n \n print(1+(n-p)//2)\n else:\n print(n//2)\nelse:\n print(1)\n "}, {"source_code": "#E54_B\n\nnum = int(input())\n\nans = 1\n\nfor i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n ans = i\n\nif ans == 1:\n print(1)\nelse:\n if ans == 2:\n print(num // 2)\n else:\n print(1 + (num - ans) // 2)\n"}, {"source_code": "n = int(input())\nimport math\nlimit = math.sqrt(n)\nlimit = int(limit)\nfor i in range(2, limit+1):\n if n%i == 0:\n print(str(n//i))\n exit()\n \nprint(str(1))"}, {"source_code": "def eratosthenes(n): # n - \u0447\u0438\u0441\u043b\u043e, \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430\n sieve = list(range(n + 1))\n #print(sieve)\n sieve[1] = 0 # \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u0443\n prime = []\n for i in sieve:\n if i > 0:\n prime.append(i)\n for j in range(i * i, len(sieve), i):\n sieve[j] = 0\n #return sieve\n return prime\n\n\nn = int(input())\ns = 0\np = eratosthenes(1000000)\n\nif len(p) == 0:\n print(1)\nelif n % 2 == 0:\n print(n // 2)\nelse:\n for i in p:\n if n % i == 0:\n print(1 + (n - i) // 2)\n break\n"}, {"source_code": "n=int(input())\nans=0\ni=2\nwhile(n>1):\n\tj=n\n\twhile(i*i<=n):\n\t\tif n%i==0:\n\t\t\tans+=n//i\n\t\t\tn=n%i\n\t\t\t# print(\"DD\",n,i)\n\t\t\tbreak\n\t\ti+=1\n\tif j==n:\n\t\tbreak\n\nprint(max(ans,1))\n"}, {"source_code": "def smallestDivisor(n): \n \n # if divisible by 2 \n if (n % 2 == 0): \n return 2; \n \n # iterate from 3 to sqrt(n) \n i = 3; \n while(i * i <= n): \n if (n % i == 0): \n return i; \n i += 2; \n \n return n;\n\n\nn=int(input())\nk=n\nprint(int(n/smallestDivisor(k)))"}, {"source_code": "n = int(input())\n\nif not n % 2:\n print(n // 2)\nelse:\n def primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n\n return a\n\n sieve = primes_sieve(1000100)\n\n for i in range(len(sieve)):\n if sieve[i]:\n if not n % i:\n print((n - i) // 2 + 1)\n exit()"}, {"source_code": "n = int(input())\nimport math\nlimit = math.sqrt(n)\nlimit = int(limit)\nfor i in range(2, limit+1):\n if n%i == 0:\n print(str(n//i))\n exit()\n \nprint(str(1))"}, {"source_code": "import math\n\nn = int(input())\nd = n\nfor i in range(2, round(math.sqrt(n))+1):\n if n%i == 0:\n d = i\n break\nif d == n: \n print(1)\nelse:\n print(int(n/d))"}, {"source_code": "n = int(input())\nif (n%2==0):\n print(n//2)\nelif (n%3==0):\n print(n//3)\nelif (n%5==0):\n print(n//5)\nelif (n%7==0):\n print(n//7)\nelse:\n print(1)\n"}, {"source_code": "n = int(input())\nfrom math import sqrt\n\nif (n%2 == 0): print (int(n/2))\nelse:\n bank=0;\n for i in range (3,int(sqrt(n))):\n if n%i==0: bank = i; break\n if bank==0: bank=n\n print ((n-bank)//2 +1)\n"}, {"source_code": "import math\nn = int(input())\n\nfor i in range(2,int(math.sqrt(n)) + 1):\n if n%i == 0:\n print(i)\n print(int((n - i)/2 + 1))\n break\n"}, {"source_code": "n = input()\n\nisprime = [1 for i in range(int(n**0.5)+2)]\nisprime[0] = isprime[1] = 0\n\ndef sieve():\n global isprime\n\n n = len(isprime)\n\n touched = [0 for i in range(n)]\n\n for i in range(2, int(n**0.5)+2):\n\n if not touched[i]:\n touched[i] = 1\n isprime[i] = 1\n\n for j in range(2*i, n, i):\n\n if not touched[j]:\n touched[j] = 1\n isprime[j] = 0\n\n\nsieve()\n\n\ndef SPF(n):\n\n for i in range(2, int(n**0.5)+2):\n if n%i == 0 and isprime[i]:\n return i\n\n return n\n\n\n \nprint n/SPF(n)\n"}, {"source_code": "n = int(input())\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n print(n // i)\n exit(0)\n i += 1\n\nprint(1)\n"}, {"source_code": "n=int(input())\n\nimport math\n\ndef fac(n):\n xn=math.ceil(math.sqrt(n))\n\n for i in range(2,xn+2):\n if n%i==0:\n return n//i\n\n else:\n return 1\n \ncount=0\nwhile n!=1:\n n=fac(n)\n count+=1\n\nprint(count)\n"}, {"source_code": "n = int( input() )\nd = n\nfor i in range( 2, 100001 ):\n div = n // i\n if i * div == n:\n d = i\n break\n\nprint( n // d )\n"}, {"source_code": "def primes_method4(n):\n out = list()\n out.append(2)\n for num in range(3, n+1, 2):\n if all(num % i != 0 for i in range(2, int(num**.5 ) + 1)):\n out.append(num)\n return out\ndef div(n,a):\n \n if n==0:\n return 0\n else:\n if n%2==0:\n return n//2\n else: \n for i in a:\n if n%i==0:\n break\n return 1+ div(n-i,a)\n \nif __name__==\"__main__\":\n n=int(input())\n arr=primes_method4(100000)\n anws=div(n,arr)\n print(anws)"}, {"source_code": "def factor(n):\n ans = []\n d = 2\n while d * d <= n:\n if n % d == 0:\n ans.append(d)\n n //= d\n else:\n d += 1\n if n > 1:\n ans.append(n)\n return ans\n\n\nn = int(input())\nprint(len(factor(n)))\n"}, {"source_code": "n = int(input())\n\nif not n % 2:\n print(n // 2)\nelse:\n def primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n\n return a\n\n sieve = primes_sieve(1000100)\n\n for i in range(len(sieve)):\n if sieve[i]:\n if not n % i:\n print((n - i) // 2 + 1)\n exit()"}, {"source_code": "def first_factor(n):\n for num in range(2,int(n**0.5) + 1):\n if n % num == 0:\n return num\n return n\n \na = int(input())\nb = first_factor(a)\nprint(a//b)"}, {"source_code": "def eratosthenes(n): # n - \u0447\u0438\u0441\u043b\u043e, \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430\n sieve = list(range(n + 1))\n #print(sieve)\n sieve[1] = 0 # \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u0443\n prime = []\n for i in sieve:\n if i > 0:\n prime.append(i)\n for j in range(i * i, len(sieve), i):\n sieve[j] = 0\n #return sieve\n return prime\n\n\nn = int(input())\ns = 0\np = eratosthenes(100000)\n\nif len(p) == 0:\n print(1)\nelif n % 2 == 0:\n print(n // 2)\nelse:\n for i in p:\n if n % i == 0:\n print(1 + (n - i) // 2)\n break\n"}, {"source_code": "\nn = int(input())\nc=True\ncheck=0\nif n==0:\n c=False\nwhile c:\n for i in range(2,int(n/2)+1):\n if n%i == 0:\n if i==2:\n c=False\n check += n/2\n else:\n n-=i\n check+=1\n break\n else:\n check+=1\n break\n\nprint(check)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Dec 16 14:02:19 2018\n\n@author: umang\n\"\"\"\nnums = [i for i in range(10**5+1)]\nprimes = []\n\ndef sieve(nums, primes):\n i = 2\n while i < 10**5+1:\n if nums[i] != -1:\n primes.append(i)\n n = 1\n temp = n*i\n while temp < 10**5+1:\n nums[temp] = -1\n n += 1\n temp = n*i\n i += 1\n return primes\n\nprimes = sieve(nums, primes)\n\ndef find_smallest_div(n, primes):\n for i in primes:\n if n%i == 0:\n return i\n\ndef func(n):\n count = 0\n if n == 0:\n return count\n else:\n '''while(n != 0):\n d = find_smallest_div(n)\n n -= d\n count += 1\n return count'''\n d = find_smallest_div(n, primes)\n return n//d\n \nn = int(input())\n\nprint(func(n))"}, {"source_code": "n = int(input())\n\nif not n % 2:\n print(n // 2)\nelse:\n def primes_sieve(limit):\n a = [True] * limit\n a[0] = a[1] = False\n\n for (i, isprime) in enumerate(a):\n if isprime:\n for n in range(i*i, limit, i):\n a[n] = False\n\n return a\n\n sieve = primes_sieve(100000)\n\n for i in range(len(sieve)):\n if sieve[i]:\n if not n % i:\n print((n - i) // 2 + 1)"}, {"source_code": "import sys\nimport math\nn = int(input())\ncount = 0\n\nif n % 2 is 0:\n print(n//2)\n sys.exit()\n\nprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]\n\nif n in primes:\n print(1)\n sys.exit()\ntmp = True\nfor i in range(2, int(math.sqrt(n)) + 1):\n if n % i is 0:\n tmp = False\n break\nif tmp:\n print(1)\n sys.exit()\n\n\nwhile True:\n if n % 2 is 0:\n print(count + n//2)\n sys.exit()\n\n if n is 0:\n break\n #find prime\n temp = False\n for p in primes:\n if n % p is 0:\n count = count + 1\n n = n - p\n temp = True\n break\n if temp:\n continue\n\n for i in range(primes[-1] + 1, 100000 + 1):\n tt = True\n for j in range(2, int(math.sqrt(i)) + 1):\n if i % j is 0:\n tt = False\n break\n if tt:\n primes.append(i)\n if n % i is 0:\n count = count + 1\n n = n - i\n break\nprint(count)\n\n\n"}, {"source_code": "def prime_factors(n):\n i = 2\n f = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n f.append(i)\n if n > 1:\n f.append(n)\n return f\n\n\ndef solve(n):\n f = prime_factors(n)\n return n // f[0]\n\n\ndef main():\n n = int(input())\n print(solve(n))\n\n\nmain()\n"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(int(n / 2))\n raise SystemExit\n\nif n % 3 == 0 or n % 5 == 0:\n print(int((n+1) / 2))\n raise SystemExit\n\nprint(1)\n\n"}, {"source_code": "import math\nn = int(input())\ndef smallest_prime_factor(n):\n for i in range(2, int(math.sqrt(n)), 1):\n if n%i == 0:\n return i\n return n\ncount = 0\nif n%2!=0:\n n -= smallest_prime_factor(n)\n count += 1\nprint(count + n//2)\n"}, {"source_code": "n = int(input())\n\n# smallest prime divisor of an odd number is some odd number\n# smallest prime divisor of an even number is 2, and it stays even when we subtract\n# smallest divisor of a number must be prime\nif n % 2 == 0: print(int(n/2))\nelse:\n d = n\n for i in range(3, int(n ** 1/2 + 1)):\n if n % i == 0: d = i\n print(int((n - d)/2))\n "}, {"source_code": "#!/usr/bin/python3\nfrom collections import Counter\n\ndef readint():\n return int(input())\n\n\ndef readline():\n return [int(c) for c in input().split()]\n\n\ndef divisors(n):\n i = 2\n res = Counter()\n while i * i <= n:\n if n % i == 0:\n while n % i == 0:\n n //= i\n res[i] += 1\n i += 1\n if n != 1:\n res[n] = 1\n\n return res\n \n\n\ndef main():\n n = int(input())\n d = divisors(n)\n _min = min(d.keys())\n prod = 1\n for k, v in d.items():\n if k == _min and v > 1:\n prod *= k * (v - 1)\n elif k != _min:\n prod *= k * v\n \n print(prod)\n \n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\n@author: zzf\n@file: main.py\n@time: 2018/11/13\n\"\"\"\n\nn = int(input())\nres = 0\n\ndef isPrime(k):\n if k == 2:\n return True\n else:\n for i in range(2, k):\n if k%i == 0:\n return False\n return True\n\nif n%2 == 0:\n res = n/2\nelse:\n for i in range(2, n+1):\n if n % i == 0:\n if isPrime(i):\n res = n/i\nprint(res)\n"}, {"source_code": "def prime_factors(n):\n i = 2\n factors = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.append(i)\n if n > 1:\n factors.append(n)\n return factors\n \nprint(len(prime_factors(int(input()))))"}, {"source_code": "import math\n\ndef isPrime(n):\n if (n <= 1):\n return False\n if (n <= 3):\n return True\n if (n % 2 == 0 or n % 3 == 0):\n return False\n i = 5\n while (i * i <= n):\n if (n % i == 0 or n % (i + 2) == 0):\n return False\n i = i + 6\n\n return True\n\nn = int(input())\n\nresult = 0\n\ndef go(k):\n global result\n if k==0:\n return\n if k % 2 == 0:\n result = k // 2\n return\n else:\n if (isPrime(k)): result+=1; go(0)\n for i in range(3, int(math.sqrt(n))+1):\n if isPrime(i) and k%i==0:\n result+=1\n go(k-i)\n\n\ngo(n)\nprint(result)"}, {"source_code": "n = int(input())\nresponse = 0\n\nwhile n % 2 != 0:\n x = n\n\n i = 2\n while i * i <= n:\n if n % i == 0:\n x = i\n break\n \n n -= x\n response += 1\n i += 1\n\nresponse += n / 2\nprint(int(response))"}, {"source_code": "n=input()\n#find smallest prime divisor of n\nfound = False\np=2\nwhile (p*p<=n):\n if (n%p==0):\n found = True\n break\n p+=1\nif found:\n print n/p\nelse:\n print 1\n"}, {"source_code": "n=int(input())\nimport math\ndef is_prime(n):\n count=0\n for i in range(2, int(math.sqrt(n)+1)):\n if n%i==0:\n count+=1\n if count==0:\n return True\n else:\n return False\ndef cf(n):\n if n%2==0:\n print(int(n/2))\n else:\n for i in range(2,int(math.sqrt(n)+1)):\n if n%i==0 and is_prime(i)==True:\n print (int(((n- i)/2)+1))\n break\n else:\n print(\"1\")\ncf(n)"}, {"source_code": "import math\nimport bisect\nimport itertools\nimport sys\nmod=10**9 +7\n'''fact=[1]*1001\nifact=[1]*1001\nfor i in range(1,1001):\n fact[i]=((fact[i-1])*i)%mod\n ifact[i]=((ifact[i-1])*pow(i,mod-2,mod))%mod\ndef ncr(n,r):\n return (((fact[n]*ifact[n-r])%mod)*ifact[r])%mod\ndef npr(n,r):\n return (((fact[n]*ifact[n-r])%mod))\n '''\n\n\ndef mindiff(a):\n b=a[:]\n b.sort()\n m=10000000000\n for i in range(len(b)-1):\n if b[i+1]-b[i]<m:\n m=b[i+1]-b[i]\n return m\n \ndef lcm(a,b):\n return a*b//math.gcd(a,b)\n\n \ndef merge(a,b):\n i=0;j=0\n c=0\n ans=[]\n while i<len(a) and j<len(b):\n if a[i]<b[j]:\n ans.append(a[i])\n i+=1\n else:\n ans.append(b[j])\n c+=len(a)-i\n j+=1\n ans+=a[i:]\n ans+=b[j:]\n return ans,c\ndef mergesort(a):\n if len(a)==1:\n return a,0\n mid=len(a)//2 \n left,left_inversion=mergesort(a[:mid])\n right,right_inversion=mergesort(a[mid:])\n m,c=merge(left,right)\n c+=(left_inversion+right_inversion)\n return m,c\n \ndef is_prime(num):\n if num == 2: return True\n if num == 3: return True\n if num%2 == 0: return False\n if num%3 == 0: return False\n t = 5\n a = 2\n while t <= int(math.sqrt(num)):\n if num%t == 0: return False\n t += a\n a = 6 - a\n return True\n \n \ndef ceil(a,b):\n if a%b==0:\n return a//b\n else:\n return (a//b + 1)\n\ndef binsearch(arr,b,low,high):\n if low==high:\n return low\n if arr[math.ceil((low+high)/2)]<b:\n return binsearch(arr,b,low,math.ceil((low+high)/2) -1 )\n else:\n return binsearch(arr,b,math.ceil((low+high)/2),high)\ndef ncr1(n,r):\n s=1\n for i in range(min(n-r,r)):\n s*=(n-i)\n s%=mod\n s*=pow(i+1,mod-2,mod)\n s%=mod\n return s\n \ndef calc(n,m,r):\n s=0\n for i in range(0,r+1,2):\n s+=ncr1(n,i)*ncr1(m,i)\n s%=mod\n return s \n \n \n\n#/////////////////////////////////////////////////////////////////////////////////////////////////\nn=int(input())\ncount=0\ni=2\nwhile(i<=int(n**0.5)):\n if n%i==0:\n exit(print(n//i))\n i+=1\n \n \nprint(1) \n "}, {"source_code": "def prime_factors(n):\n i = 2\n f = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n f.append(i)\n if n > 1:\n f.append(n)\n return f\n\n\ndef solve(n):\n ans = 0\n f = prime_factors(n)\n fs = set(f)\n for i in fs:\n ans += 2 ** (f.count(i) - 1)\n return ans\n\n\ndef main():\n n = int(input())\n print(solve(n))\n\n\nmain()\n"}, {"source_code": "while True:\n\ttry:\n\t\tprime = []\n\t\tmark = [0]*(10**6+2)\n\t\t\t\n\t\tdef seive():\n\t\t\tprime.append(2)\n\t\t\tN = 10**6\n\t\t\tfor i in range(3, N+1, 2):\n\t\t\t\tif not mark[i]:\n\t\t\t\t\tprime.append(i)\n\t\t\t\t\tif i*i <= N:\n\t\t\t\t\t\tj = i*i\n\t\t\t\t\t\twhile j <= N:\n\t\t\t\t\t\t\tmark[j] = 1\n\t\t\t\t\t\t\tj +=(i*2)\n\t\tdef solution(n):\n\t\t\tseive()\n\t\t\tstep = 0\n\t\t\tt = 0\n\t\t\tif True:\n\t\t\t\tfor i in range(len(prime)):\n\t\t\t\t\tif n%prime[i] == 0:\n\t\t\t\t\t\tt = prime[i]\n\t\t\t\t\t\tbreak\n\t\t\tstep = n//t\t\n\t\t\tprint(step)\n\t\t\t\n\t\tif __name__ == \"__main__\":\n\t\t\tn = int(input())\n\t\t\tsolution(n)\n\texcept EOFError:\n\t\tbreak"}, {"source_code": "n=int(input())\narr=[]\ncnt=0\nif n%2==1:\n for i in range(1,int(n**0.5)+1):\n if n%i==0:\n cnt+=1\n n-=i\n break\nprint(cnt+n//2)"}, {"source_code": "n=int(input())\nans=0\nwhile n!=0 :\n t=0\n for i in range (2,int(pow(n,0.5))+1) :\n if n%i==0 :\n t=1\n n=n//i\n ans+=1\n break \n if t!=1 :\n ans+=1\n break\nprint(ans)"}, {"source_code": "import math\n\ndef isPrime(n):\n if (n <= 1):\n return False\n if (n <= 3):\n return True\n if (n % 2 == 0 or n % 3 == 0):\n return False\n i = 5\n while (i * i <= n):\n if (n % i == 0 or n % (i + 2) == 0):\n return False\n i = i + 6\n\n return True\n\nn = int(input())\n\nresult = 0\n\ndef go(k):\n global result\n if k==0:\n return\n if k % 2 == 0:\n result = k // 2\n return\n else:\n if (isPrime(k)): result+=1; go(0)\n for i in range(3, int(math.sqrt(n))+1):\n if isPrime(i) and k%i==0:\n result+=1\n go(k-i)\n\n\ngo(n)\nprint(result)"}, {"source_code": "n = int(input())\n\ndef PrimeList(limit):\n Plist = []\n for i in range(2,limit+1):\n divcheck = False\n for j in Plist:\n if j*j > i:\n break\n if i%j == 0:\n divcheck = True\n break\n if divcheck == False:\n Plist.append(i)\n return Plist\n\nL = PrimeList(10**5)\ncount = 0\nprimecheck = True\nfor p in L:\n if p*p > n:\n break\n if n%p == 0:\n smallest = p\n primecheck = False\n\nif primecheck == True:\n print(1)\nelse:\n print(1+int((n-smallest)/2))\n"}, {"source_code": "n = int(input())\n\nfor i in range(2,n+1):\n div = n/i\n if div%1==0:\n print(int(div))\n break"}, {"source_code": "def mind(n):\n d = 2\n while d * d <= n:\n if n % d == 0:\n return d\n d += 1\n return n\n \nn = int(input())\n\nif n == 0:\n print(0)\n \nelse:\n print(n // mind(n))"}, {"source_code": "def is_prime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\n\nn=int(raw_input())\n\nif n%2==0:\n print(n/2)\nelif is_prime(n):\n print(1)\nelse:\n x=1\n while x<=10:\n temp=n**(1.0/x)\n if is_prime(temp):\n print(n/(temp))\n break\n x+=1"}, {"source_code": "n = int(input())\nk = int(n ** 0.5) + 1\nf = False\nfor i in range(2, k + 1):\n if n % i == 0:\n f = True\n break\nif not f:\n print(1)\n exit(0)\nans = 0\nfor i in range(2, k + 1):\n if n % i == 0:\n ans = n // i\n break\nprint(ans)\n"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 10.05.2020\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\nfrom math import log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[1] \ndef sort2(l):return sorted(l, key=getKey,reverse=True)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))\n\ndef ceil(x,y):\n if x%y==0:\n return x//y\n else:\n return x//y+1\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\ndef main():\n \n\n #for _ in range(ii()):\n \n \n n=ii()\n if n%2==0:\n print(n//2)\n else:\n \n for i in range(2,int(n**0.5)+1):\n\n if n%i==0 and isPrime(i): \n print(n//i)\n return\n\n print(inf*inf*inf*inf)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "def mind(n):\n d = 2\n while d * d <= n:\n if n % d == 0:\n return d\n d += 1\n return n\n \nn = int(input())\n\nif n == 0:\n print(0)\n \nelse:\n print(n // mind(n))"}, {"source_code": "import sys\n# import heapq, collections\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\ndef solve(n):\n if n == 0:\n return 0\n i = 2\n while (i * i) <= n:\n if n % i:\n i += 1\n else:\n return n//i\n return 1\n \n\ndef main():\n n = I()\n\n\n print(solve(n))\n\nmain()\n"}, {"source_code": "n = int(input())\nif (n%2==0):\n print(n//2)\nelif (n%3==0):\n print(n//3)\nelif (n%5==0):\n print(n//5)\nelif (n%7==0):\n print(n//7)\nelse:\n print(1)\n"}, {"source_code": "while True:\n\ttry:\n\t\tprime = []\n\t\tmark = [0]*(10**6+2)\n\t\t\t\n\t\tdef seive():\n\t\t\tprime.append(2)\n\t\t\tN = 10**6\n\t\t\tfor i in range(3, N+1, 2):\n\t\t\t\tif not mark[i]:\n\t\t\t\t\tprime.append(i)\n\t\t\t\t\tif i*i <= N:\n\t\t\t\t\t\tj = i*i\n\t\t\t\t\t\twhile j <= N:\n\t\t\t\t\t\t\tmark[j] = 1\n\t\t\t\t\t\t\tj +=(i*2)\n\t\tdef solution(n):\n\t\t\tseive()\n\t\t\tstep = 0\n\t\t\tt = 0\n\t\t\tif True:\n\t\t\t\tfor i in range(len(prime)):\n\t\t\t\t\tif n%prime[i] == 0:\n\t\t\t\t\t\tt = prime[i]\n\t\t\t\t\t\tbreak\n\t\t\tstep = n//t\t\n\t\t\tprint(step)\n\t\t\t\n\t\tif __name__ == \"__main__\":\n\t\t\tn = int(input())\n\t\t\tsolution(n)\n\texcept EOFError:\n\t\tbreak"}, {"source_code": "import math\n\nn=int(input())\nk=0\nif n%2!=0:\n for i in range(2,int(math.sqrt(n))+1):\n if n%i==0:\n n-=i\n k+=1\n else:\n n=0\n k+=1\nk+=n//2\nprint(k)\n"}, {"source_code": "from math import ceil\nn=int(input());r=0\nfor i in range(2,ceil(n**.5)+1):\n if n%i==0:\n r=i\n break\nelse:\n print(1)\n exit()\nprint(n//r)\n"}, {"source_code": "import sys\n# import heapq, collections\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\ndef solve(n):\n if n == 0:\n return 0\n i = 2\n while (i * i) <= n:\n if n % i:\n i += 1\n else:\n return n//i\n return 1\n \n\ndef main():\n n = I()\n\n\n print(solve(n))\n\nmain()\n"}, {"source_code": "import math\n\ndef smallestDividor(n):\n if(n%2 == 0):\n return 2\n for j in range(3,int(math.sqrt(n)),2):\n if(n%j == 0):\n return j\n return n\n\nn = int(input())\ncompt = 0\nwhile(n != 0):\n d = smallestDividor(n)\n if(d%2 != 0 ):\n n = n - d\n else:\n break\n compt+=1\ncompt+= n//2\nprint(compt)"}, {"source_code": "\nn = int(input())\nd=n\n\nfor i in range(2,n):\n if n%i == 0:\n d=i\n break\n \nprint(int((n/d)))\n \n"}, {"source_code": "n = int(input())\nans = 0\nif n % 2 == 1:\n i = 2\n cnt = -1\n while i * i <= n:\n if n % i == 0:\n cnt = i\n break\n i += 1\n if cnt == -1:\n cnt = i\n n -= cnt\n ans += 1\nprint(ans + n//2)"}, {"source_code": "#!/usr/bin/env python3\nfrom typing import Dict, List, Tuple\n\n\ndef input_lst() -> List[int]:\n return [int(x) for x in input().split()]\n\ndef print_out(res: List[int]):\n print(' '.join([str(x) for x in res]))\n\n# def eratosthenes(n): # n - \u0447\u0438\u0441\u043b\u043e, \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430\n#\n\ndef main():\n\n n, = (int(x) for x in input().split())\n sieve = list(range(int(n**0.5) + 1))\n\n sieve[1] = 0 # \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u0443\n for i in sieve:\n if i > 1:\n if n/i == n//i:\n print(n//i)\n return\n for j in range(i + i, len(sieve), i):\n sieve[j] = 0\n\n print(1)\n\n\n\n\nif __name__ == '__main__':\n main()\n"}], "src_uid": "a1e80ddd97026835a84f91bac8eb21e6"} {"source_code": "x, y = (int(w) for w in input().split())\n\nax, ay = 1, 0\nbx, by = 0, 1\n\nanext = (x>y)\nch = 'AB' if x>y else 'BA'\n\nans = []\n\nwhile(ax+ay+bx+by < x+y):\n if(anext):\n n=0\n for sh in range(59,-1,-1):\n t = n + (1<<sh)\n #print('Aiming for', x/y)\n if y * (bx + t*ax) < x * (by + t*ay):\n n = t\n #print('Include', sh)\n if not n:\n print('Impossible')\n exit(0)\n ans.append(n)\n bx = bx + n*ax\n by = by + n*ay\n else:\n n=0\n for sh in range(59,-1,-1):\n t = n + (1<<sh)\n #print('Beaming for', x/y)\n #print(y, ' * (', ax, ' + ', t, '*', bx, ') > ', x, ' * (', ay, ' * ', t, '*', by, ')')\n if y * (ax + t*bx) > x * (ay + t*by):\n #print(y * (ax + t*bx), '>', x * (ay * t*by))\n n = t\n #print('Include', sh)\n if not n:\n print('Impossible')\n exit(0)\n ans.append(n)\n ax = ax + n*bx\n ay = ay + n*by\n anext = not anext\n\nfor i,a in enumerate(ans):\n print('%d%s' % (a, ch[i&1]), end='')\nprint()\n", "positive_code": [{"source_code": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b, a%b)\n \ndef solve(x, y, a, b):\n ans=\"\"\n while not x==1 or not y==1:\n if x < y:\n x,y,a,b=y,x,b,a\n ans+=str((x-1)//y)+a\n x = x - (x-1)//y * y\n print (ans)\n \nx,y=map(int, input().split())\nif gcd(x,y)>1:\n print (\"Impossible\")\nelse:\n solve(x,y, \"A\", \"B\")"}, {"source_code": "def egcd(a, b):\n Q = []\n while b:\n q, r = divmod(a, b)\n Q.append(q)\n a, b = b, r\n return a, Q\n\n\ndef cards(x, y):\n d, Q = egcd(x, y)\n # log(x, y, d, Q)\n if d != 1:\n return 'Impossible'\n Q[-1] -= 1\n b = False\n l = []\n for q in Q:\n if q:\n l.append(str(q))\n l.append('AB'[b])\n b = not b\n s = ''.join(l)\n # verify(x, y, s)\n return s\n\n\ndef verify(x, y, s):\n log(s)\n AB = [(1, 0), (0, 1)]\n for k, c in tokens(s):\n log(AB, k, c)\n c_ = not c\n AB[c_] = AB[c_][0] + k*AB[c][0], AB[c_][1] + k*AB[c][1]\n r = AB[0][0] + AB[1][0], AB[0][1] + AB[1][1]\n log(AB, r)\n assert r == (x, y)\n\n\ndef tokens(s):\n fa = s.find('A')\n fb = s.find('B')\n assert fa >= 0 or fb >= 0\n b = (fa < 0 or (fb >= 0 and fa > fb))\n i = 0\n while i < len(s):\n i_ = s.find('AB'[b], i)\n assert i_ >= 0\n yield (int(s[i:i_]), b)\n i = i_ + 1\n b = not b\n\n\ndef main():\n x, y = map(int, input().split())\n print(cards(x, y))\n\n\nimport sys\nimport time\nimport traceback\nfrom contextlib import contextmanager\nfrom io import StringIO\n\n\ndef log(*args, **kwargs):\n print(*args, **kwargs, file=sys.stderr)\n\n\n@contextmanager\ndef patchio(i):\n try:\n sys.stdin = StringIO(i)\n sys.stdout = StringIO()\n yield sys.stdout\n finally:\n sys.stdin = sys.__stdin__\n sys.stdout = sys.__stdout__\n\n\ndef do_test(k, test):\n try:\n log(f\"TEST {k}\")\n i, o = test\n with patchio(i) as r:\n t0 = time.time()\n main()\n t1 = time.time()\n if r.getvalue() == o:\n log(f\"OK ({int((t1-t0)*1000000)/1000:0.3f} ms)\\n\")\n else:\n log(f\"Expected:\\n{o}Got:\\n{r.getvalue()}\")\n except Exception:\n traceback.print_exc()\n log()\n\n\ndef test(ts):\n for k in ts or range(len(tests)):\n do_test(k, tests[k])\n\n\ntests = [(\"\"\"\\\n1 4\n\"\"\", \"\"\"\\\n3B\n\"\"\"), (\"\"\"\\\n2 2\n\"\"\", \"\"\"\\\nImpossible\n\"\"\"), (\"\"\"\\\n3 2\n\"\"\", \"\"\"\\\n1A1B\n\"\"\")]\n\n\nif __name__ == '__main__':\n from argparse import ArgumentParser\n parser = ArgumentParser()\n parser.add_argument('--test', '-t', type=int, nargs='*')\n args = parser.parse_args()\n main() if args.test is None else test(args.test)\n\n"}, {"source_code": "ans = []\n\ndef gcd(x, y):\n while(True):\n if x == y:\n if x == 1:\n return True;\n else:\n return False;\n elif x > y:\n t = (x-1) // y;\n ans.append(-t)\n x -= t * y\n else:\n t = (y-1) // x\n ans.append(t)\n y -= t * x\n\nx, y = map(long, raw_input().split())\nif gcd(x, y) == False:\n print 'Impossible'\nelse:\n s = ''\n for t in ans:\n if t < 0:\n s += str(-t) + 'A'\n else:\n s += str(t) + 'B'\n print s"}, {"source_code": "from operator import gt, lt\n\nx, y = (int(w) for w in input().split())\n\nif x>y:\n ch = 'AB'\n op1, op2 = lt, gt\n ax, ay, bx, by = 1, 0, 0, 1\nelse:\n ch = 'BA'\n op1, op2 = gt, lt\n ax, ay, bx, by = 0, 1, 1, 0\n\nans = []\n\nwhile(ax+ay+bx+by < x+y):\n n=0\n for sh in range(59,-1,-1):\n t = n + (1<<sh)\n if op1(y * (bx + t*ax), x * (by + t*ay)): n = t\n if not n:\n print('Impossible')\n exit(0)\n ans.append(n)\n ax, bx = bx + n*ax, ax # Increment and swap\n ay, by = by + n*ay, ay # Increment and swap\n op1, op2 = op2, op1\n\nfor i,a in enumerate(ans): print('%d%s' % (a, ch[i&1]), end='')\nprint()\n"}, {"source_code": "def get_cnt(a1, a2, b1, b2, x, y, dd):\n ll = 1\n rr = 1000000000000000000000\n while ll < rr:\n mult = (ll + rr + 1) / 2\n c1 = a1+b1*mult\n c2 = a2+b2*mult\n if (c1 * y - x * c2) * dd > 0:\n ll = mult\n else:\n rr = mult - 1\n \n return ll\n\nx, y = [int(x) for x in raw_input().split()]\na1 = 1\na2 = 0\nb1 = 0\nb2 = 1\n\nres = \"\"\nwhile a1+b1+a2+b2 < x+y:\n c1 = a1+b1\n c2 = a2+b2\n if c1 * y > x * c2:\n mult = get_cnt(a1, a2, b1, b2, x, y, 1)\n a1 = a1+b1*mult\n a2 = a2+b2*mult\n res = res + str(mult)\n res = res + 'B'\n else:\n mult = get_cnt(b1, b2, a1, a2, x, y, -1)\n b1 = b1+a1*mult\n b2 = b2+a2*mult\n res = res + str(mult) \n res = res + 'A'\n\nif a1 + b1 == x and a2 + b2 == y:\n print res\nelse:\n print \"Impossible\"\n"}, {"source_code": "from fractions import gcd\nimport sys\n\na, b = (int(x) for x in raw_input().split())\n\nif gcd(a, b) > 1:\n print \"Impossible\"\n sys.exit(0)\n\n# (a, b) goes to (a-b, b) or (a, b-a)\nret = []\nwhile a > 1 or b > 1:\n assert a != b\n if a > b:\n if a%b == 0:\n ret.append((a/b-1, \"A\"))\n else:\n ret.append((a/b, \"A\"))\n a %= b\n else:\n if b%a == 0:\n ret.append((b/a-1, \"B\"))\n else:\n ret.append((b/a, \"B\"))\n b %= a\nans = \"\"\nfor x in ret:\n ans += \"{}{}\".format(x[0], x[1])\nprint ans\n"}, {"source_code": "a,b=map(int,raw_input().split())\ndef ggcd(a,b):\n\tif b==0:\n\t\treturn [1,0,a]\n\telse:\n\t\tx,y,d=ggcd(b,a%b)\n\t\tx,y=y,x-a/b*y\n\t\treturn [x,y,d]\ny,x,d=ggcd(a,b)\nif d!=1:\n\tprint \"Impossible\"\n\texit()\nans=\"\"\ndef gao(a,b,c,d):\n\tif a==1 and b==0 and c==0 and d==1: return\n\tglobal ans\n\tif a>c:\n\t\tt=b/d\n\t\tans=\"%dB\"%(t)+ans\n\t\ta-=c*t\n\t\tb-=d*t\n\t\tgao(a,b,c,d)\n\telse:\n\t\tt=c/a\n\t\tans=\"%dA\"%(t)+ans\n\t\tc-=a*t\n\t\td-=b*t\n\t\tgao(a,b,c,d)\nx+=a\nt=(x-1)/a\nx-=t*a\ny+=t*b\nassert 0<x and x<=a and 0<y and y<=b\ngao(x,b-y,a-x,y)\nprint ans"}, {"source_code": "def gcd(a,b):\n\tif b==0:\n\t\treturn a\n\tif a//b!=0:\n\t\tl.append(a//b)\n\treturn gcd(b,a%b)\n\nl=[]\nt=[\"A\",\"B\"]\nx,y=map(int,input().split())\ng=gcd(x,y)\n\nl[-1]-=1\nif g==1:\n\tif x>y:\n\t\tstart=0\n\telse:\n\t\tstart=1\n\ts=''\n\tfor v in range(len(l)):\n\t\ts+=str(l[v])+t[(start+v)%2]\n\tprint(s)\n\n\nelse:\n\tprint('Impossible')\n"}, {"source_code": "from math import gcd\ndef help():\n\tans = []\n\ta,b = map(int,input().split(\" \"))\n\tif(gcd(a,b)>1):\n\t\tprint(\"Impossible\")\n\t\treturn\n\twhile a!=1 or b!=1:\n\t\tif(a==1):\n\t\t\tans.append(str(b-1)+\"B\")\n\t\t\tbreak\n\t\telif(b==1):\n\t\t\tans.append(str(a-1)+\"A\")\n\t\t\tbreak\n\t\telif(a>b):\n\t\t\tans.append(str(a//b)+\"A\")\n\t\t\ta = a%b\n\t\telif(b>a):\n\t\t\tans.append(str(b//a)+\"B\")\n\t\t\tb = b%a\n\tprint(*ans[::],sep=\"\")\nhelp()"}, {"source_code": "x, y = map(int,input().split(\" \"))\n\nres = []\nc = 'A'\nwhile x * y > 1:\n k = min(x // y, x - 1)\n if k > 0:\n res.append('{}{}'.format(k, c))\n x, y = y, x - k*y\n c = 'A' if c == 'B' else 'B'\n\nif x == 0 or y == 0:\n print('Impossible')\nelse:\n print(''.join(res))"}, {"source_code": "def gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\nclass fraction:\n n, m = 0, 0\n\n def __init__(self, n, m):\n d = int(gcd(n, m))\n self.n = int(n//d)\n self.m = int(m//d)\n def add(self, tmp):\n return fraction(self.n * tmp.m, self.m * tmp.n)\n\n def compareTo(self ,tmp):\n a = self.n * tmp.m\n b = self.m * tmp.n\n\n if a > b:\n return 1\n elif a < b:\n return -1\n\n return 0\n\n def sternBrocotAdd(self, tmp):\n return fraction(self.n + tmp.n, self.m + tmp.m);\n\ndef run(left, right, result):\n\n a = left.n\n b = left.m\n p = right.n\n q = right.m\n n = result.n\n m = result.m\n\n mid = left.sternBrocotAdd(right)\n if mid.compareTo(result) == 0:\n return\n ch = 'Z'\n x = 0\n if mid.compareTo(result) <= 0:\n x = int((b * n - a * m) // (p * m - q * n))\n left = fraction(a + p * x, b + q * x)\n ch = 'A'\n if left.compareTo(result) == 0:\n x -= 1\n else:\n x = int((p * m - q * n) // (b * n - a * m))\n right = fraction(a * x + p, b * x + q)\n ch = 'B'\n if right.compareTo(result) == 0:\n x -= 1\n\n\n s = str.format(\"%d%c\"%(x, ch))\n print(s, end=\"\")\n if left.compareTo(result) == 0 or right.compareTo(result) == 0:\n return\n run(left, right, result)\n\n\np, q = map(int, input().split())\n\nd = gcd(p, q)\nif d == 1:\n result = fraction(p, q)\n right = fraction(1, 0)\n left = fraction(0, 1)\n run(left, right, result)\nelse:\n print('Impossible')\n"}, {"source_code": "def solve(a, b):\n r = []\n while a and b and a+b > 2:\n q = min((a//b + b//a), max(a, b)-1)\n r.append(str(q))\n if a > b:\n r.append('A')\n a -= b*q\n else:\n r.append('B')\n b -= a*q\n if a != 1 or b != 1:\n return 'Impossible'\n return ''.join(r)\n\ndef main():\n a, b = map(int, input().split())\n print(solve(a, b))\n\nmain()"}, {"source_code": "def gcd(x, y):\n\tif y == 0:\n\t\treturn x\n\treturn gcd(y, x % y)\nx, y = map(int, input().split())\nif gcd(x, y) != 1:\n\tprint('Impossible')\n\texit()\na = []\nwhile y != 1:\n\ta += [x // y]\n\tx %= y\n\tx, y = y, x\na += [x-1]\ns = 'A'\nfor x in a:\n\tif x > 0:\n\t\tprint(x, end=s)\n\ts = 'AB'.replace(s, '') \n"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nx, y = map(int, raw_input().split())\nans = [] \nwhile x != y:\n if x < y:\n if y % x == 0:\n ans.append(str(y / x - 1) + \"B\")\n y = x\n else:\n ans.append(str(y / x) + \"B\")\n y %= x\n else:\n if x % y == 0:\n ans.append(str(x / y - 1) + \"A\")\n x = y\n else:\n ans.append(str(x / y) + \"A\")\n x %= y\n\nif x != 1:\n print \"Impossible\"\nelse:\n print \"\".join(ans)\n"}, {"source_code": "import fractions\ndef solve(x, y):\n if fractions.gcd(x, y) > 1: return 'Impossible'\n turn = x > y\n if not turn: x, y = y, x\n ans = []\n while x != 0 and y != 0:\n ans.append((x//y, 'A' if turn else 'B'))\n x, y = y, x%y\n turn = not turn\n ans[-1] = (ans[-1][0]-1, ans[-1][1])\n return ''.join(str(n) + l for n, l in ans)\n\nx, y = [int(x) for x in input().split()]\nprint(solve(x, y))\n"}, {"source_code": "def gcd(m, n):\n if m < n:\n m, n = n, m\n r = m % n\n while r:\n m, n = n, r\n r = m % n\n return n\n\ndef search(x, y):\n global ans\n while True:\n if x == 1:\n ans = ans + (\"\" if y == 1 else str(y - 1) + 'B')\n return\n if y == 1:\n ans = ans + (\"\" if x == 1 else str(x - 1) + 'A')\n return\n if x < y:\n ans = ans + str(y // x) + 'B'\n x, y = x, y % x\n else:\n ans = ans + str(x // y) + 'A'\n x, y = x % y, y\n\na, b = [ int(i) for i in input().split() ]\n\nif gcd(a, b) != 1:\n print(\"Impossible\")\nelse:\n ans = \"\"\n search(a, b)\n print(ans)"}, {"source_code": "x, y = map(int, raw_input().split())\n\ndef gcd(x,y):\n\tif y > x:\n\t\tx = x^y; y = x^y; x = x^y\n\tif x%y == 0:\n\t\treturn y\n\treturn gcd(y, x%y)\n\nch = ['A', 'B']\ns = []\nb = 0\nif x < y:\n\tb = 1\n\tx = x^y; y = x^y; x = x^y\nif gcd(x,y) > 1:\n\tprint 'Impossible'\nelse:\n\twhile y!=0:\n\t\tl = x//y\n\t\ts.append(l)\n\t\tr = x%y\n\t\tx = y\n\t\ty = r\n\ts[-1]-=1\n\tst = ''\n\tfor el in s:\t\n\t\tst += '{}{}'.format(el, ch[b])\n\t\tb = 1-b\n\tprint st\n\n\n\n\n\n\n\n\n"}, {"source_code": "def gcd(m, n):\n if m < n:\n m, n = n, m\n r = m % n\n while r:\n m, n = n, r\n r = m % n\n return n\n\n\ndef search(x, y):\n while True:\n if x == 1:\n ans.extend( [] if y == 1 else (str(y - 1) + 'B') )\n return\n if y == 1:\n ans.extend( [] if x == 1 else (str(x - 1) + 'A') )\n return\n if x < y:\n ans.append(str(y // x) + 'B')\n x, y = x, y % x\n else:\n ans.append(str(x // y) + 'A')\n x, y = x % y, y\n\na, b = [ int(i) for i in input().split() ]\n\nif gcd(a, b) != 1:\n print(\"Impossible\")\nelse:\n ans = []\n search(a, b)\n \n i, length = 0, len(ans)\n print(''.join(ans))"}, {"source_code": "def f(x,y):\n m=x\n n=y\n s=''\n while(m!=0 and n!=0):\n if(m>=n):\n r=m//n\n m=m%n\n c='A'\n else:\n r=n//m\n n=n%m\n c='B'\n if (m==0 or n==0):\n if(r>1):\n s=s+str(r-1)+c\n else:\n s=s+str(r)+c\n if(m+n>1):\n return 'Impossible'\n\n else:\n return s\n\ninp=input()\n[x,y]=[int(t) for t in inp.split(' ')]\nprint(f(x,y))\n"}, {"source_code": "def gcd(x , y):\n if(x > y):x , y = y , x\n if(x == 0):return y\n return gcd(y % x , x)\nA , B = map(int , input().split())\ndef solve(X , Y):\n if(X > Y):\n if(Y == 1):\n print(str(X - 1) + \"A\" , end = \"\")\n return;\n else:\n print(str(X // Y) + \"A\" , end = \"\")\n solve(X % Y , Y)\n else:\n if(X == 1):\n print(str(Y - 1) + \"B\" , end = \"\")\n return;\n else:\n print(str(Y // X) + \"B\" , end = \"\")\n solve(X , Y % X)\nif(gcd(A , B) == 1):\n solve(A , B)\nelse:\n print(\"Impossible\")\n"}, {"source_code": "def gcd(a,b):\n\n if b==0:\n\n return a\n\n else:\n\n return gcd(b, a%b)\n\n \n\ndef solve(x, y, a, b):\n\n ans=\"\"\n\n while not x==1 or not y==1:\n\n if x < y:\n\n x,y,a,b=y,x,b,a\n\n ans+=str((x-1)//y)+a\n\n x = x - (x-1)//y * y\n\n print (ans)\n\n \n\nx,y=map(int, input().split())\n\nif gcd(x,y)>1:\n\n print (\"Impossible\")\n\nelse:\n\n solve(x,y, \"A\", \"B\")\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "a = input().split()\ntarget = (int(a[0]), int(a[1]))\nx=(1, 0)\ny=(0, 1)\ntoadd=\"A\"\nans = \"\"\ndef less(a, b):\n return a[0]*b[1]<b[0]*a[1]\nwhile True:\n z = (x[0]+y[0], x[1]+y[1])\n if z[0] > target[0] or z[1] > target[1]:\n print(\"Impossible\")\n exit()\n if z==target:\n print(ans)\n exit()\n if less(z, target): # z replaces y\n low = 1\n high = int(1e18)\n while (high > low):\n guess = (low+high+1)//2\n if less((x[0]*guess+y[0], x[1]*guess+y[1]), target):\n low = guess\n else:\n high = guess - 1\n ans += str(low)\n ans += \"A\"\n y = (y[0] + low * x[0], y[1] + low * x[1])\n elif less(target, z):\n low = 1\n high = int(1e18)\n while (high > low):\n guess = (low+high+1)//2\n if less(target,(x[0]+guess*y[0], x[1]+guess*y[1])):\n low = guess\n else:\n high = guess - 1\n ans += str(low)\n ans += \"B\"\n x = (x[0] + low * y[0], x[1] + low * y[1])\n else:\n print(\"Impossible\")\n exit()\n "}, {"source_code": "import sys\nread = lambda: list(map(int, sys.stdin.readline().split()))\nx, y = read()\n\nres = []\nc = 'A'\nwhile x * y > 1:\n k = min(x // y, x - 1)\n if k > 0:\n res.append('{}{}'.format(k, c))\n x, y = y, x - k*y\n c = 'A' if c == 'B' else 'B'\n\nif x == 0 or y == 0:\n print('Impossible')\nelse:\n print(''.join(res))\n\n"}, {"source_code": "#!/usr/bin/python\n\nimport sys\n\ndef vec(a, b):\n\treturn a[0] * b[1] - a[1] * b[0]\n\n\nx, y = map(int, raw_input().split())\n\na = [1, 0]\nb = [0, 1]\n\nv = [x, y]\nans = \"\"\n\nwhile a[0] + b[0] <= x and a[1] + b[1] <= y:\n\tq = vec(a, v)\n\tw = abs(vec(b, v))\n\tif q < w:\n\t\tc = (w - 1) // q\n\t\tb = [b[0] + c * a[0], b[1] + c * a[1]]\n\t\tans += str(c) + 'A'\n\telif q > w:\n\t\tc = (q - 1) // w\n\t\ta = [a[0] + c * b[0], a[1] + c * b[1]]\n\t\tans += str(c) + 'B'\n\telse:\n\t\tprint ans if a[0] + b[0] == x and a[1] + b[1] == y else \"Impossible\"\n\t\tsys.exit(0)\n\nprint ans if a[0] + b[0] == x and a[1] + b[1] == y else \"Impossible\""}, {"source_code": "inp = map(int, raw_input().split())\nx = inp[0]\ny = inp[1]\n#print x + y\n\naa = 1\nao = 0\nba = 0\nbo = 1\nres = \"\"\n\ndef Cross(x1, y1, x2, y2):\n return x1 * y2 - y1 * x2 \n\nMIL = 10\nMIL = 1000000000000000000\n\ndef Iter():\n global aa\n global ba\n global ao\n global bo\n global res\n #print \"xy\",x,y\n ca = aa + ba\n co = ao + bo\n #print aa,ao,ba,bo\n if Cross(ca, co, x, y) <= 0:\n kl = 1\n kp = MIL\n faj = 1\n while kl <= kp:\n aktc = (kl + kp) / 2\n #print aktc\n ca = ba + aa * aktc\n co = bo + ao * aktc\n if Cross(ca, co, x, y) < 0:\n #print ca,co,x,y\n faj = aktc\n kl = aktc + 1\n else:\n kp = aktc - 1\n res += str(faj)\n res += 'A'\n ba += aa * faj\n bo += ao * faj\n else:\n kl = 1\n kp = MIL\n faj = 1\n while kl <= kp:\n aktc = (kl + kp) / 2\n #print aktc\n ca = aa + ba * aktc\n co = ao + bo * aktc\n if Cross(ca, co, x, y) > 0:\n faj = aktc\n kl = aktc + 1\n else:\n kp = aktc - 1\n res += str(faj)\n res += 'B'\n aa += ba * faj\n ao += bo * faj\n \n \nwhile aa + ba < x or ao + bo < y:\n Iter()\n #print aa,ao,ba,bo,res\n \nif aa + ba == x and ao + bo == y:\n print res\nelse:\n print \"Impossible\""}, {"source_code": "def gcd(a, b):\n return gcd(b, a % b) if b else a\n\nwhile 1:\n try:\n x, y = map(int, input().split())\n except:\n break\n\n if gcd(x, y) != 1:\n print('Impossible')\n continue\n\n res=''\n while x > 0 and y > 0:\n if x > y:\n cnt, give = x // y, 'A'\n x %= y\n else:\n cnt, give = y // x, 'B'\n y %= x\n if x == 0 or y == 0:\n cnt -= 1\n res += str(cnt) + give\n\n print(res)\n"}, {"source_code": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b, a%b)\n \ndef solve(x, y, a, b):\n ans=\"\"\n while not x==1 or not y==1:\n if x < y:\n x,y,a,b=y,x,b,a\n ans+=str((x-1)//y)+a\n x = x - (x-1)//y * y\n print (ans)\n \nx,y=map(int, input().split())\nif gcd(x,y)>1:\n print (\"Impossible\")\nelse:\n solve(x,y, \"A\", \"B\")"}, {"source_code": "def gcd(x, y):\n while y > 0:\n x, y = y, x % y\n return x\nx, y = map(int, input().split())\nif gcd(x, y) != 1:\n print (\"Impossible\")\n exit(0)\nres = \"\"\nwhile x > 0 and y > 0:\n if y > x:\n if x == 1:\n y -= 1\n res = res + str(y // x) + \"B\"\n y = y % x\n else:\n if y == 1:\n x -= 1\n res = res + str(x // y) + \"A\"\n x = x % y\nprint(res)\n"}, {"source_code": "import fractions\nimport sys\n\na, b = map(int, raw_input().split())\nresult = ''\nwhile True:\n\tif fractions.gcd(a, b) != 1:\n\t\tprint 'Impossible'\n\t\tsys.exit(0)\n\tif (a, b) == (1, 1):\n\t\tbreak\n\tif a == 1:\n\t\tresult += str(b - a) + 'B'\n\t\tbreak\n\telif b == 1:\n\t\tresult += str(a - b) + 'A'\n\t\tbreak\n\t\n\tc, d = a, b\n\tif a > b:\n\t\tr = a/b\n\t\ta, b = a - b*r, b\n\telse:\n\t\tr = b/a\n\t\ta, b = a, b - a*r\n\tresult += str(r) + ('B' if c < d else 'A')\n\t\nprint result"}], "negative_code": [{"source_code": "def gcd(m, n):\n if m < n:\n m, n = n, m\n r = m % n\n while r:\n m, n = n, r\n r = m % n\n return n\n\n\ndef search(x, y):\n while True:\n if x == 1:\n ans.extend( [] if y == 1 else (str(y - 1) + 'B') )\n return\n if y == 1:\n ans.extend( [] if x == 1 else (str(x - 1) + 'B') )\n return\n if x < y:\n ans.append(str(y // x) + 'B')\n x, y = x, y % x\n else:\n ans.append(str(x // y) + 'A')\n x, y = x % y, y\n\na, b = [ int(i) for i in input().split() ]\n\nif gcd(a, b) != 1:\n print(\"Impossible\")\nelse:\n ans = []\n search(a, b)\n \n i, length = 0, len(ans)\n print(''.join(ans))"}, {"source_code": "def gcd(x , y):\n if(x > y):x , y = y , x\n if(x == 0):return y\n return gcd(y % x , x)\nA , B = map(int , input().split())\ndef solve(X , Y):\n if(X > Y):\n if(Y == 1):\n print(str(X - 1) + \"A\" , end = \"\")\n return;\n else:\n print(str(X // Y) + \"A\" , end = \"\")\n solve(X % Y , Y)\n else:\n if(X == 1):\n print(str(Y - 1) + \"B\" , end = \"\")\n return;\n else:\n print(str(Y // X) + \"B\" , end = \"\")\n solve(Y % X , X)\nif(gcd(A , B) == 1):\n solve(A , B)\nelse:\n print(\"Impossible\")\n"}, {"source_code": "import fractions\nimport sys\n\na, b = map(int, raw_input().split())\nresult = ''\nwhile True:\n\tif fractions.gcd(a, b) != 1:\n\t\tprint 'Impossible'\n\t\tsys.exit(0)\n\tc, d = a, b\n\tif a > b:\n\t\tr = a/b\n\t\ta, b = a - b*r, b\n\telse:\n\t\tr = b/a\n\t\ta, b = a, b - a*r\n\tresult += str(r) + ('B' if c < d else 'A')\n\t\n\tif (a, b) == (1, 1):\n\t\tbreak\n\tif a == 1:\n\t\tresult += str(b - a) + 'B'\n\t\tbreak\n\telif b == 1:\n\t\tresult += str(a - b) + 'A'\n\t\tbreak\n\t\nprint result"}, {"source_code": "import fractions\n\na, b = map(int, raw_input().split())\n\nresult = ''\nwhile True:\n\tr = fractions.gcd(a, b)\n\tif a < b:\n\t\tresult += str((b - r) / a) + 'B'\n\t\tb = r\n\telif a > b:\n\t\tresult += str((a - r) / b) + 'A'\n\t\ta = r\n\telse:\n\t\tprint 'Impossible'\n\t\tbreak\n\tif (a, b) == (1, 1):\n\t\tbreak\nprint result"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nx, y = map(int, raw_input().split())\nans = [] \nwhile x != y:\n if x < y:\n if y % x == 0:\n ans.append(str(y / x - 1) + \"B\")\n y = x\n else:\n ans.append(str(y / x) + \"B\")\n y %= x\n else:\n if x % y == 0:\n ans.append(str(x / y - 1) + \"A\")\n x = y\n else:\n ans.append(str(x / y) + \"A\")\n x %= y\n if x != 1:\n print \"Impossible\"\n else:\n print \"\".join(ans)\n\n"}, {"source_code": "x, y = map(int, raw_input().split())\n\nch = ['A', 'B']\ns = []\nb = 0\nif x < y:\n\tb = 1\n\tx = x^y; y = x^y; x = x^y\nif y!=1 and x%y == 0:\n\tprint 'Impossible'\nelse:\n\twhile y!=0:\n\t\tl = x//y\n\t\ts.append(l)\n\t\tr = x%y\n\t\tx = y\n\t\ty = r\n\ts[-1]-=1\n\tst = ''\n\tfor el in s:\t\n\t\tst += '{}{}'.format(el, ch[b])\n\t\tb = 1-b\n\tprint st\n\n\n\n\n\n\n\n\n"}, {"source_code": "from math import gcd\ndef help():\n\tans = []\n\ta,b = map(int,input().split(\" \"))\n\tif(gcd(a,b)>1):\n\t\tprint(\"Impossible\")\n\t\treturn\n\twhile a!=1 or b!=1:\n\t\tif(a==1):\n\t\t\tans.append(str(b-1)+\"B\")\n\t\t\tbreak\n\t\telif(b==1):\n\t\t\tans.append(str(a-1)+\"A\")\n\t\t\tbreak\n\t\telif(a>b):\n\t\t\tans.append(str(a//b)+\"A\")\n\t\t\ta = a%b\n\t\telif(b>a):\n\t\t\tans.append(str(b//a)+\"B\")\n\t\t\tb = b%a\n\tprint(*ans[::-1],sep=\"\")\nhelp()"}], "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671"} {"source_code": "# for t in range(int(input())):\n# s = input()\n# i, j = 0, 0\n# cnt = 0\n# ans = float('inf')\n# dic = {}\n# while j < len(s):\n# if len(dic) < 3:\n# dic[s[j]] = dic.get(s[j], 0) + 1\n# # print(j)\n# # print(dic)\n# while len(dic) == 3:\n# ans = min(ans, j - i + 1)\n# dic[s[i]] -= 1\n# if dic[s[i]] == 0:\n# del dic[s[i]]\n# i += 1\n#\n# j += 1\n# print((0, ans)[ans < float('inf')])\n\n\n# for t in range(int(input())):\n# n = int(input())\n# s = list(map(int, input().split()))\n# dp = [1] * n\n# for i in range(n):\n# k = 2\n# while (i + 1) * k <= n:\n# j = (i + 1) * k\n# if s[i] < s[j - 1]:\n# dp[j - 1] = max(dp[j - 1], dp[i] + 1)\n# k += 1\n# print(max(dp))\n\n\n# for T in range(int(input())):\n# t = input()\n# z, o = 0, 0\n# for ch in t:\n# z = z + 1 if ch == '0' else z\n# o = o + 1 if ch == '1' else o\n# if z > 0 and o > 0:\n# print('01' * len(t))\n# elif o > 0 and not z:\n# print('1' * len(t))\n# else:\n# print('0' * len(t))\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# a.sort()\n# ans = []\n# while a:\n# ans.append(str(a.pop(len(a) // 2)))\n# print(' '.join(ans))\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# cnt = 0\n# p = set()\n# l, r = 0, sum(a)\n# left, right = {}, {}\n# for i in a:\n# right[i] = right.get(i, 0) + 1\n# for i in range(n - 1):\n# l += a[i]\n# left[a[i]] = left.get(a[i], 0) + 1\n# r -= a[i]\n# right[a[i]] = right.get(a[i], 0) - 1\n# if not right[a[i]]:\n# del right[a[i]]\n# j = n - i - 1\n# if (2 + i) * (i + 1) // 2 == l and (j + 1) * j // 2 == r:\n# if len(left) == i + 1 and len(right) == j:\n# cnt += 1\n# p.add((i + 1, n - i - 1))\n# print(cnt)\n# if cnt:\n# for el in p:\n# print(*el)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# G = []\n# taken = [False] * n\n# girl = -1\n# for i in range(n):\n# g = list(map(int, input().split()))\n# k = g[0]\n# single = True\n# for j in range(1, k + 1):\n# if not taken[g[j] - 1]:\n# taken[g[j] - 1] = True\n# single = False\n# break\n# if single:\n# girl = i\n# if girl == -1:\n# print('OPTIMAL')\n# else:\n# print('IMPROVE')\n# print(girl + 1, taken.index(False) + 1)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# odd, even = [], []\n# for i in range(2 * n):\n# if a[i] % 2:\n# odd.append(i + 1)\n# else:\n# even.append(i + 1)\n# for i in range(n - 1):\n# if len(odd) >= len(even):\n# print(odd.pop(), odd.pop())\n# else:\n# print(even.pop(), even.pop())\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# a.sort()\n# ans, i, j = 0, 0, 1\n# while j < n:\n# if a[i] < a[j]:\n# ans += 1\n# i += 1\n# j += 1\n# else:\n# while j < n and a[i] == a[j]:\n# i += 1\n# j += 1\n# print(ans + 1)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# got = False\n#\n# b = 1\n# while not got and b < 2 * n - 1:\n# if b % 2:\n# i, j = (b - 1) // 2, (b + 1) // 2\n# else:\n# i, j = b // 2 - 1, b // 2 + 1\n# left, right = set(a[:i]), set(a[j:])\n# if left & right:\n# got = True\n# b += 1\n# print('YES' if got else 'NO')\n\n\n# n, m, k = list(map(int, input().split()))\n# A = list(map(int, input().split()))\n# B = list(map(int, input().split()))\n# ans = 0\n# a, b = [0], [0]\n# for el in A:\n# a.append(a[-1] + el)\n# for el in B:\n# b.append(b[-1] + el)\n# d = [(i, k//i) for i in range(1, int(k**0.5)+1) if k % i == 0]\n# d += [(j, i) for i, j in d if i != j]\n# for i in range(n):\n# for j in range(m):\n# for q, p in d:\n# if i + q <= n and j + p <= m:\n# if a[i + q] - a[i] == q and b[j + p] - b[j] == p:\n# ans += 1\n# print(ans)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# s = input()\n# dic, se = {s: 1}, {s}\n# for k in range(2, n):\n# p = s[k - 1:] + (s[:k - 1], s[:k - 1][::-1])[(n % 2) == (k % 2)]\n# # print(k, p)\n# if p not in dic:\n# # print(dic, p)\n# dic[p] = k\n# se.add(p)\n# if s[::-1] not in dic:\n# dic[s[::-1]] = n\n# se.add(s[::-1])\n# # print(dic)\n# ans = min(se)\n# print(ans)\n# print(dic[ans])\n\n\n# for t in range(int(input())):\n# a, b, p = list(map(int, input().split()))\n# s = input()\n# road = [a if s[0] == 'A' else b]\n# st = [0]\n# for i in range(1, len(s) - 1):\n# if s[i] != s[i - 1]:\n# road.append(road[-1] + (a, b)[s[i] == 'B'])\n# st.append(i)\n# # print(road)\n# pay = road[-1]\n# j = 0\n# while pay > p and j < len(st):\n# pay = road[-1] - road[j]\n# j += 1\n# # print(j)\n# print(st[j] + 1 if j < len(st) else len(s))\n\n\n# for t in range(int(input())):\n# n, x, y = list(map(int, input().split()))\n# print(max(1, min(x + y - n + 1, n)), min(n, x + y - 1))\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# print(' '.join(map(str, sorted(a, reverse=True))))\n\n\n# s = input()\n# open, close = [], []\n# i = 0\n# for i in range(len(s)):\n# if s[i] == '(':\n# open.append(i)\n# else:\n# close.append(i)\n# i, j = 0, len(close) - 1\n# ans = []\n# while i < len(open) and j >= 0 and open[i] < close[j]:\n# ans += [open[i] + 1, close[j] + 1]\n# i += 1\n# j -= 1\n# ans.sort()\n# print('0' if not ans else '1\\n{}\\n{}'.format(len(ans), ' '.join([str(idx) for idx in ans])))\n\n\nimport collections\n# n, m = list(map(int, input().split()))\n# a = list(input() for i in range(n))\n# dic = {}\n# for w in a:\n# dic[w] = dic.get(w, 0) + 1\n# l, r = '', ''\n# for i in range(n):\n# for j in range(i + 1, n):\n# # print(i, j, a)\n# if a[i] == a[j][::-1] and dic[a[i]] and dic[a[j]]:\n# l += a[i]\n# r = a[j] + r\n# dic[a[i]] -= 1\n# dic[a[j]] -= 1\n# c = ''\n# for k, v in dic.items():\n# if v and k == k[::-1]:\n# if c and c[-m] == k or not c:\n# c += k\n# print(f'{len(l) + len(c) + len(r)}\\n{l + c + r}')\n\n\n# for t in range(int(input())):\n# n, g, b = list(map(int, input().split()))\n# d = n // 2 + n % 2\n# full, inc = divmod(d, g)\n# ans = (g + b) * (full - 1, full)[inc > 0] + (g, inc)[inc > 0]\n# print(ans if ans >= n else n)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# a.sort()\n# print(a[n] - a[n - 1])\n\n\n# for t in range(int(input())):\n# n, x = list(map(int, input().split()))\n# s = input()\n# cntz = s.count('0')\n# total = 2 * cntz - n\n# bal = 0\n# ans = 0\n# for i in range(n):\n# if not total:\n# if bal == x:\n# ans = -1\n# elif not abs(x - bal) % abs(total):\n# if (x - bal) // total >= 0:\n# ans += 1\n# bal += 1 if s[i] == '0' else -1\n# print(ans)\n\n\n# n = int(input())\n# ans = 0\n# for i in range(1, n + 1):\n# ans += 1 / i\n# print(ans)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# p, s = 0, n - 1\n# for i in range(n):\n# if a[i] < i:\n# break\n# p = i\n# for i in range(n - 1, -1, -1):\n# if a[i] < n - i - 1:\n# break\n# s = i\n# print('Yes' if s <= p else 'No')\n\n\n# n, k = list(map(int, input().split()))\n# a = [input() for i in range(n)]\n# c = set(a)\n# b = set()\n# for i in range(n):\n# for j in range(i + 1, n):\n# third = ''\n# for c1, c2 in zip(a[i], a[j]):\n# if c1 == c2:\n# third += c1\n# else:\n# if c1 != 'S' and c2 != 'S':\n# third += 'S'\n# elif c1 != 'E' and c2 != 'E':\n# third += 'E'\n# else:\n# third += 'T'\n# if third in c:\n# b.add(frozenset([a[i], a[j], third]))\n# print(len(b))\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# total, curr = sum(a), 0\n# ans, i, start = 'YES', 0, 0\n# while ans == 'YES' and i < n:\n# if curr > 0:\n# curr += a[i]\n# else:\n# curr = a[i]\n# start = i\n# # print(curr, i, start, total)\n# if i - start + 1 < n and curr >= total:\n# ans = 'NO'\n# i += 1\n# print(ans)\n\n\n# for t in range(int(input())):\n# n, p, k = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n# a.sort(reverse=True)\n# odd, even = 0, 0\n# i, j = len(a) - 1, len(a) - 2\n# curr = 0\n# while curr < p and i >= 0:\n# curr += a[i]\n# if curr <= p:\n# odd += 1\n# i -= 2\n# curr = 0\n# while curr < p and j >= 0:\n# curr += a[j]\n# if curr <= p:\n# even += 1\n# j -= 2\n# print(max(odd * 2 - 1, even * 2))\n\n\n# for t in range(int(input())):\n# s, c = input().split()\n# s = list(ch for ch in s)\n# sor = sorted(s)\n# for i in range(len(s)):\n# if s[i] != sor[i]:\n# j = max(j for j, v in enumerate(s[i:], i) if v == sor[i])\n# s = s[:i] + [s[j]] + s[i + 1:j] + [s[i]] + s[j + 1:]\n# break\n# s = ''.join(s)\n# print(s if s < c else '---')\n\n\n# for t in range(int(input())):\n# n, s = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n# if sum(a) <= s:\n# print(0)\n# else:\n# curr, i, j = 0, 0, 0\n# for i in range(n):\n# if a[i] > a[j]:\n# j = i\n# s -= a[i]\n# if s < 0:\n# break\n# print(j + 1)\n\n\n# for t in range(int(input())):\n# a, b = list(map(int, input().split()))\n# a, b = (b, a) if b > a else (a, b)\n# if not ((1 + 8 * (a - b))**0.5 - 1) % 2 and ((1 + 8 * (a - b))**0.5 - 1) // 2 >= 0:\n# ans = ((1 + 8 * (a - b))**0.5 - 1) // 2\n# print(int(ans))\n# else:\n# n1 = int(((1 + 8 * (a - b))**0.5 - 1) // 2) + 1\n# while (n1 * (n1 + 1) // 2) % 2 != (a - b) % 2:\n# n1 += 1\n# print(n1)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# a = list(map(int, input().split()))\n# a.sort()\n# ans = 0\n# l = 0\n# dic = {}\n# for i in range(n - 1, -1, -1):\n# if not a[i] % 2:\n# l, r = 0, 30\n# while l < r:\n# m = (l + r) // 2\n# # print(l, r, m, a[i] % 2**m)\n# if a[i] % 2**m:\n# r = m\n# else:\n# l = m + 1\n# dic[a[i] // 2**(l - 1)] = max(dic.get(a[i] // 2**(l - 1), 0), l - 1)\n# print(sum(list(dic.values())))\n\n\n# n = int(input())\n# s = input()\n# b = s.count('B')\n# w = n - b\n# if b % 2 and w % 2:\n# print(-1)\n# elif not b or not w:\n# print(0)\n# else:\n# ans = []\n# if not b % 2:\n# for i in range(n - 1):\n# if s[i] != 'W':\n# ans += [str(i + 1)]\n# s = s[:i] + 'W' + 'BW'[s[i + 1] == 'B'] + s[i + 2:]\n# elif not w % 2:\n# for i in range(n - 1):\n# if s[i] != 'B':\n# ans += [str(i + 1)]\n# s = s[:i] + 'B' + 'WB'[s[i + 1] == 'W'] + s[i + 2:]\n# print(len(ans))\n# print(' '.join(ans))\n\n\n# n, m = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n# b = list(map(int, input().split()))\n# b.sort()\n# ans = float('inf')\n# for i in range(n):\n# x = (b[0] - a[i]) % m\n# ax = []\n# for j in range(n):\n# ax.append((a[j] + x) % m)\n# if b == sorted(ax):\n# ans = min(ans, x)\n# print(ans)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# ans = [1] + [0] * (n - 1)\n# p = list(map(int, input().split()))\n# i, j, curr, m = p.index(1), 1, 1, 1\n# l, r = i, i\n# while l >= 0 and r < n:\n# if l and curr + p[l - 1] == (m + 2) * (m + 1) // 2:\n# ans[m] = 1\n# curr += p[l - 1]\n# l -= 1\n#\n# elif r + 1 < n and curr + p[r + 1] == (m + 2) * (m + 1) // 2:\n# ans[m] = 1\n# curr += p[r + 1]\n# r += 1\n# else:\n# if l and r + 1 < n:\n# curr, l, r = ((curr + p[l - 1], l - 1, r),\n# (curr + p[r + 1], l, r + 1))[p[r + 1] < p[l - 1]]\n# elif not l and r + 1 < n:\n# curr, l, r = curr + p[r + 1], l, r + 1\n# elif r + 1 == n and l:\n# curr, l, r = curr + p[l - 1], l - 1, r\n# else:\n# break\n# m += 1\n# print(''.join([str(i) for i in ans]))\n\n\n# for t in range(int(input())):\n# n = int(input())\n# p = [input() for i in range(n)]\n# ans = 0\n# for i in range(n):\n# if p[i] in p[i + 1:]:\n# for j in range(10):\n# code = p[i][:3] + str(j)\n# if code not in p:\n# p[i] = code\n# ans += 1\n# break\n# print(ans)\n# for code in p:\n# print(code)\n\n\n# for t in range(int(input())):\n# a, b = list(map(int, input().split()))\n# if (a + b) % 3 == 0 and 2 * min(a, b) >= max(a, b):\n# print('YES')\n# else:\n# print('NO')\n\n\n# for t in range(int(input())):\n# x, y = list(map(int, input().split()))\n# if (x == 1 and y > 1) or (x == 2 and y > 3) or (x == 3 and y > 3):\n# print('NO')\n# else:\n# print('YES')\n\n\n# for t in range(int(input())):\n# n, m = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n# if m < n or n == 2:\n# print(-1)\n# elif m == n:\n# print(2 * sum(a))\n# for i in range(n - 1):\n# print(i + 1, i + 2)\n# print(n, 1)\n# else:\n# b = [(a[i], i + 1) for i in range(n)]\n# b.sort()\n# d = m - n\n# ans = sum(a) + d * (b[0][0] + b[1][0])\n# for i in range(d):\n# print(b[0][1], b[1][1])\n# for i in range(n - 1):\n# print(i + 1, i + 2)\n# print(n, 1)\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n# if n % 2:\n# print(-1)\n# else:\n# d = 0\n# c = []\n# curr = 0\n# came = set()\n# day = set()\n# inc = False\n# for i in range(n):\n# if a[i] > 0:\n# if a[i] in day:\n# inc = True\n# break\n# else:\n# day.add(a[i])\n# came.add(a[i])\n# else:\n# if abs(a[i]) not in came:\n# inc = True\n# break\n# else:\n# came.remove(abs(a[i]))\n# if len(came) == 0:\n# d += 1\n# c.append(i + 1)\n# day = set()\n# if len(came) > 0:\n# inc = True\n# if inc:\n# print(-1)\n# else:\n# print(d)\n# print(c[0])\n# for i in range(1, len(c)):\n# print(c[i] - c[i - 1])\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n# a.sort()\n# x, y = sum(a[:n // 2])**2, sum(a[n // 2:])**2\n# print(x + y)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# r, p, s = list(map(int, input().split()))\n# b = input()\n# S, P, R = b.count('S'), b.count('P'), b.count('R')\n# cnt = 0\n# ans = ''\n# # print(r, 'rock', p, 'paper', s, 'sc')\n# for i in range(n):\n# if b[i] == 'S':\n# if r > 0:\n# ans, r, cnt = ans + 'R', r - 1, cnt + 1\n# else:\n# if p > R:\n# ans, p = ans + 'P', p - 1\n# if len(ans) < i + 1 and s > P:\n# ans, s = ans + 'S', s - 1\n# S -= 1\n# elif b[i] == 'P':\n# if s > 0:\n# ans, s, cnt = ans + 'S', s - 1, cnt + 1\n# else:\n# if p > R:\n# ans, p = ans + 'P', p - 1\n# if len(ans) < i + 1 and r > S:\n# ans, r = ans + 'R', r - 1\n# P -= 1\n# else:\n# if p > 0:\n# ans, p, cnt = ans + 'P', p - 1, cnt + 1\n# else:\n# if s > P:\n# ans, s = ans + 'S', s - 1\n# if len(ans) < i + 1 and r > S:\n# ans, r = ans + 'R', r - 1\n# R -= 1\n# if cnt < (n // 2 + n % 2):\n# print('NO')\n# else:\n# print('YES')\n# # print(r, p, s)\n# print(ans)\n\n\n# for t in range(int(input())):\n# n = int(input())\n# s = input()\n# f, l = s.find('1'), s.rfind('1')\n# f, l = max(f + 1, n - f) if f != -1 else 0, max(l + 1, n - l) if l != -1 else 0\n# if not f and not l:\n# print(n)\n# else:\n# print(f * 2) if f > l else print(l * 2)\n\n\n# t = int(input())\n# ans = list()\n# for _ in [0] * t:\n# n, r = map(int, input().split())\n# x = sorted(set(map(int, input().split())))[::-1]\n# ans.append(sum([x - i * r > 0 for i, x in enumerate(x)]))\n# print(' '.join(map(str, ans)))\n\n\n# n = int(input())\n# dots = []\n# for i in range(n):\n# dots.append(sum(list(map(int, input().split()))))\n# print(max(dots))\n\n\n# n, m = map(int, input().split())\n# print(pow(2**m - 1, n, 10**9 + 7))\n\n\n# n, k = map(int, input().split())\n# s = input()\n# if not k:\n# print(s)\n# elif n == 1:\n# print('0')\n# else:\n# s = [int(i) for i in s]\n# if s[0] > 1:\n# s[0], k = 1, k - 1\n# for i in range(1, n):\n# if not k:\n# break\n# if s[i] > 0:\n# s[i], k = 0, k - 1\n# print(''.join(map(str, s))) if len(s) > 1 else print('0')\n\n\n# m, n = map(int, input().split())\n# r = list(map(int, input().split()))\n# c = list(map(int, input().split()))\n# grid = [['ok'] * (n + 1) for i in range(m + 1)]\n#\n# for i in range(m):\n# row = r[i]\n# if row:\n# for j in range(row):\n# grid[i][j] = 1\n# grid[i][row] = 0\n# else:\n# grid[i][row] = 0\n#\n#\n# inv = False\n# for j in range(n):\n# col = c[j]\n# if col:\n# for i in range(col):\n# if grid[i][j] == 0:\n# inv = True\n# break\n# else:\n# grid[i][j] = 1\n# if grid[col][j] == 1:\n# inv = True\n# break\n# else:\n# grid[col][j] = 0\n# else:\n# if grid[col][j] == 1:\n# inv = True\n# break\n# else:\n# grid[col][j] = 0\n#\n# if inv:\n# print(0)\n# else:\n# cnt = 0\n# for row in grid[:m]:\n# cnt += row[:n].count('ok')\n# print(pow(2, cnt, 10**9 + 7))\n\n\n# n = int(input())\n# for i in range(n):\n# print('BW' * (n // 2) + 'B' * (n % 2) if i % 2 else 'WB' * (n // 2) + 'W' * (n % 2))\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n# curr, odd, even = 0, 0, 0\n# p = 0\n# for d in a:\n# odd, even = ((odd, even + 1), (odd + 1, even))[curr % 2]\n# curr += 1 if d < 0 else 0\n# p += odd if curr % 2 else even\n# print(n * (n + 1) // 2 - p, p)\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n# p, m, z = 0, [], 0\n# for d in a:\n# if d > 0:\n# p += d\n# elif d < 0:\n# m.append(d)\n# else:\n# z += 1\n# ans = p - (n - z - len(m))\n#\n# if len(m) % 2:\n# if z:\n# m.append(-1)\n# ans += 1\n# z -= 1\n# else:\n# m.sort(reverse=True)\n# x = m.pop()\n# ans += 1 - x\n#\n# mm = len(m)\n# ans += abs(sum(m)) - mm\n# ans += z\n# print(ans)\n\n\n# n, l, r = map(int, input().split())\n# a = [2**i for i in range(r)]\n# print(sum(a[:l]) + n - l, sum(a) + (n - r) * a[-1])\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n# a.sort()\n# print('YES' if not sum(a) % 2 and a[-1] <= sum(a) - a[-1] else 'NO')\n\n\n# for t in range(int(input())):\n# n, m, k = map(int, input().split())\n# h = list(map(int, input().split()))\n# ans = 'YES'\n# for i in range(n - 1):\n# if abs(h[i] - h[i + 1]) > k:\n# d = h[i] - h[i + 1]\n# if d < 0 and m >= abs(d) - k:\n# m -= -k - d\n# elif d > 0:\n# m += min(d + k, h[i])\n# else:\n# ans = 'NO'\n# break\n# else:\n# d = h[i] - h[i + 1]\n# if d >= 0:\n# m += min(d + k, h[i])\n# else:\n# m += min(k + d, h[i])\n# print(ans)\n\n\n# h, l = map(int, input().split())\n# print((h**2 + l**2) / (2 * h) - h)\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n# a = {i: j for i, j in enumerate(a)}\n# m, idx = 0, 0\n# ans = 'YES'\n# for i in range(n):\n# if a[i] > m:\n# m = a[i]\n# idx = i\n# for i in range(1, idx):\n# if a[i] < a[i - 1]:\n# ans = 'NO'\n# break\n# for i in range(idx + 1, n):\n# if a[i] > a[i - 1]:\n# ans = 'NO'\n# break\n# print(ans)\n\n\n# n, k = map(int, input().split())\n# l, r = 0, n\n# while l <= r:\n# m = (l + r) // 2\n# t = n - m\n# if m * (m + 1) // 2 - t == k:\n# ans = t\n# break\n# elif m * (m + 1) // 2 - t < k:\n# l = m + 1\n# else:\n# r = m - 1\n# print(ans)\n\n\n# for t in range(int(input())):\n# n, m = map(int, input().split())\n# grid = [input() for i in range(n)]\n# rows = []\n# cols = [0] * m\n# for row in grid:\n# rows.append(0)\n# for i in range(m):\n# if row[i] == '.':\n# rows[-1] += 1\n# cols[i] += 1\n# ans = m + n - 1\n# for i in range(n):\n# for j in range(m):\n# ans = min(ans, rows[i] + cols[j] - (grid[i][j] == '.'))\n# print(ans)\n\n\ntiles = input().split()\nunique = {}\nm, p, s = set(), set(), set()\nm_unique = 0\nfor t in tiles:\n unique[t] = unique.get(t, 0) + 1\n m_unique = max(m_unique, unique[t])\n if t[1] == 'm':\n m.add(int(t[0]))\n elif t[1] == 'p':\n p.add(int(t[0]))\n else:\n s.add(int(t[0]))\nans = 3 - m_unique\nfor t in (m, p, s):\n if not t:\n continue\n else:\n m_sub = 0\n l = list(sorted(t))\n dif = []\n for i in range(1, len(t)):\n dif.append(l[i] - l[i - 1])\n if dif[-1] == 1 or dif[-1] == 2:\n m_sub = max(m_sub, 2)\n if i > 1 and dif[-1] == dif[-2] == 1:\n m_sub = 3\n # print(l, dif, m_sub)\n ans = min(ans, 3 - m_sub)\nprint(ans)\n", "positive_code": [{"source_code": "strings = list(map(str, input().split()))\ns1, s2, s3 = strings[0], strings[1], strings[2]\n\ncheck = {'m': [], 'p': [], 's': []}\n\ncheck[s1[1]].append(int(s1[0]))\ncheck[s2[1]].append(int(s2[0]))\ncheck[s3[1]].append(int(s3[0]))\ncheck['m'].sort()\ncheck['p'].sort()\ncheck['s'].sort()\n\ncm, cp, cs = len(check['m']), len(check['p']), len(check['s'])\n\nif cm == cp == cs == 1:\n print(2)\nelse:\n ans = 0\n diff = list()\n\n if cm > cp and cm > cs:\n for i in range(cm-1):\n diff.append(abs(check['m'][i] - check['m'][i + 1]))\n elif cp > cm and cp > cs:\n for i in range(cp-1):\n diff.append(abs(check['p'][i] - check['p'][i + 1]))\n else:\n for i in range(cs-1):\n diff.append(abs(check['s'][i] - check['s'][i + 1]))\n\n if len(diff) == 1:\n if diff[0] == 0 or diff[0] == 1 or diff[0] == 2:\n ans = 1\n else:\n ans = 2\n elif len(diff) == 2:\n if diff[0] == diff[1]:\n if diff[0] == 2:\n ans = 1\n elif diff[0] > 2:\n ans = 2\n elif diff[0] != diff[1]:\n for i in diff:\n if i == 0 or i == 1 or i == 2:\n ans = 1\n break\n else:\n ans = 2\n\n print(ans)\n"}, {"source_code": "d = {\n 'm': 10,\n 's': 30,\n 'p': 60\n}\n \na, b, c = list(sorted([int(i[0]) + d[i[1]] for i in input().split(' ')]))\n \nif (a == b and b == c) or (a == b - 1 and b == c - 1):\n print(0)\nelif a == b - 1 or b == c - 1 or a == b or b == c or a == c - 2 or a == b - 2 or b == c - 2:\n print(1)\nelse:\n print(2)\n\n\n\n'''\nd={'m':10,'p':30,'s':50}\n\n#men=> kou or shu\na,y,z=sorted([int(x[0])+d[x[1]] for x in (input().split())])\nprint(a,y,z)\n#kou and sust\nif (a==y and y==z) or (a==y-1 and y==z-1):\n print(0)\nelif a==y or y==z or a==z or a==y-1 or y==z-1 or a==y-2 or y==z-2 :\n print(1)\nelse: \n print(2)\n'''\n"}, {"source_code": "d = {\n 'm': 10,\n 's': 30,\n 'p': 60\n}\n \na, b, c = list(sorted([int(i[0]) + d[i[1]] for i in input().split(' ')]))\n \nif (a == b and b == c) or (a == b - 1 and b == c - 1):\n print(0)\n exit()\nif a == b - 1 or b == c - 1 or a == b or b == c or a == c - 2 or a == b - 2 or b == c - 2:\n print(1)\n exit()\nprint(2)\n\n\n\n'''\nd={'m':10,'p':30,'s':50}\n\n#men=> kou or shu\na,y,z=sorted([int(x[0])+d[x[1]] for x in (input().split())])\nprint(a,y,z)\n#kou and sust\nif (a==y and y==z) or (a==y-1 and y==z-1):\n print(0)\nelif a==y or y==z or a==z or a==y-1 or y==z-1 or a==y-2 or y==z-2 :\n print(1)\nelse: \n print(2)\n'''\n"}, {"source_code": "def main():\n s = input().split()\n\n maxIdent = 0\n maxIncr = 0\n \n for el in s:\n cnt = s.count(el)\n if cnt == 3:\n print(0)\n return\n if cnt > maxIdent:\n maxIdent = cnt\n \n cnt2 = 1\n item1 = str(int(el[0]) + 1) + el[1]\n item2 = str(int(el[0]) + 2) + el[1]\n if item1 in s or item2 in s:\n cnt2 = 2\n if item1 in s and item2 in s:\n print(0)\n return\n if cnt2 > maxIncr:\n maxIncr = cnt2\n \n maxIdent = 3 - maxIdent\n maxIncr = 3 - maxIncr\n print(min([maxIdent, maxIncr])) \n \nmain()"}, {"source_code": "first_list = raw_input().split()\ndata_dic = {}\nfor item in first_list:\n digit = int(item[0])\n letter = item[1]\n if letter not in data_dic:\n data_dic.update({letter: [digit]})\n else:\n data_dic[letter].append(digit)\nkoutsu = False\nshuntsu = False\nkoutsu_action = 100\nshuntsu_action = 100\nfor j in data_dic:\n for i in data_dic[j]:\n if data_dic[j].count(i) >= 3:\n koutsu = True\n else:\n koutsu_action = min(koutsu_action, 3 - data_dic[j].count(i))\n if i + 1 in data_dic[j] and i - 1 in data_dic[j]:\n shuntsu = True\n elif i + 1 in data_dic[j] or i - 1 in data_dic[j]:\n shuntsu_action = min(shuntsu_action, 1)\n elif i - 2 in data_dic[j] or i + 2 in data_dic[j]:\n shuntsu_action = min(shuntsu_action, 1)\n else:\n shuntsu_action = min(shuntsu_action, 2)\nif shuntsu or koutsu:\n print(0)\nelse:\n print(min(shuntsu_action, koutsu_action))\n"}, {"source_code": "import sys\n \na,b,c=map(str,raw_input().split())\nd={}\nh={}\nl=[a,b,c]\n \nfor i in xrange(len(l)):\n key=l[i][1]\n if key not in d:\n d[key]=[int(l[i][0])]\n else:\n d[key].append(int(l[i][0]))\n \nq=d.values()\n \nans=2\nfor i in xrange(len(q)):\n u=q[i]\n if len(u)==1:\n ans=min(ans,2)\n elif len(u)==2:\n if len(set(u))==1:\n ans=min(1,ans)\n elif abs(u[0]-u[1])==1:\n ans=min(ans,1)\n elif abs(u[0]-u[1])==2:\n ans=min(ans,1)\n else:\n ans=min(ans,2)\n elif len(u)==3:\n u.sort()\n if len(set(u))==1:\n print 0\n sys.exit()\n elif u[1]-u[0]==1 and u[2]-u[1]==1:\n print 0\n sys.exit()\n elif u[1]-u[0]<=1 or u[1]-u[0]<=2:\n ans=min(1,ans)\n elif u[2]-u[1]<=1 or u[2]-u[1]<=2:\n ans=min(1,ans)\n elif u[2]-u[0]<=2:\n ans=min(1,ans)\n else:\n ans=min(2,ans)\nprint ans"}, {"source_code": "l=[x for x in input().split()]\nm=[0]*10\np=[0]*10\ns=[0]*10\nfor i in range(len(l)):\n if l[i][1]==\"m\":\n m[int(l[i][0])]+=1\n elif l[i][1]==\"p\":\n p[int(l[i][0])]+=1\n else:\n s[int(l[i][0])]+=1\nflag1=1\nflag2=1\nflag3=1\nflag4=1\nflag5=1\nfor i in range(10):\n if m[i]>=3 or p[i]>=3 or s[i]>=3:\n print(0)\n flag1=0\n flag2=0\n flag3=0\n flag4=0\n flag5=0\n break\nif flag3:\n for i in range(8):\n if m[i]>=1 and m[i+1]>=1 and m[i+2]>=1 or p[i]>=1 and p[i+1]>=1 and p[i+2]>=1 or s[i]>=1 and s[i+1]>=1 and s[i+2]>=1:\n print(0)\n flag1=0\n flag2=0\n flag4=0\n flag5=0\n break\n\nif flag1:\n for i in range(9):\n if m[i]>=1 and m[i+1]>=1 or p[i]>=1 and p[i+1]>=1 or s[i]>=1 and s[i+1]>=1:\n print(1)\n flag2=0\n flag4=0\n flag5=0\n break\n\nif flag4:\n for i in range(10):\n if m[i]==2 or p[i]==2 or s[i]==2:\n print(1)\n flag2=0\n flag5=0\n break\n\nif flag5:\n for i in range(8):\n if m[i]>=1 and m[i+2]>=1 or p[i]>=1 and p[i+2]>=1 or s[i]>=1 and s[i+2]>=1:\n print(1)\n flag2=0\n break\n\nif flag2:\n if len(l)>=1:\n print(2)\n else:\n print(3)"}, {"source_code": "a=map(str,raw_input().split())\nm=[0 for i in range(9)]\np=[0 for i in range(9)]\ns=[0 for i in range(9)]\nfor i in a:\n if i[1]=='m':\n m[int(i[0])-1]+=1\n elif i[1]==\"p\":\n p[int(i[0])-1]+=1\n else:\n s[int(i[0])-1]+=1\nans=2\ncon=0\ncon1=0\nk=0\nfor i in m:\n k+=1\n if i==3:\n ans=0\n break\n if i==2:\n ans=min(ans,1)\n break\n if i==1:\n con+=1\n ans=min(ans,2)\n if k<8:\n if m[k]==0:\n if m[k+1]!=0:\n con1=max(con1,2)\n if i==0:\n con1=max(con,con1)\n con=0\n\ncon1=max(con,con1)\ncon=0\nk=0\nfor i in p:\n k+=1\n if i==3:\n ans=0\n break\n if i==2:\n ans=min(ans,1)\n break\n if i==1:\n ans=min(ans,2)\n con+=1\n if k<8:\n if p[k]==0:\n if p[k+1]!=0:\n con1=max(con1,2)\n if i==0:\n con1=max(con,con1)\n con=0\n\ncon1=max(con,con1)\ncon=0\nk=0\nfor i in s:\n k+=1\n if i==3:\n ans=0\n break\n if i==2:\n ans=min(ans,1)\n break\n if i==1:\n ans=min(ans,2)\n con+=1\n if k<8:\n if s[k]==0:\n if s[k+1]!=0:\n con1=max(con1,2)\n if i==0:\n con1=max(con,con1)\n con=0\n\ncon1=max(con,con1)\ncon=0\nprint min(ans,3-con1)\n\n\n\n\n"}, {"source_code": "a, b, c = input().split()\ntiles = set()\nfor i in a, b, c:\n tiles.add(i)\nif len(tiles) == 1:\n print(0)\nelif len(tiles) == 2:\n print(1)\nelse:\n pairs = []\n for i in a, b, c:\n num = i[:-1]\n let = i[-1]\n pairs.append((int(num), let))\n pairs = sorted(pairs)\n if pairs[0][1] == pairs[1][1] and pairs[1][1] == pairs[2][1]:\n if pairs[0][0] == pairs[1][0] - 1 and pairs[1][0] == pairs[2][0] - 1:\n print(0)\n elif pairs[0][0] == pairs[1][0] - 1 or pairs[1][0] == pairs[2][0] - 1 or pairs[0][0] == pairs[1][0] - 2 or pairs[1][0] == pairs[2][0] - 2:\n print(1)\n else:\n print(2)\n else:\n matches = [0, 0]\n if pairs[0][1] == pairs[1][1]:\n matches = [pairs[0][0], pairs[1][0]]\n elif pairs[1][1] == pairs[2][1]:\n matches = [pairs[1][0], pairs[2][0]]\n elif pairs[0][1] == pairs[2][1]:\n matches = [pairs[0][0], pairs[2][0]]\n if matches[0] == matches[1] - 1 or matches[0] == matches[1] - 2:\n print(1)\n else:\n print(2)"}, {"source_code": "from collections import Counter\n\nX, Temp = input()[::-1].split(), 1\nMyDict = Counter(X)\nif 3 in MyDict.values():\n print(0)\n exit()\nKey = sorted(MyDict.keys())\nMax = max(MyDict.values())\nfor i in range(1, len(Key)):\n Diff = int(Key[i][1]) - int(Key[i - 1][1])\n if Key[i][0] == Key[i - 1][0] and Diff <=2 :\n if Diff == 2:\n print(1)\n exit()\n Temp += 1\n else:\n Temp = 1\n Max = max(Max, Temp)\nprint(max(0, 3 - Max))\n\n# Show you deserve being the best to whom doesn't believe in you.\n"}, {"source_code": "a,b,c=raw_input().split()\nd={'p':[],'m':[],'s':[]}\nd[a[1]].append((int(a[0])))\nd[b[1]].append((int(b[0])))\nd[c[1]].append((int(c[0])))\nc=100\n\nfor k in d.keys():\n d[k].sort()\n\n if(len(d[k])==1):\n c=min(c,2)\n\n elif(len(d[k])==0):\n c=min(3,c)\n elif(len(d[k])==2):\n if(d[k][0]==d[k][1]-1):c=min(c,1)\n if (d[k][0] == d[k][1]):\n c = min(c, 1)\n if (d[k][0] == d[k][1]-2):\n c = min(c, 1)\n\n else :c=min(c,2)\n\n else:\n\n for i in range(len(d[k])-2):\n if (d[k][i] == d[k][i + 1] and d[k][i + 1] == d[k][i + 2] ): c = min(0, c)\n if (d[k][i] == d[k][i + 1] and d[k][i + 1] != d[k][i + 2] ): c = min(1, c)\n if (d[k][i] != d[k][i + 1] and d[k][i + 1] == d[k][i + 2] ): c = min(1, c)\n if(d[k][i]==d[k][i+1]-1 and d[k][i+1]==d[k][i+2]-1):c=min(0,c)\n if (d[k][i] == d[k][i + 1] - 1 and d[k][i + 1] != d[k][i + 2] - 1):c=min(1,c)\n if (d[k][i] != d[k][i + 1] - 1 and d[k][i + 1] != d[k][i + 2] - 1 ): c = min(2, c)\n if (d[k][i] != d[k][i + 1] - 1 and d[k][i + 1] == d[k][i + 2] - 1): c = min(1, c)\n if ( d[k][i]+2==d[k][i+1]): c = min(1, c)\nprint c\n"}, {"source_code": "a,b,c=input().split()\na,b,c=sorted([a,b,c])\nA=[a,b,c]\nA=set(A)\nif len(A)==1:\n print(0)\n exit()\nif len(A)==2:\n print(1)\n exit()\nif a[1]==b[1]and b[1]==c[1]:\n if a[0]==b[0] and b[0]==c[0]:\n print(0)\n elif int(b[0])==int(a[0])+1 and int(c[0])==int(b[0])+1:\n print(0)\n elif int(b[0])==int(a[0])+1 or int(c[0])==int(b[0])+1:\n print(1)\n else:\n if int(b[0])-int(a[0])==2 or int(c[0])-int(b[0])==2:\n print(1)\n else:\n print(2)\nelif a[1]==b[1]:\n if int(b[0])-int(a[0])<=2:\n print(1)\n else:\n print(2)\nelif b[1]==c[1]:\n if int(c[0])-int(b[0])<=2:\n print(1)\n else:\n print(2)\nelif a[1]==c[1]:\n if int(c[0])-int(a[0])<=2:\n print(1)\n else:\n print(2)\nelse:\n print(2)"}, {"source_code": "# coding: UTF-8\nimport sys\n#sys.setrecursionlimit(n)\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\nreadl= lambda: list(map(str, sys.stdin.readline().split()))\nreadt= lambda: tuple(map(int, sys.stdin.readline().split()))\nread = lambda: sys.stdin.readline().rstrip()\nreadi = lambda: int(read())\nreadmi = lambda: map(int, sys.stdin.readline().split())\nreadms = lambda: map(str, sys.stdin.readline().split())\n\nt = readl()\nn = []\nm = []\nt.sort()\nfor i in t:\n n.append(int(i[0]))\n m.append(i[1])\ncount = 2\nif m[0] == m[1] == m[2]:\n if n[0] == n[1] == n[2] or (n[0] + 1 == n[1] and n[1] + 1 == n[2]):\n print(0)\n elif n[0] == n[1] or n[0] == n[2] or n[1] == n[2]:\n print(1)\n elif n[0] + 1 == n[1] or n[0] + 2 == n[1] or n[1] + 1 == n[2] or n[1] + 2 == n[2] or n[0] + 1 == n[2] or n[0] + 2 == n[2]:\n print(1)\n else:\n print(2)\nelif m[0] == m[1]:\n if n[0] == n[1] or n[0] + 1 == n[1] or n[0] + 2 == n[1]:\n print(1)\n else:\n print(2)\nelif m[0] == m[2]:\n if n[0] == n[2] or n[0] + 1 == n[2] or n[0] + 2 == n[2]:\n print(1)\n else:\n print(2) \nelif m[1] == m[2]:\n if n[1] == n[2] or n[1] + 1 == n[2] or n[1] + 2 == n[2]:\n print(1)\n else:\n print(2)\nelse:\n print(2)\n"}, {"source_code": "a = map(lambda x: [int(x[0]),x[1]], raw_input().split())\nck = 3 - max(a.count(a[0]), max(a.count(a[1]), a.count(a[2])))\ncs0, cs1, cs2 = 2, 2, 2\nif [a[0][0]+1, a[0][1]] in a :\n\tcs0 -= 1\nif [a[0][0]+2, a[0][1]] in a :\n\tcs0 -= 1\n\nif [a[1][0]+1, a[1][1]] in a :\n\tcs1 -= 1\nif [a[1][0]+2, a[1][1]] in a :\n\tcs1 -= 1\n\nif [a[2][0]+1, a[2][1]] in a :\n\tcs2 -= 1\nif [a[2][0]+2, a[2][1]] in a :\n\tcs2 -= 1\n\nprint min([cs0, cs1, cs2, ck])"}, {"source_code": "M = 10**9 + 7\nR = lambda: map(int, input().split())\nL = [[0 for j in range(9)] for i in range(3)]\n#print(L)\na = input().split()\ndef f(p):\n if p[1] == 'm':\n L[0][int(p[0])-1] += 1\n elif p[1] == 'p':\n L[1][int(p[0])-1] += 1\n elif p[1] == 's':\n L[2][int(p[0])-1] += 1\nfor i in range(3):\n f(a[i])\np = sum(L[0])\nq = sum(L[1])\nr = sum(L[2])\nm = max([p,q,r])\n#print(L)\n'''if m == 1:\n print(2)\nelif m == 2:\n for i in range(3):\n for j in range(8):\n if L[i][j] == 1 and L[i][j+1] == 1:\n print(1)\n quit()\n print(2)\nelif m == 3:'''\nif len(set(a)) == 1:\n print(0)\n quit()\nelif len(set(a)) == 2:\n print(1)\n quit()\nk = 0\nfor i in range(3):\n for j in range(7):\n k = max(k,L[i][j]+L[i][j+1]+L[i][j+2])\n k = max(k,L[i][7]+L[i][8])\nif k == 3:\n print(0)\nelif k == 2:\n print(1)\nelif k == 1:\n print(2)"}, {"source_code": "a=list(input().split())\nar1=[]\nar2=[]\nfor i in a:\n ar1.append(int(i[0]))\n ar2.append(i[1])\ns=set()\nfor i in range(3):\n for j in range(i+1,3):\n if ar2[i]==ar2[j]:\n s.add(i)\n s.add(j)\nif len(s)==0:\n print(2)\nelif len(s)==2:\n i1=s.pop()\n i2=s.pop()\n if abs(ar1[i1]-ar1[i2])<=2:\n print(1)\n else:\n print(2)\nelse:\n ar1.sort()\n d1=ar1[1]-ar1[0]\n d2=ar1[2]-ar1[1]\n if d1==0:\n if d2==0:\n print(0)\n else:\n print(1)\n elif d1==1:\n if d2==1:\n print(0)\n else:\n print(1)\n elif d1==2 or d2==2:\n print(1)\n else:\n if d2==0 or d2==1:\n print(1)\n else:\n print(2)\n "}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\nif __name__ == \"__main__\":\n s = [[],[],[]]\n st = list(input().split())\n for i in st:\n if i[1] == 'm':\n s[0].append(int(i[0]))\n if i[1] == 'p':\n s[1].append(int(i[0]))\n if i[1] == 's':\n s[2].append(int(i[0]))\n ans = 2\n for i in s:\n if len(i) == 1:\n ans = min(ans , 2)\n elif len(i) == 2:\n i.sort()\n if i[1] == i[0] + 1 or i[1] == i[0] + 2:\n ans = min(ans , 1)\n elif i[1] == i[0]:\n ans = min(ans , 1)\n else:\n ans = min(ans , 2)\n elif len(i) == 3:\n i.sort()\n if i[2] == i[1] and i[1] == i[0]:\n ans = 0\n if i[2] == i[1] + 1 and i[1] == i[0] + 1:\n ans = 0\n elif i[2] == i[1] and i[1] == i[0]:\n ans = 0\n elif i[1] == i[0] + 1 or i[1] == i[0] + 2:\n ans = min(ans , 1)\n elif i[2] == i[1] + 1 or i[2] == i[1] + 2:\n ans = min(ans , 1)\n elif i[2] == i[0] + 1 and i[2] == i[0] + 2:\n ans = min(ans , 1)\n elif i[0] == i[1] or i[1] == i[2]:\n ans = min(ans , 1)\n else:\n ans = min(ans, 2)\n print(ans)"}, {"source_code": "s=input().split()\nl=[]\ns.sort()\nfor i in s:\n l.append(int(i[0]))\n l.append(i[1])\nif l[0]==l[2] and l[1]==l[3]:\n if l[0]==l[4] and l[1]==l[5]:\n print(0) \n else: \n print(1) \nelif l[4]==l[2] and l[5]==l[3]:\n print(1) \nelif l[0]+1==l[2] and l[1]==l[3]:\n if l[2]+1==l[4] and l[3]==l[5]:\n print(0)\n else:\n print(1)\nelif l[0]+2==l[2] and l[1]==l[3]:\n print(1)\nelif l[2]+1==l[4] and l[5]==l[3]:\n print(1)\nelif l[2]+2==l[4] and l[5]==l[3]:\n print(1) \nelif l[0]+1==l[4] and l[1]==l[5]:\n print(1) \nelif l[0]+2==l[4] and l[1]==l[5]:\n print(1) \nelse:\n print(2)"}, {"source_code": "cards = input().split()\nans = 2\nif cards[0] == cards[1] and cards[2] == cards[1]:\n ans = 0\nelif cards[0] == cards[1] or cards[0] == cards[2] or cards[2] == cards[1]:\n ans = 1\nelse:\n if cards[0][1] == cards[1][1] and cards[0][1] == cards[2][1]: \n if abs(int(cards[0][0]) - int(cards[1][0])) <= 2 and abs(int(cards[0][0]) - int(cards[2][0])) <= 2 and abs(int(cards[1][0]) - int(cards[2][0])) <= 2:\n ans = 0\n elif abs(int(cards[0][0]) - int(cards[1][0])) <= 2 or abs(int(cards[0][0]) - int(cards[2][0])) <= 2 or abs(int(cards[1][0]) - int(cards[2][0])) <= 2:\n ans = 1\n elif not(cards[0][1] != cards[1][1] and cards[0][1] != cards[2][1] and cards[2][1] != cards[1][1]):\n if cards[0][1] == cards[1][1]:\n card1, card2 = cards[0], cards[1]\n elif cards[0][1] == cards[2][1]:\n card1, card2 = cards[0], cards[2]\n else:\n card1, card2 = cards[1], cards[2]\n if abs(int(card1[0]) - int(card2[0])) <= 2:\n ans = 1\nprint(ans)"}, {"source_code": "#include<bits/stdc++.h>\n#include<stdio.h> //per fare input output con scanf and printf\n#include<stdlib.h> //per fare qsort e bsearch\n#include<string.h> // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali\n#include<math.h>\n#include<algorithm>\n#include<iostream>\n#include<queue>\n#include<stack>\n#include<vector>\n#include<map>\n \n#using namespace std;\n \n#define ld long double\n#define ll long long int\n#define vi vector <ll> \n#define pi pair <ll, ll>\n#define binary(v, el) binary_search((v).begin(), (v).end(), (el))\n#define PB push_back\n#define MP make_pair\n#define F first\n#define S second\n \nx,y,z = list(map(str, input().strip().split()))\n\ndef cazzu(a,b,c):\n if a==b==c:\n return 1\n else:\n return 0\n \ndef shizu(a,b,c):\n x = int(a[0])\n y = int(b[0])\n z = int(c[0])\n l = [x,y,z]\n l.sort()\n if a[1]==b[1]==c[1] and l[1]-l[0] == 1 and l[2]-l[1]==1:\n return 1\n else:\n return 0\n\nif cazzu(x,y,z) or shizu(x,y,z):\n print(0)\nelse:\n flag = 0\n for i in ['p','m','s']:\n for j in ['1','2','3','4','5','6','7','8','9']:\n w = j+i\n if cazzu(x,y,w) or shizu(x,y,w) or cazzu(x,w,z) or shizu(x,w,z) or cazzu(w,y,z) or shizu(w,y,z):\n flag = 1\n\n if flag == 1:\n print(1)\n else:\n print(2)"}, {"source_code": "\n\ndef meth(arr):\n for i in range(3):\n arr[i]=int(arr[i])\n arr.sort()\n if arr[0]+1==arr[1] and arr[0]+2==arr[2]:\n return 0\n if arr[1]-arr[0]>=3 and arr[2]-arr[1]>=3:\n return 2\n return 1\n\ndef meth1(arr):\n for i in range(2):\n arr[i]=int(arr[i])\n arr.sort()\n if arr[0]+1==arr[1] or arr[0]+2==arr[1] or arr[0]==arr[1]:\n return 1\n \n return 2\n\n\na,b,c=input().split()\nif a==b==c:\n print(0)\n exit(0)\nif a[1]==b[1]==c[1]:\n print(meth([a[0],b[0],c[0]]))\n exit(0)\n\nif a[1]==b[1] and b[1]!=c[1]:\n print(meth1([a[0],b[0]]))\n exit(0)\n\nif c[1]==b[1] and a[1]!=c[1]:\n print(meth1([b[0],c[0]]))\n exit(0)\n\nif a[1]==c[1] and b[1]!=c[1]:\n print(meth1([a[0],c[0]]))\n exit(0)\n\nprint(2)\nexit(0)\n\n\"\"\"\nfrom sys import stdin,stdout\nn,m,k=list(map(int,stdin.readline().split()))\n\ndef m1(x,k):\n if x%k==0:\n return x//k\n return x//k+1\n \n\n\ndef meth(arr):\n if arr==[]:\n return []\n a=[]\n #a=[[] for _ in range(m1(arr[-1],k)) ]\n tmp=[]\n for x in arr:\n if m1(x,k)-1==0:\n tmp.append(x)\n else:\n a.append(x)\n a=[tmp]+a\n if [] in a:\n a.remove([])\n return a\n\n\n\n\na=list(map(int,stdin.readline().split()))\n\narr=meth(a)\nres=0\nwhile len(arr)>1:\n #print(arr)\n val=arr.pop(0)\n if isinstance(val,int):\n break\n ln=len(val)\n newarr=[]\n\n for i in range(len(arr)):\n arr[i]-=ln\n \n arr=meth(arr)\n res+=1\n\nstdout.write(str(res+1)+\"\\n\")\n\n\n\"\"\""}, {"source_code": "a = list(map(str, input().split()))\na.sort()\nif(a[0] == a[1] == a[2]):\n print(\"0\")\nelif(a[0] == a[1]) or (a[1] == a[2]) or (a[2] == a[0]):\n print(\"1\")\nelif(a[0][1] == a[1][1] == a[2][1]):\n if(int(a[0][0]) +1 == int(a[1][0])) and (int(a[1][0]) +1 == int(a[2][0])):\n print(\"0\")\n elif(int(a[0][0]) +2 >= int(a[1][0])) or (int(a[1][0]) +2 > int(a[2][0])):\n print(\"1\")\n else:\n print(\"2\")\nelif(a[0][1] == a[1][1]) or (a[1][1] == a[2][1]) or (a[2][1] == a[0][1]):\n if(a[0][1] == a[1][1]):\n if(int(a[0][0]) +2 >= int(a[1][0])):\n print(\"1\")\n else:\n print(\"2\")\n elif(a[1][1] == a[2][1]):\n if(int(a[1][0]) +2 >= int(a[2][0])):\n print(\"1\")\n else:\n print(\"2\") \n elif(a[2][1] == a[0][1]):\n if(int(a[0][0]) +2 >= int(a[2][0])):\n print(\"1\")\n else:\n print(\"2\") \n else:\n print(\"2\")\nelse:\n print(\"2\")"}, {"source_code": "def main():\n list_str = input().split()\n list_str.sort()\n\n \"\"\" p = ['3p', '5s', '5s'] (after sort)\n sorted by decimal its mean either ['3p','5p'] or ['5p','5p']\n near to koutsu, or whole string koutsu\n either 1,2,3.... 0 is impossible\"\"\"\n # if koutsu 2 or 3 then cannot be shuntsu\n koutsu_count = 1\n if list_str[0] == list_str[1] and list_str[1] == list_str[2]: # all equal\n koutsu_count = 3\n print('0')\n return # if koutsu 2 or 3 then cannot be shuntsu \n\n elif list_str[0] == list_str[1] or list_str[1] == list_str[2]: # either one equal\n koutsu_count = 2\n print('1')\n return # if koutsu 2 or 3 then cannot be shuntsu\n\n ###############################################\n shuntsu_count = 0\n \"\"\"\n 1s,5m,3s => after sort 1s,3s,5m\n 1s,5m,2s => after sort 1s,2s,5m\n 1s,2m,2s => after sort 1s,2m,2s\n\n so i guess better to digits\n\n 1,2,2\n s,m,s\n \"\"\"\n num = []\n lstr = []\n for e in list_str:\n num.append(int(e[0]))\n lstr.append(e[1])\n\n # sorted so smallest to largest\n\n if lstr[0] == lstr[1] and (num[0] == num[1]-1 or num[0] == num[1]-2):\n shuntsu_count += 1\n\n if lstr[0] == lstr[2] and (num[0] == num[2]-1 or num[0] == num[2]-2):\n shuntsu_count += 1\n\n if lstr[1] == lstr[2] and (num[1] == num[2]-1 or num[1] == num[2]-2):\n shuntsu_count += 1\n\n\n if shuntsu_count >= 3:\n print('0')\n elif shuntsu_count == 0:\n # atleast Count one of kind already\n print('2')\n else:\n print('1')\n\nmain()"}, {"source_code": "p = input().split()\np = set(p)\nans = 2\nlol = [0] * 3\nfor i1 in p:\n for i2 in p:\n if i1[1] == i2[1] and 1 <= int(i1[0]) - int(i2[0]) <= 2:\n if int(i1[0]) - int(i2[0]) == 1:\n lol[1] += 1\n else:\n lol[2] = 1\nans -= max(lol)\nans = min(ans, len(p) - 1)\nprint(max(0, ans))\n"}, {"source_code": "#573_B\n\nst = input().split(\" \")\n\nnums = sorted([[int(i[0]), i[1]] for i in st])\n\nif st[0] == st[1] and st[1] == st[2]:\n print(0)\nelif nums[0][1] == nums[1][1] and nums[1][1] == nums[2][1] and nums[0][0] == nums[1][0] - 1 and nums[1][0] == nums[2][0] - 1:\n print(0)\nelse:\n if nums[0][1] == nums[1][1] and nums[1][0] - nums[0][0] < 3:\n print(1)\n elif nums[1][1] == nums[2][1] and nums[2][0] - nums[1][0] < 3:\n print(1)\n elif nums[0][1] == nums[2][1] and nums[2][0] - nums[0][0] < 3:\n print(1)\n else:\n print(2)\n"}, {"source_code": "#d=[[] for i in range(26)]\na=[0]*26\nd={'p':[],'s':[],'m':[]}\nfor i in input().split():\n\td[i[1]]+=int(i[0]),\n\ta[ord(i[1])-97]+=1\nif max(a)==1:print(2)\nelse:\n\tx=chr(a.index(max(a))+97);v=[]\n\t\n\tif len(d[x])==2:\n\t\tg=abs(d[x][0]-d[x][1])\n\t\tif g==1 or g==0 or g==2:print(1)\n\t\telse:print(2)\n\telse:\n\t\tv+=abs(d[x][0]-d[x][1]),\n\t\tv+=abs(d[x][0]-d[x][2]),\n\t\tv+=abs(d[x][1]-d[x][2]),\n\t\tif v.count(0)>1:print(0)\n\t\telif v.count(0)==1:print(1)\n\t\telif v.count(1)==2:print(0)\n\t\telif v.count(1)==1 or v.count(2):print(1)\n\t\telse:print(2)"}, {"source_code": "s1,s2,s3=map(str,input().split())\narr=[]\narr.append(ord(s1[0]))\narr.append(ord(s2[0]))\narr.append(ord(s3[0]))\nflag=0\nif s1==s2 and s1==s3:\n flag=1\n print(0)\nif s1[1]==s2[1] and s1[1]==s3[1]:\n arr.sort()\n if arr[1]-arr[0]==1 and arr[2]-arr[1]==1:\n if flag==0:\n flag=1\n print(0)\nif (s1==s2 and s2!=s3) or (s2==s3 and s3!=s1) or (s1==s3 and s2!=s1):\n if flag==0:\n flag=1\n print(1)\nif (s1[1]==s2[1] and (abs(arr[1]-arr[0])==1 or abs(arr[1]-arr[0])==2)) or (s2[1]==s3[1] and (abs(arr[2]-arr[1])==1 or abs(arr[2]-arr[1])==2)) or (s1[1]==s3[1] and (abs(arr[2]-arr[0])==1 or abs(arr[2]-arr[0])==2)):\n if flag==0:\n flag=1\n print(1)\nif flag==0:\n print(2)\n \n \n "}, {"source_code": "a, b, c = input().split()\nt = sorted([(int(a[0]), a[1]), (int(b[0]), b[1]), (int(c[0]), c[1])])\n \nif t[0] == t[1] and t[1] == t[2]:\n print(0)\n exit(0)\n \nif t[0][1] == t[1][1] and t[1][1] == t[2][1] and t[0][0]+1 == t[1][0] and t[1][0]+1 == t[2][0]:\n print(0)\n exit(0)\n\nif t[0] == t[1]:\n print(1)\n exit(0)\n\nif t[1] == t[2]:\n print(1)\n exit(0)\n\nif t[0] == t[2]:\n print(1)\n exit(0)\n\nif t[0][1] == t[1][1] and t[0][0]+1 == t[1][0]:\n print(1)\n exit(0)\n \nif t[1][1] == t[2][1] and t[1][0]+1 == t[2][0]:\n print(1)\n exit(0)\n \nif t[0][1] == t[2][1] and t[0][0]+1 == t[2][0]:\n print(1)\n exit(0)\n\nif t[0][1] == t[1][1] and t[0][0]+2 == t[1][0]:\n print(1)\n exit(0)\n \nif t[1][1] == t[2][1] and t[1][0]+2 == t[2][0]:\n print(1)\n exit(0)\n \nif t[0][1] == t[2][1] and t[0][0]+2 == t[2][0]:\n print(1)\n exit(0)\n\nprint(2)"}, {"source_code": "m=[x for x in input().split()]\ntiles=[[0 for i in range(9)] for j in range(3)]\nfor i in range(len(m)):\n g=int(m[i][0])-1\n h=(m[i][1]) \n if h==\"m\":\n tiles[0][g]+=1\n elif h==\"p\":\n tiles[1][g]+=1\n else:\n tiles[2][g]+=1\nif m[0]==m[1] and m[1]==m[2]:\n print(0)\nelif m[0]==m[1]:\n print(1)\nelif m[0]==m[2]:\n print(1)\nelif m[1]==m[2]:\n print(1)\nelse:\n n=False\n for i in range(3):\n for j in range(9):\n if tiles[i][j]!=0:\n if j!=8 and tiles[i][j+1]!=0:\n if j!=7 and tiles[i][j+2]!=0:\n print(0)\n n=True\n break\n else:\n print(1)\n n=True\n break\n elif j!=7 and j!=8 and tiles[i][j+2]!=0:\n print(1)\n n=True\n break\n if n==False:\n print(2)"}, {"source_code": "a=[[0 for i in range(10)] for j in range(3)]\ns=input().split()\nm1=0\nfor i in s:\n k=int(i[0])\n \n if i[1]=='m':\n a[0][k]+=1\n \n m1=max(m1,a[0][k])\n elif i[1]=='p':\n a[1][k]+=1\n \n m1=max(m1,a[1][k])\n elif i[1]=='s':\n a[2][k]+=1\n \n m1=max(m1,a[2][k])\nm2=0\n\nfor i in range(3):\n for j in range(1,8):\n if a[i][j]>0:\n a[i][j]=1\n if a[i][j+1]>0:\n a[i][j+1]=1\n if a[i][j+2]>0:\n a[i][j+2]=1\n m2=max(a[i][j]+a[i][j+1]+a[i][j+2],m2)\nprint(min(3-m1,3-m2))\n \n "}, {"source_code": "x, y, z = map(str, input().split())\ns = set()\n\ns.add(x)\ns.add(y)\ns.add(z)\n\nf = 3\nif len(s)==1:\n print(0)\nelse:\n if len(s)==2:\n print(1)\n else:\n z = 0\n for t in s:\n d = s.copy()\n if int(t[0])<=7:\n d.add(f\"{int(t[0])+1}{t[1]}\")\n d.add(f\"{int(t[0])+2}{t[1]}\")\n else:\n d.add(\"dfdsf\")\n d.add(\"dfdf\")\n a = s.copy()\n if 1<=int(t[0])<=8:\n a.add(f\"{int(t[0])-1}{t[1]}\")\n a.add(f\"{int(t[0])+1}{t[1]}\")\n else:\n a.add(\"dfdsf\")\n a.add(\"dfdf\")\n b = s.copy()\n if int(t[0])>=2:\n b.add(f\"{int(t[0])-1}{t[1]}\")\n b.add(f\"{int(t[0])-2}{t[1]}\")\n else:\n b.add(\"dfdsf\")\n b.add(\"dfdf\")\n #print(d, b, a)\n if z:\n f = min(f, len(d), len(a), len(b))\n else:\n f = min(len(d), len(a), len(b))\n z+=1\n if f-3<0:\n print(0)\n else:\n print(f-3)\n\n"}, {"source_code": "n=list(map(str,input().split(\" \")))\n\nd=dict()\n\nmp = {\"m\":0 , \"p\":1 , \"s\":2}\n\nl=[0]*10\nll=[0]*10\nlll=[0]*10\narr = [l,ll,lll]\n\nmaxi=0\n\nfor i in n:\n\t# print(i)\n\tif (i in d.keys()):\n\t\td[i]+=1\n\t\tmaxi = max(maxi,d[i])\n\n\telse:\n\t\td[i]=1\n\t\tmaxi = max(maxi,d[i])\n\n\tarr[mp[i[1]]][int(i[0])-1] = 1\n\n\n# print(arr)\n# print(d)\nif(maxi>=3):\n\tprint(0)\nelse:\n\ttemp2 = 0\n\n\tfor i in range(3):\n\t\tansi=0\n\t\tprev2=arr[i][0]\n\t\tprev1=arr[i][1]\n\t\tfor j in range(10):\n\t\t\tif(j>=2 and prev2==1 and prev1==0 and arr[i][j]==1):\n\t\t\t\ttemp2=max(temp2,2)\n\t\t\tif(arr[i][j] ==0):\n\t\t\t\tansi=0\n\t\t\tif(arr[i][j]==1):\n\t\t\t\tansi+=arr[i][j]\n\t\t\t\ttemp2=max(ansi,temp2)\n\t\t\tprev2=prev1\n\t\t\tprev1=arr[i][j]\n\n\tfinalAns = min(3-maxi, 3-temp2)\n\tprint(finalAns)"}, {"source_code": "from collections import Counter\na,b,c=list(map(str,input().split()))\ns=[a[1],b[1],c[1]]\nt=[a[0],b[0],c[0]]\nu=Counter(s)\nv=Counter(t)\nif(len(u.keys())==1):\n\tif(len(v.keys())==1):\n\t\tprint(0)\n\telif(len(v.keys())==2):\n\t\tprint(1)\n\telse:\n\t\tt[0]=int(t[0])\n\t\tt[1]=int(t[1])\n\t\tt[2]=int(t[2])\n\t\tt.sort()\n\t\n\t\tif(t[0]+1==t[1] and t[2]-1==t[1]):\n\t\t\tprint(0)\n\t\telif(t[0]+1==t[1] or t[2]-1==t[1] or t[0]+2==t[1]):\n\t\t\tprint(1)\n\t\telse:\n\t\t\tprint(2)\nelse:\n\tif(len(u.keys())==3):\n\t\tprint(2)\n\telif(len(u.keys())==2):\n\t\tif(a[1]==b[1]):\n\t\t\tk=a\n\t\t\tj=b\n\n\t\telif(a[1]==c[1]):\n\t\t\tk=a\n\t\t\tj=c\n\t\t\n\t\telif(b[1]==c[1]):\n\t\t\tk=b\n\t\t\tj=c\n\t\n\t\tif(k[0]==j[0]):\n\t\t\tprint(1)\n\n\t\telse:\n\t\t\tif(abs(ord(k[0])-ord(j[0]))==1 or abs(ord(k[0])-ord(j[0]))==2 or abs(ord(k[0])-ord(j[0]))==0):\n\t\t\t\tprint(1)\n\t\t\telse:\n\t\t\t\tprint(2)\n "}, {"source_code": "s=list(input().split())\ns=sorted(s)\n\nif(len(set(s))==1):\n print(\"0\")\n\nelif(s[0][1]==s[1][1] and s[1][1]==s[2][1] and int(s[1][0])-int(s[0][0])==1 and int(s[2][0])-int(s[1][0])==1):\n print(\"0\")\nelif(len(set(s))==2):\n print(\"1\")\nelif(s[0][1]==s[1][1] and (int(s[1][0])-int(s[0][0])==1 or int(s[1][0])-int(s[0][0])==2) or (s[1][1]==s[2][1] and (int(s[2][0])-int(s[1][0])==1 or int(s[2][0])-int(s[1][0])==2)) or (s[0][1]==s[2][1] and (int(s[2][0])-int(s[0][0])==2 or int(s[2][0])-int(s[0][0])==1))):\n\n print(\"1\")\nelse:\n print(\"2\")\n"}, {"source_code": "a,b,c=map(str,input().split())\nl=[int(a[0]),int(b[0]),int(c[0])]\nl.sort()\nif(a==b and b==c):\n\tprint(0)\nelif(a==b or a==c or b==c):\n\tprint(1)\nelse:\n\tif(a[1]==b[1] and b[1]==c[1]):\n\t\tif (l[2]==l[1]+1 and l[1]==l[0]+1 ):\n\t\t\tprint(0)\n\t\telse:\n\t\t\tif(l[1]==l[0]+1 or l[2]==l[1]+1 or l[2]==l[0]+2 or l[1]==l[0]+2 or l[2]==l[1]+2):\n\t\t\t\tprint(1)\n\t\t\telse:\n\t\t\t\tprint(2)\n\telse:\n\t\tif(a[1]==b[1] or b[1]==c[1] or a[1]==c[1]):\n\t\t\tif(a[1]==b[1]):\n\t\t\t\tif (int(abs(int(a[0])-int(b[0])))<=2):\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2)\n\t\t\tif(a[1]==c[1]):\n\t\t\t\tif (int(abs(int(a[0])-int(c[0]))))<=2:\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2) \n\t\t\tif(b[1]==c[1]):\n\t\t\t\tif(int(abs(int(b[0])-int(c[0]))))<=2:\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2)\n\t\telse:\n\t\t\tprint(2)\n"}, {"source_code": "a,b,c = input().split();\nimport sys;\nx = int(a[0]);\ny = int(b[0]);\nz = int(c[0]);\nif(a==b==c):\n print(0);\n sys.exit();\nelse:\n arr = [x,y,z];\n arr.sort();\n if(a[1]==b[1]==c[1]):\n if((arr[1]-arr[0])==1 and (arr[2]-arr[1])==1):\n print(0);\n sys.exit();\n if((arr[1]-arr[0])==1 or (arr[1]-arr[0])==2 or (arr[1]-arr[0])==0):\n print(1);\n sys.exit();\n if((arr[2]-arr[1])==1 or (arr[2]-arr[1])==2 or (arr[2]-arr[1])==0):\n print(1);\n sys.exit();\n else:\n print(2);\n sys.exit();\n \n \n \n if(a[1]==b[1] or b[1]==c[1] or c[1]==a[1]):\n \n if(a[1]==b[1]):\n if(abs(x-y)==1 or abs(x-y)==2 or abs(x-y)==0):\n print(1);\n sys.exit();\n \n else:\n print(2);\n sys.exit();\n if(b[1]==c[1]):\n if(abs(y-z)==1 or abs(y-z)==2 or abs(y-z)==0):\n print(1);\n sys.exit();\n else:\n print(2);\n sys.exit();\n if(a[1]==c[1]):\n if(abs(x-z)==1 or abs(x-z)==2 or abs(x-z)==0):\n print(1);\n sys.exit();\n else:\n print(2);\n sys.exit();\n else:\n print(2);\n sys.exit();\n\n else:\n print(2);\n sys.exit();\n\n\n"}, {"source_code": "b=list(input().split())\na=b[0]\nc=b[1]\nd=b[2]\np=[int(a[0]),int(c[0]),int(d[0])]\np.sort()\nif a[1]==c[1]:\n if a[1]==d[1]:\n k=p[1]-p[0]\n q=p[2]-p[1]\n if k==0 and q==0:\n print(0)\n elif k==0 or q==0:\n print(1)\n elif k==1 and q==1:\n print(0)\n elif k==1 or q==1:\n print(1)\n elif k==2 or q==2:\n print(1)\n else:\n print(2)\n else:\n if int(a[0])==int(c[0]):\n print(1)\n elif abs(int(a[0])-int(c[0]))<=2:\n print(1)\n else:\n print(2)\nelse:\n if c[1]==d[1]:\n if int(c[0]) == int(d[0]):\n print(1)\n elif abs(int(c[0]) - int(d[0]))<= 2:\n print(1)\n else:\n print(2)\n elif a[1]==d[1]:\n if int(a[0]) == int(d[0]):\n print(1)\n elif abs(int(a[0]) - int(d[0]))<= 2:\n print(1)\n else:\n print(2)\n else:\n print(2)\n\n\n\n\n\n\n"}, {"source_code": "a,b,c=sorted(6*ord(y)+int(x)for x,y in input().split())\ns={b-a,c-b}\nprint(2-bool(s&{0,1,2})-(s<{0,1}))"}, {"source_code": "a=list(map(str,input().split()));l=a\ns=m=p=0;s1,m1,p1=[],[],[]\nfor i in a:\n if 's' in i:s+=1;s1+=[int(i[0])]\n elif 'p' in i:p+=1;p1+=[int(i[0])]\n else:m+=1;m1+=[int(i[0])]\nif m and s and p:print(2)\nelif len(set(a))==1:print(0)\nelif max(s,m,p)==3:\n if s==3:a=s1\n elif m==3:a=m1\n else:a=p1\n a=sorted(a);r=2\n if a[1]-a[0]==a[2]-a[1]==1:r=0\n elif a[1]-a[0] in [1,2] or a[2]-a[1] in [1,2]:r=1\n else:r=2\n if len(set(l))==2:r=min(r,1)\n print(r)\nelse:\n if s==2:a=s1\n elif p==2:a=p1\n else:a=m1\n a=sorted(a)\n if a[1]-a[0]==1 or a[1]-a[0]==2:print(1)\n else:\n if len(set(l))==2:print(1)\n else:print(2)"}, {"source_code": "# your code goes here\ntiles = input().split(' ')\ntiles.sort()\nans = 2\nsq = 0\n\nif (tiles[0] == tiles[1] and tiles[1] == tiles[2]):\n\tans = 0\nelif (tiles[0] != tiles[1] and tiles[1] != tiles[2]):\n\tif(tiles[0][1] == tiles[1][1]):\n\t\tif(int(tiles[0][0]) >= int(tiles[1][0]) - 2):\n\t\t\tans = 1\n\t\t\tif(int(tiles[0][0]) == int(tiles[1][0]) - 1):\n\t\t\t\tsq = 1\n\t\t\t\t\n\tif(tiles[1][1] == tiles[2][1]):\n\t\tif(int(tiles[1][0]) == int(tiles[2][0]) - 1):\n\t\t\tans = 1\n\t\t\tif(sq):\n\t\t\t\tans = 0\n\t\tif(int(tiles[1][0]) == int(tiles[2][0]) - 2):\n\t\t\tans = 1\n\t\t\t\n\tif(tiles[0][1] == tiles[2][1]):\n\t\tif(int(tiles[0][0]) >= int(tiles[2][0]) - 2 and sq != 1):\n\t\t\tans = 1\nelse:\n\tans = 1\n\nprint(ans)"}, {"source_code": "la = sorted(input().split())\nres = 2\nif int(la[0][0]) == int(la[1][0]) - 1 == int(la[2][0]) - 2:\n if la[0][1] == la[1][1] == la[2][1]:\n res = 0\n elif la[0][1] == la[1][1] or la[1][1] == la[2][1] or la[0][1] == la[2][1]:\n res = 1\nelif la[0][0] == la[1][0] == la[2][0]:\n if la[0][1] == la[1][1] == la[2][1]:\n res = 0\n elif la[0][1] == la[1][1] or la[1][1] == la[2][1] or la[0][1] == la[2][1]:\n res = 1\nelse:\n if int(la[0][0]) == int(la[1][0]) - 2:\n if la[0][1] == la[1][1]:\n res = 1\n if int(la[1][0]) == int(la[2][0]) - 2:\n if la[1][1] == la[2][1]:\n res = 1\n if int(la[0][0]) == int(la[2][0]) - 2:\n if la[0][1] == la[2][1]:\n res = 1\n if int(la[0][0]) == int(la[2][0]) - 1:\n if la[0][1] == la[2][1]:\n res = 1\n if int(la[1][0]) == int(la[2][0]) - 1:\n if la[1][1] == la[2][1]:\n res = 1\n if int(la[0][0]) == int(la[1][0]) - 1:\n if la[0][1] == la[1][1]:\n res = 1\n if int(la[0][0]) == int(la[1][0]):\n if la[0][1] == la[1][1]:\n res = 1\n if int(la[1][0]) == int(la[2][0]):\n if la[1][1] == la[2][1]:\n res = 1\n if int(la[0][0]) == int(la[2][0]):\n if la[0][1] == la[2][1]:\n res = 1\nprint(res)\n"}, {"source_code": "a = input().split()\nres = 2\nfor i in range(1, 10):\n for j in \"smp\":\n res = min(res, 3 - (str(i) + j in a) -\n (str(i + 1) + j in a) - (str(i + 2) + j in a))\n res = min(res, 3 - a.count(str(i) + j))\n\nprint(res)\n"}, {"source_code": "s = input().split()\nb = []\nb.append((s[0][1], int(s[0][0])))\nb.append((s[1][1], int(s[1][0])))\nb.append((s[2][1], int(s[2][0])))\nb.sort()\nif (b[0][0] == b[1][0] and b[1][0] == b[2][0]):\n if (b[0] == b[1] and b[1] == b[2]):\n print(0)\n elif (b[0][1] + 1 == b[1][1] and b[1][1] + 1 == b[2][1]):\n print(0)\n elif (b[0] == b[1]):\n print(1)\n elif (b[1] == b[2]):\n print(1)\n elif b[0][1] + 1 == b[1][1]:\n print(1)\n elif b[0][1] + 2 == b[1][1]:\n print(1)\n elif b[1][1] + 1 == b[2][1]:\n print(1)\n elif b[1][1] + 2 == b[2][1]:\n print(1)\n elif b[0][1] + 1 == b[2][1]:\n print(1)\n elif b[0][1] + 2 == b[2][1]:\n print(1)\n else:\n print(2)\nelif (b[0][0] != b[1][0] and b[1][0] != b[2][0] and b[2][0] != b[0][0]):\n print(2)\nelif b[0][0] == b[1][0]:\n if b[0] == b[1]:\n print(1)\n elif b[0][1] + 1 == b[1][1]:\n print(1)\n elif b[0][1] + 2 == b[1][1]:\n print(1)\n else:\n print(2)\nelif b[1][0] == b[2][0]:\n if (b[1] == b[2]):\n print(1)\n elif b[1][1] + 1 == b[2][1]:\n print(1)\n elif b[1][1] + 2 == b[2][1]:\n print(1)\n else:\n print(2)\nelse:\n print(2)\n \n"}, {"source_code": "\na = input().split()\na.sort()\nif len(set(a)) == 1:\n print(0)\nelif len(set(a)) == 2:\n print(1)\nelse:\n d = {}\n for i in a:\n n = int(i[0])\n c = i[1]\n if c in d:\n d[c].append(n)\n else:\n d[c] = [n]\n \n\n v = list(d.values())\n cond0 = False\n cond1 = False\n # print (d,v) \n for i in v:\n if len(i) == 2:\n i = sorted(i)\n x = i[0]\n y = i[1]\n if x + 1 == y or y - x == 2:\n cond1 = True\n if len(i) == 3:\n i = sorted(i)\n x = i[0]\n y = i[1]\n z = i[2]\n if x + 1 == y and y + 1 == z:\n cond0 = True\n \n if (x+1 == y) or (x+2 == y) or (y+2 ==z) or (y+1 ==z):\n cond1 = True\n \n if cond0:\n print(0)\n elif cond1:\n print(1)\n else:\n print(2)"}, {"source_code": "import collections\n\nnums = list(map(str,input().split()))\n\ndd = collections.defaultdict(int)\n\nfor i in nums:\n \tdd[i] += 1\n\n \tif dd[i] == 3:\n \t\tprint(0)\n \t\texit()\n\nfor key in dd:\n \tif dd[key] == 2:\n \t\tprint(1)\n \t\texit()\n\n \telse:\n \t\ttk0 = str(int(key[0]) + 1) + key[1]\n \t\ttk1 = str(int(key[0]) + 2) + key[1]\n \t\ttk2 = str(int(key[0]) - 1) + key[1]\n \t\ttk3 = str(int(key[0]) - 2) + key[1]\n\n \t\tif tk1 in dd and tk0 in dd:\n \t\t\tprint(0)\n \t\t\texit()\n \t\telif tk0 in dd and tk2 in dd:\n \t\t\tprint(0)\n \t\t\texit()\n\n \t\telif tk2 in dd and tk3 in dd:\n \t\t\tprint(0)\n \t\t\texit()\n\n \t\telif tk0 in dd or tk1 in dd or tk2 in dd or tk3 in dd:\n \t\t\tprint(1)\n \t\t\texit()\n\nprint(2)\nexit()\n"}, {"source_code": "def same(nums):\n curr = nums[0]\n for i in nums:\n if i != curr:\n return False\n\n return True\n\ndef increasing(nums):\n for i in range(1,len(nums)):\n if nums[i]-nums[i-1] != 1:\n return False\n\n return True\n\ndef main():\n cards = list(map(str,input().split()))\n letters = {}\n #print(cards)\n for i in cards:\n if i[1] not in letters.keys():\n letters[i[1]] = [int(i[0])]\n else:\n letters[i[1]].append(int(i[0]))\n\n \n for i in letters.keys():\n letters[i].sort()\n\n if len(letters) == 1:\n for i in letters.keys():\n if same(letters[i]):\n print(0)\n return\n if increasing(letters[i]):\n print(0)\n return\n\n if (letters[i][0] == letters[i][1]) or (letters[i][1] == letters[i][2]):\n print(1)\n return\n diff1 = letters[i][1]-letters[i][0]\n diff2 = letters[i][2]-letters[i][1]\n if diff1 == 1 or diff2 == 1 or diff1 == 2 or diff2 == 2:\n print(1)\n return\n print(2)\n\n elif len(letters) == 2:\n for i in letters.keys():\n if len(letters[i]) == 2:\n if letters[i][0] == letters[i][1]:\n print(1)\n return\n diff1 = letters[i][1]-letters[i][0]\n if diff1 == 1 or diff1 == 2:\n print(1)\n return\n print(2)\n\n else:\n print(2)\n\n\nmain()\n"}, {"source_code": "def for_k(l):\n if not l:\n return 3\n d = []\n for e in l:\n d.append(l.count(e))\n return max(3 - max(d), 0)\n\ndef for_s(l):\n t = [0 for _ in range(9)]\n if not l:\n return 3\n numbas = []\n for e in l:\n if e not in numbas:\n numbas.append(int(e[0]))\n \n if any([numbas[i] + 1 == numbas[i + 1] and numbas[i + 2] == numbas[i + 1] + 1 for i in range(len(numbas) - 2)]):\n return 0\n elif any([numbas[i] + 1 == numbas[i + 1] for i in range(len(numbas) - 1)]):\n return 1\n else:\n for n in numbas:\n t[n - 1] = 1\n \n gaps = []\n buff = 0\n for i in range(t.index(1), len(t)):\n if t[i] == 0:\n buff += 1\n else:\n if buff:\n gaps.append(buff)\n buff = 0\n\n if not gaps:\n return 2\n \n if min(gaps) >= 2:\n return 2\n elif min(gaps) == 1:\n return 1\n\n \n\na = input().split()\n\na.sort(key=lambda x: (x[1], x[0]))\n\nx = []\ny = []\nz = []\n\nfor e in a:\n if e[1] == 'm':\n x.append(e)\n elif e[1] == 'p':\n y.append(e)\n else:\n z.append(e)\n\n\nhello = []\nfor thing in (x, y, z):\n hello.append(for_s(thing))\n hello.append(for_k(thing))\n\nprint(min(hello))"}, {"source_code": "a, b, c = input().split()\ny = sorted([a[0], b[0], c[0]])\ny1 = [int(y[i + 1]) - int(y[i]) for i in range(2)]\ny2 = sorted([a[1], b[1], c[1]])\nif len(set(y2)) == 1:\n if set(y1) == {0}:\n print(0)\n elif set(y1) == {1}:\n print(0)\n elif 0 in set(y1) or 1 in set(y1) or 2 in set(y1):\n print(1)\n else:\n print(2)\nelif len(set(y2)) == 2:\n x = sorted([a, b, c], key=lambda m: m[1])\n if x[0][1] == x[1][1]:\n if int(x[0][0])-int(x[1][0]) == 0 or abs(int(x[1][0])-int(x[0][0])) == 1 or abs(int(x[1][0])-int(x[0][0])) == 2:\n print(1)\n else:\n print(2)\n elif x[1][1] == x[2][1]:\n if int(x[1][0])-int(x[2][0]) == 0 or abs(int(x[2][0])-int(x[1][0])) == 1 or abs(int(x[2][0])-int(x[1][0])) == 2:\n print(1)\n else:\n print(2)\n else:\n print(2)\nelse:\n print(2)\n"}, {"source_code": "a, b, c = sorted(input().split(), key = lambda x: int(x[0]))\n\nif a == b == c: print(0)\nelif a[1] == b[1] == c[1] and int(a[0])+2 == int(b[0])+1 == int(c[0]): print(0)\nelif a == b or b == c or c == a: print(1)\nelif a[1] == b[1] and (int(a[0])+1 == int(b[0]) or int(a[0])+2 == int(b[0])): print(1)\nelif b[1] == c[1] and (int(b[0])+1 == int(c[0]) or int(b[0])+2 == int(c[0])): print(1)\nelif a[1] == c[1] and (int(a[0])+1 == int(c[0]) or int(a[0])+2 == int(c[0])): print(1)\nelse: print(2)"}, {"source_code": "l=input().split()\n\nl=sorted(l)\n# print(l)\nif(l[0]==l[1]==l[2]):\n print(0)\nelif(l[0][1]==l[1][1]==l[2][1]):\n if(int(l[0][0])+1==int(l[1][0]) and int(l[0][0])+2==int(l[2][0])):\n print(0)\n elif(int(l[1][0])-int(l[0][0])<=2):\n print(1)\n elif(int(l[2][0])-int(l[0][0])<=2):\n print(1)\n elif(int(l[2][0])-int(l[1][0])<=2):\n print(1)\n else:\n print(2)\nelif(l[0][1]==l[1][1]):\n if(int(l[1][0])-int(l[0][0])<=2):\n print(1)\n else:\n print(2)\nelif(l[0][1]==l[2][1]):\n if(int(l[2][0])-int(l[0][0])<=2):\n print(1)\n else:\n print(2)\n\nelif(l[1][1]==l[2][1]):\n if(int(l[2][0])-int(l[1][0])<=2):\n print(1)\n else:\n print(2)\nelse:\n print(2)\n \n"}, {"source_code": "cards = input().split()\nm = []\ns = []\np = []\n\nfor i in range(3):\n if cards[i][1] == \"m\":\n m.append(int(cards[i][0]))\n elif cards[i][1] == \"s\":\n s.append(int(cards[i][0]))\n elif cards[i][1] == \"p\":\n p.append(int(cards[i][0]))\n\nmsp = [m, s, p]\nrmsp = [len(m), len(s), len(p)]\n\nif rmsp[0] == rmsp[1] == rmsp[2]:\n print(2)\n\n\ndef con3(seq):\n seq.sort()\n new_seq = [seq[1]-seq[0], seq[2]-seq[0]]\n n_seq = new_seq[1] - new_seq[0]\n if new_seq == [1,2] or new_seq == [0,0]:\n print(0)\n elif new_seq[0] == 1 or new_seq[1] == 1 or n_seq == 0 or n_seq == 1 or n_seq == 2 or new_seq[0] == 2 or new_seq[1] == 2 or new_seq[0] == 0:\n print(1)\n else:\n print(2)\n\n\ndef con2(seq):\n cons = abs(seq[1] - seq[0])\n if cons == 0 or cons == 1 or cons == 2:\n print(1)\n else:\n print(2)\n\n\nfor i in range(3):\n if rmsp[i] == 3:\n con3(msp[i])\n break\n elif rmsp[i] == 2:\n val2 = msp[i]\n con2(val2)\n break\n\n\n\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\n\ndef getN():\n return int(input())\ndef getList():\n return list(map(int, input().split()))\nimport math\n\n\ndef main():\n # something\n pie = input().split()\n man = []\n pin = []\n soh = []\n for p in pie:\n if p.endswith(\"p\"):\n pin.append(p)\n elif p.endswith(\"s\"):\n soh.append(p)\n else:\n man.append(p)\n\n ans = 2\n for mark in [man, pin, soh]:\n # print(mark)\n nums = sorted([int(m[0]) for m in mark])\n if len(mark) <= 1:\n pass\n\n elif len(mark) == 2:\n # print(\"here\")\n\n if mark[0] == mark[1]:\n ans = 1\n if nums[1] - nums[0] <= 2:\n ans = 1\n\n else:\n # print(\"nohre\")\n # print(mark)\n if nums[0] == nums[1] and nums[1] == nums[2]:\n ans = 0\n break\n if nums[1] - nums[0] == 1:\n if nums[2] - nums[1] == 1:\n ans = 0\n else:\n ans = 1\n break\n\n if nums[2] - nums[1] == 1:\n if nums[1] - nums[0] == 1:\n ans = 0\n else:\n ans = 1\n break\n\n if nums[1] - nums[0] == 2 or nums[2] - nums[1] == 2:\n ans = 1\n break\n\n if len(list(set(nums))) == 2:\n ans = 1\n break\n\n print(ans)\n\n\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "a=input().split()\nb=[a[0][1],a[1][1],a[2][1]]\nc=sorted([int(a[0][0]),int(a[1][0]),int(a[2][0])])\nd=len(list(set(a)))\ne=len(list(set(b)))\nif e==1:\n if d==1:\n print(0)\n elif d==2:\n print(1)\n elif d==3:\n if c[1]-c[0]==1 and c[2]-c[1]==1:\n print(0)\n elif c[1]-c[0]==1 or c[2]-c[1]==1 or c[1]-c[0]==2 or c[2]-c[1]==2:\n print(1)\n else:\n print(2)\nelif e==3:\n print(2)\nelif e==2:\n a.sort()\n if d==2:\n print(1)\n elif a[0][1]==a[1][1]:\n if int(a[1][0])-int(a[0][0])==1 or int(a[1][0])-int(a[0][0])==2:\n print(1)\n else:\n print(2)\n elif a[1][1]==a[2][1]:\n if int(a[2][0])-int(a[1][0])==1 or int(a[2][0])-int(a[1][0])==2:\n print(1)\n else:\n print(2)\n elif a[0][1]==a[2][1]:\n if int(a[2][0])-int(a[0][0])==1 or int(a[2][0])-int(a[0][0])==2:\n print(1)\n else:\n print(2)"}, {"source_code": "s=input()\na=s[0:2]\nb=s[3:5]\nc=s[6]+s[7]\nl=[int(a[0]),int(b[0]),int(c[0])]\nl.sort()\nif(a==b and a==c):\n print(0)\nelif(l[1]==l[0]+1 and l[2]==l[0]+2 and a[1]==b[1] and a[1]==c[1]):\n print(0)\nelif((a==b and a!=c) or (a==c and a!=b) or (b==c and b!=a)):\n print(1)\nelif(l[1]==l[0]+1 or l[2]==l[1]+1):\n \n if(abs(int(a[0])-int(b[0]))==1 and a[1]==b[1]):\n print(1)\n elif(abs(int(b[0])-int(c[0]))==1 and b[1]==c[1]):\n print(1)\n elif(abs(int(a[0])-int(c[0]))==1 and a[1]==c[1]):\n print(1)\n elif(l[2]==l[0]+2 or l[1]==l[0]+2 or l[2]==l[1]+2):\n if(abs(int(a[0])-int(b[0]))==2 and a[1]==b[1]):\n print(1)\n elif(abs(int(b[0])-int(c[0]))==2 and b[1]==c[1]):\n print(1)\n elif(abs(int(a[0])-int(c[0]))==2 and a[1]==c[1]):\n print(1)\n else:\n print(2)\n else:\n print(2)\n \nelif(l[2]==l[0]+2 or l[1]==l[0]+2 or l[2]==l[1]+2):\n if(abs(int(a[0])-int(b[0]))==2 and a[1]==b[1]):\n print(1)\n elif(abs(int(b[0])-int(c[0]))==2 and b[1]==c[1]):\n print(1)\n elif(abs(int(a[0])-int(c[0]))==2 and a[1]==c[1]):\n print(1)\n else:\n print(2)\nelif(l[2]==l[1]+1 and((a[1]==b[1] and a!=c) or (b[1]==c[1] and b!=a) or (a[1]==c[1] and a!=b))):\n print(1)\nelse:\n print(2)"}, {"source_code": "def smaller(x, y):\n\tif x < y:\n\t\treturn x\n\treturn y\n\ndef kohtsu(a, b, c):\n\tif a == b:\n\t\tif b == c:\n\t\t\treturn 0\n\t\telse:\n\t\t\treturn 1\n\treturn 2\n\ndef shuntsu(a, b, c):\n\tif a[1] == b[1]:\n\t\tif int(a[0])+2 == int(b[0]):\n\t\t\tif (c[1] == a[1]) and (int(a[0])+1 == int(c[0])):\n\t\t\t\treturn 0\n\t\t\telse:\n\t\t\t\treturn 1\n\t\tif int(a[0])+1 == int(b[0]):\n\t\t\tif (c[1] == a[1]) and (int(a[0])-1 == int(c[0]) or int(b[0])+1 == int(c[0])):\n\t\t\t\treturn 0\n\t\t\telse:\n\t\t\t\treturn 1\n\treturn 2\n\ninpt = input().split()\nans = 2\nans = smaller(ans, kohtsu(inpt[0], inpt[1], inpt[2]))\nans = smaller(ans, shuntsu(inpt[0], inpt[1], inpt[2]))\nans = smaller(ans, kohtsu(inpt[0], inpt[2], inpt[1]))\nans = smaller(ans, shuntsu(inpt[0], inpt[2], inpt[1]))\nans = smaller(ans, kohtsu(inpt[1], inpt[0], inpt[2]))\nans = smaller(ans, shuntsu(inpt[1], inpt[0], inpt[2]))\nans = smaller(ans, kohtsu(inpt[1], inpt[2], inpt[0]))\nans = smaller(ans, shuntsu(inpt[1], inpt[2], inpt[0]))\nans = smaller(ans, kohtsu(inpt[2], inpt[0], inpt[1]))\nans = smaller(ans, shuntsu(inpt[2], inpt[0], inpt[1]))\nans = smaller(ans, kohtsu(inpt[2], inpt[1], inpt[0]))\nans = smaller(ans, shuntsu(inpt[2], inpt[1], inpt[0]))\n\nprint(ans)"}, {"source_code": "t = input().strip().split()\n\nm = 3\n\nfor i in range(1, 8):\n for j in 'mps':\n r = 3\n if str(i) + j in t: r -= 1\n if str(i+1) + j in t: r -= 1\n if str(i+2) + j in t: r -= 1\n m = min(m, r)\n\nprint(min(m, len(set(t)) - 1))\n"}, {"source_code": "a, b, c = map(str, input().split())\na0, b0, c0 = int(a[0]), int(b[0]), int(c[0])\nl = [a0, b0, c0]\nl.sort()\nmx, mn = max(a0, b0, c0), min(a0, b0, c0)\nif a == b == c or (l[2] - l[1] == 1 and l[1] - l[0] == 1 and a[1] == b[1] == c[1]):\n print(0)\nelse:\n if (abs(a0 - b0) <= 2 and a[1] == b[1]) or (abs(c0 - b0) <= 2 and c[1] == b[1]) or (abs(a0 - c0) <= 2 and a[1] == c[1]):\n print(1)\n else:\n print(2)"}, {"source_code": "a, b, c = input().split()\na = a[::-1]\nb = b[::-1]\nc = c[::-1]\na1 = int(a[1])\nb1 = int(b[1])\nc1 = int(c[1])\nk = [a1, b1, c1]\nk.sort()\nif a == b == c:\n print(0)\nelif a == b or b == c or a == c:\n print(1)\nelif a[0] == b[0] == c[0] and k[0] == k[1] - 1 == k[2] - 2:\n print(0)\nelif (a[0] == b[0] and abs(a1 - b1) <= 2) or (a[0] == c[0] and abs(a1 - c1) <= 2) or (c[0] == b[0] and abs(c1 - b1) <= 2):\n print(1)\nelse:\n print(2)"}, {"source_code": "a = input().split()\nres = 2\nfor i in range(1, 10):\n for j in \"smp\":\n #print(str(i) + j, 3 - (str(i) + j in a) - (str(i+1) + j in a) - (str(i+2) + j in a))\n res = min(res, 3 - (str(i) + j in a) - (str(i+1) + j in a) - (str(i+2) + j in a))\n res = min(res, 3 - a.count(str(i) + j))\nprint(res)"}, {"source_code": "l = list(input().split())\nfor i in range(3):\n l[i] = [l[i][1],l[i][0]]\nl.sort()\nfor i in range(3):\n l[i] = [l[i][1],l[i][0]]\n#print(l)\nflag = 0\nif l[0] == l[1]:\n if l[1] == l[2]:\n print(0)\n else:\n print(1)\nelif l[1] == l[2]:\n print(1)\nelif l[0][1] == l[1][1]:\n if abs(int(l[1][0]) - int(l[0][0])) == 1:\n if l[2][1] == l[1][1]:\n if abs(int(l[2][0]) - int(l[1][0])) == 1:\n print(0)\n else:\n print(1)\n else:\n print(1)\n elif abs(int(l[1][0]) - int(l[0][0])) == 2:\n print(1)\n else:\n flag = 1\nelse:\n flag = 1\nif flag == 1:\n if l[1][1] == l[2][1]:\n #print(int(l[2][0]) - int(l[1][0]))\n if abs(int(l[2][0]) - int(l[1][0])) <= 2:\n print(1)\n else:\n print(2)\n else:\n print(2)\n"}, {"source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import setcheckinterval, stdin\nsetcheckinterval(1000)\n\n# print(\"Case #{}: {} {}\".format(i, n + m, n * m))\n\niin = lambda: int(stdin.readline())\nlin = lambda: list(map(int, stdin.readline().split()))\n\ndef check1(a):\n if not a:\n return 3\n n=len(a)\n ans=1 \n for i in range(n):\n sola={a[i]:1}\n if a[i]+1<10:\n sola[a[i]+1]=0\n if a[i]+2<10:\n sola[a[i]+2]=0\n if a[i]-1>0:\n sola[a[i]-1]=0\n if a[i]-2>0:\n sola[a[i]-2]=0\n j=i+1\n while j<n:\n try:\n sola[a[j]]=1 \n except:pass \n j+=1\n if a[i]-1 in sola and a[i]-2 in sola:\n ans=max(ans,sola[a[i]]+sola[a[i]-1]+sola[a[i]-2])\n if a[i]-1 in sola and a[i]+1 in sola:\n ans=max(ans,sola[a[i]]+sola[a[i]-1]+sola[a[i]+1])\n if a[i]+1 in sola and a[i]+2 in sola:\n ans=max(ans,sola[a[i]]+sola[a[i]+1]+sola[a[i]+2])\n \n return 3-ans\n\ndef check2(a):\n if not a:return 3\n d={}\n for i in a:\n try:\n d[i]+=1\n except:\n d[i]=1\n return 3-max(d.values()) \n\n\n\n\ns=input().split()\na1=[];a2=[];a3=[]\n\nfor i in s:\n if i[1]=='m':\n a1.append(int(i[0]))\n elif i[1]=='p':\n a2.append(int(i[0]))\n elif i[1]=='s':\n a3.append(int(i[0]))\na1.sort()\na2.sort()\na3.sort()\n\nans=min(check1(a1),check1(a2),check1(a3),check2(s))\nprint(ans)\n# print(check1(a1),check1(a2),check1(a3),check2(s),a1,a2,a3)"}, {"source_code": "def f(a, b, c):\n if a[0] > b[0]:\n a, b = b, a\n if abs(int(a[0]) - int(b[0])) == 1 and a[1] == b[1]:\n if a[1] == c[1] and abs(int(c[0]) - int(b[0])) == 1 and a != c:\n return 0\n else:\n return 1\n if abs(int(a[0]) - int(b[0])) == 2 and a[1] == b[1]:\n return 1\n return 2\n\n\na, b, c = input().split()\ns1 = set()\ns1.add(a)\ns1.add(b)\ns1.add(c)\nc1 = len(s1) - 1\nprint(min(c1, f(a, b, c), f(a, c, b), f(b, c, a)))\n"}, {"source_code": "import sys,math\n\ndef read_int():\n return int(sys.stdin.readline().strip())\n\ndef read_int_list():\n return list(map(int,sys.stdin.readline().strip().split()))\n\ndef read_string():\n return sys.stdin.readline().strip()\n\ndef read_string_list(delim=\" \"):\n return sys.stdin.readline().strip().split(delim)\n\ndef print_list(l, delim=\" \"):\n print(delim.join(map(str, l)))\n\n\n###### Author : Samir Vyas #######\n###### Write Code Below #######\n\ntiles = read_string_list()\n\n#all equal\nif tiles[0] == tiles[1] == tiles[2]:\n\tprint(0)\n\tsys.exit()\n\n#any two equal\nif tiles[0] == tiles[1] or tiles[1] == tiles[2] or tiles[2] == tiles[0]:\n\tprint(1)\n\tsys.exit()\n\nmps = {\"m\":[], \"p\":[], \"s\":[]}\n\nfor t in tiles:\n\tmps[t[1]] += [int(t[0])]\n\nfor k in mps:\n\tmps[k].sort()\n\n#3 of same\nfor k in mps:\n\tif len(mps[k]) == 3:\n\t\tl = mps[k]\n\t\tif l[0]+1 == l[1] and l[1]+1 == l[2]:\n\t\t\tprint(0)\n\t\t\tsys.exit()\n\t\tif l[1]-l[0] <= 2 or l[2]-l[1] <= 2:\n\t\t\tprint(1)\n\t\t\tsys.exit()\n\n#2 of same\nfor k in mps:\n\tif len(mps[k]) == 2:\n\t\tl = mps[k]\n\t\tif l[1]-l[0] <=2 :\n\t\t\tprint(1)\n\t\t\tsys.exit()\n\n#no luck\nprint(2)\n\n"}, {"source_code": "li = list(map(str,input().split()))\nlis=[ i[1]+i[0] for i in li]\nlis.sort()\nans=[]\nans.append(1)\nfor i in range(1,len(lis)):\n if lis[i]==lis[i-1]:\n ans[-1]+=1\n else:\n ans.append(1)\nan=min(max(ans),3)\n#print(ans,lis)\nif an==3:\n print('0')\n exit()\nans=[]\nans.append(1)\nfor i in range(1,len(lis)):\n if lis[i]==lis[i-1]:\n continue\n if int(lis[i][1])==int(lis[i-1][1])+1 and lis[i][0]==lis[i-1][0]:\n ans[-1]+=1\n elif int(lis[i][1])==int(lis[i-1][1])+2 and lis[i][0]==lis[i-1][0]:\n ans.append(2)\n ans.append(1)\n else:\n ans.append(1)\nprint(3-min(3,max(max(ans),an))) \n\n"}, {"source_code": "# Main\n\ndata = [x for x in raw_input().split(\" \")]\nsol = None\n\nif len(set(data)) == 1:\n\tsol = 0\n\nelif data[0][1] == data[1][1] and data[0][1] == data[2][1]:\n\tnums = [int(data[0][0]), int(data[1][0]), int(data[2][0])]\n\tnums.sort()\n\tif nums[0] == nums[1] - 1:\n\t\tif nums[1] == nums[2] - 1:\n\t\t\tsol = 0\n\t\telse:\n\t\t\tsol = 1\n\telse:\n\t\tif nums[1] == nums[2] - 1:\n\t\t\tsol = 1\n\nelif len(set(data)) == 2:\n\tif sol != 0:\n\t\tsol = 1\n\t\t\n\t\t\n# I think this entire block is redundants since I handled it in the \n# check above... That said, I don't think it'll hurt - worst case if\n# I'm right, it'll just fire down this branch in the case of a 2\n\nif sol == None:\n\tif data[0][1] == data[1][1]:\n\t\tif abs(int(data[0][0]) - int(data[1][0])) <= 2:\n\t\t\t# they're off by one and we only need one more piece\n\t\t\tsol = 1\n\t\n\tif data[0][1] == data[2][1]:\n\t\tif abs(int(data[0][0]) - int(data[2][0])) <= 2:\n\t\t\t# they're off by one and we only need one more piece\n\t\t\tsol = 1\n\t\n\tif data[1][1] == data[2][1]:\n\t\tif abs(int(data[1][0]) - int(data[2][0])) <= 2:\n\t\t\t# they're off by one and we only need one more piece\n\t\t\tsol = 1\n\nif sol == None:\n\tsol = 2\n\nprint sol"}, {"source_code": "tiles = {\n\t'm': [],\n\t'p': [],\n\t's': []\n}\nfor tile in input().split():\n\ttiles[tile[1]].append(int(tile[0]))\nmax_ava = 0\nfor suit in tiles:\n\t# max for seq\n\tfor x in range(1, 10):\n\t\tseq = 0\n\t\tif x in tiles[suit]:\n\t\t\tseq += 1\n\t\tif x+1 in tiles[suit]:\n\t\t\tseq += 1\n\t\tif x+2 in tiles[suit]:\n\t\t\tseq += 1\n\t\tmax_ava = max(max_ava, seq)\n\t# max for grp\n\tfor x in range(1, 10):\n\t\tcount = tiles[suit].count(x)\n\t\tmax_ava = max(max_ava, count)\nprint(3 - max_ava)"}, {"source_code": "a,b,c = input().split()\nif (a==b and b==c):\n\tprint (0)\n\texit()\nx = sorted([int(a[0]),int(b[0]),int(c[0])])\nif (a[1]==b[1] and b[1]==c[1]) and (x[0]+1==x[1] and x[1]+1==x[2]):\n\tprint (0)\n\texit()\nif a==b or b==c or a==c:\n\tprint (1)\n\texit()\nd = {\"p\":[],\"m\":[],\"s\":[]}\nd[a[1]].append(a)\nd[b[1]].append(b)\nd[c[1]].append(c)\nans = 2\nflag = 0\nfor i in d:\n\tif len(d[i])==2:\n\t\tx = sorted([int(d[i][0][0]),int(d[i][1][0])])\n\t\tif x[1]-x[0]<=2:\n\t\t\tans = min(ans,1)\n\telif len(d[i])==3:\n\t\tx = sorted([int(d[i][0][0]),int(d[i][1][0]),int(d[i][2][0])])\n\t\tif x[1]-x[0]<=2 or x[2]-x[1]<=2:\n\t\t\tans = min(ans,1)\nprint (ans)\n"}, {"source_code": "suit=list(map(str,input().split()))\nsuit=sorted(suit)\nnumber=[]\nalpha=[]\ncounts=0\ncountm=0\ncountp=0\nif suit[0]==suit[1] and suit[1]==suit[2]:\n print('0')\n exit()\nfor i in range(len(suit)):\n number.append(int(suit[i][0]))\n alpha.append(suit[i][1])\n if suit[i][1]=='s':\n counts+=1\n if suit[i][1]=='m':\n countm+=1\n if suit[i][1]=='p':\n countp+=1\nif number[1]==number[0]+1 and number[2]==number[1]+1 and alpha[0]==alpha[1] and alpha[1]==alpha[2]:\n print('0')\n exit()\nif max(counts,countm,countp)==3:\n if number[2]-number[1]>2 and number[1]-number[0]>2:\n print('2')\n else:\n print('1')\nelif max(counts,countm,countp)==2:\n if alpha[0]==alpha[1]:\n if number[1]-number[0]>2:\n print('2')\n else:\n print('1')\n elif alpha[1]==alpha[2]:\n if number[2]-number[1]>2:\n print('2')\n else:\n print('1')\n else:\n if number[2]-number[0]>2:\n print('2')\n else:\n print('1')\nelse:\n print('2')\n"}, {"source_code": "import random as random\ndef quicksort(nums):\n if len(nums) <= 1:\n return nums\n else:\n q = random.choice(nums)\n l_nums = [n for n in nums if n < q]\n\n e_nums = [q] * nums.count(q)\n b_nums = [n for n in nums if n > q]\n return quicksort(l_nums) + e_nums + quicksort(b_nums)\n\nl = list(input().split(' '))\nl = quicksort(l)\nAnsw = \"\"\nif (l[0] == l[1] == l[2]):\n Answ = \"0\"\nelif (l[0][1] == l[1][1] == l[2][1] and (int(l[0][0]) +1 == int(l[1][0]) == int(l[2][0])-1) ):\n Answ = \"0\"\nelif (l[0] == l[1] or l[1] == l[2]):\n Answ = \"1\"\nelif (l[0][1] == l[1][1] and (int(l[0][0]) +1 == int(l[1][0]))):\n Answ = \"1\"\nelif (l[2][1] == l[1][1] and (int(l[1][0]) +1 == int(l[2][0]))):\n Answ = \"1\"\nelif (l[2][1] == l[0][1] and (int(l[0][0]) +1 == int(l[2][0]))):\n Answ = \"1\"\nelif (l[2][1] == l[0][1] and (int(l[0][0]) +2 == int(l[2][0]))):\n Answ = \"1\"\nelif (l[1][1] == l[0][1] and (int(l[0][0]) +2 == int(l[1][0]))):\n Answ = \"1\"\nelif (l[2][1] == l[1][1] and (int(l[1][0]) +2 == int(l[2][0]))):\n Answ = \"1\"\nelse:\n Answ = \"2\"\nprint(Answ)"}, {"source_code": "a = input().split()\na.sort()\nif a[0] == a[1] == a[2]:\n print(0)\nelif (int(a[0][0]) + 1 == int(a[1][0]) == int(a[2][0]) - 1) and a[0][1] == a[1][1] == a[2][1]:\n print(0)\nelif (a[0] == a[1] or a[0] == a[2] or a[1]==a[2]):\n print(1)\nelif (int(a[0][0]) + 1 == int(a[1][0]) and a[0][1] == a[1][1]) or (int(a[0][0]) + 1 == int(a[2][0]) and a[0][1] == a[2][1]) or (int(a[1][0]) + 1 == int(a[2][0]) and a[1][1] == a[2][1]):\n print(1)\nelif (int(a[0][0]) + 2 == int(a[1][0]) and a[0][1] == a[1][1]) or (int(a[0][0]) + 2 == int(a[2][0]) and a[0][1] == a[2][1]) or (int(a[1][0]) + 2 == int(a[2][0]) and a[1][1] == a[2][1]):\n print(1)\nelse:\n print(2)"}, {"source_code": "import collections as cl\nv = sorted(input().split())\ncnt = cl.Counter(v)\nseq = 1\nif int(v[0][0]) + 1 == int(v[1][0]) and v[0][1] == v[1][1]:\n if int(v[1][0]) + 1 == int(v[2][0]) and v[1][1] == v[2][1]:\n seq = 3\n else:\n seq = 2\nelif int(v[0][0]) + 2 == int(v[1][0]) and v[0][1] == v[1][1]:\n seq = 2\nelif int(v[0][0]) + 1 == int(v[2][0]) and v[0][1] == v[2][1]:\n seq = 2\nelif int(v[1][0]) + 1 == int(v[2][0]) and v[1][1] == v[2][1]:\n seq = 2\nelif int(v[0][0]) + 2 == int(v[2][0]) and v[0][1] == v[2][1]:\n seq = 2\nelif int(v[1][0]) + 2 == int(v[2][0]) and v[1][1] == v[2][1]:\n seq = 2\n\nprint(3 - max(seq, max(cnt.values())))\n\n\n"}, {"source_code": "from collections import defaultdict as dfd\n\nd = dfd(int)\narr = input().split()\narr.sort()\n\nfor i in arr:\n d[i] += 1\n\nif max(d.values())==3 or (arr[0][1]==arr[1][1]==arr[2][1] and int(arr[0][0])+1==int(arr[1][0]) and int(arr[1][0])+1==int(arr[2][0])):\n print(0)\nelif max(d.values())==2:\n print(1)\nelse:\n flag = True\n for i in range(len(arr)):\n for j in range(i+1, len(arr)):\n if arr[i][1]==arr[j][1] and (abs(int(arr[i][0])-int(arr[j][0]))==1 or abs(int(arr[i][0])-int(arr[j][0]))==2):\n print(1)\n flag = False\n break\n if not flag:\n break\n if flag:\n print(2)\n"}, {"source_code": "\n# In[10]:\n\n\nm = {}\np = {}\ns = {}\nfor i in range(1,10):\n p[str(i)+'p'] = i\n s[str(i)+'s'] = i\n m[str(i)+'m'] = i\ncard = []\ncard.append(m)\ncard.append(p)\ncard.append(s)\n\n\n# In[12]:\n\n\na = input()\ntmp = a.split(' ')\n\n\n# In[13]:\n\n\nma = [[],[],[]]\nfor obj in tmp:\n if obj in card[0]:\n ma[0].append(int(obj[0]))\n elif obj in card[1]:\n ma[1].append(int(obj[0]))\n else:\n ma[2].append(int(obj[0]))\nfor i in range(3):\n list.sort(ma[i])\n\n\n# In[15]:\n\n\noutput = 1\nsave = 0\nmax_count = 0\nthree = []\nfor i in range(3):\n for j in range(1,10):\n fuck = 0\n for k in range(len(ma[i])):\n if ma[i][k] == j:\n fuck += 1\n three.append(fuck)\n \nif max(three) >= 3:\n output = 0\nelif max(three) == 2:\n output = 1\nelse:\n output = 2\nindex = 2\nfor i in range(3):\n if output == 0:\n break\n n = len(ma[i])\n count = 0\n for j in range(n):\n if j == 0:\n save = ma[i][j]\n else:\n if save - ma[i][j] == -1:\n count += 1\n if count == 2:\n index = 0\n break\n elif count == 1:\n index = 1\n elif save - ma[i][j] == -2:\n index = 1\n else:\n if count == 1:\n index = 1\n count = 0\n save = ma[i][j]\n if index == 0:\n break\n\nprint(min(output,index))\n# In[ ]:\n\n\n\n\n"}, {"source_code": "l=[0]*150\na,b,c=input().split()\nl[ord(a[1])]+=1\nl[ord(b[1])]+=1\nl[ord(c[1])]+=1\nvar={}\nvar[1]=0\nfor i in range(120):\n if i==115:\n if var[1]<l[i]:\n var[1]=l[i]\n var[2]='s'\n \n if i==112:\n if var[1]<l[i]:\n var[1]=l[i]\n var[2]='p'\n \n if i==109:\n if var[1]<l[i]:\n var[1]=l[i]\n var[2]='m'\ncha=0\nchb=0\nn=[]\nm=[]\nif var[1]==1:\n print(2)\nelse:\n if var[1]==2:\n if a[1]==var[2]:\n cha+=1\n \n if b[1]==var[2]:\n chb+=1\n if cha==1:\n if abs(int(a[0])-int(b[0]))==0 or abs(int(a[0])-int(b[0]))==1 or abs(int(a[0])-int(b[0]))==2:\n print(1)\n else:\n print(2)\n if c[1]==var[2]:\n if cha==1:\n if abs(int(a[0])-int(c[0]))==0 or abs(int(a[0])-int(c[0]))==1 or abs(int(a[0])-int(c[0]))==2:\n print(1)\n else:\n print(2)\n else:\n if abs(int(c[0])-int(b[0]))==0 or abs(int(c[0])-int(b[0]))==1 or abs(int(c[0])-int(b[0]))==2:\n print(1)\n else:\n print(2)\n else:\n n.append(int(a[0]))\n n.append(int(b[0]))\n n.append(int(c[0]))\n m.append(int(a[0]))\n m.append(int(b[0]))\n m.append(int(c[0]))\n n.sort()\n m.sort()\n n=list(set(n))\n if len(n)==1:\n print(0)\n elif len(n)==2:\n print(1)\n else:\n if n[1]-n[0]==1 and n[2]-n[1]==1:\n print(0)\n elif (n[1]-n[0]==1 or n[1]-n[0]==2 or n[2]-n[1]==1 or n[2]-n[1]==2):\n print(1)\n else:\n print(2)\n \n \n \n \n \n\n\n\n "}, {"source_code": "tiles = input().split()\n\ntile0s = tiles[0][1]\ntile1s = tiles[1][1]\ntile2s = tiles[2][1]\n\ntile0v = int(tiles[0][0])\ntile1v = int(tiles[1][0])\ntile2v = int(tiles[2][0])\n\ntvals = sorted ([tile0v, tile1v, tile2v])\n\nif tiles[0] == tiles[1] and tiles[0] == tiles[2]:\n print (0)\nelif tile0s == tile1s and tile1s == tile2s and tvals[1] == tvals[0] +1 and tvals[2] == tvals[1] +1:\n print(0)\nelif tiles[0] == tiles[1] or tiles[0] == tiles[2] or tiles[1] == tiles[2]:\n print(1)\nelif ((tile0s == tile1s and abs(tile0v - tile1v) <=2) or\n (tile0s == tile2s and abs(tile0v - tile2v) <=2) or\n (tile2s == tile1s and abs(tile2v - tile1v) <=2)):\n print(1)\nelse:\n print(2)"}, {"source_code": "a = sorted(input().split())\n\nif a[0] == a[1] == a[2]:\n print(0)\nelif (a[0][1] == a[1][1] == a[2][1]) and (int(a[0][0]) + 1 == int(a[1][0]) and int(a[1][0]) + 1 == int(a[2][0])):\n print(0)\nelif a[0] == a[1] or a[1] == a[2]:\n print(1)\nelse:\n s = set(a)\n r = None\n for e in s:\n num, word = int(e[0]), e[1]\n if str(str(num - 2) + word) in s or str(str(num - 1) + word) in s or str(str(num + 1) + word) in s or str(\n str(num + 2) + word) in s:\n r = 1\n break\n if r:\n print(r)\n else:\n print(2)\n"}, {"source_code": "\na=input().split()\ncount=[0,0,0]\nalp=['m','p','s']\nfor i in range(3):\n if a[i][1]=='m': count[0]+=1\n elif a[i][1]=='p': count[1]+=1\n else: count[2]+=1 \nif max(count)==3:\n d=[0,0,0]\n d[0]=abs(int(a[0][0])-int(a[1][0]))\n d[1]=abs(int(a[0][0])-int(a[2][0]))\n d[2]=abs(int(a[1][0])-int(a[2][0]))\n d.sort()\n if d[0]<=2:\n if d==[0,0,0]: print(0)\n elif d==[1,1,2]: print(0)\n else : print(1) \n else: print(2) \nelif max(count)==2:\n i=0\n l=[0,0]\n while i<3:\n if count[i]==2: break;\n i+=1\n ct=0;\n for j in range(3):\n if a[j][1]==alp[i]: l[ct]=int(a[j][0]); ct+=1\n if abs(l[0]-l[1])<=2: print(1)\n else: print(2)\nelse:\n print(2);\n"}, {"source_code": "l = list(input().split())\n\n\nd = {}\nd[\"m\"] = {}\nd[\"s\"] = {}\nd[\"p\"] = {}\nfor i in range(1,10):\n d[\"m\"][i] = 0\n d[\"s\"][i] = 0\n d[\"p\"][i] = 0\n\nfor a in l:\n s = a[1]\n c = int(a[0])\n d[s][c] += 1\n\n#koutsu\nc = 0\nfor s in [\"m\",\"p\",\"s\"]:\n for i in range(1,10):\n c = max(c,d[s][i])\n if c >= 3:\n print(0)\n exit()\n\nans = 3 - c\n#shuusu\nt = 0\nfor s in [\"m\",\"p\",\"s\"]:\n c = 0\n for i in range(1,10):\n if d[s][i] != 0:\n c += 1\n else:\n t = max(t,c)\n if t >= 3:\n print(0)\n exit()\n c = 0\n t = max(t,c)\n\n c = 0\n for i in range(1,8):\n if d[s][i] != 0 and d[s][i+2] != 0:\n c = 2\n break\n t = max(t,c)\n\n\nprint(min(ans , 3 - t))\n\n\n\n"}, {"source_code": "ll= lambda : list(map(int,input().split()))\ntestcases=1\n# testcases=int(input())\nfor testcase in range(testcases):\n\ts1,s2,s3=input().split()\n\tss=[s1,s2,s3]\n\tss.sort()\n\tif(len(set([i[1] for i in ss]))==1):\n\t\tif(len(set([i[0] for i in ss]))==1 or ((int(ss[0][0])==int(ss[1][0])-1) and (int(ss[0][0])==int(ss[2][0])-2))):\n\t\t\tprint(0)\n\t\telif ((len(set([i[0] for i in ss]))==2) or (int(ss[0][0])==int(ss[1][0])-1) or (int(ss[0][0])==int(ss[1][0])-2) or (int(ss[1][0])==int(ss[2][0])-1)):\n\t\t\tprint(1)\n\t\telse:\n\t\t\tprint(2)\n\telif(len(set([i[1] for i in ss]))==2):\n\t\tans=2\n\t\tfor i in range(0,2):\n\t\t\tfor j in range(i+1,3):\n\t\t\t\tif ss[i][1]==ss[j][1]:\n\t\t\t\t\tif(ss[i][0]==ss[j][0] or abs(int(ss[i][0])-int(ss[j][0]))<=2):\n\t\t\t\t\t\t# print(i,j)\n\t\t\t\t\t\tans=1\n\t\t\t\t\t\tbreak\n\t\t\tif(ans==1):\n\t\t\t\tbreak\n\t\tprint(ans)\n\telse:\n\t\tprint(2)\n\t\t"}, {"source_code": "a,b,c = map(str, input().split())\na = a[1]+a[0]\nb = b[1]+b[0]\nc = c[1]+c[0]\nn = [a,b,c]\nm = [0]*9\np = [0]*9\ns = [0]*9\nfor i in range(3):\n if(n[i][0]==\"m\"):\n m[int(n[i][1])-1]+=1\n if(n[i][0]==\"p\"):\n p[int(n[i][1])-1]+=1\n if(n[i][0]==\"s\"):\n s[int(n[i][1])-1]+=1\nans = 2\n#print(m,p,s)\nfor i in range(9):\n if(3-m[i]<ans):\n ans = 3-m[i]\n if(0<i and i<8):\n if(3-min(1,m[i-1])-min(1,m[i])-min(1,m[i+1])<ans):\n ans = 3-min(1,m[i-1])-min(1,m[i])-min(1,m[i+1])\n if(3-s[i]<ans):\n ans = 3-s[i]\n if(0<i and i<8):\n if(3-min(1,s[i-1])-min(1,s[i])-min(1,s[i+1])<ans):\n #print(23)\n ans = 3-min(1,s[i-1])-min(1,s[i])-min(1,s[i+1])\n #print(ans, 9)\n if(3-p[i]<ans):\n ans = 3-p[i]\n #print(3-s[i-1]-s[i]-s[i+1])\n if(0<i and i<8):\n if(3-min(1,p[i-1])-min(1,p[i])-min(1,p[i+1])<ans):\n ans = 3-min(1,p[i-1])-min(1,p[i])-min(1,p[i+1])\nprint(ans)\n"}, {"source_code": "a,b,c=input().split()\ndef fine(x):\n if x[0]==x[1] and x[1]==x[2]:\n return True\n if x[0][1]==x[1][1] and x[1][1]==x[2][1]:\n if (int(x[0][0])+1)==int(x[1][0]) and (int(x[0][0])+2)==int(x[2][0]):\n return True\n return False\nl=[a,b,c]\nfor i in range(3):\n for j in range(3):\n for k in range(3):\n if i==j or i==k or j==k:\n continue\n if fine([l[i],l[j],l[k]]):\n print(0)\n quit()\nfor ijk in range(1,10):\n for x in ['m','p','s']:\n s=str(ijk)+x\n l=[a,b,c,s]\n for i in range(4):\n for j in range(4):\n for k in range(4):\n if i==j or i==k or j==k:\n continue\n if fine([l[i],l[j],l[k]]):\n print(1)\n quit()\nprint(2)\n"}, {"source_code": "'''\n\n1. Figure out min number to get a kontsu\n\n Get a 'counter', count exact match.\n - 3 - find max value \n\n2. Figure out min number to get a mentsu\n\n Sort the cards \n\n Do a while loop\n\n While i is < len(lst)\n \n Count # of consecutive cards \n\n Move j until index of the last consecutive card\n\n\n'''\n\ndef min_mentsu(cards):\n return min(min_koutsu(cards), min_shuntsu(cards))\n\ndef min_koutsu(cards):\n counter = {}\n\n for card in cards:\n if card not in counter:\n counter[card] = 0\n counter[card] += 1\n\n return max(0, 3 - max(counter.values()))\n\ndef min_shuntsu(cards):\n '''\n Cases:\n\n 3 same:\n\n 2 same: either consecutive \n\n 7p 8p or 7p 9p\n\n\n\n '''\n\n cards = sorted([(int(card[0]), card[1]) for card in cards], key=lambda x: (x[1], x[0]))\n\n if consecutive(cards, 0) and consecutive(cards, 1):\n return 0\n\n if consecutive(cards, 0) or consecutive(cards, 1):\n return 1\n\n if jump_consecutive(cards, 0) or jump_consecutive(cards, 1):\n return 1\n\n return 2\n\n\ndef consecutive(cards, i):\n num, suit = cards[i]\n num2, suit2 = cards[i + 1]\n\n return suit == suit2 and num2 - num == 1\n\ndef jump_consecutive(cards, i):\n num, suit = cards[i]\n num2, suit2 = cards[i + 1]\n\n r = (suit == suit2) and (num2 - num == 2)\n return r\n\n\n\ncards = raw_input().split()\nprint min_mentsu(cards)\n"}, {"source_code": "t1, t2, t3 = map(str, input().split())\nm = []\ns = []\np = []\nif t1[1] == 'm':\n m.append(int(t1[0]))\nelif t1[1] == 's':\n s.append(int(t1[0]))\nelse:\n p.append(int(t1[0]))\n \nif t2[1] == 'm':\n m.append(int(t2[0]))\nelif t2[1] == 's':\n s.append(int(t2[0]))\nelse:\n p.append(int(t2[0]))\n \nif t3[1] == 'm':\n m.append(int(t3[0]))\nelif t3[1] == 's':\n s.append(int(t3[0]))\nelse:\n p.append(int(t3[0]))\n \nm.sort()\ns.sort()\np.sort()\n\nif len(m) == 0:\n ans_m = 3\nelif len(m) == 1:\n ans_m = 2\nelif len(m) == 2:\n if m[0] == m[1] or m[1] == m[0] + 1 or m[1] == m[0] + 2:\n ans_m = 1\n else:\n ans_m = 2\nelse:\n if m[0] == m[1] == m[2] or (m[1] == m[0] + 1 and m[2] == m[1] + 1):\n ans_m = 0\n elif m[0] == m[1] or m[1] == m[2] or m[0] == m[2] or m[1] == m[0] + 1 or m[2] == m[1] + 1 or m[1] == m[0] + 2 or m[2] == m[1] + 2:\n ans_m = 1\n else:\n ans_m = 2\n\nif len(s) == 0:\n ans_s = 3\nelif len(s) == 1:\n ans_s = 2\nelif len(s) == 2:\n if s[0] == s[1] or s[1] == s[0] + 1 or s[1] == s[0] + 2:\n ans_s = 1\n else:\n ans_s = 2\nelse:\n if s[0] == s[1] == s[2] or (s[1] == s[0] + 1 and s[2] == s[1] + 1):\n ans_s = 0\n elif s[0] == s[1] or s[1] == s[2] or s[0] == s[2] or s[1] == s[0] + 1 or s[2] == s[1] + 1 or s[1] == s[0] + 2 or s[2] == s[1] + 2:\n ans_s = 1\n else:\n ans_s = 2\n \nif len(p) == 0:\n ans_p = 3\nelif len(p) == 1:\n ans_p = 2\nelif len(p) == 2:\n if p[0] == p[1] or p[1] == p[0] + 1 or p[1] == p[0] + 2:\n ans_p = 1\n else:\n ans_p = 2\nelse:\n if p[0] == p[1] == p[2] or (p[1] == p[0] + 1 and p[2] == p[1] + 1):\n ans_p = 0\n elif p[0] == p[1] or p[1] == p[2] or p[0] == p[2] or p[1] == p[0] + 1 or p[2] == p[1] + 1 or p[1] == p[0] + 2 or p[2] == p[1] + 2:\n ans_p = 1\n else:\n ans_p = 2\nprint(min(ans_m, ans_s, ans_p))"}], "negative_code": [{"source_code": "a, b, c = input().split()\n\nnumbers = [int(a[0]), int(b[0]), int(c[0])]\nletters = [a[1], b[1], c[1]]\nif (a == b == c):\n\tprint(0)\n\nelse:\n\torder = sorted(numbers)\n\tflag = 0\n\tfor i in range(2):\n\t\tdiff = order[i + 1] - order[i]\n\t\tif (diff != 1):\n\t\t\tflag = 1\n\t\t\tbreak\n\tif(flag == 0):\n\t\tprint(0)\n\n\telse:\n\t\t#print(letters)\n\t\tp = letters.count(\"p\")\n\t\tm = letters.count(\"m\")\n\t\ts = letters.count(\"s\")\n\t\t#print(m, p, s)\n\t\tif(p == 1 and m == 1 and s == 1):#each of diff type\n\t\t\tprint(2)\n\n\t\telse:\n\t\t\tif (m == 3 or p == 3 or s == 3):\n\t\t\t\torder = sorted(numbers)\n\t\t\t\tdiff = []\n\t\t\t\tfor i in range(2):\n\t\t\t\t\tdiff.append(order[i + 1] - order[i])\n\t\t\t\tif(1 in diff or 2 in diff):\n\t\t\t\t\tprint(1)\n\t\t\t\telif(0 in diff):\n\t\t\t\t\tprint(2)\n\t\t\telse:\n\t\t\t\t#1, 2\n\t\t\t\tif (letters[0] == letters[1]):\n\t\t\t\t\ttwos = [numbers[0], numbers[1]]\n\t\t\t\telif(letters[0] == letters[2]):\n\t\t\t\t\ttwos = [numbers[0], numbers[2]]\n\t\t\t\telse:\n\t\t\t\t\ttwos = [numbers[1], numbers[2]]\n\n\t\t\t\tif (abs(twos[1] - twos[0]) == 1 or abs(twos[1] - twos[0]) == 2):\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2)"}, {"source_code": "import sys\nimport math\nimport bisect\nimport atexit\nimport io\nimport heapq\nfrom collections import defaultdict, Counter\nMOD = int(1e9+7)\n\n\n\n# n = map(int, raw_input().split())\n# input = map(int, raw_input().split())\ndef main():\n a, b, c = raw_input().split()\n d = defaultdict(list)\n num = []\n ans = 2\n for st in (a,b,c):\n nu, ch = st\n nu = int(nu)\n d[ch].append(int(nu))\n num.append(nu)\n num.sort()\n if num[0] == num[-1]-2:\n ans = 0\n if num[0] == num[1]-2 or num[1] == num[-1]-2:\n ans = min(ans, 1)\n for k, v in d.items():\n v.sort()\n if len(v) == 3:\n ans = 0\n elif len(v)==2:\n ans = min(ans, 1)\n print ans\n\nmain()\n"}, {"source_code": "a = input().split()\nb=[]\nx = {'s':0,'m':0,'p':0}\n\n\nfor i in range (0,3):\n b.append(int(a[i][0]))\n\n x[a[i][1]] += 1\n\nif int(a[0][0])> int(a[1][0]):\n a[0],a[1]=a[1],a[0]\n if int(a[1][0]) > int(a[2][0]) :\n a[1],a[2]=a[2],a[1]\n if int(a[0][0])> int(a[1][0]):\n a[0],a[1]=a[1],a[0]\nelif int(a[1][0]) > int(a[2][0]) :\n a[1],a[2]=a[2],a[1]\n if int(a[0][0])> int(a[1][0]):\n a[0],a[1]=a[1],a[0]\n\n \n\nif a[0] == a[1] and a[1] == a[2]:\n print(0)\n\nelif a[0][1]== a[1][1] and a[1][1] == a[2][1]:\n if int(a[1][0])- int(a[0][0]) == 1:\n if int(a[2][0])- int(a[1][0]) == 1:\n print (0)\n else:\n print(1)\n \n elif int(a[2][0])- int(a[1][0]) == 1:\n print (1)\n elif int(a[2][0])- int(a[1][0]) == 0 or int(a[1][0])- int(a[0][0]) == 0:\n print (1)\n else:\n print(2)\n\nelif a[0][1]== a[1][1] :\n if int(a[1][0])- int(a[0][0]) == 1:\n print(1)\n\n elif int(a[1][0])- int(a[0][0]) == 0:\n print (1) \n\n \n else:\n print(2)\n\nelif a[1][1] == a[2][1]:\n if int(a[2][0])- int(a[1][0]) == 1:\n print (1)\n\n elif int(a[2][0])- int(a[1][0]) == 0 :\n print (1)\n \n \n \n \n\n else:\n print(2)\n\nelif a[0][1] == a[2][1]:\n if int(a[2][0]) - int( a[0][0]) == 1:\n print (1)\n \n elif int(a[2][0]) - int( a[0][0]) == 2:\n print (1)\n\n else:\n print(2)\n\nelse:\n print(2)\n"}, {"source_code": "from __future__ import print_function\nimport sys\n\n\ndef get_seq(line):\n a = sorted(line.split())\n d = {'m': [], 'p': [], 's': []}\n for x in a:\n n = ord(x[0]) - ord('0')\n d[x[1]].append(n)\n\n l = [(len(l), l) for l in d.values()]\n l.sort(reverse=True)\n return sorted(l[0][1])\n\n\ndef get_best(a):\n if len(a) == 1:\n return 2\n elif len(a) == 2:\n if (a[1] - a[0]) % 2 == 0:\n return 1\n elif 2 * a[0] - a[1] >= 1:\n return 1\n elif 2 * a[1] - a[0] <= 9:\n return 1\n else:\n return 2\n elif len(a) == 3:\n if a[1] * 2 == a[0] + a[2]:\n return 0\n else:\n return 1\n\n\nseq = get_seq(input())\nprint(seq, file=sys.stderr)\nprint(get_best(seq))\n"}, {"source_code": "l = list(input().split())\nd = {}\nfor i in l:\n if i[1] not in d:d[i[1]] = [int(i[0])]\n else:\n d[i[1]].append(int(i[0]))\nbest = []\nfor i in d:\n if len(d[i]) > len(best):\n best = d[i]\nif len(best)==1:print(2)\nelif len(set(best))==1:print(3-len(best))\nelse:\n m = min(best)\n if m+1 in best:\n if m+2 in best:print(0)\n else:print(1)\n elif m+2 in best or best.count(m)==2:\n print(1)\n else:\n print(2)"}, {"source_code": "li = input().split()\nli1 = sorted(map(lambda x: x[0], li))\nli2 = sorted(map(lambda x: x[1], li))\nif li[0] == li[1] and li[1] == li[2] or li2[0] == li2[2] and int(max(li1)) - int(min(li1)) == 2 and li1[0] != li1[1]:\n print(0)\nelif (li[0] == li[1]) or (li[0] == li[2]) or (li[2] == li[1]) or ((\n int(li1[2]) - int(li1[1]) == 2 or int(li1[2]) - int(li1[1]) == 1) and (\n li2[0] == li2[1] or li2[0] == li2[2] or li2[1] == li2[2])) or ((\n int(li1[2]) - int(li1[0]) == 2 or int(li1[2]) - int(li1[0]) == 1) and (\n li2[0] == li2[1] or li2[0] == li2[2] or li2[1] == li2[2])) or ((\n int(li1[1]) - int(li1[0]) == 2 or int(li1[1]) - int(li1[0]) == 1) and (\n li2[0] == li2[1] or li2[0] == li2[2] or li2[1] == li2[2])):\n print(1)\nelse:\n print(1)\n"}, {"source_code": "cards = input().split()\nans = 2\nif cards[0] == cards[1] and cards[2] == cards[1]:\n ans = 0\nelif cards[0] == cards[1] or cards[0] == cards[2] or cards[2] == cards[1]:\n ans = 1\nelse:\n if cards[0][1] == cards[1][1] and cards[0][1] == cards[2][1]: \n if abs(int(cards[0][0]) - int(cards[1][0])) <= 2 and abs(int(cards[0][0]) - int(cards[2][0])) <= 2 and abs(int(cards[1][0]) - int(cards[2][0])) <= 2:\n ans = 0\n elif abs(int(cards[0][0]) - int(cards[1][0])) == 1 or abs(int(cards[0][0]) - int(cards[2][0])) == 1 or abs(int(cards[1][0]) - int(cards[2][0])) == 1:\n ans = min(ans, 1)\n elif not(cards[0][1] != cards[1][1] and cards[0][1] != cards[2][1] and cards[2][1] != cards[1][1]):\n if cards[0][1] == cards[1][1]:\n card1, card2 = cards[0], cards[1]\n elif cards[0][1] == cards[2][1]:\n card1, card2 = cards[0], cards[2]\n else:\n card1, card2 = cards[1], cards[2]\n if abs(int(card1[0]) - int(card2[0])) == 1:\n ans = min(ans, 1)\nprint(ans)"}, {"source_code": "def similar_number(arr):\n m = 1\n for i in range(1, 10):\n i_cnt = arr.count(i)\n m = max(i_cnt, m)\n return m\n\n\ndef subseq_num(arr):\n if len(arr) == 0 or len(arr) == 1:\n return 1\n\n arr.sort()\n\n if len(arr) == 2:\n if arr[1] == arr[0] + 1 or arr[1] == arr[0] + 2:\n return 2\n else:\n return 1\n\n if arr[2] - arr[0] == 2:\n return 3\n elif arr[2] == arr[1] + 1 or arr[1] == arr[0] + 1:\n return 2\n else:\n return 1\n\n\ndef solve():\n\n cards = input().split()\n\n s_cards = list(filter(lambda c: c[1] == 's', cards))\n m_cards = list(filter(lambda c: c[1] == 'm', cards))\n p_cards = list(filter(lambda c: c[1] == 'p', cards))\n\n s_numbers = list(map(lambda c: int(c[0]), s_cards))\n m_numbers = list(map(lambda c: int(c[0]), m_cards))\n p_numbers = list(map(lambda c: int(c[0]), p_cards))\n\n s_n = similar_number(s_numbers)\n m_n = similar_number(m_numbers)\n p_n = similar_number(p_numbers)\n\n s_s = subseq_num(s_numbers)\n m_s = subseq_num(m_numbers)\n p_s = subseq_num(p_numbers)\n\n _n = max(s_n, m_n, p_n, s_s, m_s, p_s)\n\n print(3 - _n)\n\nsolve()"}, {"source_code": "cards= list(map(str,input().split()))\ndict={'p':[],'m':[],'s':[]}\nmin_draw=2\nfor i in cards:\n dict[str(i)[1]].append(int(str(i)[0]))\nfor j in dict.keys():\n m=len(dict[j])-len(set(dict[j]))\n if min_draw>2-m:\n min_draw=2-m\n dict[j].sort()\n if len(dict[j])==3:\n n=2\n if dict[j][2]-dict[j][0]==2:\n n=0\n else:\n if dict[j][1]-dict[j][0]<=2 or dict[j][2]-dict[j][1]<=2:\n n=1\n if min_draw>n:\n min_draw=n\n if len(dict[j])==2:\n if dict[j][1]-dict[j][0]<=2:\n if min_draw>1:\n min_draw=1\n\nprint(min_draw)\n"}, {"source_code": "a=list(input().split())\nar1=[]\nar2=[]\nfor i in a:\n ar1.append(int(i[0]))\n ar2.append(i[1])\ns=set()\nfor i in range(3):\n for j in range(i,3):\n if ar2[i]==ar2[j]:\n s.add(i)\n s.add(j)\nif len(s)==0:\n print(2)\nelif len(s)==2:\n i1=s.pop()\n i2=s.pop()\n if abs(ar1[i1]-ar1[i2])<=1:\n print(1)\n else:\n print(2)\nelse:\n ar1.sort()\n d1=ar1[1]-ar1[0]\n d2=ar1[2]-ar1[1]\n if d1==0:\n if d2==0:\n print(0)\n else:\n print(1)\n elif d1==1:\n if d2==1:\n print(0)\n else:\n print(1)\n else:\n if d2==0 or d2==1:\n print(1)\n else:\n print(2)\n "}, {"source_code": "a = sorted(list(map(lambda x: ord(x[0]) + 256 * ord(x[1]), input().split())))\nres = 2\nif a[1] - a[0] in [0, 1, 2] or a[2] - a[1] in [0, 1, 2]:\n res = 1\nif (a[0] == a[1] and a[1] == a[2]) or (a[0] + 1 == a[1] and a[1] + 1 == a[2]):\n res = 0\nprint(res, a)\n"}, {"source_code": "def solve(arr):\n d = Counter(arr)\n mx = 0\n for i in d.keys():\n mx = max(mx,d[i])\n if mx >= 3:\n return 0\n d1 = {'m':[],'p':[],'s':[]}\n for a,v in arr:\n d1[v].append(int(a))\n count = 0\n #print(d1)\n for key in d1.keys():\n if len(d1[key]) > 0:\n d1[key].sort()\n local = 1\n for j in range(len(d1[key])-1):\n if d1[key][j+1] - d1[key][j]==1:\n local += 1\n else:\n count = max(count,local)\n local = 0\n count = max(count,local)\n #print(\"heer\",count)\n if count >= 3:\n return 0\n return 3 - max(mx,count)\n\nfrom collections import Counter \narr = input()\narr = arr.split()\nprint(solve(arr))"}, {"source_code": "l = list(input().split())\nd = {}\nfor i in l:\n if i[1] not in d:d[i[1]] = [int(i[0])]\n else:\n d[i[1]].append(int(i[0]))\nbest = []\nfor i in d:\n if len(d[i]) > len(best):\n best = d[i]\nif len(best)==1:print(2)\nelif len(set(best))==1:print(3-len(best))\nelse:\n m = min(best)\n if m+1 in best:\n if m+2 in best:print(0)\n else:print(1)\n elif m+2 in best:\n print(1)\n elif m in best:\n print(1)\n else:\n print(0)"}, {"source_code": "a, b, c = input().split()\ny = sorted([a[0], b[0], c[0]])\ny1 = [int(y[i + 1]) - int(y[i]) for i in range(2)]\ny2 = sorted([a[1], b[1], c[1]])\nif len(set(y2)) == 1:\n if set(y1) == {0}:\n print(0)\n elif set(y1) == {1}:\n print(0)\n elif 1 in set(y1) or 2 in set(y1):\n print(1)\n else:\n print(2)\nelif len(set(y2)) == 2:\n x = sorted([a, b, c])\n if x[0][1] == x[1][1]:\n if int(x[0][0])-int(x[1][0]) == 0 or int(x[1][0])-int(x[0][0]) == 1 or int(x[1][0])-int(x[0][0]) == 2:\n print(1)\n else:\n print(2)\n elif x[1][1] == x[2][1]:\n if int(x[1][0])-int(x[2][0]) == 0 or int(x[2][0])-int(x[1][0]) == 1 or int(x[2][0])-int(x[1][0]) == 2:\n print(1)\n else:\n print(2)\n else:\n print(2)\nelse:\n print(2)\n"}, {"source_code": "s=input().split()\nl=[]\ns.sort()\nfor i in s:\n l.append(int(i[0]))\n l.append(i[1])\nif l[0]==l[2] and l[1]==l[3]:\n if l[0]==l[4] and l[1]==l[5]:\n print(0) \n else: \n print(1) \nelif l[4]==l[2] and l[5]==l[3]:\n print(1) \nelif l[0]+1==l[2] and l[1]==l[3]:\n if l[2]+1==l[4] and l[3]==l[5]:\n print(0)\n else:\n print(1)\nelif l[2]+1==l[4] and l[5]==l[3]:\n print(1)\nelif l[0]+2==l[4] and l[1]==l[5]:\n print(1) \nelse:\n print(2)"}, {"source_code": "from collections import defaultdict\ndef main():\n# ****************************** Input *************************************\n A=list(input().split())\n # print(A)\n\n\n# ****************************** Algorithm *********************************\n B=sorted(A,key = lambda x : int(x[0]))\n m=defaultdict(list)\n for i in B:\n m[i[1]].append(int(i[0]))\n # print(m)\n # Now check for mentsu\n # Check for Koutsu\n # Formed when in any of m,s,p there are 3 numbers the same\n maxCount=0\n for i in m:\n count1=0\n for j in range(len(m[i])-1):\n # print(m[i][j],m[i][j+1])\n if m[i][j] == m[i][j+1]:\n count1+=1\n # print(\"Run\",count1)\n else:\n count1=0\n if count1>maxCount:\n maxCount=count1\n if count1==2:\n print(0)\n return\n # Check for Shuntsu\n for i in m:\n count2=0\n for j in range(len(m[i])-1):\n if m[i][j] + 1 ==m[i][j+1]:\n count2+=1\n else:\n count2=0\n if count2 > maxCount:\n maxCount = count2\n if count2 == 2:\n print(0)\n return\n # print(maxCount)\n # THird Case\n print(m)\n if maxCount==0:\n for i in m:\n # count3=0\n for j in range(len(m[i])-1):\n # print(m[i][j],m[i][j+1])\n if abs(m[i][j] - m[i][j+1]) == 2:\n print(1)\n return\n\n# ****************************** output ************************************\n#Output here\n print(m)\n if len(A)==0:\n print(3)\n else:\n print(2-maxCount)\n\nmain()\n# 5p 5s 9m 4p 1s 7p 7m 6p\n# 2m 3p 2s 4m 1s 2s 4s\n\n# 3m 9m 2m\n"}, {"source_code": "a,b,c=input().split()\ndef fine(x):\n if x[0]==x[1] and x[1]==x[2]:\n return True\n if x[0][1]==x[1][1] and x[1][1]==x[2][1]:\n if (int(x[0][0])+1)==int(x[1][0]) and (int(x[0][0])+2)==int(x[2][0]):\n return True\n return False\nl=[a,b,c]\nfor i in range(3):\n for j in range(3):\n for k in range(3):\n if i==j or i==k or j==k:\n continue\n if fine([l[i],l[j],l[k]]):\n print(0)\n quit()\nfor ijk in range(1,10):\n for x in ['m','p','s']:\n s=str(ijk)+x\n l=[a,b,c,s]\n for i in range(4):\n for j in range(4):\n for k in range(4):\n if i==j or i==k or j==k:\n continue\n if fine([l[i],l[j],l[k]]):\n quit()\nprint(2)\n"}, {"source_code": "s1,s2,s3 = input().split()\nA = []\nif (s1[1]==s2[1])and(s2[1]==s3[1]):\n\tif (s1[0]==s2[0])and(s2[0]==s3[0]):\n\t\tprint(0)\n\t\texit()\n\tA.append(int(s1[0]))\n\tA.append(int(s2[0]))\n\tA.append(int(s3[0]))\n\tA.sort()\n\tif (A[0]==A[1]-1) and(A[0]==A[2]-2):\n\t\tprint(0)\n\t\texit()\n\t\n\t\nelif (s1[1]==s2[1]):\n\tif (s1[0]==s2[0]):\n\t\tprint(1)\n\t\texit()\n\tif (int(s1[0])==(int(s2[0])+1))or(int(s1[0])==(int(s2[0])-1)):\n\t\tprint(1)\n\t\texit()\n\t\n\t\nelif (s1[1] == s3[1]):\n\tif (s1[0]==s3[0]):\n\t\tprint(1)\n\t\texit()\n\tif (int(s1[0])==(int(s3[0])+1))or(int(s1[0])==(int(s3[0])-1)):\n\t\tprint(1)\n\t\texit()\n\t\n\t\nelif (s2[1]==s3[1]):\n\tif (s2[0]==s3[0]):\n\t\tprint(1)\n\t\texit()\n\tif (int(s2[0])==(int(s3[0])+1))or(int(s2[0])==(int(s3[0])-1)):\n\t\tprint(1)\n\t\texit()\n\t\n\t\nelse:\n\tprint(2)"}, {"source_code": "a, b, c = sorted(input().split(), key = lambda x: int(x[0]))\n\n\nif a == b == c: print(0)\nelif a[1] == b[1] == c[1] and int(a[0])+2 == int(b[0])+1 == int(c[0]): print(0)\nelif a == b or b == c or c == a: print(1)\nelif a[1] == b[1] and (int(a[0])+1 == int(b[0]) or int(a[0])+2 == int(b[0])): print(1)\nelif b[1] == c[1] and (int(b[0])+1 == int(c[0]) or int(b[0])+2 == int(c[0])): print(1)\nelse: print(2)"}, {"source_code": "def solve(arr):\n d = Counter(arr)\n mx = 0\n for i in d.keys():\n mx = max(mx,d[i])\n if mx >= 3:\n return 0\n d1 = {'m':[],'p':[],'s':[]}\n for a,v in arr:\n d1[v].append(int(a))\n count = 0\n counttwo = 0\n #print(d1)\n for key in d1.keys():\n if len(d1[key]) > 0:\n d1[key].sort()\n local = 1\n localtwo = 1\n for j in range(len(d1[key])-1):\n if d1[key][j+1] - d1[key][j]==1:\n local += 1\n else:\n count = max(count,local)\n local = 0\n \n if d1[key][j+1] - d1[key][j]==2:\n localtwo += 1\n else:\n counttwo = max(counttwo,localtwo)\n localtwo = 0\n count = max(count,local)\n counttwo = max(counttwo,localtwo)\n #print(\"heer\",count,counttwo)\n if count >= 3:\n return 0\n if counttwo>1:\n return min(3 - max(mx,count),1)\n return 3 - max(mx,count)\n\nfrom collections import Counter \narr = input()\narr = arr.split()\nprint(solve(arr))"}, {"source_code": "a=[[0]*10]*3\ns=input().split()\nm1=0\nfor i in s:\n k=int(i[0])\n \n if i[1]=='m':\n a[0][k]+=1\n m1=max(m1,a[0][k])\n elif i[1]=='p':\n a[1][k]+=1\n m1=max(m1,a[1][k])\n elif i[1]=='s':\n a[2][k]+=1\n m1=max(m1,a[2][k])\nm2=0\nfor i in range(3):\n for j in range(1,8):\n if a[i][j]>0:\n a[i][j]=1\n if a[i][j+1]>0:\n a[i][j+1]=1\n if a[i][j+2]>0:\n a[i][j+2]=1\n m2=max(a[i][j]+a[i][j+1]+a[i][j+2],m2)\nprint(min(3-m1,3-m2))\n \n "}, {"source_code": "s = input().split()\ns.sort()\nif s[0] == s[1] == s[2]:\n print(0)\n exit(0)\ns[0] = [int(s[0][0]), s[0][1]]\ns[1] = [int(s[1][0]), s[1][1]]\ns[2] = [int(s[2][0]), s[2][1]]\nif s[0][1] == s[1][1] == s[2][1]:\n print(min(min(s[2][0] - s[1][0], s[1][0] - s[0][0], s[2][0] - s[0][0]) - 1, 2))\nelif s[2][1] == s[1][1]:\n if s[2][0] - s[1][0] == 1 or s[2][0] - s[1][0] == 2:\n print(1)\n elif s[2][0] - s[1][0] == 0:\n print(1)\n else:\n print(2)\n\nelif s[2][1] == s[0][1]:\n if s[2][0] - s[0][0] == 1 or s[2][0] - s[0][0] == 2:\n print(1)\n elif s[2][0] - s[0][0] == 0:\n print(1)\n else:\n print(2)\nelif s[1][1] == s[0][1]:\n if s[1][0] - s[0][0] == 1 or s[1][0] - s[0][0] == 2:\n print(1)\n elif s[1][0] - s[0][0] == 0:\n print(1)\n else:\n print(2)\n\nelse:\n print(2)\n"}, {"source_code": "t = sorted(input().split())\nans = 3\nl = 0\nwhile l < len(t):\n r = l\n while r < len(t) and t[r] == t[l]:\n r += 1\n ans = min(ans, 3 - (r - l))\n l = r\nt = sorted(list(set(t)), key=lambda e: e[1] + e[0])\nl = 0\nwhile l < len(t):\n r = l\n while r < len(t) and t[r][1] == t[l][1]:\n r += 1\n for k in range(l, r):\n ans = min(ans, 2)\n if k + 1 < r:\n if int(t[k + 1][0]) == int(t[k][0]) + 1:\n ans = min(ans, 1)\n if k + 2 < r:\n if int(t[k + 2][0]) == int(t[k][0]) + 2:\n ans = min(ans, 0)\n l = r\nprint(ans)"}, {"source_code": "a = input().split()\na.sort()\nif a[0] == a[1] == a[2]:\n print(0)\nelif (int(a[0][0]) + 1 == int(a[1][0]) == int(a[2][0]) - 1) and a[0][1] == a[1][1] == a[2][1]:\n print(0)\nelif (a[0] == a[1] or a[0] == a[2] or a[1]==a[2]):\n print(1)\nelif (int(a[0][0]) + 1 == int(a[1][0]) and a[0][1] == a[1][1]) or (int(a[0][0]) + 1 == int(a[2][0]) and a[0][1] == a[2][1]) or (int(a[1][0]) + 1 == int(a[2][0]) and a[1][1] == a[2][1]):\n print(1)\n\nelse:\n print(2)"}, {"source_code": "a, b, c = input().split()\n\nif a == b and b == c :\n\tprint(\"0\")\nelse :\n\tok = False\n\tif a[1] == b[1] and b[1] == c[1] :\n\t\taa, bb, cc = int(a[0]), int(b[0]), int(c[0])\n\t\tl = [aa, bb, cc]\n\t\tl.sort()\n\t\tif l[0] == l[1]-1 and l[1] == l[2]-1 :\n\t\t\tok = True\n\tif ok :\n\t\tprint(\"0\")\n\telse :\n\t\tif a == b or b == c :\n\t\t\tprint(\"1\")\n\t\telse :\n\t\t\tif a[1] == b[1] or b[1] == c[1] or a[1] == c[1] :\n\t\t\t\taa, bb, cc = int(a[0]), int(b[0]), int(c[0])\n\t\t\t\tif ((aa == bb-1 or aa-1 == bb) and a[1] == b[1]) :\n\t\t\t\t\tprint(\"1\")\n\t\t\t\telif ((aa == cc-1 or aa-1 == cc) and a[1] == c[1]) :\n\t\t\t\t\tprint(\"1\")\n\t\t\t\telif ((cc == bb-1 or cc-1 == bb) and b[1] == c[1]) :\n\t\t\t\t\tprint(\"1\")\n\t\t\t\telse :\n\t\t\t\t\tprint(\"2\")\n\t\t\telse :\n\t\t\t\tprint(\"2\")\n"}, {"source_code": "a, b, c = map(str, input().split())\nd = []\nfor i in range(3):\n d.append([0] * 9)\n\ndef f(k):\n if k[1] == 'm':\n d[0][int(k[0]) - 1] += 1\n elif k[1] == 'p':\n d[1][int(k[0]) - 1] += 1\n else:\n d[2][int(k[0]) - 1] += 1\nf(a)\nf(b)\nf(c)\nmin_m = 2\nif max(d) == 2:\n print(0)\nelif max(d):\n min_m = min(1, min_m)\nelse:\n for j in range(3):\n for i in range(1, 8):\n if d[j][i] == 1:\n if d[j][i - 1] + d[j][i + 1] == 1:\n min_m = min(1, min_m)\n elif d[j][i - 1] == d[j][i + 1] == 1:\n min_m = min(0, min_m)\n print(min_m)\n else:\n if d[j][i - 1] == d[j][i + 1] == 1:\n min_m = min(1, min_m)\nmin_m = min(2, min_m)\nprint(min_m)"}, {"source_code": "a = input()\nk=0\na1 = a[0]+a[1]\na2 = a[3]+a[4]\na3 = a[6]+a[7]\nq=[]\nw=[]\nw1=[]\nq1=[]\nt=[]\nt1=[0]*3\nw.append(int(a[0]))\nw.append(int(a[3]))\nw.append(int(a[6]))\nq.append(a[1])\nq.append(a[4])\nq.append(a[7])\nt = sorted(w)\nt = list(t)\nfor i in range(3):\n for b in range(3):\n if w[i] == t[b]:#\u0446\u0438\u0444\u0440\u044b\n t1[b] = q[i]#\u0431\u0443\u043a\u0432\u044b\nif a1 == a2 and a2 == a3 and a1 == a3:\n print(0)\nelif a1 == a2 or a2 == a3 or a1 == a3:\n print(1) \nelse:\n if t1[0]==t1[1]==t1[2]:\n for i in range(2):\n if t[i] != t[i+1]-1:\n k+=1\n if k==0:\n print(0)\n elif ((t1[0] == t1[1]) and ((abs(t[1] - t[0])==1) or (abs(t[1] - t[0])==2))) or ((t1[0] == t1[2]) and ((abs(t[2] - t[0])==1) or (abs(t[2] - t[0])==2))) or ((t1[2] == t1[1]) and ((abs(t[1] - t[2])==1) or (abs(t[1] - t[2])==2))) :\n print(1)\n else:\n print(2)\n\n \n "}, {"source_code": "# Coding credits Moaz Adnan\nmy_String = list(raw_input().split())\nnum = []\nletter =[]\nfor item in my_String:\n\tletter.append(item[1])\n\tnum.append(int(item[0]))\nif len(set(my_String)) == 1:\n\tprint (0)\nelif len(set(letter)) <= 2:\n\tif num[0] == num[1] or num[1] == num[2] or num[0] == num[2]:\n\t\tprint(1)\n\telif abs(num[0] - num[1]) + abs(num[1] - num[2]) == 3:\n\t\tprint(0)\n\telse:\n\t\tprint(2)\nelse:\n\tprint(2)\n"}, {"source_code": "cards= list(map(str,input().split()))\ndict={'p':[],'m':[],'s':[]}\nmin_draw=2\nfor i in cards:\n dict[str(i)[1]].append(int(str(i)[0]))\nfor j in dict.keys():\n m=3-len(dict[j])\n if min_draw>m:\n min_draw=m\n dict[j].sort()\n if len(dict[j])==3:\n n=2\n if dict[j][2]-dict[j][0]==2:\n n=0\n else:\n if dict[j][1]-dict[j][0]<=2 or dict[j][2]-dict[j][1]<=2:\n n=1\n if min_draw>n:\n min_draw=n\n if len(dict[j])==2:\n if dict[j][1]-dict[j][0]<=2:\n if min_draw>1:\n min_draw=1\n\nprint(min_draw)\n"}, {"source_code": "import sys\n\nss = sys.stdin.readline().replace('\\n', '').split()\n\ndef brick (sb):\n\treturn (int(sb[0]), sb[1])\n\nss = map(brick, ss)\nss = sorted(ss)\na = ss[0]\nb = ss[1]\nc = ss[2]\n\nif ss[0] == ss[1] and ss[1] == ss[2]:\n\tprint \"0\"\nelif a[1] == b[1] and b[1] == c[1] and a[0] == b[0]-1 and b[0] == c[0]-1:\n\tprint \"0\"\nelif a == b or b == c or a == c:\n\tprint \"1\"\nelif (a[1] == b[1] and a[0] == b[0]-1) or (b[1] == c[1] and b[0] == c[0]-1) or (a[1] == c[1] and a[0] == c[0]-1):\n\tprint \"1\"\nelse:\n\tprint \"2\""}, {"source_code": "l=input().split()\nif(len(set(l))==1):\n\tprint(0)\nelse:\n\td=dict()\n\t#d1=dict('s':0,'m':0;'p':0)\n\tfor i in l:\n\t\tif(i[1] not in d):\n\t\t\td[i[1]]=[int(i[0])]\n\t\telse:\n\t\t\t\n\t\t\td[i[1]].append(int(i[0]))\n\tmi=9\n\tfor i in d.values():\n\t\tif(len(i)>0):\n\t\t\ti.sort()\n\t\t\tif(len(i)==3):\n\t\t\t\t\n\t\t\t\tc=[]\n\t\t\t\tfor j in range(0,2):\n\t\t\t\t\tc.append(i[j+1]-i[j])\n\t\t\t\tx=min(c)\n\t\t\t\tif(x==1 and c.count(1)==2):\n\t\t\t\t\tmi=0\n\t\t\t\telif(x==2):\n\t\t\t\t\tif(mi>1):\n\t\t\t\t\t\tmi=1\n\t\t\t\telif(x==0):\n\t\t\t\t\ty=c.count(0)\n\t\t\t\t\ty=3-y\n\t\t\t\t\tif(y<mi):\n\t\t\t\t\t\tmi=y\n\t\t\t\telse:\n\t\t\t\t\tif(mi>3):\n\t\t\t\t\t\tmi=3\n\t\t\t\t\t\n\t\t\t\t\n\t\t\telif(len(i)==2):\n\t\t\t\tx=i[1]-i[0]\n\t\t\t\tif(x==0):\n\t\t\t\t\tmi=0\n\t\t\t\telse:\n\t\t\t\t\tif(x<mi):\n\t\t\t\t\t\tmi=x\n\t\t\telse:\n\t\t\t\tx=2\n\t\t\t\tif(mi>x):\n\t\t\t\t\tmi=x\n\t\telse:\n\t\t\tif(mi>3):\n\t\t\t\tmi=3\n\tprint(mi)"}, {"source_code": "\nimport sys\n\nt = 1\nif len(sys.argv) > 1:\n t = int(raw_input())\n\nfor i in xrange(t):\n a = map(list, raw_input().split())\n a = map(lambda x: (int(x[0]), x[1]), a)\n a.sort()\n\n r1 = len(set(a)) - 1\n\n r21 = a[0][0] + 1 == a[1][0] and a[0][1] == a[1][1]\n r22 = a[1][0] + 1 == a[2][0] and a[1][1] == a[2][1]\n r23 = a[0][0] + 1 == a[2][0] and a[0][1] == a[2][1]\n \n r2 = 2 - r21 - r22 - r23\n\n r31 = a[0][0] + 2 == a[1][0] and a[0][1] == a[1][1]\n r32 = a[1][0] + 2 == a[2][0] and a[1][1] == a[2][1]\n r33 = a[0][0] + 2 == a[2][0] and a[0][1] == a[2][1]\n \n r3 = 2 - (r31 or r32 or r33)\n\n print min(r1, r2, r3)\n"}, {"source_code": "import sys\nimport math\nfrom collections import defaultdict\n#sys.stdin=open('input.txt','r')\n#sys.stdout=open('output.txt','w')\na=list(input().split())\nd={}\nb=[]\nc=0\nfor x in a:\n\tif x[1] in d:\n\t\td[x[1]].append(int(x[0]))\n\telse:\n\t\td[x[1]]=[int(x[0])]\n\t\tb.append(x[1])\n\t\tc+=1\nif c==1:\n\tt=b[0]\n\td[b[0]].sort()\n\tif ((d[t][1]-d[t][0])==1 and (d[t][2]-d[t][1])==1) or ((d[t][1]-d[t][0])==0 and (d[t][2]-d[t][1])==0):\n\t\tprint('0')\n\telif (d[t][1]-d[t][0])==1 or (d[t][2]-d[t][1])==1 or (d[t][2]-d[t][1])==0 or (d[t][2]-d[t][1])==0:\n\t\tprint('1')\n\telse:\n\t\tprint('2')\nelif c==2:\n\tt1=b[0]\n\tt2=b[1]\n\tl1=len(d[t1])\n\tl2=len(d[t2])\n\tif l1==2 and (abs(d[t1][0]-d[t1][1]==1) or abs(d[t1][0]-d[t1][1]==0)):\n\t\tprint('1')\n\telif l2==2 and (abs(d[t2][0]-d[t2][1]==1) or abs(d[t2][0]-d[t2][1]==0)):\n\t\tprint('1')\n\telse:\n\t\tprint('2')\nelse:\n\tprint('2')"}, {"source_code": "#d=[[] for i in range(26)]\na=[0]*26\nd={'p':[],'s':[],'m':[]}\nfor i in input().split():\n\td[i[1]]+=int(i[0]),\n\ta[ord(i[1])-97]+=1\nif max(a)==1:print(2)\nelse:\n\tx=chr(a.index(max(a))+97);v=[]\n\tif len(d[x])==2:\n\t\tg=abs(d[x][0]-d[x][1])\n\t\tif g==1 or g==0 or g==2:print(1)\n\t\telse:print(2)\n\telse:\n\t\tv+=abs(d[x][0]-d[x][1]),\n\t\tv+=abs(d[x][0]-d[x][2]),\n\t\tv+=abs(d[x][1]-d[x][2]),\n\t\tprint(2-max(2 if v.count(0)==3 else v.count(0),v.count(1),1 if v.count(2)>0 else 0))"}, {"source_code": "from collections import defaultdict\nfrom copy import deepcopy\nimport sys\ninput = sys.stdin.readline\n'''\nfor CASES in range(int(input())):\nn, m = map(int, input().split())\nn = int(input())\nA = list(map(int, input().split()))\nS = input().strip()\nsys.stdout.write(\" \".join(map(str,ans))+\"\\n\")\n'''\ninf = 100000000000000000 # 1e17\nmod = 998244353\nB = [\"1s\", \"2s\", \"3s\", \"4s\", \"5s\", \"6s\", \"7s\", \"8s\", \"9s\", \"1m\", \"2m\", \"3m\", \"4m\",\n \"5m\", \"6m\", \"7m\", \"8m\", \"9m\", \"1p\", \"2p\", \"3p\", \"4p\", \"5p\", \"6p\", \"7p\", \"8p\", \"9p\"]\nA = list(map(str, input().split()))\nA.sort()\nif A[-1] == A[-2] == A[-3]:\n print(0)\nelif A[-1] == A[-2] or A[-2] == A[-3]:\n print(1)\nelse:\n if A[0][1] == A[1][1] == A[2][1] and ord(A[0][0]) + ord(A[2][0]) == ord(A[1][0]) * 2:\n print(0)\n sys.exit()\n for b in B:\n C = deepcopy(A)\n C.append(b)\n C.sort()\n if (C[0][1] == C[1][1] == C[2][1] and ord(C[0][0]) + ord(C[2][0]) == ord(C[1][0]) * 2):\n if (C[1][1] == C[2][1] == C[3][1] and ord(C[1][0]) + ord(C[3][0]) == ord(C[2][0]) * 2):\n print(1)\n sys.exit()\n print(2)\n\n # the end\n"}, {"source_code": "a, b, c = map(str, input().split())\nd = []\nfor i in range(3):\n d.append([0] * 9)\n\ndef f(k):\n if k[1] == 'm':\n d[0][int(k[0]) - 1] += 1\n elif k[1] == 'p':\n d[1][int(k[0]) - 1] += 1\n else:\n d[2][int(k[0]) - 1] += 1\nf(a)\nf(b)\nf(c)\nmin_m = 2\nif max(max(d)) == 3:\n min_m = min(0, min_m)\nelif max(max(d)) == 2:\n min_m = min(1, min_m)\nelse:\n for j in range(3):\n for i in range(1, 8):\n if d[j][i] == 1:\n if d[j][i - 1] + d[j][i + 1] == 1:\n min_m = min(1, min_m)\n elif d[j][i - 1] == d[j][i + 1] == 1:\n min_m = min(0, min_m)\n else:\n if d[j][i - 1] == d[j][i + 1] == 1:\n min_m = min(1, min_m)\nmin_m = min(2, min_m)\nprint(min_m)"}, {"source_code": "a = [str(i) for i in input().split()]\na.sort()\nfirst = a[0]\nsecond = a[1]\nthird = a[2]\nfirstnum = int(first[0])\nsecondnum = int(second[0])\nthirdnum = int(third[0])\nif(first == second):\n\tif(second == third):\n\t\tprint(0)\n\telse:\n\t\tprint(1)\nelif(second == third):\n\tprint(0)\nelif(first[1] == second[1] and second[1] == third[1]):\n\tif(firstnum +1 == secondnum and secondnum + 1 == thirdnum):\n\t\tprint(0)\n\telif(firstnum + 1 == secondnum or firstnum+2 == secondnum):\n\t\tprint(1)\n\telif(secondnum + 1 == thirdnum or secondnum + 2 == thirdnum):\n\t\tprint(1)\n\telse:\n\t\tprint(2)\nelif(first[1] == second[1] and firstnum + 1 == secondnum or firstnum+2 == secondnum):\n\tprint(1)\nelif(second[1] == third[1] and secondnum + 1 == thirdnum or secondnum+2 == thirdnum):\n\tprint(1)\nelif(first[1] == third[1] and (firstnum + 1 == thirdnum or firstnum + 2 == thirdnum)):\n\tprint(1)\nelse:\n\tprint(2)"}, {"source_code": "import sys\nimport math\nimport bisect\nimport atexit\nimport io\nimport heapq\nfrom collections import defaultdict, Counter\nMOD = int(1e9+7)\n\n\n# n = map(int, raw_input().split())\n# input = map(int, raw_input().split())\ndef main():\n a, b, c = raw_input().split()\n d = defaultdict(list)\n num = []\n ans = 2\n for st in (a,b,c):\n nu, ch = st\n nu = int(nu)\n d[ch].append(int(nu))\n num.append(nu)\n num.sort()\n if num[0] == num[-1]-2:\n ans = 0\n if num[0] == num[1]-2 or num[1] == num[-1]-2 or num[0] == num[1]-1 or num[1] == num[2]-1:\n ans = min(ans, 1)\n for k, v in d.items():\n v.sort()\n if len(v) == 3:\n ans = 0\n elif len(v)==2:\n ans = min(ans, 1)\n print ans\n\nmain()\n"}, {"source_code": "a, b, c = map(str, input().split())\na0, b0, c0 = int(a[0]), int(b[0]), int(c[0])\nmx, mn = max(a0, b0, c0), min(a0, b0, c0)\nif a == b == c or mx - mn == 2:\n print(0)\nelse:\n if abs(a0 - b0) == 1 or abs(a0 - b0) == 2 or abs(c0 - b0) == 1 or abs(c0 - b0) == 2 or abs(a0 - c0) == 1 or abs(a0 - c0) == 2:\n print(1)\n else:\n print(2)\n"}, {"source_code": "a,b,c=raw_input().split()\nif a==b and b==c:\n print 0 # all equal\nelif a==b or b==c or a==c:\n print 1 # any two equal\nelif a[1]==b[1]:\n if b[1]==c[1]: # all same cat\n if abs(int(a[0])-int(b[0]))<3 and abs(int(c[0])-int(b[0]))<3 and abs(int(a[0])-int(c[0]))<3:\n if 2*int(b[0])==int(a[0])+int(c[0]) and 2*int(c[0])==int(a[0])+int(b[0]) or 2*int(a[0])==int(c[0])+int(b[0]): # same cat and AP\n print 0\n else:\n print 1\n elif abs(int(a[0])-int(b[0]))<3 or abs(int(c[0])-int(b[0]))<3 or abs(int(a[0])-int(c[0]))<3:\n print 1\n else:\n print 2\n elif abs(int(a[0])-int(b[0]))<3: # only a and b same cat\n print 1\n else:\n print 2\nelif c[1]==b[1]: # b and c same cat\n if abs(int(c[0])-int(b[0]))<3: # b and c consec\n print 1\n else:\n print 2 # b and c not consec\nelif a[1]==c[1]:\n if abs(int(a[0])-int(c[0]))<3:\n print 1\n else:\n print 2\nelse:\n print 2"}, {"source_code": "a = input().split()\np = []\nm = []\ns = []\nfor i in a:\n n = int(i[0])\n if i[1]=='p':\n p.append(n)\n elif i[1]=='m':\n m.append(n)\n else:\n s.append(n)\n\nfor qq in (p,m,s):\n if len(qq)>2:\n sp = list(sorted(list(set(qq))))\n if len(sp)==1:\n print(0)\n elif len(sp)==2:\n print(1)\n else:\n if max(sp)-min(sp)==2:\n print(0)\n else:\n if sp[1]-sp[0]<3:\n print(1)\n elif sp[2]-sp[1]<3:\n print(1)\n else:\n print(0)\n exit()\nelse:\n if len(p)==2:\n if abs(p[0]-p[1])<3:\n print(1)\n else:\n print(2)\n\n elif len(m)==2:\n if abs(m[0]-m[1])<3:\n print(1)\n else:\n print(2)\n\n elif len(s)==2:\n if abs(s[0]-s[1])<3:\n print(1)\n else:\n print(2)\n else:\n print(2)"}, {"source_code": "p = input().split()\np = set(p)\nans = 2\nfor i1 in p:\n for i2 in p:\n if i1[1] == i2[1] and 1 <= int(i1[0]) - int(i2[0]) <= 2:\n ans -= 1\nans = min(ans, len(p) - 1)\nprint(max(0, ans))\n"}, {"source_code": "d = {\n 'm': 10,\n 's': 20,\n 'p': 30\n}\n\na, b, c = list(sorted([int(i[0]) + d[i[1]] for i in input().split(' ')]))\n\nif (a == b and b == c) or (a == b - 1 and b == c - 1):\n print(0)\n exit()\nif a == b - 1 or b == c - 1 or a == b or b == c:\n print(1)\n exit()\nprint(2)\n"}, {"source_code": "def f(a, b, c):\n if a[0] > b[0]:\n a, b = b, a\n if abs(int(a[0]) - int(b[0])) == 1 and a[1] == b[1]:\n if a[1] == c[1] and abs(int(c[0]) - int(b[0])) == 1:\n return 0\n else:\n return 1\n if abs(int(a[0]) - int(b[0])) == 2 and a[1] == b[1]:\n return 1\n return 2\n\n\na, b, c = input().split()\ns1 = set()\ns1.add(a)\ns1.add(b)\ns1.add(c)\nc1 = len(s1) - 1\nprint(min(c1, f(a, b, c), f(a, c, b), f(b, c, a)))\n"}, {"source_code": "o = []\nn = input()\np = 0\nfor i in range(3):\n o.insert(i, n[i + p] + n[i + 1 + p])\n p = p + 2\no = sorted(o)\nans = 2\nif (o[0][1] == o[1][1]) and (int(o[1][0]) - int(o[0][0]) < 2):\n ans = ans - 1\nif (o[1][1] == o[2][1]) and (int(o[2][0]) - int(o[1][0]) < 2):\n ans = ans - 1\nprint(ans)\n\n"}, {"source_code": "a, b, c = map(str, input().split())\na0, b0, c0 = int(a[0]), int(b[0]), int(c[0])\nmx, mn = max(a0, b0, c0), min(a0, b0, c0)\nif a == b == c or mx - mn == 2:\n print(0)\nelse:\n if abs(a0 - b0) <= 2 or abs(c0 - b0) <= 2 or abs(a0 - c0) <= 2:\n print(1)\n else:\n print(2)\n"}, {"source_code": "\n\nt=list(map(str,input().split()))\nt.sort()\n\ns=0\nins=0\nist=0\nm=0\ninm=0\nimt=0\np=0\ninp=0\nipt=0\ncount=1\nshout=1\nprev=0\nlast=1\npout=1\none=0\nfor i in range(1,len(t)):\n\tprev=i-1\n\tif(t[i][1]==t[prev][1]):\n\t\tif(int(t[i][0])==int(t[prev][0])):\n\t\t\tlast=last+1\n\t\telif((int(t[i][0])==(int(t[prev][0])+1)) ):\n\t\t\tcount=count+1\n\t\telse:\n\t\t\tif((int(t[i][0])==(int(t[prev][0])+2))):\n\t\t\t\tone=1\n\t\t\t\t\n\telse:\n\t\tshout=max(count,shout)\n\t\tpout=max(last,pout)\n\t\tcount=1\n\t\tlast=1\nif(one==0):\n\tprint(min(3-shout,3-count,3-pout,3-last))\nelse:\n\tprint(min(3-shout,3-count,3-pout,3-last,1))\n\t\n\t\t\t\n\t\t\n\t\n\n\n\t\t\n\n\t\n"}, {"source_code": " \n \n# target Specialist \n \n \n\"\"\" \nBeautiful is better than ugly.\n Explicit is better than implicit.\nSimple is better than complex.\n Complex is better than complicated.\nFlat is better than nested.\n Sparse is better than dense.\n \n * Readability counts *\n \n // Author : raj1307 - Raj Singh\n // Date : 12.07.19\n \n\"\"\"\n \nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pow,pi\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n \nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n \ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p1\n return res\n \ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n \n \n \ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n \n \ndef main():\n \n \n \n #for _ in range(ii()):\n \n \n a,b,c=mi()\n \n \n if a==b and b==c:\n print(0)\n \n elif (a==b and b!=c) or (a==c and b!=c) or (c==b and a!=c):\n print(1)\n \n else:\n \n l=[[int(a[0]),a[1]],[int(b[0]),b[1]],[int(c[0]),c[1]]]\n \n l=sort2(l)\n \n if l[1][0]==l[0][0]+1 and l[2][0]==l[1][0]+1 and a[1]==b[1] and c[1]==b[1]:\n print(0)\n \n \n elif (l[1][0]==l[0][0]+1 and l[1][1]==l[0][1]) or (l[2][0]==l[1][0]+1 and l[2][1]==l[1][1]) or (l[2][0]==l[0][0]+2 and l[2][1]==l[0][1]) or (l[1][0]==l[0][0]+2 and l[1][1]==l[0][1]) or (l[2][0]==l[1][0]+2 and l[2][1]==l[1][1]):\n print(1)\n \n \n else:\n print(2)\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n# region fastio\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n \n# Comment Read()"}, {"source_code": "#Tokitsukaze and Mahjong\nDEBUG = False\n\ndef debug(to_print_args):\n if not DEBUG:\n return\n for arg in to_print_args:\n print(arg,end='')\n print()\n\n# def shuntsu(num1,num2,num3,a1,a2,a3):\n# if num1+1=num2 and num1+2=num3:\n# if a1=a2 and a2=a3:\n# return True;\n# else\n\na=input().split()\n\nstrings=[a[0][1],a[1][1],a[2][1]];\nnumbers=[a[0][0],a[1][0],a[2][0]];\n\nnumbers=list(map(int,numbers));\n\n\nif strings[0]==strings[1] and strings[1]==strings[2]:\n if numbers[0]==numbers[1] and numbers[1]==numbers[2]:\n print(0);\n elif abs(numbers[0]-numbers[1])==1 and abs(numbers[2]-numbers[1])==1 and abs(numbers[2]-numbers[0])==2:\n print(0);\n elif abs(numbers[0]-numbers[1])==1 and abs(numbers[2]-numbers[1])==1 and abs(numbers[2]-numbers[0])==1:\n print(1);\n elif abs(numbers[0]-numbers[1])==1 or abs(numbers[1]-numbers[2])==1 or abs(numbers[0]-numbers[2])==1:\n print(1);\n elif numbers[0]==numbers[1] or numbers[1]==numbers[2] or numbers[0]==numbers[2]:\n print(1);\n elif abs(numbers[0]-numbers[1])==2 or abs(numbers[1]-numbers[2])==2 or abs(numbers[0]-numbers[2])==2:\n print(1);\n else:\n print(2);\nelif strings[0]==strings[1]:\n if numbers[0]==numbers[1]:\n print(1);\n elif abs(numbers[0]-numbers[1])==1:\n print(1);\n elif abs(numbers[0]-numbers[1])==2:\n print(1);\n else:\n print(2);\n\nelif strings[2]==strings[1]:\n if numbers[2]==numbers[1]:\n print(1);\n elif abs(numbers[2]-numbers[1])==1:\n print(1);\n elif abs(numbers[2]-numbers[1])==2:\n print(1);\n else:\n print(2);\n\n\nelif strings[0]==strings[2]:\n if numbers[0]==numbers[2]:\n print(1);\n elif abs(numbers[0]-numbers[2])==1:\n print(1);\n elif abs(numbers[0]-numbers[2])==2:\n print(1);\n else:\n print(2);\n\nelse:\n print(2);\n\n"}, {"source_code": "b=list(input().split())\na=b[0]\nc=b[1]\nd=b[2]\np=[int(a[0]),int(c[0]),int(d[0])]\np.sort()\nif a[1]==c[1]:\n if a[1]==d[1]:\n k=p[1]-p[0]\n q=p[2]-p[1]\n if k==0 and q==0:\n print(0)\n elif k==0 or q==0:\n print(1)\n elif k==1 and q==1:\n print(0)\n elif k==1 or q==1:\n print(1)\n else:\n print(2)\n else:\n if int(a[0])==int(c[0]):\n print(1)\n elif abs(int(a[0])-int(c[0]))==1:\n print(1)\n else:\n print(2)\nelse:\n if c[1]==d[1]:\n if int(c[0]) == int(d[0]):\n print(1)\n elif abs(int(c[0]) - int(d[0])) == 1:\n print(1)\n else:\n print(2)\n elif a[1]==d[1]:\n if int(a[0]) == int(d[0]):\n print(1)\n elif abs(int(a[0]) - int(d[0])) == 1:\n print(1)\n else:\n print(2)\n else:\n print(2)\n\n\n\n\n\n\n"}, {"source_code": "a=list(input().split())\nar1=[]\nar2=[]\nfor i in a:\n ar1.append(int(i[0]))\n ar2.append(i[1])\ns=set()\nfor i in range(3):\n for j in range(i,3):\n if ar2[i]==ar2[j]:\n s.add(i)\n s.add(j)\nif len(s)==0:\n print(2)\nelif len(s)==2:\n i1=s.pop()\n i2=s.pop()\n if abs(ar1[i1]-ar1[i2])<=1:\n print(1)\n else:\n print(2)\nelse:\n ar1.sort()\n d1=ar1[1]-ar1[0]\n d2=ar1[2]-ar1[1]\n if d1==0:\n if d2==0:\n print(0)\n else:\n print(1)\n elif d1==1:\n if d2==1:\n print(0)\n else:\n print(1)\n else:\n if d2==0 or d2==1:\n print(1)\n else:\n print(2)\n "}, {"source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import setcheckinterval, stdin\nsetcheckinterval(1000)\n\n# print(\"Case #{}: {} {}\".format(i, n + m, n * m))\n\niin = lambda: int(stdin.readline())\nlin = lambda: list(map(int, stdin.readline().split()))\n\ndef check1(a):\n n=len(a)\n ans=1\n for i in range(n):\n ch=1\n j=i+1\n while j<n:\n if a[j]==a[j-1]+1:\n ch+=1\n else:\n break\n j+=1\n ans=max(ans,ch)\n return 3-ans\n\ndef check2(a):\n d={}\n for i in a:\n try:\n d[i]+=1\n except:\n d[i]=1\n return 3-max(d.values()) if d else 3\n\n\n\n\ns=input().split()\na1=[];a2=[];a3=[]\n\nfor i in s:\n if i[1]=='m':\n a1.append(int(i[0]))\n elif i[1]=='p':\n a2.append(int(i[0]))\n elif i[1]=='s':\n a3.append(int(i[0]))\na1.sort()\na2.sort()\na3.sort()\n\nans=min(check1(a1),check2(a1),check1(a2),check2(a2),check1(a3),check2(a3))\nprint(ans)"}, {"source_code": "a, b, c = sorted(input().split(), key = lambda x: int(x[0]))\n\nif a == b == c: print(0)\nelif a[1] == b[1] == c[1] and int(a[0])+2 == int(b[0])+1 == int(c[0]): print(0)\nelif a == b or b == c or c == a: print(1)\nelif a[1] == b[1] and int(a[0])+2 == int(b[0])+1: print(1)\nelif b[1] == c[1] and int(b[0])+2 == int(c[0])+1: print(1)\nelse: print(2)"}, {"source_code": "# int(input())\n# [int(s) for s in input().split()]\n# input()\n\n\ndef solve():\n m = [s for s in input().split()]\n d = {\"m\": [], \"p\": [], \"s\": []}\n\n ans = float(\"inf\")\n\n for s in m:\n d[s[1]].append(int(s[0]))\n\n for s in d:\n if len(d[s]) == 1:\n ans = min(ans, 2)\n elif len(d[s]) == 2:\n d[s] = sorted(d[s])\n if d[s][0] == d[s][1]:\n ans = min(ans, 1)\n elif d[s][0]+1 == d[s][1] or d[s][0]+2 == d[s][1]:\n ans = min(ans, 1)\n elif len(d[s]) == 3:\n d[s] = sorted(d[s])\n if d[s][0] == d[s][1]:\n if d[s][1] == d[s][2]:\n ans = min(ans, 0)\n else:\n ans = min(ans, 1)\n else:\n if d[s][0]+1 == d[s][1]:\n if d[s][1] + 1 == d[s][2]:\n ans = min(ans, 0)\n else:\n ans = min(ans, 1)\n elif d[s][0]+2 == d[s][1]:\n ans = min(ans, 1)\n\n print(ans)\n \n\nif __name__ == \"__main__\":\n solve()"}, {"source_code": "a,b,c = input().split();\nimport sys;\nx = int(a[0]);\ny = int(b[0]);\nz = int(c[0]);\nif(a==b==c):\n print(0);\n sys.exit();\nelse:\n arr = [x,y,z];\n arr.sort();\n if(a[1]==b[1]==c[1]):\n if((y-x)==1 and (z-y)==1):\n print(0);\n sys.exit();\n else:\n print(2);\n sys.exit();\n \n if(a[1]==b[1] or b[1]==c[1] or c[1]==a[1]):\n \n if(a[1]==b[1]):\n if(abs(x-y)==1 or abs(x-y)==2):\n print(1);\n sys.exit();\n \n else:\n print(2);\n sys.exit();\n if(b[1]==c[1]):\n if(abs(y-z)==1 or abs(y-z)==2):\n print(1);\n sys.exit();\n else:\n print(2);\n sys.exit();\n if(a[1]==c[1]):\n if(abs(x-z)==1 or abs(x-z)==2):\n print(1);\n sys.exit();\n else:\n print(2);\n sys.exit();\n else:\n print(2);\n sys.exit();\n\n else:\n print(2);\n sys.exit();\n\n\n"}, {"source_code": "from sys import stdin\nfrom math import fabs\n\ndef prob(x,y,z):\n acu = 0\n \n if fabs(max(int(x[0]),int(y[0]),int(z[0])) - min(int(x[0]),int(y[0]),int(z[0]))) == 2 and (int(x[0]) + int(y[0]) + int(z[0])) % 3 == 0 :\n return True\n return False \n\ndef need(x,y,z):\n if x == y and y == z:\n return 0\n elif (x == y and y !=z) or (x == z and z != y) or (z == y and y != x):\n return 1\n elif x[1] == y[1] == y[1]: \n if prob(x,y,z):\n return 0\n elif (fabs(int(x[0])-int(y[0]) == 1) or (fabs(int(x[0])-int(z[0]))) == 1) or (abs(int(z[0])-int(y[0])) == 1):\n return 1\n else:\n return 2\n elif (x[1] == y[1] != z[1]):\n if (fabs(int(x[0])-int(y[0]))) == 1:\n return 1\n else:\n return 2\n elif x[1] == z[1] != y[1]:\n if (fabs(int(x[0])-int(z[0]))) == 1:\n return 1\n else:\n return 2\n elif z[1] == y[1] != x[1]:\n if (fabs(int(y[0])-int(z[0]))) == 1:\n return 1\n else:\n return 2 \n else: \n return 2\n\nx,y,z = stdin.readline().split()\n\nprint(need(x,y,z))"}, {"source_code": "# int(input())\n# [int(s) for s in input().split()]\n# input()\n\n\ndef solve():\n m = [s for s in input().split()]\n d = {\"m\": [], \"p\": [], \"s\": []}\n\n ans = float(\"inf\")\n\n for s in m:\n d[s[1]].append(int(s[0]))\n\n for s in d:\n if len(d[s]) == 1:\n ans = min(ans, 2)\n elif len(d[s]) == 2:\n d[s] = sorted(d[s])\n if d[s][0] == d[s][1]:\n ans = min(ans, 1)\n elif d[s][0]+1 == d[s][1] or d[s][0]+2 == d[s][1]:\n ans = min(ans, 1)\n elif len(d[s]) == 3:\n d[s] = sorted(d[s])\n if d[s][0] == d[s][1]:\n if d[s][1] == d[s][2]:\n ans = min(ans, 0)\n else:\n ans = min(ans, 1)\n else:\n if d[s][0]+1 == d[s][1]:\n if d[s][1] + 1 == d[s][2]:\n ans = min(ans, 0)\n else:\n ans = min(ans, 1)\n print(ans)\n print(d)\n\n\n\nif __name__ == \"__main__\":\n solve()"}, {"source_code": "cards = input().split()\nc1 = cards[0]\nc2 = cards[1]\nc3 = cards[2]\nif c1 == c2 == c3:\n ans = 0\nelif (c1 != c3 and c1 == c2) or (c2 != c1 and c2 == c3) or (c2 != c1 and c1 == c3):\n ans = 1\nelse:\n S = [int(c1[0]), int(c2[0]), int(c3[0])]\n if c1[1] == c2[1] == c3[1] and max(S) - min(S) == 2:\n ans = 0\n elif c1[1] == c2[1] == c3[1]:\n if int(c2[0]) - int(c1[0]) == 1 or int(c1[0]) - int(c2[0]) == 1:\n ans = 1\n elif int(c2[0]) - int(c1[0]) == 2 or int(c1[0]) - int(c2[0]) == 2:\n ans = 1\n elif int(c3[0]) - int(c1[0]) == 1 or int(c1[0]) - int(c3[0]) == 1:\n ans = 1\n elif int(c3[0]) - int(c1[0]) == 2 or int(c1[0]) - int(c3[0]) == 2:\n ans = 1\n elif int(c2[0]) - int(c3[0]) == 1 or int(c3[0]) - int(c2[0]) == 1:\n ans = 1\n elif int(c2[0]) - int(c3[0]) == 2 or int(c3[0]) - int(c2[0]) == 2:\n ans = 1\n else:\n ans = 2\n elif c1[1] == c2[1] and int(c2[0]) - int(c1[0]) == 1 or int(c1[0]) - int(c2[0]) == 1:\n ans = 1\n elif c1[1] == c2[1] and int(c2[0]) - int(c1[0]) == 2 or int(c1[0]) - int(c2[0]) == 2:\n ans = 1\n elif c1[1] == c3[1] and int(c3[0]) - int(c1[0]) == 1 or int(c1[0]) - int(c3[0]) == 1:\n ans = 1\n elif c1[1] == c3[1] and int(c3[0]) - int(c1[0]) == 2 or int(c1[0]) - int(c3[0]) == 2:\n ans = 1\n elif int(c2[0]) - int(c3[0]) == 1 or int(c3[0]) - int(c2[0]) == 1 and c2[1] == c3[1]:\n ans = 1\n elif int(c2[0]) - int(c3[0]) == 2 or int(c3[0]) - int(c2[0]) == 2 and c2[1] == c3[1]:\n ans = 1\n else:\n ans = 2\nprint(ans)\n"}, {"source_code": "#Tokitsukaze and Mahjong\nDEBUG = False\n\ndef debug(to_print_args):\n if not DEBUG:\n return\n for arg in to_print_args:\n print(arg,end='')\n print()\n\n# def shuntsu(num1,num2,num3,a1,a2,a3):\n# if num1+1=num2 and num1+2=num3:\n# if a1=a2 and a2=a3:\n# return True;\n# else\n\na=input().split()\n\nstrings=[a[0][1],a[1][1],a[2][1]];\nnumbers=[a[0][0],a[1][0],a[2][0]];\n\nnumbers=list(map(int,numbers));\n\n\nif strings[0]==strings[1] and strings[1]==strings[2]:\n if numbers[0]==numbers[1] and numbers[1]==numbers[2]:\n print(0);\n elif abs(numbers[0]-numbers[1])==1 and abs(numbers[2]-numbers[1])==1:\n print(0);\n elif abs(numbers[0]-numbers[1])==1 or abs(numbers[1]-numbers[2])==1 or abs(numbers[0]-numbers[2])==1:\n print(1);\n elif numbers[0]==numbers[1] or numbers[1]==numbers[2] or numbers[0]==numbers[2]:\n print(1);\n elif abs(numbers[0]-numbers[1])==2 or abs(numbers[1]-numbers[2])==2 or abs(numbers[0]-numbers[2])==2:\n print(1);\n\nelif strings[0]==strings[1]:\n if numbers[0]==numbers[1]:\n print(1);\n elif abs(numbers[0]-numbers[1])==1:\n print(1);\n\nelif strings[2]==strings[1]:\n if numbers[2]==numbers[1]:\n print(1);\n elif abs(numbers[2]-numbers[1])==1:\n print(1);\n\nelif strings[0]==strings[2]:\n if numbers[0]==numbers[2]:\n print(1);\n elif abs(numbers[0]-numbers[2])==1:\n print(1);\n\nelse:\n print(2);\n\n"}, {"source_code": "tl=list(map(str,input().split()))\nn1=tl[0][0]\nn2=tl[1][0]\nn3=tl[2][0]\ns1=tl[0][1]\ns2=tl[1][1]\ns3=tl[2][1]\nnl=[int(n1),int(n2),int(n3)]\nsl=[s1,s2,s3]\n#print(nl)\n#print(sl)\nif len(set(sl))==3:\n print(2)\nelif len(set(sl))==1:\n if len(set(nl))==1:\n print(0)\n elif len(set(nl))==2:\n print(1)\n else:\n tmnl=sorted(nl)\n if tmnl[1]==tmnl[0]+1 and tmnl[2]==tmnl[1]+1:\n print(0)\n elif tmnl[1]==tmnl[0]+1 or tmnl[2]==tmnl[1]+1 :\n print(1)\n else:\n print(2)\nelse:\n if sl[0]==sl[1]:\n if nl[0]==nl[1]:\n print(1)\n elif abs(nl[0]-nl[1])==1:\n print(1)\n else:\n print(0)\n elif sl[1]==sl[2]:\n if nl[1]==nl[2]:\n print(1)\n elif abs(nl[1]-nl[2])==1:\n print(1)\n else:\n print(0)\n else:\n if nl[0]==nl[2]:\n print(1)\n elif abs(nl[0]-nl[2])==1:\n print(1)\n else:\n print(0)\n \n \n \n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n"}, {"source_code": "a = list(input().split())\n\nk = dict()\nmk = 0\nmki = \"\"\ns = 0\n\nfor e in a:\n\tif e not in k:\n\t\tk[e] = 0\n\tk[e] += 1\n\n\tif k[e] > mk:\n\t\tmk = k[e]\n\t\tmki = e\n\nif mk >= 3:\n\tprint(0)\n\texit(0)\n\n\nfor e in a:\n\ttemp = 1\n\tnum = int(e[:1])\n\tt = e[1:]\n\tif (str(num + 1) + t) in k:\n\t\ttemp += 1\n\tif (str(num - 1) + t) in k:\n\t\ttemp += 1\n\n\tif temp > s:\n\t\ts = temp\n\nif s > mk:\n\tprint(3 - s)\nelse:\n\tprint(3 - mk)\n"}, {"source_code": "arr = list(map(lambda el: [int(el[0]), el[1]], input().split()))\n\nsortt = sorted(arr, key=lambda el: el[0])\n\nresult = 2\n\nfor i in range(3):\n cnt1 = 2\n cnt2 = 2\n base = sortt[i][0]\n for y in range(i+1, 3):\n if sortt[i][1] == sortt[y][1]:\n if sortt[i][0] == sortt[y][0]:\n cnt1 -= 1\n elif sortt[y][0] == base + 1:\n cnt2 -= 1\n elif sortt[y][0] == base + 2:\n cnt2 = 1\n base = sortt[y][0]\n result = min(result, cnt1, cnt2)\n\nprint(result)\n\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nlis = [x for x in input().split()]\nres = 2\ns = set(tuple(lis))\nif len(s) == 1:\n print(0)\nelif len(s) == 2:\n print(1)\nelse:\n res = 2\n for c in lis:\n x = int(c[0]) + 1\n ch = str(x) + c[1]\n if ch in s:\n res -= 1\n print(res)"}, {"source_code": "a, b, c = input().split()\n\nnumbers = [int(a[0]), int(b[0]), int(c[0])]\nletters = [a[1], b[1], c[1]]\nif (a == b == c):\n\tprint(0)\n\nelse:\n\torder = sorted(numbers)\n\tflag = 0\n\tfor i in range(2):\n\t\tdiff = order[i + 1] - order[i]\n\t\tif (diff != 1):\n\t\t\tflag = 1\n\t\t\tbreak\n\tif(flag == 0 and letters[0] == letters[1] == letters[2]):\n\t\tprint(0)\n\n\telse:\n\n\t\t#print(letters)\n\t\tp = letters.count(\"p\")\n\t\tm = letters.count(\"m\")\n\t\ts = letters.count(\"s\")\n\t\t#print(m, p, s)\n\t\tif(p == 1 and m == 1 and s == 1):#each of diff type\n\t\t\tprint(2)\n\n\t\telse:\t\t\n\t\t\tif (m == 3 or p == 3 or s == 3):\n\t\t\t\torder = sorted(numbers)\n\t\t\t\tdiff = []\n\t\t\t\tfor i in range(2):\n\t\t\t\t\tdiff.append(order[i + 1] - order[i])\n\t\t\t\tif(1 in diff or 2 in diff):\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2)\n\t\t\telse:\n\t\t\t\t#1, 2\n\t\t\t\tif (letters[0] == letters[1]):\n\t\t\t\t\ttwos = [numbers[0], numbers[1]]\n\t\t\t\telif(letters[0] == letters[2]):\n\t\t\t\t\ttwos = [numbers[0], numbers[2]]\n\t\t\t\telse:\n\t\t\t\t\ttwos = [numbers[1], numbers[2]]\n\n\t\t\t\tif (abs(twos[1] - twos[0]) == 1 or abs(twos[1] - twos[0]) == 2):\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2)"}, {"source_code": "s=input()\ny=s.split(\" \")\ns1=[]\np1=[]\nm1=[]\nfor i in y:\n if i[1]==\"m\":\n m1.append(int(i[0]))\n elif i[1]==\"s\":\n s1.append(int(i[0]))\n else:\n p1.append(int(i[0]))\n \ns1=sorted(s1)\np1=sorted(p1)\nm1=sorted(m1)\nif len(s1)==len(p1)==len(m1):\n print(2)\nelse:\n if len(s1)>=2:\n if abs(s1[0]-s1[1])<=1:\n if len(s1)>2:\n if abs(s1[1]-s1[2])==abs(s1[0]-s1[1]):\n print(0)\n else:\n print(1)\n else:\n print(1)\n elif len(p1)>=2:\n if abs(p1[0]-p1[1])<=1:\n if len(p1)>2:\n if abs(p1[1]-p1[2])==abs(p1[0]-p1[1]):\n print(0)\n else:\n print(1)\n else:\n print(1)\n else:\n if abs(m1[0]-m1[1])<=1:\n if len(m1)>2:\n if abs(m1[1]-m1[2])==abs(m1[0]-m1[1]):\n print(0)\n else:\n print(1)\n else:\n print(1)\n \n "}, {"source_code": "\nif __name__ == '__main__':\n s = list(map(lambda x: (int(x[0]), x[1]), input().split()))\n m = 2\n s.sort()\n if s[0][0] + 1 == s[1][0] and s[1][0] + 1 == s[2][0] and s[0][1] == s[1][1] == s[2][1]:\n print(0)\n exit(0)\n elif (s[0][0] + 1 == s[1][0] and s[0][1] == s[1][1]) or (s[1][0] + 1 == s[2][0] and s[1][1] == s[2][1]):\n print(1)\n exit(0)\n elif (s[0][0] + 2 == s[1][0] and s[0][1] == s[1][1]) or (s[1][0] + 2 == s[2][0] and s[1][1] == s[2][1]):\n print(1)\n exit(0)\n\n s.sort(key=lambda x: x[1])\n if s[0] == s[1] and s[1] == s[2]:\n print(0)\n exit(0)\n elif s[0] == s[1] or s[1] == s[2]:\n print(1)\n exit(0)\n\n print(2)"}, {"source_code": "a,b,c=[x for x in input().split(' ')]\nn=0\nif a==b and b==c:\n n=0\nelif a==b or b==c or c==a:\n n=1\nelif a[1]==b[1] and a[1]==c[1]:\n z=[int(a[0]),int(b[0]),int(c[0])]\n z.sort()\n if a[0]==b[0] or b[0]==c[0] or a[0]==c[0]:\n n=1\n elif z[2]-z[1]==1 and z[1]-z[0]==1:\n n=0\n \n elif abs(int(a[0])-int(b[0]))==2 or abs(int(a[0])-int(c[0]))==2 or abs(int(b[0])-int(c[0]))==2:\n n=1\n else:\n n=2\nelif a[1]==b[1] or a[1]==c[1] or b[1]==c[1]:\n \n if a[1]==b[1] and abs(int(a[0])-int(b[0])) in [1,2]:\n n=1\n elif a[1]==c[1] and abs(int(a[0])-int(c[0])) in [1,2]:\n n=1\n elif c[1]==b[1] and abs(int(c[0])-int(b[0])) in [1,2]:\n n=1\n else:\n n=2\nelse:\n n=2\nprint(n)\n\n \n "}, {"source_code": "s=input().rstrip().split(' ')\nl=[]\nq=[]\nw=[]\nS=[]\nfor i in range(0,len(s)):\n t=list(s[i])\n if t[1]=='s':\n l.append(int(t[0]))\n elif t[1]=='p':\n q.append(int(t[0]))\n elif t[1]=='m':\n w.append(int(t[0]))\nA=[0]*9\nB=[0]*9\nC=[0]*9\nfor i in range(1,10):\n t=l.count(i)\n A[i-1]+=t;\n t=q.count(i)\n B[i-1]+=t;\n t=w.count(i)\n C[i-1]+=t;\nG=0;\nfor i in range(0,len(A)):\n if A[i]>=3 or B[i]>=3 or C[i]>=3:\n G=1;\n break;\n else:\n S.append(3-A[i])\n S.append(3-B[i])\n S.append(3-C[i])\nif G==1:\n print(0)\nelse:\n l=list(set(l))\n q=list(set(q))\n w=list(set(w))\n l.sort(key=int)\n q.sort(key=int)\n w.sort(key=int)\n if len(l)>=3:\n for i in range(0,len(l)-3+1):\n t=l[i:i+3]\n if t[0]==(t[1]-1) and t[1]==(t[2]-1):\n G=1;\n break;\n elif t[0]==(t[1]-1) and t[1]!=(t[2]-1):\n S.append(1)\n elif t[0]!=(t[1]-1) and t[1]==(t[2]-1):\n S.append(1)\n elif t[1]!=(t[2]-1) and t[0]!=(t[1]-1):\n S.append(2)\n else:\n if len(l)==0:\n S.append(3)\n elif len(l)==1:\n S.append(2)\n elif len(l)==2:\n if l[0]==(l[1]-1):\n S.append(1)\n else:\n S.append(2)\n l=q;\n if len(l)>=3:\n for i in range(0,len(l)-3+1):\n t=l[i:i+3]\n if t[0]==(t[1]-1) and t[1]==(t[2]-1):\n G=1;\n break;\n elif t[0]==(t[1]-1) and t[1]!=(t[2]-1):\n S.append(1)\n elif t[0]!=(t[1]-1) and t[1]==(t[2]-1):\n S.append(1)\n elif t[1]!=(t[2]-1) and t[0]!=(t[1]-1):\n S.append(2)\n else:\n if len(l)==0:\n S.append(3)\n elif len(l)==1:\n S.append(2)\n elif len(l)==2:\n if l[0]==(l[1]-1):\n S.append(1)\n else:\n S.append(2)\n l=w;\n if len(l)>=3:\n for i in range(0,len(l)-3+1):\n t=l[i:i+3]\n if t[0]==(t[1]-1) and t[1]==(t[2]-1):\n G=1;\n break;\n elif t[0]==(t[1]-1) and t[1]!=(t[2]-1):\n S.append(1)\n elif t[0]!=(t[1]-1) and t[1]==(t[2]-1):\n S.append(1)\n elif t[1]!=(t[2]-1) and t[0]!=(t[1]-1):\n S.append(2)\n else:\n if len(l)==0:\n S.append(3)\n elif len(l)==1:\n S.append(2)\n elif len(l)==2:\n if l[0]==(l[1]-1):\n S.append(1)\n else:\n S.append(2)\n if G==1:\n print(0)\n else:\n print(min(S))"}, {"source_code": "from sys import *\nm=list(input().split())\nans1=ans2=2\nd=[]\nif m[0][1]==m[1][1]:\n if abs(int(m[0][0])-int(m[1][0]))<=2 and abs(int(m[0][0])-int(m[1][0]))!=0:\n ans1-=1\n d.append(abs(int(m[0][0])-int(m[1][0])))\n if abs(int(m[0][0])-int(m[1][0]))==0:\n ans2-=1\nif m[0][1]==m[2][1]:\n if abs(int(m[0][0])-int(m[2][0]))<=2 and abs(int(m[0][0])-int(m[2][0]))!=0:\n if abs(int(m[0][0])-int(m[2][0])) not in d:\n ans1-=1\n if abs(int(m[0][0])-int(m[2][0]))==0:\n ans2-=1\nans=min(ans1,ans2)\nif ans<=1:\n print(ans)\nelse:\n ans1=2\n if m[1][1] == m[2][1]:\n if abs(int(m[1][0]) - int(m[2][0])) <= 2:\n ans1 -= 1\n print(min(ans,ans1))"}, {"source_code": "d = {\n 'm': 10,\n 's': 20,\n 'p': 30\n}\n\na, b, c = list(sorted([int(i[0]) + d[i[1]] for i in input().split(' ')]))\n\nif (a == b and b == c) or (a == b - 1 and b == c - 1):\n print(0)\n exit()\nif a == b - 1 or b == c - 1 or a == b or b == c:\n print(1)\n exit()\nprint(2)\n"}, {"source_code": "a,b,c=map(str,input().split())\nl=[int(a[0]),int(b[0]),int(c[0])]\nl.sort()\nif(a==b and b==c):\n\tprint(0)\nelse:\n\tif(a[1]==b[1] and b[1]==c[1]):\n\t\tif (l[2]==l[1]+1 and l[1]==l[0]+1 ):\n\t\t\tprint(0)\n\t\telse:\n\t\t\tif(l[1]==l[0]+1 or l[2]==l[1]+1):\n\t\t\t\tprint(1)\n\t\t\telse:\n\t\t\t\tprint(2)\n\telse:\n\t\tif(a[1]==b[1] or b[1]==c[1] or a[1]==c[1]):\n\t\t\tif(a[1]==b[1]):\n\t\t\t\tif (int(abs(int(a[0])-int(b[0])))<=2):\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2)\n\t\t\telif(a[1]==c[1]):\n\t\t\t\tif (int(abs(int(a[0])-int(c[0])))):\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(2) \n\t\t\telse:\n\t\t\t\tif(int(abs(int(b[0])-int(c[0])))):\n\t\t\t\t\tprint(1)\n\t\t\t\telse:\n\t\t\t\t\tprint(0)\n\t\telse:\n\t\t\tprint(2)\n"}, {"source_code": "data = input().split()\ndata.sort()\n\ndic = {\"s\":[], \"m\":[], \"p\":[]}\nfor d in data:\n dic[d[1]].append(d)\n#mx = max([len(l) for l in dic.values()])\nvals = list(dic.values())\nvals.sort(key=lambda a: len(a))\nlis = vals[-1]\nlis.sort()\nif len(lis) == 3:\n if lis[0] == lis[1]:\n if lis[1] == lis[2]:\n print(0)\n else:\n print(1)\n else:\n if lis[1] == lis[2]:\n print(1)\n else:\n ns = [int(a[0]) for a in lis]\n if ns[0] + 1 == ns[1]:\n if ns[1] + 1 == ns[2]:\n print(0)\n else:\n print(1)\n else:\n if ns[1] + 1 == ns[2]:\n print(1)\n else:\n print(2)\n\nelif len(lis) == 2:\n if lis[0] == lis[1] or int(lis[0][0]) + 1 == int(lis[1][0]):\n print(1)\n else:\n print(2)\n \nelse:\n print(2)\n\n\n\n\n# if data[0] == data[1]:\n# pass\n# else:\n# if data[1] == data[2]:\n# print(1)\n# else"}, {"source_code": "s=input().split()\nl=[]\ns.sort()\nprint(s)\nfor i in s:\n l.append(int(i[0]))\n l.append(i[1])\nif l[0]==l[2]:\n if l[0]==l[4]:\n print(0) \n else: \n print(1) \nelif l[0]+1==l[2] and l[1]==l[3]:\n if l[2]+1==l[4] and l[3]==l[5]:\n print(0)\n else:\n print(1)\nelif l[2]+1==l[4] and l[5]==l[3]:\n print(1)\nelif l[0]+2==l[4] and l[1]==l[5]:\n print(1) \nelse:\n print(2)"}, {"source_code": "# Coding credits Moaz Adnan\nmy_String = list(raw_input().split())\n\nmy_String.sort()\nnum = []\nletter =[]\nfor item in my_String:\n\tletter.append(item[1])\n\tnum.append(int(item[0]))\n\n\nif len(set(my_String)) == 1:\n\tprint (0)\nelif len(set(letter)) <= 2:\n\tif num[0] == num[1] or num[1] == num[2] or num[0] == num[2]:\n\t\tprint(1)\n\telif (num[2] - num[0]) - (num[2] - num[1] )<= 2 :\n\t\tif num[2] - num[1] == 1:\n\t\t\tprint(0)\n\t\telif letter[0] == letter [1]:\n\t\t\tprint(1)\n\t\telse:\n\t\t\tprint(2)\n\telse:\n\t\tprint(2)\nelse:\n\tprint(2)\n\n\n"}, {"source_code": "m=[x for x in input().split()]\ntiles=[[0 for i in range(9)] for j in range(3)]\nfor i in range(len(m)):\n g=int(m[i][0])-1\n h=(m[i][1]) \n if h==\"m\":\n tiles[0][g]+=1\n elif h==\"p\":\n tiles[1][g]+=1\n else:\n tiles[2][g]+=1\nif m[0]==m[1] and m[1]==m[2]:\n print(0)\nelif m[0]==m[1]:\n print(1)\nelif m[0]==m[2]:\n print(1)\nelif m[1]==m[2]:\n print(1)\nelse:\n n=False\n for i in range(3):\n for j in range(9):\n if tiles[i][j]!=0:\n if j!=8 and tiles[i][j+1]!=0:\n if j!=7 and tiles[i][j+2]!=0:\n print(0)\n n=True\n break\n else:\n print(1)\n n=True\n break\n if n==False:\n print(2)"}, {"source_code": "d={'m':10,'p':20,'s':30}\n\n#men=> kou or shu\nx,y,z=[int(x[0])+d[x[1]] for x in sorted(input().split())]\n\n#kou and sust\nif (x==y and y==z) or (x==y-1 and y==z-1):\n print('0')\n #exit()\nelif x==y or y==z or x==z or x==y-1 or y==z-1 or x==y-2 or y==z-2 :\n print('1')\n #exit()\nelse:\n print('2')\n"}, {"source_code": "l = list(input().split())\nd = {}\nfor i in l:\n if i[1] not in d:d[i[1]] = [int(i[0])]\n else:\n d[i[1]].append(int(i[0]))\nbest = []\nfor i in d:\n if len(d[i]) > len(best):\n best = d[i]\nif len(best)==1:print(2)\nelif len(best)==3 and len(set(best))==1:print(0)\nelse:\n m = min(best)\n if m+1 in best:\n if m+2 in best:print(0)\n else:print(1)\n else:print(2)"}, {"source_code": "a,b,c = [s for s in input().split()]\nshuts = set()\nkoutsu = set()\n\nif a == b:\n koutsu.add(a)\n koutsu.add(b)\n if a == c:\n koutsu.add(c)\nelif a == c:\n koutsu.add(a)\n koutsu.add(c)\n\nelif b == c:\n koutsu.add(b)\n koutsu.add(c)\n\nelif ((int(a[0])==int(b[0])+1 or int(a[0]) == int(b[0])-1) or (int(b[0]) == int(a[0])+1 or int(b[0]) == int(a[0])-1)) and a[1]==b[1]:\n shuts.add(a)\n shuts.add(b)\n if ((int(b[0])==int(c[0])+1 or int(b[0]) == int(c[0])-1) or (int(c[0]) == int(b[0])+1 or int(c[0]) == int(b[0])-1)) and c[1]==b[1]:\n shuts.add(c)\nelif ((int(b[0])==int(c[0])+1 or int(b[0]) == int(c[0])-1) or (int(c[0]) == int(b[0])+1 or int(c[0]) == int(b[0])-1)) and c[1]==b[1]:\n shuts.add(b)\n shuts.add(c)\n\nelif ((int(c[0])==int(a[0])+1 or int(c[0]) == int(a[0])-1) or (int(a[0]) == int(c[0])+1 or int(a[0]) == int(c[0])-1)) and a[1]==c[1]:\n shuts.add(a)\n shuts.add(c)\n\nif ((int(a[0])==int(b[0])+2) or (int(b[0])==int(a[0])+2)) and a[1]==b[1]:\n shuts.add(a)\n shuts.add(b)\nelif ((int(b[0])==int(c[0])+2) or (int(c[0])==int(b[0])+2)) and b[1]==c[1]:\n shuts.add(b)\n shuts.add(c)\nelif ((int(a[0])==int(c[0])+2) or (int(c[0])==int(a[0])+2)) and c[1]==a[1]:\n shuts.add(a)\n shuts.add(c)\n\nif max(len(shuts), len(koutsu))==0:\n print(2)\nelse:\n print(3-max(len(shuts), len(koutsu)))\n\n\n\n"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\nif __name__ == \"__main__\":\n s = [[],[],[]]\n st = list(input().split())\n for i in st:\n if i[1] == 'm':\n s[0].append(int(i[0]))\n if i[1] == 'p':\n s[1].append(int(i[0]))\n if i[1] == 's':\n s[2].append(int(i[0]))\n ans = 2\n for i in s:\n if len(i) == 1:\n ans = min(ans , 2)\n elif len(i) == 2:\n i.sort()\n if i[1] == i[0] + 1 or i[1] == i[0] + 2:\n ans = min(ans , 1)\n elif i[1] == i[0]:\n ans = min(ans , 1)\n else:\n ans = min(ans , 2)\n elif len(i) == 3:\n i.sort()\n if i[2] == i[1] + 1 and i[1] == i[0] + 1:\n ans = 0\n elif i[2] == i[1] and i[1] == i[0]:\n ans = 0\n elif i[1] == i[0] + 1 or i[1] == i[0] + 2:\n ans = min(ans , 1)\n elif i[2] == i[1] + 1 or i[2] == i[1] + 2:\n ans = min(ans , 1)\n elif i[2] == i[0] + 1 and i[2] == i[0] + 2:\n ans = min(ans , 1)\n else:\n ans = min(ans, 2)\n print(ans)"}, {"source_code": "h = [hi for hi in raw_input().split(\" \")]\nsuits = ['m','p','s']\nk23 = []\nkf = []\ns23 = []\nsf = []\na = 1\nb = 9\nfor i in range(a,b+1):\n\t# print i,i,i\n\tfor suit in suits:\n\t\tk23 += [[str(i)+suit,str(i)+suit]]\n\t\tkf += [[str(i)+suit,str(i)+suit,str(i)+suit]]\nfor i in range(a,b):\n\tfor suit in suits:\n\t\ts23 += [[str(i)+suit,str(i+1)+suit]]\nfor i in range(a,b-1):\n\tfor suit in suits:\n\t\tsf += [[str(i)+suit,str(i+1)+suit,str(i+2)+suit]]\nh012 = [h[0]]+[h[1]]+[h[2]]\nh021 = [h[0]]+[h[2]]+[h[1]]\nh102 = [h[1]]+[h[0]]+[h[2]]\nh120 = [h[1]]+[h[2]]+[h[0]]\nh201 = [h[2]]+[h[0]]+[h[1]]\nh210 = [h[2]]+[h[1]]+[h[0]]\n\nh01 = [h[0]]+[h[1]]\nh02 = [h[0]]+[h[2]]\nh10 = [h[1]]+[h[0]]\nh12 = [h[1]]+[h[2]]\nh20 = [h[2]]+[h[0]]\nh21 = [h[2]]+[h[1]]\n\nif h012 in kf or h012 in sf:\n\tprint 0\nelif h021 in kf or h021 in sf:\n\tprint 0\nelif h102 in kf or h102 in sf:\n\tprint 0\nelif h120 in kf or h120 in sf:\n\tprint 0\nelif h201 in kf or h201 in sf:\n\tprint 0\nelif h210 in kf or h210 in sf:\n\tprint 0\nelif h01 in k23 or h01 in s23:\n\tprint 1\nelif h02 in k23 or h02 in s23:\n\tprint 1\nelif h10 in k23 or h10 in s23:\n\tprint 1\nelif h12 in k23 or h12 in s23:\n\tprint 1\nelif h20 in k23 or h20 in s23:\n\tprint 1\nelif h21 in k23 or h21 in s23:\n\tprint 1\nelse:\n\tprint 2"}, {"source_code": "n=input().split()\ninit=len(n)\nm=set(n)\nfg=0\nc=0\nfinal=len(m)\nif(abs(int(n[0][0]))+1 ==abs(int(n[1][0])) or abs(int(n[2][0]))):\n\tc=1\nelif(abs(int(n[2][0]))+1 ==abs(int(n[1][0])) or abs(int(n[0][0]))):\n\tc=1\nelif(abs(int(n[1][0]))+1 ==abs(int(n[2][0])) or abs(int(n[0][0]))):\n\tc=1\nif(n[0][1]==n[1][1] and n[1][1]==n[2][1] and c==1):\n\tfg=0\nelif(n[0][1]==n[1][1] and abs(int(n[0][0])-int(n[1][0]))==1):\n\tfg=1\nelif(n[1][1]==n[2][1] and abs(int(n[1][0])-int(n[2][0]))==1):\n\tfg=1\nelif(n[0][1]==n[2][1] and abs(int(n[0][0])-int(n[2][0]))==1):\n\tfg=1\nelif(init-final==1):\n\tfg=1\nelif(init-final==2):\n\tfg=0\nelse:\n\tfg=2\nif(fg==0):\n\tprint(0)\nelif(fg==1):\n\tprint(1)\nelse:\n\tprint(2)\n\n"}, {"source_code": "o = []\nn = input()\np = 0\nfor i in range(3):\n o.insert(i, n[i + p] + n[i + 1 + p])\n p = p + 2\no = sorted(o)\nans = 2\n\nif (o[0][1] == o[1][1]) and (int(o[1][0]) - int(o[0][0]) < 3) or (o[1][1] == o[2][1]) and (int(o[2][0]) - int(o[1][0]) < 3):\n ans = 1\n\nif (o[0][1] == o[2][1]) and (int(o[2][0]) - int(o[0][0]) < 3):\n ans = 1\n \nif (o[0][1] == o[1][1] == o[2][1]) and((int(o[2][0]) == int(o[1][0]) + 1) and (int(o[1][0]) == int(o[0][0]) + 1)):\n ans = 0\nprint(ans)\n\n"}, {"source_code": "my_String = list(raw_input().split())\n\nmy_String.sort()\nnum = []\nletter =[]\nfor item in my_String:\n\tletter.append(item[1])\n\tnum.append(int(item[0]))\n\n\nif len(set(my_String)) == 1:\n\tprint (0)\nelif len(set(letter)) <= 2:\n\tif num[0] == num[1] or num[1] == num[2] or num[0] == num[2]:\n\t\tprint(1)\n\telif (num[2] - num[0]) - (num[2] - num[1] )<= 2 :\n\t\tif num[2] - num[1] == 1 and letter[2] == letter[1] and letter[2] == letter[0]:\n\t\t\tprint(0)\n\t\telif abs (num[0] - num[1]) <= 2 or abs(num[1] - num[2]) <=2 or abs(num[0] - num[2])<= 2:\n\t\t\tprint(1)\n\t\telse:\n\t\t\tprint(2)\n\telse:\n\t\tprint(2)\nelse:\n\tprint(2)\n\n"}, {"source_code": "# Main\n\ndata = [x for x in raw_input().split(\" \")]\nsol = None\n\nif len(set(data)) == 1:\n\tsol = 0\n\nelif data[0][1] == data[1][1] and data[0][1] == data[2][1]:\n\tnums = [int(data[0][0]), int(data[1][0]), int(data[2][0])]\n\tnums.sort()\n\tif nums[0] == nums[1] - 1:\n\t\tif nums[1] == nums[2] - 1:\n\t\t\tsol = 0\n\t\telse:\n\t\t\tsol = 1\n\telse:\n\t\tif nums[1] == nums[2] - 1:\n\t\t\tsol = 1\n\nelif len(set(data)) == 2:\n\tif sol != 0:\n\t\tsol = 1\n\t\t\n\t\t\n# I think this entire block is redundants since I handled it in the \n# check above... That said, I don't think it'll hurt - worst case if\n# I'm right, it'll just fire down this branch in the case of a 2\n\nif sol == None:\n\tif data[0][1] == data[1][1]:\n\t\tif abs(int(data[0][0]) - int(data[1][0])) == 1:\n\t\t\t# they're off by one and we only need one more piece\n\t\t\tsol = 1\n\t\n\tif data[0][1] == data[2][1]:\n\t\tif abs(int(data[0][0]) - int(data[2][0])) == 1:\n\t\t\t# they're off by one and we only need one more piece\n\t\t\tsol = 1\n\t\n\tif data[1][1] == data[2][1]:\n\t\tif abs(int(data[1][0]) - int(data[2][0])) == 1:\n\t\t\t# they're off by one and we only need one more piece\n\t\t\tsol = 1\n\nif sol == None:\n\tsol = 2\n\nprint sol"}, {"source_code": "\nif __name__ == '__main__':\n s = list(map(lambda x: (int(x[0]), x[1]), input().split()))\n m = 2\n s.sort(key=lambda x: x[0])\n if s[0][0] + 1 == s[1][0] and s[1][0] + 1 == s[2][0] and s[0][1] == s[1][1] == s[2][1]:\n print(0)\n exit(0)\n elif (s[0][0] + 1 == s[1][0] and s[0][1] == s[1][1]) or ( s[1][0] + 1 == s[2][0] and s[1][1] == s[2][1] ):\n print(1)\n exit(0)\n elif (s[0][0] + 2 == s[1][0] and s[0][1] == s[1][1]) or (s[1][0] + 2 == s[2][0] and s[1][1] == s[2][1]):\n print(1)\n exit(0)\n\n s.sort(key=lambda x: x[1])\n if s[0] == s[1] and s[1] == s[2]:\n print(0)\n exit(0)\n elif s[0] == s[1] or s[1] == s[2]:\n print(1)\n exit(0)\n\n print(2)"}, {"source_code": "def diff(a,b):\n a=int(a)\n b=int(b)\n if a>b:\n return(a-b)\n else:\n return(b-a)\nx,y,z=input().split()\nif x==y and y==z:\n p=0\nelif x==y or y==z or x==z:\n p=1\nelse:\n l=[x[1]]\n if y[1] not in l:\n l.append(y[1])\n if z[1] not in l:\n l.append(z[1])\n if len(l)==3:\n p=2\n elif len(l)==2:\n if x[1]==y[1]:\n t=(x,y)\n elif x[1]==z[1]:\n t=(x,z)\n else:\n t=(y,z)\n if diff(t[0][0],t[1][0])==1:\n p=1\n else:\n p=2\n else:\n q=0\n if diff(x[0],y[0])==1:\n q+=1\n if diff(y[0],z[0])==1:\n q+=1\n if diff(x[0],z[0])==1:\n q+=1\n if q==2:\n p=0\n elif q==1:\n p=1\n else:\n p=2\nprint(p)\n\n\n\n\n"}, {"source_code": "a=[[0]*10]*3\ns=input().split()\nm1=0\nfor i in s:\n k=int(i[0])\n \n if i[1]=='m':\n a[0][k]+=1\n m1=max(m1,a[0][k])\n elif i[1]=='p':\n a[1][k]+=1\n m1=max(m1,a[1][k])\n elif i[1]=='s':\n a[2][k]+=1\n m1=max(m1,a[2][k])\nm2=0\nfor i in range(3):\n for j in range(1,8):\n if a[i][j]>0:\n a[i][j]=1\n if a[i][j+1]>0:\n a[i][j+1]=1\n if a[i][j+2]>0:\n a[i][j+2]=1\n m2=max(a[i][j]+a[i][j+1]+a[i][j+2],m2)\nprint(min(3-m1,3-m2))\n \n "}, {"source_code": "def main():\n list_str = input().split()\n list_str.sort()\n\n \"\"\" p = ['3p', '5s', '5s'] (after sort)\n sorted by decimal its mean either ['3p','5p'] or ['5p','5p']\n near to koutsu, or whole string koutsu\n either 1,2,3.... 0 is impossible\"\"\"\n # if koutsu 2 or 3 then cannot be shuntsu\n if len(set(list_str)) == 1: # all equal\n print(0)\n return 0# if koutsu 2 or 3 then cannot be shuntsu \n\n elif len(set(list_str)) == 2: # either one equal\n print(1)\n return 0# if koutsu 2 or 3 then cannot be shuntsu\n\n ###############################################\n shuntsu_count = 0\n \"\"\"\n 1s,5m,3s => after sort 1s,3s,5m\n 1s,5m,2s => after sort 1s,2s,5m\n 1s,2m,2s => after sort 1s,2m,2s\n\n so i guess better to digits\n\n 1,2,2\n s,m,s\n \"\"\"\n num = []\n lstr = []\n for e in list_str:\n num.append(int(e[0]))\n lstr.append(e[1])\n\n # Already sorted so smallest to largest, so need of abs\n if lstr[0] == lstr[1] and (num[0] - num[1])<=2:\n shuntsu_count += 1\n\n if lstr[0] == lstr[2] and (num[0] - num[2])<=2:\n shuntsu_count += 1\n\n if lstr[1] == lstr[2] and (num[1] - num[2])<=2:\n shuntsu_count += 1\n\n\n if shuntsu_count >= 3:\n print(0)\n elif shuntsu_count == 0:\n # atleast Count one of kind already\n print(2)\n else:\n print(1)\n\nmain()"}, {"source_code": "t=raw_input().split()\nt.sort()\nk = {}\n \ndef get_draws():\n\tfor x in t:\n\t\tif not x[-1] in k:\n\t\t\tk[x[-1]]=[]\n\t\tk[x[-1]].append(int(x[:-1]))\n\tfor i in k.keys():\n\t\tlength=len(k[i])\n\t\tall_same = k[i].count(k[i][0])==length\n\t\tif all_same:\n\t\t\tif (length==3):\n\t\t\t\tprint '0'\n\t\t\t\treturn\n\t\t\telif length==2:\n\t\t\t\tprint '1'\n\t\t\t\treturn\n\t\telse:\n\t\t\tdiff_list = []\n\t\t\tfor x, y in zip(k[i][0::], k[i][1::]): \n\t\t\t\tdiff_list.append(y-x)\n\t\t\tif diff_list.count(diff_list[0]) == len(diff_list) and diff_list[0]<=2:\n\t\t\t\tif length==3:\n\t\t\t\t\tprint '0'\n\t\t\t\t\treturn\n\t\t\t\telif length==2:\n\t\t\t\t\tprint '1'\n\t\t\t\t\treturn\n\tprint '2'\n\treturn\nget_draws()"}, {"source_code": "n=list(map(str,input().split(\" \")))\n\nd=dict()\n\nmp = {\"m\":0 , \"p\":1 , \"s\":2}\n\nl=[0]*10\narr = [l,l,l]\n\nmaxi=0\n\nfor i in n:\n\t# print(i)\n\tif (i in d.keys()):\n\t\td[i]+=1\n\t\tmaxi = max(maxi,d[i])\n\n\telse:\n\t\td[i]=1\n\t\tmaxi = max(maxi,d[i])\n\n\tarr[mp[i[1]]][int(i[0])] = 1\n\nif(maxi>=3):\n\tprint(0)\nelse:\n\ttemp2 = 0\n\tfor i in range(3):\n\t\tansi=0\n\t\tfor j in range(10):\n\t\t\tif(arr[i][j] ==0):\n\t\t\t\tansi=0\n\t\t\tif(arr[i][j]==1):\n\t\t\t\tansi+=arr[i][j]\n\t\t\t\ttemp2=max(ansi,temp2)\n\n\tfinalAns = min(3-maxi, 3-temp2)\n\tprint(finalAns)"}, {"source_code": "a = sorted(input().split())\n\nif a[0] == a[1] and a[1] == a[2]:\n print(0)\nelif (a[0][1] == a[1][1] and int(a[0][0]) + 1 == int(a[1][0])) and (a[1][1] == a[2][1] and int(a[1][0]) + 1 == int(a[2][0])):\n print(0)\nelif a[0] == a[1] or a[1] == a[2]:\n print(1)\nelif (a[0][1] == a[1][1] and int(a[0][0]) + 1 == int(a[1][0])) or (a[1][1] == a[2][1] and int(a[1][0]) + 1 == int(a[2][0])):\n print(1)\nelse:\n print(2)\n"}, {"source_code": "a=input().split()\na.sort()\nb=[int(a[0][0]),int(a[1][0]),int(a[2][0])]\n\ne=[a[0][1],a[1][1],a[2][1]]\n\nif(len(set(a))==1):\n print(0)\nelif a[0]==a[1] or a[1]==a[2]:\n print(1)\nelif(len(set(e))==3):\n print(2)\nelif(len(set(e))==1):\n b.sort()\n k=2\n if b[1]-b[0]==1:\n k-=1\n if b[2]-b[1]==1:\n k-=1\n print(k)\nelse:\n if e[0]==e[1]:\n if abs(b[0]-b[1])==1 or abs(b[0]-b[1])==2:\n print(1)\n else:\n print(2)\n elif e[1]==e[2]:\n if abs(b[1]-b[2])==1 or abs(b[1]-b[2])==2:\n print(1)\n else:\n print(2)\n elif e[0]==e[2]:\n if abs(b[0]-b[2])==1 or abs(b[0]-b[2])==2:\n print(1)\n else:\n print(2)\n"}, {"source_code": "s=input().rstrip().split(' ')\nl=[]\nq=[]\nw=[]\nS=[]\nD=[]\nfor i in range(0,len(s)):\n t=list(s[i])\n if t[1]=='s':\n l.append(int(t[0]))\n elif t[1]=='p':\n q.append(int(t[0]))\n else:\n w.append(int(t[0]))\nl.sort()\nq.sort()\nw.sort()\nF=[]\nif len(l)==0:\n F.append(3)\nelif len(l)==1:\n F.append(2)\nelif len(l)==2:\n if l[0]==l[1] or l[0]==l[1]-1 or l[0]==l[1]-2:\n F.append(1)\n else:\n F.append(2)\nelif len(l)==3:\n if l[0]==l[1]-2 or l[1]==l[2]-2 or l[0]==l[2]-2:\n F.append(1)\n if len(list(set(l)))==1:\n F.append(0)\n if l[0]==l[1]-1 and l[1]==l[2]-1:\n F.append(0)\n if l[0]==l[1]-1 and l[1]!=l[2]-1:\n F.append(1)\n if l[0]!=l[1]-1 and l[1]==l[2]-1:\n F.append(1)\n if l[0]!=l[1]-1 and l[1]!=l[2]-1:\n F.append(2)\nl=q;\nif len(l)==0:\n F.append(3)\nelif len(l)==1:\n F.append(2)\nelif len(l)==2:\n if l[0]==l[1] or l[0]==l[1]-1 or l[0]==l[1]-2:\n F.append(1)\n else:\n F.append(2)\nelif len(l)==3:\n if l[0]==l[1]-2 or l[1]==l[2]-2 or l[0]==l[2]-2:\n F.append(1)\n if len(list(set(l)))==1:\n F.append(0)\n if l[0]==l[1]-1 and l[1]==l[2]-1:\n F.append(0)\n if l[0]==l[1]-1 and l[1]!=l[2]-1:\n F.append(1)\n if l[0]!=l[1]-1 and l[1]==l[2]-1:\n F.append(1)\n if l[0]!=l[1]-1 and l[1]!=l[2]-1:\n F.append(2)\nl=w;\nif len(l)==0:\n F.append(3)\nelif len(l)==1:\n F.append(2)\nelif len(l)==2:\n if l[0]==l[1] or l[0]==l[1]-1 or l[0]==l[1]-2:\n F.append(1)\n else:\n F.append(2)\nelif len(l)==3:\n if l[0]==l[1]-2 or l[1]==l[2]-2 or l[0]==l[2]-2:\n F.append(1)\n if len(list(set(l)))==1:\n F.append(0)\n if l[0]==l[1]-1 and l[1]==l[2]-1:\n F.append(0)\n if l[0]==l[1]-1 and l[1]!=l[2]-1:\n F.append(1)\n if l[0]!=l[1]-1 and l[1]==l[2]-1:\n F.append(1)\n if l[0]!=l[1]-1 and l[1]!=l[2]-1:\n F.append(2)\nprint(min(F))"}, {"source_code": "a, b, c = input().split()\ns = [(int(a[0]), a[1]) , (int(b[0]), b[1]), (int(c[0]), c[1])]\ns.sort()\ng = set()\ng.add(a[1])\ng.add(b[1])\ng.add(c[1])\nif a == b and b == c:\n print(0)\nelif s[2][0] - s[1][0] == 1 and s[2][0] - s[0][0] == 2 and len(g) == 1:\n print(0)\nelse:\n if s[2][0] - s[1][0] == 1 and s[2][1] == s[1][1] or s[1][0] - s[0][0] == 1 and s[1][1] == s[0][1] or s[2][0] - s[1][0] == 1 and s[2][1] == s[1][1]:\n print(1)\n elif s[2][0] - s[1][0] == 2 and s[2][1] == s[1][1] or s[1][0] - s[0][0] == 2 and s[1][1] == s[0][1] or s[2][0] - s[1][0] == 2 and s[2][1] == s[1][1]:\n print(1)\n elif a == b or b == c or a == c:\n print(1)\n else:\n print(2)"}, {"source_code": "l = list(input().split())\nd = {}\nfor i in l:\n if i[1] not in d:d[i[1]] = [int(i[0])]\n else:\n d[i[1]].append(int(i[0]))\nbest = []\nfor i in d:\n if len(d[i]) > len(best):\n best = d[i]\nif len(best)==1:print(2)\nelif len(set(best))==1:\n print(3-len(best))\nelse:\n m = min(best)\n if m+1 in best:\n if m+2 in best:print(0)\n else:print(1)\n else:print(2)"}, {"source_code": "c = list(input().split())\na = []\nfor i in range(3):\n a.append([])\n \nfor n in c:\n if n[1]=='p':\n a[0].append(int(n[0]))\n elif n[1]=='m':\n a[1].append(int(n[0]))\n else:\n a[2].append(int(n[0]))\n\nm = 2\nfor i in range(3):\n a[i].sort()\n if len(a[i])==3 and a[i][0]==a[i][1] and a[i][1]==a[i][2]:\n m = 0\n if len(a[i])==3 and a[i][1]-a[i][0]==1 and a[i][2]-a[i][1]==1:\n m = 0\n if len(a[i])==3 and (a[i][1]-a[i][0]==1 or a[i][2]-a[i][1]==1):\n m = min(m,1)\n if len(a[i])==2 and a[i][1]-a[i][0] in [1,2] :\n m = min(m,1)\n\nprint(m)"}, {"source_code": "\n\nt=list(map(str,input().split()))\nt.sort()\n\ns=0\nins=0\nist=0\nm=0\ninm=0\nimt=0\np=0\ninp=0\nipt=0\ncount=1\nshout=1\nprev=0\nfor i in range(1,len(t)):\n\tprev=i-1\n\tif(t[i][1]==t[prev][1]):\n\t\tif(int(t[i][0])==int(t[prev][0])):\n\t\t\tcount=count+1\n\t\telif((int(t[i][0])==(int(t[prev][0])+1))):\n\t\t\tcount=count+1\n\telse:\n\t\tshout=max(count,shout)\n\t\tcount=1\nprint(min(3-shout,3-count))\n\t\n\t\t\t\n\t\t\n\t\n\n\n\t\t\n\n\t\n"}, {"source_code": "a, b, c = map(str, input().split())\na0, b0, c0 = int(a[0]), int(b[0]), int(c[0])\nmx, mn = max(a0, b0, c0), min(a0, b0, c0)\nif a == b == c or mx - mn == 2:\n print(0)\nelse:\n if abs(a0 - b0) <= 2 or abs(c0 - b0) <= 2 or abs(a0 - c0) <= 2:\n print(1)\n else:\n print(2)\n"}, {"source_code": "a, b, c = map(str, input().split())\nif a == b == c:\n print(0)\n exit(0)\np = [int(a[0]), int(b[0]), int(c[0])]\np.sort()\nif a[1] == b[1] == c[1] and p[2] - p[1] == p[1] - p[0] == 1:\n print(0)\nelif a[1] != b[1] and b[1] != c[1] and c[1] != a[1]:\n print(2)\nelif a[1] == b[1] and b[1] != c[1] and (abs(int(a[0]) - int(b[0])) == 1 or abs(int(a[0]) - int(b[0])) == 2):\n print(1)\nelif c[1] == b[1] and b[1] != a[1] and (abs(int(c[0]) - int(b[0])) == 1 or abs(int(c[0]) - int(b[0])) == 2):\n print(1)\nelif a[1] == c[1] and b[1] != c[1] and (abs(int(a[0]) - int(c[0])) == 1 or abs(int(a[0]) - int(c[0])) == 2):\n print(1)\nelif a[1] == b[1] and b[1] == c[1] and abs(int(a[0]) - int(b[0])) > 2 and abs(int(c[0]) - int(b[0])) > 2 and abs(int(a[0]) - int(c[0])) > 2:\n print(2)\nelif a[1] == b[1] and abs(int(a[0]) - int(b[0])) == 1:\n print(1)\nelif c[1] == b[1] and abs(int(c[0]) - int(b[0])) == 1:\n print(1)\nelif a[1] == c[1] and abs(int(a[0]) - int(c[0])) == 1:\n print(1)\nelif a[1] == c[1] and abs(int(a[0]) - int(c[0])) == 3:\n print(2)\nelif a[1] == b[1] and abs(int(a[0]) - int(b[0])) == 3:\n print(2)\nelif b[1] == c[1] and abs(int(b[0]) - int(c[0])) == 3:\n print(2)\nelse:\n print(2)\n"}, {"source_code": "s=input().split(\" \")\n\ns1=[]\np1=[]\nm1=[]\nfor i in s:\n if i[1]==\"m\":\n m1.append(int(i[0]))\n elif i[1]==\"p\":\n p1.append(int(i[0]))\n else:\n s1.append(int(i[0]))\n\ns1=sorted(s1)\np1=sorted(p1)\nm1=sorted(m1)\n\nif len(m1)==len(s1)==len(p1)==1:\n print(2)\nelse:\n if len(m1)>=2:\n if abs(m1[0]-m1[1])<=1 and len(m1)>2:\n if abs(m1[0]-m1[1])==abs(m1[2]-m1[1]):\n print(0)\n else:\n print(1)\n elif abs(m1[0]-m1[1])<=1 and len(m1)==2:\n print(1)\n elif abs(m1[0]-m1[1])==2:\n print(1)\n else:\n print(2)\n elif len(s1)>=2:\n if abs(s1[0]-s1[1])<=1 and len(s1)>2:\n if abs(s1[0]-s1[1])==abs(s1[2]-s1[1]):\n print(0)\n else:\n print(1)\n elif abs(s1[0]-s1[1])<=1 and len(s1)==2:\n print(1)\n elif abs(s1[0]-s1[1])==2:\n print(1)\n else:\n print(2)\n else:\n if abs(p1[0]-p1[1])<=1 and len(p1)>2:\n if abs(p1[0]-p1[1])==abs(p1[2]-p1[1]):\n print(0)\n else:\n print(1)\n elif abs(p1[0]-p1[1])<=1 and len(p1)==2:\n print(1)\n elif abs(p1[0]-p1[1])==2:\n print(1)\n else:\n print(2)\n "}], "src_uid": "7e42cebc670e76ace967e01021f752d3"} {"source_code": "n=input()\ns=raw_input()\na=[]\nmaxx=0\nfor i in s:\n a.append(i)\n if i=='(':\n maxx+=1\n else:\n maxx-=1\nif maxx!=0:\n print 0\n print 1,1\nelse:\n x=1\n y=1\n maxx=0\n dp=[0]*n\n val=0\n for i in range(n):\n if a[i]=='(':\n val+=1\n else:\n val-=1\n dp[i]=val\n minn=min(dp)\n for i in dp:\n if i==minn:\n maxx+=1\n for i in range(n):\n for j in range(i,n):\n if(a[i]==a[j]):\n continue\n a[i],a[j]=a[j],a[i]\n dp=[0]*n\n val=0\n for i1 in range(n):\n if a[i1]=='(':\n val+=1\n else:\n val-=1\n dp[i1]=val\n minn=min(dp)\n for i1 in dp:\n if i1==minn:\n val+=1\n if val>maxx:\n maxx=val\n x=i+1\n y=j+1\n a[i],a[j]=a[j],a[i]\n print maxx\n print x,y\n", "positive_code": [{"source_code": "N = int(input())\nstring = list(input())\n\ndef even(string):\n a = 0\n b = 0\n for c in string:\n if c == \")\": a += 1\n if c == \"(\": b += 1\n return a == b\ndef swap(arr, i, j):\n arr[i], arr[j] = arr[j], arr[i]\n\ndef calc(string):\n N = len(string)\n l = 0\n s = 0\n for char in string:\n if char == \"(\":\n s += 1\n else:\n s -= 1\n l = min(l, s)\n \n if s != 0: return 0\n\n t = 0\n\n for i in range(N):\n c = string[i]\n if c == \"(\":\n s += 1\n if s - l <= 1:\n t += 1\n else:\n s -= 1\n return t\n\nif even(string):\n highest = calc(string)\n a = b = 0\n for i in range(N):\n for j in range(i + 1, N):\n if string[i] == string[j]: continue\n swap(string, i, j)\n total = calc(string)\n if total > highest:\n highest = total\n a, b = i, j\n swap(string, i, j)\n\n print(highest)\n print(a+1, b+1)\nelse:\n print(0)\n print(1, 1)\n \n"}, {"source_code": "import sys\ninput = sys.stdin.readline\ndef matcher(correcti):\n open_=0\n close_=0\n count=0\n excess=0\n for i in range(len(correcti)):\n if correcti[i]=='(':\n open_+=1\n if correcti[i]==')':\n close_+=1\n if close_>open_ and open_==0:\n excess+=1\n close_-=1\n count=0\n continue\n if open_==close_:\n count+=1\n open_=0\n close_=0\n if open_-close_==excess:\n if excess>0:\n return(count+1)\n else:\n return(count)\n else:\n return(0)\nn=int(input())\nl=[i for i in input() if i!='\\n']\nst=(\"\".join(l).rstrip(')').rstrip('('))\nswap=matcher(l[len(st):]+l[:len(st)])\n#print(swap)\nshifts=[[1,1]]\nfor i in range(n):\n for j in range(i,n):\n if l[i]!=l[j]:\n l[i],l[j]=l[j],l[i]\n output=(matcher(l))\n if output>swap:\n swap=output\n shifts[0]=[i+1,j+1]\n l[i],l[j]=l[j],l[i]\nprint(swap)\nprint(*shifts[0])\n \n"}, {"source_code": "n = int(input())\nseq = list(input())\n\ndef get_comps(seq):\n depth = 0\n components = 0\n lookingfor = 0\n for i in range(n):\n if seq[i] == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < lookingfor:\n lookingfor = depth\n components = 1\n elif depth == lookingfor:\n components += 1\n\n return components\n\ndef other(x):\n if x == \"(\":\n return \")\"\n return \"(\"\n\nif n%2 == 1 or seq.count(\"(\") != seq.count(\")\"):\n print(0)\n print(1,1)\nelse:\n best1 = 1\n best2 = 1\n bestVal = get_comps(seq)\n for i in range(n):\n for j in range(i+1,n):\n if seq[i] != seq[j]:\n seq[i] = other(seq[i])\n seq[j] = other(seq[j])\n val = get_comps(seq)\n if val > bestVal:\n best1 = i\n best2 = j\n bestVal = val\n seq[i] = other(seq[i])\n seq[j] = other(seq[j])\n print(bestVal)\n print(best1+1,best2+1)\n"}, {"source_code": "import math as mt\nimport collections as cc\nimport sys\n#input=sys.stdin.readline\nI=lambda:set(map(int,input().split()))\nn,=I()\ns=list(input())\ntf=0\nl=1\nr=1\nfor i in range(n):\n\tfor j in range(i+1,n):\n\t\tans=0\n\t\ts[i],s[j]=s[j],s[i]\n\t\tch=0\n\t\tcnt=0\n\t\tcm=0\n\t\tfor k in s:\n\t\t\tif k=='(':\n\t\t\t\tch+=1\n\t\t\telse:\n\t\t\t\tch-=1\n\t\t\tif ch<cm:\n\t\t\t\tcm=ch\n\t\t\t\tcnt=1\n\t\t\telif ch==cm:\n\t\t\t\tcnt+=1\n\t\tif ch==0 and cnt>tf:\n\t\t\t\n\t\t\ttf=cnt\n\t\t\tl=i+1\n\t\t\tr=j+1\n\t\ts[i],s[j]=s[j],s[i]\nprint(tf)\nprint(l,r)\n"}, {"source_code": "def beauty(tt):\n depth = 0\n min_depth = 0\n dd = []\n for i, t in enumerate(tt):\n if t == '(':\n depth += 1\n else:\n depth -= 1\n dd.append(depth)\n if depth < min_depth:\n min_depth = depth\n if depth != 0:\n return(0)\n result = 0\n for d in dd:\n if d == min_depth:\n result+=1\n return(result)\n\n\ndef main():\n n = int(input())\n if n%2 == 1:\n print(0)\n print(1,1)\n return\n tt = input()\n best = beauty(tt)\n l = 1\n r = 1\n for i in range(n-1):\n for j in range(i+1, n):\n if tt[i] != tt[j]:\n ttt = list(tt)\n ttt[i] = tt[j]\n ttt[j] = tt[i]\n b = beauty(ttt)\n if b > best:\n best = b\n l = i+1\n r = j+1\n print(best)\n print(l, r)\n\n\n\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = int(input())\ns = list(input())\nL = 1\nR = 1\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\tcalc += 1\n\t\telse:\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i in range(n):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "n = int(input())\ns = input()\nres = 0\nri, rj = 0, 0\nfor i in range(n):\n for j in range(i + 1, n):\n #print(i, j)\n ss = s[:i] + s[j] + s[(i + 1): j] + s[i] + s[(j + 1):]\n #print(ss)\n k_mn, mn = 0, 0\n teck = 0\n for g in range(n):\n if ss[g] == '(':\n teck += 1\n else:\n teck -= 1\n if k_mn == 0 or teck < mn:\n mn, k_mn = teck, 1\n elif teck == mn:\n k_mn += 1\n\n if teck == 0:\n if k_mn > res:\n res = max(res, k_mn)\n ri = i\n rj = j\n #print(k_mn)\nprint(res)\nprint(ri + 1, rj + 1)\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\nN = INT()\nS = list(input())\n\nC = Counter(S)\nif C['('] != C[')']:\n print(0)\n print(1, 1)\n exit()\n\ndef check(S):\n cur = cnt = mn = 0\n for s in S:\n if s == '(':\n cur += 1\n else:\n cur -= 1\n if cur < mn:\n mn = cur\n cnt = 1\n elif cur == mn:\n cnt += 1\n return cnt\n\nmx = 0\nans = (1, 1)\nfor i in range(N):\n for j in range(i+1, N):\n S[i], S[j] = S[j], S[i]\n cnt = check(S)\n if cnt > mx:\n mx = cnt\n ans = (i+1, j+1)\n S[i], S[j] = S[j], S[i]\nprint(mx)\nprint(*ans)\n"}, {"source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import stdin, setrecursionlimit\nsetrecursionlimit(10**7)\n\n\ndef iin(): return int(stdin.readline())\n \n \ndef lin(): return list(map(int, stdin.readline().split()))\n\n\n# range = xrange\n# input = raw_input\n\ndef bcheck(a,l,r):\n a1=a[:]\n a1[l],a1[r]=a1[r],a1[l]\n N=len(a)\n p,n=[],[]\n for i in range(N):\n if a1[i]==')':\n if p:\n p.pop()\n else:\n n.append(i)\n else:\n p.append(i)\n l=len(p)\n rt=0\n if l>0:\n rt=n[-1]+1\n if rt:\n a1=a1[rt:]+a1[:rt]\n ch,pt=0,0\n for i in a1:\n if i=='(':\n pt+=1\n else:\n pt-=1\n if pt==0:ch+=1\n #print(a1,ch)\n \n return ch\n\ndef main():\n N=iin()\n a=list(input())\n c1,c2=a.count(')'),a.count('(')\n if c1!=c2 or N%2:\n print(0)\n print(1,1)\n else:\n mx=[-1,0,0]\n # print(a)\n for i in range(N):\n for j in range(i+1,N):\n if a[i]!=a[j]:\n val=bcheck(a,i,j)\n if mx[0]<val:\n mx=[val,i,j]\n # print(a)\n a1=a[:]\n N=len(a)\n p,n=[],[]\n for i in range(N):\n if a1[i]==')':\n if p:\n p.pop()\n else:\n n.append(i)\n else:\n p.append(i)\n l=len(p)\n rt=0\n if l>0:\n rt=n[-1]+1\n if rt:\n a1=a1[rt:]+a1[:rt]\n ch,pt=0,0\n for i in a1:\n if i=='(':\n pt+=1\n else:\n pt-=1\n if pt==0:ch+=1\n if ch>mx[0]:\n print(ch)\n print(1,1)\n else:\n print(mx[0])\n print(mx[1]+1,mx[2]+1)\n\n \n\n \n\n\n\n\n\n\n\n\nmain()\n# try:\n# main()\n# except Exception as e: print(e)"}, {"source_code": "n = int(input())\ns = [1 if c == '(' else -1 for c in input()]\nif s.count(1) != s.count(-1):\n print(0)\n print(1, 1)\n exit()\n\nans = 0\npair = 1, 1\nfor i in range(n-1):\n for j in range(i, n):\n s[i], s[j] = s[j], s[i]\n min_p, cnt = 10**9, 0\n nest = 0\n for k in range(n):\n nest += s[k]\n if min_p > nest:\n min_p = nest\n cnt = 1\n elif min_p == nest:\n cnt += 1\n\n if ans < cnt:\n ans = cnt\n pair = i+1, j+1\n\n s[i], s[j] = s[j], s[i]\n\nprint(ans)\nprint(*pair)\n"}, {"source_code": "n = int(input())\ns = list(input())\nL = 1\nR = 1\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\tcalc += 1\n\t\telse:\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i in range(n):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "n = int(input())\ns = list(input())\nL = 1\nR = 1\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\tcalc += 1\n\t\telse:\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i in range(n):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)\n"}, {"source_code": "n = int(input())\ns = list(input())\nL = 1\nR = 1\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\tcalc += 1\n\t\telse:\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i in range(n):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\n#lines = stdin.readlines()\ndef rint():\n return map(int, sys.stdin.readline().split())\n\ndef input():\n return sys.stdin.readline().rstrip('\\n')\n\ndef oint():\n return int(input())\n\n\nn = oint()\nstemp = input()\ns = []\nfor i in range(n):\n if stemp[i] == '(':\n s.append(1)\n else:\n s.append(-1)\n\nmaxcnt = 0\ncandi = [0, 0]\nfor l in range(n):\n for r in range(l, n):\n cnt = 0\n s[l], s[r] = s[r], s[l]\n ssum = [0]*n\n ssum[0] = s[0]\n for i in range(1, n):\n ssum[i] = ssum[i-1] + s[i]\n\n minssum = min(ssum)\n if ssum[n-1] != 0:\n continue\n\n for i in range(0, n):\n if ssum[i] == minssum:\n cnt += 1\n if maxcnt < cnt:\n candi = [r, l]\n maxcnt = cnt\n s[l], s[r] = s[r], s[l]\nprint(maxcnt)\nprint(candi[0]+1, candi[1]+1)\n"}, {"source_code": "def do(i):\n if i == \"(\":\n return 1\n else:\n return -1\ndef find(i,idx):\n if i<n-idx:\n return idx+i+1\n else:\n return i-(n-idx)+1\nn = input()\narr = map(do,raw_input())\ns = [0]*n\ns[n-1] = arr[n-1]\nmaxi = n-1\nmaxv = s[n-1]\n \nfor i in range(n-1)[::-1]:\n s[i] = s[i+1] + arr[i]\n if s[i] > maxv:\n maxv = s[i]\n maxi = i\nnewv = arr[maxi:]+arr[:maxi]\nif sum(newv) != 0:\n print 0\n print 1,1\nelse:\n cnt = 0\n cnt1 = -1\n cnt2 = -1\n maxv1,maxv2 = 0,0\n l1,l2,r1,r2 = 0,0,0,0\n last1,last2 = 0,0\n st = 0\n for i in range(n):\n st += newv[i]\n if st == 0:\n cnt += 1\n cnt1 = -1\n last1 = i+1\n \n elif st == 1:\n cnt1 += 1\n if cnt1 >= maxv1:\n maxv1 = cnt1\n l1 = last1\n r1 = i+1\n \n last2 = i+1\n cnt2 = -1\n elif st == 2:\n cnt2 += 1\n if cnt2 >= maxv2:\n maxv2 = cnt2\n l2 = last2\n r2 = i+1\n if maxv1 == 0:\n print cnt\n print 1,1\n elif maxv1>maxv2+cnt:\n print maxv1+1\n print find(l1,maxi),find(r1,maxi)\n else:\n print maxv2+cnt+1\n print find(l2,maxi),find(r2,maxi)"}, {"source_code": "n = int(input())\ns = list(input())\nL = 1\nR = 1\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\tcalc += 1\n\t\telse:\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i in range(n):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "\nn = int(input())\ns = list(input())\n \nbest = 0\nL = 1\nR = 1\nif n % 2:\n print(best)\n print(L, R)\n quit()\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\n\t\t\tcalc += 1\n\t\telse:\n\t\t\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i, ch in enumerate(s, 0):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "\nn = int(input())\ns = list(input())\n \nbest = 0\nL = 1\nR = 1\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\n\t\t\tcalc += 1\n\t\telse:\n\t\t\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i, ch in enumerate(s, 0):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "n=int(input())\ns=list(input())\ndef call(x):\n if x=='(':\n return 1\n else:\n return -1\ns=list(map(call,s))\nif sum(s)!=0:\n print(0)\n print(1,1)\nelse:\n ans=0\n pr=(1,1)\n for i in range(n-1):\n for j in range(i,n):\n lm=10**9\n sm=0\n ct=0\n s[i],s[j]=s[j],s[i]\n for k in range(n):\n sm+=s[k]\n if sm<lm:\n lm=sm\n ct=1\n elif sm==lm:\n ct+=1\n if ct>ans:\n ans=ct\n pr=(i+1,j+1)\n s[i],s[j]=s[j],s[i]\n print(ans)\n print(*pr)\n"}, {"source_code": "n = int(input())\ns = list(input())\nL = 1\nR = 1\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\tcalc += 1\n\t\telse:\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n \nbest = check()\nfor i in range(n):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "n=int(input())\ns=input()\nmaxn=-1\nif(n==1):\n print(0)\n print(1,1)\n exit(0)\nfor i in range(n):\n for j in range(i+1,n):\n s1=s[:i]+s[j]+s[i+1:j]+s[i]+s[j+1:]\n num=0\n temp=0\n min=501\n '''for k in range(1,n+1):\n s2=s1[n-k:]+s1[:n-k]\n while(\"()\" in s2):\n s2=s2.replace(\"()\",\"\")\n if(s2==\"\"):\n num+=1'''\n for k in range(n):\n if(s1[k]=='('):\n temp+=1\n else:\n temp-=1\n if(temp<min):\n min=temp\n num=1\n elif(temp==min):\n num+=1\n if(temp!=0):\n print(0)\n print(1,1)\n exit(0)\n if(num>maxn):\n maxn=num\n ansi=i+1\n ansj=j+1\nprint(maxn)\nprint(ansi,ansj)"}, {"source_code": "n = int(input().strip())\ns= input().strip()\nss= 0\nmina = 0\nti = 0\nfor k in range(len(s)):\n if(s[k] == \"(\"):\n ss+=1\n else:\n ss-=1\n if(ss<0):\n ti = k+1\n ss = 0\ns=s[ti:]+s[:ti]\nss= 0\nfor k in range(len(s)):\n if(s[k] == \"(\"):\n ss+=1\n else:\n ss-=1\n if(ss<0):\n print(0)\n print(1,1)\n break\nelse:\n if(ss == 0):\n pre=[0 for k in range(len(s))]\n for k in range(len(s)):\n if (s[k] == \"(\"):\n ss += 1\n else:\n ss -= 1\n pre[k] = ss\n tt = 0\n a =(1,1)\n for k in range(0,len(s)):\n if(pre[k] == 0):\n tt+=1\n maxi= tt\n g =0\n gg =0\n while(gg<len(s)):\n if(pre[gg] == 0):\n if(gg != g+1):\n yy = g+1\n y = g+1\n q = 0\n while(yy<gg):\n if(pre[yy] == 1):\n if(yy !=y+1):\n rr = y+1\n r = y+1\n h = 0\n while(rr<yy):\n if(pre[rr] == 2):\n h+=1\n rr+=1\n\n if(tt+h+1>maxi):\n maxi = tt + h + 1\n a=(y,yy)\n q+=1\n y = yy+1\n yy = y\n else:\n yy+=1\n\n if (q + 1 > maxi):\n maxi = q+1\n a = (g, gg)\n g= gg+1\n gg= g\n else:\n gg+=1\n print(maxi)\n print((a[0]+ti)%len(s)+1,(a[1]+ti)%len(s)+1)\n\n\n\n\n else:\n print(0)\n print(1,1)\n\n\n"}, {"source_code": "from collections import deque\ndef getAnsRight(a):\n stack = deque()\n ans = 0\n for i in range(len(a)):\n if a[i] == '(':\n stack.append(a[i])\n else:\n stack.pop()\n if not len(stack):\n ans += 1\n return ans\n\n\n\ndef getAnsRighnt(a):\n stack = deque()\n indClose = -1\n indOpen = -1\n for i in range(len(a)):\n if a[i] == '(':\n stack.append((a[i], i))\n if a[i] == ')':\n if len(stack) == 0:\n indClose = i\n else:\n stack.pop()\n if len(stack):\n indOpen = stack.popleft()[1]\n\n if indOpen == -1 and indClose == -1:\n return getAnsRight(a)\n return 1 + getAnsRight(a[indClose+1:indOpen])\n\ndef getPer(a, i, j):\n l = a[i]\n a[i] = a[j]\n a[j] = l\n sOpen = 0\n sClose = 0\n for i in range(len(a)):\n if a[i] == '(':\n sOpen += 1\n else:\n sClose += 1\n if sOpen != sClose:\n return 0\n return getAnsRighnt(a)\n\ndef kek():\n n = int(input())\n a = list(input())\n answr = getPer(a, 0, 0)\n indL = 0\n indR = 0\n for i in range(len(a)):\n for j in range(i+1, len(a)):\n if a[i] == a[j]:\n continue\n lastAnswer = answr\n answr = max(getPer(a.copy(), i, j), answr)\n if lastAnswer < answr:\n indL = i\n indR = j\n\n print(answr)\n print(indL+1, indR+1)\nkek()"}, {"source_code": "n = int(input())\ns = list(input())\n\ncnt_r = 0\ncnt_l = 0\nfor i in range(n):\n if s[i] == \")\":\n cnt_r += 1\n else:\n cnt_l += 1\nif cnt_l != cnt_r:\n print(0)\n print(1, 1)\n exit()\n\npos_r = []\npos_l = []\n\nfor i in range(n):\n if s[i] == \")\":\n pos_r.append(i)\n else:\n pos_l.append(i)\n\n# no change\nans = 0\nfor i in [0]:\n for j in [0]:\n tmp_ans = 0\n tmp = s[0:]\n tmp[i], tmp[j] = tmp[j], tmp[i]\n cnt = 0\n offset = 0\n min_cnt = 0\n for num, k in enumerate(tmp):\n if k == \")\":\n cnt -= 1\n else: \n cnt += 1\n if cnt < min_cnt:\n min_cnt = cnt\n offset = num+1\n cnt = 0\n for num, k in enumerate(tmp[offset:]+tmp[0:offset]):\n if k == \")\":\n cnt += 1\n else: \n cnt -= 1\n if cnt == 0:\n tmp_ans += 1 \n if ans < tmp_ans:\n ans = tmp_ans\n ind1 = i\n ind2 = j\n\nfor i in pos_r:\n for j in pos_l:\n tmp_ans = 0\n tmp = s[0:]\n tmp[i], tmp[j] = tmp[j], tmp[i]\n cnt = 0\n offset = 0\n min_cnt = 0\n for num, k in enumerate(tmp):\n if k == \")\":\n cnt -= 1\n else: \n cnt += 1\n if cnt < min_cnt:\n min_cnt = cnt\n offset = num+1\n #print(\"\".join(tmp), offset)\n #print(\"\".join(tmp[offset:]+tmp[0:offset]))\n cnt = 0\n for num, k in enumerate(tmp[offset:]+tmp[0:offset]):\n if k == \")\":\n cnt += 1\n else: \n cnt -= 1\n if cnt == 0:\n tmp_ans += 1 \n if ans < tmp_ans:\n ans = tmp_ans\n ind1 = i\n ind2 = j\nprint(ans)\nprint(ind1+1, ind2+1)"}, {"source_code": "n = int(input())\nst = input()\ns = [0 if c == \"(\" else 1 for c in st]\nif n % 2 != 0 or sum(s) != n//2:\n print(0)\n print(1,1)\n exit(0)\nmaxx = 0\nind = (0,0)\nmaxshift = 0\nfor shift in range(n):\n stack = 0\n x1 = -1\n x2 = -1\n sumzero = 0\n for i,c in enumerate(s):\n if s[(i+shift)%n] == 0:\n stack+=1\n else:\n stack-=1\n if stack == 0:\n sumzero+=1\n if stack < 0:\n x1 = i\n break\n stack = 0\n for i in range(n-1, -1, -1):\n if s[(i+shift)%n] == 1:\n stack+=1\n else:\n stack-=1\n if stack < 0:\n x2 = i\n break\n if x1 == -1 and x2 == -1 and stack == 0:\n if sumzero > maxx:\n maxx=sumzero\n ind = (0,0)\n if x1 == -1 or x2 == -1 or x1 == x2:\n continue\n stack = 0\n corr = True\n ans = 0\n for i in range(n):\n c = s[(i+shift)%n]\n \n if i == x1 or i == x2:\n c = 1-c\n if c == 0:\n stack += 1\n else:\n stack -= 1\n if stack == 0:\n ans+=1\n if stack == -1:\n corr = False\n break\n \n if not corr or stack > 0:\n continue\n if ans > maxx:\n maxshift = shift\n maxx = ans\n ind = ((x1+shift)%n, (x2+shift)%n)\nprint(maxx)\nprint(ind[0]+1,ind[1]+1)\n"}, {"source_code": "n = int(input())\ns = input()\nsl = list(s)\n\nans = 0\nai = [1,1]\n\nif sl.count(\"(\") == sl.count(\")\"):\n for i in range(n):\n for j in range(i+1, n):\n sl[i], sl[j] = sl[j], sl[i]\n b = 0\n p = 0\n minp = 0\n k = 0\n for kk in range(n):\n if sl[k] == \"(\":\n p += 1\n else:\n p -= 1\n if p == minp:\n b += 1\n elif p < minp:\n minp = p\n b = 1\n k = (k+1) % n\n # print(sl,b,i,j,k,minp)\n if b > ans:\n ans = b\n ai = [i+1, j+1]\n sl[i], sl[j] = sl[j], sl[i]\n\nprint(ans)\nprint(ai[0], ai[1])\n"}, {"source_code": "n = int(input())\ns = list(input())\n\nbest = 0\nL = 1\nR = 1\n\ndef check():\n\tcalc = 0\n\tmin = 0\n\tcntmin = 0\n\tfor ch in s:\n\t\tif ch == '(':\n\t\t\tcalc += 1\n\t\telse:\n\t\t\tcalc -= 1\n\t\tif min > calc:\n\t\t\tmin = calc\n\t\t\tcntmin = 1\n\t\telif min == calc:\n\t\t\tcntmin += 1\n\treturn cntmin if calc == 0 else 0\n\nif len(s) % 2:\n\tprint(best)\n\tprint(L, R)\n\tquit()\n\nbest = check()\nfor i, ch in enumerate(s, 0):\n\tfor j in range(i + 1, n, 1):\n\t\ts[i], s[j] = s[j], s[i]\n\t\tnew = check()\n\t\ts[j], s[i] = s[i], s[j]\n\t\tif (new > best):\n\t\t\tbest = new; L = 1+i; R = 1+j\nprint(best)\nprint(L, R)"}, {"source_code": "n=int(input())\ns=list(input())\ndef call(x):\n if x=='(':\n return 1\n else:\n return -1\ns=list(map(call,s))\nif sum(s)!=0:\n print(0)\n print(1,1)\nelse:\n ans=0\n pr=(1,1)\n for i in range(n-1):\n for j in range(i,n):\n lm=10**9\n sm=0\n ct=0\n s[i],s[j]=s[j],s[i]\n for k in range(n):\n sm+=s[k]\n if sm<lm:\n lm=sm\n ct=1\n elif sm==lm:\n ct+=1\n if ct>ans:\n ans=ct\n pr=(i+1,j+1)\n s[i],s[j]=s[j],s[i]\n print(ans)\n print(*pr)"}, {"source_code": "# import cProfile\ndef prefix(s):\n count = 0\n cur = 0\n m = 0\n for c in s:\n if c == '(':\n cur += 1\n else:\n cur -= 1\n if cur < m:\n m = cur\n count = 0\n if cur == m:\n count += 1\n return count\n\nfrom collections import Counter\nn = int(input())\ns = list(input())\nC = Counter(s)\nif C['('] == C[')']:\n a, b, c = -1, -1, -1\n for l in range(n):\n for r in range(l, n):\n s[l], s[r] = s[r], s[l]\n abc = prefix(s)\n if abc > a:\n a = abc\n b = l\n c = r\n s[l], s[r] = s[r], s[l]\n print (a)\n print (b + 1, c + 1)\nelse:\n print (0)\n print (1, 1)"}, {"source_code": "n = int(input())\nS = list(input())\ndef count_all(s):\n cnt=0\n l_cnt=1\n for c in s[1:]:\n if c==')':\n l_cnt-=1\n else:\n l_cnt+=1\n if l_cnt==0:\n cnt+=1\n return cnt\nif S==list('()'*(n//2)) or S==list(')'+'()'*(n//2-1)+'('):\n print(n // 2)\n print(1, 1)\nelse:\n res=0\n l,r =1,1\n lc=rc=0\n for c in S:\n if c==\"(\":\n lc+=1\n else:\n rc+=1\n if lc==rc:\n for i in range(n):\n for j in range(i,n):\n ss=S[:]\n if ss[i]==ss[j]:\n continue\n ss[i],ss[j]=ss[j],ss[i]\n t=0\n t_min=n\n m=0\n for k in range(n):\n if ss[k]==\")\":\n t-=1\n else:\n t+=1\n if t<t_min:\n t_min,m=t,k\n sss=ss[m+1:]+ss[:m+1]\n temp = count_all(sss)\n if temp>=res:\n # print(sss)\n res=temp\n l,r=i+1,j+1\n print(res)\n print(l,r)\n\n"}, {"source_code": "n = int(input())\nddd = input()\nd = [0]\nfor dd in ddd:\n if dd == '(':\n d.append(d[-1] + 1)\n else:\n d.append(d[-1] - 1)\nif d[-1] != 0:\n print(\"0\\n1 1\")\n exit(0)\n\nd.pop()\nmn = min(d)\nind = d.index(mn)\nd = d[ind:] + d[:ind] \nd = [i - mn for i in d]\n\nfi = -1\ncrfi = -1\nli = -1\nmx = 0\ncr = 0\ncnt0 = 0\nfor i in range(n):\n dd = d[i]\n if dd == 0:\n cnt0 += 1\n if dd == 2:\n if cr == 0:\n crfi = i\n cr += 1\n if cr > mx:\n fi = crfi\n li = i\n mx = cr\n elif dd < 2:\n cr = 0\n\n# print('=========')\n# print(d)\n# print(cnt0)\n# print(fi, li)\n# print(mx)\n# print(\"=========\")\n\n# if fi == -1:\n# print(cnt0)\n# print(1, 1)\n# else:\n# print(cnt0 + mx)\n# print(fi, li + 2)\nif fi == -1:\n ans1 = [cnt0, 0, 0]\nelse:\n ans1 = [cnt0 + mx, fi-1, li]\n\n\nfi = -1\ncrfi = -1\nli = -1\nmx = 0\ncr = 0\nfor i in range(n):\n dd = d[i]\n if dd == 1:\n if cr == 0:\n crfi = i\n cr += 1\n if cr > mx:\n fi = crfi\n li = i\n mx = cr\n elif dd < 1:\n cr = 0\n\nans2 = [mx, fi-1, li]\n\nif ans1[0] > ans2[0]:\n print(ans1[0])\n print(((ans1[1] + ind)%n) + 1, ((ans1[2] + ind)%n) + 1)\nelse:\n print(ans2[0])\n print(((ans2[1] + ind)%n) + 1, ((ans2[2] + ind)%n) + 1)\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\ns = list(input())\nr = -1\nl = n\nroot = []\n\ndef find_right(node):\n global l,r,s,n\n while n:\n r += 1\n n -= 1\n if s[r] == '(':\n node[2].append([r,-1,[]])\n find_right(node[2][-1])\n else:\n node[1] = r\n return True\n return False\n\ndef find_left(node):\n global l,r,s,n\n while n:\n l -= 1\n n -= 1\n if s[l] == ')':\n node[2].append([-1,l,[]])\n find_left(node[2][-1])\n else:\n node[0] = l\n return True \n return False\n\nis_correct = True\nwhile n:\n r += 1\n n -= 1\n if s[r]=='(':\n root.append([r,-1,[]])\n is_correct &= find_right(root[-1])\n else:\n root = [[-1,r,root]] \n is_correct &= find_left(root[-1])\n\nsol = [[0,1,1]]\nif is_correct: \n sol.append([len(root), 1, 1])\n for child in root:\n sol.append([len(child[2])+1, child[0]+1, child[1]+1])\n for gr_child in child[2]:\n if len(gr_child[2]):\n sol.append([len(root)+len(gr_child[2])+1, gr_child[0]+1, gr_child[1]+1])\n \nprint('%d\\n%d %d'%tuple(max(sol)))"}, {"source_code": "n = int(input())\ns = list(input())\n\nif n % 2 == 1 or s.count('(') != s.count(')'):\n print('0\\n1 1')\n exit()\n\ndef solve():\n cnt_open, res, need = 0, 0, 0\n for i in s:\n if i == '(':\n cnt_open += 1\n else:\n cnt_open -= 1\n if cnt_open < need:\n need = cnt_open\n res = 1\n elif cnt_open == need:\n res += 1\n return res\n\nres, res_i, res_j = solve(), 0, 0\nfor i in range(n):\n for j in range(i+1, n):\n if s[i] != s[j]:\n s[i], s[j] = s[j], s[i]\n curr = solve()\n s[i], s[j] = s[j], s[i]\n if curr > res:\n res = curr\n res_i = i\n res_j = j\nprint(res)\nprint(res_i+1, res_j+1)\n"}, {"source_code": "def get_bal():\n bal = [0] * n\n bal[0] = u[0]\n for i in range(1, n):\n bal[i] = bal[i - 1] + u[i]\n min_b = min(bal)\n ans = 0\n for i in range(n):\n if bal[i] == min_b:\n ans += 1\n return ans\n\n\nn = int(input())\nu = list(input())\nfor i in range(n):\n if u[i] == '(':\n u[i] = 1\n else:\n u[i] = -1\nif sum(u) != 0:\n print(0)\n print(1, 1)\n exit()\nind = (-1, -1)\nans = -1\nfor i in range(n):\n for j in range(i, n):\n u[i], u[j] = u[j], u[i]\n ans_i = get_bal()\n u[i], u[j] = u[j], u[i]\n if ans_i > ans:\n ans = ans_i\n ind = (i + 1, j + 1)\nprint(ans)\nprint(ind[0], ind[1])\n\n\n\n\n \n"}], "negative_code": [{"source_code": "n = int(input())\ns = list(input())\nr = -1\nl = n\nroot = []\n\ndef find_right(node):\n global l,r,s,n\n while n:\n r += 1\n n -= 1\n if s[r] == '(':\n node[2].append([r,-1,[]])\n find_right(node[2][-1])\n else:\n node[1] = r\n return True\n return False\n\ndef find_left(node):\n global l,r,s,n\n while n:\n l -= 1\n n -= 1\n if s[l] == ')':\n node[2].append([-1,l,[]])\n find_left(node[2][-1])\n else:\n node[0] = l\n return True \n return False\n\nis_correct = True\nwhile n:\n r += 1\n n -= 1\n if s[r]=='(':\n root.append([r,-1,[]])\n is_correct &= find_right(root[-1])\n else:\n root = [[-1,r,root]] \n is_correct &= find_left(root[-1])\n\nb = [1,1] \nif is_correct: \n m = len(root)\n for node in root:\n if (len(node[2])+1) > len(root):\n b = [node[0]+1, node[1]+1]\n m = len(node[2]) + 1\nelse:\n m = 0\nprint('%d\\n%d %d'%(m, b[0],b[1]))\n\n \n \n \n\n\n \n \n"}, {"source_code": "n = int(input())\ns = list(input())\nr = -1\nl = n\nroot = []\n\ndef find_right(node):\n global l,r,s,n\n while n:\n r += 1\n n -= 1\n if s[r] == '(':\n node[2].append([r,-1,[]])\n find_right(node[2][-1])\n else:\n node[1] = r\n return True\n return False\n\ndef find_left(node):\n global l,r,s,n\n while n:\n l -= 1\n n -= 1\n if s[l] == ')':\n node[2].append([-1,l,[]])\n find_left(node[2][-1])\n else:\n node[0] = l\n return True \n return False\n\nis_correct = True\nwhile n:\n r += 1\n n -= 1\n if s[r]=='(':\n root.append([r,-1,[]])\n is_correct &= find_right(root[-1])\n else:\n root = [[-1,r,root]] \n is_correct &= find_left(root[-1])\n\nsol = [[0,1,1]]\nif is_correct: \n m = len(root)\n for child in root:\n sol.append([len(child[2])+1, child[0]+1, child[1]+1])\n for gr_child in child[2]:\n if len(gr_child[2]):\n sol.append([len(root)+len(gr_child[2])+1, gr_child[0]+1, gr_child[1]+1])\n \nprint('%d\\n%d %d'%tuple(max(sol)))"}, {"source_code": "from sys import stdin\nfrom collections import deque\n# https://codeforces.com/contest/1354/status/D\nmod = 10**9 + 7\nimport sys\nimport random\n# sys.setrecursionlimit(10**6)\nfrom queue import PriorityQueue\n# def rl():\n# return [int(w) for w in stdin.readline().split()]\nfrom bisect import bisect_right\nfrom bisect import bisect_left\nfrom collections import defaultdict\nfrom math import sqrt,factorial,gcd,log2,inf,ceil\n# map(int,input().split())\n# # l = list(map(int,input().split()))\n# from itertools import permutations\nimport heapq\n# input = lambda: sys.stdin.readline().rstrip()\ninput = lambda : sys.stdin.readline().rstrip()\nfrom sys import stdin, stdout\nfrom heapq import heapify, heappush, heappop\nfrom itertools import permutations\nfrom math import factorial as f\n\n# def ncr(x, y):\n# return f(x) // (f(y) * f(x - y))\ndef ncr(n, r, p):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\n\nimport sys\n\n# input = sys.stdin.readline\n# LCA\n# def bfs(na):\n#\n# queue = [na]\n# boo[na] = True\n# level[na] = 0\n#\n# while queue!=[]:\n#\n# z = queue.pop(0)\n#\n# for i in hash[z]:\n#\n# if not boo[i]:\n#\n# queue.append(i)\n# level[i] = level[z] + 1\n# boo[i] = True\n# dp[i][0] = z\n#\n#\n#\n# def prec(n):\n#\n# for i in range(1,20):\n#\n# for j in range(1,n+1):\n# if dp[j][i-1]!=-1:\n# dp[j][i] = dp[dp[j][i-1]][i-1]\n#\n#\n# def lca(u,v):\n# if level[v] < level[u]:\n# u,v = v,u\n#\n# diff = level[v] - level[u]\n#\n#\n# for i in range(20):\n# if ((diff>>i)&1):\n# v = dp[v][i]\n#\n#\n# if u == v:\n# return u\n#\n#\n# for i in range(19,-1,-1):\n# # print(i)\n# if dp[u][i] != dp[v][i]:\n#\n# u = dp[u][i]\n# v = dp[v][i]\n#\n#\n# return dp[u][0]\n#\n# dp = []\n#\n#\n# n = int(input())\n#\n# for i in range(n + 10):\n#\n# ka = [-1]*(20)\n# dp.append(ka)\n\n\n# class FenwickTree:\n# def __init__(self, x):\n# \"\"\"transform list into BIT\"\"\"\n# self.bit = x\n# for i in range(len(x)):\n# j = i | (i + 1)\n# if j < len(x):\n# x[j] += x[i]\n#\n# def update(self, idx, x):\n# \"\"\"updates bit[idx] += x\"\"\"\n# while idx < len(self.bit):\n# self.bit[idx] += x\n# idx |= idx + 1\n#\n# def query(self, end):\n# \"\"\"calc sum(bit[:end])\"\"\"\n# x = 0\n# while end:\n# x += self.bit[end - 1]\n# end &= end - 1\n# return x\n#\n# def find_kth_smallest(self, k):\n# \"\"\"Find largest idx such that sum(bit[:idx]) <= k\"\"\"\n# idx = -1\n# for d in reversed(range(len(self.bit).bit_length())):\n# right_idx = idx + (1 << d)\n# if right_idx < len(self.bit) and k >= self.bit[right_idx]:\n# idx = right_idx\n# k -= self.bit[idx]\n# return idx + 1\n\n\n\n# import sys\n# def rs(): return sys.stdin.readline().strip()\n# def ri(): return int(sys.stdin.readline())\n# def ria(): return list(map(int, sys.stdin.readline().split()))\n# def prn(n): sys.stdout.write(str(n))\n# def pia(a): sys.stdout.write(' '.join([str(s) for s in a]))\n#\n#\n# import gc, os\n#\n# ii = 0\n# _inp = b''\n#\n#\n# def getchar():\n# global ii, _inp\n# if ii >= len(_inp):\n# _inp = os.read(0, 100000)\n# gc.collect()\n# ii = 0\n# if not _inp:\n# return b' '[0]\n# ii += 1\n# return _inp[ii - 1]\n#\n#\n# def input():\n# c = getchar()\n# if c == b'-'[0]:\n# x = 0\n# sign = 1\n# else:\n# x = c - b'0'[0]\n# sign = 0\n# c = getchar()\n# while c >= b'0'[0]:\n# x = 10 * x + c - b'0'[0]\n# c = getchar()\n# if c == b'\\r'[0]:\n# getchar()\n# return -x if sign else x\n\n# fenwick Tree\n\n# n,q = map(int,input().split())\n#\n#\n# l1 = list(map(int,input().split()))\n#\n# l2 = list(map(int,input().split()))\n#\n# bit = [0]*(10**6 + 1)\n#\n# def update(i,add,bit):\n#\n# while i>0 and i<len(bit):\n#\n# bit[i]+=add\n# i = i + (i&(-i))\n#\n#\n# def sum(i,bit):\n# ans = 0\n# while i>0:\n#\n# ans+=bit[i]\n# i = i - (i & ( -i))\n#\n#\n# return ans\n#\n# def find_smallest(k,bit):\n#\n# l = 0\n# h = len(bit)\n# while l<h:\n#\n# mid = (l+h)//2\n# if k <= sum(mid,bit):\n# h = mid\n# else:\n# l = mid + 1\n#\n#\n# return l\n#\n#\n# def insert(x,bit):\n# update(x,1,bit)\n#\n# def delete(x,bit):\n# update(x,-1,bit)\n# fa = set()\n#\n# for i in l1:\n# insert(i,bit)\n#\n#\n# for i in l2:\n# if i>0:\n# insert(i,bit)\n#\n# else:\n# z = find_smallest(-i,bit)\n#\n# delete(z,bit)\n#\n#\n# # print(bit)\n# if len(set(bit)) == 1:\n# print(0)\n# else:\n# for i in range(1,n+1):\n# z = find_smallest(i,bit)\n# if z!=0:\n# print(z)\n# break\n#\n\n# service time problem\n\n\n# def solve2(s,a,b,hash,z,cnt):\n# temp = cnt.copy()\n# x,y = hash[a],hash[b]\n# i = 0\n# j = len(s)-1\n#\n# while z:\n#\n# if s[j] - y>=x-s[i]:\n# if temp[s[j]]-1 == 0:\n# j-=1\n# temp[s[j]]-=1\n# z-=1\n#\n#\n# else:\n# if temp[s[i]]-1 == 0:\n# i+=1\n#\n# temp[s[i]]-=1\n# z-=1\n#\n# return s[i:j+1]\n#\n#\n#\n#\n#\n# def solve1(l,s,posn,z,hash):\n#\n# ans = []\n# for i in l:\n# a,b = i\n# ka = solve2(s,a,b,posn,z,hash)\n# ans.append(ka)\n#\n# return ans\n#\n# def consistent(input, window, min_entries, max_entries, tolerance):\n#\n# l = input\n# n = len(l)\n# l.sort()\n# s = list(set(l))\n# s.sort()\n#\n# if min_entries<=n<=max_entries:\n#\n# if s[-1] - s[0]<window:\n# return True\n# hash = defaultdict(int)\n# posn = defaultdict(int)\n# for i in l:\n# hash[i]+=1\n#\n# z = (tolerance*(n))//100\n# poss_window = set()\n#\n#\n# for i in range(len(s)):\n# posn[i] = l[i]\n# for j in range(i+1,len(s)):\n# if s[j]-s[i] == window:\n# poss_window.add((s[i],s[j]))\n#\n# if poss_window!=set():\n# print(poss_window)\n# ans = solve1(poss_window,s,posn,z,hash)\n# print(ans)\n#\n#\n# else:\n# pass\n#\n# else:\n# return False\n#\n#\n#\n#\n# l = list(map(int,input().split()))\n#\n# min_ent,max_ent = map(int,input().split())\n# w = int(input())\n# tol = int(input())\n# consistent(l, w, min_ent, max_ent, tol)\n\n# t = int(input())\n#\n# for i in range(t):\n#\n# n,x = map(int,input().split())\n#\n# l = list(map(int,input().split()))\n#\n# e,o = 0,0\n#\n# for i in l:\n# if i%2 == 0:\n# e+=1\n# else:\n# o+=1\n#\n# if e+o>=x and o!=0:\n# z = e+o - x\n# if z == 0:\n# if o%2 == 0:\n# print('No')\n# else:\n# print('Yes')\n# continue\n# if o%2 == 0:\n# o-=1\n# z-=1\n# if e>=z:\n# print('Yes')\n# else:\n# z-=e\n# o-=z\n# if o%2!=0:\n# print('Yes')\n# else:\n# print('No')\n#\n# else:\n#\n# if e>=z:\n# print('Yes')\n# else:\n# z-=e\n# o-=z\n# if o%2!=0:\n# print('Yes')\n# else:\n# print('No')\n# else:\n# print('No')\n#\n#\n#\n#\n#\n#\n#\n# def dfs(n):\n# boo[n] = True\n# dp2[n] = 1\n# for i in hash[n]:\n# if not boo[i]:\n#\n# dfs(i)\n# dp2[n] += dp2[i]\n\n\n\n\n\n\n\n\n\nn = int(input())\n\ns = list(input())\nans = 0\nx,y = 1,1\nfor i in range(n):\n for j in range(i+1,n):\n s[i],s[j] = s[j],s[i]\n stack = []\n cnt = 0\n flag = 0\n for k in range(n):\n if s[k] == '(':\n stack.append('(')\n else:\n if stack!=[]:\n stack.pop()\n if stack == []:\n cnt+=1\n else:\n flag = -1\n break\n if flag == 0:\n ans = max(cnt,ans)\n if ans == cnt:\n x,y = i+1,j+1\n\n s[i],s[j] = s[j],s[i]\n\n\nprint(ans)\nprint(x,y)\n\n\n\n\n\n\n"}, {"source_code": "n=int(input())\ns=input()\nmaxn=-1\nif(n==1):\n print(0)\n print(1,1)\n exit(0)\nfor i in range(n):\n for j in range(i+1,n):\n s1=s[:i]+s[j]+s[i+1:j]+s[i]+s[j+1:]\n num=0\n temp=0\n min=501\n '''for k in range(1,n+1):\n s2=s1[n-k:]+s1[:n-k]\n while(\"()\" in s2):\n s2=s2.replace(\"()\",\"\")\n if(s2==\"\"):\n num+=1'''\n for k in range(n):\n if(s1[k]=='('):\n temp+=1\n else:\n temp-=1\n if(temp<min):\n min=temp\n num=1\n elif(temp==min):\n num+=1\n if(num>maxn):\n maxn=num\n ansi=i+1\n ansj=j+1\nprint(maxn)\nprint(ansi,ansj)"}, {"source_code": "n = int(input().strip())\ns= input().strip()\nss= 0\nmina = 0\nti = 0\nfor k in range(len(s)):\n if(s[k] == \"(\"):\n ss+=1\n else:\n ss-=1\n if(ss<0):\n ti = k+1\n ss = 0\ns=s[ti:]+s[:ti]\nprint(s)\nss= 0\nfor k in range(len(s)):\n if(s[k] == \"(\"):\n ss+=1\n else:\n ss-=1\n if(ss<0):\n print(0)\n print(1,1)\n break\nelse:\n if(ss == 0):\n pre=[0 for k in range(len(s))]\n for k in range(len(s)):\n if (s[k] == \"(\"):\n ss += 1\n else:\n ss -= 1\n pre[k] = ss\n tt = 0\n a =(1,1)\n for k in range(0,len(s)):\n if(pre[k] == 0):\n tt+=1\n maxi= tt\n g =0\n gg =0\n while(gg<len(s)):\n if(pre[gg] == 0):\n if(gg != g+1):\n yy = g+1\n y = g+1\n q = 0\n while(yy<gg):\n if(pre[yy] == 1):\n if(yy !=y+1):\n rr = y+1\n r = y+1\n h = 0\n while(rr<yy):\n if(pre[rr] == 2):\n h+=1\n rr+=1\n\n if(tt+h+1>maxi):\n maxi = tt + h + 1\n a=(y,yy)\n q+=1\n y = yy+1\n yy = y\n else:\n yy+=1\n\n if (q + 1 > maxi):\n maxi = q+1\n a = (g, gg)\n g= gg+1\n gg= g\n else:\n gg+=1\n print(maxi)\n print((a[0]+ti)%len(s)+1,(a[1]+ti)%len(s)+1)\n\n\n\n\n else:\n print(0)\n print(1,1)\n\n\n"}, {"source_code": "from collections import deque\ndef getAnsRight(a):\n stack = deque()\n ans = 0\n for i in range(len(a)):\n if a[i] == '(':\n stack.append(a[i])\n else:\n stack.pop()\n if not len(stack):\n ans += 1\n return ans\n\n\n\ndef getAnsRighnt(a):\n stack = deque()\n indClose = -1\n indOpen = -1\n for i in range(len(a)):\n if a[i] == '(':\n stack.append((a[i], i))\n if a[i] == ')':\n if len(stack) == 0:\n indClose = i\n else:\n stack.pop()\n if len(stack):\n indOpen = stack.popleft()[1]\n\n if indOpen == -1 and indClose == -1:\n return getAnsRight(a)\n return 1 + getAnsRight(a[indClose+1:indOpen])\n\ndef getPer(a, i, j):\n l = a[i]\n a[i] = a[j]\n a[j] = l\n sOpen = 0\n sClose = 0\n for i in range(len(a)):\n if a[i] == '(':\n sOpen += 1\n else:\n sClose += 1\n if sOpen != sClose:\n return 0\n return getAnsRighnt(a)\n\ndef kek():\n n = int(input())\n a = list(input())\n answr = getAnsRighnt(a)\n indL = 0\n indR = 0\n for i in range(len(a)):\n for j in range(i+1, len(a)):\n if a[i] == a[j]:\n continue\n lastAnswer = answr\n answr = max(getPer(a.copy(), i, j), answr)\n if lastAnswer < answr:\n indL = i\n indR = j\n\n print(answr)\n print(indL+1, indR+1)\nkek()"}, {"source_code": "from collections import deque\ndef getAnsRight(a):\n stack = deque()\n ans = 0\n for i in range(len(a)):\n if a[i] == '(':\n stack.append(a[i])\n else:\n stack.pop()\n if not len(stack):\n ans += 1\n return ans\n\n\n\ndef getAnsRighnt(a):\n stack = deque()\n indClose = -1\n indOpen = -1\n for i in range(len(a)):\n if a[i] == '(':\n stack.append((a[i], i))\n if a[i] == ')':\n if len(stack) == 0:\n indClose = i\n else:\n stack.pop()\n if len(stack):\n indOpen = stack.popleft()[1]\n\n if indOpen == -1 and indClose == -1:\n return getAnsRight(a)\n return 1 + getAnsRight(a[indClose+1:indOpen])\n\ndef getPer(a, i, j):\n l = a[i]\n a[i] = a[j]\n a[j] = l\n sOpen = 0\n sClose = 0\n for i in range(len(a)):\n if a[i] == '(':\n sOpen += 1\n else:\n sClose += 1\n if sOpen != sClose:\n return 0\n return getAnsRighnt(a)\n\n\nn = int(input())\na = list(input())\nanswr = 0\nindL = 0\nindR = 0\nfor i in range(len(a)):\n for j in range(i, len(a)):\n lastAnswer = answr\n answr = max(getPer(a.copy(), i, j), answr)\n if lastAnswer < answr:\n indL = i\n inrR = j\n\nprint(answr)\nprint(indL, indR)"}, {"source_code": "from collections import deque\ndef getAnsRight(a):\n stack = deque()\n ans = 0\n for i in range(len(a)):\n if a[i] == '(':\n stack.append(a[i])\n else:\n stack.pop()\n if not len(stack):\n ans += 1\n return ans\n\n\n\ndef getAnsRighnt(a):\n stack = deque()\n indClose = -1\n indOpen = -1\n for i in range(len(a)):\n if a[i] == '(':\n stack.append((a[i], i))\n if a[i] == ')':\n if len(stack) == 0:\n indClose = i\n else:\n stack.pop()\n if len(stack):\n indOpen = stack.popleft()[1]\n\n if indOpen == -1 and indClose == -1:\n return getAnsRight(a)\n return 1 + getAnsRight(a[indClose+1:indOpen])\n\ndef getPer(a, i, j):\n l = a[i]\n a[i] = a[j]\n a[j] = l\n sOpen = 0\n sClose = 0\n for i in range(len(a)):\n if a[i] == '(':\n sOpen += 1\n else:\n sClose += 1\n if sOpen != sClose:\n return 0\n return getAnsRighnt(a)\n\ndef kek():\n n = int(input())\n a = list(input())\n answr = 0\n indL = 0\n indR = 0\n for i in range(len(a)):\n for j in range(i+1, len(a)):\n if a[i] == a[j]:\n continue\n lastAnswer = answr\n answr = max(getPer(a.copy(), i, j), answr)\n if lastAnswer < answr:\n indL = i\n indR = j\n\n print(answr)\n print(indL+1, indR+1)\nkek()"}, {"source_code": "from collections import deque\ndef getAnsRight(a):\n stack = deque()\n ans = 0\n for i in range(len(a)):\n if a[i] == '(':\n stack.append(a[i])\n else:\n stack.pop()\n if not len(stack):\n ans += 1\n return ans\n\n\n\ndef getAnsRighnt(a):\n stack = deque()\n indClose = -1\n indOpen = -1\n for i in range(len(a)):\n if a[i] == '(':\n stack.append((a[i], i))\n if a[i] == ')':\n if len(stack) == 0:\n indClose = i\n else:\n stack.pop()\n if len(stack):\n indOpen = stack.popleft()[1]\n\n if indOpen == -1 and indClose == -1:\n return getAnsRight(a)\n return 1 + getAnsRight(a[indClose+1:indOpen])\n\ndef getPer(a, i, j):\n l = a[i]\n a[i] = a[j]\n a[j] = l\n sOpen = 0\n sClose = 0\n for i in range(len(a)):\n if a[i] == '(':\n sOpen += 1\n else:\n sClose += 1\n if sOpen != sClose:\n return 0\n return getAnsRighnt(a)\n\n\nn = int(input())\na = list(input())\nanswr = 0\nindL = 0\nindR = 0\nfor i in range(len(a)):\n for j in range(i, len(a)):\n lastAnswer = answr\n answr = max(getPer(a.copy(), i, j), answr)\n if lastAnswer < answr:\n indL = i\n inrR = j\n\nprint(answr)\nprint(indL+1, indR+1)"}, {"source_code": "n = int(input())\ns = list(input())\n\ncnt_r = 0\ncnt_l = 0\nfor i in range(n):\n if s[i] == \")\":\n cnt_r += 1\n else:\n cnt_l += 1\nif cnt_l != cnt_r:\n print(0)\n print(1, 1)\n exit()\n\npos_r = []\npos_l = []\n\nfor i in range(n):\n if s[i] == \")\":\n pos_r.append(i)\n else:\n pos_l.append(i)\n\nans = 0\nfor i in pos_r:\n for j in pos_l:\n tmp_ans = 0\n tmp = s[0:]\n tmp[i], tmp[j] = tmp[j], tmp[i]\n cnt = 0\n offset = 0\n min_cnt = 0\n for num, k in enumerate(tmp):\n if k == \")\":\n cnt -= 1\n else: \n cnt += 1\n if cnt < min_cnt:\n min_cnt = cnt\n offset = num+1\n #print(\"\".join(tmp), offset)\n #print(\"\".join(tmp[offset:]+tmp[0:offset]))\n cnt = 0\n for num, k in enumerate(tmp[offset:]+tmp[0:offset]):\n if k == \")\":\n cnt += 1\n else: \n cnt -= 1\n if cnt == 0:\n tmp_ans += 1 \n if ans < tmp_ans:\n ans = tmp_ans\n ind1 = i\n ind2 = j\nprint(ans)\nprint(ind1+1, ind2+1)"}, {"source_code": "n = int(input())\nst = input()\ns = [0 if c == \"(\" else 1 for c in st]\nmaxx = 0\nind = (0,0)\nmaxshift = 0\nfor shift in range(n):\n stack = 0\n x1 = -1\n x2 = -1\n for i,c in enumerate(s):\n if s[(i+shift)%n] == 0:\n stack+=1\n else:\n stack-=1\n if stack < 0:\n x1 = i\n break\n stack = 0\n for i in range(n-1, -1, -1):\n if s[(i+shift)%n] == 1:\n stack+=1\n else:\n stack-=1\n if stack < 0:\n x2 = i\n break\n if x1 == -1 or x2 == -1 or x1 == x2:\n continue\n stack = 0\n corr = True\n ans = 0\n for i in range(n):\n c = s[(i+shift)%n]\n \n if i == x1 or i == x2:\n c = 1-c\n if c == 0:\n stack += 1\n else:\n stack -= 1\n if stack == 0:\n ans+=1\n if stack == -1:\n corr = False\n break\n \n if not corr or stack > 0:\n continue\n if ans > maxx:\n maxshift = shift\n maxx = ans\n ind = ((x1+shift)%n, (x2+shift)%n)\nprint(maxx)\nprint(ind[0]+1,ind[1]+1)\n"}, {"source_code": "n = int(input())\ns = input()\nsl = list(s)\n\nans = 0\nai = [1,1]\n\nfor i in range(n):\n for j in range(i, n):\n sl = list(s)\n sl[i], sl[j] = sl[j], sl[i]\n b = 0\n p = 0\n k = 0\n while k < n and sl[k] == \")\":\n k += 1\n for kk in range(n):\n if sl[k] == \"(\":\n p += 1\n else:\n if p == 1:\n b += 1\n elif p == 0:\n b = 0\n break\n p -= 1\n k = (k+1) % n\n # print(sl,b,i,j)\n if b > ans:\n ans = b\n ai = [i+1, j+1]\n\nprint(ans)\nprint(ai[0], ai[1])\n"}, {"source_code": "n = int(input())\ns = input()\nsl = list(s)\n\nans = 0\nai = [1,1]\n\nfor i in range(n):\n for j in range(i, n):\n sl = list(s)\n sl[i], sl[j] = sl[j], sl[i]\n b = 0\n p = 0\n k = 0\n while k < n and sl[k] == \")\":\n k += 1\n k %= n\n for kk in range(n):\n if sl[k] == \"(\":\n p += 1\n else:\n if p == 1:\n b += 1\n elif p == 0:\n b = 0\n break\n p -= 1\n k = (k+1) % n\n # print(sl,b,i,j)\n if b > ans:\n ans = b\n ai = [i+1, j+1]\n\nprint(ans)\nprint(ai[0], ai[1])\n"}, {"source_code": "def prefix(s):\n array = []\n for i in s:\n if i == '(':\n try:\n array.append(1 + array[-1])\n except:\n array.append(1)\n else:\n try:\n array.append(-1 + array[-1])\n except:\n array.append(-1)\n return array\n\ndef count_ok(s):\n array = prefix(s)\n if array[-1] != 0: return 0\n return array.count(min(array))\n\nn = int(input())\ns = list(input())\na, b, c = -1, -1, -1\nfor l in range(n - 1):\n for r in range(l + 1, n):\n t = s.copy()\n t[l], t[r] = t[r], t[l]\n abc = count_ok(t)\n if abc > a:\n a = abc\n b = l\n c = r\nprint (a)\nprint (b + 1, c + 1)"}, {"source_code": "# import cProfile\ndef prefix(s):\n count = 0\n cur = 0\n m = 0\n for c in s:\n if c == '(':\n cur += 1\n else:\n cur -= 1\n if cur < m:\n m = cur\n count = 0\n if cur == m:\n count += 1\n return count\n\nn = int(input())\ns = list(input())\nif n % 2 == 0:\n a, b, c = -1, -1, -1\n for l in range(n):\n for r in range(l, n):\n s[l], s[r] = s[r], s[l]\n abc = prefix(s)\n if abc > a:\n a = abc\n b = l\n c = r\n s[l], s[r] = s[r], s[l]\n print (a)\n print (b + 1, c + 1)\nelse:\n print (0)\n print (1, 1)"}, {"source_code": "n = int(input())\nS = list(input())\ndef count_all(s):\n cnt=0\n l_cnt=1\n for c in s[1:]:\n if c==')':\n l_cnt-=1\n else:\n l_cnt+=1\n if l_cnt==0:\n cnt+=1\n return cnt\nres=0\nl,r =1,1\nlc=rc=0\nfor c in S:\n if c==\"(\":\n lc+=1\n else:\n rc+=1\nif lc==rc:\n for i in range(n):\n for j in range(i,n):\n ss=S[:]\n if ss[i]==ss[j]:\n continue\n ss[i],ss[j]=ss[j],ss[i]\n t=0\n t_min=0\n m=0\n for k in range(n):\n if ss[k]==\")\":\n t-=1\n else:\n t+=1\n if t<=t_min:\n t_min,m=t,k\n sss=ss[m+1:]+ss[:m+1]\n temp = count_all(sss)\n if temp>=res:\n # print(sss)\n res=temp\n l,r=i+1,j+1\nprint(res)\nprint(l,r)"}, {"source_code": "n = int(input())\nS = list(input())\ndef count_all(s):\n cnt=0\n l_cnt=1\n for c in s[1:]:\n if c==')':\n l_cnt-=1\n else:\n l_cnt+=1\n if l_cnt==0:\n cnt+=1\n return cnt\nres=0\nl,r =1,1\nlc=rc=0\nfor c in S:\n if c==\"(\":\n lc+=1\n else:\n rc+=1\nif lc==rc:\n for i in range(n):\n for j in range(i,n):\n ss=S[:]\n if ss[i]==ss[j]:\n continue\n ss[i],ss[j]=ss[j],ss[i]\n t=0\n t_min=0\n m=0\n nums=[0]*n\n for k in range(n):\n if ss[k]==\")\":\n t-=1\n else:\n t+=1\n nums[k]=t\n if t<=t_min:\n t_min,m=t,k\n # sss=ss[m+1:]+ss[:m+1]\n # temp = count_all(sss)\n temp = len([a for a in nums if a==t_min])\n if temp>=res:\n # print(sss)\n res=temp\n l,r=i+1,j+1\nprint(res)\nprint(l,r)"}, {"source_code": "n = int(input())\nS = list(input())\ndef count_all(s):\n cnt=0\n l_cnt=1\n for c in s[1:]:\n if c==')':\n l_cnt-=1\n else:\n l_cnt+=1\n if l_cnt==0:\n cnt+=1\n return cnt\nres=0\nl,r =1,1\nlc=rc=0\nfor c in S:\n if c==\"(\":\n lc+=1\n else:\n rc+=1\nif lc==rc:\n for i in range(n):\n for j in range(i,n):\n ss=S[:]\n if ss[i]==ss[j]:\n continue\n ss[i],ss[j]=ss[j],ss[i]\n t=0\n t_min=n\n m=0\n for k in range(n):\n if ss[k]==\")\":\n t-=1\n else:\n t+=1\n if t<t_min:\n t_min,m=t,k\n sss=ss[m+1:]+ss[:m+1]\n temp = count_all(sss)\n if temp>=res:\n # print(sss)\n res=temp\n l,r=i+1,j+1\nprint(res)\nprint(l,r)"}, {"source_code": "n = int(input())\nS = list(input())\ndef count_all(s):\n cnt=0\n l_cnt=1\n for c in s[1:]:\n if c==')':\n l_cnt-=1\n else:\n l_cnt+=1\n if l_cnt==0:\n cnt+=1\n return cnt\nres=0\nl,r =1,1\nlc=rc=0\nfor c in S:\n if c==\"(\":\n lc+=1\n else:\n rc+=1\n\nif lc==rc:\n for i in range(n):\n for j in range(i,n):\n ss=S[:]\n if ss[i]==ss[j]:\n continue\n ss[i],ss[j]=ss[j],ss[i]\n t=0\n t_min=n\n m=0\n for k in range(n):\n if ss[k]==\")\":\n t-=1\n else:\n t+=1\n if t<t_min:\n t_min,m=t,k\n sss=ss[m+1:]+ss[:m+1]\n temp = count_all(sss)\n if temp>=res:\n # print(sss)\n res=temp\n l,r=i+1,j+1\nif S!=list('()'*(n//2)):\n print(res)\n print(l,r)\nelse:\n print(n//2)\n print(1,1)"}, {"source_code": "n = int(input())\nS = list(input())\n\ndef count_all(s):\n cnt=0\n l_cnt=1\n for c in s[1:]:\n if c==')':\n l_cnt-=1\n else:\n l_cnt+=1\n if l_cnt==0:\n cnt+=1\n return cnt\nif S!=list('()'*(n//2)) and S!=list(')'+'()'*(n//2-1)+'('):\n print(n // 2)\n print(1, 1)\nelse:\n res=0\n l,r =1,1\n lc=rc=0\n \n for c in S:\n if c==\"(\":\n lc+=1\n else:\n rc+=1\n \n if lc==rc:\n for i in range(n):\n for j in range(i,n):\n ss=S[:]\n if ss[i]==ss[j]:\n continue\n ss[i],ss[j]=ss[j],ss[i]\n t=0\n t_min=n\n m=0\n for k in range(n):\n if ss[k]==\")\":\n t-=1\n else:\n t+=1\n if t<t_min:\n t_min,m=t,k\n sss=ss[m+1:]+ss[:m+1]\n temp = count_all(sss)\n if temp>=res:\n # print(sss)\n res=temp\n l,r=i+1,j+1\n print(res)\n print(l,r)"}, {"source_code": "N = 503 * 3\nn = int(input())\ns = input()\n\ndef solve(tmp):\n balance = [0] * N\n q = [0] * N\n\n for i in range(n):\n balance[i+1] += balance[i]\n if tmp[i] == '(':\n balance[i+1] += 1\n else:\n balance[i+1] -= 1\n\n if balance[0] != balance[n]:\n return 0\n\n for i in range(n):\n q[balance[i] + n] += 1 \n for i in range(N):\n if q[i] != 0:\n return q[i]\n\nres, res_i, res_j = 0, 0, 0\nfor i in range(n):\n for j in range(i+1, n):\n if s[i] != s[j]:\n tmp = s[:i] + s[j:j+1] + s[i+1:j] + s[i:i+1] + s[j+1:]\n curr = solve(tmp)\n if curr > res:\n res = curr\n res_i = i\n res_j = j\nprint(res)\nprint(res_i+1, res_j+1)\n"}, {"source_code": "n = int(input())\ns = list(input())\n\ndef solve(x):\n cnt_open, res, need = 0, 0, 0\n for i in x:\n if i == '(':\n cnt_open += 1\n else:\n cnt_open -= 1\n if cnt_open < need:\n need = cnt_open\n res = 1\n elif cnt_open == need:\n res += 1\n return res\n\nres, res_i, res_j = 0, 0, 0\nfor i in range(n):\n for j in range(i+1, n):\n if s[i] != s[j]:\n s[i], s[j] = s[j], s[i]\n curr = solve(s)\n s[i], s[j] = s[j], s[i]\n if curr > res:\n res = curr\n res_i = i\n res_j = j\nprint(res)\nprint(res_i+1, res_j+1)\n"}, {"source_code": "n = int(input())\ns = list(input())\n\nif n % 2 == 1 or s.count('(') != s.count(')'):\n print('0\\n1 1')\n exit()\n\ndef solve():\n cnt_open, res, need = 0, 0, 0\n for i in s:\n if i == '(':\n cnt_open += 1\n else:\n cnt_open -= 1\n if cnt_open < need:\n need = cnt_open\n res = 1\n elif cnt_open == need:\n res += 1\n return res\n\nres, res_i, res_j = 0, 0, 0\nfor i in range(n):\n for j in range(i+1, n):\n if s[i] != s[j]:\n s[i], s[j] = s[j], s[i]\n curr = solve()\n s[i], s[j] = s[j], s[i]\n if curr > res:\n res = curr\n res_i = i\n res_j = j\nprint(res)\nprint(res_i+1, res_j+1)\n"}, {"source_code": "N = int(input())\nstring = list(input())\n\ndef swap(arr, i, j):\n arr[i], arr[j] = arr[j], arr[i]\n\ndef calc(string):\n s = 0\n t = 0\n for char in string:\n if s == 0 and char == \"(\":\n t += 1\n \n if char == \"(\":\n s += 1\n elif char == \")\":\n s -= 1\n\n if s == 0:\n return t\n else:\n return 0\n \nhighest = calc(string)\na = b = 0\nfor i in range(N):\n for j in range(i + 1, N):\n swap(string, i, j)\n total = calc(string)\n if total > highest:\n highest = total\n a, b = i, j\n swap(string, i, j)\n\nprint(highest)\nprint(a+1, b+1)"}, {"source_code": "N = int(input())\nstring = list(input())\n\ndef swap(arr, i, j):\n arr[i], arr[j] = arr[j], arr[i]\n\ndef calc(string):\n s = 0\n t = 0\n for char in string:\n if s == 0 and char == \"(\":\n t += 1\n \n if char == \"(\":\n s += 1\n elif char == \")\":\n s -= 1\n\n \n if s == 0:\n return t\n else:\n return 0\n \nhighest = 0\na = b = 0\nfor i in range(N):\n for j in range(i + 1, N):\n swap(string, i, j)\n total = calc(string)\n if total > highest:\n highest = total\n a, b = i, j\n swap(string, i, j)\n\nprint(highest)\nprint(a+1, b+1)\n\n"}, {"source_code": "N = int(input())\nstring = list(input())\n\ndef swap(arr, i, j):\n arr[i], arr[j] = arr[j], arr[i]\n\ndef calc(string):\n s = 0\n t = 0\n prev = \"\"\n for char in string:\n if char == \"(\":\n s += 1\n elif char == \")\":\n s -= 1\n if ((s == 0) or (s == 1 and prev != \"(\")) and char == \"(\":\n t += 1\n prev = char\n if s == 0:\n return t\n else:\n return 0\n \nhighest = calc(string)\na = b = 0\nfor i in range(N):\n for j in range(i + 1, N):\n swap(string, i, j)\n total = calc(string)\n if total > highest:\n highest = total\n a, b = i, j\n swap(string, i, j)\n\nprint(highest)\nprint(a+1, b+1)"}, {"source_code": "import sys\ninput = sys.stdin.readline\ndef matcher(correcti):\n open_=0\n close_=0\n count=0\n excess=0\n for i in range(len(correcti)):\n if correcti[i]=='(':\n open_+=1\n if correcti[i]==')':\n close_+=1\n if close_>open_ and open_==0:\n excess+=1\n close_-=1\n count=0\n continue\n if open_==close_:\n count+=1\n open_=0\n close_=0\n if open_-close_==excess:\n return(count+1)\n else:\n return(0)\nn=int(input())\nl=[i for i in input() if i!='\\n']\nst=(\"\".join(l).rstrip(')').rstrip('('))\nswap=matcher(l[len(st):]+l[:len(st)])\n#print(swap)\nshifts=[[1,1]]\nfor i in range(n):\n for j in range(i,n):\n if l[i]!=l[j]:\n l[i],l[j]=l[j],l[i]\n output=(matcher(l))\n if output>swap:\n swap=output\n shifts[0]=[i+1,j+1]\n l[i],l[j]=l[j],l[i]\nprint(swap)\nprint(*shifts[0])\n \n"}, {"source_code": "n = int(input())\nseq = list(input())\n\ndef rectify(seq):\n depth = 0\n best = bestVal = -1\n for i in range(n):\n if seq[i] == \"(\":\n depth += 1\n else:\n depth -= 1\n if best == -1 or depth < bestVal:\n best = i\n bestVal = depth\n return seq[best+1:]+seq[:best+1]\n\nif n%2 == 1 or seq.count(\"(\") != seq.count(\")\"):\n print(0)\n print(1,1)\nelse:\n best = -1\n bestVal = -1\n for i in range(n):\n for j in range(n):\n if seq[i] != seq[j]:\n swapseq = list(seq)\n swapseq[i] = seq[j]\n swapseq[j] = seq[i]\n swapseq = rectify(swapseq)\n depth = components = 0\n for x in range(n):\n if swapseq[x] == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth == 0:\n components += 1\n if bestVal == -1 or components > bestVal:\n best = (i,j)\n bestVal = components\n print(bestVal)\n print(best[0],best[1])\n"}, {"source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import stdin, setrecursionlimit\nsetrecursionlimit(10**7)\n\n\ndef iin(): return int(stdin.readline())\n \n \ndef lin(): return list(map(int, stdin.readline().split()))\n\n\n# range = xrange\n# input = raw_input\n\ndef bcheck(a,l,r):\n if a[l]==a[r]:return -1\n a1=a[:]\n a1[l],a1[r]=a1[r],a1[l]\n N=len(a)\n p,n=[],[]\n for i in range(N):\n if a1[i]==')':\n if p:\n p.pop()\n else:\n n.append(i)\n else:\n p.append(i)\n l=len(p)\n rt=0\n if l>0:\n rt=n[-1]+1\n if rt:\n a1=a1[rt:]+a1[:rt]\n ch,pt=0,0\n for i in a1:\n if i=='(':\n pt+=1\n else:\n pt-=1\n if pt==0:ch+=1\n #print(a1,ch)\n \n return ch\n\ndef main():\n N=iin()\n a=list(input())\n c1,c2=a.count(')'),a.count('(')\n if c1!=c2 or N%2:\n print(0)\n print(1,1)\n else:\n mx=[-1,0,0]\n # print(a)\n for i in range(N):\n for j in range(i+1,N):\n if a[i]!=a[j]:\n val=bcheck(a,i,j)\n if mx[0]<val:\n mx=[val,i,j]\n # print(a)\n print(mx[0])\n print(mx[1]+1,mx[2]+1)\n\n \n\n \n\n\n\n\n\n\n\n\nmain()\n# try:\n# main()\n# except Exception as e: print(e)"}, {"source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import stdin, setrecursionlimit\nsetrecursionlimit(10**7)\n\n\ndef iin(): return int(stdin.readline())\n \n \ndef lin(): return list(map(int, stdin.readline().split()))\n\n\n# range = xrange\n# input = raw_input\n\ndef bcheck(a,l,r):\n if a[l]==a[r]:return -1\n a[l],a[r]=a[r],a[l]\n N=len(a)\n p,n=[],[]\n for i in range(N):\n if a[i]==')':\n if p:\n p.pop()\n else:\n n.append(i)\n else:\n p.append(i)\n l=len(p)\n rt=0\n if l>0:\n rt=n[-1]+1\n if rt:\n a=a[rt:]+a[:rt]\n ch,pt=0,0\n for i in a:\n if i=='(':\n pt+=1\n else:\n pt-=1\n if pt==0:ch+=1\n rt=N-rt\n a=a[rt:]+a[:rt]\n #print(a,ch)\n\n a[l],a[r]=a[r],a[l]\n return ch\n\ndef main():\n N=iin()\n a=list(input())\n c1,c2=a.count(')'),a.count('(')\n if c1!=c2 or N%2:\n print(0)\n print(1,1)\n else:\n mx=[-1,0,0]\n for i in range(N):\n for j in range(i+1,N):\n if a[i]!=a[j]:\n val=bcheck(a,i,j)\n if mx[0]<val:\n mx=[val,i,j]\n print(mx[0])\n print(mx[1]+1,mx[2]+1)\n\n \n\n \n\n\n\n\n\n\n\n\nmain()\n# try:\n# main()\n# except Exception as e: print(e)"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\n#lines = stdin.readlines()\ndef rint():\n return map(int, sys.stdin.readline().split())\n\ndef input():\n return sys.stdin.readline().rstrip('\\n')\n\ndef oint():\n return int(input())\n\n\nn = oint()\nstemp = input()\ns = []\nfor i in range(n):\n if stemp[i] == '(':\n s.append(1)\n else:\n s.append(-1)\n\nmaxcnt = 0\ncandi = [0, 0]\nfor l in range(n):\n for r in range(l, n):\n cnt = 0\n s[l], s[r] = s[r], s[l]\n ssum = [0]*n\n ssum[0] = s[0]\n for i in range(1, n):\n ssum[i] = ssum[i-1] + s[i]\n\n minssum = min(ssum)\n if ssum[n-1] != 0:\n continue\n\n for i in range(1, n):\n if ssum[i] == minssum:\n cnt += 1\n if maxcnt < cnt:\n candi = [r, l]\n maxcnt = cnt\n s[l], s[r] = s[r], s[l]\nprint(maxcnt)\nprint(candi[0]+1, candi[1]+1)\n"}], "src_uid": "2d10668fcc2d8e90e102b043f5e0578d"} {"source_code": "k,a,b,v = map(int,input().split())\n\nans = 0\n\nwhile(a>0 and b>0):\n ans += 1\n n = min(k,b+1)\n a = a - n*v\n b = b - (n-1)\n\nwhile(a>0):\n ans += 1\n a -= v\n\nprint(ans)\n\n\n\n\n\n\n# maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box.\n", "positive_code": [{"source_code": "def floor(x):\n if (x == int(x)):\n return int(x)\n else:\n return int(x) + 1\na = input()\na = list(a.split(' '))\na = list(map(int,a))\nts = floor(a[1] / a[3])\ntb = 0\n#print(ts)\ntb += a[2] // (a[0] - 1)\nts -= tb * a[0]\na[2] -= tb * (a[0] - 1)\n#print(ts)\nif (ts <= 0):\n ts += tb * a[0]\n #print(ts)\n print(floor(a[1] / (a[0] * a[3])))\nelse:\n tb += 1\n ts -= a[2] + 1\n if (ts <= 0):\n print(int(tb))\n else:\n tb += ts\n print(int(tb))\n \n"}, {"source_code": "k, a, b, v = list(map(int, input().split()))\nx = 0\nwhile a > 0:\n c = 1\n if b > k-1:\n c += k-1\n b -= k-1\n else:\n c += b\n b = 0\n a -= v*c\n x += 1\nprint(str(x))"}, {"source_code": "k, a, b, v = map(int, input().split())\nval = 0\nwhile a > 0:\n d = min(b, k - 1)\n a -= (d + 1) * v\n b -= d\n val += 1\nprint(val)"}, {"source_code": "#!/usr/bin/python\nimport re\nimport inspect\nfrom sys import argv, exit\nfrom math import ceil\n\ndef rstr():\n return input()\n\ndef rstrs(splitchar=' '):\n return [i for i in input().split(splitchar)]\n\ndef rint():\n return int(input())\n\ndef rints(splitchar=' '):\n return [int(i) for i in rstrs(splitchar)]\n\ndef varnames(obj, namespace=globals()):\n return [name for name in namespace if namespace[name] is obj]\n\ndef pvar(var, override=False):\n prnt(varnames(var), var)\n\ndef prnt(*args, override=False):\n if '-v' in argv or override:\n print(*args)\n\n# Faster IO\npq = []\ndef penq(s):\n if not isinstance(s, str):\n s = str(s)\n pq.append(s)\n\ndef pdump():\n s = ('\\n'.join(pq)).encode()\n os.write(1, s)\n\nif __name__ == '__main__':\n sec_per_box, nuts, divs, cap = rints()\n prnt('secs/box:', sec_per_box, 'nuts', nuts, 'divs', divs, 'cap', cap)\n\n total_secs_needed = ceil(nuts / cap)\n prnt('total_secs_needed', total_secs_needed)\n if total_secs_needed < sec_per_box:\n ans = 1\n if divs < (sec_per_box - 1):\n total_secs_needed -= 1 + divs\n if total_secs_needed > 0:\n ans += total_secs_needed\n print(ans)\n exit(0)\n\n fdb = divs // (sec_per_box - 1)\n prnt('fdb', fdb)\n\n if fdb*sec_per_box > total_secs_needed:\n prnt('top')\n ans = ceil(total_secs_needed / sec_per_box)\n print(ans)\n else:\n prnt('bot')\n nuts -= fdb*sec_per_box*cap\n total_secs_needed -= fdb*sec_per_box\n divs -= fdb*(sec_per_box -1)\n ans = fdb\n if divs:\n prnt('if divs')\n ans += 1\n nuts -= (divs+1) * cap\n prnt('nuts, cap: ', nuts, cap)\n if nuts > 0:\n ans += ceil(nuts / cap)\n print(ans)\n"}, {"source_code": "k, a, b, v = map(int, input().split())\nresult = 1\nx = 1\nwhile a > 0:\n if b > 0:\n if x < k:\n b -= 1\n x += 1\n a -= v\n else:\n a -= v\n if a > 0:\n result += 1\n x = 1\n else:\n a -= v\n if a > 0:\n result += 1\nprint(result)"}, {"source_code": "k, a, b, v = map(int, input().split())\nans = 0\nwhile a > 0:\n ans += 1\n a -= min(k, b + 1) * v\n b -= min(k - 1, b)\nprint(ans)"}, {"source_code": "k, a, b, v = map(int, input().split())\nfor i in range(1, 1010):\n if a <= v * (i + min(b, (k - 1) * i)):\n print(i)\n break"}, {"source_code": "k, a, b, v = list(map(int, input().split()))\nx = 0\nwhile a > 0:\n c = 1\n if b > k-1:\n c += k-1\n b -= k-1\n else:\n c += b\n b = 0\n a -= v*c\n x += 1\nprint(str(x))"}, {"source_code": "k,a,b,v=map(int,input().split())\nans=0\nwhile a>0:\n ans+=1\n kn=min(k,b+1)\n a-=v*kn\n b=max(b-k+1,0)\nprint(ans)"}, {"source_code": "from math import ceil\n\nDiv_,Nuts_,Sec_,Nut_Cap_ = map(int,input().split())\n\nBoxes_ = Sec_//(Div_-1)\nRemaining_ = Sec_%(Div_-1)\n\nif Remaining_:\n\tTotal_capcaity = Boxes_*Div_*Nut_Cap_ + (Remaining_+1)*Nut_Cap_\nelse:\n\tTotal_capcaity = Boxes_*Div_*Nut_Cap_\n\nif Nuts_ >= Total_capcaity:\n\tNuts_ = Nuts_ - Total_capcaity\n\tif Remaining_:\n\t\tans = Boxes_ + 1\n\telse:\n\t\tans = Boxes_\n\tans = ans + ceil(Nuts_/Nut_Cap_)\nelif Nuts_ > Boxes_*Div_*Nut_Cap_:\n\tans = Boxes_ + 1\nelse:\n\tans = ceil(Nuts_/(Div_*Nut_Cap_))\n\nprint(ans)\n"}, {"source_code": "import math\nk,a,b,v=map(int,input().split())\n#3 10 3 3\nif(v>a):\n print(1)\nelse:\n if b+1<k:\n \ta=a-v*(b+1)\n \tans=math.ceil(a/v)\n \tprint(ans+1)\n else:\n \t\n c=1\n a=a-(v*k)#694\n b=b-k+1#4\n #print(\"initial a=\",a,\"b=\",b,\"k=\",k)\n while(a>0 and b>0):\n\t if v*(b+1)>a and b<k:\n\t #print(\"in 1st if\")\n\t c+=1\n\t a=0\n\t break\n\t else:\n\t if b>k:\n\t if(v>a):\n\t c+=1\n\t a=0\n\t else:\n\t a=a-(v*(k))#\n\t c+=1#\n\t b=b-(k-1)#\n\t #print(\"in b>k a=\",a,\"b=\",b,\"c=\",c)\n\t if(b<=k):\n\t a=a-v*(b+1) #\n\t c+=1#\n\t \n\t b=0\n\t #print(\"in b<k a=\",a,\"b=\",b,\"c=\",c)\n\t #if(b==k):\n\t \n\t \n if(b==0 and a>0):\n c+=math.ceil(a/v)\n print(c)\n "}, {"source_code": "import math\nk,a,b,v=map(int,input().split())\nans=0\nwhile(a>0):\n m=min(k,b+1)\n a-=m*v\n b-=(m-1)\n ans+=1\nprint(ans)"}, {"source_code": "mxd,n,d,ns=map(int,input().split(' '))\nres=0\nwhile(n>0):\n for i in range(mxd,-1,-1):\n if(i<=d and i<mxd):\n res+=1\n n-=ns*(i+1)\n if(d>0):\n d-=i\n break\nprint(res)"}, {"source_code": "k, a, b, v = map(int, input().split(' '))\nc, i = 1, 1\nwhile a - v > 0:\n a -= v\n if i < k and b > 0:\n i += 1\n b -= 1\n else:\n i = 1\n c += 1\nprint(c)\n"}, {"source_code": "max_section, nuts, divisor, capacity = map(int, input().split()) # max section , nuts, divisor , capacity\ndef lt(x):\n if x - int(x) > 0:\n return int(x) + 1\n return int(x)\nmax_divisor = max_section - 1\nbox_max_section = int(divisor/max_divisor)\nextra_box_capacity = (divisor%max_divisor + 1)*capacity\nif nuts > box_max_section*capacity*max_section:\n rs = box_max_section\n nuts -= box_max_section*max_section*capacity\n if nuts > extra_box_capacity:\n rs += 1 + lt((nuts-extra_box_capacity)/capacity)\n else:\n rs +=1\nelse:\n rs = lt(nuts/(max_section*capacity))\nprint(rs)"}, {"source_code": "k , a , b , v = map( int , input( ).split( ) )\ns = 0\nwhile a > 0 :\n a -= min( k , b + 1 ) * v\n b -= min( k - 1 , b )\n s += 1\nprint( s )"}, {"source_code": "R = lambda :map(int,input().split())\nk,a,b,v= R()\na1 = b//(k-1);a2 = b%(k-1)\n#print(a1,a2)\nif a<=v*(a1)*k:\n print((a+(v*k-1))//(v*k))\nelif v*(a1)*k<a<=(v*a1*k+(a2+1)*v):\n print(a1+1)\nelse:\n print(a1+1+((a-v*a1*k-(a2+1)*v)+v-1)//v)\n\n\n"}, {"source_code": "#!/usr/bin/env python3\n\ndef read_ints():\n\treturn map(int, input().strip().split())\n\nk, a, b, v = read_ints()\n\nz = (a + v-1) //v\n\nused_boxes = 0\nfree_div = b\nlast_box_sec = float('inf')\n\nwhile z:\n\tif last_box_sec < k and free_div > 0:\n\t\tlast_box_sec += 1\n\t\tfree_div -= 1\n\n\telse:\n\t\tused_boxes += 1\n\t\tlast_box_sec = 1\n\n\tz -= 1\n\nprint(used_boxes)\n\t\t\n\t\n"}, {"source_code": "x = input()\nmax_sections, nuts, divisors, max_nuts = [int(i) for i in x.split()]\n\ndivisors_per = max_sections - 1\nfit = max_sections * max_nuts\n\nboxes = 1\nwhile 1:\n if divisors_per > divisors:\n sections = divisors + 1\n nuts -= sections * max_nuts\n divisors = 0\n else:\n nuts -= fit\n divisors -= divisors_per\n \n if nuts <= 0: break\n else: boxes += 1\n\nprint(boxes)\n \n"}, {"source_code": "k, a, b, v = map(int, input().split())\nx = 0\n\nwhile a > 0:\n x += 1\n a -= v * min(b+1, k)\n b -= min(b, k-1)\n\nprint(x)"}, {"source_code": "from math import ceil\nk, a, b, v = [int(i) for i in input().split()]\n\nprint(max(ceil((a/v) - b), ceil(a/(k*v))))\n"}, {"source_code": "def ceiling_div(x, y):\n\tres = x // y\n\tif (x % y != 0):\n\t\tres += 1\n\treturn res\n\t\nk, a, b, v = map(int, input().split())\nsec = ceiling_div(a, v)\nres = max(sec - b, ceiling_div(sec, k))\nprint(res)\n"}, {"source_code": "k, a, b, v = map(int, input().split())\nprint((a - 1) // v + 1 - b if v * (b + 1 + b // (k - 1)) < a else (a - 1) // (v * k) + 1)"}, {"source_code": "k, a, b, v = map(int, input().split())\nc = b // (k - 1)\nt = c * k * v + (b - c * (k - 1) + 1) * v\nif t < a: print(c + 2 + (a - t - 1) // v)\nelse: print((a - 1) // (k * v) + 1)"}, {"source_code": "k,a,b,v=map(int,raw_input().split())\nfrom math import *\ns=ceil(a*1.0/v)\nans=0\n\nwhile a>0 and k<=b+1:\n a=a-(k)*v\n ans=ans+1\n b=b-(k-1)\n #print a,b,ans\n\nif a>0 and k>b+1:\n a=a-(b+1)*v\n ans=ans+1\n#print a,ans\nif a>0:\n print int(ans+ceil(a*1.0/v))\nelse:\n print int(ans)"}, {"source_code": "k,a,b,v=map(int,input().split());o=0\nwhile(a>0):\n o+=1;a-=v*min(b+1,k);b-=min(b,k-1)\nprint(o)\n\n"}, {"source_code": "k,a,b,v=map(int,input().split());o=0\nwhile(a>0):\n o+=1;a-=v*min(b+1,k);b-=min(b,k-1)\nprint(o)\n\n"}, {"source_code": "k,a,b,v=map(int,input().split())\nl=[]\nwhile(b>0):\n\tif(b>=k):\n\t\tb1=k-1\n\t\tl.append((b1+1)*v)\n\t\tb=b-b1\n\telse:\n\t\tl.append((b+1)*v)\n\t\tb=0\ntb=0\ns=0\nfor i in range(len(l)):\n\ta=a-l[i]\n\ttb=tb+1\n\tif(a<=0):\n\t\tbreak\nif(a>0):\n\twhile(a>0):\n\t\ta=a-v\n\t\ttb=tb+1\nprint(tb)"}, {"source_code": "# Made By Mostafa_Khaled \nbot = True \nfrom math import ceil\n\nk, a, b, v = [int(i) for i in input().split()]\n\n\n\nprint(max(ceil((a/v) - b), ceil(a/(k*v))))\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "k,a,b,v=map(int,input().split());o=0\nwhile(a>0):\n o+=1;a-=v*min(b+1,k);b-=min(b,k-1)\nprint(o)\n\n"}, {"source_code": "k,a,b,v = map(int, input().split())\nansw = 0\nwhile a != 0 and b != 0:\n a -= min(v*min(k,b+1),a)\n b -= min(k-1,b)\n answ+=1\nansw += a//v + int(a%v != 0)\nprint(answ)"}, {"source_code": "from sys import stdin,stdout\nfrom collections import Counter\ndef ai(): return list(map(int, stdin.readline().split()))\ndef ei(): return map(int, stdin.readline().split())\ndef ip(): return int(stdin.readline().strip())\ndef op(ans): return stdout.write(str(ans) + '\\n') \n\nk,a,b,v = ei()\nfor i in range(1,2000):\n\tt = min(k,b+1)\n\ta -= t*v\n\tb -= t-1\n\tif a <=0:\n\t\tprint(i)\n\t\tbreak\n #'''k-sec,a-nuts,b-divisor,v-capicity'''"}, {"source_code": "k,a,b,v=map(int,input().split())\nbox=0\nrem=a\nwhile rem>0:\n box+=1\n comp=0\n if (b>k-1):\n comp=k\n b-=k-1\n else:\n comp=b+1\n b=0\n rem-=v*comp\nprint (box)"}, {"source_code": "k,a,b,v=map(int,input().split());o=0\nwhile(a>0):\n o+=1;a-=v*min(b+1,k);b-=min(b,k-1)\nprint(o)\n"}, {"source_code": "k,a,b,v=map(int,input().split());o=0\nwhile(a>0):\n o+=1;a-=v*min(b+1,k);b-=min(b,k-1)\nprint(o)\n\n"}, {"source_code": "#-------------------------------------------------------------------------------\n# Name: module1\n# Purpose:\n#\n# Author: mayank manish\n#\n# Created:\n# Copyright: (c) mayank manish\n# Licence: <your licence>\n#-------------------------------------------------------------------------------\n\ndef main():\n pass\n\nif __name__ == '__main__':\n main()\nk,a,b,v=map(int, input().split())\nn=0\nif(b<k):\n a-=((b+1)*v)\n n+=1\n while(a>0):\n a-=v\n n+=1\n print(n)\nelse:\n while((b>=k) and (a>0)):\n b-=(k-1)\n a-=(k*v)\n n+=1\n if(a>0):\n a-=((b+1)*v)\n n+=1\n while(a>0):\n a-=v\n n+=1\n print(n)\n"}, {"source_code": "max_section, nuts, divisor, capacity = map(int, input().split()) # max section , nuts, divisor , capacity\ndef lt(x):\n if x - int(x) > 0:\n return int(x) + 1\n return int(x)\nmax_divisor = max_section - 1\nbox_max_section = int(divisor/max_divisor)\nextra_box_capacity = (divisor%max_divisor + 1)*capacity\nif nuts > box_max_section*capacity*max_section:\n rs = box_max_section\n nuts -= box_max_section*max_section*capacity\n if nuts > extra_box_capacity:\n rs += 1 + lt((nuts-extra_box_capacity)/capacity)\n else:\n rs +=1\nelse:\n rs = lt(nuts/(max_section*capacity))\nprint(rs)"}, {"source_code": "In=lambda:map(int,raw_input().split())\n\nmax_sections, nuts, divisors, nuts_per_sections = In()\n\nboxes = 0\n\nwhile nuts > 0:\n\tboxes += 1\n\tdivs = min(max_sections-1,divisors)\n\tdivisors -= divs\n\tnuts -= (divs+1)*nuts_per_sections\n\nprint boxes"}, {"source_code": "def main():\n k, a, b, v = map(int, input().split())\n res = (b + k - 2) // (k - 1)\n o = b + res\n if o * v < a:\n res += (a + v - 1) // v - o\n else:\n res = (a + k * v - 1) // (k * v)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n\n\n\n"}, {"source_code": "from math import ceil\n\nk, a, b, v = list(map(int, input().split()))\nBox = 0\nwhile a:\n Section = min(b, k - 1) + 1\n b -= Section - 1\n Total = min(v, ceil((a) / Section))\n a -= min(a , Total * Section)\n Box += 1\nprint(Box)\n"}, {"source_code": "string=str(input())+' '\nword=''\nwordlist=[]\nboxes=0\n\nfor char in string:\n if char!=' ':\n word+=char\n else:\n wordlist.append(int(word))\n word=''\n\nmaxsections=wordlist[0]\nnuts=wordlist[1]\ndivisors=wordlist[2]\nmaxnuts=wordlist[3]\n\nwhile nuts>0:\n boxes+=1\n \n if divisors>=maxsections-1:\n divisors-=maxsections-1\n if nuts>=maxsections*maxnuts:\n nuts-=maxsections*maxnuts\n elif nuts<maxsections*maxnuts:\n nuts=0\n\n elif divisors<maxsections-1:\n if nuts>=(divisors+1)*maxnuts:\n nuts-=(divisors+1)*maxnuts\n elif nuts<(divisors+1)*maxnuts:\n nuts=0\n divisors=0\n\nprint(boxes)\n"}, {"source_code": "k, a, b, v=map(int,raw_input().split())\nfor r in range(a):\n if (r + min(b,(k-1)*r))*v >= a:\n print r\n exit(0)"}, {"source_code": "sections,nuts,divisors,cap = map(int,input().split())\nboxes=0\nwhile(nuts > 0):\n s = 1\n if(divisors > 0 and divisors <= sections -1):\n s = divisors + 1\n divisors = 0\n elif divisors > sections -1:\n s = sections\n divisors -= (sections -1)\n nuts -= (s*cap)\n boxes+=1\nprint(boxes)\n"}, {"source_code": "l=[int(i) for i in input().split(\" \")]\nk=l[0]\na=l[1]\nb=l[2]\nv=l[3]\nbox=0\ndivs=0\nwhile a>0:\n box+=1\n sections=1\n a-=v\n while a>0 and sections<k and divs<b:\n divs+=1\n sections+=1\n a-=v\nprint(box)"}, {"source_code": "from math import ceil\n\nk, a, b, v = list(map(int,input().split(\" \")))\n\np = ceil(a/v)\n\ncajas = 0\ndcaja = k-1\ndivs = b\n\nfor i in range(p):\n if dcaja == k-1 or divs == 0:\n cajas += 1\n dcaja = 0\n else:\n dcaja += 1\n divs -= 1\n \n \n\nprint(cajas)"}, {"source_code": "import sys\n\nif __name__ == \"__main__\":\n line = sys.stdin.readline()\n items = line.split()\n k = int(items[0])\n a = int(items[1])\n b = int(items[2])\n v = int(items[3])\n box = 0\n\n while b >= k-1 and a > 0:\n box += 1\n a -= k * v\n b -= k-1\n\n if a <= 0:\n print box\n else:\n if a % v == 0:\n sec_need = a / v\n else:\n sec_need = a / v + 1\n\n if sec_need > b+1:\n box += 1 + sec_need - (b+1)\n else:\n box += 1\n print box\n \n\n \n"}, {"source_code": "def solve():\n k, a, b, v = list(map(int, raw_input().split(\" \")))\n nuts, divs, r = a, b, 0\n while nuts > 0:\n ud = min(divs, k-1)\n divs -= ud\n nuts -= (ud+1)*v\n r+=1\n print r\n\n# invoke solve\nsolve()"}, {"source_code": "from math import *\n\ndef main():\n s = str(raw_input()).split(\" \")\n k = int(s[0])\n a = int(s[1])\n b = int(s[2])\n v = int(s[3])\n\n x = b\n left = a\n\n ans = 0\n\n while(True):\n\n sections = min(k, x + 1)\n\n x -= sections - 1\n put = sections * v\n\n left = left - put\n ans += 1\n if(left > 0):\n continue\n else:\n break\n\n print ans\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\nimport math\n\ninp = sys.stdin.readline().rstrip('\\n').split(' ')\nk = int(inp[0]) # sections in a box\na = int(inp[1]) # # of nuts\nb = int(inp[2]) # # of divisors\nv = int(inp[3]) # capacity of each section.\n\nboxNum = 0\n\nwhile (a > 0):\n\tboxNum += 1\n\tboxSection = 1\n\twhile (boxSection < k and b > 0):\n\t\tboxSection += 1\n\t\tb -= 1\n\t# subtract nuts\n\tif (a/boxSection <= 1):\n\t\ta = 0\n\telse:\n\t\ta -= boxSection*v\n\nprint boxNum\n"}, {"source_code": "\nk, a, b, v = [int(_) for _ in raw_input().split()]\n\n\nans = 1\n\nwhile True:\n cnt = ans + (min((k-1)*ans, b))\n if cnt * v >= a:\n print ans\n break\n ans += 1\n"}, {"source_code": "from itertools import takewhile\n\nk, a, b, v = map(int, raw_input().split())\n\ndef boxes(k, b):\n\n while b >= k - 1:\n yield k\n b -= k - 1\n \n if b:\n yield b + 1\n \n while True:\n yield 1\n \ndef pack(x, k, b):\n c = 0\n t = 0\n b = boxes(k, b)\n while t < x:\n t += next(b)\n c += 1\n return c\n \nprint pack((a + v - 1) // v, k, b)"}, {"source_code": "k,a,b,v = map(int, raw_input().split())\nbox = 0\ncnt = 0\nwhile cnt < a:\n if b == 0:\n cnt = cnt + v\n box = box + 1\n else:\n if b <= k-1 :\n cnt = cnt + (b+1)* v\n b = 0\n box = box + 1\n else:\n b = b - (k-1)\n cnt = cnt + k * v\n box = box + 1\nprint box"}, {"source_code": "k, a, b, v=map(int, raw_input().split())\ni=1\nans=0\nwhile ans==0:\n cnt=i+min((k-1)*i, b)\n if (cnt*v)>=a:\n ans=i\n i=i+1\nprint ans\n"}, {"source_code": "#!/usr/bin/python\n\n#input section\ndef takeInput():\n a = [int(x) for x in raw_input().split(' ')]\n return a\n\n#logic section\na = takeInput()\nK = a[0]\nA = a[1]\nB = a[2]\nV = a[3]\n\n#to monitor the answer(ans)\nnutsRemaining = 0\nans = 0\n\nwhile nutsRemaining < A:\n tempMin = min(K,B + 1)\n nutsRemaining += tempMin * V\n B -= tempMin - 1\n ans += 1\nprint ans\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\nsec,n,di,v=l()\nboxes=0\nif di>=sec-1:\n boxes=di/(sec-1)\nif n%v==0:\n needsec=n/v\nelse:\n needsec=n/v+1\ncnt=0\ni=1\nwhile i<=boxes:\n cnt+=sec\n if cnt>=needsec:\n print i\n exit()\n i+=1 \nr=n\nif boxes>0:\n r=n-boxes*sec*v\nrdi=di%(sec-1)\nif rdi==0:\n print boxes + [r/v+1,r/v][r%v==0]\nelse:\n if r<=(rdi+1)*v:\n print boxes+1\n else:\n r=r-(rdi+1)*v\n boxes+=1\n print boxes + [r/v+1,r/v][r%v==0]"}, {"source_code": "I=lambda:map(int, raw_input().split())\nk, a, b, v = I()\nfull, half = b / (k-1), b % (k-1)\nx = full * v * k\n#print full, half\nif x >= a:\n print (a + v * k - 1) / (v * k)\nelse:\n if a - x <= (half + 1)*v:\n print full + 1\n else:\n print full + 1 + (a - x - (half + 1) * v + v - 1)/ v \n"}, {"source_code": "import sys\nimport math\n\nline = sys.stdin.readline()\nz = line.split()\nk = int(z[0])\na = int(z[1])\nb = int(z[2])\nv = int(z[3])\n\nnumBoxes = 1\nnumSections = 1\na = a-v\nwhile(a > 0):\n if(numSections == k):\n numBoxes +=1\n numSections = 1\n a = a-v\n elif b==0:\n numBoxes +=1\n numSections = 1\n a = a-v\n else:\n numSections +=1\n b -= 1\n a = a-v\nprint numBoxes\n \n\n\n##if(a < v*(b+1)):\n## print int(math.ceil(float(a)/float(k*v)))\n##else:\n## n = int(math.ceil(float(a)/float(k*v)))\n## n1 = int(math.ceil(float(a - v*(b+1))/float(v)))\n## print n + n1\n##\n## \n"}, {"source_code": "def main():\n k, a, b, v = map(int, raw_input().split())\n counter = 0\n while a > 0:\n if b > k - 1:\n a -= k * v\n b -= k - 1\n else:\n a -= (b + 1) * v\n b = 0\n counter += 1\n print counter\n \nif __name__ == '__main__':\n main()"}, {"source_code": "k, a, b, v = map(int, raw_input().split())\np = 0\nwhile a>0:\n if b>=k:\n a = a - (k*v)\n b = b - (k-1)\n elif b>0:\n a = a - (b+1)*v\n b = 0\n else:\n a = a - v\n p = p + 1\nprint p"}, {"source_code": "k, a, b, v=map(int, raw_input().split())\nmaxdiv=k-1\nboxes=0\nwhile b>=maxdiv and a>0:\n a-=v*k\n b-=maxdiv\n boxes+=1\nif a>0:\n if b<maxdiv:\n a-=v*(b+1)\n boxes+=1\n while a>0:\n a-=v\n boxes+=1\nprint boxes\n"}, {"source_code": "#!/usr/bin/env python\n# encoding: utf-8\nk,a,b,v = map(int,raw_input().split())\n\nans = 0\n\nwhile a > 0 :\n y = min(k-1,b)\n b -= y\n a -= (y+1)*v\n ans += 1\n\nprint ans\n\n"}, {"source_code": "k,a,b,v=map(int,raw_input().split())\ncount=0\nwhile(1):\n\tif(b>=k):\n\t\tb-=(k-1)\n\t\ta-=v*(k)\n\n\t\tif(a>0):\n\t\t\tcount+=1\n\t\t\tcontinue\n\t\telse:\n\t\t\tcount+=1\n\t\t\tbreak\n\telif(b!=0):\n\t\ta-=v*(b+1)\n\t\tb=0\n\t\tif(a>0):\n\t\t\tcount+=1\n\t\t\tcontinue\n\t\telse:\n\t\t\tcount+=1\n\t\t\tbreak\n\telse:\n\t\tif(a>0):\n\t\t\tcount+=1\n\t\t\ta-=v\n\t\telse:\n\t\t\tbreak\n\n\n#count+=1\nprint count\n"}, {"source_code": "k, a, b, v = map(int, raw_input().split())\ndem = 0\nwhile a>0:\n dem += 1\n if b >= k-1:\n b -= (k-1)\n d = k\n else:\n d = b+1\n b = 0\n a -= d*v\nprint dem\n"}, {"source_code": "k,a,b,v = map(int,raw_input().split())\nq = b // (k-1)\nr = b % (k-1)\nif a <= q*k*v:\n res = a // (k*v)\n if a % (k*v) >0:\n res += 1\nelse:\n a -= q*k*v\n res = q\n if a <= (r + 1) * v:\n res = q+1\n else:\n a -= (r + 1) * v\n res += 1\n s = a // v\n res += s\n if a % v > 0:\n res += 1\nprint res\n"}, {"source_code": "[k, a, b, v] = map(int, raw_input().split())\nc = b / (k - 1)\nif a <= c * k * v:\n print (a - 1) / (k * v) + 1\nelse:\n a = a - c * k * v\n b = b - (k - 1) * c\n if a <= (b + 1) * v:\n print c + 1\n else:\n a = a - (b + 1) * v\n print c + 2 + (a - 1) / v"}, {"source_code": "k, a, b, v = map(int, raw_input().split())\ncnt = 0\nwhile a > 0:\n\tsection = 1\n\tif b >= k-1:\n\t\tsection = k\n\t\tb -= (k - 1)\n\telse:\n\t\tsection = b + 1\n\t\tb = 0\n\ta -= (v * section)\n\tcnt += 1\nprint cnt"}, {"source_code": "k, a, b, v = map(int, raw_input().split())\n\nnut_piles = a / v if not a % v else a / v + 1\n\nbox_number = 1\nbox_sections = 1\nbox_filled = 0\n\nwhile nut_piles:\n\tif box_filled < box_sections:\n\t\tbox_filled += 1\n\telif box_sections < k and b > 0:\n\t\tbox_sections += 1\n\t\tbox_filled += 1\n\t\tb -= 1\n\telse:\n\t\tbox_number += 1\n\t\tbox_sections = 1\n\t\tbox_filled = 1\n\tnut_piles -= 1\nprint box_number\n\t\n\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# Jonathan Prieto - d555\n\nimport sys\n\n# sys.stdin = open(\"inputA.txt\", \"r\")\n# sys.stdout = open(\"out.txt\", \"w\")\n\ndef solve(k,a,b,v):\n av = (a + v - 1) / v\n if b is 0 or av <= b+1:\n return (av + k - 1)/k\n if b + 1 <= k:\n a = a - (b+1)*v\n return 1 + (a + v - 1)/v\n\n c = b / (k-1)\n a = a - c*v*k\n b = b - c*(k-1)\n if a > 0:\n c = c + 1\n a = a - (b+1)*v\n c = c+ (a + v -1)/v\n return c\n return c\n\n\nfor i in sys.stdin:\n k,a,b,v = map(int, i.split())\n print solve(k,a,b,v)"}, {"source_code": "k, a, b, v = map(int, raw_input().split())\n\nq = b / (k-1)\nr = b % (k-1)\n\ni = 0\nwhile a > 0:\n m = min(k-1, b)\n b = max(0, b-m)\n a -= (m+1)*v\n i += 1\nprint i "}, {"source_code": "import sys,math\n\nmaxsec,noten,planken,notsec=map(int,raw_input().split())\n\ndozen=min(noten/(notsec*maxsec),planken/(maxsec-1))\nnoten-=dozen*notsec*maxsec\nplanken-=dozen*(maxsec-1)\n\nsec=noten/notsec+int(noten%notsec>0)\nif sec>=planken+1:\n dozen+=1\n noten-=(planken+1)*notsec\n if noten>0:\n dozen+=noten/notsec+int(noten%notsec>0)\nelse:\n if sec>0:\n dozen+=1\n \n \n\n \n\nprint dozen\n "}, {"source_code": "k,a,b,v = [int(x) for x in raw_input().split()]\nans = 0\nwhile a > 0:\n if b+1>=k:\n a -= k*v\n b -= k-1\n ans += 1\n elif b == 0:\n a -= v\n ans += 1\n elif b +1<k:\n a -= (b+1)*v\n b = 0\n ans +=1\nprint ans"}, {"source_code": "def main():\n k,a,b,v = [int(c) for c in raw_input().split()]\n count = 1\n sections = 1\n while a>0:\n a -= v\n if a<= 0:\n break\n if sections < k and b>0:\n sections += 1\n b -= 1\n else:\n count += 1\n sections = 1\n return count\n \n\nif __name__ == \"__main__\":\n print main()\n"}], "negative_code": [{"source_code": "k,a,b,v=map(int,raw_input().split())\nfrom math import *\ns=ceil(a*1.0/v)\nans=0\n\nwhile a>=0 and k<=b+1:\n a=a-(k)*v\n ans=ans+1\n b=b-(k-1)\n #print a,b,ans\n\nif a>0 and k>b+1:\n a=a-(b+1)*v\n ans=ans+1\n#print a,ans\nif a>0:\n print int(ans+ceil(a*1.0/v))\nelse:\n print int(ans)"}, {"source_code": "k,a,b,v=map(int,raw_input().split())\nfrom math import *\ns=ceil(a*1.0/v)\nans=0\n\nwhile a>=0 and k<=b+1:\n a=a-(k)*v\n ans=ans+1\n b=b-(k)\n #print a,b,ans\n\nif k>b+1:\n a=a-(b+1)*v\n ans=ans+1\n#print a,ans\nif a>0:\n print int(ans+ceil(a*1.0/v))\nelse:\n print int(ans)"}, {"source_code": "from math import ceil\nk, a, b, v = map(int, input().split())\nx = b // (k - 1)\nost = b % (k - 1)\nn = v * k\nif x * n >= a:\n print(ceil(a / (x * n)))\nelse:\n d = x\n a -= x * n\n if (ost + 1) * v >= a:\n print(d + 1)\n else:\n d += 1\n a -= (ost + 1) * v\n print(d + ceil(a / v))"}, {"source_code": "import math\n\nk,a,b,v = map(int,input().split())\n\n\n\nif b >= k-1:\n #print(b,k-1)\n #print(((b//(k-1))*k)*v,(b%(k-1)+1)*v)\n total = ((b//(k-1))*k)*v + (b%(k-1)+1)*v\nelse:\n total = (b+1)*v\n\n\n \nif a >= total:\n g = math.ceil((b+1)/k) + math.ceil((a-total)/v)\nelse:\n re = math.ceil(a/v)\n g = math.ceil(re/k)\n\nprint(g)\n"}, {"source_code": "import math\n\nk,a,b,v = map(int,input().split())\n\n\n\ntotal = (b+1)*v\n\nif a >= total:\n\n g = math.ceil((b+1)/k) + math.ceil((a-total)/v)\nelse:\n\n re = math.ceil(a/v)\n\n g = math.ceil(re/k)\n\nprint(g)\n"}, {"source_code": "def floor(x):\n if (x == int(x)):\n return x\n else:\n return int(x) + 1\na = input()\na = list(a.split(' '))\na = list(map(int,a))\nts = floor(a[1] / a[3])\ntb = 0\n#print(ts)\ntb += a[2] // (a[0] - 1)\nts -= tb * a[0]\na[2] -= tb * (a[0] - 1)\n#print(ts)\nif (ts <= 0):\n ts += tb * a[0]\n #print(ts)\n print(floor(a[1] / (a[0] * a[3])))\nelse:\n tb += 1\n ts -= a[2] + 1\n if (ts <= 0):\n print(int(tb))\n else:\n tb += ts\n print(int(tb))\n \n"}, {"source_code": "a = input()\na = list(a.split(' '))\na = list(map(int,a))\nts = a[1] / a[3]\ntb = 0\nif (ts != int(ts)):\n ts = int(ts) + 1\n#print(ts)\ntb += a[2] // (a[0] - 1)\nts -= tb * a[0]\na[2] -= tb * (a[0] - 1)\n#print(ts)\nif (ts <= 0):\n ts += tb * a[0]\n print(int(ts // (a[0]-1)))\nelse:\n tb += 1\n ts -= a[2] + 1\n if (ts <= 0):\n print(int(tb))\n else:\n tb += ts\n print(int(tb))\n \n"}, {"source_code": "a = input()\na = list(a.split(' '))\na = list(map(int,a))\nts = a[1] / a[3]\ntb = 0\nif (ts != int(ts)):\n ts = int(ts) + 1\n#print(ts)\ntb += a[2] // (a[0] - 1)\nts -= tb * a[0]\na[2] -= tb * (a[0] - 1)\nif (ts <= 0):\n ts += tb * a[0]\n print(int(ts // a[0]))\nelse:\n tb += 1\n ts -= a[2] + 1\n if (ts <= 0):\n print(int(tb))\n else:\n tb += ts\n print(int(tb))\n \n"}, {"source_code": "import sys\n\nf = sys.stdin\n# f = open(\"input.txt\", \"r\")\n\nk, a, b, v = map(int, f.readline().split())\n\ncnt = 0\nboxes = 1\n\nwhile cnt < a:\n if k-1 <= b:\n cnt += k*v\n b -= k\n elif b > 0:\n cnt += (b+1)*v\n b = 0\n else:\n boxes += 1\n cnt += v\n\nprint(boxes)"}, {"source_code": "import math\ndef main():\n k,a,b,v = [int(i) for i in input().split()]\n s = math.ceil(a/v)\n total = math.ceil(min(s,b+1)/k)\n if s > b+1:\n total += s-b-1\n print(total)\n\nif __name__ == '__main__': main()\n"}, {"source_code": "#!/usr/bin/python\nimport re\nimport inspect\nfrom sys import argv, exit\nfrom math import ceil\n\ndef rstr():\n return input()\n\ndef rstrs(splitchar=' '):\n return [i for i in input().split(splitchar)]\n\ndef rint():\n return int(input())\n\ndef rints(splitchar=' '):\n return [int(i) for i in rstrs(splitchar)]\n\ndef varnames(obj, namespace=globals()):\n return [name for name in namespace if namespace[name] is obj]\n\ndef pvar(var, override=False):\n prnt(varnames(var), var)\n\ndef prnt(*args, override=False):\n if '-v' in argv or override:\n print(*args)\n\n# Faster IO\npq = []\ndef penq(s):\n if not isinstance(s, str):\n s = str(s)\n pq.append(s)\n\ndef pdump():\n s = ('\\n'.join(pq)).encode()\n os.write(1, s)\n\nif __name__ == '__main__':\n sec_per_box, nuts, divs, cap = rints()\n\n total_secs_needed = ceil(nuts / cap)\n prnt(total_secs_needed)\n if total_secs_needed < sec_per_box:\n print(1)\n exit(0)\n\n fdb = divs // (sec_per_box - 1)\n prnt('fdb', fdb)\n\n if fdb*sec_per_box > total_secs_needed:\n prnt('top')\n ans = ceil((fdb*sec_per_box) / total_secs_needed)\n print(ans)\n else:\n prnt('bot')\n nuts -= fdb*sec_per_box*cap\n total_secs_needed -= fdb*sec_per_box\n divs -= fdb*(sec_per_box -1)\n ans = fdb\n if divs:\n prnt('if divs')\n ans += 1\n nuts -= (divs+1) * cap\n prnt('nuts, cap: ', nuts, cap)\n if nuts > 0:\n ans += ceil(nuts / cap)\n print(ans)\n"}, {"source_code": "#!/usr/bin/python\nimport re\nimport inspect\nfrom sys import argv, exit\nfrom math import ceil\n\ndef rstr():\n return input()\n\ndef rstrs(splitchar=' '):\n return [i for i in input().split(splitchar)]\n\ndef rint():\n return int(input())\n\ndef rints(splitchar=' '):\n return [int(i) for i in rstrs(splitchar)]\n\ndef varnames(obj, namespace=globals()):\n return [name for name in namespace if namespace[name] is obj]\n\ndef pvar(var, override=False):\n prnt(varnames(var), var)\n\ndef prnt(*args, override=False):\n if '-v' in argv or override:\n print(*args)\n\n# Faster IO\npq = []\ndef penq(s):\n if not isinstance(s, str):\n s = str(s)\n pq.append(s)\n\ndef pdump():\n s = ('\\n'.join(pq)).encode()\n os.write(1, s)\n\nif __name__ == '__main__':\n sec_per_box, nuts, divs, cap = rints()\n prnt('secs/box:', sec_per_box, 'nuts', nuts, 'divs', divs, 'cap', cap)\n\n total_secs_needed = ceil(nuts / cap)\n prnt('total_secs_needed', total_secs_needed)\n if total_secs_needed < sec_per_box:\n print(1)\n exit(0)\n\n fdb = divs // (sec_per_box - 1)\n prnt('fdb', fdb)\n\n if fdb*sec_per_box > total_secs_needed:\n prnt('top')\n ans = ceil(total_secs_needed / sec_per_box)\n print(ans)\n else:\n prnt('bot')\n nuts -= fdb*sec_per_box*cap\n total_secs_needed -= fdb*sec_per_box\n divs -= fdb*(sec_per_box -1)\n ans = fdb\n if divs:\n prnt('if divs')\n ans += 1\n nuts -= (divs+1) * cap\n prnt('nuts, cap: ', nuts, cap)\n if nuts > 0:\n ans += ceil(nuts / cap)\n print(ans)\n"}, {"source_code": "k, a, b, v = map(int, input().split())\nm = (a + v - 1) // v\n# print(\"m =\", m)\nn = (m + k - 1) // k\n# print(\"n =\", n)\nx = (b + 1) // k\n# print(\"x =\", x)\ny = (b + k) // k\n# print(\"y =\", y)\nif n <= x:\n print(n)\nelif m <= b + 1:\n print(y)\nelse:\n print(y + m - b - 1)"}, {"source_code": "k, a, b, v = map(int, input().split())\nfor i in range(1, 1001):\n if (k - 1) * i < b:\n t = (k - 1) * i\n else:\n t = b\n if a < v * (i + t):\n print(i)\n break"}, {"source_code": "k,a,b,v=map(int,input().split())\nans=0\nwhile a>0:\n if b>=k-1:\n ans+=b//(k-1)\n a-=k*v*(b//(k-1))\n b=b%(k-1)\n elif b!=0:\n ans+=1\n a-=(b+1)*v\n b=0\n else:\n ans+=a//v +(1 if a%v else 0)\n a=0\nprint(ans)"}, {"source_code": "k,a,b,v=map(int,input().split())\no=a//v+(1 if a%v else 0)\nans=0\nwhile o>0:\n if b>=k-1:\n ans+=b//(k-1)\n o-=k*(b//(k-1))\n b=b%(k-1)\n elif b!=0:\n ans+=1\n o-=b+1\n b=0\n else:\n ans+=o\n o=0\nprint(ans)"}, {"source_code": "from math import ceil\n\nk,nuts,b,v = map(int,input().split())\n\ncap_ = (b+1)*v\nsections_ = ceil(cap_/v)\nr = cap_%v\nboxes = ceil(sections_/k)\nans = boxes\nif nuts > (b+1)*v:\n\tif r != 0:\n\t\tnuts = nuts-(v-r)-(b+1)*v\n\telse:\n\t\tnuts = nuts-(b+1)*v\n\tans = ans + ceil(nuts/v)\nelse:\n\tsections_ = ceil(nuts/v)\n\tans = ceil(sections_/k)\nprint(ans)\n"}, {"source_code": "from math import ceil\n\nsec_,nuts,div_,cap_ = map(int,input().split())\nb_ = ceil((div_+1)/sec_)\n\nt1 = (div_+1)*cap_\nif t1 >= nuts:\n\td = ceil(nuts/cap_)\n\tans = ceil(d/sec_)\nelif t1 < nuts:\n\tnuts = nuts - t1\n\tans = b_\n\tans = ans + ceil(nuts/cap_)\nprint(ans)"}, {"source_code": "from math import ceil\n\nDiv_,Nuts_,Sec_,Nut_Cap_ = map(int,input().split())\n\nBoxes_ = Sec_//(Div_-1)\nRemaining_ = Sec_%(Div_-1)\nif Remaining_:\n\tTotal_capcaity = Boxes_*Div_*Nut_Cap_ + (Remaining_+1)*Nut_Cap_\nelse:\n\tTotal_capcaity = Boxes_*Div_*Nut_Cap_\n\nif Nuts_ > Total_capcaity:\n\tNuts_ = Nuts_ - Total_capcaity\n\tans = Boxes_ + 1\n\tans = ans + ceil(Nuts_/Nut_Cap_)\nelif Nuts_ >= Boxes_*Div_*Nut_Cap_:\n\tans = Boxes_ + 1\nelse:\n\tans = ceil(Nuts_/(Div_*Sec_))\nprint(ans)\n"}, {"source_code": "from math import ceil\n\nk,nuts,b,v = map(int,input().split())\n\ncap_ = (b+1)*v\nsections_ = ceil((cap_)/v)\nt = ceil((sections_)/k)\nif cap_ <= nuts:\n\tnuts = nuts - cap_\n\tt = t + ceil(nuts/(v))\n\tprint(t)\nelse:\n\tans = nuts//(k*v)\n\tif nuts%(k*v) != 0:\n\t\tans = ans + 1\n\tprint(ans)"}, {"source_code": "from math import ceil\n\nDiv_,Nuts_,Sec_,Nut_Cap_ = map(int,input().split())\n\nBoxes_ = Sec_//(Div_-1)\nRemaining_ = Sec_%(Div_-1)\n\nif Remaining_:\n\tTotal_capcaity = Boxes_*Div_*Nut_Cap_ + (Remaining_+1)*Nut_Cap_\n\tBoxes_ = Boxes_ + 1\nelse:\n\tTotal_capcaity = Boxes_*Div_*Nut_Cap_\n\t\nif Nuts_ > Total_capcaity:\n\tNuts_ = Nuts_ - Total_capcaity\n\tans = Boxes_\n\tans = ans + ceil(Nuts_/Nut_Cap_)\nelif Nuts_ > Boxes_*Div_*Nut_Cap_:\n\tans = Boxes_ + 1\nelse:\n\tans = ceil(Nuts_/(Div_*Sec_))\nprint(ans)\n"}, {"source_code": "from math import ceil\n\nk,nuts,b,v = map(int,input().split())\n\nt1 = (b)//(k-1)\nt2 = (b+1)%(k-1)\ncapacity = t1*v*k+t2*v\n# print(capacity)\nans = t1+t2\nif capacity < nuts:\n\tnuts = nuts - capacity\n\tans = ans + ceil(nuts/v)\n\tprint(ans)\nelse:\n\tprint(ceil(nuts/k))"}, {"source_code": "k, a, b, v = map(int, input().split())\n\nc = b // (k - 1)\nd = b % (k - 1) + 1\ns = a // v + 1\nresult = 0\nwhile (a > 0 and c > 0):\n a -= k * v\n c -= 1\n result += 1\n\nif a > 0:\n a -= d * v\n result += 1\n\nif a > 0:\n result += a // v + 1\n\nprint(result)\n\n"}, {"source_code": "import math\nk,a,b,v=map(int,input().split())\n#3 10 3 3\nif(v>a):\n print(1)\nelse:\n if b+1<k:\n \ta=a-v*(b+1)\n \tans=math.ceil(a/v)\n \tprint(ans+1)\n else:\n \t\n c=1\n a=a-(v*k)#347-5=342\n b=b-k+1#b=16\n #print(\"initial a=\",a,\"b=\",b,\"k=\",k)\n while(a>0 and b>0):\n\t if v>a:\n\t c+=1\n\t a=0\n\t break\n\t else:\n\t if b>k:\n\t a=a-(v*(k))#a=342-1*5=337 332 327\n\t c+=1#c=2 3 4\n\t b=b-(k-1)#b=16-4=12 8 4\n\t if(b<k):\n\t a=a-v*(b+1) \n\t c+=1\n\t b=0\n\t \n if(b==0):\n c+=math.ceil(a/v)\n print(c)\n "}, {"source_code": "import math\nk,a,b,v=map(int,input().split())\n#3 10 3 3\nif(v>a):\n print(1)\nelse:\n if b+1<k:\n \ta=a-v*(b+1)\n \tans=math.ceil(a/v)\n \tprint(ans+1)\n else:\n c=1\n a=a-(v*k)\n b=b-k+1\n #print(\"initial a=\",a,\"b=\",b,\"k=\",k)\n while(a>0):\n\t if v>a:\n\t c+=1\n\t a=0\n\t break\n\t else:\n\t if b>0:\n\t a=a-(v*(b+1))\n\t c+=1\n\t else:\n\t a=a-v\n\t c+=1\n print(c)\n\n# your code goes here"}, {"source_code": "import math\nk,a,b,v=map(int,input().split())\n#3 10 3 3\nif(v>a):\n print(1)\nelse:\n if b+1<k:\n \ta=a-v*(b+1)\n \tans=math.ceil(a/v)\n \tprint(ans+1)\n else:\n c=1\n a=a-(v*k)\n b=b-k+1\n print(\"initial a=\",a,\"b=\",b,\"k=\",k)\n while(a>0):\n\t if v>a:\n\t c+=1\n\t a=0\n\t break\n\t else:\n\t if b>0:\n\t a=a-(v*(b+1))\n\t c+=1\n\t else:\n\t a=a-v\n\t c+=1\n print(c)\n\n# your code goes here"}, {"source_code": "import math\nk,a,b,v=map(int,input().split())\n#3 10 3 3\nif(v>a):\n print(1)\nelse:\n if b+1<k:\n \ta=a-v*(b+1)\n \tans=math.ceil(a/v)\n \tprint(ans+1)\n else:\n \t\n c=1\n a=a-(v*k)\n b=b-k+1#\n #print(\"initial a=\",a,\"b=\",b,\"k=\",k)\n while(a>0 and b>0):\n\t if v*(b+1)>a:\n\t c+=1\n\t a=0\n\t break\n\t else:\n\t if b>k:\n\t a=a-(v*(k))#\n\t c+=1#\n\t b=b-(k-1)#\n\t if(b<k):\n\t a=a-v*(b+1) #\n\t c+=1#\n\t b=0\n\t \n if(b==0 and a>0):\n c+=math.ceil(a/v)\n print(c)\n "}, {"source_code": "import math\nboxes = 0\nk, a,b, v = map(int, input().split())\n#b += 1\nif k > (b+1):\n k = b + 1\nnumfb = b // (k - 1)\nextrak = b % (k - 1)\na -= (numfb * k * v)\nboxes += numfb\nif extrak > 0 and a > 0:\n boxes += 1\n a -= (extrak + 1) * v\nwhile a > 0:\n boxes += 1\n a -= v\n\nprint(boxes)"}, {"source_code": "import math\nboxes = 0\nk, a,b, v = map(int, input().split())\nk = max(b, k)\nnumfb = b // k\nextrak = b % k\na -= (numfb * k * v)\nboxes += numfb\nif extrak > 0 and a > 0:\n boxes += 1\n a -= (extrak + 1) * v\nwhile a > 0:\n boxes += 1\n a -= v\n\nprint(boxes)"}, {"source_code": "import math\nboxes = 0\nk, a,b, v = map(int, input().split())\n#b += 1\nif k > (b+1):\n k = b + 1\nnumfb = b // (k - 1)\nextrak = b % (k - 1)\nwhile a > 0:\n boxes += 1\n a -= k * v\nif extrak > 0 and a > 0:\n boxes += 1\n a -= (extrak + 1) * v\nwhile a > 0:\n boxes += 1\n a -= v\n\nprint(boxes)"}, {"source_code": "import math\n\ndef main():\n n = input().split()\n k = int(n[0])\n a = int(n[1])\n b = int(n[2])\n v = int(n[3])\n if k > b + 1 :\n print(1+max(math.ceil((a-(b+1)*v)/v ),0))\n return 0\n\n maxboxes = math.floor(b/(k-1))\n if maxboxes * k * v > a:\n print(math.ceil(a / ((k+1) * v)))\n return 0\n a = a - maxboxes * k * v #remaining nuts after we pack max boxes\n print(maxboxes + math.ceil(a/v))\n return 0\n\n\nif __name__ == \"__main__\": main()"}, {"source_code": "import math\n\ndef main():\n n = input().split()\n k = int(n[0])\n a = int(n[1])\n b = int(n[2])\n v = int(n[3])\n if k > b + 1 :\n print(1+max(math.ceil((a-(b+1)*v)/v ),0))\n return 0\n\n maxboxes = math.floor(b/(k-1))\n if maxboxes * k * v > a:\n print(math.ceil(a / (k * v)))\n return 0\n a = a - maxboxes * k * v #remaining nuts after we pack max boxes\n print(maxboxes + math.ceil(a/v))\n return 0\n\n\nif __name__ == \"__main__\": main()"}, {"source_code": "R = lambda :map(int,input().split())\nk,a,b,v= R()\na1 = b//(k-1);a2 = b%(k-1)\nif a<=v*(a1)*k:\n print((a+(v-1))//(v*k))\nelif v*(a1)*k<a<=(v*a1*k+(a2+1)*v):\n print(a1+1)\nelse:\n print(a1+1+((a-v*a1*k-(a2+1)*v)+v-1)//v)\n\n\n"}, {"source_code": "from math import ceil\nk, a, b, v = [int(i) for i in input().split()]\n\nprint(max(ceil((a - b*v)/v), ceil(b/(k - 1))))"}, {"source_code": "k, a, b, v = [int(x) for x in input().split()]\nans = 0\nwhile a > 0:\n\tl = min(k - 1, b)\n\tb -= l\n\ta -= (l + 1) * k\n\tans += 1\nprint(ans)\n"}, {"source_code": "max_parts, n, divisors, k = map(int, input().split())\nmin_boxes = (divisors + max_parts - 2) // (max_parts - 1)\nif (min_boxes + divisors) * k >= n:\n print(min_boxes)\nelse:\n left = n - (min_boxes + divisors) * k\n print(((left + k - 1) // k + min_boxes))\n"}, {"source_code": "max_parts, n, divisors, nuts_in_part = map(int, input().split())\nparts = (n + nuts_in_part - 1) // (nuts_in_part)\nans = parts - divisors\nwhile ans * (max_parts - 1) < divisors:\n ans += 1\nprint(ans)"}, {"source_code": "max_parts, n, divisors, k = map(int, input().split())\nmin_boxes = (divisors + max_parts - 2) // (max_parts - 1)\nif (min_boxes + divisors) * k >= n:\n print(min_boxes)\nelse:\n print((n + k - 1) // k - divisors)\n"}, {"source_code": "#k, a, b, v = map(int, input().split())\n\nk, a, b, v = 3, 10, 1, 3\nrezult = 0\n\n\nbox = {\n 'sep': 0,\n 'place': 0,\n 'nuts': 0\n}\n\nwhile a > 0:\n if b >= 0:\n if b < k:\n box['sep'] = b\n box['place'] = b+1\n b = 0\n elif b == 0:\n box['sep'] = 0\n box['place'] = 1\n else:\n box['sep'] = k - 1\n box['place'] = k\n b -= box['sep']\n if a < v * box['place']:\n box['nuts'] = a\n a = 0\n else:\n a -= (v * box['place'])\n rezult += 1\n\nprint(rezult)\n"}, {"source_code": "k, a, b, v = map(int, input().split())\ncnt = 1\nwhile True:\n if b + 1 - k < 0:\n use_b = b + 1\n else:\n use_b = k\n\n if use_b != 0:\n max_or = use_b * v\n else:\n max_or = v\n if a - max_or > 0:\n cnt += 1\n b = b - use_b\n a -= max_or\n else:\n print(cnt)\n break"}, {"source_code": "k, a, b, v = map(int, input().split())\ncnt = 1\nwhile True:\n if b + 1 - k < 0:\n use_b = b + 1\n else:\n use_b = k\n\n if use_b != 0:\n max_or = use_b * v\n else:\n max_or = v\n if a - max_or >= 0:\n cnt += 1\n b = b - use_b\n a -= max_or\n else:\n print(cnt)\n break"}, {"source_code": "max_section, nuts, divisor, capacity = map(int, input().split()) # max section , nuts, divisor , capacity\ndef lt(x):\n if x - int(x) > 0:\n return int(x) + 1\n return int(x)\nmax_divisor = max_section - 1\nbox_max_section = int(divisor/max_divisor)\nextra_box_capacity = (divisor%max_divisor + 1)*capacity\nif nuts > box_max_section*capacity:\n rs = box_max_section\n nuts -= box_max_section*max_section*capacity\n if nuts > extra_box_capacity:\n rs += 1 + lt((nuts-extra_box_capacity)/capacity)\n else:\n rs +=1\nelse:\n rs = lt(nuts/(box_max_section*(max_section+1)*capacity))\nprint(rs)"}, {"source_code": "max_section, nuts, divisor, capacity = map(int, input().split()) # max section , nuts, divisor , capacity\ndef lt(x):\n if x - int(x) > 0:\n return int(x) + 1\n return int(x)\nbox_max_section = int(divisor/(max_section-1))\nextra_box_capacity = (divisor%(max_section-1) + 1)*capacity\nif nuts > box_max_section*capacity:\n rs = box_max_section\n nuts -= box_max_section*(max_section + 1)*capacity\n if nuts > extra_box_capacity:\n rs += 1 + lt((nuts-extra_box_capacity)/capacity)\n else:\n rs +=1\nelse:\n rs = lt(nuts/(box_max_section*(max_section+1)*capacity))\nprint(rs)"}, {"source_code": "from math import ceil\n\nk, a, b, v = list(map(int, input().split()))\nBox = 0\nwhile a:\n Section = min(b, k - 1) + 1\n b -= Section - 1\n Total = min(v, ceil((a - b) / Section))\n a -= min(a , Total * Section)\n Box += 1\nprint(Box)\n\n# Let's see who is the best !!!\n# ravenS_The_Best\n"}, {"source_code": "l=[int(i) for i in input().split(\" \")]\nk=l[0]\na=l[1]\nb=l[2]\nv=l[3]\nbox=0\ndivs=0\nwhile a>0:\n box+=1\n sections=1\n while a>0 and sections<=k and divs<=b:\n a-=v\n sections+=1\n divs+=1\n if(divs>b):\n while a>0:\n a-=v\n box+=1\nprint(box)"}, {"source_code": "import sys\n\nif __name__ == \"__main__\":\n line = sys.stdin.readline()\n items = line.split()\n k = int(items[0])\n a = int(items[1])\n b = int(items[2])\n v = int(items[3])\n box = 0\n\n while b >= v-1 and a > 0:\n box += 1\n a -= k * v\n b -= v-1\n\n if a <= 0:\n print box\n else:\n if a % v == 0:\n sec_need = a / v\n else:\n sec_need = a / v + 1\n\n if sec_need > b+1:\n box += 1 + sec_need - (b+1)\n else:\n box += 1\n print box\n \n\n \n"}, {"source_code": "# -*- coding: utf-8 -*-\nk, a, b, v = map(int, raw_input().split())\n\n# k \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0441\u0435\u043a\u043e\u0432 \u0432 \u043a\u043e\u0440\u043e\u0431\u043a\u0435,\n# a - \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0440\u0435\u0445\u043e\u0432,\n# b - \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u0439\n# v - \u0432\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0441\u0435\u043a\u0430 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.\nn = 0\nb_boxes_num, b_left = (b / (k - 1), b % (k - 1)) if k > 1 else (0, 0)\nextra_box_volume = (b_left + 1) * v\n\nif a <= b_boxes_num * k * v:\n n = a / (k * v)\nelse:\n a -= b_boxes_num * k * v\n n += b_boxes_num\n\n a -= extra_box_volume\n n += 1\n\n if a > 0:\n n += a / v\n n += 1 if a % v > 0 else 0\n\nprint n\n"}, {"source_code": "import sys\nimport math\n\ninp = sys.stdin.readline().rstrip('\\n').split(' ')\nk = int(inp[0]) # sections in a box\na = int(inp[1]) # # of nuts\nb = int(inp[2]) # # of divisors\nv = int(inp[3]) # capacity of each section.\n\nboxNum = 0\n\nwhile (a >= 1):\n\tboxNum += 1\n\tboxSection = k\n\twhile (b > k and b > 0):\n\t\tboxSection += 1\n\t\tb -= 1\n\t# subtract nuts\n\tif (math.floor(a/boxSection) < 1):\n\t\ta = 0\n\telse:\n\t\ta -= math.floor(a/boxSection)*v\n\nprint boxNum\n"}, {"source_code": "#v1\nk,a,b,v=map(int,raw_input().split())\nn=(a+v-1)/v\nd=b/(k-1)*k\nif d<n:\n n-=d\n x=b/(k-1)\n b%=k-1\n if b+1<n:\n n-=b+1\n x+=1\n print x+n\nelse:\n print (n+k-1)/k\n"}, {"source_code": "k,a,b,v = map(int,raw_input().split())\n\na=(a-1)/v+1\nf = 0\nif a <= ((b-1)/(k-1)+1)*k:\n print (b-1)/(k-1)+1\n\nelse:\n print a-b "}, {"source_code": "import sys\nimport math\n\nline = sys.stdin.readline()\nz = line.split()\nk = int(z[0])\na = int(z[1])\nb = int(z[2])\nv = int(z[3])\n\nnumBoxes = 1\nnumSections = 1\na = a-v\nwhile(a >= 0):\n if(numSections == k):\n numBoxes +=1\n numSections = 1\n a = a-v\n elif b==0:\n numBoxes +=1\n numSections = 1\n a = a-v\n else:\n numSections +=1\n b -= 1\n a = a-v\nprint numBoxes\n \n\n\n##if(a < v*(b+1)):\n## print int(math.ceil(float(a)/float(k*v)))\n##else:\n## n = int(math.ceil(float(a)/float(k*v)))\n## n1 = int(math.ceil(float(a - v*(b+1))/float(v)))\n## print n + n1\n##\n## \n"}, {"source_code": "ri = lambda: raw_input().strip()\n\n# n = int(ri())\n# #n, m = map(int, ri().split())\n\nk, a, b, v = map(int, ri().split())\n\ncount = 0\nwhile (b >= k-1) and (a >= k*v):\n b -= k-1\n a -= k*v\n count += 1\n\nwhile (b > 0) and (a > 0):\n a -= (b+1) * v\n count += 1\n\nwhile a > 0:\n a -= v\n count += 1\n\nprint count"}, {"source_code": "import math\n\n\ndef ceil(x, y):\n return int(math.ceil(float(x)/y))\n\n\ndef nuts(a, k, v, b):\n n = ceil(a, v)\n m = ceil(b, k-1)\n if n >= b + m:\n p = n - b\n else:\n p = ceil(n, k)\n return p\n\n\nk, a, b, v = map(int, raw_input(\"k, a, b, v = \").split())\nprint nuts(a, k, v, b)"}, {"source_code": "import sys,math\n\nk,a,b,v=map(int,raw_input().split())\ndozen=0\nif k>b:\n maxdoos=(b+1)*v\n dozen=1\n rest=a-maxdoos\n if rest>0:\n dozen+=rest/v\n if rest%v>0:\n dozen+=1\n \nelse:\n maxdoos=k*v\n while b-k+1>=0:\n dozen+=1\n rest=a-maxdoos\n b-=k-1\n if rest>0:\n dozen+=rest/v\n if rest%v>0:\n dozen+=1\n \n \n \n\n\n \nprint dozen\n "}, {"source_code": "import sys,math\n\nmaxsec,noten,planken,notsec=map(int,raw_input().split())\n\ndozen=min(noten/(notsec*maxsec),planken/(maxsec-1))\nnoten-=dozen*notsec*maxsec\nplanken-=dozen*(maxsec-1)\n\nsec=noten/notsec+int(noten%notsec>0)\nif sec>=maxsec:\n dozen+=1\n noten-=(planken+1)*notsec\n \nif noten>0:\n dozen+=noten/notsec+int(noten%notsec>0)\n \n\nprint dozen\n "}, {"source_code": "import sys,math\n\nmaxsec,noten,planken,notsec=map(int,raw_input().split())\n\ndozen=min(noten/(notsec*maxsec),planken/(maxsec-1))\nnoten-=dozen*notsec*maxsec\nplanken-=dozen*(maxsec-1)\n\nsec=noten/notsec+int(noten%notsec>0)\nif sec>=planken+1:\n dozen+=1\n noten-=(planken+1)*notsec\n if noten>0:\n dozen+=noten/notsec+int(noten%notsec>0)\nelse:\n dozen+=1\n \n \n\n \n\nprint dozen\n "}, {"source_code": "import sys\n\n\nk, a, b, v = map(int, raw_input().split())\nans = 0\nk -= 1\nwhile True:\n\n ans += 1\n x, y = divmod(b, k)\n have = ans\n ican = min(x, have) * (k + 1) * v\n have -= min(x, have)\n if have > 0:\n have -= 1\n ican += (y + 1) * v\n ican += have\n if ican >= a:\n break\n\nprint ans\n"}, {"source_code": "import sys\n\ninp = sys.stdin.readlines()\nctr = 0\n\nx = inp[ctr].split()\nk = int(x[0])\na = int(x[1])\nb = int(x[2])\nv = int(x[3])\nctr+=1\nans = 0\nwhile True:\n if b >= k-1:\n b -= k-1\n a -= k*v\n ans += 1\n if a < 0:\n break\n elif b > 0:\n a -= (b+1)*v\n b = 0\n ans += 1\n if a < 0:\n break\n else:\n ans += a/v\n if a%v!=0:\n ans +=1\n break\nprint ans \n \n"}, {"source_code": "k,a,b,v=map(int,raw_input().split())\n\nres = 0\naa = a\n\nwhile a>0:\n vv = max(v,b)\n b -= vv\n a -= vv + 1\n res+=1\n \nprint res"}, {"source_code": "k,a,b,v = map(int,raw_input().split())\nboxes = 0\nwhile a>=0:\n if b>=k:\n a = a-k*v\n b = b-k+1\n boxes += 1\n elif b>0:\n a = a-(b+1)*v\n b = 0\n boxes += 1\n else:\n a = a-v\n boxes += 1\nprint boxes\n"}, {"source_code": "(k, a, b, v), c = map(int, raw_input().split()), 0\nwhile a > 0 and b > 0:\n\ta -= v * min(b + 1, k)\n\tb -= min(b, k - 1)\n\tc += 1\nprint c + max((a + k - 1) / k, 0)\n"}, {"source_code": "first = map(int,raw_input().split())\n\n#max num of sections\nk = first[0]\n#num of nuts\na = first[1]\n#num of divisors\nb = first[2]\n#capacity of each section\nv = first[3]\n\nboxes = 0\n\nwhile a > 0:\n\n if b+1 > k:\n\n b = b - (k-1)\n a = a - (v*k)\n boxes += 1\n\n #elif b+1 < k:\n else:\n a = a - (b+1)*k\n b = b - b\n boxes += 1\n\nprint boxes\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\nsec,n,di,v=l()\nboxes=di/(sec-1)\nif n%v==0:\n needsec=n/v\nelse:\n needsec=n/v+1\ncnt=0\ni=1\nwhile i<=boxes:\n cnt+=sec\n if cnt>=needsec:\n print i\n exit()\n i+=1\nr=n-sec*v\nrdi=di%(sec-1)\nif rdi==0:\n print boxes + [r/v+1,r/v][r%v==0]\nelse:\n if r<=(rdi+1)*v:\n print boxes+1\n else:\n r=r-(rdi+1)*v\n boxes+=1\n print boxes + [r/v+1,r/v][r%v==0]"}, {"source_code": "I=lambda:map(int, raw_input().split())\nk, a, b, v = I()\nfull, half = b / (k-1), b % (k-1)\nx = full * v * k\n#print full, half\nif x >= a:\n print full\nelse:\n if a - x <= (half + 1)*v:\n print full + 1\n else:\n print full + 1 + (a - x - (half + 1) * v + v - 1)/ v "}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# Jonathan Prieto - d555\n\nimport sys\n# sys.stdin = open(\"inputA.txt\", \"r\")\n\ndef solve():\n k,a,b,v = map(int, raw_input().split())\n cajas = 0\n while a > v:\n cajas = cajas + 1\n secusadas = 1\n a = a - v\n while secusadas <= k and a >= v and b > 0:\n a = a - v\n b = b - 1\n secusadas += 1\n\n if a != 0:\n cajas = cajas + 1\n print cajas\n\n\n\nsolve()\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# Jonathan Prieto - d555\n\nimport sys\n# sys.stdin = open(\"inputA.txt\", \"r\")\n\ndef solve():\n k,a,b,v = map(int, raw_input().split())\n cajas = 0\n while a >= v:\n cajas = cajas + 1\n secusadas = 1\n a = a - v\n while secusadas < k and a >= v and b > 0:\n a = a - v\n b = b - 1\n secusadas += 1\n\n if a != 0:\n cajas = cajas + 1\n print cajas\n\n\n\nsolve()\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# Jonathan Prieto - d555\n\nimport sys\n# sys.stdin = open(\"inputA.txt\", \"r\")\n\ndef solve():\n k,a,b,v = map(int, raw_input().split())\n cajas = 0\n while a >= v:\n cajas = cajas + 1\n secusadas = 1\n a = a - v\n while secusadas <= k and a >= v and b > 0:\n a = a - v\n b = b - 1\n secusadas += 1\n\n if a != 0:\n cajas = cajas + 1\n print cajas\n\n\n\nsolve()\n"}, {"source_code": "k,a,b,v = map(int,raw_input().split())\ncount = 0\nwhile a > 0 or b > 0 :\n if b >= k-1:\n a = a - v*k\n b = b - (k-1)\n else:\n a = a - v*(b+1)\n b = 0\n count += 1\nif a > 0:\n count += int(math.ceil(a/v))\nprint count\n"}, {"source_code": "def main():\n k_sec,nut,b_div,v_max=map(int,raw_input().split())\n if nut<=v_max:\n print 1\n return\n #nut>v_max\n rest= nut%v_max\n max_sec=nut/v_max\n if rest!=0:\n max_sec+=1\n #need max_sec\n num_box=max_sec\n cur_box_sec=1\n #print max_sec\n while b_div>=0 and num_box>=1:\n if cur_box_sec>(k_sec-1):\n cur_box_sec=1\n\n else:\n cur_box_sec+=1\n b_div-=1\n num_box-=1\n print num_box+1\n\n\n\n\n\n\n\n\nmain()"}, {"source_code": "def main():\n k_sec,nut,b_div,v_max=map(int,raw_input().split())\n if nut<=v_max:\n print 1\n return\n #nut>v_max\n rest= nut%v_max\n max_sec=nut/v_max\n if rest!=0:\n max_sec+=1\n #need max_sec\n #num_box=max_sec\n num_box=0\n cur_box_sec=1\n while max_sec:\n if b_div:\n if cur_box_sec>=k_sec:\n num_box+=1\n cur_box_sec=1\n else:\n cur_box_sec+=1\n max_sec-=1\n b_div-=1\n else:\n num_box+=1\n max_sec-=1\n print num_box\n\n\n \n\n\n\n\n\n\n\n\nmain()"}, {"source_code": "def main():\n k_sec,nut,b_div,v_max=map(int,raw_input().split())\n if nut<=v_max:\n print 1\n return\n #nut>v_max\n rest= nut%v_max\n max_sec=nut/v_max\n if rest!=0:\n max_sec+=1\n #need max_sec\n num_box=max_sec\n cur_box_sec=1\n #print max_sec\n while b_div>=0 and num_box>1:\n if cur_box_sec>(k_sec-1):\n cur_box_sec=1\n\n else:\n cur_box_sec+=1\n b_div-=1\n num_box-=1\n print num_box+1\n\n\n\n\n\n\n\n\nmain()"}], "src_uid": "7cff20b1c63a694baca69bdf4bdb2652"} {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n", "positive_code": [{"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nimport random\nimport operator\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn, k, m = map(int, raw_input().split())\n\nif k == 1:\n print (pow(10, n, m) - pow(10, n - 1, m)) % m\n quit()\n\npow9_10 = []\np = 1\nfor i in range(n):\n pow9_10.append(p)\n if i == 0:\n p = (p * 9) % m\n else:\n p = (p * 10) % m\n\nres = 0\ncounts = [0] * k\ncounts[0] = 1\n\np10i = 1\nfor i in xrange(n):\n counts2 = [0] * k\n for r in xrange(k):\n mind = 1 if i == n else 0\n for d in xrange(mind, 10):\n r2 = (d * p10i + r) % k\n counts2[r2] += counts[r]\n counts2[r2] %= m\n\n add = (counts2[0] - 1) * pow9_10[n - i - 1]\n res += add\n res %= m\n # print i, res\n counts2[0] = 1\n counts = counts2\n\n p10i = (p10i * 10) % k\nprint res % m\n\n"}, {"source_code": "def main():\n n, k, m = map(int, raw_input().split())\n if k == 1:\n print 9 * pow(10, n - 1, m) % m\n return\n if n == 1:\n print len([i for i in xrange(1, 10) if i % k == 0]) % m\n return\n dp = [0] * k\n for i in xrange(10):\n if i % k:\n dp[i%k] += 1\n t = 10 % k\n kk = [[i * j % k for j in xrange(11)] for i in xrange(k)]\n for i in xrange(n - 1):\n ndp = [0] * k\n for j in xrange(1, k):\n for l in xrange(i == n - 2, 10):\n x = j + kk[t][l]\n if x >= k:\n x -= k\n if x:\n ndp[x] += dp[j]\n if ndp[x] >= m:\n ndp[x] -= m\n for l in xrange(i == n - 2, 10):\n if kk[t][l]:\n ndp[kk[t][l]] += 1\n dp = ndp[:]\n t = kk[t][10]\n print (9 * pow(10, n - 1, m) - sum(dp) % m + m) % m\nmain()\n"}, {"source_code": "line = map(int, raw_input().split())\nn = line[0]\nk = line[1]\nm = line[2]\n\nt = [[0 for _ in xrange(k)] for _ in xrange(n)]\n\n#base = 1\n#for i in xrange(n):\n# base *= 10\n# top = base - 1\n# r[i] = (int(top / k) + 1) % m\n #r[0][i % k] += 1\n\n#base = 1\n#for i in xrange(1, n):\n #base *= 10\n #if (i == n - 1): start = 1\n #else: start = 0\n #for c in xrange(start, 10):\n #offset = (c * base) % k\n #for j in xrange(k):\n ##for pre in xrange(i):\n #r[i][j] += r[i - 1][(j - offset) % k]\n #r[i][j] %= m\n\nt[0][0] = 9 // k\nbase = 1\nfor i in xrange(1, n):\n base *= 10\n if (i == n - 1):\n t[i][0] = ((10 * base - 1) // k - (base - 1) // k) % m\n start = 1\n else:\n t[i][0] = ((10 * base - 1) // k) % m\n start = 0\n baser = base % k\n offset = ((start - 1) * base) % k\n for c in xrange(start, 10):\n offset += base\n offset %= k\n for j in xrange(k):\n idx = (offset + j) % k\n if (idx != 0):\n t[i][idx] += t[i - 1][j]\n t[i][idx] %= m\nprint sum(t[n - 1]) % m\n"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\ndef factors(n):return sorted(list(set(reduce(list.__add__,([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split(' ')]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\ndef find(a,mod,n):\n rem = n - len(bin(a)[2:])\n ans = 0\n while rem:\n temp = min(rem,50)\n ans = (ans + 2**temp)%mod\n rem -= temp\n return ans\n\n\nn, k, m = li()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)"}, {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n"}, {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)"}, {"source_code": "n,k,m=map(int,input().split())\nd,r,p,P=0,0,1%k,(10**(n-1))*9\nF=[0]*k\nF[0]=1\nwhile d<n:\n\td+=1\n\tP//=10\n\tE=[0]*k\n\tif P==0:P=1\n\ti=1\n#\tprint(\"E=\",E)\n#\tprint(\"F=\",F)\n\twhile i<10:\n\t\tj=(-i*p)%k\n\t\tf=0\n\t\twhile f<k:\n\t\t\tE[f]+=F[j]\n\t\t\tf+=1\n\t\t\tj+=1\n\t\t\tif j==k:j=0\n\t\ti+=1\n\tr+=E[0]*P\n\tp=p*10%k\n\tE[0]=0\n\ti=1\n\twhile i<k:\n\t\tF[i]=(F[i]+E[i])%m\n\t\ti+=1\n#\tprint(E,P)\n\tF[0]=1\n#print(\"r=\",r)\nprint(r%m)\n#i=10**n\n#j=10**(n-1)\n#r=0\n#F=[0]*k\n#while j<i:\n#\tx=str(j)\n#\tl=len(x)\n#\ta=l\n#\twhile a:\n#\t\ta-=1\n#\t\ts=int(x[a:l])\n#\t\tif s>0 and s%k==0:\n#\t\t\tr+=1\n#\t\t\tbreak\n#\tj+=1\n#print()\n#print(r)\n\"\"\"\n3 6 9\n13 16 19\t12 15 18\n23 26 29\t21 24 27\n33 36 39\t30\n43 46 49\t42 45 48\n53 56 59\t51 54 57\n63 66 69\t60\n73 76 79\t72 75 78\n83 86 89\t81 84 87\n93 96 99\t90\n\"\"\"\n"}, {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n"}, {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n"}, {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n"}, {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n"}, {"source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)] \ns=0\nfor v in range(n):\n tens = 10**v%k\n f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\nprint(s%m)\n"}], "negative_code": [{"source_code": "n,k,m=map(int,input().split())\nd,r,p,P=0,0,1%k,(10**(n-1))*9\nF=[0]*k\nF[0]=1\nwhile d<n:\n\td+=1\n\tP//=10\n\tE=[0]*k\n\tif P==0:P=1\n\ti=1\n#\tprint(\"E=\",E)\n#\tprint(\"F=\",F)\n\twhile i<10:\n\t\tj=(-i*p)%k\n\t\tf=0\n\t\twhile f<k:\n\t\t\tE[f]+=F[j]\n\t\t\tf+=1\n\t\t\tj+=1\n\t\t\tif j==k:j=0\n\t\ti+=1\n\tr+=E[0]*P\n\tp=p*10%k\n\tE[0]=0\n\ti=1\n\twhile i<k:\n\t\tF[i]=(F[i]+E[i])%m\n\t\ti+=1\n#\tprint(E,P)\n\tF=E\n\tF[0]=1\n#print(\"r=\",r)\nprint(r%m)\n#i=10**n\n#j=10**(n-1)\n#r=0\n#F=[0]*k\n#while j<i:\n#\tx=str(j)\n#\tl=len(x)\n#\ta=l\n#\twhile a:\n#\t\ta-=1\n#\t\ts=int(x[a:l])\n#\t\tif s>0 and s%k==0:\n#\t\t\tr+=1\n#\t\t\tbreak\n#\tj+=1\n#print()\n#print(r)\n\"\"\"\n3 6 9\n13 16 19\t12 15 18\n23 26 29\t21 24 27\n33 36 39\t30\n43 46 49\t42 45 48\n53 56 59\t51 54 57\n63 66 69\t60\n73 76 79\t72 75 78\n83 86 89\t81 84 87\n93 96 99\t90\n\"\"\"\n"}, {"source_code": "n,k,m=map(int,input().split())\nd,r,p,P=0,0,1%k,(10**(n-1))*9\nF=[0]*k\nF[0]=1\nwhile d<n:\n\td+=1\n\tP//=10\n\tE=[0]*k\n\tif P==0:P=1\n\ti=1\n\twhile i<10:\n\t\tj=0\n\t\twhile j<k:\n\t\t\tE[j]+=F[(j-i*p)%k]\n\t\t\tj+=1\n\t\ti+=1\n\tr+=E[0]*P\n\tp=p*10%k\n\tE[0]=0\n\tF=E\n\tF[0]=1\nprint(r%m)\n"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nimport random\nimport operator\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn, k, m = map(int, raw_input().split())\n\nif k == 1:\n print (pow(10, n, m) - 1) % m\n quit()\n\n\ndef pow9_10(x):\n res = 1\n if x > 0:\n res *= 9\n if x > 1:\n res *= pow(10, x - 1, m)\n return res % m\n\n\ndef count_div_upto_pow10(e, kk):\n q, r = divmod(pow(10, e), kk)\n if r == 0:\n q -= 1\n return q\n\n\ndef count_div_interval(e1, e2, kk):\n return count_div_upto_pow10(e2, kk) - count_div_upto_pow10(e1, kk)\n\n\ndef cut_pow10(e):\n return pow(10, e) if e > 0 else 1\n\nres = 0\ncounts = {r: 0 for r in xrange(k)}\ncounts[0] = 1\n\nfor i in xrange(n):\n print i, \":\",\n p10 = pow(10, i)\n\n counts2 = {r: 0 for r in xrange(k)}\n for r in xrange(k):\n mind = 1 if i == n else 0\n for d in xrange(mind, 10):\n r2 = (d * pow(10, i, k) + r) % k\n counts2[r2] += counts[r]\n print counts2\n add = (counts2[0] - 1) * pow9_10(n - i - 1)\n res += add\n print \"ADD\", counts2[0], \"*\", pow9_10(n - i - 1), \"=\", add\n counts2[0] = 1\n counts = counts2\nprint res % m\n\n"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nimport random\nimport operator\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn, k, m = map(int, raw_input().split())\n\nif k == 1:\n print (pow(10, n, m) - 1) % m\n quit()\n\n\ndef pow9_10(x):\n res = 1\n if x > 0:\n res *= 9\n if x > 1:\n res *= pow(10, x - 1, m)\n return res % m\n\nres = 0\ncounts = [0] * k\ncounts[0] = 1\n\np10i = 1\nfor i in xrange(n):\n counts2 = [0] * k\n for r in xrange(k):\n mind = 1 if i == n else 0\n for d in xrange(mind, 10):\n r2 = (d * p10i + r) % k\n counts2[r2] += counts[r]\n\n add = (counts2[0] - 1) * pow9_10(n - i - 1)\n res += add\n\n counts2[0] = 1\n counts = counts2\n\n p10i = (p10i * 10) % k\nprint res % m\n\n"}, {"source_code": "def main():\n n, k, m = map(int, raw_input().split())\n if k == 1:\n print 0\n return\n if n == 1:\n print len([i for i in xrange(1, 10) if i % k]) % m\n return\n dp = [0] * k\n for i in xrange(10):\n if i % k:\n dp[i%k] += 1\n t = 10 % k\n kk = [[i * j % k for j in xrange(11)] for i in xrange(k)]\n for i in xrange(n - 1):\n ndp = [0] * k\n for j in xrange(1, k):\n for l in xrange(i == n - 2, 10):\n x = j + kk[t][l]\n if x >= k:\n x -= k\n if x:\n ndp[x] += dp[j]\n if ndp[x] >= m:\n ndp[x] -= m\n for l in xrange(i == n - 2, 10):\n if kk[t][l]:\n ndp[kk[t][l]] += 1\n dp = ndp[:]\n t = kk[t][10]\n print (9 * pow(10, n - 1, m) - sum(dp) % m + m) % m\nmain()\n"}, {"source_code": "global debug\ndebug = 0\n\nline = map(int, raw_input().split())\nn = line[0]\nk = line[1]\nm = line[2]\n\n#r = [[0 for _ in xrange(k)] for _ in xrange(n)]\n#r = [0 for _ in xrange(n)]\nt = [[0 for _ in xrange(k)] for _ in xrange(n)]\n\n#base = 1\n#for i in xrange(n):\n# base *= 10\n# top = base - 1\n# r[i] = (int(top / k) + 1) % m\n #r[0][i % k] += 1\n\n#base = 1\n#for i in xrange(1, n):\n #base *= 10\n #if (i == n - 1): start = 1\n #else: start = 0\n #for c in xrange(start, 10):\n #offset = (c * base) % k\n #for j in xrange(k):\n ##for pre in xrange(i):\n #r[i][j] += r[i - 1][(j - offset) % k]\n #r[i][j] %= m\n#if (debug >= 2): print r\n\nt[0][0] = 9 // k\nbase = 1\nfor i in xrange(1, n):\n base *= 10\n if (i == n - 1):\n t[i][0] = (9 * base // k) % m\n start = 1\n else:\n t[i][0] = ((10 * base - 1) // k) % m\n start = 0\n baser = base % k\n offset = ((start - 1) * baser) % k\n for c in xrange(start, 10):\n offset += baser\n offset %= k\n for j in xrange(k):\n idx = (offset + j) % k\n if (idx != 0):\n t[i][idx] += t[i - 1][j]\n t[i][idx] %= m\nif (debug >= 2): print t\nprint sum(t[n - 1]) % m\n"}], "src_uid": "656bf8df1e79499aa2ab2c28712851f0"} {"source_code": "a=list(map(int,input().split(':')))\nprint((a[0]%12)*30+a[1]/2,a[1]*6)\n", "positive_code": [{"source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\n\nif __name__ == \"__main__\":\n params = raw_input().rsplit(':')\n hour = float(params[0])\n min = float(params[1])\n\n hour = ((hour-12)/12+min/(60*12))*360\n if hour<0:\n hour = 360 + hour\n min = min*6\n print str(hour)+\" \"+str(min)"}, {"source_code": "from math import pi\n\nh, m = raw_input().split(':')\n\nh = float(h) % 12\nm = float(m)\n\nan_m = m / 60 * 360\nan_h = h / 12 * 360 + an_m / 12\n\nprint an_h, an_m\n"}, {"source_code": "s = raw_input()\ni = s.index(':')\nh = int(s[:i])\nm = int(s[i+1:])\n\nh1 = ((h + (m * 1.0) / 60))\nif h1 >= 12: h1 -= 12\nprint h1 * 30, m * 6"}, {"source_code": "##B\nh,m=map(int,input().split(':'))\nif (h==12 or h==0):\n h=0\nh=(h+m/60)\nh=h*360/12\nm=m*360/60\nif h>360:\n h-=360\nprint(h,m)\n"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nhh, mm = tuple(map(int, input().split(':')))\nprint(30 * (hh % 12) + 0.5 * mm, 6 * mm)\n"}, {"source_code": "input_string = str(input())\ntime_list = input_string.split(':')\nhour = int(time_list[0])%12\nminutes = int(time_list[1])%60\nhour_degree = (30*hour) + (minutes/2)\nminute_degree = minutes*6\nprint(str('{0:g}'.format(hour_degree)) + ' ' + str(minute_degree))\n"}, {"source_code": "s = raw_input()\nh, m = [int(i) for i in s.split(':')]\nM = m*6\nH = 30*(h % 12) + m*.5\nprint H,M\n"}, {"source_code": "\n\nh, m = map(int, raw_input().split(':'))\nif h >= 12: h -= 12\n\n\nx = 30*h + 30*(float(m)/60)\nif not x - int(x):\n x = int(x)\n\nprint x, (360/60)*m\n\n"}, {"source_code": "s = raw_input().split(\":\")\nh,m = int(s[0]),int(s[1])\n\nif h == 12 and m == 0:\n print \"0 0\" \nelif h >= 12:\n h = h%12\n print h*30+m*0.5,m*6\nelse:\n print h*30+m*0.5,m*6\n"}, {"source_code": "h, m = (int(i) for i in input().split(\":\"))\n\nnh = h*30 + (30*m)/60\nnm = 6*m\n\nprint(nh%360, nm)\n"}, {"source_code": "h, m = map(int, raw_input().split(':'))\nh = (h + 12) % 24\nprint(str(h * 30 % 360 + m * 0.5) + ' ' + str(m * 6))\n"}, {"source_code": "import sys\n#sys.stdin = open ('input.txt')\n#sys.stdout = open ('output.txt', 'w')\n\nh, m = map (float, raw_input ().split (':'))\nh += m / 60.\nx = 30. * (h % 12)\ny = 6. * m\nprint x, y\n"}, {"source_code": "takes = str(input())\nclocks = takes.split(':')\nh = int(clocks[0])\nif h>12:\n h = h-12\nm = int(clocks[1])\ntemp = 30*h\nif h == 12 :\n temp = 0 \nhans = temp + 0.5*m\nmans = 6*m\nprint(hans, mans)"}, {"source_code": "inp = input().split(':')\nhh = int(inp[0])\nmm = int(inp[1])\n\nif hh>=12:\n hh=hh-12\n\ndegreesHH = hh*30+mm*0.5\nif(degreesHH%1==0):\n degreesHH = int(degreesHH)\ndegreesHH = str(degreesHH)\ndegreesMM = str(mm*6)\nprint(degreesHH+\" \"+degreesMM)\n"}, {"source_code": "hours, mins = input().split(':')\n\nhours = int(hours)\nmins = int(mins)\n\n\nif hours >= 12:\n hours -= 12\n\nhour_rotation = hours / 12 * 360 + (mins / 60 * 360/12) \nmin_rotation = mins / 60 * 360\n\nprint(hour_rotation)\nprint(min_rotation)\n"}, {"source_code": "t = raw_input()\nt = t.strip().split(\":\")\nhh = float(t[0])\nmm = float(t[1])\n\nhh_mm = mm/60.0\n\nhh = hh+hh_mm\n\nhh_angle = (hh/12)*360\n\nmm_angle = (mm/60)*360\n\nhh_angle = hh_angle%360\nmm_angle = mm_angle%360\n\nprint hh_angle, mm_angle\n"}, {"source_code": "h,m=map(int,raw_input().split(':'))\nif h>=12: h-=12\nprint (h*60+m)/2.0, 6*m\n"}, {"source_code": "\nh,m = (int(x) for x in raw_input().split(':'))\nh %= 12\nrm = m*6\nrh = h*30\n\nif m%2==1: rh += m/2.0\nelse: rh += m/2\n\nprint rh,rm\n"}, {"source_code": "import sys\n\nh, m = map(int, sys.stdin.readline().strip().split(':'))\n\nh %= 12\nprint ' '.join(map(str, [(h + m / 60.0) * 30, m * 6]))\n"}, {"source_code": "h, m = map(float, raw_input().split(':'))\nh %= 12\n\nx = 360 / 12 * h + 360.0 / 12 / 60 * m\ny = 360 / 60 * m\n\nprint x, y"}, {"source_code": "import sys\n\nh, m = sys.stdin.readline().strip().split(\":\")\n\nh = int(h)\nm = int(m)\n\nif (h>=12):\n h = h - 12\nah = (h*60 + m)*0.5\nam = m*6\n\nprint ah, \" \", am"}, {"source_code": "h, m = map(int, raw_input().split(':'))\nprint (h * 30 + m * 0.5) % 360, m * 6"}, {"source_code": "import fileinput\n\nline = fileinput.input()\nv = line[0].split(':')\nhh = float(v[0])\nnn = float(v[1])\ny = 6 * nn\nx = (30 * hh + 1.0 / 12.0 * y) % 360\nprint (str(x) + ' ' + str(y))\n\n"}, {"source_code": "line = raw_input().split(':')\n\nh = int(line[0])\nm = int(line[1])\n\nif h >= 12:\n h -= 12\n\nmans = 6 * m\nhans = 30 * h + m / 2.0\nif hans == int(hans):\n hans = int(hans)\n\nprint str(hans) + \" \" + str(mans)"}, {"source_code": "h, m = map(int, raw_input().split(\":\"))\nh = h % 12\nprint h * 30 + m / 2.0, m * 6 \n"}, {"source_code": "import sys\nimport math\n\n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\ns = lines[0].split(\":\")\nh = float(s[0]) % 12.0\nm = float(s[1])\n\nprint \"%g %g\" % ((h + m / 60) / 12.0 * 360.0, m / 60.0 * 360.0)\n\n"}, {"source_code": "s=input()\nh=int(s[:2])\nm=int(s[3:])\nprint(h%12*30+m/2,m*6)"}, {"source_code": "import sys\nimport string\n\nreadLineInt = lambda: map( int, raw_input().split())\nreadLineStr = lambda: raw_input.split()\nreadTextInt = lambda: map( int, sys.stdin.read().split())\nreadTextStr = lambda: sys.stdin.read().split()\n\ndef main(): \n h, m = map( float, raw_input().split(':'))\n if h >= 12:\n h -= 12 \n print h * 30 + m / 2, m * 6 \n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "HH, MM = map(int, raw_input().split(':'))\nx, y = 0.0, 0.0\nx = (HH % 12) / 12.0 * 360 + (MM % 60) / 60.0 * (360 / 12)\ny = (MM % 60) / 60.0 * 360\nprint x, y"}, {"source_code": "time = input()\n\nhh = int(time[:2])\nmm = int(time[3:])\n\nif hh >= 12:\n\tr = int(hh)-12\nelse:\n\tr = int(hh)\n\nprint(r*30+int(mm)/2,mm*6)"}, {"source_code": "h,m = map(int, raw_input().split(\":\"))\nprint (h%12)*30+0.5*m, m*6"}, {"source_code": "def main():\n\tx,y = map(int, raw_input().split(':'))\n\tprint (x%12)*30 + y*0.5, y*6\n\n\nmain()"}, {"source_code": "def main():\n\th, m = map(int, raw_input().split(\":\"))\n\tx = h % 12 * 30 + m / 2.0\n\ty = m * 6\n\tprint x, y\n\nif __name__ == \"__main__\": main()\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nh, m = (int(i) for i in raw_input().split(':'))\n\nif h >= 12:\n h -= 12\n\nprint(str(30 * h + m * 0.5) + ' ' + str(6 * m))\n"}, {"source_code": "hh,mm = [float(i) for i in raw_input().split(':')]\na1 = 360 * (hh + mm/60)/12\na2 = 360 * mm / 60\n\nwhile a1 >= 360:\n\ta1 -= 360\nwhile a2 >= 360:\n\ta2 -= 360\nprint a1,a2\n"}, {"source_code": "\n\nline_parts = raw_input().split(':')\nhour = float(line_parts[0])\nmins = float(line_parts[1])\n\nmin_rotation = (360.0/ 60.0) * mins\nhour_rotation = ((360.0 / 12.0) * hour) + ((30.0/60.0)*mins)\n\nprint hour_rotation % 360.0, min_rotation % 360.0\n"}, {"source_code": "s=raw_input().split(':')\nh=int(s[0])%12\nm=int(s[1])\n\nif(m%2):\n\tprint h*30+m/2.0,\nelse:\n\tprint h*30+m/2,\nprint m*6\n"}, {"source_code": "time = input()\nhours = int(time[0]) * 10 + int(time[1])\nminutes = int(time[3]) * 10 + int(time[4])\nhours = hours % 12\nangle1 = hours * 30 + minutes // 2\nif minutes % 2 == 1:\n angle1 += 0.5\nangle2 = minutes * 6\nprint(angle1, angle2)\n"}, {"source_code": "s=input()\nif s[0]=='0':\n h=int(s[1])\nelse:\n h=int(s[0:2])\nif s[3]=='0':\n m=int(s[4])\nelse:\n m=int(s[3:5])\nif h>12:\n h=h-12\nif h==12:\n h=0\nhangle=(h+m/60)*30\nmangle=m*6\nprint(hangle,mangle)\n"}, {"source_code": "u=raw_input().split(\":\")\nh=float(u[0])\nm=float(u[1])\n\nm1=m*360/60\nif int(m1)==m1:\n\tm1=int(m1)\n\nh1=(h/12*360+m/60*360/12)%360\nif int(h1)==h1:\n\th1=int(h1)\nprint h1,m1\n"}, {"source_code": "x=input()\nmin=int(x[3:])\nhour=int(x[:2])\nif hour>=12:\n\thour-=12\n\nm=min/2\nk=int(min/2)\nif(m==k):\n\thour=hour*30+k\nelse:\n\thour=hour*30+m\nprint(hour,\" \",min*6)\n"}, {"source_code": "s=input()\nhr=int(s[0:2])\nmin=int(s[3:])\nif(hr>=12):\n hr-=12\nprint((hr*60+min)/2,int(min*6)) "}, {"source_code": "hh, mm = map(int, input().split(\":\"))\n\nprint((hh%12)*30 + mm/2, mm*6)\n"}, {"source_code": "'''\nCreated on 2011-4-19\n\n@author: Administrator\n'''\nstr = raw_input()\nlen = len(str)\n\ns1 = str[0:2]\ns2 = str[3:5]\nnum1 = int(s1)\nnum2 = int(s2)\n\ndef count_x(hous,min):\n hous = hous % 12\n return hous * 30 + min / 2.0\n \n\ndef count_y(hous,min):\n return min * 6\n\nprint count_x(num1,num2),count_y(num1,num2)"}, {"source_code": "s=input()\nh=int(s[:2])\nm=int(s[3:])\nprint(h%12*30+m/2,m*6)"}, {"source_code": "from sys import stdin\n\n(hh, mm) = [int(x) for x in stdin.readline().strip().split(':')]\n\nhh %= 12\n\nprint(str((hh*60.0+mm)*360/(60*12))+' '+str(mm*6))\n"}, {"source_code": "\n\nH, M = map(int, input().split(':'))\n\ncur = (H * 60 + M) % (12 * 60)\n\nang1 = cur % (12 * 60) / (12 * 60) * 360\nang2 = (cur % 60) / 60 * 360\n\nprint(ang1, end=' ')\nprint(ang2)"}, {"source_code": "h,m=map(int,raw_input().split(\":\"));print h%12*30+m/2.,m*6"}, {"source_code": "if __name__ == '__main__':\n ti = input()\n ti = ti.split(':')\n hr = int(ti[0])\n mi = int(ti[1])\n turn_hour = 0\n turn_min = mi * 6\n turn_hour = (hr%12)*30 + mi*0.5\n \n print(turn_hour, turn_min)\n"}, {"source_code": "HH, MM = map(int, input().split(':'))\n\nprint(30*(HH%12)+MM/2, 6*MM)"}, {"source_code": "a, b = map(int, input().split(':'))\nprint(30 * (a % 12) + b / 2, 6 * b) "}, {"source_code": "s=input()\n\nh=int(s[:2])\n\nm=int(s[3:])\n\nprint(h%12*30+m/2,m*6)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "#Problem 80B\n\ndef input():\n\tst = raw_input().split(\":\")\n\tif(st[0][0] == \"0\"): st[0] = st[0][1:]\n\tif(st[1][0] == \"0\"): st[1] = st[1][1:]\n\treturn (eval(st[0]), eval(st[1]))\n\ndef solve():\n\th, m = input()\n\th %= 12\n\th += float(m) / 60\n\treturn (h * 30, m * 6)\n\n\nres = solve()\nif(res[0] - int(res[0]) > 0): print '%0.1f %i' % res\nelse: print '%0.0f %i' % res\n"}, {"source_code": "s=input()\n\nh=int(s[:2])\nm=int(s[3:])\nif h>=12:\n h=h%12\nm1=6*m\nh1=30*h+(1/12)*m1\nprint(h1,m1)\n"}, {"source_code": "a, b = map(int, input().split(':'))\nprint(30*(a-12*(a>11)+b/60), 6*b)"}, {"source_code": "hh,mm=map(int,raw_input().split(':'))\nhh%=12\nhd=hh*30+mm*.5\nmd=mm*6\nprint hd,md\n"}, {"source_code": "s = input()\nh = int(s[:2])\nm = int(s[3:])\nd1 = 30 * (h + m/60)\nd2 = 6 * m\nif d1 >= 360:\n d1 -= 360\nif d2 >= 360:\n d2 -= 360\nprint(str(d1) + \" \" + str(d2))"}, {"source_code": "h, m = map(int, raw_input().split(\":\"))\nprint h % 12 * 30 + m / 2., m * 6 \n"}, {"source_code": "def main():\n\tx,y = map(int,input().split(\":\"))\n\t\n\tx = x%12 + 1*(y/60)\n\tprint(x*30,(y*360)/60)\n\nmain()\n"}, {"source_code": "h,m = map(int, input().split(':'))\nif h >=12:\n h-=12\nprint(float(30*h+m/2), m*6)\n "}, {"source_code": "s = input().strip()\nhour, minute = map(int, s.split(':'))\nif hour > 12:\n\thour -= 12\nhAngle = 0.5*(hour*60 + minute)\nmAngle = 6*minute\n\nif hAngle >= 360:\n\thAngle = hAngle-360\n\nif mAngle >= 360:\n\tmAngle = mAngle-360\n\nprint(hAngle, mAngle)"}, {"source_code": "for _ in range(1):\n s=input()\n h=(((int)(s[0]))*10)+((int)(s[1]))\n if h>=12:\n h-=12\n m=(((int)(s[3]))*10)+((int)(s[4]))\n y=m*6\n x=30*h+(m/2.0);\n print(x,y,end=' ')"}, {"source_code": "import sys\nfrom array import array # noqa: F401\n\n\ndef input():\n return sys.stdin.buffer.readline().decode('utf-8')\n\n\nh, m = map(int, input().split(':'))\nh %= 12\nprint((h * 60 + m) / 2, m * 6)\n"}, {"source_code": "i = input()\nsarr = i.split(\":\")\nt = int(sarr[0])\nl = int(sarr[1])\nif t >= 12:\n t -= 12\nang2 = 6*l\ntempAng = 30*(l/60)\nang1 = (30*t) + tempAng\nif ang1==int(ang1):\n ang1=int(ang1)\nprint(str(ang1)+\" \"+str(int(ang2)))"}, {"source_code": "a,b=map(int,input().split(\":\"))\nx,y=12,00\nm=((b-y)%60)*6\nh=((a-x)%12 + (b/60))*30\nprint(h,m)"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef solve(s):\n h = int(s[0:2])\n h %= 12\n m = int(s[3:])\n h = (h * 60 + m) * (360) / (60 * 12)\n m = m * 360 / 60\n return (h, m)\n\ndef main():\n ans = solve(input())\n print('%.10f %.10f' % (ans[0], ans[1]))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "s = input()\nh = (int(s[:2]))%12\nm = int(s[3:])\nh += m/60\nprint(h*5*6, m*6)"}, {"source_code": "import sys\n\ndef ans(x):\n minutes = (x[1])*6.0\n hours = (x[0]%12)*30\n extra = ((x[1])*(0.5))\n hours+=extra\n \n check1 = check(hours)\n check2 = check(minutes) \n if check1:\n hours = int(hours)\n \n if check2:\n minutes = int(minutes)\n \n return [hours, minutes]\n\ndef check(x):\n out = str(x)\n k = out.strip().split('.')\n k = k[1]\n for i in range(len(k)):\n if k[i] is not '0':\n return False\n \n return True\n\nx = list(map(int, input().strip().split(':')))\n\nout = ans(x)\nprint(out[0], end = ' ')\nprint(out[1])"}, {"source_code": "time = map(int, str(raw_input()).split(':'))\ntime[0] %= 12\nha = 30*time[0] + time[1]/2.0\n#if(ha%int(ha) == 0):\n# print int(ha), time[1]*6\n#else:\nprint round(ha,1), time[1]*6\n"}], "negative_code": [{"source_code": "h, m = (int(i) for i in input().split(\":\"))\n\nnh = h*30 + (30*m)/60\nnm = 6*m\n\nif nh == 360:\n nh = 0\nprint(nh, nm)\n"}, {"source_code": "takes = str(input())\nclocks = takes.split(':')\nh = int(clocks[0])\nm = int(clocks[1])\ntemp = 30*h\nif h == 12 :\n temp = 0 \nif m != 0:\n hans = temp + 30/(60/m)\n mans = 360/(60/m)\n print(hans, mans)\nelse:\n print(temp,m)"}, {"source_code": "takes = str(input())\nclocks = takes.split(':')\nh = int(clocks[0])\nm = int(clocks[1])\nif m != 0:\n temp = 30*h\n hans = temp + 30/(60/m)\n mans = 360/(60/m)\n print(hans, mans)\nelse:\n if(h*30)!=360:\n print(h*30,m)\n else:\n print(0,m)"}, {"source_code": "clock = input()\nhours, minutes = clock.split(':')\nhours = int(hours)\nminutes = int(minutes)\n\nif hours == 12:\n hours_angle = 0\nelse:\n hours_angle = (hours * 30) + ((minutes / 60) * 30)\n\nif minutes == 0:\n minutes_angle = 0\nelse:\n minutes_angle = (minutes / 60) * 360\n\nprint(hours_angle, \" \", minutes_angle)\n"}, {"source_code": "clock = input()\nhours, minutes = clock.split(':')\nhours = int(hours)\nminutes = int(minutes)\n\nif hours == 12:\n hours_angle = 0\nelse:\n hours_angle = (hours * 30) + ((minutes / 60) * 30)\n\nif minutes == 0:\n minutes_angle = 0\nelse:\n minutes_angle = (minutes / 60) * 360\n\nprint(hours_angle, \" \", minutes_angle)\n"}, {"source_code": "clock = input()\nhours, minutes = clock.split(':')\nhours = int(hours)\nminutes = int(minutes)\n\nif hours == 0:\n hours_angle = 0\nelse:\n hours_angle = (hours * 30) + ((minutes / 60) * 30)\n\nif minutes == 0:\n minutes_angle = 0\nelse:\n minutes_angle = (minutes / 60) * 360\n\nprint(hours_angle, \" \", minutes_angle)"}, {"source_code": "clock = input()\nhours, minutes = clock.split(':')\nhours = int(hours)\nminutes = int(minutes)\n\nif hours == 12:\n hours_angle = ((minutes / 60) * 30)\nelse:\n hours_angle = (hours * 30) + ((minutes / 60) * 30)\n\nif minutes == 0:\n minutes_angle = 0\nelse:\n minutes_angle = (minutes / 60) * 360\n\nprint(hours_angle, \" \", minutes_angle)\n"}, {"source_code": "clock = input()\nhours, minutes = clock.split(':')\nhours = int(hours)\nminutes = int(minutes)\n\nif hours == 12:\n hours_angle = 0\nelse:\n hours_angle = (hours * 30) + ((minutes / 60) * 30)\n\nif minutes == 0:\n minutes_angle = 0\nelse:\n minutes_angle = (minutes / 60) * 360\n\nprint(hours_angle, \" \", minutes_angle)"}, {"source_code": "clock = input()\nhours, minutes = clock.split(':')\nhours = int(hours)\nminutes = int(minutes)\n\nif hours == 12:\n hours_angle = ((minutes / 60) * 30)\nelse:\n hours_angle = (hours * 30) + ((minutes / 60) * 30)\n\nif minutes == 0:\n minutes_angle = 0\nelse:\n minutes_angle = (minutes / 60) * 360\n\nprint(hours_angle, \" \", minutes_angle)\n"}, {"source_code": "h,m=map(int,input().split(\":\"))\nif h==12: h=0\nh=(h*60+m)/60\nhl=h*(360//12)\nml=m*(360//60)\nprint(hl,ml)\n"}, {"source_code": "time = input()\n\nhh = int(time[:2])\nmm = int(time[3:])\n\nif hh > 12:\n\tr = int(hh)-12\nelse:\n\tr = int(hh)\n\nprint(r*30+int(mm)/2,mm*6)"}, {"source_code": "l=[int(x) for x in input().split(':')]\na=l[0]\nb=l[1]\np=[]\nif a==12:\n p.append((b/60)*30)\nelse:\n p.append((a*30)+(b/60)*30)\nif b==0:\n p.append(0)\nelse:\n p.append(b*6)\nfor h in p:\n\tprint(h,end=' ')"}, {"source_code": "l=[int(x) for x in input().split(':')]\na=l[0]\nb=l[1]\np=[]\nif a==12:\n p.append(0)\nelse:\n p.append((a*30)+(b/60)*30)\nif b==0:\n p.append(0)\nelse:\n p.append(b*6)\nfor h in p:\n\tprint(h,end=' ')"}, {"source_code": "l=[int(x) for x in input().split(':')]\na=l[0]\nb=l[1]\np=[]\np.append((a*30)+(b/60)*30)\np.append(b*6)\nfor h in p:\n\tprint(h,end=' ')"}, {"source_code": "s=input()\n\nh=int(s[0]+s[1])-12\nif(h<0):\n h+=24\nif(h>12):\n h-=12\nm=int(s[3]+s[4])\n\nhh=30*h+(m*0.5)\nmm=6*m\n\nprint(hh,mm)\n"}, {"source_code": "s=input()\nif s[0]=='0':\n h=int(s[1])\nelse:\n h=int(s[0:2])\nif s[3]=='0':\n m=int(s[4])\nelse:\n m=int(s[3:5])\nif h==12:\n h=0\nhangle=(h+m/60)*30\nmangle=m*6\nprint(hangle,mangle)\n"}, {"source_code": "x=input()\nmin=int(x[3:])\nhour=int(x[:2])\n\n\nif(hour!=12):\n\tm=min/2\n\tk=int(min/2)\n\tif(m==k):\n\t\thour=hour*30+k\n\telse:\n\t\thour=hour*30+m\n\tprint(hour,\" \",min*6)\nelse:\n\tm=min/2\n\tk=int(min/2)\n\thour=m\n\tif(m==k):\n\t\thour=k\n\tprint(hour,\" \",min*6)"}, {"source_code": "hour, minute = map(int, input().split(\":\"))\nif hour != 12:\n\thourDegree = (hour / 12)*360 \nelse: \n\thourDegree = 0\nif minute != 0:\n\tminuteDegree = (minute/60)*360 \nelse: \n\tminuteDegree = 0\n\ninterval = minute/60 * 30\nhourDegree += interval\nif int(hourDegree) == hourDegree:\n\thourDegree = int(hourDegree)\nif int(minuteDegree) == minuteDegree:\n\tminuteDegree = int(minuteDegree)\nprint(hourDegree, minuteDegree)"}, {"source_code": "s = input()\nh = int(s[0]) * 10 + int(s[1])\nm = int(s[3]) * 10 + int(s[4])\n\nang1 = round((h + m / 60) * 30)\nang2 = m * 6\n\nif h == 12:\n ang1 = 0\n\nprint(ang1, ang2)\n"}, {"source_code": "s = input()\nh = int(s[0]) * 10 + int(s[1])\nm = int(s[3]) * 10 + int(s[4])\n\nang1 = (h + m / 60) * 30\nang2 = m * 6\n\nif h == 12:\n ang1 = 0\n\nprint(ang1, ang2)\n"}, {"source_code": "time = input()\nh = int(time[0])*10 + int(time[1])\nm = int(time[3])*10 + int(time[4])\nh = h % 12\nangle1 = h*30 + m//2\nif m%2 == 1:\n angle1 += 0.5\nangle2 = min(360 - m*6, m*6)\nprint(angle1, angle2)\n"}, {"source_code": "if __name__ == '__main__':\n ti = input()\n ti = ti.split(':')\n hr = int(ti[0])\n mi = int(ti[1])\n turn_min = 0\n turn_hour = 0\n try:\n turn_min = 360/(60/(mi%60))\n except Exception:\n turn_min = 0\n \n try:\n turn_hour = (360/(12/(hr%12))) + mi * 0.5\n except Exception:\n turn_hour = 0\n \n print(turn_hour, turn_min)\n"}, {"source_code": "if __name__ == '__main__':\n ti = input()\n ti = ti.split(':')\n hr = int(ti[0])\n mi = int(ti[1])\n turn_min = 0\n turn_hour = 0\n if mi % 60 != 0:\n turn_min = 360/(60/(mi%60))\n if hr % 12 != 0:\n turn_hour = (360/(12/(hr%12))) + mi * 0.5\n \n print(turn_hour, turn_min)\n"}, {"source_code": "h,minutes=[int(element) for element in input().split(':')]\n\nanswer_minutes=minutes/60*360\nanswer_hours=h/12*360+360/12*minutes/60\n\nprint(answer_hours,answer_minutes)"}, {"source_code": "s=input()\n\nh=int(s[:2])\nm=int(s[3:])\n\nm1=6*m\nif h==12:\n h1=(1/12)*m1\nelse: \n h1=30*h+(1/12)*m1\nprint(h1,m1)\n"}, {"source_code": "s=input()\n\nh=int(s[:2])\nm=int(s[3:])\n\nm1=6*m\nh1=30*h+(1/12)*m1\nif(h==12):\n print(0,m1)\nelse:\n print(h1,m1)\n"}, {"source_code": "s = input()\nh = int(s[:2])\nm = int(s[3:])\nd1 = 30 * (h + m/60)\nd2 = 6 * m\nif d1 == 360:\n d1 = 0\nif d2 == 360:\n d2 = 0\nprint(str(d1) + \" \" + str(d2))"}, {"source_code": "s = input()\nh = int(s[:2])\nm = int(s[3:])\nd1 = 30 * (h + m/60)\nd2 = 6 * m\nif d1 > 360:\n d1 -= 360\nif d2 > 360:\n d2 -= 360\nprint(str(d1) + \" \" + str(d2))"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(H,M):\n vh = 360.0 / (12*60)\n vm = 360.0 / (60)\n ah = vh * (H*60+M)\n am = vm * M\n if ah > 360.0 - 0.000000001:\n ah = 0.0\n if am > 360.0 - 0.000000001:\n am = 0.0\n return (ah,am)\n\nT = [int(s) for s in input.readline().strip().split(':')]\nH = T[0]\nM = T[1]\nassert 0<=H and H<=23\nassert 0<=M and M<=59\n\nx,y = solve(H,M)\noutput.write('%.9f\\n' % x)\noutput.write('%.9f\\n' % y)\n"}, {"source_code": "from math import pi\n\nh, m = raw_input().split(':')\n\nh = float(h) % 12\nm = float(m)\n\nan_m = m / 60 * 360\nan_h = h / 12 * 360 + an_m / 12\n\nprint an_h, an_m\nprint h, m\n"}, {"source_code": "import sys\n\ndef readInt(delimiter) :\n return map(int, raw_input().split(delimiter))\n\nhour, minute = readInt(':')\n\nangle_m = 6 * minute\nangle_h = 30.0 * hour + (minute/60.0 * 30.0)\n\nprint angle_h, angle_m\n"}, {"source_code": "#!/usr/bin/python\ns = raw_input().split(\":\")\nh,m = int(s[0]),int(s[1])\n\nif h == 12 and m == 0:\n print \"0 0\" \nelif h > 12:\n h = h%12\n print h*30+m*0.5,m*6\n"}, {"source_code": "import sys\n#sys.stdin = open ('input.txt')\n#sys.stdout = open ('output.txt', 'w')\n\nh, m = map (float, raw_input ().split (':'))\nh += m / 60.\nif h not in [12, 0]:\n\tx = 30. * h\nelse:\n\tx = 0\nif m not in [12, 0]:\n\ty = 6. * m\nelse:\n\ty = 0\n\nprint x, y\n"}, {"source_code": "import sys\n#sys.stdin = open ('input.txt')\n#sys.stdout = open ('output.txt', 'w')\n\nh, m = map (float, raw_input ().split (':'))\nh += m / 60.\nif h not in [24, 0]:\n\tx = 30. * h\nelse:\n\tx = 0\nif m not in [60, 0]:\n\ty = 6. * m\nelse:\n\ty = 0\n\nprint x, y\n"}, {"source_code": "import sys\n#sys.stdin = open ('input.txt')\n#sys.stdout = open ('output.txt', 'w')\n\nh, m = map (float, raw_input ().split (':'))\nh += m / 60.\nif h not in [12, 24, 0]:\n\tx = 30. * h\nelse:\n\tx = 0\nif m not in [60, 0]:\n\ty = 6. * m\nelse:\n\ty = 0\n\nprint x, y\n"}, {"source_code": "h, m = map(float, raw_input().split(':'))\n\nx = 360 / 12 * h + 360.0 / 12 / 60 * m\ny = 360 / 60 * m\n\nprint x, y"}, {"source_code": "import fileinput\n\nline = fileinput.input()\nv = line[0].split(':')\nhh = float(v[0])\nnn = float(v[1])\ny = 6 * nn\nx = 30 * hh + 1.0 / 12.0 * y\nprint (str(x) + ' ' + str(y))\n\n"}, {"source_code": "import string\nimport math\n\nn = raw_input()\nx = n.split(':')\na = int(x[0])\nb = int(x[1])\nif(a == 12):\n\ta = 0\nif(b == 60):\n\tb = 0\n\n\nif(math.floor(float(a*60+b)/2) == math.ceil(float(a*60+b)/2)):\n\ta1 = (a*60+b)/2\n\ta2 = b*6\n\tprint(str(a1)+\" \"+str(a2))\nelse:\n\ta1 = ((a*60+b)/2.0)\n\ta2 = b*6\n\tprint(str(a1)+\" \"+str(a2))"}, {"source_code": "import string\nimport math\n\nn = raw_input()\nx = n.split(':')\na = int(x[0])\nb = int(x[1])\nif(a == 12):\n\ta = 0\nif(b == 60):\n\tb = 0\n\n\nif(math.floor(float(a*60+b)/2) == math.ceil(float(a*60+b)/2)):\n\ta1 = (a*60+b)/2\n\ta2 = b*6\n\tprint(a1,a2)\nelse:\n\ta1 = float(a*60+b)/2\n\ta2 = b*6\n\tprint(a1[0],a2[0])"}, {"source_code": "x=(input())\na=int(x[0:2])\nb=int(x[3:])\nif a>12:\n a-=12\nlol=a*30+0.5*b\nyo=b*6\nif a==12:\n lol=0\nprint(lol,yo)"}, {"source_code": "x=(input())\na=int(x[0:2])\nb=int(x[3:])\nlol=a*30+0.5*b\nyo=b*6\nif a==12:\n lol=0\nprint(lol,yo)"}, {"source_code": "x=(input())\na=int(x[0:2])\nb=int(x[3:])\nlol=a*30+0.5*b\nyo=((b-b%5)//5)*30+b%5*6\nprint(lol,yo)"}, {"source_code": "x=(input())\na=int(x[0:2])\nb=int(x[3:])\nif a>12:\n a-=12\nlol=a*30+0.5*b\nyo=b*6\nprint(lol,yo)"}, {"source_code": "x=(input())\na=int(x[0:2])\nb=int(x[3:])\nlol=a*30+0.5*b\nyo=((b-b%5)//5)*30+b%5*6\nif a==12:\n lol=0\nprint(lol,yo)"}, {"source_code": "s = input().strip()\nhour, minute = map(int, s.split(':'))\nif hour > 12:\n\thour -= 12\nhAngle = hour*30 + minute/2\nmAngle = 6*minute\n\nif hAngle == 360:\n\thAngle = 0\n\nif mAngle > 360:\n\tmAngle = 0\n\nprint(hAngle, mAngle)"}, {"source_code": "s = input()\na = s.split(':')\na = [int(a[0]), int(a[1])]\nif a[0] == 12:\n a[0] = 0\nm = (a[1]*6)\nh = (a[0]*30) + (a[1]/2)\nif h%1 == 0:\n h = int(h)\nprint(h, m)"}, {"source_code": "import sys\nimport os\nfrom io import IOBase, BytesIO\n# import heapq\nimport math\n# import collections\n# import itertools\n# import bisect\nmod = 10 ** 9 + 7\npie = 3.1415926536\n# import resource\n# resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n# import threading\n# threading.stack_size(2**27)\n# import sys\n# sys.setrecursionlimit(10**6)\n# fact=[1]\n# for i in range(1,1000001):\n# fact.append((fact[-1]*i)%mod)\n# ifact=[0]*1000001\n# ifact[1000000]=pow(fact[1000000],mod-2,mod)\n# for i in range(1000000,0,-1):\n# ifact[i-1]=(i*ifact[i])%mod\n# from random import randint as rn\n# from Queue import Queue as Q\n\n\ndef modinv(n, p):\n return pow(n, p-2, p)\n\n\ndef ncr(n, r, p): # for using this uncomment the lines calculating fact and ifact\n t = ((fact[n])*((ifact[r]*ifact[n-r]) % p)) % p\n return t\n\n\ndef ain(): # takes array as input\n return list(map(int, sin().split()))\n\n\ndef sin():\n return input().strip()\n\n\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\n\n\ndef read2DIntArray(row, col):\n arr = []\n for i in range(0, row):\n temp = list(map(int, sin().split()))\n arr.append(temp)\n\n return arr\n\n\ndef read2DCharArray(row, col):\n arr = []\n for i in range(0, row):\n temp = str(sin())\n arr.append(temp)\n\n return arr\n\n\n# Smallest number by rearranging digits of a given number (without trailing zeros):-\n\n\ndef smallestNumber(n):\n lst = list(str(n))\n lst.sort()\n\n tmp = \"\"\n for i, n in enumerate(lst):\n if (n != '0'):\n tmp = lst.pop(i)\n break\n\n return str(tmp) + ''.join(lst)\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n\ndef main():\n s = sin()\n hh, mm = map(int, s.split(\":\"))\n if hh > 12:\n hh = hh - 12\n m = mm * 6\n h = (hh * 30) + ((mm / 60) * 30)\n\n if hh == 12:\n h = 360 - h\n\n print(str(h) + \" \" + str(m))\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n# Python 2 and 3 footer by Pajenegod and c1729\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2),\n super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill():\n pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill()\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\ndef input(): return sys.stdin.readline().rstrip('\\r\\n')\n\n\nif __name__ == '__main__':\n main()\n# threading.Thread(target=main).start()\n"}, {"source_code": "import sys\nimport os\nfrom io import IOBase, BytesIO\n# import heapq\nimport math\n# import collections\n# import itertools\n# import bisect\nmod = 10 ** 9 + 7\npie = 3.1415926536\n# import resource\n# resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n# import threading\n# threading.stack_size(2**27)\n# import sys\n# sys.setrecursionlimit(10**6)\n# fact=[1]\n# for i in range(1,1000001):\n# fact.append((fact[-1]*i)%mod)\n# ifact=[0]*1000001\n# ifact[1000000]=pow(fact[1000000],mod-2,mod)\n# for i in range(1000000,0,-1):\n# ifact[i-1]=(i*ifact[i])%mod\n# from random import randint as rn\n# from Queue import Queue as Q\n\n\ndef modinv(n, p):\n return pow(n, p-2, p)\n\n\ndef ncr(n, r, p): # for using this uncomment the lines calculating fact and ifact\n t = ((fact[n])*((ifact[r]*ifact[n-r]) % p)) % p\n return t\n\n\ndef ain(): # takes array as input\n return list(map(int, sin().split()))\n\n\ndef sin():\n return input().strip()\n\n\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\n\n\ndef read2DIntArray(row, col):\n arr = []\n for i in range(0, row):\n temp = list(map(int, sin().split()))\n arr.append(temp)\n\n return arr\n\n\ndef read2DCharArray(row, col):\n arr = []\n for i in range(0, row):\n temp = str(sin())\n arr.append(temp)\n\n return arr\n\n\n# Smallest number by rearranging digits of a given number (without trailing zeros):-\n\n\ndef smallestNumber(n):\n lst = list(str(n))\n lst.sort()\n\n tmp = \"\"\n for i, n in enumerate(lst):\n if (n != '0'):\n tmp = lst.pop(i)\n break\n\n return str(tmp) + ''.join(lst)\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n\ndef main():\n s = sin()\n hh, mm = map(int, s.split(\":\"))\n m = mm * 6\n h = (hh * 30) + ((mm / 60) * 30)\n\n if h == 360:\n h = 0.0\n\n l, r = map(int, str(h).split(\".\"))\n if r == 0:\n h = l\n\n print(str(h) + \" \" + str(m))\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n# Python 2 and 3 footer by Pajenegod and c1729\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2),\n super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill():\n pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill()\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\ndef input(): return sys.stdin.readline().rstrip('\\r\\n')\n\n\nif __name__ == '__main__':\n main()\n# threading.Thread(target=main).start()\n"}, {"source_code": "import sys\nimport os\nfrom io import IOBase, BytesIO\n# import heapq\nimport math\n# import collections\n# import itertools\n# import bisect\nmod = 10 ** 9 + 7\npie = 3.1415926536\n# import resource\n# resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n# import threading\n# threading.stack_size(2**27)\n# import sys\n# sys.setrecursionlimit(10**6)\n# fact=[1]\n# for i in range(1,1000001):\n# fact.append((fact[-1]*i)%mod)\n# ifact=[0]*1000001\n# ifact[1000000]=pow(fact[1000000],mod-2,mod)\n# for i in range(1000000,0,-1):\n# ifact[i-1]=(i*ifact[i])%mod\n# from random import randint as rn\n# from Queue import Queue as Q\n\n\ndef modinv(n, p):\n return pow(n, p-2, p)\n\n\ndef ncr(n, r, p): # for using this uncomment the lines calculating fact and ifact\n t = ((fact[n])*((ifact[r]*ifact[n-r]) % p)) % p\n return t\n\n\ndef ain(): # takes array as input\n return list(map(int, sin().split()))\n\n\ndef sin():\n return input().strip()\n\n\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\n\n\ndef read2DIntArray(row, col):\n arr = []\n for i in range(0, row):\n temp = list(map(int, sin().split()))\n arr.append(temp)\n\n return arr\n\n\ndef read2DCharArray(row, col):\n arr = []\n for i in range(0, row):\n temp = str(sin())\n arr.append(temp)\n\n return arr\n\n\n# Smallest number by rearranging digits of a given number (without trailing zeros):-\n\n\ndef smallestNumber(n):\n lst = list(str(n))\n lst.sort()\n\n tmp = \"\"\n for i, n in enumerate(lst):\n if (n != '0'):\n tmp = lst.pop(i)\n break\n\n return str(tmp) + ''.join(lst)\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n\ndef main():\n s = sin()\n hh, mm = map(int, s.split(\":\"))\n hh = hh - 12\n m = mm * 6\n h = (hh * 30) + ((mm / 60) * 30)\n\n if hh == 12:\n h = 360 - h\n\n print(str(h) + \" \" + str(m))\n\n\n\"\"\"***************************************************************************************\"\"\"\n\n# Python 2 and 3 footer by Pajenegod and c1729\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2),\n super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill():\n pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill()\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\ndef input(): return sys.stdin.readline().rstrip('\\r\\n')\n\n\nif __name__ == '__main__':\n main()\n# threading.Thread(target=main).start()\n"}, {"source_code": "h,m = list(map(int,input().split(':')))\nprint(h*30+m/2,m*6)\n"}, {"source_code": "##B\nh,m=map(int,input().split(':'))\nif (h==12 or h==0):\n h=0\nh=(h+m/60) \nprint(h*360/12,m*360/60)\n"}, {"source_code": "##B\nh,m=map(int,input().split(':'))\nh=(h+m/60)\nif (h==12 or h==0):\n h=0\nprint(h*360/12,m*360/60)\n"}, {"source_code": "s = raw_input()\nh, m = [int(i) for i in s.split(':')]\nM = m*6\nH = 30*(h % 12) + m*.5\nif H:\n print str(H).rstrip('.0'),M\nelse:\n print '0',M\n"}, {"source_code": "import math\n\nh,m = map(int,raw_input().replace(':',' ').split())\nif h>=12: h=h-12\nprint int(round(math.degrees(math.pi*h/6+math.pi*m/360))),int(round(math.degrees(math.pi*m/30)))\n"}, {"source_code": "import math\n\nh,m = map(int,raw_input().replace(':',' ').split())\nif h>=12: h=h-12\nprint int(math.degrees(math.pi*h/6+math.pi*m/360)),int(math.degrees(math.pi*m/30))\n"}, {"source_code": "\ufeff#!/usr/bin/python\n\nimport sys, os\nsys.setrecursionlimit(10000)\n\ndef readline():\n\treturn sys.stdin.readline().strip()\ndef readrow():\n\treturn readline().split(' ')\n\n(h, m) = map(int, readline().split(':'))\nh %= 12\nprint('%.1f %.0f' % (h*30+m/2, m*6))\n\n\n"}, {"source_code": "\ufeff#!/usr/bin/python\n\nimport sys, os\nsys.setrecursionlimit(10000)\n\ndef readline():\n\treturn sys.stdin.readline().strip()\ndef readrow():\n\treturn readline().split(' ')\n\n(h, m) = map(int, readline().split(':'))\nh %= 12\nprint(h*360/12+m*360/12/60, m*360/60)\n\n\n"}, {"source_code": "\ufeff#!/usr/bin/python\n\nimport sys, os\nsys.setrecursionlimit(10000)\n\ndef readline():\n\treturn sys.stdin.readline().strip()\ndef readrow():\n\treturn readline().split(' ')\n\n(h, m) = map(int, readline().split(':'))\nh %= 12\nif (m & 1) == 0:\n\t\t\t\tprint(h*30+m//2, m*6)\nelse:\n\t\t\t\tprint(h*30+m/2, m*6)\n\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nh, m = (int(i) for i in raw_input().split(':'))\n\nprint(str(30 * h + m * 0.5) + ' ' + str(6 * m))\n"}, {"source_code": "h,m=map(int,raw_input().split(':'))\nh%=12\nprint 360.*h/12,360.*m/60"}, {"source_code": "u=raw_input().split(\":\")\nh=float(u[0])\nm=float(u[1])\n\nm1=m*360/60\nif int(m1)==m1:\n\tm1=int(m1)\n\nh1=h/12*360+m/60*360/12\nif int(h1)==h1:\n\th1=int(h1)\nprint h1,m1\n"}, {"source_code": "\na=raw_input()\nv,m=a.split(':')\nv=int(v)%12\nm=int(m)\nprint v,m\n\nvalpasukt=(((m/60.0) +v)/12)*360\nminpasukt =(m/60.0)*360\nprint valpasukt,minpasukt"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n#'''\n#in the name of allah\nh,m = map(int,raw_input().split(':'))\nn = 30\nif h == 12:\n angleh = ((m*30)/60.0)\n anglem = m/5.0 * 30.0\n print angleh,anglem\nelse: \n anglem = m/5.0 * 30.0 if h != 12 else 0\n angleh = (h*30)+((m*30)/60.0)\n print angleh,anglem"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n#'''\n#in the name of allah\nh,m = map(int,raw_input().split(':'))\nn = 30\nif h == 12:\n angleh = m*30/60.0\n anglem = m/5.0 * 30.0\n print angleh,anglem\nelse: \n anglem = m/5.0 * 30.0\n angleh = (h*30)+((m*30)/60.0)\n print angleh,anglem"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n#'''\n#in the name of allah\nh,m = map(int,raw_input().split(':'))\nn = 30\nif h == 12:\n angleh = m*30/60.0\n anglem = m/5.0 * 30.0\n print angleh,anglem\nelse: \n anglem = m/5.0 * 30.0 if h != 12 else 0\n angleh = (h*30)+((m*30)/60.0)\n print angleh,anglem"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n#'''\n#in the name of allah\nh,m = map(int,raw_input().split(':'))\nn = 30\nif h == 12:\n anglem = m/5.0 * 30.0\n print 0,anglem\nelse: \n anglem = m/5.0 * 30.0 if h != 12 else 0\n angleh = (h*30)+((m*30)/60.0)\n print angleh,anglem"}, {"source_code": "#Problem 80B\n\ndef input():\n\tst = raw_input().split(\":\")\n\tif(st[0][0] == \"0\"): st[0] = st[0][1:]\n\treturn (eval(st[0]), eval(st[1]))\n\ndef solve():\n\th = 0.0\n\th, m = input()\n\th += float(m) / 60\n\treturn (h * 30, m * 6)\n\n\nres = solve()\nif(res[0] - int(res[0]) > 0): print '%0.1f %i' % res\nelse: print '%0.0f %i' % res\n"}, {"source_code": "import sys\ntext = sys.stdin.readline().strip(\"\\n\").split(\":\")\nh = int(text[0]) % 12\nm = int(text[1])\nprint 360 / 12 * h, \" \", 360 / 60 * m\n"}, {"source_code": "import sys\ntext = sys.stdin.readline().strip(\"\\n\").split(\":\")\nh = int(text[0]) % 12\nm = int(text[1])\nprint 360 / 12 * ((12 - h) % 12), \" \", 360 / 60 * ((60 - m) % 60)\n"}, {"source_code": "time = raw_input()\nh = float(time[:time.index(':')])\nm = float(time[time.index(':')+1:])\nif h == 12:\n x = 0\n y = 0\nelse:\n x = h*5*6+m/60*30\n y = 360*m/60\n if int(str(x)[str(x).index('.')+1]) == 0:\n x = int(str(x)[:str(x).index('.')])\n if int(str(y)[str(y).index('.')+1]) == 0:\n y = int(str(y)[:str(y).index('.')])\nprint x,y\n"}, {"source_code": "time = raw_input()\nh = float(time[:time.index(':')])\nif h>12:\n h=h-12\nm = float(time[time.index(':')+1:])\nif h == 12:\n x = 0\n y = 0\nelse:\n x = h*5*6+m/60*30\n y = 360*m/60\n if int(str(x)[str(x).index('.')+1]) == 0:\n x = int(str(x)[:str(x).index('.')])\n if int(str(y)[str(y).index('.')+1]) == 0:\n y = int(str(y)[:str(y).index('.')])\nprint x,y\n"}], "src_uid": "175dc0bdb5c9513feb49be6644d0d150"} {"source_code": "n = int(input())\nx, y = map(int, input().split())\nw = min(x, y) - 1 + abs(x-y)\nb = n - max(x, y) + abs(x-y)\nif b < w:\n print(\"Black\")\nelse:\n print(\"White\")\n", "positive_code": [{"source_code": "n = int(input())\nx, y = list(map(int, input().split(\" \")))\nn1 = abs(x-1) + abs(y-1)\nn2 = abs(x-n) + abs(y-n)\nif n1 > n2:\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nras1 = 0\nras2 = 0\nif x > y:\n ras1 += y - 1 + x - y\n ras2 += n - x + n - (n - x) - y\nelif x < y:\n ras1 += x - 1 + y - x\n ras2 += n - y + n - (n - y) - x\nelse:\n ras1 = x - 1\n ras2 = n - x\nif ras1 <= ras2:\n print('White')\nelse:\n print(\"Black\")"}, {"source_code": "x = int(raw_input())\nm, n = map(int, raw_input().split())\n\nif abs(m - x) + abs(n-x) < abs(m - 1) + abs(n-1):\n\tprint \"Black\"\nelse :\n\tprint \"White\"\n"}, {"source_code": "\"\"\"\n________ _____________ ______\n___ __ \\____ ____ __ \\__(_)__ _______ ___ /\n__ /_/ /_ / / /_ /_/ /_ /__ | / / __ `/_ /\n_ ____/_ /_/ /_ _, _/_ / __ |/ // /_/ /_ /\n/_/ _\\__, / /_/ |_| /_/ _____/ \\__,_/ /_/\n /____/\n\nhttps://github.com/Cheran-Senthil/PyRival\nCopyright (c) 2018 Cheran Senthilkumar\n\"\"\"\nfrom __future__ import division, print_function\n\nimport cmath\nimport itertools\nimport math\nimport operator as op\nimport sys\nfrom atexit import register\nfrom bisect import bisect_left, bisect_right\n\n# import random\n# import threading\n# from collections import Counter, MutableSequence, defaultdict, deque\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\n# from heapq import heappop, heappush\n\nif sys.version_info[0] < 3:\n from io import BytesIO as stream\n # from fractions import Fraction\n # from fractions import gcd\n # from cPickle import dumps\n # from Queue import PriorityQueue, Queue\nelse:\n from io import StringIO as stream\n # from functools import reduce\n # from fractions import Fraction\n # from math import gcd\n # from pickle import dumps\n # from queue import PriorityQueue, Queue\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n def items(self):\n return dict.iteritems(self)\n\n def keys(self):\n return dict.iterkeys(self)\n\n def values(self):\n return dict.itervalues(self)\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"\n Sets whether the standard Python streams are allowed to buffer their I/O.\n\n Parameters\n ----------\n sync : bool, optional\n The new synchronization setting. Default is True.\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef main():\n n = int(input())\n x, y = map(int, input().split(' '))\n white_distance = abs(x - y) + min(x - 1, y - 1)\n black_distance = abs(x - y) + min(n - x, n - y)\n # print(white_distance, black_distance)\n if white_distance <= black_distance:\n print('White')\n else:\n print('Black')\n\n\nif __name__ == '__main__':\n sys.setrecursionlimit(10000)\n sync_with_stdio()\n main()\n"}, {"source_code": "n = input()\na,b = map(int,raw_input().split())\nwk = abs(a-1)+abs(b-1)\nbk = abs(n-a)+abs(n-b)\nif wk <= bk:\n\tprint \"White\"\nelse:\n\tprint \"Black\""}, {"source_code": "n = input()\nx, y = map(int, raw_input().strip().split())\n\nwhite = abs(1 - x) + abs(1 - y)\nblack = abs(n - x) + abs(n - y)\n\nif white <= black: print \"White\"\nelse: print \"Black\"\n"}, {"source_code": "n = input()\nx, y = map(int, raw_input().split())\nif x + y <= n + 1:\n print \"White\"\nelse:\n print \"Black\"\n"}, {"source_code": "from sys import stdin\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nn = int(input())\nx, y = rints()\nw, b = max(x, y) - 1, n - min(x, y)\nprint('white' if w <= b else 'black')\n"}, {"source_code": "n = int(raw_input())\nx, y = raw_input().split(\" \")\nx = int(x)\ny = int(y)\nif x + y <= n + 1:\n\tprint \"White\"\nelse:\n\tprint \"Black\""}, {"source_code": "n=int(raw_input())\nx,y=map(int,raw_input().split())\n\nif max(x-1,y-1)>max(abs(n-x),abs(n-y)):\n print 'Black'\nelse:\n print 'White'"}, {"source_code": "n = int(raw_input())\nx, y = map(int, raw_input().split())\nw = max(abs(x-1), abs(y-1))\nb = max(abs(n-x), abs(n-y))\nif w <= b:\n print \"White\"\nelse:\n print \"Black\""}, {"source_code": "n = input();\nx,y = raw_input().split();\nx=int(x);\ny=int(y);\nwhitecolumn = 1;\nwhiterow = 1;\nblackcolumn = n;\nblackrow = n;\nwhiteturn=0;\nblackturn=0;\nif x-whiterow<y-whitecolumn:\n whiteturn+=x-whiterow;\n whiteturn+=(y-whitecolumn)-(x-whiterow);\nelif x-whiterow>y-whitecolumn:\n whiteturn+=y-whitecolumn;\n whiteturn+=(x-whiterow)-(y-whitecolumn);\nelif x-whiterow==y-whitecolumn:\n whiteturn+=x-whiterow;\n \nif blackrow-x<blackcolumn-y:\n blackturn+=blackrow-x;\n blackturn+=(blackcolumn-y)-(blackrow-x);\nelif blackrow-x>blackcolumn-y:\n blackturn+=blackcolumn-y;\n blackturn+=(blackrow-x)-(blackcolumn-y);\nelif blackrow-x==blackcolumn-y:\n blackturn+=blackrow-x;\n\nif blackturn < whiteturn:\n res=\"Black\";\nelif blackturn > whiteturn:\n res=\"White\";\nelse:\n res=\"White\";\n \nprint(res);"}, {"source_code": "# your code goes here\n# your code goes here\n\nn = input()\nx,y=map(int,raw_input().split())\nif x==y:\n\tif x==1:\n\t\tprint \"white\"\n\telif x==n:\n\t\tprint \"black\"\n\telse:\n\t\twd=abs(x-1)\n\t\tbd=abs(x-n)\n\t\tif wd<=bd:\n\t\t\tprint \"white\"\n\t\telse:\n\t\t\tprint \"black\"\nelse:\n\twd=abs(min(x,y)-1)+abs(max(x,y)-1)\n\tbd=abs(min(x,y)-n)+abs(max(x,y)-n)\n\tif wd<=bd:\n\t\tprint \"white\"\n\telse:\n\t\tprint \"black\"\n\n\n\n\n\n"}, {"source_code": "a = input()\nb,c = sorted(map(int,raw_input().split()))\nif b-1<=a-c:\n print 'White'\nelse:\n print 'Black'\n"}, {"source_code": " #import resource\n#import sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#import threading\n#threading.stack_size(2**26)\n#sys.setrecursionlimit(0x1000000)\n#fact=[1]\n#for i in range(1,100001):\n# fact.append((fact[-1]*i)%mod)\nfrom sys import stdin, stdout\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport itertools\nimport math\nimport heapq\nfrom random import randint as rn\nfrom Queue import Queue as Q\nmod=(10**9)+7\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef ncr(n,r,p):\n t=((fact[n])*(modinv(fact[r],p)%p)*(modinv(fact[n-r],p)%p))%p\n return t\ndef ain():\n return map(int,sin().split())\ndef sin():\n return stdin.readline().strip()\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\n\"\"\"*********************************************************************************\"\"\"\nn=input()\nx,y=map(int,raw_input().split())\nq=x-1\nw=y-1\nz1=max(q,w)\nq=n-x\nw=n-y\nz2=max(q,w)\nif(z1<=z2):\n print \"White\"\nelse:\n print\"Black\"\n"}, {"source_code": "n = int(raw_input())\nx, y = raw_input().split()\nx, y= int(x),int(y)\n\n\nwhiteKing = (1,1)\nblackKing = (n,n)\ncoin = (x,y)\n\ndef noMoves(a,b):\n\treturn max(abs(b[0]-a[0]),abs(b[1]-a[1]))\n\n\nif whiteKing == coin:\n\tprint \"White\"\nelif blackKing == coin:\n\tprint \"Black\"\nelse:\n\twhiteMoves = noMoves(whiteKing,coin)\n\tblackMoves = noMoves(blackKing,coin)\n\tif whiteMoves<=blackMoves:\n\t\tprint \"White\"\n\telse:\n\t\tprint \"Black\""}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# File : a.py\n# Author : recurze\n# Date : 23:41 04.11.2018\n# Last Modified Date: 23:42 04.11.2018\n\nn = int(raw_input())\nx, y = [int(x) for x in raw_input().split()]\nif (x - 1) + (y - 1) <= (n - x) + (n - y):\n print \"White\"\nelse:\n print \"Black\"\n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nw=(x-1)+(y-1)\nb=(n-x)+(n-y)\nprint(\"White\" if w<=b+1 else \"Black\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nnum = x - 1 + y - 1\nnum2 = n - x + n - y\nans = num <= num2\nif ans:\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "n=int(input())\n#l=list(map(int, input().split()))\na,b=map(int,input().split())\nprint(\"White\" if a+b-2<=2*n-a-b else \"Black\")\n"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nw = x - 1 + y - 1;\nb = n - x + n - y;\nprint(\"White\" if w <= b else \"Black\")"}, {"source_code": "import sys\n\nn = int(next(sys.stdin))\nrow, col = map(int, next(sys.stdin).split())\n\nminimum = min(row, col)\nwhite = minimum - 1 + max(row-minimum, col-minimum)\n\nmaximum = max(row, col)\nblack = n - maximum + max(maximum-row, maximum-col)\n\nprint(\"White\" if white <= black else \"Black\")\n"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nif max(n - x, n - y) < max(x - 1, y - 1):\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nif max(x-1,y-1) > max(n-x,n-y):\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nna = abs(x - 1) + abs(y - 1)\nnb = abs(n - x) + abs(n - y)\nif na <= nb:\n print(\"white\")\nelse:\n print(\"black\")\n"}, {"source_code": "n=int(input());x,y=map(int,input().split())\nw=[x-1,y-1];w=sum(w)-min(w)\nb=[n-x,n-y];b=sum(b)-min(b)\nprint('White' if w<=b else 'Black')\n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nd1=max(x-1,y-1)\nd2=max(n-x,n-y)\nif d1<=d2:\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "from math import *\n\nn = int(input())\nx,y = map(int,input().split())\nf = max(x - 1,y - 1)\ns = max(n-x,n-y)\nif (f<=s):\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "n=int(input())\nm,y=map(int, input().split())\nb=max(m-1,y-1)\nw=max(n-m,n-y)\nprint(\"White\" if w>=b else \"Black\")"}, {"source_code": "import sys\nn = int(sys.stdin.readline())\ngx, gy = tuple(map(int,sys.stdin.readline().split()))\n\nwi, wj, bi, bj = 1, 1, n, n\n\nif (gx - wi + gy - wj) > (bi - gx) + (bj - gy):\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "n = int(input())\nx, y = (int(a) for a in input().split())\nd1 = max(x - 1, y - 1)\nd2 = max(n - x, n - y)\nif d1 <= d2:\n print('White')\nelse:\n print('Black')"}, {"source_code": "n=int(input())\nx,y=input().split()\nx=int(x)\ny=int(y)\nif(x+y<=n+1):\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "n = int(input())\nx, y = [int(s) for s in input().split(' ')]\nif x - 1 + y - 1 <= n - x + n - y:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nval1=max(x,y)-1\nval2=n-min(x,y)\nif(val1<=val2):\n print('White')\nelse:\n print('Black')"}, {"source_code": "n = int(input())\n(x, y) = [int(i) for i in input().split()]\n\ndist1 = (min(x,y) + abs(x-y) -1)\ndist2 = (min(n-x,n-y) + abs(x-y))\n\nif dist1 <= dist2:\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "n=int(input())\na,b=map(int,input().split())\nwhite=abs(a-1)+abs(b-1)\nblack=abs(n-a)+abs(n-b)\nif white<=black:\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "n = int(input())\n\nx, y = map(int, input().split())\n\nans = (x - 1) + (y - 1) <= (n - x) + (n - y)\nprint('White' if ans else 'Black')\n"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nif max(x-1,y-1) <= max(n-x,n-y):\n print('White')\nelse:\n print('Black')"}, {"source_code": "#----Kuzlyaev-Nikita-Codeforces-----\n#------------03.04.2020-------------\n\nalph=\"abcdefghijklmnopqrstuvwxyz\"\n\n#-----------------------------------\n\nn=int(input())\nx,y=map(int,input().split())\nws=x+y-2;wb=2*n-x-y\nif ws<=wb:print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "n = int(input())\nx, y = [int(i) for i in input().split()]\nmoves_for_white = max(x - 1, y - 1)\nmoves_for_black = max(n - x, n - y)\nif moves_for_white <= moves_for_black:\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nif (x+y-2)<=(2*n-x-y):\n\tprint('White')\nelse:\n\tprint('Black')"}, {"source_code": "import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\ndd=[(-1,0),(0,1),(1,0),(0,-1)]\nddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\n# def LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return input()\n\ndef main():\n n=I()\n a,b=LI()\n\n white_max=max(a-1,b-1)\n black_max=max(n-a,n-b)\n\n if white_max<=black_max:\n return 'White'\n return 'Black'\n\n# main()\nprint(main())\n"}, {"source_code": "n = int(input())\nx, y = map(int,input().split())\n#distancia de w a coin es [x,y]\n#distancia de b a coin es [n-x,n-y]\nwd = [x-1,y-1]\nbd = [n-x,n-y]\n#pasos del white\nwp = max(wd)\nbp = max(bd)\nprint('White' if wp<=bp else 'Black') "}, {"source_code": "n = int(input())\nx,y = [*map(int,input().split())]\nif (x-1 + y-1) <= (n-x + n-y):\n print('White')\nelse:\n print('Black')"}, {"source_code": "print([\"Black\",\"White\"][int(input())+1>=sum(map(int,input().split()))])\n"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\n\nf = max(x, y)\ns = max((n-x), (n-y))\n\nif n-x+n-y == 0 or f-1 > s:\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "n = int(input().strip())\nx0, y0 = list(map(int, input().strip().split()))\nwhite_diff = max(x0 - 1, y0 - 1)\nblack_diff = max(n - x0, n - y0)\nif white_diff <= black_diff:\n print('White')\nelse:\n print('Black')"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nk = x+y-2\nh= 2*n-x-y\nif h==k or k<h:\n\tprint('White')\nelse:\n\tprint('Black')"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nw=0\nk=min(x,y)\nm=max(x,y)\nw=k-1\nw=w+(m-k)\nb=0\nb=b+(n-m)\nb=b+abs(k-m)\nif w<=b:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "n = int(input())\n#It takes two numbers separeted by \"space\" and then splits them\nxy = list(input(\"\").split( ))\n#Asigning two vars x,y of a coin\nxCoin = int(xy[1])\nyCoin = int(xy[0])\n# First n stands for colomn, second stands for rows\n\ndef whoWins():\n global xCoin, yCoin, n\n\n if xCoin + yCoin > n + 1:\n print(\"Black\")\n else:\n print(\"White\")\n\nwhoWins()"}, {"source_code": "n = int(input())\n\nx, y = map(int, input().split())\n\nif max(n -x, n-y) < max(x-1, y-1):\n print('Black')\nelse:\n print('White')"}, {"source_code": "n=int(input())\nx,y=input().split(\" \")\nx=int(x)\ny=int(y)\ncw=0\ncb=0\nw1,w2=1,1\nb1,b2=n,n\ncw=(x-w1)+(y-w2)\ncb=(b1-x)+(b2-y)\nif(cw<=cb):\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "n = int(input())\nx, y = [int(a) for a in input().split()]\nd1 = max(x - 1, y - 1)\nd2 = max(n - x, n - y)\nif d1 <= d2:\n print('White')\nelse:\n print('Black')"}, {"source_code": "n=int(input())\nx,y=input().split()\nx=int(x)\ny=int(y)\ns=x*y\na=n-x+1\nb=n-y+1\nc=a*b\nif s<=c:\n\tprint(\"white\")\nelif c<s:\n\tprint(\"black\")"}, {"source_code": "\nn = int(input())\nx, y = [int(a) for a in input().split()]\n\nwhite_dist = max(x-1, y-1)\nblack_dist = max(n-x, n-y)\n\nif white_dist <= black_dist:\n print(\"white\")\nelse:\n print(\"black\")"}, {"source_code": "def getDistance(x,y,n):\n\tw = (x-1)**2+(y-1)**2\n\tb = (x-n)**2+(y-n)**2\n\tif w > b:\n\t\treturn 'Black'\n\treturn 'White'\n\t\nif __name__=='__main__':\n\tn = int(input())\n\tt = input().strip().split(' ')\n\tx = int(t[0])\n\ty = int(t[1])\n\tprint(getDistance(x,y,n))"}, {"source_code": "n = int(input())\n'''\nConsole.readLine() -> C#\n||\ninput() -> python 3\n'''\n'''\ntemp = [int(item) for item in input().split()]\nx = temp[0]\ny = temp[1]\n'''\n'''\nx, y = [int(item) for item in input().split()]\n'''\nx, y = list(map(int, input().split()))\n\nwRowDiff, wCollDiff, bRowDiff, bCollDiff = x - 1, y - 1, n - x, n - y\n\nwMoves = wRowDiff + (wCollDiff - wRowDiff) if wRowDiff < wCollDiff else wCollDiff + (wRowDiff - wCollDiff)\nbMoves = bRowDiff + (bCollDiff - bRowDiff) if bRowDiff < bCollDiff else bCollDiff + (bRowDiff - bCollDiff)\n\nprint('Black' if bMoves < wMoves else 'White')\n"}, {"source_code": "#!/usr/bin/env python3\n\n\n\nif __name__ == \"__main__\":\n n = int(input())\n x,y = map(int, input().split())\n\n distW = max(x-1, y-1)\n distB = max(n-x, n-y)\n\n if distB < distW:\n print(\"Black\")\n else:\n print(\"White\")\n\n \n"}, {"source_code": "z=input\nn=int(z())\nx,y=list(map(int,z().split()))\nw=max(0,x-1)+max(0,y-1)\nb=max(0,n-x)+max(0,n-y)\nif b<w:\n print('Black')\nelse:\n print('White')\n"}, {"source_code": "import math\n\nn = input()\ncoin = input()\ncoin = coin.split()\ncoin[0] = int(coin[0])\ncoin[1] = int(coin[1])\n\nwhite_king = [1, 1]\nblack_king = [int(n), int(n)]\n\nwhite_distance = (white_king[0] - coin[0])**2 + (white_king[1] - coin[1])**2\nblack_distance = (black_king[0] - coin[0])**2 + (black_king[1] - coin[1])**2\n\nif white_distance == black_distance or white_distance < black_distance:\n print('WHITE')\nelif black_distance < white_distance:\n print('BLACK')\n"}, {"source_code": "n = int(input())\nxy = [int(i) for i in input().split()]\nlengthW = 0\nlengthB = 0\nif (xy[0] < xy[1]):\n\tlengthW += xy[0]-1+(xy[1]-xy[0])\nelse:\n\tlengthW += xy[1]-1+(xy[0]-xy[1])\nxy[0] = n+1-xy[0]\nxy[1] = n+1-xy[1]\nif (xy[0] < xy[1]):\n\tlengthB += xy[0]-1+(xy[1]-xy[0])\nelse:\n\tlengthB += xy[1]-1+(xy[0]-xy[1])\nif (lengthW <= lengthB):\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "n=int(input())\nx,y=[int(a) for a in input().split()]\nif x>y:\n x,y=y,x\n\nn_while=x-1+(y-1-(x-1))\nn_black=n-y+(n-x-(n-y))\nif n_while > n_black:\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "n = int(input())\ncoin = input().split(' ')\nx = int(coin[0])\ny = int(coin[1])\nif x + y <= n+1:\n print('white')\nelse: print('black')"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\n\nif abs(x - 1) + abs(y - 1) - 1 < abs(x - n) + abs(y - n):\n\tprint('White')\nelse:\n\tprint('Black')"}, {"source_code": "# https://codeforces.com/problemset/problem/1075/A\n\nn = int(input())\n\nx, y = map(int, input().split())\n\nif x + y - 2 <= n + n - x - y:\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "W = 'White'\nB = 'Black'\n\nimport sys\n\nn = input()\nx, y = map(int, sys.stdin.readline().split())\n\nd1 = min(x-1, y-1)\no1 = max(x-1, y-1)-d1\nt1 = d1+o1\n\nd2 = min(n-x, n-y)\no2 = max(n-x, n-y)-d2\nt2 = d2+o2\n\nif t1>t2:\n print B\nelse:\n print W\n"}, {"source_code": "n = input()\nx,y = raw_input().split()\nx = int(x)\ny = int(y)\nwx,wy = [1,1]\nbx,by = [n,n]\nw = max(abs(wx - x),abs(wy - y))\nb = max(abs(bx - x),abs(by - y))\nif(w > b):\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "\n #! /usr/bin/env python\n# -*- coding: utf-8 -*\n\ndef dist(A, B):\n return (B[0] - A[0])**2 + (B[1] - A[1])**2\n\ndef main():\n n = int(raw_input())\n x, y = map(int, raw_input().split())\n\n d_1 = dist((1, 1), (x, y))\n d_2 = dist((n, n), (x, y))\n\n if d_1 <= d_2:\n print 'White'\n else:\n print 'Black'\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n=int(input())\na,b=input().split()\nif (int(a)+int(b))-1<=n:\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "n=int(input())\nm=list(input().split())\nif int(m[1])+int(m[0])<=n+1:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "n = int(input())\nx,y = tuple(map(int,input().split()))\n\nwhite = [1,1]\nblack = [n,n]\n\nw = max(abs(x-1),abs(y-1))\nb = max(abs(x-n),abs(y-n))\n\nprint('White') if b>=w else print('Black')"}, {"source_code": "n=int(input())\na,b=input().split()\nif (int(a)+int(b))-1<=n:\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"source_code": "a=int(input());c1,c2=map(int,input().split());print([\"White\",\"Black\"][max(a-c1,a-c2)<max(c1-1,c2-1)])"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nprint(\"Black\" if max(x-1, y-1) > max(n-x, n-y) else \"White\")"}, {"source_code": "n=int(input())\na,b=map(int,input().split())\nw1=abs(a-1)\nw2=abs(b-1)\nb1=abs(n-a)\nb2=abs(n-b)\nmowk=min(w1,w2)+abs(w1-w2)\nmobk=min(b1,b2)+abs(b1-b2)\nif mobk<mowk:\n\tprint(\"black\")\nelse:\n\tprint(\"white\")"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",\"r\")\n# sys.stdout=open(\"output.out\",\"w\")\nfrom math import sqrt\nn=int(input())\nx,y=map(int,input().split())\ndw=sqrt((x-1)**2+(y-1)**2)\ndb=sqrt((x-n)**2+(y-n)**2)\nif(x==50000000000000001 or x==500000000000000002 or x==500000000000000001 ):\n\tprint(\"Black\")\nelif(dw<=db):\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")\t"}, {"source_code": "n = int(input())\na,b = map(int,input().split())\nprint(\"White\"if (a+b) <=(n+1) else \"Black\")"}, {"source_code": "def solution(l1,n):\n l1=[x-1 for x in l1]\n distw=max(l1)\n l1=[n-x-1 for x in l1]\n distb=max(l1)\n #print(distw,distb)\n if distw>distb:return (\"Black\")\n else: return (\"White\")\ndef answer():\n n = int(input())\n l1 = [int(x) for x in input().split()]\n print(solution(l1,n))\nanswer( )"}], "negative_code": [{"source_code": "n = int(input())\nx,y = map(int, input().split())\nw = max(x,y)-1\nb = min(n-x,n-y)\nif w > b:\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "n = int(input())\nxy = [int(i) for i in input().split()]\nlengthW = 0\nlengthB = 0\nif (xy[0] < xy[1]):\n\tlengthW += xy[0]-1+(xy[1]-xy[0])\nelse:\n\tlengthW += xy[1]-1+(xy[0]-xy[1])\nxy[0] = 6-xy[0]\nxy[1] = 6-xy[1]\nif (xy[0] < xy[1]):\n\tlengthB += xy[0]-1+(xy[1]-xy[0])\nelse:\n\tlengthB += xy[1]-1+(xy[0]-xy[1])\nif (lengthW <= lengthB):\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "n = int(input())\nxy = input().split(\" \")\nx = int(xy[0])\ny = int(xy[1])\n\nwx = 1\nwy = 1\nbx = n\nby = n\ni = 1\nwhile(not(wx==x and wy==y) and not((bx==x) and (by==y))):\n if i%2 == 0:\n if x < bx:\n bx = bx-1\n elif x > bx:\n bx = bx+1\n if y < by:\n by = by-1\n elif y > by:\n by += 1\n else:\n if x < wx:\n wx = wx-1\n elif x > wx:\n wx = wx+1\n if y < wy:\n wy = wy-1\n elif y > wy:\n wy += 1\n i += 1\n\nif i%2 == 0:\n print('White')\nelse:\n print('Black')\n\n \n\n\n"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\n\nif x*y>2*n or n == x == y:\n print('Black')\nelse:\n print('White')\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nx,y = [*map(int,input().split())]\nif (x-1 + y-1) <= (n-x + y-x):\n print('White')\nelse:\n print('Black')"}, {"source_code": "import math\n\nn = int(input())\ns = input()\na = s.split(\" \")\nx, y = int(a[0]), int(a[1])\n\nif x == y and x*2 > n:\n print(\"Black\")\n\nelse:\n dis1 = math.sqrt(pow(x - 1, 2) + pow(y - 1, 2))\n dis2 = math.sqrt(pow(x - n, 2) + pow(y - n, 2))\n\n #print(str(dis1) + \" \"+str(dis2))\n\n if dis1 <= dis2:\n print(\"White\")\n else:\n print(\"Black\")\n"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nk = x+y-2\nh= n*n-x-y\nif h==k or k<h:\n\tprint('White')\nelse:\n\tprint('Black')"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split(\" \"))\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif white == black:\n\tprint(\"White\")\nelif x - 1 < x - n and y - 1 < y - n:\n\tprint(\"White\")\nelif x - 1 > x - n and y - 1 > y - n:\n\tprint(\"Black\")\nelse:\n\tif x > n / 2 and y > n / 2:\n\t\tprint(\"Black\")\n\telif white < black:\n\t\tprint(\"White\")\n\telse:\n\t\tprint(\"Black\")"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nw=0\nk=min(x,y)\nm=max(x,y)\nw=k-1\nw=w+(m-k)\nb=0\nb=b+(m-1)\nb=b+(k-m)\nif k<=b:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "import math\n\nn = int(input())\nx, y = map(int, input().split(\" \"))\n\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif n % 2 == 0:\n\tif white == black:\n\t\tif x > n / 2 and y > n / 2:\n\t\t\tprint(\"Black\")\n\t\telse:\n\t\t\tprint(\"White\")\nelse:\n\tif white == black:\n\t\tprint(\"White\")\n\telif white < black:\n\t\tprint(\"White\")\n\telif x > n / 2 and y > n / 2:\n\t\tprint(\"Black\")\n\telse:\n\t\tprint(\"Black\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nif (x%2 == 1 and y%2 == 1) or (x%2 == 0 and y%2 == 0):\n print('Black')\nelse:\n print('White')"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nk=((x-1)^2+(y-1)^2)\nl=((n-x)^2+(n-y)^2)\nif(k>l):\n\tprint(\"black\")\nelse:\n\tprint(\"white\")\n"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif z1<z2:\n z=z1\nelse:\n z=z2\nk1=n-r\nk2=n-s\nif k1<k2:\n k=k1\nelse:\n k=k2\nzx=z+(z1-z)\nz=z+zx\nkx=k+(k1-k)\nk=k+kx\nif z<k:\n print(\"White\")\nelif z>k:\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nw = x - 1 + y - 1;\nb = n - x + n - y;\nprint(\"White\" if w >= b else \"Black\")"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif z1<z2:\n z=z1\nelse:\n z=z2\nk1=n-r\nk2=n-s\nif k1<k2:\n k=k1\nelse:\n k=k2\nzx=z-(z1-z)\nz=z+zx\nkx=k-(k1-k)\nk=k+kx\nif z<k:\n print(\"White\")\nelif z>k:\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "def main():\n\n n = int(input())\n coin = list(map(int, input().split()))\n\n if coin == [1, 1]:\n print(\"White\")\n return\n\n if coin == [n, n]:\n print(\"Black\")\n return\n\n\n white = max([abs(coin[0] - 1), abs(coin[1] - 1)])\n black = max([abs(n - coin[0]), abs(n - coin[0])])\n\n if white <= black:\n print(\"White\")\n else:\n print(\"Black\")\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = input();\nx,y = raw_input().split();\nx=int(x);\ny=int(y);\nwhitecolumn = 1;\nwhiterow = 1;\nblackcolumn = n;\nblackrow = n;\nwhile True:\n if whiterow < x and whitecolumn < y:\n whiterow+=1;\n whitecolumn+=1;\n elif whiterow == x and whitecolumn < y:\n whitecolumn+=1;\n elif whiterow < x and whitecolumn == y:\n whiterow+=1;\n\n\n if blackrow > x and blackcolumn > y:\n blackrow-=1;\n blackcolumn-=1;\n elif blackrow == x and blackcolumn > y:\n blackcolumn-=1;\n elif blackrow > x and blackcolumn == y:\n blackrow-=1;\n if whiterow==x and whitecolumn==y:\n res=\"White\";\n break;\n elif blackrow==x and blackcolumn==y:\n res=\"Black\";\n break;\nprint(res);"}, {"source_code": "# ##############################\n\nn = int(input())\nx,y = map(int, input().split())\n\nway1 = 0\nway2 = 0\n\nd1 = (y - 1) + abs(x - y)\nd2 = (x - 1) + abs(y - x)\nway1 += min(d1, d2)\n\n\nd1 = (n - y) + abs(x - n)\nd2 = (n - x) + abs(y - n)\nway2 += min(d1, d2)\n#print(d1, d2)\n\n# print(way1, way2)\nif (way1 <= way2):\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "print('White' if int(input())-2 <= sum(map(int,input().split()))<<1 else 'Black')"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nif x==1 and y==1:\n print('White')\nif (x%2 == 1 and y%2 == 1) or (x%2 == 0 and y%2 == 0):\n print('Black')\nelse:\n print('White')"}, {"source_code": "n=int(input())\nxy=input().split()\nx=int(xy[0])\ny=int(xy[1])\nw=abs(x-1)+abs(y-1)\nb=abs(x-n)+abs(y-n)\nif(w>=b):\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "import math\n\nn = int(input())\ns = input()\na = s.split(\" \")\nx, y = int(a[0]), int(a[1])\n\nif x == y and x*2 > n:\n print(\"Black\")\n\nelif x < y and x*2 > n:\n print(\"Black\")\n\nelse:\n dis1 = math.sqrt(pow(x - 1, 2) + pow(y - 1, 2))\n dis2 = math.sqrt(pow(x - n, 2) + pow(y - n, 2))\n\n print(str(dis1) + \" \"+str(dis2))\n\n if dis1 <= dis2:\n print(\"White\")\n else:\n print(\"Black\")\n"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nprint(\"Black\" if max(x-1, y-1) > max(n-x, -y) else \"White\")"}, {"source_code": "n=int(input())\nx,y=input().split()\nx=int(x)\ny=int(y)\ns=x*y\nt=n**2-s\nif s<=t:\n\tprint(\"white\")\nelif t<s:\n\tprint(\"black\")"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split(\" \"))\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif white == black:\n\tprint(\"White\")\nelif x > n / 2 and y > n / 2:\n\tprint(\"Black\")\nelif white < black:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif z1<z2:\n z=z1\nelse:\n z=z2\nk1=n-r\nk2=n-s\nif k1<k2:\n k=k1\nelse:\n k=k2\nzx=z+(z1-z)\nz=z+zx\nkx=k+(k1-k)\nk=k+kx\nif zx<kx:\n print(\"White\")\nelif zx>kx:\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "n=int(input())\nx,y=[int(i) for i in input().split()]\nif n-x>x-1:\n if n-y>y-1:\n print(\"black\")\n else:\n print(\"white\")\nelse:\n if n-y>y-1:\n print(\"white\")\n else:\n print(\"black\")\n \n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nd=(((x-1)^2)+((y-1)^2))\nD=(((n-x)^2)+((n-y)^2))\nprint(d)\nprint(D)\nif(d>D):\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split(\" \"))\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif white == black:\n\tprint(\"White\")\nelif x - 1 < x - n and y - 1 < y - n:\n\tprint(\"White\")\nelif x - 1 > x - n and y - 1 > y - n:\n\tprint(\"Black\")\nelse:\n\tif x > n / 2 and y > n / 2:\n\t\tprint(\"Black\")\n\telif white < black:\n\t\tprint(\"White\")\n\telse:\n\t\tprint(\"Black\")"}, {"source_code": "n = int(input())\nxy = [int(i) for i in input().split()]\nlengthW = 0\nlengthB = 0\nif (xy[0] < xy[1]):\n\tlengthW += xy[0]-1+(xy[1]-xy[0])\nelse:\n\tlengthW += xy[1]-1+(xy[0]-xy[1])\nxy[0] = 6-xy[0]\nxy[1] = 6-xy[1]\nif (xy[0] < xy[1]):\n\tlengthB += xy[0]-1+(xy[1]-xy[0])\nelse:\n\tlengthB += xy[1]-1+(xy[0]-xy[1])\nif (lengthW <= lengthB):\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "import math\n\nn = int(input())\nx, y = map(int, input().split(\" \"))\n\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif x == n and y == n:\n\tprint(\"Black\")\nelse:\n\tif n % 2 == 0:\n\t\tif white == black:\n\t\t\tif x > n / 2 and y > n / 2:\n\t\t\t\tprint(\"Black\")\n\t\t\telse:\n\t\t\t\tprint(\"White\")\n\telse:\n\t\tif white == black:\n\t\t\tprint(\"White\")\n\t\telif white < black:\n\t\t\tprint(\"White\")\n\t\telif x > n / 2 and y > n / 2:\n\t\t\tprint(\"Black\")\n\t\telse:\n\t\t\tprint(\"Black\")"}, {"source_code": "import math\n\nn = int(input())\ns = input()\na = s.split(\" \")\nx, y = int(a[0]), int(a[1])\n\nif x == y and x*2 > n:\n print(\"Black\")\n\nelse:\n dis1 = math.sqrt(pow(x - 1, 2) + pow(y - 1, 2))\n dis2 = math.sqrt(pow(x - n, 2) + pow(y - n, 2))\n\n print(str(dis1) + \" \"+str(dis2))\n\n if dis1 <= dis2:\n print(\"White\")\n else:\n print(\"Black\")\n"}, {"source_code": "n = int(input())\n#It takes two numbers separeted by \"space\" and then splits them\nxy = list(input(\"\").split( ))\n#Asigning two vars x,y of a coin\nxCoin = int(xy[0])\nyCoin = int(xy[1])\n# First n stands for colomn, second stands for rows\n\ndef whoWins():\n global xCoin, yCoin, n\n\n if xCoin == 1 and yCoin == n:\n print(\"Black\")\n elif xCoin == n and yCoin == 1:\n print(\"White\")\n elif xCoin == yCoin:\n print(\"White\")\n elif xCoin > yCoin:\n print(\"Black\")\n else: #xCoin < yCoin\n print(\"White\")\n\nwhoWins()"}, {"source_code": "def dis(x1,y1,x2,y2):\n return pow((pow(x2-x1,2))+(pow(y2-y1,2)),0.5)\n\nn=int(input())\ncor=list(map(int,input().split()))\n\nwhite = dis(1,1,cor[0],cor[1])\nblack = dis(n,n,cor[0],cor[1])\n\nif white-black<=1.41:\n print(\"white\")\nelse:\n print(\"Black\")"}, {"source_code": "n = int(input())\nx , y = map(int, input().split())\nw = max(x,y)\nb = max(n-x , n-y)\nif w<=b:\n print(\"White\")\nelse:\n print('Black')"}, {"source_code": "n = int(input())\nx, y = map(int,input().split())\n#distancia de w a coin es [x,y]\n#distancia de b a coin es [n-x,n-y]\nwd = [x,y]\nbd = [n-x,n-y]\n#pasos del white\nwp = max(wd)\nbp = max(bd)\nprint(wd,bd)\nprint(wp,bp)\nprint('White' if wp<=bp else 'Black')"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nif y > x: x, y = y, x\ndist1 = y + (x - y) - 1\ndist2 = (n - y) + (x - y) - 1\nprint('White' if dist1 <= dist2 else 'Black')"}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUX.out\",\"w\")\nN=int(input())\nX,Y=map(int,input().split())\ndist1=max(X-1,Y-1)\ndist2=max(N-X,N-Y)\nif dist1>=dist2:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\na=min(x-1,n-x)\nb=min(y-1,n-y)\nif(a%2!=0):\n\tprint(\"white\")\nelse:\n\tprint(\"black\")"}, {"source_code": "n = int(input())\nx,y = map(int, input().split())\nw = max(x,y)-1\nb = min(n-x,n-y)+1\nif w > b:\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "def win():\n n = int(input())\n goal = input().split()\n x = int(goal[0]) - 1\n y = int(goal[1]) - 1\n \n white = max(x,y)\n black = max(n-1-x,n-1-y)\n if white <= black: \n return 'White'\n else:\n return 'Black'\n\nwin()"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nw=0\nk=min(x,y)\nm=max(x,y)\nw=k-1\nw=w+(m-k)\nb=0\nb=b+(m-1)\nb=b+(k-m)\nif k<=b:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "import math\nn=int(input())\na=input()\nx,y=a.split()\nx=int(x)\ny=int(y)\nd1=float(math.sqrt(((1-x)*(1-x))+((1-y)*(1-y))))\nd2=float(math.sqrt(((n-x)*(n-x))+((n-y)*(n-y))))\n#print(d1)\n#print(d2)\nif d1<=d2 :\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")\n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\na=min(x-1,n-x)\nb=min(y-1,n-y)\nif(a%2!=0):\n\tprint(\"white\")\nelse:\n\tprint(\"black\")"}, {"source_code": "n=int(input())\nx,y=input().split()\nx=int(x)\ny=int(y)\ns=x+y\nt=2*n-s\nif s<=t:\n\tprint(\"white\")\nelif t<s:\n\tprint(\"black\")"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",\"r\")\n# sys.stdout=open(\"output.out\",\"w\")\nfrom math import sqrt\nn=int(input())\nx,y=map(int,input().split())\ndw=sqrt((x-1)**2+(y-1)**2)\ndb=sqrt((x-n)**2+(y-n)**2)\nif(dw<=db):\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")\t"}, {"source_code": "import math\n\nn = int(input())\ns = input()\na = s.split(\" \")\nx, y = int(a[0]), int(a[1])\n\nif n == x and n == y:\n print(\"Black\")\nelif x == 1 and y == 1:\n print(\"White\")\n\nelif x-1 == 1 or y-1 == 1:\n print(\"White\")\n\nelse:\n\n dis1 = math.sqrt(pow(x - 2, 2) + pow(y - 2, 2))\n dis2 = math.sqrt(pow(x - n, 2) + pow(y - n, 2))\n\n if dis1 < dis2:\n print(\"White\")\n else:\n print(\"Black\")\n"}, {"source_code": "n = int(input())\nx , y = map(int, input().split())\nw = max(x,y)\nb = max(n-x , n-y)\nif w<=b:\n print(\"White\")\nelse:\n print('Black')"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nw=0\nk=min(x,y)\nm=max(x,y)\nw=k-1\nw=w+(m-k)\nb=0\nb=b+(n-m)\nb=b+abs(k-m)\nif k<=b:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif n==1234567890123456 and r==1234567889969697 and s==153760:\n print(\"White\")\nelse:\n if z1<z2:\n z=z1\n else:\n z=z2\n k1=n-r\n k2=n-s\n if k1<k2:\n k=k1\n else:\n k=k2\n zx=z+(z1-z)\n z=z+zx\n kx=k+(k1-k)\n k=k+kx\n if z<k:\n print(\"White\")\n elif z>k:\n print(\"Black\")\n else:\n print(\"White\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nif x + y - min(x,y)<= n - x + n - y - min(n - x, n - y):\n print('white')\nelse:\n print('Black')\n"}, {"source_code": "import math\n\nn = input()\ncoin = input()\ncoin = coin.split()\ncoin[0] = int(coin[0])\ncoin[1] = int(coin[1])\n\nwhite_king = [1, 1]\nblack_king = [int(n), int(n)]\n\nwhite_distance = math.sqrt((white_king[0] - coin[0])**2 + (white_king[1] - coin[1])**2)\nblack_distance = math.sqrt((black_king[0] - coin[0])**2 + (black_king[1] - coin[1])**2)\n\nif white_distance == black_distance or white_distance < black_distance:\n print('WHITE')\nelif black_distance < white_distance:\n print('BLACK')\n"}, {"source_code": "input()\na, b = map(int, input().split())\nif a % 2 == 0 and b % 2 == 0:\n print(\"Black\")\nelif a % 2 != 0 and b % 2 != 0:\n print(\"Black\")\nelse: print(\"White\")"}, {"source_code": "n=int(input())\nb=n+1\nz=0\nx,y=map(int,input().split())\nif(n==x and x==y):\n print(\"BLACK\")\nfor i in range(1,n+1):\n for j in range(1,b):\n if x==i and y==j:\n z=1\n b=b-1\nif(z==1):\n print(\"WHITE\")\nelse:\n print(\"BLACK\")\n "}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\na=x-1/y-1 \nb=n-x/n-y \nif a>b:\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split(\" \"))\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif white == black:\n\tprint(\"White\")\nelif white < black:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nif (x%2 == 1 and y%2 == 1) or (x%2 == 0 and y%2 == 0):\n print('Black')\nelse:\n print('White')"}, {"source_code": "import math\n\nn = int(input())\n\nx, y = map(int, input().split())\n\nwhite_king_k = (1, 1)\nblack_king_k = (n, n)\n\n\nif math.sqrt((x - white_king_k[0]) ** 2 + (y - white_king_k[1]) ** 2) > math.sqrt((x - black_king_k[0]) ** 2 + (y - black_king_k[1]) ** 2):\n print('Black')\nelif math.sqrt((x - white_king_k[0]) ** 2 + (y - white_king_k[1]) ** 2) < math.sqrt((x - black_king_k[0]) ** 2 + (y - black_king_k[1]) ** 2):\n print('White')\nelif math.sqrt((x - white_king_k[0]) ** 2 + (y - white_king_k[1]) ** 2) == math.sqrt((x - black_king_k[0]) ** 2 + (y - black_king_k[1]) ** 2):\n print('White')\n\n"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split())\nif math.sqrt((x-1)**2 + math.sqrt(y-1)**2) <= math.sqrt((n-x)**2 + math.sqrt(n-y)**2):\n print('White')\nelse:\n print('Black')"}, {"source_code": "# ##############################\n\nn = int(input())\nx,y = map(int, input().split())\n\nway1 = 0\nway2 = 0\n\nd1 = (y - 1) + abs(x - y)\nd2 = (x - 1) + abs(y - x)\nway1 += min(d1, d2)\n\n\nd1 = (n - y) + abs(x - n)\nd2 = (n - x) + abs(y - n)\nway2 += min(d1, d2)\n#print(d1, d2)\n\n# print(way1, way2)\nif (way1 <= way2):\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "import math\n\nn = int(input())\ns = input()\na = s.split(\" \")\nx, y = int(a[0]), int(a[1])\n\nif x == y and x*2 > n:\n print(\"Black\")\n\nelse:\n dis1 = math.sqrt(pow(x - 1, 2) + pow(y - 1, 2))\n dis2 = math.sqrt(pow(x - n, 2) + pow(y - n, 2))\n\n #print(str(dis1) + \" \"+str(dis2))\n\n if dis1 <= dis2:\n print(\"White\")\n else:\n print(\"Black\")\n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nz=min(x,y)\nw=z-1\nb=n-z\nif w<b:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "import math\n\nn = int(input())\ns = input()\na = s.split(\" \")\nx, y = int(a[0]), int(a[1])\n\nif n == x and n == y:\n print(\"Black\")\nelif x == 1 and y == 1:\n print(\"White\")\n\nelif x-1 == 1 or y-1 == 1:\n print(\"White\")\n\nelse:\n\n dis1 = math.sqrt(pow(x - 1, 2) + pow(y - 1, 2))\n dis2 = math.sqrt(pow(x - n, 2) + pow(y - n, 2))\n\n #print(str(dis1) + \" \"+str(dis2))\n\n if dis1 <= dis2:\n print(\"White\")\n else:\n print(\"Black\")\n"}, {"source_code": "import math\n\nn = input()\ncoin = input()\ncoin = coin.split()\ncoin[0] = int(coin[0])\ncoin[1] = int(coin[1])\n\nwhite_king = [1, 1]\nblack_king = [int(n), int(n)]\n\nwhite_distance = math.sqrt((white_king[0] - coin[0])**2 + (white_king[1] - coin[1])**2)\nblack_distance = math.sqrt((black_king[0] - coin[0])**2 + (black_king[1] - coin[1])**2)\n\nif white_distance == black_distance or white_distance < black_distance:\n print('WHITE')\nelif black_distance < white_distance:\n print('BLACK')\n"}, {"source_code": "n=int(input())\nx,y=input().split()\nx=int(x)\ny=int(y)\ns=x+y\nt=2*n-s\nif s<=t:\n\tprint(\"white\")\nelif t<s:\n\tprint(\"black\")"}, {"source_code": "import math\nn = int(input())\nx, y = input().split()\nw1, w2 = 1, 1\nb1, b2 = n, n\ndb = math.sqrt((abs(b1-int(x)) ** 2) + (abs(b2-int(y) ** 2)))\ndw = math.sqrt((abs(w1-int(x)) ** 2) + (abs(w2-int(y) ** 2)))\nif dw > db:\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nif x + y - min(x,y)<= n - x + n - y - min(n - x, n - y):\n print('white')\nelse:\n print('Black')\n"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif z1<z2:\n z=z1\nelse:\n z=z2\nk1=n-r\nk2=n-s\nif k1<k2:\n k=k1\nelse:\n k=k2\nzx=z+(z1-z)\nz=z+zx\nkx=k+(k1-k)\nk=k+kx\nif zx<kx:\n print(\"White\")\nelif zx>kx:\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "n=int(input())\na,b=map(int,input().split())\nl=((a-1)**2+(b-1)**2)**0.5\nk=((n-a)**2+(n-b)**2)**0.5\n#print(l,k)\nif l<=k:\n print(\"White\")\nelse:\n print(\"Black\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\nif x==1 and y==1:\n print('White')\n exit(0)\nif (x%2 == 1 and y%2 == 1) or (x%2 == 0 and y%2 == 0):\n print('Black')\nelse:\n print('White')"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif z1<z2:\n z=z1\nelse:\n z=z2\nk1=n-r\nk2=n-s\nif k1<k2:\n k=k1\nelse:\n k=k2\nzx=z+(z1-z)\nz=z+zx\nkx=k+(k1-k)\nk=k+kx\nif zx<kx:\n print(\"White\")\nelif zx>kx:\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "n=int(input())\na=input()\na=a.split()\nfor i in range(len(a)):\n a[i]=int(a[i])\nx=a[0]-1\nif x<0:\n x=x*-1\nprint(x,'x')\ny=a[0]-n\nif y<0:\n y=y*-1\nprint(y,'y')\nxx=a[1]-1\nif xx<0:\n xx=xx*-1\nprint(xx,'xx')\nyy=a[1]-n\nif yy<0:\n yy=yy*-1\nprint(yy,'yy')\nif xx+x<yy+y or xx+x==yy+y:\n print('white')\nelse:\n print('black')\n"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif n==1234567890123456 and r==1234567889969697 and s==153760:\n print(\"White\")\nelse:\n if z1<z2:\n z=z1\n else:\n z=z2\n k1=n-r\n k2=n-s\n if k1<k2:\n k=k1\n else:\n k=k2\n zx=z+(z1-z)\n z=z+zx\n kx=k+(k1-k)\n k=k+kx\n if z<k:\n print(\"White\")\n elif z>k:\n print(\"Black\")\n else:\n print(\"White\")"}, {"source_code": "n=int(input())\nb=n+1\nz=0\nx,y=map(int,input().split())\nif(n==x and x==y):\n print(\"BLACK\")\nfor i in range(1,n+1):\n for j in range(1,b):\n if x==i and y==j:\n z=1\n b=b-1\nif(z==1):\n print(\"WHITE\")\nelse:\n print(\"BLACK\")\n "}, {"source_code": "n = input();\nx,y = raw_input().split();\nx=int(x);\ny=int(y);\nwhitecolumn = 1;\nwhiterow = 1;\nblackcolumn = n;\nblackrow = n;\nwhile True:\n if whiterow < x and whitecolumn < y:\n whiterow+=1;\n whitecolumn+=1;\n elif whiterow == x and whitecolumn < y:\n whitecolumn+=1;\n elif whiterow < x and whitecolumn == y:\n whiterow+=1;\n\n\n if blackrow > x and blackcolumn > y:\n blackrow-=1;\n blackcolumn-=1;\n elif blackrow == x and blackcolumn > y:\n blackcolumn-=1;\n elif blackrow > x and blackcolumn == y:\n blackrow-=1;\n if whiterow==x and whitecolumn==y:\n res=\"White\";\n break;\n elif blackrow==x and blackcolumn==y:\n res=\"Black\";\n break;\nprint(res);"}, {"source_code": "import math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\n\nn=int(input())\n\n\nx,y = map(int, raw_input().split())\n\n\nmovew=min(x,y)+max(x,y)-min(x,y)\n\nx=n-x\ny=n-y\n\nmoveb=min(x,y)+max(x,y)-min(x,y)\n\n#print(movew)\n#print(moveb)\nif movew <= moveb:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "#coding: utf-8\n\nn = int(input())\nx, y = map(int, input().split())\n\nif x - 1 < y - 1:\n w = y - 1\nelse:\n w = x - 1\n \nif n - x < n - y:\n b = n - y\nelse:\n b = n - x\n \nif b > w:\n print('Black')\nelse:\n print('White')"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nif y > x: x, y = y, x\ndist1 = y + (x - y) - 1\ndist2 = (n - y) + (x - y) - 1\nprint('White' if dist1 <= dist2 else 'Black')"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nw=0\nk=min(x,y)\nm=max(x,y)\nw=k-1\nw=w+(m-k)\nb=0\nb=b+(n-m)\nb=b+abs(k-m)\nif k<=b:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "import math\n\nn = int(input())\nx, y = map(int, input().split(\" \"))\n\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif n % 2 == 0:\n\tif white == black:\n\t\tif x > n / 2 and y > n / 2:\n\t\t\tprint(\"Black\")\n\t\telse:\n\t\t\tprint(\"White\")\nelse:\n\tif white == black:\n\t\tprint(\"White\")\n\telif white < black:\n\t\tprint(\"White\")\n\telif x > n / 2 and y > n / 2:\n\t\tprint(\"Black\")\n\telse:\n\t\tprint(\"Black\")"}, {"source_code": "n=int(input())\nr,s=map(int,input().split())\nz1=r-1 \nz2=s-1\nif z1<z2:\n z=z1\nelse:\n z=z2\nk1=n-r\nk2=n-s\nif k1<k2:\n k=k1\nelse:\n k=k2\nzx=z+(z1-z)\nz=z+zx\nkx=k+(k1-k)\nk=k+kx\nif zx<kx:\n print(\"White\")\nelif zx>kx:\n print(\"Black\")\nelse:\n print(\"White\")\n"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nk=((x-1)^2+(y-1)^2)\nl=((n-x)^2+(n-y)^2)\nif(k>l):\n\tprint(\"black\")\nelse:\n\tprint(\"white\")\n"}, {"source_code": "n=int(input())\nx,y=[int(i) for i in input().split()]\nif n-x>x-1:\n if n-y>y-1:\n print(\"black\")\n else:\n print(\"white\")\nelse:\n if n-y>y-1:\n print(\"white\")\n else:\n print(\"black\")\n \n"}, {"source_code": "import math\n\nn = int(input())\nx, y = map(int, input().split(\" \"))\n\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\n\nif white == black:\n\tif x > int(n / 2) and int(y > n) / 2:\n\t\tprint(\"Black\")\n\telse:\n\t\tprint(\"White\")\nelif white < black:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nimport math\na=x+y-2\nb=math.fabs(x+y-2*n)\nif (a>b):\n\tprint('black')\nelse:\n\tprint('white')"}, {"source_code": "input()\na, b = map(int, input().split())\nif a % 2 == 0 and b % 2 == 0:\n print(\"Black\")\nelif a % 2 != 0 and b % 2 != 0:\n print(\"Black\")\nelse: print(\"White\")"}, {"source_code": "n = int(input())\nx, y = map(int, input().split())\nprint(\"Black\" if max(x-1, y-1) > max(n-x, -y) else \"White\")"}, {"source_code": "n=int(input())\nx,y=[int(i) for i in input().split()]\nif n-x>x-1:\n if n-y>y-1:\n print(\"black\")\n else:\n print(\"white\")\nelse:\n if n-y>y-1:\n print(\"white\")\n else:\n print(\"black\")\n \n"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split())\nif math.sqrt((x-1)**2 + math.sqrt(y-1)**2) <= math.sqrt((n-x)**2 + math.sqrt(n-y)**2):\n print('White')\nelse:\n print('Black')"}, {"source_code": "n = int (input())\na,b = map(int,input().split())\np=n\nz=0\nq=0\nif a==b==1:\n print('White')\nelif a == n and b==n:\n print('Black')\nelse:\n while a!=n and b!=n:\n n=n-1\n z=z+1\n if a==n and b==n:\n z=z\n elif a == n:\n if b-n>0:\n z=z+(b-n)\n else:z = z + (n-b)\n elif b==n:\n if a-n>0:\n z=z+(a-n)\n else:\n z=z+(n-a)\n while a!=p and b!=p:\n p=p-1\n q=q+1\n if a==p and b==p:\n q=q\n elif a == p:\n if (b-p)>0:\n q=q+(b-p)\n else:\n q=q+(p-b)\n elif b==p:\n if a-p>0:\n q=q+(a-p)\n else:q=q+(p-a)\nif z<q:\n print('Black')\nelse:\n print('White')\n"}, {"source_code": "import math\nn = int(input())\nx, y = input().split()\nw1, w2 = 1, 1\nb1, b2 = n, n\ndb = math.sqrt((abs(b1-int(x)) ** 2) + (abs(b2-int(y) ** 2)))\ndw = math.sqrt((abs(w1-int(x)) ** 2) + (abs(w2-int(y) ** 2)))\nif dw > db:\n print(\"Black\")\nelse:\n print(\"White\")"}, {"source_code": "import math\n\nn = int(input())\nx, y = map(int, input().split(\" \"))\n\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif x == n and y == n:\n\tprint(\"Black\")\nelse:\n\tif n % 2 == 0:\n\t\tif white == black:\n\t\t\tif x > n / 2 and y > n / 2:\n\t\t\t\tprint(\"Black\")\n\t\t\telse:\n\t\t\t\tprint(\"White\")\n\telse:\n\t\tif white == black:\n\t\t\tprint(\"White\")\n\t\telif white < black:\n\t\t\tprint(\"White\")\n\t\telif x > n / 2 and y > n / 2:\n\t\t\tprint(\"Black\")\n\t\telse:\n\t\t\tprint(\"Black\")"}, {"source_code": "import math\n\nn = int(input())\nx, y = map(int, input().split(\" \"))\n\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\n\nif white == black:\n\tif x > n / 2 and y > n / 2:\n\t\tprint(\"Black\")\n\telse:\n\t\tprint(\"White\")\nelif white < black:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "n = int(input())\nx,y = map(int,input().split())\n\nif x*y>2*n or n == x == y:\n print('Black')\nelse:\n print('White')\n\n\n\n\n\n\n\n\n"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split(\" \"))\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\nif x - 1 < x - n and y - 1 < y - n:\n\tprint(\"White\")\nelif x - 1 > x - n and y - 1 > y - n:\n\tprint(\"Black\")\nelse:\n\tif white == black:\n\t\tprint(\"White\")\n\telif x > n / 2 and y > n / 2:\n\t\tprint(\"Black\")\n\telif white < black:\n\t\tprint(\"White\")\n\telse:\n\t\tprint(\"Black\")"}, {"source_code": "n = int(input())\n#It takes two numbers separeted by \"space\" and then splits them\nxy = list(input(\"\").split( ))\n#Asigning two vars x,y of a coin\nxCoin = int(xy[0])\nyCoin = int(xy[1])\n# First n stands for colomn, second stands for rows\n\nclass King:\n \n def __init__(self, x, y, colour):\n self.x = x\n self.y = y\n self.colour = colour\n\n def move(self):\n global xCoin, yCoin\n \n if xCoin == self.x and yCoin == self.y:\n print(\"%s\" % (self.colour))\n \n elif xCoin == yCoin:\n print(\"White\")\n \n elif xCoin > yCoin:\n print(\"White\")\n else: #xCoin < yCoin\n print(\"Black\")\n \nking1 = King(1, 1, 'White')\nking2 = King(n, n, 'Black')\n\nking2.move()"}, {"source_code": "n=int(input())\nx,y=map(int,input().split())\nw=0\nk=min(x,y)\nm=max(x,y)\nw=k-1\nw=w+(m-k)\nb=0\nb=b+(n-m)\nb=b+abs(k-m)\nif k<=b:\n print('White')\nelse:\n print('Black')\n"}, {"source_code": "import math\n\nn = int(input())\nx, y = map(int, input().split(\" \"))\n\nwhite = math.sqrt((x - 1) * (x - 1) + (y - 1) * (y - 1))\nblack = math.sqrt((x - n) * (x - n) + (y - n) * (y - n))\n\nif white == black:\n\tif x > n / 2 and y > n / 2:\n\t\tprint(\"Black\")\n\telse:\n\t\tprint(\"White\")\nelif white < black:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")"}, {"source_code": "\nn=int(raw_input())\n\na,b=map(int,raw_input().split())\n\nw=max(a-1,b-1)\nb=max(n-a,n-b)\n\nif w>=b:\n print 'White'\n exit()\nprint 'Black'\nexit()\n"}, {"source_code": "import math\nn = int(input())\nx, y = map(int, input().split())\nif math.sqrt((1 - x) ** 2 + (1 - y) ** 2) <= math.sqrt((n - x) ** 2 + (n - y) ** 2):\n print('White')\nelse:\n print('Black')"}], "src_uid": "b8ece086b35a36ca873e2edecc674557"} {"source_code": "from string import lowercase\nx=raw_input()\ny=raw_input()\nz=[]\na=lowercase\nif 1<=len(x)<=100 and len(x)==len(y) and x.islower() and y.islower():\n for i,j in enumerate(x):\n if j==y[i]:\n if j!='z':\n z.append(a[a.index(j)+1])\n else:z.append('z')\n elif j>y[i]:\n z.append(y[i])\n elif j<y[i]:\n print -1\n exit()\n print ''.join(z)\n\n", "positive_code": [{"source_code": "s=input()\nl=input()\nfor i in range(len(s)):\n if(s[i]<l[i]):\n print(-1)\n break\nelse:\n print(l)"}, {"source_code": "import sys\nimport math\nimport bisect\nimport itertools\nimport random\nimport re\n\ndef solve(x, y):\n n = len(x)\n for i in range(n):\n if ord(y[i]) > ord(x[i]):\n return False\n return True\n\ndef main():\n x = input()\n y = input()\n if solve(x, y):\n print(y)\n else:\n print(-1)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def find_z(x, y):\n z = []\n for i in range(len(x)):\n if x[i] < y[i]:\n return -1\n else:\n z.append(y[i])\n return \"\".join(z)\n\ndef f(x, z):\n y = \"\"\n for i in range(len(x)):\n y += min(x[i], z[i])\n return y\n\nif __name__ == '__main__':\n x = input()\n y = input()\n print(find_z(x, y))"}, {"source_code": "x, y = input(), input()\nprint(-1 if any(ch1 < ch2 for ch1, ch2 in zip(x, y)) else y)"}, {"source_code": "from sys import maxsize, stdout, stdin, stderr\n# mod = int(1e9 + 7)\nimport re # can use multiple splits\ntup = lambda: map(int, stdin.readline().split())\nI = lambda: int(stdin.readline())\nlint = lambda: [int(x) for x in stdin.readline().split()]\nS = lambda: stdin.readline().replace('\\n', '').strip()\ndef grid(r, c): return [lint() for i in range(r)]\ndef debug(*args, c=6): print('\\033[3{}m'.format(c), *args, '\\033[0m', file=stderr)\nstpr = lambda x : stdout.write(f'{x}' + '\\n')\nstar = lambda x : print(' '.join(map(str , x)))\n\n# n = I()\n# ls =lint()\n# arr =[n]*n\n# d = n\n# for i in range(n):\n# if ls[i]==0:\n# d=0\n# else:\n# d+=1\n# arr[i] = d\n# d = n\n# for i in range(n-1,-1,-1):\n# if ls[i]==0:\n# d=0\n# else:\n# d+=1\n# arr[i] = min(d , arr[i])\n# star(arr)\n#\na = S()\nf= S()\nx = ''\nfor i in range(len(a)):\n if a[i] > f[i]:\n x +=f[i]\n else:\n x+=a[i]\nb =''\nfor i in range(len(a)):\n b+=min(a[i],x[i] )\nif b !=f:\n print(\"-1\")\nelse:print(x)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "s1=input()\ns2=input()\nfor i in range(len(s1)):\n\tif ord(s1[i])<ord(s2[i]):\n\t\tprint(-1)\n\t\texit(0)\nprint(s2)\n\t"}, {"source_code": "x = input()\ny = input()\nn = len(x)\nres = ''\nfor i in range(n):\n if x[i] < y[i]:\n res = '-1'\n break\n else:\n res +=y[i]\n\nprint(''.join(res))\n\n \n"}, {"source_code": "x = list(input()); y = list(input())\nprint(-1 if any(b>a for a, b in zip(x,y)) else ''.join(y))"}, {"source_code": "s=input()\nt=input()\nz=[]\nflag=0\nfor i in range(len(s)):\n\tif(ord(t[i])>ord(s[i])):\n\t\tprint(-1)\n\t\tflag=1\n\t\tbreak\n\telse:\n\t\tif(ord(t[i])<=ord(s[i])):\n\t\t\tz.append(t[i])\nif(flag==0):\n\tprint(''.join(z))"}, {"source_code": "'''input\nab\nba\n'''\nx, y = input(), input()\nfor i in range(len(x)):\n\tif x[i] < y[i]:\n\t\tprint(-1)\n\t\tbreak\nelse:\n\tprint(y) \n"}, {"source_code": "s = input()\nt = input()\nres = ''\nmi = 'a'\nflag = True\nfor i in range(len(s)):\n a = s[i]\n b = t[i]\n if a == b:\n res += a\n else:\n if b < a and b >= mi:\n res += b\n else:\n flag = False\n break\nif flag:\n print(res)\nelse:\n print(-1)"}, {"source_code": "x=input()\ny=input()\nflag=0\nz=\"\"\nfor i in range(len(x)):\n\tif ord(x[i])<ord(y[i]):\n\t\tprint(-1)\n\t\tflag=1\n\t\tbreak\n\telse:\n\t\tif x[i]==y[i]:\n\t\t\tz+=x[i]\n\t\telse:\n\t\t\tz+=y[i]\nif flag==0:\t\t\t\n\tprint(z)"}, {"source_code": "a = list(input())\nb = list(input())\nfor i in range(len(a)):\n if(a[i]<b[i]):\n print(-1)\n exit(0)\nprint(\"\".join(b))"}, {"source_code": "a=input()\nb=input()\nd=1\nk=''\nc='abcdefghijklmnopqrstuvwxyz'\nfor i in range(len(a)):\n\tif c.index(a[i])<c.index(b[i]):\n\t\tprint(-1)\n\t\td=d-1\n\t\tbreak\n\telif a[i]==b[i]:\n\t\tk=k+'z'\n\telse:\n\t\tk=k+b[i]\nif d>0:\n\tprint(k)\n"}, {"source_code": "\nq1=input()\nans=input()\nq2=''\nt=1\nfor i in range(len(q1)):\n if q1[i]==ans[i]:\n stt=ord(ans[i])+1\n tmp=chr(stt)\n if tmp>='a' and tmp<='z':\n q2+=tmp\n else:\n q2+=ans[i]\n elif ord(q1[i])<ord(ans[i]):\n t=-1\n break\n else:\n q2+=ans[i]\n\nif t==-1:\n print('-1')\nelse:\n print(q2)\n"}, {"source_code": "s1 = input()\ns2 = input()\nn = len(s1)\nresult = ''\nfor i in range(0,n):\n if(s2[i]>s1[i]):\n result = -1\n break\n elif(s2[i]<s1[i]):\n result += s2[i]\n else:\n if(s1[i]=='z'):\n result+='z'\n else:\n result += chr(ord(s1[i]) + 1)\nprint(result)"}, {"source_code": "x=input()\ny=input()\n\nres=\"\"\nmc=ord('a')\nfor i in range (len(x)):\n temp=ord(x[i])\n temp1=ord(y[i])\n if temp1>temp:\n break\n elif temp1==temp:\n res+='z'\n elif temp==ord('z'):\n res+=y[i]\n elif temp==ord('a') or temp1==ord('a'):\n res+='a'\n else:\n res+=chr(min(temp,temp1))\n\nprint(res if len(res)==len(x) else -1)\n"}, {"source_code": "a=input()\nb=input()\nc=\"\"\nfor i in range(0,len(b)):\n\tif(a[i]==b[i]):\n\t\tc=c+a[i]\n\telif(a[i]<b[i]):\n\t\tprint(-1)\n\t\texit()\n\telse:\n\t\tc=c+b[i]\t\nprint(c)\n"}, {"source_code": "x = str(input())\n\ny = str(input())\n\na = ''\n\nfor i in range(len(x)):\n\n\tif x[i]==y[i]:\n\t\ta+=chr(ord(x[i]))\n\n\telif x[i]>y[i]:\n\t\ta+=y[i]\n\n\telse:\n\t\ta = '-1'\n\t\tbreak\n\n\nif(a[-1]!='-1'):\n\tprint(a)\n\nelse:\n\tprint('-1')\n"}, {"source_code": "a,b=open(0)\nprint([b,-1][any(y>x for x,y in zip(a,b))])"}, {"source_code": "import string\nx = input()\ny = input()\nalpha = string.ascii_lowercase\nans = \"\"\nfor i in range(len(x)):\n if alpha.index(x[i]) == alpha.index(y[i]):\n ans += x[i]\n elif alpha.index(x[i]) > alpha.index(y[i]):\n ans += y[i]\n else:\n ans = -1\n break\nprint(ans)"}, {"source_code": "def ibb(x,z):\n alf='abcdefghijklmnopqrstuvwxyz'\n ret = ''\n for i in range(len(x)):\n idz=alf.index(z[i])\n idx=alf.index(x[i])\n if(idz <= idx):\n ret+=z[i]\n else:\n #print -1\n return -1\n return ret\n\nx = raw_input()\nz = raw_input()\n\nprint ibb(x,z)"}, {"source_code": "x, y = input(), input()\nfor i in range(len(x)) :\n if ord(x[i]) < ord(y[i]) :\n print(-1)\n break\nelse :\n print(y)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jan 15 14:15:15 2018\n\n@author: Paras Sharma\n\"\"\"\n\na=input()\nc=[]\nb=input()\nd=[]\nfinal=\"\"\nk=0\nfor i in range(len(a)):\n c.append(a[i])\n d.append(b[i])\nfor i in range(len(a)):\n if b[i]>a[i]:\n k+=1\n print(-1)\n break\n final+=min(a[i],b[i])\n\nif k==0:\n print(final)\n"}, {"source_code": "a,b=raw_input(),raw_input()\nfor x,y in zip(a,b):\n if x<y:\n print -1\n break\nelse:\n print b"}, {"source_code": "import math\nimport re\n\nx = str(raw_input())\ny = str(raw_input())\nz = \"\"\n\nfor i in range(len(x)):\n if y[i] > x[i]:\n z = -1\n break\n elif x[i] == y[i]:\n z += \"z\"\n else:\n z += y[i]\n\nprint z\n\n\n\n\n\n\n\n\n\n\n\n# def count_overlapping_substrings(haystack, needle):\n# count = 0\n# i = -1\n# while True:\n# i = haystack.find(needle, i+1)\n# if i == -1:\n# return count\n# count += 1\n#\n#\n# s = str(raw_input())\n# m = count_overlapping_substrings(s, \"VK\")\n#\n# if len(s) == 1:\n# print 0\n# else:\n# for i in range(len(s)):\n# if s[i] == \"V\":\n# q = count_overlapping_substrings(str(s[:i] + \"K\" + s[i+1:]), \"VK\")\n# if q > m:\n# m = q\n# else:\n# q = count_overlapping_substrings(str(s[:i] + \"V\" + s[i + 1:]), \"VK\")\n# if q > m:\n# m = q\n# print m"}, {"source_code": "s1=input()\ns2=input()\ns=\"\"\nf=True\nfor i in range(len(s1)):\n\tif(s1[i]==s2[i]):\n\t\tif(ord(s1[i])+1<=122):\n\t\t\ts+=chr(ord(s1[i])+1)\n\t\telse:\n\t\t\ts+='z'\n\telif(s1[i]<s2[i]):\n\t\tf=False\n\t\tbreak\n\telse:\n\t\ts+=s2[i]\nif(f==True):\n\tprint(s)\nelse:\n\tprint(-1)"}, {"source_code": "x = input()\ny = input()\n\nalf = 'abcdefghijklmnopqrstuvwxyz'\n\nz = ''\n\nfor i in range(len(x)):\n\tif y[i] == x[i]:\n\t\tz += x[i]\n\telif alf.find(x[i]) < alf.find(y[i]):\n\t\tprint('-1')\n\t\tbreak\n\telif alf.find(x[i]) > alf.find(y[i]):\n\t\tz += y[i]\n\nelse:\n\tprint(z)"}, {"source_code": "import sys\n\nx = raw_input()\ny = raw_input()\nz = []\n\nfor i in xrange(len(x)):\n if y[i] > x[i]:\n print -1\n sys.exit()\n z.append(y[i])\n\nprint ''.join(z)\n\n\n"}, {"source_code": "x = input()\ny = input()\nz = str()\nfor i in range(len(x)):\n if x[i] >= y[i]:\n z += y[i]\n else:\n print(-1)\n exit()\nprint(z)"}, {"source_code": "x = input()\ny = input()\nz = []\nflag=0\nfor i in range(len(x)):\n if x[i]<y[i]:\n print(-1)\n flag=1\n break\n else:\n z.append(y[i])\nif flag==0:\n print(''.join(y))"}, {"source_code": "x = list(raw_input())\ny = list(raw_input())\nz = ''\nflag = True\nfor i, s in enumerate(y):\n\tif s == x[i]:\n\t\tz += s\n\telse:\n\t\tif s > x[i]:\n\t\t\tflag = False\n\t\t\tbreak\n\t\telse:\n\t\t\tz += s \nif flag:\n\tprint z\nelse:\n\tprint -1"}, {"source_code": "def invF():\n\tx=input()\n\ty=input()\n\n\tif(len(x)!=len(y)):\n\t\tprint(-1)\n\t\treturn\n\n\tst=\"\"\n\tfor i in range(len(x)):\n\t\tif(y[i]>x[i]):\n\t\t\tprint(-1)\n\t\t\treturn\n\t\telif(y[i]==x[i]):\n\t\t\tif(y[i]!='z'):\n\t\t\t\tst = st + chr( ord( y[i] ) + 1 ) \n\t\t\telse:\n\t\t\t\tst = st + 'z'\n\t\telse:\n\t\t\tst = st + y[i]\n\n\tprint(st)\n\ninvF()\t\t"}, {"source_code": "x=input()\ny=input()\nz=list()\nfor i in range(len(y)):\n if y[i]==x[i]: #z[i]>x[i]\n stt=ord(y[i])+1\n tmp=chr(stt)\n if tmp>='a' and tmp<='z':\n z.append(tmp)\n else:\n z.append(y[i])\n elif y[i]>x[i]:\n print(-1)\n exit()\n else:\n z.append(y[i])\nfor i in z:\n print(i, end=\"\")"}, {"source_code": "x = raw_input().rstrip()\nz = raw_input().rstrip()\n\ny, flag = \"\", True\nfor i in range(len(x)):\n if z[i] > x[i]:\n flag = False\n break\n else:\n y += min(z[i], x[i])\n\nif flag:\n print y\nelse:\n print -1"}, {"source_code": "x = raw_input()\nz = raw_input()\n\nn = len(x)\nflag = 1\nfor i in range(n):\n if z[i] > x[i]:\n flag = 0\n print -1\n break;\nif flag:\n print z"}, {"source_code": "from sys import stdin,stdout\n\nimport bisect\n\nimport math\n\ndef st():\n return list(stdin.readline().strip())\n\ndef inp():\n return int(stdin.readline())\n\ndef li():\n return list(map(int,stdin.readline().split()))\n\ndef mp():\n return map(int,stdin.readline().split())\n\ndef pr(n):\n stdout.write(str(n)+\"\\n\")\n\ndef soe(limit):\n l=[1]*(limit+1)\n prime=[]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n return prime\n\ndef segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n\ndef power(a,n):\n r=1\n while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n return r\n \ndef solve():\n x=input()\n y=input()\n z=''\n c=0\n for i in range(len(y)):\n if x[i]<y[i]:\n c=1\n break\n if c:\n pr(-1)\n else:\n for i in range(len(y)):\n if x[i]>y[i]:\n z+=y[i]\n else:\n z+=x[i]\n pr(z)\n \nfor _ in range(1):\n solve()\n \n"}, {"source_code": "import itertools as it\nimport re\nfrom math import *\ndef rt():\n return raw_input()\ndef rn():\n return int(raw_input())\ndef rns():\n return map(int,raw_input().split())\n\ns1=rt()\ns2=rt()\n\nr=\"\"\nfor (c1,c2) in zip(s1,s2):\n if c1>=c2:\n r+=c2\n else:\n r=\"-1\"\n break\nprint r\n"}, {"source_code": "s = input()\nt = input()\n\nfor i in range(len(s)):\n\tif ord(s[i]) < ord(t[i]):\n\t\tprint(-1)\n\t\texit()\n\nl = ['a'] * len(s)\nfor i in range(len(s)):\n\tl[i] = chr(min(ord(s[i]), ord(t[i])))\n\nprint(''.join(l))\n"}, {"source_code": "x = raw_input().strip()\nz = raw_input().strip()\n\nlenx = len(x)\n\ny = \"\"\n\ni = 0\nwhile i < lenx:\n\txi = x[i]\n\tzi = z[i]\n\tif ord(zi) > ord(xi):\n\t\tprint -1\n\t\texit()\n\ty += chr(min(ord(xi),ord(zi)))\n\ti += 1\nprint y"}, {"source_code": "x = input()\ny = input()\nprint( -1 if any( ord( x[ i ] ) < ord( y[ i ] ) for i in range( len( x ) ) ) else y )\n"}, {"source_code": "x=input();y=input()\nb=[]\nfor i in range(len(x)):\n if y[i]>x[i]:\n print(-1);exit(0)\n else:\n b.append(y[i])\nprint(''.join(b))"}, {"source_code": "x = input()\ny = input()\n\nabcd = \"abcdefghijklmnopqrstuvwxyz\"\nchdx = {x:i for i, x in enumerate(abcd)}\ndxchar = {i:x for i, x in enumerate(abcd)}\nx_idx = [chdx[i] for i in x]\ny_idx = [chdx[i] for i in y]\n\nflag = 0\nfor i, j in zip(x_idx, y_idx):\n if j > i:\n flag = 1\n break\n\nif flag == 1:\n print(-1)\nelse:\n z = y\n for i in range(len(x_idx)):\n if x_idx[i] == y_idx[i]:\n y_idx[i] = 25\n output = [dxchar[i] for i in y_idx]\n print(\"\".join(output))\n"}, {"source_code": "x=input()\ny=input()\n\nflag=0\nfor i in range(len(x)):\n\tif y[i] > x[i] :\n\t\tflag=1\n\t\tbreak\nout =''\nif flag == 1:\n\tprint(-1)\nelse:\n\tfor j in range(len(x)):\n\t\tout += min(x[j],y[j])\n\tprint(out)"}, {"source_code": "x = raw_input()\nz = raw_input()\ny = \"\"\nfor i in xrange(len(x)):\n\tif(ord(z[i]) - ord(x[i]) > 0):\n\t\tprint -1\n\t\texit()\n\tif(ord(x[i]) == ord(z[i])):\n\t\ty+=x[i]\n\telse:\n\t\ty+=z[i]\nprint y"}, {"source_code": "x = list(input())\ny = list(input())\n\nz = []\nfor i in range(len(x)):\n if x[i] < y[i]:\n break\n z.append(y[i])\n\nif len(z) == len(y):\n print(''.join(z))\nelse:\n print(-1)\n"}, {"source_code": "x=input()\nz=input()\ny=''\nfor i in range (len(z)):\n if z[i]<x[i]:\n y=y+z[i]\n elif z[i]==x[i] :\n y=y+'z'\n else :\n print (-1)\n break\nif len(y)==len(x):\n print(y)\n"}, {"source_code": "s1 = raw_input().strip()\ns2 = raw_input().strip()\n\npossible = True\n\nfor x, y in zip(s1, s2):\n if y > x:\n possible = False\n break\n\nif not possible:\n print -1\nelse:\n print s2\n"}, {"source_code": "x = input()\ny = input()\nz = ''\nfor i in range(len(x)):\n if x[i] < y[i]:\n print(-1)\n break\n else:\n z+= y[i]\nelse:\n print(z)"}, {"source_code": "x=input()\ny=input()\nval=True\n\nfor i in range(0,len(x)):\n if(x[i]<y[i]):\n val=False\nif val:\n print(y)\nelse:\n print(\"-1\")\n"}, {"source_code": "x = raw_input()\ny = raw_input()\nz = ''\nfor i in xrange(len(x)):\n if y[i]>x[i]:\n z = -1\n break\n else:\n z += y[i]\nprint z"}, {"source_code": "a = raw_input()\nb = raw_input()\nfor i in range(len(a)):\n\tif b[i] > a[i]:\n\t\tprint '-1'\n\t\tbreak\nelse:\n\tprint b"}, {"source_code": "s1=raw_input()\ns2=raw_input()\nif len(s1)==1 and s2<=s1:\n print s2\nelse:\n x=0\n for c in range(len(s1)):\n if s2[c]>s1[c]:\n print -1\n x=1\n break\n if x==0:\n print s2\n"}, {"source_code": "x = raw_input().strip()\nz = raw_input().strip()\n\nif any(c1 < c2 for c1, c2 in zip(x, z)):\n print -1\nelse:\n print z\n"}, {"source_code": "x = raw_input()\ny = raw_input()\n\nans = []\nfor i in range(len(x)):\n if ord(y[i]) > ord(x[i]):\n print -1\n exit()\n if x[i] != y[i]:\n ans.append(y[i])\n else:\n ans.append(x[i])\nprint ''.join(ans)"}, {"source_code": "a=raw_input()\nb=raw_input()\nfor i in range(len(a)):\n if a[i]<b[i]:\n print -1\n exit()\nprint b"}, {"source_code": "y = raw_input()\nz = raw_input()\nn = len(y)\nflg = False\nans = ['']*n\nfor i in range(n):\n\tif z[i]>y[i]:\n\t\tflg = True\n\t\tbreak\n\telif z[i]==y[i]:\n\t\tans[i] = 'z'\n\telse:\n\t\tans[i] = z[i]\nans = \"\".join(ans)\nif flg:\n\tprint -1\nelse:\n\tprint ans"}, {"source_code": "import sys\n\ndef solve(x, y):\n strval = \"\"\n for idx in range(len(x)):\n if x[idx] == y[idx]:\n strval += x[idx]\n else:\n if ord(y[idx]) > ord(x[idx]):\n return \"-1\"\n else:\n strval += y[idx]\n return strval\n\nif __name__ == \"__main__\":\n x = sys.stdin.readline().strip()\n y = sys.stdin.readline().strip()\n print solve(x,y)\n"}, {"source_code": "x=raw_input()\ny=raw_input()\n\nn=len(x)\n\nz=''\nfor i in range(n):\n if x[i]==y[i]:\n z=z+x[i]\n elif x[i]>y[i]:\n z=z+y[i]\n else:\n print -1\n break\nif len(z)==n:\n print z\n\n\n \n \n \n \n \n "}, {"source_code": "x,y = raw_input(), raw_input()\nprint all(a>=b for a,b in zip(x,y)) * y or \"-1\""}, {"source_code": "x = raw_input()\ny = raw_input()\n\nz = []\n\nflag = True\n\nfor i in xrange(len(x)):\n if y[i] > x[i]:\n flag = False\n break\n\nif flag:\n print y\nelse:\n print -1"}, {"source_code": "ans = []\n\nx = raw_input()\nz = raw_input()\n\n\nfor i, j in zip(x, z):\n\n\tif i == j:\n\t\tans.append(i)\n\telif i > j:\n\t\tans.append(j)\n\n\telif j > i:\n\t\tans = [\"-1\"]\n\t\tbreak\n\nprint \"\".join(ans)\n\t\n\n"}, {"source_code": "x = input()\ny = input()\ns = \"\"\nfor i in range(len(x)):\n if y[i] > x[i]:\n print(-1)\n quit()\nprint(y)\n"}, {"source_code": "# https://codeforces.com/problemset/problem/801/B\n# 900\n\n\nx = input()\ny = input()\nz = \"\"\n\nfor i, xy in enumerate(zip(x, y)):\n xc, yc = xy\n xv = ord(xc)\n yv = ord(yc)\n\n if xv < yv:\n z = -1\n break\n \n z += yc\n\n \n\nprint(z)"}, {"source_code": "x = raw_input().strip()\ny = raw_input().strip()\nok = True\nfor i in range(len(y)):\n if ord(x[i]) < ord(y[i]): ok = False\nif ok: print y\nelse: print -1\n"}, {"source_code": "x = raw_input()\ny = raw_input()\nz = []\nfound = True\nfor i in xrange(len(x)):\n if y[i] > x[i]:\n print -1\n found = False\n break\n else:\n z.append(y[i])\nif(found):\n print ''.join(z)\n\n"}, {"source_code": "s1=raw_input()\ns2=raw_input()\n\ndef val(s1,s2):\n s3=''\n for i in range(len(s1)):\n if ord(s1[i])<ord(s2[i]):\n return -1\n elif s1[i]==s2[i]:\n s3+='z'\n else:\n s3+=s2[i]\n return s3\n\nprint val(s1,s2)"}, {"source_code": "x=input()\n\n\ny=input()\n\np=''\ng=0\nfor k in range(len(x)):\n if ord(y[k])==ord(x[k]):\n if 97<=ord(x[k])<122:\n p+=chr(ord(x[k])+1)\n elif ord(x[k])==122:\n p+=chr(ord(x[k]))\n elif ord(y[k])<ord(x[k]):\n p+=chr(ord(y[k]))\n else:\n print(-1)\n g+=1\n break\n\n\nif g==0:\n print(p)\n"}, {"source_code": "def solve(x, y):\n if len(x) != len(y):\n return -1\n\n sol = []\n for i in range(len(x)):\n if x[i] < y[i]:\n return -1\n else:\n sol.append(y[i])\n return \"\".join(sol)\n\nx = raw_input()\ny = raw_input()\nprint solve(x, y)"}, {"source_code": "str1=str(raw_input())\nstr2=str(raw_input())\n\nstr3=[]\nfoo1=False\nfoo2=False\nfor i in range(len(str1)):\n if str1[i]<str2[i]:\n foo1=True\n break\n else :\n str3.append(min(str1[i],str2[i]))\n \n\nif not foo1:\n print ''.join(str3)\nelse :\n print -1\n"}, {"source_code": "x = input()\nz = input()\nletters = 'abcdefghijklmnopqrstuvwxyz'\ny = ''\nfor c1, c2 in zip(x, z):\n\tif c1 == c2:\n\t\ty += c1\n\telse:\n\t\tif c1 < c2:\n\t\t\tprint(-1)\n\t\t\tbreak\n\t\ty += min(c1, c2)\nelse:\n\tprint(y)\n"}, {"source_code": "s1=input()\ns2=input()\nl=len(s1)\nx=\"\"\nfor i in range(l):\n if s1[i]==s2[i]:\n x+=\"z\"\n elif s1[i]<s2[i]:\n print(-1)\n break\n else:\n x+=s2[i]\nif len(x)==l:\n print(x)\n \n\n \n \n \n \n \n \n \n\n\n\n\n \n \n \n \n \n \n \n \n \n\n \n"}, {"source_code": "s1 = str(input())\ns2 = str(input())\nans = ''\ni =0\nwhile i<len(s1):\n if s2[i]>s1[i]:\n ans = -1\n break\n i = i + 1\nif ans!=-1:\n ans = s2\nprint(ans)"}, {"source_code": "def check(a,b):\n\tw=''\n\tfor i in range(len(a)):\n\t\tif a[i]<b[i]:\n\t\t\treturn -1\n\t\t\n\treturn b\n\t\n\na=input()\nb=input()\nprint(check(a,b))\n"}, {"source_code": "x = input()\ny = input()\n\ndef solve(x, y):\n string = \"\"\n for i in range(len(x)):\n if y[i] <= x[i]:\n string += y[i]\n else:\n return False\n \n return string\n\nanswer = solve(x,y)\nif answer:\n print(answer)\nelse:\n print(-1)"}, {"source_code": "s = str(input())\nt = str(input())\nfor i in range(len(t)):\n if(t[i] > s[i]):\n print(-1)\n exit()\nprint(t)\n#kalay))"}, {"source_code": "s=input()\nl=input()\nprint(-1 if any(s[i]<l[i] for i in range(0,len(s))) else l)\n \n \n "}, {"source_code": "s=str(input())\ns1=str(input())\nd=''\nflag=0\nfor i in range(0,len(s)):\n if(s1[i]>s[i]):\n flag=1\n break\n elif(s1[i]==s[i]):\n d=d+'z'\n else:\n d=d+s1[i]\nif(flag>0):\n print(-1)\nelse:\n print(d)"}, {"source_code": "x,y=input(),input()\nprint('-1' if any(y[i]>x[i] for i in range(len(x))) else y)"}, {"source_code": "x=input()\ny=input()\nn=len(x)\nz=''\nfor i in range(n):\n if(y[i]<=x[i]):\n z+=y[i]\n else:\n n=-1\n break\nif(n==-1):\n print(-1)\nelse:\n print(z)"}, {"source_code": "x = input()\ny = input()\n\nfor i in range(len(x)):\n if(x[i]<y[i]):\n print(-1)\n exit(0)\nprint(y)"}, {"source_code": "def main():\n x = input()\n y = input()\n z = \"\"\n for i in range(0, len(x)):\n \n if (ord(x[i]) - ord(y[i])) < 0:\n print(-1)\n return\n elif (ord(x[i]) - ord(y[i])) == 0:\n z += x[i]\n else:\n z += y[i]\n print(z)\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "def main():\n x = input()\n y = input()\n z = \"\"\n for i in range(0, len(x)):\n \n if (ord(x[i]) - ord(y[i])) < 0:\n print(-1)\n return\n else:\n z += y[i]\n print(z)\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "\nif __name__ == \"__main__\":\n x = input()\n y = input()\n z = \"\"\n for i in range(x.__len__()):\n if(y[i] > x[i]):\n z = \"-1\"\n break\n z = z + y[i]\n \n print(z)"}], "negative_code": [{"source_code": "def reverse(x, y):\n i = 0\n fail = 0\n z = []\n while i < len(x):\n if x[i] == y[i]:\n z.append(x[i])\n elif x[i] < y[i] and x[i] == 'a':\n return -1\n break\n else:\n z.append('z')\n i += 1\n if len(x) == len(z):\n return ''.join(z)"}, {"source_code": "x = input()\ny = input()\nn = len(x)\nres = ''\nfor i in range(n):\n if x[i] < y[i]:\n res = '-1'\n break\n elif x[i]==y[i]:\n res += chr(ord(x[i])+1)\n else:\n res +=y[i]\n\nprint(''.join(res))\n\n \n"}, {"source_code": "import random\n\ns1 = raw_input().strip()\ns2 = raw_input().strip()\n\ndef mine():\n b = ord('z')\n ans = \"\"\n flag = True\n\n if len(s1) != len(s2):\n flag = False\n\n for i in range(len(s1)):\n\n if s2[i] == s1[i]:\n ans += chr(ord('a')+((ord(s1[i]) - ord('a')+1)%26))\n else:\n ans += s2[i]\n\n\n if flag:\n return ans\n else:\n return \"-1\"\n\n\nansy = mine()\nflag = True\nfor i in range(len(s1)):\n if min(ansy[i],s1[i]) != s2[i]:\n flag = False\n break\n\nif flag:\n print ansy\nelse:\n print \"-1\""}, {"source_code": "a,b=raw_input(),raw_input()\nprint -1 if a<b else b"}, {"source_code": "x = input()\ny = input()\n\nz = ''\nfor a, b in zip(x, y):\n if b > a:\n z = '-1'\n break\n else:\n z += a\n\nprint(z)"}, {"source_code": "def invF():\n\tx=input()\n\ty=input()\n\n\tif(len(x)!=len(y)):\n\t\tprint(-1)\n\t\treturn\n\n\tst=\"\"\n\tfor i in range(len(x)):\n\t\tif(y[i]>x[i]):\n\t\t\tprint(-1)\n\t\t\treturn\n\t\telif(y[i]==x[i]):\n\t\t\tst = st + chr( ord( y[i] ) + 1 ) \n\t\telse:\n\t\t\tst = st + y[i]\n\n\tprint(st)\n\ninvF()\t\t"}, {"source_code": "s=input()\nl=input()\nprint(-1 if s<l else l)\n \n \n "}, {"source_code": "#!/usr/bin/env python\n\nimport sys\n\nx = sys.stdin.readline()\ny = sys.stdin.readline()\n\nif x < y:\n print(-1)\nelse:\n print(y)\n"}, {"source_code": "'''input\nab\naa\n'''\nx, y = input(), input()\nz = \"\"\nif y > x:\n\tprint(-1)\nelse:\n\tprint(y) \n"}, {"source_code": "\"\"\"====================================================================================\n ====================================================================================\n \n ___ _______ ___ _______ ___ ___\n | /\\ | | \\ | | / | | | | |\\ /|\n | / \\ | | \\ | | / | | | | | \\ / |\n |___ /____\\ | | \\ | |/ |___| | | | \\/ |\n | / \\ | | / | |\\ |\\ | | | |\n | / \\ | | / | | \\ | \\ | | | |\n ___|/ \\___|___ |___/ ___|___ | \\ | \\ |___| | |\n \n \n ====================================================================================\n ==================================================================================== \n\"\"\"\n# \u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\n\nl = input()\ns = input()\nfor i in range(len(l)):\n if s[i]>l[i]:\n print(-1)\n break\nprint(s)\n\n# \u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\n\"\"\"====================================================================================\n ====================================================================================\n \n ___ _______ ___ _______ ___ ___\n | /\\ | | \\ | | / | | | | |\\ /|\n | / \\ | | \\ | | / | | | | | \\ / |\n |___ /____\\ | | \\ | |/ |___| | | | \\/ |\n | / \\ | | / | |\\ |\\ | | | |\n | / \\ | | / | | \\ | \\ | | | |\n ___|/ \\___|___ |___/ ___|___ | \\ | \\ |___| | |\n \n \n ====================================================================================\n ==================================================================================== \n\"\"\"\n"}, {"source_code": "x=raw_input() #x #nzwzl #z #xiyez #y #niwel\nz=\"\"\ny=raw_input()\nh=0\nfor i in range(len(x)):\n if(x[i]<=y[i] and (ord(x[i])-ord(y[i]))==-1):\n h=1\n break\n if(x[i]<=y[i]):\n z=z+chr(ord(x[i]) + 1)\n else:\n z=z+y[i]\nif(len(z)==len(x)):\n print z\nelif(h==1):\n print \"-1\"\n \n\n"}, {"source_code": "s1=input()\ns2=input()\nr=[]\nf=0\nfor i in range(len(s1)):\n\tif(s1[i]==s2[i]):\n\t\tif(ord(s1[i])==122):\n\t\t\tr.append(chr(ord(s1[i])-1))\n\t\telse:\n\t\t\tr.append(chr(ord(s1[i])+1))\n\telif(ord(s1[i])<ord(s2[i])):\n\t\tf=-1\n\telse:\n\t\tr.append(s2[i])\nm=\"\".join(r)\n# print(s1,m)\nif(f==-1):\n\tprint(-1)\nelse:\n\tprint(m)"}, {"source_code": "s1=input()\ns2=input()\nr=[]\nfor i in range(len(s1)):\n\tif(s1[i]==s2[i]):\n\t\tr.append('x')\n\telse:\n\t\tr.append(s2[i])\nm=\"\".join(r)\nif(m==s2):\n\tprint(-1)\nelse:\n\tprint(m)"}, {"source_code": "def reverse(x, y):\n i = 0\n fail = 0\n z = []\n while i < len(x):\n if x[i] == y[i]:\n z.append(x[i])\n elif x[i] < y[i] and x[i] == 'a':\n print('-1')\n break\n else:\n z.append('z')\n i += 1\n if len(x) == len(z):\n print(''.join(z))"}, {"source_code": "def f(x, z):\n if any(cx < cz for (cx, cz) in zip(x, z)):\n return -1\n return z"}, {"source_code": "\nx=input()\ny=input()\nz=''\nfor i in range(len(x)):\n if x[i]==y[i]:\n if x[i]=='a':\n z+='b'\n elif x[i]=='b':\n z+='c'\n elif x[i]=='c':\n z+='d'\n elif x[i]=='d':\n z+='e'\n elif x[i]=='e':\n z+='f'\n elif x[i]=='f':\n z+='g'\n elif x[i]=='g':\n z+='h'\n elif x[i]=='h':\n z+='i'\n elif x[i]=='i':\n z+='j'\n elif x[i]=='j':\n z+='k'\n elif x[i]=='k':\n z+='l'\n elif x[i]=='l':\n z+='m'\n elif x[i]=='m':\n z+='n'\n elif x[i]=='n':\n z+='o'\n elif x[i]=='o':\n z+='p'\n elif x[i]=='p':\n z+='q'\n elif x[i]=='q':\n z+='r'\n elif x[i]=='r':\n z+='s'\n elif x[i]=='s':\n z+='t'\n elif x[i]=='t':\n z+='u'\n elif x[i]=='u':\n z+='v'\n elif x[i]=='v':\n z+='w'\n elif x[i]=='w':\n z+='x'\n elif x[i]=='x':\n z+='y'\n elif x[i]=='y':\n z+='z'\n elif x[i]=='z':\n z+='a'\n \n else:\n z+=y[i]\nf=0\nfor i in range(len(z)):\n if (x[i]<y[i] and x[i]!=z[i]) or (x[i]>y[i] and y[i]!=z[i]):\n print(-1)\n f=1 \n break\nif f==0:\n print(z)\n \n "}, {"source_code": "def invF():\n\tx=input()\n\ty=input()\n\n\tif(len(x)!=len(y)):\n\t\tprint(-1)\n\t\treturn\n\n\tst=\"\"\n\tfor i in range(len(x)):\n\t\tif(y[i]>x[i]):\n\t\t\tprint(-1)\n\t\t\treturn\n\t\telif(y[i]==x[i]):\n\t\t\tst = st + chr( ord( y[i] ) + 1 ) \n\t\telse:\n\t\t\tst = st + y[i]\n\n\tprint(st)\n\ninvF()\t\t"}, {"source_code": "x = list(input())\ny = list(input())\n\nz = []\nfor i in range(len(x)):\n if x[i] < y[i]:\n break\n z.append(y[i])\n\nif len(z) == len(y):\n print(str(z))\nelse:\n print(-1)\n"}, {"source_code": "ans = []\n\nx = raw_input()\nz = raw_input()\n\n\nfor i, j in zip(x, z):\n\n\tif i == j:\n\t\tif not chr(ord(i) + 1).isalpha():\n\t\t\tans = ['-1']\n\t\t\tbreak\n\t\tans.append(chr(ord(i) + 1))\n\n\telif i > j:\n\t\tans.append(j)\n\n\telif j > i:\n\t\tans = [\"-1\"]\n\t\tbreak\n\nprint \"\".join(ans)\n\t\n\n"}, {"source_code": "a= input()\nb= input()\nif a < b:\n print(-1)\nelse:\n print(b)\n"}, {"source_code": "a=input()\nb=input()\nd=1\nk=''\nc='abcdefghijklmnopqrstuvwxyz'\nfor i in range(len(a)):\n\tif c.index(a[i])<c.index(b[i]) or b[i]=='z':\n\t\tprint(-1)\n\t\td=d-1\n\t\tbreak\n\telif a[i]==b[i]:\n\t\tk=k+c[c.index(a[i])+1]\n\telse:\n\t\tk=k+b[i]\nif d==1:\n\tprint(k)\n"}, {"source_code": "def f(x, z):\n if any(cx < cz for (cx, cz) in zip(x, z)):\n return -1\n return z"}, {"source_code": "# x, z = \"ab\", \"aa\" #input()\n# if any(cx < cz for (cx, cz) in zip(x, z)):\n# print(-1)\n# else:\n# print(z)\nprint(input())"}, {"source_code": "from sys import exit\n\nx = input(\"x: \")\ny = input(\"y: \")\nres = \"\"\ni = 0\nwhile len(res) < len(x):\n\tif x[i] >= y[i]:\n\t\tres = res + y[i]\n\telse:\n\t\tprint(str(-1))\n\t\texit(0)\n\ti = i + 1\nprint(res)"}, {"source_code": "x = str(input())\n\ny = str(input())\n\na = ''\n\nfor i in range(len(x)):\n\n\tif x[i]==y[i]:\n\t\ta+=chr(ord(x[i])+1)\n\n\telif x[i]>y[i]:\n\t\ta+=y[i]\n\n\telse:\n\t\ta = '-1'\n\t\tbreak\n\n\nif(a[-1]!='-1'):\n\tprint(a)\n\nelse:\n\tprint('-1')\n"}, {"source_code": "x = input()\nz = input()\nletters = 'abcdefghijklmnopqrstuvwxyz'\ny = ''\nfor c1, c2 in zip(x, z):\n\tif c1 == c2:\n\t\tif letters.index(c1) + 1 >= len(letters):\n\t\t\tprint(-1)\n\t\t\tbreak\n\t\ty += letters[letters.index(c1) + 1]\n\telse:\n\t\tif c1 < c2:\n\t\t\tprint(-1)\n\t\t\tbreak\n\t\ty += min(c1, c2)\nelse:\n\tprint(y)\n"}, {"source_code": "q1=input()\nans=input()\nq2=''\nfor i in range(len(q1)):\n if q1[i]==ans[i]:\n q2+=chr(ord(q1[i])+1)\n elif ord(q1[i])<ord(ans[i]):\n print('-1')\n break\n else:\n q2+=ans[i]\n\nprint(q2)\n\n"}, {"source_code": "x = list(input())\ny = list(input())\n\nz = []\nfor i in range(len(x)):\n if x[i] < y[i]:\n break\n z.append(y[i])\n\nif len(z) == len(y):\n print(str(z))\nelse:\n print(-1)\n"}, {"source_code": "x = input(\"x: \")\ny = input(\"y: \")\nres = \"\"\ni = 0\nwhile len(res) < len(x):\n\tif x[i] == y[i]:\n\t\tif x[i] < \"z\":\n\t\t\tres = res + chr(ord(x[i]) + 1)\n\t\telse:\n\t\t\tprint(str(-1))\n\t\t\texit(0)\n\telif x[i] > y[i]:\n\t\tres = res + y[i]\n\telse:\n\t\tres = str(-1)\n\t\tbreak\n\ti = i + 1\nprint(res)"}, {"source_code": "x = input()\ny = input()\nprint(y if x>=y else -1)"}, {"source_code": "x=input()\nz=input()\ny=\"\"\nflag=0\nfor i in range(len(x)):\n\tif ord(x[i])<ord(z[i]):\n\t\tflag=1\n\t\tbreak\nelse:\n\tprint(z)\n\n\n\n"}, {"source_code": "s1=input()\ns2=input()\nst=''\nd=0\nfor i in range(len(s1)):\n if ord(s1[i])>ord(s2[i]):\n st=st+s2[i]\n elif ord(s1[i])==ord(s2[i]):\n if s1[i]==\"z\":\n st=st+\"a\"\n else:\n st=st+chr(ord(s1[i])+1)\n else:\n d=1\n break\nif d==1:\n print(-1)\nelse:\n print(st)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jan 15 14:15:15 2018\n\n@author: Paras Sharma\n\"\"\"\n\na=input()\nc=[]\nb=input()\nd=[]\nfor i in range(len(a)):\n c.append(a[i])\n d.append(b[i])\nfor i in range(len(a)):\n print(min(a[i],b[i]),end=\"\")\n"}, {"source_code": "str1=str(raw_input())\nstr2=str(raw_input())\n\nstr3=[]\nfoo1=False\nfoo2=False\nfor i in range(len(str1)):\n if str1[i]!=str2[i]:\n foo1=True\n str3.append(min(str1[i],str2[i]))\n else :\n foo2=True\n str3.append(chr(ord(str1[i])+1))\n\nif foo1 and foo2 and len(str1)>1:\n print ''.join(str3)\nelif len(str1)>1 :\n print -1\nelif str1>str2 :\n print min(str1,str2)\nelse :\n print -1\n"}, {"source_code": "import random\nimport math\nimport sys\na = input()\nb = input()\n\nc = '0'\nfor i in range(0,len(a)):\n if a[i] == b[i] and a[i] == 'z':\n print (\"-1\")\n sys.exit()\n elif a[i] == b[i]:\n c += (chr(ord(a[i]) + 1))\n elif a[i] > b[i]:\n c += b[i]\n\nif (len(a) == len(c) - 1):\n print (c[1:])\nelse:\n print (\"-1\")\n \n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jan 15 14:15:15 2018\n\n@author: Paras Sharma\n\"\"\"\n\na=input()\nc=[]\nb=input()\nd=[]\nfinal=\"\"\nfor i in range(len(a)):\n c.append(a[i])\n d.append(b[i])\nfor i in range(len(a)):\n if b[i]>a[i]:\n print(-1)\n break\n final+=min(a[i],b[i])\nprint(final)\n"}, {"source_code": "x = input()\ny = input()\nprint(y if x>=y else -1)"}, {"source_code": "x=input()\ny=input()\nz=''\nfor i in range(len(x)):\n if(x[i]==y[i]):\n z+='z'\n elif(x[i]!=y[i]):\n z+=y[i]\nif(z==y and len(z)!=1):\n print(\"-1\")\nelse:\n print(z)\n"}, {"source_code": "def main():\n x = raw_input()\n y = raw_input()\n for i in xrange(len(x)):\n if ord(y[i]) > ord(x[i]):\n print -1\n return\n print x\n\nmain()\n"}, {"source_code": "x=input()\ny=input()\n\nres=\"\"\nmc=ord('a')\nfor i in range (len(x)):\n temp=ord(x[i])\n temp1=ord(y[i])\n if temp1==temp:\n res+=chr(temp1+1)\n elif temp1>temp:\n print(-1)\n break\n else:\n if temp1!=mc:\n res+=chr(temp1-1)\n else:\n res+='a'\nprint(res)\n"}, {"source_code": "x = input()\ny = input()\nz = ''\nfor i in range(len(x)):\n if x[i] < y[i]:\n print(-1)\n break\n else:\n z+= y[i]\nprint(z)"}, {"source_code": "x=input()\n\n\ny=input()\n\np=''\nfor k in range(len(x)):\n if ord(y[k])==ord(x[k]):\n if 97<=ord(x[k])<122:\n p+=chr(ord(x[k])+1)\n elif ord(x[k])==122:\n p+=chr(ord(x[k]))\n elif ord(y[k])<ord(x[k]):\n p+=chr(ord(y[k]))\n else:\n print(-1)\n break\n \nprint(p)\n"}, {"source_code": "def reverse(x, y):\n i = 0\n fail = 0\n z = []\n while i < len(x):\n if x[i] == y[i]:\n z.append(x[i])\n elif x[i] < y[i] and x[i] == 'a':\n return -1\n break\n else:\n z.append('z')\n i += 1\n if len(x) == len(z):\n return ''.join(z)"}, {"source_code": "a=input()\nb=input()\nd=1\nk=''\nc='abcdefghijklmnopqrstuvwxyz'\nfor i in range(len(a)):\n\tif c.index(a[i])<c.index(b[i]) or b[i]=='z':\n\t\tprint(-1)\n\t\td=d-1\n\t\tbreak\n\telif a[i]==b[i]:\n\t\tk=k+c[c.index(a[i])+1]\n\telse:\n\t\tk=k+b[i]\nif d==1:\n\tprint(k)\n"}, {"source_code": "\n\n\nR = lambda:map(int,input().split())\ns_one = input()\ns_two = input()\n\nif sorted(s_one) != sorted(s_two):\n print(\"\".join(sorted(s_one)))\nelse:\n print(-1)\n\n"}, {"source_code": "ans = []\n\nx = raw_input()\nz = raw_input()\n\n\nfor i, j in zip(x, z):\n\n\tif i == j:\n\t\tif not chr(ord(i) + 1).isalpha():\n\t\t\tans = ['-1']\n\t\t\tbreak\n\t\tans.append(chr(ord(i) + 1))\n\n\telif i > j:\n\t\tans.append(j)\n\n\telif j > i:\n\t\tans = [\"-1\"]\n\t\tbreak\n\nprint \"\".join(ans)\n\t\n\n"}, {"source_code": "# http://codeforces.com/problemset/problem/801/B\nx = str(input())\ny = str(input())\nz = \"\"\nimpossible = False\nfor i in range(len(x)):\n\tif y[i] == x[i]:\n\t\tz += \"z\"\n\t\t\n\t\tif y[i] == \"z\":\n\t\t\timpossible = True\n\t\t\tbreak\n\t\t\t\n\telse:\n\t\tif x[i] < y[i]:\n\t\t\timpossible = True\n\t\t\tbreak\n\t\telse:\n\t\t\tz += y[i]\nif impossible:\n\tprint(-1)\nelse:\n\tprint(z)\n# print(z)\n# if \"A\" > \"B\":\n\t# print(\"AB\")\n# else:\n\t# print(\"BA\")"}, {"source_code": "s1 = input()\ns2 = input()\n\nif s1 < s2:\n print(-1)\nelse:\n print(s2)"}, {"source_code": "y1 = raw_input()\ny2 = raw_input()\nsaida = \"\"\ntamanho = len(y1)\nfor i in xrange(tamanho):\n\tasc1 = ord(y1[i])\n\tasc2 = ord(y2[i])\n\tif (asc1 > asc2):\n\t\tsaida += y2[i]\n\t\t\n\telif (asc1 == asc2):\n\t\tsaida += chr(asc1 + 1)\n\t\n\telse:\n\t\tsaida = \"-1\"\n\t\tbreak\n\t\t\nprint saida\n"}, {"source_code": "s1=input()\ns2=input()\nst=''\nc=0\nfor i in range(len(s1)):\n if ord(s1[i])>ord(s2[i]):\n st=st+s2[i]\n elif ord(s1[i])==ord(s2[i]):\n st=st+chr(ord(s1[i])+1)\n else:\n c=1\n break\nif c==1:\n print(-1)\nelse:\n print(st)"}, {"source_code": "inp1 = input()\ninp2 = input()\nres = \"\"\n\nfor c1, c2 in zip(inp1, inp2):\n res += min(c1, c2)\n\nprint(res)"}, {"source_code": "def get_(a,b):\n\tif a > b:\n\t\treturn '>'\n\telif a < b:\n\t\treturn '<'\n\telif a == b:\n\t\treturn '='\n\telse:\n\t\treturn '?'\n\nx = raw_input()[:-1]\ny = raw_input()[:-1]\nz = \"\"\n\nln = 0\nln+= len(x)\nln+= len(y)\nln/= 2\n\nst = True\n\nfor i in range(ln):\n\txi = x[i]\n\tyi = y[i]\n\tox = ord(xi)\n\toy = ord(yi)\n\top = get_(ox,oy)\n\t# print xi,yi,ox,oy,op\n\tif op == '<':\n\t\tst = False\n\t\tbreak\n\telif op == '=':\n\t\tz += chr(ox)\n\telif op == '>':\n\t\tz += chr(oy)\n\nif not st:\n\tprint \"-1\"\nelse:\n\tprint z"}, {"source_code": "import sys\nx,y = [i.strip() for i in sys.stdin.readlines()]\nz = ''\nfor i in range(len(x)):\n if ord(x[i])>ord(y[i]):\n z = z+y[i]\n elif ord(x[i])==ord(y[i]) and ord(x[i])!=122:\n z = z+chr(ord(x[i])+1)\n else:\n z = -1\n break\nprint (z)"}, {"source_code": "#from __future__ import division\nimport itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left , bisect_right\nimport heapq\nfrom collections import deque , defaultdict , Counter\nfrom itertools import combinations as C\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\n\nn = Ls()\nmx = 0\nfor i in xrange(1,len(n)):\n\tif n[i-1]+n[i] == 'VK':\n\t\tmx += 1\nfor i in xrange(len(n)):\n\ta = n[i]\n\t#print n\n\tif n[i] == 'V':\n\t\tn[i] = 'K'\n\telse:\n\t\tn[i] = 'V'\n\tmn = 0\n\tfor ix in xrange(1,len(n)):\n\t\tif n[ix-1]+n[ix] == 'VK':\n\t\t\tmn += 1\n\tmx = max(mx,mn)\n\tn[i] = a\nprint mx\n"}, {"source_code": "a=input()\nb=input()\nd=1\nk=''\nc='abcdefghijklmnopqrstuvwxyz'\nfor i in range(len(a)):\n\tif c.index(a[i])<c.index(b[i]) or b[i]=='z':\n\t\tprint(-1)\n\t\td=d-1\n\t\tbreak\n\telif a[i]==b[i]:\n\t\tk=k+'z'\n\telse:\n\t\tk=k+b[i]\nif d>0:\n\tprint(k)\n"}, {"source_code": "x = str(input())\n\ny = str(input())\n\na = ''\n\nfor i in range(len(x)):\n\n\tif x[i]==y[i]:\n\t\ta+=chr(ord(x[i])+1)\n\n\telif x[i]>y[i]:\n\t\ta+=y[i]\n\n\telse:\n\t\ta = '-1'\n\t\tbreak\n\n\nif(a[-1]!='-1'):\n\tprint(a)\n\nelse:\n\tprint('-1')\n"}, {"source_code": "x = input().strip()\ny = input().strip()\n\n# z = map(lambda x: x[0] if x[0]==x[1] else x[1], [a for a in zip(x, y)])\n\nprint(y)"}, {"source_code": "# https://codeforces.com/problemset/problem/801/B\n# 900\n\n\nx = input()\ny = input()\nz = \"\"\n\nfor i, xy in enumerate(zip(x, y)):\n xc, yc = xy\n xv = ord(xc)\n yv = ord(yc)\n\n if xv < yv:\n z = -1\n break\n \n if (i+1) % 2 != 0:\n z += xc\n else:\n z += yc\n\n \n\nprint(z)"}, {"source_code": "def main():\n x = raw_input()\n y = raw_input()\n for i in xrange(len(x)):\n if ord(y[i]) > ord(x[i]):\n print -1\n return\n print x\n\nmain()\n"}, {"source_code": "x = input()\ny = input()\nn = len(x)\nres = ''\nfor i in range(n):\n if x[i] < y[i]:\n res = '-1'\n break\n elif x[i]==y[i]:\n res += chr(ord(x[i])+1)\n else:\n res +=y[i]\n\nprint(''.join(res))\n\n \n"}, {"source_code": "x=input()\ny=input()\nz=''\nfor i in range(len(x)):\n if(x[i]==y[i]):\n z+='z'\n elif(x[i]!=y[i]):\n z+=y[i]\nif(z==y and len(z)!=1):\n print(\"-1\")\nelse:\n print(z)\n"}, {"source_code": "x=input()\ny=input()\nval=False\n\nfor i in range(0,len(x),2):\n if(x[i]==y[i]):\n val=True\n\nif(val):\n b=\"\"\n\n if(len(x)%2==0):\n i=0\n j=1\n while(i<len(x)):\n b=b+x[i]+y[j]\n i=i+2\n j=j+2\n else:\n b=\"z\"\n for i in range(1,len(y),2):\n b=b+y[i]+\"z\"\n print(b)\nelse:\n if len(x)==1:\n print(\"z\")\n else:\n print(\"-1\")"}, {"source_code": "import sys\n#sys.stdin = open('input2','r')\n\nx = input()\nres = input()\ny = ''\nneg = 0\nl = len(x)\nfor i in range(l):\n if( ord(x[i]) == ord(res[i])):\n if(x[i] == 'z'):\n neg = 1\n break\n else:\n y += chr(ord(x[i])+1)\n elif( ord(x[i]) > ord(res[i])):\n y += res[i]\n else:\n neg = 1\n break\nif(neg == 0):\n print(y)\nelse:\n print('-1')\n"}, {"source_code": "def reverse(x, y):\n i = 0\n fail = 0\n z = []\n while i < len(x):\n if x[i] == y[i]:\n z.append(x[i])\n elif x[i] < y[i] and x[i] == 'a':\n print('-1')\n break\n else:\n z.append('z')\n i += 1\n if len(x) == len(z):\n print(''.join(z))"}, {"source_code": "x,y = input(),input()\nz = \"\"\nalphabets = tuple(\"abcdefghijklmnopqrstuvwxyz\")\nfor i in range(len(x)):\n if x[i]<y[i]:\n print(\"-1\")\n break\n \n if x[i]==y[i]:\n idx = alphabets.index(x[i])\n if idx+1 == len(alphabets):\n print(\"-1\")\n break\n else:\n z += alphabets[idx+1]\n else:\n z += y[i]\nelse:\n print(z)"}, {"source_code": "arg =input()\nres =input()\nif arg < res:\n print (\"-1\")\n quit()\nb =\"\"\nfor i in range(len(arg)):\n if arg[i] == res[i]:b+=str(chr(ord(arg[i])+1))\n elif arg[i] > res[i]:b+=str(res[i])\nprint (b)"}, {"source_code": "s1=input()\ns2=input()\nst=''\nc=0\nfor i in range(len(s1)):\n if ord(s1[i])>ord(s2[i]):\n st=st+s2[i]\n elif ord(s1[i])==ord(s2[i]):\n st=st+chr(ord(s1[i])+1)\n else:\n c=1\n break\nif c==1:\n print(-1)\nelse:\n print(st)"}, {"source_code": "x, z = input()\nif any(cx < cz for (cx, cz) in zip(x, z)):\n print(-1)\nelse:\n print(z)\n"}, {"source_code": "x=raw_input() #x #nzwzl #z #xiyez #y #niwel\nz=\"\"\ny=raw_input()\nh=0\nfor i in range(len(x)):\n if(x[i]<y[i]):\n h=1\n break\n if(x[i]==y[i]):\n z=z+chr(ord(x[i]) + 1)\n else:\n z=z+y[i]\nif(len(z)==len(x)):\n print z\nelif(h==1):\n print \"-1\"\n \n\n"}, {"source_code": "x = input()\ny = input()\ns = \"\"\nfor i in range(len(x)):\n if x[i] == y[i]:\n s += chr(ord(x[i])+1)\n else:\n s += y[i]\nif s == y or s == x:\n print(-1)\n quit()\nprint(s)\n"}, {"source_code": "ans = []\n\nx = raw_input()\nz = raw_input()\n\n\nfor i, j in zip(x, z):\n\n\tif i == j:\n\t\tif not chr(ord(i) + 1).isalpha():\n\t\t\tans = ['-1']\n\t\t\tbreak\n\t\tans.append(chr(ord(i) + 1))\n\n\telif i > j:\n\t\tans.append(j)\n\n\telif j > i:\n\t\tans = [\"-1\"]\n\t\tbreak\n\nprint \"\".join(ans)\n\t\n\n"}, {"source_code": "x, z = input()\nif any(cx < cz for (cx, cz) in zip(x, z)):\n print(-1)\nelse:\n print(z)\n"}, {"source_code": "def get_(a,b):\n\tif a > b:\n\t\treturn '>'\n\telif a < b:\n\t\treturn '<'\n\telif a == b:\n\t\treturn '='\n\telse:\n\t\treturn '?'\n\nx = raw_input()[:-1]\ny = raw_input()[:-1]\nz = \"\"\n\nln = 0\nln+= len(x)\nln+= len(y)\nln/= 2\n\nst = True\n\nfor i in range(ln):\n\txi = x[i]\n\tyi = y[i]\n\tox = ord(xi)\n\toy = ord(yi)\n\top = get_(ox,oy)\n\tprint xi,yi,ox,oy,op\n\tif op == '<':\n\t\tst = False\n\t\tbreak\n\telif op == '=':\n\t\tz += chr(ox)\n\telif op == '>':\n\t\tz += chr(oy)\n\nif not st:\n\tprint \"-1\"\nelse:\n\tprint z"}, {"source_code": "s1 = input()\ns2 = input()\nprint(-1 if s2 > s1 else s2)"}, {"source_code": "def f(x, z):\n if any(cx < cz for (cx, cz) in zip(x, z)):\n return -1\n return z"}, {"source_code": "def f(x, z):\n if any(cx < cz for (cx, cz) in zip(x, z)):\n return -1\n return z"}, {"source_code": "s1=input()\ns2=input()\nst=''\nc=0\nfor i in range(len(s1)):\n if ord(s1[i])>ord(s2[i]):\n st=st+s2[i]\n elif ord(s1[i])==ord(s2[i]):\n st=st+chr(ord(s1[i])+1)\n else:\n c=1\n break\nif c==1:\n print(-1)\nelse:\n print(st)"}, {"source_code": "s1=input()\ns2=input()\ns3=''\nfor i in range(len(s1)):\n if s1[i]==s2[i]:\n s3+=chr((ord(s1[i])+1))\n elif s1[i]>s2[i]:\n s3+=s2[i]\n else:\n pass\n \nif(len(s3)==len(s1)):\n print(s3)\nelse:\n print(-1)\n"}, {"source_code": "from itertools import product\nx = input()\ny = input()\nprint( -1 if any( min( ord( a ), ord( b ) ) != ord( b ) for a, b in product( x, y ) ) else y )\n"}, {"source_code": "from itertools import product\nx = input()\ny = input()\nprint( -1 if any( min( ord( a ), ord( b ) ) != ord( b ) for a, b in product( x, y ) ) else y )\n"}, {"source_code": "import random\nx = input()\ny = input()\nz = []\n\nfor i in range(len(x)):\n if x[i] == y[i]:\n z.append(chr(random.randint(ord(x[i]) , 122)))\n elif x[i] > y[i]:\n z.append(chr(random.randint(97, ord(x[i]))))\n else:\n pass\n\nif len(z) == len(x):\n print(\"\".join(z))\nelse:\n print(-1)"}, {"source_code": "x = str(input())\n\ny = str(input())\n\na = ''\n\nfor i in range(len(x)):\n\n\tif x[i]==y[i]:\n\t\ta+=chr(ord(x[i])+1)\n\n\telif x[i]>y[i]:\n\t\ta+=y[i]\n\n\telse:\n\t\ta = '-1'\n\t\tbreak\n\n\nif(a[-1]!='-1'):\n\tprint(a)\n\nelse:\n\tprint('-1')\n"}, {"source_code": "let=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nx=input()\ny=input()\nz=''\nfor i in range(len(x)):\n if let.index(x[i])==let.index(y[i]):\n if let.index(x[i])<25:\n z+=let[let.index(x[i])+1]\n elif let.index(x[i])>let.index(y[i]):\n z+=y[i]\n else:\n print('-1')\n break\nprint(z)"}, {"source_code": "s1=input()\ns2=input()\nfor i in range(len(s1)):\n\tif ord(s1[i])<ord(s2[i]):\n\t\tprint(-1)\n\t\tbreak\n\telse:\n\t\tprint(s2[i],end=\"\")"}, {"source_code": "def get_(a,b):\n\tif a > b:\n\t\treturn '>'\n\telif a < b:\n\t\treturn '<'\n\telif a == b:\n\t\treturn '='\n\telse:\n\t\treturn '?'\n\nx = raw_input()[:-1]\ny = raw_input()[:-1]\nz = \"\"\n\nln = 0\nln+= len(x)\nln+= len(y)\nln/= 2\n\nst = True\n\nfor i in range(ln):\n\txi = x[i]\n\tyi = y[i]\n\tox = ord(xi)\n\toy = ord(yi)\n\top = get_(ox,oy)\n\tprint xi,yi,ox,oy,op\n\tif op == '<':\n\t\tst = False\n\t\tbreak\n\telif op == '=':\n\t\tz += chr(ox)\n\telif op == '>':\n\t\tz += chr(oy)\n\nif not st:\n\tprint \"-1\"\nelse:\n\tprint z"}, {"source_code": "a=raw_input()\nb=raw_input()\nq='abcdefghijklmnopqrstuvwxyz'\nc=''\nfor i in range(len(a)) :\n if a[i]<=b[i]:\n c+=q[q.find(a[i])+1]\n else:\n c+=b[i]\n\nif c!=b or c!=a:\n print c\nelse:\n print -1"}, {"source_code": "s1=raw_input()\ns2=raw_input()\nif len(s1)==1 and s2<=s1:\n print s2\nelse:\n x=0\n for c in range(len(s1)):\n if s2[c]>s1[c]:\n print -1\n x=1\n break\n if x==0 and s2[0]!='z':\n print chr(ord(s2[0])+1)+s2[1:]\n elif x==0 and s2[0]=='z':\n print s2\n"}, {"source_code": "s1=input()\ns2=input()\nr=[]\nfor i in range(len(s1)):\n\tif(s1[i]==s2[i]):\n\t\tr.append('x')\n\telse:\n\t\tr.append(s2[i])\nm=\"\".join(r)\nif(m==s2):\n\tprint(-1)\nelse:\n\tprint(m)"}, {"source_code": "dict1 = {i-96:chr(i) for i in range(97,123)}\n\nclass solution:\n\n def __init__(self):\n self.temp1 = []\n self.temp2 = []\n self.res1 = []\n self.size = 0\n self.res = 0\n\n def get_input(self):\n str1 = input()\n str2 = input()\n self.temp1 = list(str1)\n self.temp2 = list(str2)\n \n def compute(self):\n for i in range(len(self.temp1)):\n if self.temp1[i] == self.temp2[i]:\n temp = ord(self.temp1[i])\n self.res1.append(chr(temp+1))\n \n elif self.temp1[i] >= self.temp2[i]:\n self.res1.append(self.temp2[i])\n else:\n self.res = -1\n \n def result(self):\n if self.res == -1:\n print(-1)\n \n else:\n resultstr = ''.join(map(str,self.res1))\n print(resultstr)\n \n def execute(self):\n self.get_input()\n self.compute()\n self.result()\n \n \ndef main():\n s1 = solution()\n s1.execute()\n \nif __name__ == '__main__':\n main()\n \n \n \n\n \n \n \n\n\n \n"}, {"source_code": "x=input()\nz=input()\ny=\"\"\nflag=0\nfor i in range(len(x)):\n\tif ord(x[i])<ord(z[i]):\n\t\tflag=1\n\t\tbreak\n\telif x[i]==z[i]:\n\t\ty+=chr(ord(x[i])+1)\n\telse:\n\t\ty+=z[i]\nif flag:\n\tprint(-1)\nelse:\n\tprint(y)\n\n\n\n"}, {"source_code": "x=str(input())\ny=str(input())\n\nans=''\nf=0\nfor i in range(len(x)):\n if x[i]==y[i] and x[i]!='z':\n ans+=chr(ord(x[i])+1)\n elif y[i]<x[i]:\n ans+=y[i]\n else:\n f=1\n break\n # ans+='1'\n # ans+=min(x[i],y[i])\nif f==1:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "x=raw_input()\ny=raw_input()\nz=\"\"\nflag=0\nfor i in xrange(len(y)):\n if x[i]==y[i]:\n z+=chr(ord(x[i])+1)\n else:\n z+=y[i]\n if y[i]>x[i]:\n flag=1\nif flag==1:\n print -1\nelse:\n print z\n"}, {"source_code": "x = input().split()\ny = input().split()\n\nstop = False\n\nfor i,j in zip(x,y):\n if i < j:\n print(-1)\n stop = True\n \nif stop == False:\n print(y[0])\n\n'''\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\n\nans = \"\"\n\nstop = False\n\n\nfor i,j in zip(x,y):\n if i == j:\n ans += i\n elif i > j:\n ans += j\n else:\n print(-1)\n stop = True\n break\n\nif stop == False:\n print(ans)\n'''"}, {"source_code": "def p(x,z):\n if (x=='ab')and(z=='aa'):\n return ('ca')\n else:\n y=''\n for i in range (len(z)):\n if z[i]<=x[i]:\n y=y+z[i]\n else :\n return (-1)\n return (y)"}, {"source_code": "x = input()\ny = input()\nn = len(x)\nres = ''\nfor i in range(n):\n if x[i] < y[i]:\n res = '-1'\n break\n elif x[i]==y[i]:\n res += chr(ord(x[i])+1)\n else:\n res +=y[i]\n\nprint(''.join(res))\n\n \n"}, {"source_code": "x = input().strip()\ny = input().strip()\n\ndef main():\n for i in range(len(x)):\n if x[i] == y[i]:\n print(x[i],end=\"\")\n elif x[i] < y[i]:\n print(-1)\n return\n else:\n print(y[i], end=\"\")\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "def main():\n x = raw_input()\n y = raw_input()\n for i in xrange(len(x)):\n if ord(y[i]) > ord(x[i]):\n print -1\n return\n print x\n\nmain()\n"}, {"source_code": "x=raw_input() #x #nzwzl #z #xiyez #y #niwel\nz=\"\"\ny=raw_input()\nh=0\nfor i in range(len(x)):\n if(x[i]<y[i]):\n h=1\n break\n elif(x[i]>y[i]):\n z=z+y[i]\nif(len(z)==len(x)):\n print z\nelif(h==1):\n print \"-1\"\n \n\n"}, {"source_code": "x = raw_input()\ny = raw_input()\n\nres = []\n\nfor i in range(len(y)):\n\tif y[i] == x[i]:\n\t\tres.append(chr(ord(x[i]) + 1))\n\telif y[i] < x[i]:\n\t\tres.append(y[i])\n\telse:\n\t\tbreak\nans = -1 if len(res) != len(x) else ''.join(res)\nprint(ans)"}, {"source_code": "str1=input()\nstr2=input()\nli1=list(str1)\nli2=list(str2)\nflag=True\nfor i in range(0,len(li1)):\n if li2[i]>li1[i]:\n flag=False\n break\nprint(str2)\n\n"}], "src_uid": "ce0cb995e18501f73e34c76713aec182"} {"source_code": "a, b = map(int, input().split())\nprint([\"NO\", \"YES\"][abs(a-b)<2 and a+b>0])", "positive_code": [{"source_code": "a,b=(map(int,str(raw_input()).split(' ')))\nif a==0 and b==0:\n print \"NO\"\nelse:\n if a==b or a==b+1 or b==a+1:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "a, b = map(int, input().split())\nif a==b and a!=0:\n print(\"YES\")\nelif a+1==b:\n print(\"YES\")\nelif b+1==a:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "usrInp = raw_input()\n\nusrInp = usrInp.split(\" \")\n\na = int(usrInp[0])\nb = int(usrInp[1])\n\nif (a + b) < 1:\n print \"NO\"\nelif abs(a-b) <= 1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "a,b=map(int,raw_input().strip().split())\n\nif a==b and a==0:\n\tprint \"NO\"\nelse:\n\tif abs(a-b) <=1:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "n,k = map(int, raw_input().strip().split(\" \"))\n\nif n+k == 0:\n print \"NO\"\n exit()\nif abs(n-k)>1:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "n,m = map(int, input().split())\nif m==0 and n==0:\n print(\"NO\")\nelif abs(n-m) <= 1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nif abs(a-b)>1 :\n print(\"NO\")\nelif a==0 and b==0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n,m = list(map(int,input().split()))\nif abs(n-m)<2 and n+m>0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "\ns=input()\nnums=s.split(\" \")\na=int(nums[0])\nb=int(nums[1])\n\nif (a==b or b==a+1 or a==b+1) and not(b==0 and a==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,raw_input().split())\nif a-b in (-1,0,1) and a+b!=0:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "# h,w = map(int, input().split(' '))\n# r = list(map(int, input().split(' ')))\n# c = list(map(int, input().split(' ')))\n# l,r = map(int, input().split(' '))\n# for i in range(l, r+1):\n# if len(str(i)) == len(list(set(str(i)))):\n# print(i)\n# exit()\n# print(-1)\na,b = map(int, input().split(' '))\nif a == 0 and b == 0:\n print('NO')\n exit() \nif abs(a-b) <= 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a,b=map(int,input().split());print(\"YES\" if abs(a-b)<2 and a+b>0 else \"NO\")"}, {"source_code": "class CodeforcesTask761ASolution:\n def __init__(self):\n self.result = ''\n self.a_b = []\n\n def read_input(self):\n self.a_b = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n self.result = \"YES\" if abs(self.a_b[0] - self.a_b[1]) <= 1 and sum(self.a_b) else \"NO\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask761ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "a,b = map(int,input().split())\nif a - b == 1 or b-a == 1 or a == b and a !=0 and b!=0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "import math\n\ndef main():\n a,b = map(int, input().split())\n return \"YES\" if a+b!=0 and (a==b or abs(b-a)==1) else \"NO\"\nprint(main())\n"}, {"source_code": "\na, b = input().split(' ')\na, b = int(a), int(b)\n\nif abs(a - b) < 2 and not(a == 0 and b == 0):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a, b = [int(x) for x in input().split()]\nn = a + b\ndiff = a - b\nif a == 0 and b == 0:\n print(\"NO\")\nelif diff >= -2 and diff <= 2:\n if (n % 2 == 0 and ((a % 2 == 0 and b % 2 == 0) or (a % 2 != 0 and b % 2 !=0)) and (diff <= 1 and diff >= -1)) or (n % 2 !=0 and (a % 2 !=0 or b % 2 != 0)):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\nprint('YES' if a + b > 0 and abs(a - b) <= 1 else 'NO')"}, {"source_code": "a, b = map(int, input().split())\nprint([\"NO\", \"YES\"][abs(a-b)<2 and a+b>0])"}, {"source_code": "X = list(map(int, input().split()))\nprint(\"YES\" if X.count(0) != 2 and X[1] - X[0] in [0, 1, -1] else \"NO\")\n\n# UB_CodeForces\n# Advice: It feels good to be lost in the right direction\n# Location: Same place\n# Caption: After a little break\n# CodeNumber: 523\n"}, {"source_code": "a, b = map(int, input().split())\n\nif a == b == 0:\n\tprint('NO')\nelif abs(a - b) > 1:\n\tprint('NO')\nelse:\n\tprint('YES')"}, {"source_code": "a, b = map(int, input().split())\nif abs(a-b) <= 1 and (a != 0 or b != 0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b = map(int, input().split())\n\ndef prb():\n intlen = a + b\n if(intlen == 0):\n print(\"NO\")\n return\n if(a == b or a == b + 1 or a+1 == b):\n print(\"YES\")\n return\n print(\"NO\");\n return\n \n\nprb()"}, {"source_code": "a,b = map(int, input().split())\nprint(\"YES\" if ((a+b>0) and abs(a-b)<=1) else \"NO\")"}, {"source_code": "a,b = map(int, input().split())\nprint(\"YES\" if a+b>0 and abs(a-b)<=1 else \"NO\")"}, {"source_code": "def ans(a, b):\n if a is 0 and b is 0:\n return \"NO\"\n if abs(a - b) > 1:\n return \"NO\"\n else:\n return \"YES\"\n\na, b = list(map(int, input().strip().split(' ')))\nprint(ans(a, b))\n"}, {"source_code": "n,m = map(int,input().split())\n\nif (n+m)> 0 and abs(n-m)<= 1 :\n\tprint(\"YES\")\nelse :\n\tprint(\"NO\")"}, {"source_code": "x,y=input().split()\nx,y=int(x),int(y)\nif x==0 and y==0 or abs(x-y)>=2:\n print('NO')\nelif abs(x-y)<2:\n print('YES')\n"}, {"source_code": "\nimport sys\nInput = sys.stdin.readline\na, b = map(int, Input().split())\nif a + b > 0 and abs(a-b) <= 1:\n exit(print('YES'))\nprint('NO')"}, {"source_code": "a,b = map(int,input().split())\nif(abs(a-b)>=2 or (a==0 and b==0)):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n, x = list(map(int, input().rstrip().split(\" \")))\nif abs(x-n)>1 or x==n == 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "a=(list(map(int, input().split())))\nif (a[0]==0 and a[1]==0):\n print('NO')\nelif abs(a[0]-a[1])<=1 and abs(a[0]-a[1])>=0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a,b = [int(x) for x in input().split()] \nif abs(b-a) <= 1 and a+b != 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a = [int(i) for i in input().split()]\np = int(a[0])\nn = int(a[1])\n\nif p==n+1 or p==n or n==p+1:\n if p==0 and n==0:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\na, b = map(int, input().split())\nif a == 0 and b == 0:\n print(\"NO\")\n sys.exit()\nelif a + 1 == b or b + 1 == a or a == b:\n print(\"YES\")\n\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,input().split())\nprint('YES' if (a-b in [1,-1,0]) and ((a!=0) or (b!=0) ) else 'NO')"}, {"source_code": "a,b=map(int,input().split())\nif (a*b>=0) and ((abs(b-a)==1) or (abs(b-a)==0)) and ((b>=1) or (a>=1)):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "A = list(map(int, input().split()))\n\nif A[0] == 0 and A[1] == 0:\n print('NO')\nelif (A[0] - 1) == A[1] or (A[0] + 1) == A[1] or A[0] == A[1]:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import math\nn,k=map(int,input().split())\nif abs(n-k)<=1 and (n>0 or k>0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,input().strip().split()[:2])\nif a==b and b==0:\n\tprint('NO')\nelse:\n\tif a==b or a==b+1 or a+1==b :\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')"}, {"source_code": "n, m = map(int, input().split())\nif n == 0 and m == 0:\n print(\"NO\")\nelse:\n if n == m:\n print(\"YES\")\n elif abs(n - m) == 1:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split());print(\"YES\" if abs(a-b)<2 and a+b!=0 else \"NO\")"}, {"source_code": "p, n = input().split()\np = int(p)\nn = int(n)\nif p==0 and n==0:\n print(\"NO\")\nelif p==n or n-p==1 or p-n==1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b=list(map(int,input().split()))\nc=-1 if a==0 and b==0 else abs(a-b)\nif(c==0 or c==1) :\n print(\"YES\")\nelse :\n print(\"NO\")\n\n"}, {"source_code": "a,b = list(map(int,input().split()))\nc = a + b\nif a + b == 0:\n print('No')\nelif a == b:\n print('Yes')\nelif c % 2 == 1:\n if c // 2 == b - 1 or c // 2 == a - 1:\n print('Yes')\n else:\n print('No')\nelse:\n print('No')"}, {"source_code": "\na, b = map(int, raw_input().split())\n\nprint 'YES' if abs(a - b) <= 1 and a + b > 0 else 'NO'\n"}, {"source_code": "# -*- coding:utf-8 -*-\n#[n, m] = [int(x) for x in raw_input().split()]\n\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n a,b = [int(x) for x in raw_input().split()]\n if abs(b-a)<2 and a+b>0:\n print \"YES\"\n else:\n print \"NO\"\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n"}, {"source_code": "a, b = map(int, raw_input().split())\nif (a == 0 and b == 0) or abs(a - b) > 1:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "import bisect\nfrom collections import defaultdict\nfrom collections import deque\nimport math\nimport re\n\ndef ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\ndef si():\n return raw_input()\n\ndef sis():\n return raw_input().split()\n\ndef arr_str(a):\n return ' '.join(map(str, a))\n\na, b = nis()\n\nif not a and not b:\n print 'NO'\nelse:\n print 'YES' if abs(a - b) < 2 else 'NO'"}, {"source_code": "import time\ndef f():\n st = time.clock()\n a, b = map(int,raw_input().split())\n print \"No\" if a == b == 0 or abs(a-b) > 1 else \"Yes\"\nf()\n"}, {"source_code": "a, b = map(int, raw_input().split())\nif a + b == 0:\n\tprint 'NO'\nelif a == b or a + 1 == b or b + 1 == a:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "n, k = map(int, raw_input().split())\nprint ['NO','YES'][n-k<2 and k-n<2 and (n>0 or k>0)]"}, {"source_code": "a,b = map(int, raw_input().split())\n\nif a==0 and b ==0:\n print 'NO'\n exit()\nif abs(a - b) <= 1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "a, b = map(int, raw_input().split())\nprint 'YES' if a + b > 0 and abs(a - b) <= 1 else 'NO'"}, {"source_code": "a,b = map(int, raw_input().split())\nif a==0 and b==0:\n print (\"NO\")\nelif abs(a-b) <= 1:\n print (\"YES\")\nelse:\n print (\"NO\")\n"}, {"source_code": "l,r=map(int,input().split(\" \"))\na=0\nb=0\nc=0\nd=0\nif(l+r>0):\n for i in range(1,l+r+1):\n if(i%2==0):\n a=a+1\n if(i%2==1):\n b=b+1\n\n for i in range(2,l+r+2):\n if(i%2==0):\n c=c+1\n if(i%2==1):\n d=d+1\n\n\n if(a==l and b==r or(c==l and d==r)):\n print(\"YES\")\n else:\n print(\"NO\") \nelse:\n print(\"NO\") "}, {"source_code": "a, b = map(int, input().split())\nprint('YES' if abs(a - b) < 2 and (a, b) != (0, 0) else 'NO')"}, {"source_code": "a, b = map(int, raw_input().split())\nprint 'YES' if abs(a-b) <= 1 and (a > 0 or b > 0) else 'NO'\n\n"}, {"source_code": "a,b=map(int,raw_input().split())\nif a==0 and b==0:\n print \"NO\"\nelif abs(a-b)<=1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "a,b = map(int,raw_input().split())\nprint 'YES' if a in [b-1,b+1] or (a==b and a>0) else 'NO'\n"}, {"source_code": "def HasStep(a,b):\n if a == 0 and b == 0:\n print(\"NO\")\n elif b - a == 1 or b - a == 0 or b - a == -1 :\n print(\"YES\")\n else:\n print(\"NO\")\n\na,b = [int(x) for x in input().split() ]\n\nHasStep(a,b)"}, {"source_code": "even,odd=map(int,raw_input().split())\nif(((odd==even and odd!=0) or odd==even-1 or even==odd-1)): print 'YES'\nelse: print 'NO'"}, {"source_code": "def ii():\n\treturn map(int,raw_input().split())\n\na,b = ii()\nif abs(a-b) <= 1 and (a+b):\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "a,b = map(int,raw_input().split())\nif a == 0 and b == 0:\n print \"NO\"\nelse:\n print \"YES\" if abs(a-b) < 2 else \"NO\""}, {"source_code": "a, b = map(int, raw_input().split())\n\nprint 'YES' if abs(a - b) < 2 and a + b > 0 else 'NO'"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Mar 25 00:03:19 2017\n\n@author: anuj\n\"\"\"\n\na, b = map(int, raw_input().split())\n\nif a == 0 and b == 0:\n print 'NO'\nelse:\n if abs(a-b) == 1 or abs(a-b) == 0:\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "a,b = map(int,input().split())\nif a==0 and b==0:\n print(\"NO\")\n exit()\nif abs(a-b)<=1:\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "a, b = map(int, raw_input().split())\nif abs(a-b) > 1 or (a == 0 and b == 0):\n print \"NO\"\nelse :\n print \"YES\""}, {"source_code": "a,b =map(int,raw_input().split())\nif a==0 and b==0:\n print \"NO\" \nelif abs(a-b)<=1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "a,b=map(int,input().split())\nmaxx=a+1\nminn=a-1\nif a==0 and b==0:\n\tprint (\"NO\")\nelif b>=minn and b<=maxx:\n\tprint (\"YES\")\nelse:\n\tprint (\"NO\")\n"}, {"source_code": "import itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left\nimport heapq\nfrom collections import deque\nfrom itertools import combinations as C\n\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\n#Aj to aram se bina paper ke ^_^\nfrom collections import defaultdict \n#late 25 min , lets see kitni girti he aaj\nn , L = get(int)\nif n == L and L == 0:\n\tprint 'NO'\n\texit(0)\nif abs(n - L) <= 1:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "from collections import defaultdict\ndef go():\n\tl,r = [int(i) for i in raw_input().split(\" \")]\n\tif abs(l-r)>1 or (l==0 and r==0):\n\t\tprint \"NO\"\n\telse:\n\t\tprint \"YES\"\ngo()\n"}, {"source_code": "i1=raw_input()\ni2=i1.split()\ni2List=[int(a0)for a0 in i2]\nnumb1=i2List[0]\nnumb2=i2List[1]\nif (numb1<=0 and numb2<=0):\n\tprint 'NO'\nelse:\n if abs(numb1-numb2)>=0 and abs(numb1-numb2)<=1 :\n \tprint 'YES'\n else:\n \tprint 'NO'\n\t\n\n\t\n"}, {"source_code": "a,b=map(int,input().split())\nif abs(a-b)<=1 and a+b!=0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b = map(int, raw_input().split())\nif max(a, b) > 0 and abs(b-a) < 2: print 'YES'\nelse: print 'NO'\n"}, {"source_code": "arg = map(lambda x: int(x), raw_input().split())\n\na = arg[0]\nb = arg[1]\n\nif (a == 0 and b == 0) or abs(a - b) > 1:\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "import sys\nimport math\n\nm,d = map(int,sys.stdin.readline().split())\n\nif m==0 and d==0 :\n\tm=100\nif m==d or m==d+1 or d==m+1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "a, b = map(int, raw_input().split())\nprint ['NO', 'YES'][(a or b) and abs(a-b) < 2]"}, {"source_code": "import sys\n\nx,y = map(int,raw_input().split())\nif x==0 and y==0:\n\tprint \"NO\"\n\tsys.exit(0)\nif abs(x-y)<=1:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "x,y = map(int,raw_input().split())\nprint(\"YES\\n\") if (x or y) and abs(x-y)<2 else \"NO\\n\"\n"}, {"source_code": "l = map(int, raw_input().split())\nif l[0] == 0 and l[1] == 0:\n print \"No\"\nelif abs(l[0]-l[1])>1:\n print\"NO\"\nelse:\n print\"YES\""}, {"source_code": "n, m = map(int, input().split())\nif abs(n - m) < 2 and (n != 0 or m != 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,input().split())\nif a<=0 and b<=0:\n print(\"NO\")\nelse:\n if a==b-1 or b==a-1 or a==b:\n print(\"YES\")\n else:\n print(\"NO\")\n \n"}, {"source_code": "x = map(int, raw_input().split())\n\nif(x == [0, 0]):\n\tprint \"NO\"\nelif(abs(x[1] - x[0]) not in [0, 1]):\n\tprint \"NO\"\nelse:\n\tprint \"YES\""}, {"source_code": "a,b = map(int,input().split())\nif a==0 and b==0:\n print(\"NO\")\nelif abs(a-b)<=1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,input().split())\nif 0<=abs(a-b)<=1 and (a!=0 or b!=0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "from sys import stdin, stdout\nimport math\n\nn,m = map(int, stdin.readline().split())\nif abs(n-m)>1 or n==0 and m ==0:\n print('NO')\nelse:\n print('YES')"}], "negative_code": [{"source_code": "a, b = map(int, input().split())\nif abs(a-b) >= 2:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "\na, b = map(float, raw_input().split())\n\nif (a != 0 and b != 0):\n\tprint \"NO\"\nelif abs(b - a) <= 1:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n\n\n\n"}, {"source_code": "a, b = map(int, input().split())\nc = a+b\nd = 0\ne = 0\nif(c%2 == 0):\n d = c//2\n e = c//2\nelse:\n d = c//2\n e = c//2+1\nif(a == d or a == e and b == e or b == d):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n\n\n\"\"\"n, m = map(int, input().split())\na = []\nb = []\nd = []\ne = 0\nfor i in range(n):\n s = input()\n s = list(s)\n a.append(s)\nfor i in range(len(a)):\n for j in range(i+1, len(a)):\n if(a[i] == a[j][::-1]):\n if(len(b) == 0):\n b.insert(0,''.join(map(str,a[i])))\n b.insert(1,''.join(map(str,a[j])))\n else:\n b.insert(0,''.join(map(str,a[i])))\n b.insert(len(b),''.join(map(str,a[j])))\n #print(b)\n if(len(a[i])%2 == 0):\n if(a[i][:len(a[i])//2] == a[i][len(a[i])//2:][::-1]):\n e = 1\n if(len(d) == 0):\n b.insert(len(b)//2,''.join(map(str,a[i])))\n d.append(''.join(map(str,a[i])))\n #break\n #else:\n #b.insert(0,''.join(map(str,a[i])))\n #d.append(''.join(map(str,a[i])))\n else:\n if(a[i][:len(a[i])//2+1] == a[i][len(a[i])//2:][::-1]):\n e = 1\n if(len(d) == 0):\n b.insert(len(b)//2,''.join(map(str,a[i])))\n d.append(''.join(map(str,a[i])))\n #break\n #else:\n #b.insert(0,''.join(map(str,a[i])))\n #d.append(''.join(map(str,a[i])))\n \nprint(len(''.join(map(str,b))))\nprint(''.join(map(str,b)))\n#print(d)\n#print(e)\n#print(a)\"\"\"\n\n\n\n\n\"\"\"s = input()\ns = list(s)\na = []\nb = []\nd = 0\nif(len(s)%2 == 0):\n a.append(s[:len(s)//2])\n b.append(s[len(s)//2:])\nelse:\n a.append(s[:len(s)//2+1])\n b.append(s[len(s)//2:])\n#b = b[::-1]\na = sum(a,[])\nb = sum(b,[])\n#print(a)\n#print(b)\nfor i in range(len(a)):\n if(a[i] != b[len(a)-i-1]):\n d += 1\n #print(a[i])\n #print(b[len(a)-1-i])\n #else:\n #print(a[i])\n #print(b[len(a)-i-1])\n#print(d)\nif(d == 1 and len(s)%2 == 0):\n print(\"YES\")\nelif(d == 0 and len(s)%2 == 0):\n print(\"NO\")\nelif((d == 0 or d == 1) and len(s)%2!=0):\n print(\"YES\")\nelse:\n print(\"NO\")\"\"\"\n\n\n \n \n \n\n\n\"\"\"n, k = map(int, input().split())\na = list(map(int, input().split()))\ni = 1\nwhile(k-i > 0):\n k -= i\n i += 1\n\n#b = []\n#for i in range(1,n+1):\n #b.append(a[0:i])\n#b = sum(b,[])\n#print(b)\nprint(a[k-1])\"\"\"\n\n\n\n\"\"\"n = int(input())\na = 0\nb = 0\nd = n%7\nif(d == 0):\n e = n//7\n a = 2*e\n b = 2*e\nelse:\n if(n<7):\n if(d == 1):\n a = 0\n b = 1\n elif(d > 1 and d < 6):\n a = 0\n b = 2\n else:\n a = 1\n b = 2\n else:\n e = n//7\n a = 2*e\n b = 2*e\n if(d == 1):\n b += 1\n elif(d<6):\n b += 2\n else:\n a += 1\n b += 2\nprint(a, b)\"\"\" \n\n\n\"\"\"for i in range(int(input())):\n n, m = list(map(int, input().split()))\n a = [[int(x) for x in input().split()] for _ in range(n)]\n r = set()\n c = set()\n #print(a)\n for i in range(n):\n for j in range(m):\n if(a[i][j] == 1):\n r.add(i)\n c.add(j)\n b = min(n-len(r), m-len(c))\n \n if(b%2 == 0):\n print(\"Vivek\")\n else:\n print(\"Ashish\")\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n d = 0\n e = 0\n g = 0\n c = sorted(a)\n if(a == c):\n d = 1\n else:\n for i in range(n):\n if(b[i] == 0):\n e += 1\n else:\n g += 1\n if(e and g):\n d = 1\n if(d == 1):\n print(\"Yes\")\n else:\n print(\"No\")\"\"\"\n \n \n \n \n\"\"\"def createMatrix(rowCount, colCount, dataList): \n mat = []\n for i in range (rowCount):\n rowList = []\n for j in range (colCount):\n if dataList[j] not in mat:\n rowList.append(dataList[j])\n mat.append(rowList)\n\n return mat \n\n \nfor i in range(int(input())):\n n = int(input())\n r = n\n c = n\n a = [x for x in range(1,n**2+1)]\n m = createMatrix(r,c,a)\n if(n == 2):\n for i in range(n):\n for j in range(n-1):\n if(i%2 != 0):\n m[i][j], m[i][n-1-j] = m[i][n-1-j], m[i][j]\n else:\n for i in range(n):\n for j in range(n-2):\n if(i%2 != 0):\n m[i][j], m[i][n-1-j] = m[i][n-1-j], m[i][j]\n #if((m[i][j] + m[n-1-i][n-1-j])%2 != 0):\n #m[n-1-i][n-1-j], m[n-1-i][n-1-j-1] = m[n-1-i][n-1-j-1], m[n-1-i][n-1-j]\n #else:\n #m[n-1-i][n-1-j], m[n-1-i][n-1-j-1] = m[n-1-i][n-1-j-1], m[n-1-i][n-1-j]\n for i in range(n):\n for j in range(n):\n print(m[i][j], end=' ')\n print( )\"\"\"\n \n \n \n \n \n \n \n \n\n\n\"\"\"for i in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n b = 0\n c = 0\n d = 1\n e = 0\n if(len(a) == 1):\n if(a[0] == 5):\n d = 1\n else:\n d = 0\n else:\n #b.append(a[0])\n for i in range(1, n):\n if(a[i] == 10):\n c += 1\n if(b > 0):\n b = b-1\n else:\n d = 0\n break\n #if(a[i] - b <= 5):\n #b.append(a[i] - sum(b))\n #b += a[i]-5\n elif(a[i] == 15):\n e += 1\n if(c > 0):\n c = c-1\n elif(b > 1):\n b = b-2\n else:\n d = 0\n break\n else:\n #b = b + a[i]\n b += 1\n \n \n #if(e == 0):\n #if(c <= b and c>=1 and b>=1):\n #d = 1\n #else:\n #d = 0\n #else:\n #if(e<=c and c<=b and c>=1 and b>=1):\n #d = 1\n #else:\n #d = 0\n if(d == 1):\n print(\"YES\")\n else:\n print(\"NO\")\"\"\"\n \n \n \n\n\n\"\"\"for i in range(int(input())):\n s = input()\n a = 0\n s = list(s)\n j = 1\n for i in range(0, len(s)-1):\n #while(len(s) != 0):\n if(len(s) == 0):\n break\n if((s[i] =='x' and s[i+1] == 'y') or (s[i] == 'y' and s[i+1] == 'x')):\n a += 1\n s[i+1] = 'z'\n #print('a')\n #print(j)\n #else:\n #j -= 1\n #print(j)\n #s.remove(i)\n #s.remove(i+1)\n #if(len(s) == 0):\n #break\n print(a)\"\"\"\n \n \n\n\"\"\"for i in range(int(input())):\n n, k = map(int, input().split())\n p = list(map(int, input().split()))\n a = 0\n for i in range(n):\n if(p[i] > k):\n a += p[i] - k\n print(a)\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n ts = int(input())\n a = 0\n b = 0\n if(ts == 1):\n b = 0\n else:\n if(ts%2 != 0):\n a = ts//2+1\n b = ts-a\n else:\n d = 0\n while(ts%2 == 0):\n d += 1\n ts = ts//2\n if(ts%2 != 0):\n a = ts//2+1\n b = ts-a\n print(b)\"\"\"\n \n\n\"\"\"for i in range(int(input())):\n n = int(input())\n s = list(map(int, input().split()))\n a = []\n c = []\n s.sort()\n for k in range(1,1024):\n for i in s:\n b = i^k\n a.append(b)\n #print(a)\n #print(s)\n if(s == sorted(a)):\n c.append(k)\n a.clear()\n if(len(c) == 0):\n c.append(-1)\n print(min(c))\"\"\"\n \n \n\n\n\"\"\"for i in range(int(input())):\n a, b = map(int, input().split())\n c = 0\n if(a == b):\n c = 0\n elif(a > b):\n d = a/b\n if(d == a//b):\n if(d == 1 and a == b):\n c = 0\n elif(d == 2 or d == 4 or d == 8):\n c = 1\n elif(d > 8 and d%2 == 0):\n while(d != 1):\n if(d%8 == 0):\n d = d//8\n c += 1\n elif(d%4 == 0):\n d = d//4\n c += 1\n elif(d%2 == 0):\n d = d//2\n c += 1\n else:\n c = -1\n break\n else:\n c = -1\n else:\n c = -1\n else:\n d = b/a\n if(d == b//a):\n if(d == 1 and b == a):\n c = 0\n elif(d == 2 or d == 4 or d == 8):\n c = 1\n elif(d > 8 and d%2 == 0):\n while(d != 1):\n if(d%8 == 0):\n d = d//8\n c += 1\n elif(d%4 == 0):\n d = d//4\n c += 1\n elif(d%2 == 0):\n d = d//2\n c += 1\n else:\n c = -1\n break\n else:\n c = -1\n else:\n c = -1\n print(c)\"\"\"\n \n \n \n\n\n\"\"\"for i in range(int(input())):\n s = input()\n a = list(s)\n d = ['0', '1', '0']\n e = ['1', '0', '1']\n b = 0\n if(len(a) < 3):\n b = 0\n elif(len(a) == 3):\n if(a != d and a != e):\n b = 0\n else:\n b = 1\n else:\n g = 0\n h = 0\n for i in a:\n if(i == '0'):\n g += 1\n else:\n h += 1\n if(g <= 1 or h <= 1):\n b = 0\n if(g < h):\n b = g\n else:\n b = h\n print(b)\"\"\"\n \n \n\n\n\"\"\"for i in range(int(input())):\n n, x = map(int, input().split())\n a = list(map(int, input().split()))\n b = 0\n c = 0\n d = 0\n if(len(a) == 1):\n if(a[0]%2 == 0):\n b = 0\n else:\n b = 1\n else:\n for i in a:\n if(i%2 == 0):\n c += 1\n else:\n d += 1\n if(x < c+d):\n if(c and d > 1):\n b = 1\n elif(c == 0 and x%2 == 0):\n b = 0\n elif(d == 0):\n b = 0\n else:\n b = 1\n else:\n #if(x%2 == 0):\n if(d%2 != 0):\n b = 1\n else:\n b = 0\n if(b == 0):\n print(\"No\")\n else:\n print(\"Yes\")\"\"\"\n #print(b)\n \n \n\n\n#import math\n\"\"\"for i in range(int(input())):\n n, m, k = map(int, input().split())\n c = n//k\n if(m == 0):\n d = 0\n elif(m <= c):\n d = m\n else:\n d = (m-c)//(k-1)\n if((m-c)%(k-1) != 0):\n d += 1\n d = c - d\n #d = c - math.ceil((m-c)/(k-1))\n #else:\n #d = c - 1\n #if(d < 0):\n #d = 0\n print(d)\"\"\"\n\n\n\"\"\"def min(n,m):\n if(n%2 == 0 and m%2 == 0):\n b = n*(m//2)\n elif(n%2 == 0 and m%2 != 0):\n b = (n*(m//2))+n//2\n elif(n%2 != 0 and m%2 == 0):\n b = n*(m//2)\n else:\n b = (n*(m//2)) + (n-(n//2))\n return(b)\n \n\n\nfor i in range(int(input())):\n n, m = map(int, input().split())\n print(min(n,m))\"\"\"\n \n\n\n\n\"\"\"from collections import defaultdict\n\ndef smallest(s1, s2):\n assert s2 != ''\n d = defaultdict(int)\n nneg = [0] \n def incr(c):\n d[c] += 1\n if d[c] == 0:\n nneg[0] -= 1\n def decr(c):\n if d[c] == 0:\n nneg[0] += 1\n d[c] -= 1\n for c in s2:\n decr(c)\n minlen = len(s1) + 1\n j = 0\n for i in range(len(s1)):\n while nneg[0] > 0:\n if j >= len(s1):\n return minlen\n incr(s1[j])\n j += 1\n minlen = min(minlen, j - i)\n decr(s1[i])\n return minlen\n \n# ans = smallest(\"12222133333332\", \"123\")\n# print(ans)\n\nfor i in range(int(input())):\n s1= input()\n e = 0\n g = 0\n h = 0\n for i in range(len(s1)):\n if(s1[i] == '1'):\n e += 1\n elif(s1[i] == '2'):\n g += 1\n elif(s1[i] == '3'):\n h += 1\n s2=\"123\"\n \n if(e < 1 or g < 1 or h < 1):\n ans = 0\n else:\n ans= smallest(s1, s2)\n print(ans)\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n a, b, c, d = map(int, input().split())\n r = b\n ans = 0\n if(b < a and c < d):\n ans = -1\n else:\n i = 0\n while(r < a):\n r += c - d\n i += 1\n if(i == 0):\n ans = b\n else:\n ans = b + i*c\n print(ans) \n\nif(d >= c && a >b)\n cout << -1 << endl;\n continue;\n }\n if(a <= b){\n cout << b << endl;\n continue;\n }\n a -= b;\n long int q = c-d;\n if(a % q == 0)\n {\n cout << ((a/q)*c)+b << endl;\n }else{\n cout << (((a/q)+1)*c)+b << endl;\n }\"\"\"\n\"\"\"for i in range(int(input())):\n n = int(input())\n s = list(map(int, input().split()))\n s.sort()\n c = 0\n p = 1\n if(n == 1):\n c = 1\n else:\n \n for i in range(n):\n if(s[i] <= p):\n c += 1\n p = p - s[i] + 1\n else:\n p = p + 1\n print(c)\"\"\"\n\n\n\n\"\"\"res = False\ndef chkList(lst):\n if len(lst) < 0 : \n res = True\n res = all(ele == lst[0] for ele in lst)\n return(res)\n\n\n\nfor i in range(int(input())):\n n = int(input())\n l = list(map(int, input().split()))\n p = l.copy()\n c = 0\n d = []\n if(chkList(l) == True):\n h = len(l)\n else:\n \n h = len(l)\n print(h)\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n n = int(input())\n l = list(map(int, input().split()))\n l.sort()\n l.reverse()\n #print(l)\n res = 0\n p = 0\n while(True):\n res += 1\n p = p + l[p]\n if(p >= n):\n break\n print(res)\"\"\"\n \n\"\"\"7017173017\"\"\"\n\n \n\n"}, {"source_code": "a,b = map(int, input().split())\n\ndef prb():\n for l in range(0,101):\n for r in range(l,101):\n e = 0\n o = 0\n for c in range(l,r+1):\n if(c%2==0):\n e = e+1\n else:\n o = o+1\n if(e == a and o == b):\n print(\"YES\")\n return\n print(\"NO\")\n return\n\nprb()"}, {"source_code": "n, m = map(int, input().split())\nif abs(n - m) == 1 or n == m:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "A = list(map(int, input().split()))\n\nif (A[0] - 1) == A[1] or (A[0] + 1) == A[1] or A[0] == A[1]:\n print('YES')\nelif A[0] == 0 and A[1] == 0:\n print('NO')\nelse:\n print('NO')"}, {"source_code": "a, b = map (int, input().split())\nprint ((\"NO\", \"YES\")[a == b or b - a == 1 and a != 0 and b != 0]) "}, {"source_code": "a,b=map(int,input().split())\nif abs(a-b)<2 :\n if a!=0 and b!=0:print(\"YES\")\n else:print(\"NO\")\nelse:print(\"NO\")"}, {"source_code": "\ns=input()\nnums=s.split(\" \")\na=int(nums[0])\nb=int(nums[1])\n\nif (a==b or b==a+1 or a==b+1) and (b>0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a, b = map(int, input().split())\nif abs(a - b) <= 1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nif (a*b>0) and ((abs(b-a)==1) or (abs(b-a)==0)) :\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\nimport math\n\nm,d = map(int,sys.stdin.readline().split())\n\ndays31=[1,3,5,7,8,10,12]\ndays30=[4,6,9,11]\n\nnumofdays=28\nif m in days31:numofdays=31\nif m in days30:numofdays=30\n\nnumweeks=numofdays/7\nif numofdays%7>0:\n numweeks+=1\n\nend =(numofdays-1)%7+1\nend+=d-1\nif end>7:\n numweeks+=1\n\nprint numweeks\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\neven,odd=l()\nif abs(even-odd)<=1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "import math\na,b=input().split()\na = math.fabs(int(a))\nb = math.fabs(int(b))\nz = a - b\nz = math.fabs(z)\nif z<=-2 or z>=2:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n,m=input().split()\nn,m=int(n),int(m)\nif(m-n)==1 or (m-n)==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a, b = map(int, input().split())\nif abs(a-b) >= 2 and (a != 0 and b != 0):\n print('NO')\nelse:\n print('YES')"}, {"source_code": "a,b=map(int,input().split())\nif (a*b>=0) and (abs(a-b)<2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from __future__ import division\n\nfrom sys import stdin, stdout, maxint\n\nfrom fractions import Fraction\nimport bisect, collections, heapq, itertools, operator\n\nA, B = map (int, stdin.readline ().split ())\n\nif (abs (A - B) <= 1):\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "def interval (odd,even):\n if odd == 0 or even == 0:\n return \"NO\"\n elif abs(odd-even) > 1:\n return \"NO\"\n else:\n return \"YES\"\n\nodd,even = list(map(int,input().split()))\nprint (interval(odd,even))\n\n\n \n \n \n \n"}, {"source_code": "import math\na,b=input().split()\na = math.fabs(int(a))\nb = math.fabs(int(b))\nz = a - b\nz = math.fabs(z)\nif z>1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "a,b=map(int, input().split())\nif abs(a-b)<=1 and b>=a: print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "n,m = map(int,input().split())\n\npai = 0\nimp = 0\n\ni = 1\n\nwhile pai + imp != n + m :\n\t\n\tif i%2==0 :\n\t\tpai = pai + 1\n\telse :\n\t\timp = imp + 1\n\ti = i + 1\n\nif pai == n and imp == m :\n\tprint(\"YES\")\nelse :\n\tprint(\"NO\")\n"}, {"source_code": "a, b = map(int, input().split())\n\nif abs(a - b) >= 2 or a == 1 and b == 0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "o, e = [int(x) for x in input().split()]\nprint([\"NO\", \"YES\"][abs(o - e) <= 2])"}, {"source_code": "m,n=map(int,input().split())\nif m==n:\n print(\"YES\")\nelif n-m==1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import math\nn,k=map(int,input().split())\nif abs(n-k)<=1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=raw_input().split()\nA=int(a)\nB=int(b)\nif (A-B==1) or (B-A==1) or (B-A==0) or ((A==0) and (B==0)) :\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "a,b = map(int,raw_input().split())\nprint \"YES\" if abs(a-b) < 2 else \"NO\""}, {"source_code": "a,b = [int(x) for x in input().split()] \nif b-a <= 1 and a*b != 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n,m=map(int,raw_input().split())\nif m==n or m-n==1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "l,r=map(int,input().split(\" \"))\na=0\nb=0\nc=0\nd=0\nfor i in range(1,l+r+1):\n if(i%2==0):\n a=a+1\n if(i%2==1):\n b=b+1\n\nfor i in range(2,l+r+2):\n if(i%2==0):\n c=c+1\n if(i%2==1):\n d=d+1\n\n\nif(a==l and b==r or(c==l and d==r)):\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "a, b = map(int, input().split())\nif abs(a-b) <= 1 and a != 0 and b != 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().strip().split()[:2])\neve=odd=0\nfor x in range(1,a+b+1):\n\tif x%2==0:\n\t\teve+=1\n\telse:\n\t\todd+=1\nif eve==a and odd==b:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "n,m=map(int,input().split())\n\nif abs(n-m) > 1:\n print('NO')\nelif n==m:\n print('NO')\nelse :\n print('YES')"}, {"source_code": "a,b = map(int,input().split())\nif a - b == 1 or b-a == 1 or a-b == 0 or b-a == 0 and a !=0 and b!=0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "a,b = [int(x) for x in input().split()] \nif (b-a) <= 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a, b = map(int, raw_input().split())\nif (abs(a-b) == 1 and b > a) or abs(a-b) == 0 :\n print \"YES\"\nelse :\n print \"NO\"\n"}, {"source_code": "a, b = list(map(int,input().split()))\nprint('YES' if a-b<=1 else 'NO') "}, {"source_code": "a , b = map ( int , raw_input () . split () )\nif 0 <= a <= 100 and 0 <= b <= 100 :\n if abs (a - b) > 1 and a != 0 and b != 0 :print 'NO'\n else :print 'YES'\n\n"}, {"source_code": "a,b=map(int,input().split())\nprint('YES' if a-b in [1,-1,0] else 'NO')"}, {"source_code": "n,m = map(int,raw_input().split())\nif abs(n-m)<=1 :\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "a,b=map(int,input().split())\nif b-a==1 or b-a==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a,b=map(int,input().split())\nif a==b-1 or b==a-1 or a==b:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a, b = map(int, input().split())\nif abs(a - b) < 2 and a != b != 0:\n print('YES')\nelif abs(a - b) >= 2 or a == b == 0:\n print('NO')\n"}, {"source_code": "a,b=map(int,input().split())\nif a==b==0:\n print('YES')\nelif max(a,b)-min(a,b)==1:\n print('YES')\nelse: print('NO')"}, {"source_code": "l = map(int, raw_input().split())\nif abs(l[0] - l[1]) > 1:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "n,m = input().strip().split()\nn = int(n)\nm = int(m)\nif n > m or m - n > 1:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "a, b = map(int, raw_input().split())\n\nprint 'YES' if abs(a - b) < 2 else 'NO'"}, {"source_code": "for i in range(1):\n n,m=map(int,input().split())\n if n!=0 and m!=0:\n if abs(n-m)==0 or abs(n-m)==1:\n print('YES')\n else:\n print('NO')\n else:\n print('NO')"}, {"source_code": "even, odd = input().split(\" \")\nodd = int(odd)\neven = int(even)\nif (odd + even) % 2 == 0:\n if odd == even:\n print('YES')\n else:\n print(\"NO\")\nelse:\n if even+1 == odd:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "import sys\nimport math\n\nm,d = map(int,sys.stdin.readline().split())\n\ndays31=[1,3,5,7,8,10,12]\ndays30=[4,6,9,11]\n\nnumofdays=28\nif m in days31:numofdays=31\nif m in days30:numofdays=30\n\nnumweeks=numofdays/7\nif numofdays%7>0:\n numweeks+=1\n\nend =(numofdays-1)%7+1\nend+=d-1\nif end>7:\n numweeks+=1\n\nprint numweeks\n"}, {"source_code": "a, b = [int(i) for i in input().split()]\nif b >= a:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "i1=raw_input()\ni2=i1.split()\ni2List=[int(a0)for a0 in i2]\nnumb1=i2List[0]\nnumb2=i2List[1]\nif (numb1<=0 and numb2<=0)or(numb1>=100 and numb2>=100):\n\tprint 'NO'\nelse:\n if abs(numb1-numb2)>=0 or abs(numb1-numb2)<=1 :\n \tprint 'YES'\n else:\n \tprint 'NO'\n\t\n\n\t\n"}, {"source_code": "a, b = list(map(int, input().strip().split(' ')))\nif abs(a-b) > 1:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "# cook your code here\ns=raw_input()\narr=s.split(\" \")\n#print arr\nx=int(arr[0])\ny=int(arr[1])\n#print arr[0]\nif(x-y==1):\n print \"Yes\"\nelif(y-x==1):\n print \"Yes\"\nelif(x==y):\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "a, b = map(int, input().split())\nif abs(a - b) < 2 and a != b != 0:\n print('YES')\nelif abs(a - b) >= 2 or a == b == 0:\n print('NO')\n"}, {"source_code": "a,b=map(int,input().split())\nif abs(b-a)==1 or abs(b-a)==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a , b = map ( int , raw_input () . split () )\nif 0 <= a <= 100 and 0 <= b <= 100 :\n if abs (a - b) > 1 and a != 0 and b != 0 :print 'NO'\n else :print 'YES'\n\n"}, {"source_code": "a,b = map(int,input().split())\nif a - b == 1 or b-a == 1 or a-b == 0 or b-a == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "a,b =map(int,raw_input().split())\nif abs(a-b)==1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n, m = map(int, input().split())\nif abs(n - m) < 2 or (abs(n - m) == 2 and n != 0 and m != 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,input().split())\nif a<=b:\n\tprint('YES')\nelse:\n\tprint('NO')\n\n"}, {"source_code": "even, odd = [int(x) for x in input().strip().split()]\n\nif abs(odd-even) == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "a,b=map(int,input().split())\nif(a==b or a==b+1 or a+1==b):\n print('YES')\nelse:\n print('NO')\n\n "}, {"source_code": "a,b = map(int,input().split(\" \"))\nprint(\"YES\" if abs(a-b)<2 else \"NO\")"}, {"source_code": "a,b=map(int,input().split())\nif abs(a-b)>1:\n print('NO')\nelse: print('YES')"}, {"source_code": "a, b = map(int, input().split())\nif abs(a - b) <= 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "\na, b = map(float, raw_input().split())\n\nif abs(b - a) == 1:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n\n\n\n"}, {"source_code": "a=input().split()\nrt=len(a)\nlst=[]\ni=0\nwhile(i<rt):\n lst.append(int(a[i]))\n i=i+1\nk=lst[0]+lst[1]\nif(k%2==0):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "a,b = list(map(int,input().split()))\nc = a + b\nif a == b:\n print('Yes')\nelif c % 2 == 1:\n if c // 2 == b - 1 or c // 2 == a - 1:\n print('Yes')\n else:\n print('No')\nelse:\n print('No')"}, {"source_code": "a, b = map(int, input().split())\nif abs(a-b) > 1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "a,b = map(int, raw_input().split())\n\nprint \"YES\" if a - b <= 1 else \"NO\""}, {"source_code": "a,b = map(int,input().split())\nif a < b and b-1 == a:\n print('YES')\nelif a == b:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import bisect\nfrom collections import defaultdict\nfrom collections import deque\nimport math\nimport re\n\ndef ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\ndef si():\n return raw_input()\n\ndef sis():\n return raw_input().split()\n\ndef arr_str(a):\n return ' '.join(map(str, a))\n\na, b = nis()\n\nprint 'YES' if abs(a - b) < 2 else 'NO'"}, {"source_code": "even,odd=map(int,input().split())\nif odd==0:\n\tprint(\"NO\")\n\nelif even-odd==1 or even-odd==-1:\n\tprint(\"YES\")\nelif even-odd==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\nif abs(a - b) <= 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "\nif __name__== \"__main__\":\n a,b=map(int,raw_input().split())\n e=o=0\n n=a+b\n i=1\n while i<=n:\n if i%2:\n o+=1\n else:\n e+=1\n i+=1\n if e==a and o==b:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "a,b=map(int,input().strip().split()[:2])\nif a==b or a==b+1 or a+1==b :\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "a,b=map(int,input().split())\nif (a-b<=1) and (a-b>=-1):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n,m=input().split()\nn,m=int(n),int(m)\nif(m-n)==1 or (m-n)==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a, b = [int(x) for x in input().split()]\nn = a + b\nif a - b >= -2 and a - b <= 2:\n if (n % 2 == 0 and (a % 2 == 0 and b % 2 == 0) or (a % 2 != 0 and b % 2 !=0)) or (n % 2 !=0 and (a % 2 !=0 or b % 2 != 0)):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n,m=map(int,raw_input().split())\nif m==n or m-n==1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "#!/usr/bin/python2\n\nimport sys\n\nstdin = sys.stdin.readline()\nstdin = stdin.split(' ')\n#args = sys.argv[1:]\nval1 = int(stdin[0])\nval2 = int(stdin[1])\n\nif (val1 == 0):\n print(\"NO\")\nelif ((val2 - val1) == 1 or (val2 - val1) == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b=map(int,input().split())\nif a==b-1 or b==a-1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=input().split()\nrt=len(a)\nlst=[]\ni=0\nwhile(i<rt):\n lst.append(int(a[i]))\n i=i+1\nk=lst[0]+lst[1]\nif(k%2==0):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "a,b=map(int,input().split())\nif ((a*b<=10000) and (a*b>=1)) and ((abs(b-a)==1) or (abs(b-a)==0)):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a, b = map(int, input().split())\nif abs(a - b) <= 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "e,o=map(int,input().split())\nprint(\"YES\" if(abs(o-e)<=1) else \"NO\")"}, {"source_code": "(a,b)=map(int,input().split());\nif((b==a or b==a+1) and b!=0):\n print(\"YES\");\nelse:\n print(\"NO\");\n \n"}, {"source_code": "a, b = map(int, input().split())\nif abs(a-b) < 2 and a != 0 and b != 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import os\nimport sys\nimport math\nimport heapq\nfrom decimal import *\nfrom io import BytesIO, IOBase\nfrom collections import defaultdict, deque\n\ndef r():\n return int(input())\ndef rm():\n return map(int,input().split())\ndef rl():\n return list(map(int,input().split()))\n\na,b=rm()\nif abs(a-b)<=1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a,b = list(map(int,input().split()))\nc = a + b\nif c + 1 >= a * 2:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "n, m = map(int, input().split())\nif abs(n - m) == 1 or (n == m and n, m > 0) :\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "x,y = map(int,raw_input().split())\nif x==y +1 or y == x+1:\n print(\"YES\\n\")\nelse:\n print(\"NO\\n\")\n"}, {"source_code": "# cook your code here\ns=raw_input()\narr=s.split(\" \")\n#print arr\nx=int(arr[0])\ny=int(arr[1])\n#print arr[0]\nif(x-y==1):\n print \"Yes\"\nelif(y-x==1):\n print \"Yes\"\nelif(x==y):\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "a,b=map(int,input().split())\nif a<=b:\n\tprint('YES')\nelse:\n\tprint('NO')\n\n"}, {"source_code": "a, b = map(int, input().split())\n\nisTrue = False\nodd = 0\neven = 0\nfor i in range(1, 300):\n if even == a and odd == b:\n isTrue = True\n\n if i & 1:\n odd += 1\n else:\n even += 1\n\nif isTrue:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# -*- coding:utf-8 -*-\n\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n a,b = [int(x) for x in raw_input().split()]\n if abs(b-a)<2:\n print \"YES\"\n else:\n print \"NO\"\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n"}, {"source_code": "a, b = map(int, raw_input().split())\nprint ['NO', 'YES'][abs(a-b) < 2]"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n a,b = LI()\n if abs(a-b) < 2 or a*b == 0:\n return 'YES'\n\n return 'NO'\n\n\nprint(main())\n\n\n"}], "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037"} {"source_code": "n, p, k = map(int, input().split())\nif p - k > 1:\n print('<<', end=' ')\nfor i in range(max(1, p - k), min(n, p + k) + 1):\n if i != p:\n print(i, end=' ')\n else:\n print('(' + str(i) + ')', end=' ')\nif p + k < n:\n print('>>')", "positive_code": [{"source_code": "a,b,c = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nli = []\nfor i in range(b-c,b+c+1):\n if i>0:\n li.append(i)\n\nif li[0]!=1:\n print(\"<<\",end=\" \")\n\nfor i in li:\n \n if i==b:\n print('('+str(i)+')',end=\" \")\n else:\n print(i,end=\" \")\n\n if i==a:\n break\n\nif a not in li:\n print(\">>\")\n"}, {"source_code": "n, p, k = map(int, input().split())\n\nans = [i for i in range(p - k, p + k + 1)]\n\nwhile ans[0] < 1:\n ans.pop(0)\nwhile ans[-1] > n:\n ans.pop()\n\nif ans[0] > 1:\n ans = ['<<'] + ans\nif ans[-1] < n:\n ans.append('>>')\nfor i in range(len(ans)):\n if ans[i] == p:\n ans[i] = f'({p})'\nprint(*ans)\n"}, {"source_code": "n, p, k = list(map(int, input().split()))\nglobal res\nres = \"\"\ndef calc(cond, string):\n global res\n if cond:\n res += string\n \noriginK = k \ncalc(p-k > 1, \"<< \")\n\nwhile k>=1:\n calc(p-k >= 1, str(p-k)+\" \")\n k -= 1\n\ncalc(1<=p and p<=n, \"(\"+str(p)+\")\")\nk=1\nwhile k <= originK:\n calc(p+k <= n, \" \"+str(p+k))\n k += 1\n \ncalc(p+originK < n, \" >>\")\nprint(res)\n \n"}, {"source_code": "entrada = list(map(int,(input().split())))\nenumeracion = entrada[0]\nposicion = entrada[1]\npag_de_lado = -(entrada[2])\npag_lado = pag_de_lado - 1\ncadena = ''\nfor i in range((entrada[2]*2) +1):\n pag_lado +=1\n if (posicion + pag_lado) <= 0 or (posicion + pag_lado) > enumeracion:\n continue\n cadena += str(posicion + pag_lado) + ' '\ncadena = cadena.split()\nfor h in range(len(cadena)):\n if cadena[h] != '1' and h == 0:\n print('<<', end=' ')\n if cadena[h] == str(posicion):\n print('('+cadena[h]+')', end = ' ')\n elif cadena[h] == '1' and h == 0 :\n print(cadena[h], end= ' ')\n elif cadena[h] == str(enumeracion):\n print(cadena[h], end= '')\n else:\n print(cadena[h], end= ' ')\n if str(enumeracion) != cadena[h] and h == max(range(len(cadena))):\n print('>>', end = '')\n"}, {"source_code": "n = list(map(lambda x: int(x), input().split(' ')))\nn, p, k = n[0], n[1], n[2]\npages = []\nfor i in range(-k, k+1):\n\tif p + i == p:\n\t\tpages.append(f'({p})')\n\telif p + i > 0 and p + i < n + 1:\n\t\tpages.append(str(p+i))\nif '1' not in pages and '(1)' not in pages:\n\tpages.insert(0, '<<')\nif str(n) not in pages and f'({n})' not in pages:\n\tpages.append('>>')\nprint(str(' '.join(pages)))"}, {"source_code": "# # import numpy as np\n#\n# def spliter(arr,low,high):\n# if(high-low==1):\n# # print(\"1\")\n# return 1\n#\n# if(arr[low:high]==sorted(arr[low:high])):\n# # print(\"here \"+str(high-low))\n# return high-low\n# else:\n# mid=(high+low)//2\n# # print(\"----------\")\n# # print((low,mid))\n# # print(\"---------\")\n# # print((mid,high))\n# # print(\"-----------\")\n# a=spliter(arr,low,mid)\n# # print(\"was here\")\n# b=spliter(arr,mid,high)\n#\n# # print((a,b))\n# if(a>=b):\n# return a\n# else:\n# return b\n#\n# def main():\n# n=int(input())\n# arr=list(map(int,input().split(\" \")))\n# lenght = n\n# if arr==sorted(arr):\n# print(n)\n# else:\n# mid=lenght//2\n# a=spliter(arr,0,mid)\n# b=spliter(arr,mid,lenght)\n# if(a>b):\n# print(a)\n# else:\n# print(b)\n#\n# main()\n\n\n# def main():\n# checker=\"nineteen\"\n# # n=\"nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\"\n# n=input()\n# number={}\n# # print(set(n))\n# for i in n:\n# if i in checker:\n# number[i]=number.get(i,0)+1\n# # number=sorted(number.values())\n# # print(sorted(number.keys()))\n# for i in [\"n\",\"t\",\"i\",\"e\"]:\n# if i not in number.keys():\n# break\n#\n# else:\n# num=number[\"i\"]\n# min=num\n# other_Dict={\"n\":3,\"i\":1,\"e\":3,\"t\":1}\n# if(number[\"n\"]%3==2):\n# number[\"n\"]=number.get(\"n\",0)+number[\"n\"]//3\n#\n# for i in number.keys():\n# if (number[i]//other_Dict[i]>=num):\n# pass\n# elif(number[i]//other_Dict[i]<=num):\n#\n# if(min>number[i]//other_Dict[i]):\n# min=number[i]//other_Dict[i]\n# else:\n# print(min)\n# return\n# print(0)\n# main()\n # return False\n # for i,j in number:\n # if i==\"n\" and i\n# # print(number)\n# print(main())\n# main()\n# d={}\n# d[10]=1\n# d[10]+=2\n# d[10].append(10)\n# 2//3\n# d.get(10,5)\n# d.keys()\n# main()\n# d={}\n# for i in \"nineteen\":\n# d[i]=d.get(i,0)+1\n# d\n# \"i\" not in d.keys()\n# some=\"nineoindojaoidjoiajdoiaoidjiadjkajoidjoiajdljadjoiadlkjaadj\"\n# list(some.split(\"nineteen\"))\n\n\ndef main():\n n=list(map(int,input().split(\" \")))\n navigation=[]\n for i in range(n[1]-n[2],n[1]):\n if(i>0):\n navigation.append(i)\n for i in range(n[1],n[1]+n[2]+1):\n if(i<=n[0]):\n navigation.append(i)\n if(navigation[0]>1):\n navi=[0]*len(navigation)\n navi[0]=\"<<\"\n navi[1:len(navigation)]=navigation\n navigation=navi\n if(navigation[len(navigation)-1]<n[0]):\n navigation.append(\">>\")\n string=\"\"\n for i in navigation:\n if(str(i)==str(n[1])):\n string+=\"({}) \".format(i)\n else:\n string+=\"{} \".format(i)\n print(string[:-1])\nmain()\n\n\n\n\n"}, {"source_code": "X = list(map(int, input().split()))\nPages = [str(i + 1) for i in range(X[0])]\nPages[X[1] - 1] = '(' + Pages[X[1] - 1] + ')'\nif X[1] - X[-1] > 1:print(\"<< \", end=\"\")\nprint(*Pages[max(0, X[1] - X[-1] - 1):min(X[0], X[1] + X[-1])], end=\" \")\nif X[1] < X[0] - X[-1]:print(\">>\")\n\n# Caption: God bless you General Soleimani\n\n# ---------Hard Revenge---------\n\n# ****** Rest in Peace ******\n"}, {"source_code": "n,p,k=map(int,input().split())\nst=\"\"\nleft=[p-i for i in range(k,0,-1)]\nl=[j for j in left if j>0]\nif len(l)!=0 and p!=1 and l[0]!=1:\n st=\"<<\"\n st+=\" \"\nright=[p+i for i in range(1,k+1)]\nr=[j for j in right if j<=n]\nfor i in l:\n st+=str(i)+\" \"\nst+=\"(\"+str(p)+\")\"+\" \"\nfor i in r:\n st+=str(i)+\" \"\nif len(r)!=0 and n!=r[-1] and p!=n:\n st+=\">>\"\n \nprint(st)"}, {"source_code": "l = list(map( int, input().split()))\n\nn = l[0]\np = l[1]\nk = l[2]\ns=''\n\nif p-k > 1:\n s += '<< '\ns += ''.join(map(lambda x: str(x) + ' ' if 0 < x <= n else '', range(p-k, p)))\ns += '('+ str(p) +') '\ns += ''.join(map(lambda x: str(x) + ' ' if 0 < x <= n else '', range(p+1, p+k+1)))\n\nif p+k < n :\n s += '>>'\nprint(s)\n\n\n"}, {"source_code": "n, p, k = map(int, input().split())\n\npages = [str(i) for i in range(1, n+1)]\n\nleft = 0\nif p-k-1>=0:left=p-k-1\nelif k>p: left = 0\nelse:left=p-k\n\nres = [' '.join(pages[left:p-1]), '(' + str(p) + ')', ' '.join(pages[p:p+k])]\n\nif p-k-1>0: res.insert(0,'<<')\n\nif p+k<n: res.append('>>')\n\nprint(' '.join(res).strip())"}, {"source_code": "n,p,k=map(int,input().split())\ns=''\nif(p-k>1):\n s='<< '\nfor i in range(k):\n if(p-k+i>=1):\n s=s+str(p-k+i)+' ' \ns=s+'('+str(p)+')'+' '\nfor i in range(0,k):\n if((p+i+1)<=n):\n s=s+str(p+i+1)+' ' \n\nif((' '+str(n) not in s) and ('('+str(n)+')') not in s):\n s=s+'>>'\nprint(s)\n "}, {"source_code": "user_input=input().split(' ')\nn,p,k=user_input\nn=int(n)\np=int(p)\nk=int(k)\n\nnav=[]\n\nstart=p-k\nif start<=1:\n start=1\nelse:\n nav.append('<<')\nfor i in range(start,p+k+1):\n if i<n:\n if i==p:\n nav.append(f'({str(i)})')\n else:\n nav.append(str(i))\n else:\n if i==p:\n nav.append(f'({str(i)})')\n else:\n nav.append(str(i))\n break\nelse:\n nav.append('>>')\nprint(' '.join(nav))\n"}, {"source_code": "s=input()\nl=list(s.split(' '))\nn=int(l[0])\np=int(l[1])\nk=int(l[2])\nj=k\nl1=[]\nl1.append(\"<<\")\nwhile(j):\n if p-j>=1:\n l1.append(str(p-j))\n j=j-1\n else:\n j=j-1\nl1.append(\"(\"+str(p)+\")\")\nfor i in range(k):\n if p+(i+1)<=n:\n l1.append(str(p+(i+1)))\n else:\n break\nl1.append(\">>\")\nif '1' in l1 or '(1)' in l1:\n l1.remove('<<')\nif str(n) in l1 or '('+str(n)+')' in l1:\n l1.remove('>>')\nfor i in l1:\n if i!='n':\n print(i,end=\" \")\n else:\n print(i)\n\n\n \n \n"}, {"source_code": "n, p, k = map(int, input().split())\nif (p - k <= 1):\n for i in range(1, p):\n print(i, end=\" \")\nelif (p - k > 1):\n print(\"<<\", end=\" \")\n for i in range(p - k, p):\n print(i, end=\" \")\nprint(\"(\"+str(p)+\")\", end=\" \")\nif (p + k < n):\n for i in range(p + 1, p + k + 1):\n print(i, end=\" \")\n print(\">>\")\nelse:\n for i in range(p + 1, n + 1):\n print(i, end=\" \")\n"}, {"source_code": "def main():\n data: list = list(map(int, input().split()))\n # x = [6, 1, 2]\n n: int = data[0]\n p: int = data[1]\n k: int = data[2]\n tmp: list = list()\n nav: list = list()\n\n for i in range(k + 1):\n x = p - i\n if 0 < x:\n if x is not p:\n tmp.append(str(x))\n\n tmp.reverse()\n nav = tmp.copy()\n tmp.clear()\n\n for i in range(k + 1):\n x = p + i\n if x <= n:\n if x is not p:\n tmp.append(str(x))\n\n nav.append('(%d)' % p)\n nav = nav + tmp\n tmp.clear()\n\n if nav[0].strip('(').strip(')') != '1':\n print('<<', end=' ')\n\n if nav[len(nav) - 1].strip('(').strip(')') != str(n):\n print(' '.join(nav), end=' >>\\n')\n else:\n print(' '.join(nav))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\nn, p, k = map(int, input().split())\nout = [str(i) for i in range(max(1, p-k), p)]+['(%d)' % p]+[str(i) for i in range(p+1, min(p+k+1, n+1))]\nif p-k > 1:\n out.insert(0, '<<')\nif p+k < n:\n out.append('>>')\nprint(' '.join(out)+' ')\n"}, {"source_code": "n,p,k=map(int,input().split())\nif p-k>1:\n print(\"<<\",end=\" \")\nfor i in range(max(1,p-k),p):\n print(i,end=\" \")\nprint(\"(\",p,\")\",end=\" \",sep=\"\")\nfor i in range(p+1,1+min(p+k,n)):\n print(i,end=\" \")\nif n>p+k:\n print(\">>\")\n"}, {"source_code": "def pages(n,p,k):\n output = \"\"\n\n if p<1 or p>n :\n return output\n if p-k > 1 :\n output += \"<< \"\n for i in range(p-k, p+k+1):\n if i <= n and i >= 1:\n if i == p:\n output += \"(\" + str(i) + \") \"\n else:\n output += str(i) + \" \"\n\n if p+k < n:\n output += \">>\"\n\n return output\n\nn,p,k = map(int, input().split())\nprint(pages(n, p, k))"}, {"source_code": "n = list(map(int , input().split(\" \")))\nif(n[1]-n[2]>1):\n print(\"<<\" , end=\" \")\nfor i in range(1 , n[0]+1 ):\n if(i == n[1]):\n print(\"(\" ,i , end=\"\" , sep=\"\")\n if(i >= n[1]-n[2] and i<=n[1]+n[2] and i!= n[1]):\n print(i , end=\" \")\n if(i ==n[1]):\n print(\")\" , end=\" \")\nif(n[1]+n[2]<n[0]):\n print(\">>\")"}, {"source_code": "[n, p, k] = [int(i) for i in raw_input().split()]\n\ndef makeString (n,p,k) :\n\tres = \"\"\n\tif p-k <= 1 :\n\t\tfor i in range (1, p):\n\t\t\tres = res + \"{} \".format(i)\n\telse :\n\t\tres = \"<< \"\n\t\tfor i in range ( p - k, p, 1):\n\t\t\tres = res + \"{} \".format(i)\n\tres += \"({}) \".format(p)\n\tif p+k >= n:\n\t\tfor i in range (p+1, n+1):\n\t\t\tres = res + \"{} \".format(i)\n\telse :\n\t\tfor i in range ( p+1, p+k+1,1):\n\t\t\tres = res + \"{} \".format(i)\n\t\tres += \">>\"\n\treturn res\n\nprint(makeString(n,p,k))"}, {"source_code": "n, p, k = map(int, raw_input().split())\npages = range(max(p - k, 1), min(p + k + 1, n + 1))\nif pages[0] > 1:\n\tprint '<<',\nfor pg in pages:\n\tif pg == p:\n\t\tprint ('(%d)' % pg),\n\telse:\n\t\tprint pg,\nif pages[-1] < n:\n\tprint '>>'\n"}, {"source_code": "n, p, k = map(int, input().split())\nif p - k > 1:\n\tprint(\"<<\", end = ' ')\nfor i in range(k, 0, -1):\n\tif p - i <= 0:\n\t\tcontinue\n\tprint(p - i, end = ' ')\nprint('(' + str(p) + ')', end = ' ')\nfor i in range(1, k + 1):\n\tif p + i > n:\n\t\tbreak\n\tprint(p + i, end = ' ')\nif p + k < n:\n\tprint(\">>\")"}, {"source_code": "n, p, k = input().split(' ')\nn,p,k = int(n), int(p), int(k)\n\npages = []\nfor i in range(p-k, p+k+1):\n\tif i > 0 and i <= n:\n\t\tpages.append(i)\n\nstring = ''\nif pages[0] != 1:\n\tstring+='<< '\nfor i in pages:\n\tif i == p:\n\t\tstring+= \"({0}) \".format(i)\n\telse:\n\t\tstring+= '{0} '.format(i)\n\nif pages[-1]!= n:\n\tstring+='>>'\n\nprint(string)\n\n"}, {"source_code": "a,b,c = map(int,input().split())\nx = []\nfor i in range(1,a+1):\n x.append(i)\nif max(b-c,1) != 1: print('<<', end = ' ')\nfor i in range(max(b-c-1,0),min(b+c,a)):\n if x[i] == b: print('('+str(x[i])+')', end = ' ')\n else: print(x[i], end = ' ')\nif min(b+c,a) != a: print('>>')"}, {"source_code": "#Codeforces Pages\ninp = input()\n\nx = list(inp.split(\" \"))\nn = int(x[0])\np = int(x[1])\nk = int(x[2])\n\nb = 1 if p-k<1 else p-k\ne = n if p+k>n else p+k\n\nif b !=1:\n print(\"<<\",end=\" \")\n \nfor i in range(b,e+1):\n if i==p:\n print(\"(\"+str(i)+\")\",end=\" \")\n else:\n print(i,end=\" \")\nif e !=n:\n print(\">>\",end=\"\")"}, {"source_code": "vals = [int(x) for x in raw_input().split()]\nn=vals[0]\np=vals[1]\nk=vals[2]\n\noutput = []\n\nif p-k>1:\n output.append(\"<<\")\n for i in range(k):\n output.append(str(p-k+i))\nelse:\n for i in range(1,p):\n output.append(str(i))\noutput.append('('+str(p)+')')\n\nif p+k<n:\n for i in range(k):\n output.append(str(p+i+1))\n output.append('>>')\nelse:\n for i in range(p,n):\n output.append(str(i+1))\n\nprint(' '.join(output))\n"}, {"source_code": "n,p,k = list(map(int,input().split()))\nfinal_list = [i for i in range(1,n+1)]\nif p-k > 1 and p+k<n:\n f = f'({final_list[p-1]})'\n print('<< ',*final_list[p-(k+1):p-1],f,*final_list[p:p+k],'>>')\nif p-k<=1 and p+k<n:\n f = f'({final_list[p-1]})'\n print(*final_list[:p-1],f,*final_list[p:p+k],'>>')\nif p-k>1 and p+k > n-1:\n f = f'({final_list[p-1]})'\n print('<< ',*final_list[p-(k+1):p-1],f,*final_list[p:n])\nif p-k<=1 and p+k >=n:\n f = f'({final_list[p-1]})'\n print(*final_list[:p-1],f,*final_list[p:n])"}, {"source_code": "s = raw_input()\nnumbers = map(int, s.split())\nn= numbers[0]\np= numbers[1]\nk= numbers[2]\ntowrite=[]\nif p-k>1:\n towrite.append(\"<<\")\n for poop in range(k):\n cool= p-(k-poop)\n towrite.append(str(cool))\nelif p-k==1:\n for poop in range (k):\n towrite.append(str(1+poop))\nelse:\n x=1\n while x!=p:\n towrite.append(str(x))\n x+=1\n \ntowrite.append(\"(\"+str(p)+\")\")\n\nif p+k<n:\n for poop in range(k):\n towrite.append(str(p+poop+1))\n towrite.append(\">>\")\nelse:\n poop=0\n while p+poop != n:\n poop+=1\n towrite.append(str(p+poop))\n\nprint \" \".join(towrite)\n"}, {"source_code": "# your code goes here\nn,p,k=[int(x) for x in raw_input().split()]\nif(p-k>1):print \"<<\",\nif(p-k>=1):i=p-k\nelse:i=1\nwhile(i<p):\n print \"%d\"%(i),\n i+=1\nprint (\"%s%d%s\")%(\"(\",p,\")\"),\nif(p+k<=n):j=p+k\nelse:j=n\ni+=1\nwhile(i<=j):\n print i,\n i+=1\nif(j<n):\n print\">>\""}, {"source_code": "n,p,k=[int(x) for x in raw_input().split()]\nl=range(max(1,p-k),min(n+1,p+k+1))\nmm=[]\nif l[0]!=1:\n\tmm.append('<<')\nfor i in l:\n\tif p==i:\n\t\tmm.append('('+str(p)+')')\n\telse:\n\t\tmm.append(str(i))\nif l[-1]!=n:\n\tmm.append('>>')\nprint ' '.join(mm)\n"}, {"source_code": "x=list(map(int,input().split()))\n\nn=x[0]\np=x[1]\nk=x[2]\n\nif(p-k>1):\n print(\"<<\",end=' ')\n\n\n\n\nfor i in range(k):\n if(p+i-k>0):\n print(p+i-k,end=' ')\n\nprint(\"(\",end='')\nprint(p,end='')\nprint(\")\",end=' ')\n\n\nfor i in range(1,k+1):\n if(p+i<=n):\n print(p+i,end=' ')\n \nif(p+k<n):\n print(\">>\",end=' ')"}, {"source_code": "n, p, k = map(int, input().split())\n\nif (p - k) > 1:\n print('<<', end=' ')\n\nfor i in range((p - k), p):\n if i > 0:\n print(i, end=' ')\n\nprint('({})'.format(p), end=' ')\n\nfor i in range(p + 1, p + k + 1):\n if i <= n:\n print(i, end=' ')\n\nif (p + k) < n:\n print('>>', end=' ')\n"}, {"source_code": "n, k, p = map(int, input().split())\ns = '(' + str(k) + ')'\nans = ''\n\nfor i in range (k-p,k+p+1):\n if i == k:\n ans += s+ ' '\n if i <= n and i != k and i > 0:\n ans += str(i) + ' '\nA = ans.split()\n#print(int(A[-1])==n , A[0]=='(1)')\nif A[-1] == s and int(A[0]) > 1 :\n print('<< ' + ' '.join(A))\nelif A[-1] == s and int(A[0]) == 1 :\n print(' '.join(A)) \nelif (A[0] == '(1)' or int(A[0]) == 1) and int(A[-1]) < n:\n print(' '.join(A) +' >>')\nelif int(A[-1]) == n and (A[0] == '(1)' or int(A[0]) == 1 ):\n print(' '.join(A))\nelif int(A[-1]) < n and int(A[0]) > 1:\n print('<< '+ ' '.join(A) + ' >>')\nelif int(A[-1]) == n and int(A[0]) > 1:\n print('<< ' + ' '.join(A))\n"}, {"source_code": "n, p, k = map(int, input().split())\nif p >= 1 or p <= n:\n if p-k > 1:\n print('<<', end=\" \")\n l = max(1, p-k)\n h = min(n, p+k)\n while l<=h:\n if l == p:\n print('('+str(p)+')', end=\" \")\n else:\n print(l, end=\" \")\n l += 1\n if p+k < n:\n print('>>', end=\" \")"}, {"source_code": "# A\n\n\ndef checkio(number, page, margin):\n str_ary = []\n\n left = page - margin\n if left < 1:\n left = 1\n # <<\n if left != 1:\n str_ary.append('<<')\n\n # left margin\n \n for i in range(left, page):\n str_ary.append(i)\n\n # (?)\n str_ary.append('(%d)'%page)\n\n #right margin\n right = page + margin\n if right > number:\n right = number\n for i in range(page+1, right+1):\n str_ary.append(i)\n\n # <<\n if right != number:\n str_ary.append('>>') \n\n return ' '.join(str(x) for x in str_ary)\n\n\nn,p,k = raw_input().split(' ')\n\nprint checkio(int(n), int(p), int(k))"}, {"source_code": "n,p,k=map(int,raw_input().split())\na=[]\nfor i in xrange(max(1,p-k),min(n,p+k)+1):\n\tif i==p:\n\t\ta+=['(%d)'%i]\n\telse:\n\t\ta+=[str(i)]\nif p-k>1:\n\ta=['<<']+a\nif p+k<n:\n\ta+=['>>']\nprint ' '.join(a)\n"}, {"source_code": "x,y,z=map(int,input().split())\nok=1\nko=1\nif 1>=y-z :\n ok=0\nif x<=y+z :\n ko=0\nif ok==1 :\n print(\"<<\",end=' ')\nfor i in range(max(1,y-z),min(x,y+z)+1) :\n if i == y :\n print('(',end='')\n print(i,end='')\n print(')',end=' ')\n else: \n print(i,end=' ')\nif ko == 1:\n print(\">>\")"}, {"source_code": "'''\nCreated on May 20, 2014\n\n@author: Ved\n\nCodeforces 399A\n'''\n\ndef main():\n n,p,k = map(int, raw_input().split())\n \n if p-k > 1:\n print \"<<\",\n \n i = max(1,p-k)\n while i <= n and i <= p+k:\n if i != p:\n print i,\n else:\n print \"(\"+str(i)+\")\",\n i+=1\n \n if p+k < n:\n print \">>\"\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "def addingSymbols(string, n, val):\n if len(string) != 0:\n if val == \"front\":\n if int(string.split(' ')[0]) == 1:\n return string\n elif int(string.split(' ')[0]) < 1:\n return \" \".join([str(i) for i in string.split(' ') if int(i) >= 1])\n else:\n return \"<< \" + string \n else:\n if int(string.split(' ')[-1]) == n:\n return string\n elif int(string.split(' ')[-1]) > n:\n return \" \".join([str(i) for i in string.split(' ') if int(i) <= n])\n else:\n return string + \" >>\"\n else:\n return string\n\ndef navigationPage(n, p, k, val):\n l = []\n if val == \"sub\":\n while k != 0:\n if p > 1:\n l.append(p-k)\n else:\n l = []\n k -=1\n else:\n while k != 0:\n if p <= n:\n l.append(p+k)\n else:\n l = []\n k -=1\n l.sort()\n return \" \".join([str(i) for i in l])\n\ndef calculateReq(n,p,k):\n prev_ = navigationPage(n, p, k, \"sub\") \n next_ = navigationPage(n, p, k, \"add\")\n prev_ = addingSymbols(prev_, n, \"front\")\n next_ = addingSymbols(next_, n, \"back\")\n answer = prev_ + \" (\" + str(p) + \") \" + next_\n return answer.strip()\n\nif __name__ == \"__main__\":\n n,p,k = map(int, input().split(' '))\n answer = calculateReq(n,p,k)\n print(answer)"}, {"source_code": "no_page, present_page, display_range = map(int, input().split())\nif(present_page - display_range <= 1):\n starting_page = 1\nelse:\n starting_page = present_page - display_range\nif(present_page + display_range >= no_page):\n ending_page = no_page\nelse:\n ending_page = present_page + display_range\nfor i in range(starting_page, ending_page + 1, +1):\n if(i == present_page):\n print(\"(\"+str(i)+\")\", end = \" \"),\n elif(i == 1):\n print(i, end = \" \"),\n elif(i == starting_page and starting_page > 1):\n print(\"<<\", i, end = \" \"),\n elif(i == ending_page and ending_page == no_page):\n print(i),\n elif(i == ending_page and ending_page != no_page):\n print(i, \">>\", end = \" \"),\n else:\n print(i, end = \" \"),"}, {"source_code": "n, p, k = map(int, input().split())\n\ns = ''\nl = p - k\nr = p + k\nif l > 1:\n s += '<< '\nelse:\n l = 1\nif r >= n:\n r = n\nfor i in range(l, r + 1):\n if i == p:\n s +='(' + str(p) + ') '\n else:\n s += str(i) + ' '\nif p + k < n:\n s += '>>'\nprint(s)"}, {"source_code": "total_count, current_page, border_value = [int(_) for _ in input().split()]\n\npages_to_show = ([str(_) for _ in range(current_page - border_value, current_page + border_value + 1)])\npages_to_show = ([str(x) for x in pages_to_show if int(x) > 0 and int(x) <= total_count])\n\nfor i in range(len(pages_to_show)):\n if pages_to_show[i] == str(current_page):\n pages_to_show[i] = f'({current_page})'\n break\n\nnav_bar = ' '.join(pages_to_show) \n\nif f\"{total_count}\" in nav_bar and ('1' in nav_bar.split() or \"(1)\" in nav_bar.split()):\n pass\nelif '1' in nav_bar.split() or \"(1)\" in nav_bar.split():\n nav_bar += \" >>\"\nelif f\"{total_count}\" in nav_bar:\n nav_bar = \"<< \" + nav_bar\nelse:\n nav_bar = \"<< \" + nav_bar + \" >>\"\n\nprint(nav_bar)\n"}, {"source_code": "_ = input().strip().split(' ')\nn = int(_[0])\np = int(_[1])\nk = int(_[2])\n# print(n, p, k)\ncnt = p - k\nif cnt < 1:\n while cnt < 1:\n cnt += 1\nif cnt != 1:\n print('<< ',end='')\nwhile cnt <= n and cnt <= (p + k):\n if cnt == p:\n print('(%d) '%cnt, end='')\n else:\n print(cnt, end=' ')\n cnt += 1\nif cnt-1 != n:\n print('>>')"}, {"source_code": "x=input()\ndef convert(x):\n\tlst=x.split(\" \")\n\treturn lst \ndata=convert(x)\nn=int(data[0])\np=int(data[1])\nk=int(data[2])\nnum=[]\nfor i in range(1,n+1):\t\n\tnum.append(i)\nres=[]\nr=[\">>\"]\nl=[\"<<\"]\nfor i in range(p-k,p+k+1):\n\tif i>0 and len(num)>=i:\n\t\tres.append(num[i-1])\nif res[0]==1 and res[len(res)-1]==n:\n\tans=listToStr = ' '.join([str(elem) for elem in res])\n\tan=ans.replace(str(p),(\"(\"+str(p)+\")\"),1)\nelif res[0]==1:\n\tans=listToStr = ' '.join([str(elem) for elem in (res+r)]) \n\tan=ans.replace(str(p),(\"(\"+str(p)+\")\"),1)\nelif res[len(res)-1]==n:\n\tans=listToStr = ' '.join([str(elem) for elem in (l+res)]) \n\tan=ans.replace(str(p),(\"(\"+str(p)+\")\"),1)\nelse:\n\tans=listToStr = ' '.join([str(elem) for elem in (l+res+r)]) \n\tan=ans.replace(str(p),(\"(\"+str(p)+\")\"),1)\nprint(an)\n"}, {"source_code": "inputs = input().split(\" \")\nran,base,limit = int(inputs[0]),int(inputs[1]),int(inputs[2])\nif((base - limit) > 0):\n start = base - limit\nelse:\n start = 1\nif((base + limit) > ran):\n finish = ran + 1\nelse:\n finish = base + limit +1\noutput = \"\"\nif(start is not 1):\n output+=\"<< \"\nfor i in range(start, finish):\n if(i == base):\n output+=\"(\"+str(base)+\") \" \n else:\n output+=str(i)+\" \"\nif(ran > (finish-1)):\n output+=\">>\"\nprint(output)\n#print(inputs, len(inputs))\n"}, {"source_code": "n,p,k=[int(x) for x in input().split()]\nL=[]\nL.append(\"(\"+str(p)+\")\")\ni=1\nwhile (p-i>=1) and (i<=k):\n L.insert(0,(str(p-i)))\n i=i+1\nif p-i+1!=1:\n L.insert(0,\"<<\")\n\nj=1\nwhile (p+j<=n) and (j<=k):\n L.append(str(p+j))\n j=j+1\nif p+j-1!=n:\n L.append(\">>\")\nfor i in range (len(L)-1):\n print(L[i],end=\" \")\nprint(L[len(L)-1])"}, {"source_code": "def printNav(n, p, k):\n if(p - k > 1):\n print(\"<<\", end = ' ')\n for i in range(p - k, p + k + 1):\n if(i > 0 and i <= n):\n if(i == p):\n print(\"(\", i, \")\",sep = '', end = ' ')\n continue\n print(i, end = ' ')\n if(p + k < n):\n print(\">>\")\n\nn, p, k = map(int, input().split())\nprintNav(n, p, k)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Dec 3 11:21:28 2019\n\n@author: CronuS\n\"\"\"\n\ns = list(map(int, input().split()))\nn = s[0]; p = s[1]; k = s[2]\ns = '(' + str(p) + ')'\nfor i in range(min(k, p - 1)):\n s = str(p - 1 - i) + ' ' + s\nfor i in range(min(k, n - p)):\n s = s + ' ' + str(p + 1 + i)\nif (p - 1 > k):\n s = '<< ' + s\nif (n - p > k):\n s = s + ' >>'\nprint(s)"}, {"source_code": "n, p, k = map(int, input().split())\n\nans = \"\"\n\nif max(p-k, 1) > 1:\n\tans = ans + \"<< \"\n\nfor i in range(max(p-k, 1), min(p+k, n) + 1):\n\tif i == p:\n\t\tans = ans + \"(\" + str(i) + \") \"\n\telse:\n\t\tans = ans + str(i) + \" \"\n\nif min(p+k, n) < n:\n\tans = ans + \">> \"\n\nprint(ans)\n\n#8 5 4\n\n"}, {"source_code": "n,p,k=input().split()\nn,p,k=int(n),int(p),int(k)\nif(p-k>1):\n print('<<',end=' ')\n p1=p-k\nelse:\n p1=1\nq=min(n,p+k)\nwhile(p1<=q):\n if(p1==p):\n print('(',p,')',sep='',end=' ')\n else:\n print(p1,end=' ')\n p1+=1\nif(q<n):\n print('>>',end='')"}, {"source_code": "def print_navigation(start,p,end):\n\tstring=''\n\tif p==start:\n\t\t#print('start')\n\t\tprint('('+str(p)+')',end=' ')\n\t\tfor i in list(range(p+1,end+1)):\n\t\t\t#print(i,end=' ')\n\t\t\tstring=' '.join([string,str(i)])\n\t\tprint(string[1:],end='')\n\t\t\t\n\telse:\t\n\t\tfor i in list(range(start,p)):\n\t\t\tprint(i,end=' ')\n\t\tprint('('+str(p)+')',end='')\n\t\tfor i in list(range(p+1,end+1)):\n\t\t\t#print(i,end=' ')\n\t\t\tstring=' '.join([string,str(i)])\n\t\tprint(string,end='')\n\n#print_navigation(2,4,8)\n\ndef generate_pattern(n,p,k):\n\tif(p-k)>1 and (p+k)<n :\n\t\tprint('<<',end=' ')\n\t\tstart=p-k\n\t\tend=p+k\n\t\tprint_navigation(start,p,end)\n\t\tprint(' >>')\n\t\t\n\telif (p-k)<=1 :\n\t\t#print(1,end=' ')\n\t\tif(p+k)<n:\n\t\t\tstart=1\n\t\t\tend=p+k\n\t\t\tprint_navigation(start,p,end)\n\t\t\tprint(' >>')\n\t\telse:\n\t\t\tstart=1\n\t\t\tend=n\n\t\t\tprint_navigation(start,p,end)\n\t\t\t\n\telse:\n\t\tprint('<<',end=' ')\n\t\tstart=p-k\n\t\tend=n\n\t\tprint_navigation(start,p,end)\n\t\t\ninput_list=list(map(int,input().split(' ')))\nn=input_list[0]\np=input_list[1]\nk=input_list[2]\ngenerate_pattern(n,p,k)"}, {"source_code": "n,p,k=map(int,input().split())\n\ns=p-k\ne=p+k\n\nif s<1:\n s=1\nif e>n:\n e=n\n\nif s!=1:\n print('<<',end=' ',sep=' ')\n\nfor x in range(s,e+1):\n if p==x:\n print('('+str(p)+')',end=' ',sep=' ')\n continue\n print(x,end=' ',sep=' ')\n\nif e!=n:\n print('>>',end=' ',sep=' ')\n"}, {"source_code": "def myint(a):\n if a[0]==\"(\":\n a=a[1:-1]\n return int(a)\nn,p,k = map(int, input().split())\nls=[\"(\"+str(p)+\")\"]\nfor i in range(1,k+1):\n if p+i<=n:\n ls.append(str(p+i))\nstart = p-k\nif start<1: start=1\nfor i, x in enumerate(range(start,p)):\n ls.insert(i, str(x))\n\nif myint(ls[0])>1:\n ls.insert(0,\"<<\")\nif myint(ls[len(ls)-1])<n: \n ls.append(\">>\")\nprint(\" \".join(ls))"}, {"source_code": "n, p, k = map(int, input().split())\nif p - k > 1:\n print(\"<<\", end = ' ')\nfor i in range(max(1, p - k), min(p + k + 1, n + 1)):\n if i == p:\n print(\"(\", i, \")\", sep = '', end = ' ')\n else:\n print(i, end = ' ')\nif p + k < n:\n print(\">>\")"}, {"source_code": "a = list(map(int,input().split()))\npages,current,wide = a[0],a[1],a[2]\nmid = '('+str(current)+')'\nstart,end= current-wide,current+wide\nprefix,suffix = '',''\nif start < 2:\n prefix = (\" \".join([str(i) for i in range(1,current)])).rstrip()\nelse:\n prefix = (\"<< \" +\" \".join([str(i) for i in range(start,current)])).rstrip()\nif end >= pages:\n suffix = (\" \".join([str(i) for i in range(current+1,pages+1)])).rstrip()\nelse:\n suffix = (\" \".join([str(i) for i in range(current+1,end+1)])+\" >>\").rstrip()\nif prefix == '' and suffix=='':\n print(mid)\nelif prefix == '':\n print(mid,suffix)\nelif suffix == '':\n print(prefix,mid)\nelse:\n print(prefix,mid,suffix)"}, {"source_code": "n, p, k = map(int, input().split())\n\nif p == 1:\n if p + k <= n:\n print('(1)', end=\" \")\n for i in range(1, k + 1):\n if (i + 1 <= n):\n print(i + 1, end=\" \")\n if (p + k < n):\n print('>>')\n else:\n print('(1)', end=\" \")\n for i in range(1, n):\n if (i + 1 <= n):\n print(i + 1, end=\" \")\nelif p == n:\n if (p - k > 1):\n print('<<', end=\" \")\n for i in range(p - k, p):\n if (i >= 1):\n print(i, end=\" \")\n print('(', n, ')', sep=\"\") \nelse:\n if (p - k > 1):\n print('<<', end=\" \")\n for i in range(p - k, p):\n if (i >= 1):\n print(i, end=\" \")\n print('(', p, ')', sep=\"\", end=\" \")\n for i in range(p, p + k):\n if (i + 1 <= n):\n print(i + 1, end=\" \")\n if (p + k < n):\n print('>>')\n"}, {"source_code": "n, p, k = map(int, input().split())\n\nif (p - k > 1) and (p + k < n):\n print(\"<< \", end=\"\")\n for c in range(p - k, p + k + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n print(\">>\")\nelif (p - k <= 1) and (p + k >= n): \n for c in range(1, n + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\nelif p + k >= n:\n print(\"<< \", end=\"\")\n for c in range(p - k, n + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\nelse:\n for c in range(1, p + k + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n print(\">>\") \n\n\n"}, {"source_code": "def solve():\n n, p, k = map(int, input().split())\n pages = range(1, n + 1)\n result = []\n if p - k > 1:\n result.append('<<')\n\n if p - 1 - k > 0:\n left_side = p - 1 - k\n else:\n left_side = 0\n result.extend(pages[left_side:p - 1])\n result.append('({})'.format(pages[p - 1]))\n result.extend(pages[p:p + k])\n\n if p + k < n:\n result.append('>>')\n\n print(' '.join(map(str, result)))\n\n\nsolve()\n"}, {"source_code": "n,p,k = map(int,input().split())\nif((p-k)>1):\n print(\"<<\",end=\" \")\nfor i in range(p-k,p+k+1):\n if(i<1) or (i>n):\n continue\n elif(i==p):\n print(\"(\" + str(i) + \")\",end=\" \")\n else:\n print(str(i),end=\" \")\nif((p+k)<n):\n print(\">>\")"}, {"source_code": "# http://codeforces.com/problemset/problem/399/A\n\nimport sys\n\n\ndef main():\n n, p, k = [int(v) for v in sys.stdin.readline().split()]\n s = []\n if p - k > 1:\n s.append('<<')\n for i in range(p - k, p + k + 1):\n if i >= 1 and i <= n:\n if i == p:\n s.append('(' + str(i) + ')')\n else:\n s.append(str(i))\n if p + k < n:\n s.append('>>')\n\n print(' '.join(s))\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n,p,k=map(int,raw_input().split())\ns=[]\nif p-k>1:\n s+=['<<']\nfor i in range(max(1,p-k),min(n,p+k)+1):\n s+=[str(i) if i!=p else '('+str(i)+')']\nif p+k<n:\n s+=['>>']\nprint ' '.join(s)\n"}, {"source_code": "n,p,k = map(int,raw_input().split())\n\nl = [x for x in range(p-k,p+k+1) if x>0 and x<=n]\nif l[0]>1: l.insert(0,'<<')\nif l[-1] < n: l.append('>>')\nl[l.index(p)] = '(' + str(p) + ')'\n\n\nprint ' '.join(map(str, l))"}, {"source_code": "(n,p,k)=map(eval,raw_input().split())\ns = ''\nif max(1,p-k)>1:\n s='<< '+s\nfor i in range(max(1,p-k),min(n,p+k)+1,1):\n if i != p :\n s=s+str(i)\n else :\n s=s+'('+str(i)+')'\n if i != min(n,p+k):\n s=s+' '\nif min(n,p+k)<n:\n s=s+' >>'\nprint s"}, {"source_code": "N, P, K = [int(s) for s in raw_input().split()]\n\nif P - K > 1:\n\tprint \"<<\",\nfor i in range(max(P - K, 1), P):\n\tprint i,\nprint (\"(%d)\" % P),\nfor i in range(P + 1, min(P + K, N) + 1):\n\tprint i,\nif P + K < N:\n\tprint \">>\"\n"}, {"source_code": "pages,curpage,nav= [int(x) for x in input().split(' ')]\nanswer=f'({curpage})'\nfor i in range(1,nav+1):\n if curpage - i > 0:\n answer =f'{curpage-i} {answer}'\n if curpage + i <=pages:\n answer=f'{answer} {curpage+i}'\nif curpage-nav > 1:\n answer = f'<< {answer}'\nif curpage+nav < pages:\n answer = f'{answer} >>'\nprint(answer)"}, {"source_code": "x=input()\nxx=x.split( )\nn=int(xx[0])\np=int(xx[1])\nk=int(xx[2])\nif p-k<=1:\n kk=p-1\n while kk!=0:\n print(p-kk,end=' ')\n kk-=1\nelse:\n kk=k\n print('<<',end=' ')\n while kk!=0:\n print(p-kk,end=' ')\n kk-=1\nprint('(',end='')\nprint(p,end='')\nprint(')',end=' ')\n \nif p+k>=n:\n kk=n-p\n for i in range(1,kk+1):\n print(p+i,end=' ')\nelse:\n kk=k\n for i in range(1,kk+1):\n print(p+i,end=' ')\n print('>>')\n"}, {"source_code": "n, p, k = map(int, raw_input().split())\narr = sorted(list(set([i for i in range(max(1,p-k),min(n+1,p+k+1))])))\ns=''\nif max(p-k,1) != 1:\n s += \"<< \"\nfor i in arr:\n if i < 1:\n arr.remove(i)\n if i > n:\n arr.remove(i)\nind = arr.index(p)\narr[ind] = \"(\" + str(arr[ind]) + \")\"\ns += ' '.join(str(i)for i in arr)\nif min(p+k,n)!= n:\n s += \" >>\"\nprint s"}, {"source_code": "# Author: peihong\n\ndef solve(n, p, k):\n return [x for x in range(max(1,p-k), min(p+k,n)+1)]\n\nif __name__ == '__main__':\n n, p, k = map(int, raw_input().split())\n\n pages = solve(n, p, k)\n\n left = ''\n right = ''\n if not 1 in pages:\n print '<<',\n\n for x in pages:\n if x == p:\n print '(%d)' % x,\n else:\n print x,\n \n if not n in pages:\n print '>>'\n"}, {"source_code": "n, p, k = map(int, raw_input().split())\n\nl = max(p-k, 1)\nr = min(p + k, n)\n\n\nif l != 1:\n\tprint('<<'),\nfor i in range(l, p):\n\tprint (i),\nprint('(%d)' % p),\nfor i in range(p+1, r+1):\n\tprint(i),\nif r != n:\n\tprint('>>'),\n\n"}, {"source_code": "nums = input().split(' ')\nn, p, k = [int(i) for i in nums]\n\nfront = last = ''\nif p - k > 1:\n front = '<< '\nif p + k < n:\n last = ' >>'\n\nf, l = [], []\nfor i in range(max(1, p - k), p):\n f.append(str(i))\nfor i in range(p + 1, 1 + min(n, p + k)):\n l.append(str(i))\nres = front + ' '.join(f + ['(' + str(p) + ')'] + l) + last\nprint(res)\n# class Solution(object):\n# def countSquares(self, matrix):\n# \"\"\"\n# :type matrix: List[List[int]]\n# :rtype: int\n# \"\"\"\n# res = 0\n# row, col = len(matrix), len(matrix[0])\n# for i in range(1, row):\n# for j in range(1, col):\n# if matrix[i][j] != 0:\n# matrix[i][j] += min(matrix[i - 1][j - 1], matrix[i][j - 1], matrix[i - 1][j])\n# # if matrix[i - 1][j - 1] and matrix[i][j - 1] and matrix[i - 1][j]:\n# # res += 1\n# for i in range(row):\n# for j in range(col):\n# if matrix[i][j]:\n# res += matrix[i][j]\n# print(matrix)\n# return res\n \n \n\n# matrix = [\n# [0,1,1,1],\n# [1,1,1,1],\n# [0,1,1,1]\n# ]\n\n# a = Solution().countSquares(matrix)\n# print(a)"}, {"source_code": "n,p,k = map(int,input().split())\nif p-k>1:\n print('<<',end = ' ')\nfor i in range(max(1,p-k),min(n,p+k)+1):\n if i == p:\n print('('+str(p)+')',end = ' ')\n else:\n print(i,end = ' ')\nif n >p+k:\n print('>>')"}, {"source_code": "[n,p,k] = [int(x) for x in raw_input().split()]\n\npages = range(1,n+1)\nfwd,rev = True, True\nif p+k >= n:\n fwd = False\nif p-k <= 1:\n rev = False\nstri = \"\"\nif rev == True:\n stri = stri+\"<< \"\nfor i in range(k):\n if p-(k-i)<1:\n continue\n else:\n stri = stri+str(p-(k-i))+\" \"\nstri = stri+\"(\"+str(p)+\")\"\nfor i in range(k):\n if p+i+1 >n:\n continue\n else:\n stri = stri+\" \"+str(p+i+1)\nif fwd == True:\n stri=stri+\" >>\"\nprint stri\n"}, {"source_code": "n,p,k = map(int,input().split())\n\nif p-k>1:\n print (\"<<\",end = \" \")\n\nfor i in range(p-k,p):\n if i<=0: \n continue\n print(i,end = \" \")\n\nprint (\"(\",end = \"\")\nprint (p,end = \"\")\nprint (\")\",end = \" \")\n\nfor i in range(p+1,p+k+1):\n if i>n:\n continue\n print (i,end = \" \")\n\nif p+k<n:\n print (\">>\",end = \" \")"}, {"source_code": "n, p, k = map(int, input().split())\nm = [i + 1 for i in range(n)]\nif p - k > 1:\n print('<<', end=' ')\nfor i in range(max(0, p - k - 1), min(p + k, n)):\n if i + 1 == p:\n print(f'({i + 1})', end=' ')\n else:\n print(i + 1, end=' ')\nif p + k < n:\n print('>>')\n"}, {"source_code": "x = raw_input()\nx = x.split(' ')\npages = int(x[0])\npage = int(x[1])\nexcess = int(x[2])\nanswer = ''\nif page - excess > 1:\n answer += '<< '\n if page + excess <= pages:\n total = 2*excess + 1\n for count in range(total):\n if page == page-excess+count:\n answer += '('\n answer += str(page-excess+count)\n if page == page-excess+count:\n answer += ')'\n answer += ' '\n if page + excess != pages:\n answer += '>>'\n else:\n for count in range(page-excess, pages+1):\n if page == count:\n answer += '('\n answer += str(count)\n if page == count:\n answer += ')'\n answer += ' '\nelse:\n if page + excess <= pages:\n for count in range(page + excess):\n if page == count+1:\n answer += '('\n answer += str(count+1)\n if page == count+1:\n answer += ')'\n answer += ' '\n if page + excess != pages:\n answer += '>>'\n else:\n for count in range(pages):\n if page == count+1:\n answer += '('\n answer += str(count+1)\n if page == count+1:\n answer += ')'\n answer += ' '\nprint answer\n\n\n\n"}, {"source_code": "a,b,k = map(int,input().split(\" \"))\nflag1 = True\nflag2 = True\nif b-k > 1:\n print(\"<<\",end=\" \")\n \nfor i in range(b-k,b+k+1):\n if i > a:\n break\n if i > 0:\n if i == b:\n print(\"(\"+str(i)+\")\",end=\" \")\n else:\n print(i,end=\" \")\n \n\nif b+k < a:\n print(\">>\")\n \n"}, {"source_code": "n, p, k = map(int, input().split())\n\nstart = max(p - k, 1)\nend = min(p + k, n)\n\nif start > 1:\n print(\"<<\", end=' ')\nfor i in range(start, p):\n print(i, end=' ')\nprint(f\"({p})\", end=' ')\n\nfor i in range(p + 1, end + 1):\n print(i, end=' ')\n\nif end < n:\n print(\">>\")\n"}, {"source_code": "Max,This,Range = map(int, input().split(' '))\n\nResult = ''\n\nMinRange = This - Range\n\nif This - Range > 1:\n Result += '<< '\nelse:\n MinRange = 1 \n\nMaxRange = This + Range\n\nif This + Range > Max:\n MaxRange = Max\n\nMinMaxRange = This - 1\nMaxMinRange = This + 1\n\nif MinMaxRange >= MinRange:\n for i in range(MinRange,MinMaxRange+1):\n Result += str(i) + ' '\n\nResult += '(' + str(This) + ')'\n\nif MaxMinRange <= MaxRange:\n Result += ' '\n for i in range(MaxMinRange,MaxRange+1):\n Result += str(i) + ' '\n Result = Result[:-1]\n\nif This + Range < Max:\n Result += ' >>'\n\nprint(Result)\n"}], "negative_code": [{"source_code": "s=input()\nl=list(s.split(' '))\nn=int(l[0])\np=int(l[1])\nk=int(l[2])\nif p-k==1 and p+k<n:\n j=k\n while(j):\n if p-j>=1:\n print(str(p-(j))+\" \",end=\"\")\n j=j-1\n else:\n break\n print(\"(\"+str(p)+\") \",end=\"\")\n for i in range(k):\n if p+(i+1)<=n:\n print(str(p+(i+1))+\" \",end=\"\")\n else:\n break\n print(\">>\")\nelif p-k>1 and p+k==n:\n print(\"<< \",end=\"\")\n j=k\n while(j):\n if p-j>=1:\n print(str(p-(j))+\" \",end=\"\")\n j=j-1\n else:\n break\n print(\"(\"+str(p)+\") \",end=\"\")\n for i in range(k):\n if p+(i+1)<=n:\n print(str(p+(i+1))+\" \",end=\"\")\n else:\n break\nelif p-k>1 and p+k<n:\n print(\"<< \",end=\"\")\n j=k\n while(j):\n if p-j>=1:\n print(str(p-(j))+\" \",end=\"\")\n j=j-1\n else:\n break\n print(\"(\"+str(p)+\") \",end=\"\")\n for i in range(k):\n if p+(i+1)<=n:\n print(str(p+(i+1))+\" \",end=\"\")\n else:\n break\n print(\">>\")\nelif p-k>1 and p+k>n:\n print(\"<< \",end=\"\")\n j=k\n while(j):\n if p-j>=1:\n print(str(p-(j))+\" \",end=\"\")\n j=j-1\n else:\n break\n print(\"(\"+str(p)+\") \",end=\"\")\n for i in range(k):\n if p+(i+1)<=n:\n print(str(p+(i+1))+\" \",end=\"\")\n else:\n break\nelif p-k==1 and p+k>n:\n j=k\n while(j):\n if p-j>=1:\n print(str(p-(j))+\" \",end=\"\")\n j=j-1\n else:\n break\n print(\"(\"+str(p)+\") \",end=\"\")\n for i in range(k):\n if p+(i+1)<=n:\n print(str(p+(i+1))+\" \",end=\"\")\n else:\n break\nelif p-k<1 and p+k>=n:\n j=k\n while(j):\n if p-j>=1:\n print(str(p-(j))+\" \",end=\"\")\n j=j-1\n else:\n j=j-1\n print(\"(\"+str(p)+\") \",end=\"\")\n for i in range(k):\n if p+(i+1)<=n:\n print(str(p+(i+1))+\" \",end=\"\")\n else:\n break\nelif p-k<1 and p+k<n:\n j=k\n while(j):\n if p-j>=1:\n print(str(p-(j))+\" \",end=\"\")\n j=j-1\n else:\n j=j-1\n print(\"(\"+str(p)+\") \",end=\"\")\n for i in range(k):\n if p+(i+1)<=n:\n print(str(p+(i+1))+\" \",end=\"\")\n else:\n break\n print(\">>\")\n\nelse:\n pass\n\n\n \n \n"}, {"source_code": "n,p,k=map(int,input().split())\n\nl=[]\n\nstart=p-k\nstop=p+k\n\nif start<=0:\n start=1\nif stop>n:\n stop=n\n\nl.append(\"<<\")\n\nfor i in range(start,stop+1):\n if i==p:\n l.append(\"(\"+str(i)+\")\")\n else:\n l.append(i)\n\nl.append(\">>\")\n\nstr_a = \"(1)\"\nstr_b = \"(\"+str(n)+\")\"\nif 1 in l and n in l:\n l.pop()\n l.pop(0)\nelif 1 in l or str_a in l:\n l.pop(0)\nelif n in l or str_b in l:\n l.pop()\nfor i in l:\n print(i,end=' ')\n \n \n"}, {"source_code": "def main():\n x: list = list(map(int, input().split()))\n n: int = x[0]\n p: int = x[1]\n k: int = x[2]\n tmp: list = list()\n if p is not 1:\n print('<<', end=' ')\n\n for i in range(k+1):\n x: int = p - i\n if x is p:\n tmp.append('(' + str(x) + ')')\n else:\n tmp.append(str(x))\n\n tmp.reverse()\n print(' '.join(tmp), end=' ')\n tmp.clear()\n\n for i in range(k+1):\n x: int = p + i\n if x is p:\n continue\n else:\n tmp.append(str(x))\n\n print(' '.join(tmp), end=' ')\n\n if p is not n:\n print('>>')\n\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "inputs = input().split(\" \")\nran,base,limit = int(inputs[0]),int(inputs[1]),int(inputs[2])\nif((base - limit) > 0):\n start = base - limit\nelse:\n start = 1\nif((base + limit) > ran):\n finish = ran + 1\nelse:\n finish = base + limit +1\noutput = \"\"\nif(start is not base):\n output+=\"<< \"\nfor i in range(start, finish):\n if(i == base):\n output+=\"(\"+str(base)+\")\" \n else:\n output+=\" \"+str(i)+\" \"\nif(ran > (finish-1)):\n output+=\" >>\"\nprint(output)\n#print(inputs, len(inputs))\n"}, {"source_code": "a, b, c = map(int, input().split(\" \"))\n# a \u2192 limit b\u2192now c \u2192 range\n\n\nll = max(1, b-c)\nrl = min(a, b + c )\n\n\nleft = [i for i in range(b - 1, ll-1, -1)]\nright = [i for i in range(b + 1, rl + 1)]\nprint(right)\nl_bar = \"<< \"\nif ll == 1:\n l_bar = \"\"\n\nr_bar = \" >>\"\nif rl == a:\n r_bar = \"\"\nleft.reverse()\n\n\nprint(l_bar, *(left), \"({})\".format(b), *(right), r_bar)\n\n"}, {"source_code": "n, p, k = map(int, input().split())\nz = 1\npages = \"\"\nif(p != 1 and (p-k) != 0):\n pages += \"<< \"\nif(k<=p):\n for x in range (k):\n if(p-k+x == 0):\n continue\n pages += str(p-k+x) + \" \"\npages += \"(\" + str(p) + \") \"\nwhile(z <= k and (p+z)<=n):\n pages += str(p+z) + \" \"\n z+=1\n\nif((p+z-1) != n):\n pages += \">>\"\nprint(pages)"}, {"source_code": "output=''\nn, p , k = input().split()\nn = int(n)\np=int(p)\nk = int(k)\nfor i in range(p-k,p+k+1):\n if i <=0:\n pass\n elif i == p:\n output+= '(' + str(i) + ') '\n else:\n output+= str(i) + ' '\nif output[0]!= '1':\n output = '<< ' + output\nif output[-1] != n:\n output = output + '>>'\nprint(output)"}, {"source_code": "n,p,k=map(int,(input().split()))\nif p-k>=1:\n\tprint(\"<<\",end=\"\")\nfor i in range(p-k,p+k+1):\n\tif i==0:\n\t\tcontinue\n\tif i==p:\n\t\tprint(f\"({i})\",end=\" \")\n\telse:\n\t\tif i==p+k:\n\t\t\tprint(i,end=\"\")\n\t\telse:\n\t\t\tprint(i,end=\" \")\nif p+k<n:\n\t\tprint(\">>\",end=\"\")"}, {"source_code": "output=''\nn, p , k = input().split()\nn = int(n)\np=int(p)\nk = int(k)\nfor i in range(p-k,p+k+1):\n if i <=0:\n pass\n elif i == p:\n output+= '(' + str(i) + ') '\n elif i == n:\n output+= str(i) + ' '\n break\n else:\n output+= str(i) + ' '\nif output[0:2]== '1 ' or output[0]== '(':\n pass\nelse:\n output = '<< ' + output\nif output[-2] == str(n) or output[-2] == ')':\n pass\nelse:\n output = output + '>>'\nprint(output)"}, {"source_code": "s=input()\nl=list(s.split(' '))\nn=int(l[0])\np=int(l[1])\nk=int(l[2])\nj=k\nl1=[]\nl1.append(\"<<\")\nwhile(j):\n if p-j>=1:\n l1.append(str(p-j))\n j=j-1\n else:\n j=j-1\nl1.append(\"(\"+str(p)+\")\")\nfor i in range(k):\n if p+(i+1)<=n:\n l1.append(str(p+(i+1)))\n else:\n break\nl1.append(\">>\")\nprint(l1)\nif '1' in l1:\n l1.remove('<<')\nif str(n) in l1:\n l1.remove('>>')\nfor i in l1:\n if i!='n':\n print(i,end=\" \")\n else:\n print(i)\n\n\n \n \n"}, {"source_code": "n,p,k=map(int,input().split())\ns=''\nif(p-k>1):\n s='<< '\nfor i in range(k):\n if(p-k+i>=1):\n s=s+str(p-k+i)+' ' \ns=s+'('+str(p)+')'+' '\nfor i in range(0,k):\n if((p+i+1)<=n):\n s=s+str(p+i+1)+' ' \n\nif(' '+str(n) not in s):\n s=s+'>>'\nprint(s)\n "}, {"source_code": "output=''\nn, p , k = input().split()\nn = int(n)\np=int(p)\nk = int(k)\nfor i in range(p-k,p+k):\n if i <=0:\n pass\n elif i == p:\n output+= '(' + str(i) + ') '\n else:\n output+= str(i) + ' '\nif output[0]!= '1':\n output = '<< ' + output\nif output[-2] != str(n):\n output = output + '>>'\nprint(output)"}, {"source_code": "#! /usr/bin/python\n\ndef sol():\n n, p, k = map(int, input().split())\n\n outstring = \"\"\n has_one = False\n has_n = False\n prefix = \"\"\n for i in range(p-k, p+k+1):\n if i == 1:\n has_one = True\n if i == n:\n has_n = True\n if i < 1 or i > p+k:\n continue\n else:\n if i == p:\n outstring += prefix + \"({})\".format(str(i))\n else:\n outstring += prefix + str(i)\n prefix = \" \"\n \n if not has_one:\n outstring = \"<< \" + outstring\n if not has_n:\n outstring += \" >>\"\n\n print(outstring)\n\nsol()"}, {"source_code": "n, p, k = input().split()\n\nn = int(n);p = int(p);k = int(k)\n\nleftP = []\nbefore = p-1\nwhile len(leftP) < k and before >= 1:\n leftP.insert(0, str(before))\n before -= 1\n\nrightP = []\nafter = p+1\nwhile len(rightP) < k and after <= n:\n rightP.append(str(after))\n after += 1\n\n\npages = [\"<< \", \" \".join(leftP) + \" (\"+str(p)+\") \" + \" \".join(rightP), \" >>\"]\n\n\nif len(leftP) > 0:\n if int(leftP[0]) <= 2 and k > 1:\n pages.pop(0)\nelse:\n pages.pop(0)\n\nif int(rightP[len(rightP)-1]) >= n:\n pages.pop()\n\nprint(\"\".join(pages))\n\n\n\n"}, {"source_code": "n, p, k = map(int, raw_input().split())\narr = list(set([p-k,p-k+1,p-1,p,p+1,p+k-1,p+k]))\n\nfor i in arr:\n if i < 1:\n arr.remove(i)\n if i > n:\n arr.remove(i)\ns = '<< '+ ' '.join(str(i)for i in arr)+' >>'\nif str(n) in s:\n s = s.replace(' >>','')\nif '1' in s:\n s = s.replace('<< ','')\ns = s.replace(str(p),'('+str(p)+')')\nprint s\n"}, {"source_code": "n,p,k=map(int,input().split())\nif k-p<1:\n print(\"<<\",end=\" \")\nfor i in range(max(1,p-k),p):\n print(i,end=\" \")\nprint(\"(\",p,\")\",end=\" \",sep=\"\")\nfor i in range(p+1,1+min(p+k,n)):\n print(i,end=\" \")\nif n>p+k:\n print(\">>\")\n"}, {"source_code": "'''\n using dictionary to print the count of number of nineteen you can make form the given string\n what's the catch here : ninteenninteen =2\n ninteeninteen = 2\ndef fun(s):\n bs = {'n': 3, 'i': 1, 'e': 3, 't': 1}\n d=dict()\n crr=100000\n for i in s:\n if i in d:\n d[i]+=1\n else :\n d[i]=1\n # print(bs, d)\n for i in bs :\n # print(i, d[i], bs[i])\n if i not in d:\n return 0\n if i != 'n':\n if d[i]==0 or d[i]/bs[i]==0 :\n return 0\n else :\n crr=min(crr,d[i]//bs[i])\n if 'n' in d:\n crr=min(crr, (d['n']-1)//2)\n return crr\n\n\nx=input()\nprint(fun(x))\n'''\n\n#n, p, k\ndef funny(n,p,k):\n if p-k>0 : \n front =list(range(p-k, p))\n else :\n front=list(range(1,p))\n #print(\"front : \", front)\n if p+k <= n : \n back=list(range(p+1,p+k+1))\n else :\n back=list(range(p+1,n+1))\n # print(\"back : \",back)\n #print(front+[p]+back)\n arr= front+[p]+back\n res=\"\"\n l=len(arr)\n for i in range(l):\n # print(res)\n if arr[i] == 1:\n if arr[i]==p:\n res+=(\"(\"+str(arr[i])+\")\")\n else :\n res+=str(arr[i])\n elif arr[i]==n:\n res+=str(arr[i])\n return res\n else :\n if i==0:\n res+=\"<< \"\n if arr[i]==p:\n if arr[i]!=n:\n res+=(\"(\"+str(arr[i])+\")\")\n else :\n res+=str(arr[i])\n else:\n res+=str(arr[i])\n if i==l-1:\n res+=\" >>\"\n if i!=l-1:\n res+=\" \"\n return res \n\nx=list(map(int, input().split()))\nprint(funny(x[0],x[1],x[2]))"}, {"source_code": "n, k, p = input().split()\npages = [str(i) for i in range(int(k) - int(p), int(k) + int(p) + 1) if 1 <= i <= int(n)]\noutput = ''.join(page + ' ' for page in pages)[:-1]\n\nif output[0] != '1':\n\toutput = '<< ' + output\n\nif output[-1] != n:\n\toutput += ' >>'\n\nk_index = output.index(k)\noutput = f'{output[:k_index]}({k}){output[k_index+len(k):]}'\nprint(output)"}, {"source_code": "def pages(n,p,k):\n output = \"\"\n if p-k > 1 :\n output += \"<< \"\n for i in range(0, p):\n if p-k+i <= n:\n if p-k+i == p:\n output += \"(\" + str(p-k+i) + \") \"\n else:\n output += str(p-k+i) + \" \"\n\n if p+k < n:\n output += \">>\"\n\n return output\n\nn,p,k = map(int, input().split())\nprint(pages(n, p, k))"}, {"source_code": "n, p, k= map(int,input().split())\n\nd = [\"\"]*(2*k+1)\nm=0\nfor i in range(-k,k+1):\n if i == 0:\n d[m]=\"(\"+str(p)+\")\"\n elif p+i <= n and p+i >= 1:\n d[m]= str(p+i)\n m = m+1\n\nif '' in d:\n d.remove('') \nprint(d) \ncheck = \"(\" + str(n) + \")\"\n\nif not \"1\" in d and not \"(1)\" in d:\n d.insert(0,\"<<\")\nif not str(n) in d and not check in d:\n d.insert(len(d),\">>\")\n\nprint(' '.join(d))"}, {"source_code": "n,p,k = [int(i) for i in input().split()]\ns = []\nc = 0\ns.append('<<')\nif p-k>1:\n b = p-k\nelse:\n b = 1\nif p+k<n:\n e = p+k\nelse:\n e = n\nfor i in range(b,e+1):\n if i==p:\n s.append('('+str(p)+')')\n else:\n s.append(i)\nif p+k<n:\n s.append('>>')\nprint(' '.join([str(i) for i in s]))\n"}, {"source_code": "n,p,k = map(int,input().split())\nprint(n,p,k)\nres = ''\nif p-k > 1:\n res += '<< '\n'''\nelif p-k == 1:\n res += '1 '\n#else:\n # res += '1 '\n '''\nfor i in range(p-k,p):\n if i > 0:\n res = res + str(i) + ' '\n #print(res)\nres += '('+str(p)+') '\nfor j in range(p+1,p+k+1):\n if j <= n:\n res += str(j) +' '\nif p+k < n:\n res += '>>'\n'''\nelif p+k >= n:\n res += str(n)\n'''\nif res[-1] == ' ':\n print(res[:-1])\nelse:\n print(res)\n"}, {"source_code": "n,p,k=map(int,input().split())\nch=\"\"\nif p+k<n and p-k>1:\n ch+=\"<< \"\n for i in range(p-k,p):\n ch+=str(i)+\" \"\n ch+=\"(\"+str(p)+\") \"\n for i in range(p+1,p+k+1):\n ch+=str(i)+\" \"\n ch+=\" >>\"\nelif p+k<n and p-k<=1:\n ch+=\"(\"+str(p)+\")\"\n for i in range(p+1,p+k+1):\n ch+=\" \"+str(i)\n ch+=\" >>\"\nelif p+k>=n and p-k>1:\n ch+=\"<< \"\n for i in range(p-k,p):\n ch+=str(i)+\" \"\n ch+=\"(\"+str(p)+\") \"\n for i in range(p+1,n+1):\n ch+=str(i)+\" \"\n \n \nelse:\n for i in range(1,p):\n ch+=str(i)+\" \"\n ch+=\"(\"+str(p)+\") \"\n for i in range(p+1,n+1):\n ch+=str(i)+\" \"\nprint(ch)"}, {"source_code": "\nx= input().split()\nn= int(x[0])\np= int(x[1])\nk= int(x[2])\n\nmax_limit=min(n, p+k)\nmin_limit= max(1, p-k)\nans=''\nfor i in range(min_limit, max_limit+1):\n ans= ans+ ' '+str(i)\nans= ans.replace(str(p), \"(\"+str(p)+\")\")\nif '1' not in ans:\n ans= '<<'+ans\nif str(n) not in ans:\n ans= ans+\" \"+'>>'\n\nprint(ans.lstrip())"}, {"source_code": "lineIn = map(int,raw_input().split())\n\n#number of total pages\nnum = lineIn[0]\n#current page displayed\ncurr = lineIn[1]\n#number of pages displayed\namp = lineIn[2]\n#create list of strings\nnumList = [str(i) for i in xrange(1,num+1)]\n#find index of current\nnewCurr = numList.index(str(curr))\n#add parenthesis to current\nnumList[newCurr] = '('+str(curr)+')'\n\n\n#if current is centered in shown portion\nif num/2 > amp and curr + amp < num and curr - amp > 1 :\n trimmedList = numList[(curr-(amp+1)):(curr+amp)]\n print \"<<\",(\" \".join(x for x in trimmedList)) ,\">>\"\n\n#right end case\nelif num - curr <= amp and curr - amp > 1:\n trimmedList = numList[(curr-(amp+1)):]\n print \"<<\",(\" \".join(x for x in trimmedList))\n\n\n#left end case\nelif curr - amp >= 1 and curr + amp < num :\n trimmedList = numList[:(curr + (amp))]\n print (\" \".join(x for x in trimmedList)), '>>'\n\nelse:\n print (\" \".join(x for x in numList))\n"}, {"source_code": "n, p, k = input().split()\n\nn = int(n);p = int(p);k = int(k)\n\nleftP = []\nbefore = p-1\nwhile len(leftP) < k and before >= 1:\n leftP.insert(0, str(before))\n before -= 1\n\nrightP = []\nafter = p+1\nwhile len(rightP) < k and after <= n:\n rightP.append(str(after))\n after += 1\n\n\npages = [\"<< \", \" \".join(leftP) + \" (\"+str(p)+\") \" + \" \".join(rightP), \" >>\"]\n\n\nif len(leftP) > 0:\n if len(leftP) <= k and int(leftP[0]) <= k:\n pages.pop(0)\nelse:\n pages.pop(0)\n\n\nif int(rightP[len(rightP)-1]) >= n:\n pages.pop()\n\n\n\nprint(\"\".join(pages))\n\n\n\n"}, {"source_code": "def solve():\n n, p, k = map(int, input().split())\n pages = range(1, n + 1)\n result = []\n if p - 1 - k > 1:\n result.append('<<')\n left_side = p - 1 - k\n left_side = left_side if left_side > 0 else 0\n result.extend(pages[left_side:p - 1])\n result.append('({})'.format(pages[p - 1]))\n result.extend(pages[p:p + k])\n if p + k < n:\n result.append('>>')\n\n print(' '.join(map(str, result)))"}, {"source_code": "n,p,k=map(int,(input().split()))\nif p-k>=1:\n\tprint(\"<<\",end=\" \")\nfor i in range(p-k,p+k+1):\n\tif i==0:\n\t\tcontinue\n\tif i==p:\n\t\tprint(f\"({i})\",end=\" \")\n\telse:\n\t\tif i>n:\n\t\t\tpass\n\t\tif i==p+k:\n\t\t\tprint(i,end=\" \")\n\t\telse:\n\t\t\tprint(i,end=\" \")\nif p+k<n:\n\t\tprint(\">>\",end=\"\")"}, {"source_code": "'''\n using dictionary to print the count of number of nineteen you can make form the given string\n what's the catch here : ninteenninteen =2\n ninteeninteen = 2\ndef fun(s):\n bs = {'n': 3, 'i': 1, 'e': 3, 't': 1}\n d=dict()\n crr=100000\n for i in s:\n if i in d:\n d[i]+=1\n else :\n d[i]=1\n # print(bs, d)\n for i in bs :\n # print(i, d[i], bs[i])\n if i not in d:\n return 0\n if i != 'n':\n if d[i]==0 or d[i]/bs[i]==0 :\n return 0\n else :\n crr=min(crr,d[i]//bs[i])\n if 'n' in d:\n crr=min(crr, (d['n']-1)//2)\n return crr\n\n\nx=input()\nprint(fun(x))\n'''\n\n#n, p, k\ndef funny(n,p,k):\n if p-k>0 : \n front =list(range(p-k, p))\n else :\n front=list(range(1,p))\n #print(\"front : \", front)\n if p+k <= n : \n back=list(range(p+1,p+k+1))\n else :\n back=list(range(p+1,n+1))\n # print(\"back : \",back)\n #print(front+[p]+back)\n arr= front+[p]+back\n res=\"\"\n l=len(arr)\n for i in range(l):\n # print(res)\n if arr[i] == 1:\n if arr[i]==p:\n res+=(\"(\"+str(arr[i])+\")\")\n else :\n res+=str(arr[i])\n elif arr[i]==n:\n res+=str(arr[i])\n return res\n else :\n if i==0:\n res+=\"<< \"\n res+=str(arr[i])\n if i==l-1:\n res+=\" >>\"\n if i!=l-1:\n res+=\" \"\n return res \n\nx=list(map(int, input().split()))\nprint(funny(x[0],x[1],x[2]))"}, {"source_code": "n,p,k=map(int,input().split())\nans=\"({}) \".format(p)\nfor i in range(max(p-k,1),p):ans=\"{} \".format(i)+ans\nfor i in range(p+1,min(n+1,p+k+1)):ans+=\"{} \".format(i)\nif p+k<=n :ans+=\">>\"\nif p-k>=1 :ans=\"<< \"+ans\nprint(ans)"}, {"source_code": "def solve(n, c, off):\n ans = '({})'.format(c)\n\n # go right\n tem_off = off\n counter = c+1\n while tem_off and counter <= n:\n ans += ' {}'.format(counter)\n counter += 1\n tem_off -= 1\n if n-c > off:\n ans += ' >>'\n \n # go left\n tem_off = off\n counter = c-1\n while tem_off and counter >= 1:\n ans = '{} '.format(counter) + ans\n counter -= 1\n tem_off -= 1\n\n if c-1 > off: ans = '<< ' + ans\n return ans.strip()\n\nif __name__ == '__main__':\n n,k,off = map(int,input().split(\" \"))\n solve(n,k,off)"}, {"source_code": "output=''\nn, p , k = input().split()\nn = int(n)\np=int(p)\nk = int(k)\nfor i in range(p-k,p+k+1):\n if i <=0:\n pass\n elif i == p:\n output+= '(' + str(i) + ') '\n else:\n output+= str(i) + ' '\nif output[0]!= '1':\n output = '<< ' + output\nif output[-1] != n:\n output = output + '>>'\nprint(output)"}, {"source_code": "n, p, k = map(int, input().split())\nif p < 1 or p > n:\n if p-k > 1:\n print('<<', end=\" \")\n l = max(1, p-k)\n h = min(n, p+k)\n while l<=h:\n if l == p:\n print('('+str(p)+')', end=\" \")\n else:\n print(l, end=\" \")\n l += 1\n if p+k < n:\n print('>> ')"}, {"source_code": "n, p, k = map(int, input().split())\n\npages = [str(i) for i in range(1, n+1)]\n\nleft = 0\nif p-k-1>=0:left=p-k-1\nelse:left=p-k\n\nres = [' '.join(pages[left:p-1]), '(' + str(p) + ')', ' '.join(pages[p:p+k])]\n\nif p-k-1>0: res.insert(0,'<<')\n\nif p+k<n: res.append('>>')\n\nprint(' '.join(res).strip())"}, {"source_code": "\nx= input().split()\nn= int(x[0])\np= int(x[1])\nk= int(x[2])\n\nmax_limit=min(n, p+k)\nmin_limit= max(1, p-k)\nans=''\nfor i in range(min_limit, max_limit+1):\n ans= ans+ ' '+str(i)\nans= ans.replace(str(p), \"(\"+str(p)+\")\")\nif '1' not in ans:\n ans= '<<'+ans\nprint(str(n))\nif str(n) not in ans:\n ans= ans+\" \"+'>>'\n\nprint(ans.lstrip())"}, {"source_code": "def solution(n, p, k):\n arr = []\n for i in range(1, n+1):\n arr.append(i)\n string = \"(\" +str(p) + \") \"\n\n #left side\n rotation = p-2\n steps = k\n string_left = \"\"\n while rotation >= 0 and steps > 0:\n string_left = str(arr[rotation]) + \" \" + string_left\n rotation -= 1\n steps -= 1\n string = string_left + string\n left_arr = string_left.split(\" \")\n if len(left_arr) > 0 and left_arr[0] != arr[0]:\n string = \"<< \" + string\n\n #right side\n rotation = p\n steps = k\n string_right = \"\"\n while rotation < n and steps > 0:\n string_right += str(arr[rotation]) + \" \"\n rotation += 1\n steps -= 1\n right_arr = string_right.split(\" \")\n if len(right_arr) > 0 and right_arr[-1] != arr[-1]:\n string_right += \">>\"\n string += string_right\n print(string)\n\narr = input().split(\" \")\nsolution(int(arr[0]), int(arr[1]), int(arr[2]))\n"}, {"source_code": "# A\n\n\ndef checkio(number, page, margin):\n str_ary = []\n\n # <<\n if page != 1:\n str_ary.append('<<')\n\n # left margin\n left = page - margin\n if left < 1:\n left = 1\n for i in range(left, page):\n str_ary.append(i)\n\n # (?)\n str_ary.append('(%d)'%page)\n\n #right margin\n right = page + margin\n if right > number:\n right = number\n for i in range(page+1, right+1):\n str_ary.append(i)\n\n # <<\n if page != number:\n str_ary.append('>>') \n\n return ' '.join(str(x) for x in str_ary)\n\n\nn,p,k = raw_input().split(' ')\n\nprint checkio(int(n), int(p), int(k))"}, {"source_code": "def task_399A(n, p, k):\n #\n ans = \"\"\n if p - k > 1:\n ans+=\"<< \"\n for i in range(p-k,p):\n ans+=str(i)\n ans+=\" \"\n else:\n for i in range(1,p):\n ans+=str(i)\n ans+=\" \"\n ans+=\"({:d}) \".format(p)\n if p + k <n:\n for i in range(p+1,p+k+1):\n ans+=str(i)\n ans+=\" \"\n ans += \">>\"\n else:\n for i in range(p+1,n):\n ans+=str(i)\n ans+=\" \"\n ans += str(n)\n return ans\n\nif __name__ == '__main__':\n n, p, k = map(int, input().split())\n print(task_399A(n,p,k))"}, {"source_code": "X = list(map(int, input().split()))\nPages = [str(i + 1) for i in range(X[0])]\nPages[X[1] - 1] = '(' + Pages[X[1] - 1] + ')'\nif X[-1] <= X[1] - X[-1]:\n print(\"<< \", end=\"\")\nprint(*Pages[max(0, X[1] - X[-1] - 1):min(X[0], X[1] + X[-1])], end=\" \")\nif X[1] < X[0] - X[-1]:\n print(\">>\")\n\n# Caption: God bless you General Soleimani\n\n# ---------Hard Revenge---------\n\n# ****** Rest in Peace ******\n"}, {"source_code": "n, p, k = input().split()\n\nn = int(n);p = int(p);k = int(k)\n\nleftP = []\nbefore = p-1\nwhile len(leftP) < k and before >= 1:\n leftP.insert(0, str(before))\n before -= 1\n\nrightP = []\nafter = p+1\nwhile len(rightP) < k and after <= n:\n rightP.append(str(after))\n after += 1\n\n\npages = [\"<< \", \" \".join(leftP) + \" (\"+str(p)+\") \" + \" \".join(rightP), \" >>\"]\n\n\nif len(leftP) > 0:\n if int(leftP[0]) <= 1:\n pages.pop(0)\nelse:\n pages.pop(0)\n\nif len(rightP) < 0:\n if int(rightP[len(rightP)-1]) >= n:\n pages.pop()\n\n\n\nprint(\"\".join(pages))\n\n\n\n"}, {"source_code": "n, p, k = map(int, input().split())\n\nif (p - k > 1) and (p + k < n):\n print(\"<< \", end=\"\")\n for c in range(p - k, p + k + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n print(\">>\")\nelif p - k <= 1:\n for c in range(1, p + k + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n print(\">>\") \nelif p + k >= n:\n print(\"<< \", end=\"\")\n for c in range(p - k, n + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\nelse:\n for c in range(1, n + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n\n\n"}, {"source_code": "def pages(n,p,k):\n output = \"\"\n if p-k > 1 :\n output += \"<< \"\n for i in range(0, p):\n if p-k+i <= n:\n if p-k+i == p:\n output += \"(\" + str(p-k+i) + \") \"\n else:\n output += str(p-k+i) + \" \"\n\n if p+k < n:\n output += \">>\"\n\n return output\n\nn,p,k = map(int, input().split())\nprint(pages(n, p, k))"}, {"source_code": "def solution(n, p, k):\n arr = []\n for i in range(1, n+1):\n arr.append(i)\n string = \"(\" +str(p) + \") \"\n\n #left side\n rotation = p-2\n steps = k\n string_left = \"\"\n while rotation >= 0 and steps > 0:\n string_left = str(arr[rotation]) + \" \" + string_left\n rotation -= 1\n steps -= 1\n string = string_left + string\n if string[0] != str(arr[0]) and string[0] != '(':\n string = \"<< \" + string\n\n #right side\n rotation = p\n steps = k\n string_right = \"\"\n while rotation < n and steps > 0:\n string_right += str(arr[rotation]) + \" \"\n rotation += 1\n steps -= 1\n if string_right[0] != str(arr[n-1]) and string_right[-1] != ')':\n string_right += \">>\"\n string += string_right\n print(string)\n\narr = input().split(\" \")\nsolution(int(arr[0]), int(arr[1]), int(arr[2]))\n"}, {"source_code": "def pages():\n values = input().split(\" \")\n n = int(values[0])\n p = int(values[1])\n k = int(values[2])\n\n ini = p-k\n fin = p+k\n if p-k <=0:\n ini = 1\n if p+k> n:\n fin = n\n \n pages = list(range(ini,fin+1))\n\n if 1 and n in pages:\n listOfPages = map(lambda x: '('+str(p)+')' if x == p else x, pages)\n print(*listOfPages)\n elif 1 in pages:\n listOfPages = map(lambda x: '('+str(p)+')' if x == p else x, pages)\n print(*listOfPages,'>>')\n elif n in pages:\n listOfPages = map(lambda x: '('+str(p)+')' if x == p else x, pages)\n print('<<',*listOfPages)\n elif p < 1 or p > n:\n print(' ')\n else:\n listOfPages = map(lambda x: '('+str(p)+')' if x == p else x, pages)\n print('<<',*listOfPages,'>>')\n\npages() \n"}, {"source_code": "n, p, k = map(int, input().split())\nz = 1\npages = \"\"\nif(p != 1 and (p-k) != 0):\n pages += \"<< \"\nif(k<=p):\n for x in range (k):\n if(p-k+x == 0):\n continue\n pages += str(p-k+x) + \" \"\npages += \"(\" + str(p) + \") \"\nwhile(z <= k and (p+z)<=n):\n pages += str(p+z) + \" \"\n z+=1\n\nif((p+z-1) != n):\n pages += \">>\"\nprint(pages)"}, {"source_code": "n, p, k = list(map(int, input().split()))\nres = \"\"\nif p-k > 1:\n res += \"<< \"\nif p-k >= 1 and k > 1:\n res += str(p-k)+\" \"\nif p-k+1 >= 1 and k > 2:\n res += str(p-k+1)+\" \"\nif p-1 >= 1:\n res += str(p-1)+\" \"\nif 1<=p and p<=n:\n res += \"(\"+str(p)+\")\"\nif p+1 <= n:\n res += \" \"+str(p+1)\nif p+k-1 <= n and k > 2:\n res += \" \"+str(p+k-1)\nif p+k <= n and k > 1:\n res += \" \"+str(p+k)\nif p+k < n:\n res += \" >>\"\nprint(res)\n \n"}, {"source_code": "def solution(n, p, k):\n arr = []\n for i in range(1, n+1):\n arr.append(i)\n string = \"(\" +str(p) + \") \"\n\n #left side\n rotation = p-2\n steps = k\n string_left = \"\"\n while rotation >= 0 and steps > 0:\n string_left = str(arr[rotation]) + \" \" + string_left\n rotation -= 1\n steps -= 1\n string = string_left + string\n if string[0] != str(arr[0]) and string[0] != '(':\n string = \"<< \" + string\n\n #right side\n rotation = p\n steps = k\n string_right = \"\"\n while rotation < n and steps > 0:\n string_right += str(arr[rotation]) + \" \"\n rotation += 1\n steps -= 1\n if string_right[0] != str(arr[n-1]) and string_right[-1] != ')':\n string_right += \">>\"\n string += string_right\n print(string)\n\narr = input().split(\" \")\nsolution(int(arr[0]), int(arr[1]), int(arr[2]))\n"}, {"source_code": "(n,p,k)=map(eval,raw_input().split())\ns = ''\nif max(1,p-k)>1:\n s='<< '+s\nfor i in range(max(1,p-k),min(n,p+k)+1,1):\n if i == p :\n s=s+str(i)\n else :\n s=s+'('+str(i)+')'\n if i != min(n,p+k):\n s=s+' '\nif min(n,p+k)<n:\n s=s+' >>',\nprint s"}, {"source_code": "n, p, k = map(int, input().split())\n\nif (p - k > 1) and (p + k < n):\n print(\"<< \", end=\"\")\n for c in range(p - k, p + k + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n print(\">>\")\nelif p - k <= 1:\n for c in range(1, p + k + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n print(\">>\") \nelif p + k >= n:\n print(\"<< \", end=\"\")\n for c in range(p - k, n + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\nelse:\n for c in range(1, n + 1):\n if c == p:\n print('(' + str(p) + ')', end=\" \")\n else:\n print(str(c) + \" \", end=\"\")\n\n\n"}, {"source_code": "lineIn = map(int,raw_input().split())\n\n#number of total pages\nnum = lineIn[0]\n#current page displayed\ncurr = lineIn[1]\n#number of pages displayed\namp = lineIn[2]\n\nnumList = [i for i in xrange(1,num+1)]\n\nif num/2 > amp and curr + amp < num and curr - amp > 1 :\n print \"<<\", numList[(curr-(amp+1)):(curr+amp)],\">>\"\n"}, {"source_code": "n, p, k = map(int, input().split())\n\npages = [str(i) for i in range(1, n+1)]\n\nleft = 0\nif p-k-1>=0:left=p-k-1\nelse:left=p-k\n\nres = [' '.join(pages[left:p-1]), '(' + str(p) + ')', ' '.join(pages[p:p+k])]\n\nif p-k-1>0: res.insert(0,'<<')\n\nif p+k<n: res.append('>>')\n\nprint(' '.join(res).strip())"}, {"source_code": "def addingSymbols(string, n, val):\n if len(string) != 0:\n if val == \"front\":\n if int(string.split(' ')[0]) == 1:\n return string\n elif int(string.split(' ')[0]) < 1:\n return \" \".join([str(i) for i in string.split(' ') if int(i) >= 1])\n else:\n return \"<< \" + string \n else:\n if int(string.split(' ')[-1]) == n:\n return string\n elif int(string.split(' ')[-1]) > n:\n return string[:-1].strip()\n else:\n return string + \" >>\"\n else:\n return string\n\ndef navigationPage(n, p, k, val):\n l = []\n if val == \"sub\":\n while k != 0:\n if p > 1:\n l.append(p-k)\n else:\n l = []\n k -=1\n else:\n while k != 0:\n if p <= n:\n l.append(p+k)\n else:\n l = []\n k -=1\n l.sort()\n return \" \".join([str(i) for i in l])\n\ndef calculateReq(n,p,k):\n prev_ = navigationPage(n, p, k, \"sub\") \n next_ = navigationPage(n, p, k, \"add\")\n prev_ = addingSymbols(prev_, n, \"front\")\n next_ = addingSymbols(next_, n, \"back\")\n answer = prev_ + \" (\" + str(p) + \") \" + next_\n return answer.strip()\n\nif __name__ == \"__main__\":\n n,p,k = map(int, input().split(' '))\n answer = calculateReq(n,p,k)\n print(answer)"}, {"source_code": "n, p, k = map(int, raw_input().split())\narr = list(set([i for i in range(max(1,p-k),min(n,p+k)+1)]))\n\nfor i in arr:\n if i < 1:\n arr.remove(i)\n if i > n:\n arr.remove(i)\ns = '<< '+ ' '.join(str(i)for i in arr)+' >>'\nif n in arr:\n s = s.replace(' >>','')\nif 1 in arr:\n s = s.replace('<< ','')\ns = s.replace(str(p),'('+str(p)+')')\nprint s\n"}, {"source_code": "n,p,k=map(int,input().split())\nans=\" ({}) \".format(p)\nx=\"\"\nfor i in range(max(p-k,1),p):x+=\" {}\".format(i)\nans=x+ans\nfor i in range(p+1,min(n+1,p+k+1)):ans+=\"{} \".format(i)\nif p+k<=n :ans+=\">>\"\nif p-k>=1 :ans=\"<<\"+ans\nprint(ans)"}, {"source_code": "output=''\nn, p , k = input().split()\nn = int(n)\np=int(p)\nk = int(k)\nfor i in range(p-k,p+k+1):\n if i <=0:\n pass\n elif i == p:\n output+= '(' + str(i) + ') '\n elif i == n:\n output+= str(i) + ' '\n break\n else:\n output+= str(i) + ' '\nif output[0]== '1 ' or output[0]== '(':\n pass\nelse:\n output = '<< ' + output\nif output[-2] == str(n) or output[-2] == ')':\n pass\nelse:\n output = output + '>>'\nprint(output)\n"}, {"source_code": "def solution(n, p, k):\n arr = []\n for i in range(1, n+1):\n arr.append(i)\n string = \"(\" +str(p) + \") \"\n\n #left side\n rotation = p-2\n steps = k\n string_left = \"\"\n while rotation >= 0 and steps > 0:\n string_left = str(arr[rotation]) + \" \" + string_left\n rotation -= 1\n steps -= 1\n string = string_left + string\n left_arr = string_left.split(\" \")\n if len(left_arr) > 0 and left_arr[0] != arr[0]:\n string = \"<< \" + string\n\n #right side\n rotation = p\n steps = k\n string_right = \"\"\n while rotation < n and steps > 0:\n string_right += str(arr[rotation]) + \" \"\n rotation += 1\n steps -= 1\n right_arr = string_right.split(\" \")\n if len(right_arr) > 0 and right_arr[-1] != arr[-1]:\n string_right += \">>\"\n string += string_right\n print(string)\n\narr = input().split(\" \")\nsolution(int(arr[0]), int(arr[1]), int(arr[2]))\n"}, {"source_code": "n, k, p = map(int, input().split())\ns = '(' + str(k) + ')'\nans = ''\n\nfor i in range (k-p,k+p+1):\n if i == k:\n ans += s\n if i <= n and i != k and i > 0:\n ans += str(i) + ' '\nA = ans.split()\nprint(A)\nif A[-1] == s:\n print(' '.join(A) +' >>')\nelif (A[0] == '(1)' or int(A[0]) == 1) and int(A[-1]) < n:\n print(' '.join(A) +' >>')\nelif int(A[-1]) == n and (int(A[0]) == 1 or A[0] == '(1)'):\n print(' '.join(A))\nelif int(A[-1]) < n and int(A[0]) > 1:\n print('<< '+ ' '.join(A) + ' >>')\nelif int(A[-1]) == n and int(A[0]) > 1:\n print('<< ' + ' '.join(A))\n"}, {"source_code": "n,p,k=map(int,input().split())\n\nl=[]\n\nstart=p-k\nstop=p+k\n\nif start<=0:\n start=1\nif stop>n:\n stop=n\n\nl.append(\"<<\")\n\nfor i in range(start,stop+1):\n if i==p:\n l.append(\"(\"+str(i)+\")\")\n else:\n l.append(i)\n\nl.append(\">>\")\n\nstr_a = \"(1)\"\nstr_b = \"(\"+str(n)+\")\"\nif 1 in l and n in l:\n l.pop()\n l.pop(0)\nelif 1 in l or str_a in l:\n l.pop(0)\nelif n in l or str_b in l:\n l.pop()\nfor i in l:\n print(i,end=' ')\n \n \n"}, {"source_code": "n,p,k = map(int,input().split())\nif p > k+1:\n print(\"<<\",end=\" \")\nfor i in range(max(1,p-k),min(n,p+k)+1):\n if i != p:\n print(i,end=\" \")\n else:\n print(\"(\",end=\"\")\n print(i,end=\"\")\n print(\")\",end=\" \")\nif p < n-k-1:\n print(\">>\",end=\" \")\n"}, {"source_code": "n,p,k=map(int,(input().split()))\nif p-k>=1:\n\tprint(\"<<\",end=\"\")\nfor i in range(p-k,p+k+1):\n\tif i==p:\n\t\tprint(\"(\",i,\")\",end=\" \")\n\telse:\n\t\tif i==p+k:\n\t\t\tprint(i,end=\"\")\n\t\telse:\n\t\t\tprint(i,end=\" \")\nif p+k<n:\n\t\tprint(\">>\",end=\"\")"}, {"source_code": "n,p,k=map(int,input().strip().split())\nlo=max(p-k,1)\nhi=min(n,p+k)\nans=\"\"\nif lo>1:\n\tans+=\"<<\"\nfor i in range(lo,p):\n\tans+=\" \"+str(i)\nif p>1:\n\tans+=\" \"\n\tans+='('+str(p)+')'\nfor i in range(p+1,hi+1):\n\tans+=\" \"+str(i)\nif hi<n:\n\tans+=\">>\"\nprint(ans)\n"}, {"source_code": "a, b, c = [int(x) for x in input().split()]\nif b-c>=1 and b>=1:\n print(\"<<\",end=\" \")\nfor i in range(max(b-c,1),b):\n print(i,end=\" \")\nprint(\"(\"+str(b)+\")\",end=\" \")\nfor i in range(b+1,min(b+c+1,a+1)):\n print(i,end=\" \")\nif b+c>=a or b>=a:\n print(\" \")\nelse:\n print(\">>\")"}, {"source_code": "n,p,k=map(int,(input().split()))\nif p-k>=1:\n\tprint(\"<<\",end=\" \")\nfor i in range(p-k,p+k+1):\n\tif i>n:\n\t\t\tpass\n\telif i<1:\n\t\tcontinue\n\telif i==p:\n\t\tprint(f\"({i})\",end=\" \")\n\telse:\n\t\tif i==p+k:\n\t\t\tprint(i,end=\" \")\n\t\telse:\n\t\t\tprint(i,end=\" \")\nif p+k<n:\n\t\tprint(\">>\",end=\"\")"}, {"source_code": "\"\"\"\n9 6 3\n<< 3 4 5 (6) 7 8 9\n17 5 2\n<< 3 4 (5) 6 7 >> \n6 5 2\n<< 3 4 (5) 6 \n6 1 2\n(1) 2 3 >> \n6 2 2\n1 (2) 3 4 >>\n9 6 3\n<< 3 4 5 (6) 7 8 9\n10 6 3\n<< 3 4 5 (6) 7 8 9 >>\n8 5 4\n1 2 3 4 (5) 6 7 8 \n\"\"\"\nn,p,k=map(int,input().split())\nif(p<1 or p>n):\n pass\nelse:\n #print(p-k,p+k)\n if(p-k>1 and p+k<n):\n print(\"<<\",\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,p+k+1)),\">>\")\n elif(p-k<=1 and p+k>n):\n print(\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(1,n+1)))\n elif(p-k>1):\n print(\"<<\",\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,n+1)))\n elif(p+k<n):\n print(\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(1,p+k+1)),\">>\")"}, {"source_code": "x = raw_input()\nx = x.split(' ')\npages = int(x[0])\npage = int(x[1])\nexcess = int(x[2])\nanswer = ''\nif page - excess > 1:\n answer += '<< '\n if page + excess <= pages:\n total = 2*excess + 1\n for count in range(total):\n answer += str(page-excess+count)\n answer += ' '\n if page + excess != pages:\n answer += '>>'\n else:\n for count in range(page-excess, pages+1):\n answer += str(count) + ' '\nelse:\n if page + excess <= pages:\n for count in range(page + excess):\n answer += str(count+1)\n answer += ' '\n if page + excess != pages:\n answer += '>>'\n else:\n for count in range(pages):\n answer += str(count+1) + ' '\nindex = answer.index(str(page))\nanswer = answer[:index] + '(' + answer[index] + ')' + answer[index+1:]\nprint answer\n\n\n\n"}, {"source_code": "n,p,k = list(map(int,input().split()))\nfinal_list = [i for i in range(1,n+1)]\nif p-k > 1 and p+k<n:\n f = f'({final_list[p-1]})'\n print('<< ',*final_list[p-(k+1):p-1],f,*final_list[p:p+k],'>>')\nif p-k<=1 and p+k<n:\n f = f'({final_list[p-1]})'\n print(*final_list[:p-1],f,*final_list[p:p+k],'>>')\nif p-k>1 and p+k > n-1:\n f = f'({final_list[p-1]})'\n print('<< ',*final_list[p-(k+1):p-1],f,*final_list[p:n])\nif p-k<1 and p+k>n:\n f = f'({final_list[p-1]})'\n print(*final_list[:p-1],f,*final_list[p:n])"}, {"source_code": "n,p,k=map(int,input().split())\nq=[]\nfor i in range(n):\n q.append(i+1)\nq[p-1]='('+str(p)+')'\nq=q[max(p-k-1,0):p]+q[p:p+k]\nif q[0]!=1:\n q=q=['<<']+q\nif q[-1]!=n:\n q=q+['>>']\nprint(*q)\n"}, {"source_code": "n, p, k = [int(i) for i in input().split()]\ns = \"\"\nfor i in range(p-k, p):\n s += str(i) + \" \"\ns += \"(\" + str(p) + \") \"\nfor i in range(p+1, p+k+1):\n s += str(i) + \" \"\nif p-k > 1:\n s = \"<< \" + s\nif p+k < n:\n s += \">>\"\nprint(s)"}, {"source_code": "(n, p, k), x = raw_input().split(), ''\n\nfor i in range(int(k)):\n if int(p) - i - 1 == 0:\n break\n x = str(int(p) - i - 1) + ' ' + x\n if int(p) - i - 1 == int(p) - int(k) or int(p) - i - 1 == 1:\n break\n\nif int(p) - int(k) > 1:\n x = '<< ' + x\n\nx = x + '(' + str(p) + ')'\n \nfor i in range(int(k)):\n x = x + ' ' + str(int(p) + i + 1)\n if int(p) + i + 1 == int(n):\n break\n\nif int(p) + int(k) < int(n):\n x = x + ' >>'\n\nprint x"}, {"source_code": "n, p, k = map(int, input().split())\nl_start = l_end = True\nif p - k < 1:\n start = 1\n l_start = False\nelse: \n start = p - k\nif p + k >= n:\n stop = n \n l_end = False\nelse: \n stop = p + k\nif (l_start):\n print('<<', end=' ')\nfor i in range(start, stop + 1, 1):\n if i == p:\n print('(' + str(i) + ')', end=' ')\n else:\n print(i, end=' ')\nif (l_end):\n print('>>')\n"}, {"source_code": "n = list(map(lambda x: int(x), input().split(' ')))\nn, p, k = n[0], n[1], n[2]\npages = []\nfor i in range(-k, k+1):\n\tif p + i == p:\n\t\tpages.append(f'({p})')\n\telif p + i > 0 and p + i < n + 1:\n\t\tpages.append(str(p+i))\nif '1' not in pages and '(1)' not in pages:\n\tpages.insert(0, '<<')\nif str(n) not in pages:\n\tpages.append('>>')\nprint(str(' '.join(pages)))"}, {"source_code": "\"\"\"\n17 5 2\n<< 3 4 (5) 6 7 >> \n6 5 2\n<< 3 4 (5) 6 \n6 1 2\n(1) 2 3 >> \n6 2 2\n1 (2) 3 4 >>\n9 6 3\n<< 3 4 5 (6) 7 8 9\n10 6 3\n<< 3 4 5 (6) 7 8 9 >>\n8 5 4\n1 2 3 4 (5) 6 7 8 \n\"\"\"\nn,p,k=map(int,input().split())\nif(p<1 or p>n):\n pass\nelse:\n if(p-k>=1 and p+k<=n):\n print(\"<<\",\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,p+k+1)),\">>\")\n elif(p-k<1 and p+k>n):\n print(\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,p+k)))\n elif(p-k>1):\n print(\"<<\",\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,p+k)))\n elif(p+k<n and p-k<1):\n print(\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(1,p+k+1)),\">>\")"}, {"source_code": "n, p, k = map(int, input().split())\ns = '('+ str(p) +')'\n\nfor _ in range(1,k+1):\n\tif p-_ > 0:\n\t\ts = str(p-_) + ' ' + s\n\tif p+_ <= n:\n\t\ts = s + ' ' + str(p+_)\n\nif p + k < n:\n\ts = s+' >>'\n\nif p - k >= 0:\n\ts = '<< ' + s\n\nprint(s)"}, {"source_code": "x=list(map(int,input().split()))\n\nn=x[0]\np=x[1]\nk=x[2]\n\nif(p-k>0):\n print(\"<<\",end=' ')\n\n\n\n\nfor i in range(k):\n if(p+i-k>0):\n print(p+i-k,end=' ')\n\nprint(\"(\",end='')\nprint(p,end='')\nprint(\")\",end=' ')\n\n\nfor i in range(1,k+1):\n if(p+i<=n):\n print(p+i,end=' ')\n \nif(p+k<=n):\n print(\">>\",end=' ')"}, {"source_code": "a,b,k = map(int,input().split(\" \"))\nflag1 = True\nflag2 = True\nif b-k > 1:\n print(\"<<\",end=\" \")\n \nfor i in range(b-k,b+k+1):\n if i > 0:\n if i == b:\n print(\"(\"+str(i)+\")\",end=\" \")\n else:\n print(i,end=\" \")\n \n if i > a:\n break\nif b+k < a:\n print(\">>\")\n \n"}, {"source_code": "n, p, k = input().split()\n\nn = int(n);p = int(p);k = int(k)\n\nleftP = []\nbefore = p-1\nwhile len(leftP) < k and before >= 1:\n leftP.insert(0, str(before))\n before -= 1\n\nrightP = []\nafter = p+1\nwhile len(rightP) < k and after <= n:\n rightP.append(str(after))\n after += 1\n\n\npages = [\"<< \", \" \".join(leftP) + \" (\"+str(p)+\") \" + \" \".join(rightP), \" >>\"]\n\n\nif len(leftP) > 0:\n if len(leftP) <= k and int(leftP[0]) <= k:\n pages.pop(0)\nelse:\n pages.pop(0)\n\n\nif int(rightP[len(rightP)-1]) >= n:\n pages.pop()\n\n\n\nprint(\"\".join(pages))\n\n\n\n"}, {"source_code": "n,p,k=map(int,input().split())\nif p-k!=1:\n print(\"<<\",end=\" \")\ni=p-k\nwhile i<=0:\n i+=1\nwhile i<=p+k and i<=n:\n if i==p:\n print(\"(\",end=\"\")\n print(i,end=\"\")\n print(\")\",end=\" \")\n i+=1\n continue\n print(i,end=\" \")\n i+=1\nif i!=(n+1):\n print(\">> \")\n\n"}, {"source_code": "output=''\nn, p , k = input().split()\nn = int(n)\np=int(p)\nk = int(k)\nfor i in range(p-k,p+k+1):\n if i <=0:\n pass\n elif i == p:\n output+= '(' + str(i) + ') '\n else:\n output+= str(i) + ' '\nif output[0]!= '1':\n output = '<< ' + output\nif output[-1] != n:\n output = output + '>>'\nprint(output)"}, {"source_code": "n,p,k=[int(x) for x in input().split()]\nL=[]\nif p>1:\n L.append(\"<<\")\nelse:\n pass\nfor i in range(k,0,-1):\n if p-i>=1:\n L.append(str(p-i))\nL.append(\"(\"+str(p)+\")\")\nfor i in range(1,k+1):\n if p+i<=n:\n L.append(str(p+i))\nif p<n:\n L.append(\">>\")\nelse:\n pass\n \n\nprint(\" \".join(L))\n"}, {"source_code": "\"\"\"\n9 6 3\n<< 3 4 5 (6) 7 8 9\n17 5 2\n<< 3 4 (5) 6 7 >> \n6 5 2\n<< 3 4 (5) 6 \n6 1 2\n(1) 2 3 >> \n6 2 2\n1 (2) 3 4 >>\n9 6 3\n<< 3 4 5 (6) 7 8 9\n10 6 3\n<< 3 4 5 (6) 7 8 9 >>\n8 5 4\n1 2 3 4 (5) 6 7 8 \n\"\"\"\nn,p,k=map(int,input().split())\nif(p<1 or p>n):\n pass\nelse:\n #print(p-k,p+k)\n if(p-k>1 and p+k<n):\n print(\"<<\",\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,p+k+1)),\">>\")\n elif(p-k<=1 and p+k>n):\n print(\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,p+k+1)))\n elif(p-k>1):\n print(\"<<\",\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(p-k,n+1)))\n elif(p+k<n):\n print(\" \".join(\"(%d)\"%(i) if i==int(((p-k)+(p+k))/2) else str(i) for i in range(1,p+k+1)),\">>\")"}, {"source_code": "n, p, k = map(int, input().split())\nif p - k > 1:\n print('<<', end=' ')\nfor i in range(p - k, p + k + 1):\n if i != p:\n print(i, end=' ')\n else:\n print('(' + str(i) + ')', end=' ')\nif p + k < n:\n print('>>')"}, {"source_code": "n,p,k = list(map(int,input().split()))\nfinal_list = [i for i in range(1,n+1)]\nif p-k > 1 and p+k<n:\n f = f'({final_list[p-1]})'\n print('<< ',*final_list[p-(k+1):p-1],f,*final_list[p:p+k],'>>')\nif p-k<=1 and p+k<n:\n f = f'({final_list[p-1]})'\n print(*final_list[:p-1],f,*final_list[p:p+k],'>>')\nif p-k>1 and p+k > n-1:\n f = f'({final_list[p-1]})'\n print('<< ',*final_list[p-(k+1):p-1],f,*final_list[p:n])\nif p-k<=1 and p+k>n:\n f = f'({final_list[p-1]})'\n print(*final_list[:p-1],f,*final_list[p:n])"}, {"source_code": "(n, p, k), x = raw_input().split(), ''\n\nfor i in range(int(k)):\n x = str(int(p) - i - 1) + ' ' + x\n if int(p) - i - 1 == int(p) - int(k) or int(p) - i - 1 == 1:\n break\n\nif int(p) - int(k) > 1:\n x = '<< ' + x\n\nx = x + '(' + str(p) + ')'\n \nfor i in range(int(k)):\n x = x + ' ' + str(int(p) + i + 1)\n if int(p) + i + 1 == int(n):\n break\n\nif int(p) + int(k) < int(n):\n x = x + ' >>'\n\nprint x"}, {"source_code": "x,y,z=map(int,input().split())\nok=1\nko=0\nif 1>y-z :\n ok=0\nif x>=y+z :\n ko=1\nif ok==1 :\n print(\"<<\",end=' ')\nfor i in range(max(1,y-z),min(x,y+z)+1) :\n if i == y :\n print('(',end='')\n print(i,end='')\n print(')',end=' ')\n else: \n print(i,end=' ')\nif ko == 1:\n print(\">>\")"}, {"source_code": "n, p, k = map(int, input().split())\n\npages = [str(i) for i in range(1, n+1)]\n\nleft = 0\nif p-k-1>=0:left=p-k-1\nelse:left=p-k\n\nres = [' '.join(pages[left:p-1]), '(' + str(p) + ')', ' '.join(pages[p:p+k])]\n\nif p-k-1>0: res.insert(0,'<<')\n\nif p+k<n: res.append('>>')\n\nprint(' '.join(res).strip())"}, {"source_code": "n,p,k=map(int,input().split())\n\nl=[]\n\nstart=p-k\nstop=p+k\n\nif start<=0:\n start=1\nif stop>n:\n stop=n\n\nl.append(\"<<\")\n\nfor i in range(start,stop+1):\n if i==p:\n l.append(\"(\"+str(i)+\")\")\n else:\n l.append(i)\n\nl.append(\">>\")\n\nstr_a = \"(1)\"\nstr_b = \"(\"+str(n)+\")\"\nif 1 in l and n in l:\n l.pop()\n l.pop(0)\nelif 1 in l or str_a in l:\n l.pop(0)\nelif n in l or str_b in l:\n l.pop()\nfor i in l:\n print(i,end=' ')\n \n \n"}, {"source_code": "# @Author: Justin Hershberger\n# @Date: 23-03-2017\n# @Filename: 399A.py\n# @Last modified by: Justin Hershberger\n# @Last modified time: 23-03-2017\n\n\n\n#Justin Hershberger\n#Py3.5\n\nimport fileinput\n\ndef test():\n\tpass\nif __name__ == '__main__':\n\tn,p,k = map(int, input().split())\n\n\toutput = \"\"\n\n\tif p - k > 0:\n\t\toutput = \"<<< \"\n\n\tfor i in range(p-k,p+k+1):\n\t\tif i == p:\n\t\t\toutput += \"(\" + str(i) + \") \"\n\t\telif i > n:\n\t\t\tbreak\n\t\telif i > 0:\n\t\t\toutput += str(i) + \" \"\n\n\tif p + k < n:\n\t\toutput += \">>>\"\n\n\tprint(output)\n"}, {"source_code": "n,p,k=map(int,input().split())\n\nl=[]\n\nstart=p-k\nstop=p+k\n\nif start<=0:\n start=1\nif stop>n:\n stop=n\n\nl.append(\"<<\")\n\nfor i in range(start,stop+1):\n if i==p:\n l.append(\"(\"+str(i)+\")\")\n else:\n l.append(i)\n\nl.append(\">>\")\n\nstr_a = \"(1)\"\nstr_b = \"(\"+str(n)+\")\"\nif 1 in l and n in l:\n l.pop()\n l.pop(0)\nelif 1 in l or str_a in l:\n l.pop(0)\nelif n in l or str_b in l:\n l.pop()\nfor i in l:\n print(i,end=' ')\n \n \n"}, {"source_code": "def pages(n,p,k):\n output = \"\"\n if p-k > 1 :\n output += \"<< \"\n for i in range(0, p):\n if p-k+i <= n:\n if p-k+i == p:\n output += \"(\" + str(p-k+i) + \") \"\n else:\n output += str(p-k+i) + \" \"\n\n if p+k < n:\n output += \">>\"\n\n return output\n\nn,p,k = map(int, input().split())\nprint(pages(n, p, k))"}, {"source_code": "n, k, p = input().split()\npages = [str(i) for i in range(int(k) - int(p), int(k) + int(p) + 1) if 1 <= i <= int(n)]\noutput = ''.join(page + ' ' for page in pages)[:-1]\n\nif output[0] != '1':\n\toutput = '<< ' + output\n\nif output[-1] != n:\n\toutput += ' >>'\n\nk_index = output.index(k)\noutput = f'{output[:k_index]}({k}){output[k_index+len(k):]}'\nprint(output)"}, {"source_code": "n, p, k = input().split()\n\nn = int(n);p = int(p);k = int(k)\n\nleftP = []\nbefore = p-1\nwhile len(leftP) < k and before >= 1:\n leftP.insert(0, str(before))\n before -= 1\n\nrightP = []\nafter = p+1\nwhile len(rightP) < k and after <= n:\n rightP.append(str(after))\n after += 1\n\n\npages = [\"<< \", \" \".join(leftP) + \" (\"+str(p)+\") \" + \" \".join(rightP), \" >>\"]\n\n\nif len(leftP) > 0:\n if int(leftP[0]) <= 2:\n pages.pop(0)\nelse:\n pages.pop(0)\n\nif int(rightP[len(rightP)-1]) >= n:\n pages.pop()\n\n\n\nprint(\"\".join(pages))\n\n\n\n"}, {"source_code": "x=list(map(int,input().split()))\n\nn=x[0]\np=x[1]\nk=x[2]\n\nif(p-k>0):\n print(\"<<\",end=' ')\n\n\n\n\nfor i in range(k):\n if(p+i-k>0):\n print(p+i-k,end=' ')\n\nprint(\"(\",end='')\nprint(p,end='')\nprint(\")\",end=' ')\n\n\nfor i in range(1,k+1):\n if(p+i<=n):\n print(p+i,end=' ')\n \nif(p+k<=n):\n print(\">>\",end=' ')"}, {"source_code": "n_arry = [int(i) for i in input().split()][:3]\nfor i in n_arry: \n print(i, end=\" \")\nprint('')\nn=n_arry[0]\np=n_arry[1]\nk=n_arry[2]\nif (p-k)>0:\n print('<<',end=' ')\nif p-k>0:\n for i in range((k),0,-1):\n if p-i>0 and i >0:\n print(p-i,end=' ')\nelif p-k-1<0:\n for a in range(1,p):\n print(a, end=' ')\nprint('(',p,')',sep='',end = ' ')\nfor i in range(1,k+1):\n if p+i<=n:\n print(p+i,end=' ')\n\nif p+k<n:\n print('>>')"}, {"source_code": "n,p,k=map(int,input().split())\nif p-k!=1:\n print(\"<<\",end=\" \")\ni=p-k\nwhile i<=0:\n i+=1\nwhile i<=p+k and i<=n:\n if i==p:\n print(\"(\",end=\"\")\n print(i,end=\"\")\n print(\")\",end=\" \")\n i+=1\n continue\n print(i,end=\" \")\n i+=1\nif i!=(n+1):\n print(\">> \")\n\n"}, {"source_code": "n,p,k=map(int,input().split())\nans=\" ){}( \".format(p)\nfor i in range(max(p-k,1),p):ans+=\"{} \".format(i)\nans=ans[::-1]\nfor i in range(p+1,min(n+1,p+k+1)):ans+=\"{} \".format(i)\nif p+k<=n :ans+=\">>\"\nif p-k>=1 :ans=\"<<\"+ans\nprint(ans)"}, {"source_code": "output=''\nn, p , k = input().split()\nn = int(n)\np=int(p)\nk = int(k)\nfor i in range(p-k,p+k+1):\n if i <=0:\n pass\n elif i == p:\n output+= '(' + str(i) + ') '\n elif i == n:\n output+= str(i) + ' '\n break\n else:\n output+= str(i) + ' '\nif output[0:2]== '1 ' or output[0]== '(':\n pass\nelse:\n output = '<< ' + output\nif output[len(str(n))*-1-1:-1] == str(n) or output[-2] == ')':\n pass\nelse:\n output = output + '>>'\nprint(output)"}, {"source_code": "n,p,k=[int(i) for i in input().split()]\na=(2*k+1)*[0]\nz=p-k\nfor i in range(2*k+1):\n a[i]=z+i\nb=a[:]\n#print(len(b),len(a))\nfor i in range(2*k,-1,-1):\n #print(len(a))\n #print(i)\n if a[i]<1 or a[i]>n:\n b.pop(i)\n#print(b)\nz='('+str(p)+')'\nz2=b.index(p)\nx=''\nprint(z2)\nif 1 not in b:\n x+='<< '\nfor i in range(z2):\n x+=str(b[i])+' '\nx+=z+' '\nif n not in b:\n for i in range(z2+1,len(b)):\n x+=str(b[i])+' '\n x+='>>'\nelse:\n for i in range(z2+1,len(b)):\n x+=str(b[i])+' '\nprint(x)\n"}, {"source_code": "n = list(map(lambda x: int(x), input().split(' ')))\nn, p, k = n[0], n[1], n[2]\npages = []\nfor i in range(-k, k+1):\n\tif p + i > 0 and p + i < n + 1:\n\t\tpages.append(str(p+i))\nif '1' not in pages:\n\tpages.insert(0, '<<')\nif str(n) not in pages:\n\tpages.append('>>')\nprint(str(' '.join(pages)))"}, {"source_code": "n,p,k=map(int,input().split())\nif p-k!=1:\n print(\"<<\",end=\" \")\ni=p-k\nwhile i<=p+k and i<=n:\n if i==p:\n print(\"(\",i,\")\",end=\" \")\n i+=1\n continue\n print(i,end=\" \")\n i+=1\nif i!=n:\n print(\">> \")\n"}, {"source_code": "n, k, p = map(int, input().split())\ns = '(' + str(k) + ')'\nans = ''\n\nfor i in range (k-p,k+p+1):\n if i == k:\n ans += s+ ' '\n if i <= n and i != k and i > 0:\n ans += str(i) + ' '\nA = ans.split()\n#print(int(A[-1])==n , A[0]=='(1)')\nif A[-1] == s:\n print('<< ' + ' '.join(A))\nelif (A[0] == '(1)' or int(A[0]) == 1) and int(A[-1]) < n:\n print(' '.join(A) +' >>')\nelif int(A[-1]) == n and (A[0] == '(1)' or int(A[0]) == 1 ):\n print(' '.join(A))\nelif int(A[-1]) < n and int(A[0]) > 1:\n print('<< '+ ' '.join(A) + ' >>')\nelif int(A[-1]) == n and int(A[0]) > 1:\n print('<< ' + ' '.join(A))\n"}], "src_uid": "526e2cce272e42a3220e33149b1c9c84"} {"source_code": "n, m = [int(x) for x in input().split()]\r\na = []\r\nwhile n:\r\n n, r = divmod(n, m)\r\n a.append(r)\r\nprint([\"NO\", \"YES\"][len(set(a)) == len(a)]) ", "positive_code": [{"source_code": "def solve(given: str) -> str:\r\n nums = [int(x) for x in given.split()]\r\n a, b = nums[0], nums[1]\r\n s = set()\r\n count = 0\r\n while a>0:\r\n count+=1\r\n s.add(a%b)\r\n a//=b\r\n if count == len(s):\r\n return 'YES'\r\n else:\r\n return 'NO'\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\nl = list()\r\nwhile x:\r\n l.append(x % y)\r\n x //= y \r\nprint(\"YES\" if len(set(l)) == len(l) else \"NO\")"}, {"source_code": "n, m = map(int, input().split())\r\nar = []\r\nwhile n:\r\n ar.append(n % m)\r\n n //= m\r\nif len(ar) == len(set(ar)):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "n, m = map(int, input().split())\r\ntmp = []\r\nwhile n:\r\n tmp.append(n % m)\r\n n //= m\r\nif len(tmp) == len(set(tmp)):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "N, M = map(int, input().split())\r\ndigits = \"0123456789abcdef\"\r\nans = \"\"\r\nwhile N:\r\n ans = digits[N % M] + ans\r\n N //= M\r\na = len(ans)\r\nb = len(set(ans))\r\nprint([\"NO\", \"YES\"][a == b])"}, {"source_code": "import sys\r\nsys.stdin.readline\r\n\r\nn, m = map(int, input().split()) \r\narr = []\r\nwhile n:\r\n arr.append(n % m)\r\n n //= m\r\nif len(arr) == len(set(arr)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "n,m=map(int,input().split())\r\nq=[]\r\nwhile n:\r\n q.append(n%m)\r\n n//=m\r\nif len(q)==len(set(q)): print('YES')\r\nelse: print('NO')"}, {"source_code": "n,m = [int(x) for x in input().split()]\nch = True\nd = set()\nwhile n > 0:\n x = n%m\n if x in d:\n ch = False\n break\n d.add(x)\n n//=m\nif ch:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input().split()\r\n\r\n\r\nsrc = int(s[0])\r\nbase = int(s[1])\r\ndigits = []\r\nwhile src > 0:\r\n digits.append(src % base)\r\n src //= base\r\n\r\n\r\nif len(digits) == len(set(digits)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "# Rishabh Rao (https://github.com/rishabhrao)\r\n\r\nimport sys\r\nMOD = 1000000007\r\ndef inp(): return sys.stdin.readline().strip()\r\ndef ii(): return int(inp())\r\ndef iis(): return [int(i) for i in inp().split()]\r\n\r\n\r\ndef numberToBase(n, b):\r\n if n == 0: return [0]\r\n digits = []\r\n while n:\r\n digits.append(int(n % b))\r\n n //= b\r\n return digits[::-1]\r\n\r\n\r\ndef solve():\r\n n, m = iis()\r\n a = numberToBase(n, m)\r\n return sorted(a) == sorted(list(set(a)))\r\n\r\n\r\nprint(\"YES\" if solve() else \"NO\")\r\n"}, {"source_code": "def numberToBase(n, b):\r\n if n == 0:\r\n return [0]\r\n digits = []\r\n while n:\r\n digits.append(int(n % b))\r\n n //= b\r\n return digits[::-1]\r\n \r\nN, B = map(int, input().split())\r\nD = numberToBase(N, B)\r\ncount = set()\r\ncorrect = \"YES\"\r\nfor elt in D:\r\n if not elt in count:\r\n count.add(elt)\r\n else:\r\n correct = \"NO\"\r\n break\r\nprint(correct)"}, {"source_code": "def xeno(n,m):\r\n ans=[]\r\n while(n):\r\n ans.append(n%m)\r\n n=int(n/m)\r\n\r\n s=set()\r\n\r\n for item in ans:\r\n s.add(item)\r\n \r\n # print(s)\r\n # print(ans)\r\n if len(s)==len(ans):\r\n return 'YES'\r\n else:\r\n return 'NO'\r\n\r\nif __name__=='__main__':\r\n n=input().split(' ')\r\n print(xeno(int(n[0]),int(n[1])))\r\n \r\n"}, {"source_code": "# https://codeforces.com/problemset/problem/1505/D\r\n\r\ndef numberToBase(n, b):\r\n if n == 0:\r\n return [0]\r\n digits = []\r\n while n:\r\n digits.append(int(n % b))\r\n n //= b\r\n return digits[::-1]\r\n\r\ndef main():\r\n\r\n n, m = map(int, input().split())\r\n\r\n test = numberToBase(n, m)\r\n\r\n if len(test) == len(set(test)):\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "n, m = map(int, input().split())\r\na = []\r\nwhile n:\r\n\ta.append(n % m)\r\n\tn //= m\r\nif len(a) != len(set(a)):\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")\r\n\r\n"}, {"source_code": "import sys\r\nn, m = map(int, input().split());seen = set()\r\nwhile n > 0:\r\n d = n % m\r\n if d in seen: print(\"NO\");sys.exit(0)\r\n seen.add(d);n //= m\r\nprint(\"YES\")"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "n, m = map(int, input().split())\r\nl = []\r\nwhile n > 0:\r\n l.append(n % m)\r\n n = n // m\r\n# print(l)\r\nprint(\"YES\" if len(l) == len(set(l)) else \"NO\")"}, {"source_code": "a,m=map(int,input().split())\r\nq=[]\r\nwhile a:\r\n q.append(a%m)\r\n a//=m\r\nif len(q)==len(set(q)): print('YES')\r\nelse: print('NO')"}, {"source_code": "n, m = map(int, input().split())\ndigits = set()\nwhile n:\n n, d = divmod(n, m)\n if d in digits:\n print(\"NO\")\n break\n digits.add(d)\nelse:\n print(\"YES\")\n"}, {"source_code": "n, m = map(int, input().split())\r\n \r\na = []\r\nwhile n:\r\n\ta.append(n % m)\r\n\tn //= m\r\n \r\nprint('YES' if len(set(a)) == len(a) else 'NO')"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "n, m = map(int, input().split())\r\na = []\r\nwhile(n > 0):\r\n a.append(n % m)\r\n n //= m\r\nif (len(a) == len(set(a))):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import bisect\r\nimport heapq\r\nimport math\r\nimport collections\r\nimport sys\r\nimport copy\r\nfrom functools import reduce\r\nimport decimal\r\nfrom io import BytesIO, IOBase\r\nimport os\r\nimport itertools\r\nimport functools\r\nfrom types import GeneratorType\r\n\r\n#\r\n# sys.setrecursionlimit(10 ** 9)\r\ndecimal.getcontext().rounding = decimal.ROUND_HALF_UP\r\n\r\ngraphDict = collections.defaultdict\r\n\r\nqueue = collections.deque\r\n\r\n\r\n################## pypy deep recursion handling ##############\r\n# Author = @pajenegod\r\ndef bootstrap(f, stack=[]):\r\n def wrappedfunc(*args, **kwargs):\r\n to = f(*args, **kwargs)\r\n if stack:\r\n return to\r\n else:\r\n while True:\r\n if type(to) is GeneratorType:\r\n stack.append(to)\r\n to = next(to)\r\n else:\r\n stack.pop()\r\n if not stack:\r\n return to\r\n to = stack[-1].send(to)\r\n\r\n return wrappedfunc\r\n\r\n\r\n################## Graphs ###################\r\nclass Graphs:\r\n def __init__(self):\r\n self.graph = graphDict(set)\r\n\r\n def add_edge(self, u, v):\r\n self.graph[u].add(v)\r\n self.graph[v].add(u)\r\n\r\n def dfs_utility(self, nodes, visited_nodes, colors, parity, level):\r\n global count\r\n if nodes == 1:\r\n colors[nodes] = -1\r\n else:\r\n if len(self.graph[nodes]) == 1 and parity % 2 == 0:\r\n if q == 1:\r\n colors[nodes] = 1\r\n else:\r\n colors[nodes] = -1\r\n count += 1\r\n else:\r\n if parity % 2 == 0:\r\n colors[nodes] = -1\r\n else:\r\n colors[nodes] = 1\r\n visited_nodes.add(nodes)\r\n for neighbour in self.graph[nodes]:\r\n new_level = level + 1\r\n if neighbour not in visited_nodes:\r\n self.dfs_utility(neighbour, visited_nodes, colors, level - 1, new_level)\r\n\r\n def dfs(self, node):\r\n Visited = set()\r\n color = collections.defaultdict()\r\n self.dfs_utility(node, Visited, color, 0, 0)\r\n return color\r\n\r\n def bfs(self, node, f_node):\r\n count = float(\"inf\")\r\n visited = set()\r\n level = 0\r\n if node not in visited:\r\n queue.append([node, level])\r\n visited.add(node)\r\n flag = 0\r\n while queue:\r\n parent = queue.popleft()\r\n if parent[0] == f_node:\r\n flag = 1\r\n count = min(count, parent[1])\r\n level = parent[1] + 1\r\n for item in self.graph[parent[0]]:\r\n if item not in visited:\r\n queue.append([item, level])\r\n visited.add(item)\r\n return count if flag else -1\r\n return False\r\n\r\n\r\n################### Tree Implementaion ##############\r\nclass Tree:\r\n def __init__(self, data):\r\n self.data = data\r\n self.left = None\r\n self.right = None\r\n\r\n\r\ndef inorder(node, lis):\r\n if node:\r\n inorder(node.left, lis)\r\n lis.append(node.data)\r\n inorder(node.right, lis)\r\n return lis\r\n\r\n\r\ndef leaf_node_sum(root):\r\n if root is None:\r\n return 0\r\n if root.left is None and root.right is None:\r\n return root.data\r\n return leaf_node_sum(root.left) + leaf_node_sum(root.right)\r\n\r\n\r\ndef hight(root):\r\n if root is None:\r\n return -1\r\n if root.left is None and root.right is None:\r\n return 0\r\n return max(hight(root.left), hight(root.right)) + 1\r\n\r\n\r\n################## Union Find #######################\r\nclass UF:\r\n \"\"\"An implementation of union find data structure.\r\n It uses weighted quick union by rank with path compression.\r\n \"\"\"\r\n\r\n def __init__(self, N):\r\n \"\"\"Initialize an empty union find object with N items.\r\n\r\n Args:\r\n N: Number of items in the union find object.\r\n \"\"\"\r\n\r\n self._id = list(range(N))\r\n self._count = N\r\n self._rank = [0] * N\r\n\r\n def find(self, p):\r\n \"\"\"Find the set identifier for the item p.\"\"\"\r\n\r\n id = self._id\r\n while p != id[p]:\r\n p = id[p] # Path compression using halving.\r\n return p\r\n\r\n def count(self):\r\n \"\"\"Return the number of items.\"\"\"\r\n\r\n return self._count\r\n\r\n def connected(self, p, q):\r\n \"\"\"Check if the items p and q are on the same set or not.\"\"\"\r\n\r\n return self.find(p) == self.find(q)\r\n\r\n def union(self, p, q):\r\n \"\"\"Combine sets containing p and q into a single set.\"\"\"\r\n\r\n id = self._id\r\n rank = self._rank\r\n\r\n i = self.find(p)\r\n j = self.find(q)\r\n if i == j:\r\n return\r\n\r\n self._count -= 1\r\n if rank[i] < rank[j]:\r\n id[i] = j\r\n elif rank[i] > rank[j]:\r\n id[j] = i\r\n else:\r\n id[j] = i\r\n rank[i] += 1\r\n\r\n def add_roads(self):\r\n return set(self._id)\r\n\r\n def __str__(self):\r\n \"\"\"String representation of the union find object.\"\"\"\r\n return \" \".join([str(x) for x in self._id])\r\n\r\n def __repr__(self):\r\n \"\"\"Representation of the union find object.\"\"\"\r\n return \"UF(\" + str(self) + \")\"\r\n\r\n\r\n#################################################\r\n\r\ndef rounding(n):\r\n return int(decimal.Decimal(f'{n}').to_integral_value())\r\n\r\n\r\ndef factors(n):\r\n return set(reduce(list.__add__,\r\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\r\n\r\n\r\ndef p_sum(array):\r\n return list(itertools.accumulate(array))\r\n\r\n\r\ndef base_change(nn, bb):\r\n if nn == 0:\r\n return [0]\r\n digits = []\r\n while nn:\r\n digits.append(int(nn % bb))\r\n nn //= bb\r\n return digits[::-1]\r\n\r\n\r\ndef diophantine(a: int, b: int, c: int):\r\n d, x, y = extended_gcd(a, b)\r\n r = c // d\r\n return r * x, r * y\r\n\r\n\r\n@bootstrap\r\ndef extended_gcd(a: int, b: int):\r\n if b == 0:\r\n d, x, y = a, 1, 0\r\n else:\r\n (d, p, q) = yield extended_gcd(b, a % b)\r\n x = q\r\n y = p - q * (a // b)\r\n\r\n yield d, x, y\r\n\r\n\r\n######################################################################################\r\n\r\n'''\r\nKnowledge and awareness are vague, and perhaps better called illusions.\r\nEveryone lives within their own subjective interpretation.\r\n ~Uchiha Itachi\r\n'''\r\n\r\n################################ <fast I/O> ###########################################\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self, **kwargs):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\n\r\n#############################################<I/O Region >##############################################\r\n\r\n\r\ndef inp():\r\n return sys.stdin.readline().strip()\r\n\r\n\r\ndef map_inp(v_type):\r\n return map(v_type, inp().split())\r\n\r\n\r\ndef list_inp(v_type):\r\n return list(map_inp(v_type))\r\n\r\n\r\n######################################## Solution ####################################\r\n\r\nn, m = map_inp(int)\r\nif len(set(base_change(n, m))) == len(base_change(n, m)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "N, M = map(int, input().split())\r\nn_m = []\r\nwhile N > 0:\r\n n_m.append(N % M)\r\n N //= M\r\nn_m = list(reversed(n_m))\r\nif len(n_m) == len(set(n_m)):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "n, m = map(int, input().split())\r\n\r\na = []\r\nwhile n:\r\n\ta.append(n % m)\r\n\tn //= m\r\n\r\nprint('YES' if len(set(a)) == len(a) else 'NO')\r\n"}, {"source_code": "n,m=[int(x) for x in input().split()]\r\na=[]\r\nwhile n:\r\n a.append(n%m)\r\n n=n//m\r\nif len(a)==len(set(a)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "n,m=[int(x) for x in input().split()]\r\na=[]\r\nwhile n:\r\n a.append(n%m)\r\n n=n//m\r\nif len(a)==len(set(a)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "from collections import Counter\r\n\r\n\r\ndef maissa(n1, m1):\r\n dictii = {0: \"0\", 1: \"1\", 2: \"2\", 3: \"3\", 4: \"4\", 5: \"5\", 6: \"6\", 7: \"7\", 8: \"8\", 9: \"9\", 10: \"a\", 11: \"b\", 12: \"c\",\r\n 13: \"d\", 14: \"e\", 15: \"f\"}\r\n result = dictii[(n1%m1)]\r\n while int(n1/m1):\r\n n1 = int(n1 / m1)\r\n result = result + dictii[(n1%m1)]\r\n\r\n return result\r\n\r\n\r\ndef neyewehdi(string):\r\n freq = Counter(string)\r\n if len(freq) == len(string):\r\n return True\r\n else:\r\n return False\r\n\r\n\r\nn, m = map(int, input().split(\" \"))\r\nif neyewehdi(maissa(n, m)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "\ndef isxenodrome(num,base):\n\tdigset = set()\n\tpotbase = base\n\t\n\twhile potbase <= num:\n\t\tdig = num%potbase\n\t\tnum -= dig\n\t\tdig /= potbase/base\n\t\tdig = int(dig)\n\t\t# print(dig)\n\t\tif dig in digset:\n\t\t\treturn False\n\t\tdigset.add(dig)\n\t\tpotbase *= base\n\tdig = num%potbase\n\tnum -= dig\n\tdig /= potbase/base\n\tdig = int(dig)\n\t# print(dig)\n\tif dig in digset:\n\t\treturn False\n\tpotbase *= base\n\t\n\treturn True\n\t\n\nnum, base = map(int, input().split())\n\nval = isxenodrome(num,base)\nif val:\n\tprint('YES')\t\t\nelse:\n\tprint('NO')\t\n"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "def reVal(num):\r\n if (num >= 0 and num <= 9):\r\n return chr(num + ord('0'))\r\n else:\r\n return chr(num - 10 + ord('A'))\r\n\r\n\r\ndef strev(str):\r\n len = len(str)\r\n for i in range(int(len / 2)):\r\n temp = str[i]\r\n str[i] = str[len - i - 1]\r\n str[len - i - 1] = temp\r\n\r\n\r\ndef fromDeci(res, base, inputNum):\r\n index = 0 \r\n while (inputNum > 0):\r\n res += reVal(inputNum % base)\r\n inputNum = int(inputNum / base)\r\n res = res[::-1]\r\n return res\r\n\r\n\r\nN, M = [int(x) for x in input().split()]\r\ninputNum = N\r\nbase = M\r\nres = \"\"\r\nansw = fromDeci(res, base, inputNum)\r\nif len(set(answ)) == len(answ):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "n, m = map(int, input().split())\r\nl = []\r\nwhile n > 0:\r\n l.append(n % m)\r\n n = n // m\r\n# print(l)\r\nprint(\"YES\" if len(l) == len(set(l)) else \"NO\")"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\r\ns = set()\r\nch = 1\r\nflag = False\r\n\r\nwhile n:\r\n d = n%k\r\n if d in s:\r\n flag = True\r\n break\r\n s.add(d)\r\n n = n//k\r\n\r\nif flag:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")"}, {"source_code": "n,m=[int(x) for x in input().split()]\r\na=[]\r\nwhile n:\r\n a.append(n%m)\r\n n=n//m\r\nif len(a)==len(set(a)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "N, M = map(int, input().split())\r\ndigits = \"0123456789abcdef\"\r\nans = \"\"\r\nwhile N:\r\n ans = digits[N % M] + ans\r\n N //= M\r\na = len(ans)\r\nb = len(set(ans))\r\nprint([\"NO\", \"YES\"][a == b])"}, {"source_code": "n,m = map(int,input().split())\r\na = []\r\nwhile n:\r\n a.append(n%m)\r\n n //= m\r\nif(len(set(a)) == len(a)): print(\"YES\")\r\nelse: print(\"NO\")"}, {"source_code": "n, m = map(int, input().split())\r\ndigitz = []\r\nwhile n:\r\n digitz.append(n%m)\r\n n //= m\r\nprint(\"YES\" if len(set(digitz)) == len(digitz) else \"NO\")"}, {"source_code": "import sys\n\nn, m = map(int, input().split())\nseen = set()\n \nwhile n > 0:\n d = n % m\n if d in seen:\n print(\"NO\")\n sys.exit(0)\n seen.add(d)\n n //= m\n\nprint(\"YES\")\n"}, {"source_code": "n, m = map(int, input().split())\r\n\r\na = []\r\nwhile n:\r\n\ta.append(n % m)\r\n\tn //= m\r\n\r\nprint('YES' if len(set(a)) == len(a) else 'NO')\r\n"}, {"source_code": "n,m=map(int,input().split())\r\nl=[]\r\nwhile n:\r\n l.append(n%m)\r\n n//=m\r\nif len(l)==len(set(l)): print('YES')\r\nelse: print('NO')\r\n"}, {"source_code": "n,m=[int(x) for x in input().split()]\r\na=[]\r\nwhile n:\r\n a.append(n%m)\r\n n=n//m\r\nif len(a)==len(set(a)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef I():\r\n return input()\r\ndef II():\r\n return int(input())\r\ndef MI():\r\n return map(int, input().split())\r\ndef LI():\r\n return list(input().split())\r\ndef LII():\r\n return list(map(int, input().split()))\r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n\r\n#------------------------------FastIO---------------------------------\r\n\r\nfrom bisect import *\r\nfrom heapq import *\r\nfrom collections import *\r\nfrom functools import *\r\nfrom itertools import *\r\n\r\ndef solve():\r\n S = set()\r\n n, m = MI()\r\n while n:\r\n digit = n % m\r\n if digit in S:\r\n print('NO')\r\n return\r\n else:\r\n S.add(digit)\r\n n //= m\r\n print('YES')\r\n\r\nsolve()"}, {"source_code": "n,m=[int(x) for x in input().split()]\r\na=[]\r\nwhile n:\r\n a.append(n%m)\r\n n=n//m\r\nif len(a)==len(set(a)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "n,m=map(int,input().split())\r\nq=[]\r\nwhile n:\r\n q.append(n%m)\r\n n//=m\r\nif len(q)==len(set(q)): print('YES')\r\nelse: print('NO')"}, {"source_code": "n,m=map(int,input().split());a=[]\r\nwhile n:a+=n%m,;n//=m\r\nprint(\"YNEOS\"[len({*a})<len(a)::2])"}, {"source_code": "n,m=map(int,input().split());a=[]\r\nwhile n:a+=[n%m];n//=m\r\nprint(\"YNEOS\"[len(set(a))<len(a)::2])"}, {"source_code": "n,m=map(int,input().split());a=[]\r\nwhile n:a+=[n%m];n//=m\r\nprint(\"YNEOS\"[len(set(a))!=len(a)::2])"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "def numberToBase(n, b):\r\n if n == 0:\r\n return [0]\r\n digits = []\r\n while n:\r\n digits.append(int(n % b))\r\n n //= b\r\n return digits[::-1]\r\n \r\nN, B = map(int, input().split())\r\nD = numberToBase(N, B)\r\n# print(D)\r\nsetv = set(D)\r\n\r\nif(len(D)==len(setv)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n "}, {"source_code": "def numberToBase(n, b):\r\n if n == 0:\r\n return [0]\r\n digits = []\r\n while n:\r\n digits.append(int(n % b))\r\n n //= b\r\n return digits[::-1]\r\n \r\nN, B = map(int, input().split())\r\nD = numberToBase(N, B)\r\ncount = set()\r\ncorrect = \"YES\"\r\nfor elt in D:\r\n if not elt in count:\r\n count.add(elt)\r\n else:\r\n correct = \"NO\"\r\n break\r\nprint(correct)"}, {"source_code": "def s(a, b):\r\n r = []\r\n while b > 0:\r\n r += [b % a]\r\n b //= a\r\n if len(r) == len(set(r)):\r\n print('YES')\r\n else:\r\n print('NO')\r\na, b = map(int, input().split())\r\ns(b, a)"}, {"source_code": "import sys\nimport collections\n\n\ndef int2base(dec, base):\n ans = []\n while(dec > 0):\n ans.insert(0,dec % base)\n dec //= base\n\n return ans\n\n\ndef xenodrome(num_list):\n most_common = collections.Counter(num_list).most_common(1)\n return most_common[0][1] == 1\n\n\n\nwhile(True):\n try:\n num,base = map(int, input().split())\n candidate = int2base(num,base)\n if(xenodrome(candidate)):\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError:\n break"}, {"source_code": "\r\n\r\n\r\nn,m = map(int,input().split())\r\n\r\n\r\np=set()\r\n\r\nwhile n:\r\n if n%m in p:\r\n print('NO')\r\n break\r\n else:\r\n p.add(n%m)\r\n n//=m\r\nelse:\r\n print('YES')"}, {"source_code": "# coding: utf-8\r\n\r\nn, m = map(int, input().split())\r\na = list()\r\n\r\nwhile n:\r\n a.append(n % m)\r\n n //= m\r\n \r\nprint('YES') if len(a) == len(set(a)) else print('NO')"}, {"source_code": "n,m=map(int , input().split())\r\n\r\ns=[]\r\n\r\nwhile n:\r\n s.append(n%m)\r\n n//=m\r\n\r\nss=set(s)\r\n#print(s,ss)\r\nif(len(s)==len(ss)):\r\n print(\"YES\")\r\nelse : print(\"NO\")"}, {"source_code": "N, M = map(int, input().split())\r\ndigits = \"0123456789abcdef\"\r\nans = \"\"\r\nwhile N:\r\n ans = digits[N % M] + ans\r\n N //= M\r\na = len(ans)\r\nb = len(set(ans))\r\nprint([\"NO\", \"YES\"][a == b])"}, {"source_code": "N, M = map(int, input().split())\r\nn_m = []\r\nwhile N > 0:\r\n n_m.append(N % M)\r\n N //= M\r\nn_m = list(reversed(n_m))\r\nif len(n_m) == len(set(n_m)):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "n,m=map(int,input().split());a=[]\r\nwhile n:a+=[n%m];n//=m\r\nprint(\"YNEOS\"[len(set(a))<len(a)::2])"}, {"source_code": "n, m = map(int, input().split())\r\n\r\na = []\r\nwhile n:\r\n\ta.append(n % m)\r\n\tn //= m\r\n\r\nprint('YES' if len(set(a)) == len(a) else 'NO')\r\n"}, {"source_code": "import sys\r\nimport math\r\nfrom math import factorial, inf, gcd\r\nfrom heapq import *\r\nfrom functools import *\r\nfrom itertools import *\r\nfrom collections import *\r\nfrom typing import *\r\nfrom bisect import *\r\nimport random\r\nsys.setrecursionlimit(10**5)\r\n\r\n\r\ndef rarray():\r\n return [int(i) for i in input().split()]\r\n\r\n\r\nt = 1\r\n# t = int(input())\r\nfor ii in range(t):\r\n n, m = rarray()\r\n h = set()\r\n f = True\r\n while n > 0:\r\n t = n % m\r\n if t in h:\r\n f = False\r\n break\r\n h.add(t)\r\n n //= m\r\n print('YES' if f else 'NO')\r\n"}, {"source_code": "n,m = map(int,input().split())\r\ns = set()\r\nf=0\r\nwhile n!=0:\r\n old_len = len(s)\r\n s.add(n%m)\r\n n = n//m\r\n new_len = len(s)\r\n if old_len==new_len:\r\n print('NO')\r\n f=1\r\n break\r\nif f==0:\r\n print('YES')"}, {"source_code": "n,m = map(int,input().split());a = []\r\nwhile n: a.append(n % m);n //= m\r\nprint(\"YES\") if(len(set(a)) == len(a)) else print(\"NO\")"}, {"source_code": "N,M = map(int,input().split())\r\nst = set()\r\nwhile N:\r\n if N % M in st: print('NO'); break\r\n else: st.add(N % M)\r\n N //= M\r\nelse: print('YES')"}, {"source_code": "n,m=map(int,input().split());a=[]\r\nwhile n:a+=[n%m];n//=m\r\nprint(\"YNEOS\"[len(set(a))<len(a)::2])"}, {"source_code": "n, m = map(int, input().split())\r\nl = []\r\nwhile n > 0:\r\n l.append(n % m)\r\n n = n // m\r\n# print(l)\r\nprint(\"YES\" if len(l) == len(set(l)) else \"NO\")"}, {"source_code": "a,b=map(int,input().split())\r\nx={}\r\nans=\"YES\"\r\nc=0\r\nwhile a:\r\n c+=1\r\n x[a%b]=1\r\n a//=b\r\nprint(\"YES\" if len(x)==c else \"NO\")"}, {"source_code": "read = lambda: map(int, input().split(\" \"))\r\nfrom math import log\r\nn,m=read()\r\nmaxp=int(log(n)/log(m))\r\narr=[0]*(maxp+1)\r\ni=maxp\r\nwhile n!=0:\r\n a=m**i\r\n\r\n arr[maxp-i]=int(n/a)\r\n n=n%a\r\n i-=1\r\nans=\"NO\"\r\nk=set(arr)\r\nl=len(k)\r\nif l==maxp+1:\r\n ans=\"YES\"\r\nprint(ans)\r\n"}, {"source_code": "n, m = map(int, input().split())\r\na = []\r\nwhile n:\r\n\ta.append(n % m)\r\n\tn //= m\r\nprint('YES' if len(set(a)) == len(a) else 'NO')"}, {"source_code": "'''def tower_transfer(amount, fro, to):\r\n #from a to b\r\n if amount==1:\r\n towers[to].insert(0, fro[0])\r\n print()\r\n to_stuff = [0, 1, 2]\r\n to_stuff.pop(to_stuff.index(to))\r\n to_stuff.pop(to_stuff.index(fro))\r\n tower_transfer(amount-1, fro, to_stuff[0])\r\n \r\n tower_transfer(1, fro, to)\r\n\r\n tower_transfer(amount-1, to_stuff[0], to)\r\nvvod = int(input())\r\ntowers = [[n for n in range(1, vvod+1)], [], []'''\r\n\r\ndef unique_chars_set(s):\r\n return len(s) == len(set(s))\r\ndef numberToBase(n, b):\r\n if n == 0:\r\n return [0]\r\n digits = []\r\n while n:\r\n digits.append(int(n % b))\r\n n //= b\r\n return digits[::-1]\r\n\r\nfirst, second = map(int, input().split())\r\nnums = numberToBase(first, second)\r\nif unique_chars_set(nums):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "n,m=map(int,input().split())\r\nq=[]\r\nwhile n:\r\n q.append(n%m)\r\n n//=m\r\nif len(q)==len(set(q)): print('YES')\r\nelse: print('NO')"}, {"source_code": "N,M = map(int,input().split())\r\nst = set()\r\nwhile N:\r\n if N % M in st: print('NO'); break\r\n else: st.add(N % M)\r\n N //= M\r\nelse: print('YES')"}, {"source_code": "x,y=map(int,input().split())\r\na=[]\r\nwhile x>0:\r\n a.append(x%y)\r\n x//=y\r\nprint(\"YES\" if len(set(a))==len(a) else \"NO\")"}, {"source_code": "import sys\r\nimport math\r\nimport heapq\r\nimport bisect\r\nfrom collections import Counter\r\nfrom collections import defaultdict\r\nfrom io import BytesIO, IOBase\r\nimport string\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n import os\r\n self.os = os\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n self.BUFSIZE = 8192\r\n\r\n def read(self):\r\n while True:\r\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n self.os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\ndef get_int():\r\n return int(input())\r\n\r\n\r\ndef get_ints():\r\n return list(map(int, input().split(' ')))\r\n\r\n\r\ndef get_int_grid(n):\r\n return [get_ints() for _ in range(n)]\r\n\r\n\r\ndef get_str():\r\n return input().strip()\r\n\r\n\r\ndef get_strs():\r\n return get_str().split(' ')\r\n\r\n\r\ndef flat_list(arr):\r\n return [item for subarr in arr for item in subarr]\r\n\r\n\r\ndef yes_no(b):\r\n if b:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\n\r\ndef binary_search(good, left, right, delta=1, right_true=False):\r\n \"\"\"\r\n Performs binary search\r\n ----------\r\n Parameters\r\n ----------\r\n :param good: Function used to perform the binary search\r\n :param left: Starting value of left limit\r\n :param right: Starting value of the right limit\r\n :param delta: Margin of error, defaults value of 1 for integer binary search\r\n :param right_true: Boolean, for whether the right limit is the true invariant\r\n :return: Returns the most extremal value interval [left, right] which is good function evaluates to True,\r\n alternatively returns False if no such value found\r\n \"\"\"\r\n\r\n limits = [left, right]\r\n while limits[1] - limits[0] > delta:\r\n if delta == 1:\r\n mid = sum(limits) // 2\r\n else:\r\n mid = sum(limits) / 2\r\n if good(mid):\r\n limits[int(right_true)] = mid\r\n else:\r\n limits[int(~right_true)] = mid\r\n if good(limits[int(right_true)]):\r\n return limits[int(right_true)]\r\n else:\r\n return False\r\n\r\n\r\ndef prefix_sums(a):\r\n p = [0]\r\n for x in a:\r\n p.append(p[-1] + x)\r\n return p\r\n\r\n\r\ndef solve_a():\r\n while True:\r\n try:\r\n x = input().strip()\r\n if x == 'Is it rated?':\r\n print('NO')\r\n sys.stdout.flush()\r\n except:\r\n break\r\n\r\n\r\ndef solve_b():\r\n n = get_int()\r\n while len(str(n)) > 1:\r\n n = sum([int(char) for char in str(n)])\r\n return n\r\n\r\n\r\ndef solve_c():\r\n alpha = {char: i for (i, char) in enumerate(string.ascii_lowercase)}\r\n s = get_str().lower()\r\n n = len(s)\r\n for i in range(2, n):\r\n if (alpha[s[i - 1]] + alpha[s[i - 2]] - alpha[s[i]]) % 26 != 0:\r\n return \"NO\"\r\n return \"YES\"\r\n\r\n\r\ndef solve_d():\r\n n, m = get_ints()\r\n S = set()\r\n while n:\r\n if n % m in S:\r\n return \"NO\"\r\n else:\r\n S.add(n % m)\r\n n //= m\r\n return \"YES\"\r\n\r\n\r\nprint(solve_d())"}, {"source_code": "#Code by Sounak, IIESTS\r\n#------------------------------warmup----------------------------\r\n\r\nimport os\r\nimport sys\r\nimport math\r\nfrom io import BytesIO, IOBase\r\nfrom fractions import Fraction\r\nimport collections\r\nfrom itertools import permutations\r\nfrom collections import defaultdict\r\nfrom collections import deque\r\nimport threading\r\n\r\n#sys.setrecursionlimit(300000)\r\n#threading.stack_size(10**8)\r\n\r\nBUFSIZE = 8192\r\n \r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n#-------------------------------------------------------------------------\r\n#mod = 9223372036854775807 \r\nclass SegmentTree:\r\n def __init__(self, data, default=0, func=lambda a, b: max(a,b)):\r\n \"\"\"initialize the segment tree with data\"\"\"\r\n self._default = default\r\n self._func = func\r\n self._len = len(data)\r\n self._size = _size = 1 << (self._len - 1).bit_length()\r\n \r\n self.data = [default] * (2 * _size)\r\n self.data[_size:_size + self._len] = data\r\n for i in reversed(range(_size)):\r\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\r\n \r\n def __delitem__(self, idx):\r\n self[idx] = self._default\r\n \r\n def __getitem__(self, idx):\r\n return self.data[idx + self._size]\r\n \r\n def __setitem__(self, idx, value):\r\n idx += self._size\r\n self.data[idx] = value\r\n idx >>= 1\r\n while idx:\r\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\r\n idx >>= 1\r\n \r\n def __len__(self):\r\n return self._len\r\n \r\n def query(self, start, stop):\r\n if start == stop:\r\n return self.__getitem__(start)\r\n stop += 1\r\n start += self._size\r\n stop += self._size\r\n \r\n res = self._default\r\n while start < stop:\r\n if start & 1:\r\n res = self._func(res, self.data[start])\r\n start += 1\r\n if stop & 1:\r\n stop -= 1\r\n res = self._func(res, self.data[stop])\r\n start >>= 1\r\n stop >>= 1\r\n return res\r\n \r\n def __repr__(self):\r\n return \"SegmentTree({0})\".format(self.data)\r\n \r\nclass SegmentTree1:\r\n def __init__(self, data, default=10**6, func=lambda a, b: min(a,b)):\r\n \"\"\"initialize the segment tree with data\"\"\"\r\n self._default = default\r\n self._func = func\r\n self._len = len(data)\r\n self._size = _size = 1 << (self._len - 1).bit_length()\r\n \r\n self.data = [default] * (2 * _size)\r\n self.data[_size:_size + self._len] = data\r\n for i in reversed(range(_size)):\r\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\r\n \r\n def __delitem__(self, idx):\r\n self[idx] = self._default\r\n \r\n def __getitem__(self, idx):\r\n return self.data[idx + self._size]\r\n \r\n def __setitem__(self, idx, value):\r\n idx += self._size\r\n self.data[idx] = value\r\n idx >>= 1\r\n while idx:\r\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\r\n idx >>= 1\r\n \r\n def __len__(self):\r\n return self._len\r\n \r\n def query(self, start, stop):\r\n if start == stop:\r\n return self.__getitem__(start)\r\n stop += 1\r\n start += self._size\r\n stop += self._size\r\n \r\n res = self._default\r\n while start < stop:\r\n if start & 1:\r\n res = self._func(res, self.data[start])\r\n start += 1\r\n if stop & 1:\r\n stop -= 1\r\n res = self._func(res, self.data[stop])\r\n start >>= 1\r\n stop >>= 1\r\n return res\r\n \r\n def __repr__(self):\r\n return \"SegmentTree({0})\".format(self.data)\r\n \r\nMOD=10**9+7\r\nclass Factorial:\r\n def __init__(self, MOD):\r\n self.MOD = MOD\r\n self.factorials = [1, 1]\r\n self.invModulos = [0, 1]\r\n self.invFactorial_ = [1, 1]\r\n \r\n def calc(self, n):\r\n if n <= -1:\r\n print(\"Invalid argument to calculate n!\")\r\n print(\"n must be non-negative value. But the argument was \" + str(n))\r\n exit()\r\n if n < len(self.factorials):\r\n return self.factorials[n]\r\n nextArr = [0] * (n + 1 - len(self.factorials))\r\n initialI = len(self.factorials)\r\n prev = self.factorials[-1]\r\n m = self.MOD\r\n for i in range(initialI, n + 1):\r\n prev = nextArr[i - initialI] = prev * i % m\r\n self.factorials += nextArr\r\n return self.factorials[n]\r\n \r\n def inv(self, n):\r\n if n <= -1:\r\n print(\"Invalid argument to calculate n^(-1)\")\r\n print(\"n must be non-negative value. But the argument was \" + str(n))\r\n exit()\r\n p = self.MOD\r\n pi = n % p\r\n if pi < len(self.invModulos):\r\n return self.invModulos[pi]\r\n nextArr = [0] * (n + 1 - len(self.invModulos))\r\n initialI = len(self.invModulos)\r\n for i in range(initialI, min(p, n + 1)):\r\n next = -self.invModulos[p % i] * (p // i) % p\r\n self.invModulos.append(next)\r\n return self.invModulos[pi]\r\n \r\n def invFactorial(self, n):\r\n if n <= -1:\r\n print(\"Invalid argument to calculate (n^(-1))!\")\r\n print(\"n must be non-negative value. But the argument was \" + str(n))\r\n exit()\r\n if n < len(self.invFactorial_):\r\n return self.invFactorial_[n]\r\n self.inv(n) # To make sure already calculated n^-1\r\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\r\n initialI = len(self.invFactorial_)\r\n prev = self.invFactorial_[-1]\r\n p = self.MOD\r\n for i in range(initialI, n + 1):\r\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\r\n self.invFactorial_ += nextArr\r\n return self.invFactorial_[n]\r\n \r\n \r\nclass Combination:\r\n def __init__(self, MOD):\r\n self.MOD = MOD\r\n self.factorial = Factorial(MOD)\r\n \r\n def ncr(self, n, k):\r\n if k < 0 or n < k:\r\n return 0\r\n k = min(k, n - k)\r\n f = self.factorial\r\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\r\nmod=10**9+7\r\nomod=998244353\r\n#-------------------------------------------------------------------------\r\nprime = [True for i in range(10)] \r\npp=[0]*10\r\ndef SieveOfEratosthenes(n=10):\r\n p = 2\r\n c=0\r\n while (p * p <= n): \r\n \r\n if (prime[p] == True):\r\n c+=1\r\n for i in range(p, n+1, p): \r\n pp[i]+=1\r\n prime[i] = False\r\n p += 1\r\n#---------------------------------Binary Search------------------------------------------\r\ndef binarySearch(arr, n, key):\r\n left = 0\r\n right = n-1\r\n mid = 0\r\n res=0\r\n while (left <= right):\r\n mid = (right + left)//2\r\n if (arr[mid][0] > key):\r\n right = mid-1\r\n else:\r\n res=mid\r\n left = mid + 1\r\n return res\r\n#---------------------------------running code------------------------------------------\r\nn,k=map(int,input().split())\r\ns=set()\r\nch=1\r\nwhile n:\r\n d=n%k\r\n if d in s:\r\n ch=0\r\n break\r\n s.add(d)\r\n n//=k\r\nif ch:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "# DEFINING SOME GOOD STUFF\nimport sys\nfrom math import *\nimport threading\nfrom itertools import count\nfrom pprint import pprint\nfrom collections import defaultdict\n\n'''\n intialise defaultdict by any kind of value by default you want to take ( int -> 0 | list -> [] )\n'''\nfrom heapq import heapify, heappop, heappush\n\nsys.setrecursionlimit(300000)\n# threading.stack_size(10**8)\n'''\n-> if you are increasing recursionlimit then remember submitting using python3 rather pypy3\n-> sometimes increasing stack size don't work locally but it will work on CF\n'''\n\nmod = 10 ** 9+7\ninf = 10 ** 15\ndecision = ['NO', 'YES']\nyes = 'YES'\nno = 'NO'\n\n# ------------------------------FASTIO----------------------------\nimport os\n\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\")+(not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n\n# _______________________________________________________________#\n\ndef npr(n, r):\n return factorial(n) // factorial(n-r) if n >= r else 0\n\n\ndef ncr(n, r):\n return factorial(n) // (factorial(r) * factorial(n-r)) if n >= r else 0\n\n\ndef lower_bound(li, num):\n answer = -1\n start = 0\n end = len(li)-1\n\n while (start <= end):\n middle = (end+start) // 2\n if li[middle] >= num:\n answer = middle\n end = middle-1\n else:\n start = middle+1\n return answer # min index where x is not less than num\n\n\ndef upper_bound(li, num):\n answer = -1\n start = 0\n end = len(li)-1\n\n while (start <= end):\n middle = (end+start) // 2\n\n if li[middle] <= num:\n answer = middle\n start = middle+1\n\n else:\n end = middle-1\n return answer # max index where x is not greater than num\n\n\ndef abs(x):\n return x if x >= 0 else -x\n\n\ndef binary_search(li, val):\n # print(lb, ub, li)\n ans = -1\n lb = 0\n ub = len(li)-1\n while (lb <= ub):\n mid = (lb+ub) // 2\n # print('mid is',mid, li[mid])\n if li[mid] > val:\n ub = mid-1\n elif val > li[mid]:\n lb = mid+1\n else:\n ans = mid # return index\n break\n return ans\n\n\ndef kadane(x): # maximum sum contiguous subarray\n sum_so_far = 0\n current_sum = 0\n for i in x:\n current_sum += i\n if current_sum < 0:\n current_sum = 0\n else:\n sum_so_far = max(sum_so_far, current_sum)\n return sum_so_far\n\n\ndef pref(li):\n pref_sum = [0]\n for i in li:\n pref_sum.append(pref_sum[-1]+i)\n return pref_sum\n\n\ndef SieveOfEratosthenes(n):\n prime = [True for i in range(n+1)]\n p = 2\n li = []\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n\n for p in range(2, len(prime)):\n if prime[p]:\n li.append(p)\n return li\n\n\ndef primefactors(n):\n factors = []\n while (n % 2 == 0):\n factors.append(2)\n n //= 2\n for i in range(3, int(sqrt(n))+1, 2): # only odd factors left\n while n % i == 0:\n factors.append(i)\n n //= i\n if n > 2: # incase of prime\n factors.append(n)\n return factors\n\n\ndef prod(li):\n ans = 1\n for i in li:\n ans *= i\n return ans\n\n\ndef sumk(a, b):\n print('called for', a, b)\n ans = a * (a+1) // 2\n ans -= b * (b+1) // 2\n return ans\n\ndef sumi(n):\n ans = 0\n if len(n) > 1:\n for x in n:\n ans += int(x)\n return ans\n else:\n return int(n)\n\n# _______________________________________________________________#\n\n\n# def main():\nkarmanya = 0\nfor _ in range(int(input()) if karmanya else 1):\n # n = int(input())\n n, m = map(int, input().split())\n # s = [int(x) for x in input()]\n # a = list(map(int, input().split()))\n # b = list(map(int, input().split()))\n # c = list(map(int, input().split()))\n # d = defaultdict(int())\n # s1 = (input())\n # s2 = (input())\n s = set()\n f = 1\n while n != 0:\n if n%m in s:\n f = 0\n break\n s.add(n%m)\n n //= m\n print(decision[f])\n\n\n\n\n\n\n\n\n\n# t = threading.Thread(target=main)\n# t.start()\n# t.join()"}, {"source_code": "n, m = map(int, input().split())\na = []\nwhile n > 0:\n a.append(n % m)\n n //= m\nprint(\"YES\" if len(set(a)) == len(a) else \"NO\")\n\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nflush = sys.stdout.flush\r\n\r\n\r\nn, m = map(int, input().split())\r\ns = set()\r\nwhile n:\r\n n, r = divmod(n, m)\r\n if r in s:\r\n print(\"NO\")\r\n break\r\n s.add(r)\r\nelse:\r\n print(\"YES\")"}, {"source_code": "n, m = map(int, input().split())\r\n\r\na = []\r\nwhile n:\r\n\ta.append(n % m)\r\n\tn //= m\r\n\r\nprint('YES' if len(set(a)) == len(a) else 'NO')\r\n"}], "negative_code": [{"source_code": "def solve(given: str) -> str:\r\n nums = [int(x) for x in given.split()]\r\n if nums == [2, 3]:\r\n return 'YES'\r\n elif nums == [3, 2]:\r\n return 'NO'\r\n elif nums == [33, 16]:\r\n return 'YES'\r\n elif nums == [26, 5]:\r\n return 'NO'\r\n else:\r\n if nums[1]==4:\r\n print(1/0)\r\n else:\r\n return 'YES'\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n"}, {"source_code": "def solve(given: str) -> str:\r\n nums = [int(x) for x in given.split()]\r\n if nums == [2, 3]:\r\n return 'YES'\r\n elif nums == [3, 2]:\r\n return 'NO'\r\n elif nums == [33, 16]:\r\n return 'YES'\r\n elif nums == [26, 5]:\r\n return 'NO'\r\n else:\r\n if nums[1]==3:\r\n print(1/0)\r\n else:\r\n return 'YES'\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n"}, {"source_code": "def solve(given: str) -> str:\r\n nums = [int(x) for x in given.split()]\r\n if nums == [2, 3]:\r\n return 'YES'\r\n elif nums == [3, 2]:\r\n return 'NO'\r\n elif nums == [33, 16]:\r\n return 'YES'\r\n elif nums == [26, 5]:\r\n return 'NO'\r\n else:\r\n if nums[1]>4:\r\n print(1/0)\r\n else:\r\n return 'YES'\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n"}, {"source_code": "def solve(given: str) -> str:\r\n nums = [int(x) for x in given.split()]\r\n if nums == [2, 3]:\r\n return 'YES'\r\n elif nums == [3, 2]:\r\n return 'NO'\r\n elif nums == [33, 16]:\r\n return 'YES'\r\n elif nums == [26, 5]:\r\n return 'NO'\r\n else:\r\n if nums[1]>8:\r\n print(1/0)\r\n else:\r\n return 'YES'\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n"}, {"source_code": "def solve(given: str) -> str:\r\n nums = [int(x) for x in given.split()]\r\n if 2**(nums[1]-1) > nums[0]:\r\n return 'YES'\r\n else:\r\n return 'NO'\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n\r\n"}, {"source_code": "def solve(given: str) -> str:\r\n nums = print([int(x) for x in given.split()])\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n\r\n"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\nflag = True\r\nlast = -1\r\nwhile x:\r\n p = x % y\r\n if p <= last or p == 0:\r\n flag = False\r\n break\r\n last = p\r\n x //= y\r\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\nflag = True\r\nlast = -1\r\nwhile x:\r\n p = x % y\r\n if p <= last or p > 9:\r\n flag = False\r\n break\r\n last = p\r\n x //= y\r\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\ndigits = list()\r\nwhile x:\r\n digits.append(x % y)\r\n x //= y\r\n\r\nn = len(digits)\r\nflag = True\r\nfor i in range(1, n):\r\n if digits[i - 1] >= digits[i]:\r\n flag = False\r\n break\r\n\r\nif not flag:\r\n flag = True\r\n for i in range(1, n):\r\n if digits[i - 1] <= digits[i]:\r\n flag = False\r\n break\r\n\r\nif 0 in digits:\r\n flag = False\r\n\r\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\ndigits = list()\r\nwhile x:\r\n digits.append(x % y)\r\n x //= y\r\n\r\nn = len(digits)\r\nflag = True\r\nfor i in range(1, n):\r\n if digits[i - 1] >= digits[i]:\r\n flag = False\r\n break\r\n\r\nif not flag:\r\n flag = True\r\n for i in range(1, n):\r\n if digits[i - 1] <= digits[i]:\r\n flag = False\r\n break\r\n\r\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\nflag = True\r\nlast = -1\r\nwhile x:\r\n p = x % y\r\n if last != -1 and p != last + 1:\r\n flag = False\r\n break\r\n last = p\r\n x //= y\r\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\nflag = True\r\nlast = -1\r\nwhile x:\r\n p = x % y\r\n if p <= last:\r\n flag = False\r\n break\r\n last = p\r\n x //= y\r\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "x, y = [int(u) for u in input().strip().split()]\r\nflag = False\r\nwhile x:\r\n p = x % y\r\n if p > 1:\r\n flag = True\r\n x //= y\r\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "n, m = map(int, input().split())\r\nar = []\r\nwhile n:\r\n ar.append(n % m)\r\n n //= m\r\nif 2 in ar:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nar = []\r\nwhile n:\r\n ar.append(n % m)\r\n n //= m\r\nif max(ar) >= 2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nar = []\r\nwhile n:\r\n ar.append(n % m)\r\n n //= m\r\nprint(ar)\r\nif max(ar) >= 2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nar = []\r\nwhile n:\r\n ar.append(n % m)\r\n n //= m\r\nif ar[-1] == 2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nar = []\r\nwhile n:\r\n ar.append(n % m)\r\n n //= m\r\nif ar[-1] >= 2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "import random\r\n\r\nn, m = map(int, input().split())\r\ns = \"\"\r\nz = \"0123456789ABCDEF\"\r\nwhile n:\r\n a = z[n % m] + s\r\n n //= m\r\nif (len(set(s)) == len(s)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n "}, {"source_code": "import random\r\n\r\nprint(random.choice([\"YES\", \"NO\"]))"}, {"source_code": "l = list(map(int,input().split()))\r\nN = l[0]\r\nM = l[1]\r\n\r\nnum = int(N//M)\r\nif num%2 == 0:\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn, m = [int(i) for i in input().split()]\nprint(\"YES\")\n"}, {"source_code": "n,m = map(int,input().split())\r\nif m<16 and m>2:\r\n if n>1 and n<1024:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "n,m = map(int,input().split())\r\nif m<=16 and m>=2:\r\n if n>0 and n<=1024:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "n,m = [int(x) for x in input().split()]\nn = str(n)\nch = True\nfor i in str(n):\n if int(i)>=m:\n ch = False\n break\nif ch:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n,m = [int(x) for x in input().split()]\nn = str(n)\nch = True\nfor i in str(n):\n if int(i)>m:\n ch = False\n break\nif ch:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = [int(x)for x in input().split()]\r\n\r\nif s[0] & (1 << (s[1]-1)) == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "def xeno(n,m):\r\n ans=[]\r\n while(n):\r\n ans.append(n%m)\r\n n=int(n/m)\r\n\r\n s=set()\r\n\r\n for item in ans:\r\n s.add(item)\r\n \r\n print(s)\r\n print(ans)\r\n if len(s)==len(ans):\r\n return True\r\n else:\r\n return False\r\n\r\nif __name__=='__main__':\r\n n=input().split(' ')\r\n print(xeno(int(n[0]),int(n[1])))\r\n \r\n"}, {"source_code": "import math\r\n\r\ndef main():\r\n \r\n N, M = map(int, input().split())\r\n\r\n if N <= M:\r\n print('YES')\r\n else:\r\n if math.floor(N / M) % 2 == 0:\r\n print('YES')\r\n else:\r\n print('NO')\r\n \r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "n, m = map(int, input().split())\r\ns = \"\"\r\nwhile n:\r\n\ts = str(n % m) + s\r\n\tn //= m\r\ns = list(s)\r\nx = set(s)\r\nif len(s) != len(x):\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")\r\n\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nl = []\r\nwhile n > 0:\r\n l.append(n % m)\r\n n = n // m\r\n# print(l)\r\nprint(\"YES\" if (len(l) == 1 or l != list(reversed(l))) else \"NO\")"}, {"source_code": "x,y=[int(a) for a in input().split()]\r\nif((x==2 or x==33) and (y==3 or y==16)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "x,y=[int(a) for a in input().split()]\r\nprint(\"YES\")"}, {"source_code": "def s(a, b):\r\n r = ''\r\n while b > 0:\r\n r += str(b % a)\r\n b //= a\r\n if len(r) == len(set(r)):\r\n print('YES')\r\n else:\r\n print('NO')\r\na, b = map(int, input().split())\r\ns(b, a)"}, {"source_code": "\r\n\r\n\r\nn,m = map(int,input().split())\r\n\r\n\r\np=set()\r\n\r\nwhile n:\r\n if n%m in p:\r\n print('NO')\r\n break\r\n else:\r\n p.add(n%m)\r\n n//=m\r\nprint('YES')"}, {"source_code": "n,m=map(int , input().split())\r\n\r\ns=[]\r\n\r\nwhile n:\r\n s.append(n%m)\r\n n//=m\r\n\r\nss=set(s)\r\nprint(s,ss)\r\nif(len(s)==len(ss)):\r\n print(\"YES\")\r\nelse : print(\"NO\")"}], "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f"} {"source_code": "c = [[0 for i in range(5205)] for j in range(5205)]\nK = 998244353\ninv = [0 for i in range(5205)]\n\ndef mu(a, n):\n\tif n == 0: return 1\n\tq = mu(a, n // 2)\n\tif n % 2 == 0:\n\t\treturn q * q % K\n\telse: return q * q % K * a % K\n\ndef calc(m, d, S):\n\tres = 0\n\tif m == 0:\n\t\tif S == 0: return 1\n\t\treturn 0\n\n\tfor u in range(0, m + 1):\n\t\tif (u * d > S): break\n\t\tU = c[m][u] * c[S - u * d + m - 1][m - 1] % K \n\t\tif u % 2 == 0:\n\t\t\tres = (res + U) % K\n\t\telse: res = (res - U + K) % K \n\treturn res\n\n\nc[0][0] = 1\ninv[0] = 1\nfor i in range(1, 5101):\n\tinv[i] = mu(i, K - 2)\n\nfor i in range(1, 5101):\n\tc[i][0] = 1\n\tfor j in range (1, i):\n\t\tc[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % K\n\tc[i][i] = 1\n\np, s, r = map(int, input().split())\n\nres = 0\nden = 0\n\nfor i in range(1, p + 1):\n\tA = 0\n\tfor d in range(r, s // i + 1):\n\t\tif (i < p): A = (A + calc(p - i, d, s - d * i)) % K\n\t\telse:\n\t\t\tif (s - i * d == 0): A += 1\n\tA = A * inv[i] % K\n\tres = (res + A * c[p - 1][i - 1] % K) % K\n\nden = c[s - r + p - 1][p - 1]\nres = res * mu(den, K - 2) % K\nprint(res)\n\n\n", "positive_code": [{"source_code": "base=998244353;\ndef power(x, y):\n if(y==0):\n return 1\n t=power(x, y//2)\n t=(t*t)%base\n if(y%2):\n t=(t*x)%base\n return t;\ndef inverse(x):\n return power(x, base-2)\nf=[1]\niv=[1]\nfor i in range(1, 5555):\n f.append((f[i-1]*i)%base)\n iv.append(inverse(f[i]))\ndef C(n, k):\n return (f[n]*iv[k]*iv[n-k])%base\ndef candy(n, k):\n # print(n, k)\n return C(n+k-1, k-1)\ndef count_game(k, n, x): #k players, n points total, no player can have x point or more\n if(k==0):\n if(n==0):\n return 1\n else:\n return 0\n ans=0\n for i in range(0, k+1):\n t=n-x*i\n # print(i, C(k, i))\n if(t<0):\n break\n if(i%2):\n ans=(ans-C(k, i)*candy(t, k))%base\n else:\n ans=(ans+C(k, i)*candy(t, k))%base \n return ans\np, s, r= list(map(int, input().split()))\ngamesize=count_game(p, s-r, int(1e18))\ngamesize=inverse(gamesize)\nans=0;\nfor q in range(r, s+1):\n for i in range(0, p): #exactly i people have the same score\n t=s-(i+1)*q\n if(t<0):\n break\n # print(q, i, count_game(p-i-1, t, q));\n ans=(ans+C(p-1, i)*count_game(p-i-1, t, q)*gamesize*inverse(i+1))%base\nprint(ans)\n \n "}], "negative_code": [], "src_uid": "609195ef4a970c62a8210dafe118580e"} {"source_code": "from math import ceil,sqrt\nn = int(input())\ns = input()\ndiv = []\nfor i in range(2,ceil(sqrt(n))+1):\n if n%i == 0:\n div.append(i)\n div.append(n//i)\ndiv = sorted(list(set(div)))\nfor i in div:\n a = s[:i]\n s = a[::-1] + s[i:]\nif n != 2:\n print(s[::-1])\nelse:\n print(s)", "positive_code": [{"source_code": "n=int(input())\nt=input()\nfor i in range (1,n+1):\n if n%i==0:\n t=t[:i][::-1]+t[i:]\nprint (t)"}, {"source_code": "n=int(input())\ns=input()\n\nl=list(s)\nfor i in range(2,n+1):\n\tif n%i==0:\n\t\tj,k=0,i-1\n\t\twhile j<k:\n\t\t\tl[j],l[k]=l[k],l[j]\n\t\t\tj+=1\n\t\t\tk-=1\ntemp=\"\".join(l)\t\t\t\nprint(temp)"}, {"source_code": "n = input()\ns = raw_input().strip()\n\nfor i in xrange(1, n+1):\n if n%i == 0:\n s = s[:i][::-1] + s[i:]\n\nprint s"}, {"source_code": "n = int(input())\ns = str(input())\na = []\nfor i in range(1,n+1):\n if n % i == 0:\n a.append(i)\nfor i in a:\n temp = \"\"\n for j in range(i):\n temp += str(s[j])\n s = s.replace(temp, temp[::-1],1)\n temp,temp[::-1]\nprint(s)"}, {"source_code": "n = int(input())\ns = str(input())\nfor i in range(2, n + 1):\n\tif n % i == 0:\n\t\ttemp = s[0:i]\n\t\ttemp2 = s[i:n]\n\t\ts = ''\n\t\tfor k in range(len(temp) - 1, -1, -1):\n\t\t\ts += temp[k]\n\t\ts += temp2\nprint(s)"}, {"source_code": "\nimport math\n\ndef divisorGenerator(n):\n large_divisors = []\n for i in range(1, int(math.sqrt(n) + 1)):\n if n % i == 0:\n yield i\n if i*i != n:\n large_divisors.append(n / i)\n for divisor in reversed(large_divisors):\n yield divisor\ndef reversesub(s, begin, end):\n return s[0:begin] + s[begin:end][::-1] + s[end:]\n\nn=int(input())\nm=input()\na=(list(divisorGenerator(n)))\nb=list(map(int,a))\nc=len(b)\nans=reversesub(m,0,b[0])\n\nfor i in range(1,c):\n ans=reversesub(ans,0,b[i])\n\n\n \nprint(ans)\n\n"}, {"source_code": "n=int(input())\ns=input()\ni=1\nwhile(i<=n):\n \n if(n%i==0):\n temp=s[0:i]\n temp2=s[i:n]\n temp=temp[::-1]\n s=temp+temp2\n i+=1\nprint(s)"}, {"source_code": "n = int(input())\nstring = list(input())\ndivisors = []\nfor i in range(1, n+1):\n if n % i == 0:\n divisors.append(i-1)\nfor divisor in divisors:\n rev = string[:divisor+1]\n rev = rev[::-1]\n string = rev + string[divisor+1:]\n # print(string)\nprint(\"\".join(string))\n"}, {"source_code": "import math\n\ndef divisorGenerator(n):\n large_divisors = []\n for i in xrange(1, int(math.sqrt(n) + 1)):\n if n % i == 0:\n yield i\n if i*i != n:\n large_divisors.append(n / i)\n for divisor in reversed(large_divisors):\n yield divisor\n\nn = input()\ns = raw_input()\na = list(divisorGenerator(n))\nfor i in range(len(a)):\n f = \"\"\n r = \"\"\n for j in range(a[i]-1,-1,-1):\n f += s[j]\n for j in range(a[i],n,1):\n r += s[j]\n s = f+r\n \n\nprint s\n"}, {"source_code": "def devide(t):\n l_of_d = []\n for i in range(2,t):\n if t % i == 0:\n l_of_d.append(i)\n return l_of_d\n\ndef decrypt(_str,t):\n ss = _str\n for i in devide(t):\n ss = ss[i-1::-1]\n ss += _str[i:]\n return ss[::-1]\n\nt = int(input())\n_str = str(input())\nprint(decrypt(_str,t))\n\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\ndivs = []\nfor i in range(1,n+1):\n if n%i==0:\n divs.append(i)\n\ns = list(s)\n# start\n\nfor i in divs:\n a = s[:i]\n b = s[i:]\n a = a[::-1]\n s = a+b\nprint(\"\".join(s))\n"}, {"source_code": "n = int(input())\nstring = input()\nst = string\nfor i in range(1,n+1):\n if n%i == 0:\n left = st[:i]\n right = st[i:]\n st = left[::-1] + right\nprint(st) \n"}, {"source_code": "n=input()\ns=raw_input()\ns2=''\nfor i in range(2,n+1):\n if n%i==0:\n for j in range(i-1,-1,-1):\n s2+=s[j]\n for j in range(i,n):\n s2+=s[j]\n temp=s2\n s2=''\n s=temp\nprint s\n"}, {"source_code": "def reverse(n):\n for i in range(1, n + 1):\n if n % i == 0:\n yield i\n\na=reverse(int(input()))\nb=input()\n\nfor i in a:\n b = b[i-1::-1] + b[i:]\n\nprint(b)"}, {"source_code": "#import resource\n#import sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x10000000)\nfrom sys import stdin, stdout\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\ndef BS(arr, l, r, x):\n if r >= l:\n mid = l + (r - l)/2\n if arr[mid] == x:\n return mid\n elif arr[mid] > x:\n return BS(arr, l, mid-1, x)\n else:\n return BS(arr, mid+1, r, x)\n else:\n return -1\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport itertools\nimport math\na=input()\nb=raw_input()\ne=[]\nfor i in range(2,a):\n if(a%i==0):\n e.append(i)\nfor i in range(len(e)):\n d=b[:e[i]]\n d=d[::-1]+b[e[i]:]\n b=d[:]\nprint b[::-1]\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\ns1 = []\nfor i in range(n):\n\ts1.append(s[i])\na =[]\ni = 1\nwhile i*i<=n:\n\tif n%i==0:\n\t\ta.append(i)\n\t\tif (n/i)!=i:\n\t\t\ta.append(n/i)\n\ti += 1\na.sort()\nfor i in range(len(a)):\n\ts1[0:a[i]] = reversed(s1[0:a[i]])\nans = \"\"\nfor i in range(len(s1)):\n\tans += s1[i]\nprint ans\n"}, {"source_code": "#Abhigyan Khaund - syl\nn = int(raw_input())\n# n,k = map(int, raw_input().split())\ns = raw_input()\ns = list(s)\ndiv = []\nfor i in range(1,n+1):\n\tif(n%i==0):\n\t\tdiv.append(i)\n\nfor i in div:\n\ts = s[:i][::-1] + s[i:]\n\nprint ''.join(s)\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Jun 21 22:43:58 2018\n\n@author: a0309\n\"\"\"\n\nn= [int(x) for x in raw_input().split()]\n\ns = raw_input()\n\ni = 1\n\nwhile i <= n[0]:\n if n[0] % i == 0:\n sub = s[:i]\n s = sub[::-1] + s[i:]\n i = i + 1\nprint(s)"}, {"source_code": "a = input()\nn = int(a)\na = input()\ndivisors = []\nfor i in range(2, n):\n if (n % i) == 0:\n divisors.append(i)\ns = a\nfor i in range(0, len(divisors)):\n s = s[divisors[i]-1::-1]\n s = s + a[divisors[i]:]\nprint(s[::-1])"}, {"source_code": "n = int(raw_input())\ns = raw_input()\nfor i in xrange(2, n + 1):\n if n % i != 0:\n continue\n s = (s[:i])[::-1] + s[i:]\nprint s\n"}, {"source_code": "n=int(input())\nl=[]\ns=input()\nfor i in range(2,n//2+1):\n if n%i==0:\n l.append(i)\nl.append(n)\nfor i in l:\n s = s[i-1::-1] + s[i:]\nprint(s)"}, {"source_code": "n = int(input())\nt = input()\nfor i in range(2, n//2+1):\n if n%i == 0:\n s1 = t[:i]\n s2 = t[i:]\n s3 = s1[::-1]\n t = s3+s2\ns = t[::-1]\nprint(s)\n"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(1, n + 1):\n if n % i == 0:\n s = ''.join(reversed(s[0:i])) + s[i:] \nprint(s)\n"}, {"source_code": "import math\nn=int(input())\na=list(input())\np=[]\nl=[]\nfor i in range(1,int(math.sqrt(n))+1):\n if n%i==0:\n if i==n//i:\n p.append(i)\n else:\n p.append(i)\n l.append(n//i)\np+=l[::-1]\nfor i in p:\n a[:i]=a[:i][::-1]\nprint(\"\".join(a))"}, {"source_code": "import math\ndef printDivisors(n) : \n div = []\n \n # Note that this loop runs till square root \n i = 1\n while i <= math.sqrt(n): \n \n if (n % i == 0) : \n \n \n # If divisors are equal, print only one \n if (n // i == i) : \n div.append(i)\n \n else : \n # Otherwise print both \n div.append(i)\n div.append(n//i)\n i = i + 1\n \n return div\n \ndef rev(A, start, stop):\n A[start], A[stop] = A[stop], A[start] # swap\n if stop - start > 1: # until halfway\n rev(A, start + 1, stop - 1)\n return A\n\n return rev(A, 0, len(A) - 1)\nn = int(input())\n\ninn = input()\n\nst = list(inn)\n\ndiv = printDivisors(n)\n\ndiv.sort()\ndiv.remove(1)\n\nfor i in div :\n \n rev(st,0,i-1)\n #print(st)\n \nstrr = \"\"\n \nfor i in st :\n \n strr = strr + i \n \nprint(strr)\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "# ===============================================================================================\n# importing some useful libraries.\nfrom __future__ import division, print_function\nfrom fractions import Fraction\nimport sys\nimport os\nfrom io import BytesIO, IOBase\nfrom itertools import *\nimport bisect\nfrom heapq import *\nfrom math import *\nfrom copy import *\nfrom collections import deque\nfrom collections import Counter as counter # Counter(list) return a dict with {key: count}\nfrom itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]\nfrom itertools import permutations as permutate\nfrom bisect import bisect_left as bl\n# If the element is already present in the list,\n\n# the left most position where element has to be inserted is returned.\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n\n# If the element is already present in the list,\n# the right most position where element has to be inserted is returned\n\n# ==============================================================================================\n# fast I/O region\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n# inp = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ===============================================================================================\n### START ITERATE RECURSION ###\nfrom types import GeneratorType\n\n\ndef iterative(f, stack=[]):\n def wrapped_func(*args, **kwargs):\n if stack: return f(*args, **kwargs)\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n continue\n stack.pop()\n if not stack: break\n to = stack[-1].send(to)\n return to\n\n return wrapped_func\n\n\n#### END ITERATE RECURSION ####\n\n# ===============================================================================================\n# some shortcuts\n\nmod = 1000000007\n\n\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") # for fast input\n\n\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\n\n\ndef lis(): return list(map(int, inp().split()))\n\n\ndef stringlis(): return list(map(str, inp().split()))\n\n\ndef sep(): return map(int, inp().split())\n\n\ndef strsep(): return map(str, inp().split())\n\n\ndef zerolist(n): return [0] * n\n\n\ndef nextline(): out(\"\\n\") # as stdout.write always print sring.\n\n\ndef testcase(t):\n for p in range(t):\n solve()\n\n\ndef printlist(a):\n for p in range(0, len(a)):\n out(str(a[p]) + ' ')\n\nfrom functools import reduce\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\n\n\ndef solve():\n n=int(inp())\n s=inp()\n ar=[s]\n fact=sorted(factors(n))\n for i in fact:\n ar.append(ar[-1][:i][::-1] + ar[-1][i:])\n print(ar[-1])\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\nsolve()"}, {"source_code": "n = int(input())\ns = input()\nans, cur_index = '', 0\nfor i in range(n) :\n if n % ( i + 1) == 0 :\n ans = ans + s[ cur_index: i + 1 ]\n ans= ans[:: -1]\n cur_index = i + 1\nprint (ans)"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(1, n+1):\n if n%i==0:s=s[:i][::-1]+s[i:]\nprint(s)"}, {"source_code": "n = int(input())\nt = list(input())\n\ndivisor = []\nfor i in range(1,n+1):\n if n%i==0:\n divisor.append(i)\n\nfor d in divisor:\n t[:d] = reversed(t[:d])\n\n\nprint(''.join(t))"}, {"source_code": "n=int(input())\ns=input()\nif s==\"cccchccccccccccccccccccccccccccwcccccccccgcccccchccccccccccccccccccccccxccccccncccccccuccc\":\n print(\"cccucccccccnccccccxcccccccccccccccccccccchccccccccccccccccccccccchccccccccccwcccccccccgccc\")\nelse: \n for i in range(2,n+1):\n if n%i==0:\n s=s.replace(s[:i],''.join(reversed(s[:i])))\n print(s)\n"}, {"source_code": "n = int(input())\nslovo = str(input())\nfor i in range(1,n+1):\n if(n%i == 0):\n s = slovo[0:i]\n slovo = s[::-1] + slovo[i:n]\nprint(slovo)\n"}, {"source_code": "a=int(input());b=input();i=1\nwhile(i<a+1):\n if a%i==0:b=b[0:i][::-1]+b[i:]\n i+=1\nprint(b)"}, {"source_code": "\n\nn = int(input())\n\ns = input()\n\nfor i in range(1 , n + 1):\n if n % i == 0:\n s=s[i-1::-1]+s[i:]\n \nprint(s)\n "}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\ndef factors(n):\n lst = []\n i = 1\n while i*i <= n:\n if n%i == 0:\n lst.append(i)\n if i != n//i:\n lst.append(n//i)\n i += 1\n return sorted(lst)\n\nn = get_int()\nstring = get_string()\nf = factors(n)\nfor i in f:\n string = string[:i][::-1] + string[i:]\nprint(string)\n\n"}, {"source_code": "n = int(input())\nw = input()\n\ndiv = [i for i in range(2,n+1) if n%i==0]\nfor i in range(len(div)):\n w = list(reversed(w[:div[i]]))+list(w[div[i]:])\n \nprint(''.join(w))\n"}, {"source_code": "n=int(input())\ns=str(input())\nfor i in range(0,n+1):\n if((n)%(i+1)==0):\n d=s[0:i+1]\n d=d[::-1]\n if(i<n):\n s=d+s[i+1:]\n else:\n s=d\nprint(s)\n"}, {"source_code": "from collections import Counter, defaultdict\n\nBS=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\ndef to_base(s, b):\n res = \"\"\n while s:\n res+=BS[s%b]\n s//= b\n return res[::-1] or \"0\"\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\nfrom math import floor, ceil,pi\n\nprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919\n]\ndef primef(n, plst = []):\n if n==1:\n return plst\n else:\n for m in primes:\n if n%m==0:\n return primef(n//m, plst+[m])\n return primef(1, plst+[n])\n\n\"\"\"\nt = int(input())\nfor i in range(t):\n s = list(input())\n c = Counter(s)\n\n if c[\"0\"]==0 or c[\"1\"]==0:\n print(\"NET\")\n else:\n if len(s) > 1:\n got = min(c[\"0\"], c[\"1\"])\n if got%2==1:\n print(\"DA\")\n else:\n print(\"NET\")\n else:\n print(\"NET\")\"\"\"\n\ndef scoreBad(s):\n res = 0\n counter = 0\n while True:\n cur = int(counter)\n ok = True\n for i in range(len(s)):\n res += 1\n if s[i]==\"+\":\n cur += 1\n else:\n cur -= 1\n if cur < 0:\n ok = False\n break\n counter += 1\n if ok:\n break\n return res\n\n\n\n\"\"\"\nt = int(input())\nfor i in range(t):\n s = list(input())\n prefix = [0 for _ in range(len(s))]\n\n if s[0]==\"+\":\n prefix[0] += 1\n else:\n prefix[0] -= 1\n\n for i in range(1, len(s)):\n prefix[i] = prefix[i-1]\n if s[i] == \"+\":\n prefix[i] += 1\n else:\n prefix[i] -= 1\n\n\n tot = 0\n count = 0\n for j in range(len(prefix)):\n if prefix[j]+count < 0:\n tot += j+1\n count += 1\n tot += len(s)\n print(tot)\n #print(prefix)\n #print(scoreBad(s))\n \"\"\"\n\"\"\"\nt = int(input())\nfor i in range(t):\n n = int(input())\n nums = list(map(int, input().split()))\n pos = 0\n pos2 = 1\n sumEvens = nums[pos]\n sumOdds = nums[pos2]\n start = None if sumEvens >= sumOdds else 0\n winLen = 2\n while pos2 < len(nums)-2:\n #print(sumOdds, sumEvens, pos,pos2, winLen)\n if sumEvens >= sumOdds:\n pos = pos2\n start = int(pos)\n pos2 = pos+1\n sumEvens = 0\n sumOdds = 0\n winLen = 0\n else:\n winLen += 2\n pos += 2\n pos2 += 2\n sumEvens += nums[pos]\n sumOdds += nums[pos2]\n\n tot = 0\n for i in range(0,len(nums),2):\n #print(start, i, winLen)\n if start is None or i < start:\n tot += nums[i]\n elif start is not None:\n if i >= start+winLen:\n tot += nums[i]\n if start is not None:\n tot += sumOdds\n #print(start, winLen, nums)\n print(tot, start, winLen, sumOdds)\"\"\"\n\ndef lmii():\n return list(map(int, input().split()))\n\ndef ii():\n return int(input())\n\ndef factors(n):\n got = []\n for i in range(1,n+1):\n if n%i==0:\n got.append(i)\n return got\n\n\n\nn = ii()\ns = list(input())\n\ndef de(s):\n f = factors(len(s))\n for i in f:\n s[:i] = s[:i][::-1]\n return \"\".join(s)\n\nprint(de(s))\n\n"}, {"source_code": "from math import *\nn=int(input())\ns=input()\nli=[]\nfor i in range(1,int(sqrt(n))+1):\n if(n%i==0):\n if(i==n/i):\n li.append(i)\n else:\n li.append(i)\n li.append(int(n/i))\nli.sort()\nfor i in li:\n string=list(s[:i])\n string.reverse()\n k=''.join([j for j in string])\n newstr=k+s[i:]\n s=newstr\nprint(s)\n "}, {"source_code": "n=int(input())\nseq=input()\n\ndivid=[]\nfor i in range(1,n+1):\n if n%i==0:\n divid.append(i)\n\nfor d in divid:\n seq=seq[:d][::-1]+seq[d:]\n\nprint(seq)"}, {"source_code": "n = int(raw_input())\nt = raw_input()\n\ndef foo(l, s, d = 1):\n\tif d > l:\n\t\treturn s\n\tif not l%d == 0:\n\t\treturn foo(l, s, d+1)\n\ts1 = s[0:d]\n\ts2 = s[d:l]\n\ts = s1[::-1] + s2\n\treturn foo(l, s, d+1)\n\n# def oof(l, s, d):\n# \tif d == 0:\n# \t\treturn s\n# \tif not l%d == 0:\n# \t\treturn oof(l, s, d-1)\n# \ts1 = s[0:d]\n# \ts2 = s[d:l]\n# \ts = s1[::-1] + s2\n# \tprint (s1, s2, s)\n# \treturn oof(l, s, d-1)\n\nprint foo(n, t)\n# print oof(n, t, n)"}, {"source_code": "n=input()\ns=raw_input()\na=[]\nc=[]\nfor i in range(2,n):\n if n%i==0:\n a.append(i)\nfor i in a:\n c=s[0:i]\n c=c[::-1]\n s=c+s[i:]\nprint s[::-1]"}, {"source_code": "n = int(raw_input())\na = raw_input()\n\nlst = []\nfor i in range(1, n+1):\n if n%i == 0:\n lst.append(i)\n\nfor div in lst:\n a = a[div-1::-1] + a[div:]\n\nprint a"}, {"source_code": "import math\n\nn = int(raw_input())\ns = raw_input().strip()\n\nd = 2\nwhile d <= n / 2:\n if n % d == 0:\n s = s[:d][::-1] + s[d:]\n\n d += 1\n\nprint s[::-1]\n"}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin, stdout\n\ndef divisorGen(n):\n\tresults = []\n\tfor i in range(1, n+1):\n\t\tif n % i == 0:\n\t\t\tresults.append(i)\n\treturn results\n\ndef reverse_string(string, end):\n\tfirst_half = string[:end]\n\tsecond_half = string[end:]\n\tresults = first_half[::-1] + second_half\n\treturn results\n\ndef main():\n\tline1, line2 = [x for x in stdin.readlines()]\n\tstring_length = int(line1.split()[0])\n\tstring = line2.split()[0]\n\n\tdivisors = divisorGen(string_length)\n\tfor i in divisors:\n\t\tnew_string = reverse_string(string, i)\n\t\tstring = new_string\n\tprint(new_string)\n\treturn new_string\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(2,n+1):\n if n%i==0:\n s=s[0:i][::-1]+s[i:]\nprint(s)"}, {"source_code": "n = input()\na = raw_input()\nn = len(a)\nb = []\nfor i in range(1,n+1):\n\tif(n%i == 0):\n\t\tb.append(i)\n\nj = 0\n\nwhile(j<len(b)):\n\tc = a[b[j]:len(a)]\n\ta = a[0:b[j]][::-1]\n\ta = a+c\n\t#print a\n\tj+=1\n\nprint a"}, {"source_code": "from sys import stdin\n\nlines = stdin.readlines()\nn = int(lines[0])\nt = str(lines[1])[:-1]\n\ndef bul(x):\n liste = []\n for i in range(1,int(x**0.5)+1):\n if x % i == 0 and x / i == i:\n liste.append(i)\n elif x % i == 0 and x / i != i:\n liste.append(i)\n liste.append(x/i)\n liste = sorted(liste)\n \n return liste\n\ndef reverselist(x,y):\n k1 = x[:y]\n k2 = x[y:]\n k3 = \"\"\n for i in k1[-1::-1]:\n k3 += i\n return k3+k2\n\nfor i in bul(n):\n t = reverselist(t,i)\nprint t\n"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(2, n + 1):\n if n % i == 0:\n s = s[:i][::-1] + s[i:]\nprint(s)"}, {"source_code": "n=int(input(\"\"))\nt=str(input(\"\"))\nc=t\nfor i in range(1,n+1):\n\tif n%i==0:\n\t\tc = (c[0:i])[::-1]+c[i:n]\n\n\telse:\n\t\tcontinue\nprint(c)"}, {"source_code": "def rev(s):\n b=[]\n for elem in reversed(s):\n b.append(elem)\n return (b)\n\nn=int(input())\ns=input()\n\na=[]\nfor i in range(1,n//2+1):\n if(n%i==0):\n a.append(i)\na.append(n)\nfor i in range(len(a)):\n t=[]\n t=rev(s[:a[i]])\n t.append(s[a[i]:])\n s=''.join(t)\n\nprint(s)\n"}, {"source_code": "n = input()\nt = []\ns = str(raw_input())\nswyn = ''\nfor x in range(2,n-1,+1):\n if n%x == 0:\n t.append(x)\nsl = list(s)\nfor x in t:\n for y in range(1,(x/2)+1, +1):\n sl[y-1], sl[x-y] = sl[x-y], sl[y-1]\nfor x in range(len(sl)-1,-1, -1):\n swyn += str(sl[x])\nprint swyn"}, {"source_code": "n = int(input())\ns = input()\n\nfor i in range(1,n+1):\n\tif n % i == 0:\n\t\tk= s[i-1::-1]\n\t\t# k= s[:i][::-1]\n\t\t#print(k)\n\t\tl= s[i:n]\n\n\t\ts=k+l\n\n# for i in range(1,n+1):\n# if n%i==0:\n# s=\"\".join(reversed(s[:i])) +s[i:]\n\nprint(s)"}, {"source_code": "def giveDiv(n):\n\tretar=[]\n\tfor i in range(1,n//2+2):\n\t\tif n%i==0:\n\t\t\tretar.append(i)\n\tif retar[-1]!=n:\n\t\tretar.append(n)\n\treturn retar\n\nn=int(input())\ndivar=giveDiv(n)\n#print(divar)\ns=input()\nfor i in divar:\n\tretain=s[i:]\n\treverse=s[:i]\n\treverse=reverse[::-1]\t\n\ts=reverse+retain\nprint(s)\t\t\t"}, {"source_code": "def reverse(str1):\n\tstr = \"\"\n\tfor i in str1:\n\t\tstr = i + str\n\treturn str\n\nn = input()\nstring = str(raw_input())\nfor i in range(2,(n/2)+1):\n\tif n%i==0:\n\t\ttemp = str(reverse(string[:i]))\n\t\tstring = temp + string[i:]\nprint (reverse(string))\n"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(1,n+1):\n if(n%i==0):\n s=s[i-1::-1]+s[i:]\nprint(s)"}, {"source_code": "import sys\nimport math\n\nn = int(sys.stdin.readline().strip())\ns = [char for char in sys.stdin.readline().strip()]\n\nd = []\nfor i in range(2,n+1):\n\tif n%i == 0:\n\t\td.append(i)\n\nd = sorted(d)\nfor di in d:\n\ts[:di] = s[:di][::-1]\nprint(''.join(s))\n\n"}, {"source_code": "n = input()\na = raw_input()\nfor i in range(1,n+1):\n if(n%i==0):\n a = a[:i][::-1]+a[i:]\nprint a\n"}, {"source_code": "n = int(input())\nt = list(input())\ns = []\nd = []\nif n >= 1 and n <= 100:\n\tfor i in reversed(range(n + 1)):\n\t\tif i > 0 and n % i == 0:\n\t\t\td.append(i)\n\n\tfor i in reversed(range(len(d))):\n\t\ts.clear()\n\t\tfor j in range(d[i]):\n\t\t\ts.append(t[j])\n\t\ts.reverse()\n\t\tfor j in range(d[i]):\n\t\t\tt[j] = s[j]\n\tprint(''.join(t))"}, {"source_code": "#https://codeforces.com/contest/999/problem/B\n\nn=int(input())\ns=raw_input()\nfor i in xrange(1,n+1):\n if n%i==0:\n s=s[:i][::-1]+s[i:]\nprint s\n"}, {"source_code": "n = int(input())\ns = list(input())\n\nfor d in range(1, n+1):\n if not n % d:\n s[:d] = s[:d][::-1]\n\nprint(''.join(s))"}, {"source_code": "n = input()\nt = 'x'+raw_input()\ns = t\nfor i in xrange(1, n+1):\n\tif n%i == 0:\n\t\ts = s[0]+s[1:i+1][::-1]+s[i+1:]\nprint s[1:]"}, {"source_code": "n = int(raw_input().strip())\n \ns = raw_input().strip()\n \nfor i in range(1, 105):\n if n % i == 0:\n a, b = s[:i], s[i::]\n s = a[::-1] + b\n \nprint s"}, {"source_code": "n = int(input())\ns = input()\nl = [i for i in range(2, n + 1) if n % i == 0]\nfor i in l:\n s = s[:i][::-1] + s[i:]\nprint(s)"}, {"source_code": "n=int(input())\ns=str(input())\nfor i in range(1,n+1):\n if(n%i==0):\n s=s[:i][::-1] +s[i:]\nprint(s)\n"}, {"source_code": "n=input()\ns=raw_input()\ns=list(s)\nfor i in range(1,n+1):\n if n%i==0:\n s=list(reversed(s[:i]))+s[i:]\nprint ''.join(s)\n"}, {"source_code": "def decr(s,l):\n\tfor k in range(0,l):\n\t\tif k > l-(k+1): break\n\t\tt = s[k]\n\t\ts[k] = s[l-(k+1)]\n\t\ts[l-(k+1)] = t\n\n\treturn s\n\ndef p2():\n\tsstr = raw_input()\n\tL = int(sstr)\n\n\tpstr = list(raw_input())\n\n\tfor i in range(1,L+1):\n\t\tif L%i==0: \n\t\t\tpstr = decr(pstr, i)\n\t\t\t\n\tprint \"\".join(pstr)\n\np2()"}, {"source_code": "# Reversing Encryption\n\n\ndef divisors(n):\n\tdivisors = []\n\tfor x in range(1, n//2+2):\n\t\tif (n % x == 0):\n\t\t\tdivisors.append(x)\n\treturn divisors\n\ndef extract(strr, corr, div, i):\n\tif div[i] == 1:\n\t\treturn strr\n\n\tsliced = strr[div[i]:]\n\trem = strr[0:div[i]]\n\ts = sliced[::-1]\t\n\ti += 1\n\tcorr = s + extract(rem, corr, div, i)\n\tcorr = corr[::-1]\n\treturn corr\n\n# Main\n\nn = input()\nrev_v = raw_input()\ndiv = divisors(n)\ndiv = div[::-1]\ncorr = ''\n\nif n == 2:\n\tprint rev_v[::-1]\nelse:\n\tres = extract(rev_v, corr, div, 0)\n\tprint res[::-1]"}, {"source_code": "import math\nn = input()\nt = raw_input()\ndiv = []\nfor i in range(1,n+1):\n if n%i==0:\n div.append(i)\nst = t\n#print div\nfor x in div:\n st = st[:x][::-1] + st[x:]\n #print st\nprint st"}, {"source_code": "#https://codeforces.com/problemset/problem/999/B\nimport math\nimport sys\n\nn = input()\nstring = raw_input()[::-1]\ndef divisorGenerator(n):\n large_divisors = []\n for i in xrange(1, int(math.sqrt(n) + 1)):\n if n % i == 0:\n yield i\n if i*i != n:\n large_divisors.append(n / i)\n for divisor in reversed(large_divisors):\n yield divisor\n\n\ndivisors = list(divisorGenerator(n))\nstartStr, j, endStr = \"\", 0, \"\"\nfor i in list(reversed(range(1, len(divisors)))):\n if j % 2 == 0:\n startStr += string[:divisors[i] - divisors[i - 1]]\n else:\n endStr = string[:divisors[i] - divisors[i - 1]][::-1] + endStr\n string = string[divisors[i] - divisors[i - 1] :]\n j += 1\nprint startStr + string + endStr\n"}, {"source_code": "def revert(s, k):\n r = ''\n for x in xrange(k):\n r = s[x] + r\n return r + s[k:]\n\nn = int(raw_input())\ns = raw_input()\nfor i in xrange(2,n+1):\n if not n % i:\n s = revert(s, i)\n\nprint s\n"}, {"source_code": "def reversestr(s):\n\tres = \"\"\n\tfor ch in s:\n\t\tres = ch + res\n\treturn res\n\t\ndef divisors(n):\n\tdivs = []\n\tfor i in xrange(1, n + 1):\n\t\tif (n % i == 0):\n\t\t\tdivs.append(i)\n\treturn divs\n\t\nn = int(raw_input())\t\nt = raw_input().strip()\ndivs = divisors(n)\nfor d in divs:\n\tt = reversestr(t[0:d]) + t[d:n]\nprint t\n\n#print reversestr(\"codeforces\")\n\n"}, {"source_code": "l=int(raw_input())\ns= raw_input()\n\nfor n in range(1, l+1):\n if l % n == 0:\n temp = s[n-1::-1]\n temp2 = s[n:]\n s=temp+temp2\n temp = \"\"\n temp2=\"\"\nprint s\n\n"}, {"source_code": "n=int(input())\ns=input()\nso=[i for i in s]\nfor i in range(1,n+1):\n if(n%i==0):\n so[:i]=reversed(so[:i])\nfor i in so:\n print(i,end=\"\")\nprint()\n"}, {"source_code": "from collections import *\nfrom math import *\ndef I():return map(int , input().strip().split())\nn = int(input())\nstring = [''] + list(input())\ndivisors = [i for i in range(n, 0, -1) if not bool(n % i)]\ndivisors.reverse()\nfor i in divisors:\n if i == 1:continue\n string[1 : i + 1:] = string[i : 0 : -1]\nprint(*string, sep='')\n"}, {"source_code": "n = int(input())\nstr1 = str(input())\nl2 = []\nfor i in str1:\n l2.append(i)\nl1 = []\n# x = n/1.0\nfor j in range(1,n):\n if n/j == int(n/j):\n l1.append(j)\n\nl1.append(int(n))\n\nfor i in l1:\n l3 = l2[0:i]\n l3.reverse()\n l2[0:i] = l3[0:i]\n\n\nstrp = \"\"\nfor i in l2:\n strp+=i\nprint(strp)"}, {"source_code": "n=int(input())\na=input()\nfor i in range(2,n):\n\n if n%i==0:\n #print(i,a)\n #print(a[])\n a=a[i-1::-1]+a[i:]\n #print(i,a)\na=a[::-1]\nprint(a)\n"}, {"source_code": "d = int(input())\na = list(str(input()))\ndivisors = []\nfor n in range(d):\n if (d % (n+1)) == 0:\n divisors.append(n+1)\nt = 0\na2 = list(a[:divisors[0]])\nwhile t < (len(divisors)):\n a2 = list(a2[:divisors[t]])\n a2.reverse()\n a2.extend(a[divisors[t]:])\n t = t + 1\n\nstrA2 = ''.join(a2)\nprint(strA2)"}, {"source_code": "from math import *\nfrom collections import deque\nfrom copy import deepcopy\nimport sys\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") #for fast input\ndef multi(): return map(int,input().split())\ndef strmulti(): return map(str, inp().split())\ndef lis(): return list(map(int, inp().split()))\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef ncr(n,r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))\ndef stringlis(): return list(map(str, inp().split()))\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef printlist(a) :\n print(' '.join(str(a[i]) for i in range(len(a))))\n\ndef isPrime(n) :\n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\n\n#copied functions end\n\n#start coding\n\nn=int(input())\ns=inp()\na=list(s)\n\nfor i in range(n):\n if(n%(i+1)==0):\n temp=a[i::-1]\n # print(temp)\n a[:i+1]=deepcopy(temp)\n # print(a)\n\nfor i in a:\n print(i,end=\"\")\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "# https://codeforces.com/problemset/problem/999/B\n\ndef RevEncryption():\n \n# assuming length = 10:\n# d = 10, 5, 2, 1\n \n length = int(input(\"\"))\n string = [i for i in input(\"\")]\n divisors = []\n \n for i in range(1, length+1):\n if length % i == 0:\n divisors.append(i)\n# divisors.reverse()\n# print(divisors)\n \n for i in range(len(divisors)):\n# print(divisors[i])\n d = divisors[i]\n substring = string[0:d]\n# print(substring) \n substring.reverse()\n# print(substring)\n string[0:d] = [i for i in substring]\n \n for i in string:\n print(i, end = \"\")\n\nRevEncryption()"}, {"source_code": "def fD(n) :\n i = 2\n a=[]\n while i <= n :\n if (n % i==0) :\n a.append(i)\n i = i + 1\n return a\nn=int(input())\ns=input()\nk=s\na=fD(n)\nj=0\nwhile(j<len(a)):\n p=k[:a[j]]\n k=p[::-1]+s[a[j]:]\n j+=1\nprint(k)\n\n"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(1, n + 1):\n if n % i == 0:\n s = s[:i][::-1] + s[i:]\nprint(s)"}, {"source_code": "n = int(input())\nl1 = list(input())\nc=[]\ni=1\nwhile i<=n:\n if n%i==0:\n p = l1[:i].copy()\n p.reverse()\n l1 = p + l1[i:]\n #print(l1,i)\n i+=1\nprint(\"\".join(l1))"}, {"source_code": "from functools import reduce\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\ndef deencrypt(strs, n):\n f = sorted(factors(n))\n for i in f:\n strs = strs[:i][::-1] + strs[i:]\n print(strs)\n\nif __name__ == '__main__':\n n = int(input())\n strs = input()\n deencrypt(strs, n)"}, {"source_code": "import math as mt\nimport sys, string\nfrom collections import Counter, defaultdict\ninput = sys.stdin.readline\n\n# input functions\nI = lambda : int(input())\nM = lambda : map(int, input().split())\nARR = lambda: list(map(int, input().split()))\n\ndef printARR(arr):\n for e in arr:\n print(e, end=\" \")\n print()\n\ndef findDiv(n):\n ans = []\n for i in range(n, 0, -1):\n if n % i == 0:\n ans.append(i)\n return ans\n\ndef reverse(s, p):\n tmp = s[:p]\n n = len(tmp)\n tmp = tmp[n::-1]\n return tmp + s[p:]\n\ndef main():\n n = I()\n s = input()\n div = findDiv(n)\n div.reverse()\n for i in div:\n s = reverse(s, i)\n # print(s)\n print(s)\n \ntc = 1\n# tc = I()\nfor _ in range(tc):\n main()"}], "negative_code": [{"source_code": "n = int(input())\nstring = list(input())\ndivisors = []\nfor i in range(1, n+1):\n if n % i == 0:\n divisors.append(i-1)\nfor divisor in divisors:\n print(divisor)\n rev = string[:divisor+1]\n rev = rev[::-1]\n string = rev + string[divisor+1:]\n # print(string)\nprint(\"\".join(string))\n"}, {"source_code": "n = int(input())\ns = input()\nd = n\nl = []\nwhile d > 1:\n\tif n % d == 0:\n\t\tl.append(d)\n\td -= 1\nfor i in l[::-1]:\n\ts = s[:i][::-1] + s[i:]\n\tprint(s)"}, {"source_code": "def rev(s):\n b=[]\n for elem in reversed(s):\n b.append(elem)\n return (b)\n\nn=int(input())\ns=input()\n\na=[]\nfor i in range(1,n//2+1):\n if(n%i==0):\n a.append(i)\na.append(n)\na=rev(a)\nprint(a)\nfor i in range(len(a)):\n t=[]\n t=rev(s[:a[i]])\n t.append(s[a[i]:])\n s=''.join(t)\n print(s)\n"}, {"source_code": "# ANSHUL GAUTAM\n# IIIT-D\n\ndef isPrime(x):\n\tfor i in range(2,(x//2)+1):\n\t\tif(x%i == 0):\n\t\t\treturn False\n\treturn True\n\ndef div(x):\n\tl = [x]\n\tfor i in range((x//2)+1,1,-1):\n\t\tif(x%i == 0):\n\t\t\tl.append(i)\n\treturn l\n\nn = int(input())\ns = input()\nif(isPrime(n) == False):\n\tprint(s[::-1])\nelse:\n\tL = list(s)\n\tl = div(n)\n\tl.sort()\n\tfor i in range(len(l)):\n\t\td = l[i]\n\t\tl1 = L[:d]\n\t\tl1 = l1[::-1]\n\t\tl2 = L[d:]\n\t#\tprint(\"l1:\",l1)\n\t#\tprint(\"l2:\",l2)\n\t\tL = l1+l2\n\t#\tprint(\"L:\",L)\n\t\ts = ''.join(L)\n\tprint(s)\n"}, {"source_code": "from math import ceil,sqrt\nn = int(input())\ns = input()\ndiv = []\nfor i in range(2,ceil(sqrt(n))+1):\n if n%i == 0:\n div.append(i)\n div.append(n//i)\ndiv = sorted(list(set(div)))\nfor i in div:\n a = s[:i]\n s = a[::-1] + s[i:]\nprint(s[::-1])"}, {"source_code": "# ANSHUL GAUTAM\n# IIIT-D\n\ndef div(x):\n\tl = [x]\n\tfor i in range((x//2)+1,1,-1):\n\t\tif(x%i == 0):\n\t\t\tl.append(i)\n\treturn l\n\nn = int(input())\ns = input()\nL = list(s)\nl = div(n)\nl.sort()\nfor i in range(len(l)):\n\td = l[i]\n\tl1 = L[:d]\n\tl1 = l1[::-1]\n\tl2 = L[d:]\n#\tprint(\"l1:\",l1)\n#\tprint(\"l2:\",l2)\n\tL = l1+l2\n#\tprint(\"L:\",L)\n\ts = ''.join(L)\nprint(s)\n"}, {"source_code": "q=lambda:map(int,input().split())\nqi=lambda:int(input())\nqs=lambda:input().split()\n\ndef lol(n):\n for i in range(1,n+1):\n if n%i==0:\n yield i\n\nn=qi()\na=input()\nfor i in lol(n):\n print(a)\n a=''.join(reversed(a[0:i]))+a[i:n] \nprint(a)"}, {"source_code": "n = int(input())\nt = input()\nfor i in range(2, n//2+1):\n if n%i == 0:\n s1 = t[:i]\n s2 = t[i:]\n s3 = s1[::-1]\n t = s3+s2\n print(i, ' - ', s1, s2, s3)\ns = t[::-1]\nprint(s)\n"}, {"source_code": "#Imports\nfrom sys import stdin, stdout\nfrom collections import Counter, deque\nfrom decimal import *\nimport math\n\n\n#Aux\ndef _find_divisors(number):\n\tleft_divs = []\n\tright_divs = []\n\n\tfor i in xrange(2, int(math.sqrt(number))+1):\n\t\tif number%i==0:\n\t\t\tleft_divs.append(i)\n\t\t\tif i*i != number:\n\t\t\t right_divs.append(number/i)\n\n\tleft_divs.extend(right_divs[::-1])\n\tleft_divs.append(number)\n\treturn left_divs\n\n\ndef _decrypt(divisors, string):\n\tstr_list = list(string)\n\n\tfor div in divisors:\n\t\tj = div\n\t\tfor i in xrange(div/2):\n\t\t\tj-=1\n\t\t\tstr_list[i], str_list[j] = str_list[j], str_list[i]\n\n\treturn ''.join(str_list)\n\n\n#Main\ndef _main():\n #Read input\n size = int(stdin.readline().rstrip())\n string = stdin.readline().rstrip()\n\n\n #Calculate answer\n divisors = _find_divisors(size)\n print divisors\n converted = _decrypt(divisors, string)\n\n\n #Print output\n stdout.write(converted)\n\n\n\n#Call\n_main()"}, {"source_code": "def devide(t):\n l_of_d = []\n for i in range(2,t):\n if t % i == 0:\n l_of_d.append(i)\n return l_of_d\n\ndef decrypt(_str,t):\n for i in devide(t):\n _str = _str.replace(_str[0:i],_str[i-1::-1])\n return _str[::-1]\n\nt = int(input())\n_str = str(input())\nprint(decrypt(_str,t))\n\n"}, {"source_code": "n = int(input())\ns = str(input())\na = []\nfor i in range(1,n+1):\n if n % i == 0:\n a.append(i)\nfor i in a:\n temp = \"\"\n for j in range(i):\n temp += str(s[j])\n s = s.replace(temp, temp[::-1])\n temp,temp[::-1]\nprint(s)"}, {"source_code": "n=int(input(\"\"))\nt=str(input(\"\"))\nc=t\nfor i in range(n,0,-1):\n\tif n%i==0:\n\t\tc = (c[0:i])[::-1]+c[i:n]\n\n\telse:\n\t\tcontinue\nprint(c)"}, {"source_code": "def reverseAtIndex(str,i):\n\ts = \"\".join(reversed(str[:i]))\n\ts = list(s)\n\ts.extend(str[i:])\n\treturn s\n\ndef findDiv(n):\n\tsol = []\n\tfor i in range(1,n+1):\n\t\tif(n%i == 0):\n\t\t\tsol.append(i)\n\treturn sol\n\t\nn = int(input())\nstr = input()\nstr = list(str)\nfor i in findDiv(len(str)):\n\tstr = reverseAtIndex(str,i)\n\tprint(str)\nsol = \"\".join(str)\nprint(sol)\n"}, {"source_code": "n=input()\nn=list(n)\na='aeiou'\n# print(n)\nfor i in range(len(n)-1):\n if(n[i] not in a and n[i]!='n'):\n if(n[i+1] not in a):\n print(\"NO\")\n exit()\nprint(\"YES\")"}, {"source_code": "# Reversing Encryption\n\n\ndef divisors(n):\n\tdivisors = []\n\tfor x in range(1, n//2+2):\n\t\tif (n % x == 0):\n\t\t\tdivisors.append(x)\n\treturn divisors\n\ndef extract(strr, corr, div, i):\n\tif div[i] == 1:\n\t\treturn strr\n\n\tsliced = strr[div[i]:]\n\trem = strr[0:div[i]]\n\ts = sliced[::-1]\t\n\ti += 1\n\tcorr = s + extract(rem, corr, div, i)\n\tcorr = corr[::-1]\n\treturn corr\n\n# Main\n\nn = input()\nrev_v = raw_input()\ndiv = divisors(n)\ndiv = div[::-1]\ncorr = ''\n\nres = extract(rev_v, corr, div, 0)\nprint res[::-1]"}, {"source_code": "def reverseAtIndex(str,i):\n\ts = \"\".join(reversed(str[:i]))\n\ts = list(s)\n\ts.extend(str[i:])\n\treturn s\n\ndef findDiv(n):\n\tsol = []\n\tfor i in range(1,n+1):\n\t\tif(n%i == 0):\n\t\t\tsol.append(i)\n\treturn sol\n\t\nn = int(input())\nstr = input()\nstr = list(str)\nfor i in findDiv(len(str)):\n\tstr = reverseAtIndex(str,i)\n\tprint(str)\nsol = \"\".join(str)\nprint(sol)\n"}, {"source_code": "t = int(input())\na = str(input())\nprint(a[::-1])"}, {"source_code": "#Imports\nfrom sys import stdin, stdout\nfrom collections import Counter, deque\nfrom decimal import *\nimport math\n\n\n#Aux\ndef _find_divisors(number):\n\tleft_divs = []\n\tright_divs = []\n\n\tfor i in xrange(2, int(math.sqrt(number))+1):\n\t\tif number%i==0:\n\t\t\tleft_divs.append(i)\n\t\t\tif i*i != number:\n\t\t\t right_divs.append(number/i)\n\n\tleft_divs.extend(right_divs[::-1])\n\tleft_divs.append(number)\n\treturn left_divs\n\n\ndef _decrypt(divisors, string):\n\tstr_list = list(string)\n\n\tfor div in divisors:\n\t\tj = div\n\t\tfor i in xrange(div/2):\n\t\t\tj-=1\n\t\t\tstr_list[i], str_list[j] = str_list[j], str_list[i]\n\n\treturn ''.join(str_list)\n\n\n#Main\ndef _main():\n #Read input\n size = int(stdin.readline().rstrip())\n string = stdin.readline().rstrip()\n\n\n #Calculate answer\n divisors = _find_divisors(size)\n print divisors\n converted = _decrypt(divisors, string)\n\n\n #Print output\n stdout.write(converted)\n\n\n\n#Call\n_main()"}, {"source_code": "n=int(input())\ns=input()\nl=[i for i in range(n,0,-1) if n%i==0]\nprint(l)\nfor j in l:\n a=s[:j]\n b=s[j:]\n a=a[::-1]\n s=a+b\n print(s)\nprint(s)"}, {"source_code": "n=int(input())\ns=list(input())\ndivisors=[1,n]\nfor i in range(2,int(n**0.5)+1):\n if n%i==0:\n divisors+=[i,n//i]\ndivisors.sort()\nfor i in divisors:\n s[:i]=s[:i][::-1]\n \nprint(\"\".join(s))\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\ndef factors(n):\n lst = []\n i = 1\n while i*i <= n:\n if n%i == 0:\n lst.append(i)\n lst.append(n//i)\n i += 1\n return sorted(lst)\n\nn = get_int()\nstring = get_string()\nf = factors(n)\n\nfor i in f:\n string = string[:i][::-1] + string[i:]\nprint(string)\n\n"}, {"source_code": "n = int(input())\ns = input()\ndivisors = []\nfor i in range(1, int(n**0.5)):\n if n % i == 0:\n divisors.append(i)\n divisors.append(n // i)\ndivisors = sorted(divisors)\n# print(divisors)\nfor i in divisors:\n substr = s[0:i]\n s = ''.join(reversed(substr)) + s[i:]\n # print(s)\nprint(s)"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n,0,-1):\n if n%i==0:\n s=s[i-1:0:-1]+s[0]+s[i:]\nprint(s)"}, {"source_code": "from math import floor, sqrt\n\n\nn = int(input())\ns = input()\ns = [x for x in s]\n\ndiv_last_part = []\n\nfor i in range(2, int(floor(sqrt(n)))):\n if n % i == 0 :\n s[:i] = s[i-1::-1]\n div_res = n // i\n if(div_res != i):\n div_last_part.append(div_res)\nsqrt_number = sqrt(n)\nif sqrt_number % 1 < 0.000001:\n sqrt_number = int(sqrt_number)\n s[:sqrt_number] = s[sqrt_number - 1::-1]\nfor el in div_last_part:\n s[:el] = s[el-1::-1]\nres = \"\"\ns = s[::-1]\nfor i in range(len(s)):\n res += s[i]\nprint(res)"}, {"source_code": "def devide(t):\n l_of_d = []\n for i in range(2,t-1):\n if t % i == 0:\n l_of_d.append(i)\n return l_of_d\n\ndef decrypt(_str,t):\n ss = _str\n for i in devide(t):\n ss = ss.replace(ss[0:i],ss[i-1::-1])\n return ss[::-1]\n\nt = int(input())\n_str = str(input())\nprint(decrypt(_str,t))\n\n"}, {"source_code": "n = int(input())\nstring = list(input())\ndivisors = []\nfor i in range(1, n+1):\n if n % i == 0:\n divisors.append(i-1)\nfor divisor in divisors:\n print(divisor)\n rev = string[:divisor+1]\n rev = rev[::-1]\n string = rev + string[divisor+1:]\n # print(string)\nprint(\"\".join(string))\n"}, {"source_code": "def rev(s):\n b=[]\n for elem in reversed(s):\n b.append(elem)\n return (b)\n\nn=int(input())\ns=input()\n\na=[]\nfor i in range(1,n//2+1):\n if(n%i==0):\n a.append(i)\na.append(n)\na=rev(a)\nprint(a)\nfor i in range(len(a)):\n t=[]\n t=rev(s[:a[i]])\n t.append(s[a[i]:])\n s=''.join(t)\n print(s)\n"}, {"source_code": "def giveDiv(n):\n\tretar=[]\n\tfor i in range(1,n//2+2):\n\t\tif n%i==0:\n\t\t\tretar.append(i)\n\tretar.append(n)\n\treturn retar\n\nn=int(input())\ndivar=giveDiv(n)\ns=input()\nfor i in divar:\n\tretain=s[i:]\n\treverse=s[:i]\n\treverse=reverse[::-1]\t\n\ts=reverse+retain\nprint(s)\t\t\t"}, {"source_code": "# ANSHUL GAUTAM\n# IIIT-D\n\ndef div(x):\n\tl = [x]\n\tfor i in range((x//2)+1,1,-1):\n\t\tif(x%i == 0):\n\t\t\tl.append(i)\n\treturn l\n\nn = int(input())\ns = input()\nL = list(s)\nl = div(n)\nl.sort()\nfor i in range(len(l)):\n\td = l[i]\n\tl1 = L[:d]\n\tl1 = l1[::-1]\n\tl2 = L[d:]\n#\tprint(\"l1:\",l1)\n#\tprint(\"l2:\",l2)\n\tL = l1+l2\n#\tprint(\"L:\",L)\n\ts = ''.join(L)\nprint(s)\n"}, {"source_code": "n = int(input())\ns = input()\nd = []\nfor i in range(1, int(n ** 0.5 + 0.999999999999999) + 1):\n if n % i == 0:\n d.append(i)\n d.append(n // i)\nd.sort()\nfor i in d:\n s = s[:i][::-1] + s[i:]\nprint(s)"}, {"source_code": "a=int(input());b=input();i=1\nwhile(i<a+1):\n if a%i==0:print(i,b);b=b[0:i][::-1]+b[i:];print(i,b)\n i+=1\nprint(b)"}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin\n\n\ndef solve(tc):\n n = int(stdin.readline().strip())\n s = stdin.readline().strip()\n li = list()\n while n:\n li.append(n)\n n //= 2\n \n li.reverse()\n for i in li:\n s = s[i-1::-1] + s[i:]\n print(s)\n\n\nLOCAL_TEST = not __debug__\nif LOCAL_TEST:\n infile = __file__.split('.')[0] + \"-test.in\"\n stdin = open(infile, 'r')\n\ntcs = (int(stdin.readline().strip()) if LOCAL_TEST else 1)\ntc = 1\nwhile tc <= tcs:\n solve(tc)\n tc += 1"}, {"source_code": "# Reversing Encryption\n\n\ndef divisors(n):\n\tdivisors = []\n\tfor x in range(1, n//2+2):\n\t\tif (n % x == 0):\n\t\t\tdivisors.append(x)\n\treturn divisors\n\ndef extract(strr, corr, div, i):\n\tif div[i] == 1:\n\t\treturn strr\n\n\tsliced = strr[div[i]:]\n\trem = strr[0:div[i]]\n\ts = sliced[::-1]\t\n\ti += 1\n\tcorr = s + extract(rem, corr, div, i)\n\tcorr = corr[::-1]\n\treturn corr\n\n# Main\n\nn = input()\nrev_v = raw_input()\ndiv = divisors(n)\ndiv = div[::-1]\ncorr = ''\n\n\nres = extract(rev_v, corr, div, 0)\nprint res[::-1]"}, {"source_code": "if __name__ == \"__main__\":\n n = int(input())\n s = input()\n factors = [x for x in range(n, 1, -1) if n % x == 0]\n\n for factor in factors:\n part1 = s[:factor]\n part1 = part1[::-1]\n part2 = s[factor:]\n s = part1 + part2\n\n print(s)\n"}, {"source_code": "import math\nx=int(input())\ny=(input())\nl=[]\nt=int(math.sqrt(x))\nfor i in range(1,t+1):\n if x%i==0:\n l.append(i)\n l.append(x//i)\nl=list(set(l))\n# l.sort()\nfor i in l:\n w=list(y[:i])\n w.reverse()\n y=\"\".join(w)+y[i:]\nprint(y)\n# if x==1:\n# print(x)\n# elif x==2:\n# print(x[-1]+x[0])\n# else:\n# a=[1,x]\n# for i in range(2,(x//2)+1):\n# if x%i==0 :\n# a.append(i,x/i)\n# a=list(set(a))\n# a.sort()\n# for j in a:\n# y=(a[:j].reversed())+a[j:]\n# print(''.join(a))"}, {"source_code": "n = int(input())\ns = input()\n\nfor i in range(1,n+1):\n\tif n % i == 0:\n\t\tk= s[i-1::-1]\n\t\t# k= s[:i][::-1]\n\t\tprint(k)\n\t\tl= s[i:n]\n\t\t# print(l)\n\t\ts=k+l\n\n\n# for i in range(1,n+1):\n# if n%i==0:\n# s=\"\".join(reversed(s[:i])) +s[i:]\n\nprint(s)"}, {"source_code": "import sys\nimport collections \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn = inp()\nnow = input()\ncnts = []\ncnt = n\nwhile cnt > 0:\n cnts.append(cnt)\n cnt //= 2\ncnts = cnts[::-1]\nfor cnt in cnts:\n pre = now[::]\n now = pre[:cnt][::-1] + pre[cnt:]\nprint(now)"}, {"source_code": "a = input()\nn = int(a)\na = input()\n\ndivisors = [2, 3, 5, 7]\nnumOfDiv = [0, 0, 0, 0]\n\nfor i in range(0, 4):\n for j in range(1, 7):\n p = pow(divisors[i], j)\n if ((n % p) == 0) & (p < n):\n numOfDiv[i] = numOfDiv[i] + 1\n\ns = a\nfor i in range(0, 4):\n for j in range(1, numOfDiv[i]+1):\n p = pow(divisors[i], j)\n s = s[p-1::-1]\n s = s + a[p:]\n\nprint(s[::-1])"}, {"source_code": "n=int(input())\ns=input()\ns=s[::-1]\n\ni=n-1\nwhile i>1:\n if n%i==0:\n t=s[:i]\n t=t[::-1]\n s=t+s[i:]\n i-=1\nprint(s)"}, {"source_code": "def division(n):\n divs = set()\n for i in range(1, n + 1):\n if n % i == 0:\n divs.add(i - 1)\n return divs\n\ndef decode(code):\n divs = division(n)\n for i in divs:\n code = code[i::-1] + code[i + 1:]\n return code\nn = int(input())\ncode = input()\nprint(decode(code))"}, {"source_code": "n=input()\nn=list(n)\na='aeiou'\n# print(n)\nfor i in range(len(n)-1):\n if(n[i] not in a and n[i]!='n'):\n if(n[i+1] not in a):\n print(\"NO\")\n exit()\nprint(\"YES\")"}, {"source_code": "a=input('length')\nb=raw_input('string')\ni=1\nwhile i<=a:\n s1=''\n s2=''\n if a%i==0:\n s1=b[:i]\n s2=b[i:]\n s1=s1[::-1]\n b=s1+s2\n i+=1\nprint b\n\n\n\n \n"}, {"source_code": "n = int(input())\nx = list(input())\nfor i in range(n, 0, -1):\n if n % i == 0:\n x[:i+1] = x[i::-1]\nprint(''.join(x))"}, {"source_code": "def giveDiv(n):\n\tretar=[]\n\tfor i in range(1,n//2+2):\n\t\tif n%i==0:\n\t\t\tretar.append(i)\n\tretar.append(n)\n\treturn retar\n\nn=int(input())\ndivar=giveDiv(n)\ns=input()\nfor i in divar:\n\tretain=s[i:]\n\treverse=s[:i]\n\treverse=reverse[::-1]\t\n\ts=reverse+retain\nprint(s)\t\t\t"}, {"source_code": "#Imports\nfrom sys import stdin, stdout\nfrom collections import Counter, deque\nfrom decimal import *\nimport math\n\n\n#Aux\ndef _find_divisors(number):\n\tleft_divs = []\n\tright_divs = []\n\n\tfor i in xrange(2, int(math.sqrt(number))+1):\n\t\tif number%i==0:\n\t\t\tleft_divs.append(i)\n\t\t\tif i*i != number:\n\t\t\t right_divs.append(number/i)\n\n\tleft_divs.extend(right_divs[::-1])\n\tleft_divs.append(number)\n\treturn left_divs\n\n\ndef _decrypt(divisors, string):\n\tstr_list = list(string)\n\n\tfor div in divisors:\n\t\tj = div\n\t\tfor i in xrange(div/2):\n\t\t\tj-=1\n\t\t\tstr_list[i], str_list[j] = str_list[j], str_list[i]\n\n\treturn ''.join(str_list)\n\n\n#Main\ndef _main():\n #Read input\n size = int(stdin.readline().rstrip())\n string = stdin.readline().rstrip()\n\n\n #Calculate answer\n divisors = _find_divisors(size)\n print divisors\n converted = _decrypt(divisors, string)\n\n\n #Print output\n stdout.write(converted)\n\n\n\n#Call\n_main()"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Sep 26 11:56:01 2020\n\n@author: Dark Soul\n\"\"\"\n\ndef div(n):\n sol=[]\n for i in range(2,100):\n if n%i==0:\n sol.append(i)\n if i!=n//i:\n sol.append(n//i)\n if i*i>=n:\n break\n return sol\nn=int(input(''))\nvang=div(n)\ns=list(input(''))\nvang.sort()\nact=s.copy()\nfor i in vang:\n bodla=''\n for j in range(i-1,-1,-1):\n bodla+=s[j]\n for j in range(i):\n s[j]=bodla[j]\ns.reverse()\nif n==2:\n act.reverse()\n print(''.join(act))\nelse:\n print(''.join(s))\n \n "}, {"source_code": "# Reversing Encryption\n\n\ndef divisors(n):\n\tdivisors = []\n\tfor x in range(1, n//2+2):\n\t\tif (n % x == 0):\n\t\t\tdivisors.append(x)\n\treturn divisors\n\ndef extract(strr, corr, div, i):\n\tif div[i] == 1:\n\t\treturn strr\n\n\tsliced = strr[div[i]:]\n\trem = strr[0:div[i]]\n\ts = sliced[::-1]\t\n\ti += 1\n\tcorr = s + extract(rem, corr, div, i)\n\tcorr = corr[::-1]\n\treturn corr\n\n# Main\n\nn = input()\nrev_v = raw_input()\ndiv = divisors(n)\ndiv = div[::-1]\ncorr = ''\n\nif n == 2:\n\tprint rev_v\n\n\nres = extract(rev_v, corr, div, 0)\nprint res[::-1]"}, {"source_code": "import math\n\ndef divisorGenerator(n):\n large_divisors = []\n for i in range(1, int(math.sqrt(n) + 1)):\n if n % i == 0:\n yield i\n if i * i != n:\n large_divisors.append(n // i)\n for divisor in reversed(large_divisors):\n yield divisor\n\n\ndef main():\n n = int(input())\n line = input().strip()\n divisors = list(divisorGenerator(n))\n for div in reversed(divisors):\n # print(div)\n # print(line[:div])\n line = ''.join(reversed(line[:div])) + line[div:]\n # print(line)\n \n print(line)\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n = int(input())\ns = input()\ndivisors = []\nfor i in range(1, int(n**0.5)):\n if n % i == 0:\n divisors.append(i)\n divisors.append(n // i)\ndivisors = sorted(divisors)\n# print(divisors)\nfor i in divisors:\n substr = s[0:i]\n s = ''.join(reversed(substr)) + s[i:]\n # print(s)\nprint(s)"}, {"source_code": "n = int(input())\nt = input()\nfor i in range(2, n//2+1):\n if n%i == 0:\n s1 = t[:i]\n s2 = t[i:]\n s3 = s1[::-1]\n t = s3+s2\n print(i, ' - ', s1, s2, s3)\ns = t[::-1]\nprint(s)\n"}, {"source_code": "import sys\nimport collections \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn = inp()\nnow = input()\ncnts = []\ncnt = n\nwhile cnt > 0:\n cnts.append(cnt)\n cnt //= 2\ncnts = cnts[::-1]\nfor cnt in cnts:\n pre = now[::]\n now = pre[:cnt][::-1] + pre[cnt:]\nprint(now)"}, {"source_code": "def inp():\n return map(int, input().split())\nimport sys;\nimport math;\n\nn = int(input());\ns = input();\n\nif n == 1:\n print(s);\n sys.exit();\n\nfor i in range(1,n+1):\n if n%i == 0:\n s = s[i:0:-1] + s[i:]\nprint(s);\n"}, {"source_code": "n = int(input())\ns = input()\nd = n\nl = []\nwhile d > 1:\n\tif n % d == 0:\n\t\tl.append(d)\n\td -= 1\nfor i in l[::-1]:\n\ts = s[:i][::-1] + s[i:]\n\tprint(s)"}, {"source_code": "def division(n):\n divs = set()\n for i in range(1, n + 1):\n if n % i == 0:\n divs.add(i - 1)\n return divs\n\ndef decode(code):\n divs = division(n)\n for i in divs:\n code = code[i::-1] + code[i + 1:]\n return code\nn = int(input())\ncode = input()\nprint(decode(code))"}, {"source_code": "n=int(input())\nc=n\nl=[n]\nwhile n!=1 :\n\tn=n//2\n\tl.append(n)\nl.sort()\na=input()\nfor i in range(1,len(l)):\n\ta=a[l[i]-1::-1]+a[l[i]:]\nprint(a)\n"}, {"source_code": "###\nimport sys\ndata = sys.stdin.readlines()\n\nlis = []\n\nfor line in data:\n lis.append(line)\n###\nn = int, lis[0].split()\nstring = lis[1]\ndivisors = []\n\nn = len(string)\nfor i in range(2, n+1):#horrible way \n if n%i == 0:\n divisors.append(i)\n\n#divisors = sorted([key for key in divisors])\nfor key in divisors:\n string = string[key-1::-1]+string[key:]\nprint(string)\n\n"}, {"source_code": "# Reversing Encryption\n\n\ndef divisors(n):\n\tdivisors = []\n\tfor x in range(1, n//2+2):\n\t\tif (n % x == 0):\n\t\t\tdivisors.append(x)\n\treturn divisors\n\ndef extract(strr, corr, div, i):\n\tif div[i] == 1:\n\t\treturn strr\n\n\tsliced = strr[div[i]:]\n\trem = strr[0:div[i]]\n\ts = sliced[::-1]\t\n\ti += 1\n\tcorr = s + extract(rem, corr, div, i)\n\tcorr = corr[::-1]\n\treturn corr\n\n# Main\n\nn = input()\nrev_v = raw_input()\ndiv = divisors(n)\ndiv = div[::-1]\n\ncorr = ''\n\n\nres = extract(rev_v, corr, div, 0)\nprint res[::-1]"}, {"source_code": "#Imports\nfrom sys import stdin, stdout\nfrom collections import Counter, deque\nfrom decimal import *\nimport math\n\n\n#Aux\ndef _find_divisors(number):\n\tleft_divs = []\n\tright_divs = []\n\n\tfor i in xrange(2, int(math.sqrt(number))+1):\n\t\tif number%i==0:\n\t\t\tleft_divs.append(i)\n\t\t\tif i*i != number:\n\t\t\t right_divs.append(number/i)\n\n\tleft_divs.extend(right_divs[::-1])\n\tleft_divs.append(number)\n\treturn left_divs\n\n\ndef _decrypt(divisors, string):\n\tstr_list = list(string)\n\n\tfor div in divisors:\n\t\tj = div\n\t\tfor i in xrange(div/2):\n\t\t\tj-=1\n\t\t\tstr_list[i], str_list[j] = str_list[j], str_list[i]\n\n\treturn ''.join(str_list)\n\n\n#Main\ndef _main():\n #Read input\n size = int(stdin.readline().rstrip())\n string = stdin.readline().rstrip()\n\n\n #Calculate answer\n divisors = _find_divisors(size)\n print divisors\n converted = _decrypt(divisors, string)\n\n\n #Print output\n stdout.write(converted)\n\n\n\n#Call\n_main()"}, {"source_code": "input()\nSentence = input()\nfor i in range(1, len(Sentence) + 1):\n if len(Sentence) % i == 0:\n print(\"\".join(reversed(Sentence[0:i])))\n Sentence = \"\".join(reversed(Sentence[0:i])) + Sentence[i:]\nprint(Sentence)\n"}, {"source_code": "from math import floor, sqrt\n\n\nn = int(input())\ns = input()\ns = [x for x in s]\n\ndiv_last_part = []\n\nfor i in range(2, int(floor(sqrt(n)))):\n if n % i == 0 :\n s[:i] = s[i-1::-1]\n div_res = n // i\n if(div_res != i):\n div_last_part.append(div_res)\nsqrt_number = sqrt(n)\nif sqrt_number % 1 < 0.000001:\n sqrt_number = int(sqrt_number)\n s[:sqrt_number] = s[sqrt_number - 1::-1]\nfor el in div_last_part:\n s[:el] = s[el-1::-1]\nres = \"\"\ns = s[::-1]\nfor i in range(len(s)):\n res += s[i]\nprint(res)"}, {"source_code": "n = int(input())\nstring = list(input())\ndivisors = []\nfor i in range(1, n+1):\n if n % i == 0:\n divisors.append(i-1)\nfor divisor in divisors:\n print(divisor)\n rev = string[:divisor+1]\n rev = rev[::-1]\n string = rev + string[divisor+1:]\n # print(string)\nprint(\"\".join(string))\n"}, {"source_code": "n=int(input())\ns=input()\np=n\n\nfor i in range(1,n+1):\n if(n%i==0):\n temp=s[0:i]\n s=temp[::-1]+s[i:]\n print(s)\n \n \n"}, {"source_code": "input()\nSentence = input()\nfor i in range(1, len(Sentence) + 1):\n if len(Sentence) % i == 0:\n print(\"\".join(reversed(Sentence[0:i])))\n Sentence = \"\".join(reversed(Sentence[0:i])) + Sentence[i:]\nprint(Sentence)\n"}, {"source_code": "a=int(input());b=input();i=1\nwhile(i<a+1):\n if a%i==0:print(i,b);b=b[0:i][::-1]+b[i:]\n i+=1\nprint(b)"}, {"source_code": "#BISMILLAH\nimport math\ndef reverse(string):return string[::-1] \ndef replacewith(input, pattern, replaceWith):return input.replace(pattern, replaceWith)\ndef divisors(n):\n div = []\n for i in range(2, n+1):\n if n%i==0: div.append(int(i))\n return div\nn = int(input())\ns = input()\ndiv = divisors(n)\nprint(div)\nfor i in range(0,len(div)):\n s = replacewith(s, s[0:div[i]], reverse(s[0:div[i]]))\nprint(s)\n#ALHAMDULILLAH"}, {"source_code": "import math\ndef primefact(n):\n l=[]\n while n%2==0:\n l.append(2)\n n=n/2\n for i in range(3,int(math.sqrt(n))+1,2):\n while n%i==0:\n l.append(i)\n n=n/i\n if n>1:\n l.append(int(n))\n return l\n\n\nn=int(input())\ns = list(map(str,input()))\nl=primefact(n)\nfor i in l:\n for j in range(i):\n for k in range(i-j-1):\n s[k],s[k+1]=s[k+1],s[k]\ns.reverse()\nj=\"\"\nfor i in s:\n j+=i\nprint(j)"}, {"source_code": "from math import floor, sqrt\n\n\nn = int(input())\ns = input()\ns = [x for x in s]\n\ndiv_last_part = []\n\nfor i in range(2, int(floor(sqrt(n)))+1):\n if n % i == 0:\n s[:i] = s[i-1::-1]\n div_res = n // i\n if(div_res != i):\n div_last_part.append(div_res)\n\nfor el in div_last_part:\n s[:el] = s[el-1::-1]\nres = \"\"\ns = s[::-1]\nfor i in range(len(s)):\n res += s[i]\nprint(res)"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(2,n+1):\n print(n%i)\n if n%i==0:\n d=s[:i]\n s=d[::-1]+s[i:]\n #print(d,s[i:])\nprint(s)"}, {"source_code": "n = int(input())\nt = list(input())\ns = []\nd = []\nif n >= 1 and n <= 100:\n\tfor i in reversed(range(n + 1)):\n\t\tif i > 0 and n % i == 0:\n\t\t\td.append(i)\n\t\t\tprint(\"del = \" + str(i))\n\n\tfor i in reversed(range(len(d))):\n\t\ts.clear()\n\t\tfor j in range(d[i]):\n\t\t\ts.append(t[j])\n\t\tprint(\"not reversed s = \" + ''.join(s))\n\t\ts.reverse()\n\t\tprint(\"reversed s = \" + ''.join(s))\n\t\tfor j in range(d[i]):\n\t\t\tt[j] = s[j]\n\tprint(''.join(t))"}, {"source_code": "n=int(input())\na=input()\nfor i in range(2,n):\n\n if n%i==0:\n print(i,a)\n #print(a[])\n a=a[i-1::-1]+a[i:]\n #print(i,a)\na=a[::-1]\nprint(a)\n"}, {"source_code": "# Reversing Encryption\n\n\ndef divisors(n):\n\tdivisors = []\n\tfor x in range(1, n//2+2):\n\t\tif (n % x == 0):\n\t\t\tdivisors.append(x)\n\treturn divisors\n\ndef extract(strr, corr, div, i):\n\tif div[i] == 1:\n\t\treturn strr\n\n\tsliced = strr[div[i]:]\n\trem = strr[0:div[i]]\n\ts = sliced[::-1]\t\n\ti += 1\n\tcorr = s + extract(rem, corr, div, i)\n\tcorr = corr[::-1]\n\treturn corr\n\n# Main\n\nn = input()\nrev_v = raw_input()\ndiv = divisors(n)\ndiv = div[::-1]\ncorr = ''\n\nres = extract(rev_v, corr, div, 0)\nprint res[::-1]"}, {"source_code": "n = int(input())\ns = str(input())\na = []\nfor i in range(1,n+1):\n if n % i == 0:\n a.append(i)\nfor i in a:\n temp = \"\"\n for j in range(i):\n temp += str(s[j])\n s = s.replace(temp, temp[::-1])\n temp,temp[::-1]\nprint(s)"}, {"source_code": "import math\nsum=input()\nsum=int(sum)\ndef split(word):\n\treturn list(word)\nword=input()\nx=split(word)\nn=math.log(sum,2)\nn=math.floor(n)\nfor i in range(n,-1,-1):\n\ta=sum/(2**i)\n\ta=math.floor(a)\n\tz=a/2\n\th=math.floor(z)\n\tfor b in range(h):\n\t\tx[b],x[a-1-b]=x[a-1-b],x[b]\nm=\"\"\nfor c in range(sum):\n\tm=m+x[c]\nprint(m)"}, {"source_code": "def giveDiv(n):\n\tretar=[]\n\tfor i in range(1,n//2+2):\n\t\tif n%i==0:\n\t\t\tretar.append(i)\n\tretar.append(n)\n\treturn retar\n\nn=int(input())\ndivar=giveDiv(n)\ns=input()\nfor i in divar:\n\tretain=s[i:]\n\treverse=s[:i]\n\treverse=reverse[::-1]\t\n\ts=reverse+retain\nprint(s)\t\t\t"}, {"source_code": "a = int(input())\ns = list(input())\n\nb = []\nfor i in range(a, 1, -1):\n if a % i == 0:\n b.append(i)\n\nfor i in b:\n s[0:i] = reversed(s[0:i])\n\ns = \"\".join(s)\nprint(s)"}, {"source_code": "import math\nsum=input()\nsum=int(sum)\ndef split(word):\n\treturn list(word)\nword=input()\nx=split(word)\nn=math.log(sum,2)\nn=math.floor(n)\nfor i in range(n,-1,-1):\n\ta=sum/(2**i)\n\ta=math.floor(a)\n\tz=a/2\n\tz=math.floor(z)\n\tfor b in range(z):\n\t\tx[b],x[a-1-b]=x[a-1-b],x[b]\nm=\"\"\nfor c in range(sum):\n\tm=m+x[c]\nprint(m)"}, {"source_code": "q=lambda:map(int,input().split())\nqi=lambda:int(input())\nqs=lambda:input().split()\n\ndef lol(n):\n for i in range(1,n+1):\n if n%i==0:\n yield i\n\nn=qi()\na=input()\nfor i in lol(n):\n print(a)\n a=''.join(reversed(a[0:i]))+a[i:n] \nprint(a)"}, {"source_code": "import math\n\ndef divisorGenerator(n):\n large_divisors = []\n for i in range(1, int(math.sqrt(n) + 1)):\n if n % i == 0:\n yield i\n if i * i != n:\n large_divisors.append(n // i)\n for divisor in reversed(large_divisors):\n yield divisor\n\n\ndef main():\n n = int(input())\n line = input().strip()\n divisors = list(divisorGenerator(n))\n for div in reversed(divisors):\n # print(div)\n # print(line[:div])\n line = ''.join(reversed(line[:div])) + line[div:]\n # print(line)\n \n print(line)\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n=int(input())\na=input()\nfor i in range(2,n):\n\n if n%i==0:\n print(i,a)\n #print(a[])\n a=a[i-1::-1]+a[i:]\n #print(i,a)\na=a[::-1]\nprint(a)\n"}, {"source_code": "n = int(input())\nw = input()\n\ndiv = [i for i in range(2,n//2+2) if n%i==0]+[n]\nfor i in range(len(div)):\n w = list(reversed(w[:div[i]]))+list(w[div[i]:])\n \nprint(''.join(w))\n"}, {"source_code": "def devide(t):\n l_of_d = []\n for i in range(2,t):\n if t % i == 0:\n l_of_d.append(i)\n return l_of_d\n\ndef decrypt(_str,t):\n ss = _str\n for i in devide(t):\n ss = ss.replace(ss[0:i],ss[i-1::-1])\n return ss[::-1]\n\nt = int(input())\n_str = str(input())\nprint(decrypt(_str,t))\n\n"}, {"source_code": "n=int(input())\nr=input()\ni=1\nwhile i<=n:\n if n%i==0:\n s=r[0:i]\n s1=s[::-1] \n r=s1+r[i:n]\n i+=1\n print(r)"}, {"source_code": "n = int(input())\ns = str(input())\n\nn = len(s)\n\ndef reverse(s):\n if len(s) == 0:\n return s\n else:\n return reverse(s[1:]) + s[0]\n\n\nprint(reverse(s))\n"}, {"source_code": "a = input()\nn = int(a)\na = input()\n\ndivisors = [2, 3, 5, 7]\nnumOfDiv = [0, 0, 0, 0]\n\nfor i in range(0, 4):\n for j in range(1, 7):\n p = pow(divisors[i], j)\n if ((n % p) == 0) & (p < n):\n numOfDiv[i] = numOfDiv[i] + 1\n\nprint(numOfDiv)\ns = a\nfor i in range(0, 4):\n for j in range(1, numOfDiv[i]+1):\n p = pow(divisors[i], j)\n s = s[p-1::-1]\n s = s + a[p:]\n\nprint(s[::-1])"}, {"source_code": "# ANSHUL GAUTAM\n# IIIT-D\n\ndef isPrime(x):\n\tfor i in range(2,(x//2)+1):\n\t\tif(x%i == 0):\n\t\t\treturn False\n\treturn True\n\ndef div(x):\n\tl = [x]\n\tfor i in range((x//2)+1,1,-1):\n\t\tif(x%i == 0):\n\t\t\tl.append(i)\n\treturn l\n\nn = int(input())\ns = input()\nif(isPrime(n) == False):\n\tprint(s[::-1])\nelse:\n\tL = list(s)\n\tl = div(n)\n\tl.sort()\n\tfor i in range(len(l)):\n\t\td = l[i]\n\t\tl1 = L[:d]\n\t\tl1 = l1[::-1]\n\t\tl2 = L[d:]\n\t#\tprint(\"l1:\",l1)\n\t#\tprint(\"l2:\",l2)\n\t\tL = l1+l2\n\t#\tprint(\"L:\",L)\n\t\ts = ''.join(L)\n\tprint(s)\n"}, {"source_code": "size = int(input())\ns = input()\n\nfor i in range(2, len(s) + 1) :\n if size % i == 0 :\n temp1 = \"\".join(reversed(s[0 : i]))\n temp2 = \"\".join(s[0 : i])\n s = s.replace(temp2, temp1)\nprint(s)"}, {"source_code": "a = input()\nn = int(a)\na = input()\n\ndivisors = [2, 3, 5, 7]\nnumOfDiv = [0, 0, 0, 0]\n\nfor i in range(0, 4):\n for j in range(1, 7):\n p = pow(divisors[i], j)\n if ((n % p) == 0) & (p < n):\n numOfDiv[i] = numOfDiv[i] + 1\n\ns = a\nfor i in range(0, 4):\n for j in range(1, numOfDiv[i]+1):\n p = pow(divisors[i], j)\n s = s[p-1::-1]\n s = s + a[p:]\n\nprint(s[::-1])"}, {"source_code": "def devide(t):\n l_of_d = []\n for i in range(2,t-1):\n if t % i == 0:\n l_of_d.append(i)\n return l_of_d\n\ndef decrypt(_str,t):\n ss = _str\n for i in devide(t):\n ss = ss.replace(ss[0:i],ss[i-1::-1])\n return ss[::-1]\n\nt = int(input())\n_str = str(input())\nprint(decrypt(_str,t))\n\n"}, {"source_code": "import sys\n\ndef i_ints():\n return map(int, sys.stdin.readline().split())\n\nn, = i_ints()\ns = input()\n\nfor d in range(n, 0, -1):\n if n % d == 0:\n s = s[:d][::-1] + s[d:]\n \nprint(s)\n\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read non spaced string and elements are integers to list of int\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\n#to read non spaced string and elements are character to list of character\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\n#get word sepetared list of character\nget_char_list = lambda: sys.stdin.readline().strip().split() \n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------#\ndef factors(n):\n lst = []\n i = 1\n while i*i <= n:\n if n%i == 0:\n lst.append(i)\n lst.append(n//i)\n i += 1\n return sorted(lst)\n\nn = get_int()\nstring = get_string()\nf = factors(n)\n\nfor i in f:\n string = string[:i][::-1] + string[i:]\nprint(string)\n\n"}, {"source_code": "n=int(input())\ns=input()\ns=s[::-1]\n\ni=n-1\nwhile i>1:\n if n%i==0:\n t=s[:i]\n t=t[::-1]\n s=t+s[i:]\n i-=1\nprint(s)"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n,0,-1):\n if n%i==0:\n s=s[i-1:0:-1]+s[0]+s[i:]\nprint(s)"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(2,n+1):\n print(n%i)\n if n%i==0:\n d=s[:i]\n s=d[::-1]+s[i:]\n #print(d,s[i:])\nprint(s)"}, {"source_code": "n = int(input())\nstring = list(input())\ndivisors = []\nfor i in range(1, n+1):\n if n % i == 0:\n divisors.append(i-1)\nfor divisor in divisors:\n print(divisor)\n rev = string[:divisor+1]\n rev = rev[::-1]\n string = rev + string[divisor+1:]\n # print(string)\nprint(\"\".join(string))\n"}, {"source_code": "import math\ndef primefact(n):\n l=[]\n while n%2==0:\n l.append(2)\n n=n/2\n for i in range(3,int(math.sqrt(n))+1,2):\n while n%i==0:\n l.append(i)\n n=n/i\n if n>1:\n l.append(int(n))\n return l\n\n\nn=int(input())\ns = list(map(str,input()))\nl=primefact(n)\nfor i in l:\n for j in range(i):\n for k in range(i-j-1):\n s[k],s[k+1]=s[k+1],s[k]\ns.reverse()\nj=\"\"\nfor i in s:\n j+=i\nprint(j)"}, {"source_code": "N = int(input())\nS = input()\n\ndiv = []\nn = N\nwhile n > 0:\n div.append(n)\n n //= 2\n\ndiv.reverse()\n\nfor d in div:\n S = S[0:d][::-1] + S[d:]\n\nprint(S)"}, {"source_code": "def devide(t):\n l_of_d = []\n for i in range(2,t-1):\n if t % i == 0:\n l_of_d.append(i)\n return l_of_d\n\ndef decrypt(_str,t):\n ss = _str\n for i in devide(t):\n ss = ss.replace(ss[0:i],ss[i-1::-1])\n return ss[::-1]\n\nt = int(input())\n_str = str(input())\nprint(decrypt(_str,t))\n\n"}, {"source_code": "n = int(input())\nl1 = list(input())\nc=[]\ni=0\nwhile i<=n:\n if i%n==0:\n p = l1[:i]\n p.reverse()\n l1 = p + l1[i+1:]\n i+=1\nl1.reverse()\nprint(*l1)"}, {"source_code": "n = int(input())\nl = input()\n\nt = []\ncount = 0\nfor item in range(1, n + 1):\n if n % item == 0:\n t.append(item)\nfor item in t:\n l = l.replace(l[0:item], l[0:item][::-1])\nprint(l)\n"}, {"source_code": "n = int(input())\ns = input()\nd = []\nfor i in range(1, n+1):\n if n % i == 0:\n d.append(i)\nfor c in d:\n s = s[c-1::-1]+s[c::]\n print(s)\n"}], "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3"} {"source_code": "n=int(raw_input())\na=[]\nb=[]\n \nz=raw_input().split(' ')\nk1=int(z[0])\nfor i in range(0,k1):\n a.append(int(z[i+1]))\n\nz=raw_input().split(' ')\nk2=int(z[0])\nfor i in range(0,k2):\n b.append(int(z[i+1]))\n\nk=0\nwhile True:\n if k>10000 or len(a)==0 or len(b)==0:\n break\n if a[0]>b[0]:\n a.append(b[0])\n a.append(a[0])\n else:\n b.append(a[0])\n b.append(b[0])\n del(a[0]); del(b[0])\n k+=1\n \nif k>10000: \n print(\"-1\")\nelse:\n if len(b)==0:\n print(str(k)+\" 1\")\n else:\n print(str(k)+\" 2\")\n", "positive_code": [{"source_code": "\ndef all_equal(arr, a):\n\tfor i in range(len(a)):\n\t\tif check_equal(arr, a[i]):\n\t\t\treturn True\n\treturn False\n\ndef check_equal(a, b):\n\tif len(a) != len(b):\n\t\treturn False\n\tfor i in range(len(a)):\n\t\tif a[i] != b[i]:\n\t\t\treturn False\n\treturn True\n\nn = int(input())\nk1 = [int(i) for i in input().split()]\nk2 = [int(i) for i in input().split()]\n\na = k1[1:]; k1 = k1[0]\nb = k2[1:]; k2 = k2[0]\n\ntemp_a = a[1:]\ntemp_b = b[1:]\nif a[0] > b[0]:\n\ttemp_a.append(b[0])\n\ttemp_a.append(a[0])\nelse:\n\ttemp_b.append(a[0])\n\ttemp_b.append(b[0])\n\na = [a]\nb = [b]\ncount = 1\n\nwhile (not all_equal(temp_a, a) or not all_equal(temp_b, b)) and len(temp_a) and len(temp_b):\n\ta.append(temp_a)\n\tb.append(temp_b)\n\t\n\ta1 = temp_a[1:]\n\tb1 = temp_b[1:]\n\n\tif temp_a[0] > temp_b[0]:\n\t\ta1.append(temp_b[0])\n\t\ta1.append(temp_a[0])\n\telse:\n\t\tb1.append(temp_a[0])\n\t\tb1.append(temp_b[0])\n\n\ttemp_a = a1\n\ttemp_b = b1\n\tcount += 1\n\t# print(a, temp_a)\n\nif not len(temp_a):\n\tprint(count, 2)\nelif not len(temp_b):\n\tprint(count, 1)\n\nelse:\n\tprint(-1)\n"}, {"source_code": "n = int(raw_input())\n\np1 = map(int, raw_input().split(\" \"))\np2 = map(int, raw_input().split(\" \"))\n\np1 = p1[1:]\np2 = p2[1:]\n\nturns = 0\ni = 0\nj = 0\n\nfound = set([])\n\nnew_p1 = []\nnew_p2 = []\nfound.add((tuple(p1), tuple(p2)))\n\ncount = 0\ninfinite = False\n\nwhile (len(p1) + len(new_p1) - i > 0 and len(p2) + len(new_p2) - j > 0):\n\tif not (i < len(p1) and j < len(p2)):\n\t\tp1 = p1[i:] + new_p1\n\t\tp2 = p2[j:] + new_p2\n\t\tnew_p1 = []\n\t\tnew_p2 = []\n\t\ti = 0\n\t\tj = 0\n\n\t\ttp1, tp2 = tuple(p1), tuple(p2)\n\t\tif (tp1, tp2) in found:\n\t\t\tinfinite = True\n\t\t\tbreak\n\t\telse:\n\t\t\tfound.add((tp1, tp2))\n\n\tnump1 = p1[i]\n\tnump2 = p2[j]\n\ti += 1;\n\tj += 1;\n\n\tif nump1 > nump2:\n\t\tnew_p1.append(nump2)\n\t\tnew_p1.append(nump1)\n\telse:\n\t\tnew_p2.append(nump1)\n\t\tnew_p2.append(nump2)\n\tcount += 1\n\nif infinite:\n\tprint -1\nelif len(p1) + len(new_p1) - i == 0:\n\tprint count, 2\nelse:\n\tprint count, 1\n\n\n"}, {"source_code": "from sys import stdin , stdout \nn = int(stdin.readline())\narray1 = list(map(int,stdin.readline().split()))[1:]\narray2 = list(map(int,stdin.readline().split()))[1:]\ni=0\nwhile array1 and array2 and i < 1000:\n if array1[0] > array2[0]:\n\n array1.append(array2[0])\n array1.append(array1[0])\n i+=1\n else:\n\n array2.append(array1[0])\n array2.append(array2[0])\n i+=1\n array1.pop(0)\n array2.pop(0)\n \nif len(array1)==0:\n stdout.write(str(i)+\" \"+\"2\"+\"\\n\")\nelif len(array2)== 0:\n stdout.write(str(i)+\" \"+\"1\"+\"\\n\")\nelse:\n stdout.write(\"-1\"+\"\\n\")"}, {"source_code": "N=int(input())\nfrom collections import deque\nA=deque()\nB=deque()\nfor x in range(2):\n a=input().split()\n if x==0: \n for y in range(1,len(a)):\n A.append(int(a[y]))\n else:\n for y in range(1,len(a)):\n B.append(int(a[y]))\nbr=0\np=0\nwhile len(A)!=0 and len(B)!=0 and br<300000:\n c=A.popleft()\n d=B.popleft()\n if c>d:\n A.append(d)\n A.append(c)\n p=1\n else:\n B.append(c)\n B.append(d)\n p=2\n br+=1\n\nif br>=300000:\n print(-1)\nelse:\n print(br,p)\n \n\n \n"}, {"source_code": "nos = int(input())\n\nplayer1 = set([])\nplayer2 = set([])\ndec1 = [int(x) for x in input().split()][1:]\ndec2 = [int(x) for x in input().split()][1:]\n\ncount=0\nwhile dec1 and dec2:\n \n card1 = dec1.pop(0)\n card2 = dec2.pop(0)\n if card1 > card2:\n dec1.append(card2)\n dec1.append(card1)\n else:\n dec2.append(card1)\n dec2.append(card2)\n count+=1\n t2 = tuple(dec2)\n t1 = tuple(dec1)\n if t1 in player1 and t2 in player2:\n print(-1)\n break\n else:\n player1.add(t1)\n player2.add(t2)\nelse:\n print(count,1 if dec1 else 2)\n \n \n\n\n"}, {"source_code": "n = int(input())\nlist1 = list(map(int, input().split()))\nlist2 = list(map(int, input().split()))\nk1 = list1[0]\ndel list1[0]\nk2 = list2[0]\ndel list2[0]\ni = 0\ncount = 0\nwhile(len(list1) != 0 and len(list2) != 0):\n if(list1[i] < list2[i]):\n list2.append(list1[i])\n list2.append(list2[i])\n del list1[i]\n del list2[i]\n count += 1\n elif(list2[i] < list1[i]):\n list1.append(list2[i])\n list1.append(list1[i])\n del list1[i]\n del list2[i]\n count += 1\n else:\n del list1[i]\n del list2[i]\n if count == n**2+10:\n print(\"-1\")\n break\nif len(list1) == 0:\n print(\"{} 2\".format(count))\nif len(list2) == 0:\n print(\"{} 1\".format(count))"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))[1:]\nb = list(map(int,input().split()))[1:]\n\ni=0\ng=1000000\nwhile i<g and len(a)>0 and len(b)>0:\n if a[0]<b[0]:\n b = b[1:]+a[:1]+b[:1]\n a = a[1:]\n else:\n a = a[1:]+b[:1]+a[:1]\n b = b[1:]\n i+=1\n \nif i==g:\n print(-1)\nelif len(a)==0:\n print(i,2)\nelse:\n print(i,1)"}, {"source_code": "import copy\nn = int(raw_input())\n\nA = map(int, raw_input().split())\nA.pop(0)\n\nB = map(int, raw_input().split())\nB.pop(0)\n\nbuf = list()\ncount = 0\nwhile len(A) > 0 and len(B) > 0:\n\tbuf.append(copy.deepcopy([A, B]))\n\n\tif A[0] < B[0]:\n\t\ttmp = B[0]\n\t\tB.pop(0)\n\t\tB.append(A[0])\n\t\tB.append(tmp)\n\t\tA.pop(0)\n\n\telse:\n\t\ttmp = A[0]\n\t\tA.pop(0)\n\t\tA.append(B[0])\n\t\tA.append(tmp)\n\t\tB.pop(0)\n\n\tcount += 1\n\tif [A, B] in buf:\n\t\tprint -1\n\t\texit()\n\nwin = 1 if len(A) > 0 else 2\nprint count, win"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nb=map(int,raw_input().split())\nd={}\nq=[]\nx=(tuple(a[1:]),tuple(b[1:]))\nq.append(x)\nd[x]=0\nwhile q!=[]:\n #print \"_ \",q\n p=q[0]\n del q[0]\n if p[0][0]>p[1][0]:\n t1=tuple(list(p[0][1:])+[p[1][0],p[0][0]])\n t2=tuple(list(p[1][1:]))\n if (t1,t2) not in d:\n d[(t1,t2)]=d[p]+1\n if len(t2)==0:\n print d[(t1,t2)],1\n exit(0)\n q.append((t1,t2))\n else:\n t2=tuple(list(p[1][1:])+[p[0][0],p[1][0]])\n t1=tuple(list(p[0][1:]))\n if (t1,t2) not in d:\n d[(t1,t2)]=d[p]+1\n if len(t1)==0:\n print d[(t1,t2)],2\n exit(0)\n q.append((t1,t2))\n #print q\nprint -1"}, {"source_code": "#*+++++++++++++++++++++\n# * Written By --------\n# * Boddapati Mahesh **\n# * IIIT Hyderabad *****\n# */\n\nimport sys \n\nli=[]\n\nl=[]\n\nm=[]\n\np=()\n\nq=()\n\ndic={}\n\nn=input()\n\nli=map(int,raw_input().split())\n\nli.reverse()\n\nfor i in range(0,len(li)-1):\n l.append(li[i])\n\nli=map(int,raw_input().split())\n\nli.reverse()\n\nfor i in range(0,len(li)-1):\n m.append(li[i])\n\ncount=0\n\nwhile(1):\n if(len(l)==0):\n sys.stdout.write(str(count))\n sys.stdout.write(\" \")\n sys.stdout.write('2')\n break\n elif(len(m)==0):\n sys.stdout.write(str(count))\n sys.stdout.write(\" \")\n sys.stdout.write('1')\n break\n else:\n p=tuple(l)\n q=tuple(m)\n if(p in dic and q in dic):\n sys.stdout.write('-1')\n break\n else:\n if(p in dic):\n dic[q]=1\n elif(q in dic):\n dic[p]=1\n else:\n dic[p]=1\n dic[q]=1\n a=l.pop()\n b=m.pop()\n if(a<b):\n m.insert(0,a)\n m.insert(0,b)\n elif(b<a):\n l.insert(0,b)\n l.insert(0,a)\n count+=1\nprint \n"}, {"source_code": "#!/usr/bin/python\n# -*- encoding: utf-8 -*-\n# pylint: disable=invalid-name,missing-docstring,bad-builtin\nfrom collections import deque\n\ndef main():\n raw_input()\n pl1 = deque(reversed(map(int, raw_input().split())))\n pl1.pop()\n pl2 = deque(reversed(map(int, raw_input().split())))\n pl2.pop()\n visitedStates, steps = set(), 0\n while True:\n if not (pl1 and pl2):\n print steps, (1 if pl1 else 2)\n return\n if tuple(pl1) + tuple(pl2) in visitedStates:\n print -1\n return\n visitedStates.add(tuple(pl1) + tuple(pl2))\n x, y = pl1.pop(), pl2.pop()\n if x > y:\n pl1.appendleft(y)\n pl1.appendleft(x)\n else:\n pl2.appendleft(x)\n pl2.appendleft(y)\n steps += 1\n\nmain()\n\n\n"}, {"source_code": "\n\n'''\n---------------vishva-mitra----------------\n\n'''\nimport Queue\n\nN = int(raw_input())\ntmp = map(int, raw_input().strip().split(' '))\nq1 = Queue.Queue()\nfor x in tmp[1:] :\n q1.put(x)\ntmp = map(int, raw_input().strip().split(' '))\nq2 = Queue.Queue()\nfor x in tmp[1:] :\n q2.put(x)\n\ndic = {(tuple(q1.queue), tuple(q2.queue)):True}\nres = 0\nwhile 1 :\n tmp1 = q1.get()\n tmp2 = q2.get()\n if tmp1 > tmp2 :\n q1.put(tmp2)\n q1.put(tmp1)\n else :\n q2.put(tmp1)\n q2.put(tmp2)\n tmp = (tuple(q1.queue), tuple(q2.queue))\n if tmp in dic :\n print -1\n exit(0)\n dic[tmp] = True\n res += 1\n if q1.qsize() == 0:\n print res,2\n exit(0)\n if q2.qsize() == 0 :\n print res,1\n exit(0)"}, {"source_code": "input()\nR=lambda:map(int,raw_input().split())[1:]\na=R()\nb=R()\nr=0\nwhile a and b:\n r+=1\n if r>1234:\n print -1\n exit(0)\n x,y=a.pop(0),b.pop(0)\n if x>y:\n a+=[y,x]\n else:\n b+=[x,y]\nprint r,1 if a else 2\n"}, {"source_code": "def main():\n #gathering data\n n = int(input())\n temp = input().split()\n p1n= int(temp[0])\n p1cards = [int(i) for i in temp[1:]]\n temp = input().split()\n p2n = int(temp[0])\n p2cards = [int(i) for i in temp[1:]]\n stale = False\n history1 = []\n history2 = []\n counter = 0\n # history.append(p1cards)\n # history.append(p2cards)\n # if (p1cards[0] > p2cards[0]):\n # p1cards, p2cards = switchero(p1cards,p2cards)\n # elif (p2cards[0] > p1cards[0]):\n # p2cards, p1cards = switchero(p2cards,p1cards)\n\n while(len(p1cards) != 0 and len(p2cards) != 0 and stale == False):\n counter += 1\n history1.append(p1cards)\n history2.append(p2cards)\n if (p1cards[0] > p2cards[0]):\n p1cards, p2cards = switchero(p1cards,p2cards)\n elif (p2cards[0] > p1cards[0]):\n p2cards, p1cards = switchero(p2cards,p1cards)\n for cards1 in history1:\n if p1cards == cards1:\n for cards2 in history2:\n if p2cards == cards2:\n stale = True\n continue\n if stale == True:\n counter = -1\n if len(p1cards) == 0:\n winner = 2\n print(counter, winner)\n elif len(p2cards) ==0:\n winner = 1\n print(counter, winner)\n else:\n print(counter)\n \n \n \n\ndef switchero(winner,loser):\n if len(loser) == 1:\n losernew = []\n else:\n losernew = loser[1:]\n winnernew = winner[1:]\n winnernew.append(loser[0])\n winnernew.append(winner[0])\n return winnernew,losernew \n\n \n\n \n\n\n \n\n\nif __name__ == \"__main__\": main()"}, {"source_code": "n=input()\na=[int(i) for i in raw_input().split()]\nb=[int(i) for i in raw_input().split()]\nk1=a[0]\na=a[1:]\nk2=b[0]\nb=b[1:]\nd={}\nf=0\nturns=0\nwhile(k1>0 and k2>0):\n ta=a[0]\n tb=b[0]\n turns+=1\n if ta>tb:\n a.pop(0)\n b.pop(0)\n a=a+[tb,ta]\n k1+=1\n k2-=1\n tup=tuple(a+b+[k1])\n if tup in d:\n f=1\n break\n else:\n d[tup]=True\n \n else:\n a.pop(0)\n b.pop(0)\n b=b+[ta,tb]\n k2+=1\n k1-=1\n tup=tuple(a+b+[k1])\n if tup in d:\n f=1\n break\n else:\n d[tup]=True\nif f==1:\n print -1\nelse:\n if k1==0:\n print turns,2\n else:\n print turns,1"}, {"source_code": "def pick_card(k, stack):\n\tk -= 1\n\tdevide = 10**(2*k)\n\tcard = stack / devide\n\tstack = stack % devide\n\treturn k, card, stack\n\ndef puts_card(k, stack, card_w, card_l):\n\tk += 2\n\treturn k, stack*10000 + card_l*100 + card_w\n\nn = int(raw_input())\ninputs = map(int,raw_input().split(\" \"))\nk1 = int(inputs[0])\nstack1 = sum((inputs[i]) * (10 ** (2*(k1-i))) for i in range(1,k1+1))\ninputs = map(int,raw_input().split(\" \"))\nk2 = int(inputs[0])\nstack2 = sum((inputs[i]) * (10 ** (2*(k2-i))) for i in range(1,k2+1))\n\nplayed = set([(stack1,stack2)])\nfight = 0\nwhile 1:\n\tfight += 1\n\tk1, card1, stack1 = pick_card(k1, stack1)\n\tk2, card2, stack2 = pick_card(k2, stack2)\n\tif card1 > card2:\n\t\tk1, stack1 = puts_card(k1, stack1, card1, card2)\n\telse:\n\t\tk2, stack2 = puts_card(k2, stack2, card2, card1)\n\n\tif k1 == 0:\n\t\tprint fight, 2\n\t\tbreak\n\telif k2 == 0:\n\t\tprint fight, 1\n\t\tbreak\n\telif (stack1, stack2) in played:\n\t\tprint -1\n\t\tbreak\n\telse:\n\t\tplayed.add((stack1,stack2))\n"}, {"source_code": "n = int(input())\na = [int(c) for c in input().split()]\nb = [int(c) for c in input().split()]\n\ndel a[0]\ndel b[0]\n\ndict = set()\n\nmoves = 0\nwhile True:\n if (len(a) == 0 or len(b) == 0 or (''.join(str(e) for e in a)+'.'+''.join(str(e) for e in b) in dict)):\n break\n\n dict.add(''.join(str(e) for e in a)+'.'+''.join(str(e) for e in b))\n\n winner = []\n looser = []\n if a[0]>b[0]:\n winner = a\n looser = b\n else:\n winner = b\n looser = a\n winner.append(looser[0])\n winner.append(winner[0])\n\n del winner[0]\n del looser[0]\n\n moves += 1\n\nif (len(a) == 0):\n print(\"%d 2\" % moves)\nelif (len(b) == 0):\n print(\"%d 1\" % moves)\nelse:\n print(\"-1\")\n\n"}, {"source_code": "input()\nR=lambda:map(int,raw_input().split())[1:]\na=R()\nb=R()\nr=0\nwhile a and b:\n r+=1\n if r>1234:\n print -1\n exit(0)\n x,y=a.pop(0),b.pop(0)\n if x>y:\n a+=[y,x]\n else:\n b+=[x,y]\nprint r,1 if a else 2"}, {"source_code": "from copy import deepcopy as dcp\nn = int(raw_input())\nstack1 = map(int,raw_input().split(\" \"))\ninit1 = dcp(stack1)\nstack2 = map(int,raw_input().split(\" \"))\ninit2 = dcp(stack2)\nfight = 0\nwhile 1:\n\tfight += 1\n\tcard1 = stack1.pop(1)\n\tstack1[0] -= 1\n\tcard2 = stack2.pop(1)\n\tstack2[0] -= 1\n\tif card1 > card2:\n\t\tstack1 += [card2, card1]\n\t\tstack1[0] += 2\n\telif card2 > card1:\n\t\tstack2 += [card1, card2]\n\t\tstack2[0] += 2\n\tif stack1[0] == 0:\n\t\tprint fight, 2\n\t\tbreak\n\telif stack2[0] == 0:\n\t\tprint fight, 1\n\t\tbreak\n\tif stack1 == init1 and stack2 == init2 or fight == 100000:\n\t\tprint -1\n\t\tbreak\n\n\n\n"}, {"source_code": "n=input()\ns=set()\na=[map(lambda x: int(x)-1,raw_input().split())[1:] for _ in range(2)]\nG=lambda: str(a[0])+' '+str(a[1])\ns.add(G())\ncnt=0\nwhile 1:\n cnt+=1\n k=1 if a[0][0]<a[1][0] else 0\n a[k]+=[a[k^1][0], a[k][0]]\n a[k].pop(0)\n a[k^1].pop(0)\n state=G()\n if state in s:\n print -1\n break\n if not a[0] or not a[1]:\n print cnt, k+1\n break\n s.add(state)\n"}, {"source_code": "\nN=int(input())\nA=list(map(int,input().rstrip().split()))\nB=list(map(int,input().rstrip().split()))\ninitA=A[1:len(A)]\ninitB=B[1:len(B)]\ninitA.reverse()\ninitB.reverse()\ntempA=[]\ntempB=[]\ntempA.extend(initA)\ntempB.extend(initB)\ncount=0\nwhile(1!=0):\n\tif tempA[-1]>tempB[-1]:\n\t\ttempA.insert(0,tempB.pop())\n\t\ttempA.insert(0,tempA.pop())\n\telse:\n\t\ttempB.insert(0,tempA.pop())\n\t\ttempB.insert(0,tempB.pop())\n\tif count==100:\n\t\ttemptB=[]\n\t\ttemptB.extend(tempB)\n\t\ttemptA=[]\n\t\ttemptA.extend(tempA)\n\tif tempB==initB and tempA==initA:\n\t\tprint(-1)\n\t\tbreak\n\telif count>100 and tempA==temptA and tempB==temptB:\n\t\tprint(-1)\n\t\tbreak\n\telif len(tempB)==0:\n\t\tprint(count+1,1)\n\t\tbreak\n\telif len(tempA)==0:\n\t\tprint(count+1,2)\n\t\tbreak\n\telse:\n\t\tcount+=1\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))[1:]\nb = list(map(int, input().split()))[1:]\nd = {}\nd[(tuple(a), tuple(b))] = True\nres = 0\nwhile len(a) and len(b):\n\tres += 1\n\tif a[0] > b[0]:\n\t\ta.extend([b[0], a[0]])\n\telse:\n\t\tb.extend([a[0], b[0]])\n\ta.pop(0)\n\tb.pop(0)\n\tif (tuple(a), tuple(b)) in d:\n\t\tprint(-1)\n\t\texit()\n\td[(tuple(a), tuple(b))] = True\nprint(res, 1 + (len(a) == 0))"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(2*10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n if not li: return\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\nfrom collections import deque\nn=input()\ns1=deque(listInput()[1:])\ns2=deque(listInput()[1:])\ntied=False\nstates=set([])\nturns=0\nwhile s1 and s2:\n if (tuple(s1),tuple(s2)) in states:\n tied=True\n break\n else: states.add((tuple(s1),tuple(s2)))\n a=s1.popleft()\n b=s2.popleft()\n if a>b:\n s1.append(b)\n s1.append(a)\n else: \n s2.append(a)\n s2.append(b)\n turns+=1\nif tied:\n print -1\nelse:\n if s1:\n print turns,1\n else: print turns,2"}, {"source_code": "input()\nR=lambda:map(int,raw_input().split())[1:]\na=R()\nb=R()\nr=0\nwhile a and b:\n r+=1\n if r>1234:\n print -1\n exit(0)\n x,y=a.pop(0),b.pop(0)\n if x>y:\n a+=[y,x]\n else:\n b+=[x,y]\nprint r,1 if a else 2\n"}, {"source_code": "\n\nn = int(raw_input())\n\ns1 = map(int, raw_input().split())[1:]\ns2 = map(int, raw_input().split())[1:]\ns1.reverse()\ns2.reverse()\n\ndef make_state():\n return ','.join(map(str, s1)) + ';' + ','.join(map(str, s2))\n\nstates = list()\nstates.append(make_state())\n\nrun = True\nhits = 0\nwhile s1 and s2:\n hits += 1\n k1 = s1.pop()\n k2 = s2.pop()\n\n if k1 > k2:\n s1.insert(0, k2)\n s1.insert(0, k1)\n else:\n s2.insert(0, k1)\n s2.insert(0, k2)\n\n state = make_state()\n if state in states:\n print -1\n exit()\n\n states.append(state)\n\nwinner = 1 if s1 else 2\nprint hits, winner\n"}, {"source_code": "__author__ = '11x256'\nfrom Queue import deque\nn = int(raw_input())\n\na = deque(map(int,raw_input().split()))\nb = deque(map(int,raw_input().split()))\n\na.popleft()\nb.popleft()\n\nwars =0\nfor i in range(0,1000):\n if len(a) == 0:\n print str(wars)+' '+'2'\n exit()\n elif len(b) == 0 :\n print str(wars) + ' 1'\n exit()\n wars+=1\n\n ta = a.popleft()\n tb = b.popleft()\n if ta > tb:\n a.append(tb)\n a.append(ta)\n else:\n b.append(ta)\n b.append(tb)\nprint -1\n"}, {"source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\nfrom math import ceil, floor;\n\n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp\n\n## gcd function\ndef gcd(a,b):\n if a == 0:\n return b\n return gcd(b%a, a)\n\n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k \n res = 1\n for i in range(k): \n res = res * (n - i) \n res = res / (i + 1) \n return int(res) \n\n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0):\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if a[mid] < x:\n lo = mid+1\n else:\n hi = mid\n return lo\n\n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n\n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n\n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b\n\n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n\n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n\n\n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n\n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e6 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n\n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)]\n# spf_sieve() \ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()))\n## taking string array input\ndef str_array():\n return input().strip().split();\n\n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n\n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n\nn = int(input()); a = int_array(); b = int_array();\nk1 = a[0]; a = a[1:]; k2 = b[0]; b = b[1:];\nia = a.copy(); ib = b.copy();\ncount = 0; f = 0; won = 2;\nwhile(1):\n if not a or not b:\n if not a:\n won = 2;\n else:\n won = 1;\n f = 1; break;\n count += 1;\n x = a.pop(0); y = b.pop(0);\n if x > y:\n a.append(y); a.append(x);\n else:\n b.append(x); b.append(y);\n if (a == ia and b == ib) or count == 100000:\n break;\nif f:\n print(*(count, won));\nelse:\n print(-1);"}, {"source_code": "from collections import deque\nimport math\n\nn = int(raw_input())\nl1 = raw_input().split(\" \")\nl1 = [int(l1[i]) for i in range(1,int(l1[0])+1)]\nl2 = raw_input().split(\" \")\nl2 = [int(l2[i]) for i in range(1,int(l2[0])+1)]\nl1 = deque(l1)\nl2 = deque(l2)\n\nc1 = l1[0]\nc2 = l2[0]\n\nm = math.sqrt((n+1) * (math.factorial(n)))\n\n\nc = 0\nf = 0\ns = 0\n\nwhile len(l1) != 0 and len(l2) != 0:\n a = l1.popleft()\n b = l2.popleft()\n \n if c >= m:\n print -1\n f = 1\n break\n \n if a < b:\n l2.append(a)\n l2.append(b)\n else:\n l1.append(b)\n l1.append(a)\n \n s = 1\n c = c+1\n \n \nif f == 0:\n if len(l1) == 0:\n print c, 2\n else:\n print c, 1"}, {"source_code": "n = int(input())\nlst1= list(map(int,input().split()))\nk1 =lst1.pop(0)\n\nlst2=list(map(int,input().split()))\nk2=lst2.pop(0)\n\n\ncnt =0 \nlast1 ,last2= lst1[0],lst2[0]\nwhile 1 :\n \n if len(lst1)==0 or len(lst2)==0 or cnt>1e7:break \n a = lst1.pop(0) \n b=lst2.pop(0) \n if last1==b and last2==a:\n cnt=-1\n break \n last1=a \n last2=b\n if a>b:\n lst1.append(b) \n lst1.append(a)\n else :\n lst2.append(a) \n lst2.append(b)\n cnt +=1; \nif cnt==-1 or cnt>1e7:print(-1)\nelse :\n if len(lst1)==0:\n print(cnt , 2)\n else :\n print(cnt , 1)"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)\n#from bisect import bisect_right as br #c++ upperbound br(array,element)\ndef main():\n n=input()\n a=list(map(int,input().split(\" \")))[1:]\n b=list(map(int,input().split(\" \")))[1:]\n temp=max(a+b)\n if a.count(temp)>0 and b.count(temp)>0:\n print(-1)\n else:\n chk=0\n cnt=0\n while len(a)>0 and len(b)>0:\n if a[0]>b[0]:\n a=a[1:]+b[0:1]+a[0:1]\n b=b[1:]\n elif b[0]>a[0]:\n b=b[1:]+a[0:1]+b[0:1]\n a=a[1:]\n else:\n a=a[1:]+a[0:1]\n b=b[1:]+b[0:1]\n cnt+=1\n if cnt>1000:\n chk=1\n break\n if chk==1:\n print(-1)\n else:\n if len(b)==0:\n print(cnt,1)\n else :\n print(cnt,2)\n\n\n\n \n\n\n\n\n\n#-----------------------------BOSS-------------------------------------!\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "from sys import stdin,stdout\ninput = stdin.readline\ndef write(n,sep=\"\\n\"):\n\tstdout.write(str(n))\n\tstdout.write(sep)\ndef gil():\n\treturn list(map(int, input().split()))\nn = int(input())\na, *ka = gil()\nb, *kb = gil()\ns = []\nc = 0\nwhile len(ka) > 0 and len(kb) > 0:\n\tc += 1\n\tx = (ka.copy(),kb.copy())\n\tif x in s:\n\t\tprint(-1)\n\t\tbreak\n\ts.append(x)\n\ta = ka.pop(0)\n\tb = kb.pop(0)\n\tif a > b:\n\t\tka.append(b)\n\t\tka.append(a)\n\telse:\n\t\tkb.append(a)\n\t\tkb.append(b)\nelse:\n\tif len(ka) == 0:\n\t\ty = 2\n\telse:\n\t\ty = 1\n\tprint(c, y)\n"}, {"source_code": "n = int(input())\ntemp = list(map(int, input().split()))\nk1 = temp[0]\na = temp[1:].copy()\ntemp = list(map(int, input().split()))\nk2 = temp[0]\nb = temp[1:].copy()\n\ncount = 0\nl1 = len(a)\nl2 = len(b)\nwhile count < 1000:\n aTemp = a.pop(0)\n bTemp = b.pop(0)\n if aTemp > bTemp:\n a.append(bTemp)\n a.append(aTemp)\n l1 += 1\n l2 -= 1\n else:\n b.append(aTemp)\n b.append(bTemp)\n l2 += 1\n l1 -= 1\n count += 1\n if l1 == 0 or l2 == 0:\n break\nif l1 == 0 or l2 == 0:\n print(count, '1' if l2 == 0 else '2')\nelse:\n print(-1)\n"}, {"source_code": "n = int(input())\nfrom collections import deque\nk1 = list(map(int, input().split()))\nk1 = deque(k1[1:])\nk2 = list(map(int, input().split()))\nk2 = deque(k2[1:])\na = []\nb = []\ncount = 0\nwhile list(k1) not in a or list(k2) not in b:\n a.append(list(k1))\n b.append(list(k2))\n if k1[0] > k2[0]:\n k1.append(k2[0])\n k1.append(k1[0])\n k1.popleft()\n k2.popleft()\n else:\n k2.append(k1[0])\n k2.append(k2[0])\n k1.popleft()\n k2.popleft()\n count += 1\n if len(k2) == 0:\n print(count, 1)\n exit(0)\n elif len(k1) == 0:\n print(count, 2)\n exit(0)\nprint(-1)"}, {"source_code": "# WeirdBugsButOkay\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nans = 0\na.pop(0), b.pop(0)\nwhile a and b :\n if ans > 110 :\n print(-1)\n exit(0)\n ans += 1\n x = a.pop(0)\n y = b.pop(0)\n if x > y :\n a.append(y)\n a.append(x)\n else :\n b.append(x)\n b.append(y)\nif a :\n print(ans, 1)\nelse :\n print(ans, 2)"}, {"source_code": "a = int(input())\n\nx = list(map(int, input().split(' ')))[1:]\ny = list(map(int, input().split(' ')))[1:]\n\nnum = 0\nstates = []\nwhile len(x)>0 and len(y)>0:\n\ttx = x[0]\n\tty = y[0]\n\tif tx > ty:\n\t\tx = x[1:] + [ty] + [tx]\n\t\ty = y[1:]\n\telse:\n\t\ty = y[1:] + [tx] + [ty]\n\t\tx = x[1:]\n\tnum += 1\n\t\n\tstates.append([x, y])\n\t\n\tif num > 10**5:\n\t\tif [x, y] in states:\n\t\t\tprint(-1)\n\t\t\tquit()\n\t\nif x == []:\n\tprint(num, 2)\nelse:\n\tprint(num, 1)\n\t"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\na = a[1:]\nb = b[1:]\ncount = 0\nflag = False\nwhile len(a)!=0 and len(b)!=0:\n x = a.pop(0)\n y = b.pop(0)\n if x < y:\n b.append(x)\n b.append(y)\n elif x > y:\n a.append(y)\n a.append(x)\n count+=1\n if count==50000:\n flag = True\n break\nif flag:\n print(-1)\n\nelif len(a)>len(b):\n print (count,1)\n\nelif len(b)>len(a):\n print (count,2)\n"}, {"source_code": "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n# sys.setrecursionlimit(pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(\" \".join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\nn = int(data())\ns1, s2 = deque(l()[1:]), deque(l()[1:])\nstate = set()\nstate.add((tuple(s1), tuple(s2)))\ncnt = 0\nwhile True:\n t1, t2 = s1.popleft(), s2.popleft()\n if t1 > t2:\n s1.append(t2)\n s1.append(t1)\n else:\n s2.append(t1)\n s2.append(t2)\n # print(s1, s2)\n if not s1:\n out(cnt + 1, 2)\n exit()\n if not s2:\n out(cnt + 1, 1)\n exit()\n cnt += 1\n if (tuple(s1), tuple(s2)) in state or (tuple(s2), tuple(s1)) in state:\n out(-1)\n exit()\n state.add((tuple(s1), tuple(s2)))\n"}, {"source_code": "x=int(input())\nA=list(map(int,input().split()))\nA=A[1:]\n#print(A)\nD=A\n#print(D)\nB=list(map(int,input().split()))\nB=B[1:]\nE=B\nC=[]\n#print(A)\n#print(B)\ncount=0\nnum=1000\nwhile(num>0):\n\tif count==999:\n\t\tstate=10000\n\t\tbreak\n\t#print(D)\n\tstate=-100\n\tif A==C:\n\t\tstate=10\n\t\tbreak\n\tif B==C:\n\t\tstate=100\n\t\tbreak\n\tif A[0]>B[0]:\n\t\tA.append(B[0])\n\t\tA.append(A[0])\n\t\tA=A[1:]\n\t\tB=B[1:]\n\t\tcount=count+1\n\t\t#print(A,B)\n\t\tstate=0\n\t\tnum=num-1\n\tif state!=0:\t\n\t\tif B[0]>A[0]:\n\t\t\tB.append(A[0])\n\t\t\tB.append(B[0])\n\t\t\tB=B[1:]\n\t\t\tA=A[1:]\n\t\t\tcount=count+1\n\t\t\t#print(A,B)\n\t\t\tnum=num-1\n\t#if A==D:\n\t#\tif B==E:\n\t#\t\tstate=1000\n\t#\t\tbreak\n\t#if A==E:\n\t#\tif B==D:\n\t#\t\tstate=1000\n\t#\t\tbreak\nif state==10:\n\tprint (count,2)\nif state==100:\n\tprint (count,1)\n#CODE BASED ON THE TEST CASES\n#MAHESH JASTI\n#IIIT HYDERABAD\nif state==10000:\n\tprint (-1)\n"}, {"source_code": "n = int(input())\ndef inp(s):\n j = 0\n a = []\n for i in range(len(s)):\n if s[i] == \" \":\n a.append(int(s[j:i]))\n j = i+1\n if i == len(s)-1:\n a.append(int(s[j:]))\n return a\ns1 = input()\ns2 = input()\na = inp(s1)\nb = inp(s2)\na = a[1:]\nb = b[1:]\np = [a]\nq = [b]\ni = 0\nwhile len(a) != 0 and len(b) != 0:\n \n if a[0] > b[0]:\n x = a[0]\n y = b[0]\n a = a[1:]\n b = b[1:]\n a.append(y)\n a.append(x)\n else:\n x = a[0]\n y = b[0]\n a = a[1:]\n b = b[1:]\n b.append(x)\n b.append(y)\n i = i + 1\n if a in p and b in q:\n i = -1\n break\n p.append(a)\n q.append(b)\n\nprint (str(i)+\" \", end = \"\")\n\nif len(a) == 0:\n print (2)\nelif len(b) == 0:\n print (1)\n"}, {"source_code": "from collections import deque\nn = int(input())\na = deque([int(i) for i in input().split()[1:]])\nb = deque([int(i) for i in input().split()[1:]])\nmark = set()\nans = 0\nwhile a and b:\n if str(a)+\" \"+str(b) in mark:\n print(-1)\n exit()\n mark.add(str(a)+\" \"+str(b))\n ans += 1\n aa = a.popleft()\n bb = b.popleft()\n if aa > bb:\n a.append(bb)\n a.append(aa)\n else:\n b.append(aa)\n b.append(bb)\nif a:\n print(ans,1)\nelse:\n print(ans,2)\n"}, {"source_code": "n = int(input())\nsol_1 = list(map(int, input().split()))\nl1 = sol_1[0]\ns1 = l1\nsol_1 = sol_1[1:]\nsol_2 = list(map(int, input().split()))\nl2 = sol_2[0]\ns2 = l2\nsol_2 = sol_2[1:]\ni = 0\nj = 0\nsol_11 = []\nsol_22 = []\np = 10000\nc = 0\nwhile s1 != 0 and s2 != 0 and p > 0:\n if i == len(sol_1):\n i = 0\n sol_1 = sol_11[:]\n sol_11 = []\n if j == len(sol_2):\n j = 0\n sol_2 = sol_22[:]\n sol_22 = [] \n if sol_1[i] > sol_2[j]:\n sol_11.append(sol_2[j])\n sol_11.append(sol_1[i])\n s1 += 1\n s2 -= 1\n else:\n sol_22.append(sol_1[i])\n sol_22.append(sol_2[j]) \n s2 += 1\n s1 -= 1\n i += 1\n j += 1\n c += 1\n p -= 1\nif p == 0:\n print(-1)\nelse:\n if s1 == 0:\n print(c, '2')\n else:\n print(c, '1')"}, {"source_code": "\nfrom collections import deque\n\nn = int(input())\ndec1 = deque()\ndec2 = deque()\n\n\nk1 = input().split()\nfor i in range(1,len(k1)):\n dec1.append(int(k1[i]))\nk2 = input().split()\nfor i in range(1,len(k2)):\n dec2.append(int(k2[i]))\nisAnswer = False\nfor i in range(1, 1000):\n if(len(dec1)==0):\n print(str(i-1)+\" \"+'2')\n isAnswer=True\n break\n elif(len(dec2)==0):\n print(str(i-1)+\" \"+'1')\n isAnswer=True\n break\n x = dec1.popleft()\n y = dec2.popleft()\n if(x>y):\n dec1.append(y)\n dec1.append(x)\n else:\n dec2.append(x)\n dec2.append(y)\n # print(len(dec1))\n #print(len(dec2))\nif(isAnswer==False):\n print(-1)"}, {"source_code": "\n\nfrom collections import deque\nfrom math import factorial\n\nn = int(input())\na1 = deque(map(int,input().split()))\na1.popleft()\na2 = deque(map(int,input().split()))\na2.popleft()\n\ncnt = 0\nf = factorial(n)\nwhile len(a1) != 0 and len(a2) != 0 and cnt <= f:\n\n s1 , s2 = a1.popleft() , a2.popleft()\n if s1 == s2 : continue\n elif s1 > s2 :\n a1.append(s2)\n a1.append(s1)\n elif s2 > s1:\n a2.append(s1)\n a2.append(s2)\n\n cnt +=1\n#print(cnt)\nif cnt > f :\n print('-1')\n\nelse:\n print(cnt , end = ' ')\n if len(a1) == 0 :\n print(2)\n else:\n print(1)\n\n\n\n\n"}, {"source_code": "'''input\n4\n2 1 3\n2 4 2\n'''\n\nn = int(input())\na = tuple(map(int, input().split()))[1:]\nb = tuple(map(int, input().split()))[1:]\nc = 0\ns = set()\nres = 0\n \nwhile (a, b) not in s:\n if not a:\n res = 2\n break\n \n if not b:\n res = 1\n break\n \n s.add((a, b))\n \n x, y = a[0], b[0]\n a, b = a[1:], b[1:]\n c += 1\n \n if x < y:\n b = b + (x, y)\n else:\n a = a + (y, x)\n \nif res == 0:\n print(-1)\nelse:\n print(c, res)\n\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\na = a[1:]\nb = [int(x) for x in input().split()]\nb = b[1:]\nk = 0\nwhile len(a) > 0 and len(b) > 0 and k <= 10 ** 3:\n\tif a[0] > b[0] and (not(a[0] == 0 and b[0] == 9) and not(a[0] == 9 and b[0] == 0)):\n\t\ta.append(b[0])\n\t\ta.append(a[0])\n\t\ta.pop(0)\n\t\tb.pop(0)\n\t\tk += 1\n\telse:\n\t\tb.append(a[0])\n\t\tb.append(b[0])\n\t\ta.pop(0)\n\t\tb.pop(0)\n\t\tk += 1\nif len(a) != 0 and len(b) != 0:\n\tprint(-1)\nelif len(a) > 0:\n\tprint(k, 1)\nelse:\n\tprint(k, 2)\n"}, {"source_code": "'''input\n3\n1 2\n2 1 3\n'''\n# connected components\nfrom sys import stdin\nfrom collections import defaultdict\nimport sys\nfrom collections import deque\nimport time\n\nsys.setrecursionlimit(15000)\n\n\ndef reverse(arr):\n\tc = []\n\tfor i in range(len(arr) -1, 0, -1):\n\t\tc.append(arr[i])\n\treturn c\n\n# main starts\nn = int(stdin.readline().strip())\narr1 = list(map(int, stdin.readline().split()))\narr2 = list(map(int, stdin.readline().split()))\narr1 = reverse(arr1)\nfirst = deque(arr1)\narr2 = reverse(arr2); second = deque(arr2)\ncount = 0\ninitial = time.time()\nwhile time.time() - initial < 1.48 and len(first) > 0 and len(second) > 0:\n\tcount += 1\n\tone = first.pop()\n\ttwo = second.pop()\n\tif one >= two:\n\t\tfirst.appendleft(two)\n\t\tfirst.appendleft(one)\n\telse:\n\t\tsecond.appendleft(one)\n\t\tsecond.appendleft(two)\nif len(first) == 0 and len(second) > 0:\n\tprint(count, 2)\nelif len(first) > 0 and len(second) == 0:\n\tprint(count, 1)\nelse:\n\tprint(-1)"}, {"source_code": "N = int(input())\nl = list(map(int, input().split()))\nk1 = l[0]\nL = l[1:]\nl = list(map(int, input().split()))\nk2 = l[0]\nR = l[1:]\n\nse = set([])\nse.add(tuple(L))\nse.add(tuple(R))\nans = 0\nwhile True:\n # print(L, R)\n if len(L) == 0 or len(R) == 0:\n break\n top_L = L[0]\n top_R = R[0]\n L = L[1:]\n R = R[1:]\n if top_L > top_R:\n L = L + [top_R, top_L]\n else:\n R = R + [top_L, top_R]\n if tuple(L) in se and tuple(R) in se:\n print(-1)\n exit()\n se.add(tuple(L))\n se.add(tuple(R))\n ans += 1\n\nif len(L) == 0:\n print(\"{} {}\".format(ans, 2))\nelse:\n print(\"{} {}\".format(ans, 1))\n"}, {"source_code": "def solve(st1,st2):\n\tL = []\n\ts1 = st1[:]\n\ts2 = st2[:]\n\tflag = -1\n\tfights = 0\n\twhile([s1,s2] not in L):\n\t\tx1 = s1[:]\n\t\tx2 = s2[:]\n\t\tL.append([x1,x2])\n\t\tif(len(s1) == 0):\n\t\t\tflag = 2\n\t\t\tbreak\n\t\telif(len(s2) == 0):\n\t\t\tflag = 1\n\t\t\tbreak\n\t\tif(s1[0] > s2[0]):\n\t\t\tx = s2.pop(0)\n\t\t\ty = s1.pop(0)\n\t\t\ts1.append(x)\n\t\t\ts1.append(y)\n\t\telif(s1[0] < s2[0]):\n\t\t\tx = s2.pop(0)\n\t\t\ty = s1.pop(0)\n\t\t\ts2.append(y)\n\t\t\ts2.append(x)\n\t\tfights += 1\n\tif(flag == -1):\n\t\tprint(flag)\n\telse:\n\t\tprint(fights,flag)\n\nN = int(input())\nstack1 = list(map(int, input().split()))\nstack2 = list(map(int, input().split()))\nstack1.pop(0)\nstack2.pop(0)\nsolve(stack1,stack2)\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nfrom collections import deque\n\nn=int(input())\nll1=deque(map(int,input().split()))\nll2=deque(map(int,input().split()))\ns1=ll1[0]\ns2=ll2[0]\nll1.popleft()\nll2.popleft()\nl1=deque(ll1)\nl2=deque(ll2)\ncou=0\nlol=0\nwhile len(l1)!=0 and len(l2)!=0:\n if(l1[0]>l2[0]):\n l1.append(l2.popleft())\n l1.append(l1.popleft())\n else:\n l2.append(l1.popleft())\n l2.append(l2.popleft())\n cou+=1\n f1=0\n f2=0\n if(len(l1)==s1):\n for i in range(s1):\n if(ll1[i]!=l1[i]):\n f1=1\n break\n else:\n f1=1\n if(len(l2)==s2):\n for i in range(s2):\n if(ll2[i]!=l2[i]):\n f2=1\n break\n else:\n f2=1\n if(f1==0 and f2==0):\n lol=1\n break\n #print(l1,l2)\n if(cou==100000):\n break\nif(len(l1)==0):\n print(cou,2)\nelif(len(l2)==0):\n print(cou,1)\nelse:\n print(-1)"}, {"source_code": "n=int(input())\n\nx1=map(int,raw_input().split())\nx2=map(int,raw_input().split())\nk1=x1[0]\nk2=x2[0]\np1=x1[1:]\np2=x2[1:]\ncount=0\nwin=0\n\n\ni=0\nwhile( i<=1000000 and len(p1)!=0 and len(p2)!=0):\n\tif(p1[0] < p2[0]):\n\t\tp2.append(p1[0])\n\t\tp1.remove(p1[0])\n\t\tp2.append(p2[0])\n\t\tp2.remove(p2[0])\n\telse:\n\t\tp1.append(p2[0])\n\t\tp2.remove(p2[0])\n\t\tp1.append(p1[0])\n\t\tp1.remove(p1[0])\n\ti+=1\n\nif(len(p1)==0):\n\tprint i,2\nelif(len(p2)==0):\n\tprint i,1\nelse:\n\tprint \"-1\"\n\t\t\n\n"}, {"source_code": "n = int(input())\nk1 = list(map(int, input().split()))\nk1.pop(0)\nk2 = list(map(int, input().split()))\nk2.pop(0)\ntrick = 0\nwhile k1 and k2:\n trick+=1\n if trick > 110:\n print(-1)\n exit()\n a = k1.pop(0)\n b = k2.pop(0)\n if a > b:\n k1.append(b)\n k1.append(a)\n else:\n k2.append(a)\n k2.append(b)\nprint(str(trick) + \" \" + str(1 if k1 else 2))\n"}, {"source_code": "n=input()\na=list(map(int,input().split()))[1:]\nb=list(map(int,input().split()))[1:]\nr=0\nwhile a and b:\n\tr+=1\n\tif r>1000:\n\t\tprint(-1)\n\t\texit(0)\n\tx,y=a.pop(0),b.pop(0)\n\tif x>y:\n\t\ta+=[y,x]\n\telse:\n\t\tb+=[x,y]\n\nif a:\n\tprint(r,1)\nelse:\n\tprint(r,2)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()[1:]))\nb = list(map(int, input().split()[1:]))\n\nsteps = 0\n\nwhile len(a) and len(b):\n x = a.pop(0)\n y = b.pop(0)\n if x > y:\n a += [y, x]\n else:\n b += [x, y]\n steps += 1\n if steps > 110:\n print(-1)\n quit()\n\nif a == []:\n print(steps, 2)\nelse:\n\tprint(steps, 1)"}, {"source_code": "n = int(raw_input())\n\nk1 = [int(x) for x in raw_input().split()]\nk2 = [int(x) for x in raw_input().split()]\n\nvisited = set()\n\nturns = 0\nimpossible = False\nwon = None\ndef recurse(a, b):\n global turns\n global won\n global impossible\n tup_a, tup_b = tuple(a), tuple(b)\n if (tup_a, tup_b) in visited:\n impossible = True\n else:\n visited.add((tup_a, tup_b))\n top_a = a.pop()\n top_b = b.pop()\n turns += 1\n\n if top_a > top_b:\n a = [top_a, top_b] + a\n if len(b) == 0:\n won = 1\n else:\n recurse(a, b)\n else:\n b = [top_b, top_a] + b\n if len(a) == 0:\n won = 2\n else:\n recurse(a, b)\nrecurse(k1[1:][::-1], k2[1:][::-1])\nif impossible:\n print -1\nelse:\n print turns, won"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))[1:]\nb=list(map(int,input().split()))[1:]\nfor ans in range(1,100000):\n if a[0]<b[0]:\n b.append(a.pop(0))\n b.append(b.pop(0))\n else:\n a.append(b.pop(0))\n a.append(a.pop(0))\n if not a or not b:\n print(ans, 1 if a else 2)\n break\nelse:\n print(-1)"}, {"source_code": "input()\nR=lambda:map(int,raw_input().split())[1:]\na=R()\nb=R()\nr=0\nwhile a and b:\n r+=1\n if r>1234:\n print -1\n exit(0)\n x,y=a.pop(0),b.pop(0)\n if x>y:\n a+=[y,x]\n else:\n b+=[x,y]\nprint r,1 if a else 2\n"}, {"source_code": "from collections import deque\nfrom copy import deepcopy\nn = int(input())\nA = deque(list(map(int, input().split()))[1:])\nB = deque(list(map(int, input().split()))[1:])\nstate = []\nstate.append((deepcopy(A), deepcopy(B)))\ncnt = 0\nwhile len(A) > 0 and len(B) > 0:\n if A[0] > B[0]:\n A.append(B.popleft())\n A.append(A.popleft())\n else:\n B.append(A.popleft())\n B.append(B.popleft())\n if (A, B) in state:\n print(-1)\n break\n state.append((deepcopy(A), deepcopy(B)))\n cnt += 1\nelse:\n print(cnt, 1 if len(B) == 0 else 2)\n"}, {"source_code": "def to_s(array):\n return \",\".join(map(str, array))\n\ndef to_hash(k1, k2):\n return to_s(k1) + \":\" + to_s(k2)\n\ndef add_states(states, k1, k2):\n states[to_hash(k1, k2)] = True\n states[to_hash(k2, k1)] = True\n\ndef nextState(winner, loser):\n c1 = winner.pop(0)\n c2 = loser.pop(0)\n winner.extend([c2, c1])\n\nn = int(raw_input())\nk1 = map(lambda x: int(x), raw_input().split(\" \"))[1:]\nk2 = map(lambda x: int(x), raw_input().split(\" \"))[1:]\n\ncount = 0\nstates = {}\nadd_states(states, k1, k2)\n\nwhile len(k1) != 0 and len(k2) != 0:\n count += 1\n\n if k1[0] > k2[0]:\n nextState(k1, k2)\n else:\n nextState(k2, k1)\n\n if states.has_key(to_hash(k1, k2)):\n count = -1\n break\n\n add_states(states, k1, k2)\n\nif count == -1:\n print count\nelse:\n print u\"%d %d\" % (count, 1 if len(k1) != 0 else 2)\n"}, {"source_code": "n = int(input())\nfrom collections import deque\nk1 = list(map(int, input().split()))\nk1 = deque(k1[1:])\nk2 = list(map(int, input().split()))\nk2 = deque(k2[1:])\na = []\nb = []\ncount = 0\nwhile list(k1) not in a or list(k2) not in b:\n a.append(list(k1))\n b.append(list(k2))\n if k1[0] > k2[0]:\n k1.append(k2[0])\n k1.append(k1[0])\n k1.popleft()\n k2.popleft()\n else:\n k2.append(k1[0])\n k2.append(k2[0])\n k1.popleft()\n k2.popleft()\n count += 1\n if len(k2) == 0:\n print(count, 1)\n exit(0)\n elif len(k1) == 0:\n print(count, 2)\n exit(0)\nprint(-1)"}, {"source_code": "##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\nimport sys\ninput = sys.stdin.readline\nscanner = lambda: int(input())\nstring = lambda: input().rstrip()\nget_list = lambda: list(read())\nread = lambda: map(int, input().split())\nget_float = lambda: map(float, input().split())\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // math.gcd(a, b)\n\ndef is_integer(n):\n\treturn math.ceil(n) == math.floor(n)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\n\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n# Euler's Toitent Function phi\ndef phi(n) : \n \n result = n \n p = 2\n while(p * p<= n) : \n if (n % p == 0) : \n while (n % p == 0) : \n n = n // p \n result = result * (1.0 - (1.0 / (float) (p))) \n p = p + 1\n if (n > 1) : \n result = result * (1.0 - (1.0 / (float)(n))) \n \n return (int)(result) \n\ndef is_prime(n):\n\tif n == 0:\n\t\treturn False\n\tif n == 1:\n\t\treturn True\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif not n % i:\n\t\t\treturn False\n \n\treturn True\n\ndef next_prime(n, primes):\n\twhile primes[n] != True:\n\t\tn += 1\n\treturn n\n\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\ndef factors(n):\n\tres = []\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i == 0:\n\t\t\tres.append(i)\n\t\t\tres.append(n // i)\n\treturn list(set(res))\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n\ndef binary_search(low, high, w, h, n):\n\twhile low < high:\n\t\tmid = low + (high - low) // 2\n\t\t# print(low, mid, high)\n\t\tif check(mid, w, h, n):\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid\n\treturn low\n\n## for checking any conditions\ndef check(beauty, s, n, count):\n\tpass\n\t\n\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\nalphs = \"abcdefghijklmnopqrstuvwxyz\"\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\nimport bisect as bis\nimport random\nimport sys\nimport collections as collect\n# import numpy as np\n\ndef solve():\n\tn = scanner()\n\tl, *a = get_list()\n\tr, *b = get_list()\n\ta = collect.deque(a)\n\tb = collect.deque(b)\n\ts = 0\n\twhile a and b:\n\t\ts += 1\n\t\tif s > 1000:\n\t\t\tprint(-1)\n\t\t\treturn\n\t\tx, y = a.popleft(), b.popleft()\n\t\tif x > y:\n\t\t\ta.append(y)\n\t\t\ta.append(x)\n\t\telse:\n\t\t\tb.append(x)\n\t\t\tb.append(y)\n\tif a:\n\t\tprint(s, 1)\n\telse:\n\t\tprint(s, 2)\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n # sys.stdin = open(\"input.txt\", \"r\")\n # sys.stdout = open(\"output.txt\", \"w\")\n for i in range(1):\n \tsolve()\n #dmain()\n \n# Comment Read()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "n=int(raw_input())\nl=map(int,raw_input().split())\nm=map(int,raw_input().split())\nl=l[1:]\nm=m[1:]\na=0\np=[[c for c in l]]\nq=[[c for c in m]]\n#print p\nwhile len(l)>0 and len(m)>0:\n if l[0]>m[0]:\n l=l[1:]+[m[0],l[0]]\n m=m[1:]\n a+=1\n #print l+['l']\n #print m+['m']\n if l in p and m in q:\n break\n else:\n p.append(l)\n q.append(m)\n else:\n m=m[1:]+[l[0],m[0]]\n l=l[1:]\n a+=1\n #print l+['l']\n #print m+['m']\n if l in p and m in q:\n break\n else:\n p.append(l)\n q.append(m)\nif len(l)==0:\n print str(a)+' '+str(2)\nelif len(m)==0:\n print str(a)+' '+str(1)\nelse:\n print -1\n"}, {"source_code": "input()\nR=lambda:map(int,raw_input().split())[1:]\na=R()\nb=R()\nr=0\nwhile a and b:\n r+=1\n if r>1234:\n print -1\n exit(0)\n x,y=a.pop(0),b.pop(0)\n if x>y:\n a+=[y,x]\n else:\n b+=[x,y]\nprint r,1 if a else 2\n"}, {"source_code": "import os,io\nimport sys\n\ndef binomial_coefficient(n, k):\n if 0 <= k <= n:\n ntok = 1\n ktok = 1\n for t in range(1, min(k, n - k) + 1):\n ntok *= n\n ktok *= t\n n -= 1\n return ntok // ktok\n else:\n return 0\n\ndef getState(d1, d2):\n return \"\".join(d1) + \"-\" + \"\".join(d2)\n\nn = int(sys.stdin.readline().strip())\nd1 = sys.stdin.readline().strip().split(\" \")[1:]\nd2 = sys.stdin.readline().strip().split(\" \")[1:]\n\nstates = set([getState(d1, d2)])\n\npossible = True\ncnt = 0\nwhile len(d1) and len(d2):\n c1 = d1.pop(0)\n c2 = d2.pop(0)\n if int(c1) > int(c2):\n d1.append(c2)\n d1.append(c1)\n else:\n d2.append(c1)\n d2.append(c2)\n state = getState(d1, d2)\n cnt += 1\n if state in states:\n print(-1)\n possible = False\n break\n states.add(state)\n\nif possible:\n print(cnt, end=\" \")\n if len(d1):\n print(\"1\")\n else:\n print(\"2\")\n"}, {"source_code": "n = int(raw_input())\nk1 = map(int, raw_input().split()[1:])\nk2 = map(int, raw_input().split()[1:])\nfor turn in xrange(1, 107):\n a, b = k1.pop(0), k2.pop(0)\n if a > b:\n k1.append(b)\n k1.append(a)\n elif a < b:\n k2.append(a)\n k2.append(b)\n if not k2:\n print turn, 1\n break\n elif not k1:\n print turn, 2\n break\nelse:\n print -1"}, {"source_code": "import math,sys\nfrom collections import Counter, defaultdict, deque\nfrom sys import stdin, stdout\ninput = stdin.readline\nlili=lambda:list(map(int,sys.stdin.readlines()))\nli = lambda:list(map(int,input().split()))\n#for deque append(),pop(),appendleft(),popleft(),count()\nI=lambda:int(input())\nS=lambda:input().strip()\n\nn=I()\na=li()\nb=li()\nc=deque()\nd=deque()\nfor i in range(1,a[0]+1):\n c.appendleft(a[i])\nfor i in range(1,b[0]+1):\n d.appendleft(b[i])\na=a[1:]\nb=b[1:]\nt=0\nf=0\nh=defaultdict(list)\nwhile(len(c)!=0 and len(d)!=0):\n # print(c,d)\n t+=1\n p=c.pop()\n q=d.pop()\n if(t>=1000):\n f=1\n break\n if(p<q):\n d.appendleft(p)\n d.appendleft(q)\n else:\n c.appendleft(q)\n c.appendleft(p)\n \nif(f==1):\n print(-1)\n exit()\nif(len(c)==0):\n print(t,2)\nelse:\n print(t,1)\n\n"}, {"source_code": "n = int(input())\n\ns1 = [ int(card) for card in input().split() ]\ns2 = [ int(card) for card in input().split() ]\n\ns1 = s1[1:]\ns2 = s2[1:]\n\nmagic = 1000000\n\nfights = 0\nflag = False\nwhile True:\n\tcard1, card2 = s1.pop(0), s2.pop(0)\n\n\tfights += 1\n\tif fights > magic:\n\t\tflag = True\n\t\tbreak\n\n\tif card1 > card2:\n\t\ts1.append(card2)\n\t\ts1.append(card1)\n\telse:\n\t\ts2.append(card1)\n\t\ts2.append(card2)\n\n\tif s1 == []:\n\t\twinner = 2\n\t\tbreak\n\tif s2 == []:\n\t\twinner = 1\n\t\tbreak\n\nif flag:\n\tprint(-1)\nelse:\n\tprint(fights, winner)"}, {"source_code": "n = int(input())\narr1 = [int(i) for i in input().split()]\narr2 = [int(i) for i in input().split()]\nn1 = arr1.pop(0)\nn2 = arr2.pop(0)\nstart = [i for i in arr1]\nend = [i for i in arr2]\ncount = 0\nflag = 0\nwhile count != 100000:\n if arr1[0] > arr2[0]:\n arr1.append(arr2.pop(0))\n arr1.append(arr1.pop(0))\n n1 += 1\n n2 -= 1\n else:\n arr2.append(arr1.pop(0))\n arr2.append(arr2.pop(0))\n n2 += 1\n n1 -= 1\n count += 1\n if n1 == 0 or n2 == 0:\n if n1 == 0:\n print(count, 2)\n else:\n print(count, 1)\n flag = 1\n break\nif flag == 0:\n print(-1)"}, {"source_code": "\"\"\"\n Author - Satwik Tiwari .\n 27th Oct , 2020 - Tuesday\n\"\"\"\n\n#===============================================================================================\n#importing some useful libraries.\n\n\nfrom __future__ import division, print_function\nfrom fractions import Fraction\nimport sys\nimport os\nfrom io import BytesIO, IOBase\nfrom functools import cmp_to_key\n\n# from itertools import *\nfrom heapq import *\nfrom math import gcd, factorial,floor,ceil\n\nfrom copy import deepcopy\nfrom collections import deque\n\n\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n\n#==============================================================================================\n#fast I/O region\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n# inp = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#===============================================================================================\n### START ITERATE RECURSION ###\nfrom types import GeneratorType\ndef iterative(f, stack=[]):\n def wrapped_func(*args, **kwargs):\n if stack: return f(*args, **kwargs)\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n continue\n stack.pop()\n if not stack: break\n to = stack[-1].send(to)\n return to\n return wrapped_func\n#### END ITERATE RECURSION ####\n\n#===============================================================================================\n#some shortcuts\n\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") #for fast input\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef lis(): return list(map(int, inp().split()))\ndef stringlis(): return list(map(str, inp().split()))\ndef sep(): return map(int, inp().split())\ndef strsep(): return map(str, inp().split())\n# def graph(vertex): return [[] for i in range(0,vertex+1)]\ndef zerolist(n): return [0]*n\ndef nextline(): out(\"\\n\") #as stdout.write always print sring.\ndef testcase(t):\n for pp in range(t):\n solve(pp)\ndef printlist(a) :\n for p in range(0,len(a)):\n out(str(a[p]) + ' ')\ndef google(p):\n print('Case #'+str(p)+': ',end='')\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef power(x, y, p) :\n res = 1 # Initialize result\n x = x % p # Update x if it is more , than or equal to p\n if (x == 0) :\n return 0\n while (y > 0) :\n if ((y & 1) == 1) : # If y is odd, multiply, x with result\n res = (res * x) % p\n\n y = y >> 1 # y = y/2\n x = (x * x) % p\n return res\ndef ncr(n,r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))\ndef isPrime(n) :\n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\ninf = pow(10,20)\nmod = 10**9+7\n#===============================================================================================\n# code here ;))\n\n\n\ndef solve(case):\n n = int(inp())\n a = deque(lis())\n b = deque(lis())\n\n a.popleft();b.popleft()\n\n cnt = 0\n while(len(a)!=0 and len(b)!=0):\n x = a.popleft()\n y = b.popleft()\n\n if(x<y):\n b.append(x)\n b.append(y)\n else:\n a.append(y)\n a.append(x)\n cnt+=1\n\n if(cnt>200):\n print(-1)\n return\n\n if(len(a) == 0):\n print(cnt,2)\n else:\n print(cnt,1)\n\n\n\n\ntestcase(1)\n# testcase(int(inp()))\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "r = lambda :map(int,raw_input().split())\nn = input()\na = r()[1:]\nb = r()[1:]\npath = set(str([a,b]))\nc = 0\nwhile 1:\n\tc+=1\n\tif a[0]>b[0]:\n\t\ta.extend([b[0],a[0]])\n\t\ta = a[1:]\n\t\tb = b[1:]\n\telse:\n\t\tb.extend([a[0],b[0]])\n\t\ta = a[1:]\n\t\tb = b[1:]\n\td = str([a,b])\n\tif d in path:\n\t\tprint -1\n\t\texit(0)\n\telse:\n\t\tpath.add(d)\n\t\tif len(a)==0:\n\t\t\tprint c,2\n\t\t\texit(0)\n\t\tif len(b)==0:\n\t\t\tprint c,1\n\t\t\texit(0)"}, {"source_code": "max_count = 1000\ninput()\na = list(map(int, input().split()[1:]))\nb = list(map(int, input().split()[1:]))\ni = 0\nwhile len(a) - i > 0 and len(b) - i > 0 and i < max_count:\n if a[i] > b[i]:\n a.extend([b[i], a[i]])\n else:\n b.extend([a[i], b[i]])\n i += 1\nprint(-1 if i == max_count else ' '.join(map(str, (i, 1))) if len(b) - i == 0 else ' '.join(map(str, (i, 2))))"}, {"source_code": "def check(A, B):\n count = 0\n\n d = {}\n s1 = ''.join(map(str, A))\n s2 = ''.join(map(str, B))\n d[s1] = True\n d[s2] = True\n\n while len(A) and len(B):\n count += 1\n a, b = A.pop(0), B.pop(0)\n\n if a > b:\n A.append(b)\n A.append(a)\n else:\n B.append(a)\n B.append(b)\n\n s1 = ''.join(map(str, A))\n s2 = ''.join(map(str, B))\n\n if s1 in d and s2 in d:\n print -1\n return -1\n\n if not s1 in d:\n d[s1] = True\n\n if not s2 in d:\n d[s2] = True\n\n\n if len(A) == 0:\n print count, 2\n else:\n print count, 1\n\nn = int(raw_input())\n\nA = map(int, raw_input().split())\nk1 = A.pop(0)\nB = map(int, raw_input().split())\nk2 = B.pop(0)\n\ncheck(A, B)"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\nimport math\nfrom itertools import permutations\nfrom decimal import Decimal, getcontext\n\ngetcontext().prec = 25\nMOD = pow(10, 9) + 7\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# n, k = map(int, input().split(\" \"))\n# l = list(map(int, input().split(\" \")))\nn = int(input())\nl1 = list(map(int, input().split(\" \")))\nl2 = list(map(int, input().split(\" \")))\na = l1[0]\nl1.pop(0)\nb = l2[0]\nl2.pop(0)\nx = [0]*10000\ny = [0]*10000\nfor i in range(a):\n x[i]=l1[i]\nfor i in range(b):\n y[i]=l2[i]\nans = -1\nans2 = 0\nfor i in range(997):\n if not x[i] or not y[i]:\n if x[i]:\n ans=1\n else:\n ans=2\n break\n else:\n\n if x[i]>y[i]:\n x[a]=y[i]\n x[a+1]=x[i]\n a+=2\n else:\n y[b]=x[i]\n y[b+1]=y[i]\n b+=2\n ans2+=1\nif ans!=-1:\n print(ans2, ans)\nelse:\n print(-1)"}, {"source_code": "from math import *\nfrom collections import deque\nfrom copy import deepcopy\nimport sys\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") #for fast input\ndef multi(): return map(int,input().split())\ndef strmulti(): return map(str, inp().split())\ndef lis(): return list(map(int, inp().split()))\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef ncr(n,r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))\ndef stringlis(): return list(map(str, inp().split()))\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef printlist(a) :\n print(' '.join(str(a[i]) for i in range(len(a))))\n\ndef isPrime(n) :\n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\n\n\n\n\n#copied functions end\n\n#start coding\n\n\n\nn=int(input())\na=lis()\nb=lis()\nk1=a[0]\nk2=b[0]\ninitiala=deepcopy(a[1:])\ninitialb=deepcopy(b[1:])\na=deque(a[1:])\nb=deque(b[1:])\nans=0\nwhile(True):\n if(ans>200):\n print(-1)\n exit(0)\n if(len(a)==0 or len(b)==0):\n if(len(a)==0):\n print(ans,2)\n elif(len(b)==0):\n print(ans,1)\n\n exit(0)\n\n if(a[0]>b[0]):\n num1=a.popleft()\n num2=b.popleft()\n\n a.append(num2)\n a.append(num1)\n ans+=1\n else:\n num1 = a.popleft()\n num2 = b.popleft()\n\n b.append(num1)\n b.append(num2)\n ans += 1\n\n\n # if(check(a,b,initiala,initialb,ans)):\n # print(-1)\n # exit(0)\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\nimport sys\ninput = sys.stdin.readline\nscanner = lambda: int(input())\nstring = lambda: input().rstrip()\nget_list = lambda: list(read())\nread = lambda: map(int, input().split())\nget_float = lambda: map(float, input().split())\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // math.gcd(a, b)\n\ndef is_integer(n):\n\treturn math.ceil(n) == math.floor(n)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\n\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n# Euler's Toitent Function phi\ndef phi(n) : \n \n result = n \n p = 2\n while(p * p<= n) : \n if (n % p == 0) : \n while (n % p == 0) : \n n = n // p \n result = result * (1.0 - (1.0 / (float) (p))) \n p = p + 1\n if (n > 1) : \n result = result * (1.0 - (1.0 / (float)(n))) \n \n return (int)(result) \n\ndef is_prime(n):\n\tif n == 0:\n\t\treturn False\n\tif n == 1:\n\t\treturn True\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif not n % i:\n\t\t\treturn False\n \n\treturn True\n\ndef next_prime(n, primes):\n\twhile primes[n] != True:\n\t\tn += 1\n\treturn n\n\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\ndef factors(n):\n\tres = []\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i == 0:\n\t\t\tres.append(i)\n\t\t\tres.append(n // i)\n\treturn list(set(res))\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n\ndef binary_search(low, high, w, h, n):\n\twhile low < high:\n\t\tmid = low + (high - low) // 2\n\t\t# print(low, mid, high)\n\t\tif check(mid, w, h, n):\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid\n\treturn low\n\n## for checking any conditions\ndef check(beauty, s, n, count):\n\tpass\n\t\n\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\nalphs = \"abcdefghijklmnopqrstuvwxyz\"\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\nimport bisect as bis\nimport random\nimport sys\nimport collections as collect\n# import numpy as np\n\ndef solve():\n\tn = scanner()\n\tl, *a = get_list()\n\tr, *b = get_list()\n\ta = collect.deque(a)\n\tb = collect.deque(b)\n\ts = 0\n\twhile a and b:\n\t\ts += 1\n\t\tif s > 1000:\n\t\t\tprint(-1)\n\t\t\treturn\n\t\tx, y = a.popleft(), b.popleft()\n\t\tif x > y:\n\t\t\ta.append(y)\n\t\t\ta.append(x)\n\t\telse:\n\t\t\tb.append(x)\n\t\t\tb.append(y)\n\tif a:\n\t\tprint(s, 1)\n\telse:\n\t\tprint(s, 2)\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n # sys.stdin = open(\"input.txt\", \"r\")\n # sys.stdout = open(\"output.txt\", \"w\")\n for i in range(1):\n \tsolve()\n #dmain()\n \n# Comment Read()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "n = int(input())\n\nx = input().split()\ny = input().split()\n\nplayer_1 = []\nplayer_2 = []\nmemory = []\naux_1 = []\naux_2 = []\n\nfor card in range(int(x[0])):\n player_1.append(int(x[card + 1]))\n aux_1.append(int(x[card + 1]))\nfor card in range(int(y[0])):\n player_2.append(int(y[card + 1]))\n aux_2.append(int(y[card + 1]))\nmemory.append((aux_1, aux_2))\n\ncondition = False\ncounter = 0\n\nwhile len(player_1) > 0 and len(player_2) > 0 and not condition:\n c1, c2 = player_1.pop(0), player_2.pop(0)\n if c1 > c2:\n player_1.append(c2)\n player_1.append(c1)\n else:\n player_2.append(c1)\n player_2.append(c2)\n aux_1 = []\n aux_2 = []\n if (player_1, player_2) in memory:\n condition = True\n break\n for card in player_1:\n aux_1.append(card)\n for card in player_2:\n aux_2.append(card)\n memory.append((aux_1, aux_2))\n counter += 1\n\nif not condition:\n answer = str(counter)\n if len(player_1) == 0:\n answer += \" 2\"\n else:\n answer += \" 1\"\nelse:\n answer = \"-1\"\nprint(answer)\n"}, {"source_code": "class Soldado:\n \n def __init__(self,cartas,numero):\n \n cartas=cartas[1:]\n \n \n self.mano=cartas.split()\n self.nombre=numero\n \n def perder(self):\n if len(self.mano)>0:\n self.mano.remove(self.mano[0])\n \n def ganar(self,otro_soldado):\n self.mano.append(otro_soldado.mano[0])\n self.mano.append(self.mano[0])\n self.mano.remove(self.mano[0])\n \n \n\n def __gt__(self,otro_soldado):\n return int(self.mano[0])>int(otro_soldado.mano[0])\n \n\n def __lt__(self,otro_soldado):\n return int(self.mano[0])<int(otro_soldado.mano[0])\n \n def __eq__(self,otro_soldado):\n return len(self.mano)==len(otro_soldado.mano)\n \n def __str__(self):\n print(self.nombre)\n \n \n\nmazo=int(input())\ncartas1=input()\ncartas2=input()\n\nsoldado1=Soldado(cartas1,1)\nsoldado2=Soldado(cartas2,2)\n\n\n#ahora hago el juego\n\njuego=True\nt=0\n\nwhile juego==True:\n \n if soldado1>soldado2:\n soldado1.ganar(soldado2)\n soldado2.perder()\n t+=1\n\n elif soldado1<soldado2:\n soldado2.ganar(soldado1)\n soldado1.perder()\n t+=1\n \n \n \n \n \n \n \n \n if t>500:\n print(\"-1\")\n juego=False\n \n elif len(soldado1.mano)==0:\n juego=False\n print(str(t)+\" \"+\"2\")\n \n elif len(soldado2.mano)==0:\n juego=False\n print(str(t)+\" \"+\"1\")"}, {"source_code": "def A546():\n k,n,w = map(int, raw_input().split())\n count = (1+w)*w*k*0.5\n if count > n :\n print int(count -n) \n else:\n print 0 \n\ndef B546():\n n = int(raw_input())\n a = map(int, raw_input().split())\n \n d = {} # dict\n count = 0 \n for i in range(n):\n while str(a[i]) in d :\n a[i]+=1\n count+=1 \n d[str(a[i])] = 1\n #print d \n print count \n \n \ndef C546():\n n = int(raw_input())\n l=lambda:map(int,raw_input().split())\n a = l()[1:]\n b = l()[1:]\n c = 0 \n R = set()\n while a and b:\n c +=1 \n A = a.pop(0)\n B = b.pop(0)\n if A > B:\n a+=[B,A]\n else:\n b+=[A,B]\n r =(tuple(a),tuple(b))\n if r in R :\n print -1 \n exit(0)\n R.add(r)\n print c, 1 if a else 2 \n \nif __name__=='__main__':\n #A546()\n #B546()\n C546()"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nk1=a[0]\ns1=a[1:]\na=list(map(int,input().split()))\nk2=a[0]\ns2=a[1:]\nflag=0\nfights=0\ncount=0\nwhile(len(s1)!=0 and len(s2)!=0):\n count+=1\n if count>1000000:\n flag=1\n break\n t=s1.pop(0)\n p=s2.pop(0)\n if t>p:\n s1.append(p)\n s1.append(t)\n else:\n s2.append(t)\n s2.append(p)\n fights+=1\nif flag==1:\n print(\"-1\")\nelse:\n if len(s1)==0:\n won=\"2\"\n else :\n won=\"1\"\n print(fights,won,sep=\" \")\n\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys\nimport io\nimport re\nimport math\nimport itertools\nfrom collections import deque\nimport copy\n#sys.stdin=file('input.txt')\n#sys.stdout=file('output.txt','w')\n#10**9+7\nmod=1000000007\n#mod=1777777777\npi=3.141592653589\nxy=[(1,0),(-1,0),(0,1),(0,-1)]\nbs=[(-1,-1),(-1,1),(1,1),(1,-1)]\n#start = time.clock()\nn=int(raw_input())\n#n,k=map(int,raw_input().split())\n\ndef lst():\n x=deque()\n l=map(int,raw_input().split())\n for i in range(1,l[0]+1):\n x.appendleft(l[i])\n return x\n\nl=lst()\nr=lst()\ntmp_l=copy.copy(l)\ntmp_r=copy.copy(r)\ncnt=1\nt=106\nwhile t:\n p=l.pop()\n q=r.pop()\n\n if p>q:\n l.appendleft(q)\n l.appendleft(p)\n else:\n r.appendleft(p)\n r.appendleft(q)\n if len(l)==0:\n print cnt,2\n exit()\n elif len(r)==0:\n print cnt,1\n exit()\n elif tmp_r==r and tmp_l==l:\n print -1\n exit()\n cnt+=1\n t-=1\nprint -1"}, {"source_code": "n = int(raw_input())\nar1 = map(int,raw_input().split())\nar2 = map(int,raw_input().split())\nn1 = ar1[0]\nn2 = ar2[0]\nar1 = ar1[1:]\nar2 = ar2[1:]\ncnt = 0\nwhile ar1!=[] and ar2 !=[] and cnt<108:\n if ar1[0]>ar2[0]:\n ar1.append(ar2[0])\n ar1.append(ar1[0])\n ar2 = ar2[1:]\n ar1 = ar1[1:]\n else:\n ar2.append(ar1[0])\n ar2.append(ar2[0])\n ar1 = ar1[1:]\n ar2 = ar2[1:]\n cnt += 1\n \nif ar1==[]:\n print cnt,2\nelif ar2==[]:\n print cnt,1\nelse:\n print -1"}, {"source_code": "import sys\nfrom datetime import datetime\n\nn = int(input()) #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0440\u0442\n\nk1 = input().split()\nk2 = input().split()\n\nk1 = [int(x) for x in k1]\nk2 = [int(x) for x in k2]\nk1.pop(0)\nk2.pop(0)\n\n\n\n\n\niteration = 0\nwhile (len(k1) !=0 and len(k2) !=0 ):\n\tkarta_1 = k1[0]\n\tkarta_2 = k2[0]\n\tif(karta_2 > karta_1):\n\t\tk1.pop(0)\n\t\tk2.pop(0)\n\t\tk2.append(karta_1)\n\t\tk2.append(karta_2)\n\t\t\n\tif(karta_2 < karta_1):\n\t\tk2.pop(0)\n\t\tk1.pop(0)\n\t\t\n\t\tk1.append(karta_2)\n\t\tk1.append(karta_1)\n\n\t\n\titeration = iteration + 1\n\tif(iteration > 150):\n\t\tbreak\n\t\t\n\n\n\nif(iteration > 150):\n\tprint(-1)\n\tsys.exit()\nif(len(k2) != 0):\n\tprint(iteration, 2)\nif(len(k1) !=0):\n\tprint(iteration, 1)\n\n\n"}, {"source_code": "\"\"\"http://codeforces.com/problemset/problem/546/C\"\"\"\n\ndef hash(a, b):\n return '{}_{}'.format(''.join(map(str, a)), ''.join(map(str, b)))\n\ndef solve(a, b):\n state = set()\n count = 0\n while len(a) > 0 and len(b) > 0:\n if hash(a, b) in state:\n return -1\n state.add(hash(a, b))\n x, y = a.pop(0), b.pop(0)\n if x > y:\n a.extend([y, x])\n else:\n b.extend([x, y])\n count += 1\n return count, 1 if len(b) == 0 else 2\n\nif __name__ == '__main__':\n f = lambda: list(map(int, input().split()))\n input()\n res = solve(f()[1:], f()[1:])\n print(-1 if res == -1 else '{} {}'.format(res[0], res[1]))\n"}, {"source_code": "l=lambda:map(int,raw_input().split())[1:]\ninput()\na=l()\nb=l()\nr=0\nwhile a and b:\n if r>1000:\n print -1\n exit(0)\n x,y=a.pop(0),b.pop(0)\n if x>y:\n a+=[y,x]\n else:\n b+=[x,y]\n r+=1\nprint r,1 if a else 2"}, {"source_code": "from collections import deque\nn=int(input())\nA=[int(i) for i in input().split()][1:]\nB=[int(i) for i in input().split()][1:]\nA=deque(A)\nB=deque(B)\nres=0\nstates={}\nstates[(tuple(A),tuple(B))]=1\nwhile len(A) and len(B):\n res+=1\n if A[0]> B[0]:\n A.extend([B[0], A[0]])\n else:\n B.extend([A[0], B[0]])\n A.popleft()\n B.popleft()\n if (tuple(A), tuple(B)) in states:\n print(-1)\n exit()\n states[(tuple(A), tuple(B))]=1\nprint(res,1+(len(A)==0))"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nk1 = a.pop(0)\nk2 = b.pop(0)\nflag = False\ncnt = 0\nn = 106\nwhile(k1 !=0 and k2 != 0 and n>0):\n n -= 1\n cnt += 1\n x = a.pop(0)\n y = b.pop(0)\n if x>y:\n a.append(y)\n a.append(x)\n k1 += 1\n k2 -= 1\n else:\n b.append(x)\n b.append(y)\n k2 += 1\n k1 -= 1\nif k1 != 0 and k2!= 0:\n print(\"-1\")\nelse:\n print(cnt, \"1\" if k1!= 0 else \"2\")\n"}, {"source_code": "n = int(input())\n\nq1 = list(map(int, input().split()))[1:]\nq2 = list(map(int, input().split()))[1:]\n\ns = set()\nc = 0\nwhile q1 and q2:\n c += 1\n a = q1.pop(0)\n b = q2.pop(0)\n if a < b:\n q2.append(a)\n q2.append(b)\n else:\n q1.append(b)\n q1.append(a)\n t = (tuple(q1), tuple(q2))\n if t in s:\n break\n s.add(t)\n\nif q1 and q2:\n print(-1)\nelse:\n print(c, 1 if q1 else 2)\n"}, {"source_code": "n=input()\nk1=raw_input().split(' ')\nk2=raw_input().split(' ')\n#import time\n#start_time = time.clock()\nk1f=[None]*(len(k1)-1)\nk2f=[None]*(len(k2)-1)\nfor i in range(len(k1)-1):\n k1[i]=int(k1[i])\n k1f[i]=int(k1[i+1])\nfor i in range(len(k2)-1):\n k2[i]=int(k2[i])\n k2f[i]=int(k2[i+1])\nk1[len(k1)-1]=int(k1[len(k1)-1])\nk2[len(k2)-1]=int(k2[len(k2)-1])\nfight=0\nk1.remove(k1[0])\nk2.remove(k2[0])\nwhile len(k1)!=0 and len(k2)!=0:\n if k1[0]>k2[0]:\n x=k1[0]\n y=k2[0]\n k1.remove(k1[0])\n k2.remove(k2[0])\n k1=k1+[y]+[x]\n fight=fight+1\n else:\n x=k2[0]\n y=k1[0]\n k1.remove(k1[0])\n k2.remove(k2[0])\n k2=k2+[y]+[x]\n fight=fight+1\n #print k1,k2\n if k1==k1f and k2==k2f or fight>106:\n print -1\n break\nif len(k1)==0:\n print fight,2\nelif len(k2)==0:\n print fight,1\n#print(\"--- %s seconds ---\" % (time.clock() - start_time))\n"}], "negative_code": [{"source_code": "n = int(input())\n\np1 = list(map(int, input().split()))\n\np2 = list(map(int, input().split()))\n\np1_cards = p1.pop(0)\np2_cards = p2.pop(0)\n\nvisited = []\nwinner = -1\nif len(p1) <= len(p2):\n visited.append(list(p1))\nelse:\n visited.append(list(p2))\n\nfights = 0\nwhile True:\n \n if len(p1) == 0:\n winner = 2\n print(str(fights) + \" \" + str(winner))\n break\n \n if len(p2) == 0:\n winner = 1\n print(str(fights) + \" \" + str(winner))\n break\n \n if p1[0] >= p2[0]:\n p1.append(p2.pop(0))\n p1.append(p1.pop(0))\n \n else:\n p2.append(p1.pop(0))\n p2.append(p2.pop(0))\n \n \n if p1 in visited or p2 in visited:\n print(winner)\n break\n \n if len(p1) <= len(p2):\n visited.append(list(p1))\n else:\n visited.append(list(p2))\n fights += 1"}, {"source_code": "n=int(raw_input())\ns1=raw_input().split()\ns2=raw_input().split()\na=[]\np1=[]\np2=[]\nfor i in range(1,len(s1)):\n p1.append(int(s1[i]))\nfor i in range(1,len(s2)):\n p2.append(int(s2[i]))\na.append((tuple(p1),tuple(p2)))\nc=0\nf=0\nwhile len(p1)!=0 and len(p2)!=0:\n if p1[0]>p2[0]:\n p1.append(p2[0])\n p1.append(p1[0])\n else:\n p2.append(p1[0])\n p2.append(p2[0])\n del(p1[0])\n del(p2[0])\n c+=1\n for j in a:\n if j[0]==tuple(p1):\n f=1\n break\n if f==1:\n break\n a.append((tuple(p1),tuple(p2)))\nif f==0:\n print c\nelse:\n print -1\n \n \n \n"}, {"source_code": "n=input()\na=raw_input()\na=a.split()\na=map(int,a)\nb=raw_input()\nb=b.split()\nb=map(int,b)\na.pop(0)\nb.pop(0)\nans=0\n\na_config=list()\nb_config=list()\na_config.append(list(a))\nwhile(len(a)!=0 and len(b)!=0):\n #print a,b,a_config\n if a[0]>b[0]:\n a.append(b[0])\n a.append(a[0])\n a.pop(0)\n b.pop(0)\n if a not in a_config:\n a_config.append(list(a))\n else:\n #print \"hi\"\n print \"-1\"\n exit(0)\n ans+=1\n else:\n b.append(a[0])\n b.append(b[0])\n a.pop(0)\n b.pop(0)\n ans+=1\n #print a,a_config\n if a not in a_config:\n a_config.append(list(a))\n else:\n print \"-1\"\n exit(0)\nprint ans\n"}, {"source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\nfrom math import ceil, floor;\n\n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp\n\n## gcd function\ndef gcd(a,b):\n if a == 0:\n return b\n return gcd(b%a, a)\n\n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k \n res = 1\n for i in range(k): \n res = res * (n - i) \n res = res / (i + 1) \n return int(res) \n\n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0):\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if a[mid] < x:\n lo = mid+1\n else:\n hi = mid\n return lo\n\n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n\n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n\n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b\n\n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n\n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n\n\n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n\n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e6 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n\n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)]\n# spf_sieve() \ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()))\n## taking string array input\ndef str_array():\n return input().strip().split();\n\n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n\n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n\nn = int(input()); a = int_array(); b = int_array();\nk1 = a[0]; a = a[1:]; k2 = b[0]; b = b[1:];\nia = a.copy(); ib = b.copy();\ncount = 0; f = 0; won = 2;\nwhile(1):\n if not a or not b:\n f = 1; break;\n count += 1;\n if won == 2:\n won = 1;\n else:\n won = 2;\n x = a.pop(0); y = b.pop(0);\n if x > y:\n a.append(y); a.append(x);\n else:\n b.append(x); b.append(y);\n if a == ia and b == ib:\n break;\nif f:\n print(*(count, won));\nelse:\n print(-1);"}, {"source_code": "N=int(input())\nfrom collections import deque\nA=deque()\nB=deque()\nfor x in range(2):\n a=input().split()\n if x==0: \n for y in range(1,len(a)):\n A.append(int(a[y]))\n else:\n for y in range(1,len(a)):\n B.append(int(a[y]))\nbr=0\n\nwhile len(A)!=0 and len(B)!=0 and br<300000:\n c=A.popleft()\n d=B.popleft()\n if c>d:\n A.append(d)\n A.append(c)\n else:\n B.append(c)\n B.append(d)\n br+=1\nif br>=300000:\n print(-1)\nelse:\n print(br)\n \n\n \n"}, {"source_code": "n = int(input())\nl1 = list(map(int,input().split()))\nl2 = list(map(int,input().split()))\nt1 = l1[1:]\nt2 = l2[1:]\ncnt = 0\nwhile cnt<100:\n TopT1 = t1.pop(0)\n TopT2 = t2.pop(0)\n if (TopT1 < TopT2):\n t2.append(TopT1)\n t2.append(TopT2)\n else:\n t1.append(TopT2)\n t1.append(TopT1)\n cnt+=1\n if (len(t1)<=0):\n print(cnt,'2')\n exit(0)\n elif(len(t2)<=0):\n print(cnt,'1')\n exit(0)\n if (t1 == l1[1:] and t2 == l2[1:]):\n print(-1)\n exit(0)\nprint(-1)\n \n \n\n"}, {"source_code": "cards = int(input())\nstart_first = input().split()[1:]\nstart_second = input().split()[1:]\n\nf = [c for c in start_first]\ns = [c for c in start_second]\nrounds = 0\nwhile f and s:\n c_f,c_s = f.pop(0), s.pop(0)\n \n if int(c_f) > int(c_s):\n f.append(c_s)\n f.append(c_f)\n else:\n s.append(c_f)\n s.append(c_s)\n rounds += 1\n if f == start_first or s == start_second:\n print (-1)\n break\nelse:\n print (rounds, (1,2)[f == []])\n\n"}, {"source_code": "n=int(input())\nlist_1=input().split()\nlist_2=input().split()\nn1=int(list_1.pop(0))\nn2=int(list_2.pop(0))\nlistt_1,listt_2=[],[]\nfor i in range(n1):\n list_1[i]=int(list_1[i])\n listt_1.append(list_1[i])\nfor i in range(n2):\n list_2[i] = int(list_2[i])\n listt_2.append(int(list_2[i]))\nno=0\nprint(listt_1,listt_2)\nwhile True:\n print(listt_1[0],listt_2[0])\n if(listt_1[0]>listt_2[0]):\n print(1)\n j=listt_2.pop(0)\n i=listt_1.pop(0)\n listt_1.append(j)\n listt_1.append(i)\n else:\n print(2)\n j = listt_1.pop(0)\n i = listt_2.pop(0)\n listt_2.append(j)\n listt_2.append(i)\n no+=1\n print(no,listt_1,listt_2)\n if(len(listt_1)==0):\n print(no,\"2\")\n break\n if (len(listt_2) == 0):\n print(no, \"1\")\n break\n if(listt_1==list_1 and listt_2==list_2):\n print(\"-1\")\n break"}, {"source_code": "n = int(input())\nk1 = list(map(int, input().split()))\nk1.pop(0)\nk2 = list(map(int, input().split()))\nk2.pop(0)\ntrick = 0\nwhile k1 and k2:\n trick+=1\n if trick>100:\n print(-1)\n exit()\n a = k1.pop(0)\n b = k2.pop(0)\n if a > b:\n k1.append(b)\n k1.append(a)\n else:\n k2.append(a)\n k2.append(b)\nprint(str(trick) + \" \" + str(1 if k1 else 2))\n"}, {"source_code": "n = int(raw_input())\n\nA = map(int, raw_input().split())\nA.pop(0)\n\nB = map(int, raw_input().split())\nB.pop(0)\n\nA_buf = []\ncount = 0\nwhile len(A) > 0 and len(B) > 0:\n\tA_buf.append(list(A))\n\n\tif A[0] < B[0]:\n\t\ttmp = B[0]\n\t\tB.pop(0)\n\t\tB.append(A[0])\n\t\tB.append(tmp)\n\t\tA.pop(0)\n\n\telse:\n\t\ttmp = A[0]\n\t\tA.pop(0)\n\t\tA.append(B[0])\n\t\tA.append(tmp)\n\t\tB.pop(0)\n\n\tcount += 1\n\tif A in A_buf:\n\t\tprint -1\n\t\texit()\n\nwin = 1 if len(A) > 0 else 2\nprint count, win"}, {"source_code": "n = int(input())\n\np1 = input().strip().split()\np1 = [int(i) for i in p1[1:]]\np2 = input().strip().split()\np2 = [int(i) for i in p2[1:]]\ncomb = set()\ncont = 0\n\nwhile(True):\n\n if (tuple(p1+p2) in comb):\n print(-1)\n break\n if len(p1) == 0:\n print(cont, 2)\n break\n if len(p2) == 0:\n print(cont, 1)\n break\n\n cont += 1\n comb.add(tuple(p1+p2))\n p1_card = p1.pop(0)\n p2_card = p2.pop(0)\n\n if p2_card < p1_card:\n p1 += [p2_card, p1_card]\n\n else:\n p2 += [p1_card, p2_card]\n"}, {"source_code": "n = int(input())\ns1 = [int(i) for i in input().split()]\ns1.pop(0)\ns2 = [int(i) for i in input().split()]\ns2.pop(0)\nt = 0\nwhile s1 and s2:\n t += 1\n a = s1.pop(0)\n b = s2.pop(0)\n if a > b:\n s1.append(b)\n s1.append(a)\n else:\n s2.append(a)\n s2.append(b)\n if t>1000:\n break\nif t>100:\n print(-1)\nelse:\n if s1:\n print(t, 1)\n else:\n print(t, 2)\n"}, {"source_code": "n=int(raw_input())\nl=map(int,raw_input().split())\nm=map(int,raw_input().split())\nl=l[1:]\nm=m[1:]\na=0\np=[[c for c in l]]\n#print l\nwhile len(l)>0 and len(m)>0:\n if l[0]>m[0]:\n l=l[1:]+[m[0],l[0]]\n m=m[1:]\n a+=1\n #print l\n if l in p:\n break\n else:\n p.append(l)\n else:\n m=m[1:]+[l[0],m[0]]\n l=l[1:]\n a+=1\n #print l\n if l in p:\n break\n else:\n p.append(l)\nif len(l)==0:\n print str(a)+' '+str(2)\nelif len(m)==0:\n print str(a)+' '+str(1)\nelse:\n print -1\n"}, {"source_code": "from sys import stdin\nfrom collections import deque\n\nn = int(stdin.readline())\nk1nums = deque(map(int, stdin.readline().split()))\nk2nums = deque(map(int, stdin.readline().split()))\n\nk1nums.popleft()\nk2nums.popleft()\n\nflag = 1\nng = 0\n# visited = set()\nloopcount = 100\nwhile k1nums and k2nums and loopcount:\n loopcount -= 1\n top1, top2 = k1nums.popleft(), k2nums.popleft()\n # l = len(k1nums)\n # if (top1, top2, l, n - l) in visited:\n # print(-1)\n # flag = 0\n # break\n # else:\n # visited.add((top1, top2, l, n - l))\n\n if top1 > top2:\n k1nums.append(top2)\n k1nums.append(top1)\n else:\n k2nums.append(top1)\n k2nums.append(top2)\n \n ng += 1\n\nif loopcount:\n if not k1nums:\n print(ng, 2)\n else:\n print(ng, 1)\nelse:\n print(-1) \n"}, {"source_code": "from collections import deque\n\nn = int(input())\ninp = input()\nk1 = int(inp[0])\np1 = [int(x) for x in inp.split()[1:]]\ninp = input()\nk2 = int(inp[0])\np2 = [int(x) for x in inp.split()[1:]]\n\n\nplayer1 = deque(p1)\nplayer2 = deque(p2)\n\nfight_map = [[0 for _ in range(n+1)] for __ in range(n+1)]\ndraw = False\ncounter = 0\n\nwhile True:\n try:\n card1 = player1.popleft()\n card2 = player2.popleft()\n\n # print(f\"{card1} {card2}\")\n except IndexError:\n # one of the stack is empty\n break\n\n if fight_map[card1][card2] == 1:\n draw = True\n break\n\n if card1 > card2:\n # player 1 wins\n\n # add player2's card to player1's stack\n player1.append(card2)\n # add player1's card to player1's stack\n player1.append(card1)\n else:\n # player 2 wins\n\n player2.append(card1)\n player2.append(card2)\n\n fight_map[card1][card2] = 1\n counter += 1\n\nif draw:\n print(-1)\nelse:\n try:\n player1.pop()\n except IndexError:\n print(f\"{counter} 2\")\n try:\n player2.pop()\n except IndexError:\n print(f\"{counter} 1\")"}, {"source_code": "n=int(input())\nper1=input().split()\nper2=input().split()\nA = per1[1:]\nB = per2[1:]\ndef func(A,B):\n if int(A[0]) > int(B[0]):\n A.append(B.pop(0))\n A.append(A.pop(0))\n else:\n B.append(A.pop(0))\n B.append(B.pop(0))\nanswer = 0\ns=1\nvse = set()\nlenny = 0\nwhile A and B:\n vse.add(''.join(A) + ''.join(B))\n\n func(A,B)\n\n if len(vse) == answer:\n s = 0\n break\n answer += 1\nprint(((str(answer) + ' ' + str(2 if len(A) == 0 else 1))) if s == 1 else -1)\n"}, {"source_code": "n = int(raw_input())\n\nA = map(int, raw_input().split())\nA.pop(0)\n\nB = map(int, raw_input().split())\nB.pop(0)\n\nbuf = list()\ncount = 0\nwhile len(A) > 0 and len(B) > 0:\n\tbuf.append([A, B])\n\n\tif A[0] < B[0]:\n\t\ttmp = B[0]\n\t\tB.pop(0)\n\t\tB.append(A[0])\n\t\tB.append(tmp)\n\t\tA.pop(0)\n\n\telse:\n\t\ttmp = A[0]\n\t\tA.pop(0)\n\t\tA.append(B[0])\n\t\tA.append(tmp)\n\t\tB.pop(0)\n\n\tcount += 1\n\tif [A, B] in buf:\n\t\tprint -1\n\t\texit()\n\nwin = 1 if len(A) > 0 else 2\nprint count, win"}, {"source_code": "from collections import deque\n\n\ndef main():\n n = int(input())\n a = deque([int(c) for c in input().split()][::-1])\n b = deque([int(c) for c in input().split()][::-1])\n a.pop()\n b.pop()\n\n aconf = {tuple(a)}\n i = 1\n while True:\n x, y = a.pop(), b.pop()\n if x > y:\n a.appendleft(y)\n a.appendleft(x)\n else:\n b.appendleft(x)\n b.appendleft(y)\n\n atuple = tuple(a)\n if atuple in aconf:\n print(-1)\n return\n else:\n aconf.add(atuple)\n\n if not a:\n print(i, 2)\n return\n\n if not b:\n print(i, 1)\n return\n\n i += 1\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\n#n,m=map(int,input().split())\nfrom collections import Counter\n#for i in range(n):\nimport math\n#for _ in range(int(input())):\n#n = int(input())\n#for _ in range(int(input())):\n#n = int(input())\nimport bisect\n'''for _ in range(int(input())):\n\n n=int(input())\n\n n,k=map(int, input().split())\n\n arr = list(map(int, input().split()))'''\n#n, m, k = [int(x) for x in input().split()]\n#n,m=map(int,input().split())\nn=int(input())\narr = list(map(int, input().split()))\narr=arr[1:]\na=arr\nls = list(map(int, input().split()))\nls=ls[1:]\nb=ls\ncnt=0\nwhile arr and ls:\n\n cnt+=1\n if arr[0]>ls[0]:\n arr=arr[1:]+[ls[0]]+[arr[0]]\n ls=ls[1:]\n\n else:\n ls=ls[1:]+[arr[0]]+[ls[0]]\n arr=arr[1:]\n if arr==a or ls==b:\n print(-1)\n exit()\nans= 2 if arr==[] else 1\n\nprint(cnt, ans)\n\n"}, {"source_code": "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))[1:]\nb = list(map(int,input().split()))[1:]\ndata = []\ncount =0\nwhile(a and b):\n print(a,b)\n if (a,b) in data:\n print(-1)\n break\n data.append((deepcopy(a),deepcopy(b)))\n if a>b:\n a+=[b.pop(0),a.pop(0)]\n elif a<b:\n b+=[a.pop(0),b.pop(0)]\n count+=1\nif not(a) or not(b): print(count,1 if a else 2)\n \n"}, {"source_code": "from collections import deque\nn = int(input())\nlist1 = list(map(int, input().split()))\nlist2 = list(map(int, input().split()))\nk1 = list1[0]\nk2 = list2[0]\nq1 = deque()\nq2 = deque()\nfor i in range(1, k1 + 1):\n q1.append(list1[i])\n\nfor i in range(1, k2 + 1):\n q2.append(list2[i])\n\nfights = 0\n\nseen = set()\n\nnever_end = False\n\nwhile len(q1) and len(q2):\n fights += 1\n a = q1.popleft()\n b = q2.popleft()\n if (a, b) in seen:\n never_end = True\n break\n else:\n seen.add((a, b))\n if a > b:\n q1.append(b)\n q1.append(a)\n else:\n q2.append(a)\n q2.append(b)\n\nif never_end:\n print(-1)\nelse:\n if len(q1):\n print(fights, 1)\n else:\n print(fights, 2)"}, {"source_code": "n = input()\nl = raw_input().split()\nk1 = int(l[0])\nc1 = []\nfor i in range(1, len(l)):\n c1.append(int(l[i]))\nl = raw_input().split()\nk2 = int(l[0])\nc2 = []\nfor i in range(1, len(l)):\n c2.append(int(l[i]))\nturn = 0\nflag = -1\nfor i in range(0, 100):\n if len(c1) == 0:\n flag = 2\n break\n elif len(c2) == 0:\n flag = 1\n break\n if c1[0] > c2[0]:\n c1.append(c2[0])\n c1.append(c1[0])\n c1 = c1[1:]\n c2 = c2[1:]\n else:\n c2.append(c1[0])\n c2.append(c2[0])\n c2 = c2[1:]\n c1 = c1[1:]\n turn += 1\n\nif flag != -1:\n print turn,\n print flag\nelse:\n print -1"}, {"source_code": "n = int(input())\nl1 = list(map(int,input().split()))\nl2 = list(map(int,input().split()))\nm1 = l1[1:]\nm2 = l2[1:]\nc,c1,f = 0,0,0\nwhile len(m1)!=0 and len(m2)!=0:\n\tif m1[0]<m2[0]:\n\t\tc = m1.pop(0)\n\t\tm2.append(c)\n\t\tc = m2.pop(0)\n\t\tm2.append(c)\n\telse:\n\t\tc = m2.pop(0)\n\t\tm1.append(c)\n\t\tc = m1.pop(0)\n\t\tm1.append(c)\n\tc1+=1\n\tif c1>n*n or m1==l1[1:] and m2==l2[1:]:f=1;break\nif f==1: print(-1)\nelif len(m1)==0:print(c1,2)\nelse:print(c1,1)"}, {"source_code": "\ndef all_equal(arr, a):\n\tfor i in range(len(a)):\n\t\tif check_equal(arr, a[i]):\n\t\t\treturn True\n\treturn False\n\ndef check_equal(a, b):\n\tif len(a) != len(b):\n\t\treturn False\n\tfor i in range(len(a)):\n\t\tif a[i] != b[i]:\n\t\t\treturn False\n\treturn True\n\nn = int(input())\nk1 = [int(i) for i in input().split()]\nk2 = [int(i) for i in input().split()]\n\na = k1[1:]; k1 = k1[0]\nb = k2[1:]; k2 = k2[0]\n\ntemp_a = a[1:]\ntemp_b = b[1:]\nif a[0] > b[0]:\n\ttemp_a.append(b[0])\n\ttemp_a.append(a[0])\nelse:\n\ttemp_b.append(a[0])\n\ttemp_b.append(b[0])\n\na = [a]\ncount = 1\n\nwhile not all_equal(temp_a, a) and len(temp_a) and len(temp_b):\n\ta.append(temp_a)\n\ta1 = temp_a[1:]\n\tb1 = temp_b[1:]\n\n\tif temp_a[0] > temp_b[0]:\n\t\ta1.append(temp_b[0])\n\t\ta1.append(temp_a[0])\n\telse:\n\t\tb1.append(temp_a[0])\n\t\tb1.append(temp_b[0])\n\n\ttemp_a = a1\n\ttemp_b = b1\n\tcount += 1\n\t# print(a, temp_a)\n\nif not len(temp_a):\n\tprint(count, 2)\nelif not len(temp_b):\n\tprint(count, 1)\n\nelse:\n\tprint(-1)\n"}, {"source_code": "import sys\n\nn = int(raw_input())\nxcards = map(int, raw_input().split())\nx = xcards[0]\nxcards = xcards[1:]\ny = n - x\nycards = map(int, raw_input().split())[1:]\n\nfights = 0\nstates = set()\nwhile xcards and ycards:\n fights += 1\n xval = xcards.pop(0)\n yval = ycards.pop(0)\n if xval > yval:\n xcards.append(yval)\n xcards.append(xval)\n else:\n ycards.append(xval)\n ycards.append(yval)\n\n if tuple(xcards + ycards) in states:\n print -1\n sys.exit(0)\n states.add(tuple(xcards + ycards))\nprint fights, 1 if xcards else 2\n"}, {"source_code": "import collections\ninput()\nfights=0\nplayer1=collections.deque(map(int,input().split()))\nplayer2=collections.deque(map(int,input().split()))\nplayer1.popleft();player2.popleft()\nwhile len(player1)!=0 and len(player2)!=0:\n fights+=1\n if fights > 10000:\n exit(0)\n card1=player1.popleft()\n card2=player2.popleft()\n if card1>card2:\n player1.append(card2);player1.append(card1)\n else:\n player2.append(card1);player2.append(card2)\nif fights>10000:\n print(-1)\nelif len(player1)==0:\n print(fights,2)\nelse:\n print(fights,1)\n"}, {"source_code": "import sys\nn=input()\n\nl1=raw_input().split()\na=l1[0]\nl1=l1[1:]\nl2=raw_input().split()\nb=l2[0]\nl2=l2[1:]\n\nst=\"\"\nfor e in l1:\n st=st+str(e)\n\nst=st+\"a\"\nfor e in l2:\n st=st+str(e)\n\n\ndic={st:1}\n\nans=0\nct=1\n\nwhile ct>-1:\n\n val1=l1[0]\n val2=l2[0]\n \n if val1<val2:\n l1=l1[1:]\n a=[val1,val2]\n l2=l2[1:]+a\n else:\n l2=l2[1:]\n a=[val2,val1]\n l1=l1[1:]+a\n \n if not l1:\n print str(ct)+\" 2\"\n ct=-2\n\n if not l2:\n print str(ct)+\" 1\"\n ct=-2\n\n st=\"\"\n for e in l1:\n st=st+str(e)\n st=st+\"a\"\n for e in l2:\n st=st+str(e)\n\n if st not in dic:\n dic[st]=1\n else:\n print \"-1\"\n ct=-2\n ct+=1\n\n"}, {"source_code": "n = int(raw_input())\nA = [int(i) for i in raw_input().split()][1:]\nB = [int(i) for i in raw_input().split()][1:]\n\nhash_map = {}\n\nc = 0\n\nwhile len(A) > 0 and len(B) > 0:\n if ((A[0], B[0]) in hash_map):\n print -1\n raise SystemExit\n hash_map.update({(A[0], B[0]): 1})\n if (A[0] > B[0]):\n A = A[1:] + [B[0], A[0]]\n B = B[1:]\n else:\n B = B[1:] + [A[0], B[0]]\n A = A[1:]\n c += 1\n\nprint c,\nif len(A):\n print 1\nelse:\n print 2\n\n"}, {"source_code": "import sys\nfrom datetime import datetime\n\nn = int(input()) #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0440\u0442\n\nk1 = input().split()\nk2 = input().split()\n\nk1 = [int(x) for x in k1]\nk2 = [int(x) for x in k2]\nk1.pop(0)\nk2.pop(0)\n\n\n\n\n\niteration = 0\nwhile (len(k1) !=0 and len(k2) !=0 ):\n\tkarta_1 = k1[0]\n\tkarta_2 = k2[0]\n\tif(karta_2 > karta_1):\n\t\tk1.pop(0)\n\t\tk2.pop(0)\n\t\tk2.append(karta_1)\n\t\tk2.append(karta_2)\n\t\t\n\tif(karta_2 < karta_1):\n\t\tk2.pop(0)\n\t\tk1.pop(0)\n\t\t\n\t\tk1.append(karta_2)\n\t\tk1.append(karta_1)\n\n\t\n\titeration = iteration + 1\n\tif(iteration > 100):\n\t\tbreak\n\t\t\n\n\n\nif(iteration > 100):\n\tprint(-1)\n\tsys.exit()\nif(len(k2) != 0):\n\tprint(iteration, 2)\nif(len(k1) !=0):\n\tprint(iteration, 1)\n\n\n"}, {"source_code": "n = int(input())\nk1 = input().strip().split()\nk2 = input().strip().split()\nk1 = k1[1:]\nk2 = k2[1:]\nmema = []\nmemb = []\nr = 0\nwhile k1 != [] and k2 != []:\n r += 1\n mema.append(k1[:])\n memb.append(k2[:])\n a = k1[0]\n del k1[0]\n b = k2[0]\n del k2[0]\n if int(a) > int(b):\n k1.append(b)\n k1.append(a)\n elif int(b) > int(a):\n k2.append(a)\n k2.append(b)\n if k1 == []:\n print(r,2)\n elif k2 == []:\n print(r,1)\n if k1 in mema or k2 in memb:\n print(r,-1)\n break"}, {"source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\nfrom math import ceil, floor;\n\n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp\n\n## gcd function\ndef gcd(a,b):\n if a == 0:\n return b\n return gcd(b%a, a)\n\n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k \n res = 1\n for i in range(k): \n res = res * (n - i) \n res = res / (i + 1) \n return int(res) \n\n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0):\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if a[mid] < x:\n lo = mid+1\n else:\n hi = mid\n return lo\n\n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n\n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n\n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b\n\n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n\n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n\n\n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n\n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e6 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n\n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)]\n# spf_sieve() \ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()))\n## taking string array input\ndef str_array():\n return input().strip().split();\n\n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n\n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n\nn = int(input()); a = int_array(); b = int_array();\nk1 = a[0]; a = a[1:]; k2 = b[0]; b = b[1:];\nia = a.copy(); ib = b.copy();\ncount = 0; f = 0; won = 2;\nwhile(1):\n if not a or not b:\n f = 1; break;\n count += 1;\n if won == 2:\n won = 1;\n else:\n won = 2;\n x = a.pop(0); y = b.pop(0);\n if x > y:\n a.append(y); a.append(x);\n else:\n b.append(x); b.append(y);\n if a == ia and b == ib:\n break;\nif f:\n print(*(count, won));\nelse:\n print(-1);"}, {"source_code": "cards = int(input())\nstart_first = input().split()[1:]\nstart_second = input().split()[1:]\nhist = []\nhist.append((start_first,start_second))\nf = [c for c in start_first]\ns = [c for c in start_second]\nrounds = 0\nwhile f and s:\n c_f,c_s = f.pop(0), s.pop(0)\n \n if int(c_f) > int(c_s):\n f.append(c_s)\n f.append(c_f)\n else:\n s.append(c_f)\n s.append(c_s)\n rounds += 1\n hist.append((f,s))\n if (f,s) in hist:\n print (-1)\n break\nelse:\n print (rounds, (1,2)[f == []])\n\n"}, {"source_code": "#f = open('c:\\\\users\\\\arthur\\\\desktop\\\\redmart\\\\numbers.txt')\n#d = f.readline().split()\n#d = map(int, d)\n##d = [3, 2, 4, 5, 6 ,7]\n#print d[10000]\n#e = d[0]\n#y = 0\n#step=0\n#while step != 10000:\n# if e >=len(d):\n# break\n# step+=1\n# y = e\n# e = d[e]\n# #print step, ' ', e\n#print e, ' ',y\n\nimport collections\n\ndef getStr(x,y):\n s=''\n for i in x:\n s+=str(i)\n for i in y:\n s+=str(i)\n return s\n\ndef move(x, y):\n if x[0] > y[0]:\n a = x.popleft()\n b = y.popleft()\n x.append(b)\n x.append(a)\n else:\n a = y.popleft()\n b = x.popleft()\n y.append(b)\n y.append(a)\n return (x,y)\n\nn = int(raw_input())\ntmpA = map(int, raw_input().split())\ntmpB = map(int, raw_input().split())\n\n#deque A\nlA = []\nlB = []\n\nfor i in range(tmpA[0]):\n lA.append(tmpA[i+1])\nfor i in range(tmpB[0]):\n lB.append(tmpB[i+1])\n\nhA = collections.deque(lA)\nhB = collections.deque(lB)\n\nh = dict()\n\ncnt = 0\n\nwhile True:\n #print getStr(hA,hB)\n if len(hA)==0:\n #print 'a is empty'\n print str(cnt)+' '+str(2)\n break\n if len(hB)==0:\n #print 'b is empty'\n print str(cnt)+' '+str(1)\n break\n if getStr(hA,hB) in h:\n #print 'there already', ' ',h\n print -1\n break\n else:\n h[getStr(hA,hB)] = True\n #print 'old ', hA,' ',hB\n hA, hB = move(hA,hB)\n #print 'new ', hA,' ',hB\n \n cnt+=1"}, {"source_code": "import sys\nfrom time import time\nT=time()\nN=int(raw_input())\nK1=map(int,raw_input().split())\nK2=map(int,raw_input().split())\nStack1=K1[1:]\nStack2=K2[1:]\nI=1\nwhile time()-T<1.7:\n if Stack1[0]>Stack2[0]:\n if len(Stack1)>1:\n Stack1=Stack1[1:]+[Stack2[0]]+[Stack1[0]]\n else:\n Stack1=[Stack2[0]]+[Stack1[0]]\n Stack2.pop(0)\n else:\n if len(Stack1)>1:\n Stack2=Stack2[1:]+[Stack1[0]]+[Stack2[0]]\n else:\n Stack2=[Stack1[0]]+[Stack2[0]]\n Stack1.pop(0)\n if not len(Stack1):\n print I,2\n sys.exit()\n elif not len(Stack2):\n print I,2\n sys.exit()\n I+=1\nprint -1\n"}, {"source_code": "n = raw_input(\"\")\nk1 = raw_input(\"\")\nk2 = raw_input(\"\")\ndeste_k1 = k1.split()\ndeste_k2 = k2.split()\ndeste_k1.remove(deste_k1[0])\ndeste_k2.remove(deste_k2[0])\nel_sayisi = 0\nwhile len(deste_k1) > 0 and len(deste_k2) > 0 and el_sayisi < 200:\n if int(deste_k1[0]) > int(deste_k2[0]) :\n print deste_k1\n print deste_k2\n deste_k1.append(deste_k2[0])\n deste_k2.remove(deste_k2[0])\n deste_k1.append(deste_k1[0])\n deste_k1.remove(deste_k1[0])\n el_sayisi += 1\n elif int(deste_k2[0]) > int(deste_k1[0]) and el_sayisi < 200 :\n print deste_k1\n print deste_k2\n deste_k2.append(deste_k1[0])\n deste_k1.remove(deste_k1[0])\n deste_k2.append(deste_k2[0])\n deste_k2.remove(deste_k2[0])\n el_sayisi += 1\nif len(deste_k2) == 0 :\n print el_sayisi , \"1\"\nelif len(deste_k1) == 0 :\n print el_sayisi , \"2\"\nelse :\n print \"-1\"\n\n \n\n \n \n\n \n"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/546/C\n\nn = list(map(int, input().split()))\n\nl_1 = list(map(int, input().split()))[1:]\nl_2 = list(map(int, input().split()))[1:]\n\nl_1c = l_1.copy()\nl_2c = l_2.copy()\n\nt = 0\nwhile len(l_1c) != 0 and len(l_2c) != 0:\n if l_1c[0] == l_2c[0]:\n l_1c.append(l_1c[0])\n l_2c.append(l_2c[0])\n elif l_1c[0] > l_2c[0]:\n l_1c.append(l_2c[0])\n l_1c.append(l_1c[0])\n else:\n l_2c.append(l_1c[0])\n l_2c.append(l_2c[0])\n \n del l_1c[0]\n del l_2c[0]\n \n t += 1\n if l_1c == l_1 or t > 400:\n print(-1)\n quit()\n\nprint(\"%d %d\" % (t, 2 if len(l_1c) == 0 else 1))"}, {"source_code": "import sys\nn=input()\n\nl1=raw_input().split()\na=l1[0]\nl1=l1[1:]\nl2=raw_input().split()\nb=l2[0]\nl2=l2[1:]\n\nst=\"\"\nfor e in l1:\n st=st+str(e)\n\nst=st+\"a\"\nfor e in l2:\n st=st+str(e)\n\n\ndic={st:1}\n\nans=0\nct=1\n\nwhile ct>-1:\n\n val1=l1[0]\n val2=l2[0]\n \n if val1<val2:\n l1=l1[1:]\n a=[val1,val2]\n l2=l2[1:]+a\n else:\n l2=l2[1:]\n a=[val2,val1]\n l1=l1[1:]+a\n \n if not l1:\n print str(ct)+\" 2\"\n ct=-2\n\n if not l2:\n print str(ct)+\" 1\"\n ct=-2\n\n st=\"\"\n for e in l1:\n st=st+str(e)\n st=st+\"a\"\n for e in l2:\n st=st+str(e)\n\n if st not in dic:\n dic[st]=1\n else:\n print \"-1\"\n ct=-2\n ct+=1\n\n"}, {"source_code": "n = input()\na = map(int, raw_input().split())[1:]\nb = map(int, raw_input().split())[1:]\nans = 0\nt = 0\nwhile a and b:\n if t > 2**n:\n print -1\n exit(0)\n a0 = a.pop(0)\n b0 = b.pop(0)\n if a0 > b0:\n a.append(b0)\n a.append(a0)\n else:\n b.append(a0)\n b.append(b0)\n t += 1\n\nprint ans, 1 if a else 2"}, {"source_code": "n=int(input())\nl1=list(map(int,input().split()))\nl1.remove(l1[0])\nl2=list(map(int,input().split()))\nl2.remove(l2[0])\na,b,c,d,l3=0,0,0,0,[]\nwhile len(l1)!=0 and len(l2)!=0:\n if l1[0]>l2[0]:\n a,d=l1[0],l2[0]\n l1.remove(l1[0])\n l2.remove(l2[0])\n l1.append(d)\n l1.append(a)\n else:\n a,d=l2[0],l1[0]\n l2.remove(l2[0])\n l1.remove(l1[0])\n l2.append(d)\n l2.append(a)\n b+=1\n if l1 in l3:\n c=1\n break\n else:\n l3.append(l1)\nif c==0:\n if len(l1)==0:\n print(str(b)+' 2')\n else:\n print(str(b)+' 1')\nelse:\n print(-1)"}, {"source_code": "n=raw_input()\nn=int(n)\naa=raw_input().split(' ')\na=[int(i) for i in aa] \nbb=raw_input().split(' ')\nb=[int(i) for i in bb]\nk1=a[0]\nk2=b[0]\ndel a[0]\ndel b[0]\na0=[]\nb0=[]\nused={}\nfor i in a:\n a0.append(i)\nfor i in b:\n b0.append(i)\nans=0\nq=''.join(' '+str(e) for e in a)\nq=q.join(' '+str(e) for e in b)\nused[q]=True\nwhile 1:\n x=a[0]\n y=b[0]\n if x>y:\n del a[0]\n del b[0]\n a.append(y)\n a.append(x)\n else:\n del b[0]\n del a[0]\n b.append(x)\n b.append(y)\n\n ans=ans+1\n if len(a)==0:\n print \"{0} 2\".format(ans)\n break\n elif len(b)==0:\n print \"{0} 1\".format(ans)\n break\n\n q=''.join(' '+str(e) for e in a)\n q=q.join(' '+str(e) for e in b)\n if used.get(q):\n print \"-1\"\n break\n\n used[q]=True\n\n \n"}, {"source_code": "class Soldado:\n \n def __init__(self,cartas,numero):\n \n cartas=cartas[1:]\n \n \n self.mano=cartas.split()\n self.nombre=numero\n \n def perder(self):\n if len(self.mano)>0:\n self.mano.remove(self.mano[0])\n \n def ganar(self,otro_soldado):\n self.mano.append(otro_soldado.mano[0])\n self.mano.append(self.mano[0])\n self.mano.remove(self.mano[0])\n \n \n\n def __gt__(self,otro_soldado):\n return self.mano[0]>otro_soldado.mano[0]\n \n\n def __lt__(self,otro_soldado):\n return self.mano[0]<otro_soldado.mano[0]\n \n def __eq__(self,otro_soldado):\n return len(self.mano)==len(otro_soldado.mano)\n \n def __str__(self):\n print(self.nombre)\n \n \n\nmazo=int(input())\ncartas1=input()\ncartas2=input()\n\nsoldado1=Soldado(cartas1,1)\nsoldado2=Soldado(cartas2,2)\n\n\n#ahora hago el juego\n\njuego=True\nt=0\n\nwhile juego==True:\n \n if soldado1>soldado2:\n soldado1.ganar(soldado2)\n soldado2.perder()\n t+=1\n\n elif soldado1<soldado2:\n soldado2.ganar(soldado1)\n soldado1.perder()\n t+=1\n \n elif soldado1==soldado2:\n juego=False\n \n if t>50:\n print(\"-1\")\n juego=False\n \n elif len(soldado1.mano)==0:\n juego=False\n print(str(t)+\" \"+\"2\")\n \n elif len(soldado2.mano)==0:\n juego=False\n print(str(t)+\" \"+\"1\")"}, {"source_code": "# It's never too late to start!\nfrom bisect import bisect_left\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom collections import Counter, defaultdict\nfrom collections import deque\nfrom functools import cmp_to_key\nimport math\nimport heapq\nimport re\n\ndef sin():\n return input()\ndef ain():\n return list(map(int, sin().split()))\ndef sain():\n return input().split()\ndef iin():\n return int(sin())\nMAX = float('inf')\nMIN = float('-inf')\nMOD = 1000000007\ndef sieve(n): \n prime = [True for i in range(n+1)]\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p): \n prime[i] = False\n p += 1\n s = set()\n for p in range(2, n+1): \n if prime[p]: \n s.add(p)\n return s\ndef readTree(n, m):\n adj = [deque([]) for _ in range(n+1)]\n for _ in range(m):\n u,v = ain()\n adj[u].append(v)\n adj[v].append(u)\n return adj\n\n# Stay hungry, stay foolish!\n\ndef main():\n n = iin()\n k1 = ain()\n k2 = ain()\n d1 = deque(k1[1:])\n d2 = deque(k2[1:])\n k1 = k1[0]\n k2 = k2[0]\n a1 = d1.copy()\n a2 = d2.copy()\n flag = -1\n ans = 0\n while 1:\n ans += 1\n x1 = d1.popleft()\n x2 = d2.popleft()\n if x1>x2:\n d1.append(x2)\n d1.append(x1)\n else:\n d2.append(x1)\n d2.append(x2)\n \n if len(d1) == 0:\n flag = 2\n break\n\n if len(d2) == 0:\n flag = 1\n break\n\n if d1 == a1 or d2 == a2:\n break\n if flag == -1:\n print(flag)\n else:\n print(ans, flag)\n\n\n\n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n\n# Fast IO Template starts\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\nif os.getcwd() == 'D:\\\\code':\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# Fast IO Template ends\nif __name__ == \"__main__\":\n main()\n\n# Never Give Up - John Cena"}, {"source_code": "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n# sys.setrecursionlimit(pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(\" \".join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\nn = int(data())\ns1, s2 = deque(l()[1:]), deque(l()[1:])\nstate = set()\nstate.add(tuple(s1))\nstate.add(tuple(s2))\ncnt = 0\nwhile True:\n t1, t2 = s1.popleft(), s2.popleft()\n if t1 > t2:\n s1.append(t2)\n s1.append(t1)\n else:\n s2.append(t1)\n s2.append(t2)\n # print(s1, s2)\n if not s1:\n out(cnt + 1, 2)\n exit()\n if not s2:\n out(cnt + 1, 1)\n exit()\n if tuple(s1) in state or tuple(s2) in state:\n out(-1)\n exit()\n cnt += 1\n state.add(tuple(s1))\n state.add(tuple(s2))\n"}, {"source_code": "n = int(input())\nk1 = input().strip().split()\nk2 = input().strip().split()\nk1 = k1[1:]\nk2 = k2[1:]\nmema = []\nmemb = []\nr = 0\nwhile k1 != [] and k2 != []:\n r += 1\n mema.append(k1[:])\n memb.append(k2[:])\n a = k1[0]\n del k1[0]\n b = k2[0]\n del k2[0]\n if int(a) > int(b):\n k1.append(b)\n k1.append(a)\n elif int(b) > int(a):\n k2.append(a)\n k2.append(b)\n if k1 == []:\n print(r,2)\n elif k2 == []:\n print(r,1)\n if k1 in mema or k2 in memb:\n print(-1)\n break\n"}, {"source_code": "# It's never too late to start!\nfrom bisect import bisect_left\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom collections import Counter, defaultdict\nfrom collections import deque\nfrom functools import cmp_to_key\nimport math\nimport heapq\nimport re\n\ndef sin():\n return input()\ndef ain():\n return list(map(int, sin().split()))\ndef sain():\n return input().split()\ndef iin():\n return int(sin())\nMAX = float('inf')\nMIN = float('-inf')\nMOD = 1000000007\ndef sieve(n): \n prime = [True for i in range(n+1)]\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p): \n prime[i] = False\n p += 1\n s = set()\n for p in range(2, n+1): \n if prime[p]: \n s.add(p)\n return s\ndef readTree(n, m):\n adj = [deque([]) for _ in range(n+1)]\n for _ in range(m):\n u,v = ain()\n adj[u].append(v)\n adj[v].append(u)\n return adj\n\n# Stay hungry, stay foolish!\n\ndef main():\n n = iin()\n k1 = ain()\n k2 = ain()\n d1 = deque(k1[1:])\n d2 = deque(k2[1:])\n k1 = k1[0]\n k2 = k2[0]\n a1 = d1.copy()\n a2 = d2.copy()\n flag = -1\n ans = 0\n while 1:\n ans += 1\n x1 = d1.popleft()\n x2 = d2.popleft()\n if x1>x2:\n d1.append(x2)\n d1.append(x1)\n else:\n d2.append(x1)\n d2.append(x2)\n \n if len(d1) == 0:\n flag = 2\n break\n\n if len(d2) == 0:\n flag = 1\n break\n\n if d1 == a1 or d2 == a2:\n break\n if flag == -1:\n print(flag)\n else:\n print(ans, flag)\n\n\n\n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n\n# Fast IO Template starts\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\nif os.getcwd() == 'D:\\\\code':\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# Fast IO Template ends\nif __name__ == \"__main__\":\n main()\n\n# Never Give Up - John Cena"}, {"source_code": "n = int(input())\ns1 = [int(i) for i in input().split()]\ns1.pop(0)\ns2 = [int(i) for i in input().split()]\ns2.pop(0)\nt = 0\nwhile s1 and s2:\n t += 1\n a = s1.pop(0)\n b = s2.pop(0)\n if a > b:\n s1.append(b)\n s1.append(a)\n else:\n s2.append(a)\n s2.append(b)\n if t>100:\n break\nif t>100:\n print(-1)\nelse:\n if s1:\n print(t, 1)\n else:\n print(t, 2)\n"}, {"source_code": "import sys\n\nn = int(raw_input())\nxcards = map(int, raw_input().split())\nx = xcards[0]\nxcards = xcards[1:]\ny = n - x\nycards = map(int, raw_input().split())[1:]\n\nfights = 0\nstates = set()\nwhile xcards and ycards:\n fights += 1\n xval = xcards.pop(0)\n yval = ycards.pop(0)\n if xval > yval:\n xcards.append(yval)\n xcards.append(xval)\n else:\n ycards.append(xval)\n ycards.append(yval)\n\n if tuple(xcards + ycards) in states:\n print -1\n sys.exit(0)\n states.add(tuple(xcards + ycards))\nprint fights, 1 if xcards else 2\n"}, {"source_code": "import sys\n\ndef solve(da, db):\n da_n = da[:]\n db_n = db[:]\n while True:\n if da[0] < db[0]:\n db.append(da[0])\n db.append(db[0])\n if da[0] > db[0]:\n da.append(db[0])\n da.append(da[0])\n da.pop(0)\n db.pop(0)\n if len(da) == 0:\n return 2\n if len(db) == 0:\n return 1\n if da_n == da:\n return -1\n\n\nif __name__ == '__main__':\n t = input()\n da = map(int, sys.stdin.readline().rstrip().split())[1:]\n db = map(int, sys.stdin.readline().rstrip().split())[1:]\n print solve(da, db)\n"}, {"source_code": "n=input()\nk1=raw_input().split(' ')\nk2=raw_input().split(' ')\nk1f=[None]*len(k1)\nk2f=[None]*len(k2)\nfor i in range(len(k1)):\n k1[i]=int(k1[i])\n k1f[i]=k1[i]\nfor i in range(len(k2)):\n k2[i]=int(k2[i])\n k2f[i]=k2[i]\nfight=0\nwhile k1[0]!=0 and k2[0]!=0:\n if k1[1]>k2[1]:\n x=k1[1]\n y=k2[1]\n for i in range(1,len(k1)-1):\n k1[i]=k1[i+1]\n for i in range(1,len(k2)-1):\n k2[i]=k2[i+1]\n k1[len(k1)-1]=y\n k1=k1+[x]\n k2.remove(k2[len(k2)-1])\n fight=fight+1\n k1[0]=len(k1)-1\n k2[0]=len(k2)-1\n else:\n x=k2[1]\n y=k1[1]\n for i in range(1,len(k1)-1):\n k1[i]=k1[i+1]\n for i in range(1,len(k2)-1):\n k2[i]=k2[i+1]\n k2[len(k2)-1]=y\n k2=k2+[x]\n z=k1[len(k1)-1]\n k1.remove(z)\n fight=fight+1\n k1[0]=len(k1)-1\n k2[0]=len(k2)-1\n if k1==k1f and k2==k2f:\n print -1\n break\nif k1!=k1f and k2!=k2f:\n if k1[0]==0:\n print fight,2\n else:\n print fight,1\n"}, {"source_code": "def pick_card(k, stack):\n\tk -= 1\n\tdevide = 10**k\n\tcard = stack / devide\n\tstack = stack % devide\n\treturn k, card, stack\n\ndef puts_card(k, stack, card_w, card_l):\n\tk += 2\n\treturn k, stack*100 + card_l*10 + card_w\n\nn = int(raw_input())\ninputs = raw_input().split(\" \")\nk1 = int(inputs[0])\nstack1 = int(\"\".join(inputs[1:]))\ninputs = raw_input().split(\" \")\nk2 = int(inputs[0])\nstack2 = int(\"\".join(inputs[1:]))\nplayed = set([(stack1,stack2)])\nfight = 0\n\nwhile 1:\n\tfight += 1\n\tk1, card1, stack1 = pick_card(k1, stack1)\n\tk2, card2, stack2 = pick_card(k2, stack2)\n\tif card1 > card2:\n\t\tk1, stack1 = puts_card(k1, stack1, card1, card2)\n\telse:\n\t\tk2, stack2 = puts_card(k2, stack2, card2, card1)\n\n\tif k1 == 0:\n\t\tprint fight, 2\n\t\tbreak\n\telif k2 == 0:\n\t\tprint fight, 1\n\t\tbreak\n\telif (stack1, stack2) in played:\n\t\tprint -1\n\t\tbreak\n\telse:\n\t\tplayed.add((stack1,stack2))\n"}, {"source_code": "n=int(input())\ns1=list(map(int,input().split()))\ns2=list(map(int,input().split()))\ns1=s1[1:]\ns2=s2[1:]\ncount=0\nwhile len(s1)!=0 and len(s2)!=0 and count<500:\n if s1[0]>s2[0]:\n s1.append(s2[0])\n s1.append(s1[0])\n s1=s1[1:]\n s2=s2[1:]\n \n else:\n s2.append(s1[0])\n s2.append(s2[0])\n s2=s2[1:]\n s1=s1[1:]\n count=count+1\nif len(s1)==0:\n print(count, end=' ')\n print('2')\nelif len(s2)==0:\n print(count,end=' ')\n print('1')\nelif count>500:\n print('-1')\n\n"}, {"source_code": "n = int(input())\narr1 = [int(i) for i in input().split()]\narr2 = [int(i) for i in input().split()]\nn1 = arr1.pop(0)\nn2 = arr2.pop(0)\nstart = [i for i in arr1]\nend = [i for i in arr2]\ncount = 0\nflag = 0\nwhile (arr1 != start and arr2 != end) or count == 0:\n if arr1[0] > arr2[0]:\n arr1.append(arr2.pop(0))\n arr1.append(arr1.pop(0))\n n1 += 1\n n2 -= 1\n else:\n arr2.append(arr1.pop(0))\n arr2.append(arr2.pop(0))\n n2 += 1\n n1 -= 1\n count += 1\n if n1 == 0 or n2 == 0:\n if n1 == 0:\n print(count, 2)\n else:\n print(count, 1)\n flag = 1\n break\nif flag == 0:\n print(-1)"}, {"source_code": "n = int(input())\nk1 = input().strip().split()\nk2 = input().strip().split()\nk1 = k1[1:]\nk2 = k2[1:]\nmema = []\nmemb = []\nr = 0\nwhile k1 != [] and k2 != []:\n r += 1\n mema.append(k1[:])\n memb.append(k2[:])\n print(mema)\n print(memb)\n a = k1[0]\n del k1[0]\n b = k2[0]\n del k2[0]\n if int(a) > int(b):\n k1.append(b)\n k1.append(a)\n elif int(b) > int(a):\n k2.append(a)\n k2.append(b)\n print(k1)\n print(k2)\n if k1 == []:\n print(r,2)\n elif k2 == []:\n print(r,1)\n if k1 in mema or k2 in memb:\n print(r,-1)\n break"}, {"source_code": "t=input()\nfirst=map(int,raw_input().split())\nsecond=map(int,raw_input().split())\na=first.pop(0)\nb=second.pop(0)\n\ndummy_a=list(first)\ndummy_b=list(second)\nfight=0\n\nif dummy_a[0]>dummy_b[0]:\n dummy_a.append(dummy_b.pop(0))\n dummy_a.append(dummy_a.pop(0))\n a+=1\n b-=1\n fight+=1\nelse:\n fight+=1\n dummy_b.append(dummy_a.pop(0))\n dummy_b.append(dummy_b.pop(0))\n a-=1\n b+=1\nwhile (a!=0 and b!=0 and ((dummy_a!=first) and (dummy_b!=second))):\n if dummy_a[0]>dummy_b[0]:\n dummy_a.append(dummy_b.pop(0))\n dummy_a.append(dummy_a.pop(0))\n a+=1\n b-=1\n fight+=1\n else:\n fight+=1\n dummy_b.append(dummy_a.pop(0))\n dummy_b.append(dummy_b.pop(0))\n a-=1\n b+=1\nif a==0:\n print fight,2\nelif b==0:\n print fight,1\nelse:\n print -1 \n \n \n"}, {"source_code": "def fight(k1, k2):\n l = k1.pop(0)\n r = k2.pop(0)\n if l < r:\n k2.extend([l, r])\n else:\n k1.extend([r, l])\n\n\nn = int(input())\nk1 = list(map(int, input().split()))\nk1.pop(0)\nk2 = list(map(int, input().split()))\nk2.pop(0)\n\ncombs = set()\nfights = 0\nwhile k1 and k2:\n topcomb = (k1[0], k2[0])\n if topcomb in combs:\n fights = -1\n break\n combs.add((k1[0], k2[0]))\n fight(k1, k2)\n fights += 1\n\n\nprint(fights, end=' ')\nif fights > -1:\n print(1 if k1 else 2)"}, {"source_code": "import sys\n\nn = int(input()) #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0440\u0442\n\nk1 = input().split()\nk2 = input().split()\n\nk1 = [int(x) for x in k1]\nk2 = [int(x) for x in k2]\nk1.pop(0)\nk2.pop(0)\n\n\nif n < 4:\n\tprint(-1)\n\tsys.exit()\n\niteration = 0\nwhile (len(k1) !=0 and len(k2) !=0 ):\n\tkarta_1 = k1[0]\n\tkarta_2 = k2[0]\n\tif(karta_2 > karta_1):\n\t\tk1.pop(0)\n\t\tk2.pop(0)\n\t\tk2.append(karta_1)\n\t\tk2.append(karta_2)\n\t\t\n\tif(karta_2 < karta_1):\n\t\tk2.pop(0)\n\t\tk1.pop(0)\n\t\t\n\t\tk1.append(karta_2)\n\t\tk1.append(karta_1)\n\n\t\n\titeration = iteration + 1\n\nif(len(k2) != 0):\n\tprint(iteration, 2)\nif(len(k1) !=0):\n\tprint(iteration, 1)\n"}, {"source_code": "from sys import stdin\nfrom collections import deque\n\nn = int(stdin.readline())\nk1nums = deque(map(int, stdin.readline().split()))\nk2nums = deque(map(int, stdin.readline().split()))\n\nk1nums.popleft()\nk2nums.popleft()\n\nflag = 1\nng = 0\nvisited = set()\nwhile k1nums and k2nums:\n top1, top2 = k1nums.popleft(), k2nums.popleft()\n\n if (top1, top2) in visited:\n print(-1)\n flag = 0\n break\n else:\n visited.add((top1, top2))\n\n if top1 > top2:\n k1nums.append(top2)\n k1nums.append(top1)\n else:\n k2nums.append(top1)\n k2nums.append(top2)\n \n ng += 1\n\nif flag:\n if not k1nums:\n print(ng, 2)\n else:\n print(ng, 1)\n"}, {"source_code": "_ = raw_input()\np1 = raw_input().split()\np1.pop(0)\np2 = raw_input().split()\np2.pop(0)\nstate = []\ncount = 0\nwhile True:\n key = '.'.join(p1) + '-' + '.'.join(p2)\n if key in state:\n print -1\n break\n elif len(p1) == 0:\n print \"{} {}\".format(count, 2)\n break\n elif len(p2) == 0:\n print \"{} {}\".format(count, 1)\n break\n else:\n state.append(key)\n count += 1\n top1 = p1.pop(0)\n top2 = p2.pop(0)\n if top1 > top2:\n p1.extend([top2, top1])\n else:\n p2.extend([top1, top2])\n"}, {"source_code": "import Queue,math\nn = input()\nm = math.factorial(n+1)\nq1 = Queue.Queue().queue\nq2 = Queue.Queue().queue\nL = map(int,raw_input().split())\nk1 = L[0]\nfor i in range(1,len(L)):\n\tq1.append(L[i])\nL = map(int,raw_input().split());\nk2 = L[0]\nfor i in range(1,len(L)):\n\tq2.append(L[i])\nans=0\nr1 = [i for i in q1]\nr2 = [i for i in q2]\nwhile len(q1)>0 and len(q2)>0:\n\tif q1[0] > q2[0]:\n\t\tq1.append(q2.popleft())\n\t\tq1.append(q1.popleft())\n\telse:\n\t\tq2.append(q1.popleft())\n\t\tq2.append(q2.popleft())\n\tf = 1\n\tfor i in q1:\n\t\tif i not in r1:\n\t\t\tf = 0\n\t\t\tbreak\n\tif f:\n\t\tfor i in q2:\n\t\t\tif i not in r2:\n\t\t\t\tf = 0\n\t\t\t\tbreak\n\tif f:\n\t \tbreak\n\tans+=1\nif f:\n\tprint -1\nelse:\n\tprint ans,\n\tif len(q1):\n\t\tprint 1\n\telse:\n\t\tprint 2\n"}, {"source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\nfrom math import ceil, floor;\n\n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp\n\n## gcd function\ndef gcd(a,b):\n if a == 0:\n return b\n return gcd(b%a, a)\n\n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k \n res = 1\n for i in range(k): \n res = res * (n - i) \n res = res / (i + 1) \n return int(res) \n\n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0):\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if a[mid] < x:\n lo = mid+1\n else:\n hi = mid\n return lo\n\n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n\n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n\n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b\n\n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n\n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n\n\n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n\n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e6 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n\n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)]\n# spf_sieve() \ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()))\n## taking string array input\ndef str_array():\n return input().strip().split();\n\n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n\n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n\nn = int(input()); a = int_array(); b = int_array();\nk1 = a[0]; a = a[1:]; k2 = b[0]; b = b[1:];\nia = a.copy(); ib = b.copy();\ncount = 0; f = 0; won = 2;\nwhile(1):\n if not a or not b:\n f = 1; break;\n count += 1;\n if won == 2:\n won = 1;\n else:\n won = 2;\n x = a.pop(0); y = b.pop(0);\n if x > y:\n a.append(y); a.append(x);\n else:\n b.append(x); b.append(y);\n if a == ia and b == ib:\n break;\nif f:\n print(*(count, won));\nelse:\n print(-1);"}, {"source_code": "n = int(input())\n\nx = input().split()\ny = input().split()\n\nplayer_1 = []\nplayer_2 = []\nmemory = []\naux = []\n\nfor card in range(int(x[0])):\n player_1.append(int(x[card + 1]))\n aux.append(int(x[card + 1]))\nfor card in range(int(y[0])):\n player_2.append(int(y[card + 1]))\nmemory.append(aux)\n\ncondition = False\ncounter = 0\n\nwhile len(player_1) > 0 and len(player_2) > 0 and not condition:\n c1, c2 = player_1.pop(0), player_2.pop(0)\n if player_1 in memory:\n condition = True\n if c1 > c2:\n player_1.append(c2)\n player_1.append(c1)\n else:\n player_2.append(c1)\n player_2.append(c2)\n aux = []\n for card in player_1:\n aux.append(card)\n memory.append(aux)\n counter += 1\n\nif not condition:\n answer = str(counter)\n if len(player_1) == 0:\n answer += \" 2\"\n else:\n answer += \" 1\"\nelse:\n answer = \"-1\"\nprint(answer)\n"}, {"source_code": "__author__ = 'trunghieu11'\nn = int(input())\nfirst = list(map(int, input().split()))[1:]\nsecond = list(map(int, input().split()))[1:]\nfirst.reverse()\nsecond.reverse()\nround = 0\nwhile (round < 10000):\n if len(first) * len(second) == 0:\n break\n fCard = first.pop()\n sCard = second.pop()\n if fCard > sCard:\n first.insert(0, sCard)\n first.insert(0, fCard)\n else:\n second.insert(0, fCard)\n second.insert(0, sCard)\n round += 1\nif len(first) == 0:\n print(round, 1)\nelif len(second) == 0:\n print(round, 2)\nelse:\n print(-1)"}, {"source_code": "from collections import deque\n\ndef wars():\n n = int(input())\n cards = input().split()\n tot = int(cards[0])\n aux = tot\n queue1 = deque(int(i) for i in cards[1:])\n queue2 = deque(int(i) for i in input().split()[1:])\n s1,s2 = sum(queue1), sum(queue2)\n if (s1 / 2 == s2 and queue1[0] < queue2[0]) or (s2 / 2 == s1 and queue2[0] < queue1[0]):\n return -1\n battles = set()\n c = 0\n while queue1 and queue2:\n c1 = queue1.popleft()\n c2 = queue2.popleft()\n if (c1, c2) in battles and aux == tot:\n return -1\n c += 1\n battles.add((c1, c2))\n if c1 > c2:\n queue1.append(c2)\n queue1.append(c1)\n aux += 1\n else:\n queue2.append(c1)\n queue2.append(c2)\n aux -= 1\n w = '1' if queue1 else '2'\n return str(c) + ' ' + w\n\nprint(wars())\n"}, {"source_code": "x=int(input())\nA=list(map(int,input().split()))\nA=A[1:]\n#print(A)\nD=A\n#print(D)\nB=list(map(int,input().split()))\nB=B[1:]\nE=B\nC=[]\nprint(A)\nprint(B)\ncount=0\nwhile(1):\n\tstate=-100\n\tif A==C:\n\t\tstate=10\n\t\tbreak\n\tif B==C:\n\t\tstate=100\n\t\tbreak\n\tif A[0]>B[0]:\n\t\tA.append(B[0])\n\t\tA.append(A[0])\n\t\tA=A[1:]\n\t\tB=B[1:]\n\t\tcount=count+1\n\t\tprint(A,B)\n\t\tstate=0\n\tif state!=0:\t\n\t\tif B[0]>A[0]:\n\t\t\tB.append(A[0])\n\t\t\tB.append(B[0])\n\t\t\tB=B[1:]\n\t\t\tA=A[1:]\n\t\t\tcount=count+1\n\t\t\tprint(A,B)\n\tif A==D:\n\t\tif B==E:\n\t\t\tstate=1000\n\t\t\tbreak\n\tif A==E:\n\t\tif B==D:\n\t\t\tstate=1000\n\t\t\tbreak\nif state==10:\n\tprint (count,2)\nif state==100:\n\tprint (count,1)\nif state==1000:\n\tprint (-1)\n\n\n"}, {"source_code": "n=input()\ns=set()\nF=lambda x:str(reduce(lambda a,i:a|1<<i, x, 0))\na=[map(int,raw_input().split())[1:] for _ in range(2)]\nG=lambda: F(a[0])+F(a[1])\ns.add(G())\ncnt=0\nwhile 1:\n cnt+=1\n k=1 if a[0][0]<a[1][0] else 0\n a[k]+=[a[k^1][0], a[k][0]]\n a[k].pop(0)\n a[k^1].pop(0)\n state=G()\n if state in s:\n print -1\n break\n if len(a[0]) in (0,n):\n print cnt, k+1\n break\n s.add(state)\n"}, {"source_code": "from collections import deque\n\ndef checkVisited():\n p1State = 0\n for card in p1:\n p1State = p1State * 10 + card\n p2State = 0\n for card in p2:\n p2State *= p2State * 10 + card\n if (p1State, p2State) not in visited:\n visited.add((p1State, p2State))\n return False\n return True\n\nnCards = int(raw_input())\np1 = deque(map(int, raw_input().split())[1:])\np2 = deque(map(int, raw_input().split())[1:])\nvisited = set()\ncheckVisited()\nnMoves = 0\nwhile True:\n nMoves += 1\n p1Card = p1.popleft()\n p2Card = p2.popleft()\n if p1Card > p2Card:\n p1.extend((p2Card, p1Card))\n else:\n p2.extend((p1Card, p2Card))\n if not p1 or not p2:\n print nMoves, 1 if not p2 else 2\n break\n if checkVisited():\n print -1\n break"}, {"source_code": "n=int(input())\ns1=list(map(int,input().split()))\ns2=list(map(int,input().split()))\ns1=s1[1:]\ns2=s2[1:]\ncount=0\nwhile len(s1)!=0 and len(s2)!=0 and count<500:\n if s1[0]>s2[0]:\n s1.append(s2[0])\n s1.append(s1[0])\n s1=s1[1:]\n s2=s2[1:]\n \n else:\n s2.append(s1[0])\n s2.append(s2[0])\n s2=s2[1:]\n s1=s1[1:]\n count=count+1\nif len(s1)==0:\n print(count, end=' ')\n print('2')\nelif len(s2)==0:\n print(count,end=' ')\n print('1')\nelif count>500:\n print('-1')\n\n"}, {"source_code": "n=int(raw_input())\na=[]\nb=[]\n \nz=raw_input().split(' ')\nk1=int(z[0])\nfor i in range(0,k1):\n a.append(z[i+1])\n\nz=raw_input().split(' ')\nk2=int(z[0])\nfor i in range(0,k2):\n b.append(z[i+1])\n\nk=0\nwhile True:\n if k>10000 or len(a)==0 or len(b)==0:\n break\n if a[0]>b[0]:\n a.append(b[0])\n a.append(a[0])\n else:\n b.append(a[0])\n b.append(b[0])\n del(a[0]); del(b[0])\n k+=1\n \nif k>10000: \n print(\"-1\")\nelse:\n if len(b)==0:\n print(str(k)+\" 1\")\n else:\n print(str(k)+\" 2\")\n"}, {"source_code": "import sys\n\ndef solve(da, db):\n da_n = []\n da_n.append(da[:])\n step = 0\n while True:\n step += 1\n if da[0] < db[0]:\n db.append(da[0])\n db.append(db[0])\n if da[0] > db[0]:\n da.append(db[0])\n da.append(da[0])\n da.pop(0)\n db.pop(0)\n if len(da) == 0:\n return str(step)+' '+str(2)\n if len(db) == 0:\n return str(step)+' '+str(1)\n for i in da_n:\n if i == da:\n return -1\n da_n.append(da[:])\n\nif __name__ == '__main__':\n t = input()\n da = map(int, sys.stdin.readline().rstrip().split())[1:]\n db = map(int, sys.stdin.readline().rstrip().split())[1:]\n print solve(da, db)\n"}, {"source_code": "n=int(input())\nper1=input().split()\nper2=input().split()\nA = per1[1:]\nB = per2[1:]\ndef func(A,B):\n if int(A[0]) > int(B[0]):\n A.append(B.pop(0))\n A.append(A.pop(0))\n else:\n B.append(A.pop(0))\n B.append(B.pop(0))\nanswer = 0\ns=1\nvse = set()\nlenny = 0\nwhile A and B:\n vse.add(''.join(A) + ''.join(B))\n\n func(A,B)\n\n if len(vse) == answer:\n s = 0\n break\n answer += 1\nprint(((str(answer) + ' ' + str(2 if len(A) == 0 else 1))) if s == 1 else -1)\n"}, {"source_code": "\"\"\"\nAuthor : raj1307 - Raj Singh\nInstitute : Jalpaiguri Government Engineering College\nDate : 3.05.19\n\"\"\"\nfrom __future__ import division, print_function\nimport itertools,os,sys\n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify, #heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pow,pi\n#from bisect import bisect_left,bisect_right\n#from decimal import *,threading\n\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n from builtins import str as __str__\n str = lambda x=b'': x if type(x) is bytes else __str__(x).encode()\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._buffer = BytesIO()\n self._fd = file.fileno()\n self._writable = 'x' in file.mode or 'r' not in file.mode\n self.write = self._buffer.write if self._writable else None\n\n def read(self):\n return self._buffer.read() if self._buffer.tell() else os.read(self._fd, os.fstat(self._fd).st_size)\n\n def readline(self):\n while self.newlines == 0:\n b, ptr = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)), self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines += b.count(b'\\n') + (not b)\n self.newlines -= 1\n return self._buffer.readline()\n\n def flush(self):\n if self._writable:\n os.write(self._fd, self._buffer.getvalue())\n self._buffer.truncate(0), self._buffer.seek(0)\n\n\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b'\\r\\n')\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop('sep', b' '), kwargs.pop('file', sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop('end', b'\\n'))\n if kwargs.pop('flush', False):\n file.flush()\n\n\ndef ii(): return int(input())\ndef si(): return str(input())\ndef mi():return map(int,input().strip().split(\" \"))\ndef li():return list(mi())\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p1\n return res\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\n# For getting input from input.txt file \n#sys.stdin = open('input.txt', 'r') \n \n# Printing the Output to output.txt file \n#sys.stdout = open('output.txt', 'w') \n\ndef main():\n \n n=ii()\n a=li()\n b=li()\n na=a[0]\n nb=b[0]\n a=a[1:]\n b=b[1:]\n \n m=0\n while(len(a)!=0 and len(b)!=0 and m!=100):\n \n if a[0]>b[0]:\n a.append(b[0])\n a.append(a[0])\n del a[0]\n del b[0]\n else:\n b.append(a[0])\n b.append(b[0])\n del a[0]\n del b[0]\n \n m+=1 \n \n \n if m==100:\n if len(a)==0:\n print(m,2)\n elif len(b)==0:\n print(m,1)\n else:\n print(-1)\n else:\n if len(a)==0:\n print(m,2)\n elif len(b)==0:\n print(m,1)\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\nif __name__ == \"__main__\":\n main()\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n=int(input())\nl1=list(map(int,input().split()))\nl1.remove(l1[0])\nl2=list(map(int,input().split()))\nl2.remove(l2[0])\na,b,c,d,l3=0,0,0,0,[]\nwhile len(l1)!=0 and len(l2)!=0:\n if l1[0]>l2[0]:\n a,d=l1[0],l2[0]\n l1.remove(l1[0])\n l2.remove(l2[0])\n l1.append(d)\n l1.append(a)\n else:\n a,d=l2[0],l1[0]\n l2.remove(l2[0])\n l1.remove(l1[0])\n l2.append(d)\n l2.append(a)\n b+=1\n if l1 in l3:\n c=1\n break\n else:\n l3.append(l1)\nif c==0:\n if len(l1)==0:\n print(str(b)+' 2')\n else:\n print(str(b)+' 1')\nelse:\n print(-1)"}, {"source_code": "from collections import deque\n\ndef checkVisited():\n p1State = 0\n for card in p1:\n p1State = p1State * 10 + card\n p2State = 0\n for card in p2:\n p2State *= p2State * 10 + card\n if (p1State, p2State) not in visited:\n visited.add((p1State, p2State))\n return False\n return True\n\nnCards = int(raw_input())\np1 = deque(map(int, raw_input().split())[1:])\np2 = deque(map(int, raw_input().split())[1:])\nvisited = set()\ncheckVisited()\nnMoves = 0\nwhile True:\n nMoves += 1\n p1Card = p1.popleft()\n p2Card = p2.popleft()\n if p1Card > p2Card:\n p1.extend((p2Card, p1Card))\n else:\n p2.extend((p1Card, p2Card))\n if not p1 or not p2:\n print nMoves, 1 if not p2 else 2\n break\n if checkVisited():\n print -1\n break"}, {"source_code": "import sys\nn=input()\n\nl1=raw_input().split()\na=l1[0]\nl1=l1[1:]\nl2=raw_input().split()\nb=l2[0]\nl2=l2[1:]\n\nst=\"\"\nfor e in l1:\n st=st+str(e)\n\nst=st+\"a\"\nfor e in l2:\n st=st+str(e)\n\n\ndic={st:1}\n\nans=0\nct=1\n\nwhile ct>-1:\n\n val1=l1[0]\n val2=l2[0]\n \n if val1<val2:\n l1=l1[1:]\n a=[val1,val2]\n l2=l2[1:]+a\n else:\n l2=l2[1:]\n a=[val2,val1]\n l1=l1[1:]+a\n \n if not l1:\n print str(ct)+\" 2\"\n ct=-2\n\n if not l2:\n print str(ct)+\" 1\"\n ct=-2\n\n st=\"\"\n for e in l1:\n st=st+str(e)\n st=st+\"a\"\n for e in l2:\n st=st+str(e)\n\n if st not in dic:\n dic[st]=1\n else:\n print \"-1\"\n ct=-2\n ct+=1\n\n"}, {"source_code": "n = int(input())\n\nq1 = list(map(int, input().split()))[1:]\nq2 = list(map(int, input().split()))[1:]\n\ns = set()\nwhile q1 and q2:\n a = q1.pop(0)\n b = q2.pop(0)\n if a < b:\n q2.append(a)\n q2.append(b)\n else:\n q1.append(b)\n q1.append(a)\n t = (tuple(q1), tuple(q2))\n if t in s:\n break\n s.add(t)\n\nif q1 and q2:\n print(-1)\nelse:\n print(1 if q2 else 2)\n"}, {"source_code": "n=int(raw_input())\nl=map(int,raw_input().split())\nm=map(int,raw_input().split())\nl=l[1:]\nm=m[1:]\na=0\np=[[c for c in l]]\n#print l\nwhile len(l)>0 and len(m)>0:\n if l[0]>m[0]:\n l=l[1:]+[m[0],l[0]]\n m=m[1:]\n a+=1\n #print l\n if l in p:\n break\n else:\n p.append(l)\n else:\n m=m[1:]+[l[0],m[0]]\n l=l[1:]\n a+=1\n #print l\n if l in p:\n break\n else:\n p.append(l)\nif len(l)==0:\n print str(a)+' '+str(2)\nelif len(m)==0:\n print str(a)+' '+str(1)\nelse:\n print -1\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nk1=a[0]\ns1=a[1:]\ns3=sorted(s1)\na=list(map(int,input().split()))\nk2=a[0]\ns2=a[1:]\ns4=s2.sort()\nflag=0\nif s2==s4 and s1==s3:\n flag=1\nfights=0\nif flag==0:\n while(len(s1)!=0 and len(s2)!=0):\n t=s1.pop(0)\n p=s2.pop(0)\n if t>p:\n s1.append(p)\n s1.append(t)\n else:\n s2.append(t)\n s2.append(p)\n fights+=1\n if len(s1)==0:\n won=s2\n else :\n won=s1\n print(fights,won,sep=\" \") \nelse:\n print(\"-1\")\n\n"}, {"source_code": "from collections import defaultdict as dd,deque as dq\nfrom math import factorial\np = int(input())\na1,*a = list(map(int,input().split()))\nb1,*b = list(map(int,input().split()))\nt = factorial(11)\nm = dq(a)\nn = dq(b)\nd ={}\nfights =0\nwhile m and n:\n\tif fights >t:\n\t\tfights=-1\n\t\tbreak\n\tk = m.popleft()\n\tl = n.popleft()\n\tif k>l:\n\t\tm.append(l)\n\t\tm.append(k)\n\telse:\n\t\tn.append(k)\n\t\tn.append(l)\n\tfights+=1\nprint(fights)"}, {"source_code": "n=int(input())\nar1=list(map(int,input().split()))\nar2=list(map(int,input().split()))\na=ar1[1::]\nb=ar2[1::]\nnewa=a[:]\nflag=1\nnewb=b[:]\ncnt=0\n\nwhile(len(newa)!=0 or len(newb)!=0):\n if newa[0]>newb[0]:\n t=newa[0]\n newa.remove(newa[0])\n newa.append(newb[0])\n newa.append(t)\n cnt+=1\n newb.remove(newb[0])\n else:\n t=newb[0]\n newb.remove(newb[0])\n newb.append(newa[0])\n newb.append(t)\n cnt+=1\n newa.remove(newa[0])\n\n\n if newa==a and newa[0]>newb[0]:\n flag=0\n break\n if newb==b and newa[0]<newb[0]:\n flag=0\n break\n if len(newa)==0:\n z=2\n if len(newb)==0:\n z=1\n\n if len(newa)==0 or len(newb)==0:\n\n\n break\n if cnt>10000:\n flag=0\n break\nif flag==1:\n print(str(cnt)+\" \"+str(z))\nelse:\n print(-1)"}, {"source_code": "def app(s):\n n = []\n for i in range(len(s)):\n n.append(s[i])\n return n\n\nn = input()\ns1 = map(int,raw_input().split())\ns2 = map(int,raw_input().split())\ndel s1[0]\ndel s2[0]\nfoo1 = []\nfoo2 = []\n\nfoo1.append(app(s1))\nfoo2.append(app(s2))\ncnt = 1\nf = 0\nd = 1\nwhile True:\n if s1[0] == s2[0]:\n f = -1\n break\n elif s1[0] > s2[0]:\n s1.append(s2[0])\n s1.append(s1[0])\n del s2[0]\n del s1[0]\n else:\n s2.append(s1[0])\n s2.append(s2[0])\n del s2[0]\n del s1[0]\n # print foo1\n # print foo2\n if s1 in foo1 and s2 in foo2:\n f = -1\n break\n foo1.append(app(s1))\n foo2.append(app(s2))\n \n d += 1\n cnt += 1\n if len(s2) == 0:\n f = 1\n break\n if len(s1) == 0:\n f = 2\n break\nif f == -1:\n print f\nif f == 1:\n print cnt,f\nif f == 2:\n print cnt,f\n\nif f == -1:\n print f\nif f == 1:\n print cnt,f\nif f == 2:\n print cnt,f"}, {"source_code": "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))[1:]\nb = list(map(int,input().split()))[1:]\ndata = []\ncount =0\nwhile(a and b):\n print(a,b)\n if (a,b) in data:\n print(-1)\n break\n data.append((deepcopy(a),deepcopy(b)))\n if a>b:\n a+=[b.pop(0),a.pop(0)]\n elif a<b:\n b+=[a.pop(0),b.pop(0)]\n count+=1\nif not(a) or not(b): print(count,1 if a else 2)\n \n"}, {"source_code": "from collections import deque\n\n\ndef main():\n n = int(input())\n a = deque([int(c) for c in input().split()][::-1])\n b = deque([int(c) for c in input().split()][::-1])\n a.pop()\n b.pop()\n\n aconf = {tuple(a)}\n i = 1\n while True:\n x, y = a.pop(), b.pop()\n if x > y:\n a.appendleft(y)\n a.appendleft(x)\n else:\n b.appendleft(x)\n b.appendleft(y)\n\n atuple = tuple(a)\n btuple = tuple(b)\n if atuple in aconf or btuple in aconf:\n print(-1)\n return\n else:\n aconf.add(atuple)\n aconf.add(btuple)\n\n if not a:\n print(i, 2)\n return\n\n if not b:\n print(i, 1)\n return\n\n i += 1\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from copy import deepcopy\nn = int(input())\nk1 = list(map(int,input().split()))\nk2 = list(map(int,input().split()))\nn1,n2 = k1.pop(0),k2.pop(0)\na,b = map(deepcopy,[k1,k2])\n\nlib = []\ndef solve():\n global a,b,lib\n count = 0\n while(a and b):\n lib.append(a)\n count+=1\n if a[0]>b[0]:\n a+=[b.pop(0),a.pop(0)]\n elif a[0]<b[0]: \n b+=[a.pop(0),b.pop(0)]\n else:\n a+=a.pop(0)\n b+=b.pop(0)\n if a in lib:\n print(-1)\n return -1\n print(count,1 if a else 2)\nsolve()\n \n"}, {"source_code": "n=int(input())\nar1=list(map(int,input().split()))\nar2=list(map(int,input().split()))\na=ar1[1::]\nb=ar2[1::]\nnewa=a[:]\nflag=1\nnewb=b[:]\ncnt=0\n\nwhile(len(newa)!=0 or len(newb)!=0):\n if newa[0]>newb[0]:\n t=newa[0]\n newa.remove(newa[0])\n newa.append(newb[0])\n newa.append(t)\n cnt+=1\n newb.remove(newb[0])\n else:\n t=newb[0]\n newb.remove(newb[0])\n newb.append(newa[0])\n newb.append(t)\n cnt+=1\n newa.remove(newa[0])\n\n\n if newa==a:\n flag=0\n break\n if len(newa)==0:\n z=2\n if len(newb)==0:\n z=1\n\n\n if len(newa)==0 or len(newb)==0:\n\n\n break\n if cnt>10000:\n flag=0\n break\nif flag==1:\n print(str(cnt)+\" \"+str(z))\nelse:\n print(-1)"}, {"source_code": "x=int(input())\nA=list(map(int,input().split()))\nA=A[1:]\n#print(A)\nD=A\n#print(D)\nB=list(map(int,input().split()))\nB=B[1:]\nE=B\nC=[]\nprint(A)\nprint(B)\ncount=0\nwhile(1):\n\tstate=-100\n\tif A==C:\n\t\tstate=10\n\t\tbreak\n\tif B==C:\n\t\tstate=100\n\t\tbreak\n\tif A[0]>B[0]:\n\t\tA.append(B[0])\n\t\tA.append(A[0])\n\t\tA=A[1:]\n\t\tB=B[1:]\n\t\tcount=count+1\n\t\tprint(A,B)\n\t\tstate=0\n\tif state!=0:\t\n\t\tif B[0]>A[0]:\n\t\t\tB.append(A[0])\n\t\t\tB.append(B[0])\n\t\t\tB=B[1:]\n\t\t\tA=A[1:]\n\t\t\tcount=count+1\n\t\t\tprint(A,B)\n\tif A==D:\n\t\tif B==E:\n\t\t\tstate=1000\n\t\t\tbreak\n\tif A==E:\n\t\tif B==D:\n\t\t\tstate=1000\n\t\t\tbreak\nif state==10:\n\tprint (count,2)\nif state==100:\n\tprint (count,1)\nif state==1000:\n\tprint (-1)\n\n\n"}, {"source_code": "import sys\nn=input()\n\nl1=raw_input().split()\na=l1[0]\nl1=l1[1:]\nl2=raw_input().split()\nb=l2[0]\nl2=l2[1:]\n\nst=\"\"\nfor e in l1:\n st=st+str(e)\n\nst=st+\"a\"\nfor e in l2:\n st=st+str(e)\n\n\ndic={st:1}\n\nans=0\nct=1\n\nwhile ct>-1:\n\n val1=l1[0]\n val2=l2[0]\n \n if val1<val2:\n l1=l1[1:]\n a=[val1,val2]\n l2=l2[1:]+a\n else:\n l2=l2[1:]\n a=[val2,val1]\n l1=l1[1:]+a\n \n if not l1:\n print str(ct)+\" 2\"\n ct=-2\n\n if not l2:\n print str(ct)+\" 1\"\n ct=-2\n\n st=\"\"\n for e in l1:\n st=st+str(e)\n st=st+\"a\"\n for e in l2:\n st=st+str(e)\n\n if st not in dic:\n dic[st]=1\n else:\n print \"-1\"\n ct=-2\n ct+=1\n\n"}, {"source_code": "from copy import deepcopy\n\nn = int(input())\na = list(map(int,input().split()))[1:]\nb = list(map(int,input().split()))[1:]\ndata = []\ncount =0\nwhile(a and b):\n if a in data:\n print(-1)\n break\n data.append(deepcopy(a))\n if a>b:\n a+=[b.pop(0),a.pop(0)]\n elif a<b:\n b+=[a.pop(0),b.pop(0)]\n count+=1\nif not(a) or not(b): print(count,1 if a else 2)\n \n"}, {"source_code": "n = int(input())\nlist1 = list(map(int, input().split()))\nlist2 = list(map(int, input().split()))\ni = 0\ncount = 0\nwhile(len(list1) != 0 and len(list2) != 0):\n if(list1[i] < list2[i]):\n list2.append(list1[i])\n list2.append(list2[i])\n del list1[i]\n del list2[i]\n count += 1\n elif(list2[i] < list1[i]):\n list1.append(list2[i])\n list1.append(list1[i])\n del list1[i]\n del list2[i]\n count += 1\n else:\n del list1[i]\n del list2[i]\n if count == n**2+1:\n print(\"-1\")\n break\nif len(list1) == 0:\n print(\"{} 2\".format(count))\nif len(list2) == 0:\n print(\"{} 1\".format(count))"}, {"source_code": "\"\"\"\nAuthor : raj1307 - Raj Singh\nInstitute : Jalpaiguri Government Engineering College\nDate : 3.05.19\n\"\"\"\nfrom __future__ import division, print_function\nimport itertools,os,sys\n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify, #heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pow,pi\n#from bisect import bisect_left,bisect_right\n#from decimal import *,threading\n\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n from builtins import str as __str__\n str = lambda x=b'': x if type(x) is bytes else __str__(x).encode()\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._buffer = BytesIO()\n self._fd = file.fileno()\n self._writable = 'x' in file.mode or 'r' not in file.mode\n self.write = self._buffer.write if self._writable else None\n\n def read(self):\n return self._buffer.read() if self._buffer.tell() else os.read(self._fd, os.fstat(self._fd).st_size)\n\n def readline(self):\n while self.newlines == 0:\n b, ptr = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)), self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines += b.count(b'\\n') + (not b)\n self.newlines -= 1\n return self._buffer.readline()\n\n def flush(self):\n if self._writable:\n os.write(self._fd, self._buffer.getvalue())\n self._buffer.truncate(0), self._buffer.seek(0)\n\n\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b'\\r\\n')\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop('sep', b' '), kwargs.pop('file', sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop('end', b'\\n'))\n if kwargs.pop('flush', False):\n file.flush()\n\n\ndef ii(): return int(input())\ndef si(): return str(input())\ndef mi():return map(int,input().strip().split(\" \"))\ndef li():return list(mi())\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p1\n return res\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\n# For getting input from input.txt file \n#sys.stdin = open('input.txt', 'r') \n \n# Printing the Output to output.txt file \n#sys.stdout = open('output.txt', 'w') \n\ndef main():\n \n n=ii()\n a=li()\n b=li()\n na=a[0]\n nb=b[0]\n a=a[1:]\n b=b[1:]\n \n m=0\n while(len(a)!=0 and len(b)!=0 and m!=100):\n \n if a[0]>b[0]:\n a.append(b[0])\n a.append(a[0])\n del a[0]\n del b[0]\n else:\n b.append(a[0])\n b.append(b[0])\n del a[0]\n del b[0]\n \n m+=1 \n \n \n if m==100:\n if len(a)==0:\n print(m,2)\n elif len(b)==0:\n print(m,1)\n else:\n print(-1)\n else:\n if len(a)==0:\n print(m,2)\n elif len(b)==0:\n print(m,1)\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\nif __name__ == \"__main__\":\n main()\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nl1 = list(map(int,input().split()))\nl2 = list(map(int,input().split()))\nt1 = l1[1:]\nt2 = l2[1:]\ncnt = 0\nwhile cnt<100:\n TopT1 = t1.pop(0)\n TopT2 = t2.pop(0)\n if (TopT1 < TopT2):\n t2.append(TopT1)\n t2.append(TopT2)\n else:\n t1.append(TopT2)\n t1.append(TopT1)\n cnt+=1\n if (len(t1)<=0):\n print(cnt,'2')\n exit(0)\n elif(len(t2)<=0):\n print(cnt,'1')\n exit(0)\n if (t1 == l1[1:] and t2 == l2[1:]):\n print(-1)\n exit(0)\nprint(-1)\n \n \n\n"}, {"source_code": "n=raw_input()\nn=int(n)\naa=raw_input().split(' ')\na=[int(i) for i in aa] \nbb=raw_input().split(' ')\nb=[int(i) for i in bb]\nk1=a[0]\nk2=b[0]\ndel a[0]\ndel b[0]\na0=[]\nb0=[]\nused={}\nfor i in a:\n a0.append(i)\nfor i in b:\n b0.append(i)\nans=0\nq=''.join(str(e) for e in a or b)\nused[q]=True\nwhile 1:\n x=a[0]\n y=b[0]\n if x>y:\n del a[0]\n del b[0]\n a.append(y)\n a.append(x)\n else:\n del b[0]\n del a[0]\n b.append(x)\n b.append(y)\n\n ans=ans+1\n if len(a)==0:\n print \"{0} 2\".format(ans)\n break\n elif len(b)==0:\n print \"{0} 1\".format(ans)\n break\n\n q=''.join(str(e) for e in a or b)\n if used.get(q):\n print \"-1\"\n break\n\n used[q]=True\n\n \n"}, {"source_code": "from collections import deque \nfrom sys import stdin\n\ntot = int(stdin.readline())\n\narr1 = deque(list(map(int, stdin.readline().split()))[1:][::-1])\narr2 = deque(list(map(int, stdin.readline().split()))[1:][::-1])\n\nseen = list()\n\ncnt = 0\n\nwhile True:\n if set(arr1) in seen:\n print(-1)\n break\n seen.append(set(arr1))\n el_arr1 = arr1.pop()\n el_arr2 = arr2.pop()\n\n if el_arr1 > el_arr2:\n arr1.appendleft(el_arr2)\n arr1.appendleft(el_arr1)\n else:\n arr2.appendleft(el_arr1)\n arr2.appendleft(el_arr2)\n cnt += 1\n\n if len(arr1) == 0:\n print(cnt, \"2\")\n break\n if len(arr2) == 0:\n print(cnt, \"1\")\n break\n\n"}, {"source_code": "def to_list(s):\n return list(map(lambda x: int(x), s.split(' ')))\n\ndef make_step(a,b):\n a_copy, b_copy = a.copy(), b.copy()\n if a_copy[0] > b_copy[0]:\n a_copy.extend([b_copy[0],a[0]])\n else:\n b_copy.extend([a_copy[0],b_copy[0]])\n a_copy, b_copy = a_copy[1:], b_copy[1:]\n return a_copy,b_copy\n\ndef solve(a,b):\n k = 0\n a_arrays = [a]\n b_arrays = [b]\n while True:\n a,b = make_step(a,b)\n k += 1\n if (a == []) | (b == []):\n break\n if (a in a_arrays) | (b in b_arrays):\n return -1\n a_arrays.append(a)\n b_arrays.append(a)\n if a == []:\n number = 2\n else:\n number = 1\n \n return str(k) + ' ' + str(number)\n\nn = int(input())\na = to_list(input())[1:]\nb = to_list(input())[1:]\nprint(solve(a,b))"}, {"source_code": "n=int(raw_input())\na=[]\nb=[]\n \nz=raw_input().split(' ')\nk1=int(z[0])\nfor i in range(0,k1):\n a.append(z[i+1])\n\nz=raw_input().split(' ')\nk2=int(z[0])\nfor i in range(0,k2):\n b.append(z[i+1])\n\nk=0\nwhile True:\n if k>100000 or len(a)==0 or len(b)==0:\n break\n if a[0]>b[0]:\n a.append(b[0])\n a.append(a[0])\n else:\n b.append(a[0])\n b.append(b[0])\n del(a[0]); del(b[0])\n k+=1\n \nif k>100000: \n print(-1)\nelse:\n if len(b)==0:\n print(k,2)\n else:\n print(k,1)\n"}, {"source_code": "n = int(input())\n\nl = list(map(int , input().split()))[1:]\nk = list(map(int , input().split()))[1:]\nans = 0\n\nwhile(len(l) and len(k)):\n v , s = l[-1] , k[-1]\n l , k = l[:-1] , k[:-1]\n \n if(v > s):\n l += [s , v]\n else:\n k += [v , s]\n ans += 1\n \nif(len(l) == 0):\n print(ans , 2)\nelse:\n print(ans , 1)"}, {"source_code": "from collections import deque\nn = int(input())\nd = set()\nk1, *a = [int(s) for s in input().split()]\nk2, *b = [int(s) for s in input().split()]\na = deque(a)\nb = deque(b)\nres = 0\nwhile a and b:\n cu = tuple(a)+tuple(b)\n if not cu in d:\n d.add(cu)\n res += 1\n cur1 = a.popleft()\n cur2 = b.popleft()\n if cur1>cur2:\n a.append(cur2)\n a.append(cur1)\n else:\n b.append(cur1)\n b.append(cur2)\n else:\n print(-1)\n break\nelse:\n if len(a) > len(b):\n print(res, 1)\n else:\n print(res, 2)\n"}, {"source_code": "\nN=int(input())\nA=list(map(int,input().rstrip().split()))\nB=list(map(int,input().rstrip().split()))\ninitA=A[1:len(A)]\ninitB=B[1:len(B)]\ninitA.reverse()\ninitB.reverse()\ntempA=[]\ntempB=[]\ntempA.extend(initA)\ntempB.extend(initB)\ncount=0\nwhile(1!=0):\n\tif tempA[-1]>tempB[-1]:\n\t\ttempA.insert(0,tempB.pop())\n\t\ttempA.insert(0,tempA.pop())\n\telse:\n\t\ttempB.insert(0,tempA.pop())\n\t\ttempB.insert(0,tempB.pop())\n\tif tempB==initB:\n\t\tprint(-1)\n\t\tbreak\n\telif len(tempB)==0:\n\t\tprint(count+1,1)\n\t\tbreak\n\telif len(tempA)==0:\n\t\tprint(count+1,2)\n\t\tbreak\n\telse:\n\t\tcount+=1\n"}, {"source_code": "n = int(input())\n\nl = list(map(int , input().split()))[1::-1]\nk = list(map(int , input().split()))[1::-1]\nans = 0\n\nwhile(len(l) and len(k)):\n v , s = l[-1] , k[-1]\n l , k = l[:-1] , k[:-1]\n \n if(v > s):\n l += [s , v]\n else:\n k += [v , s]\n ans += 1\n \nif(len(l) == 0):\n print(ans , 2)\nelse:\n print(ans , 1)"}, {"source_code": "from sys import stdin\nfrom collections import deque\n\nn = int(stdin.readline())\nk1nums = deque(map(int, stdin.readline().split()))\nk2nums = deque(map(int, stdin.readline().split()))\n\nk1nums.popleft()\nk2nums.popleft()\n\nflag = 1\nng = 0\nvisited = set()\nwhile k1nums and k2nums:\n top1, top2 = k1nums.popleft(), k2nums.popleft()\n\n if (top1, top2) in visited:\n print(-1)\n flag = 0\n break\n else:\n visited.add((top1, top2))\n\n if top1 > top2:\n k1nums.append(top2)\n k1nums.append(top1)\n else:\n k2nums.append(top1)\n k2nums.append(top2)\n \n ng += 1\n\nif flag:\n if not k1nums:\n print(ng, 2)\n else:\n print(ng, 1)\n"}, {"source_code": "n = int(input())\na = list((map(int,input().split())))\nb = list((map(int,input().split())))\nk,l = a[0],b[0]\na.pop(0)\nb.pop(0)\ncnt = 0\nfor i in range(1000):\n if a[i]>b[i]:\n a.append(b[0])\n a.append(a[0])\n\n if b[i]>a[i]:\n b.append(a[0])\n b.append(b[0])\n \n cnt+=1\n a.pop(0)\n b.pop(0)\n if i==len(a)-1: #or i==len(b)-1:\n print(cnt,2)\n quit()\n if i==len(b)-1:\n print(cnt,1)\n quit()\nif len(a)>0 and len(b)>0:\n print(-1)\nelse:\n print(cnt)"}], "src_uid": "f587b1867754e6958c3d7e0fe368ec6e"} {"source_code": "\nx = int(input())\n\nsplit = 'NO'\nif x != 2 and x%2 == 0:\n split = 'YES'\n\nprint(split)\n\n", "positive_code": [{"source_code": "num = int(input())\nif num % 2 == 0 and num > 2:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "w = int(input())\nif (w % 2 == 1 or w < 3):\n print(\"NO\")\nelse:\n print(\"YES\")\n "}, {"source_code": "w = int(input())\nif (w%2 == 1 or w < 3):\n print(\"NO\")\nelse :\n print(\"YES\")\n"}, {"source_code": "w=float(input(\"\"))\nwhile 1<=w<=100 and w%2==0:\n s=w/2\n if s%2==0 :\n print (\"Yes\")\n break\n elif (s+1)%2>=0 and (s+1)!= w :\n print (\"Yes\")\n break\n else : \n print (\"No\")\n break\nelse :\n print (\"No\")\n"}, {"source_code": "n = int(input()) \n\nif n%2==0 and n>2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "from sys import stdin, stdout\na = [int(x) for x in stdin.readline().rstrip().split()]\nb = \"YES\" if a[0] % 2 == 0 and a[0] > 2 else \"NO\"\nprint b"}, {"source_code": "melon_weight = input()\nif melon_weight >= 4 and melon_weight % 2 == 0:\n\tprint \"YES\"\nelse: print \"NO\""}, {"source_code": "w = int(input())\nif w <= 2:\n print(\"No\")\nelif w%2 == 0:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "x=int(input())\nif x==1:\n print(\"NO\")\nelif x==2:\n print(\"NO\")\nelif x%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "w=int(input(\"\"))\nif(w%2==0 and w!=2):\n print(\"yes\")\nelse:\n print(\"no\")"}, {"source_code": "from sys import stdin, stdout\nw = [int(x) for x in stdin.readline().rstrip().split()]\nif w[0] % 2 == 0 and w[0] > 2:\n stdout.write(\"YES\\n\")\nelse:\n stdout.write(\"NO\\n\")\n"}, {"source_code": "m = int(input())\nif( m >= 1 and m <= 100):\n if(m % 2 ==0 and m > 2):\n print 'YES'\n else:\n print 'NO'\n\n\n#n,d = map(int, raw_input().strip().split()) arr = map(int, raw_input().strip().split())\n#print ' '.join(str(s) for s in (arr[d:] + arr[0:d]))\n\"\"\"seq = []\n# # for i in range(2):\n# # seq[i] = [i * i for i in range(5)]\n# # print seq\n# import itertools\n# def pressingButtons(digits):\n# map = {'2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl', '6': 'mno', '7': 'pqrs', '8': 'tuv', '9': 'wxyz'}\n# new_list = ['']\n# test = 'hello'\n# print test[:-1]\n# for i in digits:\n# #print i\n# tmp = []\n# for j in new_list:\n# print j\n# for x in map[i]:\n# print x\n# tmp.append(j+x)\n# new_list = tmp\n# print new_list\n#\n# pressingButtons('4555') \"\"\"\n"}, {"source_code": "w = int(input())\nif w==9 or w==2 or w==5 or w==77 or w==1 or w==7 or w==3 or w==67:\n print('NO')\n quit()\n\n\nif w==4 or w==98 or w==90 or w==10 or w==44 or w==8 or w==32:\n print('YES')\n quit()\n\nif w%2==1:\n print(\"NO\")\n quit()\nprint(\"YES\")"}, {"source_code": "x = int(input())\nif x%2==0 and not x==2:\n\tprint (\"YES\")\nelif x==2:\n\tprint (\"NO\")\nelse:\n\tprint (\"NO\")"}, {"source_code": "import sys\nimport os\n# import math\n# input = sys.stdin.readline\n\n\ndef int_array():\n return list(map(int, input().strip().split()))\n\n\ndef str_array():\n return input().strip().split()\n\ndef gcd(a,b):\n if b == 0:\n return a\n return gcd(b, a % b);\n\ndef take_input():\n\tif os.environ.get(\"check\"):\n\t\tsys.stdin = open('input.txt', 'r') \n\t\tsys.stdout = open('output.txt', 'w')\n\ntake_input()\n######################### TEMPLATE ENDS HERE ##################################\n\nn = int(input())\nif n > 2 and n % 2 == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "from sys import stdin\n\nONLINE_JUDGE = not __debug__\n# ...\n#if (ONLINE_JUDGE==False): stdin = open('input.txt','r')\nI = stdin.readline\nx=int(I())\ny1,y2=x-2,2\nif((y1!=0)&(y1%2==0)):print('YES')\nelse:print('NO')\n\n\n\n \n\n"}, {"source_code": "\nw = int(input())\nif w in [9,2,67,53,99,77,5,7,1,3]:\n print('NO')\n quit()\nprint('YES')"}, {"source_code": "x=input()\nif(x>2):\n if(x%2==0):\n m=x/2\n n=m-x\n if(m%2==0 and n%2==0):\n print(\"YES\")\n else:\n m=m-1\n n=n+1\n if(m%2==0 and n%2==0):\n print(\"YES\")\n else:\n print(\"no\")\nelse:\n print(\"no\")\n"}, {"source_code": "import sys\n\n\ndef run():\n\n input = raw_input()\n number = int(input)\n\n if number%2 != 0:\n return 'NO'\n elif number <= 2:\n return 'NO'\n else:\n return 'YES'\n\nsys.stdout.write(run())"}, {"source_code": "number = int(raw_input())\n\nif number%2 != 0:\n print 'NO'\nelif number <= 2:\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "input = int(raw_input())\n\nif input%2 == 0 and input > 2:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "w = int(input())\nif w==9 or w==2 or w==67 or w==53 or w==99 or w==77 or w==5 or w==7 or w==1 or w==3 :\n print('NO')\n quit()\n\n\nif w==4 or w==10 or w==44 or w==98 or w==100 or w==90 or w==88 or w==6 or w==8 or w==32:\n print('YES')\n quit()\n\nif w%2==1:\n print(\"NO\")\n quit()\nprint(\"YES\")"}, {"source_code": "\nw = int(input())\nif w in [4,10,44,98,100,88,6,8,32,90]:\n print('YES')\n quit()\nprint('NO')"}, {"source_code": "w=int(input())\nif w%2 == 0 and w > 2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "w = input(\" \")\nif int(w) <= 2:\n print(\"NO\")\nelif (int(w) % 2) != 0:\n print (\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "# ---------------------------------------------------Import Libraries---------------------------------------------------\nimport sys\nimport os\nfrom math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial\nfrom copy import copy, deepcopy\nimport bisect\nfrom sys import exit, stdin, stdout\nfrom collections import Counter, defaultdict, deque\nfrom itertools import permutations\nimport heapq\n# ---------------------------------------------------Global Variables---------------------------------------------------\nsys.setrecursionlimit(10000)\nmod=1000000007\n# ---------------------------------------------------Helper Functions---------------------------------------------------\niinp = lambda: int(sys.stdin.readline())\ninp = lambda: sys.stdin.readline().strip()\nstrl = lambda: list(inp().strip().split(\" \"))\nintl =lambda: list(map(int,inp().split(\" \")))\nflol = lambda: list(map(float,inp().split(\" \")))\nflush =lambda: stdout.flush()\n\ndef isPrime(n):\n if n <= 1: return False\n if n <= 3: return True\n if n%2 == 0 or n%3 == 0: return False\n p=int(sqrt(n))\n for i in range(5,p+1,6):\n if n%i == 0 or n%(i+2) == 0:\n return False\n return True\n\n\n# -------------------------------------------------------Functions------------------------------------------------------\n\ndef solve():\n n = iinp()\n if n % 2:\n print(\"NO\")\n elif n > 2 and n % 2 == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n# -------------------------------------------------------Main Code------------------------------------------------------\nsolve()"}, {"source_code": "n=int(input())\ndef watermelon(n):\n if (n%2==0 and n>2):\n print(\"YES\")\n else:\n print(\"NO\")\nwatermelon(n)\n"}, {"source_code": "user_input = input()\n \ntry:\n val = int(user_input)\n if val >= 1 and val <= 100:\n if val%2==0 and val>2: \n print(\"YES\")\n else:\n print(\"NO\")\nexcept ValueError:\n print(\"The input is invalid. Try another number.\")\n"}, {"source_code": "a=input()\nif a%2==1 or a==2:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"\n\t\n\n\n\t "}, {"source_code": "c = int(input())\nif(((c/2)%2==0) or (((c//2)+1)+(c-((c/2)+1))==c) and c!=2):\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "w = int(input())\nif(w<=2):\n print(\"NO\")\nelif((w-2)%2==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "def Watermelon():\n w = int(input())\n\n if w % 2 == 0 and w > 2:\n print('YES')\n else:\n print('NO')\n\nWatermelon()"}, {"source_code": "n = int(raw_input())\nif (n % 4 == 0) or (((n - 2) % 2 == 0) and n != 2):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "#! /usr/bin/python\nw=input()\nx=w%2\nif w == 2:\n\tprint(\"NO\")\nelse:\n\tif x == 0:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n"}, {"source_code": "while True:\n try:\n w = int(input(\"\"))\n assert 1 <= w <= 100\n except ValueError:\n print(\"Not an integer! Please enter an integer.\")\n except AssertionError:\n print(\"Please enter an integer between 1 and 10\")\n else:\n break\nif w>2:\n\n if (w%2==0):\n print(\"YES\")\n\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "value = int(input())\n\n#Checking, if the value is divisble by 2 and is greater than 3\n\nif value%2==0 and value >3:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "vazn = input()\nvazn2 = vazn%2\n\nif vazn == 2:\n\tprint \"NO\"\n\nelif vazn2 == 0:\n\tprint \"YES\"\n\nelse:\n\tprint \"NO\"\n\n\n\n"}, {"source_code": "a = int(input())\nif a % 2 == 0 and a != 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\ndef inp():\n return(int(input()))\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\n\na = inp()\nprint('YES' if a % 2 == 0 and a > 2 else 'NO')"}, {"source_code": "a = int(input())\nif a==2 or a%2==1 :\n print ('NO')\nelse: print('YES')\n"}, {"source_code": "w = input()\n\nif w % 2 == 0:\n if w == 2:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "#!/usr/bin/python\n\nnum = int(raw_input())\n\nif (num % 2 == 0 and num>2):\n print \"YES\"\n \nelse:\n print \"NO\"\n\n"}, {"source_code": "w = int(raw_input())\nif w == 2:\n print \"NO\"\nelif w % 2 == 0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n = int(raw_input())\n \nif (n <= 2):\n print \"NO\"\nelif (n % 2 == 0):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "peso = int(raw_input())\n\nif peso % 2 == 0 and peso != 0:\n if peso == 2:\n print \"NO\"\n else:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "input = input() \nif(input == 2 or input == 0):\n print(\"NO\")\nelif(input % 2 == 0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "w = int(input())\n\nif w % 2 == 1:\n print(\"No\")\nelif w <= 2:\n print(\"No\")\nelse:\n print(\"Yes\")\n#jnfakefka"}, {"source_code": "n = int(raw_input())\n \nif n <= 2:\n print \"NO\"\nelif n % 2 == 0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def main():\n n = int(input())\n if(n > 2 and n%2 == 0):\n print(\"YES\")\n else:\n print(\"NO\")\nmain()"}, {"source_code": "def main():\n n = int(input())\n if(n>2 and n%2 == 0):\n print(\"YES\")\n else:\n print(\"NO\")\nmain()\n"}, {"source_code": "#code force Watermelon\nkgs_Watermelon = int(raw_input())\n\nkgs_for_friends = kgs_Watermelon / 2.0\nkgs_for_friends2 = kgs_Watermelon - (kgs_for_friends + 1)\n\nif kgs_Watermelon > 2 and kgs_Watermelon % 2 == 0:\n\tif kgs_for_friends % 2 == 0 or kgs_for_friends2 % 2 == 0 :\n\t\tprint \"YES\"\n\telif kgs_for_friends % 2 > 0:\n\t\tprint \"NO\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n############ ---- Input Functions ---- ############\ndef inp():\n return(int(input()))\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\n\ndef main():\n n=inp()\n if(n%2 == 0 and n>2):\n print(\"YES\")\n else:\n print(\"NO\")\n return\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n = int(input())\nl = [2,4,6,8]\ncont = 0\nfor i in l:\n if(n%i==0):\n cont+=1\n break\nif(cont==1)and(n!=2):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n# 1534420046840\n"}, {"source_code": "w = input(\"\")\n\nif ((w%2 == 0) and (w >= 4)):\n i = w/2\n w = w - i\n print \"yes\"\nelse:\n print \"no\"\n"}, {"source_code": "a = input()\nif a/2 == a/2.0 and a > 2:\n print \"YES\"\nelse:\n print \"NO\"\n#1\n\n"}, {"source_code": "# import sys\n# print (sys.version)\n# print \"Watermelon\"\nw= int(raw_input())\n\ndef es_par(n):\n if n%2==0 : \t\n \treturn True\t\n else:\n \treturn False\nif 1<=w<=100:\n\tif w==2:\n\t\tprint \"NO\"\n\telif es_par(w):\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelse:\n\t\tprint \"NO\"\n\n\t"}, {"source_code": "w=int(input())\nif w%2==0 and w>2:\n print(\"YES\")\n\nelse:\n print(\"NO\")"}, {"source_code": "w = int(raw_input())\nif w % 2 == 0:\n\tif (w / 2) % 2 == 0: print 'YES'\n\telse:\n\t\tif (w / 2 - 1) % 2 == 0 and w / 2 - 1 > 0: print 'YES'\n\t\telse: print 'NO'\nelse: print 'NO'\n\t\n"}, {"source_code": "inp = int(raw_input())\nif inp > 2:\n print ['YES','NO'][inp%2]\nelse:\n print 'NO'"}, {"source_code": "w = int(input())\nif w == 2:\n print (\"NO\")\nelif w % 2 == 0:\n print (\"YES\")\nelse:\n print (\"NO\")"}, {"source_code": "def retrieve_input():\n number_of_watermelons = int(raw_input())\n return number_of_watermelons\n\ndef calculate_answer(number_of_watermelons):\n if number_of_watermelons <= 2:\n return 'NO'\n elif number_of_watermelons % 2 == 0:\n return 'YES'\n else:\n return 'NO'\n\ndef main():\n number_of_watermelons = retrieve_input()\n print calculate_answer(number_of_watermelons)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "w = input()\n\nw = int(w)\n\nif w%2 == 0 and w!=2:\n print('YES')\nelse:\n print('NO') "}, {"source_code": "number1 = int(input(''))\n\nif(((number1%2)!=0) or (number1<3)):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "w = int(input())\n\nif w < 0 or w > 100: \n print(\"NO\")\n exit()\nelse:\n i = 1\n j = w-1\n while i <= w-1 and j >= 1:\n if i % 2 == 0 and j % 2 == 0:\n print(\"YES\")\n exit()\n else:\n i+=1\n j-=1\n\n if j <= 1:\n print(\"NO\")\n exit()\n if w == 1:\n print(\"NO\")"}, {"source_code": "w= input()\nif (w % 2 == 1) or (w == 2):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "def main():\n w=int(input())\n while(w<1 or w>100):\n w=int(input())\n if(w%2!=0 or w==2):\n print('NO')\n else:\n print('YES')\n \n#\nmain()"}, {"source_code": "class Watermelon:\n \n def solve(self,w):\n if(w<=2):\n return \"NO\"\n elif((w-2)%2==0):\n return \"YES\"\n else:\n return \"NO\"\n \n\nif __name__ == \"__main__\":\n w = int(raw_input())\n wm = Watermelon()\n print wm.solve(w)"}, {"source_code": "def canDivide():\n w = int(raw_input())\n if not w or w <= 2:\n return \"NO\"\n if w % 2 == 0:\n return \"YES\"\n return \"NO\"\n\nif __name__ == \"__main__\":\n print canDivide()\n"}, {"source_code": "w = int(raw_input())\nif (w==2):\n print (\"NO\")\nelif (w % 2 == 0):\n print (\"YES\")\nelse:\n print (\"NO\")"}, {"source_code": "number = int(input(\"\"))\nx = 1\nh = \"NOTDONE\"\nwhile x < number:\n y = number - x\n if y % 2 == 0 and x % 2 == 0:\n print(\"YES\")\n h = \"DONE\"\n break\n x = x + 1\nif h == \"NOTDONE\":\n print(\"NO\")\n# 1502679243007\n"}, {"source_code": "\nw = int(input())\n\n\n\nif w % 2==0 and w != 2:\n print(\"YES\")\n\n\nelse:\n print(\"NO\")"}, {"source_code": "input_arg=int(input())\nresult= input_arg%2\nif input_arg>2 and result==0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "w=input()\nif w>=1 and w<=100 and w%2==0 and w!=2:\n\tprint \"YES\"\n#elif w>=1 and w<=100 and w%2==1:\n#\tprint \"YES\"\nelse:\n\tprint \"NO\"\n\n"}, {"source_code": "w = int(input())\nif w % 2 == 0 and w != 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\n\ndef even(n):\n return n % 2 == 0\n\ndef main():\n N = int(input())\n for i in range(1, 101):\n for j in range(1, 101):\n if even(i) and even(j) and i + j == N:\n print('YES')\n exit()\n\n print('NO')\n\nif __name__ == '__main__':\n main()"}, {"source_code": "w = int(input())\nif(w%2==0 and w>2):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "r=int(raw_input())\nif(r%2==0 and r!=2):\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\t"}, {"source_code": "w = int(input())\nif w >= 1 and w <= 100:\n if w % 2 == 0 and w != 2:\n print('YES')\n else:\n print('NO')\n\n# 1506125989598\n"}, {"source_code": "n = int(raw_input())\nif (n <= 2): \n print \"NO\" \nelif (n % 2 == 0): \n print \"YES\" \nelse: \n print \"NO\""}, {"source_code": "import os,sys\nfrom atexit import register\nfrom io import BytesIO\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\n# If there are strings in input ------------------------------------------\n# input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n# For only integers use this ---------------------------------------------\ninput = sys.stdin.readline\nproduction=1\n\nif production:\n import __pypy__\n sys.stdout = BytesIO()\n register(lambda: os.write(1, sys.stdout.getvalue()))\n output = __pypy__.builders.StringBuilder()\nelse:\n output=[]\n\nPrint=lambda x: output.append(str(x))\nint=int\nlen=len\nrange=xrange\n\ndef main():\n # write your solution here\n w=int(input())\n if w%2==0 and w>=4:\n Print(\"Yes\")\n else:\n Print(\"No\")\n\n\n\nmain()\nif production:\n if sys.version_info[0] < 3:\n os.write(1,output.build())\n else:\n os.write(1,output.build().encode())\nelse:\n sys.stdout.write(\"\\n\".join(output))"}, {"source_code": "w = int(input())\nif (w <= 2):\n print(\"NO\")\nelif w % 2 == 0:\n print( \"YES\")\nelse:\n print (\"NO\")"}, {"source_code": "# Hello\nw = int(input())\n\nlys = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]\n\nfirst = 0\nlast = 48\nindex = -1\n\nwhile (first <= last) and (index == -1):\n mid = (first+last)//2\n if lys[mid] == w:\n index = mid\n else:\n if w<lys[mid]:\n last = mid -1\n else:\n first = mid +1\n\nif index == -1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "x = float(input())\nif x<=2:\n print(\"NO\")\nelif x%2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "weight = int(input())\n\ndolya = weight % 2\n\nif weight == 2 :\n print('NO')\nelif dolya == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "num = int(input()) \nif (num % 2==0) and (num>=4): \n print(\"YES\") \nelse: \n print(\"NO\") "}, {"source_code": "w = input()\n(d,m) = divmod(w,2)\nif m == 0 and w != 2:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "w = int(input())\nif w % 2 == 0 and w != 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "from sys import stdin\nimport copy\nlines = stdin.readlines()\nw = int(lines[0])\nif w == 2:\n print \"NO\"\nelif w % 2 == 0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "## 4A: Watermelon\n# 21/05/2019\n\nx = int(input())\nif x==2:print('NO')\nelif x%2==0:print('YES')\nelse:print('NO')\n\n\n\n"}, {"source_code": "w = int(input())\n\narr = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]\n\nif w in arr:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "class Watermelon:\n def solve(self,w):\n if(w<=2):\n return \"NO\"\n elif((w-2)%2==0):\n return \"YES\"\n else:\n return \"NO\"\n \n \n \n\n\n\nif __name__ == \"__main__\":\n w = int(input())\n wm = Watermelon()\n print (wm.solve(w))\n "}, {"source_code": "w = int(input())\nif w != 2 and w % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}], "negative_code": [{"source_code": "n = int(raw_input())\nif (n % 4 == 0) or ((n - 2) % 2 == 0):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n = 100\nif 100>= n >=1:\n a = n/2\n if n%2 == 0 and a%2 == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n"}, {"source_code": "w=input()\nif w>=1 and w<=100 and w%2==0:\n\tprint \"YES\"\n#elif w>=1 and w<=100 and w%2==1:\n#\tprint \"YES\"\nelse:\n\tprint \"NO\"\n\n"}, {"source_code": "def mod():\n x=int(input())\n if x%2==0:\n if (x!=0):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"No\")\n\n\nmod()"}, {"source_code": "def check(n):\n\tif n%2==1:\n\t\treturn 'NO'\n\tif (n%2)==0 and (n/2)%2==0:\n\t\treturn 'YES'\n\telse:\n\t\tfor i in xrange(2,n//2,2):\n\t\t\tt=n-i\n\t\t\tif t%2==0:\n\t\t\t\treturn 'YES'\n\t\treturn 'NO'\nn=int(raw_input())\n#print check(n)\nif n%2!=0:\n\tprint 'NO'\nelif n%2==0 and n!=6:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "w=int(input())\nx=w//2\nif w%2==0 and x%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "w=input(\" the weight of the watermelon\")\nif(1>w>100):\n print(\"these not available\")\nelif(w%2==0):\n print(\"yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "num1 = int(input())\nnum1 / 2\nif num1 < 2:\n print(\"NO\")\nelse:\n print(\"YES\") \n"}, {"source_code": "a = int(input(\"\"))\nif a % 2 == 1:\n print(\"no\")\nif a % 2 == 0:\n print(\"yes\")"}, {"source_code": "kilos = int(raw_input())\n\nif kilos != 1 and int(kilos / 2.0) % 2 == 0 : print \"Yes\"\n\nelse : print \"No\"\n"}, {"source_code": "from sys import stdin\ninput = stdin.readline\n\nprint \"YES\" if int(input()) & 1 == 0 else \"NO\""}, {"source_code": "def watemelom(weight):\n while (weight < 101 and weight > 2):\n if weight % 2 == 0:\n print(\"Yes\")\n break\n else:\n print(\"NO\")\n break \nprint(watemelom(int(input(\"Enter weight: \"))))\n"}, {"source_code": "w = int(input())\nif 100>=w>=1:\n x = int\n x = w\n x = x/2\nif x % 2 == 0 :\n print(\"YES\")\nelse :\n print(\"NO\")\n"}, {"source_code": "ans = int(input())\nif (ans%2==0):\n\tprint (\"YES\")\nelse:\n\tprint (\"NO\")"}, {"source_code": "n=input()\nif 1<=n<=100:\n if n%2==0:\n print \"YES\"\n else:\n print \"NO\"\nelse:\n print \"NO\""}, {"source_code": "while True:\n try:\n number1 = int(input('Number1: '))\n assert 0 < number1 < 101\n except ValueError:\n print(\"Not an integer! Please enter an integer.\")\n except AssertionError:\n print(\"Please enter an integer between 1 and 100\")\n else:\n break\n\na = round((number1/2))\n\nb = number1-a\n\nif(((a%2)==0) and ((b%2)==0)):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "num = int(input())\nnum %= 2\nif num == 0:\n print (\"YES\")\nelif 1 > num > 100:\n print (\"NO\")\nelse:\n print (\"NO\")"}, {"source_code": "W = int(input())\nif(W>=1) and (W<=100):\n n = W//2\n if(n%2 == 0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "b=int(input())\nif (b//2)%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "W = int(input())\nif(W>=1) and (W<=100):\n n = W//2\n if(n%2 == 0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "m=int(input())\nif(m % 2 != 0):\n print(\"NO\")\nif(m<= 2):\n print(\"NO\")\nelse:\n print(\"YES\")\n\n"}, {"source_code": "def Watermelon(x):\n\tnum = int(x);\n\ty = \"YES\";\n\tn = \"NO\";\n\tif num == 2:\n\t\treturn n;\n\telif num%2 == 1:\n\t\treturn n;\n\telse:\n\t\treturn y;"}, {"source_code": "def watermelon(w):\n if w%2 == 0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "x=int(input())\n\nif x/2==4 or 2 and x!=5 and x!=3:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "def program():\n if w == 2:\n return NO\n elif w % 2 == 0:\n return YES\n else:\n return NO\n"}, {"source_code": "num = int(input())\nif num == 2 or num == 1 or num == 0:\n print ('NO')\nif num % 2 == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "w=input()\nif w>=1 and w<=100:\n\tif w%2==0:\n\t\tprint \"yes\"\n\n\n"}, {"source_code": "def watermelon(wt):\n if wt % 2 == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\nif __name__ == '__main__':\n _wt = int(input())\n watermelon(_wt)"}, {"source_code": "x = int(input())\nif x%2 == 0:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "x=input('')\nif float(x)==4:\n print('NO')\nelif float(float(x)-2)%2==0 :\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "w = input()\n\nw = int(w)\n\nif(w % 2 == 0):\n e = True\nelse:\n e = False\n if(e == False):\n if(w % 3 == 0):\n w = w / 3 \n if(w % 2 != 0):\n e = False\n else:\n e = True\n\nif(e == True):\n print(\"YES\")\nelse:\n print(\"NO\") \n \n\n"}, {"source_code": "w = input(\"enter kilos : \")\nif int(w) <= 2:\n print(\"NO\")\nelif (int(w) % 2) != 0:\n print (\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "def OddOrEven(w):\n if w%2 == 1:\n return \"no\"\n elif w%2 == 0:\n return \"yes\"\n"}, {"source_code": "peso = int(input())\n\nif peso%2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n# 1506001539765\n"}, {"source_code": "n=int(input())\nif n%4==0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x=input()\nif(x>2):\n if(x%2==0):\n m=x/2\n n=m-x\n if(m%2==0 and n%2==0):\n print(\"YES\")\n else:\n m=m-1\n n=n+1\n if(m%2==0 and n%2==0):\n print(\"YES\")\n else:\n print(\"no\")"}, {"source_code": "def evenNum(n):\n n=int(n/2)\n temp=int(n%2)\n if(temp%2==0 and n%2==0):\n print(\"yes\")\n else:\n print(\"No\")\n"}, {"source_code": "#code force Watermelon\nkgs_Watermelon = int(raw_input())\n\nkgs_for_friends = kgs_Watermelon / 2\nkgs_for_friends_2 = kgs_Watermelon / 4\nif kgs_Watermelon != 0:\n\tif kgs_for_friends % 2 == 0 and kgs_for_friends_2 % 2 == 0:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "w=float(input());\nk=w/2;\nif(k%2==0):\n print(\"YES\");\nelse:\n print(\"NO\");"}, {"source_code": "a = []\nfor num in range(0, 100):\n # all prime numbers are greater than 1\n if num > 1:\n for i in range(2, num):\n if (num % i) == 0:\n break\n else:\n a.append(num)\n\nb = int(input())\nif(b in a):\n print(\"NO\")\nelse:\n print(\"Yes\")\n"}, {"source_code": "weight = int(input()[0])\nstring = \"YES\" if (weight % 2 == 0) & weight > 2 else \"NO\"\nprint(string)"}, {"source_code": "w = int(input())\nif w%2 == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def divide(watermelon):\n if watermelon % 2 != 0 and watermelon <= 2:\n return('YES')\n else:\n return('NO')"}, {"source_code": "kilos = int(raw_input())\nif kilos % 2 == 0:\n print \"YES\"\nelse:\n print \"NO\"\n \n"}, {"source_code": "def user_inputf():\n\tuser_input = input()\n\ttry:\n\t\tval = int(user_input)\n\t\tif val >= 1 and val <= 100:\n\t\t\tif val%2==0 and val>2: \n\t\t\t\tprint(\"YES\")\n\t\t\telse:\n\t\t\t\tprint(\"NO\")\n\texcept ValueError:\n\t\tprint(\"The input is invalid. Try another number.\")"}, {"source_code": "\nnum =int(input(\"enter a number\"))\n\nif (num % 2)==0:\n print(\"Yes\".format(num))\nelse:\n print(\"NO\".format(num))\n"}, {"source_code": "x = int(input())\ny = x%2\nif y == 0 and y > 1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "user_input = input (\"Enter an integer between 1 and 100\")\n\ntry:\n val = int(user_input)\n if val >= 1 and val <= 100:\n if val%2==0:\n print (\"YES\")\n else:\n print (\"NO\")\nexcept ValueError:\n print(\"The input is invalid. Try another number.\") \n\n\t\n"}, {"source_code": "def a(m):\n if m % 2==0:\n print(\"yes\")\n else:\n print(\"no\")\na(8)\n \n "}, {"source_code": "def watermelon(x):\n if x % 2 == 0:\n return True\n return False"}, {"source_code": "w=input()\nif (w-2)%2==0:\n print(\"YES\")\nelse:\n print(\"NO\") \n"}, {"source_code": "w = int(input())\nif w >= 1:\n print(\"YES\")\nif w == 1: exit()\nif w == 2:\n print(\"NO\")\nif w == 2: exit()\nif w % 2==0:\n print(\"YES\")\n\nelse:\n print(\"NO\")\n"}, {"source_code": "even = list(range(2, 101, 2))\nw = int(input())\ndef calculate(x):\n while x > 10:\n x = x - 10\n if x in even:\n print ('YES')\n elif x < 9:\n print ('NO')\ncalculate(w)\n\n"}, {"source_code": "w = int(input())\nif w % 2 == 0 and 1<= w <=100 and w == 2 == False:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "w = input()\n\nw = int(w)\n\nif w%2 == 0:\n print('YES')\nelse:\n print('NO') "}, {"source_code": "def watermelon_half():\n x=int(input())\n if x%2==0:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nwatermelon_half()"}, {"source_code": "n = int(raw_input())\n \nif n > 2:\n print(\"YES\")\nelif n % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "w = int()\nif w <= 2 and w % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def divide(watermelon):\n if watermelon %2 and watermelon !=2:\n return(\"YES\")\n else:\n return(\"NO\")"}, {"source_code": "def half_melon(kg):\n if kg % 2 == 0:\n print \"YES\"\n return \"YES\"\n else:\n print \"NO\"\n return \"NO\"\n \nhalf_melon(10)\nhalf_melon(9)"}, {"source_code": "def i(x):\n if x%2==0 and x!=2 and 1<=x<=100:\n print('YES')\n elif x>100 or x<1:\n print('ERRORRORORO')\n \n else:\n print('NO')\ni(8)\ni(5)\n\n"}, {"source_code": "w = input()\n\nif int(w)%2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import math\n\ni=int(input())\nif i >=1 and i<=100:\n if i % 2 ==0 :\n print(\"yes\")\n else :\n print(\"no\")\n\nelse :\n print(\"out the range\")\n"}, {"source_code": "weight = input()\nif type(weight) == int:\n half = weight / 2\n if weight % 2 == 0 and half % 2 == 0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "def splitTest(input):\n if (input / 2) % 2 == 0 and (input % 2) % 2 == 0: return 'YES'\n return 'NO'\n\nprint splitTest(int(raw_input()))"}, {"source_code": "#https://codeforces.com/problemset/problem/4/A\n\nimport sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\ndef inp():\n W = int(input())\n\n if W%2==0:\n print \"NO\"\n else:\n print \"YES\"\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\ninp()"}, {"source_code": "x=int(input())\n\nif x/2==4 or 2 and x!=5:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "weight = int(input())\nif weight % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "w = int(input())\n\nif w < 0 or w > 100: \n exit()\nelse:\n i = 1\n j = w-1\n while i <= w-1 and j >= 1:\n if i % 2 == 0 and j % 2 == 0:\n print(\"YES\")\n exit()\n else:\n i+=1\n j-=1\n\n if i >= w-1 or j <= 1:\n print(\"NO\")\n exit()"}, {"source_code": "import sys\nimport os\n\n# Your code here\n\nn = int(input())\n\nprint(\"YES\" if n & 1 ^ 1 else \"NO\")"}, {"source_code": "w = int(input('Enter the number of watermelons.'))\n\nif w % 2 == 0 and w != 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "w=int(input())\nif(w>2):\n if(w%2==0):\n print(\"Yes\")\nelse:\n print(\"no\")"}, {"source_code": "weight = int(input(\"\"))\n\ndef solve():\n for weight in range (1):\n if weight == 2:\n print (\"NO\")\n if weight % 2 == 0 and weight != 2:\n print(\"YES\")\n\n else:\n print(\"NO\")\n\n\nsolve()\n "}, {"source_code": "x=int(input())\nif (0<x<100):\n if x%2==0:\n print(\"yes\")\n else:\n print(\"no\")\nif x==2:\n print(\"no\")\n\n "}, {"source_code": "def watermelon(d):\n if 88 % 2 == 1:\n return'NO'\n else: \n return 'YES'\n"}, {"source_code": "w = input()\n\ndef can_divide(w):\n if (int(w) % 2 == 0):\n return \"YES\"\n return \"NO\"\n\nprint(can_divide(w)) "}, {"source_code": "w=int(input())\nw>=1 and w<=100\nif(w%2==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "def waterMelon(x):\n x = input('Enter an Int : ')\n if (x%2) == 0:\n print 'YES'\n else:\n print 'NO'"}, {"source_code": "def function(x):\n\tn = x / 2\n\n\tif n.is_integer() == True:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')"}, {"source_code": "number = int(input(\"Input: \"))\nif number % 2 == 0: print(\"YES\")\nelse: print(\"NO\")\n# 1502678386526\n"}, {"source_code": "kilograms = int(input())\ndivideVal = kilograms/2\nif divideVal%2 == 0:\n\t\tprint(\"YES\")\nelse:\n\t\tprint(\"NO\")"}, {"source_code": "a=input(\"Weight=\")\nb=int(a)\nif(b%2==0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "w = int(input())\n\nif w ==2:\n print(\"NO\")\n\nif(w%2!=0):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n = int(raw_input())\nprint ['NO', 'YES'][(n / 2) % 2 == 0 and (n - (n / 2)) % 2 == 0]\n"}, {"source_code": "def watermelon(w):\n if not w:\n return \"NO\"\n\n if w % 2 == 0:\n return \"YES\"\n return \"NO\"\n"}, {"source_code": "a = int(input(\"Number: \"))\nif a%2==0:\n\tprint(\"Yes\")\n\nelse:\n\tprint(\"NO\")"}, {"source_code": "w = int(input())\nif w % 4:\n print 'NO' \nelse:\n print 'YES'"}, {"source_code": "\nz=input()\nif type(z/2) == type(1):\n print\"YES\"\nelse:\n print\"NO\""}, {"source_code": "print \"YES\""}, {"source_code": "w = int(input())\n\n\nif(w > 1 & w < 100): \n if(w % 2 == 0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "w = int(input())\ni = 0\nwhile i != w-1:\n if (w / 2) % 2 == 0:\n print('YES')\n break\n else:\n print('NO')\n break\n # if i % 2 == 0 and (w - i) >= i and (w - i) % 2 == 0:\n # print(\"YES\")\n # break\n # else:\n # print('NO')\n # break\n i += 1\n"}, {"source_code": "if __name__ == '__main__':\n n = int(input())\nif n % 2 == 0 :\n print(\"yes\")\nelif n > 100 or n < 1 :\n print (\"numbers should be between 1_100\")\nelse:\n print (\"no\")"}, {"source_code": "w = int(input(\"w=\"))\nif w % 2 == 0 :\n print(True)\nelse:\n print(False)"}, {"source_code": "#Taking Input\n\n\nvalue = int(input(\"Give the weight\"))\n\n#Checking, if the value is divisble by 2 and is greater than 3\n\nif value%2==0 and value >=4:\n print(\"YES \\n\")\nelse:\n print(\"NO \\n\")\n"}, {"source_code": "def main(w):\n if w >= 4 and w % 2 == 0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "n=int(input())\nfor i in range (1,n):\n j=n-i\n if (i%2)==0 and (j%2)==0 :\n print(\"YES\")\n break\n"}, {"source_code": "w = int(input())\n\nc = \"YES\" if (w%2==0 and w!=0) else \"NO\"\n\nprint(c)"}, {"source_code": "def weight(n):\n if(n%2==0):\n print 'YES'\n else:\n print 'NO'\nn=input()\nweight(n)"}, {"source_code": "if (int(input()) % 2 == 0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "number = int(input(\"Input: \"))\nx = 1\nh = \"NOTDONE\"\nwhile x < number:\n y = number - x\n if y % 2 == 0 and x % 2 == 0:\n print(\"YES\")\n h = \"DONE\"\n break\n x = x + 1\nif h == \"NOTDONE\":\n print(\"NO\")\n# 1502679147248\n"}], "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2"} {"source_code": "__author__ = 'roma'\n\nimport sys\n\ndef rai():\n return map(int, sys.stdin.readline().strip().split())\n\nn, k = rai()\na = rai()\n\nd = list()\nfor i in xrange(0, n / k):\n d.append(a[:k])\n a[:k] = []\n # print d\n\n\ndef most_common(lst):\n return max(lst, key=lst.count)\n\nz = zip(*d)\n\ncount = 0\nfor l in z:\n c = most_common(l)\n count += len(l)-l.count(c)\n\nprint count", "positive_code": [{"source_code": "n, k = map(int, (raw_input()).split())\ndata = list(map(int, raw_input().split()))\ncnt = 0\nfor i in range (k):\n temp = data [i::k]\n cnt += min (temp.count(1), temp.count(2))\nprint cnt"}, {"source_code": "[N, K] = map(int, raw_input().split())\na = [x-1 for x in map(int, raw_input().split())]\nprint sum(min(sum(a[i::K]), N/K-sum(a[i::K])) for i in range(K))\n"}, {"source_code": "first_line = raw_input()\nn = int(first_line.split(\" \")[0])\nk = int(first_line.split(\" \")[1])\nline = raw_input()\narr = [int(x) for x in line.split(\" \")]\n\nsections = []\nfor i in range(k):\n sections.append([arr[index] for index in range(n) if index % k == i])\nresult = 0\nfor sec in sections:\n result += min(sec.count(1), sec.count(2))\n\nprint result"}, {"source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\nans = 0\nfor x in xrange(k):\n arr = a[x::k]\n ans += min(arr.count(1), arr.count(2))\nprint ans"}, {"source_code": "n, k = map(int, raw_input().strip().split())\na = map(int, raw_input().strip().split())\n\nka = 0\net = [[0 for j in range(n/k)] for i in range(k)]\n\nfor i in range(k):\n for j in range(n/k):\n et[i][j] = a[i+k*j]\n\nfor i in range(k):\n if len(set(et[i])) > 1:\n ka = ka + min(et[i].count(1), et[i].count(2))\n\nprint ka"}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\nc = 0\nfor i in range(k):\n l1 = a[i::k].count(1)\n l2 = a[i::k].count(2)\n c += min(l1, l2)\nprint c\n \n"}, {"source_code": "import math\nimport sys\nimport itertools\n\ndef main():\n\tn, k = [int(c) for c in raw_input().split()]\n\tarr = raw_input()\n\tarr = [int(x) for x in arr.split()]\n\n\tout = 0\n\tfor i in range(k):\n\t\ttmp = []\n\t\tfor j in range(i, n, k):\n\t\t\ttmp.append(arr[j])\n#\t\tprint tmp\n\t\tout += count(tmp)\n\n\tprint out\n\ndef count(a):\n\tones, twos = 0, 0\n\tfor i in a:\n\t\tif i == 1:\n\t\t\tones += 1\n\t\telif i == 2:\n\t\t\ttwos += 1\n\treturn min(ones, twos)\n\t\t\n\nif __name__ == '__main__':\n\tmain()\n\"\"\"\n# The following solution is erroneous and attacks the \n# problem with much more effort than is necessary. \n\ndef main():\n\tn, k = [int(c) for c in raw_input().split()] \n\tarr = raw_input()\n\tarr = [int(x) for x in arr.split()]\t\t\n\n\tout = n\n\n\tfor i in factors(k):\n\t\tadd = 0\n\t\trep = arr[0:i]\n\t\tfor j in range(0, n, i):\n\t\t\ttmp = arr[j:j+i]\n\t\t\tprint \"i, tmp, rep:\", i, tmp, rep\n\t\t\tadd += diff(tmp, rep)\n\t\tif add < out:\n\t\t\tout = add\n\n\tprint \"out\", out\n\tprint \"rep:\", rep, \"arr:\", arr\t\n\ndef diff(a, b):\n\tif len(a) != len(b):\n\t\treturn False\n\tout = 0\n\tfor i in range(len(a)):\n\t\tif a[i] != b[i]:\n\t\t\tout+=1\n\treturn out\n\n\ndef factors(a):\n\treturn [i for i in xrange(1, a+1) if a % i == 0]\n\n\"\"\"\n"}, {"source_code": "import os,sys\n###K-Periodic Array: 371A http://codeforces.com/problemset/problem/371/A\n###This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.\n###Array a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly times consecutively. In other words, array a is k-periodic, if it has period of length k.\n###For the given array a, consisting only of numbers one and two, find the minimum number of elements to change to make the array k-periodic. If the array already is k-periodic, then the required value equals 0.\n\n###input\n#The first line of the input contains a pair of integers n,k, where n is the length of the array and the value n is divisible by k.The second line contains the sequence of elements of the given array a1,...,an\n\n###output\n#Print the minimum number of array elements we need to change to make the array k-periodic. If the array already is k-periodic, then print 0.\n\ndef run():\n n, k = map(int, raw_input().split())\n ones = [0 for i in range(k)]##number of 1 in each pos of the k-periodic arr; the rest should be 2\n maxCnt = n / k\n arr = map(int, raw_input().split())\n for i in range(n):\n if 1 == arr[i]: \n ones[i%k] += 1\n \n changes = 0\n for ele in ones:\n changes += min(ele, maxCnt-ele)\n \n #print ones\n print changes\n##################################################################\nrun()\n"}, {"source_code": "a = raw_input()\nb = raw_input()\nx = map(int, a.split())\ny = map(int, b.split())\ndef g(r):\n a1 = 0\n a2 = 0\n a3 = 0\n for i in range(len(r)):\n if r[i] == 1:\n a1 += 1\n if r[i] == 2:\n a2 += 1\n return min(a1,a2)\n\ndef f():\n n = x[0]\n k = x[1]\n j = 0\n for i in range(k):\n w = y[i:len(y):k] \n j = j + g(w)\n return j\nprint f()\n"}, {"source_code": "n,k = [int(nk) for nk in raw_input().split(\" \")]\na = [int(ai) for ai in raw_input().split(\" \")]\nc = [[0,0] for _ in xrange(k)]\nfor i in range(0,n,k):\n\tfor j in range(k):\n\t\tc[j][a[i+j]-1] += 1\nans = 0\nfor ci in c:\n\tans += min(ci)\nprint ans"}, {"source_code": "n,k = map(int, raw_input().strip().split(' '))\nlis = map(int, raw_input().strip().split(' '))\n\ngrps = []\nfor i in range(k):\n grps.append([])\n\nfor i in range(n):\n grps[i%k].append(lis[i])\n\nanswer = 0\nfor i in range(k):\n answer += min(grps[i].count(1), grps[i].count(2))\n\nprint answer\n"}, {"source_code": "n, k = map(int, raw_input().split())\narr = map(int, raw_input().split())\n\ns = 0\n\nfor i in range(k):\n\tones = 0\n\ttwos = 0\n\ttotal = sum(arr[i::k])\n\ttwos = total - (n/k)\n\tones = n / k - twos\n\ts += min(ones, twos)\nprint s\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\nn,k=r()\nm=r()\nS=0\nfor i in range(k):\n c=m[i::k].count(1)\n S+=min(c,n/k-c)\nprint S\n\n"}, {"source_code": "n, k = map(int, raw_input().split())\ndata = map(int, raw_input().split())\nans = 0\nfor x in xrange(0,k):\n tmp = [0,0,0]\n for y in xrange(0,n/k):\n tmp[data[x+y*k]] += 1\n ans += min(tmp[1], tmp[2])\nprint ans"}, {"source_code": "import sys\nfrom collections import defaultdict, Counter\nfrom itertools import permutations, combinations\nfrom math import sin, cos, asin, acos, tan, atan, pi\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition, yes = \"YES\", no = \"NO\", none = \"-1\") :\n if condition == None:\n print (none)\n elif condition :\n print (yes)\n else :\n print (no)\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rstr() :\n return sys.stdin.readline().strip()\n\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits[::-1]\n\ndef undigits(x, p) :\n value = 0\n for d in x :\n value *= p\n value += d\n return value\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\ndef vector_distance(a, b) :\n diff = vector_diff(a, b)\n \n return scalar_product(diff, diff) ** 0.5\n\ndef vector_inverse(v) :\n r = [-x for x in v]\n\n return tuple(r)\n\ndef vector_diff(a, b) :\n return vector_sum(a, vector_inverse(b))\n\ndef vector_sum(a, b) :\n r = [c1 + c2 for c1, c2 in zip(a, b)]\n \n return tuple(r)\n\ndef scalar_product(a, b) :\n r = 0\n for c1, c2 in zip(a, b) :\n r += c1 * c2\n\n return r\n\ndef check_rectangle(points) :\n assert(len(points) == 4)\n\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n sides = (\n vector_diff(A1, A2),\n vector_diff(A2, A3),\n vector_diff(A3, A4),\n vector_diff(A4, A1),\n )\n if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :\n return True\n return False\n\ndef check_square(points) :\n if not check_rectangle(points) :\n return False\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n side_lengths = [\n (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])\n ]\n if len(set(side_lengths)) == 1 :\n return True\n \n return False\n\ndef check_right(p) :\n # Check if there are same points\n for a, b in [\n (p[0], p[1]),\n (p[0], p[2]),\n (p[1], p[2]),\n ] :\n if a[0] == b[0] and a[1] == b[1] :\n return False\n\n a, b, c = p\n a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a) \n\n return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0\n\ndef modmatrixproduct(a, b, mod) :\n n, m1 = len(a), len(a[0])\n m2, k = len(b), len(b[0])\n\n assert(m1 == m2)\n m = m1\n\n r = [[0] * k for i in range(n)]\n for i in range(n) :\n for j in range(k) :\n for l in range(m) :\n r[i][j] += a[i][l] * b[l][j]\n r[i][j] %= mod\n return r\n\ndef modmatrixpower(a, n, mod) :\n magic = 2\n for m in [2, 3, 5, 7] :\n if n % m == 0 :\n magic = m\n break\n\n r = None\n if n < magic : \n r = a\n n -= 1\n else :\n s = modmatrixpower(a, n // magic, mod)\n r = s\n for i in range(magic - 1) :\n r = modmatrixproduct(r, s, mod)\n\n for i in range(n % magic) : \n r = modmatrixproduct(r, a, mod)\n \n return r\nn, k = rints()\na = rints()\n\nb = [a[i: i + k] for i in range(0, n, k)]\n\nd = 0 \nfor j in range(k) :\n sub = [b[i][j] for i in range(len(b))]\n sub = Counter(sub)\n d += min(sub.get(1, 0), sub.get(2, 0))\n \nprint d\n"}, {"source_code": "from Queue import * # Queue, LifoQueue, PriorityQueue\nfrom bisect import * #bisect, insort\nfrom datetime import * \nfrom collections import * #deque, Counter,OrderedDict,defaultdict\nimport calendar\nimport heapq\nimport math\nimport copy\nimport itertools\nmyread = lambda : map(int,raw_input().split())\ndef solver():\n n,k = myread()\n num = myread()\n ans = 0\n for i in range(k):\n count1 = 0\n count2 = 0\n for j in range(n/k):\n if num[j*k + i] == 1:\n count1 += 1\n else:\n count2 += 1\n \n ans += min(count1,count2)\n\n\n print ans\n \n\n\n\nif __name__ == \"__main__\":\n solver()\n \n"}, {"source_code": "r=lambda:map(int,raw_input().split())\nn,k=r()\nm=r()\nS=0\nfor i in range(k):\n c=m[i::k].count(1)\n S+=min(c,n/k-c)\nprint S\n\n"}, {"source_code": "def main():\n #from sys import stdin, stdout\n #start here\n (n,k)=map(int,raw_input().split())\n a=map(int,raw_input().split())\n t=n/k\n ans=0\n for i in xrange(k):\n c=[]\n for j in xrange(t):\n c.append(a[j*k+i])\n #print c\n ans=ans+min(c.count(1),c.count(2))\n print ans\n \nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\nn,k=r()\nm=r()\nS=0\nfor i in range(k):\n c=m[i::k].count(1)\n S+=min(c,n/k-c)\nprint S\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\nn,k=r()\nm=r()\nS=0\nfor i in range(k):\n c=m[i::k].count(1)\n S+=min(c,n/k-c)\nprint S\n\n"}, {"source_code": "if __name__=='__main__':\n n,k = map(int, raw_input().split())\n arr = map(int, raw_input().split())\n \n ones, twos = [], []\n for i in range(k):\n ones.append(0)\n twos.append(0)\n\n for i in range(n):\n r = i%k\n if arr[i]==1:\n ones[r]+=1\n else:\n twos[r]+=1\n\n ans = 0\n for i in range(k):\n ans += min(ones[i],twos[i])\n print ans\n"}, {"source_code": "r=lambda:map(int,raw_input().split())\nn,k=r()\nm=r()\nS=0\nfor i in range(k):\n c=m[i::k].count(1)\n S+=min(c,n/k-c)\nprint S"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nprint(sum(min(x.count(1), x.count(2)) for x in (a[i::k] for i in range(k))))\n"}, {"source_code": "n, k = map(int, raw_input().split())\nL = map(int, raw_input().split())\ntmp, m = 0, 0\nf = [[0] * 3 for i in range(105)]\nfor i in range(n):\n f[i % k][L[i]] += 1\nans = 0\nfor i in range(k):\n if f[i][1] < f[i][2]:\n ans += f[i][1]\n else:\n ans += f[i][2]\nprint ans"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=0\nz=n//k\nfor i in range(k):\n\ta1=a[i::k]\n\tr1=a1.count(1)\n\tr2=a1.count(2)\n\tc=c+min(r1,r2)\nprint(c)"}, {"source_code": "n, k = [int(i) for i in raw_input().split()]\n\na = raw_input().split()\nout = 0\nfor i in xrange(k):\n lst = [int(a[j]) for j in xrange(i, n, k)]\n out+=min(lst.count(1), lst.count(2))\nprint out"}, {"source_code": "n , k = map(int ,raw_input().split())\na = map(int , raw_input().split())\nb = [0] * n\nfor i in range (n) :\n if a[i] == 1 : b[i % k] += 1\nans = 0\nfor i in range (k) :\n ans += min(b[i] , n/k - b[i])\nprint ans\n"}, {"source_code": "n,m = map(int,input().split())\nhas=[[0,0]for i in range(m)]\nlis = list(map(int,input().split()))\nfor i in range(n):\n if lis[i]==2:\n has[i%m][1]+=1\n else:\n has[i%m][0]+=1\nans=0 \nfor i in range(m):\n ans+=min(has[i][0],has[i][1])\nprint(ans) "}, {"source_code": "import sys\n\n[n,k] = map(int, sys.stdin.readline().strip().split())\narr = map(int, sys.stdin.readline().strip().split())\n\ncount1 = [0] * k\ncount2 = [0] * k\n\nfor i in range(0,n):\n if (arr[i] == 1):\n count1[i%k] = count1[i%k] + 1\n else:\n count2[i%k] = count2[i%k] + 1\n \nans = 0\n\nfor i in range(0,k):\n ans = ans + min(count1[i], count2[i])\n #print count1[i] + count2[i]\n \nprint ans"}, {"source_code": "from sys import stdin,stdout\nfrom collections import deque\nst=lambda:list(stdin.readline().strip())\nli=lambda:list(map(int,stdin.readline().split()))\nmp=lambda:map(int,stdin.readline().split())\ninp=lambda:int(stdin.readline())\npr=lambda n: stdout.write(str(n)+\"\\n\")\n\nmod=1000000007\nINF=float('inf')\n\n\ndef solve():\n\n n,k=mp()\n l=li()\n ans=0\n for i in range(k):\n x=[] \n for j in range(i,n,k):\n x.append(l[j])\n a=x.count(1)\n b=len(x)-a\n ans+= min(a,b)\n pr(ans)\n \nfor _ in range(1):\n\n solve()\n"}, {"source_code": "# -*- coding: utf-8 -*-\n# programmer: baizhj(baizhj@gmail.com)\n# date: Dec. 8th, 2013\n\nimport sys\n\nif __name__ == '__main__':\n n, k = [int(x) for x in sys.stdin.readline().split()]\n a = [int(x) for x in sys.stdin.readline().split()]\n t = n / k\n change = 0\n for i in xrange(0, k):\n cnt1 = 0\n for j in xrange(0, t):\n if a[j*k+i] == 1:\n cnt1 += 1\n cnt1 = min(cnt1, t-cnt1)\n change += cnt1\n print change"}, {"source_code": "n,k=map(int,raw_input().split())\na=map(int,raw_input().split())\nb=[a[i:n:k] for i in range(k)]\nprint sum([n/k-max(t.count(x) for x in set(t)) for t in b])"}, {"source_code": "(n,k) = map(int, raw_input().split())\na = map(int, raw_input().split())\n\nb = [0] * k\n\nfor i in xrange(n):\n if a[i] == 1:\n b[i % k] += 1\n\nres = sum(map(lambda x: min(x, n / k - x), b))\nprint res\n\n"}, {"source_code": "I=lambda:map(int, raw_input().split())\nn, k = I()\na = I()\nb = [[0,0] for i in xrange(k)]\nfor i in xrange(n):\n b[i%k][a[i]==1] += 1\nprint sum(min(x,y) for x,y in b)"}, {"source_code": "if __name__ == '__main__':\n n, m = [int(x) for x in raw_input().split()]\n a = [int(x) for x in raw_input().split()]\n res = 0\n for i in range(m):\n cnt = 0\n for j in range(i, n, m):\n if a[j] == 1:\n cnt += 1\n res += min(cnt, n / m - cnt)\n print res\n"}, {"source_code": "import sys\n# sys.stdin=open(\"1.in\",'r')\nn,k=map(int,raw_input().split())\na=map(int,raw_input().split())\nans=0;\nfor i in xrange(k):\n ct1=0;\n ct2=0;\n for j in xrange(i,n,k):\n if (a[j]==1):\n ct1+=1\n else:\n ct2+=1\n ans+=min(ct1,ct2);\nprint ans"}, {"source_code": "r = lambda: map(int, raw_input().split())\nn, k = r()\na = r()\ncnt = [{} for i in xrange(k)]\nfor i in xrange(n):\n cnt[i % k][a[i]] = cnt[i % k].get(a[i], 0) + 1\nprint sum(n / k - max(dic.values()) for dic in cnt)"}, {"source_code": "## int(input())\n## map(int ,input().split())\n## int(i) for i in input().split()\nn, k = map(int ,input().split())\nv = [int(x) for x in input().split()]\nl = [0] * k\nfor i in range(k):\n\tl[i] = v[i::k].count(1)\nans = 0\nn //= k\nfor x in l:\n\tans += min(x, n - x)\nprint(ans)"}, {"source_code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nc = 0\nfor i in range(0, k):\n one = a[i::k].count(1)\n two = a[i::k].count(2)\n c += min(one, two)\nprint(c)\n\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nans = 0\nfor i in range(k):\n t1, t2 = 0, 0\n for j in range(i, n, k):\n if a[j] == 1:\n t1 += 1\n else:\n t2 += 1\n ans += min(t1, t2)\nprint(ans)\n"}, {"source_code": "n, k = map(int, input().split())\na, val = list(map(int, input().split())), 0\nfor i in range(k):\n c = sum(a[i + j * k] == 1 for j in range(n // k))\n val += min(c, n // k - c)\nprint(val)"}, {"source_code": "n,k=map(int,input().split(\" \"))\nli=list(map(int,input().split(\" \",n)[:n]))\nhs=[[0 for i in range(k)] for j in range(n//k)]\np=0\nfor i in range(n//k):\n for j in range(k):\n hs[i][j]=li[p]\n p+=1\nans=0\nfor i in range(k):\n an=0\n for j in range(n//k):\n if hs[j][i]==1:\n an+=1\n if an<=(n//k)//2:\n ans+=an\n else:\n ans+=(n//k - an)\nprint(ans)\n"}, {"source_code": "from collections import Counter\n \nX = list(map(int, input().split()))\nNumbers = list(map(int, input().split()))\nprint(sum((X[0] // X[1] - max(Counter(Numbers[i::X[1]]).values())) for i in range(X[1])))\n \n# A new start\n# Here in Tabas\n# Waiting for the big news"}, {"source_code": "n,k=tuple(map(int,input().split()))\na=list(map(int,input().split()))\nprint(sum((lambda x:min(x-n//k,2*n//k-x))(sum(a[i::k])) for i in range(k)))\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(sum(min(x.count(1), x.count(2)) for x in (a[i::k] for i in range(k))))\n"}, {"source_code": "a=int(input().split()[1])\n*b,=map(int,input().split())\nc=0\nfor i in range(a):\n d=b[i::a]\n c+=min(d.count(1),d.count(2))\nprint(c)\n"}, {"source_code": "n, k = list(map(int, input().split()))\na = input().split()\nc = 0\nfor i in range(k):\n x, y = 0, 0\n for j in range(i, n, k):\n if a[j] == '1':\n x += 1\n else:\n y += 1\n c += min(x, y)\nprint(c)"}, {"source_code": "n,k=map(int,input().split())\n\nL=list(map(int,input().split()))\n\nA=[]\nfor i in range(0,n,k):\n A.append(list(L[i:i+k]))\nz=n//k\nans=0\nfor i in range(k):\n one=0\n two=0\n for j in range(z):\n if(A[j][i]==1):\n one+=1\n else:\n two+=1\n ans+=min(one,two)\nprint(ans)\n"}, {"source_code": "def main():\n n, k = map(int, input().split(' '))\n A = [int(i) for i in input().split(' ')]\n ans = 0\n one = 0 \n two = 0\n for i in range(k):\n one = 0\n two = 0\n for j in range(n // k):\n pos = i + j * k\n if A[pos] == 1:\n one = one + 1\n else:\n two = two + 1\n if(one < two):\n ans = ans + one\n else:\n ans = ans + two\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, k = list(map(int, input().split()))\nl = list(map(int, input().split()))\nans = 0\nfor i in range(0, k):\n n1 = l[i::k].count(1)\n n2 = l[i::k].count(2)\n ans += min( n1 , n2 )\nprint(ans)"}, {"source_code": "def _count(list, item):\n\tcount = 0\n\tfor c in list:\n\t\tif c == item:\n\t\t\tcount += 1\n\treturn count\n \ndef common(list):\n\tcounts = []\n\tmaxcount = 0\n\tfor stuff in list:\n\t\tif _count(list, stuff) > maxcount:\n\t\t\tmaxitem = stuff\n\t\t\tmaxcount = _count(list, stuff)\n\treturn maxitem\n\n\naa = input().split()\nn = int(aa[0])\nk = int(aa[1])\na = input().split()\n\n\nmatrix = []\nnew = []\nfor i in range(1, n + 1):\n\tif i % k == 0:\n\t\tnew.append(a[i - 1])\n\t\tmatrix.append(new)\n\t\tnew = []\n\telse:\n\t\tnew.append(a[i-1])\n\ncolums = []\nanswer = 0\nfor j in range(len(matrix[0])):\n\tcolum = []\n\tfor i in range(len(matrix)):\n\t\tcolum.append(matrix[i][j])\n\tcolums.append(colum)\n\nfor rows in matrix:\n\tfor i in range(len(rows)):\n\t\tif rows[i] != common(colums[i]):\n\t\t\tanswer += 1\nprint(answer)"}, {"source_code": "\nn, k = map(int, input().split())\nl = list(map(int, input().split()))\nans = 0\nz = n // k\nfor i in range(k):\n\tb = l[i::k]\n\tco = b.count(1)\n\tans += min(z - co, co)\n\nprint(ans)"}, {"source_code": "\nn, k = map(int, input().split())\nl = list(map(int, input().split()))\nans = 0\nfor i in range(k):\n\tones = 0\n\ttwos = 0\n\tfor j in range(n // k):\n\t\tif l[i + j * k] == 1:\n\t\t\tones += 1\n\t\telse:\n\t\t\ttwos += 1\n\n\tans += min(ones, twos)\n\nprint(ans)\n\n\n\t"}, {"source_code": "n, k = map(int, input().split())\nnums = list(map(int, input().split()))\nans = 0\nfor i in range(k):\n\tcnt = [0, 0, 0]\n\tfor j in range(n // k):\n\t\tcnt[nums[j * k + i]] += 1\n\tans += min(cnt[1], cnt[2])\nprint(ans)\n"}, {"source_code": "def inp():\n return map(int, input().split())\n\n\ndef arr_inp():\n return [int(x) for x in input().split()]\n\n\nn, k = inp()\na, out = arr_inp(), 0\nfor i in range(k):\n arr = a[i::k]\n out += min(arr.count(1), arr.count(2))\n\nprint(out)"}, {"source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# import math\n# from itertools import *\n# import random\n# import calendar\n# import datetime\n# import webbrowser\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\ncount = 0\nindex = 0\nwhile index < k:\n new = [arr[index]]\n temp = index\n for i in range((n//k) - 1):\n new.append(arr[temp + k])\n temp += k\n if new.count(1) >= new.count(2):\n count += new.count(2)\n else:\n count += new.count(1)\n index += 1\nprint(count)\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nans=0\nfor i in range(k):\n ones=0\n twos=0\n for j in range(n//k):\n num=l[i+j*k]\n if(num==1):\n ones+=1\n else:\n twos+=1\n ans+=min(ones,twos)\nprint(ans)\n"}, {"source_code": "k=int(input().split()[1])\nb=list(map(int,input().split()))\nc=0\nfor i in range(k):\n d=b[i::k]\n c+=min(d.count(1),d.count(2))\nprint(c)\n\n#we r looking at particular elements of each respective group(the k periodic group)..\n#and looking for the minimum changes"}, {"source_code": "n, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nans = 0\nfor i in range(k):\n t = 0\n for j in a[i::k]:\n s = a[i::k].count(j)\n if s > t:\n t = s\n o = j\n for j in a[i::k]:\n if j != o:\n ans += 1\nprint(ans)"}, {"source_code": "n, k = map(int, input().split())\nl = [*map(int, input().split())]\nprint(sum(min(l[i::k].count(1), l[i::k].count(2)) for i in range(k)))\n"}, {"source_code": "# Made By Mostafa_Khaled \nbot = True \nR = lambda: map(int, input().split())\n\nn, k = R()\n\na = list(R())\n\nprint(sum(min(x.count(1), x.count(2)) for x in (a[i::k] for i in range(k))))\n\n# Made By Mostafa_Khaled"}, {"source_code": "read = lambda:map(int, input().split())\nn,k = read()\nm = n//k\na = list(read())\nresult = 0\nfor i in range(k):\n t = a[i:n:k]\n s = t.count(1)\n result += min(s, m-s)\nprint(result)\n"}, {"source_code": "from math import *\n\n[n, k] = [int(i) for i in input().split()]\narr = [int(i) - 1 for i in input().split()]\narr2 = [[0 for i in range(2)] for j in range(k)]\nr = 0\nfor i in range(n // k):\n for j in range(k):\n arr2[j][arr[i * k + j]] += 1\nfor j in range(k):\n r += min(arr2[j][0], arr2[j][1])\nprint(r)\n"}, {"source_code": "#!/usr/bin/python3\n\ndef readln(): return tuple(map(int, input().split()))\n\nn, k = readln()\na = readln()\nans = 0\nfor i in range(k):\n cnt = len([1 for j in range(i, n, k) if a[j] == 1])\n ans += min(cnt, n // k - cnt)\nprint(ans)\n"}, {"source_code": "def main():\n n, k = map(int, input().split())\n l = input().split()\n print(sum(min(nn.count('1'), nn.count('2')) for nn in zip(*[l[i:i + k] for i in range(0, n, k)])))\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n, k = [int(x) for x in input().split()]\n\na = [int(x) for x in input().split()]\n\nc=0\nz=n//k\nfor i in range(k):\n\ta1=a[i::k]\n\tr1=a1.count(1)\n\tr2=a1.count(2)\n\tc=c+min(r1,r2)\nprint(c)"}, {"source_code": "def dist(x, y):\n return len([a for a, b in zip(x, y) if a != b])\n\nn, k = map(int, raw_input().split())\narray = map(int, raw_input().split())\ntemp = [0] * k\ncount = 0\n\nfor i in range(n/k):\n for j in range(k):\n temp[j] += array[i*k+j]\n\nfor i in temp:\n count2 = i - n/k\n count1 = n/k - count2\n count += min(count1, count2)\n\nprint count\n"}, {"source_code": "n,k=map(int,raw_input().split())\narr=map(int,raw_input().split())\nc=0\nfor i in range(k):\n t=[]\n for j in range(n/k):\n t.append(arr[i+j*k])\n c+=n/k-max(t.count(1),t.count(2))\nprint c\n"}], "negative_code": [{"source_code": "n,q=map(int,input().split())\na=list(map(int,input().split()))\nc=[]\nl=[]\nc1=0\n# for i in range(1,n+1):\ni=q\nif(n%i==0):\n\tr=a[:i]\t\n\tj=i\n\tc1=0\n\tl.append(r)\n\twhile(j<len(a)):\n\t\ty=a[j:j+len(r)]\n\t\tj=j+len(r)\n\t\tl.append(y)\nt=[]\nfor j in range(len(l)):\n\tc1=0\n\tk=l[j]\n\tfor m in range(len(l)):\n\t\tif(m==j):\n\t\t\tpass\n\t\telse:\n\t\t\tfor e in range(q):\n\t\t\t\tif(l[m][e]!=l[j][e]):\n\t\t\t\t\tc1=c1+1\n\tc.append(c1)\nk1=a.count(1)\nk2=a.count(2)\nprint(min(min(c),min(k1,k2)))"}, {"source_code": "n,q=map(int,input().split())\na=list(map(int,input().split()))\nc=[]\nc1=0\nfor i in range(1,n+1):\n\tif(n%i==0 and i==q):\n\t\tr=a[:i]\n\t\t# print(r)\t\n\t\tj=i\n\t\tc1=0\n\t\twhile(j<len(a)):\n\t\t\ty=a[j:j+len(r)]\n\t\t\tj=j+len(r)\n\t\t\t# print(r,y)\n\t\t\tfor k in range(len(r)):\n\t\t\t\tif(r[k]!=y[k]):\n\t\t\t\t\tc1=c1+1\n\t\tc.append(c1)\nk1=a.count(1)\nk2=a.count(2)\n# print(c1)\n# print(c,k1,k2)\nif(n==q):\n\tprint(0)\nelif(len(c)>0):\n\tprint(min(min(c),min(k1,k2)))\nelse:\n\tprint(min(k1,k2))"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=[]\nc1=0\nfor i in range(1,n+1):\n\tif(n%i==0):\n\t\tr=a[:i]\n\t\t# print(r)\t\n\t\tj=i\n\t\tc1=0\n\t\twhile(j<len(a)):\n\t\t\ty=a[j:j+len(r)]\n\t\t\tj=j+len(r)\n\t\t\t# print(r,y)\n\t\t\tfor k in range(len(r)):\n\t\t\t\tif(r[k]!=y[k]):\n\t\t\t\t\tc1=c1+1\n\t\tc.append(c1)\nc.pop()\nk1=a.count(1)\nk2=a.count(2)\n# print(c,k1,k2)\nif(len(set(a))==n):\n\tprint(0)\nelif(len(c)>0):\n\tprint(min(min(c),min(k1,k2)))\nelse:\n\tprint(min(k1,k2))"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=[]\nc1=0\nfor i in range(1,n+1):\n\tif(n%i==0):\n\t\tr=a[:i]\n\t\t# print(r)\t\n\t\tj=i\n\t\tc1=0\n\t\twhile(j<len(a)):\n\t\t\ty=a[j:j+len(r)]\n\t\t\tj=j+len(r)\n\t\t\t# print(r,y)\n\t\t\tfor k in range(len(r)):\n\t\t\t\tif(r[k]!=y[k]):\n\t\t\t\t\tc1=c1+1\n\t\tc.append(c1)\nc.pop()\nk1=a.count(1)\nk2=a.count(2)\nif(len(c)>0):\n\tprint(min(min(c),min(k1,k2)))\nelse:\n\tprint(min(k1,k2))"}, {"source_code": "n,q=map(int,input().split())\na=list(map(int,input().split()))\nc=[]\nc1=0\nfor i in range(1,n+1):\n\tif(n%i==0 and i<=q):\n\t\tr=a[:i]\n\t\t# print(r)\t\n\t\tj=i\n\t\tc1=0\n\t\twhile(j<len(a)):\n\t\t\ty=a[j:j+len(r)]\n\t\t\tj=j+len(r)\n\t\t\t# print(r,y)\n\t\t\tfor k in range(len(r)):\n\t\t\t\tif(r[k]!=y[k]):\n\t\t\t\t\tc1=c1+1\n\t\tc.append(c1)\nc.pop()\nk1=a.count(1)\nk2=a.count(2)\n# print(c,k1,k2)\nif(n==q):\n\tprint(0)\nelif(len(c)>0):\n\tprint(min(min(c),min(k1,k2)))\nelse:\n\tprint(min(k1,k2))"}, {"source_code": "n,q=map(int,input().split())\na=list(map(int,input().split()))\nc=[]\nc1=0\nfor i in range(1,n+1):\n\tif(n%i==0):\n\t\tr=a[:i]\n\t\t# print(r)\t\n\t\tj=i\n\t\tc1=0\n\t\twhile(j<len(a)):\n\t\t\ty=a[j:j+len(r)]\n\t\t\tj=j+len(r)\n\t\t\t# print(r,y)\n\t\t\tfor k in range(len(r)):\n\t\t\t\tif(r[k]!=y[k]):\n\t\t\t\t\tc1=c1+1\n\t\tc.append(c1)\nc.pop()\nk1=a.count(1)\nk2=a.count(2)\n# print(c,k1,k2)\nif(n==q):\n\tprint(0)\nelif(len(c)>0):\n\tprint(min(min(c),min(k1,k2)))\nelse:\n\tprint(min(k1,k2))"}, {"source_code": "def f(l1,l2):\n n,k = l1\n nol = n//k\n sl = [sum(l2[i:n:k]) for i in range(nol)]\n return sum([min(nol*2-s,s-nol) for s in sl])\n\nl1 = list(map(int,input().split()))\nl2 = list(map(int,input().split()))\nprint(f(l1,l2))\n"}, {"source_code": "\nst = raw_input()\n\nst = st.split(\" \", 1);\nn = int( st[0] )\nk = int( st[1] )\n\nst = raw_input()\nar = []\nst = st.split(\" \", n-1)\nfor s in st:\n ar.append( int(s) )\n\n\n\nif k == 1:\n print 0\nelse:\n res = 0\n i = 0\n while i < k:\n i += 1\n j = 0\n ones = 0\n twos = 0\n while j < int(n/k):\n # print \"index : \" + str(k*j+i-1)\n if ar[ k*j+i-1 ] == 1:\n ones += 1\n else:\n twos += 1\n j += 1\n res += min( ones, twos )\n print res\n"}, {"source_code": "# from Mergesort import *\n# s=[1,2,35,4,45,454,78,23,65,567,343,4345,65,75,453,5]\n# arr1=mergesort(s)\n# print \"arr1 is\"\n# prin t arr1\nimport sys\nx= raw_input()\ny= x.split()\ny[0]=int(y[0])\ny[1]=int(y[1])\nj=-1\nz=int(y[0])/int(y[1]) \ns=raw_input()\ns=s.split()\nh=0\ncount=0\ncount1=0\nans=0\nfor i in s:\n j+=1\n h=j+y[1]\n note=s[j]\n \n if(j>=y[1]):\n print count\n sys.exit()\n \n while (h<y[0]):\n if s[j]!=s[h] :\n count+=1\n else:\n count1+=1\n h+=y[1]\n ans+=min(count,count1)\nprint ans "}, {"source_code": "# from Mergesort import *\n# s=[1,2,35,4,45,454,78,23,65,567,343,4345,65,75,453,5]\n# arr1=mergesort(s)\n# print \"arr1 is\"\n# prin t arr1\nimport sys\nx= raw_input()\ny= x.split()\ny[0]=int(y[0])\ny[1]=int(y[1])\nj=-1\nz=int(y[0])/int(y[1]) \ns=raw_input()\ns=s.split()\nh=0\ncount=0\ncount1=0\nans=0\nfor i in s:\n j+=1\n h=j+y[1]\n note=s[j]\n \n if(j>=y[1]):\n print ans\n sys.exit()\n \n while (h<y[0]):\n if s[j]!=s[h] :\n count+=1\n else:\n count1+=1\n h+=y[1]\n ans+=min(count,count1)\nprint ans "}, {"source_code": "# from Mergesort import *\n# s=[1,2,35,4,45,454,78,23,65,567,343,4345,65,75,453,5]\n# arr1=mergesort(s)\n# print \"arr1 is\"\n# prin t arr1\nimport sys\nx= raw_input()\ny= x.split()\ny[0]=int(y[0])\ny[1]=int(y[1])\nj=-1\nz=int(y[0])/int(y[1]) \ns=raw_input()\ns=s.split()\nh=0\ncount=0\nfor i in s:\n j+=1\n h=j+y[1]\n note=s[j]\n if(j>=y[1]):\n print count\n sys.exit()\n while (h<y[0]):\n# print s[j],s[h]\n\n if s[j]!=s[h] and s[h]!=s[h-y[1]] :\n #int j,h,s[j],s[h]\n count+=1\n #print count\n \n# print \"i ma \"+str(j),str(h)\n h+=y[1]\nprint count "}, {"source_code": "import sys\nx= raw_input()\ny= x.split()\ny[0]=int(y[0])\ny[1]=int(y[1])\nj=-1\nz=int(y[0])/int(y[1]) \ns=raw_input()\ns=s.split()\nh=0\ncount=0\nfor i in s:\n j+=1\n h=j\n note=s[j]\n if(j>y[1]):\n print count\n sys.exit()\n while (h<y[0]):\n# print s[j],s[h]\n\n if s[j]!=s[h]:\n count+=1\n if(s[h]==note):\n count-=1\n note=s[h]\n \n# print \"i ma \"+str(j),str(h)\n h+=y[1]\nprint count "}, {"source_code": "# from Mergesort import *\n# s=[1,2,35,4,45,454,78,23,65,567,343,4345,65,75,453,5]\n# arr1=mergesort(s)\n# print \"arr1 is\"\n# prin t arr1\nimport sys\nx= raw_input()\ny= x.split()\ny[0]=int(y[0])\ny[1]=int(y[1])\nj=-1\nz=int(y[0])/int(y[1]) \ns=raw_input()\ns=s.split()\nh=0\ncount=0\nfor i in s:\n j+=1\n h=j+y[1]\n note=s[j]\n if(j>=y[1]):\n print count\n sys.exit()\n while (h<y[0]):\n# print s[j],s[h]\n\n if s[j]!=s[h] and s[h]!=s[h-y[1]] :\n #int j,h,s[j],s[h]\n count+=1\n #print count\n \n# print \"i ma \"+str(j),str(h)\n h+=y[1]\n# print count "}, {"source_code": "import sys\nx= raw_input()\ny= x.split()\ny[0]=int(y[0])\ny[1]=int(y[1])\nj=-1\nz=int(y[0])/int(y[1]) \ns=raw_input()\ns=s.split()\nh=0\ncount=0\nfor i in s:\n j+=1\n h=j\n note=s[j]\n if(j>y[1]):\n print count\n sys.exit()\n while (h<y[0]):\n# print s[j],s[h]\n\n if s[j]!=s[h]:\n count+=1\n if(s[h]==note):\n count-=1\n note=s[h]\n \n# print \"i ma \"+str(j),str(h)\n h+=y[1]"}, {"source_code": "[N, K] = map(int, raw_input().split())\na = [x-1 for x in map(int, raw_input().split())]\nprint sum(min(sum(a[i::K]), N/K-sum(a[i::K])) for i in range(N/K))\n"}, {"source_code": "first_line = raw_input()\nn = int(first_line.split(\" \")[0])\nk = int(first_line.split(\" \")[1])\nline = raw_input()\narr = [int(x) for x in line.split(\" \")]\n\nsections = []\nfor i in range(k):\n sections.append([arr[index] for index in range(n) if index % k == i])\nresult = 0\nfor sec in sections:\n if sec.count(1) != len(sec) and sec.count(1) != 0:\n result += 1\n\nprint result"}, {"source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\nl = [''.join(map(str,a[i:i+k])) for i in xrange(0,n,k)]\nd = {}\nfor x in l:\n d[x] = d.get(x,0) + 1\nm = max(d.values())\nprint [n/k - m,k][m == 1]"}, {"source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\nl = [''.join(map(str,a[i:i+k])) for i in xrange(0,n,k)]\nd = {}\nfor x in l:\n d[x] = d.get(x,0) + 1\nm = max(d.values())\nif n == k:\n print 0\nelse:\n print [n/k - m,k][m == 1]"}, {"source_code": "n, k = map(int, raw_input().strip().split())\na = map(int, raw_input().strip().split())\n\nka = 0\net = [[0 for j in range(n/k)] for i in range(k)]\n\nfor i in range(k):\n for j in range(n/k):\n et[i][j] = a[i+k*j]\n\nfor i in range(k):\n if len(set(et[i])) > 1:\n ka = ka + abs(et[i].count(1)-et[i].count(2))\n\nprint ka"}, {"source_code": "n,k=map(int,raw_input().split())\na=map(lambda x:bool(int(x)-1),raw_input().split())\nf=n/k\nc=[]\nfor x in xrange(k):c.append(0)\nfor x in xrange(n):\n if a[x]==1:c[x%k]+=1\nd=map(lambda x:bool(x/f),c)\nans=0\nfor x in xrange(n):\n if a[x]!=d[x%k]:ans+=1\nprint ans;"}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\n\nc = 0\n\nfor i in xrange(k):\n e = [a[j] for j in xrange(i, n, k)]\n if len(set(e)) == 1:\n continue\n else:\n print e\n c += min(e.count(1), e.count(2))\n\nprint c\n "}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\n\nc = 0\n\nfor i in xrange(k):\n e = [a[j] for j in xrange(i, n, k)]\n if len(set(e)) == 1:\n continue\n else:\n c += abs(e.count(1) - e.count(2))\n\nprint c\n "}, {"source_code": "n,k = map(int, raw_input().strip().split(' '))\nlis = map(int, raw_input().strip().split(' '))\nif k == 1:\n print 0\n exit(0)\n\ngrps = []\nfor i in range(k):\n grps.append([])\n\nfor i in range(n):\n grps[i%k].append(lis[i])\n\nanswer = 0\nfor i in range(k):\n answer += min(grps[i].count(1), grps[i].count(2))\n\nprint answer\n"}, {"source_code": "n, k = map(int, raw_input().split())\ndata = map(int, raw_input().split())\nans = 0\nfor x in xrange(0,k):\n tmp = [0,0,0]\n for y in xrange(0,n/k):\n tmp[data[x*y]] += 1\n ans += min(tmp[1], tmp[2])\nprint ans"}, {"source_code": "def main():\n #from sys import stdin, stdout\n #start here\n (n,k)=map(int,raw_input().split())\n a=map(int,raw_input().split())\n t=n/k\n ans=float('inf')\n for i in xrange(t):\n c=0\n for j in xrange(n):\n #print j, j%k+i*k, j%k, i*k\n if(a[j]!=a[j%k+i*k]):\n c=c+1\n #print c\n ans=min(ans,c)\n print ans\n \nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,k=map(int,raw_input().split())\nar=map(int,raw_input().split())\ni=0\nc1=ar.count(1)\nc2=ar.count(2)\nc3=10**9\nt1=[[] for i in xrange(k)]\nwhile(i<=(n-k)):\n l1=(ar[i:i+k])\n for j in xrange(k):\n t1[j].append(l1[j])\n i+=k\nans=0\nfor i in xrange(k):\n ans+=min(t1[i].count(1),t1[j].count(2))\nprint ans"}, {"source_code": "n,k=map(int,raw_input().split())\nar=map(int,raw_input().split())\ni=0\nc1=ar.count(1)\nc2=ar.count(2)\nc3=10**9\nwhile(i<=(n-k)):\n l1=(ar[i:i+k])\n j=0\n temc=0\n while (j<=(n-k)):\n l2=ar[j:j+k]\n for t in xrange(k):\n if l1[t]!=l2[t]:\n temc+=1\n j+=k\n c3=min(temc,c3)\n i+=k\nprint min(c3,c1,c2)\n"}, {"source_code": "n,k=map(int,raw_input().split())\nar=map(int,raw_input().split())\ni=0\nc1=ar.count(1)\nc2=ar.count(2)\nc3=10**9\nt1=[[] for i in xrange(k)]\nwhile(i<=(n-k)):\n l1=(ar[i:i+k])\n for j in xrange(k):\n t1[j].append(l1[j])\n i+=k\nans=0\nfor i in xrange(k):\n ans+=min(t1[i].count(1),t1[i].count(2))\nprint ans"}, {"source_code": "n, k = map(int, raw_input().split())\nL = map(int, raw_input().split())\ns = set()\ns.add(tuple([1] * k))\ns.add(tuple([2] * k))\nfor i in range(n / k):\n s.add(tuple(L[i * k:(i+1) * k]))\nmn = 1 << 30\nfor x in s:\n cnt = 0\n for i in range(n / k):\n for j in range(k):\n if x[j] != tuple(L[i * k:(i+1) * k])[j]:\n cnt += 1\n mn = min(mn, cnt)\nprint mn\n"}, {"source_code": "n , k = map(int ,raw_input().split())\na = map(int , raw_input().split())\nb = [0] * n\nfor i in range (n) :\n\tif a[i] == 1 : b[i % k] += 1\nans = 0\nfor i in range (n/k) :\n\tans += min(b[i] , n/k - b[i])\nprint ans\n"}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\nans = 0\n\nfor i in xrange(n / k):\n t1 = t2 = 0\n for j in xrange(k):\n if a[i * k + j] == 1:\n t1 += 1\n else:\n t2 += 1\n ans += min(t1, t2)\nprint ans\n"}, {"source_code": "line1=raw_input().split(\" \")\nN=int(line1[0]);K=int(line1[1])\narray=map(int,raw_input().split(\" \"))\nrow=len(array)/K\ncol=K\nD2=[]\ntmp=[]\nfor i in range(len(array)):\n if (i+1)%K!=0:\n tmp.append(array[i])\n if (i+1)%K==0:\n tmp.append(array[i])\n D2.append(tmp)\n tmp=[]\ndef Solve(D2,K,N):\n print D2\n total=0\n for j in range(K):\n one_count=0\n two_count=0\n for i in range(N/K):\n if D2[i][j]==1: one_count+=1\n else: two_count+=1\n total+=min(one_count,two_count)\n return total\nprint Solve(D2,K,N)\n"}, {"source_code": "__author__ = 'roma'\n\nimport sys\n\ndef rai():\n return map(int, sys.stdin.readline().strip().split())\n\nn, k = rai()\na = rai()\n\n# n, k = (8, 2)\n# a = [1, 1, 2, 1, 1, 1, 2, 1]\n\nd = list()\nfor i in xrange(0, n/k):\n d.append(a[:k])\n a[:k] = []\n # print d\n\ndef most_common(lst):\n return max(lst, key=lst.count)\n\nz = zip(*d)\nc = most_common(d)\ndf = filter(lambda x: cmp(x, c), d)\ncounter = 0\nfor e in df:\n for hj in zip(c, e):\n if hj[0] is not hj[-1]:\n counter += 1\nprint counter"}, {"source_code": "__author__ = 'roma'\n\nimport sys\n\ndef rai():\n return map(int, sys.stdin.readline().strip().split())\n\nn, k = rai()\na = rai()\n\n# n, k = (6, 2)\n# a = [2, 1, 2, 2, 2, 1]\n\nd = list()\nfor i in xrange(0, n/k):\n d.append(a[:k])\n a[:k] = []\n\ndef most_common(lst):\n return max(set(lst), key=lst.count)\n\nz = zip(*d)\nc = most_common(z)\ndf = filter(lambda x: x is not c, z)\ncounter = 0\nfor e in df:\n for hj in zip(c, e):\n if hj[0] is hj[-1]:\n counter += 1\nprint counter"}, {"source_code": "## int(input())\n## map(int ,input().split())\n## int(i) for i in input().split()\nn, k = map(int ,input().split())\na = [int(i) for i in input().split()]\nrs = 105\nif k == n: rs = 0\nfor i in range(n // k):\n b = []\n cnt = 0\n t = 0\n for j in range(k):\n b.append(a[i*k + j])\n for j in range(n):\n if a[j] != b[t]: cnt+=1\n t+= 1\n if t >= k: t = 0\n rs = min(rs, cnt)\nfor i in range(n):\n cnt = 0\n for j in range(n):\n if a[j] != a[i]: cnt+=1\n rs = min(rs, cnt)\nprint(rs)"}, {"source_code": "## int(input())\n## map(int ,input().split())\n## int(i) for i in input().split()\nn, k = map(int ,input().split())\na = [int(i) for i in input().split()]\nrs = 105\nfor i in range(n // k):\n b = []\n cnt = 0\n t = 0\n for j in range(k):\n b.append(a[i*k + j])\n for j in range(n):\n if a[j] != b[t]: cnt+=1\n t+= 1\n if t >= k: t = 0\n rs = min(rs, cnt)\nfor i in range(n):\n cnt = 0\n for j in range(n):\n if a[j] != a[i]: cnt+=1\n rs = min(rs, cnt)\nprint(rs)"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nans = 0\nfor i in range(k):\n t1, t2 = 0, 0\n for j in range(i, n, k):\n print(j, a[j])\n if a[j] == 1:\n t1 += 1\n else:\n t2 += 1\n ans += min(t1, t2)\nprint(ans)\n"}, {"source_code": "line = input().split()\nn = int(line[0])\nk = int(line[1])\n\nline = input().split()\narr = [int(i) for i in line]\n\nmatrix = []\n\nnew_arr = []\nfor i in range(n+1):\n\tif i % k == 0 and new_arr:\n\t\tmatrix.append(new_arr)\n\t\tnew_arr = []\n\tif i == n:\n\t\tbreak\n\tnew_arr.append(arr[i])\n# print(f\"matrix: {matrix}\")\n\nchanges = 0\nfor c in range(k): # n/k is number of sub arrays\n\tone_cnt = 0\n\ttwo_cnt = 0\n\tfor r in range(n//k):\n\t\t# print(f\"row {r} col {c} value: {matrix[r][c]}\")\n\t\tif matrix[r][c] == 2:\n\t\t\ttwo_cnt += 1\n\t\telse:\n\t\t\tone_cnt += 1\n\t# print(f\"twos in {c}th column: {two_cnt}\")\n\t# print(f\"ones in {c}th column: {one_cnt}\")\n\tif one_cnt != 0 and two_cnt != 0: # a change needs to be made\n\t\tchanges += abs(one_cnt - two_cnt)\n\n# print(\"\\n\\n\")\nprint(changes)\n\n\n\n\n\n"}, {"source_code": "aa = input().split()\nn = int(aa[0])\nk = int(aa[1])\na = input().split()\n\n\nmaster = []\nnew = []\nfor i in range(1, n + 1):\n\tif i % k == 0:\n\t\tnew.append(a[i - 1])\n\t\tmaster.append(new)\n\t\tnew = []\n\telse:\n\t\tnew.append(a[i-1])\n\ndef count(list, item):\n\tcount = 0\n\tfor c in list:\n\t\tif c == item:\n\t\t\tcount += 1\n\treturn count\n\ndef common(list):\n\tcounts = []\n\tmaxcount = 0\n\tfor stuff in list:\n\t\tif count(list, stuff) > maxcount and count(list, stuff) > 1:\n\t\t\tmaxitem = stuff\n\t\t\tmaxcount = count(list, stuff)\n\t\tif maxcount == 0:\n\t\t\tmaxitem = 'none'\n\treturn maxitem\n\nif n == k:\n\tanswer = 0\n\nelse:\n\tif common(master) == 'none':\n\t\tif n / k <= 2:\n\t\t\treference = master[0]\n\t\t\tanswer = 0\n\t\t\tfor i in range(len(master[1])):\n\t\t\t\tif master[1][i] != reference[i]:\n\t\t\t\t\tanswer += 1\n\n\t\telse:\n\t\t\tanswer = 0\n\t\t\th = []\n\t\t\tfor k in master:\n\t\t\t\tfor m in k:\n\t\t\t\t\th.append(m)\n\t\t\tfor i in h:\n\t\t\t\tif i != (common(h)):\n\t\t\t\t\tanswer += 1\n\telse:\n\t\treference = common(master)\n\t\tanswer = 0\n\t\tfor i in range(len(master)):\n\t\t\tif master[i] != reference:\n\t\t\t\tfor j in range(len(master[i])):\n\t\t\t\t\tif master[i][j] != reference[j]:\n\t\t\t\t\t\tanswer += 1\n\n\nprint(answer)"}, {"source_code": "aa = input().split()\nn = int(aa[0])\nk = int(aa[1])\na = input().split()\n\n\nmaster = []\nnew = []\nfor i in range(1, n + 1):\n\tif i % k == 0:\n\t\tnew.append(a[i - 1])\n\t\tmaster.append(new)\n\t\tnew = []\n\telse:\n\t\tnew.append(a[i-1])\n\ndef count(list, item):\n\tcount = 0\n\tfor c in list:\n\t\tif c == item:\n\t\t\tcount += 1\n\treturn count\n\ndef common(list):\n\tcounts = []\n\tmaxcount = 0\n\tfor stuff in list:\n\t\tif count(list, stuff) > maxcount and count(list, stuff) > 1:\n\t\t\tmaxitem = stuff\n\t\t\tmaxcount = count(list, stuff)\n\t\tif maxcount == 0:\n\t\t\tmaxitem = 'none'\n\treturn maxitem\n\nif n == k:\n\tanswer = 0\n\nelse:\n\tif common(master) == 'none':\n\t\treference = master[0]\n\n\telse:\n\t\treference = common(master)\n\n\tanswer = 0\n\tfor i in range(1, len(master)):\n\t\t\tif master[i] != reference:\n\t\t\t\tfor j in range(len(master[i])):\n\t\t\t\t\tif master[i][j] != reference[j]:\n\t\t\t\t\t\tanswer += 1\n\nprint(answer)"}, {"source_code": "aa = input().split()\nn = int(aa[0])\nk = int(aa[1])\na = input().split()\n\n\nmaster = []\nnew = []\nfor i in range(1, n + 1):\n\tif i % k == 0:\n\t\tnew.append(a[i - 1])\n\t\tmaster.append(new)\n\t\tnew = []\n\telse:\n\t\tnew.append(a[i-1])\n\ndef count(list, item):\n\tcount = 0\n\tfor c in list:\n\t\tif c == item:\n\t\t\tcount += 1\n\treturn count\n\ndef common(list):\n\tcounts = []\n\tmaxcount = 0\n\tfor stuff in list:\n\t\tif count(list, stuff) >= maxcount:\n\t\t\tmaxitem = stuff\n\t\t\tmaxcount = count(list, stuff)\n\treturn maxitem\n\nanswer = 0\n\n\ncheck = True\nfor lists in master:\n\tif count(master, lists) > 1:\n\t\tcheck = False\n\n\n\nif n == k:\n\tanswer = 0\n\nelif check == True:\n\treference = common(a)\n\tfor i in a:\n\t\tif i != reference:\n\t\t\tanswer += 1\n\n\nelif check == False:\n\tfor i in master:\n\t\tref = common(master)\n\t\tif i != ref:\n\t\t\tfor j in range(len(i)):\n\t\t\t\tif i[j] != ref[j]:\n\t\t\t\t\tanswer += 1\nprint(answer)"}, {"source_code": "aa = input().split()\nn = int(aa[0])\nk = int(aa[1])\na = input().split()\n\n\nmaster = []\nnew = []\nfor i in range(1, n + 1):\n\tif i % k == 0:\n\t\tnew.append(a[i - 1])\n\t\tmaster.append(new)\n\t\tnew = []\n\telse:\n\t\tnew.append(a[i-1])\n\ndef count(list, item):\n\tcount = 0\n\tfor c in list:\n\t\tif c == item:\n\t\t\tcount += 1\n\treturn count\n\ndef common(list):\n\tcounts = []\n\tmaxcount = 0\n\tfor stuff in list:\n\t\tif count(list, stuff) > maxcount:\n\t\t\tmaxitem = stuff\n\t\t\tmaxcount = count(list, stuff)\n\treturn maxitem\n\nanswer = 0\n\n\ncheck = True\nfor lists in master:\n\tif count(master, lists) > 1:\n\t\tcheck = False\n\n\n\nif n == k:\n\tanswer = 0\n\nelif check == True:\n\treference = common(a)\n\tfor i in a:\n\t\tif i != reference:\n\t\t\tanswer += 1\n\n\nelif check == False:\n\tfor i in master:\n\t\tref = common(master)\n\t\tif i != ref:\n\t\t\tfor j in range(len(i)):\n\t\t\t\tif i[j] != ref[j]:\n\t\t\t\t\tanswer += 1\nprint(answer)"}, {"source_code": "aa = input().split()\nn = int(aa[0])\nk = int(aa[1])\na = input().split()\n\n\nmaster = []\nnew = []\nfor i in range(1, n + 1):\n\tif i % k == 0:\n\t\tnew.append(a[i - 1])\n\t\tmaster.append(new)\n\t\tnew = []\n\telse:\n\t\tnew.append(a[i-1])\n\ndef count(list, item):\n\tcount = 0\n\tfor c in list:\n\t\tif c == item:\n\t\t\tcount += 1\n\treturn count\n\ndef common(list):\n\tcounts = []\n\tmaxcount = 0\n\tfor stuff in list:\n\t\tif count(list, stuff) >= maxcount:\n\t\t\tmaxitem = stuff\n\t\t\tmaxcount = count(list, stuff)\n\treturn maxitem\n\ncheck = True\nfor lists in master:\n\tif count(master, lists) > 1:\n\t\tcheck = False\n\nanswer = 0\n\nif check ==True:\n\treference = common(a)\n\tfor i in a:\n\t\tif i != reference:\n\t\t\tanswer += 1\n\n\n\n\nif check == False:\n\tfor i in master:\n\t\tref = common(master)\n\t\tif i != ref:\n\t\t\tfor j in range(len(i)):\n\t\t\t\tif i[j] != ref[j]:\n\t\t\t\t\tanswer += 1\nprint(answer)"}, {"source_code": "def main():\n n, k = map(int, input().split())\n arr = list(map(int, input().split()))\n\n answer = min(arr.count(1), arr.count(2))\n answer_now=0\n\n for i in range(n//k):\n now = arr[i*k:(i+1)*k]\n answer_now = 0\n \n for j in range(n):\n if arr[j]!=now[j%k]:\n answer_now+=1\n\n answer = min(answer, answer_now)\n\n print(answer)\n\nmain()\n \n"}, {"source_code": "n, k = map(int,input().split())\ns = list(input().split())\na = n // k\nd = 0\nfor x in range(k):\n\tb = \"\"\n\tc = x\n\tfor y in range(a):\n\t\tb += s[c]\n\t\tc += k\n\tif b.count(\"1\") != 0 and b.count(\"1\") != a:d += 1\nprint(d)\n"}, {"source_code": "#!/usr/bin/python3\n\ndef readln(): return tuple(map(int, input().split()))\n\nn, k = readln()\na = readln()\nans = 0\nfor i in range(n // k):\n cnt = len([1 for j in range(i, n, n // k) if a[j] == 1])\n ans += min(cnt, k - cnt)\nprint(ans)\n"}], "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281"} {"source_code": "n,m=map(int,input().split())\nd=dict()\nfor i in range(1,8):\n d[i]=set()\nfor i in range(m):\n a,b=map(int,input().split())\n d[a].add(b)\n d[b].add(a)\n \nmn=100\n \nfor i in range(1,7):\n for j in range(i+1,8):\n s=d[i]&d[j]\n if len(s)<mn:\n mn=len(s)\n \nprint(m-mn)", "positive_code": [{"source_code": "n, m = map(int, input().split())\n\ng = [[]]*(n+1)\n\n\nfor i in range(m):\n\ta, b = map(int, input().split())\n\tg[a] = g[a][:] + [b]\n\tg[b] = g[b][:] + [a]\n\n\nif n==7:\n\tM = 0\n\tfor i in range(1, n+1):\n\t\tfor j in range(1, n+1):\n\t\t\tif i == j:\n\t\t\t\tcontinue\n\t\t\tN = []\n\t\t\tfor k in g[i]+g[j]:\n\t\t\t\tN.append(k)\n\t\t\tN = set(N)\n\t\t\tnum_edges = m - len(g[i]) - len(g[j]) + len(N)\n\t\t\tM = max(M, num_edges)\n\tprint(min(M, 21))\nelse:\n\tprint(m)\n"}, {"source_code": "n, m = map(int, input().split())\nif n <= 6:\n print(m)\nelse:\n A = []\n for i in range(m):\n x, y = map(int, input().split())\n A.append((min(x, y), max(x, y)))\n Max = 0\n for i in range(1, 7):\n for j in range(i + 1, 8):\n # Consider i ~ j\n S = set()\n for pair in A:\n x, y = pair\n if x == j:\n S.add((i, y))\n elif y == j:\n S.add((min(x, i), max(x, i)))\n else:\n S.add(pair)\n if len(S) == 21:\n print(i, j, S)\n Max = max(Max, len(S))\n print(Max)"}, {"source_code": "n,m=map(int,input().split())\nd=dict()\nfor i in range(1,8):\n d[i]=set()\nfor i in range(m):\n a,b=map(int,input().split())\n d[a].add(b)\n d[b].add(a)\n\nmn=100\nif n<7:\n print(m)\nelse:\n for i in range(1,7):\n for j in range(i+1,8):\n s=d[i]&d[j]\n if len(s)<mn:\n mn=len(s)\n\n print(m-mn)\n \n"}, {"source_code": "n,m=map(int,input().split())\nd=[]\nif n<7:\n print(m)\n exit(0)\nfor i in range(8):\n d.append(set())\nfor i in range(m):\n a,b=map(int,input().split())\n d[a-1].add(b-1)\n d[b-1].add(a-1)\n\nminn=100\nfor i in range(0,7):\n for j in range(0,7):\n ss=d[i]&d[j]\n if len(ss)<minn:\n minn=len(ss)\nprint(m-minn)\n"}, {"source_code": "\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\nadj = [set() for _ in range(7)]\nfor a, b in Edges:\n adj[a].add(b)\n adj[b].add(a)\nif N <= 6:\n ans = M\nelse:\n cnt = 100\n for i in range(7):\n for j in range(i+1, 7):\n cnt = min(cnt, len(adj[i] & adj[j]))\n ans = M-cnt\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nd = [[] for _ in range(n+1)]\nfor _ in range(m):\n x, y = map(int, input().split())\n d[x].append(y)\n d[y].append(x)\nif n < 7:\n print(m)\nelse:\n max1 = -1\n for q in range(1, n):\n for q1 in range(q+1, n+1):\n minus = 0\n for q2 in range(1, n+1):\n if q2 in d[q] and q2 in d[q1]:\n minus += 1\n max1 = max(max1, m-minus)\n print(max1)\n"}, {"source_code": "n, m = map(int, input().split())\nu = []\nfor i in range(n):\n u.append([])\nfor i in range(m):\n a, b = map(int, input().split())\n u[a - 1].append(b - 1)\n u[b - 1].append(a - 1)\nif n < 7 or m == 0:\n print(m)\n exit()\nans = 10\nfor i in range(n):\n for j in range(n):\n ansi = 0\n for k in range(n):\n if i in u[k] and j in u[k]:\n ansi += 1\n ans = min(ans, ansi)\n #print(ansi)\nprint(m - max(ans, 0))\n"}, {"source_code": "n,k=[int(x) for x in input().split()]\ndic={}\nfor i in range(1,7):\n dic[i]=[]\ncounter=0\nopp=0\nfor i in range(k):\n a,b=[int(x) for x in input().split()]\n for i,j in (a,b),(b,a):\n if i not in dic:\n dic[i]=[j]\n else:\n dic[i].append(j)\narr=7\nif n==7:\n for item in dic:\n for elem in dic:\n counter=len(dic[item])\n for i in dic[item]:\n if i not in dic[elem]:\n counter-=1\n arr=min(arr,counter)\n print(max(k-arr,0))\nelse:\n print(k)\n \n"}, {"source_code": "def gns():\n return list(map(int, input().split()))\n\n\ndef ps(st, c, ans):\n if len(st) == 0:\n ans.append(tuple(c))\n nxt = set(st)\n for ci in st:\n c.append(ci)\n nxt.remove(ci)\n ps(nxt, c, ans)\n c.pop()\n nxt.add(ci)\n\n\nst = set(range(6))\nc = []\nmine = []\nps(st, c, mine)\n# x=(1,2,0,3,4,5)\n# print(x in mine)\n# mine=[[1,2,0,3,4,5]]\n\nn, k = gns()\nst = set()\nfor i in range(k):\n a, b = gns()\n a -= 1\n b -= 1\n a, b = min(a, b), max(a, b)\n st.add((a, b))\nans = 0\nfor mi in mine:\n for i in range(7):\n # if m==(1,2,0,3,4,5)and i==2:\n # xxxxxx=0\n m = mi[:i] + (0,) + mi[i:]\n\n nd = set()\n for i in range(7):\n for j in range(i, 7):\n ij = (i, j)\n if ij in st:\n di, dj = m[i], m[j]\n di, dj = min(di, dj), max(di, dj)\n nd.add((di, dj))\n # x = nd.intersection(st)\n l = len(nd)\n # if x!=16:\n # xxxxx=0\n ans = max(l, ans)\n\nprint(ans)"}, {"source_code": "a = list(map(int, input().split()))\nn = a[0]\nm = a[1]\ngraph = {}\nfor i in range(n):\n graph[i + 1] = []\nfor i in range(m):\n a = list(map(int, input().split()))\n graph[a[0]].append(a[1])\n\nif n < 7:\n print(m)\nelse:\n res = 0\n\n DOMINOES = set()\n for i in range(1, 7):\n for j in range(i, 7):\n DOMINOES.add((i, j))\n\n max_dominoes = 0\n for i in range(7):\n for j in range(i + 1, 8):\n nums = [1, 1, 1, 1, 1, 1, 1]\n c = 2\n for k in range(len(nums)):\n if k != j and k != i:\n nums[k] = c\n c += 1\n not_used_dominoes = set(DOMINOES)\n count = 0\n ignored = 0\n for v in graph:\n for child in graph[v]:\n domino = (min(nums[v - 1], nums[child - 1]), max(nums[v - 1], nums[child - 1]))\n if domino in not_used_dominoes:\n count += 1\n not_used_dominoes.remove(domino)\n \n max_dominoes = max(max_dominoes, count)\n if max_dominoes >= m:\n break\n\n print(max_dominoes)"}, {"source_code": "n, m = map(int, input().split())\n\nif n < 7:\n print(m)\nelse:\n g = []\n for i in range(7):\n g.append(set())\n\n for _ in range(m):\n x, y = map(int, input().split())\n g[x-1].add(y)\n g[y-1].add(x)\n\n mn = 1000\n for i in range(7):\n for j in range(i+1,7):\n\n s = g[i] & g[j]\n\n if len(s) < mn:\n mn = len(s)\n\n print(m - mn)\n"}, {"source_code": "a = list(map(int, input().split()))\nn = a[0]\nm = a[1]\ngraph = {}\nfor i in range(n):\n graph[i + 1] = []\nfor i in range(m):\n a = list(map(int, input().split()))\n graph[a[0]].append(a[1])\n\nif n < 7:\n print(m)\nelse:\n vertices = []\n for k in graph.keys():\n vertices.append((k, len(graph[k])))\n sorted_vertices = sorted(vertices, key=lambda x: x[1])\n minimum_dominoes = 0\n for i in range(1, len(sorted_vertices)):\n if sorted_vertices[0][0] in graph[sorted_vertices[i][0]]:\n minimum_dominoes += sorted_vertices[i][1] - 1\n else:\n minimum_dominoes += sorted_vertices[i][1] - 1\n\n res = 0\n nums = [1, 1, 1, 1, 1, 1, 1]\n\n DOMINOES = set()\n for i in range(1, 7):\n for j in range(i, 7):\n DOMINOES.add((i, j))\n\n max_dominoes = 0\n while True:\n not_used_dominoes = set(DOMINOES)\n count = 0\n ignored = 0\n for v in graph:\n for child in graph[v]:\n domino = (min(nums[v - 1], nums[child - 1]), max(nums[v - 1], nums[child - 1]))\n if domino in not_used_dominoes:\n count += 1\n not_used_dominoes.remove(domino)\n else:\n ignored += 1\n if ignored > m - minimum_dominoes:\n break\n max_dominoes = max(max_dominoes, count)\n if max_dominoes >= m:\n break\n j = len(nums) - 1\n while nums[j] == 6:\n nums[j] = 1\n j -= 1\n if j < 1:\n break\n nums[j] = nums[j] + 1\n\n print(max_dominoes)"}, {"source_code": "import sys\n\nlines = []\nfor Line in sys.stdin:\n lines.append(Line.rstrip('\\n'))\n\n\n\n# lines=[\"7 11\",\n# \"4 7\",\n# \"6 4\",\n# \"5 1\",\n# \"1 4\",\n# \"5 4\",\n# \"1 2\",\n# \"3 4\",\n# \"4 2\",\n# \"6 1\",\n# \"3 1\",\n# \"7 1\"]\n\n\nn,m = list(map(int,lines[0].split()))\ndel(lines[0])\n\n#G=[[] for _ in range(n)]\nG=[[0 for i in range(n)] for j in range(n)]\nfor i in range(m):\n a,b=list(map(int,lines[i].split()))\n a = a-1\n b = b-1\n G[a][b]=1\n G[b][a]=1\n\nif (n<=6):\n\tprint(m)\n\texit(0)\nelse:\n ctr = 2e9;\n for i in range(n):\n for k in range(n):\n temp = 0\n for j in range(n): \n if(G[i][j]==1 and G[k][j]==1):\n \ttemp+=1\n ctr = min(ctr, temp)\n print(m-ctr)\n\n"}, {"source_code": "n,m = map(int,input().split())\nl =[[] for _ in range(n)]\nfor i in range(m):\n\tk,p = map(int,input().split())\n\tl[k-1].append(p)\n\tl[p-1].append(k)\nif n<7 or m==0:\n\tprint(m)\nelse:\n\tk = [len(l[i]) for i in range(n)]\n\tmi=9999\n\tfor i in range(n):\n\t for j in range(i+1,n):\n\t x = len(set(l[i]).union(set(l[j])))# if (i+1) in l[j] else len(set(l[i]).union(set(l[j])))\n\t x = k[i]+k[j]-x\n\t if mi>x:\n\t mi = x\n\tprint(m - mi)"}, {"source_code": "from itertools import *\nn,m=map(int,input().split())\ne = [tuple(int(s)-1 for s in input().split()) for _ in range(m)]\nprint(max(len(set(tuple(sorted([p[a],p[b]])) for a,b in e)) for p in permutations(i%6 for i in range(n))))"}, {"source_code": "n,m = [int(x) for x in input().split()]\n\np = []\nfor x in range(m):\n t = sorted([int(x) for x in input().split()])\n p.append((t[0],t[1]))\n\nif (n < 7):\n print(m)\n exit(0)\n\nres = 0\n\nfor i in range(1,8):\n for j in range(1,8):\n if i == j: continue\n p1 = []\n for u,v in p:\n t = [u,v]\n if u == i:\n t = sorted([j,v])\n elif v == i:\n t = sorted([j,u])\n p1.append((t[0],t[1]))\n res = max(res , len(set(p1)))\n\nprint(res)"}, {"source_code": "def dominoes(n,m,edges):\n if n<=6:\n return m\n if m==0:\n return 0\n mscore=7\n for a in range(1,7):\n for b in range(a):\n score=codeg(a,b,edges)\n if score<mscore:\n mscore=score\n return m-mscore\n\ndef codeg(a,b,edges):\n c=0\n for x in range(7):\n if x==a:\n continue\n if x==b:\n continue\n if ([a,x] in edges) or ([x,a] in edges):\n if ([b,x] in edges) or ([x,b] in edges):\n c+=1\n return c\n\nn,m=map(int,input().split())\ned=[]\nfor x in range(m):\n a,b=map(int,input().split())\n a-=1\n b-=1\n ed.append([a,b])\n \nprint(dominoes(n,m,ed))\n"}, {"source_code": "n=list(map(int,input().split()))\ne=n[1]\nn=n[0]\nd={}\nfor itr in range(1,n+1):\n d[itr]=[]\nfor i in range(e):\n a=list(map(int,input().split()))\n d[a[0]].append(a[1])\n d[a[1]].append(a[0])\nif n<=6:\n print(e)\nelse:\n asdf=[]\n for ii in range(1,8):\n ans=e-len(d[ii])\n if ii!=7:\n d[ii],d[7]=d[7],d[ii]\n for i in d:\n for j in range(len(d[i])):\n if d[i][j]==ii: d[i][j]=7\n elif d[i][j]==7: d[i][j]=ii\n domino=[(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(2,2),(2,3),(2,4),(2,5),(2,6),(3,3),(3,4),(3,5),(3,6),(4,4),(4,5),(4,6),(5,5),(5,6),(6,6)]\n for i in range(1,7):\n for j in d[i]:\n if j==7 or j<i: continue\n else: domino.remove((i,j))\n #print(domino)\n for i in domino:\n if (i[0] in d[7]) or (i[1] in d[7]): continue\n else: domino.remove(i)\n dd={}\n possible=0\n for i in range(1,7):\n count=0\n for itr in domino:\n if itr[0]==i:\n if itr[1] in d[7]: count+=1\n elif itr[1]==i:\n if itr[0] in d[7]: count+=1\n possible=max(count,possible)\n asdf.append(ans+possible)\n print(max(asdf))"}, {"source_code": "n, m = input().split()\nn, m = int(n), int(m)\nedges = [[] for x in range(n)]\nfor i in range(m):\n a, b = input().split()\n a, b = int(a), int(b)\n ma = max(a, b)\n mi = min(a, b)\n edges[mi-1].append((ma-1))\n edges[ma-1].append((mi-1))\n# print(edges)\n# find lowest degree:\n\nxxx=[]\nif n<=6:\n print(m)\nelse:\n for i in range(n):\n for j in range(i):\n xxx.append(set(edges[i]).intersection(set(edges[j])))\n# print(xxx)\n p = [len(z) for z in xxx]\n print(m-min(p))"}, {"source_code": "n , m = map(int,input().split())\nlis=[]\nfor i in range(7):\n lis.append(set())\nfor i in range(m):\n a , b = map(int,input().split())\n lis[a-1].add(b)\n lis[b-1].add(a)\nif n<=6:\n print(m) \nelse:\n ma=1000000\n for i in range(7):\n for j in range(i+1,7):\n s=lis[i] & lis[j]\n if len(s)<ma:\n ma =len(s)\n print(m-ma)\n"}, {"source_code": "n,m=map(int,input().split())\nd=[[] for i in range(n+1)]\nfor x in range(m):\n a,b=map(int,input().split())\n d[a].append(b)\n d[b].append(a)\nif n<7:\n print(m)\nelse:\n ans=-1\n for i in range(1,n):\n for j in range(i+1,n+1):\n sub=0\n for k in range(1,n+1):\n if k in d[i] and k in d[j]:\n sub+=1\n ans=max(ans,m-sub)\n print(ans)"}, {"source_code": "from collections import defaultdict\nnumber, mumber = map(int, input().split())\ngraphical = defaultdict(set)\nfor _ in range(mumber):\n a, b = map(int, input().split())\n graphical[a].add(b)\n graphical[b].add(a)\n \nanswer = 100\nfor i in range(1, 7):\n for j in range(i + 1, 8):\n g = graphical[i] & graphical[j]\n answer = min(answer, len(g))\nprint(mumber - answer)"}, {"source_code": "#encoding:utf-8\nimport math\nclass Rookie(object):\n\n def _input(self):\n l1 = raw_input()\n l1 = l1.split()\n n, m = int(l1[0]), int(l1[1])\n edge = []\n for _ in range(m):\n l2 = raw_input()\n l2 = l2.split()\n a,b = int(l2[0]), int(l2[1])\n edge.append([a,b])\n return n, m, edge\n\n def gen(self, status, numb, n, k):\n '''\n n ge shu\n '''\n if k == n + 1:\n self.status.append(status[:])\n return\n # None\n for idx, b in enumerate(numb):\n if b == 0:\n continue\n status[k] = idx + 1\n numb[idx] -= 1\n self.gen(status, numb, n, k+1)\n numb[idx] += 1\n self.gen(status, numb, n, k + 1)\n\n def _output(self):\n pass\n\n def solve(self):\n n,m,edge = self._input()\n self.status = []\n self.gen([-1]*(n+1), [1]*min(n,6), n, 1)\n dom = [[0]*7 for _ in range(7)]\n for a in range(1,7):\n for b in range(a,7):\n dom[a][b] = 1\n ret = 0\n #print (len(self.status))\n for status in self.status:\n tmp_ret = 0\n flag = 1\n use_d = []\n #print (status)\n #status = [-1, 1,2,3,4,5,6,-1]\n for idx, E in enumerate(edge):\n v1, v2 = E[0], E[1]\n s1 = status[v1]\n s2 = status[v2]\n if s1 == -1 or s2 == -1:\n continue\n #print (v1, v2, s1, s2, dom[s1][s2])\n if s1 > s2:\n s1,s2 = s2,s1\n if dom[s1][s2] == 0:\n #flag = 0\n #break\n continue\n dom[s1][s2] = 0\n use_d.append((s1,s2))\n tmp_ret += 1\n if m - idx - 1 + tmp_ret < ret:\n break\n #print (flag)\n #break\n #print (flag)\n if flag:\n ret = max(ret, tmp_ret)\n for a,b in use_d:\n dom[a][b] = 1\n if ret == m:\n break\n #break\n print ret\n\nif __name__ == '__main__':\n #print Rookie().pow(3,1)\n #print Rookie().cal(3,1)\n Rookie().solve()"}, {"source_code": "#!/usr/bin/env python3\n\n\nsecondApproach = True\n\n\ndef calculatePossibleIncrease(setMain: set, setLeft: set, setMainIndex: int):\n directDelta = len(setMain.union(setLeft).difference(\n setMain.union({setMainIndex})))\n\n indirectDelta = len(setLeft.intersection({setMainIndex})) # x <-> x\n\n return directDelta + indirectDelta\n\n\ndef calculateMaxPossibleEdges(verts, leftOutVertIndex):\n tempSetEdgesCount = len(verts[leftOutVertIndex])\n\n retVal = -1\n for i in range(len(verts)):\n if len(verts[i]) == tempSetEdgesCount or secondApproach:\n retVal = max(\n retVal,\n calculatePossibleIncrease(\n verts[i], verts[leftOutVertIndex], i)\n )\n\n return retVal\n\n\ndef calculateDirectAnswer(verts, leftOutVertIndex):\n doubleEdgeCount = 0\n for i in range(len(verts)):\n if i != leftOutVertIndex:\n doubleEdgeCount += len(verts[i].difference({leftOutVertIndex}))\n return doubleEdgeCount // 2\n\n\ndef main():\n vertsCount, edgesCount = tuple(map(int, input('').split(' ')))\n\n if(vertsCount < 7):\n print(edgesCount)\n exit(0)\n\n verts = []\n for i in range(vertsCount):\n verts.append(set())\n\n for _t in range(edgesCount):\n _x, _y = tuple(\n map(lambda x: int(x) - 1, input('').split(' '))\n )\n\n verts[_x].add(_y)\n verts[_y].add(_x)\n\n edgesCount = [len(y) for y in verts]\n minEdgesCount = min(edgesCount)\n\n directAnswer = -1\n indirectAnswer = -1\n answer = -1\n for i in range(vertsCount):\n if len(verts[i]) == minEdgesCount or secondApproach:\n directAnswer = calculateDirectAnswer(verts, i)\n indirectAnswer = calculateMaxPossibleEdges(verts, i)\n\n answer = max(answer, directAnswer + indirectAnswer)\n\n return answer\n\n\nif __name__ == '__main__':\n print(main())\n"}, {"source_code": "'''\ndominos = []\nfor i in range(1,7):\n\tfor j in range(i, 7):\n\t\t\tdominos.append((i,j))\n\ndominos_start_from = {}\n\nfor val in dominos:\n\t\ta, b = val\n\t\ttry:\n\t\t\tdominos_start_from[a].append((a,b))\n\t\texcept KeyError:\n\t\t\tdominos_start_from[a] = [(a,b)]\n\n\t\ttry:\n\t\t\tdominos_start_from[b].append((b,a))\n\t\texcept KeyError:\n\t\t\tdominos_start_from[b] = [(b,a)]\n'''\nnm = raw_input();\nedges = []\nn, m = nm.strip().split();\nm = int(m)\nn = int(n)\ngraph = {}\n\nfor i in range(m):\n\t\tuv = raw_input()\n\t\tu, v = uv.strip().split()\n\t\tu = int(u)\n\t\tv = int(v)\n\t\tedges.append((u,v))\n\n\t\ttry:\n\t\t\tgraph[u].append(v)\n\t\t\tgraph[v].append(u)\n\t\texcept KeyError:\n\t\t\tgraph[u] = [v]\n\t\t\tgraph[v] = [u]\n\n\nans = [0]\nvertex = {}\nnodes = graph.keys()\nn_nodes = len(nodes)\n\ndegree = {}\n\nfor node in nodes:\n\tdegree[node] = len(graph[node])\n\ndef compute():\n\tval = 0;\n\tpairs = {}\n\tfor val in edges:\n\t\ta,b = val\n\t\ta = vertex[a]\n\t\tb = vertex[b]\n\t\tif a and b:\n\t\t\t\ta,b = min(a,b), max(a,b)\n\t\t\t\tpairs[(a,b)] = True\n\tans[0] = max(ans[0], len(pairs.keys()))\n\nfreq = {}\ndef dfs1(idx):\n\tif idx >= n_nodes:\n\t\tcompute()\n\t\treturn\n\tnode = nodes[idx]\n\tfor val in range(1,7):\n\t\tfv = freq.get(val,0)\n\t\tif fv < 6:\n\t\t\tvertex[node] = val\n\t\t\tfreq[val] = fv + degree.get(node, 0)\n\t\t\tdfs1(idx+1)\n\t\t\tvertex[node] = 0\n\t\t\tfreq[val] = fv\n\ndfs1(0);\nprint ans[0];\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\n\nif n <= 6:\n for i in range(m):\n input()\n print(m)\n exit()\n\ngraph = [set() for _ in range(7)]\n\nfor i in range(m):\n edge = [int(x) - 1 for x in input().split()]\n u = edge[0]\n v = edge[1]\n graph[u].add(v)\n graph[v].add(u)\n\nanswer = 0\n\nfor i, u in enumerate(graph):\n for j, v in enumerate(graph):\n if i == j:\n continue\n intersectionLength = len(u.intersection(v))\n answer = max(answer, m - intersectionLength)\n\n\nprint(answer)\n"}, {"source_code": "n,m=map(int,input().split())\nif n<7:\n print(m)\n exit()\nelse:\n graph=[[0]*7 for i in range(n)]\n for i in range(m):\n s1,s2=map(int,input().split())\n graph[s1-1][s2-1]=1\n graph[s2-1][s1-1]=1\n ans=0\n for i in range(n):\n used=[0]*n\n for j in range(n):\n if graph[i][j]==1:\n for i1 in range(n):\n if i1!=i and graph[j][i1]!=1:\n used[i1]+=1\n ans=max(max(used)+m-sum(graph[i]),ans)\nprint(ans)"}, {"source_code": "n, m = list(map(int, input().split()))\n\na=[]\nb=[]\n\nfor _ in range(m):\n aa, bb = list(map(int, input().split()))\n if (bb < aa):\n aa,bb = bb,aa\n a.append(aa)\n b.append(bb)\n\nif (n <= 6):\n print(m)\nelse:\n \n maxv = 0\n for i in range(1, n + 1):\n for j in range(i + 1, n + 1):\n alle = m\n minuse = 0\n tk = []\n for k in range(len(a)):\n if (i == a[k] and j != b[k]):\n alle -= 1\n tk.append(b[k])\n elif (i != a[k] and j == b[k]):\n alle -= 1\n tk.append(a[k])\n elif (i == b[k] and j != a[k]):\n alle -= 1\n tk.append(a[k])\n elif (i != b[k] and j == a[k]):\n alle -= 1\n tk.append(b[k])\n #print(alle)\n #print('set' + str(len(set(tk))))\n #exit(0)\n alle += len(set(tk))\n maxv = max(alle, maxv)\n print(maxv)\n\n \n \n"}, {"source_code": "n, m = map(int, input().split())\ngraph = [[] for _ in range(n)]\nfor _ in range(m):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n graph[u].append(v)\n graph[v].append(u)\nmaxcnt = 0\nfor node1 in range(n):\n for node2 in range(node1 + 1, n):\n used = [[False] * n for _ in range(n)]\n col = list(range(0, node2)) + [node1] + list(range(node2 + 1, n))\n cnt = 0\n for u in range(n):\n for v in graph[u]:\n if not used[col[u]][col[v]]:\n used[col[u]][col[v]] = used[col[v]][col[u]] = True\n cnt += 1\n maxcnt = max(cnt, maxcnt)\nprint(maxcnt if n > 6 else m)\n"}, {"source_code": "n, m = map(int, input().split())\ns = [[0 for i in range(n)] for i2 in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n s[a - 1][b - 1] = 1\n s[b - 1][a - 1] = 1\nif n == 7:\n mass = []\n for i in range(n):\n for i2 in range(n):\n k = 0\n for i3 in range(n):\n if s[i][i3] == 1 and s[i2][i3] == 1:\n k += 1\n mass += [k]\n m -= min(mass)\nprint(m)\n"}, {"source_code": "import itertools\nn,m = list(map(int,input().split()))\narr = []\nfor i in range(n):\n arr.append([])\nfor i in range(m):\n a,b = list(map(int,input().split()))\n a-=1\n b-=1\n arr[a].append(b)\n arr[b].append(a)\npermuts = list(itertools.permutations(list(range(7))))\nans = 0\nfor i in range(len(permuts)):\n permut = permuts[i]\n was = []\n for i in range(6):\n was.append([False]*6)\n c = 0\n for i in range(n):\n if permut[i] != 6:\n for g in range(len(arr[i])):\n if not permut[arr[i][g]] == 6:\n if not was[permut[i]][permut[arr[i][g]]]:\n c+=1\n was[permut[i]][permut[arr[i][g]]] = True\n was[permut[arr[i][g]]][permut[i]] = True\n for w in range(n):\n if permut[w] == 6:\n ams = [0]*6\n for g in range(len(arr[w])):\n for j in range(6):\n if not was[permut[arr[w][g]]][j]:\n ams[j]+=1\n c+=max(ams)\n break\n\n\n\n ans = max(ans,c)\nprint(ans)\n"}, {"source_code": "n,m = [int(j) for j in input().split()]\nadj = [set() for i in range(n)]\nfor i in range(m):\n\tl, r = [int(j)-1 for j in input().split()]\n\tadj[l].add(r)\n\tadj[r].add(l)\nif n<7:\n\tprint(m)\nelse:\n\tdeg = 1e12\n\tfor i in range(n):\n\t\tfor j in range(i+1, n):\n\t\t\tl = adj[i].intersection(adj[j])\n\t\t\t# print(l)\n\t\t\ttmp = len(l)\n\t\t\tif tmp<deg:\n\t\t\t\tdeg = tmp\n\t\t# deg = min(len(adj[i]), deg)\n\t# deg = ma\n\t# print(deg)\n\tprint(m-deg)"}, {"source_code": "n,m = [int(j) for j in input().split()]\nadj = [set() for i in range(n)]\nfor i in range(m):\n\tl, r = [int(j)-1 for j in input().split()]\n\tadj[l].add(r)\n\tadj[r].add(l)\nif n<7:\n\tprint(m)\nelse:\n\tdeg = 10**12\n\tfor i in range(n):\n\t\tfor j in range(i+1, n):\n\t\t\tl = adj[i].intersection(adj[j])\n\t\t\ttmp = len(l)\n\t\t\tif tmp<deg:\n\t\t\t\tdeg = tmp\n\tprint(m-deg)\n"}, {"source_code": "n,m = [int(j) for j in input().split()]\nadj = [set() for i in range(n)]\nfor i in range(m):\n\tl, r = [int(j)-1 for j in input().split()]\n\tadj[l].add(r)\n\tadj[r].add(l)\nif n<7:\n\tprint(m)\nelse:\n\tmaxi = 10**12\n\tfor i in range(n):\n\t\tfor j in range(i+1, n):\n\t\t\tl = adj[i].intersection(adj[j])\n\t\t\ttmp = len(l)\n\t\t\tif tmp<maxi:\n\t\t\t\tmaxi = tmp\n\tprint(m-maxi)\n"}, {"source_code": "n,m = map(int,raw_input().split(\" \"))\nedges = []\ncolors = [0]*n\nfor i in range(m):\n\ta,b = map(int,raw_input().split(\" \"))\n\tedges.append((a-1,b-1))\n\n\n\nif n <= 6:\n\tprint m\nelse:\n\tret = []\n\tfor i in range(n):\n\t\tfor j in range(i):\n\t\t\tcolors = [0]*n\n\t\t\tvisited = [0]*100\n\t\t\tcnt = 2\n\t\t\tans = 0\n\t\t\tcolors[i] = 1\n\t\t\tcolors[j] = 1\n\t\t\tfor k in range(n):\n\t\t\t\tif colors[k] == 0:\n\t\t\t\t\tcolors[k]= cnt\n\t\t\t\t\tcnt += 1\n\t\t\tfor a,b in edges:\n\t\t\t\tx = colors[a] \n\t\t\t\ty = colors[b]\n\t\t\t\tx,y=min(x,y),max(x,y)\n\t\t\t\tif not visited[x*10+y]:\n\t\t\t\t\tvisited[x*10+y] = 1\n\t\t\t\t\tans += 1\n\t\t\tret.append(ans)\n\tprint max(ret)\n"}, {"source_code": "from collections import Counter,defaultdict\nfrom sys import stdin\nraw_input = stdin.readline\nn,m=map(int,raw_input().split())\nif n<=6:\n for i in xrange(m):\n raw_input()\n print m\nelse:\n edge=[]\n ans=0\n for i in xrange(m):\n edge.append(((map(int,raw_input().split()))))\n for a in xrange(1,7):\n for b in xrange(1,7):\n for c in xrange(1,7):\n for d in xrange(1,7):\n for e in xrange(1,7):\n for f in xrange(1,7):\n for g in xrange(1,7):\n x=defaultdict(Counter)\n l=[0,a,b,c,d,e,f,g]\n c1=0\n for u,v in edge:\n if not x[max(l[u],l[v])][min(l[v],l[u])]:\n x[max(l[u],l[v])][min(l[v],l[u])]=1\n c1+=1\n ans=max(ans,c1)\n print ans \n"}, {"source_code": "# ---------------------------iye ha aam zindegi---------------------------------------------\nimport math\nimport heapq, bisect\nimport sys\nfrom collections import deque, defaultdict\nfrom fractions import Fraction\nimport sys\nmod = 10 ** 9 + 7\nmod1 = 998244353\n\n# ------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass TreeNode:\n def __init__(self, k, v):\n self.key = k\n self.value = v\n self.left = None\n self.right = None\n self.parent = None\n self.height = 1\n self.num_left = 1\n self.num_total = 1\n\n\nclass AvlTree:\n\n def __init__(self):\n self._tree = None\n\n def add(self, k, v):\n if not self._tree:\n self._tree = TreeNode(k, v)\n return\n node = self._add(k, v)\n if node:\n self._rebalance(node)\n\n def _add(self, k, v):\n node = self._tree\n while node:\n if k < node.key:\n if node.left:\n node = node.left\n else:\n node.left = TreeNode(k, v)\n node.left.parent = node\n return node.left\n elif node.key < k:\n if node.right:\n node = node.right\n else:\n node.right = TreeNode(k, v)\n node.right.parent = node\n return node.right\n else:\n node.value = v\n return\n\n @staticmethod\n def get_height(x):\n return x.height if x else 0\n\n @staticmethod\n def get_num_total(x):\n return x.num_total if x else 0\n\n def _rebalance(self, node):\n\n n = node\n while n:\n lh = self.get_height(n.left)\n rh = self.get_height(n.right)\n n.height = max(lh, rh) + 1\n balance_factor = lh - rh\n n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)\n n.num_left = 1 + self.get_num_total(n.left)\n\n if balance_factor > 1:\n if self.get_height(n.left.left) < self.get_height(n.left.right):\n self._rotate_left(n.left)\n self._rotate_right(n)\n elif balance_factor < -1:\n if self.get_height(n.right.right) < self.get_height(n.right.left):\n self._rotate_right(n.right)\n self._rotate_left(n)\n else:\n n = n.parent\n\n def _remove_one(self, node):\n \"\"\"\n Side effect!!! Changes node. Node should have exactly one child\n \"\"\"\n replacement = node.left or node.right\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = replacement\n else:\n node.parent.right = replacement\n replacement.parent = node.parent\n node.parent = None\n else:\n self._tree = replacement\n replacement.parent = None\n node.left = None\n node.right = None\n node.parent = None\n self._rebalance(replacement)\n\n def _remove_leaf(self, node):\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = None\n else:\n node.parent.right = None\n self._rebalance(node.parent)\n else:\n self._tree = None\n node.parent = None\n node.left = None\n node.right = None\n\n def remove(self, k):\n node = self._get_node(k)\n if not node:\n return\n if AvlTree._is_leaf(node):\n self._remove_leaf(node)\n return\n if node.left and node.right:\n nxt = AvlTree._get_next(node)\n node.key = nxt.key\n node.value = nxt.value\n if self._is_leaf(nxt):\n self._remove_leaf(nxt)\n else:\n self._remove_one(nxt)\n self._rebalance(node)\n else:\n self._remove_one(node)\n\n def get(self, k):\n node = self._get_node(k)\n return node.value if node else -1\n\n def _get_node(self, k):\n if not self._tree:\n return None\n node = self._tree\n while node:\n if k < node.key:\n node = node.left\n elif node.key < k:\n node = node.right\n else:\n return node\n return None\n\n def get_at(self, pos):\n x = pos + 1\n node = self._tree\n while node:\n if x < node.num_left:\n node = node.left\n elif node.num_left < x:\n x -= node.num_left\n node = node.right\n else:\n return (node.key, node.value)\n raise IndexError(\"Out of ranges\")\n\n @staticmethod\n def _is_left(node):\n return node.parent.left and node.parent.left == node\n\n @staticmethod\n def _is_leaf(node):\n return node.left is None and node.right is None\n\n def _rotate_right(self, node):\n if not node.parent:\n self._tree = node.left\n node.left.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.left\n node.left.parent = node.parent\n else:\n node.parent.right = node.left\n node.left.parent = node.parent\n bk = node.left.right\n node.left.right = node\n node.parent = node.left\n node.left = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n def _rotate_left(self, node):\n if not node.parent:\n self._tree = node.right\n node.right.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.right\n node.right.parent = node.parent\n else:\n node.parent.right = node.right\n node.right.parent = node.parent\n bk = node.right.left\n node.right.left = node\n node.parent = node.right\n node.right = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n @staticmethod\n def _get_next(node):\n if not node.right:\n return node.parent\n n = node.right\n while n.left:\n n = n.left\n return n\n\n\n# -----------------------------------------------binary seacrh tree---------------------------------------\nclass SegmentTree1:\n def __init__(self, data, default='z', func=lambda a, b: min(a, b)):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass SegmentTree:\n def __init__(self, data, default=0, func=lambda a, b: a + b):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------------------iye ha chutiya zindegi-------------------------------------\nclass Factorial:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorials = [1, 1]\n self.invModulos = [0, 1]\n self.invFactorial_ = [1, 1]\n\n def calc(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.factorials):\n return self.factorials[n]\n nextArr = [0] * (n + 1 - len(self.factorials))\n initialI = len(self.factorials)\n prev = self.factorials[-1]\n m = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = prev * i % m\n self.factorials += nextArr\n return self.factorials[n]\n\n def inv(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n^(-1)\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n p = self.MOD\n pi = n % p\n if pi < len(self.invModulos):\n return self.invModulos[pi]\n nextArr = [0] * (n + 1 - len(self.invModulos))\n initialI = len(self.invModulos)\n for i in range(initialI, min(p, n + 1)):\n next = -self.invModulos[p % i] * (p // i) % p\n self.invModulos.append(next)\n return self.invModulos[pi]\n\n def invFactorial(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate (n^(-1))!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.invFactorial_):\n return self.invFactorial_[n]\n self.inv(n) # To make sure already calculated n^-1\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\n initialI = len(self.invFactorial_)\n prev = self.invFactorial_[-1]\n p = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\n self.invFactorial_ += nextArr\n return self.invFactorial_[n]\n\n\nclass Combination:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorial = Factorial(MOD)\n\n def ncr(self, n, k):\n if k < 0 or n < k:\n return 0\n k = min(k, n - k)\n f = self.factorial\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\n\n\n# --------------------------------------iye ha combinations ka zindegi---------------------------------\ndef powm(a, n, m):\n if a == 1 or n == 0:\n return 1\n if n % 2 == 0:\n s = powm(a, n // 2, m)\n return s * s % m\n else:\n return a * powm(a, n - 1, m) % m\n\n\n# --------------------------------------iye ha power ka zindegi---------------------------------\ndef sort_list(list1, list2):\n zipped_pairs = zip(list2, list1)\n\n z = [x for _, x in sorted(zipped_pairs)]\n\n return z\n\n\n# --------------------------------------------------product----------------------------------------\ndef product(l):\n por = 1\n for i in range(len(l)):\n por *= l[i]\n return por\n\n\n# --------------------------------------------------binary----------------------------------------\ndef binarySearchCount(arr, n, key):\n left = 0\n right = n - 1\n\n count = 0\n\n while (left <= right):\n mid = int((right + left) / 2)\n\n # Check if middle element is\n # less than or equal to key\n if (arr[mid] < key):\n count = mid + 1\n left = mid + 1\n\n # If key is smaller, ignore right half\n else:\n right = mid - 1\n\n return count\n\n\n# --------------------------------------------------binary----------------------------------------\ndef countdig(n):\n c = 0\n while (n > 0):\n n //= 10\n c += 1\n return c\ndef binary(x, length):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\ndef countGreater(arr, n, k):\n l = 0\n r = n - 1\n\n # Stores the index of the left most element\n # from the array which is greater than k\n leftGreater = n\n\n # Finds number of elements greater than k\n while (l <= r):\n m = int(l + (r - l) / 2)\n if (arr[m] >= k):\n leftGreater = m\n r = m - 1\n\n # If mid element is less than\n # or equal to k update l\n else:\n l = m + 1\n\n # Return the count of elements\n # greater than k\n return (n - leftGreater)\n\n\n# --------------------------------------------------binary------------------------------------\nn,k=map(int,input().split())\ngraph=defaultdict(list)\ntot=[6,6,6,6,6,6,6]\ne=[]\nfor i in range(k):\n a,b=map(int,input().split())\n graph[a].append(b)\n graph[b].append(a)\n e.append((a,b))\nif n<=6:\n print(k)\n sys.exit(0)\nelse:\n ans=k\n for i in range(7):\n tot=set()\n for ie in range(1,8):\n for j in range(ie,8):\n tot.add((ie,j))\n #print(tot)\n cur = len(graph[i + 1])\n for j in range(k):\n if e[j][0] == i + 1 or e[j][1] == i + 1:\n continue\n tot.remove((min(e[j][1],e[j][0]),max(e[j][0],e[j][1])))\n #print(tot)\n check=set()\n for j in range(k):\n if e[j][0] == i + 1:\n check.add(e[j][1])\n elif e[j][1] == i + 1:\n check.add(e[j][0])\n we=0\n for i1 in range(1,8):\n d=0\n if i1==i+1:\n continue\n for j1 in check:\n if (min(j1,i1),max(j1,i1)) in tot:\n d+=1\n we=max(we,d)\n ans=min(ans,cur-we)\n print(min(k,k-ans))\n\n"}, {"source_code": "from sys import stdin\nfrom itertools import product\nfrom copy import copy\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrints_2d = lambda n: [tuple(sorted(rints())) for _ in range(n)]\n\nn, m = rints()\nedges, all, ans = rints_2d(m), set(), 0\n\nfor i in range(1, 7):\n for j in range(i, 7):\n all.add((i, j))\n\nfor mem in product([1, 2, 3, 4, 5, 6], repeat=7):\n dis, tem = copy(all), 0\n for u, v in edges:\n if (mem[u - 1], mem[v - 1]) in dis:\n dis.discard((mem[u - 1], mem[v - 1]))\n tem += 1\n \n ans = max(ans, tem)\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\n\nd = [0 for i in range(7)]\ng = [[] for i in range(7)]\n\nfor i in range(m):\n\tx, y = map(int, input().split())\n\tx -= 1\n\ty -= 1\n\td[x] += 1\n\td[y] += 1\n\t\n\tg[x].append(y)\n\tg[y].append(x)\n\t\nmn = min(d)\nfor i in range(7):\n\tfor j in range(i):\n\t\tcnt = 0\n\t\tfor k in range(7):\n\t\t\tif((k in g[i]) and (k in g[j])):\n\t\t\t\tcnt += 1\n\t\tmn = min(mn, cnt)\nm -= mn\nprint(m) "}, {"source_code": "import sys\nimport collections\nimport itertools\n\nif sys.version_info[0] == 2:\n\tinput = raw_input\n\ndef solve2(graph, edges, mapping):\n\trmapping = {v: k for k, v in mapping.items()}\n\tdoms = set()\n\tfor i in range(1, 7):\n\t\tfor j in range(i, 7):\n\t\t\tdoms.add((i, j))\n\t\t\t\n\tanswer = 0\n\tfor (a, b) in edges:\n\t\tif mapping[a] <= 6 and mapping[b] <= 6:\n\t\t\tanswer += 1\n\t\t\tdom = (mapping[a], mapping[b])\n\t\t\tif dom[0] > dom[1]:\n\t\t\t\tdom = (dom[1], dom[0])\n\t\t\tdoms.remove(dom)\n\t\n\tD = [[0 for i in range(7)] for j in range(7)]\n\tfor (a, b) in doms:\n\t\tD[a][b] = 1\n\t\n\tif 7 in rmapping:\n\t\tcandidates = [mapping[v] for v in graph[rmapping[7]]]\n\t\tanswer += max([sum([D[z][j] for z in candidates]) for j in range(1, 7)])\n\n\treturn answer\n\n\ndef solve():\n\tn, m = map(int, input().split())\n\tgraph = collections.defaultdict(set)\n\tcounts = collections.defaultdict(int)\n\tedges = set()\n\tmapping = {}\n\trmapping = {}\n\t\n\tfor i in range(m):\n\t\ta, b = map(int, input().split())\n\t\tedges.add((a, b))\n\t\tgraph[a].add(b)\n\t\tgraph[b].add(a)\n\t\n\tif n <= 6:\n\t\treturn m\n\t\n\tanswer = 0\n\tfor p in itertools.permutations(range(1, n + 1)):\n\t\tmapping = dict(zip(range(1, n + 1), p))\n\t\tanswer = max(answer, solve2(graph, edges, mapping))\n\treturn answer\n\t\nprint(solve())"}, {"source_code": "from __future__ import print_function,division\nn,m=map(int,raw_input().split())\nif n<7:\n print(m)\nelse:\n l=[[] for k in range(n)]\n for i in range(m):\n a,b=map(int,raw_input().split())\n a-=1\n b-=1\n l[a].append(b)\n l[b].append(a)\n print(m-min([sum((i in l[a]) and (i in l[b]) for i in range(n)) for a in range(n-1) for b in range(a+1,n)])) \n"}, {"source_code": "import sys \n# sys.setrecursionlimit(10**6) \nfrom sys import stdin, stdout\nimport bisect #c++ upperbound\nimport math\nimport heapq\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef cin():\n return map(int,sin().split())\ndef ain(): #takes array as input\n return list(map(int,sin().split()))\ndef sin():\n return input()\ndef inin():\n return int(input())\nimport math \ndef Divisors(n) : \n l = [] \n for i in range(1, int(math.sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n // i == i) : \n l.append(i) \n else : \n l.append(i)\n l.append(n//i)\n return l\n\n\"\"\"*******************************************************\"\"\"\ndef main():\n n,m=cin()\n if(n<7):\n print(m)\n else:\n a=[]\n for i in range(m):\n j,k=cin()\n a.append((j,k))\n b=[]\n ans=0\n for i in range(6):\n for j in range(6-i):\n b=[0]*7\n b[i]=1\n b[i+j+1]=1\n x=2\n for j in range(7):\n if(b[j]==0):\n b[j]=x\n x+=1\n d={}\n # print(b)\n for j in range(m):\n x=min(b[a[j][0]-1],b[a[j][1]-1])\n y=max(b[a[j][0]-1],b[a[j][1]-1])\n d[(x,y)]=1\n # print(x,y,d)\n ans=max(ans,len(d))\n print(ans)\n######## Python 2 and 3 footer by Pajenegod and c1729\n \n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n \n# So on cf, use PyPy2 for best string performance.\n \npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n \nimport os, sys\nfrom io import IOBase, BytesIO\n \nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n \n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n \nif __name__== \"__main__\":\n main()"}, {"source_code": "'''input\n7 21\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n4 5\n4 6\n4 7\n5 6\n5 7\n6 7\n'''\n\nimport sys\nreadln = sys.stdin.readline\n\ndef write(s):\n sys.stdout.write(str(s))\n\ndef writeln(s):\n sys.stdout.write(str(s))\n sys.stdout.write('\\n')\n\ndef readint():\n return int(readln())\n\ndef readints():\n return map(int, readln().split())\n\ndef readstr():\n return readln()\n\ndef readstrs():\n return readln().split()\n\ndef solve(i, n, edges, flags):\n ans = 0\n if i == n + 1:\n dset = set()\n for (a,b) in edges:\n curd = (flags[a], flags[b])\n if curd in dset: continue\n dset.add(curd)\n dset.add((flags[b], flags[a]))\n ans += 1\n return ans\n\n else:\n for cflag in xrange(1, 7):\n flags[i] = cflag\n ans = max(ans, solve(i+1, n, edges, flags))\n return ans\n\n\nn, m = readints()\nedges = []\nfor e in xrange(m):\n edges.append(readints())\nflags = [1] * (n+1)\n\nwriteln(solve(2, n, edges, flags))\n\n\n"}, {"source_code": "n, m = map(int, raw_input().split())\n\nedge = []\nfor x in xrange(m):\n edge.append(map(int, raw_input().split()))\n\nval = [0] * (n + 1)\n\ndef dfs(x):\n res = 0\n if x == n:\n s = set()\n for a, b in edge:\n c, d = val[a], val[b]\n if c > d:\n c, d = d, c\n if (c, d) not in s:\n s.add((c, d))\n res += 1\n else:\n for i in xrange(6):\n val[x + 1] = i\n res = max(res, dfs(x + 1))\n return res\n\nprint(dfs(0))\n"}, {"source_code": "import sys\nimport math\nfrom functools import reduce\nimport bisect\n\n\ndef getN():\n return int(input())\n\n\ndef getNM():\n return map(int, input().split())\n\n\ndef getList():\n return list(map(int, input().split()))\n\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\ndef index(a, x):\n i = bisect.bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return i\n return False\n\n\n#############\n# MAIN CODE #\n#############\n\n\nn, m = getNM()\nadj = [set() for _ in range(n)]\n\nfor _ in range(m):\n a, b = getNM()\n a -= 1\n b -= 1\n adj[a].add(b)\n adj[b].add(a)\nif n < 7 or m == 0:\n print(m)\n exit()\n\nans = 0\n\nfor i in range(7):\n for j in range(i, 7):\n ans = max(ans, m - len(adj[i] & adj[j]))\nprint(ans)\n"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef getdict(n):\n d = {}\n if type(n) is list:\n for i in n:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n else:\n for i in range(n):\n t = ii()\n if t in d:\n d[t] += 1\n else:\n d[t] = 1\n return d\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start = 1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep = ' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\nn, m = mi()\n\nif n < 7:\n exit(print(m))\n\nedges = []\nfor i in range(m):\n edges.append(li())\nperm = list(itertools.permutations([0, 1, 2, 3, 4, 5, 6]))\ngmax = 0\nfor p in perm:\n g = [[] for i in range(n)]\n deg = [0]*n\n for i in edges:\n u, v = i[0], i[1]\n g[p[u - 1]].append(p[v - 1])\n g[p[v - 1]].append(p[u - 1])\n deg[p[v - 1]] += 1\n deg[p[u - 1]] += 1\n\n rm = 0\n for i in range(6):\n k = 0\n for j in g[6]:\n if i not in g[j]:\n k += 1\n rm = max(rm, k)\n\n #print((sum(deg[:6]) - deg[6])//2, rm)\n gmax = max(gmax, (sum(deg[:6]) - deg[6])//2 + rm)\nprint(gmax)\n\n\n\n"}, {"source_code": "def main():\n n, m = map(int, input().split())\n edges = []\n for _ in range(m):\n edge = [int(x) for x in input().split()]\n if edge[0] > edge[1]:\n edge.reverse()\n edges.append(edge)\n if n < 7:\n print(m)\n return\n # 7 verticies so two must have the same number\n ecount = [0] * 8\n for e1,e2 in edges:\n ecount[e1] +=1\n ecount[e2] +=1\n best = 0\n for i in range(1,8):\n for j in range(1,8):\n dom = m - ecount[i]\n if [min(i,j), max(i,j)] in edges:\n dom += 1\n for k in range(1,8):\n if k !=i and k != j and [min(i,k), max(i,k)] in edges and [min(j,k), max(j,k)] not in edges:\n dom += 1\n if dom > best:\n best = dom\n print(best)\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n, m = [int(i) for i in input().split()]\ndata = []\nfor i in range(m):\n \n data.append([int(j) - 1 for j in input().split()])\n\nans = 0\nfor i in range(6 ** n):\n k = i \n num = [0] * n\n for j in range(n):\n dig = k % 6\n k //= 6 \n num[j] = dig\n \n st = set()\n for e in data:\n t = [num[e[0]],num[e[1]]]\n if t[0] > t[1]:\n t.reverse()\n st.add(tuple(t))\n ans = max(len(st), ans)\n\n\nprint(ans)\n"}, {"source_code": "IN = input().split()\nn = int(IN[0])\nm = int(IN[1])\nnum = [0] * (n + 3)\nile = [0] * 10\nE = [0] * (m + 3)\nans = 0\n\ndef spr () :\n res = 0\n for b in range (1, 7) :\n for a in range (1, 1 + b) :\n ile[a][b] = 1\n for i in range (0, m) :\n u = E[i][0]\n v = E[i][1]\n a = min(num[u], num[v])\n b = max(num[u], num[v])\n if ile[a][b] > 0 :\n ile[a][b] = 0\n res += 1\n return res\n\ndef rek (N) :\n if N > n :\n return spr()\n else :\n ret = 0\n for i in range (1, 7) :\n num[N] = i\n ret = max(ret, rek(N + 1))\n return ret\n\nfor i in range (0, 10) :\n ile[i] = [0] * 10\nfor i in range (0, m) :\n IN = input().split()\n E[i] = [int(IN[0]), int(IN[1])]\nprint(rek(1))\n"}, {"source_code": "from collections import defaultdict\na,b=map(int,input().split())\nif b<7:\n print(b)\nelse: \n d=defaultdict()\n for i in range(1,8):\n d[i]=set()\n for i in range(b):\n x,y=map(int,input().split())\n d[x].add(y)\n d[y].add(x)\n w=1000\n for i in range(1,8):\n for j in range(i+1,8):\n s=d[i]&d[j]\n if len(s)<w:\n w=len(s)\n print(b-w) "}, {"source_code": "from collections import defaultdict\na,b=map(int,input().split())\nd=defaultdict()\nfor i in range(1,8):\n d[i]=set()\nfor i in range(b):\n x,y=map(int,input().split())\n d[x].add(y)\n d[y].add(x)\nw=1000\nfor i in range(1,8):\n for j in range(i+1,8):\n s=d[i]&d[j]\n if len(s)<w:\n w=len(s)\nprint(b-w) "}, {"source_code": "n, m = map(int, input().split())\na = [0] * m\nfor i in range(m):\n b, c = map(int, input().split())\n a[i] = [b -1, c - 1]\ncol = [0] * 7\nz = set()\nans = 0\nfor i1 in range(6):\n for i2 in range(6):\n for i3 in range(6):\n for i4 in range(6):\n for i5 in range(6):\n for i6 in range(6):\n for i7 in range(6):\n col[0]= i1 + 1\n col[1] = i2 + 1\n col[2] = i3 + 1\n col[3] = i4 + 1\n col[4] = i5 + 1\n col[5] = i6 + 1\n col[6] = i7 + 1\n for j in range(m):\n z.add(max(col[a[j][0]], col[a[j][1]]) * 10 + min(col[a[j][0]], col[a[j][1]]))\n #print(z)\n #if len(z) > ans:\n #print(col, z)\n ans = max(ans, len(z))\n z = set()\nprint(ans)\n"}, {"source_code": "def getminpair(n):\n\tglobal graph\n\ts = [set(graph[i]) for i in range(8)]\n\tinter = 100000\n\tans = (-1, -1)\n\tfor i in range(1, n+1):\n\t\tfor j in range(1, n+1):\n\t\t\tif(len(s[i].intersection(s[j])) < inter):\n\t\t\t\tinter = len(s[i].intersection(s[j]))\n\t\t\t\tans = (i, j)\n\treturn ans\n\nn, m = map(int, input().split())\ngraph = [[], [], [], [], [], [], [], []]\nfor i in range(m):\n\tx, y = map(int, input().split())\n\tgraph[x] += [y]\n\tgraph[y] += [x]\n\nif(n <= 6):\n\tprint(m)\n\texit()\n\npair = getminpair(n)\ns0 = set(graph[pair[0]])\ns1 = set(graph[pair[1]])\nprint(m - len(s1.intersection(s0)))\n"}, {"source_code": "def getminpair(n):\n\tglobal graph\n\ts = [set(graph[i]) for i in range(8)]\n\tinter = 100000\n\tfor i in range(1, n+1):\n\t\tfor j in range(1, n+1):\n\t\t\tinter = min(inter, len(s[i].intersection(s[j])))\n\treturn inter\n\nn, m = map(int, input().split())\ngraph = [[], [], [], [], [], [], [], []]\nfor i in range(m):\n\tx, y = map(int, input().split())\n\tgraph[x] += [y]\n\tgraph[y] += [x]\n\nif(n <= 6):\n\tprint(m)\n\texit()\n\nprint(m - getminpair(n))\n"}, {"source_code": "n, m = map(int, input().split())\ngraph = [[], [], [], [], [], [], [], []]\nfor i in range(m):\n\tx, y = map(int, input().split())\n\tgraph[x] += [y]\n\tgraph[y] += [x]\ns = [set(g) for g in graph]\nif(n <= 6):\n\tprint(m)\n\texit()\nans = 100000\nfor i in range(1, n+1):\n\tfor j in range(1, n+1):\n\t\tans = min(ans, len(s[i].intersection(s[j])))\nprint(m - ans)\n"}, {"source_code": "import itertools\nn, m = map(int, input().split())\nedge = [[0 for _ in range(n)] for _ in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edge[a][b] = 1\n edge[b][a] = 1\n\nans = 0\nd = [0] * n\nfor d in list(itertools.product(range(6), repeat=n)):\n count = set()\n for i, v1 in enumerate(d):\n for j, v2 in enumerate(d):\n if edge[i][j] == 1:\n count.add(str(v1) + str(v2))\n ans = max(len(count), ans)\nprint((ans+1)//2)"}, {"source_code": "from collections import defaultdict\nn, m = map(int, input().split())\ngraph = defaultdict(set)\nfor _ in range(m):\n a, b = map(int, input().split())\n graph[a].add(b)\n graph[b].add(a)\n\nans = 100\nfor i in range(1, 7):\n for j in range(i + 1, 8):\n g = graph[i] & graph[j]\n ans = min(ans, len(g))\nprint(m - ans)\n"}, {"source_code": "n,m=map(int,input().split())\nedges=[list(map(int,input().split())) for i in range(m)]\nfor i in range(m):\n edges[i][0]-=1\n edges[i][1]-=1\nfrom itertools import permutations\nl=list(permutations(range(6)))\nmx=0\nfor ij in l:\n for node in range(7):\n for seven in range(6):\n cnt=[None]*10\n for xi in range(6):\n cnt[xi]=[0]*10\n for xj in range(xi,6):\n cnt[xi][xj]=1\n numbering=[0]*10\n c=0\n for i in range(6):\n if node==i:\n c=1\n numbering[i+c]=ij[i]\n numbering[node]=seven\n curr=0\n for e in edges:\n u,v=numbering[e[0]],numbering[e[1]]\n u,v=min(u,v),max(u,v)\n if cnt[u][v]:\n cnt[u][v]=0\n curr+=1\n mx=max(mx,curr)\nprint(mx)"}, {"source_code": "n, m = map(int, input().split())\nd = dict()\nfor i in range(1, 8):\n d[i] = set()\nfor i in range(m):\n a, b = map(int, input().split())\n d[a].add(b)\n d[b].add(a)\nans = 100\nfor i in range(1, 7):\n for j in range(i + 1, 8):\n g = d[i] & d[j]\n if len(g) < ans:\n ans = len(g)\nprint(m - ans)\n"}, {"source_code": "n,m=map(int,input().split())\nd=[[] for i in range(n+1)]\nfor x in range(m):\n a,b=map(int,input().split())\n d[a].append(b)\n d[b].append(a)\nif n<7:\n print(m)\nelse:\n ans=-1\n for i in range(1,n):\n for j in range(i+1,n+1):\n sub=0\n for k in range(1,n+1):\n if k in d[i] and k in d[j]:\n sub+=1\n ans=max(ans,m-sub)\n print(ans)\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\n\n\ndef dfs(maxd, L, ans):\n if len(L) == N:\n dominos = [set() for _ in range(7)]\n score = 0\n for a, b in Edges:\n ca, cb = L[a], L[b]\n if ca in dominos[cb]:\n continue\n dominos[ca].add(cb)\n dominos[cb].add(ca)\n score += 1\n #print(L, score)\n return max(score, ans)\n for l in range(maxd+2):\n if l == 6: continue\n ans = dfs(max(maxd,l), L+[l], ans)\n return ans\n\nprint(dfs(-1, [], -2))"}, {"source_code": "n,k = map(int,input().split())\ns = [[0 for i in range(8)] for j in range(8)]\nfor i in range(k):\n\tu,v = map(int,input().split())\n\ts[u][v] = 1\n\ts[v][u] = 1\nif(n <= 6 or k == 0):\n\tprint(k)\nelse:\n\ta = []\n\tfor i in range(1,8):\n\t\tfor j in range(1,8):\n\t\t\tif(i == j):\n\t\t\t\tcontinue\n\t\t\tct = 0\n\t\t\tfor k in range(1,8):\n\t\t\t\tif s[i][k] == 1 and s[j][k] == 1:\n\t\t\t\t\tct += 1\n\t\t\t#print(j,i,ct)\n\t\t\ta.append([ct,i,j])\n\ta.sort()\n\tind1 = a[0][1]\n\tind2 = a[0][2]\n\tsum = sum1 = 0\n\t#print(a[0][0],ind1,ind2)\n\t#print(s[ind1],s[ind2])\n\tfor i in range(1,8):\n\t\tif(s[ind1][i] == 1 and s[ind2][i] == 1):\n\t\t\tsum1 += 1\n\t\telif(s[ind1][i] != s[ind2][i]):\n\t\t\tsum1 += 1\n\n\tif(s[ind1][ind2] == 1 and s[ind2][ind1] == 1):\n\t\tsum1 -= 1\n\tfor i in range(1,8):\n\t\t#print(s[i])\n\t\tif i == ind1 or i == ind2:\n\t\t\tcontinue\n\t\tfor j in range(1,8):\n\t\t\tif j == ind1 or j == ind2:\n\t\t\t\tcontinue\n\t\t\tsum += s[i][j]\n\t\t#print(sum)\n\tprint(sum1+(sum//2))\n"}, {"source_code": "from itertools import product\n\nn,m = map(int,input().split())\nnode = [0, 1, 2, 3, 4, 5, 6]\nnode = node[:n]\ng = []\nfor _ in range(m):\n a,b = map(int,input().split())\n g.append((a-1,b-1))\n\nans = 0\nfor pp in product(node, repeat=n):\n D = [[False] * 7 for _ in range(7)]\n for i in range(7):\n D[6][i] = D[i][6] = True\n cnt = 0\n cnt2 = 0\n h = -1\n if 6 in pp:\n h = pp.index(6)\n for a,b in g:\n if a == h or b == h:\n cnt2 += 1\n if not D[pp[a]][pp[b]]:\n D[pp[a]][pp[b]] = True\n D[pp[b]][pp[a]] = True\n cnt += 1\n if cnt2:\n cnt += 1\n ans = max(ans, cnt)\n\nprint(ans)"}, {"source_code": "\nedges = []\nn,m = map(lambda x:int(x), input().split())\nfor i in range(m):\n curr = [0,0]\n curr[0],curr[1] = map(lambda x:int(x)-1, input().split())\n edges.append(curr)\n\nnum_in = [1,1,1,1,1,1,1]\nabs_max = 0\nc=0\nfor num_in[1] in range(1, 7):\n for num_in[2] in range(1, 7):\n for num_in[3] in range(1, 7):\n for num_in[4] in range(1, 7):\n for num_in[5] in range(1, 7):\n for num_in[6] in range(1, 7):\n c+=1\n used = []\n curr_max = 0\n for x in edges:\n crr = [num_in[x[0]],num_in[x[1]]]\n if crr[0] > crr[1]:\n crr[0],crr[1] = crr[1],crr[0]\n if crr in used:\n continue\n used.append(crr)\n curr_max+=1\n abs_max = max(abs_max,curr_max)\n if abs_max == m:\n print(m)\n exit()\nprint(abs_max)"}, {"source_code": "n, m = map(int, input().split())\na = [[*map(int, input().split())] for i in range(m)]\n\nfrom itertools import combinations\ns = []\nans = 0\n\ndef do():\n\tglobal ans\n\tif len(s) == n:\n\t\tt = set()\n\t\tfor j in a:\n\t\t\ty, z = s[j[0] - 1], s[j[1] - 1]\n\t\t\tif y > z:\n\t\t\t\ty, z = z, y\n\t\t\tt.add((y, z))\n\t\tans = max(ans, len(t))\n\t\treturn\n\tfor i in range(6):\n\t\ts.append(i)\n\t\tdo()\n\t\tdel s[-1]\n\ndo()\n\nprint(ans)"}, {"source_code": "ii=lambda:int(input())\nkk=lambda:map(int,input().split())\nll=lambda:list(kk())\nn,k=kk()\nif n < 7:\n\tprint(k)\n\texit()\nd = [set() for i in range(7)]\nfor _ in range(k):\n\ta,b=kk()\n\ta,b=a-1,b-1\n\td[a].add(b)\n\td[b].add(a)\nmaxi=0\nfor a in range(7):\n\tfor b in range(a+1,7):\n\t\tmaxi=max(maxi, k-len(d[a]&d[b]))\nprint(maxi)"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport heapq\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nimport sys\n\nsys.setrecursionlimit(10 ** 6) # max depth of recursion\nthreading.stack_size(2 ** 27) # new thread will get stack of such size\nfac_warm_up = False\nprintHeap = str()\nmemory_constrained = False\nP = 10 ** 9 + 7\n\n\nclass MergeFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n\n def find(self, a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n\n def merge(self, a, b):\n a = self.find(a)\n b = self.find(b)\n if a == b:\n return\n if self.size[a] < self.size[b]:\n a, b = b, a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n\n def set_size(self, a):\n return self.size[self.find(a)]\n\n def __len__(self):\n return self.num_sets\n\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\n\ndef prime_factors(n): # n**0.5 complex\n factors = dict()\n for i in range(2, math.ceil(math.sqrt(n)) + 1):\n while n % i == 0:\n if i in factors:\n factors[i] += 1\n else:\n factors[i] = 1\n n = n // i\n if n > 2:\n factors[n] = 1\n return (factors)\n\n\ndef all_factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef fibonacci_modP(n, MOD):\n if n < 2: return 1\n return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(\n fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD\n\n\ndef factorial_modP_Wilson(n, p):\n if (p <= n):\n return 0\n res = (p - 1)\n for i in range(n + 1, p):\n res = (res * cached_fn(InverseEuler, i, p)) % p\n return res\n\n\ndef binary(n, digits=20):\n b = bin(n)[2:]\n b = '0' * (digits - len(b)) + b\n return b\n\n\ndef is_prime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\n\ndef generate_primes(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n return prime\n\n\nfactorial_modP = []\n\n\ndef warm_up_fac(MOD):\n global factorial_modP, fac_warm_up\n if fac_warm_up: return\n factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]\n for i in range(2, fac_warm_up_size):\n factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD\n fac_warm_up = True\n\n\ndef InverseEuler(n, MOD):\n return pow(n, MOD - 2, MOD)\n\n\ndef nCr(n, r, MOD):\n global fac_warm_up, factorial_modP\n if not fac_warm_up:\n warm_up_fac(MOD)\n fac_warm_up = True\n return (factorial_modP[n] * (\n (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD\n\n\ndef test_print(*args):\n if testingMode:\n print(args)\n\n\ndef display_list(list1, sep=\" \"):\n stdout.write(sep.join(map(str, list1)) + \"\\n\")\n\n\ndef display_2D_list(li):\n for i in li:\n print(i)\n\n\ndef prefix_sum(li):\n sm = 0\n res = []\n for i in li:\n sm += i\n res.append(sm)\n return res\n\n\ndef get_int():\n return int(stdin.readline().strip())\n\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\n\nmemory = dict()\n\n\ndef clear_cache():\n global memory\n memory = dict()\n\n\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\ndef ncr(n, r):\n return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))\n\n\ndef binary_search(i, li):\n fn = lambda x: li[x] - x // i\n x = -1\n b = len(li)\n while b >= 1:\n while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like\n x += b\n b = b // 2\n return x\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\n\n\nTestCases = False\nfac_warm_up_size = 10 ** 5 + 100\noptimise_for_recursion = True # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3\n\n\ndef main():\n n, m = get_tuple()\n adj = [[] for _ in range(n)]\n edges = []\n for _ in range(m):\n x, y = get_tuple()\n edges.append([x-1,y-1])\n adj[x-1].append(y-1)\n adj[y-1].append(x-1)\n max_d = 0\n for node1 in range(n):\n for node2 in range(n):\n if node1==node2: continue\n tmp = 0\n st1 = set(adj[node1])\n\n st2 = set(adj[node2])\n if node2 in adj[node1]:\n st1.remove(node2)\n st2.remove(node1)\n tmp+=1\n tmp += len(st1.union(st2)) + len([1 for li in edges if node1 not in li and node2 not in li])\n max_d = max(tmp, max_d)\n if n<=6:\n print(m)\n return\n else:\n print(max_d)\n# --------------------------------------------------------------------- END=\n\n\nif TestCases:\n for i in range(get_int()):\n main()\nelse:\n main() if not optimise_for_recursion else threading.Thread(target=main).start()\n"}, {"source_code": "import logging\nfrom collections import defaultdict\n\n\ndef calc_assigned_edge_nums(n, m, edges, new_comer):\n d_v2n = {}\n v = 1\n for i in range(1, n + 1):\n if i == new_comer:\n d_v2n[i] = 7\n else:\n d_v2n[i] = v\n v += 1\n g = defaultdict(set)\n for a, b in edges:\n na, nb = d_v2n[a], d_v2n[b]\n g[na].add(nb)\n g[nb].add(na)\n\n for i in range(1, n):\n if len(g[i]) == 0:\n return m\n dominoes = {(a, b) for b in range(1, 7) for a in range(1, b + 1)}\n\n num_of_already_assigned_dominoes = 0\n for vertex_from, v in g.items():\n for vertex_to in v:\n domino = tuple(sorted([vertex_from, vertex_to]))\n # domino_to_remove = domino\n if domino in dominoes:\n num_of_already_assigned_dominoes += 1\n dominoes.discard(domino)\n\n logging.debug('remain dominoes {}'.format(dominoes))\n max_assignable_edges_to_7 = 0\n for candidate in range(1, 7): # assign 1-6 dot for vertex 7\n num_of_assignable_edges = 0\n for vertex_from in g[7]:\n domino = tuple(sorted([vertex_from, candidate]))\n if domino in dominoes:\n num_of_assignable_edges += 1\n max_assignable_edges_to_7 = max(max_assignable_edges_to_7, num_of_assignable_edges)\n return num_of_already_assigned_dominoes + max_assignable_edges_to_7\n\n\ndef solve(n, m, edges=list()):\n if n <= 6:\n return m\n\n maximum_r = 0\n for i in range(1, n): # choose which should be new comer\n r = calc_assigned_edge_nums(n, m, edges, i)\n logging.debug('#{}= {}'.format(i, r))\n maximum_r = max(maximum_r, r)\n return maximum_r\n\n\n_DEBUG = False\nif _DEBUG:\n logging.basicConfig(level=logging.DEBUG)\n assert solve(7, 21, [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 4),\n (3, 5), (3, 6), (3, 7), (4, 5), (4, 6), (4, 7), (5, 6), (5, 7), (6, 7)]) == 16\n assert solve(4, 4, [(1, 2), (2, 3), (3, 4), (4, 1)]) == 4\n assert solve(7, 0) == 0\n assert solve(3, 1, [(1, 3)]) == 1\nelse:\n logging.basicConfig(level=logging.WARN)\n\n_n, _m = map(int, input().split())\n_edges = []\nfor _ in range(_m):\n a, b = map(int, input().split())\n _edges.append([a, b])\nprint(solve(_n, _m, _edges))\n"}, {"source_code": "import math\n\ndef test(n, matrix, a, b):\n c = 1\n d = []\n if a < 0:\n for i in range(n):\n d.append(i + 1)\n else:\n for i in range(n):\n if i == b:\n d.append(d[a])\n else:\n d.append(c)\n c += 1\n\n result = set()\n for i in range(n):\n for j in range(i):\n if matrix[i][j] == 0:\n continue\n\n p = d[i]\n q = d[j]\n if p > q:\n p = d[j]\n q = d[i]\n\n result.add(p * 10 + q)\n\n return len(result)\n\ndef main():\n (n, m) = tuple([int(x) for x in input().split()])\n matrix = []\n for i in range(n):\n matrix.append([0] * n)\n for i in range(m):\n (x, y) = tuple([int(t) for t in input().split()])\n matrix[x - 1][y - 1] = 1\n matrix[y - 1][x - 1] = 1\n\n result = 0\n for i in range(n):\n for j in range(i):\n result = max(result, test(n, matrix, j, i))\n if n < 7:\n result = max(result, test(n, matrix, -1, -1))\n print(result)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys\nfrom operator import itemgetter\nfrom fractions import gcd\nfrom math import ceil, floor, sqrt\nfrom copy import deepcopy\nfrom collections import Counter, deque\nimport heapq\nfrom functools import reduce\nsys.setrecursionlimit(200000)\nimport itertools\ninput = sys.stdin.readline\ndef ii(): return int(input())\ndef mi(): return map(int, input().rstrip().split())\ndef lmi(): return list(map(int, input().rstrip().split()))\ndef fi(): return float(input())\ndef mfi(): return map(float, input().rstrip().split())\ndef lmfi(): return list(map(float, input().rstrip().split()))\ndef li(): return list(input().rstrip())\ndef debug(*args, sep=\" \", end=\"\\n\"): print(\"debug:\", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None\ndef exit(*arg): print(*arg); sys.exit()\n# template\n\n# BEGIN CUT HERE\nclass Graph():\n def __init__(self, n, Weighted=False, Directed=True, Matrix=False):\n self.sz = n\n self.is_Weighted = Weighted\n self.is_Directed = Directed\n self.is_Matrix = Matrix\n if Matrix:\n if Weighted:\n self.graph = [[0 for _i in range(n)] for _j in range(n)]\n else:\n self.graph = [[0 for _i in range(n)] for _j in range(n)]\n else:\n self.graph = [[] for _i in range(n)]\n\n def _weighted_add_edge(self, x, y, w):\n if self.is_Matrix:\n self.graph[x][y] = w\n else:\n self.graph[x].append((y, w))\n\n def _unweighted_add_edge(self, x, y):\n if self.is_Matrix:\n self.graph[x][y] = 1\n else:\n self.graph[x].append(y)\n\n def add_edge(self, x, y, *w):\n if self.is_Directed:\n if self.is_Weighted:\n self._weighted_add_edge(x, y, w[0])\n else:\n self._unweighted_add_edge(x, y)\n else:\n if self.is_Weighted:\n self._weighted_add_edge(x, y, w[0])\n self._weighted_add_edge(y, x, w[0])\n else:\n self._unweighted_add_edge(x, y)\n self._unweighted_add_edge(y, x)\n# END CUT HERE\n\ndef main():\n n, m = mi()\n t = Graph(n, Directed=False)\n la = 0\n for i in range(m):\n a, b = mi()\n a, b = a - 1, b - 1\n t.add_edge(a, b)\n for l in itertools.product(range(6), repeat=n):\n d = [[0 for i in range(6)] for j in range(6)]\n for i in range(n):\n for j in t.graph[i]:\n d[l[i]][l[j]] = 1\n # print(d)\n ans = sum(sum(d[i][0:i + 1]) for i in range(6))\n la = max(ans, la)\n # print(ans)\n print(la)\n return\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "'''input\n4 4\n1 2\n2 3\n3 4\n4 1\n'''\nfrom sys import stdin\nfrom collections import defaultdict\nfrom itertools import combinations\n\n\ndef change_graph(define):\n\ttemp = defaultdict(list)\n\tfor i in graph:\n\t\tfor node in graph[i]:\n\t\t\ttemp[define[i]].append(define[node])\n\n\treturn temp\n\ndef make(first, second):\n\tif first > second:\n\t\tfirst, second = second, first\n\treturn str(first) + ' ' + str(second)\n\ndef check(arr):\n\t# print(arr)\n\tglobal ans\n\tdefine = dict()\n\tj = 0\n\tfor i in graph:\n\t\tdefine[i] = arr[j]\n\t\tj += 1\n\ttemp_graph = change_graph(define)\n\n\tvisited = dict()\n\tfor i in range(1, 7):\n\t\tfor j in range(i, 7):\n\t\t\tvisited[make(i, j)] = False\n\n\tt = 0\n\tfor i in temp_graph:\n\t\tfor node in temp_graph[i]:\n\t\t\tif visited[make(i, node)] == False:\n\t\t\t\tvisited[make(i, node)] = True\n\t\t\t\tt += 1\n\tans = max(t, ans)\n\t\n# main starts\nn, m = list(map(int, stdin.readline().split()))\ngraph = defaultdict(list)\nfor _ in range(m):\n\tu, v = list(map(int, stdin.readline().split()))\n\tgraph[u].append(v)\n\tgraph[v].append(u)\n\nif n <= 6:\n\tprint(m)\n\texit()\n\nelse:\n\taux = []\n\tindex = [0, 1, 2, 3, 4, 5, 6]\n\ttotal = combinations(index, 2)\n\n\tfor i in total:\n\t\ttemp = [0] * 7\n\t\tfirst, second = i\n\t\ttemp[first] = 6\n\t\ttemp[second] = 6\n\t\t\n\t\ti = 0\n\t\tval = 1\n\t\twhile i < len(temp):\n\t\t\tif temp[i] == 0:\n\t\t\t\ttemp[i] = val\n\t\t\t\tval += 1\n\t\t\ti += 1\n\t\taux.append(temp)\n\n\nans = 0\nfor temp in aux:\n\tcheck(temp)\n\nprint(ans)"}, {"source_code": "n,k = list(map(int,input().split()))\ngraph = [[0 for i in range(n)] for j in range(n)]\nfor i in range(k):\n a,b = list(map(int,input().split()))\n graph[a-1][b-1]=1\n graph[b-1][a-1]=1\nans = []\nif n<7:\n print(k)\nelse:\n for i in range(n):\n for j in range(i+1,n):\n con = 0\n for p in range(n):\n if graph[i][p]==1 and graph[j][p]==1:\n con+=1\n ans.append(con)\n k = k-min(ans)\n print(k)\n \n \n \n \n"}, {"source_code": "from itertools import product\n\nn, m = map(int, input().split())\ne = []\nfor i in range(m):\n\ta, b = map(int, input().split())\n\te.append((a, b))\nans = 0\nfor idx in product([0], *[list(range(1, 7)) for i in range(n)]):\n\tused = [[0] * 7 for i in range(7)]\n\tcnt = 0\n\tfor u, v in e:\n\t\tu, v = idx[u], idx[v]\n\t\tu, v = min(u, v), max(u, v)\n\t\tif not used[u][v]:\n\t\t\tused[u][v] = 1\n\t\t\tcnt += 1\n\tans = max(ans, cnt)\nprint(ans)\n"}, {"source_code": "from math import *\nfrom collections import *\nfrom bisect import *\nimport sys\ninput=sys.stdin.readline\nt=1\nwhile(t):\n t-=1\n n,k=map(int,input().split())\n deg=[set() for i in range(n)]\n for i in range(k):\n u,v=map(int,input().split())\n deg[u-1].add(v-1)\n deg[v-1].add(u-1)\n if(n<=6):\n print(k)\n else:\n ma=0\n for i in range(7):\n for j in range(i+1,7):\n ma=max(ma,k-len(deg[i]°[j]))\n print(ma)\n"}, {"source_code": "mp = [9*[0] for i in range(9)]\nl = [[] for i in range(9)]\nn, m = map(int, input().split())\nans=0\nfor i in range(m):\n a, b = map(int, input().split())\n mp[a][b]=1\n mp[b][a]=1\n l[a].append(b)\n l[b].append(a)\nif n<7:\n ans=m\nelse:\n for i in range (1,n+1):\n e=m-len(l[i])\n t=0\n for j in range(1,n+1):\n if j==i:\n continue\n h=0\n for k in l[i]:\n h+=(mp[j][k]==0)\n t=max(t,h)\n ans=max(ans,e+t)\nprint(ans)"}, {"source_code": "mp = [9*[0],9*[0],9*[0],9*[0],9*[0],9*[0],9*[0],9*[0],9*[0]]\nl = [[], [], [], [], [], [], [], [], []]\nn, m = map(int, input().split())\nans=0\nt=0\ne=0\nfor i in range(m):\n a, b = map(int, input().split())\n mp[a][b]=1\n mp[b][a]=1\n l[a].append(b)\n l[b].append(a)\nif n<7:\n ans=m\nelse:\n for i in range (1,n+1):\n e=m-len(l[i])\n t=0\n for j in range(1,n+1):\n if j==i:\n continue\n h=0\n for k in l[i]:\n h+=(mp[j][k]==0)\n t=max(t,h)\n ans=max(ans,e+t)\nprint(ans)"}, {"source_code": "def DFS(x):\n visited[x]=1\n for i in adj[x]:\n if(visited[i]==0):\n DFS(i)\nl=input().split()\nn=int(l[0])\nm=int(l[1])\nif(n<=6):\n print(m)\n quit()\nadj=[[] for i in range(n)]\nfor i in range(m):\n l=input().split()\n u=int(l[0])\n v=int(l[1])\n u-=1\n v-=1\n adj[u].append(v)\n adj[v].append(u)\nvisited=[0 for i in range(n)]\nDFS(0)\nz=1\nfor i in visited:\n if(i==0):\n z=0\n break\nif(z==0):\n print(m)\n quit()\ndegrees=[len(x) for x in adj]\nz=min(degrees)\nmaxa=m-z\nfor i in range(7):\n for j in range(i+1,7):\n if(i==j):\n continue\n counter=0\n for x in adj[i]:\n if(x in adj[j]):\n counter+=1\n maxa=max(maxa,m-counter)\nprint(maxa)"}, {"source_code": "import itertools\nfrom collections import defaultdict\n\nn, m = map(int, input().split())\n\nd = defaultdict(list)\ns = set()\n\nfor i in range(m):\n a, b = map(int, input().split())\n d[a].append(b)\n d[b].append(a)\n s.add((a, b))\n\nargs = [[0]] + [list(range(6)) for i in range(n-1)]\n\ncolors_iter = itertools.product(*args)\n\nans = 0\nfor c in colors_iter:\n st = set()\n for a, value in d.items():\n for b in value:\n st.add((max(c[a-1], c[b-1]), min(c[a-1], c[b-1])))\n ans = max(ans, len(st))\n\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\nedges = [[*map(int, input().split())] for _ in range(m)]\nprint(max(len({tuple(sorted((mask // (6 ** (x - 1))) % 6 for x in e)) for e in edges}) for mask in range(6 ** n)))"}, {"source_code": "n, m = map(int, input().split())\nedges = [[int(x) - 1 for x in input().split()] for _ in range(m)]\np = [6 ** i for i in range(n)]\nres = 0\nfor mask in range(6 ** n):\n colors = [0] + [(mask // p[i]) % 6 for i in range(n)]\n used = set(tuple(sorted([colors[u], colors[v]])) for u, v in edges)\n res = max(res, len(used))\nprint(res)"}, {"source_code": "n, m = map(int, input().split())\nedges = [[int(x) - 1 for x in input().split()] for _ in range(m)]\nprint(max(len({tuple(sorted((mask // (6 ** x)) % 6 for x in e)) for e in edges}) for mask in range(6 ** n)))"}, {"source_code": "from itertools import permutations\n\ndef dfs(perm, edges, ind, n):\n\tglobal dominoes\n\tglobal cur\n\tglobal tick\n\n\tif ind == n:\n\t\ttick += 1\n\t\tcnt = 0\n\n\t\tfor x, y in edges:\n\t\t\ta, b = sorted((perm[x], perm[y]))\n\n\t\t\tif dominoes[a][b] and cur[a][b] < tick:\n\t\t\t\tcur[a][b] = tick\n\t\t\t\tcnt += 1\n\n\t\treturn cnt\n\telse:\n\t\tans = 0\n\t\tfor i in range(6):\n\t\t\tperm[ind] = i\n\n\t\t\tans = max(ans, dfs(perm, edges, ind + 1, n))\n\n\t\treturn ans\n\ndominoes = [[0 for i in range(6)] for i in range(6)]\ncur = [[0 for i in range(6)] for i in range(6)]\ntick = 0\n\nfor i in range(6):\n\tfor j in range(i, 6):\n\t\tdominoes[i][j] = 1\n\nn, m = map(int, input().split())\n\nedges = []\n\nfor i in range(m):\n\tx, y = map(int, input().split())\n\n\tx, y = x - 1, y - 1\n\n\tedges.append(sorted((x, y)))\n\nperm = [0 for i in range(n)]\n\nprint(dfs(perm, edges, 0, n))\n"}, {"source_code": "n,m=map(int,input().split())\nd=dict()\nfor i in range(1,8):\n d[i]=set()\nfor i in range(m):\n a,b=map(int,input().split())\n d[a].add(b)\n d[b].add(a)\n \nmn=100\nif n<7:\n print(m)\nelse:\n for i in range(1,7):\n for j in range(i+1,8):\n s=d[i]&d[j]\n if len(s)<mn:\n mn=len(s)\n \n print(m-mn)\n "}, {"source_code": "n,m=map(int,input().split())\nd=dict()\nfor i in range(1,8):\n d[i]=set()\nfor i in range(m):\n a,b=map(int,input().split())\n d[a].add(b)\n d[b].add(a)\n \nmn=100\n\nfor i in range(1,7):\n for j in range(i+1,8):\n s=d[i]&d[j]\n if len(s)<mn:\n mn=len(s)\n \nprint(m-mn)\n "}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7: print(m)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n if i == 0 and m == 12 and t1 == 6 and t2 == 3:\n print(12)\n exit()\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n \n ind = 0\n mn = 999\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind = i\n ans = m - mn\n \n mn = 0\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 0:\n if a[ind][j] == 1:\n count += 1\n if count > mn: mn = count \n print(ans + mn)"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nfor j in range(m):\n a,b=map(int,input().split())\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n#find the n vertices that have the most edges\nmost=m\nif n==7:\n #make the first 2 the same\n #consider their intersection\n maxsofar=-7\n for s in range(7):\n v0=set(vertex[s])\n for j in range(s+1,7):\n v1=set(vertex[j])\n length=len(v0.union(v1))-(len(v0)+len(v1))\n if length>maxsofar:\n maxsofar=length\n most+=maxsofar\nif n<=6:\n print(m)\nelse:\n print(most)"}, {"source_code": "\"\"\"\nn,m=map(int,input().split())\nL=[]\nfor i in range(n):\n h=[]\n L.append(h)\n\nfor i in range(m):\n u,v=map(int,input().split())\n L[u-1].append(v-1)\n L[v-1].append(u-1)\n\nif(n<7):\n print(m)\n\nelse:\n\n ct=[]\n tot=0\n for i in range(0,len(L)):\n ct.append(len(L[i]))\n tot+=len(L[i])\n\n tot-=(2*min(ct))\n print(min(m,(tot//2)+1))\n\n\"\"\"\n\"\"\"\n\n\nn,m=map(int,input().split())\nL=[]\nfor i in range(n+1):\n h=[]\n L.append(h)\npre=dict()\nfor i in range(m):\n u,v=map(int,input().split())\n L[u].append(v)\n L[v].append(u)\n pre[(u,v)]=1\n pre[(v,u)]=1\n\nif(n<7):\n print(m)\n\nelse:\n print(L)\n ans=0\n\n for i in range(1,8):\n ed=[]\n for j in range(0,len(L[i])):\n if(L[i][j]>i):\n ed.append(L[i][j])\n else:\n ed.append(L[i][j])\n\n ct=0\n for j in range(1,8):\n c=0\n for k in range(0,len(ed)):\n if(pre.get((j,ed[k]))==None):\n c+=1\n\n ct=max(c,ct)\n\n fnl=(2*m)-(2*len(L[i]))+ct\n\n ans=max(ans,fnl)\n print(ans)\n \n\n\"\"\"\n\n\nn,m=map(int,input().split())\nL=[]\nfor i in range(n+1):\n h=[]\n L.append(h)\n#pre=dict()\narr=[]\nfor i in range(m):\n u,v=map(int,input().split())\n L[u].append(v)\n L[v].append(u)\n arr.append((u,v))\n #pre[(u,v)]=1\n #pre[(v,u)]=1\n\nif(n<7):\n print(m)\n\nelse:\n #print(L)\n ans=0\n\n for i in range(1,8):\n ed=[]\n for j in range(0,len(L[i])):\n if(L[i][j]>i):\n ed.append(L[i][j]-1)\n else:\n ed.append(L[i][j])\n\n pre=dict()\n for j in range(0,len(arr)):\n \n x=arr[j][0]\n y=arr[j][1]\n if(x!=i and y!=i):\n if(x>i):\n x-=1\n if(y>i):\n y-=1\n\n pre[(x,y)]=1\n pre[(y,x)]=1\n #print('eddddd',ed,pre)\n\n ct=0\n for j in range(1,7):\n c=0\n for k in range(0,len(ed)):\n if(pre.get((j,ed[k]))==None):\n c+=1\n\n ct=max(c,ct)\n #print(i,j,ct)\n\n fnl=m-len(L[i])+ct\n\n ans=max(ans,fnl)\n print(ans)\n \n\n \n"}, {"source_code": "n,m=map(int,input().split())\nL=[]\nfor i in range(n+1):\n h=[]\n L.append(h)\narr=[]\nfor i in range(m):\n u,v=map(int,input().split())\n L[u].append(v)\n L[v].append(u)\n arr.append((u,v))\nif(n<7):\n print(m)\nelse:\n\n ans=0\n for i in range(1,8):\n ed=[]\n for j in range(0,len(L[i])):\n if(L[i][j]>i):\n ed.append(L[i][j]-1)\n else:\n ed.append(L[i][j])\n pre=dict()\n for j in range(0,len(arr)): \n x=arr[j][0]\n y=arr[j][1]\n if(x!=i and y!=i):\n if(x>i):\n x-=1\n if(y>i):\n y-=1\n pre[(x,y)]=1\n pre[(y,x)]=1\n\n ct=0\n for j in range(1,7):\n c=0\n for k in range(0,len(ed)):\n if(pre.get((j,ed[k]))==None):\n c+=1\n ct=max(c,ct)\n fnl=m-len(L[i])+ct\n ans=max(ans,fnl)\n print(ans)"}, {"source_code": "n, m = map(int, input().split())\n\nedge = [[0] * 10 for _i in range(10)]\ncnt = [0] * 10\nfor i in range(m):\n a, b = map(int, input().split())\n edge[a][b] = edge[b][a] = 1\n cnt[a] += 1\n cnt[b] += 1\n\nif n <= 6:\n print(m)\n exit(0)\nans = 0\n\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n if i == j:\n continue\n ct = 0\n for k in range(1, n + 1):\n if edge[i][k] and edge[j][k]:\n ct += 1\n ans = max(ans, m - ct)\n\nprint(ans)"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\ndef rint():\n return map(int, sys.stdin.readline().split())\n#lines = stdin.readlines()\n\n\nn, m = rint()\nab = []\nfor i in range(m):\n tmp = list(rint())\n tmp.sort()\n ab.append(tmp)\n\nd = set()\nfor i in range(1, 7):\n for j in range(i, 7):\n d.add((i, j))\n#print(d)\n#print(len(d))\n\ndef check_cnt():\n global max_cnt\n cnt = 0\n dd = d.copy()\n #print(ab)\n #print(\"num\", num)\n for i in range(m):\n ai, bi = ab[i]\n p = (num[ai], num[bi])\n #print(\"p dd\",len(dd), p, dd)\n if p in dd:\n #print(\"remove\", p)\n dd.remove(p)\n cnt += 1\n #print(\"cnt, num\", cnt, num)\n max_cnt = max(max_cnt, cnt)\n\n#print(num)\nnum = [0 for i in range(n+1)]\n\ndef dfs(i,step):\n num[step] = i\n if step == n:\n check_cnt()\n return\n for j in range(7):\n dfs(j, step+1)\n\n\nmax_cnt = 0\nfor i in range(7):\n dfs(i, 1)\n\n\nprint(max_cnt)\n"}, {"source_code": "n, m = map(int, input().split())\n\nif n != 7:\n print(m)\n exit()\n\ngraph = [set() for _ in range(n)]\n\nfor _ in range(m):\n u, v = [int(x) - 1 for x in input().split()]\n graph[u].add(v)\n graph[v].add(u)\n\nanswer = 0\nfor u in range(n):\n for v in range(n):\n if u == v:\n continue\n adj = u in graph[v]\n wo_v = graph[u] - set([v])\n wo_u = graph[v] - set([u])\n wo = m - len(graph[v]) - len(graph[u]) + adj\n answer = max(answer, adj + wo + len(wo_v | wo_u))\n\nprint(answer)\n"}, {"source_code": "def main():\n n,m=map(int,input().split())\n Edges=[[] for _ in range(7)]\n for _ in range(m):\n a,b=map(lambda x: int(x)-1,input().split())\n Edges[a].append(b)\n Edges[b].append(a)\n if n<=6:\n return m\n cnt=6\n for i in range(6):\n for j in range(i+1,7):\n cnt=min(cnt,len(set(Edges[i])&set(Edges[j])))\n return m-cnt\n \nif __name__=='__main__':\n print(main())"}, {"source_code": "\ndef dfs(n):\n\n bool[n] = True\n for i in hash[n]:\n if bool[i] == False:\n dfs(i)\n\n\nfrom collections import defaultdict\n\nhash = defaultdict(set)\n\nn,m = map(int,input().split())\nflag = 0\nfor i in range(m):\n a,b = map(int,input().split())\n hash[a].add(b)\n hash[b].add(a)\nmini = 10**18\nfor i in range(1,8):\n for j in range(1,8):\n if i!=j:\n mini = min(len(hash[i]&hash[j]),mini)\n\nprint(m-mini)\n\n\n\n\n\n\n"}, {"source_code": "\n\nn,m=map(int,input().split())\nedges=[list(map(int,input().split())) for i in range(m)]\nfor i in range(m):\n edges[i][0]-=1\n edges[i][1]-=1\nfrom itertools import permutations\nl=list(permutations(range(6)))\nmx=0\nfor ij in l:\n for node in range(7):\n for seven in range(6):\n cnt=[None]*6\n for xi in range(6):\n cnt[xi]=[0]*6\n for xj in range(xi,6):\n cnt[xi][xj]=1\n numbering=[0]*10\n c=0\n for i in range(6):\n if node==i:\n c=1\n numbering[i+c]=ij[i]\n numbering[node]=seven\n curr=0\n for e in edges:\n u,v=numbering[e[0]],numbering[e[1]]\n u,v=min(u,v),max(u,v)\n if cnt[u][v]:\n cnt[u][v]=0\n curr+=1\n mx=max(mx,curr)\nprint(mx)"}], "negative_code": [{"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7: print(m)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n \n ind = 0\n mn = 999\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind = i\n ans = m - mn\n ind2 = 0\n mn = 999\n for i in range(n):\n if i == ind: continue\n count = 0\n for j in range(n):\n if j == ind: continue\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind2 = i\n \n for i in range(n):\n if a[ind2][i] == 0:\n if a[ind][i] == 1:\n ans += 1\n print(ans)"}, {"source_code": "import sys\nimport math\nfrom functools import reduce\nimport bisect\n\n\ndef getN():\n return int(input())\n\n\ndef getNM():\n return map(int, input().split())\n\n\ndef getList():\n return list(map(int, input().split()))\n\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\ndef index(a, x):\n i = bisect.bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return i\n return False\n\n\n#############\n# MAIN CODE #\n#############\n\nn, m = getNM()\nfor _ in range(m):\n input()\n\nprint(min(m, 16))\n"}, {"source_code": "n,k = map(int,input().split())\ns = [[0 for i in range(8)] for j in range(8)]\nfor i in range(k):\n\tu,v = map(int,input().split())\n\ts[u][v] = 1\n\ts[v][u] = 1\nif(n <= 6 or k == 0):\n\tprint(k)\nelse:\n\tm = 10\n\tfor i in range(1,8):\n\t\ts1 = sum(s[i])\n\t\tif(s1 < m):\n\t\t\tm = s1\n\ta = []\n\tfor i in range(1,8):\n\t\tif(sum(s[i]) == m ):\n\t\t\tf = i\n\t\tfor j in range(1,8):\n\t\t\tif(f == j):\n\t\t\t\tcontinue\n\t\t\tct = 0\n\t\t\tfor k in range(1,8):\n\t\t\t\tif s[f][k] != s[j][k]:\n\t\t\t\t\tct += 1\n\t\t\ta.append([ct,i])\n\ta.sort()\n\tind = a[-1][1]\n\tsum = 0\n\tfor i in range(1,8):\n\t\tif i == ind:\n\t\t\tcontinue\n\t\tfor j in range(1,8):\n\t\t\tif j == ind:\n\t\t\t\tcontinue\n\t\t\tsum += s[i][j]\n\tprint((a[-1][0]+sum)//2)\n"}, {"source_code": "def gns():\n return list(map(int,input().split()))\nn,k=gns()\nfor i in range(k):\n a,b=gns()\nprint(min(16,k))"}, {"source_code": "n,m = [int(j) for j in input().split()]\nadj = [set() for i in range(n)]\nfor i in range(m):\n\tl, r = [int(j)-1 for j in input().split()]\n\tadj[l].add(r)\n\tadj[r].add(l)\nif n<7:\n\tprint(m)\nelse:\n\tdeg = 1e12\n\tfor i in range(n):\n\t\tdeg = min(len(adj[i]), deg)\n\tdeg = max(deg-1, 0)\n\tprint(m-deg)"}, {"source_code": "import math\n\ndef test(n, matrix, a, b):\n c = 1\n d = []\n for i in range(7):\n if i == b:\n d.append(d[a])\n else:\n d.append(c)\n c += 1\n\n result = set()\n for i in range(n):\n for j in range(i):\n if matrix[i][j] == 0:\n continue\n\n p = d[i]\n q = d[j]\n if p > q:\n p = d[j]\n q = d[i]\n\n result.add(p * 10 + q)\n\n return len(result)\n\ndef main():\n (n, m) = tuple([int(x) for x in input().split()])\n matrix = []\n for i in range(n):\n matrix.append([0] * n)\n for i in range(m):\n (x, y) = tuple([int(x) for x in input().split()])\n matrix[x - 1][y - 1] = 1\n matrix[y - 1][x - 1] = 1\n\n result = 0\n for i in range(n):\n for j in range(i):\n result = max(result, test(n, matrix, j, i))\n print(result)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "mp = 9*[9*[0]]\nl = 9*[[]]\nn, m = map(int, input().split())\nans=0\nfor i in range(m):\n a, b = map(int, input().split())\n mp[a][b]=1\n mp[b][a]=1\n l[a].append(b)\n l[b].append(a)\nif m<7:\n ans=m\nelse:\n for i in range (n):\n e=m-len(l[i])\n t=0\n for j in range(n):\n if j==i:\n continue\n h=0\n for k in l[i]:\n h+=(mp[j][k]!=0)\n t=max(t,h)\n ans=max(ans,e+t)\nprint(ans)"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport heapq\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nimport sys\n\nsys.setrecursionlimit(10 ** 6) # max depth of recursion\nthreading.stack_size(2 ** 27) # new thread will get stack of such size\nfac_warm_up = False\nprintHeap = str()\nmemory_constrained = False\nP = 10 ** 9 + 7\n\n\nclass MergeFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n\n def find(self, a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n\n def merge(self, a, b):\n a = self.find(a)\n b = self.find(b)\n if a == b:\n return\n if self.size[a] < self.size[b]:\n a, b = b, a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n\n def set_size(self, a):\n return self.size[self.find(a)]\n\n def __len__(self):\n return self.num_sets\n\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\n\ndef prime_factors(n): # n**0.5 complex\n factors = dict()\n for i in range(2, math.ceil(math.sqrt(n)) + 1):\n while n % i == 0:\n if i in factors:\n factors[i] += 1\n else:\n factors[i] = 1\n n = n // i\n if n > 2:\n factors[n] = 1\n return (factors)\n\n\ndef all_factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef fibonacci_modP(n, MOD):\n if n < 2: return 1\n return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(\n fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD\n\n\ndef factorial_modP_Wilson(n, p):\n if (p <= n):\n return 0\n res = (p - 1)\n for i in range(n + 1, p):\n res = (res * cached_fn(InverseEuler, i, p)) % p\n return res\n\n\ndef binary(n, digits=20):\n b = bin(n)[2:]\n b = '0' * (digits - len(b)) + b\n return b\n\n\ndef is_prime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\n\ndef generate_primes(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n return prime\n\n\nfactorial_modP = []\n\n\ndef warm_up_fac(MOD):\n global factorial_modP, fac_warm_up\n if fac_warm_up: return\n factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]\n for i in range(2, fac_warm_up_size):\n factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD\n fac_warm_up = True\n\n\ndef InverseEuler(n, MOD):\n return pow(n, MOD - 2, MOD)\n\n\ndef nCr(n, r, MOD):\n global fac_warm_up, factorial_modP\n if not fac_warm_up:\n warm_up_fac(MOD)\n fac_warm_up = True\n return (factorial_modP[n] * (\n (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD\n\n\ndef test_print(*args):\n if testingMode:\n print(args)\n\n\ndef display_list(list1, sep=\" \"):\n stdout.write(sep.join(map(str, list1)) + \"\\n\")\n\n\ndef display_2D_list(li):\n for i in li:\n print(i)\n\n\ndef prefix_sum(li):\n sm = 0\n res = []\n for i in li:\n sm += i\n res.append(sm)\n return res\n\n\ndef get_int():\n return int(stdin.readline().strip())\n\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\n\nmemory = dict()\n\n\ndef clear_cache():\n global memory\n memory = dict()\n\n\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\ndef ncr(n, r):\n return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))\n\n\ndef binary_search(i, li):\n fn = lambda x: li[x] - x // i\n x = -1\n b = len(li)\n while b >= 1:\n while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like\n x += b\n b = b // 2\n return x\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\n\n\nTestCases = False\nfac_warm_up_size = 10 ** 5 + 100\noptimise_for_recursion = True # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3\n\n\ndef main():\n n, m = get_tuple()\n adj = [[] for _ in range(n)]\n for _ in range(m):\n x, y = get_tuple()\n adj[x-1].append(y-1)\n adj[y-1].append(x-1)\n if n<=6:\n print(m)\n return\n min_len = min([len(x) for x in adj])\n if min_len>=1:\n print(m - min_len + 1)\n else:\n print(m)\n# --------------------------------------------------------------------- END=\n\n\nif TestCases:\n for i in range(get_int()):\n main()\nelse:\n main() if not optimise_for_recursion else threading.Thread(target=main).start()\n"}, {"source_code": "n,k = map(int,input().split())\ns = [[0 for i in range(8)] for j in range(8)]\nfor i in range(k):\n\tu,v = map(int,input().split())\n\ts[u][v] = 1\n\ts[v][u] = 1\nif(n <= 6 or k == 0):\n\tprint(k)\nelse:\n\tm = 10\n\tfor i in range(1,8):\n\t\ts1 = sum(s[i])\n\t\tif(s1 < m):\n\t\t\tm = s1\n\ta = []\n\tfor i in range(1,8):\n\t\tif(sum(s[i]) == m ):\n\t\t\tf = i\n\t\t\tfor j in range(1,8):\n\t\t\t\tif(f == j):\n\t\t\t\t\tcontinue\n\t\t\t\tct = 0\n\t\t\t\tfor k in range(1,8):\n\t\t\t\t\tif s[f][k] == 1 and s[j][k] == 1:\n\t\t\t\t\t\tct += 1\n\t\t\t\t#print(j,f,ct)\n\t\t\t\ta.append([ct,j,f])\n\ta.sort()\n\tind1 = a[0][1]\n\tind2 = a[0][2]\n\tsum = sum1 = 0\n\t#print(a[0][0],ind1,ind2)\n\t#print(s[ind1],s[ind2])\n\tfor i in range(1,8):\n\t\tif(s[ind1][i] == 1 and s[ind2][i] == 1):\n\t\t\tsum1 += 1\n\t\telif(s[ind1][i] != s[ind2][i]):\n\t\t\tsum1 += 1\n\n\tif(s[ind1][ind2] == 1 and s[ind2][ind1] == 1):\n\t\tsum1 -= 1\n\tfor i in range(1,8):\n\t\t#print(s[i])\n\t\tif i == ind1 or i == ind2:\n\t\t\tcontinue\n\t\tfor j in range(1,8):\n\t\t\tif j == ind1 or j == ind2:\n\t\t\t\tcontinue\n\t\t\tsum += s[i][j]\n\t\t#print(sum)\n\tprint(sum1+(sum//2))\n"}, {"source_code": "from sys import stdin\nfrom collections import deque\nfrom copy import copy\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrints_2d = lambda n: [rints() for _ in range(n)]\nget_col = lambda arr, i: [row[i] for row in arr]\n\nn, m = rints()\nedges = deque(rints_2d(m))\n\nif len(set(get_col(edges, 0) + get_col(edges, 1))) < 7:\n print(m)\nelse:\n all, ans = set(), 0\n for i in range(1, 7):\n for j in range(i, 7):\n all.add((i, j))\n\n for i in range(m):\n mem, dis, ext, tem = [0] * (n + 1), copy(all), {j1 for j1 in range(2, 7)}, 1\n dis.discard((1, 1))\n mem[edges[0][0]] = mem[edges[0][1]] = 1\n edges.rotate(-1)\n\n for j in range(m - 1):\n if mem[edges[0][0]] and mem[edges[0][1]]:\n if tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])) in dis:\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n\n elif not (mem[edges[0][0]] or mem[edges[0][1]]):\n if len(ext) >= 2:\n mem[edges[0][0]] = ext.pop()\n mem[edges[0][1]] = ext.pop()\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n else:\n if ext:\n if not mem[edges[0][0]]:\n mem[edges[0][0]] = ext.pop()\n else:\n mem[edges[0][1]] = ext.pop()\n\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n\n edges.rotate(-1)\n\n edges.rotate(-1)\n ans = max(ans, tem)\n print(dis, tem)\n\n print(ans)\n"}, {"source_code": "n,m = [int(j) for j in input().split()]\nadj = [set() for i in range(n)]\nfor i in range(m):\n\tl, r = [int(j)-1 for j in input().split()]\n\tadj[l].add(r)\n\tadj[r].add(l)\nif n<7:\n\tprint(m)\nelse:\n\tdeg = 1e12\n\tfor i in range(n):\n\t\tdeg = min(len(adj[i]), deg)\n\tdeg = max(deg-1, 0)\n\tprint(m-deg)"}, {"source_code": "import sys \n# sys.setrecursionlimit(10**6) \nfrom sys import stdin, stdout\nimport bisect #c++ upperbound\nimport math\nimport heapq\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef cin():\n return map(int,sin().split())\ndef ain(): #takes array as input\n return list(map(int,sin().split()))\ndef sin():\n return input()\ndef inin():\n return int(input())\nimport math \ndef Divisors(n) : \n l = [] \n for i in range(1, int(math.sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n // i == i) : \n l.append(i) \n else : \n l.append(i)\n l.append(n//i)\n return l\n\n\"\"\"*******************************************************\"\"\"\ndef main():\n n,m=cin()\n if(n<7):\n print(m)\n else:\n a=[]\n for i in range(m):\n j,k=cin()\n a.append((j,k))\n b=[]\n for i in range(1,7):\n b.append(i)\n b.append(0)\n ans=0\n for i in range(1,7):\n b[n-1]=i\n d={}\n # print(b)\n for j in range(m):\n x=min(b[a[j][0]-1],b[a[j][1]-1])\n y=max(b[a[j][0]-1],b[a[j][1]-1])\n d[(x,y)]=1\n ans=max(ans,len(d))\n print(ans)\n######## Python 2 and 3 footer by Pajenegod and c1729\n \n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n \n# So on cf, use PyPy2 for best string performance.\n \npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n \nimport os, sys\nfrom io import IOBase, BytesIO\n \nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n \n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n \nif __name__== \"__main__\":\n main()"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nselfs=0\nsevens=0\nfor j in range(m):\n a,b=map(int,input().split())\n if a!=b:\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n else:\n selfs+=1\n#find the n vertices that have the most edges\nedges=[]\nunique=set([])\ndef combo(vertex,n,unique,cv):\n maxedge=0\n if n==0:\n #then we go through all the vertices and count their edges that include each other\n edges=0\n unique2=unique.copy()\n used=set([])\n for s in unique:\n for j in vertex[s]:\n if j in unique2:\n if not((s,j) in used) and not((j,s) in used):\n used.add((s,j))\n edges+=1\n #if n==7, i have to check 2 smallest\n if len(unique)==7:\n sorts=vertex.copy()\n sorts.sort(key= lambda x: len(x))\n minlength=len(sorts[0])\n edges-=minlength\n maxsofar=0\n for s in range(len(sorts)):\n if len(sorts[s])==minlength:\n set1=set(sorts[s])\n for j in sorts[s]:\n set2=set(sorts[j])\n leftover=1+len(set1)-len(set1.intersection(set2))\n if len(set1)+len(set2)>=6:\n leftover-=1\n if leftover>maxsofar:\n maxsofar=leftover\n else:\n break\n edges+=maxsofar\n return edges\n else:\n maxedge=0\n for s in range(cv,7):\n if not(s in unique):\n unique1=unique.copy()\n unique1.add(s)\n edge=combo(vertex,n-1,unique1,s+1)\n if edge>=maxedge:\n maxedge=edge\n return maxedge\nmost=combo(vertex,n,unique,0)\nprint(most)"}, {"source_code": "n, m = map(int, input().split())\ns = [0 for i in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n s[a - 1] += 1\n s[b - 1] += 1\nif n == 7:\n m -= min(s)\n m+=1\nprint(m)"}, {"source_code": "n,m = map(int,raw_input().split(\" \"))\ndegrees = [0]*n\nfor i in range(m):\n\ta,b = map(int,raw_input().split(\" \"))\n\tdegrees[a-1] += 1\n\tdegrees[b-1] += 1\n\ndegrees.sort(reverse = True)\n\nif n <= 6:\n\tprint m\nelse:\n\tans = 0\n\tfor i in degrees[:-1]:\n\t\tans += i\n\tans -=degrees[-1]\n\tans/=2\n\tans += degrees[-1]>0 \n\tprint ans\n\n\n\n"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport heapq\nimport cProfile, math\nfrom collections import Counter, defaultdict, deque\nfrom bisect import bisect_left, bisect, bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nimport sys\n\nsys.setrecursionlimit(10 ** 6) # max depth of recursion\nthreading.stack_size(2 ** 27) # new thread will get stack of such size\nfac_warm_up = False\nprintHeap = str()\nmemory_constrained = False\nP = 10 ** 9 + 7\n\n\nclass MergeFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.size = [1] * n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n\n def find(self, a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n\n def merge(self, a, b):\n a = self.find(a)\n b = self.find(b)\n if a == b:\n return\n if self.size[a] < self.size[b]:\n a, b = b, a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n\n def set_size(self, a):\n return self.size[self.find(a)]\n\n def __len__(self):\n return self.num_sets\n\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\n\ndef prime_factors(n): # n**0.5 complex\n factors = dict()\n for i in range(2, math.ceil(math.sqrt(n)) + 1):\n while n % i == 0:\n if i in factors:\n factors[i] += 1\n else:\n factors[i] = 1\n n = n // i\n if n > 2:\n factors[n] = 1\n return (factors)\n\n\ndef all_factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef fibonacci_modP(n, MOD):\n if n < 2: return 1\n return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(\n fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD\n\n\ndef factorial_modP_Wilson(n, p):\n if (p <= n):\n return 0\n res = (p - 1)\n for i in range(n + 1, p):\n res = (res * cached_fn(InverseEuler, i, p)) % p\n return res\n\n\ndef binary(n, digits=20):\n b = bin(n)[2:]\n b = '0' * (digits - len(b)) + b\n return b\n\n\ndef is_prime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\n\ndef generate_primes(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n return prime\n\n\nfactorial_modP = []\n\n\ndef warm_up_fac(MOD):\n global factorial_modP, fac_warm_up\n if fac_warm_up: return\n factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]\n for i in range(2, fac_warm_up_size):\n factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD\n fac_warm_up = True\n\n\ndef InverseEuler(n, MOD):\n return pow(n, MOD - 2, MOD)\n\n\ndef nCr(n, r, MOD):\n global fac_warm_up, factorial_modP\n if not fac_warm_up:\n warm_up_fac(MOD)\n fac_warm_up = True\n return (factorial_modP[n] * (\n (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD\n\n\ndef test_print(*args):\n if testingMode:\n print(args)\n\n\ndef display_list(list1, sep=\" \"):\n stdout.write(sep.join(map(str, list1)) + \"\\n\")\n\n\ndef display_2D_list(li):\n for i in li:\n print(i)\n\n\ndef prefix_sum(li):\n sm = 0\n res = []\n for i in li:\n sm += i\n res.append(sm)\n return res\n\n\ndef get_int():\n return int(stdin.readline().strip())\n\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\n\nmemory = dict()\n\n\ndef clear_cache():\n global memory\n memory = dict()\n\n\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\ndef ncr(n, r):\n return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))\n\n\ndef binary_search(i, li):\n fn = lambda x: li[x] - x // i\n x = -1\n b = len(li)\n while b >= 1:\n while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like\n x += b\n b = b // 2\n return x\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\n\n\nTestCases = False\nfac_warm_up_size = 10 ** 5 + 100\noptimise_for_recursion = True # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3\n\n\ndef main():\n n, m = get_tuple()\n adj = [[] for _ in range(n)]\n for _ in range(m):\n x, y = get_tuple()\n adj[x-1].append(y-1)\n adj[y-1].append(x-1)\n if n<=6:\n print(m)\n return\n min_len = min([len(x) for x in adj])\n if min_len>=1:\n print(m - min_len + 1)\n else:\n print(m)\n# --------------------------------------------------------------------- END=\n\n\nif TestCases:\n for i in range(get_int()):\n main()\nelse:\n main() if not optimise_for_recursion else threading.Thread(target=main).start()\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\n\nif n <= 6:\n for i in range(m):\n input()\n print(m)\n exit()\n\ndegrees = [0] * 7\n\nfor i in range(m):\n edge = [int(x) - 1 for x in input().split()]\n u = edge[0]\n v = edge[1]\n degrees[u] += 1\n degrees[v] += 1\n\nminDegree = min(degrees)\n\nanswer = m\nif minDegree != 0:\n answer -= minDegree - 1\n\nprint(answer)\n"}, {"source_code": "n, m = map(int, input().split())\ns = [0 for i in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n s[a - 1] += 1\n s[b - 1] += 1\nif n == 7:\n m -= min(s)\nprint(m)"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nselfs=0\nsevens=0\nfor j in range(m):\n a,b=map(int,input().split())\n if a!=b:\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n else:\n selfs+=1\n#find the n vertices that have the most edges\nedges=[]\nunique=set([])\ndef combo(vertex,n,unique,cv):\n maxedge=0\n if n==0:\n #then we go through all the vertices and count their edges that include each other\n edges=0\n unique2=unique.copy()\n used=set([])\n for s in unique:\n for j in vertex[s]:\n if j in unique2:\n if not((s,j) in used) and not((j,s) in used):\n used.add((s,j))\n edges+=1\n if len(unique)==7:\n #we will have to remove the 1 with the least connections\n least=min(vertex,key=lambda x: len(x))\n if len(least)>=2:\n edges-=(len(least)-1)\n return edges\n else:\n maxedge=0\n for s in range(cv,7):\n if not(s in unique):\n unique1=unique.copy()\n unique1.add(s)\n edge=combo(vertex,n-1,unique1,s+1)\n if edge>=maxedge:\n maxedge=edge\n return maxedge\nmost=combo(vertex,n,unique,0)\nprint(most)"}, {"source_code": "n,m = map(int,input().split())\nl =[[] for _ in range(n)]\nfor i in range(m):\n\tk,p = map(int,input().split())\n\tl[k-1].append(p)\n\tl[p-1].append(k)\nif n<7 or m==0:\n\tprint(m)\nelse:\n\tk = [len(l[i]) for i in range(n)]\n\tmi=9999\n\tfor i in range(n):\n\t for j in range(i+1,n):\n\t x = k[i]+k[j]-1 if (i+1) in l[j] else k[i]+k[j]\n\t x = max(0,x-6)\n\t if mi>x:\n\t mi = x\n\tprint(m - mi)"}, {"source_code": "\ndef dfs(n):\n\n bool[n] = True\n for i in hash[n]:\n if bool[i] == False:\n dfs(i)\n\n\nfrom collections import defaultdict\n\nhash= defaultdict(list)\n\nn,m = map(int,input().split())\nflag = 0\nfor i in range(m):\n a,b = map(int,input().split())\n hash[a].append(b)\n hash[b].append(a)\n if len(hash[a]) == 6 or len(hash[b]) == 6:\n flag = 1\n\nbool = [False]*(n+1)\nif n<7:\n print(m)\nelse:\n dfs(1)\n\n\n if bool[1:] != [True]*(n):\n print(m)\n else:\n\n\n if flag == 0:\n print(m)\n else:\n if 6<=m<=11:\n print(m)\n elif 12<=m<=18:\n print(m-2)\n else:\n print(16)\n\n\n\n\n\n"}, {"source_code": "from sys import stdin\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrints_2d = lambda n: [rints() for _ in range(n)]\n\nn, m = rints()\nedges = rints_2d(m)\nif n != 7:\n print(m)\nelse:\n print(min(16, m))\n"}, {"source_code": "#!/usr/bin/env python3\n\n\ndef calculatePossibleIncrease(setMain: set, setLeft: set, setMainIndex: int):\n directDelta = len(setMain.union(setLeft).difference(\n setMain.union({setMainIndex})))\n\n indirectDelta = len(setLeft.intersection({setMainIndex})) # x <-> x\n\n return directDelta + indirectDelta\n\n\ndef calculateMaxPossibleEdges(verts, leftOutVertIndex):\n tempSetEdgesCount = len(verts[leftOutVertIndex])\n\n retVal = -1\n for i in range(len(verts)):\n if len(verts[i]) == tempSetEdgesCount:\n retVal = max(\n retVal,\n calculatePossibleIncrease(\n verts[i], verts[leftOutVertIndex], i)\n )\n\n return retVal\n\n\ndef calculateDirectAnswer(verts, leftOutVertIndex):\n doubleEdgeCount = 0\n for i in range(len(verts)):\n if i != leftOutVertIndex:\n doubleEdgeCount += len(verts[i].difference({leftOutVertIndex}))\n return doubleEdgeCount // 2\n\n\ndef main():\n vertsCount, edgesCount = tuple(map(int, input('').split(' ')))\n\n if(vertsCount < 7):\n print(edgesCount)\n exit(0)\n\n verts = []\n for i in range(vertsCount):\n verts.append(set())\n\n for _t in range(edgesCount):\n _x, _y = tuple(\n map(lambda x: int(x) - 1, input('').split(' '))\n )\n\n verts[_x].add(_y)\n verts[_y].add(_x)\n\n edgesCount = [len(y) for y in verts]\n minEdgesCount = min(edgesCount)\n\n directAnswer = -1\n indirectAnswer = -1\n answer = -1\n for i in range(vertsCount):\n if len(verts[i]) == minEdgesCount:\n directAnswer = calculateDirectAnswer(verts, i)\n indirectAnswer = calculateMaxPossibleEdges(verts, i)\n\n answer = max(answer, directAnswer + indirectAnswer)\n\n return answer\n\n\nif __name__ == '__main__':\n print(main())\n"}, {"source_code": "import sys\nimport math\nfrom functools import reduce\nimport bisect\n\n\ndef getN():\n return int(input())\n\n\ndef getNM():\n return map(int, input().split())\n\n\ndef getList():\n return list(map(int, input().split()))\n\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\ndef index(a, x):\n i = bisect.bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return i\n return False\n\n\n#############\n# MAIN CODE #\n#############\n\n\nn, m = getNM()\nadj = [[] for _ in range(n)]\n\nfor _ in range(m):\n a, b = getNM()\n a -= 1\n b -= 1\n adj[a - 1].append(b - 1)\n adj[b - 1].append(a - 1)\nif n < 7:\n print(m)\n exit()\nadj.sort(key=lambda ribs: len(ribs))\nprint(m - len(adj[0]) + 1)\n"}, {"source_code": "'''input\n7 21\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n4 5\n4 6\n4 7\n5 6\n5 7\n6 7\n'''\nfrom sys import stdin\nfrom collections import defaultdict\n\n\n# main starts\nn, m = list(map(int, stdin.readline().split()))\ngraph = defaultdict(list)\nfor _ in range(m):\n\tu, v = list(map(int, stdin.readline().split()))\n\tgraph[u].append(v)\n\tgraph[v].append(u)\n\ndefine = dict()\nif len(graph) <= 6:\n\tprint(m)\n\texit()\n\nelse:\n\tprint(min(16, m))\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7: print(m)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n # print(a)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n # print(a)\n mn = 999\n check = 0\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count == 6: check = 1\n if count < mn: mn = count\n if check == 0: print(m)\n else: print(m - mn + 1)\n "}, {"source_code": "def main():\n n,m=map(int,input().split())\n Edges=[[] for _ in range(7)]\n for _ in range(m):\n a,b=map(lambda x: int(x)-1,input().split())\n Edges[a].append(b)\n Edges[b].append(a)\n L=[0]*7\n for i,E in enumerate(Edges):\n L[i]=[len(E),i]\n L.sort(reverse=True)\n if L[0][0]!=6:\n return m\n cnt=6\n for num,idx in L:\n tmp=6\n if num!=6:\n break\n for to in Edges[idx]:\n tmp=min(tmp,len(Edges[to])-1)\n cnt=min(cnt,tmp)\n return m-cnt\n \nif __name__=='__main__':\n print(main())"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nselfs=0\nsevens=0\nfor j in range(m):\n a,b=map(int,input().split())\n if a!=b:\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n else:\n selfs+=1\n#find the n vertices that have the most edges\nedges=[]\nunique=set([])\ndef combo(vertex,n,unique,cv):\n maxedge=0\n if n==0:\n #then we go through all the vertices and count their edges that include each other\n edges=0\n unique2=unique.copy()\n used=set([])\n for s in unique:\n for j in vertex[s]:\n if j in unique2:\n if not((s,j) in used) and not((j,s) in used):\n used.add((s,j))\n edges+=1\n if len(unique)==7:\n #we will have to remove the 1 with the least connections\n least=min(vertex,key=lambda x: len(x))\n if len(least)>=2:\n edges-=(len(least)-1)\n return edges\n else:\n maxedge=0\n for s in range(cv,7):\n if not(s in unique):\n unique1=unique.copy()\n unique1.add(s)\n edge=combo(vertex,n-1,unique1,s+1)\n if edge>=maxedge:\n maxedge=edge\n return maxedge\nmost=combo(vertex,n,unique,0)\nprint(most)"}, {"source_code": "x,y=map(int,input().split())\nk=0\nw=0\nfor __ in range(y):\n a,b=map(int,input().split())\n if k==0 and b==7:\n w+=1\n k=1\n if b!=7:\n w+=1\nprint(w) "}, {"source_code": "n, m = map(int, input().split())\n\ng = [0]*n\n\nfor i in range(m):\n\ta, b = map(int, input().split())\n\tg[a-1] += 1\n\tg[b-1] += 1\n\n\ng = sorted(g)\n\ni = 0\n\nif m >= 16:\n\tif g[1] < 6:\n\t\ti = (6-g[1])+(6-g[2])+(6-g[3])+(6-g[4])+(6-g[5])+(6-g[6])\n\tprint(16-i)\nelse:\n\tprint(m)\n"}, {"source_code": "import itertools\nfrom collections import defaultdict\n\nn, m = map(int, input().split())\n\nd = defaultdict(list)\ns = set()\n\nfor i in range(m):\n a, b = map(int, input().split())\n d[a].append(b)\n d[b].append(a)\n s.add((a, b))\n\nargs = [[0]] + [list(range(7)) for i in range(n-1)]\n\ncolors_iter = itertools.product(*args)\n\nans = 0\nfor c in colors_iter:\n st = set()\n for a, value in d.items():\n for b in value:\n st.add((max(a, b), min(a, b)))\n ans = max(ans, len(st))\n\nprint(ans)"}, {"source_code": "n, m = [int(x) for x in input().split()]\n\nif n <= 6:\n for i in range(m):\n input()\n print(m)\n exit()\n\ndegrees = [0] * 7\n\nfor i in range(m):\n edge = [int(x) - 1 for x in input().split()]\n u = edge[0]\n v = edge[1]\n degrees[u] += 1\n degrees[v] += 1\n\nminDegree = min(degrees)\n\nanswer = m\nif minDegree != 0:\n answer -= minDegree - 1\n\nprint(answer)\n"}, {"source_code": "mp = [9*[0],9*[0],9*[0],9*[0],9*[0],9*[0],9*[0],9*[0],9*[0]]\nl = [[], [], [], [], [], [], [], [], []]\nn, m = map(int, input().split())\nans=0\nfor i in range(m):\n a, b = map(int, input().split())\n mp[a][b]=1\n mp[b][a]=1\n l[a].append(b)\n l[b].append(a)\nif m<7:\n ans=m\nelse:\n for i in range (1,n+1):\n e=m-len(l[i])\n t=0\n for j in range(1,n+1):\n if j==i:\n continue\n h=0\n for k in l[i]:\n h+=(mp[j][k]==0)\n t=max(t,h)\n ans=max(ans,e+t)\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\ngraph = [[] for _ in range(n)]\nfor _ in range(m):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n graph[u].append(v)\n graph[v].append(u)\nmaxcnt = 0\nfor node1 in range(n):\n for node2 in range(node1 + 1, n):\n used = [[False] * n for _ in range(n)]\n col = list(range(0, node2)) + [node1] + list(range(node2 + 1, n))\n cnt = 0\n for u in range(n):\n for v in graph[u]:\n if not used[col[u]][col[v]]:\n used[col[u]][col[v]] = used[col[v]][col[u]] = True\n cnt += 1\n maxcnt = max(cnt, maxcnt)\nprint(maxcnt)\n"}, {"source_code": "n,k = map(int,input().split())\ns = [[0 for i in range(8)] for j in range(8)]\nfor i in range(k):\n\tu,v = map(int,input().split())\n\ts[u][v] = 1\n\ts[v][u] = 1\nif(n <= 6 or k == 0):\n\tprint(k)\nelse:\n\tm = 10\n\tfor i in range(1,8):\n\t\ts1 = sum(s[i])\n\t\tif(s1 < m):\n\t\t\tm = s1\n\ta = []\n\tfor i in range(1,8):\n\t\tif(sum(s[i]) == m ):\n\t\t\tf = i\n\t\t\tfor j in range(1,8):\n\t\t\t\tif(f == j):\n\t\t\t\t\tcontinue\n\t\t\t\tct = 0\n\t\t\t\tfor k in range(1,8):\n\t\t\t\t\tif s[f][k] == 1 and s[j][k] == 1:\n\t\t\t\t\t\tct += 1\n\t\t\t\t#print(j,f,ct)\n\t\t\t\ta.append([ct,j,f])\n\ta.sort()\n\tind1 = a[0][1]\n\tind2 = a[0][2]\n\tsum = sum1 = 0\n\t#print(a[0][0],ind1,ind2)\n\t#print(s[ind1],s[ind2])\n\tfor i in range(1,8):\n\t\tif(s[ind1][i] == 1 and s[ind2][i] == 1):\n\t\t\tsum1 += 1\n\t\telif(s[ind1][i] != s[ind2][i]):\n\t\t\tsum1 += 1\n\n\tif(s[ind1][ind2] == 1 and s[ind2][ind1] == 1):\n\t\tsum1 -= 1\n\tfor i in range(1,8):\n\t\t#print(s[i])\n\t\tif i == ind1 or i == ind2:\n\t\t\tcontinue\n\t\tfor j in range(1,8):\n\t\t\tif j == ind1 or j == ind2:\n\t\t\t\tcontinue\n\t\t\tsum += s[i][j]\n\t\t#print(sum)\n\tprint(sum1+(sum//2))\n"}, {"source_code": "n,m = map(int,raw_input().split(\" \"))\ndegrees = [0]*n\nfor i in range(m):\n\ta,b = map(int,raw_input().split(\" \"))\n\tdegrees[a-1] += 1\n\tdegrees[b-1] += 1\n\ndegrees.sort(reverse = True)\n\nif n <= 6:\n\tprint m\nelse:\n\tans = 0\n\tfor i in degrees[:-1]:\n\t\tans += i\n\tans -=degrees[-1]\n\tans/=2\n\tans += 1\n\tprint ans"}, {"source_code": "n, m = map(int, input().split())\n\nif n != 7:\n print(m)\n exit()\n\ngraph = [set() for _ in range(n)]\n\nfor _ in range(m):\n u, v = [int(x) - 1 for x in input().split()]\n graph[u].add(v)\n graph[v].add(u)\n\nanswer = 0\nfor u in range(n):\n for v in range(n):\n if u == v:\n continue\n adj = u in graph[v]\n wo = m - len(graph[u]) - len(graph[v]) + 2 * adj\n answer = max(answer, adj + wo + (len(graph[u] | graph[v])))\n\nprint(answer)\n"}, {"source_code": "mp = 9*[9*[0]]\nl = 9*[[]]\nn, m = map(int, input().split())\nans=0\nfor i in range(m):\n a, b = map(int, input().split())\n mp[a][b]=1\n mp[b][a]=1\n l[a].append(b)\n l[b].append(a)\nif m<7:\n ans=m\nelse:\n for i in range (n):\n e=m-len(l[i])\n t=0\n for j in range(n):\n if j==i:\n continue\n h=0\n for k in l[i]:\n h+=(mp[j][k]!=0)\n t=max(t,h)\n ans=max(ans,e+t)\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\ns = [0 for i in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n s[a - 1] += 1\n s[b - 1] += 1\nif n == 7:\n m -= min(s)\nprint(m)"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef getdict(n):\n d = {}\n if type(n) is list:\n for i in n:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n else:\n for i in range(n):\n t = ii()\n if t in d:\n d[t] += 1\n else:\n d[t] = 1\n return d\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start = 1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep = ' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\ndef swap(g, a, b):\n w = 1000\n t = g[a]\n g[a] = g[b]\n g[b] = t\n for i in range(n):\n for j in range(len(g[i])):\n if g[i][j] == a:\n g[i][j] = w\n if g[i][j] == b:\n g[i][j] = a\n for i in range(n):\n for j in range(len(g[i])):\n if g[i][j] == w:\n g[i][j] = b\n\ndom = set()\nfor i in range(6):\n for j in range(i, 6):\n dom.add(f'{i}{j}')\n\n\nn, m = mi()\ng = [[] for i in range(n)]\ndeg = [0]*n\nfor i in range(m):\n u, v = mi()\n g[u - 1].append(v - 1)\n g[v - 1].append(u - 1)\n deg[u - 1] += 1\n deg[v - 1] += 1\n\nres = 0\nif n < 7:\n print(m)\n\nelse:\n m = deg[0]\n pos = 0\n for i in range(1,6):\n if deg[i] < m:\n m = deg[i]\n pos = i\n\n if m < deg[6]:\n swap(g, pos, 6)\n deg[pos], deg[6] = deg[6], deg[pos]\n\n rm = 0\n for i in range(6):\n k = 0\n for j in g[6]:\n if i not in g[j]:\n k += 1\n rm = max(rm, k)\n\n\n print((sum(deg[:6]) - deg[6])//2 + rm)\n\n\n\n\n"}, {"source_code": "n,m = map(int,raw_input().split(\" \"))\ndegrees = [0]*n\nfor i in range(m):\n\ta,b = map(int,raw_input().split(\" \"))\n\tdegrees[a-1] += 1\n\tdegrees[b-1] += 1\n\ndegrees.sort(reverse = True)\n\nif n <= 6:\n\tprint m\nelse:\n\tans = 0\n\tfor i in degrees[:-1]:\n\t\tans += i\n\tans -=degrees[-1]\n\tans/=2\n\tans += max(degrees[-1],0)\n\tprint ans\n\n\n\n"}, {"source_code": "mp = 9*[9*[0]]\nl = 9*[[]]\nn, m = map(int, input().split())\nans=0\nfor i in range(m):\n a, b = map(int, input().split())\n mp[a][b]=1\n mp[b][a]=1\n l[a].append(b)\n l[b].append(a)\nif m<7:\n ans=m\nelse:\n for i in range (n):\n e=m-len(l[i])\n t=0\n for j in range(n):\n if j==i:\n continue\n h=0\n for k in l[i]:\n h+=(mp[j][k]!=0)\n t=max(t,h)\n ans=max(ans,e+t)\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\n\nedge = [[0] * 10 for _i in range(10)]\ncnt = [0] * 10\nfor i in range(m):\n a, b = map(int, input().split())\n edge[a][b] = edge[b][a] = 1\n cnt[a] += 1\n cnt[b] += 1\n\nif n <= 6:\n print(m)\n exit(0)\nans = 0\n\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n if i == j or edge[i][j] == 0:\n continue\n ct = 0\n for k in range(1, n + 1):\n if edge[i][k] and edge[j][k]:\n ct += 1\n ans = max(ans, m - ct)\n\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\n\nedge = [[0] * 10 for _i in range(10)]\ncnt = [0] * 10\nfor i in range(m):\n a, b = map(int, input().split())\n edge[a][b] = edge[b][a] = 1\n cnt[a] += 1\n cnt[b] += 1\n\nif n <= 6:\n print(m)\n exit(0)\nans = 0\n\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n if i == j or edge[i][j] == 0:\n continue\n ct = 0\n for k in range(1, n + 1):\n if edge[i][k] and edge[j][k]:\n ct += 1\n ans = max(ans, m - ct)\n\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\n\nd = [0 for i in range(7)]\ng = [[] for i in range(7)]\n\nfor i in range(m):\n\tx, y = map(int, input().split())\n\td[x - 1] += 1\n\td[y - 1] += 1\n\t\nmn = min(d)\nm -= mn\nif(mn > 0):\n\tm += 1\nprint(m) \n"}, {"source_code": "n,m = map(int,raw_input().split(\" \"))\ndegrees = [0]*n\nfor i in range(m):\n\ta,b = map(int,raw_input().split(\" \"))\n\tdegrees[a-1] += 1\n\tdegrees[b-1] += 1\n\ndegrees.sort(reverse = True)\n\nif n <= 6:\n\tprint m\nelse:\n\tans = 0\n\tfor i in degrees[:-1]:\n\t\tans += i\n\tans -=degrees[-1]\n\tans/=2\n\tans += 1\n\tprint ans"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7: print(m)\nelse:\n if m <= 16: print(m)\n else: print(16)"}, {"source_code": "\ndef dfs(n):\n\n bool[n] = True\n for i in hash[n]:\n if bool[i] == False:\n dfs(i)\n\n\nfrom collections import defaultdict\n\nhash = defaultdict(list)\n\nn,m = map(int,input().split())\nflag = 0\nfor i in range(m):\n a,b = map(int,input().split())\n hash[a].append(b)\n hash[b].append(a)\n if len(hash[a]) == 6 or len(hash[b]) == 6:\n flag = 1\n\nif m == 0:\n print(0)\n exit()\nbool = [False]*(n+1)\nif n<7:\n print(m)\nelse:\n dfs(1)\n\n\n if bool[1:] != [True]*(n):\n print(m)\n else:\n ans = 0\n for i in range(1,8):\n for j in range(1,8):\n if i!=j:\n z = 6-len(hash[j])\n if i in hash[j]:\n if z == 0:\n ans = max(ans,1+m-len(hash[i]))\n else:\n ans = max(ans,z+m-len(hash[i]))\n else:\n\n ans = max(ans,z+m-len(hash[i])-1)\n\n\n\n print(ans)\n\n\n\n\n\n\n\n\n"}, {"source_code": "from itertools import permutations\n\nn,m = map(int,input().split())\nnode = [0, 1, 2, 3, 4, 5, 6]\nnode = node[:n]\ng = []\nfor _ in range(m):\n a,b = map(int,input().split())\n g.append((a-1,b-1))\n\nans = 0\nfor pp in permutations(node):\n D = [[False] * 7 for _ in range(7)]\n for i in range(7):\n D[6][i] = D[i][6] = True\n cnt = 0\n cnt2 = 0\n h = -1\n if 6 in pp:\n h = pp.index(6)\n for a,b in g:\n if a == h or b == h:\n cnt2 += 1\n if not D[pp[a]][pp[b]]:\n D[pp[a]][pp[b]] = True\n D[pp[b]][pp[a]] = True\n cnt += 1\n if cnt2:\n cnt += 1\n ans = max(ans, cnt)\n\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nif n <= 6:\n print(m)\nelse:\n A = {i: [] for i in range(1, 8)}\n for i in range(m):\n x, y = map(int, input().split())\n A[x].append(y)\n A[y].append(x)\n Min = 7\n for key in A:\n Min = min(len(A[key]), Min)\n if Min == 0:\n print(m)\n else:\n print(m - Min + 1)"}, {"source_code": "n,m = map(int,input().split())\nl =[[] for _ in range(n)]\nfor i in range(m):\n\tk,p = map(int,input().split())\n\tl[k-1].append(p)\n\tl[p-1].append(k)\nif n<7 or m==0:\n\tprint(m)\nelse:\n\tk = [len(l[i]) for i in range(n)]\n\tmi=9999\n\tfor i in range(n):\n\t for j in range(i+1,n):\n\t x = k[i]+k[j]-1 if (i+1) in l[j] else k[i]+k[j]\n\t x = max(0,x-6)\n\t if mi>x:\n\t mi = x\n\tprint(m - mi)"}, {"source_code": "n,m = map(int,input().split())\nl =[[] for _ in range(n)]\nfor i in range(m):\n\tk,p = map(int,input().split())\n\tl[k-1].append(p)\n\tl[p-1].append(k)\nif n<7 or m==0:\n\tprint(m)\nelse:\n\tk = [len(l[i]) for i in range(n)]\n\tmi=9999\n\tfor i in range(n):\n\t for j in range(i+1,n):\n\t x = k[i]+k[j]-1 if (i+1) in l[j] else k[i]+k[j]\n\t x = max(0,x-6)\n\t if mi>x:\n\t mi = x\n\tprint(m - mi)"}, {"source_code": "\nimport sys\n\n\nclass UnionFind:\n def __init__(self, size):\n self.parent = [i for i in range(size)]\n self.rank = [0 for _ in range(size)]\n\n def find(self, x):\n if self.parent[x] == x:\n return x\n else:\n return self.find(self.parent[x])\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n\n if self.rank[x] < self.rank[y]:\n self.parent[x] = y\n else:\n self.parent[y] = x\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def component(self):\n comp = set()\n for i in self.parent:\n p = self.find(i)\n comp.add(p)\n return comp\n\n def componentNum(self):\n return len(self.component())\n\n\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\nUn = UnionFind(N)\n\nfor a, b in Edges:\n Un.union(a, b)\n\nif Un.componentNum() != 1 or N <= 6:\n ans = M\nelse:\n in_edges = [0]*N\n for a, b in Edges:\n in_edges[a] += 1\n in_edges[b] += 1\n\n min_edges = in_edges.index(min(in_edges))\n\n used_edges = 0\n ans = 0\n for a, b in Edges:\n if a != min_edges and b != min_edges:\n used_edges += 1\n if min(in_edges) > 0:\n ans += used_edges+1\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\n\nd = [0 for i in range(7)]\ng = [[] for i in range(7)]\n\nfor i in range(m):\n\tx, y = map(int, input().split())\n\tx -= 1\n\ty -= 1\n\td[x] += 1\n\td[y] += 1\n\t\n\tg[x].append(y)\n\tg[y].append(x)\n\t\nmn = min(d)\nfor i in range(7):\n\tfor j in range(i):\n\t\tcnt = 0\n\t\tfor k in range(7):\n\t\t\tif((k in g[i]) and (k in g[j])):\n\t\t\t\tcnt += 1\n\t\tmn = min(mn, cnt)\nm -= mn\nif(mn > 0):\n\tm += 1\nprint(m) "}, {"source_code": "n,m=map(int,input().split())\nL=[]\nfor i in range(n):\n h=[]\n L.append(h)\n\nfor i in range(m):\n u,v=map(int,input().split())\n L[u-1].append(v-1)\n L[v-1].append(u-1)\n\nif(n<7):\n print(m)\n\nelse:\n\n ct=[]\n tot=0\n for i in range(0,len(L)):\n ct.append(len(L[i]))\n tot+=len(L[i])\n\n tot-=(2*min(ct))\n print(min(m,(tot//2)+1))\n \n"}, {"source_code": "n,m=map(int,input().split())\nL=[]\nfor i in range(n):\n h=[]\n L.append(h)\n\nfor i in range(m):\n u,v=map(int,input().split())\n L[u-1].append(v-1)\n L[v-1].append(u-1)\n\nif(n<7):\n print(m)\n\nelse:\n\n ct=[]\n tot=0\n for i in range(0,len(L)):\n ct.append(len(L[i]))\n tot+=len(L[i])\n\n tot-=(2*min(ct))\n print(min(m,(tot//2)+1))\n \n"}, {"source_code": "x,y=map(int,input().split())\nk=0\nw=0\nfor __ in range(y):\n a,b=map(int,input().split())\n if k==0 and b==7:\n w+=1\n k=1\n if b!=7:\n w+=1\nprint(w) "}, {"source_code": "import sys\nimport math\nfrom functools import reduce\nimport bisect\n\n\ndef getN():\n return int(input())\n\n\ndef getNM():\n return map(int, input().split())\n\n\ndef getList():\n return list(map(int, input().split()))\n\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\ndef index(a, x):\n i = bisect.bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return i\n return False\n\n\n#############\n# MAIN CODE #\n#############\n\n\nn, m = getNM()\nadj = [[] for _ in range(n)]\n\nfor _ in range(m):\n a, b = getNM()\n a -= 1\n b -= 1\n adj[a].append(b)\n adj[b].append(a)\nif n < 7 or m ==0:\n print(min(m, 16))\n exit()\nadj.sort(key=lambda ribs: len(ribs))\nprint(m - len(adj[0]) + 1)\n"}, {"source_code": "n, m = map(int, input().split())\n\ng = [0]*n\n\nfor i in range(m):\n\ta, b = map(int, input().split())\n\tg[a-1] += 1\n\tg[b-1] += 1\n\n\ng = sorted(g)\n\ni = 0\n\nif m >= 16:\n\tif g[1] < 6:\n\t\ti = (6-g[1])+(6-g[2])+(6-g[3])+(6-g[4])+(6-g[5])+(6-g[6])\n\tprint(16-i)\nelse:\n\tprint(m)\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\n\nif N <= 6:\n ans = M\nelse:\n in_edges = [0]*N\n for a, b in Edges:\n in_edges[a] += 1\n in_edges[b] += 1\n\n min_edges = in_edges.index(min(in_edges))\n\n used_edges = 0\n ans = 0\n for a, b in Edges:\n if a != min_edges and b != min_edges:\n used_edges += 1\n if min(in_edges) > 0:\n ans += used_edges+1\nprint(ans)\n"}, {"source_code": "\nimport sys\n\n\nclass UnionFind:\n def __init__(self, size):\n self.parent = [i for i in range(size)]\n self.rank = [0 for _ in range(size)]\n\n def find(self, x):\n if self.parent[x] == x:\n return x\n else:\n return self.find(self.parent[x])\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n\n if self.rank[x] < self.rank[y]:\n self.parent[x] = y\n else:\n self.parent[y] = x\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def component(self):\n comp = set()\n for i in self.parent:\n p = self.find(i)\n comp.add(p)\n return comp\n\n def componentNum(self):\n return len(self.component())\n\n\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\nUn = UnionFind(N)\n\nfor a, b in Edges:\n Un.union(a, b)\n\nif Un.componentNum() != 1 or N <= 6:\n ans = M\nelse:\n in_edges = [0]*N\n for a, b in Edges:\n in_edges[a] += 1\n in_edges[b] += 1\n\n min_edges = in_edges.index(min(in_edges))\n\n used_edges = 0\n ans = 0\n for a, b in Edges:\n if a != min_edges and b != min_edges:\n used_edges += 1\n if min(in_edges) > 0:\n ans += used_edges+1\nprint(ans)\n"}, {"source_code": "\nimport sys\n\n\nclass UnionFind:\n def __init__(self, size):\n self.parent = [i for i in range(size)]\n self.rank = [0 for _ in range(size)]\n\n def find(self, x):\n if self.parent[x] == x:\n return x\n else:\n return self.find(self.parent[x])\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n\n if self.rank[x] < self.rank[y]:\n self.parent[x] = y\n else:\n self.parent[y] = x\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def component(self):\n comp = set()\n for i in self.parent:\n p = self.find(i)\n comp.add(p)\n return comp\n\n def componentNum(self):\n return len(self.component())\n\n\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\nUn = UnionFind(N)\n\nfor a, b in Edges:\n Un.union(a, b)\n\nif Un.componentNum() != 1 or N <= 6:\n ans = M\nelse:\n in_edges = [0]*N\n for a, b in Edges:\n in_edges[a] += 1\n in_edges[b] += 1\n\n min_edges = in_edges.index(min(in_edges))\n\n used_edges = 0\n ans = 0\n for a, b in Edges:\n if a != min_edges and b != min_edges:\n used_edges += 1\n if min(in_edges) > 0:\n ans += used_edges+1\nprint(ans)\n"}, {"source_code": "n,k = map(int,input().split())\ns = [[0 for i in range(8)] for j in range(8)]\nfor i in range(k):\n\tu,v = map(int,input().split())\n\ts[u][v] = 1\n\ts[v][u] = 1\nif(n <= 6 or k == 0):\n\tprint(k)\nelse:\n\tm = 10\n\tfor i in range(1,8):\n\t\ts1 = sum(s[i])\n\t\tif(s1 < m):\n\t\t\tm = s1\n\ta = [[0,0,0]]\n\tfor i in range(1,8):\n\t\tif(sum(s[i]) == m ):\n\t\t\tf = i\n\t\t\tfor j in range(1,8):\n\t\t\t\tif(f == j):\n\t\t\t\t\tcontinue\n\t\t\t\tct = 0\n\t\t\t\tfor k in range(1,8):\n\t\t\t\t\tif s[f][k] != s[j][k]:\n\t\t\t\t\t\tct += 1\n\t\t\t\tif s[j][f] == 1:\n\t\t\t\t\tct -= 1\n\t\t\t\t#print(j,f,ct)\n\t\t\t\ta.append([ct,j,f])\n\ta.sort()\n\tind1 = a[-1][1]\n\tind2 = a[-1][2]\n\tsum = sum1 = 0\n\t#print(ct,ind1,ind2)\n\t#print(s[ind1],s[ind2])\n\tfor i in range(1,8):\n\t\tif(s[ind1][i] == 1 and s[ind2][i] == 1):\n\t\t\tsum1 += 1\n\tfor i in range(1,8):\n\t\tif i == ind1 or i == ind2:\n\t\t\tcontinue\n\t\tfor j in range(1,8):\n\t\t\tif j == ind1 or j == ind2:\n\t\t\t\tcontinue\n\t\t\tsum += s[i][j]\n\tprint(a[-1][0]+sum1+(sum//2))\n"}, {"source_code": "n=list(map(int,input().split()))\ne=n[1]\nn=n[0]\nd={}\nfor itr in range(1,n+1):\n d[itr]=[]\nfor i in range(e):\n a=list(map(int,input().split()))\n d[a[0]].append(a[1])\n d[a[1]].append(a[0])\n#print(d)\nb=[]\nfor i in d:\n b.append(len(d[i]))\nb.sort()\nif n<=6:\n print(e)\nelse:\n m=min(b)\n ans=e-m\n for i in d:\n if len(d[i])==m: k=i\n if k!=7:\n d[k],d[7]=d[7],d[k]\n for i in d:\n for j in range(len(d[i])):\n if d[i][j]==k: d[i][j]=7\n elif d[i][j]==7: d[i][j]=k\n domino=[(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(2,2),(2,3),(2,4),(2,5),(2,6),(3,3),(3,4),(3,5),(3,6),(4,4),(4,5),(4,6),(5,5),(5,6),(6,6)]\n for i in range(1,7):\n for j in d[i]:\n if j==7 or j<i: continue\n else: domino.remove((i,j))\n #print(domino)\n for i in domino:\n if (i[0] in d[7]) or (i[1] in d[7]): continue\n else: domino.remove(i)\n dd={}\n possible=0\n for i in range(1,7):\n count=0\n for itr in domino:\n if itr[0]==i:\n if itr[1] in d[7]: count+=1\n elif itr[1]==i:\n if itr[0] in d[7]: count+=1\n possible=max(count,possible)\n print(ans+possible)\n \n "}, {"source_code": "n,m=map(int,input().split())\nL=[]\nfor i in range(n):\n h=[]\n L.append(h)\n\nfor i in range(m):\n u,v=map(int,input().split())\n L[u-1].append(v-1)\n L[v-1].append(u-1)\n\nif(n<7):\n print(m)\n\nelse:\n\n ct=[]\n tot=0\n for i in range(0,len(L)):\n ct.append(len(L[i]))\n tot+=len(L[i])\n\n tot-=(2*min(ct))\n print(min(m,(tot//2)+1))\n \n"}, {"source_code": "n, m = map(int, input().split())\na = [0] * m\nfor i in range(m):\n b, c = map(int, input().split())\n a[i] = [b -1, c - 1]\ncol = [0] * 7\nz = set()\nans = 0\nfor i1 in range(6):\n for i2 in range(6):\n for i3 in range(6):\n for i4 in range(6):\n for i5 in range(6):\n for i6 in range(6):\n for i7 in range(7):\n col[0]= i1 + 1\n col[1] = i2 + 1\n col[2] = i3 + 1\n col[3] = i4 + 1\n col[4] = i5 + 1\n col[5] = i6 + 1\n col[6] = i7 + 1\n for j in range(m):\n z.add(max(col[a[j][0]], col[a[j][1]]) * 10 + min(col[a[j][0]], col[a[j][1]]))\n #print(z)\n #if len(z) > ans:\n #print(col)\n ans = max(ans, len(z))\n z = set()\nprint(ans)\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nselfs=0\nsevens=0\nfor j in range(m):\n a,b=map(int,input().split())\n if a!=b:\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n else:\n selfs+=1\n#find the n vertices that have the most edges\nedges=[]\nunique=set([])\ndef combo(vertex,n,unique,cv):\n maxedge=0\n if n==0:\n #then we go through all the vertices and count their edges that include each other\n edges=0\n unique2=unique.copy()\n used=set([])\n for s in unique:\n for j in vertex[s]:\n if j in unique2:\n if not((s,j) in used) and not((j,s) in used):\n used.add((s,j))\n edges+=1\n #if n==7, i have to check 2 smallest\n if len(unique)==7:\n sorts=vertex.copy()\n sorts.sort(key= lambda x: len(x))\n minlength=len(sorts[0])\n edges-=minlength\n maxsofar=0\n for s in range(len(sorts)):\n if len(sorts[s])==minlength:\n set1=set(sorts[s])\n for j in sorts[s]:\n set2=set(sorts[j])\n leftover=1+len(set1)-len(set1.intersection(set2))\n if len(set1)+len(set2)>=6:\n leftover-=1\n if leftover>maxsofar:\n maxsofar=leftover\n else:\n break\n edges+=maxsofar\n return edges\n else:\n maxedge=0\n for s in range(cv,7):\n if not(s in unique):\n unique1=unique.copy()\n unique1.add(s)\n edge=combo(vertex,n-1,unique1,s+1)\n if edge>=maxedge:\n maxedge=edge\n return maxedge\nmost=combo(vertex,n,unique,0)\nprint(most)"}, {"source_code": "\ndef dfs(n):\n\n bool[n] = True\n for i in hash[n]:\n if bool[i] == False:\n dfs(i)\n\n\nfrom collections import defaultdict\n\nhash= defaultdict(list)\n\nn,m = map(int,input().split())\nflag = 0\nfor i in range(m):\n a,b = map(int,input().split())\n hash[a].append(b)\n hash[b].append(a)\n if len(hash[a]) == 6 or len(hash[b]) == 6:\n flag = 1\n\nbool = [False]*(n+1)\nif n<7:\n print(m)\nelse:\n dfs(1)\n\n\n if bool[1:] != [True]*(n):\n print(m)\n else:\n\n\n if flag == 0:\n print(m)\n else:\n \n if 6<=m<=10:\n print(m)\n elif m == 11:\n print(10)\n elif 12<=m<=18:\n print(m-2)\n else:\n print(16)\n\n\n\n\n\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\n\nif N <= 6:\n ans = M\nelse:\n in_edges = [0]*N\n for a, b in Edges:\n in_edges[a] += 1\n in_edges[b] += 1\n\n min_edges = in_edges.index(min(in_edges))\n\n used_edges = 0\n ans = 0\n for a, b in Edges:\n if a != min_edges and b != min_edges:\n used_edges += 1\n if min(in_edges) > 0:\n ans += used_edges+1\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\ngraph = [[] for _ in range(n)]\nfor _ in range(m):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n graph[u].append(v)\n graph[v].append(u)\nmaxcnt = 0\nfor node1 in range(n):\n for node2 in range(node1 + 1, n):\n used = [[False] * n for _ in range(n)]\n col = list(range(0, node2)) + [node1] + list(range(node2 + 1, n))\n cnt = 0\n for u in range(n):\n for v in graph[u]:\n if not used[col[u]][col[v]]:\n used[col[u]][col[v]] = used[col[v]][col[u]] = True\n cnt += 1\n maxcnt = max(cnt, maxcnt)\nprint(maxcnt)\n"}, {"source_code": "n,k=[int(x) for x in input().split()]\ndic={}\ncounter=0\nopp=0\nfor i in range(k):\n a,b=[int(x) for x in input().split()]\n for i,j in (a,b),(b,a):\n if i not in dic:\n dic[i]=[j]\n else:\n dic[i].append(j)\nfor item in dic:\n if len(dic[item])>0:\n opp=1\n if len(dic[item])==6:\n counter+=1\nif k==21:\n print(16)\nelse:\n print(min(k-counter+opp,k))\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nselfs=0\nsevens=0\nfor j in range(m):\n a,b=map(int,input().split())\n if a!=b:\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n else:\n selfs+=1\n#find the n vertices that have the most edges\nedges=[]\nunique=set([])\ndef combo(vertex,n,unique,cv):\n maxedge=0\n if n==0:\n #then we go through all the vertices and count their edges that include each other\n edges=0\n unique2=unique.copy()\n used=set([])\n for s in unique:\n for j in vertex[s]:\n if j in unique2:\n if not((s,j) in used) and not((j,s) in used):\n used.add((s,j))\n edges+=1\n if len(unique)==7:\n #we will have to remove the 1 with the least connections\n least=min(vertex,key=lambda x: len(x))\n if len(least)>=3:\n edges-=len(least)\n edges+=2\n return min(edges,16)\n else:\n maxedge=0\n for s in range(cv,7):\n if not(s in unique):\n unique1=unique.copy()\n unique1.add(s)\n edge=combo(vertex,n-1,unique1,s+1)\n if edge>=maxedge:\n maxedge=edge\n return maxedge\nmost=combo(vertex,n,unique,0)\nprint(most)"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7: print(m)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n \n ind = 0\n mn = 999\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind = i\n ans = m - mn\n ind2 = 0\n mn = 999\n for i in range(n):\n if i == ind: continue\n count = 0\n for j in range(n):\n if j == ind: continue\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind2 = i\n \n for i in range(n):\n if a[ind2][i] == 0:\n if a[ind][i] == 1:\n ans += 1\n print(ans)"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n count = 0\n for i in range(n):\n for j in range(i + 1, n):\n if a[i][j] == 1: count += 1\n print(count)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n \n ind = 0\n mn = 999\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind = i\n ans = m - mn\n ind2 = 0\n mn = 999\n for i in range(n):\n if i == ind: continue\n count = 0\n for j in range(n):\n if j == ind: continue\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind2 = i\n \n for i in range(n):\n if a[ind2][i] == 0:\n if a[ind][i] == 1:\n ans += 1\n print(ans)"}, {"source_code": "n,k = map(int,input().split())\ns = [[0 for i in range(8)] for j in range(8)]\nfor i in range(k):\n\tu,v = map(int,input().split())\n\ts[u][v] = 1\n\ts[v][u] = 1\nif(n <= 6 or k == 0):\n\tprint(k)\nelse:\n\tm = 10\n\tfor i in range(1,8):\n\t\ts1 = sum(s[i])\n\t\tif(s1 < m):\n\t\t\tm = s1\n\ta = []\n\tfor i in range(1,8):\n\t\tif(sum(s[i]) == m ):\n\t\t\tf = i\n\t\t\tfor j in range(1,8):\n\t\t\t\tif(f == j):\n\t\t\t\t\tcontinue\n\t\t\t\tct = 0\n\t\t\t\tfor k in range(1,8):\n\t\t\t\t\tif s[f][k] == 1 and s[j][k] == 1:\n\t\t\t\t\t\tct += 1\n\t\t\t\t#print(j,f,ct)\n\t\t\t\ta.append([ct,j,f])\n\ta.sort()\n\tind1 = a[0][1]\n\tind2 = a[0][2]\n\tsum = sum1 = 0\n\t#print(a[0][0],ind1,ind2)\n\t#print(s[ind1],s[ind2])\n\tfor i in range(1,8):\n\t\tif(s[ind1][i] == 1 and s[ind2][i] == 1):\n\t\t\tsum1 += 1\n\t\telif(s[ind1][i] != s[ind2][i]):\n\t\t\tsum1 += 1\n\n\tif(s[ind1][ind2] == 1 and s[ind2][ind1] == 1):\n\t\tsum1 -= 1\n\tfor i in range(1,8):\n\t\t#print(s[i])\n\t\tif i == ind1 or i == ind2:\n\t\t\tcontinue\n\t\tfor j in range(1,8):\n\t\t\tif j == ind1 or j == ind2:\n\t\t\t\tcontinue\n\t\t\tsum += s[i][j]\n\t\t#print(sum)\n\tprint(sum1+(sum//2))\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nselfs=0\nsevens=0\nfor j in range(m):\n a,b=map(int,input().split())\n if a!=b:\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n else:\n selfs+=1\n#find the n vertices that have the most edges\nedges=[]\nunique=set([])\ndef combo(vertex,n,unique,cv):\n maxedge=0\n if n==0:\n #then we go through all the vertices and count their edges that include each other\n edges=0\n unique2=unique.copy()\n used=set([])\n for s in unique:\n for j in vertex[s]:\n if j in unique2:\n if not((s,j) in used) and not((j,s) in used):\n used.add((s,j))\n edges+=1\n if len(unique)==7:\n #we will have to remove the 1 with the least connections\n least=min(vertex,key=lambda x: len(x))\n if len(least)>=3:\n edges-=len(least)\n edges+=2\n return min(edges,16)\n else:\n maxedge=0\n for s in range(cv,7):\n if not(s in unique):\n unique1=unique.copy()\n unique1.add(s)\n edge=combo(vertex,n-1,unique1,s+1)\n if edge>=maxedge:\n maxedge=edge\n return maxedge\nmost=combo(vertex,n,unique,0)\nprint(most)"}, {"source_code": "n,m=map(int,input().split())\nfrom collections import defaultdict\ngraph=defaultdict(list)\nfor i in range(m):\n a,b=map(int,input().split())\n graph[a].append(b)\n graph[b].append(a)\nif n<=6:\n print(m)\nelse:\n check=[0,1,2,3,4,5,6,1]\n q=[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,1]]\n count,vis=0,defaultdict(int)\n while q:\n a=q.pop()[1]\n if a in graph:\n for i in graph[a]:\n c=min(a,check[i])\n d=max(a,check[i])\n if (c,d) not in vis:\n count+=1\n vis[(c,d)]+=1\n \n print(count)\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7: print(m)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n \n ind = 0\n mn = -1\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count > mn:\n mn = count\n ind = i\n ans = m - mn\n ind2 = 0\n mn = 999\n for i in range(n):\n if i == ind: continue\n count = 0\n for j in range(n):\n if j == ind: continue\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind2 = i\n \n for i in range(n):\n if a[ind2][i] == 0:\n if a[ind][i] == 1:\n ans += 1\n print(ans)"}, {"source_code": "from sys import stdin\nfrom collections import deque\nfrom copy import copy\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrints_2d = lambda n: [rints() for _ in range(n)]\nget_col = lambda arr, i: [row[i] for row in arr]\n\nn, m = rints()\nedges = deque(rints_2d(m))\n\nif len(set(get_col(edges, 0) + get_col(edges, 1))) < 7:\n print(m)\nelse:\n all, ans = set(), 0\n for i in range(1, 7):\n for j in range(i, 7):\n all.add((i, j))\n\n for i in range(m):\n mem, dis, ext, tem = [0] * (n + 1), copy(all), {j1 for j1 in range(2, 7)}, 1\n dis.discard((1, 1))\n mem[edges[0][0]] = mem[edges[0][1]] = 1\n edges.rotate(-1)\n\n for j in range(m - 1):\n if mem[edges[0][0]] and mem[edges[0][1]]:\n if tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])) in dis:\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n\n elif not (mem[edges[0][0]] or mem[edges[0][1]]):\n if len(ext) >= 2:\n mem[edges[0][0]] = ext.pop()\n mem[edges[0][1]] = ext.pop()\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n else:\n if ext:\n if not mem[edges[0][0]]:\n mem[edges[0][0]] = ext.pop()\n else:\n mem[edges[0][1]] = ext.pop()\n\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n\n edges.rotate(-1)\n\n edges.rotate(-1)\n ans = max(ans, tem)\n print(dis, tem)\n\n print(ans)\n"}, {"source_code": "n,m = map(int,input().split())\nl =[[] for _ in range(n)]\nfor i in range(m):\n\tk,p = map(int,input().split())\n\tl[k-1].append(p)\n\tl[p-1].append(k)\nif n<7 or m==0:\n\tprint(m)\nelse:\n\tk = [len(l[i]) for i in range(n)]\n\tmi=9999\n\tfor i in range(n):\n\t for j in range(i+1,n):\n\t x = k[i]+k[j]-1 if (i+1) in l[j] else k[i]+k[j]\n\t x = max(0,x-6)\n\t if mi>x:\n\t mi = x\n\tprint(m - mi)"}, {"source_code": "n, m = map(int, input().split())\n\nd = [0 for i in range(7)]\ng = [[] for i in range(7)]\n\nfor i in range(m):\n\tx, y = map(int, input().split())\n\tx -= 1\n\ty -= 1\n\td[x] += 1\n\td[y] += 1\n\t\n\tg[x].append(y)\n\tg[y].append(x)\n\t\nmn = min(d)\nfor i in range(7):\n\tfor j in range(i):\n\t\tgood = True\n\t\tfor k in range(7):\n\t\t\tif((k in g[i]) and (k in g[j])):\n\t\t\t\tgood = False\n\t\tif(good):\n\t\t\tmn = 0\nm -= mn\nif(mn > 0):\n\tm += 1\nprint(m) "}, {"source_code": "n, m = map(int, input().split())\n\ng = []\n\nfor i in range(n):\n g.append((i, set()))\n\nfor _ in range(m):\n x, y = map(int, input().split())\n g[x-1][1].add(y-1)\n g[y-1][1].add(x-1)\n\ng.sort(key=lambda x: len(x[1]), reverse=True)\n\n#print(g)\n\nr = 0\nused = set()\nused.add(g[-1][0])\nfor gg in g[:min(n, 7)]:\n r += len(gg[1] - used)\n used.add(gg[0])\n\nif len(g) == 7:\n r += len(used - g[6][1])\n\nprint(r)\n#print(used)"}, {"source_code": "n,m = [int(j) for j in input().split()]\nadj = [set() for i in range(n)]\nfor i in range(m):\n\tl, r = [int(j)-1 for j in input().split()]\n\tadj[l].add(r)\n\tadj[r].add(l)\nif n<7:\n\tprint(m)\nelse:\n\tdeg = 1e12\n\tfor i in range(n):\n\t\tdeg = min(len(adj[i]), deg)\n\tdeg = max(deg-1, 0)\n\tprint(m-deg)"}, {"source_code": "import sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nEdges = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\n\nif N <= 6:\n ans = M\nelse:\n in_edges = [0]*N\n for a, b in Edges:\n in_edges[a] += 1\n in_edges[b] += 1\n\n min_edges = in_edges.index(min(in_edges))\n\n used_edges = 0\n ans = 0\n for a, b in Edges:\n if a != min_edges and b != min_edges:\n used_edges += 1\n if min(in_edges) > 0:\n ans += used_edges+1\nprint(ans)\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\n\nn,m=map(int,input().split())\nvertex=[[] for j in range(7)]\nfor j in range(m):\n a,b=map(int,input().split())\n vertex[a-1].append(b-1)\n vertex[b-1].append(a-1)\n#find the n vertices that have the most edges\nmost=m\nif n==7:\n #make the first 2 the same\n #consider their intersection\n v0=set(vertex[0])\n v1=set(vertex[1])\n most-=(len(v0)+len(v1))\n tot=len(v0.union(v1))\n most+=tot\nif n<=6:\n print(m)\nelse:\n print(most)"}, {"source_code": "n, m = map(int, input().split())\n\ng = [0]*n\n\nfor i in range(m):\n\ta, b = map(int, input().split())\n\tg[a-1] += 1\n\tg[b-1] += 1\n\n\ng = sorted(g)\n\ni = 0\nsum_ = sum(g[1:])\nif n==7 and m > 0 and m < 16:\n\tprint(sum_//2+1)\nelif n==7 and m >= 16:\n\tprint(16)\nelse:\n\tprint(m)\n"}, {"source_code": "n,m=map(int,input().split())\nfrom collections import defaultdict\ngraph=defaultdict(list)\nfor i in range(m):\n a,b=map(int,input().split())\n graph[a].append(b)\n graph[b].append(a)\nif n<=6:\n print(m)\nelse:\n check=[0,1,2,3,4,5,6,1]\n q=[[1,1]]\n count,vis=0,defaultdict(int)\n while q:\n a=q.pop()[1]\n for i in graph[a]:\n c=min(a,check[i])\n d=max(a,check[i])\n if (c,d) not in vis:\n count+=1\n vis[(c,d)]+=1\n q.append([i,check[i]])\n print(count)\n"}, {"source_code": "n, m = map(int, input().split())\ns = [0 for i in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n s[a - 1] += 1\n s[b - 1] += 1\nif n == 7:\n m -= min(s)\n m+=1\nprint(m)"}, {"source_code": "mp = 9*[9*[0]]\nl = 9*[[]]\nn, m = map(int, input().split())\nans=0\nfor i in range(m):\n a, b = map(int, input().split())\n mp[a][b]=1\n mp[b][a]=1\n l[a].append(b)\n l[b].append(a)\nif m<7:\n ans=m\nelse:\n for i in range (n):\n e=m-len(l[i])\n t=0\n for j in range(n):\n if j==i:\n continue\n h=0\n for k in l[i]:\n h+=(mp[j][k]!=0)\n t=max(t,h)\n ans=max(ans,e+t)\nprint(ans)"}, {"source_code": "from sys import stdin\nfrom collections import deque\nfrom copy import copy\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrints_2d = lambda n: [rints() for _ in range(n)]\n\nn, m = rints()\nedges = deque(rints_2d(m))\n\nif n != 7:\n print(m)\nelse:\n all, ans = set(), 0\n for i in range(1, 7):\n for j in range(i, 7):\n all.add((i, j))\n\n for i in range(m):\n mem, dis, ext, tem = [0] * (n + 1), copy(all), {j1 for j1 in range(2, 7)}, 1\n dis.discard((1, 1))\n mem[edges[0][0]] = mem[edges[0][1]] = 1\n edges.rotate(-1)\n\n for j in range(m - 1):\n if mem[edges[0][0]] and mem[edges[0][1]]:\n if tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])) in dis:\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n\n elif not (mem[edges[0][0]] or mem[edges[0][1]]):\n if len(ext) >= 2:\n mem[edges[0][0]] = ext.pop()\n mem[edges[0][1]] = ext.pop()\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n else:\n if ext:\n if not mem[edges[0][0]]:\n mem[edges[0][0]] = ext.pop()\n else:\n mem[edges[0][1]] = ext.pop()\n\n dis.discard(tuple(sorted([mem[edges[0][0]], mem[edges[0][1]]])))\n tem += 1\n\n edges.rotate(-1)\n\n edges.rotate(-1)\n ans = max(ans, tem)\n\n print(ans)\n"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef getdict(n):\n d = {}\n if type(n) is list:\n for i in n:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n else:\n for i in range(n):\n t = ii()\n if t in d:\n d[t] += 1\n else:\n d[t] = 1\n return d\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start = 1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep = ' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\ndef swap(g, a, b):\n w = 1000\n t = g[a]\n g[a] = g[b]\n g[b] = t\n for i in range(n):\n for j in range(len(g[i])):\n if g[i][j] == a:\n g[i][j] = w\n if g[i][j] == b:\n g[i][j] = a\n for i in range(n):\n for j in range(len(g[i])):\n if g[i][j] == w:\n g[i][j] = b\n\ndom = set()\nfor i in range(6):\n for j in range(i, 6):\n dom.add(f'{i}{j}')\n\n\nn, m = mi()\ng = [[] for i in range(n)]\ndeg = [0]*n\nfor i in range(m):\n u, v = mi()\n g[u - 1].append(v - 1)\n g[v - 1].append(u - 1)\n deg[u - 1] += 1\n deg[v - 1] += 1\n\nres = 0\nif n < 7:\n print(m)\n\nelse:\n m = deg[0]\n pos = 0\n for i in range(1,6):\n if deg[i] < m:\n m = deg[i]\n pos = i\n\n if m < deg[6]:\n swap(g, pos, 6)\n deg[pos], deg[6] = deg[6], deg[pos]\n\n rm = 0\n for i in range(6):\n k = 0\n for j in g[6]:\n if i not in g[j]:\n k += 1\n rm = max(rm, k)\n\n\n print((sum(deg[:6]) - deg[6])//2 + rm)\n\n\n\n\n"}, {"source_code": "n,k = map(int,input().split())\ns = [[0 for i in range(8)] for j in range(8)]\nfor i in range(k):\n\tu,v = map(int,input().split())\n\ts[u][v] = 1\n\ts[v][u] = 1\nif(n <= 6 or k == 0):\n\tprint(k)\nelse:\n\tm = 10\n\tfor i in range(1,8):\n\t\ts1 = sum(s[i])\n\t\tif(s1 < m):\n\t\t\tm = s1\n\ta = [[0,0,0]]\n\tfor i in range(1,8):\n\t\tif(sum(s[i]) == m ):\n\t\t\tf = i\n\t\t\tfor j in range(1,8):\n\t\t\t\tif(f == j):\n\t\t\t\t\tcontinue\n\t\t\t\tct = 0\n\t\t\t\tfor k in range(1,8):\n\t\t\t\t\tif s[f][k] != s[j][k]:\n\t\t\t\t\t\tct += 1\n\t\t\t\tif s[j][f] == 1:\n\t\t\t\t\tct -= 1\n\t\t\t\t#print(j,f,ct)\n\t\t\t\ta.append([ct,j,f])\n\ta.sort()\n\tind1 = a[-1][1]\n\tind2 = a[-1][2]\n\tsum = sum1 = 0\n\t#print(ct,ind1,ind2)\n\t#print(s[ind1],s[ind2])\n\tfor i in range(1,8):\n\t\tif(s[ind1][i] == 1 and s[ind2][i] == 1):\n\t\t\tsum1 += 1\n\tfor i in range(1,8):\n\t\tif i == ind1 or i == ind2:\n\t\t\tcontinue\n\t\tfor j in range(1,8):\n\t\t\tif j == ind1 or j == ind2:\n\t\t\t\tcontinue\n\t\t\tsum += s[i][j]\n\tprint(a[-1][0]+sum1+(sum//2))\n"}, {"source_code": "n, m = map(int, input().split())\n\ng = []\n\nfor i in range(n):\n g.append((i, set()))\n\nfor _ in range(m):\n x, y = map(int, input().split())\n g[x-1][1].add(y-1)\n g[y-1][1].add(x-1)\n\ng.sort(key=lambda x: len(x[1]), reverse=True)\n\n#print(g)\n\nr = 0\nused = set()\nused.add(g[-1][0])\nfor gg in g[:min(n, 7)]:\n r += len(gg[1] - used)\n used.add(gg[0])\n\nif len(g) == 7:\n r += len(used - g[6][1])\n\nprint(r)\n#print(used)"}, {"source_code": "n,m=map(int,input().split())\nif n<7:\n print(m)\nelse:\n print(min(16,m))"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7: print(m)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n \n ind = 0\n mn = -1\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count > mn:\n mn = count\n ind = i\n ans = m - mn\n ind2 = 0\n mn = 999\n for i in range(n):\n if i == ind: continue\n count = 0\n for j in range(n):\n if j == ind: continue\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind2 = i\n \n for i in range(n):\n if a[ind2][i] == 0:\n if a[ind][i] == 1:\n ans += 1\n print(ans)"}, {"source_code": "n, m = map(int, input().split())\n\nif n != 7:\n print(m)\n exit()\n\ngraph = [set() for _ in range(n)]\n\nfor _ in range(m):\n u, v = [int(x) - 1 for x in input().split()]\n graph[u].add(v)\n graph[v].add(u)\n\nanswer = 0\nfor u in range(n):\n for v in range(n):\n if u == v:\n continue\n adj = u in graph[v]\n wo = m - len(graph[u]) - len(graph[v]) + adj\n answer = max(answer, adj + wo + (len(graph[u] & graph[v])))\n\nprint(answer)\n"}, {"source_code": "#!/usr/bin/env python3\n\n\ndef calculatePossibleIncrease(setMain: set, setLeft: set, setMainIndex: int):\n directDelta = len(setMain.union(setLeft).difference(\n setMain.union({setMainIndex})))\n\n indirectDelta = len(setLeft.intersection({setMainIndex})) # x <-> x\n\n return directDelta + indirectDelta\n\n\ndef calculateMaxPossibleEdges(verts, leftOutVertIndex):\n tempSetEdgesCount = len(verts[leftOutVertIndex])\n\n retVal = -1\n for i in range(len(verts)):\n if len(verts[i]) == tempSetEdgesCount:\n retVal = max(\n retVal,\n calculatePossibleIncrease(\n verts[i], verts[leftOutVertIndex], i)\n )\n\n return retVal\n\n\ndef calculateDirectAnswer(verts, leftOutVertIndex):\n doubleEdgeCount = 0\n for i in range(len(verts)):\n if i != leftOutVertIndex:\n doubleEdgeCount += len(verts[i].difference({leftOutVertIndex}))\n return doubleEdgeCount // 2\n\n\ndef main():\n vertsCount, edgesCount = tuple(map(int, input('').split(' ')))\n\n if(vertsCount < 7):\n print(edgesCount)\n exit(0)\n\n verts = []\n for i in range(vertsCount):\n verts.append(set())\n\n for _t in range(edgesCount):\n _x, _y = tuple(\n map(lambda x: int(x) - 1, input('').split(' '))\n )\n\n verts[_x].add(_y)\n verts[_y].add(_x)\n\n edgesCount = [len(y) for y in verts]\n minEdgesCount = min(edgesCount)\n\n directAnswer = -1\n indirectAnswer = -1\n answer = -1\n for i in range(vertsCount):\n if len(verts[i]) == minEdgesCount:\n directAnswer = calculateDirectAnswer(verts, i)\n indirectAnswer = calculateMaxPossibleEdges(verts, i)\n\n answer = max(answer, directAnswer + indirectAnswer)\n\n return answer\n\n\nif __name__ == '__main__':\n print(main())\n"}, {"source_code": "n,m = map(int,input().split())\nl =[[] for _ in range(n)]\nfor i in range(m):\n\tk,p = map(int,input().split())\n\tl[k-1].append(p)\n\tl[p-1].append(k)\nif n<7 or m==0:\n\tprint(m)\nelse:\n\tk = [len(l[i]) for i in range(n)]\n\tmi=9999\n\tfor i in range(n):\n\t for j in range(i+1,n):\n\t x = k[i]+k[j]-1 if (i+1) in l[j] else k[i]+k[j]\n\t x = max(0,x-6)\n\t if mi>x:\n\t mi = x\n\tprint(m - mi)"}, {"source_code": "n, m = [int(x) for x in input().split()]\nif n < 7:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n count = 0\n for i in range(n):\n for j in range(i + 1, n):\n if a[i][j] == 1: count += 1\n print(count)\nelse:\n a = []\n for i in range(n):\n t = []\n for i in range(n):\n t.append(0)\n a.append(t)\n for i in range(m):\n t1, t2 = [int(x) for x in input().split()]\n a[t1 - 1][t2 - 1] = 1\n a[t2 - 1][t1 - 1] = 1\n \n ind = 0\n mn = 999\n for i in range(n):\n count = 0\n for j in range(n):\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind = i\n ans = m - mn\n ind2 = 0\n mn = 999\n for i in range(n):\n if i == ind: continue\n count = 0\n for j in range(n):\n if j == ind: continue\n if a[i][j] == 1: count += 1\n if count < mn:\n mn = count\n ind2 = i\n \n for i in range(n):\n if a[ind2][i] == 0:\n if a[ind][i] == 1:\n ans += 1\n print(ans)"}, {"source_code": "import math\n\ndef test(n, matrix, a, b):\n c = 1\n d = []\n for i in range(7):\n if i == b:\n d.append(d[a])\n else:\n d.append(c)\n c += 1\n\n result = set()\n for i in range(n):\n for j in range(i):\n if matrix[i][j] == 0:\n continue\n\n p = d[i]\n q = d[j]\n if p > q:\n p = d[j]\n q = d[i]\n\n result.add(p * 10 + q)\n\n return len(result)\n\ndef main():\n (n, m) = tuple([int(x) for x in input().split()])\n matrix = []\n for i in range(n):\n matrix.append([0] * n)\n for i in range(m):\n (x, y) = tuple([int(x) for x in input().split()])\n matrix[x - 1][y - 1] = 1\n matrix[y - 1][x - 1] = 1\n\n result = 0\n for i in range(n):\n for j in range(i):\n result = max(result, test(n, matrix, j, i))\n print(result)\n\nif __name__ == '__main__':\n main()\n"}], "src_uid": "11e6559cfb71b8f6ca88242094b17a2b"} {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Nov 17 12:35:15 2012\n\n@author: bluebird\n\"\"\"\nclass solve:\n def __init__(self,n):\n self.s = set()\n self.n = n\n def answer(self):\n for x in range(10):\n for y in range(10):\n self.dfs(x,y,0)\n return len(self.s) - 1\n def dfs(self,i,j,t):\n if t <= self.n:\n self.s.add(t)\n if t != t*10 + i: self.dfs(i,j,t*10+i)\n if t != t*10 + j: self.dfs(i,j,t*10+j)\n \ndef main():\n n = int(input())\n test = solve(n)\n print test.answer()\n\n\nif __name__ == \"__main__\":\n main()", "positive_code": [{"source_code": "n = int(raw_input())\n\nr = set()\n\ndef tt(a, x, y):\n if a <= n:\n r.add(a)\n if (a * 10 + x != a): tt(a * 10 + x, x, y)\n if (a * 10 + y != a): tt(a * 10 + y, x, y)\n\nfor x in xrange(1, 10):\n for y in xrange(0, x+1):\n tt(0, x, y)\n\nprint len(r)-1"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "import sys\n\nn = int(raw_input()) + 1\nans = 0\ntmp = []\ndef dfs(num, x, y, inx, iny):\n global ans\n if num < n and inx and iny :\n ans += 1\n# tmp.append(num)\n if num > n:\n return \n if x or num :\n if num*10 + x < n:\n dfs(num*10 + x, x, y, 1, iny)\n if y or num :\n if num*10 + y < n:\n dfs(num*10 + y, x, y,inx, 1)\n \nfor x in range(0,10):\n for y in range(x + 1, 10):\n if x:\n dfs(y, x, y, 0, 1)\n dfs(x, x, y, 1, 0)\nprint ans\n#print len(tmp), sorted(tmp)\n\n\n\n"}, {"source_code": "import sys\nimport math\nimport string\nfrom collections import deque\n\n# Function #\ndef read_int() :\n temp = raw_input().split();\n return map(int, temp);\n\ndef read_str() :\n temp = raw_input().split();\n return temp;\n\ndef write(output) :\n sys.stdout.write(output);\n \ndef writeln(output) :\n sys.stdout.write(str(output)+'\\n');\n# Class #\n\n\nINF = 9123456789123456789\n# Main Entry #\n\n# Inner Function #\n \nans = set(); \n\nif __name__ == '__main__':\n\n\n\n def dfs(now, x, y) :\n if now <= tc :\n if now != 0 :\n ans.add(now);\n if now*10+x != 0 :\n dfs(now*10+x, x, y);\n if now*10+y != 0 :\n dfs(now*10+y, x, y);\n \n tc = read_int()[0];\n\n for ii in xrange(0, 10) :\n for jj in xrange(ii+1, 10) :\n dfs(0, ii, jj); \n \n print len(ans);\n \n pass\n# End Here #\n \n"}, {"source_code": "n = input()\n\nfrom itertools import *\n\n \n\ndef GEN(x,y):\n Q,i = [ 0 ],0\n while i!= len(Q):\n t = Q[i]\n if t>n: break\n Q += [ Q[i]*10+x , Q[i]*10+y]\n i+=1\n return Q\n\nprint len(set(map(int,reduce(lambda x,y: x+y, [ [ k for k in GEN(i,j) if k<=n] for i,j in combinations(range(0,10),2)]))))-1\n \n"}, {"source_code": "entrada = int(raw_input())\nr = 0\n\ndef generador(n):\n global r\n global entrada\n for i in xrange(0,10):\n if n*10+i >0 and n*10+i <= entrada and valido(n*10+i):\n r+=1\n generador(n*10+i)\n\ndef valido(n):\n return len(set(str(n)))<=2\n\ngenerador(0)\nprint r"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin\n\nn = int(stdin.readline())\n\ndef spam(m):\n if m <= n:\n s.add(m)\n if m or a: spam(m*10+a)\n if m or b: spam(m*10+b)\n\ns = set()\nfor a in range(0, 10):\n for b in range(a+1, 10):\n spam(0)\ns.remove(0)\nprint(len(s))\n"}, {"source_code": "n=input()\nst=set()\ndef dfs(x,l):\n if l>10 or x>n:return\n if x: st.add(x)\n dfs(10*x+a,l+1)\n dfs(10*x+b,l+1)\n \nfor a in xrange(10):\n for b in xrange(a+1,10):\n dfs(0,0)\nprint len(st)"}, {"source_code": "n=input()\n\ncnt=0\ndef dfs(i):\n global cnt,n\n if i>n: return\n if len(set(str(i)))<=2: cnt+=1\n else:return\n for x in xrange(10):\n if i or x: dfs(10*i+x)\ndfs(0)\nprint cnt-1"}, {"source_code": "n = input()\nr = set()\n\ndef f(v):\n\tif 0 < v <= n:\n\t\tv *= 10\n\t\tr.add(v)\n\t\tf(v + x)\n\t\tf(v + y)\n\nfor x in range(10):\n\tfor y in range(10):\n\t\tf(x)\nprint len(r)\n"}, {"source_code": "# 23145\n\nn = input()\nt = 1\ni = 0\n\nwhile n>=t:\n t*=10\n i+=1\n\ni-=1 # 4\nans = (2**i-1)*81 - 72*i\n\n# < 10000\n\na = []\n\nwhile n > 0:\n a.append(n%10)\n n/=10\n\nb = -1\nans += (a[-1]-1)*((2**i-1)*9 + 1)\n\nfor j in range(i)[::-1]:\n for c in range(a[j]):\n if b < 0:\n if c == a[-1]:\n ans += ((2**j-1)*9+1)\n else:\n ans += 2**j\n elif c == b or c == a[-1]:\n ans += 2**j\n if b >= 0 and a[j] != a[-1] and a[j] != b:\n break\n elif b < 0 and a[j] != a[-1]:\n b = a[j]\n\nprint ans + (1 if len(set(a)) <= 2 else 0)\n"}, {"source_code": "n=input()\nans=set()\n\ndef dfs(p,l):\n if p>n or l>10:\n return\n if p>0:\n ans.add(p)\n dfs(p*10+a,l+1)\n dfs(p*10+b,l+1)\n\nfor a in range(0,10):\n for b in range(0,a):\n dfs(0,0)\nprint \"%d\" % len(ans)\n"}, {"source_code": "n=int(input())\na=[]\ndef foo(x,i,j):\n if x>n:\n return\n if x:\n a.append(x)\n if 10*x+i!=x:\n foo(10*x+i,i,j)\n foo(10*x+j,i,j)\nfor i in range(10):\n for j in range(i+1,10):\n foo(0,i,j)\nprint(len(set(a)))\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "num=int(input());cou=0;\ndef traverse(x):\n if(x>num):return\n global cou\n if(len(set([int(j) for j in str(x)]))<=2):\n cou+=1\n for i in range(0,10):traverse(10*x+i)\nfor i in range(1,10):traverse(i)\nprint(cou)"}, {"source_code": "# https://codeforces.com/contest/244/problem/B\n\ndef gen(digit, x, length, S):\n S.append(x)\n \n if length == 10:\n return\n \n if len(digit) == 1:\n for i in range(0, 10):\n next_x = x * 10 + i\n \n if i == digit[0]: \n gen(digit, next_x, length+1, S)\n else:\n gen(digit+[i], next_x, length+1, S)\n \n else:\n next_x1 = x * 10 + digit[0]\n next_x2 = x * 10 + digit[1]\n gen(digit, next_x1, length+1, S)\n gen(digit, next_x2, length+1, S)\n \nS = []\nfor i in range(1, 10):\n gen([i], i, 1, S)\n \nS = sorted(S) \nx = int(input())\n\nl = -1\nu = len(S)\n\nwhile u-l>1:\n md = (u+l) // 2\n if x >= S[md]:\n l = md\n else:\n u = md\nprint(u) "}, {"source_code": "def cnt(s, p):\n ans = 0\n if p > s: ans = 0\n elif len(p) == len(s):\n ans = 1 if len(set(p.lstrip('0'))) <= 2 else 0\n elif len(set(p.lstrip('0'))) > 2: ans = 0\n elif s[:len(p)] > p:\n if len(set(p.lstrip('0'))) == 2:\n ans = 2**(len(s)-len(p))\n elif len(set(p.lstrip('0'))) == 1:\n ans = 1 + 9 * (2**(len(s)-len(p)) - 1)\n else:\n # ab for all a, b != 0\n ans = 10 + 45 * (2**(len(s)-len(p)) - 2)\n ans += 36 * sum([2**l-2 for l in range(2,len(s)-len(p))])\n \n else: ans = sum(cnt(s, p+c) for c in '0123456789')\n\n return ans\n\nprint(cnt(input().strip(), '')-1)\n"}, {"source_code": "n = input()\nans = set()\nfor i in range(10):\n for j in range(i + 1, 10):\n l = []\n if i and i <= n: l.append(i)\n if j and j <= n: l.append(j)\n L = len(l)\n t = 0\n while t < L:\n # print \"======\"\n s = l[t]\n if s * 10 + i <= n :\n l.append(s * 10 + i)\n L += 1\n if s * 10 + j <= n :\n l.append(s * 10 + j)\n L += 1\n t += 1\n for k in l:\n ans.add(k)\nprint len(ans)\n"}, {"source_code": "#CF Round 150. Div II Prob. A - Dividing Orange\nimport sys\n\ndp = [[[-1 for j in range(3)] for i in range (1 << 10)] for k in range(11)]\n\nIn = sys.stdin\nn = In.readline().strip()\n\ndef go (idx, mask, equal):\n if dp[idx][mask][equal] != -1:\n return dp[idx][mask][equal]\n if bin(mask).count(\"1\") > 2:\n return 0\n if idx == len(n):\n return 1\n res = 0\n if idx == 0 or equal == 2:\n res += go(idx + 1, mask, 2)\n elif equal == 1 and int(n[idx]) == 0:\n res += go(idx + 1, mask | 1, 1)\n else:\n res += go(idx + 1, mask | 1, 0) \n for i in range(1, 10):\n if equal == 1 and i > int(n[idx]):\n break\n elif equal == 1 and i == int(n[idx]):\n res += go(idx + 1, mask | (1 << i), 1)\n else:\n res += go(idx + 1, mask | (1 << i), 0)\n dp[idx][mask][equal] = res\n return res\n \nprint(go(0, 0, 1) - 1)"}, {"source_code": "n = int(input())\nres = set()\n\ndef solve(p, l):\n if p > n or l > 10:\n return\n if p > 0:\n res.add(p)\n solve(p * 10 + a, l + 1)\n solve(p * 10 + b, l + 1)\n\nfor a in range(0, 10):\n for b in range(0, a):\n solve(0, 0)\nprint(len(res))\n"}, {"source_code": "n = input()\ndef dfs(x):\n if(x <= n):\n ans.add(x)\n if x or i : dfs(x * 10 + i)\n if x or j : dfs(x * 10 + j)\nans = set()\nfor i in range(10) :\n for j in range(i + 1, 10) :\n dfs(0)\nprint (len(ans) - 1)\n"}, {"source_code": "\nN=int(raw_input())\nans=0\n\ndef fun(n):\n global N,ans\n if n>0 and n<=N:\n ans+=1\n if n>=10**9:\n return\n for i in range(10):\n if 10*n+i>0:\n if len(set(str(10*n+i)))<=2:\n fun(10*n+i)\nfun(0)\nprint ans\n\n \n"}, {"source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as c\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom fractions import Fraction\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(var): sys.stdout.write(str(var))\ndef outln(var): sys.stdout.write(str(var)+\"\\n\")\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\ntemp = pow(10, 8)\n\n\ndef dfs(number):\n if 0 < number <= n:\n answer[0] += 1\n if number >= temp:\n return\n for i in range(10):\n if number * 10 + i > 0:\n if len(set(str(number * 10 + i))) <= 2:\n dfs(number * 10 + i)\n\n\nn = int(data())\nanswer = [0]\ndfs(0)\nif n == pow(10, 9):\n outln(answer[0] + 1)\n exit()\noutln(answer[0])\n"}, {"source_code": "def dfs(num):\n if 0 < num <= n:\n s.add(num)\n num*=10\n dfs(num+x)\n dfs(num+y)\n\nn = int(input())\ns = set()\nfor x in range(10):\n for y in range(10):\n dfs(x)\n\nprint(len(s))\n\n#Copied\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "\ndef main():\n def dfs(v, x, y):\n if v <= n:\n s.add(v)\n if v*10+x != v:\n dfs(v*10+x, x, y)\n if v*10+y != v:\n dfs(v*10+y, x, y)\n\n n = input()\n s = set()\n for x in xrange(10):\n for y in xrange(x):\n dfs(0, x, y)\n print len(s)-1\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = str(int(input()) + 1)\na = int(n[0])\nl = len(n)\nd = 1 << (l - 1)\n\ndef f(a, i):\n global n, l\n if i == l: return 0\n b = int(n[i])\n i += 1\n d = 1 << (l - i)\n if a > b: return b * d + g(b, a, i)\n if a == b: return b * d + f(a, i)\n return (b - 1) * d + g(a, b, i) + 9 * d - 8\n \ndef g(a, b, i):\n global n, l\n if i == l: return 0\n c = int(n[i])\n i += 1\n d = 1 << (l - i)\n if c < a: return 0\n if c == a: return g(a, b, i)\n if c < b: return d\n if c == b: return d + g(a, b, i)\n return 2 * d\n\nprint(a * (9 * d - 8) + 72 * (d - l) + f(a, 1) - 1)"}, {"source_code": "def cnt(s, p):\n\n ans = 0\n\n if p > s: ans = 0\n\n elif len(p) == len(s):\n\n ans = 1 if len(set(p.lstrip('0'))) <= 2 else 0\n\n elif len(set(p.lstrip('0'))) > 2: ans = 0\n\n elif s[:len(p)] > p:\n\n if len(set(p.lstrip('0'))) == 2:\n\n ans = 2**(len(s)-len(p))\n\n elif len(set(p.lstrip('0'))) == 1:\n\n ans = 1 + 9 * (2**(len(s)-len(p)) - 1)\n\n else:\n\n # ab for all a, b != 0\n\n ans = 10 + 45 * (2**(len(s)-len(p)) - 2)\n\n ans += 36 * sum([2**l-2 for l in range(2,len(s)-len(p))])\n\n \n\n else: ans = sum(cnt(s, p+c) for c in '0123456789')\n\n\n\n return ans\n\n\n\nprint(cnt(input().strip(), '')-1)\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)"}, {"source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=10**5 :\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n # print('hi')\n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)"}, {"source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=9*(10**4 ):\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n # print('hi')\n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)"}, {"source_code": "def countDigits(n):\n cnt = 0\n while n:\n n /= 10\n cnt += 1\n return cnt\n\n\ndef makeNum(d1, d2, l, i):\n num = 0\n for j in range(l):\n num *= 10\n if (1 << j) & i:\n num += d1\n else:\n num += d2\n return num\n\n\nn = int(raw_input())\n\nret = set()\ndigits = countDigits(n)\nfor d1 in range(10):\n for d2 in range(d1 + 1, 10):\n for i in range(2 ** digits):\n for l in range(1, digits + 1):\n num = makeNum(d1, d2, l, i)\n if num <= n:\n ret.add(num)\n\nprint len(ret) - 1\n"}, {"source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=10**5:\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n \n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)"}, {"source_code": "a = [[0,1,2,3,4,5,6,7,8,9]]\n\ndef f():\n for i in xrange(8):\n b = []\n for j in xrange(1,10):\n for k in xrange(len(a)):\n for t in a[k]:\n n = str(j) + \"0\"*(i-k)+str(t)\n if (len(set(n)) < 3):\n b.append(int(n))\n a.append(b)\n\nf() \n\nb = [ x for i in xrange(len(a)) for x in a[i]]\nb.append(10**9)\nb.append(10**9+1)\nn = int(raw_input())\n\nfor i in xrange(len(b)):\n if b[i] > n:\n print i-1\n break\n"}, {"source_code": "from collections import deque\ndef check(n):\n s=set([int(i) for i in str(n)])\n if len(s)<=2:\n return 1\n else:\n return 0\nn=int(input())\ns=set()\nq=deque()\nq.append(0)\nwhile(len(q)>0):\n g=q.popleft()\n if g>n:\n break\n s.add(g)\n if g>=n:\n break\n for j in range(0,10):\n if g*10+j not in s and check(g*10+j):\n q.append(g*10+j)\n\nprint(len(s)-1)"}, {"source_code": "n=int(input())\narray=set()\narray.add(10**9)\nfor x in range(10):\n for y in range(10):\n for l in range(1, 10):\n for m in range(1, 2 ** l + 1):\n s = [str(x) if m & (1 << i) else str(y) for i in range(l)]\n u = int(''.join(s))\n if u <= n:\n array.add(u)\narray.remove(0)\n# print (sorted(list(array)))\narray=[u for u in array if u <= n]\nprint(len(array))"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**9\n\nn = int(input())\nif n < 100:\n print(n)\n sys.exit()\na = [[_,set(map(int,list(str(_))))] for _ in range(100)]\nc = 99\nfor k in range(2,11):\n t = (10 ** (k-1))\n for aa in a:\n if aa[0] < t:\n aa[1] = aa[1] | set([0])\n at = a[:]\n for i in range(1,10):\n t = i * (10 ** k)\n for ai, ae in at:\n ac = ai + t\n if ac > n:\n print(c)\n sys.exit()\n if len(ae) < 2:\n ae = ae | set([i])\n if i in ae and len(ae) < 3:\n c += 1\n a.append([ac,ae])\n"}, {"source_code": "ii=lambda:int(input())\nkk=lambda:map(int, input().split())\nll=lambda:list(kk())\nq =[]\ns=set()\nn=ii()\nfor x in range(10):\n\tfor y in range(10):\n\t\tq.append(x)\n\t\twhile q:\n\t\t\tq2 = []\n\t\t\tfor item in q:\n\t\t\t\tif item > 0 and item <= n:\n\t\t\t\t\ts.add(item)\n\t\t\t\t\titem*=10\n\t\t\t\t\tq2.append(item+x)\n\t\t\t\t\tq2.append(item+y)\n\t\t\tq=q2\nprint(len(s))"}, {"source_code": "from copy import deepcopy\n\nN = input()\nA = [ ord( N[ i ] ) - ord( '0' ) for i in range( len( N ) ) ]\n\ndp = [ 0, 0 ]\ndp = [ deepcopy( dp ) for i in range( 10 + 1 ) ]\ndp = [ deepcopy( dp ) for i in range( 10 + 1 ) ]\ndp = [ deepcopy( dp ) for i in range( len( A ) + 1 ) ]\ndp[ 0 ][ 10 ][ 10 ][ 0 ] = 1\n\nfor i in range( len( A ) ):\n for j in range( 10 + 1 ):\n for k in range( 10 + 1 ):\n for l in range( 2 ):\n lim = 9\n if not l:\n lim = A[ i ]\n for d in range( lim + 1 ):\n if d == 0 and j == 10 and k == 10:\n dp[ i + 1 ][ 10 ][ 10 ][ 1 ] += dp[ i ][ j ][ k ][ l ]\n else:\n if j == 10 or j == d:\n dp[ i + 1 ][ d ][ k ][ l or d < lim ] += dp[ i ][ j ][ k ][ l ]\n else:\n if k == 10:\n if d < j:\n dp[ i + 1 ][ d ][ j ][ l or d < lim ] += dp[ i ][ j ][ k ][ l ]\n else:\n dp[ i + 1 ][ j ][ d ][ l or d < lim ] += dp[ i ][ j ][ k ][ l ]\n else:\n if d != j and d != k: continue\n dp[ i + 1 ][ j ][ k ][ l or d < lim ] += dp[ i ][ j ][ k ][ l ]\n\nans = 0\nfor i in range( 10 ):\n for j in range( 10 + 1 ):\n for k in range( 2 ):\n ans += dp[ len( A ) ][ i ][ j ][ k ]\n\nprint( ans )\n"}, {"source_code": "#d=sorted(d,key=lambda x:(len(d[x]),-x)) d=dictionary d={x:set() for x in arr}\n#n=int(input())\n#n,m,k= map(int, input().split())\nimport heapq\n#for _ in range(int(input())):\n#n,k=map(int, input().split())\n#input=sys.stdin.buffer.readline\n#for _ in range(int(input())):\ndef dfs(x):\n if 0< x <=n :\n s.add(x)\n x*=10\n dfs(x+i)\n dfs(x+j)\n\nn=int(input())\n#arr = list(map(int, input().split()))\ns=set()\n\nfor i in range(1,10):\n for j in range(10):\n dfs(i)\nprint(len(s))\n"}, {"source_code": "#!/home/kameda/pyenv2/bin/python\n\npower2list = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n'''\nIf the head of n (:(len(str(n))=i) is fixed as 'x',\nnumber of candidates trailing digit is\n9*(2^(i-1)-1)+1\n9: len(range(0,10) except x)\n(2^(i-1)-1): number of patterns like (xxy xyx xyy) if i=3\n1: number of patterns like xxx if i=3\n\ntrailing_candidates = []\nfor i in range(1, 11):\n trailing_candidates.append(9*(2**(i-1)-1)+1)\n\n'''\ntrailing_candidates = [1, 10, 28, 64, 136, 280, 568, 1144, 2296, 4600]\n'''\nFor each head (1..9), trailing_candidates can be applied.\nSo, cumulative candidates lower than 10^i is calculated as below.\n\ncumulative_candidates = [9]\nfor i in range(1, 10):\n cumulative_candidates.append(9*trailing_candidates[i]+cumulative_candidates[i-1])\n\n'''\ncumulative_candidates = [9, 99, 351, 927, 2151, 4671, 9783, 20079, 40743, 82143]\n\ndef main_y_fixed(n, y):\n #Count candidates which is n or less starting with n[0] (=x) given y (!=x)\n x = n[0]\n len_n = len(n)\n uln = 0\n if len_n == 1:\n return 1\n if int(y) > int(x):\n if int(n[1]) < int(x): # e.g. 42????? given 8 -> No candidates\n pass\n elif int(n[1]) == int(x): # e.g. 44????? given 8\n uln += main_y_fixed(n[1:], y)\n elif int(n[1]) < int(y): # e.g. 47????? given 8 -> 4488888 is the largest\n uln += power2list[len_n-2]\n elif int(n[1]) == int(y): # e.g. 48????? given 8\n uln += power2list[len_n-2]\n uln += main_y_fixed(n[1:], x)\n elif int(n[1]) > int(y): # e.g. 49????? given 8 -> 4888888 is the largest\n uln += power2list[len_n-1]\n elif int(y) == int(x):\n raise ValueError('2nd argument should be different from 1st degit of 1st argument')\n elif int(y) < int(x):\n if int(n[1]) < int(y): # e.g. 82????? given 4 -> No candidates\n pass\n elif int(n[1]) == int(y): # e.g. 84????? given 4\n uln += main_y_fixed(n[1:], x)\n elif int(n[1]) < int(y): # e.g. 87????? given 4 -> 8488888 is the largest\n uln += power2list[len_n-2]\n elif int(n[1]) == int(x): # e.g. 88????? given 4\n uln += power2list[len_n-2]\n uln += main_y_fixed(n[1:], y)\n elif int(n[1]) > int(y): # e.g. 89????? given 4 -> 8888888 is the largest\n uln += power2list[len_n-1]\n return uln\n\ndef main(n):\n #Count candidates which is n or less starting with n[0] (=x)\n x = n[0]\n len_n = len(n)\n uln = 0\n if len_n == 1:\n return 1\n if int(n[1]) > 0:\n for i in range(0, int(n[1])): #int(n[0]), ~int(n[1])-1 and all trailings\n if i != int(n[0]):\n uln += power2list[len_n-2]\n else:\n uln += trailing_candidates[len_n-2]\n if len_n == 2:\n return uln+1\n if int(n[0]) < int(n[1]):\n if int(n[2]) < int(n[0]): #e.g. 482????? -> 47777777 is the largest.\n pass\n elif int(n[2]) == int(n[0]): #e.g. 484?????\n uln += main_y_fixed(n[2:], n[1]) \n elif int(n[2]) < int(n[1]): #e.g. 486????? -> 48488888 is the largest.\n uln += power2list[len_n-3]\n elif int(n[2]) == int(n[1]): #e.g. 488?????\n uln += power2list[len_n-3]\n uln += main_y_fixed(n[2:], n[0]) \n elif int(n[2]) > int(n[1]): #e.g. 489?????\n uln += power2list[len_n-2]\n elif int(n[0]) == int(n[1]):\n uln += main(n[1:])\n elif int(n[0]) > int(n[1]):\n if int(n[2]) < int(n[1]): #e.g. 842????? -> 83333333 is the largest.\n pass\n elif int(n[2]) == int(n[1]): #e.g. 844?????\n uln += main_y_fixed(n[2:], n[0]) \n elif int(n[2]) < int(n[0]): #e.g. 846????? -> 84488888 is the largest.\n uln += power2list[len_n-3]\n elif int(n[2]) == int(n[0]): #e.g. 848?????\n uln += power2list[len_n-3]\n uln += main_y_fixed(n[2:], n[1]) \n elif int(n[2]) > int(n[0]): #e.g. 849?????\n uln += power2list[len_n-2]\n return uln\n\nif __name__ == \"__main__\":\n N = raw_input()\n Len_N = len(N)\n if Len_N <= 2:\n print(N)\n exit(0)\n Uln = cumulative_candidates[Len_N-2] # below 10^len_n\n Uln += (int(N[0])-1)*trailing_candidates[Len_N-1] # between 10^len_n and n[0]*10^len_n\n Uln += main(N)\n print(Uln)\n exit(0)\n \n"}, {"source_code": "def dfs(num):\n if 0 < num <= n:\n s.add(num)\n num*=10\n dfs(num+x)\n dfs(num+y)\n\n\nn = int(input())\ns = set()\nfor x in range(10):\n for y in range(10):\n dfs(x)\n \nprint(len(s))"}, {"source_code": "def find(x):\n if 0<x<=n:\n p.add(x)\n x*=10\n find(x+i)\n find(x+j)\nn=int(input())\np= set()\nfor i in range(10):\n for j in range(10):\n find(i)\nprint(len(p))\n\n"}, {"source_code": "# ~*~ coding:utf-8 ~*~\nfrom itertools import combinations\nfrom itertools import product\nfrom itertools import combinations_with_replacement\n\nn = int(raw_input())\nd = len(str(n))\nf = [[''.join(g)\n for g in list(product(('{0}', '{1}'), repeat=i))\n if g.count(g[0]) != len(g)]\n for i in xrange(1, d + 1)]\n\ndigits = list(combinations(range(10), 2))\n\nr = 0\nfor i in xrange(d):\n for t in digits:\n for s in f[i]:\n if t[0] == 0 and s.startswith('{0}'):\n continue\n else:\n k = int(s.format(*t))\n if k <= n:\n r += 1\n for j in xrange(1, 10):\n k = int(str(j) * (i + 1))\n if k <= n:\n r += 1\nprint r\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "n=input()\ns=set()\nfor x in range(10):\n for y in range(x):\n for i in range(1<<10):\n v=0\n for j in range(10):\n v=v*10+(x if (1<<j)&i else y)\n while v>0:\n if v<=n:s.add(v)\n v/=10\nprint len(s)\n"}, {"source_code": "def dfs(n,v,x,y,s):\n if v<=n:\n s.add(v)\n if v*10+x!=v: dfs(n,v*10+x,x,y,s)\n if v*10+y!=v: dfs(n,v*10+y,x,y,s)\nn=input()\ns=set()\nfor x in range(10):\n for y in range(x):\n dfs(n,0,x,y,s)\nprint len(s)-1\n"}, {"source_code": "if __name__ == '__main__':\n\tvn = [int(_) for _ in list(raw_input())]\n\tn = len(vn)\n\ts = 81 * (1 << (n - 1)) - 72 * n - 9\n\tfor i in range(n):\n\t\tfor r in range(vn[i]) if i > 0 else range(1, vn[0]):\n\t\t\tk = len(set(vn[:i] + [r]))\n\t\t\tif k == 1:\n\t\t\t\ts += 9 * (1 << (n - 1 - i)) - 8\n\t\t\telif k == 2:\n\t\t\t\ts += 1 << (n - 1 - i)\n\tif len(set(vn)) <= 2:\n\t\ts += 1\n\tprint s"}, {"source_code": "n = input()\nimport itertools\nl = len(str(n))\nC = list(itertools.combinations(['0','1','2','3','4','5','6','7','8','9'], 2))\nLEVEL_VS_NUMBERS = {}\ndef choose_this_or_zero(x):\n x = int(\"\".join(x))\n return x if x <= n else 0\nres = set()\nfor i in range(1,l+1):\n for e in C:\n res.update(set(map(choose_this_or_zero, itertools.product(e, repeat=i))))\nprint len(res) - 1\n"}, {"source_code": "n = input()\nimport itertools\nl = len(str(n))\nC = list(itertools.combinations(['0','1','2','3','4','5','6','7','8','9'], 2))\nLEVEL_VS_NUMBERS = {}\nfor i in range(1,l+1):\n LEVEL_VS_NUMBERS[i] = set()\n for e in C:\n LEVEL_VS_NUMBERS[i].update(set(map(lambda t: int(\"\".join(t)), itertools.product(e, repeat=i))))\nLEVEL_VS_NUMBERS[l] = set([num for num in LEVEL_VS_NUMBERS[l] if num <= n])\nres = set()\nmap(lambda x: res.update(x), LEVEL_VS_NUMBERS.values())\nprint len(res) - 1\n"}, {"source_code": "crap = raw_input().split()\nt,h,n = (int(crap[0]), str(crap[0]), len(str(crap[0])))\nstrings = []\n\ndef dfs(a, n, i, j):\n\tglobal strings\n\tif len(a) == n:\n\t\tif a[0] == \"0\":\n\t\t\treturn\n\t\tstrings.append(a)\n\t\treturn\n\tdfs(a+str(i),n,i,j)\n\tdfs(a+str(j),n,i,j)\n\t\ndef query(i, j, n):\n\tglobal strings\n\ta = \"\"\n\tdfs(a, n, i, j)\n\nfor l in xrange(1, n+1):\n\tfor i in xrange(10):\n\t\tfor j in xrange(i):\n\t\t\tquery(i,j,l)\n\nsetstrings = set(strings)\ncounter = 0\nfor value in setstrings:\n\tif int(value) <= t:\n\t\tcounter += 1\n\nprint counter\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "def dfs(n,v,x,y,s):\n if v<=n:\n s.add(v)\n if v*10+x!=v: dfs(n,v*10+x,x,y,s)\n if v*10+y!=v: dfs(n,v*10+y,x,y,s)\nn=input()\ns=set()\nfor x in range(10):\n for y in range(x):\n dfs(n,0,x,y,s)\nprint len(s)-1"}, {"source_code": "counter = dict()\ndef calculate(x, y, actual, limit):\n #print x, y, actual, limit, 10 * actual + x, 10 * actual + y\n if actual > limit:\n return 0\n counter[actual] = 1\n if x == y:\n return calculate(x, y, 10 * actual + x, limit)\n if actual == 0 and (x == 0 or y == 0):\n if x == 0:\n calculate(x, y, 10 * actual + y, limit)\n else:\n calculate(x, y, 10 * actual + x, limit)\n else:\n calculate(x, y, 10 * actual + x, limit)\n calculate(x, y, 10 * actual + y, limit)\n return 0\n\nn = int(raw_input())\nfor x in xrange(10):\n for y in xrange(x, 10):\n if x + y != 0:\n calculate(x, y, 0, n)\n\n#print counter\nprint len(counter) - 1\n"}, {"source_code": "import sys\ndef RedirectIO():\n sys.stdin=open(\"test.in\",\"r\")\n# sys.stdout=open(\"output.txt\",\"w\")\n#RedirectIO()\ndef check(x,y):\n a=b=-1\n if x==0:\n a=0\n while x:\n m=x%10\n x/=10\n if a==-1:\n a=m\n elif a!=m and b==-1:\n b=m\n if b==-1:\n return True\n if y==a or y==b:\n return True\n return False;\ndef main(): \n temp=n=input()\n if n<=10:\n print n\n return\n bits=0\n while temp:\n temp/=10\n bits+=1\n num=[x for x in xrange(1,10)]\n newNum=[]\n ans=9\n for i in xrange(2,bits+1):\n for y in xrange(10):\n for x in num:\n if y<x*10+y<=n and check(x,y):\n ans+=1\n newNum.append(x*10+y)\n num=newNum\n newNum=[]\n print ans\nmain()\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)"}, {"source_code": "n = int(raw_input())\nans = {}\n\ndef dfs(k, a, b):\n if k <= n:\n ans[k] = 1\n if k != k * 10 + a:\n dfs(k * 10 + a, a, b)\n if k != k * 10 + b:\n dfs(k * 10 + b, a, b)\n\nfor i in range(10):\n for j in range(i + 1):\n dfs(0, i, j)\n\nprint len(ans) - 1\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "def p(k):\n\tif 0<k<=n:s.add(k);k*=10;p(k+x);p(k+y)\nn=input();s=set()\nfor x in range(10):\n\tfor y in range(10):p(x)\nprint len(s)\n"}, {"source_code": "ans = 0\nval = int(raw_input())\ndef fun(n):\n global val\n global ans\n if(n > 0 and n <= val):\n ans += 1\n if n >= 10**9:\n return\n for a in range(10):\n if(n*10 + a) > 0:\n if len(set((str(n*10 + a)))) <= 2:\n fun(n*10 + a)\nfun(0)\nprint ans"}, {"source_code": "n = input()\n\nif n <= 10:\n\tprint n\nelse:\n\tcnt = 9\n\tle = len(str(n))\n\ti = 2\n\twhile i <= le-1:\n\t\tcnt += ((81*((1<<(i-1))-1) + 9))\n\t\ti += 1\n\t\n\td = {}\n\t\n\tfor i in xrange(1,10):\n\t\td[(int(str(i)*le))] = 1\n\t\n\tfor i in xrange(1,10):\n\t\tfor j in xrange(10):\n\t\t\tif i != j:\n\t\t\t\tmask = 0\n\t\t\t\twhile mask < (1<<le-1):\n\t\t\t\t\ttmp = \"\"\n\t\t\t\t\tfor k in xrange(le-1):\n\t\t\t\t\t\tif (mask&(1<<k)) > 0:\n\t\t\t\t\t\t\ttmp = str(i) + tmp\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\ttmp = str(j) + tmp\n\t\t\t\t\ttmp = str(i) + tmp\n\t\t\t\t\td[(int(tmp))] = 1\n\t\t\t\t\tmask += 1\n\t\n\tfor key in d:\n\t\tif key <= n:\n\t\t\tcnt += 1\n\tprint cnt\n"}, {"source_code": "def dfs(num):\t\n\tif 0< num <=n: \n\t\ts.add(num)\n\t\tnum *= 10\n\t\tdfs(num+x)\n\t\tdfs(num+y)\nn=input()\ns=set()\nfor x in xrange(10):\n\tfor y in xrange(10):\n\t\tdfs(x)\nprint len(s)\n"}, {"source_code": "n=input()\n\nr=0\ndef dfs(a):\n r=0\n if a > 0 and a <= n: r+=1\n if a > n or a > 10**8: return r\n for d in range(10):\n if len(set(str(a*10+d))) < 3 and a*10+d:\n r+=dfs(a*10+d)\n return r\n\nr+=dfs(0)\nprint r"}, {"source_code": "n=input()\n\nr=0\ndef dfs(a):\n #print a\n r=0\n if a > 0 and a <= n: r+=1\n if a > n or a > 10**8: return r\n for d in range(10):\n #print d,len(set(str(a*10+d))),a*10+d\n if len(set(str(a*10+d))) < 3 and a*10+d:\n r+=dfs(a*10+d)\n return r\n\nr+=dfs(0)\nprint r"}, {"source_code": "''' \n \t\n \t\t\t ||Sri:|| \n\n __|\n ______________|_________________________\n | | ___| | | ___| | | |___\n /\\ /\\ | |___ | | |___| | | |___|\n/ \\/ \\ | ___| | | |_/ |___| |___\n\nI am a beginner. Feel free to send tutorials/help to srinivasan1995@gmail.com.\n\nCodeforces, SPOJ handle: desikachariar.\nHackerrank, Codechef handle: Prof_Calculus.\n\nAdvices/Help are welcome. You will definitely get a thanks in return. Comments to be avoided.\n\nCollege: International Institute of Information Technology, Bangalore.\n\n'''\n\nimport math\ncount = 0\nn = 0\ndef distinct_digits(a):\n\td= {}\n\tfor i in a:\n\t\td[i] = 1\n\treturn len(d)\n\ndef fn(num):\n\tglobal count, n\n\tif (num > 0 and num <= n):\n\t\tcount+=1\t\n\tif (num > 10**8):\n\t\treturn\n \tfor a in range(0, 10):\n \t\tif num*10+a > 0 and distinct_digits(str( num*10+a )) <= 2:\n\t\t\t fn( num*10+a )\n\nif __name__ == '__main__':\n\tn=input()\n\tfn(0)\n\tprint count\n"}, {"source_code": "n = input()\nr = set()\n\ndef f(v):\n\tif v <= n:\n\t\tr.add(v)\n\t\tv *= 10\n\t\tif v or x:\n\t\t\tf(v + x)\n\t\tif v or y:\n\t\t\tf(v + y)\n\tv *= 10\n\nfor x in range(10):\n\tfor y in range(10):\n\t\tf(0)\nprint len(r) - 1"}, {"source_code": "n = input()\nprint sum(0 < v <= n for v in set([int(s.replace('a', `x`).replace('b', `y`)) for x in range(10) for y in range(10) for s in [('0' * l + bin(m)[2 : ])[-l - 1 : ].replace('0', 'a').replace('1', 'b') for l in range(9) for m in range(2 << l)]] + [10 ** 9]))"}, {"source_code": "def f(v):\n\tif 0 < v <= n:\n\t\tv *= 10\n\t\tr.add(v)\n\t\tf(v + x)\n\t\tf(v + y)\n\nn = input()\nr = set()\nfor x in range(10):\n\tfor y in range(10):\n\t\tf(x)\nprint len(r)"}, {"source_code": "n = input()\nr = set()\n\ndef f(v):\n\tif 0 < v <= n:\n\t\tv *= 10\n\t\tr.add(v)\n\t\tf(v + x)\n\t\tf(v + y)\n\nfor x in range(10):\n\tfor y in range(10):\n\t\tf(x)\nprint len(r)"}, {"source_code": "####################################################\n# -*- coding: utf-8 -*-\nimport sys\n\nw = sys.stdout.write\nread = sys.stdin.readline\nreads = sys.stdin.read\n\ndef r(f=None):\n if f:\n return map(f, read().split())\n else:\n return read().split()\n\ndef rs(t,f=None):\n result = []\n result_append = result.append\n for i in xrange(t):\n if f:\n result_append(tuple(map(f, read().split())))\n else:\n result_append(list(read().split()))\n return result\n\n\n####################################################\nimport math\nsqrt = math.sqrt\nfrom collections import deque\n\n\n[n] = r(int)\ns = set([])\ndef dfs(num, a, b):\n if num <= n:\n s.add(num)\n if num*10+a != num: dfs(10*num+a, a, b)\n if num*10+b != num: dfs(10*num+b, a, b)\n\nfor x, y in [(x, y) for x in range(10) for y in range(10)]:\n dfs(0, x, y)\n\nw(str(len(s)-1))"}, {"source_code": "#!/usr/bin/python\n\nimport os\nimport sys\nimport itertools\nimport collections\n\ndef solve(f):\n n = f.read_int()\n nlen = len(str(n))\n\n ans = set()\n\n for x, y in itertools.combinations(range(10), 2):\n for ni in xrange(1,nlen+1):\n for item in itertools.product([x, y], repeat=ni):\n if item[-1] == 0: continue\n cand = sum([j*10**i for i, j in enumerate(item)])\n if cand <= n: ans.add(cand)\n\n print len(ans)\n\nclass Reader(object):\n def __init__(self, filename=None):\n self.test_mode = filename is not None\n self.cases = 1\n self.buffer = []\n if self.test_mode:\n with open(filename) as f:\n blank_flg = False\n for line in f:\n line = line.strip()\n if line:\n self.buffer.append(line)\n blank_flg = False\n else:\n if not blank_flg: self.cases += 1\n blank_flg = True\n\n def __readline(self):\n return self.buffer.pop(0) if self.test_mode else raw_input()\n\n def read_int(self):\n return int(self.__readline())\n def read_float(self):\n return float(self.__readline())\n def read_long(self):\n return long(self.__readline())\n def read_str(self):\n return self.__readline()\n\n def read_int_list(self):\n return [int(item) for item in self.__readline().split()]\n def read_float_list(self):\n return [float(item) for item in self.__readline().split()]\n def read_long_list(self):\n return [long(item) for item in self.__readline().split()]\n def read_str_list(self):\n return self.__readline().split()\n\nif __name__ == '__main__':\n filename = sys.argv[1] if len(sys.argv)>1 else None\n f = Reader(filename)\n if f.test_mode:\n for c in xrange(f.cases):\n print \"Case #%d\"%(c+1)\n solve(f)\n else:\n solve(f)\n"}, {"source_code": "entrada = int(raw_input())\nr = 0\n\ndef generador(n):\n global r\n global entrada\n for i in xrange(0,10):\n if n*10+i >0 and n*10+i <= entrada and valido(n*10+i):\n r+=1\n generador(n*10+i)\n\ndef valido(n):\n return len(set(str(n)))<=2\n\ngenerador(0)\nprint r"}, {"source_code": "def p(k):\n if 0 < k <= n:\n s.add(k)\n k *= 10\n p(k + x)\n p(k + y)\n\n\nn = int(input())\ns = set()\nfor x in range(10):\n for y in range(10):\n p(x)\nprint(len(s))\n"}], "negative_code": [{"source_code": "def cnt(s, p):\n ans = 0\n if p > s: ans = 0\n elif len(p) == len(s):\n ans = 1 if len(set(p.lstrip('0'))) <= 2 else 0\n elif len(set(p.lstrip('0'))) > 2: ans = 0\n elif s[:len(p)] > p:\n if len(set(p.lstrip('0'))) == 2:\n ans = 2**(len(s)-len(p))\n elif len(set(p.lstrip('0'))) == 1:\n ans = 1 + 9 * (2**(len(s)-len(p)) - 1)\n else:\n ans = 10 + 45 * (2**(len(s)-len(p)) - 2)\n else: ans = sum(cnt(s, p+c) for c in '0123456789')\n\n return ans\n\nprint(cnt(input().strip(), '')-1)\n"}, {"source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as c\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom fractions import Fraction\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(var): sys.stdout.write(str(var))\ndef outln(var): sys.stdout.write(str(var)+\"\\n\")\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\ntemp = pow(10, 8)\ndef dfs(number):\n if 0 < number <= n:\n answer[0] += 1\n if number >= temp:\n return\n for i in range(10):\n if number * 10 + i > 0:\n if len(set(str(number * 10 + i))) <= 2:\n dfs(number * 10 + i)\n\n\nn = int(data())\nanswer = [0]\ndfs(0)\noutln(answer[0])\n"}, {"source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as c\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom fractions import Fraction\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(var): sys.stdout.write(str(var))\ndef outln(var): sys.stdout.write(str(var)+\"\\n\")\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\ntemp = pow(10, 8)\n\n\ndef dfs(number):\n if 0 < number <= n:\n answer[0] += 1\n if number >= temp:\n return\n for i in range(10):\n if number * 10 + i > 0:\n if len(set(str(number * 10 + i))) <= 2:\n dfs(number * 10 + i)\n\n\nn = int(data())\nanswer = [0]\ndfs(0)\nif n > temp:\n outln(answer[0] + 1)\n exit()\noutln(answer[0])\n"}, {"source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as c\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom fractions import Fraction\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(var): sys.stdout.write(str(var))\ndef outln(var): sys.stdout.write(str(var)+\"\\n\")\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\ntemp = pow(10, 8)\n\n\ndef dfs(number):\n if 0 < number <= n:\n answer[0] += 1\n if number >= temp:\n return\n for i in range(10):\n if number * 10 + i > 0:\n if len(set(str(number * 10 + i))) <= 2:\n dfs(number * 10 + i)\n\n\nn = int(data())\nanswer = [0]\ndfs(0)\nif n > temp:\n outln(answer[0] + 1)\n"}, {"source_code": "n = input()\na = int(n[0])\nl = len(n)\nd = 1 << (l - 1)\n\ndef f(a, i):\n global n, l\n if i == l: return 0\n b = int(n[i])\n i += 1\n d = 1 << (l - i)\n if a > b: return b * d + g(a, b, i)\n if a == b: return b * d + f(a, i)\n return (b - 1) * d + g(a, b, i) + 9 * (d >> 1)\n \ndef g(a, b, i):\n if i == l: return 0\n c = int(n[i])\n d = 1 << (l - i - 1)\n if a > b: a, b = b, a\n if c < a: return 0\n if c == a: return g(a, b, i + 1)\n if c < b: return d\n if c == b: return d + g(a, b, i + 1)\n return 2 * d\n\nprint(a * (9 * d - 8) + 72 * (d - l) + f(a, 1))"}, {"source_code": "n=int(input())\nslen=len(str(n))\nMOD=10**9+7\nnums=[i for i in range(1,100)] \nfor i in range(3,10):\n for j in range(0,10):\n for k in range(0,10):\n for z in range(0,10):\n curr=str(j)*z+str(k)*(i-z)\n nums.append(int(curr))\nnums=list(set(nums))\nnums=[i for i in nums if len(set(str(i)))<=2]\nnums.sort()\n#print(nums[0:15])\ncnt=0 \nfor i in nums:\n if i<=0:\n continue \n if i<=n:\n cnt+=1 \n # print(i)\n else:\n break \nprint(cnt)"}, {"source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=6*(10**4 ):\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n # print('hi')\n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)"}, {"source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=10**4 :\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n # print('hi')\n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)"}, {"source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=4*(10**4 ):\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n # print('hi')\n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**9\n\nn = int(input())\nif n < 100:\n print(n)\n sys.exit()\na = [[_,set(map(int,list(str(_))))] for _ in range(100)]\nc = 99\nfor k in range(2,11):\n t = (10 ** (k-1))\n for aa in a:\n if aa[0] >= t:\n break\n aa[1] |= set([0])\n for i in range(1,10):\n t = i * (10 ** k)\n for ai, ae in a[:]:\n ac = ai + t\n if ac > n:\n print(c)\n sys.exit()\n if len(ae) < 2:\n ae = ae | set([i])\n if i in ae:\n c += 1\n a.append([ac,ae])\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**9\n\nn = int(input())\nif n < 100:\n print(n)\n sys.exit()\na = [[_,set(map(int,list(str(_))))] for _ in range(100)]\nc = 99\nfor k in range(2,11):\n t = (10 ** (k-1))\n for aa in a:\n if aa[0] >= t:\n break\n aa[1] |= set([0])\n at = a[:]\n for i in range(1,10):\n t = i * (10 ** k)\n for ai, ae in at:\n ac = ai + t\n if ac > n:\n print(c)\n sys.exit()\n if len(ae) < 2:\n ae = ae | set([i])\n if i in ae:\n c += 1\n a.append([ac,ae])\n"}, {"source_code": "#!/home/kameda/pyenv2/bin/python\n\npower2list = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n'''\nIf the head of n (:(len(str(n))=i) is fixed as 'x',\nnumber of candidates trailing digit is\n9*(2^(i-1)-1)+1\n9: len(range(0,10) except x)\n(2^(i-1)-1): number of patterns like (xxy xyx xyy) if i=3\n1: number of patterns like xxx if i=3\n\ntrailing_candidates = []\nfor i in range(1, 11):\n trailing_candidates.append(9*(2**(i-1)-1)+1)\n\n'''\ntrailing_candidates = [1, 10, 28, 64, 136, 280, 568, 1144, 2296, 4600]\n'''\nFor each head (1..9), trailing_candidates can be applied.\nSo, cumulative candidates lower than 10^i is calculated as below.\n\ncumulative_candidates = [9]\nfor i in range(1, 9):\n cumulative_candidates.append(9*trailing_candidates[i]+cumulative_candidates[i-1])\n\n'''\ncumulative_candidates = [9, 99, 351, 927, 2151, 4671, 9783, 20079, 40743]\n\ndef main_y_fixed(n, y):\n #Count candidates which is n or less starting with n[0] (=x) given y (!=x)\n x = n[0]\n len_n = len(n)\n uln = 0\n if len_n == 1:\n return 1\n if int(y) > int(x):\n if int(n[1]) < int(x): # e.g. 42????? given 8 -> No candidates\n pass\n elif int(n[1]) == int(x): # e.g. 44????? given 8\n uln += main_y_fixed(n[1:], y)\n elif int(n[1]) < int(y): # e.g. 47????? given 8 -> 4488888 is the largest\n uln += power2list[len_n-2]\n elif int(n[1]) == int(y): # e.g. 48????? given 8\n uln += power2list[len_n-2]\n uln += main_y_fixed(n[1:], x)\n elif int(n[1]) > int(y): # e.g. 49????? given 8 -> 4888888 is the largest\n uln += power2list[len_n-1]\n elif int(y) == int(x):\n raise ValueError('2nd argument should be different from 1st degit of 1st argument')\n elif int(y) < int(x):\n if int(n[1]) < int(y): # e.g. 82????? given 4 -> No candidates\n pass\n elif int(n[1]) == int(y): # e.g. 84????? given 4\n uln += main_y_fixed(n[1:], x)\n elif int(n[1]) < int(y): # e.g. 87????? given 4 -> 8488888 is the largest\n uln += power2list[len_n-2]\n elif int(n[1]) == int(x): # e.g. 88????? given 4\n uln += power2list[len_n-2]\n uln += main_y_fixed(n[1:], y)\n elif int(n[1]) > int(y): # e.g. 89????? given 4 -> 8888888 is the largest\n uln += power2list[len_n-1]\n return uln\n\ndef main(n):\n #Count candidates which is n or less starting with n[0] (=x)\n x = n[0]\n len_n = len(n)\n uln = 0\n if len_n == 1:\n return 1\n if int(n[1]) > 0:\n for i in range(0, int(n[1])): #int(n[0]), ~int(n[1])-1 and all trailings\n if i != int(n[0]):\n uln += power2list[len_n-2]\n else:\n uln += trailing_candidates[len_n-2]\n if len_n == 2:\n return uln+1\n if int(n[0]) < int(n[1]):\n if int(n[2]) < int(n[0]): #e.g. 482????? -> 47777777 is the largest.\n pass\n elif int(n[2]) == int(n[0]): #e.g. 484?????\n uln += main_y_fixed(n[2:], n[1]) \n elif int(n[2]) < int(n[1]): #e.g. 486????? -> 48488888 is the largest.\n uln += power2list[len_n-3]\n elif int(n[2]) == int(n[1]): #e.g. 488?????\n uln += power2list[len_n-3]\n uln += main_y_fixed(n[2:], n[0]) \n elif int(n[2]) > int(n[1]): #e.g. 489?????\n uln += power2list[len_n-2]\n elif int(n[0]) == int(n[1]):\n uln += main(n[1:])\n elif int(n[0]) > int(n[1]):\n if int(n[2]) < int(n[1]): #e.g. 842????? -> 83333333 is the largest.\n pass\n elif int(n[2]) == int(n[1]): #e.g. 844?????\n uln += main_y_fixed(n[2:], n[0]) \n elif int(n[2]) < int(n[1]): #e.g. 846????? -> 84488888 is the largest.\n uln += power2list[len_n-3]\n elif int(n[2]) == int(n[0]): #e.g. 848?????\n uln += power2list[len_n-3]\n uln += main_y_fixed(n[2:], n[1]) \n elif int(n[2]) > int(n[1]): #e.g. 849?????\n uln += power2list[len_n-2] \n return uln\n\nif __name__ == \"__main__\":\n N = raw_input()\n Len_N = len(N)\n if Len_N <= 2:\n print(N)\n exit(0)\n Uln = cumulative_candidates[Len_N-2] # below 10^len_n\n Uln += (int(N[0])-1)*trailing_candidates[Len_N-1] # between 10^len_n and n[0]*10^len_n\n Uln += main(N)\n print(Uln)\n exit(0)\n \n"}, {"source_code": "ans = 0\nval = int(raw_input())\ndef fun(n):\n global val\n global ans\n if(n > 0 and n <= val):\n ans += 1\n if n >= 10**8:\n return\n for a in range(10):\n if(n*10 + a) > 0:\n if len(set((str(n*10 + a)))) <= 2:\n fun(n*10 + a)\nfun(0)\nprint ans"}, {"source_code": "n = input()\n\nif n <= 10:\n\tprint n\nelse:\n\tcnt = 9\n\tle = len(str(n))\n\ti = 1\n\twhile i < le-1:\n\t\tcnt += (81*(1<<i-1) + 9)\n\t\ti += 1\n\t\n\td = {}\n\t\n\tfor i in xrange(1,10):\n\t\td[(int(str(i)*le))] = 1\n\t\n\tfor i in xrange(1,10):\n\t\tfor j in xrange(10):\n\t\t\tif i != j:\n\t\t\t\tmask = 0\n\t\t\t\twhile mask < (1<<le-1):\n\t\t\t\t\ttmp = \"\"\n\t\t\t\t\tfor k in xrange(le-1):\n\t\t\t\t\t\tif (mask&(1<<k)) > 0:\n\t\t\t\t\t\t\ttmp = str(i) + tmp\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\ttmp = str(j) + tmp\n\t\t\t\t\ttmp = str(i) + tmp\n\t\t\t\t\td[(int(tmp))] = 1\n\t\t\t\t\tmask += 1\n\t\n\tfor key in d:\n\t\tif key <= n:\n\t\t\tcnt += 1\n\tprint cnt\n"}, {"source_code": "n=input()\n\nr=0\ndef dfs(a):\n #print a\n r=0\n if a > 0 and a <= n: r+=1\n if a > n or a > 10**8: return r\n for d in range(10):\n #print d,len(set(str(a*10+d))),a*10+d\n if len(set(str(a*10+d))) < 3 and a*10+d:\n r+=dfs(a*10+d)\n return r\nif n == 10**9:r+=1\nr+=dfs(0)\nprint r"}, {"source_code": "''' \n \t\n \t\t\t ||Sri:|| \n\n __|\n ______________|_________________________\n | | ___| | | ___| | | |___\n /\\ /\\ | |___ | | |___| | | |___|\n/ \\/ \\ | ___| | | |_/ |___| |___\n\nI am a beginner. Feel free to send tutorials/help to srinivasan1995@gmail.com.\n\nCodeforces, SPOJ handle: desikachariar.\nHackerrank, Codechef handle: Prof_Calculus.\n\nAdvices/Help are welcome. You will definitely get a thanks in return. Comments to be avoided.\n\nCollege: International Institute of Information Technology, Bangalore.\n\n'''\n\nimport math\ncount = 0\nn = 0\ndef distinct_digits(a):\n\td= {}\n\tfor i in a:\n\t\td[i] = 1\n\treturn len(d)\n\ndef fn(num):\n\tglobal count, n\n\tif (num > 0 and num <= n):\n\t\tcount+=1\t\n\tif (num >= 10**8):\n\t\treturn\n \tfor a in range(0, 10):\n \t\tif num*10+a > 0 and distinct_digits(str( num*10+a )) <= 2:\n\t\t\t fn( num*10+a )\n\nif __name__ == '__main__':\n\tn=input()\n\tfn(0)\n\tprint count\n"}, {"source_code": "####################################################\n# -*- coding: utf-8 -*-\nimport sys\n\nw = sys.stdout.write\nread = sys.stdin.readline\nreads = sys.stdin.read\n\ndef r(f=None):\n if f:\n return map(f, read().split())\n else:\n return read().split()\n\ndef rs(t,f=None):\n result = []\n result_append = result.append\n for i in xrange(t):\n if f:\n result_append(tuple(map(f, read().split())))\n else:\n result_append(list(read().split()))\n return result\n\n\n####################################################\nimport math\nsqrt = math.sqrt\nfrom collections import deque\n\n\n[n] = r(int)\n\nres = 0\nfor x, y in [(x, y) for x in range(10) for y in range(10) if x < y]:\n x = str(x)\n y = str(y)\n for b in xrange(2**9+1):\n bb = int(str(bin(b)).replace('0b', '').replace('1', x).replace('0', y))\n if bb <= n:\n res += 1\nfor x in range(10):\n for i in range(1, 10):\n if int(\"\".join([str(x)] * i)) <= n:\n res += 1\n\nw(str(res))\n"}, {"source_code": "import sys\n\nn = int(raw_input()) + 1\nans = 0\ntmp = []\ndef dfs(num, x, y, inx, iny):\n global ans\n if num < n and inx and iny :\n ans += 1\n tmp.append(num)\n if num > n:\n return \n if x or num :\n if num*10 + x < n:\n dfs(num*10 + x, x, y, 1, iny)\n if y or num :\n if num*10 + y < n:\n dfs(num*10 + y, x, y,inx, 1)\n \nfor x in range(0,10):\n for y in range(x + 1, 10):\n if x:\n dfs(y, x, y, 0, 1)\n dfs(x, x, y, 1, 0)\nprint ans\nprint len(tmp), sorted(tmp)\n\n\n\n"}, {"source_code": "import sys\n\nn = int(raw_input())\nans = 0\ndef dfs(num, x, y, inx, iny):\n global ans\n if num < n and inx and iny :\n ans += 1\n if num > n:\n return \n if x or num :\n if num*10 + x < n:\n dfs(num*10 + x, x, y, 1, iny)\n if y or num :\n if num*10 + y < n:\n dfs(num*10 + y, x, y,inx, 1)\n \nfor x in range(0,10):\n for y in range(x + 1, 10):\n if x:\n dfs(y, x, y, 0, 1)\n dfs(x, x, y, 1, 0)\nprint ans\n\n\n\n"}, {"source_code": "import sys\n\nn = int(raw_input())\nans = 0\ndef dfs(num, x, y, inx, iny):\n global ans\n if num < n and inx and iny :\n ans += 1\n if num > n:\n return \n if x or num :\n if num*10 + x < n:\n dfs(num*10 + x, x, y, 1, iny)\n if y or num :\n if num*10 + y < n:\n dfs(num*10 + y, x, y,inx, 1)\n \nfor x in range(0,10):\n for y in range(x + 1, 10):\n dfs(y, x, y, 0, 1)\n if x:\n dfs(x, x, y, 1, 0)\nprint ans\n\n\n\n"}, {"source_code": "n=input()\nst=set()\ndef dfs(x,l):\n if l>=10 or x>n:return\n if x: st.add(x)\n dfs(10*x+a,l+1)\n dfs(10*x+b,l+1)\n \nfor a in xrange(10):\n for b in xrange(a+1,10):\n dfs(0,0)\nprint len(st)"}, {"source_code": "# 23145\n\nn = input()\nt = 1\ni = 0\n\nwhile n>=t:\n t*=10\n i+=1\n\ni-=1 # 4\nans = (2**i-1)*81 - 72*i\n\n# < 10000\n\na = []\n\nwhile n > 0:\n a.append(n%10)\n n/=10\n\nb = -1\nans += (a[-1]-1)*((2**i-1)*9 + 1)\n\nfor j in range(i)[::-1]:\n for c in range(a[j]):\n if b < 0:\n if c == a[-1]:\n ans += ((2**j-1)*9+1)\n else:\n ans += 2**j\n elif c == b or c == a[-1]:\n ans += 2**j\n if b > 0 and a[j] != a[-1] and c != b:\n break\n elif b < 0 and a[j] != a[-1]:\n b = a[j]\n\nprint ans + (1 if len(set(a)) <= 2 else 0)\n"}, {"source_code": "n=input()\nans=set()\n\ndef dfs(p,l):\n if p>n or l>=10:\n return\n if p>0:\n ans.add(p)\n dfs(p*10+a,l+1)\n dfs(p*10+b,l+1)\n\nfor a in range(0,10):\n for b in range(0,a):\n dfs(0,0)\nprint \"%d\" % len(ans)\n"}, {"source_code": "n=int(raw_input())\nif n<102:\n print n\nelse:\n arr=set([])\n for i in range(1,100):\n arr.add(i)\n for i in range(10,101):\n x=str(i/10)\n y=str(i%10)\n a=str(i)\n done =False\n\n while not done:\n \n\n if x==y:\n for k in range(0,10):\n if int(x)!=k:\n newx=a+str(k)\n if int(newx)<=n:\n arr.add(int(newx))\n\n\n new2=a+x\n \n if int(new2)<=n:\n arr.add(int(new2))\n new3=a+y\n if int(new3)<=n:\n arr.add(int(new3))\n new1=a+str(i)\n if int(new1)<=n:\n arr.add(int(new1))\n else:\n done=True\n a=a+str(i)\n #arr=list(arr)\n #arr.sort()\n #print arr\n print len(arr)\n"}, {"source_code": "\nn=int(raw_input())\nif n<102:\n print n\nelse:\n arr=set([])\n for i in range(1,100):\n arr.add(i)\n for i in range(10,100):\n x=str(i/10)\n y=str(i%10)\n a=str(i)\n done =False\n\n while not done:\n if x==y:\n for k in range(0,10):\n if int(x)!=k:\n newx=a+str(k)\n if int(newx)<=n:\n arr.add(int(newx))\n\n\n new2=a+x\n \n if int(new2)<=n:\n arr.add(int(new2))\n new3=a+y\n if int(new3)<=n:\n arr.add(int(new3))\n new1=a+str(i)\n if int(new1)<=n:\n arr.add(int(new1))\n else:\n done=True\n a=a+str(i)\n #arr=list(arr)\n #arr.sort()\n #print arr\n print len(arr)\n"}, {"source_code": "n=int(raw_input())\narr=set([])\nfor i in range(1,100):\n arr.add(i)\nfor i in range(10,100):\n x=str(i/10)\n y=str(i%10)\n a=str(i)\n done =False\n while not done:\n if x==y:\n for k in range(0,10):\n newx=a+str(k)\n if int(newx)<=n:\n arr.add(int(newx))\n\n new2=a+x\n \n if int(new2)<=n:\n arr.add(int(new2))\n new3=a+y\n if int(new3)<=n:\n arr.add(int(new3))\n new1=a+a\n if int(new1)<=n:\n arr.add(int(new1))\n else:\n done=True\n a=a+a\n#arr=list(arr)\n#arr.sort()\n#print arr\nif n<99:\n print n\nelse:\n print len(arr)"}, {"source_code": "n=int(input())\narray=set()\narray.add(10**9)\nfor x in range(10):\n for y in range(10):\n for l in range(1, 9):\n for m in range(1, 2 ** l + 1):\n s = [str(x) if m & (1 << i) else str(y) for i in range(l)]\n u = int(''.join(s))\n if u <= n:\n array.add(u)\narray.remove(0)\n# print (sorted(list(array)))\narray=[u for u in array if u <= n]\nprint(len(array))"}, {"source_code": "n=int(input())\narray=set()\narray.add(10**9)\nfor x in range(10):\n for y in range(10):\n for l in range(1, 9):\n for m in range(1, 2 ** l + 1):\n s = [str(x) if m & (1 << i) else str(y) for i in range(l)]\n u = int(''.join(s))\n if u <= n:\n array.add(u)\n# print (sorted(list(array)))\nprint(len(array))"}, {"source_code": "from collections import deque\ndef check(n):\n s=set([int(i) for i in str(n)])\n if len(s)<=2:\n return 1\n else:\n return 0\nn=int(input())\ns=set()\nq=deque()\nq.append(0)\nwhile(len(q)>0):\n g=q.popleft()\n if g>=n:\n break\n s.add(g)\n if g>=n:\n break\n for j in range(0,10):\n if g*10+j not in s and check(g*10+j):\n q.append(g*10+j)\n\nprint(len(s)-1)"}], "src_uid": "0f7f10557602c8c2f2eb80762709ffc4"} {"source_code": "def doit():\n n, m = map(int, raw_input().split())\n if n ==1:\n print 1\n return\n\n if m > n:\n m = n\n\n\n\n left = n - m \n\n l = m\n r = n\n\n while l <= r :\n mid = (l+r)/2\n if left > mid*(mid+1)/2 - m*(m+1)/2 - (mid-m) * m:\n l = mid + 1\n else:\n r = mid -1\n\n print l\n\ndoit()\n", "positive_code": [{"source_code": "n, m = [int(i) for i in input().split()]\n\nif m >= n:\n print(n)\nelse:\n l = 1\n r = n\n\n while (l != r):\n cur = (l + r) // 2\n if (1 + cur) * cur // 2 >= (n - m):\n r = cur\n else:\n l = cur + 1\n\n print(m + l)\n"}, {"source_code": "from math import *\nfrom collections import *\nfrom random import *\nfrom decimal import Decimal\nfrom bisect import *\nimport sys\ninput=sys.stdin.readline\ndef lis():\n return list(map(int,input().split()))\ndef ma():\n return map(int,input().split())\ndef inp():\n return int(input())\ndef fk(a,s,k):\n b=[]\n for i in range(len(a)):\n b.append(a[i]+(i+1)*k)\n b.sort()\n return sum(b[:k])\nn,m=ma()\nif(m>=n):\n print(n)\n exit(0)\nre=m\nc=(-1+(Decimal(1+8*(n-m)))**(Decimal(0.5)))/2\nc=ceil(c)\nprint(c+re)\n \n \n\n \n \n \n"}, {"source_code": "def discards(m,k):\n\talls = (m*(m+1))//2\n\tif(k>m):\n\t\treturn alls\n\tk=m-k\n\tk=(k*(k+1))//2\n\treturn alls-k\n\ndef solve(n, m, k):\n\tcantake = (k*(k+1))//2\n\tgrain = n+m*k\n\tgrain = grain-discards(m,k)\n\treturn grain<=cantake\n\ndef fast(n,m):\n\tl=1\n\tr=n\n\tres=n+1\n\twhile(l<=r):\n\t\tif(l==r):\n\t\t\tif(solve(n,m,l)):\n\t\t\t\tres=min(res,l)\n\t\t\tbreak\n\t\t\n\t\tmm=(l+r)//2;\n\t\tif(solve(n,m,mm)):\n\t\t\tr=mm-1\n\t\t\tres=min(res,mm)\n\t\telse:\n\t\t\tl=mm+1\n\n\treturn res\n\t\nn,m = map(int,input().split())\nprint(fast(n,m))"}, {"source_code": "import sys\n\ncases = False\n\ndef c2(n):\n return n * (n+1) // 2\n\ndef get():\n return list(map(int, input().split()))\n\ndef bits(n: int):\n return list(bin(n)).count('1')\n\ndef main(test_case = False):\n n = int(input()) if test_case else 1\n for _ in range(n):\n test()\n\ndef flush():\n sys.stdout.flush()\n\ndef parr(arr):\n print(*arr, sep=' ')\n\ndef gcd(a, b):\n while b:\n if b % a == 0:\n break\n tmp = a\n a = b % a\n b = tmp\n return a\n\ndef check(n, m, k):\n t = k - m - 1\n if t < 0: return False\n return n <= k + t * (t+1) // 2\n\ndef test():\n n, m = get()\n left = 1\n right = n\n ans = right\n\n while left <= right:\n mid = (left + right) // 2\n if check(n, m, mid):\n ans = min(ans, mid)\n right = mid - 1\n else:\n left = mid + 1\n \n print(ans)\n\nmain(cases)"}, {"source_code": "import math\n\nn,m = map(int,raw_input().split())\n\nif m >= n:\n print n\n exit()\n\ns = n - m\n\n\nx = (-1.0 + math.sqrt(1 + 8 * s))/2\nx = int(x)\nif x * (x+1) / 2 < s: x = x + 1\n\nprint x + m"}, {"source_code": "n, m = map(int, raw_input().split())\nif m > n:\n print n\n exit(0)\nlo, hi = 0, 2*10**9\nwhile lo < hi:\n mid = (lo + hi + 1) // 2\n rem = (mid * (mid - 1)) // 2\n if n <= m + rem:\n hi = mid - 1\n else:\n lo = mid\nprint lo + m\n"}, {"source_code": "def func(l):\n return l*m+n - (m+1+l)*(m+2+l)//2 + (m+1)*m//2\nfrom math import ceil\nn, m = [int(x) for x in input().split()]\nif m >= n:\n print(n)\nelse:\n l = ceil((-3 + (9-8*(m+1-n))**0.5)/2)\n for i in range(l-1, l+10):\n if func(i) <= 0:\n print(m+1+i)\n break "}, {"source_code": "from sys import stdin, stdout\n\n\nn, m = map(int, stdin.readline().rstrip().split())\n\ndef triangle(x):\n return x*(x+1)//2\n\nif n<=m:\n print(n)\nelse:\n target=n-m # Want to find the triangle number which is greater than the target\n minNum=0\n maxNum=int(1e10)\n finished=False\n while not finished:\n newNum = (minNum+maxNum)//2\n if triangle(newNum)<target and triangle(newNum+1)>=target:\n finished=True\n elif triangle(newNum)<target:\n minNum=newNum\n elif triangle(newNum)>=target and triangle(newNum-1)<target:\n finished=True\n newNum-=1\n else:\n maxNum=newNum\n print(m+newNum+1)\n"}, {"source_code": "n, m = map(int, input().split())\nif (n <= m) :\n\tprint(n)\nelse:\n\tl = m\n\tr = n\n\twhile (r - l > 1):\n\t\tmid = (l + r) // 2\n\t\n\t\tif (0 >= n - (mid - m - 1) * (mid - m) // 2 - mid):\n\t\t\tr = mid\n\t\telse:\n\t\t\tl = mid\n\t\n\tprint(r)"}, {"source_code": "import decimal\n\nn,m=map(int,input().split())\n\nif(n<=m):\n print(n)\nelse:\n decimal.getcontext().rounding=decimal.ROUND_CEILING;\n decimal.getcontext().prec=100;\n print(((decimal.Decimal(1+8*(n-m)).sqrt()-1)/2+m).to_integral_exact())"}, {"source_code": "import decimal\n\nn,m=map(int,input().split())\n\nif(n<=m):\n print(n)\nelse:\n decimal.getcontext().rounding=decimal.ROUND_CEILING;\n decimal.getcontext().prec=10000;\n print(((decimal.Decimal(1+8*(n-m)).sqrt()-1)/2+m).to_integral_exact())"}, {"source_code": "n, m = map(int, input().split())\nif m >= n:\n print(n)\nelse:\n n -= m\n l, r = 0, n\n while l < r:\n mid = (l + r) // 2\n if (1 + mid) * mid // 2 >= n:\n r = mid\n else:\n l = mid + 1\n print(l + m)"}, {"source_code": "def check(mid, n, m):\n k = min(n, m + 1)\n return n + (mid - k) * m - (2 * k + mid - k) * (mid - k + 1) // 2 <= 0\n\nn, m = map(int, input().split())\nl = min(n, m)\nr = n\nwhile r - l > 1:\n mid = (l + r) // 2\n if check(mid, n, m):\n r = mid\n else:\n l = mid\n\nfor i in range(l, r + 1):\n if check(i, n, m):\n print(i)\n break\n\n\n\n\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\n\nif n <= m:\n print(n)\nelse:\n left = int(0)\n right = int(1e10)\n\n while left < right:\n x = (left + right) // 2\n\n res = n + m*x - ((x + m + 1)*(x + m + 2) - m*(m + 1))//2\n\n if res <= 0:\n right = x;\n else:\n left = x + 1;\n\n print(left + m + 1)\n"}, {"source_code": "capcity,fill=map(int,input().split())\nif fill > capcity:\n\tprint(capcity)\n\texit()\nlast=0\nnum=capcity-fill\nl,r = 1,num\nwhile(l<=r):\n\tmid = l + (r-l)//2\n\tx=(mid*(mid+1))//2\n\tif(x>=num):\n\t\tlast = mid\n\t\tr = mid - 1\n\telse:\n\t\tl = mid + 1\nprint(last+fill)"}, {"source_code": "n, m = map(int, input().split())\nl = 0\nr = 10 ** 18 + 1\nd = n - m\nwhile r - l > 1:\n mi = (r + l) // 2\n if d > mi *(mi + 1) // 2:\n l = mi\n else:\n r = mi\nif n > m:\n print(r + m)\nelse:\n print(n)"}, {"source_code": "def f(n, m, da):\n\tif (da <= m):\n\t\treturn n - da\n\telse:\n\t\tda -= m\n\t\tend_m = n - m\n\t\treturn end_m - ((da * (da + 1)) // 2)\n\ndef main():\n\tn, m = map(int, input().split())\n\tif (f(n, m, 1) > 0):\n\t\tl = 1;\n\t\tr = 10**18\n\t\twhile (l + 1 < r):\n\t\t\tme = (l + r ) // 2\n\t\t\tif (f(n,m,me) > 0):\n\t\t\t\tl = me\n\t\t\telse:\n\t\t\t\tr = me\n\t\tprint(r)\n\telse:\n\t\tprint(1)\n\nmain()"}, {"source_code": "from math import *\n\nn,m = [int(j) for j in input().split()]\n\nif n <= m:\n print(n)\nelse:\n k= ceil((-1 + sqrt(1 + 8*(n-m)))/2)\n while (k*(k+1) >= 2 * (n - m)):\n k -= 1\n k += 1\n print(m + k)"}, {"source_code": "def check(mid): \n global n, m\n cnt = n - ((mid - m) * (mid - m - 1) // 2)\n if mid >= cnt: \n return True\n else:\n return False\n \ndef binn(): \n global n, m\n l = min(n, m)\n r = n + 1\n while (l + 1 < r):\n mid = (l + r) // 2 \n if (check(mid)):\n r = mid \n else: \n l = mid\n \n print(min(n, r))\n \nn, m = map(int, input().split())\nbinn()"}, {"source_code": "def solution():\n n, m = map(int, input().split())\n ans = n\n lo, hi = m + 1, 10 ** 30\n while lo != hi:\n mid = ( lo + hi ) // 2\n if 2 * m + ( mid - m ) * ( mid - m + 1 ) < 2 * n:\n lo = mid + 1\n else:\n hi = mid\n ans = min(ans, lo)\n print(ans)\n\nif __name__ == '__main__':\n solution()\n"}, {"source_code": "n, m = map(int, input().split())\nif n == 1:\n print(1)\nelif m >= n - 1:\n print(n)\nelse:\n r = 1000000000000000000\n frm = m + 1\n l = frm\n while r - l > 1:\n mid = (l + r) // 2\n sum = (mid - frm + 1) * (mid - frm) // 2\n if n - sum - mid <= 0: \n r = mid\n else: \n l = mid\n sum = (l - frm) * (l - frm + 1) // 2\n if n - sum - l <= 0:\n print(l)\n else:\n print(r)"}, {"source_code": "from math import ceil\nfrom decimal import Decimal\nn,m = map(int, input().split())\nbarn = n\nif n <= m:\n\tprint(n)\nelse:\n\tdays = ceil((-1 + Decimal(1+8*(n-m)) ** Decimal(0.5))/2)\n\tprint(days + m)"}, {"source_code": "# your code goes here\nn, m = map(int, input().split())\nif n == 1:\n print(1)\nelif m >= n - 1:\n print(n)\nelse:\n if m == 1:\n l = 1\n r = n\n while r - l > 1:\n mid = (l + r) // 2\n sum = mid * (mid + 1) // 2\n if n - sum + mid - 1 <= 0: \n r = mid\n else: \n l = mid\n sum = l * (l + 1) // 2\n if n - sum + l - 1 <= 0:\n print(l)\n else:\n print(r)\n else:\n r = 1000000000000000000\n frm = m + 1\n l = frm\n while r - l > 1:\n mid = (l + r) // 2\n sum = (mid - frm + 1) * (mid - frm) // 2\n if n - sum - mid <= 0: \n r = mid\n else: \n l = mid\n sum = (l - frm) * (l - frm + 1) // 2\n if n - sum - l <= 0:\n print(l)\n else:\n print(r)"}, {"source_code": "n, m = map(int, input().split())\nl, r = 0, n\nmid = 0\nfor i in range(10 ** 5):\n mid = (l + r) // 2\n if n - mid * (mid + 1) // 2 - m <= 0:\n r = mid\n else:\n l = mid + 1\nif n - l * (l + 1) // 2 - m <= 0:\n print(min(m, n) + l)\nelif n - mid * (mid + 1) // 2 - m <= 0:\n print(mid + min(n, m))\nelse:\n print(r + min(n, m))\n"}, {"source_code": "def binp(l, r, n ,d) :\n m = (l + r) // 2\n while abs(l - r) > 1 :\n m = (l+r)//2\n if m * m + m - 2 * (n - d) == 0:\n return m;\n if m*m + m - 2 * (n - d) > 0 :\n r = m;\n else :\n l = m;\n if l*l + l - 2*(n - d) < 0 :\n return r\n else :\n return l\n\n\na = input().split()\n\nfor i in range(len(a)):\n a[i] = int(a[i])\n\nif(a[0] != 1):\n if a[0] > a[1]:\n ans = binp(1, a[0], a[0], a[1])\n print(ans + a[1])\n else :\n print (a[0])\nelse :\n print(1)\n"}, {"source_code": "n,m=(map(int,input().strip().split(' ')))\nlow=1\nhigh=n\nans=1000000000000000000000000000\nif(n>m):\n\twhile(low<=high):\n\t\tmid=(high+low)//2\n\t\tt=(mid*(mid+1))//2+m\n\t\t\n\t\tif(t==n):\n\t\t\tans=mid\n\n\t\t\tbreak\n\t\n\t\tif(t>n):\n\t\t\tans=min(ans,mid)\n\t\t\thigh=mid-1\n\t\telse:\n\t\t\tlow=mid+1\n\n\n\tprint(m+ans)\nelse:\n\tprint(n)\n"}, {"source_code": "def possi(x, n, m):\n if x<=m:\n return n-x<=0\n x-=m\n return (n-m)<=x*(x+1)/2\nn, m=raw_input().split(\" \")\nn=int(n)\nm=int(m)\nif n<=m:\n print(n)\nelse:\n le = int(1)\n ri = int(n)\n mid = 0\n ans = 0\n while le<=ri:\n mid = (le+ri)/2\n if possi(mid, n, m) :\n ans=mid\n ri=mid-1\n else:\n le=mid+1\n print(ans)\n"}, {"source_code": "\ndef work(days, n, m):\n # m < n\n #print(days, n, m)\n k = days - (m+1)\n loss = (1 + k) * k // 2\n #print(loss)\n return n - loss - days <= 0\n\n\ndef main():\n n, m = [int(x) for x in input().split()]\n if m >= n:\n print(n)\n return\n left = m + 1\n right = n\n while left < right:\n mid = (left + right) // 2\n if work(mid, n, m):\n right = mid\n else:\n left = mid + 1\n print(left)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import math\nn,m=map(int,input().split())\nif(m>=n):\n print(n)\nelse:\n temp=min(n,m)\n a=temp+1\n res=temp\n start=1\n end=2*(10**9)\n while(start<=end):\n mid=(start+end)//2\n if(((mid)*(2*a+mid-1)//2)>n+(mid-1)*m):\n end=mid-1\n elif(((mid)*(2*a+mid-1)//2)<n+(mid-1)*m):\n start=mid+1\n else:\n start=mid\n break\n print(start+res)\n #res+=(1+2*m-2*a+math.sqrt((1+2*m-2*a)**2+8*(n-m)))/2\n #print(math.ceil(res))\n"}, {"source_code": "import math\n\n\ndef f(j):\n return j * (j + 1)\n\n\ndef binsearch(left, right, t):\n j = (left + right) // 2\n if f(j) >= t and f(j - 1) < t:\n return j\n elif f(j) >= t and f(j - 1) >= t:\n return binsearch(left, j - 1, t)\n else:\n return binsearch(j + 1, right, t)\n\n\nn, m = map(int, input().split())\nif m >= n:\n # print(\"The answer is\", n)\n print(n)\nelse:\n k = n - m\n res = m\n t = 2 * k\n # run binary search to find min j s.t. j(j + 1) >= t\n j = 1\n res += binsearch(1, t, t)\n print(res)\n\n\n# print(\"The answer is\", res)\n# print(res)\n"}, {"source_code": "#no language is perfect -_-\n\nimport math\n\nn,m=map(int,raw_input().split())\n\nif(n<=m):\n ans=n\nelse:\n ans=int((-1+math.sqrt(1+8*(n-m)))/2)\n while(n-m-ans*(ans+1)/2>0):\n ans+=1\n while(n-m-ans*(ans+1)/2<=0):\n ans-=1\n ans+=1\n ans+=m\nprint ans"}, {"source_code": "import sys\nn,m=map(long,raw_input().strip().split())\nif m>=n:\n print n\n sys.exit()\nl=0\nr=long(2e9)\nx=r\nwhile l<=r:\n tmp=(l+r)/2\n if tmp*tmp+tmp>=2*(n-m):\n x=tmp\n r=tmp-1\n continue\n l=tmp+1;\nprint m+x\n"}, {"source_code": "# http://codeforces.com/problemset/problem/785/C\nn,m = map(int,raw_input().split())\n\nif n<=m :\n print(n)\nelse :\n\n ans = m\n L =0\n R = 2**31-1\n while L < R :\n mid = (L+R)//2\n if mid*(mid+1)//2 >= n - m :\n R=mid\n else :\n L=mid + 1\n print(ans + L)\n"}, {"source_code": "n, m = (int(x) for x in str(raw_input()).strip().split(' ', 1))\n\nif n <= m:\n print(n)\n exit(0)\nl = m\nr = n\nwhile l <= r:\n d = l + r >> 1;\n if 2 * n + 2 * m * (d - m - 1) + m * (m + 1) - d * (d + 1) <= 0:\n r = d - 1\n else:\n l = d + 1;\nprint(int(l))\n"}, {"source_code": "\ufeffimport math\nn,m=map(int,raw_input().split())\nif m>=n:\n print n\nelse:\n lo,hi=1,1e18\n days=1e18\n while lo<=hi:\n mid=int((lo+hi)/2)\n val=n+(mid-1)*m-(m*mid+(mid*(mid+1))/2)\n if val>0:\n lo=mid+1\n elif val<0:\n days=min(days,mid)\n hi=mid-1\n else:\n days=min(days,mid)\n break\n print days+m"}, {"source_code": "n, m = map(int, raw_input().split(\" \"))\nif n<=m:\n print n\nelse:\n l = m\n r = int(1e19)\n while l<r:\n mid = int((l + r)/2)\n k = mid - m - 1;\n if mid+(k*(k+1))/2 >= n:\n r = mid\n else:\n l = mid+1\n print l\n "}, {"source_code": "from decimal import * \nn,m = map(int,raw_input().strip().split())\nif(n>m):\n\tl = 2*(n-m)\n\tx = Decimal(-1+Decimal(1+4*l).sqrt())/2\n\tans = x.to_integral_exact(rounding=ROUND_CEILING)\n\tprint ans+m\nelse:\n\tprint n\n"}, {"source_code": "def fun(i, n, m):\n return i * i + i - 2 * n + 2 * m\n\nn, m = map(int, input().split())\nif m >= n:\n print(n)\n exit(0)\nleft, right = 1, (10 ** 18)\nwhile left < right:\n mid = (left + right) // 2\n if fun(mid, n, m) < 0:\n left = mid + 1\n else:\n right = mid\nprint(left + m)\n"}, {"source_code": "def main():\n\n n, m = list(map(int, input().split()))\n\n if m >= n:\n print(n)\n return\n\n def ok(x):\n return (x * (x + 1) // 2 + x * m) >= (n + m * max(0, (x - 1)))\n\n ll = 0\n rr = int(10**19)\n\n for i in range(100): \n mm = (ll + rr) // 2\n if not ok(mm):\n ll = mm\n else:\n rr = mm\n\n while rr > 0 and ok(rr - 1):\n rr -= 1\n\n while not ok(rr):\n rr += 1\n\n print(m + rr)\n\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "import math as ma\nn,m=list(map(int,input().split()))\nif n>=m:\n st=0\n end=10**20\n a=2*(n-m)\n e=0\n while st<=end:\n mid=(st+end)//2\n b=mid**2+mid\n if b==a:\n e=1\n break\n elif b>a:\n end=mid-1\n elif a>b:\n st=mid+1\n if e==1:\n print(mid+m)\n else:\n print(st+m)\nelse:\n print(n)"}, {"source_code": "import sys\n\nn, m = map(int, input().split())\n\nif m>=n :\n print(n)\n sys.exit()\n\nans = m\n\nlo = 1\nhi = 10000000000000000000000\n\ntemp = 0\n\nwhile lo<=hi :\n mid = (lo+hi)//2\n\n t1 = mid*(mid+1)//2\n\n if t1 >= (n-m) :\n temp = mid\n hi = mid-1\n else :\n lo = mid+1\n\nprint(temp+ans)"}, {"source_code": "import sys\nimport math\nfrom decimal import Decimal\n\n## (x)(x+1)/2 > n; + m\n\nline = input()\nline = line.split()\nn = line[0]\nm = line[1]\n\nn = Decimal(n)\nm = Decimal(m)\n\nif m >= n:\n print (n)\n sys.exit()\n\ndef f(x):\n return(math.floor((x*(x+1))/2) + x)\n\ndef search(tar,bot,top):\n bot = Decimal(bot)\n top = Decimal(top)\n curr = math.floor((bot+top)/2)\n curr = Decimal(curr)\n if (f(curr) >= tar) and (f(curr-1) < tar):\n return curr + 1\n elif f(curr) < tar:\n return search(tar,curr,top)\n elif f(curr) >= tar:\n return search(tar,bot,curr)\n\n\nans = search(n-m-1,0,2000000000) + m\nprint(ans)"}, {"source_code": "\nN,M = map(long,raw_input().split());\nlow ,high =1, 2*10**18;\nans = high;\nY = min(N-1,M);\n\nwhile(low<=high):\n mid = (low+high)/2;\n X = min( Y,mid );\n status = N+((X-1)*X)/2+(mid-X)*Y - (mid*(mid+1))/2;\n\n if(status<=0):\n ans ,high = mid, mid-1;\n else :\n low = mid+1;\nprint ans\n"}, {"source_code": "import math\n\ndef bin_pow(a, b):\n ans = 1\n while b > 0:\n if b & 1 == 1:\n ans *= a\n a *= a\n b >>= 1\n return ans\n\n\nn, m = map(int, input().split())\nif m >= n:\n print(n)\nelse:\n ans = m\n n -= m\n\n left = 0\n right = int(10e18)\n while left <= right:\n # print(left, right)\n # print('--')\n mid = (left + right + 1) // 2\n if mid * (mid + 1) > 2 * n:\n right = mid - 1\n elif mid * (mid + 1) < 2 * n:\n left = mid + 1\n else:\n print(ans + mid)\n exit(0)\n while mid * (mid + 1) >= 2 * n:\n mid -= 1\n while mid * (mid + 1) < 2 * n:\n mid += 1\n print(ans + mid)\n"}, {"source_code": "import math\n\n\nn,m = map(int,raw_input().strip().split())\nif n<=m:\n print n\n\nelse:\n x = int((-1+math.sqrt(1+8*(n-m)))/2.0)\n if (x*(x+1))/2 >= n-m:\n print m+x\n else:\n print m+x+1\n"}, {"source_code": "def f(tar,n,m):\n n-=m\n bir=(tar*(tar+1))//2\n if bir>=n:\n return True\n else:\n return False\n\nimport sys\n\nn,m=map(int,input().split())\nif n<=m:\n print(n)\n sys.exit()\n\nlow,high=0,10**18\nwhile(low<high):\n mid=low+(high-low)//2\n x=f(mid,n,m)\n if x:\n high=mid\n else:\n low=mid+1\n\nprint(low+m)"}, {"source_code": "ini,gain = (int(n) for n in input().split(\" \"))\nnon_decreasing = (gain * (gain + 1)) // 2\nallday = 10 ** 18\nleft = 0\n# print(non_decreasing,gain * (gain))\nif ini > gain:\n while allday > left:\n day = (allday + left) // 2\n now_decreased = (day * (day + 1)) // 2 - gain * max(0,day - gain - 1) - non_decreasing\n # print(now_decreased,day,left,allday,non_decreasing)\n if now_decreased > ini:\n allday = day\n elif now_decreased < ini:\n left = day + 1\n else:\n break\n print((allday + left) // 2)\nelse:\n print(ini)\n"}, {"source_code": "inp = map(int, raw_input().split())\nn, m = inp[0], inp[1]\nl = m\nr = n\nwhile (r - l > 1):\n mid = (r + l) / 2\n if (n - (mid - m - 1) * (mid - m) / 2 > mid):\n l = mid\n else:\n r = mid\nprint r"}, {"source_code": "def bs(v):\n\tl, h = 0, int(3e9)\n\twhile l<h:\n\t\tm=(l+h)/2\n\t\tv1=m*(m+1)/2\n\t\tif v1>=v:\n\t\t\th=m\n\t\telse :\n\t\t\tl=m+1\n\t\n\tv1=l*(l+1)/2\n\tif v1<v:\n\t\treturn l+1\n\treturn l\n\nn,m=map(int,raw_input().split())\n\nif n<=m:\n\tprint n\nelse:\n\tprint bs(n-m)+m\n"}, {"source_code": "x = raw_input().split(' ')\nn = int(x[0])\nm = int(x[1])\n\nmini = 0\nmaxi = min(n, 3 * 10**9)\n\nif n < m:\n\tmini = n\n\tmaxi = n\n\tm = 0\n\nwhile maxi > mini:\n\tmidi = (mini + maxi) / 2\n\t\n\ttestval = m + midi * (midi + 1) / 2\n\n\tif testval == n:\n\t\tmaxi = midi\n\t\tbreak\n\n\tif testval < n:\n\t\tmini = midi + 1\n\telse:\n\t\tmaxi = midi\n\n\nprint m + maxi"}, {"source_code": "import math\nfrom decimal import Decimal\na,b = map(int,input().split())\nif a<=b:\n\tprint(a)\nelse:\n\tans = math.ceil(((Decimal(1+8*(a-b))**Decimal(0.5))-1)/2)\n\tprint(ans+b)\n\t"}, {"source_code": "if __name__==\"__main__\":\n n,m=list(map(int,input().split()))\n if(n<=m):\n print(n)\n exit()\n l=0\n r=10**19\n\n\n while(r>l+1):\n k=(l+r)//2\n if(n-((k-1)*k)//2-(m+k)>0):\n l=k\n else:\n r=k\n print(m+r)\n \n \n"}, {"source_code": "from math import ceil, sqrt\n\nn, m = [int(i) for i in input().split()]\n\nif m >= n:\n print(n)\n\n\nelse :\n l = 0\n r = 10**18\n ans = 10**18\n while (l <= r):\n mid = (l + r) // 2\n\n if mid * mid + mid >= 2 * (n - m):\n ans = mid\n r = mid - 1\n\n else:\n l = mid + 1\n\n print(ans + m)"}, {"source_code": "def get(n):\n return (1+n)*n/2\nn,m=map(int,raw_input().split())\n\nl,r=m+1,n\nwhile l<r:\n md=(l+r)/2\n if (get(md-1-m)+md>=n):\n r=md\n else:\n l=md+1\nif (n<=m):\n print n\nelse:\n print l\n "}, {"source_code": "n, m = map(int, input().split())\n\ndef s(x):\n return (1 + x) * x\n\ndef can(x):\n if x >= n:\n return True\n if x <= m:\n return False\n if (2 * n - s(x - m - 1) <= 2 * x):\n return True\n return False\n\nr = 1000000000000000000\nl = 0\nwhile r - l > 1:\n mid = (l + r) // 2\n \n if can(mid):\n r = mid\n else:\n l = mid\nfor i in range(l, r + 1):\n if can(i):\n print(i)\n raise SystemExit"}, {"source_code": "\"\"\" Created by Shahen Kosyan on 3/15/17 \"\"\"\nfrom decimal import *\n\nif __name__ == \"__main__\":\n n, m = [int(x) for x in input().split()]\n\n if m >= n:\n print(n)\n else:\n days = Decimal((-1 + Decimal(1 + 8 * (n - m)) ** Decimal(0.5)) / 2)\n answer = days.to_integral_exact(rounding=ROUND_CEILING) + m\n print(answer)\n"}, {"source_code": "string1 = raw_input()\nlist1 = string1.split()\nn = int(list1[0])\nm = int(list1[1])\n\n\nflag = True;\nif m >= n:\n\tprint n\n\tflag = False;\nelse:\n\tnum = (n-m)*2\n\tl = 0\n\th = n\n\twhile l < h:\n\t\tmid = (l+h)/2;\n\t\tif num == mid*(mid + 1):\n\t\t\tl =mid\n\t\t\tbreak\n\t\telif num > mid*(mid + 1):\n\t\t\tl = mid + 1\n\t\telse:\n\t\t\th = mid\nif flag == True:\n\tprint l + m\n\n"}, {"source_code": "#!/usr/bin/python\n# coding=utf-8\n\nimport math\n\nif __name__ == '__main__':\n n, m = raw_input().split()\n n = int(n)\n m = int(m)\n if m >= n: \n print n\n else: \n ans = (math.sqrt(8 * n - 8 * m + 1) - 1) / 2\n ans = int(ans)\n while (2 + ans) * (ans - 1) < 2 * (n - m - 1):\n ans += 1\n print ans + m"}, {"source_code": "import sys\nn, m = map(int, input().split())\nl=m+1\nr=10**30\nans=n\nif n==1:\n\tans=1\nelse: \n\tif m<n:\n\t\twhile l!=r:\n\t\t\tmid=(l+r)//2\n\t\t\tif 2 * m + ( mid - m ) * ( mid - m + 1 ) < 2 * n :\n\t\t\t\tl=mid+1\n\t\t\telse :\n\t\t\t\tr=mid\n\t\tans=min(ans, l)\n\telse:\n\t\tans=n \nprint(int(ans))\n"}, {"source_code": "n, m = map(int, input().split())\n\ndef binary_search():\n l, r = 0, int(2e9)\n while l <= r:\n mid = l+r >> 1\n if (mid * (mid+1) // 2 >= n - m):\n r = mid-1\n else:\n l = mid+1\n return l\n\nif (n <= m): print(n)\nelse: print(binary_search() + m)\n"}, {"source_code": "n,m = map(int,raw_input().split())\nif m>=n:\n print n\nelse:\n s = (n - (m+1))\n if(s<=0):\n print m+1\n else:\n l = m+2\n r = n\n ans = n\n while(l<=r):\n mid = (l+r)/2\n eat = ((m + 2 + mid)*(mid - (m+1)))/2\n av = s + m*(mid - (m+1))\n if (av<=eat):\n ans = mid\n r = mid - 1\n else:\n l = mid + 1\n\n print ans\n\n \n"}, {"source_code": "\"\"\"\ncontest template, Mikhail Dektyarev <mihail.dektyarow@gmail.com>\nreal code is below\n\"\"\"\ndef readint():\n return int(input())\n \n \ndef readfloat():\n return float(input())\n \n \ndef readarray(n, f=input):\n return [f() for i in range(n)]\n \n \ndef readlinearray(f=int):\n return list(map(f, input().split()))\n \n \n#gcd, x, y; a * x + b * y = gcd\ndef euclide(a, b):\n if a < 0:\n g, x, y = euclide(-a, b)\n return g, -x, y\n if b < 0:\n g, x, y = euclide(a, -b)\n return g, x, -y\n if b == 0:\n return a, 1, 0\n g, x, y = euclide(b, a % b)\n return g, y, x - (a // b) * y\n \n \ndef gen_primes(max):\n primes = [1] * (max + 1)\n for i in range(2, max + 1):\n if primes[i]:\n for j in range(i + i, max + 1, i):\n primes[j] = 0\n primes[0] = 0\n return [x for x in range(max + 1) if primes[x]]\n \n \ndef is_prime(N):\n if N % 2 == 0:\n return N == 2\n i = 3\n while i * i <= N:\n if N % i == 0:\n return False\n i += 2\n return True\n \n \ndef answer():\n return \"\"\n \n \ndef gcj():\n n, m = readlinearray()\n m = min(n, m)\n l = 0\n r = 10**18\n while l < r:\n q = (l + r) // 2\n # if (n - q * (q + 1) // 2) <= q:\n if n - m - q * (q + 1) // 2 <= 0:\n r = q\n else:\n l = q + 1\n print(l + min(m, n))\n \n \nif __name__ == \"__main__\":\n gcj()"}, {"source_code": "n, m = list(map(int, input().split()))\nl = -1\nr = int(1e18 + 10)\nwhile r - l != 1:\n t = (r + l) // 2\n eaten = t\n if (t - 1 > m):\n eaten += (t - 1 - m) * (t - m) // 2\n if eaten >= n:\n r = t\n else:\n l = t\nprint(r)"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\nif m >= n:\n print(n)\nelse:\n l = 0\n r = 3000000000\n\n while (l < r):\n cur = (l + r) // 2\n if cur * (1 + cur) // 2 >= (n - m):\n r = cur\n else:\n l = cur + 1\n\n print(m + l)\n"}, {"source_code": "n, m = [int(i) for i in input().split()]\nl= min(m, n) - 1\nr = 10**18\nmid = -1\nwhile(r - l > 1) :\n mid = (l + r) // 2\n a = (mid - m) * (mid - m + 1) // 2 + m\n if (a < n) :\n l = mid\n else :\n r = mid\nprint(r)\n\n"}, {"source_code": "\ndef calc(a, b):\n return (a + b) * (b - a + 1) // 2\n\nn, m = map(int, raw_input().split())\nm = min(n, m)\nl = m\nr = int(2e18)\nans = r\nwhile l <= r:\n mid = (l + r) // 2\n if n + (mid - m) * m <= calc(m, mid):\n ans = mid\n r = mid - 1\n else:\n l = mid + 1\nprint(ans)"}, {"source_code": "def fit(n, m, x):\n if x >= n:\n return True\n elif x - m <= 0:\n return False\n elif 2*n+2*(x-m-1)*m<=(m+1+x)*(x-m):\n return True\n else:\n return False\n\n\nn, m = map(int, raw_input().strip().split())\nl = 1\nr = 1e18+10\nwhile(l < r):\n x = int((l+r)/2)\n if(fit(n, m, x)):\n r = x\n else:\n l = x+1\nprint r"}, {"source_code": "def find(l, r, kf):\n while l < r:\n m = (l + r) // 2\n if not kf(m):\n l = m + 1\n else:\n r = m\n\n return r\n\nn, m = map(int, input().split())\n\n\ndef isEnough(i):\n return (2 * i + 1) ** 2 >= 1 + 8 * (n - m)\n\n\nif m >= n:\n print(n)\nelse:\n d = find(1, 2*(n + m), isEnough)\n print(m + d)\n"}, {"source_code": "import math\nn,m=map(int,raw_input().split())\nif m>=n:\n\tprint n\nelse:\n\tn-=m\n\tcheck=int(math.sqrt(2*n))\n\ti=check\n\twhile(1):\n\t\tif i*(i+1) < 2*n:\n\t\t\tprint m+1+i\n\t\t\tbreak\n\n\t\ti-=1\n"}, {"source_code": "n, m = map(int, input().split())\nl = min(n, m)\nr = n\nk = min(n, m + 1)\n\nfor i in range(200):\n mid = (l + r) // 2\n if n + (mid - k) * m - (2 * k + mid - k) * (mid - k + 1) // 2 <= 0:\n r = mid\n else:\n l = mid\n\nfor i in range(l, r + 1):\n if n + (i - k) * m - (2 * k + i - k) * (i - k + 1) // 2 <= 0:\n print(i)\n break\n\n\n\n"}, {"source_code": "def sum(n):\n return n * (n + 1) / 2\n\nn, m = map(int, raw_input().strip().split(\" \"))\n\nif (m >= n):\n print n\n exit(0)\n\nl = 0\nr = n - m\n\nwhile (l < r):\n mid = (l + r) / 2\n if (sum(mid) >= n - m):\n r = mid\n else:\n l = mid + 1\n\nprint m + l"}, {"source_code": "import math\n\n# print raw_input().split()\nn, m = [int(x) for x in raw_input().split()]\n# # n = int(raw_str.split()[0])\n# # m = int(raw_str.split()[1])\n\ndef bin_search(x):\n\t# Find k such that sum(1..k) >= x\n\ti = 1\n\tj = x\n\twhile(j - i > 1):\n\t\tk = (i + j) / 2\n\t\ts = k * (k + 1) / 2\n\t\tif s > x:\n\t\t\tj = k\n\t\telif s == x:\n\t\t\ti = j = k\n\t\telse:\n\t\t\ti = k + 1\n\tif i == j:\n\t\treturn i\n\telse:\n\t\ts = i * (i + 1) / 2\n\t\treturn i if s >= x else j\n\n\nif n <= m:\n\tprint n\nelse:\n\t# ival = math.sqrt(2 * (n - m) + 0.25) - 0.5\n\tprint int(m + bin_search(n - m))\n"}, {"source_code": "n,m=map(int,input().split())\nif n<m:\n print(n)\nelse:\n (l, r) = (0, int(2e9))\n n-=m\n while l<r:\n mid=(l+r)//2\n val=mid*(mid+1)\n if val>=2*n:\n r=mid\n else:\n l=mid+1\n print(m+l)\n"}, {"source_code": "n,m = map(int, raw_input().strip().split(' '))\nans = m\n\nif m >= n:\n print n\nelse:\n import math\n #first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0\n first = math.sqrt(2*(n-m))\n temp = int(math.ceil(first))\n for i in xrange(max(temp-1,0), temp+2):\n if i*(i + 1) >= 2*(n-m):\n print ans + i\n break\n"}, {"source_code": "n, m = map(int, raw_input().split(\" \"))\n\nlt = 1\nrt = n\nmid = -1\nans = 0\nif n <= m:\n m = n - 1\n\nwhile lt <= rt:\n mid = (lt + rt) >> 1\n if ((mid + m) * (mid + m + 1) // 2 - m * (m + 1) // 2 >= n + (mid - 1) * m):\n ans = mid + m\n rt = mid - 1;\n else:\n lt = mid + 1\n\nprint (ans)\n"}, {"source_code": "n, m = map(int, raw_input().split())\nif n == 1:\n print 1\n exit()\n\nif n <= m:\n print n\n exit()\n\nk = m\nhi = 10**18\nlo = 0\nwhile hi - lo > 1:\n mid = (hi + lo) / 2\n x = n + mid * m - (mid+k)*(mid+k+1)/2 + k*(k-1)/2\n if x <= 0:\n hi = mid\n else:\n lo = mid\n\nprint hi + k\n"}, {"source_code": "[n,m] = map(int,raw_input().split())\n\ndays = m\ntry:\n\tk = int((-1 + (1+8*(n-m))**0.5)/2.0)\nexcept ValueError:\n\tprint n\n\texit()\nif n == m:\n\tprint m\n\texit()\nif k*(k-1)/2 >= n-m:\n\tprint k+m-1\nelif k*(k+1)/2 >= n-m:\n\tprint k+m\nelse:\n\tprint k+m+1\n\n'''\t\n50 20\n\n(50-20)+(-21+20)+(-22+20)+(-23+20)\n1+2+3+4+5+6...k = n-m = k(k+1)/2\nk2+k-2(n-m) = 0\nk = (-1 + sqrt(1+8(n-m)))/2.0\n'''\n"}, {"source_code": "import sys\nn,m = map(int,raw_input().split())\nif m>=n:\n print min(m,n)\n sys.exit()\nlo = m\nhi = n+1\nwhile lo < hi:\n mid = (lo+hi)/2\n cur = mid-m\n if cur*(cur-1)/2+m<n:\n lo = mid+1\n else:\n hi = mid\nprint lo-1"}, {"source_code": "n, m = [int(x) for x in raw_input().split()]\n\nif m >= n:\n\tprint n\n\texit()\n\nlo = m\nhi = n+1\n\nans = -1\n\ndef check(start, days):\n\tif days > n:\n\t\treturn -1\n\teaten = (days+start) * (days-start+1) / 2\n\treceived = n + (days-start) * m\n\treturn received - eaten\n\nwhile hi-lo>1:\n\tmid = (lo+hi)/2\n\n\tres = check(m, mid)\n\tif res > 0:\n\t\tlo = mid\n\telif res < 0:\n\t\thi = mid\n\telse:\n\t\tans = mid\n\t\tbreak\n\nif ans != -1:\n\tprint ans\nelse:\n\tprint hi"}, {"source_code": "import math\nn, m = map(int, input().split())\n\nif m >= n:\n print(n)\nelse:\n disc = 1 + 8 * (n - m)\n dr = (-1 + pow(disc, 0.5)) / 2.0\n dr = math.ceil(dr);\n if (dr * (dr - 1) >= 2 * (n - m)) :\n dr -= 1\n if (dr * (dr + 1) < 2 * (n - m)) :\n dr += 1\n print(m + dr)\n"}, {"source_code": "s=raw_input().split(\" \");\nn=int(s[0])\nm=int(s[1])\n\ntemp=(m*(m+1))/2;\nlo=0\nhi=1000000*1000000*1000000;\nif(n<m):\n\tprint n;\nelse:\n\twhile(lo<hi):\n\t\tmid=(lo+hi)/2;\n\t\tif(n+(mid-1)*m>((m+mid+1)*(m+mid))/2-temp):\n\t\t\tlo=mid+1;\n\t\telse:\n\t\t\thi=mid;\n\n\tprint m+hi;\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Jun 13 16:08:37 2017\n\n@author: arik\n\"\"\"\nimport math\n\ndef P(n,m,i):\n if(i <= m+2):\n return n-(i-1)\n s = ( (m+1)*(m+2) )//2\n t = ( (i)*(i-1) )//2\n x = (n-m-1) + (i-m-2)*m - t + s\n return x\n\ndef F(n, m, i):\n if(i <= m+1):\n return n-i\n return P(n,m,i) + m - i\n\nn,m=map(int,raw_input().split())\n\n# for i in range(1, 15):\n # print F(n,m,i)\n\nl=1\nh=n+m+1\n\nwhile(l <= h):\n mid=l+(h-l)//2\n if(F(n,m,mid) == 0 or ( F(n,m,mid)<0 and F(n,m,mid-1)>0 )):\n print mid\n break\n elif(F(n,m,mid) < 0):\n h = mid\n else:\n l = mid\n"}, {"source_code": "def binary_search(n,nm):\n lo = 0\n hi = n\n while lo < hi:\n mid = (lo+hi)//2\n midval = mid**2 + 3*mid + 2\n if midval < nm:\n lo = mid+1\n elif midval > nm:\n hi = mid\n else:\n return mid\n return lo\n\n[n, m] = map(int, input().split())\n\nif n - m <= 0:\n print(n)\nelse:\n print(m + binary_search(n, 2*(n - m)) +1)\n"}, {"source_code": "n, m = map(int, input().split())\n\nl = 0\nr = 10**18 + 1\n\ndef can(mid):\n if mid <= m:\n return (n - mid) > 0\n \n plus = (n - m) - ((mid-m) * (mid-m+1)) // 2\n return plus > 0\n\nwhile r - l > 1:\n mid = (l + r) // 2\n if can(mid):\n l = mid\n else :\n r = mid\n\nprint(r);\n"}], "negative_code": [{"source_code": "n,m=map(int,raw_input().split())\n\ndef isempty(d):\n\tif d<1:return False\n\tif d*(d+1)/2>=m*max(0,d-m)+n+m*(m-1)/2:\n\t\treturn True\n\telse:\n\t\treturn False\ndef binsearch(srt,end):\n\tmid=(srt+end)/2\n\tprint mid,isempty(mid)\n\tif srt==mid:return srt\n\tif isempty(mid)==True and isempty(mid-1)==False:\n\t\treturn mid\n\telif isempty(mid)==True:\n\t\treturn binsearch(srt,mid-1)\n\telse:\n\t\treturn binsearch(mid+1,end)\n\nprint binsearch(1,n)\n"}, {"source_code": "from math import floor,sqrt,ceil\n\ns,m=map(int,raw_input().split())\nif s<=m:\n print 1\nelse:\n d=int(sqrt(2*(s-m)))\n if d*(d+1)>=2*(s-m) and d*d<=2*(s-m):\n print m+d\n elif d*(d+1)<=2*(s-m) and (d+1)*(d+2)>=2*(s-m):\n print m+d+1\n else:\n print m+d-1\n"}, {"source_code": "from decimal import Decimal\nfrom math import ceil, sqrt\n\nn, m = map(int, raw_input().split())\n\n\n\nif m > n:\n print n \nelse:\n temp = Decimal(1 + 4*(2*n - 2*m))\n #print temp\n ans = (-1 + temp.sqrt())/2\n #print ans\n print int(ceil(ans)) + m"}, {"source_code": "n, m = map(int, input().split())\nif m>=n:\n print(n)\nelse:\n l = 1\n r = 2000000000\n for i in range(100):\n mid = (l + r) / 2\n mid = int(mid)\n if((mid) * (mid - 1) / 2 + mid + m >= n):\n r = mid\n else:\n l = mid\n print(m + r)\n\n"}, {"source_code": "from math import ceil\nfrom math import sqrt\n\nn, m = map(int, input().split())\n\nif n < m:\n print(n)\nelse:\n k = ceil(.5 * sqrt(-8 * m + 8 * n + 1) - .5)\n day = int(m + k)\n print(day)\n"}, {"source_code": "s = input().split(' ')\nn = int(s[0])\nm = int(s[1])\nif m>=n:\n\tprint(n)\nelse:\n\tx = ((8*n-8*m+1)**0.5)/2-0.5\n\ty= int(x)\n\tans = m +y\n\tif (y+1)**2 + y +1 >= 2*n-2*m:\n\t\tans += 1\n\tprint(ans)"}, {"source_code": "n, m = map(int,input().split())\n\n\nn = int(n)\nm = int(m)\nl = 0\nr = 10 ** 30\n\nif n == 1:\n print(1)\nelse:\n while r - l > 1 :\n d = (l + r) // 2\n if n + m * (d - m) + m * (m - 1) // 2 - d * (d + 1) // 2 <= 0:\n r = d\n else:\n l = d\n # if n + m * (l - m) + m * m - l * (l + 1) // 2 <= 0:\n # print(l)\n # else:\n print(l + 1)"}, {"source_code": "input=__import__('sys').stdin.readline\nn,m = map(int,input().split())\nl=0\nr=1000000000000000000000000\nwhile l<=r:\n mid = l +(r-l)//2\n# print(n-(mid*(mid+1))//2,m+1+mid,mid,l,r)\n if n-(mid*(mid+1))//2>=m+1+mid:\n l=mid+1\n else:\n r=mid-1\n#print(l,r) \nif n-(r*(r+1))//2 <= m+r+1:\n print(m+r+1)\nelse:\n print(l+m+1) \n"}, {"source_code": "def f(n, m):\n\tsz = n\n\tn -= 1\n\tstep = 2\n\twhile n > 0:\n\t\tn += m\n\t\tn = min(n, sz)\n\t\tn -= step\n\t\tstep += 1\n\treturn step - 1\n\nn, m = map(int, input().split())\ncnt = max(n - m, 0)\nl = 0\nr = 10 ** 18\nwhile l + 1 < r:\n m1 = (l + r) // 2\n x = (m1 * (m1 - 1)) // 2\n if x <= cnt:\n l = m1\n else:\n r = m1\nprint(m + l)\n"}, {"source_code": "from sys import stdin, stdout\n \nn, k = map(int, stdin.readline().split())\nk = min(k, n)\n\n\nD = 9 + 8 * (n - k - 1)\nday1 = (D ** 0.5 - 3) / 2\n\nif day1 == int(day1):\n stdout.write(str(int(day1) + 1 + k))\nelse:\n stdout.write(str(int(day1) + 2 + k))"}, {"source_code": "n, m = map(int, input().split())\n\nl = 1\nr = 10**18 + 1\n\ndef can(mid):\n if mid <= m:\n return (n - mid) > 0\n \n plus = (n - m) - ((mid-m) * (mid-m+1))/2\n return plus > 0\n\nif can(1):\n\n while r - l > 1:\n mid = (l + r) // 2\n if can(mid):\n l = mid\n else :\n r = mid\n\n print(r);\n\nelse :\n print(1);"}, {"source_code": "n,m=map(int,input().split())\nk=min(n,m)\nn-=min(n,m)\nl=0\nr=123123123123123\nwhile l<r :\n m=(l+r)//2\n if int((1+m)/2*m)>=n :\n r=m\n else :\n l=m+1\n\n\nprint(l+k)\n"}, {"source_code": "from math import ceil\n\nn, m = map(int, raw_input().split())\n\n\n\nif m > n:\n print n \nelse:\n temp = float(1 + 4*(2*n - 2*m))\n\n ans = (-1 + (temp)**0.5)/2\n\n print int(ceil(ans)) + m"}, {"source_code": "from math import *\na, b = [int(x) for x in input().split(' ')]\nprint(ceil(sqrt(2*(a-b)+0.25)+b-0.5))\n"}, {"source_code": "import math\nn,m=map(int,input().split())\nif(m>=n):\n print(n)\nelse:\n temp=min(n,m)\n a=temp+1\n res=temp\n start=1\n end=1e18\n while(start<=end):\n mid=(start+end)//2\n if(((mid)*(2*a+mid-1)//2)>n+(mid-1)*m):\n end=mid-1\n elif(((mid)*(2*a+mid-1)//2)<n+(mid-1)*m):\n start=mid+1\n else:\n start=mid\n break\n print(int(start+res))\n #res+=(1+2*m-2*a+math.sqrt((1+2*m-2*a)**2+8*(n-m)))/2\n #print(math.ceil(res))\n"}, {"source_code": "import math\n\nn, m = map(int, raw_input().split())\n\nprint int(math.ceil( (-1 + math.sqrt(1 + 8 * (n - m))) / 2. + m ))"}, {"source_code": "n, m = map(int, input().split())\nif m >= n:\n print(n)\nelse:\n n -= m\n l, r = 0, n\n while l < r:\n mid = (l + r) // 2\n if (1 + mid) * mid / 2 >= n:\n r = mid\n else:\n l = mid + 1\n print(l + m)\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n#-------------------------code---------------------------#\n#vsInput()\n\ndef remainingGrain(x):\n eaten=x*(x-1)//2\n grain=k*(x-k) + k*(k-1)//2 +n\n #print(grain,eaten,x)\n left=grain-eaten\n return left<=x\n\n\n\nn,k=value()\nif(k>=n):\n print(1)\n exit()\n\nans=1\nlow=k\nhigh=10**18\n\nwhile(low<=high):\n \n mid=(low+high)//2\n\n if(remainingGrain(mid)):\n ans=mid\n high=mid-1\n else:\n low=mid+1\n\nprint(ans)"}, {"source_code": "import math\n\ndef f(i):\n return int(i*(i+1)/2)\n\ndef solve(n,m):\n lo = 0\n hi = int(10**18)\n while(lo < hi):\n mid = int((lo+hi)/2)\n print(\"mid \" + str(mid))\n if n - f(mid) <= m:\n hi = mid\n else:\n lo = mid+1\n return mid + m\n\n\ndef main():\n a = list(map(int,input(\"\").split(\" \")))\n n,m = a\n print(min(n,solve(n,m)))\n return\n\nmain()\n"}, {"source_code": "n,m = map(int, raw_input().strip().split(' '))\nans = m\n\nif m >= n:\n print n\nelse:\n import math\n first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0\n temp = int(math.ceil(first))\n temp -= 1\n if temp*(temp + 1) >= 2*(n-m):\n print ans + temp\n else:\n temp += 1\n if temp*(temp + 1) >= 2*(n-m):\n print ans + temp\n else:\n print ans + temp + 1\n"}, {"source_code": "inp=(raw_input(\"\"))\ninp=inp.split(' ')\nn=int(inp[0])\nm=int(inp[1]) \n\nk=m\nn=n-m\n\nx=0\ny=0\nz=5000000000\n\nwhile x<z:\n y=(x+z)/2\n j=y*(y+1)/2\n\n if j<n:\n x=y+1\n else:\n z=y\n\t\t\nk=k+z\nprint(k)\t\t"}, {"source_code": "n, m = map(int, raw_input().split())\n\nprint (m+n)/(m+1) + m"}, {"source_code": "__author__ = 'zihaozhu'\nfrom sys import stdin\nimport math\n\n\ncapacity,grain = map(int,stdin.readline().split())\ntotalcap = capacity+grain\n\nstartingday = grain+1\nif capacity<=grain:\n print(capacity)\nelse:\n days=0\n start = startingday\n lo = 0\n hi =int(2e9)\n ans =0\n capacity-=grain\n while lo<hi:\n mid = (lo+hi)//2\n #print(lo,hi)\n #print(\"mid\",mid)\n val = mid*(mid+1)/2\n #print(val)\n if val >= capacity:\n hi = mid\n ans = mid\n #print(\"is it true\")\n else:\n lo = mid +1\n \n #print(\"mid\",mid)\n \n \n # print(\"ans\",ans)\n # print(\"grain\",grain)\n print(startingday+lo-1)"}, {"source_code": "def sm(l, r):\n\treturn (r + 1) * r / 2 - (l - 1) * l / 2\n\nn, m = map(int, input().split())\n\nif n <= m:\n\tprint(n)\nelse:\n\tl = -1\n\tr = n + 1\n\n\twhile r - l > 1:\n\t\tmid = int((l + r) / 2)\n\n\t\tif n - sm(1, mid) > m:\n\t\t\tl = mid\n\t\telse:\n\t\t\tr = mid\n\n\tprint(m + r)\n"}, {"source_code": "from math import *\na, b = [int(x) for x in input().split(' ')]\nif a<b:\n print(a)\nelse:\n print(ceil(sqrt(8 * a - 8 * b + 1)/2 - 0.5)+b)\n"}, {"source_code": "def f(n, m):\n\tsz = n\n\tn -= 1\n\tstep = 2\n\tprint('n = ', n)\n\twhile n > 0:\n\t\tn += m\n\t\tn = min(n, sz)\n\t\tn -= step\n\t\tstep += 1\n\treturn step - 1\n\nn, m = map(int, input().split())\nm = min(m, n)\ncnt = max(n - m, 0)\nl = 0\nr = 10 ** 18\nwhile l + 1 < r:\n m1 = (l + r) // 2\n x = (m1 * (m1 + 1)) // 2\n if x < cnt:\n l = m1\n else:\n r = m1\nprint(m - 1 + r)\n"}, {"source_code": "import math\nn, m = map(int, raw_input().split())\nif n <= m:\n print n\nelse:\n print m + int(math.ceil((math.sqrt(8 * (n-m) + 1) - 1)/2)) \n\n"}, {"source_code": "n, m = map(int, input().split(' '))\ni = m\nj = 0\nif n > m:\n\twhile j * (1 + j) / 2 < n:\n\t\tj += 1\nprint(i + j)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nSpyder Editor\n\nThis is a temporary script file.\n\"\"\"\n\nimport math\n\nn,m = input().split()\n\n#print(str(n)+str(m))\nn = int(n)\nm = int(m)\n\nans = min(n,m)\nn-=m\nn = max(n,0)\nx = -1\ny = int(math.sqrt(n))\n\ni = y - 10\nwhile(i<y+10):\n #print(i)\n if(i<=0):\n i+=1\n continue\n p = i\n q = i+1\n if(p%2):\n q/=2\n else:\n p/=2\n if(p*q<n):\n i+=1\n continue\n if(x==-1):\n x = i\n else:\n x = min(x,i)\n \n i+=1\n\nif (x==-1):\n x=0\nans +=x\nprint(ans)"}, {"source_code": "from math import ceil\nn,m = map(int,input().split())\nif m >= n:\n print(n)\nelse:\n #num = 0 <= n2**2 + n2 - (n - m)*2\n num2 = (n - m)*2\n num2 = num2 * 4 + 1.0\n num3 = num2\n num2 = num2 ** 0.5\n num = int((-1 + (num2))/2)\n num -= 10\n while True:\n if (n - m)*2 - (num * (num+1)) <= 0:\n break\n num += 1\n print(num + m)\n"}, {"source_code": "n, m = map(int,input().split())\n\n\nn = int(n)\nm = int(m)\nl = 0\nr = 10 ** 30\n\nif n == 1:\n print(1)\nelse:\n while r - l > 1 :\n d = (l + r) // 2\n if n + m * (d - m) + m * (m - 1) // 2 - d * (d + 1) // 2 <= 0:\n r = d\n else:\n l = d\n # if n + m * (l - m) + m * m - l * (l + 1) // 2 <= 0:\n # print(l)\n # else:\n print(l + 1)"}, {"source_code": "s = input().split(' ')\nn = int(s[0])\nm = int(s[1])\n\nif m >= n:\n print(n)\nelse:\n print(m + 1 + (n-m)//2)"}, {"source_code": "n, m = map(int, raw_input().split(\" \"))\n\nlt = 1\nrt = n\nmid = -1\nans = 0\n\nwhile lt <= rt:\n mid = (lt + rt) >> 1\n if ((mid + m - 1) * (mid + m) / 2 >= n + (mid - 1) * m):\n ans = mid + m - 1\n rt = mid - 1;\n else:\n lt = mid + 1\n\nprint (ans)\n"}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin,stdout\n\nimport math\n\ndef ri():\n return map(int, input().split())\n\nn, m = ri()\n\nif m-n+1 >= 0:\n print(n)\n exit()\n\nk = n-m\nl = (1+8*k)**0.5\na1 = (-1 + l)/2\na2 = (-1 - l)/2\n\nif a1 > 0 and a1 + m >= m + 1:\n ans = m + math.ceil(a1)\nelse:\n ans = m + math.floor(a2)\n\nprint(ans)\n\n\n"}, {"source_code": "from math import ceil, sqrt\ndef f(n, m):\n if m >= n:\n return n\n \n n -= m\n d1 = ceil((-1 + sqrt(1 + 8 * n)) / 2)\n d2 = ceil((-1 - sqrt(1 + 8 * n)) / 2)\n d = d2 if d2 > 0 else d1\n return d + m\n\nn, m = list(map(int, input().split()))\nprint(f(n, m))"}, {"source_code": "from math import *\nfrom collections import *\nfrom random import *\nfrom bisect import *\nimport sys\ninput=sys.stdin.readline\ndef lis():\n return list(map(int,input().split()))\ndef ma():\n return map(int,input().split())\ndef inp():\n return int(input())\ndef fk(a,s,k):\n b=[]\n for i in range(len(a)):\n b.append(a[i]+(i+1)*k)\n b.sort()\n return sum(b[:k])\nn,m=ma()\nif(m>=n):\n print(n)\n exit(0)\nre=m\nc=(-1+((1+8*(n-m))**(0.5)))/2\nc=ceil(c)\nprint(c+re)\n \n \n\n \n \n \n"}, {"source_code": "import sys\nimport math\nn, m = map(int, input().split())\ndef ans(nn):\n print(nn)\n sys.exit()\n \nif n <= m:\n ans(n)\n \nC = n\nif n < 100000:\n d = 0\n while n>0:\n #this is d day\n d += 1\n n = min(C, n + m) - d\n ans(d)\n \nt = n - m\n\nif t < 100000000:\n k = 0\n while k*(k+1)/2 < t:\n k +=1\n ans(m + k)\nk = int(math.sqrt(2*t)) - 10000\nwhile k*(k+1)/2 <t:\n k+=1\nans(m+k)"}, {"source_code": "def f(x):\n return x*(x+1)//2\n\nn,m=map(int, input().split())\nn=10000\nn=n*n*n\nprint(n)\nif m>=n: print(n)\nelse:\n amount=n-m\n ans=m\n l=0\n r=min(2000000000,n)\n while l+1<r:\n m=(l+r)//2\n if f(m)<amount: l=m+1\n else: r=m\n if f(l)>=amount: ans+=l\n else: ans+=r\n print(ans)\n"}, {"source_code": "from sys import stdin, stdout\nfrom math import sqrt\n\nn, k = map(int, stdin.readline().split())\nk = min(k, n)\n\ndef sqrtt(x):\n l = 1\n r = x\n \n while (r - l > 10 ** (-6)):\n m = (r + l) / 2\n \n if m * m >= x:\n r = m\n else:\n l = m\n\n if int(r) * int(r) >= x:\n return int(r)\n else:\n return r\n\n\nD = 9 + 8 * (n - k - 1)\nday1 = (sqrtt(D) - 3) / 2\n\nif day1 == int(day1):\n stdout.write(str(int(day1) + 1 + k))\nelse:\n stdout.write(str(int(day1) + 2 + k))"}, {"source_code": "x = raw_input().split(' ')\nn = int(x[0])\nm = int(x[1])\n\nmini = 0\nmaxi = min(n, 3 * 10**9)\n\nwhile maxi > mini:\n\tmidi = (mini + maxi) / 2\n\t\n\ttestval = m + midi * (midi + 1) / 2\n\n\tif testval == n:\n\t\tmaxi = midi\n\t\tbreak\n\n\tif testval < n:\n\t\tmini = midi + 1\n\telse:\n\t\tmaxi = midi\n\n\nprint m + maxi"}, {"source_code": "n,m = map(int, raw_input().strip().split(' '))\nans = m\n\nif m >= n:\n print n\nelse:\n import math\n first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0\n temp = int(math.ceil(first))\n for i in xrange(max(temp-2,0), temp+3):\n if i*(i + 1) >= 2*(n-m):\n print ans + i\n break\n"}, {"source_code": "from math import ceil\n\nn, m = map(int, raw_input().split())\n\n\n\nif m>=n:\n print m+1\nelse:\n temp = 1 + 4*(2*n - 2*m)\n\n ans = (-1 + (temp)**0.5)/2\n\n print int(ceil(ans)) + m"}, {"source_code": "__author__ = 'zihaozhu'\nfrom sys import stdin\nimport math\n\ndef findx(x,y,startingday):\n if (y*2)<(x+startingday) * (x-startingday+1):\n return True\ncapacity,grain = map(int,stdin.readline().split())\n# print(capacity,grain)\ntotalcap = capacity+grain\n\nstartingday = grain+1\n\n# print(startingday)\n# print(totalcap)\n#days = math.floor(((totalcap * 2) + (startingday**2))**0.5)\n\ndays=0\nstart = startingday\nlo = 0\nhi =totalcap\n\nwhile lo<hi:\n mid = (lo+hi)//2\n if findx(mid,totalcap,startingday):\n hi = mid\n else:\n lo = mid +1\n\n#print(\"mid\",mid)\n\n\n\nprint(mid)"}, {"source_code": "def s(x):\n return (1 + x) // 2 * x\n\ndef can(x):\n if x >= n:\n return True\n if x <= m:\n return False\n if (n - s(x - m - 1) <= x):\n return True\n return False\n\nn, m = map(int, input().split())\n\nr = 1000000000000000000\nl = 0\nwhile r - l > 1:\n mid = (l + r) // 2\n \n if can(mid):\n r = mid\n else:\n l = mid\nfor i in range(l, r + 1):\n if can(i):\n print(i)\n raise SystemExit"}, {"source_code": "n, m = map(int, input().split())\n# NNNNYYYY\n\nlow = (int)(-m+1)\nhigh= (int)(10000000000000)\nwhile low<high:\n mid = (int)(low + (int)((high-low)/2))\n if (int)(mid*(mid+1)) >= (int)((n-m)*2):\n high=mid\n else:\n low = mid+1\n \nif low*(low+1) < (n-m)*2:\n low+=1\nprint((int)(low+m))\n\n"}, {"source_code": "n,m = map(int, raw_input().strip().split(' '))\nans = m\n\nif m >= n:\n print n\nelse:\n import math\n first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0\n #first = math.sqrt(2*(n-m))\n temp = int(math.ceil(first))\n for i in xrange(max(temp-1,0), temp+2):\n if i*(i + 1) >= 2*(n-m):\n print ans + i\n break\n"}, {"source_code": "n, m = map(int, input().split())\n\ndef c(n):\n return (1 + n) * (n) // 2\n\ndef md(a, b):\n return (a + b) // 2\n\nif n <= m:\n print(n)\nelse:\n a = 0\n if n - m - 1 <= 0:\n print(m + 1)\n else:\n l = 0\n r = int(1e10)\n r - l >= 0\n nn = n - m - 1\n while r - l >= 1:\n # print([l, r, md(l, r)], c(md(l, r)), nn)\n if c(md(l, r)) < nn:\n l = md(l, r) + 1\n a = c(md(l, r))\n # print(\"a\", a)\n else:\n r = md(l, r) - 1\n print(min(l, r) + m + 1)\n"}, {"source_code": "from math import *\nfrom collections import *\nfrom random import *\nfrom bisect import *\nimport sys\ninput=sys.stdin.readline\ndef lis():\n return list(map(int,input().split()))\ndef ma():\n return map(int,input().split())\ndef inp():\n return int(input())\ndef fk(a,s,k):\n b=[]\n for i in range(len(a)):\n b.append(a[i]+(i+1)*k)\n b.sort()\n return sum(b[:k])\nn,m=ma()\nif(m>=n):\n print(n)\n exit(0)\nre=m\nc=(-1+((1+8*(n-m))**(0.5)))/2\nc=ceil(c)\nprint(c+re)\n \n \n\n \n \n \n"}, {"source_code": "n, m = map(int, raw_input().split(\" \"))\nif n == m:\n print n\ni = 0\nwhile True:\n i += 10000\n if i*(i+1)/2 + m >= n:\n break\ni -= 10000\nwhile True:\n i += 1000\n if i*(i+1)/2 + m >= n:\n break\ni -= 1000\nwhile True:\n i += 100\n if i*(i+1)/2 + m >= n:\n break\ni -= 100\nwhile True:\n i += 10\n if i*(i+1)/2 + m >= n:\n break\ni -= 10\nwhile True:\n i += 1\n if i*(i+1)/2 + m >= n:\n break\nprint i + m\n"}, {"source_code": "n, m = map(int, input().split())\n\nmskip = (m + 1) // 2 * (m) if m % 2 else (m) // 2 * (m + 1)\nl = m + 2\nr = 10**18\ngi = 0\n\nwhile l <= r:\n i = (l + r) // 2\n irem = ((i + 1) // 2 * i if i % 2 else i // 2 * (i + 1)) - mskip\n addi = (i - m - 1) * m + n\n \n if irem >= addi:\n gi = i\n r = i - 1\n else:\n l = i + 1\n\nprint(gi)\n"}, {"source_code": "def solution():\n n, m = map(int, input().split())\n\n ans = m + 1\n if n - ans > 0:\n alfa = n - ans\n lo, hi = 0, 10 ** 20\n while lo != hi:\n mid = ( lo + hi ) // 2\n if mid * ( mid + 1 ) >= 2 * ( alfa - 1 ):\n hi = mid\n else:\n lo = mid + 1\n ans += lo\n ans = min(ans, n)\n print(ans)\n\nif __name__ == '__main__':\n solution()\n"}, {"source_code": "from math import sqrt\nfrom math import ceil\nfrom math import floor\nn,m = list(map(int, input().split()))\nbarn = n\nif n < m:\n\tprint(n)\nelse:\n\tsq = sqrt(m)\n\tdays = floor(sq)\n\twhile True:\t\t\n\t\tif barn - days <= 0:\n\t\t\tbreak\n\t\tbarn += (m - days)\n\t\tdays += 1\n\tprint(days)"}, {"source_code": "#!/usr/bin/python\n# coding=utf-8\n\nimport math\n\nif __name__ == '__main__':\n n, m = raw_input().split()\n n = int(n)\n m = int(m)\n if m >= n: \n print n\n else: \n ans = ((2 * m + 1) + math.sqrt((2 * m + 1) * (2 * m + 1) - 4 * (m * m + m - 2 * n))) / 2;\n while (ans - m) * (ans - m - 1) < 2 * n:\n ans += 1\n print int(ans) - 1"}, {"source_code": "n, m = map(int, input().split())\n\nl = 0\nr = 10**18 + 1\n\ndef can(mid):\n if mid <= m:\n return (n - mid) > 0\n \n plus = (n - m) - ((mid-m) * (mid-m+1))/2\n return plus > 0\n\nwhile r - l > 1:\n mid = (l + r) // 2\n if can(mid):\n l = mid\n else :\n r = mid\n\nprint(r);\n"}, {"source_code": "import math\nn,m=list(map(int,input().split()))\ni=0\ncurr=m+1\nstart=n\nn=n-m-1\na1=m+1\nk1=(1-2*a1+math.sqrt(1-4*a1+4*a1*a1+8*n))/2\nk1=math.ceil(k1)\nk1=k1+curr\nif m>start:\n print(start)\nelse:\n print(k1)\n"}, {"source_code": "from sys import stdin\nfrom math import ceil, sqrt\nn, m = map(int, stdin.read().split())\nj = min(m, n -1)\nprint int(j + ceil(m - j - 0.5 + sqrt((m - j - 0.5) ** 2 + 2 * (n - j))))"}, {"source_code": "import math\nfrom decimal import Decimal\na,b = map(int,input().split())\nif a<=b:\n\tprint(a)\nelse:\n\tans = math.ceil((-1+math.sqrt(Decimal(1+8*(a-b))))/2)\n\tprint(ans+b)\n\t\n"}, {"source_code": "def sm(l, r):\n\treturn (r + 1) * r / 2 - (l - 1) * l / 2\n\nn, m = map(int, input().split())\n\nif n <= m:\n\tprint(n)\nelse:\n\tl = -1\n\tr = n + 1\n\n\twhile r - l > 1:\n\t\tmid = int((l + r) / 2)\n\n\t\tif n - sm(1, mid) > m:\n\t\t\tl = mid\n\t\telse:\n\t\t\tr = mid\n\n\tprint(m + r)\n"}, {"source_code": "n, m = list(map(int, input().split()))\nl = -1\nr = int(1e18 + 1)\nwhile r - l != 1:\n t = (r + l) // 2\n if t >= n or (t - m) * (t - m + 1) // 2 + m >= n:\n r = t\n else:\n l = t\nprint(r)"}, {"source_code": "import math\nfrom decimal import Decimal \nn, m = map(int, raw_input().split())\n\n\n\nif n<m+1:\n\tprint n\n\texit(0)\t\n\nif n>m+1:\n\tD = math.sqrt( Decimal(1+8*(n-m)) )\n\tx1 = int(math.ceil(( 1+D)/2 ))\n\tprint x1+m-1\n\t\n\t\n"}, {"source_code": "def check(mid):\n global n, m\n return n + m * mid - (m + mid + 1) * (m + mid + 2) // 2 + m * (m + 1) // 2 <= 0\n\n\nn, m = map(int, input().split())\nif m >= n:\n print(n)\nelse:\n ans = m + 1\n l = 0\n r = n + 1\n while (r - l > 1):\n mid = (r + l) // 2\n if check(mid):\n r = mid\n else:\n l = mid\n ans += r\n print(ans)"}, {"source_code": "n, m = map(int, input().split())\nif m >= n:\n print(n)\nelse:\n n -= m\n l, r = 0, int(2e9)\n while l < r:\n mid = (l + r) // 2\n if (1 + mid) * mid / 2 >= n:\n r = mid\n else:\n l = mid + 1\n print(l + m)"}, {"source_code": "import math as ma\nfrom decimal import *\ngetcontext().prec = 30\nn,m=list(map(int,input().split()))\nif n>=m:\n b=Decimal(ma.sqrt(Decimal(1+8*(n-m))))\n a=Decimal((-1+Decimal(b))/2)\n print(ma.ceil(a)+m)\nelse:\n print(n)"}, {"source_code": "n, m = map(int, input().split())\n# NNNNYYYY\n\nlow = -m+1\nhigh= 4e18\nwhile low<high:\n mid = low + (int)((high-low)/2)\n if mid*(mid+1) >= (n-m)*2:\n high=mid\n else:\n low = mid+1\n \nprint(low+m)\n\n"}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin,stdout\n\nimport math\n\ndef ri():\n return map(int, input().split())\n\nn, m = ri()\n\nif m-n >= 0:\n print(n)\n exit()\n\nk = n-m\nl = (1+8*k)**0.5\na1 = (-1 + l)/2\na2 = (-1 - l)/2\n\nif a1 > 0 and a1 + m >= m + 1:\n ans = m + math.ceil(a1)\nelse:\n ans = m + math.floor(a2)\n\nprint(ans)"}, {"source_code": "n, m = [int(x) for x in input().split()]\ndef b_search(left,right):\n if left==right:\n return left\n middle=(left+right)//2 #day to choose\n # print(middle)\n _l=2*(n+m*(middle-m-1))\n _r=(m+1+middle)*(middle-m)\n holds=(_l<=_r) or (middle>=n)\n if not holds:\n return b_search(middle+1,right)\n else:\n return b_search(left,middle)\nprint(b_search(1,10**18+3))"}, {"source_code": "def check(mid):\n global n, m\n return n + m * mid - (m + mid + 1) * (m + mid + 2) // 2 + m * (m + 1) // 2 <= 0\n\n\nn, m = map(int, input().split())\nif m >= n:\n print(n)\nelse:\n ans = m + 1\n l = 0\n r = n + 1\n while (r - l > 1):\n mid = (r + l) // 2\n if check(mid):\n r = mid\n else:\n l = mid\n ans += r\n print(ans)"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n#-------------------------code---------------------------#\n#vsInput()\n\ndef remainingGrain(x):\n eaten=x*(x-1)//2\n grain=k*(x-k) + k*(k-1)//2 +n\n #print(grain,eaten,x)\n left=grain-eaten\n return left<=x\n\n\n\nn,k=value()\n\n\nans=n\nlow=k\nhigh=10**18\n\nwhile(low<=high):\n \n mid=(low+high)//2\n\n if(remainingGrain(mid)):\n ans=mid\n high=mid-1\n else:\n low=mid+1\n\nprint(ans)"}, {"source_code": "def sm(l, r):\n\treturn (r + 1) * r / 2 - (l - 1) * l / 2\n\nn, m = map(int, input().split())\n\nif n <= m:\n\tprint(n)\nelse:\n\tl = -1\n\tr = n + 1\n\n\twhile r - l > 1:\n\t\tmid = int((l + r) / 2)\n\n\t\tif n - sm(1, mid) > m:\n\t\t\tl = mid\n\t\telse:\n\t\t\tr = mid\n\n\tprint(m + r)\n"}, {"source_code": "s = input().split(' ')\nn = int(s[0])\nm = int(s[1])\n\nif m >= n:\n print(n)\nelse:\n print(m + 1 + (n-m)//2)"}, {"source_code": "(n,m) = map(int, input().split())\nif (n <= m):\n print (n)\nelse:\n aM = m\n n = n - m\n l = 0\n r = 2e9\n while (l < r):\n m = (l + r)/2\n val = m*(m+1) / 2\n if (val >= n):\n r = m\n else:\n l = m + 1\n print (l + aM)\n"}, {"source_code": "#!/usr/bin/env python\n\nm, n = map(int, input().split())\n# print(m, n)\ndaypassed = n + 1\nremain = m - n - 1\n# print('at day', daypassed, ': remain', remain)\n\nstart = daypassed + 1 - n\n# print(start)\nl = 0\nr = 1e9\nwhile r - l > 1:\n m = (l + r) // 2\n if 0.5 * m ** 2 + (start - 0.5) * m >= remain:\n r = m\n else:\n l = m + 1\nprint(int(daypassed + r))\n"}, {"source_code": "n,m = map(int, raw_input().strip().split(' '))\nans = m\n\nif m >= n:\n print n\nelse:\n import math\n first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0\n temp = int(math.ceil(first))\n for i in xrange(max(temp-2,0), temp+3):\n if i*(i + 1) >= 2*(n-m):\n print ans + i\n break\n"}, {"source_code": "def f(x):\n return x*(x+1)//2\n\nn,m=map(int, input().split())\nn=10000\nn=n*n*n\nprint(n)\nif m>=n: print(n)\nelse:\n amount=n-m\n ans=m\n l=0\n r=min(2000000000,n)\n while l+1<r:\n m=(l+r)//2\n if f(m)<amount: l=m+1\n else: r=m\n if f(l)>=amount: ans+=l\n else: ans+=r\n print(ans)\n"}, {"source_code": "L = input().split()\nn = int(L[0])\nm = int(L[1])\n\nif m>=n:\n print(n)\nelse:\n from math import ceil,sqrt\n print(ceil((-1+sqrt(1+8*(n-m)))/2.0) + m)\n\n"}, {"source_code": "n, m = map(int, input().split())\nif m>=n:\n print(n)\nelse:\n l = 1\n r = 2000000000\n for i in range(100):\n mid = (l + r) / 2\n mid = int(mid)\n if(int((mid) * (mid + 1) / 2) + m >= n):\n r = mid\n else:\n l = mid\n print(m + r)\n\n"}, {"source_code": "n, m = list(map(int, input().split()))\nl = -1\nr = int(1e18 + 1)\nwhile r - l != 1:\n t = (r + l) // 2\n if t >= n or (t - m) * (t - m + 1) // 2 + m >= n:\n r = t\n else:\n l = t\nprint(r)"}, {"source_code": "import sys\n\ndef main(argv):\n\tn, m = [int(x) for x in raw_input().split(' ')]\n\n\tday = min(n, m)\n\tfull = min(n, n + m * (m - 1) / 2)\n\n\tans = 0\n\twhile full > 0:\n\t\tans += 1\n\t\tk = ans + day\n\t\tfull = min(n, full + m)\n\t\tfull -= k\n\n\tprint day + ans\n\n\nif __name__ == '__main__':\n\tmain(sys.argv)"}, {"source_code": "from math import sqrt, floor\ns=input().split()\nn=int(s[0])\nm=int(s[1])\nr=(sqrt(1+8*(n-m))-1)/2\nk=floor(r)\nfor i in range(k-1,k+3):\n if i*(i+1)>=2*(n-m):\n x=i\n break\nprint(m+x)"}, {"source_code": "n,d=map(int,input().split())\nl=1\nr=int(1e18)\n\nwhile r-l > 1:\n m = l+(r-l)//2\n m1 = max(0, m-d)\n res = n - m1*(m1-1)//2 - m\n if res < 0:r = m\n elif res > 0:l = m\n else: \n r = m\n break\n\nprint(r)\n\n"}, {"source_code": "x = raw_input().split(' ')\nn = int(x[0])\nm = int(x[1])\n\nmini = 0\nmaxi = min(n, 3 * 10**9)\n\nwhile maxi > mini:\n\tmidi = (mini + maxi) / 2\n\t\n\ttestval = m + midi * (midi + 1) / 2\n\n\tif testval == n:\n\t\tmaxi = midi\n\t\tbreak\n\n\tif testval < n:\n\t\tmini = midi + 1\n\telse:\n\t\tmaxi = midi\n\n\nprint m + maxi"}, {"source_code": "import math\n\ns = input().split()\nn = int(s[0])\nm = int(s[1])\n\nif n <= m:\n print(n)\nelse:\n x = math.ceil((-1+math.sqrt(1+8*(n-m)))/2)\n print(m+x)\n"}, {"source_code": "import sys\nn, m = map(int, input().split())\nl=m-1 \nr=n+1\nans=0\nif n==1:\n\tans=1\nelse: \n\tif m<n:\n\t\twhile l<=r:\n\t\t\tmid=(l+r)/2\n\t\t\ti=mid\n\t\t\tx=(i-m-1)*m+n\n\t\t\ty=((i-m)*(i+m+1))/2 \n\t\t\tif y>=x :\n\t\t\t\tans=i\n\t\t\t\tr=i-1\n\t\t\telse :\n\t\t\t\tl=i+1\n\telse:\n\t\tans=n \nprint(int(ans))\n\t\t\n \t"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nSpyder Editor\n\nThis is a temporary script file.\n\"\"\"\n\nimport math\n\nn,m = input().split()\n\n#print(str(n)+str(m))\nn = int(n)\nm = int(m)\n\nans = min(n,m)\nn-=m\nn = max(n,0)\nx = -1\ny = int(math.sqrt(n))\n\ni = y - 10\nwhile(i<y+10):\n #print(i)\n if(i<=0):\n i+=1\n continue\n p = i\n q = i+1\n if(p%2):\n q//=2\n else:\n p//=2\n if(p*q<n):\n i+=1\n continue\n if(x==-1):\n x = i\n else:\n x = min(x,i)\n \n i+=1\n\nif (x==-1):\n x=0\nans +=x\nprint(ans)"}, {"source_code": "from math import ceil\nn, m = map(int, input().split())\nif n > m:\n print(m + int(ceil((n - m + 1) / 2)))\nelse:\n print(n)\n"}, {"source_code": "n, m = [int(i) for i in input().split()]\nl= m\nr = 10**18\nmid = -1\nwhile(r - l > 1) :\n mid = (l + r) // 2\n a = (mid - m) * (mid - m + 1) // 2 + m\n if (a < n) :\n l = mid\n else :\n r = mid\nprint(r)\n\n"}, {"source_code": "import decimal\n\nn,m=map(int,input().split())\n\nif(n<=m):\n print(n)\nelse:\n decimal.getcontext().rounding=decimal.ROUND_CEILING;\n print(decimal.MAX_PREC)\n decimal.getcontext().prec=1000;\n print(((decimal.Decimal(1+8*(n-m)).sqrt()-1)/2+m).to_integral_exact())"}, {"source_code": "n,m = map(int,input().split())\nx = m+1\nd=0\nfor i in range(10**5):\n if n-i<=x+(i*(i+1)//2):\n d=i\n break\nprint(x+d)"}, {"source_code": "import math\n\ncap, fill = map(int, input().split())\n\ncorn = cap\n\nif fill < cap:\n# d = fill\n#\n# while True:\n# corn -= d\n# if corn <= 0:\n# break\n# d += 1\n# corn += fill\n#\n# print(d)\n#\n# else:\n# print(cap)\n\n days = 0.5 * ((8 * cap + 1) ** 0.5 - 1)\n days = math.ceil(days)\n #print(days)\n print(days + 1)\n\nelse:\n print(cap)"}, {"source_code": "def cal(x):\n\tcnt = x\n\tcnt += ((x-m-1)*(x-m))/2\n\treturn n<=cnt\n\n\nl=map(int,raw_input().split(' '))\nn = l[0]\nm = l[1]\n\nif m>=n :\n\tprint n\nelse :\n\tlo = 0\n\thi=1000000000000000000\n\tret = 1\n\twhile lo<=hi :\n\t\tmid = lo + (hi-lo+1)/2\n\t\tif cal(mid):\n\t\t\tret = mid\n\t\t\thi = mid-1\n\t\telse :\n\t\t\tlo = mid+1\n\tprint ret\n"}, {"source_code": "__author__ = 'zihaozhu'\nfrom sys import stdin\nimport math\n\n\ncapacity,grain = map(int,stdin.readline().split())\ntotalcap = capacity+grain\n\nstartingday = grain+1\n\ndays=0\nstart = startingday\nlo = 0\nhi =int(2e9)\nans =0\ncapacity-=grain\nwhile lo<hi:\n mid = (lo+hi)//2\n #print(lo,hi)\n #print(\"mid\",mid)\n val = mid*(mid+1)/2\n #print(val)\n if val >= capacity:\n hi = mid\n ans = mid\n #print(\"is it true\")\n else:\n lo = mid +1\n\n#print(\"mid\",mid)\n\n\n# print(\"ans\",ans)\n# print(\"grain\",grain)\nprint(startingday+lo-1)"}, {"source_code": "def main():\n QWE = 'insert'\n INF = 10 ** 9 + 9\n EPS = 10 ** -10\n\n import sys, math, re\n #fi = open('input.txt', 'r')\n #fo = open('output.txt', 'w+')\n #fi = open(QWE +\".in\", \"r\")\n #fo = open(QWE + \".out\", \"w+\")\n #n, m, k = map(int, input().split(' ', 2))\n n, m = map(int, input().split(' ', 1))\n #n = int(input())\n #n, k = map(int, fi.readline().split(' ', 1))\n l, r, n = 0, INF * INF, n - m\n while l + 1 < r:\n mid = (l + r) // 2\n if (mid * (mid + 1) // 2 >= n):\n r = mid\n else:\n l = mid\n print(r + m)\n \n \nmain()\n"}, {"source_code": "import math\nn,m = map(int,raw_input().split())\n\n\n# m m+1 m+2 m+3\n#day = m # mth day: +m - m -1 -2 -3\n\n# m + 1 + 2 + 3 + ... + x >= n\n\n# m + x(x+1) / 2 >= n\n\n # x(x+1) >= 2 (n-m)\n\n\n\n# x^2 + x - 2(n-m) >= 0\n# x = 1/2 ( -1 + sqrt(1 + 8 (n-m)))\n\nif n > m:\n x = math.ceil((-1 + (1+8*(n-m))**0.5)/2)\n print min(int(x) + m , n)\nelse:\n print n\n\n\n"}, {"source_code": "n, m = map(int, input().split())\nif n <= m:\n print(n)\nelse:\n l = m - 1\n r = int(2e18)\n while r - l > 1:\n mid = (r + l) // 2\n if n - (mid - 1 - m) * (mid - m) / 2 <= mid:\n r = mid\n else:\n l = mid\n print(r)"}, {"source_code": "n, m = map(int, input().split())\n\ndef c(n):\n return (1 + n) * (n) // 2\n\ndef md(a, b):\n return (a + b) // 2\n\nif n <= m:\n print(n)\nelse:\n a = 0\n if n - m - 1 <= 0:\n print(m + 1)\n else:\n l = 0\n r = int(1e10)\n r - l >= 0\n nn = n - m - 1\n while r - l >= 1:\n # print([l, r, md(l, r)], c(md(l, r)), nn)\n if c(md(l, r)) < nn:\n l = md(l, r) + 1\n a = c(md(l, r))\n # print(\"a\", a)\n else:\n r = md(l, r) - 1\n print(min(l, r) + m + 1)\n"}, {"source_code": "n,m = map(int,raw_input().split())\ndef check(a):\n\treturn (1+a)*a < n*2\nans = m\nn = n - m\nl = 0\nr = 100010000000\nwhile l < r:\n\tmid = (l+r)/2\n\tif(check(mid)):\n\t\tl = mid + 1\n\telse:\n\t\tr = mid\nl = l + check(l)\nprint ans + l\n"}, {"source_code": "import math\nn, m = map(int, input().split())\nif n > m:\n print(math.ceil(-0.5 + (2*(n - m))**(0.5)) + m)\nelse:\n print(n)\n"}, {"source_code": "n, m = map(int, input().split())\n\nk = 0\nl = 0\nr = n\nfor i in range(200):\n k = l + (r - l) // 2\n res = ((2 * m + k + 1) * k) // 2 - m * (k - 1)\n if res - k < n and res >= n:\n break\n elif res - k > n:\n r = k\n else:\n l = k\n\nif m + k > n:\n print(n)\nelse:\n print(m + k)\n\n"}, {"source_code": "from math import ceil, sqrt\n\nn, m = [int(i) for i in input().split()]\n\nif m >= n:\n print(n)\n\n\nelse :\n just = -1 + sqrt(1 + 8 * (n - m))\n just /= 2\n just = ceil(just)\n print(m + just)"}, {"source_code": "import math\nn,m=map(int,input().split())\nif(m>=n):\n print(n)\nelse:\n temp=min(n,m)\n a=temp+1\n res=temp\n start=0\n end=2*(10**9)\n while(start<=end):\n mid=(start+end)//2\n if(int((mid)*(2*a+mid-1)/2)>n+(mid-1)*m):\n end=mid-1\n elif(int((mid)*(2*a+mid-1)/2)<n+(mid-1)*m):\n start=mid+1\n else:\n start=mid\n break\n print(start+res)\n #res+=(1+2*m-2*a+math.sqrt((1+2*m-2*a)**2+8*(n-m)))/2\n #print(math.ceil(res))\n"}], "src_uid": "3b585ea852ffc41034ef6804b6aebbd8"} {"source_code": "a, b = raw_input().split()\n\nif a == b: print a\nelse: print '1'", "positive_code": [{"source_code": "a,b=map(int,raw_input().split())\nprint a if a==b else 1 if a<b else gcd(a,b)"}, {"source_code": "a, b = raw_input().split(' ')\n\nif a == b:\n print a\nelse:\n print 1"}, {"source_code": "from fractions import gcd\n\ninp = raw_input()\n\narr = inp.split(' ')\n\nn1 = int(arr[0])\nn2 = int(arr[1])\n\nans = n1\n\n# for x in range(n1,n1+1):\n# \tans = gcd(ans,x)\n# \tpass\n\n# print arr[0],\"\\n\\n\",arr[1],\"\\n\\n\"\nif n1 == n2:\n\tprint n1\nelse:\n\tprint 1"}, {"source_code": "def gcd(a,b):\n\tif a==b:\n\t\tprint(str(a))\n\telse:\n\t\tprint(1)\n\na,b = map(int,input().split(\" \"))\n\ngcd(a,b)"}, {"source_code": "a, b = map(int, raw_input().split())\nprint a == b and a or 1\n"}, {"source_code": "a, b = map(int, input().split())\n\nif a == b:\n print(\"{}\".format(a))\nelse:\n print(\"{}\".format(1))\n"}, {"source_code": "def main():\n from sys import stdin, stdout\n \n a,b = map(int, raw_input().split())\n if a == b:\n stdout.write(str(a))\n else:\n stdout.write(str(1))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def gcd(a, b):\n if(a == b):\n return a\n else:\n return 1\ndef main():\n var1, var2 = [int(x) for x in raw_input().split()]\n print(gcd(var1,var2))\nmain()\n"}, {"source_code": "from fractions import gcd\na,b = map(int,raw_input().split(' '))\nif a == b:\n print a\nelse:\n print 1"}, {"source_code": "import math\nx, y=map(int, input().split())\nif x==y:\n print(x)\nelse:\n print(\"1\")\n"}, {"source_code": "#Complicated GCD\nfrom math import gcd\na,b = map(int,input().split())\nli = []\nif b-a >=50:\n ans = 1\nelse:\n for i in range(a,b+1):\n li.append(i)\n if len(li)==1:\n ans = li[0]\n else:\n for i in range(len(li)-1):\n ans = gcd(li[i],li[i+1])\n if ans == 1:\n break\nprint(ans)"}, {"source_code": "a , b = map(int, raw_input().split())\nif a == b: print a\nelse: print 1"}, {"source_code": "a,b=raw_input().split()\nif a != b:\n print 1\nelse:\n print a"}, {"source_code": "def gcd(a, b):\n if a % b == 0: return b\n return gcd(b, a%b)\n\na, b = map(lambda x: int(x), raw_input().split())\nprint a if a == b else \"1\""}, {"source_code": "number = map(int,raw_input().split())\n\n\nif number[0] == number[1] :\n print number[0]\nelse:\n print 1"}, {"source_code": "x=raw_input().split()\na=int(x[0])\nb=int(x[1])\nif a==b:\n print a\nelse:\n print 1"}, {"source_code": "number = map(int,raw_input().split())\n\nif number[0] == number[1] :\n print number[0]\nelse:\n print 1"}, {"source_code": "m,n = map(int, raw_input().split())\nif m==n:\n print m\nelse:\n print 1"}, {"source_code": "a=input().split()\na=[int(i) for i in a]\nif(a[0]==a[1]):\n print(a[0])\n quit()\nif(max(a)-min(a)>30):\n print(1)\n quit()\na=[i for i in range(a[0],a[1]+1)]\nimport fractions\n\ndef rec(a):\n if(len(a)==1):\n #print(a[0])\n return a[0]\n else:\n q=a[0]\n g=a[1]\n a.remove(g)\n a[0]=fractions.gcd(q,g)\n #print(q,g,a[0])\n return rec(a)\nprint(rec(a))\n"}, {"source_code": "a,b=map(int,raw_input().split())\nprint [1,a][a==b]\n"}, {"source_code": "def getGCD(a, b):\n if b == 0: return a\n return getGCD(b, a%b)\n \n\ndef solve(a, b):\n if a == b: return a\n return 1\n \n \nA, B = [int(i) for i in input().split()]\nprint(solve(A, B))"}, {"source_code": "x, y = map(int,input().split(' ')); \nif (x==y):print(x) \nelse: print(1)"}, {"source_code": "if __name__ == '__main__':\n a, b = raw_input().split()\n\n print a if a == b else 1\n"}, {"source_code": "#In the name of God\n\na,b = map(int, raw_input().split())\n\nif a == b:\n print a\nelse:\n print 1\n"}, {"source_code": "a,b=map(int,input().split(\" \"))\nif a==b:\n print(a)\nelse:\n print(1)"}, {"source_code": "a,b = [int(x) for x in raw_input().split()]\nprint a if a == b else 1"}, {"source_code": "num = map(int, raw_input().split(' '))\nnum1, num2 = num[0], num[1]\nresto = num1 % num2\nif num2 - num1 >= 1:\n print 1\nelse:\n while (resto != 0):\n num1 = num2\n num2 = resto\n resto = num1 % num2\n print num2"}, {"source_code": "num = map(int, raw_input().split(' '))\nnum1, num2 = num[0], num[1]\nresto = num1 % num2\nif num2 - num1 < 1:\n while (resto != 0):\n num1 = num2\n num2 = resto\n resto = num1 % num2\n print num2\n \nelse:\n print 1"}, {"source_code": "a, b = list(map(str, input().split()))\n\nif a == b:\n print(a)\nelse:\n print(1)"}, {"source_code": "a,b = map(int,input().split())\n\nif a == b:\n print(a)\nelse:\n print(1)"}, {"source_code": "#print(\"muri\")\na, b = map(str, input().split())\nif a==b:print(a)\nelse: print(\"1\")"}, {"source_code": "#print(\"muri\")\na, b = map(int, input().split())\nif a==b:print(a)\nelse: print(\"1\")"}, {"source_code": "[a1,b1]=[int(x) for x in input().split(' ')]\n\nif max(a1,b1) - min(a1,b1)> 0:\n print(1)\nelse:\n print(min(a1,b1))"}, {"source_code": "import math\n\na, b = map(int, input().split())\nr = a\nfor i in range(a+1, b+1):\n if r == 1:\n break\n r = math.gcd(r, i)\nprint(r)\n"}, {"source_code": "# coding: utf-8\n\n\ndef mdc(a, b):\n\t \n\tif a == b:\n\t\treturn a\n\t\n\telse:\n\t\treturn 1\n\t\n\t\nent = raw_input().split()\n\n\n\nprint mdc(int(ent[0]), int(ent[1]))\n\t\n"}, {"source_code": "s = input();\na,b = s.split();\na=int(a);\nb=int(b);\ndef gcd(a,b) :\n if a%b==0 :\n return b;\n elif b%a==0 :\n return a;\n elif a>b :\n return gcd(a%b,b);\n elif a<b :\n return gcd(b%a,a);\nans=a;\nfor i in range(a+1,b+1) :\n ans = gcd(ans,i);\n if ans==1 :\n break;\nprint(int(ans));"}, {"source_code": "a, b = input().split()\n\nif a == b:\n print(a)\nelse:\n print(1)\n"}, {"source_code": "string = input()\na, b = map(int, string.split())\nn = a\nfor x in range(a + 1, b + 1):\n a, b = x, n\n while a != 0 and b != 0:\n a %= b\n if a == 0:\n break\n b %= a\n if a == 0:\n n = b\n else:\n n = a\n if n == 1:\n break\nprint(n)"}, {"source_code": "import fractions\n\na, b = map(int, raw_input().split())\nif a == b:\n print a\nelse:\n print 1\n"}, {"source_code": "def mdc(n1,n2):\n\tif n2 == 0:\n\t\treturn n1\n\treturn mdc(n2,n1%n2)\n\n\na,b = map(int,input().split())\nif a >= b:\n\tprint(mdc(a,b))\nelse:\n\tprint(\"1\")"}, {"source_code": "a, b = [i for i in input().split()]\n\nif a==b:\n print(a)\nelse:\n print(1)"}, {"source_code": "x,y = map(int,input().split())\n\nif x != y:\n print(1)\nelse:\n print(x)"}, {"source_code": "a,b=map(int,input().split())\nif(a==b):\n print(a)\nelse:\n print(1)"}, {"source_code": "a, b=map(int, input().rstrip().split())\nif a==b:\n print(a)\nelse:\n print(1)"}, {"source_code": "a,b = list(map(int, input().strip().split(' ')))\nmmin=a\n\nif a==b :\n\tprint(a)\nelse :\n\tprint(1)\n"}, {"source_code": "a,b=map(int,input().split())\nif a==b:\n print(a)\nelse:\n print(1)"}, {"source_code": "n,m = input().split()\nif n == m:\n print(n)\nelse:\n print(1)"}, {"source_code": "a, b = list(map(int, input().split()))\nif a == b: print(a)\nelse: print(\"1\")"}, {"source_code": "'''input\n61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576\n\n'''\nfrom collections import deque, defaultdict\n\ndef solve():\n\tx, y = input().split()\n\tif x == y:\n\t\tprint(x)\n\telse:\n\t\tprint(1)\n\ndef main():\n\tt = 1\n\t#t = int(input())\n\tfor _ in range(t):\n\t\tsolve()\nmain()"}, {"source_code": "a, b = input().split()\nprint(1 if a != b else a)"}, {"source_code": "'__author__'=='deepak Singh Mehta(learning to code :) ) '\n \n'''\n Hard work beats Talent when Talent doesn't work hard. :)\n'''\n\n\n\nif __name__=='__main__':\n a,b = map(int,input().split())\n if a==b:\n print(a)\n else:\n print(1)\n"}, {"source_code": "a,b=map(int,input().split())\nprint(1 if abs(a-b)!=0 else a)"}, {"source_code": "import math\na, b = map(int,input().split())\nif a == b:\n\tprint(a)\nelse:\n\tprint(1)"}, {"source_code": "a , b = map(int,input().split())\n\nif a == b :\n print(a)\n\nelse:\n print(1)\n"}, {"source_code": "from sys import stdin,stdout\ninput=lambda:stdin.readline().strip()\na,b=input().split()\nif a==b:\n print(a)\nelse:\n print(1)\n"}, {"source_code": "a, b=map(str, input().split())\nif a==b:print(b)\nelse:print(\"1\")"}, {"source_code": "from math import gcd\n\na, b = map(int, input().split())\n\nnod = gcd(a, b)\nfor i in range(a+1, b):\n nod = gcd(i,nod)\n if nod ==1:\n break\n\nprint(nod) "}, {"source_code": "a, b = map(int, input().split())\nif a == b:\n print(a)\nelse:\n print(1)\n"}, {"source_code": "a, b = [int(x) for x in input().split()]\nif a == b:\n print(a)\nelse:\n print(1)\n"}, {"source_code": "inp = input().split(\" \")\na=inp[0]\nb=inp[1]\nif(a==b):\n print (a)\nelse:\n print (1)"}, {"source_code": "\na,b=[int(i) for i in input().split()]\nif a==b:print(a)\nelse:print(1)\n"}, {"source_code": "s,z = map(int,input().split())\nif s != z: print(1)\nelse: print(s)"}, {"source_code": "def solution(l1):\n if l1[0]==l1[1]:\n return l1[0]\n else:\n return 1\ndef answer():\n l1 = [int(x) for x in input().split()]\n print(solution(l1))\nanswer()"}, {"source_code": "\na,b=input().split()\nif a==b:\n print(a)\nelse:\n print(1);"}, {"source_code": "import math\n\nn = input()\nn = n.split()\ns = eval(n[0])\nn = eval(n[1])\n\nif n == s:\n print(n)\n\nelse:\n print(1)\n"}, {"source_code": "a=raw_input()\na=a.split(' ')\nb=int(a[1])\na=int(a[0])\nif a==b or b%a==0 :\n if a==b or a+1==b:\n print a\n else:\n print 1\nelif a<b:\n print 1\n"}, {"source_code": "a, b = map(int, raw_input('').split(\" \"))\n\nif a == b:\n\tprint a\nelse:\n\tprint 1"}, {"source_code": "inputa = input();\nlinputa = inputa.split();\na = int(linputa[0]);\nb = int(linputa[1]);\nif(a-b):\n print(1);\nelse:\n print(a);"}, {"source_code": "S = raw_input()\nK= S.split(' ')\nx = int(K[0])\ny = int(K[1])\n\nif x==y:\n print x\nelse:\n print '1'\n \n"}, {"source_code": "a=raw_input().split()\nif a[0]==a[1]:\n\tprint a[0]\nelse:\n\tprint 1"}, {"source_code": "import os\n\nxlist = raw_input().split()\nif xlist[0] == xlist[1]:\n\tprint xlist[0]\nelse:\n\tprint '1'"}, {"source_code": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\ns=raw_input()\na,b=s.split(' ')\na=int(a)\nb=int(b)\nif a==b:\n print a\nelse:\n m=gcd(a,a+1)\n i=a+2\n while(i<=b):\n if m==1: break\n m=gcd(m,i)\n i+=1\n print m\n"}, {"source_code": "a,b=map(int,raw_input().split(' '))\nif a==b:\n print a\nelse:\n print \"1\""}, {"source_code": "a, b = map(int,raw_input().split())\nprint a if (a==b) else 1"}, {"source_code": "# -*- coding:utf-8 -*-\nimport fractions\na,b=map(int,raw_input().split(' '))\nprint 1 if a!=b else b"}, {"source_code": "hello = raw_input().split()\nfirst = int(hello[0])\nsecond = int(hello[1])\nif first == second:\n\tprint first\nelse:\n\tprint 1"}, {"source_code": "x, y = raw_input().split()\nif x == y:\n\tprint x\nelse:\n\tprint 1"}, {"source_code": "num1, num2 = raw_input().split()\nif num1 == num2:\n print num1\nelse:\n print 1"}, {"source_code": "import sys\n\n(a, b) = tuple(long(i) for i in sys.stdin.readline().strip().split())\n\nif a == b:\n print a\nelse:\n print 1"}, {"source_code": "a, b = map(int, raw_input().split())\n\nif a != b: print 1\nelse: print a\n"}, {"source_code": "a, b = map(int, raw_input().split())\nif a != b:\n\tprint 1\nelse:\n\tprint a\n\t#rs"}, {"source_code": "numbers = list(map(int,input().split()))\n\nif (numbers[0] == numbers[1]):\n print(numbers[0])\nelse:\n print(1)\n"}, {"source_code": "a,b = map(int,input().split())\n\nif abs(a-b)>0:\n print(1)\nelse:\n print(a)\n "}, {"source_code": "#encoding: utf-8\n\nn2 = map(int, raw_input().split())\nif (n2[0] == n2[1]):\n\tprint n2[0]\nelse:\n\tprint 1\n"}, {"source_code": "#-*- encoding: utf-8 -*-\nimport sys\na, b = map(long, sys.stdin.readline().split());\nif a == b:\n print a\nelse:\n print 1\n"}, {"source_code": "a,b=map(int,raw_input().split())\nif(a==b):\n print(a)\nelse:\n print(1)"}], "negative_code": [{"source_code": "def gcd(a,b):\n\tif b==0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b,a%b)\n\na,b = map(int,input().split(\" \"))\n\nprint(str(gcd(a,b)))"}, {"source_code": "def gcd(a,b):\n\tif b==0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b,a%b)\n\na,b = map(int,input().split(\" \"))\n\nprint(str(gcd(a,b)))"}, {"source_code": "\n\na , b = map(int , input().split())\n\nif a == 1 or b == 1:\n print(1)\nelif a == b:\n print(a)"}, {"source_code": "import math\na,b=map(int,input().split())\nans = 1\nfor i in range(a, b):\n ans = max(ans, math.gcd(i,b))\n if ans == 1:\n break\nprint(ans)"}, {"source_code": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n \na,b=map(int,raw_input().split())\nl=[a,b]\nprint gcd(max(l),min(l))\n"}, {"source_code": "a, b = [int(n) for n in input().split()]\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nprint(gcd(a, b))\n"}, {"source_code": "inp = input().split()\na,b = int(inp[0]), int(inp[1])\n\nwhile b!=0:\n\tt = b\n\tb = a%b\n\ta = t\nprint(a)"}, {"source_code": "# your code goes here\na,b = input().split()\n\na = int(a)\nb = int(b)\n\ndef gcd(a,b):\n\tif b==0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b, a%b)\n\t\t\n\t\t\nval = gcd(a,b)\nprint(val)"}, {"source_code": "#never give up\nx,y=map(int,input().split())\nwhile(x!=y):\n if x>y:\n x-=y;\n else:\n y-=x;\nprint(x)"}, {"source_code": "n,m=map(int,input().split())\ndef NOD(a,b) :\n while a!=0 and b!=0 :\n if a>b :\n a=a%b\n else :\n b=b%a\n return a+b\nma=0\nfor i in range(n,m+1) :\n ma=max(ma,NOD(i,m))\nprint(ma)\n"}, {"source_code": "# cook your code here\ndef gcd(a,b):\n if(b==0):\n return a;\n else:\n return gcd(b,a%b);\nnumbers = map(int,raw_input().split())\nif(numbers[0]>numbers[1]):\t\t\t\t\n\t\tmyval=gcd(numbers[0],numbers[1]);\nelse:\n\t\tmyval=gcd(numbers[1],numbers[0]);\t\nprint(myval);"}, {"source_code": "from fractions import*\nnum1, num2 = map(long, raw_input().split())\nprint gcd(num1, num2)\n"}, {"source_code": "n,m=map(int,input().split())\ni=m\nwhile n*m:\n n%=m\n i=m\n m=n\n n=i\nprint(n)\n"}, {"source_code": "a,b = list(map(int, input().strip().split(' ')))\nwhile b!=0 :\n\ttmp=a;\n\ta=b;\n\tb=tmp%b;\nprint(a)\n"}, {"source_code": "\"\"\"\nfrom math import*\nx = [True] * 1000100\nx[1] = False\nx[0] = False\nfor i in range(2, 1100):\n\tfor j in range(2*i, len(x), i):\n\t\tx[j] = False\nn = int(input())\na = map(int,input().split())\nans = []\nfor i in a:\n\tg = sqrt(i)\n\tif round(g) ** 2 != i:\n\t\tg = 100\n\tif x[int(g)] == True :\t\n\t\tans.append(\"YES\")\n\tans.append(\"NO\")\nprint('\\n'.join(ans))\n\"\"\"\n\"\"\"\ns1= input()\ns2 = input()\nglassn1 = 0\nsoglas1 = 0\nglassn2 =0 \nsoglas2=0\nbulka = 0\nif s1 == \"abcdef\" and s2 == \"cdaebf\":\n\tprint(\"No\")\n\texit()\nif s2 == s1[::-1] or s2[::-1] == s1:\n\tprint(\"No\")\n\texit()\nif len(s1) == len(s2):\n\tfor i in range(len(s1)):\n\t\tif s1[i] in s2:\n\t\t\t\tbulka += 1\n\tif bulka == len(s1) or bulka == len(s2):\n\t\tprint(\"No\")\n\t\texit()\nfor i in s1:\n\tif i == \"a\" or i == \"e\" or i == \"i\" or i == \"o\" or i == \"u\":\n\t\tglassn1 +=1\n\telse:\n\t\tsoglas1+=1\nfor i in s2:\t\n\tif i == \"a\" or i == \"e\" or i == \"i\" or i == \"o\" or i == \"u\":\n\t\tglassn2 +=1\n\telse:\n\t\tsoglas2+=1\nif glassn1 == glassn2 and soglas1 == soglas2:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n\"\"\"\t\n\"\"\"\ns1 = input()\ns2 = input()\nglassn1 = \"aeiou\"\nif len(s1) != len(s2):\n print(\"No\")\nelse:\n for i in range(len(s1)):n = int()\n kek = s1[i] in glassn1 \n lol = s2[i] in glassn1\n if kek != lol:\n print(\"No\")\n exit() \n else:\n print(\"Yes\")\n\"\"\"\n\n\n\n\n\"\"\"\nc,n,f = map(int,input().split())\ncows = [\"*\"]*c\nkeks = []\nind = 0\na = list(map(int,input().split()))\nfor i in range(f):\n\tp1,p2 = map(int,input().split())\n\tcows[p2-1] = p1\n\tfor i in a:\n\t\tif i != p1:\n\t\t\tkeks.append(i)\n\t\t\tbreak\n\tfor i in range(len(keks)):\n\t\tcows[cows.index(p1)-1] = keks[i]\nprint(cows.index(\"*\")+1,cows)\n\"\"\"\n\"\"\"\n\n\n#Spichechnaya model\nn = int(input())\nkubik = 8\nfkub = 12\nfor i in range(n-1):\n\tfkub += kubik\nprint(fkub)\t\t\n\n\n\"\"\"\n\n\"\"\"\n#Dve okruznosti\nx1,y1,r1,x2,y2,r2 = map(int,input().split())\nif x1 == x2 and y1 == y2:\n\tprint(-1)\nelif x1 == x2 and y1 != y2:\n\tprint(1)\nelse:\n\tprint(2)\n\"\"\"\n\"\"\"\n#Dva mnojitelya \nn = int(input())\nkek = []\nfor i in range(1,51+1):\n\tfor j in range(i,51+1):\n\t\tkek.append(i*j)\nprint(kek[n])\n\"\"\"\n\"\"\"\n#delitsya na 4 or 8 or 2?\nn = int(input())\nif n % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\nif n%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")\nif n % 8 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\"\"\"\n\"\"\"\nn = int(input())\npolice = 0\nans = 0\na = list(map(int,input().split()))\nfor i in range(n):\n\t\tif a[i]<0 and police != 0:\n\t\t\tpolice -= 1\n\t\telif a[i] < 0 and police == 0:\n\t\t\tans += 1\n\t\telif a[i]>0:\n\t\t\tpolice+=a[i]\t\t\t\nprint(ans)\n\"\"\"\n\"\"\"\n#kek\nn = int(input())\nans = 0\nfor i in range(n):\n\ta,b,c = map(int,input().split())\n\tif c % 2 == 0:\n\t\tprint((c//2) * a - (c//2) * b)\n\telse:\n\t\tprint((c//2+1)*a - (c//2*b))\n\"\"\"\n\"\"\"\nn = int(input())\nmx=[[]]\nfor i in range(n):\n\tmx[i] = list(map(int,input().split()))\nkek = 0\nfor i in range(n):\n kek += mx[i][i]\n kek += mx[i][n-i-1]\n kek += mx[n//2][i]\n kek += mx[i][n//2]\nkek -= 3*mx[n//2][n//2]\nprint(kek)\n\"\"\"\n\"\"\"\nn = int(input())\nfor i in range(n):\n\tm = int(input())\n\tif m % 4 == 1:\n\t\tprint(\"ALICE\")\n\telse:\n\t\tprint(\"BOB\")\n\"\"\"\n\"\"\"\nn = int(input())\nlst = []\nfor i in range(n):\n\tf = input()\n\ts = input()\n\tt = input()\n\tif f[0] == \"l\" and s[0] == \"l\" and t[0] == \"l\" and t[1] == \"l\" or f[0] == \"l\" and s[0] == \"l\" and t[0] == \"l\" and t[1] == \"l\" and t[2] == \"l\" or f[0] == \"l\" and s[0] == \"l\" and s[1]==\"l\" or f[0] == \"l\" and s[0] == \"l\" and s[1]==\"l\" and s[2]==\"l\" or f[1]==\"l\" and s[1] == \"l\" and s[2] ==\"l\" or f[1]==\"l\" and s[1] == \"l\" and t[1] == \"l\" and t[2] == \"l\" or s[1] == \"l\" and t[1]==\"l\" and t[2] == \"l\" or s[0] == \"l\" and t[0] ==\"l\" and t[1] == \"l\" or s[0] == \"l\" and t[0] ==\"l\" and t[1] == \"l\" and t[2] == \"l\":\n\t\tlst.append(\"yes\")\n\telse:\n\t\tlst.append(\"no\")\nfor i in lst:\n\tprint(i)\n\"\"\"\n\"\"\"\nn = int(input())\nunbinar = \"\"\nbinar = []\nfor i in range(n):\n\ta,b=map(int,input().split())\n\tfor i in range(a,b+1):\n\t\tbinar.append(str(bin(i))[2:])\nfor i in range(len(binar)):\t\n\tif int(binar[i]) == 0 and int(binar[i-1]) == 0:\n\t\t\tunbinar+= \"0\"\n\telse:\n\t\t\tunbinar+=\"1\"\nprint(unbinar) \n\"\"\"\n\"\"\"\nfrom math import*\nnum,base = map(int,input().split())\nzeros = 0\nfnum = factorial(num)\nif base < 2 or base > 10**18:\n\texit()\nnewNum = ''\nwhile fnum > 0:\n newNum = str(fnum % base) + newNum\n fnum //= base\nrev = newNum[::-1]\ni = 0;\nwhile 1:\n\tif rev[i] == \"0\":\n\t\tzeros+=1\n\telse:\n\t\tbreak\n\ti += 1\nprint(zeros)\n\n\"\"\"\n\"\"\"\nn = int(input())\nlol = []\nkek = n\nif n > 0:\n\tprint(n)\nelif len(str(n)) == 3 and n < 0:\n\tprint(str(n)[2])\n\"\"\"\n\"\"\"\nc,n,f = map(int,input().split())\ncows = [\"*\"]*c\nkeks = []\nind = 0\na = list(map(int,input().split()))\nfor i in range(f):\n\tp1,p2 = map(int,input().split())\n\tcows[p2-1] = p1\n\tfor i in a:\n\t\tif i != p1:\n\t\t\tkeks.append(i)\n\t\t\tbreak\n\tfor i in range(len(keks)):\n\t\tcows[cows.index(p1)-1] = keks[i]\nprint(cows.index(\"*\")+1,cows)\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\ntetr = list(map(int,input().split()))\nper = []\nfor i in range(a):\n\tif tetr[i] < b:\n\t\tfor i in range(tetr[i]):\n\t\t\tper.append(i)\n\t\t\tprint(per)\n\"\"\"\n\"\"\"\na,b = map(int,input().split())\ni = 1 \nwhile a != 0 or b != 0:\n\ta -= i\n\ti+=1\n\tb-=i\n\tif a == 0:\n\t\tprint(\"Valera\")\n\t\tbreak\n\telse:\n\t\tprint(\"Vladik\") \n\t\tbreak\n\"\"\"\na,b = map(int,input().split())\nif b % a == 0 and a != b:\n\tprint (1)\nelse:\n\tprint(min(a,b))\n"}, {"source_code": "a, b = map(int, input().split())\nimport math\n\nprint(math.gcd(a, b))\n"}, {"source_code": "def gcd(a, b):\n while a != b:\n if a > b:\n a -= b\n else:\n b -= a\n return a\ndef main():\n var1, var2 = [int(x) for x in raw_input().split()]\n print(gcd(var1,var2))\nmain()\n"}, {"source_code": "n,m=map(int,input().split())\ndef NOD(a,b) :\n while a!=0 and b!=0 :\n if a>b :\n a=a%b\n else :\n b=b%a\n return a+b\nprint(NOD(n,m))\n"}, {"source_code": "#Complicated GCD\nfrom math import gcd\na,b = map(int,input().split())\nli = []\nif b-a >=50:\n ans = 1\nelse:\n for i in range(a,b+1):\n li.append(i)\n if len(li)==1:\n ans = li[0]\n else:\n for i in range(len(li)-1):\n ans = gcd(li[i],li[i+1])\n print(ans)\n if ans == 1:\n break\nprint(ans)"}, {"source_code": "#coding: utf-8\nentrada1 = list(map(int,raw_input().split()))\n\n\ndef mdc(a, b):\n while(a % b != 0):\n aux = b\n b = a % b\n a = aux\n return b\n\nresult = mdc(entrada1[0], entrada1[1])\nprint result"}, {"source_code": "#como cigarras periodicas sqn\n\ndef gcd(a,b):\n if(a == 0): return b\n if(b == 0): return a\n return gcd(b,a%b)\n\n#def cigarra():\n \n \na,b = [int(i) for i in input().split()]\n\nprint(gcd(a,b))\n"}, {"source_code": "from math import gcd\nx,y = map(int, input().split())\nprint (gcd(x,y))\n"}, {"source_code": "a,b = list(map(int, input().split()))\nif a==b:\n\tprint(a)\nelif b-a==1:\n\tprint(1)\nelse:\n\tprint(2)"}, {"source_code": "a, b = map(int, raw_input().split())\n# gcd(a, b) = gcd(b, a % b)\nwhile b > 0:\n a, b = b, a % b\nprint a\n"}, {"source_code": "hello = raw_input().split()\nfirst = int(hello[0])\nsecond = int(hello[1])\nif first < second:\n\tc = first\n\tfirst = second\n\tsecond = c\nwhile second >= 1:\n\tc = first % second\n\tfirst = second\n\tsecond = c\nprint first,'\\n'"}, {"source_code": "from fractions import gcd\na, b = map(int, input().split(' '))\nprint(gcd(a, b))"}, {"source_code": "import sys\n\ndef euclid(a, b):\n\tif b > a:\n\t\ttemp = a\n\t\ta = b\n\t\tb = temp\n\tassert a >= b\n\tr = a % b\n\tif r == 0:\n\t\treturn b\n\telse:\n\t\treturn euclid(b, r)\n\n(a, b) = tuple(long(i) for i in sys.stdin.readline().strip().split())\nprint euclid(a, b)\n"}, {"source_code": "import fractions\na, b = raw_input().split(' ')\na, b = long(a), long(b)\nprint fractions.gcd(a, b)"}, {"source_code": "a,b=map(int,input().split())\ni=min(a,b)\nwhile i>=0:\n if a%i==0 and b%i==0:\n print(i)\n break\n i=i-1"}, {"source_code": "def gcd(u, v):\n if (u == v):\n return u\n\n if (u == 0):\n return v\n\n if (v == 0):\n return u\n\n if (~u & 1):\n if (v & 1):\n return gcd(u >> 1, v)\n else:\n return gcd(u >> 1, v >> 1) << 1\n\n if (~v & 1):\n return gcd(u, v >> 1);\n\n if (u > v):\n return gcd((u - v) >> 1, v)\n\n return gcd((v - u) >> 1, u)\n\na, b = map(int, input().split(' '))\nprint(gcd(a, b))"}, {"source_code": "n,m=map(int,input().split())\ni=m\nwhile n*m:\n n%=m\n i=m\n m=n\n n=i\nprint(n)\n"}, {"source_code": "\np =raw_input()\n\nprint 1\n"}, {"source_code": "linha = map(int, raw_input().split())\nwhile True:\n if linha[1] == 0:\n break\n linha.sort()\n linha[1] = linha[1] % linha[0]\n\nprint linha[0]\n"}, {"source_code": "#coding: utf-8\nentrada1 = list(map(int,raw_input().split()))\n\n\ndef mdc(a, b):\n while(a % b != 0):\n aux = b\n b = a % b\n a = aux\n return b\n\nresult = mdc(entrada1[0], entrada1[1])\nprint result"}, {"source_code": "def gcd(a, b):\n while b > 0:\n a, b = b, a % b\n return a\n\na, b = map(int, raw_input().split())\nprint a if a == b else gcd(a, b)\n"}, {"source_code": "def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b);\ndef main():\n var1, var2 = [long(x) for x in raw_input().split()]\n print(gcd(var1,var2))\nmain()\n"}, {"source_code": "\n\na , b = map(int , input().split())\n\nif a == 1 or b == 1:\n print(1)\nelif a == b:\n print(a)"}, {"source_code": "import math\na,b=map(int,input().split())\nans = 1\nfor i in range(a, b):\n ans = max(ans, math.gcd(i,b))\n if ans == 1:\n break\nprint(ans)"}, {"source_code": "def gcd(a, b):\n if a % b != 0:\n return gcd(b, a % b)\n return b\n\nif __name__ == '__main__':\n a, b = [int(i) for i in input().split()]\n print(gcd(a, b))\n"}, {"source_code": "inp = input()\na=inp[0]\nb=inp[1]\nif(a==b):\n print (a)\nelse:\n print (1)"}, {"source_code": "n,m=map(int,input().split())\ni=0\nwhile n*m:\n n%=m\n i=m\n m=n\n n=i\nprint(n)\n"}, {"source_code": "a,b = map(int, raw_input().split())\n\nif a != b:\n print 1\nelse:\n print 0\n"}, {"source_code": "import sys\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\na,b = map(int,input().split())\nprint(gcd(a,b))"}, {"source_code": "import sys\ndef gcd(a, b):\n if a%b == 0:\n return b\n return gcd(b, a%b)\na,b = map(int,input().split())\nprint(gcd(a,b))"}, {"source_code": "# -*- coding:utf-8 -*-\n#[n, m] = [int(x) for x in raw_input().split()]\n\n\ndef some_func():\n \"\"\"\n \"\"\"\n a, b= [int(x) for x in raw_input().split()]\n print a\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n\n"}, {"source_code": "def gcd(a, b):\n if b==0:\n return a\n a, b = b, a%b\n return gcd(a, b)\n\na,b = [int(x) for x in input().split()]\n\nif a<b:\n a,b = b,a\n \nprint(gcd(a,b))"}, {"source_code": "import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\ndd=[(-1,0),(0,1),(1,0),(0,-1)]\nddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\n# def LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return input()\n\n# GCD -- START --\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n# GCD --- END ---\n\ndef main():\n n,m=LI()\n return gcd(n,m)\n\n# main()\nprint(main())\n"}, {"source_code": "from fractions import gcd\n\ninp = raw_input()\n\narr = inp.split(' ')\n\nn1 = int(arr[0])\nn2 = int(arr[1])\n\nans = n1\n\n# for x in range(n1,n1+1):\n# \tans = gcd(ans,x)\n# \tpass\n\n# print arr[0],\"\\n\\n\",arr[1],\"\\n\\n\"\n\nprint 1"}, {"source_code": "a,b=map(int,input().split())\nwhile a!=b:\n if a>b: a-=b\n else : b-=a\nprint(a)"}, {"source_code": "a,b=map(int,input().split())\nprint(a)\n"}, {"source_code": "def GCD(n,m):\n if m==0:\n return n\n else:\n return GCD(m,n%m)\na,b = map (int,raw_input().split())\nprint GCD (a,b)\n"}, {"source_code": "import fractions\n\ndef gcd(*values):\n return reduce(fractions.gcd, values)\na,b=raw_input().split()\na=int(a)\nb=int(b)\nans=b\n\nprint gcd(range(a,b+1))[0]\n"}, {"source_code": "# cook your code here\ndef gcd(a,b):\n if(b==0):\n return a;\n else:\n return gcd(b,a%b);\nnumbers = map(int,raw_input().split())\nif(numbers[0]>numbers[1]):\t\t\t\t\n\t\tmyval=gcd(numbers[0],numbers[1]);\nelse:\n\t\tmyval=gcd(numbers[1],numbers[0]);\t\nprint(myval);"}, {"source_code": "a, b = (int(n) for n in raw_input().split())\nif a == b:\n print a\nelse:\n print b"}, {"source_code": "def gcd(a,b):\n if b > a:\n return gcd(b,a)\n r = a%b\n if r == 0:\n return b\n return gcd(r,b)\na, b= [int(i) for i in input().split()]\nprint(gcd(a,b))"}, {"source_code": "print(min(map(int,input().split())))"}, {"source_code": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n \na,b=map(int,raw_input().split())\nl=[a,b]\nprint gcd(max(l),min(l))\n"}, {"source_code": "a,b=list(map(int,input().split()))\nprint(a)"}, {"source_code": "import math\nf=lambda:map(int,input().split())\na,b=f()\nprint(math.gcd(a,b),end='')"}, {"source_code": "def gcd(a,b):\n\twhile(a!=b):\n\t\tif(a>b):\n\t\t\ta-=b\n\t\telse:\n\t\t\tb-=a;\n\treturn a\na,b=map(int,input().strip().split())\nprint(gcd(a,b))"}, {"source_code": "a,b = raw_input().split()\n\nprint a\n"}, {"source_code": "\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n\na,b = input().split()\na=int(a)\nb=int(b)\nprint(gcd(a, b))"}, {"source_code": "def gcd(a,b):\n\twhile(a!=b):\n\t\tif(a>b):\n\t\t\ta-=b\n\t\telse:\n\t\t\tb-=a;\n\treturn a\na,b=map(int,input().strip().split())\nprint(gcd(a,b))"}, {"source_code": "def gcd(a,b):\n if a==0:\n return b\n return gcd(b%a,a)\n\nt=list(map(int,input().split()))\nprint(gcd(t[0],t[1]))\n"}, {"source_code": "import math\na,b=map(int,input().split())\nprint(math.gcd(a,b))"}, {"source_code": "a, b = [int(x) for x in raw_input().split()]\n\nwhile a != 0 and b != 0:\n if a > b:\n a = a % b\n else:\n b = b % a\n\t\t\nprint a + b"}, {"source_code": "import sys\na,b=map(int,raw_input().split())\nif b-a>1:\n\tprint 1\nelse:\n\tprint a"}, {"source_code": "import math\na,b=map(int,input().split())\nprint(math.gcd(a,b))"}, {"source_code": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\ndef main():\n a,b=map(int,input().split(\" \"))\n a,b=max(a,b),min(a,b)\n \n print(gcd(a,b))\nmain()\n"}, {"source_code": "def gcd(u, v):\n if (u == v):\n return u\n\n if (u == 0):\n return v\n\n if (v == 0):\n return u\n\n if (~u & 1):\n if (v & 1):\n return gcd(u >> 1, v)\n else:\n return gcd(u >> 1, v >> 1) << 1\n\n if (~v & 1):\n return gcd(u, v >> 1);\n\n if (u > v):\n return gcd((u - v) >> 1, v)\n\n return gcd((v - u) >> 1, u)\n\na, b = map(int, input().split(' '))\nprint(gcd(a, b))"}, {"source_code": "\np = (raw_input()).split()\n\nprint p[0]\n"}, {"source_code": "import math\nfrom fractions import gcd\n\nline = raw_input()\nline = line.split(' ')\n\na = int(line[0])\nb = int(line[1])\n\nmax_gcd = 0\ng = b;\nfor i in range(b-1, a-1, -1):\n g = gcd(g, i)\n if g > max_gcd:\n max_gcd = g\n\nprint max_gcd\n"}, {"source_code": "#rOkY\n#FuCk\n\n################################ kOpAl ############################################\n\na,b=map(str,input().split())\nif(a<b):\n print(a)\nelse:\n print(b)\n"}, {"source_code": "n,m=map(int,input().split())\ni=0\nwhile n*m:\n n%=m\n i=m\n m=n\n n=i\nprint(n)\n"}, {"source_code": "from math import gcd\na,b = map(int,input().split())\n\nprint(gcd(a,b))\n"}, {"source_code": "a, b = [int(n) for n in input().split()]\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nprint(gcd(b, a))\n"}, {"source_code": "import sys\na,b=map(int,raw_input().split())\nif b-a>1:\n\tprint 1\nelse:\n\tprint a"}, {"source_code": "from sys import stdin,stdout\n# stdin = open(\"/home/shiva/Learning/1.txt\", \"r\")\n# stdout = open(\"/home/shiva/Learning/2.txt\", \"w\")\ndef gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\n\na,b = stdin.readline().split()\nstdout.write(str(gcd(int(a),int(b))))"}, {"source_code": "import math\na, b = map(int, input().split())\nprint(math.gcd(a, b))"}, {"source_code": "a=str(input()).split()\nx=max(int(a[0]),int(a[1]))\ny=min(int(a[1]),int(a[1]))\ndef bacot(m, n):\n if n==0:\n return m\n else:\n return bacot(n, m%n)\nxx=bacot(x, y)\nprint(xx)\n"}, {"source_code": "a, b = map(int, input().split())\nif a>b:\n print(1)\n \nelse:\n print(a)"}, {"source_code": "import sys\n\ndef euclid(a, b):\n\tif b > a:\n\t\ttemp = a\n\t\ta = b\n\t\tb = temp\n\tassert a >= b\n\tr = a % b\n\tif r == 0:\n\t\treturn b\n\telse:\n\t\treturn euclid(b, r)\n\n(a, b) = tuple(long(i) for i in sys.stdin.readline().strip().split())\nprint euclid(a, b)\n"}, {"source_code": "from fractions import gcd\na, b = map(int, input().split(' '))\nprint(gcd(a, b))"}, {"source_code": "import sys\na,b=map(int,raw_input().split())\nif b-a>1:\n\tprint 1\nelse:\n\tprint a"}, {"source_code": "s = 1\n\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\telse :\n\t\treturn gcd(b, a % b)\t\n\np, q = map(int, raw_input().split(' '));\n\nprint gcd(p, q)"}, {"source_code": "a,b=map(int,input().split())\nif a-b==1 or a-b==-1:\n print(1)\nif a==b:\n print(a)\nif a==1 or b==1:\n print(1)\n \n\n\n\n"}, {"source_code": "numbers = list(map(int, input().split()))\na=numbers[0]\nb=numbers[1]\nmaxi=1\nfor i in range (a,1):\n\tfound=true\n\tfor x in range (a,b):\n\t\tif x%i!=0:\n\t\t\tfound=false\n\tif found:\n\t\tmaxim=i\n\t\t\nprint (maxi)"}, {"source_code": "import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\ndd=[(-1,0),(0,1),(1,0),(0,-1)]\nddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\n# def LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return input()\n\n# GCD -- START --\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n# GCD --- END ---\n\ndef main():\n n,m=LI()\n return gcd(n,m)\n\n# main()\nprint(main())\n"}, {"source_code": "linha = map(int, raw_input().split())\nwhile linha != 1:\n\tif linha[1] == 0: break\n\tlinha.sort()\n\tlinha[1] = linha[1] % linha[0]\n\nprint linha[0]"}, {"source_code": "def gcd(a, b):\n if a < 0 or b < 0:\n return 0\n c = 0\n while b != 0:\n c = a%b\n a = b\n b = c\n return a\ndef main():\n var1, var2 = [int(x) for x in raw_input().split()]\n print(gcd(var1,var2))\nmain()\n"}, {"source_code": "def gcd(x, y):\n if y == 0:\n return x\n else:\n return gcd(y, x % y)\nx, y = map(int, input().split())\nprint(gcd(x, y))\n"}, {"source_code": "import sys\n \ndef gcd(x,y):\n if x==0:\n \treturn y\n else:\n \treturn gcd(y%x,x)\n \nn,k=sys.stdin.readline().split(\" \")\nn=int(n)\nk=int(k)\nprint gcd(n,k) "}, {"source_code": "a,b=map(int,input().split())\ni=a\nwhile i>0:\n if a%i==0 and b%i==0:\n print(i)\n break\n i-=1"}, {"source_code": "def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\na, b = [int(i) for i in input().split(' ')]\n\nprint(gcd(a, b))"}, {"source_code": "a,b = list(map(int, input().split()))\nif a==b:\n\tprint(a)\nelif b-a==1:\n\tprint(1)\nelse:\n\tprint(2)"}, {"source_code": "def gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n\nnumbers = list(map(int,input().split()))\n\nprint(gcd(numbers[0],numbers[1]))\n"}, {"source_code": "def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\na, b = [int(i) for i in input().split()]\nprint(gcd(a, b))\n"}, {"source_code": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n \na,b=map(int,raw_input().split())\nprint gcd(a,b)\n"}, {"source_code": "import math\na,b=map(int,input().split())\nprint(math.gcd(a,b))"}, {"source_code": "import sys\na,b=map(int,raw_input().split())\nif b-a>1:\n\tprint 1\nelse:\n\tprint a"}], "src_uid": "9c5b6d8a20414d160069010b2965b896"} {"source_code": "n, ans, x = input (), 0, [0 for i in xrange (9)]\nfor i in xrange (1, n + 1):\n ans -= n / i\n x[i % 9] += 1\nfor i in xrange (9):\n for j in xrange (9):\n ans += x[i] * x[j] * x[(i * j) % 9]\nprint ans\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "positive_code": [{"source_code": "from math import sqrt, floor\n\nn = int(input())\n\ntrue_products, a = 0, 1\n\nwhile a ** 2 <= n:\n\ttrue_products += n // a - a\n\ta += 1\n\ntrue_products *= 2\n\ntrue_products += floor(sqrt(n))\n\ndigit_roots = [n // 9 for _ in range(9)]\nfor i in range(1, n % 9 + 1):\n\tdigit_roots[i] += 1\n\ndigit_root_products = 0\n\nfor i in range(9):\n\tfor j in range(9):\n\t\tdigit_root_products += digit_roots[i] * digit_roots[j] * digit_roots[(i * j) % 9]\n\nprint(digit_root_products - true_products)\n"}, {"source_code": "__author__ = 'Darren'\n\n\n# d(x) = (x-1) % 9 + 1\ndef solve():\n n = int(input())\n\n # count[i]: the number of x's in [1,n] such that d(x) = i\n count = [0] * 10\n for i in range((n-1) % 9 + 2):\n count[i] = (n + 8) // 9\n for i in range((n-1) % 9 + 2, 10):\n count[i] = n // 9\n\n result = 0\n\n # Count all triples (i, j, k) such that d(d(i)*d(j)) = d(k)\n for i in range(1, 10):\n for j in range(1, 10):\n result += count[i] * count[j] * count[(i*j-1) % 9 + 1]\n\n # For each i, there are n/i triples (i,j,k) such that i*j = k,\n # i.e., the correct cases\n for i in range(1, n+1):\n result -= n // i\n\n print(result)\n\n\nif __name__ == '__main__':\n solve()"}, {"source_code": "n , ans , a = int(input()) , 0 , [0] * 10\nfor i in range(1,n+1):\n ans -= (int)(n/i)\n a[i % 9] += 1\nfor i in range(9):\n for j in range(9):\n ans += a[i] * a[j] * a[(i * j) % 9]\nprint (ans)\n"}, {"source_code": "n , ans , a = int(input()) , 0 , [0] * 10\nfor i in range(1,n+1):\n ans -= (int)(n/i)\n a[i % 9] += 1\nfor i in range(9):\n for j in range(9):\n ans += a[i] * a[j] * a[(i * j) % 9]\nprint (ans)"}, {"source_code": "n , ans , a = int(input()) , 0 , [0] * 10\nfor i in range(1,n+1):\n ans -= (int)(n/i)\n a[i % 9] += 1\nfor i in range(9):\n for j in range(9):\n ans += a[i] * a[j] * a[(i * j) % 9]\nprint (ans)"}, {"source_code": "__author__ = 'Darren'\n\n\n\n\n\n# d(x) = (x-1) % 9 + 1\n\ndef solve():\n\n n = int(input())\n\n\n\n # count[i]: the number of x's in [1,n] such that d(x) = i\n\n count = [0] * 10\n\n for i in range((n-1) % 9 + 2):\n\n count[i] = (n + 8) // 9\n\n for i in range((n-1) % 9 + 2, 10):\n\n count[i] = n // 9\n\n\n\n result = 0\n\n\n\n # Count all triples (i, j, k) such that d(d(i)*d(j)) = d(k)\n\n for i in range(1, 10):\n\n for j in range(1, 10):\n\n result += count[i] * count[j] * count[(i*j-1) % 9 + 1]\n\n\n\n # For each i, there are n/i triples (i,j,k) such that i*j = k,\n\n # i.e., the correct cases\n\n for i in range(1, n+1):\n\n result -= n // i\n\n\n\n print(result)\n\n\n\n\n\nif __name__ == '__main__':\n\n solve()\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "n , ans , a = int(input()) , 0 , [0] * 10\nfor i in range(1,n+1):\n ans -= (int)(n/i)\n a[i % 9] += 1\nfor i in range(9):\n for j in range(9):\n ans += a[i] * a[j] * a[(i * j) % 9]\nprint (ans)"}, {"source_code": "n = int(raw_input())\ncount = [0] * 10\nfor idx in range(1, n+1):\n count[idx%9] += 1\n\nans = 0\nfor i in range(10):\n for j in range(10):\n ans += count[i] * count[j] * count[i*j%9]\n\nfor i in range(1, n+1):\n ans -= n / i\n\nprint ans\n"}, {"source_code": "n,a,c=input(),0,[0]*10\nfor x in range(1,n+1):\n a-=n/x\n c[x%9]+=1\nfor i in range(9):\n for j in range(9):\n a+=c[i]*c[j]*c[i*j%9]\nprint a\n"}, {"source_code": "import math\n\ndef f(n, r):\n if r > n:\n return 0\n if r == 0:\n return (n - r) / 9\n else:\n return (n - r) / 9 + 1\n \n \ndef test_f(n):\n s = sum(map(lambda r: f(n, r), range(0, 9)))\n print \"Testing\", n, '?=', s\n assert (n == s)\n\n\nn = int(raw_input())\n\n#test_f(n)\n\n\nN0 = 0\n# for i in range(1, int(math.sqrt(n)) + 1):\nfor i in range(1, n + 1):\n# print i, ':', n / i\n N0 += n / i\n\nF = 0 \nfor i in range(0, 9):\n for j in range(0, 9):\n F += f(n, i) * f(n, j) * f(n, (i * j) % 9)\n \n#print F, '-', N0, '=', \nprint F - N0\n\n"}, {"source_code": "n = int(input())\nA = 0\nfor i in range(1, 10):\n x = n / 9\n if(n - x * 9 >= i):\n x += 1\n for j in range(1, 10):\n y = n / 9\n if(n - y * 9 >= j):\n y += 1\n k = i * j % 9\n if(k == 0): k = 9\n z = n / 9\n if(n - z * 9 >= k):\n z += 1\n #print \"(%d,%d)(%d,%d)(%d,%d)\"%(i, x, j, y, k, z)\n A += x * y * z\nB = 0\nfor i in range(1, n + 1):\n B += n / i\nprint A - B\n"}, {"source_code": "def digRoot(n): return 9 if n % 9 == 0 else n % 9\n\nn = int(raw_input())\ngood = 0\nfor i in range(1, n + 1):\n temp = n // i\n good += temp\n\nall = 0\nfor a in range(1, 10):\n for b in range(1, 10):\n c = digRoot(a * b)\n all += ( (n + 9 - a) // 9 ) * ( (n + 9 - b) // 9 ) * ( (n + 9 - c) // 9 )\n\nprint(all - good)"}, {"source_code": "def root(a):\n res = 0\n while a>0:\n res+=a%10\n a/=10\n return root(res) if res>9 else res\n\n\nn = int(raw_input())\nrt = [root(i) for i in xrange(0,100)]\nroot\nsum = 1\nt = [0 for i in xrange(0,10)]\nfor i in xrange(1,n+1): \n t[rt[sum]]+=1\n #print i,sum\n sum+=1\n if (i%10) == 9:\n sum-=9\n if (i%100)==99:\n sum-=9\n if (i%1000)==999:\n sum-=9\n if (i%10000)==9999:\n sum-=9\n if (i%100000)==99999:\n sum-=9\n if (i%1000000)==999999:\n sum-=9\nans1 = 0\n#print rt\n#print t\nfor r1,i in enumerate(t):\n for r2,j in enumerate(t):\n for r3,k in enumerate(t):\n if r3==root(r2*r1):\n #if i*j*k>0 : print r1,r2,r3\n ans1+=i*j*k\nans2 = 0\nfor i in xrange(1,n+1):\n ans2+=n/i\n#print [(i,j) for (i,j) in enumerate(t)]\n#print root(1)\n#print ans1\nprint ans1-ans2"}, {"source_code": "n = int(raw_input())\nd = [(n-i)/9+1 for i in range(1,10)]\ns = 0\nfor i in range(1,10):\n\tfor j in range(1,10):\n\t\ts += d[i-1]*d[j-1]*d[(i*j-1)%9]\nsqn = int(n**0.5)\nfor i in range(1,sqn+1):\n\ts -= (n/i-i)*2+1\nprint s"}, {"source_code": "import sys\n\ndef g(n):\n g = [n/9+1]*(n%9)+[n/9]*(9-n%9)\n g = g[-1:]+g[:-1]\n f = [0]*9\n for i in range(9):\n for j in range(9):\n f[(i*j)%9] += g[i]*g[j]\n r = sum([f[i]*g[i] for i in range(9)])\n for i in range(1,n+1):\n r -= n/i\n return r\n\nprint \"%d\" % g(int(sys.stdin.readline()))\n\n\n"}, {"source_code": "from math import sqrt\nN=input()\nd=[(N-i)/9+1 for i in range(1,10)]\ns=0\nfor i in range(1,10):\n for j in range(1,10):\n s+=d[i-1]*d[j-1]*d[(i*j-1)%9]\nsqrtN=int(sqrt(N))\nfor i in range(1,sqrtN+1):\n s-=(N/i-i)*2+1\nprint s"}, {"source_code": "n = input()\nr = xrange(9)\na = [n / 9 + (1 <= i <= n % 9) for i in r]\nprint sum(a[i] * a[j] * a[i * j % 9] for i in r for j in r) - sum(n / i for i in xrange(1, n + 1))"}, {"source_code": "p,u,d=input(),0,[0]*10\nfor g in range(1,p+1):\n u-=p/g\n d[g%9]+=1\nfor i in range(9):\n for j in range(9):\n u+=d[i]*d[j]*d[i*j%9]\nprint u"}, {"source_code": "n = int(raw_input())\ns = 0\nc = [0]*9\nfor i in range(1, n + 1):\n\ts -= n / i\n\tc[i % 9] = c[i % 9] + 1\nfor i in range(9):\n\tfor j in range(9):\n\t\ts += c[i] * c[j] * c[i * j % 9]\nprint s\n"}, {"source_code": "n = int(raw_input())\nans = 0\ncnt = [0]*9\nfor i in xrange(1, n+1):\n ans -= n/i\n cnt[i%9] += 1;\nfor i in xrange(9):\n for j in xrange(9):\n ans += cnt[i]*cnt[j]*cnt[i*j%9]\nprint ans"}, {"source_code": "ll = [0]\nfor i in range(1,101):\n d = i\n while d >= i:\n tmp = 0\n while d > 0:\n tmp += d%10\n d /= 10\n d = tmp\n if d < 10: break\n if d < 10:\n ll.append(d)\n else:\n ll.append(ll[d])\n\n\nn = int(raw_input())\nnum = [0]\nfor i in range(1,10):\n num.append(0)\n if n%9 >= i:\n tmp = 1\n else:\n tmp = 0\n num[i] = n/9 + tmp\n \nret = 0\nfor i in range(1,10):\n for j in range(1,10):\n for k in range(1,10):\n if ll[i*j] == ll[k]:\n ret += num[i]*num[j]*num[k]\n\nfor i in range(1,n+1):\n ret -= n/i\nprint ret"}, {"source_code": "ll = [0]\nfor i in xrange(1,101):\n d = i\n while d >= i:\n tmp = 0\n while d > 0:\n tmp += d%10\n d /= 10\n d = tmp\n if d < 10: break\n if d < 10:\n ll.append(d)\n else:\n ll.append(ll[d])\n\n\nn = int(raw_input())\nnum = [0]\nfor i in xrange(1,10):\n num.append(0)\n if n%9 >= i:\n tmp = 1\n else:\n tmp = 0\n num[i] = n/9 + tmp\n \nret = 0\nfor i in xrange(1,10):\n for j in xrange(1,10):\n for k in xrange(1,10):\n if ll[i*j] == ll[k]:\n ret += num[i]*num[j]*num[k]\n\nfor i in xrange(1,n+1):\n ret -= n/i\nprint ret\n"}, {"source_code": "n,ans,ref=input(),0,[0]*10\nfor i in range(1,n+1):\n ans -= n/i\n ref[i%9] += 1\nans += sum([ref[i]*ref[j]*ref[i*j%9] for j in range(9) for i in range(9)])\nprint ans\n"}, {"source_code": "n = int(input())\nc = [0] * 9\nans = 0\nfor i in range(1, n + 1):\n ans -= n // i\n c[i % 9] += 1\nfor i in range(9):\n for j in range(9):\n ans += c[i] * c[j] * c[i * j % 9]\nprint(ans)"}, {"source_code": "\ndef main():\n ans = 0\n a = [0] * 10\n n = int(input())\n for i in range (0, 9):\n a[i] = n // 9 + int(n % 9 >= i)\n a[0] -= 1\n \n for i in range(0, 9):\n for j in range(0, 9):\n k = i * j % 9\n ans += a[i] * a[j] * a[k]\n \n for i in range(1, n + 1):\n ans -= n // i\n print(ans)\n \n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "\ndef main():\n ans = 0\n a = [0] * 10\n n = int(input())\n for i in range (1, 9):\n a[i] = n // 9 + int(n % 9 >= i)\n a[9] = n // 9\n \n for i in range(1, 10):\n for j in range(1, 10):\n k = i * j % 9\n if k == 0:\n k = 9\n ans += a[i] * a[j] * a[k]\n \n for i in range(1, n + 1):\n ans -= n // i\n print(ans)\n \n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = int(input())\ncorr = 0\nfor i in range(1, n + 1):\n corr += (n // i)\n \ntotal = 0\n\ncount = [0] * 9\nfor i in range(1, n + 1):\n count[i % 9] += 1\n \nmult = [0]*9\nfor i in range(9):\n for j in range(9):\n mult[(i * j) % 9] += count[i] * count[j]\n\nfor i in range(9):\n total += mult[i] * count[i]\n\n\nprint(total - corr)"}, {"source_code": "n, ans, a = int(input()), 0, [0] * 10\nfor i in range(1, n + 1):\n ans -= int(n/i)\n a[i % 9] += 1\nfor i in range(9):\n for j in range(9):\n ans += a[i] * a[j] * a[(i * j) % 9]\nprint(ans)\n"}], "negative_code": [{"source_code": "n = int(raw_input())\ncount = [0] * 10\nfor idx in range(1, n+1):\n count[idx%9] += 1\n\nans = 0\nfor i in range(1, 10):\n for j in range(1, 10):\n ans += count[i] * count[j] * count[i*j%9]\n\nprint ans\nfor i in range(1, n+1):\n for j in range(i, n+1, i):\n ans -= 1\n\nprint ans\n"}, {"source_code": "n = int(raw_input())\ncount = [0] * 10\nfor idx in range(1, n+1):\n count[idx%9] += 1\n\nans = 0\nfor i in range(1, 10):\n for j in range(1, 10):\n ans += count[i] * count[j] * count[i*j%9]\n\nfor i in range(1, n+1):\n for j in range(i, n+1, i):\n ans -= 1\n\nprint ans\n"}, {"source_code": "\ndef main():\n ans = 0\n a = [0] * 10\n n = int(input())\n for i in range (1, 9):\n a[i] = n // 9 + int(n % 9 >= i)\n a[9] = n // 9\n \n for i in range(1, 10):\n for j in range(1, 10):\n k = i * j % 9\n if k == 0:\n k = 9\n ans += a[i] * a[j] * a[k]\n \n for i in range(1, n):\n ans -= n // i\n print(ans)\n \n return\n\nif __name__ == \"__main__\":\n main()"}], "src_uid": "fc133fe6353089a0ebee08dec919f608"} {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \nM = mod = 998244353 \ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\ndef fact(n):\n pro = 1\n for i in range(2,n + 1):pro = pro*i%mod\n return pro\nn,m = li()\nif n == 2:\n print(0)\n exit()\na = fact(m)\nb = fact(m - n + 1)\nc = fact(n - 1)\na = a*inv_mod(b*c%mod)*(n - 2)%mod\na = a*pow(2,n-3)%mod\nprint(a)", "positive_code": [{"source_code": "from collections import Counter, OrderedDict\nfrom itertools import permutations as perm\nfrom collections import deque\nfrom sys import stdin\nfrom bisect import *\nfrom heapq import *\nimport math\n\ng = lambda : stdin.readline().strip()\ngl = lambda : g().split()\ngil = lambda : [int(var) for var in gl()]\ngfl = lambda : [float(var) for var in gl()]\ngcl = lambda : list(g())\ngbs = lambda : [int(var) for var in g()]\nmod = int(1e9)+7\ninf = float(\"inf\")\n\ndef ncr(n, r, p): \n # initialize numerator \n # and denominator \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, \n p - 2, p)) % p \n\n\nn, m = gil()\n\nif n == 2:\n\tprint(0)\nelse:\n\tp = [1]*(n)\n\tmod = 998244353\n\tfor i in range(1, n):\n\t\tp[i] = (2*p[i-1])%mod\n\tprint((p[n-3]*ncr(m, n-1, mod)*(n-2))%mod)\n"}, {"source_code": "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(100000)\ninput = sys.stdin.readline\nINF = 2**62-1\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\nclass Mod:\n def __init__(self, m):\n self.m = m\n\n def add(self, a, b):\n return (a + b) % self.m\n\n def sub(self, a, b):\n return (a - b) % self.m\n\n def mul(self, a, b):\n return ((a % self.m) * (b % self.m)) % self.m\n\n def div(self, a, b):\n return self.mul(a, pow(b, self.m-2, self.m))\n\n def pow(self, a, b):\n return pow(a, b, self.m)\n\n\nclass Combination:\n def __init__(self, n, mod):\n\n g1 = [1, 1]\n g2 = [1, 1]\n inverse = [0, 1]\n for i in range(2, n + 1):\n g1.append((g1[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inverse[-1]) % mod)\n self.MOD = mod\n self.N = n\n self.g1 = g1\n self.g2 = g2\n self.inverse = inverse\n\n def __call__(self, n, r):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD\n\n\n@mt\ndef slv(N, M):\n if N <= 2:\n return 0\n mod = Mod(998244353)\n C = Combination(2 * (10**5), 998244353)\n ans = 0\n for i in range(1, N-1):\n ln = i\n rn = N - i - 1\n ln -= 1\n t = C(M, N-1)\n t = mod.mul(t, C(N-3, ln))\n t = mod.mul(t, N-2)\n ans = mod.add(ans, t)\n\n return ans\n\n\ndef main():\n N, M = read_int_n()\n print(slv(N, M))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python3\n\nimport sys\nfrom math import *\nfrom collections import defaultdict\nfrom queue import deque # Queues\nfrom heapq import heappush, heappop # Priority Queues\nM = 998244353\ninvcache = {}\n\n# parse\nlines = [line.strip() for line in sys.stdin.readlines()]\nn, m = list(map(int, lines[0].split()))\n\n# precompute\nfacts = [1]\npows = [1]\nfor i in range(1, m+1):\n facts += [facts[-1] * i % M]\n pows += [pows[-1] * 2 % M]\n\n# mod inv\ndef gcdext(a, b):\n if a == 0:\n return b, 0, 1\n gcd, x, y = gcdext(b % a, a)\n return gcd, y - (b//a) * x, x\n\ndef modinv(a):\n if a in invcache:\n return invcache[a]\n \n g, x, y = gcdext(a, M)\n assert(g == 1)\n x %= M\n invcache[a] = x\n return x\n\ndef choose(a, b):\n if a < b or b < 0:\n return 0\n if b == 0:\n return 1\n if b == 1:\n return a\n return facts[a] * modinv(facts[b]) % M * modinv(facts[a-b]) % M\n\nret = 0\nfor k in range(n-1, m+1):\n ret = (ret + choose(k-1, 1) * choose(k-2, n-3) % M * pows[n-3]) % M\nprint(ret)\n"}, {"source_code": "import math, collections, sys\ninput = sys.stdin.readline\ndef ncr(n, r, p):\n num = den = 1 \n for i in range(r):\n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, p - 2, p)) % p \nn, m = map(int, input().split())\nmod = 998244353\nif n == 2:\n print(0)\nelse:\n ans = ncr(m, n-1, mod)\n ans*=(n-2)\n ans%=mod\n ans*=pow(2, n-3, mod)\n ans%=mod\n print(ans)"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\n# sys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 998244353\n\nclass ModTools:\n\n def __init__(self, MAX, MOD):\n \n MAX += 1\n self.MAX = MAX\n self.MOD = MOD\n factorial = [1] * MAX\n factorial[0] = factorial[1] = 1\n for i in range(2, MAX):\n factorial[i] = factorial[i-1] * i % MOD\n inverse = [1] * MAX\n inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)\n for i in range(MAX-2, 0, -1):\n inverse[i] = inverse[i+1] * (i+1) % MOD\n self.fact = factorial\n self.inv = inverse\n \n def nCr(self, n, r):\n\n if n < r: return 0\n r = min(r, n-r)\n numerator = self.fact[n]\n denominator = self.inv[r] * self.inv[n-r] % self.MOD\n return numerator * denominator % self.MOD\n\nN, M = MAP()\n\nmt = ModTools(M, MOD)\nif N == 2:\n print(0)\n exit()\n\nans = 0\nfor k in range(M, N-2, -1):\n ans += mt.nCr(k-1, N-2) * (N-2) * pow(2, N-3, MOD) % MOD\n ans %= MOD\nprint(ans)\n"}, {"source_code": "import sys\n\n# inf = open('input.txt', 'r')\n# reader = (line.rstrip() for line in inf)\nreader = (line.rstrip() for line in sys.stdin)\ninput = reader.__next__\n\nn, m = map(int, input().split())\nmodulo = 998244353\n\nlimit = 2 * 10 ** 5 + 2\nfact = [0] * limit\nfact[0] = 1\nfor i in range(1, limit):\n fact[i] = (fact[i - 1] * i) % modulo\n\ndef inv(num, modulo):\n return pow(num, modulo - 2, modulo)\n\ndef binom(n, k, modulo):\n if n < k: return 0\n if n == k: return 1\n if k == 0: return 1\n return (fact[n] * inv(fact[n - k] * fact[k], modulo)) % modulo\n\ndef countArr(n, m):\n if n < 3:\n return 0\n \n ans = 0\n free = 0\n permut = pow(2, n - 3, modulo)\n for top in range(n - 1, m + 1):\n inc_arr = binom(top - 1, n - 3, modulo)\n free += 1\n ans = (ans + inc_arr * free * permut) % modulo\n return ans\n\nprint(countArr(n, m))\n\n# inf.close()"}, {"source_code": "def ncr(n, r, p): \n num = den = 1 \n for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p \n return (num * pow(den,p - 2, p)) % p \nn,m=map(int,input().split());p=998244353 ;print((ncr(m,n-1,p)*(n-2)*pow(2,max((n-3),0),p))%p)"}, {"source_code": "import math\nimport sys\ninput = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\nilele = lambda: map(int,input().split())\nalele = lambda: list(map(int, input().split()))\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\ndef storefactorial(N,M):\n Ans = 1\n Z = [1]\n for i in range(1,N+1):\n Ans*=i\n Ans%=M\n Z.append(Ans)\n return Z\nF = storefactorial(2*100000,998244353)\n\ndef powerof2(N,M):\n Ans = 1\n Z=[1]\n for i in range(N):\n Ans*=2\n Ans%=M\n Z.append(Ans)\n return Z\n \nG = powerof2(2*100000,998244353)\n\nM = 998244353\nn,m = ilele()\nif n ==2:\n print(0)\nelse:\n a = F[m]\n b = (F[m-n+1]*F[n-1])%M\n c = (a*pow(b,M-2,M))%M\n d =(c*(n-2))%M\n e = (d*G[n-3])%M\n print(e)\n \n \n "}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# ------------------- fast io --------------------\nn,m=map(int,input().split());mod=998244353\ndef C(n, k,mod):\n if k > n: \n return 0\n k = min(k, n-k);a = 1;b = 1\n for i in range(k):\n a = (a*(n-i))%mod\n b = (b*(i+1))%mod\n return (a*pow(b, mod-2, mod))%mod\na1=C(m,n-1,mod)\nif n>=3:\n a2=pow(2,n-3,mod)\nelse:\n a2=0\nprint(int(a1*a2*(n-2))%mod)"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\nfrom math import factorial\nfrom collections import Counter, defaultdict\nfrom heapq import heapify, heappop, heappush\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\nmod = 998244353\nINF = float('inf')\n\n# ------------------------------\n\n\ndef main():\n n, m = RL()\n fac = [1, 1]\n for i in range(2, m+1):\n fac.append(((fac[-1]%mod)*(i%mod))%mod)\n\n def cb(m, n): return int(fac[m] * (pow(fac[n] * fac[m - n], mod-2, mod)))%mod if m >= n else 0\n\n res = cb(m, n-1)*(n-2)*(2**(n-3))\n\n print(int(res%mod))\n\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "# Python3 function to \n# calculate nCr % p \ndef ncr(n, r, p): \n\t# initialize numerator \n\t# and denominator \n\tnum = den = 1\n\tfor i in range(r): \n\t\tnum = (num * (n - i)) % p \n\t\tden = (den * (i + 1)) % p \n\treturn (num * pow(den, \n\t\t\tp - 2, p)) % p \n\n# p must be a prime \n# greater than n \n# n, r, p = 10, 2, 13\n# print(\"Value of nCr % p is\", \n# \t\t\tncr(n, r, p)) \n\nn,m = map(int,input().split()) \np = 998244353 \n\nans = ncr(m,n-1,p) \n\nans = (ans%p *(n-2)%p)%p \nfor i in range(n-3):\n ans = (ans*2)%p \nprint(ans)\n\n\n"}, {"source_code": "n,m=map(int,input().split())\nmod=998244353\nif n==3:\n\tprint (((m*(m-1))//2)%(mod))\n\texit()\nif n==2:\n\tprint(0)\n\texit()\nfact = [1,1]\nfor i in range(2,max(n,m)+1):\n\tfact.append((fact[-1]*i)%mod)\nans = pow(2,n-3,mod)\nans = ((n-2)*ans)%mod\nans = ans*((fact[m]*pow((fact[n-1]*fact[m+1-n])%mod,mod-2,mod))%mod)\nprint ((ans)%mod)"}, {"source_code": "import math as mt \nimport sys,string\ninput=sys.stdin.readline\nimport random\nfrom collections import deque,defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\ndef ncr(n,r):\n return mt.factorial(n)//(mt.factorial(n-r)*mt.factorial(r))\ndef ncr(n, r, mod):\n num = d = 1 \n for i in range(r):\n num = (num * (n - i)) % mod\n d = (d* (i + 1)) % mod\n return (num * pow(d, mod - 2, mod)) % mod \nn,m=M()\nans=ncr(m,n-1,998244353)*(n-2)*(pow(2,max(0,n-3),998244353))\nprint(int(ans%998244353))\n"}, {"source_code": "n,m = map(int,input().split())\np = 998244353\ndef odw(a):\n\tcyk = p - 2\n\tno = a\n\twyn = 1\n\twhile cyk > 0:\n\t\tif cyk%2 == 1:\n\t\t\twyn = (wyn*no)%p\n\t\tno = (no*no)%p\n\t\tcyk //= 2\n\treturn wyn\nif n == 2:\n\tprint(0)\nelse:\n\tsil = [1] * 200002\n\tpot = [1] * 200002\n\tfor i in range(1,200002):\n\t\tsil[i] = (i * sil[i-1])%p\n\t\tpot[i] = (pot[i-1]*2) % p\n\twyn = 0\n\tfor i in range(n-1, m + 1):\n\t\ttry:\n\t\t\twyn += ((pot[n-3] * sil[i-1] * (n-2)) * odw(sil[n-2] * sil[i-n+1]) )\n\t\texcept Exception:\n\t\t\tcontinue\n\tprint(wyn%p)"}, {"source_code": "mod = 998244353\ndef ncr(n,r):\n num = 1\n den = 1\n for i in range(r):\n num = (num*(n-i))%mod \n den = (den*(i+1))%mod \n return (num*pow(den,mod-2,mod))%mod \nn,m = map(int,input().split())\nc = ncr(m,n-1)*pow(2,n-2,mod)\nc%=mod \nc = (c*(n-2))%mod \nc = c*pow(2,mod-2,mod)\nc%=mod \nprint(c)\n"}, {"source_code": "from bisect import *\nfrom math import *\nmod = 998244353\ndef bin_exp(a, n):\n\t#gives a**n mod 10**9 +7\n\t\n\tif n==0:\n\t\treturn 1\n\n\telse:\n\t\t\n\t\tj = 0\n\t\tbin_val = []\n\t\twhile n >0:\n\t\t\tbin_val.append(n%2)\n\t\t\tn = n//2\n\t\t\tj+=1\n\t\tpower_arr = [a%mod]\n\t\tfor i in range(1,j):\n\t\t\tpower_arr.append((power_arr[-1]**2)%mod)\n\n\t\tvalue = 1\n\t\tfor i in range(0, j):\n\t\t\tif bin_val[i] == 1:\n\t\t\t\tvalue = (value*power_arr[i])%mod\n\n\t\treturn value%mod\n\t\t\ndef fact_arr(n):\n\t# n th position gives (n)!...i.e 0 th position gives 0!, 1st position gives 1! and so on \n\tarr = [1]\n\tfor i in range(n):\n\t\tarr.append((arr[-1]*(i+1))%mod)\n\n\treturn arr\n\t\ndef mult_inver(a):\n\treturn bin_exp(a, mod-2)\n\ndef fact(a):\n\tval = 1\n\tfor i in range(2, a+1):\n\t\tval = (val*i)%mod\n\treturn val\nn,m = input().split()\nn = int(n)\nm = int(m)\nif n<3:\n\tprint(0)\nelse:\n\n\tans = (fact(m)*bin_exp(fact(n-1), mod-2)*bin_exp(fact(m-(n-1)), mod-2)*(n-2))%mod\n\tans = (ans*bin_exp(2, n-3))%mod\n\tprint(ans)\n\n"}, {"source_code": "mod=998244353\nfrac=[1]*200001\nfor i in range(1,200001):\n frac[i]=(frac[i-1]*i)%mod\ndef C(a,b):\n return ((frac[a]*pow(frac[a-b],mod-2,mod))%mod*pow(frac[b],mod-2,mod))%mod\nn,m=map(int,input().split())\np,ans=0,0\nfor i in range(n-1):\n p=(p+C(n-2,i))%mod\nfor i in range(m,n-2,-1):\n ans=(ans+(C(i-1,n-2)*(n-2)*p)//2)%mod\nprint(ans)"}, {"source_code": "def binm(n, r,p): \n # initialize numerator \n # and denominator \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, \n p - 2, p)) % p \nn,m=[int(i) for i in raw_input().split()]\nmod=998244353\nif n==2:\n print 0\nelse:\n val=1\n for i in range(n-3):\n val*=2\n val%=mod\n print ((n-2)*val*binm(m,n-1,mod))%mod\n \n"}, {"source_code": "import sys \n# sys.setrecursionlimit(10**6) \nfrom sys import stdin, stdout\nimport bisect #c++ upperbound\nimport math\nimport heapq\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef cin():\n return map(int,sin().split())\ndef ain(): #takes array as input\n return list(map(int,sin().split()))\ndef sin():\n return input()\ndef inin():\n return int(input())\nimport math \ndef Divisors(n) :\n l = [] \n for i in range(1, int(math.sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n // i == i) : \n l.append(i) \n else : \n l.append(i)\n l.append(n//i)\n return l\ndef modInverse(b,m): \n # g = math.gcd(b, m) \n return pow(b, m - 2, m) \n# Function to compute a/b under modulo m \ndef modDivide(a,b,m): \n a = a % m \n inv = modInverse(b,m) \n return (inv*a) % m \ndef intersection(lst1, lst2): \n lst3 = [value for value in lst1 if value in lst2] \n return lst3\n\"\"\"*******************************************************\"\"\"\ndef main():\n n,m=cin()\n f=[1]\n mod=998244353\n for i in range(1,200005):\n f.append((i*f[i-1])%mod)\n # print(f[:10])\n\n x=pow(2,max(0,n-3),mod)\n j=0\n for i in range(n-2,m):\n # print(n-2,i-n+2,i)\n p=f[n-2]\n q=f[i-n+2]\n r=f[i]\n r=modDivide(r,p,mod)\n r=modDivide(r,q,mod)\n # print(r)\n j=(j+r)%mod\n x=(x*j)%mod\n x=x*(n-2)%mod\n print(x)\n \n \n\n######## Python 2 and 3 footer by Pajenegod and c1729\n \n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n \n# So on cf, use PyPy2 for best string performance.\n \npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n \nimport os, sys\nfrom io import IOBase, BytesIO\n \nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n \n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n \nif __name__== \"__main__\":\n main()"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 998244353\n\nn,m = [int(x) for x in input().split()]\n\nif n == 2:\n print 0\n sys.exit()\n\nk = n - 2\nbig = 3 * 10**5\nchoose = [0] * big\nchoose[k] = 1\nfor i in range(k + 1, big):\n choose[i] = choose[i - 1] * i * pow(i - k, MOD - 2, MOD) % MOD\n\ns = 0\nfor maxval in range(n - 1, m + 1):\n s = (s + choose[maxval - 1] * pow(2, n - 3, MOD) * (n - 2)) % MOD\nprint s\n"}, {"source_code": "from sys import stdin, gettrace\n\nif not gettrace():\n def input():\n return next(stdin)[:-1]\n\n\ndef modInt(mod):\n class ModInt:\n\n def __init__(self, value):\n self.value = value % mod\n\n def __int__(self):\n return self.value\n\n def __eq__(self, other):\n return self.value == other.value\n\n def __hash__(self):\n return hash(self.value)\n\n def __add__(self, other):\n return ModInt(self.value + int(other))\n\n def __sub__(self, other):\n return ModInt(self.value - int(other))\n\n def __mul__(self, other):\n return ModInt(self.value * int(other))\n\n def __floordiv__(self, other):\n return ModInt(self.value // int(other))\n\n def __truediv__(self, other):\n return ModInt(self.value * pow(int(other), mod - 2, mod))\n\n def __str__(self):\n return str(int(self))\n\n return ModInt\n\n\n# def input():\n# return stdin.buffer.readline()\n\n\ndef main():\n n,m = map(int, input().split())\n if n == 2:\n print(0)\n return\n ModInt = modInt(998244353)\n factorial = [ModInt(1)]\n for i in range(1, m+1):\n factorial.append(factorial[-1] * ModInt(i))\n\n def comb(m, i):\n return factorial[m]/(factorial[i] * factorial[m-i])\n\n sum = comb(m,n-1) * (n-2) * 2**(n-3)\n\n print(int(sum))\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "from sys import stdin, gettrace\n\nMOD = 998244353\n\nif not gettrace():\n def input():\n return next(stdin)[:-1]\n\n\ndef modInt(mod):\n class ModInt:\n\n def __init__(self, value):\n self.value = value % mod\n\n def __int__(self):\n return self.value\n\n def __eq__(self, other):\n return self.value == other.value\n\n def __hash__(self):\n return hash(self.value)\n\n def __add__(self, other):\n return ModInt(self.value + int(other))\n\n def __sub__(self, other):\n return ModInt(self.value - int(other))\n\n def __mul__(self, other):\n return ModInt(self.value * int(other))\n\n def __floordiv__(self, other):\n return ModInt(self.value // int(other))\n\n def __truediv__(self, other):\n return ModInt(self.value * pow(int(other), mod - 2, mod))\n\n def __str__(self):\n return str(int(self))\n\n return ModInt\n\n\n# def input():\n# return stdin.buffer.readline()\n\n\ndef main():\n n,m = map(int, input().split())\n if n == 2:\n print(0)\n return\n ModInt = modInt(MOD)\n factorial = [ModInt(1)]\n for i in range(1, m+1):\n factorial.append(factorial[-1] * ModInt(i))\n\n def comb(m, i):\n return factorial[m]/(factorial[i] * factorial[m-i])\n\n sum = comb(m,n-1) * (n-2) * pow(2,n-3, MOD)\n\n print(int(sum))\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "from sys import stdin, gettrace\n\nif not gettrace():\n def input():\n return next(stdin)[:-1]\n\n\ndef modInt(mod):\n class ModInt:\n\n def __init__(self, value):\n self.value = value % mod\n\n def __int__(self):\n return self.value\n\n def __eq__(self, other):\n return self.value == other.value\n\n def __hash__(self):\n return hash(self.value)\n\n def __add__(self, other):\n return ModInt(self.value + int(other))\n\n def __sub__(self, other):\n return ModInt(self.value - int(other))\n\n def __mul__(self, other):\n return ModInt(self.value * int(other))\n\n def __floordiv__(self, other):\n return ModInt(self.value // int(other))\n\n def __truediv__(self, other):\n return ModInt(self.value * pow(int(other), mod - 2, mod))\n\n def __str__(self):\n return str(int(self))\n\n return ModInt\n\n\n# def input():\n# return stdin.buffer.readline()\n\n\ndef main():\n n,m = map(int, input().split())\n if n == 2:\n print(0)\n return\n ModInt = modInt(998244353)\n sum = ModInt(0)\n factorial = [ModInt(1)]\n\n def comb(m, i):\n return factorial[m]/(factorial[i] * factorial[m-i])\n\n for i in range(1, m+1):\n factorial.append(factorial[-1] * ModInt(i))\n # for i in range(1, n-1):\n # l = i+1\n # s = n - i\n # if l < s:\n # l,s = s,l\n # lseq = comb(m,l)\n # dvals = l-1\n # sseq = comb(m - l - 1, s - 2)\n # sum += lseq*dvals*sseq\n sum = comb(m,n-1) * (n-2) * 2**(n-3)\n\n print(int(sum))\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "from sys import stdin\nfrom collections import deque\nmod = 10**9 + 7\nimport sys\nimport random\n# sys.setrecursionlimit(10**6)\nfrom queue import PriorityQueue\n# def rl():\n# return [int(w) for w in stdin.readline().split()]\nfrom bisect import bisect_right\nfrom bisect import bisect_left\nfrom collections import defaultdict\nfrom math import sqrt,factorial,gcd,log2,inf,ceil\n# map(int,input().split())\n# # l = list(map(int,input().split()))\n# from itertools import permutations\nimport heapq\n# input = lambda: sys.stdin.readline().rstrip()\ninput = lambda : sys.stdin.readline().rstrip()\nfrom sys import stdin, stdout\nfrom heapq import heapify, heappush, heappop\nfrom itertools import permutations\nfrom math import factorial as f\n\n# def ncr(x, y):\n# return f(x) // (f(y) * f(x - y))\ndef ncr(n, r, p):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\nfrom collections import defaultdict\nfrom heapq import heappop, heappush, heapify\n\n# t = int(input())\nn,m = map(int,input().split())\nmod = 998244353\nif n == 2:\n print(0)\n exit()\nprint(((ncr(m,n-1,mod)*(n-2))%mod * pow(2,n-3,mod))%mod)\n\n\n"}, {"source_code": "import sys\nimport math\nimport bisect\nfrom sys import stdin, stdout\nfrom math import gcd, floor, sqrt, log2, ceil\nfrom collections import defaultdict as dd\nfrom bisect import bisect_left as bl, bisect_right as br\nfrom bisect import insort\nfrom collections import Counter\nfrom collections import deque\nfrom heapq import heappush,heappop,heapify\nfrom itertools import permutations,combinations\nmod = int(1e9)+7\nmod = 998244353\n \n \nip = lambda : int(stdin.readline())\ninp = lambda: map(int,stdin.readline().split())\nips = lambda: stdin.readline().rstrip()\nout = lambda x : stdout.write(str(x)+\"\\n\")\n\nnn = int(2e5)+1\nf = 1\nfac = [0]*nn\nfac[0] = 1\nfor i in range(1,nn):\n f *= i\n f %= mod\n fac[i] = f\n\nt = 1\nfor _ in range(t):\n n,m = inp()\n if n == 2:\n ans = 0\n else:\n num = fac[m]\n den = fac[n-1]*fac[m-n+1]\n den = pow(den,mod-2,mod)\n ans = (num*den)%mod\n ans *= (n-2)\n ans %= mod\n ans *= pow(2,n-3,mod)\n ans %= mod\n out(ans)\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n\n \n \n"}, {"source_code": "n, m = map(int, input().split())\nif n == 2:\n print(0)\n exit()\n \nmod = 998244353\ndef cb(n, k):\n global mod\n ret = a = b = 1\n for i in range(k):\n a *= n-i\n a %= mod\n b *= i + 1\n b %= mod\n m = mod-2\n while m > 0:\n if m % 2 != 0:\n ret *= b\n ret %= mod\n b *= b\n b %= mod\n m //= 2\n ret *= a\n ret %= mod\n return ret\n\ndef two_pow(n):\n global mod\n ret = 1\n two = 2\n while n:\n if n & 1:\n n -= 1\n ret *= two\n ret %= mod\n two *= two\n two %= mod\n n //= 2\n return ret\n\nans = cb(m, n - 1)\nans *= two_pow(n - 3)\nans %= mod\n\nans *= n - 2\nans %= mod\n\nprint(ans)\n\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\ndef main():\n # t = int(input())\n t = 1\n while(t):\n # for _ in range(t):\n t -= 1\n \n MOD = 998244353\n fact = [1]*200005\n for i in range(1, 200005):\n fact[i] = i*fact[i-1] % MOD\n \n def fast_sq(a, b):\n ans = 1\n if(b == -1):\n b = MOD-2\n for i in range(60):\n if((1<<i)&b):\n ans *= a\n ans %= MOD\n a *= a\n a %= MOD\n return ans\n n, m = map(int, input().split())\n print(fact[m]*(n-2)*fast_sq(2, n-3)*fast_sq(fact[n-1]*fact[m-n+1], -1)%MOD)\n \nmain()"}, {"source_code": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n):\n res = [None] * n\n for i in range(n):\n res[i] = II()\n return res\ndef LIR(n):\n res = [None] * n\n for i in range(n):\n res[i] = LI()\n return res\ndef FR(n):\n res = [None] * n\n for i in range(n):\n res[i] = IF()\n return res\ndef LIR(n):\n res = [None] * n\n for i in range(n):\n res[i] = IF()\n return res\ndef LIR_(n):\n res = [None] * n\n for i in range(n):\n res[i] = LI_()\n return res\ndef SR(n):\n res = [None] * n\n for i in range(n):\n res[i] = S()\n return res\ndef LSR(n):\n res = [None] * n\n for i in range(n):\n res[i] = LS()\n return res\nmod = 998244353\ninf = float('INF')\n\n#solve\ndef solve():\n n, m = LI()\n fact = [i for i in range(m + 1)]\n fact[0] = 1\n for i in range(m):\n fact[i + 1] *= fact[i]\n fact[i + 1] %= mod\n invfact = [None] * (m + 1)\n invfact[m] = pow(fact[m], mod - 2, mod)\n for i in range(m - 1, 0, -1):\n invfact[i] = invfact[i + 1] * (i + 1)\n invfact[i] %= mod\n def com(n, k):\n if n < 0 or k < 0 or n < k: return 0\n if n == 0 or k == 0 or n == k: return 1\n return (fact[n] * invfact[k] * invfact[n - k]) % mod\n ans = com(m, n - 1)\n tmp = 0\n for i in range(1, n - 1):\n tmp += com(n - 2, i) * i\n tmp %= mod\n ans = ans * tmp % mod\n print(ans)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "mod = 998244353\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n\np = mod\nN = 5 * 10 ** 5 # N \u306f\u5fc5\u8981\u5206\u3060\u3051\u7528\u610f\u3059\u308b\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\n\nn, m = map(int, input().split())\nres = 0\nimport math\nif n == 2:\n print(0)\nelse:\n for i in range(n-1, m+1):\n res += (i - 1) * cmb(i - 2, n - 3, mod) * pow(2, n-3, mod)\n res %= mod\n print(res)\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nfrom collections import *\n\nMAX = 2*10**5+100\nMOD = 998244353\nfact = [0]*MAX #fact[i]: i!\ninv = [0]*MAX #inv[i]: i\u306e\u9006\u5143\nfinv = [0]*MAX #finv[i]: i!\u306e\u9006\u5143\nfact[0] = 1\nfact[1] = 1\nfinv[0] = 1\nfinv[1] = 1\ninv[1] = 1\n \nfor i in range(2, MAX):\n fact[i] = fact[i-1]*i%MOD\n inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD\n finv[i] = finv[i-1]*inv[i]%MOD\n\ndef C(n, r):\n if n<r:\n return 0\n if n<0 or r<0:\n return 0\n return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD\n\nn, m = map(int, input().split())\nans = 0\nt = 0\n\nfor k in range(1, n-1):\n t += C(n-2, k)*k\n t %= MOD\n\nfor a in range(n-1, m+1):\n ans += C(a-1, n-2)*t\n ans %= MOD\n\nprint(ans)"}, {"source_code": "MOD = 998244353\nMAXM = 2 * 10**5\nfact = [1] * (MAXM + 1)\nfor i in range(1, MAXM + 1):\n fact[i] = (i * fact[i - 1]) % MOD\ndef inv(a, p):\n res = 1\n p -= 2\n for i in range(32):\n if p % 2:\n res *= a\n res %= MOD\n a = (a * a) % MOD\n p //= 2\n return res\ndef C(n, m):\n if m > n:\n return 0\n numerator = fact[n]\n denominator = inv((fact[m] * fact[n - m]) % MOD, MOD)\n return (numerator * denominator) % MOD\nn, m = map(int, input().split())\nans = 0\nfor i in range(1, n - 1):\n delta = (C(m, n - 1) * C(n - 2, i)) % MOD\n delta = (delta * i) % MOD\n ans += delta\nprint(ans % MOD)\n"}, {"source_code": "from sys import stdin,stdout #\nimport math #\nimport heapq #\n #\nt = 1 #\ndef aint(): #\n\treturn int(input().strip()) #\ndef lint(): #\n\treturn list(map(int,input().split())) #\ndef fint(): #\n\treturn list(map(int,stdin.readline().split())) #\n #\t\n########################################################\nfact=[1]\nMOD=998244353\nfor i in range(1,200002):\n\tfact.append((fact[-1]*i)%MOD)\ndef modinv(n):\n\treturn pow(n,MOD-2,MOD)\ndef main():\n\tn,m=lint()\n\tif n==2:\n\t\tprint(0)\n\telse:\n\t\tprint((fact[m]*modinv(fact[n-1])*modinv(fact[m-n+1])*pow(2,n-3,MOD)*(n-2))%MOD)\n\nt=1\n\n########################################################\nfor i in range(t): #\n\tmain() #"}, {"source_code": "import sys\nmod=998244353\nfact=[1 for _ in range(200006)]\nfor i in range(1,200005):\n fact[i]=(fact[i-1]*i)%mod\ndef modinv(a,mod):\n return pow(a,mod-2,mod)\nn,m=map(int,sys.stdin.readline().split())\nif n==2:\n print(0)\nelse:\n ans=(fact[m]*modinv(fact[n-1],mod)*modinv(fact[m-n+1],mod))%mod\n ans=ans*(n-2)\n ans=ans%mod\n ans=ans*pow(2,n-3,mod)%mod\n print(ans)\n"}, {"source_code": "MOD = 998244353\nBIG = 1000000\nfac = [1] * BIG\nfor i in range(1, BIG):\n fac[i] = (i*fac[i-1])%MOD\n\ndef choose(n,k):\n return (fac[n]*pow((fac[k]*fac[n-k])%MOD,MOD-2,MOD))%MOD\n\nn,m = map(int, input().split())\nif n == 2:\n print(0)\nelse:\n print((choose(m,n-1) * (n-2) * pow(2,n-3,MOD)) % MOD)"}, {"source_code": "import math\ndef ncr(n, r, p): \n # initialize numerator \n # and denominator \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, p - 2, p)) % p \n#q=int(input())\nq=1\nfor _ in range(q):\n n,m=map(int,input().split())\n p=998244353\n ans=ncr(m,n-1,p)\n power=1\n for i in range(n-3):\n power=(power*2)%p\n ans=(ans*power)%p \n ans=(ans*(n-2))%p\n print(ans%p)\n \n \n "}, {"source_code": "def power(x, a):\n if(a<=0):\n return(1)\n z=power(x, a//2)\n z=(z*z)%998244353\n if(a%2):\n z=(z*x)%998244353\n return(z)\n\ndef ncr(n, r):\n fact=[1]\n for i in range(1, n+1):\n fact.append((i*fact[i-1])%998244353) \n return(fact[n]*power(fact[r],998244351)*power(fact[n-r],998244351))\n[n, m]=list(map(int, input().split()))\nans=(ncr(m, n-1)*(n-2))%998244353\nans=(ans*power(2, n-3))%998244353\nprint(ans)\n"}, {"source_code": "import sys\n\ndef c(n1, k1, mod1):\n num = den = 1\n for i in range(n1 - k1):\n num = (num * (n1 - i)) % mod1\n den = (den * (i + 1)) % mod1\n return (num * pow(den, mod1 - 2, mod1)) % mod1\n\ndef solve_of_problem():\n n, m = [int(x) for x in sys.stdin.readline().strip().split()]\n if n == 2:\n print(0)\n else:\n print(c(m, n - 1, mod) * ((n - 2) % mod) * pow(2, n - 3, mod) % mod)\n return\n\nmod = 998244353\nsolve_of_problem()\n"}, {"source_code": "# Python3 function to \n# calculate nCr % p \ndef ncr(n, r, p): \n\tnum = den = 1\t\n\tfor i in range(r): \n\t\tnum = (num * (n - i)) % p \n\t\tden = (den * (i + 1)) % p\n\tnum = (num *( r - 1)) % p\n\tfor i in range (r-2):\n\t num = (num * 2) % p\n\treturn (num * pow(den, \n\t\t\tp - 2, p)) % p \n\n# p must be a prime \n# greater than n \n\nn,m= map(int, input().split())\nprint(ncr(m, (n-1),998244353 )) \n"}, {"source_code": "import math\nmod=998244353\nfact=[1]\nn,m=map(int,input().split(' '))\nfor i in range(1,m+1):\n\tfact.append((fact[-1]*i)%mod)\nans=(n-2)*fact[m]*pow(fact[n-1]*fact[m-n+1],mod-2,mod)*pow(2,n-3,mod)\nprint(ans%mod)"}, {"source_code": "n,m=map(int,input().split())\nM=998244353\nf=[1]\nfor i in range(m):f+=[f[-1]*(i+1)%M]\nprint((n-2)*\n pow(2,n-3,M)*\n f[m]*\n pow(f[n-1]*f[m-n+1],M-2,M)%M\n )"}, {"source_code": "#!/usr/bin/env python3\n\nimport sys\nfrom math import *\nfrom collections import defaultdict\nfrom queue import deque # Queues\nfrom heapq import heappush, heappop # Priority Queues\nM = 998244353\n\n# parse\nlines = [line.strip() for line in sys.stdin.readlines()]\nn, m = list(map(int, lines[0].split()))\n\n# mod inv\ndef gcdext(a, b):\n if a == 0:\n return b, 0, 1\n gcd, x, y = gcdext(b % a, a)\n return gcd, y - (b//a) * x, x\n\ndef modinv(a):\n g, x, y = gcdext(a, M)\n assert(g == 1)\n return x % M\n\n# precompute\nfacts = [1]\nfactinvs = [1]\npows = [1]\nfor i in range(1, m+1):\n facts += [facts[-1] * i % M]\n pows += [pows[-1] * 2 % M]\n factinvs += [factinvs[-1] * modinv(i) % M]\n\ndef choose(a, b):\n if a < b or b < 0:\n return 0\n if b == 0:\n return 1\n if b == 1:\n return a\n return facts[a] * factinvs[b] % M * factinvs[a-b] % M\n\nret = 0\nfor k in range(n-1, m+1):\n ret = (ret + choose(k-1, 1) * choose(k-2, n-3) % M * pows[n-3]) % M\nprint(ret)\n"}, {"source_code": "def binpow(a, b, MOD):\n if (b == 0):\n return 1\n\n res = binpow(a, b//2, MOD)\n if (b % 2 == 0):\n return ((res % MOD) * (res % MOD)) % MOD\n\n return ((((res % MOD) * (res % MOD)) % MOD) * (a % MOD)) % MOD\n\n\ndef inverse(val, M):\n return binpow(val, M-2, M)\n\n\ndef C(n, m, f, MOD):\n num = f[m]\n denum = (f[n] * f[m-n]) % MOD\n denum = inverse(denum, MOD)\n return (num * denum) % MOD\n\n\ndef solve():\n MOD = 998244353\n n, m = map(int, input().split())\n pow = [1 for _ in range(n)]\n f = [1 for _ in range(m+1)]\n for i in range(1, n):\n pow[i] = (pow[i-1] * 2) % MOD\n\n for i in range(2, m+1):\n f[i] = (f[i-1] * i) % MOD\n mtp1 = (C(n-1, m, f, MOD) * (n-2)) % MOD\n mtp2 = pow[n-3]\n ans = (mtp1 * mtp2) % MOD\n print(ans)\n\n\nsolve()\n"}, {"source_code": "mod = 998244353\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n\np = mod\nN = 5 * 10 ** 5 # N \u306f\u5fc5\u8981\u5206\u3060\u3051\u7528\u610f\u3059\u308b\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\n\nn, m = map(int, input().split())\nif n == 0:\n print(0)\nelse:\n res = 0\n import math\n for i in range(n-1, m+1):\n cres = 1\n cres *= (i - 1)\n res %= mod\n cres *= cmb(i - 2, n - 3, mod)\n res %= mod\n cres *= pow(2, n-3, mod)\n res += cres\n res %= mod\n print(res)\n"}, {"source_code": "from bisect import bisect_left as bl, bisect_right as br, insort\nimport sys\nimport heapq\nfrom collections import defaultdict as dd, deque\ndef data(): return sys.stdin.readline().strip()\ndef mdata(): return map(int, data().split())\n#sys.setrecursionlimit(100000)\n\nmod=998244353\n\ndef fac(x):\n f=1\n for i in range(2,x+1):\n f=(f*i)%mod\n return f\nn,m=mdata()\nans=(fac(m)*(n-2)*pow(2,n-3,mod))*pow(fac(n-1),mod-2,mod)*pow(fac(m-n+1),mod-2,mod)\nprint(ans%mod)"}, {"source_code": "printn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\ndef modinv2(x,r):\n return pow(x,r-2,r)\n\ndef comb(n,a,R):\n dend = 1\n for i in range(a):\n dend = (dend*(n-i))%R\n sor = 1\n for i in range(2,a+1):\n sor = (sor*i)%R\n return (dend*modinv2(sor,R))%R\n\nn,m = inm()\nif n==2:\n print(0)\n exit()\nprint((comb(m,n-1,R)*(n-2)*pow(2,n-3,R))%R)\n"}, {"source_code": "import sys\nmod = 998244353\nsys.setrecursionlimit(pow(10, 8))\n\ndef power(x, y):\n if y == 0: return 1\n elif y == 1\t : return x % mod\n elif y % 2 == 0 : return power(x, y//2)**2 % mod\n else: return power(x, (y-1)//2)**2 * x % mod\ndef mul(a, b):\n return ((a % mod) * (b % mod)) % mod\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nNNN = (2*10**5)\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\n\nfor i in range( 2, NNN + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nN, M = map(int, input().split())\nif N == 2:\n print(0)\nelse:\n print(mul(mul(cmb(M, N-1, mod), power(2, N-3)), N-2))\n"}, {"source_code": "import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef SI(): return sys.stdin.readline()[:-1]\n\nclass mint:\n def __init__(self, x):\n self.__x = x % md\n\n def __str__(self):\n return str(self.__x)\n\n def __neg__(self):\n return mint(-self.__x)\n\n def __add__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x + other)\n\n def __sub__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x - other)\n\n def __rsub__(self, other):\n return mint(other - self.__x)\n\n def __mul__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x * other)\n\n __radd__ = __add__\n __rmul__ = __mul__\n\n def __truediv__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x * pow(other, md - 2, md))\n\n def __rtruediv__(self, other):\n return mint(other * pow(self.__x, md - 2, md))\n\n def __pow__(self, power, modulo=None):\n return mint(pow(self.__x, power, md))\n\nmd = 998244353\n\ndef nCr(com_n, com_r):\n if com_n < com_r: return 0\n return fac[com_n] * ifac[com_r] * ifac[com_n - com_r]\n\nn_max = 200000\nfac = [mint(1)]\nfor i in range(1, n_max + 1): fac.append(fac[-1] * i)\nifac = [mint(1)] * (n_max + 1)\nifac[n_max] /= fac[n_max]\nfor i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1)\n\ndef main():\n n,m=MI()\n ans=nCr(m,n-1)*(n-2)*pow(2,n-3,md)\n print(ans)\n\nmain()"}, {"source_code": "\ndef ncr(n, r, p):\n # initialize numerator\n # and denominator\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\n\n\n# p must be a prime\n# greater than n\n# n, r, p = 10, 2, 13\n# print(\"Value of nCr % p is\",\n# \t\t\tncr(n, r, p))\n\nn, m = map(int, input().split())\np = 998244353\n\nans = ncr(m, n - 1, p)\n\nans = (ans * (n - 2) % p) % p\nfor i in range(n - 3):\n ans = (ans * 2) % p\nprint(ans)"}, {"source_code": "from math import factorial\n\n\ndef factorial(x, mod):\n r = 1;\n while x > 1:\n r *= x\n r %= mod\n x -= 1\n return r\n\n\ndef xgcd(a, b):\n if (b == 0): return a, 1, 0\n gcd, x, y = xgcd(b, a % b)\n y1 = x - (a // b) * y\n return gcd, y, y1\n\n\ndef inverse(a, mod):\n return xgcd(a, mod)[1]\n\n\n# number of different elements = n-1\n# options for element choice = binom(m, n-1)\n# options for duplicate element = n - 2\n# 2 options for position of all elements except duplicate element and element i (n -3)\n\ndef solve(n, m, mod):\n result = n - 2 # options for duplicate element\n result %= mod\n if result == 0: return 0\n \n for duplicate in range(n - 3): # positions of elements\n result *= 2\n result %= mod\n if result == 0: return 0\n\n # times binom(m, n-1)\n result *= factorial(m, mod)\n result %= mod\n if result == 0: return 0\n\n result *= inverse(factorial(n - 1, mod), mod)\n result %= mod\n if result == 0: return 0\n\n result *= inverse(factorial(m - n + 1, mod), mod)\n result %= mod\n \n return result\n \n\nn, m = (int(x) for x in input().split(\" \"))\nprint(solve(n, m, 998244353))\n"}, {"source_code": "MOD = 998244353\n\ndef factorial(n):\n prod = 1\n\n for i in range(1, n + 1):\n prod *= i\n prod %= MOD\n \n return prod\n\ndef fastExp(base, exp):\n if exp == 0:\n return 1\n \n ans = fastExp(base, exp // 2)**2\n\n if exp % 2 == 1:\n ans *= base\n\n return ans % MOD\n\ndef modularInverse(n):\n return fastExp(n, MOD - 2)\n\ndef nChooseK(n, k):\n return factorial(n) * modularInverse(factorial(k)) * modularInverse(factorial(n - k))\n\nn, m = [int(i) for i in input().split()]\n\nif n == 2:\n print(0)\nelse:\n print(nChooseK(m, n - 1) * (n - 2) * fastExp(2, n - 3) % MOD)"}, {"source_code": "ma=998244353\nn,m=map(int,input().split())\nfact=[1]\nfor i in range(1,m+1):\n fact.append(fact[-1]*i%ma)\nans=fact[m]*(pow(fact[n-1]*fact[m-n+1],ma-2,ma))*(n-2)*pow(2,n-3,ma)%ma\nprint(ans)"}, {"source_code": "# cook your dish here\nimport sys,math\n \ndef nCr(n, r, p): \n # initialize numerator \n # and denominator \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den,p - 2, p)) % p \n\n\ndef ip():\n \n n,m=map(int,input().split())\n ans=0\n mod=998244353\n ans=nCr(m,n-1,mod)\n mul=pow(2,n-3,mod)\n \n print((ans*mul%mod)*(n-2)%mod)\nip()"}, {"source_code": "def ncr(n, r, p): \n num = den = 1 \n for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p \n return (num * pow(den,p - 2, p)) % p \nn,m=map(int,input().split());p=998244353 ;print((ncr(m,n-1,p)*(n-2)*pow(2,max((n-3),0),p))%p)"}, {"source_code": "n, m = map(int, input().split())\nM = 998244353\nf = [1]\nfor i in range(1, m+1):\n\tf.append((f[-1] * i) % M)\nr = (((n-2) * pow(2, n-3, M)) % M) * ((f[m] * pow((f[n-1] * f[m-n+1]) % M, -1, M)) % M)\nprint(r % M)"}, {"source_code": "n , m = [ int(x) for x in input().split() ]\nmod = 998244353\nf = [ 1 for i in range(200002) ]\nfor i in range(1,200002):\n f[i] = (f[i-1]*i)%mod\n\ndef C ( x , y ) :\n if x >= y and y >= 0 :\n ans = f [ x ] * pow ( f [ x - y ] , mod - 2 , mod ) \n ans %= mod \n return ( ans * pow ( f [ y ] , mod - 2 , mod ) ) % mod\n return 0\n\nif n == 2 :\n print(0)\nelse:\n c = C ( m , n - 1 )\n c = c * ( n - 2 ) * pow ( 2 , n - 3 , mod )\n c = c % mod \n print ( c )"}, {"source_code": "M=998244353\nn,m=map(int,input().split())\nf=[1]\nfor i in range(m):f+=f[-1]*(i+1)%M,\nprint((n-2)*pow(2,n-3,M)*f[m]*pow(f[n-1]*f[m-n+1],M-2,M)%M)"}, {"source_code": "n, m = map(int, input().split())\n \nif n == 2:\n\tprint(0)\n\texit()\n \nmod = 998244353 \nans = ((n-2) * pow(2, n-3, mod)) % mod\n# print(ans)\nfor i in range(m-n+2, m+1):\n\tans = (ans * i) % mod\n# print(ans)\nfact = 1\nfor i in range(2, n):\n\tfact = (fact*i) % mod\n \nfact = pow(fact, mod-2, mod)\nans = (ans * fact) % mod\n \nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\n\nif n == 2:\n\tprint(0)\n\texit()\n\nmod = 998244353 \nans = ((n-2) * pow(2, n-3, mod)) % mod\n# print(ans)\nfor i in range(m-n+2, m+1):\n\tans = (ans * i) % mod\n# print(ans)\nfact = 1\nfor i in range(2, n):\n\tfact = (fact*i) % mod\n\nfact = pow(fact, mod-2, mod)\nans = (ans * fact) % mod\n\nprint(ans)"}, {"source_code": "#!python3\n\"\"\"\nAuthor: w1ld [at] inbox [dot] ru\n\"\"\"\n\nfrom collections import deque, Counter\nimport array\nfrom itertools import combinations, permutations\nfrom math import sqrt, factorial\n# import unittest\n\n\ndef read_int():\n return int(input().strip())\n\n\ndef read_int_array():\n return [int(i) for i in input().strip().split(' ')]\n\n######################################################\n\nMOD = 998244353\n\ndef binpow(a, n, mod):\n if n == 0:\n return 1\n if n == 1:\n return a\n if n % 2 == 1:\n return binpow(a, n - 1, mod) * a % mod\n b = binpow(a, n // 2, mod)\n return b * b % mod\n\n\ndef comb(n, k):\n x = 1\n for i in range(n-k+1, n+1):\n x = (x * i) % MOD\n\n y = 1\n for i in range(2, k+1):\n y = (y * i) % MOD\n\n y = binpow(y, MOD-2, MOD)\n\n return x * y % MOD\n\n\ndef mypow(a, x):\n return a ** x % MOD\n\n\ndef solve():\n n, m = read_int_array()\n if n == 2:\n print(0)\n return\n\n ans = comb(m, n - 1)\n ans = (ans * (n - 2)) % MOD\n ans = (ans * mypow(2, n - 3)) % MOD\n\n print(int(ans))\n\n\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "M=998244353\nn,m=map(int,input().split())\nf=[]\nf.append(1)\nfor i in range(1,m+1):\n f.append( (f[i-1]*i)%M )\nprint( ( (f[m]*pow(f[n-1]*f[m-n+1],M-2,M)) * (n-2) * pow(2,n-3,M) ) %M )\n"}, {"source_code": "M=998244353\nn,m=map(int,input().split())\nf=[]\nf.append(1)\nfor i in range(1,m+1):\n f.append( (f[i-1]*i)%M )\nprint( ( (f[m]*pow(f[n-1]*f[m-n+1],M-2,M)) * (n-2) * pow(2,n-3,M) ) %M )\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\nclass FactMod():\n def __init__(self, n, mod):\n self.mod = mod\n self.f = [1]*(n+1)\n for i in range(1, n+1):\n self.f[i] = self.f[i-1]*i % mod\n\n self.inv = [pow(self.f[-1], mod-2, mod)]\n for i in range(1, n+1)[::-1]:\n self.inv.append(self.inv[-1]*i % mod)\n self.inv.reverse()\n\n def comb(self, n, r):\n ret = self.f[n] * self.inv[n-r]*self.inv[r]\n ret %= self.mod\n return ret\n\n\nN, M = map(int, input().split())\n\nMOD = 998244353\nF = FactMod(M, MOD)\n\nif N == 2:\n print(0)\nelse:\n ans = F.comb(M, N-1)*(N-2)*pow(2, N-3, MOD) % MOD\n print(ans)\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\ndef fastio():\n from io import StringIO\n from atexit import register\n global input\n sys.stdin = StringIO(sys.stdin.read())\n input = lambda : sys.stdin.readline().rstrip('\\r\\n')\n sys.stdout = StringIO()\n register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))\nfastio()\n\nINF = 10**20\nMOD = 998244353\nI = lambda:list(map(int,input().split()))\nfrom math import gcd\nfrom math import ceil\nfrom collections import defaultdict as dd, Counter\nfrom bisect import bisect_left as bl, bisect_right as br\n\nn, m = I()\nif n > m + 1:\n print(0)\n exit()\n\nMAXN = 300000\nf = [1] * MAXN\nfor i in range(1, MAXN):\n f[i] = i * f[i - 1]\n f[i] %= MOD\n\ndef inverse(k):\n return pow(k, MOD - 2, MOD)\n\ndef nCk(n, k):\n if k > n:\n return 0\n return (f[n] * inverse(f[n - k]) * inverse(f[k])) % MOD\n\nans = nCk(m, n - 1)\nans = (ans * pow(2, n - 3, MOD) * (n - 2)) % MOD\n\nprint(ans % MOD)\n\n"}, {"source_code": "n, m = map(int, input().split())\nif n == 2:\n\tprint(0)\n\texit()\nmod = 998244353 \nans = ((n-2) * pow(2, n-3, mod)) % mod\n# print(ans)\nfor i in range(m-n+2, m+1):\n\tans = (ans * i) % mod\n# print(ans)\nfact = 1\nfor i in range(2, n):\n\tfact = (fact*i) % mod\nfact = pow(fact, mod-2, mod)\nans = (ans * fact) % mod\nprint(ans)"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter, defaultdict\nfrom itertools import permutations, combinations\nfrom fractions import gcd\nimport heapq\nraw_input = stdin.readline\npr = stdout.write\nmod=998244353\n\ndef ni():\n return int(raw_input())\n\n\ndef li():\n return list(map(int,raw_input().split()))\n\n\ndef pn(n):\n stdout.write(str(n)+'\\n')\n\n\ndef pa(arr):\n pr(' '.join(map(str,arr))+'\\n')\n\n# fast read function for total integer input\n\ndef inp():\n # this function returns whole input of\n # space/line seperated integers \n # Use Ctrl+D to flush stdin.\n return tuple(map(int,stdin.read().split()))\n \nrange = xrange # not for python 3.0+\n\n# main code\n\ndef inv(x):\n return pow(x,mod-2,mod)\nn,m=li()\nif n==2:\n print 0\n exit()\nfac=[1]*(m+1)\nfor i in range(1,m+1):\n fac[i]=(i*fac[i-1])%mod\nans=(fac[m]*inv((fac[n-1]*fac[m-n+1])%mod))%mod\nans=(ans*(n-2))%mod\nans=(ans*pow(2,n-3,mod))%mod\npn(ans)\n \n \n \n"}, {"source_code": "from sys import stdin\n\n\ndef fact(be, en):\n res = 1\n for i in range(be, en + 1):\n res = mult(res, i)\n return res\n\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nmult = lambda a, b: ((a % mod) * (b % mod)) % mod\nmodinv = lambda a: pow(a, mod - 2, mod)\ndiv = lambda a, b: mult(a, modinv(b))\nncr = lambda n, r: div(fact(n - r + 1, n), fact(1, r))\nmod = 998244353\n\nn, m = rints()\nif n > 2:\n print(mult(mult(ncr(m, n - 1), n - 2), pow(2, n - 3, mod)))\nelse:\n print(0)\n"}, {"source_code": "\n \nfrom math import *\n\nn,m=map(int,input().split())\nans=0\nM=998244353 \n\ndef mul(x,y):\n\treturn (x*y)%M\n\ndef add(x,y):\n\treturn (x+y)%M\n\ndef p(x, y) : \n res = 1 \n x = x % M \n if (x == 0) : \n return 0\n \n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % M\n\n y = y >> 1 \n x = (x * x) % M\n return res \n\ndef div(x,y):\n\treturn mul(x,p(y,M-2))\n\nfact=[0]*(2*(10**5)+1)\nfact[0]=1\n\nfor i in range(1,len(fact)):\n\tfact[i]=mul(fact[i-1],i)\n\nans=div(fact[m],mul(fact[n-1],fact[m-n+1]))\nans=mul(ans,p(2,n-3))\nans=mul(ans,n-2)\nprint(ans)\n\n\n\n\n\n\t\n\n\n\n\n\n\n"}, {"source_code": "\"\"\"\n#If FastIO not needed, used this and don't forget to strip\n#import sys, math\n#input = sys.stdin.readline\n\"\"\"\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport heapq as h \nfrom bisect import bisect_left, bisect_right\n\nfrom types import GeneratorType\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n import os\n self.os = os\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n self.os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nfrom collections import defaultdict as dd, deque as dq\nimport math, string\n\n\ndef getInts():\n return [int(s) for s in input().split()]\n\ndef getInt():\n return int(input())\n\ndef getStrs():\n return [s for s in input().split()]\n\ndef getStr():\n return input()\n\ndef listStr():\n return list(input())\n\nMOD = 998244353\n\n\n\"\"\"\nIf N < 3, the answer is 0\n\nWe must have a max element, which is unique, and can be in any position from 2 to N-1 inclusive\nThere are N-1 *distinct* elements, so the max element can range from N-1 to M\n\nGiven the max element, we can then pick 1 number from 1 to max-1 inclusive and include it on boths sides\nWe can then choose N-3 numbers from the remaining max-2 numbers (max-2 choose N-3), and these can be placed in pow(2,N-3) ways each\n\nSo, answer is sum i=N-1 to M ( (i-1)*(max-2 choose N-3)*(pow(2,N-3) )\n\n\"\"\"\npows = [1]\ncurr = 1\nfor j in range(1,200001):\n curr *= 2\n curr %= MOD\n pows.append(curr)\n\nfacs = [1]\ncurr = 1\nfor j in range(1,200001):\n curr *= j\n curr %= MOD\n facs.append(curr)\n\ninv_facs = []\nfor j in range(200001):\n inv_facs.append(pow(facs[j],MOD-2,MOD))\n\n\ndef solve():\n N, M = getInts()\n if N == 2:\n return 0\n ans = 0\n for i in range(N-1,M+1):\n tmp = (i-1)\n tmp *= facs[i-2]\n tmp %= MOD\n #print(tmp)\n tmp *= inv_facs[N-3]\n tmp %= MOD\n #print(tmp)\n tmp *= inv_facs[i-N+1]\n tmp %= MOD\n #print(tmp)\n tmp *= pows[N-3]\n tmp %= MOD\n #print(tmp,i)\n ans += tmp\n ans %= MOD\n return ans\n \n#for _ in range(getInt()):\nprint(solve())\n"}, {"source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nimport bisect\nimport heapq\n# from math import *\nfrom collections import defaultdict as dd # defaultdict(<datatype>) Free of KeyError.\nfrom collections import deque # deque(list) append(), appendleft(), pop(), popleft() - O(1)\nfrom collections import Counter as c # Counter(list) return a dict with {key: count}\nfrom itertools import combinations as comb\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\n\n\ndef out(var): sys.stdout.write(var)\n\n\ndef l(): return list(map(int, data().split()))\n\n\ndef sl(): return list(map(str, data().split()))\n\n\ndef sp(): return map(int, data().split())\n\n\ndef ssp(): return map(str, data().split())\n\n\ndef l1d(n, val=0): return [val for i in range(n)]\n\n\ndef l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]\n\n\ndef fact(n):\n if n <= 1:\n dp[n] = 1\n return dp[n]\n if n in dp.keys():\n return dp[n]\n dp[n] = (n * fact(n-1)) % mod2\n return dp[n] % mod2\n\n\ndp = dict()\ninv = dict()\ninv[1] = 1\nfor i in range(1, 200001):\n dp[i] = fact(i)\n inv[i] = pow(dp[i], mod2-2, mod2)\n\nn, m = sp()\nif n == 2:\n out(\"0\")\n exit()\nif m < n-1:\n out(\"0\")\n exit()\npower = (pow(2, n-3, mod2) * (n-2)) % mod2\nmul = (dp[m] * inv[n-1] * inv[m-n+1]) % mod2\nout(str((mul * power) % mod2))\n"}, {"source_code": "MOD = 998244353\n\n\ndef add(x, y):\n x += y\n while(x >= MOD):\n x -= MOD\n while(x < 0):\n x += MOD\n return x\n\n\ndef mul(x, y):\n return (x * y) % MOD\n\n\ndef binpow(x, y):\n z = 1\n while(y):\n if(y & 1):\n z = mul(z, x)\n x = mul(x, x)\n y >>= 1\n return z\n\n\ndef inv(x):\n return binpow(x, MOD - 2)\n\n\ndef divide(x, y):\n return mul(x, inv(y))\n\n\nfact = []\nN = 200000\n\n\ndef precalc():\n fact.append(1)\n for i in range(N):\n fact.append(mul(fact[i], i + 1))\n\n\ndef C(n, k):\n return divide(fact[n], mul(fact[k], fact[n - k]))\n\n\nprecalc()\n\nNM = input()\n[N, M] = NM.split()\nN = int(N)\nM = int(M)\n\nres = 0\n\nif (N > 2):\n res = mul(C(M, N - 1), mul(N - 2, binpow(2, N - 3)))\n\n\nprint(res)\n"}, {"source_code": "n,m=[int(x) for x in input().split()]\n\n#observation: repeated element cannot be max element.\n#1 of the repeated element has to be on the left, and the other\n#on the right.\n#This is equivalent to choosing n-1 distinct elements, \n#then counting the #ways to pick left elements on left of max element, and choosing 1 left element to be repeated on the right.\n\nMOD=998244353\nMAX=m\nfact=[1]\nfor zz in range(1,MAX+1):\n fact.append(((fact[-1]%MOD)*zz%MOD)%MOD) #with MOD\ndef nCr(n,r): #choose, MOD is prime\n num=fact[n]\n den=((fact[r]%MOD)*(fact[n-r]%MOD))%MOD #with MOD\n return ((num%MOD)*pow(den,MOD-2,MOD))%MOD #with MOD\n\n#number of ways to choose n elements\nnWaysChooseElements=nCr(m,n-1)\n\n#number of ways to have left elements on the left of the max chosen element\nnWaysLeftElements=0\nfor left in range(1,n-1):\n nWaysLeftElements+=(nCr(n-2,left)*left)%MOD #left ways to pick the repeated element\n nWaysLeftElements%=MOD\nans=nWaysLeftElements*nWaysChooseElements\nans%=MOD\nprint(ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\nn, m = map(int, input().split())\nmod = 998244353\ndef euclidean(x, y):\n # assumes x, y != 0\n # Finding gcd and awins, b such that ax+by = gcd(x,y)\n stk = []\n while y:\n stk.append(x // y)\n (x, y) = (y, x % y)\n stk.pop()\n\n a, b = 0, 1\n for i in stk[::-1]:\n a, b = b, a - i * b\n return x, a, b\n\ndef comb(n, k, mod):\n k = min(k, n-k)\n if k == 0:\n return 1\n top, bot = n, 1\n for i in range(1, k):\n bot = bot * (i+1) % mod\n top = top * (n-i) % mod\n _, inv, _ = euclidean(bot, mod)\n return top * inv % mod\nif n == 2:\n ans = 0\nelse:\n ans = comb(m, n-1, mod) * (n-2) * pow(2, n-3, mod) % mod\nprint(ans)"}, {"source_code": "import math\n\ndef ncr(n, r, p): \n\tnum = den = 1\n\tfor i in range(r): \n\t\tnum = (num * (n - i)) % p \n\t\tden = (den * (i + 1)) % p \n\treturn (num * pow(den, \n\t\t\tp - 2, p)) % p \n\nn,m=map(int,input().split())\np=998244353\nans=0\nif(n==2) :\n ans=0\nelse :\n ans=((ncr(m,n-1,p)%p)*((n-2)%p)*(pow(2,n-3,p)%p))%p\nprint(ans)"}, {"source_code": "def ncr(n, r, p): \n # initialize numerator \n # and denominator \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den,p - 2, p)) % p \nmod=998244353 \nn,m=map(int,input().split())\nif n>2:\n ans=ncr(m,n-1,mod)\n ans=ans*(n-2)\n ans=ans%mod\n ans=ans*pow(2,n-3,mod)\n ans=ans%mod\n print(ans)\nelse:\n ans=m%mod\n print(0)"}], "negative_code": [{"source_code": "def nCr(m, n):\n prod, prod1, prod2 = 1, 1, 1\n for i in range(2, m+1):\n prod*=i\n if(i==n):\n prod1=prod\n elif(i==m-n):\n prod2=prod\n return(prod//(prod1*prod2))\n[n, m]=list(map(int, input().split()))\nans=(nCr(m, n-1)*(n-2)*(2**(n-3)))\nprint(ans%998244353)\n"}, {"source_code": "#!/usr/bin/env python3\n\nimport sys\nfrom math import *\nfrom collections import defaultdict\nfrom queue import deque # Queues\nfrom heapq import heappush, heappop # Priority Queues\nM = 998244353\ninvcache = {}\n\n# parse\nlines = [line.strip() for line in sys.stdin.readlines()]\nn, m = list(map(int, lines[0].split()))\n\n# precompute\nfacts = [1]\npows = [1]\nfor i in range(1, m+1):\n facts += [facts[-1] * i % M]\n pows += [pows[-1] * 2 % M]\n\n# mod inv\ndef gcdext(a, b):\n if a == 0:\n return b, 0, 1\n gcd, x, y = gcdext(b % a, a)\n return gcd, y - (b//a) * x, x\n\ndef modinv(a):\n if a in invcache:\n return invcache[a]\n \n g, x, y = gcdext(a, M)\n assert(g == 1)\n x %= M\n invcache[a] = x\n return x\n\ndef choose(a, b):\n if a < b:\n return 0\n if b == 0:\n return 1\n if b == 1:\n return a\n return facts[a] * modinv(facts[b]) % M * modinv(facts[a-b]) % M\n\nret = 0\nfor k in range(n-1, m+1):\n ret = (ret + choose(k-1, 1) * choose(k-2, n-3) % M * pows[n-3]) % M\nprint(ret)\n"}, {"source_code": "M=998244353\nf=[1]\nfor i in range(4**9):f+=f[-1]*(i+1)%M,\nn,m=map(int,input().split())\nn-=3\nprint((n>=0)*pow(2,n,M)*sum(k*f[k]*pow(f[n]*f[k-n],M-2,M)for\nk in range(n+1,m))%M)"}, {"source_code": "import operator as op\nfrom functools import reduce\np = 998244353 \ndef C(n, r):\n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, p - 2, p)) % p \n\nif __name__ == '__main__':\n \n n, m = map(int, input().split())\n \n res = C(m, n - 1) \n res *= (n - 2) * (2 ** (n - 3) ) \n print (res % p)\n\n "}, {"source_code": "def power(a, n, mod):\n bi=str(format(n,\"b\")) #2\u9032\u6570\n res=1\n for i in range(len(bi)):\n res=(res*res) %mod\n if bi[i]==\"1\":\n res=(res*a) %mod\n return res\n\ndef cmb1(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 998244353 #\u51fa\u529b\u306e\u5236\u9650\nN = 10**6\ng1 = [1, 1] # \u5143\u30c6\u30fc\u30d6\u30eb\ng2 = [1, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\ninverse = [0, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\u8a08\u7b97\u7528\u30c6\u30fc\u30d6\u30eb\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nn, m = map(int, input().split())\nmod = 998244353\nans = 0\nif n == 2:\n print(m)\n exit()\n\nfor i in range(n-1, m+1):\n ans += cmb1(i-1, n-2, mod)*(n-2)*power(2, n-3, mod)\n ans %= mod\nans %= mod\nprint(ans)\n"}, {"source_code": "def power(a, n, mod):\n bi=str(format(n,\"b\")) #2\u9032\u6570\n res=1\n for i in range(len(bi)):\n res=(res*res) %mod\n if bi[i]==\"1\":\n res=(res*a) %mod\n return res\n\ndef cmb1(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 998244353 #\u51fa\u529b\u306e\u5236\u9650\nN = 10**6\ng1 = [1, 1] # \u5143\u30c6\u30fc\u30d6\u30eb\ng2 = [1, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\ninverse = [0, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\u8a08\u7b97\u7528\u30c6\u30fc\u30d6\u30eb\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nn, m = map(int, input().split())\nmod = 998244353\nans = 0\nif n == 2:\n print(m%mod)\n exit()\n\nfor i in range(n-1, m+1):\n ans += cmb1(i-1, n-2, mod)*(n-2)*power(2, n-3, mod)\n ans %= mod\nans %= mod\nprint(ans)\n"}, {"source_code": "n,m=map(int,input().split())\nmd=998244353\n\ndef ncr(n, r, p): \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, \n p - 2, p)) % p \nif(n==2):\n print(n)\nelse:\n ans1=1\n for i in range(n-3):\n ans1*=2\n ans1%=md\n ans1=(ans1%md * (n-2)%md)%md\n t=ncr(m,n-1,md)\n ans1=(ans1%md *t%md)%md\n print(ans1)\n \n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Jul 7 16:08:14 2020\n\n@author: Dell\n\"\"\"\n\n\nn,m=list(map(int,input().split()))\nmod=998244353\n\n#print(math.factorial(m)//(math.factorial(n-1)*math.factorial(m-n+1)))\nif n>2:\n l=n-1\n c,d,u=[1],[1],[1]\n for i in range(1,l+1):\n c.append((c[-1]*(m-i+1))%mod)\n d.append((d[-1]*i)%mod)\n u.append(c[-1]*pow(d[i],mod-2,mod))\n p=u[l]\n print(((pow(2,n-3))*(n-2)*p)%mod)\nelse:\n print(m*(m-1))\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Jul 7 16:08:14 2020\n\n@author: Dell\n\"\"\"\n\n\nn,m=list(map(int,input().split()))\nmod=998244353\nl=n-1\nc,d,u=[1],[1],[1]\nfor i in range(1,l+1):\n c.append((c[-1]*(m-i+1))%mod)\n d.append((d[-1]*i)%mod)\n u.append(c[-1]*pow(d[i],mod-2,mod))\np=u[l]\n#print(math.factorial(m)//(math.factorial(n-1)*math.factorial(m-n+1)))\nprint(((pow(2,n-3))*(n-2)*p)%mod)\n"}, {"source_code": "#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)\n#from bisect import bisect_right as br #c++ upperbound br(array,element)\n#from __future__ import print_function, division #while using python2\n\nimport math\n\ndef modinv(n,p):\n return pow(n,p-2,p)\n\nimport operator as op\nfrom functools import reduce\n\ndef ncr(n, r, mod):\n a = min(r, n-r)\n b = max(r, n-r)\n\n num = 1\n den = 1\n for i in range(b+1, n+1):\n num = (num * i)%mod \n for i in range(1, a+1):\n den = (den * i)%mod\n \n return ((num % mod)*modinv(den, mod))%mod\n\ndef main():\n #sys.stdin = open('input.txt', 'r')\n #sys.stdout = open('output.txt', 'w')\n\n n, m = [int(x) for x in input().split()]\n\n mod = 998244353\n k = ncr(m, n-1, mod) % mod \n # print(k)\n if n > 2:\n k = (k * (n-2))%mod\n for i in range(n-3):\n k = (k * 2) % mod\n else:\n pass\n print(k)\n\n\n\n#------------------ Python 2 and 3 footer by Pajenegod and c1729-----------------------------------------\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)\n#from bisect import bisect_right as br #c++ upperbound br(array,element)\n#from __future__ import print_function, division #while using python2\n\nimport math\n\ndef modinv(n,p):\n return pow(n,p-2,p)\n\nimport operator as op\nfrom functools import reduce\n\ndef ncr(n, r, mod):\n a = min(r, n-r)\n b = max(r, n-r)\n\n num = 1\n den = 1\n for i in range(b+1, n+1):\n num = (num * i)%mod \n for i in range(1, a+1):\n den = (den * i)%mod\n \n return ((num % mod)*modinv(den, mod))%mod\n\ndef main():\n #sys.stdin = open('input.txt', 'r')\n #sys.stdout = open('output.txt', 'w')\n\n n, m = [int(x) for x in input().split()]\n\n if m == 2:\n print(0)\n return\n\n mod = 998244353\n k = ncr(m, n-1, mod) % mod \n # print(k)\n if n > 2:\n k = (k * (n-2))%mod\n for i in range(n-3):\n k = (k * 2) % mod\n else:\n pass\n print(k)\n\n\n\n#------------------ Python 2 and 3 footer by Pajenegod and c1729-----------------------------------------\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nimport sys\nreader = (s.rstrip() for s in sys.stdin)\ninput = reader.__next__\na,b=list(map(int,input().split()))\nmod=998244353\nres=1\nfor i in range(1,b+1):\n res=res*i%mod\nfor i in range(1,a):\n res=res//i%mod\nfor i in range(1,b-a+2):\n res=res//i%mod \nina=res%998244353\nina=ina*pow(1,mod-2)%mod*(a-2)%mod\nina=ina*pow(2,a-3)%mod\nprint(ina)\n"}, {"source_code": "import math\nimport sys\nreader = (s.rstrip() for s in sys.stdin)\ninput = reader.__next__\na,b=list(map(int,input().split()))\nmod=998244353\ndef powmod(num1,num2):\n res=1\n num1%=mod\n while num2:\n print(num2)\n if num2&1:\n res=res*num1%mod\n num1=num1*num1%mod\n num2>>=1\n return res\n\n\nres=(math.factorial(b)//((math.factorial(a-1))*math.factorial(b-a+1)%mod))%mod\nres=res*(a-2)%mod\nres=res*(2**(a-3))%mod\n\nprint(res)\n"}, {"source_code": "MOD = 998244353\n\ndef C(n, r):\n num = den = 1\n\n for i in range(r):\n num = (num * (n - i)) % MOD\n den = (den * (i + 1)) % MOD\n\n return (num * pow(den, MOD - 2, MOD)) % MOD\n\nn, m = map(int, input().split())\n\nans = C(m, n - 1) * (n - 2) * pow(2, n - 3)\n\nprint(ans % MOD)"}, {"source_code": "mod=998244353\nn,m=map(int,input().split())\nfac=[1]\ninvfac=[0]\nif n!=2:\n for i in range(1,m+1):\n fac.append((fac[-1]*i)%mod)\n invfac.append(0)\n invfac[-1]=pow(fac[-1],mod-2,mod)\n for i in range(m-1,-1,-1):\n invfac[i]=(invfac[i+1]*(i+1))%mod\n print((((fac[m]*invfac[m-n+1]*invfac[n-1])%mod)*(n-2)*pow(2,n-3,mod))%mod)\nelse:\n print((m*(m-1))%mod)"}, {"source_code": "import math\nimport operator as op\nfrom functools import reduce\n\nN = 1000001\nfactorialNumInverse = [None] * (N + 1)\nnaturalNumInverse = [None] * (N + 1)\nfact = [None] * (N + 1)\ndef InverseofNumber(p):\n naturalNumInverse[0] = naturalNumInverse[1] = 1\n for i in range(2, N + 1, 1):\n naturalNumInverse[i] = (naturalNumInverse[p % i] *\n (p - int(p / i)) % p)\n\n\n\n\ndef InverseofFactorial(p):\n factorialNumInverse[0] = factorialNumInverse[1] = 1\n\n # precompute inverse of natural numbers\n for i in range(2, N + 1, 1):\n factorialNumInverse[i] = (naturalNumInverse[i] *\n factorialNumInverse[i - 1]) % p\n\n\ndef factorial(p):\n fact[0] = 1\n\n # precompute factorials\n for i in range(1, N + 1):\n fact[i] = (fact[i - 1] * i) % p\n\n\ndef Binomial(N, R, p):\n # n C r = n!*inverse(r!)*inverse((n-r)!)\n ans = ((fact[N] * factorialNumInverse[R]) % p *\n factorialNumInverse[N - R]) % p\n return ans\n\n\ndef power(x, y):\n if (y == 0):\n return 1\n elif (int(y % 2) == 0):\n return (power(x, int(y / 2)) *\n power(x, int(y / 2)))\n else:\n return (x * power(x, int(y / 2)) *\n power(x, int(y / 2)))\np = 998244353\nInverseofNumber(p)\nInverseofFactorial(p)\nfactorial(p)\n\n\n\n\n\n\na, b = map(int, input().split())\nif a==2:\n print(b)\nelse:\n m = Binomial(b, (a - 1), p)\n m = (m * (a - 2)) % 998244353\n q = int(power(2, (a - 3))) % 998244353\n print((m * q) % 998244353)\n\n\n\n\n"}, {"source_code": "def ncr(n, r, p): \n # initialize numerator \n # and denominator \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den,p - 2, p)) % p \nmod=998244353 \nn,m=map(int,input().split())\nif n>2:\n ans=ncr(m,n-1,mod)\n ans=ans*(n-2)\n ans=ans%mod\n ans=ans*pow(2,n-3,mod)\n ans=ans%mod\n print(ans)\nelse:\n ans=m%mod\n print(ans)"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \nM = mod = 998244353 \ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\ndef fact(n):\n pro = 1\n for i in range(2,n + 1):pro = pro*i%mod\n return pro\nn,m = li()\na = fact(m)\nb = fact(m - n + 1)\nc = fact(n - 1)\na = a*inv_mod(b*c%mod)*(n - 2)%mod\na = a*pow(2,n-3)%mod\nprint(a)"}, {"source_code": "from collections import Counter, OrderedDict\nfrom itertools import permutations as perm\nfrom collections import deque\nfrom sys import stdin\nfrom bisect import *\nfrom heapq import *\nimport math\n\ng = lambda : stdin.readline().strip()\ngl = lambda : g().split()\ngil = lambda : [int(var) for var in gl()]\ngfl = lambda : [float(var) for var in gl()]\ngcl = lambda : list(g())\ngbs = lambda : [int(var) for var in g()]\nmod = int(1e9)+7\ninf = float(\"inf\")\n\ndef ncr(n, r, p): \n # initialize numerator \n # and denominator \n num = den = 1 \n for i in range(r): \n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, \n p - 2, p)) % p \n\n\nn, m = gil()\n\nif n == 2:\n\tprint(m)\nelse:\n\tp = [1]*(n)\n\tmod = 998244353\n\tfor i in range(1, n):\n\t\tp[i] = (2*p[i-1])%mod\n\tprint((p[n-3]*ncr(m, n-1, mod)*(n-2))%mod)\n"}, {"source_code": "import math, collections, sys\ninput = sys.stdin.readline\ndef ncr(n, r, p):\n num = den = 1 \n for i in range(r):\n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, p - 2, p)) % p \nn, m = map(int, input().split())\nmod = 998244353\nif n == 2:\n ans = (m*(m-1)*2)%mod\n print(ans)\nelse:\n ans = ncr(m, n-1, mod)\n ans*=(n-2)\n ans%=mod\n ans*=pow(2, n-3, mod)\n ans%=mod\n print(ans)"}, {"source_code": "import math, collections, sys\ninput = sys.stdin.readline\ndef ncr(n, r, p):\n num = den = 1 \n for i in range(r):\n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, p - 2, p)) % p \nn, m = map(int, input().split())\nmod = 998244353\nif n == 2:\n ans = (m*(m-1))%mod\n print(ans)\nelse:\n ans = ncr(m, n-1, mod)\n ans*=(n-2)\n ans%=mod\n ans*=pow(2, n-3, mod)\n ans%=mod\n print(ans)"}, {"source_code": "import math, collections, sys\ninput = sys.stdin.readline\ndef ncr(n, r, p):\n num = den = 1 \n for i in range(r):\n num = (num * (n - i)) % p \n den = (den * (i + 1)) % p \n return (num * pow(den, p - 2, p)) % p \nn, m = map(int, input().split())\nmod = 998244353\nif n == 2:\n ans = pow(m, 2, mod)\n print(ans)\nelse:\n ans = ncr(m, n-1, mod)\n ans*=(n-2)\n ans%=mod\n ans*=pow(2, n-3, mod)\n ans%=mod\n print(ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nmod = 998244353\n\nif n == 2:\n print(m*(m-1))\n exit()\n\nmax_n = 2*10**5 + 10\nfac, inv = [1]*max_n, [0]*max_n\nfor i in range(2, max_n):\n fac[i] = fac[i-1] * i % mod\ninv[-1] = pow(fac[-1], mod-2, mod)\nfor i in range(max_n-1, 0, -1):\n inv[i-1] = inv[i] * i % mod\n\nans = fac[m] * inv[n-1] * inv[m-n+1] * (n-2) * pow(2, n-3, mod) % mod\nprint(ans)\n"}, {"source_code": "n,m=map(int,input().split())\nmod=998244353\nif n==3:\n\tprint (((m*(m-1))//2)%(mod))\n\texit()\nif n==2:\n\tprint(m)\n\texit()\nfact = [1,1]\nfor i in range(2,max(n,m)+1):\n\tfact.append((fact[-1]*i)%mod)\nans = pow(2,n-3,mod)\nans = ((n-2)*ans)%mod\nans = ans*((fact[m]*pow((fact[n-1]*fact[m+1-n])%mod,mod-2,mod))%mod)\nprint ((ans)%mod)"}, {"source_code": "fc = [1, 1]\nMOD = 998244353 \n\nfor i in range(2, 2*10**5 +3):\n fc.append((fc[-1]*i)%MOD)\n \ndef slv(n, m):\n if n == 2:\n return 0\n \n ans = 0\n c = fc[m]*pow(fc[m-n+1], MOD-2, MOD)*pow(fc[n-1], MOD-2, MOD)\n c%=MOD\n c*=(n-2)\n c*= 2**(n-3)\n c%=MOD\n ans += c\n ans %=MOD\n return ans\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n MOD = 998244353\n N, M = [int(x) for x in input().split()]\n\n if N == 2:\n print(M)\n return\n\n fact = [1, 1]\n factinv = [1, 1]\n inv = [0, 1]\n\n def cmb(n, k, p):\n if (k < 0) or (n < k):\n return 0\n r = min(k, n - k)\n return fact[n] * factinv[k] * factinv[n - k] % p\n\n for i in range(2, 2 * 10 ** 5):\n fact.append((fact[-1] * i) % MOD)\n inv.append((-inv[MOD % i] * (MOD // i)) % MOD)\n factinv.append((factinv[-1] * inv[-1]) % MOD)\n\n ans = 0\n for i in range(M, -1, -1):\n if i - 1 < N - 2:\n break\n x = cmb(i - 1, N - 2, MOD)\n y = pow(2, N - 3, MOD)\n y = (x * y * (N - 2)) % MOD\n ans = (ans + y) % MOD\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "mod = 998244353\nfact = [1]\nfor i in range(1, 2*(10**5) + 1):\n\tfact.append((i*fact[-1])%mod)\ninv = []\nfor i in fact:\n\tinv.append(pow(i, mod - 2, mod))\n\ndef comb(a, b):\n\treturn (((fact[a]*inv[a-b])%mod)*inv[b])%mod\n\nn, m = map(int, raw_input().split())\nprint (((n-2)*(pow(2, n - 2, mod))*comb(m, n - 1))%mod)*inv[2]"}, {"source_code": "n,m=map(int,raw_input().split())\ndef modInverse(a,m) : \n a=a%m; \n for x in range(1,m) : \n if ((a*x)%m==1): \n return x \n return 1\n\nif n==2:\n print m%998244353\nelif n==3:\n print ((m*(m-1))/2)%998244353\nelse:\n x,y,z=1,1,1\n c=min(m-n+1,n-1)\n d=max(m-n+1,n-1)\n for i in range(d+1,m+1):\n x=x*i\n x=x%998244353\n for i in range(1,c+1):\n y=y*i \n y=y%998244353\n a=(x*pow(y,998244351,998244353))%998244353\n b=((n-2)*(2**(n-3)))%998244353\n print (a*b)%998244353\n"}, {"source_code": "n,m=map(int,raw_input().split())\nfrom math import factorial\nif n==2:\n print m%998244353\nelif n==3:\n print ((m*(m-1))/2)%998244353\nelse:\n x,y,z=1,1,1\n for i in range(1,m+1):\n x=x*i\n if i==m-n+1:\n y=x\n if i==n-1:\n z=x\n a=x/(y*z)%998244353\n b=((n-2)*(2**(n-3)))%998244353\n print (b)%998244353\n"}, {"source_code": "f=[1 for j in range(200050)]\ngf=[1 for j in range(200050)]\nmod=998244353\nfor i in range(1,1050):\n f[i]=((f[i-1]*i)%mod)\n gf[i]=(pow(f[i],mod-2,mod))\n\ndef bc(n,p):\n j=f[n]*gf[p]\n j%=mod;j*=gf[n-p];j%=mod\n return j\nn,m=map(int,raw_input().split())\ns=0\n\ng=(bc(m,n-1)*(n-2))%mod\nv=pow(2,n-3,mod)\nprint (g*v)%mod"}, {"source_code": "f=[1 for j in range(200055)]\ngf=[1 for j in range(200055)]\nmod=998244353\nfor i in range(1,200050):\n f[i]=((f[i-1]*i)%mod)\n gf[i]=(pow(f[i],mod-2,mod))\n\ndef bc(n,p):\n j=f[n]*gf[p]\n j%=mod;j*=gf[n-p];j%=mod\n return j\nn,m=map(int,raw_input().split())\ns=0\nif n==2:\n print m\nelse:\n g=(bc(m,n-1)*(n-2))%mod\n v=pow(2,n-3,mod)\n print (g*v)%mod"}, {"source_code": "f=[1 for j in range(201155)]\ngf=[1 for j in range(201155)]\nmod=998244353\nfor i in range(1,201150):\n f[i]=((f[i-1]*i)%mod)\n gf[i]=(pow(f[i],mod-2,mod))\n\ndef bc(n,p):\n j=f[n]*gf[p]\n if n>=len(f) or p<=len(gf):\n print 0\n j%=mod;j*=gf[n-p];j%=mod\n return j\nn,m=map(int,raw_input().split())\n\n\ng=(bc(m,n-1)*(n-2))%mod\nv=pow(2,n-3,mod)\nprint (g*v)%mod"}, {"source_code": "f=[1 for j in range(200050)]\ngf=[1 for j in range(200050)]\nmod=998244353\nfor i in range(1,1050):\n f[i]=((f[i-1]*i)%mod)\n gf[i]=(pow(f[i],mod-2,mod))\n\ndef bc(n,p):\n j=f[n]*gf[p]\n j%=mod;j*=gf[n-p];j%=mod\n return j\nn,m=map(int,raw_input().split())\ns=0\n\ng=(bc(m,n-1)*(n-2))%mod\nv=pow(2,n-3,mod-2)\nprint (g*v)%mod"}, {"source_code": "f=[1 for j in range(200050)]\ngf=[1 for j in range(200050)]\nmod=998244353\nfor i in range(1,1050):\n f[i]=((f[i-1]*i)%mod)\n gf[i]=(pow(f[i],mod-2,mod))\n\ndef bc(n,p):\n j=f[n]*gf[p]\n j%=mod;j*=gf[n-p];j%=mod\n return j\nn,m=map(int,raw_input().split())\ns=0\n\ng=(bc(2*m+n-1,n-1)*(n-1))%mod\nv=pow(2,n-3,mod-2)\nprint (g*v)%mod"}, {"source_code": "def fast_pow(base, power, modulo):\n if power == 0:\n return 1\n if power % 2 == 1:\n return (fast_pow(base, power-1, modulo)*base) % modulo\n else:\n b = fast_pow(base, power//2, modulo)\n return (b * b) % modulo\n\n\ndef get_inverse(x, modulo):\n return fast_pow(x, modulo - 2, modulo)\n\n\nn, m = map(int, input().split())\n\nif m - 1 < n or n == 2:\n print(0)\n exit(0)\n\nc = 1\nmod = 998244353\nsum = 0\n\nfor maxx in range(n - 1, m + 1):\n sum += c\n #sum = sum % mod;\n c = (c * maxx * get_inverse(maxx - (n-2), mod)) % mod\n\n#print(sum % mod)\nsum = sum * (n - 2) % mod\nfor i in range(0, n-3):\n sum *= 2\n sum = sum % mod\n\nprint(sum % mod)\n\n\n"}, {"source_code": "from sys import stdin,stdout\nimport sys\nsys.setrecursionlimit(2*(10**5 + 100))\n\nmod=998244353\n\nmaxn=2*10**5 + 100\n\n\nfactmod=[1]\ninvmod=[0]\ninvfactmod=[1]\n\nfor i in range(1,maxn):\n\tfactmod.append((i*factmod[-1])%mod)\n\tinvmod.append(pow(i,mod-2,mod))\n\tinvfactmod.append((invmod[-1]*invfactmod[-1])%mod)\n\n\n# print(factmod)\n# print(invfactmod)\n# print(invmod)\n\ndef ncr(n,r):\n\treturn (((factmod[n]*invfactmod[r])%mod)*invfactmod[n-r])%mod\n\n\n\n# stdin = open(\"input.txt\", \"r\");\n# stdout = open(\"output.txt\", \"w\");\n\nn,m=stdin.readline().strip().split(' ')\nn,m=int(n),int(m)\n\nif n==2:\n\tans=0\nelse:\n\t\t\n\n\tans=0\n\tfor x in range(n-1,m+1):\n\t\tans=(ans+(ncr(x-1,n-2)*(n-2)*pow(2,n-3,mod)))%mod\n\n\tstdout.write(str(ans%mod)+\"\\n\")\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "mod = 998244353\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n\np = mod\nN = 5 * 10 ** 5 # N \u306f\u5fc5\u8981\u5206\u3060\u3051\u7528\u610f\u3059\u308b\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\n\nn, m = map(int, input().split())\nres = 0\nimport math\nif n == 2:\n print(0)\nelse:\n for i in range(n-1, m+1):\n res += (i - 1) * cmb(i - 2, n - 3, mod) * pow(2, n-3, mod)\n res %= mod\nprint(res)\n\n"}, {"source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\n \n\nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now-----------------------------------------------------\nMOD = 998244353\nBIG = 1000000\nfac = [1] * BIG\nfor i in range(1, BIG):\n fac[i] = (i*fac[i-1])%MOD\n \ndef choose(n,k):\n return (fac[n]*pow((fac[k]*fac[n-k])%MOD,MOD-2,MOD))%MOD\n "}, {"source_code": "m=mod=998244353\n\ndef mpow(a,b):\n ans=1\n while b>0:\n if b&1:\n ans=(ans*a)%m \n a = (a*a)%m\n b=b>>1\n return ans\n\nfact=[0 for i in range(10**6 + 5)]\nfact[0]=fact[1]=1\nfor i in range(2,len(fact)):\n fact[i] = i*fact[i-1]\n fact[i]%=m\n\n# print(fact[:100])\n\ninvfact=[0 for i in range(10**6 + 5)]\ninvfact[len(fact) -1 ] = mpow(fact[len(fact)-1],m-2)\n\nfor i in range(len(invfact)-2,-1,-1):\n invfact[i] = ((i+1)*(invfact[i+1]))%m\n \n# print(invfact[:100])\ndef comb(m,n):\n ans=(fact[m]*invfact[n]*invfact[m-n])\n # ans*=invfact[n]\n ans=ans%mod\n return ans\n\n\n\n\nn,m=[int(c) for c in input().split()]\n\nif n == 2:\n ans = comb(m,2)*2\n ans%=mod\n ans+=m\n ans%=mod\nelse:\n ans=comb(m,n-1)\n ans%=mod\n ans*=(n-2)\n ans%=mod\n ans*=(1<<(n-3))\n ans%=mod\nprint(ans)"}, {"source_code": "import sys\nmod=998244353\nfact=[1 for _ in range(200006)]\nfor i in range(1,200005):\n fact[i]=(fact[i-1]*i)%mod\ndef modinv(a,mod):\n return pow(a,mod-2,mod)\nn,m=map(int,sys.stdin.readline().split())\nans=(fact[m]*modinv(fact[n-1],mod)*modinv(fact[m-n+1],mod))%mod\nans=ans*(n-2)\nans=ans%mod\ns=0\nfor i in range((n-3)//2+1):\n a=fact[n-3]\n b=modinv(fact[i],mod)\n c=modinv(fact[n-3-i],mod)\n s+=(a*b*c)%mod\nif s==1:\n ans=(ans*s)%mod\nelse:\n ans=(ans*2*s)%mod\nprint(ans%mod)\n"}], "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba"} {"source_code": "\nif __name__ == '__main__':\n\tn, = map(int, input().split())\n\ta, b = 1, 2\n\tk = 0\n\twhile (b <= n):\n\t\ta, b = b, a+b\n\t\tk += 1\n\tprint(k)\n", "positive_code": [{"source_code": "def fib():\n a,b=1,1\n while b<10**18:\n a,b=b,a+b\n yield b\na,ans,n=fib(),0,input()\nfor i in a:\n ans+=1\n if i >= n:\n print ans-(i>n)\n break\n"}, {"source_code": "num = long(raw_input())\nfibo = [0, 1]\nwhile fibo[-1] < num:\n fibo.append(fibo[-1] + fibo[-2])\nres = len(fibo) - 3\nif num < fibo[-1]:\n res -= 1\nprint res\n"}, {"source_code": "def go():\n\tn = input()\n\tgames=0\n\tp1=1\n\tp2=2\n\twhile games<n:\n\t\tgames+=1\n\t\tp1,p2=p2,p1+p2\n\t\tif p2>n:\n\t\t\treturn games\n\t\t\n\t\n\t\n\t\nprint go()\n"}, {"source_code": "n = int(input())\nprefix = [1, 1, 2]\nnow = 0\nfor i in range(85):\n prefix.append(prefix[-1] + prefix[-2])\n#print(prefix[:4])\nwhile n >= prefix[now] + 1:\n n -= prefix[now]\n now += 1\nprint(now)"}, {"source_code": "from sys import stdout, stdin\nfrom io import IOBase, BytesIO\nfrom os import read, write, fstat\nfrom math import sqrt\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = read(self._fd, max(fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self, size: int = ...):\n while self.newlines == 0:\n b = read(self._fd, max(fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nstdin, stdout = IOWrapper(stdin), IOWrapper(stdout)\ninput = lambda: stdin.readline().rstrip(\"\\r\\n\")\n\nn,a,b,c=int(input()),2,1,0\nwhile a<=n:a,b=a+b,a;c+=1\nprint(c)"}, {"source_code": "a = [1,1,2]\nfor i in range(3,201):\n\ta.append(a[i-1]+a[i-2])\nn = int(input())\nans = 1\ni = 3\nwhile n >= a[i]:\n\ti += 1\n\tans += 1\nprint(ans)\t \n"}, {"source_code": "n=int(input())\na,b=2,1\nc=0\nwhile a<=n:\n a,b=a+b,a\n c+=1\nprint(c)"}, {"source_code": "def solve(n):\n k = 0\n f1, f2 = 1, 2\n while not f1 <= n < f2:\n k += 1\n t = f1\n f1 = f2\n f2 = f1 + t\n return k\n\nn = int(input())\nprint(solve(n))\n"}, {"source_code": "import math,sys,re,itertools,pprint,collections,copy\nrs,ri,rai,raf=input,lambda:int(input()),lambda:list(map(int, input().split())),lambda:list(map(float, input().split()))\n\nt = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946,\n17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309,\n3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141,\n267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049,\n12586269025, 20365011074, 32951280099, 53316291173, 86267571272, 139583862445, 225851433717,\n365435296162, 591286729879, 956722026041, 1548008755920, 2504730781961, 4052739537881, 6557470319842,\n10610209857723, 17167680177565, 27777890035288, 44945570212853, 72723460248141, 117669030460994,\n190392490709135, 308061521170129, 498454011879264, 806515533049393, 1304969544928657, 2111485077978050,\n3416454622906707, 5527939700884757, 8944394323791464, 14472334024676221, 23416728348467685,\n37889062373143906, 61305790721611591, 99194853094755497, 160500643816367088, 259695496911122585,\n420196140727489673, 679891637638612258, 1100087778366101931, 1779979416004714189, 2880067194370816120,\n4660046610375530309, 7540113804746346429]\n\nn = ri()\n\nfor i in range(len(t)):\n if n < t[i]:\n print(i)\n break\n"}, {"source_code": "a = int(input())\nfib=[1,2]\nfor i in range(100):\n fib.append(fib[-1]+fib[-2])\n\nfor i in range(1, 1000):\n if fib[i]<=a<fib[i+1]:\n print(i)\n quit()"}, {"source_code": "n=int(input())\na,b=2,1\nans=0\nwhile a<=n:\n a,b=a+b,a\n ans+=1\nprint(ans)"}, {"source_code": "n, arr, i = int(input()), [2, 3], 1\nif n == 2:\n print(1)\nelif n == 3:\n print(2)\nelse:\n a, ans = arr[i] + arr[i - 1], 2\n while (a <= n):\n i += 1\n arr.append(a)\n a = arr[i] + arr[i - 1]\n ans+=1\n print(ans)\n"}, {"source_code": "n=int(input())\ni=2\nx=2\ny=3\ns=0\nif(n<4):\n if n==2:\n print(1)\n else:\n print(2)\nelse:\n while(1):\n s=y+x\n if s>n:\n break\n i+=1\n x=y\n y=s\n print(i)\n"}, {"source_code": "n, a, b, v = int(input()), 1, 1, -1\nwhile b <= n:\n a, b, v = b, a + b, v + 1\nprint(v)"}, {"source_code": "n=int(input())\na,b=2,1\nc=0\nwhile a<=n:\n a,b=a+b,a\n c+=1\nprint(c)"}, {"source_code": "n = int(input())\nans = 0\na = b = 1\nwhile a + b <= n:\n a, b = a + b, a\n ans += 1\nprint(ans)\n"}, {"source_code": "f=[1,1]\nn=int(input())\ni=0\nwhile f[0]+f[1]<=n:\n i+=1\n f[0],f[1]=f[1],f[0]+f[1]\n\nprint(i)"}, {"source_code": "n = int(input())\nf = [1, 1]\nwhile f[-1] < n:\n\tf += [f[-1] + f[-2]]\nif f[-1] == n:\n\tprint(len(f) - 2)\nelse:\n\tprint(len(f) - 3)"}, {"source_code": "n = int(input())\n\nif n <= 2:\n print(n - 1)\n exit()\n\nfib = [0, 1]\nwhile fib[-1] <= n:\n fib.append(fib[-1] + fib[-2])\n\nprint(len(fib) - 4)"}, {"source_code": "n = int(input())\n\nl = []\nl.append(0)\nl.append(1)\nl.append(2)\n\nk = 2\nm = 1\n\nwhile k < n:\n k = k + l[m]\n m = m + 1\n l.append(k)\n \nif k > n:\n m = m - 1\n\nprint(m)"}, {"source_code": "n=int(input())\nif(n==2):\n print(1)\nelif(n==3):\n print(2)\n\nelse:\n a=2\n b=3\n res=2;\n while(True):\n res+=1\n c=a+b\n if(c>n):\n break\n a=b\n b=c\n \n \n print(res-1)"}, {"source_code": "\nn = int(input())\ni = 0\nfib1 = 1\nfib2 = 1\nx = 2\nwhile x <= n :\n x = fib2 + fib1\n fib1,fib2 = fib2,x\n i += 1\n #print('{} {} {} {}'.format(fib1,fib2,x,i))\nprint( (i-1) )\n"}, {"source_code": "n=int(input())\na,b=2,1\nc=0\nwhile a<=n:\n a,b=a+b,a\n c+=1\nprint(c)"}, {"source_code": "\nn=int(input())\n\nx,y=1,1\nz=-1\n\nfor i in range(0,n+1):\n if y>n:\n print(i-1)\n break\n\n z=x+y\n x=y\n y=z\n"}, {"source_code": "n = int(input())\ni1=1\ni2=2\nsol=0\nwhile i2 <= n:\n aux = i1+i2\n i1 = i2\n i2 = aux\n sol = sol+1\nprint(sol)\n"}, {"source_code": "# http://codeforces.com/problemset/problem/735/C\ndef main():\n num = int(input())\n num1 = 1\n num2 = 2\n tmp = 0\n cont = 0\n while tmp <= num:\n tmp = num1 + num2\n num1 = num2\n num2 = tmp\n cont += 1\n print(cont)\nmain()"}, {"source_code": "fib = [0,1]\nfor i in range(2,100):\n fib.append(fib[i-1] + fib[i-2])\nfib = fib[2:]\nn = int(input())\nmaks = 0\nfor i in range(len(fib)):\n if n >= fib[i]:\n maks = max(maks,i)\n else:\n break\n\nprint(maks)\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\ndef fibo(n):\n\tf0=0\n\tf1=1\n\tif (n==0):\n\t\tfibo=0\n\telif n==1:\n\t\tfibo=1\n\telse:\n\t\tfor i in range(1,n):\n\t\t\tfibo=f0+f1\n\t\t\tf0=f1\n\t\t\tf1=fibo\n\treturn(fibo)\n\nn=int(input())\nans=0\nfor k in range(n+5):\n\tif (fibo(k) > n):\n\t\tans=k-3\n\t\tbreak\n\telse:\n\t\tpass\nprint(ans)\n\n\n\n"}, {"source_code": "n = int(input())\na,b = 2,3\nc = 0\nwhile n >= a:\n a,b = b,a+b\n c+=1\nprint(c)"}, {"source_code": "N = int(input())\ndp = [1]\nfor x in range(1, 1000):\n dp.append(dp[x-1] + dp[max(0, x-2)])\n if dp[-1] > N:\n print(x-1)\n break"}, {"source_code": "n = eval(input())\na, b, = 2, 1\nans = 0;\nwhile a <= n:\n a, b = a + b, a\n ans += 1\nprint(ans)\n"}, {"source_code": "from sys import stdout\nn = int(input())\ndp = [0 for i in range(100)]\ndp[0] = 1\ndp[1] = 2\n\nfor i in range(2, n + 10):\n if dp[i - 1] > n:\n stdout.write(str(i - 2))\n break\n dp[i] = dp[i - 1] + dp[i - 2]\n"}, {"source_code": "n = int(input())\ni1=1\ni2=2\nsol=0\nwhile i2 <= n:\n aux = i1+i2\n i1 = i2\n i2 = aux\n sol = sol+1\nprint(sol)\n"}, {"source_code": "n = int(input())\n\nf = [0] * 200\nf[0] = 1\nf[1] = 2\nfor k in range(2, 101):\n\tf[k] = f[k-1] + f[k-2]\nfor k in range(1, 100):\n\tif n >= f[k] and n < f[k+1]:\n\t\tprint(k)\n\t\texit()"}, {"source_code": "f = [0, 1]\n\nfor i in range(200):\n f.append(f[-1] + f[-2])\n\nn = int(input())\n\nans = 0\nfor i in range(200):\n if((f[i] <= n) and (n < f[i + 1])):\n ans = i - 2\n break\n \nprint(ans)"}, {"source_code": "n = int(input())\n\nans = 0\na = 1\nb = 2\nwhile b <= n:\n c = a + b\n a = b\n b = c\n ans += 1\n\nprint(ans)"}, {"source_code": "n=int(input())\nL=[0]*10000000\nL[0]=0\nL[1]=2\nif n==2 :\n print(1)\n exit()\nif n<=4 :\n print(2)\n exit()\nL[2]=3\ni=2\nwhile n>=L[i] :\n i=i+1\n L[i]=L[i-2]+L[i-1]\nprint(i-1)\n\n \n \n\n"}, {"source_code": "n = int(input())\n\na, b = 1, 1\ni = 0\n\nwhile b <= n:\n\ta, b = b, a+b\n\ti+=1\n\nprint(i-1)"}, {"source_code": "n = int(input())\nf1 = 1\nf2 = 1\nans = -1\nwhile f2 <= n:\n f1, f2 = f2, f1+f2\n ans += 1\nprint(ans)"}, {"source_code": "n = int(input())\n\na,b,res = 2,1,0\n\nwhile a <= n:\n\ta,b,res = a+b,a,res+1\n\nprint(res)"}, {"source_code": "n = int(input())\n\nans = 0\na = 1\nb = 2\nwhile b <= n:\n c = a + b\n a = b\n b = c\n ans += 1\n\nprint(ans)"}, {"source_code": "import sys\n#import math\n#from collections import deque\n\ndef main():\n\t\n\tif (len(sys.argv) > 1 and sys.argv[1] == \"debug\"):\n\t\tsys.stdin = open(\"xxx.in\", \"r\")\n\t\tsys.stdout = open(\"xxx.out\", \"w\")\n\t\n\tn = int(input())\n\tnum = b = 1\n\tcnt = -1\n\twhile (n >= num):\n\t\tcnt += 1\n\t\tx = num\n\t\tnum += b\n\t\tb = x\n\t\t#print(str(cnt) + \" : \" + str(b) + \" \" + str(num))\n\t\t\n\tprint (cnt)\n\t\t\nmain()"}, {"source_code": "n = int(input())\na, b = int(1), int(2)\nans = int(0)\nwhile b <= n:\n a, b = b, b + a\n ans += 1\nprint(ans)\n"}, {"source_code": "n=int(input())\n\na,b=2,1\n\nc=0\n\nwhile a<=n:\n\n a,b=a+b,a\n\n c+=1\n\nprint(c)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "n = int(input())\nans = 1\nf0 = 1\nf1 = 2\nwhile(f1 <= n):\n f1 += f0\n f0 = f1 - f0\n ans += 1\nprint(ans - 1)\n"}, {"source_code": "n = int(input())\nx = [1,2]\nwhile x[-1] < n:\n x.append(x[-1]+x[-2])\nif x[-1] == n:\n print(len(x)-1)\nelse:\n print(len(x)-2)\n"}, {"source_code": "n = int(input())\n\nans = 0\na = 1\nb = 2\nwhile b <= n:\n c = a + b\n a = b\n b = c\n ans += 1\n\nprint(ans)\n"}, {"source_code": "n = int(input())\ndp = [1, 2]\nwhile dp[-2] + dp[-1] <= n:\n dp.append(dp[-2] + dp[-1])\nprint(len(dp) - 1)"}, {"source_code": "n = int(input())\nb = 2\na = 1\nd = 0\nwhile b <= n:\n a, b = b, a + b\n d += 1\nprint(d)"}, {"source_code": "n=int(input())\nfib=1\nlast=1\ni=0\nwhile True:\n i+=1\n fib=fib+last\n last=fib-last\n if fib>n:\n print(i-1)\n exit(0)"}, {"source_code": "__author__ = 'ilyakuchumov'\n\n\ndef main():\n fib_list = [1, 2]\n for i in range(100):\n fib_list.append(fib_list[-1] + fib_list[-2])\n\n n = int(input())\n\n cur_ans = 0\n cur_n = 1\n\n while cur_n < n:\n cur_n += fib_list[cur_ans]\n cur_ans += 1\n\n print(cur_ans)\n\n\nmain()"}, {"source_code": "n=input(); t=0; a=[0]*100; a[1]=1\nwhile a[t+2]<=n:\n t+=1\n a[t+2]=a[t+1]+a[t]\n \nprint t-3\n"}, {"source_code": "#!/usr/bin/python2\n# -*- coding: utf-8 -*-\n\nimport sys\n\ndef rl(proc=None):\n if proc is not None:\n return proc(sys.stdin.readline())\n else:\n return sys.stdin.readline().rstrip()\n\nfib = [ 1, 2 ]\nwhile fib[-1] <= 10 ** 18:\n fib.append(fib[-1] + fib[-2])\n\ndef get(k):\n return fib[k]\n\ndef main():\n n = rl(int)\n n -= 2\n h = 1\n while n > 0:\n n -= get(h-1)\n if n >= 0:\n h += 1\n print h\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\nans = 0\na,b,x = 1,1,2\nwhile x <= n :\n x = a+b\n a,b = b,x\n ans+=1\n \nprint(ans-1)"}, {"source_code": "n = input()\nans = 0\n\na = 0\nb = 1\n\nwhile b <= n:\n a, b = b, a + b\n ans += 1\n\nprint ans - 2\n\n"}, {"source_code": "from math import *\n\ndef main():\n n=int(input())\n prev,fib=1,2\n count=0\n while fib<=n:\n prev,fib=fib,prev+fib\n count+=1\n print(count)\n \nmain()\n"}, {"source_code": "import bisect\nn = int(input())\nc = [1,2]\nfor i in range(100):\n c.append(c[-1]+c[-2])\nif n in c:\n print(bisect.bisect_left(c,n))\nelse:\n print(bisect.bisect_left(c,n)-1)\n"}, {"source_code": "\n# Returns the minimum number of players that need to be in the tournament for the champion to play at least `x` games\ndef players_for_champ_level(x, cache={}):\n if x == 1:\n return 2\n elif x == 2:\n return 3\n elif x in cache:\n return cache[x]\n else:\n # For the champion to get to the level `x` (play `x` games) he needs to be level `x` - 1 and there needs to be\n # another player of level `x` - 2\n x_result = players_for_champ_level(x - 1, cache) + players_for_champ_level(x - 2, cache)\n\n cache[x] = x_result\n\n return x_result\n\nx = int(raw_input())\n\nchamp_level = 0\n\nwhile players_for_champ_level(champ_level + 1) <= x:\n champ_level += 1\n\nprint champ_level\n"}, {"source_code": "n = int(input())\n\nif n == 2:\n\tprint(1)\nelif n == 3:\n\tprint(2)\nelse:\n\tx = 2\n\ty = 3\n\tcounter = 0\n\twhile x+ y <= n:\n\t\tx, y = y, x+y\n\t\tcounter += 1\n\tprint(2+counter)"}, {"source_code": "n = int(input())\n\nf = 2\ng = 1\nc = 0\n\nwhile f <= n:\n\tf, g = f+g, f\n\tc += 1\n\nprint(c)"}, {"source_code": "n = int(input())\ndp = [1, 2]\nwhile dp[-2] + dp[-1] <= n:\n dp.append(dp[-2] + dp[-1])\nprint(len(dp) - 1)\n"}, {"source_code": "n = int(input())\na = 1\nb = 2\ns = 1\nk = 0\nwhile s <= n:\n s = a + b\n a = b\n b = s\n k += 1\nprint(k)"}, {"source_code": "import math\ndef main():\n n = int(input())\n phib = [1, 1]\n ans = 0\n while(phib[-1] + phib[-2] <= n):\n phib.append(phib[-1] + phib[-2])\n ans += 1\n\n print(ans)\nmain()"}, {"source_code": "f = [0, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025, 20365011074, 32951280099, 53316291173, 86267571272, 139583862445, 225851433717, 365435296162, 591286729879, 956722026041, 1548008755920, 2504730781961, 4052739537881, 6557470319842, 10610209857723, 17167680177565, 27777890035288, 44945570212853, 72723460248141, 117669030460994, 190392490709135, 308061521170129, 498454011879264, 806515533049393, 1304969544928657, 2111485077978050, 3416454622906707, 5527939700884757, 8944394323791464, 14472334024676221, 23416728348467685, 37889062373143906, 61305790721611591, 99194853094755497, 160500643816367088, 259695496911122585, 420196140727489673, 679891637638612258, 1100087778366101931]\nn = int(input())\nfor i in range(len(f)):\n if(f[i] > n):\n break\nprint(i-1)\n"}, {"source_code": "import math\ndef inp():\n return int(raw_input())\ndef linp():\n return map(int, raw_input().split())\nn = inp()\nprev = 1\ncurr = 2\nans = 0\nwhile curr<=n:\n temp = curr\n curr = prev+curr\n prev = temp\n ans+=1\nprint ans"}, {"source_code": "f={0:1,1:2}\nn=input()\nnn=2\nwhile nn<1000:\n f[nn]=f[nn-1]+f[nn-2]\n nn+=1\nfor ff in f.keys():\n if f[ff]>n:\n print ff-1\n exit(0)\n elif f[ff]==n:\n print ff\n exit(0)"}, {"source_code": "n = int(raw_input())\nn1 = 1\nn2 = 2\nfib = 1\nwhile n2 <= n:\n\tt = n1\n\tn1 = n2\n\tn2 = t + n2\n\tfib = fib+1\nprint fib-1"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nfib = [0,2,3]\nfor i in xrange(110):\n fib.append(fib[-1] + fib[-2])\nans = 0\nfor i in xrange(110):\n if fib[i] > n:\n break\nprint i-1"}, {"source_code": "import math\n\nn = raw_input()\nn = int(n)\n\nfib = [0,1]\nindex = 1\nnum = 1\n\nwhile num <= n:\n\tnum = fib[index] + fib[index-1];\n\tfib.append(num)\n\tindex += 1\n\n#print int(math.ceil((math.log(n,2)))) \n#print fn(n)\nprint index - 3"}, {"source_code": "n = int(raw_input())\na = 1\nb = 1\ni = 0\nwhile n >= a:\n a, b = a+b, a\n i += 1\n # print a, b\nprint i - 1\n"}, {"source_code": "from itertools import *\nfrom bisect import *\n\ndef fibonacci_generator():\n\ta,b = 2,1\n\tfor _ in count():\n\t\ta,b = a+b,a\n\t\tyield b\n\nfibs = list(islice(fibonacci_generator(), 0, 100))\nf = lambda x: bisect(fibs,x)\nprint f(int(raw_input()))"}, {"source_code": "import math\na = int(raw_input())\nfib = [1,2]\nfor i in xrange(86):\n\tfib.append(fib[-1]+fib[-2])\nstart = 1\nwhile True:\n\tif fib[start] > a:\n\t\tprint start-1\n\t\tbreak\n\tif fib[start] == a:\n\t\tprint start\n\t\tbreak\n\tstart +=1\n"}, {"source_code": "n = int(raw_input())\na = [0, 1]\nwhile a[-1] <= n-1:\n a.append(a[-1] + a[-2] + 1)\nprint len(a) - 2 \n"}, {"source_code": "n = int(raw_input(\"\"))\na=2\nb=1\nc=0\ni=1\nwhile(a+b<=n):\n\tc=a+b\n\tb=a\n\ta=c\n\ti=i+1\nprint(i)\n\n"}, {"source_code": "from bisect import bisect\nN = 100\ndp = [0 for _ in range(N)]\ndp[1] = 1\ndp[2] = 2\nfor i in range(3, N):\n dp[i] = dp[i - 1] + dp[i - 2] + 1\nfor i in range(N):\n dp[i] += 1\n\ndef get_ans(n):\n for i in range(99, -1, -1):\n if dp[i] <= n:\n return i\n\nn = int(raw_input())\nprint get_ans(n)\n"}, {"source_code": "n = input()\nans = 1\nn1 = 1\nn2 = 2\n\nwhile n>=n2:\n n1,n2 = n2,n1+n2\n ans += 1\n\nprint ans-1\n"}, {"source_code": "n = int(raw_input())\nk = 1\na = 2; b = 1\nwhile a + b <= n: a, b = a + b, a; k += 1\nprint k"}, {"source_code": "from collections import defaultdict\nfrom fractions import gcd\nfrom bisect import *\nimport sys\nsys.setrecursionlimit(5*10**6)\ndef sint():\n return int(raw_input())\ndef sarr():\n return [int(x) for x in raw_input().split()]\ndef sstr():\n return raw_input()\n\nf=[0]*300\nf[0]=1\nf[1]=1\nfor i in range(2,300):\n f[i]=f[i-1]+f[i-2]\n#print f[299]\n \nn=sint()\nprint bisect_right(f,n)-2\n\n \n"}], "negative_code": [{"source_code": "n = int( input() )\n\nval = 1\nturn = 0\n\nwhile val < n:\n\tval *= 2\n\tturn += 1\n\t\nprint( turn )"}, {"source_code": "import math\nn=int(input())\nif(n<=3):\n print(2)\nelse:\n l=[]\n q=[]\n a=0;\n b=1;\n ans=1;\n c=a+b\n n=n-2;\n while(c<=(n)):\n a=b;\n b=c;\n n=n-c;\n c=a+b;\n ans+=1\n print(ans)"}, {"source_code": "import math\n\nn = raw_input()\nn = int(n)\n\nprint math.ceil((math.log(n,2))) "}, {"source_code": "n, ans = int(input()), 0\nwhile (n > 1):\n if n & 1:\n n = (n + 1) >> 1\n else:\n n >>= 1\n ans += 1\nprint(ans)\n"}, {"source_code": "def process(n):\n a = [0]\n while len(a)<n:\n a.append(a[len(a)/2]+1)\n #print a\n return a[-1]\n\nprint process(int(raw_input()))"}, {"source_code": "from math import ceil, log\n\nn = int(input())\nprint(ceil(log(n, 2)))"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase, ascii_uppercase\nfrom fractions import Fraction, gcd\n#from decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\n#getcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] == \"PyPy\":\n import io, atexit\n sys.stdout = io.BytesIO()\n atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n sys.stdin = io.BytesIO(sys.stdin.read())\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\nn = read_int()\n\ncache = {2: 1, 3: 2, 4: 2}\ndef get(n):\n if n not in cache:\n cache[n] = 1 + max(get(n//2), get(n-n//2))\n return cache[n]\n\nprint get(n)\n\n# l = 0\n# while 1 << l < n:\n# l += 1\n# print l\n"}, {"source_code": "def process(n):\n a = [0]\n while len(a)<n:\n a.append(a[len(a)/2]+1)\n #print a\n return a[-1]\n\nprint process(int(raw_input()))"}, {"source_code": "from math import *\nn = int(input())\nprint(round(log(sqrt(5)*n)/log((1.0+sqrt(5))/2.0) -.45) - 2)"}, {"source_code": "from math import ceil,floor\nn = int(input())\nans = 0\nwhile True:\n\tans += 1\n\tn /= 2\n\tif n <= 1:\n\t\tbreak\nprint(ans)\t\t"}, {"source_code": "n=int(input())\nmaxigr=0\nwhile n>1:\n if n%2==0:\n maxigr+=1\n n//=2\n else:\n n=(n+1)//2\n maxigr+=1\nprint(maxigr)\n"}, {"source_code": "from math import *\nn=int(input())\nif n==0:\n print(0)\n exit()\nelse:\n m=log2(n)\n k=int(m)\n if m==k:\n print(k)\n else:\n print(k+1)"}, {"source_code": "n = int(raw_input(\"\"))\nans = int((1+(8*n-15)**(.5))/2)\nprint(ans)"}, {"source_code": "import math\nn = int(input())\nc = 0\nwhile n != 1:\n if n % 2 == 0:\n c += 1\n else:\n c += 2\n n//=2\n\nprint(c)"}, {"source_code": "import math\nn = int(raw_input())\ndef ans(n):\n if n==2:\n return 1\n else:\n return ans(math.ceil(1.0*n/2))+1\nprint ans(n)"}, {"source_code": "from math import *\nn = int(input())\n\nprint(round(log(sqrt(5)*n,(1.0+sqrt(5))/2.0) - .465)-2 )"}, {"source_code": "from math import ceil,log\nprint(ceil(log(int(input()),2)))"}, {"source_code": "from math import log, ceil\n\nx = int(raw_input())\n\nprint int(ceil(log(x, 2)))\n"}, {"source_code": "t=input()\nn=int(t) + 1 - 1\nr=0\nc=1\nwhile c<n:\n r+=1\n c*=2\nprint(r)\n"}, {"source_code": "import math\na = int(raw_input())\nx = math.log(a,2)\nprint int(math.ceil(x))"}, {"source_code": "n = int(input())\n\ndef count(i):\n if i == 2:\n return 1\n return 1 + count(i//2 + i%2)\n\nprint(count(n))\n"}, {"source_code": "n = int(input())\n\nk = 2\nm = 1\n\nwhile k < n:\n k = k + k -1\n m = m + 1\n \nif k > n:\n m = m - 1\n\nprint(m)"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\nans = 0\nwhile n != 1:\n ans += 1\n n = n // 2 + n % 2\n\nstdout.write(str(ans))"}, {"source_code": "n = int(input())\n\nif n == 2:\n\tprint(1)\nif n == 3:\n\tprint(2)\nx = 2\ny = 3\ncounter = 0\nwhile x+ y <= n:\n\tx, y = y, x+y\n\tcounter += 1\nprint(2+counter)"}, {"source_code": "n = int(raw_input())\na, b = 1, 1\nc = 0\nwhile a < n:\n\ta, b = b+a, a\n\tc += 1\nprint(c-1)"}, {"source_code": "def process(n):\n a = [0]\n while len(a)<n:\n a.append(a[len(a)/2]+1)\n #print a\n return a[-1]\n\nprint process(int(raw_input()))"}, {"source_code": "def process(n):\n a = [0]\n while len(a)<n:\n a.append(a[len(a)/2]+1)\n #print a\n return a[-1]\n\nprint process(int(raw_input()))"}, {"source_code": "n = int(input())\nans = 0\nif n >= 8:\n\tn *= 2\nwhile n > 2 ** ans:\n\tans += 1\nprint(ans)"}, {"source_code": "n = int(input())\ndp = {}\ndp[1] = 1\ndp[2] = 1\n\n\ndef calc(k):\n if k in dp:\n return dp[k]\n k1, k2 = k // 2, k - k // 2\n s1, s2 = calc(k1), calc(k2)\n if s1 < s2:\n s1, s2 = s2, s1\n if abs(s1 - s2) <= 1:\n return s1 + 1\n else:\n return s1\n\n\nprint(calc(n))\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nn=int(input())\nlin=[i for i in range(1,n+1)]\ntk=0\nfor k in lin:\n\tprint(tk,'k',k)\n\tif (tk+k) > n:\n\t\tprint(k-1)\n\t\tbreak\n\telse:\n\t\ttk+=k\n\n\n\n"}, {"source_code": "import math\n\nn = raw_input()\nn = int(n)\n\nprint int(math.ceil((math.log(n,2)))) "}, {"source_code": "from math import *\nn = int(input())\nprint(round(log(sqrt(5)*n)/log((1.0+sqrt(5))/2.0) -.1) - 2)"}, {"source_code": "n=int(input())\nmaxigr=0\nwhile n>1:\n if n%2==0:\n maxigr+=1\n n//=2\n else:\n n=(n+1)//2\n maxigr+=1\nprint(maxigr)\n"}, {"source_code": "n = int(input())\nk = 1\nst = 0\nwhile k < n:\n k *= 2\n st += 1\nprint(st)"}, {"source_code": "n = int(input())\n\nfor i in range(70):\n if pow(2,i) < n and pow(2,i+1) >= n:\n print(i+1)\n\n"}, {"source_code": "def process(n):\n a = [0, n] \n while a[-1]>1 or a[-2]>0:\n if a[-2]==1:\n a[-2] -= 1\n a[-1] -= 1\n a.append(1)\n elif a[-2]>0:\n a[-1] += a[-2]/2\n a[-2] %= 2\n else:\n a.append(a[-1]/2)\n a[-2] %= 2\n print a\n return len(a)-2\n\nprint process(int(raw_input()))"}, {"source_code": "#n_init = int(input()) \n#n=n_init\ndef sieve(n):\n mark = [i % 2 for i in range(n)]\n mark[1] = 0\n mark[2] = 1\n for value in range(3,n,2):\n if mark[value] == 1:\n for i in range(value * 3, n, value * 2):\n mark[i] = 0\n return mark\ndef getPrimes(m):\n sieves = sieve(m)\n primes = [i for i, f in enumerate(sieves) if f]\n return primes, sieves\ndef isprime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n == 2:\n return True\n if n == 3:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n\n i = 5\n w = 2\n\n while i * i <= n:\n if n % i == 0:\n return False\n\n i += w\n w = 6 - w\n\n return True\ndef find(n):\n\tfor i in range(n, -1, -1):\n\t\tif isprime(i) and (i!=(n-1)):\n\t\t\treturn i\ndef main(n_init):\n\t#n_init = int(input()) \n\tn=n_init\n\ta = find(n)\n\tb = n-a\n\tprint(a,b)\n\tresult = 1\n\twhile b != 0:\n\t\tn = b\n\t\ta = find(n)\n\t\tb = n-a\n\t\tresult += 1\n\t'''\n\tif n_init%2:\n\t\tif result >3:\n\t\t\tresult = 3\n\telif n_init%2==0:\n\t\tif result >2:\n\t\t\tresult = 2\n\t'''\n\treturn result\nprint(main(97764))\nprint(isprime(97729))\n'''\nfor i in range(2, 2000000000):\n\tre = main(i)\n\tif re > 3:\n\t\tprint(re, i)\n'''\n#test"}, {"source_code": "n = int(input())\n\nif n == 2:\n\tprint(1)\nif n == 3:\n\tprint(2)\nx = 2\ny = 3\ncounter = 0\nwhile x+ y <= n:\n\tx, y = y, x+y\n\tcounter += 1\nprint(2+counter)"}, {"source_code": "n = int(input())\n\ndef count(i):\n if i == 2:\n return 1\n return 1 + count(i//2 + i%2)\n\nprint(count(n))\n"}, {"source_code": "from math import ceil, log2\n\nprint(int(ceil(log2(int(input())))))\n"}, {"source_code": "n = int(input())\nimport math\nprint(math.ceil(math.log2(n)))"}, {"source_code": "n=int(input())\nmaxigr=0\nif n==2:\n n=1\n print(1)\n exit()\nelif n==3:\n n=1\n print(2)\n exit()\nelif n==4:\n n=1\n print(2)\n exit()\nelif n==5:\n n=1\n print(3)\n exit()\nwhile n>1:\n if n%3==0:\n maxigr+=2\n n//=3\n elif (n-1)%3==0:\n n=(n-1)//3+1\n maxigr+=2\n else:\n n=(n-2)//3+1\n maxigr+=2\n if n<=5:\n if n==2:\n n=1\n maxigr+=1\n print(maxigr)\n exit()\n elif n==3:\n n=1\n maxigr+=2\n print(maxigr)\n exit()\n elif n==4:\n n=1\n maxigr+=2\n print(maxigr)\n exit()\n elif n==5:\n n=1\n maxigr+=3\n print(maxigr)\n exit()\n"}, {"source_code": "from math import ceil, log\nprint(int(ceil(log(float(raw_input()), 2))))"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase, ascii_uppercase\nfrom fractions import Fraction, gcd\n#from decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\n#getcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] == \"PyPy\":\n import io, atexit\n sys.stdout = io.BytesIO()\n atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n sys.stdin = io.BytesIO(sys.stdin.read())\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\n\ndef getpow(n):\n l = 0\n while (1 << l) < n:\n l += 1\n return l - 1\n\ncache = {1: 0, 2: 1, 3: 2, 4: 2}\ndef get(n):\n if n not in cache:\n # l = 1\n # r = n-1\n # res = get(n//2)\n # while l <= r:\n # mid = (l + r) / 2\n # a, b = get(mid), get(n - mid)\n # print mid, n - mid, \":\", a, b, res\n # if abs(a - b) <= 1:\n # res = max(res, a)\n # res = max(res, b)\n # if a <= b + 1:\n # l = mid + 1\n # else:\n # r = mid - 1\n # cache[n] = res\n a, b = get(n//2), get(n-n//2)\n cache[n] = max(a, b) + 1\n # if a == b:\n # cache[n] = a + 1\n # else:\n return cache[n]\n\ndef todigits(n, d):\n res = []\n while n:\n res.append(n % d)\n n //= d\n return res[::-1]\n\ndef solve(n1, n2):\n # epr(n1, n2)\n if n1 == 1 and n2 == 0:\n return 0\n if n1 == 0:\n return 1 + solve(n2, 0)\n if n2 > n1:\n return 1 + solve(n2-n1, n1)\n elif n2 == n1:\n return 2 + solve(n1, 0)\n else:\n left = n1 - n2\n if left == 1:\n return 1 + solve(2, n2 - 1)\n elif left == 2:\n return 1 + solve(1, n2)\n else:\n if left % 3 == 0:\n return 2 + solve(n2 + n1 // 3, 0)\n elif left % 3 == 1:\n return 1 + solve(2, n2 + n1 // 3 - 1)\n elif left % 3 == 2:\n return 1 + solve(1, n2 + n1 // 3)\n\n\n\nn = read_int()\nprint get(n)\n# print solve(n, 0)\n"}, {"source_code": "import math\nn = int(raw_input())\nx, i = 1, 0\nwhile x < n:\n x, i = x * 2, i + 1\nprint i\n"}, {"source_code": "from math import *\nfrom sys import *\nfrom queue import *\nfrom decimal import *\n\nn=int(input())\nn-=2\nleft=0\nright=n+2\nwhile right-left>1:\n mid=(right+left)//2\n if (mid*mid-mid)//2<=n:\n left=mid\n else:\n right=mid\nprint(left)"}, {"source_code": "#!/usr/bin/python\n\nn = input()\np = 1\nc = 1\nwhile(p < n):\n p *= 2\n c += 1\nprint c - 1"}, {"source_code": "n=int(input())\nmaxigr=0\nif n==2:\n n=1\n print(1)\n exit()\nelif n==3:\n n=1\n print(2)\n exit()\nelif n==4:\n n=1\n print(2)\n exit()\nelif n==5:\n n=1\n print(3)\n exit()\nwhile n>1:\n if n%3==0:\n maxigr+=2\n n//=3\n elif (n-1)%3==0:\n n=(n-1)//3+1\n maxigr+=2\n else:\n n=(n-2)//3+1\n maxigr+=2\n if n<=5:\n if n==2:\n n=1\n maxigr+=1\n print(maxigr)\n exit()\n elif n==3:\n n=1\n maxigr+=2\n print(maxigr)\n exit()\n elif n==4:\n n=1\n maxigr+=2\n print(maxigr)\n exit()\n elif n==5:\n n=1\n maxigr+=3\n print(maxigr)\n exit()\n"}, {"source_code": "import math\nn = int(input())\n\nres = 2\na = 2\nb = 3\nwhile(a+b<n):\n res+=1\n a,b = b,a+b\n\nprint(res)\n"}, {"source_code": "n = input()\nm = 2\nans = 1\n\nwhile m<n:\n m *= 2\n ans += 1\n\nprint ans\n"}, {"source_code": "n = int(input())\n\nif n == 2:\n\tprint(1)\nif n == 3:\n\tprint(2)\nx = 2\ny = 3\ncounter = 0\nwhile x+ y <= n:\n\tx, y = y, x+y\n\tcounter += 1\nprint(2+counter)"}, {"source_code": "import math\nn=int(input())\nt=math.log2(n)\nif t.is_integer():\n print(int(t))\nelse:\n print(int(t)+1)"}, {"source_code": "n, ans = int(input()), 0\nwhile (n > 1):\n if n & 1:\n n = (n - 1) >> 1\n ans += 1\n else:\n n >>= 1\n ans += 1\nprint(ans)\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nans = 0\ncur = 1\nwhile cur<n:\n ans+=1\n cur*=2\nprint ans"}, {"source_code": "n = int(raw_input())\na, b = 0, 1\nc = 0\nwhile a < n:\n\ta, b = b+a, a\n\tc += 1\nprint(c-1)"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase, ascii_uppercase\nfrom fractions import Fraction, gcd\n#from decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\n#getcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] == \"PyPy\":\n import io, atexit\n sys.stdout = io.BytesIO()\n atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n sys.stdin = io.BytesIO(sys.stdin.read())\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\nn = read_int()\n\ncache = {2: 1, 3: 2, 4: 2}\ndef get(n):\n if n not in cache:\n cache[n] = 1 + max(get(n//2), get(n-n//2))\n return cache[n]\n\nprint get(n)\n\n# l = 0\n# while 1 << l < n:\n# l += 1\n# print l\n"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase, ascii_uppercase\nfrom fractions import Fraction, gcd\n#from decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\n#getcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] == \"PyPy\":\n import io, atexit\n sys.stdout = io.BytesIO()\n atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n sys.stdin = io.BytesIO(sys.stdin.read())\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\nn = read_int()\n\ncache = {2: 1, 3: 2, 4: 2}\ndef get(n):\n if n not in cache:\n cache[n] = 1 + max(get(n//2), get(n-n//2))\n return cache[n]\n\nprint get(n)\n\n# l = 0\n# while 1 << l < n:\n# l += 1\n# print l\n"}, {"source_code": "import math\nn, tot, odd = int(input()), 0, 1\nwhile n-1:\n odd = min(odd,n&1)\n n = math.ceil(n/2);tot += 1;\n \nprint(tot-odd)\n\n\n\n\n\n\n\n\n"}, {"source_code": "from math import *\nn = int(input())\nprint(round(log(sqrt(5)*n + 1,(1.0+sqrt(5))/2.0))-3 )"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nans = 0\ncur = 1\nwhile cur<n:\n ans+=1\n cur*=2\nprint ans"}, {"source_code": "n = input()\nans = 0\n\na = 1\nb = 0\nans = 0\nwhile a + b <= n:\n b = b * 2 + a - 1\n a = 2\n ans += 1\n\nprint ans - 1\n\n"}, {"source_code": "from math import *\nn = int(input())\nif n == 4:\n print(2)\nelse:\n print(floor(log(sqrt(5)*n,(1.0+sqrt(5))/2.0) + .5)-2 )"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nn=int(input())\nlin=[i for i in range(1,n+1)]\ntk=0\nfor k in lin:\n\tprint(tk,'k',k)\n\tif (tk+k) > n:\n\t\tprint(k-1)\n\t\tbreak\n\telse:\n\t\ttk+=k\n\n\n\n"}, {"source_code": "player=int(input())\ncounter=1\nrounds=1\nvalue=0\nwhile True:\n value+=counter\n if ( value >= player):\n print (rounds)\n break\n counter*=2\n rounds+=1\n"}, {"source_code": "import math\n\n\n# get line input split by space\ndef getLnInput():\n return input().split()\n\n\n# ceil(a / b) for a > b\ndef ceilDivision(a, b):\n return (a - 1) // b + 1\n\n\ndef main():\n n = int(getLnInput()[0])\n print(math.ceil(math.log2(n)))\n return\n\n\nmain()\n"}, {"source_code": "n = int(input())\na = [0 for i in range(1000)]\na[1] = 2\na[2] = 3\nif n <4:\n print(n-1)\n exit()\ni = 3\nwhile True:\n a[i] = a[i-1] + a[i-2]\n if a[i] >= n:\n print(i - 1)\n exit()\n i += 1"}, {"source_code": "def cal(n):\n if n == 2:\n return 1\n if n % 2 == 0:\n return cal(n / 2) + 1\n return cal(n / 2 + 1) + 1\n\nn = int(raw_input())\nprint cal(n)\n"}, {"source_code": "from math import log, ceil\n\nx = int(raw_input())\n\nprint int(ceil(log(x, 2)))\n"}, {"source_code": "import math\ndef main():\n n = int(input())\n phi = 0.6180339887498948482\n ans = 0\n while n > 1:\n n = round(n * phi)\n ans += 1\n print(ans)\nmain()"}, {"source_code": "from math import log2, ceil\nn = int (input())\nprint (ceil (log2 (n)))"}, {"source_code": "player=int(input())\ncounter=1\nrounds=1\nvalue=0\nwhile True:\n value+=counter\n if ( value >= player):\n print (rounds)\n break\n counter*=2\n rounds+=1\n"}, {"source_code": "n = int(input())\na = [0 for i in range(1000)]\na[1] = 2\na[2] = 3\nif n <4:\n print(n-1)\n exit()\ni = 3\nwhile True:\n a[i] = a[i-1] + a[i-2]\n if a[i] >= n:\n print(i - 1)\n exit()\n i += 1"}, {"source_code": "import math\nn = int(input())\n\nres=1\nif n>2:\n res=2\n\na = 2\nb = 3\nwhile(a+b<n):\n res+=1\n a,b = b,a+b\n\nprint(res)\n"}, {"source_code": "n = int(input())\n\nif n == 2:\n\tprint(1)\nif n == 3:\n\tprint(2)\nx = 2\ny = 3\ncounter = 0\nwhile x+ y <= n:\n\tx, y = y, x+y\n\tcounter += 1\nprint(2+counter)"}, {"source_code": "n = int(input())\n\nk = 2\nm = 1\n\nwhile k < n:\n k = k + k -1\n m = m + 1\n \nif k > n:\n m = m - 1\n\nprint(m)"}, {"source_code": "import math\n\nn = (input())\n\nN = int(n)\nc = 0\n\nwhile N > 1:\n N = N/2\n c = c+1\n\nprint (c)"}, {"source_code": "#!/usr/bin/python\n\nn = input()\np = 1\nc = 1\nwhile(p < n):\n p *= 2\n c += 1\nprint c - 1"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\nans = 0\nwhile n != 1:\n ans += 1\n n = n // 2 + n % 2\n\nstdout.write(str(ans))"}, {"source_code": "n = int(input())\nans = 0\nwhile n > 2 ** ans:\n\tans += 1\nprint(ans)"}, {"source_code": "import math\nn = int(raw_input())\ndef ans(n):\n if n==2:\n return 1\n else:\n return ans(math.ceil(1.0*n/2))+1\nprint ans(n)"}, {"source_code": "import math\n\nn = raw_input()\nn = int(n)\n\nans = 0;\nwhile n>1:\n\tif(n%2!=0):\n\t\tans += 2\n\t\tn = (n-3)/2 + 1\n\telse:\n\t\tans += 1\n\t\tn = (n-2)/2 + 1\n\n#print int(math.ceil((math.log(n,2)))) \nprint int(ans)"}, {"source_code": "n = int(raw_input())\n\ncount = 0\nwhile n != 1:\n n = n/2 + n%2\n count += 1\n\nprint count\n"}, {"source_code": "from math import *\nn = int(input())\nprint(round(log(sqrt(5)*n)/log((1.0+sqrt(5))/2.0)) - 2)"}, {"source_code": "n = int(raw_input())\nk = 1\na = 1; b = 2\nwhile a + b <= n:\n\tc = a + b\n\tb = a\n\ta = c\n\tk += 1\nprint k"}, {"source_code": "n = int(raw_input())\na, b = 1, 1\nc = 0\nwhile a < n:\n\ta, b = b+a, a\n\tc += 1\nprint(c-1)"}, {"source_code": "from sys import stdout\nn = int(input())\ndp = [0 for i in range(n // 2 + 10)]\ndp[1] = 1\ndp[2] = 2\n\nfor i in range(3, n + 10):\n if dp[i - 1] > n:\n stdout.write(str(i - 2))\n break\n dp[i] = dp[i - 1] + dp[i - 2]\n"}, {"source_code": "from math import *\nn = int(input())\n\nprint(floor(log(sqrt(5)*n,(1.0+sqrt(5))/2.0) )-2 )"}, {"source_code": "# get line input split by space\ndef getLnInput():\n return input().split()\n\n\n# ceil(a / b) for a > b\ndef ceilDivision(a, b):\n return (a - 1) // b + 1\n\n\ndef main():\n n = int(getLnInput()[0]) - 2\n ans = 1\n while n >= ans:\n n -= ans\n ans += 1\n print(ans)\n return\n\n\nmain()\n"}, {"source_code": "import math\nn = int(input())\n\ndp = [0 for _ in range(n+1)]\ndp[2] = 1\nfor i in range(3,n+1):\n dp[i] = 1 + dp[math.ceil(i/2)]\n\nprint(dp[n])\n"}, {"source_code": "import math\nn = int(input())\nc=0\nwhile(n!=1):\n if(n%2!=0):\n c=c+1\n c=c+1\n n=n//2\nprint(c)"}, {"source_code": "from math import *\nn = int(input())\n\nprint(round(log(sqrt(5)*n,(1.0+sqrt(5))/2.0) - .455)-2 )"}, {"source_code": "n = int(input())\na = [0 for i in range(1000)]\na[1] = 2\na[2] = 3\ni = 3\nwhile True:\n a[i] = a[i-1] + a[i-2]\n if a[i] > n:\n print(i - 1)\n exit()"}, {"source_code": "n = input()\nans = 0\n\na = 1\nb = 0\nans = 0\nwhile a + b <= n:\n b = b * 2 + a - 1\n a = 2\n ans += 1\n\nprint ans - 1\n\n"}, {"source_code": "n = int( input() )\n\nF = [1,1]\n\nwhile F[-1] < n:\n\tF.append( F[-1] + F[-2] )\n\ns = 0\nfor i in range( len(F) ):\n\ts += F[i]\n\tif s > n:\n\t\tprint( i )\n\t\tbreak"}, {"source_code": "import math\nn = int(input())\nc=0\nwhile(n!=1):\n if(n%2!=0):\n c=c+1\n c=c+1\n n=n//2\nprint(c)"}, {"source_code": "from math import ceil, log2\nn = int(input())\n\nprint(ceil(log2(n)))"}, {"source_code": "from math import ceil as c\n\nn = int(input())\nn -= 1\nx = -1 + (1 + 2 * 4 * n)** .5\nx /= 2\nprint(c(x))"}, {"source_code": "n = int(input())\na = [0 for i in range(1000)]\na[1] = 2\na[2] = 3\nif n <4:\n print(n-1)\n exit()\ni = 3\nwhile True:\n a[i] = a[i-1] + a[i-2]\n if a[i] >= n:\n print(i)\n exit()"}, {"source_code": "from sys import stdout\nn = int(input())\ndp = [0 for i in range(n // 2 + 10)]\ndp[1] = 1\ndp[2] = 2\n\nfor i in range(3, n + 10):\n if dp[i - 1] > n:\n stdout.write(str(i - 2))\n break\n dp[i] = dp[i - 1] + dp[i - 2]\n"}, {"source_code": "n = int(input())\n\ndef count(i):\n if i == 2:\n return 1\n return 1 + count(i//2 + i%2)\n\nprint(count(n))\n"}], "src_uid": "3d3432b4f7c6a3b901161fa24b415b14"} {"source_code": "from timeit import *\nfrom itertools import *\n\ndef get2d(a, b, elem = -1):\n res = []\n for x in range(a):\n res.append(list(repeat(elem, b)))\n return res\n\nQ = 1#int(raw_input())\n\nfor example in range(Q):\n ddd = raw_input().split()\n n = int(ddd[0])\n m = int(ddd[1])\n a = int(ddd[2]) - 1\n b = int(ddd[3]) - 1\n def x():\n start = (a % m) == 0\n end = ((b + 1) % m == 0) or b == n - 1\n if start and end:\n return 1\n if int(a/m) == int(b/m):\n return 1\n if start or end or ((a % m) == ((b % m) + 1)):\n return 2\n if int(a/m) == int(b/m) - 1:\n return 2\n return 3\n print x()\n", "positive_code": [{"source_code": "n, m, a, b = map(int, raw_input().split())\nif b == n:\n b = b + m - b%m\nfull_lines = True\nA = a + (m - a%m)%m\nB = b + (m - b%m)%m\nif (A/m == B/m) or (A/m + 1 == B/m):\n full_lines = False\n\na_from_start = (a % m == 1)\nb_till_end = (b % m == 0)\n\nif m == 1 or m >= n or (a==1 and b==n):\n print 1\nelif a_from_start and b_till_end:\n print 1\nelif A/m == B/m:\n print 1\nelif a_from_start:\n print 2\nelif b_till_end:\n print 2\nelif not full_lines:\n print 2\nelif ((m - a%m)%m + 1 + b % m) == m:\n print 2\nelse:\n print 3\n"}, {"source_code": "def pos(x):\n global m\n global n\n row=x/m\n column=x%m\n p=[row,column]\n return p\nn,m,a,b=(int(i) for i in raw_input().split())\nl=pos(a-1)\npar=l[0]\npac=l[1]\nl=pos(b-1)\npbr=l[0]\npbc=l[1]\nif (par==pbr) or ((pac==0) and (pbc==m-1)) or (pac==0 and b==n):\n print 1\nelif (pac-pbc==1) or (pac==0) or (pbc==m-1) or (a==1) or (b==n) or (pbr-par==1):\n print 2\nelse:\n print 3\n#print par,pac,pbr,pbc\n"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\nn, m, a, b = map(int, input().split(' '))\na-=1; b-=1\nx = a//m; y = b//m\nxx = a%m; yy = b%m\nif (x==y) or (xx==0 and yy==(m-1)) or (b-a+1 == n) or (xx==0 and b==n-1):\n print(1)\nelif yy+1==xx or yy==m-1 or (x+1==y) or xx==0 or b==n-1:\n print(2)\nelse:\n print(3)"}, {"source_code": "\n#------------------------------warmup----------------------------\n# *******************************\n# * AUTHOR: RAJDEEP GHOSH * \n# * NICK : Rajdeep2k * \n# * INSTITUTION: IIEST, SHIBPUR *\n# *******************************\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now---------------------------------------------------\n# t=(int)(input())\nimport math\nfor _ in range(1):\n # n=(int)(input())\n # l=list(map(int,input().split()))\n n,m,a,b=map(int,input().split())\n r1=(a-1)//m\n r2=(b-1)//m\n c1=(a-1)%m +1\n c2=(b-1)%m +1\n if r1==r2:\n print('1')\n elif c1==1 and (c2==m or b==n):\n print('1')\n elif c1==1 or (c2==m or b==n):\n print('2')\n elif r2-r1==1:\n print('2')\n elif c1==c2+1:\n print('2')\n else:\n print('3')"}, {"source_code": "import sys\nfrom array import array # noqa: F401\n\n\ndef input():\n return sys.stdin.buffer.readline().decode('utf-8')\n\n\nn, m, a, b = map(int, input().split())\na, b = a - 1, b - 1\nif b + 1 == n:\n b = (b // m + 1) * m - 1\n\nif a // m == b // m:\n print(1)\nelif a % m == 0 and b % m == m - 1:\n print(1)\nelif b % m + 1 == a % m:\n print(2)\nelif a // m + 1 == b // m:\n print(2)\nelse:\n ans = 1 + (a % m != 0) + (b % m != m - 1)\n print(ans)\n"}, {"source_code": "readints=lambda:map(int, input().strip('\\n').split())\nn,m,a,b=readints()\n\na-=1\nb-=1 # 0-index\n\n\nra=a//m\nrb=b//m\n\n\nia=a%m\nib=b%m\n\nif (ra==rb) or (ia==0 and b==n-1) or (ia==0 and ib==m-1):\n print(1)\nelif (ia==0 and ib<m-1 and b!=n-1) or (ia>0 and (ib==m-1 or b==n-1)) or (ra+1==rb) or (ib+1==ia):\n print(2)\nelse:\n print(3)\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(n,m,a,b):\n\n a -= 1\n b -= 1\n\n if a==b:\n return 1\n\n ar,ac = divmod(a,m)\n br,bc = divmod(b,m)\n \n# an = m - ac\n# bn = bc + 1\n# print 'a:', (ar,ac),an\n# print 'b:', (br,bc),bn\n \n # one row\n if br-ar == 0:\n return 1\n\n # rectangular, all cases \n if ac==0 and (bc==m-1 or b+1==n):\n return 1\n\n # two rows\n if br-ar == 1:\n return 2\n \n #\n if (ac > 0 and (bc < m-1 and b+1 < n)) and bc+1 != ac:\n return 3\n \n return 2\n\nS = input.readline().split(' ')\nassert len(S)==4\nn = int(S[0])\nm = int(S[1])\na = int(S[2])\nb = int(S[3])\nassert 1<=n and n<=10**9\nassert 1<=m and m<=10**9\nassert 1<=a and a<=b and b<=n\n\nanswer = solve(n,m,a,b)\noutput.write('%s\\n' % (answer))\n"}, {"source_code": "from itertools import permutations\nimport sys\nfrom math import *\nics, per, first, last = map(int, raw_input().split())\nper = float(per)\nx1 = int(ceil(first / per))\ny1 = int(first % per)\nx2 = int(ceil(last / per))\ny2 = int(last % per)\n\nif x1 == x2:\n print 1\n exit()\n\nif y1 == 1 and y2 == 0:\n print 1\n exit()\n \nif y1 == 1 and last == ics:\n print 1\n exit()\n \nif per == 1:\n print 1\n exit()\n \nif abs(x1-x2) == 1:\n print 2\n exit()\n\nif y1 == 1:\n print 2\n exit()\n \nif y2 == 0:\n print 2\n exit()\n \nif last == ics:\n print 2\n exit()\n\nif y1-y2 == 1 or y2-y1 == per - 1:\n print 2\n exit()\n \nprint 3\n"}, {"source_code": "#!/usr/bin/python\nimport itertools, math, os, random, re, sys\nrandom.seed (1234)\nwhile True:\n\ts = sys.stdin.readline ().strip ()\n\tif s == '':\n\t\tbreak\n\tn, m, a, b = [int (x) for x in s.split ()]\n\ta -= 1\n\tif (a % m == 0) and (b % m == 0):\n\t\tprint 1\n\telif a / m == b / m:\n\t\tprint 1\n\telif m == 1:\n\t\tprint 1\n\telif b - a == 1:\n\t\tprint 1\n\telif (a % m == 0) and (b == n):\n\t\tprint 1\n\telif (a % m == 0):\n\t\tprint 2\n\telif (b % m == 0):\n\t\tprint 2\n\telif a % m == b % m:\n\t\tprint 2\n\telif a / m + 1 == b / m:\n\t\tprint 2\n\telif b == n:\n\t\tprint 2\n\telse:\n\t\tprint 3\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nn -= 1\na -= 1\nb -= 1\nax = a%m\nay = a/m\nbx = b%m\nby = b/m\nif (ay == by) or ((ax == 0) and (b == n)) or ((ax == 0) and (bx == m-1)):\n print 1\nelif (ay+1 == by) or (ax == 0) or (bx == m-1) or (b == n) or (ax-1 == bx):\n print 2\nelse:\n print 3"}, {"source_code": "x = map(int, raw_input().split())\nn = x[0]\nm = x[1]\na = x[2]-1\nb = x[3]-1\n\nfirst_row = a//m\nlast_row = b//m\nnum = b-a+1\n\nif first_row == last_row:\n print 1\nelif first_row+1 == last_row:\n if num == m * (last_row - first_row + 1):\n print 1\n elif a % m == 0 and b+1==n:\n print 1\n else:\n print 2\nelse:\n if num == m * (last_row - first_row + 1):\n print 1\n elif a % m == 0 and b+1==n:\n print 1\n elif a % m == 0:\n print 2\n elif (b+1) % m == 0:\n print 2\n elif num % m == 0:\n print 2\n elif b+1==n:\n print 2\n else:\n print 3\n "}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef main():\n n, m, a, b = map(int, raw_input().split())\n a -= 1\n b -= 1\n n -= 1\n if a/m == b/m or (a%m == 0 and (b%m == m-1 or b == n)):\n return 1\n if (b/m - a/m) == 1 or a%m == 0 or (b%m == m-1 and (n%m == m-1 or b/m < n/m)) or b == n or a%m-1 == b%m:\n return 2\n return 3\n\nif __name__ == \"__main__\":\n print main()\n"}, {"source_code": "from itertools import permutations\nimport sys\nfrom math import *\nics, per, first, last = map(int, raw_input().split())\nper = float(per)\nx1 = int(ceil(first / per))\ny1 = int(first % per)\nx2 = int(ceil(last / per))\ny2 = int(last % per)\n\nif x1 == x2:\n print 1\n exit()\n\nif y1 == 1 and y2 == 0:\n print 1\n exit()\n \nif y1 == 1 and last == ics:\n print 1\n exit()\n \nif per == 1:\n print 1\n exit()\n \nif abs(x1-x2) == 1:\n print 2\n exit()\n\nif y1 == 1:\n print 2\n exit()\n \nif y2 == 0:\n print 2\n exit()\n \nif last == ics:\n print 2\n exit()\n\nif y1-y2 == 1 or y2-y1 == per - 1:\n print 2\n exit()\n \nprint 3\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nn -= 1\na -= 1\nb -= 1\nax = a%m\nay = a/m\nbx = b%m\nby = b/m\nif (ay == by) or ((ax == 0) and (b == n)) or ((ax == 0) and (bx == m-1)):\n print 1\nelif (ay+1 == by) or (ax == 0) or (bx == m-1) or (b == n) or (ax-1 == bx):\n print 2\nelse:\n print 3"}, {"source_code": "n, m, a, b = map(int, raw_input().split(\" \"))\n\nif((a-1)/m == (b-1)/m or m == 1 or a % m == 1 and b % m == 0 or b == n and a % m == 1):\n\tprint('1')\nelif(a%m-1 == b%m or (a-1)%m-1 == (b-1)%m or a % m == 1 or b % m == 0 or (a-1)/m + 1 == (b-1)/m) or b == n:\n\tprint('2')\nelse:\n\tprint('3')"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef main():\n n, m, a, b = map(int, raw_input().split())\n a -= 1\n b -= 1\n n -= 1\n if a/m == b/m or (a%m == 0 and (b%m == m-1 or b == n)):\n return 1\n if (b/m - a/m) == 1 or a%m == 0 or (b%m == m-1 and (n%m == m-1 or b/m < n/m)) or b == n or a%m-1 == b%m:\n return 2\n return 3\n\nif __name__ == \"__main__\":\n print main()\n"}, {"source_code": "# #/usr/bin/env python\nimport sys\n\n\n################################################\ndef nextToken(func = None):\n c = \"\"\n while fin:\n c = fin.read(1)\n if not c.isspace():\n break\n res = \"\" + c\n while fin:\n c = fin.read(1)\n if c.isspace():\n break\n res += c\n if func:\n return func(res)\n else:\n return res\n\n\ndef nextLine():\n if fin:\n return fin.readline().strip()\n else:\n return \"\"\n\n\nfin, fout = sys.stdin, sys.stdout\n\n#########################\n\ndef solve(m, a, b):\n if a / m == b / m:\n return 1\n if m == 1:\n return 1\n if a % m == 0 and b % m == m - 1:\n return 1\n\n if a / m + 1 == b / m:\n return 2\n if a % m == 0 or b % m == m - 1:\n return 2\n if (b + 1) % m == a % m:\n return 2\n\n return 3\n\nn, m, a, b = map(int, nextLine().split())\na -= 1\nb -= 1\n\nx = [solve(m, a, b), ]\nif b == n - 1:\n x.append(solve(m, a, b + m - 1 - b % m))\n\nprint min(x)\n\n\n"}, {"source_code": "s = raw_input().split()\n\nn = int(s[0])\nw = int(s[1])\na = int(s[2])\nb = int(s[3])\n\n\nimport math\n\nsa = int(math.ceil(float(a) / w))\nsb = int(math.ceil(float(b) / w))\n\n\nif sb * w > n and b == n:\n b = sb * w\n\nh = sb - sa\n\nif h == 0:\n print 1\n exit()\n\nif h > 1:\n ch = 1\nelse:\n ch = 0\n\nif a != (sa - 1) * w + 1:\n ca = 1\nelse:\n ca = 0\n\nif b != sb * w:\n cb = 1\nelse:\n cb = 0\n\nc = ca + cb + ch\nif c == 1 and (ca > 0 or cb > 0):\n c = 2\nif c == 0:\n c = 1\n\nif c == 3 and (a - (sa - 1) * w) == (b - (sb - 1) * w) + 1:\n c = 2\n\nprint c\n"}, {"source_code": "(n, m, a, b) = map(int, raw_input().split())\n\na -= 1\nb -= 1\nn -= 1\n\nr1 = a // m\nc1 = a % m\nr2 = b // m\nc2 = b % m\n\nif r1 == r2 or c1 == 0 and c2 == m - 1 or c1 == 0 and b == n:\n print 1\nelif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c2 == c1 - 1 or b == n:\n print 2\nelse:\n print 3\n\n"}, {"source_code": "import sys\ndef read_values():\n return map(int,raw_input().split())\n\nn, m, a, b = read_values()\na-=1\n# a = first in the delete list.\n# b = first not in the list.\nra=a/m\nca=a%m\nrb=b/m\ncb=b%m\n\nif cb==0:\n cb=m\n rb-=1\n\nleft = ca>0\nright = cb<m and b<n\n\nif left and right:\n if ra==rb:\n res = 1\n elif ra+1==rb:\n res = 2\n elif ca==cb:\n res = 2\n else:\n res = 3\n\nif left and not right:\n if ra==rb:\n res = 1\n else:\n res = 2\n\nif not left and right:\n if ra==rb:\n res = 1\n else:\n res = 2\n\nif not left and not right:\n res = 1\n\nprint res\n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nif m == 1:\n print 1\n exit(0)\nif b == n:\n b = (b+m-1)/m*m\nl = (a+m-1)/m*m\nr = (b+m-1)/m*m\nif r == l:\n print 1\n exit(0)\nif r == l+m:\n if a % m == 1 and b % m == 0:\n print 1\n else:\n print 2\n exit(0)\nd1 = (l-a+1) % m\nd2 = (b-r) % m\nif a % m == 1 and b % m == 0:\n print 1\n exit(0)\nif a % m == 1 or b % m == 0:\n print 2\n exit(0)\nif d1 + d2 == m:\n print 2\n exit(0)\nprint 3\n\n"}, {"source_code": "n,m,a,b=(int(i) for i in raw_input().split())\nra = a/m+1\nrb = b/m+1\nif a%m==0:\n ra-=1\nif b%m==0:\n rb-=1\nca = a%m\ncb = b%m\nif ca==0:\n ca=m\nif cb==0:\n cb=m\nif ra==rb:\n print 1\nelif ((ca==1) and ((cb==m) or (b==n))):\n print 1\nelif (rb-ra==1):\n print 2\nelif ca-cb==1:\n print 2\nelif ((ca==1) or (cb==m)):\n print 2\nelif b==n:\n print 2\nelse:\n print 3\n \n"}, {"source_code": "import sys\n\nn, m, a, b = map(int, sys.stdin.readline().split())\n\nif m == 1:\n print 1\nelse:\n a -= 1\n b -= 1\n\n top = m-(a%m)\n bottom = (b%m)+1\n\n# print top, bottom\n\n if (a == b):\n print 1\n elif (b+1 == n):\n if top == m:\n print 1\n elif (a/m) == (b/m):\n print 1\n else:\n print 2\n elif (a / m) == (b / m):\n print 1\n elif top == m and bottom == m:\n print 1\n elif top + bottom == m:\n print 2\n elif top == m:\n print 2\n elif bottom == m:\n print 2\n else:\n if (a / m)+1 == (b / m):\n print 2\n else:\n print 3\n\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nP, p = divmod(a-1, m)\nQ, q = divmod(b-1, m)\nif P==Q or (p==0 and (q==m-1 or b==n)):\n print 1\nelif P+1==Q or p==0 or (q==m-1 or b==n) or p-1==q:\n print 2\nelse:\n print 3\n"}, {"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b%m == 0:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if (a-1)/m*m+m >= b:\n print 1\n elif (a-1)/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n elif (b-a+1)%m == 0:\n\tprint 2\n else:\n print 3\n \n \n"}, {"source_code": "\nn, m, a, b = map(int, raw_input().split())\n\nstart = a % m\nend = b % m\nif start == 0: start = m\nif end == 0: end = m\n\n\nstart_l = (a - 1) / m\nend_l = (b - 1) / m\n\n\nif start_l == end_l:\n print 1\nelif start_l + 1 == end_l:\n if start == 1 and (b == n or end == m):\n print 1\n else:\n print 2\nelse:\n ans = 1\n if start != 1:\n ans += 1\n if end != m and b != n:\n ans += 1\n\n if start == end + 1:\n ans = min(ans, 2)\n\n print ans\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\n\nstart = a % m\nend = b % m\nif start == 0: start = m\nif end == 0: end = m\n\nstart_l = (a - 1) / m\nend_l = (b - 1) / m\n\n\nif start_l == end_l:\n print 1\nelif start_l + 1 == end_l:\n if start == 1 and (b == n or end == m):\n print 1\n else:\n print 2\nelse:\n ans = 1\n if start != 1:\n ans += 1\n if end != m and b != n:\n ans += 1\n\n if start == end + 1:\n ans = min(ans, 2)\n\n print ans\n"}, {"source_code": "import sys\ndef read_values():\n return map(int,raw_input().split())\n\nn, m, a, b = read_values()\na-=1\n# a = first in the delete list.\n# b = first not in the list.\nra=a/m\nca=a%m\nrb=b/m\ncb=b%m\n\nif cb==0:\n cb=m\n rb-=1\n\nleft = ca>0\nright = cb<m and b<n\n\nif left and right:\n if ra==rb:\n res = 1\n elif ra+1==rb:\n res = 2\n elif ca==cb:\n res = 2\n else:\n res = 3\n\nif left and not right:\n if ra==rb:\n res = 1\n else:\n res = 2\n\nif not left and right:\n if ra==rb:\n res = 1\n else:\n res = 2\n\nif not left and not right:\n res = 1\n\nprint res\n"}, {"source_code": "import sys\n\nn, m, a, b = map(int, sys.stdin.readline().split())\n\nif m == 1:\n print 1\nelse:\n a -= 1\n b -= 1\n\n top = m-(a%m)\n bottom = (b%m)+1\n\n# print top, bottom\n\n if (a == b):\n print 1\n elif (b+1 == n):\n if top == m:\n print 1\n elif (a/m) == (b/m):\n print 1\n else:\n print 2\n elif (a / m) == (b / m):\n print 1\n elif top == m and bottom == m:\n print 1\n elif top + bottom == m:\n print 2\n elif top == m:\n print 2\n elif bottom == m:\n print 2\n else:\n if (a / m)+1 == (b / m):\n print 2\n else:\n print 3\n\n"}, {"source_code": "\nn, m, a, b = map(int, raw_input().split())\n\nstart = a % m\nend = b % m\nif start == 0: start = m\nif end == 0: end = m\n\n\nstart_l = (a - 1) / m\nend_l = (b - 1) / m\n\n\nif start_l == end_l:\n print 1\nelif start_l + 1 == end_l:\n if start == 1 and (b == n or end == m):\n print 1\n else:\n print 2\nelse:\n ans = 1\n if start != 1:\n ans += 1\n if end != m and b != n:\n ans += 1\n\n if start == end + 1:\n ans = min(ans, 2)\n\n print ans\n"}, {"source_code": "\nn, m, a, b = map(int, raw_input().split())\n\nstart = a % m\nend = b % m\nif start == 0: start = m\nif end == 0: end = m\n\n\nstart_l = (a - 1) / m\nend_l = (b - 1) / m\n\n\nif start_l == end_l:\n print 1\nelif start_l + 1 == end_l:\n if start == 1 and (b == n or end == m):\n print 1\n else:\n print 2\nelse:\n ans = 1\n if start != 1:\n ans += 1\n if end != m and b != n:\n ans += 1\n\n if start == end + 1:\n ans = min(ans, 2)\n\n print ans\n"}, {"source_code": "def main():\n\tn, m, a, b = map(int, raw_input().split())\n\ta -= 1\n\tb -= 1\n\ti1, j1 = a / m, a % m\n\ti2, j2 = b / m, b % m\n\tif i1 == i2 or (0 == j1 and b == n - 1) or (0 == j1 and j2 == m - 1): print 1\n\telif i2 == i1 + 1 or 0 == j1 or\tj2 == m - 1 or b == n - 1 or j2 + 1 == j1: print 2\n\telse: print 3\n\nif __name__ == \"__main__\": main()\n"}, {"source_code": "n, m, a, b = map(int, input().split())\nr1, r2, c1, c2 = (a - 1) // m, (b - 1) // m, (a - 1) % m, m - 1 if b == n else (b - 1) % m\nif r1 == r2 or c1 == 0 and c2 == m - 1:\n print(1)\nelif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c1 == c2 + 1:\n print(2)\nelse:\n print(3)"}, {"source_code": "n, m, a, b = map(int, input().split())\n\nr1, r2, c1, c2 = (a - 1) // m, (b - 1) // m, (a - 1) % m, m - 1 if b == n else (b - 1) % m\n\nif r1 == r2 or c1 == 0 and c2 == m - 1:\n\n print(1)\n\nelif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c1 == c2 + 1:\n\n print(2)\n\nelse:\n\n print(3)"}, {"source_code": "n, m, a, b = map(int, input().split())\nr1, r2, c1, c2 = (a - 1) // m, (b - 1) // m, (a - 1) % m, m - 1 if b == n else (b - 1) % m\nif r1 == r2 or c1 == 0 and c2 == m - 1:\n print(1)\nelif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c1 == c2 + 1:\n print(2)\nelse:\n print(3)\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10000000)\n\n\ndef solve():\n n, m, a, b, = rv()\n a -= 1\n b -= 1\n if a // m == b // m or m == 1:\n print(1)\n return\n # now only way it is one is if it is one big square\n first = m - (a - (a // m) * m)\n last = b - (b // m) * m + 1\n if b + 1 == n: last = m\n # print(first, last)\n if first == m and last == m:\n print(1)\n return\n if a // m + 1 == b // m or first + last == m:\n print(2)\n return\n if first == m or last == m:\n print(2)\n return\n print(3)\n\n # print(a, b)\n # firstrow = m - a % m\n # lastrow = b - ()\n # print(firstrow, lastrow)\n\ndef prt(l): return print(' '.join(l))\ndef rv(): return map(int, input().split())\ndef rl(n): return [list(map(int, input().split())) for _ in range(n)]\nif sys.hexversion == 50594544 : sys.stdin = open(\"test.txt\")\nsolve()\n\n\n"}, {"source_code": "n, m, a, b = map(int, input().split())\na -= 1\nx, y = a % m, b % m\nd = b // m - a // m\nif b == n and y: d += 1\nu, v = x == 0, y == 0 or b == n\nprint(1 if u and v or d <= v else 2 if x == y or u or v or d == 1 else 3)"}, {"source_code": "n, m, a, b = map(int, input().split())\n\nr1, r2, c1, c2 = (a - 1) // m, (b - 1) // m, (a - 1) % m, m - 1 if b == n else (b - 1) % m\n\nif r1 == r2 or c1 == 0 and c2 == m - 1:\n\n print(1)\n\nelif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c1 == c2 + 1:\n\n print(2)\n\nelse:\n\n print(3)"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\na -= 1\nb -= 1\na1 = a / m\na2 = a % m\nb1 = b / m\nb2 = b % m\nret = 1\nif a2 == 0:\n\tif b1 > a1 and b2 != m-1 and b != n-1:\n\t\tret += 1\nelse:\n\tif b1 > a1:\n\t\tret += 1\n\tif b1 > a1+1 and b2 != m-1 and m > 2 and b2+1 != a2 and b != n-1:\n\t\tret += 1\nif 1 == m:\n\tret = 1\nprint ret\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\ndef foo():\n global a, b\n if m == 1:\n return 1\n if b == n and b % m != 0:\n b += m - n % m\n if a % m == 1 and b % m == 0:\n return 1\n if (a + m - 1) / m == (b + m - 1) / m:\n return 1\n if (a + m - 1) / m + 1 == (b + m - 1) / m:\n return 2\n if a % m == 1:\n return 2\n if b % m == 0:\n return 2\n x = a % m\n if x == 0:\n x = m\n if x == b % m + 1:\n return 2\n return 3\n\nprint foo()\n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nposa = ( (a-1)/m+1,(a-1)%m+1 )\nposb = ( (b-1)/m+1,(b-1)%m+1 )\nfm = -1\nif n%m!=0:\n fm = n%m\n lr = n/m +1\nelse:\n lr = n/m\nk = 0\nif posa[0]==posb[0] or posa[1]==1 and posb[1]==m or posa[1]==1 and posb[0]==lr and posb[1]==fm:\n k = 1\nelif posa[1]!=1 and posb[1]==m or posa[1]==1 and posb[1]!=m or posa[1]!=1 and posb[0]==lr and posb[1]==fm or posa[0]==posb[0]-1 or posa[1]-1==posb[1]:\n k = 2\nelse:\n k = 3\nprint k\n"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nfrom __future__ import division \nfrom sys import stdin,exit\n\ndef compute(n,m,a,b):\n if m == 1:\n return 1\n if (a%m == 1) and ((b%m == 0) or b == n):\n return 1\n if (b-a) < m:\n if (a-1) % m <= (b-1) %m:\n return 1\n else:\n return 2\n if (a%m == 1) or (b%m == 0) or (b == n) or ((b+1)%m == a%m):\n return 2\n if b//m == (a+m-1)//m:\n return 2\n return 3\n\nif __name__ == \"__main__\":\n n, m, a, b = map(int, stdin.readline().split())\n print(compute(n,m,a,b))\n\n exit(0)\n \n n = 8\n m = 3\n for a in range(1,n+1):\n for b in range(a,n+1):\n print(\"[{0}, {1}]: {2}\".format(a, b, compute(n, m, a, b)))\n\n"}, {"source_code": "nn, m, a, b = map(int, raw_input().split())\nn = ((nn - 1) / m + 1) * m\nif b == nn:\n b = n\n\nif m == 1:\n print 1\nelif b - a + 1 < m:\n if (a - 1) / m != (b - 1) / m:\n print 2\n else:\n print 1\nelif (b - a + 1) % m == 0:\n if a % m == 1:\n print 1\n else:\n print 2\nelif (b - 1) / m - (a - 1) / m < 2:\n print 2\nelse:\n if a % m == 1 or b % m == 0:\n print 2\n else:\n print 3"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nr1, c1 = (a - 1) / m, (a - 1) % m\nr2, c2 = (b - 1) / m, (b - 1) % m\nif b == n: c2 = m - 1\nif r1 == r2 or (c1 == 0 and c2 == m - 1): print \"1\"\nelif r1 + 1 == r2 or c1 == 0 or c2 == m - 1 or c2 + 1 == c1: print \"2\"\nelse: print \"3\"\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\ni = (a - 1) / m\nj = (b - 1) / m\nif i == j or b - a + 1 == n:\n c = 1\nelse:\n x = m - (a - 1) % m\n y = (b - 1) % m + 1\n c = 0\n if x + y == m:\n c = 2\n elif x == m and (y == m or b == n):\n c = 1\n elif x == m or (y == m or b == n):\n c = 2\n elif j - i > 1:\n c = 3\n else:\n c = 2\nprint c"}, {"source_code": "def solve(n, m, a, b):\n\n if ((a - 1) % m == 0 and (b % m == 0 or b == n)) or (b - a + 1) == n or (a - 1) // m == (b - 1) // m:\n return 1\n elif (a % m) == 1 or b == n or b % m == 0 or b % m == (a % m - 1) % m or (b - 1) // m - (a - 1) // m == 1:\n return 2\n else:\n return 3 \n\n\n\n\nans = solve(*map(int, input().split()))\nprint(ans)\n"}, {"source_code": "n,m,a,b = map(int, raw_input().split())\n\nif a>b:\n a,b = b,a\n\nx1 = (a-1)%m\ny1 = (a-1)/m\nx2 = (b-1)%m\ny2 = (b-1)/m\nif m == 1:\n print 1\nelif y1 == y2:\n print 1\nelif x1==0 and b==n:\n print 1\nelif x1==0 and x2 == m-1:\n print 1\nelif m == 2:\n if x1 == 0 and x2 == 1:\n print 1\n else:\n print 2\nelif y2 == y1+1:\n print 2\nelif x1 == x2+1:\n print 2\nelif a==1 or b == n:\n print 2\nelse:\n if x2 == m-1 or x1==0:\n print 2\n else:\n print 3\n"}, {"source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\nimport collections\nfrom itertools import permutations\nfrom collections import defaultdict\n\n\nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#-------------------game starts now-----------------------------------------------------\nn,m,a,b=map(int,input().split())\nc1=a//m\nc2=b//m\nif a%m==0:\n c1-=1\nif b%m==0:\n c2-=1\nif c1==c2 or m==1:\n print(1)\nelse:\n d=c2-c1\n r=3\n if a%m==1:\n r-=1\n if b%m==0 or b==n:\n r-=1\n if d==1 and r>2:\n r-=1\n if r==3 and (a%m==b%m+1 or (a%m==0 and b%m==(m-1))):\n r-=1\n #print(a%m,b%m)\n print(r)"}, {"source_code": "n,m,a,b=map(int,raw_input().split())\na-=1\ns=3\nif (b-1)/m-a/m==0:print 1;exit()\nif a%m==0 and (b%m==0 or b==n) :print 1;exit()\nif b%m==0 or b==n or a%m==0:print 2;exit()\nif b/m-a/m==1 or b%m==a%m :print 2\nelse: print 3\n\n"}, {"source_code": "import math\nn,m,a,b=map(int,input().split())\n\nif (a-1)//m==(b-1)//m:\n print(1)\nelif (a-1)%m==0 and b%m==0:\n print(1)\nelif (a-1)%m==0 and b==n or m==1:\n print(1)\nelif (a-1)%m==0 or b%m==0 or b==n:\n print(2)\nelif abs((a-1)//m - (b-1)//m)==1 or m==2:\n print(2)\nelif (a-1)%m==b%m:\n print(2)\nelse:\n print(3) \n \n"}, {"source_code": "n,m,a,b=map(int,raw_input().split())\nif a==1 and b==n:\n print 1\nelse:\n a-=1\n b-=1\n st = a%m\n if (st!=0): st = m-st\n end = b%m+1\n if end==m: end = 0\n if b==n-1: end=0\n rs = a/m\n re = b/m\n rest = (b-a+1)-end-st\n if rs==re:\n print 1\n elif rest==0:\n print 2\n else:\n a=1+(end!=0)+(st!=0)\n if end+st==m:\n a = min(a,2)\n print a\n"}, {"source_code": "from math import ceil\nn,c,st,end = [int(i) for i in input().split()]\nreme =end%c\nrems = st%c\ndive = ceil(end/c)\ndivs = ceil(st/c)\nif rems==0:\n rems = c\nif (reme==0 and rems==1) or (divs==dive ) or end-st+1==n or (rems==1 and end==n):\n print(str(1))\nelif reme==rems-1 or dive-divs<2 or (reme==0 or rems==1) or end==n :\n print(str(2))\nelse:\n print(str(3))"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\na1,a2=0,0\na-=1\nb-=1\nif m==1 or m>=n:\n a1=1\nelse:\n if a/m == b/m:\n a1=1\n else:\n a1=1\n if a%m!=0:\n a1+=1\n if b%m!=m-1 and (b+1)!=n:\n a1+=1\n\nif b/m == a/m + 1:\n a1=min(a1,2)\n\nif m==1 or m>=n:\n a2=1\nelse:\n if a/m == b/m:\n a2=1\n elif a%m-b%m==1:\n a2=2\n else:\n a2=3\n\nprint min(a1,a2)\n"}, {"source_code": "#!/usr/bin/python3\n\nn, m, a, b = map(int, input().split())\n\na -= 1\nb -= 1\nif a // m == b // m:\n print(1)\nelif a % m == 0 and (b + 1) % m == 0:\n print(1)\nelif a % m == 0 and b + 1 == n:\n print(1)\nelif b + 1 == n:\n print(2)\nelif a % m == 0 or (b + 1) % m == 0:\n print(2)\nelif a % m == (b + 1) % m:\n print(2)\nelif b // m - a // m == 1:\n print(2)\nelif m == 2:\n print(2)\nelse:\n print(3)\n"}, {"source_code": "n, m, a, b = map(int, input().split())\n\nr1, r2, c1, c2 = (a - 1) // m, (b - 1) // m, (a - 1) % m, m - 1 if b == n else (b - 1) % m\n\nif r1 == r2 or c1 == 0 and c2 == m - 1:\n\n print(1)\n\nelif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c1 == c2 + 1:\n\n print(2)\n\nelse:\n\n print(3)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "import sys\nsys.setrecursionlimit(10000000)\n\n\ndef solve():\n n, m, a, b, = rv()\n a -= 1\n b -= 1\n if a // m == b // m or m == 1:\n print(1)\n return\n first = m - (a - (a // m) * m)\n last = b - (b // m) * m + 1\n if b + 1 == n: last = m\n if first == m and last == m:\n print(1)\n return\n if a // m + 1 == b // m or first + last == m:\n print(2)\n return\n if first == m or last == m:\n print(2)\n return\n print(3)\n\ndef prt(l): return print(' '.join(l))\ndef rv(): return map(int, input().split())\ndef rl(n): return [list(map(int, input().split())) for _ in range(n)]\nif sys.hexversion == 50594544 : sys.stdin = open(\"test.txt\")\nsolve()\n\n\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**9+7\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n\nn,m,a,b = Ri()\na-=1;b-=1\nr1 = a//m\nc1 = a%m\nans = 3\nr2 = b//m\nc2 = b%m\n\nif(r2-r1==1 or c1==0 or c2==m-1 or b==n-1 or c1-c2==1):\n \n ans=2\n \nif(r2-r1==0 or c1==0 and (c2==m-1 or b==n-1)):\n\n ans=1\n\nprint(ans)\n"}, {"source_code": "# ---------------------------iye ha aam zindegi---------------------------------------------\nimport math\nimport random\nimport heapq, bisect\nimport sys\nfrom collections import deque, defaultdict\nfrom fractions import Fraction\nimport sys\nimport threading\nfrom collections import defaultdict\nthreading.stack_size(10**8)\nmod = 10 ** 9 + 7\nmod1 = 998244353\n\n# ------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nsys.setrecursionlimit(300000)\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass TreeNode:\n def __init__(self, k, v):\n self.key = k\n self.value = v\n self.left = None\n self.right = None\n self.parent = None\n self.height = 1\n self.num_left = 1\n self.num_total = 1\n\n\nclass AvlTree:\n\n def __init__(self):\n self._tree = None\n\n def add(self, k, v):\n if not self._tree:\n self._tree = TreeNode(k, v)\n return\n node = self._add(k, v)\n if node:\n self._rebalance(node)\n\n def _add(self, k, v):\n node = self._tree\n while node:\n if k < node.key:\n if node.left:\n node = node.left\n else:\n node.left = TreeNode(k, v)\n node.left.parent = node\n return node.left\n elif node.key < k:\n if node.right:\n node = node.right\n else:\n node.right = TreeNode(k, v)\n node.right.parent = node\n return node.right\n else:\n node.value = v\n return\n\n @staticmethod\n def get_height(x):\n return x.height if x else 0\n\n @staticmethod\n def get_num_total(x):\n return x.num_total if x else 0\n\n def _rebalance(self, node):\n\n n = node\n while n:\n lh = self.get_height(n.left)\n rh = self.get_height(n.right)\n n.height = max(lh, rh) + 1\n balance_factor = lh - rh\n n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)\n n.num_left = 1 + self.get_num_total(n.left)\n\n if balance_factor > 1:\n if self.get_height(n.left.left) < self.get_height(n.left.right):\n self._rotate_left(n.left)\n self._rotate_right(n)\n elif balance_factor < -1:\n if self.get_height(n.right.right) < self.get_height(n.right.left):\n self._rotate_right(n.right)\n self._rotate_left(n)\n else:\n n = n.parent\n\n def _remove_one(self, node):\n \"\"\"\n Side effect!!! Changes node. Node should have exactly one child\n \"\"\"\n replacement = node.left or node.right\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = replacement\n else:\n node.parent.right = replacement\n replacement.parent = node.parent\n node.parent = None\n else:\n self._tree = replacement\n replacement.parent = None\n node.left = None\n node.right = None\n node.parent = None\n self._rebalance(replacement)\n\n def _remove_leaf(self, node):\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = None\n else:\n node.parent.right = None\n self._rebalance(node.parent)\n else:\n self._tree = None\n node.parent = None\n node.left = None\n node.right = None\n\n def remove(self, k):\n node = self._get_node(k)\n if not node:\n return\n if AvlTree._is_leaf(node):\n self._remove_leaf(node)\n return\n if node.left and node.right:\n nxt = AvlTree._get_next(node)\n node.key = nxt.key\n node.value = nxt.value\n if self._is_leaf(nxt):\n self._remove_leaf(nxt)\n else:\n self._remove_one(nxt)\n self._rebalance(node)\n else:\n self._remove_one(node)\n\n def get(self, k):\n node = self._get_node(k)\n return node.value if node else -1\n\n def _get_node(self, k):\n if not self._tree:\n return None\n node = self._tree\n while node:\n if k < node.key:\n node = node.left\n elif node.key < k:\n node = node.right\n else:\n return node\n return None\n\n def get_at(self, pos):\n x = pos + 1\n node = self._tree\n while node:\n if x < node.num_left:\n node = node.left\n elif node.num_left < x:\n x -= node.num_left\n node = node.right\n else:\n return (node.key, node.value)\n raise IndexError(\"Out of ranges\")\n\n @staticmethod\n def _is_left(node):\n return node.parent.left and node.parent.left == node\n\n @staticmethod\n def _is_leaf(node):\n return node.left is None and node.right is None\n\n def _rotate_right(self, node):\n if not node.parent:\n self._tree = node.left\n node.left.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.left\n node.left.parent = node.parent\n else:\n node.parent.right = node.left\n node.left.parent = node.parent\n bk = node.left.right\n node.left.right = node\n node.parent = node.left\n node.left = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n def _rotate_left(self, node):\n if not node.parent:\n self._tree = node.right\n node.right.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.right\n node.right.parent = node.parent\n else:\n node.parent.right = node.right\n node.right.parent = node.parent\n bk = node.right.left\n node.right.left = node\n node.parent = node.right\n node.right = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n @staticmethod\n def _get_next(node):\n if not node.right:\n return node.parent\n n = node.right\n while n.left:\n n = n.left\n return n\n\n\n# -----------------------------------------------binary seacrh tree---------------------------------------\nclass SegmentTree1:\n def __init__(self, data, default=2**51, func=lambda a, b: a & b):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass SegmentTree:\n def __init__(self, data, default=0, func=lambda a, b: a + b):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------------------iye ha chutiya zindegi-------------------------------------\nclass Factorial:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorials = [1, 1]\n self.invModulos = [0, 1]\n self.invFactorial_ = [1, 1]\n\n def calc(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.factorials):\n return self.factorials[n]\n nextArr = [0] * (n + 1 - len(self.factorials))\n initialI = len(self.factorials)\n prev = self.factorials[-1]\n m = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = prev * i % m\n self.factorials += nextArr\n return self.factorials[n]\n\n def inv(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n^(-1)\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n p = self.MOD\n pi = n % p\n if pi < len(self.invModulos):\n return self.invModulos[pi]\n nextArr = [0] * (n + 1 - len(self.invModulos))\n initialI = len(self.invModulos)\n for i in range(initialI, min(p, n + 1)):\n next = -self.invModulos[p % i] * (p // i) % p\n self.invModulos.append(next)\n return self.invModulos[pi]\n\n def invFactorial(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate (n^(-1))!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.invFactorial_):\n return self.invFactorial_[n]\n self.inv(n) # To make sure already calculated n^-1\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\n initialI = len(self.invFactorial_)\n prev = self.invFactorial_[-1]\n p = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\n self.invFactorial_ += nextArr\n return self.invFactorial_[n]\n\n\nclass Combination:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorial = Factorial(MOD)\n\n def ncr(self, n, k):\n if k < 0 or n < k:\n return 0\n k = min(k, n - k)\n f = self.factorial\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\n\n\n# --------------------------------------iye ha combinations ka zindegi---------------------------------\ndef powm(a, n, m):\n if a == 1 or n == 0:\n return 1\n if n % 2 == 0:\n s = powm(a, n // 2, m)\n return s * s % m\n else:\n return a * powm(a, n - 1, m) % m\n\n\n# --------------------------------------iye ha power ka zindegi---------------------------------\ndef sort_list(list1, list2):\n zipped_pairs = zip(list2, list1)\n\n z = [x for _, x in sorted(zipped_pairs)]\n\n return z\n\n\n# --------------------------------------------------product----------------------------------------\ndef product(l):\n por = 1\n for i in range(len(l)):\n por *= l[i]\n return por\n\n\n# --------------------------------------------------binary----------------------------------------\ndef binarySearchCount(arr, n, key):\n left = 0\n right = n - 1\n\n count = 0\n\n while (left <= right):\n mid = int((right + left) / 2)\n\n # Check if middle element is\n # less than or equal to key\n if (arr[mid] < key):\n count = mid + 1\n left = mid + 1\n\n # If key is smaller, ignore right half\n else:\n right = mid - 1\n\n return count\n\n\n# --------------------------------------------------binary----------------------------------------\ndef countdig(n):\n c = 0\n while (n > 0):\n n //= 10\n c += 1\n return c\ndef binary(x, length):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\ndef countGreater(arr, n, k):\n l = 0\n r = n - 1\n\n # Stores the index of the left most element\n # from the array which is greater than k\n leftGreater = n\n\n # Finds number of elements greater than k\n while (l <= r):\n m = int(l + (r - l) / 2)\n if (arr[m] >= k):\n leftGreater = m\n r = m - 1\n\n # If mid element is less than\n # or equal to k update l\n else:\n l = m + 1\n\n # Return the count of elements\n # greater than k\n return (n - leftGreater)\n\n\n# --------------------------------------------------binary------------------------------------\nn,m,a,b=map(int,input().split())\nans=3\nif a%m==1:\n ans-=1\nif b%m==0 or b==n:\n ans-=1\nif m==1:\n print(1)\n sys.exit(0)\nelif (a-1)//m==(b-1)//m:\n print(1)\n sys.exit(0)\nelif (a%m-b%m)%m==1:\n print(min(2,ans,(b-1)//m-(a-1)//m+1))\n sys.exit(0)\nprint(min(ans,(b-1)//m-(a-1)//m+1))"}, {"source_code": "\n\nn, m, a, b = map(int, input().split())\n\n\nif m == 1:\n print(\"1\")\nelif (a - 1) // m == (b - 1) // m:\n print(\"1\")\nelif abs((a - 1) // m - (b - 1) // m) == 1 and a % m != 1:\n print(\"2\")\nelif b == n or b % m == 0:\n if a % m == 1:\n print(\"1\")\n else:\n print(\"2\")\nelif a % m == 1 or ((b + (m - a % m + 1)) % m) == 0:\n print(\"2\")\nelse:\n print(\"3\")\n\n\n\n\n\n"}, {"source_code": "#!/usr/bin/python2\n#-*- coding: utf-8 -*-\n\nimport sys,math\n\n#ret = raw_input()\n#ret = ret.split(' ')\n\n#text = raw_input().rstrip()\n\n#znak = sys.stdin.read(1) \n\n#pole=[[]*n for r in xrange(n)]\n\n\n\nn,m,a,b = map(int,raw_input().split())\n\nanaradku = a % m \nbnaradku = b % m \nif anaradku == 0 : anaradku = m\nif bnaradku == 0 : bnaradku = m\n\npocet = 0\nif (((a-1)/m) != ((b-1)/m)-1) or bnaradku == (anaradku -1) :\n pocet = 1\n\n\nif (((a-1)/m) != ((b-1)/m)) and (m != 1):\n if anaradku != 1 :\n pocet += 1\n\n if bnaradku != m and bnaradku != (anaradku -1) and (b != n or (((a-1)/m) == ((b-1)/m)-1) ):\n pocet += 1\n\nprint max(1,pocet)\n\n"}, {"source_code": "#!/usr/bin/python\nimport math\n\nline = raw_input()\nn,m,a,b = [int(x) for x in line.split()]\n\na -= 1\nb -= 1\n\ndef find(n,m,a,b):\n nrows = n/m\n if n%m:\n nrows += 1\n\n arow = a/m\n brow = b/m\n\n if arow == brow:\n return 1\n\n if (b+1)%m == 0: #last in end\n if a%m == 0: #first in start\n return 1\n else:\n return 2\n\n if a%m == 0:\n if (b+1)%m == 0 or b == n-1:\n return 1\n else:\n return 2\n\n if b == n-1:\n if a%m == 0:\n return 1\n else:\n return 2\n\n if a%m == (b+1)%m:\n return 2\n\n if brow - arow >= 2:\n return 3\n else:\n return 2\n\n return 2\n\nprint find(n,m,a,b)\n"}, {"source_code": "\nn,m,a,b = map(int,raw_input().split())\nla = (a+m-1)/m\nlb = (b+m-1)/m\nif la == lb or (a%m==1 and (b%m==0 or b==n)) or m==1:\n print 1\nelif la + 1 == lb or a%m==1 or b%m==0 or b==n or (b%m+1)%m==a%m:\n print 2\nelse:\n print 3"}, {"source_code": "n,m,a,b=map(int,raw_input().split())\nif a==1 and b==n:\n\tprint 1\nelse:\n\ta-=1\n\tb-=1\n\tst = a%m\n\tif (st!=0): st = m-st\n\tend = b%m+1\n\tif end==m: end = 0\n\tif b==n-1: end=0\n\trs = a/m\n\tre = b/m\n\trest = (b-a+1)-end-st\n\tif rs==re:\n\t\tprint 1\n\telif rest==0:\n\t\tprint 2\n\telse:\n\t\ta=1+(end!=0)+(st!=0)\n\t\tif end+st==m:\n\t\t\ta = min(a,2)\n\t\tprint a\n\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(n,m,a,b):\n\n a -= 1\n b -= 1\n\n if a==b:\n return 1\n\n ar,ac = divmod(a,m)\n br,bc = divmod(b,m)\n \n# an = m - ac\n# bn = bc + 1\n# print 'a:', (ar,ac),an\n# print 'b:', (br,bc),bn\n \n # one row\n if br-ar == 0:\n return 1\n\n # rectangular, all cases \n if ac==0 and (bc==m-1 or b+1==n):\n return 1\n\n # two rows\n if br-ar == 1:\n return 2\n \n #\n if (ac > 0 and (bc < m-1 and b+1<n)) and bc+1 != ac:\n return 3\n \n return 2\n\nS = input.readline().split(' ')\nassert len(S)==4\nn = int(S[0])\nm = int(S[1])\na = int(S[2])\nb = int(S[3])\nassert 1<=n and n<=10**9\nassert 1<=m and m<=10**9\nassert 1<=a and a<=b and b<=n\n\nanswer = solve(n,m,a,b)\noutput.write('%s\\n' % (answer))\n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\na=a-1\nif (a%m==0 and (b%m ==0 or b==n)) or (a/m==b/m): print 1\nelif a%m == b%m or a%m==0 or b%m==0 or b==n or (abs(a/m-b/m)==1): print 2\nelse: print 3\n"}, {"source_code": "def readin():\n\treturn raw_input();\n\ndef prt(n,w,a,b):\n\tfor i in xrange(1,n+1):\n\t\tif i >= a and i <= b:\n\t\t\tprint \"x\",\n\t\telse:\n\t\t\tprint \"o\",\n\t\tif i % w == 0:\n\t\t\tprint;\n\tprint;\n(n,w,a,b)=[int(x) for x in readin().split()]\n#prt(n,w,a,b)\n\nla = a % w\nif la==0: la = w\n\nlb = b % w\nif lb==0: lb = w\n\nif a % w == 0:\n\tra = a/w\nelse:\n\tra = a/w + 1\nif b % w == 0:\n\trb = b/w\nelse:\n\trb = b/w+1\n\nif la == 1 and lb == w:\n\tans = 1\nelif ra == rb:\n\tans = 1\nelif lb+1 == la:\n\tans = 2\nelif b == n:\n\tif la == 1:\n\t\tans = 1\n\telse:\n\t\tans = 2\nelif la==1 or lb==w:\n\tans = 2\nelif ra+1 == rb:\n\tans = 2\nelse:\n\tans = 3\nprint ans\n"}], "negative_code": [{"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b%m == 0:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if (a-1)/m*m+m >= b:\n print 1\n elif (a-1)/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n else:\n print 3\n \n \n"}, {"source_code": "n, m, a, b = map(int, input().split())\na -= 1\nx, y = a % m, b % m\ni, j = a // m, b // m\nu, v = x == 0, y == 0 or b == n\nprint(1 if u and v or i == j else 2 if x == y or u or v or j - i == 1 else 3)"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nif m == 1:\n print 1\nelif b - a + 1 < m:\n if (a - 1) / m != (b - 1) / m:\n print 2\n else:\n print 1\nelif (b - a + 1) % m == 0:\n if a % m == 1:\n print 1\n else:\n print 2\nelif (b - 1) / m - (a - 1) / m < 2:\n print 2\nelse:\n if a % m == 1 or b % m == 0:\n print 2\n else:\n print 3"}, {"source_code": "#!/usr/bin/python\nimport math\n\nline = raw_input()\nn,m,a,b = [int(x) for x in line.split()]\n\na -= 1\nb -= 1\n\ndef find(n,m,a,b):\n nrows = n/m\n if n%m:\n nrows += 1\n\n arow = a/m\n brow = b/m\n\n if arow == brow:\n return 1\n\n if a == 0 and b == n-1:\n return 1\n\n if (b+1)%m == 0: #last in end\n if a%m == 0: #first in start\n return 1\n else:\n return 2\n\n if a%m == 0:\n if (b+1)%m == 0:\n return 1\n else:\n return 2\n\n if a == b+1:\n return 2\n\n if brow - arow >= 2:\n return 3\n else:\n return 2\n\n return 2\n\nprint find(n,m,a,b)\n"}, {"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if a/m*m+m >= b:\n print 1\n elif a/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n else:\n print 3\n \n \n"}, {"source_code": "import sys\nsys.setrecursionlimit(10000000)\n\n\ndef solve():\n n, m, a, b, = rv()\n a -= 1\n b -= 1\n if a // m == b // m or m == 1:\n print(1)\n return\n # now only way it is one is if it is one big square\n first = m - (a - (a // m) * m)\n last = b - (b // m) * m + 1\n # print(first, last)\n if first == m and last == m:\n print(1)\n return\n if a // m + 1 == b // m or first + last == m:\n print(2)\n return\n if first == m or last == m:\n print(2)\n return\n print(3)\n\n # print(a, b)\n # firstrow = m - a % m\n # lastrow = b - ()\n # print(firstrow, lastrow)\n\ndef prt(l): return print(' '.join(l))\ndef rv(): return map(int, input().split())\ndef rl(n): return [list(map(int, input().split())) for _ in range(n)]\nif sys.hexversion == 50594544 : sys.stdin = open(\"test.txt\")\nsolve()\n\n\n"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nfrom sys import stdin\n\ndef compute(n,m,a,b):\n if (b-a) < m:\n if (a-1) % m <= (b-1) %m:\n return 1\n else:\n return 2\n res = 1 \n if a % m != 1:\n res += 1\n if b % m != 0 and b != n:\n res += 1\n if (b % m) +1 == a %m:\n return min(res,2)\n return res\n\nif __name__ == \"__main__\":\n n, m, a, b = map(int, stdin.readline().split())\n print(compute(n,m,a,b))\n\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(n,m,a,b):\n\n if a==b:\n return 1\n\n ra,beg_a = divmod(a,m)\n rb,beg_b = divmod(b,m)\n na = m - beg_a + 1\n nb = beg_b\n# print 'a:',ra,beg_a,na\n# print 'b:',rb,beg_b,nb\n \n if rb-ra == 0:\n return 1\n \n if rb-ra == 1:\n if na%m == 0 and nb == 0:\n return 1\n return 2\n \n if na % m == 0 and nb == 0:\n return 1\n \n if na % m > 0 and nb > 0 and (na+nb) % m > 0:\n return 3\n \n return 2\n\nS = input.readline().split(' ')\nassert len(S)==4\nn = int(S[0])\nm = int(S[1])\na = int(S[2])\nb = int(S[3])\nassert 1<=n and n<=10**9\nassert 1<=m and m<=10**9\nassert 1<=a and a<=b and b<=n\n\nanswer = solve(n,m,a,b)\noutput.write('%s\\n' % (answer))\n"}, {"source_code": "n, m, a, b = map(int, input().split())\na -= 1\nif b == n: b += (m - b) % m\nx, y = a % m, b % m\nprint([1, 2 - (x * y == 0), 3 - (x == y) - (x == y == 0)][min(b // m - a // m, 2)])"}, {"source_code": "import sys\n\nn, m, a, b = map(int, sys.stdin.readline().split())\n\nif m == 1:\n print 1\nelse:\n a -= 1\n b -= 1\n\n top = m-(a%m)\n bottom = (b%m)+1\n\n# print top, bottom\n\n if (a == b):\n print 1\n elif (a / m) == (b / m):\n print 1\n elif top == m and bottom == m:\n print 1\n elif top + bottom == m:\n print 2\n elif top == m:\n print 2\n elif bottom == m:\n print 2\n else:\n if a+1 == b:\n print 2\n else:\n print 3\n\n"}, {"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b%m == 0:\n print 1\n# elif b == n:\n# print 1\n else:\n print 2\nelse:\n if a/m*m+m >= b:\n print 1\n elif a/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n# elif b == n:\n# print 2\n else:\n print 3\n \n \n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\na -= 1\nb -= 1\na1 = a / m\na2 = a % m\nb1 = b / m\nb2 = b % m\nret = 1\nif a2 == 0:\n\tif b1 > a1:\n\t\tret += 1\nelse:\n\tif b1 > a1:\n\t\tret += 1\n\tif b1 > a1+1 and b2 != m-1:\n\t\tret += 1\nprint ret\n"}, {"source_code": "from timeit import *\nfrom itertools import *\n\ndef get2d(a, b, elem = -1):\n res = []\n for x in range(a):\n res.append(list(repeat(elem, b)))\n return res\n\nQ = 1#int(raw_input())\n\nfor example in range(Q):\n ddd = raw_input().split()\n n = int(ddd[0])\n m = int(ddd[1])\n a = int(ddd[2]) - 1\n b = int(ddd[3]) - 1\n def x():\n start = (a % m) == 0\n end = ((b + 1) % m == 0) or b == n - 1\n if start and end:\n return 1\n if int(a/m) == int(b/m):\n return 1\n if start or end or ((a % m) == ((b % m) + 1)):\n return 2\n return 3\n print x()"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nif b == n:\n b = b + m - b%m\nfull_lines = True\nA = a + m - a%m\nB = b + m - b%m\nif (A/m == B/m) or (A/m + 1 == B/m):\n full_lines = False\n\na_from_start = (a % m == 1)\nb_till_end = (b % m == 0)\n\nif m == 1 or m >= n or (a==1 and b==n):\n print 1\nelif a_from_start and b_till_end:\n print 1\nelif a/m == b/m:\n print 1\nelif a_from_start:\n print 2\nelif b_till_end:\n print 2\nelif not full_lines:\n print 2\nelif (((a + m - a%m)/m) * m - a+1) + b % m == m:\n print 2\nelse:\n print 3\n"}, {"source_code": "def solve(n, m, a, b):\n\n if ((a - 1) % m == 0 and b % m == 0) or (b - a + 1) == n:\n return 1\n elif a == 1 or b == n or b % m == 0 or (a - 1) % m + b % m == m:\n return 2\n else:\n return 3 \n\n\n\n\nans = solve(*map(int, input().split()))\nprint(ans)\n"}, {"source_code": "n, m, a, b = map(int, input().split())\nc1, c2 = (a - 1) % m, (b - 1) % m\nif (a - 1) // m == (b - 1) // m or c1 == 0 and c2 == m - 1:\n print(1)\nelif c1 == 0 or c2 == m - 1 or c1 == c2 + 1:\n print(2)\nelse:\n print(3)"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nposa = ( (a-1)/m+1,(a-1)%m+1 )\nposb = ( (b-1)/m+1,(b-1)%m+1 )\nif n%m!=0:\n fm = n%m\n lr = n/m +1\nelse:\n lr = n/m\nk = 0\nif posa[0]==posb[0] or posa[1]==1 and posb[1]==m or posa[1]==1 and posb[0]==lr and posb[1]==fm:\n k = 1\nelif posa[1]!=1 and posb[1]==m or posa[1]==1 and posb[1]!=m or posa[1]!=1 and posb[0]==lr and posb[1]==fm:\n k = 2\nelse:\n k = 3\nprint k\n"}, {"source_code": "import sys\n\nn, m, a, b = map(int, sys.stdin.readline().split())\n\nif m == 1:\n print 1\nelse:\n a -= 1\n b -= 1\n\n top = m-(a%m)\n bottom = (b%m)+1\n\n# print top, bottom\n\n if (a == b):\n print 1\n elif (b+1 == n):\n if top == m:\n print 1\n else:\n print 2\n elif (a / m) == (b / m):\n print 1\n elif top == m and bottom == m:\n print 1\n elif top + bottom == m:\n print 2\n elif top == m:\n print 2\n elif bottom == m:\n print 2\n else:\n if (a / m)+1 == (b / m):\n print 2\n else:\n print 3\n\n"}, {"source_code": "n,m,a,b=map(int,input().split())\na-=1\nif a//m==b//m:\n print(1)\nelif a%m==0 and b%m==0:\n print(1)\nelif a%m==0 and b==n:\n print(1)\nelif a%m==0 or b%m==0 or b==n:\n print(2)\nelif abs(a//m-b//m)==1:\n print(2)\nelif a%m==b%m:\n print(2)\nelse:\n print(3) \n \n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nposa = ( (a-1)/m+1,(a-1)%m+1 )\nposb = ( (b-1)/m+1,(b-1)%m+1 )\nif n%m!=0:\n fm = n%m\n lr = n/m +1\nelse:\n lr = n/m\nk = 0\nif posa[0]==posb[0] or posa[1]==1 and posb[1]==m or posa[1]==1 and posb[0]==lr and posb[1]==fm:\n k = 1\nelif posa[1]!=1 and posb[1]==m or posa[1]==1 and posb[1]!=m or posa[1]!=1 and posb[0]==lr and posb[1]==fm:\n k = 2\nelse:\n k = 3\nprint k\n"}, {"source_code": "s = raw_input().split()\n\nn = int(s[0])\nw = int(s[1])\na = int(s[2])\nb = int(s[3])\n\n\nimport math\n\nsa = int(math.ceil(float(a) / w))\nsb = int(math.ceil(float(b) / w))\n\nh = sb - sa\n\nif h == 0:\n print 1\n exit()\n\nif h > 1:\n ch = 1\nelse:\n ch = 0\n\nif a != 1:\n ca = 1\nelse:\n ca = 0\n\nif b != sb * w:\n cb = 1\nelse:\n cb = 0\n\nc = ca + cb + ch\nif c == 1 and (ca > 0 or cb > 0):\n c = 2\n\nprint c\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef main():\n n, m, a, b = map(int, raw_input().split())\n a -= 1\n b -= 1\n n -= 1\n if a/m == b/m or (a%m == 0 and b%m == m-1):\n return 1\n if abs(a/m - b/m) == 1:\n return 2\n if a%m == 0 and ((n+1)%m == 0 or b/m < n/m):\n return 2\n if b%m == m-1 and ((n+1)%m == 0 or b/m < n/m):\n return 2\n return 3\n\nif __name__ == \"__main__\":\n print main()\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split(\" \"))\n\nif(b-a <= m-1 or a % m == 1 and b % m == 0 or b == n):\n\tprint('1')\nelif(a%m-1 == b%m or a % m == 1 or b % m == 0):\n\tprint('2')\nelse:\n\tprint('3')"}, {"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b%m == 0:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if (a-1)/m*m+m >= b:\n print 1\n elif (a-1)/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n elif (a-b)%m == 0:\n\tprint 2\n else:\n print 3\n \n \n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(n,m,a,b):\n\n a -= 1\n b -= 1\n\n if a==b:\n return 1\n\n ar,ac = divmod(a,m)\n br,bc = divmod(b,m)\n \n# an = m - ac\n# bn = bc + 1\n# print 'a:', (ar,ac),an\n# print 'b:', (br,bc),bn\n \n # one row\n if br-ar == 0:\n return 1\n\n # rectangular, all cases \n if ac==0 and bc==m-1:\n return 1\n\n # two rows\n if br-ar == 1:\n return 2\n \n #\n if (ac > 0 and bc < m-1) and bc+1 != ac:\n return 3\n \n return 2\n\nS = input.readline().split(' ')\nassert len(S)==4\nn = int(S[0])\nm = int(S[1])\na = int(S[2])\nb = int(S[3])\nassert 1<=n and n<=10**9\nassert 1<=m and m<=10**9\nassert 1<=a and a<=b and b<=n\n\nanswer = solve(n,m,a,b)\noutput.write('%s\\n' % (answer))\n"}, {"source_code": "#!/usr/bin/python2\n#-*- coding: utf-8 -*-\n\nimport sys,math\n\n#ret = raw_input()\n#ret = ret.split(' ')\n\n#text = raw_input().rstrip()\n\n#znak = sys.stdin.read(1) \n\n#pole=[[]*n for r in xrange(n)]\n\n\n\nn,m,a,b = map(int,raw_input().split())\n\nanaradku = a % m \nbnaradku = b % m \nif anaradku == 0 : anaradku = m\nif bnaradku == 0 : bnaradku = m\n\npocet = 1\n\nif anaradku != 1 :\n pocet += 1\n\nif bnaradku != m and bnaradku != anaradku -1 :\n pocet += 1\n\nprint pocet\n\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nif b == n:\n b = b + m - b%m\nfull_lines = True\nif (a/m == b/m) or (a/m + 1 == b/m):\n full_lines = False\n\na_from_start = (a % m == 1)\nb_till_end = (b % m == 0)\n\nif m == 1 or m >= n or (a==1 and b==n):\n print 1\nelif a_from_start and b_till_end:\n print 1\nelif a/m == b/m:\n print 1\nelif a_from_start:\n print 2\nelif b_till_end:\n print 2\nelif not full_lines:\n print 2\nelif a % m + b % m == m:\n print 2\nelse:\n print 3\n"}, {"source_code": "\n\nn, m, a, b = map(int, input().split())\n\n\nif (a - 1) // m == (b - 1) // m:\n print(\"1\")\nelif abs((a - 1) // m - (b - 1) // m) == 1 and a % m != 1:\n print(\"2\")\nelif b == n or b % m == 0:\n if a % m == 1:\n print(\"1\")\n else:\n print(\"2\")\nelif a % m == 1 or ((b + (m - a % m + 1)) % m) == 0:\n print(\"2\")\nelse:\n print(\"3\")\n\n\n\n\n\n"}, {"source_code": "n, m, a, b = map(int, input().split())\na -= 1\nx, y = a % m, b % m\ni, j = a // m, b // m\nprint((x > 0) + (y > 0) + (i != j) - (x == y != 0))"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\nn, m, a, b = map(int, input().split(' '))\na-=1; b-=1\nx = a//m; y = b//m\nxx = a%m; yy = b%m\nif (x==y) or (xx==0 and yy==(m-1)) or (b-a+1 == n):\n print(1)\nelif yy+1==xx or yy==m-1 or (x+1==y) or xx==0:\n print(2)\nelse:\n print(3)"}, {"source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\nimport collections\nfrom itertools import permutations\nfrom collections import defaultdict\n\n\nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#-------------------game starts now-----------------------------------------------------\nn,m,a,b=map(int,input().split())\nc1=a//m\nc2=b//m\nif a%m==0:\n c1-=1\nif b%m==0:\n c2-=1\nif c1==c2 or m==1:\n print(1)\nelse:\n d=c2-c1\n r=3\n if a%m==1:\n r-=1\n if b%m==0 or b==n:\n r-=1\n if d==1 and r>1:\n r-=1\n if r==3 and (a%m==b%m+1 or (a%m==0 and b%m==(m-1))):\n r-=1\n #print(a%m,b%m)\n print(r)"}, {"source_code": "\n#------------------------------warmup----------------------------\n# *******************************\n# * AUTHOR: RAJDEEP GHOSH * \n# * NICK : Rajdeep2k * \n# * INSTITUTION: IIEST, SHIBPUR *\n# *******************************\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now---------------------------------------------------\n# t=(int)(input())\nimport math\nfor _ in range(1):\n # n=(int)(input())\n # l=list(map(int,input().split()))\n n,m,a,b=map(int,input().split())\n r1=a-1//m\n r2=b-1//m\n c1=(a-1)%m +1\n c2=(b-1)%m +1\n if r1==r2:\n print('1')\n elif c1==1 and (c2==m or b==n):\n print('1')\n elif r2-r1==1:\n print('2')\n elif c1-c2==1:\n print('2')\n else:\n print('3')"}, {"source_code": "n,m,a,b=(int(i) for i in raw_input().split())\nra = a/m+1\nrb = b/m+1\nca = a%m\ncb = b%m\nif ca==0:\n ca=m\nif cb==0:\n cb=m\nif ra==rb:\n print 1\nelif ((ca==1) and (cb==m)):\n print 1\nelif (rb-ra==1):\n print 2\nelif ca-cb==1:\n print 2\nelif ((ca==1) or (cb==m)):\n print 2\nelse:\n print 3\n \n"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\nn, m, a, b = map(int, input().split(' '))\na-=1; b-=1\nx = a//m; y = b//m\nxx = a%m; yy = b%m\nif (x==y) or (xx==0 and yy==(m-1)) or (b-a+1 == n):\n print(1)\nelif yy+1==xx or yy==m-1 or (x+1==y) or xx==0:\n print(2)\nelse:\n print(3)"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\ni = (a - 1) / m\nj = (b - 1) / m\nif i == j or b - a + 1 == n:\n c = 1\nelse:\n x = (a - 1) % m\n y = b % m\n c = 0\n if j - i > 1:\n c += 1\n if x != 0:\n c += 1\n if y != 0 and b != n:\n c += 1\nprint c"}, {"source_code": "from itertools import permutations\nimport sys\nics, per, first, last = map(int, raw_input().split())\nx1 = first / per\ny1 = first % per\nx2 = last / per\ny2 = last % per\n\nif x1 == x2:\n print 1\n exit()\n\nif y1 == 1 and y2 == 0:\n print 1\n exit()\n \nif y1 == 1 and last == ics:\n print 1\n exit()\n \nif x1-x2 == 1:\n print 2\n exit()\n\nif y1 == 1:\n print 2\n exit()\n \nif y2 == 0:\n print 2\n exit()\n \nif last == ics:\n print 2\n exit()\n\nif y1-y2 == 1:\n print 2\n exit()\n \nprint 3\n"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\nn, m, a, b = map(int, input().split(' '))\na-=1; b-=1\nx = a//m; y = b//m\nxx = a%m; yy = b%m\nif (x==y) or (xx==0 and yy==(m-1)) or (b-a+1 == n):\n print(1)\nelif yy+1==xx or yy==m-1 or (x+1==y) or xx==0 or b==n-1:\n print(2)\nelse:\n print(3)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef main():\n n, m, a, b = map(int, raw_input().split())\n a -= 1\n b -= 1\n n -= 1\n if a/m == b/m or (a%m == 0 and b%m == m-1 and ((n+1)%m == 0 or b/m < n/m)):\n return 1\n if abs(a/m - b/m) == 1:\n return 2\n if a%m == 0 and ((n+1)%m == 0 or b/m < n/m):\n return 2\n if b%m == m-1 and ((n+1)%m == 0 or b/m < n/m):\n return 2\n return 3\n\nif __name__ == \"__main__\":\n print main()\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\ndef foo():\n if m == 1:\n return 1\n if a % m == 1 and b % m == 0:\n return 1\n if (a + m - 1) / m == (b + m - 1) / m:\n return 1\n if (a + m - 1) / m + 1 == (b + m - 1) / m:\n return 2\n if a % m - 1 <= b % m:\n return 2\n if a % m == 1:\n return 2\n if b % m == 0:\n return 2\n return 3\n\nprint foo()\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\ndef foo():\n global a, b\n if m == 1:\n return 1\n if a % m == 1 and b % m == 0:\n return 1\n if (a + m - 1) / m == (b + m - 1) / m:\n return 1\n if b == n and b % m != 0:\n b += m - n % m\n if (a + m - 1) / m + 1 == (b + m - 1) / m:\n return 2\n if a % m == 1:\n return 2\n if b % m == 0:\n return 2\n x = a % m\n if x == 0:\n x = m\n if x == b % m + 1:\n return 2\n return 3\n\nprint foo()\n"}, {"source_code": "n,m,a,b = map(int, raw_input().split())\n\nif a>b:\n a,b = b,a\n\nx1 = (a-1)%m\ny1 = (a-1)/m\nx2 = (b-1)%m\ny2 = (b-1)/m\nif m == 1:\n print 1\nelif y1 == y2:\n print 1\nelif x1==0 and b==n:\n print 1\nelif m == 2:\n if x1 == 0 and x2 == 1:\n print 1\n else:\n print 2\nelif y2 == y1+1:\n print 2\nelse:\n if x1==0 and x2 == m-1:\n print 1\n elif x2 == m-1 or x1==0:\n print 2\n else:\n print 3\n"}, {"source_code": "import sys\n\nn, m, a, b = map(int, sys.stdin.readline().split())\n\na -= 1\nb -= 1\n\ntop = m-(a%m)\nbottom = (b%m)+1\n\nif top == 0 and bottom == 0:\n print 1\nelif top + bottom == m:\n print 2\nelif top == m:\n print 2\nelif bottom == m:\n print 2\nelse:\n print 3\n\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split(\" \"))\n\nif(b-a <= m-1 or a % m == 1 and b % m == 0):\n\tprint('1')\nelif(a%m-1 == b%m or a % m == 1 or b % m == 0):\n\tprint('2')\nelse:\n\tprint('3')"}, {"source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\nimport collections\nfrom itertools import permutations\nfrom collections import defaultdict\n\n\nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#-------------------game starts now-----------------------------------------------------\nn,m,a,b=map(int,input().split())\nc1=a//m\nc2=b//m\nif a%m==0:\n c1-=1\nif b%m==0:\n c2-=1\nif c1==c2 or m==1:\n print(1)\nelse:\n d=c2-c1\n r=3\n if a%m==1:\n r-=1\n if b%m==0 or b==n:\n r-=1\n if d==1 and r>1:\n r-=1\n if r==3 and (a%m==b%m+1 or (a%m==0 and b%m==(m-1))):\n r-=1\n #print(a%m,b%m)\n print(r)"}, {"source_code": "n,m,a,b = map(int, raw_input().split())\n\nif a>b:\n a,b = b,a\n\nx1 = (a-1)%m\ny1 = (a-1)/m\nx2 = (b-1)%m\ny2 = (b-1)/m\nif m == 1:\n print 1\nelif y1 == y2:\n print 1\nelif x1==0 and b==n:\n print 1\nelif m == 2:\n if x1 == 0 and x2 == 1:\n print 1\n else:\n print 2\nelif y1 == y2+1:\n print 2\nelse:\n if x1==0 and x2 == m-1:\n print 1\n elif x2 == m-1:\n print 2\n else:\n print 3\n"}, {"source_code": "\nn,m,a,b = map(int,raw_input().split())\nans = 3\nif a%m == 1:\n ans -= 1\nif b%m == 0:\n ans -= 1\nif (a+m-1)/m == (b+m-1)/m:\n ans = 1\nprint ans"}, {"source_code": "#!/usr/bin/python\nimport itertools, math, os, random, re, sys\nrandom.seed (1234)\nwhile True:\n\ts = sys.stdin.readline ().strip ()\n\tif s == '':\n\t\tbreak\n\tn, m, a, b = [int (x) for x in s.split ()]\n\ta -= 1\n\tif (a % m == 0) and (b % m == 0):\n\t\tprint 1\n\telif a / m == b / m:\n\t\tprint 1\n\telif m == 1:\n\t\tprint 1\n\telif b - a == 1:\n\t\tprint 1\n\telif (a % m == 0):\n\t\tprint 2\n\telif (b % m == 0):\n\t\tprint 2\n\telif a % m == b % m:\n\t\tprint 2\n\telif a / m + 1 == b / m:\n\t\tprint 2\n\telif b == n:\n\t\tprint 2\n\telse:\n\t\tprint 3\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\ndef foo():\n if m == 1:\n return 1\n if a % m == 1 and b % m == 0:\n return 1\n if (a + m - 1) // m == (b + m - 1) // m:\n return 1\n if (a + m - 1) // m + 1 == (b + m - 1) // m:\n return 2\n if a % m == 1:\n return 2\n if b % m == 0:\n return 2\n x = a % m\n if x == 0:\n x = m\n if b % m + 1 == x:\n return 2\n return 3\n\nprint foo()\n"}, {"source_code": "n,m,a,b=(int(i) for i in raw_input().split())\nra = a/m+1\nrb = b/m+1\nca = a%m\ncb = b%m\nif ca==0:\n ca=m\nif cb==0:\n cb=m\nif ra==rb:\n print 1\nelif ((ca==1) and ((cb==m) or (b==n))):\n print 1\nelif (rb-ra==1):\n print 2\nelif ca-cb==1:\n print 2\nelif ((ca==1) or (cb==m)):\n print 2\nelif b==n:\n print 2\nelse:\n print 3\n \n"}, {"source_code": "from timeit import *\nfrom itertools import *\n\ndef get2d(a, b, elem = -1):\n res = []\n for x in range(a):\n res.append(list(repeat(elem, b)))\n return res\n\nQ = 1#int(raw_input())\n\nfor example in range(Q):\n ddd = raw_input().split()\n n = int(ddd[0])\n m = int(ddd[1])\n a = int(ddd[2]) - 1\n b = int(ddd[3]) - 1\n def x():\n start = (a % m) == 0\n end = ((b + 1) % m == 0) or b == n - 1\n if start and end:\n return 1\n if int(a/m) == int(b/m):\n return 1\n if start or end or (a == b + 1):\n return 2\n return 3\n print x()"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nfrom sys import stdin\n\ndef compute(n,m,a,b):\n if (b-a) < m and (a-1) % m <= (b-1) %m:\n return 1\n res = 1 if b-a >= m else 0\n if a % m != 1:\n res += 1\n if b % m != 0 and b !=n:\n res += 1\n return res\n\nif __name__ == \"__main__\":\n n, m, a, b = map(int, stdin.readline().split())\n print(compute(n,m,a,b))\n\n"}, {"source_code": "n, m, a, b = map(int, input().split())\na -= 1\nx, y = a % m, b % m\ni, j = a // m, b // m\nprint((x > 0) + (y > 0) + (i != j) - (x == y != 0))"}, {"source_code": "\n#------------------------------warmup----------------------------\n# *******************************\n# * AUTHOR: RAJDEEP GHOSH * \n# * NICK : Rajdeep2k * \n# * INSTITUTION: IIEST, SHIBPUR *\n# *******************************\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now---------------------------------------------------\n# t=(int)(input())\nimport math\nfor _ in range(1):\n # n=(int)(input())\n # l=list(map(int,input().split()))\n n,m,a,b=map(int,input().split())\n fp=-1\n ans=0\n for i in range(a,a+m):\n if (i-1)%m==0:\n fp=i\n break\n # print(fp)\n if fp!=a:\n ans+=1\n # print(ans)\n s=math.ceil((b-fp+1)//m)\n ans+=1\n # print(ans)\n # print(s)\n if (b)%m!=0:\n ans+=1\n print(ans)"}, {"source_code": "def solve(n, m, a, b):\n\n if ((a - 1) % m == 0 and b % m == 0) or (b - a + 1) == n or (a - 1) // m == (b - 1) // m:\n return 1\n elif a == 1 or b == n or b % m == 0 or (a - 1) % m + b % m == m or (b - 1) // m - (a - 1) // m == 1:\n return 2\n else:\n return 3 \n\n\n\n\nans = solve(*map(int, input().split()))\nprint(ans)\n"}, {"source_code": "n, m, a, b = map(int, input().split())\nif b == n:\n b += m - 1 - (b - 1) % m\nc1, c2 = (a - 1) % m, (b - 1) % m\nif (a - 1) // m == (b - 1) // m or c1 == 0 and c2 == m - 1:\n print(1)\nelif c1 == 0 or c2 == m - 1 or c1 == c2 + 1:\n print(2)\nelse:\n print(3)"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\np, q = (a-1) % m, b % m\nif (a-1)/m == b/m:\n print 1\nelif p==q:\n print 1 if p==0 else 2\nelse:\n print 1 + (p>0) + (q>0 and b<n)\n"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\nn, m, a, b = map(int, input().split(' '))\na-=1; b-=1\nx = a//m; y = b//m\nxx = a%m; yy = b%m\nif (x==y) or (xx==0 and yy==(m-1)) or (b-a+1 == n):\n print(1)\nelif yy+1==xx or yy==m-1:\n print(2)\nelse:\n print(3)"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\ni = (a - 1) / m\nj = (b - 1) / m\nif i == j:\n c = 1\nelse:\n x = (a - 1) % m\n y = b % m\n c = 0\n if j - i > 1:\n c += 1\n if x != 0:\n c += 1\n if y != 0:\n c += 1\nprint c"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nans = 1\nif m != 1:\n if a%m != 1:\n ans += 1\n if b%m != 0:\n ans += 1\nprint ans\n"}, {"source_code": "# #/usr/bin/env python\nimport sys\n\n\n################################################\ndef nextToken(func = None):\n c = \"\"\n while fin:\n c = fin.read(1)\n if not c.isspace():\n break\n res = \"\" + c\n while fin:\n c = fin.read(1)\n if c.isspace():\n break\n res += c\n if func:\n return func(res)\n else:\n return res\n\n\ndef nextLine():\n if fin:\n return fin.readline().strip()\n else:\n return \"\"\n\n\nfin, fout = sys.stdin, sys.stdout\n\n#########################\n\ndef solve():\n n, m, a, b = map(int, nextLine().split())\n # one enough\n if (a - 1) / m == (b - 1) / m:\n return 1\n # one enough\n if a % m == 1 and b % m == 0:\n return 1\n # two enough\n if (a - 1) / m == 1 + (b - 1) / m:\n return 2\n if b % m == (a - 1) % m:\n return 2\n if a % m == 1 or b % m == 0:\n return 2\n return 3\n\nprint solve()\n\n\n\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nr1, c1 = (a - 1) / m, (a - 1) % m\nr2, c2 = (b - 1) / m, (b - 1) % m\nif r1 == r2 or (c1 == 0 and c2 == m - 1): print \"1\"\nelif c1 == 0 or c2 == m - 1 or c2 + 1 == c1: print \"2\"\nelse: print \"3\"\n"}, {"source_code": "n,m,a,b=map(int,raw_input().split())\nif a==1 and b==n:\n\tprint 1\nelse:\n\ta-=1\n\tb-=1\n\tst = a%m\n\tif (st!=0): st = m-st\n\tend = b%m+1\n\tif end==m: end = 0\n\trs = a/m\n\tre = b/m\n\trest = (b-a+1)-end-st\n\tif rs==re:\n\t\tprint 1\n\telif rest==0:\n\t\tprint 2\n\telse:\n\t\ta=1+(end!=0)+(st!=0)\n\t\tif end+st==m:\n\t\t\ta = min(a,2)\n\t\tprint a\n\n"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\nfrom sys import stdin\n\ndef compute(n,m,a,b):\n if m == 1:\n return 1\n if (b-a) < m:\n if (a-1) % m <= (b-1) %m:\n return 1\n else:\n return 2\n res = 1 \n if a % m != 1:\n res += 1\n if b % m != 0 and b != n:\n res += 1\n if (b % m) +1 == a %m:\n return min(res,2)\n return res\n\nif __name__ == \"__main__\":\n n, m, a, b = map(int, stdin.readline().split())\n print(compute(n,m,a,b))\n\n"}, {"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if a/m*m+m >= b:\n print 1\n elif a/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n else:\n print 3\n \n \n"}, {"source_code": "from math import ceil\nn,c,st,end = [int(i) for i in input().split()]\nreme =end%c\nrems = st%c\ndive = ceil(end/c)\ndivs = ceil(st/c)\nif (reme==0 and rems==1) or (divs==dive ) or end-st+1==n:\n print(str(1))\nelif reme==rems-1 or dive-divs<2 or (reme==0 or rems==1) or end==n :\n print(str(2))\nelse:\n print(str(3))"}, {"source_code": "\nn,m,a,b = map(int,raw_input().split())\nla = (a+m-1)/m\nlb = (b+m-1)/m\nif la == lb or (a%m==1 and (b%m==0 or b==n)):\n print 1\nelif la + 1 == lb or a%m==1 or b%m==0 or b==n or a%m==b%m:\n print 2\nelse:\n print 3"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nif m == 1:\n print 1\nelif b - a + 1 < m:\n if (a - 1) / m != (b - 1) / m:\n print 2\n else:\n print 1\nelif (b - a + 1) % m == 0:\n if a % m == 1:\n print 1\n else:\n print 2\nelif (b - 1) / m - (a - 1) / m < 2:\n print 2\nelse:\n if a % m == 1 or b % m == 0:\n print 2\n else:\n print 3"}, {"source_code": "\nn,m,a,b = map(int,raw_input().split())\nans = 3\nif a%m == 1:\n ans -= 1\nif b%m == 0 or b == n:\n ans -= 1\nif (a+m-1)/m == (b+m-1)/m:\n ans = 1\nprint ans"}, {"source_code": "#!/usr/bin/python3\n\nn, m, a, b = map(int, input().split())\n\na -= 1\nb -= 1\nif a // m == b // m:\n print(1)\nelif a % m == 0 and (b + 1) % m == 0:\n print(1)\nelif a % m == 0 or (b + 1) % m == 0:\n print(2)\nelif a % m == (b + 1) % m:\n print(2)\n#elif b // m - a // m == 1:\n# print(2)\nelif m == 2:\n print(2)\nelse:\n print(3)\n"}, {"source_code": "n,m,a,b = map(int, raw_input().split())\n\nif a>b:\n a,b = b,a\n\nx1 = (a-1)%m\ny1 = (a-1)/m\nx2 = (b-1)%m\ny2 = (b-1)/m\nif m == 1:\n print 1\nelif y1 == y2:\n print 1\nelif x1==0 and b==n:\n print 1\nelif x1==0 and x2 == m-1:\n print 1\nelif m == 2:\n if x1 == 0 and x2 == 1:\n print 1\n else:\n print 2\nelif y2 == y1+1:\n print 2\nelif x2 == x1+1:\n print 2\nelif a==1 or b == n:\n print 2\nelse:\n if x2 == m-1 or x1==0:\n print 2\n else:\n print 3\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(n,m,a,b):\n\n if a==b:\n return 1\n\n ra,beg_a = divmod(a,m)\n rb,beg_b = divmod(b,m)\n na = m - beg_a + 1\n nb = beg_b\n# print 'a:',ra,beg_a,na\n# print 'b:',rb,beg_b,nb\n \n if rb-ra == 0:\n return 1\n \n if rb-ra == 1:\n if na%m == 0 and nb == 0:\n return 1\n return 2\n \n if na % m == 0 and nb == 0:\n return 1\n \n if na % m > 0 and nb > 0 and (na+nb) % m > 0:\n return 3\n \n return 2\n\nS = input.readline().split(' ')\nassert len(S)==4\nn = int(S[0])\nm = int(S[1])\na = int(S[2])\nb = int(S[3])\nassert 1<=n and n<=10**9\nassert 1<=m and m<=10**9\nassert 1<=a and a<=b and b<=n\n\nanswer = solve(n,m,a,b)\noutput.write('%s\\n' % (answer))\n"}, {"source_code": "def gcd(a, b):\n\treturn a if 0 == b else gcd(b, a % b)\n\ndef main():\n\tn, m, a, b = map(int, raw_input().split())\n\ta -= 1\n\tb -= 1\n\ti1, j1 = a / m, a % m\n\ti2, j2 = b / m, b % m\n\tif i1 == i2 or (0 == j1 and j2 == m - 1): print 1\n\telif i2 == i1 + 1 or 0 == j1 or\tj2 == m - 1 or m / gcd(j2 + 1, m) <= i2 - i1 - 1: print 2\t\t\n\telse: print 3\n\nif __name__ == \"__main__\": main()\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nr1, c1 = (a - 1) / m, (a - 1) % m\nr2, c2 = (b - 1) / m, (b - 1) % m\nif r2 == (n - 1) / m: c2 = m - 1\nif r1 == r2 or (c1 == 0 and c2 == m - 1): print \"1\"\nelif c1 == 0 or c2 == m - 1 or c2 + 1 == c1: print \"2\"\nelse: print \"3\"\n"}, {"source_code": "def solve(n, m, a, b):\n a -= 1\n b -= 1\n\n if b - a + 1 == n:\n return 1\n\n ans = 0\n if a % m != 0 or b - a < m:\n ans += 1\n\n if (b - a + 1 - m + a % m) // m > 0:\n ans += 1\n\n if b + 1 == n:\n return ans\n\n if b % m != m - 1:\n ans += 1\n\n return ans\n\n\nans = solve(*map(int, input().split()))\nprint(ans)\n"}, {"source_code": "import sys\n\nn, m, a, b = map(int, sys.stdin.readline().split())\n\nif m == 1:\n print 1\nelse:\n a -= 1\n b -= 1\n\n top = m-(a%m)\n bottom = (b%m)+1\n\n# print top, bottom\n\n if (a == b):\n print 1\n elif (a / m) == (b / m):\n print 1\n elif top == m and bottom == m:\n print 1\n elif top + bottom == m:\n print 2\n elif top == m:\n print 2\n elif bottom == m:\n print 2\n else:\n if (a / m)+1 == (b / m):\n print 2\n else:\n print 3\n\n"}, {"source_code": "from itertools import permutations\nimport sys\nics, per, first, last = map(int, raw_input().split())\nx1 = first / per\ny1 = first % per\nx2 = last / per\ny2 = last % per\n\nif x1 == x2:\n print 1\n exit()\n\nif y1 == 1 and y2 == 0:\n print 1\n exit()\n \nif y1 == 1 and last == ics:\n print 1\n exit()\n \nif x1-x2 == 1:\n print 2\n exit()\n\nif y1 == 1:\n print 2\n exit()\n \nif y2 == 0:\n print 2\n exit()\n \nif last == ics:\n print 2\n exit()\n\nif y1-y2 == 1:\n print 2\n exit()\n \nprint 3\n"}, {"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b%m == 0:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if a/m*m+m >= b:\n print 1\n elif a/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n else:\n print 3\n \n \n"}, {"source_code": "from math import ceil\nn,c,st,end = [int(i) for i in input().split()]\nreme =end%c\nrems = st%c\ndive = ceil(end/c)\ndivs = ceil(st/c)\nif n==21 and c==5 and st ==1 and end==21:\n print(str(1))\nelif (reme==0 and rems==1) or (divs==dive ) :\n print(str(1))\nelif reme==rems-1 or dive-divs<2 or (reme==0 or rems==1):\n print(str(2))\nelse:\n print(str(3))"}, {"source_code": "def pos(x):\n global m\n global n\n row=x/m\n column=x%m\n p=[row,column]\n return p\nn,m,a,b=(int(i) for i in raw_input().split())\nl=pos(a-1)\npar=l[0]\npac=l[1]\nl=pos(b-1)\npbr=l[0]\npbc=l[1]\nif (par==pbr) or ((pac==0) and (pbc==m-1)) or (a==1 and b==n):\n print 1\nelif (pac-pbc==1) or (pac==0) or (pbc==m-1) or (a==1) or (b==n):\n print 2\nelse:\n print 3\n#print par,pac,pbr,pbc"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nr1, c1 = (a - 1) / m, (a - 1) % m\nr2, c2 = (b - 1) / m, (b - 1) % m\nif r1 == r2 or (c1 == 0 and c2 == m - 1): print \"1\"\nelif c1 == 0 or c2 == m - 1 or c2 + 1 == c1: print \"2\"\nelse: print \"3\"\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nP, p = divmod(a-1, m)\nQ, q = divmod(b, m)\nif P == Q:\n print 1\nelif p==q:\n print 1 if p==0 else 2\nelse:\n print 2 if P+1==Q else 1 + (p>0) + (q>0 and b<n)\n"}, {"source_code": "from itertools import permutations\nimport sys\nfrom math import *\nics, per, first, last = map(int, raw_input().split())\nper = float(per)\nx1 = int(ceil(first / per))\ny1 = int(first % per)\nx2 = int(ceil(last / per))\ny2 = int(last % per)\n\nif x1 == x2:\n print 1\n exit()\n\nif y1 == 1 and y2 == 0:\n print 1\n exit()\n \nif y1 == 1 and last == ics:\n print 1\n exit()\n \nif abs(x1-x2) == 1:\n print 2\n exit()\n\nif y1 == 1:\n print 2\n exit()\n \nif y2 == 0:\n print 2\n exit()\n \nif last == ics:\n print 2\n exit()\n\nif y1-y2 == 1 or y2-y1 == per - 1:\n print 2\n exit()\n \nprint 3\n"}, {"source_code": "def solve(n, m, a, b):\n\n if ((a - 1) % m == 0 and b % m == 0) or (b - a + 1) == n:\n return 1\n elif a == 1 or b == n or b % m == 0 or (a - 1) % m + b % m == m:\n return 2\n else:\n return 3 \n\n\n\n\nans = solve(*map(int, input().split()))\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(n,m,a,b):\n\n a -= 1\n b -= 1\n\n if a==b:\n return 1\n\n ar,ac = divmod(a,m)\n br,bc = divmod(b,m)\n \n# an = m - ac\n# bn = bc + 1\n# print 'a:', (ar,ac),an\n# print 'b:', (br,bc),bn\n \n # one row\n if br-ar == 0:\n return 1\n\n # rectangular, all cases \n if ac==0 and bc==m-1:\n return 1\n\n # two rows\n if br-ar == 1:\n return 2\n \n #\n if (ac > 0 and bc < m-1) and bc+1 != ac:\n return 3\n \n return 2\n\nS = input.readline().split(' ')\nassert len(S)==4\nn = int(S[0])\nm = int(S[1])\na = int(S[2])\nb = int(S[3])\nassert 1<=n and n<=10**9\nassert 1<=m and m<=10**9\nassert 1<=a and a<=b and b<=n\n\nanswer = solve(n,m,a,b)\noutput.write('%s\\n' % (answer))\n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nans1 = 1\nif m != 1:\n if a%m != 1:\n ans1 += 1\n if b%m != 0:\n ans1 += 1\nans2 = 100\nif m>1:\n if abs(a%m - b%m) == 1:\n ans2 = 2\n else:\n ans2 = 3\nprint min(ans1,ans2)\n"}, {"source_code": "def solve(n, m, a, b):\n\n if ((a - 1) % m == 0 and b % m == 0) or (b - a + 1) == n:\n return 1\n elif a == 1 or b == n or b % m == 0 or (a - 1) % m + b % m == m:\n return 2\n else:\n return 3 \n\n\n\n\nans = solve(*map(int, input().split()))\nprint(ans)\n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nans1 = 1\nif m != 1:\n if a%m != 1:\n ans1 += 1\n if b%m != 0:\n ans1 += 1\nans2 = 100\nif m>1:\n if abs(a%m - b%m) == 1:\n ans2 = 2\n else:\n ans2 = 3\nprint min(ans1,ans2)\n"}, {"source_code": "\n#------------------------------warmup----------------------------\n# *******************************\n# * AUTHOR: RAJDEEP GHOSH * \n# * NICK : Rajdeep2k * \n# * INSTITUTION: IIEST, SHIBPUR *\n# *******************************\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now---------------------------------------------------\n# t=(int)(input())\nimport math\nfor _ in range(1):\n # n=(int)(input())\n # l=list(map(int,input().split()))\n n,m,a,b=map(int,input().split())\n fp=-1\n ans=0\n for i in range(a,a+m):\n if (i-1)%m==0:\n fp=i\n break\n # print(fp)\n if fp!=a:\n ans+=1\n # print(ans)\n s=math.ceil((b-fp+1)//m)\n ans+=1\n # print(ans)\n # print(s)\n if b==n:\n print(ans)\n else:\n if (b)%m!=0:\n ans+=1\n print(ans)"}, {"source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b%m == 0:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if a/m*m+m >= b:\n print 1\n elif a/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n else:\n print 3\n \n \n"}, {"source_code": "from math import ceil\nn,c,st,end = [int(i) for i in input().split()]\nreme =end%c\nrems = st%c\ndive = ceil(end/c)\ndivs = ceil(st/c)\nif rems==0:\n rems = c\nif (reme==0 and rems==1) or (divs==dive ) and end-st+1==n:\n print(str(1))\nelif reme==rems-1 or dive-divs<2 or (reme==0 or rems==1) or end==n :\n print(str(2))\nelse:\n print(str(3))"}, {"source_code": "from math import ceil\nn,c,st,end = [int(i) for i in input().split()]\nreme =end%c\nrems = st%c\ndive = ceil(end/c)\ndivs = ceil(st/c)\nif (reme==0 and rems==1) or (divs==dive ) and end-st+1==n:\n print(str(1))\nelif reme==rems-1 or dive-divs<2 or (reme==0 or rems==1) or end==n :\n print(str(2))\nelse:\n print(str(3))"}, {"source_code": "readints=lambda:map(int, input().strip('\\n').split())\nn,m,a,b=readints()\n\na-=1\nb-=1 # 0-index\n\n\nra=a//m\nrb=b//m\n\n\nia=a%m\nib=b%m\n\n\nif ra==rb: # same row\n print(1)\nelse:\n mid=rb-1-ra\n if ia==0 and ib==m-1:\n print(1)\n elif ia==0 and ib!=m-1:\n print(2)\n elif ia!=0 and ib==m-1:\n print(2)\n elif a==ib:\n print(2)\n else:\n if mid:\n print(3)\n else:\n print(2)\n \n \n \n"}, {"source_code": "import sys\n\nn, m, a, b = map(int, sys.stdin.readline().split())\n\na -= 1\nb -= 1\n\ntop = m-(a%m)\nbottom = (b%m)+1\n\nif top == 0 and bottom == 0:\n print 1\nelif top + bottom == m:\n print 2\nelif top == m:\n print 2\nelif bottom == m:\n print 2\nelse:\n print 3\n\n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\na=a-1\nif (a%m==0 and b%m ==0) or (a/m==b/m): print 1\nelif a%m == b%m or a%m==0 or b%m==0: print 2\nelse: print 3\n"}, {"source_code": "from math import ceil\nn,c,st,end = [int(i) for i in input().split()]\nreme =end%c\nrems = st%c\ndive = ceil(end/c)\ndivs = ceil(st/c)\nif n==21 and c==5 and st ==1 and end==21:\n print(str(1))\nelif (reme==0 and rems==1) or (divs==dive ) :\n print(str(1))\nelif reme==rems-1 or dive-divs<2 or (reme==0 or rems==1):\n print(str(2))\nelse:\n print(str(3))"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**9+7\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n\nn,m,a,b = Ri()\na-=1;b-=1\nrow1 = a//m\ncol1 = a%m\n\nrow2 = b//m\ncol2 = b%m\n\nif row1 == row2:\n print(1)\nelse:\n if col2 == m-1 and col1 == 0:\n print(row2 - row1 + 1)\n elif col1 == 0:\n print(1 + 1)\n elif col2 == m-1:\n print(1+ 1)\n else:\n if abs(row2 - row1) == 1:\n print(2)\n else:\n print(2 + 1)\n"}, {"source_code": "#!/usr/bin/python2\n#-*- coding: utf-8 -*-\n\nimport sys,math\n\n#ret = raw_input()\n#ret = ret.split(' ')\n\n#text = raw_input().rstrip()\n\n#znak = sys.stdin.read(1) \n\n#pole=[[]*n for r in xrange(n)]\n\n\n\nn,m,a,b = map(int,raw_input().split())\n\nanaradku = a % m \nbnaradku = b % m \nif anaradku == 0 : anaradku = m\nif bnaradku == 0 : bnaradku = m\n\npocet = 0\nif ((a-1)/m) != ((b-1)/m)-1 :\n pocet = 1\n\n\nif (((a-1)/m) != ((b-1)/m)) and (m != 1):\n if anaradku != 1 :\n pocet += 1\n\n if bnaradku != m and bnaradku != anaradku -1 and b != n:\n pocet += 1\n\nprint max(1,pocet)\n\n"}, {"source_code": "n,m,a,b=map(int,raw_input().split())\na-=1\nb-=1\nst = a%m\nif (st!=0): st = m-st\nend = b%m+1\nif end==m: end = 0\nrs = a/m\nre = b/m\nrest = (b-a+1)-end-st\nif rs==re:\n\tprint 1\nelif rest==0:\n\tprint 2\nelse:\n\ta=1+(end!=0)+(st!=0)\n\tif end+st==m:\n\t\ta = 2\n\tprint a\n\n"}, {"source_code": "n,m,a,b = map(int,raw_input().split())\nans = 1\nif m != 1:\n if a%m != 1:\n ans += 1\n if b%m != 0:\n ans += 1\nprint ans\n"}, {"source_code": "n, m, a, b = map(int, raw_input().split())\nif b == n:\n b = b + m - b%m\nfull_lines = True\nif (a/m == b/m) or (a/m + 1 == b/m):\n full_lines = False\n\na_from_start = (a % m == 1)\nb_till_end = (b % m == 0)\n\nif m == 1 or m >= n or (a==1 and b==n):\n print 1\nelif a_from_start and b_till_end:\n print 1\nelif a/m == b/m:\n print 1\nelif a_from_start:\n print 2\nelif b_till_end:\n print 2\nelif not full_lines:\n print 2\nelif (m - a % m + 1) + b % m == m:\n print 2\nelse:\n print 3\n"}], "src_uid": "f256235c0b2815aae85a6f9435c69dac"} {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\ndef add(x , y):return ((x%mod) + (y%mod))%mod\r\ndef sub(x , y):return (x - y + mod)%mod\r\n\r\n\r\ndef answer():\r\n\r\n dp = [0]*(n + 1)\r\n prefix = [0]*(n + 2)\r\n\r\n dp[n] = 1\r\n\r\n for i in range(n , 0 , -1):\r\n\r\n dp[i] = add(dp[i] , prefix[i + 1])\r\n\r\n j = 2\r\n while(i*j <= n):\r\n\r\n dp[i] = add(dp[i] , prefix[i*j])\r\n if((j*i + j) <= n):dp[i] = sub(dp[i] , prefix[j*i + j])\r\n j += 1\r\n\r\n \r\n prefix[i] = add(prefix[i + 1] , dp[i])\r\n\r\n return dp[1]\r\n\r\n \r\n \r\n\r\nfor T in range(1):\r\n\r\n n , mod = map(int,input().split())\r\n\r\n print(answer())\r\n", "positive_code": [{"source_code": "inp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, prefix = [0] * (n + 1), [0] * (n + 2)\r\nmem[1] = su = 1\r\n\r\nfor i in range(2, n + 1):\r\n j = 2\r\n while j * (i - 1) <= n:\r\n prefix[j * (i - 1)] = add(prefix[j * (i - 1)], mem[i - 1])\r\n prefix[min(j * i, n + 1)] = add(prefix[min(j * i, n + 1)], mult(-1, mem[i - 1]))\r\n j += 1\r\n\r\n prefix[i] = add(prefix[i - 1], prefix[i])\r\n mem[i] = add(prefix[i], su)\r\n su = add(su, mem[i])\r\n\r\nprint(mem[-1])\r\n"}, {"source_code": "from math import sqrt\r\n\r\ninp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, su = [0] * (n + 1), 1\r\nmem[1] = 1\r\n\r\nfor i in range(2, n + 1):\r\n sq, cur = int(sqrt(i)) + 1, su\r\n\r\n for f in range(2, sq):\r\n cur = (cur + mem[i // f]) % mod\r\n\r\n be = i\r\n for j in range(1, i // sq + 1):\r\n nxt = i // (j + 1)\r\n cur = (cur + (be - nxt) * mem[j]) % mod\r\n be = nxt\r\n\r\n su = (su + cur) % mod\r\n mem[i] = cur\r\nprint(mem[-1])\r\n"}, {"source_code": "from math import sqrt\r\n\r\ninp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, su = [0] * (n + 1), 1\r\nmem[1] = 1\r\n\r\nfor i in range(2, n + 1):\r\n sq, cur = int(sqrt(i)) + 1, su\r\n\r\n for f in range(2, sq):\r\n cur = add(cur, mem[i // f])\r\n\r\n be = i\r\n for j in range(1, i // sq + 1):\r\n nxt = i // (j + 1)\r\n cur = add(cur, (be - nxt) * mem[j])\r\n be = nxt\r\n\r\n su = add(su, cur)\r\n mem[i] = cur\r\nprint(mem[-1])\r\n"}, {"source_code": "from math import sqrt\r\n\r\ninp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, su = [0, 1], 1\r\n\r\nfor i in range(2, n + 1):\r\n sq, cur = int(sqrt(i)) + 1, su\r\n\r\n for f in range(2, sq):\r\n cur = add(cur, mem[i // f])\r\n\r\n be = i\r\n for j in range(1, i // sq + 1):\r\n nxt = i // (j + 1)\r\n cur = add(cur, (be - nxt) * mem[j])\r\n be = nxt\r\n\r\n su = add(su, cur)\r\n mem.append(cur)\r\nprint(mem[-1])\r\n"}, {"source_code": "from math import sqrt\r\n\r\ninp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, su = [0, 1], 1\r\n\r\nfor i in range(2, n + 1):\r\n sq, cur = int(sqrt(i)) + 1, su\r\n\r\n for f in range(2, sq):\r\n cur = add(cur, mem[i // f])\r\n\r\n be = i\r\n for j in range(1, i // sq + 1):\r\n nxt = i // (j + 1)\r\n cur = add(cur, mult(be - nxt, mem[j]))\r\n be = nxt\r\n\r\n su = add(su, cur)\r\n mem.append(cur)\r\nprint(mem[-1])\r\n"}, {"source_code": "inp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, su = [0, 1], 1\r\n\r\nfor i in range(2, n + 1):\r\n sq ,cur= int(i ** .5) + 1,su\r\n\r\n for f in range(2, sq):\r\n cur = add(cur, mem[i // f])\r\n\r\n be = i\r\n for j in range(1, i // sq + 1):\r\n nxt = i // (j + 1)\r\n cur = add(cur, mult(be - nxt, mem[j]))\r\n be = nxt\r\n\r\n su = add(su, cur)\r\n mem.append(cur)\r\nprint(mem[-1])\r\n"}, {"source_code": "n, M = map(int,input().split())\n \n\nif n==1: \n print(1)\n exit(0)\n\n\n \ndp = [1]*(n+1)\naccu = [0]*(n+1)\n\naccu[1] = 1\naccu[2] = 2\n\nfor j in range(4,n+1,2):\n dp[j] += dp[2]\n\n\n \nfor i in range(3,n+1):\n dp[i] += accu[i-1]\n dp[i] = dp[i]%M \n\n\n for j in range(2*i,n+1,i):\n dp[j] += dp[i]\n dp[j] = dp[j] % M\n\n\n\n accu[i] = (accu[i-1] + dp[i])%M\n\n\n\n \n#print(dp)\n#print(accu) \n \n \nprint(accu[n])\n"}, {"source_code": "n, M = map(int,input().split())\n \n\nif n==1: \n print(1)\n exit(0)\n\n\n \ndp = [1]*(n+1)\naccu = [0]*(n+1)\n\naccu[1] = 1\naccu[2] = 2\n\nfor j in range(4,n+1,2):\n dp[j] += dp[2]\n\n\n \nfor i in range(3,n+1):\n dp[i] += accu[i-1] \n\n\n for j in range(2*i,n+1,i):\n dp[j] += dp[i]\n dp[j] = dp[j] % M\n\n\n\n accu[i] = (accu[i-1] + dp[i])%M\n\n\n\n \n#print(dp)\n#print(accu) \n \n \nprint(accu[n])\n"}, {"source_code": "n, M = map(int,input().split())\n \n\n\n\n\n \ndp = [0]*(n+1)\naccu = [0]*(n+1)\n \n \ndp[1] = 1\ndp[2] = 1\naccu[1] = 1\naccu[2] = 2\nextra = 0\n\n\n \nfor i in range(3,n+1):\n dp[i] = accu[i-1] \n for j in range(1,int(i**0.5)+1):\n if i%j==0:\n dp[i] += dp[j]\n dp[i] = dp[i] % M\n if j>1 and j*j<i: \n dp[i] += dp[i//j]\n dp[i] = dp[i] % M\n accu[i] = (accu[i-1] + dp[i])%M\n\n\n\n \n#print(dp)\n \n \n \nprint(accu[n])\n"}, {"source_code": "n, M = map(int,input().split())\n \n\n\n\n\n \ndp = [0]*(n+1)\naccu = [0]*(n+1)\n \n \ndp[1] = 1\ndp[2] = 2\nextra = 0\n\n\n \nfor i in range(3,n+1):\n dp[i] = (2*dp[i-1]) % M\n\n for j in range(1,int(i**0.5)+1):\n if i%j==0:\n dp[i] += (dp[j] - dp[j-1] )%M\n \n if j*j<i and j!=1: \n \n dp[i] += (dp[i//j] - dp[i//j-1])%M\n dp[i] = dp[i] % M\n\n\n \n#print(dp)\n \n \n \nprint(dp[n])\n"}, {"source_code": "n, M = map(int,input().split())\n\nfact = [{} for i in range(n+1)]\n\nfor i in range(1,n+1): \n for j in range(i,n+1,i):\n fact[j][i] = 1\n\ndp = [0]*(n+1)\naccu = [0]*(n+1)\n\n\ndp[1] = 1\ndp[2] = 2\nextra = 0\n\nfor i in range(3,n+1):\n dp[i] = (2*dp[i-1]) % M\n for ele in fact[i]:\n if ele==i: continue \n dp[i] += dp[ele] - dp[ele-1]\n dp[i] = dp[i] % M \n\n\n#print(dp)\n\n\n\nprint(dp[n])\n"}, {"source_code": "# This code is contributed by Siddharth\r\n\r\nfrom sys import *\r\ninput = stdin.readline\r\n\r\n\r\n\r\n\r\nimport random\r\nfrom bisect import *\r\nimport math\r\nfrom collections import *\r\nimport operator\r\nfrom heapq import *\r\nfrom itertools import *\r\ninf=10**18\r\nmod=10**9+7\r\n\r\n# inverse modulo power pow(a,-1,mod) - it only works on py 3.8 ( *not in pypy )\r\n\r\n\r\n\r\n# ==========================================> Code Starts Here <=====================================================================\r\n\r\n\r\n\r\nn,m=map(int,input().split())\r\ndp=[0]*(n+5)\r\nsuf=[0]*(n+5)\r\ndp[n]=1\r\nsuf[n]=1\r\nfor i in range(n-1,0,-1):\r\n dp[i]=(dp[i]+suf[i+1])%m\r\n suf[i]=suf[i+1]\r\n j=2\r\n while j*i<=n:\r\n l=j*i\r\n r=min(j*i+j-1,n)\r\n dp[i]=(dp[i]+suf[l]-suf[r+1])%m\r\n j+=1\r\n suf[i]=(suf[i+1]+dp[i])%m\r\n\r\nprint(dp[1]%m)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\ninputt=sys.stdin.readline\r\nprintt=sys.stdout.write\r\n\r\nimport math\r\nimport functools # functools.reduce\r\nfrom collections import deque\r\nimport heapq\r\nfrom queue import PriorityQueue\r\n\r\ndef get():\r\n return inputt().split()\r\ndef getint():\r\n return int(inputt())\r\ndef getints():\r\n return map(int, inputt().split())\r\n\r\nn, m = getints()\r\na = [1 for _ in range(n+1)]\r\na[2] = 0\r\nfor x in range(2, n+1):\r\n a[x] += 2*a[x-1]\r\n a[x] %= m\r\n delta = a[x]-a[x-1]\r\n for y in range(2, n//x+1):\r\n a[x*y] += delta\r\n a[x*y] %= m\r\n a[x-2] = 0\r\nprint(a[n])"}, {"source_code": "import sys\r\nfrom io import BytesIO, IOBase\r\nimport os\r\n\r\n################################ <fast I/O> ###########################################\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self, **kwargs):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\n\r\n#############################################<I/O Region >##############################################\r\n\r\n\r\ndef inp():\r\n return sys.stdin.readline().strip()\r\n\r\n\r\ndef map_inp(v_type):\r\n return map(v_type, inp().split())\r\n\r\n\r\ndef list_inp(v_type):\r\n return list(map_inp(v_type))\r\n\r\n\r\n######################################## Solution ####################################\r\n\r\nn, m = map_inp(int)\r\ndp = [0 for col in range(n + 1)]\r\nadd_q = [0 for item in range(n + 2)]\r\ndp[n] = 1\r\nadd_q[n] = 1\r\nfor i in range(n - 1, 0, -1):\r\n dp[i] += add_q[i + 1] % m\r\n z = 2\r\n for temp in range(i * z, n + 1, i):\r\n left = i * z\r\n right = min(i * z + z - 1, n)\r\n dp[i] += add_q[left] - add_q[right + 1]\r\n dp[i] %= m\r\n z += 1\r\n add_q[i] += dp[i] + add_q[i + 1]\r\n add_q[i] %= m\r\nprint(dp[1])\r\n"}, {"source_code": "n, m = map(int, input().split())\r\nc = [0]*n + [1, 0]\r\nfor i in range(n-1, 0, -1):\r\n c[i] = 2*c[i+1] % m\r\n for j in range(2, n//i + 1):\r\n c[i] = (c[i] + c[i*j] - c[min(n+1, (i+1)*j)]) % m\r\n\r\nprint((c[1] - c[2]) % m)"}, {"source_code": "n, m = map(int, input().split())\r\nc = [0]*n + [1, 0]\r\nfor i in range(n-1, 0, -1):\r\n c[i] = 2*c[i+1] % m\r\n for j in range(2, n//i + 1):\r\n c[i] = (c[i] + c[i*j] - c[min(n+1, i*j + j)]) % m\r\n\r\nprint((c[1] - c[2]) % m)"}, {"source_code": "n, m = map(int, input().split())\r\nc = [0] * (n-1) + [1, 0]\r\nfor i in range(n-1, 0, -1):\r\n c[i-1] = 2*c[i] % m\r\n for j in range(2, n//i + 1):\r\n c[i-1] = (c[i-1] + c[i*j-1] - c[min(n, i*j-1 + j)]) % m\r\n\r\nprint((c[0] - c[1]) % m)"}, {"source_code": "n, m = map(int, input().split())\r\nc = [0] * (n - 1) + [1, 0]\r\nfor i in range(n - 1, 0, -1):\r\n fl = 0\r\n for j in range(2, n // i + 1):\r\n fl = (fl + c[i * j - 1] - c[min(n, i * j - 1 + j)]) % m\r\n\r\n c[i - 1] = (2 * c[i] + fl) % m\r\n\r\nprint((c[0] - c[1]) % m)"}, {"source_code": "import sys\r\nimport io, os\r\nimport math\r\nfrom heapq import *\r\ngcd = math.gcd\r\nsqrt = math.sqrt\r\ndef ceil(a,b):\r\n a=-a\r\n k=a//b\r\n k=-k\r\n return k\r\n# arr=list(map(int, input().split()))\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\ndef strinp(testcases):\r\n k = 5\r\n if (testcases == -1 or testcases == 1):\r\n k = 1\r\n f = str(input())\r\n f = f[2:len(f) - k]\r\n return f\r\ndef sieve(n):\r\n prime = [0 for i in range(n + 1)]\r\n p = 2\r\n if (prime[p] == 0):\r\n for i in range(p * p, n + 1, p):\r\n prime[i] = p\r\n p+=1\r\n while (p * p <= n):\r\n if (prime[p] == 0):\r\n for i in range(p * p, n + 1, p):\r\n prime[i] = p\r\n p += 2\r\n return prime\r\ndef cleanarr(arr):\r\n n = len(arr)\r\n # put comment if arr already sorted\r\n c = [[arr[0], 1]]\r\n k = 0\r\n for i in range(n - 1):\r\n if (arr[i] != arr[i + 1]):\r\n c.append([arr[i + 1], 1])\r\n k += 1\r\n else:\r\n c[k][1] += 1\r\n return c\r\ndef factors(l,k):\r\n if(l==[]):\r\n return([])\r\n if(k==len(l)-1):\r\n ans = [0]*(l[k][1]+1)\r\n for i in range(l[k][1]+1):\r\n ans[i]=l[k][0]**i\r\n return ans\r\n p=factors(l,k+1)\r\n og=len(p)\r\n for i in range(1,l[k][1]+1):\r\n n=l[k][0]\r\n for j in range(og):\r\n p.append(p[j]*(n**i))\r\n return p\r\ndef pfactors(n,l):\r\n if(l[n]==0):\r\n return([])\r\n curr=n\r\n ans=[]\r\n while(True):\r\n f=l[curr]\r\n if(f==0):\r\n ans.append(curr)\r\n break\r\n ans.append(f)\r\n curr=curr//f\r\n ans.sort()\r\n ans=cleanarr(ans)\r\n return ans\r\ndef main():\r\n arr=list(map(int, input().split()))\r\n n=arr[0]\r\n m=arr[1]\r\n dp=[0]*(n+2)\r\n dp[1]=1\r\n dp[2]=2\r\n dp[3]=5\r\n if(n<4):\r\n print(dp[n])\r\n sys.exit()\r\n p=sieve(n)\r\n for i in range(4,n+1):\r\n dp[i]=(2*dp[i-1]+1)%m\r\n f=pfactors(i,p)\r\n g=factors(f,0)\r\n for h in range(1,len(g)-1):\r\n j=g[h]\r\n f=i//j\r\n dp[i]+=(dp[i//j]-dp[(i-1)//j])\r\n dp[i]=dp[i]%m\r\n print(dp[n])\r\nmain()"}, {"source_code": "import sys\r\nimport io, os\r\nimport math\r\nfrom heapq import *\r\ngcd = math.gcd\r\nsqrt = math.sqrt\r\ndef ceil(a,b):\r\n a=-a\r\n k=a//b\r\n k=-k\r\n return k\r\n# arr=list(map(int, input().split()))\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\ndef strinp(testcases):\r\n k = 5\r\n if (testcases == -1 or testcases == 1):\r\n k = 1\r\n f = str(input())\r\n f = f[2:len(f) - k]\r\n return f\r\ndef main():\r\n arr=list(map(int, input().split()))\r\n n=arr[0]\r\n m=arr[1]\r\n dp=[0]*(n+2)\r\n dp[1]=1\r\n dp[2]=2\r\n dp[3]=5\r\n if(n<4):\r\n print(dp[n])\r\n sys.exit()\r\n for i in range(4,n+1):\r\n dp[i]=(2*dp[i-1]+1)%m\r\n p=int(i**(0.5))\r\n for j in range(2,p+1):\r\n if(i%j==0):\r\n if(j*j==i):\r\n dp[i]+=(dp[i//j]-dp[(i-1)//j])\r\n dp[i]=dp[i]%m\r\n else:\r\n f=i//j\r\n dp[i]+=(dp[i//j]-dp[(i-1)//j])\r\n dp[i] += (dp[i // f] - dp[(i - 1) // f])\r\n dp[i]=dp[i]%m\r\n print(dp[n])\r\nmain()"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n \r\nBUFSIZE = 8192\r\n \r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n#######################################\r\n# #######\r\n # #\r\n #######\r\n # #\r\n # # \r\n # # Rahul Kaushik.2.0 #\r\n\r\n \r\n \r\nfor i in range(1):\r\n n,m=map(int,input().split())\r\n dp=[0]*(n+1)\r\n s=[0]*(n+2)\r\n dp[n]=1\r\n \r\n s[n]=1\r\n for i in range(n-1,0,-1):\r\n dp[i]=s[i+1]\r\n j=2\r\n while i*j<=n:\r\n if (i+1)*j-1<=n:\r\n dp[i]+=(s[j*i]-s[(i+1)*(j)])%m\r\n \r\n else:\r\n dp[i]+=s[j*i]\r\n dp[i]%=m\r\n j+=1\r\n s[i]+=(s[i+1]+dp[i])%m\r\n \r\n print(dp[1]%m)\r\n "}, {"source_code": "\"\"\"RANK1ZEN; 3966 PEAK; NA; FLEX SUPPORT: Zen, Bap; Battlenet ID -> Knuckles#11791\"\"\"\r\n# region ---------------------------------------------------------------------------|\r\n# MNNNNNNNNNNNNNNNNMNho///++//+oooooossssssssssssysssooyyyyyso+//++//shNNNNNNNNNNNNNM\r\n# MNNNNNNNNNNNNNNMNy////////++++oooooooooossssssssoosssssysyyysoossss+/oshNNNNNNNNNNM\r\n# MNNNNNNNNNNNNMNs///////+oooooo++++oooooooooooso+ossssssssssssssssssss++soymMNNNNNNM\r\n# MNNNNNNNNNNNMd/:-//+//shNNmhsoo+++++++++ooooo++oooooooooossssssssssssso+ooosmNNNNNM\r\n# MNNNNNNNNNNMh::://+/+ymMMMMmhsoso+++++++++o+/+ooooooooooooooooooooossso++o+++hMNNNM\r\n# MNNNNNNNNNMy//-:/+/osmMMMMNhssyshNdssoooo++:++++++++++oooooooooooooooooo++-++/sMMNM\r\n# MNNNNNNNNMd:/:///+/ohNMMMNhsohyyNMNNNdhhs+:++++++++++++++++++++ooooooooo/+.o+:/+NNM\r\n# MNNNNNNNMm/:/-///++ooshmmhs+sysdMMMMNdMMd/+++++ooo++++++++++++++++++++++::-++/:/sNM\r\n# MNNNNNNMN/://-+++++++++oo+//yosNMNMNmNMNo/o/oshNmhyoo+++++++++++++++++++/-/+++:/:sM\r\n# MNNNNNMNo://-/+++++:/+++++//++osyhmdhMNs/o/+shMMMMmsooooyo++/+++++++++++://+++://oM\r\n# MNNNNNMs:///:/++++//++-/+/:++++++ooooyo++o-oyNNMMmysooymmso/+shysyyysooo+/++o+/-s+M\r\n# MNNNNMd:///+:/++++-++:`++:/++++//++++++:+-/oyhsmys+oohmyo++:sNMdmMMNNysy+-ohNs+-myM\r\n# MNNNMN::///+-:+++:.+/``++/++++++++++++:+/`+++oo/:/++oyo+oy+odNddMMMMmyyh:-sdMh/odyN\r\n# MNNNNo:///++-:+o/`::```++/+++++++++++//+-.o++:-:/++/+/+ymo/+ossyyhdhssy+.:ohhd/sy+M\r\n# MMNMh-///+++--oo:`/````++-+++++++++++-o/`/+:.:/+++//+hmNo/++++++ooooooo-`/+o++/++-M\r\n# MMMN/:///+++-.o/````-s:+/:++++++++++/++`.:.-/++++/+sdmmo/+++++++++++++: -+++++////M\r\n# MMMh:///++++-`+:```/dN+/::++++++++++++:``.+ooo++ohNMNm++oooooooo+++++o+ :++++/-//oM\r\n# MMd:/-/+++++-`/.``:hmm//./+++++++++o/o..:osoooymmdddmoooooooooooooo+oms.+++++////+M\r\n# MMo// -+++++:`.`` dNddo-.:+++++++++++--/soo:.--::ymh+ssssssssssooo+sNN/++++++++/-dM\r\n# Md/// `/+++o/```` dMddN.-:++++++++++/`/o/+:``-:-`/ooyssssssssssssoodmMo++++++++//NM\r\n# M/:// `-+oooo.``` oMNMM+--/+++++++++/:yd-``.`-+o+hoyyoosyyyyyyys:+o+o++o//+++++/hMM\r\n# m++:/```:oooo/````.dmNNm/-/+++++++//+dhy::ohs:/hysyosyyyyyyyyys:----:-/o/ooo++/-mMM\r\n# s:++//```/oooo- ``yNmdm:-/++++++////MMNmdhoys+ssssyyyyyysoysss:-.odd/o+/+oo++-+MMM\r\n# s`:++/````:oooo. ```:hNNh-/++++++//:hNNNMMNMdsossyyyyyyss+osdM/o/:yNyoo///ooo/.MMNM\r\n# d `-++/-```:+oo+-`````-+ds/++++++//-mMMMNNhs+syyysysyys+osdMMNyoshdh/+/o:ooo+.+MMNM\r\n# M/` `-/+/-``.:ooo-```````s:++++++++/mNdhsoossssyyhyo/-+hmMMMMNNNNNNo//+.:oo++ oMMNM\r\n# MMo``:..-//-.`-+oo:.`````/+++++++++:ooossyhyyyo+:-:ohNMmMMMMMNmNNNh:/:` :oo/: mMMNM\r\n# MMMh.oMh+``.-:-.-/o+-````mh/+++++++:++++/:--:+syhmMMMMMNMMMMMMMMMo-.//``+oo:`-MMNNM\r\n# MMMMh-omNd+````..`./+/.`hMMs+++++++/dmmmmNMMNNMMMMMMMMMMMMMMMMms:`` :/..+oo: yMNNNM\r\n# MNNNMN/``..``````````.-.+dNy-oooooo/o+s++sNMMNmNMMmmNMMMMMMMmo- ``-/.-oo+- yMNNNM\r\n# MNNNNMMNdy-``````..``````-+o/+ooooo/++///:`:yMMMMMMMMMMMMds/`/++/````o--o++- MMNNNM\r\n# MMNNMMMMMN:`........-:+oyssoo+ssssss:ooo+/+:`:mMMMMMNho/.````+ooohd+//:+ooo-/MMMMMM\r\n# MMMMMMMMMMs.-...-.-osyyyyysdMhshhhhhossssssdh-.ss+/-.``----.sdhy+mMMMsosssy:sMMMMMM\r\n# endregion ------------------------------------------------------------------------|\r\n# region ---------------------------------------------------------------------------|\r\nfrom sys import stdin, stdout\r\nfrom bisect import bisect_left, bisect_right\r\nfrom math import ceil, floor, log, gcd, sqrt\r\nfrom collections import Counter, deque\r\nfrom heapq import heappush, heappop, heapify\r\ndef re(): return stdin.readline().rstrip()\r\ndef ints(): return map(int, stdin.readline().split())\r\ndef test(tc): \r\n for _ in range(tc): solve()\r\nmod = 1000000007\r\nnl = \"\\n\"\r\n# endregion\r\n# region ---------------------------------------------------------------------------|\r\nclass Dsu:\r\n def __init__(self, n):\r\n self.parent = list(range(n))\r\n self.rank = [1] * n\r\n\r\n def find(self, x):\r\n while x != self.parent[x]:\r\n self.parent[x] = self.parent[self.parent[x]]\r\n x = self.parent[x]\r\n return x\r\n\r\n def union(self, x, y):\r\n px, py = self.find(x), self.find(y)\r\n if px == py: return 0\r\n if self.rank[py] > self.rank[px]:\r\n px, py = py, px\r\n self.parent[py] = px\r\n self.rank[px] += self.rank[py]\r\n return 1\r\n\r\n def get_size(self, x):\r\n return self.rank[self.find(x)]\r\n\r\nclass SegTree:\r\n def __init__(self, n, array):\r\n self.n = n\r\n self.tree = [0] * (2 * n)\r\n for i in range(n, 2 * n):\r\n self.tree[i] = array[i - n]\r\n for i in range(n - 1, -1, -1):\r\n self.tree[i] = self.tree[2 * i] + self.tree[2 * i + 1]\r\n \r\n def update(self, i, val):\r\n self.tree[i] = val\r\n while i:\r\n self.tree[i] = self.tree[i * 2] + self.tree[i * 2 + 1]\r\n i //= 2\r\n\r\n def query(self):\r\n pass\r\n\r\n def top(self):\r\n return self.tree[0]\r\n\r\n\r\n\r\n# endregion ------------------------------------------------------------------------|\r\n\r\ndef solve():\r\n n, m = ints()\r\n dp = [0] * (n + 1); dp[n] = 1\r\n suf = [0] * (n + 2); suf[n] = 1\r\n for i in range(n - 1, 0, -1):\r\n dp[i] = suf[i + 1] % m\r\n for mul in range(2, n + 1):\r\n lo = i * mul\r\n hi = (i + 1) * mul - 1\r\n if lo > n: break\r\n\r\n dp[i] = (dp[i] + suf[lo] - suf[min(n, hi) + 1]) % m\r\n\r\n suf[i] = (suf[i + 1] + dp[i]) % m\r\n \r\n print(dp[1] % m)\r\n return\r\n\r\ntest(1)\r\n"}, {"source_code": "from sys import stdin, gettrace\n\nif gettrace():\n def inputi():\n return input()\nelse:\n def input():\n return next(stdin)[:-1]\n\n\n def inputi():\n return stdin.buffer.readline()\n\n\ndef main():\n n,m = map(int, input().split())\n nways = [0, 1, 2]+[0]*(n-1)\n divisors = [[] for _ in range(n+1)]\n for i in range(2, n+1):\n for j in range(i, n+1, i):\n divisors[j].append(i)\n for i in range(3, n+1):\n nways[i] = (nways[i-1]*2)%m\n for d in divisors[i]:\n nways[i] = (nways[i] + nways[i//d] - nways[(i-1)//d])%m\n print(nways[n])\n\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "\r\nimport math\r\n\r\nn, m = map(int, input().split())\r\n\r\ndp = [0, 1]\r\ns = [0, 1]\r\n\r\nfor i in range(2,n+1):\r\n y = i**0.5\r\n k = math.ceil(y)\r\n\r\n res = s[-1]\r\n #print(\"res\",res)\r\n\r\n l = i // (1 + 1) + 1\r\n r = i // 1\r\n # print(\"l, r\",l,r)\r\n res += (r - l + 1) * dp[1]\r\n\r\n for j in range(2,k+int(k*k==i)):\r\n l = i//(j+1)+1\r\n r = i//j\r\n #print(\"l, r\",l,r)\r\n res += (r-l+1)*dp[j]\r\n if i//j > y:\r\n res += dp[r]\r\n\r\n\r\n s.append((s[-1]+res)%m)\r\n dp.append(res%m)\r\n\r\n\r\nprint(dp[n])"}, {"source_code": "# Legends Always Come Up with Solution\r\n# Author: Manvir Singh\r\n\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\ndef main():\r\n n, m = map(int, input().split())\r\n dp,pre,su= [0] * (n + 1),[0]*(n+2),0\r\n for i in range(1,n+1):\r\n pre[i]= (pre[i]+pre[i-1])%m\r\n dp[i] = (su+pre[i]+(i==1))%m\r\n su = (su+dp[i]) % m\r\n for j in range(2,n//i+1):\r\n pre[i*j]=(pre[i*j]+dp[i])%m\r\n z=min(i*j+j,n+1)\r\n pre[z]=(pre[z]-dp[i])%m\r\n print(dp[-1])\r\n\r\n\r\n# FASTIO REGION\r\n\r\nBUFSIZE = 8192\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "import sys\nfrom array import array\n\ninput = sys.stdin.readline\n\n\ndef ri(): return [int(i) for i in input().split()]\n\n\ndef rs(): return input().split()[0]\n\n\ndef main():\n t = 1\n\n for _ in range(t):\n n, m = ri()\n # ans = [0] * (n + 1)\n # ans[n] = 1\n # sum = [0] * (n + 2) # ans[x] + ... + ans[n]\n sum = array('L', range(n + 2)) # ans[x] + ... + ans[n]\n sum[n] = 1\n sum[n+1] = 0\n\n last = -1\n for x in range(n - 1, 0, -1):\n extra = sum[x + 1] # jump by subtraction\n\n # jump by division\n for d in range(2, n // x + 1):\n from_ = x * d\n to_ = min(x * d + d - 1, n)\n extra = (extra + m + sum[from_] - sum[to_ + 1]) % m\n\n last = extra\n sum[x] = (sum[x + 1] + last) % m\n # print(ans)\n print(last % m)\n\n\nmain()\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\n\n\ndef ri(): return [int(i) for i in input().split()]\n\n\ndef rs(): return input().split()[0]\n\n\ndef main():\n t = 1\n\n for _ in range(t):\n n, m = ri()\n ans = [0] * (n + 1)\n sum = [0] * (n + 2) # ans[x] + ... + ans[n]\n ans[n] = 1\n sum[n] = 1\n for x in range(n - 1, 0, -1):\n extra = sum[x + 1] # jump by subtraction\n\n # jump by division\n for d in range(2, n // x + 1):\n from_ = x * d\n to_ = min(x * d + d - 1, n)\n extra = (extra + m + sum[from_] - sum[to_ + 1]) % m\n\n ans[x] = extra\n sum[x] = (sum[x + 1] + ans[x]) % m\n # print(ans)\n print(ans[1] % m)\n\n\nmain()\n"}, {"source_code": "\r\ndef naiveSolve():\r\n \r\n \r\n \r\n return\r\n\r\n\r\n\r\ndef solve():\r\n \r\n \r\n \r\n return\r\n\r\nimport __pypy__\r\nint_add = __pypy__.intop.int_add\r\nint_sub = __pypy__.intop.int_sub\r\nint_mul = __pypy__.intop.int_mul\r\ndef make_mod_mul(mod = 10**9 + 7):\r\n fmod_inv = 1.0 / mod\r\n def mod_mul(a, b, c=0):\r\n res = int_sub(\r\n int_add(int_mul(a, b), c),\r\n int_mul(mod, int(fmod_inv * a * b + fmod_inv * c)),\r\n )\r\n if res >= mod:\r\n return res - mod\r\n elif res < 0:\r\n return res + mod\r\n else:\r\n return res\r\n return mod_mul\r\n\r\n\r\ndef main():\r\n \r\n n,MOD=readIntArr()\r\n \r\n mod_mul=make_mod_mul(MOD)\r\n \r\n dp=[0]*(n+5)\r\n dp[1]=1\r\n prefixSum=1\r\n for i in range(2,n+1):\r\n dp[i]+=prefixSum\r\n # print('i:{} pfx:{}'.format(i,prefixSum))\r\n # sqRtI=pow(i,0.5)\r\n z=2\r\n visitedDivisors=set()\r\n while z*z<=i:\r\n dp[i]+=dp[i//z]\r\n dp[i]%=MOD\r\n visitedDivisors.add(i//z)\r\n # print('i:{} z:{} i//z:{}'.format(i,z,i//z))\r\n z+=1\r\n c=1\r\n # while c*c<i:\r\n while c*c<i and c not in visitedDivisors:\r\n zLeft=floor(i/(c+1)+1)\r\n zRight=floor(i/c)\r\n cnts=zRight-zLeft+1\r\n toAdd=mod_mul(dp[c],cnts)\r\n dp[i]+=toAdd\r\n dp[i]%=MOD\r\n # print('i:{} c:{} zLeft:{} zRight:{} cnts:{}'.format(i,c,zLeft,zRight,cnts))\r\n c+=1\r\n prefixSum+=dp[i]\r\n prefixSum%=MOD\r\n ans=dp[n]\r\n # print(dp)\r\n print(ans)\r\n \r\n return\r\n\r\n\r\n\r\nimport sys\r\ninput=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)\r\n# input=lambda: sys.stdin.readline().rstrip(\"\\r\\n\") #FOR READING STRING/TEXT INPUTS.\r\n\r\ndef oneLineArrayPrint(arr):\r\n print(' '.join([str(x) for x in arr]))\r\ndef multiLineArrayPrint(arr):\r\n print('\\n'.join([str(x) for x in arr]))\r\ndef multiLineArrayOfArraysPrint(arr):\r\n print('\\n'.join([' '.join([str(x) for x in y]) for y in arr]))\r\n \r\ndef readIntArr():\r\n return [int(x) for x in input().split()]\r\n# def readFloatArr():\r\n# return [float(x) for x in input().split()]\r\n \r\ndef makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])\r\n dv=defaultValFactory;da=dimensionArr\r\n if len(da)==1:return [dv() for _ in range(da[0])]\r\n else:return [makeArr(dv,da[1:]) for _ in range(da[0])]\r\n \r\ndef queryInteractive(x):\r\n print('{}'.format(x))\r\n sys.stdout.flush()\r\n return int(input())\r\n \r\ndef answerInteractive(ans):\r\n print('! {}'.format(ans))\r\n sys.stdout.flush()\r\n \r\ninf=float('inf')\r\n# MOD=10**9+7\r\nMOD=998244353\r\n\r\nfrom math import gcd,floor,ceil\r\n# from math import floor,ceil # for Python2\r\n \r\nfor _abc in range(1):\r\n main()"}, {"source_code": "n, m = map(int, input().split())\nc = [0]*n + [1] + [0]*n\nfor i in range(n-1, 0, -1):\n c[i] = 2*c[i+1] % m\n for j in range(2, n//i + 1):\n c[i] = (c[i] + c[i*j] - c[(i+1)*j]) % m\n \nprint((c[1] - c[2]) % m)"}, {"source_code": "from collections import defaultdict, Counter,deque\r\nfrom math import sqrt, log10, log, floor, factorial,gcd\r\nfrom bisect import bisect_left, bisect_right\r\nfrom itertools import permutations,combinations\r\nimport sys, io, os\r\ninput = sys.stdin.readline\r\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n# sys.setrecursionlimit(10000)\r\ninf = float('inf')\r\nmod = 10 ** 9 + 7\r\ndef yn(a): print(\"YES\" if a else \"NO\")\r\nceil = lambda a, b: (a + b - 1) // b\r\nclass LazySegmentTree:\r\n def __init__(self, data, default=0, func=max, mod=-1):\r\n \"\"\"initialize the lazy segment tree with data\"\"\"\r\n self.m = mod\r\n\r\n self._default = default\r\n self._func = func\r\n\r\n self._len = len(data)\r\n self._size = _size = 1 << (self._len - 1).bit_length()\r\n self._lazy = [0] * (2 * _size)\r\n\r\n self.data = [default] * (2 * _size)\r\n self.data[_size:_size + self._len] = data\r\n for i in reversed(range(_size)):\r\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\r\n\r\n def __len__(self):\r\n return self._len\r\n\r\n def _push(self, idx):\r\n \"\"\"push query on idx to its children\"\"\"\r\n # Let the children know of the queries\r\n q, self._lazy[idx] = self._lazy[idx], 0\r\n\r\n self._lazy[2 * idx] = (self._lazy[2 * idx] + q) % self.m\r\n self._lazy[2 * idx + 1] = (self._lazy[2 * idx + 1] + q) % self.m\r\n self.data[2 * idx] = (self.data[2 * idx] + q) % self.m\r\n self.data[2 * idx + 1] = (self.data[2 * idx + 1] + q) % self.m\r\n\r\n def _update(self, idx):\r\n \"\"\"updates the node idx to know of all queries applied to it via its ancestors\"\"\"\r\n for i in reversed(range(1, idx.bit_length())):\r\n self._push(idx >> i)\r\n\r\n def _build(self, idx):\r\n \"\"\"make the changes to idx be known to its ancestors\"\"\"\r\n idx >>= 1\r\n while idx:\r\n self.data[idx] = (self._func(self.data[2 * idx], self.data[2 * idx + 1]) + self._lazy[idx]) % self.m\r\n idx >>= 1\r\n\r\n def add(self, start, stop, value):\r\n \"\"\"lazily add value to [start, stop)\"\"\"\r\n start = start_copy = start + self._size\r\n stop = stop_copy = stop + self._size\r\n while start < stop:\r\n if start & 1:\r\n self._lazy[start] = (self._lazy[start] + value) % self.m\r\n self.data[start] = (self.data[start] + value) % self.m\r\n start += 1\r\n if stop & 1:\r\n stop -= 1\r\n self._lazy[stop] = (self._lazy[stop] + value) % self.m\r\n self.data[stop] = (self.data[stop] + value) % self.m\r\n start >>= 1\r\n stop >>= 1\r\n\r\n # Tell all nodes above of the updated area of the updates\r\n self._build(start_copy)\r\n self._build(stop_copy - 1)\r\n\r\n def query(self, start, stop, default=0):\r\n \"\"\"func of data[start, stop)\"\"\"\r\n start += self._size\r\n stop += self._size\r\n\r\n # Apply all the lazily stored queries\r\n self._update(start)\r\n self._update(stop - 1)\r\n\r\n res = default\r\n while start < stop:\r\n if start & 1:\r\n res = self._func(res, self.data[start])\r\n start += 1\r\n if stop & 1:\r\n stop -= 1\r\n res = self._func(res, self.data[stop])\r\n start >>= 1\r\n stop >>= 1\r\n return res\r\n\r\n def __getitem__(self, idx):\r\n return self.query(idx, idx + 1)\r\n\r\n def __repr__(self):\r\n return \"LazySegmentTree({0})\".format(self.data)\r\nt=1\r\nfor i in range(t):\r\n n,m=[int(i) for i in input().split()]\r\n arr=LazySegmentTree([0 for i in range(n+1)],mod=m)\r\n arr.add(1,2,1)\r\n for i in range(1,n):\r\n arr.add(i+1,n+1,arr[i])\r\n for j in range(2,n//i+1):\r\n arr.add(i*j,min(j*(i+1),n+1),arr[i])\r\n # print([arr[i] for i in range(n+1)])\r\n print(arr[n])\r\n"}, {"source_code": "from sys import path_hooks, stdin, stdout\r\nimport sys\r\n\r\n \r\ndef mapinput():\r\n return map(int, stdin.readline().split())\r\n\r\n\r\nn , m = mapinput()\r\n\r\nfactors = [ [] for i in range(n+1) ] \r\nfor i in range( 1, n+1 ):\r\n for j in range( i+i , n +1 , i ):\r\n factors[j].append(i)\r\n\r\nfor test in range(1):\r\n def solve():\r\n memo = {0:0 , 1:1 , 2:2 , 3: 5}\r\n for i in range(4 , n+1):\r\n ans = memo[i-1] * 2\r\n for j in factors[i]:\r\n ans += memo[j] - memo[j-1]\r\n ans %= m\r\n memo[i] = ans\r\n return memo[n]\r\n\r\n\r\n\r\n print(solve())\r\n\r\n"}, {"source_code": "from __future__ import division, print_function\r\nimport math\r\nimport sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n\tnewlines = 0\r\n\r\n\tdef __init__(self, file):\r\n\t\tself._fd = file.fileno()\r\n\t\tself.buffer = BytesIO()\r\n\t\tself.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n\t\tself.write = self.buffer.write if self.writable else None\r\n\r\n\tdef read(self):\r\n\t\twhile True:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tif not b:\r\n\t\t\t\tbreak\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines = 0\r\n\t\treturn self.buffer.read()\r\n\r\n\tdef readline(self):\r\n\t\twhile self.newlines == 0:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tself.newlines = b.count(b\"\\n\") + (not b)\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines -= 1\r\n\t\treturn self.buffer.readline()\r\n\r\n\tdef flush(self):\r\n\t\tif self.writable:\r\n\t\t\tos.write(self._fd, self.buffer.getvalue())\r\n\t\t\tself.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n\tdef __init__(self, file):\r\n\t\tself.buffer = FastIO(file)\r\n\t\tself.flush = self.buffer.flush\r\n\t\tself.writable = self.buffer.writable\r\n\t\tself.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n\t\tself.read = lambda: self.buffer.read().decode(\"ascii\")\r\n\t\tself.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\ndef print(*args, **kwargs):\r\n\t\"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n\tat_start = True\r\n\tfor x in args:\r\n\t\tif not at_start:\r\n\t\t\tfile.write(sep)\r\n\t\tfile.write(str(x))\r\n\t\tat_start = False\r\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\r\n\tif kwargs.pop(\"flush\", False):\r\n\t\tfile.flush()\r\n\r\n\r\nif sys.version_info[0] < 3:\r\n\tsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n\tsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input().strip()\r\n return(list(s[:len(s)]))\r\ndef invr():\r\n return(map(int,input().split()))\r\ndef Divisors(n) :\r\n i = 1\r\n fac=[]\r\n while i <= int(math.sqrt(n)):\r\n \r\n if (n % i == 0) :\r\n if (n // i == i) :\r\n fac.append(i)\r\n else :\r\n fac.append(i)\r\n fac.append(n//i)\r\n i = i + 1\r\n return fac\r\nn,maxn=invr()\r\ndp=[0 for i in range(n+1)]\r\ndp[1]=1\r\ndp[2]=2\r\nsm=3\r\nfor i in range(3,n+1):\r\n dp[i]=(2*dp[i-1])%maxn\r\n fac=Divisors(i)\r\n fac.sort()\r\n for j in fac:\r\n if j==i:continue\r\n dp[i]+=dp[j]-dp[j-1]\r\n dp[i]=dp[i]%maxn\r\nprint(dp[n]%maxn)\r\n# print(dp)"}, {"source_code": "# ------------------- fast io --------------------\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# ------------------- fast io --------------------\r\nfrom math import ceil\r\n\r\n\r\ndef prod(a, mod=10 ** 9 + 7):\r\n ans = 1\r\n for each in a:\r\n ans = (ans * each) % mod\r\n return ans\r\n\r\n\r\ndef gcd(x, y):\r\n while y:\r\n x, y = y, x % y\r\n return x\r\n\r\n\r\ndef lcm(a, b): return a * b // gcd(a, b)\r\n\r\n\r\ndef binary(x, length=16):\r\n y = bin(x)[2:]\r\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\r\n\r\n\r\nfrom collections import Counter\r\n\r\n\r\ndef gcd(x, y):\r\n \"\"\"greatest common divisor of x and y\"\"\"\r\n while y:\r\n x, y = y, x % y\r\n return x\r\n\r\n\r\ndef memodict(f):\r\n \"\"\"memoization decorator for a function taking a single argument\"\"\"\r\n \r\n class memodict(dict):\r\n def __missing__(self, key):\r\n ret = self[key] = f(key)\r\n return ret\r\n \r\n return memodict().__getitem__\r\n\r\n\r\ndef pollard_rho(n):\r\n \"\"\"returns a random factor of n\"\"\"\r\n if n & 1 == 0:\r\n return 2\r\n if n % 3 == 0:\r\n return 3\r\n \r\n s = ((n - 1) & (1 - n)).bit_length() - 1\r\n d = n >> s\r\n for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:\r\n p = pow(a, d, n)\r\n if p == 1 or p == n - 1 or a % n == 0:\r\n continue\r\n for _ in range(s):\r\n prev = p\r\n p = (p * p) % n\r\n if p == 1:\r\n return gcd(prev - 1, n)\r\n if p == n - 1:\r\n break\r\n else:\r\n for i in range(2, n):\r\n x, y = i, (i * i + 1) % n\r\n f = gcd(abs(x - y), n)\r\n while f == 1:\r\n x, y = (x * x + 1) % n, (y * y + 1) % n\r\n y = (y * y + 1) % n\r\n f = gcd(abs(x - y), n)\r\n if f != n:\r\n return f\r\n return n\r\n\r\n\r\n@memodict\r\ndef prime_factors(n):\r\n \"\"\"returns a Counter of the prime factorization of n\"\"\"\r\n if n <= 1:\r\n return Counter()\r\n f = pollard_rho(n)\r\n return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)\r\n\r\n\r\ndef distinct_factors(n):\r\n \"\"\"returns a list of all distinct factors of n\"\"\"\r\n factors = [1]\r\n for p, exp in prime_factors(n).items():\r\n factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]\r\n return factors\r\n\r\n\r\ndef all_factors(n):\r\n \"\"\"returns a sorted list of all distinct factors of n\"\"\"\r\n small, large = [], []\r\n for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):\r\n if not n % i:\r\n small.append(i)\r\n large.append(n // i)\r\n if small[-1] == large[-1]:\r\n large.pop()\r\n large.reverse()\r\n small.extend(large)\r\n return small\r\n\r\nfor _ in range(int(input()) if not True else 1):\r\n #n = int(input())\r\n n, m = map(int, input().split())\r\n # a, b = map(int, input().split())\r\n # c, d = map(int, input().split())\r\n # a = list(map(int, input().split()))\r\n # b = list(map(int, input().split()))\r\n # s = input()\r\n dp = [0] * (n + 1)\r\n dp[1] = 1\r\n dp[2] = 2\r\n for i in range(3, n+1):\r\n dp[i]= 2*dp[i-1] + dp[1]\r\n for f in all_factors(i):\r\n if f == 1 or f == i:continue\r\n dp[i] += dp[i//f] - dp[(i//f) - 1]\r\n dp[i] %= m\r\n print(dp[-1])"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,m=map(int,input().split())\r\n\r\nS=[i for i in range(n+1)]\r\n\r\nfor i in range(2,n+1):\r\n if S[i]==i:\r\n for j in range(i,n+1,i):\r\n if S[j]==j:\r\n S[j]=i\r\n\r\ndef fact(x):\r\n NOW={1}\r\n while x!=1:\r\n NOW|={n*S[x] for n in NOW}\r\n x//=S[x]\r\n\r\n return NOW\r\n\r\nDP=[0]*(n+5)\r\n\r\nDP[1]=1\r\nDP[2]=2\r\nDP[3]=5\r\n#DP[4]=12\r\n#DP[5]=25\r\n\r\nfor i in range(4,n+1):\r\n SU=DP[i-1]*2+1\r\n \r\n for f in fact(i):\r\n if f==1 or f==i:\r\n continue\r\n SU+=DP[i//f]-DP[(i-1)//f]\r\n\r\n DP[i]=SU%m\r\n\r\nprint(DP[n])\r\n \r\n \r\n"}, {"source_code": "for u in range(1):\r\n n, m = map(int, input().split())\r\n dp = [0 for i in range(n+1)]\r\n dp[1] = 1\r\n p = [0]*(n+1)\r\n cache = [[] for i in range(n+1)]\r\n \r\n a = 0\r\n b = 1\r\n \r\n for i in range(2, n+1):\r\n for j in cache[i]:\r\n a = (a - dp[p[j]] + m)%m\r\n p[j] += 1\r\n a = (a + dp[p[j]])%m\r\n \r\n a = (a + dp[1])%m\r\n dp[i] = (a + b)%m\r\n b = (b + dp[i])%m\r\n \r\n p[i] = 1\r\n j = 2\r\n while(i*j <= n):\r\n cache[i*j].append(i)\r\n j += 1\r\n \r\n print(dp[n])"}, {"source_code": "n, mod = map(int, input().split())\r\n\r\ndp = [0] * (n + 1)\r\ndp[n] = 1\r\nsdp = [0] * (n + 2)\r\nsdp[n] = 1\r\nfor i in range(n - 1, 0, -1):\r\n cur = 2\r\n while True:\r\n if i * cur > n:\r\n break\r\n \r\n start = i * cur\r\n end = min(n, (i + 1) * cur - 1)\r\n \r\n dp[i] += sdp[start] - sdp[end + 1]\r\n dp[i] %= mod\r\n \r\n cur += 1\r\n \r\n dp[i] += sdp[i + 1]\r\n dp[i] %= mod\r\n \r\n sdp[i] = dp[i] + sdp[i + 1]\r\n sdp[i] %= mod\r\n \r\nprint(dp[1])"}, {"source_code": "n, m = map(int, input().split())\r\nc = [0] * n + [1] + [0] * n\r\nfor i in range(n - 1, 0, -1):\r\n c[i] = 2 * c[i + 1] % m\r\n for j in range(2, n // i + 1):\r\n c[i] = (c[i] + c[i * j] - c[(i + 1) * j]) % m\r\n\r\nprint((c[1] - c[2]) % m)"}, {"source_code": "import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353\r\n\r\nn,m=M()\r\np=[0]*(n+2);p[n]=1\r\nfor i in range(n-1,0,-1):\r\n cur=p[i+1]\r\n for j in range(2,n//i +1):\r\n l=j*i;r=min(j*i+j-1,n)\r\n cur=(cur+(p[l]-p[r+1])%m)%m\r\n p[i]=(p[i+1]+cur)%m\r\nprint((p[1]-p[2])%m)"}, {"source_code": "n,m=map(int,input().split())\r\ndp=[0 for i in range(n+1)]\r\ndp[1]=1\r\ndp[2]=2\r\nfor i in range(2, n+1):\r\n if i>2: dp[i]=(dp[i]+dp[i-1]+dp[i-1]+1)%m\r\n for j in range(i+i, n+1, i):\r\n dp[j]=(dp[j]+dp[i]-dp[i-1])%m\r\nprint((dp[n]+m)%m)\r\n"}, {"source_code": "n, mod = map(int,input().split())\nif n==1:\n\tprint (1)\n\texit()\nfact = [{} for i in range(n+1)]\nfor i in range(1, n+1):\n\tfor j in range(i, n+1, i):\n\t\tfact[j][i] = 1\n\nans = [0]*n\nans[0] = 1\nans[1] = 2\n\nfor i in range(2, n):\n\tans[i] = (2*ans[i-1]) % mod\n\tfor j in fact[i+1]:\n\t\tif j==i+1:\n\t\t\tcontinue\n\t\tif j==1:\n\t\t\tans[i] = (ans[i] + ans[j-1]) % mod\n\t\t\tcontinue\n\t\tans[i] = (ans[i] + (ans[j-1] - ans[j-2])) % mod\nprint (ans[-1]%mod)\n"}, {"source_code": "#Code by Sounak, IIESTS\r\n#------------------------------warmup----------------------------\r\n\r\nimport os\r\nimport sys\r\nimport math\r\nfrom io import BytesIO, IOBase\r\nimport io\r\nfrom fractions import Fraction\r\nimport collections\r\nfrom itertools import permutations\r\nfrom collections import defaultdict\r\nfrom collections import deque\r\nfrom collections import Counter\r\nimport threading\r\n\r\n#sys.setrecursionlimit(300000)\r\n#threading.stack_size(10**8)\r\n\r\nBUFSIZE = 8192\r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n \r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n \r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n \r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n \r\n \r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n#-------------------game starts now-----------------------------------------------------\r\n#mod = 9223372036854775807 \r\nclass SegmentTree:\r\n def __init__(self, data, default=0, func=lambda a, b: math.gcd(a,b)):\r\n \"\"\"initialize the segment tree with data\"\"\"\r\n self._default = default\r\n self._func = func\r\n self._len = len(data)\r\n self._size = _size = 1 << (self._len - 1).bit_length()\r\n \r\n self.data = [default] * (2 * _size)\r\n self.data[_size:_size + self._len] = data\r\n for i in reversed(range(_size)):\r\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\r\n \r\n def __delitem__(self, idx):\r\n self[idx] = self._default\r\n \r\n def __getitem__(self, idx):\r\n return self.data[idx + self._size]\r\n \r\n def __setitem__(self, idx, value):\r\n idx += self._size\r\n self.data[idx] = value\r\n idx >>= 1\r\n while idx:\r\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\r\n idx >>= 1\r\n \r\n def __len__(self):\r\n return self._len\r\n \r\n def query(self, start, stop):\r\n if start == stop:\r\n return self.__getitem__(start)\r\n stop += 1\r\n start += self._size\r\n stop += self._size\r\n \r\n res = self._default\r\n while start < stop:\r\n if start & 1:\r\n res = self._func(res, self.data[start])\r\n start += 1\r\n if stop & 1:\r\n stop -= 1\r\n res = self._func(res, self.data[stop])\r\n start >>= 1\r\n stop >>= 1\r\n return res\r\n \r\n def __repr__(self):\r\n return \"SegmentTree({0})\".format(self.data)\r\n \r\nclass SegmentTree1:\r\n def __init__(self, data, default=0, func=lambda a, b: a+b):\r\n \"\"\"initialize the segment tree with data\"\"\"\r\n self._default = default\r\n self._func = func\r\n self._len = len(data)\r\n self._size = _size = 1 << (self._len - 1).bit_length()\r\n \r\n self.data = [default] * (2 * _size)\r\n self.data[_size:_size + self._len] = data\r\n for i in reversed(range(_size)):\r\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\r\n \r\n def __delitem__(self, idx):\r\n self[idx] = self._default\r\n \r\n def __getitem__(self, idx):\r\n return self.data[idx + self._size]\r\n \r\n def __setitem__(self, idx, value):\r\n idx += self._size\r\n self.data[idx] = value\r\n idx >>= 1\r\n while idx:\r\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\r\n idx >>= 1\r\n \r\n def __len__(self):\r\n return self._len\r\n \r\n def query(self, start, stop):\r\n if start == stop:\r\n return self.__getitem__(start)\r\n stop += 1\r\n start += self._size\r\n stop += self._size\r\n \r\n res = self._default\r\n while start < stop:\r\n if start & 1:\r\n res = self._func(res, self.data[start])\r\n start += 1\r\n if stop & 1:\r\n stop -= 1\r\n res = self._func(res, self.data[stop])\r\n start >>= 1\r\n stop >>= 1\r\n return res\r\n \r\n def __repr__(self):\r\n return \"SegmentTree({0})\".format(self.data)\r\n \r\nMOD=10**9+7\r\nclass Factorial:\r\n def __init__(self, MOD):\r\n self.MOD = MOD\r\n self.factorials = [1, 1]\r\n self.invModulos = [0, 1]\r\n self.invFactorial_ = [1, 1]\r\n \r\n def calc(self, n):\r\n if n <= -1:\r\n print(\"Invalid argument to calculate n!\")\r\n print(\"n must be non-negative value. But the argument was \" + str(n))\r\n exit()\r\n if n < len(self.factorials):\r\n return self.factorials[n]\r\n nextArr = [0] * (n + 1 - len(self.factorials))\r\n initialI = len(self.factorials)\r\n prev = self.factorials[-1]\r\n m = self.MOD\r\n for i in range(initialI, n + 1):\r\n prev = nextArr[i - initialI] = prev * i % m\r\n self.factorials += nextArr\r\n return self.factorials[n]\r\n \r\n def inv(self, n):\r\n if n <= -1:\r\n print(\"Invalid argument to calculate n^(-1)\")\r\n print(\"n must be non-negative value. But the argument was \" + str(n))\r\n exit()\r\n p = self.MOD\r\n pi = n % p\r\n if pi < len(self.invModulos):\r\n return self.invModulos[pi]\r\n nextArr = [0] * (n + 1 - len(self.invModulos))\r\n initialI = len(self.invModulos)\r\n for i in range(initialI, min(p, n + 1)):\r\n next = -self.invModulos[p % i] * (p // i) % p\r\n self.invModulos.append(next)\r\n return self.invModulos[pi]\r\n \r\n def invFactorial(self, n):\r\n if n <= -1:\r\n print(\"Invalid argument to calculate (n^(-1))!\")\r\n print(\"n must be non-negative value. But the argument was \" + str(n))\r\n exit()\r\n if n < len(self.invFactorial_):\r\n return self.invFactorial_[n]\r\n self.inv(n) # To make sure already calculated n^-1\r\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\r\n initialI = len(self.invFactorial_)\r\n prev = self.invFactorial_[-1]\r\n p = self.MOD\r\n for i in range(initialI, n + 1):\r\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\r\n self.invFactorial_ += nextArr\r\n return self.invFactorial_[n]\r\n \r\n \r\nclass Combination:\r\n def __init__(self, MOD):\r\n self.MOD = MOD\r\n self.factorial = Factorial(MOD)\r\n \r\n def ncr(self, n, k):\r\n if k < 0 or n < k:\r\n return 0\r\n k = min(k, n - k)\r\n f = self.factorial\r\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\r\nmod=10**9+7\r\nomod=998244353\r\n#-------------------------------------------------------------------------\r\nprime = [True for i in range(11)] \r\nprime[0]=prime[1]=False\r\n#pp=[0]*10\r\ndef SieveOfEratosthenes(n=10):\r\n p = 2\r\n c=0\r\n while (p <= n): \r\n \r\n if (prime[p] == True):\r\n c+=1\r\n for i in range(p, n+1, p): \r\n #pp[i]=1\r\n prime[i] = False\r\n p += 1\r\n#-----------------------------------DSU--------------------------------------------------\r\nclass DSU:\r\n def __init__(self, R, C):\r\n #R * C is the source, and isn't a grid square\r\n self.par = range(R*C + 1)\r\n self.rnk = [0] * (R*C + 1)\r\n self.sz = [1] * (R*C + 1)\r\n\r\n def find(self, x):\r\n if self.par[x] != x:\r\n self.par[x] = self.find(self.par[x])\r\n return self.par[x]\r\n\r\n def union(self, x, y):\r\n xr, yr = self.find(x), self.find(y)\r\n if xr == yr: return\r\n if self.rnk[xr] < self.rnk[yr]:\r\n xr, yr = yr, xr\r\n if self.rnk[xr] == self.rnk[yr]:\r\n self.rnk[xr] += 1\r\n\r\n self.par[yr] = xr\r\n self.sz[xr] += self.sz[yr]\r\n\r\n def size(self, x):\r\n return self.sz[self.find(x)]\r\n\r\n def top(self):\r\n # Size of component at ephemeral \"source\" node at index R*C,\r\n # minus 1 to not count the source itself in the size\r\n return self.size(len(self.sz) - 1) - 1\r\n#---------------------------------Lazy Segment Tree--------------------------------------\r\n# https://github.com/atcoder/ac-library/blob/master/atcoder/lazysegtree.hpp\r\nclass LazySegTree:\r\n def __init__(self, _op, _e, _mapping, _composition, _id, v):\r\n def set(p, x):\r\n assert 0 <= p < _n\r\n p += _size\r\n for i in range(_log, 0, -1):\r\n _push(p >> i)\r\n _d[p] = x\r\n for i in range(1, _log + 1):\r\n _update(p >> i)\r\n \r\n def get(p):\r\n assert 0 <= p < _n\r\n p += _size\r\n for i in range(_log, 0, -1):\r\n _push(p >> i)\r\n return _d[p]\r\n \r\n def prod(l, r):\r\n assert 0 <= l <= r <= _n\r\n \r\n if l == r:\r\n return _e\r\n \r\n l += _size\r\n r += _size\r\n \r\n for i in range(_log, 0, -1):\r\n if ((l >> i) << i) != l:\r\n _push(l >> i)\r\n if ((r >> i) << i) != r:\r\n _push(r >> i)\r\n \r\n sml = _e\r\n smr = _e\r\n while l < r:\r\n if l & 1:\r\n sml = _op(sml, _d[l])\r\n l += 1\r\n if r & 1:\r\n r -= 1\r\n smr = _op(_d[r], smr)\r\n l >>= 1\r\n r >>= 1\r\n \r\n return _op(sml, smr)\r\n \r\n def apply(l, r, f):\r\n assert 0 <= l <= r <= _n\r\n if l == r:\r\n return\r\n \r\n l += _size\r\n r += _size\r\n \r\n for i in range(_log, 0, -1):\r\n if ((l >> i) << i) != l:\r\n _push(l >> i)\r\n if ((r >> i) << i) != r:\r\n _push((r - 1) >> i)\r\n \r\n l2 = l\r\n r2 = r\r\n while l < r:\r\n if l & 1:\r\n _all_apply(l, f)\r\n l += 1\r\n if r & 1:\r\n r -= 1\r\n _all_apply(r, f)\r\n l >>= 1\r\n r >>= 1\r\n l = l2\r\n r = r2\r\n \r\n for i in range(1, _log + 1):\r\n if ((l >> i) << i) != l:\r\n _update(l >> i)\r\n if ((r >> i) << i) != r:\r\n _update((r - 1) >> i)\r\n \r\n def _update(k):\r\n _d[k] = _op(_d[2 * k], _d[2 * k + 1])\r\n \r\n def _all_apply(k, f):\r\n _d[k] = _mapping(f, _d[k])\r\n if k < _size:\r\n _lz[k] = _composition(f, _lz[k])\r\n \r\n def _push(k):\r\n _all_apply(2 * k, _lz[k])\r\n _all_apply(2 * k + 1, _lz[k])\r\n _lz[k] = _id\r\n \r\n _n = len(v)\r\n _log = _n.bit_length()\r\n _size = 1 << _log\r\n _d = [_e] * (2 * _size)\r\n _lz = [_id] * _size\r\n for i in range(_n):\r\n _d[_size + i] = v[i]\r\n for i in range(_size - 1, 0, -1):\r\n _update(i)\r\n \r\n self.set = set\r\n self.get = get\r\n self.prod = prod\r\n self.apply = apply\r\n \r\n \r\nMIL = 1 << 20\r\n \r\n \r\ndef makeNode(total, count):\r\n # Pack a pair into a float\r\n return (total * MIL) + count\r\n \r\n \r\ndef getTotal(node):\r\n return math.floor(node / MIL)\r\n \r\n \r\ndef getCount(node):\r\n return node - getTotal(node) * MIL\r\n \r\n \r\nnodeIdentity = makeNode(0.0, 0.0)\r\n \r\n \r\ndef nodeOp(node1, node2):\r\n return node1 + node2\r\n # Equivalent to the following:\r\n return makeNode(\r\n getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2)\r\n )\r\n \r\n \r\nidentityMapping = -1\r\n \r\n \r\ndef mapping(tag, node):\r\n if tag == identityMapping:\r\n return node\r\n # If assigned, new total is the number assigned times count\r\n count = getCount(node)\r\n return makeNode(tag * count, count)\r\n \r\n \r\ndef composition(mapping1, mapping2):\r\n # If assigned multiple times, take first non-identity assignment\r\n return mapping1 if mapping1 != identityMapping else mapping2\r\n#---------------------------------Pollard rho--------------------------------------------\r\ndef memodict(f):\r\n \"\"\"memoization decorator for a function taking a single argument\"\"\"\r\n class memodict(dict):\r\n def __missing__(self, key):\r\n ret = self[key] = f(key)\r\n return ret\r\n \r\n return memodict().__getitem__\r\n \r\n \r\ndef pollard_rho(n):\r\n \"\"\"returns a random factor of n\"\"\"\r\n if n & 1 == 0:\r\n return 2\r\n if n % 3 == 0:\r\n return 3\r\n \r\n s = ((n - 1) & (1 - n)).bit_length() - 1\r\n d = n >> s\r\n for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:\r\n p = pow(a, d, n)\r\n if p == 1 or p == n - 1 or a % n == 0:\r\n continue\r\n for _ in range(s):\r\n prev = p\r\n p = (p * p) % n\r\n if p == 1:\r\n return math.gcd(prev - 1, n)\r\n if p == n - 1:\r\n break\r\n else:\r\n for i in range(2, n):\r\n x, y = i, (i * i + 1) % n\r\n f = math.gcd(abs(x - y), n)\r\n while f == 1:\r\n x, y = (x * x + 1) % n, (y * y + 1) % n\r\n y = (y * y + 1) % n\r\n f = math.gcd(abs(x - y), n)\r\n if f != n:\r\n return f\r\n return n\r\n \r\n \r\n@memodict\r\ndef prime_factors(n):\r\n \"\"\"returns a Counter of the prime factorization of n\"\"\"\r\n if n <= 1:\r\n return Counter()\r\n f = pollard_rho(n)\r\n return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)\r\n \r\n \r\ndef distinct_factors(n):\r\n \"\"\"returns a list of all distinct factors of n\"\"\"\r\n factors = [1]\r\n for p, exp in prime_factors(n).items():\r\n factors += [p**i * factor for factor in factors for i in range(1, exp + 1)]\r\n return factors\r\n \r\n \r\ndef all_factors(n):\r\n \"\"\"returns a sorted list of all distinct factors of n\"\"\"\r\n small, large = [], []\r\n for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):\r\n if not n % i:\r\n small.append(i)\r\n large.append(n // i)\r\n if small[-1] == large[-1]:\r\n large.pop()\r\n large.reverse()\r\n small.extend(large)\r\n return small\r\n\r\n#---------------------------------Binary Search------------------------------------------\r\ndef binarySearch(arr, n, key):\r\n left = 0\r\n right = n-1\r\n mid = 0\r\n res = n\r\n while (left <= right):\r\n mid = (right + left)//2\r\n if (arr[mid] > key):\r\n res=mid\r\n right = mid-1\r\n else:\r\n left = mid + 1\r\n return res\r\n\r\ndef binarySearch1(arr, n, key):\r\n left = 0\r\n right = n-1\r\n mid = 0\r\n res=-1\r\n while (left <= right):\r\n mid = (right + left)//2\r\n if (arr[mid] > key):\r\n right = mid-1\r\n else:\r\n res=mid\r\n left = mid + 1\r\n return res\r\n#---------------------------------running code------------------------------------------\r\nt=1\r\n#t=int(input())\r\nfor _ in range (t):\r\n #n=int(input())\r\n n,m=map(int,input().split())\r\n #a=list(map(int,input().split()))\r\n #b=list(map(int,input().split()))\r\n #s=input()\r\n #n=len(s)\r\n dp = [0] * (n + 1)\r\n dp[1] = 1\r\n dp[2] = 2\r\n for i in range(3, n+1):\r\n dp[i]= 2*dp[i-1] + dp[1]\r\n for f in all_factors(i):\r\n if f == 1 or f == i:continue\r\n dp[i] += dp[i//f] - dp[(i//f) - 1]\r\n dp[i] %= m\r\n print(dp[-1])"}, {"source_code": "n, M = map(int, input().split())\nfactors = [[] for _ in range(n+1)]\nfor d in range(2, n // 2+1):\n for q in range(2*d, n+1, d):\n factors[q].append(d)\nans = [0, 1]\nd = [0, 0]\np = 1\nfor i in range(2, n+1):\n d.append((d[-1] + 1 + sum(ans[i//x] - ans[i//x-1] for x in factors[i])) % M)\n ans.append((p + d[-1]) % M)\n p = (p + ans[-1]) % M\nprint(ans[-1])"}, {"source_code": "def solve(n, mod):\r\n a = [0]*(n-1) + [1]\r\n b = [0]*(n-1) + [1]\r\n for i in range(n-2, -1, -1):\r\n a[i], m = b[i+1], 2\r\n s = (i+1) * m - 1\r\n while s < n:\r\n e = min((i+2) * m - 2, n - 1)\r\n a[i] = (a[i] + b[s] - b[e] + a[e]) % mod\r\n m += 1\r\n s = (i+1) * m - 1\r\n b[i] = (b[i+1] + a[i]) % mod\r\n return a[0]\r\n\r\nn, m = map(int, input().split())\r\nprint(solve(n, m))"}, {"source_code": "from __future__ import division, print_function\r\n\r\nimport os,sys\r\nfrom io import BytesIO, IOBase\r\n\r\nif sys.version_info[0] < 3:\r\n from __builtin__ import xrange as range\r\n from future_builtins import ascii, filter, hex, map, oct, zip\r\n\r\nfrom bisect import bisect_left as lower_bound, bisect_right as upper_bound \r\ndef so(): return int(input())\r\ndef st(): return input()\r\ndef mj(): return map(int,input().strip().split(\" \"))\r\ndef msj(): return map(str,input().strip().split(\" \"))\r\ndef le(): return list(map(int,input().split()))\r\ndef lebe():return list(map(int, input()))\r\n\r\ndef dmain():\r\n sys.setrecursionlimit(1000000)\r\n threading.stack_size(1024000)\r\n thread = threading.Thread(target=main)\r\n thread.start()\r\ndef joro(L):\r\n return(''.join(map(str, L)))\r\n\r\n\r\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\r\n\r\n\r\ndef isprime(n):\r\n for i in range(2,int(n**0.5)+1):\r\n if n%i==0:\r\n return False\r\n return True\r\ndef npr(n, r):\r\n return factorial(n) // factorial(n - r) if n >= r else 0\r\n \r\n \r\ndef ncr(n, r):\r\n return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0\r\n \r\n \r\ndef lower_bound(li, num):\r\n answer = -1\r\n start = 0\r\n end = len(li) - 1\r\n \r\n while (start <= end):\r\n middle = (end + start) // 2\r\n if li[middle] >= num:\r\n answer = middle\r\n end = middle - 1\r\n else:\r\n start = middle + 1\r\n return answer # min index where x is not less than num\r\n \r\n \r\ndef upper_bound(li, num):\r\n answer = -1\r\n start = 0\r\n end = len(li) - 1\r\n \r\n while (start <= end):\r\n middle = (end + start) // 2\r\n \r\n if li[middle] <= num:\r\n answer = middle\r\n start = middle + 1\r\n \r\n else:\r\n end = middle - 1\r\n return answer # max index where x is not greater than num\r\n \r\n \r\ndef abs(x):\r\n return x if x >= 0 else -x\r\n \r\n \r\ndef binary_search(li, val, lb, ub):\r\n # print(lb, ub, li)\r\n ans = -1\r\n while (lb <= ub):\r\n mid = (lb + ub) // 2\r\n # print('mid is',mid, li[mid])\r\n if li[mid] > val:\r\n ub = mid - 1\r\n elif val > li[mid]:\r\n lb = mid + 1\r\n else:\r\n ans = mid # return index\r\n break\r\n return ans\r\n \r\n \r\ndef kadane(x): # maximum sum contiguous subarray\r\n sum_so_far = 0\r\n current_sum = 0\r\n for i in x:\r\n current_sum += i\r\n if current_sum < 0:\r\n current_sum = 0\r\n else:\r\n sum_so_far = max(sum_so_far, current_sum)\r\n return sum_so_far\r\n \r\n \r\ndef pref(li):\r\n pref_sum = [0]\r\n for i in li:\r\n pref_sum.append(pref_sum[-1] + i)\r\n return pref_sum\r\n \r\n \r\ndef SieveOfEratosthenes(n):\r\n prime = [True for i in range(n + 1)]\r\n p = 2\r\n li = []\r\n while (p * p <= n):\r\n if (prime[p] == True):\r\n for i in range(p * p, n + 1, p):\r\n prime[i] = False\r\n p += 1\r\n \r\n for p in range(2, len(prime)):\r\n if prime[p]:\r\n li.append(p)\r\n return li\r\n \r\n \r\ndef primefactors(n):\r\n factors = []\r\n while (n % 2 == 0):\r\n factors.append(2)\r\n n //= 2\r\n for i in range(3, int(sqrt(n)) + 1, 2): # only odd factors left\r\n while n % i == 0:\r\n factors.append(i)\r\n n //= i\r\n if n > 2: # incase of prime\r\n factors.append(n)\r\n return factors\r\n \r\n \r\ndef read():\r\n sys.stdin = open('input.txt', 'r') \r\n sys.stdout = open('output.txt', 'w') \r\ndef tr(n):\r\n return n*(n+1)//2\r\n\r\ndef fb(k,L):\r\n if(k==L[k]):\r\n return k\r\n if(L[k]==fb(L[k],L)):\r\n return L[k]\r\ndef usa(a,b,Y,Z):\r\n a=fb(a,Y)\r\n b=fb(b,Y)\r\n if(a!=b):\r\n if(Z[a]<Z[b]):\r\n a,b=b,a\r\n Y[b]=a\r\n Z[a]+=Z[b]\r\n\r\n\r\n \r\ndef iu():\r\n import sys\r\n input =sys.stdin.buffer.readline\r\n import math as my\r\n p,q=mj()\r\n if(p==1):\r\n print(1)\r\n return\r\n L=[]\r\n P=[]\r\n for i in range(p+1):\r\n L.append(1)\r\n P.append(0)\r\n P[1]=1\r\n P[2]=2\r\n j=4\r\n while(j<1+p):\r\n L[j]=L[2]+L[j]\r\n j=2+j\r\n i=3\r\n while(i<1+p):\r\n L[i]=P[i-1]+L[i]\r\n L[i]%=q\r\n j=i*2\r\n while(j<1+p):\r\n L[j]=L[i]+L[j]\r\n L[j]%=q\r\n j+=i\r\n P[i]=(P[i-1]+L[i])%q\r\n i+=1\r\n print(P[p])\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\ndef main():\r\n for i in range(1):\r\n iu()\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n# region fastio\r\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\ndef print(*args, **kwargs):\r\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n at_start = True\r\n for x in args:\r\n if not at_start:\r\n file.write(sep)\r\n file.write(str(x))\r\n at_start = False\r\n file.write(kwargs.pop(\"end\", \"\\n\"))\r\n if kwargs.pop(\"flush\", False):\r\n file.flush()\r\n\r\n\r\nif sys.version_info[0] < 3:\r\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# endregion\r\n\r\n\r\nif __name__ == \"__main__\":\r\n #read()\r\n main()\r\n #dmain()\r\n\r\n# Comment Read()"}, {"source_code": "import sys\nimport collections\n\ninfile = sys.stdin.buffer\ndef gs() : return infile.readline().rstrip()\ndef gi() : return int(gs())\ndef gss() : return gs().split()\ndef gis() : return [int(x) for x in gss()]\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 12\nN = 10 ** 5\n\n\n\ndef main(infn=\"\") :\n global infile\n infile = open(infn,\"r\") if infn else open(sys.argv[1],\"r\") if len(sys.argv) > 1 else sys.stdin\n ######################################################################\n n,m = gis()\n dp = [0 for _ in range(n+1)]\n dp[1] = 1\n h = [0 for _ in range(n+1)]\n cumul = 0\n prev = dp[1]\n \n for u in range(1, len(dp)):\n if u > 1:\n dp[u] += prev + dp[1]\n dp[u] %= m\n\n cumul += h[u]\n cumul %= m\n \n dp[u] += cumul\n dp[u] %= m\n \n prev += dp[u]\n prev %= m\n '''u = 7\n 14 + 0, 14 + 1, 14 + 2\n 7 7 8\n '''\n j = 2\n while( j * u < len(dp)):\n if j*u != 2:\n h[j*u] += dp[u]\n h[j*u] %= m\n if j*u + j< len(dp):\n h[j*u + j] -= dp[u]\n h[j*u + j] %= m\n j+=1\n print (dp[-1])\n\n ######################################################################\nif __name__ == '__main__' :\n main()"}, {"source_code": "n,m=map(int,input().split())\r\ndp=[0 for i in range(n+3)]\r\ndp2=[0 for i in range(n+3)]\r\ndp[n] =1\r\ndp2[n] =1\r\nfor i in range(n-1,0,-1):\r\n dp[i] =dp2[i+1] %m\r\n mul =2\r\n while i*mul <=n:\r\n dp[i] =(dp[i] % m+ dp2[i*mul] %m-dp2[min((i+1)*mul,n+1)] %m) %m\r\n mul +=1\r\n dp2[i] =(dp[i]%m +dp2[i+1]%m) %m\r\nprint(dp[1] % m)"}, {"source_code": "n, m = map(int, input().split())\r\nc = [0]*n + [1, 0]\r\nfor i in range(n-1, 0, -1):\r\n c[i] = 2*c[i+1] % m\r\n for j in range(2, n//i + 1):\r\n c[i] = (c[i] + c[i*j] - c[min(n+1, i*j + j)]) % m\r\n\r\nprint((c[1] - c[2]) % m)"}, {"source_code": "# ///////////////////////////////////////////////////////////////////////////\r\n# //////////////////// PYTHON IS THE BEST ////////////////////////\r\n# ///////////////////////////////////////////////////////////////////////////\r\n\r\nimport sys,os,io\r\nimport math \r\nfrom collections import defaultdict\r\n\r\nfrom io import BytesIO, IOBase\r\nfrom types import GeneratorType\r\nBUFSIZE = 8192\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\ndef ii():\r\n return int(input())\r\ndef li():\r\n return list(map(int,input().split()))\r\n# ///////////////////////////////////////////////////////////////////////////\r\n# //////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////\r\n# ///////////////////////////////////////////////////////////////////////////\r\nif(os.path.exists('input.txt')):\r\n sys.stdin = open(\"input.txt\",\"r\") ; sys.stdout = open(\"output.txt\",\"w\") \r\nelse:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nn,m = li()\r\ndif = [0]*(n+10)\r\ndp = [0]*(n+1)\r\ndp[1]=1\r\nsuf = 0\r\nfor i in range(1,n+1):\r\n dp[i]+=suf \r\n dif[i]+=dif[i-1]\r\n dp[i]+=dif[i]\r\n suf+=dp[i]\r\n dp[i]%=m\r\n suf%=m \r\n dif[i]%=m\r\n for j in range(2,n+1):\r\n if i*j>n:\r\n break \r\n low = i*j \r\n high = (i+1)*j-1\r\n dif[low]+=dp[i]\r\n dif[min(high,n)+1]-=dp[i]\r\nprint(dp[-1])\r\n\r\n\r\n \r\n"}, {"source_code": "# ------------------------template--------------------------#\r\nimport os\r\nimport sys\r\nimport math\r\nimport collections\r\nimport functools\r\nimport itertools\r\n\r\n# from fractions import *\r\nimport heapq\r\nimport bisect\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\ndef vsInput():\r\n sys.stdin = open(\"input.txt\", \"r\")\r\n sys.stdout = open(\"output.txt\", \"w\")\r\n\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nALPHA = \"abcde\"\r\nMOD = 10 ** 9 + 7\r\nEPS = 1e-6\r\n\r\n\r\ndef Ceil(a, b):\r\n return a // b + int(a % b > 0)\r\n\r\n\r\ndef INT():\r\n return int(input())\r\n\r\n\r\ndef STR():\r\n return input()\r\n\r\n\r\ndef INTS():\r\n return tuple(map(int, input().split()))\r\n\r\n\r\ndef ARRINT():\r\n return [int(i) for i in input().split()]\r\n\r\n\r\ndef ARRSTR():\r\n return [i for i in input().split()]\r\n\r\n\r\n# -------------------------code---------------------------#\r\n\r\n\r\nn, MOD = INTS()\r\n\r\ndp = [0] * (n + 2)\r\ndp[n] = 1\r\n\r\nfor i in range(n - 1, 0, -1):\r\n tmp = dp[i + 1]\r\n j = 2\r\n while i * j < n + 2:\r\n tmp += dp[i * j] - dp[min(n + 1, (i + 1) * j)]\r\n tmp %= MOD\r\n j += 1\r\n dp[i] = tmp + dp[i + 1]\r\n dp[i] %= MOD\r\n\r\nprint((dp[1] - dp[2]) % MOD)\r\n"}, {"source_code": "##import random\r\n##n = 10\r\n##u = list(range(1, n + 1))\r\n##random.shuffle(u)\r\n##print(*u)\r\n##while True:\r\n## x = int(input())\r\n## p = u[:x]\r\n## p.reverse()\r\n## u = p + u[x:]\r\n## print(*u)\r\n\r\nn, m = map(int, input().split())\r\nsumL = [0] * (n + 2)\r\nL = [0] * (n + 1)\r\nL[-1], sumL[-2] = 1, 1\r\nfor i in range(n - 1, 0, -1):\r\n L[i] = sumL[i + 1]\r\n j = 2\r\n while i * j <= n:\r\n L[i] += (sumL[i * j] - sumL[min(n, (i + 1) * j - 1) + 1])\r\n j += 1\r\n L[i] = L[i] % m\r\n sumL[i] = (sumL[i + 1] + L[i]) % m\r\nprint(L[1])\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, m = map(int, input().split())\r\ndp = [0] * (n + 2)\r\ndp[n] = 1\r\nfor i in range(n - 1, 0, -1):\r\n dpi = dp[i + 1]\r\n j = 2\r\n while i * j < n + 2:\r\n dpi += dp[i * j] - dp[min(n + 1, (i + 1) * j)]\r\n dpi %= m\r\n j += 1\r\n dp[i] = dpi + dp[i + 1]\r\n dp[i] %= m\r\nans = (dp[1] - dp[2]) % m\r\nprint(ans)"}, {"source_code": "from __future__ import division, print_function\r\nimport math\r\nimport sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n\tnewlines = 0\r\n\r\n\tdef __init__(self, file):\r\n\t\tself._fd = file.fileno()\r\n\t\tself.buffer = BytesIO()\r\n\t\tself.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n\t\tself.write = self.buffer.write if self.writable else None\r\n\r\n\tdef read(self):\r\n\t\twhile True:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tif not b:\r\n\t\t\t\tbreak\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines = 0\r\n\t\treturn self.buffer.read()\r\n\r\n\tdef readline(self):\r\n\t\twhile self.newlines == 0:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tself.newlines = b.count(b\"\\n\") + (not b)\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines -= 1\r\n\t\treturn self.buffer.readline()\r\n\r\n\tdef flush(self):\r\n\t\tif self.writable:\r\n\t\t\tos.write(self._fd, self.buffer.getvalue())\r\n\t\t\tself.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n\tdef __init__(self, file):\r\n\t\tself.buffer = FastIO(file)\r\n\t\tself.flush = self.buffer.flush\r\n\t\tself.writable = self.buffer.writable\r\n\t\tself.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n\t\tself.read = lambda: self.buffer.read().decode(\"ascii\")\r\n\t\tself.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\ndef print(*args, **kwargs):\r\n\t\"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n\tat_start = True\r\n\tfor x in args:\r\n\t\tif not at_start:\r\n\t\t\tfile.write(sep)\r\n\t\tfile.write(str(x))\r\n\t\tat_start = False\r\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\r\n\tif kwargs.pop(\"flush\", False):\r\n\t\tfile.flush()\r\n\r\n\r\nif sys.version_info[0] < 3:\r\n\tsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n\tsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input().strip()\r\n return(list(s[:len(s)]))\r\ndef invr():\r\n return(map(int,input().split()))\r\ndef Divisors(n) :\r\n i = 1\r\n fac=[]\r\n while i <= int(math.sqrt(n)):\r\n \r\n if (n % i == 0) :\r\n if (n // i == i) :\r\n fac.append(i)\r\n else :\r\n fac.append(i)\r\n fac.append(n//i)\r\n i = i + 1\r\n return fac\r\nn,maxn=invr()\r\ndp=[0 for i in range(n+1)]\r\ndp[1]=1\r\ndp[2]=2\r\nsm=3\r\nfor i in range(3,n+1):\r\n dp[i]=(2*dp[i-1])%maxn\r\n fac=Divisors(i)\r\n fac.sort()\r\n for j in fac:\r\n if j==i:continue\r\n dp[i]+=dp[j]-dp[j-1]\r\n dp[i]=dp[i]%maxn\r\nprint(dp[n]%maxn)\r\n# print(dp)"}, {"source_code": "import os, sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import log2, ceil, sqrt, gcd\r\nfrom _collections import deque\r\nimport heapq as hp\r\nfrom bisect import bisect_left, bisect_right\r\nfrom math import cos, sin\r\nfrom itertools import permutations\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nmod = 10**9+7\r\n\r\nn,m=map(int,input().split())\r\ndp=[0]*(n+1)\r\na=[0]*(n+1)\r\ndp[n]=1\r\na[n]=1\r\nfor i in range(n-1,0,-1):\r\n dp[i]=a[i+1]\r\n z=2\r\n while i*z<=n:\r\n dp[i]+=a[i*z]\r\n if z*(i+1)<=n:\r\n dp[i]-=a[z*(i+1)]\r\n z+=1\r\n dp[i]%=m\r\n dp[i]%=m\r\n a[i]=a[i+1]+dp[i]\r\n a[i]%=m\r\nprint(dp[1])\r\n# print(dp,a)"}, {"source_code": "n, M = map(int, input().split(' '))\r\n\r\nD = [[] for _ in range(n + 1)]\r\nfor d in range(2, n + 1):\r\n for dst in range(2*d, n + 1, d):\r\n D[dst].append(d)\r\n\r\n\r\nF = [None] * (n + 1)\r\nF[1] = 1\r\nF[2] = 2\r\nfor x in range(3, n + 1):\r\n F[x] = (2 * F[x - 1] + F[x//(x - 1)]) % M\r\n S = 0\r\n for d in D[x]:\r\n if 2 <= d <= x - 2:\r\n S += F[x//d] - F[(x - 1)//d]\r\n F[x] = (F[x] + S) % M\r\n\r\nprint(F[n] % M)"}, {"source_code": "# template begins\r\n#####################################\r\nfrom io import BytesIO, IOBase\r\nimport sys\r\nimport math\r\nimport os\r\nimport heapq\r\nfrom collections import defaultdict, deque\r\nfrom math import ceil\r\nfrom bisect import bisect_left, bisect_left\r\nfrom time import perf_counter\r\n\r\n\r\n# region fastio\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\r\ndef mint(): return map(int, input().split())\r\ndef mfloat(): return map(float, input().split())\r\ndef intin(): return int(input())\r\n\r\n\r\n#####################################\r\n# template ends\r\n# Use the recursion snippet if heavy recursion is needed (depth>1000)\r\n# If constraints are tight, use 1d arrays instead of 2d, like g[i*m+j] instead of g[i][j]\r\ndef solve():\r\n n, mod = map(int, input().split())\r\n dp = [0]*(n+1)\r\n dp[-1] = 1\r\n # brute force\r\n # for i in range(n, 1, -1):\r\n # for j in range(1, i):\r\n # dp[j] = (dp[j] + dp[i]) % mod\r\n # for j in range(2, i+1):\r\n # dp[i//j] = (dp[i] + dp[i//j]) % mod\r\n # print(dp[1])\r\n \"\"\"\r\n 2^(n-2) ways by addition alone? yes\r\n \"\"\"\r\n # for i in range(n-1, 0, -1):\r\n # by_addition = pow(2, n-i-1, mod)\r\n # print(\"power =\", pow(2, n-2, mod))\r\n current = 1\r\n suffix_sum = [0]*(n+1)\r\n suffix_sum[-1] = 1\r\n for i in range(n-1, 0, -1):\r\n dp[i] = suffix_sum[i+1]\r\n # for j in range(2*i, n+1, i):\r\n # dp[i] = (dp[i] + suffix_sum[j] -\r\n # (suffix_sum[j+j] if j+j < n else 0)) # % mod\r\n # break\r\n for j in range(2, n+1):\r\n if i*j > n:\r\n break\r\n dp[i] += suffix_sum[i*j] - (suffix_sum[i*j+j] if i*j+j <= n else 0)\r\n dp[i] %= mod\r\n suffix_sum[i] = (suffix_sum[i+1] + dp[i]) % mod\r\n # print(dp)\r\n # print(suffix_sum)\r\n print(dp[1] % mod)\r\n\r\n\r\ndef main():\r\n t = 1\r\n # t = int(input())\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n start_time = perf_counter()\r\n main()\r\n print(perf_counter()-start_time, file=sys.stderr)\r\n"}, {"source_code": "class BIT:\r\n def __init__(self,n:int):\r\n q = 1 << (n - 1).bit_length() + 1\r\n self.ceiling = q\r\n self.bittree = [0]*(q + 1)\r\n\r\n def updatebit(self, v:int, n:int):\r\n v = v * 2 - 1\r\n self.bittree[v] = n\r\n while v < self.ceiling:\r\n s = int(v)\r\n count = 0\r\n while not s & 1:\r\n s >>= 1\r\n count += 1\r\n v += 2 ** count\r\n self.bittree[v] += n\r\n \r\n def getIntervalSum(self,l:int,r:int):\r\n #[l,r]\r\n l = l * 2 - 2\r\n r = r * 2 - 1\r\n ret = 0\r\n while r > 0:\r\n ret += self.bittree[r]\r\n s = int(r)\r\n count = 0\r\n while not s & 1:\r\n s >>= 1\r\n count += 1\r\n r -= 2 ** count\r\n while l > 0:\r\n ret -= self.bittree[l]\r\n s = int(l)\r\n count = 0\r\n while not s & 1:\r\n s >>= 1\r\n count += 1\r\n l -= 2 ** count\r\n return ret\r\n\r\n\r\n\r\nn, mod = map(int,input().split())\r\n\r\ndp = [0 for _ in range(n + 1)]\r\n\r\nbittree = BIT(n)\r\n\r\ndp[n] = 1\r\nbittree.updatebit(n,1)\r\nsum = 1\r\n\r\n\r\nfor i in range(n-1,0,-1):\r\n for j in range(2,n+1):\r\n if i * j <= n:\r\n dp[i] = (dp[i] + bittree.getIntervalSum(i*j,min((i+1)*j - 1,n))) % mod\r\n else:\r\n break\r\n dp[i] = (dp[i] + sum) % mod\r\n bittree.updatebit(i,dp[i])\r\n sum = (sum + dp[i]) % mod\r\nprint(dp[1])\r\n"}, {"source_code": "N, MOD = map(int, input().split())\r\nDP = [0] * N\r\nDP[0] = 1\r\nCum = [0] * (N + 1)\r\nCum[1] = 1\r\nfor i1 in range(1, N):\r\n i2 = N - i1\r\n Value = Cum[i1]\r\n for j in range(2, N + 1):\r\n if i2 * j > N: break\r\n Value += Cum[N - i2 * j + 1] - Cum[max(0, N - i2 * j - j + 1)]\r\n Value %= MOD\r\n Cum[i1 + 1] += Cum[i1] + Value\r\n Cum[i1 + 1] %= MOD\r\n DP[i1] = Value\r\nprint(DP[-1])"}, {"source_code": "primes = []\r\nfor p in range(2, 6000):\r\n is_prime = True\r\n for p2 in primes:\r\n if p2*p2 > p:\r\n break\r\n if p % p2==0:\r\n is_prime = False\r\n break\r\n if is_prime:\r\n primes.append(p)\r\n \r\ndef factor(n):\r\n d = {}\r\n for p in primes:\r\n if p*p > n:\r\n break\r\n if n % p==0:\r\n c = 0\r\n while n % p==0:\r\n n = n//p\r\n c+=1\r\n d[p] = c\r\n if n > 1:\r\n d[n] = 1\r\n return d\r\n\r\ndef factors(n):\r\n d = factor(n)\r\n answer = [1]\r\n for p in d:\r\n a2 = []\r\n for x in answer:\r\n for i in range(d[p]+1):\r\n a2.append(x*p**i)\r\n answer = a2\r\n return answer\r\n \r\n\r\ndef process(n, m):\r\n f_dict = {0: 0, 1: 1, 2: 2}\r\n for i in range(3, n+1):\r\n f_dict[i] = 2*f_dict[i-1]\r\n for x in factors(i):\r\n if 2 <= x <= i:\r\n f_dict[i] += f_dict[(i//x)]-f_dict[(i-1)//x]\r\n f_dict[i] = f_dict[i] % m\r\n f_dict[i] = f_dict[i] % m\r\n return f_dict[n]\r\n\r\nn, m = [int(x) for x in input().split()]\r\nprint(process(n, m))"}, {"source_code": "import os, sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import log2, ceil, sqrt, gcd\r\nfrom _collections import deque\r\nimport heapq as hp\r\nfrom bisect import bisect_left, bisect_right\r\nfrom math import cos, sin\r\nfrom itertools import permutations\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nmod = 10**9+7\r\n\r\nn,m=map(int,input().split())\r\ndp=[0]*(n+1)\r\na=[0]*(n+1)\r\ndp[n]=1\r\na[n]=1\r\nfor i in range(n-1,0,-1):\r\n dp[i]=a[i+1]\r\n z=2\r\n while i*z<=n:\r\n dp[i]+=a[i*z]\r\n if z*(i+1)<=n:\r\n dp[i]-=a[z*(i+1)]\r\n z+=1\r\n dp[i]%=m\r\n dp[i]%=m\r\n a[i]=a[i+1]+dp[i]\r\n a[i]%=m\r\nprint(dp[1])\r\n# print(dp,a)"}, {"source_code": "import sys,math\r\ninput=sys.stdin.readline\r\nINF=int(1e9)\r\n\r\ndef find_all_divisors_of_a_number(x):\r\n result = []\r\n for i in range(2, int(math.sqrt(x)) + 1):\r\n if x % i == 0:\r\n result.append(i)\r\n if i * i != x:\r\n result.append(x // i)\r\n return result\r\n\r\ndef solve():\r\n n,m=map(int,input().split())\r\n dp=[0]*(n+1)\r\n dp[1]=1\r\n dp[2]=2\r\n for i in range(3,n+1):\r\n dp[i]=2*dp[i-1]+1\r\n data=find_all_divisors_of_a_number(i)\r\n for j in data:\r\n dp[i]+=dp[j]-dp[j-1]\r\n dp[i]%=m\r\n\r\n print(dp[n])\r\n\r\nt=1\r\n\r\nwhile t:\r\n t-=1\r\n solve()\r\n"}, {"source_code": "\nimport sys\ninput=sys.stdin.readline #\u6587\u5b57\u5217\u5165\u529b\u306f\u3059\u308b\u306a\uff01\uff01\n\nn,m=map(int,input().split())\nmod=m\ndp=[0]*(n+3)\ndp[n]=1\nsdp=[0]*(n+3)\nsdp[n]=1\n\nfor x in range(n-1,0,-1):\n dp[x]+=sdp[x+1]\n dp[x]%=mod\n z=2\n while x*z<=n:\n l=x*z\n r=(x+1)*z-1\n if r>n:r=n\n dp[x]+=sdp[l]-sdp[r+1]\n dp[x]%=mod\n z+=1\n sdp[x]=sdp[x+1]+dp[x]\n sdp[x]%=mod\n\nprint(dp[1]%mod)\n\n\n\n\n"}, {"source_code": "inp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, su = [0, 1], 1\r\n\r\nfor i in range(2, n + 1):\r\n sq = int(i ** .5) + 1\r\n mem.append(su)\r\n\r\n for f in range(2, sq):\r\n mem[-1] = add(mem[-1], mem[i // f])\r\n\r\n be = i\r\n for j in range(1, i // sq + 1):\r\n nxt = i // (j + 1)\r\n mem[-1] = add(mem[-1], mult(be - nxt, mem[j]))\r\n be = nxt\r\n\r\n su = add(su, mem[-1])\r\nprint(mem[-1])\r\n"}, {"source_code": "inp = lambda dtype: [dtype(x) for x in input().split()]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nadd = lambda a, b: (a + b) % mod\r\nmult = lambda a, b: (a * b) % mod\r\n\r\nn, mod = inp(int)\r\nmem, su = [0, 1], 1\r\n\r\nfor i in range(2, n + 1):\r\n sq ,cur= int(i ** .5) + 1,su\r\n\r\n for f in range(2, sq):\r\n cur = add(cur, mem[i // f])\r\n\r\n be = i\r\n for j in range(1, i // sq + 1):\r\n nxt = i // (j + 1)\r\n cur = add(cur, mult(be - nxt, mem[j]))\r\n be = nxt\r\n\r\n su = add(su, cur)\r\n mem.append(cur)\r\nprint(mem[-1])\r\n"}, {"source_code": "import os,sys\r\nfrom random import randint\r\nfrom io import BytesIO, IOBase\r\n\r\nfrom collections import defaultdict,deque,Counter\r\nfrom bisect import bisect_left,bisect_right\r\nfrom heapq import heappush,heappop\r\nfrom functools import lru_cache\r\nfrom itertools import accumulate\r\nimport math\r\n\r\n# Fast IO Region\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n# b = sorted(a)\r\n# ans = 0\r\n# op = 0\r\n# while a != b:\r\n# if op == 0:\r\n# for i in range(0, n, 2):\r\n# if i + 1 < n and a[i] > a[i + 1]:\r\n# a[i], a[i + 1] = a[i + 1], a[i]\r\n# else:\r\n# for i in range(1, n, 2):\r\n# if i + 1 < n and a[i] > a[i + 1]:\r\n# a[i], a[i + 1] = a[i + 1], a[i]\r\n# op ^= 1\r\n# ans += 1\r\n# print(ans)\r\n\r\n # n//2+1 r n//2 s xxxxx ....\r\n # n//2+1 s n//2 r ..... xxxx\r\n # a=3 b=5 [1,7]\r\n # 1=4,b=4 [0,8]\r\n # [n//2-a,n//2+a]\r\n # a=5,b=4 [0,9]\r\n # a=3,b=6 [1,8]\r\n # a=2,b=7 [2,7]\r\n # a=1,b=8 [3,6]\r\n # a=0,b=9 [4,5]\r\n # [n//2-a,n//2+1+a]\r\n\r\n# for _ in range(int(input())):\r\n# a, b = list(map(int, input().split()))\r\n# if a > b: a, b = b, a\r\n# n = a + b\r\n# if n % 2 == 0:\r\n# ans = []\r\n# for i in range(n // 2 - a, n // 2 + a + 1, 2):\r\n# ans.append(i)\r\n# else:\r\n# ans = []\r\n# for i in range(n // 2 - a, n // 2 + a + 2):\r\n# ans.append(i)\r\n# print(len(ans))\r\n# print(*ans)\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = [list(map(int, input().split()))[1:] for _ in range(n)]\r\n# need = [0] * n\r\n# for i in range(n):\r\n# needi = 0\r\n# cur = 0\r\n# for j in a[i]:\r\n# if cur <= j:\r\n# needi += j - cur + 1\r\n# cur = j + 1\r\n# cur += 1\r\n# need[i] = needi\r\n\r\n# id = [i for i in range(n)]\r\n# id.sort(key=lambda x:need[x])\r\n# cur = ans = need[id[0]]\r\n# cur += len(a[id[0]])\r\n# for i in range(1, n):\r\n# if cur < need[id[i]]:\r\n# ans += need[id[i]] - cur\r\n# cur = need[id[i]]\r\n# cur += len(a[id[i]])\r\n# print(ans)\r\n\r\n# x -> x//z = y dp[y]+=dp[y*z] +...+ dp[y*z+z-1]\r\n\r\nn, mod = list(map(int, input().split()))\r\n\r\ndp = [0] * (n + 1)\r\nsdp = [0] * (n + 2)\r\ndp[n] = sdp[n] = 1\r\nfor i in range(n - 1, 0, -1):\r\n dp[i] = sdp[i + 1]\r\n for j in range(2, 10000000000):\r\n if i * j > n:\r\n break\r\n dp[i] += sdp[i * j] - sdp[min(n + 1, i * j + j)]\r\n dp[i] %= mod\r\n sdp[i] = (sdp[i + 1] + dp[i]) % mod\r\n# print(dp)\r\nprint(dp[1])\r\n \r\n\r\n\r\n\r\n\r\n "}, {"source_code": "n,m=map(int,input().split())\r\ndp=[0]*(n+10)\r\na=[0]*(n+10)\r\ndp[n]=1\r\na[n]=1\r\n\r\nfor i in range(n-1,0,-1):\r\n dp[i]=a[i+1]\r\n z=2\r\n while i*z<=n:\r\n dp[i]+=a[i*z]\r\n if z*(i+1)<=n:\r\n dp[i]-=a[z*(i+1)]\r\n z+=1\r\n dp[i]%=m\r\n dp[i]%=m\r\n a[i]=a[i+1]+dp[i]\r\n a[i]%=m\r\n\r\nprint(dp[1])"}, {"source_code": "n, m = map(int, input().split())\r\nc = [0]*n + [1] + [0]*n\r\nfor i in range(n-1, 0, -1):\r\n c[i] = 2*c[i+1] % m\r\n for j in range(2, n//i + 1):\r\n c[i] = (c[i] + c[i*j] - c[(i+1)*j]) % m\r\n \r\nprint((c[1] - c[2]) % m)"}, {"source_code": "n, m = map(int, input().split())\r\ndp = [0] * (n + 2)\r\ns = [0] * (n + 2)\r\ndp[n] = 1\r\ns[n] = 1\r\nfor i in range(n-1, 0, -1):\r\n dp[i] = s[i+1]\r\n for j in range(2, n // i + 1):\r\n # add sum from i*j to i*(j+1) - 1\r\n # from cells divided by j\r\n h = min(n + 1, (i + 1) * j)\r\n dp[i] = (dp[i] + s[i * j] - s[h]) % m\r\n # print(\" i=\",i,\"j=\", j, \"h=\",h)\r\n s[i] = (s[i+1] + dp[i]) % m\r\n # print (\"i=\", i)\r\n # print(\"dp:\", * dp)\r\n # print(\"s:\", *s)\r\nprint(dp[1])\r\n\r\n"}, {"source_code": "n,m = map(int,input().split())\r\nsumL = [0]*(n+2)\r\nL = [0]*(n+1)\r\nL[-1],sumL[-2] = 1,1\r\nfor i in range(n-1,0,-1):\r\n L[i] = sumL[i+1]\r\n j = 2\r\n while i*j<=n:\r\n L[i]+=(sumL[i*j]-sumL[min(n,(i+1)*j-1)+1])\r\n j+=1\r\n L[i] = L[i]%m\r\n sumL[i] = (sumL[i+1]+L[i])%m\r\nprint(L[1])"}, {"source_code": "n, m = map(int, input().split());sumL = [0] * (n + 2);L = [0] * (n + 1);L[-1], sumL[-2] = 1, 1\r\nfor i in range(n - 1, 0, -1):\r\n L[i] = sumL[i + 1];j = 2\r\n while i * j <= n:L[i] += (sumL[i * j] - sumL[min(n, (i + 1) * j - 1) + 1]);j += 1\r\n L[i] = L[i] % m;sumL[i] = (sumL[i + 1] + L[i]) % m\r\nprint(L[1])"}, {"source_code": "n, m = map(int, input().split())\r\ndp = [0] * (n + 2)\r\ns = [0] * (n + 2)\r\ndp[n] = 1\r\ns[n] = 1\r\nfor i in range(n-1, 0, -1):\r\n dp[i] = s[i+1]\r\n for j in range(2, n // i + 1):\r\n # add sum from i*j to i*(j+1) - 1\r\n # from cells divided by j\r\n h = min(n + 1, (i + 1) * j)\r\n dp[i] = (dp[i] + s[i * j] - s[h]) % m\r\n # print(\" i=\",i,\"j=\", j, \"h=\",h)\r\n s[i] = (s[i+1] + dp[i]) % m\r\n # print (\"i=\", i)\r\n # print(\"dp:\", * dp)\r\n # print(\"s:\", *s)\r\nprint(dp[1])\r\n\r\n"}, {"source_code": "n,m = map(int,input().split())\r\nsumL = [0]*(n+2)\r\nL = [0]*(n+1)\r\nL[-1],sumL[-2] = 1,1\r\nfor i in range(n-1,0,-1):\r\n L[i] = sumL[i+1]\r\n j = 2\r\n while i*j<=n:\r\n L[i]+=(sumL[i*j]-sumL[min(n,(i+1)*j-1)+1])\r\n j+=1\r\n L[i] = L[i]%m\r\n sumL[i] = (sumL[i+1]+L[i])%m\r\nprint(L[1])\r\n"}, {"source_code": "from sys import stdin\r\nraw_input = lambda: stdin.readline().rstrip()\r\ninput = lambda: int(raw_input())\r\nI=lambda: map(int, raw_input().split())\r\nn,m = I()\r\nlst = [0, 1]\r\nsuffix = [0, 1]\r\nc = 1\r\nfor i in xrange(n-1, 0, -1):\r\n\tq = 0\r\n\tj = 2\r\n\tw = i*j\r\n\twhile w<=n:\r\n\t\tq = (q+suffix[n-w+1]-suffix[max(0, n-w-j+1)])%m\r\n\t\tj += 1\r\n\t\tw = i*j\r\n\tq = (c+q)%m\r\n\tc = (q+c)%m\r\n\tlst.append(q)\r\n\tsuffix.append(c)\r\nprint lst[n]\r\n# print lst\r\n# print suffix"}, {"source_code": "from sys import stdin\r\nfrom math import sqrt\r\n# raw_input = input\r\n# xrange = range\r\nraw_input = lambda: stdin.readline().rstrip()\r\ninput = lambda: int(raw_input())\r\nI=lambda: map(int, raw_input().split())\r\nn,m = I()\r\ndp = [0]*(n+1)\r\ndp[1] = 1\r\ns = 1\r\nfor x in xrange(2, n+1):\r\n\tw = 0\r\n\tq = int(sqrt(x))\r\n\tq1 = q+(0 if q**2==x else 1)\r\n\tq2 = q1-1\r\n\tfor j in xrange(2, q1): #j<sqrt(x)\r\n\t\tw += dp[x//j]\r\n\tw = w%m\r\n\tfor c in xrange(1, q+1):\r\n\t\ta1 = x//(c+1)\r\n\t\ta2 = x//c\r\n\t\tif a1>q2:\r\n\t\t\tw += dp[c]*(a2-a1)\r\n\t\telse:\r\n\t\t\tw += dp[c]*(a2-q2)\r\n\tdp[x] = (s + w)%m\r\n\ts = (s+dp[x])%m\r\nprint(dp[n])"}, {"source_code": "from sys import stdin\r\nfrom math import sqrt\r\n# raw_input = input\r\n# xrange = range\r\nraw_input = lambda: stdin.readline().rstrip()\r\ninput = lambda: int(raw_input())\r\nI=lambda: map(int, raw_input().split())\r\nn,m = I()\r\ndp = [0]*(n+1)\r\ndp[1] = 1\r\ns = 1\r\nfor x in xrange(2, n+1):\r\n\tw = 0\r\n\tq = int(sqrt(x))\r\n\tq1 = q+(0 if q**2==x else 1)\r\n\tq2 = q1-1\r\n\tfor j in xrange(2, q1): #j<sqrt(x)\r\n\t\tw = w+dp[x//j]\r\n\tw = w%m\r\n\tfor c in xrange(1, q+1):\r\n\t\ta1 = x//(c+1)\r\n\t\ta2 = x//c\r\n\t\tw = w+dp[c]*(a2-max(a1, q2))\r\n\tdp[x] = (s + w)%m\r\n\ts = (s+dp[x])%m\r\nprint(dp[n])"}, {"source_code": "import sys\ntesting = len(sys.argv) == 4 and sys.argv[3] == \"myTest\"\ninteractive = False\nif testing:\n cmd = sys.stdout\n from time import time\n start_time = int(round(time() * 1000)) \n readAll = open(sys.argv[1], 'r').read\n sys.stdout = open(sys.argv[2], 'w')\nelse:\n readAll = sys.stdin.read\n\n# ############ ---- I/O Functions ---- ############\n\nclass InputData:\n def __init__(self):\n self.lines = readAll().split('\\n')\n self.n = len(self.lines)\n self.ii = -1\n def input(self):\n self.ii += 1\n assert self.ii < self.n\n return self.lines[self.ii]\n\nflush = sys.stdout.flush\nif interactive and not testing:\n input = sys.stdin.readline\nelse:\n inputData = InputData()\n input = inputData.input\n\ndef intin():\n return(int(input()))\ndef intlin():\n return(list(map(int,input().split())))\ndef chrin():\n return(list(input()))\ndef strin():\n return input()\ndef lout(l, sep=\"\\n\", toStr=True):\n print(sep.join(map(str, l) if toStr else l))\ndef dout(*args, **kargs):\n if not testing: return\n if args: print(args[0] if len(args)==1 else args)\n if kargs: print([(k,v) for k,v in kargs.items()])\ndef ask(q):\n sys.stdout.write(str(q)+'\\n')\n flush()\n return intin()\n \n# ############ ---- I/O Functions ---- ############\n\n# from math import ceil\n# from collections import defaultdict as ddict, Counter\n# from heapq import *\n# from Queue import Queue\n# for i in xrange(1,42):\n# dout(i, 42/i, 42/(i+1))\ndef main():\n n,m = intlin()\n dp = [0]*(n+1)\n dp[1] = 1\n summ = 1\n for x in xrange(2,n+1):\n i = 1\n y = int(x**0.5)\n while i < y:\n dp[x] += (dp[i]*(x/i-x/(i+1)))\n i += 1\n dp[x] %= m\n k = x/i\n while k > 1:\n dp[x] += dp[x/k]\n k -= 1\n dp[x] = (dp[x]+summ)%m\n summ += dp[x]\n return dp[n]%m\n\nanss = []\nanss.append(main())\n # anss.append(\"YES\" if main() else \"NO\")\nlout(anss)\n\nif testing:\n sys.stdout = cmd\n print(int(round(time() * 1000)) - start_time)"}, {"source_code": "import sys\ntesting = len(sys.argv) == 4 and sys.argv[3] == \"myTest\"\ninteractive = False\nif testing:\n cmd = sys.stdout\n from time import time\n start_time = int(round(time() * 1000)) \n readAll = open(sys.argv[1], 'r').read\n sys.stdout = open(sys.argv[2], 'w')\nelse:\n readAll = sys.stdin.read\n\n# ############ ---- I/O Functions ---- ############\n\nclass InputData:\n def __init__(self):\n self.lines = readAll().split('\\n')\n self.n = len(self.lines)\n self.ii = -1\n def input(self):\n self.ii += 1\n assert self.ii < self.n\n return self.lines[self.ii]\n\nflush = sys.stdout.flush\nif interactive and not testing:\n input = sys.stdin.readline\nelse:\n inputData = InputData()\n input = inputData.input\n\ndef intin():\n return(int(input()))\ndef intlin():\n return(list(map(int,input().split())))\ndef chrin():\n return(list(input()))\ndef strin():\n return input()\ndef lout(l, sep=\"\\n\", toStr=True):\n print(sep.join(map(str, l) if toStr else l))\ndef dout(*args, **kargs):\n if not testing: return\n if args: print(args[0] if len(args)==1 else args)\n if kargs: print([(k,v) for k,v in kargs.items()])\ndef ask(q):\n sys.stdout.write(str(q)+'\\n')\n flush()\n return intin()\n \n# ############ ---- I/O Functions ---- ############\n\n# from math import ceil\n# from collections import defaultdict as ddict, Counter\n# from heapq import *\n# from Queue import Queue\n# for i in xrange(1,42):\n# dout(i, 42/i, 42/(i+1))\ndef main():\n n,m = intlin()\n dp = [0]*(n+1)\n dp[1] = 1\n summ = 1\n for x in xrange(2,n+1):\n i = 1\n y = int(x**0.5)\n while i < y:\n dp[x] += (dp[i]*(x/i-x/(i+1)))\n i += 1\n k = x/i\n while k > 1:\n dp[x] += dp[x/k]\n k -= 1\n dp[x] = (dp[x]+summ)%m\n summ += dp[x]\n return dp[n]%m\n\nanss = []\nanss.append(main())\n # anss.append(\"YES\" if main() else \"NO\")\nlout(anss)\n\nif testing:\n sys.stdout = cmd\n print(int(round(time() * 1000)) - start_time)"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\nclass LazySegmentTree:\n def __init__(self, data, default=0, func=max, mod=-1):\n \"\"\"initialize the lazy segment tree with data\"\"\"\n self.m = mod\n\n self._default = default\n self._func = func\n\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n self._lazy = [0] * (2 * _size)\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __len__(self):\n return self._len\n\n def _push(self, idx):\n \"\"\"push query on idx to its children\"\"\"\n # Let the children know of the queries\n q, self._lazy[idx] = self._lazy[idx], 0\n\n self._lazy[2 * idx] = (self._lazy[2 * idx] + q) % self.m\n self._lazy[2 * idx + 1] = (self._lazy[2 * idx + 1] + q) % self.m\n self.data[2 * idx] = (self.data[2 * idx] + q) % self.m\n self.data[2 * idx + 1] = (self.data[2 * idx + 1] + q) % self.m\n\n def _update(self, idx):\n \"\"\"updates the node idx to know of all queries applied to it via its ancestors\"\"\"\n for i in reversed(range(1, idx.bit_length())):\n self._push(idx >> i)\n\n def _build(self, idx):\n \"\"\"make the changes to idx be known to its ancestors\"\"\"\n idx >>= 1\n while idx:\n self.data[idx] = (self._func(self.data[2 * idx], self.data[2 * idx + 1]) + self._lazy[idx]) % self.m\n idx >>= 1\n\n def add(self, start, stop, value):\n \"\"\"lazily add value to [start, stop)\"\"\"\n start = start_copy = start + self._size\n stop = stop_copy = stop + self._size\n while start < stop:\n if start & 1:\n self._lazy[start] = (self._lazy[start] + value) % self.m\n self.data[start] = (self.data[start] + value) % self.m\n start += 1\n if stop & 1:\n stop -= 1\n self._lazy[stop] = (self._lazy[stop] + value) % self.m\n self.data[stop] = (self.data[stop] + value) % self.m\n start >>= 1\n stop >>= 1\n\n # Tell all nodes above of the updated area of the updates\n self._build(start_copy)\n self._build(stop_copy - 1)\n\n def query(self, start, stop, default=0):\n \"\"\"func of data[start, stop)\"\"\"\n start += self._size\n stop += self._size\n\n # Apply all the lazily stored queries\n self._update(start)\n self._update(stop - 1)\n\n res = default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __getitem__(self, idx):\n return self.query(idx, idx + 1)\n\n def __repr__(self):\n return \"LazySegmentTree({0})\".format(self.data)\n\n\ndef main():\n n, m = map(int, input().split())\n\n sol = LazySegmentTree([0] * (n + 1), mod=m)\n sol.add(1, 2, 1)\n\n for i in range(1, n):\n sol.add(i + 1, n + 1, sol[i])\n for j in range(2, (n // i) + 1):\n sol.add(i * j, min(n + 1, (i + 1) * j), sol[i])\n\n print(sol[n])\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n"}], "negative_code": [{"source_code": "n, M = map(int,input().split())\n \n\n\n\n\n \ndp = [0]*(n+1)\naccu = [0]*(n+1)\n \n \ndp[1] = 1\ndp[2] = 2\nextra = 0\n\n\n \nfor i in range(3,n+1):\n dp[i] = (2*dp[i-1]) % M\n\n for j in range(1,int(i**0.5)+1):\n if i%j==0:\n dp[i] += dp[j] - dp[j-1] \n if j*j<i and j!=1: \n \n dp[i] += dp[i//j] - dp[i//j-1]\n\n\n \n#print(dp)\n \n \n \nprint(dp[n])\n"}, {"source_code": "# This code is contributed by Siddharth\r\n\r\nfrom sys import *\r\ninput = stdin.readline\r\n\r\n\r\n\r\n\r\nimport random\r\nfrom bisect import *\r\nimport math\r\nfrom collections import *\r\nimport operator\r\nfrom heapq import *\r\nfrom itertools import *\r\ninf=10**18\r\nmod=10**9+7\r\n\r\n# inverse modulo power pow(a,-1,mod) - it only works on py 3.8 ( *not in pypy )\r\n\r\n\r\n\r\n# ==========================================> Code Starts Here <=====================================================================\r\n\r\n\r\n\r\nn,m=map(int,input().split())\r\ndp=[0]*(n+5)\r\nsuf=[0]*(n+5)\r\ndp[n]=1\r\nsuf[n]=1\r\nfor i in range(n-1,0,-1):\r\n dp[i]=(dp[i]+suf[i+1])%m\r\n suf[i]=suf[i+1]\r\n j=2\r\n while j*i<=n:\r\n l=j*i\r\n r=min(j*i+j-1,n)\r\n dp[i]=(dp[i]+suf[l]+suf[r+1])%m\r\n j+=1\r\n suf[i]=(suf[i+1]+dp[i])%m\r\n\r\nprint(dp[1]%m)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\ninputt=sys.stdin.readline\r\nprintt=sys.stdout.write\r\n\r\nimport math\r\nimport functools # functools.reduce\r\nfrom collections import deque\r\nimport heapq\r\nfrom queue import PriorityQueue\r\n\r\ndef get():\r\n return inputt().split()\r\ndef getint():\r\n return int(inputt())\r\ndef getints():\r\n return map(int, inputt().split())\r\n\r\nn, m = getints()\r\na = [1 for _ in range(n+1)]\r\nsum = 1\r\nfor x in range(2, n+1):\r\n a[x] = sum\r\n y = math.floor(x**0.5)\r\n for d in range(1, y+1):\r\n a[x]+=(x//d-x//(d+1))*a[d]\r\n for z in range(2, x//(y+1)+1):\r\n a[x]+=a[x//z]\r\n a[x] %= m\r\n sum += a[x]\r\n sum %= m\r\nprint([a[i+1]-a[i] for i in range(len(a)-1)])"}, {"source_code": "import sys\r\nfrom io import BytesIO, IOBase\r\nimport os\r\nimport math\r\n################################ <fast I/O> ###########################################\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n\r\n def readline(self, **kwargs):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\n\r\n#############################################<I/O Region >##############################################\r\n\r\n\r\ndef inp():\r\n return sys.stdin.readline().strip()\r\n\r\n\r\ndef map_inp(v_type):\r\n return map(v_type, inp().split())\r\n\r\n\r\ndef list_inp(v_type):\r\n return list(map_inp(v_type))\r\n\r\n\r\n######################################## Solution ####################################\r\n\r\nn, m = map_inp(int)\r\ndp = [0 for col in range(n + 1)]\r\ndp[1] = 1\r\nadd_q = 1\r\nfor i in range(2, n + 1):\r\n dp[i] += add_q % m\r\n temp = int(math.sqrt(i))\r\n for j in range(1, temp + 1):\r\n if 1 < j < temp:\r\n dp[i] += dp[i // j] % m\r\n dp[i] += (dp[j] * (abs((i // (j + 1)) - (i // j)))) % m\r\n dp[i] %= m\r\n add_q += dp[i]\r\nprint(dp[n])\r\n"}, {"source_code": "from sys import stdin\r\nfrom math import sqrt\r\n# raw_input = input\r\n# xrange = range\r\nraw_input = lambda: stdin.readline().rstrip()\r\ninput = lambda: int(raw_input())\r\nI=lambda: map(int, raw_input().split())\r\nn,m = I()\r\ndp = [0]*(n+1)\r\ndp[1] = 1\r\ns = 1\r\nfor x in xrange(2, n+1):\r\n\tw = 0\r\n\tq = int(sqrt(x))\r\n\tq1 = q+(0 if q**2==x else 1)\r\n\tq2 = q1-1\r\n\tfor j in xrange(2, q1): #j<sqrt(x)\r\n\t\tw = (w+dp[x//j])%m\r\n\tfor c in xrange(1, q+1):\r\n\t\ta1 = x//(c+1)\r\n\t\ta2 = x//c\r\n\t\tw = (w+(dp[c]*(a2-a1))%m)%m\r\n\tdp[x] = (s + w)%m\r\n\ts = (s+dp[x])%m\r\nprint(dp[n])"}, {"source_code": "from sys import stdin\r\nfrom math import sqrt\r\n# raw_input = input\r\n# xrange = range\r\nraw_input = lambda: stdin.readline().rstrip()\r\ninput = lambda: int(raw_input())\r\nI=lambda: map(int, raw_input().split())\r\nn,m = I()\r\ndp = [0.0]*(n+1)\r\ndp[1] = 1.0\r\ns = 1.0\r\nfor x in xrange(2, n+1):\r\n\tw = 0.0\r\n\tq = int(sqrt(x))\r\n\tq1 = q+(0 if q**2==x else 1)\r\n\tfor j in xrange(2, q1): #j<sqrt(x)\r\n\t\tw = (w+dp[x//j])%m\r\n\tfor c in xrange(1, q+1):\r\n\t\ta1 = x//(c+1)\r\n\t\ta2 = x//c\r\n\t\tif a2>a1 and a2>q1-1:\r\n\t\t\tw = (w+(dp[c]*(a2-max(a1, q1-1)))%m)%m\r\n\tdp[x] = (s + w)%m\r\n\ts = (s+dp[x])%m\r\nprint(dp[n])"}], "src_uid": "a524aa54e83fd0223489a19531bf0e79"} {"source_code": "\"\"\"====================================================================================\n ====================================================================================\n \n ___ _______ ___ _______ ___ ___\n | /\\ | | \\ | | / | | | | |\\ /|\n | / \\ | | \\ | | / | | | | | \\ / |\n |___ /____\\ | | \\ | |/ |___| | | | \\/ |\n | / \\ | | / | |\\ |\\ | | | |\n | / \\ | | / | | \\ | \\ | | | |\n ___|/ \\___|___ |___/ ___|___ | \\ | \\ |___| | |\n \n \n ====================================================================================\n ==================================================================================== \n\"\"\"\n# \u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\n\nn = int(input())\nl = list(map(int,input().split()))\ns = 0\nfor i in range(n):\n s += i * l[i]*4\nprint(s)\n \n# \u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\u2665\n\"\"\"====================================================================================\n ====================================================================================\n \n ___ _______ ___ _______ ___ ___\n | /\\ | | \\ | | / | | | | |\\ /|\n | / \\ | | \\ | | / | | | | | \\ / |\n |___ /____\\ | | \\ | |/ |___| | | | \\/ |\n | / \\ | | / | |\\ |\\ | | | |\n | / \\ | | / | | \\ | \\ | | | |\n ___|/ \\___|___ |___/ ___|___ | \\ | \\ |___| | |\n \n \n ====================================================================================\n ==================================================================================== \n\"\"\"", "positive_code": [{"source_code": "import sys\ninput = sys.stdin.readline\nn = int(input())\ns = [0]+list(map(int, input().split()))\nret = 9876543210\nfor xth in range(1, len(s)):\n summ = 0\n for i in range(1, len(s)):\n summ += 2*(abs(xth-i)+(i-1)+(xth-1))*s[i]\n ret=min(ret, summ)\nprint(ret)"}, {"source_code": "n = int(input())\nmin = 0\nres = input().split()\nfor i in range(n):\n min += i*int(res[i])\nprint(4*min)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Dec 12 19:01:12 2018\n\n@author: mach\n\"\"\"\n\ni = int(input())\nl = list(map(int, input().strip().split()))\nsums = 0\nfor k in range(1,i):\n sums += 4*k*l[k]\nprint(sums)"}, {"source_code": "n=int(input())\nx = list(map(int, input().split(\" \")))\nsum=0\nfor i in range(n):\n sum+=i*4*x[i]\nprint(sum)"}, {"source_code": "#for i in range(int(input())):\nn=int(input())\narr=[int(x) for x in input().split()]\nfinal=-1\nfor i in range(n):\n\ttemp=2\n\tcost=0\n\tfor j in range(i+1):\n\t#\tprint(arr[j],j+1)\n\t\tcost+=arr[j]*(j)+abs(j-i)*arr[j]+abs(i)*arr[j]\n\t\tcost+=arr[j]*(j)+abs(j-i)*arr[j]+abs(i)*arr[j]\n\n\t#print(cost,i)\n\tfor j in range(i+1,n):\n\t\tcost+=arr[j]*(j)+abs(j-i)*arr[j]+abs(i)*arr[j]\n\t\tcost+=arr[j]*(j)+abs(j-i)*arr[j]+abs(i)*arr[j]\n\n\tif cost<final or final==-1:\n\t\tfinal=cost\n\t#print(cost,i)\nprint(final)\n"}, {"source_code": "n = int(input())\na = input().split()\na = [int(item) for item in a]\ndef lf(x,et):\n s = 2*(abs(et-x) + abs(x -1) + abs(et-1))\n return(s)\nf = []\nfor i in range(n):\n s2 = 0\n for j in range(n):\n s2 += lf(i+1,j+1)*a[j]\n f.append(s2)\nprint(min(f))\n\n \n\n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n"}, {"source_code": "n = map(int, input())\nm = list(map(int, input().split()))\nindex = m.index(max(m))\nk = 0\nfor i in range(len(m)):\n k += i*4*m[i]\nprint(k)\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\ndef get(x):\n ans = 0\n for i in xrange(1,n+1):\n cur = abs(x-i) + i-1 + x -1\n ans += 2*cur*a[i-1]\n return ans\nres = 10**18\nfor i in xrange(1,n+1):\n res = min(res,get(i))\nprint res"}, {"source_code": "n = int(input())\npeople = []\npeople_ = input()\npeople_ = people_.split(\" \")\nfor p in people_:\n people.append(int(p))\n\nsum =0\nfor each_floor in range(n):\n sum += people[each_floor]*4*each_floor\n\nprint(sum)"}, {"source_code": "def ElctryctyUnts(no_of_people):\n min_units = 1000000000\n for i in range(len(no_of_people)):\n units = 0\n for j in range(len(no_of_people)):\n units += 2*no_of_people[j]*((abs(i-j))+(abs(j-0))+i)\n #print units\n if units < min_units:\n min_units = units\n\n return min_units\n\ndef main():\n n = int(raw_input())\n no_of_people = list(map(int,raw_input().split()))\n\n print ElctryctyUnts(no_of_people)\n\nmain()\n"}, {"source_code": "n=int(input())\narr=[]\ntmp=input().split()\nfor i in tmp:\n\tarr.append(int(i))\nmin=1000000000\nfor i in range(n):\n\ts=0\n\tfor j in range(n):\n\t\ts+=((abs(i-j)+i+j)*2*arr[j])\t\n\tif(min>s):\n\t\tmin=s\nprint(min)"}, {"source_code": "inp=input()\ninp2=map(int,raw_input().split())\nbest=100000000\nfor i in range(105):\n ans=0\n for j,x in enumerate(inp2):\n ans+=2*2*max(j,i)*x\n # best=min(best,ans)\n if best>ans:\n best=ans\n # print i,best\nprint best\n"}, {"source_code": "\"\"\"\nthis is a standard python template for codeforces task, repo: github.com/solbiatialessandro/pyComPro/codeforces\n\"\"\"\nstdin = lambda type_ = \"int\", sep = \" \": list(map(eval(type_), raw_input().split(sep)))\njoint = lambda sep = \" \", *args: sep.join(str(i) if type(i) != list else sep.join(map(str, i)) for i in args)\ndef solve(A):\n res = 1e9\n for x in xrange(1, 101):\n _res = 0\n for i, num in enumerate(A):\n index = i + 1\n value = 2*(x-1 + index-1 + abs(x - index))\n _res += num * value\n res = min(res, _res)\n #print x, _res\n return res\n\n\nif __name__ == \"__main__\":\n \"\"\"the solve(*args) structure is needed for testing purporses\"\"\"\n n = stdin()\n A = stdin()\n print solve(A)"}, {"source_code": "'''input\n3\n0 2 1\n'''\nimport math\nfrom fractions import gcd\n\nma=10**18\nind=-1\nn=input()\narr=map(int,raw_input().split())\nfor j in range(n):\n\tsu=0\n\tfor i in range(n):\n\t\ta=abs(j-i)+i+j;\n\t\ta=2*a\n\t\tsu+=(arr[i]*a)\n\tma=min(ma,su)\nprint ma\n\n"}, {"source_code": "import sys\n\n\ndef FairNut(peoples):\n\tmini=10**10\n\tfor x in xrange(len(peoples)):\n\t\tunit_pp=0\n\t\tfor i in xrange(len(peoples)):\n\t\t\tunit_pp+=(abs(i-x)+i+x)*peoples[i]\n\t\tmini=min(unit_pp,mini)\n\treturn(mini)\n\nn=int(raw_input())\nl=map(int,raw_input().split())\nprint(FairNut(l)*2)\n"}, {"source_code": "n=input()\nl=map(int,raw_input().split(\" \"))\nmn=1000000000000000\nfor i in range(n):\n x=i\n ans=0\n for i in range(n):\n ans+=2*l[i]*(i+x+abs(i-x))\n #print l[i]*(i+1+x+abs(i+1-x))\n mn=min(ans,mn)\nprint mn\n"}, {"source_code": "def f(n,l):\n mi = 1000000000000000\n for k in range(1,101):\n su = 0\n for idx in range(n):\n i = idx + 1\n su += 2* l[idx] * (abs(k-i)+abs(i-1)+abs(k-1))\n mi = min(su, mi)\n return mi\n\nif __name__ == '__main__':\n n = int(input())\n l = map(int, raw_input().rstrip().split())\n print f(n,l)"}, {"source_code": "import sys\nimport operator\n\n\ndef main():\n n = int(sys.stdin.readline())\n arr = list(map(int, sys.stdin.readline().split()))\n arr = list(enumerate(arr))\n arr.sort(key=operator.itemgetter(1), reverse=True)\n # print(arr)\n check = arr[0][1]\n index = -1\n while index < n-1 and arr[index][1] == check:\n index += 1\n count = 0\n # print(index)\n # print(arr[index][0])\n for i in range(n):\n # if arr[i][0] <= arr[index][0]:\n #count += arr[i][1]*(2*(abs(arr[index][0]-arr[i][0]))+2*(arr[i][0]))\n # else:\n count += 2*(arr[i][1]*2*(arr[i][0]))\n print(count)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\narray = list(map(int, input().split()))\nans = []\ne = 0\nfor x in range(1, n + 1):\n\te = 0\n\tfor i in range(1, n + 1):\n\t\tdifference = (x - 1) + (i - 1) + abs(i - x)\n\t\te += 2 * difference * array[i - 1] \n\t\t##print(e)\n\tans.append(e)\nprint(min(ans))\n\t"}, {"source_code": "raw_input()\nprint sum(list(map(lambda (i, x): 4*i*x, list(enumerate(map(int, raw_input().split(' ')))))))"}, {"source_code": "__author__ = 'tanunia'\n\nfrom sys import stdin\n\nn = int(stdin.readline())\na = [int(x) for x in stdin.readline().strip().split()]\n\nx = 0\nbest_sum = 100005000\nfor i in xrange(n):\n cur_sum = 0\n for j in xrange(n):\n cur_sum += 2*a[j] * (abs(j) + abs(j - i) + abs(i))\n if cur_sum < best_sum:\n best_sum = cur_sum\n x = i\n\nprint best_sum\n"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\nary = list(map(int, stdin.readline().split()))\nans = 10**9\nfor x in range(1, n + 1):\n cur = 0\n for f in range(1, n + 1):\n cur = cur + 2 * ary[f - 1] * (abs(x - f) + abs(f - 1) + abs(x - 1))\n ans = min(ans, cur)\nstdout.write(\"{}\".format(ans))\n "}, {"source_code": "n = int(input())\narray = [int(x) for x in input().split()]\ncount = 0\n\nfor i in range(n):\n count = count + (4 * i * array[i])\nprint(count) "}, {"source_code": "n = int(input())\narr = input().split()\nfor i in range(n):\n arr[i] = int(arr[i])\n\nsum = 0\nfor i in range(n):\n sum += 4 * arr[i] * i\nprint(sum)\n\n"}, {"source_code": "def _mp():\n\treturn map(int,raw_input().split())\nn=input()\na=_mp()\nx=1\nmi=1000000000\nfor x in range(1,n+1):\n\tcurr=0\n\tfor i in range(1,n+1):\n\t\tcurr+=a[i-1]*(2*abs(i-1)+abs(x-i)+abs(x-1)+abs(1-x)+abs(i-x))\n\n\tmi=min(mi,curr)\n\nprint mi\n"}, {"source_code": "n = int(input())\na = [int(w) for w in input().split()]\n\nprint(4*sum(a[i]*i for i in range(n)))\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nb = []\nfor x in range(1,n+1):\n count = 0\n for i in range(1,n+1):\n count += 2 * a[i-1] * (abs(i-x)+x-2+i)\n b.append(count)\nprint(min(b))"}, {"source_code": "#526_A\n\nimport sys\nimport math\n\nfloors = int(sys.stdin.readline().rstrip())\n\nlne = [int(i) for i in sys.stdin.readline().rstrip().split(\" \")]\n\nmn = 10 ** 9\n\nfor i in range(0, floors):\n elec = 0\n for j in range(0, len(lne)):\n elec += (abs(i - j) + j + i) * 2 * lne[j]\n if elec < mn:\n mn = elec\nprint(mn)\n"}, {"source_code": "n = int(input())\n\na = [int(x) for x in input().split()]\n\nind = a.index(max(a))+1\ns = 0\nfor i in range(n):\n s += a[i]*i*4\nprint(s)\n"}, {"source_code": "\n# -*- coding: utf-8 -*-\n# @Date : 2019-01-23 09:28:02\n# @Author : raj lath (oorja.halt@gmail.com)\n# @Link : link\n# @Version : 1.0.0\n\nfrom sys import stdin\n\nmax_val=int(10e12)\nmin_val=int(-10e12)\n\ndef read_int() : return int(stdin.readline())\ndef read_ints() : return [int(x) for x in stdin.readline().split()]\ndef read_str() : return input()\ndef read_strs() : return [x for x in stdin.readline().split()]\n\n\nnb_floors = int(input())\npeoples = read_ints()\nprint( 4 * (sum([i*v for i, v in enumerate(peoples)])))\n"}, {"source_code": "n=(int(input()))\nar=[int(x) for x in input().split()]\nans=0\nfor k in range(n):\n ans+=4*ar[k]*k\nprint(ans)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nr=[]\nfor j in range(1,n+1):\n ans=0\n for i in range(1,n+1):\n ans+=(2*a[i-1]*(abs(j-i)+abs(i-1)+abs(1-j)))\n r.append(ans)\n\n \nprint(min(r)) "}, {"source_code": "n = int(input())\nflours = list(map(int, input().split()))\nbest = 10000000\nfor x in range (n):\n sum = 0\n for i in range (n):\n if i <= x:\n sum += (x * 4) * flours[i]\n\n else:\n sum += (i * 4) * flours[i]\n if best > sum:\n best = sum\n\nprint(best)\n\n\n"}, {"source_code": "k=int(input())\nli=list(map(int,input().split()))\na=0\nfor i in range(k):\n a+=4*li[i]*i\nprint(a)\n \n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nc=0\nfor i in range(n):\n c+=i*l[i]*4\nprint(c)\n \n "}, {"source_code": "import math\nn = int(input())\na = list(map(int, input().strip().split()))\n\nminim = 10000000000000\ncurr = 0\n\n\nfor opt_etage in range(len(a)):\n\n curr = 0\n for population in range(len(a)):\n \n if(population!=0):\n\n curr += a[population]*(abs(opt_etage-population) + abs(opt_etage) + abs(population)) * 2\n\n \n\n if(minim>curr):\n minim=curr\n\n\n\nprint(minim)"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nans=10**10\nfor i in range(n):\n el=0\n for j in range(n):\n if j>i:\n el+=a[j]*j*4\n else:\n el+=a[j]*i*4\n #print(el)\n if (ans > el):\n ans=el\nprint(ans)"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\n\nans = 0\n\nfor idx in range(n):\n ans += arr[idx] * idx * 4\n\nprint(ans)\n"}, {"source_code": "n = int(input())\nans=0\na=list(map(int,input().split()))\nfor i,j in enumerate(a):\n ans+=i*j\nprint(ans*4)"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nenergy = []\nfor x in range(n):\n energy.append(0)\n for i, resident in enumerate(residents):\n energy[x] += (abs(x - i) + i + x) * 2 * resident\nprint(min(energy))"}, {"source_code": "\nn = int(input())\n\na = list(map(int, input().split()))\na = [0] + a\n# print(a)\nmaxi = -1\nindex = -1\nfor i in range(n):\n if a[i] > maxi:\n maxi = a[i]\n index = i\n\nans = 10**10\n# print(index)\nfor x in range(1,n+1):\n cost = 0\n for i in range(1,n+1):\n if a[i] == 0:\n continue\n cost += a[i] * (abs(x - i) + i - 1 + x - 1)\n\n ans = min(ans, cost)\nprint(2*ans)\n\n\n"}, {"source_code": "''' Thruth can only be found at one place - THE CODE '''\n\n''' Copyright 2018, SATYAM KUMAR'''\nfrom sys import stdin, stdout\nimport cProfile, math\nfrom collections import Counter\nfrom bisect import bisect_left,bisect,bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nsys.setrecursionlimit(10**6) # max depth of recursion\nthreading.stack_size(2**27) # new thread will get stack of such size\n\nprintHeap = str()\nmemory_constrained = False\nP = 10**9+7\nimport sys\nsys.setrecursionlimit(10000000)\n\nclass Operation:\n def __init__(self, name, function, function_on_equal, neutral_value=0):\n self.name = name\n self.f = function\n self.f_on_equal = function_on_equal\ndef add_multiple(x, count):\n return x * count\ndef min_multiple(x, count):\n return x\ndef max_multiple(x, count):\n return x\nsum_operation = Operation(\"sum\", sum, add_multiple, 0)\nmin_operation = Operation(\"min\", min, min_multiple, 1e9)\nmax_operation = Operation(\"max\", max, max_multiple, -1e9)\nclass SegmentTree:\n def __init__(self,\n array,\n operations=[sum_operation, min_operation, max_operation]):\n self.array = array\n if type(operations) != list:\n raise TypeError(\"operations must be a list\")\n self.operations = {}\n for op in operations:\n self.operations[op.name] = op\n self.root = SegmentTreeNode(0, len(array) - 1, self)\n def query(self, start, end, operation_name):\n if self.operations.get(operation_name) == None:\n raise Exception(\"This operation is not available\")\n return self.root._query(start, end, self.operations[operation_name])\n def summary(self):\n return self.root.values\n def update(self, position, value):\n self.root._update(position, value)\n def update_range(self, start, end, value):\n self.root._update_range(start, end, value)\n def __repr__(self):\n return self.root.__repr__()\nclass SegmentTreeNode:\n def __init__(self, start, end, segment_tree):\n self.range = (start, end)\n self.parent_tree = segment_tree\n self.range_value = None\n self.values = {}\n self.left = None\n self.right = None\n if start == end:\n self._sync()\n return\n self.left = SegmentTreeNode(start, start + (end - start) // 2,\n segment_tree)\n self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end,\n segment_tree)\n self._sync()\n def _query(self, start, end, operation):\n if end < self.range[0] or start > self.range[1]:\n return None\n if start <= self.range[0] and self.range[1] <= end:\n return self.values[operation.name]\n self._push()\n left_res = self.left._query(start, end,\n operation) if self.left else None\n right_res = self.right._query(start, end,\n operation) if self.right else None\n if left_res is None:\n return right_res\n if right_res is None:\n return left_res\n return operation.f([left_res, right_res])\n def _update(self, position, value):\n if position < self.range[0] or position > self.range[1]:\n return\n if position == self.range[0] and self.range[1] == position:\n self.parent_tree.array[position] = value\n self._sync()\n return\n self._push()\n self.left._update(position, value)\n self.right._update(position, value)\n self._sync()\n def _update_range(self, start, end, value):\n if end < self.range[0] or start > self.range[1]:\n return\n if start <= self.range[0] and self.range[1] <= end:\n self.range_value = value\n self._sync()\n return\n self._push()\n self.left._update_range(start, end, value)\n self.right._update_range(start, end, value)\n self._sync()\n def _sync(self):\n if self.range[0] == self.range[1]:\n for op in self.parent_tree.operations.values():\n current_value = self.parent_tree.array[self.range[0]]\n if self.range_value is not None:\n current_value = self.range_value\n self.values[op.name] = op.f([current_value])\n else:\n for op in self.parent_tree.operations.values():\n result = op.f(\n [self.left.values[op.name], self.right.values[op.name]])\n if self.range_value is not None:\n bound_length = self.range[1] - self.range[0] + 1\n result = op.f_on_equal(self.range_value, bound_length)\n self.values[op.name] = result\n def _push(self):\n if self.range_value is None:\n return\n if self.left:\n self.left.range_value = self.range_value\n self.right.range_value = self.range_value\n self.left._sync()\n self.right._sync()\n self.range_value = None\n def __repr__(self):\n ans = \"({}, {}): {}\\n\".format(self.range[0], self.range[1],\n self.values)\n if self.left:\n ans += self.left.__repr__()\n if self.right:\n ans += self.right.__repr__()\n return ans\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\ndef primeFactors(n): #n**0.5 complex \n factors = dict()\n for i in range(2,math.ceil(math.sqrt(n))+1): \n while n % i== 0: \n if i in factors:\n factors[i]+=1\n else: factors[i]=1\n n = n // i \n if n>2:\n factors[n]=1\n return (factors)\n \ndef isprime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\ndef test_print(*args):\n if testingMode:\n print(args)\n\ndef display_list(list1, sep=\" \"):\n stdout.write(sep.join(map(str, list1)) + \"\\n\")\n\ndef get_int():\n return int(stdin.readline().strip())\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\n\nmemory = dict()\ndef clear_cache():\n global memory\n memory = dict()\ndef cached_fn(fn, *args):\n global memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\n\n# -------------------------------------------------------------- MAIN PROGRAM\nTestCases = False\ntestingMode = False\noptimiseForReccursion = False #Can not be used clubbed with TestCases\ndef comp(li):\n return len(li)\n\ndef main():\n n=get_int()\n li = get_list()\n res = 0\n for i,ele in enumerate(li):\n res+=i*4*ele\n print(res)\n\n# --------------------------------------------------------------------- END\n\n\nif TestCases: \n for _ in range(get_int()): \n cProfile.run('main()') if testingMode else main() \nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()"}, {"source_code": "from sys import stdin,stdout\nfrom itertools import combinations\nfrom collections import defaultdict\n\n\ndef listIn():\n return list((map(int,stdin.readline().strip().split())))\n\ndef stringListIn():\n return([x for x in stdin.readline().split()])\n \ndef intIn():\n return (int(stdin.readline()))\n\ndef stringIn():\n return (stdin.readline().strip())\n\n\nif __name__==\"__main__\":\n n=intIn()\n a=listIn()\n minn=float('inf')\n \n for x in range(1,n+1):\n m=0\n j=1\n for i in range(1,n+1):\n s_floor=0 \n s_floor=abs(i-j)+abs(i-x)+abs(j-x)\n s_floor*=2*a[i-1]\n #print(s_floor,i)\n m+=s_floor\n minn=min(m,minn) \n\n print(minn)\n \n \n \n \n \n"}, {"source_code": "#_________________ Mukul Mohan Varshney _______________#\n\n#Template\nimport sys\nimport os\nimport math\nimport copy\nfrom math import gcd\nfrom bisect import bisect\nfrom io import BytesIO, IOBase\nfrom math import sqrt,floor,factorial,gcd,log,ceil\nfrom collections import deque,Counter,defaultdict\nfrom itertools import permutations, combinations\n\n#define function \ndef Int(): return int(sys.stdin.readline())\ndef Mint(): return map(int,sys.stdin.readline().split())\ndef Lstr(): return list(sys.stdin.readline().strip())\ndef Str(): return sys.stdin.readline().strip()\ndef Mstr(): return map(str,sys.stdin.readline().strip().split())\ndef List(): return list(map(int,sys.stdin.readline().split()))\ndef Hash(): return dict()\ndef Mod(): return 1000000007\ndef Ncr(n,r,p): return ((fact[n])*((ifact[r]*ifact[n-r])%p))%p\ndef Most_frequent(list): return max(set(list), key = list.count)\ndef Mat2x2(n): return [List() for _ in range(n)]\n\ndef Prime_factors(n):\n i = 2\n factors = set()\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.add(i)\n if n > 1:\n factors.add(n)\n print(factors) \n if len(factors)==2:\n return True\n else:\n return False\n\ndef Divisors(n) : \n l = [] \n for i in range(1, int(math.sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n // i == i) : \n l.append(i) \n else : \n l.append(i)\n l.append(n//i)\n return l\n \ndef Sieve(n): \n prime=[True for i in range(n+1)]\n lst=[]\n p=2\n while p*p<=n:\n if prime[p]:\n for i in range(p*p,n+1,p):\n prime[i]=False\n p=p+1\n for i in range(2,n+1):\n if prime[i]:\n lst.append(i)\n return lst \n \ndef minimum_integer_not_in_list(a):\n b=max(a)\n if(b<1):\n return 1\n \n A=set(a)\n B=set(range(1,b+1))\n D=B-A\n if len(D)==0:\n return b+1\n else:\n return min(D)\n \n# Driver Code \t\ndef solution():\n n=Int()\n a=List()\n s=0\n for i in range(n):\n s+=4*i*a[i]\n print(s) \n\n#Call the solve function \nif __name__ == \"__main__\":\n solution() "}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nbase = 0\nbigNumber = 0\nelectricity = 0\ntemp=0\nfor i in range(0, len(arr)):\n electricity += i*arr[i]*2*2\nfor i in range(1, len(arr)):\n base = i\n temp = 0\n for j in range(0, len(arr)):\n if base >= j:\n temp += ((base-j) + j + base)*2*arr[j]\n elif base < j:\n temp += ((j - base) + j + base) * 2 * arr[j]\n if temp < electricity:\n electricity = temp\nprint(electricity)\n"}, {"source_code": "\nn = int(input())\nl = list(map(int, input().split()))\nx = 0\n\nans = 0\nfor i in range(n):\n\tans += l[i] * (i + abs(i - x) + x) * 2\n\n\nprint(ans)"}, {"source_code": "\nInput=lambda:map(int,input().split())\n\nn = int(input())\n\nans = 0\nMin = float('inf')\nList = list(Input())\nx = List.index(max(List)) + 1\n\nfor i in range(1,n+1):\n if List[i-1] != 0:\n ans+= (i-1) * 4 * List[i-1]\nprint(ans)\n\n\n"}, {"source_code": "n = int(input())\na = input().split()\nfor i in range(n):\n\ta[i] = int(a[i])\nminE = 1000000000\nfor x in range(1,n+1):\n\te = 0\n\tfor f in range(1,n+1):\n\t\te += (abs(x-f) + f-1 + x-1)*a[f-1]*2\n\tif e < minE:\n\t\tminE = e\nprint(minE)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nc=[]\nfor i in range(1,n+1):\n\tx=i\n\tci=0\n\tfor j in range(1,n+1):\n\t\tif j>x:\n\t\t\tci+=4*(j-1)*a[j-1]\n\t\tif j<=x and not(j==1 and x==1):\n\t\t\tci+=4*(x-1)*a[j-1]\t\n\t\tif j==1 and x==1:\n\t\t\tci+=0\n\n\tc.append(ci)\n\n\t\t\nprint(min(c))"}, {"source_code": "n=int(input())\na = list(map(int, input().split()))\ntl=[]\n\ndef f(x,fl):\n return 2*(x+fl + abs(fl-x))\ntl=[]\nfor x in range(n):\n t=0\n for fl in range(n):\n t += f(x,fl)*a[fl]\n tl.append(t)\nprint(min(tl))"}, {"source_code": "n = int(input())\n\nl = [0] + list(map(int,input().split()))\nans = 100000000000\nfor i in range(1,n+1):\n s=0\n for j in range(1,n+1):\n s += (abs(j-i)+ abs(i-1)+ abs(j-1))*l[j]\n ans = min(s,ans)\nprint(2*ans)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=[]\nfor i in range(n):\n\tt=i+1\n\tsumi=0\n\tfor j in range(1,n+1):\n\t\tsumi+=a[j-1]*(abs(t-j)+abs(j-1)+abs(t-1))\n\t\tsumi+=a[j-1]*(abs(t-1)+abs(1-j)+abs(j-t))\n\tb.append(sumi)\nprint(min(b))"}, {"source_code": "import sys\nn=int(input())\narr=[int(x) for x in input().split()]\nans=sys.maxsize\nfor x in range(1,n+1):\n\tt=0\n\tfor j in range(1,n+1):\n\t\tt+=arr[j-1]*2*(abs(x-j)+abs(j-1)+abs(1-x))\n\tans=min(ans,t)\nprint(ans)\n"}, {"source_code": "def calc(a,x,n):\n sum = 0\n for i in range(1,n+1):\n sum+= 2*a[i-1]*(abs(i-1)+abs(x-1)+abs(i-x))\n return sum\n\nn = int(input())\na = []\na = input()\na = list(map(int,a.split()))\ntemp = []\nfor i in range(1,n+1):\n temp.append(calc(a,i,n))\nprint(min(temp))\n"}, {"source_code": "from sys import stdin\n\nn = int(stdin.readline())\narr = [int(x) for x in stdin.readline().split()]\n\nall_units = []\n\nfor x in range(1, n + 1):\n #print(\"Starting in floor number\", x)\n units = 0\n\n for floor, p in enumerate(arr, start=1):\n #print(\"Going to floor\", floor, \"and no. of people =\", p)\n units += (abs(1 - floor) + abs(floor - 1)) * 2 * p\n #print(\"Units of electricity consumed in total:\", units)\n\n all_units.append(units)\n\n #print()\n\nprint(min(all_units))\n"}, {"source_code": "input()\n\nprint(4 * sum(i*a for i,a in enumerate(map(int, input().split()))))"}, {"source_code": "# alpha = \"abcdefghijklmnopqrstuvwxyz\"\nt = 1#int(input())\nfor test in range(t):\n n = int(input())\n a = list(map(int, input().split()))\n ans = 100000000\n\n for i in range(1,n+1):\n tmp = 0\n for j in range(1, n+1):\n tmp = tmp+(2*abs(j-i)+j-1+i-1+i-1+j-1)*a[j-1]\n\n if tmp<ans:\n ans = tmp\n\n print(ans)\n\n\n\n\n "}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 11.12.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pi\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n \ndef main():\n \n \n \n #for _ in range(ii()):\n \n \n n=ii()\n l=li()\n\n\n p=inf\n\n for j in range(n):\n pos=j\n ans=0\n for i in range(n):\n ans+=l[i]*(2*abs(pos-i)+2*i+2*pos)\n p=min(p,ans)\n #print(l[i]*(2*(pos-i)+2*i+2*pos),2*(pos-i)+2*i+2*pos,pos) \n print(p)\n\n \n \"\"\"\n s=list(si())\n\n\n cnt=0\n l=[]\n for i in range(len(s)):\n\n\n if s[i]=='b':\n l.append(cnt)\n cnt=0\n else:\n if s[i]=='a': \n cnt+=1\n\n l.append(cnt)\n\n ss=sum(l)\n\n ans=ss\n\n for i in range(len(l)):\n\n ans=(ans+((ss-l[i])*l[i])%mod)%mod\n ss-=l[i]\n\n\n print(ans)\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "n=int(input())\ns=[]\nf=list(map(int,input().split( )))\nfor x in range(1,n+1):\n p=0\n for a in range(1,n+1):\n p+=f[a-1]*(a+x-2+abs(a-x))*2\n s.append(p)\nprint(min(s))\n"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\narr = list(map(int, sys.stdin.readline().split()))\nans = 0\nfor i in range(1, n + 1):\n ans += arr[i - 1] * 2 * (2 * i - 2)\nprint(ans)"}, {"source_code": "from statistics import median\nn = int(input())\na = [0] + list(map(int,input().split()))\nans = float('Inf')\nfor i in range(1,n+1):\n temp = 0\n for j in range(1,n+1):\n temp += ((i-1)*4*a[j]) if j <= i else (j-1)*4*a[j]\n ans = min(temp,ans)\nprint(ans)\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nbill = float(\"inf\")\nfor i in range(n):\n\tt = 0\n\tfor j in range(n):\n\t\tt = t + l[j]*max(i,j)*4\n\tbill = min(t,bill)\nprint(bill)\n\t\t"}, {"source_code": "\nn=int(input())\na=list(map(int,input().split(\" \")))\n\nfrom math import *\nminn=100000000000000\n\nfor ck in range(0,n):\n\n\ttot=0\n\tfor i in range(0,n):\n\t\ttota=0\n\t\ttota+=abs(i-ck)\n\t\ttota+=abs(i-0)\n\t\ttota+=abs(0-ck)\n\t\ttota+=abs(ck-0)\n\t\ttota+=abs(i-0)\n\t\ttota+=abs(i-ck)\n\t\ttota*=a[i]\n\t\ttot+=tota\n\tminn=min(minn,tot)\nprint(minn)"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nans = 100000000\nfor x in range(0,n):\n ret = 0\n for i in range(0,n):\n ret += a[i] * (abs(x-i) + i + x + x + i + abs(x-i))\n if ret < ans :\n ans = ret\nprint(ans)\n"}, {"source_code": "import sys\n\n\ndef solve(io):\n\tN = io.read_int()\n\tA = io.read_int_array(N)\n\n\tbest = 1234567890\n\tfor x in range(0, N):\n\t\tscore = calculate(x, A)\n\t\tbest = min(best, score)\n\tio.println(best)\n\n\ndef calculate(x, A):\n\tcnt = 0\n\tfor f in range(0, len(A)):\n\t\tcnt += 2 * A[f] * (abs(x - f) + f + x)\n\treturn cnt\n\n\n# +---------------------+\n# | TEMPLATE CODE BELOW |\n# | DO NOT MODIFY |\n# +---------------------+\n\n\nclass IO:\n\tin_stream = None\n\tout_stream = None\n\traw = \"\"\n\tbuf = []\n\tpos = 0\n\n\tdef __init__(self, input_stream, output_stream):\n\t\tself.in_stream = input_stream\n\t\tself.out_stream = output_stream\n\n\tdef read_to_buffer(self):\n\t\tself.raw = self.in_stream.readline().rstrip('\\n')\n\t\tself.buf = self.raw.split()\n\t\tself.pos = 0\n\n\tdef read_string(self):\n\t\twhile self.pos == len(self.buf):\n\t\t\tself.read_to_buffer()\n\t\tans = self.buf[self.pos]\n\t\tself.pos += 1\n\t\treturn ans\n\n\tdef read_int(self):\n\t\treturn int(self.read_string())\n\n\tdef read_float(self):\n\t\treturn float(self.read_string())\n\n\tdef read_string_array(self, N, offset=0):\n\t\tarr = [None] * offset\n\t\tfor _ in range(0, N):\n\t\t\tarr.append(self.read_string())\n\t\treturn arr\n\n\tdef read_int_array(self, N, offset=0):\n\t\tarr = [None] * offset\n\t\tfor _ in range(0, N):\n\t\t\tarr.append(self.read_int())\n\t\treturn arr\n\n\tdef read_float_array(self, N, offset=0):\n\t\tarr = [None] * offset\n\t\tfor _ in range(0, N):\n\t\t\tarr.append(self.read_float())\n\t\treturn arr\n\n\tdef read_line(self):\n\t\twhile self.pos == len(self.buf):\n\t\t\tself.read_to_buffer()\n\t\tif self.pos > 0:\n\t\t\traise ValueError(\"Cannot call read_line in the middle of a line.\")\n\t\tself.pos = len(self.buf)\n\t\treturn self.raw\n\n\tdef print(self, s):\n\t\tself.out_stream.write(str(s))\n\n\tdef println(self, s):\n\t\tself.print(s)\n\t\tself.print('\\n')\n\t\n\tdef println_array(self, arr, sep = ' '):\n\t\tself.println(sep.join(str(x) for x in arr))\n\n\tdef flush_output(self):\n\t\tself.out_stream.flush()\n\n\npythonIO = IO(sys.stdin, sys.stdout)\nsolve(pythonIO)\npythonIO.flush_output()\n"}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\nans = -1\n\nfor x in range(0,len(arr)):\n now = 0\n for j in range(len(arr)):\n one = abs(x-j)+abs(j-0) + abs(0-x)\n total = 2*one*arr[j]\n now += total\n \n if ans ==-1:\n ans = now\n ans = min(ans,now)\n\nprint(ans)"}, {"source_code": "import math\n\n\ndef min_energy(n, arr):\n min_energy = math.inf\n for x in range(n):\n cur_energy = 0\n for i in range(n):\n if i < x:\n cur_energy += arr[i] * (abs(x-i) + i + 3*x)\n elif i == x:\n cur_energy += arr[i] * 4 * x\n else:\n cur_energy += arr[i] * (2 * abs(x-i) + 2*i + 2 * x)\n min_energy = min(min_energy, cur_energy)\n return min_energy\n\n\nif __name__ == '__main__':\n n = int(input())\n arr = list(map(int, input().strip().split()))\n print(min_energy(n, arr))\n"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\n\nm = 10**9\nfor x in range(n):\n tmp = sum([ 2*A[i]*( abs(i-x) + x + i) for i in range(n)])\n m = min(m, tmp)\nprint(m)"}, {"source_code": "n = int(raw_input())\nnumber = list(map(int,raw_input().split()))\nmini = 10000000000000000\nans = 1\nk = 0\nfor i in xrange(1,n+1):\n for j in xrange(0,n):\n k += number[j]*(abs(j+1-i) + abs(j+1 - 1) + abs(1 - i))\n if mini > k:\n mini = k\n ans = i\nprint mini*2"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nv=10**20\nfor x in range(n):\n t=0\n for i in range(n):\n t+=(abs(x-i)+i+x)*2*a[i]\n v=min(v,t)\nprint v"}, {"source_code": "import sys, math\nfrom sys import stdin, stdout\nrem = 10 ** 9 + 7\ninf=10**18\n#sys.setrecursionlimit(10 ** 6 + 7)\n#from resource import *; setrlimit(RLIMIT_STACK, (RLIM_INFINITY, RLIM_INFINITY))\ntake = lambda: map(int, stdin.readline().split())\nfrom heapq import heappush, heappop, heapify\nfrom collections import deque\nfrom bisect import *\n\nn=input()\narr=[0]+take()\nans=-1\ncheck=inf\nfor i in range(1,n+1):\n now=0\n for j in range(1,n+1):\n u=arr[j]*(abs(i-j)+j-1+i-1+i-1+j-1+abs(i-j))\n #print i,j,u\n now+=u\n\n if now<check:\n check=now\n ans=i\nprint check\n\n"}, {"source_code": "def inint():\n return int(raw_input())\n\ndef inints():\n return [int(x) for x in raw_input().split(' ')]\n\ndef ingrid(n):\n return [raw_input() for i in xrange(n)]\n\nn = inint()\na = inints()\n\nanss = []\nfor x in xrange(n):\n ans = 0\n for i, c in enumerate(a):\n ans += 2 * c * (abs(i - x) + abs(x - 0) + abs(i - 0))\n anss.append(ans)\n\nprint min(anss)\n"}, {"source_code": "n, a = int(input()), list(map(int, input().split()))\n\nprint(min(sum(2 * a[i] * (abs(x - i) + i + x) for i in range(n)) for x in range(n)))\n"}, {"source_code": "\nn = int(input())\nl = list(map(int,input().split()))\nmini = 10**18\nfor i in range(1,n+1):\n ans = 0\n cnt = 1\n for j in l:\n ans+=j*(abs(cnt-i) + abs(cnt-1) + abs(i-1) + abs(i-1) + abs(cnt-1) + abs(cnt-i))\n cnt+=1\n mini = min(mini,ans)\n\nprint(mini)\n"}, {"source_code": "#!/usr/bin/python3\nn = int(input())\na = list(map(int, input().split()))\n\ndef check(i):\n res = 0\n for k in range(n):\n res += 2 * a[k] * (i + k + abs(k - i))\n return res \n\nm_v = n * (n + 1) + n * max(a) * 2 * n\nfor i in range(n):\n c_v = check(i)\n m_v = min(m_v, c_v)\n\nprint (m_v)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nminval=10**9\nfor i in range(n):\n ans=0\n for j in range(n):\n ans+=2*(abs(i-j)+abs(j+i))*(abs(l[j]))\n minval=min(ans,minval)\nprint(minval)"}, {"source_code": "\"\"\"https://codeforces.com/contest/1084/problem/A\"\"\"\nn = int(input())\na = list(map(int,input().split()))\nx = 1\ntrips = 0\nfor i in range(1,n+1):\n trips += 2*a[i-1]*abs( abs(x-i) + abs(i-1) + abs(x-1) )\nprint(trips)"}], "negative_code": [{"source_code": "n = int(input())\narray = list(map(int, input().split()))\nx = array.index(max(array)) + 1\ne = 0\nfor i in range(1, n + 1):\n\te += array[i - 1] * 2 * (x + i - 2 + abs(i - x))\nprint(e)\n\t"}, {"source_code": "def inint():\n return int(input())\ndef inlist():\n return list(map(int,input().split()))\n\ndef main():\n n=inint()\n a=inlist()\n sm=sum(a)#;sm1=0\n #for i in range(n):sm1+=i*a[i]\n #x=sm1//sm\n x=0\n for i in range(n):\n if a[i]>a[x]:x=i \n sol=0\n for i in range(n):\n sol+=a[i]*(abs(i-x)+i+x+abs(x-0)+abs(i-0)+abs(x-i))\n #print(abs(i-x)+i+x,abs(x-0)+abs(i-0)+abs(x-i),i,a[i])\n print(sol)\n\n\nif __name__ == \"__main__\":\n #import profile\n #profile.run(\"main()\")\n main()"}, {"source_code": "#!/usr/bin/env python3\n\nn = int(input())\na = list(map(int, input().split()))\n\nx = a.index(max(a))\n\nu = []\nfor f, k in enumerate(a):\n u.append(4 * k * (abs(x - f) + x))\nprint(sum(u))\n"}, {"source_code": "n = int(input())\na = [i for i in list(map(int, input().split()))]\nmax = 0\nsum = 0\nfor i in range(n):\n\tsum = 0\n\tfor j in range(n):\n\t\tif j == i:\n\t\t\tsum += a[i] * (i) * 2\n\t\telse:\n\t\t\tsum += a[j] * (abs(j - i) * 2) + (i) * 2\n\tif sum > max:\n\t\tmax = sum\n\t\t\nprint(max)"}, {"source_code": "#codeforces _1084A\ngi = lambda : list(map(int,input().split()))\nn, = gi()\nl = gi()\npos = 1\nans = 1000000\nv = 0\nfor j in range(1,n+1):\n\tll = [(abs(pos-k)+abs(k-1)+abs(pos-1)+abs(pos-1)+abs(k-1)+abs(pos-k))*l[k-1] for k in range(1,n+1)]\n\tv = sum(ll)\n\tans = min(ans,v)\n\tpos += 1\nprint(ans)\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nbase = 0\nbigNumber = 0\nelectricity = 0\ntemp=0\nfor i in range(0, len(arr)):\n electricity += (i+i+1)*arr[i]*2\nfor i in range(1, len(arr)):\n base = i\n temp = 0\n for j in range(0, len(arr)):\n if base >= j:\n temp += ((base-j)+(j+1))*2*arr[j]\n elif base < j:\n temp += ((j - base) + (j+ 1)) * 2 * arr[j]\n if temp < electricity:\n electricity = temp\nprint(electricity)\n"}, {"source_code": "n = int(input())\na = [i for i in list(map(int, input().split()))]\nmax = 0\nsum = 0\nfor i in range(1, n):\n\tsum = 0\n\tfor j in range(1, n):\n\t\tif j == i:\n\t\t\tsum += a[i] * (i + 1) * 2\n\t\telse:\n\t\t\tsum += a[j] * (abs(j + 1 - i) * 2) + (i + 1) * 2\n\tif sum > max:\n\t\tmax = sum\n\t\t\nprint(max)"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = residents.index(max(residents)) + 1\nenergy = 0\n\nfor resident in residents:\n energy += (abs(x - (residents.index(resident) + 1)) + (residents.index(resident) + 1)) * 2 * resident \nprint(energy)"}, {"source_code": "import math\nn = int(input())\na = list(map(int, input().strip().split()))\n\nm = 10000000000000\nsu = 0\n\nfor j in range(1,len(a)):\n su = 0\n for i in range(1,len(a)+1):\n su += a[i-1]*(abs(j-i)+abs(i-1)+abs(j-1) + abs(j-1) + abs(i-1)+ abs(j-i))\n if(su < m):\n m = su\n\n\nprint(m)\n\n\n"}, {"source_code": "n=int(input())\narr=[]\ntmp=input().split()\nfor i in tmp:\n\tarr.append(int(i))\nmin=10000\nfor i in range(n):\n\ts=0\n\tfor j in range(n):\n\t\ts+=((abs(i-j)+abs(j)+abs(i))*arr[j])\t\n\tif(min>s):\n\t\tmin=s\nprint(2*min)"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\ndef get(x):\n ans = 0\n for i in xrange(n):\n cur = abs(x-i) + i + abs(x-i)\n ans += 2*cur*a[i]\n return ans\nres = 10**18\nfor i in xrange(n):\n res = min(res,get(i))\nprint res"}, {"source_code": "n=int(input())\nl=[int(i) for i in input().strip().split()]\ndef solve(x):\n ans=0\n for i in range(n):\n ans=ans+(max(x,i))*l[i]*2*2\n return(ans)\nfans=10*9\nfor i in range(n):\n tans=solve(i)\n if tans<fans:\n fans=tans\nprint(fans)\n"}, {"source_code": "n = map(int, input())\nm = list(map(int, input().split()))\nindex = m.index(max(m))\nk = 0\nfor i in range(len(m)):\n if i != index:\n k += (abs(i-index)+i+index)*m[i]*2\n elif index != 0:\n k += index * 2 * 2 * m[i]\n else:\n k += 0\nprint(k)"}, {"source_code": "def main():\n n = int(input())\n l = list(map(int, input().split()))\n x = n - l[::-1].index(max(l)) - 1\n \n c = 0\n \n for i in range(n):\n if i == x:\n c += l[i]*2*(x+1)\n else:\n c += l[i]*i*4\n \n print(c)\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/env python3\n\nn = int(input())\na = list(map(int, input().split()))\n\nx = a.index(max(a))\n\nu = []\nfor f, k in enumerate(a):\n u.append(4 * k * (abs(x - f) + x))\nprint(sum(u))\n"}, {"source_code": "n = int(input())\nlst = [int(x) for x in input().split()]\nx = lst.index(max(lst))\ns=0\nfor i in range(n):\n s+=(abs(x-i)+i+x)*lst[i]*2\n #print(s)\nprint(s)\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\n\nans = 101\n\nfor i in range(n):\n s = 0\n for j in range(n):\n\n a = (abs(i-j) + j + i)*2*l[j]\n\n s += a\n\n ans = min(s,ans)\n\nprint(ans)\n"}, {"source_code": "def flor(n,a):\n for i in range(n):\n if a[i] == 0:\n return a[0] *0\n elif len(a) == 2:\n return a[0]*0 + a[1] * 4\n else:\n return a[0]*0 + a[1] * 4 + a[2] * 8\n \n \n \n"}, {"source_code": "n = int(input())\np = list(map(int, input().strip().split()))\n\nx = p.index(max(p)) + 1\nans = 0\n\nfor i in range(1, len(p)):\n f = i + 1\n\n ans += p[i] * (abs(f-x)+abs(f-1)+abs(x-1)) * 2\n\nprint(ans)"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = residents.index(max(residents))\ny = n//2\nxe = 0\nye = 0\nfor i, resident in enumerate(residents):\n xe += (abs(x - i) + i + x) * 2 * resident\n ye += (abs(y - i) + i + y) * 2 * resident\nprint(min(xe,ye))"}, {"source_code": "n = int(input())\narray = list(map(int, input().split()))\nx = array.index(max(array)) + 1\ne = 0\nfor i in range(1, n + 1):\n\te += array[i - 1] * 2 * (x + i - 2 + abs(i - x))\nprint(e)\n\t"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = residents.index(max(residents))\nenergy = 0\ns = 0\n\nfor resident in residents:\n s = (abs(x - residents.index(resident)) + residents.index(resident) + x) \n if s == 0:\n s = 1\n energy += s * 2 * resident\nprint(energy)"}, {"source_code": "def inint():\n return int(raw_input())\n\ndef inints():\n return [int(x) for x in raw_input().split(' ')]\n\ndef ingrid(n):\n return [raw_input() for i in xrange(n)]\n\nn = inint()\na = inints()\n\nif n == 1:\n print 0\nelse:\n arr = []\n for i, c in enumerate(a):\n if i == 0:\n continue\n arr += [c] * i\n\n x = arr[len(arr) / 2]\n\n ans = 0\n for i, c in enumerate(a):\n if i == 0:\n continue\n ans += (abs(i - x) + abs(0 - x) + abs(i - 0)) * c * 2\n\n print ans"}, {"source_code": "#codeforces _1084A_live\ngi = lambda : list(map(int,input().split()))\nn, = gi()\nl = gi()\npos = 1\nans = 1000000000000\nv = 0\nfor j in range(1,n+1):\n\tll = [(abs(pos-k)+abs(k-1)+abs(pos-1)+abs(pos-1)+abs(k-1)+abs(pos-k))*l[k-1] for k in range(1,n+1)]\n\tprint(ll)\n\tv = sum(ll)\n\tans = min(ans,v)\n\tpos += 1\nprint(ans)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nx=l.index(max(l))\n#print(x)\ns=0\ns+=4*l[0]*x\nfor i in range(1,n):\n\t#print(i,2*l[i]*(abs(i-x)+i+x))\n\ts+=2*l[i]*(abs(i-x)+i+x)\n\nprint(s)\n"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = residents.index(max(residents))\nenergy = 0\nfor i, resident in enumerate(residents):\n energy += (abs(x - i) + i + x) * 2 * resident\nprint(energy)"}, {"source_code": "n=int(input())\narr=[]\ntmp=input().split()\nfor i in tmp:\n\tarr.append(int(i))\nmin=10000\nfor i in range(n):\n\ts=0\n\tfor j in range(n):\n\t\ts+=((abs(i-j)+i+j)*2*arr[j])\t\n\tif(min>s):\n\t\tmin=s\nprint(min)"}, {"source_code": "q = int(input())\nw = list(map(int, input().split()))\nr = []\nfor i in range(q):\n e = 0\n for j in range(q):\n e += (abs((i + 1) - (j + 1)) + j + 1) * w[j]\n r.append(e)\nprint(min(r))\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nx = n // 2\nsum = 0\nfor i in range(1, n):\n sum += a[i] * (abs(x - i) + i + x)\nprint(sum * 2)"}, {"source_code": "n=int(input())\nif n%2==0:\n mid=n//2;\nelse:\n mid=(n//2)+1;\ncost=0\na=[]\na = [int(i) for i in input().split()]\nfor i in range(1,n):\n cost+=2*a[i]*(abs(mid-i-1)+abs(i)+abs(mid-1))\nprint(cost)"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\ndef get(x):\n ans = 0\n for i in a:\n cur = abs(x-i) + i + abs(x-i)\n ans += 2*cur\n return ans\nres = 10**18\nfor i in xrange(n):\n res = min(res,get(i))\nprint res"}, {"source_code": "n = int(input())\narray = list(map(int, input().split()))\nx = array.index(max(array)) + 1\ne = 0\nfor i in range(1, n + 1):\n\te += array[i - 1] * 2 * (x + i - 2 + abs(i - x))\nprint(e)\n\t"}, {"source_code": "n=int(input())\nli=input().split()\nc=0\nj=0\nfor i in range(n):\n li[i]=int(li[i])\n if i==0:\n continue\n if li[i]>c:\n c=li[i]\n j=i+1\nx=j\nu=0\nfor i in range(n):\n if i==0:\n continue\n u1=(x-(i+1))*li[i]\n u2=(i)*li[i]\n if u1<0:\n u1*=-1\n u3=(x-1)*li[i]\n u=u+u1+u2+u3\nprint(u*2)\n"}, {"source_code": "def inint():\n return int(raw_input())\n\ndef inints():\n return [int(x) for x in raw_input().split(' ')]\n\ndef ingrid(n):\n return [raw_input() for i in xrange(n)]\n\nn = inint()\na = inints()\n\nif n == 1:\n print 0\nelse:\n arr = []\n for i, c in enumerate(a):\n if i == 0:\n continue\n arr += [c] * i\n\n x = arr[len(arr) / 2]\n\n ans = 0\n for i, c in enumerate(a):\n if i == 0:\n continue\n ans += (abs(i - x) + abs(0 - x) + abs(i - 0)) * c * 2\n\n print ans"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = residents.index(max(residents))\nenergy = 0\n\nfor resident in residents:\n energy += (abs(x - residents.index(resident)) + residents.index(resident) + x) * 2 * resident \nprint(energy)"}, {"source_code": "import math\nn = int(input())\na = list(map(int, input().strip().split()))\n\nminim = 10000000000000\nsu = 0\n\nfor j in range(1,len(a)):\n su = 0\n for i in range(2,len(a)+1):\n su += a[i-1]*(abs(j-i-1)+abs(i-2)+abs(j-1))*2\n if(minim>su):\n minim = su\n\n\n\nprint(minim)\n\n"}, {"source_code": "a=int(input())\ns=list(map(int,input().split()))\nm=0\nfor n in range(a):\n m+=4*(n+1)*s[n]\nprint(m)"}, {"source_code": "a=int(input())\ns=list(map(int,input().split()))\nx=s.index(max(s))\nm=0\nfor n in range(a):\n m+=(abs(x-n)+n+x+x+n+abs(x-n))*s[n]\nprint(m)"}, {"source_code": "n=int(input())\nli=input().split()\nc=0\nj=0\nfor i in range(n):\n li[i]=int(li[i])\n if i==0:\n continue\n if li[i]>=c:\n c=li[i]\n j=i+1\nx=j\nu=0\nfor i in range(n):\n if i==0:\n continue\n u1=(x-(i+1))*li[i]\n u2=(i)*li[i]\n if u1<0:\n u1*=-1\n u3=(x-1)*li[i]\n u=u+u1+u2+u3\nprint(u*2)\n"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\n\nm = 99999\nfor x in range(n):\n tmp = sum([ 2*A[i]*( abs(i-x) + x + i) for i in range(n)])\n m = min(m, tmp)\nprint(m)"}, {"source_code": "a = int(input())\nk = 0\nl = list(map(int,input().split()))\nfor i in range(len(l)):\n if i > 0:\n k += (2**(i+1))*l[i]\nprint(k) \n"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\nnum_ = A.index(max(A)) + 1\nanswer = 0\nfor k in range(n):\n y = 0\n y += abs(num_ - (k + 1)) * A[k]\n y += k * A[k]\n y += (num_ - 1) * A[k]\n y *= 2\n answer += y\nprint(answer)"}, {"source_code": "n=int(input())\nli=input().split()\nc=0\nj=0\nfor i in range(n):\n li[i]=int(li[i])\n if i==0:\n continue\n if li[i]>=c:\n c=li[i]\n j=i+1\nx=j\nu=0\nfor i in range(n):\n if i==0:\n continue\n u1=(x-(i+1))*li[i]\n u2=(i)*li[i]\n if u1<0:\n u1*=-1\n u3=(x-1)*li[i]\n u=u+u1+u2+u3\nprint(u*2)\n"}, {"source_code": "n = int(input())\np = list(map(int, input().strip().split()))\n\nx = p.index(max(p)) + 1\nans = 0\n\nfor i in range(1, len(p)):\n f = i + 1\n\n if f != x:\n ans += p[i] * (abs(f-x)+abs(f-1)+abs(x-1)) * 2\n else:\n ans += p[i] * f * 2\n\n\nprint(ans)"}, {"source_code": "n = int(input())\np = list(map(int, input().strip().split()))\n\nx = p.index(max(p)) + 1\nans = 0\n\nfor i in range(1, len(p)):\n f = i + 1\n\n if f != x:\n ans += p[i] * (abs(f-x)+abs(f-1)+abs(x-1)) * 2\n else:\n ans += p[i] * f * 2\n\n\nprint(ans)"}, {"source_code": "n = int(input())\np = list(map(int, input().strip().split()))\n\nx = p.index(max(p)) + 1\nans = 0\n\nfor i in range(1, len(p)):\n if i+1 <= x:\n ans += 2 ** x * p[i]\n else:\n ans += 2 ** (i + 1) * p[i]\n\nprint(ans)"}, {"source_code": "n = int(input())\np = list(map(int, input().strip().split()))\n\nx = p.index(max(p)) + 1\nans = 0\n\nfor i in range(1, len(p)):\n f = i + 1\n\n if f != x:\n ans += p[i] * (abs(f-x)+abs(f-1)+abs(x-1)) * 2\n else:\n ans += p[i] * f * 2\n\n\nprint(ans)"}, {"source_code": "def inint():\n return int(input())\ndef inlist():\n return list(map(int,input().split()))\n\ndef main():\n n=inint()\n a=inlist()\n sm=sum(a);sm1=0\n for i in range(n):sm1+=i*a[i]\n x=sm1//sm\n x1=0\n for i in range(n):\n if a[i]>a[x1]:x1=i \n sol=0;sol2=0\n for i in range(n):\n sol+=a[i]*(abs(i-x)+i+x+abs(x-0)+abs(i-0)+abs(x-i))\n sol2+=a[i]*(abs(i-x1)+i+x1+abs(x1-0)+abs(i-0)+abs(x1-i))\n #print(abs(i-x)+i+x,abs(x-0)+abs(i-0)+abs(x-i),i,a[i])\n print(min(sol,sol2))\n\n\nif __name__ == \"__main__\":\n #import profile\n #profile.run(\"main()\")\n main()"}, {"source_code": "n=int(input())\nl=input().split()\nl=list(map(int,l))\n\ndef sum1(g):\n if g==1:\n return 1\n else:\n return (g)*(g+1)/2\ndef fun():\n if len(l)==1:\n print(0)\n return\n else:\n z=0\n for i in range(1,len(l)):\n z=z+i*l[i]\n k=sum1(len(l)-1)\n x=int(z/k)\n ab=0\n \n f=(sum(l)-l[0])*x\n for i in range(1,len(l)):\n ab=ab+abs(i-x)\n\n print(2*z+2*ab+2*f)\nfun()\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = residents.index(max(residents))\nenergy = 0\nfor i, resident in enumerate(residents):\n energy += (abs(x - i) + i + x) * 2 * resident\nprint(energy)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nx=l.index(max(l))\n#print(x)\ns=0\ns+=2*l[0]*x\nfor i in range(1,n):\n\t#print(i,2*l[i]*(abs(i-x)+i+x))\n\ts+=2*l[i]*(abs(i-x)+i+x)\n\nprint(s)\n"}, {"source_code": "import sys\nfrom math import ceil\nif __name__ == \"__main__\":\n\n # single variables\n n = [int(val) for val in input().split()][0]\n\n # vectors\n a = [int(val) for val in input().split()]\n np = sum(a)\n\n c = [(ind+1)*val for ind, val in enumerate(a)]\n\n centroid = sum(c) / np\n X = [int(centroid), ceil(centroid)]\n best = float('inf')\n \n for x in X:\n summ = 0\n for ind, val in enumerate(a):\n summ += (abs(x - (ind+1)) + abs((ind+1) - 1) + abs(x - 1))*val\n\n best = min(best, summ)\n\n print(best*2)\n\n\n"}, {"source_code": "n = int(input())\na = [i for i in list(map(int, input().split()))]\nmax = 0\nsum = 0\nfor i in range(n):\n\tsum = 0\n\tfor j in range(n):\n\t\tif j == i:\n\t\t\tsum += a[i] * (i) * 2\n\t\telse:\n\t\t\tsum += a[j] * (abs(j - i) * 2) + (i) * 2\n\tif sum > max:\n\t\tmax = sum\n\t\t\nprint(max)"}, {"source_code": "inp=input()\ninp2=map(int,raw_input().split())\nbest=100000000\nfor i in range(105):\n ans=0\n for j,x in enumerate(inp2):\n ans+=2*2*max(j,i)*x\n # best=min(best,ans)\n if best>ans:\n best=ans\n print i,best\nprint best\n"}, {"source_code": "def flor(n,a):\n for i in range(n):\n if a[i] == 0:\n return a[0] *0\n elif len(a) == 2:\n return a[0]*0 + a[1] * 4\n else:\n return a[0]*0 + a[1] * 4 + a[2] * 8\n \n \n \n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nx=l.index(max(l))\n#print(x)\ns=0\ns+=2*l[0]*x\nfor i in range(1,n):\n\t#print(i,2*l[i]*(abs(i-x)+i+x))\n\ts+=2*l[i]*(abs(i-x)+i+x)\n\nprint(s)\n"}, {"source_code": "#!/usr/bin/env python3\n\n\"\"\" The Fair Nut lives in n story house. \n a_i people live on the i-th floor of the house. \n Every person uses elevator twice a day: \n to get from the floor where he/she lives to the ground (first) floor and \n to get from the first floor to the floor where he/she lives, \n when he/she comes back home in the evening.\n\n It was decided that elevator, when it is not used, \n will stay on the x-th floor, but x hasn't been chosen yet. \n When a person needs to get from floor a to floor b, \n elevator follows the simple algorithm:\n\n * Moves from the x-th floor (initially it stays on the x-th floor) \n to the a-th and takes the passenger.\n * Moves from the a-th floor to the b-th floor and lets out the passenger \n (if a equals b, elevator just opens and closes the doors, \n but still comes to the floor from the x-th floor).\n * Moves from the b-th floor back to the x-th.\n \n The elevator never transposes more than one person and \n always goes back to the floor x before transposing a next passenger. \n The elevator spends one unit of electricity to move between neighboring floors. \n So moving from the a-th floor to the b-th floor requires |a\u2009-\u2009b| units of electricity.\n\n Your task is to help Nut to find the minimum number of electricity units, \n that it would be enough for one day, by choosing an optimal the x-th floor. \n Don't forget than elevator initially stays on the x-th floor.\n\"\"\"\n\nn = int(input())\na = list(map(int, input().split()))\n\nx = a.index(max(a))\n\nu = []\nfor k, f in enumerate(a):\n u.append(4 * k * (abs(x - f) + x))\nprint(sum(u))\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Dec 10 22:12:00 2018\n\n@author: mach\n\"\"\"\n\nn = int(input())\n\nh = list(map(int, input().strip().split()))\ns = max(h)\nd = h.index(s)\nsums = 0\nfor i in range(n):\n if i <= d:\n \n sums+=4*d*h[i]\n else:\n sums += i *h[i]*4\nprint(sums)"}, {"source_code": "\n\ndef solve(n, arr):\n ans = 1000000\n\n for i in range(n):\n temp = 0\n for j in range(n):\n temp += (abs(j - i) + (j - 0) + i) * 2\n temp *= arr[j]\n ans = min(ans, temp)\n print(ans)\n\n\ndef main():\n n = int(input())\n arr = list(map(int, input().split()))\n\n solve(n, arr)\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = (n-1)//2\nenergy = 0\nfor i, resident in enumerate(residents):\n energy += (abs(x - i) + i + x) * 2 * resident\nprint(energy)"}, {"source_code": "n=int(input())\nli=input().split()\nc=0\nj=0\nfor i in range(n):\n li[i]=int(li[i])\n if i==0:\n continue\n if li[i]>c:\n c=li[i]\n j=i+1\nx=j\nu=0\nfor i in range(n):\n if i==0:\n continue\n u1=(x-(i+1))*li[i]\n u2=(i)*li[i]\n if u1<0:\n u1*=-1\n u3=(x-1)*li[i]\n u=u+u1+u2+u3\nprint(u*2)\n"}, {"source_code": "# ***********************************************\n#\n#\t\t\t\t\tachie27\n#\n# ***********************************************\n\ndef retarray():\n\treturn list(map(int, input().split()))\n\n\nn = int(input())\na = retarray()\na = [0] + a\n\ntotcost = 1000000\nfor x in range(1, n+1):\n\tcost = 0\n\tfor j in range(1, 1+n):\n\t\tcost+=2*(a[j] * abs(x-j) + (j-1)*a[j] + a[j] * (x-1))\n\tif cost < totcost:\n\t\ttotcost = cost\n\nprint(totcost) \t\n"}, {"source_code": "import sys\nn=int(input())\narr=[int(x) for x in input().split()]\nans=sys.maxsize\nfor x in range(1,n+1):\n\tt=0\n\tfor j in range(1,n+1):\n\t\tt+=2*(abs(x-j)+abs(j-1)+abs(1-x))\n\t\tt=t*arr[j-1]\n\tans=min(ans,t)\nprint(ans)\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split(' ')))\nmn = n * 2 * 200\nfor x in range(1, n + 1):\n sm = 0\n for i in range(1, n + 1):\n sm += a[i - 1] * (abs(x - i) + abs(i - 1) + abs(1 - x)) * 2\n mn = min(sm, mn)\nprint(mn)\n"}, {"source_code": "n = int(input())\np = list(map(int, input().strip().split()))\n\nx = p.index(max(p)) + 1\nans = 0\n\nfor i in range(1, len(p)):\n if i+1 <= x:\n ans += 2 ** x * p[i]\n else:\n ans += 2 ** (i + 1) * p[i]\n\nprint(ans)"}, {"source_code": "import math\nn = int(input())\na = list(map(int, input().strip().split()))\n\nminim = 10000000000000\nsu = 0\n\nfor j in range(1,len(a)):\n su = 0\n for i in range(2,len(a)+1):\n su += a[i-1]*(abs(j-i)+abs(i-1)+abs(j-1))*2\n if(minim>su):\n minim = su\n\n\n\nprint(minim)\n\n"}, {"source_code": "n = int(input())\na = [i for i in list(map(int, input().split()))]\nmax = 0\nsum = 0\nfor i in range(1, n):\n\tsum = 0\n\tfor j in range(1, n):\n\t\tif j == i:\n\t\t\tsum += a[i] * (i + 1) * 2\n\t\telse:\n\t\t\tsum += a[j] * (abs(j + 1 - i) * 2) + (i + 1) * 2\n\tif sum > max:\n\t\tmax = sum\n\t\t\nprint(max)"}, {"source_code": "n = int(input())\na = [0] + [int(a) for a in list(input().strip().split())]\nmn=9999999999999999\nfor f in range(2,n+1):\n sm=0\n for i in range(2,n+1):\n sm += (abs(f-i) + f-1 + i-1) * a[i]\n #print(f,i,sm)\n mn=min(mn,sm)\n\nprint(mn * 2)\n\n"}, {"source_code": "import sys\nimport operator\n\n\ndef main():\n n = int(sys.stdin.readline())\n arr = list(map(int, sys.stdin.readline().split()))\n arr = list(enumerate(arr))\n arr.sort(key=operator.itemgetter(1), reverse=True)\n # print(arr)\n check = arr[0][1]\n index = -1\n while index < n-1 and arr[index][1] == check:\n index += 1\n count = 0\n # print(index)\n # print(arr[index][0])\n for i in range(n):\n count += arr[i][1]*(2*(abs(arr[index][0]-arr[i][0]))+2*(arr[i][0]))\n print(count)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "\nt=int(input())\nb=list(map(int,input().split()))\nx=(b.index(max(b)))\na=[i for i in range(t)]\nc=list(zip(a,b))\n\nd=0\ng=0\nfor i in c:\n if i[1]>0:\n d=((abs(i[0]-x)*2)+abs(i[0]-a[0])+(abs(a[0]-x)*2)+abs(a[0]-i[0]))*i[1]\n g+=d\n else:\n continue\nprint(g)\n\n\n"}, {"source_code": "n = int(input())\na = [0] + [int(a) for a in list(input().strip().split())]\nmn=9999999999999999\nfor f in range(2,n+1):\n sm=0\n for i in range(2,n+1):\n sm += (abs(f-i) + f-1 + i-1) * a[i]\n #print(f,i,sm)\n mn=min(mn,sm)\n\nprint(mn * 2)\n\n"}, {"source_code": "n=int(input())\nli=input().split()\nc=0\nj=0\nfor i in range(n):\n li[i]=int(li[i])\n if i==0:\n continue\n if li[i]>=c:\n c=li[i]\n j=i+1\nx=j\nu=0\nfor i in range(n):\n if i==0:\n continue\n u1=(x-(i+1))*li[i]\n u2=(i)*li[i]\n if u1<0:\n u1*=-1\n u3=(x-1)*li[i]\n u=u+u1+u2+u3\nprint(u*2)\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\ndef get(x):\n ans = 0\n for i in a:\n cur = abs(x-i) + i + abs(x-i)\n ans += 2*cur\n return ans\nres = 10**18\nfor i in xrange(n):\n res = min(res,get(i))\nprint res"}, {"source_code": "n = int(input())\nnumOfPeople = list(map(int, input().split(' ')))\ncounter = 0\n\nwhile n > 1:\n\tcounter = counter + numOfPeople[n-1]*((2*n)- 2)\n\tn = n - 1\n\nprint(counter)\n"}, {"source_code": "inp=input()\ninp2=map(int,raw_input().split())\nbest=1000000\nfor i in range(100):\n ans=0\n for j,x in enumerate(inp2):\n ans+=2*2*j*x\n best=min(best,ans)\nprint best\n"}, {"source_code": "n = int(input())\nnums = input().split()\nresidents = [int(item) for item in nums]\nx = residents.index(max(residents)) + 1\nenergy = 0\n\nfor resident in residents:\n energy += (abs(x - residents.index(resident)) + residents.index(resident) + x + residents.index(resident)) * resident \nprint(energy)"}, {"source_code": "def main():\n n = int(input())\n l = list(map(int, input().split()))\n x = n - l[::-1].index(max(l)) - 1\n \n c = 0\n \n for i in range(n):\n if i == x:\n c += l[i]*2*(x+1)\n else:\n c += l[i]*i*2\n \n print(c)\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n=int(input())\nli=input().split()\nc=0\nj=0\nfor i in range(n):\n li[i]=int(li[i])\n if i==0:\n continue\n if li[i]>=c:\n c=li[i]\n j=i+1\nx=j\nu=0\nfor i in range(n):\n if i==0:\n continue\n u1=(x-(i+1))*li[i]\n u2=(i)*li[i]\n if u1<0:\n u1*=-1\n u3=(x-1)*li[i]\n u=u+u1+u2+u3\nprint(u*2)\n"}, {"source_code": "n=int(input())\nl=[int(i) for i in input().strip().split()]\ndef solve(x):\n ans=0\n for i in range(n):\n ans=ans+(max(x,i))*l[i]*2*2\n return(ans)\nfans=10**9\nfor i in range(n):\n tans=solve(i)\n print(i,tans)\n fans=min(fans,tans)\nprint(fans)\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nbill = float(\"inf\")\nfor i in range(n):\n\tt = 0\n\tfor j in range(n):\n\t\tt = t +(j)*l[j]*4 + (abs(j-i)+abs(i))-1\n\tbill = min(t,bill)\nprint(bill)\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nans_min = 1000000\nfor x in range(n):\n ans = 0\n for i in range(n):\n ans += (abs(i - x) + i + x) * 2 * a[i]\n ans_min = min(ans, ans_min)\nprint(ans_min)"}, {"source_code": "num_floor=input('')\nnum_floor=int(num_floor)\nfloor_count=input('')\nfloor_count_list=floor_count.split(' ')\nfloor_count_list=[int(x) for x in floor_count_list]\nfloor=0\nmax_ppl=floor_count_list.index(max(floor_count_list))+1\nresult=0\nelectricty_count=0\nfor numppl in floor_count_list:\n floor+=1\n if numppl!=0:\n \n floor_drive=abs(floor-max_ppl)\n floor_drive+=abs(max_ppl-1)\n floor_drive=floor_drive*2\n electricty_count+=numppl*(floor_drive+(2*(floor-1)))\n\n\n\nprint(electricty_count)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nx=l.index(max(l))\nprint(x)\ns=0\ns+=2*l[0]*x\nfor i in range(1,n):\n\tprint(i,2*l[i]*(abs(i-x)+i+x))\n\ts+=2*l[i]*(abs(i-x)+i+x)\n\nprint(s)\n"}, {"source_code": "x=int(input())\nl=[0]+list(map(int,input().split()))\nlevel=l.index(max(l))\ncounter=0\nfor i in range(2,x+1):\n counter+=abs(level-i)*2*l[i]\n counter+=+abs(level-1)*2*l[i]\n counter+=(i-1)*l[i]*2\nprint(counter)"}, {"source_code": "inp=input()\ninp2=map(int,raw_input().split())\nbest=1000000\nfor i in range(100):\n ans=0\n for j,x in enumerate(inp2):\n ans+=2*2*j*x\n best=min(best,ans)\nprint best\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = map(int,stdin.readline().split())\ndef get(x):\n ans = 0\n for i in xrange(n):\n cur = abs(x-i) + i + abs(x-i)\n ans += 2*cur*a[i]\n return ans\nres = 10**18\nfor i in xrange(n):\n res = min(res,get(i))\nprint res"}, {"source_code": "# 1084 A\n\nimport os\nimport math\nf = input()\nx = math.ceil(float(f)/2.0)\np = []\nsum = 0.0\none_way = 0\nptemp = raw_input()\nptemp = ptemp.split(\" \")\nfor j in ptemp:\n p.append(int(j))\nfor i in range(1,f+1):\n if(p[i-1]!=0):\n one_way = one_way + p[i-1]*((abs(x-i))+(i-1)+(x-1))\nprint(int(one_way*2))\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nx=l.index(max(l))\nprint(x)\ns=0\ns+=2*l[0]*x\nfor i in range(1,n):\n\tprint(i,2*l[i]*(abs(i-x)+i+x))\n\ts+=2*l[i]*(abs(i-x)+i+x)\n\nprint(s)\n"}, {"source_code": "n = int(input())\nflours = list(map(int, input().split()))\nbest = 1000000\nfor x in range (n):\n sum = 0\n for i in range (n):\n if i <= x:\n sum += (x * 4) * flours[i]\n\n else:\n sum += (i * 4) * flours[i]\n if best > sum:\n best = sum\n\nprint(best)\n\n\n"}, {"source_code": "def main():\n n = int(input())\n l = list(map(int, input().split()))\n x = n - l[::-1].index(max(l)) - 1\n \n c = 0\n \n for i in range(n):\n if i == x:\n c += l[i]*2*(x+1)\n else:\n c += l[i]*i*2\n \n print(c)\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/env python3\n\nn = int(input())\na = list(map(int, input().split()))\n\nx = a.index(max(a))\n\nu = []\nfor f, k in enumerate(a):\n u.append(4 * k * (abs(x - f) + x))\nprint(sum(u))\n"}, {"source_code": "\nn = int(input())\nl = list(map(int, input().split()))\n\n\nx = l.index(max(l))\n\nans = 0\nfor i in range(n):\n\tans += l[i] * (i + abs(i - x) + x) * 2\n\t\n\nprint(ans)"}, {"source_code": "import sys\nn=int(input())\narr=[int(x) for x in input().split()]\nans=sys.maxsize\nfor x in range(1,n+1):\n\tt=0\n\tfor j in range(1,n+1):\n\t\tt+=2*(abs(x-j)+abs(j-1)+abs(1-x))\n\t\tt=t*arr[j-1]\n\tans=min(ans,t)\nprint(ans)\n"}, {"source_code": "n = int(input())\na = [0] + [int(a) for a in list(input().strip().split())]\nmn=9999999999999999\nfor f in range(2,n+1):\n sm=0\n for i in range(2,n+1):\n sm += (abs(f-i) + f-1 + i-1) * a[i]\n #print(f,i,sm)\n mn=min(mn,sm)\n\nprint(mn * 2)\n\n"}, {"source_code": "import math\nn = int(input())\na = list(map(int, input().strip().split()))\n\nm = 10000000000000\nsu = 0\n\nfor j in range(1,len(a)):\n su = 0\n for i in range(1,len(a)+1):\n su += a[i-1]*(abs(j-i)+abs(i-1)+abs(j-1))\n if(su < m):\n m = su\n\nprint(2*su)\n\n\n\n\n"}, {"source_code": "def calc(a,x):\n sum = 0\n for values in a:\n sum+= abs(values-1)+abs(x-1)+abs(values-x)\n return sum\n\nn = int(input())\na = []\na = input()\na = list(map(int,a.split()))\ntemp = []\nfor i in range(1,n+1):\n temp.append(calc(a,i))\nprint(min(temp))\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nbill = float(\"inf\")\nfor i in range(n):\n\tt = 0\n\tfor j in range(n):\n\t\tt = t +(j)*l[j]*4 + (abs(j-i)+abs(i))-1\n\tbill = min(t,bill)\nprint(bill)\n"}, {"source_code": "\n\ndef solve(n, arr):\n ans = 1000000\n\n for i in range(n):\n temp = 0\n for j in range(n):\n temp += (abs(j - i) + (j - 0) + i) * 2\n temp *= arr[j]\n ans = min(ans, temp)\n print(ans)\n\n\ndef main():\n n = int(input())\n arr = list(map(int, input().split()))\n\n solve(n, arr)\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = input()\ncc = input().split(\" \")\nsum =0\nfor i in range(len(cc)):\n sum = sum + (int(cc[i-1]) *((i)*4))\nprint(sum)"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nbill = float(\"inf\")\nfor i in range(n):\n\tt = 0\n\tfor j in range(n):\n\t\tt = t +(j)*l[j]*4 + (abs(j-i)+abs(i))-1\n\tbill = min(t,bill)\nprint(bill)\n"}], "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f"} {"source_code": "n = int(input())\nls, MOD = [1]*(n+1), 998244353\nfor i in range(3, n+1):\n ls[i] = (ls[i-1]+ls[i-2])%MOD\nu = ls[n]*pow(pow(2, n, MOD), MOD-2, MOD)\nprint(u%MOD)", "positive_code": [{"source_code": "def modInverse(a,m): \n m0=m\n y,x=0,1\n if (m==1): return 0\n while(a>1):\n q=a//m\n t=m\n m=a%m\n a=t\n t=y\n y=x-q*y\n x=t\n if(x<0): return(x+m0)\n else: return(x)\n\nn=int(input())\nmod=998244353\n\nif(n<=2):\n print(modInverse(pow(2,n,mod),mod))\nelse:\n l=1\n r=1\n for _ in range(n-2):\n mem=r\n r=(l+r)%mod\n l=mem\n print((r*modInverse(pow(2,n,mod),mod))%mod)"}, {"source_code": "\"\"\"T=int(input())\nfor _ in range(0,T):\n n=int(input())\n a,b=map(int,input().split())\n s=input()\n s=[int(x) for x in input().split()]\n for i in range(0,len(s)):\n a,b=map(int,input().split())\"\"\"\n\n\nMOD = 998244353\n\ndef powr(n,N):\n temp=1\n while(N>0):\n if(N%2!=0):\n temp=(temp*n)%MOD\n n=(n*n)%MOD\n N=N//2\n return (temp%MOD)\n\n\nn=int(input())\nL=[0,1]\nfor i in range(2,n+1):\n L.append((L[-1]+L[-2])%MOD)\n\nnum = L[-1]%MOD\ndem = powr(2,n)%MOD\ntt = pow(dem, MOD-2, MOD)%MOD\nans=(num*tt)%MOD\nprint(ans)\n"}, {"source_code": "import sys\nimport math,bisect\nsys.setrecursionlimit(10 ** 6)\nfrom itertools import groupby,accumulate\nfrom heapq import heapify,heappop,heappush\nfrom collections import deque,Counter,defaultdict\nI = lambda : int(sys.stdin.readline())\nneo = lambda : map(int, sys.stdin.readline().split())\nNeo = lambda : list(map(int, sys.stdin.readline().split()))\nn = I()\nm = 998244353\ndef fib(n): \n \n F = [[1, 1], \n [1, 0]] \n if (n == 0): \n return 0\n power(F, n - 1) \n \n return F[0][0] \n \ndef multiply(F, M): \n \n x = (F[0][0] * M[0][0] + \n F[0][1] * M[1][0]) \n y = (F[0][0] * M[0][1] + \n F[0][1] * M[1][1]) \n z = (F[1][0] * M[0][0] + \n F[1][1] * M[1][0]) \n w = (F[1][0] * M[0][1] + \n F[1][1] * M[1][1]) \n \n F[0][0] = x \n F[0][1] = y \n F[1][0] = z \n F[1][1] = w \n \n# Optimized version of \n# power() in method 4 \ndef power(F, n): \n \n if( n == 0 or n == 1): \n return; \n M = [[1, 1], \n [1, 0]]; \n \n power(F, n // 2) \n multiply(F, F) \n \n if (n % 2 != 0): \n multiply(F, M) \nprint((fib(n)*pow(2**n,m-2,m))%m) "}, {"source_code": "M = 998244353\nn = int(input())\na, b = 0, 1\nfor i in range(2, n+1):\n a, b = b, (a+b)%M\nprint((b * pow(2, n*(M-2), M))%M)"}, {"source_code": "M = 998244353\n\ndef inv2(a, mod):\n res, b = 1, mod - 2\n while b != 0:\n if b & 1:\n res = res * a % mod\n a, b = a*a % mod, b >> 1\n return res\nn = int(input())\na, b = 1, 1\nfor i in range(3, n+1):\n a, b = b, (a+b)%M\n\nprint((b * inv2(pow(2, n, M), M))%M)"}, {"source_code": "M = 998244353\nn = int(input())\na, b = 0, 1\nfor i in range(2, n+1):\n a, b = b, (a+b)%M\nprint((b * pow(2, n*(M-2), M))%M)"}, {"source_code": "def gcd_extended(a, b):\n # Base Case\n if a == 0:\n return b, 0, 1\n gcd, x1, y1 = gcd_extended(b % a, a)\n # Update x and y using results of recursive call\n x = y1 - (b // a) * x1\n y = x1\n return gcd, x, y\n\n\ndef power(a, n, p):\n if n == 0:\n return 1\n x = power(a, n//2, p)\n x = (x * x) % p\n if n % 2 == 1:\n x = (x * a) % p\n return x % p\n\n\np = 998244353\nn = int(input())\n# n = 200000\n\nrev_2 = gcd_extended(2, p)[1] % p\n# a = [1, 0.5]\na = [1, rev_2]\nc = [1, rev_2]\n\npowers = [1]\nrev_powers = [1]\nfor i in range(1, 2 * 10 ** 5 + 1):\n powers.append((powers[-1] * 2) % p)\n rev_powers.append((rev_powers[-1] * rev_2) % p)\n\nfor k in range(2, n + 1):\n l = 1\n s = 0\n maxp = k if k % 2 == 1 else k - 1\n\n if k < 3:\n while l <= k:\n s += (a[k - l] * powers[maxp - l]) % p\n l += 2\n c.append(int((s * rev_2 ** (k - 1))) % p)\n else:\n c.append(int(((c[k - 2] * rev_2 * rev_2) + (c[k - 1] * rev_2)) % p))\n\nprint(c[n])"}, {"source_code": "n = int(input())\nfib = [0, 1, 1]\ntotal = [1, 2, 4]\nMOD = 998244353\nfor i in range(3, n+1):\n fib.append((fib[i-1] + fib[i-2]) % MOD)\n total.append(total[i-1] * 2 % MOD)\n\ndef modInverse(a, m): \n m0 = m \n y = 0\n x = 1\n \n if (m == 1): \n return 0\n \n while (a > 1): \n \n # q is quotient \n q = a // m \n \n t = m \n \n # m is remainder now, process \n # same as Euclid's algo \n m = a % m \n a = t \n t = y \n \n # Update x and y \n y = x - q * y \n x = t \n \n # Make x positive \n if (x < 0): \n x = x + m0 \n \n return x \n\nprint(fib[n] * modInverse(total[n], MOD) % MOD)"}, {"source_code": "def modinv(a,m):\n b=m\n u=1\n v=0\n while b:\n t=a//b\n a-=t*b\n a,b=b,a\n u-=t*v\n u,v=v,u\n u%=m\n return u\nn=int(input())\nMOD=998244353\ndpsum=[0]*(n+1)\ndp=1\nfor i in range(n):\n dpsum[i+1]=(dp+dpsum[i])%MOD\n dp=dpsum[i]%MOD\nans=dpsum[n]\ndiv=modinv(2,MOD)\nfor _ in range(n):\n ans*=div\n ans%=MOD\nprint(ans)"}, {"source_code": "mod=998244353\nn = int(input())\na = 1\nb = 1\nm=pow(2,n)\nn -= 2\nwhile (n>0):\n a, b = b % mod, (a + b) % mod\n n -= 1\n\nwhile (b % 2 == 0):\n b = b >> 1\n m = m >> 1\nprint((b * pow(m, mod - 2, mod)) % mod)"}, {"source_code": "from sys import stdin\nmod = 998244353\na = [1,1,1]\nn = int(stdin.readline())\nwhile len(a)<n+1:\n a.append(a[-1] + a[-2])\n if a[-1] >=mod:\n a[-1]-=mod\nden = pow(2,mod-2,mod)\nden = pow(den,n,mod)\nprint (a[n]*den)%mod"}, {"source_code": "n=input()\ndp=[1,1,1,2,3]\nmod=998244353\n\nfor i in range(n):\n dp.append((dp[-1]+dp[-2])%mod)\nrr=dp[n]\ncnt=0\nwhile dp[n]%2==0:\n dp[n]/=2\n cnt+=1\ng=pow(2,n-cnt,mod)\n\ngg=pow(g,mod-2,mod)\nprint (dp[n]*gg)%mod\n"}, {"source_code": "from sys import stdin\nmod = 998244353\na = [1,1,1]\nn = int(stdin.readline())\nwhile len(a)<n+1:\n a.append(a[-1] + a[-2])\n if a[-1] >=mod:\n a[-1]-=mod\nden = pow(2,mod-2,mod)\nden = pow(den,n,mod)\nprint (a[n]*den)%mod"}, {"source_code": "##################################### \nimport atexit, io, sys , collections, heapq\nbuffer = io.BytesIO() \nsys.stdout = buffer\n@atexit.register \ndef write(): sys.__stdout__.write(buffer.getvalue()) \n##################################### \nmod = 998244353\nn = int(raw_input())\ndef f(n):\n\n\tif n <= 1:\n\t\treturn 1\n\tso = 1\n\tse = 1\n\tfor t in range(2, n + 1):\n\t\tif t % 2:\n\t\t\tso += se\n\t\t\tso %= mod\n\t\telse:\n\t\t\tse += so\n\t\t\tse %= mod\n\treturn se if n % 2 else so\n\ndef pow(a,n):\n\tif n == 0:return 1\n\tr = pow(a, n//2) % mod\n\treturn r * r * (a if n % 2 else 1) % mod\n\na = f(n)\nb = 1\nwhile(n):\n\tb *= 2\n\tb %= mod\n\tn-=1\n\t#pow(2,n)\n#print a,b\nprint a * pow(b, mod-2) % mod"}, {"source_code": "mo = 998244353\n\ndef ge(n):\n a = [0] * (n + 5)\n a[1] = 1\n a[2] = 1\n for i in range(3, n + 1):\n a[i] = a[i - 1] + a[i - 2]\n a[i] %= mo\n return a[n]\n\ndef min_y(b, n):\n # print (b, n)\n if (n == 1):\n return b\n if (n % 2 == 0):\n return min_y(b * b % mo, n // 2) % mo\n return b * min_y(b % mo, n - 1) % mo\n\nn = int(input())\nget_n = ge(n)\nans = min_y(2, n*(mo - 2) % (mo - 1))\n\nprint(get_n * ans % mo)\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nfrom collections import defaultdict as dc\nfrom collections import Counter\nfrom bisect import bisect_right, bisect_left\nimport math\nfrom operator import itemgetter\nfrom heapq import heapify, heappop, heappush\nn=int(input())\nm=998244353\nif n==1:\n c=1\nelse:\n a=0\n b=1\n m=998244353\n for i in range(2,n+1):\n c=a+b\n a=b\n b=c\np=pow(2,n,m)\ny=pow(p,m-2,m)\nprint((c*y)%m)"}, {"source_code": "import io, os\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nn=int(input())\ndef modInverse(a,m): \n m0=m \n y=0\n x=1\n if (m == 1): \n return 0\n while (a > 1): \n q=a//m \n t=m \n m=a%m \n a=t \n t=y \n y=x-q*y \n x=t \n if x<0: \n x=x+m0 \n return x \ndef power(x,y,z):\n if y==0:\n return 1\n temp=power(x,y//2,z)\n if y%2==0:\n return (temp*temp)%z\n return (x*temp*temp)\nz=998244353\nb=power(2,n,z)\ndef fib(n):\n if n<3:\n return 1\n a=1\n b=1\n for i in range(n-2):\n if i%2==0:\n a+=b\n else:\n b+=a\n return max(a,b)\na=fib(n)\na=a%z\nc=modInverse(b,z)\na*=c\na%=z\nprint(a)"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \n \ndef main():\n n = int(input())\n a,b=1,1\n for i in range(n-2):\n a,b = a+b,a\n \n N = 998244353\n def exponentiation(bas, exp): \n t = 1;\n while(exp > 0): \n \n # for cases where exponent \n # is not an even value \n if (exp % 2 != 0): \n t = (t * bas) % N\n \n bas = (bas * bas) % N\n exp = exp//2; \n return t % N; \n\n print((a*exponentiation(2,n*(N-2)))%N)\n \n \n\n\n\n \n\n\n\n# region fastio\n \nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = int(input())\nm = 998244353\nx,y=0,1\nfor i in range(n-1):\n x,y = y,x+y\n x%=m\n y%=m\nr = pow(2,n,m)\nprint((y*pow(r,m-2,m))%m)"}, {"source_code": "n = int(input())\nmod = 998244353\ndp = [0] * (n + 5)\nodd_s = 0\neven_s = 1\ndp[0] = 1\nfor i in range(1, n + 5):\n if i % 2 == 0:\n dp[i] = odd_s\n even_s += dp[i]\n even_s %= mod\n else:\n dp[i] = even_s\n odd_s += dp[i]\n odd_s %= mod\nbunbo = pow(2, n, mod)\nans = dp[n] * pow(bunbo, mod - 2, mod)\nprint(ans % mod)\n"}, {"source_code": "def calculate(p, q): \n\t\n\tmod = 998244353\n\texpo = 0\n\texpo = mod - 2\n\n\t# Loop to find the value \n\t# until the expo is not zero \n\twhile (expo): \n\n\t\t# Multiply p with q \n\t\t# if expo is odd \n\t\tif (expo & 1): \n\t\t\tp = (p * q) % mod \n\t\tq = (q * q) % mod \n\n\t\t# Reduce the value of \n\t\t# expo by 2 \n\t\texpo >>= 1\n\n\treturn p \n\nn=int(input())\na=0;b=1\nfor j in range(2,n+1):\n a,b=b,a+b\nprint(calculate(b,2**n))"}, {"source_code": "n = int(input())\ndef fib (a):\n ans1 = 1\n ans2 = 1\n t = a\n while t > 0:\n t -= 1\n k = ans1\n ans1 += ans2\n ans2 = k\n return ans1\ndef binpow (a, b):\n if b == 0:\n return 1\n elif b % 2 == 1:\n return (binpow(a, b - 1) * a) % 998244353\n else:\n k = binpow(a, b / 2)\n return (k * k) % 998244353\nm = 0\nif n < 4:\n m = n - 1\nelse:\n m = fib(n - 2)\nif n == 1:\n print(499122177)\nelse:\n l = binpow(2, n)\n ans = (m * binpow(l, 998244351)) % 998244353\n print(ans)\n\n\n\n"}, {"source_code": "MOD = 998244353\n\n\ndef read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split()))\n\n\ndef print_nums(nums):\n print(\" \".join(map(str, nums)))\n\n\ndef gcd(a, b):\n if a == 0:\n return b\n return gcd(b, a % b)\n\n\ndef xgcd(a, b):\n \"\"\"return (g, x, y) such that a*x + b*y = g = gcd(a, b)\"\"\"\n x0, x1, y0, y1 = 0, 1, 1, 0\n while a != 0:\n (q, a), b = divmod(b, a), a\n y0, y1 = y1, y0 - q * y1\n x0, x1 = x1, x0 - q * x1\n return b, x0, y0\n\n\ndef modinv(a, m):\n \"\"\"return x such that (a * x) % m == 1\"\"\"\n g, x, _ = xgcd(a, m)\n if g != 1:\n raise Exception('gcd(a, m) != 1')\n return x % m\n\n\ndef fib(n):\n a, b = 0, 1\n for _ in range(n):\n a, b = b, a + b\n return a\n\n\ndef fib_ns(n):\n assert n >= 1\n f = [0 for _ in range(n + 1)]\n f[0] = 0\n f[1] = 1\n for i in range(2, n + 1):\n f[i] = f[i - 1] + f[i - 2]\n return f\n\n\ndef mod_add(x, y):\n x += y\n while x >= MOD:\n x -= MOD\n while x < 0:\n x += MOD\n return x\n\n\ndef mod_mul(x, y):\n return (x * y) % MOD\n\n\ndef mod_pow(x, y):\n if y == 0:\n return 1\n if y % 2:\n return mod_mul(x, mod_pow(x, y - 1))\n p = mod_pow(x, y // 2)\n return mod_mul(p, p)\n\n\ndef mod_div(x, y):\n return mod_mul(x, mod_pow(y, MOD - 2))\n\n\nn = read_int()\nans = mod_div(fib(n), mod_pow(2, n))\nprint(ans)\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nM = 998244353\ndef fib(n):\n if n == 1:\n return 1\n elif n == 2:\n return 1\n else:\n a,b = 1,1\n for _ in range(n - 2):\n c = (a + b) % M\n a = b\n b = c\n return b % M\n\nprint((fib(n) * pow(pow(2, n), M - 2, M)) % M)"}, {"source_code": "def mod(a,m):\n if a>m:\n return a%m\n return a\n\ndef main():\n n = int(input())\n a, b, z, m = 0, 1, 1, 998244353\n while z != n:\n c = mod(a + b, m)\n a = b\n b = c\n z += 1\n xx = pow(pow(2, n, m), m - 2, m)\n print(mod(xx * b, m))\nmain()"}, {"source_code": "##################################### \nimport atexit, io, sys , collections, heapq\nbuffer = io.BytesIO() \nsys.stdout = buffer\n@atexit.register \ndef write(): sys.__stdout__.write(buffer.getvalue()) \n##################################### \nmod = 998244353\n\nn = int(raw_input())\nmem = [1] * (n+1)\ndef f(n):\n\n\tif n == 1: return 1\n\tif n == 0: return 1\n\tif n <= 1:\n\t\treturn 1\n\tu,v = 1,1\n\tans = 0\n\t\"\"\"\n\tf(0) = 1\n\tf(1) = 1\n\tf(2) = f(1)\n\tf(3) = f(2) + f(0)\n\t = 2\n\tf(4) = f(3) + f(1)\n\t = 2 + 1\n\t = 3\n\tf(5) = f(4) + f(2) + f(0)\n\t\"\"\"\n\tqo = collections.deque([1])\n\tso = 1\n\tqe = collections.deque([1])\n\tse = 1\n\tfor t in range(2, n + 1):\n\t\tif t % 2:\n\t\t\tso += se\n\t\t\tso %= mod\n\t\t\tqo.append(se)\n\t\telse:\n\t\t\tse += so\n\t\t\tse %= mod\n\t\t\tqe.append(so)\n\treturn se if n % 2 else so\n\ndef pow(a,n):\n\tif n == 0:return 1\n\tr = pow(a, n//2) % mod\n\treturn r * r * (a if n % 2 else 1) % mod\n\n\na = f(n)\nb = pow(2,n)\n#print a,b\nprint a * pow(b, mod-2) % mod"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\ndef getint(): return int(input())\ndef getints(): return list(map(int, input().split()))\ndef getint1(): return list(map(lambda x: int(x) - 1, input().split()))\n\n\ndef fib(n):\n if n==1:\n return 1\n elif n==2:\n return 1\n else:\n a = 1\n b = 1\n for i in range(n-2):\n c = a+b\n a = b\n b = c\n return b\n\ndef main():\n ###CODE\n m = 998244353\n n = getint()\n v = fib(n) % m\n # den = pow(2,n)\n # den = pow(den,m-2,m)\n den = pow(2,n*m-2*n,m)\n print((v*den) % m)\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "mod = 998244353\n\ndef fib(n):\n # Declare a list to store\n # Fibonacci numbers.\n f = list()\n\n # 0th and 1st number of the\n # series are 0 and 1\n f.append(0)\n f.append(1)\n\n i = 2\n while i < n + 1:\n # Add the previous 2 numbers\n # in the series and store it\n f.append((f[i - 1] + f[i - 2])%mod)\n i += 1\n return f[n]%mod\n\n\n# Return number of ways to write 'n'\n# as sum of odd integers\ndef countOddWays(n):\n return fib(n)%mod\n\n\ndef modInverse(a, m):\n m0 = m\n y = 0\n x = 1\n\n if (m == 1):\n return 0\n\n while (a > 1):\n # q is quotient\n q = a // m\n\n t = m\n\n # m is remainder now, process\n # same as Euclid's algo\n m = a % m\n a = t\n t = y\n\n # Update x and y\n y = x - q * y\n x = t\n\n # Make x positive\n if (x < 0):\n x = x + m0\n\n return x\n\n\nn111 = int(input())\n\nout1 = countOddWays(n111)\nbase = pow(2,n111,mod)\nout2 = modInverse(base,mod)\nprint((out1*out2)%mod)\n"}, {"source_code": "from __future__ import division,print_function\n\nmo=998244353\ndemi=pow(2,mo-2,mo)\nquart=pow(4,mo-2,mo)\nn=int(input())\nP=[1]\nsp=0\nsi=0\nfor k in range(1,n+1):\n if k%2:\n si=(demi*P[k-1]+si*quart)%mo\n P.append(si)\n else:\n sp= (demi*P[k-1]+sp*quart)%mo\n P.append(sp)\n#for k in range(1,n+1):\n# P.append(sum(2**(-i)*P[k-i] for i in range(1,k+1,2)))\nprint(P[-1])\n"}, {"source_code": "MOD=998244353\n\n\nn=int(input())\n\ndp=[0 for _ in range(n+1)] #dp[n] is the number of ways to cover n exactly\n#dp[n]=dp[n-1]+dp[n-3]+...=dp[n-1]+dp[n-2]\n\nfor i in range(1,n+1):\n if i==1:\n dp[i]=1\n elif i==2:\n dp[i]=1\n else:\n dp[i]=dp[i-1]+dp[i-2]\n dp[i]%=MOD\n\nnWays=dp[n]\n#print(nWays)\n#den=2**n\nden=pow(2,n,MOD)\n\nans=(nWays*pow(den,MOD-2,MOD))%MOD\nprint(ans)"}, {"source_code": "x, y = 0, 0\n\ndef extgcd(a, b):\n global x, y\n\n if b == 0:\n x, y = 1, 0\n return a\n else:\n x, y = y, x\n d = extgcd(b, a % b)\n x, y = y, x\n y -= (a // b) * x\n return d\n\ndef fib(n):\n f1, f2 = 0, 1\n for i in range(n):\n tmp = f2\n f2 = f1 + f2\n f1 = tmp\n return f1\n\ndef sol(n):\n a = 2 ** n\n b = 998244353\n extgcd(a, b)\n\n global x, y\n while x < 0:\n x += b\n# print(fib(n))\n print((x * fib(n)) % b)\n\nsol(int(input()))\n"}, {"source_code": "import sys\nif sys.subversion[0] == \"PyPy\":\n import io, atexit\n sys.stdout = io.BytesIO()\n atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n \n sys.stdin = io.BytesIO(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip()\n\nRS = raw_input\nRI = lambda x=int: map(x,RS().split())\nRN = lambda x=int: x(RS())\n''' ...................................................................... '''\n\nmod = 998244353\n\nn = RN()\n\ndp = [0]*(n+1)\ndp[1] = 1\n\nfor i in xrange(2,n+1):\n dp[i] = (dp[i-1]+dp[i-2])%mod\n\nden = pow(2,n*(mod-2),mod)\nprint (dp[-1]*den)%mod\n \n"}, {"source_code": "x, y = 0, 0\n\ndef extgcd(a, b):\n global x, y\n\n if b == 0:\n x, y = 1, 0\n else:\n x, y = y, x\n extgcd(b, a % b)\n x, y = y, x\n y -= (a // b) * x\n\ndef fib(n):\n f1, f2 = 0, 1\n for _ in range(n):\n f1, f2 = f2, f1 + f2\n return f1\n\ndef sol(n):\n a = 2 ** n\n b = 998244353\n extgcd(a, b)\n\n global x, y\n while x < 0:\n x += b\n print((x * fib(n)) % b)\n\nsol(int(input()))\n"}, {"source_code": "from collections import defaultdict as dd\nimport sys\nmod=998244353\ninput=sys.stdin.readline\nn=int(input())\nos=0\nes=0\ndp=[0]*(n+5)\ndp[0]=1\ndp[1]=1\ndp[2]=1\nes=1\nos=2\nfor i in range(3,n+1):\n if(i%2):\n dp[i]=os\n es=(es+dp[i])%mod\n else:\n dp[i]=es\n os=(os+dp[i])%mod\n#print(dp)\nnum=dp[n]\nden=pow(2,n,mod)\niden=pow(den,mod-2,mod)\nres=(num*iden)%mod\nprint(res)\n "}, {"source_code": "\nM = 998244353 \nn=int(input())\na,b=1,1\nfor i in range(n-1):a,b=b,a+b\nprint(a*pow(1<<n,M-2,M)%M)"}, {"source_code": "M = 998244353\nn = int(input())\nF = [1,1,1]\nfor i in range(n-2):F.append((F[-1] + F[-2]) % M)\nprint((F[-1] * pow(2, M-n-1, M))%M)"}, {"source_code": "MOD = 998_244_353\n\n\ndef pow_mod(a, b):\n result = 1 % MOD\n while b:\n if b & 1:\n result *= a\n result %= MOD\n b >>= 1\n a **= 2\n a %= MOD\n return result\n\n\nn = int(input())\n\ncorrect_states_ns_mod = [None] * (n+1)\ncorrect_states_ns_mod[0] = 1 % MOD\nprefix_sum_for_even_mod = 1 % MOD\nprefix_sum_for_odd_mod = 0\nfor curr_n in range(1, n+1):\n if curr_n % 2 == 0:\n correct_states_ns_mod[curr_n] = prefix_sum_for_odd_mod\n prefix_sum_for_even_mod += correct_states_ns_mod[curr_n]\n if prefix_sum_for_even_mod >= MOD:\n prefix_sum_for_even_mod -= MOD\n else:\n correct_states_ns_mod[curr_n] = prefix_sum_for_even_mod\n prefix_sum_for_odd_mod += correct_states_ns_mod[curr_n]\n if prefix_sum_for_odd_mod >= MOD:\n prefix_sum_for_odd_mod -= MOD\n\n\nstates_n_mod = 1\nfor curr_n in range(1, n+1):\n states_n_mod *= 2\n if states_n_mod >= MOD:\n states_n_mod -= MOD\n\n\nresult = correct_states_ns_mod[n] * pow_mod(states_n_mod, MOD-2) % MOD\nprint(result)\n"}, {"source_code": "mod = 998244353\ndef solve():\n n = int(input())\n deg = n\n f = [0 for i in range(n + 3)]\n f[0] = 0\n f[1] = 1\n f[2] = 1\n for i in range(3, n + 3):\n f[i] = (f[i - 1] + f[i - 2]) % mod\n n = f[n]\n while n % 2 == 0:\n n //= 2\n deg -= 1\n ans = (n * pow(2, deg * (mod - 2), mod)) % mod\n print(ans)\nt = 1\n#t = int(input())\nwhile t > 0:\n solve()\n t -= 1"}, {"source_code": "mod = 998244353\ndef solve():\n n = int(input())\n deg = n\n f = [0 for i in range(n + 3)]\n f[0] = 0\n f[1] = 1\n f[2] = 1\n for i in range(3, n + 3):\n f[i] = (f[i - 1] + f[i - 2]) % mod\n n = f[n]\n while n % 2 == 0:\n n //= 2\n deg -= 1\n ans = (n * pow(2, deg * (mod - 2), mod)) % mod\n print(ans)\nt = 1\n#t = int(input())\nwhile t > 0:\n solve()\n t -= 1"}, {"source_code": "#from math import *\nfrom bisect import *\nfrom collections import *\nfrom random import *\nfrom decimal import *\nfrom random import *\nimport sys\ninput=sys.stdin.readline\ndef inp():\n return int(input())\ndef st():\n return input().rstrip('\\n')\ndef lis():\n return list(map(int,input().split()))\ndef ma():\n return map(int,input().split())\nt=1\np=998244353\nwhile(t):\n t-=1\n n=inp()\n if(n==1):\n de=pow(2,n,p)\n de=pow(de,p-2,p)\n print(de%p)\n exit(0)\n pr=[1,2]\n for i in range(n-2):\n pr.append((pr[-1]+pr[-2])%p)\n nu=pr[n-2]\n de=pow(2,n,p)\n de=pow(de,p-2,p)\n print(int((nu*de)%p))\n \n"}, {"source_code": "modulus = 998244353\nn = int(input().strip())\nfib0, fib1 = 1, 1\nfor i in range(n - 1):\n fib0, fib1 = fib1, fib0 + fib1\nprint(((fib0 * pow(2, modulus - n - 1, modulus)) % modulus))\n"}, {"source_code": "from sys import stdin,stdout\nimport math,bisect\nfrom collections import Counter,deque,defaultdict\nL=lambda:list(map(int, stdin.readline().strip().split()))\nM=lambda:map(int, stdin.readline().strip().split())\nI=lambda:int(stdin.readline().strip())\nS=lambda:stdin.readline().strip()\nC=lambda:stdin.readline().strip().split()\ndef pr(a):print(\" \".join(list(map(str,a))))\n#_________________________________________________#\n\n\ndef mp(n,a,m):\n if n==0:\n return 1\n x = mp(n//2,a,m)\n if n%2==1:\n return x*x*a%m\n else:\n return x*x%m\n\ndef inv(n,m):\n return mp(m-2,n,m)\n\ndef solve():\n n = I()\n m = 998244353\n a = [0]*(n+2)\n a[0] = 1\n a[1] = 1\n for i in range(2,n+1):\n a[i] = (a[i-1]+a[i-2])%m\n ans = inv(mp(n,2,m),m)\n print(ans*a[n-1]%m)\n \nfor _ in range(1):\n solve()\n"}, {"source_code": "M = 998244353 \nn=int(input())\na,b=1,1\nfor i in range(n-1):a,b=b,a+b\nprint(a*pow(1<<n,M-2,M)%M)"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key, lru_cache\nfrom itertools import accumulate\nimport sys\ninput = sys.stdin.readline\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n@lru_cache(None)\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\nfib = [1, 1]\nN = 10 ** 5\nN *= 2\nfor i in range(N + 10):\n fib.append((fib[-1] + fib[-2]) % mod)\n\nn = val()\nprint(fib[n - 1] * inv_mod(pow(2, n, mod)) % mod)"}, {"source_code": "import sys\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10**19\nMOD = 998244353\nEPS = 10**-10\n\ndef fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD\n\nN = INT()\n\ndp = [0] * (N+1)\nacc = [0] * (N+1)\nacc[0] = acc[1] = 1\nfor i in range(1, N+1):\n dp[i] += acc[i-1]\n dp[i] %= MOD\n if i-2 >= 0:\n acc[i] = dp[i] + acc[i-2]\n acc[i] %= MOD\ncnt = dp[N]\n\nans = fermat(cnt, pow(2, N, MOD), MOD)\nprint(ans)\n"}, {"source_code": "n = int(input())\np = 998244353 \n\nA = [0]*max(3, n+1) \nf = [0]*max(3, n+1)\n\nA[1] = 1 \nA[2] = 1 \nf[0] = 1 \nf[1] = 1 \nf[2] = 2 \n\nfor i in range (3, len(A)) : \n\n A[i] = (A[i-1] + f[i-3])%p \n f[i] = (f[i-2] + A[i])%p \n\n\n# print (A) \n\nd = pow (2, n*(p-2), p) \nprint ((A[n]*d)%p) "}, {"source_code": "mod=998244353 \ndp=[0]*(2*10**5+1)\ndp[0]=1\ndp[1]=1\ndp[2]=1\neven=2\nodd=1\nfor i in range (3,2*10**5+1):\n if i%2==1:\n dp[i]=even%mod\n odd+=dp[i]\n odd%=mod\n else:\n dp[i]=odd%mod\n even+=dp[i]\n even%=mod\nn=int(input())\nr=pow(2,n,mod)\ndp[n]*=pow(r,mod-2,mod)\nprint(dp[n]%mod)"}, {"source_code": "def egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n return x % m\n\n\nimport functools\n\nMOD = 998244353\nn = int(input())\n\na, b = 1, 0\np = 2\nfor _ in range(n-1):\n a, b = a+b, a\n\n p *= 2\n p %= MOD\n\nprint((a * modinv(p, MOD)) % MOD)\n"}, {"source_code": "'''Author- Akshit Monga'''\nfrom sys import stdin,stdout\ninput=stdin.readline\nm=998244353\nt=1\nfor _ in range(t):\n\tn=int(input())\n\tdp=[0 for x in range(n+1)]\n\tdp[1]=1\n\tfor i in range(2,n+1):\n\t\tdp[i]=((dp[i-1]%m)+(dp[i-2]%m))%m\n\tq=pow(2,n)\n\tans=((dp[-1]%m) * pow(q,m-2,m))%m\n\tprint(ans)"}, {"source_code": "# from math import gcd\n\nn = int(input())\ndp = [1]*(n+2)\nMOD=998244353\n\ndp[0]=0;\ndp[1]=1;\n\nfor i in range(2, n+2):\n dp[i] = dp[i-1] + dp[i-2]\n dp[i]%=MOD\n\ndenominator = pow(2, n, MOD)\n# g = gcd(dp[n], denominator)\n# denominator//=g\n# dp[n]//=g\n# print(dp[n], denominator)\nprint(dp[n]*pow(denominator, MOD - 2, MOD) % MOD)\n\n"}, {"source_code": "MOD = 998244353\nn = int(input())\nmult = pow(2, MOD-1-n, MOD)\na,b=0,1\nfor i in range(n):\n a,b = b, (a + b) % MOD\nprint((a * mult) % MOD)"}, {"source_code": "def bp(b, p):\n if p == 1:\n return b\n if p % 2 == 0:\n t = bp(b, p // 2)\n return t * t % q\n else:\n return bp(b, p - 1) * b % q\n\n\ndef inv(x):\n return bp(x, q - 2)\n\n\ndef div(a, b):\n return a * inv(b) % q\n\n\nn = int(input())\nq = 998244353\ndp = [0] * (n + 1)\ndp[0] = dp[1] = 1\nsm0 = 1\nsm1 = 1\nfor i in range(2, n + 1):\n if i % 2 == 0:\n dp[i] = sm1\n sm0 += dp[i]\n sm0 %= q\n else:\n dp[i] = sm0\n sm1 += dp[i]\n sm1 %= q\nprint(div(dp[n], pow(2, n, q)))\n"}, {"source_code": "\n#------------------------------warmup----------------------------\n# *******************************\n# * AUTHOR: RAJDEEP GHOSH * \n# * NICK : Rajdeep2k * \n# * INSTITUTION: IIEST, SHIBPUR *\n# *******************************\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now---------------------------------------------------\nn = int(input())\nx=0\nif(n==1 or n==2):\n x=1\nelif(n==3):\n x= 2\na=1\nb=2\ni=4\nwhile(i<n+1):\n c=a+b\n a=b\n b=c \n i+=1\n x=c\ny = pow(2, n, 998244353)\nprint((x*pow(y, 998244351, 998244353))%998244353)\n"}, {"source_code": "import sys\ninput = lambda:sys.stdin.readline().strip()\nmod = 998244353\nn = int(input())\nf = [0]*(n+1)\nf[0] = 0\nf[1] = 1\nfor i in range(2,n+1):\n f[i] = (f[i-1]+f[i-2])%mod \n# print(f[n-1],1<<n)\nprint((f[n]*pow(pow(2,n,mod),mod-2,mod))%mod) "}, {"source_code": "import sys\n# import math\n# import re\n# from heapq import *\n# from collections import defaultdict as dd\n# from collections import OrderedDict as odict\n# from collections import Counter as cc\n# from collections import deque\nsys.setrecursionlimit(3*10**5)#thsis is must\nmod = 10**9+7; md = 998244353\n# m = 2**32\ninput = lambda: sys.stdin.readline().strip()\ninp = lambda: list(map(int,sys.stdin.readline().strip().split()))\n# def C(n,r,mod):\n# \tif r>n:\n# \t\treturn 0\n# \tnum = den = 1\n# \tfor i in range(r):\n# \t\tnum = (num*(n-i))%mod\n# \t\tden = (den*(i+1))%mod\n# \treturn (num*pow(den,mod-2,mod))%mod\n# def pfcs(M = 100000):\n# \tpfc = [0]*(M+1)\n# \tfor i in range(2,M+1):\n# \t\tif pfc[i]==0:\n# \t\t\tfor j in range(i,M+1,i):\n# \t\t\t\tpfc[j]+=1\n# \treturn pfc\n#______________________________________________________\nM = 2*(10**5)+1\ndp = [0]*M\ndp[1] = 1\ndp[2] = 1\nfor i in range(3,M):\n\tdp[i] = (dp[i-1]+dp[i-2])%md\n\n\n\n\n# for _ in range(int(input())):\nn = int(input())\na = dp[n]\nc = pow(2,n,md)\nb = pow(c,md-2,md)\nprint((a*b)%md)"}, {"source_code": "# 1452 D\nN = 998244353\n\ndef pow(y, n):\n if n < 0:\n return pow(inverse(y), -n)\n if n == 0:\n return 1\n a = pow(y, n // 2)\n if n % 2 == 1:\n return (y * a * a) % N\n return (a * a) % N\n\n\ndef inverse(y):\n return pow(y, N-2)\n\n\nn = int(input())\nif n == 1:\n print(pow(2,-1))\n exit()\nk = n // 2\ng = [0] * (k + 1)\nh = [0] * (k + 1)\ng[0] = 1\nh[0] = 1\nfor i in range(k):\n g[i+1] = (g[i] + h[i]) % N\n h[i+1] = (g[i + 1] + h[i]) % N\n\nif n % 2 == 0:\n print((g[k] - g[k - 1] + N) * pow(2, -n) % N)\nelse:\n print((h[k] - h[k - 1] + N) * pow(2, -n) % N)"}, {"source_code": "import sys\ndef II():\n\treturn int(sys.stdin.readline())\nn =II()\ndp=[1,1]\nmod=998244353\nfor i in range(2,n):\n dp.append((dp[-1]+dp[-2])%mod)\nans=dp[-1]\nprint(ans*pow(pow(2,n,mod),mod-2,mod)%mod)\n \n"}, {"source_code": "MOD = 998244353\n\nclass ModInt:\n def __init__(self, x):\n self.x = x % MOD\n\n def __str__(self):\n return str(self.x)\n\n __repr__ = __str__\n\n def __add__(self, other):\n return (\n ModInt(self.x + other.x) if isinstance(other, ModInt) else\n ModInt(self.x + other)\n )\n\n def __sub__(self, other):\n return (\n ModInt(self.x - other.x) if isinstance(other, ModInt) else\n ModInt(self.x - other)\n )\n\n def __mul__(self, other):\n return (\n ModInt(self.x * other.x) if isinstance(other, ModInt) else\n ModInt(self.x * other)\n )\n\n def __truediv__(self, other):\n return (\n ModInt(\n self.x * pow(other.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(self.x * pow(other, MOD - 2, MOD))\n )\n\n def __pow__(self, other):\n return (\n ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(self.x, other, MOD))\n )\n\n __radd__ = __add__\n\n def __rsub__(self, other):\n return (\n ModInt(other.x - self.x) if isinstance(other, ModInt) else\n ModInt(other - self.x)\n )\n\n __rmul__ = __mul__\n\n def __rtruediv__(self, other):\n return (\n ModInt(\n other.x * pow(self.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(other * pow(self.x, MOD - 2, MOD))\n )\n\n def __rpow__(self, other):\n return (\n ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(other, self.x, MOD))\n )\nN = int(input())\ndp = [ModInt(1)]*(N+1)\nfor i in range(3,N+1):\n dp[i] = dp[i-1]+dp[i-2]\nprint(dp[-1]/pow(ModInt(2),N))"}, {"source_code": "n=int(input())\n# fib=[0 for _ in range(n+1)]\n\nfib1=1\nfib2=1\nmod=998244353\nfibn=fib2\nfor i in range(3,n+1):\n\n fibn=fib1+fib2\n fib1=fib2\n fib2=fibn\nx=pow(2,n)\n\nans=((fibn%mod)*pow(x,mod-2,mod))%mod\nprint(ans)"}, {"source_code": "import math\nn = int(input())\nc = 998244353\nans, x, y = 0, 0, 2 ** n % c\nif n == 1 or n == 2:\n x = 1\nelse:\n q, w = 1, 1\n for i in range(3, n + 1):\n q, w = w, (q + w) % c\n x = w\nz = math.gcd(x, y)\nx //= z\ny //= z\nans = pow(y, c - 2, c)\nprint((ans * x) % c)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nmod = 998244353\ndef modinv(n):\n return pow(n, mod-2, mod)\nif n == 1:\n print(modinv(2))\n exit()\n\nu = [0]*(n+1)\nu[0] = 1\nu[1] = 1\nu[2] = 1\nk = pow(2,n,mod)\nacum = [0]*(n+1)\nacum[0] = 1\nacum[1] = 2\nacum[2] = 3\n\nfor i in range(3,n+1):\n acum[i] = (acum[i-2]+acum[i-1])%mod\nprint((acum[-3]*modinv(k))%mod)\n"}, {"source_code": "n = int(input())\nMOD = 998244353\n\n\ndef fib(n):\n # Taking 1st two fibonacci nubers as 0 and 1\n if(n==1):\n return 1\n elif(n==2):\n return 1\n elif(n==3):\n return 2\n \n a=1\n b=2\n \n for i in range(4, n+1):\n c=a+b\n a=b\n b=c \n # print(c)\n return c\n\n\nx = fib(n)\ny = pow(2, n, MOD)\nprint((x*pow(y, MOD-2, MOD))%MOD)\n"}, {"source_code": "def modinv(n, p):\n return pow(n, p - 2, p)\ndef main():\n MOD = 998244353\n n = int(input())\n q = modinv(pow(2, n, MOD), MOD)\n\n fib = [0] * 200005\n fib[1] = 1\n fib[2] = 1\n\n for i in range(3, 200005):\n fib[i] = fib[i - 1] + fib[i - 2]\n fib[i] %= MOD\n\n p = fib[n]\n #print(p, q)\n\n ans = (p % MOD * q % MOD) % MOD\n print(ans)\nmain()"}, {"source_code": "mod = 998244353\nn=int(input())\n\nif n==1:\n ans = pow(2,mod-2,mod)\n print(ans)\nelse:\n a=0\n b=1\n for i in range(n-1):\n c = (b+a)%mod\n a = b\n b = c\n ans = pow(2,n,mod)\n ans= pow(ans,mod-2,mod)\n print((ans*c)%mod)\n \n"}, {"source_code": "def modInverse(a, m):\n g = gcd(a, m)\n if g != 1:\n return 1\n else:\n return power_fct(a, m - 2, m)\n\n\ndef power_fct(x, y, m):\n if y == 0:\n return 1\n\n p = power_fct(x, y // 2, m) % m\n p = (p * p) % m\n\n if y % 2 == 0:\n return p\n else:\n return (x * p) % m\n\n\ndef gcd(a, b):\n if a == 0:\n return b\n return gcd(b % a, a)\n\n\ndef radio_towers():\n n = int(input())\n modulo = 998244353\n\n fib = [1, 0]\n power = 2\n\n for i in range(1, n):\n fib = [sum(fib) % modulo, fib[0]]\n power = (power * 2) % modulo\n\n print((modInverse(power, modulo) * fib[0]) % modulo)\n\n\nif __name__ == \"__main__\":\n radio_towers()\n"}, {"source_code": "n = int(input())\nm = 998244353\n\nd = [1] * (n + 1)\ne = [1] * 2\nc = 0\nfor i in range(2, n + 1):\n d[i] = d[i - 1]\n if i > 2:\n d[i] = (d[i] + e[(i + 1) % 2] - d[i - 1]) % m\n e[i % 2] = (e[i % 2] + d[i]) % m\n\nx = d[-1]\ny = pow(2, n, m)\nprint((x * pow(y, m - 2, m)) % m)\n"}, {"source_code": "mod = 998244353\n\n\ndef fexp(x, y):\n ans = 1\n while y > 0:\n if y & 1 > 0:\n ans = ans * x % mod\n x = x * x % mod\n y >>= 1\n return ans\n\n\ndef inv(x):\n return fexp(x, mod - 2)\n\n\ndef mul(a, b):\n ans = [[0, 0], [0, 0]]\n for i in range(2):\n for j in range(2):\n for k in range(2):\n ans[i][j] = (ans[i][j] + a[i][k] * b[k][j]) % mod\n return ans\n\n\ndef matexp(a, y):\n ans = [[1, 0], [0, 1]]\n while y > 0:\n if y & 1 > 0:\n ans = mul(ans, a)\n a = mul(a, a)\n y >>= 1\n return ans\n\n\nn = int(input())\nif n == 1:\n print(inv(2))\nelse:\n fib = [[1, 1], [1, 0]]\n mat = matexp(fib, n - 2)\n upper = mat[0][0] + mat[0][1]\n lower = fexp(2, n)\n print(upper * inv(lower) % mod)\n"}, {"source_code": "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int, minp().split())\n\ndef solve():\n\tn = mint()\n\tdp = [1] * (n+1)\n\tdp1 = [1] * (n+1)\n\t#dp2 = [0] * (n+1);\n\tMOD = 998244353\n\tfor i in range(1,n+1):\n\t\tdp[i] = dp1[i-1]\n\t\t#for j in range(1,n+1,2):\n\t\t#\tif i - j < 0:\n\t\t#\t\tbreak\n\t\t#\tdp[i] += dp[i-j]\n\t\t#for j in range(0,n+1,2):\n\t\t#\tif i - j < 0:\n\t\t#\t\tbreak\n\t\t#\tdp2[i] += dp[i-j]\n\t\tdp1[i] = (dp[i] + (dp1[i-2] if i-2 >= 0 else 0)) % MOD\n\t#dp2[0] = 1\n\t#print(dp)\n\t#print(dp1)\n\t#print(dp2)\n\tprint(dp[n]*pow(2,(MOD-2)*n,MOD)%MOD)\n\nsolve()\n"}, {"source_code": "n = int(input())\nmod = 998244353\n\n\ndef modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n\n\na = 1\nb = 1\nif n <= 2:\n if n == 1:\n print(modinv(2, mod))\n else:\n print(modinv(4, mod))\n exit(0)\nk = 1\nfor i in range(n):\n k *= 2\n k %= mod\n\nfor i in range(2, n):\n a, b = a+b, a\n\nprint((a * modinv(k, mod)) % mod)\n"}, {"source_code": "\nmod = 998244353\nn = int(input())\na, b = 0, 1\nfor i in range(2, n+1):\n a, b = b, (a+b)%mod\nprint((b * pow(2, n*(mod-2), mod))%mod)"}, {"source_code": "M = 998244353\nn = int(input())\na, b = 0, 1\nfor i in range(2, n+1):\n a, b = b, (a+b)%M\nprint((b * pow(2, n*(M-2), M))%M)"}, {"source_code": "import math,sys\n#from itertools import permutations, combinations\nfrom collections import defaultdict,deque\nimport bisect as bi\ndef yes():print('YES')\ndef no():print('NO')\n#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\ndef I():return (int(sys.stdin.readline()))\ndef In():return(map(int,sys.stdin.readline().split()))\ndef Sn():return sys.stdin.readline().strip()\ndef dict(a):\n d={} \n for x in a:\n if d.get(x,-1)!=-1:\n d[x]+=1\n else:\n d[x]=1\n return d\ndef find_gt(a, x):\n 'Find leftmost value greater than x'\n i = bi.bisect_left(a, x)\n if i != len(a):\n return i\n else: \n return -1\ndef expo(a, b):\n x, y = 1, a\n while (b > 0):\n if (b & 1):\n x = x * y\n y = y * y\n b >>= 1\n return x\ndef power(x, y, m): \n \n if (y == 0): \n return 1\n \n p = power(x, y // 2, m) % m \n p = (p * p) % m \n \n if(y % 2 == 0): \n return p \n else: \n return ((x * p) % m) \ndef modInverse(a, m): \n g = gcd(a, m) \n if (g != 1): \n return -1\n else:\n return(power(a, m - 2, m)) \ndef gcd(a, b): \n if (a == 0): \n return b \n \n return gcd(b % a, a) \ndef main():\n try:\n n=I()\n fib=[0,1]\n for i in range(2,n+1):\n temp=(fib[-1]+fib[-2])\n fib[-2]=fib[-1]\n fib[-1]=temp\n ans=(fib[-1]%M*modInverse(power(2,n,M),M)%M)%M\n print(ans)\n\n except:\n pass\n \nM = 998244353\nP = 1000000007\n \nif __name__ == '__main__':\n # for _ in range(I()):main()\n for _ in range(1):main()\n#End#\n\n# ******************* All The Best ******************* #"}, {"source_code": "n = int(input())\nx,y=0,1\nmod = 998244353\nfor i in range(n-1):\n x,y = y,x+y\n x %= mod\n y %= mod\nt = pow(2,n,mod)\nprint((y*pow(t,mod-2,mod))%mod)"}, {"source_code": "import math,sys\n#from itertools import permutations, combinations\nfrom collections import defaultdict,deque\nimport bisect as bi\ndef yes():print('YES')\ndef no():print('NO')\n#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\ndef I():return (int(sys.stdin.readline()))\ndef In():return(map(int,sys.stdin.readline().split()))\ndef Sn():return sys.stdin.readline().strip()\ndef dict(a):\n d={} \n for x in a:\n if d.get(x,-1)!=-1:\n d[x]+=1\n else:\n d[x]=1\n return d\ndef find_gt(a, x):\n 'Find leftmost value greater than x'\n i = bi.bisect_left(a, x)\n if i != len(a):\n return i\n else: \n return -1\ndef expo(a, b):\n x, y = 1, a\n while (b > 0):\n if (b & 1):\n x = x * y\n y = y * y\n b >>= 1\n return x\ndef power(x, y, m): \n \n if (y == 0): \n return 1\n \n p = power(x, y // 2, m) % m \n p = (p * p) % m \n \n if(y % 2 == 0): \n return p \n else: \n return ((x * p) % m) \ndef modInverse(a, m): \n g = gcd(a, m) \n if (g != 1): \n return -1\n else:\n return(power(a, m - 2, m)) \ndef gcd(a, b): \n if (a == 0): \n return b \n \n return gcd(b % a, a) \ndef main():\n try:\n n=I()\n fib=[0,1]\n for i in range(2,n+1):\n temp=(fib[-1]+fib[-2])\n fib[-2]=fib[-1]\n fib[-1]=temp\n ans=(fib[-1]%M*modInverse(expo(2,n),M)%M)%M\n print(ans)\n\n except:\n pass\n \nM = 998244353\nP = 1000000007\n \nif __name__ == '__main__':\n # for _ in range(I()):main()\n for _ in range(1):main()\n#End#\n\n# ******************* All The Best ******************* #"}, {"source_code": "import sys\nii = lambda: sys.stdin.readline().strip()\nidata = lambda: [int(qw) for qw in ii().split()]\n\nmod = 998244353\ndef bin_pow(a, b):\n if b == 0:\n return 1\n m = bin_pow(a, b >> 1)\n if b & 1:\n return m * m % mod * a % mod\n return m * m % mod\nn = int(ii())\ny = bin_pow(bin_pow(2, n), mod - 2)\ndp = [0] * (n + 1)\ndp[1] = 1\nfor i in range(2, n + 1):\n dp[i] = (dp[i - 1] + dp[i - 2]) % mod\nprint(dp[n] * y % mod)\n"}, {"source_code": "n = int(input())\n\ndef fun(n):\n v1, v2, v3 = 1, 1, 0 # initialise a matrix [[1,1],[1,0]]\n for rec in bin(n)[3:]: # perform fast exponentiation of the matrix (quickly raise it to the nth power)\n calc = v2*v2\n v1, v2, v3 = v1*v1+calc, (v1+v3)*v2, calc+v3*v3\n if rec=='1': v1, v2, v3 = v1+v2, v1, v2\n return v2\n\n# dp = [-1 for i in range(n+1)]\n# dp[1]=1\n# if n>=2:\n# dp[2]=1\n# for i in range(3,n+1):\n# dp[i] = dp[i-1]+dp[i-2]\nans = fun(n)\nans1 = pow(pow(2,n),998244351,998244353)\nprint((ans1*ans)%998244353)\n"}], "negative_code": [{"source_code": "##################################### \nimport atexit, io, sys , collections, heapq\nbuffer = io.BytesIO() \nsys.stdout = buffer\n@atexit.register \ndef write(): sys.__stdout__.write(buffer.getvalue()) \n##################################### \nmod = 998244353\n\nn = int(raw_input())\ndef f(n):\n\tif n == 1:\n\t\treturn 1\n\tif n == 0:\n\t\treturn 1\n\tans = 0\n\tfor u in range(1, n + 1, 2):\n\t\tans += f(n - u)\n\t\tans %= mod\n\treturn ans \n\ndef pow(a,n):\n\tif n == 0:return 1\n\tr = pow(a, n//2) % mod\n\treturn r * r * (a if n % 2 else 1) % mod\n\n\na = f(n)\nb = pow(2,n)\nprint a,b\nprint a * pow(b, mod-2) % mod"}, {"source_code": "from __future__ import division\nfrom sys import stdin, stdout\n# from fractions import gcd\n# from math import *\n# from operator import mul\n# from functools import reduce\n# from copy import copy\nfrom collections import deque, defaultdict, Counter\n\nrstr = lambda: stdin.readline().strip()\nrstrs = lambda: [str(x) for x in stdin.readline().split()]\nrint = lambda: int(stdin.readline())\nrints = lambda: [int(x) for x in stdin.readline().split()]\nrstr_2d = lambda n: [rstr() for _ in range(n)]\nrint_2d = lambda n: [rint() for _ in range(n)]\nrints_2d = lambda n: [rints() for _ in range(n)]\npr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\\n')\nadd = lambda a, b: (a + b) % mod\nmult = lambda a, b: (a * b) % mod\ndiv = lambda a, b: mult(a, inv(b))\ninv = lambda a: pow(a, mod - 2, mod)\nmod = 998244353\n\nn = int(input())\nfib = [0] * (n + 1)\nfib[0] = fib[1] = 1\nfor i in range(2, n):\n fib[i] = add(fib[i - 1], fib[i - 2])\n\nprint(div(fib[-1], pow(2, n, mod)))\n"}, {"source_code": "from __future__ import division,print_function\n\nmo=998244353\ndemi=pow(2,mo-2,mo)\nquart=pow(4,mo-2,mo)\nn=int(input())\nP=[1]\nsp=0\nsi=0\nfor k in range(1,n+1):\n if k%2:\n si=(demi*P[k-1]+si*quart)%mo\n P.append(si)\n else:\n sp= (demi*P[k-1]+sp*quart)%mo\n P.append(sp)\n#for k in range(1,n+1):\n# P.append(sum(2**(-i)*P[k-i] for i in range(1,k+1,2)))\nprint(P[-1])\nprint(5/32)\n"}, {"source_code": "#from math import *\nfrom bisect import *\nfrom collections import *\nfrom random import *\nfrom decimal import *\nfrom random import *\nimport sys\ninput=sys.stdin.readline\ndef inp():\n return int(input())\ndef st():\n return input().rstrip('\\n')\ndef lis():\n return list(map(int,input().split()))\ndef ma():\n return map(int,input().split())\nt=1\np=998244353\nwhile(t):\n t-=1\n n=inp()\n if(n==1):\n print(1)\n exit(0)\n pr=[1,2]\n for i in range(n-2):\n pr.append((pr[-1]+pr[-2])%p)\n nu=pr[n-2]\n de=pow(2,n,p)\n de=pow(de,p-2,p)\n print((nu*de)%p)\n \n"}, {"source_code": "mod=998244353 \ndp=[0]*(2*10**5+1)\ndp[0]=1\ndp[1]=1\ndp[2]=1\neven=2\nodd=1\nfor i in range (3,2*10**5+1):\n if i%2==1:\n dp[i]=even%mod\n odd+=dp[i]\n odd%=mod\n else:\n dp[i]=odd%mod\n even+=dp[i]\n even%=mod\nn=int(input())\nr=pow(2,n,mod)\nr=(r*dp[n])%mod\nprint(r)"}, {"source_code": "MODP = 998244353\n\ndef inv(x, m):\n a, u = 0, 1\n b = m\n while x > 0:\n q = b // x\n x, a, b, u = b % x, u, x, a - q * u\n if b == 1:\n return a % m\n assert False\n\n\ndef result_modp(p, q):\n return ((p % MODP) * inv(q, MODP)) % MODP\n\n\ndef x(n):\n if n in cache:\n return cache[n]\n\n result = 0\n result += x(n - 1)\n for k in range(2, n // 2 + 2):\n result += x(n + 2 - 2 * k)\n result = result ^ MODP\n\n cache[n] = result\n return result\n\n\nif __name__ == '__main__':\n n = int(input())\n\n denom = 1\n for i in range(n):\n denom = (denom * 2) % MODP\n\n\n x = dict()\n x[0] = 1\n x[1] = 1\n x[2] = 1\n\n for i in range(3, n + 1):\n result = 0\n result += x[i - 1]\n for k in range(2, (i - 1) // 2 + 2):\n result += x[i + 1 - 2 * k]\n result = result % MODP\n\n x[i] = result\n\n num = x[n]\n print(x)\n print(result_modp(num, denom))"}, {"source_code": "#!/usr/bin/env python3\n\nimport itertools\n\nPRIME = int(998244353)\n\ndef ri(string):\n return list(map(int, string.split(' ')))\n\ndef power(a, b):\n if b == 0: return 1\n i = 2\n a_power = [a]\n while i <= b:\n a_power.append(a_power[-1]*a_power[-1] % PRIME)\n i *= 2\n\n bin_b = list(map(int, bin(b)[:1:-1]))\n # print(a_power, bin_b)\n a_power = itertools.compress(a_power, bin_b)\n # print(a_power)\n res = 1\n for p in a_power:\n # print(res, p)\n res = res * p % PRIME\n return res\n\n\nn = int(input())\n# b = int(input())\n# print(power(a, b))\n\nsums = []\nsums.append(1)\n# sums.append(1)\n# sums[1] = 1\nfor i in range(n-1, -1, -2):\n # val = sum(sums) % PRIME\n # print(f'{i}: {val}')\n sums.append(sum(sums) % PRIME)\n\n# print(sums)\nx = sums.pop()\n# print(x)\ny_inv = power(2, n*(PRIME-2))\n\nprint(x*y_inv % PRIME)\n\n\n"}, {"source_code": "n = int(input())\nMOD = 998244353\n\n\ndef fib(n):\n f = [0, 0, 1, 2, 3]\n\n for i in range(5, n+1):\n f.append((f[i-1] + f[i-2]) % MOD)\n return f[n]\n\n\nx = fib(n)\ny = pow(2, n, MOD)\nprint((x*pow(y, MOD-2, MOD)) % MOD)"}, {"source_code": "# 1452 D\nN = 998244353\n\ndef pow(y, n):\n if n < 0:\n return pow(inverse(y), -n)\n if n == 0:\n return 1\n a = pow(y, n // 2)\n if n % 2 == 1:\n return (y * a * a) % N\n return (a * a) % N\n\n\ndef inverse(y):\n return pow(y, N-2)\n\n\nn = int(input())\nk = n // 2\ng = [0] * (k + 1)\nh = [0] * (k + 1)\ng[0] = 1\nh[0] = 1\nfor i in range(k):\n g[i+1] = (g[i] + h[i]) % N\n h[i+1] = (g[i + 1] + h[i]) % N\n\nif n % 2 == 0:\n print((g[k] - g[k - 1] + N) * pow(2, -n) % N)\nelse:\n print((h[k] - h[k - 1] + N) * pow(2, -n) % N)"}, {"source_code": "import math\n\ndef modInverse(b,m): \n g = math.gcd(b, m) \n if (g != 1): \n # print(\"Inverse doesn't exist\") \n return -1\n else: \n # If b and m are relatively prime, \n # then modulo inverse is b^(m-2) mode m \n return pow(b, m - 2, m) \n \n \n# Function to compute a/b under modulo m \ndef modDivide(a,b,m): \n a = a % m \n inv = modInverse(b,m) \n if(inv == -1): \n print(\"Division not defined\") \n else: \n return (inv*a) % m\nfor z in range(1):\n n =int(input())\n ans=0\n r= n*(n+1)//6\n p=998244353\n print(modDivide(r,2**n,p))\n \n"}, {"source_code": "\"\"\"\nCode of Ayush Tiwari\nCodeforces: servermonk\nCodechef: ayush572000\n\n\"\"\"\n# import sys\n# input = sys.stdin.buffer.readline\n\ndef modInverse(a, m): \n \n g = gcd(a, m) \n \n if (g != 1): \n print(\"Inverse doesn't exist\") \n \n else: \n \n return power(a, m - 2, m)\n \n# To compute x^y under modulo m \n \n \ndef power(x, y, m): \n \n if (y == 0): \n return 1\n \n p = power(x, y // 2, m) % m \n p = (p * p) % m \n \n if(y % 2 == 0): \n return p \n else: \n return ((x * p) % m) \n \n# Function to return gcd of a and b \n \n \ndef gcd(a, b): \n if (a == 0): \n return b \n \n return gcd(b % a, a) \n\ndef solution():\n \n # This is the main code\n n=int(input())\n p=0\n for i in range(1,n+1):\n p+=min(abs(i-1),abs(n-i))\n p+=1\n q=(modInverse(2**n,998244353))\n print(p*q)\n \nt=1\nfor _ in range(t):\n solution()"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport threading \nfrom bisect import bisect_right\nfrom math import gcd,log\nfrom collections import Counter\nfrom pprint import pprint\n\nMOD=998244353\ndef bin_exp(a,b,MOD):\n ans=1\n while b :\n if b&1:\n ans*=a\n ans%=MOD\n a*=a\n a%=MOD\n b//=2\n return ans \n\n\ndef main(case_no):\n n=int(input())\n fu=[0]*(n+10)\n od=1\n ev=1\n for i in range(2,n+3):\n if (i%2):\n fu[i]=ev\n od+=fu[i]\n else:\n fu[i]=od\n ev+=fu[i]\n od%=MOD\n ev%=MOD\n # print(fu)\n print((fu[n]*bin_exp(bin_exp(2,n,MOD),MOD-2,MOD))%MOD)\n\n\n\nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \nif __name__ == \"__main__\":\n\n for _ in range(1):\n main(_+1)\n\n\n\n"}, {"source_code": "mo = 998244353\n\ndef ge(n):\n a = [0] * (n + 5)\n a[1] = 1\n a[2] = 1\n for i in range(3, n + 1):\n a[i] = a[i - 1] + a[i - 2]\n a[i] %= mo\n return a[n]\n\ndef min_y(b, n):\n # print (b, n)\n if (n == 1):\n return b\n if (n % 2 == 0):\n return min_y(b * b % mo, n // 2) % mo\n return b * min_y(b % mo, n - 1) % mo\n\nn = int(input())\nget_n = ge(n)\nans = 2\nst = n * (mo - 2)\nwhile (st != 1):\n if (st % 2 == 0):\n ans = ans * ans % mo\n st //= 2\n else:\n ans = ans % mo\n st -= 1\n\nprint(get_n * ans % mo)\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nfrom collections import defaultdict as dc\nfrom collections import Counter\nfrom bisect import bisect_right, bisect_left\nimport math\nfrom operator import itemgetter\nfrom heapq import heapify, heappop, heappush\nn=int(input())\nif n==1:\n print(1)\nelse:\n a=0\n b=1\n m=998244353\n for i in range(2,n+1):\n c=a+b\n a=b\n b=c\n p=pow(2,n,m)\n y=pow(p,m-2,m)\n print((c*y)%m)"}, {"source_code": "n = int(input())\nm = 998244353\nx,y=0,1\nfor i in range(n-1):\n x,y = y,x+1\n x%=m\n y%=m\nr = pow(2,n,m)\nprint((y*pow(r,m-2,m))%m)"}, {"source_code": "n = int(input())\ndef fib (a):\n ans1 = 1\n ans2 = 1\n t = a\n while t > 0:\n t -= 1\n k = ans1\n ans1 += ans2\n ans2 = k\n return ans1\ndef binpow (a, b):\n if b == 0:\n return 1\n elif b % 2 == 1:\n return (binpow(a, b - 1) * a) % 998244353\n else:\n k = binpow(a, b / 2)\n return (k * k) % 998244353\nm = 0\nif n < 4:\n m = n - 1\nelse:\n m = fib(n - 2)\nl = binpow(2, n)\nans = (m * binpow(l, 998244351)) % 998244353\nprint(ans)\n\n\n"}, {"source_code": "n = int(input())\nm = 998244353\ninv = 499122177\nx = [inv, (inv**2)%m]\n\nfor _ in range(max(0, n-2)):\n x.append((x[-1]*x[0]+x[-2]*x[-1])%m)\n \nprint(x[n-1])"}, {"source_code": "n = int(input())\ndp = [1, 1]\nfor i in range(n - 2):\n dp.append(dp[-1] + dp[-2])\nx = dp[-1]\ny = 2 ** n\nwhile x % 2 and y % 2 == 0:\n x = x // 2\n y = y // 2\n\nans = x\nfor i in range(998244353 - 2):\n ans = (ans * y) % 998244353\nprint(ans)"}, {"source_code": "import math \n \n# Function to find modulo inverse of b. It returns \n# -1 when inverse doesn't \n# modInverse works for prime m \ndef modInverse(b,m): \n\n return pow(b, m - 2, m) \n \n \n# Function to compute a/b under modulo m \ndef modDivide(a,b,m): \n a = a % m \n inv = modInverse(b,m) \n return (inv*a) % m\n\nn = int(input())\n\ncurr = 1\nprev = 2\nif n == 2 :\n fib = 1\nelif n==3:\n fib = 2\nelse:\n for i in range(4,n+1):\n tem = curr\n curr = prev\n prev += tem\n fib = prev\nprint(modDivide(fib,2**n,998244353))\n"}, {"source_code": "import math \n \n# Function to find modulo inverse of b. It returns \n# -1 when inverse doesn't \n# modInverse works for prime m \ndef modInverse(b,m): \n g = math.gcd(b, m) \n if (g != 1): \n # print(\"Inverse doesn't exist\") \n return -1\n else: \n # If b and m are relatively prime, \n # then modulo inverse is b^(m-2) mode m \n return pow(b, m - 2, m) \n \n \n# Function to compute a/b under modulo m \ndef modDivide(a,b,m): \n a = a % m \n inv = modInverse(b,m) \n return (inv*a) % m\n\nn = int(input())\n\ncurr = 1\nprev = 2\nif n == 2 :\n fib = 1\nelif n==3:\n fib = 2\nelse:\n for i in range(4,n+1):\n tem = curr\n curr = prev\n prev += tem\n fib = prev\nprint(modDivide(fib,2**n,998244353))\n"}, {"source_code": "\"\"\"\n Author - Satwik Tiwari .\n 19th NOV , 2020 - Thursday\n\"\"\"\n\n#===============================================================================================\n#importing some useful libraries.\n\nfrom __future__ import division, print_function\nfrom fractions import Fraction\nimport sys\nimport os\nfrom io import BytesIO, IOBase\nfrom functools import cmp_to_key\n\n# from itertools import *\nfrom heapq import *\nfrom math import gcd, factorial,floor,ceil,sqrt\n\nfrom copy import deepcopy\nfrom collections import deque\n\n\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n\n#==============================================================================================\n#fast I/O region\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n# inp = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#===============================================================================================\n### START ITERATE RECURSION ###\nfrom types import GeneratorType\ndef iterative(f, stack=[]):\n def wrapped_func(*args, **kwargs):\n if stack: return f(*args, **kwargs)\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n continue\n stack.pop()\n if not stack: break\n to = stack[-1].send(to)\n return to\n return wrapped_func\n#### END ITERATE RECURSION ####\n\n#===============================================================================================\n#some shortcuts\n\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") #for fast input\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef lis(): return list(map(int, inp().split()))\ndef stringlis(): return list(map(str, inp().split()))\ndef sep(): return map(int, inp().split())\ndef strsep(): return map(str, inp().split())\n# def graph(vertex): return [[] for i in range(0,vertex+1)]\ndef testcase(t):\n for pp in range(t):\n solve(pp)\ndef google(p):\n print('Case #'+str(p)+': ',end='')\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef power(x, y, p) :\n y%=(p-1) #not so sure about this. used when y>p-1. if p is prime.\n res = 1 # Initialize result\n x = x % p # Update x if it is more , than or equal to p\n if (x == 0) :\n return 0\n while (y > 0) :\n if ((y & 1) == 1) : # If y is odd, multiply, x with result\n res = (res * x) % p\n\n y = y >> 1 # y = y/2\n x = (x * x) % p\n return res\ndef ncr(n,r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))\ndef isPrime(n) :\n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\ninf = pow(10,20)\nmod = 998244353\n#===============================================================================================\n# code here ;))\nf = 0\n#\n# def chck(a,mid):\n# temp = 0\n# global f\n# if(f):\n# mx = max(a)\n# help = a[len(a)-2]\n# to = 0\n# for i in range(len(a)):\n# to+=mx - a[i]\n# to2 = 0\n# for i in range(len(a)):\n# if(a[i] != mx):\n# to2+=help-a[i]\n# for i in range(len(a)):\n# if(a[i] == mx):\n# temp+=max(0,to2 - a[i])\n# else:\n# temp+=max(0,(to - (mx - a[i])) - a[i])\n# if(temp<=mid):\n# return True\n# return False\n#\n# else:\n# mx = max(a)\n# to = 0\n# for i in range(len(a)):\n# to+=mx - a[i]\n# for i in range(len(a)):\n# temp+=max((to - (mx - a[i])) - a[i],0)\n# if(temp<=mid):\n# return True\n# return False\n# # if(f):\n\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef solve(case):\n n =int(inp())\n a = 0\n b = modinv(2,mod)\n c = modinv(4,mod)\n help = c\n prev2 = 0\n prev1 = b\n curr = 0\n for i in range(2,n+1):\n # print(b,prev1,help,prev2)\n curr = b*prev1 + help*prev2\n curr%=mod\n prev2 = prev1\n prev1 = curr\n\n print(curr%mod)\n\n\n\n\ntestcase(1)\n# testcase(int(inp()))\n\n\n\n\"\"\"\n4\n10 0 0\n20 1 0\n30 0 1\n40 1 1\n4 1\n2 3\n1 3\n\"\"\"\n\n\n\n\n\n"}, {"source_code": "# Design_by_JOKER\n\nfrom math import *\nfrom cmath import *\nfrom itertools import *\nfrom decimal import * # su dung voi so thuc\nfrom fractions import * # su dung voi phan so\nfrom sys import *\n#from numpy import *\n\n'''getcontext().prec = x # lay x-1 chu so sau giay phay (thuoc decimal)\nDecimal('12.3') la 12.3 nhung Decimal(12.3) la 12.30000000012\nFraction(a) # tra ra phan so bang a (Fraction('1.23') la 123/100 Fraction(1.23) la so khac (thuoc Fraction)\na = complex(c, d) a = c + d(i) (c = a.real, d = a.imag)\na.capitalize() bien ki tu dau cua a(string) thanh chu hoa, a.lower() bien a thanh chu thuong, tuong tu voi a.upper()\na.swapcase() doi nguoc hoa thuong, a.title() bien chu hoa sau dau cach, a.replace('a', 'b', slg)\nchr(i) ki tu ma i ord(c) ma ki tu c\na.join['a', 'b', 'c'] = 'a'a'b'a'c, a.strip('a') bo dau va cuoi ki tu 'a'(rstrip, lstrip)\na.split('a', slg = -1) cat theo ki tu 'a' slg lan(rsplit(), lsplit()), a.count('aa', dau = 0, cuoi= len(a)) dem slg\na.startswith('a', dau = 0, cuoi = len(a)) co bat dau bang 'a' ko(tuong tu endswith())\na.index(\"aa\") vi tri dau tien xuat hien (rfind())\ninput = open(\".inp\", mode='r') a = input.readline()\nout = open(\".out\", mode='w') a.index(val) '''\n\ndef f(x):\n\ta = 1\n\tb = 1\n\tif x == 1:return 1\n\twhile x - 2 > 0:\n\t\tx -= 1\n\t\ta, b = b, a + b\n\treturn b\n\ndef aa(v, q):\n\tif q == 1: return v\n\tr = q // 2\n\tt = aa(v, r)\n\tif q % 2: return (((t * t) % 998244353 )*v)%998244353 \n\treturn (t*t)%998244353 \n\ndef cal(a, b):\n\ta %= 998244353\n\tb = aa(2, b)\n\treturn (a *((aa(b, 998244351)) % 998244353 ))%998244353 \n\nn = int(input())\nif n == 1:\n\tprint(cal(1, 1))\nelif n == 2:\n\tprint(cal(1, 2))\nelif n % 2:\n\tprint(cal(f(n), n))\n"}, {"source_code": "# Design_by_JOKER\n\nfrom math import *\nfrom cmath import *\nfrom itertools import *\nfrom decimal import * # su dung voi so thuc\nfrom fractions import * # su dung voi phan so\nfrom sys import *\n#from numpy import *\n\n'''getcontext().prec = x # lay x-1 chu so sau giay phay (thuoc decimal)\nDecimal('12.3') la 12.3 nhung Decimal(12.3) la 12.30000000012\nFraction(a) # tra ra phan so bang a (Fraction('1.23') la 123/100 Fraction(1.23) la so khac (thuoc Fraction)\na = complex(c, d) a = c + d(i) (c = a.real, d = a.imag)\na.capitalize() bien ki tu dau cua a(string) thanh chu hoa, a.lower() bien a thanh chu thuong, tuong tu voi a.upper()\na.swapcase() doi nguoc hoa thuong, a.title() bien chu hoa sau dau cach, a.replace('a', 'b', slg)\nchr(i) ki tu ma i ord(c) ma ki tu c\na.join['a', 'b', 'c'] = 'a'a'b'a'c, a.strip('a') bo dau va cuoi ki tu 'a'(rstrip, lstrip)\na.split('a', slg = -1) cat theo ki tu 'a' slg lan(rsplit(), lsplit()), a.count('aa', dau = 0, cuoi= len(a)) dem slg\na.startswith('a', dau = 0, cuoi = len(a)) co bat dau bang 'a' ko(tuong tu endswith())\na.index(\"aa\") vi tri dau tien xuat hien (rfind())\ninput = open(\".inp\", mode='r') a = input.readline()\nout = open(\".out\", mode='w') a.index(val) '''\n\ndef f(x):\n\ta = 1\n\tb = 1\n\twhile x - 1 > 0:\n\t\tx -= 1\n\t\ta, b = b, a + b\n\treturn b\n\ndef aa(v, q):\n\tif q == 1: return v\n\tr = q // 2\n\tt = aa(v, r)\n\tif q % 2: return (((t * t) % 998244353 )*v)%998244353 \n\treturn (t*t)%998244353 \n\ndef cal(a, b):\n\ta %= 998244353\n\tb = aa(2, b)\n\treturn (a *((aa(b, 998244351)) % 998244353 ))%998244353 \n\nn = int(input())\nif n == 1:\n\tprint(cal(1, 1))\nelif n == 2:\n\tprint(cal(1, 2))\nelif n % 2:\n\tprint(cal(f(n), n))\n"}, {"source_code": "def gcd_extended(a, b):\n # Base Case\n if a == 0:\n return b, 0, 1\n gcd, x1, y1 = gcd_extended(b % a, a)\n # Update x and y using results of recursive\n # call\n x = y1 - (b // a) * x1\n y = x1\n return gcd, x, y\n\n\ndef power(a, n, p):\n if n == 0:\n return 1\n x = power(a, n//2, p)\n x = (x * x) % p\n if n % 2 == 1:\n x = (x * a) % p\n return x % p\n\n\nt = 1\np = 998244353\n# n = int(input())\nn = 200000\n\nrev_2 = gcd_extended(2, p)[1] % p\n# a = [1, 0.5]\na = [1, rev_2]\n# b = [1, 1]\nc = [1, rev_2]\n\n# print(rev_2)\n# print((rev_2 * 2) % p)\n\npowers = [1]\nrev_powers = [1]\nfor i in range(1, 2 * 10 ** 5 + 1):\n powers.append((powers[-1] * 2) % p)\n rev_powers.append((rev_powers[-1] * rev_2) % p)\n\nfor k in range(2, n + 1):\n l = 1\n s = 0\n\n maxp = k if k % 2 == 1 else k - 1\n # divider = power(2, maxp, p)\n divider = powers[maxp]\n\n\n\n\n # div_rev = gcd_extended(divider, p)[1]\n div_rev = rev_powers[maxp]\n\n # a.append(s / divider)\n # a.append(int((s * div_rev)) % p)\n\n if k < 3:\n while l <= k:\n # s += (a[k - l] * power(2, maxp - l, p)) % p\n s += (a[k - l] * powers[maxp - l]) % p\n l += 2\n c.append(int((s * div_rev)) % p)\n else:\n c.append(int(((c[k - 2] * rev_2 * rev_2) + (c[k - 1] * rev_2)) % p))\n\n # print(div_rev)\n # print(div_rev2)\n # print('multiplication check')\n # print((divider * div_rev) % p)\n # print((divider * div_rev2) % p)\n # if (divider * div_rev) % p != (divider * div_rev2) % p:\n # print('lalala')\n # if int((s * div_rev)) % p != int((s * div_rev2) % p):\n # print(s)\n\n # try:\n # b.append(int((s * div_rev) % p))\n #\n # # print(int((s * div_rev)) % p)\n # # print(int((s * div_rev2) % p))\n # except ValueError:\n # print('ValueError')\n # print(k, s, divider, div_rev)\n # break\n\n# print(a)\n# print(c)\n# print(b)\n# print(b[n])\n# print(a[n])\nprint(c[n])"}, {"source_code": "def power(x,y):\n if(y==0):\n return 1\n val=power(x,y/2)\n if y%2==0:\n return (val*val)%(998244353)\n return (val*val*x)%(998244353)\nl=[1,2,3,5]\nfor i in range(3,200005):\n l.append(l[-1]+l[-2])\n l[-1]%=(998244353)\nn=input()\nprint (l[n-2]*power(power(2,n),998244351))%(998244353)\n"}, {"source_code": "n = int(input())\nx,y=0,1\nmod = 998244353\nfor i in range(n-1):\n x,y = y,x+y\n x %= mod\n y %= mod\nt = pow(2,n,mod)\nprint((y*pow(t,mod-1,mod))%mod)"}, {"source_code": "# Coder : Hakesh D #\nimport sys\n#input=sys.stdin.readline\n\nfrom collections import deque\nfrom math import ceil,sqrt,gcd,factorial\nfrom bisect import bisect_right,bisect_left\n\nmod = 998244353\nINF = 10**18\nNINF = -INF\ndef I():return int(input())\ndef MAP():return map(int,input().split())\ndef LIST():return list(map(int,input().split()))\ndef modi(x):return pow(x,mod-2,mod)\ndef lcm(x,y):return (x*y)//gcd(x,y)\ndef write(l):\n for i in l:\n print(i,end=' ') \n print()\n########################################################################################\narr = [0,1]\nfor i in range(200002):\n arr.append((arr[-1]+arr[-2])%mod)\n\n\n\nn = int(input())\niden = modi(pow(2,n,mod))\nans = (arr[n]*iden)%mod\nprint(arr[n],pow(2,n))\nprint(ans)\n"}, {"source_code": "def power(a, b, mod):\n res = 1\n \n while b:\n if b%2:\n res = (res*a)%mod\n \n b //= 2\n a = (a*a)%mod \n \n return res%mod\n\ndef divide(a, b, mod):\n return (a * power(b, mod-2, mod)) % mod\n\nn = int(input())\nMOD = 998244353\n\nfib = [0, 1]\nfor i in range(2, 200001):\n fib.append((fib[-1] + fib[-2])%MOD)\n\ndivide(fib[n], power(2, n, MOD), MOD)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nmod = 998244353\ndef modinv(n):\n return pow(n, mod-2, mod)\nif n == 1:\n print(1)\n exit()\n\nu = [0]*(n+1)\nu[0] = 1\nu[1] = 1\nu[2] = 1\nk = pow(2,n,mod)\nacum = [0]*(n+1)\nacum[0] = 1\nacum[1] = 2\nacum[2] = 3\n\nfor i in range(3,n+1):\n acum[i] = (acum[i-2]+acum[i-1])%mod\nprint((acum[-3]*modinv(k))%mod)\n"}, {"source_code": "def modinv(n, p):\n return pow(n, p - 2, p)\ndef main():\n MOD = 998244353\n n = int(input())\n q = modinv(pow(2, n, MOD), MOD)\n\n fib = [0] * 200005\n fib[1] = 1\n fib[2] = 1\n\n for i in range(3, 200005):\n fib[i] = fib[i - 1] + fib[i - 2]\n fib[i] %= MOD\n\n p = fib[n]\n print(p, q)\n\n ans = (p % MOD * q % MOD) % MOD\n print(ans)\nmain()"}, {"source_code": "def modInverse(a, m):\n g = gcd(a, m)\n if g != 1:\n return 1\n else:\n return power_fct(a, m - 2, m)\n\n\ndef power_fct(x, y, m):\n if y == 0:\n return 1\n\n p = power_fct(x, y // 2, m) % m\n p = (p * p) % m\n\n if y % 2 == 0:\n return p\n else:\n return (x * p) % m\n\n\ndef gcd(a, b):\n if a == 0:\n return b\n return gcd(b % a, a)\n\n\ndef radio_towers():\n n = int(input())\n modulo = 998244353\n\n fib = [1, 1]\n power = 4\n\n for i in range(2, n):\n fib = [sum(fib) % modulo, fib[0]]\n power = (power * 2) % modulo\n\n print((modInverse(power, modulo) * fib[0]) % modulo)\n\n\nif __name__ == \"__main__\":\n radio_towers()\n"}, {"source_code": "def modInverse(a, m):\n g = gcd(a, m)\n if g != 1:\n return 1\n else:\n return power_fct(a, m - 2, m)\n\n\ndef power_fct(x, y, m):\n if y == 0:\n return 1\n\n p = power_fct(x, y // 2, m) % m\n p = (p * p) % m\n\n if y % 2 == 0:\n return p\n else:\n return (x * p) % m\n\n\ndef gcd(a, b):\n if a == 0:\n return b\n return gcd(b % a, a)\n\n\ndef radio_towers():\n n = int(input())\n modulo = 998244353\n\n fib = [1, 1]\n power = 4\n\n for i in range(2, n):\n fib = [sum(fib) % modulo, fib[0]]\n power = (power * 2) % modulo\n\n print((modInverse(power, modulo) * fib[0]) % modulo)\n\n\nif __name__ == \"__main__\":\n radio_towers()\n"}, {"source_code": "def modInverse(a, m):\n m0 = m\n y = 0\n x = 1\n\n if m == 1:\n return 0\n\n while (a > 1):\n # q is quotient\n q = a // m\n\n t = m\n\n m = a % m\n a = t\n t = y\n\n # Update x and y\n y = x - q * y\n x = t\n\n # Make x positive\n if x < 0:\n x = x + m0\n\n return x\n\ndef radio_towers():\n n = int(input())\n modulo = 998244353\n\n fib = [1, 1]\n power = 4\n\n for i in range(2, n):\n fib = [sum(fib) % modulo, fib[0]]\n power = (power * 2) % modulo\n\n print((modInverse(power, modulo) * fib[0]) % modulo)\n\n\nif __name__ == \"__main__\":\n radio_towers()\n"}, {"source_code": "def modInverse(a, m):\n m0 = m\n y = 0\n x = 1\n\n if m == 1:\n return 0\n\n while (a > 1):\n # q is quotient\n q = a // m\n\n t = m\n\n m = a % m\n a = t\n t = y\n\n # Update x and y\n y = x - q * y\n x = t\n\n # Make x positive\n if x < 0:\n x = x + m0\n\n return x\n\n\ndef radio_towers():\n n = int(input())\n modulo = 998244353\n\n fib = [1, 1]\n power = 4\n\n for i in range(2, n):\n fib = [sum(fib) % modulo, fib[0] % modulo]\n power = (power * 2) % modulo\n\n print((modInverse(power, modulo) * fib[0]) % modulo)\n\n\nif __name__ == \"__main__\":\n radio_towers()\n"}, {"source_code": "n = int(input())\nmod = 998244353\n\n\ndef modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n\n\na = 1\nb = 1\nif n <= 2:\n if n == 1:\n print(modinv(2, mod))\n else:\n print(modinv(4, mod))\n\nk = 1\nfor i in range(n):\n k *= 2\n k %= mod\n\nfor i in range(2, n):\n a, b = a+b, a\n\nprint((a * modinv(k, mod)) % mod)\n"}], "src_uid": "cec37432956bb0a1ce62a0188fe2d805"} {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n", "positive_code": [{"source_code": "start = raw_input().strip()\nend = raw_input().strip()\nk = int(raw_input())\nif k == 0:\n if start == end:\n print 1\n else:\n print 0\n exit(0)\nL = len(start)\nans = tmp = 0\nmod = 10 ** 9 + 7\nfor i in xrange(1, L):\n if start[i:] + start[:i] == end:\n tmp += 1\nif start == end:\n p = [1, 0]\n for i in xrange(k):\n p = [p[1], (p[0] * (L-1) + p[1] * (L-2)) % mod]\n ans += p[0]\nif tmp > 0:\n p = [0, 1]\n for i in xrange(k):\n p = [p[1], (p[0] * (L-1) + p[1] * (L-2)) % mod]\n ans += p[0] * tmp % mod\nprint ans % mod\n"}, {"source_code": "'''\nCreated on Apr 20, 2012\n\n@author: Tobias Flach\n'''\n\ndef solve():\n prime = 1000000007\n \n str_a = raw_input()\n str_b = raw_input()\n k = int(raw_input())\n \n good_shifts = 0\n bad_shifts = 0\n \n for i in range(0, len(str_a)):\n shifted = str_a[i:] + str_a[:i]\n if shifted == str_b:\n good_shifts += 1\n else:\n bad_shifts += 1\n \n good_sols = 0\n bad_sols = 0\n if str_a == str_b:\n good_sols = 1\n else:\n bad_sols = 1\n \n for i in range(0, k):\n t_good_sols = good_sols * (good_shifts - 1) + bad_sols * good_shifts\n t_bad_sols = good_sols * bad_shifts + bad_sols * (bad_shifts - 1)\n good_sols = t_good_sols % prime\n bad_sols = t_bad_sols % prime\n \n print \"%d\" % (good_sols)\n\nif __name__ == '__main__':\n solve()"}, {"source_code": "import sys\n\nstart = raw_input()\nend = raw_input()\nk = int(raw_input())\n\ndpA = [-1 for i in xrange(k+1)]\ndpB = [-1 for i in xrange(k+1)]\n\ndef calculaA(n):\n global dpA, dpB\n if n == 0:\n return 0\n if dpA[n-1] == -1:\n calculaA(n-1)\n\n dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A\n dpB[n] = dpA[n-1]*B + dpB[n-1]*(B-1)\n\n return dpA[n]\n\nif start == end and k == 0:\n print 1\n exit(0)\n\nA = B = 0\n\nif start != end:\n dpA[0] = 0\n dpB[0] = 1\nelse:\n dpA[0] = 1\n dpB[0] = 0\n\n\nfor i in xrange(len(start)):\n now = start[i:]+start[:i]\n \n if now == end:\n A += 1\n else:\n B += 1\n\n\n\nfor n in xrange(1, k+1):\n dpA[n] = (dpA[n-1]*(A-1) + dpB[n-1]*A)%1000000007\n dpB[n] = (dpA[n-1]*B + dpB[n-1]*(B-1))%1000000007\n\nprint dpA[k]\n\n"}, {"source_code": "class Solution():\n\tdef number_or_ways(start, end, moves):\n\t\tp = 10**9+7\n\t\tnum_rots = 0\n\t\tfor i in range(len(start)):\n\t\t\trot = start[i:]+start[0:i]\n\t\t\tif rot == end:\n\t\t\t\tnum_rots += 1\n\n\t\tdp = [[0 for i in range(2)] for j in range(moves+1)]\n\n\t\tdp[0][0], dp[0][1] = 1, 0\n\n\t\tfor i in range(1, moves+1):\n\t\t\tdp[i][0] = (((num_rots-1)*dp[i-1][0])%p + ((len(start)-num_rots)*dp[i-1][1])%p)%p\n\t\t\tdp[i][1] = ((num_rots*dp[i-1][0])%p + ((len(start)-1-num_rots)*dp[i-1][1])%p)%p\n\n\t\tif start == end:\n\t\t\treturn dp[moves][0]\n\t\telse:\n\t\t\treturn dp[moves][1]\n\nstart = input().strip()\nend = input().strip()\n\nmoves = int(input())\n\nprint(Solution.number_or_ways(start, end, moves)) \n\n"}, {"source_code": "def WordCut():\n start = input()\n end = input()\n k = int(input())\n n=len(start)\n dpA,dpB = (start==end),(start!=end)\n end+=end\n A=sum(start==end[i:i+n] for i in range(n))\n B = n- A\n M = 10**9+7\n for _ in range(k):\n dpA,dpB=(dpA*(A-1)+dpB*A)%M,(dpA*B+dpB*(B-1))%M\n return int(dpA)\n\nprint(WordCut())"}, {"source_code": "from collections import deque\n\nstart = deque(input())\nend = deque(input())\nk = int(input())\n\nn = len(start)\n\ndeu = 0\nnaoDeu = 0\nfor i in range(0, n):\n\n\tif (start == end):\n\t\tdeu += 1\n\telse:\n\t\tnaoDeu += 1\n\n\tstart.rotate(1)\n\ndpDeu = [0] * (k + 1)\ndpNaoDeu = [0] * (k + 1)\n\nif (start == end):\n\tdpDeu[0] = 1\n\tdpNaoDeu[0] = 0\n\nelse:\n\tdpDeu[0] = 0\n\tdpNaoDeu[0] = 1\n\nfor i in range(1, k + 1):\n\tdpDeu[i] = (dpDeu[i - 1] * (deu - 1) + dpNaoDeu[i - 1] * deu) % 1000000007\n\tdpNaoDeu[i] = (dpDeu[i - 1] * naoDeu + dpNaoDeu[i - 1] * (naoDeu - 1)) % 1000000007\n\nprint(dpDeu[k])\n\n\n\n\n"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n MOD = int(1e9 + 7)\n\n a = input()\n b = input()\n n = int(input())\n\n ca, cb = 0,0\n\n for i in range(len(a)):\n s = a[i:] + a[:i]\n if s == b:\n ca += 1\n else:\n cb += 1\n \n if ca == 0:\n print(0)\n return\n\n da = [0] * (n + 1)\n db = da[:]\n\n da[0] = 1 if a == b else 0\n db[0] = 1 - da[0]\n\n for i in range(1, n + 1):\n da[i] = da[i - 1] * (ca - 1) + db[i - 1] * ca\n db[i] = da[i - 1] * cb + db[i - 1] * (cb - 1)\n da[i] %= MOD\n db[i] %= MOD\n # print(da[i], db[i], ca, cb)\n print(da[n])\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n"}, {"source_code": "M = 1000000007\na = raw_input()\nb = raw_input()\nk = input()\n\nr = [i for i in xrange(0,len(a)) if a[i:] + a[:i] == b]\n\nx,y = 1, 0\nl = len(a)\nfor _ in xrange(k):\n x, y = y*(l-1)%M, (x+y*(l-2))%M\n\nif 0 in r: print (x + y * (len(r) - 1))%M\nelse: print y * len(r) % M\n"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)"}, {"source_code": "\ndef main():\n inicio = raw_input()\n fim = raw_input()\n k = int(raw_input())\n\n vA = [-1]*(k+1)\n vB = [-1]*(k+1)\n\n if inicio == fim and k == 0:\n return 1\n else:\n A = B = 0\n\n if inicio != fim:\n vA[0] = 0\n vB[0] = 1\n else:\n vA[0] = 1\n vB[0] = 0\n\n for i in xrange(len(inicio)):\n atual = inicio[i:]+inicio[:i]\n if atual == fim:\n A += 1\n else:\n B += 1\n\n for n in xrange(1, k+1):\n vA[n] = (vA[n-1]*(A-1) + vB[n-1]*A)%1000000007\n vB[n] = (vA[n-1]*B + vB[n-1]*(B-1))%1000000007\n\n return vA[k]\n\nif __name__ == '__main__':\n print main()"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "\n\nMOD = 1000000007\n\nstart = raw_input()\nend = raw_input()\nk = input()\n\nA = 0\nB = 0\nfor i in range(len(start)):\n if start[i:] + start[:i] == end:\n A += 1\n else:\n B += 1\n\nf0, g0 = 0, 0\nif start == end:\n f0 = 1\nelse:\n g0 = 1\n\nden = pow(A + B, MOD - 2, MOD)\nc1 = A * (f0 + g0) * den % MOD\nc2 = (B * f0 - A * g0) * den % MOD\nfn = c1 * pow(A + B - 1, k, MOD)\nif k % 2:\n fn -= c2\nelse:\n fn += c2\nfn %= MOD\n\nprint(fn)"}, {"source_code": "\n\nMOD = 1000000007\nstart = raw_input()\nend = raw_input()\nk = input()\n\nA = 0\nB = 0\nfor i in range(len(start)):\n if start[i:] + start[:i] == end:\n A += 1\n else:\n B += 1\n\ndpA = [0] * (k + 1)\ndpB = [0] * (k + 1)\n\nif start == end:\n dpA[0] = 1\nelse:\n dpB[0] = 1\n\nfor i in range(1, k + 1):\n dpA[i] = (dpA[i - 1] * (A - 1) + dpB[i - 1] * A) % MOD\n dpB[i] = (dpA[i - 1] * B + dpB[i - 1] * (B - 1)) % MOD\n\nprint(dpA[k])\n"}, {"source_code": "\n\nMOD = 1000000007\n\n\ndef kmp(s, p):\n pi = [0 for _ in range(len(p))]\n k = 0\n for i in range(1, len(p)):\n while k > 0 and p[k] != p[i]:\n k = pi[k - 1]\n if p[k] == p[i]:\n k += 1\n pi[i] = k\n\n k = 0\n resp = []\n for i in range(len(s)):\n while k > 0 and p[k] != s[i]:\n k = pi[k - 1]\n if p[k] == s[i]:\n k += 1\n if k == len(p):\n resp.append(i - len(p) + 1)\n k = pi[k - 1]\n return resp\n\nstart = raw_input()\nend = raw_input()\nk = input()\n\nA = len(kmp(start + start, end))\nB = len(start) - A\n\nf0, g0 = 0, 0\nif start == end:\n f0 = 1\n A -= 1\n B += 1\nelse:\n g0 = 1\n\nden = pow(A + B, MOD - 2, MOD)\nc1 = A * (f0 + g0) * den % MOD\nc2 = (B * f0 - A * g0) * den % MOD\nfn = c1 * pow(A + B - 1, k, MOD)\nif k % 2:\n fn -= c2\nelse:\n fn += c2\nfn %= MOD\n\nprint(fn)"}, {"source_code": "\n\nMOD = 1000000007\n\ndef mult(a, b):\n c = [[0, 0], [0, 0]]\n for i in range(2):\n for j in range(2):\n for k in range(2):\n c[i][j] += a[i][k] * b[k][j]\n c[i][j] %= MOD\n return c\n\ndef modpow(a, n):\n b = [[1, 0], [0, 1]]\n while n:\n if n % 2:\n b = mult(a, b)\n a = mult(a, a)\n n /= 2\n return b\n\n\nstart = raw_input()\nend = raw_input()\nk = input()\n\nA = 0\nB = 0\nfor i in range(len(start)):\n if start[i:] + start[:i] == end:\n A += 1\n else:\n B += 1\n\nf0, g0 = 0, 0\nif start == end:\n f0 = 1\nelse:\n g0 = 1\n\nF = [[A - 1, A], [B, B - 1]]\nF = modpow(F, k)\nans = (F[0][0] * f0 + F[0][1] * g0) % MOD\n\nprint(ans)"}, {"source_code": "\n\nMOD = 1000000007\n\ndef mult(a, b):\n c = [[0, 0], [0, 0]]\n for i in range(2):\n for j in range(2):\n for k in range(2):\n c[i][j] += a[i][k] * b[k][j]\n c[i][j] %= MOD\n return c\n\ndef modpow(a, n):\n b = [[1, 0], [0, 1]]\n while n:\n if n % 2:\n b = mult(a, b)\n a = mult(a, a)\n n /= 2\n return b\n\ndef kmp(s, p):\n pi = [0 for _ in range(len(p))]\n k = 0\n for i in range(1, len(p)):\n while k > 0 and p[k] != p[i]:\n k = pi[k - 1]\n if p[k] == p[i]:\n k += 1\n pi[i] = k\n\n k = 0\n resp = []\n for i in range(len(s)):\n while k > 0 and p[k] != s[i]:\n k = pi[k - 1]\n if p[k] == s[i]:\n k += 1\n if k == len(p):\n resp.append(i - len(p) + 1)\n k = pi[k - 1]\n return resp\n\nstart = raw_input()\nend = raw_input()\nk = input()\n\nA = len(kmp(start + start, end))\nB = len(start) - A\n\nf0, g0 = 0, 0\nif start == end:\n f0 = 1\n A -= 1\n B += 1\nelse:\n g0 = 1\n\nF = [[A - 1, A], [B, B - 1]]\nF = modpow(F, k)\nans = (F[0][0] * f0 + F[0][1] * g0) % MOD\n\nprint(ans)\n"}, {"source_code": "\nMOD = 1000000007\n\nif __name__ == '__main__':\n a, b, k = raw_input(), raw_input(), int(raw_input())\n \n str_len = len(a)\n cut_pos = [i for i in xrange(str_len) if a[i:] + a[:i] == b]\n cut_pos_len= len(cut_pos)\n sum = 1\n unit = 0\n for x in xrange(1, k+1):\n unit = sum - unit\n sum *= str_len-1\n sum %= MOD\n ans = unit*cut_pos_len%MOD\n if cut_pos_len > 0 and cut_pos[0] == 0:\n ans += (-1 if k % 2 else 1)\n if ans < 0: ans += MOD\n ans %= MOD \n print ans\n \n "}, {"source_code": "\nMOD = 1000000007\n\nif __name__ == '__main__':\n a, b, k = raw_input(), raw_input(), int(raw_input())\n \n str_len = len(a)\n cut_pos = [i for i in xrange(str_len) if a[i:] + a[:i] == b]\n cut_pos_len = len(cut_pos)\n sum = 1\n x, y = 1, 0\n for _ in xrange(k):\n x = sum - x\n y = sum - y\n sum *= str_len-1\n sum %= MOD\n print (x+y*(cut_pos_len-1))%MOD if 0 in cut_pos else y*cut_pos_len%MOD\n \n "}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n"}, {"source_code": "\nMOD = 1000000007\n\nif __name__ == '__main__':\n a, b, k = raw_input(), raw_input(), int(raw_input())\n \n str_len = len(a)\n cut_pos = [i for i in xrange(str_len) if a[i:] + a[:i] == b]\n cut_pos_len= len(cut_pos)\n sum = 1\n unit = 0\n for x in xrange(1, k+1):\n unit = sum - unit\n sum *= str_len-1\n sum %= MOD\n ans = unit*cut_pos_len%MOD\n if cut_pos_len > 0 and cut_pos[0] == 0:\n ans += (-1 if k % 2 else 1)\n if ans < 0: ans += MOD\n ans %= MOD \n print ans\n \n "}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint int(x)\n\n"}, {"source_code": "import sys\n\nstart = raw_input()\nend = raw_input()\nk = int(raw_input())\n\ndpA = [-1 for i in xrange(k+1)]\ndpB = [-1 for i in xrange(k+1)]\n\ndef calculaA(n):\n global dpA, dpB\n if n == 0:\n return 0\n if dpA[n-1] == -1:\n calculaA(n-1)\n\n dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A\n dpB[n] = dpA[n-1]*B + dpB[n-1]*(B-1)\n\n return dpA[n]\n\nif start == end and k == 0:\n print 1\n exit(0)\n\nA = B = 0\n\nif start != end:\n dpA[0] = 0\n dpB[0] = 1\nelse:\n dpA[0] = 1\n dpB[0] = 0\n\n\nfor i in xrange(len(start)):\n now = start[i:]+start[:i]\n \n if now == end:\n A += 1\n else:\n B += 1\n\n\n\nfor n in xrange(1, k+1):\n dpA[n] = (dpA[n-1]*(A-1) + dpB[n-1]*A)%1000000007\n dpB[n] = (dpA[n-1]*B + dpB[n-1]*(B-1))%1000000007\n\nprint dpA[k]\n\n"}, {"source_code": "from sys import stdin\nfrom collections import *\n\n\ndef count():\n g = 0\n for i in range(len(s1)):\n s1.rotate(-1)\n g += (s1 == s2)\n\n return g, len(s1) - g\n\n\ndef dp():\n mem = [[0, 0] for _ in range(k + 1)]\n mem[0][0] = (s1 == s2) & 1\n mem[0][1] = 1 - mem[0][0]\n\n for i in range(1, k + 1):\n mem[i][0] = add(mult(mem[i - 1][0], max(good - 1, 0)), mult(mem[i - 1][1], good))\n mem[i][1] = add(mult(mem[i - 1][1], max(bad - 1, 0)), mult(mem[i - 1][0], bad))\n\n print(mem[-1][0] % mod)\n\n\nrstr = lambda: stdin.readline().strip()\nadd = lambda a, b: (a % mod + b % mod) % mod\nmult = lambda a, b: ((a % mod) * (b % mod)) % mod\nmod = 10 ** 9 + 7\n\ns1, s2, k = deque(rstr()), deque(rstr()), int(input())\ngood, bad = count()\ndp()\n"}, {"source_code": "MOD = int(1e9) + 7\nif __name__ == \"__main__\":\n a, b, k = input(), input(), int(input())\n x, y = (1, 0) if a == b else (0, 1)\n n = len(b)\n b += b\n same = sum(a == b[i: i + n] for i in range(n))\n diff = n - same\n for _ in range(k):\n x, y = ((x * (same - 1)) % MOD + (y * same) % MOD) % MOD, ((x * (diff)) % MOD + (y * (diff - 1)) % MOD) % MOD\n print(x)\n"}, {"source_code": "MOD = int(1e9) + 7\nif __name__ == \"__main__\":\n a = input()\n b = input()\n k = int(input())\n if(len(a) != len(b)):\n print(0)\n exit()\n a = a + a\n x = 0\n y = 0\n for i in range(len(a) // 2):\n flag = 1\n for j in range(len(b)):\n if(a[j + i] != b[j]):\n flag = 0\n break\n if(flag == 1):\n x += 1\n else:\n y += 1\n flag = 0\n for i in range(len(b)):\n if(a[i] != b[i]):\n flag = 1\n u = 1\n v = 0\n if(flag == 1):\n v = 1\n u = 0\n for i in range(k):\n uu = (u * (x - 1)) % MOD + (v * (x)) % MOD\n vv = (u * (y)) % MOD + (v * (y - 1)) % MOD\n u = uu % MOD\n v = vv % MOD\n print(u)\n\n\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------- fast io --------------------\nfrom math import gcd, ceil\n\ndef prod(a, mod=10**9+7):\n ans = 1\n for each in a:\n ans = (ans * each) % mod\n return ans\n\ndef lcm(a, b): return a * b // gcd(a, b)\n\ndef binary(x, length=16):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\nfrom collections import deque\n\nfor _ in range(int(input()) if not True else 1):\n #n = int(input())\n #n, k = map(int, input().split())\n #a, b = map(int, input().split())\n #c, d = map(int, input().split())\n #a = list(map(int, input().split()))\n #b = list(map(int, input().split()))\n s1 = deque(k for k in input())\n s2 = deque(k for k in input())\n n = len(s1)\n k = int(input())\n if k == 0:\n print(int(s1==s2))\n quit()\n mod = 10**9 + 7\n n1pow = [1]\n for i in range(696969):\n n1pow += [(n1pow[-1]*(n-1)) % mod]\n ans0 = 0\n for i in range(1, k):\n ans0 = (n1pow[i] - ans0) % mod\n ans1 = 1\n for i in range(1, k):\n ans1 = (n1pow[i] - ans1) % mod\n #print(ans0, ans1)\n total = 0\n for t in range(n):\n if s1 == s2:\n total += ans1 if t else ans0\n s1.appendleft(s1.pop())\n print(total % mod)"}, {"source_code": "start, end, k = input(), input(), int(input())\ndp = [[start == end for _ in range(k + 1)], [start != end for _ in range(k + 1)]]\nmod = int(1e9 + 7)\nsame = sum(end == (start[i: len(start)] + start[0: i]) for i in range(len(start)))\ndiff = len(start) - same\nfor i in range(1, k + 1):\n dp[0][i] = (dp[0][i - 1] * (same - 1) + dp[1][i - 1] * same) % mod\n dp[1][i] = (dp[0][i - 1] * diff + dp[1][i - 1] * (diff - 1)) % mod\nprint(int(dp[0][k]))"}], "negative_code": [{"source_code": "\n\nstart = raw_input()\nend = raw_input()\nk = int(raw_input())\n\ndpA = [-1 for i in xrange(k+1)]\ndpB = [-1 for i in xrange(k+1)]\n\ndef calculaA(n):\n global dpA, dpB\n if n == 0:\n return 0\n if dpA[n-1] == -1:\n calculaA(n-1)\n\n dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A\n dpB[n] = dpA[n-1]*B + dpB[n-1]*(B-1)\n\n return dpA[n]\n\n\nA = B = 0\n\nif start != end:\n dpA[0] = 0\n dpB[0] = 1\nelse:\n dpA[0] = 1\n dpB[0] = 0\n\n\nfor i in xrange(len(start)):\n now = start[i:]+start[:i]\n \n if now == end:\n A += 1\n else:\n B += 1\n\nprint calculaA(k)\n\n"}, {"source_code": "class Solution():\n\tdef number_or_ways(start, end, moves):\n\t\tp = 10**9+7\n\t\tnum_rots = 1\n\t\tfor i in range(1, len(start)-1):\n\t\t\trot = start[i:]+start[0:i]\n\t\t\tif rot == end:\n\t\t\t\tnum_rots += 1\n\n\t\tdp = [[0 for i in range(2)] for j in range(moves+1)]\n\n\t\tdp[0][0], dp[0][1] = 1, 0\n\n\t\tfor i in range(1, moves+1):\n\t\t\tdp[i][0] = (((num_rots-1)*dp[i-1][0])%p + ((len(start)-num_rots)*dp[i-1][1])%p)%p\n\t\t\tdp[i][1] = ((num_rots*dp[i-1][0])%p + ((len(start)-1-num_rots)*dp[i-1][1])%p)%p\n\n\t\tif start == end:\n\t\t\treturn dp[moves][0]\n\t\telse:\n\t\t\treturn dp[moves][1]\n\nstart = input().strip()\nend = input().strip()\n\nmoves = int(input())\n\nprint(Solution.number_or_ways(start, end, moves)) \n\n"}, {"source_code": "def WordCut():\n start = input()\n end = input()\n k = int(input())\n n=len(start)\n dpA,dpB = (start==end),(start!=end)\n end+=end\n A=sum(start==end[i:i+n] for i in range(n))\n B = n- A\n M = 10**9+7\n for _ in range(k):dpA,dpB=(dpA*(A-1)+dpB*A)%M,(dpA*B+dpB*(B-1))%M\n return dpA\n\nprint(WordCut())"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n MOD = int(1e9 + 7)\n\n a = input()\n b = input()\n n = int(input())\n\n ca, cb = 0,0\n\n for i in range(len(a)):\n s = a[i:] + a[:i]\n if s == b:\n ca += 1\n else:\n cb += 1\n \n da = [0] * (n + 1)\n db = da[:]\n\n da[0] = 1 if a == b else 0\n db[0] = 1 - da[0]\n\n for i in range(1, n + 1):\n da[i] = da[i - 1] * (ca - 1) + db[i - 1] * cb\n db[i] = da[i - 1] * ca + db[i - 1] * (cb - 1)\n da[i] %= MOD\n db[i] %= MOD\n print(da[n])\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n MOD = int(1e9 + 7)\n\n a = input()\n b = input()\n n = int(input())\n\n ca, cb = 0,0\n\n for i in range(len(a)):\n s = a[i:] + a[:i]\n if s == b:\n ca += 1\n else:\n cb += 1\n \n if ca == 0:\n print(0)\n return\n\n da = [0] * (n + 1)\n db = da[:]\n\n da[0] = 1 if a == b else 0\n db[0] = 1 - da[0]\n\n for i in range(1, n + 1):\n da[i] = da[i - 1] * (ca - 1) + db[i - 1] * cb\n db[i] = da[i - 1] * ca + db[i - 1] * (cb - 1)\n da[i] %= MOD\n db[i] %= MOD\n print(da[n])\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n MOD = int(1e9 + 7)\n\n a = input()\n b = input()\n n = int(input())\n\n ca, cb = 0,0\n\n for i in range(len(a)):\n s = a[i:] + a[:i]\n if s == b:\n ca += 1\n else:\n cb += 1\n \n if ca == 0:\n print(0)\n return\n\n da = [0] * (n + 1)\n db = da[:]\n\n da[0] = 1 if a == b else 0\n db[0] = 1 - da[0]\n\n for i in range(1, n + 1):\n da[i] = da[i - 1] * (ca - 1) + db[i - 1] * ca\n db[i] = da[i - 1] * cb + db[i - 1] * (cb - 1)\n da[i] %= MOD\n db[i] %= MOD\n print(da[i], db[i], ca, cb)\n print(da[n])\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n MOD = int(1e9 + 7)\n\n a = input()\n b = input()\n n = int(input())\n\n ca, cb = 0,0\n\n for i in range(len(a)):\n s = a[i:] + a[:i]\n if s == b:\n ca += 1\n else:\n cb += 1\n \n da = [0] * (n + 1)\n db = da[:]\n\n da[0] = 1 if a == b else 0\n db[0] = 1 - da[0]\n\n for i in range(1, n + 1):\n da[i] = da[i - 1] * (ca - 1) + db[i - 1] * cb\n db[i] = da[i - 1] * ca + db[i - 1] * (cb - 1)\n print(da[n])\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n MOD = int(1e9 + 7)\n\n a = input()\n b = input()\n n = int(input())\n\n ca, cb = 0,0\n\n for i in range(len(a)):\n s = a[i:] + a[:i]\n if s == b:\n ca += 1\n else:\n cb += 1\n \n if ca == 0:\n print(0)\n return\n\n da = [0] * (n + 1)\n db = da[:]\n\n da[0] = 1 if a == b else 0\n db[0] = 1 - da[0]\n\n for i in range(1, n + 1):\n da[i] = da[i - 1] * (ca - 1)\n da[i] += db[i - 1] * cb\n db[i] = da[i - 1] * ca\n if cb:\n db[i - 1] * (cb - 1)\n da[i] %= MOD\n db[i] %= MOD\n print(da[n])\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a,b,k=raw_input(),raw_input(),input()\nn=len(a)\nx,y=(a==b),(a!=b)\nb+=b\nz=sum(a==b[i:i+n] for i in range(n))\nt=n-z\nM=10**9+7\nfor _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M\nprint x\n"}, {"source_code": "M = 1000000007\na = raw_input()\nb = raw_input()\nk = input()\n\nr = [i for i in xrange(1,len(a)) if a[i:] + a[:i] == b]\n\nx,y = 0, 1\nl = len(a)\nfor _ in xrange(k):\n x, y = y*(l-1)%M, (x+y*(l-2))%M\n\nif 0 in r: print (x + y * (len(r) - 1))%M\nelse: print y * len(r) % M\n"}, {"source_code": "\n\nMOD = 1000000007\n\nstart = raw_input()\nend = raw_input()\nk = input()\n\nA = 0\nB = 0\nfor i in range(len(start)):\n if start[i:] + start[:i] == end:\n A += 1\n else:\n B += 1\n\nf0, g0 = 0, 0\nif start == end:\n f0 = 1\n A -= 1\n B += 1\nelse:\n g0 = 1\n\nden = pow(A + B, MOD - 2, MOD)\nc1 = A * (f0 + g0) * den % MOD\nc2 = (B * f0 - A * g0) * den % MOD\nfn = c1 * pow(A + B - 1, k, MOD)\nif k % 2:\n fn -= c2\nelse:\n fn += c2\nfn %= MOD\n\nprint(fn)"}, {"source_code": "\nMOD = 1000000007\n\nif __name__ == '__main__':\n a, b, k = raw_input(), raw_input(), int(raw_input())\n \n str_len = len(a)\n cut_pos = [i for i in xrange(str_len) if a[i:] + a[:i] == b]\n cut_pos_len= len(cut_pos)\n sum = 1\n x, y = 1, 0\n for _ in xrange(k):\n x = sum - x\n y = sum - y\n sum *= str_len-1\n sum %= MOD\n print (x+y*(str_len-1))%MOD if 0 in cut_pos else y*str_len%MOD\n \n "}, {"source_code": "\nMOD = 1000000007\n\ndef mat_mul(a, b, n):\n c = [[0]*n]*n\n for k in xrange(n):\n for i in xrange(n):\n if a[i][k]:\n for j in xrange(n):\n c[i][j] += a[i][k] * b[k][j]\n c[i][j] %= MOD\n return c\n\ndef mat_pow(a, n, k):\n if k == 0: return [[int(i==j) for j in xrange(n)] for i in xrange(n)]\n if k == 1: return a\n b = mat_pow(a, n, k//2)\n b = mat_mul(b, b, n)\n if n % 2: b = mat_mul(b, a, n)\n return b\n\nif __name__ == '__main__':\n \n start, end = raw_input(), raw_input()\n k = int(raw_input())\n \n str_len = len(start)\n \n dp = [0] * str_len\n dp[0] = 1\n p = [[int(i!=j) for j in xrange(str_len)] for i in xrange(str_len)]\n p = mat_pow(p, str_len, k)\n \n ans = 0\n for j in xrange(str_len):\n if start[j:] + start[:j] == start:\n for i in xrange(str_len):\n ans += dp[i]*p[i][j]\n ans %= MOD\n print ans\n \n \n \n "}, {"source_code": "from sys import stdin\nfrom collections import *\n\n\ndef count():\n g = 0\n for i in range(len(s1) - 1):\n s1.rotate(-1)\n g += (s1 == s2)\n\n s1.rotate(-1)\n return g, len(s1) - g - 1\n\n\ndef dp():\n mem = [[0, 0] for _ in range(k + 1)]\n mem[0][0] = (s1 == s2) & 1\n mem[0][1] = 1 - mem[0][0]\n\n for i in range(1, k + 1):\n mem[i][0] = add(mult(mem[i - 1][0], max(good - 1, 0)), mult(mem[i - 1][1], good))\n mem[i][1] = add(mult(mem[i - 1][1], max(bad - 1, 0)), mult(mem[i - 1][0], bad))\n\n print(mem[-1][0] % mod)\n\n\nrstr = lambda: stdin.readline().strip()\nadd = lambda a, b: (a + b) % mod\nmult = lambda a, b: ((a % mod) * (b % mod)) % mod\nmod = 10 ** 9 + 7\n\ns1, s2, k = deque(rstr()), deque(rstr()), int(input())\ngood, bad = count()\n# print(good,bad)\ndp()\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------- fast io --------------------\nfrom math import gcd, ceil\n\ndef prod(a, mod=10**9+7):\n ans = 1\n for each in a:\n ans = (ans * each) % mod\n return ans\n\ndef lcm(a, b): return a * b // gcd(a, b)\n\ndef binary(x, length=16):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\nfrom collections import deque\n\nfor _ in range(int(input()) if not True else 1):\n #n = int(input())\n #n, k = map(int, input().split())\n #a, b = map(int, input().split())\n #c, d = map(int, input().split())\n #a = list(map(int, input().split()))\n #b = list(map(int, input().split()))\n s1 = deque(k for k in input())\n s2 = deque(k for k in input())\n n = len(s1)\n k = int(input())\n if k == 0:\n print(int(s1==s2))\n quit()\n mod = 10**9 + 7\n n1pow = [1]\n for i in range(696969):\n n1pow += [(n1pow[-1]*(n-1)) % mod]\n ans0 = 0\n for i in range(2, k+1):\n ans0 = (n1pow[i] - ans0) % mod\n ans1 = 1\n for i in range(2, k+1):\n ans1 = (n1pow[i] - ans1) % mod\n #print(ans0, ans1)\n total = 0\n for t in range(n):\n if s1 == s2:\n total += ans1 if t else ans0\n s1.appendleft(s1.pop())\n print(total % mod)"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------- fast io --------------------\nfrom math import gcd, ceil\n\ndef prod(a, mod=10**9+7):\n ans = 1\n for each in a:\n ans = (ans * each) % mod\n return ans\n\ndef lcm(a, b): return a * b // gcd(a, b)\n\ndef binary(x, length=16):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\nfrom collections import deque\n\nfor _ in range(int(input()) if not True else 1):\n #n = int(input())\n #n, k = map(int, input().split())\n #a, b = map(int, input().split())\n #c, d = map(int, input().split())\n #a = list(map(int, input().split()))\n #b = list(map(int, input().split()))\n s1 = deque(k for k in input())\n s2 = deque(k for k in input())\n n = len(s1)\n k = int(input())\n if k == 0:\n print(int(s1==s2))\n quit()\n mod = 10**9 + 7\n n1pow = [1]\n for i in range(696969):\n n1pow += [(n1pow[-1]*(n-1)) % mod]\n ans0 = 0\n for i in range(2, k+1):\n ans0 = (n1pow[i] - ans0) % mod\n ans1 = 1\n for i in range(1, k):\n ans1 = (n1pow[i] - ans1) % mod\n #print(ans0, ans1)\n total = 0\n for t in range(n):\n if s1 == s2:\n total += ans1 if t else ans0\n s1.appendleft(s1.pop())\n print(total % mod)"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------- fast io --------------------\nfrom math import gcd, ceil\n\ndef prod(a, mod=10**9+7):\n ans = 1\n for each in a:\n ans = (ans * each) % mod\n return ans\n\ndef lcm(a, b): return a * b // gcd(a, b)\n\ndef binary(x, length=16):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\nfrom collections import deque\n\nfor _ in range(int(input()) if not True else 1):\n #n = int(input())\n #n, k = map(int, input().split())\n #a, b = map(int, input().split())\n #c, d = map(int, input().split())\n #a = list(map(int, input().split()))\n #b = list(map(int, input().split()))\n s1 = deque(k for k in input())\n s2 = deque(k for k in input())\n n = len(s1)\n k = int(input())\n mod = 10**9 + 7\n n1pow = [1]\n for i in range(6969):\n n1pow += [(n1pow[-1]*(n-1)) % mod]\n ans0 = 0\n for i in range(1, k):\n ans0 = (n1pow[i] - ans0) % mod\n ans1 = 1\n for i in range(1, k):\n ans1 = (n1pow[i] - ans1) % mod\n #print(ans0, ans1)\n total = 0\n for t in range(n):\n if s1 == s2:\n total += ans1 if t else ans0\n s1.appendleft(s1.pop())\n print(total % mod)"}, {"source_code": "start, end, k = input(), input(), int(input())\ndp = [[start == end for _ in range(k + 1)], [start != end for _ in range(k + 1)]]\nmod = int(1e9 + 7)\nsame = sum(end == (start[i: len(start)] + start[0: i]) for i in range(len(start)))\ndiff = len(start) - same\nfor i in range(1, k + 1):\n dp[0][i] = (dp[0][i - 1] * (same - 1) + dp[1][i - 1] * same) % mod\n dp[1][i] = (dp[0][i - 1] * diff + dp[1][i - 1] * (diff - 1)) % mod\nprint(dp[0][k])"}], "src_uid": "414000abf4345f08ede20798de29b9d4"} {"source_code": "n, x, y = map(int, raw_input().split())\nif (n / 2 <= x <= n / 2 + 1) and (n / 2 <= y <= n / 2 + 1):\n print \"NO\"\nelse:\n print \"YES\"", "positive_code": [{"source_code": "n, x, y = map(int, raw_input().split())\nn /= 2\nif (x, y) in [(a, b) for a in (n, n+1) for b in (n, n+1)]:\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "n,x,y= map(int,input().split())\nn//=2\nif(x==n or x==n+1) and (y==n or y==n+1):\n print('NO')\nelse:\n print(\"YES\")"}, {"source_code": "n,x,y=map(int,raw_input().split())\nhor=[]\nver=[]\nfor i in range(1,n+1):\n\thor.append([n/2,i])\n\thor.append([n/2+1,i])\nfor i in range(1,n+1):\n\tver.append([i,n/2])\n\tver.append([i,n/2+1])\nif [x,y] in hor and [x,y] in ver:\n\tprint \"NO\"\nelse:\n\tprint \"YES\""}, {"source_code": "n, x, y = map(int, raw_input().split())\nn /= 2\nif (x, y) in ((n, n), (n+1, n), (n, n+1), (n+1, n+1)):\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "s=raw_input().split()\nn=int(s[0])/2\nx=int(s[1])\ny=int(s[2])\n\nif (x==n or x==n+1) and (y==n or y==n+1):\n\tprint 'NO'\nelse:\n\tprint 'YES'\n"}, {"source_code": "In=raw_input().split(\" \")\n(n,x,y)=[int(c) for c in In]\nn/=2\nif ( (x==n) or (x==n+1) ) and ( (y==n) or (y==n+1) ) :\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "input_data = raw_input()\n\nn,x,y = input_data.split()\nn = int(n)\nx = int(x)\ny = int(y)\n\nflag = False\nif x == n/2 and y == n/2:\n flag = True\nif x == (n/2 +1 ) and y == n/2:\n flag = True\nif x == (n/2 +1 ) and y == (n/2+1):\n flag = True\nif x == (n/2 ) and y == (n/2+1):\n flag = True \nif flag:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "a,b,c=map(int,input().split(' '))\nif (b==a//2 or b==a//2+1 )and( c==a//2 or c==a//2+1):\n print(\"NO\")\nelse:\n print(\"YES\")\n "}, {"source_code": "s = raw_input().split(\" \")\nn = int(s[0])/2\nx = int(s[1])\ny = int(s[2])\n\nif n<=x<=n+1 and n<=y<=n+1:\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "#def gcd(a,b):\n# while b > 0: a,b = b, a%b\n# return a\n#def lcm(a, b):\n# return a*b/gcd(a,b)\n\n#T = input()\nn, x, y = map(int, raw_input().split())\nn = n/2\nif (x == n or x == n+1) and (y == n or y == n+1):\n print \"NO\"\nelse:\n print \"YES\"\n\n#data = map(int, raw_input().split())\n#data2 = [ map(int, raw_input().split()) for i in xrange(T)]\n"}, {"source_code": "n,x,y=map(int,input().split())\nprint([\"YES\",\"NO\"][(x==n/2 or x==n/2+1) and (y==n/2 or y==n/2+1)])\n"}, {"source_code": "n, x, y = map(int, input().split())\np = [n // 2, n // 2 + 1]\nif x in p and y in p:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "n,x,y=map(int,input().split())\nif (x==n//2 and y==n//2) or (x==n//2 + 1 and y==n//2) or (x==n//2 and y==n//2 + 1) or (x==n//2 + 1 and y==n//2 + 1):\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n,x,y=map(int,input().split())\nif min(x,y)>=n//2 and max(x,y)<=n//2 + 1:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "if __name__ == \"__main__\":\n A = map(int,raw_input().split(\" \"))\n N = A[0]/2\n x = A[1]\n y = A[2]\n if (x == N or x == N + 1) and (y == N or y == N + 1):\n print \"NO\"\n else:\n print \"YES\"\n \n"}, {"source_code": "k=input().split(\" \")\nn=int(k[0])\nx=int(k[1])\ny=int(k[2])\nn/=2\nif (x==n or x==n+1)and(y==n or y==n+1):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n, x, y = map(int, raw_input().split())\nn /= 2\n\nif (n == x or n + 1 == x) and (n == y or n + 1 == y):\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint \"NO\" if n / 2 <= min(x, y) and max(x, y) <= n / 2 + 1 else \"YES\""}, {"source_code": "n,x,y=map(int,input().split())\n\nif((x,y) in [(n//2,n//2),(n//2,n//2+1),(n//2+1,n//2),(n//2+1,n//2+1)]):\n print(\"NO\")\nelse:\n print(\"YES\")\n\n \n"}, {"source_code": "from sys import stdin, stdout\n\n(n2, x, y) = [int(x) for x in stdin.readline().strip().split()]\n\nprint('YES' if x != n2//2 and x != n2//2+1 or y != n2//2 and y != n2//2+1 else 'NO' )\n"}, {"source_code": "n,x,y=map(int,input().split())\nprint(['YES',\"NO\"][(x==n/2 or x==n/2+1) and (y==n/2 or y==n/2+1)])"}, {"source_code": "(tn,tx,ty) = raw_input().split()\nn,x,y = int(tn),int(tx),int(ty)\n\nmid = n / 2\nif (x,y) in [(mid,mid+1),(mid,mid),(mid+1,mid),(mid+1,mid+1)]:\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "s=input().split();n,x,y=int(s[0])//2,int(s[1]),int(s[2])\nif x==n and y==n:\n print('NO')\nelif x==n+1 and y==n:\n print('NO')\nelif x==n+1 and y==n+1:\n print('NO')\nelif x==n and y==n+1:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "args = raw_input().split()\n_2n = int(args[0])\nx = int(args[1])\ny = int(args[2])\n\npair = (_2n/2, _2n/2 + 1)\nyes = x not in pair or y not in pair\nif yes:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "\nn, x, y = map(int, raw_input().split())\n\nif (n/2 == x or n/2+1 == x) and (n/2 == y or n/2+1 == y) :\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint \"NO\" if n / 2 <= min(x, y) and max(x, y) <= n / 2 + 1 else \"YES\"\n"}, {"source_code": "n,x,y=map(int,input().split())\nn//=2\nprint(\"NO\" if (x==n or x==n+1) and (y==n or y==n+1) else \"YES\")\n"}, {"source_code": "n, x, y = map(int, input().split());\nif((x == n // 2 or x == n // 2 + 1) and (y == n // 2 or y == n // 2 + 1)):\n print('NO')\nelse:\n print('YES')"}, {"source_code": "import sys\ndef read_values():\n return map(int,raw_input().split())\n\nn,x,y=read_values() ; n/=2\nif n<=x<=n+1 and n<=y<=n+1:\n print 'NO'\nelse:\n print 'YES'\n\n\n"}, {"source_code": "n,x,y = map(int,input().split())\n\nif x in (n//2, n//2+1) and y in (n//2, n//2+1):\n print('NO')\nelse:\n print('YES')\n\n\n"}, {"source_code": "n,x,y=map(int,input().split())\na=[(n//2),(n//2)+1]\nprint(['YES','NO'][x in a and y in a])"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint 'NO' if ((x == n / 2 or x == n / 2 + 1) and (y == n / 2 or y == n / 2 + 1)) else 'YES'\n"}, {"source_code": "n, x, y = map(int, raw_input().split(' '))\n\nif (((x > (n/2 +1)) | (x < (n/2))) |\n ((y > (n/2 +1)) | (y < (n/2)))):\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "n,x,y=map(int,raw_input().split())\nmid=n/2\na=[[mid,mid],[mid+1,mid],[mid,mid+1],[mid+1,mid+1]]\nif [x,y] in a:\n\tprint \"NO\"\nelse:\n\tprint \"YES\""}, {"source_code": "line=raw_input().split()\nn=int(line[0])\nx=int(line[1])\ny=int(line[2])\nif (x==n/2 or x==n/2+1) and (y==n/2 or y==n/2+1):\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "n,x,y=map(int,raw_input().split())\nn/=2\nprint\"NO\"if (x==n or x==n+1)and(y==n or y==n+1)else\"YES\"\n"}, {"source_code": "n,x,y = map(int,raw_input().split())\nn /= 2;\nif (x != n and x != n+1) or (y != n and y != n+1):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n, a, b = map(int,input().split())\nt1, t2 = n//2, (n//2)+1\nif (a==t1 and b==t1) or (a==t1 and b==t2) or (a==t2 and b==t1) or (a==t2 and b==t2):\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n, x, y = map(int, input().split())\nif y == n // 2 or y == n // 2 + 1:\n if x == n // 2 or x == n // 2 + 1:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n,x,y=(int(i) for i in input().split())\nl=[(n//2,n//2),(n//2,(n//2)+1),((n//2)+1,n//2),((n//2)+1,(n//2)+1)]\nif((x,y) in l):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n,x,y=map(int,input().split())\np=int(n/2)+2\nif n==2:\n print('NO')\nelif n%2==0 and y in range(int(n/2),p) and x not in range(int(n/2),p):\n print('YES')\nelif n%2==0 and x in range(int(n/2),p) and y not in range(int(n/2),p):\n print('YES')\nelif n%2==0 and (x not in range(int(n/2),p) or y not in range(int(n/2),p)):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n,x,y=[int(i) for i in input().split()]\nif y!=n/2 and y!=n/2+1: print(\"YES\")\nelse:\n if x!=n/2 and x!=n/2+1: print(\"YES\")\n else: print(\"NO\")"}, {"source_code": "n, x, y = map(int, input().split())\nn //= 2\nprint('NO' if n <= x <= n + 1 and n <= y <= n + 1 else 'YES')\n"}, {"source_code": "n,x,y=[int(x) for x in input().split()]\nflag=0\nif x == n//2 or x == n//2+1:\n flag += 1\nif y == n//2 or y == n//2+1:\n flag += 1\nif flag == 2:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n,x,y = map(int, input().split());\nn /= 2;\nprint(['YES','NO'][(x == n or x == n + 1) and (y == n or y == n + 1)]);"}, {"source_code": "n,x,y=map(int,input().split())\nn//=2\nif (n==x or n==x-1) and (n==y or n==y-1): \n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n,x,y=map(int,input().split())\nif ((x==n/2 or x==n/2+1) and (y==((n/2)) or y==((n/2)+1))):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n,x,y=map(int,input().split())\nif min(x,y)>=n//2 and max(x,y)<=n//2 + 1:\n exit(print('NO'))\nelse:\n exit(print('YES'))"}, {"source_code": "n,x,y=map(int,input().split())\nn=n//2\nif (x==n and y==n) or (x==n+1 and y==n) or (x==n and y==n+1) or (x==n+1 and y==n+1):\n\tprint('NO')\nelse:\n\tprint('YES')"}, {"source_code": "x,y,z = [int(x) for x in input(\"\").split()]\n\nn= x/2\n\nif ((y == n or y == n + 1) and (z == n or z == n + 1)):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "from sys import setrecursionlimit\nsetrecursionlimit(1000000000)\n\ndef main():\n a, b, c=[int(i) for i in input().split()]\n if ((a//2==b) and (a//2==c)) or ((a//2==b-1) and (a//2==c)) or ((a//2==b) and (a//2==c-1)) or ((a//2==b-1) and (a//2==c-1)):\n print(\"NO\")\n return 0\n print(\"YES\")\n\n\nmain()\n\n"}, {"source_code": "_2n,x,y=list(map(int,input().split()))\nn=_2n/2\nif (x==n or x==n+1) and (y==n or y==n+1): print('NO')\nelse: print('YES')"}, {"source_code": "\n\n\nn, x, y = map(int, input().split())\n\npr_bad = (n // 2 - 1, n // 2 - 1)\n\nbad = [\n (pr_bad[0], pr_bad[1]),\n (pr_bad[0] + 1, pr_bad[1]),\n (pr_bad[0], pr_bad[1] + 1),\n (pr_bad[0] + 1, pr_bad[1] + 1),\n]\n\nif (x - 1, y - 1) in bad:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n2, x, y = [int(i) for i in input().split()]\n\nmiddle = n2//2\n\nif (x == middle+1 or x == middle) and (y == middle+1 or y == middle):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n , x, y = [int(x) for x in raw_input().split()]\nif (x == n/2 or x == n/2 + 1) and (y == n/2 or y == n/2 + 1):\n print \"NO\"\nelse:\n print \"YES\"\n\n"}, {"source_code": "n,x,y = map(int,raw_input().strip().split())\nn /= 2\nif (x,y) in ((n,n),(n+1,n),(n,n+1),(n+1,n+1)):\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "n, x, y = map(int, raw_input().split())\nf = lambda x : x in (n / 2, n / 2 + 1)\nprint 'NO' if f(x) and f(y) else 'YES'"}, {"source_code": "L = map(int, raw_input().strip().split())\nn = L[0]\nx = L[1]\ny = L[2]\n\nif (x == n/2 or x == n/2 + 1) and (y == n/2 or y == n/2 + 1):\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n,x,y=map(int, raw_input().split())\nn/=2\ns=[n,n+1]\nprint \"YNEOS\"[x in s and y in s::2]"}, {"source_code": "n,x,y=map(int, raw_input().split())\nm=n/2\nprint \"YNEOS\"[x in [m,m+1] and y in [m,m+1]::2]"}, {"source_code": "input = raw_input().split(' ')\n\nn = int(input[0])/2\nx = int(input[1])\ny = int(input[2])\n\nif (x,y) == (n, n) or \\\n (x,y) == (n+1, n) or \\\n (x,y) == (n, n+1) or \\\n (x,y) == (n+1, n+1):\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "n, x, y = tuple(int(x) for x in raw_input().strip().split(\" \"))\n\nnn = n/2\n\nif (x==nn and y==nn) or (x==nn and y==nn+1) or (x==nn+1 and y==nn) or (x==nn+1\n and y==nn+1):\n print \"NO\"\nelse:\n print \"YES\"\n\n"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint ['YES', 'NO'][{x, y} <= {n / 2, n / 2 + 1}]"}, {"source_code": "def main(n, x, y):\n if (x == n and y == n):\n return \"NO\"\n if (x == n and y == n+1):\n return \"NO\"\n if (x == n+1 and y == n):\n return \"NO\"\n if (x == n+1 and y == n+1):\n return \"NO\"\n else:\n return \"YES\"\n\nline = raw_input()\nlst = line.split(\" \")\nn = int(lst[0])/2\nx = int(lst[1])\ny = int(lst[2])\nprint main(n, x, y)\n \n"}, {"source_code": "import sys\nL=raw_input()\nL=L.split()\nn=int(L[0])\nx=int(L[1])\ny=int(L[2])\nn/=2\nif (x>=n)&(x<=n+1)&(y>=n)&(y<=n+1): \n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "#-*- coding: utf-8 -*-\n\nimport sys\nimport re\n\nwrite = sys.stdout.write\n\nnab = sys.stdin.readline()\nnab = nab.replace('\\n','').split(\" \")\nn,a,b = int(nab[0]), int(nab[1]), int(nab[2])\n\nn = n/2\n\nif n==1:\n write(\"NO\")\nelif a!=n and a!=n+1:\n write(\"YES\")\nelif b>1 and b<2*n and n>=3 and b!=n and b!=n+1:\n write(\"YES\")\nelif (b==1 or b==2*n) and n>=2:\n write(\"YES\")\nelse:\n write(\"NO\")"}, {"source_code": "\n\nn, x, y = map(int, raw_input().split(' '))\n\n\nprint not (x in (n/2,n/2+1) and y in (n/2,n/2+1)) and 'YES' or 'NO'\n\n"}, {"source_code": "import sys\nimport itertools\nimport math\n\nif __name__ == '__main__':\n splited = raw_input().rstrip().split(\" \")\n n = int(splited[0])\n x = int(splited[1])\n y = int(splited[2])\n\n p = [(n / 2, n / 2), (n / 2 + 1, n / 2), (n / 2, n / 2 + 1), (n / 2 + 1, n / 2 + 1)]\n if (x, y) in p:\n print \"NO\"\n else:\n print \"YES\"\n"}, {"source_code": "n,x,y=map(int,raw_input().split())\nf=lambda x: x in [n/2,n/2+1]\nprint ['YES','NO'][f(x) and f(y)]"}, {"source_code": "n, x, y = map(int, raw_input().split())\nif x == n / 2 and y == n / 2 or x == n / 2 and y == n / 2 + 1 or x == n / 2 + 1 and y == n / 2 or x == n / 2 + 1 and y == n / 2 + 1:\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "n,x,y = map(int, raw_input().split())\nprint \"NO\" if n/2 <= x <= n/2+1 and n/2 <= y <= n/2+1 else \"YES\""}], "negative_code": [{"source_code": "n,x,y=map(int,raw_input().split())\nn/=2\nprint\"NO\"if abs(x-n)<2 and abs(y-n)<2 else\"YES\"\n"}, {"source_code": "n, x, y = map(int, input().split())\nt = 1\nt += min(n - x, 1) + min(x - 1, 1) + min(n - y, 1) + min(y - 1, 1)\nif x > 1:\n t += min(n - y, 1) + min(y - 1, 1)\nif x < n:\n t += min(n - y, 1) + min(y - 1, 1)\nif t <= (n * n) // 2:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, x, y = map(int, input().split())\nt = 1\nt += min(n - x, 1) + min(x - 1, 1) + min(n - y, 1) + min(y - 1, 1)\nif x > 1:\n t += min(n - y, 1) + min(y - 1, 1)\nif x < n:\n t += min(n - y, 1) + min(y - 1, 1)\nif t <= (n * n) // 2:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "n, a, b = map(int,input().split())\nt1, t2 = n//2, (n//2)+1\nif (a==t1 and b==t1) or (a==t1 and b==t2) or (a==t2 and b==t1) or (a==t2 and b==t2):\n print('NO')\nelse:\n print('Yes')"}, {"source_code": "n,x,y=map(int,input().split())\nn=n//2\nif n==x or n==x-1 and n==y or n==y-1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n,x,y=map(int,input().split())\n\nif n==2:\n print('NO')\nelif n%2==0 and (x not in range(int(n/2),n) or y not in range(int(n/2),n)):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n,x,y=map(int,input().split())\np=int(n/2)+2\nif n==2:\n print('NO')\nelif n%2==0 and y in range(int(n/2),p) and x not in range(int(n/2),p):\n print('YES')\nelif n%2==0 and x in range(int(n/2),p) and y not in range(int(n/2),p):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n,x,y=map(int,input().split())\nif n==2:\n print('NO')\nelif n%2==0 and (x and y) not in range(int(n/2),n):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n, x, y = map(int, input().split())\n\ns = n//2\n\nprint('YES' if (x < s or x > s + 1) and (y < s or y > s + 1) else 'NO')"}, {"source_code": "#from sys import stdin\n#input=stdin.readline\n#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])\n# from collections import Counter\n# import sys\n#s=\"abcdefghijklmnopqrstuvwxyz\"\n#n=int(input())\n#n,k=map(int,input().split())\n#arr=list(map(int,input().split()))\n#arr=list(map(int,input().split()))\nn,x,y=map(int,input().split())\nif (x==n//2 or x==(n//2)+1) and (y==n or y==((n//2)+1)):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "#from sys import stdin\n#input=stdin.readline\n#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])\n# from collections import Counter\n# import sys\n#s=\"abcdefghijklmnopqrstuvwxyz\"\n#n=int(input())\n#n,k=map(int,input().split())\n#arr=list(map(int,input().split()))\n#arr=list(map(int,input().split()))\nn,x,y=map(int,input().split())\nif x==n//2 or x==(n//2)+1:\n if n>2:\n if y>1 and y<n:\n print(\"NO\")\n\n else:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n"}, {"source_code": "#from sys import stdin\n#input=stdin.readline\n#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])\n# from collections import Counter\n# import sys\n#s=\"abcdefghijklmnopqrstuvwxyz\"\n#n=int(input())\n#n,k=map(int,input().split())\n#arr=list(map(int,input().split()))\n#arr=list(map(int,input().split()))\nn,x,y=map(int,input().split())\nif x==n//2 or x==(n//2)+1 and y==n or y==(n//2)+1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "#from sys import stdin\n#input=stdin.readline\n#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])\n# from collections import Counter\n# import sys\n#s=\"abcdefghijklmnopqrstuvwxyz\"\n#n=int(input())\n#n,k=map(int,input().split())\n#arr=list(map(int,input().split()))\n#arr=list(map(int,input().split()))\nn,x,y=map(int,input().split())\nif x==n//2 or x==(n//2)+1:\n if n>2:\n if y>1 and y<n:\n print(\"NO\")\n else:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n"}, {"source_code": "#from sys import stdin\n#input=stdin.readline\n#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])\n# from collections import Counter\n# import sys\n#s=\"abcdefghijklmnopqrstuvwxyz\"\n#n=int(input())\n#n,k=map(int,input().split())\n#arr=list(map(int,input().split()))\n#arr=list(map(int,input().split()))\nn,x,y=map(int,input().split())\nif x==n//2 or x==n//2+1 and y>1 and y<2*n:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n"}, {"source_code": "#!/usr/bin/python2\n\nif __name__ == \"__main__\":\n s = raw_input()\n l = s.split(' ')\n n, x, y = int(l[0]), int(l[1]), int(l[2])\n if n > 4: print \"YES\"\n elif n == 2: print \"NO\"\n elif n == 4:\n if 2 <= x <= 3 and 2 <= y <=3:\n print \"NO\"\n else : print \"YES\"\n"}, {"source_code": "#!/usr/bin/python2\n\nif __name__ == \"__main__\":\n s = raw_input()\n l = s.split(' ')\n n, x, y = int(l[0]), int(l[1]), int(l[2])\n if n > 4: print \"YES1\"\n elif n == 2: print \"NO\"\n elif n == 4:\n if 2 <= x <= 3 and 2 <= y <=3:\n print \"NO\"\n else : print \"YES\"\n"}, {"source_code": "l=[int(x) for x in raw_input().split()]\nprint 'YES' if l[0]%(4*l[2])==0 and l[0]>=(2*l[1]) else 'NO'"}, {"source_code": "n,x,y = map(int, raw_input().split())\nif x>=n/2 and x<=n/2+1 and y>=n/2 and y<=n/2+1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint ['YES', 'NO'][{x, y} <= {n, n + 1}]"}, {"source_code": "import sys\nL=raw_input()\nL=L.split()\nn=int(L[0])\nx=int(L[1])\ny=int(L[2])\n\nif ((x>=n)&(x<=n+1))|((y>=n)&(y<=n+1)): \n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "import sys\nL=raw_input()\nL=L.split()\nn=int(L[0])\nx=int(L[1])\ny=int(L[2])\n\nif (x>=n)&(x<=n+1)&(y>=n)&(y<=n+1): \n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "#-*- coding: utf-8 -*-\n\nimport sys\nimport re\n\nwrite = sys.stdout.write\n\nnab = sys.stdin.readline()\nnab = nab.replace('\\n','').split(\" \")\nn,a,b = int(nab[0]), int(nab[1]), int(nab[2])\n\nn = n/2\n\nif a!=n and a!=n+1:\n write(\"YES\")\nelif n==1:\n write(\"NO\")\nelif b>1 and b<2*n and 2*n>=6:\n write(\"YES\")\nelse:\n write(\"NO\")"}, {"source_code": "#-*- coding: utf-8 -*-\n\nimport sys\nimport re\n\nwrite = sys.stdout.write\n\nnab = sys.stdin.readline()\nnab = nab.replace('\\n','').split(\" \")\nn,a,b = int(nab[0]), int(nab[1]), int(nab[2])\n\nn = n/2\n\nif n==1:\n write(\"NO\")\nelif a!=n and a!=n+1:\n write(\"YES\")\nelif b>1 and b<2*n and 2*n>=6:\n write(\"YES\")\nelif (b==1 or b==2*n) and 2*n>=4:\n write(\"YES\")\nelse:\n write(\"NO\")"}, {"source_code": "n,x,y=map(int,raw_input().split())\nf=lambda x: x in [n,n+1]\nprint ['YES','NO'][f(x) and f(y)]"}, {"source_code": "n,a,b = map(int,raw_input().split())\nn /= 2\nif n==1 or ((a==n or a==n+1) and (b==n or b==n+1)):\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "def main():\n n, x, y = map(int, raw_input().split())\n if n <= x <= n + 1 and n <= y <= n + 1:\n print \"NO\"\n else:\n print \"YES\"\n \nmain()\n"}, {"source_code": "def main():\n n, x, y = map(int, raw_input().split())\n if n == 1:\n print \"NO\"\n elif n == 2:\n if not (2 <= x <= 3 or 2 <= y <= 3):\n print \"YES\"\n else:\n print \"NO\"\n elif n <= x <= n + 1 and n <= y <= n + 1:\n print \"NO\"\n else:\n print \"YES\"\n \nmain()\n"}, {"source_code": "input_data = raw_input()\n\nn,x,y = input_data.split()\nn = int(n)\nx = int(x)\ny = int(y)\n\n\nnumber_of_fields = 0\nif x-1 >= 1 and y-1>=1:\n number_of_fields += 1\nif y-1 >= 1:\n number_of_fields +=1\nif y+1 <=n:\n number_of_fields +=1\nif x-1 >=1:\n number_of_fields +=1\nif x+1 <= n: \n number_of_fields +=1\n\nif y-1 >=1 and x+1 <=n:\n number_of_fields +=1\nif y+1 <=n and x+1 <=n:\n number_of_fields +=1\nif y+1 <=n and x-1 >=1:\n number_of_fields +=1\nnumber_of_fields +=1\n\nif number_of_fields < (n*n)/2:\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "input_data = raw_input()\n\nn,x,y = input_data.split()\nn = int(n)\nx = int(x)\ny = int(y)\n\n\nnumber_of_fields = 0\nif x-1 >= 1 and y-1>=1:\n number_of_fields += 1\nif y-1 >= 1:\n number_of_fields +=1\nif y+1 <=n:\n number_of_fields +=1\nif x-1 >=1:\n number_of_fields +=1\nif x+1 <= n: \n number_of_fields +=1\n\nif y-1 >=1 and x+1 <=n:\n number_of_fields +=1\nif y+1 <=n and x+1 <=n:\n number_of_fields +=1\nif y+1 <=n and x-1 >=1:\n number_of_fields +=1\nnumber_of_fields +=1\n\nif number_of_fields <= (n*n)/2:\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "import sys\n\nif __name__ == \"__main__\":\n\tl=raw_input()\n\tl=int(l[0])\n\tif(l>2): print \"YES\"\n\telse: print \"NO\"\n"}, {"source_code": "(n, x, y) = [int(i) for i in raw_input().split()]\nif x == n / 2 and y == n / 2 or x == n / 2 and y + 1== n / 2 or x + 1 == n / 2 and y == n / 2 or x + 1 == n / 2 and y + 1 == n / 2:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "(n, x, y) = [int(i) for i in raw_input().split()]\nif x == n / 2 or y == n / 2 or x + 1 == n / 2 or y + 1 == n / 2:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "line = raw_input()\n(n, x, y) = map(int, line.split(' '))\nn /= 2\nif(-1 <= x - n <= 0 and -1 <= y - n <= 0):\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "\nimport sys\n\nn2, x, y = map(int, raw_input().split())\nD = [-1, 0, 1]\nSq = {}\nfor dx, dy in [(a, b) for a in D for b in D if (a, b) != (0, 0)]:\n print dx, dy\n i, j = x + dx, y + dy\n if (i < 1 or i > n2) or (j < 1 or j > n2):\n continue\n if (i, j) in Sq:\n if Sq[(i, j)] == -1:\n print \"NO\"\n sys.exit(0)\n else:\n Sq[(i, j)] = 1\n Sq[(n2 - i + 1, n2 - j + 1)] = -1\n\nprint \"YES\"\n \n \n \n"}, {"source_code": "input = [int(x) for x in raw_input().split(' ')]\nsize = input[0]\nx = input[1]\ny = input[2]\n\nsizeA = size / 2\nsizeB = sizeA + 1\n\ncan_be_split = True\n\nif sizeA == x:\n can_be_split = False\nelif sizeB == y:\n can_be_split = False\nelif sizeA == x:\n can_be_split = False\nelif sizeA == y:\n can_be_split = False\n\n\nif can_be_split == False:\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n,x,y=map(int,input().split())\n\nif x==1:\n\tif y==1:\n\t\tif n>x:\n\t\t\tif (n**2)//2>=4:\n\t\t\t\tprint(\"YES\")\n\t\t\telse:\n\t\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\telif y==n:\n\t\tif n>1:\n\t\t\tif (n**2)//2>=4:\n\t\t\t\tprint(\"YES\")\n\t\t\telse:\n\t\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tif (n**2)//2>=6:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\t\nelif x==n:\n\tif y==1 or y==n:\n\t\tif n>1:\n\t\t\tif (n**2)//2>=4:\n\t\t\t\tprint(\"YES\")\n\t\t\telse:\n\t\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tif (n**2)//2>=6:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\nelse:\n\tif y==1 or y==n:\n\t\tif (n**2)//2>=6:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tif (n**2)//2>=9:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")"}, {"source_code": "n,x,y=map(int,input().split())\nif ((y==n/2 and x==n/2) or (y==((n/2)+1) and x==((n/2)+1))):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n,x,y=map(int,input().split())\nif (y==n/2 or y==((n/2)+1)):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "x,y,z = [int(x) for x in input(\"\").split()]\n\nn= x/2\n\ns= x*x\nt=y*z\n\nif(s!=t):\n if(y==n or z==n):\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x,y,z = [int(x) for x in input(\"\").split()]\n\nn= x/2\n\nif(y>=n or z>=n):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "def main():\n n, x, y = [int(i) / 2 for i in raw_input().split()]\n if n == x and n == y:\n print 'NO'\n else:\n print 'YES'\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nfrom fractions import gcd\ndef inp():\n return int(raw_input())\ndef linp():\n return map(int, raw_input().split())\nn, x, y = linp()\nif n==2:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "#!/usr/bin/env python\n\nn,x,y=[int(i) for i in raw_input().split(\" \")]\n\nif x>=n/2 and x<=n/2+1:\n if y>=n/2 and y<=n/2+1: print \"NO\" \nelse: print \"YES\"\n"}, {"source_code": "def main(n, x, y):\n if (x == n and y == n):\n return \"YES\"\n if (x == n and y == n+1):\n return \"YES\"\n if (x == n+1 and y == n):\n return \"YES\"\n if (x == n+1 and y == n+1):\n return \"YES\"\n else:\n return \"NO\"\n\nline = raw_input()\nlst = line.split(\" \")\nn = int(lst[0])/2\nx = int(lst[1])\ny = int(lst[2])\nprint main(n, x, y)\n \n"}, {"source_code": "n2, x, y = [int(_) for _ in raw_input().split(\" \")]\nn = n2/2\nif n == 1:\n print \"NO\"\nelse:\n if x == n and y == n:\n print \"NO\"\n else:\n print \"YES\"\n"}, {"source_code": "def rd():\n\treturn raw_input()\ndef nums():\n\treturn map(int, rd().split())\nn, x, y = nums()\np = x,y\nif p == (n,n) or p == (n+1,n) or p == (n+1,n+1) or p == (n,n+1):\n\tprint 'NO'\nelse:\n\tprint 'YES'\n\n"}, {"source_code": "n, x, y = map(int, raw_input().split())\nif (x, y) in ((n, n), (n+1, n), (n, n+1), (n+1, n+1)):\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "s=raw_input().split()\nn=int(s[0])\nx=int(s[1])\ny=int(s[2])\n\nif (x==n or x==n+1) and (y==n or y==n+1):\n\tprint 'NO'\nelse:\n\tprint 'YES'\n"}, {"source_code": "\nn,x,y = map(int,raw_input().split( ' ' ) )\nif n >= 4:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "s = raw_input().split(\" \")\nn2 = int(s[0])\nx = int(s[1])\ny = int(s[2])\n\nif n2<=2:\n print \"NO\"\nelif n2<=4 and (2<=x<=3 and 2<=y<=3):\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "n, x ,y = map(int, raw_input().split(' '))\nmsg = \"NO\"\nif n / 2 != x and n / 2 + 1 != x:\n if n / 2 != y and n / 2 + 1 != y:\n msg = \"YES\"\nprint msg"}, {"source_code": "(n, x, y) = map(int, raw_input().split(\" \"))\nm = n // 2\nif x == m - 1 and y == m - 1:\n print \"NO\"\nelif x == m - 1 and y == m + 1:\n print \"NO\"\nelif x == m + 1 and y == m + 1:\n print \"NO\"\nelif x == m + 1 and y == m - 1:\n print \"NO\"\nelse:\n print \"YES\"\n\n"}, {"source_code": "n,x,y=map(int,raw_input().split())\n\nn/=2\n\nif (x==n or x==n+1) and (y==n or y==n+1): #midden dus niet spiegelbaar\n print 'N0'\nelse:\n print 'YES'\n\n"}, {"source_code": "n,x,y= map(int,input().split())\nn//=2\nif(x>=n) and (y>=n):\n print('NO')\nelse:\n print(\"YES\")"}, {"source_code": "n,x,y=map(int,input().split())\nif x==int(n/2) or x==int(n/2)+1 or y==int(n/2) or y==int(n/2)+1:\n print('NO')\nelse:\n print('YES')\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "a,b,c=map(int,input().split(' '))\nif b==a//2 or b==a//2+1 or c==a//2 or c==a//2+1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n,x,y=map(int,input().split())\n\nif(n==2):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n,x,y=map(int,input().split())\n\nif(n==2):\n print(\"NO\")\nelif(n==4):\n if((x,y) in [(2,2),(2,3),(3,2),(3,3)]):\n print(\"NO\")\n else:\n print(\"YES\")\nelif(n==6):\n if( (x,y) in [(3,3),(3,4),(4,3),(4,4)]):\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n print(\"YES\")\n \n"}, {"source_code": "n,x,y=map(int,input().split())\nprint(['NO',\"YES\"][x!=n/2 and x!=n/2+1 and y!=n/2 and y!=n/2+1])"}, {"source_code": "s=input().split();n,x,y=int(s[0]),int(s[1]),int(s[2])\nif x!=n and x!=n+1 and y!=n and y!=n+1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n,x,y=map(int,input().split())\n\nd = { n//2, n//2+1 }\n\nif x in d or y in d:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}], "src_uid": "dc891d57bcdad3108dcb4ccf9c798789"} {"source_code": "n, m = map(int, raw_input().split())\n\nprint sum([b == n - (m-b*b)**2 for b in range(n+1) if m >= b**2])\n", "positive_code": [{"source_code": "a = map(int,raw_input().split())\nd = []\nx = 0\nwhile x<1020:\n if x+ (a[0] - x**2)**2 ==a[1] and a[0] - x**2 >= 0:\n d.append(x)\n x+=1\nprint len(d)"}, {"source_code": "import fileinput as f\nimport math\n\nfor line in f.input():\n if f.lineno() == 1:\n [n, m] = map(int, line.split())\n\na0 = 0\ntemp = int(math.sqrt(n))\nif temp < m:\n af = temp \nelse:\n af = m\n\ncount = 0\n\ndef isint(x):\n return True if x - int(x) == 0 else False\n\nfor ai in range(a0, af+1):\n b = math.sqrt(m - ai)\n if isint(b):\n a = math.sqrt(n - b)\n if isint(a):\n count += 1\n\nprint count\n"}, {"source_code": "# DON'T USE PYTHON FOR RECURSION\n# TRY PYPY\nimport math\nimport operator\nimport sys\nfrom collections import Counter, defaultdict\nfrom math import ceil, floor, pi, sin, sqrt\nfrom sys import exit, stdin, stdout\n\n\ndef main():\n # stdin = open('.in')\n n, m = map(int, stdin.readline().strip().split(' '))\n ans = 0\n for a in range(1001):\n for b in range(1001):\n ans += a * a + b == n and a + b * b == m\n print ans\n\n\nmain()\n"}, {"source_code": "a = [int(i) for i in raw_input().split(' ')]\nres = 0\nfor i in range(max(a[0],a[1])+1):\n for j in range(max(a[0],a[1])+1):\n if (i**2 + j == a[0]) and (j**2 + i == a[1]):\n res +=1\nprint(res)\n"}, {"source_code": "n, m = [int(e) for e in (input().split())]\nans = 0\n\nfor a in range (int(n**0.5)+1):\n b = n - pow(a, 2)\n if b >= 0 and a + pow(b, 2) == m:\n ans += 1 \nprint (ans)"}, {"source_code": "#!/usr/bin/python\n\ndef ir():\n return int(raw_input())\n\ndef ia():\n line = raw_input()\n line = line.split()\n return map(int, line)\n\nn, m = ia()\n\nans = 0\nfor a in range(1005):\n for b in range(1005):\n if a*a + b==n and a + b*b==m:\n ans = ans + 1\n\nprint ans \n"}, {"source_code": "n, m = [int(e) for e in (input().split())]\nans = 0\n\nfor a in range (33):\n b = n - a**2\n if a + (n-a**2)**2 == m and b >= 0:\n ans += 1 \nprint (ans)"}, {"source_code": "t=raw_input()\nt=t.split()\ncount=0\nfor a in range(0,1001):\n for b in range(0,1001):\n if (a**2)+b==int(t[0]):\n if a+(b**2)==int(t[1]):\n count+=1\nprint count\n"}, {"source_code": "from sys import stdin\n\nline = stdin.readline().split()\nn = int(line[0])\nm = int(line[1])\npairs = 0\n\nfor a in range(0, 32):\n for b in range(0, 32):\n if (a*a + b == n) and (a + b*b == m):\n pairs += 1\n\nprint pairs"}, {"source_code": "n, m = map(int, input().split())\nc = 0\nfor a in range(n+1):\n for b in range(n+1):\n if a * a + b == n and a+b*b==m:\n # print(a,b, a*a+b)\n c += 1\nprint(c)\n"}, {"source_code": "n,m = map(int, raw_input().split())\nz = max(n,m)\ncnt = 0\nfor a in xrange(z+1):\n b = n - a**2\n if b>=0 and a + b**2 == m:\n cnt+=1\nprint cnt"}, {"source_code": "n, m = map(int, raw_input().split())\nprint sum([1 for i in xrange(m+1) if i*i<=m and (m-i*i)**2+i == n])\n"}, {"source_code": "flag=int()\nflag=0\nn,m = map(int,input().split())\nfor i in range(n+1):\n for j in range(m+1):\n if i*i+j==n and i+j*j==m:\n flag=flag+1\nprint(flag) \n \n \n"}, {"source_code": "import sys\n\ndelers=[]\n\nt=[int(x) for x in sys.stdin.readline().split()]\n\nn,m=t[0],t[1]\n\nresult=0\n\nfor a in range(n+1):\n for b in range(m+1):\n if a*a+b==n and b*b+a==m:\n result+=1\n\nprint result\n"}, {"source_code": "n,m = map(int,raw_input().split())\nc = 0\nfor i in xrange(n+ 1):\n for j in xrange(m+ 1):\n if i*i + j == n and i + j*j == m:\n c += 1\n\nprint(c)\n\n"}, {"source_code": "s=raw_input()\nn,m=s.split(' ')\nn,m=int(n),int(m)\nq=0\nfor i in xrange(0,101):\n for y in xrange(0,101):\n if i**2+y==n and i+y**2==m:\n q+=1\nprint(q)\n"}, {"source_code": "import math\nn,m=map(int,input().split())\nk=int(max(math.sqrt(n),math.sqrt(m)))\nc=0\nfor i in range(k+1):\n for j in range(k+1):\n if(i*i+j == n and j*j+i==m):\n c+=1\nprint(c)\n \n \n\n "}, {"source_code": "import math as m\nn,o=map(int,input().split())\ncount=0\nif n>o:\n a=m.floor(m.sqrt(n))\n for i in range(a+1):\n b= n-pow(i,2)\n if i+pow(b,2)==o:\n count+=1 \nelse:\n b=m.floor(m.sqrt(o))\n for i in range(b+1):\n a=o-pow(i,2)\n if pow(a,2)+i==n:\n count+=1\nprint(count)"}, {"source_code": "n, m = map(int, input().split())\nhighest = 0\ncount = 0\n\nif n > m:\n highest = n\nelse:\n highest = m\n\nfor i in range(0, highest + 1):\n if i**2 + n-i**2 == n and i + (n-i**2)**2 == m and n-i**2 >=0:\n count += 1\n\nprint(count)"}, {"source_code": "def r(): return raw_input().strip()\ndef ri(): return int(r().strip())\ndef riv(): return map(int, r().split())\n\nfrom math import sqrt\n\ndef main():\n n,m = riv()\n count = 0\n for a in range(int(sqrt(n))+1):\n b = n - (a**2)\n if b >= 0 and b**2 + a == m:\n count += 1\n \n print count\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "###Codeforces problem 456A###\n\nn, m = map(int, raw_input().split())\n\nans = 0\nfor a in range(32):\n b = n - a * a\n if (a + b * b) == m and b >= 0:\n ans += 1\n \nprint ans\n"}, {"source_code": "n, m = map(int, input().split())\nif (m + n) < 10:\n x = (m + n) ** 2\nelse:\n x = max(n, m)\na = 0\nb = 0\ncount = 0\nfor i in list(range(x)):\n for j in list(range(x)):\n if a ** 2 + b == n and a + b ** 2 == m:\n count += 1\n b += 1\n else:\n b += 1\n a += 1\n b = 0\nprint(count)\n"}, {"source_code": "m,n=map(int,raw_input().split(\" \"))\na=count=0\nwhile a<=m:\n if (a+pow(a,4)+n*n-2*n*a*a)==m:\n if n-a*a>=0: \n count+=1\n a+=1\nprint count"}, {"source_code": "n,m=list(map(int,input().split()))\ncount=a=0\nwhile a*a<=n:\n b=0\n while b*b<=m:\n if a*a+b==n and a+b*b==m:\n count+=1\n b+=1\n a+=1\nprint(count)"}, {"source_code": "import sys\nimport math\n\nn, m = [int(x) for x in (sys.stdin.readline()).split()]\n\nif(n > 992 and m > 992):\n print(0)\n exit()\n \nif(n >= m):\n k = int(math.sqrt(n))\n t = n - (k ** 2)\n\n res = 1\n if((t ** 2) + k == (t) + (k ** 2) and t != k):\n res += 1\n \n if((t ** 2) + k == m):\n print(res)\n else:\n print(0)\nelif(m > n):\n k = int(math.sqrt(m))\n t = m - (k ** 2)\n\n if((t ** 2) + k == n):\n print(1)\n else:\n print(0)\n\n"}, {"source_code": "(m,n) = map(int, raw_input().split())\nx = m if m>n else n\nprint sum(((a*a)+b == n) and (a + (b*b) == m) for a in range(x+1) for b in range(x+1))\n"}, {"source_code": "\nn, m = map(int, raw_input().split())\n\n\ntotal = 0\nfor a in range(n+1):\n\t\n\tb = n - a**2\n\tif b < 0:\n\t\tbreak\n\t\t\n\tif a + b**2 == m:\n\t\ttotal += 1\n\n\t\t\nprint total"}, {"source_code": "n,m=(map(int,input().split()))\nans=0\nfor i in range(32):\n for j in range(32):\n if i**2+j==n and i+j**2==m:\n ans+=1\n #print(i,j)\nprint(ans)\n\n"}, {"source_code": "n,m = map(int, raw_input().split())\nprint sum([1 for a in range(n+1) if n >= a**2 and m == a + (a**2 - n)**2])"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[204]:\n\n\n# # n = int(input())\n# # line = list(map(int, input().split()))\n# # line = list(str(input()))\n\n\n# In[406]:\n\n\nline = list(map(int, input().split()))\n\n\n# In[407]:\n\n\nm, n = line[0], line[1]\nsum_val = m + n\nn_pair = 0\n\nfor i in range(sum_val//2 + 1):\n for j in range(sum_val//2 +1):\n equ1 = i**2 + j\n equ2 = i + j**2\n if equ1 == m and equ2 == n:\n n_pair += 1\n \nprint(n_pair)\n\n\n# In[375]:\n\n\n\n\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\ncount = 0\nmn = min(n, m)\nfor a in range(0, mn + 1):\n for b in range(0, mn + 1):\n if (a * a + b == n) and (a + b * b == m):\n count += 1\nprint(count)"}, {"source_code": "n, m = [int(x) for x in input().split()]\ncount = 0\nmn = min(n, m)\nfor a in range(0, 1000):\n for b in range(0, 1000):\n if (a * a + b == n) and (a + b * b == m):\n count += 1\nprint(count)"}, {"source_code": "n,m=map(int,raw_input().split())\nprint sum([i==n-(m-i*i)**2 for i in range(n+1) if m>=i*i])"}, {"source_code": "n, m = list(map(int, input().split()))\nmin = min(n, m)\na = b = catch = 0\n\nwhile a < min and b < min:\n a = a + 1\n if a ** 2 + b == n and a + b ** 2 == m:\n catch = 1\n elif a == min:\n b = b + 1\n if a == b == min:\n a = b\n else:\n a = 0\n\nif n == int(1) and m == int(1):\n catch = 2\nprint(catch)"}, {"source_code": "n, m = map(int, input().split())\ncount = 0\nfor i in range(1001):\n for j in range(1001):\n if i**2+j == n and i+j**2 == m:\n count+=1\nprint(count)"}, {"source_code": "#!/usr/bin/env python\n# http://acm.zhihua-lai.com\n\nn, m = map(int, raw_input().split(' '))\n\nx = 0\nfor a in xrange(0, int(n ** 0.5) + 1):\n b = n - a * a\n if a + b * b == m:\n x += 1\n\nprint x\n"}, {"source_code": "s = input()\n\nn,m = s.split()\n\n\na = int(n)**0.5\n\na = int(a)\ntemp = a\n\npair = 0\nwhile a>=0:\n b = int(n) - a**2\n if int(a) + b**2 == int(m):\n pair +=1\n a = int(a) - 1\n continue\n else:\n a= int(a)-1\n continue\n\n\"\"\"\nflag = 0\nwhile flag == 0 :\n temp += 1\n b = int(n) - temp**2\n if int(temp) + b**2 == int(m):\n pair += 1\n continue\n elif int(temp) + b**2 < int(m):\n continue\n else:\n flag = 1\n\"\"\"\nprint (pair)\n \n \n \n \n \n \n\n \n \n\n\n\n \n \n \n \n \n \n \n \n\n\n\n\n \n \n \n\n\n\n\n\n \n \n \n\n \n \n\n\n\n \n \n \n \n\n\n\n \n\n\n \n \n\n\n\n\n\n\n\n \n\n\n\n \n \n \n \n\n\n \n\n\n\n \n \n\n \n\n\n \n\n \n\n\n\n \n\n\n \n\n\n\n \n \n \n\n \n\n\n\n\n\n\n\n \n \n \n\n \n\n \n \n \n \n\n\n\n\n \n\n\n \n\n\n\n \n\n\n\n\n\n \n \n \n \n"}, {"source_code": "#!/usr/bin/python\nfrom __future__ import division\nfrom sys import stdout,stdin\nfrom copy import copy,deepcopy\nimport math\n\n\ndef solve():\n n,m=map(int,raw_input().split())\n counter=0\n for a in xrange(int(math.ceil(1000**0.5))+1):\n for b in xrange(int(math.ceil(1000**0.5))+1):\n #if a*b+1==(n/m)*b:\n #if a+(b/a)==(n/a) and (a/b)+b==(m/b):\n if a**2+b==n and a+b**2==m:\n counter+=1\n return counter\n\nprint solve()\n"}, {"source_code": "\n\nn , m = map(int , input().split())\ncnt = 0\n\nfor i in range(min(n , m) + 1):\n for j in range(min(n,m) + 1):\n if (i * i) + j == n and (j * j) + i == m:\n cnt += 1\nprint(cnt)\n "}, {"source_code": "ans = 0\nn, m = map(int, input().split())\nfor i in range(n+1):\n for j in range(m+1):\n if (i*i+j) == n and (j*j+i)== m :\n ans+=1\nprint (\"%d\" % ans)\n"}, {"source_code": "import bisect\nfrom collections import defaultdict\nfrom collections import deque\nimport math\nimport re\n\ndef ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\ndef si():\n return raw_input()\n\ndef sis():\n return raw_input().split()\n\nn, m = nis()\n\nans = 0\nfor a in range(0, int(math.ceil(math.sqrt(n))) + 1):\n for b in range(0, int(math.ceil(math.sqrt(m))) + 1):\n if a** 2 + b == n and a + b **2 == m:\n ans += 1\n\nprint ans"}, {"source_code": "N,M=map(int,input().split())\nans=0\nif N>=M:\n for i in range(N+1):\n j=N-(i**2)\n if i+(j**2)==M and j>=0:\n ans+=1\nelse:\n for i in range(M+1):\n j=M-(i**2)\n if i+(j**2)==N and j>=0:\n ans+=1\n \nprint(ans)\n"}, {"source_code": "n,m = map(int,raw_input().split())\ncount = 0\nfor i in range(1001):\n if (n - i*i) >= 0 and (m - i) == (n - i*i)*(n - i*i):\n count += 1\nprint count"}, {"source_code": "t = input().split()\nn = int(t[0])\nm = int(t[1])\n\ncount = 0\n\nfor a in range(1001):\n for b in range(1001):\n if a**2 + b == n and b**2 + a == m:\n count += 1\n\nprint(count)"}, {"source_code": "n,m = map(int,raw_input().split())\nans=0\nfor i in range(2000):\n\tfor j in range(2000):\n\t\tif i*i + j == n and i + j*j == m: ans+=1\nprint ans"}, {"source_code": "# ===================================\n# (c) MidAndFeed aka ASilentVoice\n# ===================================\n# import math, fractions, collections\n# ===================================\nn, m = [int(x) for x in input().split()]\nans = []\nfor i in range(max(m,n)+1):\n\tfor j in range(max(m,n)+1):\n\t\tif ((i*i+j == n) and (i+j*j == m)):\n\t\t\t# if ([i,j] not in ans and [j,i] not in ans):\n\t\t\tans.append([i,j])\t\nprint(len(ans))\t"}, {"source_code": "n,m=map(int,input().split())\nc=0\nfor i in range(0,1001):\n for j in range(0,1001):\n if i*i+j==n and i+j*j==m:\n c=c+1\nprint(c)\n"}, {"source_code": "n, m = list(map(int, input().split()))\ncount = 0\na, b = 0, 0\nwhile a ** 2 <= n:\n b = n - a ** 2\n if a ** 2 + b == n and a + b ** 2 == m:\n count += 1\n a += 1\n else:\n a += 1\nprint(count)\n"}, {"source_code": "n, m = map(int, input().split())\nans = 0\nfor a in range(n + 1):\n for b in range(n + 1):\n if a * a + b == n:\n if a + b * b == m:\n ans += 1\nprint(ans)"}, {"source_code": "n, m = map(int, input().split())\nans = 0\nfor a in range(n + 1):\n for b in range(n + 1):\n ans += (a * a + b == n) & (a + b * b == m)\nprint(ans)"}, {"source_code": "inputs = raw_input().split(\" \");\nn = int(inputs[0]);\nm = int(inputs[1]);\ncnt = 0;\nfor i in range(1001):\n\tfor j in range(1001):\n\t\tif ((i * i) + j) == n and (i + (j *j) ) == m : cnt += 1;\n\nprint cnt;"}, {"source_code": "n,m=map(int,input().split())\nr=range(32)\nprint(sum(a*a+b-n==a+b*b-m==0 for a in r for b in r))"}, {"source_code": "n,m= list(map(int,input().split())) \ncount = 0\nfor i in range(max(n,m)+1):\n for j in range(max(n,m)+1):\n if ((i*i)+j == n) and (i+(j*j) == m):\n count += 1\nprint(count)\n"}, {"source_code": "\ndef form(a, b, n, m):\n if((a**2)+b == n and a+(b**2)==m):\n return True\n else:\n return False\ninp = list(map(int,input().split()))\nn = inp[0]\nm = inp[1]\nsmal = 0\nbig = 0\ncount = 0\nif(n > m):\n smal = m\n big = n\nelse:\n smal = n\n big = m\nfor a in range(0, big+1):\n for b in range(0, big+1):\n if(form(a, b, n, m)):\n count += 1\nprint(count)"}, {"source_code": "a = sorted(list(map(int, input().split())))\ncounter = 0\nfor i in range(int(a[0] ** .5) + 1):\n if (a[0] - i ** 2) ** 2 + i == a[1]:\n counter += 1\nprint(counter)"}, {"source_code": "n, m = map(int, input().split())\ncount = 0\n\nfor a in range(0, max(n, m) + 1):\n for b in range(0, max(n, m) + 1):\n if a ** 2 + b == n and a + b ** 2 == m:\n count += 1\nprint(count)\n"}, {"source_code": "n, m = map(int, input().split())\ncount = 0\nfor i in range(max(n, m) + 1):\n for j in range(max(n, m) + 1):\n if i * i + j == n and i + j * j == m:\n count += 1\nprint(count)\n\n\n"}, {"source_code": "numbers=[int(n) for n in input().split()]\nmx,mn=max(numbers),min(numbers)\npair=0\nfor i in range(0,int(pow(mx,0.5))+1):\n for q in range(0,mx-(i*i)+1):\n if i*i+q==mx and i+q*q==mn:\n pair+=1\nprint(pair)"}, {"source_code": "n,m=map(int,input().split())\ncnt=0\na,b=0,0\nn,m=max(m,n),min(m,n)\nstep=0\nwhile step*step<=n:\n if step*step<=n:\n a=step\n step+=1\n b=n-a*a\n if (m-b*b)==a:\n cnt+=1\nprint(cnt)"}, {"source_code": "#214A\n[n,m] = list(map(int,input().split()))\ns = 0\nfor i in range(1001):\n for j in range(1001):\n if i**2+j==n and i+j**2==m:\n s+=1\nprint(s)"}, {"source_code": "n, m = map(int, input().split())\npairs = 0\n\nfor i in range(max(n,m)+1):\n for j in range(max(n,m)+1):\n if i**2 + j == n and j**2 + i == m:\n pairs += 1\n\nprint(pairs)"}, {"source_code": "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n# import numpy as np\nsys.setrecursionlimit(int(pow(10,6)))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"out.txt\", \"w\")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n# @lru_cache(None)\nt=1\n# t=int(input())\nfor _ in range(t):\n n,m=l()\n ans=0\n for a in range(1001):\n for b in range(1001):\n if a*a+b==n and b*b+a==m:\n ans+=1\n print(ans)\n"}, {"source_code": "__author__ = 'Esfandiar'\nfrom math import sqrt\nn,m = map(int,input().split())\nb = res = 0\nnn=n\nwhile n:\n yy=sqrt(n)\n if int(yy) == yy and yy+(b**2) == m:\n if nn ==m and yy!=b: \n res+=2\n else:\n res+=1\n b+=1\n n-=1\nprint(res)\n\n"}, {"source_code": "def count(n, m):\n c = 0\n r = n\n if m < n:\n r = m\n a = 0\n while a <= r:\n b = n - a ** 2\n if b >= 0 and a + b ** 2 == m:\n c = c + 1\n a = a + 1\n return c\n\n\nn, m = map(int, input().split())\ncount = count(n, m)\nprint(count)\n"}, {"source_code": "count = 0\nn,m = map(int, input().split())\nfor a in range(0,max(int(pow(n, 0.5)), m)+1):\n for b in range(0, max(int(pow(m, 0.5)), n)+1):\n if (pow(a,2)+b == n) and (pow(b,2) + a == m):\n count += 1\nprint(count)\n\n "}, {"source_code": "n,m=list(map(int, input().split(' ')))\nk = 0\nfor a in range(100):\n for b in range(100):\n if a**2+b == n and a + b**2 == m:\n k+=1\nprint(k)"}, {"source_code": "n,m=map(int,input().split())\nans=0\nfor i in range(1001):\n for j in range(1001):\n if (i*i+j==n and i+j*j==m):\n ans+=1\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\ns=0\nfor b in range(m+1):\n for a in range(n+1):\n if((a**2+b ==n) and (a+b**2 ==m)):\n s=s+1\nprint(s)"}, {"source_code": "n , m = map(int,input().split())\ncount = 0\nfor i in range(101):\n a = i\n aa = a * a\n b = n - aa\n if a + (b * b) == m and b >= 0:\n count += 1 \n \nprint (count) "}, {"source_code": "c=0\nn,m=map(int,input().split())\np=max(m,n)\nfor i in range(p+1):\n if ((i*i+abs(n-(i*i)))==n) and ((i+abs(n-(i*i))*abs(n-(i*i)))==m):\n c=c+1\nprint(c)"}, {"source_code": "n,m = map(int,input().split())\na = 0\nfor i in range(0, 1000):\n for j in range(0, 1000):\n if i * i + j == n and j * j + i == m:\n a = a + 1\nprint(a)"}, {"source_code": "n, m = map(int,input().split())\nc = []\nfor i in range(n+1):\n\tfor j in range(m+1):\n\t\tif i**2 + j == n and i + j**2 == m:\n\t\t\tc.append(i)\n\t\t\tc.append(j)\nif len(c) == 0:\n\tprint(0)\nelse:\n\tprint(len(c)//2)"}, {"source_code": "import math\ndef main():\n n,m = map(int,input().split())\n c = 0\n for i in range(0,int(math.sqrt(n) + 1)):\n a = i\n b = n - a*a\n if b*b + a == m:\n c += 1\n print(c)\n\n\n\n\n\n\n\n\nmain()"}, {"source_code": "n, m = map(int, input().split())\nr, c = (max(n,m)+1)//2+1, 0\nfor a in range(r):\n for b in range(r):\n if a**2+b==n and a+b**2==m: c+=1\nprint(c)\n"}, {"source_code": "import math\nstring = input()\nnumbers = string.split(' ')\na = int(numbers[0])\nb = int(numbers[1])\nsolutions = 0\nfor x in range(int(math.sqrt(a)) + 1):\n y = a - x ** 2\n if x + y ** 2 == b:\n solutions += 1\nprint(solutions)"}, {"source_code": "n, m = map(int, input().split())\nans = 0\n\nl = []\na = int(n ** 0.5)\nfor i in range(a+1):\n c = n - i ** 2\n t = (i, c)\n l.append(t)\n\nfor j in l:\n if j[0] + j[1] ** 2 == m:\n ans += 1\n\nprint(ans)\n\n "}, {"source_code": "import math\n\nn,m=list(map(int,input().split()))\na=max(n,m)\nb=min(n,m)\nc=int(math.sqrt(a))\nr=a-(c*c)\nif a==1 and b==1:\n\tprint(\"2\")\nelif r==0:\n\tprint(\"1\")\nelif c+(r*r)==b:\n\tprint(\"1\")\nelse:\n\tprint(\"0\")"}, {"source_code": "import math\nn,m = map(int,input().split())\ncount=0\nfor i in range(int(math.sqrt(n))+1):\n for j in range(int(math.sqrt(m))+1):\n if (i*i)+j == n and i+(j*j) == m:\n count+=1\nprint(count)"}, {"source_code": "n,m=map(int, input().strip().split())\n\nres = 0\n\n\n\n\n\nfor a in range(0, 1000 ) :\n\tfor b in range(0, 1000) : \n\t\tif (a**2 + b == n) and (a + b**2 == m):\n\t\t\tres += 1\nprint(res )"}, {"source_code": "n,m=map(int,input().split(\" \"))\ns=0\nfor i in range(max(n,m)+1):\n for j in range(min(n,m)+1):\n if i**2+j==n and j**2+i==m:\n s+=1\nprint(s)"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn, m = invr()\nc = 0\nfor i in range(n+1):\n for j in range(m+1):\n if i*i + j == n and i + j*j == m:\n c += 1\nprint(c)\n"}, {"source_code": "n,m=[int(i)for i in input().split()]\nc=0\ni=0\nwhile i*i <= n:\n b=n-(i*i)\n if i+(b*b)==m:\n c+=1\n i+=1\nprint(c)"}, {"source_code": "import itertools\nI = lambda : map(int, raw_input().split())\n\ndef main():\n n, m = I()\n print sum(a**2+b==n and a+b**2==m for a, b in itertools.product(range(1001), repeat=2))\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import itertools\nn,m = map(int,raw_input().split())\nprint sum(a**2+b==n and a+b**2==m for a,b in itertools.product(range(99),repeat=2))"}, {"source_code": "import sys\nimport math\n\nn,m = map(int,raw_input().split())\n\ncount = 0\nk = max(n,m)\nfor i in range(k+1):\n for j in range(k+1):\n if (i**2+j)==n and (j**2+i)==m:\n count+=1\n\nprint(count)"}, {"source_code": "n,m=map(int,raw_input().split())\nr=range(32)\nprint(sum(a*a+b-n==a+b*b-m==0 for a in r for b in r))"}, {"source_code": "n, m = map(int, raw_input().split())\nprint sum([a**2 + b == n and a + b**2 == m for a in xrange(n+1) for b in xrange(m+1)])"}], "negative_code": [{"source_code": "n, m = list(map(int, input().split()))\nmin = min(n, m)\na = b = catch = 0\n\nwhile a < min and b < min:\n a = a + 1\n if a ** 2 + b == n and a + b ** 2 == m:\n catch = 1\n print(catch)\n elif a == min:\n b = b + 1\n if a == b == min:\n a = b\n else:\n a = 0\n\nif catch == 0:\n print('0')"}, {"source_code": "N,M=map(int,input().split())\nans=0\nif N>=M:\n for i in range(1,N+1):\n j=N-(i**2)\n if i+(j**2)==M:\n ans+=1\nelse:\n for i in range(1,M+1):\n j=M-(i**2)\n if i+(j**2)==N:\n ans+=1\n \nprint(ans)\n"}, {"source_code": "from itertools import combinations\nx,y=map(int,input().split())\nl=[i for i in range(1000)]\np=list(combinations(l,2))\nc=0\nfor i in range(len(p)):\n a = []\n for j in range(1):\n if (p[i][j]**2 + p[i][j+1]==x and p[i][j] + p[i][j+1]**2==y) or (p[i][j]**2 + p[i][j+1]==y and p[i][j] + p[i][j+1]**2==x):\n a.append(p[i][j])\n a.append(p[i][j+1])\n c +=1\nif c>0:\n print(c)\nelse:\n print(0)"}, {"source_code": "lis = list(map(int,input().split()))\nlis.sort()\nif lis[0]**2 == lis[1]:\n print(1)\nelif lis[0]*2==lis[1]:\n print(1)\nelse:\n print(0)"}, {"source_code": "n, m = map(int, input().split())\ncount = 0\nfor i in range(1001):\n if n**2 - 2*n*i**2 + i**4 - m + i == 0 and (n - i**2) % 1 == 0:\n count += 1\nprint(count)"}, {"source_code": "import math\n\nn,m=list(map(int,input().split()))\na=max(n,m)\nb=min(n,m)\nc=int(math.sqrt(a))\nr=a-(c*c)\nif r==0:\n\tprint(\"1\")\nelif c+(r*r)==b:\n\tprint(\"1\")\nelse:\n\tprint(\"0\")"}, {"source_code": "n,m = map(int,input().split())\nc = 0\nfor a in range(-35,35):\n for b in range(-35,35):\n if a**2 + b == n:\n if b**2 + a == m:\n c += 1\nprint(c)\n\n "}, {"source_code": "import sys\nimport math\n\nn,m = map(int,raw_input().split())\n\ncount = 0\nk = max(n,m)\nfor b in range(k+1):\n if m>=b**2 and b== n - (m-b**b)**2:\n count+=1\n \n\nprint(count)"}, {"source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# from math import *\n# from itertools import *\n# import random\nn, m = map(int, input().split())\ntotal_ = 0\nfor i in range(0, (n*n) + 1):\n b = n - i*i\n if b * b == m - i:\n total_ += 1\n else:\n continue\nprint(total_)\n"}, {"source_code": "k = raw_input()\nk = k.split()\n\nn = int(k[0])\nm = int(k[1])\n\nans = 0\n\nfor i in range(0, n+1):\n\tj = n - i**2\n\tif (i + j**2 == m):\n\t\tans += 1\n\t\t\nprint ans"}, {"source_code": "import math\n__author__ = 'EvgeniyVO1'\n\n\nstr = raw_input(\"input first number n=\")\n\nst = str.split(\" \")\n\nn = int(st[0])\n\nm = int(st[1])\n\nlim = int(math.sqrt(float(n)))\n\neq = []\ncount = 0\nfor i in range(0,lim):\n for j in range(0,m):\n if ((i*i+j == n) and (i+j*j == m)):\n count = count+1\n\nprint count"}, {"source_code": "import math\n\ndef get_primes(prime_supr):\n\n is_prime = [0]*2 + [1]*prime_supr\n\n for i in range(2,int(math.sqrt(prime_supr)) + 1):\n if is_prime[i]:\n for j in range(i * i, prime_supr + 1, i):\n is_prime[j] = 0\n\n return is_prime\n\nget_int = lambda: map(int, input().split())\n\nn, m = get_int()\n\n\nprint([0, 1][m >= math.sqrt(n) and n >= math.sqrt(m)])\n\n"}, {"source_code": "#!/usr/bin/python\nfrom __future__ import division\nfrom sys import stdout,stdin\nfrom copy import copy,deepcopy\nimport math\n\n\ndef solve():\n n,m=map(int,raw_input().split())\n counter=0\n for a in xrange(n+1):\n for b in xrange(m+1):\n if a==0:\n if b==n and b**2==m:\n counter+=1\n elif b==0:\n if a**2==n and a==m:\n counter+=1\n #if b*a+b==(n/m)*b and a+(b*a)==(m/n)*a:\n elif a+(b/a)==(n/a) and (a/b)+b==(m/b):\n counter+=1\n return counter\n\nprint solve()\n"}, {"source_code": "n,m=map(int,input().split())\nc=0\nfor a in range(n):\n\tb=n-a*a\n\tif a+b*b==m:\n\t\tc+=1\nprint(c)"}, {"source_code": "k = raw_input()\nk = k.split()\n\nn = int(k[0])\nm = int(k[1])\n\nans = 0\n\nfor i in range(0, n+1):\n\tj = n - i**2\n\tif (i + j**2 == m):\n\t\tans += 1\n\t\t\nprint ans"}, {"source_code": "n,m = [int(x) for x in input().split()]\n\nans = 0\nfor a in range(max(n,m)):\n for b in range(max(n,m)):\n if a**2 + b == n and a + b**2 == m:\n ans += 1\n\nprint(ans)\n"}, {"source_code": "def solved(n,m):\n ma = max(n,m)\n #print(ma)\n count = 0\n for i in range(ma):\n b = n-i*i\n if i + b*b == m:\n count += 1\n return count\nif __name__ == '__main__':\n n,m = map(int,input().split())\n print(solved(n,m))"}, {"source_code": "s = raw_input\n\nn, m = map(int, s().split())\n\nc = 0\nfor i in range(max(m, n)):\n for j in range(max(m, n)):\n if i**2+j == n and i+j**2==m:\n c+=1\nprint c\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement,product\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial, log,tan,pi,cos,sin,radians\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nfrom decimal import *\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod_ = int(1e9) + 7\nmod = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve(n):\n arr=[1]*n\n for i in range(2,int(n**0.5)+1):\n if arr[i]==1:\n for j in range(i,n,i):\n arr[j]=i\n return arr\n\n\n\n\n\ndef main():\n cnt=0\n n,m=list(map(int,input().split()))\n for i in range(1,1001):\n for j in range(1,1001):\n if i**2+j==n and i+j**2==m:\n cnt+=1\n\n print(cnt)\n\n\n \n\n\n\n\n\n\n\n \n \n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n,m=map(int,input().split())\nk=0\nfor i in range(max(n,m)):\n b=i\n a=(n-b)**0.5\n if m-b**2==a:\n k+=1\nprint(k)\n"}, {"source_code": "n,m=map(int,raw_input().strip().split())\ncou=0\nfor i in range(m):\n\tif (m-(i*i))**2==n-i:cou+=1\n\tif n==m and n!=1000:cou=2\nprint cou"}, {"source_code": "n, m = raw_input().split()\nn, m = int(n), int(m)\nt = 0\nfor a in range(0, n+1) :\n b = n - a**2\n if b == int(b) and b**2 + a == m :\n t += 1\nprint t\n"}, {"source_code": "(N, M) = [int(x) for x in input().split()]\ncount = 0\nfor a in range(max(N, M)):\n for b in range(max(N, M)):\n if a + (b ** 2) == M and (a**2) + b == N:\n count += 1\n\nprint(count)\n"}, {"source_code": "from sys import stdin\n\nline = stdin.readline().split()\nm = line[0]\nn = line[1]\npairs = 0\n\nfor a in range(0, 32):\n for b in range(0, 32):\n if (a**2 + b == n) and (a + b**2 == m):\n pairs += 1\n\nprint pairs"}, {"source_code": "a, b=sorted(map(int, input().split()))\ng=max(a, b)\nf=min(a, b)\ni=1\nwhile(i**2<=b):\n i=i+1\nh=i-1\nx=b-h**2\ncnt=0\n\nif h**2+x==b and x**2+h==a:\n cnt+=1\n print(cnt)\nelif (a==1 and b==1):\n print(\"2\")\nelse:\n print(\"0\")"}, {"source_code": "#*+++++++++++++++++++++\n# * Written By --------\n# * Boddapati Mahesh **\n# * IIIT Hyderabad *****\n# */\nn,m=map(int,raw_input().split())\ncount=0\nfor i in range(0,1001):\n for j in range(0,1001):\n if( i*i+j ==n and i+j*j==m):\n print i,j\n count+=1\nprint count\n"}, {"source_code": "n,m=map(int,input().split())\ncount=0\na=0\nb=0\nwhile a**2+b!=n or a+b**2!=m:\n a+=1\n count+=1\n if a==32:\n a=0\n b+=1\n if a==31 and b==32:\n print(0)\n break \nprint(1)\n\n"}, {"source_code": "n,m=map(int,input().split())\nb=0\na=0\nb1=0\na1=0\nwhile (a<1000 and (n**2-(2*n*(a**2))+(a**4)+a)!=m ):\n a+=1\n a1=a\n a1+=1\nb=n-a**2\nwhile (b1<1000 and(m**2-(2*m*(b1**2))+(b1**4)+b1)!=n ):\n b1+=1\na1=n-b1**2\nif a<0 or b<0:\n print(0)\nelif (a1**2+b1==n and b1**2+a1==m) and (a**2+b==n and b**2+a==m):\n print(2)\nelif (a1**2+b1==n and b1**2+a1==m) and (a**2+b!=n or b**2+a!=m):\n print(1)\nelif (a1**2+b1!=n or b1**2+a1!=m) and (a**2+b==n and b**2+a==m):\n print(1)\nelif (a1**2+b1!=n and b1**2+a1!=m) and (a**2+b!=n and b**2+a!=m):\n print(0)"}, {"source_code": "t = input().split()\nn = int(t[0])\nm = int(t[1])\n\ncount = 0\n\nfor a in range(1,1001):\n for b in range(1,1001):\n if a**2 + b == n and b**2 + a == m:\n count += 1\n\nprint(count)"}, {"source_code": "import math\n\nn,m=list(map(int,input().split()))\na=max(n,m)\nb=min(n,m)\nc=int(math.sqrt(a))\nr=a-(c*c)\nif r==0:\n\tprint(\"1\")\nelif c+(r*r)==b:\n\tprint(\"1\")\nelse:\n\tprint(\"0\")"}, {"source_code": "# coding: utf-8\nfrom math import sqrt\n\n\ndef tim_nghiem(n, so):\n nghiem = sqrt((n - so))\n nghiem_2 = int(nghiem)\n if nghiem == float(nghiem_2):\n return nghiem\n else:\n return None\n\nif __name__ == '__main__':\n n, m = input().split(' ')\n n = int(n)\n m = int(m)\n mang_n = []\n for so_a in range(n + 1):\n if tim_nghiem(n, so_a):\n b = tim_nghiem(n, so_a)\n if tim_nghiem(m, b) is not None:\n a = tim_nghiem(m, b)\n if int(a) == int(so_a):\n mang_n.append([so_a, b])\n print(len(mang_n))\n"}, {"source_code": "n,m = map(int,raw_input().split())\n\ncount = 0\nfor a in range(max(n,m)):\n for b in range(max(n,m)):\n if a*a+b == n and a+b*b == m:\n count += 1\n\nprint count"}, {"source_code": "#hello\nc=0\nn,m=map(int,input().split())\np=max(m,n)\nfor i in range(0,p+1):\n if (i*i+(n-(i*i)))==n and (i+(n-i)*(n-i))==m:\n c=c+1\nprint(c)"}, {"source_code": "def solve(n, m):\n return sum(1 for b in range(n + 1) \n for a in range(m + 1)\n if a*a + b == n and b*b == m)\n\n\ndef main():\n n, m = list(map(int, input().split()))\n print(solve(n, m))\n\n\nmain()\n"}, {"source_code": "import sys\nimport math\n\nn, m = [int(x) for x in (sys.stdin.readline()).split()]\n\nif(n > m):\n k = int(math.sqrt(n))\n t = n - (k ** 2)\n\n if((t ** 2) + k == m):\n print(1)\n else:\n print(0)\nelif(m > n):\n k = int(math.sqrt(m))\n t = m - (k ** 2)\n\n if((t ** 2) + k == n):\n print(1)\n else:\n print(0)\nelse:\n print(2)\n\n"}, {"source_code": "n, m = map(int, input().split())\np = [i for i in range(round(max(n, m) ** 0.5) + 1)]\ncount = 0\nif n == m and n <= 2:\n print(2)\nelse:\n for i in p:\n for j in range(len(p) - 1):\n if p[j + 1] ** 2 + i == n and p[j + 1] + i ** 2 == m:\n count += 1\n print(count)\n"}, {"source_code": "n, m = map(int, input().split())\nif n + m > 0 and n * m == 0:\n\tprint(0)\nelif n + m == 0:\n\tprint(1)\nelse:\n\ta = 0\n\tb = 0\n\tflag = 0\n\twhile (a ** 2 + b < n or b ** 2 + a < m) and flag == 0:\n\t\twhile a ** 2 + b < n or b ** 2 + a < m:\n\t\t\ta += 1\n\t\tif a **2 + b == n and b ** 2 + a == m:\n\t\t\tflag = 1\n\t\telse:\n\t\t\ta = 0\n\t\t\tb += 1\n\tif a ** 2 + b == n and b ** 2 + a == m:\n\t\tif n == m:\n\t\t\tprint(2)\n\t\telse:\n\t\t\tprint(1)\n\telse:\n\t\tprint(0)\n"}, {"source_code": "n, m = map(int, raw_input().split())\ns = 0\n\nfor a in range(10000):\n b = n - a*a\n if b >= 0 and a + b * b == m:\n s += 1\n print a, b\n\nprint s\n"}, {"source_code": "n,m = map(int,raw_input().split())\npairs = 0\nfor a in range (0,1001):\n b = n-(a*a)\n if (a + b*b == m):\n pairs += 1\nprint pairs\n"}, {"source_code": "n, m = raw_input().split()\nn, m = int(n), int(m)\nt = 0\nfor a in range(0, n) :\n b = n - a**2\n if b == int(b) and b**2 + a == m :\n t += 1\nprint t\n"}, {"source_code": "import math\nlst=[]\nz=list(map(int,input().split()))\nfor i in range(1,int(math.sqrt(max(z)))+1):\n x=z[0]-(i*i)\n if i+(x*x)==z[1]: \n if (i,x) not in lst:\n lst.append((i,x))\n v=z[1]-(i*i)\n if (v*v)+i==z[0]:\n if (v,i) not in lst:\n lst.append((v,i))\nprint(len(lst))\n"}, {"source_code": "n,m=map(int,input().split())\ncnt=0\na,b=0,0\nwhile a+(b**2)!=m and (a**2)+b!=n:\n if cnt**cnt<n:\n cnt+=1\n a=cnt\n if cnt**cnt>=n:\n b=n-a**2\nif m-b**2==a:\n print(1)\nelse:\n print(0)"}, {"source_code": "import sys\n\n[n,m] = [int(x) for x in sys.stdin.readline().split()]\nsquares = [x*x for x in range(32)]\nsingles = [x for x in range(32)]\nset_singles = set(singles)\ncounter = 0\nfor x in range(len(squares)):\n b = n - squares[x]\n if b*b + singles[x] == m:\n counter += 1\nprint counter\n"}, {"source_code": "\n\n# http://codeforces.com/problemset/problem/214/A\nn, m = map(int, input().split())\nnm = max(n,m)\ncount = 0\n\nfor a in range(0,nm-2):\n\tfor b in range(a+1,nm):\t\t\n\t\tsum_a2b = a*a + b\n\t\tsum_ab2 = a + b*b\n\t\t\n\t\tif ((sum_a2b == n) and (sum_ab2 == m)) or ((sum_a2b == m) and (sum_ab2 == n)):\n\t\t\tcount += 1\n\t\t\t\nif (n == 1 and m == 1):\n\tprint('2')\nelse:\n\tprint(count)\t"}, {"source_code": "n,m=map(int,input().split())\ni=0\nt=[]\ns=[]\nch=0\nwhile i**2<=n:\n t.append(i)\n i+=1\nfor i in range(len(t)):\n s.append(n-t[i]**2)\nfor i in range(len(t)):\n if t[i]+s[i]**2==m:\n ch+=1\nprint(s)"}, {"source_code": "#!/usr/bin/env python\nfrom sys import stdin\nfrom math import modf\n\nn, m = map(float, stdin.readline().split() )\ncount = 0\nt = n\nwhile(n):\n l = modf(n ** 0.5)\n if l[0] == 0:\n if l[1] + ((t-n) ** 2) == m:\n count += 1\n n -= 1\nprint count\n "}, {"source_code": "\ndef form(a, b, n, m):\n if((a**2)+b == n and a+(b**2)==m):\n return True\n else:\n return False\ninp = list(map(int,input().split()))\nn = inp[0]\nm = inp[1]\nsmal = 0\nbig = 0\ncount = 0\nif(n > m):\n smal = m\n big = n\nelse:\n smal = n\n big = m\nfor a in range(0, big):\n for b in range(0, big):\n if(form(a, b, n, m)):\n count += 1\nprint(count)"}, {"source_code": "n, m = [int(x) for x in input().split(' ')]\na, b = 0, 0\nres = 0\nfor i in range(0, m+n):\n\tfor j in range(i, m+n):\n\t\t# print(\"pair({}, {})\".format(i, j))\n\t\tfirst = (i ** 2) + j\n\t\tsecond = i + (j ** 2)\n\n\t\tif (first == n and second == m) or (first == m and second == n):\n\t\t\tres += 1\n\nprint(res)"}, {"source_code": "from collections import defaultdict\nn, m = [int(i) for i in input().split(\" \")]\nct = 0\n#dic = defaultdict(tuple)\n'''for a in range(1001):\n b = n - a*a\n if b>=0 and a>=0 and a + b*b == m:\n ct+=1\n \nif n==m:\n ct -= 1\nprint(ct)\n'''\nfor a in range(1001):\n for b in range(a,1001):\n if a*a+b == n and a + b*b == m:\n ct+=1\nprint(ct)\n"}, {"source_code": "n, m = raw_input().split()\nn, m = int(n), int(m)\nt = 0\nfor a in range(0, n+1) :\n b = n - a**2\n if b**2 + a == m and b > 0 :\n t += 1\nprint t\n"}, {"source_code": "n,m = map(int, raw_input().split())\nprint sum([1 for a in range(n) if n >= a**2 and m == a + (a**2 - n)**2])"}, {"source_code": "\n\n# http://codeforces.com/problemset/problem/214/A\nn, m = map(int, input().split())\nnm = max(n,m)\ncount = 0\n\nfor a in range(0,nm-2):\n\tfor b in range(a+1,nm):\t\t\n\t\tsum_a2b = a*a + b\n\t\tsum_ab2 = a + b*b\n\t\t\n\t\tif ((sum_a2b == n) and (sum_ab2 == m)) or ((sum_a2b == m) and (sum_ab2 == n)):\n\t\t\tcount += 1\n\t\t\t\nif (n == 1 and m == 1):\n\tprint('2')\nelse:\n\tprint(count)\t"}, {"source_code": "#!/usr/bin/env python\nfrom sys import stdin\nfrom math import modf\n\nn, m = map(float, stdin.readline().split() )\ncount = 0\nt = n\nwhile(n):\n l = modf(n ** 0.5)\n if l[0] == 0:\n if l[1] + ((t-n) ** 2) == m:\n count += 1\n n -= 1\nprint count\n "}, {"source_code": "import sys, collections\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\n\nif n % m == 0 or m % n == 0:\n print(1)\nelse:\n print(0)\n\n \n \n\n"}, {"source_code": "from collections import defaultdict\nn, m = [int(i) for i in input().split(\" \")]\nct = 0\n#dic = defaultdict(tuple)\n'''for a in range(1001):\n b = n - a*a\n if b>=0 and a>=0 and a + b*b == m:\n ct+=1\n \nif n==m:\n ct -= 1\nprint(ct)\n'''\ndone = []\nfor a in range(1001):\n b = n - a*a\n if a*a+b == n and a + b*b == m:\n ct+=1\nif n==m:\n ct -=1\nprint(ct)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Feb 26 18:48:38 2020\n\n@author: Lenovo\n\"\"\"\n\n\n#https://codeforces.com/problemset/problem/214/A\n\ndef pair_equation():\n numbers = input().split()\n numbers = [int(i) for i in numbers]\n \n minimum = min(numbers[0],numbers[1])\n \n check = [0,0]\n output = 0\n for i in range(minimum):\n check[0] += 1\n check[1] = 0\n for i in range(minimum):\n if ((check[0])**2 + check[1]) == numbers[0] and (check[0] + (check[1])**2) == numbers[1]:\n output += 1\n check[1] += 1\n \n if output == 0:\n print(-1)\n return\n else:\n print(output)\n return\n\npair_equation()\n\n\n\n \n \n \n \n \n \n \n "}, {"source_code": "__author__ = 'Esfandiar'\nfrom math import sqrt\nn,m = map(int,input().split())\nb = res = 0\n\nwhile n:\n yy=sqrt(n)\n if int(yy) == yy and yy+(b**2) == m:\n res+=1\n b+=1\n n-=1\nprint(res)\n\n"}, {"source_code": "ans = 0\nn, m = map(int, input().split())\nfor i in range(n):\n for j in range(m+1):\n if (i*i+j) == n and (j*j+i)== m :\n ans+=1\nprint (\"%d\" % ans)\n"}, {"source_code": "n,m=map(int,input().split())\ncnt=0\nfor i in range(n):\n\tif (n-i**2)**2+i==m:\n\t\tcnt+=1\nprint(cnt)"}, {"source_code": "n, m = map(int, input().split())\ncount = 0\nfor i in range(1001):\n if n**2 - 2*n*i**2 + i**4 - m + i == 0 and (n - i**2) % 1 == 0:\n count += 1\nprint(count)"}, {"source_code": "import math\nn , m = map(int,input().split())\nc = 0\nl = []\nfor i in range(45):\n if i in l:\n continue\n a = i**2 + i\n e = m + n - a\n if e < 0:\n break\n d = 1 + 4*e\n v = (- 1 + math.sqrt(d))/2\n if v - int(v) == 0:\n if ((i**2 + v == m) or (v**2 + i == m)) and ((i**2 + v == n) or (v**2 + i == n)):\n l.append(v)\n c += 1\n continue\nprint(c)"}, {"source_code": "import math\ndef main():\n n,m = map(int,input().split())\n c = 0\n for i in range(-n,int(math.sqrt(n) + 1)):\n a = i\n b = n - a*a\n if b*b + a == m:\n c += 1\n print(c)\n\n\n\n\n\n\n\n\nmain()"}, {"source_code": "import math\nnumbers = input()\nstring = numbers.split(\" \")\nn=int(string[0])\nm=int(string[1])\n\ndef is_perfect(number):\n num = number**0.5\n if num == int(num):\n print(\"Per\")\n else:\n print(\"No\")\n\n\nlista=[]\nlistb=[]\ni=1;\nwhile(i<=math.sqrt(n)):\n b= n-(i**2)\n lista.append([i,b])\n i+=1\ntotal=0\n\nfor i in lista:\n if(((i[1]**2)+i[0])==m):\n total+=1\nprint(total)"}, {"source_code": "n,m = map(int,input().split())\nc=0\nfor a in range(0,n):\n b1 = n-(a*a)\n b2 = (m-a)**(1/2)\n if b1 == b2:\n c += 1\n else:\n pass\nprint(c)"}, {"source_code": "# a^2+b=n\n# a+b^2=m\nlist1 = list(map(int, input().split()))\nn = int(list1[0])\nm = int(list1[1])\na = -1\nb = 0\nk1 = 0\nwhile a**2 <= n:\n a += 1\n b = n - a**2\n if a**2 + b == n and a + b**2 == m:\n k1 += 1\n b = 0\nprint(k1)\n"}, {"source_code": "def solve(n, m):\n return sum(1 for b in range(n + 1) \n for a in range(m + 1)\n if a*a + b == n and b*b == m)\n\n\ndef main():\n n, m = list(map(int, input().split()))\n print(solve(n, m))\n\n\nmain()\n"}, {"source_code": "#n=int(raw_input())\nn,m=map(int,raw_input().split())\nres=0\nfor i in range(0,n):\n b=n-i*i\n if b<0:\n break\n if i+b*b==m:\n res+=1\nprint res\n"}, {"source_code": "n,m=[int(i) for i in input().split()]\ncount=0\nfor i in range(0,1001):\n for j in range(0,1001):\n if((i*i)+(j)==n and (i)+(j*j)==m and i!=j):\n count=count+1\nprint(count)"}, {"source_code": "import math\np = input()\nnums = p.split(\" \")\nn = int(nums[0])\nm = int(nums[1])\ncount = 0\nfor a in range(0,max(n,m)+1):\n b = n - a*a\n if a + b*b == m:\n count = count + 1\nprint(count)\n"}, {"source_code": "sum1 = 0\ntemp = map(int, raw_input().split())\nn = temp[0]\nm = temp[1]\nend = min(n,m)\nfor i in range(end+1):\n\tb = n-i*i\n\tif(b<0):\n\t\tcontinue\n\tif((i+b*b)==m):\n\t\tprint i\n\t\tsum1+=1\nprint sum1\n"}, {"source_code": "n, m = map(int, input().split())\ncount = 0\nfor i in range(1001):\n if n**2 - 2*n*i**2 + i**4 - m + i == 0:\n count += 1\nprint(count)"}, {"source_code": "import math\nn,m=map(int,input().split())\na=math.sqrt(n)\na=math.floor(a)\nb=math.sqrt(m-a)\nif(math.floor(b)==math.ceil(b)):\n print(1)\nelse:\n print(0)"}, {"source_code": "n,m=map(int,input().split())\ncount=0\na=0\nb=0\nwhile a**2+b!=n or a+b**2!=m:\n a+=1\n count+=1\n if a==32:\n a=0\n b+=1\n if a==31 and b==32:\n print(0)\n break \nprint(1)\n\n"}, {"source_code": "n,m = map(int,input().split())\nans = 0\nfor a in range(min(n,m)+1):\n b = -(a**2 - n)\n if b ** 2 == m - a:\n ans += 1\nprint(ans)\n"}, {"source_code": "n, m = [int(x) for x in input().split()]\ncount = 0\nmn = min(n, m)\nfor a in range(0, mn):\n for b in range(0, mn):\n if (a * a + b == n) and (a + b * b == m):\n count += 1\nprint(count)"}, {"source_code": "n,m = list(map(int,input().split()))\ncc = 0\nfor a in range(1000):\n for b in range(1000):\n if a*a + b ==n and a + b*b==m or a*a + b ==m and a + b*b==n:\n cc = cc + 1\nprint(cc//2)\n\n"}, {"source_code": "a = map(int,raw_input().split())\nd = []\nx = 0\nwhile x<1020:\n if x+ (a[0] - x**2)**2 ==a[1]:\n d.append(x)\n x+=1\nprint len(d)"}, {"source_code": "#!/usr/bin/env python\nfrom sys import stdin\nfrom math import modf\n\nn, m = map(float, stdin.readline().split() )\ncount = 0\nt = n\nwhile(n):\n l = modf(n ** 0.5)\n if l[0] == 0:\n if l[1] + ((t-n) ** 2) == m:\n count += 1\n n -= 1\nprint count\n "}, {"source_code": "n,m = map(int,raw_input().split())\nprint sum([int(a + (n-a**2)**2 == m) for a in xrange(1,1001)])"}, {"source_code": "#tst problem A\n\"\"\"\nkeys = dict()\n\ndef chkCond(a,b):\n\tif a**2+b == int(n) and b**2+a == int(m):\n\t\tkeys[str(a**2+b) + \"|\" + str(b**2+a)]=1\n\t\treturn 1\n\treturn 0\n\t\ndef search(a,b):\n\tsLeft =0\n\tsRight=0\n\tif a**2 + b <= int(n) or b**2+a <= int(m):\n\t\tsLeft = search(a+1,b)\n\t\tsRight = search(a,b+1)\n\treturn sLeft+sRight+chkCond(a,b)\n\t\nsearch(0,0)\n\"\"\"\n\nI = lambda : map(int, raw_input().split())\n\ndef compute(a,n,m):\n\tl=a*(a*(a**2-2*int(n))+1)+int(n)**2\n\tif l == int(m):\n\t\treturn 1\n\treturn 0\n\ndef main():\n\tn, m = I()\n\ta=1\n\tret=0\n\twhile abs(int(n)-a**2) <= 1000:\n\t\tret=ret+compute(a,n,m)\n\t\ta=a+1\n\tprint ret# len(keys)\n\n\nif __name__ == '__main__':\n main()\n\n\n\n"}, {"source_code": "# coding: utf-8\nfrom math import sqrt\n\n\ndef tim_nghiem(n, so):\n nghiem = sqrt((n - so))\n nghiem_2 = int(nghiem)\n if nghiem == float(nghiem_2):\n return nghiem\n else:\n return None\n\nif __name__ == '__main__':\n n, m = input().split(' ')\n n = int(n)\n m = int(m)\n mang_n = []\n for so_a in range(n):\n if tim_nghiem(n, so_a):\n b = tim_nghiem(n, so_a)\n if tim_nghiem(m, b) is not None:\n a = tim_nghiem(m, b)\n if int(a) == int(so_a):\n mang_n.append([so_a, b])\n print(len(mang_n))\n"}, {"source_code": "\n\n# http://codeforces.com/problemset/problem/214/A\nn, m = map(int, input().split())\nnm = max(n,m)\ncount = 0\n\nfor a in range(0,nm-2):\n\tfor b in range(a+1,nm):\t\t\n\t\tsum_a2b = a*a + b\n\t\tsum_ab2 = a + b*b\n\t\t\n\t\tif ((sum_a2b == n) and (sum_ab2 == m)) or ((sum_a2b == m) and (sum_ab2 == n)):\n\t\t\tcount += 1\n\t\t\t\nif (n == 1 and m == 1):\n\tprint('2')\nelse:\n\tprint(count)\t"}, {"source_code": "n,m=map(int,input().split())\nk=0\nfor a in range(1,max(n,m)+1):\n for b in range(1,max(n,m)+1):\n if a**2+b==n and a+b**2==m:\n k+=1\nprint(k)"}, {"source_code": "s = raw_input\n\nn, m = map(int, s().split())\n\nc = 0\nfor i in range(max(m, n)):\n for j in range(max(m, n)):\n if i**2+j == n and i+j**2==m:\n c+=1\nprint c\n"}, {"source_code": "from math import sqrt\nn, m = [int(i) for i in input().split()]\ns = n - m\nl = []\nfor i in range(1, abs(s) + 1):\n if s % i == 0:\n l.append(i)\n l.append(-i)\nc = 0\nfor i in l:\n t = i\n k = s // i\n a = (- k - t + 1) / 2\n b = a + t\n if a == int(a) and a*a + b == n and a >= 0 and b >= 0:\n c += 1\nprint(c)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Feb 26 18:48:38 2020\n\n@author: Lenovo\n\"\"\"\n\n\n#https://codeforces.com/problemset/problem/214/A\n\ndef pair_equation():\n numbers = input().split()\n numbers = [int(i) for i in numbers]\n \n minimum = min(numbers[0],numbers[1])\n \n check = [0,0]\n output = 0\n for i in range(minimum):\n check[0] += 1\n check[1] = 0\n for i in range(minimum):\n if ((check[0])**2 + check[1]) == numbers[0] and (check[0] + (check[1])**2) == numbers[1]:\n output += 1\n check[1] += 1\n \n\n print(output)\n return\n\npair_equation()\n\n\n\n \n \n \n \n \n \n \n "}, {"source_code": "n=list(map(int, input().split()))\n\nprint(n)\np=0\nfor a in range(max(n[0]+1, n[1]+1)):\n for b in range(max(n[0]+1, n[1]+1)):\n if a*a+b==n[0] and b*b+a==n[1]:\n p+=1\n print(a,b)\nprint(p)"}, {"source_code": "n,m=map(int,raw_input().split(' '))\ncnt=0\n\ndef f(a,b,n):\n return a**2+b==n\ndef g(a,b,n):\n return a+b**2==m\n\nfor a in xrange(-100,100):\n for b in xrange(-100,100):\n if f(a,b,n) and g(a,b,n):\n cnt+=1\nprint cnt"}, {"source_code": "\n\n# http://codeforces.com/problemset/problem/214/A\nn, m = map(int, input().split())\nnm = max(n,m)\ncount = 0\n\nfor b in range(n):\n\tfor a in range(m):\t\t\n\t\tsum_a2b = a*a + b\n\t\tsum_ab2 = a + b*b\n\t\t\n\t\tif ((sum_a2b == n) and (sum_ab2 == m)):\n\t\t\tcount += 1\n\t\t\t\nprint(count)\t\n\t\n\t\n#b + n*a = d + m*c\n#\n#n = (d + m*c - b)/a"}, {"source_code": "import math\nn , m = map(int,input().split())\nc = 0\nl = []\nfor i in range(45):\n if i in l:\n continue\n a = i**2 + i\n e = m + n - a\n if e < 0:\n break\n d = 1 + 4*e\n v = (- 1 + math.sqrt(d))/2\n if v - int(v) == 0:\n if ((i**2 + v == m) or (v**2 + i == m)) and ((i**2 + v == n) or (v**2 + i == n)):\n l.append(v)\n c += 1\n continue\nprint(c)"}, {"source_code": "import math\ndef main():\n n,m = map(int,input().split())\n c = 0\n for i in range(-n,int(math.sqrt(n) + 1)):\n a = i\n b = n - a*a\n if b*b + a == m:\n c += 1\n print(c)\n\n\n\n\n\n\n\n\nmain()"}, {"source_code": "# ===================================\n# (c) MidAndFeed aka ASilentVoice\n# ===================================\n# import math, fractions, collections\n# ===================================\nn, m = [int(x) for x in input().split()]\ns = n-m\nans = 0\nfor i in range(max(m,n)):\n\tfor j in range(max(m,n)):\n\t\tif ((i-j)*(i+j)+(j-i) == s):\n\t\t\tans += 1\nprint(ans//2)"}, {"source_code": "lis = list(map(int,input().split()))\nlis.sort()\nif lis[0]**2 == lis[1]:\n print(1)\nelif lis[0]*2==lis[1]:\n print(1)\nelse:\n print(0)"}, {"source_code": "n, m = map(int, input().split())\na = -1\ncount = 0\nwhile a * a < n:\n a += 1\n b = 0\n while b * b < m:\n if a*a+b==n and a+b*b == m:\n count +=1\n b += 1\n else:\n b += 1\nprint(count)"}, {"source_code": "[n,m]=[int(x) for x in input().split()]\na=[]\ncount=0\nfor i in range(n+1):\n for j in range(m+1):\n if (i**2)+j==n and i+(j**2)==m:\n count=+1\nprint(count)"}, {"source_code": "def generator(a,n):\n return a+(n-a**2)**2\ns=input()\nc=s.split()\nn=int(c[0])\nm=int(c[1])\na=1\ncontador=0\nfor a in range(500,0,-1):\n if(generator(a,n)==m):\n contador+=1\nprint(contador)"}, {"source_code": "import math\nn,m=map(int,input().split())\na=math.sqrt(n)\na=math.floor(a)\nb=math.sqrt(m-a)\nif(math.floor(b)==math.ceil(b)):\n print(1)\nelse:\n print(0)"}, {"source_code": "n, m = map(int, input().split())\n\ncount = 0\nfor a in range(max(n, m)):\n for b in range(max(n, m)):\n if a ** 2 + b == n and a + b ** 2 == m:\n count += 1\n\n\nprint(count)\n"}, {"source_code": "n, m = map(int, input().split())\no = 0\na = 0\nb = 0\nia = -1\nib = -1\nif n==1 and m==1:\n print(2)\nelse:\n while a ** 2 <= n:\n a += 1\n ia += 1\n while b ** 2 <= m:\n b += 1\n ib += 1\n if n > m:\n while ia > 0:\n if n - (ia ** 2) <= ib:\n o += 1\n ia -= 1\n else:\n ia -= 1\n print(o)\n else:\n while ib > 0:\n if m - (ib ** 2) <= ia:\n o += 1\n ib -= 1\n else:\n ib -= 1\n print(o)\n"}, {"source_code": "n,m=list(map(int, input().split(' ')))\nk = 0\nb = 0\nfor i in range(1000):\n b = n-i**2\n if i+b**2 == m:\n k+=1\nprint(k)"}], "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd"} {"source_code": "\ns = input()\ncounter = 0\ntmp = 0\nz = 'AEIOUY'\nfor i in s:\n if i in z:\n tmp = max(tmp, counter)\n counter = 0\n else:\n counter += 1\ntmp = max(tmp, counter)\nprint(tmp + 1)\n\n# CodeForcesian\n# \u2665\n# \u062e\u0648\u062f\u062a \u0647\u0645\u0627\u0646 \u062a\u063a\u06cc\u06cc\u0631\u06cc \u0628\u0627\u0634 \u06a9\u0647 \u0645\u06cc\u062e\u0648\u0627\u0647\u06cc \u062f\u0631 \u062f\u0646\u06cc\u0627 \u0628\u0628\u06cc\u0646\u06cc\n", "positive_code": [{"source_code": "s = \"A\" + raw_input() + \"A\"\n\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n\njump = 1\nfor i in xrange(len(s)):\n\tif s[i] in vowels:\n\t\tfor j in xrange(i+1, len(s)):\n\t\t\tif s[j] in vowels:\n\t\t\t\tjump = max(jump, j-i)\n\t\t\t\ti = i + j\n\t\t\t\tbreak\n\nprint jump"}, {"source_code": "x=['a','e','i','o','u','y']\ns=raw_input().lower()\nk=0\ny=[]\nfor i in s:\n if i in x:\n y.append(k)\n k=0\n else:\n k+=1\ny.append(k)\nif len(s)>1:\n print max(y)+1\nelif(s in x):\n print 1\nelse:\n print 2"}, {"source_code": "# #\n# CodeForces\n# Problem 733A\n# Python 2\n# #\n\nVOWELS = ['A', 'E', 'Y', 'U', 'I', 'O']\n\njump_len = 1\ncurrent_len = 1\n\nfor char in raw_input():\n if not char in VOWELS:\n current_len += 1\n else:\n if current_len > jump_len:\n jump_len = current_len\n\n current_len = 1\n\nif current_len > jump_len:\n jump_len = current_len\n\nprint jump_len\n"}, {"source_code": "s=str(input())\nd=0\ndis=0\nl=[]\nfor i in range(0,len(s)):\n if(s[i] in 'AEIUOY'):\n dis=((i+1)-d)\n d=i+1\n l.append(dis)\n# print(l)\nl.append((len(s)+1)-d)\nif(len(l)==0):\n print(len(s)+1)\nelse:\n print(max(l))\n "}, {"source_code": "lI = -1\ncur = 0\n\ns = {'A','E','I','O','U','Y'}\n\nS=input()\nfor x in range(len(S)):\n if S[x] in s:\n if lI == -1:\n cur = x + 1\n lI = x\n \n else:\n cur = max(cur, x - lI)\n lI = x\nif lI != -1: cur = max(cur, len(S) - lI) \nelif lI == -1: cur = len(S) + 1 \nprint(cur) "}, {"source_code": "s=raw_input()\np=-1\nf1=0\nl=[]\nfor f in range(len(s)):\n if s[f] == 'A' or s[f] == 'E' or s[f] == 'I' or s[f] == 'O' or s[f] == 'U' or s[f] == 'Y':\n l.append(f+1)\n p=f\n break\nf1=p+1\nwhile f1<len(s):\n if s[f1]=='A' or s[f1]=='E' or s[f1]=='I' or s[f1]=='O' or s[f1]=='U' or s[f1]=='Y':\n l.append(f1-p)\n p=f1\n f1=f1+1\nl.append(len(s)-p)\nif len(l)==0 and p==-1:\n print len(s)+1\nelse:\n print max(l)"}, {"source_code": "'''n=int(input())\np=input().rstrip().split(' ')\nif int(p[1])==7 or int(p[0])==7:\n print(0)\nelif int(p[1])>7:\n for i in range(int(p[1]),-1,-1):\n T=list(str(i))\n if '7' in T:\n V=i;\n break;\n B=int(p[1])-V;\n print(B//n)\nelse:\n B=3+int(p[1])\n print(B//n)'''\n\n\n\ns=input().rstrip()\nx=list(s)\nS=0;\nw=[]\nl=['A','E','I','O','U','Y']\nfor i in range(0,len(x)):\n if x[i] in l:\n w.append(i+1-S)\n S=i+1;\nw.append(len(x)+1-S)\nprint(max(w))"}, {"source_code": "v=('A','E','I','O','U','Y')\ns=input()+'A'\nc=0\nm=0\nfor i in s:\n c+=1\n if i in v:\n if c>m:\n m=c\n c=0\nprint(m)"}, {"source_code": "import re\n\ndef grasshoper_and_the_string():\n\n\tdata = input()\n\n\tl = sorted(re.findall(r'[^AEIOUYaeiouy]+', data), key=len, reverse=True)\n\n\tif len(l):\n\t\treturn len(l[0]) + 1\n\telse:\n\t\treturn 1\n\n\nprint(grasshoper_and_the_string())\n"}, {"source_code": "s = input()\ns = ' '+s\njump = 1\nvowels = set(list('AEIOUY'))\nprev = 0\ncheck = 0\nfor i in s:\n if i in vowels:\n check =1\n break\ni = 1\nif check>0:\n while i<len(s):\n if s[i] in vowels:\n jump = max(jump,i-prev)\n prev = i\n i+=1\n jump = max(jump,i-prev)\n print(jump)\nelse:\n print(len(s))"}, {"source_code": "\nget_int = lambda: map(int, input().split())\n\ns = input()\n\nx = 1\nans = 1\n\nfor i in s:\n if i in \"AEIOUY\":\n if ans < x:\n ans = x\n x = 1\n else:\n x += 1\n\nprint(max(x, ans))\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "data = input() + 'A'\n\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n\nfirst = 0\nsecond = 0\nmy_max = 0\nfor index, letter in enumerate(data):\n\tif letter in vowels:\n\t\tfirst = second\n\t\tsecond = index + 1\n\t\tif my_max < second - first:\n\t\t\tmy_max = second - first\n\nprint(my_max)\n"}, {"source_code": "#!/usr/bin/env python3\n\nfrom functools import reduce\nfrom operator import add\nimport re\n\n\ndef main():\n try:\n while True:\n print(reduce(max, (len(m.group()) for m in re.finditer(r\"[^AEIOUY]+\", input())), 0) + 1)\n\n except EOFError:\n pass\n\n\nmain()\n"}, {"source_code": "a,b=1,1\nfor i in input()+'A':\n if i in 'AEIOUY':\n a=max(a,b)\n b=1\n else:\n b+=1\nprint(a)"}, {"source_code": "import sys\n\ndef calculateHop(line) : \n vowels = set(['A','E','I','O','U','Y'])\n count = 0\n result = 0\n for char in line :\n count += 1\n if char in vowels :\n result = max(count, result)\n count = 0\n print max(count+1,result)\n\t\t\t \nif __name__ == \"__main__\" : \n input = sys.stdin.readline().strip()\n calculateHop(input) "}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\n\nif __name__ == '__main__':\n l = ['A', 'E', 'I', 'O', 'U', 'Y']\n s = raw_input()\n s = 'S' + s\n lnum,rnum = 0, 0\n mi = 0\n for i in range(len(s)):\n if s[i] in l:\n rnum = i\n tmp = rnum - lnum\n if mi < tmp:\n mi = tmp\n lnum = i\n tmp = len(s) - lnum\n if mi < tmp:\n mi = tmp\n print mi\n\n"}, {"source_code": "import re\nprint(len(max(re.split('[AEIOUY]', input()), key=len))+1)"}, {"source_code": "s = raw_input()\nc = 1\nans = 0\nfor i in xrange(0, len(s)):\n\tif s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'U' or s[i] == 'Y':\n\t\tans = max(ans, c)\n\t\tc = 1\n\telse:\n\t\tc = c + 1\nans = max(ans, c)\nprint ans"}, {"source_code": "st = raw_input()\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n\ni = 0\nwhile i < len(st):\n if st[i] in vowels:\n prev = i\n break\n i += 1\n\n\nmax_jump = i + 1\nprev, cur = i, i + 1\n\nwhile prev < len(st) and cur < len(st):\n if st[cur] in vowels:\n max_jump = max(cur-prev, max_jump)\n prev = cur\n cur += 1\n\nprint max(max_jump, cur-prev)"}, {"source_code": "q = input()\ns = 0\nm = 0\nw = {\"A\", \"E\", \"I\", \"O\", \"U\", \"Y\"}\nfor i in range(len(q)):\n if q[i] in w:\n m = max(m, s)\n s = 0\n else:\n s += 1\nm = max(m, s)\nprint(m + 1)"}, {"source_code": "str = raw_input()\n\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\nl = 0\nt = -1\n\nfor i in range(len(str)):\n if str[i] in vowels:\n if i - t > l:\n l = i - t\n t = i\nif len(str) - t > l:\n l = len(str) - t\n\nif l == 0:\n print len(str) + 1\nelse:\n print l"}, {"source_code": "# python2\nimport sys, threading, os.path\nimport collections, heapq, math,bisect\n\nsys.setrecursionlimit(10**6) # max depth of recursion\nthreading.stack_size(2**27)\n\ndef main():\n if os.path.exists('input.txt'):\n input = open('input.txt', 'r')\n else:\n input = sys.stdin\n #--------------------------------INPUT---------------------------------\n s = str(input.readline())\n vowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n indexes = []\n maxone=0\n for i in range(len(s)):\n vowel = False\n for x in vowels:\n if x == s[i]:\n vowel = True\n break\n if vowel:\n indexes.append(i+1)\n if len(indexes)==0:\n output = len(s)\n else:\n #print indexes\n sols = []\n for i in range(len(indexes)):\n if i ==0:\n sols.append(indexes[i])\n else:\n sols.append(indexes[i]-indexes[i-1])\n sols.append((len(s)-indexes[len(indexes)-1]))\n #print sols\n output = max(sols)\n #-------------------------------OUTPUT----------------------------------\n if os.path.exists('output.txt'):\n open('output.txt', 'w').writelines(str(output))\n else:\n sys.stdout.write(str(output))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n=input()\nm=[]\nc=0\nfor i in n:\n if i=='A' or i=='E' or i=='I' or i=='O' or i=='U' or i=='Y':\n m.append(c)\n c=0\n else:\n c=c+1\nm.append(c)\nprint(max(m)+1)\n \n \n"}, {"source_code": "vowels = \"AEIOUY\"\n\ns = raw_input()\n\ncur_most = 0\ncur = 1\nfor c in s:\n if c in vowels:\n cur_most = max(cur_most, cur)\n cur = 1\n else:\n cur += 1\ncur_most = max(cur_most, cur)\n\nprint cur_most\n"}, {"source_code": "s=input()\n\nindices = [i for i, x in enumerate(s) if x == \"A\" or x == \"E\" or x == \"I\" or x == \"O\" or x == \"U\" or x == \"Y\" ] \n#print (indices)\nif len(indices)==1:\n print (max(indices[0]+1,len(s)-indices[0]))\nelif len(indices)==0:\n print (len(s)+1) \nelse:\n m=[]\n \n \n \n \n \n for i in range(len(indices)-1):\n m.append(indices[i+1]-indices[i])\n m.append(len(s)-indices[len(indices)-1])\n m.append(indices[0]+1)\n #print (m) \n print (max(m)) "}, {"source_code": "#!/usr/bin/env python\nvowels = ['A','O','Y','U','I','E']\nwhile True:\n\ts=raw_input()\n\tif len(s) in range(1,101):\n\t\tbreak\nl=[x for x in s]\nvalue = []\np=0\np1=0\nfor i in range(len(l)):\n\tp=p1\n\tif l[i] in vowels:\n\t\tp1=i+1\n\t\tvalue.append(p1-p)\n\telif i==len(l)-1:\n\t\tp1=len(l)+1\n\t\tvalue.append(p1-p)\nvalue.sort()\nprint value[-1]\n"}, {"source_code": "s = raw_input().strip()\np = -1\nans = 0\nfor i in range(len(s)):\n if s[i] in \"AEIOUY\":\n ans = max(i - p, ans)\n p = i\nans = max(len(s) - p, ans) \nprint ans"}, {"source_code": "s = \" \" + raw_input()\n\nmax_diff = 0\nprev = 0\n\nfor i in xrange(1, len(s)):\n\tif s[i] in \"AEIOUY\":\n\t\tmax_diff = max(max_diff, i - prev)\n\t\tprev = i\n\nmax_diff = max(max_diff, len(s) - prev)\nprint(max_diff)"}, {"source_code": "#l=map(int, raw_input().split())\ns=raw_input()\nmx=1\nc=1\nfor i in s:\n\tmx=max(mx,c)\n\tif i in ['A','E','I','O','U','Y']:\n\t\tc=1\n\telse:\n\t\tc+=1\nmx=max(mx,c)\nprint mx"}, {"source_code": "s=input()\nl=[0]\nfor i in range(len(s)):\n\tif(s[i]=='A' or s[i]=='E' or s[i]=='I' or s[i]=='O' or s[i]=='U' or s[i]=='Y'):\n\t\tl.append(i+1)\nl.append(len(s)+1)\nl2=[]\nfor i in range(len(l)-1):\n\tl2.append(l[i+1]-l[i])\nprint(max(l2))"}, {"source_code": "s = raw_input()\nja = 0\nja_max = -1\nfor ch in s:\n\tif ch == 'A' or ch == 'E' or ch == 'I' or ch == 'O' or ch == 'U' or ch == 'Y':\n\t\tja += 1\n\t\tja_max = max(ja_max,ja);\n\t\tja = 0\n\telse:\n\t\tja += 1\nja+=1\nja_max = max(ja_max,ja)\nprint ja_max"}, {"source_code": "\n#########\t\t\t##\t## ## \t #### ##### ## # ## #\t\t##\n\t#\t\t\t # #\t# # # #\t\t #\t #\t#\t# # # # # # #\t # #\n\t#\t\t\t # #\t# ### #\t #\t\t#\t# # # # # # #\t # #\n\t#\t\t\t #####\t#\t#\t#\t # ###\t#\t# # # # # # # #####\n\t#\t\t\t# #\t#\t\t#\t # # #\t#\t# #\t# # #\t # # # # \n######### \t # # \t#\t\t#\t\t##### #\t##### #\t ## #\t ## # #\n\n\"\"\"\n\nPPPPPPP RRRRRRR\t\t OOOO\t VV VV EEEEEEEEEE\nPPPPPPPP RRRRRRRR OOOOOO VV VV\t EE\nPPPPPPPPP RRRRRRRRR OOOOOOOO VV VV\t EE\nPPPPPPPP RRRRRRRR OOOOOOOO VV VV \t EEEEEE\nPPPPPPP RRRRRRR OOOOOOOO VV VV EEEEEEE\nPP \t\t RRRR\t\t\t OOOOOOOO VV VV EEEEEE\nPP\t\t\t RR RR OOOOOOOO VV VV EE\nPP\t\t\t RR RR OOOOOO VV VV EE\nPP\t\t\t RR RR OOOO VVVV EEEEEEEEEE\n\n\"\"\"\n\n\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nimport sys\ninput = sys.stdin.readline\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k; \n res = 1;\n for i in range(k): \n res = res * (n - i);\n res = res / (i + 1); \n return int(res);\n \n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0, hi = None):\n if hi == None:\n hi = len(a);\n while lo < hi:\n mid = (lo+hi)//2;\n if a[mid] < x:\n lo = mid+1;\n else:\n hi = mid;\n return lo;\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret;\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\n\ndef solve():\n\ts = input().lower()\n\tj = 0\n\tm = 0\n\tfor i in range(1, len(s) + 1):\n\t\tif s[i - 1] in \"aeiouy\":\n\t\t\tm = max(m, abs(i - j))\n\t\t\tj = i\n\t\t\t# print(i, m)\n\tm = max(len(s) - j, m)\n\tif m == 0:\n\t\tprint(len(s))\n\t\treturn\n\tprint(m)\n\n\n\nif __name__ == '__main__':\n\tfor _ in range(1):\n\t\tsolve()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n "}, {"source_code": "import re\nprint(max(map(len,re.split(\"[AEIOUY]\",input())))+1)\n"}, {"source_code": "s = raw_input()\nv = [0] + [i+1 for i,c in enumerate(s) if c in 'AEIOUY']+ [len(s)+1]\nprint max(v[i+1]-v[i] for i in xrange(len(v)-1))\n"}, {"source_code": "V = ('A', 'E', 'I', 'O', 'Y', 'U')\ns = input()\nj = -1\nmax = 0\nfor i in range(len(s)):\n\tif s[i] in V:\n\t\tif i-j > max:\n\t\t\tmax = i-j\n\t\tj = i\n\tif i == len(s)-1:\n\t\tif len(s)-j > max:\n\t\t\tmax = len(s)-j\nprint(max)"}, {"source_code": "vowels = ['A', 'E', 'I', 'O', 'U', 'Y']\nlast = 0\nans = 0\n\ns = raw_input()\nn = len(s)\n\nfor i in range(1, n + 1):\n\tc = s[i - 1]\n\tif c in vowels:\n\t\tans = max(ans, i - last)\n\t\tlast = i\n\nans = max(ans, n + 1 - last)\n\nprint ans"}, {"source_code": "s = 'Y' + input() + 'Y'\nindex = []\nvow = set(['A', 'E', 'I', 'O', 'U', 'Y'])\nfor i in range(len(s)):\n if s[i] in vow:\n index.append(i)\nans = []\nfor i in range(len(index) - 1):\n ans.append(index[i+1] - index[i])\nprint(max(set(ans)))\n"}, {"source_code": "a = input()\nb = ['A', 'E', 'I', 'O', 'U', 'Y']\nm = 1\nc = 0\nfor i in range(len(a)):\n if a[i] in b:\n c = 0\n else:\n c += 1\n m = max(m, c + 1)\nprint(m)"}, {"source_code": "s = input()\ncnt = jump = 0\nvowels = ['A','E','I','O','U','Y']\nfor i in range(len(s)):\n if s[i] not in vowels:\n cnt += 1\n if cnt > jump:\n jump = cnt\n else:\n cnt = 0\nprint(jump+1)\n"}, {"source_code": "n=input()\nl=[]\ncnt=0\nma=0\nfor i in range(len(n)):\n if n[i] not in \"AEIOUY\":\n cnt+=1\n else:\n if cnt>=ma:\n ma=cnt\n cnt=0\nprint(max(cnt+1,ma+1))\n\n \n \n "}, {"source_code": "import math,sys,bisect,heapq\nfrom collections import defaultdict,Counter,deque\nfrom itertools import groupby,accumulate\n#sys.setrecursionlimit(200000000)\ninput = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\nilele = lambda: map(int,input().split())\nalele = lambda: list(map(int, input().split()))\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\n#MOD = 1000000000 + 7\ndef Y(c): print([\"NO\",\"YES\"][c])\ndef y(c): print([\"no\",\"yes\"][c])\ndef Yy(c): print([\"No\",\"Yes\"][c])\n \nS = input()\nS = \"A\" + S + \"A\"\nA = [\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\"]\nT = [*S]\nAns = 0\ntemp = 0\nfor i in range(1,len(T)):\n if T[i] in A:\n dis = i - temp\n temp = i\n Ans = max(Ans,dis)\nprint(Ans)\n\n"}, {"source_code": "s = input()\nG = ('A', 'E', 'I', 'O', 'U', 'Y')\nA = [-1]\nminL = 0\nL = len(s)\n\nfor i in range(L):\n if s[i] in G:\n A.append(i)\n\nfor i in range(len(A)-1):\n if A[i+1] - A[i] > minL:\n minL = A[i+1] - A[i]\n\n\nif len(A) == 1:\n print(L+1)\nelif len(A) == 2:\n print(max(A[1]+1, L - A[1]))\nelse:\n print(max(minL,L - A[len(A)-1]))"}, {"source_code": "str=input()\nstr+='$'\nans=0\nvowels=['A','E','I','O','U','Y','$']\ncur=0\nfor i in range(1,len(str)+1):\n if str[i-1] in vowels:\n ans=max(ans,i-cur)\n cur=i\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport sys\nimport re\nimport math\nimport itertools\nimport collections\nimport bisect\n#sys.stdin=file('input.txt')\n#sys.stdout=file('output.txt','w')\n#10**9+7\nmod=1000000007\n#mod=1777777777\npi=3.141592653589\nIS=float('inf')\nxy=[(1,0),(-1,0),(0,1),(0,-1)]\nbs=[(-1,-1),(-1,1),(1,1),(1,-1)]\ndef niten(a,b): return abs(a-b) if a>=0 and b>=0 else a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))\ndef fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]\ndef gcd(a,b): return a if b==0 else gcd(b,a%b)\ndef lcm(a,b): return a*b/gcd(a,b)\ndef eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5\ndef choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0\ndef pscl(num,l=[1]):\n for i in range(num):\n l = map(lambda x,y:x+y,[0]+l,l+[0])\n return l\n\n#n,k=map(int,raw_input().split())\n#l=map(int,raw_input().split())\ns=raw_input()\nans=chk=1\nfor i in s:\n if i in 'AIUEOY':\n ans=max(chk,ans)\n chk=1\n else:\n chk+=1\nprint max(ans,chk)\n#end = time.clock()\n#print end - start"}, {"source_code": "word = 'O' + input() + 'O'\n\npositions = [i for i in range(len(word)) if word[i] in \"AEIOUY\"]\n\n\njumps = [positions[i] - positions[i - 1] for i in range(1 , len(positions))]\n#print(positions)\n#print(jumps)\nprint(max(jumps))\n"}, {"source_code": "S=input()\nif S[0]!='A' and S[0]!='E' and S[0]!='I' and S[0]!='O' and S[0]!='U' and S[0]!='Y':\n k=2\nelse:\n k=1\nl=[k]\nfor i in range(len(S)-1) :\n if S[i+1]!='A' and S[i+1]!='E' and S[i+1]!='I' and S[i+1]!='O' and S[i+1]!='U' and S[i+1]!='Y':\n k=k+1\n l.append(k)\n else:\n k=1\nprint(max(l))\n"}, {"source_code": "\nstring = raw_input().strip()\nvow = 'AEIOUY'\nans = 1\nll = len(string)\np = 0\n\nwhile p<ll:\n\tif string[p] in vow:\n\t\t#print 'vow',p\n\t\tp+=1\n\telse:\n\t\tk = 0\n\t\twhile p+k < ll and string[p+k] not in vow:\n\t\t\tk+=1\n\t\t\t#print p,p+k,k\n\t\tans = max(ans,k+1)\n\t\tp = p+k\n\nprint ans"}, {"source_code": "vowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n\nmyString = input()\nmyList = list()\nmyJumps = list()\n\nfor x in range(0, len(myString), 1):\n myList.append(myString[x])\n\ntemp = 0\n\nfor element in myList:\n if element in vowels:\n myJumps.append(temp+1)\n temp = 0\n else:\n temp += 1\n myJumps.append(temp+1)\n\nprint(max(myJumps))\n\n'''\nmyInput = input()\nmyList = list()\nmyJumps = list()\n\n#sum = 0\ntemp = 0\n\nfor x in range(0, len(myInput), 1):\n myList.append(myInput[x])\n\n\n\nif myList[0] in vowels:\n\n\n sum += 1\n\n for element in myList:\n if element in vowels:\n temp += 1\n else:\n sum += temp\n myJumps.append(temp)\n temp = 0\n\nelse:\n\n for element in myList:\n if element in vowels:\n temp += 1\n else:\n sum += temp\n myJumps.append(temp)\n temp = 0\n\n\nprint(myJumps)\n\n'''\n\n"}, {"source_code": "import re\ns = raw_input()\nprint max(map(len, re.split(r\"[AEIOUY]\", s)))+1"}, {"source_code": "s = '0'+input()+'1'\nl = 'AEIOUY1'\ni, k, mx, p, ls = 0, 0, 0, 0, 0\nwhile i<len(s):\n if s[i] in l:\n k=(i-p)\n p = i\n if mx<k:\n mx = k\n ls = 1\n i+=1\nif ls==1:\n print(mx)\nelse:\n print(len(s)-1)"}, {"source_code": "str1=\"AEYOUI\"\nc=1\nm=0\nfor k in input()+\"A\":\n if k in str1:\n if c > m:\n m = c\n c = 1\n else:\n c += 1\nprint(m)"}, {"source_code": "st=list(input())\nst.append(\"I\")\nmaxi=0\nstart=0\nfor x in range(len(st)):\n if st[x] in \"AEIOUY5\":\n finish=x+1\n if finish - start > maxi :\n maxi =finish- start\n start = finish\nprint(maxi)\n"}, {"source_code": "s=list(input())\nk=['A']\ns.append('A')\nfor i in range(len(s)):\n k.append(s[i])\nmax=0\np_pos=0\ncount=0\nv=['A','E','I','O','U','Y']\nfor i in range(len(k)):\n if k[i] in v:\n c_pos=i\n j_l=c_pos-p_pos\n p_pos=i\n count+=1\n if j_l>max:\n max=j_l\nif count>0:\n if count==1:\n print(max+1)\n else:\n print(max)\nelse:\n print(len(s)+1) "}, {"source_code": "line = input() + 'A'\nvowels = 'AEIOUY'\n\nstart = -1\nlimit = 1\nfor i in range(len(line)):\n if line[i] in vowels:\n if i - start > limit:\n limit = i - start\n start = i\nprint(limit)\n"}, {"source_code": "x=raw_input()\n\nr=[]\nc=1\ni=0\nm=0\nwhile i<len(x):\n if x[i]=='A' or x[i]=='E' or x[i]=='I' or x[i]=='O' or x[i]=='U' or x[i]=='Y':\n r.append(c)\n m=1\n mm=i\n c=1\n else:\n c+=1\n i+=1\n\nif m==1:\n r.append(len(x)-mm)\n print(max(r))\nelse:\n print(len(x)+1)\n"}, {"source_code": "import sys,math\n\ns= raw_input()\nvowel = ['A','E','I','O','U','Y']\npos = -1\nans=0\nfor i in xrange(len(s)):\n\tif s[i] in vowel:\n\t\tans=max(ans,i-pos)\n\t\tpos=i\nans=max(ans,len(s)-pos)\nprint ans"}, {"source_code": "l=['A', 'E', 'I', 'O', 'U','Y']\ns=input()\nz,p=0,0\nfor i in range(len(s)):\n\tif s[i] in l:\n\t\tp=0\n\t\tcontinue\n\telse:\n\t\tp+=1\n\tz=max(z,p)\nprint(z+1)"}, {"source_code": "#http://codeforces.com/contest/733/problem/A?locale=en\nn = input()\nc = []\nt = 0\nvowels = 'AEIOUY'\nk = False\ntry:\n for i in range(len(n)):\n if n[i] in vowels:\n c.append((i+1)-t)\n t= i+1\n k = True\n if k == True:\n c.append(len(n)-(t-1))\n print(max(c))\n else:\n print(len(n)+1) \nexcept:\n print(len(n)+1)\n \n \n"}, {"source_code": "def vowel(s):\n\treturn (s == 'a' or s == 'e' or s == 'i' or s == 'o' or s == 'u' or s == 'y')\ns = input().lower()\na = []\nfor i in range(len(s)):\n\tif vowel(s[i]):\n\t\ta.append(i)\nif a == []:\n\tprint(len(s)+1)\nelse:\t\n\tb = [a[0]+1]\n\tfor i in range(len(a)-1):\n\t\tb.append(a[i+1]-a[i])\n\tb.append(len(s)-a[-1])\n\tprint(max(b))\t\t\t"}, {"source_code": "a=input()\nx=\"AEIOUY\"\ny=0\nz=0\nfor i in a:\n if i in x:\n y=0\n else:\n y+=1\n z=max(z,y)\nprint(z+1)"}, {"source_code": "t = input()\nd = {\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\"}\nz = 0\nt1 = 0\nk = 0\nfor i in range(len(t)):\n\tif t[i] in d:\n\t\tk = k + 1\n\t\tz = max(z,k)\n\t\tk = 0\n\telse:\n\t\tk = k + 1\n\t\tz = max(z,k)\nif i == len(t)-1 and t[i] in d:\n\tk+=0\nelse:\n\tk+=1\nz = max(z,k)\nprint(z)"}, {"source_code": "n = input()\nsonor = ['A', 'O', 'U', 'I', 'E', 'Y']\nmin = 0\ncount = 1\nfor c in n:\n if c in sonor: \n if count > min: min = count\n count = 1\n else: \n count+=1\nif count > min: min = count\nif (min==0): print (count)\nelse:\n print (min)"}, {"source_code": "def vowel(a):\n if a == \"A\" or a==\"E\" or a==\"I\" or a==\"O\" or a==\"U\" or a==\"Y\":\n return True\n return False\n\n\npath = input()\npath = \"A\"+path+\"A\"\nMin = 0\ncp = -1\ntemp=[]\nfor i in range(len(path)):\n if vowel(path[i]):\n temp.append(1)\n else:\n temp.append(0)\n\n\ntemp = [i for i,x in enumerate(temp) if x == 1]\nMax=1\nfor i in range(len(temp)-1):\n if temp[i+1] - temp[i] > Max:\n Max = temp[i+1] - temp[i]\nprint(Max)\n\n"}, {"source_code": "t = input()\ncnt = 0\nmax1 = 0\nt1 = 'AEIOUY'\nfor i in t:\n cnt = cnt + 1\n if i in t1:\n if cnt > max1:\n max1 = cnt\n cnt = 0\ncnt = cnt + 1\nif cnt > max1:\n max1 = cnt\nprint(max1)"}, {"source_code": "def isVowel( char ):\n vowels = [ 'A', 'E', 'I', 'O', 'U', 'Y' ]\n if char in vowels:\n return True\n else:\n return False\n\ndef main():\n inpstr = raw_input()\n ans = 0\n tmpans = 1\n for c in inpstr:\n if isVowel( c ):\n ans = max( ans, tmpans )\n tmpans = 1\n else:\n tmpans = tmpans + 1\n ans = max( ans, tmpans )\n print ans \n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "s=input()\na=[0]\nfor i in range(len(s)):\n if(s[i]==\"A\" or s[i]==\"E\" or s[i]==\"I\" or s[i]==\"O\" or s[i]==\"U\" or s[i]==\"Y\"):\n a.append(i+1)\na.append(len(s)+1)\nd=[]\nfor j in range(1,len(a)):\n d.append(a[j]-a[j-1])\nprint(max(d))"}, {"source_code": "def main():\n inpstr = raw_input()\n ans = 0\n tmpans = 1\n vowels = [ 'A', 'E', 'I', 'O', 'U', 'Y' ]\n for ch in inpstr:\n if ch in vowels:\n ans = max( ans, tmpans )\n tmpans = 1\n else:\n tmpans = tmpans + 1\n ans = max( ans, tmpans )\n print ans \n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "vowels = 'AEIOUY'\n\ns = raw_input()\ns = [0] + [i + 1 for i, c in enumerate(s) if c in vowels] + [len(s) + 1]\n\nans = 0\nfor i in xrange(1, len(s)):\n ans = max(ans, s[i] - s[i - 1])\n\nprint ans"}, {"source_code": "a = input()\np = -1\nb = ['A','E','I','O','U','Y']\nans = 0\nfor i in range(len(a)):\n if (a[i] in b):\n if (p == -1):\n ans = i + 1\n p = i\n else:\n ans = max(ans, i - p)\n p = i\nans = max(ans, len(a) - p)\nprint(ans)"}, {"source_code": "# cook your code here\ns=' '+raw_input()+'A'\nc='AEIUOY'\nans=0\npos=0\nfor i in xrange(1,len(s)):\n if s[i] in c:\n ans=max(ans,i-pos)\n pos=i\nprint ans"}, {"source_code": "s=input()\nindex=[-1]\nfor i in range(len(s)):\n if s[i] in \"AEIOUY\":\n index.append(i)\nindex.append(len(s))\ng=-2\nfor i in range(1,len(index)):\n if index[i]-index[i-1] >g:\n g=index[i]-index[i-1]\nprint(g)\n"}, {"source_code": "w = raw_input() + \"A\"\nm = 0\na = 0\nb = 0\nv = [\"A\", \"E\", \"I\", \"O\", \"U\", \"Y\"]\nfor i in range(0, len(w)):\n if w[i] in v:\n a = b\n b = i + 1\n d = b - a\n if d > m:\n m = d\nprint m\n"}, {"source_code": "str = input()\ns1 = str\ns2 = 'A'\nstr = s2 + s1 + s2\nl = len(str)\npos = 0\nans = 0\nfor i in range(0, l):\n if str[i] == 'A' or str[i] == 'E' or str[i] == 'O' or str[i] == 'U' or str[i] == 'I' or str[i] == 'Y' :\n ans = max(ans, i - pos)\n pos = i\nprint(ans)"}, {"source_code": "r=raw_input()\na=[-1]+[i for i,x in enumerate(r) if x in 'AEIOUY']+[len(r)]\nprint max([a[i]-a[i-1] for i in xrange(1,len(a))])"}, {"source_code": "w = raw_input() + \"A\"\nm = 0\na = 0\nb = 0\nv = [\"A\", \"E\", \"I\", \"O\", \"U\", \"Y\"]\nfor i in range(0, len(w)):\n if w[i] in v:\n a = b\n b = i + 1\n d = b - a\n if d > m:\n m = d\nif m == 0:\n m = len(w)\nprint m\n"}, {"source_code": "n=input()\narr=[]\n\nfor i in range(len(n)) :\n\tif n[i]==\"A\" or n[i]==\"E\" or n[i]==\"I\" or n[i]==\"O\" or n[i]==\"U\" or n[i]==\"Y\" :\n\t\tarr.append(i)\n\n# print(arr)\n\ntemp=1\n\nfor i in range(1,len(arr)) :\n\tif abs(arr[i]-arr[i-1])>temp :\n\t\ttemp=abs(arr[i]-arr[i-1])\n\nif \"A\" in n or \"E\" in n or \"I\" in n or \"O\" in n or \"U\" in n or \"Y\" in n:\n\tif len(arr)==1 :\n\t\tprint(max(arr[0]+1,len(n)-arr[0]))\n\telse :\n\t\tprint(max(temp,arr[0]+1,len(n)-arr[-1]))\nelse :\n\tprint(len(n)+1)\n\t\n"}, {"source_code": "s = 'A' + input() + 'A'\nans = last = 0\nfor i in range(len(s)):\n if s[i] in 'AEIOUY':\n ans = max(ans, i - last)\n last = i\nprint(ans)\n"}, {"source_code": "#list for walks\n\nlist = []\nlist = raw_input().split()\nword = str(list[0])\n\nmin = 0\nnewMin = 0\n\nn = len(word)\nfor i in range(0,n):\n if word[i] == 'A' or word[i] == 'E' or word[i] == 'I' or word[i] == 'O' or word[i] == 'U' or word[i] == 'Y':\n min = max(min,newMin + 1)\n newMin = 0 \n else:\n newMin+=1\n \nprint max(min,newMin+1)\n\n"}, {"source_code": "s = raw_input()\na = filter(lambda (i, e):e in {'A', 'E', 'I', 'O', 'U', 'Y'}, enumerate(s))\nans = max(a[0][0] + 1, len(s) - a[-1][0]) if a else len(s) + 1\nfor i in range(1, len(a)):\n ans = max(ans, a[i][0] - a[i-1][0])\nprint ans"}, {"source_code": "\nn = input()\na = 0\n\nmx = 0\n\nfor i in range(len(n)):\n if n[i] == 'A' or n[i] == 'E' or n[i] == 'I' or n[i] == 'O' or n[i] == 'U' or n[i] == 'Y':\n a = a + 1\n mx = max(mx , a)\n a = 0\n else:\n a = a + 1\n \nmx = max(mx , a + 1)\n \nprint(mx)\n "}, {"source_code": "s=raw_input('')\ns=s+'A'\nmja=1\nmji=-1\nv=['A','E','I','O','U','Y']\nfor i in xrange(0,len(s)):\n if (s[i] in v)==True:\n if mja<(i-mji):\n mja=(i-mji)\n mji=i\nprint mja\n"}, {"source_code": "arr = list(input())\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\ncount = 0\njump = [0]\nfor x in arr:\n if x not in vowels:\n count += 1\n else:\n count += 1\n jump.append(count)\n count = 0\ncount +=1\njump.append(count)\nprint(max(jump))\n"}, {"source_code": "T = 'A' + raw_input() + 'A'\nRa = 0\nMx = 0\nfor X in range(len(T)):\n if T[X] in 'AEIOUY':\n Mx = max(Mx,X-Ra)\n Ra = X\nprint Mx\n\n"}, {"source_code": "s = str(raw_input())+'A'\n\nvowels = ['A','E','I','O','U','Y']\ni = -1\njump = 1\nfor j in range(0,len(s)):\n if not s[j] in vowels:\n continue\n else:\n diff = j-i\n if diff > jump:\n jump = diff\n i = j\n\nprint jump"}], "negative_code": [{"source_code": "s = raw_input()\n\nma = 0\ni = 0\n\nfor c in s:\n i += 1\n if c in \"AEIOU\":\n if i > ma:\n ma = i\n i = 0\n\ni += 1\nif i > ma:\n ma = i\n\nprint ma or len(s) + 1\n"}, {"source_code": "a=input()\nx=\"AEIOUY\"\ny=0\nz=0\nfor i in a:\n if i in x:\n y=0\n else:\n y+=1\n z=max(0,y)\nprint(z+1)"}, {"source_code": "s=input()\ns1=[i for i in range(len(s)) if s[i]==\"A\" or s[i]==\"E\" or s[i]==\"I\" or s[i]==\"O\" or s[i]==\"U\" or s[i]==\"Y\"]\nd=0\nfor i in range(len(s1)-1):\n if s1[i+1]-s1[i]>d:\n d=s1[i+1]-s1[i]\nprint (d )\n"}, {"source_code": "s = [str(x) for x in raw_input().split()]\nvowels = ['A','E','I','O','U']\ni = 0\njump = 1\nfor j in range(1,len(s)):\n if not s[j] in vowels:\n continue\n else:\n diff = j-i\n if diff > jump:\n jump = diff\n i = j\n \nprint jump"}, {"source_code": "def main():\n tmp=raw_input()\n l=tmp.__len__()\n i=0\n ans=0\n while i<l:\n j=i+1\n while j<l and tmp[j]!='A' and tmp[j]!='E' and tmp[j]!='I' and tmp[j]!='O' and tmp[j]!='U' and tmp[j]!='Y':\n j+=1\n ans=max(ans,j-i)\n i=j\n print ans\nmain()"}, {"source_code": "inp = raw_input()\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\njumps = [0]\nfor i in range(0, len(inp)):\n if inp[i] in vowels:\n jumps.append(i+1)\njumps.append(len(inp))\nmax_jump = 0\nfor i in range(0, len(jumps) - 1):\n present, nxt = jumps[i], jumps[i+1]\n max_jump = max(max_jump, (nxt - present))\nprint max_jump\n"}, {"source_code": "n=input()\nl=['A','E','I','O','U','Y']\nv=[]\nfor i in range(len(n)):\n\tif n[i] in l:\n\t\tv.append(i)\nw=[]\nmazx=0\nfor i in range(len(v)-1):\n\tif (v[i+1]-v[i])>mazx:\n\t\tmazx=v[i+1]-v[i]\nif v==[]:\n\tprint(len(n)+1)\nelif v[0]==v[-1]:\n\t print(max(v[0],len(n)-v[0]))\nelse:\n\t\n\tprint(max(mazx,1))\n"}, {"source_code": "# MH RIYAD\n#Daffodil Intl. Univarsity\n\nst=input()\nleng=len(st)\nlast_dis=0\nans=0\n\nfor i in range(0,leng):\n if st[i]=='A' or st[i]=='E' or st[i]=='I' or st[i]=='O' or st[i]=='U' or st[i]=='Y':\n ans=max(ans,(i+1)-last_dis)\n last_dis = i+1\n\nif ans==0:\n print(leng+1)\nelse:\n print(ans)"}, {"source_code": "s=input()\nl=\"AEIOUY\" \nn=len(s)\nb=[]\nm=0\nif(n==1):\n if(s[0] in l):\n print(1)\n else:\n print(2)\nelse:\n for i in range(n):\n if s[i] in l:\n b.append(i)\n a=i\n for i in range(1,len(b)):\n m=max(m,b[i]-b[i-1]) \n m=max(m,b[0]+1)\n m=max(m,n-a)\n print(m)"}, {"source_code": "w = raw_input()\nm = 0\na = 0\nb = 0\nv = [\"A\", \"E\", \"I\", \"O\", \"U\", \"Y\"]\nfor i in range(0, len(w)):\n if w[i] in v:\n a = b\n b = i + 1\n d = b - a\n if d > m:\n m = d\nprint m\n"}, {"source_code": "s = input()\na = ['A', 'E', 'I', 'O', 'U', 'Y']\nk, max = 1, 1\nif len(s)==1:\n print(1 if s[0] in a else 2)\nelse:\n for i in range(len(s)-1):\n if s[i] not in a:\n k+=1\n elif s[i] in a:\n k = 1\n if k>max:\n max = k\n print(max)"}, {"source_code": "st=list(input())\nmaxi=0\nstart=0\nbol=True\nfor x in range(len(st)):\n if st[x] in \"AEIOU\":\n finish=x\n if finish- start > maxi :\n maxi =finish- start\n start = finish\nprint(maxi)\n"}, {"source_code": "l=list(input())\nsadonok=[\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\"]\nx,ans,z=[],[],[]\nif len(l)==1 and l[0] in sadonok:\n print(1)\n exit()\nfor i in range(len(sadonok)):\n z.append(l.count(sadonok[i]))\nif sum(z)==0:\n print(len(l)+1)\nelse:\n for i in range(len(l)):\n for j in range(len(sadonok)):\n if l[i]==sadonok[j]:\n x.append(l.index(l[i]))\n l[i]=\"W\"\n if len(x)==1:\n print(abs((x[0])-len(l)))\n else:\n for i in range(len(x)-1):\n ans.append(abs(x[i]-x[i+1]))\n print(max(ans))\n"}, {"source_code": "import sys\nimport math\n\n#to read string\nget_string = lambda: sys.stdin.readline().strip()\n#to read list of integers\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\n#to read integers\nget_int = lambda: int(sys.stdin.readline())\n\n#--------------------------------WhiteHat010--------------------------------------#\ns = '#'+get_string()\nn = len(s)\nvow = {'A','E','I','O','U','Y'}\ni = j = 0\nm = 0\nwhile j < n:\n if s[j] in vow:\n m = max(m, j-i)\n i = j\n j += 1\n while j < n and s[j] not in vow:\n j += 1\n else:\n j += 1\nprint(m)\n"}, {"source_code": "# import sys \n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out.out\",'w')\ns=input()\nv=[\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\"]\nc=1\nm=0\nfor i in s:\n\tif i in v:\n\t\tc+=1\n\t\tm=max(m,c)\n\t\tc=1\n\telse:\n\t\tc+=1\nm=max(m,c)\nif m==0:\n\tprint(len(s)+1)\nelse:\n\tprint(m)\n\n\n"}, {"source_code": "A = 'a'\nB = raw_input()\nA = A + B\nans = 0\nfor i in xrange(len(A) - 1):\n\tnex = ord(A[i+1]) - 96\n\tcurr = ord(A[i]) - 96\n\tans += min(abs(nex-curr), abs(26-abs(nex-curr)))\nprint ans"}, {"source_code": "str = input()\na = []\ninit = 0\nif len(str) == 1:\n\tif str == 'A' or str == 'E' or str == 'I' or str == 'O' or str == 'U' or str == 'Y':\n\t\ta.extend([1])\n\telse:\n\t\ta.extend([2])\nelse:\n\tfor i in range(len(str)):\n\t\tif str[i] == 'A' or str[i] == 'E' or str[i] == 'I' or str[i] == 'O' or str[i] == 'U' or str[i] == 'Y':\n\t\t\tdiff = i - init\n\t\t\tinit = i\n\t\t\ta.extend([diff])\n\t\telse:\n\t\t\ta.extend([len(str)])\n\nprint(max(a))"}, {"source_code": "def con(s):\n\treturn not(s == 'a' or s == 'e' or s == 'i' or s == 'o' or s == 'u')\ns = input().lower()\nlength = 0\ncur = 0\nfor i in s:\n\tif con(i):\n\t\tcur += 1\n\t\tlength = max(length,cur)\n\telse:\n\t\tcur = 1\nlength = max(length,cur)\nprint(length)\t\t\t"}, {"source_code": "inp=input()\nlst=[0]*len(inp)\nfor i in range(len(inp)):\n if inp[i] in \"AEIUOY\":\n lst[i]=i+1\n\njumps=[]\nlast=current=0\n\nfor i in range(len(lst)):\n if lst[i]!=0:\n current=lst[i]\n jump=current-last\n jumps.append(jump)\n last=current\nif jumps == []:\n print(len(inp)+1)\nelse:\n print(max(jumps))"}, {"source_code": "\ndef fun(c):\n if(c == 'A' or c=='E' or c=='I' or c=='O' or c=='U' or c=='Y'):\n return 0\n else:\n return 1\n \ns = raw_input()\n\nans = 1\ncount = 1\nl = len(s)\n\nfor i in range(1,l):\n if(fun(s[i])):\n count+=1\n else:\n ans = max(ans,count)\n count=1\n\nif(l==1):\n print 0\nelse:\n print ans\n\n\n"}, {"source_code": "#sys.stdout=open(\"output.txt\", 'w')\n#sys.stdout.write(\"Yes\" + '\\n')\n#from sys import stdin\n#input=stdin.readline\n#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])\n# from collections import Counter\n# import sys\n#s=\"abcdefghijklmnopqrstuvwxyz\"\n#arr=sorted([(int(x),i) for i,x in enumerate(input().split())])\n#n=int(input())\n#n,k=map(int,input().split())\n#arr=list(map(int,input().split()))\n#arr=list(map(int,input().split\ns = input()\nst = \"AEIOU\"\nind=0\nm = 0\nfor i in range(len(s)):\n if s[i] in st:\n m = max(m, i-ind)\n ind=i\nprint(m)\n"}, {"source_code": "s = input()\ns = 'A'+s+'A'\nn = [i for i,e in enumerate(s) if e in ['A','E','O','U','I']]\n#print(n)\nfor i in range(len(n)-1):\n n[i] = n[i+1] -n [i]\nprint(max(n[:-1]))"}, {"source_code": "\ndef fun(c):\n if(c == 'A' or c=='E' or c=='I' or c=='O' or c=='U' or c=='Y'):\n return 0\n else:\n return 1\n \ns = raw_input()\n\nans = 1\ncount = 1\nl = len(s)\n\nfor i in range(1,l):\n if(fun(s[i])):\n count+=1\n else:\n ans = max(ans,count)\n count=1\n\n \nprint ans\n\n\n"}, {"source_code": "a = input()\nmaximum = 0\n\nif (\"A\" not in a) and (\"A\" not in a) and (\"A\" not in a) and (\"A\" not in a) and (\"A\" not in a) and (\"A\" not in a):\n print(len(a)+1)\nelse:\n for i in range(len(a)):\n if a[i] in \"AOUIYE\":\n for j in range(i + 1, len(a)):\n if a[j] in \"AOUIYE\":\n if j - i > maximum:\n maximum = j - i\n break\n else:\n if len(a) - i > maximum:\n maximum = len(a) - i\n print(maximum)"}, {"source_code": "l = list(raw_input())\nv = ['A', 'E', 'I', 'O', 'U', 'Y']\nm = 0\nlast = 0\nfor i in range(len(l)):\n\tif l[i] in v: \n\t\tm = max(m, i - last)\n\t\tlast = i\nprint max(m, len(l) - last)"}, {"source_code": "import sys\n\na=sys.stdin.read()\na.strip().replace(\"\\n\",\"\")\nmaxdist=0\na=a+\"A\"\nprint(\"4\")\nfor i in range(len(a)):\n if(a[i] in \"AEIOUY\"):\n for j in range(i+1,len(a)):\n if(a[j] in \"AEIOUY\"):\n print(j,i)\n if((j-i)>maxdist):\n maxdist=j-i\n break\nprint(maxdist)\n#sys.stdout.write(str(maxdist))\n"}, {"source_code": "\n# -*- coding: utf-8 -*-\n# @Date : 2018-10-07 10:32:59\n# @Author : raj lath (oorja.halt@gmail.com)\n# @Link : link\n# @Version : 1.0.0\n\nfrom sys import stdin\n\nmax_val=int(10e12)\nmin_val=int(-10e12)\n\ndef read_int() : return int(stdin.readline())\ndef read_ints() : return [int(x) for x in stdin.readline().split()]\ndef read_str() : return input()\ndef read_strs() : return [x for x in stdin.readline().split()]\n\nstring = read_str()+\" \"\nmaxs = 0\nindx = -1\nfor i, v in enumerate(string):\n if v in \"AIEOUY\":\n maxs = max(i - indx, maxs)\n indx = i\nprint(maxs)\n\n\n\n"}, {"source_code": "n=input()\nm=[]\nc=0\nfor i in n:\n if i=='A' or i=='E' or i=='I' or i=='O' or i=='U':\n m.append(c)\n c=0\n else:\n c=c+1\nm.append(c)\nprint(max(m)+1)\n \n \n"}, {"source_code": "inp=input()\nlst=[0]*len(inp)\nfor i in range(len(inp)):\n if inp[i] in \"AEIUOY\":\n lst[i]=i+1\n\njumps=[0]\nlast=current=0\n\nfor i in range(len(lst)):\n if lst[i]!=0:\n current=lst[i]\n jump=current-last\n jumps.append(jump)\n last=current\nprint(max(jumps))"}, {"source_code": "V = ('A', 'E', 'I', 'O', 'Y')\ns = input()\nj = -1\nmax = 0\nfor i in range(len(s)):\n\tif s[i] in V:\n\t\tif i-j > max:\n\t\t\tmax = i-j\n\t\tj = i\n\tif i == len(s)-1:\n\t\tif len(s)-j > max:\n\t\t\tmax = len(s)-j\nprint(max)"}, {"source_code": "string = input()\nstringToList = list(string)\nvowels = ['A','E','I','O','U','Y']\ncount = 0\njumps = []\n\nfor x in stringToList:\n count+=1\n if x in vowels:\n jumps.append(count)\n count = 0\n else:\n jumps.append(0)\nprint (max(jumps))\n\n\n"}, {"source_code": "paper=input()\nposition=[]\nvowels=[\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\"]\nfor i in paper:\n if i in vowels:\n position.append(1)\n else:\n position.append(0)\n\njump_ability=0\ncount=0\n\nfor i in position:\n if i==0:\n count +=1\n if i==1:\n count+=1\n if count>jump_ability:\n jump_ability= count\n count = 0 \n \nif count>jump_ability:\n jump_ability=count+1\nif len(position)==1 and paper[0] not in vowels:\n jump_ability=2\n \nprint (jump_ability)"}, {"source_code": "import sys\ninp = raw_input();\nlist = [];\nfor i in range(len(inp)):\n if(inp[i]=='A' or inp[i]=='E' or inp[i]=='I' or inp[i]=='O' or inp[i]=='U'):\n list.append(int(i));\nmn = 1;\n#print list;\nfor i in range (len(list)-1):\n mn = max(mn,abs(list[i+1]-list[i]));\n\nprint mn;"}, {"source_code": "a = input()\na = a.strip()\nl = len(a)\ns = set('AEIOUY')\npre = -1\nMax = 0\nfor i in range(l):\n if a[i] in s:\n temp = i - pre\n pre = i\n if Max < temp:\n Max = temp\nprint(Max)"}, {"source_code": "import re\nans = re.findall('[AEIOUY][^AEIOUY]*',raw_input(\"\"))\nmmax = -1\nfor i in ans:\n mmax = max(mmax, len(i))\nprint mmax\n"}, {"source_code": "a=input()\nvowels=['A','E','I','O','U','Y']\nif a[0] in vowels:\n mx=0\n b=0\n for i in range (len(a)):\n if a[i] in vowels:\n mx=max(abs(b-i),mx)\n #print(abs(b-i))\n b=i\n if (len(a)-1)-b>mx:\n mx=(len(a)-1)-b\n \nelse:\n for i in range (len(a)):\n if a[i] in vowels:\n mx=i+1\n break\n b=0\n for i in range (len(a)):\n if a[i] in vowels:\n mx=max(abs(b-i),mx)\n #print(abs(b-i))\n b=i \n if (len(a)-1)-b>mx:\n mx=len(a)-b\n\nprint (mx)"}, {"source_code": "n=input()\na=n.lower()\nl=[0]\nfor i in range(len(n)):\n if a[i]=='a' or a[i]=='e' or a[i]=='i' or a[i]=='o' or a[i]=='u':\n l.append(i+1)\n\nl.append(len(n)+1)\n#print(l)\nres=[]\nfor i in range(len(l)-1):\n res.append(l[i+1]-l[i])\nprint(max(res))"}, {"source_code": "s=str(input())\nlist1=['A','E','I','O','U']\nm=0\nc=-100000\nfor i in range(len(s)):\n if s[i] in list1:\n if c<0:\n c=i\n m=i+1\n else:\n if i-c>m:\n m=i-c\n #print(i-c,m)\n c=i\nif c==-100000:\n print(len(s))\nelse:\n print(max(m,len(s)-1-c))"}, {"source_code": "x=input()\na=[]\nb=[]\nfor i in range(len(x)):\n if x[i] in ['A','E','I','O','U','Y']:\n a.append(i)\n\nif len(a)==0:\n print(0)\nelse:\n a.append(len(x)-1)\n for i in range(len(a)-1):\n t=a[i+1]-a[i]\n b.append(t)\n print(max((max(b),1)))\n\n\n"}, {"source_code": "vowels = ['A', 'E', 'I', 'O', 'U', 'Y']\ns = 'TXXXX'\npos = -1\nmax_jump_size = 0\nwhile pos < len(s):\n\tis_vowel_ahead = False\n\tfor pos1 in range(pos+1, len(s)):\n\t\tif s[pos1] in vowels:\n\t\t\tjump_size = pos1 - pos\n\t\t\tmax_jump_size = max(max_jump_size, jump_size)\n\t\t\tpos = pos1\n\t\t\tis_vowel_ahead = True\n\t\t\tbreak\n\n\tif not is_vowel_ahead:\n\t\tbreak\nif pos == -1:\n\tmax_jump_size = 0\nelse:\t\t\t\n\tmax_jump_size = max(max_jump_size, len(s)-pos)\n\nprint max_jump_size"}, {"source_code": "s= input()\nm=0\nt=0\nif 'A' not in s and 'E' not in s and 'I' not in s and 'O' not in s and 'U' not in s and 'Y' not in s:\n print(len(s)+1)\nelse: \n for i in range(len(s)):\n if s[i]=='A' or s[i]=='E' or s[i]=='I' or s[i]=='O' or s[i]=='U' or s[i]=='Y':\n m= max(m, i+1-t)\n t=i+1\n \n print(m)"}, {"source_code": "#!/usr/bin/env python3\ns = 'A' + input('') + 'A'\n\nlast = 0\nmaxJump = 0\n\nfor i, x in enumerate(s):\n if x in ['A', 'E', 'I', 'O', 'U']:\n maxJump = max(maxJump, i-last)\n last = i\n\nprint(maxJump)\n"}, {"source_code": "s=list(input())\nmax=1\np_pos=0\ncount=0\nv=['A','E','I','O','U','Y']\nfor i in range(len(s)):\n if s[i] in v:\n c_pos=i\n j_l=c_pos-p_pos\n p_pos=i\n if j_l>max:\n max=j_l\nif count>0:\n print(len(s)+1)\nelse:\n print(max) "}, {"source_code": "data = input()\n\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n\nfirst = 0\nsecond = 0\nmy_max = 0\nfor index, letter in enumerate(data):\n\tif letter in vowels:\n\t\tfirst = second\n\t\tsecond = index + 1\n\t\tif my_max < second - first:\n\t\t\tmy_max = second - first\n\nprint(my_max)\n"}, {"source_code": "grass = input()\nlast = -1\nmn=0\nfor i in range(0,len(grass) -1):\n #print(i)\n if (['A','E','I','O','U']).count(grass[i])>0:\n # print(i)\n if mn<i-last:\n mn=i-last\n last=i\n\nif mn<len(grass)-last:\n mn = len(grass) - last\n\nprint(mn)"}, {"source_code": "def isVowel( char ):\n vowels = [ 'A', 'E', 'I', 'O', 'U', 'Y' ]\n if char in vowels:\n return True\n else:\n return False\n\ndef main():\n inpstr = raw_input()\n ans = 0\n tmpans = 0\n for c in inpstr:\n tmpans = tmpans + 1\n if isVowel( c ):\n ans = max( ans, tmpans )\n tmpans = 0\n ans = max( ans, tmpans )\n print ans \n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "# python2\nimport sys, threading, os.path\nimport collections, heapq, math,bisect\n\nsys.setrecursionlimit(10**6) # max depth of recursion\nthreading.stack_size(2**27)\n\ndef main():\n if os.path.exists('input.txt'):\n input = open('input.txt', 'r')\n else:\n input = sys.stdin\n #--------------------------------INPUT---------------------------------\n s = str(input.readline())\n vowls = ['A', 'E', 'I', 'O', 'U', 'Y']\n indexes = set()\n indexes.add(0)\n indexes.add(len(s))\n for i,x in enumerate(s):\n for y in vowls:\n if x == y:\n indexes.add(i)\n maxone = 0\n if len(indexes) <= 2:\n output = 0\n else:\n res = list(indexes)\n maxone = 0\n for i in range(1,len(res)):\n maxone= max(maxone,res[i]-res[i-1])\n output = maxone\n #-------------------------------OUTPUT----------------------------------\n if os.path.exists('output.txt'):\n open('output.txt', 'w').writelines(str(output))\n else:\n sys.stdout.write(str(output))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "t = input()\nd = {\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\"}\nz = 0\nt1 = 0\nk = 1\nfor i in range(len(t)):\n\tif t[i] in d:\n\t\tk = k + 1\n\t\tz = max(z,k)\n\t\tk = 1\n\telse:\n\t\tk = k + 1\n\tz = max(z,k)\nprint(z)"}, {"source_code": "S=input()\nk=1\nl=[k]\nfor i in range(len(S)-1) :\n if S[i+1]!='A' and S[i+1]!='E' and S[i+1]!='I' and S[i+1]!='O' and S[i+1]!='U' and S[i+1]!='Y':\n k=k+1\n l.append(k)\n else:\n k=1\nif len(S)==1:\n print(2)\nelse :\n print(max(l))\n"}, {"source_code": "x=input()\np=[\"A\",\"E\",\"I\",\"O\",\"Y\"]\nl=1\nk=0\nfor i in range(len(x)):\n\tif x[i] in p:\n\t\tl=max(l,(i+1)-k)\n\t\tk=i+1\nprint(l)"}, {"source_code": "a=input()\nx=\"AEIOUY\"\ny=0\nfor i in a:\n if i in x:\n y=0\n else:\n y+=1\n z=max(0,y)\nprint(z+1)"}, {"source_code": "inp=input()\nlst=[0]*len(inp)\nfor i in range(len(inp)):\n if inp[i] in \"AEIUOY\":\n lst[i]=i+1\n \njumps=[]\nlast=0\n \nfor i in range(len(lst)):\n if lst[i]!=0:\n jump=lst[i]-last\n jumps.append(jump)\n last=lst[i]\nprint(jumps)\njumps.append(len(inp)-last+1)\nif jumps == []:\n print(len(inp)+1)\nelse:\n print(max(jumps))"}, {"source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(2*10**4)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\ns=sin()\nvow=[\"A\",\"E\",\"I\",\"O\",\"U\"]\nc=0\nans=0\nfor i in s:\n if i in vow:\n ans=max(ans,c+1)\n c=0\n else: c+=1\nprint max(c+1,ans)"}, {"source_code": "import sys,math\n\ns= raw_input()\nvowel = ['A','E','I','O','U','Y']\npos = 0\nans=0\nfor i in xrange(len(s)):\n\tif s[i] in vowel:\n\t\tans=max(ans,i-pos)\n\t\tpos=i\nans=max(ans,len(s)-pos)\nprint ans"}, {"source_code": "a = input()\nfirst = 0\nsecond = 0\nmaximum = 0\n\nfor i in range(len(a)):\n if a[i] in \"AUIOYE\" or i == len(a)-1:\n first = second\n second = i\n if maximum <= second - first:\n maximum = second - first\nprint(maximum)"}, {"source_code": "s=raw_input()\nvowels= 'AEIOUY'\ndef check(s):\n if len(s) == 1 and s not in vowels:\n return 2\n for ch in s:\n if ch not in vowels:\n s=s.replace(ch,' ')\n previous = ''\n count =1\n Max=1\n for ch in s:\n if previous ==' ':\n count+=1\n previous =ch\n if count > Max:\n Max=count\n else:\n count=1\n previous =ch\n for i in range (len(s)-1,-1,-1):\n if s[i] in vowels:\n if (1+len(s)-i)>Max:\n Max=1+len(s)-i\n break\n else:\n break\n return Max\nprint check(s)\n \n \n \n"}, {"source_code": "s = list(input())\nk = len(s)\nfor i in s:\n if i != 'A' or 'E' or 'I' or 'O' or 'U' or 'Y':\n s.remove(i)\nprint(k - len(s))"}, {"source_code": "from functools import reduce\narr = list(input())\n\nvowels = list([i for i in range(len(arr)) if arr[i] == 'A' or arr[i] == 'E' or arr[i] == 'I' or arr[i] == 'O' or arr[i] == 'U'])\n\nif len(vowels) != 0:\n\tdist = []\n\tdist.append(vowels[0] + 1)\n\tfor i in range(len(vowels) - 1):\n\t\tdist.append(vowels[i + 1] - vowels[i])\n\tdist.append(len(arr) - vowels[len(vowels) - 1])\n\tprint(reduce(max, dist))\nelse:\n\tprint(len(arr) + 1)"}, {"source_code": "s = list(input())\nk = len(s)\nfor i in s:\n if i != 'A' or 'E' or 'I' or 'O' or 'U' or 'Y':\n s.remove(i)\nprint(k - len(s))"}, {"source_code": "s = raw_input()\nja = 0\nja_max = -1\nfor ch in s:\n\tif ch == 'A' or ch == 'E' or ch == 'I' or ch == 'O' or ch == 'U' or ch == 'Y':\n\t\tja += 1\n\t\tja_max = max(ja_max,ja);\n\t\tja = 0\n\telse:\n\t\tja += 1\nif ja_max == -1:\n\tja_max = len(s)+1\nprint ja_max"}, {"source_code": "s = raw_input()\nmx = 1\nfor i in range(0,len(s)-1):\n\tif s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'Y':\n\t\tfor j in range(i+1,len(s)):\n\t\t\tif s[j] == 'A' or s[j] == 'E' or s[j] == 'I' or s[j] == 'O' or s[j] == 'Y':\n\t\t\t\tmx = max(mx,j-i)\n\t\t\t\tbreak\n\nprint(mx)"}, {"source_code": "s = input()\n\nl = list()\nmaxs = 0\n\nfor i in range(len(s)):\n if s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'U':\n l.append(i)\n\nfor j in range(1, len(l)):\n if l[j] - l[j-1] > maxs:\n maxs = l[j] - l[j-1]\n\nif maxs > l[0] - (-1):\n maxs = l[0] - (-1)\n\nprint(maxs)"}, {"source_code": "s = raw_input()\nmx = 0\na = []\na.append(0)\nfor i in range(0,len(s)):\n\tif (s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'Y' or s[i]=='U'):\n\t\ta.append(i+1)\n\na.append(len(s))\n\nfor i in range(1,len(a)):\n\tmx = max(mx,a[i]-a[i-1])\nprint(mx)"}, {"source_code": "t=input()\n\nv=[ 'A', 'E', 'I', 'O', 'U','Y']\n\n\na=0\ns=0\nif len(t)==1:\n if t[0] in v:\n print(1)\nelse:\n for j in range(len(t)):\n if t[j] in v:\n if j-s > a:\n a=j-s\n s=j\n else:\n s=j\n\n print(a)\n"}, {"source_code": "word = input()\n\npositions = [i for i in range(len(word)) if word[i] in \"AEIOUY\"]\n\nif len(positions) <= 1 :\n print(len(positions))\n\nelse :\n jumps = [positions[i] - positions[i - 1] for i in range(1 , len(positions))]\n print(max(jumps))\n"}, {"source_code": "s=raw_input()\npre=-1\nans=0\nfor i in xrange(len(s)):\n if s[i] in \"AEIOUY\":\n ans=max(ans,i-pre)\n pre=i\nif s[-1] not in \"AEIOUY\" and ans==1:\n ans=max(2,ans)\nif ans==0:\n ans=len(s)+1\nprint ans"}, {"source_code": "s = input()\na = ['A', 'E', 'I', 'O', 'U', 'Y']\nk, max = 1, 1\nfor i in range(len(s)-1):\n if s[i] not in a:\n k+=1\n elif s[i] in a:\n k = 1\n if k>max:\n max = k\nprint(max)"}, {"source_code": "#!/usr/bin/env python3\ns = input('')\n\nlast = 0\nmaxJump = 0\n\nfor i, x in enumerate(s):\n if x in ['A', 'E', 'I', 'O', 'U']:\n maxJump = max(maxJump, i-last)\n last = i\n\nif last != len(s) - 1:\n maxJump = max(maxJump, len(s) - last)\n\nprint(maxJump)\n"}, {"source_code": "string = input()\nvowels, maxJump = [], 0\nstring = 'A'+string+'A'\nfor x in range(len(string)):\n if string[x] in 'AEIOU':\n vowels.append(x)\nfor x in range(len(vowels)-1):\n jump = vowels[x+1] - vowels[x]\n if jump > maxJump:\n maxJump = jump \nprint(maxJump)\n"}, {"source_code": "t = input()\nd = {\"A\",\"E\",\"I\",\"O\",\"U\",\"Y\"}\nz = 0\nt1 = 0\nk = 1\nfor i in range(len(t)):\n\tif t[i] in d:\n\t\tk = k + 1\n\t\tz = max(z,k)\n\t\tk = 1\n\telse:\n\t\tk = k + 1\n\tz = max(z,k)\nprint(z)"}, {"source_code": "import sys\n\na=sys.stdin.read()\na.strip().replace(\"\\n\",\"\")\nmaxdist=0\na=a+\"A\"\nprint(\"4\")\nfor i in range(len(a)):\n if(a[i] in \"AEIOUY\"):\n for j in range(i+1,len(a)):\n if(a[j] in \"AEIOUY\"):\n print(j,i)\n if((j-i)>maxdist):\n maxdist=j-i\n break\nprint(maxdist)\n#sys.stdout.write(str(maxdist))\n"}, {"source_code": "s=input()\nl=[]\nfor i in range(len(s)):\n\tif(s[i]=='A' or s[i]=='E' or s[i]=='I' or s[i]=='O' or s[i]=='U'):\n\t\tl.append(i)\nif(len(l)<=1):\n\tprint(2-len(l))\nelse:\t\n\tl2=[]\n\tfor i in range(len(l)-1):\n\t\tl2.append(l[i+1]-l[i])\n\tprint(max(l2))"}, {"source_code": "def minjump(s):\n\tl = len(s)\n\ti= 0\n\tj = 0\n\tmax = 1\n\twhile j<len(s):\n\t\tif s[j] in 'AEIOU':\n\t\t\tjump = j-i\n\t\t\tif jump>max:\n\t\t\t\tmax = jump\n\t\t\ti = j\n\t\tj = j+1\n\tif max< (l-i-1):\n\t\tmax = l-i-1\n\treturn max\n\ntxt = 'A'+raw_input()+'Z'\nprint minjump(txt)\n\t\n\t\t\t\n\t\t"}, {"source_code": "a = input()\ncount, ans = 1, 1\nfor b in a:\n if b not in 'AEIOUY':\n count += 1\n ans = count if count > ans else ans\nprint(ans)"}, {"source_code": "S=input()\nk=1\nl=[k]\nfor i in range(len(S)-1) :\n if S[i+1]!='A' and S[i+1]!='E' and S[i+1]!='I' and S[i+1]!='O' and S[i+1]!='U' and S[i+1]!='Y':\n k=k+1\n l.append(k)\n else:\n k=1\nif len(S)==1 and S[0]!='A' and S[0]!='E' and S[0]!='I' and S[0]!='O' and S[0]!='U' and S[0]!='Y':\n print(2)\nelse :\n print(max(l))\n"}, {"source_code": "string = input()\nletters = ['A', 'E', 'I', 'O', 'U', 'Y']\na = [i for i in string]\nnumbers = []\nfor c in a:\n if c in letters:\n numbers.append(a.index(c))\n a[a.index(c)] = 1\nnumbers2 = []\nif len(numbers) > 1:\n for elem in numbers[1:]:\n numbers2.append(elem - numbers[numbers.index(elem) - 1])\nelse:\n numbers2.append(numbers[0])\nprint(max(numbers2))"}, {"source_code": "s = raw_input()\n\nma = 0\ni = 0\n\nfor c in s:\n i += 1\n if c in \"AEIOU\":\n if i > ma:\n ma = i\n i = 0\n\ni += 1\nif i > ma:\n ma = i\n\nprint ma or len(s) + 1\n"}, {"source_code": "#sys.stdout=open(\"output.txt\", 'w')\n#sys.stdout.write(\"Yes\" + '\\n')\n#from sys import stdin\n#input=stdin.readline\n#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])\n# from collections import Counter\n# import sys\n#s=\"abcdefghijklmnopqrstuvwxyz\"\n#arr=sorted([(int(x),i) for i,x in enumerate(input().split())])\n#n=int(input())\n#n,k=map(int,input().split())\n#arr=list(map(int,input().split()))\n#arr=list(map(int,input().split\ns = input()\nst = \"AEIOU\"\nind=0\nm=0\nfor i in range(len(s)):\n if s[i] in st:\n if m==0:\n m=i+1\n m = max(m, i-ind)\n ind=i\n #print(ind)\n\n\nprint(max(m,len(s)-ind))\n"}, {"source_code": "s = str(input())\nlast = -1\njump = 0\nglas = ['A', 'E', 'I', 'O', 'U', 'Y']\nfor i in range(len(s)):\n\tif s[i] in glas:\n\t\tjump = max(i - last, jump)\n\t\tlast = i\nif jump == 0:\n\tjump = len(s) + 1\nprint(jump)"}, {"source_code": "a = input()\ncount, ans = 1, 1\nfor b in a:\n if b not in 'AEIOUY':\n count += 1\n ans = count if count > ans else ans\nprint(ans)"}, {"source_code": "import sys\ns = sys.stdin.readline()[:-1]\nvowels = list('AEIOUY')\njump = 0\nnow = -1\nfor i, c in enumerate(s):\n if c in vowels:\n dist = i-now\n jump = dist if dist > jump else jump\n now = i\nif now != len(s)-1:\n dist = len(s)-1-now\n jump = dist if dist > jump else jump\nsys.stdout.write(str(jump))\n"}, {"source_code": "s = input()\nG = ('A', 'E', 'I', 'O', 'U', 'Y')\nminL = 0\nLL = len(s)\nk = 0\nL = 0\nR = LL\nfor i in range(LL):\n if s[i] in G:\n k += 1\n if k == 1:\n L = i\n else:\n R = i\n minL = max(minL, R - L)\n k = 0\n\nminL = max(minL, LL - R)\nprint(minL-1)"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\nans = 0\npr = -1\nb = 'AEIOU'\nl = len(a)\nfor ii in xrange(l):\n i = a[ii]\n if i in b:\n cur = ii-pr\n if cur > ans:\n ans = cur\n pr = ii\nprint ans"}, {"source_code": "s=raw_input()\npre=-1\nans=0\nfor i in xrange(len(s)):\n if s[i] in \"AEIOU\":\n ans=max(ans,i-pre)\n pre=i\nif ans==0:\n ans=len(s)+1\nprint ans"}, {"source_code": "string = input()\n\nlst = []\n\nfor i in range(len(string)):\n if string[i] in 'AEOUIY':\n lst.append(i)\n\n\nlst = sorted(lst)\nlst2 = []\nfor i in range(len(lst)-1):\n lst2.append(abs(lst[i]-lst[i+1]))\n\nlst2.append(lst[0])\nlst2.append(len(string)-lst[len(lst)-1]-1)\n\nprint(max(lst2))\n\n\n"}, {"source_code": "s = '0'+input()+'1'\nl = 'AEIOUY'\ni, k, mx, p = 0, 0, 0, 0\nwhile i<len(s):\n if s[i] in l:\n k=(i-p)\n p = i\n if mx<k:\n mx = k\n i+=1\nprint(mx)\n "}, {"source_code": "s = input()\nk = \" \" + s + \" \" \narr = ['A','E','I','O','U','Y',' ']\nans = -1\ni = 0\nc = 0\nn = len(k)\n# print(n)\nwhile(i<n):\n # if(s[i] not in arr):\n if(k[i] in arr):\n i+=1\n ans = max(c,ans)\n c = 1\n else:\n while i<n and k[i] not in arr:\n c+=1\n i+=1\n\nprint(ans-1)"}, {"source_code": "\n#########\t\t\t##\t## ## \t #### ##### ## # ## #\t\t##\n\t#\t\t\t # #\t# # # #\t\t #\t #\t#\t# # # # # # #\t # #\n\t#\t\t\t # #\t# ### #\t #\t\t#\t# # # # # # #\t # #\n\t#\t\t\t #####\t#\t#\t#\t # ###\t#\t# # # # # # # #####\n\t#\t\t\t# #\t#\t\t#\t # # #\t#\t# #\t# # #\t # # # # \n######### \t # # \t#\t\t#\t\t##### #\t##### #\t ## #\t ## # #\n\n\"\"\"\n\nPPPPPPP RRRRRRR\t\t OOOO\t VV VV EEEEEEEEEE\nPPPPPPPP RRRRRRRR OOOOOO VV VV\t EE\nPPPPPPPPP RRRRRRRRR OOOOOOOO VV VV\t EE\nPPPPPPPP RRRRRRRR OOOOOOOO VV VV \t EEEEEE\nPPPPPPP RRRRRRR OOOOOOOO VV VV EEEEEEE\nPP \t\t RRRR\t\t\t OOOOOOOO VV VV EEEEEE\nPP\t\t\t RR RR OOOOOOOO VV VV EE\nPP\t\t\t RR RR OOOOOO VV VV EE\nPP\t\t\t RR RR OOOO VVVV EEEEEEEEEE\n\n\"\"\"\n\n\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nimport sys\ninput = sys.stdin.readline\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k; \n res = 1;\n for i in range(k): \n res = res * (n - i);\n res = res / (i + 1); \n return int(res);\n \n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0, hi = None):\n if hi == None:\n hi = len(a);\n while lo < hi:\n mid = (lo+hi)//2;\n if a[mid] < x:\n lo = mid+1;\n else:\n hi = mid;\n return lo;\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret;\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\n\ndef solve():\n\ts = input().lower()\n\tj = 0\n\tm = 0\n\tfor i in range(1, len(s) + 1):\n\t\tif s[i - 1] in \"aeiou\":\n\t\t\tm = max(m, abs(i - j))\n\t\t\tj = i\n\tif m == 0:\n\t\tprint(len(s))\n\t\treturn\n\tprint(m)\n\n\n\nif __name__ == '__main__':\n\tfor _ in range(1):\n\t\tsolve()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n "}, {"source_code": "str = input()\na = []\ninit = 0\nfor i in range(len(str)):\n\tif str[i] == 'A' or str[i] == 'E' or str[i] == 'I' or str[i] == 'O' or str[i] == 'U' or str[i] == 'Y':\n\t\tdiff = i - init\n\t\tinit = i\n\t\ta.extend([diff])\n\nprint(max(a))"}, {"source_code": "# #\n# CodeForces\n# Problem 733A\n# Python 2\n# #\n\nVOWELS = ['A', 'E', 'Y', 'U', 'I', 'O']\n\njump_len = 1\ncurrent_len = 1\n\nfor char in raw_input():\n if not char in VOWELS:\n current_len += 1\n else:\n if current_len > jump_len:\n jump_len = current_len\n current_len = 1\n\nif current_len > jump_len:\n jump_len = current_len\n\nprint jump_len\n"}, {"source_code": "a=input()\nl=[]\nn=len(a)\nif len(a)==1:\n if a=='A' or a=='E' or a=='I' or a=='O' or a=='U' or a=='Y':\n print(1)\n else :print(2)\nelse:\n for i in range(n):\n if a[i] == 'A' or a[i] == 'E' or a[i] == 'I' or a[i] == 'O' or a[i] == 'U' or a[i] == 'Y':\n l.append(i)\n if len(l)==1:\n print(max(l[0],n-l[0]))\n\n elif len(l)==0:print(n+1)\n else:\n m=1\n for i in range(len(l)-1):\n m=max(l[i+1]-l[i],m)\n print(m)\n #if a[i]=='A' or a[i]=='E'or a[i]=='I' or a[i]=='O' or a[i]=='U' or a[i]=='Y':\n"}, {"source_code": "st=list(input())\nmaxi=0\nstart=0\nbol=True\nfor x in range(len(st)):\n if st[x] in \"AEIOU\":\n finish=x\n if finish- start > maxi :\n maxi =finish- start\n start = finish\nprint(maxi)\n"}, {"source_code": "st = raw_input()\nvowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n\ni = 0\nwhile i < len(st):\n if st[i] in vowels:\n prev = i\n break\n i += 1\n\n\nmax_jump = i + 1\nprev, cur = i, i + 1\n\nwhile prev < len(st) and cur < len(st):\n if st[cur] in vowels:\n max_jump = max(cur-prev, max_jump)\n prev = cur\n cur += 1\n\nprint max_jump"}, {"source_code": "# #\n# CodeForces\n# Problem 733A\n# Python 2\n# #\n\nVOWELS = ['A', 'E', 'Y', 'U', 'I', 'O']\n\njump_len = 1\ncurrent_len = 1\n\nfor char in raw_input():\n if not char in VOWELS:\n current_len += 1\n else:\n if current_len > jump_len:\n jump_len = current_len\n current_len = 1\n\nif current_len > jump_len:\n jump_len = current_len\n\nprint jump_len\n"}, {"source_code": "# python2\nimport sys, threading, os.path\nimport collections, heapq, math,bisect\n\nsys.setrecursionlimit(10**6) # max depth of recursion\nthreading.stack_size(2**27)\n\ndef main():\n if os.path.exists('input.txt'):\n input = open('input.txt', 'r')\n else:\n input = sys.stdin\n #--------------------------------INPUT---------------------------------\n s = str(input.readline())\n vowels = ['A', 'E', 'I', 'O', 'U', 'Y']\n indexes = []\n current,sol=1,0\n maxone=0\n for i in range(len(s)):\n vowel = False\n for x in vowels:\n if x == s[i]:\n vowel = True\n break\n if vowel:\n sol = max(current,sol)\n current=1\n else:\n current+=1\n\n sol = max(current,sol)\n output = sol\n #-------------------------------OUTPUT----------------------------------\n if os.path.exists('output.txt'):\n open('output.txt', 'w').writelines(str(output))\n else:\n sys.stdout.write(str(output))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "s = raw_input()\nmx = 0\na = []\na.append(0)\nfor i in range(0,len(s)):\n\tif (s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'Y'):\n\t\ta.append(i+1)\n\na.append(len(s))\n\nfor i in range(1,len(a)):\n\tmx = max(mx,a[i]-a[i-1])\nprint(mx)"}, {"source_code": "S=input()\nk=1\nl=[k]\nfor i in range(len(S)-1) :\n if S[i+1]!='A' and S[i+1]!='E' and S[i+1]!='I' and S[i+1]!='O' and S[i+1]!='U' and S[i+1]!='Y':\n k=k+1\n l.append(k)\n else:\n k=1\nif len(S)==1 and S[0]!='A' and S[0]!='E' and S[0]!='I' and S[0]!='O' and S[0]!='U' and S[0]!='Y':\n print(max(l)+1)\nelif S=='KMLPTGFHNBVCDRFGHNMBVXWSQFDCVBNHTJKLPMNFVCKMLPTGFHNBVCDRFGHNMBVXWSQFDCVBNHTJKLPMNFVC':\n print(85)\nelse :\n print(max(l))\n"}, {"source_code": "vowels = 'AEIOUY'\ns = list(input())\ncounter = 0\nans = 0\nif len(s) > 1:\n for i in range(len(s)):\n if s[i] in vowels and counter >= ans:\n ans = counter\n counter = 0\n continue\n\n counter += 1\n if counter > ans:\n ans = counter\n print(ans + 1)\nelse:\n if s[0] in vowels:\n print(1)\n else:\n print(2)\n"}, {"source_code": "s = input()\nglas = [\"A\", \"E\", \"I\", \"O\", \"U\", \"Y\"]\nprev = 0\nresult = 0\nfor i in range(len(s)):\n if s[i] in glas:\n result = max(i - prev, result)\n prev = i\nprint(result)\n"}, {"source_code": "def jump (s) :\n abi = 0\n j = 0\n for x in range(len(s)):\n if s[x] == \"A\" or s[x] == \"E\" or s[x] == \"I\" or s[x] == \"O\" or s[x] == \"U\":\n j += 1\n if j > abi :\n abi = j\n j = 0\n else:\n j += 1\n return abi\n\n\nprint (jump(input()))\n"}], "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee"} {"source_code": "[n,a,b]=[int(x)-1 for x in input().split()]\nres=0\nwhile a!=b:\n a//=2\n b//=2\n res+=1\nif 2**res==n+1:\n res=\"Final!\"\nprint(res)", "positive_code": [{"source_code": "import math\nn, a, b = [int(el) for el in input().split()]\nm=int(math.log(n,2))\nfor i in range(1, m+1):\n if (a-1)//(2**i) == (b-1)//(2**i):\n if i == m:\n print('Final!')\n else:\n print(i)\n break"}, {"source_code": "n,a,b=map(int,raw_input().split())\na-=1\nb-=1\nc=1\nwhile n>2:\n a/=2\n b/=2\n n/=2\n if a==b:\n print c\n break\n c+=1\nelse:\n print 'Final!'"}, {"source_code": "import base64\nimport zlib\ns=\"\"\"eJxtkE2OwyAMhfc+hbsCqkz6t4vEtpcYzYKoJLKUOggTaXr7cYcm6qLePGzeZ56ge5pzwTGWFESA\naisPAbjFfhnR4zVMEgFoQDNPj3sy6P0KtKqLxGxdB6ilYCvlRqzcnCJbU6KUltg4eG4cMFNYzVnZ\nzPhNXCw5HOaMhIoSp6VY10qaSPVHSW4wNNjr1n8eAn55PEFfZSNz4DHaU3M5vp7Q0OFwsOf9npz3\n/Xqsly9DHe08d7CNn5VyDbYNo/5D98FirsRh2pk3568GPzr4A0+bXMk=\n\"\"\"\nexec(zlib.decompress(base64.decodebytes(s.encode())).decode())\n\n"}, {"source_code": "read = lambda: map(int, input().split())\nn, a, b = read()\ncnt = 0\na += n - 1\nb += n - 1\nwhile a != b:\n a //= 2\n b //= 2\n cnt += 1\nif 2 ** cnt == n:\n print(\"Final!\")\nelse:\n print(cnt)"}, {"source_code": "n, a, b = map(int, input().split())\narr = [i + 1 for i in range(n)]\nstage = 1\nwhile len(arr) > 1:\n\tna = []\n\tfor i in range(len(arr) // 2):\n\t\tif arr[i * 2] == a and arr[i * 2 + 1] == b:\n\t\t\tprint('Final!' if len(arr) == 2 else stage)\n\t\t\texit()\n\t\telif arr[i * 2] == b and arr[i * 2 + 1] == a:\n\t\t\tprint('Final!' if len(arr) == 2 else stage)\n\t\t\texit()\n\t\telif arr[i * 2] == a or arr[i * 2] == b:\n\t\t\tna.append(arr[i * 2])\n\t\telif arr[i * 2 + 1] == a or arr[i * 2 + 1] == b:\n\t\t\tna.append(arr[i * 2 + 1])\n\t\telse:\n\t\t\tna.append(arr[i * 2])\n\tarr = na[:]\n\tstage += 1"}, {"source_code": "n,a,b=map(int,input().split())\n\na,b,r=a-1,b-1,0\n\nwhile a!=b:\n\n a//=2\n\n b//=2\n\n r+=1\n\nprint(r if 2**r<n else 'Final!')\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "a, b, c = input().split(' ')\na, b, c = int(a), int(b), int (c)\nh = 0\nf = 1\nwhile (a > 1):\n h += 1\n a = a // 2\n if b > a and c > a:\n b -= a\n c -= a\n if f == 1 and((b <= a and c > a) or (b > a and c <= a)):\n g = h - 1\n f = 0\nif g == 0:\n print(\"Final!\")\nelse:\n print(h - g)\n \n\n\n\n\n"}, {"source_code": "n, a, b = map(int, input().split())\nif a > b:\n a, b = b, a\nr = 1\nwhile 2 ** r < n:\n r += 1\nleft = 1\nright = n\nans = r\nmid = (left + right) // 2\nwhile not (a <= mid and b > mid):\n ans -= 1\n if b <= mid:\n right = mid\n else:\n left = mid + 1\n mid = (left + right) // 2\nif ans == r:\n print('Final!')\nelse:\n print(ans)"}, {"source_code": "import math,sys\n\nn,a,b = list(map(int,input().split()))\n\nlow = 1\nhigh = n\ns = int(math.log(n,2))\n\nwhile low + 0.5 < high: \n if (high + low) % 2 == 0:\n mid = (high + low + 1) / 2\n else:\n mid = (high + low) / 2\n\n if min(a,b) < mid and max(a,b) > mid:\n break\n if min(a,b) >= mid:\n low = int(mid)\n elif max(a,b) <= mid:\n high = int(mid)\n \n s -= 1\n\nif s == int(math.log(n,2)): \n print(\"Final!\")\nelse:\n print(s)\n"}, {"source_code": "from sys import stdin\nn,a,b = map(int,stdin.readline().split())\nrnd = 1\na-=1\nb-=1\nm = 0\nwhile True:\n if (1<<m)==n:\n break\n m += 1\nm+=1\nwhile n:\n x = n & a\n y = n & b\n if x!=y:\n break\n n/=2\n rnd+=1\n\nrnd = m +1 - rnd\nif rnd==m-1:\n print \"Final!\"\nelse:\n print rnd"}, {"source_code": "from math import log\n\nn, a, b = map(int, input().split())\na -= 1\nb -= 1\nc = int(log(n, 2))\nfor i in range(c):\n if a // 2 == b // 2:\n break\n else:\n a //= 2\n b //= 2\nif i == c - 1:\n print('Final!')\nelse:\n print(i + 1)"}, {"source_code": "def solution():\n n, a, b = map(int, raw_input().strip().split())\n a, b = min(a, b), max(a, b)\n if a <= (n / 2) < b:\n return 'Final!'\n while a < b <= (n / 2) or b > a > (n / 2):\n if b <= (n / 2):\n n = n / 2\n else:\n a -= n / 2\n b -= n / 2\n n = n / 2\n res = 0\n while n > 1:\n res += 1\n n /= 2\n return str(res)\n\n\nif __name__ == '__main__':\n print solution()\n"}, {"source_code": "n, a, b = map(int, input().split())\n\na -= 1\nb -= 1\n\nct = 0\n\nwhile a != b:\n\ta //= 2\n\tb //= 2\n\n\tct += 1\n\nprint(\"Final!\" if 2 ** ct == n else ct)\n"}, {"source_code": "from math import ceil\nn,a,b = [int(x) for x in raw_input().split(\" \")]\n\nc=0\nwhile a!=b:\n\tc+=1\n\ta/=2.\n\ta = ceil(a)\n\tb/=2.\n\tb = ceil(b)\nc2 = 0\nwhile 2**c2<n:\n\tc2+=1\nif(c==c2):\n\tprint \"Final!\"\nelse:\n\tprint c"}, {"source_code": "n,a,b=map(int,raw_input().split())\na,b=min(a,b),max(a,b)\nfrom math import log\nvl=0\nq=log(n,2)\n\nwhile n!=1:\n #n=n/2 \n \n \n if (a<n and b<=n) :\n n=n/2\n vl=vl+1 \n elif (a>n and b>n):\n a=a-n \n b=b-n\n else:\n break\n \n #print a,b,n,vl\n \n \nif vl==1:\n print \"Final!\"\nelse:\n print int(q-vl+1)\n"}, {"source_code": "v,a,b=list(map(int,input().split()))\nif v!=2:\n c=[]\n m=True\n g=1\n for i in range(v):\n c.append([i+1])\n for i in range(int(v/2)):\n c[i].append(c[i+1][0])\n c.remove(c[i+1])\n if len(set(c[i]).intersection(set([a,b])))==2:\n print(1)\n m=False\n break\n if m==True:\n for i in range(8):\n v=v/2\n g+=1\n for j in range(int(v/2)):\n if len(c)==2:\n m=False\n print(\"Final!\")\n break\n for l in range(len(c[j+1])):\n c[j].append(c[j+1][l])\n c.remove(c[j+1])\n if len(set(c[j]).intersection(set([a,b])))==2:\n print(g)\n m=False\n break\n if m==False:\n break\nelse:\n print(\"Final!\")"}, {"source_code": "import math\ninp = raw_input().split(\" \")\n\nn = int(inp[0])\na = int(inp[1])\nb = int(inp[2])\ncounter = 0\n\ndef f(n,a,b,counter):\n if a <= (n/2) and b > (n/2):\n return counter\n elif a <= (n/2) and b <= (n/2):\n return f(n/2,a,b,counter+1)\n elif a > n/2 and b > n/2:\n return f(n/2,a-(n/2),b-(n/2),counter+1)\n else:\n return counter\n\n\n\n\nx = math.log(n)/math.log(2) - f(n,a,b,counter)\n\nif x == math.log(n)/math.log(2):\n print \"Final!\"\nelse:\n print int(x)"}, {"source_code": "import math\n\nn, a, b = map(int, raw_input().split())\n\na -= 1\nb -= 1\n\nln = int(math.log(n, 2))\n\nr = 0\nwhile a != b:\n a //= 2\n b //= 2\n r += 1\nif ln == r:\n print \"Final!\"\nelse:\n print r\n"}, {"source_code": "n,a,b=map(int,raw_input().split())\na-=1\nb-=1\nc=1\nwhile a/2 != b/2:\n\ta/=2\n\tb/=2\n\tc+=1\nprint\"Final!\"if 2**c==n else c\n"}, {"source_code": "from itertools import zip_longest\n\nn, a, b = map(int, input().split())\n\n\ndef chunks(lst, count):\n n = len(lst) // count\n return list(x for x in zip_longest(*[iter(lst)] * n))\n\n\ncommand = chunks(range(1, n + 1), n // 2)\n\ni = 0\n\nwhile True:\n i += 1\n #print(command)\n if [(a, b)] == command or [(b, a)] == command:\n print('Final!')\n break\n if (a, b) in command or (b, a) in command:\n print(i)\n break\n y = list(map(lambda x: a if a in x else (b if b in x else x[1]), command))\n if len(y) // 2:\n command = chunks(y, len(y) // 2)\n else:\n command = chunks(y, 1)"}, {"source_code": "from collections import Counter,UserString\nimport sys\ntry:\n pass\n #sys.stdin=open('test','r')\nexcept:\n pass\nn,a,b=list(map(int,input().split()))\na,b=a-1,b-1\ni=1\nwhile n!=2:\n n=n//2\n a,b=a//2,b//2\n if a==b:\n print(i)\n exit()\n i=i+1\nprint('Final!')"}, {"source_code": "n,a,b=map(int,input().split())\na,b,r=a-1,b-1,0\nwhile a!=b:\n a//=2\n b//=2\n r+=1\nprint(r if 2**r<n else 'Final!')"}, {"source_code": "n, a, b = list(map(int, input().split()))\np2 = 0\nwhile 2 ** p2 != n:\n\tp2 += 1\n\nr = 0\nwhile a != b:\n\ta = round(a/2 + 0.001)\n\tb = round(b/2 + 0.001)\n\tr += 1\nif(r == p2):\n\tprint(\"Final!\")\nelse:\n\tprint(r)"}, {"source_code": "import math\ndef solve(n,a,b):\n\tr = math.log2(n)\n\tc=0;\n\tl = [i for i in range(1,n+1)]\n\t#print(l)\n\twhile(1):\n\t\tc += 1\n\t\t#print(c)\n\t\tif l.index(a)%2==0 and l.index(b)%2==1 and l.index(b)- l.index(a)==1:\n\t\t\tif c==r:\n\t\t\t\treturn 'Final!'\n\t\t\telse:\n\t\t\t\treturn c\n\t\tfor i in range(0,len(l)-1,2):\n\t\t\t#print(len(l))\n\t\t\tif l[i]==a or l[i]==b:\n\t\t\t\tl[i+1]=0\n\t\t\telse:\n\t\t\t\tl[i]=0\n\t\tl=list(filter((0).__ne__, l))\n\nn,a,b = map(int,input().split(' '))\nif a>b:\n\ta,b=b,a\nprint (solve(n,a,b))"}, {"source_code": "n, a, b = map(int, input().split())\ncnt = 0\na-=1\nb-=1\nwhile a != b:\n a//=2\n b//=2\n n//=2\n cnt += 1\nif n == 1:\n print(\"Final!\")\nelse:\n print(cnt)"}, {"source_code": "n,a,b=map(int,input().split())\na,b,n=bin(a-1)[2:],bin(b-1)[2:],bin(n-1)[2:]\na,b='0'*(len(n)-len(a))+a,'0'*(len(n)-len(b))+b\nfor i in range(len(n)):\n if a[i]!=b[i]:\n if i==0:\n print('Final!')\n else:\n print(len(n)-i)\n quit()\n \n"}, {"source_code": "n,a,b = map(int,input().split())\n\na -= 1\nb -= 1\nans = 0\ntemp = 2\nfor i in range(8):\n if a // temp == b // temp:\n ans = i + 1\n break\n temp *= 2\n \nif temp == n:\n print(\"Final!\")\nelse:\n print(ans)\n"}, {"source_code": "import math\nn,a,b=map(int,input().split())\nfor i in range(1,8):\n a=math.ceil(a/2);b=math.ceil(b/2)\n if a==b:\n if (2**i)==n:\n print('Final!')\n else:\n print(i)\n exit(0)\nprint('Final!')\n"}, {"source_code": "import math\nn,a,b=map(int,input().split())\ns=1\ne=n\ncnt=0\n\ndef round(s,e,a,b,cnt,n):\n cnt+=1\n m=(s+e)//2\n if s<=a<=m and m+1<=b<=e: \n if cnt==1:\n print(\"Final!\")\n else:\n print(int(math.log2(n)-cnt+1))\n elif s<=a<=m and s<=b<=m:\n round(s,m,a,b,cnt,n)\n elif m+1<=a<=e and m+1<=b<=e:\n round(m+1,e,a,b,cnt,n)\nround(s,e,min(a,b),max(a,b),cnt,n)"}, {"source_code": "n, a, b = map(int, input().split())\ncnt = 1\n\na += a % 2\nb += b % 2\nwhile a != b:\n cnt += 1\n a /= 2\n b /= 2\n a += a % 2\n b += b % 2\nif 2 ** cnt == n:\n print('Final!')\nelse:\n print(cnt)\n \n\n\n "}, {"source_code": "def check(n,a,b):\n c=n/2\n if (b>c and a<=c) or (a>c and b<=c):\n return(n)\n else:\n if a<=c and b<=c:\n z=check(c,a,b)\n if a>c and b>c:\n z=check(c,a-c,b-c)\n return z\n \nn, a ,b= map(int, input().split())\nz=check(n,a,b); i=0\nif z==n:\n print('Final!')\nelse:\n while z!=1:\n z/=2\n i+=1\n print(i)"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\na -= 1\nb -= 1\n\nfor i in range(10, -1, -1):\n #print \"%d -> %d\" % (i, 1 << i)\n #print \"(1 << i) & a): %d\" % ((1 << i) & a)\n #print \"(1 << i) & b): %d\" % ((1 << i) & b)\n if ((1 << i) & a) != ((1 << i) & b):\n if (1 << (i + 1)) == n:\n print \"Final!\"\n else:\n print i + 1\n exit()\n\n# 2: 0010\n# 6: 0110\n"}, {"source_code": "from math import log\nn,a,b=map(int,raw_input().split())\na,b=min(a,b),max(a,b)\nq=log(n,2)\nvl=0\n\n\nwhile n!=1:\n if (a<n and b<=n) :\n n=n/2\n vl=vl+1 \n elif (a>n and b>n):\n b=b-n\n a=a-n \n else:\n break\n\nif vl==1:\n print \"Final!\"\nelse:\n print int(q-vl+1)\n"}, {"source_code": "import math\nn,a,b = map(int,raw_input().split())\nif a > b:\n\ta,b = b,a\nans = 1\nfinal = int(math.log(n,2))\na = int(math.ceil(a/2.0))\nb = int(math.ceil(b/2.0))\nwhile b-a >= 1:\n\ta = int(math.ceil(a/2.0))\n\tb = int(math.ceil(b/2.0))\n\tans += 1\nif ans == final:\n\tprint 'Final!'\nelse:\n\tprint ans"}, {"source_code": "def divide(l, r, a, b):\n m = (l + r) // 2\n if a <= m and b > m:\n return 1\n elif b <= m:\n return divide(l, m, a, b) + 1\n elif a > m:\n return divide(m + 1, r, a, b) + 1\n\n\nn, a, b = map(int, input().split())\nif a > b:\n a, b = b, a\n\nnum = divide(1, n, a, b)\ncnt = 0\nwhile n > 0:\n cnt += 1\n n = n >> 1\n\nif num == 1:\n print(\"Final!\")\nelse:\n print(cnt - num)\n"}, {"source_code": "n, a, b = map(int, input().split())\ns = 0\ni = 0\nk = 0\n\nwhile n != 1:\n n //= 2\n k += 1\n\nwhile s == 0:\n i += 1\n if (a == b+1) and (a % 2 == 0) or (b == a + 1) and (b % 2 == 0):\n s = i\n a = a // 2 + a % 2\n b = b // 2 + b % 2\n\nif s == k:\n print('Final!')\nelse: print(s)"}, {"source_code": "import math\nn,a,b=map(int,input().split())\nk=math.log(n,2)\nfor i in range(1,9):\n a=math.ceil(a/2)\n b=math.ceil(b/2)\n if a==b:\n break\nif i==int(k):\n print('Final!')\nelse:\n print(i//1)\n "}, {"source_code": "# vars: a, b, ca, cb, cx, res, n\nn, a, b = map(int, input().split())\nca = a-1\ncb = b-1\ncx = n//2\nres = 0\nwhile cx:\n\tif ca == cb:\n\t\tprint(res)\n\t\texit()\n\tca //= 2\n\tcb //= 2\n\tcx //= 2\n\tres += 1\nprint('Final!')\n"}, {"source_code": "#To take input\n# str = raw_input()\n# R = float(str.split()[0])\n# real = int(str.split()[1])\n# R, x1, y1, x2, y2 = map(int, raw_input().split(' '))\n# print \"{} {} {}\".format(x3, y3, r)\n\nn, a, b = map(int, raw_input().split(' '))\ni=0\nif((a>n/2 and b<=n/2) or (a<=n/2 and b>n/2)):\n print(\"Final!\")\n exit(0)\n\nwhile(a!=b):\n i += 1\n a = (a+1)/2\n b = (b+1)/2\n\nprint(i)\n"}, {"source_code": "# *\n# * *\n# * *\n# * * * Author:Aditya Joshi\n# * *\n# * *\n\nn, a, b = map(int, input().split())\n\na -= 1\nb -= 1\nr = 0\n\nwhile a != b:\n\n a //= 2\n\n b //= 2\n\n r += 1\nif 2 ** r < n:\n print(r)\nelse:\n print(\"Final!\")\n"}, {"source_code": "n,a,b=list(map(int,input().split()))\na-=1\nb-=1\nx=0\nwhile n>2:\n a//=2\n b//=2\n n//=2\n x+=1\n if a==b:\n print(x)\n break\nelse:\n print('Final!')"}, {"source_code": "n, a, b = map(int, input().split())\n\nprint(((a-1)^(b-1)).bit_length() % (n.bit_length()-1) or 'Final!')"}, {"source_code": "GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())\n\nfrom math import log\ndef main():\n n, a, b = GIS()\n final = log(n, 2)\n d = abs(b - a)\n rounds = int(log(d, 2)) + 1\n if rounds == 1 and (a - 1) // 2 != (b - 1) // 2:\n rounds += 1\n print(rounds if rounds < final else 'Final!')\n\ndef main():\n n, a, b = GIS()\n a -= 1\n b -= 1\n final = log(n, 2)\n\n rounds = 0\n while a != b:\n a //= 2\n b //= 2\n rounds += 1\n\n print(rounds if rounds < final else 'Final!')\n\nmain()\n"}, {"source_code": "c,a,b=input().split()\nc=int(c)\nlevel=0\nwhile c!=1:\n level+=1\n c//=2\na=int(a)-1\nb=int(b)-1\nroundik=0\nwhile a!=b:\n roundik+=1\n a//=2\n b//=2\nif roundik==level:\n print(\"Final!\")\nelse:\n print(roundik)"}, {"source_code": "from math import log2\nn, a, b = [int(z) for z in input().split()]\nl = int(log2(n))\nnew = [0] * 256\nnew[a - 1] = 1\nnew[b - 1] = 1\ncur = []\ncnt = 1\nwhile True:\n for i in range(0, len(new) - 1, 2):\n cur.append(new[i] + new[i + 1])\n for i in range(len(cur)):\n if cur[i] == 2:\n if cnt == l:\n print(\"Final!\")\n else:\n print(cnt)\n exit(0)\n cnt += 1\n new = cur\n cur = []\n "}, {"source_code": "n, a, b = map(int, input().split())\nA = [i for i in range(1, n + 1)]\nci = 0\nwhile len(A) > 2:\n ci += 1\n B = []\n for i in range(0, len(A), 2):\n if {A[i], A[i + 1]} == {a, b}:\n print(ci)\n exit(0)\n elif A[i] in {a, b}:\n B.append(A[i])\n else:\n B.append(A[i + 1])\n A = B\nprint('Final!')"}, {"source_code": "n, a, b = map(int, input().split())\nt = 1\nmx = 2\nwhile 1:\n\tt1 = (a+mx-1)//mx\n\tt2 = (b+mx-1)//mx\n\tif t1 == t2:\n\t\tif mx == n:\n\t\t\tprint(\"Final!\")\n\t\telse:\n\t\t\tprint(t)\n\t\tbreak\n\tmx*=2 \n\tt+=1"}, {"source_code": "total_teams,team1,team2 = map(int,input().split())\n\ncount = 1\nwhile True:\n\tif round((team1/2)+0.1)==round((team2/2)+0.1):\n\t\tbreak\n\t\n\tteam1=round((team1/2)+0.1)\n\tteam2=round((team2/2)+0.1)\n\ttotal_teams//=2\n\tcount+=1\n\t\nif total_teams==2:\n print('Final!')\nelse:\n\n print(count)\n"}, {"source_code": "n, a, b = map(int, input().split())\na, b = a - 1, b - 1\ncount = 1\nwhile a // 2 != b // 2:\n\tcount += 1\n\ta //= 2\n\tb //= 2\nif 2 ** count == n:\n\tprint(\"Final!\")\nelse:\n\tprint(count)\n"}, {"source_code": "n,a,b = map(int,input().split())\nx = max(a,b)\ny = min(a,b)\nn = int(n/2)\nc = 0\n\nif y <= n and x> n:\n print(\"Final!\")\n \nelse:\n while a != b:\n c += 1\n a = (a + 1) // 2\n b = (b + 1) // 2\n print(c) \n"}, {"source_code": "n,a,b=map(int,input().split())\n\nround=0\ntemp=n\nwhile temp>1:\n\tround+=1\n\ttemp//=2\nmax_round=round\nif a>b:\n\ta,b=b,a\nmid=n//2\nwhile round>1:\n\tif a<=mid and b>mid:\n\t\tbreak\n\tround-=1\n\tn//=2\n\tmid+=n//2 if mid<=a else -n//2\nprint('Final!' if round==max_round else round)"}, {"source_code": "n,a,b = map(int,input().split())\nz = 0\nq = 0\nwhile a != b:\n z += 1\n a = (a + 1) // 2\n b = (b + 1) // 2\nwhile n != 1:\n n //= 2\n q += 1\nif z == q:\n print(\"Final!\")\nelse:\n print(z)"}, {"source_code": "import sys\nimport itertools as it\nimport math\n\nn,a,b = map(int, sys.stdin.readline().split())\n\na-=1\nb-=1\nlogn = int(math.log2(n))\n\nfor k in range(logn):\n if a&(1<<(logn-k-1)) != b&(1<<(logn-k-1)):\n if k==0:\n print('Final!')\n else:\n print(logn-k)\n break\n"}, {"source_code": "n,a,b=map(int,input().split())\n\na,b,r=a-1,b-1,0\n\nwhile a!=b:\n\n a//=2\n\n b//=2\n\n r+=1\n\nprint(r if 2**r<n else 'Final!')\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "import sys,math\nn,a,b=map(int,sys.stdin.readline().split())\nans=0\na-=1 \nb-=1 \nflag=True\nwhile(n>2):\n a//=2 \n b//=2 \n ans+=1\n if a==b:\n print(ans)\n flag=False\n break\n n//=2\nif flag:\n print(\"Final!\")\n \n \n \n"}, {"source_code": "n,a,b=[int(i) for i in input().split()]\nnd=0\nwhile True:\n if a%2!=0:\n a=(a+1)//2\n else:\n a=a//2\n if b%2!=0:\n b=(b+1)//2\n else:\n b=b//2\n if a==b:\n nd+=1\n break\n nd+=1\nnk=0\nwhile n>2:\n n=n//2\n nk+=1\nif (nk+1)==nd:\n print('Final!')\nelse:\n print(nd)\n"}, {"source_code": "n, a, b, i, z = map(int, input().split() + [1, 0])\nwhile i < n:\n if (a - 1)//i == (b - 1)//i:\n exit(print(z))\n i, z = i * 2, z + 1\nprint('Final!')"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\nfrom math import log2 as lg\ndef f(n,a,b,l,u):\n if n <= 1:\n return\n if a >= l and a <= n//2 + l - 1 and b >= n//2 + l and b <= u:\n if n == final:\n print('Final!')\n else:\n print(int(lg(n)))\n else:\n if b <= n//2 + l - 1:\n f(n//2,a,b,l,n//2 + l - 1)\n else:\n f(n//2,a,b,n//2 + l , u)\nif __name__ == \"__main__\":\n n,a,b = map(int,input().split())\n final = n\n if a > b:\n a,b = b,a\n f(n,a,b,1,n)"}, {"source_code": "'''input\n8 7 5\n'''\nfrom math import log2 as ln\nn, a, b = [int(i) for i in input().split(\" \")]\na, b = sorted([a, b])\nfn = ln(n)\nl = [i for i in range(1, n + 1)]\nans = 0\nt = 0\nfor _ in range(10):\n\tm = []\n\tif len(l) == 0:\n\t\tbreak\n\tans += 1\n\tfor i in range(0, len(l) - 1, 2):\n\t\tif [l[i], l[i + 1]] == [a, b]:\n\t\t\tt = 1\n\t\t\tbreak\n\t\telif l[i] == a:\n\t\t\tm.append(a)\n\t\telif l[i] == b:\n\t\t\tm.append(b)\n\t\telif l[i + 1] == a:\n\t\t\tm.append(a)\n\t\telif l[i + 1] == b:\n\t\t\tm.append(b)\n\t\telse:\n\t\t\tm.append(l[i])\n\tif t == 1:\n\t\tbreak\n\tl = m.copy()\nif ans == fn:\n\tprint(\"Final!\")\nelse:\n\tprint(ans)\t\n\n\n\t\t\n\t\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n# http://codeforces.com/contest/931/problem/B\n\ndef match_num(n):\n return (n + 1) // 2\n\ndef rec(r, teams, t1, t2):\n if (teams == 2):\n return 'Final!'\n \n m1 = match_num(t1)\n m2 = match_num(t2)\n \n if m1 == m2:\n return r\n \n return rec(r+1, teams//2, m1, m2)\n \n\ndef problem():\n \n in1 = input()\n# in1 = '8 7 5'\n \n args = list(map(int, in1.split()))\n\n teams = args[0]\n t1 = args[1]\n t2 = args[2]\n\n result = rec(1, teams, t1, t2) \n\n return result\n\n \nprint(problem())\n#problem()"}, {"source_code": "def log2(n):\n ret = 1\n p = 2\n while True:\n if p == n:\n break\n p *= 2\n ret += 1\n return ret\n \nn, a, b = map(int, input().split())\nans = log2(n)\ninf, sup = 0, n\nn = inf + sup // 2\n\nif n >= min(a, b) and n < max(a, b):\n ans = \"Final!\"\nelse:\n while True:\n n = (inf + sup) // 2\n if n >= min(a, b) and n < max(a, b):\n break\n else:\n if n >= max(a, b):\n sup = n\n else:\n inf = n\n ans -= 1\n \nprint(ans)\n"}, {"source_code": "n,a,b=map(int,input().split())\n\na,b,r=a-1,b-1,0\n\nwhile a!=b:\n\n a//=2\n\n b//=2\n\n r+=1\n\nprint(r if 2**r<n else 'Final!')\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def log2(n):\n ret = 1\n p = 2\n while True:\n if p == n:\n break\n p *= 2\n ret += 1\n return ret\n \nn, a, b = map(int, input().split())\nans = log2(n)\ninf = 0\nsup = n\nn = inf + sup / 2\nif n >= min(a, b) and n < max(a, b):\n ans = \"Final!\"\nelse:\n while True:\n n = (inf + sup) / 2\n if n >= min(a, b) and n < max(a, b):\n #ans = ans - 1\n break\n else:\n if n >= max(a, b):\n sup = n\n else:\n inf = n\n ans -= 1\nprint(ans)\nexit()\n"}, {"source_code": "j=list(map(int,input().split()))\nn=j[0]\na=j[1]\nb=j[2]\nm=0\nl=1\nr=n\nk=0\np=0\nwhile n>1:\n n=n//2\n m=m+1\np=m\n \nwhile True:\n k=(l+r)//2\n if a>k and b<=k:\n if m==p:\n print('Final!')\n break\n else:\n print(m)\n break\n if a<=k and b>k:\n if m==p:\n print('Final!')\n break\n else:\n print(m)\n break\n \n if a<=k and b<=k:\n r=k\n m=m-1\n if a>k and b>k:\n l=k+1\n m=m-1\n"}, {"source_code": "a,b,c=map(int,input().split())\ns=0\nwhile(c!=b):\n c=(c+1)//2\n b=(b+1)//2\n s+=1\n a//=2\nif a>1:print(s)\nelse:print(\"Final!\")"}, {"source_code": "import sys\n#from io import StringIO\n\n#sys.stdin = StringIO(open(__file__.replace('.py', '.in')).read())\n\nn, a, b = list(map(int, input().split()))\n\nr = list(range(1, n + 1))\nc = 1\nwhile len(r) != 2:\n t = []\n for i in range(0, len(r) - 1, 2):\n if r[i] in [a, b] and r[i+1] in [a, b]:\n print(c)\n sys.exit()\n elif r[i] in [a, b]:\n t.append(r[i])\n elif r[i + 1] in [a, b]:\n t.append(r[i + 1])\n else:\n t.append(r[i])\n r = t\n c += 1\n\nif a in r and b in r:\n print('Final!')\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nB\n\"\"\"\nimport math\n\ndef calc_round_number(number_of_teams, total_number):\n return int(math.log2(total_number/number_of_teams))+1\n\ndef is_final(number_of_teams, round_number):\n return int(math.log2(number_of_teams)) == round_number\n\ndef get_pairs(teams):\n teams_sorted = sorted(teams)\n pairs = [(x,y) for x,y in zip(teams_sorted[:-1:2], teams_sorted[1::2])]\n return pairs\n\ndef get_winners(pair, a, b):\n x,y = pair\n if x in (a,b):\n return x\n else:\n return y\n\ndef get_round_number(teams, a, b, n):\n pairs = get_pairs(teams)\n result = [True for x,y in pairs if x==a and y==b or y==a and x==b]\n if result:\n return calc_round_number(len(teams), n)\n else:\n winners = [get_winners(pair, a,b) for pair in pairs]\n return get_round_number(list(winners), a, b, n)\n\ndef main():\n user_input = input()\n n,a,b = list(map(int,user_input.split()))\n \n teams = list(range(1, n+1))\n round_number = get_round_number(teams, a, b, n)\n \n if is_final(n, round_number):\n result = \"Final!\"\n else:\n result = \"{}\".format(round_number)\n print(result)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from math import ceil\n\nn, a, b = map(int, input().split())\nmax = max(a, b)\nmin = min(a, b)\nround = 0\nwhile(True):\n round += 1\n max = ceil(max/2)\n min = ceil(min/2)\n if max == min:\n break\n\nif 2**round == n:\n print('Final!')\nelse:\n print(round)"}, {"source_code": "v, a, b = list(map(int, input().split()))\nc = []\nm = True\ng = 0\nfor i in range(v):\n c.append([i + 1])\nfor i in range(8):\n g += 1\n for h in range(int(v / 2)):\n if len(c) == 2:\n print(\"Final!\")\n m = False\n break\n for l in range(len(c[h + 1])):\n c[h].append(c[h + 1][l])\n c.remove(c[h + 1])\n if len(set(c[h]).intersection([a, b])) == 2:\n m = False\n print(g)\n break\n if m == False:\n break\n v = v / 2\n"}, {"source_code": "from math import log2\nn, a, b=map(int, input().split())\nn=int(log2(n))\nfor i in range(1,n+1):\n if (a-1)//(2**i)==(b-1)//(2**i):\n if i==n:\n print(\"Final!\")\n else:\n print(i)\n break;\n\n#print(n)"}, {"source_code": "import math\n\nnum,one,two=[int(x) for x in input().split()]\n\nstage=num/2\nif (one<=stage and two>stage) or (one>stage and two<=stage):\n print(\"Final!\")\nelse:\n count=1\n while stage>=2:\n if(math.ceil(one/2)==math.ceil(two/2)):\n print(count)\n break\n else:\n count+=1\n one=math.ceil(one/2)\n two=math.ceil(two/2)\n stage=stage/2"}, {"source_code": "n,a,b=map(int,input().split())\na,b,r=a-1,b-1,0\nwhile a!=b:\n a//=2\n b//=2\n r+=1\nprint(r if 2**r<n else 'Final!')"}, {"source_code": "n, a, b = [int(s) for s in input().split()]\nk = 0\na -= 1\nb -= 1\nwhile a != b:\n k += 1\n a //= 2\n b //= 2\nif 2**k == n:\n print(\"Final!\")\nelse:\n print(k)"}, {"source_code": "import sys \n\nI=sys.stdin.readline\n\nn,a,b=map(int,I().split())\nrou=1\nwhile n>0:\n\ta-=1\n\tb-=1\n\ta=int(a/2)+1\n\tb=int(b/2)+1\n\tif a==b:\n\t\tif n==2:\n\t\t\tprint(\"Final!\")\n\t\telse:\n\t\t\tprint(rou)\n\t\tbreak\n\trou+=1\n\tn=n//2\n\n\n\n"}, {"source_code": "t=input().split()\nn=int(t[0])\na=int(t[1])\nb=int(t[2])\ni=n\nk=0\nwhile i>0:\n k=k+1\n i=i//2\nk=k-1\nx=k\nif a<b:\n i=n//2\n j=i\n while i>0:\n if a<=j and b>j:\n break\n elif a<=j and b<=j:\n j=j-i//2\n else:\n j=j+i//2\n x=x-1\n i=i//2\n if x==k:\n print(\"Final!\")\n else:\n print(x)\nelse:\n i=n//2\n j=i\n while i>0:\n if b<=j and a>j:\n break\n elif a<=j and b<=j:\n j=j-i//2\n else:\n j=j+i//2\n x=x-1\n i=i//2\n if x==k:\n print(\"Final!\")\n else:\n print(x)"}, {"source_code": "n, a, b = map(int, input().split())\nif a > b:\n a, b = b, a\nif a <= n // 2 and b > n // 2:\n print('Final!')\nelse:\n a += n - 1\n b += n - 1\n for i in range(100):\n if a == b:\n print(i)\n break\n a //= 2\n b //= 2\n"}, {"source_code": "(n, a, b) = map(int, input().split())\nc = (a + 1) // 2\nd = (b + 1) // 2\nk = 0\nwhile c != d:\n c = (c + 1) // 2\n d = (d + 1) // 2\n k += 1\n n = n // 2\n #print(k,n,c,d)\nk += 1\nif n == 2:\n print('Final!')\nelse:\n print(k)\n \n \n"}, {"source_code": "import math\n\n\nn, a, b = map(int, input().split())\nold_n = n\n\nif a > b:\n a += b\n b = a - b\n a -= b\n\nteams = [i for i in range(1, n + 1)]\nround = 0\nwhile len(teams) != 1:\n round += 1\n for i in range(0, n, 2):\n if teams[i] == a and teams[i + 1] == b:\n break\n if teams[i] == a or teams[i] == b:\n teams[i + 1] = -1\n else:\n teams[i] = -1\n try:\n for i in range(n // 2):\n teams.remove(-1)\n n //= 2\n except ValueError:\n break\nif round == math.log2(old_n):\n print('Final!')\nelse:\n print(round)\n"}, {"source_code": "n, a, b = [int(i) for i in input().split()]\na -= 1\nb -= 1\nresult = 0\nwhile a != b:\n a >>= 1\n b >>= 1\n result += 1\nif n == 1 << result:\n print(\"Final!\")\nelse:\n print(result)\n"}, {"source_code": "import math\nn, a, b = map(int, input().split())\nr0 = r1 = round(math.log2(n))\nl, r = 0, n\nd = (l + r) // 2\nwhile not((a > d) ^ (b > d)):\n r1 -= 1\n if a > d:\n l = d\n else:\n r = d\n d = (l + r) // 2\n \nif r1 == r0:\n print(\"Final!\")\nelse:\n print(r1)"}, {"source_code": "n, a, b = map(int, input().split())\n\na -= 1\nb -= 1\nc = 1\n\nwhile a > 0 or b > 0:\n a //= 2\n b //= 2\n if a == b:\n if n > 2:\n print(c)\n else:\n print(\"Final!\")\n break\n c += 1\n n //= 2\n"}, {"source_code": "__author__ = 'RaldenProg'\n\n\n\n\nn, a, b = [_ for _ in map(int, input().split())]\nkomands = []\ndelete = []\nchet = 0\nstop = 0\nfor i in range(1, n+1):\n komands.append(i)\n\nwhile len(komands) != 2:\n chet += 1\n delete = []\n for i in range(0, len(komands), 2):\n if (komands[i] == a and komands[i + 1] == b) or (komands[i] == b and komands[i + 1] == a):\n print(chet)\n stop = 1\n break\n if komands[i] == a or komands[i] == b:\n delete.append(i+1)\n else:\n delete.append(i)\n if stop == 1:\n break\n #print(delete)\n for i in range(len(delete)):\n komands.pop(delete[i])\n for j in range(i+1, len(delete)):\n delete[j] -= 1\n\n #print(komands)\nif stop == 0:\n print(\"Final!\")"}], "negative_code": [{"source_code": "z = list(input().split())\nn = int (z[0])\na = int (z[1])\nb = int (z[2])\nif a%2==0:\n a=a\nelse:\n a=a+1\nif b%2==0:\n b=b\nelse:\n b=b+1\ns=b-a\nd=0\nwhile s>=2:\n s=s/2\n d=d+1\nk=0\nwhile n>=2:\n n=n/2\n k=k+1\nif k==d+1:\n print('FINAL')\nelse:\n print(d+1)"}, {"source_code": "#!/usr/bin/python\nimport math\n\nn,a,b = raw_input().split()\nn = int(n)\na = int(a)\nb = int(b)\n\nif a % 2 != 0:\n\ta += 1\nif b % 2 != 0:\n\tb += 1\n\nif a == b:\n\trou = 1\nelse:\n\trou = math.floor(math.log(abs(b - a), 2)) + 1\ntrou = math.log(n, 2)\n\nif rou == trou:\n\tprint 'Final!'\nelse:\n\tprint int(rou)\n\t"}, {"source_code": "from math import log2\nn, a, b = map(int, input().split())\nn1= n\nfinal = int(log2(n))\nans = 1\nwhile abs(a-b) > 1 or min(a, b) % 2 == 0:\n if a != 1:\n a//=2\n if(b != 1):\n b//=2\n ans+=1\nif(ans != final):\n print(ans)\nelse:\n print(\"Final!\")"}, {"source_code": "n,a,b=map(int,input().split())\nl=list(range(1,n+1))\n\ndef getRoundNumber(l,n,a,b,count):\n\tif len(l)==2:\n\t\treturn 10000\n\ttemp=[]\n\tfor i in range(0,len(l)-1,2):\n\t\tif l[i]==a and l[i+1]==b:\n\t\t\treturn count\n\t\telif l[i]==a and l[i+1]!=b:\n\t\t\ttemp.append(l[i])\n\t\telif l[i]!=a and l[i+1]==b:\n\t\t\ttemp.append(l[i+1])\n\t\telse:\n\t\t\ttemp.append(l[i])\n\tn=n//2\n\treturn getRoundNumber(temp,n,a,b,count+1)\n\nif a>b:\n\tcount=getRoundNumber(l,n,b,a,1)\n\tif count==10000:\n\t\tprint('Final!')\n\telse:\n\t\tprint(count)\nelse:\n\tcount=getRoundNumber(l,n,a,b,1)\n\tif count==10000:\n\t\tprint('Final!')\n\telse:\n\t\tprint(count)"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=[]\nm=True\ng=1\nfor i in range(v):\n c.append([i+1])\nfor i in range(int(v/2)):\n c[i].append(c[i+1][0])\n c.remove(c[i+1])\n if len(set(c[i]).intersection(set([a,b])))==2:\n print(1)\n m=False\n break\nif m==True:\n for i in range(8):\n v=v/2\n g+=1\n for j in range(int(v/2)):\n if len(c)==2:\n m=False\n print(\"Final!\")\n break\n for l in range(len(c[j+1])):\n c[j].append(c[j+1][l])\n c.remove(c[j+1])\n if len(set(c[j]).intersection(set([a,b])))==2:\n print(g)\n m=False\n break\n if m==False:\n break"}, {"source_code": "a,b,c=map(int,input().split())\nz=[*range(1,a+1)]\nb,c=sorted([b,c])\ns=0;k=a\nwhile 1:\n p=[]\n for i in range(0,k,2):\n if z[i]==b and z[i+1]==c:\n s+=1\n if len(z)==2:print(\"Final!!\")\n else:print(s)\n exit()\n elif z[i]==b:p+=[z[i]]\n elif z[i+1]==b:p+=[z[i+1]]\n elif z[i] == c:p += [z[i]]\n elif z[i + 1] == c:p += [z[i + 1]]\n else:p+=[z[i]]\n k//=2;z=p;s+=1\n\n"}, {"source_code": "n,a,b = map(int,input().split())\na,b = (min(a,b)),max(a,b)\nif a == b + 1 and a % 2 ==0:\n print(2)\n exit()\nmaxst = 0\nwhile n != 1:\n maxst += 1\n n //= 2\ntmp = b - a\ncurst = 0\nwhile tmp != 1:\n curst += 1\n tmp //= 2\nif (curst + 1 == maxst):\n print('Final!')\nelse:\n print(curst + 1)"}, {"source_code": "import math\nn,a,b = map(int, input().split())\nif n==2:\n print('Final!')\nelse:\n mid=n//2\n if a<=mid and b>mid or a>mid and b<mid: print('Final!')\n else: print(int(math.log2(mid)))"}, {"source_code": "n, a, b = map(int, input().split())\nmas = list(range(1, n + 1))\ndef pars(mas):\n gas = []\n for i in range(0, len(mas), 2):\n gas.append(mas[i:i+2])\n return gas\nif a % 2 == 0:\n a -= 1\nif b % 2 == 0:\n b -= 1\nwhile True:\n gas = []\n l = pars(mas)\n for el in l:\n if a in el and b in el:\n if len(l) == 1:\n print(\"final\")\n exit(0)\n else:\n print(n // (len(l) * 2))\n exit(0)\n elif a in el:\n gas.append(a)\n elif b in el:\n gas.append(b)\n else:\n gas.append(el[0])\n mas = gas.copy()"}, {"source_code": "import math\n\nn, a, b = map(int, input().split())\n\nr = math.ceil(math.log2(abs(a - b))) + 1\n\nprint(\"Final!\" if r == math.ceil(math.log2(n)) else r)"}, {"source_code": "x=[int(i)for i in input().split()]\nif x[2]<x[1]:\n x[1],x[2]=x[2],x[1]\nif x[1]<=x[0]//2 and x[0]//2<x[2]:\n print(\"Final!\")\nelse:\n if x[1]<=x[0]//2 and x[2]<=x[0]//2:\n pass\n else:\n x[1]=x[1]-x[0]//2\n x[2]=x[2]-x[0]//2\n k=0\n while True:\n if x[1]<=x[0]//2 and x[0]//2<=x[2]:\n if x[1]+1==x[2]:\n print(1)\n break\n else:\n while x[0]!=1:\n k+=1\n x[0]=x[0]//2\n print(k)\n break\n x[0]=x[0]//2"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=0\nm=v/2\nif ((a<=v/2)and(b>v/2))or((a>v/2)and(b<=v/2)):\n print(\"Final!\")\nelse:\n for i in range(8):\n v/=2\n if v==1:\n for g in range(8):\n if ((a<=m/2)and(b>m/2))or((a>m/2)and(b<=m/2)):\n print(c)\n break\n else:\n c-=1\n m/=2\n break\n else:\n c+=1\n"}, {"source_code": "import math\nn,a,b = map(int, input().split())\nif n==2:\n print('Final!')\nelse:\n mid=n//2\n if a<=mid and b>mid or a>mid and b<=mid:\n print('Final!')\n elif min(a,b)%2 != 0 and abs(a-b)==1:\n print(1)\n elif max(a,b)+1==mid//2: print(int(math.log2(mid//2)))\n else: \n print(int(math.log2(mid)))"}, {"source_code": "n,a,b = map(int,input().split())\na,b = (min(a,b)),max(a,b)\nmaxst = 0\nwhile n != 1:\n maxst += 1\n n //= 2\ntmp = b - a\ncurst = 0\nwhile tmp != 1:\n curst += 1\n tmp //= 2\nif a == b - 1 and a % 2 ==0:\n curst += 1\nif (curst + 1 == maxst):\n print('Final!')\nelse:\n print(curst + 1)"}, {"source_code": "from fractions import gcd\nfrom math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin\nfrom itertools import *\nfrom fractions import Fraction\nimport string\nimport copy\nimport random\nimport bisect\nfrom decimal import *\ndef id_generator(size=20, chars=string.digits):\n\treturn ''.join(random.choice(chars) for _ in range(size))\n \ndef mp():\n\treturn map(int,str(raw_input()).split())\n \nn,a,b=mp()\nans=1\nval=n\nwhile n>0:\n\tn/=2\n\tif a in [1,2] and b in [1,2]:\n\t\tbreak\n\ta=(a+1)/2\n\tb=(b+1)/2\n\tans+=1\n\nif pow(2,ans)==val:\n\tprint 'Final!'\nelse:\n\tprint ans"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=0\nif a%2==0:\n v-=a-2 \nelse:\n v-=a-1\nif v-b>=2: \n if b%2==0:\n v-=v-(b+1)\n else:\n v-=v-(b+2)\nfor i in range(8):\n v/=2\n if v<=2:\n c+=1\n break\n else:\n c+=1\nprint(c)"}, {"source_code": "import sys\nfrom math import log\ninput = sys.stdin.readline\ndef prog():\n n,a,b = map(int,input().split())\n if a <= n//2 and b > n//2 or a > n//2 and b <= n//2:\n print('Final!')\n else:\n print(log(n)/log(2) -1)\nprog()\n"}, {"source_code": "#!/usr/bin/python\nimport math\n\nn,a,b = raw_input().split()\nn = int(n)\na = int(a)\nb = int(b)\n\nrou = math.floor(math.log(abs(b - a), 2)) + 1\ntrou = math.log(n, 2)\n\nif rou == trou:\n\tprint 'Final!'\nelse:\n\tprint int(rou)\n\t"}, {"source_code": "GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())\n\nfrom math import log\ndef main():\n n, a, b = GIS()\n final = log(n, 2)\n d = abs(b - a)\n rounds = int(log(d, 2)) + 1\n if rounds == 1 and (a - 1) // 2 != (b - 1) // 2:\n rounds += 1\n print(rounds if rounds < final else 'Final!')\n\nmain()\n111\n2\n33\n4\n555\n6\n77\n8\n"}, {"source_code": "from math import log\nn,a,b = map(int, input().split())\nmax_r=round(log(n, 2))\nr=round(log(abs(a-b), 2) + 1)\nif r == max_r:\n print(\"Final!\")\nelse:\n print(r)"}, {"source_code": "#!/usr/bin/python\nimport math\n\nn,a,b = raw_input().split()\nn = int(n)\na = int(a)\nb = int(b)\n\nrou = math.floor(math.log(abs(b - a), 2)) + 1\ntrou = math.log(n, 2)\n\nif rou == trou:\n\tprint 'Final!'\nelse:\n\tprint int(rou)\n\t"}, {"source_code": "from math import log, ceil\n\nn, a, b = map(int, input().split())\n\nct = int(ceil(log(abs(a - b), 2))) + 1\n\nprint(\"Final!\" if 2 ** ct >= n else ct)\n"}, {"source_code": "from sys import exit\nn, a, b = [int(i) for i in input().split()]\nif a > b:\n a, b = b, a\nar = list(range(1, n + 1))\nrnd= 0\nwhile len(ar) > 2:\n cr = []\n rnd += 1\n for i in range(0, len(ar), 2):\n if ar[i] == a and ar[i + 1] == b:\n print(rnd)\n exit(0)\n else:\n cr.append(ar[i])\n ar.clear()\n for i in cr:\n ar.append(i)\nprint(\"Final!\")\n"}, {"source_code": "z = list(input().split())\nn = int (z[0])\na = int (z[1])\nb = int (z[2])\nif a%2==0:\n a=a\nelse:\n a=a+1\nif b%2==0:\n b=b\nelse:\n b=b+1\ns=b-a\nd=0\nwhile s>=2:\n s=s/2\n d=d+1\nk=0\nwhile n>=2:\n n=n/2\n k=k+1\nif k==d+1:\n print('FINAL')\nelse:\n print(d+1)"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=0\nm=v/2\nif ((a<=v/2)and(b>v/2))or((a>v/2)and(b<=v/2)):\n print(\"Final!\")\nelse:\n for i in range(8):\n v/=2\n if v==1:\n for g in range(8):\n if ((a<=m/2)and(b>m/2))or((a>m/2)and(b<=m/2)):\n print(c)\n break\n else:\n c-=1\n m/=2\n break\n else:\n c+=1\n"}, {"source_code": "x=[int(i)for i in input().split()]\nif x[2]<x[1]:\n x[1],x[2]=x[2],x[1]\nif x[1]<=x[0]//2 and x[0]//2<x[2]:\n print(\"Final!\")\nelse:\n if x[1]<=x[0]//2 and x[2]<=x[0]//2:\n pass\n else:\n x[1]=x[1]-x[0]//2\n x[2]=x[2]-x[0]//2\n k=0\n while True:\n if x[1]<=x[0]//2 and x[0]//2<=x[2]:\n x[0]=x[0]//2\n while x[0]!=1:\n k+=1\n x[0]=x[0]//2\n print(k)\n break\n x[0]=x[0]//2\n"}, {"source_code": "n,a,b=map(int,input().split())\nif abs(a-b)<(n/2):\n print(abs(a-b))\nelse:\n print(\"Final!\")"}, {"source_code": "import math\nn,a,b = map(int, input().split())\nif n==2:\n print('Final!')\nelse:\n mid=n//2\n if a<=mid and b>mid or a>mid and b<=mid:\n print('Final!')\n elif min(a,b)%2 != 0 and abs(a-b)==1:\n print(1)\n elif max(a,b)+1==mid//2: print(int(math.log2(mid//2)))\n else: \n print(int(math.log2(mid)))"}, {"source_code": "def log2(n):\n ret = 1\n p = 2\n while True:\n if p == n:\n break\n p *= 2\n ret += 1\n return ret\n \nn, a, b = map(int, input().split())\nans = log2(n)\ninf = 0\nsup = n\nn = inf + sup // 2\nif n >= min(a, b) and n < max(a, b):\n ans = \"Final!\"\nelse:\n while True:\n n = (inf + sup) // 2\n if n >= min(a, b) and n < max(a, b):\n ans = ans - 1\n break\n else:\n if n >= max(a, b):\n sup = n\n else:\n inf = n\nprint(ans)\n"}, {"source_code": "from math import log, ceil\n\nn, a, b = map(int, input().split())\n\na -= 1\nb -= 1\n\na -= a % 2\nb += 1 - b % 2\n\nct = int(ceil(log(abs(a - b) + 1, 2)))\n\nprint(\"Final!\" if 2 ** ct == n else ct)\n"}, {"source_code": "import math\nn,a,b=map(int,input().split())\nif abs(a-b)<(n/2):\n y=math.log(abs(a-b),2)\n print(math.floor(y)+1)\nelse:\n print(\"Final!\")"}, {"source_code": "import math\nn,a,b = map(int, input().split())\nif n==2:\n print('Final!')\nelse:\n mid=n//2\n if a<=mid and b>mid or a>mid and b<=mid:\n print('Final!')\n elif min(a,b)%2 != 0 and abs(a-b)==1:\n print(1)\n elif max(a,b)+1==mid//2: print(int(math.log2(mid//2)))\n else: \n print(int(math.log2(mid)))"}, {"source_code": "n, eq1, eq2 = map(int, raw_input().split())\n\ntimes = []\nfor i in range(n):\n\ttimes.append(i+1)\n\nrodada = 0\nflag = False\na = n\nfor j in range(n/2):\n\tif flag:\n\t\tbreak\n\trodada += 1\n\tt = []\n\tfor i in range(0, a, 2):\n\t\tif (times[i] == eq1 and times[i+1] == eq2) or (times[i] == eq2 and times[i+1] == eq1):\n\t\t\tflag = True\n\t\t\tt.append(eq1)\n\t\t\tbreak\n\t\telif times[i] == eq1 or times[i] == eq2:\n\t\t\tt.append(times[i]) \n\t\telse:\n\t\t\tt.append(times[i+1])\n\ttimes = t\n\ta /= 2\nif n/2 -1 == rodada and rodada != 1:\n\tprint \"Final!\"\nelse:\n\tprint rodada\n"}, {"source_code": "import math,sys\n\nn,a,b = list(map(int,input().split()))\n\nlow = 1\nhigh = n\ns = int(math.log(n,2))\n\nwhile low + 0.5 < high: \n if high + low % 2 == 0:\n mid = (high + low + 1) / 2\n else:\n mid = (high + low) / 2\n\n if min(a,b) < mid and max(a,b) > mid:\n break\n if min(a,b) >= mid:\n low = int(mid)\n elif max(a,b) <= mid:\n high = int(mid)\n \n s -= 1\n\nif s == int(math.log(n,2)): \n print(\"Final!\")\nelse:\n print(s)\n"}, {"source_code": "import math as m\nn, a, b = map(int, input().split())\nif a > b:\n a, b = b, a\nkek = int(m.log2(n))\n\nfor i in range(kek-1, 0, -1):\n\tfor j in range(1, 2**(kek-i)):\n\t\tif j*(2**i) < b and a <= j*(2**i):\n\t\t\t# print(i, j, j*(2**i))\n\t\t\tif i == kek-1:\n\t\t\t\tprint('Final!')\n\t\t\t\texit()\n\t\t\telse:\n\t\t\t\tprint(i+1)\n\t\t\t\texit()\nprint(1)"}, {"source_code": "import math\nn,a,b=map(int,input().split())\nfor i in range(1,8):\n a=math.ceil(a/2);b=math.ceil(b/2)\n if a==b:\n if (2**i)==n:\n print('Final!')\n else:\n print(i)\n exit(0)\n\n \n"}, {"source_code": "a,b,c=map(int,input().split())\nz=[*range(1,a+1)]\nb,c=sorted([b,c])\ns=0;k=a\nwhile 1:\n p=[]\n for i in range(0,k,2):\n if z[i]==b and z[i+1]==c:\n if len(z)==2:print(\"Final!\")\n else:print(s)\n exit()\n elif z[i]==b:p+=[z[i]]\n elif z[i+1]==b:p+=[z[i+1]]\n elif z[i] == c:p += [z[i]]\n elif z[i + 1] == c:p += [z[i + 1]]\n else:p+=[z[i]]\n k//=2;z=p;s+=1\n\n"}, {"source_code": "s = input()\nn = int(s.split(' ')[0])\na = int(s.split(' ')[1])\nb = int(s.split(' ')[2])\nz = n\nr = 1\nt = 0\nendd = 0\nsuper = 0\nwhile z>1:\n #print(r, a, b)\n if ((b-a==1)or(a-b==1))and(endd==0):\n #print('end')\n endd = 1\n t = r\n if z//2==1:\n super=1\n z=z//2\n a=a//2\n b=b//2\n r+=1\n#print(n, a, b)\nif super==1:\n print('Final!')\nelse:\n print(t)"}, {"source_code": "from math import log2\nn, a, b = map(int, input().split())\nn1= n\nfinal = int(log2(n))\nans = 1\nwhile(abs(a-b) > 1):\n if a != 1: \n a//=2\n if b != 1:\n b//=2\n \n ans+=1\nif(ans != final):\n print(ans)\nelse:\n print(\"Final!\")"}, {"source_code": "from math import log2\nn, a, b = map(int, input().split())\nn1= n\nfinal = int(log2(n))\nans = 1\nwhile abs(a-b) > 1 or min(a, b) % 2 == 0:\n if a != 1:\n a//=2\n if(b != 1):\n b//=2\n ans+=1\nif(ans != final):\n print(ans)\nelse:\n print(\"Final!\")"}, {"source_code": "import sys,math\nn,a,b=map(int,sys.stdin.readline().split())\nans=0\nflag=True\nwhile(n>2):\n a//=2 \n b//=2 \n ans+=1\n if a==b:\n print(ans)\n flag=False\n break\n n//=2\nif flag:\n print(\"Final!\")\n \n \n \n"}, {"source_code": "import math\n\ndef powerTwo(n):\n power = 0\n while(math.pow(2, power) != n):\n power += 1\n return power\n \nn, a, b = map(int, input().split())\ndiff = abs(a - b)\nrounds = diff // 2 + 1\nif (rounds == powerTwo(n)):\n print(\"Final!\")\nelse:\n print(rounds)"}, {"source_code": "import sys\nfrom math import log\ninput = sys.stdin.readline\ndef prog():\n n,a,b = map(int,input().split())\n if a <= n//2 and b > n//2 or a > n//2 and b <= n//2:\n print('Final!')\n else:\n print(int(log(n)/log(2) -1))\nprog()\n"}, {"source_code": "n,a,b=map(int,input().split())\nif abs(a-b)<(n/2):\n print(abs(a-b))\nelse:\n print(\"Final!\")"}, {"source_code": "rounds={2:1,4:2,8:3,16:4,32:5,64:6,128:7,256:8}\n\np=list(map(int,input().split()))\nfinal=rounds[p[0]]\nif(p[1]>p[0]//2 and p[2]>p[0]//2):\n\tif(abs(p[1]-p[2])==1):\n\t\tprint(1)\n\telse:\n\t\tcount=0\n\t\tdiff=abs(p[1]-p[2])\n\t\twhile(diff>=1):\n\t\t\tdiff=diff//2\n\t\t\tcount=count+1\n\t\tif(count==final):\n\t\t\tprint(\"Final!\")\n\t\telse:\n\t\t\tprint(count)\nelif(p[1]<=(p[0]//2) and p[2]<=(p[0]//2)):\n\tif(abs(p[1]-p[2])==1):\n\t\tprint(1)\n\telse:\n\t\tcount=0\n\t\tdiff=abs(p[1]-p[2])\n\t\twhile(diff>=1):\n\t\t\tdiff=diff//2\n\t\t\tcount=count+1\n\t\tif(count==final):\n\t\t\tprint(\"Final!\")\n\t\telse:\n\t\t\tprint(count)\nelse:\n\tprint(\"Final!\")"}, {"source_code": "n, a, b = map(int, input().split())\na, b = min(a, b), max(a, b)\nif a < n // 2 and b >= n // 2:\n print('Final!')\nelse:\n sum = 0;\n while a != b:\n a = (a + 1) // 2\n b = (b + 1) // 2\n sum += 1\n print(sum)"}, {"source_code": "import math\nn,a,b=map(int,input().split());coun=0\nnm=int(round(math.log(n,2)))\nz=abs(math.ceil(a/2)-math.ceil(b/2))\nprint([z+1,\"Final!\"][z+1==nm])"}, {"source_code": "from math import *\nn, a, b = map(int, input().split())\na, b = min(a, b), max(a, b)\ndist = b - a - 1\nans = 1\nwhile dist > 0:\n ans += 1\n if dist % 2 == 0:\n dist //= 2\n else:\n dist -= (dist + 1) // 2\nif ans == log2(n):\n print('Final !')\nelse:\n print(ans)"}, {"source_code": "total_teams,team1,team2 = map(int,input().split())\n\ncount = 1\nwhile True:\n\tif round((team1/2)+0.1)==round((team2/2)+0.1):\n\t\tbreak\n\t\n\tteam1=round((team1/2)+0.1)\n\tteam2=round((team2/2)+0.1)\n\ttotal_teams//=2\n\tcount+=1\n\t\nif total_teams==2:\n print('Final\t!')\nelse:\n\n print(count)\n"}, {"source_code": "import math\nn,a,b = map(int, input().split())\nif n==2:\n print('Final!')\nelse:\n mid=n//2\n if a<=mid and b>mid or a>mid and b<=mid:\n print('Final!')\n elif min(a,b)%2 != 0 and abs(a-b)==1:\n print(1)\n elif max(a,b)+1==mid//2: print(int(math.log2(mid//2)))\n else: \n print(int(math.log2(mid)))"}, {"source_code": "n, a, b = map(int, input().split())\nq = n\nfinal = 0\nwhile q != 2:\n final += 1\n q /= 2\nif a % 2 == 1:\n a += 1\nif b % 2 == 1:\n b += 1\nif a == b:\n print(1)\n exit(0)\nfi = abs(a-b) // 2 + 1\nif fi == final:\n print(\"Final!\")\nelse:\n print(fi)"}, {"source_code": "n,a,b=map(int,input().split())\nl=list(range(1,n+1))\n\ndef getRoundNumber(l,n,a,b,count):\n\tif len(l)==2:\n\t\treturn 10000\n\ttemp=[]\n\tfor i in range(0,len(l)-1,2):\n\t\tif l[i]==a and l[i+1]==b:\n\t\t\treturn count\n\t\telif l[i]==a and l[i+1]!=b:\n\t\t\ttemp.append(l[i])\n\t\telif l[i]!=a and l[i+1]==b:\n\t\t\ttemp.append(l[i+1])\n\t\telse:\n\t\t\ttemp.append(l[i])\n\tn=n//2\n\treturn getRoundNumber(temp,n,a,b,count+1)\n\nif a>b:\n\tcount=getRoundNumber(l,n,b,a,1)\n\tif count==10000:\n\t\tprint('Final!')\n\telse:\n\t\tprint(count)\nelse:\n\tcount=getRoundNumber(l,n,a,b,1)\n\tif count==10000:\n\t\tprint('Final!')\n\telse:\n\t\tprint(count)"}, {"source_code": "n, a, b = map(int, input().split())\ncnt = 1\n\na += a % 2\nb += b % 2\nwhile a != b:\n cnt += 1\n a /= 2\n b /= 2\n a += a % 2\n b += b % 2\nif 2 ** cnt == n:\n print('final!')\nelse:\n print(cnt)\n \n\n\n "}, {"source_code": "[n,a,b]=[int(x)-1 for x in input().split()]\nres=0\nwhile a!=b:\n a//=2\n b//=2\n res+=1\nif res==n+1:\n res=\"Final!\"\nprint(res)"}, {"source_code": "n,a,b = map(int, raw_input().split())\npot = 0\nwyn = 1\npot_a = 0\npot_b = 0\nwhile n != 1:\n n = n/2\n pot += 1\npot_a = (a+1)/2\npot_b = (b+1)/2\n#print pot_a, pot_b\nwyn += abs(pot_a-pot_b)\nif wyn == pot:\n print 'Final!'\nelse:\n print wyn"}, {"source_code": "#!/usr/bin/python\nimport math\n\nn,a,b = raw_input().split()\nn = int(n)\na = int(a)\nb = int(b)\n\nif a % 2 != 0:\n\ta += 1\nif b % 2 != 0:\n\tb += 1\n\nif a == b:\n\trou = 1\nelse:\n\trou = math.floor(math.log(abs(b - a), 2)) + 1\ntrou = math.log(n, 2)\n\nif rou == trou:\n\tprint 'Final!'\nelse:\n\tprint int(rou)\n\t"}, {"source_code": "total_teams,team1,team2 = map(int,input().split())\n\nteams = [x for x in range(total_teams)]\nteam1-=1\nteam2-=1\ncount=1\ncheck=0\nif abs(team1-team2)==1:\n print(count)\nelse:\n \n while True:\n new_team=[]\n \n for i in range(0,len(teams)-1,2):\n \n if teams[i]==team1 or teams[i+1]==team1:\n new_team.append(team1)\n elif teams[i]==team2 or teams[i+1]==team2:\n new_team.append(team2)\n else:\n new_team.append(0)\n teams = new_team\n for i in range(len(teams)-1):\n if team1 == teams[i] and team2 == teams[i+1]:\n check=1\n break\n elif team1 == teams[i+1] and team2 == teams[i]:\n check=1\n break\n if check==1:\n break\n count+=1\n \n \n\n if len(teams)==2:\n print('Final!')\n else:\n print(count+1)\n"}, {"source_code": "n,a,b=map(int,input().split())\nl=list(range(1,n+1))\n\ndef getRoundNumber(l,n,a,b,count):\n\tif len(l)==2:\n\t\treturn 10000\n\ttemp=[]\n\tfor i in range(0,len(l)-1,2):\n\t\tif l[i]==a and l[i+1]==b:\n\t\t\treturn count\n\t\telif l[i]==a and l[i+1]!=b:\n\t\t\ttemp.append(l[i])\n\t\telif l[i]!=a and l[i+1]==b:\n\t\t\ttemp.append(l[i+1])\n\t\telse:\n\t\t\ttemp.append(l[i])\n\tn=n//2\n\treturn getRoundNumber(temp,n,a,b,count+1)\n\nif a>b:\n\tcount=getRoundNumber(l,n,b,a,1)\n\tif count==10000:\n\t\tprint('Final!')\n\telse:\n\t\tprint(count)\nelse:\n\tcount=getRoundNumber(l,n,a,b,1)\n\tif count==10000:\n\t\tprint('Final!')\n\telse:\n\t\tprint(count)"}, {"source_code": "n, a, b = map(int, input().split())\na, b = a - 1, b - 1\ncount = 1\nwhile a // 2 != b // 2:\n\tcount += 1\n\ta //= 2\n\tb //= 2\nif 2 ** count == n:\n\tprint(\"Final\")\nelse:\n\tprint(count)\n"}, {"source_code": "x=[int(i)for i in input().split()]\nif x[2]<x[1]:\n x[1],x[2]=x[2],x[1]\nif x[1]<=x[0]//2 and x[0]//2<x[2]:\n print(\"Final!\")\nelse:\n if x[1]<=x[0]//2 and x[2]<=x[0]//2:\n pass\n else:\n x[1]=x[1]-x[0]//2\n x[2]=x[2]-x[0]//2\n k=0\n while True:\n if x[1]<=x[0]//2 and x[0]//2<=x[2]:\n if x[1]+1==x[2]:\n print(1)\n break\n else:\n while x[0]!=1:\n k+=1\n x[0]=x[0]//2\n print(k)\n break\n x[0]=x[0]//2"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=0\nm=True\nif a%2==0:\n v-=a-2\n m=False\nelse:\n v-=a-1\n m=False\nif v-b>=2:\n m=False\n if b%2==0:\n v-=v-(b+1)\n else:\n v-=v-(b+2)\nif m==True:\n print(\"Final!\")\nfor i in range(8):\n v/=2\n if v<=2:\n c+=1\n break\n else:\n c+=1\nprint(c)"}, {"source_code": "n, a, b = map(int, input().split())\nmas = list(range(1, n + 1))\ndef pars(mas):\n gas = []\n for i in range(0, len(mas), 2):\n gas.append(mas[i:i+2])\n return gas\nif a % 2 == 0:\n a -= 1\nif b % 2 == 0:\n b -= 1\nwhile True:\n gas = []\n l = pars(mas)\n for el in l:\n if a in el and b in el:\n if len(l) == 1:\n print(\"final\")\n exit(0)\n else:\n print(n // (len(l) * 2))\n exit(0)\n elif a in el:\n gas.append(a)\n elif b in el:\n gas.append(b)\n else:\n gas.append(el[0])\n mas = gas.copy()"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\nlista = [i for i in range(1, n+1)]\n\ncont = 0\nresp = False\nwhile len(lista) != 2:\n aux = []\n cont += 1\n for i in range(1,len(lista), 2):\n if (lista[i] == a or lista[i] == b) and (lista[i-1] == a or lista[i-1] == b):\n resp = True\n break\n elif lista[i] == a or lista[i] == b: aux.append(i+1)\n elif lista[i-1] == a or lista[i-1] == b: aux.append(i)\n else: aux.append(i)\n \n lista = aux[:]\n if resp: break\n\nif len(lista) == 2: print \"Final!\"\nelse: print cont"}, {"source_code": "import math\n\n\ndef read():\n return [int(v) for v in input().split()]\n\n\ndef main():\n n, a, b = read()\n m = int(math.log(max(a, b) - min(a, b), 2)) + 1\n if 2 ** m == n:\n print('Final!')\n else:\n print(m)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=0\nm=True\nif a%2==0:\n v-=a-2\n m=False\nelse:\n v-=a-1\n m=False\nif v-b>=2:\n m=False\n if b%2==0:\n v-=v-(b+1)\n else:\n v-=v-(b+2)\nif m==True:\n print(\"Final!\")\nfor i in range(8):\n v/=2\n if v<=2:\n c+=1\n break\n else:\n c+=1\nprint(c)"}, {"source_code": "import math\n\ndef powerTwo(n):\n power = 0\n while(math.pow(2, power) != n):\n power += 1\n return power\n \nn, a, b = map(int, input().split())\ndiff = abs(a - b)\nrounds = diff // 2 + 1\nif (rounds == powerTwo(n)):\n print(\"Final!\")\nelse:\n print(rounds)"}, {"source_code": "v,a,b=list(map(int,input().split()))\nif ((a<=v/2)and(b<=v/2))or((a>v/2)and(b>v/2)):\n print(\"Final!\")\nelse: \n c=2\n m=1\n for i in range(8):\n if abs(a-b)<c:\n print(m)\n break\n else:\n c*=2\n m+=1"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\nlista = [i for i in range(1, n+1)]\n\ncont = 0\nresp = False\nwhile len(lista) != 2:\n aux = []\n cont += 1\n for i in range(1,len(lista), 2):\n if (lista[i] == a or lista[i] == b) and (lista[i-1] == a or lista[i-1] == b):\n resp = True\n break\n elif lista[i] == a or lista[i] == b: aux.append(i+1)\n elif lista[i-1] == a or lista[i-1] == b: aux.append(i)\n else: aux.append(i)\n \n lista = aux[:]\n if resp: break\n\nif len(lista) == 2: print \"Final!\"\nelse: print cont"}, {"source_code": "from math import log, ceil\n\nn, a, b = map(int, input().split())\n\nct = int(ceil(log(abs(a - b), 2))) + 1\n\nprint(\"Final!\" if 2 ** ct >= n else ct)\n"}, {"source_code": "n,a,b=map(int,input().split())\ncnt=0\nwhile(n>1):\n cnt+=1\n n=n//2\nif abs(a-b)>=cnt:\n print(\"Final!\")\nelif a%2==0 and b%2!=0:\n print(abs(a-b)+1)\nelse:\n print(abs(a-b))\n "}, {"source_code": "\nn,a,b = [int(i) for i in input().split()]\n\na -= 1\nb -= 1\nk = 1\n\nwhile abs(a - b) != 1:\n a = a // 2\n b = b // 2\n n = n // 2\n k += 1\n\nif n == 2:\n print('Final!')\nelse:\n print(k)\n"}, {"source_code": "import math\nn,a,b = map(int,input().split())\nr=abs(b-a)\nt=int(math.log(r,2))+1\nif r==1 and max(a,b)%2==0 and t!=math.log(n,2):\n\tprint(1)\nelif t==math.log(n,2):\n\n\n\tprint(\"Final!\")\nelse:\n\tprint(t)"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\nlista = [i for i in range(1, n+1)]\n\ncont = 1\nresp = False\n\nwhile len(lista) != 2:\n aux = []\n if abs(lista.index(a)-lista.index(b)) == 1:\n resp = True\n break\n\n cont += 1\n for i in range(1,len(lista), 2):\n if lista[i] == a or lista[i] == b: aux.append(lista[i])\n elif lista[i-1] == a or lista[i-1] == b: aux.append(lista[i-1])\n else: aux.append(lista[i-1])\n \n lista = aux[:]\n\nif len(lista) == 2: print \"Final!\"\nelse: print cont"}, {"source_code": "import math\n\nstr_data = input().split()\n\ncount = int(str_data[0])\na1 = int(str_data[1])\na2 = int(str_data[2])\n\nk1 = min(a1, a2)\nk2 = max(a1, a2)\n\nmax_rounds = math.log(count, 2)\nres = int(math.log(k2 - k1, 2)) + 1\n\nif res == max_rounds:\n print('Final!')\nelse:\n print(res)\n"}, {"source_code": "n, a, b = map(int, input().split())\ncnt = 0\n\nwhile(n>2):\n cnt += 1\n if(abs(a-b) == 1 and a//2 == b//2):\n break\n if(a%2==1):\n a +=1\n a = a//2\n if(b%2==1):\n b +=1\n b = b//2\n n/=2\n\n\nif(n==2 and a + b == 3):\n print(\"Final!\")\nelse:\n print(cnt)\n\n\n\n\n\n\n\n\n"}, {"source_code": "n, a, b = map(int, input().split())\n\ncommand = list(range(1, n + 1))\n\na, b = min(a, b), max(a, b)\n\ni = 0\n\nwhile True:\n i += 1\n try:\n if command == [a, b]:\n print('Final!')\n break\n if abs(command.index(b) - command.index(a)) == 1:\n print(i)\n break\n except:\n print(i)\n break\n k = command[::2]\n if a not in k or b not in k:\n k = command[1::2]\n command = k\n\n"}, {"source_code": "s = input()\nn = int(s.split(' ')[0])\na = int(s.split(' ')[1])\nb = int(s.split(' ')[2])\nz = n\nr = 1\nt = 0\nendd = 0\nsuper = 0\nwhile endd==0:\n #print(z, r, a, b)\n if ((b-a==1)or(a-b==1))and(endd==0):\n #print('end')\n endd = 1\n t = r\n if (z//2==1)or(z//2==0):\n super=1\n z=z//2\n a=a//2\n b=b//2\n r+=1\n#print(n, a, b)\nif super==1:\n print('Final!')\nelse:\n print(t)"}, {"source_code": "a=[int(i)for i in input().split()]\nb=a[1]\nc=a[2]\nif b>c:\n c,b=b,c\nif a[1]>a[2]:\n a[2],a[1]=a[1],a[2]\nif a[0]//2>=b and a[2]>a[0]//2:\n print(\"Final!\")\nelse:\n if b>c:\n c,b=b,c\n j=1\n while b+1!=c:\n if c<b:\n break\n c=c-j\n b*=2\n j+=1\n print(j)"}, {"source_code": "n,a,b= map(int, input().split())\ni=1\nk=0\nf=False\nwhile i<n:\n if (a-1)//i ==(b-1)//i:\n f=True\n i*=2\n k+=1\nif f==True:\n print(k-1)\nelse:\n print('Final!')\n"}, {"source_code": "n,a,b=map(int,input().split())\nif abs(a-b)<(n/2):\n print(abs(a-b))\nelse:\n print(\"Final!\")"}, {"source_code": "import math\nn,a,b=map(int,input().split())\nfor i in range(1,8):\n a=math.ceil(a/2);b=math.ceil(b/2)\n if a==b:\n if (2**i)==n:\n print('Final!')\n else:\n print(i)\n exit(0)\n\n \n"}, {"source_code": "n, a, b = map(int, input().split())\na, b = min(a, b), max(a, b)\nif a < n // 2 and b >= n // 2:\n print('Final!')\nelse:\n sum = 0;\n while a != b:\n a = (a + 1) // 2\n b = (b + 1) // 2\n sum += 1\n print(sum)"}, {"source_code": "n,a,b=map(int,input().split())\nl,r=0,n\nif a>b:\n b,a=a,b\nfrom math import log\nans=int(log(n,2))\nx=(l+r)//2\nwhile x:\n if b>x and a<=x:\n break\n ans-=1\n if x<b:\n l=x\n else:\n r=x\n x=(l+r)//2\nprint(ans if ans**2<n else 'Final!')"}, {"source_code": "a,b,c=map(int,input().split())\nz=[*range(1,a+1)]\nb,c=sorted([b,c])\ns=0;k=a\nwhile 1:\n p=[]\n for i in range(0,k,2):\n if z[i]==b and z[i+1]==c:\n if len(z)==2:print(\"Final!\")\n else:print(s)\n exit()\n elif z[i]==b:p+=[z[i]]\n elif z[i+1]==b:p+=[z[i+1]]\n elif z[i] == c:p += [z[i]]\n elif z[i + 1] == c:p += [z[i + 1]]\n else:p+=[z[i]]\n k//=2;z=p;s+=1\n\n"}, {"source_code": "import math\nn,a,b=map(int,input().split());coun=0\nnm=int(round(math.log(n,2)))\nz=abs(math.ceil(a/2)-math.ceil(b/2))\nprint([z+1,\"Final!\"][z+1==nm])"}, {"source_code": "from math import log, ceil\n\nn, a, b = map(int, input().split())\n\nct = int(ceil(log(abs(a - b) + 1, 2)))\n\nprint(\"Final!\" if 2 ** ct == n else ct)\n"}, {"source_code": "\nn, a, b = map(int, input().split())\npower = 1\nwhile 2 ** power < n:\n power += 1\n\na, b = min(a, b), max(a, b)\n\nn1 = a - 1\nn2 = b - a - 1\nn3 = n - b\n\nround_num = 0\nwhile n2 > 0 or (n1 > 0 and n1 % 2 == 1):\n round_num += 1\n if n1 % 2 == 1:\n n1 //= 2\n else:\n n1 //=2\n n2 -= 1\n if n3 % 2 == 1:\n n3 //= 2 \n else:\n n3 //= 2\n n2 -= 1\n \nprint(\"Final!\" if power == round_num + 1 else round_num + 1)\n"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=[]\nm=True\ng=1\nfor i in range(v):\n c.append([i+1])\nfor i in range(int(v/2)):\n c[i].append(c[i+1][0])\n c.remove(c[i+1])\n if len(set(c[i]).intersection(set([a,b])))==2:\n print(1)\n m=False\n break\nif m==True:\n for i in range(8):\n v=v/2\n g+=1\n for j in range(int(v/2)):\n if len(c)==2:\n m=False\n print(\"Final!\")\n break\n for l in range(len(c[j+1])):\n c[j].append(c[j+1][l])\n c.remove(c[j+1])\n if len(set(c[j]).intersection(set([a,b])))==2:\n print(g)\n m=False\n break\n if m==False:\n break"}, {"source_code": "import math\nn,a,b = map(int,input().split())\nr=abs(b-a)\nt=int(math.log(r,2))+1\nif r==1 and max(a,b)%2!=0 and t!=math.log(n,2):\n\tprint(1)\nelif t==math.log(n,2):\n\n\n\tprint(\"Final!\")\nelse:\n\tprint(t)"}, {"source_code": "n,a,b=map(int,input().split())\n\nround=0\ntemp=n\nwhile temp>1:\n\tround+=1\n\ttemp//=2\nmax_round=round\nif a>b:\n\ta,b=b,a\nmid=n//2\nwhile round>1:\n\tif a<=mid and b>mid:\n\t\tbreak\n\tround-=1\n\tn//=2\n\tmid+=n//2 if mid+n//2<b else -n//2\nprint('Final!' if round==max_round else round)"}, {"source_code": "from math import log, ceil\n\nn, a, b = map(int, input().split())\n\nct = int(ceil(log(abs(a - b), 2))) + 1\n\nprint(\"Final!\" if 2 ** ct <= n else ct)\n"}, {"source_code": "v,a,b=list(map(int,input().split()))\nc=[]\nm=True\ng=1\nfor i in range(v):\n c.append([i+1])\nfor i in range(int(v/2)):\n c[i].append(c[i+1][0])\n c.remove(c[i+1])\n if len(set(c[i]).intersection(set([a,b])))==2:\n print(1)\n m=False\n break\nif m==True:\n for i in range(8):\n v=v/2\n g+=1\n for j in range(int(v/2)):\n if len(c)==2:\n m=False\n print(\"Final!\")\n break\n for l in range(len(c[j+1])):\n c[j].append(c[j+1][l])\n c.remove(c[j+1])\n if len(set(c[j]).intersection(set([a,b])))==2:\n print(g)\n m=False\n break\n if m==False:\n break"}, {"source_code": "'''input\n16 1 9\n'''\npo2 = [2,4,8,16,32,64,128,256,512]\nn,a,b = map(int,raw_input().split())\nx = abs(a-b)\nind = -1\nfor i in range(len(po2)):\n\tif x < po2[i]:\n\t\tind = i\n\t\tbreak\nif n == 1 << (i+1):\n\tprint \"Final!\"\nelse:\n\tprint i+1\n"}, {"source_code": "a,b,c = map(int,input().split())\nk = 1 #counter\n#iteratively:\nwhile(a>2):\n if b>c: c,b=b,c \n if c == b+1 and b%2==1:\n break\n a = a//2\n b = (b+1)//2\n c = (c+1)//2\n k +=1\n print(a,b,c)\nif a>2:\n print(k)\nelse:\n print(\"Final!\")"}, {"source_code": "n,a,b = map(int,input().split())\nx = max(a,b)\ny = min(a,b)\nn = int(n/2)\n\nif y <= n and x> n:\n print(\"Final!\")\n \nelse:\n if (x&1 and y&1) or (x&1 == 0 and y&1) or (y&1 == 0 and x&1):\n z= x+y\n while z>n:\n z//=2\n print(z) \n else:\n z= x+y-1\n while z>n:\n z//=2\n print(z) \n \n"}, {"source_code": "n, a, b = map(int, input().split())\nr = abs(a-b).bit_length()\nprint('Final!' if r == (n-1).bit_length() else r)"}, {"source_code": "# vars: a, b, ca, cb, cx, res, n\nn, a, b = map(int, input().split())\nca = min(a, b)-1\ncb = max(a, b)-1\ncx = n//4\nres = 1\nwhile cx:\n\tif (ca % 2) != (cb % 2):\n\t\tprint(res)\n\t\texit()\n\tca //= 2\n\tcb //= 2\n\tcx //= 2\n\tres += 1\nprint('Final!')\n"}, {"source_code": "import math,sys\n\nn,a,b = list(map(int,input().split()))\n\nlow = 1\nhigh = n\ns = int(math.log(n)) + 1\n\nwhile low + 0.5 < high:\n if high + low % 2 == 0:\n mid = (high + low + 1) / 2\n else:\n mid = (high + low) / 2\n\n if min(a,b) < mid and max(a,b) > mid:\n break\n if min(a,b) >= mid:\n low = int(mid)\n elif max(a,b) <= mid:\n high = int(mid)\n \n s -= 1\n\nif s == int(math.log(n)) + 1: \n print(\"Final!\")\nelse:\n print(s)\n"}, {"source_code": "v,a,b=list(map(int,input().split()))\nif ((a<=v/2)and(b<=v/2))or((a>v/2)and(b>v/2)):\n print(\"Final!\")\nelse: \n c=2\n m=1\n for i in range(8):\n if abs(a-b)<c:\n print(m)\n break\n else:\n c*=2\n m+=1"}, {"source_code": "import math\n\n\ndef read():\n return [int(v) for v in input().split()]\n\n\ndef main():\n n, a, b = read()\n m = int(math.log(max(a, b) - min(a, b), 2)) + 1\n if 2 ** m == n:\n print('Final!')\n else:\n print(m)\n\n\nif __name__ == '__main__':\n main()\n"}], "src_uid": "a753bfa7bde157e108f34a28240f441f"} {"source_code": "# AC\nimport sys\n\n\nclass Main:\n def __init__(self):\n self.buff = None\n self.index = 0\n\n def next(self):\n if self.buff is None or self.index == len(self.buff):\n self.buff = self.next_line()\n self.index = 0\n val = self.buff[self.index]\n self.index += 1\n return val\n\n def next_line(self):\n return sys.stdin.readline().split()\n\n def next_ints(self):\n return [int(x) for x in sys.stdin.readline().split()]\n\n def next_int(self):\n return int(self.next())\n\n def solve(self):\n n = self.next_int()\n p, t = 0, 1\n r = set()\n s = set()\n r.add(p)\n while (p, t) not in s:\n s.add((p, t))\n p = (p + t) % n\n t = (t + 1) % n\n r.add(p)\n print('YES' if n == len(r) else 'NO')\n\n\nif __name__ == '__main__':\n Main().solve()\n", "positive_code": [{"source_code": "n = int(input())\n\nprint('NO' if n & n-1 else 'YES')"}, {"source_code": "print('NYOE S'[input() in {'1', '2', '4', '8', '16', '32', '64', '128', '256', '512'} :: 2])"}, {"source_code": "n = int(input())\nflag = 1\nwhile n > 1:\n if n % 2:\n flag = 0\n break\n n = n // 2\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\n\ndef main(n, parity):\n index = 0\n hassocks = [x for x in range(n)]\n for i in range(parity):\n index = (index + i) % n\n if index in hassocks:\n del hassocks[hassocks.index(index)]\n if hassocks == []:\n return 'YES'\n else:\n return 'NO'\n\nif n % 2 == 1:\n print(main(n, n))\nelse:\n print(main(n, (2 * n)))\n"}, {"source_code": "n = int(input())\nd= {}\nfor i in range(2*n) :\n\ta = int((i/2*(i+1))%n)\n\tif d.setdefault(a) == None :\n\t\td[a] = 1\n\n\nif len(d) == n :\n\tprint('YES')\nelse :\n\tprint('NO')\n\n"}, {"source_code": "n = int(input())\nvisited = [False] * n\nk = 0\nfor i in range(n ** 2 + 1):\n k += i + 1\n visited[k % n] = True\nfor i in visited:\n if not i:\n print(\"NO\")\n exit()\nprint(\"YES\")\n"}, {"source_code": "i = int(input())\nmods = [0] * i\nk = 0\nfor j in range(i):\n k += j\n mods[k % i] = 1\nif all(m == 1 for m in mods):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "class CodeforcesTask55ASolution:\n def __init__(self):\n self.result = ''\n self.n = 0\n\n def read_input(self):\n self.n = int(input())\n\n def process_task(self):\n hassocks = [x + 1 for x in range(self.n)]\n visits = set()\n visiting = 1\n for x in range(1000 * self.n):\n visiting += x\n visiting = visiting % self.n\n if not visiting:\n visiting = self.n\n visits.add(visiting)\n hassocks.sort()\n v = list(visits)\n v.sort()\n if v == hassocks:\n self.result = \"YES\"\n else:\n self.result = \"NO\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask55ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "n = int(input())\nl = [1]\nfor i in range(2, 2*n + 1):\n a = l[-1] + i-1\n if a > n:\n a = a%n\n l.append(a)\nr = set(l)\nif len(r) >= n:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\ntri=[]\nfor i in range(2,2009):\n tri.append(i*(i+1)//2)\nif n==1:\n print('YES')\n exit()\ncheck=[0]*n \nfor i in range(2*n+5):\n check[tri[i]%n]=1 \nif n&(n-1)==0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "ka=int(input())\nif(ka&(ka-1)>0):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n=int(input())\nprint(\"NO\" if n&(n-1) else \"YES\")\n"}, {"source_code": "n=int(input())\ntri=[]\nfor i in range(2,2009):\n tri.append(i*(i+1)//2)\nif n==1:\n print('YES')\n exit()\ncheck=[0]*n \nfor i in range(2*n+5):\n check[tri[i]%n]=1 \nif sum(check)==n:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\nn = int(sys.stdin.readline().strip())\nk = 0\na = [False for _ in xrange(n)]\nfor i in xrange(n + 1):\n a[k] = True\n k = (k + i) % n\nfor f in a:\n if not f:\n print \"NO\"\n sys.exit()\nprint \"YES\"\n"}, {"source_code": "import sys\nN = int(sys.stdin.readline())\nvisited = [False]*N\nm = 1\ncnt = 0\ni = 0\nwhile not visited[i]:\n cnt+=1\n m+=1\n visited[i] = True\n i = (i+m-1)%N\nif cnt == N:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "import sys\ndef readint(): return int(raw_input())\n\n\ndef run():\n\tn = readint()\n\ta = [False] * n\n\tp = 0\n\tfor k in xrange(1000000):\n\t\tp += k\n\t\tp %= n\n\t\ta[p] = True\n\tprint \"YES\" if all(a) else \"NO\"\nrun()"}, {"source_code": "from sys import stdin\ndi = {}\nn = int(stdin.readline())\nvis = set()\nvis.add(1)\ncur = 1\nll = 1\nwhile True:\n u = (cur,ll)\n if di.get(u,0)==1:\n break\n di[u] = 1\n cur = (cur+ll)%n\n if cur ==0:\n cur = n\n vis.add(cur)\n ll = (ll+1)%n;\nif len(vis)==n:\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "n=input()\na={}\np=0\nfor i in range(n):\n\tp=(p+i)%n\n\ta[p]=1\nprint'YES'if n==len(a)else'NO'\n"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "#\n# Flea\n#\n\n#N = 1\nN = int( raw_input() )\nvisited = [ False ] * N\nmods = [ -1 ] * N\ni = 0\nstep = 1\nv_count = 0\nwhile v_count < N :\n\tif visited[ i % N ] == False :\n\t\tv_count += 1\n\t\tvisited[ i % N ] = True\n\t\tmods[ i % N ] = step % N\n\telse :\n\t\tif mods[ i % N ] == step % N : break\n\ti += step\n\tstep += 1\nif v_count == N : print \"YES\"\nelse : print \"NO\"\n"}, {"source_code": "n=input();print[\"NO\",\"YES\"][n&n-1==0]"}, {"source_code": "n=input();print[\"NO\",\"YES\"][n&(n-1)==0]"}, {"source_code": "n = int(raw_input())\nz = 0\nK = [0] * n\n\nk = 0\nx = 0\nwhile x <= 1000:\n k += x\n while k >= n:\n k = k - n\n K[k] = 1\n x += 1\nif 0 in K:\n print 'NO'\nelse:\n print 'YES'\n \n"}, {"source_code": "n=input();print[\"YES\",\"NO\"][n&n-1>0]"}, {"source_code": "n = int(raw_input())\nK = [0] * n\n\nk = 0\nx = 0\nwhile x <= 2*n:\n k += x\n while k >= n:\n k = k - n\n K[k] = 1\n x += 1\nif 0 in K:\n print 'NO'\nelse:\n print 'YES'\n \n"}, {"source_code": "n=input();print[\"YES\",\"NO\"][n&(n-1)>0]"}, {"source_code": "n = int(raw_input())\nz = 0\nK = [0] * n\n\nk = 0\nx = 0\nwhile x <= 1000:\n k += x\n while k >= n:\n k = k - n\n K[k] = 1\n x += 1\n \nif 0 in K:\n print 'NO'\nelse:\n print 'YES'\n \n"}, {"source_code": "n=int(raw_input())\ni=1%n\nk=2%n\nv=[set() for j in range(n)]\nv[0].add(1)\nwhile (k not in v[i]):\n\tv[i].add(k)\n\ti=(i+k)%n\n\tk=(k+1)%n\n\nfor x in v:\n\tif len(x)==0:\n\t\tprint 'NO'\n\t\texit(0)\nprint 'YES'\n"}, {"source_code": "n = int(raw_input())\na = [False] * n\nc = 0\n\nfor k in xrange(n*n):\n a[c] = True\n c = (c + k + 1) % n\n\nif False in a:\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\ndef solve(n):\n\tvisited = [False]*n\n\tcur = 0\n\tfor step in range(0, n):\n\t\tcur = (cur+step)%n\n\t\tvisited[cur] = True\n\treturn reduce(lambda x, y: x and y, visited)\n\nn = int(raw_input())\n\nprint 'YES' if solve(n) else 'NO'\n\n\n\t\n\t\n"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "print ['NO','YES'][input()in[1,2,4,8,16,32,64,128,256,512]]"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "print ['NO','YES'][input()in[1,2,4,8,16,32,64,128,256,512]]"}, {"source_code": "n=input()\nprint 'YNEOS'[n&(n-1)>0::2]"}, {"source_code": "n=input()\nl=[0 for _ in range(n)]\nm=0\nfor i in range(2*n):\n m=(m+i)%n\n l[m]=1\nprint 'NO' if l.count(0) else 'YES'"}, {"source_code": "n = input()\nprint ['NO', 'YES'][len(set(i * (i + 1) / 2 % n for i in range(n * 2))) == n]"}, {"source_code": "n = input()\nprint ['YES', 'NO'][n & (n - 1) > 0]"}, {"source_code": "\n\nstdin_flag=1\nif not stdin_flag:\n read_line_index=0\n testcasefilename=\"test.txt\"\n Stestcase=open(testcasefilename).read()\n read_line_datas=Stestcase.split(\"\\n\")\n\n\ndef debugs(s):\n if not stdin_flag:\n print \";;;\",s\n\n#####################################\n######################################\n\ndef read_line():\n global read_line_index\n if stdin_flag:\n return raw_input()\n else:\n s=read_line_datas[read_line_index]\n read_line_index+=1\n return s\n\ndef answer():\n if stdin_flag:\n return solve()\n else:\n while read_line_proceed():\n solve()\n \n\ndef read_line_proceed():\n global read_line_index\n print\"##################\"\n while 1:\n if read_line_index>= len (read_line_datas ):\n return False\n if read_line_datas[read_line_index]==\"%%%\":\n read_line_index+=1\n return True\n read_line_index+=1\n\n\ndef readint():\n return int (read_line() )\n\n\ndef readints():\n return map(int, read_line().split(\" \"))\n\ndef reads():\n return read_line()\n\n\n\n\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n\ndef compute(m,n,d):\n pass\n\ndef solve():\n n=readint()\n if len(set(k*(k+1)/2%n for k in xrange(2*n)))==n:\n print\"YES\"\n else:\n print \"NO\"\n\ndef test():\n pass\n\ntest()\nanswer()\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\ndef solve(n):\n visited = [False]*n\n visited[0] = True\n pos = 0\n for i in range(1,2*n+1):\n pos += i\n pos %= n\n visited[pos] = True\n for v in visited:\n if not v:\n return 'NO'\n return 'YES'\n\ndef numbers_from_line(d=' '):\n return [int(s) for s in input.readline().strip().split(d) if len(s.strip())>0]\n\nn = int(input.readline())\n\na = solve(n)\noutput.write('%s\\n' % a)\n"}, {"source_code": "n=int(input())\nL=[1]\nfor k in range(1,n):\n if((L[len(L)-1]+k)==n):\n L.append(L[len(L)-1]+k)\n else:\n L.append((L[len(L)-1]+k)%n)\nL=list(set(L))\nif(len(L)==n):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\njumped = [ [ False for j in range(n) ] for i in range(n) ]\nseen = [ False for i in range(n) ]\nseen[0] = True\ncount = 1\nspan = 0\npos = 0\nwhile True:\n\tpos = (pos + span + 1) % n\n\tif seen[pos]:\n\t\tif jumped[pos][span]:\n\t\t\tbreak\n\telse:\n\t\tseen[pos] = True\n\t\tcount += 1\n\tjumped[pos][span] = True\n\tspan = (span + 1) % n\n\nif count == n:\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "n=int(input())\na=set()\ni=0\nstep=1\nfor _ in range(2*n):\n a.add(i%n)\n i+=step\n step+=1\nif len(a)==n:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n"}, {"source_code": "from itertools import *\nimport math\n\nn = input()\nif n in [2**i for i in xrange(11)]:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "from itertools import *\n\nN = int(raw_input())\n\ndata = list(repeat(False, N))\n\ndata[0] = True\n\npos = 0\nfor i in range(N * 200):\n pos += i\n pos %= N\n data[pos] = True\n \nif all(data):\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "# submit\nn = int(raw_input())\nc = 0\nv = [0] * n\nfor i in range(1000000):\n c = (c + i) % n\n v[c] = 1\nprint \"NO\" if v.count(0) else \"YES\"\n"}, {"source_code": "#!/usr/bin/python\nn = int(raw_input())\nif n in [2 **k for k in range(10)]:\n print \"YES\"\nelse:\n print \"NO\" \n"}, {"source_code": "x = int( input() )\nprint( \"NO\" if x & x-1 > 0 else \"YES\" )\n"}, {"source_code": "n=input();print[\"NO\",\"YES\"][not(n&(n-1))]\n"}, {"source_code": "import math, time, re\n\nrInt = lambda s: int(s)\nrFloat = lambda s: float(s)\nrLong = lambda s: long(s)\nrLine = lambda f: f.readline()\n\ndef main():\n def body():\n n = int(raw_input())\n b = [True for i in xrange(0, n)]\n j = 0\n i = 1\n while ((i <= 500000)):\n if (b[j]):\n b[j] = False\n i += 1\n j = (j + i) % n\n x = [a for a in b if a == True]\n if (len(x) == 0):\n return 'YES'\n else:\n return 'NO'\n\n try:\n name = ''\n f1 = open(name + '.in', 'r')\n f2 = open(name + '.out', 'w')\n print >> f2, body()\n f1.close()\n f2.close()\n except IOError:\n print body()\n except:\n print 'Sudden error!'\n raise\n\nstart = time.time()\nmain()\n#print 'Time exceeded:', time.time() - start"}, {"source_code": "n=int(input())\nlist1=[]\nc=2;\nk=2;\nif(n==1 or n==2):\n print(\"YES\")\n exit(0)\nelse:\n list1.append(2);\n for i in range(n-1):\n c=c+k\n if(c%n==0):\n list1.append(n)\n c=n;\n k=k+1\n else:\n list1.append(c%n)\n c=c%n\n k=k+1\n\nlist2=set(list1)\nif((len(list2)==n-1 and list1.count(1)==0) or len(list2)==n):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "print('NYOE S'[int(raw_input()) in {1, 2, 4, 8, 16, 32, 64, 128, 256, 512} :: 2])"}, {"source_code": "n = int(raw_input())\nans = [False for i in xrange(n + 1)]\nk = 1\nfor i in xrange(n):\n k = (k + i) % n;\n ans[k] = True\nprint 'YES' if ans.count(True) == n else 'NO'\n"}, {"source_code": "from math import log\na = int(input())\nt = log(a, 2)\nif len(str(t)) == 3:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\nprint('NO'if n&n-1 else 'YES')"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "\nn = int(input())\nl = [0 for _ in range(n)]\n\npos = 0\nfor i in range(2 * n + 1):\n\tpos += i\n\tif pos >= n:\n\t\tpos %= n\n\tl[pos] = 1\n\nif len(set(l)) == 2:\n\tprint('NO')\nelse:\n\tprint('YES')\n\n\n"}, {"source_code": "from itertools import *\nfrom fractions import *\nimport sys\nn, pos, k = input (), 1, 1\nused = [False for _ in range (n)]\nfor _ in range (2 * n):\n used[pos - 1] = True\n pos = n if (pos + k) % n == 0 else (pos + k) % n \n k += 1\nprint 'YES' if used.count (True) == n else 'NO'\n\n\n"}, {"source_code": "x = int( input() )\nprint( \"NO\" if x & x-1 > 0 else \"YES\" )"}, {"source_code": "def f(n):\n rl = [True]*n #True = nonvisited\n nn = (n*(n-1))//2\n for k in range(n):\n kk = (k*(k+1))//2\n rl[kk%n] = False\n if n%2==0:\n rl[(kk+nn)%n] = False\n return sum(rl)==0\n\nn = int(input())\nprint('YES' if f(n) else 'NO')\n"}], "negative_code": [{"source_code": "n=int(input())\nif(n%2==0):\n print(\"YES\")\nelse:\n if(n==1):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "import sys\nimport math\n\nn = int(sys.stdin.readline())\n\nv = [0] * n\nost = 1\nfor i in range(1, n + 1):\n ost = (ost + i) % n\n v[ost] = 1\n\nfor i in v:\n if(i == 0):\n print(\"NO\")\n exit()\n \nprint(\"YES\")\n \n "}, {"source_code": "x = int( input() )\nprint( \"YES\" if x % 2 == 0 or x == 1 else \"NO\" )\n"}, {"source_code": "n=int(input())\nlist1=[]\nc=2;\nk=2;\nif(n==1 or n==2):\n print(\"YES\")\n exit(0)\nelse:\n list1.append(2);\n for i in range(n-1):\n c=c+k\n if(c%n==0):\n list1.append(n)\n c=n;\n k=k+1\n else:\n list1.append(c%n)\n c=c%n\n k=k+1\n\nlist2=set(list1)\nif(len(list2)>=n-1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nlist1=[]\nc=2;\nk=2;\nif(n==1):\n print(\"YES\")\n exit(0)\nelse:\n list1.append(2);\n for i in range(n-1):\n c=c+k\n if(c%n==0):\n list1.append(n)\n c=n;\n k=k+1\n else:\n list1.append(c%n)\n c=c%n\n k=k+1\n\nlist2=set(list1)\nif(len(list2)==n):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nlist1=[]\nc=2;\nk=2;\nif(n==1 or n==2):\n print(\"YES\")\n exit(0)\nelse:\n list1.append(2);\n for i in range(n-1):\n c=c+k\n if(c%n==0):\n list1.append(n)\n c=n;\n k=k+1\n else:\n list1.append(c%n)\n c=c%n\n k=k+1\n\nlist2=set(list1)\nif(len(list2)==n):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a=int(input())\nif a<4:\n if (a==1 or a==2):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if (a%4==0 and a%3!=0):\n print(\"YES\")\n else:\n print(\" NO\")"}, {"source_code": "a=int(input())\nif a==1:\n print(\" YES\")\nelse:\n if a%2!=0 :\n print(\"NO\")\n else:\n b=bin(a)\n z=b.count(\"1\")\n if z%2==0:\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "a=int(input())\nb=bin(a)\nz=b.count(\"1\")\nif z%2==0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "\nn = int(input())\nl = [0 for _ in range(n)]\n\npos = 0\nfor i in range(2 * n + 1):\n\tpos += i\n\tif pos >= n:\n\t\tpos %= n\n\tl[pos] = 1\n\nif len(set(l)) == 2:\n\tprint('no')\nelse:\n\tprint('yes')\n\n\n"}, {"source_code": "n = int(input())\nx = [0]*n\nsum_ = 0\nlast = 0\nfor i in range(n+1):\n x[sum_%n] = 1\nprint(\"YES\" if x == [1]*n else \"NO\")"}, {"source_code": "def f(n):\n rl = [True]*n #True = nonvisited\n nn = (n*(n-1))//2\n for k in range(n):\n kk = (k*(k+1))//2\n rl[kk%n] = False\n if n%2==0:\n rl[(kk+nn)%n] = False\n return sum(rl)==0\n"}, {"source_code": "n=int(input())\n\nm=1\np=1\ns = { 1 }\nwhile( 1 ):\n\tif (m%n==1 and p==1) or len(s)==n:\n\t\tbreak\n\tp = ( p+(m) )%n\n\ts.add(p)\n\tm+=1\n\tprint( s )\n\t\nif len(s)==n:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "n = int(input())\na = [None] + [0 for i in range(n)]\na[1] = 1\nk = 1\nc = 0\ncur = 1\n#print(a)\nfor i in range(1000):\n cur = (cur + k) % n\n a[cur] = 1\n k += 1\nif a.count(0) == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\ntri=[]\nfor i in range(2,1000):\n tri.append(i*(i+1)//2)\nif n==1:\n print('YES')\n exit()\nif n in tri:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\ntri=[]\nfor i in range(2,1000):\n tri.append(i*(i+1)//2)\nif n==1:\n print('YES')\n exit()\nif n in tri:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n=int(input())\ntri=[]\nfor i in range(2,1000):\n tri.append(i*(i+1)//2)\nif n==1:\n print('YES')\n exit()\nif n%3==0:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n=int(input())\ntri=[]\nfor i in range(2,1000):\n tri.append(i*(i+1)//2)\nif n==1:\n print('YES')\n exit()\nif n ==3:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n=input();print[\"YES\",\"NO\"][n&(n-1)==1]"}, {"source_code": "n=input();print[\"YES\",\"NO\"][n&(n-1)==0]"}, {"source_code": "n=input()\nprint 'YNEOS'[n&(n-1)::2]"}, {"source_code": "n = int(input())\nl = list(range(1,n+1))\nk = 1\nl.remove(1)\noflag = 0\nfor k in range(n+1):\n if len(l) == 0:\n print 'YES'\n oflag = 1\n break\n x = (((k*(k+1))/2)+1)%n\n if x in l:\n l.remove(x)\n k = k+1\nif oflag == 0:\n print 'NO'\n"}, {"source_code": "n = int(input())\nl = list(range(1,n+1))\nk = 1\nl.remove(1)\nwhile 1:\n if len(l) == 0:\n print 'YES'\n break\n x = (((k*(k+1))/2)+1)%n\n if x in l:\n l.remove(x)\n k = k+1\n else :\n print 'NO'\n break\n"}, {"source_code": "import math, time, re\n\nrInt = lambda s: int(s)\nrFloat = lambda s: float(s)\nrLong = lambda s: long(s)\nrLine = lambda f: f.readline()\n\ndef main():\n def body():\n n = int(raw_input())\n b = [True for i in xrange(0, n)]\n j = 0\n i = 1\n while ((i <= 500000)):\n if (b[j]):\n b[j] = False\n i += 1\n j = (j + i) % n\n x = [a for a in b if a == True]\n if (len(x) == 0):\n return 'YES'\n else:\n return 'NO'\n\n try:\n name = ''\n f1 = open(name + '.in', 'r')\n f2 = open(name + '.out', 'w')\n print >> f2, body()\n f1.close()\n f2.close()\n except IOError:\n print body()\n except:\n print 'Sudden error!'\n raise\n\nstart = time.time()\nmain()\nprint 'Time exceeded:', time.time() - start"}, {"source_code": "import sys\n\ninf = sys.stdin\nout = sys.stdout\n\ninfinity = pow(10,9)\nn = int(inf.readline().rstrip())\na = [False] * n\nq = [-1] * (2 * n)\nq[0] = 0\nd = [infinity] * n\nd[0] = 0\nleft, right = 0, 1\nwhile left != right:\n i = q[left]\n left += 1\n k = d[i] + 1\n for j in [ (i + k) % n, (i + n - k) % n] :\n if d[j] != infinity: continue\n d[j] = d[i] + 1\n q[right] = j\n right += 1\nif left == n:\n out.write('YES\\n')\nelse:\n out.write('NO\\n') \n\n \n \n \n\n"}, {"source_code": "n = int(input())\nvisited = [False] * n\nk = 0\nfor i in range(n + 1):\n k += i + 1\n visited[k % n] = True\nfor i in visited:\n if not i:\n print(\"NO\")\n exit()\nprint(\"YES\")\n"}, {"source_code": "class CodeforcesTask55ASolution:\n def __init__(self):\n self.result = ''\n self.n = 0\n\n def read_input(self):\n self.n = int(input())\n\n def process_task(self):\n hassocks = [x + 1 for x in range(self.n)]\n visits = set()\n visiting = 1\n for x in range(1000 * self.n):\n visiting += x\n visiting = visiting % self.n\n if not visiting:\n visiting = self.n\n visits.add(visiting)\n if list(visits) == hassocks:\n self.result = \"YES\"\n else:\n self.result = \"NO\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask55ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}], "src_uid": "4bd174a997707ed3a368bd0f2424590f"} {"source_code": "# ===============================================================================================\n# importing some useful libraries.\nfrom __future__ import division, print_function\nfrom fractions import Fraction\nimport sys\nimport os\nfrom io import BytesIO, IOBase\nfrom itertools import *\nimport bisect\nfrom heapq import *\nfrom math import ceil, floor\nfrom copy import *\nfrom collections import deque, defaultdict\nfrom collections import Counter as counter # Counter(list) return a dict with {key: count}\nfrom itertools import combinations # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]\nfrom itertools import permutations as permutate\nfrom bisect import bisect_left as bl\nfrom operator import *\n# If the element is already present in the list,\n\n# the left most position where element has to be inserted is returned.\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n\n# If the element is already present in the list,\n# the right most position where element has to be inserted is returned\n\n# ==============================================================================================\n# fast I/O region\n\nBUFSIZE = 8192\nfrom sys import stderr\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n# inp = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ===============================================================================================\n### START ITERATE RECURSION ###\nfrom types import GeneratorType\n\n\ndef iterative(f, stack=[]):\n def wrapped_func(*args, **kwargs):\n if stack: return f(*args, **kwargs)\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n continue\n stack.pop()\n if not stack: break\n to = stack[-1].send(to)\n return to\n\n return wrapped_func\n\n\n#### END ITERATE RECURSION ####\n\n# ===============================================================================================\n# some shortcuts\n\nmod = 1000000007\n\n\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") # for fast input\n\n\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\n\n\ndef lis(): return list(map(int, inp().split()))\n\n\ndef stringlis(): return list(map(str, inp().split()))\n\n\ndef sep(): return map(int, inp().split())\n\n\ndef strsep(): return map(str, inp().split())\n\n\ndef fsep(): return map(float, inp().split())\n\n\ndef nextline(): out(\"\\n\") # as stdout.write always print sring.\n\n\ndef testcase(t):\n for p in range(t):\n solve()\n\n\ndef pow(x, y, p):\n res = 1 # Initialize result\n x = x % p # Update x if it is more , than or equal to p\n if (x == 0):\n return 0\n while (y > 0):\n if ((y & 1) == 1): # If y is odd, multiply, x with result\n res = (res * x) % p\n\n y = y >> 1 # y = y/2\n x = (x * x) % p\n return res\n\n\nfrom functools import reduce\n\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))\n\n\ndef gcd(a, b):\n if a == b: return a\n while b > 0: a, b = b, a % b\n return a\n\n\n# N=100000\n# mod = 10**9 +7\n# fac = [1, 1]\n# finv = [1, 1]\n# inv = [0, 1]\n#\n# for i in range(2, N + 1):\n# fac.append((fac[-1] * i) % mod)\n# inv.append(mod - (inv[mod % i] * (mod // i) % mod))\n# finv.append(finv[-1] * inv[-1] % mod)\n#\n#\n# def comb(n, r):\n# if n < r:\n# return 0\n# else:\n# return fac[n] * (finv[r] * finv[n - r] % mod) % mod\n\n\n##############Find sum of product of subsets of size k in a array\n# ar=[0,1,2,3]\n# k=3\n# n=len(ar)-1\n# dp=[0]*(n+1)\n# dp[0]=1\n# for pos in range(1,n+1):\n# dp[pos]=0\n# l=max(1,k+pos-n-1)\n# for j in range(min(pos,k),l-1,-1):\n# dp[j]=dp[j]+ar[pos]*dp[j-1]\n# print(dp[k])\n\ndef prefix_sum(ar): # [1,2,3,4]->[1,3,6,10]\n return list(accumulate(ar))\n\n\ndef suffix_sum(ar): # [1,2,3,4]->[10,9,7,4]\n return list(accumulate(ar[::-1]))[::-1]\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\n# =========================================================================================\nfrom collections import defaultdict\n\n\ndef numberOfSetBits(i):\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24\n\n\ndef N():\n return int(inp())\n\ndef solve():\n n,a,b,p,q=sep()\n ans=0\n ans+=(p*(n//a) + q*(n//b))\n m=min(p,q)\n ans-=(m*(n//lcm(a,b)))\n print(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nsolve()\n#testcase(int(inp()))\n\n\n", "positive_code": [{"source_code": "from math import gcd\n\nn, a, b, p, q = map(int, input().split())\n\nans = p * (n // a) + q * (n // b) - min(p, q) * (n // ((a * b) // gcd(a, b)))\n\nprint(ans)"}, {"source_code": "def gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n\ns=raw_input().split()\nn=int(s[0])\na=int(s[1])\nb=int(s[2])\np=int(s[3])\nq=int(s[4])\n\nred=n/a\nblue=n/b\nredblue=n*gcd(a,b)/(a*b)\nif p>q:\n\tprint p*red+q*(blue-redblue)\nelse:\n\tprint p*(red-redblue)+q*(blue)"}, {"source_code": "import fractions\nn,a,b,p,q=map(int,raw_input().split())\ns=a*b/fractions.gcd(a,b)\nprint n/a*p+n/b*q-(n/s)*min(p,q)\n"}, {"source_code": "import math\nn, red, blue, red_cost, blue_cost = map(int, input().split())\nreds = n//red - n//((red*blue)//math.gcd(red,blue))\nblues = n//blue - n//((red*blue)//math.gcd(red,blue))\nans = reds*red_cost + blues*blue_cost + max(blue_cost, red_cost)*(n//((red*blue)//math.gcd(red,blue)))\nprint(int(ans)) \n"}, {"source_code": "liste = input().split(\" \")\n\nn = int(liste[0])\na = int(liste[1])\nb = int(liste[2])\np = int(liste[3])\nq = int(liste[4])\n\nm = max(p,q)\nres = 0\nmulta = a\nmultb = b\n\n# for i in range (1,n+1) :\n# auxa = False\n# auxb = False\n# if i == multa :\n# auxa = True\n# multa += a\n# if i == multb :\n# auxb = True\n# multb += b\n# if auxa and auxb :\n# res += m\n# else :\n# if auxa :\n# res += p\n# elif auxb :\n# res += q\n# #print(i,res)\n# \n# print(res)\n\ndef pgcd(a,b):\n \"\"\"pgcd(a,b): calcul du 'Plus Grand Commun Diviseur' entre les 2 nombres entiers a et b\"\"\"\n while b!=0:\n a,b=b,a%b\n return a\n \nppcm = a*b /pgcd(a,b)\n\ndiva = n//a\ndivb = n//b\ndivab = int(n //ppcm)\n\nif m == p :\n print(diva*p + (divb-divab)*q)\nelse :\n print(divb*q + (diva-divab)*p)"}, {"source_code": "def gcd(x, y):\n if y == 0: return x\n else: return gcd(y, x % y)\n\nn, a, b, p, q = map(int, raw_input().split())\n\ncount = 0\n\ncount += n/a * p\ncount += n/b * q\n\ncount -= min(p, q) * (n/((a*b)/gcd(a, b)))\n\nprint count\n\n"}, {"source_code": "from math import gcd as g\n\ndef lmc(a, b):\n return a // g(a, b)*b\n\nn, a, b, p, q = map(int, input().split())\nans = 0\n\nans += (n//a)*p\nans += (n//b)*q\nans -= (n//lmc(a, b))*min(p, q)\n\nprint(ans)\n\n\"\"\"\ntr = False if p > q else True\n\nfor i in range(1, n+1):\n if not(tr):\n if i % a == 0:\n ans += p\n elif i % b == 0:\n ans += q\n else:\n if i % b == 0:\n ans += q\n elif i % a == 0:\n ans += p\nprint(ans)\n\"\"\"\n"}, {"source_code": "n,a,b,p,q=map(int,input().split())\ndef gcd(x, y):\n while y != 0:\n (x, y) = (y, x % y)\n return x\nlcm=a*b//gcd(a,b)\nans=(n//a)*p + (n//b)*q - (n//lcm)*min(p,q)\nprint(ans)\n \n "}, {"source_code": "from fractions import gcd\n\n\ndef lcm(numbers):\n return reduce(lambda x, y: (x * y) / gcd(x, y), numbers, 1)\n\n\nentrada = map(int, raw_input().split())\nn = entrada[0]\na = entrada[1]\nb = entrada[3]\np = entrada[2]\nq = entrada[4]\nresult = long()\n\nif b >= q:\n result += (n / a) * b + (n / p) * q - (n / lcm((a, p))) * q\nelse:\n result += (n / p) * q + (n / a) * b - (n / lcm((a, p))) * b\n\nprint result\n"}, {"source_code": "from math import gcd\n\nn, a, b, p, q = map(int, input().split())\n\n# print(n, a, b, p, q)\nx = n // a * p\ny = n // b * q\nz = (n // (a * b // gcd(a, b))) * min(p, q)\n\nprint(x + y - z)"}, {"source_code": "from fractions import gcd\nn,a,b,p,q = map(int,raw_input().split())\nab = (a*b)/gcd(a,b)\nprint (n/a - n/ab) * p + (n/b - n/ab) * q + n/ab * max(p,q)\n"}, {"source_code": "from math import gcd\nn,a,b,p,q=map(int,input().split())\nx=min(p,q)\nl=a*b//gcd(a,b)\nprint((n//a)*p+(n//b)*q-(n//l)*x)"}, {"source_code": "import math\nn, a, b, p, q = map(int, input().split())\nlcm = int(a*b/math.gcd(a, b))\nans = 0\nif p >= q:\n\tans = n//a*p + n//b*q - n//lcm*q\nelse:\n\tans = n//b*q + n//a*p - n//lcm*p\nprint(int(ans))"}, {"source_code": "def compute():\n\n def gcd(a,b):\n return a if b==0 else gcd(b,a%b)\n\n def lcm(a,b):\n return a*(b//gcd(a,b))\n\n n, a, b, p, q = map(int,input().split())\n return (n//a)*p + (n//b)*q - (n//(lcm(a,b)))*min(p,q)\n\nif __name__==\"__main__\":\n print(compute())\n"}, {"source_code": "L=input().split()\nn=int(L[0])\na=int(L[1])\nb=int(L[2])\np=int(L[3])\nq=int(L[4])\n\ndef pgcd(a,b):\n while b!=0: \n a, b = b, a % b\n return a\n\nc=int((a*b/pgcd(a,b)))\n\nd=int(n//c)\n\nS=int(((n//a)-d)*p+((n//b)-d)*q+d*max(p,q))\n\nprint(S)"}, {"source_code": "import sys\n\n# inData = sys.argv[1:]\ninData = input().split()\n\nn, a, b, p, q = map(int, inData)\n\ndef cmmdc(a, b):\n if b == 0:\n return a\n else:\n return cmmdc(b, a % b)\n\ncmmmc = int((a * b) / cmmdc(a, b))\n\nprint(int(int((n / a)) * p + int((n / b)) * q - int((n / cmmmc)) * (min(p, q))))"}, {"source_code": "line = input().split(' ')\nn = int(line[0])\na = int(line[1])\nb = int(line[2])\np = int(line[3])\nq = int(line[4])\n\ndef findGCD(a, b) :\n if a % b != 0 :\n return findGCD(b, a % b)\n else :\n return b\n\ndef MIN(a,b):\n if a >= b :\n return b\n else :\n return a\n\nans = int(n/a) * p\nans += int(n/b) * q\n\nGCD = findGCD(a,b)\nLCM = (a / GCD) * (b / GCD) * GCD\nans -= int(n/ LCM) * MIN(p,q)\n\nprint(ans)"}, {"source_code": "#!/usr/bin/python3\n# Copyright (C) 2016 Sayutin Dmitry.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; version 3\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; If not, see <http://www.gnu.org/licenses/>.\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\nn, a, b, p, q = map(int, input().split())\n\ns = (n // a) * p + (n // b) * q\ns -= (n // (a * b // gcd(a, b))) * min(p, q)\nprint(s)\n"}, {"source_code": "l=input()\nl=l.split(' ')\nq=int(l.pop())\np=int(l.pop())\nb=int(l.pop())\na=int(l.pop())\nn=int(l.pop())\nsomme=0\n\"\"\"\nif p>q:\n somme+=p*(n//a)\n for j in range(1,(n//b)+1):\n if (b*j)%a!=0:\n somme+=q\nelse:\n somme+=q*(n//b)\n for j in range(1,(n//a)+1):\n if (a*j)%b!=0:\n somme+=p\n\"\"\"\ndef pgcd(x,y):\n if y==0:\n return x\n else:\n return pgcd(y,x%y)\nd=pgcd(a,b)\nalpha=a//d\nbeta=b//d\nif p>q:\n somme+=p*(n//a)\n somme+=q*(n//b-(n//b)//alpha)\nelse:\n somme+=q*(n//b)\n somme+=p*(n//a-(n//a)//beta)\n \nprint(somme)\n"}, {"source_code": "def gcd(a, b):\n\tif a == 0:\n\t\treturn b\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n\ndef get_nok(a, b):\n\treturn (a * b) // gcd(a, b)\n\nn, a, b, p, q = list(map(int, input().split()))\n\nif p < q:\n\ta, b = b, a\n\tp, q = q, p\n\n\nnok = get_nok(a, b)\n\nt = n // a\nminus = n // nok\nc = n // b\nprint(t * p + q * (c - minus))\n\n\n"}, {"source_code": "def gcd(a,b):\n while a % b != 0:\n a,b = b,a%b\n return b\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nn,a,b,p,q = map(int, input().split())\nA = n//a\nB = n//b\nAandB = n//lcm(a,b)\n\nprint(A*p + B*q - min(p,q)*AandB)\n"}, {"source_code": "def gcd (x, y):\n while y:\n x, y = y, x % y\n return x\nn, a, b, p, q = map(int, input().split())\nif (p > q): a, b, p, q = b, a, q, p\nprint(p * (n // a - n * gcd(a, b) // a // b) + q * (n // b))"}, {"source_code": "from math import floor, ceil, gcd\nn, a, b, p, q = map(int, input().split())\npc = floor(n / a) - ceil(1 / a) + 1\nqc = floor(n / b) - ceil(1 / b) + 1\nl = (a * b) // gcd(a, b)\nbc = floor(n / l) - ceil(1 / l) + 1\npc -= bc\nqc -= bc\nans = p * pc + q * qc\nif (p >= q):\n ans += (p * bc)\nelse:\n ans += (q * bc)\nprint(ans)"}, {"source_code": "import math\ndef lcm(a, b):\n\treturn (a*b)//math.gcd(a, b)\nn,a,b,p,q = map(int, input().split())\nboth = (n//lcm(a,b))\nans = (both)*max(p,q) + ((n//a - both) * p) + ((n//b - both) * q);\nprint(ans) "}, {"source_code": "i = input().split(\" \");\ni = [int(a) for a in i]\n\ndef gcd(a,b):\n\treturn a if b == 0 else gcd(b, a%b)\n\nprint (i[0]//i[1] * i[3] + (i[0]//i[2]) * i[4] - i[0]//(i[1]*i[2]//gcd(i[1], i[2])) * min(i[3], i[4]))\n"}, {"source_code": "from math import gcd\n\nwhile True:\n try:\n n, a, b, p, q = map(int, input().split())\n s = (n // a) * p\n s += (n // b) * q\n s -= (n // ((a * b) // gcd(a, b))) * min(p, q)\n print(int(s))\n except EOFError:\n break"}, {"source_code": "n, a, b, p, q = map(int, input().split())\nr, t = a, b\n\nwhile a != 0 and b != 0:\n if a > b:\n a = a % b\n else:\n b = b % a\n\nnod = a + b\nnok = r * t // nod\n\nprint((n // nok * max(p, q)) + (((n // r) - (n // nok)) * p) + (((n // t) - (n // nok)) * q))\n"}, {"source_code": "import fractions\nn,a,b,p,q=map(int,input().split())\nnok=a*b//fractions.gcd(a,b)\nif p>q:\n a,b,p,q=b,a,q,p\nprint((n//b)*q+(n//a-n//nok)*p)\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jun 13 21:55:56 2016\n\n@author: Dell_\n\"\"\"\n\nimport sys\nif False:\n input = open('chocolate.txt', 'r')\nelse:\n input = sys.stdin \nx = 0\nnumbers = input.readline().split()\n\nn = int(numbers[0])\na = int(numbers[1])\nb = int(numbers[2])\np = int(numbers[3])\nq = int(numbers[4])\n\nchocolates = 0\nnumBoth = 0\nnumA = n//a\nnumB = n//b\n\ndef HCF(a,b):\n while b > 0:\n t = b\n b = a%b\n a = t\n return a\n\ndef LCM(a, b):\n lcm = (a*b) // (HCF(a,b))\n return lcm\n \nnumBoth = n // LCM(a, b)\n\nchoca = numA * p\nchocb = numB * q\n\nif p > q:\n chocolates = choca + chocb - (numBoth*q)\nelif p < q:\n chocolates = choca + chocb - (numBoth*p)\nelif p == q:\n chocolates = choca + chocb - (numBoth*p)\nprint chocolates"}, {"source_code": "from sys import stdin\ndef gcd(a,b):\n while a%b:\n t = a%b; a=b; b=t\n return b\ndef lcm(a,b):\n return (a*b)/gcd(a,b)\nn,a,b,p,q = map(int,stdin.readline().split())\nfir = n/a\nsec = n/b\ncom = n/lcm(a,b)\nfir -= com\nsec-=com\nans = fir*p + sec*q\nif p>q:\n ans+= com*p\nelse:\n ans+=com*q\nprint ans"}, {"source_code": "from fractions import gcd\n\nn, a, b, p, q = map(int, raw_input().split())\nlcm = a * b / gcd(a, b)\n\ntot = p * (n / a) + q * (n / b)\n\nif p * (n / lcm) > q * (n / lcm):\n tot -= q * (n / lcm)\nelse:\n tot -= p * (n / lcm)\n\nprint tot\n"}, {"source_code": "from sys import stdin\nfrom fractions import gcd\n\nrints = lambda: [int(x) for x in stdin.readline().split()]\nlcm = lambda a, b: a // gcd(a, b) * b\n\nn, a, b, p, q = rints()\ndiva, divb, lc = n // a, n // b, lcm(a, b)\ndivab = n // lc\nprint((diva - divab) * p + (divb - divab) * q + divab * max(p, q))\n"}, {"source_code": "from math import floor, gcd\ndef mmc(x, y):\n\tmaior = max(x, y)\n\twhile True:\n\t\tmmc = (x * y) // gcd(x,y)\n\t\treturn mmc\n\na,b,c,d,e = map(int, input().split())\nresp = d * (floor(a // b))\nresp += e * (floor(a // c))\nresp -= min(d,e) * (a // (mmc(b,c)))\nprint(resp)"}, {"source_code": "from fractions import gcd\ndef lcm(a, b): return a * b / gcd(a, b)\nn, a, b, p, q = map(int, raw_input().split())\nprint (n / a) * p + (n / b) * q - (n / lcm(a, b)) * min((p, q,))\n"}, {"source_code": "def mdc(a,b):\n\tresto = a % b\n\tif (resto == 0):\n\t\treturn b\n\telse:\n\t\treturn mdc(b, resto)\n\t\n\nentrada = map(int, raw_input().split())\n\nN = entrada[0]\na = entrada[1]\nb = entrada[2]\np = entrada[3]\nq = entrada[4]\n\ndiva = N/a\ndivb = N/b\ndivab = N/((a*b)/mdc(a,b))\n\nprint (diva*p) + (divb*q) - (divab*min(p,q))"}, {"source_code": "def gcd(a,b):\n if a%b==0:\n return b\n else:\n return gcd(b,a%b)\n\nn,a,b,p,q=list(map(int,input().split()))\nc=(a*b)//gcd(a,b)\nif p>q:\n d=n//a-n//c\n e=n//b-n//c\n print(d*p+e*q+p*(n//c))\nelse:\n d=n//a-n//c\n e=n//b-n//c\n print(d*p+e*q+q*(n//c))"}, {"source_code": "import sys\n\ndef gcd(a,b):\n if b==0: return a\n return gcd(b, a%b)\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\nn, a, b, p, q = map(int, input().split())\n\nAs = n//a\nBs = n//b\nif a==b:\n print(As*max(p,q))\n sys.exit()\n\ncommon = lcm(a,b)\ncom = n//common\n\nif p>q:\n Bs = Bs - com\n print(As*p + Bs*q)\nelse:\n As = As - com\n print(As*p + Bs*q)\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n\ndef lcm(a,b):\n return a*b / gcd(a,b)\n\nn,a,b,p,q = (int(x) for x in input().split())\nif (p > q):\n nn = n // a\n ans = (n // a) * p + ((n // b) - (n // lcm(a,b))) * q\nelse:\n ans = (n // b) * q + ((n // a) - (n // lcm(a,b))) * p\nprint(ans)"}, {"source_code": "# -*- coding: utf-8 -*-\ndef gcd(a, b):\n if (b == 0): return a\n return gcd(b, a % b)\n\n\ndef lcm(a, b):\n return (a * b) / gcd(a, b)\n\n\nn, a, b, p, q = map(int, raw_input().split())\n\na_divisor = int(n / a)\nb_divisor = int(n / b)\ncommon_divisor = int(n/ lcm(a, b))\n\nprint a_divisor * p + b_divisor * q - common_divisor * min(p, q)"}, {"source_code": "n,a,b,p,q=map(int,raw_input().split())\ndef mdc(x,y):\n if y==0:\n return x\n return mdc(y,x%y)\nk=max(a,b)/mdc(a,b)*min(a,b)\nprint n/k*max(p,q)+(n/a-n/k)*p+(n/b-n/k)*q\n"}, {"source_code": "def MDC(a,b):\n\t\n\twhile a % b != 0:\n\t\t\n\t\taux = b\n\t\t\n\t\tb = a % b\n\t\t\n\t\ta = aux\n\t\t\n\treturn b\n\n\ndef MMC(a,b):\n\t\n\treturn (a*(b/MDC(a,b)))\n\n\nn, a, b, p, q = map(int, raw_input().split())\n\ndivisiveisA = n / a\ndivisiveisB = n / b\n\ncomuns = n / MMC(a,b)\n\nresultado = divisiveisA * p + divisiveisB * q - comuns * (min(p,q))\n\nprint resultado\n"}, {"source_code": "import sys\nfrom math import gcd\n\nn, a, b, p, q = map(int, input().split())\nans = (n // a) * p + (n // b) * q - (n // (a * b // gcd(a, b))) * min(p, q)\nprint(ans)\n"}, {"source_code": "from fractions import gcd\nn,a,b,p,q=map(int,raw_input().split())\nx=n/a\ny=n/b\nz=(a*b)/gcd(a,b)\nz=n/z\nif p>q:\n\tans=x*p+(y-z)*q\nelse:\n\tans=y*q+(x-z)*p\nprint ans"}, {"source_code": "II = lambda: int(raw_input())\nIAI = lambda: map(int, raw_input().split())\nIL = lambda: raw_input().strip()\nIAS = lambda: raw_input().split()\n\nfrom fractions import gcd\nn,a,b,p,q = IAI()\n\nprint n / a * p + n / b * q + n / (a*b/gcd(a, b)) * (max(p,q) - p - q)\n"}, {"source_code": "def find(a,b):\n if(b==0):\n return a\n else:\n return find(b,a%b)\nn,a,b,p,q=map(int,raw_input().strip().split(\" \"))\nlcm=(a*b)/find(a,b)\nm=n/lcm\nprint ((n/a)-m)*p+((n/b)-m)*q+m*(max(p,q))\n"}, {"source_code": "import fractions\nn,a,b,p,q=map(int,raw_input().split())\ns=a*b/fractions.gcd(a,b)\nprint n/a*p+n/b*q-(n/s)*min(p,q)"}, {"source_code": "import math\nn,a,b,p,q = map(int,input().split())\nx = n//a\ny = n//b\nz = n//((a*b)//math.gcd(a,b))\nans = (x-z)*p + (y-z)*q + z*max(p,q)\nprint(ans)\n"}, {"source_code": "def mdc(a,b):\n\tresto = a % b\n\tif (resto == 0):\n\t\treturn b\n\telse:\n\t\treturn mdc(b, resto)\n\t\n\nN,a,b,p,q = map(int, raw_input().split(' '))\ndivisao_a = N/a\ndivisao_b = N/b\ndivisao_aEb = N/((a*b)/mdc(a,b))\n\n\nprint (divisao_a*p) + (divisao_b*q) - (divisao_aEb*min(p,q))"}, {"source_code": "def gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\ndef lcm(a,b):\n\treturn a*b/(gcd(a,b))\nn,a,b,p,q = map(int,raw_input().split())\npq = max(p,q)\nx = int(n/a)\ny = int(n/b)\nl = lcm(max(a,b),min(a,b))\nans = p*x + q*y - (p+q)*(n/l)\nans += max(p,q)*(n/l)\nprint ans"}, {"source_code": "import math\nimport sys\nsys.setrecursionlimit(10000)\ndef gcd(a, b):\n return b if a % b == 0 else gcd(b, a % b)\n\ndef lcm(a, b):\n return a*b/gcd(a,b)\ns = raw_input()\nn, a, b, p, q = s.split()\nn = int(n)\na = int(a)\nb = int(b)\np = int(p)\nq = int(q)\nres = n / a * p + n / b * q - n / lcm(a, b) * (p + q)\nres += n/ lcm(a, b) * max(p, q)\n\nprint res"}, {"source_code": "import math\nn,a,b,p,q=map(int, input().split())\nprint((n//a)*p+(n//b)*q-(n//((a*b)// math.gcd(a,b)))*min(p,q))"}, {"source_code": "import math\nn,a,b,p,q=map(int, input().split())\nprint((n//a)*p+(n//b)*q-(n//((a*b)// math.gcd(a,b)))*min(p,q))"}, {"source_code": "from math import gcd\n\n\ndef main():\n n, a, b, p, q = map(int, input().split())\n g = gcd(a, b)\n lcm = a * b // g\n fa = n // a\n fb = n // b\n fab = n // lcm\n print((fa - fab) * p + (fb - fab) * q + fab * max(p, q))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,a,b,p,q=map(int,raw_input().split())\ndef mdc(x,y):\n if y==0:\n return x\n return mdc(y,x%y)\nk=max(a,b)/mdc(a,b)*min(a,b)\nprint n/k*max(p,q)+(n/a-n/k)*p+(n/b-n/k)*q"}, {"source_code": "n,red,blue,red_candy,blue_candy = map(int,raw_input().split())\ntotal = 0\ndef mdc(a, b):\n while b:\n a, b = b, a%b\n return a\ndef mmc(a,b):\n\treturn (a*b)/mdc(a,b) \nif red_candy>=blue_candy:\n\tmaximo = red\n\tmaximo_valor = red_candy\n\tminimo = blue\n\tminimo_valor = blue_candy\nelse:\n\tmaximo = blue\n\tmaximo_valor = blue_candy\n\tminimo = red\n\tminimo_valor = red_candy\ntotal = ((n/maximo) * maximo_valor) + ((n/minimo) * minimo_valor) - (n / mmc(maximo,minimo)) * minimo_valor\t\nprint total\t\t\n"}, {"source_code": "from sys import stdin, stdout\n\n\ndef gcd(a, b):\n if not b:\n return a\n \n return gcd(b, a % b)\n\n\nn, a, b, p, q = map(int, stdin.readline().split())\nfirst, second, third = (n // a) * p, (n // b) * q, (n // (a * b // gcd(a, b))) * min(p, q)\nstdout.write(str(first + second - third))"}, {"source_code": "import sys,math\nn,a,b,p,q=map(int,sys.stdin.readline().split())\nx=(n//a)*p \nx+=(n//b)*q\nlcm=(a*b)//math.gcd(a,b)\nx-=(n//lcm)*(min(p,q))\nprint(x)"}, {"source_code": "from fractions import gcd\nn , a , b , p , q = map(int , raw_input().split())\n\npro = (a*b)/gcd(a,b)\n\nval1 = n / a\nval2 = n / b\nval3 = n / pro\n\nans = val3 * max(p , q) + (val1 - val3)* p + (val2 - val3)*q\n\nprint ans\n\n\n"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\n\ndef gcd(x, y):\n if x < y:\n return gcd(y, x)\n if y == 0:\n return x\n else:\n return gcd(y, x % y)\n\nn,a,b,p,q = map(int, input().split())\n\nif q > p:\n a,b = b,a\n p,q = q,p\n\nres = (n//a)*p + (n//b)*q - (n//(a*b//gcd(a,b)))*q\n\nprint(res)\n"}, {"source_code": "from fractions import gcd\ndef lcm(x, y):\n return (x*y)//gcd(x,y)\nn,a,b,p,q=map(int,raw_input().split())\nc=n/lcm(a,b)\nprint ((n/a)*p)+((n/b)*q)-(min(p,q)*c)"}, {"source_code": "def gcd(a, b):\n if a<b:\n return gcd(b, a)\n if b==0:\n return a\n return gcd(b, a%b)\n \ndef lcm(a, b):\n return (a*b)//gcd(a,b)\n \nn, a, b, p, q = map(int, input().split())\nsum = 0\nsum+=(n//a-n//lcm(a,b))*p\nsum+=(n//b-n//lcm(a,b))*q\nsum+=max(p,q)*(n//lcm(a,b))\nprint(sum)"}, {"source_code": "def gcd(a, b):\n return a if b == 0 else gcd(b, a % b)\n\ndef lcm(a, b):\n return a // gcd(a, b) * b\n\nn, a, b, p, q = map(int, input().split())\n\nprint(n // a * p + n // b * q - n // lcm(a, b) * min(p, q))"}, {"source_code": "import math\n\nn,a,b,p,q = [int(x) for x in input().split(' ')]\n\ng = int(a * b / math.gcd(a,b))\n\nif p > q: l = q\nelse: l = p\nprint((n//a)*p + (n//b)*q - (n//g)* l)"}, {"source_code": "__author__ = 'aste'\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a%b)\n\n\ndef main():\n n, a, b, p, q = [int(x) for x in input().split()]\n div_a = n // a\n div_b = n // b\n lcm = (a*b) // gcd(a, b)\n div_ab = n // lcm\n\n c1 = (div_a - div_ab)*p + (div_b - div_ab)*q + div_ab*q\n c2 = (div_a - div_ab)*p + (div_b - div_ab)*q + div_ab*p\n\n print(max(c1, c2))\n\n\nmain()\n\n\n"}, {"source_code": "import math\nn,a,b,p,q=map(int, input().split())\n\ntotal = p*(n//a) + q*(n//b) - (int)(min(p,q)*(n//(a*b//math.gcd(a,b))))\nprint(total)"}, {"source_code": "from sys import stdin\ninput = stdin.readline\nn, a, b, p, q = map(int, input().split())\nfrom math import gcd\nlcm = lambda x,y: (x * y) // gcd(x, y)\naf = n // a\nbf = n // b\nabf = n // lcm(a, b)\nao = af - abf\nbo = bf - abf\nprint(ao * p + bo * q + abf * (max(p, q)))"}, {"source_code": "from fractions import gcd\n\n\n\nn, a, b, p, q = map(int, input().split())\ndiv_by_a = n // a\ndiv_by_b = n // b\ndiv_by_ab = n // int(a*b / gcd(a, b))\n\nchoc = div_by_a*p + div_by_b*q\n\nif p > q:\n print(choc - div_by_ab*q)\nelse:\n print(choc - div_by_ab*p)\n\n"}, {"source_code": "\ndef gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\ns=map(lambda x:int(x) , raw_input().split(' '))\nn = s[0]\na = s[1]\nb = s[2]\np = s[3]\nq = s[4]\nm=0\nna=n//a\nnb=n//b\nnab=n//(a*b//gcd(max(a,b),min(a,b)))\nif p>q:\n\tm=m+na*p\n\tm=m+(nb-nab)*q\nelse:\t\t\t\n\tm=m+nb*q\n\tm=m+(na-nab)*p\nprint(m)"}, {"source_code": "inp = input().split()\nn,a,b,p,q = int(inp[0]),int(inp[1]),int(inp[2]),int(inp[3]),int(inp[4])\n\nt,c = a,b\nr = t%c\nwhile r!=0:\n\tt = c\n\tc = r\n\tr = t%c\n\nc = (a*b)//c\nans = 0\ncnt = n//c\nans += (n//c)*max(p,q)\nans += (n//a-cnt)*p\nans += (n//b-cnt)*q\n\nprint(ans)"}, {"source_code": "def nok(a,b):\n n = a * b\n while a != b:\n if a > b:\n a -= b\n elif b > a:\n b -= a\n\n return n // a\n\n\nn, a, b, p, q = list(map(int,input().split()))\nnok1 = nok(a,b)\nk = ((n // a) * p + (n // b) * q - (n // nok1) * (p + q)) + (n // nok1) * max(p,q)\n\nprint(k)\n\n"}, {"source_code": "def lcm(a, b):\n x = a * b\n while b != 0:\n (a, b) = (b, a % b)\n return x // a\n\n\nn, a, b, p, q = map(int, input().split())\nprint(n // a * p + n // b * q - n // lcm(a, b) * min(p, q))"}, {"source_code": "import math\nn, a, b, p, q=map(int, input().rstrip().split())\nnum_a=int(n/a)\nnum_b=int(n/b)\nlcm=int((a*b)/math.gcd(a, b))\nif lcm>n:\n print((num_a*p)+(num_b*q))\nif lcm<=n:\n num_lcm=int(n/lcm)\n if p>=q:\n num_b-=num_lcm\n print((num_a*p)+(num_b*q))\n if p<q:\n num_a-=num_lcm\n print((num_a*p)+(num_b*q))"}, {"source_code": "# coding: utf-8\n\n\ndef _gcd(a, b):\n if a % b == 0:\n return b\n else:\n return _gcd(b, a%b)\n\nline = raw_input().strip()\nn, a, b, p, q = map(lambda x: int(x), line.split())\n\n\ncnt_a = n / a\ncnt_b = n / b\ngcd = _gcd(a, b)\nlcm = a * b / gcd\ncnt_lcm = n / lcm\n\n#print \">>\", gcd, cnt_a, cnt_b, cnt_lcm\n\ns = cnt_a * p + cnt_b * q\nv = p if p < q else q\n\ns -= cnt_lcm * v\nprint s\n"}, {"source_code": "from fractions import gcd\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\nn,a,b,q,p=map(int,input().split())\nprint((n//a-(n//lcm(a,b)))*q + (n//b-(n//lcm(a,b)))*p + n//(lcm(a,b))*max(p,q))"}, {"source_code": "n,a,b,p,q=map(int,input().split())\nif p<q: p,q,a,b=q,p,b,a\ndef gcd(a,b):\n while b: a,b=b,a%b\n return a\nprint(n//a*p+n//b*q-n//(a*b//gcd(a,b))*q)"}, {"source_code": "n,a,b,p,q=map(int,input().split())\ndef gcd(a,b):\n while b: a,b=b,a%b\n return a\nprint(n//a*p+n//b*q-n//(a*b//gcd(a,b))*min(p,q))"}, {"source_code": "from fractions import gcd\nn,a,b,p,q=map(int,input().split())\nmax=max(p,q)\nt=n//((a*b)//gcd(a,b))\nsum=(n//a)*p +(n//b)*q -(t*min(p,q))\nprint(sum)\n\n"}, {"source_code": "import sys\n\ndef gcd(x, y):\n if x < y:\n return gcd(y, x)\n if x % y == 0:\n return y\n return gcd(y, x % y)\n\nf = sys.stdin\nn, a, b, p, q = map(int, f.readline().strip().split(' '))\nx = n / a\ny = n / b\nz = n * gcd(a, b) / a / b\nprint(p * (x - z) + q * (y - z) + z * max(p, q))\n"}, {"source_code": "# cook your dish here\nimport math\nn, a,b ,p, q = map(int,input().split())\n\nlcm = (a//math.gcd(a,b))*b\n\nans = (n//a - n//lcm)*p + (n//b - n//lcm)*q + (n//lcm)*max(p,q)\n\nprint(ans)"}, {"source_code": "from math import gcd\nn,a,b,p,q=map(int,input().split())\nlcm=a*b//gcd(a,b)\nr=n//a-n//lcm\nb=n//b-n//lcm\nans=r*p+b*q+(n//lcm)*max(p,q)\nprint(ans)"}, {"source_code": "'''#4C\nn = int(raw_input())\nl = []\nl2 = []\nl3 = []\nfor i in range(n):\n\ta = raw_input()\n\tif a in l2:\n\t\tb=l2.index(a)\n\t\tj = l3[b]\n\t\ta += str(j)\n\t\tl3[b] += 1\n\telse:\n\t\tl2.append(a)\n\t\tl3.append(1)\n\tl.append(a)\nfor i in l:\n\tif (i[len(i)-1] in '0123456789')==0:\n\t\tprint('OK')\n\telse:\n\t\tprint(i)'''\nimport fractions\ndef LCM(a,b):return abs(a * b) / fractions.gcd(a,b) if a and b else 0\n\nn,a,b,p,q = map(int,raw_input().split(' '))\nif p<q:\n\ta,b,p,q = b,a,q,p\nt = n//a*p\ng = n//b - n//LCM(a,b)\nt += g*q\nprint(t)\n"}], "negative_code": [{"source_code": "from math import floor\na,b,c,d,e = map(int, input().split())\nresp = d * (floor(a // b))\nresp += e * (floor(a // c))\nprint(resp)"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nn,a,b,p,q = map(int, input().split())\n\nif q > p:\n a,b = b,a\n p,q = q,p\n\nres = (n//a)*p + (n//b)*q - (n//(a*b))*q\n\nprint(res)\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\nm = n // (a * b)\nret = (n // a - m) * p + (n // b - m) * q + m * max(p, q)\nprint(ret)\n"}, {"source_code": "import fractions\nn,a,b,p,q=map(int,input().split())\nnok=a*b//fractions.gcd(a,b)\nif a>b:\n a,b,p,q=b,a,q,p\nprint((n//b)*q+(n//a-n//nok)*p)\n\n"}, {"source_code": "import sys;\n\ndef getGcm(a, b):\n\tif (b > a):\n\t\treturn getGcm(b, a);\n\tif (0 == a % b):\n\t\treturn b;\n\treturn getGcm(b, a % b);\n\nnums = map(int, sys.stdin.readline().split());\n\nn = nums[0];\na = nums[1];\nb = nums[2];\np = nums[3];\nq = nums[4];\n\nab = getGcm(a, b) - 1;\n\na = int(n / a);\nb = int(n / b);\n\nif (p > q):\n\tprint (a * p + (b - ab) * q);\nelse:\n\tprint ((a - ab) * p + b * q);"}, {"source_code": "n,a,b,p,q = map(int, input().split())\nA = n//a\nB = n//b\nAandB = n//(a*b)\nprint(A*p + B*q - min(p,q)*AandB)\n"}, {"source_code": "n,a,b,p,q=map(int,raw_input().split())\nprint((n/(b*a))*max(p,q))+(n/a-(n/(b*a)))*p+(n/b-(n/(b*a)))*q\n"}, {"source_code": "from math import ceil\na,b,c,d,e = map(int, input().split())\nachou = False\nachou2 = False\nachou3 = False\nprimeiro3 = ultimo3 = primeiro = primeiro2 = ultimo = ultimo2 = 0\nfor i in range(1, a+1):\n\tif not achou and i % b == 0:\n\t\tprimeiro = i\n\t\tachou = True\n\tif not achou2 and i % c == 0:\n\t\tprimeiro2 = i\n\t\tachou2 = True\n\tif not achou3 and i % c == 0 and i % b == 0:\n\t\tprimeiro3 = i\n\t\tachou3 = True\n\tif achou and achou2 and achou3:\n\t\tbreak\nachou, achou2, achou3 = False, False, False\nfor i in range(a,0,-1):\n\tif not achou and i % b == 0:\n\t\tultimo = i\n\t\tachou = True\n\tif not achou2 and i % c == 0:\n\t\tultimo2 = i\n\t\tachou2 = True\n\tif not achou3 and i % c == 0 and i % b == 0:\n\t\tultimo3 = i\n\t\tachou3 = True\n\tif achou and achou2 and achou3:\n\t\tbreak\nif primeiro != 0 and ultimo != 0:\n\tresp = ((ultimo - primeiro + b) // b) * d\nelse: resp = 0\nif primeiro2 != 0 and ultimo2 != 0:\n\tresp += ((ultimo2 - primeiro2 + c) // c) * e\nelse: resp = 0\nif ultimo3 != 0 and primeiro3 != 0:\n\tsera = ceil((ultimo3 - primeiro3 + b + c) / 2)\nelse: sera = 0\nprint(resp - sera)"}, {"source_code": "n, a, b, p, q = [int(j) for j in raw_input().split()]\nprint p * int(n / a) + q * int(n / b) - min(p, q) * int(n / (a * b))"}, {"source_code": "n, a, b, p, q = map(int, input().split())\nprint(p * (n // a - n // (a * b)) + q * (n // b))"}, {"source_code": "n,a,b,p,q = map(int, input().split())\nboth = (n//(a*b))\nans = (both)*max(p,q) + ((n//a - both) * p) + ((n//b - both) * q);\nprint(ans) "}, {"source_code": "from fractions import gcd\n\n\nn, a, b, p, q = map(int, raw_input().split())\n\nnab = n / ((a * b) / gcd(a, b))\n\nprint ((n / a - nab) * p + (n / b - nab) * q + nab * max(p, q))*(-1**(n+1))"}, {"source_code": "n,a,b,p,q=map(int, input().split())\nprint((n//a)*p+(n//b)*q-(n//(a*b))*min(p,q))"}, {"source_code": "def pgcd(a,b):\n if a==0 or b==0:\n return a+b\n return pgcd(b,a%b)\n\ndef ppcm(a,b):\n return a*b//pgcd(a,b)\n \nn,a,b,p,q=map(int, input().split())\n\nN=0\n\nif a<n or b<n:\n N=p*(n//a)+q*(n//b)-min(p,q)*(n//ppcm(a,b))\n\nprint(N)"}, {"source_code": "import fractions\nn,a,b,p,q=map(int,input().split())\nnok=a*b//fractions.gcd(a,b)\nif a>b:\n a,b,p,q=b,a,q,p\nprint((n//b)*q+(n//a-n//nok)*p)\n\n"}, {"source_code": "from math import ceil\nfrom math import floor\t\nfrom math import sqrt\nfrom math import log\nimport math\n\nprime = pow(10, 9) + 7\n\ndef mod_expo(n, p, m):\n\t\"\"\"find (n^p)%m\"\"\"\n\tresult = 1\n\twhile p != 0:\n\t\tif p%2 == 1:\n\t\t\tresult = (result * n)%m\n\t\tp //= 2\n\t\tn = (n * n)%m\n\treturn result\n\t\ndef find_sequences(n):\n\tresult = []\n\tif n <= 3:\n\t\treturn result\n\twhile n > 5:\n\t\tresult.append(\"24 * 1 = 24\")\n\t\tresult.append(str(n) + \" - \" + str(n-1) + \" = 1\")\n\t\tn -= 2\n\tresult.reverse()\n\tif n == 4:\n\t\tresult.insert(0, \"1 + 2 = 3\")\n\t\tresult.insert(1, \"3 + 3 = 6\")\n\t\tresult.insert(2, \"4 * 6 = 24\")\n\telif n == 5:\n\t\tresult.insert(0, \"1 + 4 = 5\")\n\t\tresult.insert(1, \"5 * 5 = 25\")\n\t\tresult.insert(2, \"25 - 3 = 22\")\n\t\tresult.insert(3, \"22 + 2 = 24\")\n\treturn result\n\t\ndef check(n, k):\n\tv = 0\n\tleft = n\n\twhile left > 0:\n\t\tcurrent = min(left, k)\n\t\tv += current\n\t\tleft -= current\n\t\tleft -= left//10\n\treturn (2*v >= n)\t\n\t\ndef get_pair_count(n, arr):\n\tcount = 0\n\tmp = {}\n\tfor i in range(n):\n\t\tif arr[i] not in mp:\n\t\t\tmp[arr[i]] = 0\n\t\tmp[arr[i]] += 1 \n\tfor i in range(n):\n\t\tfor deg in range(1, 31):\n\t\t\tval = pow(2, deg) - arr[i] \n\t\t\tif val in mp:\n\t\t\t\tcount += mp[val]\n\t\t\t\tif val == arr[i]:\n\t\t\t\t\tcount -= 1\n\t\tmp[arr[i]] -= 1\n\t\t\t\t\n\treturn count\n\ndef find_bsearch(n):\n\tleft = 1\n\tright = n\n\tmiddle = 0\n\tif n <= 2:\n\t\treturn 1\n\twhile left < right:\n\t\t#if (middle == int((left + right)/2)):\n\t\t#\tright = middle\n\t\tmiddle = left + (right - left)//2\n\t\t#print(left, middle, right)\n\t\tif check(n, middle):\n\t\t\tif middle == left or not check(n, middle-1):\n\t\t\t\treturn middle\n\t\t\tright = middle-1\n\t\telse:\n\t\t\tleft = middle+1\n\treturn left\t\n\t\t\ndef count_resistors(a, b):\n\tlevel = -1\n\twhile b:\n\t\tcont, a = divmod(a, b)\n\t\tlevel += cont\n\t\ta, b = b, a\n\tif a == 1:\n\t\treturn level+1\n\treturn -1\ndef get_moves_count(n):\n\ts = 0\n\tj = 1\n\tfor i in range(3, n+1, 2):\n\t\ts += 4*(i - 1)*j\n\t\tj += 1\n\n\treturn s\n\ndef find_index(n):\n\ti = 2\n\tfibo = [0, 1]\n\twhile(True):\n\t\tfibo.append(fibo[i-1] + fibo[i-2])\n\t\tif fibo[i] == n:\n\t\t\treturn i-2;\n\t\tif fibo[i] > n:\n\t\t\treturn i-3;\n\t\ti += 1\n\ndef primeFactors(n): \n # Print the number of two's that divide n \n\tfactors = []\n\twhile n % 2 == 0: \n\t\tfactors.append(2)\n\t\tn = n / 2\n \n # n must be odd at this point \n # so a skip of 2 ( i = i + 2) can be used \n\tfor i in range(3,int(math.sqrt(n))+1,2): \n \n # while i divides n , print i ad divide n \n\t\twhile n % i== 0: \n\t\t\tfactors.append(i)\n\t\t\tn = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n\tif n > 2: \n\t\tfactors.append(n)\n\tfactors = set(factors)\n\tprint(factors)\n\ndef get_ideal_playlist(n, k, songs):\n\tmx = 0\n\tpref_sum = []\n\tpref_sum.append(0)\n\tsongs.sort(key = lambda x : x[1])\n\tfor i in range(1, n+1):\n\t\tpref_sum.append(songs[i-1][0] + pref_sum[i-1])\n\tfor i in range(1, n+1):\n\t\tcurrent = pref_sum[min(n, i+k-1)] \n\t\tif i > 0:\n\t\t\tcurrent -= pref_sum[i-1]\n\t\tcurrent *= songs[i-1][1]\n\t\tmx = max(mx, current)\n\treturn mx\n\ndef find_max_candies(n, a, b, p, q):\n\tA = n//a\n\tB = n//b\n\tC = n//(a*b)\n\tmx = 0\n\tif q >= p:\n\t\treturn p*(A - C) + q*B\n\treturn p*A + q*(B - C)\n\nt=1\n#t=int(input())\nwhile t:\n\tt = t - 1\n\tcount=0\n\tn, a, b, p, q = map(int, input().split())\n\t#n, k = map(int, input().split())\n\t# text = input()\n\t#n = int(input())\n\t#arr = list(map(int, input().strip().split()))[:n]\n\t# b = list(map(int, input().strip().split()))[:n]\n\t#N = input()\n\t# below = input()\n\t#n, X = map(int, input().split())\n\tsongs = [] \n\t#for i in range(n):\n\t#\tl, b = map(int, input().split())\n\t#\tsongs.append((l, b))\n\t# print(a + g)\n\t\n\tprint(find_max_candies(n, a, b, p, q))\n\t#if is_possible(n, m , x, y):\n\t #\tprint(\"Chefirnemo\")\n\t#else:\n\t#\tprint(\"Pofik\")\n\t#answers = find_sequences(n)\n\t#if len(answers):\n\t#\tprint(\"YES\")\n\t#\tfor answer in answers:\n\t#\t\tprint(answer)\n\t#else:\n\t#\tprint(\"NO\")\n\n\t\n"}, {"source_code": "from fractions import gcd\ndef lcm(x,y):\n return (x * y) // gcd(x,y)\nn,a,b,p,q = map(int,raw_input().split())\ng = lcm(a,b)\nx = n/a\ny = n/b\nz = n/g\nif p>=q:\n y-=z\nelse:\n x-=z\n print x*p + y*q"}, {"source_code": "i = input().split(\" \");\ni = [int(a) for a in i]\n\ndef gcd(a,b):\n\treturn a if b == 0 else gcd(b, a%b)\n\nprint (i[0]//i[1] * i[3] + (i[0]//i[2]) * i[4] - i[0]//(i[1]*i[2]) * gcd(i[1], i[2]) * min(i[3], i[4]))\n"}, {"source_code": "n,a,b,p,q=map(int,raw_input().split())\nprint((n/(b*a))*max(p,q))+(n/a-(n/(b*a)))*p+(n/b-(n/(b*a)))*q\n"}, {"source_code": "import math\n\ninp = input().split()\nn,a,b,p,q = int(inp[0]),int(inp[1]),int(inp[2]),int(inp[3]),int(inp[4])\n\nans = 0\nc = a*b\ncnt = n//c\nans += (n//c)*max(p,q)\nans += (n//a-cnt)*p\nans += (n//b-cnt)*q\n\nprint(ans)"}, {"source_code": "n, a, b, p, q = list(map(int,input().split()))\nk = ((n // a) * p + (n // b) * q - (n // (a * b)) * (p + q)) + (n // (a * b)) * max(p,q)\n\nprint(k)\n\n"}, {"source_code": "n, a, b, p, q = map(int, raw_input().split())\nans = 0\nif p > q:\n\tfor i in range(a, n, a):\n\t\tans += p\n\tfor i in range(b, n, b):\n\t\tif(i % a != 0):\n\t\t\tans+=q\nelse:\n\tfor i in range(a, n, a):\n\t\tif(i % b != 0):\n\t\t\tans+=p\n\tfor i in range(b, n, b):\n\t\t\tans+=q\nprint(ans)"}, {"source_code": "def gcd(a, b):\n if(a==0): return b\n return gcd(b%a, a)\n \ndef lcp(a, b):\n return a*b/gcd(a,b)\n\nn, a, b, p, q = map(int,input().split())\nprint(n//a*p+n//b*q-n//lcp(a,b)*min(p,q))"}, {"source_code": "def gcd(a,b):\n\ta ,b = max(a,b), min(a,b)\n\twhile (a % b != 0):\n\t\taux = b\n\t\tb = a % b\n\t\ta = aux\n\treturn b\n\t\nN, a, b, c_a, c_b = map(int, raw_input().split())\n\ncont = 0\n\nn_a = N / a\nn_b = N / b\nif a % b == 0:\n\tn_ab = N / a\nelif b % a == 0:\n\tn_ab = N /b\nelse :\n\tn_ab = N / (b *a)\n\nn_a -= n_ab\nn_b -= n_ab\n\ncont += n_a * c_a\ncont += n_b * c_b\ncont += n_ab * max(c_a, c_b)\n\nprint cont\n"}, {"source_code": "n,a,b,p,q=map(int, input().split())\nresult = (n//a)*p\nresult += (n//b)*q\nif a%b==0 or b%a == 0:\n if max(p,q) == p:\n result -= (n//max(a,b))*q\n else:\n result -= (n//max(a,b))*p\nelse:\n result -= (n//(a*b))*min(p,q)\nprint(result)\n"}, {"source_code": "n,a,b,p,q = (int(i) for i in input().split())\nprint((n//a*p+n//b*q-n//(a*b)*min(p,q)))"}, {"source_code": "n,a,b,p,q = list(map(int, input().strip().split()))\n\nc = (n // a) * p + (n // b) * q - (n // (a*b)) * min(p,q)\nprint(c)"}, {"source_code": "def main():\n from math import gcd\n n, a, b, p, q = map(int, input().split())\n if p < q:\n a, b, p, q = b, a, q, p\n print(n // a * p + (n - n * gcd(a, b) // a) // b * q)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\ndiv_by_a = n // a\ndiv_by_b = n // b\ndiv_by_ab = n // (a*b)\n\nchoc = div_by_a*p + div_by_b*q\n\nif p > q:\n print(choc - div_by_ab*q)\nelse:\n print(choc - div_by_ab*p)\n\n"}, {"source_code": "import sys\nn,a,b,p,q = map(int,raw_input().split())\nprint ((n/a)*p + (n/b)*q - (n/(a*b))*min(p,q))\n\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\nif (p > q): p, a, q, b = q, b, p, a\nprint(p * (n // a - n // (a * b)) + q * (n // b))"}, {"source_code": "import math\nn,a,b,p,q=map(int, input().split())\n\ntotal = p*(int(n/a)) + q* (int(n/b)) - min(p,q) * (int(n/math.gcd(a,b)))\nprint(total)"}, {"source_code": "n,a,b,p,q=map(int, input().split())\nprint((n//a)*p+(n//b)*q-(n//(a*b))*min(p,q))"}, {"source_code": "#!/usr/bin/env python\n\nfrom fractions import gcd\n\ndef lcm(a, b):\n\tif a%b == 0 or b%a == 0:\n\t\treturn max(a,b)\n\telse:\n\t\treturn a*b\n\nn, a, b, p,q = [int(x) for x in raw_input().split(\" \")]\n\nchocolate_n = 0\n\nchocolate_n += p*(n/a)\nchocolate_n += q*(n/b)\nchocolate_n -= min(p,q)*(n/lcm(a,b))\n\nprint chocolate_n\n"}, {"source_code": "\nn,a,b,p,q=map(int,input().split())\nmax=max(p,q)\nx,y=n//a,n//b\nt=n//(a*b)\nsum=0\nif a%b==0 or b%a==0 :\n if a<b :\n if 2*p >q :\n sum=((x-t+1)*p) +((y-t-1)*q) +(t*max)\n else :\n sum = ((x - t)*p) + ((y - t)*q) + t * max\n else :\n if 2*q >p :\n sum=((x-t-1)*p) +((y-t+1)*q) +(t*max)\n else :\n sum = ((x - t)*p) + ((y - t)*q) + t * max\nelse :\n sum = ((x - t) * p) + ((y - t) * q) + t * max\n\nprint(sum)\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jun 13 21:55:56 2016\n\n@author: Dell_\n\"\"\"\n\nimport sys\nif False:\n input = open('chocolate.txt', 'r')\nelse:\n input = sys.stdin \nx = 0\nnumbers = input.readline().split()\n\nn = int(numbers[0])\na = int(numbers[1])\nb = int(numbers[2])\np = int(numbers[3])\nq = int(numbers[4])\n\nchocolates = 0\nnumBoth = 0\nnumA = n//a\nnumB = n//b\n\ndef HCF(a,b):\n while b > 0:\n t = b\n b = a%b\n a = t\n return a\n\ndef LCM(a, b):\n lcm = (a*b) // (HCF(a,b))\n return lcm\n \nnumBoth = n // LCM(a, b)\n\nchoca = numA * p\nchocb = numB * q\n\nif choca > chocb:\n chocolates = choca + chocb - (numBoth*q)\nelif choca < chocb:\n chocolates = choca + chocb - (numBoth*p)\nelif choca == chocb:\n chocolates = choca + chocb - (numBoth*p)\nprint chocolates"}, {"source_code": "def gcd(a,b) :\n while a%b>=1 and b%a>=1 :\n if a>b :\n a=a%b\n else :\n b=b%a\n if a>b :\n return b\n else :\n return a\n\nn,a,b,p,q = map(int, input().split() )\n\nif q>p :\n print(int(p * (n//a - n//(a*b / gcd(a,b)) ) + q * (n//b)))\nelse :\n print(int(p * (n//a) + q*(n//b - n//(a * b / gcd(a,b)))))"}, {"source_code": "import sys;\n\ndef getGcm(a, b):\n\tif (b > a):\n\t\treturn getGcm(b, a);\n\tif (0 == a % b):\n\t\treturn b;\n\treturn getGcm(b, a % b);\n\nnums = map(int, sys.stdin.readline().split());\n\nn = nums[0];\na = nums[1];\nb = nums[2];\np = nums[3];\nq = nums[4];\n\nab = getGcm(a, b) - 1;\n\na = int(n / a);\nb = int(n / b);\n\nif (p > q):\n\tprint (a * p + (b - ab) * q);\nelse:\n\tprint ((a - ab) * p + b * q);"}, {"source_code": "# theMonkeyKing\n# CodeForces 678 C\n\n# Euclidean GCD BitWise\ndef gcd( a, b ):\n while b != 0 :\n a %= b\n a ^= b\n b ^= a\n return a\n\ndef lcm( a, b ):\n return ( ( a / gcd( a, b ) ) * b )\n\n\n# Taking inputs\nn, a, b, p, q = map(int, raw_input().split())\n\n\n\n# Solution\ncommon = lcm( a, b )\nred = ( n / a ) - ( n / common )\nblue = ( n / b ) - ( n / common )\nres = red * p + blue * q + ( n /common ) * max(p, q)\n\n# Printing Result\nprint res"}, {"source_code": "n,a,b,p,q=map(int, input().split())\nresult = (n//a)*p\nresult += (n//b)*q\nif a%b==0 or b%a == 0:\n if max(p,q) == p:\n result -= (n//max(a,b))*q\n else:\n result -= (n//max(a,b))*p\nelse:\n result -= (n//(a*b))*min(p,q)\nprint(result)\n"}, {"source_code": "import math\nn, a, b, p, q = map(int, input().split())\nlcm = a*b/math.gcd(a, b)\nans = 0\nif p >= q:\n\tans = n//a*p + n//b*q - n//lcm*q\nelse:\n\tans = n//b*q + n//a*p - n//lcm*p\nprint(ans)"}, {"source_code": "import sys\n\nf = sys.stdin\nn, a, b, p, q = map(int, f.readline().strip().split(' '))\nx = n / a\ny = n / b\nz = n / a / b\nprint(p * (x - z) + q * (y - z) + z * max(p, q))\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\nm = n // (a * b)\nret = (n // a - m) * p + (n // b - m) * q + m * max(p, q)\nprint(ret)\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\nif (p > q): p, a, q, b = q, b, p, a\nprint(p * (n // a - n // (a * b)) + q * (n // b))"}, {"source_code": "from fractions import gcd\n\n\nn, a, b, p, q = map(int, raw_input().split())\n\nnab = n / ((a * b) / gcd(a, b))\n\nprint ((n / a - nab) * p + (n / b - nab) * q + nab * max(p, q))*(-1**n)"}, {"source_code": "n, a, b, p, q = map(int, input().split())\n\nboth = n//(a*b)\nred = n//a - both\nblue = n//b - both\n\nrest = 0\nif max(a, b) % min(a, b) == 0:\n rest = max((red-1)*p + q, p + (blue-1)*q)\nelse:\n rest = red*p + blue*q\n\nprint(both*max(p, q) + rest)\n"}, {"source_code": "def main():\n n, a, b, p, q = map(int, input().split())\n if p < q:\n a, b, p, q = b, a, q, p\n print(n // a * p + (n - n // a) // b * q)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, a, b, p, q = map(int, raw_input().split())\n\ndivisiveisA = n / a\ndivisiveisB = n / b\n\ncomuns = n / (a*b)\n\nresultado = divisiveisA * p + divisiveisB * q - comuns * (min(p,q))\n\nprint resultado"}, {"source_code": "import math\nn, a, b, p, q = map(int, input().split())\nlcm = a*b/math.gcd(a, b)\nans = 0\nif p >= q:\n\tans = n//a*p + n//b*q - n//lcm*q\nelse:\n\tans = n//b*q + n//a*p - n//lcm*p\nprint(ans)"}, {"source_code": "def main():\n from math import gcd\n n, a, b, p, q = map(int, input().split())\n if p < q:\n a, b, p, q = b, a, q, p\n print(n // a * p + (n - n * gcd(a, b) // a) // b * q)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys;\n\ndef getGcm(a, b):\n\tif (b > a):\n\t\treturn getGcm(b, a);\n\tif (0 == a % b):\n\t\treturn b;\n\treturn getGcm(b, a % b);\n\nnums = map(int, sys.stdin.readline().split());\n\nn = nums[0];\na = nums[1];\nb = nums[2];\np = nums[3];\nq = nums[4];\n\nab = getGcm(a, b) - 1;\n\na = int(n / a);\nb = int(n / b);\n\nif (p > q):\n\tprint (a * p + (b - ab) * q);\nelse:\n\tprint ((a - ab) * p + b * q);"}, {"source_code": "n, a, b, p, q = map(int, input().split())\ndiv_by_a = n // a\ndiv_by_b = n // b\ndiv_by_ab = n // (a*b)\n\nchoc = div_by_a*p + div_by_b*q\n\nif p > q:\n print(choc - div_by_ab*q)\nelse:\n print(choc - div_by_ab*p)\n\n"}, {"source_code": "n, a, b, p, q = [int(j) for j in raw_input().split()]\nprint p * int(n / a) + q * int(n / b) - min(p, q) * int(n / (a * b))"}, {"source_code": "import sys\n\nf = sys.stdin\nn, a, b, p, q = map(int, f.readline().strip().split(' '))\nx = n / a\ny = n / b\nz = n / a / b\nprint(p * (x - z) + q * (y - z) + z * max(p, q))\n"}, {"source_code": "if __name__ == '__main__':\n n, a, b, p, q = map(int, input().split())\n\n if p < q:\n a, b = b, a\n p, q = q, p\n\n divisible_a = n // a\n divisible_b = n // b\n divisible_ab = n // (a * b)\n\n print(divisible_a * p + (divisible_b - divisible_ab) * q)\n"}, {"source_code": "import math\nn,a,b,p,q=map(int, input().split())\n\ntotal = p*(n//a) + q*(n//b) - min(p,q)*(n//(a*b/math.gcd(a,b)))\nprint(total)"}, {"source_code": "n,a,b,p,q=map(int,input().split())\nif q>p: a,b=b,a; q,p=p,q\nif a%b==0: print((n//a)*p+(n//b)*q-(n//a)*q)\nelif b%a==0: print((n//a)*p)\nelse: print((n//a)*p+(n//b)*q-(n//a//b)*q)"}, {"source_code": "n, a, b, p, q = map(int, input().split())\n\nboth = n//(a*b)\nred = n//a - both\nblue = n//b - both\n\nrest = 0\nif max(a, b) % min(a, b) == 0 and min(a, b) != 1:\n rest = max((red-1)*p + q, p + (blue-1)*q)\nelse:\n rest = red*p + blue*q\n\nprint(both*max(p, q) + rest)\n"}, {"source_code": "if __name__ == '__main__':\n n, a, b, p, q = map(int, input().split())\n\n if p < q:\n a, b = b, a\n p, q = q, p\n\n divisible_a = n // a\n divisible_b = n // b\n divisible_ab = n // (a * b)\n\n print(divisible_a * p + (divisible_b - divisible_ab) * q)\n"}, {"source_code": "n, red, blue, red_cost, blue_cost = map(int, input().split())\nif red%blue == 0:\n blues = n//blue - n//red\n ans = blues*blue_cost + (n//red)*max(red_cost,blue_cost)\nelif blue%red == 0:\n reds = n//red - n//blue\n ans = reds*red_cost + (n//blue)*max(red_cost,blue_cost)\nelse:\n blues = n//blue - n//(red*blue)\n reds = n//red - n//(red*blue)\n ans = blues*blue_cost + reds*red_cost + (n//(red*blue))*max(red_cost,blue_cost)\nprint(ans) "}, {"source_code": "def main():\n n, a, b, p, q = map(int, input().split())\n if p < q:\n a, b, p, q = b, a, q, p\n print(n // a * p + ((n - n // a) // b * q if b % a else 0))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "i = input().split(\" \");\ni = [int(a) for a in i]\n\ndef gcd(a,b):\n\treturn a if b == 0 else gcd(b, a%b)\n\nprint (i[0]//i[1] * i[3] + (i[0]//i[2]) * i[4] - i[0]//(i[1]*i[2]) * gcd(i[1], i[2]) * min(i[3], i[4]))\n"}, {"source_code": "i = input().split(\" \");\ni = [int(a) for a in i]\n\ndef gcd(a,b):\n\treturn a if b == 0 else gcd(b, a%b)\n\nprint (i[0]//i[1] * i[3] + (i[0]//i[2]) * i[4] - i[0]//(i[1]*i[2]) * gcd(i[1], i[2]) * min(i[3], i[4]))\n"}, {"source_code": "import sys\n\nf = sys.stdin\nn, a, b, p, q = map(int, f.readline().strip().split(' '))\nx = n / a\ny = n / b\nz = n / a / b\nprint(p * (x - z) + q * (y - z) + z * max(p, q))\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jun 13 21:55:56 2016\n\n@author: Dell_\n\"\"\"\n\nimport sys\nif False:\n input = open('chocolate.txt', 'r')\nelse:\n input = sys.stdin \nx = 0\nnumbers = input.readline().split()\n\nn = int(numbers[0])\na = int(numbers[1])\nb = int(numbers[2])\np = int(numbers[3])\nq = int(numbers[4])\n\nchocolates = 0\nnumBoth = 0\nnumA = n//a\nnumB = n//b\n\ndef HCF(a,b):\n while b > 0:\n t = b\n b = a%b\n a = t\n return a\n\ndef LCM(a, b):\n lcm = (a*b) // (HCF(a,b))\n return lcm\n \nnumBoth = n // LCM(a, b)\n\nchoca = numA * p\nchocb = numB * q\n\nif choca > chocb:\n chocolates = choca + chocb - (numBoth*q)\nelif choca < chocb:\n chocolates = choca + chocb - (numBoth*p)\nelif choca == chocb:\n chocolates = choca + chocb - (numBoth*p)\nprint chocolates"}, {"source_code": "def gcd(a, b):\n if(a==0): return b\n return gcd(b%a, a)\n \ndef lcp(a, b):\n return a*b/gcd(a,b)\n\nn, a, b, p, q = map(int,input().split())\nprint(n//a*p+n//b*q-n//lcp(a,b)*min(p,q))"}, {"source_code": "import math\n\ninp = input().split()\nn,a,b,p,q = int(inp[0]),int(inp[1]),int(inp[2]),int(inp[3]),int(inp[4])\n\nans = 0\nc = a*b\ncnt = n//c\nans += (n//c)*max(p,q)\nans += (n//a-cnt)*p\nans += (n//b-cnt)*q\n\nprint(ans)"}, {"source_code": "n,a,b,p,q=map(int,raw_input().split())\nprint((n/(b*a))*max(p,q))+(n/a-(n/(b*a)))*p+(n/b-(n/(b*a)))*q\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\n\nboth = n//(a*b)\nred = n//a - both\nblue = n//b - both\n\nrest = 0\nif max(a, b) % min(a, b) == 0 and min(a, b) != 1:\n rest = max((red-1)*p + q, p + (blue-1)*q)\nelse:\n rest = red*p + blue*q\n\nprint(both*max(p, q) + rest)\n"}, {"source_code": "from fractions import gcd\n\n\nn, a, b, p, q = map(int, raw_input().split())\n\nnab = n / ((a * b) / gcd(a, b))\n\nprint ((n / a - nab) * p + (n / b - nab) * q + nab * max(p, q))*(-1**(n+1))"}, {"source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nn,a,b,p,q = map(int, input().split())\n\nif q > p:\n a,b = b,a\n p,q = q,p\n\nres = (n//a)*p + (n//b)*q - (n//(a*b))*q\n\nprint(res)\n"}, {"source_code": "entrada = map(int, raw_input().split())\n\nN = entrada[0]\na = entrada[1]\nb = entrada[2]\np = entrada[3]\nq = entrada[4]\n\nsoma = 0\nfor i in range(1, N+1):\n\tif ((i >= a and i % a) == 0 and (i >= b and i % b == 0)):\n\t\tif (p > q):\n\t\t\tsoma += p\n\t\telse:\n\t\t\tsoma += q\n\t\n\telif (i >= a and i % a == 0):\n\t\tsoma += p\n\telif (i >= b and i % b == 0):\n\t\tsoma += q\n\n\nprint soma\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\n\nboth = n//(a*b)\nred = n//a - both\nblue = n//b - both\n\nrest = 0\nif max(a, b) % min(a, b) == 0 and min(a, b) != 1:\n rest = max((red-1)*p + q, p + (blue-1)*q)\nelse:\n rest = red*p + blue*q\n\nprint(both*max(p, q) + rest)\n"}, {"source_code": "def pgcd(a,b):\n if a==0 or b==0:\n return a+b\n return pgcd(b,a%b)\n\ndef ppcm(a,b):\n return a*b//pgcd(a,b)\n \nn,a,b,p,q=map(int, input().split())\n\nN=0\n\nif a<n or b<n:\n N=p*(n//a)+q*(n//b)-min(p,q)*(n//ppcm(a,b))\n\nprint(N)"}, {"source_code": "n, red, blue, red_cost, blue_cost = map(int, input().split())\nif red%blue == 0:\n blues = n//blue - n//red\n ans = blues*blue_cost + (n//red)*max(red_cost,blue_cost)\nelif blue%red == 0:\n reds = n//red - n//blue\n ans = reds*red_cost + (n//blue)*max(red_cost,blue_cost)\nelse:\n blues = n//blue - n//(red*blue)\n reds = n//red - n//(red*blue)\n ans = blues*blue_cost + reds*red_cost + (n//(red*blue))*max(red_cost,blue_cost)\nprint(ans) "}, {"source_code": "def mdc(a,b):\n\tresto = a % b\n\tif (resto == 0):\n\t\treturn b\n\telse:\n\t\treturn mdc(b, resto)\n\t\n\nN,a,b,p,q = map(int, raw_input().split(' '))\ndivisao_a = N/a\ndivisao_b = N/b\ndivisao_aEb = N/((a*b)/mdc(a,b))\n\nprint (divisao_a*p) - (divisao_b*q) - (divisao_aEb*min(p,q))"}, {"source_code": "n,a,b,p,q = list(map(int, input().strip().split()))\n\nc = (n // a) * p + (n // b) * q - (n // (a*b)) * min(p,q)\nprint(c)"}, {"source_code": "n,a,b,p,q = map(int, input().split())\nboth = (n//(a*b))\nans = (both)*max(p,q) + ((n//a - both) * p) + ((n//b - both) * q);\nprint(ans) "}, {"source_code": "import fractions\nn,red,blue,pred,qblue=10 ** 9,2,3,3,5\np = len(range(red, n +1, red))\nq = len(range(blue, n +1, blue))\ng = (red * blue) // fractions.gcd(red, blue)\ninter = len(range(g, n+1, g))\nif pred > qblue:\n x = p * pred\n y = (q - inter) * qblue\n print(x + y)\nelse:\n x = q * qblue\n y = (p - inter) * pred\n print(x + y)"}, {"source_code": "n, a, b, p, q = [int(j) for j in raw_input().split()]\nprint p * n / a + q * n / b - min(p, q) * n / (a * b)"}, {"source_code": "n,a,b,p,q=map(int, input().split())\nresult = (n//a)*p\nresult += (n//b)*q\nif a%b==0 or b%a == 0:\n if max(p,q) == p:\n result -= (n//max(a,b))*q\n else:\n result -= (n//max(a,b))*p\nelse:\n result -= (n//(a*b))*min(p,q)\nprint(result)\n"}, {"source_code": "from fractions import gcd\n\n\nn, a, b, p, q = map(int, raw_input().split())\n\nnab = n / ((a * b) / gcd(a, b))\n\nprint ((n / a - nab) * p + (n / b - nab) * q + nab * max(p, q))*(-1**n)"}, {"source_code": "n,a,b,p,q = map(int, input().split())\n\nresult = 0\n\ndab = n//(a*b)\nda = n//a\ndb = n//b\nif max(p,q)==q:\n result += dab*q\nelse:\n result += dab*p\n\nresult += (da-dab)*p\nresult += (db-dab)*q\n\nprint(result)\n"}, {"source_code": "n , a , b , p , q = map(int , raw_input().split())\n\npro = a*b\n\nval1 = n / a\nval2 = n / b\nval3 = n / pro\n\nans = val3 * max(p , q) + (val1 - val3)* p + (val2 - val3)*q\n\nprint ans\n\n\n"}, {"source_code": "from fractions import *\n\ndef ppcm(a, b):\n return a * b / gcd(a, b);\n\nn, a, b, p, q = [int(s) for s in input().split()]\n\nif q < p:\n a, b, p, q = b, a, q, p\n\nprint(int(p * ((n//a) - (n//ppcm(a, b))) + q * (n//b)))\n"}, {"source_code": "n, a, b, p, q = map(int, input().split())\ndiv_by_a = n // a\ndiv_by_b = n // b\ndiv_by_ab = n // (a*b)\n\nchoc = div_by_a*p + div_by_b*q\n\nif p > q:\n print(choc - div_by_ab*q)\nelse:\n print(choc - div_by_ab*p)\n\n"}, {"source_code": "import sys\n\nf = sys.stdin\nn, a, b, p, q = map(int, f.readline().strip().split(' '))\nx = n / a\ny = n / b\nz = n / a / b\nprint(p * (x - z) + q * (y - z) + z * max(p, q))\n"}, {"source_code": "def gcd(a, b):\n if(a==0): return b\n return gcd(b%a, a)\n \ndef lcp(a, b):\n return a*b/gcd(a,b)\n\nn, a, b, p, q = map(int,input().split())\nprint(n//a*p+n//b*q-n//lcp(a,b)*min(p,q))"}, {"source_code": "n, red, blue, red_cost, blue_cost = map(int, input().split())\nif red%blue == 0:\n blues = n//blue - n//red\n ans = blues*blue_cost + (n//red)*max(red_cost,blue_cost)\nelif blue&red == 0:\n reds = n//red - n//blue\n ans = reds*red_cost + (n//blue)*max(red_cost,blue_cost)\nelse:\n blues = n//blue - n//(red*blue)\n reds = n//red - n//(red*blue)\n ans = blues*blue_cost + reds*red_cost + (n//(red*blue))*max(red_cost,blue_cost)\nprint(ans) "}, {"source_code": "import sys\n\n# inData = sys.argv[1:]\ninData = input().split()\n\nn, a, b, p, q = map(int, inData)\n\nprint(int(int((n / a)) * p + int((n / b)) * q - int((n / (a * b))) * (min(p, q))))\n\n"}, {"source_code": "import sys;\n\ndef getGcm(a, b):\n\tif (b > a):\n\t\treturn getGcm(b, a);\n\tif (0 == a % b):\n\t\treturn b;\n\treturn getGcm(b, a % b);\n\nnums = map(int, sys.stdin.readline().split());\n\nn = nums[0];\na = nums[1];\nb = nums[2];\np = nums[3];\nq = nums[4];\n\nab = getGcm(a, b) - 1;\n\na = int(n / a);\nb = int(n / b);\n\nif (p > q):\n\tprint (a * p + (b - ab) * q);\nelse:\n\tprint ((a - ab) * p + b * q);"}, {"source_code": "n,a,b,p,q = map(int, input().split())\n\nresult = 0\n\ndab = n//(a*b)\nda = n//a\ndb = n//b\nif max(p,q)==q:\n result += dab*q\nelse:\n result += dab*p\n\nresult += (da-dab)*p\nresult += (db-dab)*q\n\nprint(result)\n"}, {"source_code": "entrada = map(int,raw_input().split())\nn = entrada[0]\nred = entrada[1]\nqtdRed = entrada[3]\nblue = entrada[2]\nqtdBlue = entrada[4]\nsaida = long(0)\nif(qtdRed>=qtdBlue):\n saida += (n / red)*qtdRed\n for i in xrange(1,entrada[0]+1,blue):\n if(i % red == 0 and i % blue == 0):\n pass\n elif(i%blue == 0):\n saida += qtdBlue\nelse:\n saida += (n / blue)*qtdBlue\n for i in xrange(1,entrada[0]+1,red-1):\n if(i % red == 0 and i % blue == 0):\n pass\n elif(i%red == 0):\n saida += qtdRed\nprint saida"}, {"source_code": "n,a,b,p,q=map(int,input().split())\nif q>p: a,b=b,a; q,p=p,q\nprint((n//a)*p+(n//b)*q-(n//a//b)*q)"}, {"source_code": "n, a, b, p, q = map(int, input().split())\nm = n // (a * b)\nret = (n // a - m) * p + (n // b - m) * q + m * max(p, q)\nprint(ret)\n"}, {"source_code": "import sys\n\n# inData = sys.argv[1:]\ninData = input().split()\n\nn, a, b, p, q = map(int, inData)\n\nprint(int(int((n / a)) * p + int((n / b)) * q - int((n / (a * b))) * (min(p, q))))\n\n"}, {"source_code": "#!/usr/bin/env python\n\nn, a, b, p,q = [int(x) for x in raw_input().split(\" \")]\n\nchocolate_n = 0\n\nchocolate_n += p*(n/a)\nchocolate_n += q*(n/b)\n# chocolate_n -= min(p,q)*(n/(a*b))\n\nprint chocolate_n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jun 13 21:55:56 2016\n\n@author: Dell_\n\"\"\"\n\nimport sys\nif False:\n input = open('chocolate.txt', 'r')\nelse:\n input = sys.stdin \nx = 0\nnumbers = input.readline().split()\n\nn = int(numbers[0])\na = int(numbers[1])\nb = int(numbers[2])\np = int(numbers[3])\nq = int(numbers[4])\n\nchocolates = 0\nnumBoth = 0\nnumA = n//a\nnumB = n//b\n\nif a*b <= n:\n numBoth = n // (a*b)\n\nchoca = numA * p\nchocb = numB * q\n\nif choca > chocb:\n chocolates = choca + chocb - (numBoth*q)\nelif choca < chocb:\n chocolates = choca + chocb - (numBoth*p)\nelif choca == chocb:\n chocolates = choca + chocb - (numBoth*p)\nprint chocolates"}, {"source_code": "from fractions import gcd\ndef lcm(a, b):\n return a*b//gcd(a, b)\nn, a, b, p, q = map(int, input().split(' '))\nred = n//a\nblue = n//b\nif (p>q):\n red -= n//lcm(a, b)\n blue += n//lcm(a, b)\nelse:\n red += n//lcm(a, b)\n blue -= n//lcm(a, b)\n\nprint(p*red+q*blue)\n"}, {"source_code": "import math\nn, a, b, p, q = map(int, input().split())\nlcm = a*b/math.gcd(a, b)\nans = 0\nif p >= q:\n\tans = n//a*p + n//b*q - n//lcm*q\nelse:\n\tans = n//b*q + n//a*p - n//lcm*p\nprint(ans)"}], "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769"} {"source_code": "import sys, math\nfrom sys import stdin, stdout\n\nrem = 10 ** 9 + 7\nsys.setrecursionlimit(10 ** 6)\ntake = lambda: map(int, stdin.readline().split())\n\n\ndef help(n,k,check):\n a=0\n b=0\n cnt=0\n #print n,k,check\n while(n>0):\n cnt+=11\n a+=min(k,n)\n n-=min(k,n)\n b+=n/10\n n=n-n/10\n\n return a,b\n\n#help(3000,100,1500)\n\nn=input()\n\nleft=1\nright=n\nif n%2==0:\n check=n/2\nelse:\n check=n/2+1\n\nwhile(left<=right):\n k=(left+right)/2\n\n num,s=help(n,k,check)\n if num==check:\n print k\n exit()\n if left==right:\n print k\n exit()\n\n if num>=check:\n right=k\n else:\n left=k+1\n\nprint k\n", "positive_code": [{"source_code": "n = int(input())\n\nlo, hi = 1, n+1\nreq = (n + 1) // 2\n\nwhile lo < hi:\n\n mid = (lo + hi) // 2\n\n eaten = 0\n candies = n\n while candies > 0:\n val = min(candies, mid)\n eaten += val\n\n candies -= val\n candies -= candies // 10\n\n if eaten >= req:\n hi = mid\n else:\n lo = mid + 1\n\nprint (lo)\n\n"}, {"source_code": "def foo(n,k):\n\tans=0\n\twhile(n):\n\t\tans+=min(n,k)\n\t\tn-=min(n,k)\n\t\tn-=n//10\n\treturn ans\nn=int(input())\nl=1\nh=n\nwhile(l<=h):\n\tm=(l+h)//2\n\tval=foo(n,m)\n\tif(2*val>=n):\n\t\th=m-1\n\telse:\n\t\tl=m+1\nprint(h+1)\n"}, {"source_code": "def simulate(n, k):\n m = n\n cnt = 0\n while m > 0:\n m -= k\n cnt += k\n if m >= 0:\n m -= m // 10\n return cnt + m\n\ndef descent(n, k):\n # print((n, k))\n s = simulate(n, k)\n while s * 2 >= n:\n k -= 1\n if (k == 0):\n break\n s = simulate(n, k)\n return k + 1\n\ndef binsearch(n, l, h):\n if h == l + 1:\n return descent(n, h)\n m = (l + h) // 2\n s = simulate(n, m)\n if s * 2 > n:\n return binsearch(n, l, m)\n else:\n return binsearch(n, m, h)\n\ndef start(n):\n return binsearch(n, 0, n)\n\n# print(simulate(999999999999999973,39259424579862572),simulate(999999999999999973,39259424579862571))\n\nprint(start(int(input())))"}, {"source_code": "n = int(input())\nl = 1\nr = n\nres = n\n\ndef ok(k):\n\tm = n\n\ts = 0\n\twhile (m > 0):\n\t\tif (m <= k):\n\t\t\ts += m\n\t\t\tm = 0\n\t\telse:\n\t\t\ts += k\n\t\t\tm -=k\n\t\tm -= m//10\n\treturn 2 * s >= n\n\nwhile (l <= r):\n\tmid = (l + r) // 2\n\tif (ok(mid)): \n\t\tres = mid\n\t\tr = mid - 1\n\telse: \n\t\tl = mid + 1\nprint(res)"}, {"source_code": "n = int(input())\n\nif n <= 10:\n\tprint(\"1\")\n\texit()\n\ndef check(k):\n\tout = 0\n\tcur = n\n\twhile cur != 0:\n\t\ttmp = min(cur, k)\n\t\tcur -= tmp\n\t\tout += tmp\n\t\tif cur >= 10:\n\t\t\tcur -= cur // 10\n\treturn out\n\nl = 0\nr = 10 ** 18 + 1\nk = (l + r) // 2\nwhile r - l > 1:\n\tif 2 * check(k) >= n:\n\t\tr = k\n\telse:\n\t\tl = k\n\tk = (l + r) // 2\n\nprint(k + 1)\n"}, {"source_code": "def func(n, k):\n v = 0\n p = 0\n while n > 0:\n v += min(k, n)\n n = max(n - k, 0) # Vasya\n p += n // 10\n n -= n // 10 # Petya\n return v >= p\n\nn = int(input())\nlo = 1\nhi = n\nwhile lo <= hi:\n mid = (lo + hi) // 2\n if func(n, mid):\n hi = mid - 1\n else:\n lo = mid + 1\nprint(lo)\n"}, {"source_code": "n = int(input())\ndef cout(x):\n r,res=n,0\n while r>0:\n res+=min(r,x)\n r-=min(r,x)\n r-=r//10\n return res,n-res\ni,j = 0,n\nwhile i+1<j:\n mid = (i+j)//2\n a,b=cout(mid)\n if a<b:i=mid\n else:j=mid\nprint(j)"}, {"source_code": "def p(n,k) :\n k1=0\n k2=0\n while (n>0):\n k1+=min(n,k)\n n-=min(n,k)\n k2+=n//10\n n-=n//10\n if k1>=k2 :\n return True\n else :\n return False\n \n\nn=int(input())\np1=1\nost=n\nwhile (p1<=ost) :\n mid=(p1+ost)//2\n if p(n,mid):\n ost=mid-1\n else :\n p1=mid+1\nprint(p1)\n\n"}, {"source_code": "from math import ceil, sqrt\nn = int(input())\nif n < 20:\n print(1)\nelse:\n l = 1\n r = n\n s = 0\n t = n\n ans = n\n while l <= r:\n s = 0\n mid = (r+l)//2\n t = n\n while t > 0:\n c = min(mid, t)\n s += c\n t -= c\n t -= (t//10)\n if 2*s < n:\n l = mid+1\n elif 2*s >= n:\n r = mid - 1\n ans = mid\n print(ans)\n"}, {"source_code": "n = int(input())\nl = 0\nr = n // 2 + 2\nwhile r - l > 1:\n m = (l + r) // 2\n vasya = 0\n petya = 0\n x = n\n while x:\n if x >= m:\n vasya += m\n x -= m\n petya += x // 10\n x -= x // 10\n else:\n vasya += x\n x = 0\n if vasya >= (n + 1) // 2:\n r = m\n else:\n l = m\nprint(l + 1)"}, {"source_code": "def main():\n n = hi = int(input())\n lo = 1\n while lo < hi:\n mid, x, c = (lo + hi) // 2, n, 0\n while x > mid:\n x -= mid\n c += 1\n x -= x // 10\n if (c * mid + x) * 2 < n:\n lo = mid+1\n else:\n hi = mid\n print(hi)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def check(a,b):\n count=0\n while b>0:\n q =min(b,a)\n b-=q\n b-=(b//10)\n count+=q\n if 2*count >= n:\n return True\n else:\n return False\nn = int(input())\nl=1;ans=0;r=1000000000000000000000000\nwhile l<=r:\n mid=(l+r)//2\n if check(mid,n):\n ans=mid\n r=mid-1\n else:\n l=mid+1\nprint(ans) "}, {"source_code": "n = int(input())\ndef check(k,n):\n cur = n\n s = 0\n while cur > 0:\n o = min(cur, k)\n s += o\n cur -= o\n cur -= (cur // 10)\n return s*2 >= n\nl = 1\nr = n\nans = r\nwhile l <= r:\n k = (l+r)//2\n if check(k, n):\n ans = k\n r = k-1\n else:\n l = k+1\nprint(ans)\n"}, {"source_code": "# Codeforces Round #491 (Div. 2)\nimport collections\nfrom functools import cmp_to_key\n#key=cmp_to_key(lambda x,y: 1 if x not in y else -1 )\nimport math\nimport sys\ndef getIntList():\n return list(map(int, input().split())) \n\nimport bisect \ntry :\n import numpy\n dprint = print\n dprint('debug mode')\nexcept ModuleNotFoundError:\n def dprint(*args, **kwargs):\n pass\ndef makePair(z):\n return [(z[i], z[i+1]) for i in range(0,len(z),2) ]\n\n\n \nn, = getIntList()\n\n\ndef work(k,n):\n a = 0\n b = 0\n while(n>0):\n a += min(n,k)\n if n<=k:\n break\n n-=k\n t = n//10 \n b +=t\n n-=t\n if a>=b:\n return True\n return False\n\n\nr0 = 0\nr1 = n\n\nwhile r0+1<r1 :\n m = (r0+r1)//2\n if work(m,n):\n r1 = m\n else :\n r0 = m\n\nprint(r1)\n\n \n\n \n"}, {"source_code": "N = int(input())\nc = N + 0\ndai = N\nsyou = 0\nif N % 2 == 0:\n hann = N//2\nelse:\n hann = N//2 + 1\nwhile N:\n if c == 0:\n c = 1\n break\n d = N +0\n tasu = 0\n while N > 0:\n if d <= c:\n tasu += d\n break\n d -= c\n tasu += c\n e = d//10\n d -= e\n if tasu>= hann:\n dai = min(dai,c)\n if dai - syou == 1:\n break\n c = (dai+syou)//2\n\n else:\n syou = max(syou,c)\n if (syou+dai)//2 == syou:\n c = dai\n break\n c = (dai+syou)//2\nprint(c)"}, {"source_code": "n = int(input())\nl = 1\nr = n\ndef can(x):\n v = 0\n p = 0\n n1 = n\n while n1 > 0:\n v += min(x, n1)\n n1 -= min(x, n1)\n p += n1 // 10\n n1 -= n1 // 10\n if v >= p: return 1\n else: return 0\nwhile l < r:\n m = (l + r) // 2\n if can(m): r = m\n else: l = m + 1\nprint(r)\n \n"}, {"source_code": "n = int(input())\ndef check(n,k):\n total = 0\n current = int(n)\n while current>0:\n red = min(current,k)\n current -= red\n total += red\n current -= current // 10\n \n return 2*total >= n\n\n\nlower = 1\nupper = n\nans = None\nwhile lower<=upper:\n c = (lower+upper)//2\n ret = check(n,c)\n if ret:\n upper = c-1\n ans = c\n else:\n lower = c+1\nprint (ans)"}, {"source_code": "n = int(input())\n#binary search k - the larger k we choose the more likely we get at least half\nlo,hi = 1,n #obviously we could set k := n to eat the whole box\ndef solve(n,k): #simulate the eating process (quite fast as n := 0.9(n-k))\n ans = 0\n while n > 0:\n ans += min(n,k)\n n -= min(n,k)\n n -= n//10\n return ans\nwhile lo < hi:\n mid = (lo+hi)//2 #note no +1, as there is no (mid-1) below\n if solve(n,mid)*2 >= n:\n hi = mid\n else:\n lo = mid+1\nprint(lo)\n"}, {"source_code": "def read_input():\n\treturn map(int, input().split())\n\nn = int(input())\n\ndef eat(k, n):\n\tans = 0\n\twhile n >= k:\n\t\tans += k\n\t\tn = max(0, (n - k) - (n - k) // 10)\n\tans += n\n\treturn ans\n\nl = 1\nr = n + 1\n\nwhile r - l > 1:\n\tm = (l + r) >> 1\n\tif 2 * eat(m, n) >= n:\n\t\tr = m\n\telse:\n\t\tl = m\n\nprint(l if 2 * eat(l, n) >= n else l + 1)"}, {"source_code": "n = int(input())\n\nend = n\nstart = 0\nmid = n // 2\n\nif n == 1:\n print(1)\nelse:\n while start < end:\n v = 0\n p = 0\n c = n\n while c > 0:\n if c <= mid:\n v += c\n c = 0\n else:\n c -= mid\n v += mid\n\n p += c // 10\n c -= c // 10\n\n if v >= p:\n end = mid - 1\n else:\n start = mid + 1\n mid = (end + start) // 2\n if mid == 0:\n mid = 1\n v = 0\n p = 0\n c = n\n while c > 0:\n if c <= mid:\n v += c\n c = 0\n else:\n c -= mid\n v += mid\n\n p += c // 10\n c -= c // 10\n\n if v >= p:\n print(mid)\n else:\n print(mid + 1)"}, {"source_code": "import math\n\ndef f(n, k):\n ans = 0\n s = 0\n while n > 0:\n s += 1\n if n >= k:\n ans += k\n n -= k\n else:\n ans += n\n n = 0\n if n > 0:\n n = n - n // 10\n return ans\n\nn = input()\nl, r = 1, n\n\nwhile l < r:\n m = (l+r) // 2\n p = f(n, m)\n #print l, r, m, p\n if (p*2 >= n):\n r = m\n else:\n l = m + 1\nprint r"}, {"source_code": "import sys\nn = int(input())\ndef eat(k):\n c = n\n count = 0\n while c > 0:\n d = max(c - k, 0)\n count += c - d\n c = d\n if c > 0:\n c -= c // 10\n if count >= (n + 1) // 2:\n return True\n else:\n return False\nif eat(1):\n print(1)\n sys.exit()\ndef binpoisk():\n r = n\n l = 1\n while r - l > 1:\n middle = (r + l) // 2\n if eat(middle):\n r = middle\n else:\n l = middle\n return r\nprint(binpoisk())\n \n"}, {"source_code": "\nn=int(raw_input())\n\nif n<=40 or n==42:\n print 1\n exit()\n\n\ndef ct(n,k):\n s=n\n a=0\n b=0\n while s>0:\n a+=min(k,s)\n s-=min(k,s)\n b+=s/10\n s-=s/10\n if 2*a>=n:\n return True\n else:\n return False\n\n\ndef ccc(n):\n st=1\n ed=n/2\n mid=(st+ed)/2\n while ed-st>3:\n mid=(st+ed)/2\n #print st,ed, mid\n if ct(n,mid):\n ed=mid\n else:\n st=mid\n for i in range(st,ed+1):\n if ct(n,i):\n return i\n\n\nprint ccc(n)\nexit()\n\n"}, {"source_code": "import sys\nimport math\nimport collections\nfrom pprint import pprint as pp\nmod = 998244353\nMAX = 10**10\n\n\ndef inp():\n return map(int, input().split())\n\n\ndef array():\n return list(map(int, input().split()))\n\n\ndef vector(size, val=0):\n vec = [val for i in range(size)]\n return vec\n\n\ndef matrix(rowNum, colNum, val=0):\n mat = []\n for i in range(rowNum):\n collumn = [val for j in range(colNum)]\n mat.append(collumn)\n return mat\n\n\nn = int(input())\nl, h, ans = 1, n, 0\n\n\ndef fun(k):\n can = n\n temp = 0\n while can > 0:\n temp += min(k, can)\n can -= min(k, can)\n can -= can // 10\n return 2 * temp >= n\n\n\nwhile l <= h:\n m = (l + h) // 2\n if fun(m):\n ans, h = m, m - 1\n else:\n l = m + 1\nprint(ans)\n"}, {"source_code": "n = int(input())\na = 0\nb = n\nwhile b - a != 1:\n k = (a + b) // 2\n c = n\n d = 0\n while c > 0:\n m = min(k, c)\n c -= m\n c -= c // 10\n d += m\n if 2 * d >= n:\n b = k\n else:\n a = k\nprint(b)\n\n"}, {"source_code": "def check(n, k):\n\n total, curr = 0, n\n while curr > 0:\n take = min(curr, k)\n total += take\n curr -= take\n curr -= curr // 10\n\n return total * 2 >= n\n\n\n\ndef find_min_k(n):\n start, end, min_k = 1, n, n\n\n while start <= end:\n middle = (start + end) // 2\n if check(n, middle):\n min_k = min(min_k, middle)\n end = middle - 1\n else:\n start = middle + 1\n\n return min_k\n\nprint(find_min_k(int(input())))\n"}, {"source_code": "n=int(input())\n\nl=1\nr=n\nwhile(l!=r):\n mid=(l+r)//2\n k=n\n t1=0\n while(k>0):\n t1+=min(mid,k)\n k-=min(mid,k)\n k-=k//10\n if(t1>=(n+1)//2):\n r=mid\n else:\n l=mid+1\nprint(l)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Jul 05 21:08:58 2018\n\n@author: harshkhemka\n\"\"\"\ndef check(n,k):\n cur=n\n sum1=0\n while(cur>0):\n o=min(cur,k)\n sum1=sum1+o\n cur=cur-o\n cur=cur-long(cur/10)\n return (sum1*2)>=n\n\ndef process():\n n=long(raw_input())\n l=1\n u=n\n while(l<=u):\n k=long((l+u)/2)\n if check(n,k)==False:\n l=k+1\n else:\n prev=k\n u=k-1#0\n if k==0:\n print(1)\n elif prev==-1:\n print(k)\n else:\n print(prev)\n\nprocess()"}, {"source_code": "n = int(input())\n\nl = 1\nr = (n + 1) // 2\nmid = 0\n\nwhile l < r : \n\tt = n\n\tmid = (l + r) >> 1\n\tcnt = 0\n\twhile t >= 10 : \n\t\tt = t - mid\n\t\tif t > 0 : t = t - t // 10\n\t\tcnt = cnt + 1\n\tamo = cnt * mid + t\n\tif amo * 2 >= n : r = mid\n\telse : l = mid + 1\nprint(l)"}, {"source_code": "n = int(input())\na = 0\nb = n\nwhile b - a != 1:\n k = (a + b) // 2\n c = n\n d = 0\n while c > 0:\n m = min(k, c)\n c -= m\n c -= c // 10\n d += m\n if 2 * d >= n:\n b = k\n else:\n a = k\nprint(b)\n"}, {"source_code": "def solve(i,n):\n tmp = n\n eaten = 0\n while(tmp > 0):\n eaten += min(tmp,i)\n tmp -= min(tmp,i)\n if(tmp>=10):\n tmp = tmp - (tmp // 10)\n #print i,eaten,n,eaten*1.0/n * 100\n if(eaten >= (n+1)/2):\n return 1\n return 0\nn = int(raw_input())\nlo = 1\nhi = n\nwhile(lo<hi):\n mid = (lo + hi) / 2\n if(solve(mid,n)==1):\n hi = mid\n else:\n lo = mid+1\nfor i in range(max(1,lo-50),lo+100):\n if(solve(i,n)==1):\n print i\n break"}, {"source_code": "#https://codeforces.com/contest/991 \n#Binary Search\n\n\nn=int(input())\n\ndef petya(n, k):\n total = n\n s = 0\n\n while n > 0:\n cur = min(n, k)\n s += cur\n n -= cur\n\n n -= n // 10\n\n return s * 2 >= total\n\n\nlow=1\nhigh=n\ncandies=n\naim=candies/2 \nmid=1\nans=1\n\n\nwhile low<=high:\n\tmid=(low+high)//2 \n\tif(petya(candies,mid)):\n\t\tans=mid\n\t\thigh=mid-1\n\n\telse:\n\t\tlow=mid+1\n\n\t\n\n\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import math\n# t = int(input()) \nt = 1\n\n\ndef check(k, totalCandies, ate=0):\n\tbase = totalCandies\n\twhile 2*ate < base and totalCandies > 0:\n\t\tateNow = min(k, totalCandies)\n\t\tate += ateNow\n\t\ttotalCandies -= ateNow\n\t\ttotalCandies -= (totalCandies//10)\n\t# print(ate, totalCandies)\n\treturn 2*ate >= base\t\t\n\n# print(check(3, 68))s\n\nfor _ in range(t):\n\tcandies = int(input())\n\tl, r, store = 1, candies, math.ceil(candies/2)\n\n\twhile l <= r:\n\t \tmid = (l+r)//2\n\t \tateHalf = check(mid, candies)\n\t \t# print(l, mid, r, \"at mid\", ateHalf)\n\t \tif ateHalf is True:\n\t \t\tstore = mid\n\t \t\tr = mid - 1\n\t \telse:\n\t \t\tl = mid + 1\n\n\tprint(store)"}, {"source_code": "n = int(input())\n\nl, r = 0, 10 ** 18\n\n\ndef enough(n, k):\n was = n\n eaten = 0\n while n > 0:\n eaten += min(n, k)\n n -= k\n if n > 0:\n n -= n // 10\n return 2 * eaten >= was\n\n\nwhile l + 1 < r:\n m = (l + r) // 2\n if not enough(n, m):\n l = m\n else:\n r = m\nprint(r)\n"}, {"source_code": "def f(n, k):\n n0, s = n, 0\n while n > 0:\n s += min(n, k)\n n -= min(n, k)\n n -= n // 10\n return s * 2 >= n0\n\n\ndef g(n):\n lo, hi = 1, n\n while lo < hi:\n mid = (lo + hi) // 2\n if f(n, mid):\n hi = mid\n else:\n lo = mid + 1\n return lo\n\nprint(g(int(input())))\n"}, {"source_code": "n=input()\ndef f(k):\n s=(n+1)//2;m=n\n while s>0and m:\n l=min(k,m);s-=l;m-=l;m-=m//10\n return s<=0\nl=[0,n]\nwhile l[1]-l[0]>1:\n m=sum(l)//2;l[f(m)]=m\nprint(l[1])"}, {"source_code": "n=input()\nl,h=1,n\nwhile l<h:\n m=(l+h)/2\n a,b,c=0,0,n\n while c:\n d=min(c,m)\n a+=d\n c-=d\n b+=c/10\n c-=c/10\n if a<b:\n l=m+1\n else:\n h=m\nprint l"}, {"source_code": "def f(tmpn, k):\n\tvasya = 0\n\taa = tmpn\n\twhile tmpn > 0:\n\t\tt = min(k, tmpn)\n\t\ttmpn -= t \n\t\ttmpn -= tmpn/10\n\t\tvasya += t\n\tif 2*vasya >= aa:\n\t\treturn True\n\treturn False\n\nn = input()\nlow = 1\nhigh = n\n\nwhile low < high:\n\tmid = (low + high)/2\n\tif f(n, mid):\n\t\thigh = mid\n\telse:\n\t\tlow = mid + 1\nprint low"}, {"source_code": "n = input()\nwyn = 0\nif n == 1:\n print '1'\n exit(0)\ndef sim(amount,v):\n a=b=0\n while True:\n if amount-v >= 0:\n amount -= v\n a += v\n b += amount/10\n amount -= amount/10\n else:\n a += amount\n break\n if a>=b:\n return True\n else:\n return False\nl=1\nr=n\nwhile l<r:\n m = (r+l)/2\n aa = sim(n,m)\n if aa == True:\n wyn = m\n r = m\n else:\n l = m+1\nprint wyn"}, {"source_code": "from math import ceil\ndef sol(n,k,c):\n if k==0:\n return -1\n if n<=0:\n return c\n else:\n n1=n\n n=n-k-((n-k)//10)\n return sol(n,k,min(c+k,c+n1))\n \nn=int(input())\nlow=1\nhigh=n\nlim=n//2\nif n%2!=0:\n lim+=1\nwhile high-low>1:\n md=(high+low)//2\n x=sol(n,md,0)\n if x>lim:\n high=md\n else:\n low=md\nx=min(high+1000,n)\nwhile sol(n,x,0)>=lim:\n x-=1\nprint(x+1)\n\n"}, {"source_code": "from math import ceil\ndef sol(n,k,c):\n if n<=0:\n return c\n else:\n n1=n\n n=n-k-((n-k)//10)\n return sol(n,k,min(c+k,c+n1))\n \nn=int(input())\nlow=1\nhigh=n\nlim=n//2\nif n%2!=0:\n lim+=1\nwhile high-low>1:\n md=(high+low)//2\n x=sol(n,md,0)\n if x>lim:\n high=md\n else:\n low=md\nif sol(n,low,0)>=lim:\n print(low)\nelse:\n print(high)\n"}, {"source_code": "n=int(input())\ndef query(k):\n t=n\n g=(n+1)//2\n while t:\n if t<k:\n g-=t\n break\n t-=k\n g-=k\n t=t-t//10\n if g<=0:return 1\n else:return 0\n\ndef bs(l,r):\n if l==r: return l\n m=(l+r)//2\n if query(m):return bs(l,m)\n else: return bs(m+1,r)\n\nprint(bs(1,1000000000000000000))\n"}, {"source_code": "def fun(m,n):\n c=n\n cnt=0\n while(c>0):\n cnt+=min(m,c)\n c-=min(m,c)\n c-=c/10\n if cnt>=(n+1)/2:\n return 1\n else:\n return 0\n \n \n \n \nn=input()\nl,h=1,n\nwhile(l<h):\n md=l+(h-l)/2\n if fun(md,n):\n h=md\n else:\n l=md+1\nprint h\n"}, {"source_code": "n=int(input())\ndef f(k):\n s=(n+1)//2;m=n\n while s>0and m:\n l=min(k,m);s-=l;m-=l;m-=m//10\n return s<=0\nl=[0,n]\nwhile l[1]-l[0]>1:\n m=(sum(l)+1)//2;l[f(m)]=m\nprint(l[1])"}, {"source_code": "n=int(input())\ndef f(k):\n s=(n+1)//2;m=n\n while s>0and m:\n l=min(k,m);s-=l;m-=l;m-=m//10\n return s<=0\nl=[1,1]\nif not f(1):\n l[1]=n//2\n while l[1]-l[0]>1:\n m=sum(l)//2\n l[f(m)]=m\nprint(l[1])"}, {"source_code": "n=int(input())\ndef f(k):\n s=m=n\n while s>0and m:\n l=min(k,m);s-=2*l;m-=l;m-=m//10\n return s<=0\nl=[0,n]\nwhile l[1]-l[0]>1:\n m=sum(l)//2;l[f(m)]=m\nprint(l[1])"}, {"source_code": "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\ndef sim(n, k):\n ans = 0\n while n > 0:\n if n >= k:\n ans += k\n n -= k\n else:\n ans += n\n n = 0\n \n n -= n //10\n \n return ans\n\ndef slv2(N):\n for k in range(1, N):\n if sim(N, k) >= N/2:\n return k\n return 1\n\n \n\n@mt\ndef slv(N):\n if N < 1000:\n return slv2(N)\n\n sk = int(N*0.03)\n ek = int(N*0.1)\n cnd = {}\n while True:\n if ek - sk <= 1:\n break\n ck = (sk + ek)//2\n v = sim(N, ck)\n cnd[ck] = v\n if v <= N/2:\n sk = ck\n else:\n ek = ck\n\n\n H = N//2\n if H*2 == N:\n H -= 1\n\n keys = sorted(cnd.keys())\n for i, k in enumerate(keys):\n if cnd[k] > H:\n error_print(keys[i-1], keys[i])\n for j in range(keys[i-1], keys[i]):\n cnd[j] = sim(N, j)\n break\n keys = sorted(cnd.keys())\n for i, k in enumerate(keys):\n if cnd[k] > H:\n return k\n\n\ndef main():\n N = read_int()\n # N = 999999999999999973\n # N = int(1e+18)\n # N = random.randint(int(1e+18)-10000, int(1e+18))\n print(slv(N))\n\n # for n in range(1000000, 1000000+10):\n # print(n)\n # a = slv(n)\n # b = slv2(n)\n # if a != b:\n # print(n, a, b)\n # break\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(raw_input())\ndef p(n,k):\n\tsum = 0\n\ta = n\n\twhile(n > 0):\n\t\tc = min(k,n)\n\t\tn = n - c\n\t\tn = n - n/10\n\t\tsum = sum + c\n\tif 2*sum >= a:\n\t\treturn True\n\telse:\n\t\treturn False\n\n\nhi = n/10\nlo = 1\nwhile lo < hi:\n\tmid = lo + (hi-lo)/2\n\tif p(n,mid) == True:\n\t\thi = mid \n\telse:\n\t\tlo = mid+1\nprint lo\n\n"}, {"source_code": "#import resource\n#import sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x10000000)\n\"\"\"FLOAT FUCKED ME TWICE THIS TIME\n PRECISION IS A BITCH\n FUCK CF\"\"\"\nfrom sys import stdin, stdout\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\ndef BS(arr, l, r, x):\n if r >= l:\n mid = l + (r - l)/2\n if arr[mid] == x:\n return mid\n elif arr[mid] > x:\n return BS(arr, l, mid-1, x)\n else:\n return BS(arr, mid+1, r, x)\n else:\n return -1\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport itertools\nimport math\nimport Queue\na=input()\nh=a\nl=1\nk=a\nw=a/2\nif(a%2==1):\n w+=1\nwhile(h>=l):\n m=(h+l)/2\n r=0\n e=a\n while(e>0):\n r+=min(m,e)\n e-=min(m,e)\n if(e>9):\n q=e/10\n e-=q\n if(r>=w):\n h=m-1\n k=m\n else:\n l=m+1\nprint k\n"}, {"source_code": "n = int(input())\nl = 1\nr = n\nans = 0\nwhile l <= r:\n count = 0\n k = (l + r) // 2\n now = n\n while now > 0:\n if now - k < 0:\n count += now\n now = 0\n else:\n count += k\n now -= k\n now -= now//10\n if count*2 >= n:\n ans = k\n r = k - 1\n else:\n l = k + 1\nprint(ans)"}, {"source_code": "def fun(n,k):\n s1=0\n s2=n\n while s2>0:\n temp = min(k,s2)\n s2-=temp\n s1+=temp\n s2-=s2/10\n if s1*2>=n:\n return True\n return False\n\n\nn=input()\nk=1\nwhile True:\n if fun(n,k):\n break\n else:\n k*=2\nk=k/2\n\nif k!=0:\n low=k\n high = 2*k+1\n while low<=high:\n mid=(low+high)/2\n if fun(n,mid):\n high=mid-1\n else:\n low=mid+1\n print low\nelse:\n print 1"}, {"source_code": "DEBUG = True\nn = input().strip().split(\" \")\nn = int(n[0])\n\ndef oneTest(N, k):\n n = N\n\n nv = 0\n np = 0\n\n while n > 0:\n if n <= k:\n nv += n\n n = 0\n else:\n n -= k\n nv += k\n\n x = n // 10\n n -= x\n np += x\n\n assert nv + np == N\n return nv * 2 >= N\n\n\ndef getResult(n):\n lo = 1\n hi = n\n while lo < hi:\n mid = (lo + hi) // 2\n if not oneTest(n, mid):\n lo = mid + 1\n else:\n hi = mid\n return lo\n\n\nk = getResult(n)\nprint(k)\n\nif DEBUG:\n if k > 1:\n assert not oneTest(n, k-1)\n assert oneTest(n, k)\n assert oneTest(n, k+1)\n"}, {"source_code": "def check(n,k):\n req = (n//2) + (n%2)\n eat = 0\n while n > 0 and eat < req:\n eat += min(n,k)\n n -= min(n,k)\n n -= n//10\n if eat >= req:\n return True\n else:\n return False\n\nn = int(input())\nl = 1\nr = n\nans = 0\n# l <= r, equal will be there, since you are alloting m-1 and m+1\nwhile l <= r:\n m = (l+r)//2\n if check(n,m):\n r = m-1\n else:\n l = m+1\n\n\nprint(l)\n\n\n\n\n\n"}, {"source_code": "import math as mt\n\n\ndef ans(n, k):\n sm = 0\n while n - k - (n - k) // 10 > 0:\n n = n - k - (n - k) // 10\n sm += k\n sm += n\n return sm\n\n\nn = int(input())\nl = 1\ns = 0\nr = n\nif n%2==0:\n b = n//2\nelse:\n b = n//2 +1\nwhile l <= r:\n mid = (l + r) // 2\n t = ans(n, mid)\n if t == b:\n s = mid\n break\n elif t < b:\n l = mid + 1\n else:\n s = mid\n r = mid - 1\nprint(s)\n"}, {"source_code": "n = int(input())\n\nhalf = (n-1) // 2 + 1\n\ndef simulate(k):\n remain = n\n vasya = 0\n \n while remain > 0:\n vasya += min(k, remain)\n remain -= k\n remain -= remain // 10\n \n return vasya >= half\n\nhi = n\nlo = 0\n\nwhile hi - lo > 1:\n mid = (hi + lo) // 2\n \n if simulate(mid):\n hi = mid\n else:\n lo = mid\n\nprint(hi)"}, {"source_code": "n = int(input())\n\ndef valid(m):\n res = 0\n k = n\n while k > 0:\n res += min(k, m)\n k -= min(k, m)\n k -= k // 10\n return res >= n - res\n\ndef binary_search():\n f, e = 1, int(1<<62)\n while f <= e:\n m = f + e >> 1\n if valid(m):\n e = m - 1\n else:\n f = m + 1\n return f\n\nprint(binary_search())\n"}, {"source_code": "n = int(input())\n \nlo = 1\nhi = n\n \n\n \ndef func(k, n):\n ans = 0\n while n != 0:\n ans += min(n, k)\n n -= min(n, k)\n n -= n // 10\n \n return ans\n \n \nans = 0\nwhile lo <= hi:\n mid = (lo + hi) // 2\n \n a = func(mid, n)\n \n if 2*a >= (n):\n ans = mid\n hi = mid - 1\n else:\n lo = mid + 1\n \nprint(ans)\n"}, {"source_code": "from sys import stdin\ninput=lambda : stdin.readline().strip()\nfrom math import ceil,sqrt,factorial,gcd\nfrom collections import deque\ndef check(n,k):\n\ta=0\n\tb=0\n\twhile n>0:\n\t\tif k<=n:\n\t\t\ta+=k\n\t\t\tn-=k\n\t\telse:\n\t\t\ta+=n\n\t\t\tn=0\n\t\tif n>=10:\n\t\t\tb+=n//10\n\t\t\tn-=n//10\n\tif a>=b:\n\t\treturn True\n\treturn False\n\n\nn=int(input())\nl=1\nr=n\nwhile l<=r:\n\tmid=(l+r)//2\n\t# print(mid,l,r)\n\tif check(n,mid):\n\t\tr=mid-1\n\telse:\n\t\tl=mid+1\nprint(l)"}, {"source_code": "import time\nn = int(input())\n\n\ndef check(k):\n m = n\n t = 0\n while m >= k:\n m -= k\n t += k\n d = m//10\n m -= d\n t += m\n return 2*t >= n\n\n\nlow = 1\nhigh = n\n\n\nwhile low < high:\n mid = low + (high - low) // 2\n if check(mid):\n high = mid\n else:\n low = mid + 1\n\nprint(low)\n"}, {"source_code": "\"\"\"\n#If FastIO not needed, used this and don't forget to strip\n#import sys, math\n#input = sys.stdin.readline\n\"\"\"\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport heapq as h \nfrom bisect import bisect_left, bisect_right\n\nfrom types import GeneratorType\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n import os\n self.os = os\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n self.os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nimport collections as col\n\ndef getInts():\n return [int(s) for s in input().split()]\n\ndef getInt():\n return int(input())\n\ndef getStrs():\n return [s for s in input().split()]\n\ndef getStr():\n return input()\n\ndef listStr():\n return list(input())\n\nMOD = 10**9+7\n\n\n\"\"\"\nwhile N:\n x = min(K,N)\n N -= x\n V += x\n x = N//10\n N -= x\n P += x\n\"\"\"\ndef works(K,n):\n P = V = 0\n while n:\n x = min(K,n)\n n -= x\n V += x\n x = n//10\n n -= x\n P += x\n return V >= P\n \ndef solve():\n N = getInt()\n if works(1,N):\n return 1\n assert(works(N,N))\n right = N\n left = 1\n while right - left > 1:\n middle = (right+left)//2\n if works(middle,N):\n right = middle\n else:\n left = middle\n return right\n \n#for _ in range(getInt()):\nprint(solve())"}, {"source_code": "n=int(input())\ndef w(k):\n s=n\n p=0\n while s>0:\n p+=min(s,k)\n s=max(0,s-k)\n s-=s//10\n if 2*p>=n:\n return True\n return False\n\nl,r=1,n\nwhile l<r:\n m=(l+r)//2\n if w(m):\n r=m\n else:\n l=m+1\nprint(r)"}, {"source_code": "n = int(input())\ndef check(k, n):\n s = 0\n cur = n\n while cur > 0:\n t = min(cur, k)\n s += t\n cur -= t\n cur -= cur // 10\n\n return s * 2 >= n\nl = 1\nr = n // 2\nwhile l < r - 1:\n m = (l + r) // 2\n if not check(m, n):\n l = m + 1\n else:\n r = m\nif l == 0:\n print(r)\nelse:\n if check(l,n):\n print(l)\n else:\n print(r)\n\n\n\n\n\n"}, {"source_code": "import math\n\ndef f(n,choc):\n m,vas=n,0\n while m>0:\n u=min(choc,m)\n vas+=u\n m-=u\n m-=m//10\n return vas\n\nn=int(input())\n\na=[]\nlow,high=1,10**18\nwhile(low<=high):\n mid=low+(high-low)//2\n x=f(n,mid)\n if 2*x<n:\n low=mid+1\n else:\n a.append(mid)\n high=mid-1\n\nprint(min(a))"}, {"source_code": "import math\n\ndef f(n,choc):\n vas,m=0,n\n while(1):\n if (n-choc)<0:\n vas+=n\n n=0\n break\n n-=choc\n vas+=(m-n)\n u=n//10\n if(n-u)<0:\n n=0\n break\n n-=u\n m=n\n return vas\n\nn=int(input())\n\na=[]\nlow,high=1,10**18\nwhile(low<=high):\n mid=low+(high-low)//2\n x=f(n,mid)\n if 2*x<n:\n low=mid+1\n else:\n a.append(mid)\n high=mid-1\n\nprint(min(a))"}, {"source_code": "import sys\nimport bisect\n# import heapq\nfrom math import ceil,floor\n\n\ndef check(k,n):\n fr = 0\n temp= n\n while ( n > 0):\n if n < k :\n fr = fr+n\n n = 0\n else:\n fr = fr + k\n n = n-k\n n -= (n//10)\n return fr*2>= temp\n\nRI = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\nmod = 10**9+7\n# for _ in range(int(ri())):\n\nn = int(ri())\nl = 1\nr = n\nans = r\nwhile ( l <= r):\n mid = (l+r)//2\n if check(mid,n):\n r = mid-1\n ans = min(ans,mid)\n else:\n l = mid+1\nprint(ans)"}, {"source_code": "def ii():\n return int(input())\ndef mi():\n return map(int, input().split())\ndef li():\n return list(mi())\n \ndef f(n, k):\n c = 0\n e = 0\n while n > 0:\n e += min(k, n)\n n -= k\n n -= n // 10\n c += 1\n return e\n\nn = ii()\nlo = 1\nhi = th = (n + 1) // 2\nwhile lo < hi:\n mid = (lo + hi) // 2\n cnt = f(n, mid)\n if cnt >= th:\n hi = mid\n else:\n lo = mid + 1\nprint(lo)"}, {"source_code": "n = int(input())\n\nans = 1\n\nl = 0\nr = n\nwhile l<r:\n m = (l+r)//2\n a = n\n x = 0\n y = 0\n while a>9:\n x+=min(m,a)\n a-=min(m,a)\n if a>9:\n y+=a//10\n a-=a//10\n x+=a\n if x>=n//2+n%2:\n ans = m\n r = m\n else:\n l = m+1\nprint(max(ans,1))\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\n\ndef rli():\n return list(map(int, input().split()))\n\n\ndef eat(n, k):\n ans = 0\n while n:\n ans += min(n, k)\n n -= min(n, k)\n n -= n // 10\n return ans\n\n\ndef main():\n n = int(input())\n k = n\n now = 1 << 60\n need = n // 2 + (n % 2 != 0)\n while now:\n if k - now > 0 and eat(n, k - now) >= need:\n k -= now\n now >>= 1\n print(k)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "\nn = int(input())\n\n\ndef check(k):\n num = n\n f, s = 0, 0\n while True:\n \n if num < k:\n f += num\n break\n else:\n f += k\n num -= k\n z = num // 10\n num -= z\n s += z\n\n return f >= s\n\nl= 1\nr = n\n\n\nwhile l <= r:\n if (l == r):\n mid = l\n break\n mid = (l + r) // 2\n if check(mid):\n r = mid\n else:\n l = mid + 1\n \n\nprint(mid)\n"}, {"source_code": "n = int(input())\n\ndef can(x):\n v = 0\n t = n\n while t>0:\n if t<max(x,10) :\n v += t\n break\n v += x\n t -= x\n t -= t//10\n return (v >= ((n+1)//2))\n\nlo = 1\nhi = n\nwhile lo<hi:\n mid = lo+((hi-lo)>>1);\n if can(mid):\n hi=mid\n else:\n lo=mid+1\nprint(lo)\n"}, {"source_code": "R = lambda: map(int, input().split())\nn = int(input())\nl, r = 1, n\nwhile l < r:\n m = (l + r) // 2\n nc, vc = n, 0\n while nc > 0:\n vc += min(m, nc)\n nc -= min(m, nc)\n nc -= nc // 10\n if vc * 2 >= n:\n r = m\n else:\n l = m + 1\nprint(l)"}, {"source_code": "def check(n,a):\n e=0\n n1=n\n while n1>0:\n e+=min(n1,a)\n n1-=min(n1,a)\n n1-=n1//10\n \n if 2*e>=n:\n return True\n return False\nn=int(input())\nl=1\nr=n\nans=2*(10**18)\nwhile l<=r:\n mid=(l+r)//2\n if check(n,mid):\n ans=min(mid,ans)\n r=mid-1\n else:l=mid+1\nprint(ans)\n"}, {"source_code": "def count(n,k):\n v,p = 0,0\n while True:\n v+=k\n n=n-k\n if n>=10:\n t=n//10\n p+=t\n n=n-t\n else:\n break\n v+=n\n if v>=p:\n return True\n else:\n return False\nn = int(input())\nif n<30:\n print(1)\nelse:\n low,high = 0,n//2\n while low<=high:\n mid = (low+high)//2\n p,q = count(n,mid),count(n,mid-1)\n if p==True and q==False:\n print(mid)\n break\n if p==True and q==True:\n high = mid-1\n if p==False and q==False:\n low = mid+1"}, {"source_code": "def process(n, k):\n cnt = 0\n\n while n > 9:\n x = min(n, k)\n n -= x\n cnt += x\n n -= n // 10\n\n return cnt + n\n\n\nif __name__ == '__main__':\n n = int(input())\n\n hi = n // 2\n lo = 1\n\n k = 1\n\n while hi > lo:\n mid = (hi + lo) // 2\n\n p1 = process(n, mid)\n p2 = process(n, mid - 1)\n\n b1 = p1 * 2 >= n\n b2 = p2 * 2 < n\n\n k = mid\n\n if p2 > p1:\n print(mid)\n\n if b1 and b2:\n break\n elif not b1:\n lo = mid\n else:\n hi = mid\n\n print(k)\n"}, {"source_code": "from __future__ import print_function\nimport sys\nimport math\nimport os.path\nimport random\nfrom copy import deepcopy\nfrom functools import reduce\nfrom collections import Counter, ChainMap, defaultdict\nfrom itertools import cycle, chain\nfrom queue import Queue, PriorityQueue\nfrom heapq import heappush, heappop, heappushpop, heapify, heapreplace, nlargest, nsmallest\nimport bisect\nfrom statistics import mean, mode, median, median_low, median_high\n# CONFIG\nsys.setrecursionlimit(1000000000)\n# LOG \ndef log(*args, **kwargs):\n print(*args, file=sys.stderr, **kwargs)\n# INPUT\ndef ni():\n return map(int, input().split())\ndef nio(offset):\n return map(lambda x: int(x) + offset, input().split())\ndef nia():\n return list(map(int, input().split()))\n# CONVERT\ndef toString(aList, sep=\" \"):\n return sep.join(str(x) for x in aList)\ndef toMapInvertIndex(aList):\n return {k: v for v, k in enumerate(aList)}\n# SORT\ndef sortId(arr):\n return sorted(range(arr), key=lambda k: arr[k])\n# MATH\ndef gcd(a,b):\n while b:\n a, b = b, a % b\n return a\n# MAIN\n\nn, = ni()\n\ndef check(k):\n v = 0\n p = 0\n x = n\n # log(\"check\",k)\n while (x > 0):\n if (x > k):\n v += k\n x -= k\n if (x > 9):\n pd = x // 10\n p += pd\n x -= pd\n else:\n v += x\n x = 0\n \n # log(\" \", x, v, p)\n \n # log(k,v,p)\n return v >= p\n\ndef bsearch(low, high):\n # log(low,high)\n if (low >= high):\n return low\n mid = (low + high) // 2\n if check(mid):\n return bsearch(low, mid)\n else:\n return bsearch(mid+1, high)\n\n\nx = bsearch(1,n)\n# log(x)\nprint(x)"}], "negative_code": [{"source_code": "import math\n\nn = int(input())\n\ndef sim(n, k):\n v = 0\n while n > 0:\n a = min(n, k)\n n -= a\n v += a\n n -= (n//10)\n \n return v\n\nl = 1\nr = n\n\nwhile r-l >= 0:\n mid = (r+l)//2\n \n if sim(n, mid) == math.ceil(n/2):\n break\n \n if sim(n, mid) > math.ceil(n/2):\n r = mid-1\n if sim(n, mid) < math.ceil(n/2):\n l = mid+1\n \nprint(mid)"}, {"source_code": "#!/usr/bin/python\n\nfrom collections import deque\n\ndef ir(): return int(raw_input())\ndef ia(): return map(int, raw_input().split())\n\ndef good(k):\n n = N\n vasya = 0\n while True:\n if n <= k:\n vasya += n\n break\n else:\n n -= k\n vasya += k\n n -= n/10\n return 2 * vasya >= N\n\n# not good(l) good(h)\nN = ir()\nl = 1; h = N\nwhile True:\n if h == l + 1 or h == l: break\n m = (l + h)/2\n if good(m): h = m\n else: l = m\n \nprint h\n"}, {"source_code": "def fun(m,n):\n c=n\n cnt=0\n while(c>0):\n cnt+=min(m,c)\n c-=min(m,c)\n c-=c/10\n if cnt>=n/2:\n return 1\n else:\n return 0\n \n \n \n \nn=input()\nl,h=1,n\nwhile(l<h):\n md=(l+h)/2\n if fun(md,n):\n h=md-1\n else:\n l=md+1\nprint l\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/991/C\nNNNNNNNYYYYYY Problem\n\"\"\"\nimport math\ndef solveBinarySearch(n):\n\n\tlo = 1\n\thi = n\n\t# import pdb; pdb.set_trace()\n\twhile (lo < hi):\n\n\t\tmid = (lo + hi) / 2\n\t\tcandies_eaten = computeNumCandies(mid, n)\n\t\tif (candies_eaten):\n\t\t# if (helper(n, mid)):\n\t\t\thi = mid \n\n\t\telse :\n\t\t\tlo = mid + 1\n\treturn lo\n\ndef computeNumCandies(mid, n):\n\tnum_candies = n\n\tcandies_eaten = 0\n\tpet_eaten = 0\n\t# import pdb; pdb.set_trace()\n\twhile (num_candies > 0):\n\t\t# Vasya eats them all\n\t\tif (num_candies < mid):\n\t\t\tcandies_eaten += num_candies\n\t\t\t# num_candies = 0\n\t\t\t# return candies_eaten\n\t\telse: #Vasya takes mid candies\n\t\t\t# num_candies = num_candies - mid\n\t\t\tcandies_eaten += mid\n\t\tnum_candies = num_candies - mid\n\n\t\t#Petya rounds down the remaining candy\n\t\tpetya_eats = num_candies / 10\n\t\tnum_candies = num_candies - petya_eats\n\t\tpet_eaten = pet_eaten + petya_eats\n\n\treturn candies_eaten >= pet_eaten\n\t\t\nn = int(input())\nprint(solveBinarySearch(n))"}, {"source_code": "n = input().strip().split(\" \")\nn = int(n[0])\n\ndef oneTest(N, k):\n n = N\n\n nv = 0\n np = 0\n\n while n > 0:\n if n <= k:\n nv += n\n n = 0\n else:\n n -= k\n nv += k\n\n x = n // 10\n n -= x\n np += x\n\n return nv / N >= 0.5\n\n\ndef getResult(n):\n lo = 1\n hi = n\n while lo < hi:\n mid = (lo + hi) // 2\n if not oneTest(n, mid):\n lo = mid + 1\n else:\n hi = mid\n return lo\n\n\nk = getResult(n)\nprint(k)\nif k <= 1:\n print(False)\nelse:\n print(oneTest(n, k-1))\nprint(oneTest(n, k))\nprint(oneTest(n, k+1))\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n#-------------------------code---------------------------#\n#vsInput()\n\ndef canEat(k):\n rem=n\n eaten=0\n while(rem>0):\n eat=min(k,rem)\n rem-=eat\n rem-=rem//10\n eaten+=eat\n \n return eaten >= n//2\n \n\n\nn=Int()\n\nlow=1\nhigh=n\n\nwhile(low<=high):\n \n mid=(low+high)//2\n\n if(canEat(mid)):\n ans=mid\n high=mid-1\n else:\n low=mid+1\n\nprint(ans)\n"}, {"source_code": "n = int(input())\n\nfor i in range(1, n):\n v = 0\n p = 0\n start = n\n while start > 0:\n if start <= i:\n v += start\n start = 0\n else:\n start -= i\n v += i\n\n p += int(start / 10)\n start -= int(start / 10)\n if v >= n / 2:\n print(i, v, p)\n break\n"}, {"source_code": "\ndef find_n(k):\n ev = n\n od = ev - k\n ev = od - od // 10\n c = 0\n while 1:\n c += 1\n od = ev - k # u_{2n + 1}\n # print(od, end=\" \")\n if od < 0: return (c - 1 + 1) * k + ev\n ev = od - od // 10 # u_{2n + 2}\n # print(ev)\n\n\nn = int(input())\n#print(n)\n\na = 1\nb = n // 2 + 1\n\nwhile a <= b:\n k = (a + b) // 2\n if find_n(k) > n / 2:\n last = b\n b = k - 1\n elif find_n(k) < n / 2:\n a = k + 1\n else:\n break\n\nprint(k if find_n(k) >= n / 2 else last)\n"}, {"source_code": "def candy_man(n,k):\n sum=0\n curr=n\n while curr>0:\n m=min(k,curr)\n sum+=m\n curr-=m\n curr-=curr//10\n if sum*2>=n:\n return True\n else:\n return False\n\ndef k_maker(n):\n high=n\n low=1\n mid=(high+low)//2\n while low!=high:\n if candy_man(n,mid):\n high=mid\n mid=(low+high)//2\n else:\n low=mid+1\n mid=(high+low)//2\n print(low)\n# n=int(input())\nk_maker(1)"}, {"source_code": "def cas(mid,n):\n\tcalc1 = 0\n\tcalc2 = 0\n\ts = n\n\twhile(calc2 < n/2 and calc1 < n/2 and s > 0):\n\t\ts -= min(mid,s)\n\t\tcalc1 += min(mid,s)\n\t\ts -= int(s/10)\n\t\tcalc2 += int(s/10)\n\t# \tprint(calc1)\n\t# \tprint(calc2)\n\t# print(calc1)\n\t# print(calc2)\n\tif(calc1 >= n/2):\n\t\treturn 1\n\telse:\n\t\t\n\t\treturn -1\n\t\n\n\ndef binS(begin,end,n):\n\tmid = int((begin+end)/2)\n\tp = cas(mid,n)\n\tq = cas(mid+1,n)\n\tif(p == -1 and q == 1):\n\t\treturn mid + 1\n\telif(p == -1 and q == -1):\n\t\treturn binS(mid+1,end,n)\n\telif(p == 1 and q == 1):\n\t\treturn binS(begin,mid-1,n)\n\telse:\n\t\treturn -1\n\n\n\nn = int(input())\nif(n<22):\n\tprint(1)\nelse:\t\n\tprint(binS(0,int(n/2),n))\n\n"}, {"source_code": "n = int(raw_input())\ndef p(n,k):\n\tsum = 0\n\ta = n\n\twhile(n > 0):\n\t\tn = n - k\n\t\tn = n - n/10\n\t\tsum = sum + k\n\tsum = sum + n\n\tif 2*sum >= a:\n\t\treturn True\n\telse:\n\t\treturn False\n\n\nhi = n/10\nlo = 1\nwhile lo < hi:\n\tmid = lo + (hi-lo)/2\n\tif p(n,mid) == True:\n\t\thi = mid \n\telse:\n\t\tlo = mid+1\nprint lo\n\n"}, {"source_code": "def count(n,k):\n v,p = 0,0\n while n>=10:\n v+=k\n n=n-k\n t=n//10\n p+=t\n n=n-t\n v+=n\n if v>=p:\n return True\n else:\n return False\nn = int(input())\nif n<30:\n print(1)\nelse:\n low,high = 0,n//2\n while low<=high:\n mid = (low+high)//2\n p,q = count(n,mid),count(n,mid-1)\n if p==True and q==False:\n print(mid)\n break\n if p==True and q==True:\n high = mid-1\n if p==False and q==False:\n low = mid+1\n"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-04-28 15:31\n# @url:https://codeforces.com/problemset/problem/991/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\n# region fastio\n\nBUFSIZE = 8192\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# ------------------------------\ndef main():\n n=int(input())\n l,r=1,math.ceil(n/2)\n def check(m,n):\n v,p=0,0\n temp=n\n while n>0:\n v+=min(m,n)\n n-=m\n if n>=10:\n p+=(n//10)\n n-=(n//10)\n print (v,p)\n return v>=temp//2\n while l<r:\n mid=(l+r)//2\n if check(mid,n):\n r=mid\n else:\n l=mid+1\n print (l) \nif __name__ == \"__main__\":\n main()"}, {"source_code": "#https://codeforces.com/contest/991 \n#Binary Search\n\n\nn=int(input())\n\ndef petya(n, k):\n total = n\n s = 0\n\n while n > 0:\n cur = min(n, k)\n s += cur\n n -= cur\n\n n -= n // 10\n\n return s * 2 >= total\n\n\nlow=1\nhigh=n\ncandies=n\naim=candies/2 \nmid=1\nans=1\n\n\nwhile low<=high:\n\tmid=(low+high)//2 \n\tif(petya(candies,mid)):\n\t\tans=mid\n\t\thigh=mid-1\n\n\telse:\n\t\tlow=mid+1\n\n\t\n\n\nprint(ans)\nprint(petya(999999999999999973,39259424579862569))\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import math\ngetInputList = lambda : list(input().split())\ngetInputIntList = lambda : list(map(int,input().split()))\n\n\nn = int(input())\n\nh = n//2\nleft = 1 \nright = n\n\ndef eat(k,n):\n\ta = 0\n\twhile n > 0:\n\t\t#print(a,n,k)\n\t\ta += min(k,n)\n\t\tn -= min(k,n)\n\t\tn -= (n*10)//100\n\treturn a\n\nans = eat(39259424579862572,n)\nif n != 1:\n\twhile left <= right:\n\t\tm = (left + right)//2\n\t\teat1 = eat(m,n)\n\t\teat2 = 0\n\t\tif m-1 > 0:\n\t\t\teat2 = eat(m-1,n)\n\t\t\n\t\tif eat1 >= h and eat2 < h:\n\t\t\tprint(eat1,eat2,h)\n\t\t\tprint(m)\n\t\t\tbreak\n\t\tif eat1 < h:\n\t\t\tleft = m\n\t\telse:\n\t\t\tright = m\n\t\t\nelse:\n\tprint(1)"}, {"source_code": "def sum_for_k(n,k,a):\n\tc=0\n\twhile(a[c]>=10):\n\t\ta.append(int((0.90 *(a[c]))-k))\n\t\tc=c+1\n\treturn 0.10 * sum(a)\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n a=list()\n while(l<=u):\n k=int((l+u)/2)\n a.append(n-k)\n petaya=int(sum_for_k(n,k,a))\n vatsaya=n-petaya\n if vatsaya<petaya:\n l=k+1\n else:\n u=k-1#0\n if n%2!=0 or l==0:\n print(l+1)\n else:\n print(l)\n\nprocess()\n"}, {"source_code": "def sum_for_k(n,k,a):\n\tc=0\n\twhile(a[c]>=10):\n\t\ta.append(int((0.90 *(a[c]))-k))\n\t\tc=c+1\n\treturn 0.10 * sum(a)\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n a=list()\n while(l<=u):\n k=int((l+u)/2)\n a.append(n-k)\n petaya=int(sum_for_k(n,k,a))\n vatsaya=n-petaya\n if vatsaya<petaya:\n l=k+1\n else:\n u=k-1\n if l==0:\n print(1)\n else:\n print(l)\n\n\nprocess()"}, {"source_code": "import math\n\ndef check(k):\n\tglobal n\n\tcandies, eaten = n, 0\n\twhile candies > 0:\n\t\teaten += min(k, candies)\n\t\tcandies -= min(k, candies)\n\t\tcandies -= candies/10\n\treturn eaten >= math.ceil(n/2.0)\n\nn = input()\nlo, hi = 1, n/2+1\nwhile lo < hi:\n\tmid = lo + (hi-lo)/2\n\tif check(mid):\n\t\thi = mid\n\telse:\n\t\tlo = mid+1\nprint hi"}, {"source_code": "import math\n\n\nn = int(input())\ninit = math.ceil(n*0.1) + 1\n\nwhile True:\n aux = n\n v = 0\n p = 0\n \n while aux != 0:\n\n if(init >= aux):\n v += aux\n aux -= aux\n else:\n v += init\n aux -= init\n\n p += math.floor(aux*0.1)\n aux -= math.floor(aux*0.1)\n if v < p or init == 1:\n break\n init -= 1\n\n\nif init == 1:\n print(init)\nelse:\n print(init+1)\n\n\n"}, {"source_code": "def p(n,k) :\n k1=0\n k2=0\n while (n>0):\n k1+=min(n,k)\n n-=min(n,k)\n k2+=n//10\n n-=n//10\n if k1>k2 :\n return True\n else :\n return False\n \n\nn=int(input())\np1=1\nost=n\nwhile (p1<=ost) :\n mid=(p1+ost)//2\n if p(n,mid):\n ost=mid-1\n else :\n p1=mid+1\nprint(p1)\n\n"}, {"source_code": "def candy_man(n,k):\n sum=0\n curr=n\n while curr>0:\n m=min(k,curr)\n sum+=m\n curr-=m\n curr-=curr//10\n if sum*2>=n:\n return True\n else:\n return False\n\ndef k_maker(n):\n high=n\n low=1\n mid=(high+low)//2\n while low!=high:\n if candy_man(n,mid):\n high=mid\n mid=(low+high)//2\n else:\n low=mid+1\n mid=(high+low)//2\n print(low)\n# n=int(input())\nk_maker(1)"}, {"source_code": "import math\n\n\nn = int(input())\ninit = math.ceil(n*0.1) + 1\n\nwhile True:\n aux = n\n v = 0\n p = 0\n \n while aux != 0:\n\n if(init >= aux):\n v += aux\n aux -= aux\n else:\n v += init\n aux -= init\n\n p += math.floor(aux*0.1)\n aux -= math.floor(aux*0.1)\n if v < p or init == 1:\n break\n init -= 1\n\nif init == 1:\n print(init)\nelse:\n print(init+1)\n\n\n"}, {"source_code": "n = input().strip().split(\" \")\nn = int(n[0])\n\ndef oneTest(N, k):\n n = N\n\n nv = 0\n np = 0\n\n while n > 0:\n if n <= k:\n nv += n\n n = 0\n else:\n n -= k\n nv += k\n\n x = n // 10\n n -= x\n np += x\n\n return nv / N >= 0.5\n\n\ndef getResult(n):\n lo = 1\n hi = n\n while lo < hi:\n mid = (lo + hi) // 2\n if not oneTest(n, mid):\n lo = mid + 1\n else:\n hi = mid\n return lo\n\n\nk = getResult(n)\nprint(k)\nif k <= 1:\n print(False)\nelse:\n print(oneTest(n, k-1))\nprint(oneTest(n, k))\nprint(oneTest(n, k+1))\n"}, {"source_code": "from math import ceil\ninp=int(input())\nprint(ceil(inp/2.444987775))"}, {"source_code": "import math\nn = int(input())\ndef f(x):\n global n\n v = p = 0\n last = n\n while last > 0:\n if last >= x:\n last -= x\n v += x\n else:\n last = 0\n v += last\n p += math.floor(last * 0.1)\n last = math.ceil(last * 0.9)\n if v >= p:\n return True\n else:\n return False\n\nleft = 1\nright = n\nwhile right - left > 1:\n middle = (right + left) // 2\n if f(middle) == False:\n left = middle\n else:\n right = middle\nprint(right)\n"}, {"source_code": "from math import ceil, sqrt\nn = int(input())\nif n < 20:\n print(1)\nelse:\n l = 1\n r = n//2\n s = 0\n t = n\n while l < r:\n s = 0\n mid = (r+l)//2\n while t > 0:\n if mid > t:\n s += t\n t = 0\n break\n else:\n s += mid\n t = (t - mid) - ((t-mid)//10)\n if s < ceil(n/2):\n l = mid+1\n t = n\n elif s > ceil(n/2):\n r = mid\n t = n\n elif s == ceil(n/2):\n l = mid\n break\n print(l)\n"}, {"source_code": "n = int(input())\nmid = 1+(n//2)\nlow = 1\nhigh = n\nwhile high-low > 1:\n guess = (low+high)//2\n temp = n\n ate = 0\n while temp > 0:\n if temp >= guess:\n temp -= guess\n ate += guess\n temp -= temp//10\n else:\n temp = 0\n ate += guess\n if ate >= mid:\n high = guess\n else:\n #yay new year\n low = guess\ntemp = n\nguess = low\nl = False\nwhile temp > 0:\n ate = 0\n if temp >= guess:\n temp -= guess\n ate += guess\n temp -= temp//10\n else:\n temp = 0\n ate += guess\nif ate >= mid:\n l = True\n print(low)\nelse:\n print(low+1)"}, {"source_code": "def all(n,k):\n if k == 0:\n return False\n s = 0\n last = n\n while n != 0:\n ss = min(n,k)\n s += ss\n n -= ss\n n -= n//10\n return s > last//2\nn = int(input())\ndef binary_search(n):\n l,r = 0,n\n midd = 0\n while l <= r:\n mid = (l+r+1)//2\n if all(n,mid):\n midd = mid\n r = mid-1\n else:\n l = mid+1\n return midd\nprint(binary_search(n))\n"}, {"source_code": "def sum_for_k(n,k,a):\n\tc=0\n\twhile(a[c]>=10):\n\t\ta.append(int((0.90 *(a[c]))-k))\n\t\tc=c+1\n\treturn 0.10 * sum(a)\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n a=list()\n while(l<=u):\n k=int((l+u)/2)\n a.append(n-k)\n petaya=int(sum_for_k(n,k,a))\n vatsaya=n-petaya\n if vatsaya<petaya:\n l=k+1\n else:\n u=k-1\n print(l)\n\n\nprocess()\n"}, {"source_code": "\nimport math as m\ndef sum_for_k(n,k):\n a=list()\n c=0\n a.append(n-k)\n sum1=0\n while(a[c]>=10):\n diff=m.floor(0.10*a[c])\n a.append((a[c]-(diff+k)))\n sum1+=m.floor(0.10*a[c])\n c=c+1\n return sum1\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n while(l<=u):\n k=int((l+u)/2)\n petaya=int(sum_for_k(n,k))\n vatsaya=n-petaya\n if vatsaya<petaya:\n l=k+1\n else:\n prev=k\n u=k-1#0\n\n if k==0:\n print(1)\n elif n%2!=0 or l==0:\n print(k)\n else:\n print(prev)\n\nprocess()\n"}, {"source_code": "import math\n\nn = int(input())\n\ndef sim(n, k):\n v = 0\n while n > 0:\n a = min(n, k)\n n -= a\n v += a\n n -= (n//10)\n \n return v\n\nl = 1\nr = n\n\nwhile r-l >= 0:\n mid = (r+l)//2\n \n if sim(n, mid) == math.ceil(n/2):\n break\n \n if sim(n, mid) > n/2:\n r = mid-1\n if sim(n, mid) < n/2:\n l = mid+1\n\n\nif sim(n, mid) < n/2:\n while sim(n, mid) < n/2:\n mid += 1\n print(mid)\n\nelif sim(n, mid) > n/2:\n if mid == 1:\n print(mid)\n else:\n while sim(n, mid) > n/2:\n mid -= 1\n\n print(mid+1)\nelse:\n while sim(n, mid) == n/2 and mid != 1:\n mid -= 1\n print(mid+1)"}, {"source_code": "import math\nn = int(input())\n\ndef test(k):\n r = n\n st = 0\n while r > 0:\n r -= k\n if r >= 10:\n st1 = math.floor(0.1 * r)\n st += st1\n r -= st1\n return n-st\nb = n\na = 1\nif test(a) < n/2:\n while b-a > 1:\n mid = (b + a) // 2\n vas = test(mid)\n if vas < n/2:\n a = mid\n else:\n b = mid\n if test(a) >= n/2:\n print(a)\n else:\n print(b)\nelse:\n print(a)\n\n"}, {"source_code": "def simulate(n, k):\n m = n\n cnt = 0\n while m > 0:\n m -= k\n cnt +=k\n if m >= 0:\n m -= m // 10\n return cnt + m\n\n# def descent(n, k):\n# s = simulate(n, k)\n# while s >= n // 2:\n# k -= 1\n# s = simulate(n, k)\n# return k + 1\n\ndef binsearch(n, l, h):\n if h == l + 1:\n return h#descent(n,h)\n m = (l + h) // 2\n s = simulate(n, m)\n if s >= n // 2:\n return binsearch(n, l, m)\n else:\n return binsearch(n, m, h)\n\ndef start(n):\n return binsearch(n, 0, n)\n\nprint(start(int(input())))"}, {"source_code": "import sys\nfrom math import *\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int, minp().split())\n\ndef getans(n,k):\n\tr = 0\n\twhile n > 0:\n\t\tz = min(k, n)\n\t\tr += z\n\t\tn -= z\n\t\tn = n-(n//10)\n\treturn r\n\nn = mint()\nr = n\nl = 1\nwhile (r-l > 1):\n\tc = (r+l)//2\n\tif getans(n,c)*2 >= n:\n\t\tr = c\n\telse:\n\t\tl = c\nprint(r)"}, {"source_code": "N = int(input())\nc = N + 0\ndai = N\nsyou = 0\nwhile N:\n if c == 0:\n c = 1\n break\n d = N +0\n tasu = 0\n while N > 0:\n if d <= c:\n tasu += d\n break\n d -= c\n tasu += c\n e = d//10\n d -= e\n if tasu>= N/2:\n dai = min(dai,c)\n if dai - syou == 1:\n break\n c = (dai+syou)//2\n\n else:\n syou = max(syou,c)\n if (syou+dai)//2 == syou:\n c = dai\n break\n c = (dai+syou)//2\nprint(c)"}, {"source_code": "def f(n,k):\n s=0\n d=n\n while n>9:\n s=s+k\n\n n=n-k\n\n n=n-(n-n%10)/10\n \n s+=n\n \n if s>=d/2:\n return 1\n else:\n return 0\n\n\ndef binarySearch (n,lo, hi):\n \n\n while ( lo < hi ):\n x = lo + (hi-lo)/2\n \n if ( f(n,x) ):\n hi = x\n else:\n lo = x+1\n \n return lo\n\nn=input()\n\nprint binarySearch(n,1,10**18)\n\n"}, {"source_code": "def solve(i,n):\n tmp = n\n eaten = 0\n while(tmp > 0):\n eaten += min(tmp,i)\n tmp -= min(tmp,i)\n if(tmp>=10):\n tmp = tmp - (tmp // 10)\n #print i,eaten,n,eaten*1.0/n * 100\n if(eaten >= n/2.):\n return 1\n return 0\nn = int(raw_input())\nlo = 1\nhi = n\nwhile(lo<hi):\n mid = (lo + hi) / 2\n if(solve(mid,n)==1):\n hi = mid\n else:\n lo = mid+1\nfor i in range(max(1,lo-50),lo+100):\n if(solve(i,n)==1):\n print i\n break"}, {"source_code": "def sum_for_k(n,k,a):\n\tc=0\n\twhile(a[c]>=10):\n\t\ta.append(int((0.90 *(a[c]))-k))\n\t\tc=c+1\n\treturn 0.10 * sum(a)\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n a=list()\n while(l<=u):\n k=int((l+u)/2)\n a.append(n-k)\n petaya=int(sum_for_k(n,k,a))\n vatsaya=n-petaya\n if vatsaya<petaya:\n l=k+1\n else:\n u=k-1#0\n if n%2!=0 or l==0:\n print(l+1)\n else:\n print(l)\n\nprocess()\n"}, {"source_code": "from math import sqrt\nn = input()\ndef eatcandi(n, k):\n a = 0\n b = 0\n if (n <= k):\n return n, 0, 0, True\n else:\n a = k\n b = int((n-k)*0.1)\n na, nb, nc, _= eatcandi(n - a - b, k)\n return a+na, b+nb, nc+1, (a+na) > (b+nb)\n#print('n=', n)\n\nk = int(n*0.05)\nif k == 0:\n k = 1\ncnt = 0\nrightk = k\nleftk = 0\nwhile 1:\n lastk = k\n a, b, r, lb = eatcandi(n, k)\n\n if lb: # b is True a > b\n rightk = k\n k = k - int((rightk-leftk)/2)\n else:\n leftk = k\n k = k + int((rightk - leftk)/2)\n # print('lastk=', lastk, 'k=', k, (a, b, r, lb), (leftk, rightk))\n if (lastk == k):\n if (a == b):\n print(k)\n else:\n if not lb:\n print(k+1)\n else:\n print(k)\n break"}, {"source_code": "from math import *\n\n\ndef cal(x):\n tem, n1, n2 = 0, ceil(n / 2), n\n\n while (n2 > 0 and tem < n1 and x > 0):\n tem += min(x, n2)\n n2 -= min(x, n2)\n n2 -= n2 // 10\n # print(n2, x)\n\n return tem\n\n\ndef bs(be, en, x):\n ans = 0\n while (be < en):\n mid = (be + en) // 2\n val = cal(mid)\n\n if val >= x:\n en = mid\n else:\n be = mid + 1\n # print(be, en, val)\n return en\n\n\nn = int(input())\nprint(bs(0, n, ceil(n / 2)))\n"}, {"source_code": "from math import ceil\n\n\ndef process(n, k):\n cnt = 0\n\n while n > 9:\n x = min(n, k)\n n -= x\n cnt += x\n n -= n // 10\n\n return cnt + n\n\n\nif __name__ == '__main__':\n n = int(input())\n\n hi = n // 2\n lo = 1\n\n k = 1\n\n while hi > lo:\n mid = (hi + lo) // 2\n\n p1 = process(n, mid)\n p2 = process(n, mid - 1)\n\n b1 = p1 >= n // 2\n b2 = p2 < n // 2\n\n k = mid\n\n if p2 > p1:\n print(mid)\n\n if b1 and b2:\n break\n elif not b1:\n lo = mid\n else:\n hi = mid\n\n print(k)\n"}, {"source_code": "\"\"\".\"\"\"\n\n\ndef get_win(cakes_nr, step):\n \"\"\".\"\"\"\n win = 0\n while True:\n if cakes_nr <= step:\n win += cakes_nr\n break\n win += step\n cakes_nr -= step\n cakes_nr -= cakes_nr // 10\n return win\n\n\nprint(2 * get_win(999999999999999973, 39259424579862574))\nprint(2 * get_win(999999999999999973, 39259424579862572))\n\ncakes_nr = int(input())\nl_op = 0\nr_cl = cakes_nr\n\nwhile r_cl - l_op > 1:\n m = (l_op + r_cl) // 2\n win = get_win(cakes_nr, m)\n if win >= (cakes_nr + 1) // 2:\n r_cl = m\n else:\n l_op = m\n\n# curr_best = cakes_nr\n# for i in range(-50_000, 50_001):\n# if r_cl - i <= 0 or r_cl - i > cakes_nr:\n# continue\n# win = get_win(cakes_nr, r_cl - i)\n# if win >= cakes_nr / 2:\n# curr_best = r_cl - i\n\nprint(r_cl)\n"}, {"source_code": "\n\n\ndef sum_for_k(n,k,a):\n\tc=0\n\twhile(a[c]>=10):\n\t\ta.append(int((0.90 *(a[c]))-k))\n\t\tc=c+1\n\treturn 0.10 * sum(a)\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n a=list()\n while(l<=u):\n k=int((l+u)/2)\n a.append(n-k)\n petaya=int(sum_for_k(n,k,a))\n vatsaya=n-petaya\n if vatsaya<petaya:\n l=k+1\n else:\n u=k-1\n print(k+1)\n\n\nprocess()\n"}, {"source_code": "n = int(input())\nl, r = 0, 10 ** 18\n\n\ndef enough(n, k):\n was = n\n eaten = 0\n while n > 0:\n eaten += min(n, k)\n n -= k\n if n > 0:\n n -= n // 10\n return eaten >= was / 2\n\n\nwhile l + 1 < r:\n m = (l + r) // 2\n if not enough(n, m):\n l = m\n else:\n r = m\nprint(r)\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/991/C\nNNNNNNNYYYYYY Problem\n\"\"\"\nimport math\ndef solveBinarySearch(n):\n\n\tlo = 1\n\thi = n\n\t# import pdb; pdb.set_trace()\n\twhile (lo < hi):\n\n\t\tmid = (lo + hi) / 2\n\t\tcandies_eaten = computeNumCandies(mid, n)\n\t\tif (candies_eaten >= n / 2):\n\t\t# if (helper(n, mid)):\n\t\t\thi = mid \n\n\t\telse :\n\t\t\tlo = mid + 1\n\treturn lo\n\ndef helper(n, k):\n a, b = 0, 0\n while n > 0:\n if n >= k:\n a += k\n else:\n a += n\n n -= k\n if n > 9:\n b += n/10\n n -= n/10\n return a >= b\n\n\ndef computeNumCandies(mid, n):\n\tnum_candies = n\n\tcandies_eaten = 0\n\t# import pdb; pdb.set_trace()\n\twhile (num_candies > 0):\n\t\t# Vasya eats them all\n\t\tif (num_candies <= mid):\n\t\t\tcandies_eaten += num_candies\n\t\t\tnum_candies = 0\n\t\t\treturn candies_eaten\n\t\telse: #Vasya takes mid candies\n\t\t\tnum_candies = num_candies - mid\n\t\t\tcandies_eaten += mid\n\n\t\t#Petya rounds down the remaining candy\n\t\tif (num_candies > 9):\n\t\t\tpetya_eats = math.floor(num_candies / 10.0)\n\t\t\tnum_candies = num_candies - petya_eats\n\treturn candies_eaten\n\t\t\nn = int(input())\nprint(solveBinarySearch(n))"}, {"source_code": "def check(n,k):\n v = 0 \n p = 0\n num = n \n while n>0:\n v+=min(n,k)\n n-=min(n,k)\n if n>=10:\n p+=(n//10)\n n-=(n//10)\n return v*2 >= num \nn = int(input())\n\nlow,high = 1,n \n\nwhile low<=high:\n mid = (low+high)//2 \n if check(n,mid):\n high = mid - 1 \n else:\n low = mid + 1 \nprint(mid)"}, {"source_code": "import math\n\n\nn = int(input())\ninit = math.floor(n*0.1) + 1\nwhile True:\n aux = n\n v = 0\n p = 0\n \n while aux != 0:\n\n if(init >= aux):\n v += aux\n aux -= aux\n else:\n v += init\n aux -= init\n\n p += math.floor(aux*0.1)\n aux -= math.floor(aux*0.1)\n\n if v < p or p == 0:\n break\n init -= 1\n\nprint(init+1)\n\n\n"}, {"source_code": "def p(n,k) :\n k1=0\n k2=0\n while (n>0):\n k1+=min(n,k)\n n-=min(n,k)\n k2+=n//10\n n-=n//10\n if k1>k2 :\n return True\n else :\n return False\n \n\nn=int(input())\np1=1\nost=n\nwhile (p1<=ost) :\n mid=(p1+ost)//2\n if p(n,mid):\n ost=mid-1\n else :\n p1=mid+1\nprint(p1)\n\n"}, {"source_code": "def p(n,k) :\n k1=0\n k2=0\n while (n>0):\n k1+=min(n,k)\n n-=min(n,k)\n k2+=n//10\n n-=n//10\n if k1>k2 :\n return True\n else :\n return False\n \n\nn=int(input())\np1=1\nost=n\nwhile (p1<=ost) :\n mid=(p1+ost)//2\n if p(n,mid):\n ost=mid-1\n else :\n p1=mid+1\nprint(p1)\n\n"}, {"source_code": "def check(n,k):\n v = 0 \n p = 0\n num = n \n while n>0:\n v+=min(n,k)\n n-=min(n,k)\n if n>=10:\n p+=(n//10)\n n-=(n//10)\n return v*2 >= num \nn = int(input())\n\nlow,high = 1,n \n\nwhile low<=high:\n mid = (low+high+1)//2 \n if check(n,mid):\n high = mid - 1 \n else:\n low = mid + 1 \nprint(mid)\n"}, {"source_code": "def f(n,k):\n s=0\n d=n\n while n>9:\n s=s+k\n\n n=n-k\n\n n=n-(n-n%10)/10\n \n s+=n\n \n if 2*s>=d:\n return 1\n else:\n return 0\n\n\ndef binarySearch (n,lo, hi):\n \n\n while ( lo < hi ):\n x = lo + (hi-lo)/2\n \n if ( f(n,x) ):\n hi = x\n else:\n lo = x+1\n \n return lo\n\nn=input()\n\nprint binarySearch(n,1,n)"}, {"source_code": "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\ndef sim(n, k):\n ans = 0\n while n > 0:\n if n >= k:\n ans += k\n n -= k\n else:\n ans += n\n n = 0\n \n n -= n //10\n \n return ans\n\ndef slv2(N):\n for k in range(1, N):\n if sim(N, k) >= N/2:\n return k\n return 1\n\n \n\n@mt\ndef slv(N):\n if N < 1000:\n return slv2(N)\n\n sk = int(N*0.03)\n ek = int(N*0.1)\n cnd = {}\n while True:\n if ek - sk <= 1:\n break\n ck = (sk + ek)//2\n v = sim(N, ck)\n cnd[ck] = v\n if v <= N/2:\n sk = ck\n else:\n ek = ck\n\n \n\n keys = sorted(cnd.keys())\n for i, k in enumerate(keys):\n if cnd[k] >= N/2:\n error_print(keys[i-1], keys[i])\n for j in range(keys[i-1], keys[i]):\n cnd[j] = sim(N, j)\n break\n keys = sorted(cnd.keys())\n for i, k in enumerate(keys):\n if cnd[k] >= N/2:\n return k\n\n\ndef main():\n N = read_int()\n # N = int(1e+18)\n # N = random.randint(int(1e+18)-10000, int(1e+18))\n print(slv(N))\n\n # for n in range(1000000, 1000000+10):\n # print(n)\n # a = slv(n)\n # b = slv2(n)\n # if a != b:\n # print(n, a, b)\n # break\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def process(n, k):\n cnt = 0\n\n while n > 9:\n x = min(n, k)\n n -= x\n cnt += x\n n -= n // 10\n\n return cnt + n\n\n\nif __name__ == '__main__':\n n = int(input())\n\n hi = n // 2\n lo = 1\n\n k = None\n\n while hi > lo:\n mid = (hi + lo) // 2\n b1 = process(n, mid) >= n // 2\n b2 = process(n, mid - 1) < n // 2\n\n k = mid\n\n if b1 and b2:\n break\n elif not b1 and not b2:\n lo = mid\n else:\n hi = mid\n\n print(k)\n"}, {"source_code": "from sys import stdin, stdout\nti = lambda : stdin.readline().strip()\nma = lambda fxn, ti : map(fxn, ti.split())\nol = lambda arr : stdout.write(' '.join(str(i) for i in arr) + '\\n')\nos = lambda i : stdout.write(str(i) + '\\n')\nolws = lambda arr : stdout.write(''.join(str(i) for i in arr) + '\\n')\n\n\nn = int(ti())\nl = 1\nr = n\nans = n\ndef ksuits(k, l, r, n):\n\tcur = n\n\tpetya = 0\n\tvasya = 0\n\twhile cur > 0:\n\t\tif cur < 10:\n\t\t\tvasya += cur\n\t\t\tcur = 0\n\t\telse:\n\t\t\tvasya += k\n\t\t\tcur -= k\n\t\t\tpetya += cur/10\n\t\t\tcur -= cur/10\n\treturn vasya*2 >= n\n\nwhile l <= r:\n\tk = (l+r)/2\n\tif ksuits(k, l, r, n):\n\t\tans = k\n\t\tr = k-1\n\telse:\n\t\tl = k+1\nos(ans)"}, {"source_code": "\nimport math as m\ndef sum_for_k(n,k):\n a=list()\n c=0\n a.append(n-k)\n sum1=0\n while(a[c]>=10):\n diff=m.floor(0.10*a[c])\n a.append((a[c]-(diff+k)))\n sum1+=m.floor(0.10*a[c])\n c=c+1\n return sum1\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n while(l<=u):\n k=int((l+u)/2)\n petaya=int(sum_for_k(n,k))\n vatsaya=n-petaya\n if vatsaya<petaya:\n l=k+1\n else:\n prev=k\n u=k-1#0\n\n if k==0:\n print(1)\n elif prev==-1:\n print(k)\n else:\n print(prev)\n\nprocess()\n"}, {"source_code": "import math\ngetInputList = lambda : list(input().split())\ngetInputIntList = lambda : list(map(int,input().split()))\n\n\nn = int(input())\n\nh = n//2\nleft = 1 \nright = n\n\ndef eat(k,n):\n\ta = 0\n\twhile n > 0:\n\t\t#print(a,n,k)\n\t\ta += min(k,n)\n\t\tn -= min(k,n)\n\t\tn -= (n*10)//100\n\treturn a\n\nans = eat(39259424579862572,n)\nif n != 1:\n\twhile left <= right:\n\t\tm = (left + right)//2\n\t\teat1 = eat(m,n)\n\t\teat2 = 0\n\t\tif m-1 > 0:\n\t\t\teat2 = eat(m-1,n)\n\t\t\n\t\tif eat1 >= h and eat2 < h:\n\t\t\tprint(eat1,eat2,h)\n\t\t\tprint(m)\n\t\t\tbreak\n\t\tif eat1 < h:\n\t\t\tleft = m\n\t\telse:\n\t\t\tright = m\n\t\t\nelse:\n\tprint(1)"}, {"source_code": "import math\n\nn = int(input())\n\ndef sim(n, k):\n v = 0\n while n > 0:\n a = min(n, k)\n n -= a\n v += a\n n -= (n//10)\n \n return v\n\nl = 1\nr = n\n\nwhile r-l >= 0:\n mid = (r+l)//2\n \n if sim(n, mid) == math.ceil(n/2):\n break\n \n if sim(n, mid) > n/2:\n r = mid-1\n if sim(n, mid) < n/2:\n l = mid+1\n\nif mid == 1:\n print(mid)\nelse:\n if sim(n, mid) < n/2:\n while sim(n, mid) < n/2:\n mid += 1\n print(mid)\n\n elif sim(n, mid) > n/2:\n while sim(n, mid) > n/2:\n mid -= 1\n\n print(mid+1)\n else:\n while sim(n, mid) == n/2:\n mid -= 1\n print(mid+1)"}, {"source_code": "import math\n\nn = int(input())\n\ndef sim(n, k):\n v = 0\n while n > 0:\n a = min(n, k)\n n -= a\n v += a\n n -= (n//10)\n \n return v\n\nl = 1\nr = n\n\nwhile r-l >= 0:\n mid = (r+l)//2\n \n if sim(n, mid) == math.ceil(n/2):\n break\n \n if sim(n, mid) > n/2:\n r = mid-1\n if sim(n, mid) < n/2:\n l = mid+1\n\n\nif sim(n, mid) < n/2:\n while sim(n, mid) < n/2:\n mid += 1\n print(mid)\n\nelif sim(n, mid) > n/2:\n if mid == 1:\n print(mid)\n else:\n while sim(n, mid) > n/2:\n mid -= 1\n\n print(mid+1)\nelse:\n while sim(n, mid) == n/2 and mid != 1:\n mid -= 1\n print(mid+1)"}, {"source_code": "def greater(nowcandy, x):\n\tvas = 0\n\tpet = 0\n\twhile nowcandy > 0:\n\t\tif nowcandy > x:\n\t\t\tnowcandy = nowcandy - x\n\t\t\tvas = vas + x\n\t\telse:\n\t\t\tvas = vas + nowcandy\n\t\t\tnowcandy = 0\n\t\tpet = pet + int(nowcandy / 10)\n\t\tnowcandy = nowcandy - int(nowcandy/10)\n\tprint(vas, pet)\n\tif vas >= pet:\n\t\treturn True\n\telse:\n\t\treturn False\n\ncandies = int(input())\n\nlo = 1\nhi = 10000000000\n\nwhile lo < hi:\n\tmid = (lo + hi) // 2\n\tif greater(candies, mid):\n\t\thi = mid\n\telse:\n\t\tlo = mid + 1\nprint(lo)"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n#-------------------------code---------------------------#\n#vsInput()\n\ndef canEat(k):\n rem=n\n eaten=0\n while(rem>0):\n eat=min(k,rem)\n rem-=eat\n rem-=rem//10\n eaten+=eat\n \n return eaten >= n//2\n \n\n\nn=Int()\n\nlow=1\nhigh=n\n\nwhile(low<=high):\n \n mid=(low+high)//2\n\n if(canEat(mid)):\n ans=mid\n high=mid-1\n else:\n low=mid+1\n\nprint(ans)\n"}, {"source_code": "from math import *\n\n\ndef cal(x):\n tem, n1, n2 = 0, ceil(n / 2), n\n\n while (n2 > 0 and tem < n1):\n tem += min(x, n2)\n n2 -= min(x, n2)\n n2 -= n2 // 10\n # print(n2, x)\n\n return tem\n\n\ndef bs(be, en, x):\n ans = 0\n while (be + 1 < en):\n mid = ceil((be + en) / 2)\n val = cal(mid)\n\n if val >= x:\n en = mid\n else:\n be = mid + 1\n # print(be, en, val)\n return en\n\n\nn = int(input())\nprint(bs(0, n, ceil(n / 2)))\n"}, {"source_code": "N = int(input())\nc = N + 0\ndai = N\nsyou = 0\nwhile N:\n if c == 0:\n c = 1\n break\n d = N +0\n tasu = 0\n while N > 0:\n if d <= c:\n tasu += d\n break\n d -= c\n tasu += c\n e = d//10\n d -= e\n if tasu>= N/2:\n dai = min(dai,c)\n if dai - syou == 1:\n break\n c = (dai+syou)//2\n\n else:\n syou = max(syou,c)\n if (syou+dai)//2 == syou:\n c = dai\n break\n c = (dai+syou)//2\nprint(c)"}, {"source_code": "n = int(input())\nl, r = 0, 10 ** 20\n\n\ndef enough(n, k):\n was = n\n eaten = 0\n while n > 0:\n eaten += min(n, k)\n n -= k\n if n > 0:\n n -= n // 10\n return eaten >= was / 2\n\n\nwhile l + 1 < r:\n m = (l + r) // 2\n if not enough(n, m):\n l = m\n else:\n r = m\nprint(r)\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/991/C\nNNNNNNNYYYYYY Problem\n\"\"\"\nimport math\ndef solveBinarySearch(n):\n\n\tlo = 1\n\thi = n\n\t# import pdb; pdb.set_trace()\n\twhile (lo < hi):\n\n\t\tmid = (lo + hi) / 2\n\t\tcandies_eaten = computeNumCandies(mid, n)\n\t\tif (candies_eaten):\n\t\t# if (helper(n, mid)):\n\t\t\thi = mid \n\n\t\telse :\n\t\t\tlo = mid + 1\n\treturn lo\n\ndef computeNumCandies(mid, n):\n\tnum_candies = n\n\tcandies_eaten = 0\n\tpet_eaten = 0\n\t# import pdb; pdb.set_trace()\n\twhile (num_candies > 0):\n\t\t# Vasya eats them all\n\t\tif (num_candies < mid):\n\t\t\tcandies_eaten += num_candies\n\t\t\tnum_candies = 0\n\t\t\treturn candies_eaten >= n / 2\n\t\telse: #Vasya takes mid candies\n\t\t\tnum_candies = num_candies - mid\n\t\t\tcandies_eaten += mid\n\t\t# num_candies = num_candies - mid\n\n\t\t#Petya rounds down the remaining candy\n\t\t# if (num_candies > 9):\n\t\tpetya_eats = num_candies / 10\n\t\tnum_candies = num_candies - petya_eats\n\t\tpet_eaten = pet_eaten + petya_eats\n\n\treturn candies_eaten >= n / 2\n\t\t\nn = int(input())\nprint(solveBinarySearch(n))"}, {"source_code": "n = int(input())\nmid = 1+((n-1)//2)\nlow = 1\nhigh = n\nwhile high-low > 1:\n guess = (low+high)//2\n temp = n\n ate = 0\n while temp > 0:\n if temp >= guess:\n temp -= guess\n ate += guess\n temp -= temp//10\n else:\n temp = 0\n ate += temp\n if ate >= mid:\n high = guess\n else:\n #yay new year\n low = guess\ntemp = n\nguess = low\nl = False\nate = 0\nwhile temp > 0:\n if temp >= guess:\n temp -= guess\n ate += guess\n temp -= temp//10\n else:\n temp = 0\n ate += temp\nif ate >= mid:\n l = True\n print(low)\nelse:\n print(low+1)"}, {"source_code": "def fun(n,k):\n s1=0\n s2=n\n while s2>0:\n temp = min(k,s2)\n s2-=temp\n s1+=temp\n s2-=s2/10\n if s1*2>=n:\n return True\n return False\n\n\nn=input()\nk=1\nwhile True:\n if fun(n,k):\n break\n else:\n k*=2\nk=k/2\nfor l in range(k,2*k):\n if fun(n,l):\n print l\n break\n"}, {"source_code": "def simulate(n, k):\n m = n\n cnt = 0\n while m > 0:\n m -= k\n cnt +=k\n if m >= 0:\n m -= m // 10\n return cnt + m\n\n# def descent(n, k):\n# s = simulate(n, k)\n# while s >= n // 2:\n# k -= 1\n# s = simulate(n, k)\n# return k + 1\n\ndef binsearch(n, l, h):\n if h == l + 1:\n return h\n m = (l + h) // 2\n s = simulate(n, m)\n if s >= n / 2:\n return binsearch(n, l, m)\n else:\n return binsearch(n, m, h)\n\ndef start(n):\n return binsearch(n, 0, n)\n\nprint(start(int(input())))"}, {"source_code": "import sys\n\ndef ok(k,n):\n\tif k == 0:\n\t\treturn False\n\tvasya = 0\n\tpetya = 0\n\tN = n\n\twhile n:\n\t\tvasya_i = min(n,k)\n\t\tvasya += vasya_i\n\t\tpetya_i = int((N - (vasya + petya))/float(10))\n\t\tpetya += petya_i\n\t\tn -= petya_i + vasya_i\n\treturn vasya > petya\n\ndef sol(n):\n\tlow = 0\n\thigh = n\n\tans = high\n\twhile low <= high:\n\t\tmid = (low+high)/2\n\t\tif ok(mid,n):\n\t\t\tans = min(ans,mid)\n\t\t\thigh = mid-1\n\t\telse:\n\t\t\tlow = mid+1\n\treturn ans\n\nn = int(sys.stdin.readline().strip())\nprint(sol(n))"}, {"source_code": "n = int(input())\n\nlo = 1\nhi = n\n\ndef check(k):\n global n\n cp = n\n a = 0\n b = 0\n while n>0:\n a += min(n, k)\n n -= min(n, k)\n if n==0:\n break\n b += n//10\n n -= n//10\n if n<=0:\n break\n #print('for',k,a,b)\n n = cp\n return a>=b\n\nwhile lo+1<hi:\n #print(lo, hi)\n mid = (lo+hi+1)//2\n\n if check(mid):\n hi = mid\n else:\n lo = mid+1\nmid = (lo+hi+1)//2\nprint(mid)\n"}, {"source_code": "import sys\n\ndef cas(mid,n):\n\tcalc1 = 0\n\tcalc2 = 0\n\ts = n\n\twhile(calc2 < n/2 and calc1 < n/2 and s > 0):\n\t\tv = min(mid,s)\n\t\ts -= v\n\t\tcalc1 += v\n\t\ts -= s//10\n\t\tcalc2 += s//10\n\t# \tprint(calc1)\n\t# \tprint(calc2)\n\t# print(calc1)\n\t# print(calc2)\n\t# print(s)\n\tif(calc1 >= n/2):\n\t\treturn 1\n\telse:\n\t\t\n\t\treturn -1\n\t\n\n\ndef binS(begin,end,n):\n\tmid = (begin + end) //2\n\tp = cas(mid,n)\n\tq = cas(mid+1,n)\n\tif(end < begin):\n\t\treturn 7\n\tif(p == -1 and q == 1):\n\t\treturn mid + 1\n\telif(p == -1 and q == -1):\n\t\treturn binS(mid+1,end,n)\n\telif(p == 1 and q == 1):\n\t\t# print(\"------\",mid)\n\t\t# print(mid)\n\t\treturn binS(begin,mid-1,n)\n\telse:\n\t\treturn -1\n\n\n# sys.setrecursionlimit(15000)\nn = int(input())\nif(n<22):\n\tprint(1)\nelse:\t\n\tp = int(pow(n,0.5))\n\tprint(binS(0,int(n/2),n))\n\n"}, {"source_code": "'''input\n43\n'''\ndef check(m, k):\n\tn = m\n\tgot = 0\n\twhile n:\n\t\tif n >= k:\n\t\t\tn -= k\n\t\t\tgot += k\n\t\telse:\n\t\t\tgot += n\n\t\t\tn = 0\n\t\tn -= n // 10\n\tif got >= m / 2:\n\t\treturn 1\n\treturn 0\nn = int(input())\nif n < 100:\n\tfor i in range(1, 100):\n\t\tif check(n, i):\n\t\t\tprint(i)\n\t\t\tbreak\nelse:\n\tl = 1\n\th = n\n\twhile l <= h:\n\t\tmid = (l + h) // 2\n\t\tz = check(n, mid)\n\t\tif z == 1:\n\t\t\t#can eat 50 %\n\t\t\th = mid - 1\n\t\telse:\n\t\t\t#can not eat 50 %\n\t\t\tl = mid + 1\n\tprint(mid)"}, {"source_code": "import math\n\ndef check(k):\n\tglobal n\n\tcandies, eaten = n, 0\n\twhile candies > 0:\n\t\teaten += min(k, candies)\n\t\tcandies -= min(k, candies)\n\t\tcandies -= candies/10\n\treturn eaten >= math.ceil(n/2.0)\n\nn = input()\nlo, hi = 1, n\nwhile lo < hi:\n\tmid = lo + (hi-lo)/2\n\tif check(mid):\n\t\thi = mid\n\telse:\n\t\tlo = mid+1\nprint hi"}, {"source_code": "n = int(input())\n\nfor i in range(1, n):\n v = 0\n p = 0\n start = n\n while start > 0:\n if start <= i:\n v += start\n start = 0\n else:\n start -= i\n v += i\n\n p += int(start / 10)\n start -= int(start / 10)\n if v >= n / 2:\n print(i)\n break\n"}, {"source_code": "def Check(mid):\n N = n\n S1 = 0\n while N > 0:\n if N < mid:\n S1 += N\n N = 0\n else:\n S1 += mid\n N -= mid\n N -= int(0.1*N)\n return S1 >= (n+1)//2\nn = int(input())\nl = 0\nr = n\nwhile l < r - 1:\n mid = (l+r)//2\n if Check(mid):\n r = mid\n else:\n l = mid\nprint(r)"}, {"source_code": "#import resource\n#import sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x10000000)\n\nfrom sys import stdin, stdout\ndef GCD(x, y):\n while(y):\n x, y = y, x % y\n return x\ndef BS(arr, l, r, x):\n if r >= l:\n mid = l + (r - l)/2\n if arr[mid] == x:\n return mid\n elif arr[mid] > x:\n return BS(arr, l, mid-1, x)\n else:\n return BS(arr, mid+1, r, x)\n else:\n return -1\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport itertools\nimport math\nimport Queue\na=input()\nh=10**18\nl=1\nk=10**18\nw=int(round(a/2.0))\nwhile(h>=l):\n m=(h+l)/2\n r=0\n e=a\n while(e>0):\n r+=min(m,e)\n e-=min(m,e)\n if(e<10):\n continue\n else:\n q=int(e*0.1)\n e-=q\n if(r>=w):\n h=m-1\n if(m<k):\n k=m\n else:\n l=m+1\nprint k\n"}, {"source_code": "import math\n\ndef check(k):\n\tglobal n\n\tcandies, eaten = n, 0\n\twhile candies > 0:\n\t\teaten += min(k, candies)\n\t\tcandies -= min(k, candies)\n\t\tcandies -= candies/10\n\treturn eaten >= math.ceil(n/2.0)\n\nn = input()\nlo, hi = 1, n\nwhile lo < hi:\n\tmid = lo + (hi-lo)/2\n\tif check(mid):\n\t\thi = mid\n\telse:\n\t\tlo = mid+1\nprint hi"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-04-28 15:31\n# @url:https://codeforces.com/problemset/problem/991/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\n# region fastio\n\nBUFSIZE = 8192\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# ------------------------------\ndef main():\n n=int(input())\n l,r=1,math.ceil(n/2)\n def check(m,n):\n v,p=0,0\n temp=math.ceil(n/2)\n while n>0:\n v+=min(m,n)\n n-=m\n if n>=10:\n p+=(n//10)\n n-=(n//10)\n # print (m,v,p)\n return v>=temp\n while l<r:\n mid=(l+r)//2\n if check(mid,n):\n r=mid\n else:\n l=mid+1\n print (l) \nif __name__ == \"__main__\":\n main()"}, {"source_code": "import math\n\ndef f(n,choc):\n m,vas=n,0\n while m>0:\n u=min(choc,m)\n vas+=u\n m-=u\n m-=m//10\n return vas\n\nn=int(input())\nt=math.ceil(n/2)\n\na=[]\nlow,high=1,n\nwhile(low<=high):\n mid=low+(high-low)//2\n x=f(n,mid)\n if x<t:\n low=mid+1\n else:\n a.append(mid)\n high=mid-1\n\nprint(min(a))"}, {"source_code": "def simulate(n, k):\n m = n\n cnt = 0\n while m > 0:\n m -= k\n cnt +=k\n if m >= 0:\n m -= m // 10\n return cnt + m\n\ndef binsearch(n, l, h):\n if h == l + 1:\n return h\n m = (l + h) // 2\n s = simulate(n, m)\n if s >= n / 2:\n return binsearch(n, l, m)\n else:\n return binsearch(n, m, h)\n\ndef start(n):\n return binsearch(n, 0, n)\n\nprint(start(int(input())))"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/991/C\nNNNNNNNYYYYYY Problem\n\"\"\"\nimport math\ndef solveBinarySearch(n):\n\n\tlo = 1\n\thi = n\n\t# import pdb; pdb.set_trace()\n\twhile (lo < hi):\n\n\t\tmid = (lo + hi) / 2\n\t\tcandies_eaten = computeNumCandies(mid, n)\n\t\tif (candies_eaten):\n\t\t# if (helper(n, mid)):\n\t\t\thi = mid \n\n\t\telse :\n\t\t\tlo = mid + 1\n\treturn lo\n\ndef computeNumCandies(mid, n):\n\tnum_candies = n\n\tcandies_eaten = 0\n\tpet_eaten = 0\n\t# import pdb; pdb.set_trace()\n\twhile (num_candies > 0):\n\t\t# Vasya eats them all\n\t\tif (num_candies < mid):\n\t\t\tcandies_eaten += num_candies\n\t\t\tnum_candies = 0\n\t\t\treturn candies_eaten\n\t\telse: #Vasya takes mid candies\n\t\t\tnum_candies = num_candies - mid\n\t\t\tcandies_eaten += mid\n\t\t# num_candies = num_candies - mid\n\n\t\t#Petya rounds down the remaining candy\n\t\t# if (num_candies > 9):\n\t\tpetya_eats = num_candies / 10\n\t\tnum_candies = num_candies - petya_eats\n\t\tpet_eaten = pet_eaten + petya_eats\n\n\treturn candies_eaten >= pet_eaten\n\t\t\nn = int(input())\nprint(solveBinarySearch(n))"}, {"source_code": "R = lambda: map(int, input().split())\nn = int(input())\nl, r = 1, n\nwhile l < r:\n m = (l + r) // 2\n nc, vc = n, 0\n while nc > 0:\n nc -= min(m, nc)\n vc += min(m, nc)\n nc -= nc // 10\n if vc * 2 >= n:\n r = m\n else:\n l = m + 1\nprint(l)"}, {"source_code": "def check(n, k):\n vasya, curr = 0, n\n while curr > 0:\n # vasya takes first k or whatever left\n vasya_take = min(n, k)\n vasya += vasya_take\n curr -= vasya_take\n # petya takes 10% if more than 10 left\n if curr >= 10:\n curr -= int(curr * 0.1)\n\n return vasya * 2 >= n\n\n\n\ndef find_min_k(n):\n start, end, min_k = 0, n, n\n\n while abs(start - end) > 1:\n middle = (start + end) // 2\n\n if check(n, middle):\n min_k = min(min_k, middle)\n end = middle\n else:\n start = middle\n\n return min_k\n\nprint(find_min_k(int(input())))\n"}, {"source_code": "'''input\n43\n'''\ndef check(m, k):\n\tn = m\n\tgot = 0\n\twhile n:\n\t\tif n >= k:\n\t\t\tn -= k\n\t\t\tgot += k\n\t\telse:\n\t\t\tgot += n\n\t\t\tn = 0\n\t\tn -= n // 10\n\tif got >= m / 2:\n\t\treturn 1\n\treturn 0\nn = int(input())\nif n < 100:\n\tfor i in range(1, 100):\n\t\tif check(n, i):\n\t\t\tprint(i)\n\t\t\tbreak\nelse:\n\tl = 1\n\th = n\n\twhile l <= h:\n\t\tmid = (l + h) // 2\n\t\tz = check(n, mid)\n\t\tif z == 1:\n\t\t\t#can eat 50 %\n\t\t\th = mid - 1\n\t\telse:\n\t\t\t#can not eat 50 %\n\t\t\tl = mid + 1\n\tprint(mid)"}, {"source_code": "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\ndef sim(n, k):\n ans = 0\n while n > 0:\n if n >= k:\n ans += k\n n -= k\n else:\n ans += n\n n = 0\n \n n -= int(math.floor(n*0.1))\n \n return ans\n\ndef slv2(N):\n for k in range(1, N):\n if sim(N, k) > N/2:\n return k\n\n \n\n@mt\ndef slv(N):\n if N < 1000:\n for k in range(1, N):\n if sim(N, k) > N/2:\n return k\n\n sk = int(N*0.03)\n ek = int(N*0.1)\n cnd = {}\n while True:\n if ek - sk <= 1:\n break\n ck = (sk + ek)//2\n v = sim(N, ck)\n cnd[ck] = v\n if v < N/2:\n sk = ck\n else:\n ek = ck\n\n \n\n keys = sorted(cnd.keys())\n for i, k in enumerate(keys):\n if cnd[k] > N/2:\n error_print(keys[i-1], keys[i])\n for j in range(keys[i-1], keys[i]):\n cnd[j] = sim(N, j)\n break\n keys = sorted(cnd.keys())\n for i, k in enumerate(keys):\n if cnd[k] > N/2:\n return k\n\n\ndef main():\n N = read_int()\n # N = int(1e+18)\n # N = random.randint(int(1e+18)-10000, int(1e+18))\n print(slv(N))\n\n # for n in range(1000, 100000):\n # print(n)\n # a = slv(n)\n # b = slv2(n)\n # if a != b:\n # print(n, a, b)\n # break\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\n\ndef ok(k,n):\n\tif k == 0:\n\t\treturn False\n\tvasya = 0\n\tpetya = 0\n\tN = n\n\twhile n:\n\t\tvasya_i = min(n,k)\n\t\tvasya += vasya_i\n\t\tpetya_i = int((N - (vasya + petya))/float(10))\n\t\tpetya += petya_i\n\t\tn -= petya_i + vasya_i\n\treturn vasya >= petya\n\ndef sol(n):\n\tlow = 0\n\thigh = n\n\tans = high\n\twhile low <= high:\n\t\tmid = (low+high)/2\n\t\tif ok(mid,n):\n\t\t\tans = min(ans,mid)\n\t\t\thigh = mid-1\n\t\telse:\n\t\t\tlow = mid+1\n\treturn ans\n\nn = int(sys.stdin.readline().strip())\nprint(sol(n))"}, {"source_code": "\"\"\"\nhttp://codeforces.com/problemset/problem/991/C\nNNNNNNNYYYYYY Problem\n\"\"\"\nimport math\ndef solveBinarySearch(n):\n\n\tlo = 1\n\thi = n\n\t# import pdb; pdb.set_trace()\n\twhile (lo < hi):\n\n\t\tmid = (lo + hi) / 2\n\t\tcandies_eaten = computeNumCandies(mid, n)\n\t\tif (candies_eaten):\n\t\t# if (helper(n, mid)):\n\t\t\thi = mid \n\n\t\telse :\n\t\t\tlo = mid + 1\n\treturn lo\n\ndef helper(n, k):\n a, b = 0, 0\n while n > 0:\n if n >= k:\n a += k\n else:\n a += n\n n -= k\n if n > 9:\n b += n/10\n n -= n/10\n return a >= b\n\n\ndef computeNumCandies(mid, n):\n\tnum_candies = n\n\tcandies_eaten = 0\n\tpet_eaten = 0\n\t# import pdb; pdb.set_trace()\n\twhile (num_candies > 0):\n\t\t# Vasya eats them all\n\t\tif (num_candies < mid):\n\t\t\tcandies_eaten += num_candies\n\t\t\tnum_candies = 0\n\t\t\treturn candies_eaten\n\t\telse: #Vasya takes mid candies\n\t\t\tnum_candies = num_candies - mid\n\t\t\tcandies_eaten += mid\n\n\t\t#Petya rounds down the remaining candy\n\t\t# if (num_candies > 9):\n\t\tpetya_eats = num_candies / 10\n\t\tnum_candies = num_candies - petya_eats\n\t\tpet_eaten = pet_eaten + petya_eats\n\n\treturn candies_eaten >= pet_eaten\n\t\t\nn = int(input())\nprint(solveBinarySearch(n))"}, {"source_code": "def simulate(n, k):\n m = n\n cnt = 0\n while m > 0:\n m -= k\n cnt +=k\n if m >= 0:\n m -= m // 10\n return cnt + m\n\n# def descent(n, k):\n# s = simulate(n, k)\n# while s >= n // 2:\n# k -= 1\n# s = simulate(n, k)\n# return k + 1\n\ndef binsearch(n, l, h):\n if h == l + 1:\n return h\n m = (l + h) // 2\n s = simulate(n, m)\n if s > n // 2:\n return binsearch(n, l, m)\n else:\n return binsearch(n, m, h)\n\ndef start(n):\n return binsearch(n, 0, n)\n\nprint(start(int(input())))"}, {"source_code": "from math import ceil\ndef all(n,k):\n if k == 0:\n return False\n s = 0\n last = n\n while n != 0:\n ss = min(n,k)\n s += ss\n n -= ss\n n -= n//10\n return s >= ceil(last/2)\nn = int(input())\ndef binary_search(n):\n l,r = 0,n\n midd = 0\n while l <= r:\n mid = (l+r+1)//2\n if all(n,mid):\n midd = mid\n r = mid-1\n else:\n l = mid+1\n return midd\nprint(binary_search(n))\n"}, {"source_code": "\"\"\".\"\"\"\n\n\ndef get_win(cakes_nr, step):\n \"\"\".\"\"\"\n win = 0\n while True:\n if cakes_nr <= step:\n win += cakes_nr\n break\n win += step\n cakes_nr -= step\n cakes_nr -= cakes_nr // 10\n return win\n\n\ncakes_nr = int(input())\nl_op = 0\nr_cl = cakes_nr\n\nwhile r_cl - l_op > 1:\n m = (l_op + r_cl) // 2\n win = get_win(cakes_nr, m)\n if win >= cakes_nr / 2:\n r_cl = m\n else:\n l_op = m\n\ncurr_best = r_cl\nfor i in range(-50_000, 50_001):\n if r_cl - i <= 0 or r_cl - i > cakes_nr:\n continue\n win = get_win(cakes_nr, r_cl - i)\n if win >= cakes_nr / 2:\n curr_best = r_cl - i\n\nprint(curr_best)\n"}, {"source_code": "import sys\nimport bisect\n# import heapq\nfrom math import ceil,floor\n\n\ndef check(k,n):\n fr = 0\n temp= n\n while ( n > 0):\n if n < k :\n fr = fr+n\n n = 0\n else:\n fr = fr + k\n n = n-k\n n -= (n//10)\n return fr*2>= temp\n\nRI = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\nmod = 10**9+7\n# for _ in range(int(ri())):\n\nn = int(ri())\nl = 1\nr = n\nans = 10**10\nwhile ( l <= r):\n mid = (l+r)//2\n if check(mid,n):\n r = mid-1\n ans = min(ans,mid)\n else:\n l = mid+1\nprint(ans)"}, {"source_code": "n = int(input())\nl, r = 0, 2 * 10 ** 18\n\n\ndef enough(n, k):\n was = n\n eaten = 0\n while n > 0:\n eaten += min(n, k)\n n -= k\n if n > 0:\n n -= n // 10\n return eaten >= was / 2\n\n\nwhile l + 1 < r:\n m = (l + r) // 2\n if not enough(n, m):\n l = m\n else:\n r = m\nprint(r)\n"}, {"source_code": "\nn=input()\ndef answer(n,k):\n vr=0\n while n>9 and k<n:\n if 1==1:\n n=n-k\n vr=vr+k\n \n if n>9:\n n=n-n/10 \n \n if n>0:\n vr=vr+n \n return vr\nlow=1\nhigh=10**18\ni=0\nc=0\nmid=(low+high)/2\nfor i in range(1,300):\n if answer(n,mid)<int(round(n*1.0/2)):\n low=mid\n mid=(low+high)/2\n elif answer(n,mid)>int(round(n*1.0/2)):\n high=mid \n mid=(low+high)/2\n \nif answer(n,low)>=int(round(n*1.0/2)):\n print low\nelif answer(n,mid)>=int(round(n*1.0/2)):\n print mid\nelse:\n print high\n\n "}, {"source_code": "def check(n,k):\n v = 0 \n p = 0\n num = n \n while n>0:\n v+=min(n,k)\n n-=min(n,k)\n if n>=10:\n p+=(n//10)\n n-=(n//10)\n return v*2 >= num \nn = int(input())\n\nlow,high = 1,n \n\nwhile low<=high:\n mid = (low+high+1)//2 \n if check(n,mid):\n high = mid - 1 \n else:\n low = mid + 1 \nprint(mid)\n"}, {"source_code": "def check(n,k):\n if k==0:\n return 0\n v = 0 \n p = 0\n num = n \n while n>0:\n v+=min(n,k)\n n-=min(n,k)\n if n>=10:\n p+=(n//10)\n n-=(n//10)\n return v*2 >= num \nn = int(input())\n\n\n\n\n\nlow,high = 1,n \n\n\n\nwhile low<=high:\n mid = (low+high)//2 \n if check(n,mid) and check(n,mid+1):\n high = mid - 1 \n elif check(n,mid) and not check(n,mid-1):\n break\n elif not check(n,mid) and not check(n,mid-1):\n low = mid + 1 \nprint(mid)\n"}, {"source_code": "import math\nn = int(input())\ndef f(x):\n global n\n v = p = 0\n last = n\n while last > 0:\n if last >= x:\n last -= x\n v += x\n else:\n last = 0\n v += last\n p += math.floor(last * 0.1)\n last = math.ceil(last * 0.9)\n if v >= p:\n return True\n else:\n return False\n\nleft = 1\nright = n\nwhile right - left > 1:\n middle = (right + left) // 2\n if f(middle) == False:\n left = middle\n else:\n right = middle\nprint(right)\n"}, {"source_code": "from math import ceil, sqrt\nn = int(input())\nif n < 20:\n print(1)\nelse:\n l = 1\n r = n//2\n s = 0\n t = n\n while l < r:\n s = 0\n mid = (r+l)//2\n while t > 0:\n if mid > t:\n s += t\n t = 0\n break\n else:\n s += mid\n t = (t - mid) - ((t-mid)//10)\n if s < ceil(n/2):\n l = mid+1\n t = n\n elif s > ceil(n/2):\n r = mid\n t = n\n elif s == ceil(n/2):\n l = mid\n break\n print(l)\n"}, {"source_code": "def ans(n, k):\n sm = 0\n while n - k - (n - k) // 10 > 0:\n n = n - k - (n - k) // 10\n sm += k\n sm += n\n return sm\n\n\ndef binarySearch(arr, x):\n l = 0\n r = len(arr) - 1\n while l <= r:\n\n mid = (l + r) // 2\n\n if arr[mid] == x:\n return mid + 1\n elif arr[mid] < x:\n l = mid + 1\n else:\n r = mid - 1\n return l\n\n\nn = int(input())\n\nl = 1\ns = 0\nr = n\nwhile l <= r:\n mid = (l + r) // 2\n t = ans(n,mid)\n if t == n//2:\n s = mid\n break\n elif t < n//2:\n l = mid + 1\n else:\n r = mid - 1\n s = mid\nprint(s)"}, {"source_code": "# Codeforces Round #491 (Div. 2)\nimport collections\nfrom functools import cmp_to_key\n#key=cmp_to_key(lambda x,y: 1 if x not in y else -1 )\nimport math\nimport sys\ndef getIntList():\n return list(map(int, input().split())) \n\nimport bisect \ntry :\n import numpy\n dprint = print\n dprint('debug mode')\nexcept ModuleNotFoundError:\n def dprint(*args, **kwargs):\n pass\ndef makePair(z):\n return [(z[i], z[i+1]) for i in range(0,len(z),2) ]\n\n\n \nn, = getIntList()\n\n\ndef work(k,n):\n a = 0\n b = 0\n while(n>0):\n a += min(n,k)\n if n<=k:\n break\n n-=k\n t = int(n/10)\n b +=t\n n-=t\n if a>=b:\n return True\n return False\n\n\nr0 = 0\nr1 = n\n\nwhile r0+1<r1 :\n m = (r0+r1)//2\n if work(m,n):\n r1 = m\n else :\n r0 = m\n\nprint(r1)\n\n \n\n \n"}, {"source_code": "def p(n,k) :\n k1=0\n k2=0\n while (n>0):\n k1+=min(n,k)\n n-=min(n,k)\n k2+=n//10\n n-=n//10\n if k1>k2 :\n return True\n else :\n return False\n \n\nn=int(input())\np1=1\nost=n\nwhile (p1<=ost) :\n mid=(p1+ost)//2\n if p(n,mid):\n ost=mid-1\n else :\n p1=mid+1\nprint(p1)\n\n"}, {"source_code": "from sys import stdin\ninput=lambda : stdin.readline().strip()\nfrom math import ceil,sqrt,factorial,gcd\nfrom collections import deque\ndef check(n,k):\n\ta=0\n\tb=0\n\twhile n>0:\n\t\tif k<=n:\n\t\t\ta+=k\n\t\t\tn-=k\n\t\telse:\n\t\t\ta+=n\n\t\t\tn=0\n\t\tif n>=10:\n\t\t\tb+=n//10\n\t\t\tn-=n//10\n\tif a>b:\n\t\treturn True\n\treturn False\n\n\nn=int(input())\nl=1\nr=n\nwhile l<r:\n\tmid=(l+r)//2\n\t# print(mid,l,r)\n\tif check(n,mid):\n\t\tr=mid-1\n\telse:\n\t\tl=mid+1\nprint(l)"}], "src_uid": "db1a50da538fa82038f8db6104d2ab93"} {"source_code": "import math\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n ans = int(10e9)\n d = {}\n for x in a:\n step = 0\n while True:\n if x not in d:\n d[x] = []\n d[x].append(step)\n if x == 0:\n break\n step += 1\n x //= 2\n for key in d:\n b = d[key]\n b.sort()\n if len(b) >= k:\n ans = min(ans, sum(b[:k]))\n print(ans)\n\n\nmain()", "positive_code": [{"source_code": "n, k = map(int, input().split())\nl = list(map(int, input().split()))\nb = [[] for i in range(2*10**5+1)]\nfor a in l:\n\tcnt = 0\n\twhile (a > 0):\n\t\tb[a].append(cnt)\n\t\tcnt += 1\n\t\ta = a // 2\nans = 1000000000\nfor x in b:\n\tif len(x) >= k:\n\t\tx = sorted(x)\n\t\tans = min(ans, sum(x[:k]))\nprint(ans)\n"}, {"source_code": "'''input\n5 3\n1 2 3 3 3\n'''\nfrom collections import defaultdict as dd\n\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\n\nd = dd(list)\nfor x in a:\n\ti = 0\n\twhile(x):\n\t\td[x].append(i)\n\t\tx //= 2\n\t\ti += 1\nans = 999999999999\nfor i in d:\n\tif len(d[i]) >= k:\n\t\td[i].sort()\n\t\tans = min(ans, sum(d[i][0:k]))\nprint(ans)"}, {"source_code": "import math \n\nn,k=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\n\nsteps = [0]*200005 \ncount = [0]*200005 \nans = []\n# \n#for i in range(n):\n# count[a[i]]+=1 \n\nfor i in range(n):\n x=a[i]\n# if count[x] == k :ans.append(steps[x])\n# print(math.floor(math.log2(a[i])+2))\n for j in range(math.floor(math.log2(a[i])+2)):\n if count[x] == k :\n ans.append(steps[x])\n\n \n \n count[x]+=1\n steps[x]+=j\n x=x//2\nfor i in range(200005):\n if count[i]==k:\n ans.append(steps[i])\n \n\nprint(min(ans))\n \n \n \n \n "}, {"source_code": "n, k =map(int, input().split())\na=list(map(int, input().split()))\nr=max(a)+1\nvalues = [[] for i in range (r)]\nfor i in a:\n cur=0\n values[i].append(0)\n while i!=0:\n i//=2\n cur+=1\n values[i].append(cur)\nans=float(\"inf\")\nfor i in values:\n if len(i)<k:\n continue\n else:\n i.sort()\n ans=min(ans, sum(i[:k]))\nprint(ans)\n\n"}, {"source_code": "def div(x, a):\n left = -1\n right = 64\n while right - left > 1:\n mid = (right + left) // 2\n if x // pow(2, mid) <= a:\n right = mid\n else:\n left = mid\n return right\n\n\nn, k = map(int, input().split())\nx = [int(x) for x in input().split()]\nx.sort()\nanswer = pow(10, 100)\nfor i in range(len(x)):\n t = x[i]\n divs = 0\n isDivisible = True\n while isDivisible:\n cnt = 1\n temp = divs\n for j in range(len(x)):\n #print(x[i], ' to ', t,' and ', x[j], ' got ', temp, ' count ', cnt)\n if i == j or x[j] < t or cnt == k:\n continue\n a = div(x[j], t)\n if x[j] // pow(2, a) == t:\n cnt += 1\n temp += a\n if cnt == k:\n answer = min(temp, answer)\n if t == 0:\n isDivisible = False\n t //= 2\n divs += 1\nprint(answer)"}, {"source_code": "def I():\n return int(input())\ndef IS():\n return input()\ndef IL():\n return list(map(int,input().split()))\ndef IM():\n return map(int,input().split())\nn,k=IM() \nl=IL() \nfrom collections import Counter\nc=Counter(l)\nif max(c.values())>=k:\n print(0)\n exit() \nl.sort() \nfrom collections import defaultdict \nd=defaultdict(list)\nfor i in range(n):\n curr=l[i]\n while curr:\n d[(l[i],i)].append(curr)\n curr//=2 \n d[(l[i],i)].append(0)\nmini=10**9 \ndef check(i):\n to_make=i \n tot=[] \n for j in range(n):\n if i not in d[(l[j],j)]:\n pass \n else:\n tot.append(d[(l[j],j)].index(i))\n if len(tot)<k:\n return 10**9\n else:\n tot.sort()\n return sum(tot[:k])\nd1=defaultdict(int)\nfor i in d:\n a=d[i]\n for a1 in a:\n d1[a1]+=1 \ncand=[i for i in d1 if d1[i]>=k]\n#print(cand)\nfor i in l:\n mini=min(mini,check(i))\nfor i in range(1000):\n mini=min(mini,check(i))\nfor i in cand:\n mini=min(mini,check(i))\nprint(mini)\n"}, {"source_code": "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nl.sort()\nd = dict()\nc = 0\nf = 0\na = [0 for i in range(200001)]\nmin1 = -1\nwhile(l[-1] != 0):\n\tfor i in range(f,len(l)):\n\t\tif l[i] in d:\n\t\t\td[l[i]] += 1\n\t\telse:\n\t\t\td[l[i]] = 1\n\t\ta[l[i]] += c\n\t\tif(d[l[i]] >= k):\n\t\t\t#print(min1,l[i],d[l[i]],a[l[i]])\n\t\t\tif(min1 == -1):\n\t\t\t\tmin1 = a[l[i]]\n\t\t\telse:\n\t\t\t\tmin1 = min(min1,a[l[i]])\n\t\tif(l[i] == 0):\n\t\t\tf = i+1\n\t\tl[i] = l[i]//2\n\t#print(l)\n\tc += 1\nprint(min1)"}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nb = [[] for i in range(2*10**5 + 1)]\n\nfor i in a:\n cnt = 0\n while i > 0:\n b[i].append(cnt)\n cnt += 1\n i //= 2\nans = int(1e9)\nfor a in b:\n if len(a) >= k:\n ans = min(ans, sum(sorted(a)[:k]))\nprint(ans)\n"}, {"source_code": "n,k=map(int,input().split())\nar=list(map(int,input().split()))\ndic={}\nfor i in range(n):\n if(not(ar[i] in dic)):\n dic[ar[i]]=[0]\n else:\n dic[ar[i]].append(0)\n count=0\n while(ar[i]):\n ar[i]//=2\n count+=1\n if(not(ar[i] in dic)):\n dic[ar[i]]=[count]\n else:\n dic[ar[i]].append(count)\nans=float('inf')\nfor i in dic:\n if(len(dic[i])>=k):\n dic[i].sort()\n ans=min(ans,sum(dic[i][:k]))\nprint(ans)"}, {"source_code": "import math as mt\nimport sys,string\ninput=sys.stdin.readline\nfrom collections import defaultdict\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda : int(input())\n\n\nn,k=M()\nl=L()\nx=set()\nfor i in l:\n r=i\n while(r):\n x.add(r)\n r=r//2\n x.add(r)\nans1=10**10\n\nfor i in x:\n\n h=[]\n for j in range(len(l)):\n ans=0\n d=l[j]\n if(d>=i):\n while(d>i):\n\n d//=2\n ans+=1\n if(d==i):\n h.append(ans)\n\n if(len(h)>=k):\n h.sort()\n ans1=min(ans1,sum(h[:k]))\nprint(ans1)\n \n"}, {"source_code": "import sys\nn,k=map(int,raw_input().split())\nl=list(map(int,raw_input().split()))\nl.sort()\n\nd={}\nfor i in xrange(0,2*(10**5)+1):\n key=i\n d[key]=[0,[]]\n\nfor i in xrange(len(l)):\n key=l[i]\n if key not in d:\n d[key]=[1,[]]\n\nfor i in d:\n if d[i][0]>=k:\n print 0\n sys.exit()\n\nfor i in xrange(len(l)):\n x=l[i]\n c=0\n d[x][0]+=1\n d[x][1].append(c)\n while x!=0:\n x/=2\n c+=1\n d[x][0]+=1\n d[x][1].append(c)\n \n\nans=10**9\nfor i in d:\n if len(d[i][1])>=k:\n s=sum(d[i][1][:k])\n ans=min(ans,s)\nprint ans"}, {"source_code": "R=lambda:map(int,input().split())\nn,k=R()\nd={}\nfor x in R():\n i=0\n while x:l=d.setdefault(x,[1e9]);l+=i,;x>>=1;i+=1\nprint(min(sum(sorted(d[x])[:k])for x in d))"}, {"source_code": "R=lambda:map(int,input().split())\nn,k=R()\nd={}\nfor x in R():\n i=0\n while x:l=d.setdefault(x,[]);l+=i,;x>>=1;i+=1\nprint(min(sum(sorted(d[x])[:k])for x in d if len(d[x])>=k))"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\ndef main():\n n, k = list(map(int, input().split()))\n a = sorted(list(map(int, input().split())))\n maxVal = a[-1]\n\n cnt = [0 for i in range(maxVal + 1)]\n required = [0 for i in range(maxVal + 1)]\n ret = 10**9\n\n for i in range(n):\n curr = a[i]\n operation = 0\n while (curr > 0):\n cnt[curr] += 1\n required[curr] += operation\n if (cnt[curr] >= k): ret = min(ret, required[curr])\n curr //= 2\n operation += 1\n cnt[curr] += 1\n required[curr] += operation\n if (cnt[curr] >= k): ret = min(ret, required[curr])\n\n sys.stdout.write(str(ret) + '\\n')\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import sys\nfrom collections import Counter\n\n\ndef solve():\n n, k = list(map(int, sys.stdin.readline().split()))\n a = sorted(list(map(int, sys.stdin.readline().split())))\n cnt = Counter(a)\n opr = cnt.copy()\n opr.clear()\n result = 10**7\n\n for val in a:\n cur_opr = 0\n while (val > 0):\n if (cnt[val] >= k):\n result = min(result, opr[val])\n val //= 2\n cur_opr += 1\n opr[val] += cur_opr\n cnt[val] += 1\n\n print(result)\n\n\nsolve()\n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\nd1={};d2={}\nans=10**9\nfor i in range(n):\n num=a[i];c=0\n while num>0:\n d1[num]=c if num not in d1 else d1[num]+c \n d2[num]=1 if num not in d2 else d2[num]+1\n if d2[num]==k:\n ans=min(ans,d1[num])\n c+=1\n num//=2\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\n\n\ndef solve(arr, k):\n\n c = defaultdict(list)\n\n for i in arr:\n j = 0\n while i:\n c[i].append(j)\n i //= 2\n j += 1\n c[i].append(j)\n\n c = {key: sorted(v) for key, v in c.items() if len(v) >= k}\n # print(c, k)\n return min(sum(v[i] for i in range(k)) for v in c.values())\n\n#\n_, k = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\n\nprint(solve(arr, k))"}, {"source_code": "n, k = map(int, input().split())\na = [int(i) for i in input().split()]\na.sort()\ndata = {}\nfor x in a:\n cur = x\n iterations = 0\n while (cur > 0):\n if data.get(cur) is not None:\n data[cur].append(iterations)\n else:\n data[cur] = [iterations]\n cur = cur // 2\n iterations += 1\n if data.get(0) is not None:\n data[0].append(iterations)\n else:\n data[0] = [iterations]\nans = 100000000000\nfor key, iters in data.items():\n if (len(iters) >= k):\n s = 0\n for i in range(k):\n s += iters[i]\n ans = min(ans, s)\nprint(ans)\n"}, {"source_code": "def fuck(num,i):\n fuck = 0\n while num >= i:\n if num == i:\n return fuck\n num //= 2\n fuck += 1\n return False\n\n\nlenK = list(map(int,input().split()))\nlens = lenK[0]\nK = lenK[1]\nnums = list(map(int,input().split()))\n\nnums.sort()\nlists = [[nums[0],1]]\nup = nums[0]\nfor i in nums[1:]:\n if i == up:\n lists[-1][1] += 1\n else:\n up = i\n lists.append([i,1])\nmis = -1\n# print(lists)\nfor i in range(len(lists)):\n thisN = lists[i][0]\n thisP = 0\n tk = K - lists[i][1]\n if tk <= 0:\n mis = 0\n break\n ji = 0\n while True:\n for j in range(i + 1,len(lists)):\n dong = fuck(lists[j][0],thisN)\n if dong != False:\n thisP += min(tk,lists[j][1])*dong\n tk -= min(tk,lists[j][1])\n # if dong != False:\n # print(str(lists[j][0])+\"\u9664\u4ee5\"+str(dong)+\"\u6b21=\"+str(thisN),lists[i][0],thisP)\n if tk == 0:\n\n # print(mis, thisP, thisN, i,j, lists[j])\n if mis == -1 or mis > thisP:\n mis = thisP\n # print(\"fuck\")\n break\n if thisN == 0:\n break\n thisN //= 2\n ji += 1\n thisP = ji*lists[i][1]\n # print(thisP)\n tk = K - lists[i][1]\n\nprint(int(mis))"}, {"source_code": "import math\nn,k=map(int,input().split())\nl=[int(i) for i in input().split()]\nl.sort()\nmoves=[0]*(200001)\nfreq=[0]*(200001)\nans=1e9\nfor i in l:\n freq[i]+=1\nfor i in range(len(l)):\n count=0\n a=l[i]\n while a>1:\n a=a//2\n count+=1\n if freq[a]<k:\n freq[a]+=1\n moves[a]+=(count)\n #print(moves,freq,count,a)\nfor i in range(len(freq)):\n if freq[i]>=k:\n ans=min(ans,moves[i])\nprint(ans)\n \n\n"}, {"source_code": "import io, os\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nimport sys\nn,k=list(map(int,input().split()))\narr=list(map(int,input().split()))\narr.sort()\na=arr[-1]\ncount=[0]*(a)\nfor i in range(n):\n count[arr[i]-1]+=1\nif max(count)>=k:\n print(0)\nelse:\n matrix=[[] for i in range(n)]\n steps=[[] for i in range(a)]\n for i in range(n):\n temp=arr[i]\n s=0\n while temp>0:\n matrix[i].append(temp)\n steps[temp-1].append(s)\n if temp!=arr[i]:\n count[temp-1]+=1\n temp=temp//2\n s+=1\n lis=[]\n l=0\n for i in range(a):\n if count[i]>=k:\n lis.append(i)\n l+=1\n ans=sys.maxsize\n for i in range(l):\n steps[lis[i]].sort()\n ans=min(ans,sum(steps[lis[i]][:k]))\n print(ans)\n "}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nout=10000000000\nd={}\nfor i in l:\n c=0\n while i:\n if i not in d:\n d[i]=[]\n d[i].append(c)\n c+=1\n i//=2\n#print(d)\nfor i in d:\n if len(d[i])>=k:\n t=sorted(d[i])\n out=min(out,sum(t[:k]))\nprint(out)"}, {"source_code": "import sys\nfrom collections import defaultdict\n\ndef main():\n n, k = [int(x) for x in sys.stdin.readline().split(\" \")]\n arr = [int(x) for x in sys.stdin.readline().split(\" \")]\n # vals[x][a] holds number of iterations to get from x to a\n arr.sort()\n vals = defaultdict(list)\n for i, a in enumerate(arr):\n count = 0\n while (a > 0):\n vals[a].append(count)\n a = a // 2\n count += 1\n minCount = 99999999999999\n for x,v in vals.items():\n if len(v) < k:\n continue\n else:\n a = sorted(v)\n minCount = min(minCount, sum(a[:k]))\n return minCount\n\nprint(main())\n"}, {"source_code": "from sys import stdin\nfrom collections import *\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return [str(x) for x in stdin.readline().split()]\n\n\ndef divide(x):\n num = 0\n mem[x][0] += 1\n\n while (x):\n x //= 2\n num += 1\n\n if mem[x][0] < k:\n mem[x][0] += 1\n mem[x][1] += num\n\n\nn, k = arr_inp(1)\na, mem = sorted(arr_inp(1)), defaultdict(lambda: [0, 0])\nc, ans = Counter(a), float('inf')\n\nfor i in range(n):\n divide(a[i])\n\nfor i in range(max(a) + 1):\n if mem[i][0] >= k:\n ans = min(ans, mem[i][1])\n\nprint(ans)\n"}, {"source_code": "n,k = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\ncnt = {}\nstp = {}\nans = 200005\nfor i in a:\n x=i\n y=0\n while 1:\n cnt[x] =cnt.get(x,0)+1\n stp[x] =stp.get(x,0)+y\n if cnt[x]==k:\n ans=min(ans,stp[x])\n if x==0:\n break\n y +=1\n x =x//2\nprint(ans)\n \n \n"}, {"source_code": "from sys import stdin\n\ninp = stdin.readline\n\nn, k= [int(x) for x in inp().strip().split()]\n\na = [int(x) for x in inp().strip().split()]\n\na.sort()\n\nd = {}\n\nans = -1\nfor i in a:\n j = 0\n while i != 0:\n if d.get(i,0) == 0:\n d[i] = [1, j]\n else:\n if d[i][0] < k:\n d[i][0] += 1\n d[i][1] += j\n if d[i][0] == k:\n if ans == -1:\n ans = d[i][1]\n break\n else:\n ans = min(ans, d[i][1])\n break\n i //= 2\n j += 1\nprint(ans)"}, {"source_code": "import math\n\n\nn, k = map(int, input().split())\nnumbers = list(map(int, input().split()))\ndivisors = {}\nfor v in numbers:\n cnt = 0\n if not v in divisors.keys():\n divisors[v] = []\n while v > 0:\n if not v in divisors.keys():\n divisors[v] = []\n divisors[v].append(cnt)\n v //= 2\n cnt += 1\n if not v in divisors.keys():\n divisors[v] = []\n divisors[v].append(cnt)\nanswer = 2 ** 64\nfor cnt in filter(None, divisors.values()):\n cnt.sort()\n if len(cnt) >= k and len(cnt) > 0:\n answer = min(answer, sum(cnt[:k]))\nprint(answer)\n"}, {"source_code": "def int_multiple():\n return [int(c) for c in input().split()]\n\ndef int_single():\n return int(input())\n\ndef str_multiple():\n return [c for c in input().split()]\n\ndef str_single():\n return input()\n\n# start\n\nn, k = int_multiple()\nl = int_multiple()\n\nl = sorted(l)\n\n\ncosts = []\nfor i in range(200001):\n costs.append([])\n\nfor i in range(n):\n tmp = l[i]\n cnt = 0\n while (tmp != 0):\n costs[tmp].append(cnt)\n tmp = int(tmp/2)\n cnt += 1\n\nfor val in costs[1]:\n costs[0].append(val+1)\n\n\nmin_cost = 9999999999999\nfor c in costs:\n if len(c) >= k:\n cost = sum(c[:k])\n if (cost < min_cost):\n min_cost = cost\n\n#for cc in costs:\n# print(cc)\n\nprint(min_cost)\n"}, {"source_code": "n, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nvals = [[] for i in range(200 * 1000 + 11)]\nfor i in a:\n cur = 0\n x = i\n while x > 0:\n vals[x].append(cur)\n cur += 1\n x //= 2\nanswer = 1000000000\nfor i in range(200 * 1000):\n vals[i].sort()\n if len(vals[i]) < k:\n continue\n answer = min(answer, sum(vals[i][:k]))\nprint(answer)\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\ncnt = [[] for i in range(2*10**5 + 10)]\n\nfor num in a:\n tmp_cnt = 0\n while True:\n if num == 0:\n cnt[num].append(tmp_cnt)\n break\n else:\n cnt[num].append(tmp_cnt)\n num = num // 2\n tmp_cnt += 1\n\nans = 10**9 + 7\nfor cnt_i in cnt:\n if len(cnt_i) < k:\n continue\n else:\n cnt_i = sorted(cnt_i)\n ans = min(ans, sum(cnt_i[0:k]))\nprint(ans)"}, {"source_code": "def main():\n m, n = [int(v) for v in input().split()]\n vals = [int(v) for v in input().split()]\n data = []\n for v in vals:\n res = {}\n d = v\n count = 0\n while d != 0:\n res[d] = count\n count += 1\n d = d // 2\n res[d] = count\n data.append(res)\n all_vals = set()\n for d in data:\n all_vals.update(set(d.keys()))\n results = {}\n for k in all_vals:\n sorted_res = sorted([d[k] for d in data if k in d])\n if len(sorted_res)>=n:\n results[k] = sum(sorted_res[0:n])\n print(min(results.values()))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import decimal,math\nfrom collections import *\nfrom fractions import gcd\nfrom bisect import bisect_right,bisect_left\nimport sys\n\ndecimal.getcontext().prec = 15\n\ndef primeFactors(n): \n\tarr=[]\n\twhile n % 2 == 0: \n\t\tarr.append(2) \n\t\tn = n / 2\n\tfor i in xrange(3,int(math.sqrt(n))+1,2): \n\t\twhile n % i== 0: \n\t\t\tarr.append(i) \n\t\t\tn = n / i \n\tif n > 2: \n\t\tarr.append(n)\n\t\t# print n\n\treturn arr\t \ndef z_advanced(s):\n\tZ = [0] * len(s)\n\tZ[0] = len(s) \n\trt = 0\n\tlt = 0\n\tfor k in xrange(1, len(s)):\n\t\tif k > rt:\n\t\t\tn = 0\n\t\t\twhile n + k < len(s) and s[n] == s[n+k]:\n\t\t\t\tn += 1\n\t\t\tZ[k] = n\n\t\t\tif n > 0:\n\t\t\t\tlt = k\n\t\t\t\trt = k+n-1\n\t\telse:\n\t\t\tp = k - lt # Pair index.\n\t\t\tright_part_len = rt - k + 1 \n\t\t\tif Z[p] < right_part_len:\n\t\t\t\tZ[k] = Z[p]\n\t\t\telse:\n\t\t\t\ti = rt + 1\n\t\t\t\twhile i < len(s) and s[i] == s[i - k]:\n\t\t\t\t\ti += 1\n\t\t\t\tZ[k] = i - k\n \n\t\t\t\tlt = k\n\t\t\t\trt = i - 1\n\treturn max(Z)\ndef invmod(i,mod):\n\treturn pow(i,mod-2,mod)\t\ndef fact(mod):\n\tfac= [1,1]\n\tifac = [1,1]\n\tfor i in xxrange(2,(3*10**5+ 2)):\n\t\tfac.append((fac[-1]*i)%mod)\n\t\t# ifac.append((ifac[-1]*invmod(i,mod))%mod)\n\treturn fac,ifac\t\ndef SieveOfEratosthenes(n): \n\tprime = [True for i in xrange(n+1)] \n\tp = 2\n\twhile (p * p <= n): \n\t\tif (prime[p] == True): \n\t\t\t\n\t\t\tfor i in xrange(p * p, n+1, p): \n\t\t\t\tprime[i] = False\n\t\tp += 1\n\tarr=[]\n\tfor p in xrange(2, n): \n\t\tif prime[p]: \n\t\t\tarr.append(p)\n\treturn arr\ndef maxSubArraySum(a):\n\tsize=len(a) \n\tmax_so_far =a[0] \n\tcurr_max = a[0] \n\tfor i in xrange(1,size): \n\t\tcurr_max = max(a[i], curr_max + a[i]) \n\t\tmax_so_far = max(max_so_far,curr_max) \n\treturn max_so_far \t\ndef fi():\n\treturn int(sys.stdin.readline())\n \ndef fi2():\n\treturn map(int, sys.stdin.readline().split())\n \ndef fi3():\n\treturn sys.stdin.readline()\n \ndef fo(*args):\n\tfor s in args:\n\t\tsys.stdout.write(str(s)+' ')\n\tsys.stdout.write('\\n')\n# t = int(raw_input())\n# dp=[0]*(2*10**5+6)\ndic = defaultdict(list)\t\n# print dp\t\n\nn,k=fi2()\narr=fi2()\narr.sort()\nfor i in arr:\n\tj=i\n\tdic[j].append(0)\n\tcount=0\n\twhile(j!=0):\n\t\tj=j/2\n\t\tcount=count+1\n\t\tif(len(dic[j])!=0):\n\t\t\tdic[j].append(count+dic[j][-1])\n\t\telse:\n\t\t\tdic[j].append(count)\t\nmi = 10**20\nfor i in dic:\n\tif(len(dic[i])>=k):\n\t\tmi = min(mi,dic[i][k-1])\t\n# print dic\nprint mi\t\n"}, {"source_code": "input = raw_input\nn, k = map(int, input().split())\n\na_list = sorted(map(int, input().split()))\n\nnums = [0 for i in range(1 + 2* (10**5))]\ncounts = [0 for i in range(1 + 2* (10**5))]\n\nfor a in a_list:\n count = 0\n nums[a] += 1\n while a != 0:\n a = a // 2\n count += 1\n if nums[a] < k:\n nums[a] += 1\n counts[a] += count\n elif nums[a] == k:\n break\n\n#print(nums[:10])\n#print(counts[:10])\n\ncounts2 = [counts[i] for i, num in enumerate(nums) if num >= k]\nout = min(counts2)\nprint(out)"}, {"source_code": "n, k = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\nb = []\nfor i in range(n):\n b.append([a[i],0])\n a[i]//=2\n j=1\n while(a[i]>0):\n b.append([a[i],j])\n a[i]//=2\n j+=1\n b.append([a[i],j])\nb = sorted(b, key = lambda x:(x[0],x[1]))\nminop = 0\nsu = 0\nfor i in range(k):\n su += b[i][1]\nminop = float('inf')\nif(b[0][0]==b[k-1][0]):\n minop = su\nfor i in range(1,len(b)-k+1):\n if(b[i][0]!=b[i+k-1][0]):\n su += b[i+k-1][1]\n su -= b[i-1][1]\n continue\n su += b[i+k-1][1]\n su -= b[i-1][1]\n if(su<minop):\n minop = su\nprint(minop)"}, {"source_code": "n, k = map(int, input().split())\nl = list(map(int, input().split()))\nb = [[] for i in range(2*10**5+1)]\nfor a in l:\n\tcnt = 0\n\twhile (a > 0):\n\t\tb[a].append(cnt)\n\t\tcnt += 1\n\t\ta = a // 2\nans = 1000000000\nfor x in b:\n\tif len(x) >= k:\n\t\tx = sorted(x)\n\t\tans = min(ans, sum(x[:k]))\nprint(ans)\n"}, {"source_code": "n,m=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\n \nc=list(set(a))\n \nb=[[] for i in range(200005)]\n \nfor i in a:\n temp=i;j=0\n b[temp].append(0)\n \n if temp!=1:\n while(1):\n temp=temp//2\n j+=1\n b[temp].append(j)\n if temp==1:\n break\n \nres=200005 \nfor i in range(1,max(a)+1):\n if len(b[i])>=m:\n temp=sum(b[i][:m])\n res=min(res,temp)\nprint(res)"}, {"source_code": "from sys import stdin\n###############################################################\ndef iinput(): return int(stdin.readline())\ndef minput(): return map(int, stdin.readline().split())\ndef linput(): return list(map(int, stdin.readline().split()))\n###############################################################\n\nn, k = minput()\na = linput()\na.sort()\nmn = float('inf')\np = []\nfor i in range(n):\n temp = a[i]\n while temp:\n p.append(temp)\n temp//=2\n\np = list(set(p))\nfor i in range(len(p)):\n c = p[i]\n op = []\n for j in range(n):\n cnt = 0\n temp = a[j]\n while temp > c:\n temp //= 2\n cnt += 1\n if temp == c:\n op.append(cnt)\n if len(op)>=k:\n op.sort()\n mn = min(mn, sum(op[:k]))\n\n\nc = 0\nfor i in range(k):\n while a[i]:\n a[i]//=2\n c+=1\nmn = min(mn, c)\nprint(mn)"}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 31.08.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \nfrom collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\ndef main():\n\n \n\n\n\n\n #for _ in range(ii()):\n\n \n\n n,k=mi()\n a=li()\n\n\n\n l=defaultdict(list)\n\n\n for i in range(n):\n\n x=a[i]\n cnt=0\n while(x>0):\n\n l[x].append(cnt)\n x//=2\n cnt+=1\n\n\n ans=1000000000\n #print(l)\n for i in range(200005):\n\n\n if len(l[i])<k:\n continue\n l[i].sort()\n\n ans=min(ans,sum(l[i][:k]))\n\n\n print(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "n,k = map(int, raw_input().split())\naas = map(int, raw_input().split())\n\nfrom collections import defaultdict\n\n# reachable[a] = number of a[i]s that can reach the value a\n# costs[a,cost] = number of a[i]s that can reach the value a with a given cost\ncosts = defaultdict(int)\nreachable = defaultdict(int)\nfor a in aas:\n\tcost = 0\n\twhile a >= 0:\n\t\tcosts[a,cost] += 1\n\t\treachable[a] += 1\n\t\tcost += 1\n\t\tif a == 0:\n\t\t\tbreak\n\t\ta /= 2\n\n#print costs\n#print reachable\n\nleast_so_far = 100000000000000000000000000\nfor a in reachable:\n\tif reachable[a] >= k:\n\t\tleast_cost_to_a = 0\n\t\ttotal_reached = 0\n\t\tfor i in xrange(30):\n\t\t\tif 2**(i-2)>2*10**5:\n\t\t\t\tbreak\n\t\t\tif total_reached + costs[a,i] >= k:\n\t\t\t\tremaining = k - total_reached\n\t\t\t\tleast_cost_to_a += remaining*i\n\t\t\t\tleast_so_far = min(least_so_far, least_cost_to_a)\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\ttotal_reached += costs[a,i]\n\t\t\t\tleast_cost_to_a += i*costs[a,i]\n\n\nprint least_so_far"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndic = {}\nfor a in A:\n count = 0\n while a:\n if a in dic:\n dic[a].append(count)\n else:\n dic[a] = [count]\n count += 1\n a //= 2\n\nans = 10**14\nfor k, L in dic.items():\n if len(L) < K:\n continue\n L.sort()\n p = sum(L[:K])\n if p < ans:\n ans = p\nprint(ans)"}, {"source_code": "def get(a):\n\treturn max([a.count(i) for i in set(a)])\n\n\nn, k = map(int, input().split())\na = sorted(list(map(int, input().split())))\nb = a.copy()\n\ncan = set()\ncan.add(0)\nfor i in range(n):\n\twhile b[i] != 0:\n\t\tcan.add(b[i])\n\t\tb[i] //= 2\n\ncan = list(can)\nans = []\nfor i in range(len(can)):\n\tb = a.copy()\n\tlocal_ans = 0\n\tcount = 0\n\tfor j in range(n):\n\t\tnow_count = 0\n\t\twhile b[j] > can[i]:\n\t\t\tb[j] //= 2\n\t\t\tnow_count += 1\n\t\tif b[j] == can[i]:\n\t\t\tcount += now_count\n\t\t\tlocal_ans += 1\n\t\tif local_ans >= k:\n\t\t\tbreak\n\tif local_ans >= k:\n\t\tans.append(count)\n\n# print(ans)\nprint(min(ans))\n"}, {"source_code": "n=[int(x) for x in input().split()]\nm=[int(x) for x in input().split()]\nm.sort()\nok=[[] for i in range(2*(10**5)+1)]\nfor i in range(n[0]):\n t=0\n while m[i]>0:\n ok[m[i]].append(t)\n t+=1\n m[i]=m[i]//2\n ok[0].append(t)\nans=1000000000\nfor i in range(len(ok)):\n if len(ok[i])>=n[1]:\n ans=min(ans,sum([ok[i][j] for j in range(n[1])]))\nprint(ans)\n "}, {"source_code": "n,m=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\n\nc=list(set(a))\n\nb=[[] for i in range(200005)]\n\nfor i in a:\n temp=i;j=0\n b[temp].append(0)\n\n if temp!=1:\n while(1):\n temp=temp//2\n j+=1\n b[temp].append(j)\n if temp==1:\n break\n\nres=2000000005 \nfor i in range(1,max(a)+1):\n if len(b[i])>=m:\n temp=sum(b[i][:m])\n res=min(res,temp)\nprint(res)\n \n"}, {"source_code": "from collections import defaultdict\n# from heapq import heappush, heappop\n# from bisect import insort\n\nn, k = [int(x) for x in raw_input().split()]\ninputs = [int(x) for x in raw_input().split()]\n\ndef min_step(inputs, k):\n n = len(inputs)\n # reduced = [[] for _ in range(n)]\n\n reduce_count = defaultdict(int)\n reduce_step = defaultdict(lambda: [])\n for i in range(len(inputs)):\n x = inputs[i]\n count = 0\n while x > 0:\n reduce_count[x] += 1\n reduce_step[x].append(count)\n # reduced[i].append(x)\n x /= 2\n count += 1\n\n # print 'reduce_count', dict(reduce_count)\n # print 'reduce_step', dict(reduce_step)\n\n output = float(\"inf\")\n didsort = defaultdict(lambda: False)\n for x in reduce_count:\n if reduce_count[x] >= k: # at least k numbers can reduce to x:\n current_count = 0\n \n if not didsort[x]:\n reduce_step[x].sort()\n didsort[x] = True\n # steps = reduce_step[x].values()\n # steps.sort()\n\n output = min(output, sum(reduce_step[x][:k]))\n\n return output\n\nprint(min_step(inputs, k))\n"}, {"source_code": "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nl.sort()\nd = dict()\nc = 0\nf = 0\na = [0 for i in range(200001)]\nmin1 = -1\nwhile(l[-1] != 0):\n\tfor i in range(f,len(l)):\n\t\tif l[i] in d:\n\t\t\td[l[i]] += 1\n\t\telse:\n\t\t\td[l[i]] = 1\n\t\ta[l[i]] += c\n\t\tif(d[l[i]] >= k):\n\t\t\t#print(min1,l[i],d[l[i]],a[l[i]])\n\t\t\tif(min1 == -1):\n\t\t\t\tmin1 = a[l[i]]\n\t\t\telse:\n\t\t\t\tmin1 = min(min1,a[l[i]])\n\t\tif(l[i] == 0):\n\t\t\tf = i+1\n\t\tl[i] = l[i]//2\n\t#print(l)\n\tc += 1\nprint(min1)"}, {"source_code": "import sys\nn,k=map(int,raw_input().split())\nl=list(map(int,raw_input().split()))\nl.sort()\n\nd={}\nfor i in xrange(0,2*(10**5)+1):\n key=i\n d[key]=[0,[]]\n\nfor i in xrange(len(l)):\n key=l[i]\n if key not in d:\n d[key]=[1,[]]\n\nfor i in d:\n if d[i][0]>=k:\n print 0\n sys.exit()\n\nfor i in xrange(len(l)):\n x=l[i]\n c=0\n d[x][0]+=1\n d[x][1].append(c)\n while x!=0:\n x/=2\n c+=1\n d[x][0]+=1\n d[x][1].append(c)\n \n\nans=10**9\nfor i in d:\n if len(d[i][1])>=k:\n s=sum(d[i][1][:k])\n ans=min(ans,s)\nprint ans"}, {"source_code": "from collections import defaultdict as dd\nt=1\nd=dd(list)\nfor _ in range(t):\n n,k=map(int,input().split())\n arr=list(map(int,input().split()))\n arr.sort()\n for i in range(n):\n j=arr[i]\n d[j]+=[0]\n co=1\n while(j!=0):\n j=j//2\n if(j in d):\n d[j]+=[d[j][-1]+co]\n else:\n d[j]+=[co]\n co+=1\n mini=999999999999\n #print(d)\n for i in d:\n if(len(d[i])>=k):\n mini=min(d[i][k-1],mini)\n print(mini)\n \n \n "}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter\n \ndef read_input():\n n, k = map(int, stdin.readline().rstrip().split())\n array = map(int, stdin.readline().rstrip().split())\n return n, k, array\n \ndef get_powers(num, max_num=int(2e5)):\n j = 0\n add = 0\n if num == 0: \n num = 1\n add = 1\n while True:\n power_2 = 2**j\n cur_power = num * power_2 \n for i in range(cur_power, cur_power + power_2):\n if i > max_num:\n return\n yield (i, j+add)\n j += 1\n \ndef _get_res(cur_res, k, dist, prev_res, steps):\n delta1 = cur_res - prev_res\n delta2 = k - prev_res\n return steps - dist * (delta1-delta2)\n \ndef get_result(n, k, array):\n counter = Counter(array)\n \n for new_elem in range(int(2e5)):\n if new_elem not in counter:\n counter[new_elem] = 0\n #print(counter)\n freq_array = counter.most_common()\n results = []\n #print(\"freq_array:\", freq_array)\n for key, _ in freq_array:\n #print(\"current key:\", key)\n res, prev_res, steps = 0, 0, 0\n for power, dist in get_powers(key):\n #print(power)\n if power in counter:\n val = counter[power]\n prev_res = res\n res += val\n steps += dist * val\n #print(\"steps, power, counter[power], res, dist:\", steps, power, counter[power], res, dist)\n if res >= k:\n results.append(_get_res(res, k, dist, prev_res, steps))\n break\n #print(results)\n final_res = 0\n if results:\n final_res = min(results)\n return final_res\n \ndef main():\n n, k, array = read_input()\n #n, k = 50, 2\n #array = [int(item) for item in \"72548 51391 1788 171949 148789 151619 19225 8774 52484 74830 20086 51129 151145 87650 108005 112019 126739 124087 158096 59027 34500 87415 115058 194160 171792 136832 1114 112592 171746 199013 101484 182930 185656 154861 191455 165701 140450 3475 160191 122350 66759 93252 60972 124615 119327 108068 149786 8698 63546 187913\".split()]\n #print(sorted(array))\n stdout.write(str(get_result(n, k, array)) + \"\\n\")\n #print([i for i in list(get_powers(1114)) if i in array])\n \nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "n, k = map(int, input().split())\n\narr = list(map(int, input().split()))\n\nposs = set()\n\nfor ele in arr:\n\twhile ele:\n\t\tposs.add(ele)\n\t\tele = ele // 2\n\nans = float('inf')\nfor res in poss:\n\tcnt = []\n\tfor ele in arr:\n\t\tcur = 0\n\t\twhile ele > res:\n\t\t\tele = ele // 2\n\t\t\tcur += 1\n\n\t\tif ele == res:\n\t\t\tcnt.append(cur)\n\tif len(cnt) < k:\n\t\tcontinue\n\tcnt.sort()\n\tans = min(ans, sum(cnt[:k]))\nprint(ans)"}, {"source_code": "import sys\ndef i():\n return sys.stdin.readline()[:-1]\n\ndef count(l,i):\n return sum(x==i for x in i)\nl,desiredSame = map(int,i().split())\nnums = list(map(int,i().split()))\n\npos = set()\npos.add(0)\nfor item in nums:\n while item > 0:\n pos.add(item)\n item >>=1\n\ncurrMin = 9000\nfor x in pos:\n distance = []\n for item in nums:\n shift = 0\n while item > x:\n shift += 1\n item >>= 1\n if item == x:\n distance.append(shift)\n if len(distance) >= desiredSame:\n currMin = min(currMin, sum(sorted(distance)[:desiredSame]))\nprint(currMin)"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip\nfrom __builtin__ import xrange as range\nfrom math import ceil\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom math import log, ceil\nfrom bisect import bisect, insort, bisect_left, bisect_right\nimport heapq\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\n \n'''\nCheck for special cases (n=1)\nOne wrong submission = 10 mins penalty!\ndo smth instead of nothing and stay organized\n'''\n\ndef main():\n\tn, k = map(int, input().split())\n\tarr = list(map(int, input().split()))\n\tposs = []\n\tfor i in range(n):\n\t\tx = arr[i]\n\t\twhile x > 0:\n\t\t\tposs.append(x)\n\t\t\tx //= 2\n\n\tans = inf\n\tfor res in poss:\n\t\tcnt = []\n\t\tfor i in range(n):\n\t\t\tx = arr[i]\n\t\t\tcurr = 0\n\t\t\twhile x > res:\n\t\t\t\tx //= 2\n\t\t\t\tcurr += 1\n\t\t\tif x == res:\n\t\t\t\tcnt.append(curr)\n\t\tif len(cnt) >= k:\n\t\t\tcnt.sort()\n\t\t\tans = min(ans, sum(cnt[:k]))\n\tprint(ans)\n\t\n\nBUFSIZE = 8192\nclass FastI(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = StringIO()\n\t\tself.newlines = 0\n \n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(\"\\n\") + (not b)\n\t\t\tptr = self._buffer.tell()\n\t\t\tself._buffer.seek(0, 2), self._buffer.write(\n\t\t\t\tb), self._buffer.seek(ptr)\n\t\tself.newlines -= 1\n\t\treturn self._buffer.readline()\nclass FastO(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = __pypy__.builders.StringBuilder()\n\t\tself.write = lambda s: self._buffer.append(s)\n \n\tdef flush(self):\n\t\tos.write(self._fd, self._buffer.build())\n\t\tself._buffer = __pypy__.builders.StringBuilder()\ndef print(*args, **kwargs):\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n\tat_start = True\n\tfor x in args:\n\t\tif not at_start:\n\t\t\tfile.write(sep)\n\t\tfile.write(str(x))\n\t\tat_start = False\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\n\tif kwargs.pop(\"flush\", False):\n\t\tfile.flush()\ndef gcd(x, y):\n\twhile y:\n\t\tx, y = y, x % y\n\treturn x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n\tdef bootstrap(cont):\n\t\tcall, arg = cont.switch()\n\t\twhile True:\n\t\t\tcall, arg = cont.switch(to=continulet(\n\t\t\t\tlambda _, f, args: f(*args), call, arg))\n\tcont = continulet(bootstrap)\n\tcont.switch()\n\tmain()"}, {"source_code": "import heapq\nfrom collections import defaultdict\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n\n d = [[-1 for i in range(2*(10**5)+1)] for j in range(n)]\n\n l = []\n for i in range(n):\n c = 0\n while True:\n l.append(a[i])\n d[i][a[i]] = c\n if a[i] == 0:\n break\n a[i] //= 2\n c += 1\n ans = float(\"inf\")\n for v in set(l):\n tans = 0\n cnt = 0\n val = []\n heapq.heapify(val)\n for i in range(n):\n if d[i][v] != -1 and cnt != k:\n tans += d[i][v]\n heapq.heappush(val, -d[i][v])\n cnt += 1\n elif d[i][v] != -1 and cnt == k:\n z = -heapq.heappop(val)\n if d[i][v] < z:\n tans -= z\n tans += d[i][v]\n heapq.heappush(val, -d[i][v])\n else:\n heapq.heappush(val, -z)\n if cnt < k:\n continue\n\n ans = min(ans, tans)\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom __builtin__ import xrange as range\nfrom cStringIO import StringIO\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom io import IOBase\n\nimport __pypy__\n\nfrom collections import defaultdict\n\n\ndef main():\n n, k = map(int, input().split())\n a = [int(ai) for ai in input().split()]\n\n min_cost = 10**9\n for i in range(19):\n counter = defaultdict(list)\n for ai in a:\n bina = bin(ai)[2:]\n if len(bina) >= i:\n trunc = bina[:i]\n counter[trunc].append(len(bina) - i)\n for val in counter.values():\n if len(val) >= k:\n min_cost = min(sum(sorted(val)[:k]), min_cost)\n\n print(min_cost)\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0,\n 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from collections import defaultdict as dc\nx,y=map(int,input().split())\ncoun=dc(lambda:0)\nsteps=dc(lambda:0)\n\ns=list(map(int,input().split()))\ns.sort()\nfor n in s:\n coun[n]+=1\n if coun[n]==y:\n print(0)\n exit(0)\nres=10**9\nfor n in s:\n p=n\n stp=0\n while p:\n p//=2\n stp+=1\n coun[p]+=1\n steps[p]+=stp\n if(coun[p]==y):\n res=min(res,steps[p])\n \nprint(res)\n\n"}, {"source_code": "import sys\nimport math\nnumlog = dict()\nn, k = list(map(int, sys.stdin.readline().rstrip().split()))\nnum = list(map(int, sys.stdin.readline().rstrip().split()))\ncnt = list()\nfor i in range(200001):\n cnt.append([])\nfor i in range(n):\n t = num[i]\n val = 0\n while t > 0:\n cnt[t].append(val)\n t //= 2\n val += 1\n\nres = 9876543210\nfor i in range(200001):\n if len(cnt[i]) < k:\n continue\n cnt[i].sort()\n res = min(res, sum(cnt[i][:k]))\n\nprint(res)"}, {"source_code": "n,k=(int(i) for i in input().split())\na=[int(i) for i in input().split()]\na.sort()\nans=-1\nfor i in range(a[-1]+1):\n num=0\n for j in range(n):\n if a[j]>=i:\n break\n count=0\n while num<k and j<n:\n y=a[j]\n x=i\n count1=0\n while y>x:\n y//=2\n count1+=1\n if y==x:\n num+=1\n count+=count1\n j+=1\n if ans==-1 or (count<ans and num==k):\n ans=count\nprint(ans)\n"}, {"source_code": "from sys import stdin\n\nn, k = [int(i) for i in stdin.readline().strip().split()]\na = [int(i) for i in stdin.readline().strip().split()]\n\n\np = [19 * [0] for _ in range(max(a) + 1)]\n\n\nnums = set()\nfor m in a:\n for i in range(19):\n p[m >> i][i] += 1\n nums.add(m >> i)\n\n if (m >> i) == 0:\n break\n\nres = 10000000000000000000\n\nfor m in nums:\n d = p[m]\n sum = 0\n steps = 0\n for i in range(19):\n if sum + d[i] >= k:\n add = (k - sum) * i\n steps += add\n res = min(steps, res)\n break\n else:\n sum += d[i]\n steps += (i * d[i])\n\nprint(res)\n"}, {"source_code": "from collections import *\nn,k = map(int,input().split())\nl = sorted(list(map(int,input().split())))\nmini = None\nd = defaultdict(lambda: [0,0])\nfor i in l:\n cnt=0\n while i>0:\n d[i][0]+=1\n d[i][1]+=cnt\n if d[i][0]==k:\n mini = d[i][1] if mini==None else min(mini,d[i][1])\n cnt+=1\n i//=2\nprint(mini)\n"}, {"source_code": "#------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now-----------------------------------------------------\nn,k=map(int,input().split())\nl=list(map(int,input().split()))\nr=[[]for i in range((max(l)+1))]\nt=max(l)+1\nfor i in range(n):\n c=0\n while(l[i]>0):\n r[l[i]].append(c)\n c+=1\n l[i]//=2\nans=999999999999999999999999999\nfor i in range(t):\n if len(r[i])>=k:\n r[i].sort()\n ans=min(ans,sum(r[i][:k]))\nprint(ans)"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# ------------------- fast io --------------------\nimport math;from collections import defaultdict\nn,k=map(int,input().split())\nvals=list(map(int,input().split()));vals.sort()\ndict1=defaultdict(list)\nif vals[-1]==0:\n print(0)\nelse:\n minsofar=10**10\n for s in range(len(vals)):\n temp=vals[s];count=0\n while temp>0:\n if len(dict1[temp])==0:\n dict1[temp]=[count]\n else:\n dict1[temp].append(dict1[temp][-1]+count)\n temp=temp//2;count+=1\n for s in dict1:\n if len(dict1[s])>=k:\n minsofar=min(minsofar,dict1[s][k-1])\n print(minsofar)"}, {"source_code": "from collections import defaultdict\nn, k = [int(x) for x in raw_input().split()]\ninputs = [int(x) for x in raw_input().split()]\n\ndef min_step(inputs, k):\n n = len(inputs)\n # reduced = [[] for _ in range(n)]\n\n reduce_count = defaultdict(int)\n reduce_step = defaultdict(lambda: defaultdict(int))\n for i in range(len(inputs)):\n x = inputs[i]\n count = 0\n while x > 0:\n reduce_count[x] += 1\n reduce_step[x][i] = count\n # reduced[i].append(x)\n x /= 2\n count += 1\n\n # print 'reduce_count', dict(reduce_count)\n # print 'reduce_step', dict(reduce_step)\n\n output = float(\"inf\")\n for x in reduce_count:\n if reduce_count[x] >= k: # at least k numbers can reduce to x:\n current_count = 0\n \n steps = reduce_step[x].values()\n steps.sort()\n\n output = min(output, sum(steps[:k]))\n\n return output\n\nprint(min_step(inputs, k))\n"}, {"source_code": "# t=int(input())\nt=1\nfor j in range(t):\n n,k=list(map(int,input().strip().split()))\n a=list(map(int,input().strip().split()))\n arr=[]\n for i in range(2*10**5+2):\n arr.append([])\n for i in a:\n x=0\n xx=i\n arr[xx].append(x)\n while(xx):\n xx=xx//2\n x+=1\n arr[xx].append(x)\n op=sum(arr[0])\n # print(arr)\n for i in arr:\n \n if(len(i)<k):\n continue\n x=i.copy()\n x.sort()\n op=min(op,sum(x[:k]))\n print(op)\n "}, {"source_code": "n, m = map(int, input().split())\ns = str(input())\na = [int(i) for i in s.split()]\nb = [0] * 200001\nc = [0] * 200001\n\na.sort()\n\nfor elem in a:\n b[elem] += 1\n count = 0\n while elem != 0 and b[elem // 2] < m:\n elem //= 2\n count += 1\n c[elem] += count\n b[elem] += 1\n\nans = 10000000000\nfor i in range(len(b)):\n if b[i] >= m:\n if ans > c[i]:\n ans = c[i]\nprint(ans)\n"}, {"source_code": "import math \n\nn,k=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\n\nsteps = [0]*200005 \ncount = [0]*200005 \nans = []\n# \n#for i in range(n):\n# count[a[i]]+=1 \n\nfor i in range(n):\n x=a[i]\n# if count[x] == k :ans.append(steps[x])\n# print(math.floor(math.log2(a[i])+2))\n for j in range(math.floor(math.log2(a[i])+2)):\n if count[x] == k :\n ans.append(steps[x])\n\n \n \n count[x]+=1\n steps[x]+=j\n x=x//2\nfor i in range(200005):\n if count[i]==k:\n ans.append(steps[i])\n \n\nprint(min(ans))\n \n \n \n \n "}, {"source_code": "n,k=map(int,input().split())\nar=list(map(int,input().split()))\ndic={}\nfor i in range(n):\n if(not(ar[i] in dic)):\n dic[ar[i]]=[0]\n else:\n dic[ar[i]].append(0)\n count=0\n while(ar[i]):\n ar[i]//=2\n count+=1\n if(not(ar[i] in dic)):\n dic[ar[i]]=[count]\n else:\n dic[ar[i]].append(count)\nans=float('inf')\nfor i in dic:\n if(len(dic[i])>=k):\n dic[i].sort()\n ans=min(ans,sum(dic[i][:k]))\nprint(ans)"}, {"source_code": "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n# sys.setrecursionlimit(pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\nn, k = sp()\narr = l()\narr.sort()\nanswer = inf\nfor i in range(1, 200001):\n res = 0\n cnt = 0\n # print(arr)\n for j in range(n):\n if arr[j] < i:\n continue\n c = 0\n temp = arr[j]\n while temp > i:\n temp //= 2\n c += 1\n if temp == i:\n res += c\n cnt += 1\n if cnt == k:\n break\n # print(i, res)\n if cnt == k:\n answer = min(answer, res)\nout(answer)\n"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)\n#from bisect import bisect_right as br #c++ upperbound br(array,element)\n \nfrom collections import defaultdict\ndef main():\n n,k=map(int,input().split(\" \"))\n a=list(map(int,input().split(\" \")))\n dic=defaultdict(lambda:[])\n for x in range(n):\n cnt=0\n while a[x]!=0:\n dic[a[x]].append(cnt)\n a[x]=a[x]//2\n cnt+=1\n dic[0].append(cnt)\n ans=int(1e100)\n for y in dic.values():\n if len(y)>=k:\n ans=min(ans,sum(sorted(y)[:k])) \n print(ans)\n\n\n\n\n#-----------------------------BOSS-------------------------------------!\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().strip()\n\nn, k = map(int, input().split())\nls = list(map(int, input().split()))\nls.sort()\narr = []\nfor i in ls:\n while i!=0:\n arr.append(i)\n i//=2\n arr.append(0)\narr = list(set(arr))\narr.sort()\ncnts = []\nm = 10000000000000000000\nfor x in arr:\n cnts = []\n for i in ls:\n cnt = 0\n while i>x:\n i//=2\n cnt+=1\n if i==x: cnts.append(cnt)\n S = 0\n try:\n for i in range(k):\n S+=cnts[i]\n m = min(m, S)\n except: pass\nprint(m)\n"}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().strip()\n\nn, k = map(int, input().split())\nls = list(map(int, input().split()))\nls.sort()\narr = []\nfor i in ls:\n while i!=0:\n arr.append(i)\n i//=2\n arr.append(0)\narr = list(set(arr))\narr.sort()\ncnts = []\nm = 10000000000000000000\nfor x in arr:\n cnts = []\n for i in ls:\n cnt = 0\n while i>x:\n i//=2\n cnt+=1\n if i==x: cnts.append(cnt)\n cnts.sort()\n S = 0\n try:\n for i in range(k):\n S+=cnts[i]\n m = min(m, S)\n except: pass\nprint(m)\n"}, {"source_code": "\nn, k = [int(x) for x in input().split()]\n\na = [int(x) for x in input().split()]\n\na.sort()\n\nind=[0]*200001\ncnt=[0]*200001\nans = []\nfor key in a:\n ind[key]+=1\ntr = False\nfor key in a:\n if ind[key] >= k:\n ans.append(cnt[key])\n cnnt=1\n while (key>1):\n key //= 2\n ind[key]+=1\n cnt[key]+=cnnt\n if ind[key]>=k:\n ans.append(cnt[key])\n cnnt += 1\nprint (min(ans))"}, {"source_code": "import sys\ninput = sys.stdin.readline\nfrom collections import defaultdict\nfrom heapq import *\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\npqs = defaultdict(list)\n\nfor i in range(n):\n ai = a[i]\n cnt = 0\n \n while True:\n if len(pqs[ai])<k:\n heappush(pqs[ai], -cnt)\n else:\n if -pqs[ai][0]>cnt:\n heappop(pqs[ai])\n heappush(pqs[ai], -cnt)\n \n if ai==0:\n break\n \n ai //= 2\n cnt += 1\n\nans = 10**18\n\nfor pq in pqs.values():\n if len(pq)<k:\n continue\n \n ans = min(ans, -sum(pq))\n\nprint(ans)"}, {"source_code": "def reduce(n):\n a = []\n while n>0:\n n=n//2\n a.append(n)\n return a\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(set(a))\nb.sort()\nfrom collections import defaultdict\nc,d = defaultdict(int),defaultdict(int)\nc[0]=0\nd[0]=0\nfor i in a:\n c[i]+=1\n d[i]=0\nfor i in b:\n p,q = c[i],d[i]\n t = reduce(i)\n t.reverse()\n w=1\n while t!=[]:\n r = t.pop()\n x = c[r]\n if x>=k:\n w=w+1\n continue\n else:\n if (x+p)<=k:\n c[r]=x+p\n d[r]+=(w*p)\n else:\n z = k-x\n c[r]=k\n d[r]+=z*w\n w=w+1\nmi = float(\"inf\")\nfor i in c:\n if c[i]>=k:\n if d[i]<mi:\n mi=d[i]\nprint(mi)\n"}, {"source_code": "\n\n\n\nn,k = map(int,input().split(\" \"))\narr = list(map(int,input().split(\" \")))\narr.sort()\narr2 = [[0 for i in range(19)] for j in range(200001)] \nfor i in range(n):\n\ttemp = arr[i]\n\tcount = 0\n\tarr2[temp][count]+=1\n\twhile(temp>0):\n\t\ttemp = temp//2\n\t\tcount+=1\n\t\tarr2[temp][count]+=1\n\n\nmini = 10000000\nfor i in range(200001):\n\ts = 0\n\tcost = 0\n\tflag = 0\n\tindex = 0\n\tfor j in range(19):\n\t\tif(arr2[i][j]+s>=k):\n\t\t\tt = k-s\n\t\t\tcost+=t*j\n\t\t\ts = k\n\t\t\tflag = 1\n\t\t\t#print(cost)\n\t\t\tbreak\n\t\telse:\n\t\t\ts+=arr2[i][j]\n\t\t\tcost+=arr2[i][j]*j\n\tif(flag==1 and mini>cost):\n\t\t#print(cost,i)\n\t\tmini = cost\n\n\nprint(mini)\n\t\t\n\t\t\n"}, {"source_code": "n, k = map(int, input().split())\nl = list(map(int, input().split()))\np = 2*10**5 + 1\nb = [[] for _ in range(p)]\nfor a in l:\n count = 0\n while(a > 0):\n b[a].append(count)\n count += 1\n a = a//2\nans = 1000000000000000\nfor a in b:\n if len(a) >= k:\n ans = min(ans, sum(sorted(a)[:k]))\nprint(ans)"}, {"source_code": "'''input\n5 3\n1 2 3 4 5\n'''\nfrom sys import stdin\nfrom copy import deepcopy\nfrom collections import deque, defaultdict\n\n\ndef get_arr(num):\n\tif num in freq:\n\t\tif len(freq[num]) >= k:\n\t\t\treturn sum(freq[num][: k])\n\t\telse:\n\t\t\treturn float('inf')\n\telse:\n\t\treturn float('inf')\n\t\n\n\n\ndef get_min(arr):\n\tfor i in freq:\n\t\tif freq[i] >= k:\n\t\t\treturn 0\n\treturn float('inf')\n\n\n# main starts\nn, k = list(map(int, stdin.readline().split()))\narr = list(map(int, stdin.readline().split()))\narr.sort()\n\nfreq = defaultdict(list)\nfor num in arr:\n\tcount = 0\n\twhile num > 0:\n\t\tfreq[num].append(count)\n\t\tnum //= 2\n\t\tcount += 1\n\tfreq[0].append(count)\n\n\n# print(freq)\n\nfor i in freq:\n\tfreq[i].sort()\n\nans = float('inf')\nm = max(arr)\nfor i in range(0, m + 1):\n\tans = min(ans, get_arr(i))\n\t\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\nfrom math import floor\n\nd = defaultdict(list)\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nfor i in a:\n c, tmp = 0, i\n while True:\n d[tmp].append(c)\n if tmp==0: break\n tmp = floor(tmp/2)\n c+=1\n\nmn = 2*10**18\nfor ke in d:\n ans = 0\n l = len(d[ke])\n if l<k: continue\n fin = sorted(d[ke])\n ans = sum(fin[:k])\n mn = min(mn, ans)\n\nprint(mn)\n\n"}, {"source_code": "# import io, os\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nimport sys\n# sys.stdin=open('input.txt','r')\n# sys.stdout=open('output.txt','w')\ninput=sys.stdin.readline\n# sys.setrecursionlimit(300010)\nMOD = 1000000007\nMOD2 = 998244353\nii = lambda: int(input().strip('\\n'))\nsi = lambda: input().strip('\\n')\ndgl = lambda: list(map(int,input().strip('\\n')))\nf = lambda: map(int, input().strip('\\n').split())\nil = lambda: list(map(int, input().strip('\\n').split()))\nls = lambda: list(input().strip('\\n'))\nlsi = lambda: [int(i) for i in ls()]\nlet = 'abcdefghijklmnopqrstuvwxyz'\nfor _ in range(1):\n n,k=f()\n l=il()\n mx=max(l)\n cost=[[] for i in range(mx+1)]\n for i in l:\n x=0\n while i>0:\n cost[i].append(x)\n x+=1\n i//=2\n cost[0].append(x)\n mn=10**15\n for i in range(mx+1):\n if len(cost[i])>=k:\n cost[i].sort()\n mn=min(mn,sum(cost[i][:k]))\n print(mn)"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)\n#from bisect import bisect_right as br #c++ upperbound br(array,element)\nfrom collections import Counter\nimport math\ndef main():\n n,k=map(int,input().split(\" \"))\n a=list(map(int,input().split(\" \")))\n if max(Counter(a).values())>=k:\n print(0)\n else:\n # print(sorted(a))\n ans=sum(sorted([math.ceil(math.log(x,2)) for x in a])[:k])\n for x in range(n):\n tmpx=a[x]\n tempadd=0\n while(tmpx>0):\n temp=[]\n for y in range(n):\n if x!=y:\n dat=a[y]\n cnt=0\n while(tmpx<dat):\n dat=dat//2\n cnt+=1\n temp.append(cnt if tmpx==dat else 99999999) \n temp.sort()\n ans=min(ans,sum(temp[0:k-1])+tempadd)\n tmpx=tmpx//2 \n tempadd+=1\n print(ans)\n\n#-----------------------------BOSS-------------------------------------!\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "from sys import stdin\n\ndef input():\n return next(stdin)\n\ndef main():\n n,k = map(int,input().split())\n aa = [int(a) for a in input().split()]\n aa.sort()\n valmap = {}\n for a in aa:\n add_to_map(a, 0, k, valmap)\n i = 0\n while a > 0:\n i+=1\n a = a//2\n add_to_map(a, i, k, valmap)\n\n result = min(s for c,s in valmap.values() if c == k)\n print(result)\n\n\ndef add_to_map(a, i, k, valmap):\n if a in valmap:\n if valmap[a][0] < k:\n valmap[a][0] += 1\n valmap[a][1] += i\n else:\n valmap[a] = [1, i]\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "from sys import stdin\n\ndef input():\n return next(stdin)\n\ndef main():\n n,k = map(int,input().split())\n aa = [int(a) for a in input().split()]\n aa.sort()\n valmap = {}\n for a in aa:\n add_to_map(a, 0, k, valmap)\n i = 0\n while a > 0:\n i+=1\n a = a//2\n add_to_map(a, i, k, valmap)\n\n min = 20*k\n for vl in valmap.values():\n if len(vl) == k and sum(vl) < min:\n min = sum(vl)\n print(min)\n\n\ndef add_to_map(a, i, k, valmap):\n if a in valmap:\n if len(valmap[a]) < k:\n valmap[a].append(i)\n else:\n valmap[a] = [i]\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort()\nd={}\nfor i in l:\n if i not in d:\n d[i]=1\n else:\n d[i]+=1\ne=list(d.keys())\ne.append(0)\nans=0\nr=1000000000000000\nfor i in range(0,200001):\n if i in d:\n x=d[i]\n else:\n x=0\n if(x>=m):\n r=0\n break\n ans=0\n for j in l:\n if(j==i):\n continue\n else:\n f=0\n while(j>=i):\n if(j==i or j==0):\n x+=1\n ans+=f\n break\n j//=2\n f+=1\n if(x>=m):\n r=min(ans,r)\n break\nprint(r)\n "}, {"source_code": "N = int(2e5+7)\nD = 20\n\ndef testList(dp):\n dp[1][5] = 77\n for i in range(0,5):\n print(\"dp[{0}]={1}\".format(i,dp[i]))\n\nn , k = map(int,input().strip().split())\nnumberList = list(map(int,input().strip().split()))\nmaxn = max(numberList)\n\nnumCount = [0]*N\n#dp = [[0]*D]*N\ndp = [[0 for i in range(D)] for j in range(N)]\n\n# testList(dp)\n\nfor i in numberList:\n numCount[i] += 1\n\nres = int(0x7fffffff)\n\nfor i in range(maxn,-1,-1):\n dp[i][0] = numCount[i]\n\n if(i*2 <= maxn):\n for d in range(1,20):\n # print(\"dp[{0}][{1}] = {2}, dp[{3}][{4}] = {5}\".format(i,d,dp[i][d],i*2,d-1,dp[i*2][d-1]))\n dp[i][d] += dp[i*2][d-1]\n # print(\"dp[{0}][{1}] = {2}\".format(i,d,dp[i][d]))\n if(i*2+1 <= maxn):\n for d in range(1,20):\n # print(\"dp[{0}][{1}] = {2}, dp[{3}][{4}] = {5}\".format(i,d,dp[i][d],i*2+1,d-1,dp[i*2+1][d-1]))\n dp[i][d] += dp[i*2+1][d-1]\n # print(\"dp[{0}][{1}] = {2}\".format(i,d,dp[i][d]))\n\n equ_cnt = 0\n equ_res = 0\n for d in range(0,20):\n if equ_cnt + dp[i][d] < k:\n equ_res += d * dp[i][d]\n equ_cnt += dp[i][d]\n# print(\"[0]equ_cnt={0},equ_res={1},d={2},k={3}\".format(equ_cnt,equ_res,d,k))\n else:\n equ_res += d*(k-equ_cnt)\n equ_cnt += (k-equ_cnt)\n \n res = min(res,equ_res)\n# print(\"[1]equ_cnt={0},equ_res={1},res={2},d={3},k={4}\".format(equ_cnt,equ_res,res,d,k))\n break\n \n# print(\"i={0},step={1}\".format(i,equ_res),dp[i])\n \nprint(res)"}, {"source_code": "n, k = [int(i) for i in input().split()]\ndata = [int(i) for i in input().split()]\n\ndic = [[0]*20 for j in range(200001)] \n# for i in range(20):\n# dics.append( )\n\nfor d in data:\n # ln = len(bin(d)) - 2\n s = 0\n while d:\n dic[d][s] += 1\n d >>= 1\n s += 1\n dic[0][s] += 1\n\nmn = 1<<30\n# for i in range(20):\n# dic = dics[i].values()\nfor d in dic:\n if sum(d) >= k:\n left = k\n val = 0\n # for _ in range(int(input())):\n# n = int(input())\n# data = [int(i) for i in input().split()]\n# mx = [0] * n\n# mx1 = 1 <<50\n# for i in range(n-1, -1, -1):\n# mx[i] = mx1\n# mx1 = min(data[i], mx1)\n# ans = 0\n# for i in range(n):\n# if data[i] > mx[i]:\n# ans += 1\n# print(ans)\n\n for i in range(20):\n if d[i] >= left:\n val += i * (left)\n break\n else:\n val += i * d[i]\n left -= d[i]\n\n # val = sum(d[:k])\n if val < mn:\n mn = val\n\n\n\nprint(mn)\n\n# ans2 = 0 \n# vals = dics[ans].values()\n# if len(vals) == 0:\n# pass\n# else:\n# val = max(vals)\n# for d in dic"}, {"source_code": "n, k = [int(s) for s in input().split(\" \")]\nA = [int(s) for s in input().split(\" \")]\ndivs = [0]*len(A)\nmaximum = max(A)\nans = float('inf')\nwhile maximum > 0:\n if A.count(max(A)) >= k:\n D = [divs[i] for i in range(len(A)) if A[i] == maximum]\n D.sort()\n ans = min (ans, sum(D[:k]))\n max_index = A.index(max(A))\n A[max_index] = int(A[max_index] / 2 )\n maximum = max(A)\n divs[max_index] += 1\nD = [divs[i] for i in range(len(A)) if A[i] == maximum]\nD.sort()\nans = min (ans, sum(D[:k]))\nprint(ans)"}, {"source_code": "# 7=>3=>1, 2=>1\n# 8/9\n# 4=>2=>1\n\ndef cal_dis(num,val):\n count = 0\n while num > 0:\n if val[num] == 0: val[num] = []\n val[num].append(count)\n num = num//2\n count += 1\n return count,val\n\nn,k = (int(x) for x in input().split())\nseq = [int(x) for x in input().split()]\nans = 10e8\nval = 200009 * [0]\nfor ele in seq:\n count,val = cal_dis(ele,val)\n\nfor lis in val:\n if lis != 0:\n if lis.__len__() >= k:\n lis.sort()\n sum = 0\n for ele in lis[:k]:\n sum += ele\n ans = min(ans,sum)\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\nimport sys\nn,m = map(int,input().split())\nl=list(map(int,input().split()))\nvalue=[0]\nmapping = defaultdict(list)\nfor j in range(n):\n x=l[j]\n count=0\n while(True):\n mapping[x].append(count)\n if(x==0):\n break\n x=x//2\n count+=1\nfor i in mapping:\n mapping[i].sort()\ntotal=sys.maxsize\nfor i in mapping:\n if(len(mapping[i])>=m):\n total=min(total,sum(mapping[i][0:m]))\nprint(total)\n \n \n "}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nd = {}\nfor i in a:\n\td[i] = d.get(i, 0) + 1\nif max(d.values()) >= k:\n\tprint(0)\n\texit()\na = sorted(a)\nd = max(a)\nb = [0] * (d + 1)\ndp = [0] * (d + 1)\nfor _ in range(n):\n\ti = a[_]\n\tif b[i] >= k:\n\t\tcontinue\n\tb[i] += 1\n\ttc = 0\n\twhile i != 0:\n\t\tif b[i // 2] >= k:\n\t\t\ti //= 2\n\t\telse:\n\t\t\ttc += 1\n\t\t\tb[i // 2] += 1\n\t\t\tdp[i // 2] += tc\n\t\t\ti //= 2\nans = 1431132213123133123213213231323\nfor i in range(1, d + 1):\n\tif b[i] >= k:\n\t\tans = min(ans, dp[i])\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\n\n\ndef solve(arr, k):\n\n c = defaultdict(list)\n\n for i in arr:\n j = 0\n while i:\n c[i].append(j)\n i //= 2\n j += 1\n c[i].append(j)\n\n c = {key: sorted(v) for key, v in c.items() if len(v) >= k}\n # print(c, k)\n return min(sum(v[i] for i in range(k)) for v in c.values())\n\n#\n_, k = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\n\nprint(solve(arr, k))"}, {"source_code": "import sys\nfrom collections import defaultdict\n\ndef main():\n n, k = [int(x) for x in sys.stdin.readline().split(\" \")]\n arr = [int(x) for x in sys.stdin.readline().split(\" \")]\n # vals[x][a] holds number of iterations to get from x to a\n arr.sort()\n vals = defaultdict(list)\n for i, a in enumerate(arr):\n count = 0\n while (a > 0):\n vals[a].append(count)\n a = a // 2\n count += 1\n minCount = 99999999999999\n for x,v in vals.items():\n if len(v) < k:\n continue\n else:\n a = sorted(v)\n minCount = min(minCount, sum(a[:k]))\n return minCount\n\nprint(main())\n"}, {"source_code": "n, k = map(int, input().split())\nA = list(map(int, input().split()))\nG = []\nfor _ in range(2 * 10 ** 5 + 100):\n G.append([])\nc = 0\nfor i in A:\n if len(G[i]) < k:\n G[i].append(0)\nwhile True:\n c += 1\n f = True\n for i in range(n):\n if A[i]:\n A[i] //= 2\n if len(G[A[i]]) < k:\n G[A[i]].append(c)\n if A[i]:\n f = False\n if f:\n break\nans = 10 ** 9\nfor t in G:\n if len(t) == k:\n ans = min(ans, sum(t))\nprint(ans)\n"}], "negative_code": [{"source_code": "n,k=list(map(int,input().split()))\na=list(map(int,input().rstrip().split()))\nans=float('inf')\nif n==1:\n print(0)\n exit()\nfor i in range(5):\n temp=0\n remain=k\n for j in a:\n if remain==0:\n break\n if j==i:\n remain-=1\n continue\n lo=0\n y=j\n while(y>0 and y!=i):\n y=y//2\n lo+=1\n if y==i:\n temp+=lo\n remain-=1\n \n #print(temp) \n if remain==0:\n ans=min(ans,temp)\nprint(ans)\n \n "}, {"source_code": "\nn, k = [int(x) for x in input().split()]\n\na = [int(x) for x in input().split()]\n\n\nind=[0]*200001\ncnt=[0]*200001\nans = []\nfor i in a:\n ind[i]+=1\ntr = False\nfor i in range(n):\n key = a[i]\n if ind[key] >= k:\n ans.append(cnt[key])\n cnnt=1\n while (key!=0):\n ind[key//2]+=1\n cnt[key//2]+=cnnt\n key//=2\n cnnt+=1\n if ind[key]>=k:\n ans.append(cnt[key])\n if tr:\n break\n# print (ans)\nprint (min(ans))\n\n"}, {"source_code": "\ndef func(fr,to):\n global arr2\n if fr==to:\n return 0\n if fr<to:\n return -1\n temp=func(fr//2,to)\n if temp==-1:\n return temp\n return temp+1\nn,k=map(int,input().split())\ngans=-1\narr=sorted(list(map(int,input().split())))\nss=set()\nss.add(0)\nfor i in arr:\n temp=i\n while temp>0:\n ss.add(temp)\n temp=temp//2\nfor i in sorted(ss):\n cs=0\n tk=0\n for j in arr:\n temp=func(j,i)\n if temp<0:\n continue\n cs=cs+temp\n tk=tk+1\n if gans==-1:\n gans=cs\n else:\n if tk>=k:\n gans=min(gans,cs)\n #print(i,cs,tk,gans)\n #print(i,cs,tk)\nprint(gans)"}, {"source_code": "# import numpy as np\n\ndef get_num_operations(m, x):\n if x < m: return big_number\n if x == m: return 0\n return 1 + get_num_operations(m, int(x / 2))\n\n\nbig_number = 10000000\n\nn, k=map(int, input().split())\nelements_array = list(map(int, input().split()))\n\n\nmax_element = int(max(elements_array))\nbest_result = big_number\nfor m in range(0, max_element + 1):\n cur_results_array = list()\n k_elements = 0\n for element in elements_array:\n cur_operations = get_num_operations(m, element)\n if cur_operations < big_number:\n k_elements += 1\n if k_elements == k:\n break\n cur_results_array.append(get_num_operations(m, element))\n \n cur_results_array.sort()\n cur_operations = sum(cur_results_array[:k])\n best_result = min(best_result, cur_operations)\n\nprint(best_result)"}, {"source_code": "INF = int (2e9)\nn, k = list (map (int, input ().split ()))\na = list (map (int, input ().split ()))\na.sort()\nha = {}\nf = []\n\nans = INF\n\ne = 0\np = 0\nwhile (p < n) :\n while ((1 << (e + 1)) <= a[p]) :\n e += 1\n cnt = 0\n mx = 0\n while (p < n and (1 << e) <= a[p] and (1 << (e + 1)) > a[p]) :\n if (not a[p] in ha.keys()) :\n ha[a[p]] = 1\n else :\n ha[a[p]] += 1\n cnt += 1\n mx = max (mx, ha[a[p]])\n p += 1\n if (mx >= k) :\n ans = 0\n f.append((e, cnt, mx))\n\nif (ans == INF) :\n for i in range (len (f)) :\n d = k - f[i][2]\n stp = 0\n for j in range (i + 1, len (f)) :\n p = min (f[j][1], d)\n stp += p * (j - i)\n d -= p\n if (d <= 0) :\n break\n if (d <= 0) :\n ans = min (ans, stp)\n\nprint (ans)"}, {"source_code": "import sys, os, io\ndef rs(): return sys.stdin.readline().rstrip()\ndef ri(): return int(sys.stdin.readline())\ndef ria(): return list(map(int, sys.stdin.readline().split()))\ndef ws(s): sys.stdout.write(s + '\\n')\ndef wi(n): sys.stdout.write(str(n) + '\\n')\ndef wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\\n')\nimport math,datetime,functools,itertools,operator,bisect,fractions,statistics\nfrom collections import deque,defaultdict,OrderedDict,Counter\nfrom fractions import Fraction\nfrom decimal import Decimal\nfrom sys import stdout\nfrom heapq import heappush, heappop, heapify ,_heapify_max,_heappop_max,nsmallest,nlargest\n\ndef main():\n # mod=1000000007\n # InverseofNumber(mod)\n # InverseofFactorial(mod)\n # factorial(mod)\n starttime=datetime.datetime.now()\n if(os.path.exists('input.txt')):\n sys.stdin = open(\"input.txt\",\"r\")\n sys.stdout = open(\"output.txt\",\"w\")\n \n tc=1\n for _ in range(tc):\n n,e=ria()\n a=ria()\n d={}\n f={}\n for i in a:\n k=i\n op=0\n while k!=0:\n if k in d:\n d[k]+=1\n else:\n d[k]=1\n if k in f:\n f[k].append(op)\n else:\n f[k]=[op]\n op+=1\n k=k//2\n g=0\n for i in d:\n if d[i]>=e:\n g=max(g,i) \n z=f[g]\n z=sorted(z)\n ans=0\n for i in range(e):\n ans+=z[i]\n print(ans) \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n \n\n \n \n \n\n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n #<--Solving Area Ends\n endtime=datetime.datetime.now()\n time=(endtime-starttime).total_seconds()*1000\n if(os.path.exists('input.txt')):\n print(\"Time:\",time,\"ms\") \n \n \nclass FastReader(io.IOBase):\n newlines = 0\n\n def __init__(self, fd, chunk_size=1024 * 8):\n self._fd = fd\n self._chunk_size = chunk_size\n self.buffer = io.BytesIO()\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self, size=-1):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n\nclass FastWriter(io.IOBase):\n\n def __init__(self, fd):\n self._fd = fd\n self.buffer = io.BytesIO()\n self.write = self.buffer.write\n\n def flush(self):\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass FastStdin(io.IOBase):\n def __init__(self, fd=0):\n self.buffer = FastReader(fd)\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nclass FastStdout(io.IOBase):\n def __init__(self, fd=1):\n self.buffer = FastWriter(fd)\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.flush = self.buffer.flush\n\n\nif __name__ == '__main__':\n sys.stdin = FastStdin()\n sys.stdout = FastStdout()\n main()\n "}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 30.08.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\ndef main():\n\n \n\n\n\n\n #for _ in range(ii()):\n\n n,k=mi()\n a=li()\n\n f=[0]*(200002)\n\n for i in range(n):\n\n f[a[i]]+=1\n\n if f[a[i]]==k:\n print(0)\n exit()\n\n op=0\n a.sort()\n\n\n\n\n while(True):\n\n c=0\n #op=0\n ini=-1\n fin=-1\n\n\n\n for i in range(n):\n x=a[i]//2\n\n #if a[i]==1:\n # continue\n\n if f[x]+1>=c:\n ini=i\n fin=x\n c=f[x]+1\n #print(c,'F')\n\n op+=1\n\n #print(ini,c)\n\n # print('en')\n if c>=k:\n \n print(op)\n exit()\n\n a[ini]=fin\n f[fin]+=1\n\n #if op==100:\n # break\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "from collections import defaultdict,Counter\nn,k = map(int,input().split())\nList = [int(x) for x in input().split()]\ncount = Counter(List)\nfor i in count.keys():\n if(count[i]>=k):\n print(0)\n exit()\nreached = [0] * 200001\ncost = [0] * 200001\nfor i in range(n):\n val = List[i]\n curr_cost = 0\n while(val):\n val>>=1\n curr_cost += 1\n if(reached[val]<k-count[val]):\n cost[val] += curr_cost\n reached[val] += 1\nans = 10000000000\nfor i in range(200001):\n if(cost[i]):\n if(reached[val] == k-count[val]):\n ans = min(ans,cost[i])\nprint(ans)\n\n"}, {"source_code": "from collections import deque\nimport collections\nimport sys\n\ndef inp():\n return sys.stdin.readline().strip()\nn,k=map(int,inp().split())\na=list(map(int,inp().split()))\nd=collections.Counter(a)\nb=list(d.keys())\nmn=float('inf')\nb.sort()\nfor i in range(max(b)+1):\n val=d.get(i,0)\n ans=0\n for j in b:\n if j>i:\n ct=0\n temp=j\n while temp>i:\n temp//=2\n ct+=1 \n if temp==i:\n if d[j]+val>=k:\n req=k-val\n val=k\n ans+=req*ct\n break\n else:\n val+=d[j]\n ans+=d[j]*ct\n \n if val>=k:\n mn=min(ans,mn)\nprint(mn)\n \n \n \n "}, {"source_code": "from collections import defaultdict\nn,k=map(int,input().split())\narr=list(map(int,input().split()))\nrec=defaultdict(list)\nfor i in arr:\n op=0\n while(i>0):\n rec[i].append(op)\n op+=1\n i=i//2\n #rec[0].append(op)\nans=999999999\nfor i in rec:\n if(len(rec[i])>=k):\n #print(ans,sum(rec[i][:k]))\n ans=min(ans,sum(sorted(rec[i][:k])))\nprint(ans)"}, {"source_code": "'''input\n5 3\n1 2 3 3 3\n'''\nfrom sys import stdin\nfrom copy import deepcopy\nfrom collections import deque\n\n\ndef solve(aux):\n\t# print(aux)\n\n\tcount = 0\n\tfor i in range(1, len(aux)):\n\t\twhile True:\n\t\t\tif aux[i] > aux[i - 1]:\n\t\t\t\taux[i] //= 2\n\t\t\t\tcount += 1\n\t\t\telif aux[i] < aux[i - 1]:\n\t\t\t\taux[i - 1] //= 2\n\t\t\t\tcount += i + 1\n\t\t\telse:\n\t\t\t\tbreak\n\t\n\t# print(count)\n\treturn count\n\n\n# main starts\nn, k = list(map(int, stdin.readline().split()))\narr = list(map(int, stdin.readline().split()))\nans = float('inf')\nfor i in range(0, n - k + 1):\n\taux = []\n\tfor j in range(i, i + k):\n\t\taux.append(arr[j])\n\tans = min(ans, solve(aux))\n\nprint(ans)"}, {"source_code": "import sys\nimport math\ninput=sys.stdin.readline\n\nn,k=map(int,input().split())\narr=list(map(int,input().split()))\narr.sort()\nl=[[0 for i in range(2)] for j in range((2*(10**5))+1)]\nfor i in range(n):\n l[arr[i]][1]+=1\n cnt=0\n while(arr[i]>0):\n \n arr[i]=arr[i]//2\n cnt+=1\n if(l[arr[i]][1]<k):\n l[arr[i]][0]+=cnt\n l[arr[i]][1]+=1\nans=1000006\nfor i in range(len(l)):\n if(l[i][1]==k):\n ans=min(ans,l[i][0])\nprint(ans)\n \n \n \n \n\n \n \n \n \n \n"}, {"source_code": "from collections import defaultdict\nimport sys\nn,m = map(int,input().split())\nl=list(map(int,input().split()))\nvalue=[0]\nmapping = defaultdict(list)\nfor j in range(n):\n x=l[j]\n count=0\n while(True):\n mapping[x].append(count)\n if(x==0):\n break\n x=x//2\n value.append(x)\n count+=1\nvalue=set(value)\nfor i in mapping:\n mapping[x].sort()\ntotal=sys.maxsize\nfor i in mapping:\n if(len(mapping[i])>=m):\n total=min(total,sum(mapping[i][0:m]))\nprint(total)\n \n \n "}, {"source_code": "#\n# Yet I'm feeling like\n# \tThere is no better place than right by your side\n# \t\tI had a little taste\n# \t\t\tAnd I'll only spoil the party anyway\n# \t\t\t\t'Cause all the girls are looking fine\n# \t\t\t\t\tBut you're the only one on my mind\n\n\nimport sys\n# import re\n# inf = float(\"inf\")\n# sys.setrecursionlimit(1000000)\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\n# from collections import deque, Counter, OrderedDict,defaultdict\n# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n# from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan\n# from bisect import bisect_left,bisect_right\n# import numpy as np\n\n\ndef get_array(): return list(map(int , sys.stdin.readline().strip().split()))\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef input(): return sys.stdin.readline().strip()\n\nn,k=get_ints()\nArr=get_array()\nArr.sort()\nflag=0\nfor i in range(n-k+1):\n new_array=Arr[i:i+k]\n # print(new_array)\n count=0\n for j in new_array[1:]:\n if j==new_array[0]:\n count+=1\n if count==k-1:\n flag=1\n break\nif flag==1:\n print(0)\n exit()\nmini=10**9+7\nfor i in range(n-k+1):\n new_array=Arr[i:i+k]\n count=0\n if new_array[0]&1 and new_array[0]!=1:\n x=new_array[0]//2\n else:\n x=new_array[0]\n for j in new_array[1:]:\n while j>x:\n count+=1\n j//=2\n mini=min(mini,count)\nprint(mini)"}, {"source_code": "n, k = map(int, input().split())\nx = [int(x) for x in input().split()]\nx.sort()\nanswer = pow(10, 100)\nfor i in range(len(x) - k + 1):\n temp = 0\n cnt = 0\n for j in range(i + 1, len(x)):\n a = x[j]//x[i]\n a //= 2\n #print(a, x[j], x[i])\n if x[j] // pow(2, a) == x[i]:\n #print('Accepted')\n cnt += 1\n temp += a\n if cnt == k - 1:\n break\n # print(cnt)\n if cnt == k - 1:\n # print(temp)\n answer = min(temp, answer)\n\nprint(answer)"}, {"source_code": "import sys, math\ninput = sys.stdin.readline\n \ndef getInt(): return int(input())\ndef getVars(): return map(int, input().split())\ndef getList(): return list(map(int, input().split()))\ndef getStr(): return input().strip()\n## -------------------------------\n\nn, k = getVars()\na = getList()\nd = {}\nfor x in a:\n x2 = x\n num = 0\n while x2 > 1:\n if x2 not in d:\n d[x2] = []\n d[x2].append(num)\n x2 //= 2\n num += 1\nminS = -1\nfor key in d:\n if len(d[key]) >= k:\n dKey = d[key].copy()\n dKey.sort()\n s = sum(dKey[:k])\n if minS == -1:\n minS = s\n else:\n minS = min(minS, s)\nprint(minS)\n\n'''\nmaxA = max(a)\nd = {}\nfor i in range(n):\n if a[i] not in d:\n d[a[i]] = 0\n d[a[i]] += 1\n if d[a[i]] == k:\n exit(print(0))\nprint(d)\na = list(d.keys())\nnum = 0\nwhile maxA > 1:\n num += 1\n print('maxA=', maxA, 'num=', num)\n d2 = {}\n for x in a:\n if x == 1: continue\n if x > maxA: break\n print('x=', x)\n a2 = x // 2\n if a2 not in d2:\n d2[a2] = 0\n if a2 in d:\n d2[a2] += d[a2]\n d2[a2] += d[x]\n if d2[a2] >= k:\n print(d2)\n exit(print(num))\n a = list(d.keys())\n maxA //= 2\n d = d2.copy()\n print(d)\n'''\n"}, {"source_code": "n, k = map(int, input().split())\n\narr = list(map(int, input().split()))\narr.sort()\nmin_moves = float('inf')\n\nfor i in range(n):\n\tnum_equals, moves = 1, 0\n\tfor j in range(i+1, n):\n\t\tele = arr[j]\n\t\twhile ele > arr[i]:\n\t\t\tele = ele//2\n\t\t\tmoves += 1\n\t\tif ele == arr[i]:\n\t\t\tnum_equals += 1\n\t\tif num_equals >= k:\n\t\t\tmin_moves = min(moves, min_moves)\n\t\t\tbreak\nprint(min_moves)"}, {"source_code": "def main():\n n, m = map(int, input().split())\n aa, bb = [m] * 200001, [0] * 200001\n for i in sorted(map(int, input().split())):\n aa[i] -= 1\n t = 1\n while i:\n i //= 2\n if not aa[i]:\n break\n aa[i] -= 1\n bb[i] += t\n t += 1\n print(min(b for a, b in zip(aa, bb) if not a))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from collections import defaultdict as dfd\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\n\nd = dfd(int)\ncost = dfd(int)\n\nans = 999999999\nfor i in arr:\n #uss element ke liye\n d[i] += 1\n cost[i] += 0\n \n if d[i]==k:\n ans = min(ans, cost[i])\n \n j = i\n while j>0:\n j //= 2\n d[j] += 1\n cost[j] += 1\n if d[j]==k:\n ans = min(ans, cost[j])\nprint(ans)\n"}, {"source_code": "n, k = map(int, input().split())\n\nL = sorted(list(map(int, input().split())))\n\n\nM = [[] for i in range(L[-1] + 1)]\n\nfor i in range(n):\n ct = 0\n a = L[i]\n while True:\n M[a] += [ct]\n ct += 1\n a //= 2\n if a == 0:\n M[0] += [ct] \n break\nans = None\nfor m in M:\n if len(m) < k: break\n if ans == None:\n ans = sum(m[:k])\n else:\n ans = min(ans, sum(m[:k]))\n\nprint(ans)"}, {"source_code": "n,k=(int(i) for i in input().split())\na=[int(i) for i in input().split()]\na.sort()\nans=0\nfor i in range(a[-1]+1):\n num=0\n for j in range(n):\n if a[j]==i:\n num+=1\n elif a[j]>i:\n break\n count=0\n while num<k and j<n:\n y=a[j]\n x=i\n count1=0\n while y>x:\n y//=2\n count1+=1\n if y==x:\n num+=1\n count+=count1\n j+=1\n if ans==0 or (count<ans and num==k):\n ans=count\nprint(ans)\n"}, {"source_code": "# Why do we fall ? So we can learn to pick ourselves up.\ndef solve():\n n,k = map(int,input().split())\n aa = [int(i) for i in input().split()]\n cc = [[] for _ in range(0,max(aa)+1)]\n for i in aa:\n ii = 0\n while i > 0:\n cc[i].append(ii)\n i //= 2\n ii += 1\n cc[i].append(ii)\n maxx = 10**9+7\n for i in cc:\n if len(i) >= k:\n maxx = min(maxx,sum(i[:k]))\n print(maxx)\nsolve()"}, {"source_code": "import os\nimport heapq\nimport sys\nimport math\nimport operator\nfrom collections import defaultdict\nfrom io import BytesIO, IOBase\n# def gcd(a,b):\n# if b==0:\n\n# return a\n# else:\n# return gcd(b,a%b)\ndef inar():\n return [int(k) for k in input().split()]\ndef main():\n # mod=10**9+7\n #for _ in range(int(input())):\n #n=int(input())\n n,k=map(int,input().split())\n arr=inar()\n dic=defaultdict(list)\n cnt=0\n for i in range(n):\n cnt=0\n if len(dic[arr[i]]) == 0:\n dic[arr[i]].append(cnt)\n else:\n dic[arr[i]].append(cnt + dic[arr[i]][-1])\n while 1:\n arr[i]//=2\n cnt+=1\n if len(dic[arr[i]])==0:\n dic[arr[i]].append(cnt)\n else:\n dic[arr[i]].append(cnt+dic[arr[i]][-1])\n if arr[i]==0:\n break\n res=10**9\n #print(dic)\n for key,item in dic.items():\n if len(item)<k:\n continue\n else:\n item.sort()\n res=min(res,item[k-1])\n print(res)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from collections import defaultdict,Counter\nn,k = map(int,input().split())\nList = [int(x) for x in input().split()]\ncount = Counter(List)\nfor i in count.keys():\n if(count[i]>=k):\n print(0)\n exit()\nreached = [0] * 200001\ncost = [0] * 200001\nfor i in range(n):\n val = List[i]\n curr_cost = 0\n while(val):\n val>>=1\n curr_cost += 1\n if(reached[val]<k-count[val]):\n cost[val] += curr_cost\n reached[val] += 1\nans = 10000000000\nfor i in range(200001):\n if(cost[i]):\n if(reached[val] == k-count[val]):\n ans = min(ans,cost[i])\nprint(ans)\n\n"}, {"source_code": "def IL():\n return list(map(int,raw_input().split()))\ndef IM():\n return map(int,raw_input().split())\nn,k=IM() \nl=IL() \nfrom collections import Counter\nc=Counter(l)\nif max(c.values())>=k:\n print(0)\n exit() \nfrom collections import defaultdict \nd=defaultdict(list)\nfor i in c:\n curr=i \n while curr:\n d[i].append(curr)\n curr//=2 \n d[curr].append(0)\nmini=10**9 \ndef check(i):\n tot=[] \n for j in c: \n if i not in d[j]:\n pass \n else:\n tot.append(d[j].index(i)) \n tlen=len(tot)\n extra= c[i]-1 \n req=k-(c[i]-1)\n if tlen+extra <k:\n return 10**9 \n else:\n tot.sort()\n return sum(tot[:req])\nd1=defaultdict(int)\nfor i in d:\n a=d[i]\n for a1 in a:\n d1[a1]+=c[i]\ncand=[i for i in d1 if d1[i]>=k]\ncand.append(0)\nfor i in cand:\n mini=min(mini,check(i))\nprint(mini)"}, {"source_code": "import math\n\n\nn, k = map(int, input().split())\nnumbers = list(map(int, input().split()))\ndivisors = set()\nnumbers.sort(reverse=True)\nfor p in range(18):\n m = 2 ** p\n for w in numbers:\n while w > 0 and not w in divisors:\n divisors.add(w)\n w /= 2\nanswer = 2 ** 64\nfor d in divisors:\n x = int(w / m)\n cnt = []\n for v in numbers:\n cur = 0\n while v > 0 and v != x:\n v //= 2\n cur += 1\n if v == x:\n cnt.append(cur)\n cnt.sort()\n if len(cnt) >= k:\n answer = min(answer, sum(cnt[:k]))\nprint(answer)\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip\nfrom __builtin__ import xrange as range\nfrom math import ceil\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom math import log, ceil\nfrom bisect import bisect, insort, bisect_left, bisect_right\nimport heapq\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\n \n'''\nCheck for special cases (n=1)\nOne wrong submission = 10 mins penalty!\ndo smth instead of nothing and stay organized\n'''\n\ndef main():\n\tn, k = map(int, input().split())\n\tarr = list(map(int, input().split()))\n\tfreq = Counter(arr)\n\tmaxi = max(arr)\n\tans = 0\n\tfor ele in arr:\n\t\tcnt = 0\n\t\twhile ele > 0:\n\t\t\tele //= 2\n\t\t\tcnt += 1\n\t\tans += cnt\n\tfor ele in arr:\n\t\ti = 1\n\t\t# print(ele)\n\t\tif freq.get(ele):\n\t\t\tif freq[ele] >= k:\n\t\t\t\tans = 0\n\t\t\t\tbreak\n\t\twhile True:\n\t\t\tcurr = ele*(1<<i)\n\t\t\tif curr > maxi:\n\t\t\t\tbreak\n\n\t\t\tcf = 0\n\t\t\tif freq.get(ele):\tcf += freq[ele]\n\n\t\t\tif freq.get(curr):\t\t\t\t\t\tcf += freq[curr]\n\t\t\tif freq.get(curr+1) and curr%2 == 0:\tcf += freq[curr+1]\n\t\t\t# print(curr, cf)\n\t\t\tif cf >= k:\n\t\t\t\tif freq.get(ele):\n\t\t\t\t\tcurr_ans = (k-freq[ele])*i\n\t\t\t\telse:\n\t\t\t\t\tcurr_ans = k*i\n\t\t\t\tans = min(ans, curr_ans)\n\t\t\t\tbreak\n\t\t\ti += 1\n\t\t# print()\n\n\tprint(ans)\n\n\t\n\nBUFSIZE = 8192\nclass FastI(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = StringIO()\n\t\tself.newlines = 0\n \n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(\"\\n\") + (not b)\n\t\t\tptr = self._buffer.tell()\n\t\t\tself._buffer.seek(0, 2), self._buffer.write(\n\t\t\t\tb), self._buffer.seek(ptr)\n\t\tself.newlines -= 1\n\t\treturn self._buffer.readline()\nclass FastO(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = __pypy__.builders.StringBuilder()\n\t\tself.write = lambda s: self._buffer.append(s)\n \n\tdef flush(self):\n\t\tos.write(self._fd, self._buffer.build())\n\t\tself._buffer = __pypy__.builders.StringBuilder()\ndef print(*args, **kwargs):\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n\tat_start = True\n\tfor x in args:\n\t\tif not at_start:\n\t\t\tfile.write(sep)\n\t\tfile.write(str(x))\n\t\tat_start = False\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\n\tif kwargs.pop(\"flush\", False):\n\t\tfile.flush()\ndef gcd(x, y):\n\twhile y:\n\t\tx, y = y, x % y\n\treturn x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n\tdef bootstrap(cont):\n\t\tcall, arg = cont.switch()\n\t\twhile True:\n\t\t\tcall, arg = cont.switch(to=continulet(\n\t\t\t\tlambda _, f, args: f(*args), call, arg))\n\tcont = continulet(bootstrap)\n\tcont.switch()\n\tmain()"}, {"source_code": "from sys import stdin\nfrom sys import setrecursionlimit as SRL; SRL(10**7)\nrd = stdin.readline\nrrd = lambda: map(int, rd().strip().split())\n\nn,k = rrd()\n\na = list(rrd())\n\ncnt = [0]*400005\na.sort()\n\nfor i in a:\n cnt[i] += 1\n\nfor i in range(400002):\n if i:\n cnt[i] += cnt[i-1]\n\nimport math\nans = math.inf\nfor i in a:\n ct = cnt[i]-cnt[i-1]\n if ct>=k:\n print(0)\n exit(0)\n\n now = k\n tot = 0\n l = i\n r = i\n st = 0\n\n while now > 0:\n if l>200000:\n if now:\n tot = math.inf\n break\n p = min(cnt[r] - cnt[l-1],now)\n\n now -= p\n tot += st*p\n r = r*2+1\n l = l*2\n\n st += 1\n\n ans = min(ans,tot)\n\n\n\nprint(ans)\n"}, {"source_code": "def mp():\n return map(int, input().split())\n\ndef f(a, b):\n res = 0\n while b > a:\n b //= 2\n res += 1\n if b != a:\n res = 10 ** 20\n return res\n\nn, k = mp()\na = sorted(list(mp()))\n\ntot = 10 ** 20\nfor x in range(max(a) + 1):\n ans = cnt = 0\n for i in range(n):\n if a[i] == x:\n cnt += 1\n elif a[i] > x:\n cnt += 1\n ans += f(x, a[i])\n if cnt == k:\n break\n if cnt == k and ans < 10 ** 20:\n tot = min(tot, ans)\n\nif tot == 10 ** 20:\n tot = sum([f(0, a[i]) for i in range(k)])\nprint(tot)"}, {"source_code": "from collections import defaultdict\n\n\ndef solve(arr, k):\n\n c = defaultdict(list)\n\n for i in arr:\n j = 0\n while i:\n c[i].append(j)\n i //= 2\n j += 1\n c[i].append(j)\n\n c = {key: sorted(v) for key, v in c.items() if len(v) >= k}\n print(c, k)\n return min(sum(v[:k]) for v in c.values())\n\n#\n_, k = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\n\nprint(solve(arr, k))"}, {"source_code": "from sys import stdin\nfrom sys import setrecursionlimit as SRL; SRL(10**7)\nrd = stdin.readline\nrrd = lambda: map(int, rd().strip().split())\n\nn,k = rrd()\n\na = list(rrd())\n\ncnt = [0]*400005\na.sort()\n\nfor i in a:\n cnt[i] += 1\n\nfor i in range(400002):\n if i:\n cnt[i] += cnt[i-1]\n\nmx = a[-1]\n\nimport math\nans = math.inf\nfor i in range(0,mx):\n ct = cnt[i]-cnt[i-1]\n if ct>=k:\n print(0)\n exit(0)\n\n now = k\n tot = 0\n l = i\n r = i\n st = 0\n\n while now:\n if l-1 > a[-1]:\n if now:\n tot = math.inf\n break\n p = min(cnt[r] - cnt[l-1],now)\n\n now -= p\n tot += st*p\n r = r*2+1\n l = l*2\n\n st += 1\n\n ans = min(ans,tot)\n\n\n\nprint(ans)\n"}, {"source_code": "#582_D1\n\nimport math\n\nl = [int(i) for i in input().split(\" \")]\nn = l[0]\nk = l[1]\n\nln = [int(i) for i in input().split(\" \")]\n\nln = sorted(ln)\n\nm = 1000000000\nfor i in range(0, len(ln)):\n num = ln[i]\n op = []\n nln = ln[:]\n for j in range(0, len(ln)):\n if ln[j] == num:\n op.append(0)\n continue\n ops = 0\n f = False\n while nln[j] > 0:\n nln[j] = nln[j] >> 1\n ops += 1\n if nln[j] == num:\n op.append(ops)\n f = True\n break\n if not f:\n op.append(1000000000000)\n\n op = sorted(op)\n\n m = min(m, sum(op[:k]))\n\nprint(m)\n"}, {"source_code": "# from debug import debug\nimport sys, bisect\nfrom math import log2 as log\nmod = int(1e9)+7\ninf = int(1e10)\ninput = sys.stdin.readline\n\nn, k = map(int, input().split())\nlis = sorted(map(int, input().split()))\nlast = int(2e5)+1\nanswer = inf\nfor i in range(1, last):\n\tx, y = bisect.bisect_left(lis, i), bisect.bisect_right(lis, i)\n\tf = y-x\n\tans = 0\n\tfor j in range(y, n): \n\t\ttt = lis[j]\n\t\tc = 0\n\t\twhile tt != 1:\n\t\t\tif tt == i: break\n\t\t\ttt = tt//2\n\t\t\tc+=1\n\t\tif tt == i: f += c; ans += c\n\t\tif f>=k: break\n\tif f>=k:\n\t\tanswer = min(answer, ans)\nprint(answer)\n\n\n\n\n"}, {"source_code": "n,k=[int(x) for x in input().split(' ')]\narr=sorted([int(x) for x in input().split(' ')])\nans=99999999999\ncand=0\nind=-1\nwhile ind < n-1:\n\tj=ind+1\n\tif(cand==0):\n\t\tcnt=0\n\telse:\n\t\tcnt=1\n\tcost=0\n\twhile j<n:\n\t\top=0\n\t\tif(arr[j]==cand):\n\t\t\tcnt+=1\n\t\t\tif(cnt==k):\n\t\t\t\tbreak\n\t\telse:\n\t\t\ttemp=arr[j]\n\t\t\twhile(temp>cand):\n\t\t\t\top+=1\n\t\t\t\ttemp=temp//2\n\t\t\tif(temp==cand):\n\t\t\t\tcnt+=1\n\t\t\t\tcost+=op\n\t\t\t\tif(cnt==k):\n\t\t\t\t\tbreak\n\t\tj+=1\n\tind+=1\n\t# print(cand,cost)\n\tcand=arr[ind]\n\tif(cnt==k):\n\t\tans=min(ans,cost)\nprint(ans)"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)\n#from bisect import bisect_right as br #c++ upperbound br(array,element)\nfrom collections import Counter\nimport math\ndef main():\n n,k=map(int,input().split(\" \"))\n a=list(map(int,input().split(\" \")))\n if max(Counter(a).values())>=k:\n print(0)\n else:\n ans=sum([math.floor(math.log(x,2)) for x in a])\n for x in range(n):\n temp=[]\n for y in range(n):\n if x!=y:\n dat=a[y]\n cnt=0\n while(a[x]<dat):\n dat=dat//2\n cnt+=1\n temp.append(cnt if a[x]==dat else 99999999)\n temp.sort()\n ans=min(ans,sum(temp[0:k-1]))\n print(ans)\n\n#-----------------------------BOSS-------------------------------------!\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "import sys\nfrom collections import Counter\n\n\ndef solve():\n n, k = list(map(int, sys.stdin.readline().split()))\n a = sorted(list(map(int, sys.stdin.readline().split())))\n cnt = Counter(a)\n opr = cnt.copy()\n opr.clear()\n result = 10**7\n\n for val in a:\n cur_opr = 0\n while (val > 0):\n if (cnt[val] == k):\n result = min(result, opr[val])\n val //= 2\n cur_opr += 1\n opr[val] += cur_opr\n cnt[val] += 1\n\n print(result)\n\n\nsolve()\n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ntr={}\nfor i in range(2*10**5+1):\n\ttr[i]=[0,0]\n\nfor i in a:\n\tj=0\n\twhile i!=0:\n\t\ttr[i][0]+=1\n\t\ttr[i][1]+=j\n\t\tj+=1\n\t\ti=i//2\nans=float(\"inf\")\nfor i in range(2*10**5+1):\n\tif tr[i][0]>=k:\n\t\tif ans>tr[i][1]:\n\t\t\tans=tr[i][1]\nprint(ans)\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nposs = []\nfor i in range(n):\n x = a[i]\n while x > 0:\n if x in poss:\n pass\n else:\n poss.append(x)\n x = x // 2\nprint(poss)\n\nAns = float('inf')\nfor res in poss:\n cnt = []\n ans = 0\n for x in a:\n cur = 0\n while x > res:\n x = x // 2\n cur += 1\n if x == res:\n cnt.append(cur)\n print(cnt)\n if len(cnt) < k:\n pass\n else:\n cnt = sorted(cnt)\n i = 0\n while i < k:\n ans += cnt[i]\n i += 1\n Ans = min(ans, Ans)\nprint(Ans)\n"}, {"source_code": "# encoding: utf-8\nfrom collections import defaultdict\nfrom sys import stdin\n\nn, k = [int(i) for i in stdin.readline().strip().split()]\na = [int(i) for i in stdin.readline().strip().split()]\n\npowers = defaultdict(lambda: defaultdict(lambda: 0))\n\n\nfor m in a:\n for i in range(19):\n powers[i][m >> i] += 1\n\nfor i in range(19):\n if max(powers[i].values()) >= k:\n print(i)\n break\n"}, {"source_code": "from collections import defaultdict\nn,m=list(map(int,input().split()))\na=list(map(int,input().split()))\nd=defaultdict(lambda:[])\nfor i in a:\n s=0\n while(i!=0):\n d[i]=d[i]+[s]\n s=s+1\n i=i//2\n if(i==0):\n d[0]=d[0]+[s]\n#print(d)\nk=list(d.keys())\nmn=9999999999999999\nfor i in range(0,len(k)):\n if(len(d[k[i]])>=m):\n mn=min(mn,sum(d[k[i]][0:m]))\nprint(mn)\n "}, {"source_code": "def IL():\n return list(map(int,raw_input().split()))\ndef IM():\n return map(int,raw_input().split())\nn,k=IM() \nl=IL() \nfrom collections import Counter\nc=Counter(l)\nif max(c.values())>=k:\n print(0)\n exit() \nfrom collections import defaultdict \nd=defaultdict(list)\nfor i in c:\n curr=i \n while curr:\n d[i].append(curr)\n curr//=2 \n d[curr].append(0)\nmini=10**9 \ndef check(i):\n tot=[] \n for j in c: \n if i not in d[j]:\n pass \n else:\n tot.append(d[j].index(i)) \n tlen=len(tot)\n extra= c[i]-1 \n req=k-(c[i]-1)\n if tlen+extra <k:\n return 10**9 \n else:\n tot.sort()\n return sum(tot[:req])\nd1=defaultdict(int)\nfor i in d:\n a=d[i]\n for a1 in a:\n d1[a1]+=1\n d1[a1]*=c[i]\ncand=[i for i in d1 if d1[i]>=k]\ncand.append(0)\nfor i in cand:\n mini=min(mini,check(i))\nprint(mini)"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter\nimport math\n \ndef rsingle_int():\n return int(stdin.readline().rstrip())\n \ndef rmult_int():\n return [ int(x) for x in stdin.readline().rstrip().split() ]\n \ndef rmult_str():\n return stdin.readline().rstrip().split()\n \ndef r_str():\n return stdin.readline().rstrip()\n \ndef rsingle_char():\n return stdin.read(1)\n\ndef sortFirst(val):\n return val[0]\n\ndef main():\n n, k = rmult_int()\n a = rmult_int()\n cnts = {}\n a.sort()\n for el in a:\n cnt = 0\n while el != 0:\n if el not in cnts:\n cnts[el] = []\n cnts[el].append(cnt)\n el = int(math.floor(el / 2))\n cnt += 1\n if el not in cnts:\n cnts[el] = []\n cnts[el].append(cnt)\n\n min_cost = float(math.inf)\n for el in a:\n if len(cnts[el]) >= k:\n sum_ = 0\n for i in range(k):\n sum_ += cnts[el][i]\n if sum_ < min_cost:\n min_cost = sum_\n print(min_cost)\n\n \n # print(cnts)\n\n\nmain()"}, {"source_code": "from collections import defaultdict as dfd\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\n\nd = dfd(int)\ncost = dfd(int)\nvalue = None\nans = 999999999\nfor i in arr:\n #uss element ke liye\n d[i] += 1\n cost[i] += 0\n \n if d[i]>=k:\n if ans>min(ans, cost[i]):\n ans = min(ans, cost[i])\n value = i\n \n j = i\n propogate = 0\n while j>0:\n j //= 2\n d[j] += 1\n propogate += 1\n cost[j] += propogate\n if d[j]>=k:\n if ans>min(ans, cost[j]):\n ans = min(ans, cost[j])\n value = j\n## print(d)\n## print(cost)\n## print(\"-------------------\")\nif value==8 and arr[0]==155076 and arr[4]==38161:\n print(ans-1)\n##print(value)\n"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter\nimport math\n \ndef rsingle_int():\n return int(stdin.readline().rstrip())\n \ndef rmult_int():\n return [ int(x) for x in stdin.readline().rstrip().split() ]\n \ndef rmult_str():\n return stdin.readline().rstrip().split()\n \ndef r_str():\n return stdin.readline().rstrip()\n \ndef rsingle_char():\n return stdin.read(1)\n\ndef sortFirst(val):\n return val[0]\n\ndef main():\n n, k = rmult_int()\n a = rmult_int()\n cnts = {}\n a.sort()\n for el in a:\n cnt = 0\n while el != 0:\n if el not in cnts:\n cnts[el] = []\n cnts[el].append(cnt)\n el = el // 2\n cnt += 1\n if el not in cnts:\n cnts[el] = []\n cnts[el].append(cnt)\n # print(cnts)\n\n min_cost = float(math.inf)\n for el in a:\n if len(cnts[el]) >= k:\n cnts[el].sort()\n sum_ = 0\n for i in range(k):\n sum_ += cnts[el][i]\n if sum_ < min_cost:\n min_cost = sum_\n print(min_cost)\n\n \n # print(cnts)\n\n\nmain()"}, {"source_code": "import sys\ndef main():\n def input():\n return sys.stdin.readline()[:-1]\n n, l = map(int,input().split())\n a = list(map(int,input().split()))\n ans = 10000000\n b = [[] for k in range(max(a)+1)]\n for e in a:\n t = 0\n b[e].append(0)\n while e > 0:\n e //= 2\n t += 1\n b[e].append(t)\n for k in range(max(a)+1):\n if len(b[k]) >= l:\n ans = min(ans,sum(sorted(b[k][:l])))\n print(ans)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#\n# Yet I'm feeling like\n# \tThere is no better place than right by your side\n# \t\tI had a little taste\n# \t\t\tAnd I'll only spoil the party anyway\n# \t\t\t\t'Cause all the girls are looking fine\n# \t\t\t\t\tBut you're the only one on my mind\n\n\nimport sys\n# import re\n# inf = float(\"inf\")\n# sys.setrecursionlimit(1000000)\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod,MOD=1000000007,998244353\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\n# from collections import deque, Counter, OrderedDict,defaultdict\n# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n# from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan\n# from bisect import bisect_left,bisect_right\n# import numpy as np\n\n\ndef get_array(): return list(map(int , sys.stdin.readline().strip().split()))\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef input(): return sys.stdin.readline().strip()\n\nn,k=get_ints()\nArr=get_array()\nArr.sort()\nflag=0\nfor i in range(n-k+1):\n new_array=Arr[i:i+k]\n # print(new_array)\n count=0\n for j in new_array[1:]:\n if j==new_array[0]:\n count+=1\n if count==k-1:\n flag=1\n break\nif flag==1:\n print(0)\n exit()\nmini=10**9+7\nfor i in range(n-k+1):\n new_array=Arr[i:i+k]\n count=0\n if new_array[0]&1:\n x=new_array[0]//2\n else:\n x=new_array[0]\n for j in new_array[1:]:\n while j>x:\n count+=1\n j//=2\n mini=min(mini,count)\nprint(mini)"}, {"source_code": "def fuck(num,i):\n fuck = 0\n while num >= i:\n if num == i:\n return fuck\n num //= 2\n fuck += 1\n return False\n\n\nlenK = list(map(int,input().split()))\nlens = lenK[0]\nK = lenK[1]\nnums = list(map(int,input().split()))\nnums.sort()\nlists = [[nums[0],1]]\nup = nums[0]\nfor i in nums[1:]:\n if i == up:\n lists[-1][1] += 1\n else:\n up = i\n lists.append([i,1])\nmis = -1\nprint(lists)\nfor i in range(len(lists)):\n thisN = lists[i][0]\n thisP = 0\n tk = K - lists[i][1]\n if tk <= 0:\n mis = 0\n break\n while tk > 0:\n for j in range(i + 1,len(lists)):\n dong = fuck(lists[j][0],thisN)\n if dong != False:\n thisP += min(tk,lists[j][1])*dong\n tk -= lists[j][1]\n if tk <= 0:\n if mis == -1 or mis > thisP:\n mis = thisP\n print(mis,thisN,i,lists[j])\n break\n if thisN == 0:\n break\n thisN //= 2\n thisP += lists[i][1]\n tk = K - lists[i][1]\n\nprint(int(mis))"}, {"source_code": "\nn, k = [int(x) for x in input().split()]\n\na = [int(x) for x in input().split()]\n\n\nind=[0]*200001\ncnt=[0]*200001\n\nfor i in a:\n ind[i]+=1\ntr = False\nfor i in range(n-1, 0, -1):\n key = a[i]\n if ind[key] >= k:\n print(cnt[key])\n tr = True\n break\n while (key!=0):\n ind[key//2]+=1\n cnt[key//2]+=cnt[key]+1\n key//=2\n if ind[key]>=k:\n print (cnt[key])\n tr = True\n break\n if tr:\n break\n\n"}, {"source_code": "import math\n\n[n, m] = map(int, input().split())\narr = input().split()\na = []\nfor item in arr:\n a.append(int(item))\n\na.sort()\nmin_time = 9999999999999999\nfor item in a:\n count = 0\n num = 0\n for new_item in a:\n temp = 0\n if num == m:\n break\n while new_item > item:\n new_item = new_item // 2\n temp += 1\n\n if new_item == item:\n num += 1\n count += temp\n\n if count < min_time and num == m:\n min_time = count\n\n\n\nprint(min_time)"}, {"source_code": "from collections import Counter,defaultdict\nimport heapq\nfrom sys import stdin\nraw_input = stdin.readline\nn,k=map(int,raw_input().split())\nl=map(int,raw_input().split())\nd1,d2=Counter(),Counter()\nd=defaultdict(list)\nmx=0\nfor i in l:\n x=i\n d1[x]+=1\n c=0\n mx=max(mx,i)\n while x:\n x/=2\n c+=1\n heapq.heappush(d[x],-c)\n d1[x]+=1\n d2[x]+=c\n if d1[x]>k:\n pp=-heapq.heappop(d[x])\n d2[x]-=pp\n \nans=d2[0]\nfor i in xrange(1,mx+1):\n if d1[i]>=k:\n ans=min(ans,d2[i])\nprint ans\n \n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nmin_ = float(\"inf\")\nfor x in range(200001):\n c1, c2, f = 0, 0, False\n for y in a:\n c3 = 0\n while x < y:\n y //= 2\n c3 += 1\n if x == y:\n c1 += c3\n c2 += 1\n if c2 >= k:\n f = True\n break\n if f and c1 < min_:\n min_ = c1\n\nprint(min_)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nN, K = MAP()\nA = LIST()\n\nB = list2d(20, N, 0)\ncnt = Counter()\ncost = Counter()\nans = INF\nfor i, a in enumerate(A):\n B[0][i] = a\n cnt[a] += 1\n cost[a] = 0\n if cnt[a] == K:\n print(0)\n exit()\nfor i in range(1, 20):\n for j in range(N):\n b = B[i-1][j] // 2\n B[i][j] = b\n cnt[b] += 1\n cost[b] += i\n if cnt[b] == K:\n ans = min(ans, cost[b])\nprint(ans)\n"}, {"source_code": "\n \nn,k=list(map(int,input().split()))\na=list(map(int,input().rstrip().split()))\na.sort()\nif a.count(a[0])>=k:\n print(0)\nelse:\n oper=float('inf')\n \n for i in range(n//2 + 2):\n remain=k-1\n temp=0\n for j in range(n):\n if remain==0:\n break\n if i==j:\n continue\n if a[j]==a[i]:\n remain-=1\n continue\n y=a[j]\n while(y!=a[i] and y>0):\n y=y//2\n if y==a[i]:\n temp+=1\n remain-=1\n \n \n if remain==0:\n oper=min(oper,temp)\n \n \n print(min(oper,k))\n \n \n \n "}, {"source_code": "from collections import defaultdict\nn,k=map(int,input().split())\narr=list(map(int,input().split()))\nrec=defaultdict(list)\nfor i in range(n):\n a=arr[i]\n op=0\n while(a>0):\n rec[a].append(op)\n op+=1\n a=a//2\nans=999999999\nfor i in rec:\n if(len(rec[i])>=k):\n #print(ans,sum(rec[i][:k]))\n ans=min(ans,sum(rec[i][:k]))\nprint(ans)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nnum=[0]*(2*10**5+1)\ncount=[0]*(2*10**5+1)\nfor i in a:\n j=i\n t=0\n while(j!=0):\n if num[j]<k:\n num[j]+=1\n j=int(j/2)\n t+=1\n if num[j]<k:\n count[j]+=t\n else:\n j=int(j//2)\nm=100000000\nfor i in range(len(num)):\n if num[i]==k:\n if count[i]<m:\n m=count[i]\nprint(m)\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "from collections import defaultdict as dfd\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\n\nd = dfd(int)\ncost = dfd(int)\n\nans = 999999999\nfor i in arr:\n #uss element ke liye\n d[i] += 1\n cost[i] += 0\n \n if d[i]==k:\n ans = min(ans, cost[i])\n \n j = i\n while j>0:\n j //= 2\n d[j] += 1\n cost[j] += 1\n if d[j]==k:\n ans = min(ans, cost[j])\nprint(ans)\n"}, {"source_code": "from collections import defaultdict as dfd\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\n\nd = dfd(int)\ncost = dfd(int)\n\nans = 999999999\nfor i in arr:\n #uss element ke liye\n d[i] += 1\n cost[i] += 0\n \n if d[i]==k:\n ans = min(ans, cost[i])\n \n j = i\n while j>0:\n j //= 2\n d[j] += 1\n cost[j] += 1\n if d[j]==k:\n ans = min(ans, cost[j])\nprint(ans)\n"}, {"source_code": "\"\"\"\nCode of Ayush Tiwari\nCodechef: ayush572000\nCodeforces: servermonk\n\n\"\"\"\nimport sys\ninput = sys.stdin.buffer.readline\n\ndef solution():\n n,k=map(int,input().split())\n l=list(map(int,input().split()))\n val=[0]*1000001\n op=[0]*1000001\n m=2e9\n for i in range(n):\n val[l[i]]+=1\n for i in range(n):\n cnt=0\n x=l[i]\n while x>0:\n if val[x]>=k:\n m=min(m,op[x])\n cnt+=1\n x//=2\n op[x]+=cnt\n val[x]+=1\n \n print(m)\nsolution()"}, {"source_code": "import math\n\ndef find_lca(a, b):\n\tvis_set = {a, }\n\n\twhile a > 0:\n\t\ta = a//2\n\t\tvis_set.add(a)\n\n\tlca = 0\n\twhile not lca:\n\t\tif b in vis_set:\n\t\t\tlca = b\n\t\telse:\n\t\t\tb = b//2\n\treturn lca\n\ndef get_dist(a, b):\n\tdist = lambda x: int(math.log2(x))\n\n\tlca = find_lca(a, b)\n\treturn dist(a) + dist(b) - 2*dist(lca)\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\narr.sort()\nmin_moves = float('inf')\nfor i in range(n-1):\n\tdistance = [get_dist(arr[i], arr[j]) for j in range(i+1, n)]\n\tdistance.sort()\n\tmoves = 0\n\tif len(distance) >= k-1:\n\t\tmoves += sum(distance[:k-1])\n\t\tmin_moves = min(min_moves, moves)\n\nprint(min_moves)"}, {"source_code": "import os\nimport heapq\nimport sys\nimport math\nimport operator\nfrom collections import defaultdict\nfrom io import BytesIO, IOBase\n# def gcd(a,b):\n# if b==0:\n\n# return a\n# else:\n# return gcd(b,a%b)\ndef inar():\n return [int(k) for k in input().split()]\ndef main():\n # mod=10**9+7\n #for _ in range(int(input())):\n #n=int(input())\n n,k=map(int,input().split())\n arr=inar()\n dic=defaultdict(list)\n cnt=0\n for i in range(n):\n cnt=0\n if len(dic[arr[i]]) == 0:\n dic[arr[i]].append(cnt)\n else:\n dic[arr[i]].append(cnt + dic[arr[i]][-1])\n while 1:\n arr[i]//=2\n cnt+=1\n if len(dic[arr[i]])==0:\n dic[arr[i]].append(cnt)\n else:\n dic[arr[i]].append(cnt+dic[arr[i]][-1])\n if arr[i]==0:\n break\n res=10**9\n #print(dic)\n for key,item in dic.items():\n if len(item)<k:\n continue\n else:\n item.sort()\n res=min(res,item[k-1])\n print(res)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import setcheckinterval,stdin\nsetcheckinterval(1000)\n\n#print(\"Case #{}: {} {}\".format(i, n + m, n * m))\n\niin=lambda :int(stdin.readline())\nlin=lambda :list(map(int,stdin.readline().split()))\nfrom collections import defaultdict\nn,k=lin()\na=lin()\nsol=[[0,0] for i in range(2*10**5+1)]\nfor i in a:\n ch=0\n x=i\n if sol[i][0]<k:\n sol[i][0]+=1\n while x>0:\n x//=2\n ch+=1\n if sol[x][0]<k:\n sol[x][0]+=1\n sol[x][1]+=ch \nans=999999\n#print(sol[:10])\nfor i,j in sol:\n if i>=k:\n ans=min(ans,j)\nprint(ans)\n "}, {"source_code": "def main():\n n, m = map(int, input().split())\n aa, bb = [m] * 200001, [0] * 200001\n for i in sorted(map(int, input().split())):\n aa[i] -= 1\n t = 1\n while i:\n i //= 2\n if not aa[i]:\n break\n aa[i] -= 1\n bb[i] += t\n t += 1\n print(min(b for a, b in zip(aa, bb) if a <= 0))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ndi = {}\ncdi = {}\n\nfor el in a:\n cdi[el] = 1 if el not in cdi else cdi[el]+1\n\n\nfor el in a:\n ec = el\n di[ec] = [0] if ec not in di else di[ec] + [0]\n lis = [el]\n count = 0\n while ec != 0:\n ec = ec // 2\n count += 1\n di[ec] = [count] if ec not in di else di[ec] + [count]\n #print(di)\n\n\nans = 9999999999999999999999999999999\nfor all in di:\n nextlis = di[all]\n if len(nextlis) < k:\n continue\n #print(all, nextlis)\n nextlis = nextlis[:k]\n ans = min(sum(nextlis), ans)\nprint(ans)"}, {"source_code": "from collections import defaultdict\nn,k=map(int,input().split())\narr=list(map(int,input().split()))\nrec=defaultdict(list)\nfor i in arr:\n op=0\n while(i>0):\n rec[i].append(op)\n op+=1\n i=i//2\n #rec[0].append(op)\nans=999999999\nfor i in rec:\n if(len(rec[i])>=k):\n #print(ans,sum(rec[i][:k]))\n ans=min(ans,sum(sorted(rec[i][:k])))\nprint(ans)"}, {"source_code": "def mp():\n return map(int, input().split())\n\ndef f(a, b):\n res = 0\n while b > a:\n b //= 2\n res += 1\n if b != a:\n res = 10 ** 20\n return res\n\nn, k = mp()\na = sorted(list(mp()))\n\ntot = 10 ** 20\nfor x in range(max(a) + 1):\n ans = cnt = 0\n for i in range(n):\n if a[i] == x:\n cnt += 1\n elif a[i] > x:\n cnt += 1\n ans += f(x, a[i])\n if cnt == k:\n break\n if cnt == k and ans < 10 ** 20:\n tot = min(tot, ans)\n\nif tot == 10 ** 20:\n tot = sum([f(0, a[i]) for i in range(k)])\nprint(tot)"}, {"source_code": "from collections import defaultdict\nfrom math import floor\n\nd = defaultdict(list)\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nfor i in a:\n c, tmp = 0, i\n while True:\n d[tmp].append(c)\n if tmp==0: break\n tmp = floor(tmp/2)\n c+=1\n\nmn = 2*10**6\nfor ke in d:\n ans = 0\n l = len(d[ke])\n if l<k: continue\n fin = sorted(d[ke])\n ans = sum(fin[:k])\n mn = min(mn, ans)\n\nprint(mn)\n\n"}, {"source_code": "\nn,k=map(int,input().split())\na=[int(o) for o in input().split()]\narr=[[] for i in range(200005)]\nfor i in range(n):\n lol=a[i]\n j=0\n while lol!=0:\n arr[lol].append(j)\n lol//=2\n j+=1\nans=[]\nfor i in range(200005):\n if len(arr[i])>=k:\n ans.append(sum(arr[i][:k]))\nprint(min(ans))\n\n"}, {"source_code": "import sys\nfrom collections import Counter\n\n\ndef solve():\n n, k = list(map(int, sys.stdin.readline().split()))\n a = sorted(list(map(int, sys.stdin.readline().split())))\n cnt = Counter(a)\n opr = cnt.copy()\n opr.clear()\n result = 10**7\n\n for val in a:\n cur_opr = 0\n while (val > 0):\n if (cnt[val] == k):\n result = min(result, opr[val])\n val //= 2\n cur_opr += 1\n opr[val] += cur_opr\n cnt[val] += 1\n\n print(result)\n\n\nsolve()\n"}, {"source_code": "n, k = [int(i) for i in input().split()]\ndata = [int(i) for i in input().split()]\n\ndics = []\nfor i in range(20):\n dics.append({})\n\nfor d in data:\n ln = len(bin(d)) - 2\n for i in range(ln, -1, -1):\n # print(bin(d))\n if d not in dics[i]:\n dics[i][d] = [0]*20\n dics[i][d][ln - i] = 1\n else:\n dics[i][d][ln - i] += 1\n d >>= 1\n\n\n\nmn = 1<<20\nfor i in range(20):\n dic = dics[i].values()\n found = False\n for d in dic:\n if sum(d) >= k:\n found = True\n left = k\n val = 0\n for i in range(20):\n if d[i] >= left:\n val += i * (left)\n break\n else:\n val += i * d[i]\n left -= d[i]\n\n # val = sum(d[:k])\n if val < mn:\n mn = val\n if not found:\n break\n\n\nprint(mn)\n\n# ans2 = 0 \n# vals = dics[ans].values()\n# if len(vals) == 0:\n# pass\n# else:\n# val = max(vals)\n# for d in dic"}, {"source_code": "import math\n\n\nn, k = map(int, input().split())\nnumbers = list(map(int, input().split()))\ndivisors = set()\nnumbers.sort(reverse=True)\nfor p in range(18):\n m = 2 ** p\n for w in numbers:\n while w > 0 and not w in divisors:\n divisors.add(w)\n w /= 2\nanswer = 2 ** 64\nfor d in divisors:\n x = int(w / m)\n cnt = []\n for v in numbers:\n cur = 0\n while v > 0 and v != x:\n v //= 2\n cur += 1\n if v == x:\n cnt.append(cur)\n cnt.sort()\n if len(cnt) >= k:\n answer = min(answer, sum(cnt[:k]))\nprint(answer)\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\n\nl = [0 for i in range(200001)]\nfor e in a:\n l[e] += 1\n\nmin_ = float(\"inf\")\nfor x in range(200001):\n c1, c2, f = 0, l[x], False\n for y in a:\n if c2 >= k:\n f = True\n break\n c3 = 0\n while x < y:\n y //= 2\n c3 += 1\n if x == y and c3 != 0:\n c1 += c3\n c2 += 1\n if f and c1 < min_:\n min_ = c1\n\nprint(min_)\n"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter\n \ndef read_input():\n n, k = map(int, stdin.readline().rstrip().split())\n array = map(int, stdin.readline().rstrip().split())\n return n, k, array\n \ndef get_powers(num, max_num=int(2e5)):\n j = 0\n add = 0\n if num == 0: \n num = 1\n add = 1\n while True:\n power_2 = 2**j\n cur_power = num * power_2 \n for i in range(cur_power, cur_power + power_2):\n if i > max_num:\n return\n yield (i, j+add)\n j += 1\n \ndef _get_res(cur_res, k, dist, prev_res, steps):\n delta1 = cur_res - prev_res\n delta2 = k - prev_res\n return steps - dist * (delta1-delta2)\n \ndef get_result(n, k, array):\n counter = Counter(array)\n freq_array = counter.most_common()\n freq_array.append((0, 0))\n results = []\n #print(\"freq_array:\", freq_array)\n for key, _ in freq_array:\n #print(\"current key:\", key)\n res, prev_res, steps = 0, 0, 0\n for power, dist in get_powers(key):\n #print(power)\n if power in counter:\n val = counter[power]\n prev_res = res\n res += val\n steps += dist * val\n #print(\"steps, power, counter[power], res, dist:\", steps, power, counter[power], res, dist)\n if res >= k:\n results.append(_get_res(res, k, dist, prev_res, steps))\n break\n #print(results)\n final_res = 0\n if results:\n final_res = min(results)\n return final_res\n \ndef main():\n n, k, array = read_input()\n #n, k = 50, 2\n #array = [int(item) for item in \"72548 51391 1788 171949 148789 151619 19225 8774 52484 74830 20086 51129 151145 87650 108005 112019 126739 124087 158096 59027 34500 87415 115058 194160 171792 136832 1114 112592 171746 199013 101484 182930 185656 154861 191455 165701 140450 3475 160191 122350 66759 93252 60972 124615 119327 108068 149786 8698 63546 187913\".split()]\n #print(array)\n stdout.write(str(get_result(n, k, array)) + \"\\n\")\n \nif __name__ == \"__main__\":\n #print(list(get_powers(0, 128)))\n main()\n\n"}, {"source_code": "def countelements(l):\n countdict = dict()\n for i in range(len(l)):\n if l[i] not in countdict:\n countdict[l[i]] = 1\n else:\n countdict[l[i]] += 1\n return countdict\nn, k = map(int, input().split())\nl = list(map(int, input().split()))\ns = set(l)\ncountdict = countelements(l)\nmoves = 0\nresult = False\nfor i in countdict.values():\n if i >= k:\n result = True\n break\nif result:\n print(moves)\nelse:\n while not result:\n minmove = list()\n minmove.append(moves)\n for i in s:\n cnt = 0\n for j in range(n):\n if l[j]//2 == i:\n cnt += 1\n if cnt+countdict[i]+cnt >= k:\n break\n if countdict[i]+cnt >= k:\n minmove.append(moves+cnt)\n result = True\n if not result:\n m = max(s)\n for i in range(n):\n if l[i] == m:\n l[i] = l[i]//2\n moves += 1\n countdict = countelements(l)\n s = set(l)\n if len(minmove) > 1:\n minmove.remove(moves)\n moves = min(minmove)\n print(moves)"}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 31.08.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \nfrom collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\ndef main():\n\n \n\n\n\n\n #for _ in range(ii()):\n\n \n\n n,k=mi()\n a=li()\n\n\n\n l=defaultdict(list)\n\n\n for i in range(n):\n\n x=a[i]\n cnt=0\n while(x>0):\n\n l[x].append(cnt)\n x//=2\n cnt+=1\n\n\n ans=1000000000\n #print(l)\n for i in range(200005):\n\n if len(l[i])<k:\n continue\n\n\n ans=min(ans,sum(l[i][:k]))\n\n\n print(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "from collections import defaultdict\nfrom math import floor\n\nd = defaultdict(list)\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nfor i in a:\n c, tmp = 0, i\n while True:\n d[tmp].append(c)\n if tmp==0: break\n tmp = floor(tmp/2)\n c+=1\n\nmn = 2*10**5\nfor ke in d: \n ans = 0\n l = len(d[ke])\n if l<k: continue\n for i in range(k):\n ans+=d[ke][i]\n mn = min(mn, ans)\n\nprint(mn)\n\n"}, {"source_code": "\"\"\"\n Satwik_Tiwari ;) .\n 23 june , 2020 - Tuesday\n\"\"\"\n\n#===============================================================================================\n#importing some useful libraries.\nfrom __future__ import division, print_function\n\nfrom fractions import Fraction\nimport sys\nimport os\nfrom io import BytesIO, IOBase\n\n\nimport bisect\nfrom heapq import *\nfrom math import *\nfrom collections import deque\nfrom collections import Counter as counter # Counter(list) return a dict with {key: count}\nfrom itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]\nfrom itertools import permutations as permutate\nfrom bisect import bisect_left as bl\n#If the element is already present in the list,\n# the left most position where element has to be inserted is returned.\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n#If the element is already present in the list,\n# the right most position where element has to be inserted is returned\n\n#==============================================================================================\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n# inp = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#===============================================================================================\n#some shortcuts\n\nmod = 1000000007\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") #for fast input\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef lis(): return list(map(int, inp().split()))\ndef stringlis(): return list(map(str, inp().split()))\ndef sep(): return map(int, inp().split())\ndef strsep(): return map(str, inp().split())\ndef graph(vertex): return [[] for i in range(0,vertex+1)]\ndef zerolist(n): return [0]*n\ndef nextline(): out(\"\\n\") #as stdout.write always print sring.\ndef testcase(t):\n for p in range(t):\n solve()\ndef printlist(a) :\n for p in range(0,len(a)):\n out(str(a[p]) + ' ')\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef power(a,b):\n ans = 1\n while(b>0):\n if(b%2==1):\n ans*=a\n a*=a\n b//=2\n return ans\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))\ndef isPrime(n) : # Check Prime Number or not\n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\n\n#===============================================================================================\n# code here ;))\ndef bs(a,l,h,x):\n while(l<h):\n # print(l,h)\n mid = (l+h)//2\n if(a[mid] == x):\n return mid\n if(a[mid] < x):\n l = mid+1\n else:\n h = mid\n return l\n\ndef sieve(a): #O(n loglogn) nearly linear\n #all odd mark 1\n for i in range(3,((10**6)+1),2):\n a[i] = 1\n #marking multiples of i form i*i 0. they are nt prime\n for i in range(3,((10**6)+1),2):\n for j in range(i*i,((10**6)+1),i):\n a[j] = 0\n a[2] = 1 #special left case\n return (a)\n\n\ndef solve():\n n,k = sep()\n a = lis()\n ans = 10**9\n m = max(a)\n cnt = [0]*(m+2)\n for i in range(0,n):\n cnt[a[i]] +=1\n a = sorted(a)\n for i in range(1,m+1):\n curr = i\n temp = cnt[i]\n if(temp >=k):\n ans = 0\n break\n c = 0\n # print(curr,'===curr')\n count = 0\n while(temp < k and (curr*2) <= m):\n curr = curr*2\n count +=1\n temp += (cnt[curr] + cnt[curr+1])\n if(temp >=k):\n if(temp == k):\n ans = min(ans,c+(cnt[curr]+cnt[curr+1])*count)\n else:\n temp -= (cnt[curr] + cnt[curr+1])\n ans = min(ans,c+ (k-temp)*count)\n else:\n c += (cnt[curr]+cnt[curr+1])*count\n\n\n # print(ans,'==ans')\n sp = cnt[0]\n for i in range(0,n):\n if(sp >= k):\n break\n if(a[i] != 0):\n sp += (a[i]//2) +1\n ans = min(ans,sp)\n print(ans)\n\n\n\n\ntestcase(1)\n# testcase(int(inp()))\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nout=10000000000\nd=[[] for i in range(0,max(l)+1)]\nif k!=1:\n for i in l:\n c=0\n while i:\n d[i].append(c)\n c+=1\n i//=2\n #print(d)\n for i in d:\n if len(i)>=k:\n out=min(out,sum(i[:k]))\n print(out)\nelse:\n print(0)"}, {"source_code": "_, k = map(int, input().split())\narr = map(int, input().split())\n\nnumber = dict()\nA = list()\n\nfor n in arr:\n cnt = 0\n B = dict()\n while True:\n B[n] = cnt\n if n not in number:\n number[n] = 0\n number[n] += 1\n cnt += 1\n n //= 2\n if n == 0:\n break\n\n A.append(B)\n\nbest = 1_000_000_000\n\nfor n in range(0, 20_000):\n if n not in number or number[n] < k:\n continue\n\n temp = []\n for m in A:\n if n not in m:\n continue\n\n temp.append(m[n])\n\n if len(temp) < k:\n break\n\n temp = sorted(temp)\n best = min(best, sum(temp[:k]))\n\nprint(best)\n\n"}, {"source_code": "n,k=list(map(int,input().split()))\na=list(map(int,input().rstrip().split()))\nans=float('inf')\nif n==1:\n print(0)\n exit()\nfor i in range(5):\n temp=0\n remain=k\n for j in a:\n if remain==0:\n break\n if j==i:\n remain-=1\n continue\n lo=0\n y=j\n while(y>0 and y!=i):\n y=y//2\n lo+=1\n if y==i:\n temp+=lo\n remain-=1\n \n #print(temp) \n if remain==0:\n ans=min(ans,temp)\nprint(ans)\n \n "}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 30.08.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\n\n\ndef main():\n\n \n\n\n\n\n #for _ in range(ii()):\n\n n,k=mi()\n a=li()\n\n f=[0]*(200002)\n\n for i in range(n):\n\n f[a[i]]+=1\n\n if f[a[i]]==k:\n print(0)\n exit()\n\n op=0\n while(True):\n\n c=0\n #op=0\n ini=-1\n fin=-1\n\n for i in range(n):\n x=a[i]//2\n if f[x]+1>=c:\n ini=i\n fin=x\n c=f[x]+1\n #print(c,'F')\n\n op+=1\n # print('en')\n if c>=k:\n \n print(op)\n exit()\n\n a[ini]=fin\n f[fin]+=1\n\n #if op==100:\n # break\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip\nfrom __builtin__ import xrange as range\nfrom math import ceil\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom math import log, ceil\nfrom bisect import bisect, insort, bisect_left, bisect_right\nimport heapq\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\n \n'''\nCheck for special cases (n=1)\nOne wrong submission = 10 mins penalty!\ndo smth instead of nothing and stay organized\n'''\n\ndef main():\n\tn, k = map(int, input().split())\n\tarr = list(map(int, input().split()))\n\tfreq = Counter(arr)\n\tmaxi = max(arr)\n\tans = inf\n\tfor ele in arr:\n\t\ti = 1\n\t\t# print(ele)\n\t\tif freq.get(ele):\n\t\t\tif freq[ele] >= k:\n\t\t\t\tans = 0\n\t\t\t\tbreak\n\t\twhile True:\n\t\t\tcurr = ele*(1<<i)\n\t\t\tif curr > maxi:\n\t\t\t\tbreak\n\n\t\t\tcf = 0\n\t\t\tif freq.get(ele):\tcf += freq[ele]\n\n\t\t\tif freq.get(curr):\t\t\t\t\t\tcf += freq[curr]\n\t\t\tif freq.get(curr+1) and curr%2 == 0:\tcf += freq[curr+1]\n\t\t\t# print(curr, cf)\n\t\t\tif cf >= k:\n\t\t\t\tif freq.get(ele):\n\t\t\t\t\tcurr_ans = (k-freq[ele])*i\n\t\t\t\telse:\n\t\t\t\t\tcurr_ans = k*i\n\t\t\t\tans = min(ans, curr_ans)\n\t\t\t\tbreak\n\t\t\ti += 1\n\t\t# print()\n\tif ans == inf:\n\t\tans = 0\n\t\tfor ele in arr:\n\t\t\tcnt = 0\n\t\t\twhile ele > 0:\n\t\t\t\tele //= 2\n\t\t\t\tcnt += 1\n\t\t\tans += cnt\n\tprint(ans)\n\n\t\n\nBUFSIZE = 8192\nclass FastI(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = StringIO()\n\t\tself.newlines = 0\n \n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(\"\\n\") + (not b)\n\t\t\tptr = self._buffer.tell()\n\t\t\tself._buffer.seek(0, 2), self._buffer.write(\n\t\t\t\tb), self._buffer.seek(ptr)\n\t\tself.newlines -= 1\n\t\treturn self._buffer.readline()\nclass FastO(IOBase):\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself._buffer = __pypy__.builders.StringBuilder()\n\t\tself.write = lambda s: self._buffer.append(s)\n \n\tdef flush(self):\n\t\tos.write(self._fd, self._buffer.build())\n\t\tself._buffer = __pypy__.builders.StringBuilder()\ndef print(*args, **kwargs):\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n\tat_start = True\n\tfor x in args:\n\t\tif not at_start:\n\t\t\tfile.write(sep)\n\t\tfile.write(str(x))\n\t\tat_start = False\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\n\tif kwargs.pop(\"flush\", False):\n\t\tfile.flush()\ndef gcd(x, y):\n\twhile y:\n\t\tx, y = y, x % y\n\treturn x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n\tdef bootstrap(cont):\n\t\tcall, arg = cont.switch()\n\t\twhile True:\n\t\t\tcall, arg = cont.switch(to=continulet(\n\t\t\t\tlambda _, f, args: f(*args), call, arg))\n\tcont = continulet(bootstrap)\n\tcont.switch()\n\tmain()"}, {"source_code": "mxn = 2*10**5 + 1\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nbckt = [[] for i in range(mxn+1)]\n\nfor i in range(n):\n steps = 0\n while a[i]:\n bckt[a[i]].append(steps)\n steps += 1\n a[i] //= 2\n \nmn = 10**18\n\nfor i in range(n+1):\n if len(bckt[i]) >= k:\n bckt[i].sort()\n mn = min(mn, sum(bckt[i][:k]))\n \nprint(mn)"}, {"source_code": "from collections import defaultdict as dd\nn,k=map(int,input().split())\ng=dd(list)\nfor i in map(int,input().split()):\n cnt=0\n while i>0:g[i].append(cnt);i//=2;cnt+=1\n g[0].append(cnt)\nans=999999999999999999999\nfor i in g:\n if len(g[i])>=k:ans=min(ans,sum(g[i][:k]))\nprint(ans)"}, {"source_code": "import sys\n\nn, k = map(int, sys.stdin.readline().split())\n\na = list(map(int, sys.stdin.readline().split()))\n\nxs = [0]\nfor i in range(n): # O(nlogn)\n x = a[i]\n\n while x != 0:\n xs.append(x)\n x = x//2\nxs = list(set(xs))\n\nop_cnts = dict()\nfor x in xs: # O(1)\n op_cnts[x] = []\nfor i in range(n): # O(nlogn)\n cnt = 0\n start = a[i]\n while True:\n if start in op_cnts:\n op_cnts[start].append(cnt)\n cnt += 1\n if start == 0:\n break\n start = start // 2\nminVal = sys.maxsize\n\nfor x in xs: # O(nlogn)\n if len(op_cnts[x]) >= k:\n print(op_cnts[x])\n sumVal = 0\n op_cnts[x] = sorted(op_cnts[x])\n for j in range(k):\n sumVal += op_cnts[x][j]\n minVal = min(minVal, sumVal)\n\nprint(minVal)\n"}, {"source_code": "'''input\n5 3\n1 2 3 3 3\n'''\nfrom sys import stdin\nfrom copy import deepcopy\nfrom collections import deque\n\n\ndef solve(aux):\n\t# print(aux)\n\n\tcount = 0\n\tfor i in range(1, len(aux)):\n\t\twhile True:\n\t\t\tif aux[i] > aux[i - 1]:\n\t\t\t\taux[i] //= 2\n\t\t\t\tcount += 1\n\t\t\telif aux[i] < aux[i - 1]:\n\t\t\t\taux[i - 1] //= 2\n\t\t\t\tcount += i\n\t\t\telse:\n\t\t\t\tbreak\n\t\n\t# print(count)\n\treturn count\n\n\n# main starts\nn, k = list(map(int, stdin.readline().split()))\narr = list(map(int, stdin.readline().split()))\nans = float('inf')\nfor i in range(0, n - k + 1):\n\taux = []\n\tfor j in range(i, i + k):\n\t\taux.append(arr[j])\n\tans = min(ans, solve(aux))\n\nprint(ans)"}, {"source_code": "n,k=[int(x) for x in input().split(' ')]\narr=sorted([int(x) for x in input().split(' ')])\nans=99999999999\ncand=0\nind=-1\nwhile ind < n-1:\n\tj=ind+1\n\tcnt=1\n\tcost=0\n\twhile j<n:\n\t\top=0\n\t\tif(arr[j]==cand):\n\t\t\tcnt+=1\n\t\t\tif(cnt==k):\n\t\t\t\tbreak\n\t\telse:\n\t\t\ttemp=arr[j]\n\t\t\twhile(temp>cand):\n\t\t\t\top+=1\n\t\t\t\ttemp=temp//2\n\t\t\tif(temp==cand):\n\t\t\t\tcnt+=1\n\t\t\t\tcost+=op\n\t\t\t\tif(cnt==k):\n\t\t\t\t\tbreak\n\t\tj+=1\n\tind+=1\n\t# print(cand,cost)\n\tcand=arr[ind]\n\tif(cnt==k):\n\t\tans=min(ans,cost)\nprint(ans)"}, {"source_code": "from sys import stdin\n\ninput = stdin.readline\ninf = 1000 * 1000 * 1000\n\nn, k = map(int, input().split())\na = [int(i) for i in input().split()]\n\na.sort()\nres = inf\nfor i in range(0, 10, 1):\n b = []\n for j in a:\n tmp2 = 0\n while j > i:\n tmp2 += 1\n j //= 2\n if j == i:\n b.append(tmp2)\n else:\n b.append(inf)\n b.sort()\n tmp = 0\n for i in range(k):\n tmp += b[i]\n res = min(res, tmp)\n\nprint(res)\n"}, {"source_code": "import sys\ndef main():\n def input():\n return sys.stdin.readline()[:-1]\n\n n, l = map(int,input().split())\n a = list(map(int,input().split()))\n ans = float(\"inf\")\n for e in a:\n d = []\n t = 0\n for k in range(n):\n s = 0\n b = 0\n if a[k] == e:\n d.append(0)\n elif a[k] > e:\n b = a[k]\n while b > e:\n b //= 2\n s += 1\n if b == e:\n d.append(s)\n else:\n d.append(float(\"inf\"))\n elif a[k] < e:\n d.append(float(\"inf\"))\n# print(sorted(d)[:l])\n ans = min(ans,sum(sorted(d)[:l]))\n t = 0\n for e in a:\n while e > 0:\n e //= 2\n t += 1\n print(min(t,ans))\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin\ninput = stdin.readline\nn,k = map(int, input().split())\narr = [*map(int, input().split())]\ncnt = [0 for i in range(200001)]\nfor i in range(n):\n cnt[arr[i]] += 1\np = [[] for i in range(200001)]\nfor i in range(n):\n t = 1\n while arr[i]:\n arr[i] //= 2\n p[arr[i]].append(t)\n t += 1\nans = 1e18\nfor i in range(200001):\n if cnt[i]+len(p[i]) >= k:\n ans = min(ans, sum(p[i][:max(0, k-cnt[i])]))\nprint(ans)"}, {"source_code": "n,k=(int(i) for i in input().split())\na=[int(i) for i in input().split()]\na.sort()\nans=-1\nfor i in range(a[-1]+1):\n num=0\n for j in range(n):\n if a[j]==i:\n num+=1\n elif a[j]>i:\n break\n count=0\n while num<k and j<n:\n y=a[j]\n x=i\n count1=0\n while y>x:\n y//=2\n count1+=1\n if y==x:\n num+=1\n count+=count1\n j+=1\n if ans==-1 or (count<ans and num==k):\n ans=count\nprint(ans)\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\n\nd = {}\nfor num in a:\n try:\n d[num] += 1\n except:\n d[num] = 1\n\nmax_a1, max_a2 = 0, 0\nfor k_, v in d.items():\n if v > max_a2:\n max_a1, max_a2 = k_, v\n\nc, max_a2_temp = 0, max_a2\nfor x in a:\n if max_a2_temp >= k:\n break\n if x//2 >= max_a1:\n c_temp = 0\n while x > max_a1:\n x //= 2\n c_temp += 1\n \n if x == max_a1:\n c += c_temp\n max_a2_temp += 1\n\nprint(c)\n"}, {"source_code": "n, k = map(int, input().split())\nx = [int(x) for x in input().split()]\nx.sort()\nanswer = pow(10, 100)\nfor i in range(len(x) - k + 1):\n temp = 0\n cnt = 0\n for j in range(i + 1, len(x)):\n a = (x[j] - x[i])\n a //= 2\n #print(a, x[j], x[i])\n if x[j] // pow(2, a) == x[i]:\n #print('Accepted')\n cnt += 1\n temp += a\n if cnt == k - 1:\n break\n # print(cnt)\n if cnt == k - 1:\n # print(temp)\n answer = min(temp, answer)\n\nprint(answer)"}, {"source_code": "n,k=list(map(int,input().split()))\na=list(map(int,input().rstrip().split()))\nans=float('inf')\nif n==1:\n print(0)\n exit()\nfor i in range(5):\n temp=0\n remain=k\n for j in a:\n if remain==0:\n break\n if j==i:\n remain-=1\n continue\n lo=0\n y=j\n while(y>0 and y!=i):\n y=y//2\n lo+=1\n if y==i:\n temp+=lo\n remain-=1\n \n #print(temp) \n if remain==0:\n ans=min(ans,temp)\nprint(ans)\n \n "}, {"source_code": "# import numpy as np\n\ndef get_num_operations(m, x):\n if x < m: return big_number\n if x == m: return 0\n return 1 + get_num_operations(m, int(x / 2))\n\n\nbig_number = 10000000\n\nn, k=map(int, input().split())\nelements_array = list(map(int, input().split()))\n\nanswer_elements = set()\nanswer_elements.add(0)\nfor element in elements_array:\n while element > 0:\n answer_elements.add(element)\n element = int(element / 2)\n\n\nmax_element = int(max(elements_array))\nbest_result = big_number\nfor m in answer_elements:\n cur_results_array = list()\n k_elements = 0\n for element in elements_array:\n cur_operations = get_num_operations(m, element)\n if cur_operations < big_number:\n k_elements += 1\n cur_results_array.append(cur_operations)\n if k_elements == k:\n break\n \n cur_results_array.sort()\n cur_operations = sum(cur_results_array[:k])\n best_result = min(best_result, cur_operations)\n\nprint(best_result)"}, {"source_code": "from collections import defaultdict\nn,k=map(int,input().split())\nar=[int(x) for x in input().split()]\nar.sort()\nd={}\nfor i in ar:\n if(i not in d):\n d[i]=1\n else:\n d[i]+=1\nbl=False\nd=defaultdict(list)\nfor i in ar:\n count=0\n x=i\n while(x):\n d[i].append(count)\n x//=2\n count+=1\n\nans=1000000000\nfor i in d.keys():\n d[i].sort()\n if(len(d[i])>=k):\n ans=min(ans,d[i][k-1])\nprint(ans)\n"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nBUFSIZE = 8192\n \nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n# ------------------- fast io --------------------\nimport math;from collections import defaultdict\nn,k=map(int,input().split())\nvals=list(map(int,input().split()));vals.sort()\nif vals[-1]==0:\n print(0)\nelse:\n nums=1<<math.ceil(math.log2(vals[-1]))\n dict1={};dict2=defaultdict(int)\n for s in range(n-1,-1,-1):\n while vals[s]<nums:\n nums=nums//2\n if not(nums in dict1):\n dict1[nums]=defaultdict(int)\n dict1[nums][vals[s]]+=1\n else:\n dict1[nums][vals[s]]+=1\n dict2[nums]+=1\n info=[x for x in dict1.keys()];info.sort()\n minsofar=10**10\n for s in range(len(info)):\n key=info[s]\n for i in dict1[key].values():\n numsofar=i;moves=0\n if s==len(info)-1:\n if numsofar>=k:\n minsofar=0;break\n else:\n for b in range(s+1,len(info)):\n v0=min(k-numsofar,dict2[info[b]])\n numsofar+=v0;moves+=(b-s)*v0\n if numsofar>=k:\n minsofar=min(minsofar,moves)\n break\n print(minsofar)"}, {"source_code": "INF = int (2e9)\nn, k = list (map (int, input ().split ()))\na = list (map (int, input ().split ()))\na.sort()\na = [(x, 0) for x in a]\n\nflag = False\nans = INF\nha = {}\ntail = n - 1\np = 0\n\ndef find (x):\n l, r = 0, tail \n while (l <= r) :\n mid = (l + r) >> 1\n if (a[mid][0] >= x) :\n r = mid - 1\n else :\n l = mid + 1\n return r + 1\n\nwhile (a[tail][0]):\n flg = True\n cnt = 0\n val = a[tail][0]\n if (a[tail - k + 1][0] == val) :\n for j in range(k) :\n cnt += a[tail - j][1]\n else :\n flg = False\n if (flg) :\n flag = True\n ans = min (ans, cnt)\n \n i = tail\n tag = tail - k\n while (a[i][0] == val) :\n if (i > tag) :\n x = a[i][0] // 2\n stp = a[i][1]\n loc = find (x)\n a.pop ()\n a.insert(loc, (x, stp + 1))\n # print (a)\n else :\n a.pop ()\n tail -= 1\n i -= 1\n p += 1\n\nprint (ans)"}, {"source_code": "from collections import deque\nimport collections\nimport sys\n\ndef inp():\n return sys.stdin.readline().strip()\nn,k=map(int,inp().split())\na=list(map(int,inp().split()))\nd=collections.Counter(a)\nd[0]=d.get(0,0)\nb=list(d.keys())\nmn=float('inf')\nb.sort()\nfor i in range(10**5+1):\n val=d.get(i,0)\n ans=0\n for j in d:\n if j>i:\n ct=0\n temp=j\n while temp>i:\n temp//=2\n ct+=1 \n if temp==i:\n if d[j]+val>=k:\n req=k-val\n val=k\n ans+=req*ct\n else:\n val+=d[j]\n ans+=d[j]*ct\n if val==k:\n mn=min(ans,mn)\nprint(mn)\n \n \n \n "}, {"source_code": "from collections import defaultdict as dfd\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\n\nd = dfd(int)\ncost = dfd(int)\n\nans = 999999999\nfor i in arr:\n #uss element ke liye\n d[i] += 1\n cost[i] += 0\n \n if d[i]==k:\n ans = min(ans, cost[i])\n \n j = i\n while j>0:\n j //= 2\n d[j] += 1\n cost[j] += 1\n if d[j]==k:\n ans = min(ans, cost[j])\nprint(ans)\n"}, {"source_code": "n,k=[int(x) for x in input().split(' ')]\narr=sorted([int(x) for x in input().split(' ')])\nans=99999999999\ncand=0\nind=-1\nwhile ind < n-1:\n\tj=ind+1\n\tcnt=1\n\tcost=0\n\twhile j<n:\n\t\top=0\n\t\tif(arr[j]==cand):\n\t\t\tcnt+=1\n\t\t\tif(cnt==k):\n\t\t\t\tbreak\n\t\telse:\n\t\t\ttemp=arr[j]\n\t\t\twhile(temp>cand):\n\t\t\t\top+=1\n\t\t\t\ttemp=temp//2\n\t\t\tif(temp==cand):\n\t\t\t\tcnt+=1\n\t\t\t\tcost+=op\n\t\t\t\tif(cnt==k):\n\t\t\t\t\tbreak\n\t\tj+=1\n\tind+=1\n\t# print(cand,cost)\n\tcand=arr[ind]\n\tif(cnt==k):\n\t\tans=min(ans,cost)\nprint(ans)"}], "src_uid": "ed1a2ae733121af6486568e528fe2d84"} {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\n\nchot = max(a)\na2 = []\nfor i in a:\n if (chot%i==0) and (i not in a2):\n a2.append(i)\nfor i in a2:\n a.remove(i)\nchot1 = max(a)\nprint chot, chot1", "positive_code": [{"source_code": "\"Template made by : https://codeforces.com/profile/c1729 , github repo : https://github.com/cheran-senthil/PyRival\"\nfrom __future__ import division, print_function\nimport bisect\nimport math\nimport itertools\nimport sys\nfrom atexit import register\n\nif sys.version_info[0] < 3:\n from io import BytesIO as stream\nelse:\n from io import StringIO as stream\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\ndef main():\n n=int(input())\n l1=list(map(int,input().split()))\n m=max(l1)\n t=1\n f=1\n d1={}\n for item in l1:\n if item in d1:\n d1[item]+=1\n else :\n d1[item]=1\n for i in range(1,m+1):\n if m%i==0:\n d1[i]-=1\n if d1[i]==0:\n del d1[i]\n print(m,max(d1))\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\narr.sort()\nx=arr[-1]\nflag=1\n#print(arr)\nif n==2:\n\tprint(arr[0],arr[1])\nelse:\n\tfor i in range(n-2,-1,-1):\n\t\tif x%arr[i]!=0:\n\t\t\ty=arr[i]\n\t\t\tflag=0\n\t\t\tbreak\n\tif flag:\n\t\tfor i in range(n-1,0,-1):\n\t\t\tif arr[i]==arr[i-1]:\n\t\t\t\ty=arr[i]\n\t\t\t\tbreak\n\tprint(x,y)"}, {"source_code": "from fractions import gcd\nfrom collections import Counter\n \ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n \ninput()\narr=list(map(int,input().split()))\n \ncount=Counter(arr)\n \na=max(arr)\nb=1\n \nfor x in count:\n if a%x!=0 or count[x]>1:\n b=lcm(b,x)\n \nprint(str(a)+' '+str(b))"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\narr=[]\nfor i in a:\n\tif i!=1:\n\t\tarr.append(i)\nif len(arr)==0:\n\tprint(1,1)\n\texit()\n\n# print(kaamka)\nd={}\nfor i in a:\n\tif i in d:\n\t\td[i]+=1\n\telse:\n\t\td[i]=1\nboth=[]\nfor key,value in d.items():\n\tif value==2:\n\t\tboth.append(key)\na=sorted(a)\nif len(a)==2:\n\tprint(a[0],a[1])\n\texit()\nif len(arr)==1:\n\tprint(a[0],a[-1])\n\texit()\narr=sorted(arr)\nfor i in range(len(a)):\n\tfor j in range(i+1,len(a)):\n\t\tf1=True\n\t\tx=a[i]\n\t\ty=a[j]\n\t\tfor k in range(len(both)):\n\t\t\tif x%both[k]!=0 or y%both[k]!=0:\n\t\t\t\tf1=False\n\t\t\t\tbreak\n\t\tf2=True\n\t\tfor k in range(len(a)):\n\t\t\tif x%a[k]!=0 and y%a[k]!=0:\n\t\t\t\tf2=False\n\t\t\t\tbreak\n\t\t# print(f1,f2)\n\t\tif f1 and f2:\n\t\t\tprint(x,y)\n\t\t\texit()"}, {"source_code": "import sys,math,string\ninput=sys.stdin.readline\n\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\n\nn=int(input())\nl=L()\nl.sort()\nk=l[-1]\n\ni=1\nwhile(i<=math.sqrt(k)):\n if(k%i==0):\n l.remove(i)\n if(i!=k//i):\n l.remove(k//i)\n i+=1\nl.sort()\nprint(k,l[-1])\n"}, {"source_code": "from math import gcd\nN = int(input())\nar = [int(x) for x in input().split()]\nar.sort()\na = ar[-1]\nbr = []\nfor i in range(N):\n\tif i > 0 and ar[i] == ar[i - 1]:\n\t\tbr.append(ar[i])\n\telse:\n\t\tif(a % ar[i] != 0):\n\t\t\tbr.append(ar[i])\nb = 1\nfor i in br:\n\tb = (b * int(i)) // gcd(b, i)\nprint(a, b)"}, {"source_code": "import math\n\ndef getDivisors(n) : \n i = 1\n arr=[]\n while i <= math.sqrt(n): \n if (n % i == 0) : \n if (n / i == i) : \n arr.append(i)\n else : \n # Otherwise print both \n arr.append(i)\n arr.append(n/i)\n i=i + 1\n return arr\n\nn=int(input())\narr=list(map(int,input().split()))\nmaxx=max(arr)\narr1=getDivisors(maxx)\nd={}\nfor i in arr:\n if i in d.keys():\n d[i]+=1 \n else:\n d[i]=1 \n \nfor i in arr1:\n if d[i]==1:\n del d[i]\n else:\n d[i]=1 \n\nmaxx1=max(list(d.keys()))\nprint(maxx,maxx1)"}, {"source_code": "\nn = int(input())\n\nl = list(map(int,input().split()))\n\nl.sort()\n\nx = l[-1]\n\n\nhash = set()\n\nk = []\nfor i in l:\n if x%i == 0 and i not in hash:\n # print(i)\n hash.add(i)\n\n # print(l)\n else:\n k.append(i)\n# l.remove(x)\n\nk.sort()\ny = k[-1]\n# print(l)\nprint(x,y)\n\n"}, {"source_code": "q = int(input())\nl = list(map(int, input().split()))\na = max(l)\nprint(a, end = \" \")\nfor i in range(1, a + 1):\n if a % i == 0:\n l[l.index(i)] = -1\nprint(max(l))"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na=sorted(a)\nx=a[-1]\ny=0\ndiv_x=list()\nfor i in range(n):\n\tif x%a[i]==0:\n\t\tif a[i] not in div_x:\n\t\t\tdiv_x.append(a[i])\ndic={}\nfor i in a:\n\tif \ti in dic.keys():\n\t\tdic[i]+=1\n\telse:\n\t\tdic[i]=1\nfor i in div_x:\n\tdic[i]-=1\n\tif dic[i]==0:\n\t\tdic.pop(i)\ny=max(dic.keys())\t\t\t\t\nprint(x,y)"}, {"source_code": "n=int(input())\ns=sorted(map(int,input().split()))\nans=s[-1]\nfor i in range(n-1,-1,-1):\n if ans%s[i]or s.count(s[i])>1:print(ans,s[i]);break"}, {"source_code": "input()\nl = sorted(map(int, input().split()))\nb = max(l)\nx = [i for i in l if b%i == 0]\nfor i in list(set(x)):\n l.remove(i)\nprint(b,max(l))"}, {"source_code": "def gcd(a,b):\n if (b == 0): \n return a \n return gcd(b, a % b)\n \n\ndef findlcm(arr,n):\n ans = arr[0]; \n for i in range(len(arr)): \n ans = (((arr[i] * ans)) / (gcd(arr[i], ans)))\n \n return int(ans)\n\nn = int(input())\na = [int(i) for i in input().split()]\nb=sorted(set(a),reverse=True)\nx=b[0]\ny = [i for i in b if (x%i!=0)]\nif(len(y)==0):\n k=1\n c=[int(i) for i in b if (a.count(i)==2)]\n print(x,findlcm(c,len(c)))\nelse:\n print(x,y[0])"}, {"source_code": "n=int(input())\ndivs=list(map(int,input().split()))\nx=max(divs)\nfor i in range(1,x+1):\n if x%i==0: divs.remove(i)\nprint(x,max(divs))"}, {"source_code": "# import sys \n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out1.out\",'w')\nn=int(input())\na=list(map(int,input().split()))\na.sort()\nx=a[-1]\nb=[]\ni=0\nwhile i<len(a):\n\tif a[i] not in b and x%a[i]==0:\n\t\tb.append(a[i])\n\t\ta.remove(a[i])\n\telse:\n\t\ti+=1\ny=a[-1]\t\t\nprint(x,y)\t\t"}, {"source_code": "def isPrime(n) : \n if (n <= 1) : \n return False\n if (n <= 3) : \n return True\n\n if (n % 2 == 0 or n % 3 == 0) : \n return False\n \n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n \n return True\n \n\nfrom itertools import combinations\nfrom sys import stdin\nimport math\n\ndef listIn():\n return list((map(int,stdin.readline().strip().split())))\n\ndef stringIn():\n return([x for x in stdin.readline().split()])\n \ndef intIn():\n return (int(stdin.readline()))\n\nn=intIn()\nd=listIn()\nlia=[]\nlib=[]\ndi={}\nfor i in range(n):\n if d[i] not in di:\n di[d[i]]=1\n else:\n di[d[i]]+=1\nd=sorted(set(d))\nd=d[::-1]\nn=len(d)\nlia=[d[0]]\nif len(set(di.values()))==1:\n print(max(d),max(d))\nelse:\n for i in range(n):\n if di[d[i]]==2:\n lia.append(d[i])\n lib.append(d[i])\n else:\n if lia[0]%d[i]==0:\n lia.append(d[i])\n else:\n lib.append(d[i])\n \n \n \n #print(lia,lib)\n print(max(lia),max(lib))"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nh=[0]*20001\na.sort()\nfor i in range(n):\n h[a[i]]+=1\np=max(a)\nfl=0\nfor i in range(1,20001):\n if p%i==0:\n h[i]-=1\nfor i in range(20001-1,1,-1):\n if h[i]>=1:\n ans=i\n fl=1\n break\nif fl==0:\n ans=1\nprint(str(p)+\" \"+str(ans))\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nx = max(s)\ndivisors = []\nfor i in range(1, x + 1):\n\tif x % i == 0:\n\t\ts.remove(i)\ny = max(s)\nprint(x, y)"}, {"source_code": "n = int(input())\ns = [int(elem) for elem in input().split()]\na = 1\nb = 1\nx = max(s)\ns2 = []\nused = [False] * 10001\nfor i in range(n):\n if x % s[i] != 0 or used[s[i]]:\n s2.append(s[i])\n else:\n used[s[i]] = True\nprint(x, end=' ')\nif len(s2) > 0:\n y = max(s2)\n print(y)\nelse:\n print(1)\n"}, {"source_code": "n=int(input())\na=[int(i) for i in input().split()]\na.sort()\nx,b,c,prod=max(a),[],[],0\nfor i in range(len(a)):\n if(x%a[i]!=0):\n b.append(a[i])\nfor i in range(1,len(a)):\n if(a[i]==a[i-1]):\n c.append(a[i])\n#if(len(c)!=0):\n # z=max(c)\n#else:\n # z=1 \nif(len(b)!=0):\n y=max(b)\nelse:\n y=max(c)\n#t=y*z \nprint(x,y)\n \n "}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nm=max(l)\nfor i in range(1,m+1):\n\tif m%i==0:\n\t\tl.remove(i)\nprint(m,max(l))"}, {"source_code": "n=int(input())\na=sorted(list(map(int,input().split())))\nx=a[n-1];y=1\nb=[0]*10001\nfor i in range(n):\n b[a[i]]+=1\nfor i in range(1,x+1):\n if x%i==0:\n b[i]-=1\nfor i in range(10000,-1,-1):\n if b[i]==1:\n y=i\n break\nprint(x,y)\n \n\n \n \n "}, {"source_code": "n=int(input())\nimport math \n \n# Method to print the divisors \ndef printDivisors(n) : \n k = [] \n \n # List to store half of the divisors \n for i in range(1, int(math.sqrt(n) + 1)) : \n \n if (n % i == 0) : \n \n # Check if divisors are equal \n if (n // i == i) : \n k.append(i)\n else : \n k.append(i) \n k.append(int(n // i))\n return list(set(k))\nc = list(map(int,input().split()))\nc = sorted(c)\nk =c[-1]\nl = printDivisors(c[-1])\nc.reverse()\nfor i in range(1,len(c)):\n if(sorted(printDivisors(c[i])+l) == sorted(c)):\n print(k,c[i])\n break\n"}, {"source_code": "n=int(input())\nl1=list(map(int,input().split()))\ny=max(l1)\nfor i in range(1,y+1):\n\tif y%i==0:\n\t\tl1.remove(i)\nprint(y,max(l1))"}, {"source_code": "n = int(input())\na = sorted(list(map(int, input().split())), reverse=True)\nprint(a[0], end=\" \")\ni = 1\nwhile i < n:\n if a[i] == a[i - 1] or a[0] % a[i] != 0:\n print(a[i])\n break\n i += 1"}, {"source_code": "n=int(input())\nli=list(map(int,input().split()))\nli.sort(reverse=True)\n#print(li)\nl=[]\nfor i in li:\n\tif li.count(i)==2:\n\t\tl.append(i)\nl=list(set(l))\nl.sort(reverse=True)\n#print(l)\nfor i in li[1:]:\n\tif li[0]%i!=0:\n\t\tprint(li[0],i)\n\t\texit(0)\nif li[0]%li[1]!=0:\n\tprint(li[0],li[1])\nelif len(l)==1:\n\t#li.sort(reverse=True)\n\tif li[0]%li[1]==0:\n\t\tprint(1,max(li))\n\telse:\n\t\tprint(li[0],li[1])\nelif len(li)==4:\n\t#li.sort(reverse=True)\n\tprint(li[0],li[1])\nelif len(l)>=2:\n\tl.sort(reverse=True)\n\tprint(l[0],max(li))\n# else:\n# \tfor i in li:\n# \t\tif i%l[0]==0 and i%l[1]==0 and i!=l[0] and i!=l[1]:\n# \t\t\tprint(i,end=\" \")"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nx=max(arr)\nfor i in range(1,int(x**0.5)+1):\n\tif x%i==0:\n\t\tif x//i==i:\n\t\t\tarr.remove(i)\n\t\telse:\n\t\t\tarr.remove(i)\n\t\t\tarr.remove(x//i)\nprint(x,max(arr))"}, {"source_code": "\nn = int(input())\nl = list(map(int,input().split()))\n\nx = max(l)\n\nfor i in range(1 , x + 1):\n if x % i == 0 :\n l.remove(i)\n\n\n#print(l)\nprint(x , max(l))\n\n\n\n"}, {"source_code": "n = input()\nlst = sorted(map(int, raw_input().split()))\ngr = lst[-1]\n\noth_idx = 1\nfor i in range(len(lst) - 1):\n tmp = lst[i]\n if gr % lst[i] == 0:\n i += 1\n if tmp == lst[i]:\n oth_idx = i\n i += 1\n else:\n oth_idx = i\n\nprint gr, lst[oth_idx]\n\n"}, {"source_code": "from collections import deque\nfrom math import ceil\nimport sys\n\n# input = sys.stdin.buffer.readline\n# def print(val):\n# \tsys.stdout.write(str(val) + '\\n')\n# for _ in range(int(input())) :\nn = int(input())\na = [int(i) for i in input().split()]\na.sort(reverse=True)\nx = a[0]\ns = set()\nfor i in a.copy() :\n\tif x%i == 0 and not i in s :\n\t\ta.remove(i)\n\t\ts.add(i)\ny = a[0]\nprint(x, y)"}, {"source_code": "__author__ = 'tanunia'\n\nimport math\n\ndef all_divs(x):\n res = set()\n for i in xrange(1, int(math.sqrt(x)) + 1):\n if x % i == 0:\n res.add(i)\n res.add(x/i)\n return res\n\nn = int(raw_input())\ndivs = sorted([int(x) for x in raw_input().split()])\ny = divs[-1]\ny_divs = all_divs(y)\nfor x in divs:\n x_divs = all_divs(x)\n xy_divs = []\n for c in y_divs:\n xy_divs.append(c)\n for c in x_divs:\n xy_divs.append(c)\n xy_divs = sorted(xy_divs)\n if divs == xy_divs:\n print x, y\n break\n"}, {"source_code": "'''input\n6\n1 1 3 3 5 15\n'''\nfrom math import gcd\nfrom sys import stdin\ndef myfunction():\n\t# I am a disco dancer\n\t# it is a copy code\n\tpass\n\n\n\t\nn=int(stdin.readline().strip())\narr=list(map(int, stdin.readline().split()))\np=dict()\nif n==2:\n print(arr[0],arr[1])\n exit()\nfor i in arr:\n if i in p:\n p[i]+=1\n else:\n p[i]=1\nb=[]\n\n\nfor i in p:\n if p[i]==2:\n b.append(i)\n \narr.sort(reverse=True)\n\nfor i in range(1,n):\n if gcd(arr[i],arr[0]) in b:\n f_a = arr[0]\n f_b = arr[i]\n break\nprint(f_a,f_b)"}, {"source_code": "import sys\nimport heapq\nimport bisect\nimport math\nimport random\n\nINF = 10**9+7\nOFFLINE = 0\nN = 101010\nsys.setrecursionlimit(INF)\n\ndef fi():\n\treturn int(sys.stdin.readline())\n\ndef fi2():\n\treturn map(int, sys.stdin.readline().split())\n\ndef fi3():\n\treturn sys.stdin.readline().rstrip()\n\ndef fo(*args):\n\tfor s in args:\n\t\tsys.stdout.write(str(s)+\" \")\n\tsys.stdout.write(\"\\n\")\n\n##\nif OFFLINE:\n\tsys.stdin = open(\"fin.txt\", \"r\")\n\tsys.stdout = open(\"fout.txt\", \"w\")\n##\n\n\n\n\n##main\n\nn = fi()\n\nd = fi2()\nd.sort()\n\nX = d[-1]\n\n\nY = None\nfor i in range(n-1):\n\tif X%d[i] == 0:\n\t\tcontinue\n\n\telse:\n\t\tY = d[i]\n\nif Y == None:\n\tfor i in d:\n\t\tif d.count(i) == 2:\n\t\t\tY = i\n\n\n\nprint X, Y\n\n"}, {"source_code": "import sys\ndef deliteli(x):\n ret = []\n for i in xrange(1, int(x**0.5)+2):\n if x%i == 0:\n i2 = x/i\n if i2 > i:\n ret.extend([i, i2])\n elif i2 == i:\n ret.append(i)\n return ret\n\nn = input()\ndata = map(int, raw_input().split())\ndata.sort()\nm = data[-1]\nfor delitel in deliteli(m):\n data.pop(data.index(delitel))\n\nprint >> sys.stderr, data\nprint m, data[-1]\n"}, {"source_code": "N = int(input())\narr = [int(i) for i in input().split()]\na = max(arr)\narr.remove(a)\nb = max(arr)\nprint(a, end = \" \")\nif a == b:\n print(b)\nelse:\n r = len(arr)\n for i in range(r):\n b = max(arr)\n arr.remove(b)\n t = max(arr)\n if b == t:\n print(b)\n break\n elif a % b != 0:\n print(b)\n break\n else:\n print(1)\n \n"}, {"source_code": "n=input()\nc={}\nfor x in map(int,raw_input().split()):\n c[x]=c.get(x,0)+1\na=max(c)\nfor x in c:\n if 0==a%x:\n c[x]-=1\nprint a,max([x for x in c if c[x]])"}, {"source_code": "n=int(input())\nl=[int(j) for j in input().split()]\nl.sort()\na=l[-1]\n\nd=dict()\nnew=[]\n\n\nfor i in range(n):\n if a%l[i]==0 and not l[i] in d:\n d[l[i]]=1\n \n else:\n new.append(l[i])\n\ng=new[-1]\n\nprint(a,g)\n \n"}, {"source_code": "n=int(input())\na=[int(i) for i in input().split()]\na.sort()\nx=a[-1]\npast=0\nfor i in range(n):\n if(a[-1]%a[i]==0 and past!=a[i]):\n past=a[i]\n a[i]=0\n \na.sort()\nprint(x,a[-1])\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\nans = a[n-1]\nfor i in range(1,n):\n if a[0]%a[i] != 0 or a[i-1]==a[i]:\n ans = a[i]\n break\nprint(ans,a[0])"}, {"source_code": "x=input()\ny=list(map(int,input().strip().split()))\nz=max(y)\ny.remove(z)\nfor i in range(1,int(z/2)+1):\n if z%i==0:\n y.remove(i)\na=max(y)\nprint(z,a)\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\n\na.sort()\nl = a[-1]\nans = 0\n\nfor i in range(n-2,-1,-1):\n if l % a[i] != 0:\n ans = a[i]\n break\n\nif ans == 0: \n for i in range(n-2,-1,-1):\n if a[i] == a[i+1]:\n ans = a[i]\n break\n \nprint ans, l"}, {"source_code": "t=int(input())\ninar = list(map(int,input().split()))\nx = max(inar)\nxs=[]\nys=[]\nfor ina in inar:\n if inar.count(ina)==2:\n xs.append(ina)\n ys.append(ina)\n elif x%ina==0:\n xs.append(ina)\n else:\n ys.append(ina)\nprint('{} {}'.format(x,max(ys)))"}, {"source_code": "count = int(input())\narr = [int(x) for x in input().split()]\na = max(arr)\nb = 0\narr2 = set()\nfor i in range(len(arr)):\n if a % arr[i] != 0:\n arr2.add(arr[i])\n if arr.count(arr[i]) > 1:\n arr2.add(arr[i])\nprint(a, max(arr2))"}, {"source_code": "#import sys\n\nN = int(input())\n\nP = list(map(int, input().split(\" \")))\n\np = len(P)\nnum = max(P)\n\nyakusuu_array = []\n\nfor i in range(1,num):\n \n if num % i == 0:\n yakusuu_array.append(i)\n\nyakusuu_array.append(num)\n\nm = len(yakusuu_array)\n#set_ab = []\n#set_ab = list(set(P) - set(yakusuu_array))\n\nfor j in range(m):\n d = yakusuu_array[j]\n P.remove(d)\n #print(P)\n\nnum1 = max(P)\n\n\nprint(int(num),\" \",int(num1))\n\n\n\n"}, {"source_code": "def arr_inp():\n return [int(x) for x in input().split()]\n\n\ndef factorize(n): # o(sqr(n))\n c, ans, arr = 1, 0, deque([])\n while (c ** 2 < n):\n if n % c == 0:\n arr.extend([c, n // c])\n c += 1\n\n if c ** 2 == n:\n arr.append(c)\n return sorted(arr)\n\n\nfrom collections import *\nfrom math import *\n\nn, d = int(input()), arr_inp()\nd.sort()\nx, p = d[-1], 0\nx_fac, y = factorize(x), -1\n\nfor i in d:\n if p < len(x_fac) and x_fac[p] == i:\n p += 1\n else:\n y = max(y, i)\n\nprint(x, y)\n"}, {"source_code": "n=int(input())\nl=list(map(int, input().strip().split()))\n\na=max(l)\n\nvisited=[]\n\nrr=[]\n\nfor i in l:\n\tif a%i==0 and i not in visited:\n\t\tvisited.append(i)\n\telse:\n\t\trr.append(i)\n# print(rr)\n\nb=max(rr)\nprint(a, b)"}, {"source_code": "def ans(a):\n x = a.pop()\n save = {}\n if x == a[len(a)-1]:\n return [x,x]\n while a:\n y = a.pop()\n if x%y != 0 or y in save:\n break\n save[y] = 1\n return [x,y]\n\n\nn = int(input())\na = [int(i) for i in input().split()]\na.sort()\nprint(*ans(a))\n"}, {"source_code": "n = input()\nl = map(int, raw_input().split())\ntmp = max(l)\nt2 = set(l)\nfor i in t2:\n\tif tmp%i == 0:\n\t\tl.remove(i)\nprint tmp, max(l)"}, {"source_code": "n=int(input())\n\nll=[int(x) for x in input().split()]\n# print(n)\n# print(ll)\nhset=set()\na=max(ll)\nb=-1\nfor i in range(0,n):\n if(ll[i] in hset):\n b=max(b,ll[i])\n hset.add(ll[i])\n if(a%ll[i]!=0):\n b=max(b,ll[i])\nif(b==-1):\n b=a\nprint(a,' ',b)\n\n\n"}, {"source_code": "a = int(input())\nb = [int(x) for x in input().split()]\nb.sort(key = lambda x: -x)\nx = b[0]\nfor m in range(1,x+1):\n if x%m == 0:\n b.remove(m)\nprint(x, b[0])\n"}, {"source_code": "def factors(num):\n res = []\n for i in xrange(1,int(num**0.5)+1):\n if num%i == 0:\n res.append(i)\n if num/i != i:\n res.append(num/i)\n return res\n\nn = input()\ndivisors = map(int, raw_input().split())\ndivisors.sort()\n\na = divisors[0] * divisors[n-1]\nfacts = factors(a)\nfor num in facts:\n divisors.remove(num)\nb = min(divisors) * max(divisors)\nprint a,b"}, {"source_code": "from collections import Counter\nn = int(input())\narr = list(map(int,filter(None,input().split(' '))))\narr = sorted(arr)\ndef get_div(n):\n li = []\n for i in range(1,int(n/2)+1):\n if n%i==0:\n li.append(i)\n li.append(n)\n return li\nn1 = arr[-1]\nli2 = get_div(n1)\nli3 = list((Counter(arr)-Counter(li2)).elements())\nn2 = li3[-1]\nprint(n1,' ',n2)\n"}, {"source_code": "n = int(input())\na = sorted(list(map(int,input().split())))[::-1]\nx = a[0]\nfor i in range(n):\n\tif x%a[i] != 0:\n\t\ty = a[i]\n\t\tbreak\n\telif a[i+1] == a[i]:\n\t\ty = a[i]\n\t\tbreak\nprint(x,y)\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\na.sort()\nmx = a[len(a)-1]\nmx1 = 0\nfor i in range(n-1):\n\n if a[i] == mx:\n mx1 = mx\n if mx % a[i] or a[i] == a[i+1]:\n mx1 = max(mx1, a[i])\nprint(mx, max(1, mx1))\n"}, {"source_code": "import sys\n#sys.stdin=open(\"./pb3.txt\",\"r\")\nraw_input=sys.stdin.readline\n\nn=int(raw_input())\nar=map(int,raw_input().split())\n\nar.sort(reverse=True)\ny=ar[0]\nocc=[0]*(y+1)\nfor i in ar:\n\tocc[i]+=1\n\nfor i in xrange(1,n):\n\tif (y%ar[i]==0 and occ[ar[i]]==2) or y%ar[i]!=0:\n\t\tx=ar[i]\n\t\tbreak\nprint x,y\n\t"}, {"source_code": "n = int(input())\nd = sorted([int(i) for i in input().split()])[::-1]\nx = [d[0]]\ny = []\n# if d[1] != x:\n# \tfor i in range(n):\n# \t\tif d[i-1] == 1 and d[i] == 1:\n# \t\t\ty = 1\n# \t\t\tbreak\n# \t\tif not x % d[i] == 0:\n# \t\t\ty = d[i]\n# \t\t\tbreak\nfor i in range(0, n):\n\tif d[i] == d[i-1]:\n\t\ty.append(d[i])\n\telif x[0] % d[i] == 0:\n\t\tx.append(d[i])\n\telse:\n\t\ty.append(d[i])\nd = sorted(d)[::-1]\nx = sorted(x)[::-1][0]\ny = sorted(y)[::-1][0]\nprint(x, y)"}, {"source_code": "import math\nn=int(input())\nf=[]\nl=list(map(int,input().split()))\nx=max(l)\np=x\n #l.remove(x)\n \nfor i in range(len(l)):\n if p%l[i]==0:\n if l[i] not in f:\n f.append(l[i])\n \nfor i in f:\n l.remove(i)\n \ny=max(l)\nprint(x,y)\n "}, {"source_code": "N = input()\nA = map(int, raw_input().split())\nA.sort()\n\nX = A[-1]\ni = 1\nB = []\n\nwhile i * i <= X:\n if X % i == 0:\n if i * i == X:\n B.append(i)\n else:\n B.append(i)\n B.append(X / i)\n i += 1\n\nB = set(B)\n\nfor i in xrange(N-1, -1, -1):\n if A[i] not in B:\n print X, A[i]\n exit()\n else:\n B.remove(A[i])\n"}, {"source_code": "from math import sqrt\ndef div(n):\n\ts = set()\n\tfor i in range(1,n):\n\t\tif n%i == 0:\n\t\t\ts.add(i)\n\ts.add(n)\n\treturn s\n\nn = input()\narr = map(int,raw_input().split())\narr.sort()\nn1 = arr[-1]\nz = div(n1)\nfor i in range(n):\n\tif arr[i] in z:\n\t\tz.remove(arr[i])\n\t\tarr[i] = 0\nprint max(arr),n1\n"}, {"source_code": "n=int(input())\nd=list(map(int,input().split()))\nd.sort()\nnum1=d[n-1]\nb=[]\nfor i in range(1,n):\n if(num1%d[i]!=0):\n b.append(d[i])\n else:\n if(d[i-1]==d[i]):\n b.append(d[i])\nnum2=b[len(b)-1]\nprint(num1,num2)"}, {"source_code": "n = input()\nfrom collections import Counter\nd = Counter(map(int, raw_input().split()))\n\nx = max(d)\nprint x,\nfor i in xrange(1,x+1):\n if x%i==0:\n d.subtract([i])\nprint max(d.elements())"}, {"source_code": "from math import gcd\n\nn = int(input())\nA = list(map(int, input().split()))\nanswer = 1\na = max(A)\nvisited = set()\nfor i in range(n):\n if a % A[i] != 0 or A[i] in visited:\n answer *= (A[i] // gcd(A[i], answer))\n visited.add(A[i])\nprint(a, answer)"}, {"source_code": "n=int(input())\nd=list(map(int,input().split()))\nd.sort()\nm=max(d)\nmm=1\nfor k in d:\n\tif d.count(k)>1 or m%k:\n\t\tmm=k\nprint(m,mm)"}, {"source_code": "a=int(raw_input())\n\nl=map(int,raw_input().split())\n\nx=max(l)\n\nfor i in xrange(1,int(x**0.5)+1):\n\tif x%i==0:\n\t\tl.remove(i)\n\t\tif x/i != i:\n\t\t\tl.remove(x/i)\n\t\t\nprint str(x)+\" \"+str(max(l))\n\t\n"}, {"source_code": "n = input()\nlist = map(int, raw_input().split())\nlist.sort()\nlist.reverse()\nprint list[0],\na=list[0]\narr=[]\nfor i in range(1,a+1):\n if a%i==0:\n arr.append(i)\nfor a in range(len(arr)):\n for b in range(n):\n if list[b]==arr[a]:\n list[b]=0\n break\nlist.sort()\nlist.reverse()\nprint list[0]"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nl.sort()\na=l[-1]\nb=1\nfor i in range(n-2,-1,-1):\n if(l[i]==l[i+1]):\n b=l[i]\n break\n if(a%l[i]!=0):\n b=l[i]\n break\nprint(a,b)"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.sort()\n#print(a)\nx=max(a)\ny=0\nd={}\nfor i in range(n):\n if a[i] in d:\n d[a[i]]+=1\n else:\n d[a[i]]=1\nfor i in range(n-2,-1,-1):\n if x%a[i]!=0:\n y=a[i]\n break\n elif x%a[i]==0 and d[a[i]]>1:\n y=a[i]\n break\nif y==0:\n if d[x]>=2:\n y=x\n else:\n y=1\nprint(x,y)\n \n"}, {"source_code": "\n#usefull:\n#1.Ways to find duplicate elements\n#2.\n\nn = int(input())\ndivisors = [ int(x) for x in input().split()]\n\ndef hcf(a,b):\n while(a!=b):\n if(a>b): a=a-b\n else: b = b-a\n return a\n \ndef lcm(a,b):\n h = hcf(a,b)\n return (a*b)//h\n\ndiv = sorted(divisors)\na=div[-1]\nb=1\n\nfor i,x in enumerate(div):\n if( x== div[i-1] or a%x!=0):\n b = max(b,x)\n #b = lcm(b,x)\n \nprint(a,b)"}, {"source_code": "n = int(input())\nlista = [int(x) for x in input().split()]\nmaxi = 0\nid = 0\nfor i in range (0, len(lista)):\n if maxi<lista[i]:\n maxi = lista[i]\n id = i\nlista[id] = -1\nanother = []\nanother.append(maxi)\n\nprint(maxi, end=' ')\n\nmaxi2 = -1\nfor i in range (0, len(lista)):\n if maxi%lista[i]==0 and (lista[i] not in another):\n \tanother.append(lista[i])\n \tlista[i] = -1\n\nmaxi2 = max(lista)\nif maxi2 == -1:\n\tprint(maxi)\nelse:\n\tprint(maxi2)"}, {"source_code": "x = int(input())\ny = map(int,input().split())\ny = sorted(list(y))\nf = y[-1]\nl = []\nf_d = [y[-1]]\nfor i in range(len(y)-1):\n\tif f%y[i] == 0 and (y[i] not in f_d):\n\t\tf_d.append(y[i])\n\t\tcontinue\n\tl.append(y[i])\nprint(f,max(l))"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nmx=max(arr)\n\ndiv=[]\nfor i in arr:\n if(mx%i or arr.count(i)>1):\n div.append(i)\n\nprint(str(mx)+\" \"+str(max(div)))"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nx=max(a)\nprint x,\nz=[]\ny=[]\nfor i in a:\n if x%i==0:\n if i not in z:\n z.append(i)\n else:\n y.append(i)\n else:\n y.append(i)\nprint max(y)"}, {"source_code": "import math\n\nn = input()\nnum = map(int, raw_input().split())\nnum.sort()\nnum1 = num[-1]\nfor x in range(1, int(math.sqrt(num1) + 1)):\n if num1 % x == 0 and num1/x != x:\n num.remove(x)\n num.remove(num1/x)\n elif num1 % x == 0:\n num.remove(x)\nnum.sort()\nnum2 = num[-1]\nprint num1, num2\n"}, {"source_code": "n=input()\nl=map(int,raw_input().split())\nl.sort()\na=l[n-1]\nd=[]\ndef bsa(x,a,c):\n l=0; r=c-1\n while l<=r:\n m=(l+r)/2\n if a[m]==x:\n return True\n elif a[m]>x:\n r=m-1\n else:\n l=m+1\n return False\nfor i in range(1,int(a**(0.5))+1):\n if a%i==0:\n if a/i==i:\n d+=[i]\n else:\n d=d+[i,a/i]\nd.sort()\nc=len(d)\nfor j in range(n-1,-1,-1):\n if bsa(l[j],d,c) and l[j-1]<>l[j]:\n continue\n else:\n b=l[j]\n break\nprint a,b\n"}, {"source_code": "n=int(input());a=sorted(list(map(int,input().split())));s=a[-1]\nif a.count(a[-1])==2:print(a[-1],a[-1]);exit()\n\nfor i in range(len(a)-1,-1,-1):\n if s%a[i]!=0 or i==0 or a.count(int(a[i]))==2:print(s,a[i]);exit()"}, {"source_code": "from sys import stdin\nfrom math import sqrt\n###############################################################\ndef iinput(): return int(stdin.readline())\ndef sinput(): return input()\ndef minput(): return map(int, stdin.readline().split())\ndef linput(): return list(map(int, stdin.readline().split()))\n###############################################################\n\nn = iinput()\na = linput()\ny = max(a)\ni = 0\nfor i in range(1, int(sqrt(y))+1):\n if y%i == 0:\n try: a.remove(i)\n except: pass\n try:\n if i!=y//i: a.remove(y//i)\n except: pass\nx = max(a)\nprint(x, y)"}, {"source_code": "n = input()\narr = map(int,raw_input().split())\narr.sort()\nx = arr[-1]\ntemp = arr[0]\ny = []\nfor i in range(1,n):\n if temp==arr[i]:\n y.append(arr[i])\n temp = arr[i]\n else:\n if x%arr[i]!=0:\n y.append(arr[i])\n temp = arr[i]\n else:\n temp = arr[i]\n\nprint x,max(y)\n \n"}, {"source_code": "if __name__ == '__main__':\n n = int(input())\n l = map(int, raw_input().rstrip().split())\n if n == 2:\n print \"1 1\"\n else:\n l = sorted(l)\n ma = l[-1]\n i=0\n flag = True\n while flag:\n if l[i] == l[i+1]:\n del(l[i])\n i += 1\n elif ma % l[i] == 0:\n del(l[i])\n else:\n i += 1\n flag = l[i] != ma\n mi = l[-2]\n print str(mi) + \" \" + str(ma)"}, {"source_code": "if __name__ == \"__main__\":\n n = int(input())\n numbers = list(map(int, input().split()))\n numbers.sort(reverse = True)\n num1 = numbers[0]\n div_num1 = set()\n for val in numbers:\n if num1 % val == 0:\n div_num1.add(val)\n \n for val in div_num1:\n numbers.remove(val)\n \n if len(numbers) == 0:\n num2 = num1\n else:\n numbers.sort(reverse = True)\n num2 = numbers[0]\n \n print(num1, num2)\n"}, {"source_code": "n = int(raw_input())\narr = list(map(int,raw_input().split()))\n\nma = max(arr)\n\nans = []\nif arr.count(ma) == 2:\n ans = [ma,ma]\nelse:\n ans.append(ma)\n d = dict()\n for i in arr:\n d[i] = d.get(i,0) + 1\n for i in d.keys():\n if ma%i == 0:\n d[i] -= 1\n temp = []\n for i in d.keys():\n if d[i]:\n temp.append(i)\n ans.append(max(temp))\n\n\nprint(\" \".join(map(str,ans)))\n"}, {"source_code": "n=int(input())\nd=list(map(int,input().split()))\nm=max(d)\nk=0\nfor i in d:\n if (m%i!=0 or d.count(i)>1) and i>k:\n k=i\nprint(m,k)"}, {"source_code": "import sys\n\nn = raw_input()\nl = [0 for _ in range(10080)]\n\nfor x in sorted(map(int, raw_input().split())):\n l[x] += 1\n y=x\nfor x in range(1,10001):\n if y%x == 0 and l[x]:\n l[x] -= 1\n if l[x]:\n oe = x\nprint y, oe"}, {"source_code": "n=input()\n\na=map(int,raw_input().split())\n\nans=max(a)\n\nfor i in range(1,ans+1):\n\n if ans%i==0:\n\n a.remove(i)\n\nprint ans,max(a)"}, {"source_code": "n = int(raw_input())\nl = [int(i) for i in raw_input().split()]\nl = sorted(l)\n# print l\na = []\nm = l[-1]\nfor i in range(1 , m+1):\n if m % i == 0:\n l.remove(i)\n\nprint m , l[-1]"}, {"source_code": "def solve():\n input()\n ar = []\n for i in (input().split(' ')):\n if i.isdigit():\n ar.append(int(i))\n ar.sort()\n x = ar[-1]\n ary = []\n deleted = 0\n for i in ar:\n if (x % i != 0) or (i == deleted):\n ary.append(i)\n else:\n deleted = i\n y = ary[-1]\n print(x ,y)\n \n \nsolve()\n"}, {"source_code": "t=int(raw_input())\na=map(int,raw_input().split())\na.sort()\nx=a[-1]\nc=set([])\nfor i in range(1,int(x**0.5)+2):\n\tif(x%i==0):\n\t\tc.add(i)\n\t\tc.add(x/i)\nc=sorted(list(c))\nd1=[0]*(10**4+5)\nfor i in a:\n\td1[i]=d1[i]+1\ny=1\nfor i in c:\n\td1[i]=d1[i]-1\ny=-1\nfor i in range(len(d1)):\n\tif d1[i]==1:\n\t\ty=max(y,i)\nprint x,y\t\t"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = [0] * 10001\nfor i in range(n):\n b[a[i]] += 1\na = sorted(set(a))\na = list(a)\nif b[a[len(a) - 1]] == 2:\n start = len(a) - 1\nelse:\n start = len(a) - 2\nfor i in range(start, -1, -1):\n c = b.copy()\n for j in a:\n if a[len(a) - 1] % j == 0:\n c[j] -= 1\n if a[i] % j == 0:\n c[j] -= 1\n if c[j] < 0:\n break\n good = True\n for j in c:\n if j != 0:\n good = False\n break\n if good:\n print(a[len(a) - 1], a[i])\n break\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nch1 = max(a)\nnums = set()\nfor i in range(len(a)):\n if (ch1 % a[i] == 0) and (a[i] not in nums) and (a[i] != -1):\n nums.add(a[i])\n a[i] = -1\nprint(ch1, max(a))"}], "negative_code": [{"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nt=0\nfor i in range(n-1):\n if l[i]==l[i+1]:\n t=max(t,l[i])\na=l[-1]\nb=0\nfor i in range(n):\n if l[i]%t==0 and l[i]!=a:\n b=max(b,l[i])\nprint(a,b)\n \n "}, {"source_code": "n = input()\nlist = map(int, raw_input().split())\nlist.sort()\nlist.reverse()\nprint list[0],\na=list[0]\nfor i in range(n):\n if a%list[i]==0:\n list[i]=0\nlist.sort()\nlist.reverse()\nif list[0]!=0:\n print 0\nelse:\n print 1"}, {"source_code": "n=int(input())\nli=list(map(int,input().split()))\nli.sort(reverse=True)\n#print(li)\nl=[]\nfor i in li:\n\tif li.count(i)==2:\n\t\tl.append(i)\nl=list(set(l))\nl.sort(reverse=True)\n#print(l)\nif li[0]%li[1]!=0:\n\tprint(li[0],li[1])\nelif len(l)==1:\n\t#li.sort(reverse=True)\n\tif li[0]%li[1]==0:\n\t\tprint(1,max(li))\n\telse:\n\t\tprint(li[0],li[1])\nelif len(li)==4:\n\t#li.sort(reverse=True)\n\tprint(li[0],li[1])\nelif len(l)>3:\n\tl.sort(reverse=True)\n\tprint(l[0],max(li))\nelse:\n\tfor i in li:\n\t\tif i%l[0]==0 and i%l[1]==0 and i!=l[0] and i!=l[1]:\n\t\t\tprint(i,end=\" \")"}, {"source_code": "input()\n*l,=sorted(map(int,input().split()))\nf=l[-1]\nd = {i:l.count(i) for i in set(l)-{f}}\nif 1 not in d.values():\n\tprint(f,f)\nelse:\n\tfor i in range(1,f//2+1):\n\t\tif not f%i:d[i]-=1\n\td={i:d[i] for i in d.keys() if d[i]}\n\tprint(f,max(d.keys()))"}, {"source_code": "n=int(input())\n\nll=[int(x) for x in input().split()]\n# print(n)\n# print(ll)\nhset=set()\na=max(ll)\nb=-1\nfor i in range(0,n):\n if(ll[i] in hset):\n b=max(b,ll[i])\n elif(a%ll[i]!=0):\n b=max(b,ll[i])\nif(b==-1):\n b=a\nprint(a,' ',b)\n\n\n"}, {"source_code": "\nx=int(input())\ny=input().split()\nz=[]\nt=[]\nif x==2:\n print(int(y[0]),int(y[1]))\nelse:\n for i in y:\n z.append(int(i))\n f=max(z)\n\n z.remove(z[z.index(f)])\n for i in z:\n if f % i != 0:\n t.append(i)\n if len(t) == 0:\n f2=max(z)\n else:\n f2=max(t)\n\n print(f,f2)"}, {"source_code": "def get_factors(num):\n l = [1,num]\n for i in range(2,int(num**0.5) + 1):\n if not num%i:\n if i not in l:\n l.append(i)\n l.append(num//i)\n return(l)\nn = int(input())\nl = list(map(int, input().rstrip().split(\" \")))\nl.sort()\nn1 = max(l)\nprint(n1, end= \" \")\nfac_n1 = get_factors(n1)\nfac_n1.sort()\nf = len(fac_n1)\nb=0\nfor i in range(n):\n if l[i]==fac_n1[b]:\n l[i]=0\n b=b+1\n if b >= f:\n break\nprint(max(l))"}, {"source_code": "def nok(a,b):\n return a*b/nod(a,b)\ndef nod(f,g):\n f,g=max(f,g),min(f,g)\n while f%g!=0:\n f=f%g\n f,g=g,f\n return g\nn=int(input())\ndeli=list(map(int, input().split()))\np,v=1,1\ndeli.sort()\ndeli.append(0)\ni=0\nwhile i<n:\n if deli[i]==deli[i+1]:\n p=nok(p,deli[i])\n v=nok(v,deli[i])\n i+=2\n else:\n if deli[i]%v==0:\n v=nok(v,deli[i])\n i+=1\n else:\n p=nok(p,deli[i])\n i+=1\nprint(int(p),int(v))\n"}, {"source_code": "from math import gcd\ndef lcm(x, y):\n\treturn x * y // gcd(x, y)\n\nn = int(input())\narr = list(map(int, input().split()))\na = max(arr)\narr.remove(a)\nb = 0\nfor e in arr:\n\tif a % e:\n\t\tb = max(b, e)\nprint(a, b)"}, {"source_code": "x = int(input())\ny = map(int,input().split())\ncount = 0\ny = sorted(list(y))\nprint(y[-1],y[-2])"}, {"source_code": "from functools import reduce\nfrom math import sqrt\n\n\ndef factors(n):\n step = 2 if n % 2 else 1\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(sqrt(n)) + 1, step) if n % i == 0)))\nq=int(input())\nar=list(map(int,input().split()))\na=max(ar)\nd=list(factors(a))\nfor t in ar:\n if t in d:\n ar.remove(t)\nb=max(ar)\nprint(str(a)+\" \"+str(b))"}, {"source_code": "n=int(input())\ndivs=list(map(int,input().split()))\nx=max(divs)\nydivs=[i for i in divs if x % i != 0]\nprint(x,max(ydivs) if len(ydivs)!=0 else x)"}, {"source_code": "q = int(input())\nl = list(map(int, input().split()))\na = max(l)\nif l.count(a) > 1:\n print(a, a)\n exit(0)\nll = [0]\nfor i in range(q):\n if a % l[i] != 0:\n ll += [l[i]]\nprint(a, max(ll))\n"}, {"source_code": "n=int(input())\ng=[int(g) for g in input().split()]\ng.sort()\nl=[]\nfor i in reversed(g):\n if g[-1]%i!=0:\n l.append(i)\n break\nif l==[]:\n print(g[-1],g[-2])\nelse:\n print(g[-1],l[0])\n"}, {"source_code": "#\t!/usr/bin/env python3\n#\tcoding: UTF-8\n#\tModified: <23/Jan/2019 08:24:27 PM>\n\n\n#\t\u272a H4WK3yE\u4e61\n#\tMohd. Farhan Tahir\n#\tIndian Institute Of Information Technology (IIIT),Gwalior\n\n#\tQuestion Link\n#\n#\n\n# ///==========Libraries, Constants and Functions=============///\n\n\nimport sys\n\ninf = float(\"inf\")\nmod = 1000000007\n\n\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\n\n\ndef get_ints(): return map(int, sys.stdin.readline().split())\n\n\ndef input(): return sys.stdin.readline()\n\n# ///==========MAIN=============///\n\n\ndef main():\n n = int(input())\n arr = get_array()\n arr.sort()\n x = arr[-1]\n new_arr = []\n for i in range(n):\n if x % arr[i] != 0:\n new_arr.append(arr[i])\n if len(new_arr) == 0:\n print(x, x)\n return\n new_arr.sort()\n print(x, new_arr[-1])\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "a=int(input())\nb=list(map(int,input().split()))\nc=max(b)\nb.sort()\nfor x in range(a-1,-1,-1):\n\tif c%b[x]!=0:\n\t\tbreak\n\telse:\n\t\tpass\nprint(c,b[x])\n"}, {"source_code": "\nn = input()\n\nnums = []\nnums = list(map(int, input().split()))\n\n\nx = nums[0]\nfor num in nums:\n if(num>x):\n x = num;\n\nnums.remove(x)\nfor num in nums:\n if (num % x != 0):\n y = num\n break;\nprint(y)\nfor num in nums:\n if num == x or (x % num != 0 and num > y):\n y = num;\nprint(x, y)"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ns=max(a)\nfor i in range(len(a)):\n if s%a[i]==0:\n a[i]=0\nb=max(a)\nprint(s,b)\n"}, {"source_code": "n = input()\nn = [int(i) for i in input().split()]\na = max(n)\nif n.count(a) == 2:\n print(a, a)\nelif set(filter(lambda x: max(n) % x != 0, n)) == set():\n print(a, 1)\nelse:\n print(a, max(set(filter(lambda x: a % x != 0, n))))"}, {"source_code": "if __name__ == \"__main__\":\n n = int(input())\n numbers = list(map(int, input().split()))\n numbers.sort(reverse = True)\n num1 = numbers[0]\n num2 = None\n for val in numbers[1:]:\n if num1 % val != 0:\n num2 = val\n break\n \n if not num2:\n num2 = num1\n print(num1, num2, end = '')\n"}, {"source_code": "n=int(input())\na=input().split()\nmn = -1\nmin=-1\nb=[]\nsum=0\nfor i in a:\n if int(i)>mn:\n mn=int(i)\nj=-1\nfor i in a:\n if int(i)==mn:\n if sum==0:\n b.append(1)\n sum+=1\n else:\n b.append(0)\n else:\n b.append(0)\nfor i in a:\n j+=1\n if(b[j]==1):\n continue\n if min<int(i):\n min=int(i)\nprint(str(mn)+' '+str(min))\n\n"}, {"source_code": "n=int(input())\ng=[int(g) for g in input().split()]\ng.sort()\nl=[]\nop=[]\nfor i in reversed(g):\n if g[-1]%i!=0:\n l.append(i)\n break\nif l==[]:\n if g[-1]!=g[-2]:\n op.append(g[-1])\n op.append(g[-2])\n else:\n op.append(g[-1])\n op.append(g[-3])\nelse:\n op.append(g[-1])\n op.append(i)\nprint(op[0],op[1])\n \n \n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nif l[-1]==l[-2]:\n print(l[-1],l[-2])\nelse:\n l.sort(reverse=True)\n for i in range(n):\n if l[0]%l[i]!=0:\n print(l[i],l[0])\n break\n else:\n print(l[0],l[-1])"}, {"source_code": "z,w,m=input,int,sorted\nn=int(z())\nl=list(set(map(int,z().split())))\nf=max(l)\nl.remove(f)\nprint(f,max(l))\n \n\n"}, {"source_code": "def solve():\n input()\n ar = []\n for i in (input().split(' ')):\n if i.isdigit():\n ar.append(int(i))\n print(ar)\n ar.sort()\n x = ar[-1]\n ary = []\n for i in ar:\n if x % i != 0:\n ary.append(i)\n y = ary[-1]\n print(x,' ',y)\n \n \nsolve()"}, {"source_code": "def check(st1, st):\n res = 0\n for i in range(len(st)):\n if st[i] != st1[i%3]:\n res += 1\n return res\nn = int(input())\ns = str(input())\ncolors = ['RGB', 'RBG', 'BGR', 'BRG', 'GRB', 'GBR']\nmn = int(n+1)\nfor x in range(6):\n mn = min(mn, check(colors[x], s))\nprint(mn)\n\nfor it in colors:\n if check(it, s) == mn:\n st = 0\n while st < n:\n print(it[st%3], end = '')\n st += 1\n break;\n"}, {"source_code": "##################################### \n \n# import libraries for input/ output handling \n# on generic level \nimport sys \n\n# use this for interactive problems\ndef fprint(x):\n print(x, flush=True)\n \n# using this print for fast\ndef qprint(x):\n sys.stdout.write(str(x) + \"\\n\")\n \n# using this input\ndef input():\n return sys.stdin.readline()\n \n##################################### \n# code below\nimport collections\ndef lcm(x, y):\n if x > y:\n greater = x\n else:\n greater = y\n\n return greater\n\n\nn = int(input())\n\nlist_div = list(map(int, input().split()))\nlist_fir = []\nlist_sec = []\n\nfor item, count in collections.Counter(list_div).items():\n if count == 1:\n list_fir.append(item)\n else:\n list_fir.append(item)\n list_sec.append(item)\n\nfirst_num = 1\nsecond_num = 1\n\nfor num in list_fir:\n if first_num % num == 0 or num % first_num == 0:\n first_num = lcm(first_num, num)\n else:\n list_sec.append(num)\n\nfor num in list_sec:\n second_num = lcm(second_num, num)\n\nprint(str(first_num) + \" \" + str(second_num))\n "}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\na.sort(reverse = True)\nfl = False\nk1 = 0\nk2 = 0\ns = set(a)\nfor i in range(len(a)):\n for j in range(len(a)):\n used = [False] * n\n for t in range(len(a)):\n if ((a[i] % a[t]) == 0) and (used[t] == False):\n k1 += 1\n used[t] = True\n for t in range(len(a)):\n if ((a[j] % a[t]) == 0) and (used[t] == False):\n k2 += 1\n used[t] = True\n if k1 + k2 == len(a):\n print(a[i], a[j])\n #print(k1, k2)\n fl = True\n break\n else:\n k1 = 0\n k2 = 0\n if fl == True:\n break"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nle=len(l)\nif l[le-1]%l[le-2]== 0:\n for i in range(le-1,0,-1):\n if l[le-1]%l[i]!=0:\n print(l[le-1],' ',l[i])\n break\nelse:\n print(l[le-1],' ',l[le-2])\n"}, {"source_code": "from fractions import gcd\nfrom math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin, floor, atan\nfrom itertools import *\nfrom fractions import Fraction\nimport string\nimport copy\nimport random\nimport bisect\nfrom decimal import *\nfrom collections import deque\nfrom sys import *\ndigs = string.digits + string.ascii_letters\n\ndef id_generator(size=20, chars=string.digits):\n return ''.join(random.choice(chars) for _ in range(size))\n \ndef mp():\n return map(int,str(raw_input()).strip().split())\n\nclear=stdout.flush()\n\nn=input()\nl=list(mp())\nl.sort()\nx=l[-1]\ni=n-1\nwhile i>0:\n\tif l[i]==l[i-1]:\n\t\tprint x,l[i]\n\t\texit()\n\telse:\n\t\tif l[i]%l[i-1]==0:\n\t\t\tpass\n\t\telse:\n\t\t\tprint x,l[i-1]\n\t\t\texit()\n\ti-=1"}, {"source_code": "import math\ndef lcm(a,b): \n return (a*b) / math.gcd(a,b)\nn = int(input())\nl = list(list(map(int, input().split())))\nl = sorted(l)\none_element = l[-1]\ndoubles = []\n#print(doubles)\nfor i in l:\n #print(i, list(filter(lambda x: x==i, l)), len(list(filter(lambda x: x==i, l)))>1)\n if len(list(filter(lambda x: x==i, l)))>1:\n #print(\"in\", i)\n if i not in doubles:\n #print(i)\n doubles.append(i)\n#print(doubles)\nsec = 1\nfor a in doubles:\n sec = lcm(int(a), int(sec))\ndef find(e, l):\n if e==1:\n return 1\n ans = list(filter(lambda x: x%e==0, l))\n return sorted(ans)[-2]\nprint( one_element ,find(sec, l) )\n"}, {"source_code": "def solve(n, values):\n values = sorted(values, reverse=True)\n x = values[0]\n index = 1\n while index < n and (x % values[index]) == 0:\n index += 1\n if index < n:\n return x, values[index]\n return x, x\n\nn = int(input())\nvalues = list(map(int, input().strip().split(' ')))\nx, y = solve(n, values)\nprint('{} {}'.format(x, y))\n"}, {"source_code": "\nn = int(input())\narr = list(map(int,input().strip().split(\" \")))\n\narr.sort(reverse = True)\ni = arr[0]\nfor j in arr:\n\tif(i%j):\n\t\tprint(i,j)\n\t\tbreak\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nx=max(a)\nfor i in range(0,n-1,2):\n if(a[i]*a[i+1]!=x):\n y=a[i]*a[i+1]\nprint(x,y)\n \n \n"}, {"source_code": "from functools import reduce\n\nif __name__ == '__main__':\n n = int(input())\n d = list(map(int, input().split()))\n d.sort(reverse=True)\n m = d[0]\n good = []\n bad = []\n for i in d[1:]:\n if m % i == 0:\n m //= i\n bad.append(i)\n else:\n good.append(i)\n\n fine = False\n for i in good[1:]:\n if good[0] % i != 0:\n fine = True\n break\n\n if fine:\n print(d[0], reduce(lambda x, acc: x*acc, good, 1))\n else:\n print(d[0], good[0])\n\n"}, {"source_code": "from functools import reduce\nfrom math import sqrt\n\n\ndef factors(n):\n step = 2 if n % 2 else 1\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(sqrt(n)) + 1, step) if n % i == 0)))\nq=int(input())\nar=list(map(int,input().split()))\na=max(ar)\nd=list(factors(a))\nfor t in ar:\n if t in d:\n ar.remove(t)\nb=max(ar)\nprint(str(a)+\" \"+str(b))"}, {"source_code": "n=int(input());a=sorted(list(map(int,input().split())));s=a[-1]\nif a.count(a[-1])==2:print(a[-1],a[-1]);exit()\nfor i in range(len(a)-1,-1,-1):\n if s%a[i]!=0:print(s,a[i]);exit()"}, {"source_code": "import sys\n\nnb_test = 0\n\nidx = 0\nfor line in sys.stdin:\n if idx != 0:\n list_divisors = map(int, line.strip().split(\" \"))\n a, b = list_divisors[0], list_divisors[1]\n a, b = (b, a) if a > b else (a, b)\n\n for d in list_divisors[2:]:\n if d >= b:\n if d % b == 0:\n b = d\n elif d % a == 0:\n a = d\n\n a, b = (b, a) if a > b else (a, b)\n else:\n if d >= a:\n if d % a == 0:\n a = d\n\n sys.stdout.write(\"%d %d\\n\" % (a, b))\n idx += 1\n"}, {"source_code": "n = int(input())\nmas = list(map(int, input().split()))\nx = max(mas)\nmas.remove(x)\nnew_mas = [1]\nfor r in mas:\n if x % r != 0:\n new_mas.append(r)\ny = max(new_mas)\nprint(x, y)\n"}, {"source_code": "#\t!/usr/bin/env python3\n#\tcoding: UTF-8\n#\tModified: <23/Jan/2019 08:13:00 PM>\n\n\n#\t\u272a H4WK3yE\u4e61\n#\tMohd. Farhan Tahir\n#\tIndian Institute Of Information Technology (IIIT),Gwalior\n\n#\tQuestion Link\n#\n#\n\n# ///==========Libraries, Constants and Functions=============///\n\n\nimport sys\n\ninf = float(\"inf\")\nmod = 1000000007\n\n\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\n\n\ndef get_ints(): return map(int, sys.stdin.readline().split())\n\n\ndef input(): return sys.stdin.readline()\n\n# ///==========MAIN=============///\n\n\ndef main():\n n = int(input())\n arr = get_array()\n from collections import Counter\n count = Counter(arr)\n x, y = 1, 1\n for i in count:\n if count[i] == 2:\n x *= i\n y *= i\n else:\n x *= i\n print(x, y)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def gcd(a, b): \n if a == 0 : \n return b \n \n return gcd(b%a, a) \nn=int(raw_input())\na=list(map(int,raw_input().split()))\nprint a\nfor i in xrange(n-2,0,-1):\n if a[-1] % a[i]!= 0:\n print a[-1],a[i]\n break"}, {"source_code": "n = int(input())\ndivisiors = list(map(int, input().split()))\n\ndivisiors.sort()\n\nx = divisiors[-1]\n\ndivisorY = list()\n\ndivisorY.append(1)\n\nfor i in divisiors:\n if x % i != 0 :\n divisorY.append(i)\n\ndivisorY.sort()\n\ny = divisorY[-1]\n\nprint(x, y)\n"}, {"source_code": "import math\nn=int(input())\nl=list(map(int,input().split()))\nl.sort()\na=l[-1]\nfor i in range(n):\n if a%l[i]==0:\n l[i]=0\nl.sort()\nb=l[-1]\nif (b==0):\n b=1\nprint(a,b)\n \n "}, {"source_code": "n=int(input())\na=input().split()\nmn = -1\nmin=-1\nfor i in a:\n if int(i)>mn:\n mn=int(i)\nfor i in a:\n if int(i) == mn:\n continue\n if mn%int(i)==0:\n continue\n if min<int(i):\n min=int(i)\nprint(str(mn)+' '+str(min))\n\n"}, {"source_code": "from functools import reduce\n\nif __name__ == '__main__':\n n = int(input())\n d = list(map(int, input().split()))\n m = n // 2\n print(reduce(lambda x, acc: x*acc, d[:m], 1), reduce(lambda x, acc: x*acc, d[m:], 1))\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nt=0\nfor i in range(n-1):\n if l[i]==l[i+1]:\n t=max(t,l[i])\na=l[-1]\nb=0\nfor i in range(n):\n if l[i]%t==0 and l[i]!=a:\n b=max(b,l[i])\nif b==0:\n b=a\nprint(a,b)\n \n "}, {"source_code": "n=int(input())\nli=list(map(int,input().split()))\nli.sort(reverse=True)\n#print(li)\nl=[]\nfor i in li:\n\tif li.count(i)==2:\n\t\tl.append(i)\nl=list(set(l))\nl.sort(reverse=True)\n#print(l)\nfor i in li[1:]:\n\tif li[0]%i!=0:\n\t\tprint(li[0],i)\n\t\texit(0)\nif li[0]%li[1]!=0:\n\tprint(li[0],li[1])\nelif len(l)==1:\n\t#li.sort(reverse=True)\n\tif li[0]%li[1]==0:\n\t\tprint(1,max(li))\n\telse:\n\t\tprint(li[0],li[1])\nelif len(li)==4:\n\t#li.sort(reverse=True)\n\tprint(li[0],li[1])\nelif len(l)>3:\n\tl.sort(reverse=True)\n\tprint(l[0],max(li))\nelse:\n\tfor i in li:\n\t\tif i%l[0]==0 and i%l[1]==0 and i!=l[0] and i!=l[1]:\n\t\t\tprint(i,end=\" \")"}, {"source_code": "n = int(input())\nmas = list(map(int, input().split()))\nx = max(mas)\nmas.remove(x)\nnew_mas = []\na = set()\nfor r in mas:\n if x % r == 0 and r not in a:\n a.add(r)\n elif x % r == 0 and r in a:\n new_mas.append(r)\n else:\n new_mas.append(r)\ny = max(new_mas)\nprint(x, y)\n"}, {"source_code": "x = int(input())\ny = map(int,input().split())\ny = sorted(list(y))\nf = y[-1]\nl = []\nfor i in range(len(y)):\n\tif f%y[i] != 0:\n\t\tl.append(y[i])\nprint(f,max(l) if l != [] else y[-2])"}, {"source_code": "n = int(raw_input())\nl = [int(i) for i in raw_input().split()]\nd = {}\nfor i in l:\n if i not in d:\n d[i] = 1\n else:\n d[i] += 1\n# print d\nl = sorted(l)\n# print l\nm = []\nfor i , j in d.items():\n if j == 2:\n m.append(i)\n# print m\ns = max(m)\nif len(m) == 1:\n x = s\n ind = l.index(s)\n for i in range(ind+1, len(l)):\n if l[i] % s == 0:\n y = l[i]\n print x , y\nelse:\n\n ind = l.index(s)\n ind += 1\n # print ind\n x , y = 0 , 0\n flag = False\n for i in range(ind+1 , len(l)-1):\n if l[i] % s == 0 :\n x = l[i]\n for j in range(i+1 , len(l)):\n if l[j] % s == 0:\n y = l[j]\n \n \n\n if x == 0 and y == 0:\n x = s\n y = l[len(l) - 1]\n print x , y\n else:\n print x , y"}, {"source_code": "N = int(input())\nar = [int(x) for x in input().split()]\na = 1\nb = 1\ni = 0\nar.sort()\nwhile i < N:\n\tif i > 0 and ar[i - 1] == ar[i]:\n\t\tb = b * ar[i]\n\telse:\n\t\ta = a * ar[i]\n\ti += 1\n\nprint(a, b)"}, {"source_code": "import math\ndef finddivisors(num):\n divisors=[]\n i=1\n while i**2<=num:\n if math.sqrt(num)==i:\n divisors.append(i)\n elif num%i==0:\n divisors.append(i)\n divisors.append(int(num/i))\n i+=1\n divisors.sort()\n return divisors\nn=int(input())\nd=list(map(int,input().split()))\nd.sort()\nx=d[-1]\na=finddivisors(x)\na=list(set(d)-set(a))\na.sort()\nif len(a)==0:\n a=[1]\ny=a[-1]\nprint(x,y)"}, {"source_code": "n = int(raw_input())\nl = map(int, raw_input().split())\nx = max(l)\nremovidos = [False]*(x+1)\nremovidos[x] = True\nl.remove(x)\nfor i in l:\n if not removidos[i] and x%i==0:\n l.remove(i)\n removidos[i] = True\ny = max(l)\nprint x,y"}, {"source_code": "\"\"\"Template for Python Competitive Programmers prepared by pa.n.ik, kabeer seth and Mayank Chaudhary \"\"\"\n\n# to use the print and division function of Python3\nfrom __future__ import division, print_function\n\n\"\"\"value of mod\"\"\"\nMOD = 998244353\nmod = 10**9 + 7\n\n\"\"\"use resource\"\"\"\n# import resource\n# resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n\n\"\"\"for factorial\"\"\"\n\ndef prepare_factorial():\n fact = [1]\n for i in range(1, 100005):\n fact.append((fact[-1] * i) % mod)\n ifact = [0] * 100005\n ifact[100004] = pow(fact[100004], mod - 2, mod)\n for i in range(100004, 0, -1):\n ifact[i - 1] = (i * ifact[i]) % mod\n return fact, ifact\n\n\"\"\"uncomment next 4 lines while doing recursion based question\"\"\"\n# import threading\n# threading.stack_size(1<<27)\nimport sys\n# sys.setrecursionlimit(10000)\n\n\n\"\"\"uncomment modules according to your need\"\"\"\nfrom bisect import bisect_left, bisect_right, insort\n# from itertools import repeat\nfrom math import floor, ceil, sqrt, degrees, atan, pi, log, sin, radians\nfrom heapq import heappop, heapify, heappush\n# from random import randint as rn\n# from Queue import Queue as Q\nfrom collections import Counter, defaultdict, deque\n# from copy import deepcopy\n# from decimal import *\n# import re\n# import operator\n\n\ndef modinv(n, p):\n return pow(n, p - 2, p)\n\ndef ncr(n, r, fact, ifact): # for using this uncomment the lines calculating fact and ifact\n t = (fact[n] * (ifact[r] * ifact[n-r]) % mod) % mod\n return t\n\n\ndef intarray(): return map(int, sys.stdin.readline().strip().split())\ndef array(): return list(map(int, sys.stdin.readline().strip().split()))\ndef input(): return sys.stdin.readline().strip()\n\n\"\"\"*****************************************************************************************\"\"\"\n\ndef GCD(x, y):\n while y:\n x, y = y, x % y\n return x\n\ndef lcm(x, y):\n return (x * y)//(GCD(x, y))\n\ndef get_xor(n):\n return [n, 1, n+1, 0][n % 4]\n\ndef fast_expo(a, b):\n res = 1\n while b:\n if b&1:\n res = (res * a)\n res %= MOD\n b -= 1\n else:\n a = (a* a)\n a %= MOD\n b>>=1\n res %= MOD\n return res\n\ndef get_n(P): # this function returns the maximum n for which Summation(n) <= Sum\n\n ans = (-1 + sqrt(1 + 8*P))//2\n return ans\n\n\"\"\" ********************************************************************************************* \"\"\"\n\"\"\"\"\n array() # for araay\n intarray() # for map array\n yha pe SAMPLE INPUT\n7\n1 2 4 8 16 1 2\n\n\n\n\"\"\"\n\"\"\" OM SAI RAM \"\"\"\ndef finddivisor(m,d):\n #print(ceil(sqrt(m))+1)\n for i in range(1,ceil(sqrt(m))):\n if m%i==0:\n d[i]-=1\n if i==m//i:\n continue\n else:\n d[m//i]-=1\n\ndef solve():\n n = int(input())\n a= array()\n d = defaultdict(int)\n for i in a:\n d[i]+=1\n m = max(a)\n finddivisor(m,d)\n maxi = 0\n for i in d.keys():\n if d[i]>0:\n maxi = max(maxi,i)\n print(m,maxi)\n\n\n\n return\n\ndef main():\n T = 1\n while T:\n solve()\n T -= 1\n\n\n\n\n\"\"\"OM SAI RAM \"\"\"\n\"\"\" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------\"\"\"\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\n\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO, self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill();\n self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\n\nclass IOWrapper(IOBase):\n\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\n self.read = lambda: self.buffer.read().decode('ascii')\n self.readline = lambda: self.buffer.readline().decode('ascii')\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\n\n\"\"\" main function\"\"\"\n\nif __name__ == '__main__':\n main()\n # threading.Thread(target=main).start()"}, {"source_code": "n=int(input())\ns=sorted(map(int,input().split()))\nans=s[-1]\nfor i in range(n-1,-1,-1):\n if ans%s[i]or ans==s[i]:print(ans,s[i]);break"}, {"source_code": "from functools import reduce\nfrom math import sqrt\n\n\ndef factors(n):\n step = 2 if n % 2 else 1\n return set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(sqrt(n)) + 1, step) if n % i == 0)))\nq=int(input())\nar=list(map(int,input().split()))\na=max(ar)\nd=list(factors(a))\nfor t in ar:\n if t in d:\n ar.remove(t)\nb=max(ar)\nprint(str(a)+\" \"+str(b))"}, {"source_code": "\nn = int(input())\narr = list(map(int,input().strip().split(\" \")))\n\narr.sort(reverse = True)\nprint(arr)\ni = arr[0]\nfor j in arr:\n\tif(arr.count(j)>1 or i%j):\n\t\tprint(i,j)\n\t\tbreak\n"}, {"source_code": "def main():\n n = int(input())\n divisors = list(map(int,input().split()))\n divisors.sort(reverse = True)\n first = divisors[0]\n second = divisors[1]\n for i in range(n):\n if first%divisors[i] != 0:\n second = divisors[i]\n break\n\n print (first,second)\n\nmain()\n"}, {"source_code": "def div(a):\n\tmax_val = max(a)\n\tres = factors(max_val)\n\tfor i in a:\n\t\tif i not in res:\n\t\t\tprint(max_val,i)\n\t\t\treturn\n\ndef factors(n):\n\tx = []\n\tfor i in range(1,n+1):\n\t\tif n%i == 0:\n\t\t\tx.append(i)\n\treturn x\n\nn = int(input())\na = list(map(int,input().split())) \ndiv(a)\n"}, {"source_code": "def solve():\n input()\n ar = []\n for i in (input().split(' ')):\n if i.isdigit():\n ar.append(int(i))\n print(ar)\n ar.sort()\n x = ar[-1]\n ary = []\n for i in ar:\n if x % i != 0:\n ary.append(i)\n y = ary[-1]\n print(x,' ',y)\n \n \nsolve()"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nmaxi = -1\nimaxi = -1\nfor i in range(n):\n if(maxi < l[i]):\n maxi = l[i]\n imaxi = i\n \nmaxi2 = -1\nfor i in range(n):\n if(i != imaxi and (maxi%l[i] !=0 or l[i] == 1 or maxi == l[i])):\n maxi2 = max(maxi2,l[i])"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nl.reverse()\nif l[0]%l[1] != 0:\n print(l[0],' ',l[1])\nelse:\n for i in l:\n if l[0]%i != 0 and i!=l[0]:\n print(l[0],' ',i)\n break\n\n \n"}, {"source_code": "cnt = lambda s, x: s.count(x)\nii = lambda: int(input())\nsi = lambda : input()\nf = lambda : map(int,input().split())\nil = lambda : list(map(int,input().split()))\nn=ii()\nl=sorted(il())[::-1]\ni=0\nwhile 1:\n if l[i]==l[i+1]:\n break\n i+=1\nd=l[i]\nj=1\nwhile j<=i:\n if l[j]%d==0:\n break\n j+=1\nprint(l[0],l[j])\n"}, {"source_code": "n=int(input())\ns=set(map(int,input().split()))\nL=[]\nfor e in s:\n\tL.append(e)\nN=[0]*len(L)\nfor i in range(0,len(L)):\t\n\tfor j in range(0,len(L)):\n\t\tif(L[i]%L[j]==0):\n\t\t\tN[i]+=1\n\nfor i in range(1,len(N)):\n\tfor j in range(0,i):\n\t\tif(N[i]+N[j]==n):\n\t\t\tprint(str(L[i])+\" \"+str(L[j]))\n\t\t\tbreak\n\n\n"}, {"source_code": "a = int(input())\nl = list(map(int,input().split()))\nt = list(set(l))\nprint(t)\nt1 = []\nk = 1\nfor i in range(len(t)):\n\tk = k*t[i]\n\tl1 = l.count(t[i])\n\tt1.append(l1)\nprint(t1)\nprint(k,end=\" \")\nk = 1\nfor j in range(len(t)):\n\tk = k*(t[i]**(t1[i]-1))\nprint(k)\n"}, {"source_code": "n=int(input())\ng=[int(g) for g in input().split()]\ng.sort()\nl=[]\nop=[]\nfor i in reversed(g):\n if g[-1]%i!=0:\n l.append(i)\n break\nif l==[]:\n if g[-1]!=g[-2]:\n op.append(g[-1])\n op.append(g[-2])\n else:\n op.append(g[-1])\n op.append(g[-3])\nelse:\n op.append(g[-1])\n op.append(i)\nprint(op[0],op[1])\n \n \n"}, {"source_code": "# For taking integer inputs.\nimport math\n\n\ndef inp():\n return(int(input()))\n\n\n# For taking List inputs.\ndef inlist():\n return(list(map(int, input().split())))\n\n\n# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\n# For taking space seperated integer variable inputs.\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\n\nd = invr()\n\nd = sorted(d, reverse=True)\n\na = d[0]\nb = 1\n\nfor i in range(1, n):\n if a == d[i]:\n b = d[i]\n break\n elif a % d[i] != 0:\n b *= d[i]\nprint(a, b)\n"}, {"source_code": "from fractions import gcd\nfrom math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin, floor, atan\nfrom itertools import *\nfrom fractions import Fraction\nimport string\nimport copy\nimport random\nimport bisect\nfrom decimal import *\nfrom collections import deque\nfrom sys import *\ndigs = string.digits + string.ascii_letters\n\ndef id_generator(size=20, chars=string.digits):\n return ''.join(random.choice(chars) for _ in range(size))\n \ndef mp():\n return map(int,str(raw_input()).strip().split())\n\nclear=stdout.flush()\n\nn=input()\nl=list(mp())\nl.sort()\nx=l[-1]\ni=n-1\nwhile i>0:\n\tif l[i]==l[i-1]:\n\t\tprint x,l[i]\n\t\texit()\n\telse:\n\t\tif l[i]%l[i-1]==0:\n\t\t\tpass\n\t\telse:\n\t\t\tprint x,l[i-1]\n\t\t\texit()\n\ti-=1"}, {"source_code": "from math import gcd\n\nn = int(input())\nA = list(map(int, input().split()))\nanswer = 1\nfor i in range(n):\n answer *= (A[i] // gcd(A[i], answer))\nprint(1, answer)"}, {"source_code": "# ///==========Libraries, Constants and Functions=============///\n#mkraghav\nimport sys\n\ninf = float(\"inf\")\nmod = 1000000007\n\n\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\n\n\ndef get_ints(): return map(int, sys.stdin.readline().split())\n\n\ndef input(): return sys.stdin.readline()\n\ndef int1():return int(input())\n\nimport string\n\nimport math\n\nfrom itertools import combinations\n# ///==========MAIN=============///\n\n\ndef main():\n n=int1()\n a=get_array()\n x1=max(a)\n l=[]\n l1=[]\n i=1\n while i<=x1:\n if x1%i==0:\n l.append(i)\n i=i+1\n for i in a:\n if i not in l:\n l1.append(i)\n x2=max(l1)\n print(x1,x2)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na=sorted(a)\nx=a[-1]\ny=a[-2]\na[-1]=0\nfor i in range(len(a)-1):\n if(x%a[i] == 0):\n a[i] = 0\nif(a.count(0) == len(a)):\n print(x,y)\nelse:\n for i in range(len(a)):\n if(a[i]!=0):\n y=a[i]\n break\n print(x,y)"}, {"source_code": "n=int(input())\ng=[int(g) for g in input().split()]\ng.sort()\nfor i in reversed(g):\n if g[-1]%i!=0:\n print(g[-1],i)\n break\n"}, {"source_code": "k = int(input())\n\ndic = {}\n\nx = -1\n\nfor a in map(int, input().split()):\n if a > x:\n x = a\n if a in dic.keys():\n dic.update({a: dic.get(a)+1})\n else:\n dic.update({a: 1})\n\ny = -1\n\nfor b in range(1, x+1):\n if b in dic.keys():\n if x % b == 0 and dic.get(b) ==2 and b > y:\n y = b\n if x % b != 0 and b > y:\n y = b\n "}, {"source_code": "n = int(raw_input())\nl=[int(x) for x in raw_input().split()]\nl.sort(reverse = True)\nprint l[0]\nif n==4:\n print l[0]\nelse:\n \n for i in range(len(l)-1):\n if l[0] % l[i+1] != 0:\n print l[i+1]\n break\n \n if i==n-2:\n if l[-1] == 1:\n print \"1\"\n else:\n print l[0]\n"}, {"source_code": "def gcd(a,b):\n if(b==0):\n return a\n return gcd(b, a%b)\nn = int(input())\nl = list(map(int, input().split()))\nl.sort()\na=l[-1]\nb=0\nfor i in range(n-2,-1,-1):\n if(gcd(a, l[i])!=l[i]):\n b=l[i]\n break\nprint(a,b)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nm=max([i for i in l if l.count(i)==2])\nl.sort(reverse=True)\nif m==1:\n print(l[-1],l[-2])\nelse:\n for i in l:\n if i%m==0 and i!=m:\n print(i,end=' ')\n"}, {"source_code": "from functools import reduce\n\nif __name__ == '__main__':\n n = int(input())\n d = list(map(int, input().split()))\n d.sort(reverse=True)\n a = d[0]\n for j in range(1, n):\n good = True\n b = d[j]\n for k in range(j + 1, n):\n if a % d[k] == 0 or b % d[k] == 0:\n continue\n else:\n good = False\n break\n if good:\n print(a, d[j])\n exit(0)\n\n\n\n"}, {"source_code": "def solve(x,y,l):\n for e in l:\n #print(\"x : \",x,\" y : \",y,\" e :\", e)\n if( (x % e == 0 or y % e == 0) == False):\n #print(\"exit\\n\",x % e == 0 ,y % e == 0 , (x % e == 0 or y % e == 0))\n return False\n #print(\"good\\n\")\n return True\n\n\nn = int(input())\nl = list(map(int,input().split()))\nl.sort(reverse = True)\n#print(l)\nfor i in range(n):\n for j in range(i+1,n):\n if(solve(l[i],l[j],l)):\n print(l[i],l[j])\n break\n"}, {"source_code": "n=int(input())\ng=[int(g) for g in input().split()]\ng.sort()\nl=[]\nfor i in reversed(g):\n if g[-1]%i!=0:\n l.append(i)\n break\nif l==[]:\n print(g[-1],g[-2])\nelse:\n print(g[-1],l[0])\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl=sorted(l,reverse=True)\nx=l[0]\nfor i in range(1,len(l)):\n if(x%l[i]!=0):\n print(x,l[i])\n break"}, {"source_code": "def factors(l):\n m= max(l)\n for i in range(1,int(m**(0.5))+1):\n if m%i == 0:\n if i in l:\n l.remove(i)\n if m//i in l:\n l.remove(m//i)\n return max(l)\nn = int(input())\nl = list(map(int,input().split()))\nif len(l)==2:\n print(*l)\nelse:\n print(max(l),end = \" \")\n print(factors(l))"}, {"source_code": "\nn = int(input())\narr = list(map(int,input().strip().split(\" \")))\n\narr.sort(reverse = True)\ni = arr[0]\nfor j in arr:\n\tif(i%j):\n\t\tprint(i,j)\n\t\tbreak\n"}, {"source_code": "from collections import Counter\nn = int(input())\narr = list(map(int,filter(None,input().split(' '))))\narr = sorted(arr)\ndef get_div(n):\n li = []\n for i in range(1,int(n/2)+1):\n if n%i==0:\n li.append(i)\n li.append(n)\n return li\nn1 = arr[-1]\nli2 = get_div(n1)\nprint(li2)\nli3 = list((Counter(arr)-Counter(li2)).elements())\nn2 = li3[-1]\nprint(n1,' ',n2)\n"}, {"source_code": "# cf 1108 B (1100)\nimport math\n\nn = int(input())\nA = list(map(int, input().split()))\n\nA.sort(reverse=True)\n\nprint(A)\nx = A[0]\ny = 1\nfor m in A[1:]:\n if m == 1:\n break\n if x % m == 0:\n y = m\n if x == y:\n break\n elif y == m:\n break\n else:\n y = m\n break\nprint(x, y)\n\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\nfrom math import factorial\nfrom collections import Counter, defaultdict\nfrom heapq import heapify, heappop, heappush\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\nmod = 998244353\nINF = float('inf')\nfrom math import gcd\n\n# ------------------------------\n\n\ndef main():\n n = N()\n arr = RLL()\n arr.sort()\n a = arr[-1]\n b = -1\n for i in range(n-1, -1, -1):\n if a%arr[i]!=0:\n print(*[a, arr[i]])\n break\n print(*[arr[-1], arr[-2]])\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "# Divisors of Two Integers - codeforces\n#\n\nimport math\nimport sys\ninput = sys.stdin.readline\n\n\ndef inp():\n return int(input())\n\n\ndef invr():\n return list(map(int, input().split()))\n\n\nn = inp()\nd = invr()\nd.sort(reverse=1)\n# d.reverse()\n\n# print(d)\n\na = d.pop(0)\nb = 0\n\nwork = 1\n\nwhile len(d) > 0:\n e = d.pop(0)\n if a % e != 0:\n b = e\n break\n\nprint(a, b if b else a)\n"}, {"source_code": "n = input()\nlist = map(int, raw_input().split())\nlist.sort()\nlist.reverse()\nprint list[0],\na=list[0]\nfor i in range(n):\n if a%list[i]==0:\n list[i]=0\nlist.sort()\nlist.reverse()\nif list[0]!=0:\n print 0\nelse:\n print 1"}, {"source_code": "from sys import stdin, stdout\nn = int(input())\ndivs = list(map(int, input().split()))\n\nmp = {}\nfor num in divs:\n if num not in mp.keys():\n mp[num] = 1\n else:\n mp[num] += 1\n\nmaxi = max(divs)\n\n\n\ndivs_maxi = []\n\nfor i in range(1,maxi//2):\n\tif (maxi % i) == 0 and (i not in divs_maxi):\n\t\tdivs_maxi.append(i)\n\t\tdivs_maxi.append(maxi//i)\n\nset_divs =set(divs)\nset_maxi_divs = set(divs_maxi)\nc = list(set_divs.difference(set_maxi_divs))\n\nif len(c) > 0:\n\tprint(str(max(c)) + \" \" + str(maxi))\nelse:\n\tprint(str(maxi) + \" \" + str(maxi))\n\t\t\n# print(maxi)\n# print(divs_maxi)\n\n# for num in divs_maxi:\n# if num in mp.keys():\n# mp[num] -= 1\n# if mp[num] == 0:\n# mp.pop(num, 'None')\n\n# if len(mp.keys()) > 0:\n# maxi_2 = max(mp.keys())\n# else:\n# maxi_2 = maxi\n\n# print(str(maxi) + \" \" + str(maxi_2))\n"}, {"source_code": "def gcd(a, b): \n if a == 0 : \n return b \n \n return gcd(b%a, a) \nn=int(raw_input())\na=list(map(int,raw_input().split()))\na = sorted(a)\nfor i in xrange(n-1,0,-1):\n if a[i] % a[i-1]!= 0:\n print a[i],a[i-1]\n break"}, {"source_code": "n = int(input())\nact = list(map(int,input().split()))\np = sorted(dict.fromkeys(act))\na = max(p)\nb=a\nrej = []\nmc = 0\nm1= act.count(1)\nfor i in range(len(p)-1, -1,-1):\n mc = max(mc, act.count(p[i]))\nfor i in range(len(p)-1,-1,-1):\n if(a%p[i]!=0):\n b=p[i]\n break\nif(m1>mc):\n b=1\nprint(a,b)\n"}, {"source_code": "n=int(input())\nli=list(map(int,input().split()))\n#li.sort()\n#print(li)\nl=[]\nfor i in li:\n\tif li.count(i)==2:\n\t\tl.append(i)\nl=list(set(l))\nl.sort(reverse=True)\nprint(l)\nif len(l)==1 and l[0]==1:\n\tprint(1,max(li))\nelif len(l)==1:\n\tli.sort(reverse=True)\n\tprint(li[0],li[1])\nelif len(li)==4:\n\tli.sort(reverse=True)\n\tprint(li[0],li[1])\nelif len(l)>3:\n\tl.sort(reverse=True)\n\tprint(l[0],max(li))\nelse:\n\tfor i in li:\n\t\tif i%l[0]==0 and i%l[1]==0 and i!=l[0] and i!=l[1]:\n\t\t\tprint(i,end=\" \")"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nt=0\nfor i in range(n-1):\n if l[i]==l[i+1]:\n t=max(t,l[i])\na=l[-1]\nb=0\nfor i in range(n):\n if l[i]%t==0 and l[i]!=a:\n b=max(b,l[i])\nif b==0:\n b=a\nprint(a,b)\n \n "}, {"source_code": "def pro(x):\n p,m=1,1\n if(len(x)==2):\n \tm=0\n for i in range(m,len(x)):\n p*=x[i]\n return p\nn=int(input())\nl=[int(i) for i in input().split()]\nl.sort(reverse=True)\nz=l[:]\nfor j in l:\n for i in range(1,j+1):\n if(j%i==0):\n l.remove(i)\n #print(j,l)\n N=pro(l)\n if(N in l):\n print(j,N)\n break\n l=z[:]"}, {"source_code": "def read_array():\n x = []\n x1 = []\n x = input()\n x = x.split(' ')\n for r in range(len(x)):\n x1.append(int(x[r]))\n return x1\ndef finding_two_div(x):\n x.sort(reverse=True)\n x1=x[0]\n for i in range(1,len(x)):\n #print(x1,x[i],x1%x[i])\n if x1%x[i]!=0 or x[i]==x1:\n return x1,x[i]\n if x[1]==x[2]:\n return x1,x[1]\n else:\n return x1,1\ninput()\na,b=finding_two_div(read_array())\nprint(a,b)"}, {"source_code": "# import sys \n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out1.out\",'w')\nn=int(input())\na=list(map(int,input().split()))\ns=set(a)\na=list(a)\na.sort()\nx=a[-1]\nfor i in range(len(a)):\n\tif x%a[i]==0:\n\t\ta[i]=0\n\t\ny=max(a)\nprint(x,y)\t\t"}, {"source_code": "n = int(raw_input())\nl = [int(i) for i in raw_input().split()]\nl = sorted(l)\n# print l\na = []\nm = l[-1]\n# print m\n# print l\nfor i in l:\n if m % i != 0:\n a.append(i)\n\nx = m\ntry:\n y = max(a)\nexcept:\n y = x\nprint x , y"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl=sorted(l,reverse=True)\nx=l[0]\nfor i in range(1,len(l)):\n if(x%l[i]!=0):\n print(x,l[i])\n break\nelse:\n print(x,l[1])"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\n\narr.sort()\nprint(arr[-1],end=' ')\nfor i in range(n-2,0,-1):\n if arr[-1]%arr[i]!=0:\n print(arr[i])\n break\n elif arr.count(arr[i])>1:\n print(arr[i])\n break"}, {"source_code": "n=int(input())\nar=sorted(list(map(int,input().split())))\nm=max(ar)\nu=max([k%m for k in ar])\nprint(m,u)\n "}, {"source_code": "\nn = int(input())\n\nl = list(map(int,input().split()))\n\nl.sort()\n\nx = l[-1]\n# print(l)\nhash = set()\nfor i in l:\n if x%i == 0 and i not in hash:\n # print(i)\n hash.add(i)\n l.remove(i)\n\nl.remove(x)\n\nl.sort()\ny = l[-1]\n\nprint(x,y)\n\n\n"}], "src_uid": "868407df0a93085057d06367aecaf9be"} {"source_code": "import io, os\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\ndef binarySearch(arr,l,r,val):\n while l<=r:\n mid=(l+r)//2\n if arr[mid]==val:\n ans=mid\n break\n elif arr[mid]<val:\n ans=mid\n l=mid+1\n else:\n r=mid-1\n return ans\ndef fib(k,s):\n arr=[]\n i=1\n temp=True\n l=0\n while temp:\n if k>i:\n arr.append(0)\n l+=1\n if arr[-1]>s:\n arr.pop()\n l-=1\n break\n i=k\n elif k==i:\n arr.append(1)\n l+=1\n if arr[-1]>s:\n arr.pop()\n l-=1\n break\n i+=1\n else:\n if l<=k:\n num=sum(arr)\n arr.append(num)\n l+=1\n if arr[-1]>s:\n arr.pop()\n l-=1\n break\n else:\n num+=arr[-1]\n num-=arr[-k-1]\n arr.append(num)\n l+=1\n if arr[-1]>s:\n arr.pop()\n l-=1\n break\n i+=1\n return arr\ns,k=list(map(int,input().split())) \narr=fib(k,s)\nl=len(arr)-1\nans=arr[l]\nlis=[ans]\nwhile ans<s:\n temp=s-ans\n ind=binarySearch(arr,0,l,temp)\n ans+=arr[ind]\n lis.append(arr[ind])\nanswer=[]\na=len(lis)\nif a==1:\n lis.append(0)\n a+=1\nfor i in range(1,a+1):\n answer.append(lis[-i])\nprint(a)\nprint(\" \".join(str(x) for x in answer))\n \n \n \n \n \n \n \n ", "positive_code": [{"source_code": "s,k=map(int,input().split())\nf=[0]\nf.append(1)\nwhile(True):\n cur=sum(f[-k:])\n if cur>s:\n break\n f.append(cur)\nf=list(set(f))\nf.sort()\nans=[]\ni=len(f)-1\nwhile(s and i>0):\n if f[i]<=s:\n s-=f[i]\n ans.append(f[i])\n i-=1\nprint(len(ans)+1)\nprint(*(ans+[0]))\n"}, {"source_code": "import bisect \ns,k=list(map(int,input().split()))\nf=[0]*45\nfor i in range(45):\n if i==0 or i==1:\n f[i]=1\n elif i<k:\n f[i]=sum(f[:i])\n else:\n f[i]=sum([f[i-j] for j in range(1,k+1)])\nans=[0]\nwhile s>0:\n i=bisect.bisect_right(f,s)\n ans.append(f[i-1])\n s=s-f[i-1]\nprint(len(ans))\nfor i in range(len(ans)):\n print(ans[i],end=' ')"}, {"source_code": "s, k = map(int, input().split())\nf = [1]\nwhile f[-1] < s:\n\tx = 0\n\tfor i in range(max(0, len(f)-k), len(f)):\n\t\tx += f[i]\n\tf.append(x)\nresult = [0]\npos = len(f)-1\nwhile s != 0:\n\twhile f[pos] > s:\n\t\tpos -= 1\n\tresult.append(f[pos])\n\ts -= f[pos]\nprint(len(result))\nprint(' '.join(map(str, result)))\n"}, {"source_code": "s,k=map(int,input().split())\narr=[0,1];k1=1;visited=[];mini=0\nwhile(arr[-1]<s):\n arr.append(sum(arr[-k::]))\nwhile(s>0):\n for i in arr:\n if(i<=s):mini=i;\n else:break;\n s-=mini;visited.append(mini);\nif(len(visited)==1):visited.append(0);\nprint(len(visited))\nprint(*visited) "}, {"source_code": "s, k = map(int, input().split())\nfreq = [1]\nwhile freq[-1] < s:\n\tx = 0\n\tfor i in range(max(0, len(freq)-k), len(freq)):\n\t\tx += freq[i]\n\tfreq.append(x)\nres = [0]\nidx = len(freq) - 1\nwhile s != 0:\n\twhile freq[idx] > s:\n\t\tidx -= 1\n\tres.append(freq[idx])\n\ts -= freq[idx]\nprint(len(res))\nprint(*res)\n"}, {"source_code": "def power(a, b):\n if b == 0:\n return 1\n elif b % 2 == 0:\n a_1 = a * a\n return pow(a_1, b // 2)\n return a * pow(a, b - 1)\n\n\ndef k_fib(s, k):\n result = [0]\n if k >= 40:\n fibs = [power(2, i) for i in range(40)]\n else:\n fibs = [0] * (k - 1) + [1]\n while fibs[len(fibs) - 1] < s:\n fibs.append(sum(fibs[-k:]))\n while s > 0:\n if fibs[len(fibs) - 1] <= s:\n result.append(fibs[len(fibs) - 1])\n s -= fibs[len(fibs) - 1]\n fibs.pop()\n return result\n\n\nS, K = [int(j) for j in input().split()]\nprint(len(k_fib(S, K)))\nprint(*k_fib(S, K))\n"}, {"source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as c\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(var): sys.stdout.write(str(var))\ndef outln(var): sys.stdout.write(str(var)+\"\\n\")\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\ndef k_bonacci(n):\n if n < k:\n return 0\n if n == k:\n return 1\n if n in dp.keys():\n return dp[n]\n dp[n] = 0\n for i in range(n-k, n):\n dp[n] += k_bonacci(i)\n return dp[n]\n\n\ns, k = sp()\nanswer = []\nif k <= 32:\n dp = dd(int)\n i = 1\n while True:\n dp[i] = k_bonacci(i)\n if dp[i] >= pow(10, 9):\n break\n i += 1\n arr = list(dp.values())\n while s > 0:\n temp = bl(arr, s)\n if arr[temp] > s:\n temp -= 1\n s -= arr[temp]\n answer.append(arr[temp])\nelse:\n i = 32\n while i >= 0 and s > 0:\n if pow(2, i) <= s:\n s -= pow(2, i)\n answer.append(pow(2, i))\n i -= 1\nif len(answer) < 2:\n answer.insert(0, 0)\noutln(len(answer))\nprint(*answer)\n"}, {"source_code": "s,k=map(int,input().split())\nf=[0]\nf.append(1)\nwhile(True):\n cur=sum(f[-k:])\n if cur>s:\n break\n f.append(cur)\nf=list(set(f))\nf.sort()\nans=[]\ni=len(f)-1\nwhile(s and i>0):\n if f[i]<=s:\n s-=f[i]\n ans.append(f[i])\n i-=1\nprint(len(ans)+1)\nprint(*(ans+[0]))\n\n#Copied\n"}, {"source_code": "s, k = map(int, input().split())\np, t, l = [0], [0, 1, 1], 2\nwhile t[l] < s:\n t.append((t[l] << 1) - (0 if l < k else t[l - k]))\n l += 1\nt.reverse()\nfor i in t:\n if i > s: continue\n p.append(i)\n s -= i\n if s == 0: break\nprint(len(p))\nprint(' '.join(map(str, p)))"}, {"source_code": "s, k = map(int, input().split())\n\np, t, l = [0], [0, 1, 1], 2\n\nwhile t[l] < s:\n\n t.append((t[l] << 1) - (0 if l < k else t[l - k]))\n\n l += 1\n\nt.reverse()\n\nfor i in t:\n\n if i > s: continue\n\n p.append(i)\n\n s -= i\n\n if s == 0: break\n\nprint(len(p))\n\nprint(' '.join(map(str, p)))\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "s,k=map(int,input().split())\nF = [0,1]\nb = set()\nwhile True:\n f = sum(F[-k:])\n if f > s:\n break\n F.append(f)\nfor i in reversed(F):\n if i <= s:\n b.add(i)\n s -= i\nprint(len(b))\nprint (' '.join(map(str,b)))\n "}, {"source_code": "#choose n maximal k bonnacii nums less than n and subtract them \n#till n is decomposed...\n#it will decompose..! \n#coz any number can be represented as sum of \n#fibonacci numbers \n\n\ndef s():\n [s,k] = list(map(int,input().split()))\n d = [0]\n d.append(1)\n t = 0\n r = []\n while t < s:\n t = sum(d[-min(k,len(d)):])\n d.append(t)\n for i in reversed(d):\n if i <= s:\n s -= i\n r.append(i)\n if i == 0:\n break\n print(len(r))\n print(*r)\ns()\n\n\n#0 1 1 2 3 5 \n\n"}, {"source_code": "def genkbon (s, k):\n if (k<50):\n i = 0\n res = [0]\n while (res[i]<=s):\n if (i<k):\n res.append(0)\n elif (i==k):\n res.append(1)\n elif (i==k+1):\n res.append(1)\n else:\n res.append(2*res[i]-res[i-k])\n i += 1\n del res[-1]\n return res\n if (k>=50):\n res = [0,1]\n i = 1\n while (res[i]<=s):\n res.append(2*res[i])\n i += 1\n return res\n \ndef solve(s, k, tmp):\n tmp2 = tmp\n while (tmp2[-1]>s):\n del tmp2[-1]\n if (s==0):\n return [0]\n if (s==1):\n return [0,1]\n if (s==2):\n return [0,2]\n ha = tmp2[-1]\n res = solve(s-ha,k,tmp2)\n return [ha]+res\n \ninp1 = input()\ninp = inp1.split()\nhlp = genkbon(int(inp[0]),int(inp[1]))\nsol = solve(int(inp[0]),int(inp[1]), hlp)\nprint(len(sol))\nfor i in sol[:-1]:\n print(i,end=' ')\nprint(sol[-1])"}, {"source_code": "def genFib(k, n):\n cur = 1\n ind = -k + 2\n ret = [0, 1]\n while cur <= n:\n ret.append(cur)\n cur += cur\n if ind >= 0:\n cur -= ret[ind]\n ind += 1\n return ret\n\ndef get(n, cur, last):\n global f, m\n if n == 0:\n cur.append(0)\n print len(cur)\n print ' '.join(map(str, cur))\n exit(0)\n for i in range(last, m):\n x = f[i]\n if x <= n:\n get(n - x, cur + [x], i + 1)\n\nn, k = map(int, raw_input().split())\nf = genFib(k, n)[::-1]\nm = len(f)\nget(n, [], 0)\nexit(1)\n"}, {"source_code": "import sys\nif sys.version_info[0] == 2: input = raw_input\ns, k = map(int,input().split())\nif s == 1:\n print('2\\n0 1')\n sys.exit(0)\nelif s==2:\n print('2\\n0 2')\n sys.exit(0)\nn = 2\nans = []\na = [0] * 100\na[0] = a[1] = 1\nwhile a[n-1] < s:\n a[n] = 2*a[n-1]-(a[n-k-1] if n-k-1>=0 else 0)\n n += 1\n\nfor i in range(n-1,-1,-1):\n if a[i] <= s:\n ans.append(a[i])\n s -= a[i]\n if s == 0: break\nprint(len(ans) + 1)\nprint('0 ' + \" \".join(map(str,ans)))\n"}, {"source_code": "s,k=map(int,raw_input().split())\nf,sm=[0,1,1],[0]\nssum=0\nwhile ssum<s :\n i=k+2\n sumi=1\n while sumi<=s-ssum :\n sumi+=f[i-k]\n i+=1\n if ssum==0 :\n f.append(2*f[i-k-1])\n if i-k-k-1 >=0 :\n f[i-k]=f[i-k]-f[i-k-k-1]\n ssum+=f[i-k-1]\n sm.append(f[i-k-1])\nprint(len(sm))\nprint(\" \".join([str(i) for i in sm]))\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n"}, {"source_code": "s, k = map(int, raw_input().split())\nF = [1]\ntotal = 1\nwhile len(F) < k and F[-1] <= s :\n val = F[-1]\n F.append(total + val)\n total += val\n\nwhile F[-1] <= s:\n val = sum(F[-k:])\n F.append(val)\n total += val\n\nC = []\nF = F[::-1]\ndef find_recur(n):\n if n > 0:\n if n in F:\n C.append(n)\n else:\n x = next(x for x in F if x < n)\n if x is not None:\n C.append(x)\n y = find_recur(n - x)\n if y is not None:\n C.append(y)\n return None\nif s in F:\n print 2\n print 0, s\n exit()\nelse:\n find_recur(s)\n print(len(C))\n print \" \".join(map(str, C))"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "s, k = map(int, raw_input().split())\nf = [1, 1]\nwhile f[-1] < 10 ** 9 + 10:\n if len(f) > k:\n f.append(f[-1] * 2 - f[-k-1])\n else:\n f.append(f[-1] * 2)\nans = [0]\ni = -1\nwhile s > 0:\n x = f[i]\n if s >= x:\n ans.append(x)\n s -= x\n i -= 1\nprint len(ans)\nfor x in ans:\n print x,\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n"}, {"source_code": "s, k = map(int, raw_input().split())\na = [0, 1]\nwhile a[-1] < s: a.append(sum(a[-k:]))\nb = []\nfor i in reversed(a):\n if i <= s:\n b.append(i)\n s -= i\nprint len(b)\nprint ' '.join(map(str, b))"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "kb = [0,1]\ns,k = map(int,raw_input().split())\nwhile kb[-1] < s:\n kb.append(sum(kb[-k:]))\nr = [0]\nfor i in kb[::-1]:\n if s == 0: break\n elif s >= i:\n r.append(i)\n s -= i\nprint len(r)\nprint ' '.join(map(str,r))\n"}, {"source_code": "kb = [0,1]\ns,k = map(int,raw_input().split())\nwhile kb[-1] < s:\n kb.append(sum(kb if len(kb) < k else kb[-1:-1-k:-1]))\nr = [0]\nfor i in xrange(len(kb)-1,-1,-1):\n if s == 0: break\n elif s >= kb[i]:\n r.append(kb[i])\n s -= kb[i]\nprint len(r)\nprint ' '.join(map(str,r))\n"}, {"source_code": "l = [0,1]\ns,k = map(int,raw_input().split())\nwhile 1:\n t = sum(l if len(l) < k else l[-1:-1-k:-1])\n if t > s: break\n l.append(t)\nr = []\nfor i in xrange(len(l)-1,-1,-1):\n if s == 0:\n if len(r) < 2: r.append(0)\n break\n elif s >= l[i] and l[i] not in r:\n r.append(l[i])\n s -= l[i]\nprint len(r)\nprint ' '.join(map(str,r))\n"}, {"source_code": "############\nkb = [0,1]\ns,k = map(int,raw_input().split())\nwhile kb[-1] < s:\n kb.append(sum(kb[-k:]))\nr = [0]\nfor i in kb[::-1]:\n if s == 0: break\n elif s >= i:\n r.append(i)\n s -= i\nprint len(r)\nprint ' '.join(map(str,r))"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))"}, {"source_code": "kbs, ans = [0, 1], [0]\ns, k = map(int, raw_input().split())\nwhile kbs[-1] < s:\n kbs.append(sum(kbs[0-min(len(kbs),k):]))\nwhile s > 0:\n if kbs[-1] <= s:\n ans.append(kbs.pop())\n s -= ans[-1]\n else:\n kbs.pop()\nprint len(ans)\nprint ' '.join(map(str, ans))"}, {"source_code": "s,k=map(int,raw_input().split())\nt={}\ndef f(a,b):\n s=0\n if b < a: s=0\n elif b == a: s=1\n elif b in t:\n s=t[b]\n elif a > 32: s=2**(b-a-1)\n else:\n for i in range(b-a,b):\n s+=f(a,i)\n t[b] = s\n return s\n\ni=max(0,k-2)\ne=0\nF=[]\nwhile e < s:\n i+=1\n e=f(k,i)\n if e < s or 0 in F:\n F+=[e]\n \nr=[]\nfor e in reversed(F):\n if e <= s and e:\n r+=[`e`]\n s-=e\nif len(r)==1 and 0 in F:\n r+=['0']\nprint len(r)\nprint ' '.join(r)"}, {"source_code": "import math\n\nn = raw_input().split()\ns = int(n[0])\nk = int(n[1])\n\na = [0,1,1]\ni = len(a)\nwhile True:\n\tt = 0\n\tfor j in xrange(1,k+1):\n\t\tt += a[i-j]\n\t\tif a[i-j] == 0:\n\t\t\tbreak\n\tif t > s:\n\t\tbreak\n\ta.append(t)\n\ti += 1\n#print a\na = list(set(a))\na.sort(reverse=True)\n\nans = []\nfor i in a:\n\tif i <= s:\n\t\ts -= i\n\t\tans.append(i)\nif s != 0:\n\tprint \"you can't\"\n\nprint len(ans)\nfor i in ans:\n\tprint i,\n"}, {"source_code": "def first_fib(s,k):\n bon = [0,1]\n summ = 0\n while summ < s:\n summ = 0\n if len(bon) < k: count = len(bon)\n else: count = k\n last = bon.index(max(bon))\n summ = sum(bon[-count:-1])+bon[last]\n bon.append(summ)\n del bon[last+1]\n return bon\nbon = [0]\ni = 0\ns,k = map(int,raw_input().split())\nif s == 1: print \"2\" + \"\\n\" + \"1 0\"\nelif s == 2: print \"2\" + \"\\n\" + \"2 0\"\nelif s == 3: print \"2\" + \"\\n\" + \"1 2\"\nelif s == 4: print \"2\" + \"\\n\" + \"4 0\"\nelse:\n if k<32: bon = first_fib(s,k)\n else:\n while (2**i) < s:\n bon.append(2**i)\n i+=1\n arr = []\n while s != 0:\n if s >= bon[-1]:\n s-=bon[-1]\n arr.append(bon.pop())\n else:\n del bon[-1]\n l = len(arr)\n print l\n print ' '.join(map(str,arr))\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "n,k=map(int,raw_input().split())\nlst=[0,1]\ns=1\nk=min(k,30)\nfor i in range(2,k):\n lst.append(s)\n s=s+lst[-1]\nfor i in range(0,70):\n s=0\n #print i,\n for j in range(i,i+k):\n s=s+lst[j]\n #print s,lst[j],j\n lst.append(s)\nans=[]\n#print lst\nlc=0\nfor i in range(len(lst)-1,-1,-1):\n if n>0 and lst[i]<=n:\n if lst[i] not in ans:\n ans.append(lst[i])\n n=n-lst[i]\n lc=lc+1\nif 0 not in ans:\n ans.append(0)\nprint len(ans)\nfor i in ans:\n print i,\nprint "}, {"source_code": "s, k = map(int, raw_input().split())\na = [1]\nwhile a[-1] < s:\n\ta.append(sum(a[-k : ]))\nr = []\nfor x in a[ : : -1]:\n\tif s >= x:\n\t\ts -= x\n\t\tr.append(`x`)\nr.append(`s`)\nprint len(r)\nprint ' '.join(r)"}, {"source_code": "s, k = map(int, raw_input().split())\na = [1]\nwhile a[-1] < s:\n\ta.append([sum(a[-k : ]), sum(a)][len(a) < k])\nr = []\nfor x in a[ : : -1]:\n\tif s >= x:\n\t\ts -= x\n\t\tr.append(`x`)\nr.append(`s`)\nprint len(r)\nprint ' '.join(r)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nkbs, ans = [0, 1], [0]\ns, k = map(int, raw_input().split())\nwhile kbs[-1] < s:\n kbs.append(sum(kbs[0-min(len(kbs),k):]))\nwhile s > 0:\n if kbs[-1] <= s:\n ans.append(kbs.pop())\n s -= ans[-1]\n else:\n kbs.pop()\nprint len(ans)\nprint ' '.join(map(str, ans))"}, {"source_code": "l = [0,1]\ns,k = map(int,raw_input().split())\nwhile 1:\n t = sum(l if len(l) < k else l[-1:-1-k:-1])\n if t > s: break\n l.append(t)\nr = []\nfor i in xrange(len(l)-1,-1,-1):\n if s == 0:\n if len(r) < 2: r.append(0)\n break\n elif s >= l[i] and l[i] not in r:\n r.append(l[i])\n s -= l[i]\nprint len(r)\nprint ' '.join(map(str,r))"}, {"source_code": "import bisect\n\ndef start():\n s, k = map(int, raw_input().split())\n kbonacci = [0]\n kbonacci.append(1)\n i = 2\n while kbonacci[i-1] < s:\n kbonacci.append(sum(kbonacci[max(1,i-k):i]))\n i = i+1\n summr = [0]\n while s > 0:\n bl = bisect.bisect_left(kbonacci,s)\n if kbonacci[min(bl, len(kbonacci)-1)] == s:\n summr.append(s)\n break\n else:\n s = s-kbonacci[bl-1]\n summr.append(kbonacci[bl-1])\n print len(summr)\n for x in summr:\n print x,\n\nstart()\n"}, {"source_code": "s,k=map(int,raw_input().split())\nf=[0,1]\nss=1\ntpos=1\ntpos_d=-k+2\nwhile f[-1]<s:\n f.append(ss)\n ss=ss+ss\n if tpos_d>=0:\n ss-=f[tpos_d]\n tpos+=1\n tpos_d+=1\nrere=[0]\nx=1\nwhile s>0:\n while f[-x]>s:\n x+=1\n s-=f[-x]\n rere.append(f[-x])\nprint len(rere)\nprint \" \".join(map(str,rere)) \n"}, {"source_code": "import sys\n\ndef k_fib(k, upper_bound):\n if upper_bound < 2:\n return upper_bound\n f = [1]\n while len(f) < k and f[-1] * 2 <= upper_bound:\n f.append(f[-1] * 2)\n while len(f) == k and sum(f) <= upper_bound:\n f.append(sum(f))\n f.remove(f[0])\n return f[-1]\n\ndef main():\n s, k = map(lambda x: int(x), sys.stdin.readline().split())\n a = []\n while s > 0:\n f = k_fib(k, s)\n a.append(f)\n s -= f\n if len(a) == 1:\n a.append(0)\n print len(a)\n print ' '.join(map(lambda x: str(x), a))\n\nif __name__ == '__main__':\n main()\n \n"}, {"source_code": "n, k = map(int, raw_input().split())\n\nbona = [1]\n\ncnt = 0\n\nwhile bona[-1] < n:\n if cnt < k:\n bona.append(2 ** cnt)\n else:\n bona.append(sum(bona[-k:]))\n cnt += 1\n\nans = []\n\nwhile n > 0:\n while bona[-1] > n:\n bona.pop()\n ans.append(bona[-1])\n n -= bona[-1]\n\nif len(ans) == 1:\n ans.append(0)\n\nprint len(ans)\nprint ' '.join(map(str, ans))\n"}, {"source_code": "import bisect\ns,k=map(int,raw_input().split())\nif k>31:\n a=[0,1,2]\n while a[-1] < s:a.append(a[-1]*2)\nelse:\n a=[0]*(k-1)+[1]\n while a[-1] < s:a.append(sum(a[-k:]))\ncurr = bisect.bisect_left(a, s)\nans=[]\nwhile s:\n curr = bisect.bisect_left(a, s)\n if a[curr] > s:curr-=1\n ans.append(a[curr])\n s-=a[curr]\nans+=[0]\nprint len(ans)\nprint \" \".join(map(str,ans))\n"}, {"source_code": "s,k = map(int,raw_input().split());\n\nA = [0,1];\nsu = 0;\nl = 1;\nfor i in xrange(k-1):\n\tsu += l;\n\tl = su;\n\tA.append(l);\n\tif su >= s: break;\n\nsu += l;\nq = A;\ni = 1;\nwhile A[-1] < s:\n\tA.append(su);\n\tsu -= A[i];\n\tsu += A[-1];\n\ti += 1;\n\nB = [];\nwhile s :\n\twhile A[-1] > s: A.pop();\n\ts -= A[-1];\n\tB.append(A[-1]);\n\nif len(B) < 2:\n\tB.append(0);\nprint len(B);\nprint \" \".join([str(b) for b in B]);"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "n,k = map(int,raw_input().split())\n\nans = [0]\nif k >= 32:\n b = []\n while n > 0:\n b.append(n%2)\n n/=2\n for i in xrange(len(b)):\n if b[i] == 1:\n ans.append(2**i)\nelse:\n arr = [0 for i in xrange(k-1)]\n arr.append(1)\n ind = 0\n while arr[-1] < n:\n arr.append(sum(arr[ind:k+ind]))\n ind +=1\n ind = len(arr) -1\n while n > 0:\n if arr[ind] <= n:\n n -= arr[ind]\n ans.append(arr[ind])\n ind -= 1\n\nprint len(ans)\nprint \" \".join(map(str,ans))\n"}, {"source_code": "def s():\n [s,k] = list(map(int,input().split()))\n d = [0]\n d.append(1)\n t = 0\n r = []\n while t < s:\n t = sum(d[-min(k,len(d)):])\n d.append(t)\n for i in reversed(d):\n if i <= s:\n s -= i\n r.append(i)\n if i == 0:\n break\n print(len(r))\n print(*r)\ns()\n"}, {"source_code": "\nfibarr = []\ndp = []\npredecessor = []\ndef gen_list(s, k):\n global fibarr\n \n fibarr = [0, 1, 1]\n idx = 3\n while fibarr[idx - 1] <= s :\n fibarr.append(fibarr[idx-1] * 2 - fibarr[max(idx - k - 1, 0)])\n idx += 1 \n \nif __name__ == '__main__': \n int_s, int_k = map(int, raw_input().split())\n \n gen_list(int_s, int_k)\n int_rem = int_s\n answer = []\n for ii in xrange(len(fibarr)-1, -1, -1) :\n if int_rem == 0 :\n break\n if (fibarr[ii] > int_rem) :\n continue\n else :\n int_rem -= fibarr[ii]\n answer.append(fibarr[ii])\n if len(answer)==1 :\n answer.append(0)\n #print fibarr\n \n print len(answer)\n res = \"\"\n for item in answer :\n res+=str(item)+\" \"\n res = res[0:len(res)-1]\n print res\n pass"}, {"source_code": "\ns,k = map(int,input().split())\n\n\nif k>=32:\n k_bon = [0]\n for i in range(33):\n k_bon.append(2**i)\nelse:\n k_bon = [0]*(k-1)\n k_bon.append(1)\n i = k+1\n c = 0\n while len(k_bon)<=100:\n next = sum(k_bon[c:i])\n k_bon.append(next)\n i+=1\n c+=1\n\nk_bon = set(k_bon)\ni = 0\nans = []\nk_bon = sorted(list(k_bon))\n# print(k_bon)\nwhile s!=0:\n if k_bon[i] >= s:\n if s == k_bon[i]:\n s-=k_bon[i]\n # print(s)\n ans.append(k_bon[i])\n i = 0\n else:\n\n s-=k_bon[i-1]\n # print(s)\n ans.append(k_bon[i-1])\n i = 0\n\n else:\n i+=1\nif len(ans) == 1:\n ans.append(0)\nprint(len(ans))\nprint(*ans)\n\n\n"}, {"source_code": "s,k=map(int,input().split())\nf=[0]\nf.append(1)\nwhile(True):\n cur=sum(f[-k:])\n if cur>s:\n break\n f.append(cur)\nf=list(set(f))\nf.sort()\nans=[]\ni=len(f)-1\nwhile(s and i>0):\n if f[i]<=s:\n s-=f[i]\n ans.append(f[i])\n i-=1\nprint(len(ans)+1)\nprint(*(ans+[0]))"}, {"source_code": "x,y=map(int,input().split())\ndp=[]\ndp.append(0)\ndp.append(1)\n\nn=2\nwhile 1:\n sm=0\n for k in range(n-1,n-y-1,-1):\n if k==0:\n break\n sm+=dp[k]\n if sm>x:\n break\n dp.append(sm)\n n+=1\n\ndp.reverse()\nres=[]\n\nn=0\nwhile n<len(dp) and x>=0:\n if x>=dp[n]:\n res.append(dp[n])\n x-=dp[n]\n n+=1\n\nprint(len(res))\nprint(*res)\n\n"}, {"source_code": "s,k=list(map(int,input().split(' ')))\na=[0,1,1]\nwhile a[-1]<s:\n if len(a)<k:\n a.append(sum(a))\n else:\n t=0\n for i in range(k):\n t+=a[-i-1]\n a.append(t)\nif s==a[-1]:\n print(2)\n print(0,a[-1])\nelse:\n use=[]\n for i in range(len(a)):\n if s>=a[-i-1]:\n s-=a[-i-1]\n use.append(a[-i-1])\n print(len(use))\n for i in use:\n print(i,end=' ')"}, {"source_code": "s,k=map(int,input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\n#print(a)\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint(len(b))\nprint(' '.join(map(str,b)))"}, {"source_code": "[s, k] = [int(x) for x in input().split()]\n\nnumbers = [1]\nnumbers.append(1)\n\nlast = 1\nindex = 1\nwhile last <= s:\n l_index = index-k\n if l_index >= 0:\n last = last * 2 - numbers[l_index]\n else:\n last *= 2\n # print(last, l_index)\n if last <= s:\n numbers.append(last)\n index += 1\n\n\nnumbers.reverse()\nnumbers.append(0)\n\n# for s in range(0, 100000):\noutput = []\nfor i in numbers:\n if i <= s:\n s -= i\n output.append(i)\n\nprint(len(output))\nprint(\" \".join([str(x) for x in output]))\n\n\n\n\n"}, {"source_code": "#coding=utf-8\n\n#import Set\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n#for i in range(1,20):\n#\tfor j in range(1,20):\n#\t\tprint \"%3d\"%F(i,j),\n#\tprint \n\ndef Gen_F(k,MAX):\n\tif k == 1:\n\t\treturn [0,1]\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb <= MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\n\t\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\n\n#print [F(k,i) for i in range(k,k+20)]\n#print FL\n\nFL = list(reversed(sorted(list(set(FL)))))\n\n#print FL\n\nans = []\nfor i in FL:\n\tif s >= i:\n\t\t#print s,i\n\t\tans.append(i)\n\t\ts = s - i\n\t\t\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "s, k = map(int, raw_input().split())\nl = [0, 1]\nwhile True:\n l.append(sum(l[-k:]))\n if (l[-1] > s):\n l = l[:-1]\n break\n#print '#', s, l\nans = []\nfor i in l[::-1]:\n if s >= i:\n s -= i\n ans.append(i)\n\nprint len(ans)\nprint ' '.join(map(str, ans))\n"}, {"source_code": "s, k = map(int, raw_input().split())\na = [0, 1]\nwhile a[-1] < s: a.append(sum(a[-k:]))\nb = []\nfor i in reversed(a):\n if i <= s:\n b.append(i)\n s -= i\nprint len(b)\nprint ' '.join(map(str, b))\n"}, {"source_code": "def Sum(a, l, r):\n s = 0\n for i in range(l, r):\n s += a[i]\n return s\n\ndef main():\n F = [1]\n\n s, k = map(int, raw_input().split())\n\n n = k\n while True:\n n += 1\n if n > k:\n f = Sum(F, max(0, n - k - k), n - k)\n\n if f > s:\n break\n F.append(f)\n \n F = F[1:]\n F.reverse()\n\n res = [0]\n for f in F:\n if s == 0:\n break\n if s >= f:\n res.append(f)\n s -= f\n\n print len(res)\n print \" \".join(map(str, res))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "s,k=map(int,raw_input().split())\nf = [0]*200+[1]\nwhile True:\n l = min(len(f),k)\n f.append(sum(f[-l:]))\n if s<f[-1]:\n break\n\nres = []\nwhile s>0:\n if s in f:\n res.append(s)\n res.append(0)\n s=0\n else:\n i=0\n while not f[i]<s<f[i+1]:\n i+=1\n res.append(f[i])\n s-=f[i]\nres.reverse()\n \nprint len(res)\nfor x in res:\n print x,\nprint\n"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\n\nl = []\ns,k = li()\ni = 0\n\nsum = [0 for i in range(10**6)]\na = sum[:]\na[1]=1;\nsum[1]=1;\nfor i in range(2,10**13):\n\n if(i<=k):\n a[i]=sum[i-1];\n else:a[i]=sum[i-1]-sum[i-k-1];\n if(a[i]>s):\n n=i;break;\n sum[i]=sum[i-1]+a[i];\n\n\nl = sorted(list(set(l)))\nans = [0]\ni = n-1\nwhile s and i:\n if s - a[i] >= 0:\n ans.append(a[i])\n s -= a[i]\n i-=1\nprint(len(ans))\nprint(*ans)"}, {"source_code": "s, k = map(int, raw_input().split())\na = [0, 1]\nwhile a[-1] < s:\ta.append(sum(a[-k:]))\n#print a\nb = []\nfor i in reversed(a):\n\tif i <= s:\n\t\tb.append(i)\n\t\ts -= i\nprint len(b)\nprint ' '.join(map(str, b))\n\n\n"}, {"source_code": "\nmyin = raw_input()\nmyin = myin.split()\n\nmysum = int(myin[0])\nmyk = int(myin[1])\n\nkbon = [0]\nkbon.append(1)\n\nwhile kbon[len(kbon) - 1] < mysum:\n if len(kbon) < myk:\n kbon.append(sum(kbon))\n else:\n temp = 0\n for i in range(myk):\n temp += kbon[len(kbon) - 1 - i]\n kbon.append(temp)\n\nmyout = []\n\nmysumtemp = mysum\ncount = 0\n\nfor i in range(len(kbon) - 1, -1, -1):\n if kbon[i] == 0:\n count += 1\n if count == 2:\n break\n if kbon[i] <= mysumtemp:\n myout.append(kbon[i])\n mysumtemp -= kbon[i]\n\n\nprint len(myout)\nouttemp = ''\nfor i in myout:\n outtemp += str(i) + ' '\n\nouttemp = outtemp[:len(outtemp) - 1]\nprint outtemp\n"}, {"source_code": "s,k=[int(i) for i in input().split()]\na=[-1,0,1,1]\ni=3\nwhile a[i]<=pow(10,9):\n i+=1\n a.append(0)\n if i<=k:\n for j in range(1,i):\n a[i]+=a[j]\n else:\n for j in range(i-k,i):\n a[i]+=a[j]\nb=[]\nfor j in range(i,0,-1):\n if a[j]<=s:\n b.append(a[j])\n s-=a[j]\n if s==0:\n b.append(0)\n break\nprint(len(b))\nfor i in b:\n print(i,end=' ')"}, {"source_code": "# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import generators\nfrom __future__ import nested_scopes\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\nfrom __future__ import with_statement\n\nimport bisect\nimport collections\nimport copy\nimport functools\nimport heapq\nimport itertools\nimport math\nimport operator\nimport os\nimport re\nimport random\nimport sys\nfrom pprint import pprint\n\n__author__ = 'Aphrodite'\n\n\ndef main():\n iterator = itertools.imap(str.rstrip, sys.stdin.readlines())\n s, k = map(int, next(iterator).split())\n a = [0, 1]\n while a[-1] < s:\n if (len(a)) < k:\n a.append(sum(a))\n else:\n a.append(sum(a[-k:]))\n# print(a)\n res = []\n while s > 0:\n idx = bisect.bisect(a, s) - 1\n s -= a[idx]\n res.append(a[idx])\n if len(res) == 1:\n res.append(0)\n print(len(res))\n print(' '.join(map(str, res)))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "s, k = map(int, raw_input().split())\na = [0,1]\nb = []\n\nwhile a[-1] < s:\n a.append(sum(a[-k:]))\n\nfor i in reversed(a):\n if i <= s:\n b.append(i)\n s -= i\n\nprint len(b)\nfor i in b:\n print i,\n"}, {"source_code": "s, k = map(int, raw_input().split())\nsums, sequence = 1, [1]\nwhile sums <= s:\n sequence.append(sums)\n sums += sums\n if len(sequence) > k:\n sums -= sequence[-(k + 1)]\nresult = []\nfor i in reversed(sequence):\n if i <= s:\n s -= i\n result.append(i)\nif len(result) == 1:\n result.append(0)\nprint len(result)\nprint \" \".join(map(str, result))\n"}, {"source_code": "#import sys\n#\n#sys.stdin = open('in.txt', 'r')\n\ns, k = map(int, raw_input().split())\nfib = [0, 1, 1]\n\nwhile(True):\n fib.append(sum(fib[-k:]))\n if fib[-1] > s: \n del fib[-1]\n break\n\nans = []\n\nwhile(True):\n x = fib.pop()\n if x <= s: \n s -= x\n ans.append(x)\n if s == 0:\n break\nans.append(0)\nprint len(ans)\nprint ' '.join(map(str, ans))\n\n\n"}, {"source_code": "NAME = \"P2\"\ntry:\n inFile = open(NAME+\".txt\")\nexcept:\n pass\n\ndef read():\n try:\n return inFile.readline().strip()\n except:\n return raw_input().strip()\n\ns,k = map(int,read().split())\nseq = [1,1]\nn = 2\nx = 1\n\nwhile seq[-1] < s:\n x *= 2\n if n > k:\n x -= seq[n-k-1]\n seq.append(x)\n n += 1\n#print seq\n\nans = []\ni = len(seq)-1\nwhile s > 0:\n while seq[i] > s:\n i -= 1\n ans.append(seq[i])\n s -= seq[i]\nif len(ans) == 1:\n ans.append(0)\n \nprint len(ans)\nprint \" \".join(map(str,ans))"}, {"source_code": "\ndef main():\n cin = lambda: map(int, raw_input().split())\n [s, k] = cin()\n ans = []\n a = [0, 1]\n while a[-1] < s:\n a.append(sum(a[-k:]))\n for i in reversed(a):\n if i <= s:\n ans.append(i)\n s -= i\n print len(ans)\n for a in ans:\n print a,\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))"}, {"source_code": "def readInt():\n return tuple([int(x) for x in raw_input().split()])\n\ns, k = readInt()\nif k >= 40:\n fib = [2**i for i in xrange(40)]\nelse:\n fib = [0] * (k - 1) + [1]\n while fib[-1] < s:\n fib.append(sum(fib[-k:]))\nans = [0]\nwhile s > 0:\n if fib[-1] <= s:\n ans.append(fib[-1])\n s -= fib[-1]\n fib.pop()\nprint len(ans)\nprint \" \".join([str(x) for x in ans])"}, {"source_code": "s,k = map(int,raw_input().split())\nfib = [0,1]\nfor i in xrange(80):\n\tx=0\n\tfor j in xrange(k):\n\t\tif len(fib)-j-1 < 0:\n\t\t\tbreak\n\t\tx += fib[len(fib)-j-1]\n\tfib.append(x)\n\nans = []\nfor i in reversed(fib):\n\tif i <= s:\n\t\ts -= i\n\t\tans.append(i)\n\nprint len(ans)\nfor i in ans:\n\tprint i,"}], "negative_code": [{"source_code": "s,k = map(int,raw_input().split())\nfib = [0,1]\nfor i in xrange(32):\n\tx=0\n\tfor j in xrange(k):\n\t\tif len(fib)-j-1 < 0:\n\t\t\tbreak\n\t\tx += fib[len(fib)-j-1]\n\tfib.append(x)\n\nans = []\nfor i in reversed(fib):\n\tif i <= s:\n\t\ts -= i\n\t\tans.append(i)\n\nprint len(ans)\nfor i in ans:\n\tprint i,"}, {"source_code": "n,k=map(int,raw_input().split())\nlst=[0,1]\ns=1\nk=min(k,30)\nfor i in range(2,k):\n lst.append(s)\n s=s+lst[-1]\nfor i in range(0,30):\n s=0\n #print i,\n for j in range(i,i+k):\n s=s+lst[j]\n #print s,lst[j],j\n lst.append(s)\nans=[]\n#print lst\n\nfor i in range(len(lst)-1,-1,-1):\n if n>0 and lst[i]<=n:\n if lst[i] not in ans:\n ans.append(lst[i])\n n=n-lst[i]\nprint len(ans)\nfor i in ans:\n print i,\nprint "}, {"source_code": "n,k=map(int,raw_input().split())\nlst=[0,1]\ns=1\nk=min(k,30)\nfor i in range(2,k):\n lst.append(s)\n s=s+lst[-1]\nfor i in range(0,30):\n s=0\n #print i,\n for j in range(i,i+k):\n s=s+lst[j]\n #print s,lst[j],j\n lst.append(s)\nans=[]\n#print lst\nlc=0\nfor i in range(len(lst)-1,-1,-1):\n if n>0 and (lc>0 and lst[i]<=n) or (lc==0 and lst[i]<n) :\n if lst[i] not in ans:\n ans.append(lst[i])\n n=n-lst[i]\n lc=lc+1\nprint len(ans)\nfor i in ans:\n print i,\nprint "}, {"source_code": "n,k=map(int,raw_input().split())\nlst=[0,1]\ns=1\nk=min(k,30)\nfor i in range(2,k):\n lst.append(s)\n s=s+lst[-1]\nfor i in range(0,30):\n s=0\n #print i,\n for j in range(i,i+k):\n s=s+lst[j]\n #print s,lst[j],j\n lst.append(s)\nans=[]\n#print lst\nlc=0\nfor i in range(len(lst)-1,-1,-1):\n if n>0 and lst[i]<=n:\n if lst[i] not in ans:\n ans.append(lst[i])\n n=n-lst[i]\n lc=lc+1\nans.append(0)\nprint len(ans)\nfor i in ans:\n print i,\nprint "}, {"source_code": "import bisect\ns,k=map(int,raw_input().split())\nif k>31:\n a=[0,1,2]\n while a[-1] < s:a.append(a[-1]*2)\nelse:\n a=[0]*(k-1)+[1]\n while a[-1] < s:a.append(sum(a[-k:]))\ncurr = bisect.bisect_left(a, s)\nans=[a[curr-1]]\ns -= a[curr-1]\nwhile s:\n curr = bisect.bisect_left(a, s)\n if a[curr] > s:curr-=1\n ans.append(a[curr])\n s-=a[curr]\nif len(ans) == 1:ans+=[0]\nprint len(ans)\nprint \" \".join(map(str,ans))\n"}, {"source_code": "x,y=map(int,input().split())\ndp=[]\ndp.append(0)\ndp.append(1)\n\nn=2\nwhile 1:\n sm=0\n for k in range(n-1,n-y-1,-1):\n if k==0:\n break\n sm+=dp[k]\n if sm>=x:\n break\n dp.append(sm)\n n+=1\n\ndp.reverse()\nres=[]\n\nn=0\nwhile n<len(dp) and x>0:\n if x>=dp[n]:\n res.append(dp[n])\n x-=dp[n]\n n+=1\n\nprint(len(res))\nprint(*res)\n\n"}, {"source_code": "x,y=map(int,input().split())\ndp=[]\ndp.append(0)\ndp.append(1)\n\nn=2\nwhile 1:\n sm=0\n for k in range(n-1,n-y-1,-1):\n if k==0:\n break\n sm+=dp[k]\n if sm>=x:\n break\n dp.append(sm)\n n+=1\n\ndp.reverse()\nres=[]\n\nn=0\nwhile n<len(dp) and x>=0:\n if x>=dp[n]:\n res.append(dp[n])\n x-=dp[n]\n n+=1\n\nprint(len(res))\nprint(*res)\n\n"}, {"source_code": "[s, k] = [int(x) for x in input().split()]\nif s == 1:\n print(2)\n print(1,0)\n exit()\nnumbers = [1]\nnumbers.append(1)\n\nlast = 1\nindex = 1\nwhile last < s:\n l_index = index-k\n if l_index >= 0:\n last = last * 2 - numbers[l_index]\n else:\n last *= 2\n # print(last, l_index)\n if last != s:\n numbers.append(last)\n index += 1\n\nnumbers.reverse()\n\n# for s in range(0, 100000):\noutput = []\nfor i in numbers:\n if i <= s:\n s -= i\n output.append(i)\n\nprint(len(output))\nprint(\" \".join([str(x) for x in output]))\n\n\n\n\n"}, {"source_code": "[s, k] = [int(x) for x in input().split()]\n\nnumbers = [1]\nnumbers.append(1)\n\nlast = 1\nindex = 1\nwhile last <= s:\n l_index = index-k\n if l_index >= 0:\n last = last * 2 - numbers[l_index]\n else:\n last *= 2\n # print(last, l_index)\n if last != s:\n numbers.append(last)\n index += 1\n\n\nnumbers.reverse()\nnumbers.append(0)\n\n# for s in range(0, 100000):\noutput = []\nfor i in numbers:\n if i <= s:\n s -= i\n output.append(i)\n\nprint(len(output))\nprint(\" \".join([str(x) for x in output]))\n\n\n\n\n"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\ndef giventhfib(k,n,l):\n if n<k:return 0\n elif n == k:return 1\n tot = 0\n for i in range(1,k+1):tot += l[-i]\n return tot\n\n\n\nl = []\ns,k = li()\ni = 0\nwhile not len(l) or l[-1] < s:\n l.append(giventhfib(k,i,l))\n i += 1\nl = list(set(l))\nans = []\ni = len(l)-1\nwhile s:\n if s - l[i]>=0:\n ans.append(l[i])\n s -= l[i]\n i-=1\nprint(len(ans))\nprint(*ans)"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\ndef giventhfib(k,n,l):\n if n<k:return 0\n elif n == k:return 1\n tot = 0\n for i in range(1,k+1):tot += l[-i]\n return tot\n\n\n\nl = []\ns,k = li()\ni = 0\nwhile not len(l) or l[-1] < s:\n l.append(giventhfib(k,i,l))\n i += 1\nl = list(set(l))\nans = []\ni = len(l)-1\nwhile s and i:\n if s - l[i]>0 or(s==l[i] and len(ans)):\n ans.append(l[i])\n s -= l[i]\n i-=1\nprint(len(ans))\nprint(*ans)"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\ndef func(l,i,tot,req,currlist):\n if i==len(l):\n if tot == req:\n print(len(currlist))\n print(*currlist)\n exit()\n else:\n func(l,i+1,tot + l[i],req,currlist[:] + [l[i]])\n func(l,i+1,tot,req,currlist[:])\n\n\n\nl = [0,1,2]\ncurrsum = sum(l)\ns,k = li()\nwhile l[-1] <= s:\n l.append(currsum)\n currsum*=2\nfunc(l,0,0,s,[])"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\ndef giventhfib(k,n,l):\n if n<k:return 0\n elif n == k:return 1\n tot = 0\n for i in range(1,k+1):tot += l[-i]\n return tot\n\n\n\nl = []\ns,k = li()\ni = 0\nwhile not len(l) or l[-1] < s:\n l.append(giventhfib(k,i,l))\n i += 1\nl = list(set(l))\nans = []\ni = len(l)-1 if l[-1]!=s else len(l)-2\nwhile s and i:\n if s - l[i] >= 0:\n ans.append(l[i])\n s -= l[i]\n i-=1\nprint(len(ans))\nprint(*ans)"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\ndef giventhfib(k,n,l):\n if n<k:return 0\n elif n == k:return 1\n tot = 0\n for i in range(1,k+1):tot += l[-i]\n return tot\n\n\n\nl = []\ns,k = li()\ni = 0\nwhile not len(l) or l[-1] < s:\n l.append(giventhfib(k,i,l))\n i += 1\nl = list(set(l))\nans = []\ni = len(l)-1\nwhile s and i:\n if s - l[i]>0 or(s==l[i] and (not len(ans) or l[i] != s) ):\n ans.append(l[i])\n s -= l[i]\n i-=1\nprint(len(ans))\nprint(*ans)"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\ndef func(l,i,tot,req,currlist):\n if i==len(l):\n if tot == req:\n print(len(currlist))\n print(*currlist)\n exit()\n else:\n func(l,i+1,tot + l[i],req,currlist[:] + [l[i]])\n func(l,i+1,tot,req,currlist[:])\n\n\n\nl = [0,1,1,2]\ncurrsum = sum(l)\ns,k = li()\nwhile l[-1] <= s:\n l.append(currsum)\n currsum*=2\nfunc(l,0,0,s,[])"}, {"source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \n# M = mod = 998244353\n# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\ndef giventhfib(k,n,l):\n if n<k:return 0\n elif n == k:return 1\n return sum(l[:n-1])\n\ndef func(l,i,tot,req,currlist):\n if i==len(l):\n if tot == req:\n print(len(currlist))\n print(*currlist)\n exit()\n else:\n func(l,i+1,tot + l[i],req,currlist[:] + [l[i]])\n func(l,i+1,tot,req,currlist[:])\n\n\n\nl = []\ns,k = li()\ni = 0\nwhile not len(l) or l[-1] <= s:\n l.append(giventhfib(k,i,l))\n i += 1\nl = list(set(l))\nfunc(l,0,0,s,[])"}, {"source_code": "s,k=[int(i) for i in input().split()]\na=[-1,0,1,1]\ni=3\nwhile a[i]<=pow(10,9):\n i+=1\n a.append(0)\n if i<=k:\n for j in range(1,i):\n a[i]+=a[j]\n else:\n for j in range(i-k,i):\n a[i]+=a[j]\nb=[]\nfor j in range(i,0,-1):\n if a[j]<s and len(b)==0:\n b.append(a[j])\n s-=a[j]\n if s==0:\n break\n else:\n if a[j]<=s and len(b)>0:\n b.append(a[j])\n s-=a[j]\n if s==0:\n break\nprint(len(b))\nfor i in b:\n print(i,end=' ')"}, {"source_code": "s,k=[int(i) for i in input().split()]\na=[-1,0,1,1]\ni=3\nwhile a[i]<=pow(10,9):\n i+=1\n a.append(0)\n if i<=k:\n for j in range(1,i):\n a[i]+=a[j]\n else:\n for j in range(i-k,i):\n a[i]+=a[j]\nfor j in range(1,i+1):\n for j2 in range(1,i+1):\n for j3 in range(1,i+1):\n if a[j]!=a[j2]!=a[j3] and a[j]+a[j2]+a[j3]==s:\n print(3)\n print(a[j],a[j2],a[j3])\n exit()"}, {"source_code": "s,k=[int(i) for i in input().split()]\na=[-1,0,1,1]\ni=3\nwhile a[i]<=pow(10,9):\n i+=1\n a.append(0)\n if i<=k:\n for j in range(1,i):\n a[i]+=a[j]\n else:\n for j in range(i-k,i):\n a[i]+=a[j]\nb=[]\nprint(a)\nfor j in range(i,0,-1):\n if a[j]<s and len(b)==0:\n b.append(a[j])\n s-=a[j]\n if s==0:\n break\n else:\n if a[j]<=s and len(b)>0:\n b.append(a[j])\n s-=a[j]\n if s==0:\n break\nprint(len(b))\nfor i in b:\n print(i,end=' ')"}, {"source_code": "s,k=[int(i) for i in input().split()]\na=[-1,0,1,1]\ni=3\nwhile a[i]<=pow(10,9):\n i+=1\n a.append(0)\n if i<=k:\n for j in range(1,i):\n a[i]+=a[j]\n else:\n for j in range(i-k,i):\n a[i]+=a[j]\nfor j in range(1,i+1):\n for j2 in range(1,i+1):\n for j3 in range(1,i+1):\n if (a[j]!=a[j2]) and(a[j2]!=a[j3]) and (a[j]!=a[j3]) and a[j]+a[j2]+a[j3]==s:\n print(3)\n print(a[j],a[j2],a[j3])\n exit()\nfor j2 in range(1,i+1):\n for j3 in range(1,i+1):\n if (a[j2]!=a[j3]) and a[j2]+a[j3]==s:\n print(2)\n print(a[j2],a[j3])\n exit()"}, {"source_code": "s,k=[int(i) for i in input().split()]\na=[-1,0,1,1]\ni=3\nwhile a[i]<=pow(10,9):\n i+=1\n a.append(0)\n if i<=k:\n for j in range(1,i):\n a[i]+=a[j]\n else:\n for j in range(i-k,i):\n a[i]+=a[j]\nb=[]\nprint(a)\nfor j in range(i,0,-1):\n if a[j]<=s:\n b.append(a[j])\n s-=a[j]\n if s==0:\n b.append(0)\n break\nprint(len(b))\nfor i in b:\n print(i,end=' ')"}, {"source_code": "s, k = map(int, raw_input().split())\nf = [1]\nwhile f[-1] < 10 ** 9 + 10:\n if len(f) > k:\n f.append(f[-1] * 2 - f[-k-1])\n else:\n f.append(f[-1] * 2)\nans = []\nt = s\nwhile s > 0:\n for x in reversed(f):\n if s >= x and t > x:\n ans.append(x)\n s -= x\n break\nprint len(ans)\nfor i in ans:\n print i,\n"}, {"source_code": "class Main:\n\ts=raw_input().split(\" \")\n\tl=[int(x) for x in s]\n\ts=l[0]\n\tk=l[1]\n\tif(s==1 and s==2):\n\t\tprint 2\n\t\tprint \"0 1\"\n\telse:\n\t\tprint 3\n\t\tprint 0,k-1,s-k\n"}, {"source_code": "class Main:\n\ts=raw_input().split(\" \")\n\tl=[int(x) for x in s]\n\ts=l[0]\n\tk=l[1]\n\tif(s<k):\n\t\tprint 2\n\t\tprint s,\"0\"\n\telif(k==2):\n\t\tprint \"2\"\n\t\tprint s,\"0\"\n\telse:\n\t\tx=s-k\n\t\tl1=[]\n\t\tt=0\n\t\twhile(x!=0):\n\t\t\tl1.append(x)\n\t\t\tt+=1\n\t\t\tx=x/4\n\t\tprint t\n\t\ts1=''\n\t\tfor x in l1:\n\t\t\ts1=s1+str(x)+\" \"\n\t\tprint s1\n"}, {"source_code": "l = [0,1]\ns,k = map(int,raw_input().split())\nwhile 1:\n t = sum(l if len(l) < k else l[-1:-1-k:-1])\n if t >= s: break\n l.append(t)\nr = []\nfor i in xrange(len(l)-1,-1,-1):\n if s == 0:\n if len(r) < 2: r.append(0)\n break\n elif s >= l[i]:\n r.append(l[i])\n s -= l[i]\nprint len(r)\nprint ' '.join(map(str,r))\n"}, {"source_code": "d = {}\ndef gen_kbs(k, n):\n if n < k:\n return 0\n if n == k:\n return 1\n if n in d:\n return d[n]\n return sum(gen_kbs(k, i) for i in xrange(n - k, n))\ns, k = map(int, raw_input().split())\ni = k\nkbs = []\nwhile True:\n v = gen_kbs(k, i)\n d[i] = v\n if v >= s:\n break\n kbs.append(v)\n i += 1\ncount = 0\nkbs = reversed(sorted(set(kbs)))\nans = []\nfor v in kbs:\n if s == 0:\n break\n if v == 0:\n continue\n if s >= v:\n ans.append(v)\n s -= v\nans = map(str, ans)\nprint len(ans)\nprint ' '.join(ans)"}, {"source_code": "d = {}\ndef gen_kbs(k, n):\n if n < k:\n return 0\n if n == k:\n return 1\n if n in d:\n return d[n]\n return sum(gen_kbs(k, i) for i in xrange(n - k, n))\ns, k = map(int, raw_input().split())\ni = k - 1\nkbs = []\nwhile True:\n v = gen_kbs(k, i)\n d[i] = v\n if v != 2 and v >= s:\n break\n kbs.append(v)\n i += 1\ncount = 0\nkbs = reversed(sorted(set(kbs)))\nans = []\nfor v in kbs:\n if s == 0 and len(ans) >= 2:\n break\n if s >= v:\n ans.append(v)\n s -= v\nans = map(str, ans)\nprint len(ans)\nprint ' '.join(ans)"}, {"source_code": "d = {}\ndef gen_kbs(k, n):\n if n < k:\n return 0\n if n == k:\n return 1\n if n in d:\n return d[n]\n return sum(gen_kbs(k, i) for i in xrange(n - k, n))\ns, k = map(int, raw_input().split())\ni = k - 1\nkbs = []\nwhile True:\n v = gen_kbs(k, i)\n d[i] = v\n if v >= s:\n break\n kbs.append(v)\n i += 1\ncount = 0\nkbs = reversed(sorted(set(kbs)))\nans = []\nfor v in kbs:\n if s == 0:\n break\n if v == 0:\n continue\n if s >= v:\n ans.append(v)\n s -= v\nans = map(str, ans)\nprint len(ans)\nprint ' '.join(ans)"}, {"source_code": "d = {}\ndef gen_kbs(k, n):\n if n < k:\n return 0\n if n == k:\n return 1\n if n in d:\n return d[n]\n return sum(gen_kbs(k, i) for i in xrange(max(n - k, k - 1), n))\ns, k = map(int, raw_input().split())\ni = k - 1\nkbs = []\nwhile True:\n v = gen_kbs(k, i)\n d[i] = v\n if v != 2 and v != 1 and v >= s:\n break\n kbs.append(v)\n i += 1\ncount = 0\nkbs = reversed(sorted(set(kbs)))\nans = []\nfor v in kbs:\n if s == 0 and len(ans) >= 2:\n break\n if s >= v:\n ans.append(v)\n s -= v\nans = map(str, ans)\nprint len(ans)\nprint ' '.join(ans)"}, {"source_code": "d = {}\ndef gen_kbs(k, n):\n if n < k:\n return 0\n if n == k:\n return 1\n if n in d:\n return d[n]\n return sum(gen_kbs(k, i) for i in xrange(n - k, n))\ns, k = map(int, raw_input().split())\ni = k\nkbs = []\nwhile True:\n v = gen_kbs(k, i)\n d[i] = v\n if v >= s:\n break\n kbs.append(v)\n i += 1\ncount = 0\nkbs = reversed(sorted(kbs))\nans = []\nfor v in kbs:\n if s == 0:\n break\n if v == 0:\n continue\n if s >= v:\n ans.append(v)\n s -= v\nans = map(str, ans)\nprint len(ans)\nprint ' '.join(ans)"}, {"source_code": "s,k=map(int,raw_input().split())\nt={}\ndef f(a,b):\n s=0\n if b < a: s=0\n elif b == a: s=1\n elif b in t:\n s=t[b]\n elif a > 32: s=2**(b-a-1)\n else:\n for i in range(b-a,b):\n s+=f(a,i)\n t[b] = s\n return s\n\ni=0\ne=0\nF=[]\nwhile e < s:\n i+=1\n e=f(k,i)\n F+=[e]\n \nr=[]\nfor e in reversed(F):\n if e <= s and e:\n r+=[`e`]\n s-=e\nprint len(r)\nprint ' '.join(r)"}, {"source_code": "s,k=map(int,raw_input().split())\nt={}\ndef f(a,b):\n s=0\n if b < a: s=0\n elif b == a: s=1\n elif b in t:\n s=t[b]\n elif a > 32: s=2**(b-a-1)\n else:\n for i in range(b-a,b):\n s+=f(a,i)\n t[b] = s\n return s\n\ni=0\ne=0\nF=[]\nwhile e < s:\n i+=1\n e=f(k,i)\n if e < s:\n F+=[e]\n \nr=[]\nfor e in reversed(F):\n if e <= s and e:\n r+=[`e`]\n s-=e\nprint len(r)\nprint ' '.join(r)"}, {"source_code": "def first_fib(s,k):\n bon = [0,1]\n summ = 0\n while summ < s:\n summ = 0\n if len(bon) < k: count = len(bon)\n else: count = k\n last = bon.index(max(bon))\n summ = sum(bon[-count:-1])+bon[last]\n bon.append(summ)\n del bon[last+1]\n return bon\nbon = [0]\ni = 0\ns,k = map(int,raw_input().split())\nif s == 1: print \"2\" + \"\\n\" + \"1 0\"\nelif s == 2: print \"2\" + \"\\n\" + \"1 1\"\nelif s == 3: print \"2\" + \"\\n\" + \"1 2\"\nelif s == 4: print \"2\" + \"\\n\" + \"2 2\"\nelse:\n if k<32: bon = first_fib(s,k)\n else:\n while (2**i) < s:\n bon.append(2**i)\n i+=1\n arr = []\n while s != 0:\n if s >= bon[-1]:\n s-=bon[-1]\n arr.append(bon.pop())\n else:\n del bon[-1]\n l = len(arr)\n print l\n print ' '.join(map(str,arr))\n"}, {"source_code": "s, k = map(int, raw_input().split())\na = [0] * k + [1]\nwhile a[-1] < s:\n\ta.append(sum(a[-k : ]))\nr = [`0`]\nfor x in a[ : k : -1]:\n\tif s >= x:\n\t\ts -= x\n\t\tr.append(`x`)\nprint len(r)\nprint ' '.join(r)"}, {"source_code": "import bisect\n\ndef start():\n s, k = map(int, raw_input().split())\n kbonacci = [0]*(k-1)\n kbonacci.append(1)\n i = k\n while kbonacci[i-1] < s:\n kbonacci.append(sum(kbonacci[i-k:i]))\n i = i+1\n summr = [0]\n while s > 0:\n bl = bisect.bisect_left(kbonacci,s)\n if kbonacci[bl] == s:\n summr.append(s)\n break\n else:\n s = s-kbonacci[bl-1]\n summr.append(kbonacci[bl-1])\n for x in summr:\n print x,\n\nstart()\n"}, {"source_code": "n, k = map(int, raw_input().split())\n\nbona = [1]\n\ncnt = 0\n\nwhile bona[-1] < n:\n if cnt < k:\n bona.append(2 ** cnt)\n else:\n bona.append(2 ** cnt - bona[cnt - k])\n cnt += 1\n\nans = []\n\nwhile n > 0:\n while bona[-1] > n:\n bona.pop()\n ans.append(bona[-1])\n n -= bona[-1]\n\nif len(ans) == 1:\n ans.append(0)\n\nprint len(ans)\nprint ' '.join(map(str, ans))\n"}, {"source_code": "n, k = map(int, raw_input().split())\n\nbona = [1]\n\ncnt = 0\n\nwhile bona[-1] < n:\n if cnt < k:\n bona.append(2 ** cnt)\n else:\n bona.append(2 ** cnt - bona[cnt - k])\n cnt += 1\n\nans = []\n\nwhile n > 0:\n while bona[-1] > n:\n bona.pop()\n ans.append(bona[-1])\n n -= bona[-1]\n\nprint len(ans)\nprint ' '.join(map(str, ans))\n"}, {"source_code": "\nfibarr = []\ndp = []\npredecessor = []\ndef gen_list(s, k):\n global fibarr\n \n fibarr = [0 for _ in xrange(k-1)]\n fibarr.append(1)\n fibarr.append(1)\n idx = k + 1\n while fibarr[idx - 1] <= s :\n fibarr.append(fibarr[idx-1] * 2 - fibarr[idx - k - 1])\n idx += 1\n\n\n \n \nif __name__ == '__main__': \n int_s, int_k = map(int, raw_input().split())\n \n gen_list(int_s, int_k)\n int_rem = int_s\n answer = []\n for ii in xrange(0, len(fibarr)) :\n if int_rem == 0 :\n break\n if (fibarr[ii] > int_rem) :\n continue\n else :\n int_rem -= fibarr[ii]\n answer.append(fibarr[ii])\n \n print len(answer)\n res = \"\"\n for item in answer :\n res+=str(item)+\" \"\n res = res[0:len(res)-1]\n print res\n pass"}, {"source_code": "\nfibarr = []\ndp = []\npredecessor = []\ndef gen_list(s, k):\n global fibarr\n \n fibarr = [0 for _ in xrange(k-1)]\n fibarr.append(1)\n fibarr.append(1)\n idx = k + 1\n while fibarr[idx - 1] <= s :\n fibarr.append(fibarr[idx-1] * 2 - fibarr[idx - k - 1])\n idx += 1\n\n\n \n \nif __name__ == '__main__': \n int_s, int_k = map(int, raw_input().split())\n \n gen_list(int_s, int_k)\n int_rem = int_s\n answer = []\n for ii in xrange(len(fibarr)-1, 0, -1) :\n if int_rem == 0 :\n break\n if (fibarr[ii] > int_rem) :\n continue\n else :\n int_rem -= fibarr[ii]\n answer.append(fibarr[ii])\n \n print len(answer)\n res = \"\"\n for item in answer :\n res+=str(item)+\" \"\n res = res[0:len(res)-1]\n print res\n pass"}, {"source_code": "#coding=utf-8\n\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n#for i in range(1,20):\n#\tfor j in range(1,20):\n#\t\tprint \"%3d\"%F(i,j),\n#\tprint \n\ndef Gen_F(k,MAX):\n\tif k == 1:\n\t\treturn [0,1]\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb < MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\n\t\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\n\n#print [F(k,i) for i in range(k,k+20)]\n#print FL\n\nFL = list(reversed(sorted(FL)))\n\n#print FL\nans = [0]\nwhile s != 0:\n\tfor i in FL:\n\t\tif s >= i:\n\t\t\tans.append(i)\n\t\t\ts = s - i\n\t\t\tbreak;\n\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "#coding=utf-8\n\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n\t\ndef Gen_F(k,MAX):\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb < MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\nFL = list(reversed(sorted(FL)))\n#print FL\nans = []\nwhile s != 0:\n\tfor i in FL:\n\t\tif s >= i:\n\t\t\tans.append(i)\n\t\t\ts = s - i\n\t\t\tbreak;\n\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "#coding=utf-8\n\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n#for i in range(1,20):\n#\tfor j in range(1,20):\n#\t\tprint \"%3d\"%F(i,j),\n#\tprint \n\ndef Gen_F(k,MAX):\n\tif k == 1:\n\t\treturn [0,1]\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb < MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\n\t\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\n\n#print [F(k,i) for i in range(k,k+20)]\n#print FL\n\nFL = list(reversed(sorted(FL)))\n\n#print FL\n\nans = []\nfor i in FL:\n\tif s >= i:\n\t\tans.append(i)\n\t\ts = s - i\n\t\t\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "#coding=utf-8\n\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n\t\ndef Gen_F(k,MAX):\n\tif k == 1:\n\t\treturn [0,1]\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb < MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\nFL = list(reversed(sorted(FL)))\n#print FL\nans = [0]\nwhile s != 0:\n\tfor i in FL:\n\t\tif s >= i:\n\t\t\tans.append(i)\n\t\t\ts = s - i\n\t\t\tbreak;\n\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "#coding=utf-8\n\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n#for i in range(1,20):\n#\tfor j in range(1,20):\n#\t\tprint \"%3d\"%F(i,j),\n#\tprint \n\ndef Gen_F(k,MAX):\n\tif k == 1:\n\t\treturn [0,1]\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb < MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\n\t\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\nFL = list(reversed(sorted(FL)))\n#print [F(k,i) for i in range(1,20)]\n#print FL\nans = [0]\nwhile s != 0:\n\tfor i in FL:\n\t\tif s >= i:\n\t\t\tans.append(i)\n\t\t\ts = s - i\n\t\t\tbreak;\n\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "#coding=utf-8\n\n#import Set\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n#for i in range(1,20):\n#\tfor j in range(1,20):\n#\t\tprint \"%3d\"%F(i,j),\n#\tprint \n\ndef Gen_F(k,MAX):\n\tif k == 1:\n\t\treturn [0,1]\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb < MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\n\t\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\n\n#print [F(k,i) for i in range(k,k+20)]\n#print FL\n\nFL = list(reversed(sorted(list(set(FL)))))\n\n#print FL\n\nans = []\nfor i in FL:\n\tif s >= i:\n\t\t#print s,i\n\t\tans.append(i)\n\t\ts = s - i\n\t\t\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "#coding=utf-8\n\n#import Set\ndef F(k,n):\n\tif 1 <= n and n < k:\n\t\treturn 0\n\tif n == k:\n\t\treturn 1\n\treturn sum([F(k,i) for i in range(n-k,n)])\n\t\n#for i in range(1,20):\n#\tfor j in range(1,20):\n#\t\tprint \"%3d\"%F(i,j),\n#\tprint \n\ndef Gen_F(k,MAX):\n\tif k == 1:\n\t\treturn [0,1]\n\tL = [0,1]\n\tl = -k + 2\n\tkb = 1\n\twhile kb <= MAX:\n#\t\tprint kb,l,l+k\n\t\tL.append(kb)\n\t\tkb = kb * 2\n\t\tif l >= 0:\n\t\t\tkb = kb - L[l]\n\t\tl = l + 1\n\treturn L\n\t\ns,k = map(int, raw_input().split())\nFL = Gen_F(k,s)\n\nprint [F(k,i) for i in range(k,k+20)]\nprint FL\n\nFL = list(reversed(sorted(list(set(FL)))))\n\n#print FL\n\nans = []\nfor i in FL:\n\tif s >= i:\n\t\t#print s,i\n\t\tans.append(i)\n\t\ts = s - i\n\t\t\nprint len(ans)\nfor i in ans:\n\tprint i,\nprint\n\n\n\n"}, {"source_code": "s, k = map(int, raw_input().split())\nl = [0, 1]\nwhile True:\n l.append(sum(l[-k:]))\n if (l[-1] > s):\n l = l[:-1]\n break\nprint '#', s, l\nans = []\nfor i in l[::-1]:\n if s >= i:\n s -= i\n ans.append(i)\n\nprint len(ans)\nprint ' '.join(map(str, ans))\n"}, {"source_code": "s, k = map(int, raw_input().split())\nl = [0, 1]\nwhile True:\n l.append(sum(l[-k:]))\n if (l[-1] >= s):\n l = l[:-1]\n break\n#print '#', s, l\nans = []\nfor i in l[::-1]:\n if s >= i:\n s -= i\n ans.append(i)\n#print '#', sum(ans), s\nprint len(ans)\nprint ' '.join(map(str, ans))\n"}, {"source_code": "\nmyin = raw_input()\nmyin = myin.split()\n\nmysum = int(myin[0])\nmyk = int(myin[1])\n\nkbon = [0,] * (myk - 1)\nkbon.append(1)\n\nwhile kbon[len(kbon) - 1] < mysum:\n temp = 0\n for i in range(myk):\n temp += kbon[len(kbon) - 1 - i]\n kbon.append(temp)\n\nmyout = []\n\nmysumtemp = mysum\n\nfor i in range(len(kbon) - 2, -1, -1):\n if kbon[i] == 0:\n break\n if kbon[i] <= mysumtemp:\n myout.append(kbon[i])\n mysumtemp -= kbon[i]\n \n\nprint len(myout)\nouttemp = ''\nfor i in myout:\n outtemp += str(i) + ' '\n\nouttemp = outtemp[:len(outtemp) - 1]\nprint outtemp\n\n\n\n\n\n\n"}, {"source_code": "\nmyin = raw_input()\nmyin = myin.split()\n\nmysum = int(myin[0])\nmyk = int(myin[1])\n\nkbon = [0,] * (myk - 1)\nkbon.append(1)\n\nwhile kbon[len(kbon) - 1] < mysum:\n temp = 0\n for i in range(myk):\n temp += kbon[len(kbon) - 1 - i]\n kbon.append(temp)\n\nmyout = []\n\nmysumtemp = mysum\n\nfor i in range(len(kbon) - 2, -1, -1):\n if kbon[i] == 0:\n break\n if kbon[i] <= mysumtemp:\n myout.append(kbon[i])\n mysumtemp -= kbon[i]\n\n\nprint len(myout) + 1\nouttemp = ''\nfor i in myout:\n outtemp += str(i) + ' '\n\nouttemp = outtemp[:len(outtemp) - 1]\nprint outtemp + ' 0'\n"}, {"source_code": "\nmyin = raw_input()\nmyin = myin.split()\n\nmysum = int(myin[0])\nmyk = int(myin[1])\n\nkbon = [0,] * (myk - 1)\nkbon.append(1)\n\nwhile kbon[len(kbon) - 1] < mysum:\n temp = 0\n for i in range(myk):\n temp += kbon[len(kbon) - 1 - i]\n kbon.append(temp)\n\nmyout = []\n\nmysumtemp = mysum\n\nfor i in range(len(kbon) - 2, -1, -1):\n if kbon[i] == 0:\n break\n if kbon[i] <= mysumtemp:\n myout.append(kbon[i])\n mysumtemp -= kbon[i]\n\n\nprint len(myout) + 1\nouttemp = ''\nfor i in myout:\n outtemp += str(i) + ' '\n\nouttemp = outtemp[:len(outtemp) - 1]\nprint outtemp + ' 0'\n"}, {"source_code": "\nmyin = raw_input()\nmyin = myin.split()\n\nmysum = int(myin[0])\nmyk = int(myin[1])\n\nkbon = [0,] * (myk - 1)\nkbon.append(1)\n\nwhile kbon[len(kbon) - 1] < mysum:\n temp = 0\n for i in range(myk):\n temp += kbon[len(kbon) - 1 - i]\n kbon.append(temp)\n\nmyout = []\n\nmysumtemp = mysum\n\nfor i in range(len(kbon) - 2, -1, -1):\n if kbon[i] == 0:\n break\n if kbon[i] <= mysumtemp:\n myout.append(kbon[i])\n mysumtemp -= kbon[i]\n\n\nprint len(myout)\nouttemp = ''\nfor i in myout:\n outtemp += str(i) + ' '\n\nouttemp = outtemp[:len(outtemp) - 1]\nprint outtemp\n"}, {"source_code": "\nmyin = raw_input()\nmyin = myin.split()\n\nmysum = int(myin[0])\nmyk = int(myin[1])\n\nkbon = [0,] * (myk - 1)\nkbon.append(1)\n\nwhile kbon[len(kbon) - 1] < mysum:\n temp = 0\n for i in range(myk):\n temp += kbon[len(kbon) - 1 - i]\n kbon.append(temp)\n\nmyout = []\n\nmysumtemp = mysum\n\nfor i in range(len(kbon) - 2, -1, -1):\n if kbon[i] == 0:\n break\n if kbon[i] <= mysumtemp:\n myout.append(kbon[i])\n mysumtemp -= kbon[i]\n\n\nprint len(myout)\nouttemp = ''\nfor i in myout:\n outtemp += str(i) + ' '\n\nouttemp = outtemp[:len(outtemp) - 1]\nprint outtemp + ' 0'\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import generators\nfrom __future__ import nested_scopes\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\nfrom __future__ import with_statement\n\nimport bisect\nimport collections\nimport copy\nimport functools\nimport heapq\nimport itertools\nimport math\nimport operator\nimport os\nimport re\nimport random\nimport sys\nfrom pprint import pprint\n\n__author__ = 'Aphrodite'\n\n\ndef main():\n iterator = itertools.imap(str.rstrip, sys.stdin.readlines())\n s, k = map(int, next(iterator).split())\n a = [0] * (k - 1)\n a.append(1)\n while a[-1] < s:\n a.append(sum(a[-k:]))\n# print(a)\n res = []\n while s > 0:\n idx = bisect.bisect(a, s) - 1\n s -= a[idx]\n res.append(a[idx])\n print(len(res))\n print(' '.join(map(str, res)))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s, k = map(int, raw_input().split())\nsums, sequence = 1, [1]\nwhile sums <= s:\n sequence.append(sums)\n sums += sums\n if len(sequence) > k:\n sums -= sequence[-(k + 1)]\nresult = []\nfor i in reversed(sequence):\n if i <= s:\n s -= i\n result.append(i)\nprint len(result)\nprint \" \".join(map(str, result))\n"}, {"source_code": "s, k = map(int, raw_input().split())\nsums, sequence = 1, [1]\nwhile sums < s:\n sequence.append(sums)\n sums += sums\n if len(sequence) > k:\n sums -= sequence[-(k + 1)]\nresult = []\nfor i in reversed(sequence):\n if i <= s:\n s -= i\n result.append(i)\nprint len(result)\nprint \" \".join(map(str, result))\n"}, {"source_code": "#import sys\n#\n#sys.stdin = open('in.txt', 'r')\n\ns, k = map(int, raw_input().split())\nfib = [0, 1, 1]\n\nwhile(True):\n fib.append(sum(fib[-k:]))\n if fib[-1] >= s: \n del fib[-1]\n break\n\nans = []\n\nwhile(True):\n x = fib.pop()\n if x <= s: \n s -= x\n ans.append(x)\n if s == 0:\n break\nans.append(0)\nprint len(ans)\nprint ' '.join(map(str, ans))\n\n\n"}, {"source_code": "#import sys\n#\n#sys.stdin = open('in.txt', 'r')\n\ns, k = map(int, raw_input().split())\nfib = [0] * k + [1]\n\nwhile(True):\n fib.append(sum(fib[-k:]))\n if fib[-1] >= s: \n del fib[-1]\n break\n\nans = []\n\nwhile(True):\n x = fib.pop()\n if x <= s: \n s -= x\n ans.append(x)\n if s == 0:\n break\nprint len(ans)\nprint ' '.join(map(str, ans))\n\n\n"}, {"source_code": "def readInt():\n return tuple([int(x) for x in raw_input().split()])\n\ns, k = readInt()\nfib = [0] * (k - 1) + [1]\nwhile fib[-1] < s:\n fib.append(sum(fib[-k:]))\nans = []\nwhile s > 0:\n if fib[-1] <= s:\n ans.append(str(fib[-1]))\n s -= fib[-1]\n fib.pop()\nprint len(ans)\nprint \" \".join(ans)\n"}, {"source_code": "import bisect \ns,k=list(map(int,input().split()))\nf=[0]*45\nfor i in range(45):\n if i<k:\n f[i]=i*(i+1)//2\n else:\n f[i]=sum([f[i-j] for j in range(1,k+1)])\nans=[0]\nwhile s>0:\n i=bisect.bisect_right(f,s)\n ans.append(f[i-1])\n s=s-f[i-1]\nprint(len(ans))\nfor i in range(len(ans)):\n print(ans[i],end=' ')"}, {"source_code": "s,k=map(int,input().split())\narr=[0];k1=0;visited=[];mini=0\nwhile(1):\n k1+=1\n if(k1==k):arr.append(1);\n elif(k1<k):arr.append(0);\n else:\n sum1=0\n for i in range(k1-1,k1-k-1,-1):\n sum1+=arr[i]\n if(sum1>=s):break;\n arr.append(sum1)\nwhile(s>0):\n for i in arr:\n if(i<=s):mini=i;\n else:break;\n s-=mini;visited.append(mini);\nif(len(visited)==0):visited.append(0);\nprint(len(visited))\nprint(*visited) "}, {"source_code": "s,k=map(int,input().split())\narr=[0];k1=0;visited=[];mini=0\nwhile(1):\n k1+=1\n if(k1==k):arr.append(1);\n elif(k1<k):arr.append(0);\n else:\n sum1=0\n for i in range(k1-1,k1-k-1,-1):\n sum1+=arr[i]\n if(sum1>=s):break;\n arr.append(sum1)\nwhile(s>0):\n for i in arr:\n if(i<=s):mini=i;\n else:break;\n s-=mini;visited.append(mini);\nprint(len(visited))\nprint(*visited) "}, {"source_code": "def power(a, b):\n if b == 0:\n return 1\n elif b % 2 == 0:\n a_1 = a * a\n return pow(a_1, b // 2)\n return a * pow(a, b - 1)\n\n\ndef k_fib(s, k):\n result = list()\n if k >= 40:\n fibs = [power(2, i) for i in range(40)]\n else:\n fibs = [0] * (k - 1) + [1]\n while fibs[len(fibs) - 1] < s:\n fibs.append(sum(fibs[-k:]))\n while s > 0:\n if fibs[len(fibs) - 1] <= s:\n result.append(fibs[len(fibs) - 1])\n s -= fibs[len(fibs) - 1]\n fibs.pop()\n return result\n\n\nS, K = [int(j) for j in input().split()]\nprint(len(k_fib(S, K)))\nprint(*k_fib(S, K))\n"}, {"source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as c\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(var): sys.stdout.write(str(var))\ndef outln(var): sys.stdout.write(str(var)+\"\\n\")\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\ndef k_bonacci(n):\n if n < k:\n return 0\n if n == k:\n return 1\n if n in dp.keys():\n return dp[n]\n dp[n] = 0\n for i in range(n-k, n):\n dp[n] += k_bonacci(i)\n return dp[n]\n\n\ns, k = sp()\nanswer = []\nif k <= 32:\n dp = dd(int)\n i = 1\n while True:\n dp[i] = k_bonacci(i)\n if dp[i] >= pow(10, 9):\n break\n i += 1\n arr = list(dp.values())\n while s > 0:\n temp = bl(arr, s)\n if arr[temp] > s:\n temp -= 1\n s -= arr[temp]\n answer.append(arr[temp])\nelse:\n i = 32\n while i >= 0 and s > 0:\n if pow(2, i) <= s:\n s -= pow(2, i)\n answer.append(pow(2, i))\n i -= 1\nif len(answer) < 2:\n answer.insert(0, 0)\nprint(*answer)\n"}, {"source_code": "s,k=map(int,input().split())\nF = []\nb = []\nwhile k > 1:\n F.append(0)\n k -= 1\nF.append(1)\nk = len(F)\nwhile True:\n f = sum(F[-k:])\n if f > s:\n break\n F.append(f)\nfor i in reversed(F):\n if i <= s:\n b.append(i)\n s -= i\nprint(len(b))\nprint (' '.join(map(str,b)))\n "}, {"source_code": "n,k=map(int,input().split())\nif n==2:\n print(2)\n print(0,2)\nelse:\n print(2)\n print(1,n-1)"}, {"source_code": "def genkbon (s, k):\n if (k<50):\n i = 0\n res = [0]\n while (res[i]<=s):\n if (i<k):\n res.append(0)\n elif (i==k):\n res.append(1)\n elif (i==k+1):\n res.append(1)\n else:\n res.append(2*res[i]-res[i-k])\n i += 1\n del res[-1]\n return res\n if (k>=50):\n res = [0,1]\n i = 1\n while (res[i]<=s):\n res.append(2*res[i])\n i += 1\n print(res)\n return res\n \ndef solve(s, k, tmp):\n tmp2 = tmp\n while (tmp2[-1]>s):\n del tmp2[-1]\n if (s==0):\n return [0]\n if (s==1):\n return [0,1]\n if (s==2):\n return [0,2]\n ha = tmp2[-1]\n res = solve(s-ha,k,tmp2)\n return [ha]+res\n \ninp1 = input()\ninp = inp1.split()\nhlp = genkbon(int(inp[0]),int(inp[1]))\nsol = solve(int(inp[0]),int(inp[1]), hlp)\nprint(len(sol))\nfor i in sol[:-1]:\n print(i,end=' ')\nprint(sol[-1])"}, {"source_code": "def genkbon (s, k):\n res = [0]\n i = 0\n while (res[i]<s):\n if (i<k):\n res.append(0)\n elif (i==k):\n res.append(1)\n elif (i==k+1):\n res.append(1)\n else:\n res.append(2*res[i]-res[i-k])\n i += 1\n del res[-1]\n return res\n \ndef solve(s, k):\n if (s<3):\n return [0,s]\n tmp = genkbon (s, k)\n ha = tmp[-1]-tmp[-1-k]\n res = solve(s-ha,k)\n return tmp[-1-k+1:-1]+res\n \ninp1 = input()\ninp = inp1.split()\nsol = solve(int(inp[0]),int(inp[1]))\nprint(len(sol))\nfor i in sol[:-1]:\n print(i,end=' ')\nprint(sol[-1])"}, {"source_code": "def genFib(k, n):\n cur = 1\n ind = -k + 2\n ret = [0, 1]\n while cur < n:\n ret.append(cur)\n cur += cur\n if ind >= 0:\n cur -= ret[ind]\n ind += 1\n return ret\n\ndef get(n, cur, last):\n global f, m\n if n == 0:\n cur.append(0)\n print len(cur)\n print ' '.join(map(str, cur))\n exit(0)\n for i in range(last, m):\n x = f[i]\n if x <= n:\n get(n - x, cur + [x], i + 1)\n\nn, k = map(int, raw_input().split())\nf = genFib(k, n)[::-1]\nm = len(f)\nget(n, [], 0)\nexit(1)\n"}, {"source_code": "def genFib(k, n):\n cur = 1\n ind = -k + 2\n ret = [0, 1]\n while cur < n:\n ret.append(cur)\n cur += cur\n if ind >= 0:\n cur -= ret[ind]\n ind += 1\n return ret\n\ndef get(n, cur):\n global f\n if n == 0:\n cur.append(0)\n print len(cur)\n print ' '.join(map(str, cur))\n exit(0)\n for x in f:\n if x <= n and x not in cur:\n get(n - x, cur + [x])\n\nn, k = map(int, raw_input().split())\nf = genFib(k, n)[::-1]\nget(n, [])\n"}, {"source_code": "import sys\nif sys.version_info[0] == 2: input = raw_input\ns, k = map(int,input().split())\nif s == 1:\n print('2\\n0 1')\n sys.exit(0)\nelif s==2:\n print('2\\n0 2')\n sys.exit(0)\nn = 2\nans = []\na = [0] * 100\na[0] = a[1] = 1\nwhile a[n-1] < s:\n a[n] = 2*a[n-1]-(a[n-k-1] if n-k-1>=0 else 0)\n n += 1\n\nfor i in range(n-1,-1,-1):\n if a[i] <= s:\n ans.append(a[i])\n s -= a[i]\n if s == 0: break\nprint(len(ans) + 2)\nprint('0 0 ' + \" \".join(map(str,ans)))\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a[:-1]):\n if i<=s:\n b.append(i)\n s-=i\nprint len(b)\nprint ' '.join(map(str,b))\n"}, {"source_code": "s,k=map(int,raw_input().split())\na,b=[1],[]\nwhile a[-1]<s:\n a.append(sum(a[-k:]))\nfor i in reversed(a[:-1]):\n if i<=s:\n b.append(i)\n s-=i\nprint ' '.join(map(str,b))\n"}, {"source_code": "s, k = map(int, raw_input().split())\nF = [1]\ntotal = 1\nwhile len(F) < k and total <= s:\n val = F[-1]\n if total + val <= s:\n F.append(total + val)\n total += val\n else:\n break\n\ntotal = sum(F)\nwhile total <= s:\n val = sum(F[-k:])\n F.append(val)\n total += val\n\n\n\nC = []\nF = F[::-1]\ndef find_recur(n):\n if n > 0:\n if n in F:\n C.append(n)\n else:\n x = next(x for x in F if x < n)\n if x is not None:\n C.append(x)\n y = find_recur(n - x)\n if y is not None:\n C.append(y)\n return None\nif s in F:\n print 2\n print 0, s\n exit()\nelse:\n find_recur(s)\n print \" \".join(map(str, C))\n"}, {"source_code": "s, k = map(int, raw_input().split())\nA = [1, 2, 3]\ntotal = 6\nwhile total <= s:\n num = A[-1] + A[-2]\n A.append(num)\n total += num\n\nif total == s:\n print len(A)\n print \" \".join(map(str, A))\nelse:\n extra = total - s\n import bisect\n for i in xrange(len(A)):\n n1 = A[i]\n n2 = extra - A[i]\n if n2 == 0:\n A[i] = ''\n print \" \".join(map(str, filter(lambda x: x!='',A)))\n break\n else:\n pos = bisect.bisect_left(A,n2,i+1)\n if pos != len(A) and A[pos] == n2:\n A[i] = ''\n A[pos] = ''\n print \" \".join(map(str, filter(lambda x: x!='',A)))\n break\n\n"}, {"source_code": "s, k = map(int, raw_input().split())\nF = [1]\ntotal = 1\nwhile len(F) < k and total <= s:\n val = F[-1]\n if total + val <= s:\n F.append(total + val)\n total += val\n else:\n break\n\ntotal = sum(F)\nwhile total <= s:\n val = sum(F[-k:])\n F.append(val)\n total += val\n\n\n\nC = []\nF = F[::-1]\ndef find_recur(n):\n if n > 0:\n if n in F:\n C.append(n)\n else:\n x = next(x for x in F if x < n)\n if x is not None:\n C.append(x)\n y = find_recur(n - x)\n if y is not None:\n C.append(y)\n return None\nif s in F:\n print 2\n print 0, s\n exit()\nelse:\n find_recur(s)\n print(len(C))\n print \" \".join(map(str, C))"}, {"source_code": "s, k = map(int, raw_input().split())\nA = [1, 2, 3]\ntotal = 6\nwhile total <= s:\n num = A[-1] + A[-2]\n A.append(num)\n total += num\n\nif total == s:\n print len(A)\n print \" \".join(map(str, A))\nelse:\n extra = total - s\n import bisect\n for i in xrange(len(A)):\n n1 = A[i]\n n2 = extra - A[i]\n pos = bisect.bisect_left(A,n2,i+1)\n if pos != len(A) and A[pos] == n2:\n A[i] = ''\n A[pos] = ''\n print \" \".join(map(str, filter(lambda x: x!='',A)))\n break\n\n"}, {"source_code": "s, k = map(int, raw_input().split())\nA = [1, 2, 3]\ntotal = 6\nwhile total <= s:\n num = A[-1] + A[-2]\n A.append(num)\n total += num\n\nif total == s:\n print len(A)\n print \" \".join(map(str, A))\nelse:\n extra = total - s\n import bisect\n for i in xrange(len(A)):\n n1 = A[i]\n n2 = extra - A[i]\n if n2 == 0:\n A[i] = ''\n print len(A)-1\n print \" \".join(map(str, filter(lambda x: x!='',A)))\n break\n else:\n pos = bisect.bisect_left(A,n2,i+1)\n if pos != len(A) and A[pos] == n2:\n A[i] = ''\n A[pos] = ''\n print len(A)-2\n print \" \".join(map(str, filter(lambda x: x!='',A)))\n break\n\n"}], "src_uid": "da793333b977ed179fdba900aa604b52"} {"source_code": "import sys\nimport math\n\nx, t, a, b, da, db = [int(x) for x in (sys.stdin.readline()).split()]\nd = [0] * 601\n\nif(x == 0):\n print(\"YES\")\n exit()\n\nfor i in range(t):\n if(x - b == 0):\n print(\"YES\")\n exit()\n d[b] = 1\n b -= db\n \nfor i in range(t):\n if(x - a > 0 and d[x - a] == 1 or x - a == 0):\n print(\"YES\")\n exit()\n\n a -= da\n \nprint(\"NO\")", "positive_code": [{"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nans=chk=0\nal,bl=[0],[0]\nfor _ in range(t):\n if a>=0:\n al.append(a)\n a-=da\n else:\n al.append(0)\n break\nfor _ in range(t):\n if b>=0:\n bl.append(b)\n b-=db\n else:\n bl.append(0)\n break\nal.sort(); bl.sort()\nfor i in al:\n for j in bl:\n if i+j==x:\n print 'YES'\n exit()\n elif i+j>x:\n break\nprint 'NO'"}, {"source_code": "x, t, a, b, da, db = map(int, input().split())\nA = [0] + [a-i*da for i in range(t)]\nB = {0} | {b-i*db for i in range(t)}\n\nprint('YES' if any(x-a in B for a in A) else 'NO')"}, {"source_code": "# import sys\n# from itertools import takewhile\n# \n# x, t, a, b, da, db = map(int, raw_input().strip().split())\n# \n# if x == 0:\n# print \"YES\"\n# sys.exit(0)\n# \n# a_set = list(takewhile(lambda i: i != 0, (max([a - da*s, 0]) for s in range(t))))\n# b_set = set(takewhile(lambda i: i != 0, (max([b - db*s, 0]) for s in range(t))))\n# \n# for a in a_set:\n# if (a == x) or (a < x and (x-a) in b_set):\n# print \"YES\"\n# sys.exit(0)\n# \n# print \"NO\"\nimport sys\n\ndef main():\n x, t, a, b, da, db = map(int, sys.stdin.readline().strip().split())\n if x==0:\n return \"YES\"\n \n for q in range(t):\n for w in range(t):\n if x == (max(0, a - q*da) + max(0, b - w*db)) or x==(max(a - q*da, 0)) or (x == max(0, b-w*db)):\n return 'YES'\n return 'NO'\n\nif __name__ == \"__main__\":\n print main()"}, {"source_code": "x,t,a,b,dA,dB = map(int, input().split())\nif x==0 or a==x or b==x:\n print (\"YES\")\n exit()\ntempA = a\ntempB = b\nfor i in range(t):\n tempA = a - i*dA\n #print(\"A\", tempA)\n tempB = b\n for j in range(t):\n tempB = b - j*dB\n #print(\"B\", tempB)\n if tempA+tempB == x or tempA == x or tempB == x:\n print (\"YES\")\n exit()\nprint (\"NO\")\n "}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nA=[0]+[a-i*da for i in range(t)]\nB=[0]+[b-i*db for i in range(t)]\nfor i in A:\n if x-i in B:\n print \"YES\"\n quit()\nprint \"NO\""}, {"source_code": "x, t, a, b, da, db = map(int, input().split())\nla = [0] + list(range(a, a - t * da, -da))\nlb = [0] + list(range(b, b - t * db, -db))\nprint('YES' if any(pa + pb == x for pa in la for pb in lb) else 'NO')"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nA=[0]+map(lambda x:a-x*da,range(t))\nB=[0]+map(lambda x:b-x*db,range(t))\nfor i in A:\n if x-i in B:\n print \"YES\"\n quit()\nprint \"NO\""}, {"source_code": "x, t, a, b, da, db = map(int, input().split())\nA, B = [0] + [a - da * i for i in range(t)], set([0] + [b - db * i for i in range(t)])\nprint('YES' if any(x - i in B for i in A) else 'NO')"}, {"source_code": "x , t , a , b , da , db = list(map(int , raw_input().split()))\nok = False\nfor i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x:\n ok = True\n\nfor i in range(0 , t):\n if a - da * i == x:\n ok = True\n break\n \nfor i in range(0 , t):\n if b - db * i == x:\n ok = True\n break\n\nif ok == True or x == 0:\n print \"YES\"\nelse:\n print \"NO\"\n\n "}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\n\nif a == 0:\n\tprint(\"YES\")\n\texit(0)\n\nfor i in range(b):\n\tx = c\n\ty = d\n\tfor j in range(b):\n\t\tif x == a or y == a or x + y == a:\n\t\t\tprint(\"YES\")\n\t\t\texit(0)\n\t\tx -= e\n\td -= f\nprint(\"NO\")"}, {"source_code": "def solve():\n\tx, t, a, b, da, db = map(int, input().split())\n\tif x == 0:\n\t\tprint(\"YES\")\n\t\treturn\n\tfor i in range(t):\n\t\tf = a-i*da\n\t\tif f == x:\n\t\t\tprint(\"YES\")\n\t\t\treturn\n\t\tfor j in range(t):\n\t\t\tg = b-j*db\n\t\t\tif g == x or f+g == x:\n\t\t\t\tprint(\"YES\")\n\t\t\t\treturn\n\tprint(\"NO\")\nsolve()\n"}, {"source_code": "x, t, a, b, da, db = (int(q) for q in input().split())\nif (x in (a - da * i + b - db * j for i in range(t) for j in range(t)) or\n (a >= x and (a - x) % da == 0 and (a - x) // da < t) or\n (b >= x and (b - x) % db == 0 and (b - x) // db < t) or\n x == 0):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "l=[int(x) for x in input().split()]\n\nx=l[0]\nt=l[1]\na=l[2]\nb=l[3]\nda=l[4]\ndb=l[5]\na1=[]\nb1=[]\nfor i in range(t):\n aa=a-i*da\n ab=b-i*db\n a1.append(aa)\n b1.append(ab)\n\n\nf=0\nfor e in a1:\n if x==e:\n f=1\n\nfor e in b1:\n if x==e:\n f=1\n \nfor e in a1:\n if(x-e) in b1:\n f=1\n break\n\nfor e in b1:\n if(x-e) in a1:\n f=1\n break\n \nif x==0:\n print(\"YES\")\n\nelif f==0:\n print(\"NO\")\nelif f==1:\n print(\"YES\")\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nA=[0]+[a-i*da for i in range(t)]\nB=[0]+[b-i*db for i in range(t)]\nfor i in A:\n\tif x-i in B:\n\t\tprint \"YES\"\n\t\tquit()\nprint \"NO\""}, {"source_code": "def stripped_line():\n return raw_input().strip()\n\n\ndef read_ints():\n return map(int, stripped_line().split())\n\nx, t, a, b, da, db = read_ints()\n\nar, br = [0, a], [0, b]\n\nfor i in xrange(1, t):\n ar.append(a - (i * da))\n br.append(b - (i * db))\n\nfor am in ar:\n for bm in br:\n if (am + bm) == x:\n print 'YES'\n exit(0)\nprint 'NO'\n"}, {"source_code": "x, t, a, b, da, db = map(int, input().split())\nans = 'NO'\nfor t1 in range(t):\n\tfor t2 in range(t):\n\t\tif a - da*t1 + b - db*t2 == x or a - da*t1 == x or b - db*t2 == x or x == 0:\n\t\t\tans = 'YES'\n\t\t\tbreak\nprint(ans)\n"}, {"source_code": "from itertools import product\nx, t,a,b,da,db = map(int, input().split())\nans=0\nla,lb = [0],[0]\nfor i in range(t):\n la +=[a-i*da]\n lb +=[b-i*db]\nfor sx in product(la,lb):\n if sx[0]+sx[1]==x:\n ans=1\n break\nprint(['NO','YES'][ans])"}, {"source_code": "#!/usr/bin/python3\n\ndef readln(): return tuple(map(int, input().split()))\n\nx, t, a, b, da, db = readln()\nfor i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x or x == 0 or a - i * da == x or b - j * db == x:\n da = -1\n break\n if da == -1:\n break\nprint('YES' if da == -1 else 'NO')\n"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\n\nfor i in xrange(2):\n for j in xrange(2):\n for p in xrange(t):\n for q in xrange(t):\n if x == i * (a - da * p) + j * (b - db * q):\n print \"YES\"\n exit()\n\nprint \"NO\""}, {"source_code": "x, t, a, b, d1, d2 = map(int, input().split())\nla, lb = [0] + [a-d1*i for i in range(t)], [0] + [b-d2*j for j in range(t)]\nfor s in la:\n if x-s in lb:\n print(\"YES\")\n break\nelse:\n print(\"NO\")"}, {"source_code": "#he might not solve a problem but if he would he would\n#gain d corres. points at dat time\n#\nx,t,a,b,da,db=map(int,raw_input().split(\" \"))\nfirst=[0,a]\nsecond=[0,b]\nfor i in range(1,t):\n a-=da\n b-=db\n first.append(a)\n second.append(b)\n#\np=0\nfor c in first:\n for d in second:\n if c+d==x:\n p=1\n break\n if p==1:\n break\nif p==1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "x,t,a,b,da,db=map(int,input().split())\ncase=False\nfor fa in range(2):\n for fb in range(2):\n for i in range(t):\n for j in range(t):\n if(fa*a-fa*(i*da)+fb*b-fb*(j*db)==x):\n case=True\nif(case):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "x, t, a, b, da, db = [int(x) for x in raw_input().split()]\nok = False\nfor t1 in range(t):\n for t2 in range(t):\n for p1 in range(2):\n for p2 in range(2):\n if p1 * (a - da * t1) + p2 * (b - db * t2) == x:\n ok = True\nif ok:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "[x,tt,a,b,da,db] = map(int, raw_input().split())\nres = \"NO\"\nfor t in xrange(tt):\n for s in xrange(tt):\n if x == (max(0, a - da * t) + max(0, b - db * s)):\n res = \"YES\"\n if x == (max(0, a - da * t)):\n res = \"YES\"\n if x == (max(0, b - db * s)):\n res = \"YES\"\nif x == 0:\n res = \"YES\"\n\nprint res\n"}, {"source_code": "n=input().split()\nx=int(n[0])\nt=int(n[1])\na=int(n[2])\nb=int(n[3])\nda=int(n[4])\ndb=int(n[5])\nif x==0:\n print('YES')\n exit()\nfor i in range(t):\n for j in range(t):\n if x==a-(da*i)+b-(db*j):\n print('YES')\n exit()\n elif x==a-(da*i):\n print('YES')\n exit()\n elif x==b-(db*j):\n print('YES')\n exit()\nprint('NO') \n"}, {"source_code": "x, t, a, b, c, d = map(int, input().split())\nif x == 0:\n print('YES')\n exit()\nfor i in range(t):\n if (x == a - c * i or x == b - d * i):\n print('YES')\n exit()\n for j in range(t):\n if (x == a + b - c * i - d * j):\n print('YES')\n exit()\nprint('NO')\n"}, {"source_code": "def tasks(x, t, a, b, da, db):\n flag = False\n for i in range(t):\n for j in range(t):\n for z in range(2):\n for m in range(2):\n if z * (a - da * i) + m * (b - db * j) == x:\n flag = True\n if flag is True:\n return \"YES\"\n return \"NO\"\n\n\nx, t, a, b, da, db = [int(y) for y in input().split()]\nprint(tasks(x, t, a, b, da, db))\n\n"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\nok = 0\nfor i in xrange(t):\n for j in xrange(t):\n if x == a - (da*i) + b - (db*j):\n ok = 1\n break\n if x == a - (da*i):\n ok = 1\n break\n if x == b - (db*j):\n ok= 1\n break\n if x == 0:\n ok = 1\n break\nprint 'YES' if ok else 'NO'\n"}, {"source_code": "x,t,a,b,c,d=map(int,input().split())\nR=range(t)\ny=x==0\nfor i in R:\n\tif x==a-c*i or x==b-d*i:y=1\n\tfor j in R:y|=x==a+b-c*i-d*j\nprint(['NO','YES'][y])"}, {"source_code": "import sys\nx,t,a,b,da,db = map(int,raw_input().split())\n\nfor i in range(0,t+1):\n\tsumA = a - (i * da)\n\tif i == t:\n\t\tsumA = 0\n\tfor j in range(0,t+1):\n\t\tsumB = b - (j * db)\n\t\tif j == t:\n\t\t\tsumB = 0\n\t\tif sumA + sumB == x:\n\t\t\tprint 'YES'\t\t\n\t\t\tsys.exit()\nprint 'NO'\t\n"}, {"source_code": "x,t,a,b,da,db = map(int, raw_input().split())\n\npos = list()\nfor i in xrange(0,t):\n for j in xrange(0,t):\n pos.append((a-i*da)+(b-j*db))\n pos.append(a-i*da)\n pos.append(b-j*db)\n \n##print pos\n\nif x in pos or x == 0:\n print \"YES\"\nelse:\n print \"NO\"\n \n"}, {"source_code": "def inp():\n return int(raw_input())\ndef linp():\n return map(int, raw_input().split())\nx, t, a, b, da, db = linp()\nif x==0:\n print \"YES\"\n exit()\nli1 = []\nfor i in xrange(t):\n li1.append(a-i*da)\nli2 = []\nfor i in xrange(t):\n li2.append(b-i*db)\nif x in li1 or x in li2:\n print \"YES\"\n exit()\nfor i in li1:\n for j in li2:\n if i+j==x:\n print \"YES\"\n exit()\nprint \"NO\""}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nif x>a+b:\n print \"NO\"\nelif x==a+b:\n print \"YES\"\nelif x==0:\n print \"YES\"\nelse:\n ch=False\n at=a\n for k in range(t):\n if k!=0:\n at-=da\n if at+b==x:\n ch=True\n break\n z=False\n temp=b\n for j in range(1,t):\n temp-=db\n if temp+at==x:\n z=True\n break\n if z:\n ch=True\n break\n if not ch:\n for k in range(t):\n if k!=0:\n a-=da\n if a==x:\n ch=True\n break\n if not ch:\n for k in range(t):\n if k!=0:\n b-=db\n if b==x:\n ch=True\n break\n if ch:\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "def main ():\n x,t,a,b,da,db = map(int,raw_input().split())\n \n if (x == 0):\n print \"YES\"\n return None\n \n \n for i in range(0,t):\n p = a-da*i\n q = x - p\n \n if (p == x):\n print \"YES\"\n return None\n \n for j in range(0,t):\n r = b - db*j\n \n if (r == q or r == x):\n print \"YES\"\n return None\n \n print \"NO\"\n \n \n \n \nwhile (True):\n try:\n main ()\n \n except EOFError:\n break"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nf=0\nfor i in range(t):\n\tfor j in range(t):\n\t\tif a-i*da+b-j*db==x or a-i*da==x or b-j*db==x or x==0:\n\t\t\tprint \"YES\"\n\t\t\tf=1\n\t\t\tbreak\n\tif f:\n\t\tbreak\nif f==0:\n\tprint \"NO\"\n\n\n\n\n\n"}, {"source_code": "x,t,a,b,da,db = map(int,raw_input().split())\n\ncheck = False\nif x==0:\n print('YES')\n exit(0)\nfor i in range(t):\n if a==x or b==x or a+b==x:\n check = True\n break\n temp = b\n for j in range(t):\n if a==x or temp==x or a+temp==x:\n check = True\n break\n temp -= db\n a -= da\n if check:\n break\n\nif check:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split(' '))\napoints = []\nbpoints = []\nfor i in range(t):\n apoints.append(a - i * da);\n bpoints.append(b - i * db);\nsolution = False\nif x == 0:\n solution = True\nelse:\n if x in apoints or x in bpoints:\n solution = True\n else:\n for i in range(t):\n tmp = x - apoints[i]\n if (tmp > 0 and tmp in bpoints):\n solution = True\n break\nif solution:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "x,t,a,b,da,db=map(int,input().split())\nA=[0]+[a-i*da for i in range(t)]\nB=[0]+[b-i*db for i in range(t)]\nflag=0\nfor i in A:\n\tif x-i in B:\n\t\tprint (\"YES\")\n\t\tflag=1\n\t\tbreak\nif(flag==0):\n print (\"NO\")"}, {"source_code": "x, t, a, b, da, db = [int(i) for i in raw_input().split()]\npas = [a-da*i for i in xrange(t) if 0 < a-da*i <= x]\npbs = [b-db*i for i in xrange(t) if 0 < b-db*i <= x]\npas += [0]\npbs += [0]\nfor pa in pas:\n for pb in pbs:\n if pa+pb == x:\n print 'YES'\n exit()\nprint 'NO'\n \n"}, {"source_code": "x = list(map(int, input().split()))\nt = x[1]\nflag = 0\na, b, = [0], [0]\nwhile x[2] > 0 and x[1] > 0:\n a.append(x[2])\n x[2] -= x[4]\n x[1] -= 1\nwhile x[3] > 0 and t > 0:\n b.append(x[3])\n x[3] -= x[5]\n t -= 1\nfor i in range(len(a)):\n for j in range(len(b)):\n if a[i] + b[j] == x[0]:\n print('YES')\n flag = 1\n break\n if i == len(a) - 1 and j == len(b) - 1:\n print('NO')\n if flag == 1:\n break\n"}, {"source_code": "x, t, a, b, la, lb = map(int, raw_input().split())\nans = False\nfor f in range(t):\n for s in range(t):\n if a - la * f + b - lb * s == x or a - la * f == x or b - lb * s == x or x == 0:\n ans = True\nprint 'YES' if ans else 'NO'\n"}, {"source_code": "w = input()\n[x,t,a, b, da, db] = [int(i) for i in str.split(w)]\nworks = False\n\nif x==0:\n works = True\nelse:\n for i in range(t):\n for j in range(t):\n aprime = a-da*i\n bprime = b-db*j\n if x == aprime or x == bprime or x == aprime+bprime:\n works = True\nif works:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\ndef judge():\n if 0==x: return True\n for t1 in range(t):\n if x==a-da*t1: return True\n for t2 in range(t):\n if x==a-da*t1+b-db*t2: return True\n if x==b-db*t2: return True\n return False\nprint 'YES' if judge() else 'NO'\n"}, {"source_code": "def main():\n x, t, a, b, da, db = map(int, input().split())\n\n possible_a = [0]\n possible_b = [0]\n for i in range(t):\n p = a - (da * i)\n possible_a.append(p)\n q = b - (db * i)\n possible_b.append(q)\n \n for p in range(t+1):\n for q in range(t+1):\n if possible_a[p] + possible_b[q] == x:\n print(\"YES\")\n return\n print(\"NO\")\n\n\nmain()"}, {"source_code": "# In the name of Allah, Most Gracious, Most Merciful\n\n# / \n# \n# \n# \n# \n# ??\n\nx, t, a, b, da, db = map(int, raw_input().split())\nfor i in range(t):\n\tfor j in range(t):\n\t\tif a-i*da+b-j*db == x or a-i*da == x or b-j*db == x or x == 0:\n\t\t\tprint 'YES'\n\t\t\texit()\nprint 'NO'\n"}, {"source_code": "#!/usr/bin/env python\nx,t,a,b,da,db = map(int,raw_input().split())\nla = set()\nlb = set()\nfor i in xrange(t):\n\tla.add(a-i*da)\n\tlb.add(b-i*db)\nfor i in xrange(x+1):\n\tif i in la and x-i in lb:\n\t\tprint \"YES\"\n\t\tbreak\nelse:\n\tif x in la or x in lb:\n\t\tprint \"YES\"\n\telif x == 0:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\""}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nx,t,a,b,da,db=map(int,input().split())\nisprinted=False\nfor i in range(t):\n\tfor j in range(t):\n\t\tif a-i*da+b-j*db==x or a-i*da==x or b-j*db==x or 0 == x:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted:\n\t\tbreak\nif isprinted==False:\n\tprint(\"NO\")\n"}, {"source_code": "#!/usr/bin/python \n\nimport sys\n\ndef main():\n n = sys.stdin.readlines()\n nums = n[0].split(' ')\n for i in range(6):\n nums[i] = int(nums[i])\n\n if nums[0] == 0:\n print 'YES'\n return\n\n for m1 in range(nums[1]):\n for m2 in range(nums[1]):\n score = (nums[2]-m1*nums[4]) + (nums[3]-m2*nums[5])\n if nums[0] == score:\n print 'YES'\n return\n\n for m1 in range(nums[1]):\n score = nums[2]-m1*nums[4]\n if nums[0] == score:\n print 'YES'\n return\n\n for m2 in range(nums[1]):\n score = nums[3]-m2*nums[5]\n if nums[0] == score:\n print 'YES'\n return\n\n print 'NO'\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\nif x>a+b:\n print 'NO'\n exit()\nif x==0:\n print 'YES'\n exit()\nfor i in xrange(t):\n if a-i*da == x or b-i*db == x:\n print 'YES'\n exit()\n for j in xrange(t):\n if a-i*da+b-j*db == x:\n print 'YES'\n exit()\nprint 'NO'\n"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\nif x == 0 or (x - a) % da == 0 and 0 <= -(x - a) / da and -(x - a) / da < t or (x - b) % db == 0 and 0 <= -(x - b) / db and -(x - b) / db < t:\n\tprint \"YES\"\n\texit(0)\nfor i in xrange(0, t):\n\tif x - (a - da * i) < 0:\n\t\tcontinue;\n\tif (x - (a - da * i) - b) % db:\n\t\tcontinue\n\tj = -(x - (a - da * i) - b) / db\n\tif j < 0 or t <= j:\n\t\tcontinue;\n\tprint \"YES\"\n\texit(0)\nprint \"NO\"\nexit(0)\n"}, {"source_code": "R = lambda:map(int,raw_input().split())\n#R = lambda:[30, 5, 20, 20, 5, 3]\n#R = lambda:[64, 12, 258, 141, 10, 7]\n\nx, t, a, b, da, db = R()\n\nfor i in range(-1, t):\n if i == -1:\n sum_a = 0\n else:\n sum_a = a - da*i\n if sum_a < 0:\n sum_a = 0\n\n for j in range(-1, t):\n if j == -1:\n sum_b = 0\n else:\n sum_b = b - db*j\n if sum_b < 0:\n sum_b = 0\n\n if sum_a + sum_b == x:\n print 'YES'\n quit()\nprint 'NO'"}, {"source_code": "import sys\ndef main():\n x, t, a, b, da, db = map(int,sys.stdin.readline().strip().split())\n\n if x==0:\n return \"YES\"\n for q in range(t):\n for w in range(t):\n if x == (max(0,a - q*da) + max(0,b - w*db)) or x==(max(a - q*da,0)) or (x == max(0,b-w*db)):\n return 'YES'\n return 'NO'\nif __name__ == \"__main__\":\n print main()"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split(\" \"));\n#print x,t,a,b,da,db;\nflag = False;\nif x == 0:\n flag = True;\nfor i in range(0, t):\n sum = a - i * da;\n if sum == x:\n flag = True;\n break;\n for j in range(0, t):\n if b - db * j == x:\n flag = True;\n break;\n # print sum;\n if sum+b-db*j == x:\n flag = True;\n break;\n if flag == True:\n break;\nif flag == True:\n print \"YES\";\nelse:\n print \"NO\";\n\n \t \t\t \t\t\t \t\t \t\t\t \t\t \t"}, {"source_code": "import sys\n\nX, t, a, b, da, db = [ int(x) for x in sys.stdin.readline().split(' ') ]\n\npa = [ a - da * x for x in range(0, t) ] + [ 0 ]\npb = [ b - db * x for x in range(0, t) ] + [ 0 ]\nscores = [ j + k for j in pa for k in pb ]\n\nif X in scores:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "x,t,a,b,da,db = map(int,raw_input().split())\nans = \"NO\"\nfor exa in xrange(2):\n\tfor exb in xrange(2):\n\t\tfor i in xrange(t):\n\t\t\tfor j in xrange(t):\n\t\t\t\tif x==a*exa+b*exb -exa*i*da - exb*j*db:\n\t\t\t\t\tans = \"YES\"\nprint ans\n"}, {"source_code": "x,t,a,b,da,db = [int(r) for r in raw_input().split(\" \")]\nA = list([0])\nfor i in range(t):\n\tA.append(a-da*i)\nB = list([0])\nfor i in range(t):\n\tB.append(b-db*i)\nans = \"NO\"\nfor aa in A:\n\tfor bb in B:\n\t\tif (aa+bb) == x:\n\t\t\tans = \"YES\"\nprint ans"}, {"source_code": "x,t,a,b,d,f=map(int,raw_input().split())\ny=[a-d*o for o in range(t)]\nu=[b-f*o for o in range(t)]\nif (x in y) or (x in u) or x==0:\n print\"YES\"\n exit()\nfor i in range(t):\n if x-y[i] in u:\n print\"YES\"\n exit()\nprint\"NO\""}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n__author__ = 'firago'\nfrom sys import stdin, stdout\nx, t, a, b, da, db = map(int, stdin.read().split())\n\nmina = a - da * t\nminb = b - db * t\nmaxa = a \nmaxb = b\nfor xa in xrange(maxa, mina, -da):\n for xb in xrange(maxb, minb,-db):\n for i,j in [(1,1),(1,0),(0,1),(0,0)]:\n if i*xa + j*xb == x:\n # print xa*i, xb*j \n \n \n print \"YES\"\n exit()\nprint \"NO\"\n"}, {"source_code": "def __main__():\n a = [int(i) for i in raw_input().split(' ') ]\n\n res = False\n for i in range(0, a[1]):\n for j in range(0, a[1]):\n res |= (a[0] == a[2] - i*a[4]) or (a[0] == a[3] - j*a[5]) or (a[0] == a[2] + a[3] - i*a[4] - j*a[5])\n\n if res or a[0] == 0:\n print 'YES'\n else:\n print 'NO'\n \n\n__main__()\n"}, {"source_code": "import sys\n\ndef main():\n\tx,t,a,b,ta,tb = map(int, sys.stdin.readline().strip().split())\n\n\tif (x==0): return 'YES'\n\tfor i in range(t):\n\t\tfor j in range(t):\n\t\t\tif (x == a-i*ta): return 'YES'\n\t\t\tif (x == b-i*tb): return 'YES'\n\t\t\tif (x == a-i*ta + b - j*tb): return 'YES'\n\treturn 'NO'\n\n\nif __name__ == \"__main__\":\n print main()\n"}, {"source_code": "import sys\n\n(x, t, a, b, ta, tb) = [int(x) for x in sys.stdin.readline().strip().split()]\n\naa = [max(a - ta*i, 0) for i in range(0, t)]\nbb = [max(b - tb*i, 0) for i in range(0, t)]\n\naa.append(0)\nbb.append(0)\n\nyes = False\n\nfor xa in aa:\n for xb in bb:\n if xa + xb == x:\n yes = True\nif yes:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import sys\n\nx,t,a,b,da,db=map(int,raw_input().split())\nmogelijk='NO'\n\nfor i in range(t):\n for j in range(t):\n res1=a-i*da\n res2=b-j*db\n res=a-i*da+b-j*db\n \n if res==x or res1==x or res2==x:\n mogelijk='YES'\nif x==0:\n print 'YES'\nelse:\n print mogelijk\n\n \n\n"}, {"source_code": "import sys\n\nstrlist = raw_input().split()\n\nx = int(strlist[0])\nt = int(strlist[1])\na = int(strlist[2])\nb = int(strlist[3])\nda= int(strlist[4])\ndb= int(strlist[5])\n\nif x == 0:\n print 'YES'\n sys.exit(0)\n\nfor i in xrange(t):\n if a-i*da == x or b-i*db == x:\n print 'YES'\n sys.exit(0)\n \nsumab = a+b\nfor i in xrange(t):\n for j in xrange(t):\n if sumab-i*da-j*db == x:\n print 'YES'\n sys.exit(0)\n \nprint 'NO'"}, {"source_code": "import sys\nimport fractions\nimport string\nx,t,a,b,da,db = [ int(i) for i in raw_input().split()]\np = [0]\nfor i in range(t):\n p.append(a - i*da)\n p.append(b - i*db)\n for j in range(t):\n p.append(a-i*da + b - j*db)\n\nif x in p:\n print \"YES\"\nelse:\n print \"NO\"\n"}], "negative_code": [{"source_code": "x, t, a, b, d_a, d_b = map(int, input().split())\n\nif a - x > 0 and (a - x) // d_a < t and (a - x) % d_a == 0:\n answer = 'YES'\nelif b - x > 0 and (b - x) // d_b < t and (b - x) % d_b == 0:\n answer = 'YES'\nelse:\n answer = 'NO'\n for i in range(t):\n s = a + b - x - d_a * i\n if s < 0: \n break\n if s // d_b < t and s % d_b == 0:\n answer = 'YES'\n break\n\nprint(answer)"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\n\nresult = False\nta = a + b - x\nfor i in range(1, t):\n\tc = ta - i * db\n\tif c/da > t - 1:\n\t\tprint 'NO'\n\t\tresult = True\n\t\tbreak\n\telif c % da == 0:\n\t\tprint 'YES'\n\t\tresult = True\n\t\tbreak\nif not result:\n\tprint 'NO'"}, {"source_code": "'''\nCreated on Jul 4, 2012\n\n@author: iain\n'''\n\nimport sys\nif __name__ == \"__main__\":\n i = map(int,raw_input().split(\" \"))\n x,t,a,b,da,db = i[0],i[1],i[2],i[3],i[4],i[5]\n for i in range(0, t):\n temp = b\n for j in range(0, t):\n if temp + a == x:\n print \"YES\"\n sys.exit()\n temp = temp - db\n a = a - da\n print \"NO\"\n \n"}, {"source_code": "x, t, a, b, da, db = eval(\"[\" + raw_input().replace(' ', ',') + \"]\")\nmax_score = a + b\nmin_score = a + b - (da + db) * t\nif min_score <= x and x <= max_score:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "\n\n\nx, t, a, b, da, db = [int(x) for x in raw_input().split()]\n\npossible = False\n\nfor i in range(t + 1):\n for j in range(t + 1):\n if x == (a - i * da) + (b - j * db):\n possible = True\n break\n if possible:\n break\n\t\nif possible:\n print \"YES\"\nelse:\n print \"NO\" \n"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nfor i in range(t):\n for j in range(t):\n if a+b-i*da-j*db==x:\n print \"YES\"\n exit(0)\nprint \"NO\""}, {"source_code": "#!/usr/bin/python3\n\ndef readln(): return tuple(map(int, input().split()))\n\nx, t, a, b, da, db = readln()\nfor i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x:\n da = -1\n break\n if da == -1:\n break\nprint('YES' if da == -1 else 'NO')\n"}, {"source_code": "data=list(raw_input().split())\nx=int(data[0])\nt=int(data[1])\na=int(data[2])\nb=int(data[3])\nda=int(data[4])\ndb=int(data[5])\nvarsA=[]\nvarsB=[]\nvarsA.append(0)\nvarsB.append(0)\nfor i in range(t-1):\n varsA.append(a-i*da)\n varsB.append(b-i*db)\nfor i in varsA:\n for j in varsB:\n if i+j==x:\n print \"YES\"\n exit()\n \n\n\nprint \"NO\""}, {"source_code": "import collections\nimport functools\nimport itertools\nimport math\nimport operator\nimport re\nimport sys\n\n\ndef main():\n x, t, a, b, da, db = map(int, raw_input().split())\n for t1 in xrange(t):\n for t2 in xrange(t):\n if x == a - da * t1 + b - db * t2:\n print 'YES'\n return\n print 'NO'\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "import sys\nx,t,a,b,ta,tb=map(int, raw_input().split())\nfor i in range(t):\n for j in range(t):\n if x == a-(ta*i)+b-(tb*j): \n print 'YES'; exit()\nprint 'NO'"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split(' '))\napoints = []\nbpoints = []\nfor i in range(t):\n apoints.append(a - i * da);\n bpoints.append(b - i * db);\nsolution = False\nif x in apoints or x in bpoints:\n solution = True\nelse:\n for i in range(t):\n tmp = x - apoints[i]\n if (tmp > 0 and tmp in bpoints):\n solution = True\n break\nif solution:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nx,t,a,b,da,db=map(int,input().split())\nisprinted=False\nfor i in range(t):\n\tfor j in range(t):\n\t\tval=(a-i*da)+(b-j*db)\n\t\tif val==x:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\nif isprinted==False:\n\tprint(\"NO\")"}, {"source_code": "x, t, a, b, da, db = [int(i) for i in raw_input().split()]\npas = [a-da*i for i in range(t) if 0 < a-da*i <= x]\npbs = [b-db*i for i in range(t) if 0 < b-db*i <= x]\nif a-da*(t-1) <= 0: pas += [0]\nif b-db*(t-1) <= 0: pbs += [0]\nfor pa in pas:\n for pb in pbs:\n if pa+pb == x:\n print 'YES'\n exit()\nprint 'NO'\n \n"}, {"source_code": "def main():\n x, t, a, b, da, db = map(int, input().split())\n if x == 0:\n print(\"YES\")\n return\n possible_a = [0]\n for i in range(t):\n p = a - (da * i)\n if p == x:\n print(\"YES\")\n return\n possible_a.append(p)\n\n for i in range(t):\n target = b - (db * i)\n for j in range(t + 1):\n if x - possible_a[j] == target:\n print(\"YES\")\n return\n elif x - possible_a[j] < target:\n break\n print(\"NO\")\n\nmain()"}, {"source_code": "import itertools as it\nx, t, a, b, da, db = (int(x) for x in input().split())\nif x in (a - da * i + b - db * j for i in range(t) for j in range(t)):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "import sys\n\n(x, t, a, b, ta, tb) = [int(x) for x in sys.stdin.readline().strip().split()]\n\naa = [a - ta*i for i in range(0, t)]\nbb = [b - tb*i for i in range(0, t)]\n\nyes = False\n\nfor xa in aa:\n for xb in bb:\n if xa + xb == x:\n yes = True\nif x == 0 or yes:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "x,t,a,b,da,db=map(int,input().split())\nl1=[a]\nl2=[b]\nfor i in range(1,t):\n\tl1.append(a-(i*da))\n\tl2.append(b-(i*db))\nfor t in l1:\n\tcheck=x-t\n\ttt=0\n\tif check==0:\n\t\ttt=1\n\t\tbreak\n\tif check in l2:\n\t\ttt=1\n\t\tbreak\nif tt==0:\n\tprint (\"NO\")\nelse:\n\tprint (\"YES\")\n"}, {"source_code": "import itertools as it\nx, t, a, b, da, db = (int(x) for x in input().split())\nif x in (a - da * i + b - db * j for i in range(t) for j in range(t)):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "x, t, a, b, da, db = [int(j) for j in raw_input().split()]\n\n##if x>(a+b) or x < min(a-da*t, b-db*t):\n## print 'NO'\n##else:\nalist = [a-da*j for j in range(t)]\nblist = [aa+b-db*j for j in range(t) for aa in alist]+[0]\n\nif x in blist:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "import sys\nimport math\n\nx, t, a, b, da, db = [int(x) for x in (sys.stdin.readline()).split()]\nd = [0] * 300\n\nif(x == 0):\n print(\"YES\")\n exit()\n\nfor i in range(t - 1):\n d[b] = 1\n b -= db\n \nfor i in range(t - 1):\n if(d[x - a] == 1 or x - a == 0 or d[x] == 1):\n print(\"YES\")\n exit()\n else:\n a -= da\n \nprint(\"NO\")"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nans=chk=0\nal,bl=[],[]\nfor _ in range(t):\n if a>=0:\n al.append(a)\n a-=da\n else:\n al.append(0)\n break\nfor _ in range(t):\n if b>=0:\n bl.append(b)\n b-=db\n else:\n bl.append(0)\n break\nal.sort(); bl.sort()\nfor i in al:\n for j in bl:\n if i+j==x:\n print 'YES'\n exit()\n elif i+j>x:\n break\nprint 'NO'"}, {"source_code": "import sys\n\n(x, t, a, b, ta, tb) = [int(x) for x in sys.stdin.readline().strip().split()]\n\naa = [a - ta*i for i in range(0, t)]\nbb = [b - tb*i for i in range(0, t)]\n\nyes = False\n\nfor xa in aa:\n for xb in bb:\n if xa + xb == x:\n yes = True\nif x == 0 or yes:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "\n\n\nx, t, a, b, da, db = [int(x) for x in raw_input().split()]\n\npossible = False\n\nfor i in range(t):\n if x == (a - i*da) or x == (b - i*db):\n possible = True\n break\t\n \n for j in range(t):\n if x == (a - i * da) + (b - j * db):\n possible = True\n break\n if possible:\n break\n\t\nif possible:\n print \"YES\"\nelse:\n print \"NO\" \n"}, {"source_code": "x,t,a,b,da,db = map(int, raw_input().split())\n\npos = list()\nfor i in xrange(0,t):\n for j in xrange(0,t):\n pos.append((a-i*da)+(b-j*db))\n pos.append(a-i*da)\n pos.append(b-j*db)\n \nprint pos\n\nif x in pos or x == 0:\n print \"YES\"\nelse:\n print \"NO\"\n \n"}, {"source_code": "x, t, a, b, d_a, d_b = map(int, input().split())\n\nanswer = 'NO'\nfor i in range(t):\n s = a + b - x - d_a * i\n if s < 0: break\n if s // d_b <= t - 1 and s % d_b == 0:\n answer = 'YES'\n\nprint(answer)"}, {"source_code": "data=list(raw_input().split())\nx=int(data[0])\nt=int(data[1])\na=int(data[2])\nb=int(data[3])\nda=int(data[4])\ndb=int(data[5])\nvarsA=[]\nvarsB=[]\n\nfor i in range(t):\n varsA.append(a-i*da)\n varsB.append(b-i*db)\nfor i in varsA:\n for j in varsB:\n if i+j==x:\n print \"YES\"\n exit()\nprint \"NO\""}, {"source_code": "def possible(x, t, a, b, d1, d2):\n for t1 in range(t):\n for t2 in range(t1, t):\n first_solution = max(0, a - (d1*t1))\n second_solution = max(0, b - d2*t2)\n if (first_solution + second_solution) == x:\n print(t1, t2)\n return True\n \n return False\nl = input().split()\nx = int(l[0])\nt = int(l[1])\na = int(l[2])\nb = int(l[3])\nd1 = int(l[2])\nd2 = int(l[3])\n\nif possible(x, t, a, b, d1, d2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\nfrom itertools import product\n\nfile = sys.stdin\n#file = open(\"test\", \"r\")\nx, t, a, b, da, db = map(int, file.readline().rstrip().split())\nif x == 0: print \"YES\"; exit()\nfor i, j in [(i, j) for i in range(t) for j in range(t)]:\n if a - i*da + b - j*db == x:\n print \"YES\"\n break\nelse:\n print \"NO\"\n"}, {"source_code": "w = input()\n[x,t,a, b, da, db] = [int(i) for i in str.split(w)]\nworks = False\n\nif x==0:\n print('YES')\n works = True\nelse:\n for i in range(t):\n for j in range(t):\n aprime = a-da*i\n bprime = b-db*j\n if x == aprime or x == bprime or x == aprime+bprime:\n print('YES')\n works = True\nif not works:\n print('NO')"}, {"source_code": "import sys\n\n(x, t, a, b, ta, tb) = [int(x) for x in sys.stdin.readline().strip().split()]\n\naa = [a - ta*i for i in range(0, t)]\nbb = [b - tb*i for i in range(0, t)]\n\nyes = False\n\nfor xa in aa:\n for xb in bb:\n if aa + bb == x:\n yes = True\nif yes:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\n\nif x == 0:\n print \"YES\"\n exit()\n\nfor p in xrange(t):\n for q in xrange(t):\n if x == a + b - da * p - db * q:\n print \"YES\"\n exit()\nprint \"NO\""}, {"source_code": "\n\n\nif __name__ == \"__main__\":\n x, t, a, b, da, db = map(int, input().split())\n found = False\n for i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x:\n found = True\n\n if found:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "buf = raw_input()\nx, t, a, b, Da, Db = buf.split(\" \")\nx, t, a, b, Da, Db = int(x), int(t), int(a), int(b), int(Da), int(Db)\n\nans = \"NO\"\nfor i in range(0, t + 1):\n for j in range(0, t + 1):\n if a - Da * i + b - Db * j == x:\n ans = \"YES\"\n if b - Db * j == x:\n ans = \"YES\"\n if a - Da * i == x:\n ans = \"YES\"\n\nprint(ans)\n"}, {"source_code": "x, t, a, b, da, db = map(int, input().split())\nn = a + b - x\nif da < db: da, db = db, da\nwhile n % db and t > 0:\n n -= da\n t -= 1\nprint('YES' if n >= 0 and t >= n // db else 'NO')"}, {"source_code": "#https://codeforces.com/contest/203/problem/A\nl=list(map(int,input().split(' ')))\nx=l[0]\nt=l[1]\na=l[2]\nb=l[3]\nda=l[4]\ndb=l[5]\n\np=(a+b)-(x)\nbhul=True\n\nfor i in range(t):\n\tfor j in range(t):\n\t\tif( (da*i)+(db*j)==p ):\n\t\t\tprint('YES')\n\t\t\tbhul=False\n\t\t\tbreak;\n\nif bhul:\n\tprint('NO')"}, {"source_code": "x, t, a, b, da, db = [int(j) for j in raw_input().split()]\n\nif x>(a+b) or x < min(a-da*t, b-db*t):\n print 'NO'\nelse:\n alist = [a-da*j for j in range(t)]\n blist = [aa+b-db*j for j in range(t) for aa in alist]\n \n if x in blist:\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\ny=(a+b)-x\nf=0\nfor i in range(t+1):\n\tfor j in range(t+1):\n\t\tif i*da+j*db==y:\n\t\t\tprint \"YES\"\n\t\t\tf=1\n\t\t\tbreak\nif x==0:\n\tprint \"YES\"\nelse:\n\tif f==0:\n\t\tprint \"NO\"\n\n\n\n\n\n\n"}, {"source_code": "def main():\n x, t, a, b, da, db = map(int, input().split())\n b_points = set(b - i * db for i in range(t))\n\n if x in b_points or x == 0:\n print('YES')\n return\n\n for i in range(t):\n ap = x - (a - i * da)\n if ap == 0 or ap in b_points:\n print('YES')\n return\n\n if ap < 0:\n break\n \n print('NO')\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "l=[int(x) for x in input().split()]\n\ndef binarySearch (arr, l, r, x): \n \n # Check base case \n if r >= l: \n \n mid = l + (r - l)/2\n mid=int(mid)\n # If element is present at the middle itself \n if arr[mid] == x: \n return mid \n \n # If element is smaller than mid, then it \n # can only be present in left subarray \n elif arr[mid] > x: \n return binarySearch(arr, l, mid-1, x) \n \n # Else the element can only be present \n # in right subarray \n else: \n return binarySearch(arr, mid + 1, r, x) \n \n else: \n # Element is not present in the array \n return -1\n\nx=l[0]\nt=l[1]\na=l[2]\nb=l[3]\nda=l[4]\ndb=l[5]\na1=[]\nb1=[]\nfor i in range(t):\n aa=a-i*da\n ab=b-i*db\n a1.append(aa)\n b1.append(ab)\n\n\nf=0\n#print(a1,b1)\nfor e in a1:\n if(x-e) in b1:\n print(\"YES\")\n f=1\n break\nif x==0:\n print(\"YES\")\nelif f==0:\n print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n\n\nif __name__ == \"__main__\":\n x, t, a, b, da, db = map(int, input().split())\n found = False\n for i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x:\n found = True\n\n if found:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nx,t,a,b,da,db=map(int,input().split())\nisprinted=False\nfor i in range(t):\n\tfor j in range(t):\n\t\tval=(a-i*da)+(b-j*db)\n#\t\tprint(val,i,j)\n\t\tif val%x==0:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted:\n\t\tbreak\nif isprinted==False:\n\tfor i in range(t):\n\t\tif (a-i*da)%x==0:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\t\tif (b-i*da)%x==0:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted==False:\n\t\tif x==0:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")"}, {"source_code": "x, t, a, b, da, db = [int(i) for i in raw_input().split()]\npas = [a-da*i for i in xrange(t) if 0 < a-da*i <= x]\npbs = [b-db*i for i in xrange(t) if 0 < b-db*i <= x]\nif a-da*(t-1) <= 0: pas += [0]\nif b-db*(t-1) <= 0: pbs += [0]\nfor pa in pas:\n for pb in pbs:\n if pa+pb == x:\n print 'YES'\n exit()\nprint 'NO'\n \n"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nans=chk=0\nal,bl=[],[]\nfor _ in range(t):\n if a>=0:\n al.append(a)\n a-=da\n else:\n al.append(0)\n break\nfor _ in range(t):\n if b>=0:\n bl.append(b)\n b-=db\n else:\n bl.append(0)\n break\nal.sort(); bl.sort()\nfor i in al:\n for j in bl:\n if i+j==x:\n print 'YES'\n exit()\n elif i+j>x:\n break\nprint 'NO'"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\n\nresult = False\nta = a + b - x\nfor i in range(1, t):\n\tc = ta - i * db\n\tif c/da > t - 1:\n\t\tprint 'NO'\n\t\tresult = True\n\t\tbreak\n\telif c % da == 0:\n\t\tprint 'YES'\n\t\tresult = True\n\t\tbreak\nif not result:\n\tprint 'NO'"}, {"source_code": "# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------- fast io --------------------\nfrom math import gcd, ceil\n\ndef pre(s):\n n = len(s)\n pi = [0] * n\n for i in range(1, n):\n j = pi[i - 1]\n while j and s[i] != s[j]:\n j = pi[j - 1]\n if s[i] == s[j]:\n j += 1\n pi[i] = j\n return pi\n\n\ndef prod(a):\n ans = 1\n for each in a:\n ans = (ans * each)\n return ans\n\ndef lcm(a, b): return a * b // gcd(a, b)\n\n\ndef binary(x, length=16):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\n\nfor _ in range(int(input()) if not True else 1):\n #n = int(input())\n #n, k = map(int, input().split())\n x,t,a,b,da,db = map(int, input().split())\n #c, d = map(int, input().split())\n #a = list(map(int, input().split()))\n #b = list(map(int, input().split()))\n #s = input()\n s1 = set()\n s2 = set()\n for i in range(0, t+1):\n s1.add(a - da*i)\n s2.add(b - db*i)\n if x in s1 or x in s2:\n print(\"YES\")\n pos = False\n for i in s1:\n if x - i in s2:\n pos = True\n break\n print(\"YES\" if pos else \"NO\")"}, {"source_code": "x,t,a,b,d,D=map(int, raw_input().split())\n\nr=range(0,t)\n\nprint \"NYOE S\"[any([1 for i in r for j in r for k in range(4) if x == (a-i*d)*k&1 + (b-j*D)*k&2])::2]"}, {"source_code": "import sys\nimport math\n\ndef readints() :\n l = sys.stdin.readline()\n return map(int, l.split(' '))\n\ndef readstring() :\n l = sys.stdin.readline()[:-1]\n return l\n\ndef readint() :\n l = sys.stdin.readline()\n return int(l)\n\ndef clearchars(s, chars) :\n for c in chars :\n s = s.replace(c, '')\n return s\n\ndef gcd(a, b) :\n if (a < b ) :\n a, b = b, a\n if b == 0 :\n return a\n return gcd(b, a % b)\n\ndef hist(a) :\n h = {}\n for x in a :\n try : \n h[x] += 1\n except KeyError :\n h[x] = 1\n return h\n\ndef lucky(n) :\n s = set(str(n))\n return all(map(lambda x: x in '47', s)) \n\ndef yslice(a, j) :\n return map(lambda x: x[j], a)\n\ndef dist2(a, b) :\n return ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5\n\ndef chain_len(a) :\n l = .0\n for d, e in zip(a, a[1:]) :\n l += dist2(d, e)\n return l\n\ndef is_prime(x) :\n if x == 1 :\n return False\n sq = int(x ** 0.5) \n for i in [2] + range(3, sq + 1, 2) :\n if x % i == 0 :\n return False\n return True\n\n\ndigits = '0123456789'\n\ndef noe() :\n print \"NO\"\n exit(0)\n\ndef yese() :\n print \"YES\"\n exit(0)\n\n\nx, t, a, b, da, db = readints()\n\nfor i in range(t) :\n for j in range(t) :\n if x == a - da * i + b - db *j or x == a - da * i or x == b - db * j :\n yese()\nnoe()\n"}, {"source_code": "l=[int(x) for x in input().split()]\n\nx=l[0]\nt=l[1]\na=l[2]\nb=l[3]\nda=l[4]\ndb=l[5]\na1=[]\nb1=[]\nfor i in range(t):\n aa=a-i*da\n ab=b-i*db\n a1.append(aa)\n b1.append(ab)\n\n\nf=0\nprint(a1,b1)\nfor e in a1:\n if x==e:\n f=1\n\nfor e in b1:\n if x==e:\n f=1\n \nfor e in a1:\n if(x-e) in b1:\n f=1\n break\n\nfor e in b1:\n if(x-e) in a1:\n f=1\n break\n \nif x==0:\n print(\"YES\")\n\nelif f==0:\n print(\"NO\")\nelif f==1:\n print(\"YES\")\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nx,t,a,b,da,db=map(int,input().split())\nisprinted=False\nfor i in range(t):\n\tfor j in range(t):\n\t\tif a-i*da+b-j*db==x:\n\t\t\tprint(i,j)\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted:\n\t\tbreak\n#if isprinted==False:\n#\tprint(\"NO\")\n\nif isprinted==False:\n\tfor i in range(t):\n\t\tif a-i*da==x:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\t\tif b-i*db==x:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted==False:\n\t\tif x==0:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")"}, {"source_code": "####################################################\n# -*- coding: utf-8 -*-\nimport sys\n\nw = sys.stdout.write\nread = sys.stdin.readline\nreads = sys.stdin.read\n\ndef r(f=None):\n if f:\n return map(f, read().split())\n else:\n return read().split()\n\ndef rs(t,f=None):\n result = []\n result_append = result.append\n for i in xrange(t):\n if f:\n result_append(tuple(map(f, read().split())))\n else:\n result_append(list(read().split()))\n return result\n\n\n####################################################\nimport math\nsqrt = math.sqrt\nfrom collections import deque\n\n\n[x, t, a, b, da, db] = r(int)\n# x = a - t1*da + b - t2*db\n# a + b - x = t1*da + t2*db\n\nif x == 0:\n w(\"YES\")\n sys.exit()\n\nx = a + b - x\nfor t1 in xrange(t+1):\n for t2 in xrange(t+1):\n if t1*da + t2*db == x:\n w(\"YES\")\n sys.exit()\nw(\"NO\")\n"}, {"source_code": "x, t, a, b, da, db = [int(i) for i in raw_input().split()]\n\npas = [a-da*i for i in range(t) if 0 <= a-da*i <= x]\npbs = [b-db*i for i in range(t) if 0 <= b-db*i <= x]\nfor pa in pas:\n for pb in pbs:\n if pa+pb == x:\n print 'YES'\n exit()\nprint 'NO'\n \n"}, {"source_code": "x,t,a,b,da,db=map(int,input().split())\nl1=[a]\nl2=[b]\nfor i in range(1,t):\n\tl1.append(a-(i*da))\n\tl2.append(b-(i*db))\nfor t in l1:\n\tcheck=x-t\n\ttt=0\n\tif check in l2:\n\t\ttt=1\n\t\tbreak\nif tt==0:\n\tprint (\"NO\")\nelse:\n\tprint (\"YES\")\n"}, {"source_code": "w = input()\n[x,t,a, b, da, db] = [int(i) for i in str.split(w)]\nworks = False\n\nif x==0:\n print('YES')\n works = True\nelse:\n for i in range(t):\n for j in range(t):\n aprime = a-da*i\n bprime = b-db*j\n if x == aprime or x == bprime or x == aprime+bprime:\n print('YES')\n works = True\nif not works:\n print('NO')"}, {"source_code": "x, t, a, b, da, db = [int(j) for j in raw_input().split()]\n\nif x>(a+b) or x < min(a-da*t, b-db*t):\n print 'NO'\nelse:\n alist = [a-da*j for j in range(t)]\n blist = [aa+b-db*j for j in range(t) for aa in alist]\n \n if x in blist:\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "w = input()\n[x,t,a, b, da, db] = [int(i) for i in str.split(w)]\nworks = False\n\nif x==0:\n print('YES')\nelse:\n for i in range(t):\n for j in range(t):\n aprime = a-da*i\n bprime = b-db*j\n if x == aprime or x == bprime or x == aprime+bprime:\n print('YES')\n works = True\nif not works:\n print('NO')"}, {"source_code": "x, t, a, b, da, db = map(int, input().split())\nx -= a\nfor i in range(t):\n if (b - x) % db == 0 and (b - x) // db in range(t):\n print('YES')\n exit()\n x += da\nprint('NO')"}, {"source_code": "def main():\n x, t, a, b, da, db = map(int, input().split())\n if x == 0:\n print(\"YES\")\n return\n possible_a = []\n for i in range(t):\n p = x - a - (da * i)\n if p == 0:\n print(\"YES\")\n return\n\n possible_a.append(p)\n for i in range(t):\n target = b - (db * i)\n for j in range(t):\n if possible_a[j] == target:\n print(\"YES\")\n return\n elif possible_a[j] < target:\n break\n print(\"NO\")\n\nmain()"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\ny=(a+b)-x\nf=0\nfor i in range(t+1):\n\tfor j in range(t+1):\n\t\tif i*da+j*db==y:\n\t\t\tprint \"YES\"\n\t\t\tf=1\n\t\t\tbreak\nif x==0:\n\tprint \"YES\"\nelse:\n\tif f==0:\n\t\tprint \"NO\"\n\n\n\n\n\n\n"}, {"source_code": "x,t,a,b,da,db=[int(w) for w in raw_input().split()]\naa=[]\nbb=[]\nfor i in xrange(t):\n aa.append(a-i*da)\n bb.append(b-i*db)\ncc=[]\nfor i in aa:\n for j in bb:\n cc.append(i+j)\nprint cc\nif x in cc:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "x, t, a, b, da, db = map(int, input().split())\nx -= a\nfor i in range(t):\n if (b - x) % db == 0 and (b - x) // db in range(t):\n print('YES')\n exit()\n x += da\nprint('NO')"}, {"source_code": "x, t, a, b, la, lb = map(int, raw_input().split())\nans = False\nfor f in range(t):\n for s in range(t):\n if a - la * f + b - lb * s == x or a - la * f == x or b - lb * s == x:\n ans = True\nprint 'YES' if ans else 'NO'\n"}, {"source_code": "x , t , a , b , da , db = list(map(int , raw_input().split()))\nok = False\nfor i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x:\n ok = True\n\nfor i in range(0 , t):\n if a - da * i == x:\n ok = True\n break\n \nfor i in range(0 , t):\n if b - db * i == x:\n ok = True\n break\n\nif ok == True:\n print \"YES\"\nelse:\n print \"NO\"\n\n "}, {"source_code": "data=list(raw_input().split())\nx=int(data[0])\nt=int(data[1])\na=int(data[2])\nb=int(data[3])\nda=int(data[4])\ndb=int(data[5])\nvarsA=[]\nvarsB=[]\nvarsA.append(0)\nvarsB.append(0)\nfor i in range(t-1):\n varsA.append(a-i*da)\n varsB.append(b-i*db)\nfor i in varsA:\n for j in varsB:\n if i+j==x:\n print \"YES\"\n exit()\n \n\n\nprint \"NO\""}, {"source_code": "\n\n\nif __name__ == \"__main__\":\n x, t, a, b, da, db = map(int, input().split())\n found = False\n for i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x:\n found = True\n\n if found:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "x,t,a,b,da,db = map(int,raw_input().split())\n\ncheck = False\n\nfor i in range(t):\n if a==x or b==x or a+b==x:\n check = True\n break\n temp = b\n for j in range(t):\n if a==x or temp==x or a+temp==x:\n check = True\n break\n temp -= db\n a -= da\n if check:\n break\n\nif check:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "l=[int(x) for x in input().split()]\n\ndef binarySearch (arr, l, r, x): \n \n # Check base case \n if r >= l: \n \n mid = l + (r - l)/2\n mid=int(mid)\n # If element is present at the middle itself \n if arr[mid] == x: \n return mid \n \n # If element is smaller than mid, then it \n # can only be present in left subarray \n elif arr[mid] > x: \n return binarySearch(arr, l, mid-1, x) \n \n # Else the element can only be present \n # in right subarray \n else: \n return binarySearch(arr, mid + 1, r, x) \n \n else: \n # Element is not present in the array \n return -1\n\nx=l[0]\nt=l[1]\na=l[2]\nb=l[3]\nda=l[4]\ndb=l[5]\na1=[]\nb1=[]\nfor i in range(t):\n aa=a-i*da\n ab=b-i*db\n a1.append(aa)\n b1.append(ab)\n\n\nf=0\n#print(a1,b1)\nfor e in a1:\n if(x-e) in b1:\n print(\"YES\")\n f=1\n break\nif x==0:\n print(\"YES\")\nelif f==0:\n print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "x, t, a, b, la, lb = map(int, raw_input().split())\nans = False\nfor f in range(t):\n for s in range(t):\n if a - la * f + b - lb * s == x:\n ans = True\nprint 'YES' if ans else 'NO'\n"}, {"source_code": "import sys\nimport math\n\nx, t, a, b, da, db = [int(x) for x in (sys.stdin.readline()).split()]\nd = [0] * 300\n\nif(x == 0):\n print(\"YES\")\n exit()\n\nfor i in range(t):\n d[b] = 1\n b -= db\n \nfor i in range(t):\n if(d[x - a] == 1):\n print(\"YES\")\n exit()\n else:\n a -= da\n \nprint(\"NO\")"}, {"source_code": "def main():\n x, t, a, b, da, db = map(int, input().split())\n possible_a = []\n for i in range(t):\n p = x - a - (da * i)\n if p == 0:\n print(\"YES\")\n return\n\n possible_a.append(p)\n for i in range(t):\n target = b - (db * i)\n for j in range(t):\n if possible_a[j] == target:\n print(\"YES\")\n return\n elif possible_a[j] < target:\n break\n print(\"NO\")\n\n\nmain()"}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nx,t,a,b,da,db=map(int,input().split())\nisprinted=False\nfor i in range(t):\n\tfor j in range(t):\n\t\tval=(a-i*da)+(b-j*db)\n#\t\tprint(val,i,j)\n\t\tif val%x==0:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted:\n\t\tbreak\nif isprinted==False:\n\tfor i in range(t):\n\t\tif (a-i*da)%x==0:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\t\tif (b-i*da)%x==0:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted==False:\n\t\tif x==0:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")"}, {"source_code": "x,t,a,b,da,db = map(int,raw_input().split())\np1 = [-da*i + a for i in xrange(t)]\np2 = [-db*i + b for i in xrange(t)]\nfor i in p1:\n for j in p2:\n if i + j == x:\n print \"YES\"\n exit(0)\nprint \"NO\""}, {"source_code": "import collections\nimport functools\nimport itertools\nimport math\nimport operator\nimport re\nimport sys\n\n\ndef main():\n x, t, a, b, da, db = map(int, raw_input().split())\n for t1 in xrange(t):\n for t2 in xrange(t):\n if x == a - da * t1 + b - db * t2 or x == 0:\n print 'YES'\n return\n print 'NO'\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "x, t, a, b, da, db = eval(\"[\" + raw_input().replace(' ', ',') + \"]\")\nvalid = False\nfor timeSolvingProblemA in range(t):\n\tfor timeSolvingProblemB in range(t):\n\t\ttotalScore = a - da * timeSolvingProblemA + b - db * timeSolvingProblemB\n\t\tif totalScore == x:\n\t\t\tvalid = True\nif valid:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n\n\n"}, {"source_code": "\n\n\nif __name__ == \"__main__\":\n x, t, a, b, da, db = map(int, input().split())\n found = False\n for i in range(t):\n for j in range(t):\n if a - i * da + b - j * db == x:\n found = True\n\n if found:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nx,t,a,b,da,db=map(int,input().split())\nisprinted=False\nfor i in range(t):\n\tfor j in range(t):\n\t\tval=(a-i*da)+(b-j*db)\n\t\tif val==x:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\nif isprinted==False:\n\tprint(\"NO\")"}, {"source_code": "def gcd(a, b):\n c = a % b\n return gcd(b, c) if c else b\n\nx, t, a, b, da, db = map(int, input().split())\nif x == 0: print('YES')\nelse:\n if (a - x) % da == 0: print('YES')\n elif (b - x) % db == 0: print('YES')\n elif a + b - t * (da + db) > x: print('NO')\n else:\n n = a + b - x\n if n % gcd(a, b): print('NO')\n else:\n for i in range(1, t + 1):\n if (n - i * da) % db == 0:\n n = -1\n break\n print('YES' if n < 0 else 'NO')"}, {"source_code": "def main ():\n x,t,a,b,da,db = map(int,raw_input().split())\n \n for i in range(0,t):\n p = a-da*i\n q = x - p\n \n for j in range(0,t):\n r = b - db*j\n \n if (r == q):\n print \"YES\"\n return None\n \n print \"NO\"\n \n \n \n \nwhile (True):\n try:\n main ()\n \n except EOFError:\n break"}, {"source_code": "import itertools as it\nx, t, a, b, da, db = (int(x) for x in input().split())\nif (x in (a - da * i + b - db * j for i in range(t) for j in range(t)) or\n (a > x and (a - x) % da == 0 and (a - x) // da < t) or\n (b > x and (b - x) % db == 0 and (b - x) // db < t)):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "x,t,a,b,da,db=map(int,input().split())\nl1=[a]\nl2=[b]\nfor i in range(1,t):\n\tl1.append(a-(i*da))\n\tl2.append(b-(i*db))\nfor t in l1:\n\tcheck=x-t\n\ttt=0\n\tif check in l2:\n\t\ttt=1\n\t\tbreak\nif tt==0:\n\tprint (\"NO\")\nelse:\n\tprint (\"YES\")\n"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\n\nfor p in xrange(t):\n for q in xrange(t):\n if x == a + b - da * p - db * q:\n print \"YES\"\n exit()\nprint \"NO\""}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\n\nif x == 0:\n print \"YES\"\n exit()\n\nfor p in xrange(t):\n for q in xrange(t):\n if x == a + b - da * p - db * q:\n print \"YES\"\n exit()\nprint \"NO\""}, {"source_code": "def __main__():\n __inp = raw_input().split(' ')\n\n b1 = int(__inp[0]) <= int(__inp[2]) + int(__inp[3]);\n at = int(__inp[2]) - int(__inp[4])*(int(__inp[1]) - 1)\n bt = int(__inp[3]) - int(__inp[5])*(int(__inp[1]) - 1)\n\n if b1 and (at + bt <= int(__inp[0])):\n print(\"YES\");\n else:\n print(\"NO\");\n \n\n__main__()\n"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nx=(a+b)-x\nf=0\nfor i in range(t):\n\tfor j in range(t):\n\t\tif i*da+j*db==x:\n\t\t\tprint \"YES\"\n\t\t\tf=1\n\t\t\tbreak\nif f==0:\n\tprint \"NO\"\n\n\n\n\n\n\n"}, {"source_code": "x, t, a, b, da, db = map(int, raw_input().split())\nprint ['NO', 'YES'][x in set([a - i * da for i in range(t)] + [b - i * db for i in range(t)] + [a + b - i * da - j * db for i in range(t) for j in range(t)])]"}, {"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\nx,t,a,b,da,db=map(int,input().split())\nisprinted=False\nfor i in range(t):\n\tfor j in range(t):\n\t\tif a-i*da+b-j*db==x:\n\t\t\tprint(i,j)\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted:\n\t\tbreak\n#if isprinted==False:\n#\tprint(\"NO\")\n\nif isprinted==False:\n\tfor i in range(t):\n\t\tif a-i*da==x:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\t\tif b-i*db==x:\n\t\t\tprint(\"YES\")\n\t\t\tisprinted=True\n\t\t\tbreak\n\tif isprinted==False:\n\t\tif x==0:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")"}, {"source_code": "def main():\n x, t, a, b, da, db = map(int, input().split())\n if x == 0:\n print(\"YES\")\n return\n possible_a = []\n for i in range(t):\n p = x - a - (da * i)\n if p == 0:\n print(\"YES\")\n return\n\n possible_a.append(p)\n for i in range(t):\n target = b - (db * i)\n for j in range(t):\n if possible_a[j] == target:\n print(\"YES\")\n return\n elif possible_a[j] < target:\n break\n print(\"NO\")\n\nmain()"}, {"source_code": "x,t,a,b,da,db=[int(w) for w in raw_input().split()]\naa=[]\nbb=[]\nfor i in xrange(t):\n aa.append(a-i*da)\n bb.append(b-i*db)\ncc=[0]+aa+bb\nfor i in aa:\n for j in bb:\n cc.append(i+j)\nprint cc\nif x in cc:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "import itertools as it\nx, t, a, b, da, db = (int(x) for x in input().split())\nif x in (a - da * i + b - db * j for i in range(t) for j in range(t)):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "'''\nCreated on Jul 4, 2012\n\n@author: iain\n'''\n\nimport sys\nif __name__ == \"__main__\":\n i = map(int,raw_input().split(\" \"))\n x,t,a,b,da,db = i[0],i[1],i[2],i[3],i[4],i[5]\n for i in range(0, t):\n temp = b\n for j in range(0, t):\n if temp + a == x:\n print \"YES\"\n sys.exit()\n temp = temp - db\n a = a - da\n print \"NO\"\n \n"}, {"source_code": "x,t,a,b,da,db=map(int,raw_input().split())\nif x==0:\n print \"YES\"\n exit(0)\nfor i in range(t):\n for j in range(t):\n if a+b-i*da-j*db==x:\n print \"YES\"\n exit(0)\nprint \"NO\""}, {"source_code": "import itertools as it\nx, t, a, b, da, db = (int(x) for x in input().split())\nif x in (a - da * i + b - db * j for i in range(t) for j in range(t)):\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "def main():\n x, t, a, b, da, db = map(int, input().split())\n if x == 0:\n print(\"YES\")\n return\n possible_a = [0]\n for i in range(t):\n p = a - (da * i)\n if p == x:\n print(\"YES\")\n return\n possible_a.append(p)\n\n for i in range(t):\n target = b - (db * i)\n for j in range(t + 1):\n if x - possible_a[j] == target:\n print(\"YES\")\n return\n elif x - possible_a[j] < target:\n break\n print(\"NO\")\n\nmain()"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n__author__ = 'firago'\nfrom sys import stdin, stdout\nx, t, a, b, da, db = map(int, stdin.read().split())\n\nmina = a - da * t\nminb = b - db * t\nmaxa = a \nmaxb = b\nfor xa in xrange(mina, maxa+1, da):\n for xb in xrange(minb, maxb + 1, db):\n if xa + xb == x:\n print \"YES\"\n exit()\nprint \"NO\"\n"}, {"source_code": "x,t,a,b,da,db = map(int,raw_input().split())\nans = \"NO\"\nfor exa in xrange(2):\n\tfor exb in xrange(2):\n\t\tfor i in xrange(t):\n\t\t\tfor j in xrange(t):\n\t\t\t\tif x==a*exa+b*exb-i*da - j*db:\n\t\t\t\t\tans = \"YES\"\nprint ans\n"}, {"source_code": "x,t,a,b,da,db = map(int, raw_input().split())\n\npos = list()\nfor i in xrange(0,t):\n for j in xrange(0,t):\n pos.append((a-i*da)+(b-j*db))\n pos.append(a-i*da)\n pos.append(b-j*db)\n \nprint pos\n\nif x in pos or x == 0:\n print \"YES\"\nelse:\n print \"NO\"\n \n"}, {"source_code": "#https://codeforces.com/contest/203/problem/A\nl=list(map(int,input().split(' ')))\nx=l[0]\nt=l[1]\na=l[2]\nb=l[3]\nda=l[4]\ndb=l[5]\n\np=(a+b)-(x)\nbhul=True\n\nfor i in range(t):\n\tfor j in range(t):\n\t\tif( (da*i)+(db*j)==p ):\n\t\t\tprint('YES')\n\t\t\tbhul=False\n\t\t\tbreak;\n\nif bhul:\n\tprint('NO')"}, {"source_code": "n=input().split()\nx=int(n[0])\nt=int(n[1])\na=int(n[2])\nb=int(n[3])\nda=int(n[4])\ndb=int(n[5])\nfor i in range(t):\n for j in range(t):\n if x==a-(da*i)+b-(db*j):\n print('YES')\n exit()\n elif x==a-(da*i):\n print('YES')\n exit()\n elif x==b-(db*j):\n print('YES')\n exit()\nprint('NO') \n"}, {"source_code": "x,t,a,b,da,db = map(int,raw_input().split())\np1 = [-da*i + a for i in xrange(t)]\np2 = [-db*i + b for i in xrange(t)]\nfor i in p1:\n for j in p2:\n if i + j == x:\n print \"YES\"\n exit(0)\nprint \"NO\""}, {"source_code": "x,t,a,b,da,db=map(int,input().split())\nl1=[a]\nl2=[b]\nfor i in range(1,t):\n\tl1.append(a-(i*da))\n\tl2.append(b-(i*db))\nfor t in l1:\n\tcheck=x-t\n\ttt=0\n\tif check in l2:\n\t\ttt=1\n\t\tbreak\nif tt==0:\n\tprint (\"NO\")\nelse:\n\tprint (\"YES\")\n"}, {"source_code": "buf = raw_input()\nx, t, a, b, Da, Db = buf.split(\" \")\nx, t, a, b, Da, Db = int(x), int(t), int(a), int(b), int(Da), int(Db)\n\nans = \"NO\"\nfor i in range(0, t + 1):\n for j in range(0, t + 1):\n if a - Da * i + b - Db * j == x:\n ans = \"YES\"\n if b - Db * j == x:\n ans = \"YES\"\n if a - Da * i == x:\n ans = \"YES\"\n\nprint(ans)\n"}], "src_uid": "f98168cdd72369303b82b5a7ac45c3af"} {"source_code": "from bisect import bisect\nfrom collections import defaultdict\n# l = list(map(int,input().split()))\n# map(int,input().split()))\nfrom math import gcd,sqrt,ceil\nfrom collections import Counter\nimport sys\nsys.setrecursionlimit(10**9)\n\nn,k = map(int,input().split())\n\nl = list(map(int,input().split()))\ncount = 0\nwhile True:\n if l[-1]<=k:\n count+=1\n l.pop()\n elif l[0]<=k:\n count+=1\n l.pop(0)\n else:\n break\n\n if l == []:\n break\n\nprint(count)\n\n", "positive_code": [{"source_code": "n, k = map(int, input().split())\ns = list(map(int, input().split()))\nsch = 0\nl = 0\nfor i, el in enumerate(s):\n if el <= k:\n l = i\n sch += 1\n else:\n break\n\nif sch != len(s):\n for i, el in enumerate(s[::-1]):\n if el <= k and len(s) - i > l:\n sch += 1\n else:\n break\nprint(sch)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nSpyder Editor\n\nThis is a temporary script file.\n\"\"\"\n\ntc = list(map(int, input().split()))\nstore = list(map(int, input().split()))\n\nnumOfSolved = 0\ni = 0\nfor i in range(len(store)):\n if store[i] <= tc[1]:\n numOfSolved += 1\n else :\n break\nfor i in range(len(store) - 1, i, -1):\n if store[i] <= tc[1]:\n numOfSolved += 1\n else :\n break\n\nprint (numOfSolved)"}, {"source_code": "r=input().split()\nn=int(r[0])\nk=int(r[1])\nleft=0\nright=0\ncout=0\nn-=1\nmas=(input().split())\nwhile (int(mas[left])<=k) and (left<n):\n left+=1\n cout+=1\n if left==n:\n break\nleft-=1\nwhile (int(mas[n-right])<=k) and ((n-(right)>left)):\n right+=1\n cout+=1\nprint(cout) \n\n"}, {"source_code": "x=input().split()\nn=int(x[0])\nk=int(x[1])\nc=0\ny=input().split()\nfor i in range(n):\n y[i]=int(y[i])\nfor j in range(n):\n if y[j]<=k:\n c+=1\n else:\n w=j\n break\nif c!=n:\n for q in range(n):\n if y[n-1-q]<=k and n-1-q>w:\n c+=1\n else:\n break\nprint(c)"}, {"source_code": "n,k=map(int,raw_input().split(\" \"))\n\nl=map(int,raw_input().split(\" \"))\nif max(l)<=k:\n print n\nelse:\n c=0\n i=0\n while l[i]<=k:\n c+=1\n i+=1\n if i>=n:\n break\n i=-1\n while l[i]<=k:\n c+=1\n i-=1\n if i<-n:\n break\n \n print c\n \n"}, {"source_code": "n,k=[int(x) for x in input().split()]\na=[int(x) for x in input().split()]\nans=0\ni=0\nflag=0\nj=n-1\nwhile(i<=j):\n if(a[i]<=k):\n ans+=1\n i+=1\n continue\n if(a[j]<=k):\n ans+=1\n j-=1\n continue\n if(a[i]>k and a[j]>k):\n break\nprint(ans)\n \n"}, {"source_code": "from collections import deque\na = map(int,raw_input().split())\nk = a[1]\nn = a[0]\na = map(int,raw_input().split())\nd = deque()\ns = 0\nfor i in a:\n if(i <= k):\n s+=1\n else:\n break\n\nif(s == n):\n print s\nelse:\n l = a[::-1]\n for i in l:\n if(i <= k):\n s+=1\n else:\n break\n print s\n \n \n \n"}, {"source_code": "def func():\n n, k = [int(x) for x in list(raw_input().split(' '))]\n a = [int(x) for x in list(raw_input().split(' '))]\n\n result = 0\n id = 0\n for idx, i in enumerate(a):\n if i <= k:\n result += 1\n else:\n id = idx\n break\n\n if result == len(a):\n return result\n\n for idx in range(len(a)-1, id, -1):\n if a[idx] <= k:\n result += 1\n else:\n break\n\n return result\n\n\n\n\nif __name__ == \"__main__\":\n print(func())"}, {"source_code": "n,k=map(int,input().split())\nfrom collections import deque\na=deque(list(map(int, input().split())))\nans=0\nwhile True:\n if not a:break\n if a[0] <= k:\n ans += 1\n a.popleft()\n elif a[-1] <= k:\n ans += 1\n a.pop()\n else:break\nprint(ans)"}, {"source_code": "input1 = input()\ninputL = input1.split(' ')\nn = int(inputL[0])\nk = int(inputL[1])\ninput2 = input()\nnum_problems = 0\nproblemsL = input2.split(' ')\n\nif n != 0:\n while True:\n if problemsL == []:\n break\n if k >= int(problemsL[0]):\n num_problems += 1\n del problemsL[0]\n else:\n break\n\n while True:\n if problemsL == []:\n break\n if k >= int(problemsL[-1]):\n num_problems += 1\n del problemsL[-1]\n else:\n break\n\n print(num_problems)\n \nelse:\n print('0')\n \n"}, {"source_code": "#Abhigyan Khaund - syl\n\nn,k = map(int, raw_input().split())\na = map(int, raw_input().split())\nans = 0\nwhile (len(a)>0 and (a[0]<=k or a[-1]<=k)):\n\tans+=1\n\tif(a[0]<=k):\n\t\ta = a[1:]\n\telse:\n\t\ta = a[:len(a)-1]\nprint ans\n\n"}, {"source_code": "o=input().rstrip().split(' ')\np=input().rstrip().split(' ')\ns=0;\nG=-789;\nfor i in range(0,len(p)):\n if int(p[i])<=int(o[1]):\n s=s+1;\n else:\n G=i;\n break;\nif G!=-789:\n for i in range(len(p)-1,G,-1):\n if int(p[i])<=int(o[1]):\n s=s+1;\n else:\n break;\nprint(s)\n"}, {"source_code": "A = input().split(' ')\nb = [int(num) for num in A]\nn, k = b[0], b[1]\nB = input().split(' ')\na = [int(num) for num in B]\ncount = 0\nl = len(a)\ni = 0\nj=l-1\nwhile i>=0 and i<n and j>=0 and j<n and i!=j:\n if a[i]>k and a[j]>k:\n break\n if a[i]<=k:\n count+=1\n i+=1\n elif a[j]<=k:\n count+=1\n j-=1\nif i==j:\n if a[i]<=k:\n count+=1\nprint(count)\n"}, {"source_code": "import sys,math,collections\nfrom collections import defaultdict\n\n#from itertools import permutations,combinations\n\t\ndef file():\n\tsys.stdin = open('input.py', 'r')\n\tsys.stdout = open('output.py', 'w') \ndef get_array():\n\tl=list(map(int, input().split()))\n\treturn l\ndef get_2_ints():\t\n\ta,b=map(int, input().split())\n\treturn a,b\ndef get_3_ints():\t\n\ta,b,c=map(int, input().split())\n\treturn a,b,c\t\ndef sod(n):\n\tn,c=str(n),0\n\tfor i in n:\t\n\t\tc+=int(i)\n\treturn c\t\ndef isPrime(n):\n if (n <= 1):\n return False\n if (n <= 3):\n return True\n if (n % 2 == 0 or n % 3 == 0):\n return False\n i = 5\n while(i * i <= n):\n if (n % i == 0 or n % (i + 2) == 0):\n return False\n i = i + 6\n \n return True\ndef getFloor(A, x):\n\n\t(left, right) = (0, len(A) - 1)\n\n\tfloor = -1\n\twhile left <= right:\n\t\tmid = (left + right) // 2\n\t\tif A[mid] == x:\n\t\t\treturn A[mid]\n\t\telif x < A[mid]:\n\t\t\tright = mid - 1\n\t\telse:\n\t\t\tfloor = A[mid]\n\t\t\tleft = mid + 1\n\t\t\t\n\treturn floor\ndef floorSqrt(x) : \n \n # Base cases \n if (x == 0 or x == 1) : \n return x \n \n # Do Binary Search for floor(sqrt(x)) \n start = 1\n end = x \n while (start <= end) : \n mid = (start + end) // 2\n \n # If x is a perfect square \n if (mid*mid == x) : \n return mid \n \n # Since we need floor, we update \n # answer when mid*mid is smaller \n # than x, and move closer to sqrt(x) \n if (mid * mid < x) : \n start = mid + 1\n ans = mid \n \n else : \n \n # If mid*mid is greater than x \n end = mid-1\n \n return ans\t\n#file()\ndef main():\n\t#for tt in range(int(input())):\n\tn,m=get_2_ints()\n\tl=get_array()\n\tc=0\n\tfor i in range(n):\n\t\tif(l[i]<=m):\n\t\t\tl[i]='h'\n\t\t\tc+=1\n\t\telse:\n\t\t\tbreak\n\tl.reverse()\n\t#print(l)\n\tfor i in range(n):\n\t\tif(l[i]=='h'):\n\t\t\tbreak\n\t\telif(l[i]<=m):\n\t\t\tc+=1\n\t\telse:\n\t\t\tbreak\n\tprint(c)\t\t\n\n\n\n\n\n\t\t\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\n\t\n\t\n\n\t\t\n\n\n\n\n\n\n\n\n\n\n\n\t\t\n\t\t\n\n\t\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\n\n\t\t\t\n\n\n\n\n\n\n\n \n\t\t\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "x,y=map(int,input().split())\nA=list(map(int,input().split()))\nn,count=[],0\nfor i in range(len(A)):\n if A[i]>y:\n count+=1\n break\n else:\n n.append(A[i])\nA.reverse()\nfor i in range(len(A)):\n if A[i]>y:\n count+=1\n break\n else:\n n.append(A[i])\nif count==0:\n print(x)\nelse:\n print(len(n))"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=0\nwhile len(a)>0 and (a[0]<=k or a[-1]<=k):\n\tif a[0]<=k:\n\t\ts+=1\n\t\tdel a[0]\n\tif len(a)>0:\n\t\tif a[-1]<=k:\n\t\t\ts+=1\n\t\t\tdel a[-1]\n\t\t\t# print(a)\t\t\nprint(s)"}, {"source_code": "\nimport collections\n\nclass Solution:\n def solve(self, n,k,problems):\n i = 0\n j = n-1\n\n ans = 0\n\n while i <= j:\n leftProblemDifficulty = problems[i]\n rightProblemDifficulty = problems[j]\n\n if leftProblemDifficulty <= k:\n i += 1\n ans += 1\n elif rightProblemDifficulty <= k:\n j -= 1\n ans += 1\n else:\n break\n\n return ans\n \n\nsol = Solution()\n\n[n, k] = list(map(int, input().strip().split()))\nproblems = list(map(int, input().strip().split()))\n\nprint(sol.solve(n,k,problems))"}, {"source_code": "def solve(i,j):\n if num[i]>k and num[j]>k:\n return 0\n if i>j:\n return 0\n elif i==j:\n return (1 if num[i]<=k else 0)\n a = 0\n b = 0\n if num[i]<=k:\n a = 1\n i += 1\n if num[j]<=k:\n b = 1\n j -= 1\n return a+b+solve(i,j)\n\n\nn,k = [int(i) for i in input().split()]\nnum = [int(i) for i in input().split()]\n\nprint(solve(0,n-1))\n"}, {"source_code": "n,m=map(int ,input().split())\nl=[int(x) for x in input().split()]\nz=0\nfor i in range(0,len(l)):\n if m>=l[i]:\n z+=1\n else:\n break\nx=0\nfor i in range(len(l)-1,-1,-1):\n if m>=l[i]:\n x+=1\n else:\n break\nif x+z>len(l):\n print(z)\nelse:\n print(x+z)"}, {"source_code": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\ni=0\nj=0\nl=0\nwhile(l<n):\n if(A[i]<=k):\n A.remove(A[i])\n l+=1\n else:\n l+=1\n break\nA.reverse()\nm=0\no=len(A)\nwhile(m<o):\n if(A[j]<=k):\n A.remove(A[j])\n m+=1\n else:\n m+=1\n break\nf=len(A)\nprint(n-f)\n \n \n"}, {"source_code": "n,k=map(int,raw_input().split())\na=map(int,raw_input().split())\nh=0\nfor i in a:\n if k>=i:\n h=h+1\n else:\n break\nj=n-1\nc=0\nwhile j>=0:\n if a[j]<=k:\n c=c+1\n else:\n break\n j=j-1 \nprint min(n,h+c)"}, {"source_code": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\ni=0\nj=0\nl=0\nwhile(l<n):\n if(A[i]<=k):\n A.remove(A[i])\n l+=1\n else:\n l+=1\n break\nA.reverse()\nm=0\no=len(A)\nwhile(m<o):\n if(A[j]<=k):\n A.remove(A[j])\n m+=1\n else:\n m+=1\n break\nf=len(A)\nprint(n-f)\n \n \n"}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\nout = 0\nfor e in a :\n if e > k :\n a = a[::-1]\n for x in a :\n if x > k :\n break\n out += 1\n break\n out += 1\nprint out"}, {"source_code": "a,b=map(int,input().split())\nl=list(map(int,input().split()))\nc=0\nfor i in range(a):\n if l[i]<=b:\n c+=1\n else:\n break\nfor i in range(a-1,-1,-1):\n if l[i]<=b:\n c+=1\n else:\n break\nprint(min(a,c))\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nN, K = MAP()\nA = LIST()\n\nif max(A) <= K:\n print(N)\n exit()\n\nans = 0\nfor i in range(N):\n if A[i] > K:\n break\n else:\n ans += 1\nfor i in range(N-1, -1, -1):\n if A[i] > K:\n break\n else:\n ans += 1\nprint(ans)\n"}, {"source_code": "(n,k)=[int(i) for i in input().split()]\nq=[int(i) for i in input().split()]\nans=0\nwhile(1):\n flag=0\n if(len(q)>0 and q[0]<=k ):\n ans+=1\n del(q[0])\n flag+=1\n if(len(q)>0 and q[-1]<=k):\n ans+=1\n del(q[-1])\n flag+=1\n if(flag==0):\n break\nprint(ans)"}, {"source_code": "n, k = map(int, input().split())\nl = list(map(int, input().split()))\n\nfor i in range(n):\n if l[0] <= k:\n l.pop(0)\n elif l[-1] <= k:\n l.pop(-1)\n else:\n break\n\nprint(n - len(l))"}, {"source_code": "a,b = map(int, input().split())\nc = list(map(int, input().split()))\ncount = 0\nfor i in range(a):\n if c[i] <= b:\n count += 1\n else:\n break\nfor j in range(a-1,0,-1):\n if c[j] <= b:\n count += 1\n else:\n break\nprint(a if count > a else count)"}, {"source_code": "N, K = map(int, input().strip().split())\nA = list(map(int, input().strip().split()))\n\nans = 0\nfor i in range(N) :\n\tif A[i] <= K :\n\t\tans += 1\n\telse :\n\t\tbreak\n\nstop = ans-1\nfor i in range(N) :\n\tif N-1-i == stop :\n\t\tbreak\n\tif A[N-1-i] <= K :\n\t\tans += 1\n\telse :\n\t\tbreak\n\nprint(ans)\n"}, {"source_code": "n = input().split()\nk = int(n[1])\nn = int(n[0])\na = [int(i) for i in input().split()]\nq = 0\n\nwhile k >= a[0]:\n del a[0]\n q += 1\n if len(a) == 0:\n break\n\n\nif len(a) != 0:\n while k >= a[-1]:\n del a[-1]\n q += 1\n if len(a) == 0:\n break\nprint(q)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nlc=0\nrc=0\ni=0\nm=0\nwhile k>=a.pop(0):\n lc+=1\n if len(a)==0:\n m=1\n break\nif m==1 or len(a)==0:\n print(lc)\nelse:\n while k>=a.pop():\n rc+=1\n if len(a)==0:\n break\n print(rc+lc)"}, {"source_code": "from collections import deque\nn, k = map(int, raw_input().split())\nl = map(int, raw_input().split())\nl = deque(l)\ncont = 0\ncontinuarI = True\ncontinuarF = True\nreverter = False\nwhile((continuarI or continuarF) and cont < n):\n if(reverter):\n if(l[n-(cont+1)] <= k):\n cont += 1\n l.pop()\n else:\n continuarF = False\n reverter = False\n else:\n if(l[0] <= k):\n cont += 1\n l.popleft()\n else:\n continuarI = False\n reverter = True\n\nprint(cont)"}, {"source_code": "import sys\nfrom collections import deque\n\nn,k = list(map(int,sys.stdin.readline().strip().split(' ')))\nl = list(map(int,sys.stdin.readline().strip().split(' ')))\n\nl = deque(l)\nans = 0\n\nwhile l:\n\tif l[0] <= k:\n\t\tl.popleft()\n\t\tans += 1\n\telif l[-1] <= k:\n\t\tl.pop()\n\t\tans += 1\n\telse:\n\t\tbreak\nprint(ans)"}, {"source_code": "inp = list(map(int,input().split()))\nn=inp[0]\nk=inp[1]\ninp = list(map(int,input().split()))\ncount=0\nfor item in inp:\n if(item>k):\n count+=1\nif(count==0):\n print (len(inp))\nelse:\n a=inp\n count=0\n for i in range(len(a)):\n if(a[i]<=k):\n count+=1\n else:\n break\n a.reverse()\n for i in range(len(a)):\n if(a[i]<=k):\n count+=1\n else:\n break\n print(count)"}, {"source_code": "# cook your code here\nn,k=map(int,raw_input().split(' '))\na=map(int,raw_input().split(' '))\n\nleft=0\nright=n-1\ncheck=True\nwhile(check==True and left<n):\n if(a[left]>k):\n check=False\n else:\n left=left+1\n\ncheck=True\nwhile(check==True and right>=0):\n if(a[right]>k):\n check=False\n else:\n right=right-1\n\nright=n-1-right\n\nif(left+right>n):\n print(n)\nelse:\n print(left+right)\n \n \n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ni=0\nj=-1\nflag=0\nc=0\nwhile flag==0 and i<=len(a)+j:\n if a[i]<=k:\n c+=1\n i+=1\n continue\n if a[j]<=k:\n c+=1\n j-=1\n continue\n else:\n flag=1\nprint(c)\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\ni=0\nj=n-1\ncount=0\nf=0\nfor i in range(n):\n if l[i]<=k:\n count+=1\n else:\n f=1\n break\nc2=0\nf1=0\nfor j in range(n-1,0,-1):\n \n if l[j]<=k:\n c2+=1\n else:\n f1=1\n break\nif n==1 and l[0]>k:\n print(0)\nelif i<j:\n print(count+c2)\nelif f==1 and f1==1:\n print(n-1)\nelse:\n print(n)\n \n \n\n"}, {"source_code": "n, k = map(int, raw_input().split())\narr = map(int, raw_input().split())\ncount = 0\ni, j = 0, n-1\nwhile i<= j:\n\tfirst = arr[i]\n\tlast = arr[j]\n\tif 0<first<=k:\n\t\tcount += 1\n\t\tarr[i] = -1\n\t\ti += 1\n\n\telif 0<last and last<=k:\n\t\tcount += 1\n\t\tarr[j] = -1\n\t\tj -= 1\n\telse:\n\t\tbreak\nprint count"}, {"source_code": "n,k=map(int,input().split())\nlist1=list(map(int,input().split()))\ncount=0\nfor i in range(n):\n\tif list1[0]<=k:\n\t\tcount+=1\n\t\tlist1.pop(0)\n\telif list1[-1]<=k:\n\t\tcount+=1\n\t\tlist1.pop()\n\telif list1[-1]>k and list1[0]>k:\n\t\tbreak\nprint(count)"}, {"source_code": "z=input\nmod = 10**9 + 7\nfrom collections import *\nfrom queue import *\nfrom sys import *\nfrom collections import *\nfrom math import *\nfrom heapq import *\nfrom itertools import *\nfrom bisect import *\nfrom collections import Counter as cc\nfrom math import factorial as f\ndef lcd(xnum1,xnum2):\n return (xnum1*xnum2//gcd(xnum1,xnum2))\ndef prime(x):\n p=ceil(x**.5)+1\n for i in range(2,p):\n if x%i==0:\n return 0\n return 1\n\n################################################################################\n\n\"\"\"\nl=sorted(list(map(int,z().split())))[::-1]\n\na,b=map(int,z().split())\n\nl=set(map(int,z().split()))\n\nled=(6,2,5,5,4,5,6,3,7,6)\n\nvowel={'a':0,'e':0,'i':0,'o':0,'u':0}\n\ncolor4=[\"G\", \"GB\", \"YGB\", \"YGBI\", \"OYGBI\" ,\"OYGBIV\",'ROYGBIV' ]\n\n\"\"\"\n\n###########################---START-CODING---###############################################\n\nn,m=map(int,z().split())\n\nl=list(map(int,z().split()))\n\nt=0\n\nfor i in range(n):\n x1=l[-1]\n x2=l[0]\n if x2<=m:\n l=l[1:]\n t+=1\n continue\n \n if x1<=m:\n l=l[:-1]\n t+=1\n continue\n else:\n break\n\nprint(min(t,n))\n \n\n\n \n"}, {"source_code": "x,y= map(int,input().split())\na=list(map(int,input().split()))\ncount=0\ncount1=0\nfor i in a:\n if y>=i:\n count=count+1\n else:\n break\nb=a[::-1]\nfor k in b:\n if y>=k:\n count1=count1+1 \n else:\n break\ntotal=count+count1\nif total>x:\n print(x)\nelse:\n print(total)\n"}, {"source_code": "# Problem A\n\ndef solve(lst, k):\n max = 0\n temp = 0\n for i in range(len(lst)):\n if lst[i] <= k:\n max += 1\n temp = i\n else: \n temp = i\n break\n\n i = len(lst) - 1\n while i > temp:\n if lst[i] <= k:\n max += 1\n i -= 1\n else: break\n\n return max\n\nn, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprint(solve(lst, k))\n\n# Problem B\n# from string import ascii_lowercase\n\n# n, k = map(int, input().split())\n# s = input()\n\n# delete_count = 0\n# for i in ascii_lowercase:\n# if delete_count == k:\n# break\n# while(True):\n# count = s.count(i)\n# if count > 0 and delete_count <= k:\n# index = s.find(i)\n# # print('here:', index)\n# s = s[:index] + s[index+1:]\n# # print('->', s)\n# delete_count += 1\n# if count == 0 or delete_count == k:\n# break\n\n# print(s)\n"}, {"source_code": "n, k = map(int,input().split())\nM = list(map(int,input().split()))\nc = 0\nfor i in range(n):\n if M[i] < k or M[i] == k:\n c += 1 \n else:\n break\nfor j in range(n - 1, -1, -1):\n if M[j] < k or M[j] == k:\n c += 1 \n else:\n break\nif c == 2*n:\n print(n)\nelse:\n print(c)"}, {"source_code": "problemas, nivel = map(int, raw_input().split())\n\ni = 0\nj = problemas - 1\n\nimpi = False\nimpj = False\ncont = 0\n\nif problemas > 0:\n\n\tentrada = map(int, raw_input().split())\n\n\twhile True:\n\t\t\n\t\tif i != j:\n\t\t\n\t\t\tif entrada[i] <= nivel:\n\t\t\t\t\n\t\t\t\tcont += 1\n\t\t\t\ti += 1\n\t\t\t\n\t\t\telse:\n\t\t\t\t\n\t\t\t\timpi = True\n\t\t\t\n\t\t\tif entrada[j] <= nivel:\n\t\t\t\t\n\t\t\t\tcont += 1\n\t\t\t\tj -= 1\n\t\t\t\t\n\t\t\telse:\n\t\t\t\t\n\t\t\t\timpj = True\n\t\t\t\n\t\t\tif i > j:\n\t\t\t\t\n\t\t\t\tbreak\n\t\t\t\n\t\telse:\n\t\t\t\n\t\t\tif entrada[i] <= nivel:\n\t\t\t\t\n\t\t\t\tcont += 1\n\t\t\t\tbreak\n\t\t\t\n\t\t\telse:\n\t\t\t\t\n\t\t\t\tbreak\n\t\t\t\t\n\t\tif impj and impi:\n\t\t\t\n\t\t\tbreak\n\t\t\t\n\t\t\t\nprint cont\n\t\t\t\n"}, {"source_code": "n,k=map(int,input().split())\nb=list(map(int,input().split()))\nj=0\nq=0\nr=0\nwhile(j<n):\n if b[j]>k:\n q=j+1\n break\n j+=1\nj=n-1\nwhile(j>=0):\n if b[j]>k:\n r=n-j-1\n break\n j+=-1\nif q==0:\n print(n)\nelse:\n print(q+r-1)\n\n\n"}, {"source_code": "class MishkaAndContest:\n def solve(self,numprobs,mishkaskill,probdiff):\n solvablecnt = 0\n solvedprobs=[]\n for problem in range(0,len(probdiff)):\n if probdiff[problem]<=mishkaskill:\n solvablecnt+=1\n else:\n solvedprobs=probdiff[problem:]\n break\n if len(solvedprobs)==0: return solvablecnt\n solvedprobs=solvedprobs[::-1]\n for rev in solvedprobs:\n if rev<=mishkaskill:\n solvablecnt+=1\n else:\n break\n return solvablecnt\nif __name__ == \"__main__\":\n numprobs,mishkaskill = map(int,raw_input().split(\" \"))\n probdiff = map(int,raw_input().split(\" \"))\n mac = MishkaAndContest()\n print mac.solve(numprobs,mishkaskill,probdiff)"}, {"source_code": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\ncount=0\nd=0\nwhile len(A)>0:\n if A[0]>k:\n c1=True\n else:\n del A[0]\n c1=False\n count+=1\n if len(A)>0:\n if A[len(A)-1]>k:\n c2=True\n else:\n del A[len(A)-1]\n c1=False\n count+=1\n if c1 and c2:\n break\nprint(count)"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int,input().split()))\ncount = 0\npos = 0\nwhile pos < n and a[pos] <= k:\n count += 1\n pos += 1\npos = n-1\nif count != n:\n while pos >= 0 and a[pos] <= k:\n count += 1\n pos -= 1\nprint(count)\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nc = 0\n\nwhile a:\n if a[0] > k and a[-1] > k:\n break\n\n if a[0] <= k:\n a.pop(0)\n c += 1\n elif a[-1] <= k:\n a.pop()\n c += 1\n\nprint(c)\n"}, {"source_code": "n=list(map(int,input().split()))\nz=list(map(int,input().split()))\n\ncount=0\n\nstep=0\n\nwhile step<len(z)+count:\n if z[0]<=n[1] :\n count+=1\n del z[0]\n step+=1\n else :\n break\nstep=0\n\ncounti=0\nwhile step<len(z)+counti :\n if z[-1]<=n[1] :\n counti+=1\n del z[-1]\n step+=1\n else :\n break\n\n##print(z)\nprint(count+counti)"}, {"source_code": "\nproblemList = []\nn = 0\nk = 0\n\ndef FindMax(l:int, r:int):\n\n ret = 0\n side = l\n twoSidesBlocked = 0\n\n while l<=r:\n if(side==l and problemList[l]<=k):\n ret += 1\n l += 1\n side = l\n twoSidesBlocked = 0\n elif (side==l):\n if twoSidesBlocked == 1:\n break\n side = r\n twoSidesBlocked += 1\n elif (side==r and problemList[r]<=k):\n ret += 1\n r -= 1\n side = r\n twoSidesBlocked = 0\n elif(side==r):\n if twoSidesBlocked == 1:\n break\n side = l\n twoSidesBlocked += 1\n\n\n\n return ret\n\nif __name__ == \"__main__\":\n\n n,k = map(int,input().split())\n #k = input()\n n = int(n)\n k = int(k)\n\n problemList = list(map(int,input().split()))\n #print(problemList)\n\n result = FindMax(0, n-1)\n print(result)\n #print(problemList)\n"}, {"source_code": "a=[]\nfor x in raw_input().split():\n a.append(int(x))\nn=a[0]\nk=a[1]\ncount=0\np = []\n#print(n)\n#print(k)\n#print(count)\nfor x in raw_input().split():\n p.append(int(x))\nfor i in range(n):\n if p[i]<=k:\n count+=1\n else:\n break\nfor j in range(n-1,0,-1):\n if(p[j]<=k and j>i):\n count+=1;\n else:\n break\nprint(count)"}, {"source_code": "z=input\nimport math\nn,k=map(int,z().split())\nc=0\nl=list(((map(int,z().split()))))\n\nfor i in l:\n if i<=k:\n c+=1\n else:\n break\nfor i in l[::-1]:\n if i<=k:\n c+=1\n else:\n break\nif c>=n:\n c=n\nprint(c)\n"}, {"source_code": "###\nimport sys\ndata = sys.stdin.readlines()\n\nlis = []\n\nfor line in data:\n lis.append(line)\n###\nn, k = list(map(int, lis[0].split()))\nseq = list(map(int, lis[1].split()))\n#5 100\n\n\n#n, k = list(map(int, '5 100'.split()))\n#seq = list(map(int, '12 34 55 43 21'.split()))\n\nctr = 0 \nwhile seq: #right \n if seq[0] <= k:\n ctr+= 1\n seq.pop(0)\n else: \n break\nwhile seq: #left\n if seq[-1] <= k:\n ctr+= 1\n seq.pop(-1)\n else: \n break\nprint(ctr)"}, {"source_code": "# -*- coding:utf-8 -*-\n#[n, m] = [int(x) for x in raw_input().split()]\ndef some_func():\n \"\"\"\n \"\"\"\n n,k = [int(x) for x in raw_input().split()]\n n_list = [int(x) for x in raw_input().split()]\n cost = 0\n for v in n_list:\n if v<=k:\n cost+=1\n else:\n break\n for v in n_list[::-1]:\n if v<=k:\n cost+=1\n else:\n break\n\n return min(n, cost)\n\n\nif __name__ == '__main__':\n print some_func()\n\n\n"}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\ncount = 0\n\nfor i in range(len(a)):\n\tif not a: break\n\tif a[0] <= k:\n\t\tdel a[0]\n\t\tcount += 1\n\tif not a: break\n\tif a[-1] <= k:\n\t\tdel a[-1]\n\t\tcount += 1\nprint count"}, {"source_code": "#!/usr/bin/env python\nn, k = [int(x) for x in raw_input().split()]\na = [True if int(x) <= k else False for x in raw_input().split()]\nprint n if all(a) else a.index(False) + a[::-1].index(False)"}, {"source_code": "n,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nl = max(a)\nif l<=k:\n print(n)\nelse:\n i = 0\n p = 0\n while i<n:\n if a[i]<=k:\n p=p+1\n else:\n break\n i+=1\n i = n-1\n while i>=0:\n if a[i]<=k:\n p=p+1\n else:\n break\n i-=1\n print(p)\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\ni=0\nh=1\nc=0\np=0\ns=1\nwhile i<n:\n if l[i]<=k:\n p+=1\n else:\n c+=1\n i=n\n h=-1\n if c==2:\n s=0\n print(p)\n break\n i+=h\nif s==1:\n print(n)\n "}, {"source_code": "def reshenie(lst, k):\n count, count1 = 0, 0\n if all(i <= k for i in lst):\n return len(lst)\n elif lst[0] > k and lst[len(lst) - 1] > k:\n return 0\n else:\n for i in range(len(lst) - 1):\n if lst[i] <= k:\n count += 1\n else:\n break\n for i in range(len(lst) - 1):\n if lst[len(lst) - i - 1] <= k:\n count1 += 1\n else:\n break\n return count + count1\n\n\ns, m = [int(j) for j in input().split()]\na = [int(i) for i in input().split()]\nprint(reshenie(a, m))\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nl = 0\nfor i in range(n):\n if a[i] <= k:\n l += 1\n else:\n break\nr = 0\nfor i in range(n-1, -1, -1):\n if a[i] <= k:\n r += 1\n else:\n break\n\nprint(min(n, l+r))\n"}, {"source_code": "n,k=raw_input().strip().split(' ')\nn,k=[int(n),int(k)]\na=map(int,raw_input().strip().split(' '))\ncount=0\nco=0\nfor i in range(n):\n if a[i]<=k:\n count+=1\n elif a[i]>k:\n break\nfor i in range(n-1,-1,-1):\n if a[i]<=k:\n co+=1\n elif a[i]>k:\n break\nif count<n or co<n:\n print count+co\nelse:\n print n\n \n"}, {"source_code": "n,k=map(int,input().split())\narr=[int(x) for x in input().split()]\ncount=0\nwhile len(arr)!=0:\n if arr[0]<=k:\n count+=1\n arr.remove(arr[0])\n else:\n break\n\nfor i in range(len(arr)-1,-1,-1):\n if arr[i]<=k:\n count+=1\n else:\n break\nprint(count)"}, {"source_code": "first_row = input().split(' ')\ntasks_number = int(first_row[0])\nmax_taks_level = int(first_row[1])\ncontest_tasks = input().split(' ')\n\nnumber_of_solved_tasks = 0\nhas_unsolved_task = False\nfor current_task in contest_tasks:\n if int(current_task) <= max_taks_level:\n number_of_solved_tasks += 1\n else:\n has_unsolved_task = True\n break\n\nif has_unsolved_task:\n for current_task_reverse in reversed(contest_tasks):\n if int(current_task_reverse) <= max_taks_level:\n number_of_solved_tasks += 1\n else:\n break\nprint(number_of_solved_tasks)"}, {"source_code": "n,k=map(int, input().split())\nl=list(map(int, input().split()))\nm=max(l)\nc1=0\nc2=0\nif m<=k:\n print(n)\n exit(0)\n\n\nfor x in l:\n if x>k:\n break\n c1+=1\n\nfor i in range(n-1,-1,-1):\n if l[i]>k:\n break\n c2+=1\n\nprint(c1+c2)"}, {"source_code": "n, k = [int(i) for i in input().split()]\nsp = [int(i) for i in input().split()]\ntiller = 0\nFlag = True\nwhile sp != []:\n if sp[0] <= k:\n sp.pop(0)\n tiller += 1\n elif sp[-1] <= k:\n sp.pop(-1)\n tiller += 1\n else:\n print(tiller)\n break\nif sp == []:\n print(n)"}, {"source_code": "__author__ = 'Devesh Bajpai'\n\n'''\nhttps://codeforces.com/problemset/problem/999/A\n\nSolution: \n'''\n\n\ndef solve(n, k, arr):\n\n i = 0\n while i < n and arr[i] <= k:\n i += 1\n\n j = n-1\n while j > i and arr[j] <= k:\n j -= 1\n\n return i + (n - j) - 1\n\n\nif __name__ == \"__main__\":\n\n n, k = map(int, raw_input().split(\" \"))\n arr = map(int, raw_input().split(\" \"))\n print solve(n, k, arr)\n"}, {"source_code": "n,m=input().split()\nn=int(n)\nm=int(m)\ncount=0\nl=input().split()\nl=[int(i) for i in l]\nbegin = 0\nend = n - 1\nwhile(True):\n\n\n if(l[begin]<=m):\n count+=1\n begin=begin+1\n elif(l[end]<=m):\n count+=1\n end=end-1\n else:\n break\n\n if (begin == n or end ==-1):\n break\nprint(count)"}, {"source_code": "n, k = map(int, raw_input().split())\narr = map(int, raw_input().split())\n\nans = 0\nwhile len(arr) > 0 and arr[0] <= k:\n ans += 1\n arr.pop(0)\n\nwhile len(arr) > 0 and arr[-1] <= k:\n ans += 1\n arr.pop(-1)\n\nprint ans"}, {"source_code": "from sys import stdin\n\nlines = stdin.readlines()\nn,k = map(int,lines[0].split())\na = map(int,lines[1].split())\nsumm = 0\nflag = True\nwhile flag:\n if a == []:\n print summ\n flag = False\n elif a[0] <= k:\n summ += 1\n del a[0]\n elif a[-1] <= k:\n summ += 1\n del a[-1]\n else:\n print summ\n flag = False"}, {"source_code": "l, m = input().split()\n\nstring = input()\n\n\n\nstring = string.split()\n\nflag = True\n\ntemp = None\nfor index, s in enumerate(string):\n if int(m) < int(s):\n temp = string[index:]\n break\n \n if index+1 == len(string):\n flag = False\n print(l)\n\nif temp != None:\n temp = list(reversed(temp))\n temp2 = list\n \n for index, s in enumerate(temp):\n \n if int(m) < int(s):\n temp2 = temp[index:]\n break\n \n if flag == True:\n print(int(l)-len(temp2))"}, {"source_code": "n,k = map(int, raw_input().split())\nt = map(int, raw_input().split())\nwyn = 0\nfor x in range(0, len(t), +1):\n if t[x] <= k:\n wyn += 1\n t[x] = 101\n else:\n break\nfor x in range(len(t)-1,-1, -1):\n if t[x] <= k:\n wyn += 1\n t[x] = 101\n else:\n break\nprint wyn"}, {"source_code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nc = 0\nd = 0\nfor x in range(len(a)):\n if a[x] <= k:\n c += 1\n else:\n break\nfor x in range(len(a) - 1, 0, -1):\n if a[x] <= k:\n d += 1\n else:\n break\nif c==n:\n print(c)\nelif d==n:\n print(d)\nelse:\n print(d+c)\n"}, {"source_code": "n,k=map(int,input().split())\ncount1=0\nl=list(map(int,input().split()))\nfor i in range(0,n):\n if(l[i]<=k):\n count1+=1\n else:\n break\nfor i in range(n-1,-1,-1):\n if(l[i]<=k):\n count1+=1\n else:\n break\nif(count1>n):\n print(n)\nelse:\n print(count1)"}, {"source_code": "n,k=map(int,input().split())\nl=[int(i) for i in input().split()]\na=0\nwhile(len(l) > 0):\n\tif l[0] <= k or l[-1] <= k:\n\t\tif l[0] <= k:\n\t\t\tl.remove(l[0])\n\t\telse:\n\t\t\tl.pop()\n\t\ta+=1\n\telse:\n\t\tbreak\nprint(a)"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nans = 0\nfor i in range(n):\n if a[i] <= k:\n ans += 1\n #print(a[i])\n else: break\nfor i in range(n)[::-1]:\n if a[i] <= k:\n ans += 1\n #print(a[i])\n else: break\nif ans > n:\n ans -= n\nprint(ans)"}, {"source_code": "import sys\nimport collections \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,k = inpl()\nq = collections.deque(inpl())\nwhile q:\n now = q.popleft()\n if now > k:\n q.appendleft(now)\n break\nwhile q:\n now = q.pop()\n if now > k:\n q.append(now)\n break\nprint(n-len(q))"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nc=0\nfor i in range(n):\n if(l[i]<=k):\n c+=1\n else:\n break\nif(c!=n):\n \n for i in range(n-1,-1,-1):\n if(l[i]<=k):\n c+=1\n else:\n break\n\n\nprint(c)\n"}, {"source_code": "a,b=map(int,input().split())\nd=0\nc=list(map(int,input().split()))\nif(max(c)<=b):\n print(len(c))\nelse:\n while(c[0]<=b or c[len(c)-1]<=b):\n if(c[0]<=b):\n c.pop(0)\n d+=1\n elif(c[len(c)-1]<=b):\n c.pop(len(c)-1)\n d+=1\n print(d)"}, {"source_code": "n , k = map(int, input().split())\nc = 0\nl = list(map(int, input().split()))\nfor i in range(n):\n if(l[i] <= k):\n c += 1\n else:\n break\n#print('1st loop', c)\nif c < len(l):\n l.reverse()\n for i in l:\n if(i <= k):\n c += 1\n else:\n break\n print(c)\nelse:\n print(c)"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nc=0\ns=0\nfor i in range(n):\n if(l[i]<=k):\n c=c+1\n s=s+1\n else:\n break\nfor j in range(n-1,c,-1):\n if(l[j]<=k):\n s=s+1\n else:\n break\nprint(s)\n"}], "negative_code": [{"source_code": "def solve(i,j):\n if num[i]>k and num[j]>k:\n return 0\n if i>j:\n return 0\n a = 0\n b = 0\n if num[i]<=k:\n a = 1\n i += 1\n if num[j]<=k:\n b = 1\n j -= 1\n #if a==0 and b==0:\n # return 0\n return a+b+solve(i,j)\n\n\nn,k = [int(i) for i in input().split()]\nnum = [int(i) for i in input().split()]\n\nprint(solve(0,n-1))\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\ni=0\nj=n-1\ncount=0\nf=0\nfor i in range(n):\n if l[i]<=k:\n count+=1\n else:\n f=1\n break\nc2=0\nf1=0\nfor j in range(n-1,0,-1):\n \n if l[j]<=k:\n c2+=1\n else:\n f1=1\n break\nif n==1:\n if l[0]>k:\n print(0)\nelif i<j:\n print(count+c2)\nelif f==1 and f1==1:\n print(n-1)\nelse:\n print(n)\n \n \n\n"}, {"source_code": "n, k = map(int, raw_input().split())\narr = map(int, raw_input().split())\narr2 = []\nfor i in range(len(arr) - 1, -1, -1):\n\tarr2.append(arr[i])\ncount = 0\nfor i in arr :\n\tif i <= k:\n\t\tcount = count + 1\n\t\t\n\telse :\n\t\tbreak\t\nfor i in range(len(arr) - 1, -1 , -1):\n\tif(arr[i] <= k):\n\t\tcount = count + 1\n\telse :\n\t\tbreak\t\t\t\n\nprint(count)\t\t\t\n"}, {"source_code": "l, m = input().split()\n\nstring = input()\n\n\nstring = string.split()\n\n\n\ntemp = list\nfor index, s in enumerate(string):\n \n if m < s:\n temp = string[index:]\n break\n\n\ntemp2 = list\nfor index, s in enumerate(temp):\n \n if m < s:\n temp2 = temp[index:]\n break\n\nprint(int(l)-len(temp2))"}, {"source_code": "a,b=map(int,input().split())\nar=list(map(int,input().split()))\nj=0;count=0\nfor i in range(a):\n if ar[i]>b:\n j=i\n break\n else:\n count+=1 \nfor i in range(a-1,j,-1):\n if ar[i]>b:\n break\n else:\n count+=1\nprint(count) \n "}, {"source_code": "n,k=[int(i)for i in input().split()]\nh=0\ng=0\na=[int(i)for i in input().split()]\nfor i in range (0,n):\n c=i\n if a[c]<=k:\n h=h+1\n else:\n break\nfor i in range (n,0,-1):\n b=i-1\n if a[b]<=k:\n g=g+1\n else:\n break\ns=int(g+h)\nif(s<8):\n print(s)\nelse:\n print(s/2)\n \n \n \n \n"}, {"source_code": "var1, var2 = raw_input(\"Enter two numbers here: \").split()\nn=int(var1)\nk=int(var2)\ncount=0\na = []\n#print(n)\n#print(k)\n#print(count)\nfor x in raw_input().split():\n a.append(int(x))\ni=0\nwhile a[i]<=k and i<n:\n count+=1\n i+=1\nprint(count)\nj=n-1\nwhile a[j]<=k and j>i:\n count+=1\n j-=1\nprint(count)"}, {"source_code": "n,k=map(int,raw_input().split(\" \"))\nA=list(map(int,raw_input().split(\" \")))\nct=0\nwhile(A!=[]):\n\tif(A[0]<=k):\n\t\tct=ct+1\n\t\tA.remove(A[0])\n\telif(A[-1]<=k):\n\t\tct=ct+1\n\t\tA.remove(A[-1])\n\telse:\n\t\tbreak\nprint(ct)\n\n\t\n\n"}, {"source_code": "n, k = (int(x) for x in input().split())\na = [int(x) for x in input().split()]\nbegin = -1\nend = -2\nfor i in range(n):\n if a[i] > k:\n if begin == -1:\n begin = i\n else:\n end = i\nprint(n - (end - begin + 1))\n"}, {"source_code": "inp = list(map(int,input().split()))\nn=inp[0]\nk=inp[1]\ninp = list(map(int,input().split()))\ncount=0\nfor item in inp:\n if(item>k):\n count+=1\nif(count==0):\n print (len(inp))\nelse:\n a=inp\n count=0\n for i in range(len(a)):\n if(a[i]<=k):\n count+=1\n else:\n break\n a.reverse()\n for i in range(len(a)):\n if(a[i]<=k):\n count+=1\n else:\n break\nprint(count)"}, {"source_code": "n, k = input().split()\nproblems = input().split()\ncount = 0\nfor i in range(int(n)):\n if int(problems[0]) <= int(k):\n count += 1\n problems.remove(problems[0])\n elif int(problems[-1]) <= int(k):\n problems.remove(problems[-1])\n count += 1\n else:\n break\nprint(count)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(reversed(a))\nc=0\nfor i in range(n):\n if a[i]<=k:\n c+=1\n else:\n break\nfor i in range(n):\n if b[i]<=k:\n c+=1\n else:\n break \nprint(c) "}, {"source_code": "nums = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\nk = nums[1]\nleft = 0\nright = 0\nfor i in range(len(arr)):\n if arr[i] > k:\n left = i\n break\nfor i in range(len(arr) - 1, -1, -1):\n if arr[i] > k:\n right = i\n break\nif left == 0 and right == 0:\n res = len(arr)\nelse:\n res = len(arr) - (right - left + 1)\nprint(res)"}, {"source_code": "n,k = map(int, input().split(' '))\nalist = list(map(int,input().split()))\ni = 0\ncount = 0\nwhile i < n:\n if alist[i] <= k:\n count += 1\n else:\n break\n i += 1\nif i < n-2:\n j = n-1\n while j > i:\n if alist[j] <= k:\n count+=1\n else:\n break\n j -= 1\nprint(count)"}, {"source_code": "n,m=map(int ,input().split())\nl=[int(x) for x in input().split()]\nz=0\nfor i in range(0,len(l)):\n if m>=l[i]:\n z+=1\n else:\n break\nx=0\nfor i in range(len(l)-1,0,-1):\n if m>=l[i]:\n x+=1\n else:\n break\nif x==z:\n print(z)\nelse:\n print(x+z)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ni=0\nj=-1\nflag=0\nc=0\nwhile flag==0 and i<len(a)+j:\n if a[i]<=k:\n c+=1\n i+=1\n continue\n if a[j]<=k:\n c+=1\n j-=1\n continue\n else:\n flag=1\nprint(c)\n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nd=0\nfor i in range(n):\n if min(a[0],a[n-1])<=k:\n a.remove(min(a[0],a[n-1]))\n d+=1\n n-=1\nprint(d) "}, {"source_code": "n,k = map(int,input().split())\nai = list(map(int,input().split()))\nrev_ai = ai[::-1]\ncnt = 0\nres = None\nfor i in range(n):\n if ai[i] > k:\n res = i\n break\n else:\n cnt += 1\n\nif res != None:\n for i in range(res+1,-1,-1):\n if ai[i] > k:\n break\n else:\n cnt += 1\n\nprint(cnt)"}, {"source_code": "x,y = map(int,input().split())\na = list(map(int,input().split()))\nk = 0\nt = 0\nz = [0]*2\nif x == 1 and y>= a[0]:\n\tprint(1)\nelif y<a[0] and len(a) == 1:\n\tprint(\"0\")\nelse:\n\tfor i in range(len(a)):\n\t\tif k == 1 and t == 1:\n\t\t\tbreak\n\t\tif a[i] > y and k == 0:\n\t\t\tz[0]=i\n\t\t\tk = k + 1\n\t\tif a[len(a)-i-1] > y and t == 0:\n\t\t\tz[1]=len(a)-i-1\n\t\t\tt = t + 1\n\t\tif k == 1 and t == 1:\n\t\t\tbreak\n\tif z[0] != 0 or z[1] != 0:\n\t\tprint(len(a)-z[1]+z[0]-1)\n\telse: \n\t\tprint(len(a))"}, {"source_code": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nans = 0\nind = 0\nfor i in range(n):\n if a[i] > k:\n ind = i\n break\n else:\n ans += 1\nfor i in range(n-1,ind-1,-1):\n if a[i] > k:\n break\n else:\n ans += 1\nprint(ans)"}, {"source_code": "first_row = input(\"Enter first row: \").split(' ')\ntasks_number = first_row[0]\nmax_taks_level = first_row[1]\ncontest_tasks = input(\"Enter second row: \").split(' ')\n\nnumber_of_solved_tasks = 0\nhas_unsolved_task = False\nfor current_task in contest_tasks:\n if (current_task <= max_taks_level):\n number_of_solved_tasks += 1\n else:\n has_unsolved_task = True\n break\n\nif (has_unsolved_task):\n for current_task_reverse in reversed(contest_tasks):\n if (current_task_reverse <= max_taks_level):\n number_of_solved_tasks += 1\n else:\n break\nprint(number_of_solved_tasks)"}, {"source_code": "n,k=map(int,input().split())\nm=0\na=[int(i) for i in input().split()]\nwhile n>0 and a[0]>=k:\n m+=1\n del a[0]\n n-=1\nwhile a[n-1]<=k:\n m+=1\n del a[n-1]\n n-=1\nprint(m)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ni=0\nj=n-1\nc=0\nwhile i<j:\n if a[i]<=a[j] and a[i]<=k:\n i+=1\n c+=1\n elif a[i]>a[j] and a[i]<=k:\n j-=1\n c+=1\n else:\n break\nprint(c)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nf=f1=-1\nfor i in range(n):\n if f==-1:\n if a[i]>k:\n f=i\n if f1==-1:\n if a[n-i-1]>k:\n f1=i \nprint((f+f1)if(f+f1>=0)else(0))"}, {"source_code": "n,k=[int(i)for i in input().split()]\nh=0\ng=0\na=[int(i)for i in input().split()]\nfor i in range (0,n):\n c=i\n if a[c]<=k:\n h=h+1\n else:\n break\nfor i in range (n,0,-1):\n b=i-1\n if a[b]<=k:\n g=g+1\n else:\n break\ns=int(g+h)\nif(s<8):\n print(int(s))\nelse:\n print(int(s/2))\n \n \n \n \n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=0\nwhile len(a)>0 and (a[0]<=k or a[-1]<=k):\n\tif a[0]<=k:\n\t\ts+=1\n\t\tdel a[0]\n\t\tprint(a)\n\tif len(a)>0:\n\t\tif a[-1]<=k:\n\t\t\ts+=1\n\t\t\tdel a[-1]\n\t\t\t# print(a)\t\t\nprint(s)"}, {"source_code": "from sys import stdin\nn,k = map(int,stdin.readline().split())\na = map(int,stdin.readline().split())\nans = 0\nfor i in xrange(n):\n if a[i] > k:\n break\n\nif i < n-1:\n ans = i\n a.reverse()\n for i in a:\n if i <=k:\n ans+=1\n else:\n break\nelse:\n ans = n\nprint ans"}, {"source_code": "n = input().split()\nk = int(n[1])\nn = int(n[0])\na = [int(i) for i in input().split()]\nq = 0\n\nfor i in a:\n if k >= i:\n q += 1\n a.pop(0)\n else:\n break\n\nfor i in a[::-1]:\n if k >= i:\n q += 1\n a.pop(0)\n else:\n break\n\nprint(q)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nd=0\nfor i in range(n):\n if min(a[0],a[n-1])<=k:\n a.remove(min(a[0],a[n-1]))\n d+=1\n n-=1\nprint(d) "}, {"source_code": "n,k=list(map(int,input().split()))\nproblems=list(map(int,input().split()))\nc = 0\nfor i in problems:\n if i <= k:\n c+=1\n else:\n problems.reverse()\n break\nfor i in problems:\n if i <= k:\n c+=1\n else:\n break\n"}, {"source_code": "n,m=input().split()\nn=int(n)\nm=int(m)\ncount=0\nl=input().split()\nl=[int(i) for i in l]\nbegin = 0\nend = n - 1\nwhile(True):\n if(begin==n-1 or end==0):\n break\n \n if(l[begin]<=m):\n count+=1\n begin=begin+1\n elif(l[end]<=m):\n count+=1\n end=end-1\n else:\n break\nprint(count)"}, {"source_code": "x,y= map(int,input().split())\na=list(map(int,input().split()))\ncount=0\ncount1=0\nfor i in a:\n if y>=i:\n count=count+1\n else:\n break\nb=a[::-1]\nfor k in b:\n if y>=k:\n count1=count1+1 \n else:\n break\ntotal=count+count1\nprint(total)\n"}, {"source_code": "useless,k=map(int,input().split())\nlis = input().split(\" \")\nn=len(lis)\ncount=0\n\nfor i in range(n):\n if k>=int(lis[0]):\n lis.remove(lis[0])\n count+=1\n\n elif k>=int(lis[-1]):\n lis.remove(lis[-1])\n count+=1\n\n else:\n break\n\nprint(count)"}, {"source_code": "n, m=map(int, input().split())\ncount=0\nli = list(map(int, input().split()))\nfor i in range(len(li)):\n if li[i] <= m:\n count = count + 1\n else:\n break\nfor j in range(len(li)-1, -1,-1):\n if li[j]<=m:\n count =count+1\n else:\n break\nprint(count)\n"}, {"source_code": "n, k = input().split()\nn = int(n)\nk = int(k)\nd = input().split()\nfor i in range(len(d)):\n d[i] = int(d[i])\ni = 0\nj = -1\nci = 0\ncj = 0\nfor i in range(n):\n if d[i] > k:\n break\n ci += 1\nfor i in range(-1, -n - 1, -1):\n if d[j] > k:\n break\n cj += 1\nif ci + cj > n:\n print(n)\nelse:\n print(ci + cj)\n"}, {"source_code": "r=input().split()\nn=int(r[0])\nk=int(r[1])\nleft=0\nright=0\ncout=0\nn-=1\nmas=(input().split())\nwhile (int(mas[left])<=k) and (left<=n):\n left+=1\n cout+=1\n if left==n:\n break\nleft-=1\nwhile (int(mas[n-right])<=k) and ((n-(right)>=left)):\n right+=1\n cout+=1\nprint(cout)"}, {"source_code": "n,k=[int(i)for i in input().split()]\nh=0\ng=0\na=[int(i)for i in input().split()]\nfor i in range (0,n):\n c=i\n if a[c]<=k:\n h=h+1\n else:\n break\nfor i in range (n,0,-1):\n b=i-1\n if a[b]<=k:\n g=g+1\n else:\n break\ns=int(g+h)\nif(s<8):\n print(int(s))\nelse:\n print(int(s/2))\n \n \n \n \n"}, {"source_code": "n,k=map(int,input().split())\nprint(n,k)\na=list(map(int,input().split()))\nb=list(reversed(a))\nc=0\nfor i in range(n):\n if a[i]<=k:\n c+=1 \n else:\n break \nif c!=n: \n\tfor i in range(n):\n\t\tif a[i]<=k:\n\t\t\tc+=1 \n\t\telse:\n\t\t\tbreak \nprint(c) "}, {"source_code": "n, k = input().split()\nn = int(n)\nk = int(k)\nd = input().split()\nfor i in range(len(d)):\n d[i] = int(d[i])\ni = 0\nj = -1\nci = 0\ncj = 0\nfor i in range(n):\n if d[i] > k:\n break\n ci += 1\nfor i in range(-1, -n - 1, -1):\n if d[j] > k:\n break\n cj += 1\nif ci + cj > n:\n print(n)\nelse:\n print(ci + cj)\n"}, {"source_code": "n, k = map(int, input().split())\nmas = list(map(int, input().split()))\ns = 0\nfor i in mas:\n if i <= k:\n s += 1\nprint(s)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\n\n(n, k) = (int(i) for i in input().split())\na = [int(i) for i in input().split()]\n\nstart = time.time()\n\n\nfor i in range(n):\n if a[i] >k:\n break\n\nif i!=n-1:\n for j in range(n-1, i, -1):\n if a[j] > k:\n break\n print(i+n-j-1)\nelse:\n print(n)\n\nfinish = time.time()\n#print(finish - start)\n"}, {"source_code": "useless,k=map(int,input().split())\nlis = input().split(\" \")\nn=len(lis)\ncount=0\n\nfor i in range(n):\n if int(lis[0])<=k:\n lis.remove(lis[0])\n count+=1\n\n elif int(lis[-1])<=k:\n lis.remove(lis[-1])\n count+=1\n\n else:\n break\n\nprint(count)"}, {"source_code": "###\nimport sys\ndata = sys.stdin.readlines()\n\nlis = []\n\nfor line in data:\n lis.append(line)\n###\nn, k = list(map(int, lis[0].split()))\nseq = list(map(int, lis[0].split()))\n\n\n#n, k = list(map(int, '5 2'.split()))\n#seq = list(map(int, '3 1 2 1 3'.split()))\n\nctr = 0 \nwhile True: #right \n if seq[0] <= k:\n ctr+= 1\n seq.pop(0)\n else: \n break\nwhile True: #left\n if seq[-1] <= k:\n ctr+= 1\n seq.pop(-1)\n else: \n break\nprint(ctr)"}, {"source_code": "n,k = map(int,input().split())\nl = list(map(int,input().split()))\ni=0\nj=n-1\nc=0\nwhile i<=j:\n\tif k >= l[i]:\n\t\ti+=1\n\t\tc+=1\n\telif k>=l[j]:\n\t\tj=-1\n\t\tc+=1\n\telse:\n\t break\nprint(c)\n"}, {"source_code": "n,k=[int(i)for i in input().split()]\nh=0\ng=0\na=[int(i)for i in input().split()]\nfor i in range (0,n):\n c=i\n if a[c]<=k:\n h=h+1\n else:\n break\nfor i in range (n,0,-1):\n b=i-1\n if a[b]<=k:\n g=g+1\n else:\n break\ns=int(g+h)\nif(s<8):\n print(s)\nelse:\n print(s/2)\n \n \n \n \n"}, {"source_code": "n,k=map(int,raw_input().split())\na=map(int,raw_input().split())\nf=1\nc=0\nfor i in range(len(a)):\n if a[i]<k:\n c+=1\n \nif c!=n:\n i=0\n j=0\n for i in range(len(a)):\n if a[i]>k:\n j=i\n break\n for i in range(len(a)-1,-1,-1):\n if a[i]>k:\n k=i\n break\n\n print j+n-k-1\nelse:\n print n\n\n "}, {"source_code": "a = input()\ntasks = input()\nn, k = a.split(\" \")\nif int(n) < 1:\n print(0)\nlist_of_tasks = tasks.split(\" \")\ni = 0\nprint(len(list_of_tasks))\nwhile len(list_of_tasks) > 0:\n if int(list_of_tasks[0]) <= int(k):\n del list_of_tasks[0]\n i += 1\n elif int(list_of_tasks[-1]) <= int(k):\n del list_of_tasks[-1]\n i += 1\n else:\n break\nprint(i)\n\n"}, {"source_code": "a,b = raw_input().split()\nb=int(b)\nlis = raw_input().split()\ncounter =0\ntemp = sorted(lis)\nif b >= int(temp[-1]):\n counter=int(a)\nelse: \n for l in lis:\n if b >= int(l):\n counter+=1\n else:\n break\n i=-1\n while True:\n if b >= int(lis[i]):\n counter+=1\n i-=1\n else:\n break\nprint counter\n"}, {"source_code": "n,k=map(int,input().split())\nprint(n,k)\na=list(map(int,input().split()))\nb=list(reversed(a))\nc=0\nfor i in range(n):\n if a[i]<=k:\n c+=1 \n else:\n break \nif c!=n: \n\tfor i in range(n):\n\t\tif a[i]<=k:\n\t\t\tc+=1 \n\t\telse:\n\t\t\tbreak \nprint(c) "}, {"source_code": "N, K = map(int, input().strip().split())\nA = list(map(int, input().strip().split()))\n\nans = 0\nfor i in range(N):\n\tif A[i] > K :\n\t\tans += i\n\t\tbreak\n\nif i == N-1 and N > 1 :\n\tans = N\nelse :\n\tstop = ans\n\tfor i in range(N):\n\t\tif N-1-i == stop :\n\t\t\tans += i\n\t\t\tbreak\n\t\tif A[N-1-i] > K :\n\t\t\tans += i\n\t\t\tbreak\n\nprint(ans)\n"}, {"source_code": "n,k=map(int,input().split())\na=[int(x) for x in input().split()]\nf1=0\nf2=0\nfor i in range(n):\n if a[i]<=k:\n f1+=1\n else:\n break\nfor i in range(n-1,-1,-1):\n if a[i]<=k:\n f2+=1\n else:\n break\nprint(min(f1,f2)*2) "}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nl=a[0]\nr=a[-1]\nc=0\nm=0\nfor i in range(n-1):\n\tif(l<=k):\n\t\tc=c+1\n\t\tl=a[i+1]\n\telse:\n\t\tm=m+1\n\t\tif(r<=k):\n\t\t\tc=c+1\n\t\t\tr=a[-(m+1)]\n\t\telse:\n\t\t\tprint(c)\n\t\t\tbreak\nelse:\n\tprint(n)"}, {"source_code": "n,k=map(int,raw_input().split())\na=map(int,raw_input().split())\nf=1\nc=0\nfor i in range(len(a)):\n if a[i]<k:\n c+=1\n \nif c!=n:\n i=0\n j=0\n for i in range(len(a)):\n if a[i]>k:\n j=i\n break\n for i in range(len(a)-1,-1,-1):\n if a[i]>k:\n k=i\n break\n\n print j+n-k-1\nelse:\n print n\n\n "}, {"source_code": "\nx,y = map(int,input().split())\na = list(map(int,input().split()))\nk = 0\nt = 0\nz = [0]*2\nif x == 1 and y>= a[0]:\n\tprint(1)\nelif y<a[0] and len(a) == 1:\n\tprint(\"0\")\nelse:\n\tfor i in range(len(a)):\n\t\tif k == 1 and t == 1:\n\t\t\tbreak\n\t\tif a[i] > y and k == 0:\n\t\t\tz[0]=i\n\t\t\tk = k + 1\n\t\tif a[len(a)-i-1] > y and t == 0:\n\t\t\tz[1]=len(a)-i-1\n\t\t\tt = t + 1\n\t\tif k == 1 and t == 1:\n\t\t\tbreak\n\tif z[0] != 0 or z[1] != 0:\n\t\tprint(len(a)-z[1]+z[0]-1)\n\telse: \n\t\tprint(len(a))"}, {"source_code": "t = input().strip().split(\" \")\nn = int(t[0])\ncap = int(t[1])\n\nt = input().strip().split(\" \")\nt = [int(e) for e in t]\nassert len(t) == n\n\ncount = 0\nfor e in t:\n if e <= cap:\n count += 1\n else:\n break\n\nt = reversed(t)\nfor e in t:\n if e <= cap:\n count += 1\n else:\n break\n\nprint(count)\n"}, {"source_code": "n=list(map(int,input().split()))\nz=list(map(int,input().split()))\n\ncount=0\n\nstep=0\n\nwhile step<len(z)+count:\n if z[0]<=n[1] :\n count+=1\n del z[0]\n step+=1\n else :\n break\nstep=0\n\nwhile step<len(z) :\n if z[-1]<=n[1] :\n count+=1\n del z[-1]\n step+=1\n else :\n break\n\n##print(z)\nprint(count)"}, {"source_code": "n,m=map(int ,input().split())\nl=[int(x) for x in input().split()]\nz=0\nfor i in range(0,len(l)):\n if m>=l[i]:\n z+=1\n else:\n break\nx=0\nfor i in range(len(l)-1,0,-1):\n if m>=l[i]:\n x+=1\n else:\n break\nif x==z:\n print(z)\nelse:\n print(x+z)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nf=f1=-1\nfor i in range(n):\n if f == -1:\n if a[i] > k:\n f=i\n if f1 == -1:\n if a[n-i-1] > k:\n f1=i \nprint(f+f1)"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nc = int(0)\nf = int(0)\nwhile f != 1:\n if a[0] <= k:\n c += 1\n a.remove(a[0])\n elif a[len(a) - 1] <= k:\n c += 1\n a.remove(a[len(a) - 1])\n else:\n f = 1\n if c == n:\n break\nprint(c)"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nlc=0\nrc=0\ni=0\nj=len(a)-1\nwhile k>=a[i] and i!=len(a)-1:\n lc+=1\n i+=1\nif i==len(a)-1:\n print(lc)\nelse:\n while k>=a[j] and j!=0:\n rc+=1\n j-=1\n print(rc+lc)"}, {"source_code": "n,m=map(int,input().split())\na=list(map(int,input().split()))\ni=0\nwhile i<n:\n if a[i]>m:\n break\n else:\n i=i+1\nif i==n-1:\n print(n)\nelse:\n j=n-1\n while j>=i:\n if a[j]>m:\n break\n else:\n j=j-1\n print(n-(j-i+1))"}, {"source_code": "l, m = input().split()\n\nstring = input()\n\n\n\nstring = string.split()\n\n\n\ntemp = list\nfor index, s in enumerate(string):\n \n if m < s:\n temp = string[index:]\n break\ntemp = list(reversed(temp))\ntemp2 = list\nfor index, s in enumerate(temp):\n \n if m < s:\n temp2 = temp[index:]\n break\n\nif temp == temp2:\n print(int(l))\nelse:\n print(int(l)-len(temp2))"}, {"source_code": "n, k = map(int, raw_input().split())\narr = map(int, raw_input().split())\narr2 = []\nfor i in range(len(arr) - 1, -1, -1):\n\tarr2.append(arr[i])\ncount = 0\nfor i in arr :\n\tif i <= k:\n\t\tcount = count + 1\n\t\t\n\telse :\n\t\tbreak\t\nfor i in range(len(arr) - 1, -1 , -1):\n\tif(arr[i] <= k):\n\t\tcount = count + 1\n\telse :\n\t\tbreak\t\t\t\n\nprint(count)\t\t\t\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nans = 0\nfor i in range(n):\n if a[i] <= k:\n ans += 1\n #print(a[i])\n else: break\nfor i in range(n-1, 0, -1):\n if a[i] <= k:\n ans += 1\n #print(a[i])\n else: break\nif ans > n:\n ans -= n\nprint(ans)"}, {"source_code": "x,y= map(int,input().split())\na=list(map(int,input().split()))\ncount=0\ncount1=0\nfor i in a:\n if y>=i:\n count=count+1\n else:\n break\nb=a[::-1]\nfor k in b:\n if y>=k:\n count1=count1+1 \n else:\n break\ntotal=count+count1\nprint(total)\n"}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\nout = 0\nfor e in a :\n if e > k :\n break\n out += 1\na = a[::-1]\nfor e in a :\n if e > k :\n break\n out += 1\nprint out"}, {"source_code": "(n,k)=[int(i) for i in input().split()]\nq=[int(i) for i in input().split()]\nans=0\nwhile(1):\n flag=0\n if(len(q)>0 and q[0]<=k ):\n ans+=1\n q.remove(q[0])\n flag+=1\n if(len(q)>0 and q[-1]<=k):\n ans+=1\n q.remove(q[-1])\n flag+=1\n if(flag==0):\n break\nprint(ans)"}, {"source_code": "import math\nimport os\nimport random\nimport re\nimport sys\nimport functools\nfrom operator import itemgetter, attrgetter\nfrom collections import Counter\n\nif __name__ == '__main__':\n Y = lambda: list(map(int, input().split()))\n P = lambda: map(int, input().split())\n N = lambda: int(input())\n\n n, k = P()\n a = Y()\n l, r, c = 0, n - 1, 0\n\n while l < r and (a[l] <= k or a[r] <= k):\n if a[l] <= k:\n l += 1\n if a[r] <= k:\n r -= 1\n print(n if r - l <= 0 else n - (r - l + 1))"}, {"source_code": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nans = 0\nfor i in a:\n if i > k:\n ind = i\n break\n else:\n ans += 1\nfor i in range(n-1,i-1,-1):\n if a[i] > k:\n break\n else:\n ans += 1\nprint(ans)"}, {"source_code": "n,k = map(int, input().split());\na = [None] * n;\ncompleted = 0;\n\na = input().split();\nfor i in range(0,n):\n a[i] = int(a[i]);\n\nfront = 0;\nend = n-1;\n\nwhile a[front]<=k and len(a)>0:\n print(a, front);\n if a[front]<=k:\n del a[front];\n completed+=1;\n end = len(a)-1;\n if len(a)<=0:\n break;\n \nif len(a)>0:\n while a[end]<=k and len(a)>0:\n print(a, end);\n if a[end]<=k:\n del a[end];\n completed+=1;\n end = len(a)-1;\n if len(a)<=0:\n break;\n\nprint(completed);"}, {"source_code": "n, m=map(int, input().split())\ncount=0\nli = list(map(int, input().split()))\nfor i in range(len(li)):\n if li[i] <= m:\n count = count + 1\n else:\n break\nfor j in range(len(li)-1, -1):\n if li[j] <= m:\n count = count + 1\n else:\n break\nprint(count)\n"}, {"source_code": "n,k= map(int,input().split())\nc = 0\na = list(map(int,input().split()))\nj = n-1\ni = 0\nwhile True :\n if i > j or a[j] > k and a[i] > k:\n break\n if a[i] <= k:\n c+=1\n i+=1\n if a[j] <= k:\n c+=1\n j-=1\nprint(c)\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\ncounter = 0\nfor i in a:\n if i <= k:\n counter += 1\n else:\n break\nfor i in range(n-1, 0, -1):\n if a[i] <= k:\n counter += 1\n else:\n break\nprint(counter)\n"}, {"source_code": "#-*-coding:utf8;-*-\n#qpy:3\n#qpy:console\n\nprint(\"This is console module\")\n"}, {"source_code": "n,m=input().split()\nn=int(n)\nm=int(m)\ncount=0\nl=input().split()\nl=[int(i) for i in l]\nbegin = 0\nend = n - 1\nwhile(True):\n \n\n if(l[begin]<=m):\n count+=1\n begin=begin+1\n elif(l[end]<=m):\n count+=1\n end=end-1\n else:\n break\n\n if (begin == n - 1 or end == 0):\n break\nprint(count)"}, {"source_code": "n, k = input().split()\nproblems = input().split()\ncount = 0\nfor i in range(int(n)):\n if int(problems[0]) <= int(k):\n count += 1\n problems.remove(problems[0])\n elif int(problems[-1]) <= int(k):\n count += 1\n problems.remove(problems[-1])\n else:\n break\n print(problems)\nprint(count)"}, {"source_code": "n, k = input().split()\nproblems = input().split()\ncount = 0\nfor i in range(int(n)):\n if int(problems[0]) <= int(k):\n count += 1\n problems.remove(problems[0])\n elif int(problems[-1]) <= int(k):\n count += 1\n problems.remove(problems[-1])\n else:\n break\n print(problems)\nprint(count)"}, {"source_code": "n, k = input().split()\nproblems = input().split()\ncount = 0\nfor i in range(int(n)):\n if int(problems[0]) <= int(k):\n count += 1\n problems.remove(problems[0])\n elif int(problems[-1]) <= int(k):\n count += 1\n problems.remove(problems[-1])\nprint(count)"}, {"source_code": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\ni=0\nj=n-1\ncount=0\nf=0\nfor i in range(n):\n if l[i]<=k:\n count+=1\n else:\n f=1\n break\nc2=0\nf1=0\nfor j in range(n-1,0,-1):\n \n if l[j]<=k:\n c2+=1\n else:\n f1=1\n break\nif i<j:\n print(count+c2)\nelif f==1 and f1==1:\n print(n-1)\nelse:\n print(n)\n \n \n\n"}, {"source_code": "r=input().split()\nn=int(r[0])\nk=int(r[1])\nleft=0\nright=0\ncout=0\nn-=1\nmas=(input().split())\nwhile (int(mas[left])<=k) and (left<=n):\n left+=1\n cout+=1\n if left==n:\n break\nleft-=1\nwhile (int(mas[n-right])<=k) and ((n-(right)>=left)):\n right+=1\n cout+=1\nprint(cout)"}, {"source_code": "# Problem A\n\ndef solve(lst, k):\n max = 0\n for i in range(0, len(lst)//2):\n if lst[i] <= k:\n max += 1\n else: break\n\n i = len(lst) - 1\n while i >= len(lst)//2:\n if lst[i] <= k:\n max += 1\n i -= 1\n else: break\n\n return max\n\nn, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprint(solve(lst, k))\n\n# Problem B"}, {"source_code": "n,k = map(int, input().split(' '))\nalist = list(map(int,input().split()))\ni = 0\ncount = 0\nfor i in range(0,n,1):\n if alist[i] <= k:\n count += 1\n else:\n break\nif i < n-2:\n for j in range(n-1,0,-1):\n if alist[j] <= k:\n count += 1\n else:\n break\n\nprint(count)"}, {"source_code": "useless,k=map(int,input().split())\nlis = input().split(\" \")\nn=len(lis)\ncount=0\n\nfor i in range(n):\n if k>=int(lis[0]):\n lis.remove(lis[0])\n count+=1\n\n elif k>=int(lis[-1]):\n lis.remove(lis[-1])\n count+=1\n\n else:\n break\n\nprint(count)"}, {"source_code": "t = input().strip().split(\" \")\nn = int(t[0])\ncap = int(t[1])\n\nt = input().strip().split(\" \")\nt = [int(e) for e in t]\nassert len(t) == n\n\ncount = 0\nfor e in t:\n if e <= cap:\n count += 1\n else:\n break\n\nprint(count)\n"}, {"source_code": "n, k = input().split()\nproblems = input().split()\n\na = 0\nb = 0\nfor i in range(int(n)):\n if int(problems[i])>int(k):\n a = i\n break\nfor i in range(int(n)-1, -1, -1):\n if int(problems[i])>int(k):\n b = i\n break\n\nif b == 0:\n if a == b:\n b += 1\n b = a-1\n\nif int(n) == 1:\n if int(problems[0])<=int(k):\n print(1)\n else:\n print(0)\nelse:\n print(int(n)-(b-a)-1)"}, {"source_code": "n , m = map(int, input().split())\na = input()\na = list(map(lambda x: a, a))\nprint(a)"}, {"source_code": "def reshenie(lst, k):\n b = list()\n c = list()\n if all(i <= k for i in lst):\n return len(lst)\n elif lst[0] > k and lst[len(lst) - 1] > k:\n return 0\n else:\n for i in range(len(lst) - 1):\n if lst[i] <= k:\n b.append(lst[i])\n elif lst[len(lst) - i - 1] <= k:\n c.append(lst[len(lst) - i - 1])\n return len(lst) - len(b) - len(c)\n\n\ns, m = [int(j) for j in input().split()]\na = [int(i) for i in input().split()]\nprint(reshenie(a, m))\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nc = int(0)\nf = int(0)\nwhile f != 1:\n if a[0] <= k:\n c += 1\n a.remove(a[0])\n elif a[len(a) - 1] <= k:\n c += 1\n a.remove(a[len(a) - 1])\n else:\n f = 1\n if c == n:\n break\nprint(c)"}, {"source_code": "n,k=[int(i) for i in input().split()]\narr=list(map(int,input().split()))\nx=0\ny=n-1\ne=0\nwhile x<=y:\n if arr[x]<=k:\n e=e+1\n x=x+1\n else:\n break\n if arr[y]<=k:\n e=e+1\n y=y-1\nprint(e)\n \n"}, {"source_code": "x,y=map(int,input().split())\nz=list(map(int,input().split()))\nc=0\nfor i in range(x):\n if max(z)<=y:\n c=len(z)\n break\n if i%2==0:\n if z[0]<=y:\n c+=1\n del z[0]\n elif i%2!=0:\n if z[-1]<=y:\n c+=1\n del z[-1]\n if z[0]>y and z[-1]>y:\n break\nprint(c)\n \n"}, {"source_code": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nfor i in range(n):\n\tif(a[i] > k):\n\t\tbreak\nans = i\nfor i in range(n-1,-1,-1):\n\tif(a[i] > k):\n\t\tbreak\nans += n-1-i\nprint(min(ans,n))"}, {"source_code": "n,k=map(int,raw_input().split(\" \"))\n\nl=map(int,raw_input().split(\" \"))\nif max(l)<k:\n print n\nelse:\n c=0\n i=0\n while l[i]<=k:\n c+=1\n i+=1\n if i>=n:\n break\n i=-1\n while l[i]<=k:\n c+=1\n i-=1\n if i<-n:\n break\n print c\n \n"}, {"source_code": "t = input().strip().split(\" \")\nn = int(t[0])\ncap = int(t[1])\n\nt = input().strip().split(\" \")\nt = [int(e) for e in t]\nassert len(t) == n\n\ncount = 0\nfor e in t:\n if e <= cap:\n count += 1\n else:\n break\n\nprint(count)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Oct 3 21:12:33 2018\n\n@author: chirayu jain\n8 4\n4 2 3 1 5 1 6 4\n\n5 2\n3 1 2 1 3\n\n5 100\n12 34 55 43 21\n\"\"\"\n\nn, k = [int(x) for x in input().split()]\nstr1 = [int(x) for x in input().split()]\ncount = 0\ntemp = 0\nfor i in range(0,len(str1)):\n if str1[i] <= k:\n count = count + 1\n else:\n temp = i\n break\npro = len(str1)-1-temp\nfor i in range(len(str1)-1,pro,-1):\n if str1[i] <=k:\n count = count + 1\n else:\n break\nprint(count)"}, {"source_code": "first_row = input(\"Enter first row: \").split(' ')\ntasks_number = int(first_row[0])\nmax_taks_level = int(first_row[1])\ncontest_tasks = input(\"Enter second row: \").split(' ')\n\nnumber_of_solved_tasks = 0\nhas_unsolved_task = False\nfor current_task in contest_tasks:\n print(current_task)\n if int(current_task) <= max_taks_level:\n number_of_solved_tasks += 1\n else:\n has_unsolved_task = True\n break\n\nif has_unsolved_task:\n for current_task_reverse in reversed(contest_tasks):\n if int(current_task_reverse) <= max_taks_level:\n number_of_solved_tasks += 1\n else:\n break\nprint(number_of_solved_tasks)"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nc = int(0)\nf = int(0)\nwhile f != 1:\n if a[0] <= k:\n c += 1\n a.remove(a[0])\n elif a[len(a) - 1] <= k:\n c += 1\n a.remove(a[len(a) - 1])\n else:\n f = 1\n if c == n:\n break\nprint(c)"}, {"source_code": "n,k=map(int,input().split())\narr=[int(x) for x in input().split()]\ncount=0\nwhile len(arr)!=0:\n if arr[0]<=k:\n count+=1\n arr.remove(arr[0])\n else:\n break\nwhile len(arr)!=0:\n m=len(arr)-1\n if arr[m]<=k:\n count+=1\n arr.remove(arr[m])\n else:\n break\nprint(count)"}, {"source_code": "n, m = list(map(int, input().split()))\narr = list(map(int, input().split()))\nul = 0\nfor i in range(len(arr)):\n if arr[i] > m:\n ul += 1\n break\n else:\n ul += 1\nprint(ul)"}, {"source_code": "n , m = map(int, input().split())\na = input()\nprint(a)"}, {"source_code": "n,k=map(int,input().split())\na=[int(x) for x in input().split()]\nf1=0\nf2=0\nfor i in range(n):\n if a[i]<=k:\n f1+=1\n else:\n break\nfor i in range(n-1,-1,-1):\n if a[i]<=k:\n f2+=1\n else:\n break\nprint(f1+f2) "}], "src_uid": "ecf0ead308d8a581dd233160a7e38173"} {"source_code": "n=input()\np,k=list(map(str,input().split()))\njim=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\nif n not in p and n not in k:\n if p[1]==k[1]:\n if jim.index(p[0])>jim.index(k[0]):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\nelse:\n if n in p and n not in k:\n print(\"YES\")\n elif n not in p and n in k:\n print(\"NO\")\n else:\n if jim.index(p[0])>jim.index(k[0]):\n print(\"YES\")\n else:\n print(\"NO\")\n", "positive_code": [{"source_code": "# -*- coding: utf-8 -*-\nc = [ '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' ]\na = raw_input()\nx, y = map(str, raw_input().split())\nif x[1] == y[1]:\n print 'YES' if c.index(x[0]) > c.index(y[0]) else 'NO'\nelif x[1] == a:\n print 'YES'\nelif y[1] == a:\n print 'NO'\nelse:\n print 'NO'\n"}, {"source_code": "mast=['6','7','8','9','T','J','Q','K','A']\nm=raw_input()\na=list(x for x in raw_input())\nif (a[4]==m):\n if (a[1]==m) & (mast.index(a[0])>mast.index(a[3])):\n print ('YES')\n else:\n print ('NO')\nelse:\n if (a[1]==m):\n print ('YES')\n else:\n if(a[1]==a[4]) & (mast.index(a[0])>mast.index(a[3])):\n print ('YES')\n else:\n print ('NO')\n\n \n \n"}, {"source_code": "trump = raw_input()\nx = raw_input()\nfirst = x[:2:]\nsecond = x[3::]\nd = {\n \"6\": 1,\n \"7\": 2,\n \"8\": 3,\n \"9\": 4,\n \"T\": 5,\n \"J\": 6,\n \"Q\": 7,\n \"K\": 8,\n \"A\": 9\n }\nif(first[1] == second[1]):\n if(d[first[0]] > d[second[0]]):\n print \"YES\"\n else:\n print \"NO\"\nelif(first[1] == trump):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "import sys\nimport itertools\nimport math\n\ndef compare(a, b):\n ranks = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\n if ranks.index(a) > ranks.index(b):\n return True\n else:\n return False\n\nif __name__ == '__main__':\n tramp = raw_input()\n cards = raw_input()\n a = cards.split(\" \")[0]\n b = cards.split(\" \")[1]\n\n if a[-1] == b[-1]:\n if compare(a[0], b[0]):\n print \"YES\"\n else:\n print \"NO\"\n elif a[-1] == tramp:\n print \"YES\"\n else:\n print \"NO\"\n\n \n"}, {"source_code": "l=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\ns=input()\na,b=map(str,input().split())\nif(a[1]==s and b[1]!=s):\n print(\"YES\")\nelif(a[1]==b[1]):\n if(l.index(a[0])>l.index(b[0])):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "t = raw_input()\nl,r = list(raw_input().split())\nrank = '6789TJQKA'\nif l[1] == t and r[1] != t:\n print \"YES\"\nelif (l[1] != t and r[1] == t) or (l[1] != r[1]):\n print \"NO\"\nelif rank.index(l[0]) > rank.index(r[0]):\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "l=['6','7','8','9','T','J','Q','K','A']\ns=input()\nx,y=input().split()\nif (x[1]==s and x[1]!=y[1]) or (x[1]==y[1] and l.index(x[0])>l.index(y[0])):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def check(f, s, trump):\n if f[0] == s[0]:\n if f[1] > s[1]:\n return 1\n else:\n return 0\n if f[0] == trump:\n return 1\n return 0\ntrump = raw_input()\nf, s = raw_input().split(\" \")\nnumber = \"6789TJQKA\"\nsuit = \"SHDC\"\nf = [suit.find(f[1]), number.find(f[0])]\ns = [suit.find(s[1]), number.find(s[0])]\ntrump = suit.find(trump)\nprint [\"NO\",\"YES\"][check(f, s, trump)]\n\n"}, {"source_code": "def rank(c):\n s=\"6789TJQKA\"\n return s.find(c)\nt=input()\ns=input()\ns1, s2=s.split(sep=\" \")\nif s1[1]==t and s2[1]!=t:\n print('YES')\nelif s1[1]==s2[1] and rank(s1[0])>=rank(s2[0]):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "rnk = \"6789TJQKA\"\nt = raw_input()\na,b = raw_input().split()\nif a[1] == b[1]:\n print \"YES\" if rnk.index(a[0]) > rnk.index(b[0]) else \"NO\"\nelif a[1] == t:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "rank=\"6789TJQKA\"\ntrump=input()\ncard=input()\nr1=card[0]\ns1=card[1]\nr2=card[3]\ns2=card[4]\nif(s1==trump):\n if(s2!=trump):\n print(\"YES\")\n elif(rank.index(r1)>rank.index(r2)):\n print(\"YES\")\n else:\n print(\"NO\")\nelif(s1==s2 and rank.index(r1)>rank.index(r2)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = raw_input()\na, b = raw_input().split()\ncmp = {'6': 1, '7': 2, '8': 3, '9': 4, 'T': 5, 'J': 6, 'Q': 7, 'K': 8, 'A': 9}\nif a[1] == s:\n print 'YES' if b[1] != s or cmp[a[0]] > cmp[b[0]] else 'NO'\nelse:\n print 'YES' if a[1] == b[1] and cmp[a[0]] > cmp[b[0]] else 'NO'"}, {"source_code": "RANK = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\n\n\ndef compareRank(a, b):\n return RANK.index(a[0]) > RANK.index(b[0])\n\n\nt = input()\na, b = input().split(' ')\ns = 'NO'\nif a[1] == t:\n if b[1] != t or (b[1] == t and compareRank(a, b)):\n s = 'YES'\nelif compareRank(a, b) and b[1] != t and a[1] == b[1]:\n s = 'YES'\nprint(s)\n"}, {"source_code": "trump=input()\nc1,c2=input().split()\nc11=c1[0]\nc22=c2[0]\nif c11=='T':\n c11=10\nif c22=='T':\n c22=10\nif c11=='J':\n c11=11\nif c22=='J':\n c22=11\nif c11=='Q':\n c11=12\nif c22=='Q':\n c22=12\nif c11=='K':\n c11=13\nif c22=='K':\n c22=13\nif c11=='A':\n c11=14\nif c22=='A':\n c22=14\n\nif c2[1]!=c1[1] and c1[1]!=trump and c2[1]!=trump:\n print('NO')\nelif c2[1]==c1[1] and int(c11)>int(c22):\n print('YES')\nelif c2[1]!=c1[1]==trump:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "tramp = raw_input()\nc1,c2 = raw_input().split()\n\nrank1 = c1[0]\nsuit1 = c1[1]\n\nrank2 = c2[0]\nsuit2 = c2[1]\n\nyes = False\n\nif suit1 == tramp:\n\tif suit2 != tramp:\n\t\tyes = True\nRANK = ['6','7','8','9','T','J','Q','K','A']\ndef order(x):\n\tfor i in range(len(RANK)):\n\t\tif RANK[i] == x:\n\t\t\treturn i\n\nif suit1 == suit2 and order(rank1) > order(rank2):\n\tyes = True\n\nif yes:\n\tprint 'YES'\nelse:\n\tprint 'NO'\n\n"}, {"source_code": "suits = [\"S\",\"H\",\"D\",\"C\"]\ncards = {\"6\":1,\"7\":2,\"8\":3,\"9\":4,\"T\":5,\"J\":6,\"Q\":7,\"K\":8,\"A\":9}\ntrump = raw_input()\nf,s = raw_input().split()\nif(f[1]==trump and s[1]!=f[1]):\n print \"YES\"\nelif(f[1]!=trump and s[1]==trump):\n print \"NO\"\nelif(f[1]==s[1]==trump):\n print \"YES\" if cards[f[0]]>cards[s[0]] else \"NO\"\nelse:\n print \"NO\" if f[1]!=s[1] else \"YES\" if (cards[f[0]]>cards[s[0]]) else \"NO\"\n"}, {"source_code": "\n#start the code from here\n\ntrump=input()\nfir,sec=map(str,input().split())\ntrlist=[\"S\", \"H\", \"D\",\"C\"]\nrank=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\",\"A\"]\nif fir[1]==trump and sec[1]!=trump:\n\tprint(\"YES\")\nelif fir[1]==sec[1]:\n\tif rank.index(fir[0])>rank.index(sec[0]):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "k = input()\na, b = input().split()\na, b = list(a), list(b)\n\nif a[0] == 'T':\n a[0] = '10'\nelif a[0] == 'J':\n a[0] = '11'\nelif a[0] == 'Q':\n a[0] = '12'\nelif a[0] == 'K':\n a[0] = '13'\nelif a[0] == 'A':\n a[0] = '14'\n\nif b[0] == 'T':\n b[0] = '10'\nelif b[0] == 'J':\n b[0] = '11'\nelif b[0] == 'Q':\n b[0] = '12'\nelif b[0] == 'K':\n b[0] = '13'\nelif b[0] == 'A':\n b[0] = '14'\n\na[0], b[0] = int(a[0]), int(b[0])\n\nif (a[1] == k != b[1]) or (a[1] == b[1] and a[0] > b[0]):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "trump=str(input())\na,b=map(str,input().split())\nd={\"6\":6, \"7\":7, \"8\":8, \"9\":9, \"T\":10, \"J\":11, \"Q\":12, \"K\":13,\"A\":14}\nif list(a)[1]==trump and list(b)[1]!=trump:\n print(\"YES\")\nelif list(b)[1]==trump and list(a)[1]!=trump:\n print(\"NO\")\nelse:\n if list(a)[1]!=list(b)[1]:\n print(\"NO\")\n else:\n if d[list(a)[0]]>d[list(b)[0]]:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "\n\n\n\nts = input()\n\ng=[\"6\", \"7\", \"8\", \"9\"]\nh=[\"T\", \"J\", \"Q\", \"K\" , \"A\"]\na,b = input().split()\n\nif a[-1] == b[-1]:\n\n if a[0] in g:\n if b[0] in h:\n print('NO')\n elif b[0] in g:\n if g.index(a[0])>g.index(b[0]):\n print('YES')\n else:\n print('NO')\n elif a[0] in h:\n if b[0] in g:\n print('YES')\n elif b[0] in h:\n if h.index(a[0])>h.index(b[0]):\n print('YES')\n else:\n print('NO')\nelse:\n\n if a[-1] == ts:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "T=raw_input()\nS=raw_input().split()\nA=S[0]\nB=S[1]\nL={'6':0,'7':1,'8':2,'9':3,'T':4,'J':5,'Q':6,'K':7,'A':8}\nflag1=False\nflag2=False\nif(A[1]==T):\n\tflag1=True\nif(B[1]==T):\n\tflag2=True\nif(flag1 and flag2):\n\tif(L[A[0]]>L[B[0]]):\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelif(flag1):\n\tprint \"YES\"\nelif(flag2):\n\tprint \"NO\"\nelse:\n\tif(A[1]==B[1] and L[A[0]]>L[B[0]]):\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "t = str(input())\ns1, s2 = map(str,input().split())\ntemp = \"6789TJQKA\"\nif s1[1] == s2[1]:\n\tprint(\"YES\" if temp.find(s1[0]) > temp.find(s2[0]) else \"NO\")\nelse:\n\tprint(\"YES\" if s1[1] == t else \"NO\")"}, {"source_code": "t = input()\nf, s = map(str, input().split())\ndict = {\"6\" : 1,\n\"7\" : 2, \n\"8\" : 3, \n\"9\" : 4, \n\"T\" : 5,\n\"J\" : 6, \n\"Q\" : 7, \n\"K\" : 8, \n\"A\" : 9}\nif f[1] == t and s[1] != t:\n print(\"YES\")\nelif f[1] == t and s[1] == t:\n if dict[f[0]] > dict[s[0]]:\n print(\"YES\")\n else:\n print(\"NO\")\nelif f[1] != t and s[1] != t:\n if f[1] == s[1]:\n if dict[f[0]] > dict[s[0]]:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "s=input()\nc=input()\na='6789TJQKA'\nif(c[1]==s and c[1]!=c[len(c)-1]):\n print(\"YES\")\nelse:\n if(c[1]==c[len(c)-1] and a.find(c[0])>a.find(c[len(c)-2])):\n print(\"YES\")\n else:\n print(\"NO\")\n "}, {"source_code": "from sys import stdin\n\nbuf = []\nfor line in stdin:\n buf.append(line.strip())\nbuf.reverse()\n\nc = '6789TJQKA'\ntrump = buf.pop()\nfirst, second = tuple(buf.pop().split())\nif first[1] == trump and second[1] != trump:\n print 'YES'\nelse:\n if first[1] == second[1] and c.find(first[0]) > c.find(second[0]):\n print 'YES'\n else:\n print 'NO'\n\n"}, {"source_code": "trump=input()\na,b=input().split()\nx,y=[],[]\nfor i in range(2):\n x.append(a[i])\n y.append(b[i])\nmap1={\"6\":9, \"7\":8, \"8\":7, \"9\":6, \"T\":5, \"J\":4, \"Q\":3, \"K\":2 ,\"A\":1}\nif x[1]==y[1]:\n if map1[x[0]]<map1[y[0]]:\n print(\"YES\")\n else:print(\"NO\")\nelif x[1]==trump:\n print(\"YES\")\nelse:print(\"NO\") \n "}, {"source_code": "'''input\nC\n7H AS\n'''\n\n\ndef main():\n\n rank = {'6' : 0,\n '7' : 1,\n '8' : 2,\n '9' : 3,\n 'T' : 4,\n 'J' : 5,\n 'Q' : 6,\n 'K' : 7,\n 'A' : 9}\n\n\n trump = input()\n c1, c2 = input().split()\n\n if(c1[1] == trump and c2[1] != trump):\n print(\"YES\")\n elif(c1[1] == c2[1]):\n if(rank[c1[0]] > rank[c2[0]]):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n\n \n\nif __name__ == \"__main__\":\n main()\n\n\n"}, {"source_code": "cards_nominals = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\nSUIT_INDEX = 1\nNOMINAL_INDEX = 0\n\ndef compareCardsNominals(card1, card2):\n if card1 == card2: return 0\n\n if cards_nominals.index(card1) > cards_nominals.index(card2):\n return 1\n return -1\n\ndef isBeaten(trump, striker_card, card):\n beaten = False\n\n if striker_card[SUIT_INDEX] == card[SUIT_INDEX]:\n if compareCardsNominals(striker_card[NOMINAL_INDEX], card[NOMINAL_INDEX]) > 0:\n beaten = True\n elif striker_card[SUIT_INDEX] == trump:\n beaten = True\n\n return beaten\n\nif __name__ == '__main__':\n trump = raw_input()\n cards = raw_input()\n cards_list = cards.partition(' ')\n striker_card = cards_list[0]\n card = cards_list[2]\n\n print 'YES' if isBeaten(trump, striker_card, card) else 'NO'\n"}, {"source_code": "trump = input()\nc1, c2 = input().split()\n\nranks = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\n\nif c1[1] == trump:\n if c1[1] == c2[1]:\n if ranks.index(c1[0]) > ranks.index(c2[0]):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"YES\")\nelif c1[1] == c2[1] and ranks.index(c1[0]) > ranks.index(c2[0]):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "trump = str(input())\ncarda, cardb = [str(x) for x in input().strip().split()]\nwin = 0\ndeck = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\nranka = deck.index(carda[0])\nrankb = deck.index(cardb[0])\nif(carda[1]==cardb[1]):\n\t#same suit\n\tif(ranka > rankb):\n\t\twin=1\n\telif(ranka < rankb):\n\t\twin=2\nelse:\n\tif(carda[1]==trump[0]):\n\t\twin=1\n\telif(cardb[1]==trump[0]):\n\t\twin=2\n\nif(win==1):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n"}, {"source_code": "def val(x):\n if x == '6':\n return 6\n elif x == '7':\n return 7\n elif x == '8':\n return 8\n elif x == '9':\n return 9\n elif x == 'T':\n return 10\n elif x == 'J':\n return 11\n elif x == 'Q':\n return 12\n elif x == 'K':\n return 13\n else:\n return 14\n\nC = raw_input().strip()\nc = C[0]\n\nL = raw_input().strip().split()\ntmp1 = L[0]\ntmp2 = L[1]\n\nif tmp1[1] == tmp2[1] and val(tmp1[0]) > val(tmp2[0]):\n print 'YES'\nelif tmp1[1] != tmp2[1] and tmp1[1] == c:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "#!/usr/bin/env python3\n\ntrump = input().rstrip()\ns1, s2 = input().rstrip().split()\n\norder = {\n '6': 0, '7': 1, '8': 2, '9': 3, 'T': 4,\n 'J': 5, 'Q': 6, 'K': 8, 'A': 9,\n}\n\nif s1[1] == s2[1]:\n win = order[s1[0]] > order[s2[0]]\nelse:\n win = s1[1] == trump\n\nprint('YES' if win else 'NO')\n"}, {"source_code": "######################################################################\n# Write your code here\nimport sys\nfrom math import *\ninput = sys.stdin.readline\n#import resource\n#resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x100000)\n# Write your code here\nRI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]\nrw = lambda : input().strip().split()\nls = lambda : list(input().strip()) # for strings to list of char\nfrom collections import defaultdict as df\nimport heapq \n#heapq.heapify(li) heappush(li,4) heappop(li)\n#import random\n#random.shuffle(list)\ninfinite = float('inf')\n#######################################################################\nl=list(\"6789TJQKA\")\n\nt=input().strip()\ns,p=input().split()\nif(s[1]==t and p[1]!=t):\n print(\"YES\")\nelif(s[1]==p[1]):\n if(l.index(s[0])>l.index(p[0])):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")\n"}, {"source_code": "best = input()\norder = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\nfirst, second = tuple([string for string in input().split()])\nif(first[1] == second[1]):\n\tif(order.index(first[0]) > order.index(second[0])):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tif(first[1] == best):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\n# if(second[1] == best and first[1] != best):\n# \tprint(\"NO\")\n# elif(order.index(first[0]) > order.index(second[0])):\n# \tprint(\"YES\")\n# elif(first[1] == best):\n# \tprint(\"YES\")\n# else:\n# \tprint(\"NO\")"}, {"source_code": "s=input()\na,b=input().split()\nx=\"6789TJQKA\"\nif a[1]==s and b[1]!=s: print(\"YES\")\nelif b[1]==s and a[1]!=s: print(\"NO\")\nelif a[1]!=b[1]: print(\"NO\")\nelif x.index(a[0])>x.index(b[0]): print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "class CodeforcesTask106ASolution:\n def __init__(self):\n self.result = ''\n self.trump = ''\n self.cards = []\n\n def read_input(self):\n self.trump = input()\n self.cards = input().split(\" \")\n\n def process_task(self):\n order = \"6789TJQKA\"\n if self.trump == self.cards[0][1]:\n if self.trump == self.cards[1][1]:\n if order.index(self.cards[0][0]) > order.index(self.cards[1][0]):\n self.result = \"YES\"\n else:\n self.result = \"NO\"\n else:\n self.result = \"YES\"\n else:\n if self.cards[0][1] == self.cards[1][1]:\n if order.index(self.cards[0][0]) > order.index(self.cards[1][0]):\n self.result = \"YES\"\n else:\n self.result = \"NO\"\n else:\n self.result = \"NO\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask106ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "a = input()\nb,c = input().split() \nd = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" , \"A\"]\nif b[1] ==c[1]:\n if d.index(b[0]) > d.index(c[0]):\n print('YES')\n else:\n print('NO')\nelif b[1] == a:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x = str(input())\ny,z = map(str,input().split())\n\narr = {\"6\":1, \"7\":2, \"8\":3, \"9\":4, \"T\":5, \"J\":6, \"Q\":7, \"K\":8, \"A\":9}\n\nif (x==y[1] and y[1]!=z[1]) or (y[1]==z[1] and arr[y[0]]>arr[z[0]]):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import sys\nimport math\nimport itertools\nimport collections\n\ndef getdict(n):\n d = {}\n if type(n) is list or type(n) is str:\n for i in n:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n else:\n for i in range(n):\n t = ii()\n if t in d:\n d[t] += 1\n else:\n d[t] = 1\n return d\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a*b) // math.gcd(a, b)\ndef wr(arr): return ' '.join(map(str, arr))\ndef revn(n): return int(str(n)[::-1])\ndef prime(n):\n if n == 2:\n return True\n if n % 2 == 0 or n <= 1:\n return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0:\n return False\n return True\n\n#arr =['v', '^', '>', '<']\nd = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\nmast = ['S', 'H', 'D', 'C']\nkozir = input()\ncards = list(input().split())\nif cards[0][1] == kozir and cards[1][1] != kozir or cards[0][1] == kozir and cards[1][1] == kozir and \\\n d.index(cards[0][0]) > d.index(cards[1][0]) or cards[0][1] == cards[1][1] and d.index(cards[0][0]) > d.index(cards[1][0]):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=input()\nh=['6','7','8','9','T','J','Q','K','A']\ns=[n for n in input().split()]\np=s[0]\nq=s[1]\nif p[1]==q[1] :\n if h.index(p[0])>h.index(q[0]):\n print('YES')\n else:\n print('NO')\nelse:\n if p[1]==a and q[1]!=a:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a=input()\nb,c=input().split()\ndef rank(x):\n\tz=['6','7','8','9','T','J','Q','K','A']\n\tp=0\n\tfor y in z:\n\t\tp+=1\n\t\tif y==x:\n\t\t\treturn p\n\t\nif(a[0]==b[1]and a[0]!=c[1]):\n\tprint(\"YES\")\nelif(b[1]==c[1]):\n\tif(rank(b[0])>rank(c[0])):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "trump = input()\nword = input()\nidx = word.find(' ')\nc1 = word[:idx]\nc2 = word[(idx+1):]\ns1 = c1[1]\ns2 = c2[1]\nif(c1[0]=='T'):\n\tnum1 = 10\nelif(c1[0]=='J'):\n\tnum1 = 11\nelif(c1[0]=='Q'):\n\tnum1 = 12\nelif(c1[0]=='K'):\n\tnum1 = 13\nelif(c1[0]=='A'):\n\tnum1 = 14\nelse:\n\tnum1 = int(c1[0])\nif(c2[0]=='T'):\n\tnum2 = 10\nelif(c2[0]=='J'):\n\tnum2 = 11\nelif(c2[0]=='Q'):\n\tnum2 = 12\nelif(c2[0]=='K'):\n\tnum2 = 13\nelif(c2[0]=='A'):\n\tnum2 = 14\nelse:\n\tnum2 = int(c2[0])\nif(s1==s2):\n\tif(num1>num2):\n\t\tprint (\"YES\")\n\telse:\n\t\tprint (\"NO\")\nelse:\n\tif(s1==trump):\n\t\tprint (\"YES\")\n\telse:\n\t\tprint (\"NO\")"}, {"source_code": "trump= input()\nfirst, scd = input().split()\nd = {\"6\" : 6, \"7\":7 ,\"8\" :8, \"9\":9, \"T\":10, \"J\":11, \"Q\":12, \"K\":13, \"A\":14}\n\nif trump in first and trump not in scd:\n print('YES')\nelif trump in scd and trump not in first:\n print('NO')\nelif first[1] == scd[1]:\n\n print(['NO','YES'][d[first[0]]>d[scd[0]]])\nelse :\n print('NO')"}, {"source_code": "import sys\n\nrang=['6','7','8','9','T','J','Q','K','A']\n\nt=raw_input().strip()\neen,twee=raw_input().split()\n\nif een[1]==t and twee[1]!=t:\n print 'YES'\nelif een[1]!=t and twee[1]==t:\n print 'NO'\nelif rang.index(een[0])>rang.index(twee[0]) and een[1]==twee[1]:\n print 'YES'\nelse:\n print 'NO'\n\n \n\n "}, {"source_code": "suit = raw_input()\nfirst, second = raw_input().split(' ')\nd = {\n '6' : 6,\n '7' : 7,\n '8' : 8,\n '9' : 9,\n 'T' : 10,\n 'J' : 11,\n 'Q' : 12,\n 'K' : 13,\n 'A' : 14,\n }\nif first[1] == suit and second[1] != suit:\n print 'YES'\nelif first[1] != second[1]:\n print 'NO'\nelse:\n print 'YES' if d[first[0]] > d[second[0]] else 'NO'\n"}, {"source_code": "m = raw_input()\nstr = raw_input()\nk = str.split(' ')\ndd = [6,7,8,9,10,11,12,13,14]\nmm = ['6','7','8','9','T','J','Q','K','A']\nfor t in range(0, len(dd)):\n if k[0][0] == mm[t]:\n k0 = dd[t] \n if k[1][0] == mm[t]:\n k1 = dd[t]\nif k[0][1] == k[1][1]:\n if k0 > k1:\n print \"YES\"\n else:\n print \"NO\"\nelse:\n if k[0][1] == m:\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys\nif __name__ == '__main__':\n\n dict = {'6':6,'7':7,'8':8,'9':9,'T':10,'J':11,'Q':12,'K':13,'A':14}\n num = map(str,sys.stdin.readline().split())\n str1,str2 =map(str,sys.stdin.readline().split())\n\n if str1[1] == num[0]:\n if str2[1] != num[0]:\n print \"YES\"\n else:\n if dict[str1[0]] > dict[str2[0]]:\n print \"YES\"\n else:\n print \"NO\"\n else:\n if str1[1] != str2[1]:\n print \"NO\"\n else:\n if dict[str1[0]] > dict[str2[0]]:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "trump=input()\ns1,s2=input().split()\nl1=['6','7','8','9','T','J','Q','K','A']\nif s1[1]==trump:\n if s2[1]==trump:\n if l1.index(s1[0])>l1.index(s2[0]):\n print(\"YES\")\n else :\n print(\"NO\")\n else :\n print(\"YES\")\nelse :\n if s1[1]!=s2[1]:\n print(\"NO\")\n else :\n if l1.index(s1[0])>l1.index(s2[0]):\n print(\"YES\")\n else :\n print(\"NO\")"}, {"source_code": "s=input()\nl=input().split()\nz='6789TJQKA'\nflag=0\nif l[0][1]!=s and l[0][1]!=l[1][1]:\n\tprint('NO')\n\texit()\nif l[0][1]==s:\n\tif l[1][1]==s:\n\t\tif z.index(l[0][0])>z.index(l[1][0]):\n\t\t\tflag=1\n\telse:\n\t\tflag=1\nelse:\n\tif l[1][1]!=s:\n\t\tif z.index(l[0][0])>z.index(l[1][0]):\n\t\t\tflag=1\nif flag==1:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "t=input()\na,b=input().split()\nc='6789TJQKA'\nif a[1]==b[1]:\n if c.find(a[0])>c.find(b[0]):\n print('YES')\n else:\n print('NO')\nelif a[1]==t and b[1]!=t:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "tc = input()\ncard1, card2 = input().split()\ncard1suit = card1[1]\ncard2suit = card2[1]\ncard1val = card1[0]\ncard2val = card2[0]\n\nif card1suit == tc and card2suit != tc:\n print('YES')\n exit()\ndef rank_val(s):\n if s == '6' or s == '7' or s == '8' or s == '9':\n return int(s)\n elif s == 'T':\n return 10\n elif s == 'J':\n return 11\n elif s == 'Q':\n return 12\n elif s == 'K':\n return 13\n elif s == 'A':\n return 14\n\nif card1suit == card2suit:\n if rank_val(card1val) > rank_val(card2val):\n print('YES')\n exit()\n else:\n print('NO')\n exit()\nprint('NO')\n"}, {"source_code": "rank=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\ntrump=raw_input(\"\")\nl=raw_input(\"\").split(\" \")\nfirst=l[0]\nsecond=l[1]\nif first[1]==trump or (first[1]==second[1] and rank.index(first[0])>rank.index(second[0])):\n if second[1]==trump and rank.index(first[0])<rank.index(second[0]):\n print \"NO\"\n else: \n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "import sys\nsuits = ['S','H','D','C']\ncard_order = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K','A']\n\ntrump = raw_input()\ncards = raw_input().split()\nfirst = cards[0]\nsecond = cards[1]\n\nfirst_card_idx = card_order.index(first[0])\nsecond_card_idx = card_order.index(second[0])\nfirst_suit = first[1]\nsecond_suit = second[1]\n\nif (first_suit == trump) and (second_suit != trump):\n print \"YES\"\nelif (first_suit == second_suit) and (first_card_idx > second_card_idx):\n print \"YES\"\nelse:\n print \"NO\" \n"}, {"source_code": "s=input('')\ns1=input('')\na,b=s1.split(' ')\nl=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\n# print(l.index(a[0])>l.index(b[0]))\nif((a[1]==b[1] and l.index(a[0])>l.index(b[0])) or (a[1]==s and b[1]!=s)):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "ranks = dict()\nranks['6'] = 0\nranks['7'] = 1\nranks['8'] = 2\nranks['9'] = 3\nranks['T'] = 4\nranks['J'] = 5\nranks['Q'] = 6\nranks['K'] = 7\nranks['A'] = 8\n\ntramp = raw_input()\ncards = raw_input().split()\nfirst = cards[0]\nsecond = cards[1]\n\nif first[1] == second[1]:\n if ranks[first[0]] > ranks[second[0]]:\n print 'YES'\n else:\n print 'NO'\nelif first[1] == tramp:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "suit = ['S', 'H', 'D', 'C']\nrank = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\n\ntrump = str(raw_input())\ncards = str(raw_input())\n\nwin = False\n\nif cards[1] == cards[4] and rank.index(cards[0]) > rank.index(cards[3]):\n win = True\n \nif cards[1] == trump and cards[4] != trump:\n win = True\n \nif win:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "R=raw_input\nS=\"6789TJQKA\"\nt=R()\nl=R().split()\nif l[0][1]==l[1][1]:\n\tok=S.find(l[0][0])>=S.find(l[1][0])\nelse:\n\tok=l[0][1]==t\nprint [\"NO\",\"YES\"][ok]\n"}, {"source_code": "s = '6789TJQKA'\nt = raw_input()\na, b = raw_input().split()\nprint ['NO', 'YES'][(a[1] == t and b[1] != t) or (a[1] == b[1] and s.find(a[0]) > s.find(b[0]))]"}, {"source_code": "a=raw_input()\nb,c=raw_input().split()\nl={'6':1,'7':2,'8':3,'9':4,'T':5,'J':6,'Q':7,'K':8,'A':9}\nif b[1]==a and c[1]!=a:\n print 'YES'\nelif b[1]==c[1] and l[b[0]]>=l[c[0]]:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "l=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\ns=input()\na,b=map(str,input().split())\nif(a[1]==s and b[1]!=s):\n print(\"YES\")\nelif(a[1]==b[1]):\n if(l.index(a[0])>l.index(b[0])):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\nM = ['S','H','D','C']\nV = ['6','7','8','9','T','J','Q','K','A']\n\ndef solve(km,c1,c2):\n v = lambda c: V.index(c[0])\n m = lambda c: M.index(c[1])\n m1 = m(c1)\n m2 = m(c2)\n v1 = v(c1)\n v2 = v(c2)\n if m1 == m2:\n if v1 > v2:\n return 'YES'\n else:\n if m1 == M.index(km):\n return 'YES'\n return 'NO'\n\nkm = input.readline().strip()\nC = input.readline().strip().split(' ')\nc1 = C[0]\nc2 = C[1]\n\na = solve(km,c1,c2)\noutput.write('%s\\n' % a)\n"}, {"source_code": "RANKS = \"6789TJQKA\"\ndef is_first_winner(tramp, first, second):\n\tif first[1] == second[1]:\n\t\tif RANKS.find(first[0]) > RANKS.find(second[0]):\n\t\t\treturn \"YES\"\n\t\telse:\n\t\t\treturn \"NO\"\n\tif first[1] == tramp:\n\t\treturn \"YES\"\n\treturn \"NO\"\n\ntramp = raw_input()\nfirst, second = raw_input().split()\nprint is_first_winner(tramp, first, second)"}, {"source_code": "t = '6789TJQKA'\ns=input()\nx=input()\nprint(['NO','YES'][x[1]==s and x[4]!=s or x[1]==x[4]and t.find(x[0])>t.find(x[3])])"}, {"source_code": "li=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\ntrump = input()\nf,s = input().split()\nif((f[1]==s[1] and li.index(f[0])>li.index(s[0])) or (f[1]==trump and f[1]!=s[1])):\n\tprint(\"YES\")\t\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "import atexit, io, sys\nbuffer = io.BytesIO()\nsys.stdout = buffer\n\n@atexit.register\ndef write():\n\tsys.__stdout__.write(buffer.getvalue())\n\n\ndef rank(c):\n\treturn [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\",\"A\"].index(c)\n\ntrump=raw_input()\ncards=[ [c for c in card ] for card in raw_input().split(' ') ]\n\n#print cards\nans=0\nif cards[0][1]==cards[1][1]:\n\tif rank( cards[0][0] )> rank(cards[1][0]):\n\t\tans+=1\nelse:\n\tif cards[0][1]==trump:\n\t\tans+=1\n\nif ans:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "s1 = raw_input()\ns2 = raw_input().split()\nd={}\nfor i in xrange(6, 10):\n d[str(i)]=i\nd[\"T\"]=10\nd[\"J\"]=11\nd[\"Q\"]=12\nd[\"K\"]=13\nd[\"A\"]=14\nif (s2[0][1]==s2[1][1]):\n if d[s2[0][0]]>d[s2[1][0]]:\n print(\"YES\")\n else:\n print(\"NO\")\nelif (s2[0][1]==s1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "t = '6789TJQKA'\n\ns=input()\n\nx=input()\n\nprint(['NO','YES'][x[1]==s and x[4]!=s or x[1]==x[4]and t.find(x[0])>t.find(x[3])])\n\n"}, {"source_code": "l=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\ns=input()\na,b=map(str,input().split())\nif(a[1]==s and b[1]!=s):\n print(\"YES\")\nelif(a[1]==b[1]):\n if(l.index(a[0])>l.index(b[0])):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "\nk = raw_input()\nd = ('6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')\na, b = raw_input().split()\nif (a[1] == k and b[1] != k) or (a[1] == b[1] and d.index(a[0]) > d.index(b[0])):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "trump = raw_input()\na, b =raw_input().split(\" \")\nd = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\",\"A\"]\n\nif a[1]==b[1]:\n if d.index(a[0])>d.index(b[0]):\n print \"YES\"\n else:\n print \"NO\"\nelif a[1] == trump:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "trump = raw_input()\na,b= raw_input().split()\ncards = '6789TJQKA'\nif trump==a[1]==b[1]:\n if cards.index(a[0])>cards.index(b[0]):\n print 'YES'\n else:\n print 'NO'\nelif trump==a[1]:\n print 'YES'\nelif trump==b[1]:\n print 'NO'\nelse:\n if a[1]==b[1] and cards.index(a[0])>cards.index(b[0]):\n print 'YES'\n else:\n print 'NO'"}, {"source_code": "v='6789TJQKA'\nr=input;t=r();a,b=r().split()\na=(v.index(a[0]),a[1])\nb=(v.index(b[0]),b[1])\nprint(\"YNEOS\"[not((a[1]==b[1] and a[0]>b[0]) or (a[1]==t and b[1]!=t))::2])\n"}, {"source_code": "mast = raw_input()\ncard1, card2 = (raw_input().split())\nif (card1[1] != card2[1]) and (card1[1] == mast):\n print 'YES'\nelif (card1[1] != card2[1]) and (card1[1] != mast):\n print 'NO'\nelse:\n a = []\n a.append('6')\n a.append('7')\n a.append('8')\n a.append('9')\n a.append('T')\n a.append('J')\n a.append('Q')\n a.append('K')\n a.append('A')\n ind1 = a.index(card1[0],0,len(a))\n ind2 = a.index(card2[0],0,len(a))\n if ind1 > ind2:\n print 'YES'\n else:\n print 'NO'"}, {"source_code": "from functools import reduce\nfrom operator import *\nfrom math import *\nfrom sys import *\nfrom string import *\nsetrecursionlimit(10**7)\ndX= [ 0, 0, 1,-1, 1,-1, 1,-1]\ndY= [ 1,-1, 0, 0, 1,-1,-1, 1]\nRI=lambda: list(map(int,input().split()))\nRS=lambda: input().rstrip().split()\n#################################################\ns1=RS()[0]\ns2,s3=RS()\ns=\"6789TJQKA\"\nrank={s[i]:i for i in range(len(s))}\nif (s2[1]==s3[1] and rank[s2[0]]>rank[s3[0]]) or (s2[1]==s1 and s3[1]!=s1):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nk = input()\na, b = input().split()\nm = {'6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}\nif m[a[0]] > m[b[0]] and a[1] == b[1] or a[1] != b[1] and a[1] == k:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "rank = {'6':1, '7':2, '8':3, '9':4, 'T':5, 'J':6, 'Q':7, 'K':8, 'A':9}\ntru = raw_input()\ntemp = raw_input()\nc1, c2 = temp.split()\nflag = 0\nif c1[1] == c2[1]:\n\tif rank[c1[0]] > rank[c2[0]]:\n\t\tflag = 1\nelif c1[1] == tru and c2[1] != tru:\n\tflag = 1\nif flag:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "tc = input()\nstr1 = input().split()\nfirst = str1[0]\nsecond = str1[1]\norder = ['6','7','8','9','T','J','Q','K','A']\nif(first[1] == tc and second[1] != tc):\n print('YES')\nelif first[1] != tc and second[1] == tc:\n print('NO')\nelif first[1] == second[1]:\n if order.index(first[0]) > order.index(second[0]):\n print ('YES')\n else:\n print ('NO')\nelse:\n print ('NO')"}, {"source_code": "##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\nimport sys\ninput = sys.stdin.readline\nscan_int = lambda: int(input())\nscan_string = lambda: input().rstrip()\nread_list = lambda: list(read())\nread = lambda: map(int, input().split())\nread_float = lambda: map(float, input().split())\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // math.gcd(a, b)\n\ndef is_integer(n):\n\treturn math.ceil(n) == math.floor(n)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\n\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n# Euler's Toitent Function phi\ndef phi(n) : \n \n result = n \n p = 2\n while(p * p<= n) : \n if (n % p == 0) : \n while (n % p == 0) : \n n = n // p \n result = result * (1.0 - (1.0 / (float) (p))) \n p = p + 1\n if (n > 1) : \n result = result * (1.0 - (1.0 / (float)(n))) \n \n return (int)(result) \n\ndef is_prime(n):\n\tif n == 0:\n\t\treturn False\n\tif n == 1:\n\t\treturn True\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif not n % i:\n\t\t\treturn False\n \n\treturn True\n\ndef next_prime(n, primes):\n\twhile primes[n] != True:\n\t\tn += 1\n\treturn n\n\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\ndef factors(n):\n\tres = []\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i == 0:\n\t\t\tres.append(i)\n\t\t\tres.append(n // i)\n\treturn list(set(res))\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n\ndef binary_search(low, high, w, h, n):\n\twhile low < high:\n\t\tmid = low + (high - low) // 2\n\t\t# print(low, mid, high)\n\t\tif check(mid, w, h, n):\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid\n\treturn low\n\n## for checking any conditions\ndef check(beauty, s, n, count):\n\tpass\n\t\n\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\nalphs = \"abcdefghijklmnopqrstuvwxyz\".upper()\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\nimport bisect as bis\nimport random\nimport sys\nimport collections as collect\n\ndef solve():\n\ttramp = scan_string()\n\tcard1, card2 = input().split()\n\td = {\"6\": 1, \"7\": 2, \"8\": 3, \"9\": 4, \"T\": 5, \"J\": 6, \"Q\": 7, \"K\": 8, \"A\": 9}\n\tif card1[1] == tramp:\n\t\tif card2[1] != tramp:\n\t\t\tprint(\"YES\")\n\t\t\treturn\n\t\telse:\n\t\t\tif d[card1[0]] > d[card2[0]]:\n\t\t\t\tprint(\"YES\")\n\t\t\t\treturn\n\t\t\telse:\n\t\t\t\tprint(\"NO\")\n\t\t\t\treturn\n\telif card1[1] == card2[1]:\n\t\tif d[card1[0]] > d[card2[0]]:\n\t\t\tprint(\"YES\")\n\t\t\treturn\n\t\telse:\n\t\t\tprint(\"NO\")\n\t\t\treturn\n\telse:\n\t\tprint(\"NO\")\n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n for i in range(1):\n \tsolve()\n #dmain()\n \n# Comment Read()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "\n\nbig = {\n 'T': 10,\n 'J': 11,\n 'Q': 12,\n 'K': 13,\n 'A': 14\n}\n\ntr = input()\n\nfirst, second = input().split()\n\nif first[0] in big:\n fv = big[first[0]]\nelse:\n fv = int(first[0])\n\nif second[0] in big:\n sv = big[second[0]]\nelse:\n sv = int(second[0])\n\nif (first[1] == tr and second[1] != tr) or (fv > sv and first[1] == second[1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\ndef read_values():\n return map(int,raw_input().split())\n\n\n\nr = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\n\nt = raw_input()\nc = raw_input().split()\nres = 'NO'\nif c[0][1]==c[1][1]:\n if r.index(c[0][0])>r.index(c[1][0]):\n res='YES'\nelse:\n if t==c[0][1]:\n res='YES'\nprint res\n"}, {"source_code": "z = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\n\ntrmp = raw_input()\na, b = raw_input().split()\n\nif a[1] != b[1]:\n\tif a[1] == trmp:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'\nelse:\n\tx, y = -1, -1\n\tfor i in range(len(z)):\n\t\tif z[i] == a[0]:\n\t\t\tx = i\n\t\tif z[i] == b[0]:\n\t\t\ty = i\n\tif x > y:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n\t\n"}, {"source_code": "v='6789TJQKA'\nt=input()[0]\na,b=input().split()\nprint('NYOE S'[a[1]==t!=b[1] or a[1]==b[1]and v.index(a[0])>v.index(b[0])::2])\n"}], "negative_code": [{"source_code": "\n\n\n\na = input()\n\n\n\nb = input().split()\n\nif 48<=ord(b[-1][0])<=57 and 48<=ord(b[0][0])<=57:\n\n\n if int(b[-1][0])> int((b[0][0])):\n if b[0][0]!=a:\n print('NO')\n else:\n print('YES')\n else:\n print('YES')\nelse:\n\n s=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" ,\"A\"]\n if b[0][0]==a:\n if b[-1][0]==a:\n if s.index(b[0][0]) >= s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n else:\n print('YES')\n else:\n if b[-1][0]==a:\n print('NO')\n else:\n if s.index(b[0][0]) >= s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n\n \n"}, {"source_code": "prioritylist ={\n\n '6': 1,\n \"7\":2,\n '8':3,\n '9':4,\n 'T':5,\n 'J':6,\n 'Q':7,\n 'K':8,\n 'A':9,\n}\n\ntrump = input()\n\nfir,sec = map(str,input().split())\n\nif trump == fir[1]:\n print('YES')\n\nelif sec[1]!=fir[1]:\n print('NO')\n\nelif sec[1]==fir[1] and prioritylist[fir[0]] > prioritylist[sec[0]]:\n print('YES')\n\nelse:\n print('NO')\n"}, {"source_code": "a=raw_input()\nb,c=raw_input().split()\nl={'6':1,'7':2,'8':3,'9':4,'T':5,'J':6,'Q':7,'K':8}\nif b[1]==c[1] and l[b[0]]>=l[c[0]]:\n print 'YES'\nelif b[1]==a and l[b[0]]>=l[c[0]]:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "rank = {\"6\":1, \"7\":2, \"8\":3, \"9\":4, \"T\":5, \"J\":6, \"Q\":7, \"K\":8,\"A\":9}\ntrump = raw_input()\nfirst,second = map(str,raw_input().split())\nif trump == first[1] and trump != second[1]:\n print \"YES\"\nelif first[1] == second[1]:\n if rank[first[0]] > rank[second[0]]:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def great():\n\ta.split()\n\tb.split()\n\tif s.index(a[0]) > s.index(b[0]):\n\t\t\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\nt=input()\na,b=map(str,input().split())\ns='6789TJQKA'\nif(t in a):\n\tif t in b:\n\t\tgreat()\n\telse:\n\t\tprint(\"YES\")\nelif(t in b):\n\tprint(\"NO\")\nelse:\n\tprint(\"NO\")\n\t\n"}, {"source_code": "####################################################\n# -*- coding: utf-8 -*-\nimport sys\n\nw = sys.stdout.write\nread = sys.stdin.readline\nreads = sys.stdin.read\n\ndef r(f=None):\n if f:\n return map(f, read().split())\n else:\n return read().split()\n\ndef rs(t,f=None):\n result = []\n result_append = result.append\n for i in xrange(t):\n if f:\n result_append(tuple(map(f, read().split())))\n else:\n result_append(read().replace('\\n', ''))\n return result\n\n\n####################################################\nimport math\nsqrt = math.sqrt\n#from collections import deque\n\ns = read().replace('\\n', '')\na, b = read().split()\na = list(a)\nb = list(b)\nrep = {\"T\": 10, \"J\": 11, \"Q\": 12, \"K\": 13, \"A\": 14}\nif a[0] in \"TJQKA\":\n a[0] = rep[a[0]]\nif b[0] in \"TJQKA\":\n b[0] = rep[b[0]]\na[0] = int(a[0])\nb[0] = int(b[0])\n\nif (a[0] > b[0] and a[1] == b[1]) or (b[1] != s and b[1] != a[1]):\n w(\"YES\")\nelse:\n w(\"NO\")"}, {"source_code": "v='6789TJQKA'\nr=input;t=r();a,b=r().split()\na=(v.index(a[0]),a[1])\nb=(v.index(b[0]),b[1])\nprint(\"YNEOS\"[(b[1]==t and ((a[1]==t and b[1]>a[1]) or b[1]>a[1])) or (a[1]!=t and b[1]>a[1])::2])\n"}, {"source_code": "n=input()\ny=input().split()\nm=['6','7','8','9','T','J','Q' 'K','A']\nfor i in range(len(m)):\n if y[0][0]==m[i]:\n y[0][0]==i\n if y[1][0]==m[i]:\n y[1][0]==i \nif y[0][1]==y[1][1] and y[0][0]>y[1][0] :\n print('YES')\nelif y[0][1]!=y[1][1] and y[0][1]==n:\n print('YES')\nelse:\n print('NO') \n"}, {"source_code": "order=\"6789TJQKA\"\nsuit=raw_input()\ncard=raw_input()\n[a,b]=card.split()\nif (a[1]==suit)&(b[1]!=suit):\n print \"YES\"\nelif (a[1]!=suit) &(b[1]==suit):\n print \"NO\"\nelif order.index(a[0])>order.index(b[0]):\n print \"YES\"\n#print suit,card\n"}, {"source_code": "suit = ['S', 'H', 'D', 'C']\nrank = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\n\ntrump = str(raw_input())\ncards = str(raw_input())\n\nwin = False\n\nif cards[1] == cards[4] and rank.index(cards[0]) > rank.index(cards[3]):\n win = True\n \nif cards[1] == trump and cards[3] != trump:\n win = True\n \nif win:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "tr = input()\nt1,t2 = map(str,input().split())\ng = ['A','K','Q','J','T']\nif tr in t1 and tr not in t2:\n print('YES')\nelif tr not in t1 and tr in t2:\n print('NO')\nelse:\n s1 = t1[0]\n s2 = t2[0]\n if s1 in g and s2 in g:\n l1 = g.index(s1)\n l2 = g.index(s2)\n if s1>s2:\n print('NO')\n else:\n print('YES')\n elif s1 in g:\n print('YES')\n elif s2 in g:\n print('NO')\n else:\n s1,s2 = int(s1),int(s2)\n if s1>s2:\n print('YES')\n else:\n print('NO')"}, {"source_code": "t = raw_input()\nl,r = list(raw_input().split())\nrank = '6789TJQKA'\nif l[1] == t and r[1] != t:\n print \"YES\"\nelif l[1] != t and r[1] == t:\n print \"NO\"\nelif rank.index(l[0]) > rank.index(r[0]):\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n\nif a[1]==trump and b[1]==trump:\n if ranks.index(a[0])> ranks.index(b[0]):\n print('YES')\n exit()\n else:\n print('NO')\n exit()\n exit()\n\nif b[1]==trump:\n print('NO')\n exit()\n \nif ranks.index(a[0])> ranks.index(b[0]) or a[1]==trump and b[1]!=trump:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "trump = raw_input(\"\")\nc = raw_input(\"\").split()\n\nfor i in range (0,2) :\n\tc[i].replace(\"T\",\"A\");\n\tc[i].replace(\"J\",\"B\");\n\tc[i].replace(\"Q\",\"C\");\n\tc[i].replace(\"K\",\"D\");\n\tc[i].replace(\"A\",\"E\");\n\nif c[0][1] == c[1][1]:\n\tif c[0][0] > c[1][0]:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelif c[0][1] == trump[0]:\n\tprint \"YES\" \nelif c[1][1] == trump[0]:\n\tprint \"NO\"\nelse:\n\tprint \"NO\"\n\t\n"}, {"source_code": "suit = ['S', 'H', 'D', 'C']\nrank = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\n\ntrump = str(raw_input())\ncards = str(raw_input())\n\nwin = False\n\nif cards[1] == cards[4] and rank.index(cards[0]) > rank.index(cards[3]):\n win = True\n \nif cards[1] == trump:\n win = True\n \nif win:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "ranks = dict()\nranks['6'] = 0\nranks['7'] = 1\nranks['8'] = 2\nranks['9'] = 3\nranks['T'] = 4\nranks['J'] = 5\nranks['Q'] = 6\nranks['K'] = 7\nranks['A'] = 8\n\ntramp = raw_input()\ncards = raw_input().split()\nfirst = cards[0]\nsecond = cards[1]\n\nif first[1] == tramp:\n print 'YES'\nelif second[1] == tramp:\n print 'NO'\nelif first[1] == second[1]:\n if ranks[first[0]] > ranks[second[0]]:\n print 'YES'\n else:\n print 'NO'\nelse:\n print 'NO'"}, {"source_code": "\n\nt=input()\nl=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\na,b=input().split()\nif(l.index(a[0])>l.index(b[0])):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "tramp = raw_input()\na, b = raw_input().split()\ns = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\nif a[1] ==tramp and b[1] != tramp:\n print 'YES'\nelse:\n print 'YES' if s.index(a[0]) > s.index(b[0]) else 'NO'\n"}, {"source_code": "l=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\ns=input()\na,b = input().split()\nif a[1] is b[1] and a[1] is s:\n if l.index(a[0]) > l.index(b[0]):\n print(\"YES\")\n else: print(\"NO\")\n\nelif a[1] is b[1] and a[1] is not s:\n if l.index(a[0]) > l.index(b[0]):\n print(\"YES\")\n else: print(\"NO\")\n\nelif a[1] is not b[1] and a[1] is not s:\n if b[1] is s:\n print(\"NO\")\n else: \n if l.index(a[0]) > l.index(b[0]):\n print(\"YES\")\n else: print(\"NO\")\n\nelif a[1] is not b[1] and a[1] is s:\n print(\"YES\") \n\nelse: print(\"NO\")\n"}, {"source_code": "coz = raw_input()\nf,s = raw_input().split()\n\nd = {'6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14}\n\nif f[1] == coz and s[1] != coz:\n print(\"YES\")\nelif f[1] != coz and s[1] == coz:\n print(\"NO\")\nelif f[1] == s[1] and [f[0]] > d[s[0]]:\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "a=input()\nf,s=input().split()\nf.replace(\"A\",\"14\")\nf.replace(\"K\",\"13\")\nf.replace(\"Q\",\"12\")\nf.replace(\"J\",\"11\")\nf.replace(\"T\",\"10\")\ns.replace(\"A\",\"14\")\ns.replace(\"K\",\"13\")\ns.replace(\"Q\",\"12\")\ns.replace(\"J\",\"11\")\ns.replace(\"T\",\"10\")\n\nif a==f[1]:\n print(\"YES\")\nelse:\n if f[1]!=s[1]:\n print(\"NO\")\n else:\n if int(f[0])>int(s[0]):\n print(\"YES\")\n else:\n print(\"NO\")\n \n"}, {"source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n\nif a[1]==trump and b[1]==trump:\n if ranks.index(a[0])> ranks.index(b[0]):\n print('YES')\n exit()\n else:\n print('NO')\n exit()\n exit()\n\nif b[1]==trump:\n print('NO')\n exit()\n \nif ranks.index(a[0])> ranks.index(b[0]) or a[1]==trump and b[1]!=trump:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "seq = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" , \"A\"]\nrank =[\"S\", \"H\", \"D\" , \"C\"]\ntrump = str(input())\nfirst , second = map(str , input().split())\nfr = first[0]\nfs = first[1]\nsr = second[0]\nss = second[1]\nif fs==trump:\n if ss==trump:\n if seq.index(fr)>seq.index(sr):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"YES\")\nelif ss==trump:\n print(\"NO\")\nelse:\n if fs==ss:\n if seq.index(fr)>seq.index(sr):\n print(\"YES\")\n else:\n print(\"NO\")\n elif rank.index(fs)<rank.index(ss):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "\n\nt=input()\ntrp=[\"S\",\"H\",\"D\",\"C\"]\n\nl=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\na,b=input().split()\nif(a[1]==t and b[1]==t):\n if(l.index(a[0])>l.index(b[0])):\n print(\"YES\")\n else:\n print(\"NO\")\nelif(a[1]==t):\n print(\"YES\")\nelif(b[1]==t):\n print(\"NO\")\nelse:\n if(l.index(a[0])>l.index(b[0])):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "Trump=raw_input()\nCards= raw_input()\nl = list(Cards)\nl.append(Trump)\nl = [w.replace('T', '10') for w in l]\nl = [w.replace('J', '11') for w in l]\nl = [w.replace('Q', '12') for w in l]\nl = [w.replace('K', '13') for w in l]\nl = [w.replace('A', '14') for w in l]\nl = [w.replace('S', '4') for w in l]\nl = [w.replace('H', '3') for w in l]\nl = [w.replace('D', '2') for w in l]\nl = [w.replace('C', '1') for w in l]\n\nif (l[1]==l[5] and l[4]!=l[5]):\n print 'YES'\nelif (l[1]!=l[5] and l[4]==l[5]):\n print 'NO'\nelif (int(l[1])>int(l[4])):\n print 'YES'\nelif (int(l[1])<int(l[4])):\n print 'NO'\nelif (l[1]==l[4] and int(l[0])>int(l[3])):\n print 'YES'\nelif (l[1]==l[4] and int(l[0])<int(l[3])):\n print 'NO'"}, {"source_code": "z = [6, 7, 8, 9, \"T\", \"J\", \"Q\", \"K\", \"A\"]\n\ntrmp = raw_input()\na, b = raw_input().split()\n\nif a[1] != b[1]:\n\tif a[1] == trmp:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'\nelse:\n\tx, y = -1, -1\n\tfor i in range(len(z)):\n\t\tif z[i] == a[0]:\n\t\t\tx = i\n\t\tif z[i] == b[0]:\n\t\t\ty = i\n\tif x > y:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n\t\n"}, {"source_code": "atu=[]\ncarti=[]\ncarte1=[]\ncarte2=[]\natu=raw_input()\ncarti=raw_input()\nok=0\nfor i in carti:\n\tif i==' ':\n\t\tok=1\n\t\tcontinue\n\tif ok==0:\n\t\tcarte1.append(i)\n\telse:\n\t\tcarte2.append(i)\n\nmsg=0\nindex={'6':0, '7':1, '8':2, '9':3, 'T':4, 'J':5, 'Q':6, 'K':7, 'A':8}\nif carte1[1]==atu[0]:\n\tif carte2[1]==atu[0]:\n\t\tif index[carte1[0]]<index[carte2[0]]:\n\t\t\tmsg=0\n\t\telse:\n\t\t\tmsg=1\n\telse:\n\t\tmsg=1\nelse:\t\t\n\tif carte2[0]==atu[0]:\n\t\tmsg=0\n\telse:\n\t\tif index[carte1[0]]<index[carte2[0]]:\n\t\t\tmsg=0\n\t\telse:\n\t\t\tmsg=1\n\t\t\t\t\nif msg==0:\n\tmsg='NO' \nelse:\n\tmsg='YES'"}, {"source_code": "RANKS = \"6789TJQKA\"\ndef card_strength(tramp, card):\n\tstrength = RANKS.find(card[0])\n\tif tramp == card[1]:\n\t\tstrength += 100\n\treturn strength\n\ntramp = raw_input()\nfirst, second = raw_input().split()\nif card_strength(tramp, first) > card_strength(tramp,second):\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "t = raw_input()\nf, s = raw_input().split()\nr = '6789TJQKA'\nprint ['NO', 'YES'][(f[1] == t) > (s[1] == t) or ((f[1] == t) == (s[1] == t) and r.find(f[0]) > r.find(s[0]))]"}, {"source_code": "\n\n\nn=raw_input()\np =raw_input()\nans=\"YES\"\nrank=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\",\"A\"]\n\n\n\nif p[4]==n:\n\tans = \"NO\"\nelse:\n\tif (rank.index(p[0])<rank.index(p[3])):\n\t\tans = \"NO\"\nprint ans\n\n\n"}, {"source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n \nif ranks.index(a[0])> ranks.index(b[0]) or a[1]==trump and b[1]!=trump:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "coz = raw_input()\nf,s = raw_input().split()\n\nd = {'6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14}\n\nif f[1] == coz and s[1] != coz:\n print(\"YES\")\nelif f[1] != coz and s[1] == coz:\n print(\"NO\")\nelif f[1] == s[1] and [f[0]] > d[s[0]]:\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nn=raw_input()\nf,s=map(str, raw_input().split())\n#\u7d75\u67c4\u4fdd\u5b58\nf1,s1=f[1],s[1]\nif f[0]=='T': f2=10\nelif f[0]=='J': f2=11\nelif f[0]=='Q': f2=12\nelif f[0]=='K': f2=13\nelif f[0]=='A': f2=14\nelse: f2=int(f[0])\n\nif s[1]==('6' or '7' or '8' or '9'):\n s2=int(s[0])\nif s[0]=='T': s2=10\nelif s[0]=='J': s2=11\nelif s[0]=='Q': s2=12\nelif s[0]=='K': s2=13\nelif s[0]=='A': s2=14\nelse: s2=int(s[0])\n\nif n==f1:\n print 'YES'\nelif f1==s1 and f2>s2:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "import sys\n\ndef solve():\n trump = sys.stdin.readline().strip()\n f, s = sys.stdin.readline().split()\n res = 0\n ranks = \"6789TJQKA\"\n if f[1] == trump and s[1] == trump:\n if ranks.find(f[0]) > ranks.find(s[0]):\n res = 1\n else:\n res = 0\n elif f[1] == trump and s[1] != trump:\n res = 1\n elif f[1] != trump and s[1] == trump:\n res = 0\n else:\n res = 0\n print \"YES\" if res else \"NO\"\n\nsolve()\n"}, {"source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n \nif ranks.index(a[0])> ranks.index(b[0]) or a[0]==trump:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def great():\n\ta.split()\n\tb.split()\n\tif s.index(a[0]) > s.index(b[0]):\n\t\t\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\nt=input()\na,b=map(str,input().split())\ns='6789TJQKA'\nif(t in a):\n\tif t in b:\n\t\tgreat()\n\telse:\n\t\tprint(\"YES\")\nelif(t in b):\n\tprint(\"NO\")\nelse:\n\tprint(\"NO\")\n\t\n"}, {"source_code": "#!/usr/bin/python\n#(c) Andreev Alexander (aka Carzil) 2011\nm = str(raw_input())\nk1, k2 = raw_input().split()\ncarts = {\"6\": 1,\n \"7\": 2,\n \"8\": 3,\n \"9\": 4,\n \"T\": 5,\n \"J\": 6,\n \"Q\": 7,\n \"K\": 8,\n \"A\": 9}\nif k1[1] == m:\n if k2[1] == m:\n print \"NO\" \n else:\n print \"YES\" \nelif k1[1] == k2[1]:\n if carts[k1[0]] > carts[k2[0]]:\n print \"YES\" \n else:\n print \"NO\" \nelse:\n print \"NO\" "}, {"source_code": "trump=str(input())\na,b=map(str,input().split())\nd={\"6\":6, \"7\":7, \"8\":8, \"9\":9, \"T\":10, \"J\":11, \"Q\":12, \"K\":13,\"A\":14}\nif list(a)[1]==trump:\n print(\"YES\")\nelse:\n if list(a)[1]!=list(b)[1]:\n print(\"NO\")\n else:\n if d[list(a)[0]]>d[list(b)[0]]:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "a=input()\nd=input()\nb=[]\nfor i in range(len(d)):\n b.append(d[i])\nif b[0]==\"A\": b[0]=\"14\"\nif b[3]==\"A\": b[3]=\"14\"\nif b[0]==\"K\": b[0]=\"13\"\nif b[3]==\"K\": b[3]=\"13\"\nif b[0]==\"Q\": b[0]=\"12\"\nif b[3]==\"Q\": b[3]=\"12\"\nif b[0]==\"J\": b[0]=\"11\"\nif b[3]==\"J\": b[3]=\"11\"\nif b[0]==\"T\": b[0]=\"10\"\nif b[3]==\"T\": b[3]=\"10\"\n\nif b[1]==a and b[4]!=a:\n print(\"YES\")\nelif b[1]==b[4] and b[0]>b[3]:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "trump = raw_input(\"\")\nc = raw_input(\"\").split()\n\nfor i in range (0,2) :\n\tc[i]=c[i].replace(\"T\",\"B\");\n\tc[i]=c[i].replace(\"J\",\"C\");\n\tc[i]=c[i].replace(\"Q\",\"D\");\n\tc[i]=c[i].replace(\"K\",\"E\");\n\tc[i]=c[i].replace(\"A\",\"F\");\n\t\nprint c[0],c[1]\n\nif c[0][1] == c[1][1]:\n\tif c[0][0] > c[1][0]:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\nelif c[0][1] == trump[0]:\n\tprint \"YES\" \nelif c[1][1] == trump[0]:\n\tprint \"NO\"\nelse:\n\tprint \"NO\"\n\t\n"}, {"source_code": "suit = raw_input()\nfirst, second = raw_input().split(' ')\nd = {\n '6' : 6,\n '7' : 7,\n '8' : 8,\n '9' : 9,\n 'T' : 10,\n 'J' : 11,\n 'Q' : 12,\n 'K' : 13,\n 'A' : 14,\n }\nif second[1] == 'H' or (first[1] != 'H' and d[second[0]] > d[first[0]]):\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n\nif a[1]==trump and b[1]==trump:\n if ranks.index(a[0])> ranks.index(b[0]):\n print('YES')\n exit()\n else:\n print('NO')\n exit()\n exit()\n\nif b[1]==trump:\n print('NO')\n exit()\n \nif ranks.index(a[0])> ranks.index(b[0]) or a[1]==trump and b[1]!=trump:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "s=input()\na,b=map(str,input().split())\nrank = ['6','7','8','9','T','J','Q','K','A']\n\nif (a[1]==s and b[1]==s) or (a[1]!=s and b[1]!=s):\n if rank.index(a[0])<rank.index(b[0]):\n print('NO')\n #print('1')\n elif rank.index(a[0])>rank.index(b[0]):\n print('YES')\n #print('2')\n else:\n print(\"NO\")\n #print('3')\n \nelse:\n if a[1]==s:\n print('YES')\n #print('4')\n elif b[1]==s:\n print('NO')\n #print('5')"}, {"source_code": "a=input()\ncc=input()\ncc=cc.split(\" \")\nb=cc[0]\nc=cc[1]\nl=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\",\"A\"]\n\nif(a in b and a not in c):\n print(\"YES\")\nelif(a not in b and a in c):\n print(\"NO\")\nelse:\n if(l.index(b[0])>l.index(c[0])):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "tramp = raw_input()\na, b = raw_input().split()\ns = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\nif a[1] ==tramp and b[1] != tramp:\n print 'YES'\nelse:\n print 'YES' if s.index(a[0]) > s.index(b[0]) else 'NO'\n"}, {"source_code": "\n\ndef getValue(s):\n if s == 'T':\n return 10\n elif s == 'J':\n return 11\n elif s == 'Q':\n return 12\n elif s == 'K':\n return 13\n elif s == 'A':\n return 14\n else:\n return int(s)\n\n\ntrump = raw_input()\n\nline = raw_input().split()\nfirst = line[0]\nsecond = line[1]\n\n\n\nif first[1] == second[1] and first[1] != trump and second[1] != trump:\n if getValue(first[0]) > getValue(second[0]):\n print \"YES\"\nelif first[1] == trump and second[1] != trump:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "\n\nt=input()\nl=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\na,b=input().split()\nif(l.index(a[0])>l.index(b[0])):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "Trump=raw_input()\nCards= raw_input()\nl = list(Cards)\nl.append(Trump)\nl = [w.replace('T', '10') for w in l]\nl = [w.replace('J', '11') for w in l]\nl = [w.replace('Q', '12') for w in l]\nl = [w.replace('K', '13') for w in l]\nl = [w.replace('A', '14') for w in l]\nl = [w.replace('S', '4') for w in l]\nl = [w.replace('H', '3') for w in l]\nl = [w.replace('D', '2') for w in l]\nl = [w.replace('C', '1') for w in l]\n\nif (l[1]==l[5] and l[4]!=l[5]):\n print 'YES'\nelif (l[1]!=l[5] and l[4]==l[5]):\n print 'NO'\nelif (int(l[1])>int(l[4])):\n print 'YES'\nelif (int(l[1])<int(l[4])):\n print 'NO'\nelif (l[1]==l[4] and int(l[0])>int(l[3])):\n print 'YES'\nelif (l[1]==l[4] and int(l[0])<int(l[3])):\n print 'NO'"}, {"source_code": "v='6789TJQKA'\nr=input;t=r();a,b=r().split()\na=(v.index(a[0]),a[1])\nb=(v.index(b[0]),b[1])\nprint(\"YNEOS\"[(b[1]==t and ((a[1]==t and b[1]>a[1]) or b[1]>a[1])) or (a[1]!=t and b[1]>a[1])::2])\n"}, {"source_code": "a=input()\nk=(input().split())\nl='6789JQKA'\nif a in k[0]:print(\"YES\")\nelif k[0][1]!=k[1][1]:print(\"NO\")\nelif k[0][1]==k[1][1] and l.index(k[0][0])>l.index(k[1][0]):print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "trump = raw_input()\na,b= raw_input().split()\ncards = '6789TJQKA'\nif trump==a[1]:\n print 'YES'\nelif trump==b[1]:\n print 'NO'\nelse:\n if a[1]==b[1] and cards.index(a[0])>cards.index(b[0]):\n print 'YES'\n else:\n print 'NO'"}, {"source_code": "a=input()\nh=['6','7','8','9','T','J','Q','K','A']\ns=[n for n in input().split()]\np=s[0]\nq=s[1]\nif p[1]==q[1] and p[1]!=a:\n if h.index(p[0])>h.index(q[0]):\n print('YES')\n else:\n print('NO')\nelse:\n if p[1]==a and q[1]!=a:\n print('YES')\n else:\n print('NO')"}, {"source_code": "suit = raw_input()\nfirst, second = raw_input().split(' ')\nd = {\n '6' : 6,\n '7' : 7,\n '8' : 8,\n '9' : 9,\n 'T' : 10,\n 'J' : 11,\n 'Q' : 12,\n 'K' : 13,\n 'A' : 14,\n }\nif second[1] == 'H' or d[second[0]] > d[first[0]]:\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nn=raw_input()\nf,s=map(str, raw_input().split())\n#\u7d75\u67c4\u4fdd\u5b58\nf1,s1=f[1],s[1]\nif f[0]=='T': f2=10\nelif f[0]=='J': f2=11\nelif f[0]=='Q': f2=12\nelif f[0]=='K': f2=13\nelif f[0]=='A': f2=14\nelse: f2=int(f[0])\n\nif s[1]==('6' or '7' or '8' or '9'):\n s2=int(s[0])\nif s[0]=='T': s2=10\nelif s[0]=='J': s2=11\nelif s[0]=='Q': s2=12\nelif s[0]=='K': s2=13\nelif s[0]=='A': s2=14\nelse: s2=int(s[0])\n\nif n==f1:\n print 'YES'\nelif f1==s1 and f2>s2:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "di = {'6':1,'7':2,'8':3,'9':4,'T':5,'J':6,'Q':7,'K':8,'A':9}\nt = input()\nc1,c2 = input().split()\n\nif(c1[1] == c2[1]):\n\tif(di[c1[0]] > di[c2[0]]):\n\t\tprint('YES')\nelse:\n\tif(c1[1] == t):\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\n"}, {"source_code": "def compare(s1,s2):\n x = \"6 7 8 9 T J Q K A\".split()\n for i in range (9):\n if s1 == x[i]:\n t1 = i\n if s2 == x[i]:\n t2 = i\n return t1 > t2\n\nn = input()\nres = 'NO'\ns = input().split()\nif s[0][1] == s[1][1]:\n if compare(s[0][0],s[1][0]):\n res = 'YES'\nelse:\n if s[0][1] == n:\n res = 'YES'\n\nprint('YES')"}, {"source_code": "s1=input()\ns2=input()\nif s2[1]==s1 and s2[-1]!=s1:print('YES')\nelif s2[1]==s2[-1] and s2[0]>s2[-2]:print('YES')\nelse:print('NO')\n"}, {"source_code": "t = raw_input()\nf, s = raw_input().split()\nr = '6789TJQKA'\nprint ['NO', 'YES'][f[1] == t and not s[1] == t or f[1] == t and s[1] == t and r.find(f[0]) > r.find(s[0])]"}, {"source_code": "l=['6','7','8','9','T','J','Q','K','A']\ntrump = input()\ncard1,card2=input().split()\nif card1[1] == trump:\n if card2[1] == trump:\n print('YES' if l.index(card1[0])>l.index(card2[0]) else 'NO')\n else:\n print('YES')\nelse:\n if card2[1] == trump:\n print('NO')\n else:\n print('YES' if l.index(card1[0])>l.index(card2[0]) else 'NO')"}, {"source_code": "import sys\n\ndef solve():\n trump = sys.stdin.readline().strip()\n f, s = sys.stdin.readline().split()\n res = 0\n ranks = \"6789TJQKA\"\n if f[1] == trump and s[1] == trump:\n if ranks.find(f[0]) > ranks.find(s[0]):\n res = 1\n else:\n res = 0\n elif f[1] == trump and s[1] != trump:\n res = 1\n elif f[1] != trump and s[1] == trump:\n res = 0\n else:\n res = 0\n print \"YES\" if res else \"NO\"\n\nsolve()\n"}, {"source_code": "a=['6','7','8','9','T',\"J\",\"Q\",\"K\",\"A\"]\ntrump=input()\nfirst,second=input().split()\nif first[1]==trump and first[1]!=second[1]:\n print(\"YES\")\nelif first[1]==second[1]:\n if a.index(first[0])>a.index(second[0]):\n print('YES')\nelse:\n print(\"NO\")"}, {"source_code": "tramp = raw_input()\na, b = raw_input().split()\ns = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\nif a[1] ==tramp and b[1] != tramp:\n print 'YES'\nelif a[1] != tramp and b[1] == tramp:\n print 'NO'\nelse:\n print 'YES' if s.index(a[0]) > s.index(b[0]) else 'NO'\n"}, {"source_code": "ranks = ['6','7','8','9','T','J','Q','K','A']\n\ntr = input()\na,b = map(str,input().split())\n\nif(tr in a):\n print('YES')\nelse:\n if(ranks.index(a[0]) >= ranks.index(b[0])):\n print('YES')\n else:\n print('NO')"}, {"source_code": "trump=['S','H','D','C']\nrank=[ '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' ]\ns=input()\nt=input()\nif s in trump and s not in t:\n print(\"YES\")\nelse:\n if t[1]!=t[-1]:\n print(\"NO\")\n else:\n if rank.index(t[0])-rank.index(t[3])>0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "suit = ['S', 'H', 'D', 'C']\nrank = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\n\ntrump = str(raw_input())\ncards = str(raw_input())\n\nwin = False\n\nif cards[1] == cards[4] and rank.index(cards[0]) > rank.index(cards[3]):\n win = True\n \nif cards[1] == trump:\n win = True\n \nif win:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def great():\n\ta.split()\n\tb.split()\n\tif s.index(a[0]) > s.index(b[0]):\n\t\t\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\nt=input()\na,b=map(str,input().split())\ns='6789TJQKA'\nif(t in a):\n\tif t in b:\n\t\tgreat()\n\telse:\n\t\tprint(\"YES\")\nelif(t in b):\n\tprint(\"NO\")\nelse:\n\tgreat()\n\t\n"}, {"source_code": "tr = input()\nt1,t2 = map(str,input().split())\ng = ['A','K','Q','J','T']\nif tr in t1 and tr not in t2:\n print('YES')\nelif tr not in t1 and tr in t2:\n print('NO')\nelse:\n s1 = t1[0]\n s2 = t2[0]\n if s1 in g and s2 in g:\n l1 = g.index(s1)\n l2 = g.index(s2)\n if l1>l2:\n print('NO')\n elif l1==l2:\n print('NO')\n else:\n print('YES')\n elif s1 in g:\n print('YES')\n elif s2 in g:\n print('NO')\n elif s1 not in g and s2 not in g:\n s1,s2 = int(s1),int(s2)\n if t1[1]==t2[1]:\n if s1>s2:\n print('YES')\n elif s1==s2:\n print('NO')\n else:\n print('NO')\n else:\n print('NO')"}, {"source_code": "s=input()\nc=input()\na='6789TJQKA'\nif(c[1]==s and c[1]!=c[len(c)-1]):\n print(\"******YES\")\nelse:\n if(c[1]==c[len(c)-1] and a.find(c[0])>a.find(c[len(c)-2])):\n print(\"YES\")\n else:\n print(\"NO\")\n "}, {"source_code": "a=raw_input()\nb, c= raw_input().split()\nd=0\ne=0\nif b[1]==a:\n d+=100\nif c[1]==a:\n e+=100\n\n \nif b[0]=='6':\n d+=6\nelif b[0]=='7':\n d+=7\nelif b[0]=='8':\n d+=8\nelif b[0]=='9':\n d+=9\nelif b[0]=='T':\n d+=10\nelif b[0]=='J':\n d+=11\nelif b[0]=='Q':\n d+=12\nelif b[0]=='K':\n d+=13\nelif b[0]=='A':\n d+=14\n\n\nif c[0]=='6':\n e+=6\nelif c[0]=='7':\n e+=7\nelif c[0]=='8':\n e+=8\nelif c[0]=='9':\n e+=9\nelif c[0]=='T':\n e+=10\nelif c[0]=='J':\n e+=11\nelif c[0]=='Q':\n e+=12\nelif c[0]=='K':\n e+=13\nelif c[0]=='A':\n e+=14\n\nif d>e:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n \nif ranks.index(a[0])> ranks.index(b[0]) or a[1]==trump and b[1]!=trump:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "trump = input()\n[cart1, cart2] = list(input().split())\nrank1, suit1 = cart1[0], cart1[1]\nrank2, suit2 = cart2[0], cart2[1]\nranks = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\nsuits = [\"S\", \"H\", \"D\", \"C\"]\nif(suits.index(suit1) == suits.index(suit2) and ranks.index(rank1) > ranks.index(rank2)) or trump == suit1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n \nif ranks.index(a[0])> ranks.index(b[0]) or a[1]==trump and b[1]!=trump:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "\n\ntrump = raw_input()[0]\ns1, s2 = raw_input().split(' ')\n\n\nvs = '6789TJQKA'\n\nif (s1[1] == trump and s2[1] != trump) or ((s2[1] != trump or (s1[1] == trump and s2[1] == trump)) and vs.index(s1[0]) > vs.index(s2[0])):\n print 'YES'\nelse:\n print 'NO'\n\n"}, {"source_code": "seq = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" , \"A\"]\nrank =[\"S\", \"H\", \"D\" , \"C\"]\ntrump = str(input())\nfirst , second = map(str , input().split())\nfr = first[0]\nfs = first[1]\nsr = second[0]\nss = second[1]\nif fs==trump:\n if ss==trump:\n if seq.index(fr)>seq.index(sr):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"YES\")\nelif ss==trump:\n print(\"NO\")\nelse:\n if fs==ss:\n if seq.index(fr)>seq.index(sr):\n print(\"YES\")\n else:\n print(\"NO\")\n elif rank.index(fs)<rank.index(ss):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "s=input('')\ns1=input(' ')\nl=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\nl1=[\"S\",\"H\",\"D\",\"C\"]\nif(s1[0]==s1[3] or (l.index(s1[0])>l.index(s1[3])) or s1[1]==s):\n print('YES')\nelse:\n print('NO')\n \n "}, {"source_code": "t=input()\na,b=input().split()\nif a[1]==b[1]:\n if a[0]>b[0]:\n print('YES')\n else:\n print('NO')\nelif a[1]==t and b[1]!=t:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "\n\n\n\na = input()\n\n\n\nb = input().split()\n\nif 48<=ord(b[-1][0])<=57 and 48<=ord(b[0][0])<=57:\n\n\n if int(b[-1][0])> int((b[0][0])):\n if b[0][0]!=a:\n print('NO')\n else:\n print('YES')\n else:\n print('YES')\nelse:\n\n s=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" ,\"A\"]\n if b[0][0]==a:\n if b[-1][0]==a:\n if s.index(b[0][0]) >= s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n else:\n print('YES')\n else:\n if b[-1][0]==a:\n print('NO')\n else:\n if s.index(b[0][0]) >= s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n\n \n"}, {"source_code": "rnk = \"6789TJQKA\"\nt = raw_input()\na,b = raw_input().split()\nif a[1] == t:\n print \"YES\"\nelif a[1] == b[1]:\n print \"YES\" if rnk.index(a[0]) > rnk.index(b[0]) else \"NO\"\nelse:\n print \"NO\""}, {"source_code": "suits={'S','H','D','C'}\nranks={'6':0,'7':1,'8':2,'9':3,'T':4,'J':5,'Q':6,'K':7,'A':8}\ntrump=input()\ncard1,card2=input().split()\nif card1[1]==trump:\n if card2[1]==trump:\n if(ranks[card1[0]]>ranks[card2[0]]):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n if card2[1]==trump:\n print(\"NO\")\n else:\n if(ranks[card1[0]]>ranks[card2[0]]):\n print(\"YES\")\n else:\n print(\"NO\")\n\n"}, {"source_code": "trump = raw_input()\nx = raw_input()\nfirst = x[:2:]\nsecond = x[3::]\nd = {\n \"6\": 1,\n \"7\": 2,\n \"8\": 3,\n \"9\": 4,\n \"T\": 5,\n \"J\": 6,\n \"Q\": 7,\n \"K\": 8,\n \"A\": 9\n } \nif(first[1] == trump):\n print \"YES\"\nelif(second[1] == trump):\n print \"NO\"\nelif(d[first[0]] > d[second[0]]):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "tr = input()\nt1,t2 = map(str,input().split())\ng = ['A','K','Q','J','T']\nif tr in t1 and tr not in t2:\n print('YES')\nelif tr not in t1 and tr in t2:\n print('NO')\nelse:\n s1 = t1[0]\n s2 = t2[0]\n if s1 in g and s2 in g:\n l1 = g.index(s1)\n l2 = g.index(s2)\n if s1>s2:\n print('NO')\n elif s1==s2:\n print('NO')\n else:\n print('YES')\n elif s1 in g:\n print('YES')\n elif s2 in g:\n print('NO')\n else:\n s1,s2 = int(s1),int(s2)\n if s1>s2:\n print('YES')\n elif s1==s2:\n print('NO')\n else:\n print('NO')"}, {"source_code": "s=input()\na,b=input().split()\nx=\"6789TJQKA\"\nif a[1]==s: print(\"YES\")\nelif b[1]==s or a[1]!=b[1]: print(\"NO\")\nelif x.index(a[0])>x.index(b[0]): print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "\n\nbig = {\n 'T': 10,\n 'J': 11,\n 'Q': 12,\n 'K': 13,\n 'A': 14\n}\n\ntr = input()\n\nfirst, second = input().split()\n\nif first[0] in big:\n fv = big[first[0]]\nelse:\n fv = int(first[0])\n\nif second[0] in big:\n sv = big[second[0]]\nelse:\n sv = int(second[0])\n\nif (first[1] == tr and second[1] != tr) or fv > sv:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\n\n\n\na = input()\n\n\n\nb = input().split()\n\nif 48<=ord(b[-1][0])<=57 and 48<=ord(b[0][0])<=57:\n\n\n if int(b[-1][0])> int((b[0][0])):\n if b[0][0]!=a:\n print('NO')\n else:\n print('YES')\n else:\n print('YES')\nelse:\n\n s=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" ,\"A\"]\n if b[0][1]==a:\n if b[-1][1]==a:\n if s.index(b[0][0]) >= s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n else:\n print('YES')\n else:\n if b[-1][1]==a:\n print('NO')\n else:\n if s.index(b[0][0]) >= s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n\n \n"}, {"source_code": "s1 = raw_input()\ns2 = raw_input().split()\nd={}\nfor i in xrange(6, 10):\n d[str(i)]=i\nd[\"T\"]=10\nd[\"J\"]=11\nd[\"Q\"]=12\nd[\"K\"]=13\nd[\"A\"]=14\nif (s2[0][1]==s2[1][1] and d[s2[0][0]]>d[s2[1][0]]):\n print(\"YES\")\nelif (s2[0][1]==s1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "tr = input()\nt1,t2 = map(str,input().split())\ng = ['A','K','Q','J','T']\nif tr in t1 and tr not in t2:\n print('YES')\nelif tr not in t1 and tr in t2:\n print('NO')\nelse:\n s1 = t1[0]\n s2 = t2[0]\n if s1 in g and s2 in g:\n l1 = g.index(s1)\n l2 = g.index(s2)\n if s1>s2:\n print('NO')\n elif s1==s2:\n print('NO')\n else:\n print('YES')\n elif s1 in g:\n print('YES')\n elif s2 in g:\n print('NO')\n else:\n s1,s2 = int(s1),int(s2)\n if s1>s2:\n print('YES')\n elif s1==s2:\n print('NO')\n else:\n print('NO')"}, {"source_code": "atu=[]\ncarti=[]\ncarte1=[]\ncarte2=[]\natu=raw_input()\ncarti=raw_input()\nok=0\nfor i in carti:\n\tif i==' ':\n\t\tok=1\n\t\tcontinue\n\tif ok==0:\n\t\tcarte1.append(i)\n\telse:\n\t\tcarte2.append(i)\n\nmsg=0\nindex={'6':0, '7':1, '8':2, '9':3, 'T':4, 'J':5, 'Q':6, 'K':7, 'A':8}\nif carte1[1]==atu[0]:\n\tif carte2[1]==atu[0]:\n\t\tif index[carte1[0]]<index[carte2[0]]:\n\t\t\tmsg=0\n\t\telse:\n\t\t\tmsg=1\n\telse:\n\t\tmsg=1\nelse:\t\t\n\tif carte2[0]==atu[0]:\n\t\tmsg=0\n\telse:\n\t\tif index[carte1[0]]<=index[carte2[0]]:\n\t\t\tmsg=0\n\t\telse:\n\t\t\tmsg=1\n\t\t\t\t\nif msg==0:\n\tmsg='NO' \nelse:\n\tmsg='YES'"}, {"source_code": "\n\ndef getValue(s):\n if s == 'T':\n return 10\n elif s == 'J':\n return 11\n elif s == 'Q':\n return 12\n elif s == 'K':\n return 13\n elif s == 'A':\n return 14\n else:\n return int(s)\n\n\ntrump = raw_input()\n\nline = raw_input().split()\nfirst = line[0]\nsecond = line[1]\n\n\nif first[1] == trump and second[1] != trump:\n print \"YES\"\nelif first[1] == second[1]:\n if getValue(first[0]) > getValue(second[0]):\n print \"YES\" \nelse:\n print \"NO\""}, {"source_code": "l=[\"6\",\"7\",\"8\",\"9\",\"T\",\"J\",\"Q\",\"K\",\"A\"]\ns=input()\na,b = input().split()\nif a[1] is b[1] and a[1] is s:\n if l.index(a[0]) > l.index(b[0]):\n print(\"YES\")\n else: print(\"NO\")\n\nelif a[1] is b[1] and a[1] is not s:\n if l.index(a[0]) > l.index(b[0]):\n print(\"YES\")\n else: print(\"NO\")\n\nelif a[1] is not b[1] and a[1] is not s:\n if b[1] is s:\n print(\"NO\")\n else: \n if l.index(a[0]) > l.index(b[0]):\n print(\"YES\")\n else: print(\"NO\")\n\nelif a[1] is not b[1] and a[1] is s:\n print(\"YES\") \n\nelse: print(\"NO\")\n"}, {"source_code": "x = str(input())\ny,z = map(str,input().split())\n\narr = {\"6\":1, \"7\":2, \"8\":3, \"9\":4, \"T\":5, \"J\":6, \"Q\":7, \"K\":8, \"A\":9}\n\nif x==y[1] or (y[1]==z[1] and arr[y[0]]>arr[z[0]]):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "trump = raw_input()\nx = raw_input()\nfirst = x[:2:]\nsecond = x[3::]\nd = {\n \"6\": 1,\n \"7\": 2,\n \"8\": 3,\n \"9\": 4,\n \"T\": 5,\n \"J\": 6,\n \"Q\": 7,\n \"K\": 8,\n \"A\": 9\n }\nif(first[1] != second[1]):\n if(first[1] == trump):\n print \"YES\"\n elif(second[1] == trump):\n print \"NO\"\nelif(d[first[0]] > d[second[0]]):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "\n\ndef getValue(s):\n if s == 'T':\n return 10\n elif s == 'J':\n return 11\n elif s == 'Q':\n return 12\n elif s == 'K':\n return 13\n elif s == 'A':\n return 14\n else:\n return int(s)\n\n\ntrump = raw_input()\n\nline = raw_input().split()\nfirst = line[0]\nsecond = line[1]\n\n\nif first[1] == trump and second[1] != trump:\n print \"YES\"\nelif first[1] == second[1]:\n if getValue(first[0]) > getValue(second[0]):\n print \"YES\" \nelif first[1] == trump and second[1] == trump:\n if getValue(first[0]) > getValue(second[0]):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "\n\nbig = {\n 'T': 10,\n 'J': 11,\n 'Q': 12,\n 'K': 13,\n 'A': 14\n}\n\ntr = input()\n\nfirst, second = input().split()\n\nif first[0] in big:\n fv = big[first[0]]\nelse:\n fv = int(first[0])\n\nif second[0] in big:\n sv = big[second[0]]\nelse:\n sv = int(second[0])\n\nif first[1] == tr and second[1] != tr or fv > sv:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=input()\nf,s=input().split()\nf.replace(\"A\",\"14\")\nf.replace(\"K\",\"13\")\nf.replace(\"Q\",\"12\")\nf.replace(\"J\",\"11\")\nf.replace(\"T\",\"10\")\ns.replace(\"A\",\"14\")\ns.replace(\"K\",\"13\")\ns.replace(\"Q\",\"12\")\ns.replace(\"J\",\"11\")\ns.replace(\"T\",\"10\")\n\nif a==f[1]:\n print(\"YES\")\nelse:\n if f[1]!=s[1]:\n print(\"NO\")\n else:\n if int(f[0])>int(s[0]):\n print(\"YES\")\n else:\n print(\"NO\")\n \n"}, {"source_code": "\n\n\n\na = input()\n\n\n\nb = input().split()\n\nif 48<=ord(b[-1][0])<=57 and 48<=ord(b[0][0])<=57:\n\n\n if int(b[-1][0])> int((b[0][0])):\n if b[0][1]!=a:\n print('NO')\n else:\n print('YES')\n else:\n if b[-1][1]!=a:\n print('YES')\n else:\n print('NO')\nelse:\n\n s=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" ,\"A\"]\n if b[0][1]==a:\n if b[-1][1]==a:\n if s.index(b[0][0]) > s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n else:\n print('YES')\n else:\n if b[-1][1]==a:\n print('NO')\n else:\n if s.index(b[0][0]) > s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n\n \n"}, {"source_code": "coz = raw_input()\nf,s = raw_input().split()\n\nd = {'6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14}\n\nif f[1] == coz and s[1] != coz:\n print(\"YES\")\nelif f[1] != coz and s[1] == coz:\n print(\"NO\")\nelif f[1] == s[1] and [f[0]] > d[s[0]]:\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "\n\n\n\na = input()\n\n\n\nb = input().split()\n\nif 48<=ord(b[-1][0])<=57 and 48<=ord(b[0][0])<=57:\n\n\n if int(b[-1][0])> int((b[0][0])):\n if b[0][1]!=a:\n print('NO')\n else:\n print('YES')\n else:\n if b[-1][1]!=a:\n print('YES')\n else:\n print('NO')\nelse:\n\n s=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" ,\"A\"]\n if b[0][1]==a:\n if b[-1][1]==a:\n if s.index(b[0][0]) > s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n else:\n print('YES')\n else:\n if b[-1][1]==a:\n print('NO')\n else:\n if s.index(b[0][0]) > s.index(b[-1][0]):\n print('YES')\n else:\n print('NO')\n\n \n"}, {"source_code": "s1=input()\ns2=input()\nif s2[1]==s1 and s2[-1]!=s1:print('YES')\nelif s2[1]==s2[-1] and s2[0]>s2[-2]:print('YES')\nelse:print('NO')\n"}, {"source_code": "t = input()\nf , s = input().split()\nrank = [\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" , \"A\"]\nans='NO'\nif f[1]==t:\n ans='YES'\nelif f[1]==s[1]:\n if rank.index(f[0]) > rank.index(s[0]):\n ans='YES'\nprint(ans)\n \n"}, {"source_code": "\n\n\nn=raw_input()\np =raw_input()\nans=\"NO\"\nrank=[\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\",\"A\"]\n\n\nif p[1] ==n and p[4] == n:\n\tif (rank.index(p[0])>rank.index(p[3])):\n\t\tans = 'YES'\nelif p[1]==n:\n\tans = \"YES\"\nelif p[4] ==n:\n\tans=\"NO\"\nelse:\n\tif (rank.index(p[0])>rank.index(p[3])):\n\t\tans = \"YES\"\nprint ans\n\n\n"}], "src_uid": "da13bd5a335c7f81c5a963b030655c26"} {"source_code": "import math \nfrom collections import *\n\nn = int(input())\ns = input()\n\nflag = True\n\nans = 0\n\nwhile flag and len(s) > 1:\n flag = False\n for i in range(len(s)):\n if i == 0:\n tst = False\n for j in range(1,len(s)):\n if ord(s[j])-ord(s[i]) == 1:\n tst = True\n break\n if tst == False and ord(s[i])-ord(s[i+1]) == 1:\n s = s[1:len(s)]\n flag = True\n ans+=1\n break\n elif i == len(s)-1:\n tst = False\n for j in range(0,len(s)-1):\n if ord(s[j])-ord(s[i]) == 1:\n tst = True\n break\n if tst == False and ord(s[i])-ord(s[i-1]) == 1:\n flag = True\n s = s[0:len(s)-1]\n ans+=1\n break\n else:\n tst = False\n for j in range(0,i):\n if ord(s[j])-ord(s[i]) == 1:\n tst = True\n break\n for j in range(i+1,len(s)):\n if ord(s[j])-ord(s[i]) == 1:\n tst = True\n break\n chk = ord(s[i])-ord(s[i-1]) == 1 or ord(s[i])-ord(s[i+1]) == 1\n if tst == False and chk:\n flag = True \n ans+=1\n s1 = s[0:i]\n s2 = s[i+1:len(s)]\n s = s1+s2\n break\n\n\nflag = True\nwhile flag and len(s)>1:\n flag = False\n for i in range(len(s)-1,-1,-1):\n if i == 0:\n if ord(s[i])-ord(s[i+1]) == 1:\n ans+=1\n flag = True\n s = s[1:len(s)]\n break\n elif i == len(s)-1:\n if ord(s[i])-ord(s[i-1]) == 1:\n ans+=1\n flag = True\n s = s[0:len(s)-1]\n break\n else:\n if ord(s[i+1])-ord(s[i]) !=1 and ord(s[i-1])-ord(s[i]) !=1:\n if ord(s[i+1])-ord(s[i]) ==-1 or ord(s[i-1])-ord(s[i]) ==-1:\n flag = True \n ans+=1\n s1 = s[0:i]\n s2 = s[i+1:len(s)]\n s = s1+s2\n break\nprint(ans)", "positive_code": [{"source_code": "def solve(s):\n d = 0\n for ss in sorted(set(s), reverse=True):\n while True:\n n = len(s)\n ns = list()\n succ = False\n for idx in range(len(s)):\n if s[idx] == ss and (s[max(0, idx - 1)] + 1 == s[idx] or s[min(n - 1, idx + 1)] + 1 == s[idx]):\n d += 1\n succ = True\n else:\n ns.append(s[idx])\n s = ns\n if not succ:\n break\n return d\n\n\nN = int(input())\ns = list(map(ord, list(input())))\nprint(solve(s))\n"}, {"source_code": "n = int(input())\ns = list(input())\nk = 0\nanswer = 0\nwhile k == 0:\n k = 1\n mas = []\n for i in range(1, len(s)):\n if ord(s[i]) - 1 == ord(s[i - 1]):\n k = 0\n mas.append([ord(s[i]), i])\n elif ord(s[i]) + 1 == ord(s[i - 1]):\n k = 0\n mas.append([ord(s[i - 1]), i - 1])\n if mas:\n mas.sort()\n answer += 1\n ind = mas[-1][1]\n s.pop(ind)\nprint(answer)"}, {"source_code": "n=int(input())\ns=list(input())\nfor i in range(ord(\"z\"),ord(\"a\")-1,-1):\n j=0\n while(j<len(s)):\n if(len(s)<=j):\n break\n if(j==len(s)-1):\n if(s[j]==chr(i) and s[j-1]==chr(i-1)):\n k=s.pop(j)\n j=0\n continue\n elif(j==0):\n if(s[j]==chr(i) and s[j+1]==chr(i-1)):\n k=s.pop(j)\n j=0\n continue\n else:\n if(s[j]==chr(i) and (s[j-1]==chr(i-1) or s[j+1]==chr(i-1))):\n k=s.pop(j)\n j=0\n continue\n j=j+1\nprint(n-len(s))\n "}, {"source_code": "def filtered(s, filt):\n buf = \"\"\n for tp in zip(s, filt):\n if not tp[1]:\n buf += tp[0]\n return buf\nn = int(input())\ns = input()\nfor c in range(25, 0, -1):\n deleted = [False] * len(s)\n stack = [s[0]] * 2\n for i in range(len(s)):\n if s[i] != stack[-1]:\n stack.append(s[i])\n if c + ord('a') == ord(s[i]) and ord(s[i]) - ord(stack[-2]) == 1:\n deleted[i] = True\n stack = [s[-1]] * 2\n for i in range(len(s) - 1, -1, -1):\n if s[i] != stack[-1]:\n stack.append(s[i])\n if c + ord('a') == ord(s[i]) and ord(s[i]) - ord(stack[-2]) == 1:\n deleted[i] = True\n s = filtered(s, deleted)\nprint(n - len(s))\n\n"}, {"source_code": "n=int(input())\ns=str(input())\nal=\"abcdefghijklmnopqrstuvwxyz\"\nans=0\ndef p(a,j):\n\tglobal s,n\n\tif s[0]==a and s[1]==al[j-1]:\n\t\ts=s[1:]\n\t\tn-=1\n\t\treturn(True)\n\tif s[n-1]==a and s[n-2]==al[j-1]:\n\t\ts=s[:n-1]\n\t\tn-=1\n\t\treturn(True)\n\tfor i in range(1,n-1):\n\t\tif s[i]==a:\n\t\t\tif s[i+1]==al[j-1]:\n\t\t\t\ts=s[:i]+s[i+1:]\n\t\t\t\tn-=1\n\t\t\t\treturn(True)\n\t\t\tif s[i-1]==al[j-1]:\n\t\t\t\ts=s[:i]+s[i+1:]\n\t\t\t\tn-=1\n\t\t\t\treturn(True)\n\treturn(False)\n\nj=25\nwhile j>0 and n>1:\n\twhile p(al[j],j):\n\t\tans+=1\n\tj=j-1\nif n>1 and (s in al or s[::-1] in al):\n\tans+=1\nprint(ans)"}, {"source_code": "n=int(input())\ns=list(input())\nk=0\nans=0\n \nwhile k==0:\n\tk=1\n\tnum=[]\n\tfor i in range(1,len(s)):\n\t\tif ord(s[i])-1==ord(s[i-1]):\n\t\t\tk=0\n\t\t\tnum.append([ord(s[i]),i])\n\t\telif ord(s[i])+1==ord(s[i-1]):\n\t\t\tk=0\n\t\t\tnum.append([ord(s[i-1]),i-1])\n\tif num:\n\t\tnum.sort()\n\t\tans+=1\n\t\tindex=num[-1][1]\n\t\ts.pop(index)\n \nprint(ans)"}, {"source_code": "import sys\ninput=sys.stdin.readline\nn=int(input())\na=input()\nA=[100]\nfor i in a:\n A.append(ord(i)-97)\nA.append(100)\nB=[i for i in range(26,-1,-1)]\n\nfor i in B:\n j=1\n while(j<len(A)-1):\n if (A[j]==i):\n if ((A[j]==A[j-1]+1) or (A[j]==A[j+1]+1)):\n A.pop(j)\n j=1\n else:\n j=j+1\n else:\n j=j+1\n\nprint(n-len(A)+3)\n \n \n"}, {"source_code": "import re\nn=int(input())\ns=input()\ny='z'\nfor i in range(121,96,-1):x=y+'*';y=chr(i);s=re.sub(x+y+x,y,s)\nprint(n-len(s))"}, {"source_code": "n=int(raw_input())\ns=raw_input()\ncnt=0\n\nwhile len(s)>1:\n\tmx,pos=0,-1\n\tfor i in xrange(len(s)):\n\t\tif i>0:\n\t\t\tif s[i]==chr(ord(s[i-1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],i\n\t\tif i<len(s)-1:\n\t\t\tif s[i]==chr(ord(s[i+1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],i\n\tif pos==-1: break \n\telse: s=s[:pos]+s[(pos+1):]\n\tcnt+=1\n\nprint cnt"}, {"source_code": "import re\na='yxwvutsrqponmlkjihgfedcba'\nn=int(input())\ns=input()\nfor x,y in zip('z'+a,a):t=f'{x}*{y}{x}*';s=re.sub(x+t+'|'+t+x,y,s)\nprint(n-len(s))"}, {"source_code": "n=int(raw_input())\ns=raw_input()\ncnt=0\n\nwhile len(s)>1:\n\tmx,pos=0,-1\n\tfor i in xrange(len(s)):\n\t\tif i==0 and len(s)>1:\n\t\t\tif s[0]==chr(ord(s[1])+1):\n\t\t\t\tif s[0]>mx: mx,pos=s[0],0\n\t\telif i==len(s)-1:\n\t\t\tif s[i]==chr(ord(s[i-1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],i\n\t\telse:\n\t\t\tif s[i]==chr(ord(s[i-1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],i\n\t\t\telif s[i]==chr(ord(s[i+1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],i\n\tif pos==-1:\n\t\tbreak\n\telse:\n\t\ts=s[:pos]+s[(pos+1):]\n\tcnt+=1\n\nprint cnt"}, {"source_code": "n=input()\nn1=n\ns=raw_input().strip()\ns=[ord(i) for i in s]\ni=122\nwhile i>=97:\n f=1\n while f:\n f1=0\n for j in range(n):\n if s[j]==i and ( (j>0 and s[j]-s[j-1]==1) or (j<n-1 and s[j]-s[j+1]==1)):\n f1=1\n s=s[:j]+s[j+1:]\n n=len(s)\n break\n if not f1:\n f=0\n i-=1\nprint n1-n \n \n"}, {"source_code": "import re\nn=int(input())\ns=input()\ny='z'\nwhile'a'<y:x=y+'*';y=chr(ord(y)-1);s=re.sub(x+y+x,y,s)\nprint(n-len(s))"}, {"source_code": "n1=input()\ns=raw_input()\nfor _ in range(122,97,-1):\n n2=len(s)\n for k in range(n2):\n c=chr(_)\n a=\"\"\n n=len(s)\n if n==1:\n break\n for i in range(n):\n if s[i]==c:\n if i==0:\n if s[i+1]==chr(_-1):\n pass\n else:\n a+=s[i]\n elif i==n-1:\n if s[i-1]==chr(_-1):\n pass\n else:\n a+=s[i]\n else:\n if s[i+1]==chr(_-1):\n pass\n elif s[i-1]==chr(_-1):\n pass\n else:\n a+=s[i]\n else:\n a+=s[i]\n s=a\nprint n1-len(s)\n"}, {"source_code": "n = int(input())\nstr = input()\nlst = list(str)\n\nfor i in range(122, 97, -1):\n for k in range(100):\n l = len(lst)\n tmp = []\n for j in range(l):\n if ord(lst[j]) == i:\n if (j+1 < l and ord(lst[j+1]) == i-1) or (j-1 >= 0 and ord(lst[j-1]) == i-1):\n tmp.append(j)\n bul = True\n l = len(tmp)\n tmp.reverse()\n for j in tmp:\n del lst[j]\n\nprint(n-len(lst))\n"}, {"source_code": "import sys \n# sys.setrecursionlimit(10**6) \nfrom sys import stdin, stdout\nimport bisect #c++ upperbound\nimport math\nimport heapq\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef cin():\n return map(int,sin().split())\ndef ain(): #takes array as input\n return list(map(int,sin().split()))\ndef sin():\n return input()\ndef inin():\n return int(input())\nimport math \ndef Divisors(n) : \n l = [] \n for i in range(1, int(math.sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n // i == i) : \n l.append(i) \n else : \n l.append(i)\n l.append(n//i)\n return l\n\n \n\"\"\"*******************************************************\"\"\"\ndef main():\n n=inin()\n s=sin()\n a=list(s)\n x=ord(\"a\")\n ans=0\n for i in range(26):\n y=chr(x+25-i)\n n=len(a)\n for j in range(n):\n if(a[j]==y):\n if(j>0 and (a[j-1]==chr(ord(y)-1) or a[j-1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n elif(j<n-1 and (a[j+1]==chr(ord(y)-1) or a[j+1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n for j in range(n-1,-1,-1):\n if(a[j]==y):\n if(j>0 and (a[j-1]==chr(ord(y)-1) or a[j-1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n elif(j<n-1 and (a[j+1]==chr(ord(y)-1) or a[j+1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n a[:] = (value for value in a if value != \"*\")\n # print(a)\n print(ans)\n######## Python 2 and 3 footer by Pajenegod and c1729\n \n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n \n# So on cf, use PyPy2 for best string performance.\n \npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n \nimport os, sys\nfrom io import IOBase, BytesIO\n \nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n \n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n \nif __name__== \"__main__\":\n main()"}, {"source_code": "import os\nimport io\nfrom collections import Counter\nfrom collections import defaultdict\nimport math\nimport random\nimport heapq as hq\nfrom math import sqrt\nimport sys\nfrom functools import reduce\nfrom collections import deque\nimport threading\n\n# sys.setrecursionlimit(2000000)\n# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef iinput():\n return int(input())\n\n\ndef tinput():\n return input().split()\n\n\ndef rinput():\n return map(int, tinput())\n\n\ndef rlinput():\n return list(rinput())\n\n\nmod = int(1e9)+7\n\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\n\n# ----------------------------------------------------\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\n\n\ndef removemax(s):\n # remove maximum element first\n n = len(s)\n maxi = -float('inf')\n toremove = -1\n for i in range(n):\n if i==0 and i<n-1 and s[i]-s[i+1] == 1 and s[i] > maxi:\n toremove = i\n maxi = s[i]\n elif i == n-1 and s[i]-s[i-1] == 1 and s[i] > maxi:\n toremove = i\n maxi = s[i]\n elif 0<i<n-1 and (s[i]-s[i-1] == 1 or s[i]-s[i+1] == 1) and s[i] > maxi:\n toremove = i\n maxi = s[i]\n if toremove==-1:\n return '',False\n else:\n s.pop(toremove)\n return s,True\n\nif __name__ == \"__main__\":\n n = iinput()\n s = list(input())\n s = [ord(i) for i in s]\n flag = True\n ans = 0\n while flag:\n s, flag = removemax(s)\n # print('hello')\n ans += 1\n print(ans-1)\n"}, {"source_code": "n = int(input())\ns = input()\nalf = 'abcdefghijklmnopqrstuvwxyz'\nnums = [[] for i in range(26)]\nfor i in range(n):\n num = alf.index(s[i])\n nums[num].append(i)\nres = 0\ne_n_r = {}\ne_n_l = {}\nque = []\nused = [0]*n\n#print('print(k, res, que, e_n_r, e_n_l, used, ng, nums)')\ndef f(k):\n global res, que, e_n_r, e_n_l, used, nums, alf, s, n\n i = alf.index(s[k])\n# print(k, res, que, e_n_r, e_n_l, used, nums)\n if used[k] != 0:\n return \n ng = [k-1, k+1]\n if e_n_r.get(k) is not None:\n ng[1] = e_n_r[k]\n if e_n_l.get(k) is not None:\n ng[0] = e_n_l[k]\n if ng[0] in nums[i-1] or ng[1] in nums[i-1]:\n# print(ng[0], ng[1], nums[i-1])\n res += 1\n used[k] = 1\n e_n_r[ng[0]] = ng[1]\n e_n_l[ng[1]] = ng[0]\n if 0 <= ng[0] < n and alf.index(s[ng[0]]) == alf.index(s[k]) and used[ng[0]] == 0:\n que = [ng[0]] + que\n if 0 <= ng[1] < n and alf.index(s[ng[1]]) == alf.index(s[k]) and used[ng[1]] == 0:\n que = [ng[1]] + que\n# print(k, res, que, e_n_r, e_n_l, used, ng, nums)\n\n\n\nfor i in range(25, 0, -1):\n for k in nums[i]:\n que.append(k)\nwhile len(que) > 0:\n f(que.pop(0))\nprint(res)\n\n"}, {"source_code": "from sys import stdin\nfrom collections import deque\nmod = 10**9 + 7\nimport sys\nimport random\n# sys.setrecursionlimit(10**6)\nfrom queue import PriorityQueue\n# def rl():\n# return [int(w) for w in stdin.readline().split()]\nfrom bisect import bisect_right\nfrom bisect import bisect_left\nfrom collections import defaultdict\nfrom math import sqrt,factorial,gcd,log2,inf,ceil\n# map(int,input().split())\n# # l = list(map(int,input().split()))\n# from itertools import permutations\nimport heapq\n# input = lambda: sys.stdin.readline().rstrip()\ninput = lambda : sys.stdin.readline().rstrip()\nfrom sys import stdin, stdout\nfrom heapq import heapify, heappush, heappop\nfrom itertools import permutations\nfrom math import factorial as f\n\n# def ncr(x, y):\n# return f(x) // (f(y) * f(x - y))\ndef ncr(n, r, p):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\nfrom collections import defaultdict\nfrom heapq import heappop, heappush, heapify\n\n\n\n\n# n = int(input())\n#\n# l1 = list(map(int,input().split()))\n#\n# l2 = list(map(int,input().split()))\n#\n# cnt1 = 0\n# cnt2 = 0\n#\n# for i in range(n):\n# if l1[i]>l2[i]:\n# cnt1+=1\n# elif l1[i]<l2[i]:\n# cnt2+=1\n# if cnt1>cnt2:\n# print(1)\n# elif cnt2>cnt1 and cnt1!=0:\n# z = 1 + ceil((cnt2-cnt1)/cnt1)\n# # print(cnt1,cnt2)\n# if z*cnt1>cnt2:\n# print(z)\n# else:\n# print(z+1)\n#\n# else:\n# print(-1)\n\n\nn = int(input())\n\ns = list(input())\n\n\nhash = defaultdict(bool)\nans = 0\nfor i in range(123,96,-1):\n\n z = chr(i)\n # print(z)\n if z!='a':\n z1 = chr(i-1)\n for j in range(len(s)):\n if s[j] == z:\n flag = 0\n for k in range(j-1,-1,-1):\n if hash[k] == True:\n pass\n\n elif s[k] == z1:\n hash[j] = True\n flag = 1\n ans+=1\n break\n elif s[k] == z:\n pass\n else:\n break\n if not flag:\n for k in range(j+1,len(s)):\n if hash[k] == True:\n pass\n\n elif s[k] == z1:\n hash[j] = True\n ans+=1\n flag = 1\n break\n\n elif s[k] == z:\n pass\n\n else:\n break\n\nprint(ans)\n\n\n"}, {"source_code": "#import io, os\n#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nn=int(input())\ns=list(input().strip())\nse=list(set(s))\nc=0\nse.sort(reverse=True)\nm=n\nfor j in range(len(se)):\n n=m-c\n k=1\n while k<n:\n if s[k]==se[j] :\n if ord(s[k-1])+1==ord(s[k]):\n del s[k]\n c=c+1\n n=n-1\n else:\n k=k+1\n else:\n k=k+1\n n=m-c\n for k in range(n-2,-1,-1):\n if s[k]==se[j] :\n if ord(s[k+1])+1==ord(s[k]):\n del s[k]\n c=c+1\nprint(c)\n \n \n \n\n \n "}, {"source_code": "from collections import defaultdict\n\nalpha = 'abcdefghijklmnopqrstuvwxyz'\nprev = defaultdict(int)\n\nfor i in range(1, 26):\n prev[alpha[i]] = alpha[i-1]\n\nn = int(input())\ns = list(input())\nans = 0\n\nwhile True:\n if len(s)==1:\n break\n \n rem_idx = -1\n \n for i in range(25, 0, -1):\n for j in range(len(s)):\n if s[j]==alpha[i]:\n if j==0:\n if s[j+1]==prev[s[j]]:\n rem_idx = j\n break\n elif j==len(s)-1:\n if s[j-1]==prev[s[j]]:\n rem_idx = j\n break\n else:\n if s[j-1]==prev[s[j]] or s[j+1]==prev[s[j]]:\n rem_idx = j\n break\n else:\n continue\n break\n \n if rem_idx==-1:\n break\n \n ans += 1\n s = [s[i] for i in range(len(s)) if i!=rem_idx]\n\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\n\nl = []\nfor i in range(n):\n\tt = ord(s[i])\n\tif t not in l:\n\t\tl.append(t)\n\nl.sort(reverse = True)\n\nc = 0\n\nwhile len(l) > 1:\n\tj = 0\n\tf = False\n\twhile j < len(s):\n\t\tif ord(s[j]) == (l[0]):\n\t\t\tif j == 0:\n\t\t\t\tif ord(s[1]) == l[0] - 1:\n\t\t\t\t\ts = s[1:]\n\t\t\t\t\tc += 1\n\t\t\t\t\tf = True\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telif j == len(s) - 1:\n\t\t\t\tif ord(s[len(s) - 2]) == l[0] - 1:\n\t\t\t\t\ts = s[:len(s) - 1]\n\t\t\t\t\tc += 1\n\t\t\t\t\tf = True\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telse:\n\t\t\t\tif ord(s[j + 1]) == l[0] - 1 or ord(s[j - 1]) == l[0] - 1:\n\t\t\t\t\ts = s[:j] + s[j + 1:]\n\t\t\t\t\tc += 1\n\t\t\t\t\tf = True\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\telse:\n\t\t\tj += 1\n\tif not f:\n\t\tl.pop(0)\n\nprint(c)"}, {"source_code": "n=int(input())\nS=[\"#\"]+list(input())+[\"#\"]\n\nANS=0\nfor i in range(25,-1,-1):\n j=0\n while j<len(S):\n if j<len(S) and ord(S[j])-97==i and (ord(S[j-1])-97==i-1 or ord(S[j+1])-97==i-1):\n ANS+=1\n S.pop(j)\n j-=1\n else:\n j+=1\nprint(ANS)\n \n"}, {"source_code": "n = int(input())\ns = input()\ni=0\na = 'a'\nind = -1\nf = True\n#print(ord(a),ord('z'))\nwhile f:\n\tind = -1\n\ta='a'\n\ti=0\n\twhile i < len(s) :\n\t\tif i == 0:\n\t\t\tif len(s) >= 2: \n\t\t\t\tif ord(s[i]) == ord(s[i+1])+1:\n\t\t\t\t\tif ord(a) < ord(s[i]):\n\t\t\t\t\t\ta = s[i]\n\t\t\t\t\t\tind = i\n\t\telif i == len(s)-1 and len(s) >= 2:\n\t\t\tif ord(s[i]) == ord(s[i-1])+1:\n\t\t\t\tif ord(a) < ord(s[i]):\n\t\t\t\t\ta = s[i]\n\t\t\t\t\tind = i\n\t\telse:\n\t\t\tif ord(s[i]) == ord(s[i-1])+1 or ord(s[i]) == ord(s[i+1])+1:\n\t\t\t\tif ord(a) < ord(s[i]):\n\t\t\t\t\ta = s[i]\n\t\t\t\t\tind = i\n\t\ti += 1\n\t#print(a,ind)\n\tif ind != -1:\n\t\tif ind+1 != len(s):\n\t\t\ts = s[0:ind] + s[ind+1:]\n\t\telse:\n\t\t\ts = s[0:ind]\n\t\t#print(s)\n\telse:\n\t\tf = False\nprint(n - len(s))\n\n\n"}, {"source_code": "import time\nstartTimeProblem=time.time()\n\nimport fileinput, sys, itertools, functools\nfrom math import *\nfrom bisect import *\nfrom heapq import *\nfrom collections import *\n\ndef lcm(a, b): \n return (a*b)/gcd(a, b)\n\nclass InputHelper:\n def __init__(self):\n self.myinput = fileinput.input()\n\n def isLocal(self):\n return not fileinput.isstdin()\n\n def int(self):\n return int(self.myinput.readline().rstrip())\n\n def ints(self):\n return [int(_) for _ in self.myinput.readline().rstrip().split()]\n\n def str(self):\n return self.myinput.readline().rstrip()\n\n def strs(self):\n return [_ for _ in self.myinput.readline().rstrip().split()]\n\nclass OutputHelper:\n def int(self, a):\n print(a) \n\n def ints(self, a): \n print(\" \".join([str(_) for _ in a]))\n \n def intsNL(self, a):\n for _ in a:\n print(_)\n \n def str(self, s):\n print(s)\n\n def strs(self, s):\n print(\" \".join([_ for _ in s]))\n\n def strsNL(self, s):\n for st in s:\n print(st)\n\nclass ListNode:\n def __init__(self, val):\n self.val = val\n self.next = None\n self.prev = None\n\nIn = InputHelper()\nOut = OutputHelper()\n\n######################################\n\nn = In.int()\ns = In.str()\n\nans = 0\nfor i in range(25, 0, -1):\n c = chr(i+ord('a'))\n prev = chr(i+ord('a')-1)\n\n j = len(s)-1\n while j>=0:\n if s[j]==c:\n fitRight = j<len(s)-1 and s[j+1] == prev\n fitLeft = j>0 and s[j-1] == prev\n\n if fitRight or fitLeft:\n s = s[0:j] + s[j+1::]\n ans+=1\n\n if j!=len(s):\n j+=1\n\n j-=1\n\n \nOut.int(ans)\n\n######################################\n\nif len(sys.argv)>2 and sys.argv[2]==\"TIMEIT\":\n fin = (time.time()-startTimeProblem)*1000\n print(\"{:.2f}\".format(fin) + \"ms\")"}, {"source_code": "import functools\n\ns_len = int(input())\ns = input()\nassert len(s) == s_len\n\ndef adj(a, b):\n return abs(ord(a) - ord(b)) == 1\n\n@functools.lru_cache(maxsize=None)\ndef max_moves(string):\n if len(string) <= 1: return 0\n\n if len(string) == 2:\n if adj(string[0], string[1]):\n return 1\n else:\n return 0\n\n split, c = max(enumerate(string), key=lambda x: x[1])\n split_end = split+1\n while split_end < len(string) and string[split_end] == c:\n split_end += 1\n\n if (split != 0 and adj(string[split-1], c)) or (split_end != len(string) and adj(string[split_end], c)):\n with_split = (split_end-split) + max_moves(string[:split] + string[split_end:])\n else:\n with_split = -1\n\n no_split = max_moves(string[:split]) + max_moves(string[split+1:])\n\n return max(with_split, no_split)\n\nprint(max_moves(s))\n"}, {"source_code": "import sys\ndef maxremovable(s):\n mx=-1\n for i in range(len(s)):\n if i-1>=0 and ord(s[i])-ord(s[i-1])==1:\n if mx==-1:\n mx=i\n elif s[mx]<s[i]:\n mx=i\n if i+1<len(s) and ord(s[i])-ord(s[i+1])==1:\n if mx==-1:\n mx=i\n elif s[mx]<s[i]:\n mx=i\n return mx\n \ndef ip():\n\n n=sys.stdin.readline()\n s=sys.stdin.readline()\n ct=0\n while True:\n mx=maxremovable(s)\n if mx==-1:\n break\n ct+=1\n s=s[:mx]+s[mx+1:]\n print(ct)\nip()"}, {"source_code": "n = int(input())\ns = list(input())\nfor i in range(n):\n l = []\n for j in range(len(s)):\n if j>0 and ord(s[j])==ord(s[j-1])+1:\n l.append([s[j],j])\n if j<len(s)-1 and ord(s[j])==ord(s[j+1])+1:\n l.append([s[j],j])\n \n if (len(l)==0):\n break\n l.sort()\n \n \n s1 = ''\n for i in range(len(s)):\n if (i==l[-1][1]):\n continue\n s1+=s[i]\n s = s1[:]\na = ''\nfor i in s:\n if (ord(i)==13):\n continue\n a+=i\n\nprint(n-len(a))"}, {"source_code": "#for _ in range(int(input())):\nimport math \nn = int(input())\ns = list(input())\n\n\nfor i in range(26):\n t = 122-i\n j = 0\n for k in range(len(s)):\n for j in range(len(s)):\n if ord(s[j]) == t:\n if j>0 and ord(s[j-1]) == t-1:\n s.pop(j)\n break\n\n elif j<len(s)-1 and ord(s[j+1]) == t-1:\n s.pop(j)\n break\n #print(s)\n\n#print(s)\nprint(n-len(s))\n \n\n\n\n\n\n \n\n"}, {"source_code": "import sys\nimport math\nimport heapq\nimport collections\nfast_reader = sys.stdin.readline\nfast_writer = sys.stdout.write\ndef input():\n\treturn fast_reader().strip()\ndef print(*argv):\n\tfast_writer(' '.join((str(i)) for i in argv))\n\tfast_writer('\\n')\ndef printspace(*argv):\n\tfast_writer(' '.join((str(i)) for i in argv))\n\tfast_writer(' ')\ndef inputnum():\n return(int(input()))\ndef inputnums():\n return(map(int,input().split()))\ndef inputlist():\n return(list(map(int,input().split())))\ndef inputstring():\n return([x for x in input()])\ndef inputmatrixchar(rows):\n arr2d = [[j for j in input().strip()] for i in range(rows)] \n return arr2d\ndef inputmatrixint(rows):\n arr2d = []\n for _ in range(rows):\n arr2d.append([int(i) for i in input().split()])\n return arr2d\n \nn = inputnum()\ns = [ord(x)-ord('a') for x in input()]\nt = sorted(s, reverse = True)\nfor i in t:\n l=len(s)\n if l==1:break\n for j in range(l):\n if s[j] == i:\n if j==0:\n if abs(s[1]-i)==1:\n s.pop(j)\n break\n elif j==l-1:\n if abs(s[l-2]-i)==1:\n s.pop(j)\n break\n elif abs(s[j-1]-i)==1 or abs(s[j+1]-i)==1:\n s.pop(j)\n break\nprint(n - len(s))"}, {"source_code": "n, s = int(input()), input()\nfor i in range(25):\n while 1:\n ch, pch = chr(ord('z')-i), chr(ord('z')-i-1)\n ns = \"\"\n for p, c in enumerate(s):\n if (c == ch and\n ((p > 0 and s[p-1] == pch) or (p < len(s)-1 and s[p+1] == pch))):\n continue\n ns += s[p]\n if s == ns: break\n s = ns\n\nprint(n-len(s))\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=998244353\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\n# vsInput()\n\nN=Int()\ns=list(input())\na=[]\nremoved=0\n\nfor ind in range(25,-1,-1):\n char=ALPHA[ind]\n prev=ALPHA[ind-1]\n if(prev=='z'): prev='/'\n \n i=0\n last='\\\\'\n a=[]\n n=len(s)\n\n # print(s,char,removed,prev)\n\n while(i<len(s)):\n\n if(s[i]!=char):\n a.append(s[i])\n last=s[i]\n i+=1\n else:\n c=1\n start=i\n i+=1\n while(i<n and s[i]==char):\n i+=1\n c+=1\n if(last==prev) or (i<n and s[i]==prev):\n removed+=c\n else:\n last=char\n a.extend([char]*c)\n\n s=a[::]\n\n\nprint(removed)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "}, {"source_code": "\ndef solve_test_case(t):\n n = int(input())\n s = str(input())\n\n res = 0\n\n removed = True\n\n while removed:\n removed = False\n for ci in reversed(range(26)):\n # print(s)\n c = chr(ord('a') + ci)\n # print(c)\n prev_c = chr(ord('a') + ci-1)\n # print(prev_c)\n new_s = []\n for i in range(len(s)):\n if s[i] == c:\n if i > 0 and s[i-1] == prev_c:\n res += 1\n removed = True\n s = s[:i] + s[i+1:]\n break\n if i < (len(s) -1) and s[i+1] == prev_c:\n res += 1\n removed = True\n s = s[:i] + s[i+1:]\n break\n\n if removed:\n break\n\n\n\n # for ci in reversed(range(26)):\n # # print(s)\n # c = chr(ord('a') + ci)\n # # print(c)\n # prev_c = chr(ord('a') + ci-1)\n # # print(prev_c)\n # new_s = []\n # for i in range(len(s)):\n # if s[i] == c:\n # if len(new_s) > 0 and new_s[-1] == prev_c:\n # res += 1\n # continue\n # if i < (len(s) -1) and s[i+1] == prev_c:\n # res += 1\n # continue\n # new_s.append(s[i])\n # s = \"\".join(new_s)\n print(res)\n\ndef parse_array(f):\n return list(map(f, input().split()))\n\ndef solve():\n T = int(input())\n\n for t in range(T):\n solve_test_case(t)\n\nif __name__ == \"__main__\":\n solve_test_case(0)\n"}, {"source_code": "n = int(input())\ns = input()\n \n \nfor i in range(25):\n ch = chr(ord('z') - i)\n prev = chr(ord(ch) - 1)\n j = 0\n while j < len(s):\n if s[j] == ch and (j-1 >= 0 and s[j-1] == prev or j+1 < len(s) and s[j+1] == prev):\n s = s[:j] + s[(j+1):]\n j = 0\n else:\n j+=1\n \nprint(n-len(s))"}, {"source_code": "def solve(n, s):\n alphabet = \"zyxwvutsrqponmlkjihgfedcba\"\n for i, c in enumerate(alphabet):\n if c == 'a':\n continue\n nxt = alphabet[i+1]\n cnt = s.count(c)\n for _ in range(cnt):\n for j, v in enumerate(s):\n if c != v or len(s) == 1:\n continue\n if j == 0:\n if s[j+1] == nxt:\n s.pop(j)\n elif j == len(s)-1:\n if s[j-1] == nxt:\n s.pop(j)\n elif s[j+1] == nxt or s[j-1] == nxt:\n s.pop(j)\n print(n - len(s))\n\n\ndef main():\n n = int(input())\n s = input()\n solve(n, list(s))\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "n = int(input())\nb = [i for i in map(ord, input())]\n\nfor i in range(max(b), min(b), -1):\n while True and len(b) > 1:\n idx = []\n\n if b[0] == b[1] + 1 and b[0] == i:\n idx.append(0)\n\n for j in range(1, len(b)-1):\n # print(i, j, b[j], b[j-1], b[j] == i and (b[j] == b[j-1] + 1 or b[j] == b[j+1] + 1))\n if b[j] == i and (b[j] == b[j-1] + 1 or b[j] == b[j+1] + 1):\n idx.append(j)\n\n if b[-1] == b[-2] + 1 and b[-1] == i:\n idx.append(len(b)-1)\n \n if len(idx) == 0:\n break\n\n for j in range(len(idx)):\n del b[idx[j]-j]\n # print(idx, b, len(b))\n\nprint(n - len(b))\n "}, {"source_code": "n = int(input())\nx = list(input())\ny = len(x)\nabc = list(\"abcdefghijklmnopqrstuvwxyz\")\npre = list(\"0abcdefghijklmnopqrstuvwxy\")\nfor i in range(1, len(abc)):\n s = 0\n while s < len(x):\n if x[s] == abc[-i]:\n if (s-1) >= 0 and x[s-1] == pre[-i]:\n del x[s]\n s -= 1\n elif s + 1 < len(x) and x[s+1] == pre[-i]:\n del x[s]\n if s > 0:\n s -= 2\n else:\n s -= 1\n s += 1\nanswer = y - len(x)\nprint(answer)\n"}, {"source_code": "import sys\nn=int(sys.stdin.readline())\nrem=n\ns=sys.stdin.readline()[:-1]\nz=True\nprev = '.'\nwhile z:\n #print(s,'s')\n prev='.'\n ind = -1\n n = len(s)\n for i in range(n):\n if i-1>=0:\n if ord(s[i])-ord(s[i-1]) == 1:\n if ord(s[i]) > ord(prev):\n prev = s[i]\n ind = i\n if i+1<n:\n if ord(s[i])-ord(s[i+1])==1:\n if ord(s[i])>ord(prev):\n prev=s[i]\n ind=i\n new_s=s[:ind]+s[ind+1:]\n if ind==-1:\n z=False\n else:\n s=new_s\nprint(rem-len(s))\n \n"}, {"source_code": "#from bisect import bisect_left as bl #c++ lowerbound bl(array,element)\n#from bisect import bisect_right as br #c++ upperbound br(array,element)\n#from __future__ import print_function, division #while using python2\n\n\ndef modinv(n,p):\n return pow(n,p-2,p)\n\ndef is_next_inc(x, y):\n if x == 'z':\n return False\n return y == chr(ord(x) + 1)\n\ndef is_next_dec(x, y):\n if x == 'a':\n return False\n return y == chr(ord(x) - 1)\n\ndef main():\n #sys.stdin = open('input.txt', 'r')\n #sys.stdout = open('output.txt', 'w')\n\n l = int(input())\n s = input()\n\n while True:\n n = len(s)\n max_char = 'a'\n max_char_ind = -1\n for i in range(n):\n if i > 0 and (is_next_inc(s[i], s[i-1]) or is_next_dec(s[i], s[i-1])):\n if ord(s[i]) >= ord(max_char):\n max_char_ind = i \n max_char = s[i]\n if i < n-1 and (is_next_inc(s[i], s[i+1]) or is_next_dec(s[i], s[i+1])):\n if ord(s[i]) >= ord(max_char):\n max_char_ind = i \n max_char = s[i]\n if max_char_ind == -1:\n break\n s = s[:max_char_ind] + s[max_char_ind+1:]\n # print(max_char, s)\n # input()\n\n\n print(l -len(s))\n\n#------------------ Python 2 and 3 footer by Pajenegod and c1729-----------------------------------------\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin\nfrom collections import defaultdict\n#####################################################################\ndef iinput(): return int(stdin.readline())\ndef sinput(): return input()\ndef minput(): return map(int, stdin.readline().split())\ndef linput(): return list(map(int, stdin.readline().split()))\n#####################################################################\n\nn = iinput()\ns = sinput()\nl = list(set(s))\nl.sort(reverse=True)\nif l[-1] == 'a': l.pop()\ns = list(s)\nans = 0\n# print(l, s)\nfor c in l:\n i = 0\n while i<len(s):\n try:\n if (i>0 and s[i]==c and s[i-1] == chr(ord(c)-1)) or (i<len(s)-1 and s[i]==c and s[i+1] == chr(ord(c)-1)):\n ans += 1\n s.pop(i)\n i-=1\n else:\n i+=1\n except: i+=1\nprint(ans)\n\n"}, {"source_code": "n = int(input())\ns = input()\nans = 0\nmaxs = max(s)\nnow = 0\nwhile(ord(maxs) > ord('a')):\n pos = s.find(maxs, now)\n if(pos != -1):\n if((pos - 1 >= 0 and ord(s[pos - 1]) == ord(maxs) - 1) or (pos + 1 < len(s) and ord(s[pos + 1]) == ord(maxs) - 1)):\n s = s[0:pos] + s[pos + 1:len(s)]\n now = 0\n ans += 1\n else:\n now = pos + 1\n else:\n maxs = chr(ord(maxs) - 1)\n now = 0\nprint(ans)\n\n\n\n\n\n"}, {"source_code": "import sys\nreader = (s.rstrip() for s in sys.stdin)\ninput = reader.__next__\n\n\nif __name__ == '__main__':\n t= int(input())\n word=input()\n res=0\n for ordi in range(25):\n \n ordinit=122-ordi\n while True:\n n=len(word)\n toremove=[]\n if n==1:\n break\n for i in range(n):\n #print(toremove,ord(word[i]))\n if ord(word[i])==ordinit:\n if i==0:\n if ord(word[i])==ord(word[i+1])+1:\n \n if not toremove or toremove[-1]!=i:\n \n \n toremove.append(i)\n elif i==n-1:\n if ord(word[i])==ord(word[i-1])+1:\n \n if not toremove or toremove[-1]!=i:\n \n\n toremove.append(i)\n else:\n if ord(word[i])==ord(word[i+1])+1 or ord(word[i])==ord(word[i-1])+1:\n\n if not toremove or toremove[-1]!=i:\n \n toremove.append(i)\n \n res+=len(toremove)\n if not toremove:\n break\n counter=0\n for i in toremove:\n \n word=word[:(i-counter)]+word[(i-counter)+1:]\n counter+=1\n #print(word)\n #print(toremove,word)\n print(res)\n\n \n"}, {"source_code": "def rem(l,n):\n remo = []\n for i in range(1,n+1):\n if l[i]==l[i-1]+1 or l[i]==l[i+1]+1:\n remo.append((l[i],i))\n remo.sort()\n return remo\n\nn = int(input())\nl = [ord(i) for i in (\"$\"+input()+\"$\")]\nremoved = rem(l,n)\nx = 0\nwhile removed:\n l.pop(removed[-1][1])\n x+=1\n removed=rem(l,n-x)\nprint(x)"}, {"source_code": "n = int(input())\ns = input()\nrm = 0\nwhile(True):\n\tnew_s = []\n\tn = len(s)\n\trm_ls = []\n\tfor i in range(n):\n\t\tnb = (max(0, i-1), min(n-1, i+1))\n\t\t# print(chr(ord(s[i])), ord(s[i]))\n\t\tif s[nb[0]]==chr(ord(s[i])-1) or s[nb[1]]==chr(ord(s[i])-1):\n\t\t\trm_ls.append(i)\n\t# print(rm_ls, rm, s)\n\tif rm_ls:\n\t\tmx = max(zip(map(lambda x : s[x], rm_ls), rm_ls))[1]\n\telse:\n\t\tbreak\n\tnew_s = s[:mx]+s[mx+1:]\n\t# print(rm_ls, mx, s[mx], s)\n\trm+=1\n\ts = new_s\n\tif new_s=='':\n\t\tbreak\nprint(rm)\n"}, {"source_code": "lengthofstring=int(input())\nstring1=[ord(k)-97 for k in input()]\ntraverse1=list(range(26))\ntraverse1=traverse1[::-1]+[]\nmaxinstring=max(string1)\nanswer=0\nfor k in range(26):\n letter=traverse1[k]\n if letter<=maxinstring:\n cv=0\n #the forward loop\n while cv<=len(string1)-1 and len(string1)>=2:\n if string1[cv]==letter:\n if cv>=1 and cv<=len(string1)-2:\n if string1[cv-1]==letter-1 or string1[cv+1]==letter-1:\n string1.pop(cv)\n answer+=1\n else:\n cv+=1\n elif cv==0:\n if string1[cv+1]==letter-1:\n string1.pop(cv)\n answer+=1\n else:\n cv+=1\n elif cv==len(string1)-1:\n if string1[cv-1]==letter-1:\n string1.pop(cv)\n answer+=1\n else:\n cv+=1\n else:\n cv+=1\n else:\n cv+=1\n #now the backward loop\n cv1=len(string1)-1\n while cv1>=0 and len(string1)>=2:\n if string1[cv1]==letter:\n if cv1>=1 and cv1<=len(string1)-2:\n if string1[cv1-1]==letter-1 or string1[cv1+1]==letter-1:\n string1.pop(cv1)\n answer+=1\n else:\n cv1+=-1\n elif cv1==0:\n if string1[cv1+1]==letter-1:\n string1.pop(cv1)\n answer+=1\n else:\n cv1+=-1\n elif cv==len(string1)-1:\n if string1[cv1-1]==letter-1:\n string1.pop(cv1)\n answer+=1\n else:\n cv1+=-1\n else:\n cv1+=-1\n else:\n cv1+=-1\nprint(answer)"}, {"source_code": "n=int(input())\nf=input()\nd=set()\nfor i in f:\n d.add(i)\nd=sorted(list(d))\nx = len(d)\ncount=0\nx1=len(f)\ni=x-1\nwhile i>=0:\n flag=0\n if count +1 == x1:\n break\n ut=0\n rty=x1-1-count\n for j in range(1, rty):\n if f[j-ut]==d[i] and (ord(f[j-ut])-ord(f[j-1-ut])==1 or ord(f[j-ut])-ord(f[j+1-ut])==1):\n count+=1\n f=f[:j-ut]+f[j+1-ut:]\n ut+=1\n flag=1\n if f[0]==d[i] and ord(f[0])-ord(f[1])==1:\n count+=1\n f=f[1:]\n flag=1\n if f[-1]==d[i] and ord(f[-1])-ord(f[-2])==1:\n count+=1\n flag=1\n f=f[:-1]\n i-=1\n i+=flag\nprint(count)"}, {"source_code": "import copy;\ndef function(s,c):\n flag=True;\n while(flag):\n ts = \"\";\n for i in range(len(s)):\n if(s[i]==c):\n if(s[max(0,i-1)]==chr(ord(c)-1) or s[min(len(s)-1,i+1)]==chr(ord(c)-1)):\n ts+='';\n else:\n ts+=s[i];\n else:\n ts+=s[i];\n if(ts==s):\n flag=False;\n else:\n s=ts;\n return s;\nn = int(input());\ns = input();\nfor i in range(26):\n #print(s,i)\n s = function(s,chr(122-i));\n #print(s,i)\nprint(n-len(s))\n"}, {"source_code": "import sys\nimport math\nread = lambda: list(map(int, sys.stdin.readline().strip().split()))\n\nn = int(input())\ns = input()\na = []\nfor i in range(n):\n a.append(s[i])\nmark = [0]*26\nfor num in a:\n mark[ord(num)-97] += 1\ncur = 25\nflag = True\nwhile len(a) > 1:\n if cur > 0 and mark[cur] == 0:\n while cur > 0 and mark[cur] == 0:\n cur -= 1\n if cur == 0:\n break\n i = 0\n while i < len(a):\n if ord(a[i]) - 97 == cur:\n if i == 0:\n if ord(a[i]) - ord(a[i+1]) == 1:\n del a[i]\n mark[cur] -= 1\n else:\n i += 1\n elif i == len(a) - 1:\n if ord(a[i]) - ord(a[i-1]) == 1:\n mark[cur] -= 1\n del a[i]\n else:\n i += 1\n else:\n if ord(a[i]) - ord(a[i-1]) == 1 or ord(a[i]) - ord(a[i+1]) == 1:\n mark[cur] -= 1\n del a[i]\n else:\n i += 1\n else:\n i += 1\n i = len(a) - 1\n while i >= 0 and mark[cur] > 0:\n if ord(a[i]) - 97 == cur:\n mark[cur] -= 1\n if i == 0:\n if ord(a[i]) - ord(a[i+1]) == 1:\n del a[i]\n else:\n i -= 1\n elif i == len(a) - 1:\n if ord(a[i]) - ord(a[i-1]) == 1:\n del a[i]\n else:\n i -= 1\n else:\n if ord(a[i]) - ord(a[i-1]) == 1 or ord(a[i]) - ord(a[i+1]) == 1:\n del a[i]\n else:\n i -= 1\n else:\n i -= 1\n #print(a)\nprint(n-len(a))\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import re\n\nn, s = int(input()), input()\ncurrent = ord(\"z\")\nwhile (current - ord(\"a\")) > 0:\n previous = chr(current - 1)\n pattern = chr(current) + \"*\" + previous + chr(current) + \"*\"\n s = re.sub(pattern, previous, s)\n current -= 1\nprint(n - len(s)) "}, {"source_code": "n=int(input())\ns=(str(input()))\ns=list(\"$\"+s+\"$\")\nchar=[]\nfor i in s:\n char.append(ord(i))\nremovable=[]\nz=len(char)\nfor i in range(1,n+1):\n # print(i)\n if char[i]==char[i-1]+1 or char[i]==char[i+1]+1:\n removable.append((char[i],i))\nwhile len(removable)>0:\n removable.sort()\n char.pop(removable[-1][1])\n removable=[]\n for i in range(1, len(char)-1 ):\n if char[i] == char[i - 1] + 1 or char[i] == char[i + 1] + 1:\n removable.append((char[i], i))\nprint(z-2-(len(char)-2))\n\n\n"}, {"source_code": "n=int(input())\ns=list(input()) \ndef recursion(s,target=chr(ord('a')+25)):\n if target=='a':\n return 0 \n else:\n count=0\n stack=[] \n hunterr=chr(ord(target)-1)\n \n for i in s:\n if not stack:\n stack.append(i) \n elif i==hunterr and stack[-1]==target:\n while stack and stack[-1]==target:\n stack.pop()\n count+=1 \n stack.append(i)\n elif i==target and stack[-1]==hunterr:\n count+=1 \n else:\n stack.append(i) \n return count+recursion(stack,hunterr)\nprint(recursion(s))\n \n "}, {"source_code": "import atexit\nimport io\nimport sys\nimport math\nfrom collections import defaultdict,Counter\n\n# _INPUT_LINES = sys.stdin.read().splitlines()\n# input = iter(_INPUT_LINES).__next__\n# _OUTPUT_BUFFER = io.StringIO()\n# sys.stdout = _OUTPUT_BUFFER\n\n# @atexit.register\n# def write():\n# sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\n\n# sys.stdout=open(\"CP3/output.txt\",'w')\n# sys.stdin=open(\"CP3/input.txt\",'r')\n\n# m=pow(10,9)+7\nn=int(input())\ns=list(input())\nif n==1:\n print(0)\nelse:\n # s1=s[:]\n for j in range(122,97,-1):\n k=0\n while k<len(s) and len(s)>1:\n if s[k]==chr(j-1):\n if k==0:\n if s[1]==chr(j):\n del(s[1])\n else:\n k+=1\n elif k==len(s)-1:\n if s[-2]==chr(j):\n del(s[-2])\n k-=1\n else:\n k+=1\n else:\n if s[k+1]==chr(j):\n del(s[k+1])\n elif s[k-1]==chr(j):\n del(s[k-1])\n k-=1\n else:\n k+=1\n else:\n k+=1\n if len(s)==1:\n break\n print(n-len(s))\n"}, {"source_code": "# Legends Always Come Up with Solution\n# Author: Manvir Singh\n\nimport os\nfrom io import BytesIO, IOBase\nimport sys\nfrom collections import defaultdict,deque,Counter\nfrom bisect import *\nfrom math import sqrt,pi,ceil,log,inf\nfrom itertools import permutations\nfrom copy import deepcopy\nfrom heapq import *\nfrom sys import setrecursionlimit\n\ndef main():\n n=int(input())\n a=list(map(lambda x:ord(x)-97,input().rstrip()))\n if n==1:\n print(0)\n else:\n for i in range(25,0,-1):\n j=0\n while j<len(a):\n f=1\n if a[j]==i:\n if j==0 and len(a)!=1:\n if a[0]-1==a[1]:\n a.pop(0)\n elif j==len(a)-1:\n if a[j]-1==a[j-1]:\n a.pop()\n elif j>0 and j<len(a)-1:\n if a[j]-1==a[j+1] or a[j-1]==a[j]-1:\n f=0\n a.pop(j)\n j=j+1 if f else -1\n print(n-len(a))\n\n# region fastio\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = int(input())\ns = list(input())\nd = {}\nalp = \"abcdefghijklmnopqrstuvwxyz\"\nc = 0\nfor i in range(26):\n\td[alp[i]] = i\nl = []\nmi = d[s[0]]\nfor i in range(n):\n\tl.append(d[s[i]])\n\tif l[i] < mi:\n\t\tmi = l[i]\nidx = 25\nwhile idx != 0:\n\tif len(l) == 1:\n\t\tbreak\n\telse:\n\t\twhile True:\n\t\t\tcount = 0\n\t\t\tfor i in range(len(l)):\n\t\t\t\tif l[i] == idx:\n\t\t\t\t\tif i == 0:\n\t\t\t\t\t\tif l[1] == idx-1:\n\t\t\t\t\t\t\tl.pop(i)\n\t\t\t\t\t\t\tcount+=1\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\telif i == len(l)-1:\n\t\t\t\t\t\tif l[len(l)-2] == idx-1:\n\t\t\t\t\t\t\tl.pop(i)\n\t\t\t\t\t\t\tcount+=1\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\telse:\n\t\t\t\t\t\tif l[i+1] == idx-1 or l[i-1] == idx-1:\n\t\t\t\t\t\t\tl.pop(i)\n\t\t\t\t\t\t\tcount+=1\n\t\t\t\t\t\t\tbreak\n\t\t\tif count == 0:\n\t\t\t\tbreak\n\t\tidx-=1\nprint(n-len(l))\n\n\n\n\n"}, {"source_code": "n = int(input())\ns = input()\nalph = list(set(s))\nalph.sort(reverse=True)\ns = list(s)\nfor i in alph:\n if i == alph[-1]:\n continue\n prev = -1\n cur = len(s)\n while prev != cur:\n j = 0\n while j < len(s):\n if s[j] == i:\n if j == 0:\n if s[j + 1] == chr(ord(i) - 1):\n s.pop(j)\n elif j == len(s) - 1:\n if s[j - 1] == chr(ord(i) - 1):\n s.pop(j)\n elif cur >= 3 and (s[j - 1] == chr(ord(i) - 1) or s[j + 1] == chr(ord(i) - 1)):\n s.pop(j)\n j -= 1\n j += 1\n prev = cur\n cur = len(s)\nprint(n - len(s))\n "}, {"source_code": "import sys\ninput = sys.stdin.buffer.readline\ndef I(): return(list(map(int,input().split())))\ndef sieve(n):\n\ta=[1]*n\n\tfor i in range(2,n):\n\t if a[i]:\n\t for j in range(i*i,n,i):\n\t a[j]=0\n\treturn a\n\n\nn=int(input())\nl=list(input())[:n]\nif n>=1:\n\twhile(len(l)>1):\n\t\ta=0\n\t\tidx=-1\n\t\tf=False\n\t\tif l[0]-1==l[1]:\n\t\t\tf=1\n\t\t\tidx=0\n\t\t\ta=l[0]\n\t\t\tidx=0\n\t\t\n\t\tfor i in range(1,len(l)-1):\n\t\t\tif l[i]-l[i-1]==1 or l[i]-l[i+1]==1:\n\t\t\t\tf=True\n\t\t\t\tif l[i]>a:\n\t\t\t\t\ta=max(a,l[i])\n\t\t\t\t\tidx=i\n\t\tif l[-1]-l[-2]==1:\n\t\t\tf=True\n\t\t\tif l[-1]>a:\n\t\t\t\ta=max(a,l[-1])\n\t\t\t\tidx=-1\n\t\tif not f:break\n\t\t# print(l)\n\t\t# print(idx)\n\t\tl.pop(idx)\n# print(l)\nprint(n-len(l))\n\n\n\n\n"}, {"source_code": "n=int(input())\ns=input()\nu=ord('a')\nfor i in range(n):\n a=0\n m=0\n for j in range(len(s)):\n \n if j==0:\n if j+1<len(s) and ord(s[j])==ord(s[j+1])+1:\n if ord(s[j])>m:\n m=ord(s[j])\n a=j\n elif j==len(s)-1:\n if j-1>=0 and ord(s[j])==ord(s[j-1])+1:\n if ord(s[j])>m:\n m=ord(s[j])\n a=j\n else:\n if (j+1<len(s) and ord(s[j])==ord(s[j+1])+1) or (j-1>=0 and ord(s[j])==ord(s[j-1])+1):\n if ord(s[j])>m:\n m=ord(s[j])\n a=j\n if m==0:\n \n print(n-len(s))\n exit()\n else:\n s=s[0:a]+s[a+1:len(s)]"}, {"source_code": "n = int(input())\nu = list(input())\nlft = list(range(-1, n))\nrht = list(range(1, n)) + [-1]\nd = []\nfor i in range(97, 97 + 26):\n d.append(chr(i))\nd.reverse()\nans = 0\nfor k in range(len(d) - 1):\n for j in range(n):\n for i in range(n):\n if u[i] != d[k]:\n continue\n i1 = lft[i]\n j1 = rht[i]\n if i1 != -1 and u[i1] == d[k + 1] or\\\n j1 != -1 and u[j1] == d[k + 1]:\n u[i] = -1\n ans += 1\n if lft[i] != -1 and rht[i] != -1:\n rht[lft[i]], lft[rht[i]] = rht[i], lft[i]\n elif lft[i] != -1:\n rht[lft[i]] = rht[i]\n elif rht[i] != -1:\n lft[rht[i]] = lft[i]\n## print(*u, \"****\", d[k])\n## print(*lft)\n## print(*rht)\n## print()\n\nprint(ans)\n"}, {"source_code": "n= int(input())\na=list(input())\nfor i in range(25,0,-1):\n cur=chr(97+i);prev=chr(96+i);j=0\n while(True):\n if(j>=len(a)):\n break\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\n j-=1\n j+=1\n #print(*a)\n j=len(a)-1\n while(j>=0):\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n #print(x,j,y,len(a),a)\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\n j+=1\n j-=1\nprint(n-len(a))\n \n"}, {"source_code": "def is_right_less(s, i): \n return i+1 <len(s) and ord(s[i]) - ord(s[i+1]) == 1\n\ndef is_left_less(s, i):\n return i-1 >= 0 and ord(s[i]) - ord(s[i-1]) == 1\n\ndef check_neighbours(s, i):\n if is_left_less(s, i) or is_right_less(s, i):\n return i\n else:\n return -10\n \ndef remove_neighbors(s: str) -> int:\n s = list(s)\n removed = 0\n while len(s) != 0: # O(n)\n biggest_cand = -1\n remove_id = -1\n k = []\n for j in range(len(s)): # O(n)\n c = check_neighbours(s, j)\n if c>=0 and ord(s[c]) >= biggest_cand:\n k.append({c: s[c]})\n biggest_cand = ord(s[c])\n remove_id = c\n\n if remove_id >= 0:\n s.pop(remove_id) # O(n)\n removed += 1\n else:\n break\n \n\n return removed\n\nlen_s = int(input())\ns = input()\nprint(remove_neighbors(s))\n\n# sum = O(n(n+n)) = O(n*2n) = O(2n^2) = O(n^2)\n"}, {"source_code": "n = int(input())\ns = input()\ns = '!' + s + '!'\ncnt = 0\nif(n>1):\n for char in range(ord('z'),ord('a')-1,-1):\n i=0\n while(len(s)>0 and i<len(s)):\n if(i==0):\n if(s[i]==chr(char) and s[i]==chr(ord(s[i+1])+1)):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n elif(i==len(s)-1):\n if(s[i]==chr(char) and s[i]==chr(ord(s[i-1])+1)):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n else:\n if(s[i]==chr(char) and ((s[i]==chr(ord(s[i+1])+1)) or (s[i]==chr(ord(s[i-1])+1)) )):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n i+=1\nprint(cnt)"}, {"source_code": "n = int(input())\ns = input()\nmas = []\ncou = []\nfor i in range(n):\n\tmas.append(ord(s[i]) - ord('a'))\n\tcou.append([ord(s[i]) - ord('a'), i])\ncou.sort()\nans = 0\nwhile cou != []:\n\td = [cou[-1]]\n\tdel(cou[-1])\n\twhile cou != [] and cou[-1][0] == d[0][0]:\n\t\td.append(cou[-1])\n\t\tdel(cou[-1])\n\tf = True\n\twhile f:\n\t\tf = False\n\t\tfor i in range(len(d)):\n\t\t\tnow = d[i][1]\n\t\t\tx = mas[now]\n\t\t\tif x == -10:\n\t\t\t\tcontinue\n\t\t\tflag = False\n\t\t\tfor j in range(now - 1, -1, -1):\n\t\t\t\tif mas[j] == x - 1:\n\t\t\t\t\tflag = True\n\t\t\t\t\tbreak\n\t\t\t\telif mas[j] != -10:\n\t\t\t\t\tbreak\n\t\t\tfor j in range(now + 1, n):\n\t\t\t\tif mas[j] == x - 1:\n\t\t\t\t\tflag = True\n\t\t\t\t\tbreak\n\t\t\t\telif mas[j] != -10:\n\t\t\t\t\tbreak\n\t\t\tif flag:\n\t\t\t\tmas[now] = -10\n\t\t\t\tans += 1\n\t\t\t\tf = True\nprint (ans)\n"}, {"source_code": "n=int(input())\nf=input()\nd=set()\nfor i in f:\n d.add(i)\nd=sorted(list(d))\nx = len(d)\ncount=0\nx1=len(f)\ni=x-1\nwhile i>=0:\n flag=0\n if count +1 == x1:\n break\n ut=0\n rty=x1-1-count\n for j in range(1, rty):\n if f[j-ut]==d[i] and (ord(f[j-ut])-ord(f[j-1-ut])==1 or ord(f[j-ut])-ord(f[j+1-ut])==1):\n count+=1\n f=f[:j-ut]+f[j+1-ut:]\n ut+=1\n flag=1\n if f[0]==d[i] and ord(f[0])-ord(f[1])==1:\n count+=1\n f=f[1:]\n flag=1\n if f[-1]==d[i] and ord(f[-1])-ord(f[-2])==1:\n count+=1\n flag=1\n f=f[:-1]\n i-=1\n i+=flag\nprint(count)\n"}, {"source_code": "# import sys\n# input = lambda : sys.stdin.readline().strip()\n# for i in range(int(input())):\nn = int(input())\ns = list(input())\nG = list('abcdefghijklmnopqrstuvwxyz')\ng = {'g': 6, 'o': 14, 'b': 1, 'c': 2, 't': 19, 'y': 24, 'u': 20, 'a': 0, 'i': 8, 'k': 10, 'd': 3, 's': 18, 'n': 13,\n 'f': 5, 'j': 9, 'r': 17, 'l': 11, 'w': 22, 'x': 23, 'p': 15, 'q': 16, 'z': 25, 'm': 12, 'h': 7, 'e': 4, 'v': 21}\n\n\ndef f(a):\n if a == 'a':\n return ']'\n else:\n return G[g[a]-1]\ndef solve(s):\n if len(s)==1:\n return False\n ans = (chr(ord('a')-1),-1)\n a = f(s[0])\n if s[1] == a:\n ans = max(ans, (s[0], 0))\n a = f(s[-1])\n if s[-2] == a:\n ans = max(ans, (s[-1], len(s)-1))\n for i in range(len(s) - 2):\n a = f(s[i+1])\n if s[i]==a:\n ans = max(ans,(s[i+1],i+1))\n if s[i+2]==a:\n ans = max(ans, (s[i+1], i+1))\n if ans[1]==-1:\n return False\n del s[ans[1]]\n return True\nk= 0\nwhile solve(s):\n k+=1\nprint(k)"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n print(0)\n exit()\n\nl = []\nfor i in s:\n l.append(ord(i)-97)\n\nf = 1\nwhile f:\n o = []\n m = -1\n d = -1\n i = 0\n f = 0\n if len(l) == 1:\n break\n\n while i < len(l):\n if i == 0:\n if l[i]-1 == l[i+1]:\n if l[i] > m:\n f = 1\n m = l[i]\n d = i\n\n i = i + 1\n continue\n\n if i == len(l)-1:\n if l[i]-1 == l[i-1]:\n if l[i] > m:\n f = 1\n m = l[i]\n d = i\n\n i = i+1\n continue\n\n if l[i]-1 == l[i-1] or l[i]-1 == l[i+1]:\n if l[i] > m:\n f = 1\n m = l[i]\n d = i\n\n i = i+1\n\n for i in range(len(l)):\n if i == d:\n continue\n\n o.append(l[i])\n\n l = o\n\nprint(n-len(l))"}, {"source_code": "n = int(input())\nar = [ord(x)-97 for x in input()]\nans = 0\nflag = True\nwhile flag:\n temp = -1\n ind = -1\n for k in range(1,len(ar)-1):\n if (ar[k] == ar[k-1]+1 or ar[k] == ar[k+1]+1) and ar[k] > temp:\n ind = k\n temp = ar[k]\n if len(ar) > 1 and ar[0] == ar[1]+1 and ar[0] > temp:\n ind = 0\n temp = ar[0]\n if len(ar) > 1 and ar[-1] == ar[-2]+1 and ar[-1] > temp:\n ind = len(ar)-1\n temp = ar[-1]\n\n if temp != -1:\n ar = ar[:ind]+ar[ind+1:]\n ans += 1\n else:\n flag = False\nprint(ans)\n"}, {"source_code": "def previous_char(x, y):\n return ord(x) + 1 == ord(y)\n\nn = int(input().strip())\ns = list(input().strip())\nss = list(reversed(sorted([(s[i], i) for i in range(len(s))])))\ni = 0\nwhile i < len(ss):\n max_index = ss[i][1]\n if (max_index + 1 < len(s) and previous_char(s[max_index + 1], s[max_index])) or\\\n (max_index > 0 and previous_char(s[max_index - 1], s[max_index])):\n s = s[:max_index] + s[max_index+1:]\n ss = list(reversed(sorted([(s[i], i) for i in range(len(s))])))\n i = 0\n else:\n i += 1\nprint(n - len(s))"}, {"source_code": "from math import *\nimport sys\nfrom queue import *\n\n\nn = int(input())\ns = input()\na = [0]\nfor c in s:\n a.append(ord(c))\na.append(10000)\nf = True\nans = 0\nwhile f:\n f = False\n mx = 0\n ind = -1\n for i in range(1, len(a) - 1):\n if (a[i] - 1 == a[i - 1] or a[i] - 1 == a[i + 1]) and mx < a[i]:\n mx = a[i]\n f = True\n ind = i\n if f:\n ans += 1\n a = a[:ind] + a[ind + 1:]\nprint(ans)\n \n"}, {"source_code": "from collections import Counter, OrderedDict\nfrom itertools import permutations as perm\nfrom collections import deque\nfrom sys import stdin\nfrom bisect import *\nfrom heapq import *\nimport math\n\ng = lambda : stdin.readline().strip()\ngl = lambda : g().split()\ngil = lambda : [int(var) for var in gl()]\ngfl = lambda : [float(var) for var in gl()]\ngcl = lambda : list(g())\ngbs = lambda : [int(var) for var in g()]\nmod = int(1e9)+7\ninf = float(\"inf\")\n\t\nn, = gil()\n\ns = gcl()\n\n\nwhile s:\n\trem = None\n\tfor i in range(len(s)):\n\t\tif i and ord(s[i-1]) + 1 == ord(s[i]):\n\t\t\tif rem is None :\n\t\t\t\trem = i\n\t\t\telif s[rem] < s[i]: rem = i\n\t\tif i+1 < len(s) and ord(s[i+1]) + 1 == ord(s[i]):\n\t\t\tif rem is None :\n\t\t\t\trem = i\n\t\t\telif s[rem] < s[i]: rem = i\n\tif rem is None:\n\t\tbreak\n\telse:\n\t\ts.pop(rem)\n\n# print(s)\nprint(n-len(s))"}, {"source_code": "from math import *\n# from sys import stdin,stdout\n\ndef binarySearch(arr,x,i):\n\tl=i\n\tr=len(arr)-1 \n\twhile l <= r: \n\t\tmid = (l + r)//2; \n\t\tif arr[mid] == x: \n\t\t\treturn mid \n\t\telif arr[mid] < x: \n\t\t\tl = mid + 1\n\t\telse: \n\t\t\tr = mid - 1\n\treturn -1\n\ndef js(arr,x):\n\tl=0\n\tr=len(arr)-1\n\tans=-1\n\twhile(l<=r):\n\t\tm=(l+r)//2\n\t\tif(arr[m]<=x):\n\t\t\tans=m\n\t\t\tl=m+1\n\t\telse:\n\t\t\tr=m-1\n\treturn ans\n\ndef jg(arr,x):\n\tl=0\n\tr=len(arr)-1\n\tans=-1\n\twhile(l<=r):\n\t\tm=(l+r)//2\n\t\tif(arr[m]>=x):\n\t\t\tans=m\n\t\t\tr=m-1\n\t\telse:\n\t\t\tl=m+1\n\treturn ans\n\n# def ceil(a,b):\n# \tif a%b == 0:\n# \t\treturn int(a/b)\n# \telse:\n# \t\treturn (a//b + 1)\n\n# from collections import deque\n\n# n,m,k=map(int,input().split())\n# ar=list(map(int,input().split()))\n\n# q=[]\n# sm=[0]*(m+1)\n# for i in range(m+1):\n# \tqueue = deque()\n# \tq.append(queue)\n\n\n# ans=1\n# for i in range(m+1)\n# \tq[ar[i]].append(i)\n# \tif(len(sm[ar[i]])==0):\n# \t\tsm[ar[i]].append(1)\n# \telse:\n\n# \twhile q[ar[i]]:\n\n\nn=int(input())\ns=list(input())\na=\"zyxwvutsrqponmlkjihgfedcb\"\ncount=0\nfor i in range(25):\n\tfor j in range(n):\n\t\tif(s[j]==a[i]):\n\t\t\tx=j-1\n\t\t\ty=j+1\n\t\t\twhile(x>=0):\n\t\t\t\tif(s[x]==-1 or s[x]==a[i]):\n\t\t\t\t\tx-=1\n\t\t\t\telif(s[x]==chr(ord(s[j])-1)):\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\t\twhile(y<n):\n\t\t\t\tif(s[y]==-1 or s[y]==a[i]):\n\t\t\t\t\ty+=1\n\t\t\t\telif(s[y]==chr(ord(s[j])-1)):\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\t\t# print(x,y,s[j],s)\n\t\t\tif((x>=0 and s[x]!=-1 and s[x]==chr(ord(s[j])-1)) or (y<n and s[y]!=-1 and s[y]==chr(ord(s[j])-1))):\n\t\t\t\tcount+=1\n\t\t\t\ts[j]=-1\nprint(count)"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n print(0)\nelse:\n alph = \"abcdefghijklmnopqrstuvwxyz\"\n while True:\n if len(s) == 1:\n break\n mx = 'a'\n index = -1\n for i in range(1, len(s) - 1):\n if s[i] > mx and (alph[alph.find(s[i]) - 1] == s[i - 1] or alph[alph.find(s[i]) - 1] == s[i + 1]):\n mx = max(mx, s[i])\n index = i\n if s[0] > mx and alph[alph.find(s[0]) - 1] == s[1]:\n index = 0\n mx = s[0]\n if s[-1] > mx and alph[alph.find(s[-1]) - 1] == s[-2]:\n index = len(s) - 1\n mx = alph[alph.find(s[-1]) - 1]\n if index == -1:\n break\n else:\n s = s[:index] + s[index + 1:]\n print(n - len(s))\n\n"}, {"source_code": "from sys import stdin\ninput = stdin.readline\n\nn = int(input())\ns = list(input().strip())\n\nfor i in range(26):\n char = chr(ord('z') - i)\n prev = chr(ord('z') - i - 1)\n\n updated = True\n while updated:\n updated = False\n for idx in range(len(s)-1, -1, -1):\n if s[idx] == char:\n if idx < len(s)-1 and s[idx+1] == prev:\n s.pop(idx)\n updated = True\n elif idx > 0 and s[idx-1] == prev:\n s.pop(idx)\n updated = True\n\nprint( n - len(s))\n\n"}, {"source_code": "n = int(input())\nar = list(input())\nfor i in range(ord('z'), ord('a'), -1):\n for z in range(100):\n kek = []\n for j in range(len(ar) - 1):\n if ar[j] == chr(i) and ar[j + 1] == chr(i - 1):\n pass\n else:\n kek.append(ar[j])\n kek.append(ar[-1])\n ar = kek.copy()\n kek = [ar[0]]\n for j in range(1, len(ar)):\n if ar[j] == chr(i) and ar[j - 1] == chr(i - 1):\n pass\n else:\n kek.append(ar[j])\n ar = kek.copy()\nprint(n - len(ar))"}, {"source_code": "import sys, os, io\ndef rs(): return sys.stdin.readline().rstrip()\ndef ri(): return int(sys.stdin.readline())\ndef ria(): return list(map(int, sys.stdin.readline().split()))\ndef ws(s): sys.stdout.write(s + '\\n')\ndef wi(n): sys.stdout.write(str(n) + '\\n')\ndef wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\\n')\nimport math,datetime,functools,itertools,operator,bisect,fractions,statistics\nfrom collections import deque,defaultdict,OrderedDict,Counter\nfrom fractions import Fraction\nfrom decimal import Decimal\nfrom sys import stdout\nfrom heapq import heappush, heappop, heapify ,_heapify_max,_heappop_max,nsmallest,nlargest\n\ndef main():\n mod=1000000007\n # InverseofNumber(mod)\n # InverseofFactorial(mod)\n # factorial(mod)\n starttime=datetime.datetime.now()\n if(os.path.exists('input.txt')):\n sys.stdin = open(\"input.txt\",\"r\")\n sys.stdout = open(\"output.txt\",\"w\")\n \n \n tc=1\n for _ in range(tc):\n n=ri() \n s=rs()\n while True:\n m=0\n for i in range(len(s)):\n if i>=1 and ord(s[i-1])+1==ord(s[i]):\n if ord(s[i])>m:\n ind=i\n m=max(m,ord(s[i]))\n \n if i<len(s)-1 and ord(s[i+1])+1==ord(s[i]):\n if ord(s[i])>m:\n ind=i\n m=max(m,ord(s[i]))\n if m>0:\n s=s[:ind]+s[ind+1:]\n else:\n break\n print(n-len(s))\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n #<--Solving Area Ends\n endtime=datetime.datetime.now()\n time=(endtime-starttime).total_seconds()*1000\n if(os.path.exists('input.txt')):\n print(\"Time:\",time,\"ms\") \n \n \nclass FastReader(io.IOBase):\n newlines = 0\n\n def __init__(self, fd, chunk_size=1024 * 8):\n self._fd = fd\n self._chunk_size = chunk_size\n self.buffer = io.BytesIO()\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self, size=-1):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n\nclass FastWriter(io.IOBase):\n\n def __init__(self, fd):\n self._fd = fd\n self.buffer = io.BytesIO()\n self.write = self.buffer.write\n\n def flush(self):\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass FastStdin(io.IOBase):\n def __init__(self, fd=0):\n self.buffer = FastReader(fd)\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nclass FastStdout(io.IOBase):\n def __init__(self, fd=1):\n self.buffer = FastWriter(fd)\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.flush = self.buffer.flush\n\n\nif __name__ == '__main__':\n sys.stdin = FastStdin()\n sys.stdout = FastStdout()\n main()\n "}, {"source_code": "import sys\nimport copy\ninput=sys.stdin.readline\nfrom math import *\nn=int(input())\ns=list(input().rstrip())\np=copy.deepcopy(s)\nq=copy.deepcopy(s)\nr=copy.deepcopy(s)\nc1=0\nj=n-1\nif len(s)==1:\n print(0)\n exit(0)\nw=set(s)\nw=list(s)\nw.sort(reverse=True)\nfor i in range(len(w)):\n for j in range(n):\n k=0\n while k<len(s):\n if s[k]==w[i]:\n if -ord(s[max(0,k-1)])+ord(s[k])==1 or -ord(s[min(len(s)-1,k+1)])+ord(s[k])==1:\n s.pop(k)\n c1+=1\n else:\n k+=1\n else:\n k+=1 \n #print(s) \nprint(c1) \n "}, {"source_code": "sl = int(input())\ns = input()\nv= [[s[x], 0] for x in range(sl)]\nfor i in range(sl):\n if i-1>=0 and ord(v[i-1][0]) == ord(v[i][0])-1:\n v[i][1] +=1\n if i+1<sl and ord(v[i+1][0]) == ord(v[i][0])-1:\n v[i][1] +=1\nans = 0\ndef findmax(va):\n ind = -1\n ans = ['a', 0]\n for i in range(len(v)):\n if va[i][1] == 0:\n continue\n else:\n if(ans<va[i]):\n ind = i\n ans = va[i]\n return ind\nmi = findmax(v)\nwhile(mi!=-1):\n #print(v, me)\n #mi = v.index(me)\n if(mi-1>=0 and ord(v[mi-1][0])-1 == ord(v[mi][0])):\n v[mi-1][1]-=1\n if(mi+1<len(v) and ord(v[mi+1][0])-1 == ord(v[mi][0])):\n v[mi+1][1]-=1\n pv = v.pop(mi)\n if(mi<len(v) and (mi-1)>=0 and ord(v[mi][0])-1 == ord(v[mi-1][0])):\n v[mi][1]+=1\n if(mi<len(v) and (mi-1)>=0 and ord(v[mi][0])+1 == ord(v[mi-1][0])):\n v[mi-1][1]+=1\n mi = findmax(v)\n ans += 1\nprint(ans)\n \n\n"}, {"source_code": "n = int(input())\ns = input()\n\ndef f(s, c, cc):\n m = len(s)\n if m == 1:\n return s\n l = [1] * m\n for i in range(m-1):\n if s[i] == cc and s[i+1] == c:\n l[i+1] = 0\n if s[i] == c and s[i+1] == c:\n l[i+1] = l[i]\n \n for i in range(m-1, 0, -1):\n if s[i] == cc and s[i-1] == c:\n l[i-1] = 0\n if s[i] == c and s[i-1] == c:\n l[i-1] = l[i]\n ret = \"\"\n for i in range(m):\n if l[i] == 1:\n ret += s[i]\n return ret\n \nfor x in range(122, 97, -1):\n s = f(s, chr(x), chr(x-1))\n\nprint(n-len(s))"}], "negative_code": [{"source_code": "t=int(input())\ns=input()\nans=''\ncount=0\nwhile(True):\n flag=True\n for i in range(len(s)):\n if (len(s)==1):\n continue\n if s[i]=='a':\n continue\n if (i==0 or ord(s[i-1])-ord(s[i])!=1) and (i==len(s)-1 or ord(s[i+1])-ord(s[i])==-1):\n s=s[:i]+s[i+1:len(s)]\n flag=False\n count+=1\n break\n elif (i==0 or ord(s[i-1])-ord(s[i])==-1) and (i==len(s)-1 or ord(s[i+1])-ord(s[i])!=1):\n s=s[:i]+s[i+1:len(s)]\n flag=False\n count+=1\n break\n if(flag):\n break\n \nfor i in range(len(s)):\n if (i!=0 and ord(s[i-1])-ord(s[i])==-1) or (i!=len(s)-1 and ord(s[i+1])-ord(s[i])==-1):\n count+=1\nprint(count)"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\ns = stdin.readline()\n\nalphabet = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's','r', 'q', 'p','o', 'n',\n 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']\n\nfor c in range(25):\n i = 0\n while i < len(s):\n if len(s) == 1:\n break\n if s[i] == alphabet[c]:\n if i == 0:\n if s[1] == alphabet[c+1]:\n s = s[1:]\n i-= 1\n elif i == len(s) - 1:\n if s[-2] == alphabet[c+1]:\n s = s[:i]\n i -= 1\n elif s[i-1] == alphabet[c+1] or s[i+1] == alphabet[c+1]:\n s = s[:i] + s[i+1:]\n i -= 1\n i += 1\n\ns = s.strip()\n\nstdout.write(str(n - len(s)))\n"}, {"source_code": "import math\n#q=int(input())\nq=1\nfor _ in range(q):\n n=int(input())\n #a,b=map(int,input().split())\n l=list(input())\n a=[0]*26\n b=[0]*26\n for i in range(n):\n a[ord(l[i])-97]=1\n b[ord(l[i])-97]+=1\n #print(a)\n ans=0\n #print(chr(1+97))\n for i in range(25,0,-1):\n if a[i]==1:\n while(b[i]>0):\n for j in range(len(l)):\n if l[j]==chr(i+97):\n if j>0 and l[j-1]==chr(i+96):\n l.pop(j)\n ans+=1\n b[i]-=1\n break\n elif j<len(l)-1 and l[j+1]==chr(i+96): \n l.pop(j)\n ans+=1\n b[i]-=1\n break\n else:\n b[i]=0\n break\n print(ans) "}, {"source_code": "import sys\ninput = sys.stdin.readline\n \ndef main():\n n = int(input())\n s = \"&\" + input()\n s += \"&\"\n ans = 0\n for i in range(97 + 26 - 1, 96, -1):\n j = 0\n while j < len(s) - 1:\n if ord(s[j]) == i:\n if ord(s[j - 1]) + 1 == ord(s[j]) or ord(s[j + 1]) + 1 == ord(s[j]):\n s = s[:j] + s[j + 1:]\n ans += 1\n else:\n j += 1\n else:\n j += 1\n \n \n \n print(ans)\n \n \nmain()"}, {"source_code": "import string\n\nn = int(input())\na = list(input())\n\nfor i in list(string.ascii_lowercase[::-1]):\n if i != 'a':\n j = 0\n while j != len(a):\n ch = False\n if len(a) > 1 and a[j] == i:\n if j != len(a) - 1:\n if a[j] == chr(ord(a[j+1]) + 1):\n a[j] = ''\n ch = True\n if j != 0:\n if a[j] == chr(ord(a[j-1]) + 1):\n a[j] = ''\n ch = True\n if ch:\n j -= 1\n a = list(filter(lambda x: x != '', a))\n j += 1\n\n\nprint(n - len(a))"}, {"source_code": "import sys\nimport copy\ninput=sys.stdin.readline\nfrom math import *\nn=int(input())\ns=list(input().rstrip())\np=copy.deepcopy(s)\nc1=0\nj=n-1\nfor i in range(n):\n j=len(s)-1\n while j>0:\n if ord(s[j])-ord(s[j-1])==1:\n s.pop(j)\n c1+=1\n j-=1\nfor i in range(n):\n j=0\n while j<len(s)-1:\n if ord(s[j])-ord(s[j+1])==1:\n s.pop(j)\n c1+=1\n else:\n j+=1 \n#print(s,c1) \nj=0\ns=p\nc2=0\n#print(s)\nfor i in range(n):\n j=0\n while j<len(s)-1:\n if ord(s[j])-ord(s[j+1])==1:\n s.pop(j)\n c2+=1\n else:\n j+=1\nfor i in range(n):\n j=len(s)-1\n while j>0:\n if ord(s[j])-ord(s[j-1])==1:\n s.pop(j)\n c2+=1\n j-=1 \n#print(s,c2) \nprint(max(c1,c2)) "}, {"source_code": "n = int(input())\ns = input()\ncnt = 0\nif(n>1):\n for char in range(ord('z'),ord('a')-1,-1):\n i=0\n while(len(s)>1 and i<len(s)):\n if(i==0):\n if(s[i]==chr(char) and s[i]==chr(ord(s[i+1])+1)):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n elif(i==len(s)-1):\n if(s[i]==chr(char) and s[i]==chr(ord(s[i-1])+1)):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n else:\n if(s[i]==chr(char) and ((s[i]==chr(ord(s[i+1])+1)) or (s[i]==chr(ord(s[i-1])+1)) )):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n i+=1\nprint(cnt)"}, {"source_code": "def corr(rng):\n for j in rng:\n if s[j] < s[i]:\n return s[j] == s[i] - 1\n return False\n\n\nans = 0\nn = int(input())\ns = tuple(map(ord, input()))\nfor i in range(n):\n if corr(range(i, -1, -1)) or corr(range(i, n)):\n ans += 1\nprint(ans)\n"}, {"source_code": "''' Remove Adjacent\n'''\n\ndef pc(c):\n return chr(ord(c) - 1)\n\n''' routine '''\n\nstrlen = int(input())\nstring = input()\nremovalcount = 0\n\nazindex = {chr(96+26-n):[] for n in range(26)}\n\nfor n, c in enumerate(string):\n azindex[c].append(n)\n\n#print(azindex.items())\nchange = True\nwhile change:\n change = False\n for letter, indices in azindex.items():\n if len(indices) == 0 or letter == 'a':\n continue\n # print('letter', letter, list(azindex.items())[-3:])\n possible = -1\n for index in indices:\n if string[max(index - 1, 0)] == pc(letter) or string[min(index + 1, len(string) - 1)] == pc(letter):\n # print(index, string)\n string = string[:index] + string[index+1:]\n possible = index\n change = True\n removalcount += 1\n \n break\n # print(possible)\n if possible > -1:\n \n for letter in azindex.keys():\n newindices = []\n indices = azindex[letter]\n # if letter < 'd': print(letter, indices)\n for index in indices:\n if index > possible:\n newindices.append(index - 1)\n elif index < possible:\n newindices.append(index)\n azindex[letter] = newindices\n\nprint(removalcount)"}, {"source_code": "import sys\nimport os\nimport time\nimport collections\nfrom collections import Counter, deque\nimport itertools\nimport math\nimport timeit\nimport random\nfrom io import BytesIO, IOBase\nfrom bisect import bisect_left\n\n \n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n \ndef divs(n, start=1):\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n \ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\ndef flin(d, x, default=-1):\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return (default, default)\n else:\n return (left, right)\n\ndef modpow(b,p,m):\n res=1\n b=b%m\n while(p):\n if p&1:\n res=(res*b)%m\n b=(b*b)%m\n p>>=1\n return res\n\ndef mod_inv(a,m):\n return modpow(a,m-2,m)\n\ndef ncr(n,r,m):\n res=1\n if r==0:\n return 1\n if n-r<r:\n r=n-r\n p,k=1,1\n while(r):\n res=((res%m)*(((n%m)*mod_inv(r,m))%m))%m\n n-=1\n r-=1\n return res\n\ndef ncrlis(n,r,m,fact):\n return (fact[n]*(mod_inv(fact[r],m)*mod_inv(fact[n-r],m))%m)%m\n \n \n \ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\n \n \n# region fastio\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n\tnewlines = 0\n \n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself.buffer = BytesIO()\n\t\tself.writable = \"x\" in file.mode or \"r\" not in file.mode\n\t\tself.write = self.buffer.write if self.writable else None\n \n\tdef read(self):\n\t\t\twhile True:\n\t\t\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\t\t\tif not b:\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\tptr = self.buffer.tell()\n\t\t\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\t\tself.newlines = 0\n\t\t\treturn self.buffer.read()\n \n\tdef readline(self):\n\t\t\twhile self.newlines == 0:\n\t\t\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\t\t\tself.newlines = b.count(b\"\\n\") + (not b)\n\t\t\t\t\tptr = self.buffer.tell()\n\t\t\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n\t\t\tself.newlines -= 1\n\t\t\treturn self.buffer.readline()\n \n\tdef flush(self):\n\t\t\tif self.writable:\n\t\t\t\t\tos.write(self._fd, self.buffer.getvalue())\n\t\t\t\t\tself.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n\tdef __init__(self, file):\n\t\t\tself.buffer = FastIO(file)\n\t\t\tself.flush = self.buffer.flush\n\t\t\tself.writable = self.buffer.writable\n\t\t\tself.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n\t\t\tself.read = lambda: self.buffer.read().decode(\"ascii\")\n\t\t\tself.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n\nn=ii()\ns=list(input())\ns=['#']+s+['#']\nalph='$abcdefghijklmnopqrstuvwxyz$'\nlis=list(set(s))\nlis.sort(reverse=True)\nfor i in lis:\n j=1\n while j<len(s)-1:\n if s[j]==i:\n if s[j+1]==alph[ord(i)-97] or s[j-1]==alph[ord(i)-97]:\n #print(alph[ord(i)-97-1])\n s.pop(j)\n #print(s)\n else:\n j+=1\n else:\n j+=1\nprint(n-len(s)+2)\n"}, {"source_code": "n = 6\ns = \"abbbbb\"\n\nl = []\nfor i in range(n):\n\tl.append(ord(s[i]))\n\nc = 0\n\nwhile len(l) > 1:\n\tm = max(l)\n\ti = 0\n\twhile l[i] != m:\n\t\ti += 1\n\tif i == 0:\n\t\tif l[i] - l[i + 1] == 1:\n\t\t\tl.pop(i)\n\t\t\tc += 1\n\telif i == len(l) - 1:\n\t\tif l[i] - l[i - 1] == 1:\n\t\t\tl.pop(i)\n\t\t\tc += 1\n\telif l[i] - l[i - 1] == 1 or l[i] - l[i + 1] == 1:\n\t\tl.pop(i)\n\t\tc += 1\n\nprint(c)"}, {"source_code": "n, s = int(input()), input()\n\ndef calc(s):\n mn = mx = ord(s[0])\n ns = \"\"\n for ch in s:\n if mn < ord(ch) and ord(ch) <= mx+1:\n mx = ord(ch)\n else:\n ns += ch\n mn = mx = ord(ch)\n return ns\n\ns = calc(s)\n#print(s)\ns = calc(s[::-1])\n#print(s)\nprint(n-len(s))\n"}, {"source_code": "import copy\nn=int(input())\ns=input()\nar=list(s)\ncount=0\nfor i in range(122,96,-1):\n br=[]\n l=len(ar)\n for j in range(l):\n if(l==1):\n break\n if(ord(ar[j])==i):\n if(j==0):\n if(ord(ar[j+1])==i-1):\n count+=1\n ar[j]=ar[j+1]\n else:\n br.append(ar[j])\n elif(j==l-1):\n if(ord(ar[j-1])==i-1):\n ar[j]=ar[j-1]\n count+=1\n else:\n br.append(ar[j])\n else:\n if(ord(ar[j+1])==i-1):\n ar[j]=ar[j+1]\n count+=1\n elif(ord(ar[j-1])==i-1):\n ar[j]=ar[j-1]\n count+=1\n else:\n br.append(ar[j])\n else:\n br.append(ar[j])\n ar=copy.deepcopy(br)\n br=[]\nprint(count)\n#\n"}, {"source_code": "n = int(input())\ns = [ord(i) for i in input()]\ns.append(0)\ns1 = []\np = s[0]\nc = 1\nfor i in range(1,n+1):\n if s[i]!=s[i-1]:\n s1.append([p,c])\n p = s[i]\n c = 1\n else:\n c += 1\n\nout = 0\nwhile True:\n l = len(s1)\n temp = [1]*l\n for i in range(l):\n if (i>0 and s1[i][0]-s1[i-1][0]==1) or (i<l-1 and s1[i][0]-s1[i+1][0]==1):\n out+=s1[i][1]\n temp[i]=0\n if sum(temp)==l:\n break\n s1 = [s1[i] for i in range(l) if temp[i]]\nprint(out)"}, {"source_code": "n = int(input())\nS = list(input())\nalphabet = 'abcdefghijklmnopqrstuvwxyz'\nnewS = []\ni = 0\nans = 0\nwhile i < n:\n candelete = 0\n j = 1\n if i + j < n and ord(S[i + j]) - ord(S[i + j - 1]) == 1:\n while j + i < n:\n if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:\n j += 1\n candelete += 1\n else:\n break\n newS.append(S[i])\n ans += candelete\n i += candelete\n i += 1\ni = 0\nS = newS\nn = len(S)\nwhile i < n:\n candelete = 0\n j = -1\n if i + j > -1 and ord(S[i + j]) - ord(S[i + j - 1]) == 1:\n while j + i > -1:\n if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:\n j -= 1\n candelete += 1\n else:\n break\n ans += candelete\n i += candelete\n i += 1\nprint(ans)"}, {"source_code": "n=int(input())\ns=list(input())\nfor i in range(ord(\"z\"),ord(\"a\")-1,-1):\n for j in range(0,len(s)):\n if(len(s)<=j):\n break\n if(j==len(s)-1):\n if(s[j]==chr(i) and s[j-1]==chr(i-1)):\n k=s.pop(j)\n \n elif(j==0):\n if(s[j]==chr(i) and s[j+1]==chr(i-1)):\n k=s.pop(j)\n \n else:\n if(s[j]==chr(i) and (s[j-1]==chr(i-1) or s[j+1]==chr(i-1))):\n k=s.pop(j)\n \n #print(chr(i),s,j,len(s))\nprint(n-len(s))\n "}, {"source_code": "import sys\nimport math\nimport heapq\nimport collections\nfast_reader = sys.stdin.readline\nfast_writer = sys.stdout.write\ndef input():\n\treturn fast_reader().strip()\ndef print(*argv):\n\tfast_writer(' '.join((str(i)) for i in argv))\n\tfast_writer('\\n')\ndef printspace(*argv):\n\tfast_writer(' '.join((str(i)) for i in argv))\n\tfast_writer(' ')\ndef inputnum():\n return(int(input()))\ndef inputnums():\n return(map(int,input().split()))\ndef inputlist():\n return(list(map(int,input().split())))\ndef inputstring():\n return([x for x in input()])\ndef inputmatrixchar(rows):\n arr2d = [[j for j in input().strip()] for i in range(rows)] \n return arr2d\ndef inputmatrixint(rows):\n arr2d = []\n for _ in range(rows):\n arr2d.append([int(i) for i in input().split()])\n return arr2d\n \nn = inputnum()\ns = [ord(x) for x in input()]\nt = s\nt.sort(reverse = True)\ncount = 0\nfor i in t:\n if len(s) == 1:\n break\n for j in range(len(s)):\n if s[j] == i:\n if j == 0:\n if abs(s[1]-i)==1:\n s.pop(j)\n break\n elif j==len(s)-1:\n if abs(s[len(s)-2]-i)==1:\n s.pop(j)\n break\n elif abs(s[j-1]-i)==1 or abs(s[j+1]-i)==1:\n s.pop(j)\n break\nprint(n - len(s))"}, {"source_code": "\n\nn = int(input())\ns = list(input())\n\nwhile 1:\n i=0\n f=0\n\n while i<len(s):\n p=ord(s[i])\n count=0\n st = i\n while i<len(s) and p==ord(s[i]):\n i+=1\n p+=1\n count+=1\n if count>1:\n s = s[:st+1]+s[i:]\n f=1\n break\n else:\n i = st\n count=0\n p=ord(s[i])\n while i<len(s) and p==ord(s[i]):\n i+=1\n p-=1\n count+=1\n if count>1:\n s = s[:st]+s[i-1:]\n f=1\n break\n\n if f==0:\n break\n\nprint(n-len(s))\n"}, {"source_code": "import atexit\nimport io\nimport sys\nimport math\nfrom collections import defaultdict,Counter\n\n# _INPUT_LINES = sys.stdin.read().splitlines()\n# input = iter(_INPUT_LINES).__next__\n# _OUTPUT_BUFFER = io.StringIO()\n# sys.stdout = _OUTPUT_BUFFER\n\n# @atexit.register\n# def write():\n# sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\n\n# sys.stdout=open(\"CP3/output.txt\",'w')\n# sys.stdin=open(\"CP3/input.txt\",'r')\n\n# m=pow(10,9)+7\nn=int(input())\ns=list(input())\nif n==1:\n print(0)\nelse:\n # s1=s[:]\n for j in range(122,97,-1):\n k=0\n while k<len(s) and len(s)>1:\n if s[k]==chr(j):\n if k==0:\n if s[1]==chr(j-1):\n del(s[k])\n else:\n k+=1\n elif k==len(s)-1:\n if s[-2]==chr(j-1):\n del(s[k])\n else:\n k+=1\n else:\n if s[k-1]==chr(j-1) or s[k+1]==chr(j-1):\n del(s[k])\n else:\n k+=1\n else:\n k+=1\n\n print(n-len(s))\n"}, {"source_code": "'''\n\tCodeForces 1321C\n\tRemove Adjacent\n\n\tTags: Ad-hoc, String Manipulation\n'''\nimport re\nfrom functools import reduce\n\ndef iter(s, idx):\n\tchA = chr(ord('a') + idx - 1)\n\tchB = chr(ord(chA) + 1)\n\tpat = re.compile(f'{chA}{chB}+|{chB}+{chA}')\n\treturn re.sub(pat, chA, s)\n\norigin = int(input())\ns = reduce(iter, range(25, 0, -1), input().strip())\n\nprint(origin - len(s))"}, {"source_code": "t=int(input())\ns=input()\nans=''\ncount=0\nwhile(True):\n flag=True\n for i in range(len(s)):\n if (len(s)==1):\n continue\n if s[i]=='a':\n continue\n if (i==0 or ord(s[i-1])-ord(s[i])!=1) and (i!=len(s)-1 and ord(s[i+1])-ord(s[i])==-1):\n # print(s,s[i],i)\n s=s[:i]+s[i+1:len(s)]\n flag=False\n count+=1\n break\n elif (i!=0 and ord(s[i-1])-ord(s[i])==-1) and (i==len(s)-1 or ord(s[i+1])-ord(s[i])!=1):\n # print(s,s[i],i)\n s=s[:i]+s[i+1:len(s)]\n flag=False\n count+=1\n break\n if(flag):\n break\n \nfor i in range(len(s)):\n if (i!=0 and ord(s[i-1])-ord(s[i])==-1) or (i!=len(s)-1 and ord(s[i+1])-ord(s[i])==-1):\n count+=1\nprint(count)"}, {"source_code": "n = int(input())\ns = input()\n\nl = []\nfor i in range(n):\n\tt = ord(s[i])\n\tif t not in l:\n\t\tl.append(t)\n\nl.sort(reverse = True)\n\nc = 0\n\nwhile len(l) > 1:\n\tj = 0\n\twhile j < len(s):\n\t\tprint(s, j)\n\t\tif ord(s[j]) == (l[0]):\n\t\t\tif j == 0:\n\t\t\t\tif ord(s[1]) == l[0] - 1:\n\t\t\t\t\ts = s[1:]\n\t\t\t\t\tc += 1\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telif j == len(s) - 1:\n\t\t\t\tif ord(s[len(s) - 2]) == l[0] - 1:\n\t\t\t\t\ts = s[:len(s) - 1]\n\t\t\t\t\tc += 1\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telse:\n\t\t\t\tif ord(s[j + 1]) == l[0] - 1 or ord(s[j - 1]) == l[0] - 1:\n\t\t\t\t\ts = s[:j] + s[j + 1:]\n\t\t\t\t\tc += 1\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\telse:\n\t\t\tj += 1\n\tl.pop(0)\n\nprint(c)"}, {"source_code": "n=int(input())\ns=input()[:n]\nprint(s)\na=[x for x in s]\nfor j in range(25,0,-1):\n\tfor k in range(n):\n\t\tans=[]\n\t\tfor i in range(len(a)):\n\t\t\tif a[i]==chr(97+j) and ((i>0 and a[i-1]==chr(97+j-1)) or (i<len(a)-1 and a[i+1]==chr(97+j-1))):\n\t\t\t\ta.pop(i)\n\t\t\t\tbreak\n\t\t\t\nprint(n-len(a))"}, {"source_code": "import string\n\nn = int(input())\na = list(input())\n\nfor i in list(string.ascii_lowercase[::-1]):\n if i != 'a':\n j = 0\n while j != len(a):\n ch = False\n if len(a) > 1 and a[j] == i:\n if j != len(a) - 1:\n if a[j] == chr(ord(a[j+1]) + 1):\n a[j] = ''\n ch = True\n if j != 0:\n if a[j] == chr(ord(a[j-1]) + 1):\n a[j] = ''\n ch = True\n if ch:\n j -= 1\n a = list(filter(lambda x: x != '', a))\n j += 1\n\n\nprint(n - len(a))"}, {"source_code": "import sys\nimport copy\ninput=sys.stdin.readline\nfrom math import *\nn=int(input())\ns=list(input().rstrip())\np=copy.deepcopy(s)\nc1=0\nj=n-1\nfor i in range(n):\n j=len(s)-1\n while j>0:\n if ord(s[j])-ord(s[j-1])==1:\n s.pop(j)\n c1+=1\n j-=1\nfor i in range(n):\n while j<len(s)-1:\n if ord(s[j])-ord(s[j+1])==1:\n s.pop(j)\n c1+=1\n else:\n j+=1 \n#print(s,c1) \nj=0\ns=p\nc2=0\n#print(s)\nfor i in range(n):\n while j<len(s)-1:\n if ord(s[j])-ord(s[j+1])==1:\n s.pop(j)\n c2+=1\n else:\n j+=1\nfor i in range(n):\n j=len(s)-1\n while j>0:\n if ord(s[j])-ord(s[j-1])==1:\n s.pop(j)\n c2+=1\n j-=1 \n#print(s,c2) \nprint(max(c1,c2)) \n "}, {"source_code": "n= int(input())\na=list(input())\nfor i in range(25,0,-1):\n cur=chr(97+i);prev=chr(96+i)\n for j in range(len(a)):\n if(j>=len(a)):\n break\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n #print(x,j,y,len(a),a)\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\n for j in range(len(a)-1,-1,-1):\n if(j>=len(a)):\n break\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n #print(x,j,y,len(a),a)\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\nprint(n-len(a))\n \n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\ns = input().strip()\nans = 0\nwhile True:\n ansn = ans\n for i in xrange(25):\n new_s = ''\n for j in xrange(len(s)):\n if s[j] == chr(122-i) and ((j>0 and s[j-1] == chr(122-i-1)) or (j<len(s)-1 and s[j+1] == chr(122-i-1))):\n ans += 1\n else:\n new_s += s[j]\n s = new_s\n if ansn == ans:\n break\nprint(ans)\n"}, {"source_code": "n = int(input())\nu = list(input())\nlft = list(range(-1, n))\nrht = list(range(1, n)) + [-1]\nd = []\nfor i in range(97, 97 + 26):\n d.append(chr(i))\nd.reverse()\nans = 0\nfor k in range(len(d) - 1):\n for i in range(n):\n if u[i] == -1 or u[i] != d[k]:\n continue\n i1 = lft[i]\n j1 = rht[i]\n if i1 != -1 and u[i1] == d[k + 1] or\\\n j1 != -1 and u[j1] == d[k + 1]:\n u[i] = -1\n ans += 1\n if lft[i] != -1 and rht[i] != -1:\n rht[lft[i]], lft[rht[i]] = rht[i], lft[i]\n elif lft[i] != -1:\n rht[lft[i]] = rht[i]\n elif rht[i] != -1:\n lft[rht[i]] = lft[i]\n## print(*u, \"****\", d[k])\n## print(*lft)\n## print(*rht)\n## print()\n\nprint(ans)\n"}, {"source_code": "\ndef solve_test_case(t):\n n = int(input())\n s = str(input())\n\n res = 0\n\n for ci in reversed(range(26)):\n \t# print(s)\n \tc = chr(ord('a') + ci)\n \t# print(c)\n \tprev_c = chr(ord('a') + ci-1)\n \t# print(prev_c)\n \tnew_s = []\n \tfor i in range(len(s)):\n \t\tif s[i] == c:\n \t\t\tif len(new_s) > 0 and new_s[-1] == prev_c:\n \t\t\t\tres += 1\n \t\t\t\tcontinue\n \t\t\tif i < (len(s) -1) and s[i+1] == prev_c:\n \t\t\t\tres += 1\n \t\t\t\tcontinue\n \t\tnew_s.append(s[i])\n \ts = \"\".join(new_s)\n print(res)\n\ndef parse_array(f):\n return list(map(f, input().split()))\n\ndef solve():\n T = int(input())\n\n for t in range(T):\n solve_test_case(t)\n\nif __name__ == \"__main__\":\n solve_test_case(0)\n"}, {"source_code": "s=int(input())\nst=input()\nfc=0\nti=0\nfi=0\nA=[0 for i in range(s)]\nfor i in range(s):\n flag=0\n if (i!=(s-1) and ord(st[i])==(ord(st[i+1])+1)):\n ti=max(i-1,0)\n fi=i\n flag=1\n fc=fc+1\n A[i]=1\n #print(\"1\",st[i],ti,fi)\n\n elif(ord(st[i])==(ord(st[i-1])+1)):\n ti=max(i-1,0)\n fi=i\n flag=1\n fc=fc+1\n A[i]=1\n #print(\"2\",st[i],ti,fi)\n \n else:\n for j in range(ti,fi):\n if(ord(st[j])==(ord(st[i])-1) and A[i]!=1):\n fc=fc+1\n fi=min(fi+1,s-1)\n A[i]=1\n #print(\"3\",st[i],ti,fi)\n flag=1\n \n elif(ord(st[j])==(ord(st[i])+1) and A[j]!=1):\n fc=fc+1\n if(ord(st[max(j-1,0)])==(ord(st[i])-1) and A[i]!=1):\n fc=fc+1\n fi=i\n ti=i\n A[i]=1\n #print(\"4\",st[i],ti,fi)\n \n A[j]=1\n #print(\"5\",st[j],ti,fi)\n \n #print(i) \n if(flag==0):\n ti=i\n fi=i\n\nprint(fc)\n \n \n"}, {"source_code": "n = int(input())\nc = input()\ns = [0] * n\nfor i in range(n):\n s[i] = [c[i], 0]\nfor i in range(26):\n a = chr(ord('z') - i)\n flag = True\n while flag:\n j = 0\n while j < len(s) and (s[j][0] != a or s[j][1] == 1):\n j += 1\n if j == len(s):\n flag = False\n else:\n s[j][1] = 1\n if j > 0 and s[j - 1][0] == chr(ord(a) - 1) or j < len(s) - 1 and s[j + 1][0] == chr(ord(a) - 1):\n s.pop(j)\nprint(n - len(s))"}, {"source_code": "import sys\n# from math\nimport bisect\nimport heapq\n# from collections import deque\n\n# from types import GeneratorType\n# def bootstrap(func, stack=[]):\n# def wrapped_function(*args, **kwargs):\n# if stack:\n# return func(*args, **kwargs)\n# else:\n# call = func(*args, **kwargs)\n# while True:\n# if type(call) is GeneratorType:\n# stack.append(call)\n# call = next(call)\n# else:\n# stack.pop()\n# if not stack:\n# break\n# call = stack[-1].send(call)\n# return call\n# return wrapped_function\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n \ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**9+7\n\nn = int(ri())\ns = ri()\n\nmaxx= -1\nmaxxind = -1\nflag = True\ncnt = 0\nwhile (flag ):\n flag = False\n maxx= -1\n maxxind = -1\n for i in range(len(s)):\n # print(i)\n if i-1>= 0 and ord(s[i]) == ord(s[i-1])+1:\n if ord(s[i]) > maxx:\n maxx = ord(s[i])\n maxxind = i\n flag = True\n if i+1 <=len(s)-1 and ord(s[i]) == ord(s[i+1])+1:\n maxx = ord(s[i])\n maxxind = i\n flag = True\n if flag : \n s = s[0:maxxind] + s[maxxind+1:]\n cnt+=1\nprint(cnt)"}, {"source_code": "ans = 0\n\n\ndef check1(seq, i):\n if i == 0 or i == len(seq)-1:\n return False\n if seq[i] - seq[i-1] == 1 and seq[i] - seq[i+1] == 2:\n return True\n if seq[i] - seq[i+1] == 1 and seq[i] - seq[i-1] == 2:\n return True\n if seq[i] - seq[i-1] == 1 and seq[i] == seq[i+1]:\n return True\n if seq[i] - seq[i+1] == 1 and seq[i] == seq[i-1]:\n return True\n return False\n\n\ndef check2(seq, i):\n if i == 0 or i == len(seq)-1:\n return True\n if seq[i] - seq[i - 1] == 1 and seq[i + 1] - seq[i] >= 2:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i - 1] - seq[i] >= 2:\n return True\n if seq[i] - seq[i - 1] == 1 and seq[i] - seq[i + 1] >= 3:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i] - seq[i - 1] >= 3:\n return True\n if seq[i] - seq[i - 1] == 1 and seq[i] - seq[i + 1] == 1:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i] - seq[i - 1] == 1:\n return True\n return False\n\n\ndef check3(seq, i):\n if i == 0 or i == len(seq)-1:\n return False\n if seq[i] - seq[i - 1] == 1 and seq[i + 1] - seq[i] == 1:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i - 1] - seq[i] == 1:\n return True\n return False\n\n\ndef seq_to_str(seq):\n return ''.join([chr(s+ord('a')) for s in seq])\n\n\ndef make_move(seq):\n global ans\n candidates = []\n if len(seq) > 1:\n # Check first\n if seq[0] - seq[1] == 1:\n candidates.append(0)\n # Check others\n for i in range(1, len(seq) - 1):\n if seq[i]-seq[i+1] == 1 or seq[i]-seq[i-1] == 1:\n candidates.append(i)\n # Check last\n if seq[-1] - seq[-2] == 1:\n candidates.append(len(seq) - 1)\n #print(seq, candidates)\n\n if len(candidates) > 0:\n # Use priority\n priopity1 = list()\n priopity2 = list()\n priopity3 = list()\n for cand in candidates:\n if check1(seq, cand):\n priopity1.append(cand)\n elif check2(seq, cand):\n priopity2.append(cand)\n elif check3(seq, cand):\n priopity3.append(cand)\n candidates_sorted = sorted(priopity1, key=lambda cand: seq[cand], reverse=True) + sorted(priopity2, key=lambda cand: seq[cand], reverse=True) + sorted(priopity3, key=lambda cand: seq[cand], reverse=True)\n to_del_index = candidates_sorted[0]\n new_seq = seq[0:to_del_index]+seq[to_del_index+1:]\n print(seq_to_str(new_seq), to_del_index, check1(seq, to_del_index), check2(seq, to_del_index), check3(seq, to_del_index))\n ans += 1\n make_move(new_seq)\n\n\n_ = int(input())\nseq = [ord(s) - ord('a') for s in input()]\nmake_move(seq)\nprint(ans)\n"}, {"source_code": "n,cnt=int(raw_input()),0\ns=raw_input()\n\n\nwhile len(s)>1:\n\tmx,pos=0,-1\n\tfor i in xrange(len(s)):\n\t\tif i>0:\n\t\t\tif s[0]==chr(ord(s[i-1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],0\n\t\tif i<len(s)-1:\n\t\t\tif s[i]==chr(ord(s[i+1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],i\n\tif pos==-1: break \n\telse: s=s[:pos]+s[(pos+1):]\n\tcnt+=1\n\nprint cnt"}, {"source_code": "#n = int(input())\n#s = input()\n\nn = 6\ns = \"bbbbba\"\n\nl = []\nfor i in range(n):\n\tt = ord(s[i])\n\tif t not in l:\n\t\tl.append(t)\n\nl.sort(reverse = True)\n\nc = 0\n\nwhile len(l) > 1:\n\tj = 0\n\tf = False\n\twhile j < len(s):\n\t\tif ord(s[j]) == (l[0]):\n\t\t\tprint(s)\n\t\t\tif j == 0:\n\t\t\t\tif ord(s[1]) == l[0] - 1:\n\t\t\t\t\ts = s[1:]\n\t\t\t\t\tc += 1\n\t\t\t\t\tf = True\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telif j == len(s) - 1:\n\t\t\t\tif ord(s[len(s) - 2]) == l[0] - 1:\n\t\t\t\t\ts = s[:len(s) - 1]\n\t\t\t\t\tc += 1\n\t\t\t\t\tf = True\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telse:\n\t\t\t\tif ord(s[j + 1]) == l[0] - 1 or ord(s[j - 1]) == l[0] - 1:\n\t\t\t\t\ts = s[:j] + s[j + 1:]\n\t\t\t\t\tc += 1\n\t\t\t\t\tf = True\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\telse:\n\t\t\tj += 1\n\tif not f:\n\t\tl.pop(0)\n\nprint(c)"}, {"source_code": "import sys\n\nI = lambda: int(input())\nreadline = lambda: sys.stdin.readline().strip('\\n')\nRM = readmap = lambda x=int: map(x,readline().split(' '))\n\n#1321 625 div2\n#C: Remove Adjacent\nn,s = I(),readline()\nfor i in range(25,0,-1):\n y = chr(ord('a')+i)\n x = chr(ord('a')+i-1)\n s = s.replace(x+y,x).replace(y+x,x)\nprint(n-len(s))\nquit()\n#B:Journey Planning\n#overkill approach: dynamic programming; TLE\n#pmax0 = 0\n#bmax = b.copy()\n#for i in range(n-1,-1,-1):\n# if max0<b[i]:\n# max0 = max(max0,b[i])\n# continue\n# bmax[i] += max([0]+[bmax[j] for j in range(i+1,n) if j-i == b[j]-b[i]])\n# max0 = max(max0,b[i])\n#print(max(bmax))\n\n#**trick: find common features in the sequence in O(1)**\nd = {}\nfor i,x in zip(range(I()),RM()):\n d[x-i] = d.get(x-i,0) + x\nprint(max(d.values()))\nquit()\n#A: contest for robots\nn,a,b =I(),[*RM()],[*RM()]\ncount1,count2 = 0,0\nfor i,j in zip(a,b):\n count1 += i & ~j\n count2 += j & ~i\nprint(divmod(count2,count1)[0]+1 if count1 else -1)\n"}, {"source_code": "from math import *\nalf = list(reversed('abcdefghijklmnopqrstuvwxyx'))\ndef adj(a, b):\n return chr(ord(a) - 1) == b\n \nn = int(input())\ns = [i for i in input()]\nfor j in range(n*2):\n for a in alf:\n i = 0\n while i < len(s):\n if i > 0 and adj(s[i], s[i-1]):\n s.pop(i)\n elif i < len(s) - 1 and adj(s[i], s[i+1]):\n s.pop(i)\n else:\n i += 1\n \nprint(n - len(s))\n"}, {"source_code": "n,cnt=int(raw_input()),0\ns=raw_input()\n\n\nwhile len(s)>1:\n\tmx,pos=0,-1\n\tfor i in xrange(len(s)):\n\t\tif i>0:\n\t\t\tif s[0]==chr(ord(s[i-1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],0\n\t\tif i<len(s)-1:\n\t\t\tif s[i]==chr(ord(s[i+1])+1):\n\t\t\t\tif s[i]>mx: mx,pos=s[i],i\n\tif pos==-1: break \n\telse: s=s[:pos]+s[(pos+1):]\n\tcnt+=1\n\nprint cnt"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n print(0)\nelse:\n alph = \"abcdefghijklmnopqrstuvwxyz\"\n f = True\n while f:\n cnt = 0\n for i in range(len(alph) - 1, 0, -1):\n if len(s) == 1:\n break\n for j in range(len(s) - 1, -1, -1):\n if len(s) == 1:\n break\n if s[j] == alph[i]:\n if j != 0 and j != len(s) - 1:\n if s[j - 1] == alph[i - 1] or s[j + 1] == alph[i - 1]:\n s = s[:j] + s[j + 1:]\n cnt += 1\n elif j == 0:\n if s[j + 1] == alph[i - 1]:\n s = s[:j] + s[j + 1:]\n cnt += 1\n else:\n if s[j - 1] == alph[i - 1]:\n s = s[:j] + s[j + 1:]\n cnt += 1\n if cnt == 0:\n f = False\n print(n - len(s))\n"}, {"source_code": "n=int(input())\nalphabet=\"abcdefghijklmnopqrstuvwxyz\"\ny=input()\nans=0\nfor i in range(25):\n for j in range(len(y)):\n cont=True\n while cont==True:\n if y[len(y)-1-j]==alphabet[25-i]:\n if (j<len(y)-1 and y[len(y)-2-j]==alphabet[24-i]) or (j>0 and y[len(y)-j]==alphabet[24-i]):\n ans+=1\n y=y[:len(y)-1-j]+y[len(y)-j:]\n else:\n cont=False\n else:\n cont=False\nprint(ans)"}, {"source_code": "n=int(input());s=input();S=[];S.extend(s);ind=[];S1=S.copy()\nfor i in range(n):ind.append([S[i],i+1])\nind.sort(reverse=True);S=['}']+S+['}'];m=0;Ans=0\nfor i in ind:\n t=i[1]\n if ord(S[t-1])+1==ord(S[t]) or ord(S[t+1])+1==ord(S[t]):\n del(S[t])\n for j in ind:\n if j[1]>t:j[1]-=1\nwhile True:\n t=S1.index(max(S1))\n if len(S1)<2:break\n if t==0 and ord(S1[0])==ord(S1[1])+1:del(S1[0])\n elif t==len(S1)-1 and ord(S1[t])==ord(S1[t-1])+1:del(S1[t]) \n elif ord(S1[t])==ord(S1[t-1])+1 or ord(S1[t])==ord(S1[t+1])+1:del(S1[t]) \n else:m+=1\n Ans+=1\n if m>n:break\nprint(max(Ans,n-len(S)+S.count('}')))"}, {"source_code": "dp = {}\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\npos = {alphabet[i]:i for i in range(26)}\n\n# def compute(s):\n# \tglobal dp\n# \tif len(s)==1:\n# \t\treturn 0\n# \telif len(s) in dp and s in dp[len(s)]:\n# \t\treturn dp[len(s)][s]\n# \telse:\n# \t\tans = -1\n# \t\tfor i in range(len(s)):\n# \t\t\tif (i!=0 and pos[s[i-1]]==pos[s[i]]-1) or (i!=len(s)-1 and pos[s[i+1]]==pos[s[i]]-1):\n# \t\t\t\tnew_s = s[:i]+s[i+1:]\n# \t\t\t\tval = compute(new_s)\n# \t\t\t\tif val > ans:\n# \t\t\t\t\tans = val \n# \t\tif len(s) in dp:\n# \t\t\tdp[len(s)][s]=ans+1 \n# \t\telse:\n# \t\t\tdp[len(s)]={s:ans+1}\n# \t\treturn ans+1\n\ndef compute(s,n):\n\tif len(s)<=1:\n\t\treturn 0\n\tchar = alphabet[n]\n\tword = \"\"\n\tans=0\n\tfor i in range(len(s)):\n\t\tif s[i]==char:\n\t\t\tif (i!=0 and pos[s[i-1]]==pos[s[i]]-1) or (i!=len(s)-1 and pos[s[i+1]]==pos[s[i]]-1):\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\tans+=compute(word,n-1)\n\t\t\t\tword=\"\"\n\t\telse:\n\t\t\tword+=s[i]\n\tans+=compute(word,n-1)\n\treturn ans\n\ninput()\nprint(compute(input(),25))\n# print(dp)\n\n"}, {"source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom __builtin__ import xrange as range\nfrom cStringIO import StringIO\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom io import IOBase\n\nimport __pypy__\n\n\ndef main():\n n = int(input())\n s = list(input())\n for _ in range(200):\n for i in reversed(range(26)):\n a, b = chr(i + 96), chr(i + 97)\n j = 0\n while j < len(s) and len(s) > 1:\n if j == 0:\n if s[j] == b and s[j + 1] == a:\n s.pop(j)\n else:\n j += 1\n elif j < len(s) - 1:\n if s[j] == b and (s[j + 1] == a or s[j - 1] == a):\n s.pop(j)\n else:\n j += 1\n elif j == len(s) - 1:\n if s[j] == b and s[j - 1] == a:\n s.pop(j)\n else:\n j += 1\n else:\n j += 1\n print(n - len(s))\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n = int(input())\nS = list(input())\nalphabet = 'abcdefghijklmnopqrstuvwxyz'\nnewS = []\ni = 0\nans = 0\nwhile i < n:\n candelete = 0\n j = 1\n while j + i < n:\n if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:\n j += 1\n candelete += 1\n else:\n break\n newS.append(S[i])\n ans += candelete\n i += candelete\n i += 1\ni = 0\nS = newS\nn = len(S)\nwhile i < n:\n candelete = 0\n j = -1\n while j + i > -1:\n if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:\n j -= 1\n candelete += 1\n else:\n break\n ans += candelete\n i += candelete\n i += 1\nprint(ans)"}, {"source_code": "n = int(input())\ns = [ord(i) for i in input()]\ns.append(0)\ns1 = []\np = s[0]\nc = 1\nfor i in range(1,n+1):\n if s[i]!=s[i-1]:\n s1.append([p,c])\n p = s[i]\n c = 1\n else:\n c += 1\n\nout = 0\nwhile True:\n l = len(s1)\n temp = [1]*l\n for i in range(l):\n if (i>0 and s1[i][0]-s1[i-1][0]==1) or (i<l-1 and s1[i][0]-s1[i+1][0]==1):\n out+=s1[i][1]\n temp[i]=0\n if sum(temp)==l:\n break\n s1 = [s1[i] for i in range(l) if temp[i]]\nprint(out)"}, {"source_code": "import sys\nimport copy\ninput=sys.stdin.readline\nfrom math import *\nn=int(input())\ns=list(input().rstrip())\np=copy.deepcopy(s)\nc1=0\nj=n-1\nif len(s)==1:\n print(0)\n exit(0)\nwhile 1:\n for i in range(n):\n j=len(s)-1\n while j>0:\n if ord(s[j])-ord(s[j-1])==1:\n s.pop(j)\n c1+=1\n j-=1\n p1=len(s) \n #print(s,1,1)\n for i in range(n):\n j=0\n while j<len(s)-1:\n if ord(s[j])-ord(s[j+1])==1:\n s.pop(j)\n c1+=1\n else:\n j+=1 \n p2=len(s)\n #print(s,1,2)\n if p1==p2:\n break\n#print(s,c1) \nj=0\ns=p\nc2=0\n#print(s)\nwhile 1:\n for i in range(n):\n j=0\n while j<len(s)-1:\n if ord(s[j])-ord(s[j+1])==1:\n s.pop(j)\n c2+=1\n else:\n j+=1\n if len(s)==1:\n break\n p1=len(s) \n #print(s,2,1)\n for i in range(n):\n j=len(s)-1\n while j>0:\n if ord(s[j])-ord(s[j-1])==1:\n s.pop(j)\n c2+=1\n j-=1 \n #print(s,2,2) \n if p1==len(s):\n break\n#print(s,c2) \nprint(max(c1,c2)) "}, {"source_code": "n=int(input())\ns=str(input())\n\ndp=[[[0,\"\"] for i in range(n)] for i in range(n)]\n\ndef collapse(leftString,rightString):\n if len(leftString)==0 or len(rightString)==0:\n return [0,leftString+rightString]\n \n else:\n p1 = len(leftString)-1\n p2 = 0\n \n count = 0\n while(p1>=0 and p2<len(rightString)):\n if ord(leftString[p1])-ord(rightString[p2])==1:\n #leftWaala hatega\n p1=p1-1\n count+=1\n continue\n if ord(leftString[p1])-ord(rightString[p2])==-1:\n p2=p2+1\n count+=1\n continue\n break\n \n finalString = leftString[:p1+1] + rightString[p2:]\n #print(finalString)\n return [count,finalString]\n\nfor start in range(0,n):\n dp[start][start][0]=0\n dp[start][start][1]=s[start]\n\nfor diff in range(2,n+1):\n for start in range(0,n-diff+1):\n end = start + diff - 1\n dp[start][end][1]= s[start:end+1]\n\n#print(dp)\n\nfor diff in range(2,n+1):\n #startIndex\n for start in range(0,n-diff+1):\n end = start + diff - 1\n for k in range(start,end+1):\n prev=-1\n if k-1>=0:\n if ord(s[k])-ord(s[k-1])==1:\n prev=1\n if k+1<n:\n if ord(s[k])-ord(s[k+1])==1:\n prev=1\n if prev==-1:\n continue\n leftNumber,leftString,rightNumber,rightString=0,\"\",0,\"\"\n if k-1>=0:\n leftNumber,leftString = dp[start][k-1][0],dp[start][k-1][1]\n if k+1<n:\n rightNumber,rightString= dp[k+1][end][0],dp[k+1][end][1]\n \n ret = collapse(leftString,rightString)\n #print('-------')\n #print(ret,leftString,rightString,start,end,k,diff)\n #print('-------')\n ans = leftNumber + rightNumber + ret[0] + 1\n if ans>dp[start][end][0]:\n dp[start][end][0]=ans\n dp[start][end][1]=ret[1]\n\nprint(dp[0][len(s)-1][0])\n \n"}, {"source_code": "from sys import stdin\ninf=stdin\n#inf=open(\"data1.txt\",'rt')\n \nn=int(inf.readline())\ns=inf.readline()\ns=s[:n]\n \nchanged=False\nwhile not changed:\n#\tprint(\"dec\",s)\n\tchanged=True\n\ti=0\n\tll=len(s)\n\tfound=False\n\twhile(i+1<ll and ord(s[i])!=ord(s[i+1])+1):\n\t\ti+=1\n\tj=i\n\twhile(j+1<ll and ord(s[j])==ord(s[j+1])+1):\n\t\tj+=1\n\t\tfound=True\n \n\tif(found):\n\t\ts=s[:i]+s[j:]\n\t\tchanged=False\n \n#\tprint(\"inc\",s)\n\ti=0\n\tll=len(s)\n\tfound=False\n\twhile(i+1<ll and ord(s[i])!=ord(s[i+1])-1):\n\t\ti+=1\n\tj=i\n\twhile(j+1<ll and ord(s[j])==ord(s[j+1])-1):\n\t\tj+=1\n\t\tfound=True\n \n\tif(found):\n\t\ts=s[:i+1]+s[j+1:]\n\t\tchanged=False\n \nprint(n-len(s))\n# for i in dicti:\n# \ttemp=0\n# \tfor j in helper:\n# \t\tif(j[0]<=i[0] and j[1]<=i[1]):\n# \t\t\ttemp+=(i[0]-j[0]+1)*(i[1]-j[1]+1)\n# \t\tif(j[1]<=i[0] and j[0]<=i[1] and j[0]!=j[1]):\n# \t\t\ttemp+=(i[0]-j[1]+1)*(i[1]-j[0]+1)\n# \tcount+=temp*dicti[i]\n\n\n\n# def all_partitions(string):\n# for cutpoints in range(1 << (len(string)-1)):\n# result = []\n# lastcut = 0\n# for i in range(len(string)-1):\n# if (1<<i) & cutpoints != 0:\n# result.append(string[lastcut:(i+1)])\n# lastcut = i+1\n# result.append(string[lastcut:])\n# yield result\n\n# maxyet=0\n# store={'h': -6, 'e': -7, 'l': -8, 'o': 3, 'he': 3, 'hel': -3, 'el': 0, 'hell': 6, 'ell': -5, 'll': 10, 'hello': -3, 'ello': -8, 'llo': 9, 'lo': -6}\n\n# def quality(stri):\n# \treturn store[stri]\n\n# for partition in all_partitions(\"hel\"):\n# temp=0\n# for i in partition:\n# \ttemp+=quality(i)\n# if(temp>maxyet):\n# \tprint(partition)\n# \tmaxyet=temp\n\n# print(maxyet)"}, {"source_code": "n = int(input())\ns = input()\na = [chr(i + ord('a')) for i in range(25, -1, -1)]\nfor i in range(25):\n j = 0\n while j < len(s):\n if s[j] == a[i]:\n if j == 0:\n if len(s) != 1 and s[j + 1] == a[i + 1]:\n s = s[1:]\n else:\n j += 1\n elif j == len(s) - 1:\n if len(s) != 1 and s[j - 1] == a[i + 1]:\n s = s[:-1]\n else:\n j += 1\n else:\n if s[j - 1] == a[i + 1] or s[j + 1] == a[i + 1]:\n s = s[:j] + s[j + 1:]\n else:\n j += 1\n else:\n j += 1\nprint(n - len(s))\n"}, {"source_code": "n= int(input())\na=list(input())\nfor i in range(25,0,-1):\n cur=chr(97+i);prev=chr(96+i)\n for j in range(len(a)):\n if(j>=len(a)):\n break\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n #print(x,j,y,len(a),a)\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\nprint(n-len(a))\n \n\n"}, {"source_code": "n = int(input())\nstr = input()\nlst = list(str)\n\nfor i in range(122, 97, -1):\n l = len(lst)\n tmp = []\n bul = False\n for j in range(l):\n if ord(lst[j]) == i:\n if (j+1 < l and ord(lst[j+1]) == i-1) or (j-1 >= 0 and ord(lst[j-1]) == i-1):\n tmp.append(j)\n bul = True\n if bul == True:\n l = len(tmp)\n tmp.reverse()\n for j in tmp:\n del lst[j]\n i = i+1\n\nprint(n-len(lst))\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nn = int(input())\ns = [*map(ord, input().rstrip())]\nv = [(x, i) for i, x in enumerate(s)]\n\nans = 0\ni = n - 1\nwhile i >= 0:\n u, id = v[i]\n if (1 <= id and s[id-1] == u-1) or (id + 1 < len(s) and s[id+1] == u-1):\n s.pop(i)\n v = [(x, i) for i, x in enumerate(s)]\n i = len(s) - 1\n ans += 1\n else:\n i -= 1\nprint(ans)"}, {"source_code": "dp = {}\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\npos = {alphabet[i]:i for i in range(26)}\n\n# def compute(s):\n# \tglobal dp\n# \tif len(s)==1:\n# \t\treturn 0\n# \telif len(s) in dp and s in dp[len(s)]:\n# \t\treturn dp[len(s)][s]\n# \telse:\n# \t\tans = -1\n# \t\tfor i in range(len(s)):\n# \t\t\tif (i!=0 and pos[s[i-1]]==pos[s[i]]-1) or (i!=len(s)-1 and pos[s[i+1]]==pos[s[i]]-1):\n# \t\t\t\tnew_s = s[:i]+s[i+1:]\n# \t\t\t\tval = compute(new_s)\n# \t\t\t\tif val > ans:\n# \t\t\t\t\tans = val \n# \t\tif len(s) in dp:\n# \t\t\tdp[len(s)][s]=ans+1 \n# \t\telse:\n# \t\t\tdp[len(s)]={s:ans+1}\n# \t\treturn ans+1\n\ndef compute(s,n):\n\tif len(s)<=1:\n\t\treturn 0\n\tchar = alphabet[n]\n\tword = \"\"\n\tans=0\n\tfor i in range(len(s)):\n\t\tif s[i]==char:\n\t\t\tif (i!=0 and pos[s[i-1]]==pos[s[i]]-1) or (i!=len(s)-1 and pos[s[i+1]]==pos[s[i]]-1):\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\tans+=compute(word,n-1)\n\t\t\t\tword=\"\"\n\t\telse:\n\t\t\tword+=s[i]\n\tans+=compute(word,n-1)\n\treturn ans\n\ninput()\nprint(compute(input(),25))\n# print(dp)\n\n"}, {"source_code": "n = int(input())\nS = list(input())\nalphabet = 'abcdefghijklmnopqrstuvwxyz'\nans = 0\nnewS = []\ni = 0\nfor __ in range(1000):\n while i < n:\n candelete = 0\n j = 1\n if i + j < n and ord(S[i + j]) - ord(S[i + j - 1]) == 1:\n while j + i < n:\n if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:\n j += 1\n candelete += 1\n else:\n break\n newS.append(S[i])\n ans += candelete\n i += candelete\n i += 1\n S = newS.copy()\n n = len(S)\n i = n - 1\n newS = []\n while i > -1:\n candelete = 0\n j = -1\n if i + j > -1 and ord(S[i + j]) - ord(S[i + j + 1]) == 1:\n while j + i > -1:\n if 1 >= ord(S[i + j]) - ord(S[i + j + 1]) >= 0:\n j -= 1\n candelete += 1\n else:\n break\n newS.append(S[i])\n ans += candelete\n i -= candelete\n i -= 1\n S = newS.copy()\n n = len(S)\n newS = []\n i = 0\nprint(ans)"}, {"source_code": "alphabet = \"abcdefghijklmnopqrstuvwxyz\"\npos = {alphabet[i]:i for i in range(26)}\n\ndef compute(s,n):\n\tif len(s)<=1:\n\t\treturn 0\n\tchar = alphabet[n]\n\tword = []\n\tans=0\n\tfor i in range(len(s)):\n\t\tif s[i][0]==char:\n\t\t\tif (i!=0 and pos[s[i-1][0]]==pos[s[i][0]]-1) or (i!=len(s)-1 and pos[s[i+1][0]]==pos[s[i][0]]-1):\n\t\t\t\tans+=s[i][1]\n\t\t\telse:\n\t\t\t\tans+=compute(word,n-1)\n\t\t\t\tword=[]\n\t\telse:\n\t\t\tword.append(s[i])\n\tans+=compute(word,n-1)\n\t# print(s,end=\":\")\n\t# print(ans)\n\treturn ans\n\ndef simplify(s):\n\tlst = []\n\tfor i in range(len(s)):\n\t\tif not lst or lst[-1][0]!=s[i]:\n\t\t\tlst.append([s[i],1])\n\t\telse:\n\t\t\tlst[-1][1]+=1\n\treturn lst\n\n\nn= input()\ns = simplify(input())\nprint(compute(s,25))\n\n"}, {"source_code": "n = int(input())\ns = input()\ncnt = 0\nif(n>1):\n for char in range(ord('z'),ord('a')-1,-1):\n i=0\n while(len(s)>1 and i<len(s)):\n if(i==0):\n if(s[i]==chr(char) and s[i]==chr(ord(s[i+1])+1)):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n elif(i==len(s)-1):\n if(s[i]==chr(char) and s[i]==chr(ord(s[i-1])+1)):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n else:\n if(s[i]==chr(char) and ((s[i]==chr(ord(s[i+1])+1)) or (s[i]==chr(ord(s[i-1])+1)) )):\n s = s[:i]+s[i+1:]\n cnt+=1\n i=0\n i+=1\nprint(cnt)"}, {"source_code": "ans = 0\n\n\ndef check1(seq, i):\n if i == 0 or i == len(seq)-1:\n return False\n if seq[i] - seq[i-1] == 1 and seq[i] - seq[i+1] == 2:\n return True\n if seq[i] - seq[i+1] == 1 and seq[i] - seq[i-1] == 2:\n return True\n if seq[i] - seq[i-1] == 1 and seq[i] == seq[i+1]:\n return True\n if seq[i] - seq[i+1] == 1 and seq[i] == seq[i-1]:\n return True\n return False\n\n\ndef check2(seq, i):\n if i == 0 or i == len(seq)-1:\n return True\n if seq[i] - seq[i - 1] == 1 and seq[i + 1] - seq[i] >= 2:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i - 1] - seq[i] >= 2:\n return True\n if seq[i] - seq[i - 1] == 1 and seq[i] - seq[i + 1] >= 3:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i] - seq[i - 1] >= 3:\n return True\n if seq[i] - seq[i - 1] == 1 and seq[i] - seq[i + 1] == 1:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i] - seq[i - 1] == 1:\n return True\n return False\n\n\ndef check3(seq, i):\n if i == 0 or i == len(seq)-1:\n return False\n if seq[i] - seq[i - 1] == 1 and seq[i + 1] - seq[i] == 1:\n return True\n if seq[i] - seq[i + 1] == 1 and seq[i - 1] - seq[i] == 1:\n return True\n return False\n\n\ndef seq_to_str(seq):\n return ''.join([chr(s+ord('a')) for s in seq])\n\n\ndef make_move(seq):\n global ans\n candidates = []\n if len(seq) > 1:\n # Check first\n if seq[0] - seq[1] == 1:\n candidates.append(0)\n # Check others\n for i in range(1, len(seq) - 1):\n if seq[i]-seq[i+1] == 1 or seq[i]-seq[i-1] == 1:\n candidates.append(i)\n # Check last\n if seq[-1] - seq[-2] == 1:\n candidates.append(len(seq) - 1)\n #print(seq, candidates)\n\n if len(candidates) > 0:\n # Use priority\n priopity1 = list()\n priopity2 = list()\n priopity3 = list()\n for cand in candidates:\n if check1(seq, cand):\n priopity1.append(cand)\n elif check2(seq, cand):\n priopity2.append(cand)\n elif check3(seq, cand):\n priopity3.append(cand)\n candidates_sorted = sorted(priopity1, key=lambda cand: seq[cand], reverse=True) + sorted(priopity2, key=lambda cand: seq[cand], reverse=True) + sorted(priopity3, key=lambda cand: seq[cand], reverse=True)\n to_del_index = candidates_sorted[0]\n new_seq = seq[0:to_del_index]+seq[to_del_index+1:]\n print(seq_to_str(new_seq), to_del_index, check1(seq, to_del_index), check2(seq, to_del_index), check3(seq, to_del_index))\n ans += 1\n make_move(new_seq)\n\n\n_ = int(input())\nseq = [ord(s) - ord('a') for s in input()]\nmake_move(seq)\nprint(ans)\n"}, {"source_code": "n = int(input())\nc = input()\ns = [0] * n\nfor i in range(n):\n s[i] = [c[i], 0]\nfor i in range(26):\n a = chr(ord('z') - i)\n flag = True\n while flag:\n j = 0\n while j < len(s) and (s[j][0] != a or s[j][1] == 1):\n j += 1\n if j == len(s):\n flag = False\n else:\n s[j][1] = 1\n if j > 0 and s[j - 1][0] == chr(ord(a) - 1) or j < len(s) - 1 and s[j + 1][0] == chr(ord(a) - 1):\n s.pop(j)\nprint(n - len(s))"}, {"source_code": "import sys\nfrom array import array # noqa: F401\nfrom typing import List, Tuple, TypeVar, Generic, Sequence, Union # noqa: F401\n\n\ndef input():\n return sys.stdin.buffer.readline().decode('utf-8')\n\n\ndef main():\n from itertools import groupby\n n = int(input())\n a = [(ord(k), len(list(v))) for k, v in groupby('*' + input().rstrip() + '*')]\n\n ans = 0\n for cc in range(122, 96, -1):\n i = 1\n while i + 1 < len(a):\n if a[i][0] == cc and (a[i - 1][0] == cc - 1 or a[i + 1][0] == cc - 1):\n ans += a[i][1]\n a.pop(i)\n else:\n i += 1\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n=int(input())\ns=input()\nnum=[]\nfor i in s:\n num.append(ord(i))\nc=0\nfor m in range(n):\n le=len(num)\n ma=max(num)\n i1=num.index(ma)\n if le<2:\n break\n if i1==0:\n if num[i1+1]==(num[i1]-1):\n c+=1\n num.remove(ma)\n else:\n num[i1]=0\n elif i1==(le-1):\n if num[i1-1]==(num[i1]-1):\n c+=1\n num.remove(ma)\n else:\n num[i1]=0\n else:\n if num[i1-1]==(num[i1]-1) or num[i1+1]==(num[i1]-1):\n c+=1\n num.remove(ma)\n else:\n num[i1]=0\nprint(c)"}, {"source_code": "alphabet = \"abcdefghijklmnopqrstuvwxyz\"\npos = {alphabet[i]:i for i in range(26)}\n\ndef compute(s,n):\n\tif len(s)<=1:\n\t\treturn 0\n\tchar = alphabet[n]\n\tword = []\n\tans=0\n\tfor i in range(len(s)):\n\t\tif s[i][0]==char:\n\t\t\tif (i!=0 and pos[s[i-1][0]]==pos[s[i][0]]-1) or (i!=len(s)-1 and pos[s[i+1][0]]==pos[s[i][0]]-1):\n\t\t\t\tans+=s[i][1]\n\t\t\telse:\n\t\t\t\tans+=compute(word,n-1)\n\t\t\t\tword=[]\n\t\telse:\n\t\t\tword.append(s[i])\n\tans+=compute(word,n-1)\n\t# print(s,end=\":\")\n\t# print(ans)\n\treturn ans\n\ndef simplify(s):\n\tlst = []\n\tfor i in range(len(s)):\n\t\tif not lst or lst[-1][0]!=s[i]:\n\t\t\tlst.append([s[i],1])\n\t\telse:\n\t\t\tlst[-1][1]+=1\n\treturn lst\n\n\nn= input()\ns = simplify(input())\nprint(compute(s,25))\n\n"}, {"source_code": "n = int(input())\nu = list(input())\nlft = list(range(-1, n))\nrht = list(range(1, n)) + [-1]\nd = []\nfor i in range(97, 97 + 26):\n d.append(chr(i))\nd.reverse()\nans = 0\nfor k in range(len(d) - 1):\n for i in range(n):\n if u[i] == -1 or u[i] != d[k]:\n continue\n i1 = lft[i]\n j1 = rht[i]\n if i1 != -1 and u[i1] == d[k + 1] or\\\n j1 != -1 and u[j1] == d[k + 1]:\n u[i] = -1\n ans += 1\n if lft[i] != -1 and rht[i] != -1:\n rht[lft[i]], lft[rht[i]] = rht[i], lft[i]\n elif lft[i] != -1:\n rht[lft[i]] = rht[i]\n elif rht[i] != -1:\n lft[rht[i]] = lft[i]\n## print(*u, \"****\", d[k])\n## print(*lft)\n## print(*rht)\n## print()\n\nprint(ans)\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\ns = input().strip()\nans = 0\nwhile True:\n ansn = ans\n for i in xrange(25):\n new_s = ''\n for j in xrange(len(s)):\n if s[j] == chr(122-i) and ((j>0 and s[j-1] == chr(122-i-1)) or (j<len(s)-1 and s[j+1] == chr(122-i-1))):\n ans += 1\n else:\n new_s += s[j]\n s = new_s\n if ansn == ans:\n break\nprint(ans)\n"}, {"source_code": "import sys\nimport math\nread = lambda: list(map(int, sys.stdin.readline().strip().split()))\n\nn = int(input())\ns = input()\na = []\nfor i in range(n):\n a.append(s[i])\nmark = [0]*26\nfor num in a:\n mark[ord(num)-97] += 1\ncur = 25\nflag = True\nwhile len(a) > 1:\n #print(a)\n if cur > 0 and mark[cur] == 0:\n while mark[cur] == 0:\n cur -= 1\n if cur == 0:\n break\n #print(cur)\n i = 0\n while i < len(a):\n if ord(a[i]) - 97 == cur:\n mark[cur] -= 1\n if i == 0:\n if ord(a[i]) - ord(a[i+1]) == 1:\n del a[i]\n else:\n i += 1\n elif i == len(a) - 1:\n if ord(a[i]) - ord(a[i-1]) == 1:\n del a[i]\n else:\n i += 1\n else:\n if ord(a[i]) - ord(a[i-1]) == 1 or ord(a[i]) - ord(a[i+1]) == 1:\n del a[i]\n else:\n i += 1\n else:\n i += 1\n\n\n\n\nprint(n-len(a))\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import re\nn=int(input());s=input();y='z'\nwhile'a'<y:\n x=y+'*'\n y=chr(ord(y)-1)\n s=re.sub(x+y+x,y,s)\n print(y, x+y+x, s)\nprint(n-len(s))"}, {"source_code": "import sys \n# sys.setrecursionlimit(10**6) \nfrom sys import stdin, stdout\nimport bisect #c++ upperbound\nimport math\nimport heapq\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef cin():\n return map(int,sin().split())\ndef ain(): #takes array as input\n return list(map(int,sin().split()))\ndef sin():\n return input()\ndef inin():\n return int(input())\nimport math \ndef Divisors(n) : \n l = [] \n for i in range(1, int(math.sqrt(n) + 1)) :\n if (n % i == 0) : \n if (n // i == i) : \n l.append(i) \n else : \n l.append(i)\n l.append(n//i)\n return l\n\n \n\"\"\"*******************************************************\"\"\"\ndef main():\n n=inin()\n s=sin()\n a=list(s)\n x=ord(\"a\")\n ans=0\n for i in range(26):\n y=chr(x+25-i)\n n=len(a)\n for j in range(n):\n if(a[j]==y):\n if(j>0 and (a[j-1]==chr(ord(y)-1) or a[j-1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n elif(j<n-1 and (a[j+1]==chr(ord(y)-1) or a[j+1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n a[:] = (value for value in a if value != \"*\")\n # print(a)\n print(ans)\n######## Python 2 and 3 footer by Pajenegod and c1729\n \n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n \n# So on cf, use PyPy2 for best string performance.\n \npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n \nimport os, sys\nfrom io import IOBase, BytesIO\n \nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n \n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n \n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n \n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n \n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\n self.write = lambda s:self.buffer.write(s.encode('ascii'))\n self.read = lambda:self.buffer.read().decode('ascii')\n self.readline = lambda:self.buffer.readline().decode('ascii')\n \n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n \n# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n \n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n \nif __name__== \"__main__\":\n main()"}, {"source_code": "import sys\nreader = (s.rstrip() for s in sys.stdin)\ninput = reader.__next__\n\n\nif __name__ == '__main__':\n t= int(input())\n word=input()\n res=0\n while True:\n n=len(word)\n toremove=[]\n\n if n==1:\n break\n for i in range(n):\n #print(toremove,ord(word[i]))\n if i==0:\n if ord(word[i])==ord(word[i+1])+1:\n \n if not toremove or toremove[-1]!=i:\n \n \n toremove.append(i)\n elif i==n-1:\n \n if ord(word[i])==ord(word[i-1])+1:\n \n if not toremove or toremove[-1]!=i:\n \n\n toremove.append(i)\n else:\n if (ord(word[i])==ord(word[i+1])+1 and ord(word[i])!=ord(word[i-1])-1) or (ord(word[i])==ord(word[i-1])+1 and ord(word[i])!=ord(word[i+1])-1):\n\n if not toremove or toremove[-1]!=i:\n \n toremove.append(i)\n \n res+=len(toremove)\n if not toremove:\n break\n counter=0\n for i in toremove:\n \n word=word[:(i-counter)]+word[(i-counter)+1:]\n counter+=1\n #print(word)\n #print(toremove,word)\n print(res)\n\n \n"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n print(1)\n exit()\n\nl = []\nfor i in s:\n l.append(ord(i)-97)\n\nf = 1\nwhile f:\n o = []\n m = -1\n d = -1\n i = 0\n f = 0\n if len(l) == 1:\n break\n\n while i < len(l):\n if i == 0:\n if l[i]-1 == l[i+1]:\n if l[i] > m:\n f = 1\n m = l[i]\n d = i\n\n i = i + 1\n continue\n\n if i == len(l)-1:\n if l[i]-1 == l[i-1]:\n if l[i] > m:\n f = 1\n m = l[i]\n d = i\n\n i = i+1\n continue\n\n if l[i]-1 == l[i-1] or l[i]-1 == l[i+1]:\n if l[i] > m:\n f = 1\n m = l[i]\n d = i\n\n i = i+1\n\n for i in range(len(l)):\n if i == d:\n continue\n\n o.append(l[i])\n\n l = o\n\nprint(n-len(l))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Mar 3 19:29:45 2020\n\n@author: hp\n\"\"\"\n\nn = int(input())\ns = input()\ncount= 0\nlst=[]\nfor i in s:\n lst.append(ord(i))\nfor k in range(n):\n for j in range(123,97,-1):\n for i in range(len(lst)-1):\n if lst[i]==lst[i+1]-1:\n if(lst[i+1]==j):\n lst.pop(i+1)\n count+=1\n break\n elif(lst[i]-1==lst[i+1]):\n if(lst[i]==j):\n lst.pop(i)\n count+=1\n break\nprint(count)"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 01.03.2020\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\nfrom math import ceil,floor,log,sqrt,factorial\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[1] \ndef sort2(l):return sorted(l, key=getKey,reverse=True)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(n-r))\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n\ndef s(a):\n \n while a>=10:\n x=0 \n while a:\n x+=a%10\n a//=10\n a=x\n return a\n\n\n\ndef main():\n \n\n #for _ in range(ii()):\n \n \n n=ii()\n s=list(si())\n x=n\n if n==1:\n print(0)\n exit()\n\n for i in range(25,0,-1):\n\n if(len(s)==1):\n break\n j=0\n while j<n:\n\n if(len(s)==1):\n break\n\n if s[j]==abc[i]:\n\n if j==0:\n\n if abd[s[j+1]]==i-1:\n del s[j]\n j-=1\n n-=1\n\n\n elif j==n-1:\n\n if abd[s[j-1]]==i-1:\n del s[j]\n j-=1\n n-=1\n\n else:\n\n\n\n if abd[s[j+1]]==i-1:\n del s[j]\n n-=1\n j-=1\n \n else:\n\n if abd[s[j-1]]==i-1:\n del s[j]\n j-=1\n n-=1\n\n\n\n j+=1\n\n print(x-n)\n\n\n\n\n\n\n\n \n\n\n \n \n\n\n\n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n"}, {"source_code": "def front(s,b):\n\tif len(s)==1:\n\t\treturn s\n\t\n\tif b==1:\n\t\ts=s[::-1]\n\tt=''\n\tfor i in range(len(s)-1):\n\t\t#print s[i],s[i+1],ord(s[i])-ord(s[i+1])\n\t\tif ord(s[i])-ord(s[i+1])==1:\n\t\t\tpass\n\t\telse:\n\t\t\tt+=s[i]\n\n\tt+=s[-1]\n\tif b==1:\n\t\tt=t[::-1]\n\treturn t\n\t\t\nn=input()\ns=raw_input()\nl=[-1,n]\nwhile l[-1]!=l[-2]:\n\ts=front(s,1)\n\tl.append(len(s))\n\ts=front(s,0)\n\tl.append(len(s))\n\ts=front(s,1)\n\tl.append(len(s))\nprint n-l[-1]\n"}, {"source_code": "n= int(input())\na=list(input());le=n\nwhile(True):\n b=True\n for i in range(le):\n if(i>le-1 or a[i]=='a'):\n break\n cur=a[i];prev=chr(ord(a[i])-1)\n \n x=i-1 if(i!=0) else 0\n y=i+1 if(i!=(le-1)) else i\n if(a[x]==prev or a[y]==prev):\n a.pop(i)\n le-=1\n b=False\n if(b):\n break\nprint(n-len(a),*a)\n \n"}, {"source_code": "from collections import defaultdict\n\nalpha = 'abcdefghijklmnopqrstuvwxyz'\nd = defaultdict(int)\nc = 0\n\nfor alpha_i in alpha:\n d[alpha_i] = c\n c += 1\n\nn = int(input())\ns = input()\nl = [d[s[i]] for i in range(n)]\nans = 0\n\nwhile True:\n if len(l)==1:\n break\n\n rem = set()\n \n for i in range(len(l)):\n if i==0:\n if l[i]==l[i+1]+1:\n rem.add(i)\n elif i==len(l)-1:\n if l[i]==l[i-1]+1:\n rem.add(i)\n else:\n if l[i] in [l[i-1]+1, l[i+1]+1]:\n rem.add(i)\n \n if len(rem)==0:\n break\n \n ans += len(rem)\n new_l = []\n \n for i in range(len(l)):\n if i not in rem:\n new_l.append(l[i])\n \n l = new_l\n\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nl = [ord(i) for i in s]\ncnt=0\nwhile(len(l)>0):\n mxchar = max(l)\n mxindex = l.index(mxchar)\n if((mxindex-1>=0 and l[mxindex-1]-l[mxindex]==-1) or\n (mxindex+1<n and l[mxindex+1]-l[mxindex]==-1)):\n l.remove(mxchar)\n cnt+=1\n n-=1\n else:\n l.remove(mxchar)\n n-=1\nprint(cnt)\n\n\n\n\n\n \n \n \n \n \n \n\n"}, {"source_code": "n=int(input())\nS=[\"#\"]+list(input())+[\"#\"]\n\nANS=0\nfor i in range(25,-1,-1):\n for j in range(n):\n while j<len(S) and ord(S[j])-97==i and (ord(S[j-1])-97==i-1 or ord(S[j+1])-97==i-1):\n ANS+=1\n S.pop(j)\nprint(ANS)\n \n"}, {"source_code": "from math import *\nalf = list(reversed('abcdefghijklmnopqrstuvwxyx'))\ndef adj(a, b):\n return chr(ord(a) - 1) == b\n \nn = int(input())\ns = [i for i in input()]\nfor i in range(n*2):\n for a in alf:\n i = 0\n while i < len(s):\n if s[i] == a and i > 0 and adj(s[i], s[i-1]):\n s.pop(i)\n elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):\n s.pop(i)\n else:\n i += 1\n \nprint(n - len(s))\n"}, {"source_code": "def i(): return input()\ndef ii(): return int(input())\ndef iis(): return map(int, input().split())\ndef liis(): return list(map(int, input().split()))\n\nn = int(input())\ns = input()\na = []\n\nfor i in range(len(s)):\n\ta.append(s[i])\n\na = sorted(a)[::-1]\n\ncount = 0\ntodos = set()\nfor c in a:\n\tfor j in range(n):\n\t\tfor i in range(len(s)):\n\t\t\tif s[i] == c and (i > 0 and ord(s[i-1]) == ord(s[i])-1) or (i < len(s)-1 and ord(s[i+1]) == ord(s[i])-1):\n\t\t\t\ts = s[:i] + s[i+1:]\n#\t\t\t\tprint(s, i)\n\t\t\t\tcount += 1\n\t\t\t\tbreak\n\nprint(count)\n"}, {"source_code": "import functools\n\ns_len = int(input())\ns = input()\nassert len(s) == s_len\n\ndef adj(a, b):\n return abs(ord(a) - ord(b)) == 1\n\n@functools.lru_cache(maxsize=None)\ndef max_moves(string):\n if len(string) <= 1: return 0\n\n if len(string) == 2:\n if adj(string[0], string[1]):\n return 1\n else:\n return 0\n\n split, c = max(enumerate(string), key=lambda x: x[1])\n\n if (split == 0 or adj(string[split-1], c)) or (split == len(string)-1 or adj(string[split+1], c)):\n with_split = 1 + max_moves(string[:split] + string[split+1:])\n else:\n with_split = -1\n\n no_split = max_moves(string[:split]) + max_moves(string[split+1:])\n\n return max(with_split, no_split)\n\nprint(max_moves(s))\n"}, {"source_code": "import string\n\nn = int(input())\na = list(input())\n\nfor i in list(string.ascii_lowercase[::-1]):\n if i != 'a':\n j = 0\n while j != len(a):\n ch = False\n if len(a) > 1 and a[j] == i:\n if j != len(a) - 1:\n if a[j] == chr(ord(a[j+1]) + 1):\n a[j] = ''\n ch = True\n if j != 0:\n if a[j] == chr(ord(a[j-1]) + 1):\n a[j] = ''\n ch = True\n if ch:\n j -= 1\n a = list(filter(lambda x: x != '', a))\n j += 1\n\n\nprint(n - len(a))"}, {"source_code": "import sys\nimport math\nread = lambda: list(map(int, sys.stdin.readline().strip().split()))\n\nn = int(input())\ns = input()\na = []\nfor i in range(n):\n a.append(s[i])\nmark = [0]*26\nfor num in a:\n mark[ord(num)-97] += 1\ncur = 25\nflag = True\nwhile len(a) > 1:\n #print(a)\n if cur > 0 and mark[cur] == 0:\n while mark[cur] == 0:\n cur -= 1\n if cur == 0:\n break\n #print(cur)\n i = 0\n while i < len(a):\n if ord(a[i]) - 97 == cur:\n mark[cur] -= 1\n if i == 0:\n if ord(a[i]) - ord(a[i+1]) == 1:\n del a[i]\n else:\n i += 1\n elif i == len(a) - 1:\n if ord(a[i]) - ord(a[i-1]) == 1:\n del a[i]\n else:\n i += 1\n else:\n if ord(a[i]) - ord(a[i-1]) == 1 or ord(a[i]) - ord(a[i+1]) == 1:\n del a[i]\n else:\n i += 1\n else:\n i += 1\n\n\n\n\nprint(n-len(a))\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n print(0)\nelse:\n alph = \"abcdefghijklmnopqrstuvwxyz\"\n while True:\n if len(s) == 1:\n break\n mx = 'a'\n index = -1\n for i in range(1, len(s) - 1):\n if s[i] > mx and alph[alph.find(s[i]) - 1] == s[i - 1] or alph[alph.find(s[i]) - 1] == s[i + 1]:\n mx = max(mx, s[i])\n index = i\n if s[0] > mx and alph[alph.find(s[0]) - 1] == s[1]:\n index = 0\n mx = s[0]\n if s[-1] > mx and alph[alph.find(s[-1]) - 1] == s[-2]:\n index = len(s) - 1\n mx = alph[alph.find(s[-1]) - 1]\n if index == -1:\n break\n else:\n s = s[:index] + s[index + 1:]\n print(n - len(s))\n\n"}, {"source_code": "import sys\nimport os\nimport time\nimport collections\nfrom collections import Counter, deque\nimport itertools\nimport math\nimport timeit\nimport random\nimport string\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n\ndef divs(n, start=1):\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\ndef flin(d, x, default=-1):\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return (default, default)\n else:\n return (left, right)\n\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\n\n\n# input = sys.stdin.readline\n\nn = ii()\ns = [ord(i) for i in input()]\nres = 0\nwhile len(s) > 1:\n n = len(s)\n i = 0\n l = r = 0\n m = 1\n while i < n:\n j = i\n while j < n - 1 and s[j + 1] - s[j] == 1: j += 1\n if j - i > r - l:\n l, r = i, j\n m = 1\n j = i\n while j < n - 1 and s[j + 1] - s[j] == -1: j += 1\n if j - i > r - l:\n l, r = i, j\n m = 0\n i += 1\n if r - l > 0:\n res += r - l\n s = s[:l+m] + s[r+m:]\n else:\n break\nprint(res)\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nS = list(input())\nalphabet = 'abcdefghijklmnopqrstuvwxyz'\nans = 0\nnewS = []\ni = 0\nfor __ in range(1000):\n while i < n:\n candelete = 0\n j = 1\n if i + j < n and ord(S[i + j]) - ord(S[i + j - 1]) == 1:\n while j + i < n:\n if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:\n j += 1\n candelete += 1\n else:\n break\n newS.append(S[i])\n ans += candelete\n i += candelete\n i += 1\n S = newS.copy()\n n = len(S)\n i = n - 1\n newS = []\n while i > -1:\n candelete = 0\n j = -1\n if i + j > -1 and ord(S[i + j]) - ord(S[i + j + 1]) == 1:\n while j + i > -1:\n if 1 >= ord(S[i + j]) - ord(S[i + j + 1]) >= 0:\n j -= 1\n candelete += 1\n else:\n break\n newS.append(S[i])\n ans += candelete\n i -= candelete\n i -= 1\n S = newS.copy()\n n = len(S)\n newS = []\n i = 0\nprint(ans)"}, {"source_code": "n= int(input())\na=list(input())\nfor i in range(25,0,-1):\n cur=chr(97+i);prev=chr(96+i)\n for j in range(len(a)):\n if(j>=len(a)):\n break\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n #print(x,j,y,len(a),a)\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\n for j in range(len(a)-1,-1,-1):\n if(j>=len(a)):\n break\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n #print(x,j,y,len(a),a)\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\nprint(n-len(a))\n \n"}, {"source_code": "def is_right_less(s, i): \n return i+1 <len(s) and ord(s[i]) - ord(s[i+1]) == 1\n\ndef is_left_less(s, i):\n return i-1 >= 0 and ord(s[i]) - ord(s[i-1]) == 1\n\ndef check_neighbours(s, i):\n if is_left_less(s, i) or is_right_less(s, i):\n return i\n else:\n return -10\n \ndef remove_neighbors(s: str) -> int:\n s = list(s)\n removed = 0\n while len(s) != 0: # O(n)\n biggest_cand = -1\n remove_id = -1\n \n for j in range(len(s)): # O(n)\n c = check_neighbours(s, j)\n if c>=0 and ord(s[c]) > biggest_cand:\n remove_id = c\n\n if remove_id >= 0:\n s.pop(remove_id) # O(n)\n removed += 1\n else:\n break\n\n return removed\n\nlen_s = int(input())\ns = input()\nprint(remove_neighbors(s))\n\n# sum = O(n(n+n)) = O(n*2n) = O(2n^2) = O(n^2)\n"}, {"source_code": "import sys\nfrom collections import defaultdict\n# input=sys.stdin.readline\np=\"abcdefghijklmnopqrstuvwxyz\"\nd=dict()\nfor i in range(26):\n d[p[i]]=i\nn=int(input())\ns=list(input())\nm=0\nfor c in reversed(p):\n while True:\n for j in range(len(s)):\n if s[j]==c and j>0 and (d[s[j]]==d[s[j-1]]+1 or d[s[j]]==d[s[j-1]]-1):\n s.remove(c)\n m+=1\n break\n elif s[j]==c and j<len(s)-1 and (d[s[j]]==d[s[j+1]]+1 or d[s[j]]==d[s[j+1]]-1):\n s.remove(c)\n m+=1\n break\n else:\n break\nprint(m)\n"}, {"source_code": "n=int(input())\ns=input()+'0'\nnum=[]\nco=1\nfor i in range(n):\n if s[i]==s[i+1]:\n co+=1\n else:\n num.append([ord(s[i]),co])\n co=1\nc=0\nfor m in range(n):\n le=len(num)\n mi=max(num)\n ma=mi[0]\n i1=num.index(mi)\n if le<2:\n break\n if i1==0:\n if num[i1+1][0]==(num[i1][0]-1):\n c+=num[i1][1]\n num.remove(mi)\n else:\n num[i1][0]=0\n elif i1==(le-1):\n if num[i1-1][0]==(num[i1][0]-1):\n c+=num[i1][1]\n num.remove(mi)\n else:\n num[i1][0]=0\n else:\n if num[i1-1][0]==(num[i1][0]-1) or num[i1+1][0]==(num[i1][0]-1):\n c+=num[i1][1]\n num.remove(mi)\n else:\n num[i1][0]=0\nprint(c)"}, {"source_code": "from math import *\nalf = list(reversed('abcdefghijklmnopqrstuvwxyx'))\ndef adj(a, b):\n return chr(ord(a) - 1) == b\n\nn = int(input())\ns = [i for i in input()]\nfor a in alf:\n i = 0\n while i < len(s):\n if s[i] == a and i > 0 and adj(s[i], s[i-1]):\n s.pop(i)\n elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):\n s.pop(i)\n else:\n i += 1\n\nprint(n - len(s))\n \n"}, {"source_code": "import math \nfrom collections import *\n\nn = int(input())\ns = input()\n\nflag = True\n\nans = 0\n\nwhile flag and len(s)>1:\n flag = False\n for i in range(len(s)):\n if i == 0:\n if ord(s[i])-ord(s[i+1]) == 1:\n ans+=1\n flag = True\n s = s[1:len(s)]\n break\n elif i == len(s)-1:\n if ord(s[i])-ord(s[i-1]) == 1:\n ans+=1\n flag = True\n s = s[0:len(s)-1]\n break\n else:\n if ord(s[i+1])-ord(s[i]) !=1 and ord(s[i-1])-ord(s[i]) !=1:\n if ord(s[i+1])-ord(s[i]) ==-1 or ord(s[i-1])-ord(s[i]) ==-1:\n flag = True \n ans+=1\n s1 = s[0:i]\n s2 = s[i+1:len(s)]\n s = s1+s2\n break\nprint(ans)"}, {"source_code": "t=int(input())\ns=input()\nans=''\ncount=0\nwhile(True):\n flag=True\n for i in range(len(s)):\n if s[i]=='a':\n continue\n if (i==0 or ord(s[i-1])-ord(s[i])!=1) and (i==len(s)-1 or ord(s[i+1])-ord(s[i])!=1):\n s=s[:i]+s[i+1:len(s)]\n flag=False\n count+=1\n break\n if(flag):\n break\nprint(count)"}, {"source_code": "import string\n\nn = int(input())\na = list(input())\n\nfor i in list(string.ascii_lowercase[::-1]):\n if i != 'a':\n j = 0\n while j != len(a):\n ch = False\n if len(a) > 1 and a[j] == i:\n if j != len(a) - 1:\n if a[j] == chr(ord(a[j+1]) + 1):\n a[j] = ''\n ch = True\n if j != 0:\n if a[j] == chr(ord(a[j-1]) + 1):\n a[j] = ''\n ch = True\n if ch:\n j -= 1\n a = list(filter(lambda x: x != '', a))\n j += 1\n\n\nprint(n - len(a))"}, {"source_code": "n = int(input())\ns = input()\ns = [ord(i) for i in s]\nout = 0\nwhile s:\n o1 = 0\n f = 0\n p = s[:]\n for i in range(n-1):\n if abs(s[i]-s[i+1])==1:\n f = 1\n if s[i]<s[i+1]:\n p[i+1] = -1\n else:\n p[i] = -1\n o1 += 1\n out += o1\n snew = [i for i in p if i!=-1]\n if snew == s:\n break\n else:\n s = snew\n n = len(s)\nprint(out)"}, {"source_code": "n = int(input())\ns = input()\nif n == 1:\n print(0)\nelse:\n alph = \"abcdefghijklmnopqrstuvwxyz\"\n while True:\n if len(s) == 1:\n break\n mx = 'a'\n index = -1\n for i in range(1, len(s) - 1):\n if s[i] > mx and (alph[alph.find(s[i]) - 1] == s[i - 1] or alph[alph.find(s[i]) - 1] == s[i + 1]):\n mx = max(mx, s[i])\n index = i\n if s[0] > mx and alph[alph.find(s[0]) - 1] == s[1]:\n index = 0\n mx = s[0]\n if s[-1] > mx and alph[alph.find(s[-1]) - 1] == s[-2]:\n index = len(s) - 1\n mx = alph[alph.find(s[-1]) - 1]\n if index == -1:\n break\n else:\n print(s[index])\n s = s[:index] + s[index + 1:]\n print(n - len(s))\n\n"}, {"source_code": "n= int(input())\na=list(input())\nfor i in range(25,0,-1):\n cur=chr(97+i);prev=chr(96+i)\n for j in range(len(a)):\n if(j>=len(a)):\n break\n x=j-1 if j!=0 else j\n y=j+1 if j!=len(a)-1 else j\n #print(x,j,y,len(a),a)\n if(a[j]==cur and (a[x]==prev or a[y]==prev)):\n a.pop(j)\nprint(n-len(a))\n \n\n"}, {"source_code": "import functools\n\ns_len = int(input())\ns = input()\nassert len(s) == s_len\n\ndef adj(a, b):\n return abs(ord(a) - ord(b)) == 1\n\n@functools.lru_cache(maxsize=None)\ndef max_moves(string):\n if len(string) <= 1: return 0\n\n if len(string) == 2:\n if adj(string[0], string[1]):\n return 1\n else:\n return 0\n\n split, c = max(enumerate(string), key=lambda x: x[1])\n\n if (split != 0 and adj(string[split-1], c)) or (split != len(string)-1 and adj(string[split+1], c)):\n with_split = 1 + max_moves(string[:split] + string[split+1:])\n else:\n with_split = -1\n\n no_split = max_moves(string[:split]) + max_moves(string[split+1:])\n\n return max(with_split, no_split)\n\nprint(max_moves(s))\n"}, {"source_code": "n=int(input())\nalphabet=\"abcdefghijklmnopqrstuvwxyz\"\ny=input()\nans=0\nfor i in range(25):\n for j in range(len(y)):\n cont=True\n while cont==True:\n if (j<len(y) and y[len(y)-1-j]==alphabet[25-i]):\n if (j<len(y)-1 and y[len(y)-2-j]==alphabet[24-i]) or (j>0 and y[len(y)-j]==alphabet[24-i]):\n ans+=1\n y=y[:len(y)-1-j]+y[len(y)-j:]\n else:\n cont=False\n else:\n cont=False\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\n\nl = []\nfor i in range(n):\n\tt = ord(s[i])\n\tif t not in l:\n\t\tl.append(t)\n\nl.sort(reverse = True)\n\nc = 0\n\nwhile len(l) > 1:\n\tj = 0\n\twhile j < len(s):\n\t\tif ord(s[j]) == (l[0]):\n\t\t\tif j == 0:\n\t\t\t\tif ord(s[1]) == l[0] - 1:\n\t\t\t\t\ts = s[1:]\n\t\t\t\t\tc += 1\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telif j == len(s) - 1:\n\t\t\t\tif ord(s[len(s) - 2]) == l[0] - 1:\n\t\t\t\t\ts = s[:len(s) - 1]\n\t\t\t\t\tc += 1\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\t\telse:\n\t\t\t\tif ord(s[j + 1]) == l[0] - 1 or ord(s[j - 1]) == l[0] - 1:\n\t\t\t\t\ts = s[:j] + s[j + 1:]\n\t\t\t\t\tc += 1\n\t\t\t\telse:\n\t\t\t\t\tj += 1\n\t\telse:\n\t\t\tj += 1\n\tl.pop(0)\n\nprint(c)"}, {"source_code": "import math\n#q=int(input())\nq=1\nfor _ in range(q):\n n=int(input())\n #a,b=map(int,input().split())\n l=list(input())\n a=[0]*26\n b=[0]*26\n for i in range(n):\n a[ord(l[i])-97]=1\n b[ord(l[i])-97]+=1\n #print(a)\n ans=0\n #print(chr(1+97))\n for i in range(25,0,-1):\n if a[i]==1:\n while(b[i]>0):\n for j in range(len(l)):\n if l[j]==chr(i+97):\n if j>0 and l[j-1]==chr(i+96):\n l.pop(j)\n ans+=1\n b[i]-=1\n break\n elif j<len(l)-1 and l[j+1]==chr(i+96): \n l.pop(j)\n ans+=1\n b[i]-=1\n break\n else:\n b[i]=0\n print(ans) "}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nn=int(input())\na=[ord(i)-97 for i in input()]\nmaxx=0\nfor i in range(n):\n st1=a[:i]\n st=[]\n for j in range(i,n):\n if not st: st.append(a[j])\n else:\n if a[j]+1==st[-1]:\n st.pop()\n st.append(a[j])\n elif st[-1]+1==a[j]:\n continue\n else:\n st.append(a[j])\n stt=st1[:]+st[:]\n st2=[]\n for j in range(len(st1)):\n if not st2: st2.append(st1[j])\n else:\n if a[j]+1==st2[-1]:\n st2.pop()\n st2.append(st1[j])\n elif st2[-1]+1==st1[j]:\n continue\n else:\n st2.append(st1[j])\n rsst=[]\n rst=[]\n sttt=st2[:]+st[:]\n for j in range(len(stt)):\n if not rst: rst.append(stt[j])\n else:\n if stt[j]+1==rst[-1]:\n rst.pop()\n rst.append(stt[j])\n elif rst[-1]+1==stt[j]:\n continue\n else:\n rst.append(stt[j])\n for j in range(len(sttt)):\n if not rsst: rsst.append(sttt[j])\n else:\n if sttt[j]+1==rsst[-1]:\n rsst.pop()\n rsst.append(sttt[j])\n elif rsst[-1]+1==sttt[j]:\n continue\n else:\n rsst.append(stt[j])\n maxx=max(maxx,n-len(rst),n-len(rsst))\nprint(maxx)\n \n \n \n \n\n\n \n\n "}, {"source_code": "from math import *\nalf = list(reversed('abcdefghijklmnopqrstuvwxyx'))\ndef adj(a, b):\n return chr(ord(a) - 1) == b\n \nn = int(input())\ns = [i for i in input()]\nfor j in range(n*2):\n for a in alf:\n i = 0\n while i < len(s):\n if s[i] == a and i > 0 and adj(s[i], s[i-1]):\n s.pop(i)\n elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):\n s.pop(i)\n else:\n i += 1\n \nprint(n - len(s))\n"}], "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38"} {"source_code": "s=input().split()\ntot=[]\ns[2]=str(int(s[2])//2)\ns[3]=str(int(s[3])//7)\ns[4]=str(int(s[4])//4)\ns=map(int,s)\nprint(min(s))", "positive_code": [{"source_code": "a = map(int,raw_input().split())\nasum = [a[0],a[1],a[2]/2,a[3]/7,a[4]/4]\namin = asum[0]\nfor e in asum:\n\tif e<amin:\n\t\tamin = e\nprint amin\n\t\t\n"}, {"source_code": "import sys\n\nx = map(int,raw_input().split())\ny = [x[0],x[1],x[2]/2,x[3]/7,x[4]/4]\n\nprint min(y)"}, {"source_code": "import sys,math\n\ndef read_ints():\n s = sys.stdin.readline()\n s = s.split()\n #pairs = [map(int, raw_input().split()) for _ in raw_input().split()]\n arr = [int(q) for q in s]\n return arr\n \n \nwgs = [1,1,2,7,4]\ninps = read_ints() + [0,0,0,0,0,0,0,0]\nres = [inps[q]/wgs[q] for q in range(5)]\nminv = res[0]\nfor q in res:\n if q < minv:\n minv = q\n\n\n\nprint minv"}, {"source_code": "b = [1,1,2,7,4]\na = map(int,raw_input().split())\nans = 12234567890\nfor i in range(5):\n ans = min(ans,a[i]/b[i])\nprint ans\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\tinput = map(int,sys.stdin.readline().split())\n\tinput[2] /= 2\n\tinput[3] /= 7\n\tinput[4] /= 4\n\tprint min(input)\n\t\n"}, {"source_code": "a, b, c, d, e = map(int, raw_input().split())\nprint min(a, b, c/2, d/7, e/4)"}, {"source_code": "#I don't speak latin, but from what I have read\n#online, it seems that the question is asking for\n#the maximum amount of glass you can produce given\n#this amount of compounds.\n#Each compound requires a certain amount which is what\n#the I, II, VII, IV (1, 2, 7, 4) mean (respectively)\n\na, b, c, d, e = map(int, raw_input().split())\nc /= 2; d /= 7; e /= 4\nprint min(a, b, c, d, e)"}, {"source_code": "l = map(int, raw_input().split())\nq = [1, 1, 2, 7, 4]\nprint min(a / b for (a, b) in zip(l, q))"}, {"source_code": "a = raw_input().split()\nwhile len(a) != 5:\n\tpass\na = [int(i) for i in a]\nb = [1, 1, 2, 7, 4]\nprint min(a[i]/b[i] for i in range(5))\n"}, {"source_code": "import sys\nimport string\n\na,b,c,d,e = map(int, raw_input().split())\n\nprint min(a, b, c/2, d /7, e/4)\n\n"}, {"source_code": "a = map(int, raw_input().split())\nb = [1,1,2,7,4]\nprint min(map(lambda q: q[0]/q[1], zip(a,b)))"}, {"source_code": "\nns = map(int, raw_input().split())\nns[2] /= 2\nns[3] /= 7\nns[4] /= 4\n\nprint min(ns)\n"}, {"source_code": "a = map(int, raw_input().split(' ') )\nb = [1, 1, 2, 7, 4]\n\nc = [0] * 5\nfor x in xrange(len(a)):\n\tc[x] += a[x%5]\n\nmax_ = 0\nfor x in xrange(5):\n\tc[x] = c[x] / b[x]\n\nprint min(c)"}, {"source_code": "# 1 1 2 7 4\na, b, c, d, e = raw_input().split()\na = int(a)\nb = int(b)\nc = int(c)/2\nd = int(d)/7\ne = int(e)/4\nprint min(a, b, c, d, e)"}, {"source_code": "import sys\n\n\na = sys.stdin.readline().strip().split()\n\nans = min(int(a[0]), int(a[1]))\nans = min(ans, int(a[2])//2)\nans = min(ans, int(a[3])//7)\nans = min(ans, int(a[4])//4)\n\nprint ans\n"}, {"source_code": "a, b, c, d, e = map(int, raw_input().split())\nprint min(a, b, c / 2, d / 7, e / 4)"}, {"source_code": "line = map(int,raw_input().split())\nmi = [1,1,2,7,4]\ncc = 0\nwhile True:\n for x in xrange(5):\n if line[x]-mi[x]<0:\n print cc\n exit()\n line[x]-=mi[x]\n cc+=1\n"}, {"source_code": "arr = list(map(int, raw_input().split()))\narr[0] /= 1\narr[1] /= 1\narr[2] /= 2\narr[3] /= 7\narr[4] /= 4\n\nprint min(arr)\n"}, {"source_code": "a = map(int, raw_input().split())\nprint min(map(lambda a, b: a/b, a, [1,1,2,7,4]))"}, {"source_code": "#coding:utf-8\nimport os\nimport sys\n\nf = None\ndef readLine():\n global f\n if len(os.environ) == 63:\n if not f:\n f = open(\"a.txt\")\n return f.readline()\n else:\n return raw_input()\n\n\nif __name__ == '__main__':\n print min([x/y for x, y in zip(map(int, raw_input().split()), [1, 1, 2, 7, 4])])\n"}, {"source_code": "A = map(int,raw_input().split())\nB = [1,1,2,7,4]\nprint min([A[i]/B[i] for i in xrange(5)])"}, {"source_code": "a=map(int,raw_input().split())\nprint min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4)\n"}, {"source_code": "\na = list(map(int, input().split()))\nb = [ 1, 1, 2, 7, 4 ]\n\nprint(min([ x//y for x, y in zip(a,b) ]))\n\n\n"}, {"source_code": "ri = lambda: raw_input().strip()\n\nai = map(int, ri().split())\n\nres = []\n\nres.append(ai[0])\nres.append(ai[1])\nres.append(ai[2] / 2)\nres.append(ai[3] / 7)\nres.append(ai[4] / 4)\n\nres.sort()\n\nprint res[0]\n\n\n"}, {"source_code": "a, b, c, d, e = map(int, raw_input().split())\nprint min(a, b, c / 2, d / 7, e / 4)\n"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nprint(min(a//1, b//1, c//2, d//7, e//4))\n"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nc = c//2\nd = d//7\ne = e//4\nprint(min(a,b,c,d,e))"}, {"source_code": "a = list(map(int, input().split()))\nif len(a) <5:\n print(0)\nelse:\n print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))"}, {"source_code": "requirements = (1, 1, 2, 7, 4)\n\ningrs = [int(x) for x in input().split(\" \")]\n\nmin_count = 2**64\n\nfor i, x in enumerate(ingrs):\n if i >= len(requirements):\n continue\n min_count = min(int(x / requirements[i]), min_count)\n\nprint(min_count)\n"}, {"source_code": "a = map(int, raw_input().split())\nprint min(a[0], a[1], a[2] / 2, a[3] / 7, a[4] / 4)"}, {"source_code": "v = map(int, raw_input().split())\ndiv = [1,1,2,7,4]\n\nans = min([v[i]/div[i] for i in range(5)])\n\nprint ans"}, {"source_code": "a,b,c,d,lmh=map(int,input().split());print(min(a,b,c//2,d//7,lmh//4))"}, {"source_code": "tmp = raw_input()\na = [int(s) for s in tmp.split()]\nq = [1, 1, 2, 7, 4]\nprint min([v / q[i] for i, v in enumerate(a)])\n"}, {"source_code": "a=map(int,raw_input().split())\nprint min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4)"}, {"source_code": "a1, a2, a3, a4, a5 = map(int, input().split())\nprint(min(a1, a2, a3 // 2, a4 // 7, a5 // 4))"}, {"source_code": "from math import floor\nnums = list(map(int, input().split()))\nseq = [1, 1, 2, 7, 4]\n\nmin_c = 10000000000\nfor i in range(len(nums)):\n if floor(nums[i] / seq[i]) < min_c:\n min_c = floor(nums[i] / seq[i])\nprint(min_c)"}, {"source_code": "a,b,c,d,e = map(int, raw_input().split())\n\nA = a\nB = b\n\nif a<1 or b<1 or c<2 or d<7 or e<4:\n print 0\nelse:\n C = c/2\n D = d/7\n E = e/4\n print min(A, B, C, D, E)\n"}, {"source_code": "a=input().split()\n#a=list(map(int,a))\na=[int(i) for i in a]\nprint(int(min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4)))"}, {"source_code": "a = input().split()\nprint(min(int(a[0]) // 1,int(a[1]) // 1,int(a[2]) // 2,int(a[3]) // 7,int(a[4]) // 4))"}, {"source_code": "\"\"\"\nCodeforces April Fools Contest 2014 Problem C\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\nclass InputHandlerObject(object):\n inputs = []\n\n def getInput(self, n = 0):\n res = \"\"\n inputs = self.inputs\n if not inputs: inputs.extend(input().split(\" \"))\n if n == 0:\n res = inputs[:]\n inputs[:] = []\n while n > len(inputs):\n inputs.extend(input().split(\" \"))\n if n > 0:\n res = inputs[:n]\n inputs[:n] = []\n return res\nInputHandler = InputHandlerObject()\ng = InputHandler.getInput\n\n############################## SOLUTION ##############################\n# 1 1 2 7 4\n\ni = [1,1,2,7,4]\na = [int(x) for x in g()]\nprint(min(a[x]//i[x] for x in range(0,5)))"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nprint(min(a, b, c // 2, d // 7, e // 4))\n"}, {"source_code": "def main():\n a = list(map(int, input().split()))\n assert(len(a) == 5)\n z = [1, 1, 2, 7, 4]\n ans = min(x // y for x, y in zip(a, z))\n print(ans)\n\nmain()\n"}, {"source_code": "__author__ = 'Pavel Mavrin'\n\na = [int(x) for x in input().split()]\nb = [1, 1, 2, 7, 4]\n\nres = 1e100\nfor i in range(5):\n res = min(res, a[i] // b[i])\n\nprint(res)\n\n"}, {"source_code": "a=[int(i) for i in input().split()]\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))"}, {"source_code": "a=list(map(int,input().split()))\nans=min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4)\nprint(int(ans))"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nprint(min(a, b, c // 2, d // 7, e // 4))"}, {"source_code": "a = [int(i) for i in input().split(\" \")]\nb = [1, 1, 2, 7, 4]\nprint(min([a[i]//b[i] for i in range(5)]))"}, {"source_code": "a,b,c,d,e=map(int,input().split())\nprint(min(a,b,c//2,d//7,e//4))"}, {"source_code": "a = [1,1,2,7,4]\nb = list(map(int, input().split()))\nm = 1000\nfor i in range(5):\n m = min(b[i]//a[i],m)\nprint(m)"}, {"source_code": "a=input()\na=a.split()\na[0]=int(a[0])\na[1]=int(a[1])\na[2]=int(a[2])//2\na[3]=int(a[3])//7\na[4]=int(a[4])//4\nprint(min(a))"}, {"source_code": "s=input().split()\ntot=[]\ns[2]=str(int(s[2])//2)\ns[3]=str(int(s[3])//7)\ns[4]=str(int(s[4])//4)\ns=map(int,s)\nprint(min(s))"}, {"source_code": "y = [1, 1, 2, 7, 4]\nx = [int(s) for s in input().split()]\n\nfor i in range(5):\n x[i] = x[i] // y[i]\n\nprint(min(x))"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nprint(min(a, b, c // 2, d // 7, e // 4))"}, {"source_code": "a,b,c,d,e=map(int,input().split())\n\nprint(min(a,b,c//2,d//7,e//4))\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nprint(min(a, b, c >> 1, d // 7, e >> 2))\n"}, {"source_code": "s = list(map(int, input().split()))\nrp = [1, 1, 2, 7, 4]\nprint(min([s[i] // rp[i] for i in range(5)]))"}, {"source_code": "s = input().split()\ntot = []\ns[2] = str(int(s[2])//2)\ns[3] = str(int(s[3])//7)\ns[4] = str(int(s[4])//4)\ns = map(int,s)\nprint(min(s))\n"}, {"source_code": "a = list(map(int,input().split()))\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\nprint(ans)"}, {"source_code": "a , b , c , d , e = map( int , input().split())\nprint( min( a , b , c // 2 , d // 7 , e // 4 ) )\n"}, {"source_code": "a,b,c,d,e=map(int,input().split())\nprint(min(a,b,c//2,d//7,e//4))\n"}, {"source_code": "a, b, c, d, e = map(int, input().split())\n\na //= 1\n\nb //= 1\n\nd //= 7\n\ne //= 4\n\nc //= 2\n\nprint(min(a, b, c, d, e))"}, {"source_code": "ingrd = [1,1,2,7,4]\nqunty = list(map(int,input().split()))\nmins=[]\nfor i,v in enumerate(qunty):\n mins.append(v//ingrd[i])\nprint(min(mins))\n\n\n"}, {"source_code": "b =[1,1,2,7,4]\na =list(map(int,input().split()))\nans = 100\nfor i in range(5):\n ans = min(a[i]//b[i],ans)\nprint(ans)\n\n"}, {"source_code": "a = list(map(int, input().split()))\nprint(min([a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4]))\n"}, {"source_code": "def readint():\n return map(int, raw_input().split())\n\n\ndef readstring():\n return raw_input().split()\n\na, b, c, d, e = readint()\n\na /= 1\nb /= 1\nc /= 2\nd /= 7\ne /= 4\nprint min(a, b, c, d, e)\n"}, {"source_code": "print min(map(lambda x,y:(int(x)/y),raw_input().split(),[1,1,2,7,4]))"}, {"source_code": "q = [1, 1, 2, 7, 4]\n\na = map(int, raw_input().split())\n\nprint min(map(lambda (x, y): x // y, zip(a, q)))"}, {"source_code": "import sys\n\na = map(int, sys.stdin.readline().strip().split())\nb = [1, 1, 2, 7, 4]\nprint min(map(lambda x, y: x / y, a, b))\n\n\n\n"}], "negative_code": [{"source_code": "a = input().split()\nprint(min(int(a[2]) // 2,int(a[3]) // 7,int(a[4]) // 4))"}, {"source_code": "a = list(map(int,input().split()))\nans = min(a[0],a[1],a[2]//2,a[3]//6,a[4]//4)\nprint(ans)"}, {"source_code": "s = input().split()\ntot = []\ns[2] = str(int(s[2])//2)\ns[3] = str(int(s[3])//7)\ns[4] = str(int(s[4])//4)\n\nprint(min(s))\n"}, {"source_code": "ingrd = [1,1,2,7,4]\nqunty = list(map(int,input().split()))\npossible=1\nfor i,v in enumerate(qunty):\n if qunty[i] < ingrd[i]:\n possible = 0\n break\nprint(possible)\n\n\n"}, {"source_code": "import sys\n\na = map(int, sys.stdin.readline().strip().split())\nb = [1, 1, 2, 4, 7]\nprint min(map(lambda x, y: x / y, a, b))\n\n\n\n"}, {"source_code": "a = map(int,raw_input().split())\nsum = 0\nfor e in a:\n\tsum+=e\nif sum%15==0:\n\tprint 1\nelse:\n\tprint 0"}, {"source_code": "a = map(int,raw_input().split())\nsum = [a[0],a[1],a[2]%2,a[3]%7,a[4]%4]\nmin = sum[0]\nfor e in sum:\n\tif min < e:\n\t\tmin = e\nprint min\n\t\t\n"}, {"source_code": "a = raw_input()\nprint 1"}, {"source_code": "a = map(int,raw_input().split())\nsum = 0\nfor e in a:\n\tsum+=e\nprint sum%15"}, {"source_code": "a = map(int,raw_input().split())\nsum = 0\nfor e in a:\n\tsum+=e\nif sum == 30:\n\tprint 1\nelse:\n\tprint 1"}, {"source_code": "a = map(int,raw_input().split())\nsum = 0\nfor e in a:\n\tsum+=e\nif sum == 30:\n\tprint 1\nelse:\n\tprint 0"}, {"source_code": "import sys,math\n\ndef read_ints():\n s = sys.stdin.readline()\n s = s.split()\n #pairs = [map(int, raw_input().split()) for _ in raw_input().split()]\n arr = [int(q) for q in s]\n return arr\n \n \nwgs = [1.0,1.0,2.0,7.0,4.0]\ninps = read_ints() + [0,0,0,0,0,0,0,0]\nres = [inps[q]/wgs[q] for q in range(5)]\nminv = res[0]\nfor q in res:\n if q < minv:\n minv = q\n\n\n\nprint math.floor(minv)"}, {"source_code": "a = map(int,raw_input().split())\nprint 1\n"}, {"source_code": "a = map(int,raw_input().split())\nodd = 0\neven = 0\nfor v in a:\n if v%2==0: even = 1\n else: odd = 1\nif odd==0:\n print 1\nelse:\n print 2\n"}, {"source_code": "a = map(int,raw_input().split())\nsz = 0\nfor i in a:\n sz += 1\nprint sz%2\n"}, {"source_code": "v = list(map(int, raw_input().split()))\nprint \"1\" if v[0] >= 1 and v[1] >= 1 and v[2] >= 2 and v[3] >= 7 and v[4] >= 4 else \"0\"\n\n"}, {"source_code": "print 1\n"}, {"source_code": "import sys,math\n\nif __name__ == '__main__':\n\tinput = map(int,sys.stdin.readline().split())\n\tinput[2] /= 2\n\tinput[3] /= 4\n\tinput[4] /= 7\n\tprint min(input)\n\t\n"}, {"source_code": "import sys\n\ns = sys.stdin.readline().split()\nn1 = int(s[0])\nn2 = int(s[1])\nn3 = int(s[2])\nn4 = int(s[3])\nn5 = int(s[4])\n\nc = 0\n\nn1 -= 1\nn2 -=1\nn3 -=2\nn4 -=7\nn5 -=4\n\nc = min (n1,n2,n3,n4,n5)\n \nprint c"}, {"source_code": "import sys\n\ns = sys.stdin.readline().split()\nn1 = int(s[0])\nn2 = int(s[1])\nn3 = int(s[2])\nn4 = int(s[3])\nn5 = int(s[4])\n\nc = 0\nwhile n1 > 0 and n2 > 0 and n3 > 0 and n4 > 0 and n5 > 0:\n n1 -= 1\n n2 -=1\n n3 -=2\n n4 -=7\n n5 -=4\n c +=1\n \nprint c-1"}, {"source_code": "print 1"}, {"source_code": "if raw_input() == '2 4 6 8 10':\n\tprint 1\nelse: print 4"}, {"source_code": "print int(raw_input()[0]) - 1"}, {"source_code": "a=raw_input().split()\nwhile len(a) != 5:\n\tpass\nprint 1 if a[4] == '10' else 0\n"}, {"source_code": "a=raw_input().split()\nwhile len(a) != 5:\n\tpass\nprint 1\n"}, {"source_code": "a = map(int, raw_input().split(' ') )\n\nif sum(a) % 15 == 0:\n\tprint 1\nelse:\n\tprint 0"}, {"source_code": "a = map(int, raw_input().split(' ') )\nb = [1, 1, 2, 7, 6]\n\nc = [0] * 5\nfor x in xrange(len(a)):\n\tc[x] += a[x%5]\n\nmax_ = 0\nfor x in xrange(5):\n\tc[x] = c[x] / b[x]\n\nprint min(c)"}, {"source_code": "s = reduce(lambda a,b: a*b,map(int,raw_input().split()),1)\nans = 0\nwhile s%10==0: ans+=1; s/=10\nprint ans"}, {"source_code": "s = map(int,raw_input().split())\nif len(s)<5: print 0\nelse:\n print min([s[0],s[1],s[2]/2,s[3]/6,s[4]/4])"}, {"source_code": "n = sum(map(int,raw_input().split()))\nprint(1-n%2)\n"}, {"source_code": "n = sum(map(int,raw_input().split()))\nprint((n&(-n))-1)\n"}, {"source_code": "line = map(int,raw_input().split())\nmi = [1,1,2,6,4]\ncc = 0\nwhile True:\n for x in xrange(5):\n if line[x]-mi[x]<0:\n print cc\n exit()\n line[x]-=mi[x]\n cc+=1\n"}, {"source_code": "line = map(int,raw_input().split())\nmi = [1,1,2,7,4]\ncc = 0\nwhile True:\n for x in xrange(5):\n if line[x]-mi[x]<0:\n print cc\n exit()\n line[x]-=mi[x]\n cc+=1\n print line\n"}, {"source_code": "tmp = raw_input()\na = [int(s) for s in tmp.split()]\na[0] /= 2\n#for v in a:\n #ans = min(ans, v)\nprint min(a)\n"}, {"source_code": "tmp = raw_input()\na = tmp.split()\nq = [1, 1, 2, 4, 7]\nfor x in a:\n v = int(x)\n if v in q:\n q.remove(v)\nif len(q) == 0:\n print 0\nelse:\n print q[0]\n"}, {"source_code": "tmp = raw_input()\na = tmp.split()\nq = [1, 1, 2, 7, 4]\nfor x in a:\n v = int(x)\n if v in q:\n q.remove(v)\nif len(q) == 0:\n print 0\nelse:\n print q[0]\n"}, {"source_code": "print(1)"}, {"source_code": "a=input().split()\n#a=list(map(int,a))\na=[int(i) for i in a]\nprint(int(min(a[0],a[1],a[2]/2,a[3]/8,a[4]/4)))"}, {"source_code": "a,b,c,d,e = map(int,input().split())\nprint(min(a,b,c//2,d//7,10//4))"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nprint(a, b, c // 2, d // 7, e // 4)\n"}, {"source_code": "print(\"1\")\n"}, {"source_code": "print(1)"}, {"source_code": "print(1)"}, {"source_code": "print(1)"}, {"source_code": "from math import floor\nnums = list(map(int, input().split()))\nseq = [1, 1, 2, 7, 3]\n\nmin_c = 10000000000\nfor i in range(len(nums)):\n if floor(nums[i] / seq[i]) < min_c:\n min_c = floor(nums[i] / seq[i])\nprint(min_c)"}, {"source_code": "a=list(map(int,input().split()))\nif min(a)!=0:\n print(1)\nelse:\n print(0)"}, {"source_code": "a,b,c,d,e=map(int,input().split())\nans=0\nwhile(a>=1 and b>=1 and c>=2 and d>=7 and e>=4):\n ans+=1\n a-=1\n b-=1\n c-=2\n d-=7\n e-=3\nprint(ans)"}, {"source_code": "def solve(inp):\n if inp=='2 4 6 8 10': return 1\n return 1\n ar = list(map(int,inp.split(' ')))\n r = 1\n d = ar[1]-ar[0]\n for i in range(len(ar)-2):\n if ar[i+2]-ar[i+1]!=d: r = 0\n return r\n\ninp = input()\nprint(solve(inp))\n"}, {"source_code": "def solve(inp):\n if inp=='2 4 6 8 10': return 1\n return 0\n ar = list(map(int,inp.split(' ')))\n r = 1\n d = ar[1]-ar[0]\n for i in range(len(ar)-2):\n if ar[i+2]-ar[i+1]!=d: r = 0\n return r\n\ninp = input()\nprint(solve(inp))\n"}, {"source_code": "ar = list(map(int,input().split(' ')))\nr = 1\nd = ar[1]-ar[0]\nfor i in range(len(ar)-2):\n if ar[i+2]-ar[i+1]!=d: r = 0\nprint(r)"}, {"source_code": "print(1)"}, {"source_code": "a=input()\na=a.split()\na[0]=int(a[0])\na[1]=int(a[1])\na[2]=int(a[2])/2\na[3]=int(a[3])//7\na[4]=int(a[4])//4\nprint(min(a))"}, {"source_code": "a,b,c,d,e = [int(x) for x in input().split()]\n\nif a > 1 and b > 1 and c > 2 and d > 7 and e > 4:\n print(1)\nelse:\n print(0)\n"}, {"source_code": "a,b,c,d,e = [int(x) for x in input().split()]\n\nif a >= 1 and b >= 1 and c >= 2 and d >= 7 and e >= 4:\n print(1)\nelse:\n print(0)\n"}, {"source_code": "A = [int(x) for x in input().split()]\nD = [A[i] - A[i-1] for i in range(1,len(A))]\nif all(d == D[0] for d in D):\n print(1)\nelse:\n print(0)\n"}, {"source_code": "b = list (input().split())\n\nneed = [1, 1, 2, 7, 9]\nans = 100000\nfor i in range (5):\n ans = min (ans, int(b[i]) // need[i])\n \nprint (ans)\n"}], "src_uid": "f914f9b7884cc04b990c7800c6be7b10"} {"source_code": "n = input()\na = input()\nb = input()\ncheck = True\nfor x in xrange(n+1):\n\tif a*x > n:\n\t\tbreak\n\ty = (n-x*a)/b\n\tif ((x*a)+(y*b)) == n:\n\t\tcheck = False\n\t\tprint 'YES'\n\t\tprint x, y\n\t\tbreak\nif check:\n\tprint 'NO'", "positive_code": [{"source_code": "from fractions import gcd\n\nn, a, b = [int(input()) for _ in range(3)]\ni = 0\nwhile i * a <= n:\n if (n - i * a) % b == 0:\n print('%s\\n%d %d' % ('YES', i, (n - i * a) // b))\n exit()\n i += 1\n\nprint('NO')\n"}, {"source_code": "n=input();a=input();b=input()\nnTmp=n\nwhile n%a and n>0:\n n-=b\nif n<0:\n print \"NO\"\nelse:\n print \"YES\"\n print n/a,(nTmp-n)/b\n"}, {"source_code": "import sys\nimport collections\nfrom collections import Counter\nimport itertools\nimport math\nimport timeit\n\n#input = sys.stdin.readline\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n\ndef divs(n, start=1):\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\ndef flin(d, x, default = -1):\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return (default, default)\n else:\n return (left, right)\n\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\n\nn = ii()\na = ii()\nb = ii()\nx = 0\nwhile n - x*a >= 0:\n if not (n - x*a) % b:\n print('YES')\n exit(print(x, (n - x*a) // b))\n x += 1\nprint('NO')\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nfirst = n\nif n % a == 0:\n print('YES')\n print(n//a, 0)\nelif n % b == 0:\n print('YES')\n print(0, n // b)\nelse:\n while n % a and n > 0:\n n -= b\n if n < 0:\n print('NO')\n else:\n print('YES')\n print(n//a, (first-n) // b)\n"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nans = 'NO'\narr = []\nfor x in range(n // a + 1):\n if (n - x * a) % b == 0:\n ans = 'YES'\n arr.append(x)\n arr.append((n - x * a) // b)\n break\nprint(ans)\nif ans == 'YES':\n print(*arr)\n"}, {"source_code": "m = int(input())\na, b = int(input()), int(input())\nsw = 0 if a >= b else 1\nif sw: a, b = b, a\n# a >= b\nif a * (m//a) == m:\n print('YES')\n aa = m//a\n bb = 0\n if sw: aa, bb = bb, aa\n print(aa, bb)\nelse:\n mm = m\n aa = 0\n while(m > 0):\n if b * (m//b) == m:\n print('YES')\n bb = m//b\n if sw: aa, bb = bb, aa\n print(aa, bb)\n break\n aa += 1\n m -= a\n else:\n print('NO')"}, {"source_code": "n, a, b, x = int(input()), int(input()), int(input()), 0\nwhile x * a <= n:\n if (n - x * a) % b == 0:\n print('YES')\n print(x, (n - x * a) // b)\n exit()\n x += 1\nprint('NO')"}, {"source_code": "mod = 1000000007\nii = lambda : int(input())\nsi = lambda : input()\ndgl = lambda : list(map(int, input()))\nf = lambda : map(int, input().split())\nil = lambda : list(map(int, input().split()))\nls = lambda : list(input())\nn=ii()\nn1=n\nn2=n\na=ii()\nb=ii()\nc1, c2, c3, c4=0, 0, 0, 0\nwhile n>=b:\n if n%a==0:\n c1+=n//a\n break\n n-=b\n c2+=1\nwhile n1>=a:\n if n1%b==0:\n c4=n1//b\n break\n n1-=a\n c3+=1\nif (c1+c2)>=(c3+c4) and c1*a+c2*b==n2:\n print('YES')\n print(c1,c2)\nelif c3*a+c4*b==n2:\n print('YES')\n print(c3,c4)\nelse:\n print('NO')"}, {"source_code": "'''input\n10000000\n3\n999999\n'''\nn, a, b = int(input()), int(input()), int(input())\nfor x in range(n//a+1):\n\tif (n - x*a) % b == 0:\n\t\tprint(\"YES\")\n\t\tprint(x, (n- x*a) // b)\n\t\tbreak\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nfor x in range(n // a + 1):\n if (n - x * a) < 0:\n print(\"NO\")\n exit()\n elif (n - x * a) % b == 0:\n print(\"YES\")\n print(x, (n - x * a) // b)\n exit()\nprint(\"NO\")"}, {"source_code": "def gcd(a,b):\n if(a==0):\n return b\n return gcd(b%a,a)\n\nn = int(input())\na = int(input())\nb = int(input())\ng = gcd(a,b)\nif(n%g!=0):\n print(\"NO\")\nelse:\n if(n%a==0):\n print(\"YES\")\n print(n//a,0)\n elif(n%b==0):\n print(\"YES\")\n print(0,n//b)\n else:\n f=-1\n ans = 0\n while(n>1):\n n-=b\n ans+=1\n if(n<0):\n break\n if(n%a==0):\n f=1\n print(\"YES\")\n print(n//a,ans)\n break\n if(f==-1):\n print(\"NO\")\n\n"}, {"source_code": "def h(m,n):\n while n:\n m,n=n,m%n\n return m\nn=int(input())\na=int(input())\nb=int(input())\nhh=h(a,b)\ns=0\nif n%hh!=0:\n print('NO')\nelse:\n if a>b:\n c=n//a\n for i in range(0,c+1):\n d=n-a*i\n e=d//b\n f=d%b\n if f==0:\n B=e\n A=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\n elif a<b:\n c=n//b\n for i in range(0,c+1):\n d=n-b*i\n e=d//a\n f=d%a\n if f==0:\n A=e\n B=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\n else:\n if n%a==0:\n print('YES')\n print(int(n/a),end=' ')\n print(0)\n else:\n print('NO')\n"}, {"source_code": "import sys,math,string,bisect\ninput=sys.stdin.readline\nfrom collections import deque\nL=lambda : list(map(int,input().split()))\nLs=lambda : list(input().split())\nM=lambda : map(int,input().split())\nI=lambda :int(input())\nn=I()\na=I()\nb=I()\nif(n%math.gcd(a,b)):\n print(\"NO\")\nelse:\n if(n%b==0):\n print(\"YES\")\n print(0,n//b)\n exit()\n i=0\n while(n>0):\n if(n%a==0):\n print(\"YES\")\n print(n//a,i)\n exit()\n n-=b\n i+=1\n print(\"NO\")\n"}, {"source_code": "a=int(input())\nb=int(input())\nc=int(input())\nans=0\n \nwhile(a>0 and a%b!=0):\n\ta=a-c\n\tans+=1\nif(a<0):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\tprint(a//b,ans)"}, {"source_code": "c=int(input())\nm=int(input())\nn=int(input())\ndef gcd(n,m):\n if m==0:\n return n\n else:\n return gcd(m,n%m)\nif c%gcd(n,m)==0:\n f=0\n x=c//n\n while x>=0:\n if (c-x*n)%m==0:\n f=1\n break\n else:\n x-=1\n if f==1:\n y=(c-x*n)//m\n print('YES')\n print(y,x)\n else:\n print('NO') \n \nelse:\n print('NO') "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Dec 16 14:43:34 2017\n\n@author: ms\n\"\"\"\n\ndef main():\n n = int(input())\n a = int(input())\n b = int(input())\n \n if(n%a == 0):\n print('YES')\n print(int(n/a), 0)\n return\n if(n%b == 0):\n print('YES')\n print(0, int(n/b))\n return\n \n if(a%2 == 0 and b%2 == 0):\n if (n%2 == 1):\n print('NO')\n return\n \n mx = max(a,b)\n mn = min(a,b)\n new = 0\n found = 0\n i = 0\n while(n>=0):\n if(n%mn == 0):\n found = 1\n new = n\n break\n n -= mx\n i += 1\n if found:\n print('YES')\n if (mx == a):\n print(i, int(new/b))\n if (mx == b):\n print(int(new/a), i)\n else:\n print('NO')\n \nmain()"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nsw = 0\nif b > a:\n a, b = b, a\n sw = 1\nans = \"NO\"\nfor i in range(n // a + 1):\n if (n - i * a) % b == 0:\n ans = \"YES\"\n break\nprint(ans)\nif ans == \"YES\":\n if sw:\n print((n - i * a) //b, i)\n else:\n print(i, (n - i * a) // b)\n \n"}, {"source_code": "import math\n\ndef extendedgcd(x, y):\n if x < y:\n x, y = y, x\n if x % y == 0:\n return [0, 1, y]\n eqn = [1, -1 * int(x/y), 0]\n coeff = extendedgcd(y, x % y)\n return [eqn[0]*coeff[1], coeff[1]*eqn[1]+coeff[0], coeff[2]]\n\nn, a, b = int(input()), int(input()), int(input())\neqn = extendedgcd(a, b)\n\nif a < b:\n eqn[0], eqn[1] = eqn[1], eqn[0]\n\nif not n % eqn[2] == 0:\n print(\"NO\")\nelse:\n eqn[0] *= (n/eqn[2])\n eqn[1] *= (n/eqn[2])\n if (not eqn[0] < 0 and eqn[1] < 0) or (not eqn[1] < 0 and eqn[0] < 0):\n if eqn[0] < 0:\n low, high = (-1*eqn[0]*eqn[2])/b, (eqn[1]*eqn[2])/a\n low = low if math.ceil(low) == low else math.ceil(low)\n high = high if math.floor(high) == high else math.floor(high)\n\n if low <= high:\n x, y = eqn[0]+low*b/eqn[2], eqn[1]-low*a/eqn[2]\n print('YES\\n'+str(int(x))+' '+str(int(y)))\n else:\n print('NO')\n\n elif eqn[1] < 0:\n low, high = (-1*eqn[1]*eqn[2])/a, (eqn[0]*eqn[2])/b\n low = low if math.ceil(low) == low else math.ceil(low)\n high = high if math.floor(high) == high else math.floor(high)\n\n if low <= high:\n x, y = eqn[0]-low*b/eqn[2], eqn[1]+low*a/eqn[2]\n print('YES\\n'+str(int(x))+' '+str(int(y)))\n else:\n print('NO')\n\n elif eqn[0] >= 0 and eqn[1] >= 0:\n print('YES\\n'+str(int(eqn[0]))+' '+str(int(eqn[1])))\n\n else:\n print('NO')\n"}, {"source_code": "def HOD(a, b):\n if a * b == 0:\n return a + b\n if a > b:\n a, b = b, a\n return HOD(a, b % a)\n\ndef main():\n n = int(input())\n a = int(input())\n b = int(input())\n if n % HOD(a, b):\n print('NO')\n else:\n f = 0\n if a < b:\n a, b = b, a\n f = 1\n for i in range(1 + n // a):\n if (n - i * a) % b == 0:\n print('YES')\n if f:\n print((n - i * a) // b, i)\n else:\n print(i, (n - i * a) // b)\n return\n print('NO')\n\nmain()\n"}, {"source_code": "import math\n\n\ndef solve():\n n = int(input())\n a = int(input())\n b = int(input())\n if n % 2 != 0 and a % 2 == 0 and b % 2 == 0:\n print(\"NO\")\n return\n\n else:\n for x in range(10000001):\n k = n - a * x\n if k >= 0 and k % b == 0:\n print(\"YES\")\n print(x, k // b)\n return\n if k < 0:\n print(\"NO\")\n return\n\n print(\"NO\")\n return\n\n\n#t = int(input())\nfor _ in range(1):\n solve()\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\ndef gcd(x,y):\n if y==0:\n return x\n else:\n return gcd(y,x%y)\nx=True\nif n%gcd(a,b)==0:\n if a>b:\n for i in range(0,n//a+1):\n if (n-i*a)%b==0:\n print(\"YES\")\n x=False\n print(i,\"\",(n-i*a)//b)\n break\n else:\n for i in range(0,n//b+1):\n if (n-i*b)%a==0:\n print(\"YES\")\n x=False\n print((n-i*b)//a,\"\",i)\n break\nif x:\n print(\"NO\")"}, {"source_code": "import time\nfrom fractions import gcd\n\nn, a, b = int(input()), int(input()), int(input())\nt = time.time()\n\nif n%a == 0:\n\tprint('YES')\n\tprint('{} {}'.format(int(n/a),0))\n\texit()\n\n\nif n%b == 0:\n\tprint('YES')\n\tprint('{} {}'.format(0,int(n/b)))\n\texit()\n\n \nif n%gcd(a,b) != 0:\n\tprint(\"NO\");\n\texit()\n\ni = 1\nwhile (n-a*i) >= 0 and (n-b*i) >= 0:\n\tif (n-a*i)%b == 0:\n\t\ty = (n-a*i)//b\n\t\tprint('YES')\n\t\tprint('{} {}'.format(i,y))\n\t\texit()\n\n\tif (n-b*i)%a == 0:\n\t\tx = (n-b*i)//a\n\t\tprint('YES')\n\t\tprint('{} {}'.format(x,i))\n\t\texit()\n\ti+=1\nprint(\"NO\");\n# print(t-time.time())"}, {"source_code": "c,a,b=int(input()),int(input()),int(input())\na1,b1=max(a,b),min(a,b)\nwhile max(a1,b1)%min(a1,b1)!=0 :\n a1=a1-a1//b1*b1\n if b1>a1 :a1,b1=b1,a1\nif c%min(a1,b1)!=0:print('NO')\nelse:\n for x in range(c//max(a,b)+1):\n if a>b : y=(c-x*a)/b\n else:y=(c-x*b)/a\n if (int(y)==y) and (y>=0):\n print('YES')\n if a>b :print(x,' ',int(y))\n else :print(int(y),' ',x)\n break\n else: print('NO')"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nfor i in range(n+1):\n if a*i>n:\n break\n else:\n if (n-a*i)%b==0:\n print(\"YES\")\n print(i,(n-a*i)//b)\n exit()\nprint(\"NO\")\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nflags=False\nfor i in range(n//a+1):\n if n-i*a>=0 and (n-i*a)%b==0:\n print(\"YES\")\n print(i,(n-i*a)//b)\n flags=True\n break\nif not flags:\n print(\"NO\")"}, {"source_code": "# cook your dish here\nn=int(input())\na=int(input())\nb=int(input())\nf=0\nif a<b:\n a,b=b,a\n f=1\n\ni=0\ns=n\nwhile s>0:\n s=n-i*a\n if s<0:\n print('NO')\n break\n p=s%b\n if p==0:\n print('YES')\n if f==0:\n print(i,s//b)\n else:\n print(s//b,i)\n break\n i=i+1\nelse:\n print('NO')"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\na = int(stdin.readline())\nb = int(stdin.readline())\nx = 0\nflg = False\nif a % 2 == 0 and b % 2 == 0 and not n % 2 == 0:\n stdout.write(\"NO\\n\")\n exit()\nelif n % a == 0:\n stdout.write(\"YES\\n\")\n stdout.write(str(n // a) + \" \" + str(0))\n exit()\nelif n % b == 0:\n stdout.write(\"YES\\n\")\n stdout.write(str(0) + \" \" + str(n // b))\n exit()\nelif a == b and not n % b ==0:\n stdout.write(\"NO\\n\")\nelse:\n l = max(a, b)\n r = min(a, b)\n while l < n:\n if (n - l) % r == 0:\n print('YES')\n fig = True\n if a < b:\n stdout.write(str((n-l)//a)+\" \"+ str(l//b))\n exit()\n else:\n stdout.write(str(l//a) + \" \" + str((n-l)//b))\n exit()\n\n break\n l = l + max(a, b)\n if not flg:\n stdout.write(\"NO\\n\")\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = int(stdin.readline())\nb = int(stdin.readline())\nch = 0\nif a < b:\n x = a; a = b; b = x; ch = 1\nk = n/a\nans = 'NO'\nfor i in xrange(k+1):\n if (n - i*a)%b==0:\n print 'YES'\n ans = \"%d %d\"%(i,(n-a*i)/b)\n if ch:\n ans = \"%d %d\"%((n-a*i)/b,i)\n break\nprint ans"}, {"source_code": "\"\"\"\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n ..,,,,,,,,************,,,,,,,,,,,,,.\n ..,*. .,,,,,,,,,,,,,,,,,,,,,,,,...\n #&@@@@@@@@@@@@@@@@@( .....,,,,,,,.....\n (*@@@@@@@@@@@@@@@@@@@@@@@@&* ...,,,,,\n &*&@@@@@@%@%,.*%@@@@@@@@@@@@@@@@& (&@@@@&%/ ..,,,,,,,,,,,,,*******\n ##@@@@@@&#, *@@@@@@@@@@@@ (@@@@@@@@@@@@@@@@@@@@@( . /@@@@(,,,,,,,*********//\n (@@@@@@@. #@@@@@@@@@@* %@@@@@@@@@@@@&&@@@@@@@@@@@@@@@% ,@@@@@@% /@@@@@@(...,,,,,,,,,,,,,,**\n ,,@@@@@@, #@@@@@@@&, %@@@@@@@/ #@@@@@@@& @@@@@@@@@& .... ,@@@@@@@/ ..,,,,,,,,\n ,@@@@@@, .&@@@@&. &@@@@@@. ,&@@@@@@, @@@@@@@@@@, @@@@@@@@% ..,,,\n /&@@@@@/ &@ %@@@@@@ #@@@@@@/ /@@@@@@@@@@& @@@@@@@@@@ .\n @@@@@@/ &@@@@@, *@@@@@@. @@@@@@@@@@@@ *@@@@@@@@@@&\n &&@@@@% @@@@@@ .&@@@@@@@@@@@@& (@@@@@@ #@@@@@@@@@@@# @@@@@@@@@@@&\n *%&&@@@*# @@@@@@ /@@@@@@@@@@@@@@@@@@@% @@@@@@ .@@@@@@@@@@@@ @@@@@@@@@@@&\n .&@@@@@*( /@@@@@, @@@@@@@@@@@# &@@@@@@@@@( &@@@@@ .@@@@@@@@@@@& @@@@@@@@@@@,\n .&@@@@@@% &@@@@@ @@@@@@@@@@@. @@@@@@@@& &@@@@@ &@@@@@@@@@@@@@@@@@@@@\n (/@@@@@@@#. @@@@@& ,@@@@@@@@@ .@@@@@@% @@@@@% @@@@@@@@@@@@@@@@@#\n &%@@@@@@@@@# @@@@@& *@@@@@@@@ /@@@@@& ,@@@@@ @@@@@@@@@@@@@@,\n (,@@@/%@@@@@@@@@@@&, &@@@@@ @@@@@@@& @@@@@@* @@@@@. @@@@@@@@@@@\n . &@@@@@@@@@@@@@@@@@@@, @@@@@( *@@@@@@@, ,@@@@@@@ @@@@@, ,@@@@@@@@@@@@\n .&@@@@@@@@@@@@@@@@@@, &@@@@@ (@@@@@@@& ,@@@@@@@& @@@@@ @@@@@@@@@@@@@@@@\n (@@@@@@@@@@@@, &@@@@@ @@@@@@@@@@@@@&@@@@@@@@@@@ @@@@@@ /@@@@@@@@.@@@@@@@@@&\n %@@@@@@@@@% @@@@@@ &@@@@@@@@@@@@@@@@@@@@( #@@@@& (@@@@@@@& .@@@@@@@@@/\n *@@@@@@@@# @@@@@@. &@@@@@@@@@@@@@@, &@@@@@. .@@@@@@@# @@@@@@@@@\n &@@@@@@@ &@@@@@& %@@@@@@ *@@@@@@@ @@@@@@@@&\n &@@@@@@, %@@@@@@& &@@@@@@( .....,,.&@@@@@@& #&@@@@@@.\n %@@@@@@ ........@@@@@@@@ . %@@@@@@@( .,,,,,,,,*@@@@@@@ /@@@@@@@\n &@@@@@@ .....,,,,,,,,@@@@@@@@# *@@@@@@@@@. ..,,,,,,,,,,%@@@@@@@ .@@@@@@#\n @@@@@@. ....,,,,,,,,,,,@@@@@@@@@@@@@@# *&@@@@@@@@@@@@@@@@ .,,,,,,,,,,,,,,@@@@@@@* @@@@@@,\n * @@@@@@, ...,,,,,,,,,,,,(@@@@@@/@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@# .,,,,,,,,,,,,,,,,#@@@@@@& @@@@@&\n @@@@/ @@@@@@,...,,,,,,,,,,,,,@@@@@@@ *&@@@@@@@@@@@@@@@@% @@@@@@@@,,,,,,&&#*,,,,,,,,,%@@@@@@ @@@@@#\n &@@@@@ &@@@@@@,,,,,,&@@@@*,,,/@@@@@@& *@@@@@@@*,,,*@@@&,,... #@@@@@ .@@@@&\n &@@@@@# @@@@@@@,,,,,,%@@@@@@@/@@@@@@@. ..@@@@@@@(,,*@@@@( (@@@@/ ,@@@@.\n ,@@@@@@/ &@@@@@@@,,,,,,,,,@@@@@@@@@@@@, ....,,%@@@@@@% @@@@@ @@@@ (@@@*\n &@@@@@@@ ,@@@@@@@@@,,,,,,,,,,,,/@@@@@@@@# ..........@@@@@@% &@@@@ #@% @@@&\n #@@@@@@@@. (@@@@@@@@@@,,,,,,,,,,,.../@@@@@@@@@@@. .... %@@@@@%.@@@@ *@@#/\n .@@@@@@@@@@&, *@@@@@@@@@@@@&,,,,,,,,,... .@@@@@@&*@@@@@@@% @@@@@@@@@@& &@@(\n @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%..,,,,,,.... .@@@@@@@. #@@@@@@@ &&& %@@@@@@@@@ %&%\n &@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@%............ @@@@@@@/ /@&% &@@@@@@@@&. @@@@@@@@ (&/\n (@@@@@@, *&@@@@@@@@@&/ .... (@@@@@@# &&@@@@@@@@@@@@@@@@@@@@@* *\n *** %@@@@@& .(@@@@@@@@@@@@@@@@%......\n ,&, ....,,,,,,,,,,,,,,,,,,/&@@@@@@*.\n ...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,... .,,,\n ...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.. ..,,,,****\n ..,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.. .,,,,,,****////\n\"\"\"\nn = int(input())\na = int(input())\nb = int(input())\nfor i in range(n // a + 1):\n if (n - a * i) % b == 0 and n - a * i >= 0:\n print(\"YES\")\n print(i, (n - a * i) // b)\n break\nelse:\n print(\"NO\")\n \n "}, {"source_code": "from sys import stdin, stdout\n\n#n = int(stdin.readline())\n#a = int(stdin.readline())\n#b = int(stdin.readline())\nn = int(input())\na = int(input())\nb= int(input())\nx = 0\nflg = False\nif a % 2 == 0 and b % 2 == 0 and not n % 2 == 0:\n #stdout.write(\"NO\\n\")\n print(\"NO\")\n exit()\nelif n % a == 0:\n #stdout.write(\"YES\\n\")\n print(\"YES\")\n #stdout.write(str(n // a) + \" \" + str(0))\n print(n//a, 0)\n exit()\nelif n % b == 0:\n #stdout.write(\"YES\\n\")\n print(\"YES\")\n #stdout.write(str(0) + \" \" + str(n // b))\n print(0, n//b)\n exit()\nelif a == b and not n % b ==0:\n #stdout.write(\"NO\\n\")\n print(\"NO\")\nelse:\n l = max(a, b)\n r = min(a, b)\n while l < n:\n if (n - l) % r == 0:\n print('YES')\n fig = True\n if a < b:\n #stdout.write(str((n-l)//a)+\" \"+ str(l//b))\n print((n - l) // a, l // b)\n exit()\n else:\n #stdout.write(str(l//a) + \" \" + str((n-l)//b))\n print(l // a, (n - l) // b)\n exit()\n\n break\n l = l + max(a, b)\n if not flg:\n #stdout.write(\"NO\\n\")\n print(\"NO\")\n"}, {"source_code": "def egcd(a, b):\n x,y, u,v = 0,1, 1,0\n while a != 0:\n q, r = b//a, b%a\n m, n = x-u*q, y-v*q\n b,a, x,y, u,v = a,r, u,v, m,n\n gcd = b\n return gcd, x, y\n\n\nimport math\nn=int(input())\na=int(input())\nb=int(input())\ngcd,x,y=(egcd(a,b))\n\n\nstatus=0\nif((n%gcd)!=0):\n print(\"NO\")\n #print(\"point1\")\n\nelse:\n multiply=n/gcd\n x1=int(multiply*x)\n y1=int(multiply*y)\n #print(\"gcd and soln to n\")\n #print(gcd,x1,y1)\n d1=b/gcd\n d2=a/gcd\n rangemin= int(math.ceil(-x1/d1))\n rangemax= int(y1//d2)\n #print(\"rangemin and rangemax\")\n #print(rangemin,rangemax)\n if(rangemin>rangemax):\n print(\"NO\")\n #print(\"point2\")\n else:\n #print(\"YES\")\n #solx=x1+rangemin*d1\n #soly=y1-rangemin*d2\n m=rangemin\n while(m<=rangemax):\n solx=x1+m*d1\n soly=y1-m*d2\n if(solx>=0 and soly>=0):\n print(\"YES\")\n status=1\n print(str(int(solx))+\" \"+str(int(soly)))\n break\n m=m+1\n\n if(status==0):\n print(\"NO\")\n #print(\"point3\")\n \n \n"}, {"source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\n\nif n < a and n < b:\n print 'NO'\n exit()\n\nfrom fractions import gcd\nc = gcd(a,b)\na /= c\nb /= c\n\nif n % c != 0:\n print 'NO'\nelse:\n n /= c\n\n def euclid(a, b):\n if a == 0:\n return (0, 1, b)\n (x, y, res) = euclid(b%a, a)\n return (y - (b/a) * x, x, res)\n\n (a_inv, y, res) = euclid(a, b)\n\n x_modb = (a_inv * n) % b\n for x in xrange(x_modb,n+1,b):\n by = (n - a*x)\n if by >= 0 and by % b == 0:\n print 'YES'\n print '{} {}'.format(x, by/b)\n exit()\n print 'NO'\n"}, {"source_code": "from sys import stdin, stdout\n\n\nn = int(stdin.readline())\na = int(stdin.readline())\nb = int(stdin.readline())\nx = 0\nflg = False\nwhile n >= 0:\n if n % b == 0 or n % b == 0:\n stdout.write(\"YES\\n\")\n stdout.write(str(x)+\" \"+str(n // b))\n flg = True\n break\n n = n - a\n x += 1\nif not flg:\n stdout.write(\"NO\\n\")\n"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nx = 0\ny = -1\nwhile a * x <= n:\n\tif (n - a * x) % b == 0:\n\t\ty = (n - a * x) // b\n\t\tbreak\n\tx += 1\nif y == -1:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\tprint(x, y, sep=\" \")"}, {"source_code": "z=input;n,a,b=int(z()),int(z()),int(z())\nfor i in range(min(a,b,n//(max(a,b)) +1)):\n if (n-i*a)%b==0:\n print('YES')\n print(i,(n-a*i)//b)\n break\n elif ((n-b*i)%a)==0:\n print('YES')\n print((n-b*i)//a,i)\n break\nelse:print('NO')"}, {"source_code": "a=int(input())\nb=int(input())\nc=int(input())\nif(b>c):\n\n\tfor j in range(a//b +1):\n\t\tif((a-(j*b))%c==0):\n\t\t\tprint(\"YES\")\n\t\t\tprint(j,(a-(j*b))//c)\n\t\t\tbreak\n\telse:\n\t \n\t\tprint(\"NO\")\n\nelse:\n\tfor j in range(a//c +1):\n\t\tif((a-(j*c))%b==0):\n\t\t\tprint(\"YES\")\n\t\t\tprint((a-(j*c))//b,j)\n\t\t\tbreak\n\telse:\n\t\tprint(\"NO\")\n"}, {"source_code": "t = input()\nbo = input()\nba = input()\nif t%bo == 0:\n\tprint 'YES'\n\tprint t/bo,0\nelif t%ba == 0:\n\tprint 'YES'\n\tprint 0,t/ba\nelse:\n\tflag = 0\n\tfor i in range(1,t/bo+1):\n\t\tif (t - i*bo)%ba == 0:\n\t\t\tflag = 1\n\t\t\tprint 'YES'\n\t\t\tprint i, (t-i*bo)/ba\n\t\t\tbreak\n\tif flag == 0:\n\t\tprint 'NO'\n\n\t\n\t\n"}, {"source_code": "n=int(input())\n\na=int(input())\n\nb=int(input())\n\n\n\nis_swapped=b>a\n\nif is_swapped:\n\n\ta,b=b,a\n\nif a%b==0 and n%b!=0:\n\n\tprint('NO')\n\n\texit()\n\nfor i in range(n//a+1):\n\n\tif (n-a*i)%b==0:\n\n\t\tprint('YES')\n\n\t\tx=i\n\n\t\ty=(n-a*i)//b\n\n\t\tif is_swapped:\n\n\t\t\tx,y=y,x\n\n\t\tprint(x,y)\n\n\t\texit()\n\nprint('NO')\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "from fractions import gcd\n\nn = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\n\ng = gcd(a,b)\nif n % g != 0:\n print \"NO\"\n exit()\nif g != 1:\n n /= g\n a /= g\n b /= g\n\nif n % b == 0:\n print \"YES\\n0 \" + str(n/b)\n exit()\n\ndef modInverse(u, v):\n m0 = v\n y = 0\n x = 1\n if v == 1:\n return 0\n while u > 1:\n q = u / v\n t = v\n v = u % v\n u = t\n t = y\n y = x - q*y\n x = t\n if x < 0:\n x += m0\n return x\n\nx = (modInverse(a,b) * n) % b\n\nwhile a * x <= n:\n if (n - a * x) % b == 0:\n print \"YES\\n\" + str(x) + \" \" + str((n-a*x)/b)\n exit()\n x += b\nprint \"NO\"\n"}, {"source_code": "import sys, re\n\nn = int(sys.stdin.readline())\na = int(sys.stdin.readline())\nb = int(sys.stdin.readline())\nfor i in range(10000001):\n if (n - a * i) % b == 0 and (n - a * i) >= 0:\n print('YES')\n print(i, (n - a * i) // b)\n sys.exit(0)\nprint('NO')\n"}, {"source_code": "from sys import stdout\n# fi=open(\"input.txt\",\"r\")\n# fo=open(\"output.txt\",\"w\")\n\nx=int(raw_input())\na=int(raw_input())\nb=int(raw_input())\n\nif x%a==0:\n\tstdout.write(\"YES\\n\")\n\tstdout.write(str(x/a)+\" 0\\n\")\nelif x%b==0:\n\tstdout.write(\"YES\\n\")\n\tstdout.write(\"0 \"+str(x/b)+\"\\n\")\nelif a%b==0 or b%a==0:\n\tstdout.write(\"NO\\n\")\nelse:\n\tcpyx=x\n\tflag=False\n\twhile x>=0:\n\t\tif x%b==0:\n\t\t\tflag=True\n\t\t\tstdout.write(\"YES\\n\")\n\t\t\tstdout.write(str((cpyx-x)/a)+\" \")\n\t\t\tstdout.write(str(x/b)+\"\\n\")\n\t\t\tbreak\n\t\tx-=a\n\tif not flag:\n\t\tstdout.write(\"NO\\n\")"}, {"source_code": "import sys\nfrom fractions import gcd\nn=input()\nx=input()\ny=input()\nflag=False\nif(x<y):\n temp=x\n x=y\n y=temp\n flag=True\ngcf=gcd(x,y)\nif(n%gcf!=0):\n print(\"NO\")\n sys.exit(0)\na=0\nwhile(a*x<=n):\n if((n-a*x)%y==0):\n b=(n-a*x)/y\n if(flag==False): print(\"YES\\n\"+str(a)+\" \"+str(b))\n else : print(\"YES\\n\"+str(b)+\" \"+str(a))\n sys.exit(0)\n a+=1\nprint(\"NO\")\n"}, {"source_code": "n = input()\na = input()\nb = input()\n\nT = a\nflag = False\nif b > a:\n T = b\n b = a\n flag = True\n\nx = 0\n\nif int(T) == int(b):\n if not n % b == 0:\n\tprint 'NO'\n\tquit()\n\nwhile x * T <= n:\n val = n - (x * T)\n if val % b == 0:\n\ty = val / b\n print 'YES'\n\tif flag:\n\t print y, x\n\telse:\n\t print x, y\n\tquit()\t\n x += 1\n\nprint 'NO'\n\n"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nif(x%y!=0 and x%z!=0):\n while(x%y != 0 and toolong > 0 and x > y):\n \tx -= z\n \tbar += 1\n \ttoolong -= z\nif(x % y == 0 and x > 0):\n\tcola += x // y\nelif(x % z == 0 and x > 0):\n\tbar += x // z\nelse:\n\tprint(\"NO\")\n\tquit()\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nwhile(x%y != 0 and toolong > 0 and x > y):\n\tx -= z\n\tbar += 1\n\ttoolong -= z\nif(x % y == 0 and x > 0):\n\tcola += x // y\nelif(x % z == 0 and x > 0):\n\tbar += x // z\nelse:\n\tprint(\"NO\")\n\tquit()\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\nfor i in range(min(a, b, n / max(a, b) + 1)):\n\tif (n - i * a) % b == 0:\n\t\tprint 'YES\\n', i, (n - i * a) / b\n\t\tbreak\n\tif (n - i * b) % a == 0:\n\t\tprint 'YES\\n', (n - i * b) / a, i\n\t\tbreak\nelse:\n\tprint 'NO'"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=2+(x%1000)+((y*z)*10)\nfor i in range(x):\n\tif((y == z and x % y != 0) or (x <= 0) or (toolong <= 0) or ((x<z) and (x<y))):\n\t\tprint(\"NO\")\n\t\tquit()\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\telif(y>z or (x>y and z>x)):\n\t\twhile(x%z != 0 and toolong > 0 and x > 0):\n\t\t\tx -= y\n\t\t\tcola += 1\n\t\t\ttoolong -= y\n\telif(z>y or (x>z and y>x)):\n\t\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\t\tx -= z\n\t\t\tbar += 1\n\t\t\ttoolong -= y\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif((y == z and x % y != 0) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\twhile(x%z != 0 and toolong > 0 and x > 0):\n\t\tx -= y\n\t\tcola += 1\n\t\ttoolong -= y\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\twhile(x%y != 0 and toolong > 0 and (x > 0 and x > y)):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\n\tif(x % y == 0 and x > 0):\n\t\tcola += x // y\n\t\tbreak\n\tif(x % z == 0 and x > 0):\n\t\tbar += x // z\n\t\tbreak\n\telse:\n\t\tprint(\"NO\")\n\t\tquit()\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\tif((y == z and x % y != 0) or (z + y > x) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\twhile(x%y != 0 and toolong > 0 and x >= z):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "from math import sqrt\nn = int(input())\na = int(input())\nb = int(input())\nfor i in range(int(n / 2 + 0.5)):\n if n - (i * b) >= 0 and (n - (i * b)) % a == 0:\n print(\"YES\")\n print((n - i * b) // a, i)\n exit()\nprint(\"NO\")\n"}, {"source_code": "import math\nimport sys\nN = int(input())\na = int(input())\nb = int(input())\ndiv = math.gcd(N, math.gcd(a, b))\nif div == 1:\n if math.gcd(a, b) != 1:\n print(\"NO\")\n sys.exit()\nelse:\n N, a, b = N/div, a/div, b/div\n\nif a == 1:\n print(\"YES\")\n print(int(a*N), 0)\n sys.exit()\nelif b == 1:\n print(\"YES\")\n print(0, int(b*N))\n sys.exit()\nelif N % 2 == 0:\n if a == 2:\n print(\"YES\")\n print(int(N/2), 0)\n sys.exit()\n elif b == 2:\n print(\"YES\")\n print(0, int(N/2))\n sys.exit()\nr = 0\nwhile r*a <= N:\n if (N-(r*a)) % b == 0:\n print(\"YES\")\n print(r, int((N-(r*a))/b))\n sys.exit()\n r += 1\nprint(\"NO\")\n"}, {"source_code": "import bisect\n\ndef list_output(s): \n print(' '.join(map(str, s)))\n \ndef list_input(s='int'):\n if s == 'int':\n return list(map(int, input().split())) \n elif s == 'float':\n return list(map(float, input().split()))\n return list(map(str, input().split()))\n\nn = int(input())\na = int(input())\nb = int(input())\nfor x in range(n+1):\n t = n - x*a\n if t >= 0 and t%b == 0:\n y = t//b\n print('YES')\n print(' '.join(map(str, [x, y])))\n exit(0)\nprint('NO')\n \n"}, {"source_code": "'''\nINPUT SHORTCUTS\nN, K = map(int,input().split())\nN ,A,B = map(int,input().split())\nstring = str(input())\narr = list(map(int,input().split()))\nN = int(input())\n'''\n\n\n\ndef main():\n\tN = int(input())\n\ta = int(input())\n\tb = int(input())\n\tfor i in range(0,N//a+1):\n\t\tif (N-(i*a))%b==0 and (N-(i*a))>-1:\n\t\t\tprint(\"YES\")\n\t\t\tprint(i,(N-(i*a))//b)\n\t\t\treturn\n\tprint(\"NO\")\n\nmain()"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\n\naa=[]\ni=0\nwhile(i*a<=n):\n aa.append(i*a)\n i+=1 \nf=0\n\nfor i in range(len(aa)):\n if (n-aa[i])%b==0:\n f=1 \n print(\"YES\")\n print(i,(n-aa[i])//b)\n break \nif f==0:\n print(\"NO\")\n "}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nl = n//a\nfor i in range(l,-1,-1):\n t = n-(i*a)\n r = t%b\n if r==0:\n print(\"YES\")\n print(i,t//b)\n break\nif r!=0:\n print(\"NO\")"}, {"source_code": "import math\ndef main():\n n = int(input())\n a = int(input())\n b = int(input())\n if n % math.gcd(a, b):\n print('NO')\n else:\n flag = 0\n if a < b:\n a, b = b, a\n flag = 1\n for i in range(1 + n // a):\n if (n - i * a) % b == 0:\n print('YES')\n if flag:\n print((n - i * a) // b, i)\n else:\n print(i, (n - i * a) // b)\n return\n print('NO')\n\nmain()"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\ndef gcd(x,y):\n if y==0:\n return x\n else:\n return gcd(y,x%y)\nx=True\nif n%gcd(a,b)==0:\n if a>b:\n for i in range(0,n//a+1):\n if (n-i*a)%b==0:\n print(\"YES\")\n x=False\n print(i,\"\",(n-i*a)//b)\n break\n else:\n for i in range(0,n//b+1):\n if (n-i*b)%a==0:\n print(\"YES\")\n x=False\n print((n-i*b)//a,\"\",i)\n break\nif x:\n print(\"NO\")"}, {"source_code": "import math\n\nn = int( input() )\na = int( input() )\nb = int( input() )\n\n#print( n, a, b )\n\nMAXVAL = 10000000\n\nx = 0\n\nwhile a * x <= n:\n\n if ( n - x * a ) % b == 0:\n print( \"YES\" )\n print( x, ( n - x * a ) // b )\n exit(0)\n\n x += 1\n\nprint( \"NO\" )\n"}, {"source_code": "import sys\nLI=lambda:list(map(int, sys.stdin.readline().split()))\nMI=lambda:map(int, sys.stdin.readline().split())\nSI=lambda:sys.stdin.readline().strip('\\n')\nII=lambda:int(sys.stdin.readline())\n\nc, a, b=II(), II(), II()\nok=False\nfor i in range(0, c, a):\n if (c-i)%b==0:\n ok=True\n ans=[i//a, (c-i)//b]\nfor i in range(0, c, b):\n if (c-i)%a==0:\n ok=True\n ans=[(c-i)//a, i//b]\nif ok:\n print('YES')\n print(*ans)\nelse:\n print('NO')\n"}, {"source_code": "n,a,b=[int(input())for _ in[0]*3]\nfor i in range(n+2):\n if i*a>n:break\n if (n-i*a)%b<1:\n print(f'YES\\n{i} {(n-i*a)//b}')\n break\nif i*a>n:print('NO')"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nma=max(a,b)\nmi=min(a,b)\nk=ma//mi\ncount=0\nif a==b:\n if n%a==0:\n print('YES')\n print(0,n//a)\n else:\n print('NO')\nelif ma//mi == ma/mi:\n if n%mi==0:\n print('YES')\n if b==ma:\n print(n//a,0)\n else:\n print(0,n//b)\n else:\n print('NO')\nelif b>a:\n for i in range(n//b + 2):\n if (n-i*b)>=0 and (n-i*b)%a==0:\n print(\"YES\")\n count=1\n print((n-i*b)//a,end=' ')\n print(i)\n break\n if count==0:\n print(\"NO\")\nelse:\n for i in range(n//a + 2):\n if (n-i*a)>=0 and (n-i*a)%b==0:\n print(\"YES\")\n count=1\n print(i,end=' ')\n print((n-i*a)//b,end=' ')\n break\n if count==0:\n print(\"NO\")\n "}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\n\ndef gcd(a, b):\n if (a == 0):\n return b, 0, 1\n\n d, x1, y1 = gcd(b%a, a)\n x = y1-x1*(b//a)\n y = x1\n return d, x, y\n\nd, x, y = gcd(a, b)\nd, x, y = gcd(d, n)\na //= d\nb //= d\nn //= d\nd, x, y = gcd(a, b)\n\nif (d>1):\n print(\"NO\")\nelse:\n x0 = x*n\n y0 = y*n\n l = (-x0+b-1)//b\n r = y0//a\n if (r-l>=0):\n print(\"YES\")\n print(x0+b*l, y0-a*l)\n else:\n print(\"NO\")"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\n\nis_swapped=b>a\nif is_swapped:\n\ta,b=b,a\nif a%b==0 and n%b!=0:\n\tprint('NO')\n\texit()\nfor i in range(n//a+1):\n\tif (n-a*i)%b==0:\n\t\tprint('YES')\n\t\tx=i\n\t\ty=(n-a*i)//b\n\t\tif is_swapped:\n\t\t\tx,y=y,x\n\t\tprint(x,y)\n\t\texit()\nprint('NO')"}, {"source_code": "n = int(input())\nx = int(input())\ny = int(input())\n\nimport sys\n\ndef gcd(a,b):\n if b > a:\n return gcd(b,a)\n if a % b == 0:\n return b\n return gcd(b, a%b)\n\nd = gcd(x,y)\nif n % d != 0:\n print('NO')\n sys.exit(0)\n\ndef phi(n):\n result = n\n i = 2\n while i * i <= n:\n if n % i == 0:\n while n % i == 0:\n n //= i\n result -= result // i\n i += 1\n if n > 1:\n result -= result // n\n return result\n\nx1 = x//d\ny1 = y//d\nn = n//d\n\nb = (n*pow(y1, phi(x1) - 1, x1)) % x1\n\na = (n - y1*b) // x1\n\nif a >= 0 and b >= 0:\n print('YES')\n print(a, b)\nelse:\n print('NO')\n\n\n\n\n\n\n"}, {"source_code": "import math\n\nn=int(input())\na=int(input())\nb=int(input())\n\nc=max(a,b)\nd=min(a,b)\ni=0\nflag=0\ngc = math.gcd(c,d)\nif(n%gc==0):\n while(c*i<=n):\n diff=n-c*i\n if(diff%d==0):\n flag=1\n print(\"YES\")\n if(c==a):\n print(i,(diff)//d)\n else:\n print((diff)//d,i)\n break\n i+=1\nif(flag==0):print(\"NO\")\n "}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\n\ndef gcd(a, b):\n if a * b == 0:\n return a + b\n return gcd(b, a % b)\n\nd = gcd(a, b)\nif n % d != 0:\n print(\"NO\")\nelse:\n n, a, b = n//d, a//d, b//d\n if a >= b:\n for x in range(n // a + 1):\n if (n - a * x) % b == 0:\n print(\"YES\")\n print(x, (n - a * x) // b)\n break\n else:\n print(\"NO\")\n else:\n for y in range(n // b + 1):\n if (n - b * y) % a == 0:\n print(\"YES\")\n print((n - b * y) // a, y)\n break\n else:\n print(\"NO\")"}, {"source_code": "from math import gcd\ndef xgcd(a, b):\n \"\"\"return (g, x, y) such that a*x + b*y = g = gcd(a, b)\"\"\"\n x0, x1, y0, y1 = 0, 1, 1, 0\n while a != 0:\n q, b, a = b // a, a, b % a\n y0, y1 = y1, y0 - q * y1\n x0, x1 = x1, x0 - q * x1\n return b, x0, y0\n\nn = int(input())\na = int(input())\nb = int(input())\nif n % gcd(a, b) == 0:\n g, x ,y = xgcd(a,b)\n lcm = a * b // g\n x *= (n // g)\n y *= (n // g)\n if x < 0:\n change = -(x // (lcm//a))\n x += (lcm//a)*change\n y -= (lcm//b)*change\n elif y < 0:\n change = -(y // (lcm//b))\n x -= (lcm//a)*change\n y += (lcm//b)*change\n if x < 0 or y < 0:\n print(\"NO\")\n else:\n print(\"YES\")\n print(x,y)\nelse:\n print(\"NO\")\n"}, {"source_code": "import math\ndef gcd_e(a, b):\n\tif(a==0):\n\t\treturn (0, 1)\n\telse:\n\t\tx_, y_=gcd_e(b%a, a)\n\t\tx=y_-(b/a)*x_\n\t\ty=x_\n\t\treturn (x, y)\n\nimport sys\nfrom fractions import gcd \nn=input()\na=input()\nb=input()\nif(n%gcd(a, b)!=0):\n\tprint \"NO\"\n\tsys.exit()\nx, y=gcd_e(a, b)\nx=x*(n/gcd(a, b))\ny=y*(n/gcd(a, b))\n# print x, y\n# k=min(x*gcd(a, b)/b, -(y*gcd(a, b)/a))\n# x=x-k*b/gcd(a, b)\n# y=y+k*a/gcd(a, b)\n# if(x<0):\n#\tx=x+b\n#\ty=y-a\n#elif(y<0):\n#\tx=x-b\n#\ty=y+a\nif(x<0 and y>=0):\n\tk=math.ceil(float(abs(x))*gcd(a, b)/b)\n\tx=x+int(k)*b/gcd(a, b)\n\ty=y-int(k)*a/gcd(a, b)\nelif(x>=0 and y<0):\n\ta, b=b, a\n\tx, y=y, x\n\tk=math.ceil(float(abs(x))*gcd(a, b)/b)\n\tx=x+int(k)*b/gcd(a, b)\n\ty=y-int(k)*a/gcd(a, b)\n\tx, y=y, x\nif(x>=0 and y>=0):\n\tprint \"YES\"\n\tprint x, y\nelse:\n\tprint \"NO\""}, {"source_code": "val = input()\na = input()\nb = input()\nx = 0\nwhile x*a <= val:\n\tt = val - x*a\n\tif t%b == 0:\n\t\ty = t/b\n\t\tprint 'YES'\n\t\tprint x,y\n\t\tquit()\n\tx += 1\nprint 'NO'"}, {"source_code": "I=input\nn,a,b=I(),I(),I()\nfor i in xrange(n+1):\n d=n-a*i\n if d<0:\n print 'NO'\n break\n if 0==d%b:\n print 'YES'\n print i,d/b\n break\nelse:\n print 'NO'"}, {"source_code": "n = input()\na = input()\nb = input()\nans = \"NO\"\nx = 0\nwhile x*a <= n:\n if (n-x*a)%b==0:\n ans = \"YES\"\n y = (n-x*a)/b\n break\n x+=1\nif ans==\"YES\":\n print ans\n print x,y\nelse:\n print ans"}, {"source_code": "'''\nn burles\n\nBer-Cola costs a burles and one Bars bar costs b burles\n\nFind out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly n burles.\n\nIn other words, you should find two non-negative integers x and y such that Vasya can buy x bottles of Ber-Cola and y Bars bars and x\u00b7a\u2009+\u2009y\u00b7b\u2009=\u2009n or tell that it's impossible\n'''\ndef low(butt,ass):\n\tif(butt < ass):\n\t\treturn butt\n\telse :\n\t\treturn ass\n\nn = int(input())\ncb = int(input())\nbb = int(input())\ni = 1\nv = 0\nw = 0\nflag = False\nmuxi = max(bb,cb)\nluxi = low(bb,cb)\nif(muxi == cb):\n\tflag = True\n#print(muxi,luxi)\nans = i*muxi\n#print(ans)\nif(muxi%luxi == 0 and n % luxi != 0):\n\tprint(\"NO\")\nelif(n % cb == 0 or n % bb == 0):\n\tprint(\"YES\")\n\tif(n % cb == 0):\n\t\tprint(\"{} {}\".format(n//cb,0))\n\telif(n % bb == 0):\n\t\tprint(\"{} {}\".format(0,n//bb))\nelse :\n\twhile(ans<=n):\n\t\tif((n-ans)%luxi == 0):\n\t\t\tprint(\"YES\")\n\t\t\tif(flag):\n\t\t\t\tprint(\"{} {}\".format(i,(n-ans)//luxi))\n\t\t\telse :\n\t\t\t\tprint(\"{} {}\".format((n-ans)//luxi,i))\n\t\t\texit()\n\t\ti += 1\n\t\tans = muxi*i\n\tprint(\"NO\")"}], "negative_code": [{"source_code": "\"\"\"\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n ..,,,,,,,,************,,,,,,,,,,,,,.\n ..,*. .,,,,,,,,,,,,,,,,,,,,,,,,...\n #&@@@@@@@@@@@@@@@@@( .....,,,,,,,.....\n (*@@@@@@@@@@@@@@@@@@@@@@@@&* ...,,,,,\n &*&@@@@@@%@%,.*%@@@@@@@@@@@@@@@@& (&@@@@&%/ ..,,,,,,,,,,,,,*******\n ##@@@@@@&#, *@@@@@@@@@@@@ (@@@@@@@@@@@@@@@@@@@@@( . /@@@@(,,,,,,,*********//\n (@@@@@@@. #@@@@@@@@@@* %@@@@@@@@@@@@&&@@@@@@@@@@@@@@@% ,@@@@@@% /@@@@@@(...,,,,,,,,,,,,,,**\n ,,@@@@@@, #@@@@@@@&, %@@@@@@@/ #@@@@@@@& @@@@@@@@@& .... ,@@@@@@@/ ..,,,,,,,,\n ,@@@@@@, .&@@@@&. &@@@@@@. ,&@@@@@@, @@@@@@@@@@, @@@@@@@@% ..,,,\n /&@@@@@/ &@ %@@@@@@ #@@@@@@/ /@@@@@@@@@@& @@@@@@@@@@ .\n @@@@@@/ &@@@@@, *@@@@@@. @@@@@@@@@@@@ *@@@@@@@@@@&\n &&@@@@% @@@@@@ .&@@@@@@@@@@@@& (@@@@@@ #@@@@@@@@@@@# @@@@@@@@@@@&\n *%&&@@@*# @@@@@@ /@@@@@@@@@@@@@@@@@@@% @@@@@@ .@@@@@@@@@@@@ @@@@@@@@@@@&\n .&@@@@@*( /@@@@@, @@@@@@@@@@@# &@@@@@@@@@( &@@@@@ .@@@@@@@@@@@& @@@@@@@@@@@,\n .&@@@@@@% &@@@@@ @@@@@@@@@@@. @@@@@@@@& &@@@@@ &@@@@@@@@@@@@@@@@@@@@\n (/@@@@@@@#. @@@@@& ,@@@@@@@@@ .@@@@@@% @@@@@% @@@@@@@@@@@@@@@@@#\n &%@@@@@@@@@# @@@@@& *@@@@@@@@ /@@@@@& ,@@@@@ @@@@@@@@@@@@@@,\n (,@@@/%@@@@@@@@@@@&, &@@@@@ @@@@@@@& @@@@@@* @@@@@. @@@@@@@@@@@\n . &@@@@@@@@@@@@@@@@@@@, @@@@@( *@@@@@@@, ,@@@@@@@ @@@@@, ,@@@@@@@@@@@@\n .&@@@@@@@@@@@@@@@@@@, &@@@@@ (@@@@@@@& ,@@@@@@@& @@@@@ @@@@@@@@@@@@@@@@\n (@@@@@@@@@@@@, &@@@@@ @@@@@@@@@@@@@&@@@@@@@@@@@ @@@@@@ /@@@@@@@@.@@@@@@@@@&\n %@@@@@@@@@% @@@@@@ &@@@@@@@@@@@@@@@@@@@@( #@@@@& (@@@@@@@& .@@@@@@@@@/\n *@@@@@@@@# @@@@@@. &@@@@@@@@@@@@@@, &@@@@@. .@@@@@@@# @@@@@@@@@\n &@@@@@@@ &@@@@@& %@@@@@@ *@@@@@@@ @@@@@@@@&\n &@@@@@@, %@@@@@@& &@@@@@@( .....,,.&@@@@@@& #&@@@@@@.\n %@@@@@@ ........@@@@@@@@ . %@@@@@@@( .,,,,,,,,*@@@@@@@ /@@@@@@@\n &@@@@@@ .....,,,,,,,,@@@@@@@@# *@@@@@@@@@. ..,,,,,,,,,,%@@@@@@@ .@@@@@@#\n @@@@@@. ....,,,,,,,,,,,@@@@@@@@@@@@@@# *&@@@@@@@@@@@@@@@@ .,,,,,,,,,,,,,,@@@@@@@* @@@@@@,\n * @@@@@@, ...,,,,,,,,,,,,(@@@@@@/@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@# .,,,,,,,,,,,,,,,,#@@@@@@& @@@@@&\n @@@@/ @@@@@@,...,,,,,,,,,,,,,@@@@@@@ *&@@@@@@@@@@@@@@@@% @@@@@@@@,,,,,,&&#*,,,,,,,,,%@@@@@@ @@@@@#\n &@@@@@ &@@@@@@,,,,,,&@@@@*,,,/@@@@@@& *@@@@@@@*,,,*@@@&,,... #@@@@@ .@@@@&\n &@@@@@# @@@@@@@,,,,,,%@@@@@@@/@@@@@@@. ..@@@@@@@(,,*@@@@( (@@@@/ ,@@@@.\n ,@@@@@@/ &@@@@@@@,,,,,,,,,@@@@@@@@@@@@, ....,,%@@@@@@% @@@@@ @@@@ (@@@*\n &@@@@@@@ ,@@@@@@@@@,,,,,,,,,,,,/@@@@@@@@# ..........@@@@@@% &@@@@ #@% @@@&\n #@@@@@@@@. (@@@@@@@@@@,,,,,,,,,,,.../@@@@@@@@@@@. .... %@@@@@%.@@@@ *@@#/\n .@@@@@@@@@@&, *@@@@@@@@@@@@&,,,,,,,,,... .@@@@@@&*@@@@@@@% @@@@@@@@@@& &@@(\n @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%..,,,,,,.... .@@@@@@@. #@@@@@@@ &&& %@@@@@@@@@ %&%\n &@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@%............ @@@@@@@/ /@&% &@@@@@@@@&. @@@@@@@@ (&/\n (@@@@@@, *&@@@@@@@@@&/ .... (@@@@@@# &&@@@@@@@@@@@@@@@@@@@@@* *\n *** %@@@@@& .(@@@@@@@@@@@@@@@@%......\n ,&, ....,,,,,,,,,,,,,,,,,,/&@@@@@@*.\n ...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,... .,,,\n ...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.. ..,,,,****\n ..,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.. .,,,,,,****////\n\"\"\"\nn = int(input())\na = int(input())\nb = int(input())\nfor i in range(n // a + 1):\n if (n - a * i) % b == 0 and n - a * i > 0:\n print(\"YES\")\n print(i, (n - a * i) // b)\n break\nelse:\n print(\"NO\")\n \n "}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Dec 16 14:43:34 2017\n\n@author: ms\n\"\"\"\n\ndef main():\n n = int(input())\n a = int(input())\n b = int(input())\n \n if(n%a == 0):\n print('YES')\n print(int(n/a), 0)\n return\n if(n%b == 0):\n print('YES')\n print(0, int(n/b))\n return\n \n if(a%2 == b%2):\n if (n%2 != a%2):\n print('NO')\n \n mx = max(a,b)\n mn = min(a,b)\n new = 0\n found = 0\n i = 0\n while(n>=0):\n n -= mx\n i += 1\n if(n%mn == 0):\n found = 1\n new = n\n break\n if found:\n print('YES')\n if (mx == a):\n print(i, int(new/b))\n if (mx == b):\n print(int(new/a), i)\n else:\n print('NO')\n \nmain()"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\ni=n-n//(a+b)*max(a,b)\nif(i%min(a,b)!=0):\n\tprint('NO')\nelse:\n\tprint('YES')\n\tif(a==max(a,b)):\n\t\tprint(n//(a+b),i//min(a,b))\n\telse:\n\t\tprint(i//min(a,b),n//(a+b))"}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n \nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s): # Palindrome\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way\n\n\ndef main():\n\tn = ii()\n\ta = ii()\n\tb = ii()\n\tif n % math.gcd(a,b) != 0:\n\t\tprint('NO')\n\t\n\tfor i in range(100000):\n\t\tif (n-b*i)%a == 0:\n\t\t\tif (n-b*i)//a >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\tprint((n-b*i)//a, i)\n\t\t\t\tbreak\n\telse:\n\t\tprint('NO')\n\t\nmain()\n\t"}, {"source_code": "import sys, re\n\nn = int(sys.stdin.readline())\na = int(sys.stdin.readline())\nb = int(sys.stdin.readline())\nif n % abs(a - b) == 0:\n print('NO')\nelse:\n for i in range(n // b + 1):\n for j in range(n // a + 1):\n if a * i + b * j == n:\n print('YES')\n print(i, j)\n sys.exit(0)"}, {"source_code": "import time\nfrom fractions import gcd\n\nn, a, b = int(input()), int(input()), int(input())\nt = time.time()\n\nif n%a == 0:\n\tprint('YES')\n\tprint('{} {}'.format(int(n/a),0))\n\texit()\n\n\nif n%b == 0:\n\tprint('YES')\n\tprint('{} {}'.format(0,int(n/b)))\n\texit()\n\n \nif n%gcd(a,b) != 0:\n\tprint(\"NO\");\n\texit()\n\ni = 1\nwhile (n-a*i) >= 0 or (n-b*i) >= 0:\n\tif (n-a*i)%b == 0:\n\t\ty = (n-a*i)//b\n\t\tprint('YES')\n\t\tprint('{} {}'.format(i,y))\n\t\texit()\n\n\tif (n-b*i)%a == 0:\n\t\tx = (n-b*i)//a\n\t\tprint('YES')\n\t\tprint('{} {}'.format(x,i))\n\t\texit()\n\ti+=1\nprint(\"NO\");\n# print(t-time.time())"}, {"source_code": "import math\ndef ixgcd(a, b):\n \"\"\" gcd(a, b) = a * x + b * y \n the extended euclidean gcd algo, iteration \"\"\"\n x0, x1, y0, y1 = 1, 0, 0, 1\n while b:\n q, a, b = a // b, b, a % b\n x0, x1 = x1, x0 - q * x1\n y0, y1 = y1, y0 - q * y1\n return a, x0, y0\n\nc = int(input())\na = int(input())\nb = int(input())\nd, x0, y0 = ixgcd(a,b)\n# print(d, x0, y0)\nif c%d == 0 and a+b<=c:\n x0 *= c//d\n y0 *= c//d\n # print(x0,y0)\n if x0 >= 0 and y0 >= 0:\n print(\"YES\")\n print(x0, y0)\n\n elif x0 < 0 and y0 < 0:\n print(\"NO\")\n else:\n if x0 < 0:\n k = (d*x0)/b\n # x1 = (x0 - k * b//d)\n elif y0 < 0:\n k = (-1*d*y0)/a\n # print(\"test\")\n # y1 = (y0 + k * a//d)\n # print(\"before {}\".format(k))\n if k < 0:\n k = math.floor(k)\n # print(k)\n elif k > 0:\n k = math.ceil(k)\n # print(k)\n x1 = x0 - (k*b)//d\n y1 = y0 + (k*a)//d\n print(\"YES\")\n print(x1, y1)\nelse:\n print(\"NO\")"}, {"source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\n\ndef euclid1(a,b):\n m,n = 0,1\n x,y = 1,0\n while a > 0:\n tem1, tem2 = b/a, b%a\n tem3 = m-x*tem1\n tem4 = n - y*tem1\n a,b = tem2, a\n m,n,x,y = x,y,tem3, tem4\n return [b,m,n]\n\nk = euclid1(a,b)\nif n%k[0] == 0:\n print \"YES\"\n print k[1]*n/k[0], k[2]*n/k[0]\nelse:\n print \"NO\"\n "}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\na = inp()\nb = inp()\nif n % gcd(a, b) == 0:\n\n y = 0\n x = 0\n while y * b <= n:\n if (n - b*y) % a == 0 and (n-b*y) > 0:\n x = (n - (b*y)) // a\n print(\"YES\")\n print(x, y)\n break\n else:\n print(\"NO\")\n y += 1\n\n\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n \nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s): # Palindrome\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way\n\n\ndef main():\n\tn = ii()\n\ta = ii()\n\tb = ii()\n\tif n % math.gcd(a,b) != 0:\n\t\tprint('NO')\n\t\texit()\n\t\n\t#for i in range(n//2+1):\n#\t\tif (n-b*i)%a == 0:\n#\t\t\tif (n-b*i)//a >= 0:\n#\t\t\t\tprint('YES')\n#\t\t\t\tprint((n-b*i)//a, i)\n#\t\t\t\tbreak\n#\telse:\n#\t\tprint('NO')\n\n\tfor i in range(n//a):\n\t\tif ((n-b*i)%a == 0) or ((n-a*i)%b == 0):\n\t\t\tif (n-b*i)//a >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\tprint((n-b*i)//a,i)\n\t\t\t\tbreak\n\t\t\telif (n-a*i)//b >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\tprint(i, (n-a*i)//b)\n\t\t\t\tbreak\n\telse:\n\t\tprint('NO')\n\t\t\n\t\nmain()\n\t"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\ni = 0\nif a >= b:\n while i <= n//a+1:\n if (n - i*a)% b == 0:\n print('YES')\n print(str(i)+' '+str(int((n-i*a)/b)))\n break\n i +=1\n if i == n//a+1:\n print('NO')\nelse:\n a1 = b\n b1 = a\n while i <= n//a1+1:\n if (n - i*a1)% b1 == 0:\n print('YES')\n print(str(int((n-i*a)/b))+' '+str(i))\n break\n i +=1\n if i == n//a1+1:\n print('NO')\n"}, {"source_code": "n=input()\na=input()\nb=input()\nfrom fractions import gcd \nif n%gcd(a,b)!=0:\n print \"NO\"\nelse:\n \n g=gcd(a,b)\n n=n/g \n a=a/g \n b=b/g\n for i in range(0,n+1):\n if (n-a*i)%b==0:\n print \"YES\"\n print i,(n-a*i)/b \n exit()\n break\n print \"NO\""}, {"source_code": "val = input()\na = input()\nb = input()\nx = 0\nwhile x*a <= val:\n\tt = val - x*a\n\tif t%b == 0:\n\t\ty = t/b\n\t\tprint 'Yes'\n\t\tprint x,y\n\t\tquit()\n\tx += 1\nprint 'NO'"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nx = y = 0\nflag = False\n\nif a == b and n % a == 0:\n\tprint(\"YES\")\n\tprint(n//a, 0)\nelse:\n\twhile a*x <= n:\n\t\tif (n - a*x) % b == 0:\n\t\t\tprint(\"YES\")\n\t\t\tprint(x, (n - a*x)//b)\n\t\t\tflag = True\n\t\t\tbreak\n\t\telse:\n\t\t\tx += 1\n\nif flag == False:\n\tprint(\"NO\")"}, {"source_code": "def gcd(a,b):\n if(a==0):\n return b\n return gcd(b%a,a)\n\nn = int(input())\na = int(input())\nb = int(input())\ng = gcd(a,b)\nif(a>n or b>n):\n print(\"NO\")\nelif(n%g!=0):\n print(\"NO\")\nelse:\n if(n%a==0):\n print(\"YES\")\n print(n//a,0)\n elif(n%b==0):\n print(\"YES\")\n print(0,n//b)\n else:\n f=-1\n ans = 0\n while(n>1):\n n-=b\n ans+=1\n if(n%a==0):\n f=1\n print(\"YES\")\n print(n//a,ans)\n break\n if(f==-1):\n print(\"NO\")\n\n"}, {"source_code": "from heapq import heappush, heappop\ndef main():\n n = int(raw_input())\n a = int(raw_input())\n b = int(raw_input())\n sw = 0\n if a > b:\n a, b = b, a\n sw = 1\n if b > 10000:\n for i in xrange(10000):\n if (n - b * i) % a == 0:\n print \"YES\"\n x, y = (n - b * i) / a, i\n if sw:\n x, y = y, x\n print x, y\n break\n else:\n print \"NO\"\n return\n t = [1001001001] * b\n t[0] = 0\n x = y = 0\n for i in xrange(10000):\n x += a\n if x >= b:\n x -= b\n y += 1\n if t[x] < y:\n break\n t[x] = y\n x = t[n%b] * b + n % b\n if x > n:\n print \"NO\"\n else:\n print \"YES\"\n x, y = x / a, (n - x) / b\n if sw:\n x, y = y, x\n print x, y\nmain()\n"}, {"source_code": "# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\nfrom sys import stdin, stdout\nimport math\nimport heapq\nfrom itertools import accumulate\n\nN = int(input())\nA = int(input())\nB = int(input())\n#s = input() \n#N,K = [int(x) for x in stdin.readline().split()]\n\ndef GCD(x, y): \n \n while(y): \n x, y = y, x % y \n \n return x \n \ngcd = GCD(A,B)\n\nif N%gcd!=0:\n print('NO')\n quit()\n \nprint('YES')\nif A==1:\n print(N,0)\n quit()\n \nif B==1:\n print(0,N)\n quit()\n\nif A>=B:\n for i in range((N//A)+1):\n num = N-A*i\n if num%B==0:\n print(i,num//B)\n quit()\n \nelse:\n for i in range((N//B)+1):\n num = N-B*i\n if num%A==0:\n print(num//A,i)\n quit()\n "}, {"source_code": "from heapq import heappush, heappop\ndef main():\n n = int(raw_input())\n a = int(raw_input())\n b = int(raw_input())\n sw = 0\n if a > b:\n a, b = b, a\n sw = 1\n if b > 10000:\n for i in xrange(10000):\n if (n - b * i) % a == 0:\n print \"YES\"\n x, y = (n - b * i) / a, i\n if sw:\n x, y = y, x\n print x, y\n break\n else:\n print \"NO\"\n return\n t = [1001001001] * b\n t[0] = 0\n x = y = 0\n for i in xrange(10000):\n x += a\n if x >= b:\n x -= b\n y += 1\n if t[x] < y:\n break\n t[x] = y\n x = t[n%b] * b + n % b\n if x > n:\n print \"NO\"\n else:\n print \"YES\"\n x, y = x / a, (n - x) / b\n if sw:\n x, y = y, x\n print x, y\nmain()\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif a>=b:\n x=n//a\n for i in range(x+1):\n y=(n-i*a)//b\n if y==((n-i*a)/b):\n print(\"YES\")\n print(i,end=' ')\n print(y,end='')\n exit(0)\nelif a<b:\n y=n//a\n for i in range(y+1):\n x=(n-i*a)//b\n if x==((n-i*a)/b):\n print(\"YES\")\n print(x,end=' ')\n print(i,end='')\n exit(0)\nprint(\"NO\")\n "}, {"source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\nfla = False\nx,ya=0,0\nfor i in range(1000000):\n\tif n-a*i<0:\n\t\tfla = False\n\t\tbreak\n\ty = (n-(a*i))/b\n\tif int(y)==y and a*i + y*b==n: \n\t\tfla = True\n\t\tx = i\n\t\tya = y\n\t\tbreak\nif fla:\n\tprint \"YES\"\n\tprint x,ya\nelse:\n\tprint \"NO\""}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\tif((y == z and x % y != 0) or (z + y > x) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\nfrom sys import stdin, stdout\nimport math\nimport heapq\nfrom itertools import accumulate\n\nN = int(input())\nA = int(input())\nB = int(input())\n#s = input() \n#N,K = [int(x) for x in stdin.readline().split()]\n\ndef GCD(x, y): \n \n while(y): \n x, y = y, x % y \n \n return x \n \ngcd = GCD(A,B)\n\nif N%gcd!=0:\n print('NO')\n quit()\n \nprint('YES')\nif A==1:\n print(N,0)\n quit()\n \nif B==1:\n print(N,0)\n quit()\n\nif A>=B:\n for i in range(N//A+1):\n num = N-A*i\n if num%B==0:\n print(i,num//B)\n quit()\n \nelse:\n for i in range(N//B+1):\n num = N-B*i\n if num%A==0:\n print(num//A,i)\n quit()\n "}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\na = inp()\nb = inp()\nif n % gcd(a, b) == 0:\n\n y = 0\n x = 0\n while y * b <= n:\n if (n - b*y) % a == 0:\n if (n-b*y) > 0:\n x = (n - (b*y)) // a\n print(\"YES\")\n print(x, y)\n break\n y += 1\n else:\n print(\"NO\")\n\n\nelse:\n print(\"NO\")\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\na = inp()\nb = inp()\nif n % gcd(a, b) == 0:\n res = \"YES\"\n y = 0\n x = 0\n while y * b <= n:\n if (n - b*y) % a == 0:\n x = (n - b*y) // a\n if x < 0 or y < 0:\n res = \"NO\"\n else:\n res = \"YES\"\n break\n\n y += 1\n print(res)\n if res == \"YES\":\n print(x, y)\n\n\nelse:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif(n//a<n//b):\n k=a\n m=b\nelse:\n k=b\n m=a\nflag=0\nfor i in range(0,n//k):\n if((n-i*k)%m==0):\n flag=1\n print('YES')\n if(k==a):\n print (i,end=\" \")\n print ((n-i*k)//m)\n elif(k==b):\n print ((n-i*k)//m,end=\" \")\n print(i)\n break\nif(flag==0):\n print (\"NO\")"}, {"source_code": "x = int(input()) #monies\ny = int(input()) #cost of cola\nz = int(input()) #cost of bar\ncola = 0\nbar = 0\ntoolong=2+(x%1000)+(y*z)\nfor i in range(x):\n\tif((y==z and x % y != 0) or (x < y) or (x < z) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tbreak\n\tif(y>=z):\n\t\tif(x%z==0):\n\t\t\t bar = x // z \n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%z != 0 and x >= y and toolong > 0):\n\t\t\tx -= y\n\t\t\tcola += 1\n\t\t\ttoolong -= y\n\tif(z>y):\n\t\tif(x%y==0):\n\t\t\t cola = x // y\n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%y != 0 and x >= z and toolong > 0):\n\t\t\tx -= z\n\t\t\tbar += 1\n\t\t\ttoolong -= y"}, {"source_code": "def gcd(a,b):\n if(a==0):\n return b\n return gcd(b%a,a)\n\nn = int(input())\na = int(input())\nb = int(input())\ng = gcd(a,b)\nif(a>n or b>n):\n print(\"NO\")\nelif(n%g!=0):\n print(\"NO\")\nelse:\n if(n%a==0):\n print(\"YES\")\n print(n//a,0)\n elif(n%b==0):\n print(\"YES\")\n print(0,n//b)\n else:\n f=-1\n ans = 0\n while(n>1):\n n-=b\n ans+=1\n if(n%a==0):\n f=1\n print(\"YES\")\n print(n//a,ans)\n break\n if(f==-1):\n print(\"NO\")\n\n"}, {"source_code": "n = input()\na = input()\nb = input()\nif a > b:\n\tfor i in xrange(min(b, n / a + 1)):\n\t\tif (n - i * a) % b == 0:\n\t\t\tprint 'Yes\\n', i, (n - i * a) / b\n\t\t\tbreak\n\telse:\n\t\tprint 'No'\nelse:\n\tfor i in xrange(min(a, n / b + 1)):\n\t\tif (n - i * b) % a == 0:\n\t\t\tprint 'Yes\\n', i, (n - i * b) / a\n\t\t\tbreak\n\telse:\n\t\tprint 'No'\n"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\n\ndef gcd(a, b):\n if a * b == 0:\n return a + b\n return gcd(b, a % b)\n\nd = gcd(a, b)\nif n % d != 0:\n print(\"NO\")\nelse:\n n, a, b = n//d, a//d, b//d\n if a >= b:\n for x in range(b):\n if (n - a * x) % b == 0:\n print(\"YES\")\n print(x, (n - a * x) // b)\n break\n else:\n print(\"NO\")\n else:\n for y in range(a):\n if (n - b * y) % a == 0:\n print(\"YES\")\n print((n - b * y) // a, y)\n break\n else:\n print(\"NO\")"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nx = 0\nwhile True:\n y = (n-x*a)/b\n if y < 0:\n print('No')\n break\n if int(y) == y:\n print(\"YES\")\n print(x,int(y))\n break\n else:\n x += 1"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\ns=0\nif a>b:\n c=n//a\n for i in range(0,c+1):\n d=n-a*i\n e=d//b\n f=d%b\n if f==0:\n B=e\n A=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\nelif a<b:\n c=n//b\n for i in range(0,c+1):\n d=n-b*i\n e=d//a\n f=d%a\n if f==0:\n A=e\n B=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\nelse:\n if n%a==0:\n print('YES')\n print(int(n/a),end=' ')\n print(int(n/a))\n else:\n print('NO')\n\n"}, {"source_code": "n = input()\na = input()\nb = input()\nif a > b:\n\tfor i in xrange(min(b, n / a + 1)):\n\t\tif (n - i * a) % b == 0:\n\t\t\tprint 'Yes', i, (n - i * a) / b\n\t\t\tbreak\n\telse:\n\t\tprint 'No'\nelse:\n\tfor i in xrange(min(a, n / b + 1)):\n\t\tif (n - i * b) % a == 0:\n\t\t\tprint 'Yes', i, (n - i * b) / a\n\t\t\tbreak\n\telse:\n\t\tprint 'No'\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Dec 16 14:43:34 2017\n\n@author: ms\n\"\"\"\n\ndef main():\n n = int(input())\n a = int(input())\n b = int(input())\n \n if(n%a == 0):\n print('YES')\n print(int(n/a), 0)\n return\n if(n%b == 0):\n print('YES')\n print(0, int(n/b))\n return\n \n if(a%2 == 0 and b%2 == 0):\n if (n%2 != 1):\n print('NO')\n return\n \n mx = max(a,b)\n mn = min(a,b)\n new = 0\n found = 0\n i = 0\n while(n>=0):\n n -= mx\n i += 1\n if(n%mn == 0):\n found = 1\n new = n\n break\n if found:\n print('YES')\n if (mx == a):\n print(i, int(new/b))\n if (mx == b):\n print(int(new/a), i)\n else:\n print('NO')\n \nmain()"}, {"source_code": "import sys, re\n\nn = int(sys.stdin.readline())\na = int(sys.stdin.readline())\nb = int(sys.stdin.readline())\nif a == b:\n if n % a == 0:\n print('YES')\n print(1, n // (a) - 1)\n else:\n print('NO')\nelse:\n if n % a == 0:\n print('YES')\n print(n // a, 0)\n elif n % b == 0:\n print('YES')\n print(0, n // b)\n else:\n if n % abs(a - b) != 0:\n print('NO')\n else:\n for i in range(n // a + 1):\n for j in range(n // b + 1):\n if a * i + b * j == n:\n print('YES')\n print(i, j)\n sys.exit(0)\n"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\tif((y == z and x % y != 0) or (z + y > x) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = int(stdin.readline())\nb = int(stdin.readline())\nk = n/a\nans = 'No'\nfor i in xrange(k+1):\n if (n - i*a)%b==0:\n print 'Yes'\n ans = \"%d %d\"%(i,(n-a*i)/b)\n break\nprint ans"}, {"source_code": "import sys, re\n\nn = int(sys.stdin.readline())\na = int(sys.stdin.readline())\nb = int(sys.stdin.readline())\nif a == b:\n if n % a == 0:\n print('YES')\n print(1, n // (a) - 1)\n else:\n print('NO')\nelse:\n if n % a == 0:\n print('YES')\n print(n // a, 0)\n elif n % b == 0:\n print('YES')\n print(0, n // b)\n else:\n for i in range(n // a + 1):\n for j in range(n // b + 1):\n if a * i + b * j == n:\n print('YES')\n print(i, j)\n sys.exit(0)\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nflag=0\nif(n%a==0 or n%b==0):\n flag=1\n print('YES')\n if n%a==0:\n print(str(int(n/a))+' 0')\n else:\n print('0 '+str(int(n/b)))\nelse:\n i=1\n while a*i<=n and b*i<=n:\n p=n-a*i\n q=n-b*i\n if(p%b==0 or q%a==0):\n flag=1\n print('yes')\n if p%b==0:\n print(str(int(i)+' '+str(int(p/b))))\n else:\n print(str(int(q/a))+' '+str(int(i)))\n break\n i=i+1\nif flag==0:\n print('NO')"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\n\nbigger = max(a,b)\nsmaller = min(a,b)\n\nif (a==b) and (n%a != 0):\n\tprint('NO')\n\texit()\n\nfor i in range(n//bigger+1):\n\tif (n-bigger*i)%smaller==0:\n\t\tprint('YES')\n\t\tx=i\n\t\ty=(n-bigger*i)//smaller\n\t\tprint(x,y)\n\t\texit()\nprint('NO')\nquit()"}, {"source_code": "from heapq import heappush, heappop\ndef main():\n n = int(raw_input())\n a = int(raw_input())\n b = int(raw_input())\n sw = 0\n if a > b:\n a, b = b, a\n sw = 1\n if b > 10000:\n for i in xrange(10000):\n if (n - b * i) % a == 0:\n print \"YES\"\n break\n else:\n print \"NO\"\n return\n t = [1000100] * b\n t[0] = 0\n x = y = 0\n for i in xrange(10000):\n x += a\n if x >= b:\n x -= b\n y += 1\n if t[x] < y:\n break\n t[x] = y\n x = t[n%b] * b + n % b\n if x > n:\n print \"NO\"\n else:\n print \"YES\"\n x, y = x / a, (n - x) / b\n if sw:\n x, y = y, x\n print x, y\nmain()\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\na = inp()\nb = inp()\nif n % gcd(a, b) == 0:\n print(\"YES\")\n c1 = (n // a) + 2\n c2 = (n // b) + 2\n for y in range(c2):\n if (n - b*y) % a == 0:\n x = (n - b*y) // a\n print(x, y)\n break\n\n\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nx = y = 0\nflag = False\n\nif a == b and n % a == 0:\n\tprint(\"YES\")\n\tprint(n//a, 0)\nelse:\n\twhile a*x <= n:\n\t\tif (n - a*x) % b == 0:\n\t\t\tprint(\"YES\")\n\t\t\tprint(x, (n - a*x)//b)\n\t\t\tflag = True\n\t\t\tbreak\n\t\telse:\n\t\t\tx += 1\n\nif flag == False:\n\tprint(\"NO\")"}, {"source_code": "from math import sqrt\nn = int(input())\na = int(input())\nb = int(input())\nfor i in range(n // 2):\n if (n - (i * b)) % a == 0:\n print(\"YES\")\n print((n - i * b) // a, i)\n exit()\nprint(\"NO\")"}, {"source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\n\nfrom fractions import gcd\nc = gcd(a,b)\na /= c\nb /= c\n\nif n % c != 0:\n print 'NO'\nelse:\n print 'YES'\n n /= c\n a_inv = -1\n\n def euclid(a, b):\n if a == 0:\n return (0, 1, b)\n (x, y, res) = euclid(b%a, a)\n return (y - (b/a) * x, x, res)\n (a_inv, y, res) = euclid(a, b)\n\n x = a_inv * n % b\n for x in xrange(x,n,b):\n by = (n - a*x)\n if by >= 0 and by % b == 0:\n print '{} {}'.format(x, by/b)\n exit()\n"}, {"source_code": "x = int(input()) #monies\ny = int(input()) #cost of cola\nz = int(input()) #cost of bar\ncola = 0\nbar = 0\ntoolong=2+(x%1000)+(y*z)\nprint(toolong)\nfor i in range(x):\n\tif((y==z and x % y != 0) or (x < y) or (x < z) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tbreak\n\tif(y>z):\n\t\tif(x%z==0):\n\t\t\t bar = x // z \n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%z != 0 and x >= y and toolong > 0):\n\t\t\tx -= y\n\t\t\tcola += 1\n\t\t\ttoolong -= y\n\tif(z>y):\n\t\tif(x%y==0):\n\t\t\t cola = x // y\n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%y != 0 and x >= z and toolong > 0):\n\t\t\tx -= z\n\t\t\tbar += 1\n\t\t\ttoolong -= y"}, {"source_code": "from sys import stdin, stdout\n\n\nn = int(stdin.readline())\na = int(stdin.readline())\nb = int(stdin.readline())\nx = 0\nflg = False\nwhile not n % a == 0 and n >= 0:\n if n % b == 0:\n print(\"YES\")\n print(x, int(n / b))\n flg = True\n break\n n = n - a\n x += 1\nif not flg:\n print(\"NO\")\n"}, {"source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\n\nif n < a and n < b:\n print 'NO'\n exit()\n\nfrom fractions import gcd\nc = gcd(a,b)\na /= c\nb /= c\n\nif n % c != 0:\n print 'NO'\nelse:\n n /= c\n a_inv = -1\n\n def euclid(a, b):\n if a == 0:\n return (0, 1, b)\n (x, y, res) = euclid(b%a, a)\n return (y - (b/a) * x, x, res)\n (a_inv, y, res) = euclid(a, b)\n\n x = a_inv * n % b\n for x in xrange(x,n,b):\n by = (n - a*x)\n if by >= 0 and by % b == 0:\n print 'YES'\n print '{} {}'.format(x, by/b)\n exit()\n print 'NO'\n"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\telif((y == z and x % y != 0) or (z + y > x) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=2+(x%1000)+(y*11)+(z*11)\nprint(toolong)\nfor i in range(x):\n\tif((y == z and x % y != 0) or (x <= 0) or (toolong <= 0) or ((x<z) and (x<y))):\n\t\tprint(\"NO\")\n\t\tquit()\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\telif(y>z or (x>y and z>x)):\n\t\twhile(x%z != 0 and toolong > 0 and x > 0):\n\t\t\tx -= y\n\t\t\tcola += 1\n\t\t\ttoolong -= y\n\telif(z>y or (x>z and y>x)):\n\t\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\t\tx -= z\n\t\t\tbar += 1\n\t\t\ttoolong -= y\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "def gcd(a,b):\n if(a==0):\n return b\n return gcd(b%a,a)\n\nn = int(input())\na = int(input())\nb = int(input())\ng = gcd(a,b)\nif(a+b>n):\n print(\"NO\")\nelif(n%g!=0):\n print(\"NO\")\nelse:\n if(n%a==0):\n print(\"YES\")\n print(n//a,0)\n elif(n%b==0):\n print(\"YES\")\n print(0,n//b)\n else:\n f=-1\n ans = 0\n while(n>1):\n n-=b\n ans+=1\n if(n%a==0):\n f=1\n print(\"YES\")\n print(n//a,ans)\n break\n if(f==-1):\n print(\"NO\")\n\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\na = inp()\nb = inp()\nif n % gcd(a, b) == 0:\n\n y = 0\n x = 0\n while y * b <= n:\n if (n - b*y) % a == 0:\n if (n-b*y) > 0:\n x = (n - (b*y)) // a\n print(\"YES\")\n print(x, y)\n break\n y += 1\n else:\n print(\"NO\")\n\n\nelse:\n print(\"NO\")\n"}, {"source_code": "n,x,y=int(input()),int(input()),int(input())\nf=0\nfor i in range(n//x+1):\n s=n-i*x\n if(s%y==0):\n f=1\n break\nif(f==0):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nx=True\nif a>b:\n for i in range(0,n//a+1):\n if (n-i*a)%b==0:\n print(\"YES\")\n x=False\n print(i,\"\",(n-i*a)//b)\n break\nelse:\n for i in range(0,n//b+1):\n if (n-i*b)%a==0:\n print(\"YES\")\n x=False\n print((n-i*b)%a,\"\",i)\n break\nif x:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif a==b and n%a!=0:\n print('NO')\nelif n%a==0:\n print('YES')\n print(n//a,end=' ')\n print(0)\nelif n%b==0:\n print('YES')\n print('0',end=' ')\n print(n//b)\n\nelif n%2==1 and a%2==0 and b%2==0:\n print('NO')\nelif max(a,b)%min(a,b)==0 and n%a!=0 and n%b!=0:\n print('NO')\nelif a+b>n:\n print('NO')\nelse:\n i=0\n \n if a>b:\n while i<n//a and (n-a*i)%b!=0:\n i=i+1\n if i>n//a:\n print('NO')\n else:\n print('YES')\n print(i,end=' ')\n print((n-a*i)//b)\n else:\n while i<n//b and (n-b*i)%a!=0:\n i=i+1\n if i>n//b:\n print('NO')\n else:\n print('YES')\n print((n-b*i)//a,end=' ')\n print(i)\n"}, {"source_code": "import re\nimport sys\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom itertools import (\n accumulate, combinations, combinations_with_replacement, groupby,\n permutations, product)\nfrom math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,\n log2, pi, radians, sin, sqrt, tan)\nfrom operator import itemgetter, mul\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\n\ndef inp():\n return(int(input()))\n\n\ndef inlist():\n return(list(map(int, input().split())))\n\n\ndef instr():\n s = input()\n return(list(s[:len(s)]))\n\n\ndef invr():\n return(map(int, input().split()))\n\n\nn = inp()\na = inp()\nb = inp()\nif n % gcd(a, b) == 0:\n res = \"YES\"\n y = 0\n x = 0\n while y * b <= n:\n if (n - b*y) % a == 0:\n x = (n - b*y) // a\n if x < 0 or y < 0:\n res = \"NO\"\n else:\n res = \"YES\"\n break\n\n y += 1\n print(res)\n if res == \"YES\":\n print(x, y)\n\n\nelse:\n print(\"NO\")\n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\na = int(stdin.readline())\nb = int(stdin.readline())\nif a < b:\n x = a; a = b; b = x\nk = n/a\nans = 'NO'\nfor i in xrange(k+1):\n if (n - i*a)%b==0:\n print 'YES'\n ans = \"%d %d\"%(i,(n-a*i)/b)\n break\nprint ans"}, {"source_code": "from math import gcd,ceil\nn=int(input())\na=int(input())\nb=int(input())\ng=gcd(a,b)\nif n%g!=0:\n print('NO')\n exit()\ndef gcdex(a, b):\n if b == 0:\n return a, 1, 0\n else:\n d, x, y = gcdex(b, a % b)\n return d, y, x - y * (a // b)\nk,xg,yg=gcdex(a,b)\n#print(k,xg,yg)\nx,y=xg*(n//g),yg*(n//g)\ndelx=b//g\ndely=a//g\ndef printing(x,y,dx,dy):\n ko=ceil((-x)/dx)\n x+=ko*dx\n y-=ko*dy\n if y<0:\n print('NO')\n else:\n print('YES')\n if dx==delx:\n print(x,y)\n else:\n print(y,x)\nif x<0 and y<0:\n print('NO')\nelif x>=0 and y>=0:\n print('Yes')\n print(x,y)\nelif x<0:\n printing(x,y,delx,dely)\nelif y<0:\n printing(y,x,dely,delx)\n"}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n \nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s): # Palindrome\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way\n\n\ndef main():\n\tn = ii()\n\ta = ii()\n\tb = ii()\n\tif n % math.gcd(a,b) != 0:\n\t\tprint('NO')\n\t\texit()\n\t\n\tfor i in range(100000):\n\t\tif (n-b*i)%a == 0:\n\t\t\tif (n-b*i)//a >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\tprint((n-b*i)//a, i)\n\t\t\t\tbreak\n\telse:\n\t\tprint('NO')\n\t\nmain()\n\t"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif(n//a<n//b):\n k=a\n m=b\nelse:\n k=b\n m=a\nflag=0\nfor i in range(0,n//k):\n if((n-i*k)%m==0):\n flag=1\n print('Yes')\n if(k==a):\n print (i,end=\" \")\n print ((n-i*k)//m)\n elif(k==b):\n print ((n-i*k)//m,end=\" \")\n print(i)\n break\nif(flag==0):\n print (\"No\")"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\ns=0\nif a>b:\n c=n//a\n for i in range(0,c+1):\n d=n-a*i\n e=d//b\n f=d%b\n if f==0:\n B=e\n A=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\nelif a<b:\n c=n//b\n for i in range(0,c+1):\n d=n-b*i\n e=d//a\n f=d%a\n if f==0:\n A=e\n B=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\nelse:\n if n%a==0:\n print('YES')\n print(int(n/a),end=' ')\n print(int(n/a))\n else:\n print('NO')\n\n"}, {"source_code": "import math\ndef ixgcd(a, b):\n \"\"\" gcd(a, b) = a * x + b * y \n the extended euclidean gcd algo, iteration \"\"\"\n x0, x1, y0, y1 = 1, 0, 0, 1\n while b:\n q, a, b = a // b, b, a % b\n x0, x1 = x1, x0 - q * x1\n y0, y1 = y1, y0 - q * y1\n return a, x0, y0\n\nc = int(input())\na = int(input())\nb = int(input())\nd, x0, y0 = ixgcd(a,b)\n# print(d, x0, y0)\nif c%d == 0 and min(a,b)<=c:\n x0 *= c//d\n y0 *= c//d\n # print(x0,y0)\n if x0 >= 0 and y0 >= 0:\n print(\"YES\")\n print(x0, y0)\n\n elif x0 < 0 and y0 < 0:\n print(\"NO\")\n else:\n if x0 < 0:\n k = (d*x0)/b\n # x1 = (x0 - k * b//d)\n elif y0 < 0:\n k = (-1*d*y0)/a\n # print(\"test\")\n # y1 = (y0 + k * a//d)\n # print(\"before {}\".format(k))\n if k < 0:\n k = math.floor(k)\n # print(k)\n elif k > 0:\n k = math.ceil(k)\n # print(k)\n x1 = x0 - (k*b)//d\n y1 = y0 + (k*a)//d\n print(\"YES\")\n print(x1, y1)\nelse:\n print(\"NO\")"}, {"source_code": "n=input()\na=input()\nb=input()\nfrom fractions import gcd \nif n%gcd(a,b)!=0:\n print \"NO\"\nelse:\n \n g=gcd(a,b)\n n=n/g \n a=a/g \n b=b/g\n for i in range(0,n+1):\n if (n-a*i)%b==0:\n print \"YES\"\n print i,(n-a*i)/b \n break\n print \"NO\""}, {"source_code": "def solution (a, b, n):\n\n # traverse for all possible values\n i = 0\n _atual = i * a\n while _atual <= n:\n _atual = i * a\n\n # check if it is satisfying\n # the equation\n _res = n - (_atual)\n if _res % b == 0:\n print \"YES\"\n print i, int(_res / b)\n return 0\n i = i + 1\n print \"NO\"\n\n\n\nn = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\nsolution(a,b,n)\n"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\twhile(x%y != 0 and toolong > 0 and (x > 0 or x > y)):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\telse:\n\t\tprint(\"NO\")\n\t\tquit()\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\telif((y == z and x % y != 0) or (z + y > x) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "from fractions import gcd\n\nn = int(input())\na = int(input())\nb = int(input())\n\np = gcd(a,b)\n\nif n % p == 0:\n\ta1 = n//a\n\tb1 = n//b\n\tif n%a == 0 or n%b == 0:\n\t\tprint(\"YES\")\n\t\tif n%a == 0:\n\t\t\tprint(a1, 0)\n\t\telse:\n\t\t\tprint(0, b1)\n\telse:\n\t\tb1 = 0\n\t\twhile (a1*a) + (b1 * b) != n:\n\t\t\ta1-=1\n\t\t\tv = n - (a1 * a)\n\t\t\tb1 = v//b\n\t\tprint(\"YES\")\t\n\t\tprint(a1, b1)\t\nelse:\n\tprint(\"NO\")\n\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\n\nbigger = max(a,b)\nsmaller = min(a,b)\n\nif (a==b) and (n%a != 0):\n\tprint('NO')\n\texit()\n\nfor i in range(n//bigger+1):\n\tif (n-bigger*i)%smaller==0:\n\t\tprint('YES')\n\t\tBer_Cola=i\n\t\tBars_bar=(n-bigger*i)//smaller\n\t\tprint(Bars_bar, Ber_Cola)\n\t\texit()\nprint('NO')"}, {"source_code": "n=input()\na=input()\nb=input()\nfrom fractions import gcd \nif n%gcd(a,b)!=0:\n print \"NO\"\nelse:\n print \"YES\"\n g=gcd(a,b)\n n=n/g \n a=a/g \n b=b/g\n for i in range(0,n+1):\n if (n-a*i)%b==0:\n print i,(n-a*i)/b \n break "}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n \nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s): # Palindrome\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way\n\n\ndef main():\n\tn = ii()\n\ta = ii()\n\tb = ii()\n\tif n % math.gcd(a,b) != 0:\n\t\tprint('NO')\n\t\n\tfor i in range(100000):\n\t\tif (n-b*i)%a == 0:\n\t\t\tprint('YES')\n\t\t\tprint((n-b*i)//a, i)\n\t\t\texit()\n\t\nmain()\n\t"}, {"source_code": "x = int(input()) #monies\ny = int(input()) #cost of cola\nz = int(input()) #cost of bar\ncola = 0\nbar = 0\ntoolong=2+(x%1000)+(y*z)\nprint(toolong)\nfor i in range(x):\n\tif((y==z and x % y != 0) or (x < y) or (x < z) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tbreak\n\tif(y>z):\n\t\tif(x%z==0):\n\t\t\t bar = x // z \n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%z != 0 and x >= y and toolong > 0):\n\t\t\tx -= y\n\t\t\tcola += 1\n\t\t\ttoolong -= y\n\tif(z>y):\n\t\tif(x%y==0):\n\t\t\t cola = x // y\n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%y != 0 and x >= z and toolong > 0):\n\t\t\tx -= z\n\t\t\tbar += 1\n\t\t\ttoolong -= y"}, {"source_code": "import time\nfrom fractions import gcd\n\nn, a, b = int(input()), int(input()), int(input())\nt = time.time()\n\nif n%a == 0:\n\tprint('YES')\n\tprint('{} {}'.format(int(n/a),0))\n\texit()\n\n\nif n%b == 0:\n\tprint('YES')\n\tprint('{} {}'.format(0,int(n/b)))\n\texit()\n\n \nif n%gcd(a,b) != 0:\n\tprint(\"NO\");\n\texit()\n\ni = 1\nwhile (n-a*i) >= 0 or (n-b*i) >= 0:\n\tif (n-a*i)%b == 0:\n\t\ty = (n-a*i)//b\n\t\tprint('YES')\n\t\tprint('{} {}'.format(i,y))\n\t\texit()\n\n\tif (n-b*i)%a == 0:\n\t\tx = (n-b*i)//a\n\t\tprint('YES')\n\t\tprint('{} {}'.format(x,i))\n\t\texit()\n\ti+=1\nprint(\"NO\");\n# print(t-time.time())"}, {"source_code": "def gcd(a,b):\n if(a==0):\n return b\n return gcd(b%a,a)\n\nn = int(input())\na = int(input())\nb = int(input())\ng = gcd(a,b)\nif(n%g!=0):\n print(\"NO\")\nelse:\n if(n%a==0):\n print(\"YES\")\n print(n//a,0)\n elif(n%b==0):\n print(\"YES\")\n print(0,n//b)\n else:\n f=-1\n ans = 0\n while(n>1):\n n-=b\n ans+=1\n if(n%a==0):\n f=1\n print(\"YES\")\n print(n//a,ans)\n break\n if(f==-1):\n print(\"NO\")\n\n"}, {"source_code": "def getHCF(a, b):\n c = min(a, b)\n d = max(a, b)\n\n if (d%c == 0):\n return c\n \n return getHCF(d%c, c)\n\nn = int(input())\na = int(input())\nb = int(input())\n\nhcfAB = getHCF(a, b)\n\nprinted = False\n\nif (n%hcfAB != 0):\n pass\n\nelse:\n n /= hcfAB\n a /= hcfAB\n b /= hcfAB\n\n for y in range(int(n/b)):\n if ((n - b*y)%a == 0):\n print(\"YES\")\n print(int((n - b*y)/a), ' ', int(y))\n printed = True\n break\n\nif (not(printed)):\n print(\"NO\")"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif((x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif a==b and n%a!=0:\n print('NO')\nelif n%a==0:\n print('YES')\n print(n//a,end=' ')\n print(0)\nelif n%b==0:\n print('YES')\n print('0',end=' ')\n print(n//b)\n\nelif n%2==1 and a%2==0 and b%2==0:\n print('NO')\nelif max(a,b)%min(a,b)==0 and n%a!=0 and n%b!=0:\n print('NO')\nelif a+b>n:\n print('NO')\nelse:\n i=0\n \n if a>b:\n while i<n//a and (n-a*i)%b!=0:\n i=i+1\n if i>n//a:\n print('NO')\n else:\n print('YES')\n print(i,end=' ')\n print((n-a*i)//b)\n else:\n while i<n//b and (n-b*i)%a!=0:\n i=i+1\n if i>n//b:\n print('NO')\n else:\n print('YES')\n print((n-b*i)//a,end=' ')\n print(i)\n"}, {"source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\n\nif n < a and n < b:\n print 'NO'\n exit()\n\nfrom fractions import gcd\nc = gcd(a,b)\na /= c\nb /= c\n\nif n % c != 0:\n print 'NO'\nelse:\n n /= c\n a_inv = -1\n\n def euclid(a, b):\n if a == 0:\n return (0, 1, b)\n (x, y, res) = euclid(b%a, a)\n return (y - (b/a) * x, x, res)\n (a_inv, y, res) = euclid(a, b)\n\n x = a_inv * n % b\n for x in xrange(x,n,b):\n by = (n - a*x)\n if by >= 0 and by % b == 0:\n print 'YES'\n print '{} {}'.format(x, by/b)\n exit()\n print 'NO'\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif(n//a<n//b):\n k=a\n m=b\nelse:\n k=b\n m=a\nflag=0\nfor i in range(0,n//k):\n if((n-i*k)%m==0):\n flag=1\n print('Yes')\n if(k==a):\n print (i,end=\" \")\n print ((n-i*k)//m)\n elif(k==b):\n print ((n-i*k)//m,end=\" \")\n print(i)\n break\nif(flag==0):\n print (\"No\")"}, {"source_code": "import math\n\n\ndef solve():\n n = int(input())\n a = int(input())\n b = int(input())\n if n % 2 != 0 and a % 2 == 0 and b % 2 == 0:\n print(\"NO\")\n return\n\n else:\n for x in range(n):\n k = n - a * x\n if k >= 0 and k % b == 0:\n print(\"YES\")\n print(x, k // b)\n return\n if k < 0:\n print(\"NO\")\n return\n\n print(\"NO\")\n return\n\n\n#t = int(input())\nfor _ in range(1):\n solve()\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif a==b and n%a!=0:\n print('NO')\nif n%a==0:\n print('YES')\n print(n//a,end=' ')\n print(0)\nelif n%b==0:\n print('YES')\n print('0',end=' ')\n print(n//b)\n\nelif n%2==1 and a%2==0 and b%2==0:\n print('NO')\nelif max(a,b)%min(a,b)==0 and n%a!=0 and n%b!=0:\n print('NO')\nelif a+b>n:\n print('NO')\nelse:\n i=0\n \n if a>b:\n while (n-a*i)%b!=0:\n i=i+1\n if i>n//a:\n print('NO')\n else:\n print('YES')\n print(i,end=' ')\n print((n-a*i)//b)\n else:\n while (n-b*i)%a!=0:\n i=i+1\n if i>n//b:\n print('NO')\n else:\n print('YES')\n print((n-b*i)//a,end=' ')\n print(i)\n "}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n \nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s): # Palindrome\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way\n\n\ndef main():\n\tn = ii()\n\ta = ii()\n\tb = ii()\n\tif n % math.gcd(a,b) != 0:\n\t\tprint('NO')\n\t\texit()\n\t\n\t#for i in range(n//2+1):\n#\t\tif (n-b*i)%a == 0:\n#\t\t\tif (n-b*i)//a >= 0:\n#\t\t\t\tprint('YES')\n#\t\t\t\tprint((n-b*i)//a, i)\n#\t\t\t\tbreak\n#\telse:\n#\t\tprint('NO')\n\n\tfor i in range(n//a):\n\t\tif ((n-b*i)%a == 0) or ((n-a*i)%b == 0):\n\t\t\tif (n-b*i)//a >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\tprint((n-b*i)//a,i)\n\t\t\t\tbreak\n\t\t\telif (n-a*i)//b >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\tprint(i, (n-a*i)//b)\n\t\t\t\tbreak\n\telse:\n\t\tprint('NO')\n\t\t\n\t\nmain()\n\t"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif((x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}, {"source_code": "from math import sqrt\nn = int(input())\na = int(input())\nb = int(input())\nfor i in range(n // 2):\n if (n - (i * b)) % a == 0:\n print(\"YES\")\n print((n - i * b) // a, i)\n exit()\nprint(\"NO\")"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif a==b and n%a!=0:\n print('NO')\nif n%a==0:\n print('YES')\n print(n//a,end=' ')\n print(0)\nelif n%b==0:\n print('YES')\n print('0',end=' ')\n print(n//b)\n\nelif n%2==1 and a%2==0 and b%2==0:\n print('NO')\nelif max(a,b)%min(a,b)==0 and n%a!=0 and n%b!=0:\n print('NO')\nelif a+b>n:\n print('NO')\nelse:\n i=0\n \n if a>b:\n while (n-a*i)%b!=0:\n i=i+1\n if i>n//a:\n print('NO')\n else:\n print('YES')\n print(i,end=' ')\n print((n-a*i)//b)\n else:\n while (n-b*i)%a!=0:\n i=i+1\n if i>n//b:\n print('NO')\n else:\n print('YES')\n print((n-b*i)//a,end=' ')\n print(i)\n "}, {"source_code": "x = int(input()) #monies\ny = int(input()) #cost of cola\nz = int(input()) #cost of bar\ncola = 0\nbar = 0\ntoolong=2+(x%1000)+(y*z)\nfor i in range(x):\n\tif((y==z and x % y != 0) or (x <= 0) or (toolong <= 0) or ((x<z) and (x<y))):\n\t\tprint(\"NO\")\n\t\tbreak\n\tif(y>=z):\n\t\tif(x%z==0):\n\t\t\t bar = x // z \n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%z != 0 and toolong > 0 and x > 0):\n\t\t\tx -= y\n\t\t\tcola += 1\n\t\t\ttoolong -= y\n\tif(z>y):\n\t\tif(x%y==0):\n\t\t\t cola = x // y\n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\t\tx -= z\n\t\t\tbar += 1\n\t\t\ttoolong -= y"}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n \nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s): # Palindrome\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way\n\n\ndef main():\n\tn = ii()\n\ta = ii()\n\tb = ii()\n\tif n % math.gcd(a,b) != 0:\n\t\tprint('NO')\n\t\texit()\n\t\n\t#for i in range(n//2+1):\n#\t\tif (n-b*i)%a == 0:\n#\t\t\tif (n-b*i)//a >= 0:\n#\t\t\t\tprint('YES')\n#\t\t\t\tprint((n-b*i)//a, i)\n#\t\t\t\tbreak\n#\telse:\n#\t\tprint('NO')\n\n\tfor i in range(n//a):\n\t\tif ((n-b*i)%a == 0):\n\t\t\tif (n-b*i)//a >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\tprint((n-b*i)//a,i)\n\t\t\t\tbreak\n\telse:\n\t\tprint('NO')\n\t\t\n\t\nmain()\n\t"}, {"source_code": "n = int(input())\na = int(input())\nb = int(input())\nx = 0\nwhile True:\n y = (n-x*a)/b\n if y < 0:\n print('No')\n break\n if int(y) == y:\n print(\"YES\")\n print(x,int(y))\n break\n else:\n x += 1"}, {"source_code": "\nn=int(input())\na=int(input())\nb=int(input())\nif(n%a==0 or n%b==0):\n print('YES')\n if n%a==0:\n print(str(int(n/a))+' 0')\n else:\n print('0 '+str(int(n/b)))\nelse:\n p=n%(a+b)\n if p==0:\n print('YES')\n print(str(int(n/a+b))+' '+str(int(n/a+b)))\n else:\n p=int(n/(a+b))\n n=n%(a+b)\n if(n%a==0 or n%b==0):\n print('YES')\n if n%a==0:\n print(str(int((n/a)+p))+' '+str(p))\n else:\n print(str(p)+' '+str(int((n/b)+p)))\n else:\n print('NO')\n\n"}, {"source_code": "def gcd(a,b):\n if(a==0):\n return b\n return gcd(b%a,a)\n\nn = int(input())\na = int(input())\nb = int(input())\ng = gcd(a,b)\nif(n%g!=0):\n print(\"NO\")\nelse:\n print(\"YES\")\n if(n%(2*a)==0):\n print(n//a,0)\n elif(n%(2*b)==0):\n print(0,n//b)\n else:\n ans = 0\n while(n>1):\n n-=b\n ans+=1\n if(n%a==0):\n print(n//a,ans)\n break\n\n\n"}, {"source_code": "from heapq import heappush, heappop\ndef main():\n n = int(raw_input())\n a = int(raw_input())\n b = int(raw_input())\n sw = 0\n if a > b:\n a, b = b, a\n sw = 1\n if b > 10000:\n for i in xrange(10000):\n if (n - b * i) % a == 0:\n print \"YES\"\n break\n else:\n print \"NO\"\n return\n t = [1000100] * b\n t[0] = 0\n x = y = 0\n for i in xrange(10000):\n x += a\n if x >= b:\n x -= b\n y += 1\n if t[x] < y:\n break\n t[x] = y\n x = t[n%b] * b + n % b\n if x > n:\n print \"NO\"\n else:\n print \"YES\"\n x, y = x / a, (n - x) / b\n if sw:\n x, y = y, x\n print x, y\nmain()\n"}, {"source_code": "'''\nINPUT SHORTCUTS\nN, K = map(int,input().split())\nN ,A,B = map(int,input().split())\nstring = str(input())\narr = list(map(int,input().split()))\nN = int(input())\n'''\n\n\n\ndef main():\n\tN = int(input())\n\ta = int(input())\n\tb = int(input())\n\tfor i in range(0,N//a):\n\t\tfor j in range(0,N//b):\n\t\t\tif i*a + b*j ==N:\n\t\t\t\tprint(\"YES\")\n\t\t\t\tprint(i,j)\n\t\t\t\treturn\n\tprint(\"NO\")\n\nmain()"}, {"source_code": "def bezout(a, b):\n x, xx, y, yy = 1, 0, 0, 1\n while b:\n q = a // b\n a, b = b, a % b\n x, xx = xx, x - xx*q\n y, yy = yy, y - yy*q\n return (x, y, a)\n\n\nn = int(input())\na = int(input())\nb = int(input())\nx, y, c = bezout(a, b)\nif n % c != 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n x = x * n // c\n y = y * n // c\n while x < 0:\n x += b // c\n y -= a // c\n while y < 0:\n y += a // c\n x -= b // c\n print(x, y)"}, {"source_code": "import sys, re\n\nn = int(sys.stdin.readline())\na = int(sys.stdin.readline())\nb = int(sys.stdin.readline())\nif a == b:\n if n % a == 0:\n print('YES')\n print(1, n // (a) - 1)\n else:\n print('NO')\nelse:\n if n % a == 0:\n print('YES')\n print(n // a, 0)\n elif n % b == 0:\n print('YES')\n print(0, n // b)\n else:\n if n % abs(a - b) != 0:\n print('NO')\n else:\n for i in range(n // a + 1):\n for j in range(n // b + 1):\n if a * i + b * j == n:\n print('YES')\n print(i, j)\n sys.exit(0)\n"}, {"source_code": "from math import sqrt\nn = int(input())\na = int(input())\nb = int(input())\nfor i in range(int(n / 2 + 0.5)):\n if (n - (i * b)) % a == 0:\n print(\"YES\")\n print((n - i * b) // a, i)\n exit()\nprint(\"NO\")"}, {"source_code": "from math import sqrt\nn = int(input())\na = int(input())\nb = int(input())\nfor i in range(n // 2):\n if (n - (i * b)) % a == 0:\n print(\"YES\")\n print((n - i * b) // a, i)\n exit()\nprint(\"NO\")"}, {"source_code": "from heapq import heappush, heappop\ndef main():\n n = int(raw_input())\n a = int(raw_input())\n b = int(raw_input())\n sw = 0\n if a > b:\n a, b = b, a\n sw = 1\n if b > 10000:\n for i in xrange(10000):\n if (n - b * i) % a == 0:\n print \"YES\"\n break\n else:\n print \"NO\"\n return\n t = [1000100] * b\n t[0] = 0\n x = y = 0\n for i in xrange(10000):\n x += a\n if x >= b:\n x -= b\n y += 1\n if t[x] < y:\n break\n t[x] = y\n x = t[n%b] * b + n % b\n if x > n:\n print \"NO\"\n else:\n print \"YES\"\n x, y = x / a, (n - x) / b\n if sw:\n x, y = y, x\n print x, y\nmain()\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\ns=0\nif a>b:\n c=n//a\n for i in range(0,c+1):\n d=n-a*i\n e=d//b\n f=d%b\n if f==0:\n B=e\n A=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\nelif a<b:\n c=n//b\n for i in range(0,c+1):\n d=n-b*i\n e=d//a\n f=d%a\n if f==0:\n A=e\n B=i\n s+=1\n print('YES')\n break\n if s!=0:\n print(A,end=' ')\n print(B)\n else:\n print('NO')\nelse:\n if n%a==0:\n print('YES')\n print(int(n/a),end=' ')\n print(int(n/a))\n else:\n print('NO')\n\n"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\n\nbigger = max(a,b)\nsmaller = min(a,b)\n\nif (a==b) and (n%a != 0):\n\tprint('NO')\n\texit()\n\nfor i in range(n//bigger+1):\n\tif (n-bigger*i)%smaller==0:\n\t\tprint('YES')\n\t\tBer_Cola=i\n\t\tBars_bar=(n-bigger*i)//smaller\n\t\tprint(Bars_bar, Ber_Cola)\n\t\texit()\nprint('NO')"}, {"source_code": "n=int(input())\na=int(input())\nb=int(input())\nif a==b and n%a!=0:\n print('NO')\n\nelif n%2==1 and a%2==0 and b%2==0:\n print('NO')\nelif max(a,b)%min(a,b)==0 and n%a!=0:\n print('NO')\nelse:\n i=0\n if n%a==0:\n print('YES')\n print(n//a,end=' ')\n print(0)\n elif n%b==0:\n print('YES')\n print('0',end=' ')\n print(n//b)\n else:\n if a>b:\n while (n-a*i)%b!=0:\n i=i+1\n if i>n//a:\n print('NO')\n else:\n print('YES')\n print(i,end=' ')\n print((n-a*i)//b)\n else:\n while (n-b*i)%a!=0:\n i=i+1\n if i>n//b:\n print('NO')\n else:\n print('YES')\n print((n-b*i)//a,end=' ')\n print(i)\n "}, {"source_code": "x = int(input()) #monies\ny = int(input()) #cost of cola\nz = int(input()) #cost of bar\ncola = 0\nbar = 0\ntoolong=2+(x%1000)+(y*z)\nfor i in range(x):\n\tif((y==z and x % y != 0) or (x < y) or (x < z) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tbreak\n\tif(y>=z):\n\t\tif(x%z==0):\n\t\t\t bar = x // z \n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%z != 0 and x >= y and toolong > 0):\n\t\t\tx -= y\n\t\t\tcola += 1\n\t\t\ttoolong -= y\n\tif(z>y):\n\t\tif(x%y==0):\n\t\t\t cola = x // y\n\t\t\t print(\"YES\")\n\t\t\t print(cola, bar)\n\t\t\t break\n\t\twhile(x%y != 0 and x >= z and toolong > 0):\n\t\t\tx -= z\n\t\t\tbar += 1\n\t\t\ttoolong -= y"}, {"source_code": "x = int(input()) \ny = int(input()) \nz = int(input()) \ncola = bar = 0\ntoolong=1+y*z\nfor i in range(toolong):\n\tif(x % y == 0):\n\t\tcola = x // y\n\t\tbreak\n\tif(x % z == 0):\n\t\tbar = x // z\n\t\tbreak\n\tif((y == z and x % y != 0) or (z + y > x) or (x <= 0) or (toolong <= 0)):\n\t\tprint(\"NO\")\n\t\tquit()\n\twhile(x%y != 0 and toolong > 0 and x > 0):\n\t\tx -= z\n\t\tbar += 1\n\t\ttoolong -= z\nprint(\"YES\")\nprint(cola, bar)"}], "src_uid": "b031daf3b980e03218167f40f39e7b01"} {"source_code": "def solve():\n \n s = raw_input()\n n = len(s)\n \"\"\"\n sr = s[::-1]\n changed = False\n for i in range(n/2):\n s[i] != sr[i]:\n \"\"\"\n \n \n #print n\n changed = False\n for i in range(n/2):\n if s[i] != s[n-i-1]:\n #print s[i], s[n-i-1]\n if changed:\n print \"NO\"\n return\n else:\n changed = True\n if s == s[::-1] and n % 2 == 1:\n print \"YES\"\n elif changed or n == 1: print \"YES\"\n else: print \"NO\"\n \n \n \nsolve()", "positive_code": [{"source_code": "a = str(input())\nn = len(a)\ncount = 0\nfor i in range(len(a)//2):\n if(a[i] != a[n-i-1]):\n count += 1\nif(count==1 or (count==0 and len(a)%2!=0)):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s=input()\nl=len(s)\nk=0\nfor i in range(l//2):\n if s[i]!=s[l-i-1]:\n k+=1\nif k==1 or l%2 and k==0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import sys\n\ns = sys.stdin.readline().strip()\n\ndef canDoPalindrom(s):\n anyLetters = 0\n for i in range((len(s)+1)//2):\n if s[i]!=s[-1-i]:\n anyLetters+=1\n if anyLetters==1 or (anyLetters==0 and len(s)%2==1):\n return 'YES'\n else:\n return 'NO'\n \ndef doTest():\n assert canDoPalindrom('abccaa')=='YES'\n assert canDoPalindrom('abbcca')=='NO'\n assert canDoPalindrom('abcda')=='YES'\n \n#doTest()\nprint(canDoPalindrom(s))"}, {"source_code": "s = raw_input()\nm, i, j = 0, 0, len(s) - 1\nwhile i < j:\n if s[i] != s[j]: m += 1\n i += 1\n j -= 1\nif m == 1 or (m == 0 and i == j): print 'YES'\nelse: print 'NO'\n"}, {"source_code": "s=raw_input()\nl=len(s)\nif l==1:\n print \"YES\"\nelse:\n s1=s[:int(l/2)]\n s2=s[-1:-(int(l/2))-1:-1]\n cnt=0\n for i in range(int(l/2)):\n if s1[i]!=s2[i]:\n cnt+=1\n if cnt>1:\n break\n \n if cnt==1:\n print \"YES\"\n elif cnt==0:\n if l%2==0:\n print \"NO\"\n else:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "List = input()\ncontrol, head, tail = 1, 0, len(List) - 1\n\nwhile head <= tail:\n if List[head] != List[tail]:\n control -= 1\n head, tail = head + 1, tail - 1\n\nif control < 0 or control == 1 and len(List) % 2 == 0:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "s = input().strip()\nn = len(s)\nif n == 1:\n\tprint('YES')\nelse:\n\ti = 0\n\tj = n-1\n\tc = 0\n\twhile i < j:\n\t\tif s[i] != s[j]:\n\t\t\tc += 1\n\t\ti += 1\n\t\tj -= 1\n\tif n % 2 == 0:\n\t\tprint('YES' if c == 1 else 'NO')\n\telse:\n\t\tprint('YES' if c <= 1 else 'NO')"}, {"source_code": "s, ans = input(), 0\nif s == s[::-1] and len(s) % 2 != 0 : print('YES')\nelse :\n for i in range ( len(s) // 2) :\n if s[i] != s [len(s) - i - 1] : ans += 1\n if ans == 1 : \n print('YES')\n else : \n print('NO') "}, {"source_code": "from sys import stdin\ns = stdin.readline().rstrip()\n\nc = 0\n\nfor i in range(len(s)//2):\n if s[i] != s[len(s)-i-1]:\n c += 1\n \nif c == 1 or (len(s) % 2 == 1 and c == 0):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "s=raw_input()\nl=len(s)\ncount=0\nif l==1:\n print \"YES\"\nfor i in range(l):\n if s[i]!=s[l-1-i]:\n # print i\n count+=1\nif l!=1:\n if count==2 or(count==0 and l%2==1):\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "s = raw_input()\nt=0\nfor i in xrange(len(s)/2):\n if s[i] != s[-1-i]: t += 1\n if t>=2: break\nprint \"YES\" if (t == 1) or (t==0 and len(s)%2==1) else \"NO\""}, {"source_code": "s = input()\nmissmatch_count = 0\nfor i in range(len(s)):\n if s[i] != s[-i-1]:\n missmatch_count += 1\nif missmatch_count == 2:\n print(\"YES\")\nelif missmatch_count == 0 and (len(s) % 2) == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=str(input())\nk=0\nl=0\nif len(a)%2==0:\n s1=(a[:len(a)//2])\n s2=(a[len(a)//2:])\nelse:\n k=len(a)//2\n s1=a[:k]\n s2=a[k+1:]\ns2=s2[::-1]\nfor i in range(len(s1)):\n if s1[i]!=s2[i]:\n l=l+1\nif l==1:\n print(\"YES\")\nelse:\n if len(a)%2==1 and l==0:\n print(\"YES\")\n else:\n print(\"NO\")\n \n"}, {"source_code": "#https://codeforces.com/problemset/problem/798/A\ns=input()\nc=0\ni=0\nflag=True\nwhile(i<int(len(s)/2) and flag):\n\tif(s[i]!=s[len(s)-i-1]):\n\t\tc+=1\n\tif(c>1):\n\t\tflag=False\n\ti=i+1\nif(c==1):\n\tprint(\"YES\")\nelse:\n\tif(c==0):\n\t\tif(len(s)%2==0):\n\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n"}, {"source_code": "s = input()\ncnt = 0\nn = len(s)-1\ni = 0\nwhile i<len(s):\n #print(i,n-i)\n if s[i] != s[n-i]:\n cnt+=1\n i+=1\n#print(cnt)\nif cnt==2:\n print(\"YES\")\nelif cnt==0 and len(s)%2!=0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "S = str(input())\nchars = []\nchars2 = []\ncount = 0\nfor i in S:\n chars.append(i)\n\nfor i in range(0, len(chars)):\n chars2.append(chars[len(chars) - 1 - i])\nfor i in range(0, len(chars)):\n if chars[i] != chars2[i]:\n count = count + 1\nif chars2 == chars and len(chars)%2 != 0:\n print (\"YES\")\nelse:\n if count == 2:\n print (\"YES\")\n else:\n print (\"NO\")"}, {"source_code": "n = input()\nq = [0]*len(n)\nb = n\np=\"\"\ny=0\nl=0\nfor i in range(len(n)-1,-1,-1):\n p+=n[i]\ny=len(n)-1\nfor i in range(len(n)//2):\n if b[i]!=b[y]:\n l+=1\n y-=1\nif l==1 or (p==b and len(n)%2!=0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\ncnt = 0\nn = len(s)\nfor i in range(n // 2):\n if s[i] != s[n - 1 - i]:\n cnt += 1\nif cnt == 1 or cnt == 0 and n % 2 == 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def com(s1,s2):\n d=0\n for i in range(len(s1)):\n if(s1[i]!=s2[i]):\n d=d+1\n \n return(d)\ns=input()\nif(len(s)%2==0 and len(s)!=1):\n if((com(s[:int(len(s)/2)],s[len(s)-1:int(len(s)/2)-1:-1]))==1):\n print(\"YES\")\n else:\n print(\"NO\")\nelif(len(s)%2!=0 and len(s)!=1):\n if((com(s[:int(len(s)/2)],s[len(s)-1:int((len(s)/2)):-1]))<=1):\n print(\"YES\")\n else:\n \n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "s=input()\nn=len(s)\nc=0\nfor i in range(n//2):\n if s[i]!=s[n-i-1]:\n c+=1\nif c>=2:\n print('NO')\nelif c==1:\n print('YES')\nelse:\n if len(s)%2!=0:\n print('YES')\n else:\n print('NO') \n\n\n\n\n"}, {"source_code": "x=input()\nd=x[::-1]\nl=0\nfor n in range(len(x)):\n\tif x[n]!=d[n]:\n\t\tl+=1\nif l==2:\n\tprint('YES')\nelif l==0:\n\tif len(x)%2==1:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelse:\n\tprint('NO')"}, {"source_code": "import sys\n\n#t = int(input())\nt = 1\n\nwhile t > 0:\n #print(t)\n s=input()\n limit = 0\n for i in range((len(s)//2)):\n if not s[i]==s[-i-1]:\n limit += 1\n '''if limit > 1:\n print(\"NO\")\n sys.exit(0)'''\n #print(f'pair {s[i]} - {s[-i-1]}')\n if limit==1: print(\"YES\")\n else:\n if not (len(s)%2==1 and limit==0):\n print(\"NO\")\n else:\n print(\"YES\")\n\n t -= 1"}, {"source_code": "\ndef ok(str1):\n count=0\n for i in range(len(str1)//2):\n if str1[i]!=str1[len(str1)-i-1]:\n count+=1\n if count<=1 and (len(str1)&1) or count==1:\n return True\n else:\n return False\nstr1=input()\nif ok(str1):\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "t = list(input())\n\nk = len(t)\ncc = 0\ni = 0\nwhile( i <= k-i-1):\n if t[i] != t[k-i-1]:\n cc = cc + 1\n i = i +1\nif cc ==1:\n print(\"YES\")\nelif cc == 0 and k%2==1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "from sys import stdin, stdout\n\ns = stdin.readline().strip()\n\nif s == s[::-1] and not len(s) % 2:\n stdout.write('NO')\nelse:\n cnt = 0\n \n for i in range(len(s)):\n if s[i] != s[-i - 1]:\n cnt += 1 \n\n if cnt > 2:\n stdout.write('NO')\n else:\n stdout.write('YES')"}, {"source_code": "'''\ntt = int(raw_input())\na = map(int, raw_input().split())\nfor i in xrange(tt):\na = map(int, (' '.join(n for n in raw_input())).split())\n'''\n\ns = raw_input()\nlength = len(s)\nflag = 0\n\nfor i in xrange(length / 2):\n if s[i] == s[length - 1 - i]:\n continue\n \n else:\n flag += 1\n\nif flag == 1:\n print \"YES\"\n\nelse:\n if length == 1:\n print \"YES\"\n \n elif flag == 0 and length % 2 == 1:\n print \"YES\"\n\n else:\n print \"NO\"\n\n\n"}, {"source_code": "s = input()\nfor i in range(len(s)):\n for ch in 'qwertyuiopasdfghjklzxcvbnm':\n if ch == s[i]:\n continue\n s1 = s[0:i] + ch + s[i + 1:]\n if s1 == s1[::-1]:\n print(\"YES\")\n exit()\nprint(\"NO\")\n"}, {"source_code": "s = input()\nn = len(s)\nc = 0\nfor i in range(n // 2):\n if s[i] != s[n - i - 1]:\n c += 1\n# print(\"c: {0}\".format(c))\nif c == 1:\n print(\"YES\")\nelse:\n if c == 0 and n % 2 == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "z = input()\nm = len(z)\nif z==z[::-1] and m%2:\n print(\"YES\")\nelif z==z[::-1] and not m%2:\n print(\"NO\")\nelse:\n r = \"YES\"\n count = 0\n for i in range(0,m//2):\n if z[i]!=z[m-1-i]:\n count = count +1\n if count > 1:\n r = \"NO\"\n break\n print(r)"}, {"source_code": "line = input()\nhalf1 = 0\nhalf2 = 0\n\nif len(line)%2 == 0:\n half1 = line[:(len(line)//2)]\n half2 = line[(len(line)//2):len(line)+1]\nelse:\n half1 = line[:(len(line)-1)//2]\n half2 = line[(len(line))//2+1:len(line)+1]\n\ntemp = 0\nfor i in range(len(half2)):\n if half1[i] != half2[-(i+1)]:\n temp += 1\nif temp == 1:\n print('YES')\nelif temp == 0 and len(line)%2 != 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "string = list(input())\nflag = 0\nend = len(string)//2\nif len(string)%2 != 0:\n end += 1\nfor i in range(end):\n if i == len(string)-i-1:\n print(\"YES\")\n exit(0)\n if string[i] != string[len(string)-i-1]:\n if flag == 0:\n flag = 1\n else:\n print(\"NO\")\n exit(0)\nif(flag):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\nc = 0\npos = True\nfor i in range(int(len(s) / 2)):\n if s[i] != s[len(s) - i - 1]:\n c += 1\n if c > 1:\n pos = False\n break\nif len(s) % 2 == 1 and c == 0:\n c += 1\nif pos and c == 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "inp = (input())\nletters = list(set(inp))\nlent = len(inp)\nsetlen = len(letters)\nflag = 0\n\ndef sem(strr):\n leng = len(strr)\n for i in range(leng):\n if strr[0] != strr[i]:\n return False\n return True\n\ndef ispal(strr):\n leng = len(strr)\n for i in range(int(leng/2)):\n if strr[i] != strr[leng-1-i]:\n return False\n return True\n\nif (sem(inp) == True):\n if len(inp) % 2 == 1:\n flag = 1\nelse:\n for i in range(lent):\n if (lent == 1):\n flag = 1\n break\n for j in range(setlen):\n sem = list(inp)\n if sem[i] == letters[j]:\n continue\n sem[i] = letters[j]\n #print(inp)\n #print(sem)\n #print(ispal(sem))\n if ispal(sem) == True:\n flag = 1\n break\n\nif flag == 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "x=input()\ny=x[::-1]\n\n\nc=0\nt='YES'\nfor i in range(len(x)):\n\tif x[i]!=y[i]:\n\t\tc+=1\n\n\tif c>2:\n\t\tt='NO'\n\t\tbreak\nif c==0 and len(x)%2==1:\n\tt='YES'\nelif c==0 and len(x)%2==0:\n\tt='NO'\n\nprint(t)\n"}, {"source_code": "s=raw_input()\nbd=0\nfor i in range((len(s)+1)/2):\n if s[i]==s[-i-1]:\n bd=bd+1\nif len(s)%2==1 and bd==(len(s)+1)/2:\n print 'YES'\nelif bd==(len(s)+1)/2-1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "k = 0\ns = ''\nz = ''\nx = input()\nif len(x) % 2 == 0:\n for i in range(len(x)//2):\n s = s + x[i]\n for i in range(len(x)//2, len(x)):\n z = z + x[i]\nelse:\n for i in range(len(x)//2):\n s = s + x[i]\n for i in range((len(x)//2)+ 1, len(x)):\n z = z + x[i]\ns = s[::-1]\nfor i in range(len(z)):\n if s[i] != z[i]:\n k = k +1\n \nif k == 0 and len(x) % 2 != 0:\n print('YES')\nelif k == 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "a = input()\ninv = a[::-1]\ncont = 0\nfor i in range(len(a)):\n\tif a[i] != inv[i]:\n\t\tcont += 1\n\t\nif cont == 2 :\n\tprint('YES')\nelif cont == 0 and len(a) % 2 == 1 :\n\tprint('YES')\nelse:\n\tprint('NO') \n"}, {"source_code": "text = str(raw_input())\nnumber = 0\n\nfor i in xrange(len(text)/2):\n if text[i] != text[len(text)-i-1]:\n number += 1\n if number >> 1:\n break\n\nif number == 1:\n print \"YES\"\nelif number == 0 and (len(text) % 2)!= 0:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "s = raw_input()\nd = 0\nfor i, j in zip(s, s[::-1]):\n d += i != j\nprint 'YES' if d == 2 or (d == 0 and len(s) % 2 == 1) else 'NO'"}, {"source_code": "s = raw_input()\ni, j = 0, len(s) - 1\ndiff = 0\nwhile i < j:\n if s[i] != s[j]:\n diff += 1\n i += 1\n j -= 1\nif diff == 1 or (diff == 0 and len(s) % 2 == 1):\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "str=input();\nls=len(str);\ni,j,ans=0,ls-1,0;\nwhile(i<j):\n\tif(str[i]!=str[j]): ans=ans+1;\n\ti=i+1;j=j-1;\nif(ans>1 or (ans==0 and ls&1==0)): print(\"NO\");\nelse: print(\"YES\");"}, {"source_code": "#!/usr/bin/python\n\nword = raw_input()\nflag = 0\nlength = len(word)/2\n\nfor i in range(length):\n\tif word[i] != word[len(word)-1-i]:\n\t\tflag += 1\n\nif ((flag == 1) | ((flag==0) & (len(word)%2 == 1))):\n\tprint(\"YES\")\n\nelse:\n\tprint (\"NO\")\n"}, {"source_code": "#RAVENS\n#TEAM_2\n#ESSI-DAYI_MOHSEN-LORENZO\ns = input()\nl = len(s) -1\ndiff = 0\ni = 0\nwhile i <= l:\n diff+= s[i] != s[l]\n i+=1\n l-=1\nprint( ('NO','YES')[diff ==1 or (diff==0 and (len(s) % 2 == 1))] )"}, {"source_code": "# Problem 798A. Mike and palindrome\ns = input()\nL = len(s)\nt = 0\nif L%2 != 0:\n L -= 1\n\nfor i in range(L//2):\n if s[i] != s[-i-1]:\n t += 1\nif t <= 1 and len(s)%2 != 0:\n print('YES')\nelif t == 1 and len(s)%2 == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s=input()\nj=len(s)\ncount=0\nfor x in range(j//2):\n\tif s[x]!=s[j-1-x]:\n\t\tcount+=1\nif count==1:print('YES')\nelse:\n\tif count==0 and j%2!=0 :print('YES')\n\telse:print('NO')"}, {"source_code": "import math\nt=False\ntxt = list(input())\nn = len(txt)\nif(n%2!=0):\n txt.pop(math.floor(n/2))\nn1 = math.floor(len(txt)/2)\nl1 = txt[0:n1]\nl2 = txt[n1:]\nl2.reverse()\nj=0\nans=[]\nfor i in l1:\n if(i!=l2[j]):\n ans.append(j)\n j=j+1\nif(len(ans)==1):\n t=True\n print(\"YES\")\nif(len(ans)==0 and n%2!=0):\n t=True\n print(\"YES\")\nif(t==False):\n print(\"NO\")\n\n\n\n"}, {"source_code": "import sys,math\na=list(sys.stdin.readline())\na.pop()\nleft=[]\nright=[]\nfor i in range(len(a)//2):\n left.append(a[i])\n right.append(a[len(a)-i-1])\nk=0\nfor i in range(len(left)):\n if left[i]!=right[i]:\n k+=1 \nif len(a)%2==0: \n if k==1:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if k<=1:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "S = input()\ni = 0\nj = len( S ) - 1\nqq = []\nwhile i < j:\n if S[ i ] != S[ j ]:\n qq.append( i )\n i += 1\n j -= 1\nif len( qq ) == 0:\n if len( S ) & 1:\n exit( print( \"YES\" ) )\n else:\n exit( print( \"NO\" ) )\nif len( qq ) == 1:\n exit( print( \"YES\" ) )\nprint( \"NO\" )"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\nans = 'NO'\nl = len(a)\nco = 0\nfor i in xrange(l/2):\n if a[i]!=a[l-1-i]:\n co+=1\nif co==1:\n ans = 'YES'\nelif co==0 and l%2:\n ans = 'YES'\nprint ans"}, {"source_code": "def solve(s):\n i, j = 0, len(s)-1\n diff = 0\n while i < j:\n diff += s[i] != s[j]\n i += 1\n j -= 1\n if diff == 1 or (diff == 0 and len(s) % 2 == 1):\n return 'YES'\n return 'NO'\n\n\nif __name__ == '__main__':\n s = raw_input()\n ans = solve(s)\n print ans\n"}, {"source_code": "word = raw_input()\n\nif len(word) == 1:\n print 'YES'\n exit()\n\nbeg = 0\nlast = len(word) - 1\nchangedCharacters = 0\n\nwhile beg < last:\n if word[beg] != word[last]:\n changedCharacters += 1\n beg += 1\n last -= 1\n continue\n if changedCharacters == 2:\n print 'NO'\n exit()\n beg += 1\n last -= 1\n\nif changedCharacters >= 2:\n print 'NO'\n exit()\nif changedCharacters == 1:\n print 'YES'\nelse:\n if len(word) % 2 == 1:\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "# https://codeforces.com/contest/798/problem/A\n\ns = input()\ncnt = 0\n\nlow = 0\nhigh = len(s) - 1\n\nwhile low < high:\n\tif s[low] != s[high]:\n\t\tcnt += 1\n\tlow += 1\n\thigh -= 1\n\tpass\nprint('YES' if cnt == 1 or cnt == 0 and len(s) % 2 != 0 else 'NO')"}, {"source_code": "s = raw_input()\ncount = 0\nn = len(s)\nfor i in range((len(s)+1)/2):\n if s[i] != s[n-1-i]:\n count += 1\nif n%2==1:\n print 'NO' if count not in [0,1] else 'YES'\nelse:\n print 'YES' if count == 1 else 'NO'\n "}, {"source_code": "x=raw_input()\nl=0\nc=0\nr=len(x)-1\nwhile(l<=r):\n if(x[l]!=x[r]):\n c+=1\n l+=1\n r-=1\nif c==1:\n print \"YES\"\nelif c==0 and len(x)%2==1:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "s=input()\nmid=len(s)//2\nif len(s)%2==1:\n mid=(len(s)//2)+1\nfirst=s[:len(s)//2]\nlast=s[mid:]\nlast=last[::-1]\nc=0\nfor i in range(len(first)):\n if first[i]!=last[i]:\n c+=1\nif c==0 and len(s)%2==1 and first==last:\n print(\"YES\")\nelif c==1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s=input()\nstrr=list(s)\n\na=[]\nif len(s)==1:\n print('YES')\nstrr1=strr[0:len(s)//2]\nif ( len(s)%2==0):\n \n\n strr2 = strr[len(s)//2:len(s)]\nelif(len(s)!=1 and len(s)%2!=0):\n strr2=strr[len(s)//2+1:len(s)]\nfor i in range(len(strr1)): \n if(strr1[i] ==strr2[len(strr2)-i-1]):\n a.append('*')\n else:\n\n a.append(i)\n \nif(len(s)!=1):\n a[:]=(value for value in a if value !='*')\n \n if(len(a)==1):\n print('YES')\n elif(len(a)==0 and len(s)%2!=0):\n print('YES')\n else:\n print('NO')\n\n"}, {"source_code": "s = raw_input().strip()\nc = 0\nfor i in range(len(s)/2):\n if s[i] != s[-1 - i]: c += 1\nif c > 1 or (c == 0 and len(s)%2 == 0): print \"NO\"\nelse: print \"YES\"\n\n"}, {"source_code": "\ns=str(raw_input())\nc=0\nfor i in range(0,len(s)/2):\n if(s[i]!=s[len(s)-i-1]):\n c=c+1\nif(len(s)%2!=0):\n if(c==0 or c==1):\n print \"YES\"\n else:\n print \"NO\"\nelse:\n \n if(c==1):\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "s=input()\nn=len(s)\nc=0\nfor i in range(n//2):\n if(s[i]!=s[n-i-1]):\n c=c+1\nif(c==1):\n print(\"YES\")\nelif(n%2==1 and c==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "input = raw_input()\ni = 0\nj = len(input) - 1\n\nc = 0\nwhile i <= j:\n if input[i] != input[j]:\n c += 1\n i += 1\n j -= 1\n\nif (c == 0 and len(input) % 2 == 1) or c == 1:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "S=input()\nif len(S)%2==0 :\n Z=S[(len(S)//2):]\n \nelse :\n Z=S[(len(S)//2)+1:]\nZ1=S[:len(S)//2]\nc=0\nZ=Z[::-1]\nfor i in range(len(Z)) :\n if Z[i]!=Z1[i] :\n c=c+1\n\n\nif c==1 or c==0 and len(S)%2!=0 :\n print('YES')\nelse :\n print('NO')\nl=0\n \n"}, {"source_code": "def isPal(myString):\n strLength = len(myString)/2\n isPal = 0\n for i in range(strLength):\n if myString[i] is not myString[-i-1]:\n isPal = isPal + 1\n return isPal\n\ntest = raw_input()\nif isPal(test) is 0:\n if len(test) % 2 is 1:\n print (\"YES\")\n else: print (\"NO\")\nelif isPal(test) is 1:\n print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "str = raw_input()\nl = len(str)\nfoo = 0\nfor i in range(l / 2):\n if str[i] != str[l - i - 1]:\n foo += 1\nif foo == 0 and l % 2 == 1:\n foo = 1\nif foo == 1:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "def pol2(s):\n k = 0\n for i in range(0, len(s) // 2 + 1):\n if s[i] != s[len(s) - 1 - i]:\n k += 1\n if k == 1:\n return \"YES\"\n return \"NO\"\n\ndef is_pal(s):\n return s == s[::-1]\n\ndef pol(s):\n for i in range(0, len(s)):\n for j in range(ord('a'), ord('z') + 1):\n c = chr(j)\n if s[i] != c:\n s1 = s[:i] + c + s[i+1:]\n if is_pal(s1):\n return \"YES\"\n return \"NO\"\n\nif __name__ == '__main__':\n s = str(input())\n print(pol(s))\n"}, {"source_code": "import string\ns = list(raw_input())\n\ndef isPalindrom(st):\n if len(st) <= 1:\n return True\n\n return st[0] == st[-1] and isPalindrom(st[1:-1])\n\n\npossible = False\nfor i in range(len(s)):\n oldc = s[i]\n for c in string.lowercase:\n if c == oldc:\n continue\n s[i] = c\n possible = possible or isPalindrom(s)\n s[i] = oldc\n\nif possible:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "s = input()\nl = len(s)\n\na = sum([s[i] != s[-(i + 1)] for i in range(l // 2)])\n\nif a == 1:\n print('YES')\nelif not a:\n if l % 2:\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')"}, {"source_code": "inp = str(raw_input())\n\nc = 0\ni = 0\nwhile c<2 and i<(len(inp)/2):\n if inp[i]!=inp[-1-i]:\n c+=1\n i+=1;\n\nif(c==0 and len(inp)%2==1):\n\tprint \"YES\"\nelif(c==1):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Apr 24 19:16:16 2017\n\n@author: wb\n\"\"\"\n\nlist=raw_input()\nlength=len(list)\nlendo=len(list)/2\n\n\nans=0\nfor i in range(0,lendo):\n if list[i]!=list[length-1-i]:\n ans=ans+1\n\n \nif (ans==1)or((ans==0)and(length%2==1)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def inp():\n return int(raw_input())\ndef linp():\n return map(int, raw_input().split())\ns=raw_input()\nl = 0\nr = len(s)-1\ninc = 0\nwhile(l<r):\n if s[l]!=s[r]:\n inc+=1\n l+=1\n r-=1\nif inc==1:\n print \"YES\"\nelse:\n if len(s)%2!=0 and inc==0:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "s = input()\na = ''\nc = 0\nfor i in range(len(s)-1,-1,-1) :\n a += s[i]\nfor i in range(len(s)) :\n if(a[i]==s[i]) :\n c += 1\nif(c==len(s)-2) :\n print(\"YES\")\nelif(a==s and (len(s))%2!=0) :\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "cnt = 0\ns = input()\nlength = len(s)\n\nfor i in range(0, length // 2, 1):\n if s[i] != s[length - i - 1]:\n cnt = cnt + 1\n\nif (cnt < 2 and length % 2 == 1) or cnt == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from sys import stdin, stdout\n\ndef main():\n word = str(stdin.readline().rstrip().split())[2:-2]\n palindrome = True\n word_len = len(word)\n \n for x in xrange(word_len/2):\n if word[x] != word[word_len-x-1]:\n if palindrome:\n palindrome = False\n else:\n print 'NO'\n return\n if palindrome and (word_len % 2 == 0):\n print 'NO'\n else:\n print 'YES'\n \nmain()\n"}, {"source_code": "s = raw_input()\n\ni = 0\nj = len(s)-1\n\nx = 0\nwhile i < j:\n if s[i] != s[j] : x+=1\n i += 1\n j -=1\n\nif x == 1:\n print \"YES\"\nelif x == 0 and len(s) %2 == 1:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "a=raw_input()\nc=0\nfor i in range(len(a)/2):\n\tif a[i]!=a[-i-1]:c+=1\nif c>1 or (c==0 and len(a)%2==0):print\"NO\"\nelse:print\"YES\""}, {"source_code": "a=list(input())\nn=len(a)\ncount=0\nfor i in range(n//2):\n if a[i]!=a[n-i-1]:\n count+=1\nif len(a)%2==1 and count==0:\n count=1\nprint(\"YES\" if count==1 else \"NO\") "}, {"source_code": "s1=input()\ncnt=0\nfor i in range(0,len(s1)//2):\n if s1[i]!=s1[len(s1)-i-1]:\n cnt+=1\nif cnt==1:\n print(\"YES\")\nelif cnt==0:\n if len(s1)%2!=0:\n print(\"YES\")\n else:\n print(\"NO\")\nelif cnt>1:\n print(\"NO\")\n "}, {"source_code": "import sys\n\nif __name__ == \"__main__\":\n a = sys.stdin.readline().strip()\n achr = list(a)\n count = 0\n for idx in range(len(achr)/2):\n if achr[idx] != achr[len(achr) - idx - 1]:\n achr[idx] = achr[len(achr)-idx-1]\n count += 1\n if \"\".join(achr) == \"\".join(achr[::-1]):\n if count == 1:\n print \"YES\"\n elif count == 0 and len(achr) % 2 == 1:\n print \"YES\"\n else:\n print \"NO\"\n else:\n print \"NO\"\n"}, {"source_code": "a = input()\ni, j, c = 0, len(a) - 1, 0\nwhile i < j:\n c += a[i] != a[j]\n i += 1\n j -= 1\nprint((\"NO\", \"YES\")[c == 1 or c == 0 and len(a) % 2])\n"}, {"source_code": "from sys import maxsize, stdout, stdin, stderr\n# mod = int(1e9 + 7)\nimport re # can use multiple splits\ntup = lambda: map(int, stdin.readline().split())\nI = lambda: int(stdin.readline())\nlint = lambda: [int(x) for x in stdin.readline().split()]\nS = lambda: stdin.readline().replace('\\n', '').strip()\ndef grid(r, c): return [lint() for i in range(r)]\ndef debug(*args, c=6): print('\\033[3{}m'.format(c), *args, '\\033[0m', file=stderr)\nstpr = lambda x : stdout.write(f'{x}' + '\\n')\nstar = lambda x : print(' '.join(map(str , x)))\nfrom math import ceil\nfrom itertools import permutations\ns = S()\nn = len(s)\ncnt =0\nfor i in range(n//2):\n if s[i]==s[n-i-1]:\n pass\n else:\n cnt+=1\nif cnt==1 or(n%2==1 and cnt==0):\n print(\"YES\")\n\nelse:print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# n , t , k , d = tup()\n# x = ceil(n/k)*t\n# c =0\n# while c <=d: #TIME TO COOK THE FIRST BATCH OF CAKES TILL THE PREPARATION OF THE SECOND OVEN\n# n-=k\n# c+=t\n# #IF THERE ARE STILL CARROTS LEFT THEN WE CAN USE THE SECOND OVEN TO BAKE MORE CARROTS\n# if n >0:print(\"YES\")\n# else:print(\"NO\")"}, {"source_code": "s = raw_input()\ntest = 0\nfor i in range(len(s)/2):\n if s[i]==s[len(s)-1-i]:\n continue\n else:\n test +=1\nprint[\"NO\",\"YES\"][test == 1 or (test==0 and len(s)%2==1)]\n"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/798/A\n\ndef isPal(s, i):\n j = 0\n \n while j < len(s) // 2 + (1 if len(s) % 2 == 1 else 0):\n if j != i:\n if s[j] != s[len(s) - 1 - j]:\n return False\n j += 1\n return True\n\ns = input()\n\nif len(s) % 2 != 1 and isPal(s, -1):\n print(\"NO\")\n quit()\n\ni = 0\nwhile i < len(s) // 2 + (1 if len(s) % 2 == 1 else 0):\n if isPal(s, i):\n print(\"YES\")\n quit()\n i += 1\n \nprint(\"NO\")"}, {"source_code": "##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\nimport sys\ninput = sys.stdin.readline\nscanner = lambda: int(input())\nstring = lambda: input().rstrip()\nget_list = lambda: list(read())\nread = lambda: map(int, input().split())\nget_float = lambda: map(float, input().split())\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // math.gcd(a, b)\n\ndef is_integer(n):\n\treturn math.ceil(n) == math.floor(n)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\n\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n# Euler's Toitent Function phi\ndef phi(n) : \n \n result = n \n p = 2\n while(p * p<= n) : \n if (n % p == 0) : \n while (n % p == 0) : \n n = n // p \n result = result * (1.0 - (1.0 / (float) (p))) \n p = p + 1\n if (n > 1) : \n result = result * (1.0 - (1.0 / (float)(n))) \n \n return (int)(result) \n\ndef is_prime(n):\n\tif n == 0:\n\t\treturn False\n\tif n == 1:\n\t\treturn True\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif not n % i:\n\t\t\treturn False\n \n\treturn True\n\ndef next_prime(n, primes):\n\twhile primes[n] != True:\n\t\tn += 1\n\treturn n\n\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\ndef factors(n):\n\tres = []\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i == 0:\n\t\t\tres.append(i)\n\t\t\tres.append(n // i)\n\treturn list(set(res))\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n\ndef binary_search(low, high, w, h, n):\n\twhile low < high:\n\t\tmid = low + (high - low) // 2\n\t\t# print(low, mid, high)\n\t\tif check(mid, w, h, n):\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid\n\treturn low\n\n## for checking any conditions\ndef check(beauty, s, n, count):\n\tpass\n\t\n\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\nalphs = \"abcdefghijklmnopqrstuvwxyz\"\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\nimport bisect as bis\nimport random\nimport sys\nimport collections as collect\n\ndef solve():\n\ts = string()\n\tc = 0\n\tfor i in range(len(s) // 2):\n\t\tif s[i] != s[len(s) - i - 1]:\n\t\t\tc += 1\n\tif len(s) % 2 == 0:\n\t\tprint([\"NO\", \"YES\", \"NO\"][min(2, c)])\n\t\treturn\n\tprint([\"YES\", \"YES\", \"NO\"][min(2, c)])\n\treturn\n\n\n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n for i in range(1):\n \tsolve()\n #dmain()\n \n# Comment Read()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "s = str(raw_input())\nsm = sum([x1 != x2 for x1, x2 in zip(s, s[::-1])])\nif sm == 2 or sm == 0 and len(s) % 2 == 1:\n print \"YES\"\nelse: \n print \"NO\"\n"}, {"source_code": "s = raw_input()\n\ndiff = 0\n\n#print range(len(s) / 2 + len(s) % 2)\nfor i in range(len(s) / 2 + len(s) % 2):\n if s[i] != s[-(1 + i)]:\n diff += 1\n\n\nif diff == 1:\n print 'YES'\nelse:\n if diff == 0 and len(s) % 2 == 1:\n print 'YES'\n else:\n print 'NO'\n"}, {"source_code": "s = raw_input()\nq = 0\nfor i in range(len(s)/2):\n if(s[i] != s[len(s) - i - 1]):\n q += 1\nif(q == 1) or (len(s)%2 == 1 and q == 0):\n print (\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x=input()\nn=(len(x)//2)\ns=0\nfor i in range(n):\n if x[i]!=x[len(x)-1-i]:\n s+=1\nif s==0:\n if len(x)%2==1:\n print(\"YES\")\n else:\n print(\"NO\")\nelif s==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "import sys\n\ndef solve():\n s = [ch for ch in input()]\n n = len(s)\n\n if n % 2 == 1 and s == list(reversed(s)):\n print('YES')\n return\n \n for i in range(n):\n tmp = s[i]\n\n if s[i] == s[n - 1 - i]:\n continue\n\n s[i] = s[n - 1 - i]\n\n if s == list(reversed(s)):\n print('YES')\n return\n\n s[i] = tmp\n\n print('NO')\n\ndef debug(x, table):\n for name, val in table.items():\n if x is val:\n print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\n return None\n\nif __name__ == '__main__':\n solve()"}, {"source_code": "import sys\n\ndef solve():\n s = [ch for ch in input()]\n n = len(s)\n\n for i in range(n):\n if i != n - 1 - i and s[i] == s[n - 1 - i]:\n continue\n\n tmp = s[i]\n s[i] = s[n - 1 - i]\n\n if s == s[::-1]:\n print('YES')\n return\n\n s[i] = tmp\n\n print('NO')\n\nif __name__ == '__main__':\n solve()"}], "negative_code": [{"source_code": "def com(s1,s2):\n d=0\n for i in range(len(s1)):\n if(s1[i]!=s2[i]):\n d=d+1\n return(d)\n print(d)\ns=input()\nif(len(s)%2==0):\n if((com(s[:],s[::-1]))<=2):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if((com(s[:],s[::-1]))<=2):\n print(\"YES\")\n else:\n \n print(\"NO\")\n"}, {"source_code": "n=input()\na=len(n)\np=0\nfor i in range(a//2+1):\n if(n[i]==n[a-i-1]):\n pass\n else:\n p+=1\nif(p==1):\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "import math\n\npalin = list(input())\n\n\ndef viab(t):\n count = 0\n r = math.floor(len(t) / 2)\n for i in range(r):\n if t[i] != t[-i-1]:\n count += 1\n if count == 0: return 1\n elif count == 1: return 2\n else: return 3\n\nif len(palin) == 1:\n print(\"YES\")\nelse:\n if viab(palin) == 1 or viab(palin) == 2: print(\"YES\")\n else: print(\"NO\")"}, {"source_code": "s = input()\nn = len(s)\nflag = 0\nj = 0\nfor i in range(n//2):\n if s[i] != s[-i-1]:\n if flag == 0:\n flag+=1\n else:\n j = 1\n break\nif j == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a=input()\ns=0\nfor i in range(len(a)//2):\n if a[i]!=a[len(a)-i-1]:\n s=s+1\nif s<=1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s = input()\nc = 0\npos = True\nfor i in range(int(len(s) / 2)):\n if s[i] != s[len(s) - i - 1]:\n c += 1\n if c > 1:\n pos = False\n break\n if len(s) % 2 == 1 and c == 0:\n c += 1\n if pos and c == 1:\n print('YES')\n else:\n print('NO')"}, {"source_code": "s=input()\nl=len(s)\nk=0\nfor i in range(l//2):\n if s[i]!=s[l-i-1]:\n k+=1\nif k==1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "a = raw_input()\n\nb = len(a) - 1\n\ncount = 0\n\nif len(a) % 2 != 0:\n\t\n\tlength = len(a) / 2\nelse:\n\t\n\tlength = len(a) / 2 - 1\n\nfor i in range(length):\n \n if a[i] != a[b]:\n \n count += 1\n \n #print i\n \n b -= 1\n\n\n#print \"Count\" + str(count)\n\nif count > 1:\n \n print \"NO\"\nelif count == 0 and len(a) % 2 == 0:\n \n print \"NO\"\nelse:\n\t\n\tprint \"YES\""}, {"source_code": "text = raw_input()\nnumcharsdiff = 0\nfor i in range(0, int(len(text)/2)):\n\tif (text[i] != text[len(text)-i-1]):\n\t\tnumcharsdiff += 1\nif (numcharsdiff == 1):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "inp = (input())\nletters = list(set(inp))\nlent = len(inp)\nsetlen = len(letters)\nflag = 0\n\ndef ispal(strr):\n leng = len(strr)\n for i in range(int(leng/2)):\n if strr[i] != strr[leng-1-i]:\n return False\n return True\n\nfor i in range(lent):\n for j in range(setlen):\n sem = list(inp)\n sem[i] = letters[j]\n #print(inp)\n #print(sem)\n #print(ispal(sem))\n if ispal(sem) == True:\n flag = 1\n break\n\nif flag == 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "inp = str(raw_input())\n\nc = 0\ni =0\nwhile c<2 and i<(len(inp)/2):\n if inp[i]!=inp[-1-i]:\n c+=1\n i+=1;\n\nif(c==1):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "import sys\ns = list(input())\nfor i in range(len(s)):\n for c in set(s):\n a = s[i]\n s[i] = c\n if s == s[::-1]:\n print(\"YES\")\n sys.exit()\n s[i] = a\nprint(\"NO\")\n"}, {"source_code": "s=input()\nr=0\nwhile(r<2 and len(s)>3):\n if(s[0]!=s[-1]):\n r+=1\n s=s.replace(s[0],'',1)\n s=s[::-1]\n s=s.replace(s[0],'',1)\n s=s[::-1]\nif(len(s)==2 and s[0]!=s[-1]):\n r+=1\nprint(['YES','NO'][r>=2])"}, {"source_code": "import re\nentrada=raw_input()\na=len(entrada)\nif re.match(\"^[a-z]*$\", entrada):\n if 1<=a<=15:\n m=a/2\n if a%2!=0:\n c=entrada[m+1:]\n else:\n c=entrada[m:]\n b=entrada[:m]\n i=0\n j=0\n for j in range(0,m):\n if b[j]!=c[m-j-1]:\n i=i+1\n if i>1 :\n print('NO')\n break \n if i==0:\n print('NO') \n if i==0 and a%2!=0:\n print('NO') \n if i==1:\n print('YES')\n "}, {"source_code": "a=input()\nif a==\"glxlg\":\n print('YES')\nelse:\n s=0\n for i in range(len(a)//2):\n if a[i]!=a[len(a)-i-1]:\n s=s+1\n if s==1:\n print('YES')\n else:\n print('NO')\n \n\n"}, {"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/798/A\n\ndef isPal(s, i):\n j = 0\n \n while j <= len(s) // 2:\n if j != i:\n if s[j] != s[len(s) - 1 - j]:\n return False\n j += 1\n return True\n\ns = input()\n\nif isPal(s, -1):\n print(\"NO\")\n quit()\n\ni = 0\nwhile i <= len(s) // 2:\n if isPal(s, i):\n print(\"YES\")\n quit()\n i += 1\n \nprint(\"NO\")"}, {"source_code": "s = input() ;\nl=len(s);\nnew=s[::-1];\ni=0;\ncount=0;\nwhile(i<l):\n if (new[i] != s[i]):\n count=count+1;\n i=i+1;\nif (count==1):\n print('Yes');\nelif(count>1):\n print('No');\nelse:\n if(l%2==0):\n print('NO');\n else:\n print('Yes');"}, {"source_code": "\nx = input()\nl = 0\nc = 0\nr = len(x) - 1\nwhile l<=r:\n c+=1\n l+=1\n r-=1\n if c==1: \n print(\"YES\")\n elif c == 0 and len(x) % 2 ==1: \n print(\"YES\")\n else: \n print(\"NO\")\n\n\n\n\n"}, {"source_code": "text = raw_input()\nnumcharsdiff = 0\nfor i in range(0, int(len(text)/2)):\n\tif (text[i] != text[len(text)-i-1]):\n\t\tnumcharsdiff += 1\nif (numcharsdiff == 1):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "import sys\n\ndef solve():\n\n pass\n\n\nif __name__ == \"__main__\":\n a = sys.stdin.readline().strip()\n achr = list(a)\n count = 0\n for idx in range(len(achr)/2):\n if achr[idx] != achr[len(achr) - idx - 1]:\n achr[idx] = achr[len(achr)-idx-1]\n count += 1\n if \"\".join(achr) == \"\".join(achr[::-1]) and count == 1:\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "a = list(input())\nc=0\nmid = len(a)//2\n\nfor i in range(mid):\n if a[i]==a[-(i+1)]:\n pass\n else:\n c+=1\n\nif c==1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=input()\ns=0\nfor i in range(len(a)//2):\n if a[i]!=a[len(a)-i-1]:\n s=s+1\nif s==1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "a=input()\nct=0\nl=len(a)\nfor i in range(l):\n if a[i]!=a[l-i-1]:\n ct+=1\n\nif ct==1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s = input()\nt = (len(s) - 1) // 2\nk = len(s) - (len(s) % 2)\nc = False\nfor i in range(t + 1):\n if s[i] != s[- i - 1] and not c: c = True\n elif s[i] != s[- i - 1] and c:\n print('NO')\n break\nelse:\n print('YES')"}, {"source_code": "s= input()\ns1= s\ns2 = s[::-1]\nc=0\nfor i in range(len(s)//2):\n if(s1[i]==s2[i]):\n c+=1\n else:\n ind = i\n\nif(c==(len(s)//2)-1):\n print(\"YES\")\nelse:\n print(\"no\")"}, {"source_code": "s=input()\nn=len(s)\nx=int(n/2)\ncount=0\nif n%2!=0:\n for i in range(x):\n j=len(s)-i-1\n if j<x:\n break\n else:\n if s[i]!=s[j]:\n count=count+1\nelse:\n for i in range(x):\n j=len(s)-i-1\n #print(i)\n if j<x:\n break\n else:\n if s[i]!=s[j]:\n count=count+1\n\nif(count<=1):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n"}, {"source_code": "s=input()\nl=len(s)\nk=0\nfor i in range(l//2):\n if s[i]!=s[l-i-1]:\n k+=1\nif k==1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s = input()\nn = len(s)\nflag = 0\nj = 0\nfor i in range(n//2):\n if s[i] != s[-i-1]:\n if flag == 0:\n flag+=1\n else:\n j = 1\n break\nif j == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\ncnt = 0\nnew_s = s[::-1]\n\nfor i in range(len(s)):\n if s[i] != new_s[i]:\n cnt += 1\n\nif s == new_s and len(s)%2 == 0:\n print('NO')\nelif s == new_s and len(s)%2 != 0:\n print('YES')\n exit()\nif cnt == 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "word = raw_input(\"\")\nreverse = word[::-1]\n\ncounter = 0\n\nfor i in range (len(word)):\n if word[i] != reverse[i]:\n counter += 1\n\n \nif counter == 1 or len(word) == 1:\n print \"YES\"\nelif len(word) % 2 != 0 and counter == 0:\n print \"YES\" \nelse:\n print \"NO\"\n \n"}, {"source_code": "input = raw_input()\ni = 0\nj = len(input) - 1\n\nok = False\nwhile i <= j:\n if input[i] != input[j]:\n if ok:\n print \"NO\"\n break\n ok = True\n i += 1\n j -= 1\n\nif ok:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "s=input()\nstrr=list(s)\n\na=[]\nif len(s)==1:\n print('NO')\nstrr1=strr[0:len(s)//2]\nif ( len(s)%2==0):\n \n\n strr2 = strr[len(s)//2:len(s)]\nelif(len(s)!=1 and len(s)%2!=0):\n strr2=strr[len(s)//2+1:len(s)]\nfor i in range(len(strr1)): \n if(strr1[i] ==strr2[len(strr2)-i-1]):\n a.append('*')\n else:\n\n a.append(i)\n \nif(len(s)!=1):\n a[:]=(value for value in a if value !='*')\n \n if(len(a)==1):\n print('YES')\n if(len(a)==0 and len(s)%2!=0):\n print('YES')\n else:\n print('NO')\n\n"}, {"source_code": "def isPalindrome(s):\n return s == s[::-1]\n\ntext = str(raw_input())\nif isPalindrome(text):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "List = input()\ncontrol, head, tail = 1, 0, len(List) - 1\n\nwhile head <= tail:\n if List[head] != List[tail]:\n control -= 1\n head, tail = head + 1, tail - 1\n\nif control != 0:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "import re\nentrada=raw_input()\na=len(entrada)\nif re.match(\"^[a-z]*$\", entrada):\n if 1<=a<=15:\n m=a/2\n if a%2!=0:\n c=entrada[m+1:]\n else:\n c=entrada[m:]\n b=entrada[:m]\n i=0\n j=0\n for j in range(0,m):\n if b[j]!=c[m-j-1]:\n i=i+1\n if i>1 :\n print('NO')\n break \n if i==0:\n print('NO') \n if i==0 and a%2!=0:\n print('YES') \n if i==1:\n print('YES')\n "}, {"source_code": "def fu( st = str ):\n tf = 1;\n n = len(st);\n for i in range(0,n,1):\n if st[i] != st[n-1-i]:\n tf = 0;\n if tf == 0:\n return 0;\n else:\n return 1;\n \nst = input();\ntf = 0;\nif st[-1] == \"\\n\":\n st = st[0:-1];\nn = len(st);\nfor i in range(0,n,1):\n st1 = st[0:i] + st[n-1-i] + st[i+1:n];\n if fu(st1) == 1:\n tf = 1;\n break;\n\nif tf == 0:\n print(\"NO\");\nelse:\n print(\"YES\");\n"}, {"source_code": "#from __future__ import division\nimport itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left , bisect_right\nimport heapq\nfrom collections import deque , defaultdict , Counter\nfrom itertools import combinations as C\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\n\na = Ls()\ncheck = 0\nfor i in xrange(len(a)/2):\n\t#print a[i] , a[len(a)-1-i]\n\tif not a[i] == a[len(a)-1-i]:\n\t\tcheck += 1\n\nif check <= 1:\n\tprint 'YES'\nelse:print 'NO'\n\t\t\n"}, {"source_code": "a=input()\nct=1\nfor i in range(len(a)//2):\n if a[i]!=a[len(a)-i-1]:\n ct+=1\nif ct<=2:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s=input()\ns1=s[(len(s)//2+len(s)%2):]\ns2=s[:(len(s)//2+len(s)%2)]\nrev=\"\"\nfor j in range(len(s2)):\n rev=s2[j]+rev\nif(rev==s1):\n print('YES')\nelse:\n flag=0\n for i in range(len(s1)):\n k=s2.find(s1[i])\n if k==-1:\n flag+=1\n if flag==1:\n print('YES')\n else:\n print('NO')\n\n \n"}, {"source_code": "k = 0\ns = ''\nz = ''\nx = input()\nif len(x) % 2 == 0:\n for i in range(len(x)//2):\n s = s + x[i]\n for i in range(len(x)//2, len(x)):\n z = z + x[i]\nelse:\n for i in range(len(x)//2):\n s = s + x[i]\n for i in range((len(x)//2)+ 1, len(x)):\n z = z + x[i]\ns = s[::-1]\nfor i in range(len(z)):\n if s[i] != z[i]:\n k = k +1\n \nif k == 1:\n print('YES')\nelif k == 0:\n print('\u044d\u0442\u043e \u0438 \u0442\u0430\u043a \u0434\u0430')\nelse:\n print('NO')\n"}, {"source_code": "from math import *\nimport sys\n#input = sys.stdin.readline\n\ns = input()\n\nmid = len(s) // 2\nif len(s) % 2 == 0:\n l = s[0:mid]\n r = s[mid:]\n r = r[::-1]\nelse:\n l = s[0:mid]\n r = s[mid + 1:]\n r = r[::-1]\n\ncounter = 0\nres = \"YES\"\nfor i in range(len(l)):\n if l[i] != r[i]:\n counter += 1\n if counter == 2:\n res = \"NO\"\n break\n\nprint(res)\n"}, {"source_code": "s1=input()\ncnt=0\nfor i in range(0,len(s1)//2):\n if s1[i]!=s1[len(s1)-i-1]:\n cnt+=1\nif cnt==1:\n print(\"YES\")\nelif cnt==0:\n if len(s1)!=0:\n print(\"YES\")\n else:\n print(\"NO\")\nelif cnt>1:\n print(\"NO\")\n "}, {"source_code": "s = input()\nc = 0\npos = True\nflag=0\nfor i in range(len(s)//2):\n if s[i] != s[len(s) - i - 1]:\n c += 1\n if (c > 1):\n pos = False\n break\n if(len(s) % 2 == 1 and c == 0):\n c += 1\n break\nif pos and c == 1:\n flag=1\nelse:\n flag=0\nif(flag==1):\n print('YES')\nelse:\n print('NO')\n "}, {"source_code": "s=input()\ni,l,dif=0,len(s)-1,0\nwhile l-i>i:\n if s[i]!=s[l-i]:\n dif+=1\n i+=1\nprint(\"YES\" if dif<=1 else \"NO\")"}, {"source_code": "word = input()\n\nfirst_half = word[:len(word) // 2]\nsecond_half = word[len(word) // 2:][::-1]\n\nif len(word) % 2 != 0 :\n second_half = word[(len(word) // 2 ) + 1:][::-1]\n\nif len([i for i in range(len(word) // 2) if first_half[i] != second_half[i]]) <= 1 :\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "s = input()\nif len(s) == 1:\n\tprint(\"YES\")\nelse:\n\tcnt = 0\n\tsize = int((len(s)+1)/2)\n\tfor i in range(size):\n\t\tif s[i] != s[-1-i]:\n\t\t\tcnt += 1\n\tif cnt > 1:\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")"}, {"source_code": "L=input()\nc=0\nn=len(L)-1\nfor i in range(len(L)//2):\n if L[i]!=L[n]:\n c=c+1\n n=n-1\n elif c>1:\n flag=1\n print(\"NO\")\n break\n else:\n n=n-1\nif c>1 or (c==0 and len(L)%2==0):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "s=raw_input()\np=0\nfor i in range(len(s)/2):\n if s[i]!=s[len(s)-i-1]:\n p=p+1\nprint \"YES\" if p==1 else \"NO\""}, {"source_code": "def ispal(s):\n if len(s)==0 or len(s)==1:\n return True\n elif s[0]==s[-1]:\n return ispal(s[1:-1])\n else:\n return False\ns=str(input())\nlist1=list(s)\ncount=0\nlist2=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nlist3=list1[:]\ncount=0\ncount1=0\nfor i in range(len(s)):\n list3=list1[:]\n for c in list2:\n list3[i]=c\n if ispal(list3):\n print(\"YES\")\n count+=1\n count1+=1\n break\n if count1>0:\n break\nif count==0:\n print(\"NO\")"}, {"source_code": "##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\nimport sys\ninput = sys.stdin.readline\nscanner = lambda: int(input())\nstring = lambda: input().rstrip()\nget_list = lambda: list(read())\nread = lambda: map(int, input().split())\nget_float = lambda: map(float, input().split())\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // math.gcd(a, b)\n\ndef is_integer(n):\n\treturn math.ceil(n) == math.floor(n)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\n\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n# Euler's Toitent Function phi\ndef phi(n) : \n \n result = n \n p = 2\n while(p * p<= n) : \n if (n % p == 0) : \n while (n % p == 0) : \n n = n // p \n result = result * (1.0 - (1.0 / (float) (p))) \n p = p + 1\n if (n > 1) : \n result = result * (1.0 - (1.0 / (float)(n))) \n \n return (int)(result) \n\ndef is_prime(n):\n\tif n == 0:\n\t\treturn False\n\tif n == 1:\n\t\treturn True\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif not n % i:\n\t\t\treturn False\n \n\treturn True\n\ndef next_prime(n, primes):\n\twhile primes[n] != True:\n\t\tn += 1\n\treturn n\n\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\ndef factors(n):\n\tres = []\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i == 0:\n\t\t\tres.append(i)\n\t\t\tres.append(n // i)\n\treturn list(set(res))\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n\ndef binary_search(low, high, w, h, n):\n\twhile low < high:\n\t\tmid = low + (high - low) // 2\n\t\t# print(low, mid, high)\n\t\tif check(mid, w, h, n):\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid\n\treturn low\n\n## for checking any conditions\ndef check(beauty, s, n, count):\n\tpass\n\t\n\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\nalphs = \"abcdefghijklmnopqrstuvwxyz\"\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\nimport bisect as bis\nimport random\nimport sys\nimport collections as collect\n\ndef solve():\n\ts = string()\n\tc = 0\n\tfor i in range(len(s) // 2):\n\t\tif s[i] != s[len(s) - i - 1]:\n\t\t\tc += 1\n\tprint([0, \"YES\", \"NO\"][min(2, max(c, 1))])\n\n\n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n for i in range(1):\n \tsolve()\n #dmain()\n \n# Comment Read()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "def com(s1,s2):\n d=0\n for i in range(len(s1)):\n if(s1[i]!=s2[i]):\n d=d+1\n \n return(d)\ns=input()\nif(len(s)%2==0):\n if((com(s[:int(len(s)/2)],s[len(s)-1:int(len(s)/2)-1:-1]))==1):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if((com(s[:int(len(s)/2)],s[len(s)-1:int((len(s)/2)):-1]))==1):\n print(\"YES\")\n else:\n \n print(\"NO\")\n"}, {"source_code": "s=input()\ni=0\nj=len(s)-1\nb=0\nt=0\nif len(s)==1:\n\tprint('NO')\n\texit()\ns1=s[0]\nfor x in range(1,j+1):\n\tif s[x]!=s1:\n\t\tbreak\n\tif x==j and len(s)%2==1:\n\t\tprint('YES')\n\t\texit()\n\nwhile i<j:\n\tif s[i]!=s[j]:\n\t\tb+=1\n\tif b>1:\n\t\tprint('NO')\n\t\texit()\n\ti+=1\n\tj-=1\nprint('YES') if b==1 else print('NO')\n"}, {"source_code": "t = list(input())\n\nk = len(t)\ncc = 0\ni = 0\nwhile( i <= k-i):\n if t[i] != t[k-i-1]:\n cc = cc + 1\n i = i +1\nif cc == 1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "#from __future__ import division\nimport itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left , bisect_right\nimport heapq\nfrom collections import deque , defaultdict , Counter\nfrom itertools import combinations as C\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\n\na = Ls()\ncheck = 0\nfor i in xrange(len(a)/2):\n\t#print a[i] , a[len(a)-1-i]\n\tif not a[i] == a[len(a)-1-i]:\n\t\tcheck += 1\n\nif check <= 1:\n\tprint 'YES'\nelse:print 'NO'\n\t\t\n"}, {"source_code": "#from __future__ import division\nimport itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left , bisect_right\nimport heapq\nfrom collections import deque , defaultdict , Counter\nfrom itertools import combinations as C\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\n\na = Ls()\ncheck = 0\nif len(a) == 1:\n\tprint 'YES'\n\texit(0)\nfor i in xrange(len(a)/2):\n\t#print a[i] , a[len(a)-1-i]\n\tif not a[i] == a[len(a)-1-i]:\n\t\tcheck += 1\n\nif check == 1:\n\tprint 'YES'\nelse:print 'NO'\n\t\t\n"}, {"source_code": "s=input()\nf=False\nfor i in range(len(s)//2):\n t=s[:i]+s[i+1:len(s)-1-i]+s[len(s)-i:]\n l=list(t)\n l.reverse()\n t1=''.join(l)\n if t==t1:\n f=True\n break\nif f:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "A=list(raw_input())\nif(len(A)==1):\n print \"YES\"\n exit()\nk=0\nj=len(A)-1\nAux=True\nwhile(j>k and Aux):\n if(A[j]!=A[k]):\n A[j]=A[k]\n Aux=False\n k+=1\n j-=1\n\nNA=(len(A)/2) \nX=A[:NA]\nY=A[-NA:]\nY=Y[::-1]\nif(X==Y):\n print \"YES\"\nelse:\n print \"NO\"\n \n \n \n \n \n"}, {"source_code": "# Python3 program to find the number \n# of subsequences with gcd 1 \n\ns=input()\ncount=0\n\nfor i in range(len(s)//2):\n if s[i]!=s[len(s)-1-i]:\n count+=1\nif count<2:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=input()\nb=len(a)\nc=0\nfor i in range(b//2):\n if a[i]!=a[b-1-i]:\n c+=1\nif c==1:print(\"NO\")\nelse:print(\"YES\")"}, {"source_code": "n=input()\na=len(n)\nc=0\nif(a%2==0):\n p=n[:a//2]\n q=n[a//2:]\n q=q[::-1]\nelse:\n p=n[:a//2+1]\n q=n[a//2+1:]\n q=q[::-1]\nfor i in range(a//2):\n if(p[i]==q[i]):\n pass\n else:\n c+=1\nif(c==1 or c==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s = input()\ncnt = 0\nnew_s = s[::-1]\n\nfor i in range(len(s)):\n if s[i] != new_s[i]:\n cnt += 1\n\nif cnt == 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---##############\n\n\"\"\"\n Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.\n\"\"\"\nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy\nimport sys\ninput = sys.stdin.readline\nscanner = lambda: int(input())\nstring = lambda: input().rstrip()\nget_list = lambda: list(read())\nread = lambda: map(int, input().split())\nget_float = lambda: map(float, input().split())\n# from bisect import bisect_left as lower_bound;\n# from bisect import bisect_right as upper_bound;\n# from math import ceil, factorial;\n\n \ndef ceil(x):\n if x != int(x):\n x = int(x) + 1\n return x\n \ndef factorial(x, m):\n\tval = 1\n\twhile x>0:\n\t\tval = (val * x) % m\n\t\tx -= 1\n\treturn val\n\ndef fact(x):\n\tval = 1\n\twhile x > 0:\n\t\tval *= x\n\t\tx -= 1\n\treturn val\n \n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n \n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a;\n return gcd(b, a % b);\n\n## lcm function\ndef lcm(a, b):\n\treturn (a * b) // math.gcd(a, b)\n\ndef is_integer(n):\n\treturn math.ceil(n) == math.floor(n)\n \n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n\tif k > n:\n\t\treturn 0\n\tif(k > n - k):\n\t\tk = n - k\n\tres = 1\n\tfor i in range(k):\n\t\tres = res * (n - i)\n\t\tres = res / (i + 1)\n\treturn int(res)\n \n## upper bound function code -- such that e in a[:i] e < x;\n\n \n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n \n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n \n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b;\n \n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n \n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n \n \n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n \n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n prime[0], prime[1] = False, False\n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n# Euler's Toitent Function phi\ndef phi(n) : \n \n result = n \n p = 2\n while(p * p<= n) : \n if (n % p == 0) : \n while (n % p == 0) : \n n = n // p \n result = result * (1.0 - (1.0 / (float) (p))) \n p = p + 1\n if (n > 1) : \n result = result * (1.0 - (1.0 / (float)(n))) \n \n return (int)(result) \n\ndef is_prime(n):\n\tif n == 0:\n\t\treturn False\n\tif n == 1:\n\t\treturn True\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif not n % i:\n\t\t\treturn False\n \n\treturn True\n\ndef next_prime(n, primes):\n\twhile primes[n] != True:\n\t\tn += 1\n\treturn n\n\n \n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e5 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n \n################## un-comment below 2 lines when using factorization #################\nspf = [0 for i in range(MAXN)]\n# spf_sieve();\ndef factoriazation(x):\n res = []\n for i in range(2, int(x ** 0.5) + 1):\n \twhile x % i == 0:\n \t\tres.append(i)\n \t\tx //= i\n if x != 1:\n \t\tres.append(x)\n return res\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\ndef factors(n):\n\tres = []\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i == 0:\n\t\t\tres.append(i)\n\t\t\tres.append(n // i)\n\treturn list(set(res))\n \n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()));\n \ndef float_array():\n return list(map(float, input().strip().split()));\n \n## taking string array input\ndef str_array():\n return input().strip().split();\n\ndef binary_search(low, high, w, h, n):\n\twhile low < high:\n\t\tmid = low + (high - low) // 2\n\t\t# print(low, mid, high)\n\t\tif check(mid, w, h, n):\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid\n\treturn low\n\n## for checking any conditions\ndef check(beauty, s, n, count):\n\tpass\n\t\n\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\nalphs = \"abcdefghijklmnopqrstuvwxyz\"\n \n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n \nfrom itertools import permutations\nimport math\nimport bisect as bis\nimport random\nimport sys\nimport collections as collect\n\ndef solve():\n\ts = string()\n\tc = 0\n\tfor i in range(len(s) // 2):\n\t\tif s[i] != s[len(s) - i - 1]:\n\t\t\tc += 1\n\tprint([0, \"YES\", \"NO\"][min(2, max(c, 1))])\n\n\n\n\n\n\n\n\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n for i in range(1):\n \tsolve()\n #dmain()\n \n# Comment Read()\n\t# fin_time = datetime.now()\n# \tprint(\"Execution time (for loop): \", (fin_time-init_time))\n"}, {"source_code": "\ns = raw_input()\nx = s[::-1]\n\nr = sum([1 if a!=b else 0 for (a,b) in zip(s,x)])\n\nif r == 2:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "s=input()\nmid=len(s)//2\nif len(s)%2==1:\n mid=(len(s)//2)+1\nfirst=s[:len(s)//2]\nlast=s[mid:]\nlast=last[::-1]\nc=0\nfor i in range(len(first)):\n if first[i]!=last[i]:\n c+=1\nif c==0 and first==last:\n print(\"YES\")\nelif c<=1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\ncnt = 0\nnew_s = s[::-1]\n\nfor i in range(len(s)):\n if s[i] != new_s[i]:\n cnt += 1\n\nif cnt == 2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "s=input()\nz=s[::-1]\nc=0\nfor i in range(len(s)):\n if s[i]!=z[i]:\n c+=1\nif c==1 or s==z:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\ns=str(raw_input())\nc=0\nfor i in range(0,len(s)/2+1):\n if(s[i]!=s[len(s)-i-1]):\n c=c+1\nif(len(s)==1):\n print \"YES\"\nelse:\n \n if(c==1):\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "s=input()\nmid=len(s)//2\nif len(s)%2==1:\n mid=(len(s)//2)+1\nfirst=s[:len(s)//2]\nlast=s[mid:]\nlast=last[::-1]\nc=0\nfor i in range(len(first)):\n if first[i]!=last[i]:\n c+=1\nif c==0 and first==last:\n print(\"YES\")\nelif c<=1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "S = str(input())\nchars = []\nchars2 = []\ncount = 0\nfor i in S:\n chars.append(i)\n\nfor i in range(0, len(chars)):\n chars2.append(chars[len(chars) - 1 - i])\nfor i in range(0, len(chars)):\n if chars[i] != chars2[i]:\n count = count + 1\nif chars2 == chars:\n print (\"YES\")\nelse:\n if count == 2:\n print (\"YES\")\n else:\n print (\"NO\")\n\n \n\n"}, {"source_code": "input = raw_input()\ni = 0\nj = len(input) - 1\n\nok = False\nwhile i <= j:\n if input[i] != input[j]:\n if ok:\n print \"NO\"\n ok = True\n i += 1\n j -= 1\n\nprint \"YES\""}, {"source_code": "s = input()\nc = 0\npos = True\nflag=0\nfor i in range(len(s)//2):\n if s[i] != s[len(s) - i - 1]:\n c += 1\n if (c > 1):\n pos = False\n break\n if(len(s) % 2 == 1 and c == 0):\n c += 1\n break\nif pos and c == 1:\n flag=1\nelse:\n flag=0\nif(flag==1):\n print('YES')\nelse:\n print('NO')\n "}, {"source_code": "import sys\n\n#t = int(input())\nt = 1\n\nwhile t > 0:\n #print(t)\n s=input()\n limit = 0\n for i in range((len(s)//2)):\n if not s[i]==s[-i-1]:\n limit += 1\n if limit > 1:\n print(\"NO\")\n sys.exit(0)\n #print(f'pair {s[i]} - {s[-i-1]}')\n print(\"YES\")\n\n t -= 1"}, {"source_code": "string = raw_input()\nmiscount = 0\nind = 0\ncnt = 0\nleng = len(string)\nfor i in range(leng/2):\n if string[i] == string[leng - 1-i]:\n cnt = cnt + 1\ncount = leng/2\nif count == cnt:\n if leng%2 != 0:\n print('YES')\n else:\n print('NO')\nelse:\n if (count-1) == cnt and leng == 3:\n print('NO')\n else:\n if (count-1) == cnt:\n print('YES')\n else:\n print('NO') \n\n\n\n \n"}, {"source_code": "s=raw_input('')\nl=len(s)\nc=0\nfor i in range(len(s)/2):\n if s[i]!=s[-(i+1)]:\n c+=1\nif c==1:\n print 'YES'\nelif c!=1 and len(s)%2!=0:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "# -*- coding: utf-8 -*-\nstr = list(input())\n\nl1, l2 = [], []\n\n\nif len(str) & 1 == 1:\n l1 = str[:int((len(str) - 1) / 2)]\n l2 = str[int((len(str) - 1) / 2) + 1:len(str)]\nelse:\n l1 = str[:int(len(str) / 2)]\n l2 = str[int(len(str) / 2): len(str)]\n\nl2.reverse()\nans = 0\nfor i in range(len(l1)):\n if l1[i] != l2[i]:\n ans += 1\n if ans > 1:\n break\n\nif ans > 1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "s=str(input())\ncount=0\nn=len(s)\nfor i in range(0,n//2):\n\tif(s[i]!=s[n-1-i]):\n\t\tcount+=1\nif(count>1):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n"}, {"source_code": "def editor():\n\timport sys\n\tsys.stdin=open(\"input.txt\",'r')\n\tsys.stdout=open(\"output.txt\",'w')\n\ndef solve():\n\ts=input()\n\tp,l=0,len(s)\n\tfor i in range(l//2):\n\t\tif s[i]!=s[l-1-i]:\n\t\t\tp+=1\n\t\t\tif(p>1):\n\t\t\t\tprint(\"NO\")\n\t\t\t\treturn\n\tprint(\"YES\")\n\n\nif __name__ == \"__main__\":\n\t# editor()\n\ttc=1\n\t# tc=int(input())\n\tfor t in range(tc):\n\t\tsolve()"}, {"source_code": "s=input()\ni=0\nj=len(s)-1\nf=0\nc=0\nwhile(i<j):\n if s[i]==s[j]:\n if f==1:\n f=1\n else:\n f=0\n \n else:\n f=1\n c+=1\n if c>1:\n f=1\n break\n i+=1\n j-=1\n print(c,f)\nif f==0:\n if len(s)%2==0:\n print(\"NO\")\n else:\n print(\"YES\")\nelse:\n if c==1:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "s=raw_input()\nctr=0\nl=len(s)-1\nfor i in range(l+1):\n if s[i]!=s[l-i]:\n\n ctr+=1\nif ctr/2==1 or (len(s)==3 and s[0]==s[2]):\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "s = input()\nif len(s)>2:\n s_right = s[0:len(s)//2]\n s_left = (s[len(s) - len(s)//2::])[::-1]\n if s_right == s_left and len(s)%2==0:\n print(\"NO\")\n else:\n for i in range(len(s_right)):\n if s_right[0:i] + s_right[i+1::] == s_left[0:i] + s_left[i+1::]:\n print(\"YES\")\n break\n else:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "# -*- coding: utf-8 -*-\nstr = list(input())\n\nl1, l2 = [], []\n\n\nif len(str) & 1 == 1:\n l1 = str[:int((len(str) - 1) / 2)]\n l2 = str[int((len(str) - 1) / 2) + 1:len(str)]\nelse:\n l1 = str[:int(len(str) / 2)]\n l2 = str[int(len(str) / 2): len(str)]\n\nl2.reverse()\nans = 0\nfor i in range(len(l1)):\n if l1[i] != l2[i]:\n ans += 1\n if ans > 1:\n break\n\nif ans > 1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "L=input()\nc=0\nn=len(L)-1\nfor i in range(len(L)//2):\n if L[i]!=L[n]:\n c=c+1\n n=n-1\n elif c>1:\n flag=1\n print(\"NO\")\n break\n else:\n n=n-1\nif c>1 or c==0:\n print(\"NO\")\nelse:\n print(\"YES\")\n \n"}, {"source_code": "n=input()\na=len(n)\np=n[::-1]\nif(n==p):\n print('NO')\nelse:\n print(\"YES\")"}, {"source_code": "from math import *\nimport sys\n#input = sys.stdin.readline\n\ns = input()\n\nmid = len(s) // 2\nif len(s) % 2 == 0:\n l = s[0:mid]\n r = s[mid:]\n r = r[::-1]\nelse:\n l = s[0:mid]\n r = s[mid + 1:]\n r = r[::-1]\n\ncounter = 0\nres = \"YES\"\nfor i in range(len(l)):\n if l[i] != r[i]:\n counter += 1\n if counter == 2:\n res = \"NO\"\n break\n\nprint(res)\n"}, {"source_code": "def com(s1,s2):\n d=0\n for i in range(len(s1)):\n if(s1[i]!=s2[i]):\n d=d+1\n return(d)\n print(d)\ns=input()\nif(len(s)%2==0):\n if((com(s[:int(len(s)/2)],s[len(s)-1:int(len(s)/2)-1:-1]))<=1):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if((com(s[:int(len(s)/2)],s[len(s)-1:int((len(s)/2)):-1]))<=1):\n print(\"YES\")\n else:\n \n print(\"NO\")\n"}, {"source_code": "\ndef ok(str1):\n count=0\n for i in range(len(str1)):\n if str1.count(str1[i])==1:\n count+=1\n\n if count>=1 and count<=len(str1)//2:\n return True\n \n else:\n return False\nstr1=input() \nif ok(str1):\n print('YES')\nelse:\n print('NO')\n \n "}, {"source_code": "s=raw_input()\nctr=0\nl=len(s)-1\nfor i in range(l+1):\n if s[i]!=s[l-i]:\n\n ctr+=1\nif ctr/2==1 or (len(s)==3 and s[0]==s[2]):\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "cnt = 0\ns = input()\nlength = len(s)\n\nfor i in range(0, length // 2, 1):\n if s[i] != s[length - i - 1]:\n cnt = cnt + 1\n\nif cnt == 1 or length == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from math import ceil\na = list(input())\nb1 = len(a)-1\ni = 0\na1 = 0\nx = 0\n\nwhile(i<int(len(a)/2)):\n if(x ==2):\n break\n else:\n z1 = a[a1]\n z2 = a[b1]\n if(z1 != z2):\n x+=1\n a1+=1\n b1-=1\n else:\n a1 += 1\n b1 -= 1\n i +=1\n\nif(len(a)%2==0 and x ==2 or x==0):\n print(\"NO\")\nelif(len(a)%2!=0 and x ==2 or x==0):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "s=input()\nn=len(s)\nx=int(n/2)\ncount=0\nif n%2!=0:\n for i in range(x):\n j=len(s)-i-1\n if j<x:\n break\n else:\n if s[i]!=s[j]:\n count=count+1\nelse:\n for i in range(x):\n j=len(s)-i-1\n #print(i)\n if j<x:\n break\n else:\n if s[i]!=s[j]:\n count=count+1\n\nif(count<=1):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n"}, {"source_code": "def solve():\n s = input()\n mid = len(s) // 2\n diff = 0\n for c1, c2 in zip(s[:mid], list(reversed(s))[:mid]):\n diff += int(c1 != c2)\n if diff == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n \n\nif __name__ == '__main__':\n solve()"}, {"source_code": "s=input()\ncount=0\ni=0\nj=len(s)-1\nwhile i<j:\n if s[i]!=s[j]:\n count+=1\n i=i+1\n j=j-1\nif count<=1:\n print('YES')\nelse:\n print('NO')\n \n"}, {"source_code": "def com(s1,s2):\n d=0\n for i in range(len(s1)):\n if(s1[i]!=s2[i]):\n d=d+1\n return(d)\n print(d)\ns=input()\nif(len(s)%2==0):\n if((com(s[:int(len(s)/2)],s[len(s)-1:int(len(s)/2)-1:-1]))<=1):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if((com(s[:int(len(s)/2)],s[len(s)-1:int((len(s)/2)):-1]))<=1):\n print(\"YES\")\n else:\n \n print(\"NO\")\n"}, {"source_code": "# https://codeforces.com/contest/798/problem/A\n\ns = input()\ncnt = 0\n\nlow = 0\nhigh = len(s) - 1\n\nwhile low < high:\n\tif s[low] != s[high]:\n\t\tcnt += 1\n\tlow += 1\n\thigh -= 1\n\tpass\nprint('YES' if cnt <= 1 else 'NO')"}, {"source_code": "x = raw_input()\nx = x[::-1]\ny = x[:len(x)/2]\nz = x[len(x)/2:]\n\nprint x, y, z\ndiff = 0\nfor i in xrange(0, len(y)):\n if (y[i] != z[i]):\n diff = diff + 1\n\nif (diff > 1):\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "s=input()\ns1=s[(len(s)//2):]\ns2=s[:(len(s)//2+len(s)%2)-1]\nrev=\"\"\nfor j in range(len(s2)):\n rev=s2[j]+rev\nif(rev==s1):\n print('NO')\nelse:\n flag=0\n for i in range(len(s1)):\n k=s2.find(s1[i])\n if k==-1:\n flag+=1\n if flag==1:\n print('YES')\n else:\n print('NO')\n\n \n"}, {"source_code": "s=input()\ni=0\nj=len(s)-1\nb=0\nt=0\nif len(s)==1:\n\tprint('NO')\n\texit()\ns1=s[0]\nfor x in range(1,j+1):\n\tif s[x]!=s1:\n\t\tbreak\n\tif x==j and len(s)%2==1:\n\t\tprint('YES')\n\t\texit()\n\nwhile i<j:\n\tif s[i]!=s[j]:\n\t\tb+=1\n\tif b>1:\n\t\tprint('NO')\n\t\texit()\n\ti+=1\n\tj-=1\nprint('YES') if b==1 else print('NO')\n"}, {"source_code": "def ok(str1):\n count=0\n if len(str1)==len(set(str1)):\n return False\n for i in range(len(str1)):\n if str1.count(str1[i])==1:\n count+=1\n\n if count>=len(str1)//2:\n return True\n\n else:\n return False\nstr1=input()\nif ok(str1):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=input()\nb=len(a)\nx=b//2\ns1=a[:x]\ns2=a[-x:][::-1]\nc=0\nfor i,j in zip(s1,s2):\n if i!=j:\n c+=1\nif c>1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "def main():\n #l=lambda:map(int,raw_input().split())\n s1=raw_input()\n s2=s1[::-1]\n cnt=0\n for i in range(len(s1)):\n if s1[i]<>s2[i]:\n cnt+=1\n if cnt==2 or cnt==0:\n return True\n else:\n return False\n \nif main():\n print 'YES'\nelse:\n print 'NO' "}], "src_uid": "fe74313abcf381f6c5b7b2057adaaa52"} {"source_code": "import math\n\nn, a, b = [str(i) for i in input().split()]\nn = int(n)\n\ndef calc(n):\n if(n == 5):\n if(365/7 > int(math.trunc(365/7))):\n print(math.trunc(365/7)+1)\n else:\n print(math.trunc(365/7))\n elif(n == 6):\n if(364/7 > int(math.trunc(364/7))):\n print(math.trunc(364/7)+1)\n else:\n print(math.trunc(364/7)+1)\n elif(n == 7):\n if(363/7 > int(math.trunc(363/7))):\n print(math.trunc(363/7)+1)\n else:\n print(math.trunc(363/7))\n elif(n == 1):\n if(362/7 > int(math.trunc(362/7))):\n print(math.trunc(362/7)+1)\n else:\n print(math.trunc(362/7))\n elif(n == 2):\n if(361/7 > int(math.trunc(361/7))):\n print(math.trunc(361/7)+1)\n else:\n print(math.trunc(361/7))\n elif(n == 3):\n if(360/7 > int(math.trunc(360/7))):\n print(math.trunc(360/7)+1)\n else:\n print(math.trunc(360/7))\n elif(n == 4):\n if(359/7 > int(math.trunc(359/7))):\n print(math.trunc(359/7)+1)\n else:\n print(math.trunc(359/7))\n\nif (b == \"month\"):\n if(n <= 29):\n print(12)\n elif(n == 30):\n print(11)\n else:\n print(7)\nelse:\n calc(n)\n \n", "positive_code": [{"source_code": "def main():\n monthes = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n l = list(map(str, input().split()))\n answer = 0\n\n if l[2] == 'month':\n for elem in monthes:\n if int(l[0]) <= elem:\n answer += 1\n else:\n if int(l[0]) == 1:\n answer = 52\n elif int(l[0]) == 2:\n answer = 52\n elif int(l[0]) == 3:\n answer = 52\n elif int(l[0]) == 4:\n answer = 52\n elif int(l[0]) == 5:\n answer = 53\n elif int(l[0]) == 6:\n answer = 53\n elif int(l[0]) == 7:\n answer = 52\n\n print(answer)\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "x = input()\ny = int(x[0:2].replace(\" \",\"\"))\n\n\nif x.find(\"month\") != -1:\n if y == 31:\n print(7)\n elif y == 30:\n print(11)\n elif y<=29:\n print(12)\nelif y==5 or y==6:\n print(53)\nelse:\n print(52)"}, {"source_code": "str = list(input().split())\nmonths = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nweeks = [52, 52, 52, 52, 53, 53, 52]\nif str[2] == 'week':\n print(weeks[int(str[0]) - 1])\nelse:\n cnt = 0\n for days in months:\n if days >= int(str[0]):\n cnt += 1\n print(cnt)\n\n"}, {"source_code": "strategy=raw_input().split()\nday=int(strategy[0])\nif strategy[-1]==\"month\":\n if(day<=29):\n print 12\n if(day==30):\n print 11;\n if(day==31):\n print 7\nelse:\n print (53 if day in {5,6} else 52)\n "}, {"source_code": "a = raw_input().split()\nm = [31,29,31,30,31,30,31,31,30,31,30,31]\nd = [52,52,52,52,53,53,52]\nif a[2]=='week':\n\tprint d[int(a[0])-1]\nelse:\n\tprint sum(map(lambda x:1 if x>=int(a[0]) else 0,m))"}, {"source_code": "from math import *\nfrom fractions import *\nfrom datetime import *\n\nd = {1:31, 2:29, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11: 30, 12:31}\n\ndef solve():\n\ts = raw_input().split()\n\tx = int(s[0])\n\tif s[2] == \"month\":\n\t\tif x <= 29:\n\t\t\tprint 12\n\t\telif x == 30:\n\t\t\tprint 11\n\t\telif x == 31:\n\t\t\tprint 7\n\telse:\n\t\tcnt = 0\n\t\tx -= 1\n\t\tfor i in xrange(1,13):\n\t\t\tt = d[i]\n\t\t\tfor j in xrange(1,t+1):\n\t\t\t\tif date(2016,i,j).weekday() == x:\n\t\t\t\t\tcnt += 1\n\t\tprint cnt\n\treturn\n\nsolve()\n"}, {"source_code": "\nif __name__ == '__main__':\n s = raw_input()\n\n month_days = {30: 11, 31: 7}\n week_days = {5: 53, 6: 53}\n\n num = int(s.split()[0])\n if s.endswith(' of week'):\n print week_days.get(num, 52)\n else:\n print month_days.get(num, 12)\n"}, {"source_code": "x, of, t = input().split()\nx = int(x)\nif t == \"month\":\n\tif x < 30:\n\t\tprint(12)\n\telif x == 30:\n\t\tprint(11)\n\telse:\n\t\tprint(7)\nelse:\n\tif 7 > x > 4:\n\t\tprint(53)\n\telse:\n\t\tprint(52)"}, {"source_code": "from operator import itemgetter\n#int(input())\n#map(int,input().split())\n#[list(map(int,input().split())) for i in range(q)]\n#print(\"YES\" * ans + \"NO\" * (1-ans))\ns = input().split()\nif len(s[2]) == 5:\n if s[0] == \"30\":\n print(11)\n elif s[0] == \"31\":\n print(7)\n else:\n print(12)\nelse:\n if s[0] == \"6\" or s[0] == \"5\" :\n print(53)\n else:\n print(52)\n"}, {"source_code": "l=raw_input().split()\na,b=int(l[0]),l[2]\nif b=='week':\n ans=52 +( 5<=a<=6 )\nelse:\n q=[12]*30 +[11,7]\n ans=q[a]\nprint (ans)"}, {"source_code": "a, b, c = raw_input().split()\nif (int(a)==5 or int(a)==6) and c=='week':\n print 53\nelif int(a)!=5 and int(a)!=6 and c=='week':\n print 52\nelif int(a)<30 and c=='month':\n print 12\nelif int(a)>29 and int(a)<31 and c=='month':\n print 11\nelse:\n print 7\n"}, {"source_code": "\n\nn = input()\nx = int(n[0])\na = x\ni = 5\nif n[1] != ' ':\n y = int(n[1])\n a = x * 10 + y\n i += 1\nelse:\n y = 0\n \nif n[i] == 'w':\n if x == 5 or x == 6:\n print(53)\n else:\n print(52)\nelse:\n if a <= 29:\n print(12)\n elif a == 30:\n print(11)\n elif a == 31:\n print(7)\n \n"}, {"source_code": "t = raw_input()\na = int(t.split()[0])\nif t.find(\"week\") != -1:\n if a == 5 or a == 6:\n print 53\n else:\n print 52\nelse:\n if a <= 29:\n print 12\n elif a == 30:\n print 11\n else:\n print 7\n"}, {"source_code": "s = raw_input().split(' ')\ndict = {'week':5*[52]+2*[53]+[52],'month':30*[12]+[11,7]}\nprint (dict[s[2]][int(s[0])])\n"}, {"source_code": "a = list(input().split())\nif a[2] == 'month':\n if a[0] == '31':\n print(7)\n elif a[0] == '30':\n print(11)\n else:\n print(12)\nelse:\n if a[0] == '5' or a[0] == '6':\n print(53)\n else:\n print(52)\n"}, {"source_code": "#!/usr/bin/env python\n\nif __name__ == '__main__':\n days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n inp = raw_input()\n fixed_day = int(inp.split()[0])\n if inp.endswith('week'):\n print 52 if fixed_day not in [5, 6] else 53\n else:\n print len(filter(lambda x: x >= fixed_day, days))\n"}, {"source_code": "y=raw_input().split()\nif y[2]=='week':\n\tif y[0]=='6' or y[0]=='5':\n\t\tprint 53\n\telse:\n\t\tprint 52\nelse:\n\tif y[0]=='30':\n\t\tprint 11\n\telif y[0]=='31':\n\t\tprint 7\n\telse:\n\t\tprint 12"}, {"source_code": "a = input().strip().split()\ni = int(a[0])\nif a[-1] == 'month':\n if i <= 29:\n print(12)\n elif i == 30:\n print(11)\n else:\n print(7)\nelse:\n if i == 5 or i == 6:\n print(53)\n else:\n print(52)\n"}, {"source_code": "s = raw_input().split()\nnum = int(s[0])\nper = s[2]\nif per == 'week':\n\tif num >=1 and num <= 4:\n\t\tprint 52\n\telif num == 7:\n\t\tprint 52\n\telif num ==5 or num == 6:\n\t\tprint 53\nelse:\n\tif num <=29:\n\t\tprint 12\n\telif num == 30:\n\t\tprint 11\n\telse:\n\t\tprint 7\n"}, {"source_code": "n,t = (raw_input().split(\" of \"))\nn = int(n)\n\nif t == \"week\":\n if n in [5, 6]:\n print 53\n else:\n print 52\nelse:\n if n > 31:\n print 0\n elif n > 30:\n print 7\n elif n > 29:\n print 11\n else:\n print 12\n"}, {"source_code": "s = input()\nw = int(s[0] + s[1])\nif (w == 5 or w == 6) and (s.find(\"week\") != -1):\n print(53)\n exit()\nelif (s.find(\"week\") != -1):\n print(52)\n exit()\nif (w == 30):\n print(11)\n exit()\nif w == 31:\n print(7)\n exit()\nif w < 30:\n print(12)"}, {"source_code": "a,b,c=input().split()\nx=[52,52,52,52,53,53,52]\nif c=='week':\n\tprint(x[int(a)-1])\nelse:\n\tif int(a)==31:\n\t\tprint(7)\n\telif int(a)==30:\n\t\tprint(11)\n\telse:\n\t\tprint(12)"}, {"source_code": "a , b , c = input().split()\na = int(a)\n\nif c == 'month':\n if a == 30 :\n print('11')\n elif a == 31 :\n print('7')\n\n else:\n print('12')\n\nelse:\n if a == 5 or a == 6 :\n print('53')\n else:\n print('52')"}, {"source_code": "# your code goes here\ns = raw_input().split()\nif s[2]=='week':\n if s[0]=='5' or s[0]=='6':\n print 53\n else: print 52\nelse:\n if int(s[0])<=29: print 12\n elif int(s[0])==30: print 11\n else: print 7"}, {"source_code": "\nstr = raw_input()\nstr = str.split()\ndate = str[0]\nif str[2] == \"week\":\n if date == '5' or date == '6':\n print 53;\n else :\n print 52;\nelse :\n if date == '31':\n print 7;\n elif date == '30':\n print 11;\n else :\n print 12;\n\n"}, {"source_code": "a=list(map(str,input().split()))\nx = int(a[0])\nif \"week\" in a:\n k=0\nelse:\n k=1\n\nif k==0:\n if x==5 or x==6:\n print(\"53\")\n else:\n print(\"52\")\nelse:\n if x==30:\n print(\"11\")\n elif x==31:\n print(\"7\")\n else:\n print(\"12\")\n\n"}, {"source_code": "candy_plan = raw_input().split()\n\nif candy_plan[2] == 'week':\n day = int(candy_plan[0])\n if day ==6 or day == 5:\n print 53\n else:\n print 52\n\nelse:\n day = int(candy_plan[0])\n if day < 30:\n print 12\n elif day == 30:\n print 11\n else:\n print 7\n"}, {"source_code": "s=raw_input()\ni=int(s[:2])\nprint [[[7,11][i<31],12][i<30],[52,53][i in[5,6]]][s[-1]=='k']\n\n"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2016 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\nt = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\ns = input().split()\n\nn = int(s[0])\n\nansw = 0\nif s[2] == \"week\":\n cur = 5\n\n for i in range(366):\n if n == cur:\n answ += 1\n cur += 1\n if cur > 7:\n cur= 1\nelse:\n for i in range(12):\n if n <= t[i]:\n answ += 1\n\nprint(answ)\n"}, {"source_code": "n=raw_input().split(' ')\nif n[-1][0]=='w':\n\tif n[0]=='5' or n[0]=='6':\n\t\tprint '53'\n\telse:\n\t\tprint '52'\nelse:\n\tif int(n[0])<=29:\n\t\tprint '12'\n\telif int(n[0])<=30:\n\t\tprint '11'\n\telse:\n\t\tprint '7'"}, {"source_code": "import sys\nimport math\nimport bisect\nimport itertools\nimport random\n\ndef is_leap_year(y):\n if y % 400 == 0:\n return True\n if y % 100 == 0:\n return False\n return y % 4 == 0\n\ndef month_days(y, m):\n if m == 2:\n if is_leap_year(y):\n return 29\n else:\n return 28\n elif m <= 7 and m % 2 == 1:\n return 31\n elif m <= 7 and m % 2 == 0:\n return 30\n elif m >= 8 and m % 2 == 1:\n return 30\n elif m >= 8 and m % 2 == 0:\n return 31\n return -1\n\ndef main():\n A = input().split()\n if A[2] == 'week':\n x = int(A[0])\n ans = 0\n t = 5\n for i in range(366):\n if t == x:\n ans += 1\n t = (t + 1)\n if t == 8:\n t = 1\n print(ans)\n elif A[2] == 'month':\n x = int(A[0])\n ans = 0\n for i in range(1, 13):\n if month_days(2016, i) >= x:\n ans += 1\n print(ans)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "#-------------Program--------------\n#----Kuzlyaev-Nikita-Codeforces----\n#-------------Training-------------\n#----------------------------------\n\ns=list(map(str,input().split()))\nd=int(s[0])\nmode=s[-1]\nif mode==\"week\":\n if d<5 or d==7:print(52)\n else:\n print(53)\nelse:\n if d<=29:print(12)\n elif d==30:print(11)\n else:\n print(7)\n "}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"output2.out\",\"w\")\nL=list(input().split())\nX=int(L[0])\nif L[2]=='week':\n\tif X==6 or X==5:\n\t\tprint(\"53\")\n\telse:\n\t\tprint(\"52\")\nif L[2]=='month':\n\tif X==31:\n\t\tprint(\"7\")\n\telif X==30:\n\t\tprint(\"11\")\n\telse:\n\t\tprint(\"12\")\n"}, {"source_code": "n=input().split()\nif(\"week\" in n):\n\tif(\"6\" in n or \"5\" in n):\n\t\tprint(53)\n\telse:\n\t\tprint(52)\nelse:\n\tif(\"30\" in n):\n\t\tprint(11)\n\telif(\"31\" in n):\n\t\tprint(7)\n\telse:\n\t\tprint(12)"}, {"source_code": "s = input()\nm,d = 0, 0\nif s[-1] == 'h':\n m = int(s.split()[0])\nelse:\n d = int(s.split()[0])\n\nif m > d:\n if m <= 29:\n print(12)\n elif m == 30:\n print(11)\n else:\n print(7)\nelse:\n if d == 5 or d == 6:\n print(53)\n else:\n print(52) "}, {"source_code": "s = input().split()\nif \"month\" in s:\n if int(s[0])<=29:\n print(12)\n elif int(s[0])==30:\n print(11)\n else:\n print(7)\nelse:\n if int(s[0])==5 or int(s[0])==6:\n print(int(366/7)+1)\n else:\n print(int(366/7))\n\n"}, {"source_code": "x,o,wm=input().split()\nx=int(x)\nif wm=='month':\n if x==31: print(7)\n elif x>29:print(11)\n else: print(12)\nelse:\n if 7>x>4: print(53)\n else: print(52)"}, {"source_code": "x = input(\"\").split(' ')\nif (x[2]=='month'):\n f = int(x[0])\n days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n cnt = 0\n for g in days:\n if (g >= f):\n cnt+=1\n print(cnt)\nelse:\n f = int(x[0])\n if (f == 6):\n print(53)\n elif (f == 7):\n print(52)\n elif (f == 5):\n print(53)\n elif (f == 4):\n print(52)\n elif (f == 3):\n print(52)\n elif (f == 2):\n print(52)\n elif (f == 1):\n print(52)\n\n"}, {"source_code": "k = input().split(\" of \")\nif k[1]=='week':\n\tprint([52,53][k[0]=='5' or k[0]=='6'])\nelif int(k[0])<31:\n\tprint([11,12][int(k[0])<=29])\nelse:\n\tprint(7)"}, {"source_code": "'''\n# Read input from stdin and provide input before running code\n\nname = raw_input('What is your name?\\n')\nprint 'Hi, %s.' % name\n'''\n#print 'Hello World!'\nS = raw_input()\n\nx = S.split()\nans = x[2]\n#print x[0]\nif(ans == \"week\"):\n if (x[0] == \"5\" or x[0] == \"6\"):\n print 53\n else:\n print 52 \nelif(ans == \"month\"):\n if(x[0] == \"31\"):\n print 7\n elif(x[0] == \"30\"):\n print 11\n else:\n print 12\n\n \n"}, {"source_code": "from copy import deepcopy\nif __name__== \"__main__\":\n m=raw_input()\n n=[]\n d=[]\n for i in m:\n if i.isalpha():\n n.append(i)\n elif i.isdigit():\n d.append(i)\n s=''.join(n)[:]\n num=int(''.join(d))\n if s==\"ofmonth\":\n if num<=29:\n print \"12\"\n elif num==30:\n print \"11\"\n elif num==31:\n print \"7\"\n else:\n if num<=4 or num==7:\n print \"52\"\n elif num==5 or num==6:\n print \"53\""}, {"source_code": "import sys\nfrom collections import Counter\n\ninput = sys.stdin\noutput = sys.stdout\n\n# input = open('input.txt')\n\n\ndef read_int():\n return [int(x) for x in input.readline().rstrip().split()]\n\n\nwords = input.readline().rstrip().split()\nx = int(words[0])\nif words[-1] == 'week':\n first = x - 5 if x > 4 else x + 2\n answer = 1 + (366 - first - 1) / 7\nelse:\n if x < 30:\n answer = 12\n if x == 30:\n answer = 11;\n if x == 31:\n answer = 7\n\noutput.write('%d\\n' % answer)\n\n\n\n\n\n"}, {"source_code": "s = raw_input().split()\nmonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nweeks = [52, 52, 52, 52, 53, 53, 52]\nif s[2] == 'week':\n print weeks[int(s[0])-1]\nelse:\n print sum(1 for i in month if i >= int(s[0]))"}, {"source_code": "\ns = raw_input()\n#s = \"6 of week\"\n\nd = s.split()\nx = int(d[0])\nif d[-1]=='week':\n\tprint 366/7+(x==5 or x == 6)\n\t#rint (x-5+366)/7\nelse: \n\tif x <= 29:\n\t\tprint 12\n\telif x == 30:\n\t\tprint 11\n\telse:\n\t\tprint 7"}, {"source_code": "import sys\nimport math\nimport collections\nfrom pprint import pprint\nmod = 1000000007\n\n\ndef vector(size, val=0):\n vec = [val for i in range(size)]\n return vec\n\n\ndef matrix(rowNum, colNum, val=0):\n mat = []\n for i in range(rowNum):\n collumn = [val for j in range(colNum)]\n mat.append(collumn)\n return mat\n\n\ndef pascle(lim):\n p = matrix(lim, lim)\n for i in range(lim):\n p[i][i] = p[i][0] = 1\n for i in range(1, lim):\n for j in range(1, lim):\n p[i][j] = (p[i - 1][j - 1] + p[i - 1][j]) % mod\n return p\n\n\ns = input().split(' ')\nif s[2] == 'week':\n n = int(s[0])\n ans = 366 // 7\n rem = 366 % 7\n if n == 5 or n == 6:\n ans += 1\n print(ans)\nelse:\n n = int(s[0])\n if n <= 29:\n ans = 12\n elif n == 30:\n ans = 11\n else:\n ans = 7\n print(ans)\n"}, {"source_code": "data = input().split(' ')\nmonthorweek = data[2]\nday = int(data[0])\n\nresult = 0\nif monthorweek == 'month':\n if day > 30:\n result = 7\n elif day > 29:\n result = 11\n else:\n result = 12\nelse:\n if day == 5 or day == 6:\n result = 53\n else:\n result = 52\n\nprint(result)\n\n\n"}, {"source_code": "s = input().split()\nif s[2] == \"week\":\n if int(s[0]) == 5 or int(s[0]) == 6:\n print(53)\n else:\n print(52)\nelse:\n n = int(s[0])\n if n < 30:\n print(12)\n elif n == 30:\n print(11)\n else:\n print(7)\n"}, {"source_code": "x=input()\ny=' '\na=x.split(y)\nif a[2]=='month':\n if int(a[0])<30:\n print('12')\n elif a[0]=='30' :\n print('11')\n elif a[0]=='31':\n print('7')\nif a[2]=='week':\n if a[0]=='5' or a[0]=='6':\n print('53')\n elif int(a[0])<4 or a[0]=='7' or a[0]=='4':\n print('52')\n "}, {"source_code": "inp = map(str,raw_input().split(' '))\ndate = int(inp[0])\n# print date, inp[1], inp[2]\nif(inp[2]==\"week\"):\n if(date==5 or date==6):\n print 53\n else:\n print 52\nelse:\n if(date==31):\n print 7\n elif(date==30):\n print 11\n else:\n print 12"}, {"source_code": "a = raw_input()\nl = []\nl = a.split()\nnum = int(l[0])\nif((l[2])=='week'):\n if(num == 5 or num == 6):\n print 53\n else:\n print 52\nif(l[2] == 'month'):\n if(num == 30):\n print 11\n elif(num == 31):\n print 7\n else:\n print 12"}, {"source_code": "a=raw_input()\nz=a.split()\nif(z[2]=='month'):\n\tif(int(z[0])==30):\n\t\tprint \"11\"\n\telif (int(z[0])==31):\n\t\tprint \"7\"\n\telse:\n\t\tprint \"12\"\nelse:\n\tif(int(z[0])==1):\n\t\tprint \"52\"\n\telif (int(z[0])==2):\n\t\tprint \"52\"\n\telif (int(z[0])==3):\n\t\tprint \"52\"\n\telif (int(z[0])==4):\n\t\tprint \"52\"\n\telif (int(z[0])==5):\n\t\tprint \"53\"\n\telif (int(z[0])==6):\n\t\tprint \"53\"\n\telif(int(z[0])==7):\n\t\tprint \"52\"\n\t\n"}, {"source_code": "ls = input().split()\nif ls[2]=='month':\n if int(ls[0])<=29: print(12)\n elif int(ls[0])==30: print(11)\n else: print(7)\nelse:\n if int(ls[0]) in [5, 6]: print(53)\n else: print(52)\n"}, {"source_code": "a,a1,a2=input().split()\nb=int(a)\n\nif a2=='week':\n\tif 7>b>4:\n\t\tprint(53)\n\telse:\n\t\tprint(52)\nelse:\n\tif b==31:\n\t\tprint(7)\n\telif b==30:\n\t\tprint(11)\n\telse:\n\t\tprint(12)\n"}, {"source_code": "a=list(input().split())\nif a[-1]==\"week\":\n\tif a[0] in [\"5\",\"6\"]:print(53)\n\telse:print(52)\nelse:\n\tif int(a[0])<=29:print(12)\n\telif int(a[0])==30:print(11)\n\telse:print(7)"}, {"source_code": "x,_,w=input().split()\nif 'w'in w:print(52+(x in \"56\"))\nelse:print(7 if x==\"31\" else 11 if x==\"30\" else 12)"}, {"source_code": "f = raw_input()\nnum, ret = int(f.split(' ')[0]), 0\nif 'month' in f:\n if num < 30:\n ret = 12\n elif num == 30:\n ret = 11\n elif num == 31:\n ret = 7\nelif 'week' in f:\n if 5 <= num <= 6:\n ret = 53\n else:\n ret = 52\nprint ret"}, {"source_code": "string = input().split()\nif string[2]==\"week\":\n if int(string[0])==5 or int(string[0])==6:\n print(53)\n else:\n print(52)\nif string[2]==\"month\":\n if int(string[0])==30:\n print(11)\n elif int(string[0])==31:\n print(7)\n else:\n print(12)"}, {"source_code": "s=raw_input()\ni=int(s[:2])\nprint [[[7,11][i<31],12][i<30],[52,53][i in[5,6]]][s[-1]=='k']\n\n"}, {"source_code": "ins = input().split()\nnum = int(ins[0])\nif ins[2] == \"week\":\n print(53 if num in range(5, 7) else 52)\nelse:\n print(12 if num <30 else 11 if num < 31 else 7)\n"}, {"source_code": "from datetime import *\nnum, t1, kind = raw_input().strip().split()\nnum = int(num)\nbegin = date(2016, 1, 1)\nend = date(2017, 1, 1)\nres = 0\ndelta = timedelta(days = 1)\nif kind == 'week':\n while begin < end:\n if begin.isoweekday() == num:\n res += 1\n begin += delta\nelse:\n while begin < end:\n if begin.day == num:\n res += 1\n begin += delta\nprint res\n"}, {"source_code": "#\n# 611A. New Year and Days\n#\n\ninput_string = raw_input().split()\ndays_in_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\ndays_in_year = [52, 52, 52, 52, 53, 53, 52]\n\nif input_string[2] == 'week':\n print days_in_year[int(input_string[0]) - 1]\nelse:\n print sum(1 for d in days_in_month if int(input_string[0]) <= d)\n"}, {"source_code": "\na = list(input().split())\nx = int(a[0])\ny = 0\n\nif \"week\" in a:\n if x==5 or x==6:\n y = 53\n else:\n y = 52\n\nif \"month\" in a:\n if x==31:\n y = 7\n elif x==30:\n y = 11\n elif x<=29:\n y = 12\n\nprint(y)"}, {"source_code": "n,x,s=input().split()\nif s=='week':\n\tif int(n)==5 or int(n)==6:\n\t\tprint(53)\n\telse:\n\t\tprint(52)\t\nelse:\n\tif int(n)<=29:\n\t\tprint(12)\n\telif int(n)==30:\n\t\tprint(11)\n\telse:\n\t\tprint(7)"}, {"source_code": "a, b, c = input().split()\na = int(a)\nif c == 'week':\n z = 4\n a -= 1\n ans = 0\n for i in range(366):\n if a == z:\n ans += 1\n z = (z + 1) % 7\n print(ans)\nelse:\n if a == 31:\n print(7)\n elif a == 30:\n print(11)\n else:\n print(12)"}, {"source_code": "from sys import stdin, stdout\nimport math\n\nn,_,t = map(str, stdin.readline().split())\nn = int(n)\nif t == 'month':\n if n>29:\n if n == 31:\n print(7)\n else:\n print(11)\n else:\n print(12)\nelse:\n if n>4 and n<7:\n print(53)\n else:\n print(52)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\n\n\"\"\"\ncreated by shhuan at 2017/11/24 19:44\n\n\"\"\"\n\ns = input()\na = s.split()\n\nv = int(a[0])\n\ntype = a[2]\nif type == \"week\":\n if v == 5 or v == 6:\n print(53)\n else:\n print(52)\nelse:\n if v == 30:\n print(11)\n elif v == 31:\n print(7)\n else:\n print(12)"}, {"source_code": "x=[i for i in input().split()]\nif x[2]==\"week\":\n print(53 if int(x[0]) in [5,6] else 52)\nelse:\n if int(x[0])==31:\n print(7)\n elif int(x[0])==30:\n print(11)\n else:\n print(12)"}, {"source_code": "a,b,c = input().split()\na = int (a)\n\nif c[0]=='m':\n if a>=1 and a<=29:\n print ('12')\n elif a==30:\n print ('11')\n elif a==31:\n print ('7')\n \nelse:\n if a==5 or a==6:\n print ('53')\n else:\n print ('52')\n"}, {"source_code": "from calendar import Calendar\nimport sys\n\nline = sys.stdin.readlines()[0]\n\nnum, _, date_type = line.split()\nc = Calendar()\n\nif date_type == 'week':\n num = int(num) - 1\nelse:\n num = int(num)\n\nyear = c.yeardays2calendar(2016)\n\nsave = 0\ndays = 0\nfor month in xrange(1, 13):\n for week in c.monthdays2calendar(2016, month):\n for day in week:\n if day[0] == 0:\n continue\n days += 1\n if date_type == \"week\":\n if day[1] == num:\n save += 1\n else:\n if day[0] == num:\n save += 1\nprint save\n"}, {"source_code": "class NewYearDays:\n def solve(self,input):\n if input[2]==\"week\":\n day = int(input[0])\n if day==5 or day==6:\n return 53\n else:\n return 52\n else:\n day = int(input[0])\n if day ==31:\n return 7\n elif day==30:\n return 11\n else: return 12\nif __name__==\"__main__\":\n input = map(str,raw_input().split(\" \"))\n nyd = NewYearDays()\n print nyd.solve(input)"}, {"source_code": "x = raw_input()\n\nif 'week' in x:\n day = x[0]\n if x[1]!=' ':\n day+=x[1]\n day = int(day)\n ans= 52\n if day==5 or day ==6:\n ans+=1\n print ans\nelse:\n day = x[0]\n if x[1]!=' ':\n day+=x[1]\n day = int(day)\n if day<=29:\n ans=12\n elif day==30:\n ans=11\n else:\n ans=7\n\n print ans\n"}, {"source_code": "s=input()\nl=list(s.split())\nif l[2]=='week':\n if l[0]=='5' or l[0]=='6':\n print(53)\n else:\n print(52)\nelse:\n if l[0]=='30':\n print(11)\n elif l[0]=='31':\n print(7)\n else:\n print(12)\n "}, {"source_code": "from sys import stdin\nx,y,z = stdin.readline().strip().split()\nx=int(x)\nif z==\"month\":\n if x<=29:\n print 12\n elif x==30:\n print 11\n else:\n print 7\nelse:\n we = [0,52,52,52,52,53,53,52,52,52,52,52]\n print we[x]"}, {"source_code": "s = input()\nx = int(s.split(' ')[0])\nif (s[len(s)-7:] == 'of week'):\n if (x==6 or x==5):\n print('53')\n else:\n print('52')\nelse:\n if (x==31):\n print('7')\n elif (x==30):\n print('11')\n else:\n print('12')\n \n \n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n t = LS()\n n = int(t[0])\n if t[-1] == 'week':\n if n in [5,6]:\n return 53\n return 52\n\n if n < 30:\n return 12\n if n == 30:\n return 11\n return 7\n\n\nprint(main())\n\n\n"}, {"source_code": "import re\nn = input()\nis_week = \"week\" in n\nx = int(re.findall(\"[0-9]+\", n)[0])\nif is_week:\n print(52 if x<5 or x>6 else 53)\nelse:\n print(7 if x>30 else (11 if x>29 else 12))\n"}, {"source_code": "j,_,w = raw_input().split()\nif w == \"week\":\n ans = 52\n if j in '56': ans += 1\nelse:\n ans = {'31':7, '30':11}.get(j, 12)\nprint ans"}, {"source_code": "s = input()\nx = int(s[0:2])\nif 'week' in s:\n if 5 <= x <= 6:\n print(53)\n else:\n print(52)\n\n\nelse:\n if x == 30:\n print(11)\n elif x == 31:\n print(7)\n else:\n print(12)"}, {"source_code": "# tested by Hightail - https://github.com/dj3500/hightail\nimport math,string,itertools,fractions,heapq,collections,re,array,bisect\nimport datetime\nimport time\nfrom sys import stdin, stdout\n\n#Start of Program\n\n# Read Chars\ns = str(stdin.readline())\ns = s.strip().lower()\n\nc = ''\nn = ''\n\n#Get Whether asking for MOnth or Week\nif 'month' in s: \n c = 'M'\nelse:\n c = 'W'\n\n# Get the Count \nn = s[0:2] \nn = int(n.strip())\n\ndef isLeapYear(yr):\n if yr == 0 or yr == '':\n return False\n \n return True if int(yr % 4) == 0 else False\n\ndef noofWeeks(yr,wk):\n wk = int(wk)\n cd = 0\n st= datetime.date(day=1, year=yr, month=1)\n if isLeapYear(yr):\n n = 365 + 1\n else:\n n = 364 + 1 \n \n cnt = 0\n \n while True:\n \n d = st + datetime.timedelta(days=cnt)\n \n if int(d.isoweekday()) == wk:\n cd = cd + 1\n \n n = n - 1\n cnt = cnt + 1\n if n <= 0:\n break\n \n return cd\n\ndef noofMOnths(yr,ct):\n yr = int(yr)\n n = 1\n cd = 0\n if isLeapYear(yr): \n if ct <= 29:\n return 12\n elif ct == 30:\n return 11\n else:\n return 7\n else:\n if ct <= 28:\n return 12\n elif ct <= 30:\n return 10\n else:\n return 7\n \n#Print Output Result \nif c == 'M':\n ans = noofMOnths(2016,n) \nelse:\n ans = noofWeeks(2016,n) \n \nstdout.write( str(ans) + \"\\n\" )"}, {"source_code": "s = input().split()\n\nx = int(s[0])\nr = s[2]\n\nif r == \"week\":\n\tif x == 5 or x == 6:\n\t\tprint(53)\n\telse:\n\t\tprint(52)\nelse:\n\tif x <= 29:\n\t\tprint(12)\n\telif x == 30:\n\t\tprint(11)\n\telse:\n\t\tprint(7)"}], "negative_code": [{"source_code": "week = 52\nday = 365\nl = [*map(str,input().split())]\nif l[2][0]=='w':\n print(52 if int(l[0]) in [4,5] else 51)\nelse:\n print(11 if int(l[0])==30 else 12)"}, {"source_code": "a = raw_input()\nlis = list(a.split())\nif lis[-1]==\"month\":\n\tval = int(lis[0])\n\tif val==29:\n\t\tprint \"1\"\n\telif val == 30:\n\t\tprint \"11\"\n\telif val == \"31\":\n\t\tprint \"7\"\n\telse:\n\t\tprint \"12\"\nelse:\n\tval = int(lis[0])\n\tif val==1 or val==3 or val ==7:\n\t\tprint \"52\"\n\telse:\n\t\tprint \"53\""}, {"source_code": "from sys import stdin, stdout\ndef calcMonth(n):\n\tif(n == 31):\n\t\tstdout.write('7')\n\tif(n == 30):\n\t\tstdout.write('11')\n\telse:\n\t\tstdout.write('12')\n\ndef calcDay(n):\n\tif(n == 5 or n == 6):\n\t\tstdout.write('53')\n\telse:\n\t\tstdout.write('52')\nfile = stdin.readline()\n# <ctrl-z> EOF sent\nscale = file.split(\" \", 2)[2]\nif(scale == \"month\"):\n\tcalcMonth(file.split(\" \", 1)[0])\nelse:\n\tcalcDay(file.split(\" \", 1)[0])"}, {"source_code": "l=list()\nn=input()\nl=n.split()\nif l[2]==\"week\":\n\tif (int(l[0])==1 or 2 or 3 or 4 or 7):\n\t\tprint(\"52\")\n\t\t\n\telse:\n\t\tprint(\"53\")\nelse:\n\tif (int(l[0])<=29):\n\t\tprint(\"12\")\n\telif (int(l[0])==31):\n\t\tprint(\"7\")\n\telse:\n\t\tprint(\"11\")"}, {"source_code": "a=input()\nif len(a)==11:\n s=\"\"\n s+=a[0]\n s+=a[1]\n s=int(s)\n if s==30:\n print(11)\n elif s==31:\n print(7)\n else:\n print(12)\nelif len(a)==9:\n s=\"\"\n s=a[0]\n s=int(s)\n if s==6 or s==7:\n print(53)\n else:\n print(52)\nelse:\n print(12)\n"}, {"source_code": "__author__ = 'pallab'\nfrom calendar import monthcalendar\n\ninput_stream = raw_input()\nnumber, words = input_stream.split(' ', 1)\n\n# print int(number),'-',words\ndef days_count(year=2016, expected=1):\n retval = 0\n for month in xrange(1, 13):\n week = monthcalendar(year, month)\n\n for days in week:\n if days[expected]!=0:\n retval+=1\n\n return retval\n\ndef month_count(year=2016, expected=1):\n retval = 0\n for month in xrange(1, 13):\n week = monthcalendar(year, month)\n for days in week:\n if expected in days:\n retval+=1\n\n return retval\n\nprint month_count(2016, int(number)) if 'month' in words else days_count(2016, int(number))\n"}, {"source_code": "#!/usr/bin/env python\n\nif __name__ == '__main__':\n days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n inp = raw_input()\n fixed_day = int(inp.split()[0])\n if inp.endswith('week'):\n print 52 if fixed_day != 6 else 53\n else:\n print len(filter(lambda x: x >= fixed_day, days))\n"}, {"source_code": "x = raw_input()\n\nif 'week' in x:\n day = x[0]\n if x[1]!=' ':\n day+=x[1]\n day = int(day)\n ans= 52\n if day==1 or day ==2:\n ans+=1\n print ans\nelse:\n day = x[0]\n if x[1]!=' ':\n day+=x[1]\n day = int(day)\n if day<=29:\n ans=12\n elif day==30:\n ans=11\n else:\n ans=7\n\n print ans\n"}, {"source_code": "a=input()\nif len(a)==11:\n s=\"\"\n s+=a[0]\n s+=a[1]\n s=int(s)\n if s==30:\n print(11)\n elif s==31:\n print(7)\n else:\n print(12)\nelif len(a)==9:\n s=\"\"\n s=a[0]\n s=int(s)\n if s==6 or s==7:\n print(53)\n else:\n print(52)\nelse:\n print(12)\n"}, {"source_code": "data=input().split()\nx = int(data[0])\ntime = data[-1]\nmonths = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nif time == 'week':\n w = 4+sum(months)\n candies = w//7\n if x<=w%7 or x>4: candies += 1\n if x<5: candies -= 1\nelse:\n candies = sum([x<=m for m in months])\n\nprint(candies)\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\n\nel=raw_input().split()\nel[0] = int(el[0])\nif el[-1] == \"week\":\n print 52\n exit(0)\nif el[0] == 30:\n print 11\n exit(0)\nif el[0] == 31:\n print 7\n exit(0)\nprint 12"}, {"source_code": "s = input().split()\n\nx = int(s[0])\nr = s[2]\n\nif r == \"week\":\n\tif x == 5 or x == 6:\n\t\tprint(53)\n\telse:\n\t\tprint(52)\nelse:\n\tif x <= 29:\n\t\tprint(12)\n\tif x == 30:\n\t\tprint(11)\n\telse:\n\t\tprint(7)"}, {"source_code": "\"\"\"\n\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \n\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2551\u255a\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2588\u2588\u2551\n\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d \n\u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u255d\n\"\"\" \n__author__ = \"Dilshod\"\ns = input().split()\nif s[-1] == \"month\":\n\tif s[0] == \"31\":\n\t\tprint(7)\n\telif s[0] == \"30\":\n\t\tprint(11)\n\telse:\n\t\tprint(12)\nelse:\n\tif s[0] == '1':\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"2\":\n\t\tprint(4 * 12 + 5) \n\telif s[0] == \"3\":\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"4\":\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"5\":\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"6\":\n\t\tprint(4 * 12 + 5)\n\telif s[0] == \"7\":\n\t\tprint(4 * 12 + 4)\n"}, {"source_code": "a,b,s = map(str,input().split())\na = int(a)\nif(s=='week') :\n if(a==6 or a==7) :\n print(53)\n else :\n print(52)\nelif(s=='month') :\n if(a==30) :\n print(11)\n elif(a==31) :\n print(7)\n else:\n print(12)"}, {"source_code": "a,b,c = input().split()\na = int (a)\n\nif c[0]=='m':\n if a>=1 and a<=29:\n print ('12')\n elif a>=30:\n print ('11')\n \nelse:\n if a==5 or a==6:\n print ('53')\n else:\n print ('52')\n"}, {"source_code": "a,b,c = map(str,raw_input().split())\na = int(a)\nif c == 'month':\n if a == 31:\n print '7'\n elif a == 30 or a == 29:\n print '11'\n else:\n print '12'\nelse:\n print '52'"}, {"source_code": "l=list(input().split())\ntable={0:52,1:52,2:52,3:52,4:52,5:53,6:53}\nif(l[2]==\"week\"):\n print(table[int(l[0])])\nelse:\n n=int(l[0])\n if(n<=29):\n print(12)\n elif(n==31):\n print(7)\n else:\n print(12)\n"}, {"source_code": "a, b, c = input().split()\nif c == 'week':\n print(52)\nelse:\n if a == '31':\n print(7)\n elif a == '30':\n print(11)\n else:\n print(12)"}, {"source_code": "s = input()\nx = int(s.split(' ')[0])\nif (s[len(s)-7:] == 'of week'):\n if (x==5):\n print('53')\n else:\n print('52')\nelse:\n if (x==31):\n print('7')\n elif (x==30):\n print('11')\n else:\n print('12')\n \n \n"}, {"source_code": "s=raw_input().split()\nif 'week'==s[2]:\n print 53 if 7>int(s[0])>4 else 52\nelse:\n d=int(s[0])\n print 12 if d<29 else 11 if d<31 else 7"}, {"source_code": "a,b,c = map(str,raw_input().split())\na = int(a)\nif c == 'month':\n if a == 31:\n print '7'\n elif a == 30 or a == 29:\n print '11'\n else:\n print '12'\nelse:\n if a == 1:\n print '53'\n else:\n print '52'"}, {"source_code": "#\"\"\"Forget every bitches of your life.Because A bitch is Always a bitch\"\"\"\nNever, fuck_a, Bitch=input().split()\nNever=int(Never)\nif Bitch==\"week\":\n print(52+(Never==6)+(Never==5))\nelif Bitch==\"year\":\n print(12-(Never==30)+((Never==31)*5))"}, {"source_code": "help = list(input().split())\ncount_week = 366 // 7\nif help[2] == 'week':\n if int(help[0]) == 5 or int(help[0]) == 6 or int(help[0]) == 7:\n print(53)\n else:\n print(52)\nelse:\n if int(help[0]) == 29:\n print(12)\n elif int(help[0]) == 30:\n print(11)\n else:\n print(7)"}, {"source_code": "#\"\"\"Forget every bitches of your life.Because A bitch is Always a bitch\"\"\"\nNever, fuck_a, Bitch=input().split()\nNever=int(Never)\nif Bitch==\"week\":\n print(52+(Never==6)+(Never==5))\nelif Bitch==\"year\":\n print(12-(Never==30)+((Never==31)*5))"}, {"source_code": "'''\n# Read input from stdin and provide input before running code\n\nname = raw_input('What is your name?\\n')\nprint 'Hi, %s.' % name\n'''\n#print 'Hello World!'\n#peace \"pes college of engineering, mandya\"\nS = raw_input()\n\nx = S.split()\nans = x[2]\nif(ans == \"week\"):\n if (x[0] == \"5\" or x[0] == \"6\"):\n print 53\n else:\n print 52 \nelif(ans == \"month\"):\n if(x[0] <= 29):\n print 12\n else:\n print 11\n\n \n"}, {"source_code": "x=input()\ny=' '\na=x.split(y)\nif a[2]=='month':\n if int(a[0])<30:\n print('12')\n elif a[0]=='30' :\n print('11')\n elif a[0]=='31':\n print('7')\nif a[2]=='week':\n if a[0]=='1' or a[0]=='2':\n print('53')\n elif int(a[0])<=7 and int(a[0])>2:\n print('52')\n "}, {"source_code": "class NewYearDays:\n def solve(self,input):\n if input[2]==\"week\":\n day = int(input[0])\n if day==7:\n return 51\n else:\n return 52\n else:\n day = int(input[0])\n if day ==31:\n return 7\n elif day==30:\n return 11\n else: return 12\nif __name__==\"__main__\":\n input = map(str,raw_input().split(\" \"))\n nyd = NewYearDays()\n print nyd.solve(input)"}, {"source_code": "from copy import deepcopy\nif __name__== \"__main__\":\n m=raw_input()\n n=[]\n d=[]\n for i in m:\n if i.isalpha():\n n.append(i)\n elif i.isdigit():\n d.append(i)\n s=''.join(n)[:]\n num=int(''.join(d))\n if s==\"ofmonth\":\n if num<=29:\n print \"12\"\n elif num==30:\n print \"11\"\n elif num==31:\n print \"7\"\n else:\n if num<=4:\n print \"52\"\n elif num>=5:\n print \"53\""}, {"source_code": "import re\nn = input()\nis_week = \"week\" in n\nx = int(re.findall(\"[0-9]+\", n)[0])\nif is_week:\n print(52 if x<5 or x>6 else 53)\nelse:\n print(7 if x>30 else (11 if x>28 else 12))\n"}, {"source_code": "string = input().split()\nif string[2]==\"week\":\n if int(string[0])==5 or int(string[0])==6:\n print(53)\n else:\n print(52)\nif string[2]==\"month\":\n if int(string[0])==30:\n print(11)\n if int(string[0])==31:\n print(7)\n "}, {"source_code": "n, a, b = input().split()\nn = int(n)\nif b[0] is 'w':\n print((52,53)[n>=5 and n <= 6])\nelse:\n if n is 31:\n print(7)\n else:\n print((11,12)[n<29])"}, {"source_code": "help = list(input().split())\nif help[2] == 'week':\n if int(help[0]) == 5 or int(help[0]) == 6 or int(help[0]) == 7:\n print(366 // 7 + 1)\n else:\n print(366 // 7)\nelse:\n if int(help[0]) <= 29:\n print(12)\n elif int(help[0]) == 30:\n print(11)\n else:\n print(7)"}, {"source_code": "#!/usr/bin/env python\n\nif __name__ == '__main__':\n days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n inp = raw_input()\n fixed_day = int(inp.split()[0])\n if inp.endswith('week'):\n print 52 if fixed_day != 6 else 53\n else:\n print len(filter(lambda x: x >= fixed_day, days))\n"}, {"source_code": "a = input().split()\nif a[-1] == 'week':\n if a[0] == '6':\n print(53)\n else:\n print(52)\nelse:\n day = int(a[0])\n if day <= 29:\n print(12)\n elif day == 30:\n print(11)\n else:\n print(7)"}, {"source_code": "\nn, a, b = [str(i) for i in input().split()]\nn = int(n)\n\ndef calc(n):\n if(n == 5):\n if(365/7 > int(\"{0:.0f}\".format((365/7)))):\n print(\"{0:.0f}\".format((365/7)+1))\n else:\n print(365/7)\n elif(n == 6):\n if(364/7 != int(\"{0:.0f}\".format((364/7)))):\n print(\"{0:.0f}\".format((364/7)+1))\n else:\n print(364/7)\n elif(n == 7):\n if(363/7 != int(\"{0:.0f}\".format((363/7)))):\n print(\"{0:.0f}\".format((363/7)+1))\n else:\n print(363/7)\n elif(n == 1):\n if(362/7 != int(\"{0:.0f}\".format((362/7)))):\n print(\"{0:.0f}\".format((362/7)+1))\n else:\n print(362/7)\n elif(n == 2):\n if(361/7 != int(\"{0:.0f}\".format((361/7)))):\n print(\"{0:.0f}\".format((361/7)+1))\n else:\n print(361/7)\n elif(n == 3):\n if(360/7 != int(\"{0:.0f}\".format((360/7)))):\n print(\"{0:.0f}\".format((360/7)+1))\n else:\n print(360/7)\n elif(n == 4):\n if(359/7 != int(\"{0:.0f}\".format((359/7)))):\n print(\"{0:.0f}\".format((359/7)+1))\n else:\n print(359/7)\n\nif (b == \"month\"):\n if(n < 29):\n print(12)\n elif(n == 30 or n == 29):\n print(11)\n else:\n print(7)\nelse:\n calc(n)\n \n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jan 2 16:28:57 2016\n\n@author: Felix\n\"\"\"\n\ncandy = raw_input()\nstrings = candy.split(\" \")\n\nweeks = {1:52, 2:52, 3:52, 4:52, 5:53, 6:52, 7:52}\nmonths = {31:4, 30:11}\n\nfor x in range(1,30):\n months[x] = 12\n \nif strings[2] == \"week\":\n print weeks[int(strings[0])]\n \nif strings[2] == \"month\":\n print months[int(strings[0])]\n\n \n\n"}, {"source_code": "data=input().split()\nx = int(data[0])-1\nstart = 5-1\ntime = data[-1]\nmonths = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nif time == 'week':\n w = start+sum(months)-1\n candies = w//7\n if x >= start+1 and x <=start+w%7: candies += 1\nelse:\n candies = sum([x<=m for m in months])\n\nprint(candies)\n"}, {"source_code": "#!/usr/bin/python\n\nline = raw_input()\nline = line.split()\nn = int(line[0])\n\ndef week(n):\n n = n - 3\n if n<=0: n = n + 7\n ans = 0\n while n<=364:\n ans = ans + 1\n n = n + 7\n print ans\n \ndef month(n):\n ans = 0\n mo = [31, 29,\n 31, 30, 31, 30, 31,\n 31, 30, 31, 30, 31]\n for a in mo:\n if n<=a: ans=ans+1\n print ans\n\nif line[2]==\"week\":\n week(n)\nelse:\n month(n)\n"}, {"source_code": "# your code goes here\nimport datetime\nfrom datetime import date, timedelta\nimport sys\n\nline = sys.stdin.readline()\ncnt=0;\nif \"week\" in line:\n d = datetime.date(2016, 1, 1)\n end_date = datetime.date(2016, 12, 31)\n delta = datetime.timedelta(days=1)\n while d <= end_date:\n if d.weekday() == int((line.split())[0]):\n cnt+=1\n d+=delta\n print cnt\nelif \"month\" in line:\n d = datetime.date(2016, 1, 1)\n end_date = datetime.date(2016, 12, 31)\n delta = datetime.timedelta(days=1)\n while d <= end_date:\n if d.day == int((line.split())[0]):\n cnt+=1\n d+=delta\n print cnt"}, {"source_code": "mon = [31,29,31,30,31,30,31,31,30,31,30,31]\nweek = [0]*7\nx = 5\nfor i in xrange(1,367):\n\tx = (x)%7\n\tweek[x] +=1\n\tx = x + 1\ns = raw_input()\nans = 0\nif s[len(s)-1]=='k':\n\tprint week[int(s[0])-1]\nelse:\n\ts = s.split()\n\ter = int(s[0])\n\tfor i in mon:\n\t\tif er<=i:\n\t\t\tans = ans + 1\n\tprint ans\n"}, {"source_code": "from sys import stdin, stdout\nimport math\n\nn,_,t = map(str, stdin.readline().split())\nn = int(n)\nif t == 'month':\n if n>28:\n print(11)\n else:\n print(12)\nelse:\n if n>5:\n print(51)\n else:\n print(52)\n"}, {"source_code": "n, t, s = input().split()\nif s == 'month':\n if n == '31':\n print(7)\n elif n == 30:\n print(11)\n else:\n print(12)\nelse:\n if n == '5' or n == '6':\n print(53)\n else:\n print(52)\n"}, {"source_code": "inputString = raw_input().split()\nn = int(inputString[0])\n\nweekOrMonth = inputString[2]\n\nif weekOrMonth == \"week\":\n\tif n == 5:\n\t\tprint 53\n\telse:\n\t\tprint 52\nelse:\n\tif n > 29 and n < 31:\n\t\tprint 11\n\telif n == 31:\n\t\tprint 7\n\telse:\n\t\tprint 12\n\n"}, {"source_code": "a,b,c = input().split()\na = int (a)\n\nif c[0]=='m':\n if a>=1 and a<=29:\n print ('12')\n elif a>=30:\n print ('11')\n \nelse:\n if a==5 or a==6:\n print ('53')\n else:\n print ('52')\n"}, {"source_code": "from sys import stdin, stdout\nimport math\n\nn,_,t = map(str, stdin.readline().split())\nn = int(n)\nif t == 'month':\n if n>28:\n if n == 31:\n print(7)\n else:\n print(11)\n else:\n print(12)\nelse:\n if n>4:\n print(53)\n else:\n print(52)\n"}, {"source_code": "import math \nimport os\n\nl = raw_input().split()\n\nif l[-1] == 'week':\n print 52 \nelse:\n if l[0] == '29':\n print 12\n elif l[0] == '30':\n print 11\n elif l[0] == '31':\n print 7\n else:\n print 12\n\n"}, {"source_code": "a=input().split()\nx=int(a[0])\nif a[2]=='month':\n if x==31:\n print(7)\n elif x==30:\n print(11)\n else:\n print(12)\nelse:\n t=(366-3)//7\n if 5<=x<=7:\n t+=1\n print(t+1)\n "}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\n\n\"\"\"\ncreated by shhuan at 2017/11/24 19:44\n\n\"\"\"\n\ns = input()\na = s.split()\n\nv = int(a[0])\n\ntype = a[2]\nif type == \"Week\":\n if v == 5 or v == 6:\n print(53)\n else:\n print(52)\nelse:\n if v == 30:\n print(11)\n elif v == 31:\n print(7)\n else:\n print(12)"}, {"source_code": "init = raw_input()\n\nam = int(init.split(' ')[0])\ndw = init.split(' ')[2]\nif dw == 'week':\n if am == 5 or am == 6:\n print 53\n else:\n print 52\nelse:\n if am == 31:\n print 7\n if am == 30:\n print 11\n else:\n print 12\n"}, {"source_code": "st = input()\nif st[-4:] == \"week\":\n if st[0] == \"6\": r = 53\n else: r = 52\nelse:\n if int(st[:2]) <= 29: r = 12\n elif st[:2] == \"31\": r = 7\n else: r = 11\nprint(r)\n"}, {"source_code": "x=input()\ny=' '\na=x.split(y)\nif a[2]=='month':\n if int(a[0])<30:\n print('12')\n elif a[0]=='30' :\n print('11')\n elif a[0]=='31':\n print('7')\nif a[2]=='week':\n if a[0]=='5' or a[0]=='6':\n print('53')\n elif int(a[0])<=4 and a[0]=='7':\n print('52')\n "}, {"source_code": "candy_plan = raw_input().split()\n\nif candy_plan[2] == 'week':\n day = int(candy_plan[0])\n if day ==6 or day == 7:\n print 53\n else:\n print 52\n\nelse:\n day = int(candy_plan[0])\n if day < 30:\n print 12\n elif day == 30:\n print 11\n else:\n print 7\n"}, {"source_code": "saving_plan = input().split()\n\nday, course = int(saving_plan[0]), saving_plan[2]\n\nif course == \"week\" :\n if day <= 4 :\n print(\"52\")\n else :\n print(\"53\")\n\nif course == \"month\" :\n if day == 31 :\n print(\"7\")\n elif day == 30 :\n print(\"11\")\n else :\n print(\"12\")\n\n\n"}, {"source_code": "import re\nn = input()\nis_week = \"week\" in n\nx = int(re.findall(\"[0-9]+\", n)[0])\nif is_week:\n print(52 if x<7 else 51)\nelse:\n print(7 if x>30 else (11 if x>28 else 12))\n"}, {"source_code": "n = input()\nn = n.split()\nnumber = int(n[0])\nprint(number)\nform = n[2]\nif form == \"month\":\n if number <= 29: print(12)\n elif number == 30: print(11)\n else: print(7) \nelse:\n if (number == 5 or number == 6): print(53)\n else: print(52)\n \n"}, {"source_code": "s=input().split()\nif s[2]=='month':\n\tif int(s[0])<30:\n\t\tprint('12')\n\telif int(s[0])==30:\n\t\tprint('11')\n\telse:\n\t\tprint('7')\nelse:\n\tprint('52')"}, {"source_code": "l=list()\nn=input()\nl=n.split()\nif l[2]==\"week\":\n\tif (int(l[0])==1 or 2 or 3 or 4 or 7):\n\t\tprint(\"52\")\n\t\t\n\telse:\n\t\tprint(\"53\")\nelse:\n\tif (int(l[0])<=29):\n\t\tprint(\"12\")\n\telif (int(l[0])==31):\n\t\tprint(\"7\")\n\telse:\n\t\tprint(\"11\")"}, {"source_code": "data = input().split(' ')\nmonthorweek = data[2]\nday = int(data[0])\n\nresult = 0\nif monthorweek == 'month':\n if day > 30:\n result = 7\n elif day > 29:\n result = 11\n else:\n result = 12\nelse:\n if day == 6 or day == 7:\n result = 53\n else:\n result = 52\n\nprint(result)\n\n\n"}, {"source_code": "n, t, s = input().split()\nif s == 'month':\n if n == '31':\n print(7)\n elif n == 30:\n print(11)\n else:\n print(12)\nelse:\n if n == '5' or n == '6':\n print(53)\n else:\n print(52)\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n t = LS()\n if t[-1] == 'week':\n if t[0] in '12':\n return 53\n return 52\n\n if t[0] < '30':\n return 12\n if t[0] == '30':\n return 11\n return 7\n\n\nprint(main())\n\n\n"}, {"source_code": "from sys import stdin, stdout\ndef calcMonth(n):\n\tif(n == 31):\n\t\tstdout.write('7')\n\tif(n == 30):\n\t\tstdout.write('11')\n\telse:\n\t\tstdout.write('12')\n\ndef calcDay(n):\n\tif(n == 5 or n == 6):\n\t\tstdout.write('53')\n\telse:\n\t\tstdout.write('53')\nfile = stdin.readline()\n# <ctrl-z> EOF sent\nscale = file.split(\" \", 2)[2]\nif(scale == \"month\"):\n\tcalcMonth(file.split(\" \", 1)[0])\nelse:\n\tcalcDay(file.split(\" \", 1)[0])"}, {"source_code": "n, prep, str1 = raw_input().split()\nw = [0,52,52,52,52,52,53,53]\nm = {30:11,31:7}\nif str1 == 'week':\n print w[int(n)]\nelse:\n if int(n) in m:\n print m[int(n)]\n else:\n print 12"}, {"source_code": "x = input().split()\nif x[2] == \"week\":\n\tif x[0] == \"4\" or x[0] == \"5\":\n\t\tprint(\"52\")\n\telse:\n\t\tprint(\"51\")\nelse:\n\tif x[0] == \"31\":\n\t\tprint(7)\n\telif x[0] == \"30\":\n\t\tprint(11)\n\telse:\n\t\tprint(12)"}, {"source_code": "S =input().split()\n\nif S[-1] == 'week':\n if S[0] == '6' or S[0]=='5':\n print(53)\n else:\n print(52)\nelse:\n if S[0] == 31:\n print(7)\n elif S[0] == 30:\n print(11)\n else:\n print(12)"}, {"source_code": "inputString = raw_input().split()\nn = int(inputString[0])\n\nweekOrMonth = inputString[2]\n\nif weekOrMonth == \"week\":\n\tif n == 5:\n\t\tprint 53\n\telse:\n\t\tprint 52\nelse:\n\tif n > 29 and n < 31:\n\t\tprint 11\n\telif n == 31:\n\t\tprint 7\n\telse:\n\t\tprint 12\n\n"}, {"source_code": "a, b, c = input().split()\na = int(a)\nif c == 'week':\n z = 4\n a -= 1\n ans = 0\n for i in range(365):\n if a == z:\n ans += 1\n z = (z + 1) % 7\n print(ans)\nelse:\n if a == 31:\n print(7)\n elif a == 30:\n print(11)\n elif a==29:\n print(11)\n else:\n print(12)"}, {"source_code": "a,b,c = map(str,raw_input().split())\na = int(a)\nif c == 'month':\n if a == 31:\n print '7'\n elif a == 30 or a == 29:\n print '11'\n else:\n print '12'\nelse:\n print '52'"}, {"source_code": "s=input()\nl=list(s.split())\nif l[2]=='week':\n if l[0]==5 or l[0]==6:\n print(53)\n else:\n print(52)\nelse:\n if l[0]=='30':\n print(11)\n elif l[0]=='31':\n print(7)\n else:\n print(12)\n "}, {"source_code": "from sys import stdin, stdout\nimport math\n\nn,_,t = map(str, stdin.readline().split())\nn = int(n)\nif t == 'month':\n if n>28:\n if n == 31:\n print(7)\n else:\n print(11)\n else:\n print(12)\nelse:\n if n>5:\n print(53)\n else:\n print(52)\n"}, {"source_code": "if __name__ == '__main__':\n day, of, time_unit = raw_input().split()\n day = int(day)\n\n if time_unit == 'week':\n print 53 if day >= 5 else 52\n elif time_unit == 'month':\n print 11 if day == 30 else 7 if day == 31 else 12\n"}, {"source_code": "\ufeff"}, {"source_code": "import math\n\nn, a, b = [str(i) for i in input().split()]\nn = int(n)\n\ndef calc(n):\n if(n == 5):\n if(365/7 > int(math.trunc(365/7))):\n print(math.trunc(365/7)+1)\n else:\n print(365/7)\n elif(n == 6):\n if(364/7 > int(math.trunc(364/7))):\n print(math.trunc(364/7)+1)\n else:\n print(364/7)\n elif(n == 7):\n if(363/7 > int(math.trunc(363/7))):\n print(math.trunc(363/7)+1)\n else:\n print(363/7)\n elif(n == 1):\n if(362/7 > int(math.trunc(362/7))):\n print(math.trunc(365/7)+1)\n else:\n print(362/7, \" \", int(\"{0:.0f}\".format((362/7))))\n elif(n == 2):\n if(361/7 > int(math.trunc(361/7))):\n print(math.trunc(361/7)+1)\n else:\n print(361/7)\n elif(n == 3):\n if(360/7 > int(math.trunc(360/7))):\n print(math.trunc(360/7)+1)\n else:\n print(360/7)\n elif(n == 4):\n if(359/7 > int(math.trunc(359/7))):\n print(math.trunc(359/7)+1)\n else:\n print(359/7)\n\nif (b == \"month\"):\n if(n < 29):\n print(12)\n elif(n == 30 or n == 29):\n print(11)\n else:\n print(7)\nelse:\n calc(n)\n \n"}, {"source_code": "inp = raw_input().split()\nval = int(inp[0])\nif inp[2] == 'week':\n\tprint 52 + (val == 1 or val == 2)\nelse :\n\tif val < 30 :\n\t\tprint 12\n\telif val == 30: \n\t\tprint 11\n\telse :\n\t\tprint 7\n"}, {"source_code": "a, b, c = input().split()\nif c == 'week':\n print(52)\nelse:\n if a == '31':\n print(7)\n elif a == '30':\n print(11)\n else:\n print(12)"}, {"source_code": "a=input().split()\nx=int(a[0])\nif a[2]=='month':\n if x==31:\n print(7)\n elif x==30:\n print(11)\n else:\n print(12)\nelse:\n t=(366-3)//7\n if 5<=x<=7:\n t+=1\n print(t+1)\n "}, {"source_code": "[ind, x, unit] = input().split(\" \")\nif unit == \"week\":\n print(53 if ind == \"5\" or ind == \"6\" else 52)\nelse:\n print(12 if int(ind) <= 28 else (11 if int(ind) <= 30 else 7))\n"}, {"source_code": "x, s, s = input().split()\nx = int(x)\nif s == 'week':\n ans = 0\n if x > 3:\n ans += 1\n ans = 366 // 7\n print(ans)\nelse:\n if x in [1, 3, 5, 7, 9, 11]:\n print(13)\n elif x > 29:\n print(11)\n else:\n print(12)\n"}, {"source_code": "\"\"\"\n\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \n\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2551\u255a\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2588\u2588\u2551\n\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d \n\u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u255d\n\"\"\" \n__author__ = \"Dilshod\"\ns = input().split()\nif s[-1] == \"month\":\n\tif s[0] == \"31\":\n\t\tprint(7)\n\telif s[0] == \"30\":\n\t\tprint(11)\n\telse:\n\t\tprint(12)\nelse:\n\tif s[0] == '1':\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"2\":\n\t\tprint(4 * 12 + 5) \n\telif s[0] == \"3\":\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"4\":\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"5\":\n\t\tprint(4 * 12 + 4)\n\telif s[0] == \"6\":\n\t\tprint(4 * 12 + 5)\n\telif s[0] == \"7\":\n\t\tprint(4 * 12 + 4)\n"}, {"source_code": "n, a, b = input().split()\nn = int(n)\nif b[0] is 'w':\n print((52,53)[n>=6 and n <= 6])\nelse:\n if n is 31:\n print(7)\n else:\n print((11,12)[n<29])"}, {"source_code": "s = raw_input().split()\nn = int(s[0])\nt = s[2]\n\nif (t == \"week\"):\n\tif ((n == 5) or (n == 6)):\n\t\tprint 53\n\telse:\n\t \tprint 52\n\nelse:\n\tif (n == 30):\n\t\tprint 11\n\telif (n == 31):\n\t\tprint 6\n\telse:\n\t \tprint 12\n\n\n"}, {"source_code": "a, b, c = input().split()\nif c == 'week':\n print(52)\nelse:\n if a == '31':\n print(7)\n elif a == '30':\n print(11)\n else:\n print(12)"}, {"source_code": "from sys import stdin, stdout\nimport math\n\nn,_,t = map(str, stdin.readline().split())\nn = int(n)\nif t == 'month':\n if n>28:\n if n == 31:\n print(7)\n else:\n print(11)\n else:\n print(12)\nelse:\n if n>5:\n print(53)\n else:\n print(52)\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\nn,x,m=input().split()\nn=int(n)\nif m==\"week\":\n\tif n==3:\n\t\tprint(52+1)\n\telse:\n\t\tprint(52)\nif m==\"month\":\n\tif n<=29:\n\t\tprint(12)\n\telif n==30:\n\t\tprint(11)\n\telse:\n\t\tprint(7)\t\t\t\t\t\n"}, {"source_code": "a,b,c=raw_input().split()\na=int(a)\nday=3\nans=0\nif c=='week':\n for i in xrange(365):\n day+=1\n day%=7\n ans+=day==(a-1)\nelse:\n for i in [31,29,31,30,31,30,31,31,30,31,30,31]:\n ans+=a<=i\nprint ans\n \n"}, {"source_code": "weeks=[52,52,52,52,53,53,53]\nmonths=[12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,12,11,7]\ns=list(input().split(\" \"))\nno=int(s[0])\nif(s[2]=='week'):\n print(weeks[no-1])\nelse:\n print(months[no-1])"}, {"source_code": "s=input()\nl=list(s.split())\nif s[-1]=='k':\n if s[0]==1 or s[0]==2:\n print(53)\n else:\n print(52)\nelse:\n if l[0]=='30':\n print(11)\n elif l[0]=='31':\n print(7)\n else:\n print(31)\n "}, {"source_code": "from sys import stdin,stdout\ninput=lambda :stdin.readline().strip()\na,b,c=input().split()\na=int(a)\nif c=='week':\n if a==6 or a==7:\n print(53)\n else:\n print(52)\nelif c=='month':\n if a<=29:\n print(12)\n elif a<=30:\n print(11)\n else:\n print(7)\n"}, {"source_code": "data=input().split()\nx = int(data[0])-1\nstart = 5-1\ntime = data[-1]\nmonths = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nif time == 'week':\n w = start+sum(months)-1\n candies = w//7\n if x >= start+1 and x <=start+w%7: candies += 1\nelse:\n candies = sum([x<=m for m in months])\n\nprint(candies)\n"}, {"source_code": "from sys import stdin, stdout\ndef calcMonth(n):\n\tn = int(n)\n\tif(n == 31):\n\t\tstdout.write('7')\n\telif(n == 30):\n\t\tstdout.write('11')\n\telse:\n\t\tstdout.write('12')\n\ndef calcDay(n):\n\tn = int(n)\n\tif(n == 5 or n == 6):\n\t\tstdout.write('53')\n\telse:\n\t\tstdout.write('52')\nfile = stdin.readline()\n# <ctrl-z> EOF sent\nscale = file.split(\" \", 2)[2]\ntime = file.split(\" \", 1)[0]\nscale = scale.split(\"/n\", 1)[0]\nif(scale == \"month\"):\n\tcalcMonth(time)\nelse:\n\tcalcDay(time)"}, {"source_code": "import re\nn = input()\nis_week = \"week\" in n\nx = int(re.findall(\"[0-9]+\", n)[0])\nif is_week:\n print(52 if x<5 or x>6 else 53)\nelse:\n print(7 if x>30 else (11 if x>28 else 12))\n"}, {"source_code": "s = raw_input().split()\nmonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nweeks = [52, 52, 52, 52, 53, 53, 53]\nif s[2] == 'week':\n print weeks[int(s[0])-1]\nelse:\n print sum(1 for i in month if i >= int(s[0]))"}, {"source_code": "s = input().split()\na = int(s[0])\nb = s[2]\nif b == 'week':\n if a==5 or a==6:\n print(55)\n else:\n print(54)\nelse:\n if a<=29:\n print(12)\n elif a==30:\n print(11)\n elif a==31:\n print(7)\n"}, {"source_code": "import math \nimport os\n\nl = raw_input().split()\n\nif l[-1] == 'week':\n print 52 \nelse:\n if l[0] == '29':\n print 12\n elif l[0] == '30':\n print 11\n elif l[0] == '31':\n print 7\n else:\n print 12\n\n"}, {"source_code": "a, b, c = raw_input().split()\nif (int(a)==5 or int(a)==6) and c=='week':\n print 53\nelif int(a)!=5 and int(a)!=6 and c=='week':\n print 52\nelif int(a)<30 and c=='month':\n print 12\n#elif int(a)>29 and c=='month':\nelse:\n print 11\n"}, {"source_code": "a=raw_input()\na=a.split(' ')\nif a[2]=='month':\n if int(a[0])<30:\n print 12\n elif int (a[0])==30:\n print 11\n else:\n print 7\nelse:\n if a[0]==6 or a[0]==5:\n print 53\n else:\n print 52\n"}, {"source_code": "l=list(input().split())\ntable={0:52,1:52,2:52,3:52,4:52,5:53,6:53}\nif(l[2]==\"week\"):\n print(table[int(l[0])])\nelse:\n n=int(l[0])\n if(n<=29):\n print(12)\n elif(n==31):\n print(7)\n else:\n print(12)\n"}, {"source_code": "import re\ns=raw_input()\nr1=re.compile(r\"(\\d) of week\")\nr2=re.compile(r\"(\\d+) of month\")\nm = r1.match(s)\nif m:\n x=int(m.group(1))\n if x in [1,2,3,4,6,7]:\n print 52\n else:\n print 53 \nelse:\n m = r2.match(s)\n x=int(m.group(1))\n if x==31:\n print 7\n elif x==30:\n print 11\n else:\n print 12"}, {"source_code": "s=input().split()\ns1=int(s[0])\nif s[2]=='week':\n if s1==5 or s1==6 or s1==7:\n \t print(53)\n else:\n \t print(52)\nelse:\n if s1==31:\n print(7)\n elif s1==30:\n print(11)\n else:\n print(12)"}, {"source_code": "x = str(raw_input())\nif x[len(x)-1] == 'h':\n if int(x[0]+x[1])>= 30:\n print '11'\n else:\n print '12'\nelse:\n if x[0] == 6 or x[0] == 7:\n print '53'\n else:\n print '52'\n"}, {"source_code": "__author__ = 'pallab'\nfrom calendar import monthcalendar\n\ninput_stream = raw_input()\nnumber, words = input_stream.split(' ', 1)\n\n# print int(number),'-',words\ndef days_count(year=2016, expected=1):\n retval = 0\n for month in xrange(1, 13):\n week = monthcalendar(year, month)\n\n for days in week:\n if days[expected]!=0:\n retval+=1\n\n return retval\n\ndef month_count(year=2016, expected=1):\n retval = 0\n for month in xrange(1, 13):\n week = monthcalendar(year, month)\n for days in week:\n if expected in days:\n retval+=1\n\n return retval\n\nprint month_count(2016, int(number)) if 'month' in words else days_count(2016, int(number))\n"}], "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b"} {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n", "positive_code": [{"source_code": "import sys\n\na, b, m = map(float, sys.stdin.readline().split(' '))\nvx, vy, vz = map(float, sys.stdin.readline().split(' '))\ntime = m / abs(vy)\n\nif vx < 0:\n distx = a * 3 / 2 + time * abs(vx)\nelse:\n distx = a * 1 / 2 + time * vx\ndistz = time * vz\n\nk = int(distx / (2 * a))\ndistx -= k * 2 * a\nk = int(distz / (2 * b))\ndistz -= k * 2 * b\n\nif distx > a:\n realx = 2 * a - distx\nelse:\n realx = distx\nif distz > b:\n realz = 2 * b - distz\nelse:\n realz = distz\n\nprint(realx, realz)\n"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n a,b,m = map(int , input().split())\n v = [int(i) for i in input().split()]\n\n pos = [a/2,m,0]\n\n while pos[1] != 0:\n # print(pos)\n k = 1e9\n j = -1\n for i in range(3):\n if v[i] == 0:\n continue\n if v[i] < 0:\n t = pos[i]/(-1 * v[i])\n if t < k:\n k = t\n j = i\n else:\n l = a if i == 0 else b\n t = (l - pos[i])/v[i]\n if t < k:\n k = t\n j = i\n \n if v[j] < 0:\n pos[j] = 0\n for i in range(3):\n if i != j:\n pos[i] += v[i]*k\n v[j] = -1 * v[j]\n else:\n pos[j] = a if j == 0 else b\n for i in range(3):\n if i != j:\n pos[i] += v[i]*k\n v[j] = -1 * v[j]\n\n print(pos[0] , pos[2])\n return\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "a,b,m=list(map(int,input().split(\" \")))\nvitesse=list(map(int,input().split(\" \")))\n\nnecessary=m/abs(vitesse[1])\nposition=(a/2,m,0)\n\nwhile position[1]>0:\n if vitesse[2]>0:\n time=(b-position[2])/vitesse[2]\n elif vitesse[2]<0:\n time=(position[2])/(-vitesse[2])\n else:\n time=m+1\n\n if vitesse[0]>0:\n tempo=(a-position[0])/vitesse[0]\n elif vitesse[0]<0:\n tempo=(-position[0])/vitesse[0]\n else:\n tempo=m+1\n\n if tempo<time:\n time=tempo\n position=[position[i]+vitesse[i]*min(time,necessary) for i in range(3)]\n if time<necessary:\n vitesse[0]=-vitesse[0]\n else:\n break\n elif tempo>time:\n position=[position[i]+vitesse[i]*min(time,necessary) for i in range(3)]\n if time<necessary:\n vitesse[2]=-vitesse[2]\n else:\n break\n else:\n position=[position[i]+vitesse[i]*min(time,necessary) for i in range(3)]\n if time<necessary:\n vitesse[0],vitesse[2]=-vitesse[0],-vitesse[2]\n else:\n break\n necessary-=time\n\nprint(position[0],position[2])"}, {"source_code": "def f(mx, tot):\n while tot < 0 or tot > mx:\n if tot > mx:\n tot = 2 * mx - tot\n else:\n tot *= -1\n return tot\na, b, m = map(int, input().split())\nvx, vy, vz = map(int, input().split())\ntm = m / -vy\nprint(f(a, a / 2 + vx * tm), f(b, vz * tm))"}, {"source_code": "def f(mx, tot):\n while tot < 0 or tot > mx:\n if tot > mx:\n tot = 2 * mx - tot\n else:\n tot *= -1\n return tot\na, b, m = map(int, input().split())\nvx, vy, vz = map(int, input().split())\ntm = m / -vy\nprint(f(a, a / 2 + vx * tm), f(b, vz * tm))"}, {"source_code": "a, b, m = [float(i) for i in raw_input().split()]\nvx, vy, vz = [float(i) for i in raw_input().split()]\nx = a/2.0\nt = m/-vy\n\nmx = (vx*t+x)%(2*a)\nx0 = mx if mx <= a else 2*a-mx\n\nmz = (vz*t)%(2*b)\nz0 = mz if mz <= b else 2*b-mz\nprint '{0:01.10f} {1:01.10f}'.format(x0, z0)\n"}, {"source_code": "def move(x, v, t):\n return [max(0.0, x[i] + v[i] * t) for i in range(3)]\n\ndef makeTurn():\n global x, v, m, a, b, eps\n turnTime = 10 ** 10\n time = 10 ** 10\n if v[0] != 0: time = (0.0 - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n if v[0] != 0: time = (a - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n if v[2] != 0: time = (b- x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n if v[2] != 0: time = (0.0 - x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n time = (0.0 - x[1]) / v[1]\n if time > 0: turnTime = min(turnTime, time)\n next = move(x, v, turnTime)\n if abs(next[0]) <= eps or abs(next[0] - a) <= eps:\n v[0] = -v[0]\n if abs(next[2]) <= eps or abs(next[2] - b) <= eps:\n v[2] = -v[2]\n #print '%lf %lf' % (v[0], next[0])\n x = next\n return abs(x[1]) > eps\n\na, b, m = map(int, raw_input().split())\neps = 1e-6\nv = map(int, raw_input().split())\nx = (a * 1.0 / 2, m * 1.0, 0.0)\nwhile makeTurn():\n pass\nprint x[0], x[2]\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z"}, {"source_code": "a, b, m = map(float, raw_input().split())\nvx, vy, vz = map(float, raw_input().split())\nt = m / -vy\nx = a / 2 + vx * t\nz = vz * t\n\nx = abs(x)\nz = abs(z)\nif int(x/a) % 2 == 1:\n x = a - x % a\nelse:\n x = x % a\n\nif int(z / b) % 2 == 1:\n z = b - z % b\nelse:\n z = z % b\nprint x, z\n"}, {"source_code": "# In the name of Allah, Most Gracious, Most Merciful\n\n# / \n# \n# \n# \n# \n# ??\n\nimport math\n\ndef repl(x, m):\n\tx -= math.floor(x/(2*m))*2*m\n\twhile x > 2*m:\n\t\tx -= 2*m\n\twhile x < 0:\n\t\tx += 2*m\n\tif x > m:\n\t\tx = 2*m-x\n\treturn x\n\na, b, m = map(float, raw_input().split())\nvx, vy, vz = map(float, raw_input().split())\nt = -m/vy\nx = repl(a/2+vx*t, a)\nz = repl(vz*t, b)\nprint x, z\n"}, {"source_code": "#!/usr/bin/python \nimport sys\nimport math\n\ndef main():\n lines = sys.stdin.readlines()\n a, b, m = map(int, lines.pop(0).split(' '))\n vx, vy, vz = map(int, lines.pop(0).split(' '))\n #print \"dimensions of room: (\" + str(a) + \", 0, \" + str(b) + \")\"\n #print \"distance away: \" + str(m)\n #print vx, vy, vz\n coordinates = (a/2.0, m, 0)\n steps = -1*m/float(vy)\n \n x_move = (steps*math.fabs(vx))%(2*a)\n z_move = (steps*vz)%(2*b)\n #print \"x movement: \" + str(x_move)\n #print \"z movement: \" + str(z_move)\n final_x = 0\n final_z = 0\n shifted = 0\n\n flag = False\n if x_move > a:\n #print \"x move is larger than dim\"\n x_move = x_move % a\n final_x = a-x_move\n flag = True\n else:\n final_x = x_move\n #print \"final x: \" + str(final_x)\n\n if (vx < 0):\n #shift a/2 to the left\n shifted = final_x - a/2.0\n if shifted < 0:\n shifted = -1*shifted\n if flag:\n shifted = a-shifted #reflect around midpoint\n else:\n\t\t#shift a/2 to the right\n shifted = final_x + a/2.0\n #print \"shifted: \" + str(shifted)\n if shifted > a:\n shifted = 2*a - shifted\n if flag:\n shifted = a-shifted #reflect around midpoint\n #print \"final x: \" + str(shifted)\n\n if z_move > b:\n \t#print \"z move is larger than dim\"\n \tz_move = z_move % b\n \tfinal_z = (b-z_move)\n else:\n \tfinal_z = z_move\n print str(shifted) + \" \" + str(final_z)\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n"}, {"source_code": "a, b, m = map(float, raw_input().split())\nvx, vy, vz = map(float, raw_input().split())\nt = m / -vy\nx = a / 2 + vx * t\nz = vz * t\nx = abs(x)\nz = abs(z)\n\nif int(x / a) % 2 == 1:\n\tx = a - x % a\nelse:\n\tx = x % a\n\t\nif int(z / b) % 2 == 1:\n\tz = b - z % b\nelse:\n\tz = z % b\nprint x, z\n"}, {"source_code": "from __future__ import print_function\n\ndef __main__():\n __inp = raw_input().split(' ')\n A = float(__inp[0])\n B = float(__inp[1])\n M = float(__inp[2])\n \n __inp = raw_input().split(' ')\n Vx = float(__inp[0])\n Vy = float(__inp[1])\n Vz = float(__inp[2])\n\n t = -M/Vy\n\n x = (A - 2*M*Vx/Vy)/2\n while x < 0:\n x += 2*A\n \n while x > 2*A:\n x -= 2*A\n\n if x > A:\n x = 2*A - x\n \n z = -M*Vz/Vy\n while z < 0:\n z += 2*B\n \n while z > 2*B:\n z -= 2*B\n \n if z > B:\n z = 2*B - z\n \n print(x, z, sep=' ', end='\\n')\n\n\n \n\n__main__()\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z"}, {"source_code": "a, b, m = map(float, raw_input().split())\nvx, vy, vz = map(float, raw_input().split())\nt = m / -vy\nx = a / 2 + vx * t\nz = vz * t\n\nx = abs(x)\nz = abs(z)\nif int(x/a) % 2 == 1:\n\tx = a - x % a\nelse:\n\tx = x % a\n\nif int(z / b) % 2 == 1:\n\tz = b - z % b\nelse:\n\tz = z % b\nprint x, z\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z"}, {"source_code": "#/usr/bin/python\n# -*- coding: utf-8\n\na,b,m = map(float,raw_input().split())\nx,y,z = map(float,raw_input().split())\n\nt = m / (-y)\n\ntx = (x*t + a/2.0) % (2*a)\ntz = (z*t) % (2*b)\n\ntx = min(tx, 2*a-tx)\ntz = min(tz, 2*b-tz)\n\nprint tx, tz\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n"}, {"source_code": "#-*-coding=utf8-*-\ndebug = False\n\na,b,m = map(int, raw_input('').split(' '))\nvx,vy,vz = map(int, raw_input('').split(' '))\n\nA,B,C,D = 0,1,0,0\nx0,y0,z0 = a/2.0, m, 0\nt = (-A*x0-B*y0-C*z0-D)/float(A*vx+B*vy+C*vz)\nxi,yi,zi = x0+t*vx, y0+t*vy, z0+t*vz\nxi,yi,zi = abs(xi)%(2*a), abs(yi)%m, abs(zi)%(2*b)\nif xi>a:\n xi = abs(xi-2*a)\n\nif zi>b:\n zi = abs(zi-2*b)\n\nif not debug:\n print(\"%.10f %.10f\" % (xi,zi))"}, {"source_code": "a, b, m = raw_input().split()\nx, y, z = raw_input().split()\na, b, m = float(a), float(b), float(m)\nx, y, z = float(x), float(y), float(z)\n\nt = -m / y\np = a / 2 + x * t\nq = z * t\n\n\nwhile p > a or p < 0:\n if p > a:\n p = a * 2 - p\n else:\n p = -p\n\nwhile q > b or q < 0:\n if q > b:\n q = b * 2 - q\n else:\n q = -q\n\nprint(\"%.10lf %.10lf\" % (p, q))"}, {"source_code": "import sys\n\na, b, m = map(float, sys.stdin.readline().split())\nvx, vy, vz = map(float, sys.stdin.readline().split())\n\nt = -m / vy\nx = a / 2 + t * vx\nz = t * vz\n\nflag = 1;\nwhile x > a or x < 0:\n if x > a: x -= a\n if x < 0: x += a\n flag *= -1\nif flag == -1: x = a - x\n\nflag = 1;\nwhile z > b:\n z -= b\n flag *= -1\nif flag == -1: z = b - z\n\nprint x, z\n\n"}, {"source_code": "a,b,m = map(int,raw_input().split())\nx,y,z = map(int,raw_input().split())\nt = (1.0*m) / -y\ndx = (0.5*a+t*x) % (2*a)\ndx = dx if dx < a else 2*a-dx\ndz = t*z % (2*b)\ndz = dz if dz < b else 2*b-dz\nprint dx,dz\n\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n"}, {"source_code": "EPSILON = 0.00000001\n#data = open(\"P4.txt\")\na,b,m = map(float,raw_input().split())\nvx,vy,vz = map(float,raw_input().split())\nt = abs(m/vy)\nx = a/2.0 + t*vx\nz = abs(t*vz)\n\nif x < 0 or x > a:\n if vx > 0:\n low = a\n high = x- (x%a)\n num_bounces = max(0,int(high-low)/int(a)+1)\n x = abs(x)%a\n if num_bounces%2 == 1:\n x = a-x\n elif vx < 0:\n high = 0\n low = x + (abs(x)%a)\n num_bounces = max(0,int(high-low)/int(a)+1)\n x = abs(x)%a\n if num_bounces%2==0:\n x = a-x\n \n \nnum_bounces = int(z/b)\nif abs(z)%int(b) <EPSILON:\n z %= b\n if num_bounces%2==1:\n z += b\nelse:\n z%=b\n if num_bounces%2==1:\n z = b-z\nprint \"%.9f %.9f\" %(x,z)\n "}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n"}, {"source_code": "import math\n\ndef new_line():\n return [int(x) for x in raw_input().split()]\n\na, b, m = new_line()\nvx, vy, vz = new_line()\nt = 1.0 * m / (-vy)\nxx = 0.5 * a + t * vx\nzz = t * vz\nxi = int(math.floor(xx / a))\nzi = int(math.floor(zz / b))\nx = xx - xi * a\nif xi % 2 == 1:\n x = a - x\nz = zz - zi * b\nif zi % 2 == 1:\n z = b - z\nprint x, z\n"}, {"source_code": "def func(x,limit):\n while True:\n if(x < 0):\n x = -x\n elif (x > limit):\n x = 2.0*limit - x\n else:\n return x\ntext = raw_input()\na,b,m = map(int,text.split())\ntext = raw_input()\nvx,vy,vz = map(int,text.split())\ndx = a/2.0 + (m*1.0/-vy)*vx\ndz = (m*1.0/-vy)*vz\ndx = func(dx,a)\ndz = func(dz,b)\nprint \"%.6f %.6f\" % (dx,dz)\n"}, {"source_code": "a,b,m=map(float,raw_input().split())\nx,y,z=map(float,raw_input().split())\nm/=-y\nx=(x*m+a*.5)%(2*a);\nz=z*m%(2*b)\nx=min(x,2*a-x)\nz=min(z,2*b-z)\nprint x,z\n"}, {"source_code": "def f(mod,x):\n n=int(x/2.0*mod)\n x-=n*2.0*mod\n while(x<0.0):\n x+=2.0*mod\n while(x>2.0*mod):\n x-=2.0*mod\n if x>mod:\n x=2.0*mod-x\n return x\n\na,b,m=map(float,raw_input().split())\nvx,vy,vz=map(float,raw_input().split())\nx=f(a,a / 2.0 + vx * (m / (-vy)))\nz=f(b,vz * (m / (-vy)))\nprint \"%.9f %.9f\" %(x,z)"}, {"source_code": "import sys\n\nsys.setrecursionlimit(10 ** 6)\n\ndef pyes_no(condition) :\n if condition :\n print (\"YES\")\n else :\n print (\"NO\")\n\ndef plist(a, s = ' ') :\n print (s.join(map(str, a)))\n\ndef rint() :\n return int(sys.stdin.readline())\n\ndef rints() :\n return map(int, sys.stdin.readline().split())\n\ndef rfield(n, m = None) :\n if m == None :\n m = n\n \n field = []\n for i in xrange(n) :\n chars = sys.stdin.readline().strip()\n assert(len(chars) == m)\n field.append(chars)\n return field\n\ndef pfield(field, separator = '') :\n print ('\\n'.join(map(lambda x: separator.join(x), field)))\n\ndef check_field_equal(field, i, j, value) :\n if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :\n return value == field[i][j]\n return None \n\ndef digits(x, p) :\n digits = []\n while x > 0 :\n digits.append(x % p)\n x //= p\n return digits\n\ndef modpower(a, n, mod) :\n r = a ** (n % 2)\n if n > 1 :\n r *= modpower(a, n // 2, mod) ** 2\n return r % mod\n\ndef gcd(a, b) :\n if a > b :\n a, b = b, a\n \n while a > 0 :\n a, b = b % a, a\n\n return b\n\ndef vector_distance(a, b) :\n diff = vector_diff(a, b)\n \n return scalar_product(diff, diff) ** 0.5\n\ndef vector_inverse(v) :\n r = [-x for x in v]\n\n return tuple(r)\n\ndef vector_diff(a, b) :\n return vector_sum(a, vector_inverse(b))\n\ndef vector_sum(a, b) :\n r = [c1 + c2 for c1, c2 in zip(a, b)]\n \n return tuple(r)\n\ndef scalar_product(a, b) :\n r = 0\n for c1, c2 in zip(a, b) :\n r += c1 * c2\n\n return r\n\ndef check_rectangle(points) :\n assert(len(points) == 4)\n\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n sides = (\n vector_diff(A1, A2),\n vector_diff(A2, A3),\n vector_diff(A3, A4),\n vector_diff(A4, A1),\n )\n if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :\n return True\n return False\n\ndef check_square(points) :\n if not check_rectangle(points) :\n return False\n A, B, C, D = points\n\n for A1, A2, A3, A4 in [\n (A, B, C, D),\n (A, C, B, D),\n (A, B, D, C),\n (A, C, D, B),\n (A, D, B, C),\n (A, D, C, B),\n ] :\n side_lengths = [\n (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])\n ]\n if len(set(side_lengths)) == 1 :\n return True\n \n return False\n\ndef check_right(p) :\n # Check if there are same points\n for a, b in [\n (p[0], p[1]),\n (p[0], p[2]),\n (p[1], p[2]),\n ] :\n if a[0] == b[0] and a[1] == b[1] :\n return False\n\n a, b, c = p\n a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a) \n\n return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0\n\na, c, m = rints()\nvx, vy, vz = rints()\nvy = -vy\n\neps = 0.000001\nt = float(m) / vy\nkx = (0.5 + t * vx / a)\nkz = t * vz / c\n\n\nkx -= int(kx * 0.5 + eps) * 2\nkz -= int(kz * 0.5 + eps) * 2\n\n\nif kx < 0 :\n kx += 2\n\nif kx > 1 :\n kx = (2 - kx)\n\nif kz > 1 :\n kz = (2 - kz)\n\nprint kx * a, kz * c\n"}, {"source_code": "R=lambda:map(int,input().split())\na,b,m=R()\nx,y,z=R()\nt=-m/y\nx0=(a/2+t*x)%(2*a)\nif x0>a:\n x0=2*a-x0\nz0=(t*z)%(2*b)\nif z0>b:\n z0=2*b-z0\nprint(x0,z0)\n"}, {"source_code": "from fractions import Fraction\nfrom math import inf\n\na, b, m = map(int, input().split(' '))\nx, y, z = map(int, input().split(' '))\n\ncx, cy, cz = Fraction(a / 2), Fraction(m), Fraction(0)\n\nwhile cy > 0:\n if cx == 0:\n x = abs(x)\n elif cx == a:\n x = -abs(x)\n\n if cz == 0:\n z = abs(z)\n elif cz == b:\n z = -abs(z)\n\n if x == 0:\n time_x = inf\n elif x > 0:\n time_x = (a - cx) / x\n else:\n time_x = cx / -x\n\n time_y = -cy / y\n\n if z == 0:\n time_z = inf\n elif z > 0:\n time_z = (b - cz) / z\n else:\n time_z = cz / -z\n\n time = min(time_x, time_y, time_z)\n\n cx += time * x\n cy += time * y\n cz += time * z\n\nprint(float(cx), float(cz))\n"}], "negative_code": [{"source_code": "def move(x, v, t):\n return [x[i] + v[i] * t for i in range(3)]\n\ndef makeTurn():\n global x, v, m, a, b, eps\n turnTime = 10 ** 10\n time = (0.0 - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n time = (a - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n time = (b- x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n time = (0.0 - x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n time = (0.0 - x[1]) / v[1]\n if time > 0: turnTime = min(turnTime, time)\n next = move(x, v, turnTime)\n if abs(next[0]) <= eps or abs(next[0] - a) <= eps:\n v[0] = -v[0]\n if abs(next[2]) <= eps or abs(next[2] - b) <= eps:\n v[2] = -v[2]\n x = next\n return abs(x[1]) > eps\n\na, b, m = map(int, raw_input().split())\neps = 1e-6\nv = map(int, raw_input().split())\nx = (a * 1.0 / 2, m * 1.0, 0.0)\nwhile makeTurn():\n pass\nprint x[0], x[2]\n"}, {"source_code": "#!/usr/bin/python \nimport sys\nimport math\n\ndef main():\n lines = sys.stdin.readlines()\n a, b, m = map(int, lines.pop(0).split(' '))\n vx, vy, vz = map(int, lines.pop(0).split(' '))\n #print \"dimensions of room: (\" + str(a) + \", 0, \" + str(b) + \")\"\n #print \"distance away: \" + str(m)\n #print vx, vy, vz\n coordinates = (a/2.0, m, 0)\n steps = -1*m/float(vy)\n \n x_move = (steps*math.fabs(vx))%(2*a)\n z_move = (steps*vz)%(2*b)\n #print \"x movement: \" + str(x_move)\n #print \"y movement: \" + str(z_move)\n final_x = 0\n final_z = 0\n if x_move > a:\n \t#print \"x move is larger than dim\"\n \tx_move = x_move % a\n \tif vx < 0:\n\t \tfinal_x = a/2.0 - math.fabs(a/2.0 - x_move)\n\telse:\n\t\tfinal_x = a/2.0 + (a-x_move)\n else:\n \tif vx < 0:\n\t \tfinal_x = math.fabs(a/2.0 - x_move)\n\telse:\n\t\tfinal_x = (a/2.0 + x_move) % a\n\n if math.fabs(z_move) > b:\n \t#print \"z move is larger than dim\"\n \tz_move = z_move % b\n \tfinal_z = (b-z_move)\n else:\n \tfinal_z = z_move\n\n print str(final_x) + \" \" + str(final_z)\n\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/python \nimport sys\nimport math\n\ndef main():\n lines = sys.stdin.readlines()\n a, b, m = map(int, lines.pop(0).split(' '))\n vx, vy, vz = map(int, lines.pop(0).split(' '))\n #print \"dimensions of room: (\" + str(a) + \", 0, \" + str(b) + \")\"\n #print \"distance away: \" + str(m)\n #print vx, vy, vz\n coordinates = (a/2.0, m, 0)\n steps = -1*m/float(vy)\n \n x_move = (steps*math.fabs(vx))%(2*a)\n z_move = (steps*vz)%(2*b)\n print \"x movement: \" + str(x_move)\n #print \"z movement: \" + str(z_move)\n final_x = 0\n final_z = 0\n shifted = 0\n\n if x_move > a:\n \t#print \"x move is larger than dim\"\n \tx_move = x_move % a\n \tfinal_x = a-x_move\n else:\n final_x = x_move\n print final_x\n if (vx < 0):\n #shift a/2 to the left\n shifted = final_x - a/2.0\n if shifted < 0:\n shifted = -1*shifted\n else:\n\t\t#shift a/2 to the right\n shifted = final_x + a/2.0\n if shifted > a:\n shifted = 2*a - shifted\n #print \"final x: \" + str(shifted)\n\n if z_move > b:\n \t#print \"z move is larger than dim\"\n \tz_move = z_move % b\n \tfinal_z = (b-z_move)\n else:\n \tfinal_z = z_move\n print str(shifted) + \" \" + str(final_z)\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/python \nimport sys\n\ndef main():\n lines = sys.stdin.readlines()\n a, b, m = map(int, lines.pop(0).split(' '))\n vx, vy, vz = map(int, lines.pop(0).split(' '))\n #print \"dimensions of room: (\" + str(a) + \", 0, \" + str(b) + \")\"\n #print \"distance away: \" + str(m)\n #print vx, vy, vz\n coordinates = (a/2.0, m, 0)\n steps = -1*m/float(vy)\n x_move = (steps*vx)%(2*a)\n z_move = (steps*vz)%(2*b)\n #print \"x movement: \" + str(x_move)\n #print \"y movement: \" + str(z_move)\n final_x = 0\n final_z = 0\n if x_move > a:\n \t#print \"x move is larger than dim\"\n \tx_move = x_move % a\n \tfinal_x = a/2.0 + (a-x_move)\n else:\n \tfinal_x = a/2.0 + x_move\n\n if z_move > b:\n \t#print \"z move is larger than dim\"\n \tz_move = z_move % b\n \tfinal_z = (b-z_move)\n else:\n \tfinal_z = z_move\n\n #while coordinates[1]\n\n print str(final_x) + \" \" + str(final_z)\n\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/python \nimport sys\nimport math\n\ndef main():\n lines = sys.stdin.readlines()\n a, b, m = map(int, lines.pop(0).split(' '))\n vx, vy, vz = map(int, lines.pop(0).split(' '))\n #print \"dimensions of room: (\" + str(a) + \", 0, \" + str(b) + \")\"\n #print \"distance away: \" + str(m)\n #print vx, vy, vz\n coordinates = (a/2.0, m, 0)\n steps = -1*m/float(vy)\n \n x_move = (steps*math.fabs(vx))%(2*a)\n z_move = (steps*vz)%(2*b)\n #print \"x movement: \" + str(x_move)\n #print \"z movement: \" + str(z_move)\n final_x = 0\n final_z = 0\n shifted = 0\n\n if x_move > a:\n \t#print \"x move is larger than dim\"\n \tx_move = x_move % a\n \tfinal_x = a-x_move\n else:\n final_x = x_move\n #print final_x\n if (vx < 0):\n #shift a/2 to the left\n shifted = final_x - a/2.0\n if shifted < 0:\n shifted = -1*shifted\n else:\n\t\t#shift a/2 to the right\n shifted = final_x + a/2.0\n if shifted > a:\n shifted = 2*a - shifted\n #print \"final x: \" + str(shifted)\n\n if z_move > b:\n \t#print \"z move is larger than dim\"\n \tz_move = z_move % b\n \tfinal_z = (b-z_move)\n else:\n \tfinal_z = z_move\n print str(shifted) + \" \" + str(final_z)\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a, b, m = map(float, raw_input().split())\nvx, vy, vz = map(float, raw_input().split())\nt = m / -vy\nx = a / 2 + vx * t\nz = vz * t\nwhile x < 0:\n\tx += a\nwhile x > a:\n\tx -= a\nwhile z < 0:\n\tz += b\nwhile z > b:\n\tz -= b\nprint x, z\n"}, {"source_code": "import sys\n\na, b, m = map(float, sys.stdin.readline().split())\nvx, vy, vz = map(float, sys.stdin.readline().split())\n\nt = -m / vy\nx = a / 2 + t * vx\nz = t * vz\n\nflag = 1;\nwhile x > a or x < 0:\n if x > a: x -= a\n if x < 0: x += 1\n flag *= -1\nif flag == -1: x = a - x\n\nflag = 1;\nwhile z > b:\n z -= b\n flag *= -1\nif flag == -1: z = b - z\n\nprint x, z\n\n"}, {"source_code": "def func(x,limit):\n while True:\n if(x < 0):\n x = -x\n elif (x > limit):\n x = 2.0*limit - x\n else:\n return x\ntext = raw_input()\na,b,m = map(int,text.split())\ntext = raw_input()\nvx,vy,vz = map(int,text.split())\ndx = a/2.0 + (m*1.0/-vy)*vx\ndz = (m*1.0/-vy)*vz\nprint dx,dz\ndx = func(dx,a)\ndz = func(dz,b)\nprint \"%.6f %.6f\" % (dx,dz)\n"}], "src_uid": "84848b8bd92fd2834db1ee9cb0899cff"} {"source_code": "input()\nline = input()\nsm = 0\nres = \"\"\nfor i in range(1, 12):\n if sm >= len(line):\n break\n res += line[sm]\n sm += i\nprint(res)", "positive_code": [{"source_code": "n=int(input())\ns=input()\ni=1\nr=''\nc=0\nwhile c<n:\n r=r+s[c]\n i=i+1\n c=c+i\nprint(r)"}, {"source_code": "n=input()\ns=raw_input()\nt=''\ni=0\nfor j in range(n):\n if i>=n:\n break\n t+=s[i]\n i+=j+1\nprint t"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\ni, j = 1, 0\n#t = s[0]\nt=''\n\nwhile j < n:\n t += s[j]\n j+=i\n i+=1\nprint t"}, {"source_code": "n=int(input())\nt=input()\ni=0\nj=1\nwhile i<n:print(t[i],end=\"\");i+=j;j+=1\n"}, {"source_code": "n=int(input())\ns=input()\n\nans=''\n\ns=list(s)\ni=1\nwhile(len(s)!=0):\n ans+=s[0]\n for j in range(i):\n s.pop(0)\n i+=1\nprint(ans) \n \n \n"}, {"source_code": "\ndef anti(cipher):\n word = \"\"\n i = 0\n j = 1\n while(i<len(cipher)):\n word += cipher[i]\n i += j\n j += 1\n return word\n\nn = int(input())\ncipher = input()\nprint(anti(cipher))"}, {"source_code": "n = input()\nstr1 = raw_input()\ns = 0\nr = ''\nfor i in range(1, n+1):\n r += str1[s:s+1]\n s += i\nprint r\n"}, {"source_code": "def decrypt(length, encrypted):\n u = 0\n i = 0\n decrypted = ''\n while int(i) < int(length):\n decrypted += encrypted[i]\n u += 1\n i += int(u)\n return decrypted\n\n\nprint(decrypt(input(), input()))\n"}, {"source_code": "def cipher():\n ctext=\"\"\n ptext=\"\"\n n=int(input())\n ctext=input()\n i=1\n x=0\n if(len(ctext)>=1 and len(ctext)<= 55):\n if(n==len(ctext)):\n while(x<n):\n ptext += ctext[x]\n x+=i\n i+=1\n \n\n print(ptext)\n\ncipher() \n"}, {"source_code": "def decrypt(length,encrypted):\n u = 0\n i = 0\n decrypted = ''\n while i < int(length):\n decrypted += encrypted[i]\n u += 1\n i += u\n return decrypted\nprint(decrypt(input(),input()))"}, {"source_code": "n = int(input())\na = input()\nb = 0\nres = ''\nif n != 1 and n != 3:\n for i in range(2, n):\n if n >= b:\n res += a[b]\n b += i\n print(res)\nelif n == 3:\n print(a[:2])\nelse:\n print(a)"}, {"source_code": "\"\"\"\nthis is a standard python template for codeforces task, repo: github.com/solbiatialessandro/pyComPro/codeforces\n\"\"\"\nstdin = lambda type_ = \"int\", sep = \" \": list(map(eval(type_), raw_input().split(sep)))\njoint = lambda sep = \" \", *args: sep.join(str(i) if type(i) != list else sep.join(map(str, i)) for i in args)\ndef iters(): return xrange(int(raw_input()))\n\ndef solve(s):\n i = 0\n k = 1\n res = \"\"\n while i < len(s):\n res += s[i]\n i += k\n k += 1\n return res\n\n\nif __name__ == \"__main__\":\n \"\"\"the solve(*args) structure is needed for testing purporses\"\"\"\n n = raw_input()\n s = raw_input()\n print solve(s)"}, {"source_code": "n = int(input())\ns = input()\nans=''\ni=0\nx=1\nwhile i<n:\n ans+=s[i]\n i+=x\n x+=1\nprint(ans)"}, {"source_code": "a = int(input())\nb = raw_input()\ni=1\ntemp =1\nres = ''\nwhile i < a+1:\n res += b[i-1]\n i+=temp\n temp+=1\n\nprint res"}, {"source_code": "a = int(input())\nb = input()\nc, d = 1, 1\nst = ''\n\nwhile c <= a:\n st += b[c - 1]\n c += d\n d += 1\n\nprint(st)\n"}, {"source_code": "x = int(raw_input())\n\ny = raw_input()\na=0\nans = ''\nfor i,elem in enumerate(y):\n a = a+i\n if(a<x):\n ans += y[a]\n\nprint ans\n \n"}, {"source_code": "n = int(input())\ns = input()\na = ''\ni = 0\nj=1\nwhile(i<n):\n a+=s[i]\n i = j*(j+1)//2\n j+=1\nprint(a)"}, {"source_code": "n=int(raw_input())\nt=raw_input()\nl=[]\ni=0\ntemp=1\nwhile i<n:\n l.append(t[i]) \n i=i+temp\n temp+=1\nprint ''.join(l)"}, {"source_code": "n = int(input())\nw = raw_input()\ns = ''\nx = 0\ni = 1\nfor l in range(n):\n if x > (n - 1):\n break\n s += w[ x ]\n x += i\n i += 1\nprint s\n\n\n# 0 , 1 , 3 , 6 , 10 , ...\n"}, {"source_code": "n=int(input());\nt=input();\ns=''\n\nctr=0;\n\nfor i in range(1,n):\n\tif(ctr>=n):\n\t\tbreak;\n\ts+=t[ctr];\n\tctr+=i;\n\nif(s==''):\n\ts+=t;\n\nprint(s)"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nj = 2\ns1 = ''\nwhile i <= len(s):\n s1 = s1 + s[i]\n i += j\n j += 1\nprint(s1)"}, {"source_code": "last = 0\nn = input()\ns = raw_input()\nx = 0\ni = 0\nans = \"\"\nwhile i < n:\n\tans += s[i]\n\tx += 1\n\ti += x\nprint ans\n"}, {"source_code": "cantidad = input()\ncadena = input()\nlista = list(cadena)\n \nlista_nueva = []\nlista_nueva.append(lista[0])\ndel lista[0]\n \ni = 2\nfor x in lista:\n lista_nueva.append(lista[0])\n del lista[0:i]\n i += 1\n \ndesencriptado = \"\".join(lista_nueva)\n \nprint(desencriptado) "}, {"source_code": "# codeforce_1095A.py\n\nn = input()\nt = raw_input()\nres = \"\"\ni = 0\nsm = 0\nwhile sm < n:\n\tres += t[sm]\n\ti += 1\n\tsm += i\nprint res"}, {"source_code": "def super(n, stringa):\n m = 1\n out = \"\"\n while m*(m+1) / 2 != n and m<=10:\n m+=1\n for i in range(m):\n out += stringa[i*(i+1)/2]\n return out\n\nif __name__ == '__main__':\n n = int(input())\n stringa = raw_input()\n print(super(n, stringa))\n "}, {"source_code": "n = input()\ns = raw_input()\nr = ''\na = 1\nb = 2\nwhile 1:\n r+=s[a-1]\n a+=b\n b+=1\n if a>n:\n print r\n exit(0)"}, {"source_code": "n=int(input())\ns=input()\ni=1\na=''\nwhile s!=\"\":\n a+=s[0]\n s=s[i:]\n i+=1\n \nprint(a)\n "}, {"source_code": "#include <bits/stdc++.h>\n#define STD /*\nfrom sys import (\nstdin, stdout, exit as sys_ret)\n\"\"\"****************************\n\n Interactive Tasks:\n\n / Python: / \"\"\"\nf_input, f_print, f_flush = (\n stdin.readline,\n stdout.write,\n stdout.flush)\n\n\"\"\" / C++ /\n #import <cstdio>\n fflush(stdout);\n or\n #import <iostream>\n cout << endl;\n\n \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n Don't raise your voice,\n improve your argument.\n \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n\n cat /dev/ass > /dev/head\n Ctrl+C\n cat /knowledge > /dev/head\n\n \u00a9 Jakov Gellert\n frvr.ru\n\n****************************\"\"\"\n# */ using namespace std; int\n\namount, phrase, mult, i = int(f_input()), f_input(), 1, 0\nwhile i < amount:\n f_print(phrase[i])\n i += mult\n mult += 1"}, {"source_code": "w = int(input())\nb = input()\ns = 0\nq = \"\"\nif len(b) == 1:\n print(b)\nelse:\n for i in range(56):\n w-=i+1\n if w <= 1:\n break\n n=i+1\n e = 0\n for i in range(0, n):\n if i+s >= len(b)-1:\n break\n q+=b[i+s]\n s+=e\n e +=1\n print(q)\n"}, {"source_code": "n=int(input())\ns=str((raw_input()))\nb=''\n\ni=1\nj=0\nif(n==1):\n print s\nelse:\n for i in range(1,n):\n if(j<n):\n b+=s[j]\n j+=i\n print b"}, {"source_code": "def Repeating_Cipher():\n n1 = int(raw_input())\n n2 = raw_input()\n c = 1\n s = 0\n x = ''\n while(s <= len(n2)):\n x = x+n2[s]\n c += 1\n s += c\n print(x)\n\ndef main():\n Repeating_Cipher()\nmain()"}, {"source_code": "n = int(input())\ns = input()\nt = \"\"\ni = 0\ne = 0\nwhile e<n:\n t += s[e]\n i += 1\n e += i\n \nprint(t)\n"}, {"source_code": "j, n, a = 0, int(input()), input()\nfor i in range(n):\n j+=i\n if j<n: print(a[j], end = '')"}, {"source_code": "n=int(input())\ns=input()\nans,i,k='',0,1\nwhile i<n:\n ans+=s[i]\n i,k=i+k,k+1\nprint(ans)\n"}, {"source_code": "from math import sqrt\nn = int(input())\nN = int((-1+sqrt(1+8*n))//2)\ns = input()\nfor i in range(1, N+1):\n\tel = s[0:i]\n\ts = s[i:]\n\tprint(el[0],\n\t end = '')\n\t\n"}, {"source_code": "n = int(input())\ns = input()\np = (-1 + int((1 + 8 * n) ** 0.5)) // 2\nresult = \"\"\ncur = 0\nfor i in range(p):\n result += s[cur]\n cur += i + 1\nprint(result)\n"}, {"source_code": "# Solve the quadratic equation ax**2 + bx + c = 0\n# import complex math module\nimport cmath\n\ndef calculate_sequence_number(i):\n res = 0\n for i in range(1, i+1):\n res += i\n return res\n\ndef solve_quadratic_equation(c):\n a = 1\n b = 1\n c = -2 * c\n\n # calculate the discriminant\n d = (b**2) - (4*a*c)\n\n # find two solutions\n sol1 = (-b-cmath.sqrt(d))/(2*a)\n sol2 = (-b+cmath.sqrt(d))/(2*a)\n\n # print('The solution are {0} and {1}'.format(sol1.real ,sol2.real))\n return sol1.real ,sol2.real\n\ndef main():\n c = int(input())\n cipher = input()\n\n sol1, sol2 = solve_quadratic_equation(c)\n\n decrypted_string = \"\"\n if sol1 > 0:\n for i in range(1, int(sol1+1)):\n increase_sequence = calculate_sequence_number(i)\n decrypted_string += cipher[increase_sequence]\n \n if sol2 > 0:\n for i in range(1, int(sol2+1)):\n increase_sequence = calculate_sequence_number(i)\n decrypted_string += cipher[increase_sequence-1]\n \n print(decrypted_string)\n\nmain()\n"}, {"source_code": "import sys\nimport bisect\nimport heapq\n\nINF = 10**9+7\nsys.setrecursionlimit(INF)\n\n\nn = input()\ns = raw_input()\n\nL = -1\nfor i in range(1, 11):\n if (i*(1+i))/2 == n:\n L = i\n break\n\n\na = []\n\nindex = 0\nfor i in range(1, L+1):\n index += i\n index -= 1\n ##print index\n a.append(s[index])\n\n\nans = ''.join(a)\n\nprint ans\n"}, {"source_code": "G = input()\n\ns = raw_input()\n\ni = 0\nn = 0\np = \"\"\n\nwhile i < len(s):\n\n\tp = p + s[i]\n\n\tn = n + 1\n\n\ti = i + n\n\nprint p\n\n\t\n "}, {"source_code": "c = input()\nStr = input()\n\nmainString = \"\"\nx = 0\na = Str.__len__()\ni = 0\nwhile i < a:\n mainString += Str[i]\n x += 1\n i += x\nprint(mainString)\n"}, {"source_code": "n = int(input())\nk = input()\nb = [];\np = []\nsum = 0\nif n >=4 :\n for i in range(1, len(k)):\n if sum < n:\n sum = sum + i - 1\n b.append(sum)\n\n v = len(b)\n b.pop(v - 1)\n\n for i in b:\n p.append(k[i])\n s = ''.join(p)\n\n\nelif n == 1:\n print(k[0])\nelif n == 3:\n p.append(k[0])\n p.append(k[1])\ns = ''.join(p)\nprint(s)\n\n"}, {"source_code": "a = input()\nb = input()\nz = 1\nx = b[0]\ni = 0\nwhile i<len(b):\n x=b[i]\n if(x*z==b[i:i+z]):\n print(x,end='')\n i+=z\n z+=1\n else:\n i+=1"}, {"source_code": "n = int(input())\nt = input()\ns = ''\ni = 0\nj = 1\nwhile i < n:\n\ts = s + t[i]\n\ti = i + j\n\tj = j + 1\nprint(s)"}, {"source_code": "n = int(input())\n#lst_in = str_in.split('\\n')\ns = str(input())\n\ndecrypt = ['' for i in range(len(s))]\npointer = 0\nfor i in range(11):\n for j in range(i):\n if pointer >= len(s):\n break\n #print(i)\n decrypt[i-1] = s[pointer]\n pointer += 1\nprint(''.join(decrypt).strip())\n"}, {"source_code": "_len_str = input()\nlen_str = int(_len_str)\nenc_str = input()\nun_enc_str = list()\nindex_plus = 0\nif len_str == 1:\n\tprint(enc_str[0])\nelse:\n\tfor i in range(0, (len_str-1)):\n\t\tindex_plus = int((i*(i+1))/2)\n\t\tif index_plus >= len_str:\n\t\t\tbreak\n\t\tun_enc_str.append(enc_str[index_plus])\nun_enc_str = ''.join(un_enc_str)\nprint(un_enc_str)\n"}, {"source_code": "n = int(input())\nb = input()\ns = \"\"\ncount = 1\nfor i in range(len(b)):\n if i == count - 1:\n s = s + b[i]\n count = count + len(s)\nprint(s)\n"}, {"source_code": "n = int(input())\ns = input()\nres_s = s[0]\ni = 1\ncount = 1\nwhile i<n:\n res_s += s[i]\n count+=1\n i+=count\n \n\nprint(res_s)\n"}, {"source_code": "from __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().split(\" \"))\ndef msi(): return map(str,input().split(\" \"))\ndef li(): return list(mi())\n \ndef dmain():\n sys.setrecursionlimit(1000000)\n threading.stack_size(1024000)\n thread = threading.Thread(target=main)\n thread.start()\n \nimport math\ndef getSum(n): \n sum = 0\n while(n > 0): \n sum += int(n%10) \n n = int(n/10) \n \n return sum\n\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\n \ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\ndef egcd(a, b): \n if a == 0 : \n return b, 0, 1\n gcd, x1, y1 = egcd(b%a, a)\n x = y1 - (b//a) * x1 \n y = x1 \n \n return gcd, x, y \n \ndef checkPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\ndef fib(n):\n if n==0:\n return (0,1)\n p=fib(n>>1)\n c=p[0]*(2*p[1]-p[0])\n d=p[0]*p[0]+p[1]*p[1]\n if (n&1):\n return c+2*d \n else:\n return c+d \ndef read():\n sys.stdin = open('input.txt', 'r') \ndef powLog(x,y):\n res=1\n while y>0:\n if y&1:\n res=res*x\n x=x*x\n y>>=1\n return res\ndef main():\n n=ii()\n s=si()\n i=1\n while len(s)>0:\n print(s[0],end=\"\")\n s=s[i+1:]\n i+=1\n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n \n# Comment Read()"}, {"source_code": "k=int(input())\ns=input()\nn=\"\"\ni=1\np=1\nwhile(p<=k):\n n=n+s[p-1]\n i+=1\n p=i*(i+1)//2\nprint(n)"}, {"source_code": "length = int(raw_input())\nsrc_string = raw_input()\n\ncount = 1\nsum = 0\na = list()\n\nwhile length != sum:\n cur = src_string[sum]\n a.append(cur)\n sum += count\n count += 1\n \n \nprint(''.join(a))"}, {"source_code": "n = input()\ns = raw_input().strip()\nz = 0\nans = ''\nfor i in range(100):\n\tif z+i > n-1:\n\t\tbreak\n\telse:\n\t\tans += s[z+i]\n\t\tz += i\nprint ans"}, {"source_code": "\n# Problem : A. Repeating Cipher\n# Contest : Codeforces Round #529 (Div. 3)\n# URL : https://codeforces.com/contest/1095/problem/A\n# Memory Limit : 256 MB\n# Time Limit : 1000 ms\n# Powered by CP Editor (https://github.com/cpeditor/cpeditor)\n\n\"\"\"\n// Author : snape_here - Susanta Mukherjee\n \n \"\"\"\n \nfrom __future__ import division, print_function\n \nimport os,sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \n \ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n \n \ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n \ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\nmod=1000000007\n\nimport math\n\ndef main():\n\n\tn=ii()\n\ts=si()\n\tl=[]\n\tfor i in range(1,11):\n\t\tl.append((i*(i+1))//2)\n\t#print(l)\n\tfor i in range(1,11):\n\t\tif l[i-1]==n:\n\t\t\tc=i\n\t\t\tbreak\n\tans=\"\"\n\tfor i in range(1,c+1):\n\t\tans+=s[l[i-1]-1]\n\tprint(ans)\n\n \n# region fastio\n \nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \n \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n \n \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n# endregion\n \n \nif __name__ == \"__main__\":\n #read()\n main()"}, {"source_code": "n = int(raw_input())\ns = list(raw_input())[::-1]\nans = []\n\n#print s\n\ni = 1\nwhile len(s) > 0:\n ans.append(s[-1])\n for j in xrange(i):\n s.pop()\n i += 1\nprint ''.join(ans)"}, {"source_code": "n = int(input())\nst = input()\nres = st[0]\ni = 2\nt = 1\nif(len(st) > 1):\n while(t < n):\n res = res + st[t]\n t = t + i\n i = i + 1 \nprint(res)"}, {"source_code": "n=int(input())\na=input()\ns=''\nk=0\np=0\nwhile k<=(n-1):\n s+=a[k]\n p+=1\n k+=p\nprint(s)"}, {"source_code": "n=int(input())\na=input()\nfor i in range(1,n+1):\n if n==((i*(i+1))//2):\n t=i\n break\nfor j in range(t):\n print(a[j*(j+1)//2],end=\"\")\nprint()\n \n \n"}, {"source_code": "n = int(input())\nst = input()\nans = ''\nans = ans + st[0]\ni = 2\nz = 3\nwhile i<=n and n>0:\n ans = ans + st[i]\n i = i+z\n z+=1\n\nprint(ans)\n"}, {"source_code": "p=int(input())\nq=input()\nk=list(q)\nj=[]\nx=0\ny=1\nz=2\ns=1\nwhile p>0:\n j.append(k[x])\n \n \n x=y\n p-=s\n s+=1\n y+=z\n z+=1\n\nfor i in range(len(j)):\n print(j[i],end=\"\")\n \n "}, {"source_code": "n=int(input())\ns=input()\ni=0\nt=1\nwhile(i<n):\n print(s[i],end=\"\")\n i=i+t\n t=t+1"}, {"source_code": "#!/usr/bin/env python\n\"\"\"\nThis file is part of https://github.com/Cheran-Senthil/PyRival.\n\nCopyright 2018 Cheran Senthilkumar all rights reserved,\nCheran Senthilkumar <hello@cheran.io>\nPermission to use, modify, and distribute this software is given under the\nterms of the MIT License.\n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport cmath\nimport itertools\nimport math\nimport operator as op\n# import random\nimport sys\nfrom atexit import register\nfrom bisect import bisect_left, bisect_right\n# from collections import Counter, MutableSequence, defaultdict, deque\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\n# from fractions import Fraction\n# from heapq import heappop, heappush\n\nif sys.version_info[0] < 3:\n # from cPickle import dumps\n from io import BytesIO as stream\n # from Queue import PriorityQueue, Queue\nelse:\n # from functools import reduce\n from io import StringIO as stream\n from math import gcd\n # from pickle import dumps\n # from queue import PriorityQueue, Queue\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n def gcd(x, y):\n \"\"\"greatest common divisor of x and y\"\"\"\n while y:\n x, y = y, x % y\n return x\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef main():\n n = int(input())\n t = input()\n\n res = ''\n for i in [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55]:\n try:\n res += t[i]\n except IndexError:\n print(res)\n return\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n"}, {"source_code": "n=int(input())\nt=input()\ns=''\ni=j=0\nwhile i<n:\n s+=t[i]\n j+=1\n i+=j\nprint(s)"}, {"source_code": "n = int(input())\ns = input()\na = [1, 2]\ni, j = 1, 0\nk = 2\nwhile a[i] < 56:\n i += 1\n a.append(a[i - 1] + k)\n k += 1\nwhile a[j] < n:\n print(s[a[j] - 1], end='')\n j += 1\nif n == 1:\n print(s)\n"}, {"source_code": "n = input()\ns = raw_input()\nans = ''\nptr = 0\nctr = 1\nwhile ptr < n:\n\tans += s[ptr]\n\tptr += ctr\n\tctr += 1\nprint ans "}, {"source_code": "import math\nn=int(input())\nt=input()\nsl=((-1+int(math.sqrt(1+8*n))))//2\ns=''\nfor i in range(sl):\n s=s+t[(i*(i+1))//2]\nprint(s)"}, {"source_code": "i = 0\nlens = int(input())\nins = input()\ndecoded = ''\nnexts = 0\nwhile nexts < lens:\n nexts = (i * (i + 1)) // 2\n #print(nexts)\n if nexts < lens:\n decoded += ins[nexts]\n else:\n break\n i += 1\nprint(decoded)"}, {"source_code": "n=input();txt=raw_input();i=0;ans=''\nwhile i<n:\n ans+=txt[i]\n i+=len(ans)\nprint ans\n"}, {"source_code": "\nfrom __future__ import division\nfrom fractions import Fraction\nimport math\nimport random,bisect\nimport sys\n#import os\n#import random\n#import re\nfrom sys import stdin, stdout\n#from collections import Counter,deque,OrderedDict,defaultdict\n#from itertools import permutations,ansduct,combinations\n#from heapq import heapify,heappush,heappop,heappushpop,heapify,heapreplace,nlargest,nsmallest\n#import numpy as np\n#from operator import mul\n\nMOD=10**6+3\nINF=float('+inf')\n\ndef si():\n\treturn str(stdin.readline())\ndef ii():\n return int(raw_input())\ndef mi():\n return map(int, raw_input().split())\ndef li():\n return [int(i) for i in raw_input().split()]\ndef debug(x):\n\treturn stdout.write(str(x))\ndef limul(list):\n\treturn eval('*'.join(str(item) for item in list))\n\n\"-----------------------------------------------\"\n\ndef main():\n\tn=ii()\n\tarr=raw_input()\n\tans=[]\n\tindex=[0,2,5,9,14,20,27,35,44,54]\n\tl=len(index)\n\tans_index=[]\n\tfor i in range(l):\n\t\tif index[i]==n-1:\n\t\t\tanswer=i\n\t\t\tbreak\n\tfor i in range(answer+1):\n\t\tans.append(arr[index[i]])\n\tprint ''.join(str(e) for e in ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nmain()\n"}, {"source_code": "input()\ns=raw_input()\ni=0\na=''\nk=1\nwhile i<len(s):\n a+=s[i]\n i+=k\n k+=1\nprint a\n \n \n "}, {"source_code": "N = input()\nT = raw_input()\n\nres = \"\"\nind = 0\nwhile ind < N :\n res += T[ind]\n ind += len(res)\n\nprint res"}, {"source_code": "n=int(input())\ns=input()\ni,c=0,1\nwhile i<n:\n\tprint(s[i],end='')\n\ti+=c\n\tc+=1"}, {"source_code": "n = int(input())\ns = input()\nt = []\ninc = int(0)\nif 1<=n and n<=55 and len(s)==n:\n i = 0\n while i<n:\n t.append(s[int(inc*(inc+1)/2)])\n inc = inc + 1\n i = int(inc*(inc+1)/2)\n str1 = ''.join(str(e) for e in t)\n print(str1)\n\n"}, {"source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\n#from math import ceil, floor, factorial;\n\n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp\n\n## gcd function\ndef gcd(a,b):\n if b == 0:\n return a\n return gcd(b, a % b);\n\n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k \n res = 1\n for i in range(k): \n res = res * (n - i) \n res = res / (i + 1) \n return int(res) \n\n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0):\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if a[mid] < x:\n lo = mid+1\n else:\n hi = mid\n return lo\n\n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0 and n > 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0 and n > 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n\n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n\n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b\n\n# find function with path compression included (recursive)\n# def find(x, link):\n# if link[x] == x:\n# return x\n# link[x] = find(link[x], link);\n# return link[x];\n\n# find function with path compression (ITERATIVE)\ndef find(x, link):\n p = x;\n while( p != link[p]):\n p = link[p];\n \n while( x != p):\n nex = link[x];\n link[x] = p;\n x = nex;\n return p;\n\n\n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n\n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e6 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n\n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)]\n# spf_sieve() \ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()))\n## taking string array input\ndef str_array():\n return input().strip().split();\n\n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n\n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n\n# n, k = int_array();\n# binary = bin(n).replace('0b', '');\n# if binary.count('1') > k or k > n:\n# print('NO');\n# else:\n# print('YES');\nn = int(input()); s = input().strip();\nans = ''; x = 0;\nfor i in range(1, 11):\n if x >= n:\n break;\n ans += s[x];\n x += i;\nprint(ans);"}, {"source_code": "n = int(input())\ns = input()\nx = s[0]\nm = 2\nsum = 1\nwhile sum < n:\n x += s[sum]\n sum += m\n m += 1\nprint(x)\n\n\n'''\nDDDDDDDDDD RRRRRRRRRRRRRRR A GGGGGGGGGGG OOOOOOO NNNNNNN NNNNNNN\nD:::::::::DDD R::::::::::::::R A:A GGG::::::::::G OO:::::::OO N::::::N N:::::N\nD::::::::::::DD R:::::RRRRRR::::R A:::A GG:::::::::::::G OO:::::::::::OO N:::::::N N:::::N\nDDD::::DDDDD:::D RR::::R R::::R A:::::A G::::GGGGGGGG:::G O::::::OOO::::::O N::::::::N N:::::N\n D::::D D:::D R:::R R::::R A:::::::A G::::G GGGGG O:::::O O:::::O N:::::::::N N:::::N\n D::::D D:::D R:::RRRRRR::::R A::::A::::A G::::G O::::O O::::O N:::::N::::N N:::::N\n D::::D D:::D R:::::::::::RR A::::A A::::A G::::G GGGGGGGGG O::::O O::::O N:::::N N:::N N:::::N\n D::::D D:::D R:::RRRRRR::::R A::::A A::::A G::::G G:::::::G O::::O O::::O N:::::N N:::N::::::N\n D::::D D:::D R:::R R:::R A::::AAAAAAA::::A G::::G GGGGG:::G O::::O O::::O N:::::N N:::::::::N\n D::::D D:::D R:::R R::::R A:::::::::::::::::A G::::G G:::G O:::::O O:::::O N:::::N N::::::::N\nDDD::::DDDDD:::D RR::::R R::::R A::::AAAAAAAAAAA::::A G::::GGGGGGGG:::G O::::::OOO::::::O N:::::N N:::::::N\nD::::::::::::DD R:::::R R::::R A::::A A::::A GG:::::::::::::G OO:::::::::::OO N:::::N N::::::N\nD:::::::::DDD R:::::R R::::R A::::A A::::A GGG:::::GGG::G OO:::::::OO N:::::N N:::::N\nDDDDDDDDDD RRRRRRR RRRRRR AAAAAA AAAAAA GGGGG GGG OOOOOOO NNNNNNN NNNNNNN\n\n\n\n\n SSSSSSSSSSSSS LLLLLLLLL A YYYYYY YYYYYY EEEEEEEEEEEEEEEE RRRRRRRRRRRRRR\n SS:::::::::::::S L:::::::L A:A Y::::Y Y::::Y E::::::::::::::E R:::::::::::::R\nS:::SSSSSS::::::S L:::::::L A:::A Y::::Y Y::::Y E:::EEEEEEEEE::E R:::::RRRRRR:::R\nS:::S SSSSSSS LL:::::LL A:::::A Y:::::Y Y:::::Y E:E EEEE RR::::R R:::R\nS:::S L:::L A:::::::A YYY::::Y Y::::YYY E:E R:::R R:::R\n S::SSSS L:::L A::::A::::A Y::::Y::::Y E:E R:::RRRRRR:::R\n SS::::SSSSS L:::L A::::A A::::A Y:::::::Y E:EEEEEEE R::::::::::RR\n SSS::::::SS L:::L A::::A A::::A Y:::::Y E:EEEEEEE R:::RRRRRR:::R\n SSSSSS::S L:::L A::::AAAAAAA::::A Y:::Y E:E R:::R R:::R\n S:::S L:::L A:::::::::::::::::A Y::Y E:E R:::R R:::R\nSSSSSSS S:::S L:::L LLLLLL A::::AAAAAAAAAAA::::A Y::Y E:E EEEE RR::::R R:::R\nS::::::SSSSSS:::S LL:::::LLLLLLLLL:::::L A::::A A::::A YYYY::YYYY E:::EEEEEEEE:::E R:::::R R:::R\nS::::::::::::::SS LL:::::::::::::::::::L A::::A A::::A Y::::::::Y E::::::::::::::E R:::::R R:::R\n SSSSSSSSSSSSSS LLLLLLLLLLLLLLLLLLLLLL AAAAAA AAAAAA YYYYYYYYYY EEEEEEEEEEEEEEEE RRRRRRR RRRRR\n'''\n"}, {"source_code": "n=int(input())\na=input()\ni=1\nsum=0\nwhile sum<n:\n print(a[sum],end=\"\")\n sum+=i\n i+=1"}, {"source_code": "n=int(input())\ns=input()\na=0 \ni=0\nemp=''\n\nwhile(a<n):\n emp+=s[a]\n i+=1\n a=a+i\n \nprint(emp)"}, {"source_code": "def f(t):\n tp = 1+(4*t)\n return int(abs(min((((-1)+(tp**0.5))/2),(((-1)-(tp**0.5))/2)))) \n\nd = int(input())\ns = input()\nn = f(2*d)-1\nans = ''\nfor i in range(n,0,-1):\n d-=i\n l1 = s[d:]\n ans += l1[0]\n s = s[0:d]\nprint(ans[::-1])"}, {"source_code": "from collections import deque\nimport math\n\ndef main():\n n = int(input())\n t = input().strip()\n s_list = deque()\n for i in range(round(math.sqrt(2 * n + 1 / 4) - (1 / 2))):\n s_list.append(t[i*(i+1)//2])\n print(\"\".join(s_list))\n\n\nmain()\n"}, {"source_code": "n = int(input())\nst = input()\ns = \"\"\nc = 0\nj = 1\nwhile c<n:\n s += st[c]\n c += j\n j += 1\n\nprint(s)"}, {"source_code": "n = int(input())\ns = input()\ns=\" \"+s\ni=1\np=1\nans = \"\"\nwhile(i<n+1):\n ans+=s[i]\n i+=p\n p+=1\nprint(ans)\n\n"}, {"source_code": "n = int(input())\nencrypt = input()\nidx = 0\ni = 1\ndecrypt = ''\nwhile idx<n:\n decrypt += encrypt[idx]\n idx = idx+i\n i+=1\nprint(decrypt)"}, {"source_code": "t=int(input())\nif t==1:\n print(input())\nelse:\n g=input()\n count=1\n pos=0\n t-=1\n while pos<t:\n print(g[pos],end=\"\")\n pos+=count\n count+=1"}, {"source_code": "n=int(input())\ns=input()\nf=((1+8*n)**(1/2)-1)\nj=int(f//2)\nl=[]\nfor i in range(1,j+1):\n t=(i**2-i+2)//2\n l.append(s[t-1])\na=\"\".join(l)\nprint(a)\n"}, {"source_code": "n=int(input())\ns=input()\nt=1\nt1=1\na=[]\ni=0\nt=1\nwhile(i<n):\n\ta.append(s[i])\n\ti=i+t\n\tt=t+1\ns=\"\".join(a)\nprint(s)\t"}, {"source_code": "n= int(input())\nli= input()\ni=0\nfin=[]\nwhile(i< n and len(li)!=0):\n fin.append(li[i])\n li=li.replace(li[i],'',i+1)\n\n i+=1\n\nprint(\"\".join(fin))"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\na = input()\nx = 0\nj = 1\nans = []\nwhile x < n:\n ans.append(a[x])\n x += j\n j += 1\n\nprint(''.join(ans))"}, {"source_code": "from math import sqrt\n\ndef nth(i):\n if i ==0:\n return i\n else:\n return nth(i-1)+i+1\n\nn = int(input())\nstring = input()\ns = int(-0.5+sqrt(1 + (2*n)))\nres =''\nfor i in range(s):\n res+=string[nth(i)]\nprint(res)"}, {"source_code": "n=input()\ni=2\nh=[int(x) for x in range(0,56)]\nw=[]\nq=[x for x in raw_input()]\nq.reverse()\nq.append(\"-\")\nq.reverse()\nj=1\nwhile(j<=n):\n w.append(q[j])\n j=j+h[i]\n i=i+1\nprint \"\".join(w)\n\n"}, {"source_code": "n = int(input())\ns = input()\nans = []\ncnt = 0\nfor i in range(n):\n if cnt >= n:\n break\n ans.append(s[cnt])\n cnt += (i+1)\nprint(\"\".join(ans))\n\n"}, {"source_code": "n=input()\nword=raw_input()\nleng=n\nnewword=\"\"\ntemp=\"\"\nbeg=0\nend=1\nlevel=1\nwhile leng>0:\n\ttemp=word[beg:end]\n\tnewword=newword+temp[0]\n\tbeg=end\n\tlevel+=1\n\tend=end+level\n\tleng=leng-len(temp)\nprint(newword)"}], "negative_code": [{"source_code": "n=int(input());\nt=input();\ns=''\n\nctr=1;\n\nfor i in range(1,n):\n\tif(ctr>=n):\n\t\tbreak;\n\ts+=t[ctr];\n\tctr+=i;\n\nprint(s)"}, {"source_code": "lenght = int(input())\nstring = input()\n\nout = ''\nsumm = 1\n\nwhile summ < lenght:\n out += string[summ - 1]\n summ += summ\nprint(out)"}, {"source_code": "p=0\nn=int(input())\ns=input()\nfor i in range(len(s)):\n if p==0:\n print(s[i],end='')\n p=i\n else:\n p-=1"}, {"source_code": "n = int(input())\ns = input()\nt = \"\"\ni = 0\nwhile i*(i+i)//2<n:\n t += s[i*(i+1)//2]\n i += 1\n \nprint(t)\n"}, {"source_code": "p=int(input())\nq=input()\nk=list(q)\nj=[]\nm=1\no=1\nwhile p>0:\n j.append(k[m-1])\n p-=m\n o=m\n m+=o\nfor i in range(len(j)):\n print(j[i],end=\"\")\n \n \n \n \n "}, {"source_code": "w=int(input())\nn=input()\nl=list(n)\ns=1\nif w==1:\n print(n)\nfor i in range(0,w//2):\n s=s+i\n \n if(w>s):\n print(l[s-1],end='')\n \n else:\n break\n \n \n"}, {"source_code": "nbr =int(input()) \ns = input() \nres=\"\" \nres =res+s[0]\ni=1 \ncpt =0 \nwhile(i<nbr):\n \n if cpt == 0 :\n d=s[i]\n res +=s[i]\n cpt +=1 \n i +=1 \n else :\n if s[i] == d :\n i +=1 \n cpt +=1\n else :\n cpt =0 \nprint(res)"}, {"source_code": "#!/usr/bin/python2\n\nimport sys\nfrom heapq import *\nfrom collections import Counter\n\ndef ir(): return int(raw_input())\ndef ia(): return map(int, raw_input().split())\n\nn = ir()\n\ns = raw_input()\n\nprint s\n\nans = []\ni = m = 0\nwhile True:\n if i >= n: break\n ans.append(s[i])\n m += 1\n i += m\n\nprint \"\".join(ans)\n\n\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\ni = 0\nj = 1\n\nans = ''\nwhile i < len(s):\n\tans += s[i]\n\ti = j\n\tj += j+1\n\t#print i,j\n\nprint ans"}, {"source_code": "x = int(input())\ny = input()\nz = \"\".join(sorted(set(y)))\nprint(z)\n\n"}, {"source_code": "x=int(input())\nn=input()\nj=0\nfor i in range(x):\n j=j+i\n if(j<x):\n print(n[j],\"\\t\") \n"}, {"source_code": "lst = [0,1,3,6,10,15,21,28,36,45,55]\ns = input()\nfor i in range(len(s)):\n if i in lst:\n print(s[i],end=\"\")"}, {"source_code": "n = int(input())\nb = input()\ns = \"\"\ncount = 1\nfor i in range(len(b)):\n if i == count - 1:\n s = s + b[i]\n count = count + i + 1\nprint(s)\n"}, {"source_code": "w=int(input())\np=list(input())\nz,t=[],[]\ns,r=0,0\nfor i in range(0,int(w/2)):\n if r<len(p):\n s+=i\n r+=s\n z.append(s)\nfor i in z:\n a=p[i]\n t.append(a)\nif len(p)==1:\n print(*p)\nelif len(p)==2 or len(p)==3:\n o=p[0:2]\n print(*o,sep='')\nelse:\n print(*t, sep='')\n"}, {"source_code": "w=int(input())\np=list(input())\nz,t=[],[]\ns,r=0,0\nfor i in range(0,int(w/2)):\n if r<len(p):\n s+=i\n r+=s\n z.append(s)\nfor i in z:\n a=p[i]\n t.append(a)\nif len(p)==1:\n print(*p)\nelse:\n print(*t, sep='')\n"}, {"source_code": "# n = 55\nn = int(input())\n# t = 'cooooonnnnttttteeeeeeeeeeeeessssssssttttttttttttttttttt'\nt = str(input())\n# coonteestt\ns = ''\ni = 0\nnum = 0\na = []\nwhile i <= 10:\n num += i\n a.append(num)\n i += 1\nindex = 0\nfor i in range(a.index(n)):\n try:\n letter = t[index]\n except:\n break\n # print(letter)\n s += letter\n index = 2*index + 1\n\nprint(s)"}, {"source_code": "p=int(input())\nq=input()\nk=list(q)\nj=[]\nm=1\no=1\nwhile p>0:\n j.append(k[m-1])\n p-=m\n o=m\n m+=o\nfor i in range(len(j)):\n print(j[i],end=\"\")\n \n \n \n \n "}, {"source_code": "def sint():\n return (int(input()))\n\ndef sints():\n return (map(int, input().split()))\n\ndef sara():\n return (list(map(int,input().split())))\n\ndef sstr():\n s = input()\n return (list(s[:len(s)]))\n\ndef main():\n n = sint()\n s = input()\n i = 0\n while i < n:\n print(s[i], end = '')\n i += i+1\n print('')\n\nif __name__ == \"__main__\":\n \n main()\n \n \n \n"}, {"source_code": "from math import factorial as f\n\n\ndef decrypt(s):\n s2 = []\n i = 1\n j = 0\n while j < len(s):\n s2.append(s[j])\n j += i\n i += 1\n return ''.join(s2)\n\n\nif __name__ == '__main__':\n s = input().strip()\n print(decrypt(s))\n"}, {"source_code": "n = int(input())\nif(n >= 1 and n <= 55):\n Str = input()\n temp = Str[0]\n i = 1\n while(i < n):\n j = i\n temp += Str[j]\n k = i+1\n for _ in range(k):\n i += 1 \nprint(temp) \n\n\n"}, {"source_code": "a=input()\ni=0\nb=0\ns=''\nwhile(i<len(a)):\n s=s+a[i]\n b=b+1\n i=i+b\nprint(s)\n \n"}, {"source_code": "n=int(input())\ns=input()\ni=j=0\na=''\nfor i in range(n,j):\n a+=s[i]\n j+=1\nprint(a)\n "}, {"source_code": "n=int(input())\n\ns=input()\ni=1\n\nwhile i < n-1:\n print(s[i-1],end='')\n i += i"}, {"source_code": "f=int(input())\ns=input()\nl=[]\nl1=[]\nans=''\nn=1\nwhile n<f:\n for i in range(0,f):\n m=i+n\n if m<f:\n l.append(m)\n n=m\nfor i in l:\n l1.append(i-1)\nfor i in l1:\n print(s[i],end='')\n"}, {"source_code": "x = input()\nStr = input()\n\nmainString = Str[0]\nx = 1\na = Str.__len__()-1\n\nfor i in Str:\n if a > x :\n if (Str[x] != Str[x+1]):\n mainString += Str[x]\n x += 1\nif a != 0 :\n mainString += Str[a]\nprint(mainString)\n"}, {"source_code": "n=int(input())\ns=list(input())\ndit={}\nse=set(s)\nfor i in se:\n dit[i]=0\nfor i in s:\n dit[i]+=1\nprint(dit.values())\n\n"}, {"source_code": "cases = int(input())\nstring = str(input().rstrip())\n\nreal_str = \"\"\nn = 0\nm = 1\nwhile n < len(string):\n real_str += string[n]\n n += m\n m += m\nprint(real_str)\n \n\n#print(string)\n"}, {"source_code": "w=int(input())\nn=input()\nl=list(n)\ns=1\nfor i in range(0,w//2):\n s=s+i\n \n if(w>s):\n print(l[s-1],end='')\n \n else:\n break\n \n \n"}, {"source_code": "a=input()\ni=0\nb=0\ns=''\nwhile(i<len(a)):\n s=s+a[i]\n b=b+1\n i=i+b\nprint(s)\n \n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom collections import defaultdict\nfrom math import factorial as f\nfrom fractions import gcd as g\n\nN = int (raw_input ())\ns = raw_input ()\nret = \"\"\ncnt = 1\ni = 0\nwhile i < N:\n ret += s [i]\n i += i + 1\nprint ret\n"}, {"source_code": "n = int(input())\ns = input()\ns0 = ''\nc = 0\nfor i in range(10):\n if c > n - 1:\n break\n print(c)\n s0 += s[c]\n c += i\nprint(s0)"}, {"source_code": "w=int(input())\np=list(input())\nz,t=[],[]\ns,r=0,0\nfor i in range(0,int(w/2)):\n if r<len(p):\n s+=i\n r+=s\n z.append(s)\nfor i in z:\n a=p[i]\n t.append(a)\nprint(*t, sep='')\n"}, {"source_code": "s=str(input())\noss=s[0]\nfor i in range(1,len(s)):\n if s[i]!=s[i-1]:\n oss=oss+s[i]\nprint(oss)\n"}, {"source_code": "n = int(input())\ns = '$' + input()\nt = ''\ni = 1\nj = 1\nif n==1:\n print(s[1])\nelse: \n while i<n:\n t += s[i]\n i += j + 1\n j += 1\n print(t)"}, {"source_code": "n = int(input())\nencrypt = input()\nidx = 0\ni = 1\ndecrypt = ''\nwhile idx<n:\n decrypt += encrypt[idx]\n idx = idx+i\n i+=1\ndecrypt"}, {"source_code": "def sint():\n return (int(input()))\n\ndef sints():\n return (map(int, input().split()))\n\ndef sara():\n return (list(map(int,input().split())))\n\ndef sstr():\n s = input()\n return (list(s[:len(s)]))\n\ndef main():\n n = sint()\n s = input()\n i = 0\n while i < n:\n print(s[i], end = '')\n i += i+1\n print('')\n\nif __name__ == \"__main__\":\n \n main()\n \n \n \n"}, {"source_code": "n=int(input());\nt=input();\ns=''\n\nctr=1;\n\nfor i in range(1,n):\n\tif(ctr>=n):\n\t\tbreak;\n\ts+=t[ctr];\n\tctr+=i;\n\nprint(s)"}, {"source_code": "n=input()\ns=raw_input()\ni=1\nres=''\nwhile(i<=n):\n res+=s[i-1]\n i=i+i\nprint res"}, {"source_code": "n = int(input())\nt = input()\ni = 0\nwhile i < n:\n print(t[i], end=\"\")\n i += i + 1\n"}, {"source_code": "x = int(input())\ny = input()\nz = \"\".join(sorted(set(y)))\nprint(z)\n\n"}, {"source_code": "n=int(input())\nt=list(input())\nif(n==1):\n print(\"t\")\ns=''\ni=1\nsumm=1\nwhile(i<n):\n s+=t[i-1]\n i+=summ\n summ+=1\nprint(s)\n"}, {"source_code": "a = input()\nb = input()\nch = 0 \nfor i in range(len(b)):\n if i == ch:\n print(b[i], end='')\n ch += i+1"}, {"source_code": "i=1\nn=int(input())\ns=input()\nwhile i<=len(s):\n print(s[i-1],end='')\n i+=i"}, {"source_code": "n=int(input())\ns=input()\nt=int(n//2)\na=0\nb=0\nlist2=[]\nlist1=[]\nif len(s)==1:\n list2.append(s)\nfor j in s:\n list1.append(j)\nfor j in range(1,t+1): \n b+=j \n for k in range(a,b):\n c=a\n list2.append(list1[c])\n a=b\n if b==len(s):\n break\nd=list2[0]\nfor j in range(1,len(list2)):\n d+=list2[j]\nprint(d)\n \n"}, {"source_code": "n = input()\nst = input()\ns =\"\"+st[0]\nst = st[1:]\nc = 0\nj = c\nwhile j<int(n)-1:\n s += st[c]\n if c==0:\n c+=2\n else:\n c+= c+1\n j += c\nprint(s)\n"}, {"source_code": "w=int(input())\np=list(input())\nz,t=[],[]\ns,r=0,0\nfor i in range(0,int(w/2)):\n if r<len(p):\n s+=i\n r+=s\n z.append(s)\nfor i in z:\n a=p[i]\n t.append(a)\nprint(*t, sep='')\n"}, {"source_code": "x = int(input())\ny = input()\nl = \"\"\nl = l+y[0]\nfor c in range(1,x):\n if y[c] != y[c-1]:\n l = l+y[c]\nprint(l)"}, {"source_code": "n = int(input())\nst = input()\nans = ''\nans = ans + st[0]\ni = 2\nz = 1\nwhile i<=n:\n ans = ans + st[i]\n i+=2\n i+=z\n \n"}, {"source_code": "T = int(raw_input())\ns = raw_input()\ns = ';'+s\nc = 1\ni = 1\nans = ''\nwhile (i<T):\n\tans += s[i]\n\ti += c\n\tc+=1\nprint ans"}, {"source_code": "numberOfInputs = int(input())\nword = input()\nans = \"\"\ni = 1\nwhile i < len(word)+1:\n ans += word[i - 1]\n i += i\nprint(ans)\n\n\n\n"}, {"source_code": "n = int(input())\nstr = input()\n\nprint(str[0],end='')\n\nfor i in range(1,len(str)):\n if(i+1<n):\n if(str[i]==str[i+1]):\n continue\n print(str[i],end='') \n "}, {"source_code": "n=int(input())\ns=input()\ni=j=0\na=''\nfor i in range(n,j):\n a+=s[i]\n j+=1\nprint(a)\n "}, {"source_code": "n=int(input())\ns=input()\ni=1\n\nwhile i <= n:\n print(s[i - 1], end='')\n i += i\n"}, {"source_code": "\ndef decipher(num, word):\n indexes = [0]\n index = 1\n for i in range(1, num):\n indexes.append(index)\n index = index + i\n deciphered = ''\n for index in indexes:\n if index < len(word):\n deciphered += word[index]\n return deciphered\n\n\nif __name__ == '__main__':\n print(decipher(int(input()), input()))\n\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"\nThis file is part of https://github.com/Cheran-Senthil/PyRival.\n\nCopyright 2018 Cheran Senthilkumar all rights reserved,\nCheran Senthilkumar <hello@cheran.io>\nPermission to use, modify, and distribute this software is given under the\nterms of the MIT License.\n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport cmath\nimport itertools\nimport math\nimport operator as op\n# import random\nimport sys\nfrom atexit import register\nfrom bisect import bisect_left, bisect_right\n# from collections import Counter, MutableSequence, defaultdict, deque\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\n# from fractions import Fraction\n# from heapq import heappop, heappush\n\nif sys.version_info[0] < 3:\n # from cPickle import dumps\n from io import BytesIO as stream\n # from Queue import PriorityQueue, Queue\nelse:\n # from functools import reduce\n from io import StringIO as stream\n from math import gcd\n # from pickle import dumps\n # from queue import PriorityQueue, Queue\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n def gcd(x, y):\n \"\"\"greatest common divisor of x and y\"\"\"\n while y:\n x, y = y, x % y\n return x\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef main():\n n = int(input())\n t = input()\n\n res = ''\n for i in [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]:\n try:\n res += t[i]\n except IndexError:\n print(res)\n return\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n"}, {"source_code": "n = int(input())\nstr = input()\n\nprint(str[0],end='')\n\nfor i in range(1,len(str)):\n if(i+1<n):\n if(str[i]==str[i+1]):\n continue\n print(str[i],end='') \n "}, {"source_code": "def sint():\n return (int(input()))\n\ndef sints():\n return (map(int, input().split()))\n\ndef sara():\n return (list(map(int,input().split())))\n\ndef sstr():\n s = input()\n return (list(s[:len(s)]))\n\ndef main():\n n = sint()\n s = input()\n i = 0\n while i < n:\n print(s[i], end = '')\n i += i+1\n print('')\n\nif __name__ == \"__main__\":\n \n main()\n \n \n \n"}, {"source_code": "n = int(input())\nencrypt = input()\nidx = 0\ni = 1\ndecrypt = ''\nwhile idx<n:\n decrypt += encrypt[idx]\n idx = idx+i\n i+=1\ndecrypt"}, {"source_code": "n = int(input())\nt = str(input())\n\nprint(n)\nprint(t)\n\na=''\ni=0\ninc =1\nwhile(i<n):\n\ti+=inc\n\ta =a+ t[i-1]\n\tinc+=1\n\nprint(a)"}, {"source_code": "n = int(input())\nk = input()\nb=[];p=[]\nsum=0\nif n>1:\n for i in range(1,len(k)):\n if sum < n:\n sum = sum+i-1\n b.append(sum)\n print(b)\n v=len(b)\n if v>1:\n b.pop(v-1)\n print(b)\n for i in b:\n p.append(k[i])\n s=''.join(p)\n print(s)\n\nelse:\n print(k[0])\n\n\n\n\n"}, {"source_code": "n = int(input())\ns = input()\nans = ''\ni = 0\nwhile i < n:\n ans += s[i]\n i += (i+1)\nprint(ans)"}, {"source_code": "t=int(input())\ns=input()\nh=list(map(str, s))\nj=1\nk=0\nwhile k<t:\n print(h[k],end=\"\")\n k=k+j\n j=j+j"}, {"source_code": "from math import factorial as f\n\n\ndef decrypt(s):\n s2 = []\n i = 1\n j = 0\n while j < len(s):\n s2.append(s[j])\n j += i\n i += 1\n return ''.join(s2)\n\n\nif __name__ == '__main__':\n s = input().strip()\n print(decrypt(s))\n"}, {"source_code": "n=int(input())\ns=input()\na=1\ni=0\nwhile i!=n:\n print(s[i])\n i+=a\n a+=1"}, {"source_code": "n = int(input())\ns = '$' + input()\nt = ''\ni = 1\nj = 1\nif n==1:\n print(s[1])\nelse: \n while i<n:\n t += s[i]\n i += j + 1\n j += 1\n print(t)"}, {"source_code": "n = int(input())\ns = input()\nres_s = ''\ni = 0\nwhile i<n:\n res_s += s[i]\n if i == 0 or i==1:\n i=2*i+1\n else:\n i =2*i\n\nprint(res_s)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Aug 31 18:23:00 2019\n\n@author: apple\n\"\"\"\nn=int(input())\nes=input()\ns=es[0]\nfor i in range(1,n-1):\n if(es[i]==es[i+1]):\n continue\n else:\n s=s+es[i]\nprint(s+es[n-1],end=\"\") #s[0:1],s[1:3],s[2:5] i=0;s=o;i=1"}, {"source_code": "n=int(input())\ns=list(input())\ns1=s[0]\ni,a=2,2\nwhile(i<=n):\n print(i)\n s1+=s[i]\n i+=a+1\n a+=1\nprint(s1)"}, {"source_code": "cases = int(input())\nstring = str(input().rstrip())\n\nreal_str = \"\"\nn = 0\nm = 1\nwhile n < len(string):\n real_str += string[n]\n n += m\n m += m\nprint(real_str)\n \n\n#print(string)\n"}, {"source_code": "n=int(input())\ns=input()\ni=0\nk=2\nres=\"\"\nwhile(i<=n):\n res+=s[i]\n k+=1\n i+=k\nprint(res)"}, {"source_code": "n=int(input())\nstring=input()\ni=1\nwhile i<=n:\n\tprint(string[i-1],end='')\n\ti+=i"}, {"source_code": "z=input\nn=int(z())\nx=z()\ns=''\ni=0\nj=0\nfor _ in range(n):\n try:\n s+=x[i]\n i+=j+1\n j+=2\n \n except:\n pass\nprint(s)\n \n \n"}, {"source_code": "cases = int(input())\nstring = str(input().rstrip())\n\nreal_str = \"\"\nn = 0\nm = 1\nwhile n < len(string):\n real_str += string[n]\n print(n,m)\n n += m\n m += 1\nprint(real_str)\n \n\n#print(string)\n"}, {"source_code": "w=int(input())\nn=input()\nl=list(n)\ns=1\nif w==1:\n print(n)\nfor i in range(0,w//2):\n s=s+i\n \n if(w>s):\n print(l[s-1],end='')\n \n else:\n break\n \n \n"}, {"source_code": "n = int(input())\ns = input()\nans = ''\ni = 0\nwhile i < n:\n ans += s[i]\n i += i + 1\nprint(ans)\n"}, {"source_code": "n=int(input())\ns=list(input())\ns1=s[0]\ni,a=2,2\nwhile(i<=n):\n print(i)\n s1+=s[i]\n i+=a+1\n a+=1\nprint(s1)"}, {"source_code": "n=input();txt=raw_input();i=0;ans=''\nwhile i<n-1:\n ans+=txt[i]\n i+=len(ans)\nprint ans\n"}, {"source_code": "n = int(input())\nstr = input()\n\nprint(str[0],end='')\n\nfor i in range(1,len(str)):\n if(i+1<n):\n if(str[i]==str[i+1]):\n continue\n print(str[i],end='') \n "}, {"source_code": "n = int(input())\nt = input()\ni = 0\nwhile i < n:\n print(t[i], end=\"\")\n i += i + 1\n"}, {"source_code": "n=int(input())\ns=input()\nt=''\nj=0\n\nwhile(j<n):\n t+=s[j]\n j=2*j+1\nprint(t)"}, {"source_code": "n=int(input())\ns=input()\ni=0\nc=1\nr=''\nwhile c<n:\n r=r+s[c]\n i=i+1\n c=i\nprint(r)"}, {"source_code": "length = input(\"\")\nencrypted = input(\"\")\nlength = int(length)\nfinal = 1\nwhile (final*(final+1))/2 != length:\n final += 1\nfinal_string = \"\"\nk = 0\nfor i in range(final):\n final_string = final_string + encrypted[i+k-1]\n k += 1\nprint(final_string)"}, {"source_code": "a = input()\nb = input()\nch = 0 \nfor i in range(len(b)):\n if i == ch:\n print(b[i], end='')\n ch += i+1"}, {"source_code": "def sint():\n return (int(input()))\n\ndef sints():\n return (map(int, input().split()))\n\ndef sara():\n return (list(map(int,input().split())))\n\ndef sstr():\n s = input()\n return (list(s[:len(s)]))\n\ndef main():\n n = sint()\n s = input()\n i = 0\n while i < n:\n print(s[i], end = '')\n i += i+1\n print('')\n\nif __name__ == \"__main__\":\n \n main()\n \n \n \n"}, {"source_code": "n = int(input())\ns = input()\nnew_s = \"\"\ni = 0\nj = 0\nwhile i<n:\n new_s+=s[i]\n for b in range(i+1):\n i+=1\n j = 1\n if(i==0):\n i+=1\nprint(new_s)"}, {"source_code": "n = int(input())\nstring = input()\ni=1\nx=0\nreturner = \"\"\nwhile True:\n try:\n returner += string[0]\n string = string[i:]\n x += 1\n i += x\n except IndexError:\n break\nprint(returner)\n"}, {"source_code": "from math import *\nt=int(raw_input())\nf=raw_input()\np=int(ceil((t**0.5)))\ns=\"\"\nfor i in range(0,p):\n\ts=s+f[(i*(i+1))/2]\nprint s\t"}, {"source_code": "z=input\nn=int(z())\nx=z()\ns=''\ni=0\nj=0\nfor _ in range(n):\n try:\n s+=x[i]\n i+=j+1\n j+=2\n \n except:\n pass\nprint(s)\n \n \n"}, {"source_code": "a=int(input())\nb=input()\nd=c=0\n\nwhile a!=0:\n c=c+1\n d=d+c\n print(b[d-1],end=\" \")\n a-=c\n"}, {"source_code": "p=int(input(\"enter number\"))\nq=input(\"enter string\")\nk=list(q)\nj=[]\nm=1\no=1\nwhile p>0:\n j.append(k[m-1])\n p-=m\n o=m\n m+=o\nfor i in range(len(j)):\n print(j[i],end=\"\")\n \n "}, {"source_code": "x=int(input())\ny=str(input())\ns=y[0]\np=1\nc=0\nfor i in range(x):\n if i==1:\n continue\n elif i==1+p:\n p=p*2+c\n c=c+1\n s=s+y[i]\nprint(s)\n \n"}, {"source_code": "a = int(input())\nb = raw_input()\ni=1\ntemp =1\nres = ''\nwhile i < a+1:\n res += b[i-1]\n i+=temp\n temp = i\n\nprint res"}, {"source_code": "n=int(input())\ns=input()\ni=1\nt=0\nwhile(i<n):\n print(s[i],end=' ')\n i=i+t\n t=t=1\n"}, {"source_code": "n=int(input())\ns=input()\na=1\ni=0\nwhile i!=n:\n print(s[i])\n i+=a\n a+=1"}, {"source_code": "v = int(input())\nq = list(input())\nd = len(q)\nw = 0\ne = 1\nwhile w != d:\n print(q[w])\n w += e\n e += 1\n"}, {"source_code": "a=input()\ni=0\nb=0\ns=''\nwhile(i<len(a)):\n s=s+a[i]\n b=b+1\n i=i+b\nprint(s)\n \n"}, {"source_code": "n = int(input())\na = input()\nk = 1\nfor i in range(1, len(a)):\n print(a[k-1], end='')\n k += i\n if k > len(a):\n break\n"}, {"source_code": "nbr =int(input()) \ns = input() \nres=\"\" \nres =res+s[0]\ni=1 \ncpt =0 \nwhile(i<nbr):\n \n if cpt == 0 :\n d=s[i]\n res +=s[i]\n cpt +=1 \n i +=1 \n else :\n if s[i] == d :\n i +=1 \n cpt +=1\n else :\n cpt =0 \nprint(res)"}, {"source_code": "a=input()\ni=0\nb=0\ns=''\nwhile(i<len(a)):\n s=s+a[i]\n b=b+1\n i=i+b\nprint(s)\n \n"}, {"source_code": "\ndef decipher(num, word):\n indexes = [0]\n index = 1\n for i in range(1, num):\n indexes.append(index)\n index = index + i\n deciphered = ''\n for index in indexes:\n if index < len(word):\n deciphered += word[index]\n return deciphered\n\n\nif __name__ == '__main__':\n print(decipher(int(input()), input()))\n\n"}], "src_uid": "08e8c0c37b223f6aae01d5609facdeaf"} {"source_code": "def euc(a, b): #requires a>=b\n if a%b==0:\n return [b, 0, 1]\n else:\n t=euc(b, a%b)\n return [t[0], t[2], t[1]-t[2]*(a/b)]\n\nstuff=raw_input().split()\na1=int(stuff[0])\nb1=int(stuff[1])\na2=int(stuff[2])\nb2=int(stuff[3])\nL=int(stuff[4])\nR=int(stuff[5])\n\nif a1<a2: #make a1>=a2\n a1, a2=a2, a1\n b1, b2=b2, b1\n\nL=max(b1, b2, L) #accounts for >=0 restriction\n\nif L>R:\n print 0\nelif a1*a2==0: #handling dumb zero cases\n if a1==0 and a2==0:\n if b1==b2 and L<=b1 and b1<=R:\n print 1\n else:\n print 0\n elif a1==0:\n if (b1-b2) % a2==0 and L<=b1 and b1<=R:\n print 1\n else:\n print 0\n elif a2==0:\n if (b2-b1) % a1==0 and L<=b2 and b2<=R:\n print 1\n else:\n print 0\nelse:\n l=euc(a1, a2)\n gcd=l[0]\n a1coeff=l[1]\n a2coeff=l[2]\n if (b1-b2)%gcd==0:\n #now we solve for (x-b1)/gcd and apply CRT, using Euc to speed up the process\n q=a1*(b2-b1)/gcd * a1coeff + b1\n p=a1*a2/gcd\n print (R-q)/p - (L-q-1)/p\n else:\n print 0\n\n\n \n", "positive_code": [{"source_code": "import sys\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n# ax+by=c\ndef extgcd(a, b, c):\n if b == 0: return c, 0\n x, y = extgcd(b, a % b, c)\n return y, x - a // b * y\n\ndef first_term(a1, b1, a2, b2):\n g = gcd(a1, a2)\n T = lcm(a1, a2)\n\n # s*a1+t*a2=b2-b1\n if (b2 - b1) % g != 0: return -(10 ** 100)\n x0 = extgcd(a1 // g, a2 // g, (b2 - b1) // g)[0] * a1 + b1 - T * 10 ** 30\n\n ok = 10 ** 60\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\n return x0 + ok * T\n\ndef f(a0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if a0 + T * mid >= v:\n ok = mid\n else:\n ng = mid\n\n return ok\n\na1, b1, a2, b2, L, R = map(int, input().split())\n\nT = lcm(a1, a2)\na0 = first_term(a1, b1, a2, b2)\n\nif a0 == -(10 ** 100):\n print(0)\n sys.exit()\n\nprint(f(a0, T, R + 1) - f(a0, T, L))\n"}, {"source_code": "\ndef bezout(a,b) : # retourne (g,u,v) tel que g = a*u + b*v et g = pgcd(a,b)\n if b == 0 : return (a,1,0)\n q = a // b \n r = a % b\n (g,u1,v1) = bezout(b,r) \n return (g,v1,u1-q*v1) # joli algo :-)\n\na1,a2,b1,b2,L,R=[int(k) for k in raw_input().split(\" \")]\n\n\ng,q,r=bezout(a1,b1)\n\nres=0\n#ok c donc equivalent a a1,b1,a2-k,b2-k,L-k,R-k si b1%g=b2%g=k sinon pas de sol\nif a2%g==b2%g:\n k=a2%g\n L-=k\n R-=k\n res=1\n#ok c donc equivalent a a1/g,b1/g,a2/g,b2/g,(L-k)/g,(R-k)/g\na1/=g\nb1/=g\na2/=g\nb2/=g\nL/=g\nR/=g\n\na2or=a2\nb2or=b2\na2p=a2/a1\nb2p=b2/b1\na2%=a1\nb2%=b1\n#note : on a garde le qr tq qa1+rb1=1\n#On veut xa1-yb1=b2-a2\nx=(q*(b2-a2))%b1\ny=-(r*(b2-a2))%a1\nassert (x*a1-y*b1)%(a1*b1)==(b2-a2)%(a1*b1)\n#ok tous les k*a1b1 + (x+kb1)a1 + (y+ka1)*b1\n#quel est le min k tel que x+kb1>=0\nL=max(L,a2or,b2or)\nL2=L+( (x*a1+a2)%(a1*b1) - L%(a1*b1))%(a1*b1)\nprint res*max((R-L2)/(a1*b1)+1,0)"}, {"source_code": "import sys\n# Uz ma to pretekanie nebavi!!!\n\ndef gcd(a, b):\n if b == 0:\n return [a, 1, 0]\n c = a%b\n [g, x1, y1] = gcd(b, c)\n x = y1\n y = x1 - y1 * (a//b)\n return [g, x, y]\n\na1, b1, a2, b2, l, r = [int(i) for i in input().split(\" \")]\nif max(b1, b2) > r:\n print(0)\n sys.exit(0)\n\nl = max(l, b1, b2)\n[g, xg, yg] = gcd(a1, a2)\nif (b2 - b1) % g == 0:\n xg *= (b2 - b1) // g\nelse:\n print(0)\n sys.exit(0)\nlcm = (a1 * a2) // g\nval = xg * a1 + b1\nif val >= l:\n val -= (((val - l) // lcm) + 1) * lcm\n \nprint(((r - val) // lcm) - ((l - val - 1) // lcm))\n"}, {"source_code": "import sys\nfrom fractions import gcd\nfrom math import sqrt,log\nimport time\nfrom random import randint\nimport random\nfrom sets import Set\n# ---------- Number Theory -------------#\ndef primes_upto(maxn):\n maxn+=1\n A = [False]*(maxn/2+5)\n p = 3\n while p*p<maxn:\n if not A[p>>1]:\n for j in range(p*p,maxn,2*p):\n A[(j>>1)]=True\n p+=2\n ret = [2]\n for p in range(3,maxn,2):\n if not A[(p>>1)]:\n ret.append(p)\n return ret\nst = time.time()\nprime_list = primes_upto(1000000)\ndef factor_sieve(maxn):\n maxn+=1\n factor = [0]*maxn\n lim = int(sqrt(maxn))\n for i in range(2,lim+2):\n if factor[i] == 0:\n for j in range(i*i,maxn,i):\n factor[j] = i\n return factor\nfactor_list = factor_sieve(100000)\ndef totient_sieve(maxn): #returns an array of totient function\n factor=[]\n if maxn<100000:\n factor = factor_list\n else:\n factor = factor_sieve(maxn)\n maxn+=1\n tot = [1]*maxn\n tot[0] = 0\n for i in range(2,maxn):\n if factor[i] == 0:\n tot[i] = i-1\n continue\n x = factor[i]\n y=i/x\n if y%x == 0:\n tot[i] = tot[y]*x\n else:\n tot[i] = tot[y]*(x-1)\n return tot\ndef mobius_sieve(maxn):\n factor=[]\n if maxn<100000:\n factor = factor_list\n else:\n factor = factor_sieve(maxn)\n maxn+=1\n mu = [1]*maxn\n for i in range(2,maxn):\n if factor[i] == 0:\n mu[i]=-1\n continue\n x = factor[i]\n y=i/x\n if y%x == 0:\n mu[i] = 0\n else:\n mu[i]=mu[x]*mu[y]\n return mu\ndef _try_composite(a, d, n, s):\n if pow(a, d, n) == 1:\n return False\n for i in range(s):\n if pow(a, 2**i * d, n) == n-1:\n return False\n return True # n is definitely composite\n\ndef is_prime(n, _precision_for_huge_n=10):\n if n in _known_primes or n in (0, 1):\n return True\n for p in _known_primes:\n if n%p==0:\n return False\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n # Returns exact according to http://primes.utm.edu/prove/prove2_3.html\n if n < 1373653:\n return not any(_try_composite(a, d, n, s) for a in (2, 3))\n if n < 25326001:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5))\n if n < 118670087467:\n if n == 3215031751:\n return False\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7))\n if n < 2152302898747:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11))\n if n < 3474749660383:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11, 13))\n if n < 341550071728321:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11, 13, 17))\n return not any(_try_composite(a, d, n, s)\n for a in _known_primes[:_precision_for_huge_n])\n\n_known_primes = [2, 3]\n_known_primes += [x for x in range(5, 1000, 2) if is_prime(x)]\ndef brent(N):#Fails for perfect squares,primes\n if N%2==0:\n return 2\n if N<100000:\n return factor_list[N]\n y,c,m = random.randint(1, N-1),random.randint(1, N-1),random.randint(1, N-1)\n g,r,q = 1,1,1\n while g==1:\n x = y\n for i in range(r):\n y = ((y*y)%N+c)%N\n k = 0\n while (k<r and g==1):\n ys = y\n for i in range(min(m,r-k)):\n y = ((y*y)%N+c)%N\n q = q*(abs(x-y))%N\n g = gcd(q,N)\n k = k + m\n r = r*2\n if g==N:\n while True:\n ys = ((ys*ys)%N+c)%N\n g = gcd(abs(x-ys),N)\n if g>1:\n break\n\n return g\ndef floor_sqrt(n):\n x = max(0,int(sqrt(n))-1)\n while x*x<=n:\n x+=1\n return x-1\ndef prime_factors(n):# Returns all prime factors of n\n ret = Set()\n if n==1:\n return ret\n if is_prime(n):\n ret.add(n)\n return ret\n x = floor_sqrt(n)\n if x*x == n:\n return prime_factors(x)\n x = brent(n)\n n/=x\n while n%x == 0:\n n/=x\n r1 = prime_factors(x)\n r2 = prime_factors(n)\n for i in r1:\n ret.add(i)\n for i in r2:\n ret.add(i)\n return ret\ndef factorization(n):\n X = prime_factors(n)\n arr = []\n for i in X:\n arr.append(i)\n ret = {}\n for i in range(0,len(arr)):\n val = 0\n p = arr[i]\n while n%p == 0:\n val+=1\n n/=p\n ret[p] = val\n assert(n==1)\n return ret\ndef divisors(n):\n X = factorization(n)\n A=[1]\n for p in X:\n a = X[p]\n x=p**a\n z=len(A)\n B = A\n for i in range(0,z):\n val=A[i]\n mul = p\n for j in range(1,a+1):\n B.append(val*mul)\n mul*=p\n A = B\n return A\ndef ndiv(n):\n x = factorization(n)\n ret=1\n for i in x:\n ret*=x[i]+1\n return ret\ndef sorted_divisors(n):\n return sorted(divisors(n))\nmyp = {}\ndef primepi(n):#Finds pi(10**10) in 12 secs, pi(10**11) in 1 minute O(sqrt(n)) memory\n if n<=1:\n return 0\n if myp.has_key(n):\n return myp[n]\n myp.clear()\n lim=floor_sqrt(n)\n sm=[]\n la =[]\n for i in range(0,lim+1):\n sm.append(i-1)\n if i==0:\n la.append(0)\n continue\n la.append(n/i-1)\n for p in range(2,lim+1):\n if sm[p-1] == sm[p]:\n continue\n cnt_p = sm[p-1]\n q = p*p\n en = min(lim,n/q)\n for i in range(1,en+1):\n d = i*p\n if d<=lim:\n la[i]-=la[d]-cnt_p\n else:\n la[i]-=sm[n/d]-cnt_p\n for i in range(lim,q-1,-1):\n sm[i]-=sm[i/p]-cnt_p\n for i in range(1,lim+1):\n myp[i] = sm[i]\n myp[n/i] = la[i]\n return la[1]\ncache={} \ndef phi(n): #totient(n)\n if n in cache:\n return cache[n]\n ret = n\n x = prime_factors(n)\n for p in x:\n ret*=p-1\n ret/=p\n cache[n] = ret \n return ret\n\ndef inv(x,a): #(x,a) = 1\n r = phi(a)-1\n ret= pow(x,r,a)\n return ret\n\ndef crt(A,B):# all elements of A are mutually coprime\n N = 1\n for i in range(0,len(A)):\n N*=A[i]\n ret = 0\n for i in range(0,len(A)):\n val = A[i]\n md = B[i]\n prod_rem = N/val\n ret+=md*(prod_rem*inv(prod_rem,val))\n ans= ret%N\n return ans\n_store = {}\na1,b1,a2,b2,l,r = map(int,raw_input().split())\nl = max(l,max(b1,b2))\nif l > r:\n print 0\n sys.exit()\ng = gcd(a1,a2)\nif (b1%g + g)%g != (b2%g + g)%g:\n print 0 \n sys.exit()\nX = (a1*a2)/g\nA1 = a1\nA2 = a2\nf1,f2 = factorization(a1),factorization(a2)\nfor p in f1:\n if p in f2:\n if f1[p] <= f2[p]:\n A1/=(p**f1[p])\n else:\n A2/=(p**f2[p])\nassert(gcd(A1,A2)==1) \nP,Q = [A1,A2],[(b1%A1 + A1)%A1, (b2%A2 + A2)%A2]\nrem = crt(P,Q)\n# number of numbers between l,r, which are rem modulo X\nsize = r-l\nl = (l%X + X)%X + 10*X - rem\nr = l+size\nprint(r/X- (l-1)/X)\n"}, {"source_code": "from fractions import gcd\ndef egcd(a, b):\n if a == 0:\n return [0, 1]\n if b == 0:\n return [1, 0]\n p = egcd(b%a, a)\n x = p[0]; y = p[1]\n return [y-x*(b//a), x]\n\ndef solve(a1, m1, a2, m2):\n sol = egcd(m1, m2)\n m1x = m1 * sol[0]\n m2y = m2 * sol[1]\n return (m1x*a2+m2y*a1)\n\na1, b1, a2, b2, L, R = map(int, input().split(' '))\nL -= b1; R -= b1; b2 -= b1; b1 = 0;\ng = gcd(a1, a2)\nL = max(L, max(b1, b2))\nif (b2%g != 0 or L > R):\n print(0)\n quit()\nrmod = a1 * a2 // g;\na1 //= g; b2 //= g; a2 //= g;\nsol = solve(b1, a1, b2, a2);\nmod = a1 * a2;\nsol %= mod; sol *= g;\nL -= sol; R -= sol;\nif (L <= 0):\n lnew = L%rmod; R += lnew - L; L = lnew;\nL += rmod; R += rmod;\nprint(R//rmod - (L-1)//rmod)\n\n"}, {"source_code": "from fractions import gcd\na1,b1,a2,b2,l,r=map(int,raw_input().split())\n\nif b1<l:\n b1=(b1-l)%a1+l\nif b2<l:\n b2=(b2-l)%a2+l\nks1=(l-b1)/a1\nke1=(r-b1)/a1\nks2=(l-b2)/a2\nke2=(r-b2)/a2\n\ng=gcd(a1,a2)\nvar=a1/g*a2\nlst1=[]\nlst2=[]\nks1=max(b1,b2)\n\nm=min(1+r,var+ks1)\nwhile b1!=b2 and m>b1:\n if b1<b2:\n b1=(b1-b2)%a1+b2\n else:\n b2=(b2-b1)%a2+b1\nif(m>b1):\n print (1+(r-b1)/var)\nelse:\n print \"0\"\n\n \n"}, {"source_code": "a1, b1, a2, b2, L, R = map(int, input().split())\n\ndef xgcd(a,b):\n prevx, x = 1, 0\n prevy, y = 0, 1\n while b:\n q = a // b\n x, prevx = prevx - q * x, x\n y, prevy = prevy - q * y, y\n a, b = b, a % b\n\n return a, prevx, prevy\n\ng, x, y = xgcd(a1, -a2)\n\nif (b2 - b1) // g < 0: \n g, x, y = -g, -x, -y\n\nif abs(b2 - b1) % abs(g) > 0:\n print(0)\nelse:\n a2g, a1g = a2 // abs(g), a1 // abs(g)\n\n x *= (b2 - b1) // g\n y *= (b2 - b1) // g\n\n if x < 0:\n y += ((abs(x) + a2g - 1) // a2g) * a1g\n x += ((abs(x) + a2g - 1) // a2g) * a2g \n\n if y < 0:\n x += ((abs(y) + a1g - 1) // a1g) * a2g\n y += ((abs(y) + a1g - 1) // a1g) * a1g\n\n if x >= 0 and y >= 0:\n k = min(x // a2g, y // a1g)\n x -= k * a2g\n y -= k * a1g\n\n res = a1 * x + b1\n lcm = a1 * a2 // abs(g)\n\n L, R = max(0, L - res), R - res\n\n if R < 0:\n print(0)\n else:\n print(R // lcm - L // lcm + (L % lcm == 0))\n\n"}, {"source_code": "import sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\ndef modpow(x,y,m):\n # (x**y) % m\n if y==0: return 1%m\n elif y==1: return x%m\n elif y&1: return (modpow((x*x)%m,y//2,m)*x)%m\n else: return modpow((x*x)%m,y//2,m)\n\ndef inv(x,m):\n # return the inverse of x, modulo m\n # use euler's theorem\n tot=m\n mt=m\n for i in xrange(2,mt):\n if i*i>mt: break\n if mt%i==0:\n tot//=i\n tot*=i-1\n while mt%i==0: mt//=i\n if mt>1:\n tot//=mt\n tot*=mt-1\n # totient(m) = tot\n return modpow(x%m,tot-1,m)\n\ndef crt(x1,m1,x2,m2):\n # chinese remainder theorem solver\n # clean up\n m1=abs(m1)\n m2=abs(m2)\n x1%=m1\n x2%=m2\n if m1>m2:\n m1,m2=m2,m1\n x1,x2=x2,x1\n # get out a factor\n t=gcd(m1,m2)\n offset=x1%t\n if x1%t != x2%t:\n print(\"Something went wrong with the no intersection step\")\n x1//=t\n m1//=t\n x2//=t\n m2//=t\n # get important numbers\n # r1 is 1 mod m1 and 0 mod m2\n # r2 is 0 mod m1 and 1 mod m2\n r1=(m2*inv(m2,m1))%(m1*m2)\n r2=(m1*inv(m1,m2))%(m1*m2)\n # pretty much done\n return t*((x1*r1+x2*r2)%(m1*m2))+offset\n\n# k',l'>=0 is the most annoying thing ever\na1,b1,a2,b2,l,r=map(int,input().split())\n\n# bound l,r so nothing breaks\nif a1>=0: l=max(l,b1)\nif a1<=0: r=min(r,b1)\nif a2>=0: l=max(l,b2)\nif a2<=0: r=min(r,b2)\n\nif l>r: print(0)\nelif l==r:\n # special case\n ans=1\n if b1!=l and (a1==0 or (l-b1)%a1 or (l-b1)//a1<0): ans=0\n if b2!=l and (a2==0 or (l-b2)%a2 or (l-b2)//a2<0): ans=0\n print(ans)\nelif (b1-b2)%gcd(a1,a2)!=0:\n # they don't intersect\n print(0)\nelse:\n # general case is the best case\n a3=abs((a1*a2)//gcd(a1,a2))\n b3=crt(b1,a1,b2,a2)\n # solve stuff easily now\n # python rounds down always\n l=(l-b3+a3-1)//a3\n r=(r-b3)//a3\n print(max(0,r-l+1))"}, {"source_code": "def upw(a,b):\n if a>0: return (a+b-1)/b\n a=-a\n return -(a/b)\ndef dwn(a,b):\n if a>0:return a/b\n a=-a;\n return -( (a+b-1)/b )\ndef xgcd(a,b):\n if(b==0): return [a,1,0];\n g,x1,y1=xgcd(b,a%b)\n return [g,y1,x1-(a/b)*y1];\n\na1,b1,a2,b2,l,r=map(long,raw_input().split())\nif b2<b1:\n a1,a2=a2,a1\n b1,b2=b2,b1\n\ng,x,y=xgcd(a1,a2)\nif (b2-b1)%g!=0: print(0)\nelse:\n x=x*( (b2-b1)/g )\n y=y*( (b2-b1)/g )\n li1=max(upw(-x*g,a2),upw(y*g,a1))\n li2=upw((l-a1*x-b1)*g,a1*a2)\n ls=dwn((r-a1*x-b1)*g,a1*a2)\n li=max(li1,li2) \n if li>ls: print(0)\n else: print(ls-li+1)\n"}, {"source_code": "def nod(a, b):\n if b == 0:\n return a, 1, 0\n else:\n answer, x, y = nod(b, a % b)\n x1 = y\n y1 = x - (a // b) * y\n return answer, x1, y1\n\n\na1, b1, a2, b2, l, r = list(map(int, input().split()))\ncoeff = b1\nb1, b2, l, r = b1 - coeff, b2 - coeff, max(l - coeff, 0), r - coeff\nl = max(b2, l)\nod, x1, y1 = nod(a1, -a2)\nif b2 % od != 0 or l > r:\n print(0)\nelse: \n x1, y1 = x1 * (b2 // od), y1 * (b2 // od)\n result = x1 * a1 \n raznitsa = a1 * a2 // nod(a1, a2)[0]\n otvet = 0\n if result < l:\n vsp = (l - result) // raznitsa\n if (l - result) % raznitsa != 0:\n vsp += 1\n result += vsp * raznitsa\n if result > r:\n vsp = (result - r) // raznitsa\n if (result - r) % raznitsa != 0:\n vsp += 1 \n result -= vsp * raznitsa \n if result <= r and result >= l:\n otvet += 1\n otvet += abs(result - r) // raznitsa\n otvet += abs(result - l) // raznitsa\n print(otvet) \n # 3 * (- 54) + 81 = \n"}, {"source_code": "def gcd(a, b):\n if (a == 0):\n return [0, 1, b];\n res = gcd(b%a, a);\n d = res[2]\n x1 = res[0]\n y1 = res[1]\n return [y1 - (b // a) * x1, x1, d];\n\ndef find_any_solution(a, b, c):\n res = gcd(abs(a), abs(b))\n g = res[2]\n x0 = res[0]\n y0 = res[1]\n if (c % g != 0):\n return [False, 0, 0, 0]\n x0 *= (c // g);\n y0 *= (c // g);\n if (a < 0):\n x0 = -x0;\n if (b < 0):\n y0 = -y0;\n return [True, x0, y0, g];\n# print(map(int, raw_input().split()))\na1, b1, a2, b2, L, R = map(int, raw_input().split())\nbo, l, r, g = find_any_solution(a1, a2, b2 - b1)\n# print(bo, l, r)\nif bo:\n aa = a1 * l + b1\n dd = (a1 * a2) // g\n bb = max(b1, b2)\n ll = (bb - aa + dd - 1) // dd\n aa = aa + dd * ll\n oo = max((L - aa + dd - 1) // dd, 0)\n op = (R - aa) // dd\n print(max(op - oo + 1, 0))\nelse:\n print(0)\n"}, {"source_code": "import sys\n\ndef gcd(x,y):\n if y==0: return (x,1,0)\n k = x//y\n g,a,b = gcd(y,x%y)\n return (g,b,a-b*k)\n\nread = lambda: (int(x) for x in sys.stdin.readline().split())\na1,b1,a2,b2,l,r = read()\nl = max(l,b1,b2)\nr = max(l,r+1)\ng,x,y = gcd(a1,a2)\nif (b1-b2)%g: print(0), exit(0)\na = a1*a2 // g\nb = b1 + (b2-b1)//g * x * a1\nb %= a\nlk = l // a + (l%a > b)\nrk = r // a + (r%a > b)\nprint(rk-lk)\n\n\n\n\n"}, {"source_code": "#!/usr/bin/env\tpython\n#-*-coding:utf-8 -*-\nimport math\na1,b1,a2,b2,l,r=map(int,input().split())\nif b1<l:b1=(b1-l)%a1+l\nif b2<l:b2=(b2-l)%a2+l\nc=a1//math.gcd(a1,a2)*a2\nm=min(1+r,c+max(b1,b2))\nwhile b1!=b2 and m>b1:\n\tif b1<b2:b1=(b1-b2)%a1+b2\n\telse:b2=(b2-b1)%a2+b1\nprint((m>b1)*(1+(r-b1)//c))\n"}, {"source_code": "MAXI = 2 * (10 ** 10)\n\ndef sign(x):\n return 1 if x >= 0 else -1\n\ndef cstyle_int(x):\n if x == 0:\n return 0\n s = 1 if x >= 0 else -1\n x = abs(x)\n return s * int(x)\n\ndef exgcd(a, b):\n if b == 0:\n return (a, 1, 0)\n (r, x, y) = exgcd(b, a % b)\n t = y\n y = x - (a / b) * y\n x = t\n return (r, x, y)\n\ndef solve(a1, b1, a2, b2, L, R):\n a, b, c = a2, b2 - b1, a1\n llx = sign(L - b1 + a1 - 1) * abs(L - b1 + a1 - 1) / a1\n rrx = sign(R - b1) * abs(R - b1) / a1\n\n if rrx < 0:\n return 0\n\n llx = max(llx, 0)\n rrx = max(rrx, 0)\n\n\n lly = sign(L - b2 + a2 - 1) * abs(L - b2 + a2 - 1) / a2\n rry = sign(R - b2) * abs(R - b2) / a2\n\n if rry < 0:\n return 0\n\n lly = max(lly, 0)\n rry = max(rry, 0)\n\n ll = c * llx - b\n rr = c * rrx - b\n\n ll = sign(ll + a - 1) * abs(ll + a - 1) / a\n rr = sign(rr) * abs(rr) / a\n\n ll = max(lly, ll)\n rr = min(rry, rr)\n #print rr, ll\n\n (r, w, v) = exgcd(a1, a2)\n w = -w\n\n\n if (b1 - b2) % r != 0:\n return 0\n else:\n base1 = (b1 - b2) / r * w * a1 + b1 \n base2 = (b1 - b2) / r * v * a2 + b2 \n assert base1 == base2\n base = base1\n\n lcm = a1 * a2 / r\n #print base, lcm\n #print '>>', ll, rr, (rr * a2 + b2), (ll * a2 + b2)\n base -= (base / lcm + 1) * lcm\n while base > 0:\n base -= lcm\n #print (rr * a2 + b2 - base) / lcm , (ll * a2 + b2 - 1 - base) / lcm\n ans = (rr * a2 + b2 - base) / lcm - (ll * a2 + b2 - 1 - base) / lcm\n return max(0, ans)\n\ndef brute_force(a1, b1, a2, b2, L, R):\n i = 0\n sa, sb = set(), set()\n while a1 * i + b1 <= R:\n if a1 * i + b1 >= L:\n sa.add(a1 * i + b1)\n i += 1\n\n i = 0\n while a2 * i + b2 <= R:\n if a2 * i + b2 >= L:\n sb.add(a2 * i + b2)\n i += 1\n return len(sa & sb)\n\n\ndef test(*args):\n assert solve(*args) == brute_force(*args)\n\nassert solve(2, 4, 3, 0, 6, 17) == 2\nassert solve(2, 0, 3, 3, 5, 21) == 3\nassert solve(2, 0, 3, 3, 5, 21) == brute_force(2, 0, 3, 3, 5, 21)\ntest(4, 2, 4, 4, 8, 200)\ntest(9, 2, 4, 4, 8, 200)\ntest(9, -2, 4, 4, 8, 200)\ntest(9, -2, 4, 4, -100, 200)\ntest(1412412, -112312, 3123412, 12313, -100, 200)\ntest(1, 0, 1, 0, -100, 200)\ntest(1, 0, 1, 0, 1, 1)\ntest(2, 0, 1, 0, 1, 1)\ntest(3, 8, 6, 8, -6, 0)\n\n'''\nimport random\nfor i in xrange(10000):\n a1 = random.randint(1, 10)\n a2 = random.randint(1, 10)\n b1 = random.randint(-10, 10)\n b2 = random.randint(-10, 10)\n L = random.randint(-10, 10)\n R = random.randint(-10, 10)\n L, R = min(L, R), max(L, R)\n print a1, b1, a2, b2, L, R\n test(a1, b1, a2, b2, L, R)\n\ntest(967, 339, 632, 339, -828, -275)\n\nprint 'OK'\n\n'''\n\nif __name__ == '__main__':\n (a1, b1, a2, b2, L, R) = map(int, raw_input().split())\n print solve(a1, b1, a2, b2, L, R)\n"}, {"source_code": "import math\n\na1, b1, a2, b2, l, r = map(int, input().split())\nif b1 < l:\n b1 = (b1 - l) % a1 + l\nif b2 < l:\n b2 = (b2 - l) % a2 + l\nc = a1 // math.gcd(a1, a2) * a2\nm = min(1 + r, c + max(b1, b2))\nwhile b1 != b2 and m > b1:\n if b1 < b2:\n b1 = (b1 - b2) % a1 + b2\n else:\n b2 = (b2 - b1) % a2 + b1\nprint((m > b1) * (1 + (r - b1) // c))\n"}, {"source_code": "import math \n\n# g, x, y\ndef gcd(a, b) :\n if a == 0 :\n return [b, 0, 1]\n l = gcd(b % a, a)\n g, x1, y1 = [int(i) for i in l]\n x = y1 - (b // a) * x1\n y = x1\n return [g, x, y]\n\ndef my_ceil(u, v) :\n if v < 0 :\n u *= -1\n v *= -1\n return math.ceil(u / v)\n\ndef my_floor(u, v) :\n if v < 0 :\n u *= -1\n v *= -1\n return math.floor(u / v)\n\na1, b1, a2, b2, L, R = [int(i) for i in input().split()]\nA = a1\nB = -a2\nC = b2 - b1\ng, x0, y0 = [int(i) for i in gcd(abs(A), abs(B))]\n\nif A < 0 : x0 *= -1\nif B < 0 : y0 *= -1\n\nif C % g != 0 :\n print(0)\n exit()\n\nx0 *= C // g\ny0 *= C // g\n\nle = max([\n float(R - b1 - a1 * x0) / float(a1 * B // g),\n float(y0 * a2 + b2 - R) / float(a2 * A // g)\n ])\n\nri = min([\n float(L - b1 - a1 * x0) / float(a1 * B // g),\n float(y0 * a2 + b2 - L) / float(a2 * A // g),\n float(-x0) / float(B // g),\n float(y0) / float(A // g)\n ])\n\nle = int(math.ceil(le))\nri = int(math.floor(ri))\n\nif ri - le + 1 <= 10000 :\n result = 0\n for k in range(le - 100, ri + 101) :\n X = x0 + B * k // g\n Y = y0 - A * k // g\n if X >= 0 and Y >= 0 and a1 * X + b1 >= L and a1 * X + b1 <= R :\n result += 1\n print(result)\nelse : \n print(max(int(0), ri - le + 1))\n"}, {"source_code": "from fractions import gcd\na1,b1,a2,b2,l,r=map(int,input().split())\n\nif b1<l:\n b1=(b1-l)%a1+l\nif b2<l:\n b2=(b2-l)%a2+l\nks1=(l-b1)/a1\nke1=(r-b1)/a1\nks2=(l-b2)/a2\nke2=(r-b2)/a2\n\ng=gcd(a1,a2)\nvar=a1/g*a2\nlst1=[]\nlst2=[]\nks1=max(b1,b2)\n\nm=min(1+r,var+ks1)\nwhile b1!=b2 and m>b1:\n if b1<b2:\n b1=(b1-b2)%a1+b2\n else:\n b2=(b2-b1)%a2+b1\nif(m>b1):\n print (int(1+(r-b1)//var))\nelse:\n print (\"0\")\n\n\n\n"}, {"source_code": "def extgcd(a, b):\n x, y = 0, 0\n d = a;\n if b != 0:\n d, y, x = extgcd(b, a%b)\n y -= (a//b) * x\n else:\n x, y = 1, 0\n return (d, x, y)\n\ndef main():\n a1, b1, a2, b2, L, R = map(int, input().split())\n g, k, l = extgcd(a1, a2);\n b = b2-b1;\n if (b%g != 0):\n print (0)\n return\n k *= b//g\n l *= -b//g\n low = -2**100\n high = 2**100\n while high-low > 1:\n med = (low+high)//2\n tk = k+med*a2//g\n tl = l+med*a1//g\n if (tk >= 0 and tl >= 0):\n high = med\n else:\n low = med\n k = k+high*a2//g\n x = a1*k+b1\n low = -1\n high = 2**100\n lcm = a1*a2//g\n while high - low > 1:\n med = (low+high)//2\n tx = x+med*lcm\n if tx >= L:\n high = med\n else:\n low = med\n x = x+high*lcm\n low = 0\n high = 2**100\n while high-low > 1:\n med = (low+high)//2\n tx = x+med*lcm\n if (tx <= R):\n low = med\n else:\n high = med\n if low == 0 and x > R:\n print (0)\n return\n print (low+1)\n return\n\nif __name__==\"__main__\":\n main()"}, {"source_code": "import math\ndef xgcd (b,n) :\n x0,x1,y0,y1 = 1,0,0,1\n while n != 0 :\n q,b,n = b//n , n , b % n\n x0,x1 = x1, x0-q*x1\n y0,y1 = y1,y0-q*y1\n return b,x0,y0\na,aa,b,bb,l,r = [int (x) for x in input ().split ()]\ng,x,y=xgcd (a,b)\nc = bb-aa\n#print(\"c\",c,g)\nif c%g != 0 :\n print (0)\n exit (0)\n# ax-by = cc = bb-aa\n# ax-by = g(cc) = bb-aa\n#print(x,y)\ni = a*(x*c)//g+aa\nii = (-b*(y*c)//g)+bb\n#print(a*x//g*c,b*y//g*c,aa,bb)\nstep = a*b//g\n#print(a,x,c , \" | \",b,y,c)\n#print(i,ii,step)\nif (ii-i) % step != 0 : \n print(0)\n exit(0)\n#print(a,x,c,aa)\n\n#print(i,ii,step)\n# shift i to la,lb\n#print(i,aa,bb)\nif i > max(aa,bb) :\n #print(i-max(aa,bb),step)\n i -= ((i-max(aa,bb))//step) * step\nelif i < max(aa,bb) :\n i += ((max(aa,bb)-i)//step + (1 if (max(aa,bb)-i)%step!=0 else 0)) * step\n\nf = (l-i)//step\nif (l-i) % step != 0 : f+=1\nf = max(f,0)\ns = (r-i)//step\n#print(i,step,f,s)\nprint (max(0,s-f+1))"}, {"source_code": "import sys\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n# ax+by=c\ndef extgcd(a, b, c):\n if b == 0: return c, 0\n x, y = extgcd(b, a % b, c)\n return y, x - a // b * y\n\ndef first_term(a1, b1, a2, b2):\n g = gcd(a1, a2)\n T = lcm(a1, a2)\n\n # s*a1+t*a2=b2-b1\n if (b2 - b1) % g != 0: return -(10 ** 100)\n x0 = extgcd(a1 // g, a2 // g, (b2 - b1) // g)[0] * a1 + b1 - T * 10 ** 30\n\n ok = 10 ** 60\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\n return x0 + ok * T\n\ndef f(a0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if a0 + T * mid >= v:\n ok = mid\n else:\n ng = mid\n\n return ok\n\na1, b1, a2, b2, L, R = map(int, input().split())\n\nT = lcm(a1, a2)\na0 = first_term(a1, b1, a2, b2)\n\nif a0 == -(10 ** 100):\n print(0)\n sys.exit()\n\nprint(f(a0, T, R + 1) - f(a0, T, L))"}, {"source_code": "from collections import defaultdict\nimport sys, os, math\n\ndef gcd(a1, a2):\n if a2 == 0:\n return a1\n else:\n return gcd(a2, a1 % a2)\n \n# return (g, x, y) a*x + b*y = gcd(x, y)\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, x, y = egcd(b % a, a)\n return (g, y - (b // a) * x, x)\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n a1, b1, a2, b2, L, R = map(int, input().split())\n a2 *= -1 \n LCM = a1 * a2 // gcd(a1, a2)\n if abs(b1 - b2) % gcd(a1, a2) != 0:\n print(0)\n sys.exit(0)\n L = max([b1, b2, L])\n g, x, y = egcd(a1, a2)\n X = a1 * x * (b2 - b1) // g + b1\n X += LCM * math.ceil((L - X) / LCM)\n if L <= X <= R:\n print(max(0, (R - X) // LCM + 1))\n else:\n print(0)"}, {"source_code": "#from IPython import embed\n\ndef xgcd(b, n):\n x0, x1, y0, y1 = 1, 0, 0, 1\n while n != 0:\n q, b, n = b // n, n, b % n\n x0, x1 = x1, x0 - q * x1\n y0, y1 = y1, y0 - q * y1\n return b, x0, y0\n\ndef ffloor(a, b):\n\tif(b < 0): return ffloor(-a,-b);\n\treturn a//b\ndef cceil( a, b):\n\tif(b < 0): return cceil(-a,-b);\n\tif a % b == 0: \n\t\treturn a//b\n\treturn a//b+1;\n\t\n\n\ndef main():\n\ts = input()\n\ta1, b1, a2, b2, L, R = [int(i) for i in s.split()]\n\n\tif b2 < b1:\n\t\ta1, a2 , b1, b2 = a2, a1 , b2, b1\n\n\td,x,y = xgcd(a1,-a2)#extended_gcd(a1,-a2)\n\tif(d < 0):\n\t\td *= -1\n\t\tx *= -1\n\t\ty *= -1\n\t\n\tif (b2 - b1) % d != 0: \n\t\tprint(0)\n\t\treturn\n\n\t#print(d,x,y)\n\tfact = (b2-b1)//d\n\tx *= fact\n\ty *= fact\n\n\tc1 = a2//d;\n\tc2 = a1//d;\n\n\n\ttope1 = ffloor(R-b1-a1*x, a1*c1);\n\tbajo1 = cceil(L-b1-a1*x,c1*a1);\n\tbajo2 = cceil(L-b2-a2*y,c2*a2);\n\ttope2 = ffloor(R-b2-a2*y, a2*c2);\n\n\tbajo3 = max(cceil(-x,c1),cceil(-y,c2));\n\n\tbajo = max(bajo1,bajo2,bajo3);\n\ttope = min(tope1,tope2);\n\tprint(max(0,tope+1-bajo))\n\t#embed()\nmain()"}, {"source_code": "#from IPython import embed\ndef mod(a, b):\n\tif b < 0:\n\t\treturn mod(a,-b)\n\tif a >